@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,22 +1,10 @@
|
|
|
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, useState, useEffect } from "react";
|
|
13
2
|
import { subDays, addDays, isValid, isAfter, isBefore, isSameDay } from "date-fns";
|
|
14
3
|
import { BasePicker } from "./shared/components/BasePicker";
|
|
15
4
|
import { DatePickerHeader } from "./shared/components/DatePickerHeader";
|
|
16
5
|
const DEFAULT_DATE_FORMAT = "yyyy-MMM-dd";
|
|
17
6
|
const DEFAULT_PLACEHOLDER = "YYYY-Mon-DD";
|
|
18
|
-
const DatePicker = forwardRef((
|
|
19
|
-
var { selected, dateFormat = DEFAULT_DATE_FORMAT, onChange } = _a, props = __rest(_a, ["selected", "dateFormat", "onChange"]);
|
|
7
|
+
const DatePicker = forwardRef(({ selected, dateFormat = DEFAULT_DATE_FORMAT, onChange, ...props }, datePickerRef) => {
|
|
20
8
|
const [selectedDate, setSelectedDate] = useState(selected);
|
|
21
9
|
const [ref] = useState(null);
|
|
22
10
|
useEffect(() => {
|
|
@@ -46,6 +34,6 @@ const DatePicker = forwardRef((_a, datePickerRef) => {
|
|
|
46
34
|
ref.setOpen(!isOpen);
|
|
47
35
|
}
|
|
48
36
|
};
|
|
49
|
-
return (React.createElement(BasePicker,
|
|
37
|
+
return (React.createElement(BasePicker, { ...props, selected: selectedDate, dateFormat: dateFormat, onChange: handleSelectedDateChange, ref: datePickerRef, defaultFormat: DEFAULT_DATE_FORMAT, defaultPlaceholder: DEFAULT_PLACEHOLDER, showMonthYearPicker: false, disabledKeyboardNavigation: true, onUpKeyPress: handleUpKey, onDownKeyPress: handleDownKey, onEnterKeyPress: handleEnterKey, renderHeader: (headerProps) => (React.createElement(DatePickerHeader, { locale: props.locale, ...headerProps })) }));
|
|
50
38
|
});
|
|
51
39
|
export default DatePicker;
|
|
@@ -1,22 +1,10 @@
|
|
|
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, useState, useEffect } from "react";
|
|
13
2
|
import { noop } from "../utils/noop";
|
|
14
3
|
import { BasePicker } from "./shared/components/BasePicker";
|
|
15
4
|
import { MonthDatePickerHeader } from "./custom/MonthPickerHeader";
|
|
16
5
|
export const DEFAULT_MONTH_FORMAT = "yyyy-MMM";
|
|
17
6
|
export const DEFAULT_PLACEHOLDER = "YYYY-Mon";
|
|
18
|
-
const MonthPicker = forwardRef((
|
|
19
|
-
var { selected, dateFormat = DEFAULT_MONTH_FORMAT, onChange } = _a, props = __rest(_a, ["selected", "dateFormat", "onChange"]);
|
|
7
|
+
const MonthPicker = forwardRef(({ selected, dateFormat = DEFAULT_MONTH_FORMAT, onChange, ...props }, monthPickerRef) => {
|
|
20
8
|
const [selectedDate, setSelectedDate] = useState(selected);
|
|
21
9
|
const [ref] = useState(null);
|
|
22
10
|
useEffect(() => {
|
|
@@ -36,6 +24,6 @@ const MonthPicker = forwardRef((_a, monthPickerRef) => {
|
|
|
36
24
|
ref.setOpen(!isOpen);
|
|
37
25
|
}
|
|
38
26
|
};
|
|
39
|
-
return (React.createElement(BasePicker,
|
|
27
|
+
return (React.createElement(BasePicker, { ...props, selected: selectedDate, onChange: handleSelectedDateChange, ref: monthPickerRef, dateFormat: dateFormat, defaultFormat: DEFAULT_MONTH_FORMAT, defaultPlaceholder: DEFAULT_PLACEHOLDER, showMonthYearPicker: true, renderHeader: (headerProps) => (React.createElement(MonthDatePickerHeader, { locale: props.locale, ...headerProps })), onUpKeyPress: handleUpKey, onDownKeyPress: handleDownKey, onEnterKeyPress: handleEnterKey }));
|
|
40
28
|
});
|
|
41
29
|
export default MonthPicker;
|
|
@@ -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 propTypes from "@styled-system/prop-types";
|
|
13
2
|
import { addDays, endOfWeek, getWeek, getYear, isAfter, isBefore, isSameDay, isValid, startOfWeek, subDays, } from "date-fns";
|
|
14
3
|
import React, { forwardRef, useEffect, useState } from "react";
|
|
@@ -40,8 +29,7 @@ const roundMaxDateToWeekEnd = (date) => {
|
|
|
40
29
|
const weekEnd = endOfWeek(date, { weekStartsOn: WEEK_START_DAY });
|
|
41
30
|
return isBefore(date, weekEnd) ? addDays(startOfWeek(date, { weekStartsOn: WEEK_START_DAY }), -1) : weekEnd;
|
|
42
31
|
};
|
|
43
|
-
const WeekPicker = forwardRef((
|
|
44
|
-
var { dateFormat, errorMessage, errorList, inputProps, minDate, maxDate, locale, disableFlipping, className, onInputChange, onChange, onBlur, onFocus, selected } = _a, props = __rest(_a, ["dateFormat", "errorMessage", "errorList", "inputProps", "minDate", "maxDate", "locale", "disableFlipping", "className", "onInputChange", "onChange", "onBlur", "onFocus", "selected"]);
|
|
32
|
+
const WeekPicker = forwardRef(({ dateFormat, errorMessage, errorList, inputProps, minDate, maxDate, locale, disableFlipping, className, onInputChange, onChange, onBlur, onFocus, selected, ...props }, datePickerRef) => {
|
|
45
33
|
const [selectedDate, setSelectedDate] = useState(selected);
|
|
46
34
|
const { locale: contextLocale } = useLocale();
|
|
47
35
|
const { i18n } = useTranslation();
|
|
@@ -111,7 +99,7 @@ const WeekPicker = forwardRef((_a, datePickerRef) => {
|
|
|
111
99
|
}
|
|
112
100
|
};
|
|
113
101
|
const renderCustomHeader = (props) => {
|
|
114
|
-
return React.createElement(DatePickerHeader,
|
|
102
|
+
return React.createElement(DatePickerHeader, { locale: currentLocale, ...props });
|
|
115
103
|
};
|
|
116
104
|
const weekPickerRefHandler = (r) => {
|
|
117
105
|
if (datePickerRef) {
|
|
@@ -119,10 +107,15 @@ const WeekPicker = forwardRef((_a, datePickerRef) => {
|
|
|
119
107
|
}
|
|
120
108
|
onRefChange(r);
|
|
121
109
|
};
|
|
122
|
-
const customInputProps =
|
|
123
|
-
|
|
110
|
+
const customInputProps = {
|
|
111
|
+
...InputFieldDefaultProps,
|
|
112
|
+
error: !!(errorMessage || errorList),
|
|
113
|
+
...inputProps,
|
|
114
|
+
placeholder: (inputProps && inputProps.placeholder) ||
|
|
115
|
+
(finalDateFormat === defaultDateFormat ? defaultPlaceholder : finalDateFormat),
|
|
116
|
+
};
|
|
124
117
|
const customInput = (React.createElement(DatePickerInput, { locale: currentLocale, variant: componentVariant, inputProps: customInputProps, dateFormat: finalDateFormat, onInputChange: handleInputChange, onUpKeyPress: handleUpKey, onDownKeyPress: handleDownKey, onEnterKeyPress: handleEnterKey }));
|
|
125
|
-
return (React.createElement(Field,
|
|
118
|
+
return (React.createElement(Field, { className: `${className} nds-date-picker`, ...spaceProps },
|
|
126
119
|
React.createElement(DatePickerStyles, null),
|
|
127
120
|
React.createElement(WeekPickerStyles, { variant: componentVariant }),
|
|
128
121
|
React.createElement(ReactDatePicker, { showWeekNumbers: true, showWeekPicker: true, weekLabel: weekShorthand, calendarStartDay: WEEK_START_DAY, selected: selectedDate, openToDate: selectedDate, dateFormat: finalDateFormat, onChange: handleSelectedDateChange, customInput: customInput, renderCustomHeader: renderCustomHeader, strictParsing: true, minDate: roundedMinDate, maxDate: roundedMaxDate, locale: NDS_TO_DATE_FN_LOCALES_MAP[currentLocale], ref: weekPickerRefHandler, onFocus: onFocus, onBlur: onBlur, popperModifiers: getPopperModifiers(disableFlipping), disabledKeyboardNavigation: true }),
|
|
@@ -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, useState } from "react";
|
|
13
2
|
import propTypes from "@styled-system/prop-types";
|
|
14
3
|
import ReactDatePicker from "react-datepicker";
|
|
@@ -23,8 +12,7 @@ import { InlineValidation } from "../../../Validation";
|
|
|
23
12
|
import { DatePickerStyles } from "../styles";
|
|
24
13
|
import { getPopperModifiers } from "../helpers";
|
|
25
14
|
import DatePickerInput from "./DatePickerInput";
|
|
26
|
-
export const BasePicker = forwardRef((
|
|
27
|
-
var { dateFormat, errorMessage, errorList, inputProps, minDate, maxDate, disableFlipping, className, onInputChange, onChange, onBlur, onFocus, selected, highlightDates, defaultFormat, defaultPlaceholder, showMonthYearPicker, showWeekNumbers, renderHeader, onUpKeyPress, onDownKeyPress, onEnterKeyPress, locale, disabledKeyboardNavigation, name, required } = _a, props = __rest(_a, ["dateFormat", "errorMessage", "errorList", "inputProps", "minDate", "maxDate", "disableFlipping", "className", "onInputChange", "onChange", "onBlur", "onFocus", "selected", "highlightDates", "defaultFormat", "defaultPlaceholder", "showMonthYearPicker", "showWeekNumbers", "renderHeader", "onUpKeyPress", "onDownKeyPress", "onEnterKeyPress", "locale", "disabledKeyboardNavigation", "name", "required"]);
|
|
15
|
+
export const BasePicker = forwardRef(({ dateFormat, errorMessage, errorList, inputProps, minDate, maxDate, disableFlipping, className, onInputChange, onChange, onBlur, onFocus, selected, highlightDates, defaultFormat, defaultPlaceholder, showMonthYearPicker, showWeekNumbers, renderHeader, onUpKeyPress, onDownKeyPress, onEnterKeyPress, locale, disabledKeyboardNavigation, name, required, ...props }, pickerRef) => {
|
|
28
16
|
const { locale: contextLocale } = useLocale();
|
|
29
17
|
const [ref, setRef] = useState(null);
|
|
30
18
|
const componentVariant = useComponentVariant();
|
|
@@ -48,7 +36,13 @@ export const BasePicker = forwardRef((_a, pickerRef) => {
|
|
|
48
36
|
ref.setOpen(!isOpen);
|
|
49
37
|
}
|
|
50
38
|
};
|
|
51
|
-
const customInputProps =
|
|
39
|
+
const customInputProps = {
|
|
40
|
+
...InputFieldDefaultProps,
|
|
41
|
+
inputWidth: componentVariant === "touch" ? "280px" : "184px",
|
|
42
|
+
error: !!(errorMessage || errorList),
|
|
43
|
+
...inputProps,
|
|
44
|
+
placeholder: (inputProps && inputProps.placeholder) || (dateFormat === defaultFormat ? defaultPlaceholder : dateFormat),
|
|
45
|
+
};
|
|
52
46
|
const customInput = (React.createElement(DatePickerInput, { locale: currentLocale, variant: componentVariant, inputProps: customInputProps, dateFormat: dateFormat, onInputChange: handleInputChange, onUpKeyPress: onUpKeyPress, onDownKeyPress: onDownKeyPress, onEnterKeyPress: handleEnterKey }));
|
|
53
47
|
const pickerRefHandler = (r) => {
|
|
54
48
|
if (pickerRef) {
|
|
@@ -57,7 +51,7 @@ export const BasePicker = forwardRef((_a, pickerRef) => {
|
|
|
57
51
|
onRefChange(r);
|
|
58
52
|
};
|
|
59
53
|
const spaceProps = getSubset(props, propTypes.space);
|
|
60
|
-
return (React.createElement(Field,
|
|
54
|
+
return (React.createElement(Field, { className: `${className} nds-date-picker`, ...spaceProps },
|
|
61
55
|
React.createElement(DatePickerStyles, null),
|
|
62
56
|
React.createElement(ReactDatePicker, { highlightDates: highlightDates, selected: selected, openToDate: selected, dateFormat: dateFormat, onChange: onChange, customInput: customInput, renderCustomHeader: renderHeader, strictParsing: true, minDate: minDate, maxDate: maxDate, locale: NDS_TO_DATE_FN_LOCALES_MAP[currentLocale], ref: pickerRefHandler, onFocus: onFocus, onBlur: onBlur, showMonthYearPicker: showMonthYearPicker, showWeekNumbers: showWeekNumbers, name: name, required: required, onEnterKeyPress: onEnterKeyPress, popperModifiers: getPopperModifiers(disableFlipping), disabledKeyboardNavigation: disabledKeyboardNavigation }),
|
|
63
57
|
React.createElement(InlineValidation, { mt: "x1", errorMessage: errorMessage, errorList: errorList })));
|
|
@@ -1,20 +1,9 @@
|
|
|
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 { useTranslation } from "react-i18next";
|
|
14
3
|
import { InputField, InputFieldDefaultProps } from "../../../Input/InputField";
|
|
15
4
|
const DatePickerInput = forwardRef(({ onChange, onClick, onBlur, onFocus, onInputChange, value, inputProps = InputFieldDefaultProps, onUpKeyPress, onDownKeyPress, onEnterKeyPress, variant, locale, "aria-label": ariaLabel, }, ref) => {
|
|
16
5
|
const { i18n } = useTranslation();
|
|
17
|
-
const { placeholder
|
|
6
|
+
const { placeholder, ...inputFieldProps } = inputProps;
|
|
18
7
|
const handleChange = (event) => {
|
|
19
8
|
onInputChange(event);
|
|
20
9
|
if (onChange) {
|
|
@@ -40,6 +29,6 @@ const DatePickerInput = forwardRef(({ onChange, onClick, onBlur, onFocus, onInpu
|
|
|
40
29
|
break;
|
|
41
30
|
}
|
|
42
31
|
};
|
|
43
|
-
return (React.createElement(InputField,
|
|
32
|
+
return (React.createElement(InputField, { onBlur: onBlur, onFocus: onFocus, ref: ref, variant: variant, "aria-label": ariaLabel || t("select a date"), autoComplete: "off", value: value, placeholder: placeholder, iconRight: "calendarToday", iconRightSize: "x2", onClick: onClick, onKeyDown: handleKeyDown, onChange: handleChange, ...inputFieldProps }));
|
|
44
33
|
});
|
|
45
34
|
export default DatePickerInput;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { StoryObj } from "@storybook/react";
|
|
3
|
+
import { DatePicker } from "../index";
|
|
2
4
|
declare const _default: {
|
|
3
5
|
title: string;
|
|
6
|
+
component: React.ForwardRefExoticComponent<Omit<import("../shared/types").DatePickerProps, "ref"> & React.RefAttributes<ReactDatePicker>>;
|
|
4
7
|
};
|
|
5
8
|
export default _default;
|
|
6
|
-
|
|
7
|
-
export declare const
|
|
9
|
+
type Story = StoryObj<typeof DatePicker>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const WithCustomDateFormat: Story;
|
|
8
12
|
export declare const WithCustomPlaceholder: () => React.JSX.Element;
|
|
9
13
|
export declare const WithErrorState: () => React.JSX.Element;
|
|
10
14
|
export declare const WithMinAndMaxDate: () => React.JSX.Element;
|
|
11
|
-
export declare const DisableFlipping:
|
|
15
|
+
export declare const DisableFlipping: Story;
|
|
12
16
|
export declare const UsingRefToControlFocus: () => React.JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
2
|
import { action } from "@storybook/addon-actions";
|
|
3
|
-
import { select, boolean } from "@storybook/addon-knobs";
|
|
4
3
|
import { DatePicker } from "../index";
|
|
5
4
|
import { Button } from "../..";
|
|
6
5
|
const selectedDateExamples = [
|
|
@@ -10,31 +9,64 @@ const selectedDateExamples = [
|
|
|
10
9
|
];
|
|
11
10
|
export default {
|
|
12
11
|
title: "Components/DatePickers/DatePicker",
|
|
12
|
+
component: DatePicker,
|
|
13
|
+
};
|
|
14
|
+
export const Default = {
|
|
15
|
+
args: {
|
|
16
|
+
selected: selectedDateExamples[0],
|
|
17
|
+
onChange: action("date changed"),
|
|
18
|
+
onFocus: action("date selector focused"),
|
|
19
|
+
onBlur: action("date selector blurred"),
|
|
20
|
+
onInputChange: action("input changed"),
|
|
21
|
+
inputProps: { labelText: "Expiry Date" },
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
selected: {
|
|
25
|
+
control: { type: "select" },
|
|
26
|
+
options: selectedDateExamples,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const WithCustomDateFormat = {
|
|
31
|
+
args: {
|
|
32
|
+
selected: selectedDateExamples[0],
|
|
33
|
+
dateFormat: "MMMM d, yyyy",
|
|
34
|
+
onChange: action("date changed"),
|
|
35
|
+
onFocus: action("date selector focused"),
|
|
36
|
+
onBlur: action("date selector blurred"),
|
|
37
|
+
onInputChange: action("input changed"),
|
|
38
|
+
inputProps: { labelText: "Expiry Date" },
|
|
39
|
+
},
|
|
40
|
+
argTypes: {
|
|
41
|
+
selected: {
|
|
42
|
+
control: { type: "select" },
|
|
43
|
+
options: selectedDateExamples,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
13
46
|
};
|
|
14
|
-
export const Default = () => (React.createElement(DatePicker
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
//@ts-ignore
|
|
17
|
-
, {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
|
-
//@ts-ignore
|
|
20
|
-
selected: select("selected", selectedDateExamples, selectedDateExamples[0], "selected"), onChange: action("date changed"), onFocus: action("date selector focused"), onBlur: action("date selector blurred"), onInputChange: action("input changed"), inputProps: { labelText: "Expiry Date" } }));
|
|
21
|
-
export const WithCustomDateFormat = () => (React.createElement(DatePicker
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23
|
-
//@ts-ignore
|
|
24
|
-
, {
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
26
|
-
//@ts-ignore
|
|
27
|
-
selected: select("selected", selectedDateExamples, selectedDateExamples[0], "selected"), dateFormat: "MMMM d, yyyy", onChange: action("date changed"), onFocus: action("date selector focused"), onBlur: action("date selector blurred"), onInputChange: action("input changed"), inputProps: { labelText: "Expiry Date" } }));
|
|
28
47
|
export const WithCustomPlaceholder = () => (React.createElement(DatePicker, { dateFormat: "MMMM d, yyyy", onFocus: action("date selector focused"), onBlur: action("date selector blurred"), onChange: action("date changed"), onInputChange: action("input changed"), inputProps: { labelText: "Expiry Date", placeholder: "Month day, year" } }));
|
|
29
48
|
export const WithErrorState = () => (React.createElement(DatePicker, { dateFormat: "MMMM d, yyyy", onFocus: action("date selector focused"), onBlur: action("date selector blurred"), onChange: action("date changed"), onInputChange: action("input changed"), inputProps: { labelText: "Expiry Date" }, errorMessage: "The date is invalid" }));
|
|
30
49
|
export const WithMinAndMaxDate = () => (React.createElement(DatePicker, { selected: new Date("2019-01-05T05:00:00.000Z"), minDate: new Date("2019-01-03T05:00:00.000Z"), maxDate: new Date("2019-01-10T05:00:00.000Z"), onFocus: action("date selector focused"), onBlur: action("date selector blurred"), onChange: action("date changed"), onInputChange: action("input changed"), inputProps: { labelText: "Expiry Date" } }));
|
|
31
|
-
export const DisableFlipping =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
export const DisableFlipping = {
|
|
51
|
+
args: {
|
|
52
|
+
selected: selectedDateExamples[0],
|
|
53
|
+
onBlur: action("date selector blurred"),
|
|
54
|
+
onFocus: action("date selector focused"),
|
|
55
|
+
onChange: action("date changed"),
|
|
56
|
+
onInputChange: action("input changed"),
|
|
57
|
+
inputProps: { labelText: "Expiry Date" },
|
|
58
|
+
disableFlipping: true,
|
|
59
|
+
},
|
|
60
|
+
argTypes: {
|
|
61
|
+
selected: {
|
|
62
|
+
control: { type: "select" },
|
|
63
|
+
options: selectedDateExamples,
|
|
64
|
+
},
|
|
65
|
+
disableFlipping: {
|
|
66
|
+
control: { type: "boolean" },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
38
70
|
export const UsingRefToControlFocus = () => {
|
|
39
71
|
const ref = useRef(null);
|
|
40
72
|
const handleClick = () => {
|
|
@@ -33,7 +33,7 @@ export const AdvancedUsage = () => {
|
|
|
33
33
|
setInputValue(value);
|
|
34
34
|
// Custom validation could be implemented here
|
|
35
35
|
};
|
|
36
|
-
return (React.createElement(WeekPicker, { selected: selectedWeek
|
|
36
|
+
return (React.createElement(WeekPicker, { selected: selectedWeek?.startDate, onChange: handleWeekChange, onInputChange: handleInputChange, minDate: new Date(2023, 0, 1), maxDate: new Date(), errorMessage: hasError ? "Please select a valid week" : undefined, inputProps: {
|
|
37
37
|
value: inputValue,
|
|
38
38
|
inputWidth: "560px",
|
|
39
39
|
placeholder: "Select a week",
|
|
@@ -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, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from "react";
|
|
13
2
|
import { isBefore, isSameDay } from "date-fns";
|
|
14
3
|
import { useTranslation } from "react-i18next";
|
|
@@ -21,8 +10,10 @@ import EndTime from "./EndTime";
|
|
|
21
10
|
import StartTime from "./StartTime";
|
|
22
11
|
import { useComponentVariant } from "../NDSProvider/ComponentVariantContext";
|
|
23
12
|
const DEFAULT_LABEL = "Date Range";
|
|
24
|
-
const DateRange = forwardRef((
|
|
25
|
-
|
|
13
|
+
const DateRange = forwardRef(({ dateFormat, onRangeChange, onStartDateChange, onEndDateChange, errorMessage, startDateErrorMessage, endDateErrorMessage, defaultStartDate = null, defaultEndDate = null, endDateInputProps, startDateInputProps, disableRangeValidation, labelProps = {
|
|
14
|
+
...FieldLabelDefaultProps,
|
|
15
|
+
labelText: DEFAULT_LABEL,
|
|
16
|
+
}, minDate, maxDate, showTimes, minTime, maxTime, defaultStartTime, defaultEndTime, onStartTimeChange, onEndTimeChange, timeFormat, interval, disableFlipping = false, locale, endTimeProps, startTimeProps, variant, ...props }, ref) => {
|
|
26
17
|
const dateRef1 = useRef(null);
|
|
27
18
|
const dateRef2 = useRef(null);
|
|
28
19
|
const timeRef1 = useRef(null);
|
|
@@ -35,10 +26,22 @@ const DateRange = forwardRef((_a, ref) => {
|
|
|
35
26
|
const { t } = useTranslation();
|
|
36
27
|
const componentVariant = useComponentVariant(variant);
|
|
37
28
|
useImperativeHandle(ref, () => ({
|
|
38
|
-
dateRef1:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
dateRef1: {
|
|
30
|
+
...dateRef1,
|
|
31
|
+
focus: () => dateRef1.current?.setFocus(),
|
|
32
|
+
},
|
|
33
|
+
dateRef2: {
|
|
34
|
+
...dateRef2,
|
|
35
|
+
focus: () => dateRef2.current?.setFocus(),
|
|
36
|
+
},
|
|
37
|
+
timeRef1: {
|
|
38
|
+
...timeRef1,
|
|
39
|
+
focus: () => timeRef1.current?.focus(),
|
|
40
|
+
},
|
|
41
|
+
timeRef2: {
|
|
42
|
+
...timeRef2,
|
|
43
|
+
focus: () => timeRef2.current?.focus(),
|
|
44
|
+
},
|
|
42
45
|
}));
|
|
43
46
|
useEffect(() => {
|
|
44
47
|
validateDateRange();
|
|
@@ -91,15 +94,26 @@ const DateRange = forwardRef((_a, ref) => {
|
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
|
-
const startInputProps =
|
|
97
|
+
const startInputProps = {
|
|
98
|
+
"aria-label": t("select a start date"),
|
|
99
|
+
error: rangeError,
|
|
100
|
+
...startDateInputProps,
|
|
101
|
+
};
|
|
95
102
|
const startDateInput = (React.createElement(React.Fragment, null,
|
|
96
103
|
React.createElement(DatePicker, { dateFormat: dateFormat, selected: startDate, onChange: changeStartDateHandler, inputProps: startInputProps, errorMessage: startDateErrorMessage, minDate: minDate, maxDate: maxDate, highlightDates: highlightDates(startDate, endDate), locale: locale, disableFlipping: disableFlipping, ref: dateRef1 }),
|
|
97
|
-
showTimes && (React.createElement(StartTime,
|
|
104
|
+
showTimes && (React.createElement(StartTime, { variant: componentVariant, selected: startTime, defaultValue: defaultStartTime, "aria-label": t("select a start time"), minTime: minTime, maxTime: maxTime, timeFormat: timeFormat, interval: interval, onChange: changeStartTimeHandler, locale: locale, "data-testid": "daterange-start-time", ref: timeRef1, error: !!rangeError, ...startTimeProps }))));
|
|
98
105
|
const endDateInput = (React.createElement(React.Fragment, null,
|
|
99
|
-
showTimes && (React.createElement(EndTime,
|
|
100
|
-
React.createElement(DatePicker, { dateFormat: dateFormat, selected: endDate, onChange: changeEndDateHandler, inputProps:
|
|
106
|
+
showTimes && (React.createElement(EndTime, { variant: componentVariant, selected: endTime, defaultValue: defaultEndTime, minTime: minTime, maxTime: maxTime, timeFormat: timeFormat, interval: interval, onChange: changeEndTimeHandler, locale: locale, "aria-label": t("select an end time"), "data-testid": "daterange-end-time", ref: timeRef2, error: !!rangeError, ...endTimeProps })),
|
|
107
|
+
React.createElement(DatePicker, { dateFormat: dateFormat, selected: endDate, onChange: changeEndDateHandler, inputProps: {
|
|
108
|
+
"aria-label": t("select an end date"),
|
|
109
|
+
error: rangeError,
|
|
110
|
+
...endDateInputProps,
|
|
111
|
+
}, errorMessage: endDateErrorMessage, minDate: minDate, maxDate: maxDate, highlightDates: highlightDates(startDate, endDate), locale: locale, disableFlipping: disableFlipping, ref: dateRef2 })));
|
|
101
112
|
return (React.createElement(React.Fragment, null,
|
|
102
113
|
React.createElement(DateRangeStyles, null),
|
|
103
|
-
React.createElement(RangeContainer,
|
|
114
|
+
React.createElement(RangeContainer, { variant: componentVariant, labelProps: {
|
|
115
|
+
...labelProps,
|
|
116
|
+
labelText: labelProps.labelText === DEFAULT_LABEL ? t("date range") : labelProps.labelText,
|
|
117
|
+
}, startComponent: startDateInput, endComponent: endDateInput, errorMessages: !disableRangeValidation ? [t(rangeError), errorMessage] : [errorMessage], ...props })));
|
|
104
118
|
});
|
|
105
119
|
export default DateRange;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
declare const EndTime: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
|
3
2
|
variant?: import("../NDSProvider/ComponentVariantContext").ComponentVariant;
|
|
4
3
|
disabled?: boolean;
|
|
@@ -14,14 +13,14 @@ declare const EndTime: import("styled-components/dist/types").IStyledComponentBa
|
|
|
14
13
|
defaultValue?: string;
|
|
15
14
|
"aria-label"?: string;
|
|
16
15
|
errorMessage?: string;
|
|
17
|
-
errorList?:
|
|
16
|
+
errorList?: React.ReactNode;
|
|
18
17
|
labelText?: string;
|
|
19
18
|
ref?: any;
|
|
20
19
|
onBlur?: (...args: any[]) => any;
|
|
21
20
|
onFocus?: (...args: any[]) => any;
|
|
22
21
|
onClick?: (...args: any[]) => any;
|
|
23
22
|
} & {
|
|
24
|
-
children?: import("react").ReactNode;
|
|
23
|
+
children?: import("react").ReactNode | undefined;
|
|
25
24
|
}, "ref"> & {
|
|
26
25
|
ref?: any;
|
|
27
26
|
}, never>> & string & Omit<import("react").FC<import("react").PropsWithChildren<import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
|
@@ -39,7 +38,7 @@ declare const EndTime: import("styled-components/dist/types").IStyledComponentBa
|
|
|
39
38
|
defaultValue?: string;
|
|
40
39
|
"aria-label"?: string;
|
|
41
40
|
errorMessage?: string;
|
|
42
|
-
errorList?:
|
|
41
|
+
errorList?: React.ReactNode;
|
|
43
42
|
labelText?: string;
|
|
44
43
|
ref?: any;
|
|
45
44
|
onBlur?: (...args: any[]) => any;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
declare const StartTime: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
|
3
2
|
variant?: import("../NDSProvider/ComponentVariantContext").ComponentVariant;
|
|
4
3
|
disabled?: boolean;
|
|
@@ -14,14 +13,14 @@ declare const StartTime: import("styled-components/dist/types").IStyledComponent
|
|
|
14
13
|
defaultValue?: string;
|
|
15
14
|
"aria-label"?: string;
|
|
16
15
|
errorMessage?: string;
|
|
17
|
-
errorList?:
|
|
16
|
+
errorList?: React.ReactNode;
|
|
18
17
|
labelText?: string;
|
|
19
18
|
ref?: any;
|
|
20
19
|
onBlur?: (...args: any[]) => any;
|
|
21
20
|
onFocus?: (...args: any[]) => any;
|
|
22
21
|
onClick?: (...args: any[]) => any;
|
|
23
22
|
} & {
|
|
24
|
-
children?: import("react").ReactNode;
|
|
23
|
+
children?: import("react").ReactNode | undefined;
|
|
25
24
|
}, "ref"> & {
|
|
26
25
|
ref?: any;
|
|
27
26
|
}, never>> & string & Omit<import("react").FC<import("react").PropsWithChildren<import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & {
|
|
@@ -39,7 +38,7 @@ declare const StartTime: import("styled-components/dist/types").IStyledComponent
|
|
|
39
38
|
defaultValue?: string;
|
|
40
39
|
"aria-label"?: string;
|
|
41
40
|
errorMessage?: string;
|
|
42
|
-
errorList?:
|
|
41
|
+
errorList?: React.ReactNode;
|
|
43
42
|
labelText?: string;
|
|
44
43
|
ref?: any;
|
|
45
44
|
onBlur?: (...args: any[]) => any;
|
|
@@ -11,7 +11,7 @@ const RightAngleTriangle = styled(Box) `
|
|
|
11
11
|
`;
|
|
12
12
|
export default function BackgroundTriangles(props) {
|
|
13
13
|
const theme = useTheme();
|
|
14
|
-
return (React.createElement(Box,
|
|
14
|
+
return (React.createElement(Box, { "aria-hidden": "true", transition: "max-width 0.3s cubic-bezier(0.455, 0.03, 0.515, 0.955)", position: "absolute", bottom: 0, right: 0, height: "100%", maxWidth: { extraSmall: "320px", small: "768px", medium: "1024px", large: "1280px" }, width: "90%", ...props },
|
|
15
15
|
React.createElement(RightAngleTriangle, { "aria-hidden": "true", height: "44.85%", opacity: "0.5", background: "linear-gradient(178.25deg, rgba(192, 200, 209, 0.5) 62.98%, rgba(225, 235, 250, 0.25) 98.52%)" }),
|
|
16
16
|
React.createElement(RightAngleTriangle, { "aria-hidden": "true", height: "19.85%", opacity: "0.25", background: `linear-gradient(196.88deg, ${theme.colors.grey} 11.92%, rgba(0, 67, 143, 0) 88.36%)` })));
|
|
17
17
|
}
|
|
@@ -1,20 +1,8 @@
|
|
|
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 from "react";
|
|
13
2
|
import { DescriptionListProvider } from "./DescriptionListContext";
|
|
14
3
|
import { validateAndExtractGridProps } from "./lib/utils";
|
|
15
4
|
import { DescriptionList as Dl, DescriptionListContainer } from "./DescriptionList.parts";
|
|
16
|
-
export default function DescriptionList(
|
|
17
|
-
var { descriptionTermMaxWidth = "320px", layout = "stacked", autoLayoutBreakpoint = "640px", showDivider = false, density = "medium", fontSize = "medium", lineHeight = "base", children } = _a, props = __rest(_a, ["descriptionTermMaxWidth", "layout", "autoLayoutBreakpoint", "showDivider", "density", "fontSize", "lineHeight", "children"]);
|
|
5
|
+
export default function DescriptionList({ descriptionTermMaxWidth = "320px", layout = "stacked", autoLayoutBreakpoint = "640px", showDivider = false, density = "medium", fontSize = "medium", lineHeight = "base", children, ...props }) {
|
|
18
6
|
const { columns, groupMinWidth } = validateAndExtractGridProps(props);
|
|
19
7
|
return (React.createElement(DescriptionListProvider, { descriptionTermMaxWidth: descriptionTermMaxWidth, layout: layout, autoLayoutBreakpoint: autoLayoutBreakpoint, showDivider: showDivider, density: density, fontSize: fontSize, lineHeight: lineHeight, columns: columns, groupMinWidth: groupMinWidth },
|
|
20
8
|
React.createElement(DescriptionListContainer, null,
|