Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fundamental-react

SAP2.3kApache-2.00.14.5TypeScript support: included

SAP Fundamental Library, implemented in React

readme

Fundamental React

REUSE status npm version Minified Size
Minzipped Size Build Status Coverage Status Slack

Deploys by Netlify

Description

The fundamental-react library is a set of React components built using SAP Fundamental Styles.

The Fundamental Styles library is a design system and HTML/CSS component library used to build modern product user experiences with the SAP look and feel.

API Reference

See Component Documentation for examples and API details.

Requirements

You will need to install Node and Node Package Manager.

Polyfills

Fundamental React requires a polyfill for:

You will need to add your own polyfills. See core-js for instructions.

Getting Started

For an existing react application, follow the steps below:

  1. Install fundamental-react.

     npm install fundamental-react
  2. All components are currently packaged together with their respective css, you will need to edit your webpack configuration to handle these files. See css-loader.

  3. Import components as needed. See Component Documentation for examples and API details.

     import { MessageStrip } from 'fundamental-react/lib/MessageStrip';

    or

     import { MessageStrip } from 'fundamental-react';

    NOTE: Importing from specific component is recommended. Doing so will bring in only the component you are using instead of the whole library, which will reduce your bundle size significantly.

  1. This project does not contain fonts and icons - they must be added to your project separately. Download Font 72 and SAP icons. After adding fonts and icons to your project, include the following in your css:
    @font-face {
        font-family: "72";
        src: url("path/to/fonts") format("woff"); /* Bold, Light, Regular available in woff and woff2 */
        font-weight: normal;
        font-style: normal;
    };

    @font-face {
        font-family: "SAP-icons";
        src: url("path/to/icons") format("woff"); /* available in woff, woff2 and ttf */
        font-weight: normal;
        font-style: normal;
    }

Additionally, edit your webpack configuration to load font and icon fonts - see file-loader.

All styles are based on rem units. Include the following in your CSS to ensure components are sized correctly:

    html {
        font-size: 16px;
    }

Versioning

The fundamental-react library follows Semantic Versioning. These components strictly adhere to the [MAJOR].[MINOR].[PATCH] numbering system (also known as [BREAKING].[FEATURE].[FIX]).

Merges to the main branch will be published as a prerelease. Prereleases will include an rc version (e.g. [MAJOR].[MINOR].[PATCH]-rc.[RC]).

The following circumstances will be considered a BREAKING change:

  • A component’s existing API is altered (with the exception of additions)
  • The existing underlying HTML markup of a component is altered
  • An existing unit test is altered to account for either of the above

The following circumstances will NOT be considered a BREAKING change:

  • Additions to a component’s API
  • Non-visual HTML attribute changes/additions (such as role, aria-*, data-*)
  • An existing unit test is altered to account for non-visual HTML attribute changes/additions (such as role, aria-*, data-*)

CSS Modules

This library supports css-modules. The motivation for this support is to be able to include multiple versions or instances of fundamental styles on the same page without collisions in styles. This can be useful if you have a page using fundamental-ngx alongside fundamental-react, for example.

One way to use fundamental-react with hashed class names is to pass the library code through css-loader in your webpack config

// If you have an existing css rule
{
    test: /.css$/,
    exclude: [
        /node_modules\/fundamental-styles/
    ],
    use: [
        'style-loader',
        'css-loader'
    ]
},
// run css-loader with modules enabled for css files from fundamental-styles
{
    test: /.css$/,
    include: [
        /node_modules\/fundamental-styles/
    ],
    use: [
        'style-loader',
        {
            loader: 'css-loader',
            options: {
                modules: {
                    localIdentName: '[local]-[sha1:hash:hex:6]'
                }
            }
        }
    ]
},

It's important to include [local] in the localIdentName which keeps the class name in the hash. This is because some of the style rules in fundamental-styles reference the name of the class, like [class*=level].

Known Issues

Please see Issues.

Support

If you encounter an issue or want to request a feature, you can create an issue.

Contributing

If you want to contribute, please check the Contribution Guidelines. Also see our Developer Guide to Getting Started.

Similar Projects

Tips for fundamental-react project developers

