@indico-data/design-system 3.18.0 → 3.20.0
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/.eslintrc.js +87 -2
- package/.husky/pre-commit +2 -0
- package/.vscode/settings.json +10 -1
- package/lib/components/badge/Badge.d.ts +1 -1
- package/lib/components/badge/Badge.stories.d.ts +1 -1
- package/lib/components/button/Button.d.ts +2 -2
- package/lib/components/button/Button.stories.d.ts +1 -1
- package/lib/components/button/types.d.ts +1 -1
- package/lib/components/card/Card.d.ts +1 -1
- package/lib/components/card/Card.stories.d.ts +1 -1
- package/lib/components/floatUI/FloatUI.d.ts +1 -1
- package/lib/components/floatUI/FloatUI.stories.d.ts +2 -2
- package/lib/components/floatUI/types.d.ts +2 -2
- package/lib/components/forms/checkbox/Checkbox.stories.d.ts +1 -1
- package/lib/components/forms/date/datePicker/DatePicker.d.ts +1 -1
- package/lib/components/forms/date/datePicker/DatePicker.stories.d.ts +1 -1
- package/lib/components/forms/date/datePicker/contants.d.ts +1 -1
- package/lib/components/forms/date/datePicker/types.d.ts +8 -1
- package/lib/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.d.ts +7 -4
- package/lib/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.stories.d.ts +1 -1
- package/lib/components/forms/date/iconTriggerDatePicker/types.d.ts +5 -0
- package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.d.ts +4 -3
- package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.stories.d.ts +1 -1
- package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +7 -4
- package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.d.ts +1 -1
- package/lib/components/forms/date/inputDateRangePicker/types.d.ts +7 -0
- package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +4 -3
- package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.d.ts +1 -1
- package/lib/components/forms/form/Form.d.ts +1 -1
- package/lib/components/forms/form/Form.stories.d.ts +1 -1
- package/lib/components/forms/input/Input.d.ts +2 -2
- package/lib/components/forms/input/Input.stories.d.ts +1 -1
- package/lib/components/forms/numberInput/NumberInput.d.ts +2 -2
- package/lib/components/forms/numberInput/NumberInput.stories.d.ts +1 -1
- package/lib/components/forms/passwordInput/PasswordInput.d.ts +1 -1
- package/lib/components/forms/passwordInput/PasswordInput.stories.d.ts +1 -1
- package/lib/components/forms/radio/Radio.stories.d.ts +1 -1
- package/lib/components/forms/select/Select.d.ts +4 -2
- package/lib/components/forms/select/Select.stories.d.ts +4 -4
- package/lib/components/forms/select/types.d.ts +11 -1
- package/lib/components/forms/subcomponents/Label.d.ts +5 -1
- package/lib/components/forms/subcomponents/types.d.ts +5 -0
- package/lib/components/forms/textarea/Textarea.d.ts +1 -1
- package/lib/components/forms/textarea/Textarea.stories.d.ts +1 -1
- package/lib/components/forms/timePicker/TimePicker.d.ts +4 -1
- package/lib/components/forms/timePicker/types.d.ts +5 -0
- package/lib/components/forms/toggle/Toggle.stories.d.ts +1 -1
- package/lib/components/grid/col/Col.d.ts +1 -1
- package/lib/components/grid/col/Col.stories.d.ts +1 -1
- package/lib/components/grid/container/Container.d.ts +1 -1
- package/lib/components/grid/container/Container.stories.d.ts +1 -1
- package/lib/components/grid/row/Row.d.ts +1 -1
- package/lib/components/grid/row/Row.stories.d.ts +1 -1
- package/lib/components/icons/Icon.d.ts +1 -1
- package/lib/components/icons/Icon.stories.d.ts +2 -2
- package/lib/components/icons/indicons.d.ts +1 -1
- package/lib/components/icons/types.d.ts +4 -4
- package/lib/components/loading-indicators/BarSpinner/BarSpinner.stories.d.ts +1 -1
- package/lib/components/loading-indicators/CirclePulse/CirclePulse.stories.d.ts +1 -1
- package/lib/components/menu/Menu.stories.d.ts +2 -2
- package/lib/components/modal/ConfirmationModal.d.ts +2 -2
- package/lib/components/modal/Modal.d.ts +2 -2
- package/lib/components/modal/Modal.stories.d.ts +6 -2
- package/lib/components/modal/types.d.ts +21 -7
- package/lib/components/pagination/Pagination.d.ts +2 -2
- package/lib/components/pagination/Pagination.stories.d.ts +1 -1
- package/lib/components/pagination/index.d.ts +1 -0
- package/lib/components/pagination/types.d.ts +13 -0
- package/lib/components/pill/Pill.d.ts +1 -1
- package/lib/components/pill/Pill.stories.d.ts +1 -1
- package/lib/components/pill/types.d.ts +2 -2
- package/lib/components/skeleton/Skeleton.stories.d.ts +1 -1
- package/lib/components/stepper/Stepper.d.ts +2 -2
- package/lib/components/stepper/Stepper.stories.d.ts +1 -1
- package/lib/components/stepper/components/BackNavigation.d.ts +2 -1
- package/lib/components/stepper/components/Legend.d.ts +1 -1
- package/lib/components/stepper/components/NextNavigation.d.ts +3 -1
- package/lib/components/stepper/types.d.ts +12 -1
- package/lib/components/table/LoadingComponent.d.ts +5 -1
- package/lib/components/table/Table.d.ts +1 -1
- package/lib/components/table/Table.stories.d.ts +2 -2
- package/lib/components/table/components/HorizontalStickyHeader.d.ts +4 -1
- package/lib/components/table/components/helpers.d.ts +1 -1
- package/lib/components/table/hooks/usePinnedColumnsManager.d.ts +2 -2
- package/lib/components/table/sampleData.d.ts +1 -1
- package/lib/components/table/types.d.ts +20 -2
- package/lib/components/table/utils/processColumns.d.ts +2 -2
- package/lib/components/tanstackTable/TankstackTable.types.d.ts +20 -3
- package/lib/components/tanstackTable/TanstackTable.d.ts +2 -2
- package/lib/components/tanstackTable/TanstackTable.stories.d.ts +2 -2
- package/lib/components/tanstackTable/__tests__/__mocks__/test-mock-data.d.ts +1 -1
- package/lib/components/tanstackTable/components/ActionBar/ActionBar.d.ts +2 -2
- package/lib/components/tanstackTable/components/ActionBar/ActionBar.stories.d.ts +1 -1
- package/lib/components/tanstackTable/components/NoResults/NoResults.d.ts +2 -1
- package/lib/components/tanstackTable/components/TableBody/TableBody.d.ts +1 -1
- package/lib/components/tanstackTable/components/TableHeader/TableHeader.d.ts +1 -1
- package/lib/components/tanstackTable/components/TableLoading/TableLoading.d.ts +1 -1
- package/lib/components/tanstackTable/components/TablePagination/TablePagination.d.ts +3 -1
- package/lib/components/tanstackTable/docs/internalSorting/InternalClientSideSorting.stories.d.ts +2 -2
- package/lib/components/tanstackTable/docs/pinnedColumns/PinnedColumn.stories.d.ts +2 -2
- package/lib/components/tanstackTable/docs/withRowClick/WithRowClick.stories.d.ts +2 -2
- package/lib/components/tanstackTable/helpers.d.ts +2 -2
- package/lib/components/tanstackTable/mock-data/table-configuration.d.ts +2 -2
- package/lib/components/tanstackTable/useTanstackTable.d.ts +1 -1
- package/lib/components/toast/Toast.stories.d.ts +1 -1
- package/lib/components/tooltip/Tooltip.d.ts +2 -2
- package/lib/components/tooltip/Tooltip.stories.d.ts +1 -1
- package/lib/components/truncate/Truncate.d.ts +1 -1
- package/lib/components/truncate/Truncate.stories.d.ts +2 -2
- package/lib/components/truncate/types.d.ts +1 -1
- package/lib/docs/BaseColorPalette/BaseColorsPalette.stories.d.ts +1 -1
- package/lib/docs/SemanticTokens/ColorSwatch.d.ts +1 -1
- package/lib/docs/SemanticTokens/SemanticTokens.stories.d.ts +1 -1
- package/lib/index.d.ts +165 -45
- package/lib/index.esm.js +253 -170
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +253 -170
- package/lib/index.js.map +1 -1
- package/lib/setup/setupIcons.d.ts +1 -1
- package/lib/storybook/formArgTypes.d.ts +1 -1
- package/lib/stylesAndAnimations/borders/BorderColor.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/borders/BorderRadius.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/borders/BorderStyles.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/borders/BorderThickness.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/colors/UtilityClasses.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/sizing/Sizing.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/typography/Typography.stories.d.ts +1 -1
- package/lib/stylesAndAnimations/utilityClasses/UtilityClassesTable.stories.d.ts +1 -1
- package/lib/types.d.ts +4 -4
- package/package.json +8 -2
- package/src/components/badge/Badge.stories.tsx +4 -3
- package/src/components/badge/Badge.tsx +2 -1
- package/src/components/badge/__tests__/Badge.test.tsx +1 -0
- package/src/components/button/Button.stories.tsx +5 -4
- package/src/components/button/Button.tsx +12 -22
- package/src/components/button/__tests__/Button.test.tsx +31 -28
- package/src/components/button/types.ts +1 -1
- package/src/components/card/Card.stories.tsx +2 -1
- package/src/components/card/Card.tsx +2 -1
- package/src/components/card/__tests__/Card.test.tsx +1 -0
- package/src/components/floatUI/FloatUI.stories.tsx +3 -2
- package/src/components/floatUI/FloatUI.tsx +6 -7
- package/src/components/floatUI/__tests__/FloatUI.test.tsx +5 -3
- package/src/components/floatUI/types.ts +2 -2
- package/src/components/forms/checkbox/Checkbox.stories.tsx +3 -2
- package/src/components/forms/checkbox/Checkbox.tsx +1 -1
- package/src/components/forms/checkbox/__tests__/Checkbox.test.tsx +2 -1
- package/src/components/forms/date/datePicker/DatePicker.stories.tsx +12 -1
- package/src/components/forms/date/datePicker/DatePicker.tsx +35 -25
- package/src/components/forms/date/datePicker/__tests__/DatePicker.test.tsx +1 -0
- package/src/components/forms/date/datePicker/contants.ts +1 -1
- package/src/components/forms/date/datePicker/types.ts +16 -8
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.stories.tsx +16 -2
- package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.tsx +21 -8
- package/src/components/forms/date/iconTriggerDatePicker/__tests__/IconTriggerDatePicker.test.tsx +2 -1
- package/src/components/forms/date/iconTriggerDatePicker/types.ts +5 -0
- package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.stories.tsx +4 -2
- package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +18 -13
- package/src/components/forms/date/inputDatePicker/__tests__/SingleInputDatePicker.test.tsx +4 -2
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +15 -4
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +29 -23
- package/src/components/forms/date/inputDateRangePicker/__tests__/InputDateRangePicker.test.tsx +2 -2
- package/src/components/forms/date/inputDateRangePicker/types.ts +7 -0
- package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.tsx +9 -5
- package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +18 -13
- package/src/components/forms/form/Form.stories.tsx +7 -6
- package/src/components/forms/form/Form.tsx +1 -1
- package/src/components/forms/form/__tests__/Form.test.tsx +7 -4
- package/src/components/forms/input/Input.stories.tsx +6 -3
- package/src/components/forms/input/Input.tsx +4 -3
- package/src/components/forms/input/__tests__/Input.test.tsx +5 -3
- package/src/components/forms/numberInput/NumberInput.stories.tsx +5 -2
- package/src/components/forms/numberInput/NumberInput.tsx +6 -3
- package/src/components/forms/numberInput/__tests__/NumberInput.test.tsx +2 -1
- package/src/components/forms/passwordInput/PasswordInput.stories.tsx +6 -3
- package/src/components/forms/passwordInput/PasswordInput.tsx +12 -3
- package/src/components/forms/passwordInput/__tests__/PasswordInput.test.tsx +3 -4
- package/src/components/forms/radio/Radio.stories.tsx +5 -2
- package/src/components/forms/radio/__tests__/Radio.test.tsx +3 -2
- package/src/components/forms/select/Select.stories.tsx +11 -9
- package/src/components/forms/select/Select.tsx +21 -6
- package/src/components/forms/select/__tests__/Select.test.tsx +2 -2
- package/src/components/forms/select/types.ts +13 -1
- package/src/components/forms/subcomponents/Label.tsx +24 -4
- package/src/components/forms/subcomponents/__tests__/Label.test.tsx +1 -0
- package/src/components/forms/subcomponents/types.ts +5 -0
- package/src/components/forms/textarea/Textarea.stories.tsx +5 -2
- package/src/components/forms/textarea/Textarea.tsx +5 -4
- package/src/components/forms/textarea/__tests__/Textarea.test.tsx +3 -3
- package/src/components/forms/timePicker/TimePicker.stories.tsx +14 -2
- package/src/components/forms/timePicker/TimePicker.tsx +15 -5
- package/src/components/forms/timePicker/__tests__/TimePicker.test.tsx +2 -1
- package/src/components/forms/timePicker/types.ts +5 -0
- package/src/components/forms/toggle/Toggle.stories.tsx +3 -2
- package/src/components/forms/toggle/__tests__/Toggle.test.tsx +3 -2
- package/src/components/grid/col/Col.stories.tsx +2 -1
- package/src/components/grid/col/Col.tsx +1 -1
- package/src/components/grid/container/Container.stories.tsx +2 -1
- package/src/components/grid/container/Container.tsx +1 -1
- package/src/components/grid/row/Row.stories.tsx +2 -1
- package/src/components/grid/row/Row.tsx +1 -1
- package/src/components/icons/Icon.stories.tsx +11 -4
- package/src/components/icons/Icon.tsx +4 -3
- package/src/components/icons/__tests__/Icon.test.tsx +1 -0
- package/src/components/icons/indicons.tsx +3 -3
- package/src/components/icons/types.ts +5 -4
- package/src/components/loading-indicators/BarSpinner/BarSpinner.stories.tsx +2 -1
- package/src/components/loading-indicators/BarSpinner/__tests__/BarSpinner.test.tsx +1 -0
- package/src/components/loading-indicators/CirclePulse/CirclePulse.stories.tsx +2 -1
- package/src/components/menu/Menu.stories.tsx +3 -2
- package/src/components/menu/Menu.test.tsx +1 -1
- package/src/components/menu/Menu.tsx +1 -1
- package/src/components/modal/ConfirmationModal.tsx +25 -18
- package/src/components/modal/Modal.stories.tsx +62 -28
- package/src/components/modal/Modal.tsx +9 -2
- package/src/components/modal/__tests__/Modal.test.tsx +1 -0
- package/src/components/modal/types.ts +23 -7
- package/src/components/pagination/Pagination.stories.tsx +14 -2
- package/src/components/pagination/Pagination.tsx +18 -8
- package/src/components/pagination/__tests__/Pagination.test.tsx +1 -0
- package/src/components/pagination/index.ts +1 -0
- package/src/components/pagination/types.ts +14 -0
- package/src/components/pill/Pill.stories.tsx +10 -6
- package/src/components/pill/Pill.tsx +2 -1
- package/src/components/pill/__tests__/Pill.test.tsx +4 -1
- package/src/components/pill/types.ts +4 -2
- package/src/components/skeleton/Skeleton.stories.tsx +2 -1
- package/src/components/skeleton/__tests__/Skeleton.test.tsx +1 -0
- package/src/components/stepper/Stepper.stories.tsx +20 -7
- package/src/components/stepper/Stepper.tsx +18 -3
- package/src/components/stepper/__tests__/Stepper.tests.tsx +5 -4
- package/src/components/stepper/components/BackNavigation.tsx +5 -3
- package/src/components/stepper/components/Legend.tsx +4 -3
- package/src/components/stepper/components/NextNavigation.tsx +15 -5
- package/src/components/stepper/examples/MixedExample.tsx +4 -3
- package/src/components/stepper/examples/OptionalStepsExample.tsx +4 -3
- package/src/components/stepper/examples/RequiredStepsExample.tsx +4 -3
- package/src/components/stepper/examples/commonExample/CommonExample.tsx +4 -3
- package/src/components/stepper/examples/commonExample/steps/StepOne.tsx +1 -0
- package/src/components/stepper/examples/commonExample/steps/StepThree.tsx +1 -0
- package/src/components/stepper/examples/commonExample/steps/StepTwo.tsx +1 -0
- package/src/components/stepper/types.ts +13 -1
- package/src/components/table/LoadingComponent.tsx +6 -2
- package/src/components/table/Table.stories.tsx +19 -5
- package/src/components/table/Table.tsx +16 -5
- package/src/components/table/__tests__/Table.test.tsx +2 -1
- package/src/components/table/components/HorizontalStickyHeader.tsx +14 -2
- package/src/components/table/components/TablePagination.tsx +1 -1
- package/src/components/table/components/__tests__/HorizontalStickyHeader.test.tsx +3 -3
- package/src/components/table/components/__tests__/TablePagination.test.tsx +1 -0
- package/src/components/table/components/helpers.ts +1 -1
- package/src/components/table/hooks/usePinnedColumnsManager.ts +7 -2
- package/src/components/table/sampleData.tsx +1 -3
- package/src/components/table/types.ts +25 -6
- package/src/components/table/utils/processColumns.tsx +4 -2
- package/src/components/tanstackTable/TankstackTable.types.ts +21 -3
- package/src/components/tanstackTable/TanstackTable.stories.tsx +14 -11
- package/src/components/tanstackTable/TanstackTable.tsx +28 -18
- package/src/components/tanstackTable/__tests__/TanstackTable.test.tsx +2 -1
- package/src/components/tanstackTable/__tests__/__mocks__/test-mock-data.tsx +2 -1
- package/src/components/tanstackTable/components/ActionBar/ActionBar.stories.tsx +6 -3
- package/src/components/tanstackTable/components/ActionBar/ActionBar.tsx +7 -3
- package/src/components/tanstackTable/components/ActionBar/__tests__/ActionBar.test.tsx +4 -1
- package/src/components/tanstackTable/components/NoResults/NoResults.tsx +9 -3
- package/src/components/tanstackTable/components/NoResults/__tests__/NoResult.test.tsx +1 -0
- package/src/components/tanstackTable/components/TableBody/TableBody.tsx +2 -1
- package/src/components/tanstackTable/components/TableHeader/TableHeader.tsx +3 -2
- package/src/components/tanstackTable/components/TableLoading/TableLoading.tsx +2 -1
- package/src/components/tanstackTable/components/TablePagination/TablePagination.tsx +4 -1
- package/src/components/tanstackTable/components/TablePagination/__tests__/TablePagination.test.tsx +1 -0
- package/src/components/tanstackTable/docs/internalSorting/InternalClientSideSorting.stories.tsx +5 -5
- package/src/components/tanstackTable/docs/pinnedColumns/PinnedColumn.stories.tsx +5 -4
- package/src/components/tanstackTable/docs/withRowClick/WithRowClick.stories.tsx +5 -4
- package/src/components/tanstackTable/helpers.ts +2 -2
- package/src/components/tanstackTable/mock-data/table-configuration.tsx +7 -4
- package/src/components/tanstackTable/useTanstackTable.tsx +1 -2
- package/src/components/toast/Toast.stories.tsx +2 -1
- package/src/components/tooltip/Tooltip.stories.tsx +3 -2
- package/src/components/tooltip/Tooltip.tsx +2 -2
- package/src/components/truncate/Truncate.stories.tsx +3 -2
- package/src/components/truncate/Truncate.tsx +5 -4
- package/src/components/truncate/__tests__/Truncate.test.tsx +1 -0
- package/src/components/truncate/types.ts +1 -1
- package/src/docs/BaseColorPalette/BaseColorPalette.tsx +1 -0
- package/src/docs/BaseColorPalette/BaseColorsPalette.stories.tsx +2 -1
- package/src/docs/BaseColorPalette/Swatch.tsx +2 -1
- package/src/docs/SemanticTokens/ColorSwatch.tsx +1 -1
- package/src/docs/SemanticTokens/SemanticTokens.stories.tsx +2 -2
- package/src/index.ts +1 -1
- package/src/setup/setupIcons.ts +2 -2
- package/src/storybook/formArgTypes.ts +12 -1
- package/src/storybook/iconNames.ts +1 -0
- package/src/storybookDocs/Permafrost.mdx +8 -0
- package/src/stylesAndAnimations/borders/BorderColor.stories.tsx +2 -1
- package/src/stylesAndAnimations/borders/BorderColor.tsx +0 -1
- package/src/stylesAndAnimations/borders/BorderRadius.stories.tsx +2 -1
- package/src/stylesAndAnimations/borders/BorderRadius.tsx +0 -1
- package/src/stylesAndAnimations/borders/BorderStyles.stories.tsx +2 -1
- package/src/stylesAndAnimations/borders/BorderStyles.tsx +0 -1
- package/src/stylesAndAnimations/borders/BorderThickness.stories.tsx +2 -1
- package/src/stylesAndAnimations/borders/BorderThickness.tsx +0 -1
- package/src/stylesAndAnimations/colors/UtilityClasses.stories.tsx +2 -1
- package/src/stylesAndAnimations/colors/UtilityClasses.tsx +1 -2
- package/src/stylesAndAnimations/sizing/Sizing.stories.tsx +2 -1
- package/src/stylesAndAnimations/sizing/Sizing.tsx +0 -1
- package/src/stylesAndAnimations/typography/Typography.stories.tsx +2 -1
- package/src/stylesAndAnimations/typography/Typography.tsx +0 -1
- package/src/stylesAndAnimations/utilityClasses/UtilityClassesTable.stories.tsx +2 -1
- package/src/stylesAndAnimations/utilityClasses/UtilityClassesTable.tsx +6 -3
- package/src/types.ts +12 -6
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { type DateRange, DayPicker, type Mode, type OnSelectHandler } from 'react-day-picker';
|
|
3
|
+
|
|
2
4
|
import 'react-day-picker/style.css';
|
|
3
|
-
import { DatePickerProps } from './types';
|
|
4
5
|
import { getCommonProps } from './contants';
|
|
5
|
-
import {
|
|
6
|
+
import { type DatePickerProps, type DatePickerText } from './types';
|
|
6
7
|
import { Col, Row } from '../../../grid';
|
|
7
|
-
import {
|
|
8
|
+
import { TimePicker } from '../../timePicker/TimePicker';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_TEXT: Required<DatePickerText> = {
|
|
11
|
+
selectTime: 'Select Time',
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
export const DatePicker = (props: DatePickerProps) => {
|
|
10
15
|
const {
|
|
11
16
|
mode = 'single',
|
|
12
|
-
className,
|
|
13
|
-
captionLayout = 'dropdown',
|
|
14
17
|
selected,
|
|
15
18
|
hasTimePicker = false,
|
|
16
|
-
id,
|
|
17
|
-
month,
|
|
18
|
-
defaultMonth,
|
|
19
|
-
startMonth,
|
|
20
19
|
endMonth,
|
|
21
|
-
components,
|
|
22
20
|
numberOfMonths,
|
|
23
|
-
isDisabled,
|
|
24
|
-
formatters,
|
|
25
|
-
weekStartsOn,
|
|
26
|
-
firstWeekContainsDate,
|
|
27
|
-
today,
|
|
28
21
|
timeValue,
|
|
29
|
-
isRequired,
|
|
30
|
-
min,
|
|
31
|
-
max,
|
|
32
22
|
onTimeChange,
|
|
33
23
|
onSelect,
|
|
34
|
-
onMonthChange,
|
|
35
|
-
onNextClick,
|
|
36
|
-
onPrevClick,
|
|
37
|
-
onDayClick,
|
|
38
24
|
isReadOnly,
|
|
39
25
|
ref,
|
|
40
26
|
timeTabIndex,
|
|
41
|
-
|
|
27
|
+
text: textProp,
|
|
28
|
+
// Destructure props handled by getCommonProps to prevent them from
|
|
29
|
+
// leaking through ...rest and overriding the transformed values
|
|
30
|
+
className: _className,
|
|
31
|
+
captionLayout: _captionLayout,
|
|
32
|
+
id: _id,
|
|
33
|
+
month: _month,
|
|
34
|
+
defaultMonth: _defaultMonth,
|
|
35
|
+
startMonth: _startMonth,
|
|
36
|
+
components: _components,
|
|
37
|
+
isDisabled: _isDisabled,
|
|
38
|
+
formatters: _formatters,
|
|
39
|
+
weekStartsOn: _weekStartsOn,
|
|
40
|
+
firstWeekContainsDate: _firstWeekContainsDate,
|
|
41
|
+
today: _today,
|
|
42
|
+
isRequired: _isRequired,
|
|
43
|
+
min: _min,
|
|
44
|
+
max: _max,
|
|
45
|
+
onMonthChange: _onMonthChange,
|
|
46
|
+
onNextClick: _onNextClick,
|
|
47
|
+
onPrevClick: _onPrevClick,
|
|
48
|
+
onDayClick: _onDayClick,
|
|
49
|
+
dateTabIndex: _dateTabIndex,
|
|
42
50
|
...rest
|
|
43
51
|
} = props;
|
|
44
52
|
|
|
53
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
54
|
+
|
|
45
55
|
const futureDateByYear = (year: number) => new Date(new Date().getFullYear() + year, 11, 31);
|
|
46
56
|
const endMonthDefault = endMonth ?? futureDateByYear(5);
|
|
47
57
|
|
|
@@ -116,7 +126,7 @@ export const DatePicker = (props: DatePickerProps) => {
|
|
|
116
126
|
<div className="time-picker-wrapper">
|
|
117
127
|
<Row align="center">
|
|
118
128
|
<Col xs="content">
|
|
119
|
-
<p className="ma-0">
|
|
129
|
+
<p className="ma-0">{text.selectTime}</p>
|
|
120
130
|
</Col>
|
|
121
131
|
<Col>
|
|
122
132
|
<TimePicker
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CustomComponents,
|
|
3
|
-
DateRange,
|
|
4
|
-
DayEventHandler,
|
|
5
|
-
Formatters,
|
|
6
|
-
Matcher,
|
|
7
|
-
Mode,
|
|
8
|
-
MonthChangeEventHandler,
|
|
9
|
-
OnSelectHandler,
|
|
2
|
+
type CustomComponents,
|
|
3
|
+
type DateRange,
|
|
4
|
+
type DayEventHandler,
|
|
5
|
+
type Formatters,
|
|
6
|
+
type Matcher,
|
|
7
|
+
type Mode,
|
|
8
|
+
type MonthChangeEventHandler,
|
|
9
|
+
type OnSelectHandler,
|
|
10
10
|
} from 'react-day-picker';
|
|
11
11
|
|
|
12
|
+
/** Customizable text for DatePicker. */
|
|
13
|
+
export interface DatePickerText {
|
|
14
|
+
/** Label for "Select Time" text. Default: "Select Time" */
|
|
15
|
+
selectTime?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
export interface DatePickerProps {
|
|
13
19
|
ref?: React.LegacyRef<HTMLInputElement>;
|
|
14
20
|
/** The selected day(s). */
|
|
@@ -51,6 +57,8 @@ export interface DatePickerProps {
|
|
|
51
57
|
isReadOnly?: boolean;
|
|
52
58
|
timeTabIndex?: number;
|
|
53
59
|
dateTabIndex?: number;
|
|
60
|
+
/** Customizable display text. */
|
|
61
|
+
text?: DatePickerText;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
export interface CommonProps {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
1
|
import { useArgs } from '@storybook/preview-api';
|
|
2
|
+
import { type DateRange } from 'react-day-picker';
|
|
3
|
+
|
|
3
4
|
import { IconTriggerDatePicker } from '@/components/forms/date/iconTriggerDatePicker';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
|
|
6
10
|
const meta: Meta<typeof IconTriggerDatePicker> = {
|
|
7
11
|
component: IconTriggerDatePicker,
|
|
@@ -175,6 +179,16 @@ const meta: Meta<typeof IconTriggerDatePicker> = {
|
|
|
175
179
|
},
|
|
176
180
|
action: 'onSelect',
|
|
177
181
|
},
|
|
182
|
+
text: {
|
|
183
|
+
control: 'object',
|
|
184
|
+
description: 'Customizable text.',
|
|
185
|
+
table: {
|
|
186
|
+
category: 'i18n Text',
|
|
187
|
+
type: {
|
|
188
|
+
summary: '{ triggerIcon?: string }',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
178
192
|
},
|
|
179
193
|
};
|
|
180
194
|
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import { type UseFloatingOptions } from '@floating-ui/react-dom';
|
|
1
2
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { DateRange, OnSelectHandler, Mode } from 'react-day-picker';
|
|
3
|
-
|
|
3
|
+
import { type DateRange, type OnSelectHandler, type Mode } from 'react-day-picker';
|
|
4
|
+
|
|
5
|
+
import { type IconTriggerDatePickerText } from './types';
|
|
4
6
|
import { FloatUI } from '../../../floatUI';
|
|
5
|
-
import { DatePicker } from '../datePicker/DatePicker';
|
|
6
7
|
import { Icon } from '../../../icons/Icon';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import { type IconName, type IconSizes } from '../../../icons/types';
|
|
9
|
+
import { DatePicker } from '../datePicker/DatePicker';
|
|
10
|
+
import { type PortalOptions } from '../datePicker/types';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_TEXT: Required<IconTriggerDatePickerText> = {
|
|
13
|
+
triggerIcon: 'Open date picker',
|
|
14
|
+
};
|
|
15
|
+
|
|
9
16
|
interface Props {
|
|
10
17
|
/** Allows you to select a single day, a range of days, or multiple days. */
|
|
11
18
|
mode?: Mode;
|
|
@@ -42,17 +49,20 @@ interface Props {
|
|
|
42
49
|
isPortal?: boolean;
|
|
43
50
|
/** The floating options for the date picker. Follows floating-ui options. */
|
|
44
51
|
floatingOptions?: UseFloatingOptions;
|
|
52
|
+
/** Customizable display text. */
|
|
53
|
+
text?: IconTriggerDatePickerText;
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
export const IconTriggerDatePicker = (props: Props) => {
|
|
48
57
|
const {
|
|
49
58
|
ariaLabel,
|
|
50
|
-
className,
|
|
51
59
|
isDisabled,
|
|
52
60
|
disableBeforeDate,
|
|
53
61
|
disableAfterDate,
|
|
54
62
|
id,
|
|
55
|
-
|
|
63
|
+
// Destructure unused props to prevent leaking into ...rest
|
|
64
|
+
className: _className,
|
|
65
|
+
label: _label,
|
|
56
66
|
onSelect,
|
|
57
67
|
selected,
|
|
58
68
|
triggerIcon,
|
|
@@ -64,9 +74,12 @@ export const IconTriggerDatePicker = (props: Props) => {
|
|
|
64
74
|
portalOptions,
|
|
65
75
|
floatingOptions,
|
|
66
76
|
isPortal,
|
|
77
|
+
text: textProp,
|
|
67
78
|
...rest
|
|
68
79
|
} = props;
|
|
69
80
|
|
|
81
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
82
|
+
|
|
70
83
|
const [localMonth, setLocalMonth] = useState<Date>(initialMonth ?? new Date());
|
|
71
84
|
|
|
72
85
|
const handleSelect: OnSelectHandler<Date> = (date) => {
|
|
@@ -93,7 +106,7 @@ export const IconTriggerDatePicker = (props: Props) => {
|
|
|
93
106
|
floatingOptions={floatingOptions}
|
|
94
107
|
>
|
|
95
108
|
<Icon
|
|
96
|
-
aria-label=
|
|
109
|
+
aria-label={text.triggerIcon}
|
|
97
110
|
name={triggerIcon}
|
|
98
111
|
size={triggerIconSize}
|
|
99
112
|
className="date__picker__trigger"
|
package/src/components/forms/date/iconTriggerDatePicker/__tests__/IconTriggerDatePicker.test.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import { IconTriggerDatePicker } from '../IconTriggerDatePicker';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
3
|
|
|
4
|
+
import { IconTriggerDatePicker } from '../IconTriggerDatePicker';
|
|
5
|
+
|
|
5
6
|
describe('DatePicker', () => {
|
|
6
7
|
it('The date picker opens when the icon is clicked', async () => {
|
|
7
8
|
render(
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { SingleInputDatePicker, SingleInputDatePickerProps } from './SingleInputDatePicker';
|
|
3
1
|
import { useArgs } from '@storybook/preview-api';
|
|
4
2
|
|
|
3
|
+
import { SingleInputDatePicker, type SingleInputDatePickerProps } from './SingleInputDatePicker';
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
+
|
|
5
7
|
const meta: Meta<typeof SingleInputDatePicker> = {
|
|
6
8
|
component: SingleInputDatePicker,
|
|
7
9
|
title: 'Forms/DatePicker/SingleInputDatePicker',
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type UseFloatingOptions } from '@floating-ui/react-dom';
|
|
2
2
|
import { isValid, parse } from 'date-fns';
|
|
3
|
-
import {
|
|
3
|
+
import { useId, useState, useEffect } from 'react';
|
|
4
|
+
|
|
5
|
+
import { formatDateAsString } from './helpers';
|
|
6
|
+
import { FloatUI } from '../../../floatUI';
|
|
4
7
|
import { Input } from '../../input';
|
|
8
|
+
import { DatePicker } from '../datePicker/DatePicker';
|
|
9
|
+
import { type PortalOptions } from '../datePicker/types';
|
|
10
|
+
|
|
5
11
|
import type { IconName } from '../../../icons/types';
|
|
6
|
-
|
|
7
|
-
import { formatDateAsString } from './helpers';
|
|
8
|
-
import { UseFloatingOptions } from '@floating-ui/react-dom';
|
|
9
|
-
import { PortalOptions } from '../datePicker/types';
|
|
12
|
+
|
|
10
13
|
export interface SingleInputDatePickerProps {
|
|
11
14
|
/** A label for assistive technologies. */
|
|
12
15
|
ariaLabel: string;
|
|
@@ -16,7 +19,8 @@ export interface SingleInputDatePickerProps {
|
|
|
16
19
|
/** The layout of the caption. Enables you to add or remove the dropdown navigation for months/years */
|
|
17
20
|
captionLayout?: 'dropdown' | 'dropdown-months' | 'dropdown-years' | 'label';
|
|
18
21
|
id?: string;
|
|
19
|
-
label
|
|
22
|
+
/** The label for the input field. */
|
|
23
|
+
label: string;
|
|
20
24
|
onSelect: (selected: Date | undefined) => void;
|
|
21
25
|
initialMonth?: Date;
|
|
22
26
|
selected?: Date;
|
|
@@ -46,13 +50,9 @@ export interface SingleInputDatePickerProps {
|
|
|
46
50
|
export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
47
51
|
const {
|
|
48
52
|
ariaLabel,
|
|
49
|
-
className,
|
|
50
53
|
isDisabled,
|
|
51
|
-
disableBeforeDate,
|
|
52
|
-
disableAfterDate,
|
|
53
54
|
captionLayout,
|
|
54
55
|
initialMonth,
|
|
55
|
-
id,
|
|
56
56
|
label,
|
|
57
57
|
selected,
|
|
58
58
|
isOpen,
|
|
@@ -69,6 +69,11 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
|
69
69
|
portalOptions,
|
|
70
70
|
floatingOptions,
|
|
71
71
|
isPortal,
|
|
72
|
+
// Destructure unused props to prevent leaking into ...rest
|
|
73
|
+
className: _className,
|
|
74
|
+
disableBeforeDate: _disableBeforeDate,
|
|
75
|
+
disableAfterDate: _disableAfterDate,
|
|
76
|
+
id: _id,
|
|
72
77
|
...rest
|
|
73
78
|
} = props;
|
|
74
79
|
|
|
@@ -131,9 +136,9 @@ export function SingleInputDatePicker(props: SingleInputDatePickerProps) {
|
|
|
131
136
|
isClearable={isClearable}
|
|
132
137
|
onChange={handleInputChange}
|
|
133
138
|
errorMessage={errorMessage}
|
|
134
|
-
label={
|
|
139
|
+
label={label}
|
|
135
140
|
tabIndex={tabIndex}
|
|
136
|
-
name={
|
|
141
|
+
name={label}
|
|
137
142
|
ref={ref}
|
|
138
143
|
readonly={isReadOnly}
|
|
139
144
|
/>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import { SingleInputDatePicker } from '../SingleInputDatePicker';
|
|
5
3
|
import { format, addDays } from 'date-fns';
|
|
6
4
|
|
|
5
|
+
import { SingleInputDatePicker } from '../SingleInputDatePicker';
|
|
6
|
+
|
|
7
7
|
const mockOnSelect = jest.fn();
|
|
8
8
|
|
|
9
9
|
describe('SingleInputDatePicker', () => {
|
|
@@ -30,6 +30,7 @@ describe('SingleInputDatePicker', () => {
|
|
|
30
30
|
render(
|
|
31
31
|
<SingleInputDatePicker
|
|
32
32
|
ariaLabel="Single Input Date Picker"
|
|
33
|
+
label="Date Picker"
|
|
33
34
|
data-testid="datepicker-testid"
|
|
34
35
|
captionLayout="label"
|
|
35
36
|
onSelect={mockOnSelect}
|
|
@@ -70,6 +71,7 @@ describe('SingleInputDatePicker', () => {
|
|
|
70
71
|
render(
|
|
71
72
|
<SingleInputDatePicker
|
|
72
73
|
ariaLabel="Single Input Date Picker"
|
|
74
|
+
label="Date Picker"
|
|
73
75
|
captionLayout="label"
|
|
74
76
|
data-testid="datepicker-testid"
|
|
75
77
|
onSelect={mockOnSelect}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { InputDateRangePicker } from './InputDateRangePicker';
|
|
3
1
|
import { useArgs } from '@storybook/preview-api';
|
|
4
|
-
import { DateRange } from 'react-day-picker';
|
|
5
|
-
|
|
2
|
+
import { type DateRange } from 'react-day-picker';
|
|
3
|
+
|
|
4
|
+
import { InputDateRangePicker } from './InputDateRangePicker';
|
|
5
|
+
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
7
|
|
|
7
8
|
const meta: Meta<typeof InputDateRangePicker> = {
|
|
8
9
|
component: InputDateRangePicker,
|
|
@@ -261,6 +262,16 @@ const meta: Meta<typeof InputDateRangePicker> = {
|
|
|
261
262
|
disable: true,
|
|
262
263
|
},
|
|
263
264
|
},
|
|
265
|
+
text: {
|
|
266
|
+
control: 'object',
|
|
267
|
+
description: 'Customizable text.',
|
|
268
|
+
table: {
|
|
269
|
+
category: 'i18n Text',
|
|
270
|
+
type: {
|
|
271
|
+
summary: '{ fromDate?: string; toDate?: string }',
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
264
275
|
},
|
|
265
276
|
};
|
|
266
277
|
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type UseFloatingOptions } from '@floating-ui/react-dom';
|
|
2
2
|
import { isValid, parse } from 'date-fns';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
3
|
+
import { useId, useState, useEffect } from 'react';
|
|
4
|
+
import { type DateRange } from 'react-day-picker';
|
|
5
|
+
|
|
6
|
+
import { type InputDateRangePickerText } from './types';
|
|
7
7
|
import { FloatUI } from '../../../floatUI';
|
|
8
8
|
import { Col, Row } from '../../../grid';
|
|
9
|
+
import { type IconName } from '../../../icons/types';
|
|
10
|
+
import { Input } from '../../input';
|
|
11
|
+
import { DatePicker } from '../datePicker/DatePicker';
|
|
12
|
+
import { type PortalOptions } from '../datePicker/types';
|
|
9
13
|
import { formatDateAsString } from '../inputDatePicker/helpers';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
|
|
15
|
+
const DEFAULT_TEXT: Required<InputDateRangePickerText> = {
|
|
16
|
+
fromDate: 'From Date',
|
|
17
|
+
toDate: 'To Date',
|
|
18
|
+
};
|
|
19
|
+
|
|
13
20
|
interface InputDateRangePickerProps {
|
|
14
21
|
/** A label for assistive technologies. */
|
|
15
22
|
ariaLabel: string;
|
|
@@ -51,18 +58,22 @@ interface InputDateRangePickerProps {
|
|
|
51
58
|
floatingOptions?: UseFloatingOptions;
|
|
52
59
|
/** Whether the date picker is a portal. */
|
|
53
60
|
isPortal?: boolean;
|
|
61
|
+
/** Customizable display text. */
|
|
62
|
+
text?: InputDateRangePickerText;
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
57
66
|
const {
|
|
58
67
|
ariaLabel,
|
|
59
|
-
className,
|
|
60
68
|
isDisabled,
|
|
61
|
-
disableBeforeDate,
|
|
62
|
-
disableAfterDate,
|
|
63
69
|
captionLayout,
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
// Destructure unused props to prevent leaking into ...rest
|
|
71
|
+
className: _className,
|
|
72
|
+
disableBeforeDate: _disableBeforeDate,
|
|
73
|
+
disableAfterDate: _disableAfterDate,
|
|
74
|
+
month: _month,
|
|
75
|
+
id: _id,
|
|
76
|
+
isPortal: _isPortal,
|
|
66
77
|
onSelect,
|
|
67
78
|
selected,
|
|
68
79
|
isOpen,
|
|
@@ -84,10 +95,12 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
84
95
|
fromTabIndex,
|
|
85
96
|
portalOptions,
|
|
86
97
|
floatingOptions,
|
|
87
|
-
|
|
98
|
+
text: textProp,
|
|
88
99
|
...rest
|
|
89
100
|
} = props;
|
|
90
101
|
|
|
102
|
+
const text = { ...DEFAULT_TEXT, ...textProp };
|
|
103
|
+
|
|
91
104
|
const inputId = useId();
|
|
92
105
|
|
|
93
106
|
// Hold the input values in state
|
|
@@ -157,13 +170,6 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
157
170
|
}
|
|
158
171
|
}, [isOpen, clearOnClose]);
|
|
159
172
|
|
|
160
|
-
// Handle set date button click
|
|
161
|
-
const handleSetDate = () => {
|
|
162
|
-
if (setIsOpen) {
|
|
163
|
-
setIsOpen(false);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
173
|
return (
|
|
168
174
|
<FloatUI
|
|
169
175
|
isOpen={isOpen}
|
|
@@ -183,7 +189,7 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
183
189
|
onChange={(e) => handleInputChange(e, 'from')}
|
|
184
190
|
errorMessage={fromErrorMessage}
|
|
185
191
|
label={fromLabel}
|
|
186
|
-
name={
|
|
192
|
+
name={text.fromDate}
|
|
187
193
|
data-testid="date-picker-from"
|
|
188
194
|
hasHiddenLabel={hasHiddenLabel}
|
|
189
195
|
ref={ref}
|
|
@@ -201,7 +207,7 @@ export function InputDateRangePicker(props: InputDateRangePickerProps) {
|
|
|
201
207
|
onChange={(e) => handleInputChange(e, 'to')}
|
|
202
208
|
errorMessage={toErrorMessage}
|
|
203
209
|
label={toLabel}
|
|
204
|
-
name={
|
|
210
|
+
name={text.toDate}
|
|
205
211
|
data-testid="date-picker-to"
|
|
206
212
|
hasHiddenLabel={hasHiddenLabel}
|
|
207
213
|
ref={ref}
|
package/src/components/forms/date/inputDateRangePicker/__tests__/InputDateRangePicker.test.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import { InputDateRangePicker } from '../InputDateRangePicker';
|
|
5
3
|
import { format } from 'date-fns';
|
|
6
4
|
|
|
5
|
+
import { InputDateRangePicker } from '../InputDateRangePicker';
|
|
6
|
+
|
|
7
7
|
const mockOnSelect = jest.fn();
|
|
8
8
|
|
|
9
9
|
describe('InputDateRangePicker', () => {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import {
|
|
3
|
-
SingleInputDateTimePicker,
|
|
4
|
-
SingleInputDateTimePickerProps,
|
|
5
|
-
} from './SingleInputDateTimePicker';
|
|
6
1
|
import { useArgs } from '@storybook/preview-api';
|
|
2
|
+
|
|
7
3
|
import { indiconDefinitions } from '@/components/icons/indicons';
|
|
8
4
|
import { registerFontAwesomeIcons } from '@/setup/setupIcons';
|
|
9
5
|
|
|
6
|
+
import {
|
|
7
|
+
SingleInputDateTimePicker,
|
|
8
|
+
type SingleInputDateTimePickerProps,
|
|
9
|
+
} from './SingleInputDateTimePicker';
|
|
10
|
+
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
+
|
|
13
|
+
|
|
10
14
|
registerFontAwesomeIcons(...indiconDefinitions);
|
|
11
15
|
|
|
12
16
|
const meta: Meta<typeof SingleInputDateTimePicker> = {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type UseFloatingOptions } from '@floating-ui/react-dom';
|
|
2
2
|
import { isValid, parse } from 'date-fns';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import type { IconName } from '../../../icons/types';
|
|
6
|
-
import { FloatUI } from '../../../floatUI';
|
|
3
|
+
import { useId, useState, useEffect } from 'react';
|
|
4
|
+
|
|
7
5
|
import { formatDateAsString } from './helpers';
|
|
8
|
-
import {
|
|
6
|
+
import { FloatUI } from '../../../floatUI';
|
|
9
7
|
import { Row, Col } from '../../../grid';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { Input } from '../../input';
|
|
9
|
+
import { TimePicker } from '../../timePicker/TimePicker';
|
|
10
|
+
import { DatePicker } from '../datePicker/DatePicker';
|
|
11
|
+
import { type PortalOptions } from '../datePicker/types';
|
|
12
|
+
|
|
13
|
+
import type { IconName } from '../../../icons/types';
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
export interface SingleInputDateTimePickerProps {
|
|
14
17
|
/** A label for assistive technologies. */
|
|
@@ -18,7 +21,8 @@ export interface SingleInputDateTimePickerProps {
|
|
|
18
21
|
isDisabled?: boolean;
|
|
19
22
|
captionLayout?: 'dropdown' | 'dropdown-months' | 'dropdown-years' | 'label';
|
|
20
23
|
id?: string;
|
|
21
|
-
label
|
|
24
|
+
/** The label for the date input field. */
|
|
25
|
+
label: string;
|
|
22
26
|
onSelect: (selected: Date | undefined) => void;
|
|
23
27
|
initialMonth?: Date;
|
|
24
28
|
selected?: Date;
|
|
@@ -54,10 +58,7 @@ export interface SingleInputDateTimePickerProps {
|
|
|
54
58
|
export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps) {
|
|
55
59
|
const {
|
|
56
60
|
ariaLabel,
|
|
57
|
-
className,
|
|
58
61
|
isDisabled,
|
|
59
|
-
disableBeforeDate,
|
|
60
|
-
disableAfterDate,
|
|
61
62
|
captionLayout,
|
|
62
63
|
initialMonth,
|
|
63
64
|
id,
|
|
@@ -81,6 +82,10 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
81
82
|
portalOptions,
|
|
82
83
|
floatingOptions,
|
|
83
84
|
isPortal,
|
|
85
|
+
// Destructure unused props to prevent leaking into ...rest
|
|
86
|
+
className: _className,
|
|
87
|
+
disableBeforeDate: _disableBeforeDate,
|
|
88
|
+
disableAfterDate: _disableAfterDate,
|
|
84
89
|
...rest
|
|
85
90
|
} = props;
|
|
86
91
|
|
|
@@ -153,7 +158,7 @@ export function SingleInputDateTimePicker(props: SingleInputDateTimePickerProps)
|
|
|
153
158
|
onChange={handleInputChange}
|
|
154
159
|
errorMessage={errorMessage}
|
|
155
160
|
hasHiddenLabel={hasHiddenLabel}
|
|
156
|
-
label={
|
|
161
|
+
label={label}
|
|
157
162
|
name={`${id}-date-picker`}
|
|
158
163
|
tabIndex={dateTabIndex}
|
|
159
164
|
/>
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { Form } from './Form';
|
|
3
|
-
import { Input } from '../input/Input';
|
|
4
|
-
import { useForm, Controller, SubmitHandler } from 'react-hook-form';
|
|
5
1
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
2
|
+
import { type Meta, type StoryObj } from '@storybook/react';
|
|
3
|
+
import { useForm, Controller, type SubmitHandler } from 'react-hook-form';
|
|
6
4
|
import * as z from 'zod';
|
|
5
|
+
|
|
6
|
+
import { Form } from './Form';
|
|
7
7
|
import { Button } from '../../button/Button';
|
|
8
|
-
import { PasswordInput } from '../passwordInput';
|
|
9
|
-
import { Textarea } from '../textarea';
|
|
10
8
|
import { Col, Row, Container } from '../../grid';
|
|
11
9
|
import { Checkbox } from '../checkbox';
|
|
10
|
+
import { Input } from '../input/Input';
|
|
11
|
+
import { PasswordInput } from '../passwordInput';
|
|
12
12
|
import { Radio } from '../radio';
|
|
13
|
+
import { Textarea } from '../textarea';
|
|
13
14
|
import { Toggle } from '../toggle';
|
|
14
15
|
|
|
15
16
|
const meta: Meta = {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import { Form } from '@/components/forms/form/Form';
|
|
3
2
|
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { type ChangeEvent } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Form } from '@/components/forms/form/Form';
|
|
6
|
+
|
|
6
7
|
import { Button } from '../../../button';
|
|
8
|
+
import { Input } from '../../input';
|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
const onSubmit = jest.fn();
|
|
9
12
|
|
|
@@ -17,7 +20,7 @@ describe('form', () => {
|
|
|
17
20
|
isRequired
|
|
18
21
|
name="first name"
|
|
19
22
|
value="first name"
|
|
20
|
-
onChange={function (
|
|
23
|
+
onChange={function (_e: ChangeEvent<HTMLInputElement>): void {
|
|
21
24
|
throw new Error('Function not implemented.');
|
|
22
25
|
}}
|
|
23
26
|
/>
|