@nulogy/components 15.2.1 → 15.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/main.js +53108 -54055
- package/dist/main.module.js +8809 -9756
- package/dist/src/Alert/Alert.js +2 -14
- package/dist/src/Alert/Alert.story.d.ts +15 -19
- package/dist/src/Alert/Alert.story.js +25 -14
- package/dist/src/AppTag/components/LogoWrapper.d.ts +0 -1
- package/dist/src/AppTag/components/NulogyLogo.js +2 -14
- package/dist/src/AsyncSelect/AsyncSelect.graphql.story.js +4 -13
- package/dist/src/AsyncSelect/AsyncSelect.js +14 -16
- package/dist/src/AsyncSelect/AsyncSelectComponents.js +9 -21
- package/dist/src/AsyncSelect/fixtures.js +4 -13
- package/dist/src/Banner/Banner.js +1 -15
- package/dist/src/BottomSheet/BottomSheet.js +2 -15
- package/dist/src/BottomSheet/BottomSheet.parts.d.ts +2 -2
- package/dist/src/BottomSheet/BottomSheet.parts.js +8 -22
- package/dist/src/BottomSheet/BottomSheet.styled.d.ts +4 -5
- package/dist/src/Box/Box.d.ts +12 -4
- package/dist/src/BrandedNavBar/DesktopMenu.js +22 -36
- package/dist/src/BrandedNavBar/MenuTrigger.js +4 -16
- package/dist/src/BrandedNavBar/MenuTriggerButton.js +8 -22
- package/dist/src/BrandedNavBar/MobileMenu.js +28 -35
- package/dist/src/BrandedNavBar/NavBar.js +7 -21
- package/dist/src/BrandedNavBar/NavBar.story.d.ts +4 -6
- package/dist/src/BrandedNavBar/NavBar.story.js +12 -4
- package/dist/src/BrandedNavBar/NavBarBackground.d.ts +0 -1
- package/dist/src/BrandedNavBar/NavBarDropdownMenu.js +14 -8
- package/dist/src/BrandedNavBar/SmallNavBar.js +4 -16
- package/dist/src/BrandedNavBar/SmallNavBar.story.d.ts +5 -2
- package/dist/src/BrandedNavBar/SmallNavBar.story.js +27 -6
- package/dist/src/BrandedNavBar/SubMenuTrigger.js +4 -16
- package/dist/src/BrandedNavBar/SubMenuTriggerButton.js +2 -14
- package/dist/src/BrandedNavBar/renderSubMenuItems.js +7 -17
- package/dist/src/Branding/Branding.js +2 -14
- package/dist/src/Branding/BrandingText.d.ts +0 -1
- package/dist/src/Branding/LettermarkLogo.js +2 -14
- package/dist/src/Branding/WordmarkLogo.js +2 -14
- package/dist/src/Breadcrumbs/Breadcrumbs.js +2 -14
- package/dist/src/Breadcrumbs/BreadcrumbsList.d.ts +0 -1
- package/dist/src/Breadcrumbs/BreadcrumbsListItem.d.ts +0 -1
- package/dist/src/Button/Button.js +2 -14
- package/dist/src/Button/CloseButton.js +1 -1
- package/dist/src/Button/ControlIcon.js +2 -16
- package/dist/src/Button/DangerButton.d.ts +0 -1
- package/dist/src/Button/IconicButton.js +55 -73
- package/dist/src/Button/PrimaryButton.d.ts +0 -1
- package/dist/src/Button/QuietButton.d.ts +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.d.ts +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.js +8 -2
- package/dist/src/Card/Card.js +2 -14
- package/dist/src/Card/Card.story.js +1 -1
- package/dist/src/Card/CardSet.d.ts +0 -1
- package/dist/src/Checkbox/Checkbox.js +20 -6
- package/dist/src/Checkbox/Checkbox.story.js +4 -1
- package/dist/src/Checkbox/CheckboxGroup.js +4 -16
- package/dist/src/DatePickers/DatePicker.js +2 -14
- package/dist/src/DatePickers/MonthPicker.js +2 -14
- package/dist/src/DatePickers/WeekPicker.js +10 -17
- package/dist/src/DatePickers/custom/weekPickerStyles.d.ts +0 -1
- package/dist/src/DatePickers/shared/components/BasePicker.js +9 -15
- package/dist/src/DatePickers/shared/components/DatePickerInput.js +2 -13
- package/dist/src/DatePickers/shared/styles.d.ts +0 -1
- package/dist/src/DatePickers/shared/types.d.ts +0 -1
- package/dist/src/DatePickers/stories/DatePicker.story.d.ts +7 -3
- package/dist/src/DatePickers/stories/DatePicker.story.js +54 -22
- package/dist/src/DatePickers/stories/WeekPicker.story.js +1 -1
- package/dist/src/DateRange/DateRange.js +36 -22
- package/dist/src/DateRange/DateRangeStyles.d.ts +0 -1
- package/dist/src/DateRange/EndTime.d.ts +3 -4
- package/dist/src/DateRange/StartTime.d.ts +3 -4
- package/dist/src/Decorations/index.js +1 -1
- package/dist/src/DescriptionList/DescriptionList.js +1 -13
- package/dist/src/DescriptionList/DescriptionList.parts.d.ts +0 -1
- package/dist/src/DescriptionList/DescriptionList.parts.js +156 -77
- package/dist/src/DescriptionList/DescriptionListContext.js +1 -15
- package/dist/src/DescriptionList/lib/utils.js +1 -1
- package/dist/src/DescriptionList/stories/DescriptionList.column.story.js +1 -1
- package/dist/src/DescriptionList/stories/DescriptionList.group-min-width.story.d.ts +7 -8
- package/dist/src/DescriptionList/stories/DescriptionList.group-min-width.story.js +15 -12
- package/dist/src/DescriptionList/stories/DescriptionList.layout.story.js +1 -1
- package/dist/src/DescriptionList/stories/DescriptionList.playground.story.d.ts +7 -8
- package/dist/src/DescriptionList/stories/DescriptionList.playground.story.js +203 -195
- package/dist/src/DescriptionList/stories/fixtures.d.ts +2 -2
- package/dist/src/Divider/Divider.d.ts +0 -1
- package/dist/src/DropdownMenu/DropdownItem.d.ts +0 -1
- package/dist/src/DropdownMenu/DropdownMenu.js +13 -17
- package/dist/src/DropdownMenu/DropdownMenu.story.js +2 -2
- package/dist/src/DropdownMenu/DropdownMenuContainer.d.ts +0 -1
- package/dist/src/DropdownMenu/DropdownMenuContainer.js +10 -1
- package/dist/src/DropdownMenu/DropdownText.d.ts +1 -2
- package/dist/src/FieldLabel/FieldLabel.js +2 -14
- package/dist/src/FieldLabel/HelpText.d.ts +1 -2
- package/dist/src/FieldLabel/LabelText.d.ts +0 -1
- package/dist/src/FieldLabel/MaybeFieldLabel.js +1 -15
- package/dist/src/FieldLabel/RequirementText.js +1 -1
- package/dist/src/Flex/Flex.d.ts +0 -1
- package/dist/src/Flex/Flex.story.js +3 -17
- package/dist/src/Form/Field.d.ts +0 -1
- package/dist/src/Form/Fieldset.d.ts +0 -1
- package/dist/src/Form/Form.js +3 -17
- package/dist/src/Form/FormSection.js +3 -17
- package/dist/src/Icon/Icon.js +9 -24
- package/dist/src/Icon/LoadingIcon.js +2 -14
- package/dist/src/Input/Input.js +3 -15
- package/dist/src/Input/InputField.js +4 -16
- package/dist/src/Input/Prefix.js +2 -16
- package/dist/src/Input/Suffix.js +2 -14
- package/dist/src/Layout/ApplicationFrame.js +2 -14
- package/dist/src/Layout/Header.d.ts +1 -1
- package/dist/src/Layout/Header.js +4 -17
- package/dist/src/Layout/Header.story.d.ts +10 -9
- package/dist/src/Layout/Header.story.js +9 -8
- package/dist/src/Layout/Page.js +5 -19
- package/dist/src/Layout/Sidebar.js +4 -18
- package/dist/src/Layout/Sidebar.story.d.ts +4 -1
- package/dist/src/Layout/Sidebar.story.js +24 -31
- package/dist/src/Link/Link.js +13 -21
- package/dist/src/List/List.d.ts +0 -1
- package/dist/src/Modal/Modal.story.d.ts +39 -61
- package/dist/src/Modal/Modal.story.js +110 -85
- package/dist/src/Modal/ModalCloseButton.d.ts +0 -1
- package/dist/src/Modal/ModalFooter.d.ts +0 -1
- package/dist/src/Modal/ModalHeader.d.ts +0 -1
- package/dist/src/NDSProvider/ComponentVariantContext.js +1 -1
- package/dist/src/NDSProvider/GlobalStyles.d.ts +0 -1
- package/dist/src/NDSProvider/ModalStyleOverride.d.ts +0 -1
- package/dist/src/NDSProvider/Reset.d.ts +0 -1
- package/dist/src/NDSProvider/renderWithNDSProvider.spec-utils.d.ts +3 -1
- package/dist/src/NDSProvider/renderWithNDSProvider.spec-utils.js +3 -1
- package/dist/src/NavBarSearch/NavBarSearch.js +2 -14
- package/dist/src/Navigation/Navigation.js +3 -16
- package/dist/src/Navigation/components/AppSwitcher/NulogyAppSwitcher.js +6 -3
- package/dist/src/Navigation/components/AppSwitcher/parts/Item.js +1 -15
- package/dist/src/Navigation/components/AppSwitcher/parts/Link.js +2 -16
- package/dist/src/Navigation/components/AppSwitcher/parts/index.d.ts +4 -5
- package/dist/src/Navigation/components/DesktopNav/DesktopNav.js +2 -2
- package/dist/src/Navigation/components/MenuSubItem/MenuSubItem.js +4 -5
- package/dist/src/Navigation/components/MenuSubItem/parts/styled.d.ts +0 -1
- package/dist/src/Navigation/components/MenuSubItem/parts/styled.js +49 -7
- package/dist/src/Navigation/components/MobileNav/MobileNav.js +2 -2
- package/dist/src/Navigation/components/MobileNav/parts/MobileMenuItem.js +12 -21
- package/dist/src/Navigation/components/MobileNav/parts/styled.d.ts +1 -2
- package/dist/src/Navigation/components/MobileNav/parts/styled.js +35 -4
- package/dist/src/Navigation/components/NulogyLogo/SvgNulogyLogo.js +1 -1
- package/dist/src/Navigation/components/UserMenu/UserMenu.d.ts +0 -1
- package/dist/src/Navigation/components/UserMenu/parts/Header.js +1 -1
- package/dist/src/Navigation/components/UserMenu/parts/Item.js +7 -16
- package/dist/src/Navigation/components/UserMenu/parts/MobileItem.js +7 -16
- package/dist/src/Navigation/components/UserMenu/parts/styled.d.ts +0 -1
- package/dist/src/Navigation/components/UserMenu/parts/styled.js +43 -18
- package/dist/src/Navigation/components/shared/NavigationLogo.js +4 -16
- package/dist/src/Navigation/components/shared/NavigationLogoLink.js +2 -14
- package/dist/src/Navigation/components/shared/NavigationMenuContent.d.ts +0 -1
- package/dist/src/Navigation/components/shared/NavigationMenuItem.js +10 -24
- package/dist/src/Navigation/components/shared/components.d.ts +0 -1
- package/dist/src/Navigation/components/shared/components.js +29 -5
- package/dist/src/Navigation/hooks/useResponsiveMenu.d.ts +0 -1
- package/dist/src/Navigation/stories/Navigation.mobileVisibility.story.js +21 -9
- package/dist/src/Navigation/stories/fixtures/logos/CustomLogo2.js +1 -1
- package/dist/src/Navigation/stories/fixtures/logos/CustomLogo3.js +1 -1
- package/dist/src/Navigation/stories/fixtures/logos/Customlogo1.js +1 -1
- package/dist/src/Overlay/Overlay.d.ts +0 -1
- package/dist/src/Pagination/PageNumber.d.ts +0 -1
- package/dist/src/Pagination/Pagination.js +3 -16
- package/dist/src/Pagination/PaginationButton.d.ts +0 -1
- package/dist/src/Popper/Popper.js +29 -6
- package/dist/src/Primitives/index.d.ts +0 -1
- package/dist/src/Radio/Radio.js +11 -18
- package/dist/src/Radio/Radio.story.d.ts +322 -32
- package/dist/src/Radio/Radio.story.js +36 -22
- package/dist/src/Radio/RadioGroup.js +4 -16
- package/dist/src/RangeContainer/RangeContainer.js +6 -15
- package/dist/src/Select/MenuList.js +14 -19
- package/dist/src/Select/Select.d.ts +2 -2
- package/dist/src/Select/Select.js +16 -17
- package/dist/src/Select/Select.spec-utils.js +1 -0
- package/dist/src/Select/Select.story.d.ts +5 -1
- package/dist/src/Select/Select.story.fixture.js +8 -30
- package/dist/src/Select/Select.story.js +107 -31
- package/dist/src/Select/SelectComponents.js +7 -7
- package/dist/src/Select/SelectOption.js +1 -1
- package/dist/src/Select/customReactSelectStyles.js +152 -44
- package/dist/src/Select/lib.js +1 -2
- package/dist/src/SortingTable/SortingTable.js +6 -15
- package/dist/src/StatusIndicator/StatusIndicator.d.ts +0 -1
- package/dist/src/StatusIndicator/StatusIndicator.js +16 -1
- package/dist/src/Summary/Summary.js +2 -14
- package/dist/src/Summary/SummaryDivider.js +1 -1
- package/dist/src/Summary/SummaryItem.js +2 -14
- package/dist/src/Switcher/Switch.js +23 -19
- package/dist/src/Switcher/Switcher.js +4 -16
- package/dist/src/Table/BaseTable.js +2 -14
- package/dist/src/Table/StatefulTable.d.ts +1 -1
- package/dist/src/Table/StatefulTable.js +17 -9
- package/dist/src/Table/StyledTh.d.ts +0 -1
- package/dist/src/Table/StyledTh.js +11 -2
- package/dist/src/Table/Table.js +2 -14
- package/dist/src/Table/Table.types.d.ts +0 -1
- package/dist/src/Table/TableBody.js +11 -11
- package/dist/src/Table/TableFoot.js +5 -8
- package/dist/src/Table/TableHead.js +1 -4
- package/dist/src/Table/addExpandableControl.js +5 -2
- package/dist/src/Table/addSelectableControl.js +5 -2
- package/dist/src/Table/stories/BaseTable.story.d.ts +11 -7
- package/dist/src/Table/stories/BaseTable.story.js +156 -34
- package/dist/src/Table/stories/SortingColumnHeader.story.d.ts +5 -2
- package/dist/src/Table/stories/SortingColumnHeader.story.js +20 -3
- package/dist/src/Table/stories/Table.story.d.ts +7 -14
- package/dist/src/Table/stories/Table.story.js +172 -127
- package/dist/src/Table/stories/TableWithCustomSorting.story.js +4 -1
- package/dist/src/Table/stories/TableWithFiltering.story.js +8 -2
- package/dist/src/Table/stories/TableWithServerSidePagination.story.js +4 -15
- package/dist/src/Tabs/Tab.js +11 -18
- package/dist/src/Tabs/TabContainer.d.ts +0 -1
- package/dist/src/Tabs/TabScrollIndicator.js +2 -14
- package/dist/src/Tabs/Tabs.js +5 -7
- package/dist/src/Textarea/Textarea.js +3 -15
- package/dist/src/TimePicker/TimePicker.js +2 -14
- package/dist/src/TimePicker/TimePickerDropdown.d.ts +0 -1
- package/dist/src/TimePicker/TimePickerInput.d.ts +0 -1
- package/dist/src/TimePicker/TimePickerInput.js +6 -4
- package/dist/src/TimeRange/TimeRange.js +20 -20
- package/dist/src/Toast/Toast.js +4 -16
- package/dist/src/ToastContainer/ToastContainer.js +4 -16
- package/dist/src/ToastContainer/ToastContainer.story.js +1 -1
- package/dist/src/ToastContainer/ToastFunction.js +7 -19
- package/dist/src/Toggle/Toggle.js +4 -17
- package/dist/src/Toggle/ToggleButton.js +2 -14
- package/dist/src/Tooltip/Tooltip.story.d.ts +15 -52
- package/dist/src/Tooltip/Tooltip.story.js +80 -72
- package/dist/src/Tooltip/TooltipContainer.d.ts +0 -1
- package/dist/src/Tooltip/TooltipContainer.js +16 -1
- package/dist/src/Tooltip/components/TooltipComponents.js +9 -24
- package/dist/src/TopBar/TopBar.styled.d.ts +14 -7
- package/dist/src/TopBar/components/BackLink.js +2 -14
- package/dist/src/TopBar/components/Menu.js +2 -15
- package/dist/src/TopBar/components/MenuItemLink.js +2 -14
- package/dist/src/TopBar/components/PageTitle.js +2 -14
- package/dist/src/TopBar/stories/TopBar.backButton.story.js +3 -3
- package/dist/src/TopBar/stories/TopBar.menu.story.js +9 -20
- package/dist/src/TopBar/stories/TopBar.story.js +3 -3
- package/dist/src/TruncatedText/TruncatedText.js +8 -16
- package/dist/src/TruncatedText/components/MaybeTooltip.d.ts +1 -1
- package/dist/src/TruncatedText/components/TruncatedTextFillWidth.js +3 -15
- package/dist/src/TruncatedText/components/TruncatedTextMaxCharacters.js +4 -16
- package/dist/src/Type/Headings.d.ts +4 -5
- package/dist/src/Type/Text.d.ts +0 -1
- package/dist/src/Validation/InlineValidation.js +2 -14
- package/dist/src/VerticalDivider/VerticalDivider.d.ts +0 -1
- package/dist/src/VisualTests/WithSpace.story.js +18 -18
- package/dist/src/hooks/useMediaQuery/useMediaQuery.js +1 -2
- package/dist/src/i18n.js +1 -1
- package/dist/src/locale.story.js +1 -1
- package/dist/src/testing/matchers/toHaveStyle.d.ts +15 -0
- package/dist/src/testing/matchers/toHaveStyle.js +50 -0
- package/dist/src/testing/matchers/toMatchDate.d.ts +1 -0
- package/dist/src/testing/matchers/toMatchDate.js +1 -1
- package/dist/src/theme/mergeThemes.util.js +7 -1
- package/dist/src/theme/useNDSTheme.js +9 -3
- package/dist/src/utils/ClickInputLabel.d.ts +0 -1
- package/dist/src/utils/DetectOutsideClick.d.ts +3 -0
- package/dist/src/utils/DetectOutsideClick.js +3 -0
- package/dist/src/utils/PopperArrow.js +5 -1
- package/dist/src/utils/ScrollIndicators.js +1 -1
- package/dist/src/utils/generateId.d.ts +5 -0
- package/dist/src/utils/generateId.js +5 -0
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.js +0 -1
- package/dist/src/utils/numberFromDimension/numberFromDimension.spec.js +1 -0
- package/dist/src/utils/story/code.d.ts +0 -1
- package/dist/src/utils/story/dashed.d.ts +2 -2
- package/dist/src/utils/story/placeholder.js +1 -1
- package/dist/src/utils/story/resizable.d.ts +2 -2
- package/dist/src/utils/story/resizable.js +1 -1
- package/dist/src/utils/story/simulatedAPIRequests.js +8 -19
- package/dist/src/utils/subPx.js +1 -1
- package/dist/src/utils/testing/useConditionalAutoClick.js +3 -3
- package/dist/src/utils/testing/useUrlProps.js +1 -1
- package/dist/src/utils/ts/FocusManager.js +1 -1
- package/dist/src/utils/useWindowDimension.story.d.ts +1 -1
- package/dist/src/utils/withMenuState.js +1 -1
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +11 -0
- package/package.json +45 -85
- package/dist/src/NDSProvider/mountWithNDSProvider.spec-utils.d.ts +0 -1
- package/dist/src/NDSProvider/mountWithNDSProvider.spec-utils.js +0 -4
- package/dist/src/utils/withWindowDimensions.d.ts +0 -3
- package/dist/src/utils/withWindowDimensions.js +0 -28
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import React, { forwardRef } from "react";
|
|
13
2
|
import ReactSelect from "react-select";
|
|
14
3
|
import { useTranslation } from "react-i18next";
|
|
@@ -25,8 +14,7 @@ import { SelectControl, SelectMultiValue, SelectClearIndicator, SelectContainer,
|
|
|
25
14
|
import { SelectOption } from "./SelectOption";
|
|
26
15
|
import MenuList from "./MenuList";
|
|
27
16
|
import { calcOptionsLength, checkOptionsAreValid, extractValue, getReactSelectValue } from "./lib";
|
|
28
|
-
const NDSSelect = forwardRef((
|
|
29
|
-
var { value, onChange, defaultValue, disabled, errorMessage, errorList, id, initialIsOpen, multiselect, placeholder, components, options, styles, windowThreshold = 300, autocomplete = true, maxHeight = "248px", required = false, menuPosition = "absolute", menuPlacement = "bottom", classNamePrefix = "ndsSelect", closeMenuOnSelect = true, noOptionsMessage } = _a, props = __rest(_a, ["value", "onChange", "defaultValue", "disabled", "errorMessage", "errorList", "id", "initialIsOpen", "multiselect", "placeholder", "components", "options", "styles", "windowThreshold", "autocomplete", "maxHeight", "required", "menuPosition", "menuPlacement", "classNamePrefix", "closeMenuOnSelect", "noOptionsMessage"]);
|
|
17
|
+
const NDSSelect = forwardRef(({ value, onChange, defaultValue, disabled, errorMessage, errorList, id, initialIsOpen, multiselect, placeholder, components, options, styles, windowThreshold = 300, autocomplete = true, maxHeight = "248px", required = false, menuPosition = "absolute", menuPlacement = "bottom", classNamePrefix = "ndsSelect", closeMenuOnSelect = true, noOptionsMessage, ...props }, ref) => {
|
|
30
18
|
const { t } = useTranslation();
|
|
31
19
|
const variant = useComponentVariant();
|
|
32
20
|
const theme = useTheme();
|
|
@@ -49,14 +37,25 @@ const NDSSelect = forwardRef((_a, ref) => {
|
|
|
49
37
|
maxHeight,
|
|
50
38
|
windowed: options.length > windowThreshold,
|
|
51
39
|
});
|
|
52
|
-
return (React.createElement(Field,
|
|
53
|
-
React.createElement(MaybeFieldLabel,
|
|
54
|
-
React.createElement(ReactSelect,
|
|
40
|
+
return (React.createElement(Field, { ...styledProps },
|
|
41
|
+
React.createElement(MaybeFieldLabel, { ...fieldLabelProps },
|
|
42
|
+
React.createElement(ReactSelect, { ref: ref, isSearchable: autocomplete, isDisabled: disabled, defaultMenuIsOpen: initialIsOpen, isMulti: multiselect, defaultValue: getReactSelectValue(options, defaultValue), value: getReactSelectValue(options, value), options: options, onChange: (newValue) => {
|
|
55
43
|
if (!onChange)
|
|
56
44
|
return;
|
|
57
45
|
const value = extractValue(newValue, multiselect);
|
|
58
46
|
onChange(value);
|
|
59
|
-
}, placeholder: placeholder || t("select"), "aria-required": required, required: required, "aria-invalid": error, inputId: id, styles: styles ? styles(stylesConfig) : stylesConfig, components:
|
|
47
|
+
}, placeholder: placeholder || t("select"), "aria-required": required, required: required, "aria-invalid": error, inputId: id, styles: styles ? styles(stylesConfig) : stylesConfig, components: {
|
|
48
|
+
Option: (props) => React.createElement(SelectOption, { ...props }, props.children),
|
|
49
|
+
Control: SelectControl,
|
|
50
|
+
MultiValue: SelectMultiValue,
|
|
51
|
+
ClearIndicator: SelectClearIndicator,
|
|
52
|
+
DropdownIndicator: SelectDropdownIndicator,
|
|
53
|
+
SelectContainer: SelectContainer,
|
|
54
|
+
Menu: SelectMenu,
|
|
55
|
+
Input: SelectInput,
|
|
56
|
+
...(isWindowed ? { MenuList } : {}),
|
|
57
|
+
...components,
|
|
58
|
+
}, closeMenuOnSelect: closeMenuOnSelect, classNamePrefix: classNamePrefix, menuPosition: menuPosition, menuPlacement: menuPlacement, maxMenuHeight: numberFromDimension(maxHeight), noOptionsMessage: noOptionsMessage, ...props }),
|
|
60
59
|
React.createElement(InlineValidation, { mt: "x1", errorMessage: errorMessage, errorList: errorList }))));
|
|
61
60
|
});
|
|
62
61
|
export default NDSSelect;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { StoryObj } from "@storybook/react";
|
|
3
|
+
import Select, { NDSSelectProps } from "./Select";
|
|
2
4
|
declare const _default: {
|
|
3
5
|
title: string;
|
|
6
|
+
component: <Option extends import("./Select").NDSOption = import("./Select").NDSOption, IsMulti extends boolean = false, Group extends import("react-select").GroupBase<Option> = import("react-select").GroupBase<Option>>(props: NDSSelectProps<Option, IsMulti, Group> & React.RefAttributes<import("react-select/base").default<Option, IsMulti, Group>>) => React.ReactElement;
|
|
4
7
|
};
|
|
5
8
|
export default _default;
|
|
6
|
-
|
|
9
|
+
type Story = StoryObj<typeof Select>;
|
|
10
|
+
export declare const _Select: Story;
|
|
7
11
|
export declare const WithStyledProps: () => React.JSX.Element;
|
|
8
12
|
export declare const WithABlankValue: {
|
|
9
13
|
(): React.JSX.Element;
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
1
|
import React from "react";
|
|
22
2
|
import styled from "styled-components";
|
|
23
3
|
import { SelectOption } from "./SelectOption";
|
|
@@ -56,15 +36,15 @@ export const PCNList = [
|
|
|
56
36
|
{ value: "1", label: "PCN1" },
|
|
57
37
|
{ value: "9", label: "PCN9" },
|
|
58
38
|
];
|
|
59
|
-
export const getPhotos = () =>
|
|
39
|
+
export const getPhotos = async () => {
|
|
60
40
|
// returns 5000 items
|
|
61
|
-
const data =
|
|
62
|
-
const json =
|
|
41
|
+
const data = await fetch("https://jsonplaceholder.typicode.com/photos");
|
|
42
|
+
const json = await data.json();
|
|
63
43
|
return json.map(({ title, id }) => ({
|
|
64
44
|
label: title,
|
|
65
45
|
value: id,
|
|
66
46
|
}));
|
|
67
|
-
}
|
|
47
|
+
};
|
|
68
48
|
const Indicator = styled.span(() => ({
|
|
69
49
|
borderRadius: "25%",
|
|
70
50
|
background: "green",
|
|
@@ -74,16 +54,14 @@ const Indicator = styled.span(() => ({
|
|
|
74
54
|
height: "10px",
|
|
75
55
|
marginRight: "5px",
|
|
76
56
|
}));
|
|
77
|
-
export const CustomOption = (
|
|
78
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
57
|
+
export const CustomOption = ({ children, ...props }) => {
|
|
79
58
|
const newChildren = (React.createElement(React.Fragment, null,
|
|
80
59
|
React.createElement(Indicator, null),
|
|
81
60
|
children));
|
|
82
|
-
return React.createElement(SelectOption,
|
|
61
|
+
return React.createElement(SelectOption, { ...props }, newChildren);
|
|
83
62
|
};
|
|
84
|
-
export const CustomFieldsOption = (
|
|
85
|
-
|
|
86
|
-
return (React.createElement(SelectOption, Object.assign({}, props),
|
|
63
|
+
export const CustomFieldsOption = ({ ...props }) => {
|
|
64
|
+
return (React.createElement(SelectOption, { ...props },
|
|
87
65
|
React.createElement("span", null, props.data.label),
|
|
88
66
|
React.createElement("span", null, props.data.description)));
|
|
89
67
|
};
|
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
22
2
|
import { action } from "@storybook/addon-actions";
|
|
23
|
-
import { boolean, select, text } from "@storybook/addon-knobs";
|
|
24
3
|
import { Box } from "../Box";
|
|
25
4
|
import { Flex } from "../Flex";
|
|
26
5
|
import { Button } from "../index";
|
|
27
6
|
import Select from "./Select";
|
|
28
7
|
import { CustomOption, getPhotos, options, partnerCompanyName, wrappingOptions, PCNList, errorList, CustomFieldsOption, } from "./Select.story.fixture";
|
|
29
|
-
const SelectWithManyOptions = (
|
|
30
|
-
var { multiselect, labelText } = _a, props = __rest(_a, ["multiselect", "labelText"]);
|
|
8
|
+
const SelectWithManyOptions = ({ multiselect, labelText, ...props }) => {
|
|
31
9
|
const [photoList, setPhotoList] = useState([]);
|
|
32
|
-
const setOptions = () =>
|
|
33
|
-
const result =
|
|
10
|
+
const setOptions = async () => {
|
|
11
|
+
const result = await getPhotos();
|
|
34
12
|
setPhotoList(result);
|
|
35
|
-
}
|
|
13
|
+
};
|
|
36
14
|
useEffect(() => {
|
|
37
15
|
setOptions();
|
|
38
16
|
}, []);
|
|
39
|
-
return React.createElement(Select,
|
|
17
|
+
return React.createElement(Select, { multiselect: multiselect, options: photoList, labelText: labelText, ...props });
|
|
40
18
|
};
|
|
41
19
|
class SelectWithState extends React.Component {
|
|
42
20
|
constructor(props) {
|
|
@@ -54,14 +32,106 @@ class SelectWithState extends React.Component {
|
|
|
54
32
|
render() {
|
|
55
33
|
const { selectedValue } = this.state;
|
|
56
34
|
return (React.createElement(Flex, { flexDirection: "column", gap: "x2", alignItems: "flex-start" },
|
|
57
|
-
React.createElement(Select,
|
|
35
|
+
React.createElement(Select, { className: "Select", classNamePrefix: "SelectTest", onChange: this.handleChange, value: selectedValue, options: options, ...this.props }),
|
|
58
36
|
React.createElement(Button, { onClick: this.clearSelection }, "Clear selection")));
|
|
59
37
|
}
|
|
60
38
|
}
|
|
61
39
|
export default {
|
|
62
40
|
title: "Components/Select",
|
|
41
|
+
component: Select,
|
|
42
|
+
};
|
|
43
|
+
export const _Select = {
|
|
44
|
+
args: {
|
|
45
|
+
options,
|
|
46
|
+
autocomplete: true,
|
|
47
|
+
className: undefined,
|
|
48
|
+
classNamePrefix: undefined,
|
|
49
|
+
closeMenuOnSelect: true,
|
|
50
|
+
disabled: false,
|
|
51
|
+
defaultValue: undefined,
|
|
52
|
+
errorMessage: "",
|
|
53
|
+
labelText: "Inventory Status",
|
|
54
|
+
helpText: undefined,
|
|
55
|
+
noOptionsMessage: () => "No options",
|
|
56
|
+
required: false,
|
|
57
|
+
requirementText: undefined,
|
|
58
|
+
id: undefined,
|
|
59
|
+
maxHeight: "248px",
|
|
60
|
+
menuPosition: "absolute",
|
|
61
|
+
multiselect: false,
|
|
62
|
+
name: undefined,
|
|
63
|
+
placeholder: " ",
|
|
64
|
+
value: undefined,
|
|
65
|
+
menuIsOpen: undefined,
|
|
66
|
+
onMenuOpen: action("on menu open"),
|
|
67
|
+
onMenuClose: action("on menu close"),
|
|
68
|
+
onChange: action("selection changed"),
|
|
69
|
+
onInputChange: action("typed input value changed"),
|
|
70
|
+
onBlur: action("blurred"),
|
|
71
|
+
},
|
|
72
|
+
argTypes: {
|
|
73
|
+
autocomplete: {
|
|
74
|
+
control: { type: "boolean" },
|
|
75
|
+
},
|
|
76
|
+
className: {
|
|
77
|
+
control: { type: "text" },
|
|
78
|
+
},
|
|
79
|
+
classNamePrefix: {
|
|
80
|
+
control: { type: "text" },
|
|
81
|
+
},
|
|
82
|
+
closeMenuOnSelect: {
|
|
83
|
+
control: { type: "boolean" },
|
|
84
|
+
},
|
|
85
|
+
disabled: {
|
|
86
|
+
control: { type: "boolean" },
|
|
87
|
+
},
|
|
88
|
+
defaultValue: {
|
|
89
|
+
control: { type: "select" },
|
|
90
|
+
options: [undefined, ...options.map(({ value }) => value)],
|
|
91
|
+
},
|
|
92
|
+
errorMessage: {
|
|
93
|
+
control: { type: "text" },
|
|
94
|
+
},
|
|
95
|
+
labelText: {
|
|
96
|
+
control: { type: "text" },
|
|
97
|
+
},
|
|
98
|
+
helpText: {
|
|
99
|
+
control: { type: "text" },
|
|
100
|
+
},
|
|
101
|
+
required: {
|
|
102
|
+
control: { type: "boolean" },
|
|
103
|
+
},
|
|
104
|
+
requirementText: {
|
|
105
|
+
control: { type: "text" },
|
|
106
|
+
},
|
|
107
|
+
id: {
|
|
108
|
+
control: { type: "text" },
|
|
109
|
+
},
|
|
110
|
+
maxHeight: {
|
|
111
|
+
control: { type: "text" },
|
|
112
|
+
},
|
|
113
|
+
menuPosition: {
|
|
114
|
+
control: { type: "select" },
|
|
115
|
+
options: ["absolute", "fixed"],
|
|
116
|
+
},
|
|
117
|
+
multiselect: {
|
|
118
|
+
control: { type: "boolean" },
|
|
119
|
+
},
|
|
120
|
+
name: {
|
|
121
|
+
control: { type: "text" },
|
|
122
|
+
},
|
|
123
|
+
placeholder: {
|
|
124
|
+
control: { type: "text" },
|
|
125
|
+
},
|
|
126
|
+
value: {
|
|
127
|
+
control: { type: "select" },
|
|
128
|
+
options: [undefined, ...options.map(({ value }) => value)],
|
|
129
|
+
},
|
|
130
|
+
menuIsOpen: {
|
|
131
|
+
control: { type: "boolean" },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
63
134
|
};
|
|
64
|
-
export const _Select = () => (React.createElement(Select, { options: options, autocomplete: boolean("autocomplete", true), className: text("className", undefined), classNamePrefix: text("classNamePrefix", undefined), closeMenuOnSelect: boolean("closeMenuOnSelect", true), disabled: boolean("disabled", false), defaultValue: select("defaultValue", [undefined, ...options.map(({ value }) => value)], undefined), errorMessage: text("errorMessage", ""), labelText: text("labelText", "Inventory Status"), helpText: text("helpText", undefined), noOptionsMessage: () => "No options", required: boolean("required", false), requirementText: text("requirementText", undefined), id: text("id", undefined), maxHeight: text("maxHeight", "248px"), menuPosition: select("menuPosition", ["absolute", "fixed"], "absolute"), multiselect: boolean("multiselect", false), name: text("name", undefined), placeholder: text("placeholder", " "), value: select("value", [undefined, ...options.map(({ value }) => value)], undefined), menuIsOpen: boolean("menuIsOpen", undefined), onMenuOpen: action("on menu open"), onMenuClose: action("on menu close"), onChange: action("selection changed"), onInputChange: action("typed input value changed"), onBlur: action("blurred") }));
|
|
65
135
|
export const WithStyledProps = () => {
|
|
66
136
|
return (React.createElement(Select, { initialIsOpen: true, placeholder: "Please select inventory status", onChange: action("selection changed"), onBlur: action("blurred"), maxWidth: "300px", options: options, labelText: "Default size", onInputChange: action("typed input value changed") }));
|
|
67
137
|
};
|
|
@@ -123,7 +193,7 @@ WithWrappingText.story = {
|
|
|
123
193
|
name: "With wrapping text",
|
|
124
194
|
};
|
|
125
195
|
export const WithMultiselect = (props) => {
|
|
126
|
-
return (React.createElement(Select,
|
|
196
|
+
return (React.createElement(Select, { defaultValue: [partnerCompanyName[0].value, partnerCompanyName[2].value], noOptionsMessage: () => "Nothing to see here", placeholder: "Please select inventory status", options: PCNList, labelText: "Select PCN", className: "Select", multiselect: true, ...props }));
|
|
127
197
|
};
|
|
128
198
|
WithMultiselect.story = {
|
|
129
199
|
name: "with multiselect",
|
|
@@ -181,7 +251,13 @@ export const WithTopMenuPlacement = () => {
|
|
|
181
251
|
};
|
|
182
252
|
export const WithCustomStyles = () => {
|
|
183
253
|
return (React.createElement(Select, { options: options, menuPlacement: "top", styles: (styles) => {
|
|
184
|
-
return
|
|
254
|
+
return {
|
|
255
|
+
...styles,
|
|
256
|
+
control: (provided, props) => ({
|
|
257
|
+
...styles.control(provided, props),
|
|
258
|
+
border: "2px solid lightblue",
|
|
259
|
+
}),
|
|
260
|
+
};
|
|
185
261
|
} }));
|
|
186
262
|
};
|
|
187
263
|
export const WithCustomOptionFields = () => {
|
|
@@ -3,29 +3,29 @@ import { components, } from "react-select";
|
|
|
3
3
|
export function SelectControl(props) {
|
|
4
4
|
const { isFocused } = props;
|
|
5
5
|
return (React.createElement("div", { "data-testid": "select-control" },
|
|
6
|
-
React.createElement(components.Control,
|
|
6
|
+
React.createElement(components.Control, { className: isFocused ? "nds-select--is-focused" : null, isFocused: isFocused, ...props }, props.children)));
|
|
7
7
|
}
|
|
8
8
|
export function SelectMultiValue(props) {
|
|
9
9
|
return (React.createElement("div", { "data-testid": "select-multivalue" },
|
|
10
|
-
React.createElement(components.MultiValue,
|
|
10
|
+
React.createElement(components.MultiValue, { ...props }, props.children)));
|
|
11
11
|
}
|
|
12
12
|
export function SelectClearIndicator(props) {
|
|
13
13
|
return (React.createElement("div", { "data-testid": "select-clear" },
|
|
14
|
-
React.createElement(components.ClearIndicator,
|
|
14
|
+
React.createElement(components.ClearIndicator, { ...props })));
|
|
15
15
|
}
|
|
16
16
|
export function SelectDropdownIndicator(props) {
|
|
17
17
|
return (React.createElement("div", { "data-testid": "select-arrow" },
|
|
18
|
-
React.createElement(components.DropdownIndicator,
|
|
18
|
+
React.createElement(components.DropdownIndicator, { ...props })));
|
|
19
19
|
}
|
|
20
20
|
export function SelectMenu(props) {
|
|
21
21
|
return (React.createElement("div", { "data-testid": "select-dropdown" },
|
|
22
|
-
React.createElement(components.Menu,
|
|
22
|
+
React.createElement(components.Menu, { ...props }, props.children)));
|
|
23
23
|
}
|
|
24
24
|
export function SelectContainer(props) {
|
|
25
25
|
return (React.createElement("div", { "data-testid": "select-container" },
|
|
26
|
-
React.createElement(components.SelectContainer,
|
|
26
|
+
React.createElement(components.SelectContainer, { ...props }, props.children)));
|
|
27
27
|
}
|
|
28
28
|
export function SelectInput(props) {
|
|
29
29
|
return (React.createElement("div", { "data-testid": "select-input" },
|
|
30
|
-
React.createElement(components.Input,
|
|
30
|
+
React.createElement(components.Input, { ...props }, props.children)));
|
|
31
31
|
}
|
|
@@ -38,5 +38,5 @@ export const StyledOption = styled.div(typography, ({ isSelected, isFocused, the
|
|
|
38
38
|
}));
|
|
39
39
|
export function SelectOption(props) {
|
|
40
40
|
return (React.createElement(StyledOption, { isSelected: props.isSelected, isFocused: props.isFocused, "data-testid": "select-option" },
|
|
41
|
-
React.createElement(components.Option,
|
|
41
|
+
React.createElement(components.Option, { ...props }, props.children)));
|
|
42
42
|
}
|
|
@@ -41,42 +41,64 @@ const customStyles = ({ theme, error, maxHeight, windowed, hasIcon, variant, has
|
|
|
41
41
|
option: () => ({
|
|
42
42
|
height: 38,
|
|
43
43
|
}),
|
|
44
|
-
clearIndicator: (provided) => (
|
|
45
|
-
|
|
44
|
+
clearIndicator: (provided) => ({
|
|
45
|
+
...provided,
|
|
46
|
+
color: theme.colors.midGrey,
|
|
47
|
+
}),
|
|
48
|
+
control: (provided, state) => ({
|
|
49
|
+
...provided,
|
|
50
|
+
display: "flex",
|
|
51
|
+
minHeight: theme.space.x5,
|
|
52
|
+
paddingLeft: theme.space.x1,
|
|
53
|
+
position: "relative",
|
|
54
|
+
width: "100%",
|
|
55
|
+
fontSize: theme.fontSizes.base,
|
|
56
|
+
lineHeight: theme.lineHeights.base,
|
|
57
|
+
color: state.isDisabled ? transparentize(0.6667, theme.colors.black) : theme.colors.black,
|
|
58
|
+
background: state.isDisabled ? theme.colors.whiteGrey : theme.colors.white,
|
|
59
|
+
borderColor: getBorderColor({
|
|
46
60
|
errored: error,
|
|
47
61
|
disabled: state.isDisabled,
|
|
48
62
|
isOpen: state.selectProps.menuIsOpen,
|
|
49
63
|
isFocused: state.isFocused,
|
|
50
64
|
theme,
|
|
51
|
-
}),
|
|
65
|
+
}),
|
|
66
|
+
boxSizing: "border-box",
|
|
67
|
+
boxShadow: getShadow({
|
|
52
68
|
errored: error,
|
|
53
69
|
isOpen: state.selectProps.menuIsOpen,
|
|
54
70
|
theme,
|
|
55
|
-
}),
|
|
71
|
+
}),
|
|
72
|
+
borderRadius: theme.radii.medium,
|
|
73
|
+
borderBottomLeftRadius: getControlBorderRadius({
|
|
56
74
|
border: "bottom",
|
|
57
75
|
isMenuOpen: state.selectProps.menuIsOpen,
|
|
58
76
|
menuLength: state.selectProps.options.length,
|
|
59
77
|
menuPlacement: state.selectProps.menuPlacement,
|
|
60
78
|
theme: theme,
|
|
61
|
-
}),
|
|
79
|
+
}),
|
|
80
|
+
borderBottomRightRadius: getControlBorderRadius({
|
|
62
81
|
border: "bottom",
|
|
63
82
|
isMenuOpen: state.selectProps.menuIsOpen,
|
|
64
83
|
menuLength: state.selectProps.options.length,
|
|
65
84
|
menuPlacement: state.selectProps.menuPlacement,
|
|
66
85
|
theme: theme,
|
|
67
|
-
}),
|
|
86
|
+
}),
|
|
87
|
+
borderTopRightRadius: getControlBorderRadius({
|
|
68
88
|
border: "top",
|
|
69
89
|
isMenuOpen: state.selectProps.menuIsOpen,
|
|
70
90
|
menuLength: state.selectProps.options.length,
|
|
71
91
|
menuPlacement: state.selectProps.menuPlacement,
|
|
72
92
|
theme: theme,
|
|
73
|
-
}),
|
|
93
|
+
}),
|
|
94
|
+
borderTopLeftRadius: getControlBorderRadius({
|
|
74
95
|
border: "top",
|
|
75
96
|
isMenuOpen: state.selectProps.menuIsOpen,
|
|
76
97
|
menuLength: state.selectProps.options.length,
|
|
77
98
|
menuPlacement: state.selectProps.menuPlacement,
|
|
78
99
|
theme: theme,
|
|
79
|
-
}),
|
|
100
|
+
}),
|
|
101
|
+
"&:hover, &:focus": {
|
|
80
102
|
borderColor: getBorderColor({
|
|
81
103
|
errored: error,
|
|
82
104
|
disabled: state.isDisabled,
|
|
@@ -84,68 +106,154 @@ const customStyles = ({ theme, error, maxHeight, windowed, hasIcon, variant, has
|
|
|
84
106
|
isFocused: true,
|
|
85
107
|
theme,
|
|
86
108
|
}),
|
|
87
|
-
} }), (hasIcon && {
|
|
88
|
-
paddingLeft: `calc(${theme.space.x3} + ${theme.space.x1_5})`,
|
|
89
|
-
}))),
|
|
90
|
-
dropdownIndicator: (provided) => (Object.assign(Object.assign(Object.assign({}, provided), (!hasDefaultOptions && { display: "none" })), { color: theme.colors.midGrey })),
|
|
91
|
-
indicatorsContainer: (provided) => (Object.assign(Object.assign({}, provided), { color: theme.colors.midGrey })),
|
|
92
|
-
singleValue: (provided) => (Object.assign(Object.assign({}, provided), { marginLeft: 2, marginRight: 2, position: "absolute", top: "50%", transform: "translateY(-50%)" })),
|
|
93
|
-
valueContainer: (provided) => (Object.assign(Object.assign(Object.assign({}, provided), { padding: 0, display: "flex", overflow: "auto", maxHeight: "150px", gap: theme.space.half, paddingTop: theme.space.none, paddingBottom: theme.space.none }), stylesForVariant({
|
|
94
|
-
touch: {
|
|
95
|
-
fontSize: "md",
|
|
96
|
-
lineHeight: "base",
|
|
97
109
|
},
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
...(hasIcon && {
|
|
111
|
+
paddingLeft: `calc(${theme.space.x3} + ${theme.space.x1_5})`,
|
|
112
|
+
}),
|
|
113
|
+
}),
|
|
114
|
+
dropdownIndicator: (provided) => ({
|
|
115
|
+
...provided,
|
|
116
|
+
...(!hasDefaultOptions && { display: "none" }),
|
|
117
|
+
color: theme.colors.midGrey,
|
|
118
|
+
}),
|
|
119
|
+
indicatorsContainer: (provided) => ({
|
|
120
|
+
...provided,
|
|
121
|
+
color: theme.colors.midGrey,
|
|
122
|
+
}),
|
|
123
|
+
singleValue: (provided) => ({
|
|
124
|
+
...provided,
|
|
125
|
+
marginLeft: 2,
|
|
126
|
+
marginRight: 2,
|
|
127
|
+
position: "absolute",
|
|
128
|
+
top: "50%",
|
|
129
|
+
transform: "translateY(-50%)",
|
|
130
|
+
}),
|
|
131
|
+
valueContainer: (provided) => ({
|
|
132
|
+
...provided,
|
|
133
|
+
padding: 0,
|
|
134
|
+
display: "flex",
|
|
135
|
+
overflow: "auto",
|
|
136
|
+
maxHeight: "150px",
|
|
137
|
+
gap: theme.space.half,
|
|
138
|
+
paddingTop: theme.space.none,
|
|
139
|
+
paddingBottom: theme.space.none,
|
|
140
|
+
...stylesForVariant({
|
|
141
|
+
touch: {
|
|
142
|
+
fontSize: "md",
|
|
143
|
+
lineHeight: "base",
|
|
144
|
+
},
|
|
145
|
+
}, variant),
|
|
146
|
+
}),
|
|
147
|
+
menu: (provided, state) => ({
|
|
148
|
+
...provided,
|
|
149
|
+
marginTop: 0,
|
|
150
|
+
marginBottom: 0,
|
|
151
|
+
position: "absolute",
|
|
152
|
+
overflowX: "auto",
|
|
153
|
+
zIndex: 100,
|
|
154
|
+
width: "100%",
|
|
155
|
+
background: theme.colors.white,
|
|
156
|
+
borderWidth: "1px",
|
|
157
|
+
borderColor: getBorderColor({
|
|
100
158
|
errored: error,
|
|
101
159
|
isOpen: true,
|
|
102
160
|
isFocused: false,
|
|
103
161
|
theme,
|
|
104
|
-
}),
|
|
162
|
+
}),
|
|
163
|
+
borderLeftStyle: "solid",
|
|
164
|
+
borderRightStyle: "solid",
|
|
165
|
+
borderBottomStyle: getMenuBorderRadius({
|
|
105
166
|
border: "bottom",
|
|
106
167
|
menuPlacement: state.selectProps.menuPlacement,
|
|
107
168
|
theme,
|
|
108
|
-
}).style,
|
|
109
|
-
|
|
169
|
+
}).style,
|
|
170
|
+
borderTopStyle: getMenuBorderRadius({ border: "top", menuPlacement: state.selectProps.menuPlacement, theme })
|
|
171
|
+
.style,
|
|
172
|
+
borderBottomLeftRadius: getMenuBorderRadius({
|
|
110
173
|
border: "bottom",
|
|
111
174
|
menuPlacement: state.selectProps.menuPlacement,
|
|
112
175
|
theme,
|
|
113
|
-
}).radius,
|
|
176
|
+
}).radius,
|
|
177
|
+
borderBottomRightRadius: getMenuBorderRadius({
|
|
114
178
|
border: "bottom",
|
|
115
179
|
menuPlacement: state.selectProps.menuPlacement,
|
|
116
180
|
theme,
|
|
117
|
-
}).radius,
|
|
118
|
-
|
|
181
|
+
}).radius,
|
|
182
|
+
borderTopLeftRadius: getMenuBorderRadius({ border: "top", menuPlacement: state.selectProps.menuPlacement, theme })
|
|
183
|
+
.radius,
|
|
184
|
+
borderTopRightRadius: getMenuBorderRadius({
|
|
119
185
|
border: "top",
|
|
120
186
|
menuPlacement: state.selectProps.menuPlacement,
|
|
121
187
|
theme,
|
|
122
|
-
}).radius,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
188
|
+
}).radius,
|
|
189
|
+
boxShadow: getShadow({ errored: error, isOpen: true, theme }),
|
|
190
|
+
}),
|
|
191
|
+
menuList: (provided) => ({
|
|
192
|
+
...provided,
|
|
193
|
+
minWidth: "fit-content",
|
|
194
|
+
padding: 0,
|
|
195
|
+
maxHeight: numberFromDimension(maxHeight),
|
|
196
|
+
borderRadius: theme.radii.medium,
|
|
197
|
+
marginTop: windowed ? "-4px" : 0,
|
|
198
|
+
marginBottom: windowed ? "-4px" : 0,
|
|
199
|
+
}),
|
|
200
|
+
multiValue: (provided) => ({
|
|
201
|
+
...provided,
|
|
202
|
+
background: theme.colors.lightGrey,
|
|
203
|
+
color: theme.colors.black,
|
|
204
|
+
margin: 0,
|
|
205
|
+
}),
|
|
206
|
+
multiValueLabel: () => ({
|
|
207
|
+
textOverflow: "ellipsis",
|
|
208
|
+
whiteSpace: "nowrap",
|
|
209
|
+
overflow: "hidden",
|
|
210
|
+
color: theme.colors.black,
|
|
211
|
+
borderRadius: theme.radii.small,
|
|
212
|
+
fontSize: theme.fontSizes.small,
|
|
213
|
+
padding: theme.space.half,
|
|
214
|
+
paddingLeft: theme.space.x1,
|
|
215
|
+
...stylesForVariant({
|
|
216
|
+
touch: {
|
|
217
|
+
fontSize: "md",
|
|
218
|
+
lineHeight: "base",
|
|
219
|
+
},
|
|
220
|
+
}, variant),
|
|
221
|
+
}),
|
|
222
|
+
multiValueRemove: (provided) => ({
|
|
223
|
+
...provided,
|
|
224
|
+
svg: { fill: theme.colors.black, height: theme.sizes.x2, width: theme.sizes.x2 },
|
|
225
|
+
borderBottomLeftRadius: 0,
|
|
226
|
+
borderTopLeftRadius: 0,
|
|
227
|
+
padding: theme.space.half,
|
|
228
|
+
paddingLeft: theme.space.x1,
|
|
229
|
+
"&:hover": {
|
|
132
230
|
background: theme.colors.darkGrey,
|
|
133
231
|
cursor: "pointer",
|
|
134
232
|
svg: { fill: theme.colors.white },
|
|
135
|
-
} }), stylesForVariant({
|
|
136
|
-
touch: {
|
|
137
|
-
fontSize: "md",
|
|
138
|
-
lineHeight: "base",
|
|
139
233
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
234
|
+
...stylesForVariant({
|
|
235
|
+
touch: {
|
|
236
|
+
fontSize: "md",
|
|
237
|
+
lineHeight: "base",
|
|
238
|
+
},
|
|
239
|
+
}, variant),
|
|
240
|
+
}),
|
|
241
|
+
noOptionsMessage: (provided) => ({
|
|
242
|
+
...provided,
|
|
243
|
+
color: theme.colors.black,
|
|
244
|
+
fontSize: theme.fontSizes.small,
|
|
245
|
+
}),
|
|
246
|
+
indicatorSeparator: (provided, state) => ({
|
|
247
|
+
...provided,
|
|
248
|
+
display: showIndicatorSeparator({
|
|
143
249
|
hasValue: state.hasValue,
|
|
144
250
|
isClearable: state.selectProps.isClearable,
|
|
145
251
|
isMulti: state.isMulti,
|
|
146
252
|
})
|
|
147
253
|
? "block"
|
|
148
|
-
: "none",
|
|
254
|
+
: "none",
|
|
255
|
+
borderLeft: `1px solid ${theme.colors.grey}`,
|
|
256
|
+
}),
|
|
149
257
|
placeholder: (state) => {
|
|
150
258
|
return {
|
|
151
259
|
label: "placeholder",
|
package/dist/src/Select/lib.js
CHANGED
|
@@ -56,12 +56,11 @@ export function checkOptionsAreValid(options) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
export function getOption(options, value) {
|
|
59
|
-
var _a;
|
|
60
59
|
if (Array.isArray(value)) {
|
|
61
60
|
return value.map((o) => getOption(options, o));
|
|
62
61
|
}
|
|
63
62
|
if (options.length > 0 && value !== undefined) {
|
|
64
|
-
return
|
|
63
|
+
return options.find((o) => o.value === value) ?? null;
|
|
65
64
|
}
|
|
66
65
|
return value;
|
|
67
66
|
}
|