For the MAC M1 user, to Set up your local dev environment, you need to run the project under node x86.

changelog

0.14.5 (2023-06-26)

0.14.5-rc.13 (2023-06-26)

0.14.5-rc.12 (2023-03-06)

0.14.5-rc.11 (2023-02-08)

Bug Fixes

0.14.5-rc.10 (2023-02-08)

Bug Fixes

  • storybook deployment lack FD theming css (#1480) (31e8488)

0.14.5-rc.9 (2023-02-08)

Bug Fixes

  • popover position && no arrow styles (#1477) (ad0e0d4)
  • trigger build (#1479) (ddd2a36)
  • update readme and re-trigger build rc version due to last time failed by commit name lint (#1478) (5cf3327)

0.14.5-rc.8 (2023-02-07)

Bug Fixes

0.14.5-rc.7 (2023-02-07)

Bug Fixes

0.14.5-rc.6 (2023-02-07)

Features

0.14.5-rc.5 (2023-02-06)

Bug Fixes

  • upgrade fd-styles to latest and fix components due to broken changes from fd-styles (#1471) (6e58a23)

Broken changes

There are some broken changes caused by fundamental-styles's upgrade (if your test case rely on the class or x-path , you may need to change that):

  • Popover: Changed .fd-popover__popper to .fd-popover__body Changed .fd-popover__innerRef to .fd-popover__innerRef
  • Calendar: Ad one more fd-calendar__content--dates besides .fd-calendar__content

  • Loading Indicator: .fd-busy-indicator--circle-0 to .fd-busy-indicator__circle .fd-busy-indicator--circle-1 to .fd-busy-indicator__circle .fd-busy-indicator--circle-2 to .fd-busy-indicator__circle

  • Shell bar: .fd-counter .fd-counter--notification .fd-shellbar__counter--notification to .fd-badge

0.14.5-rc.4 (2022-11-08)

Features

0.14.5-rc.3 (2022-11-07)

Features

  • add an option to fire onclick event on actions menu, revert compact option for product switch (#1454) (833da87)
  • add onclick event on actions, revert compact option for product switch (#1458) (ec68eb0)

0.14.5-rc.2 (2022-11-03)

Features

  • add compact option to product menu, remove console errors (#1446) (f618ab5)

0.14.5-rc.1 (2022-09-05)

Features

0.14.5-rc.0 (2022-07-05)

0.14.4 (2022-06-01)

0.14.4-rc.0 (2022-05-30)

Features

0.14.3 (2022-04-26)

0.14.3-rc.0 (2022-04-26)

Features

0.14.2 (2022-04-26)

0.14.2-rc.1 (2022-04-25)

0.14.2-rc.0 (2022-04-08)

Bug Fixes

  • type definition of dialog headers and allowListForLockFocus (#1410) (a502255)

0.14.1 (2022-02-12)

0.14.1-rc.2 (2022-02-12)

Bug Fixes

  • restore scroll position after fialog closes (#1397) (a3d948a)

0.14.1-rc.1 (2022-02-12)

Features

Bug Fixes

  • added fix to support the behavior of twelve hour timepicker format if seconds not passed" (#1392) (37b4b46)

0.14.1-rc.0 (2021-12-02)

Bug Fixes

0.14.0 (2021-12-01)

0.14.0-rc.36 (2021-11-03)

Bug Fixes

  • check explicitly if typedValue is a string (#1378) (3120c39)

0.14.0-rc.35 (2021-10-21)

Features

0.14.0-rc.34 (2021-10-04)

0.14.0-rc.33 (2021-10-03)

0.14.0-rc.32 (2021-09-28)

0.14.0-rc.31 (2021-09-21)

0.14.0-rc.30 (2021-09-20)

Features

0.14.0-rc.29 (2021-08-18)

Features

0.14.0-rc.28 (2021-07-21)

Bug Fixes

0.14.0-rc.27 (2021-06-13)

0.14.0-rc.26 (2021-06-08)

0.14.0-rc.25 (2021-06-04)

0.14.0-rc.24 (2021-05-22)

0.14.0-rc.23 (2021-05-07)

0.14.0-rc.22 (2021-04-29)

0.14.0-rc.21 (2021-04-29)

0.14.0-rc.20 (2021-04-25)

0.14.0-rc.19 (2021-03-13)

0.14.0-rc.18 (2021-03-13)

0.14.0-rc.17 (2021-03-10)

0.14.0-rc.16 (2021-01-21)

0.14.0-rc.15 (2021-01-20)

Bug Fixes

0.14.0-rc.14 (2021-01-07)

0.14.0-rc.13 (2021-01-07)

0.14.0-rc.12 (2020-12-22)

0.14.0-rc.11 (2020-12-22)

0.14.0-rc.10 (2020-12-01)

Features

  • update dependencies and upgrade to react@17 (#1269) (44c1948)

0.14.0-rc.9 (2020-11-21)

0.14.0-rc.8 (2020-11-21)

Features

  • update fundamental-styles to 0.13.1-rc.2 (#1266) (60cbc68)

0.14.0-rc.7 (2020-11-16)

Features

0.14.0-rc.6 (2020-11-09)

Bug Fixes

0.14.0-rc.5 (2020-11-06)

Bug Fixes

  • Datepicker today actions props interface (#1259) (74ba734)

BREAKING CHANGES

  • Removed todayAction property from Datepicker. Add todayActionType property to Datepicker to configure the type of today action. Update Datepicker to use a label for the Today action button from localizedText.todayLabel.

0.14.0-rc.4 (2020-11-05)

Bug Fixes

  • Call DatePicker buttonProps.onClick when button is clicked (#1258) (a6a5d95)

0.14.0-rc.3 (2020-11-05)

Features

BREAKING CHANGES

  • form-select component has been removed

  • feat: update fd-styles to 0.13.0-rc.34

  • chore: update storybook tests

  • chore: remove FormSelect from index

0.14.0-rc.2 (2020-11-05)

0.14.0-rc.1 (2020-10-20)

Features

0.14.0-rc.0 (2020-10-19)

Features

  • Make Calendar disabledDates an array of single dates, use disabledDateRanges for existing functionality (#1244) (84b8927)

BREAKING CHANGES

  • The DatePicker and Calendar prop disabledDates is no longer considered as a range, instead it is an array of single disabled dates. The disableDateRanges prop can be used for existing functionality to disable multiple ranges.

0.13.1 (2020-10-19)

0.13.1-rc.17 (2020-10-16)

0.13.1-rc.16 (2020-10-16)

Features

  • new innerRefClassName prop as part of validationOverlayProps (#1242) (59ebaa1)

0.13.1-rc.15 (2020-10-14)

Bug Fixes

0.13.1-rc.14 (2020-10-13)

Features

0.13.1-rc.13 (2020-10-12)

Bug Fixes

Features

  • Hide the DatePicker button when readOnly is true (#1234) (80bb5d6)

0.13.1-rc.12 (2020-10-11)

Features

0.13.1-rc.11 (2020-10-08)

Bug Fixes

  • Fix isCssModulesEnabled check and improve README for css-modules (#1237) (7b90a32)

Features

0.13.1-rc.10 (2020-10-06)

Features

0.13.1-rc.9 (2020-10-05)

0.13.1-rc.8 (2020-10-02)

Bug Fixes

0.13.1-rc.7 (2020-10-01)

Bug Fixes

0.13.1-rc.6 (2020-09-29)

Bug Fixes

Features

0.13.1-rc.5 (2020-09-28)

Features

0.13.1-rc.4 (2020-09-24)

Bug Fixes

0.13.1-rc.3 (2020-09-24)

Features

  • cell-level keyboard navigation for Table (#1211) (2f82eef)

0.13.1-rc.2 (2020-09-24)

0.13.1-rc.1 (2020-09-24)

Features

  • update fundamental-styles to 0.12.0-rc.64 (#1215) (a2d8369)

0.13.1-rc.0 (2020-09-23)

Features

  • SearchInput as a functional comp with forwarded ref (#1218) (03659ff)

0.13.0 (2020-09-21)

0.13.0-rc.22 (2020-09-21)

Bug Fixes

  • refine and document component event callbacks (#1210) (42391f9)

BREAKING CHANGES

  • In this change we
  • improve the callback API for various components
    • Calendar.onChange - added todayPressed param which is true only if the change was caused by the today button
    • ComboboxInput - Forwarded reference now contains both button (ref.current.button) and input (ref.current.input) refs
    • ComboboxInput.onSelectionChange - added reason string param which represents what caused the selection to change
    • ComboboxInput.selectedKey should work now
    • DatePicker - added startAndEndDates array to callback data which contains start and end dates when ranged selection is enabled, else it is an empty array
    • DatePicker.onChange - added reason string param which represents what caused the selection to change
    • DatePicker.onFocus changed to DatePicker.onInputFocus
    • DatePicker.onBlur changed to DatePicker.onInputBlur
    • Dialog.onClose now contains the event param
    • FormRadioItem.data property added which is available in the FormRadioGroup.onChange's callback
    • ListSelection and it's parent ListItem now self manage their selected states based on internal checkbox onChange events
    • SearchInput.onEnter should work now
  • update tests accordingly
  • document the callback API using JSDoc syntax
  • wire-up @storybook/actions to log callback events in the dev stories of these components

0.13.0-rc.21 (2020-09-15)

Features

  • update fundamental-styles to 0.12.0-rc.44 (#1203) (0c0cce7)

0.13.0-rc.20 (2020-09-15)

Bug Fixes

0.13.0-rc.19 (2020-09-11)

0.13.0-rc.18 (2020-09-08)

Bug Fixes

  • multiple validationState messages + popover validation message styles (#1196) (dd769c9)

0.13.0-rc.17 (2020-09-08)

0.13.0-rc.16 (2020-09-08)

0.13.0-rc.15 (2020-09-04)

Bug Fixes

0.13.0-rc.14 (2020-09-02)

Features

0.13.0-rc.13 (2020-09-02)

Features

0.13.0-rc.12 (2020-09-01)

Features

  • add additional props for customization to validationOverlayProps (#1192) (ebbbd31)

0.13.0-rc.11 (2020-09-01)

Bug Fixes

  • fundamental Switch state doesn't refresh (#1193) (1a7ac92)

0.13.0-rc.10 (2020-08-31)

Features

  • update fundamental-styles to v0.12.0-rc.18 (#1172) (efb2d17)

BREAKING CHANGES

  • In this change we
  • Update fundamental-styles to 0.12.0-rc.18 and support the new features and fixes therein.

    • Removed LayoutGrid component in favor of the new grid system based on Container, Row, and Column components
    • Remove LayoutPanel.colSpan property; added story for LayoutPanel in the new grid system.
    • Removed the TreeViewcomponent in favor of the new Tree component.
    • Shellbar avatar now has a branded border.
  • Docs/Storybook:

    • update storybook to v6.0.16
    • fix missing storyDescriptions and component descriptions.
    • Add copy button to easily copy import statements to clipboard.

0.13.0-rc.9 (2020-08-31)

chore

BREAKING CHANGES

  • removed unused spinners prop from TimePicker and Time components

0.13.0-rc.8 (2020-08-27)

Bug Fixes

  • select onfocus onblur callbacks called at appropriate times (#1186) (f9e1282)

0.13.0-rc.7 (2020-08-26)

0.13.0-rc.6 (2020-08-26)

Bug Fixes

  • remove detect-browser from package.json, bump standard version and run audit fix (#1187) (c2c952f)

Features

0.13.0-rc.5 (2020-08-26)

Features

  • normalize FormValidationOverlay usage in other components (#1183) (1baafc8)

0.13.0-rc.4 (2020-08-25)

Features

0.13.0-rc.3 (2020-08-21)

Features

  • BREAKING CHANGE: checkbox replace state with validation states (#1176) (9a71277)

BREAKING CHANGES

  • Checkbox: replace state property with validationState

0.13.0-rc.2 (2020-08-20)

0.13.0-rc.1 (2020-08-19)

Bug Fixes

BREAKING CHANGES

  • Checkbox component now sets the className value on the FormItem component that wraps the input; instead of on the input itself. This is consistent with the behavior in other Form components.

0.13.0-rc.0 (2020-08-18)

Bug Fixes

BREAKING CHANGES