@flipdish/ui-library 0.61.0 → 0.62.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/dist/components/__internal__/segmentedInput/SegmentedInputBase.cjs +44 -0
- package/dist/components/__internal__/segmentedInput/SegmentedInputBase.cjs.map +1 -0
- package/dist/components/__internal__/segmentedInput/SegmentedInputBase.d.ts +20 -0
- package/dist/components/__internal__/segmentedInput/SegmentedInputBase.d.ts.map +1 -0
- package/dist/components/__internal__/segmentedInput/SegmentedInputBase.js +42 -0
- package/dist/components/__internal__/segmentedInput/SegmentedInputBase.js.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.cjs +40 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.cjs.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.d.ts +29 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.d.ts.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.js +38 -0
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.js.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.cjs +14 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.cjs.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.d.ts +13 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.d.ts.map +1 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.js +12 -0
- package/dist/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.js.map +1 -0
- package/dist/components/atoms/Inputs/index.cjs +2 -0
- package/dist/components/atoms/Inputs/index.cjs.map +1 -1
- package/dist/components/atoms/Inputs/index.d.ts +4 -2
- package/dist/components/atoms/Inputs/index.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/index.js +1 -0
- package/dist/components/atoms/Inputs/index.js.map +1 -1
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.cjs +43 -0
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.cjs.map +1 -0
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.d.ts +38 -0
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.d.ts.map +1 -0
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.js +39 -0
- package/dist/components/forms/__internal__/dateValue/utilities/dateValue.utils.js.map +1 -0
- package/dist/components/forms/fields/FormDatePicker/index.cjs +2 -2
- package/dist/components/forms/fields/FormDatePicker/index.cjs.map +1 -1
- package/dist/components/forms/fields/FormDatePicker/index.js +1 -1
- package/dist/components/forms/fields/FormDateRangePicker/index.cjs +35 -0
- package/dist/components/forms/fields/FormDateRangePicker/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormDateRangePicker/index.d.ts +20 -0
- package/dist/components/forms/fields/FormDateRangePicker/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormDateRangePicker/index.js +33 -0
- package/dist/components/forms/fields/FormDateRangePicker/index.js.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/index.cjs +34 -0
- package/dist/components/forms/fields/FormTimeInput/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/index.d.ts +19 -0
- package/dist/components/forms/fields/FormTimeInput/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/index.js +32 -0
- package/dist/components/forms/fields/FormTimeInput/index.js.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.cjs +33 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.cjs.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.d.ts +19 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.d.ts.map +1 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.js +30 -0
- package/dist/components/forms/fields/FormTimeInput/utilities/formTimeInput.utils.js.map +1 -0
- package/dist/components/forms/validation/index.cjs +103 -14
- package/dist/components/forms/validation/index.cjs.map +1 -1
- package/dist/components/forms/validation/index.d.ts +40 -4
- package/dist/components/forms/validation/index.d.ts.map +1 -1
- package/dist/components/forms/validation/index.js +102 -15
- package/dist/components/forms/validation/index.js.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.cjs +2 -2
- package/dist/components/molecules/Selects/Select/Select.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.js +2 -2
- package/dist/components/molecules/Selects/Select/Select.js.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.js +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.js.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.cjs +2 -2
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.js +2 -2
- package/dist/components/organisms/DatePickers/DatePicker/components/Calendar.js.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +2 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +2 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs +2 -2
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js +2 -2
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js.map +1 -1
- package/dist/localization/en.json.cjs +21 -0
- package/dist/localization/en.json.cjs.map +1 -1
- package/dist/localization/en.json.js +19 -1
- package/dist/localization/en.json.js.map +1 -1
- package/dist/native/components/forms/fields/FormDateRangePicker/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormTimeInput/index.d.ts +12 -0
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts +1 -1
- package/dist/utilities/__internal__/builtInTextUtils/builtInText.utils.d.ts.map +1 -1
- package/package.json +3 -1
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs +0 -23
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.cjs.map +0 -1
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts +0 -9
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.d.ts.map +0 -1
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js +0 -21
- package/dist/components/forms/fields/FormDatePicker/utilities/formDatePicker.utils.js.map +0 -1
- package/dist/components/organisms/DatePickers/components/InputDate.cjs +0 -59
- package/dist/components/organisms/DatePickers/components/InputDate.cjs.map +0 -1
- package/dist/components/organisms/DatePickers/components/InputDate.d.ts +0 -50
- package/dist/components/organisms/DatePickers/components/InputDate.d.ts.map +0 -1
- package/dist/components/organisms/DatePickers/components/InputDate.js +0 -57
- package/dist/components/organisms/DatePickers/components/InputDate.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The bordered group of date or time segments, with no label or hint, for a react-aria `DateField`, `TimeField` or a
|
|
11
|
+
* picker's `start` and `end` slots. INTERNAL: import as `#internal/components/segmentedInput/SegmentedInputBase`.
|
|
12
|
+
*/
|
|
13
|
+
const SegmentedInputBase = ({ size = 'md', isInvalid, isDisabled, icon: Icon, wrapperClassName, ...inputProps }) => {
|
|
14
|
+
const prefix = testIdUtils.useTestIdPrefix();
|
|
15
|
+
const slot = typeof inputProps.slot === 'string' ? inputProps.slot : undefined;
|
|
16
|
+
const inputTestId = prefix ? testIdUtils.joinTestId(prefix, slot ? `input-${slot}` : 'input') : undefined;
|
|
17
|
+
const sizes = cx.sortCx({
|
|
18
|
+
sm: {
|
|
19
|
+
root: cx.cx('px-3 py-2 text-sm', isInvalid && 'pr-9', Icon && 'pl-8.5'),
|
|
20
|
+
iconLeading: 'left-3 size-4 stroke-[2.25px]',
|
|
21
|
+
iconTrailing: 'right-3',
|
|
22
|
+
},
|
|
23
|
+
md: {
|
|
24
|
+
root: cx.cx('px-3 py-2 text-md', isInvalid && 'pr-9', Icon && 'pl-10'),
|
|
25
|
+
iconLeading: 'left-3 size-5',
|
|
26
|
+
iconTrailing: 'right-3',
|
|
27
|
+
},
|
|
28
|
+
lg: {
|
|
29
|
+
root: cx.cx('px-3.5 py-2.5 text-md', isInvalid && 'pr-9.5', Icon && 'pl-10.5'),
|
|
30
|
+
iconLeading: 'left-3.5 size-5',
|
|
31
|
+
iconTrailing: 'right-3.5',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return (jsxRuntime.jsxs(reactAriaComponents.Group
|
|
35
|
+
// Opts out of the field's group context, which the date input inside takes: sharing it doubled the field's id and key handlers.
|
|
36
|
+
, {
|
|
37
|
+
// Opts out of the field's group context, which the date input inside takes: sharing it doubled the field's id and key handlers.
|
|
38
|
+
slot: null, isDisabled, isInvalid, "data-testid": inputTestId, className: ({ isFocusWithin, isDisabled, isInvalid }) => cx.cx('group/input relative flex w-full flex-row place-content-center place-items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary transition-shadow duration-100 ease-linear ring-inset', isFocusWithin && !isDisabled && 'ring-2 ring-brand',
|
|
39
|
+
// Each `group-*` class follows the field around the input, which can be disabled or invalid without the prop.
|
|
40
|
+
isDisabled && 'cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100', 'group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100', isInvalid && 'ring-error_subtle', 'group-invalid:ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error', isFocusWithin && 'group-invalid:ring-2 group-invalid:ring-error', wrapperClassName), children: [Icon && jsxRuntime.jsx(Icon, { className: cx.cx('pointer-events-none absolute text-fg-quaternary', sizes[size].iconLeading) }), jsxRuntime.jsx(reactAriaComponents.DateInput, { ...inputProps, className: cx.cx('flex w-full', sizes[size].root, typeof inputProps.className === 'string' && inputProps.className), children: (segment) => (jsxRuntime.jsx(reactAriaComponents.DateSegment, { segment: segment, className: cx.cx('rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden', segment.isPlaceholder && 'text-placeholder uppercase', segment.type === 'literal' && 'text-fg-quaternary') })) }), jsxRuntime.jsx(uiIcons.InfoCircle, { className: cx.cx('pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block', sizes[size].iconTrailing) })] }));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.SegmentedInputBase = SegmentedInputBase;
|
|
44
|
+
//# sourceMappingURL=SegmentedInputBase.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedInputBase.cjs","sources":["../../../../src/components/__internal__/segmentedInput/SegmentedInputBase.tsx"],"sourcesContent":[null],"names":["useTestIdPrefix","joinTestId","sortCx","cx","_jsxs","AriaGroup","_jsx","AriaDateInput","AriaDateSegment","InfoCircle"],"mappings":";;;;;;;;AAsBA;;;AAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,UAAU,EAA2B,KAAI;AACjJ,IAAA,MAAM,MAAM,GAAGA,2BAAe,EAAE;AAChC,IAAA,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,GAAG,UAAU,CAAC,IAAI,GAAG,SAAS;IAC9E,MAAM,WAAW,GAAG,MAAM,GAAGC,sBAAU,CAAC,MAAM,EAAE,IAAI,GAAG,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE,GAAG,OAAO,CAAC,GAAG,SAAS;IAE7F,MAAM,KAAK,GAAGC,SAAM,CAAC;AACnB,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAEC,KAAE,CAAC,mBAAmB,EAAE,SAAS,IAAI,MAAM,EAAE,IAAI,IAAI,QAAQ,CAAC;AACpE,YAAA,WAAW,EAAE,+BAA+B;AAC5C,YAAA,YAAY,EAAE,SAAS;AACxB,SAAA;AACD,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAEA,KAAE,CAAC,mBAAmB,EAAE,SAAS,IAAI,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC;AACnE,YAAA,WAAW,EAAE,eAAe;AAC5B,YAAA,YAAY,EAAE,SAAS;AACxB,SAAA;AACD,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAEA,KAAE,CAAC,uBAAuB,EAAE,SAAS,IAAI,QAAQ,EAAE,IAAI,IAAI,SAAS,CAAC;AAC3E,YAAA,WAAW,EAAE,iBAAiB;AAC9B,YAAA,YAAY,EAAE,WAAW;AAC1B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|
|
|
1
|
+
import type { ComponentType, HTMLAttributes } from 'react';
|
|
2
|
+
import type { DateInputProps as AriaDateInputProps } from 'react-aria-components';
|
|
3
|
+
export interface SegmentedInputBaseProps extends Omit<AriaDateInputProps, 'children'> {
|
|
4
|
+
/** Sets the input's height, padding and text size. */
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
/** Class name for the input wrapper. */
|
|
7
|
+
wrapperClassName?: string;
|
|
8
|
+
/** Icon component to display on the left side of the input. */
|
|
9
|
+
icon?: ComponentType<HTMLAttributes<HTMLOrSVGElement>>;
|
|
10
|
+
/** Draws the error ring and shows the error icon. */
|
|
11
|
+
isInvalid?: boolean;
|
|
12
|
+
/** Dims the input and blocks editing. */
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The bordered group of date or time segments, with no label or hint, for a react-aria `DateField`, `TimeField` or a
|
|
17
|
+
* picker's `start` and `end` slots. INTERNAL: import as `#internal/components/segmentedInput/SegmentedInputBase`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SegmentedInputBase: ({ size, isInvalid, isDisabled, icon: Icon, wrapperClassName, ...inputProps }: SegmentedInputBaseProps) => import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=SegmentedInputBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedInputBase.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/segmentedInput/SegmentedInputBase.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGlF,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC;IACnF,sDAAsD;IACtD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,8EAAqF,uBAAuB,gCA2E9I,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { InfoCircle } from '@flipdish/ui-icons';
|
|
3
|
+
import { sortCx, cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
+
import { useTestIdPrefix, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
import { Group, DateInput, DateSegment } from 'react-aria-components';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The bordered group of date or time segments, with no label or hint, for a react-aria `DateField`, `TimeField` or a
|
|
9
|
+
* picker's `start` and `end` slots. INTERNAL: import as `#internal/components/segmentedInput/SegmentedInputBase`.
|
|
10
|
+
*/
|
|
11
|
+
const SegmentedInputBase = ({ size = 'md', isInvalid, isDisabled, icon: Icon, wrapperClassName, ...inputProps }) => {
|
|
12
|
+
const prefix = useTestIdPrefix();
|
|
13
|
+
const slot = typeof inputProps.slot === 'string' ? inputProps.slot : undefined;
|
|
14
|
+
const inputTestId = prefix ? joinTestId(prefix, slot ? `input-${slot}` : 'input') : undefined;
|
|
15
|
+
const sizes = sortCx({
|
|
16
|
+
sm: {
|
|
17
|
+
root: cx('px-3 py-2 text-sm', isInvalid && 'pr-9', Icon && 'pl-8.5'),
|
|
18
|
+
iconLeading: 'left-3 size-4 stroke-[2.25px]',
|
|
19
|
+
iconTrailing: 'right-3',
|
|
20
|
+
},
|
|
21
|
+
md: {
|
|
22
|
+
root: cx('px-3 py-2 text-md', isInvalid && 'pr-9', Icon && 'pl-10'),
|
|
23
|
+
iconLeading: 'left-3 size-5',
|
|
24
|
+
iconTrailing: 'right-3',
|
|
25
|
+
},
|
|
26
|
+
lg: {
|
|
27
|
+
root: cx('px-3.5 py-2.5 text-md', isInvalid && 'pr-9.5', Icon && 'pl-10.5'),
|
|
28
|
+
iconLeading: 'left-3.5 size-5',
|
|
29
|
+
iconTrailing: 'right-3.5',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return (jsxs(Group
|
|
33
|
+
// Opts out of the field's group context, which the date input inside takes: sharing it doubled the field's id and key handlers.
|
|
34
|
+
, {
|
|
35
|
+
// Opts out of the field's group context, which the date input inside takes: sharing it doubled the field's id and key handlers.
|
|
36
|
+
slot: null, isDisabled, isInvalid, "data-testid": inputTestId, className: ({ isFocusWithin, isDisabled, isInvalid }) => cx('group/input relative flex w-full flex-row place-content-center place-items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary transition-shadow duration-100 ease-linear ring-inset', isFocusWithin && !isDisabled && 'ring-2 ring-brand',
|
|
37
|
+
// Each `group-*` class follows the field around the input, which can be disabled or invalid without the prop.
|
|
38
|
+
isDisabled && 'cursor-not-allowed opacity-50 in-data-input-wrapper:opacity-100', 'group-disabled:cursor-not-allowed group-disabled:opacity-50 in-data-input-wrapper:group-disabled:opacity-100', isInvalid && 'ring-error_subtle', 'group-invalid:ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error', isFocusWithin && 'group-invalid:ring-2 group-invalid:ring-error', wrapperClassName), children: [Icon && jsx(Icon, { className: cx('pointer-events-none absolute text-fg-quaternary', sizes[size].iconLeading) }), jsx(DateInput, { ...inputProps, className: cx('flex w-full', sizes[size].root, typeof inputProps.className === 'string' && inputProps.className), children: (segment) => (jsx(DateSegment, { segment: segment, className: cx('rounded px-0.5 text-primary tabular-nums caret-transparent focus:bg-brand-solid focus:font-medium focus:text-white focus:outline-hidden', segment.isPlaceholder && 'text-placeholder uppercase', segment.type === 'literal' && 'text-fg-quaternary') })) }), jsx(InfoCircle, { className: cx('pointer-events-none absolute hidden size-4 stroke-[2.25px] text-fg-error-secondary group-invalid/input:block', sizes[size].iconTrailing) })] }));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { SegmentedInputBase };
|
|
42
|
+
//# sourceMappingURL=SegmentedInputBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedInputBase.js","sources":["../../../../src/components/__internal__/segmentedInput/SegmentedInputBase.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaGroup","_jsx","AriaDateInput","AriaDateSegment"],"mappings":";;;;;;AAsBA;;;AAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,UAAU,EAA2B,KAAI;AACjJ,IAAA,MAAM,MAAM,GAAG,eAAe,EAAE;AAChC,IAAA,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,GAAG,UAAU,CAAC,IAAI,GAAG,SAAS;IAC9E,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,IAAI,GAAG,CAAA,MAAA,EAAS,IAAI,CAAA,CAAE,GAAG,OAAO,CAAC,GAAG,SAAS;IAE7F,MAAM,KAAK,GAAG,MAAM,CAAC;AACnB,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAE,EAAE,CAAC,mBAAmB,EAAE,SAAS,IAAI,MAAM,EAAE,IAAI,IAAI,QAAQ,CAAC;AACpE,YAAA,WAAW,EAAE,+BAA+B;AAC5C,YAAA,YAAY,EAAE,SAAS;AACxB,SAAA;AACD,QAAA,EAAE,EAAE;AACF,YAAA,IAAI,EAAE,EAAE,CAAC,mBAAmB,EAAE,SAAS,IAAI,MAAM,EAAE,IAAI,IAAI,OAA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D,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,oBAAoB,CACnD,EAAA,CACD,CACH,EAAA,CACa,EAEhBF,GAAA,CAAC,UAAU,EAAA,EACT,SAAS,EAAE,EAAE,CACX,8GAA8G,EAC9G,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,CACzB,EAAA,CACD,CAAA,EAAA,CACQ;AAEhB;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactAriaComponents = require('react-aria-components');
|
|
8
|
+
var SegmentedInputBase = require('../../../__internal__/segmentedInput/SegmentedInputBase.cjs');
|
|
9
|
+
var HintText = require('../components/HintText.cjs');
|
|
10
|
+
var Label = require('../components/Label.cjs');
|
|
11
|
+
var timeInput_utils = require('./utilities/timeInput.utils.cjs');
|
|
12
|
+
|
|
13
|
+
/** Hands the field's react-aria state to `TimeInput`, whose blur handler sits outside the field that provides it. */
|
|
14
|
+
const TimeInputStateRef = ({ ref }) => {
|
|
15
|
+
const state = React.useContext(reactAriaComponents.TimeFieldStateContext);
|
|
16
|
+
React.useImperativeHandle(ref, () => state, [state]);
|
|
17
|
+
return null;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A field for typing a time of day, one segment each for the hour, the minute and, on a 12-hour clock, AM or PM. Reach
|
|
21
|
+
* for it when the user sets a time with no date, such as an opening hour; it follows the user's locale unless `hourCycle` is set.
|
|
22
|
+
*
|
|
23
|
+
* @summary typed time-of-day field with hour and minute segments
|
|
24
|
+
*/
|
|
25
|
+
const TimeInput = ({ label, hint, size = 'md', icon, hideRequiredIndicator, className, ref, onBlur, 'data-testid': dataTestId, ...props }) => {
|
|
26
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'time-input', rootName: 'time-input' });
|
|
27
|
+
const fieldState = React.useRef(null);
|
|
28
|
+
// Leaving a time with a segment cleared empties it, before `onBlur`, so a form validates the empty field.
|
|
29
|
+
const handleBlur = (event) => {
|
|
30
|
+
const state = fieldState.current;
|
|
31
|
+
if (state && timeInput_utils.isPartlyCleared(Boolean(state.value), state.segments))
|
|
32
|
+
state.setValue(null);
|
|
33
|
+
onBlur?.(event);
|
|
34
|
+
};
|
|
35
|
+
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.TimeField, { ...props, ref: ref, onBlur: handleBlur, "data-testid": rootTestId, className: (state) => cx.cx('group flex h-max w-full flex-col items-start justify-start gap-1.5', typeof className === 'function' ? className(state) : className), children: ({ isInvalid, isDisabled, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(TimeInputStateRef, { ref: fieldState }), label && (jsxRuntime.jsx(Label.Label, { isRequired: hideRequiredIndicator ? false : isRequired, isInvalid: isInvalid, children: label })), jsxRuntime.jsx(SegmentedInputBase.SegmentedInputBase, { size: size, icon: icon, isInvalid: isInvalid, isDisabled: isDisabled }), hint && (jsxRuntime.jsx(HintText.HintText, { isInvalid: isInvalid, size: size === 'sm' ? 'sm' : 'md', children: hint }))] })) }) }));
|
|
36
|
+
};
|
|
37
|
+
TimeInput.displayName = 'TimeInput';
|
|
38
|
+
|
|
39
|
+
exports.TimeInput = TimeInput;
|
|
40
|
+
//# sourceMappingURL=TimeInput.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeInput.cjs","sources":["../../../../../src/components/atoms/Inputs/TimeInput/TimeInput.tsx"],"sourcesContent":[null],"names":["useContext","TimeFieldStateContext","useImperativeHandle","useResolvedTestId","useRef","isPartlyCleared","_jsx","TestIdProvider","AriaTimeField","cx","_jsxs","_Fragment","Label","SegmentedInputBase","HintText"],"mappings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AAS,KAAK,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,EAAA,QAAA,EAGzI,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MACrCC,eAAA,CAAAC,mBAAA,EAAA,EAAA,QAAA,EAAA,CACEL,cAAA,CAAC,iBAAiB,EAAA,EAAC,GAAG,EAAE,UAAU,EAAA,CAAI,EACrC,KAAK,KACJA,cAAA,CAACM,WAAK,EAAA,EAAC,UAAU,EAAE,qBAAqB,GAAG,KAAK,GAAG,UAAU,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EAChF,KAAK,EAAA,CACA,CACT,EAEDN,cAAA,CAACO,qCAAkB,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI,EAE3F,IAAI,KACHP,cAAA,CAACQ,iBAAQ,EAAA,EAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,EAAA,QAAA,EAC9D,IAAI,EAAA,CACI,CACZ,CAAA,EAAA,CACA,CACJ,EAAA,CACa,EAAA,CACD;AAErB;AAEA,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ComponentType, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { TimeFieldProps as AriaTimeFieldProps, TimeValue } from 'react-aria-components';
|
|
3
|
+
export interface TimeInputProps extends AriaTimeFieldProps<TimeValue> {
|
|
4
|
+
/** Visible label above the field; it names every segment. When omitted, pass `aria-label`. */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Helper text beneath the field, read out as its description; shown as the error message while the field is invalid. */
|
|
7
|
+
hint?: ReactNode;
|
|
8
|
+
/** Sets the field's height, padding and text size. */
|
|
9
|
+
size?: 'sm' | 'md' | 'lg';
|
|
10
|
+
/** Icon component shown before the segments, such as a clock. */
|
|
11
|
+
icon?: ComponentType<HTMLAttributes<HTMLOrSVGElement>>;
|
|
12
|
+
/** Hides the asterisk a required field shows beside its label. */
|
|
13
|
+
hideRequiredIndicator?: boolean;
|
|
14
|
+
/** Ref forwarded to the root element, which holds the label, the segments and the hint. */
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
16
|
+
/** Overrides the root `data-testid` (defaults to `fd-time-input`). The group of segments derives its id from it. */
|
|
17
|
+
'data-testid'?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A field for typing a time of day, one segment each for the hour, the minute and, on a 12-hour clock, AM or PM. Reach
|
|
21
|
+
* for it when the user sets a time with no date, such as an opening hour; it follows the user's locale unless `hourCycle` is set.
|
|
22
|
+
*
|
|
23
|
+
* @summary typed time-of-day field with hour and minute segments
|
|
24
|
+
*/
|
|
25
|
+
export declare const TimeInput: {
|
|
26
|
+
({ label, hint, size, icon, hideRequiredIndicator, className, ref, onBlur, "data-testid": dataTestId, ...props }: TimeInputProps): import("react").JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=TimeInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Inputs/TimeInput/TimeInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAc,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvF,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAkB,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAO7G,MAAM,WAAW,cAAe,SAAQ,kBAAkB,CAAC,SAAS,CAAC;IACnE,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yHAAyH;IACzH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sDAAsD;IACtD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,iEAAiE;IACjE,IAAI,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,kEAAkE;IAClE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,2FAA2F;IAC3F,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,oHAAoH;IACpH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AASD;;;;;GAKG;AACH,eAAO,MAAM,SAAS;sHAWnB,cAAc;;CA0ChB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
|
+
import { useResolvedTestId, TestIdProvider } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
|
+
import { useRef, useContext, useImperativeHandle } from 'react';
|
|
5
|
+
import { TimeField, TimeFieldStateContext } from 'react-aria-components';
|
|
6
|
+
import { SegmentedInputBase } from '../../../__internal__/segmentedInput/SegmentedInputBase.js';
|
|
7
|
+
import { HintText } from '../components/HintText.js';
|
|
8
|
+
import { Label } from '../components/Label.js';
|
|
9
|
+
import { isPartlyCleared } from './utilities/timeInput.utils.js';
|
|
10
|
+
|
|
11
|
+
/** Hands the field's react-aria state to `TimeInput`, whose blur handler sits outside the field that provides it. */
|
|
12
|
+
const TimeInputStateRef = ({ ref }) => {
|
|
13
|
+
const state = useContext(TimeFieldStateContext);
|
|
14
|
+
useImperativeHandle(ref, () => state, [state]);
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A field for typing a time of day, one segment each for the hour, the minute and, on a 12-hour clock, AM or PM. Reach
|
|
19
|
+
* for it when the user sets a time with no date, such as an opening hour; it follows the user's locale unless `hourCycle` is set.
|
|
20
|
+
*
|
|
21
|
+
* @summary typed time-of-day field with hour and minute segments
|
|
22
|
+
*/
|
|
23
|
+
const TimeInput = ({ label, hint, size = 'md', icon, hideRequiredIndicator, className, ref, onBlur, 'data-testid': dataTestId, ...props }) => {
|
|
24
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'time-input', rootName: 'time-input' });
|
|
25
|
+
const fieldState = useRef(null);
|
|
26
|
+
// Leaving a time with a segment cleared empties it, before `onBlur`, so a form validates the empty field.
|
|
27
|
+
const handleBlur = (event) => {
|
|
28
|
+
const state = fieldState.current;
|
|
29
|
+
if (state && isPartlyCleared(Boolean(state.value), state.segments))
|
|
30
|
+
state.setValue(null);
|
|
31
|
+
onBlur?.(event);
|
|
32
|
+
};
|
|
33
|
+
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(TimeField, { ...props, ref: ref, onBlur: handleBlur, "data-testid": rootTestId, className: (state) => cx('group flex h-max w-full flex-col items-start justify-start gap-1.5', typeof className === 'function' ? className(state) : className), children: ({ isInvalid, isDisabled, isRequired }) => (jsxs(Fragment, { children: [jsx(TimeInputStateRef, { ref: fieldState }), label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : isRequired, isInvalid: isInvalid, children: label })), jsx(SegmentedInputBase, { size: size, icon: icon, isInvalid: isInvalid, isDisabled: isDisabled }), hint && (jsx(HintText, { isInvalid: isInvalid, size: size === 'sm' ? 'sm' : 'md', children: hint }))] })) }) }));
|
|
34
|
+
};
|
|
35
|
+
TimeInput.displayName = 'TimeInput';
|
|
36
|
+
|
|
37
|
+
export { TimeInput };
|
|
38
|
+
//# sourceMappingURL=TimeInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeInput.js","sources":["../../../../../src/components/atoms/Inputs/TimeInput/TimeInput.tsx"],"sourcesContent":[null],"names":["_jsx","AriaTimeField","_jsxs","_Fragment"],"mappings":";;;;;;;;;;AA8BA;AACA,MAAM,iBAAiB,GAAG,CAAC,EAAE,GAAG,EAAuC,KAAI;AACz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,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MACrCC,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACEH,GAAA,CAAC,iBAAiB,EAAA,EAAC,GAAG,EAAE,UAAU,EAAA,CAAI,EACrC,KAAK,KACJA,GAAA,CAAC,KAAK,EAAA,EAAC,UAAU,EAAE,qBAAqB,GAAG,KAAK,GAAG,UAAU,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EAChF,KAAK,EAAA,CACA,CACT,EAEDA,GAAA,CAAC,kBAAkB,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI,EAE3F,IAAI,KACHA,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,IAAI,EAAA,QAAA,EAC9D,IAAI,EAAA,CACI,CACZ,CAAA,EAAA,CACA,CACJ,EAAA,CACa,EAAA,CACD;AAErB;AAEA,SAAS,CAAC,WAAW,GAAG,WAAW;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tells whether the user has cleared part of the time a field holds. react-aria reports no change for that, so the field
|
|
5
|
+
* would go on holding a time it no longer shows.
|
|
6
|
+
*
|
|
7
|
+
* @param hasValue Whether the field holds a time.
|
|
8
|
+
* @param segments The field's segments, as react-aria's field state lists them.
|
|
9
|
+
* @returns `true` when the field holds a time and at least one segment the user can edit shows its placeholder.
|
|
10
|
+
*/
|
|
11
|
+
const isPartlyCleared = (hasValue, segments) => hasValue && segments.some((segment) => segment.isEditable && segment.isPlaceholder);
|
|
12
|
+
|
|
13
|
+
exports.isPartlyCleared = isPartlyCleared;
|
|
14
|
+
//# sourceMappingURL=timeInput.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeInput.utils.cjs","sources":["../../../../../../src/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AACI,MAAM,eAAe,GAAG,CAAC,QAAiB,EAAE,QAAoE,KACrH,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,aAAa;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells whether the user has cleared part of the time a field holds. react-aria reports no change for that, so the field
|
|
3
|
+
* would go on holding a time it no longer shows.
|
|
4
|
+
*
|
|
5
|
+
* @param hasValue Whether the field holds a time.
|
|
6
|
+
* @param segments The field's segments, as react-aria's field state lists them.
|
|
7
|
+
* @returns `true` when the field holds a time and at least one segment the user can edit shows its placeholder.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isPartlyCleared: (hasValue: boolean, segments: readonly {
|
|
10
|
+
isEditable: boolean;
|
|
11
|
+
isPlaceholder: boolean;
|
|
12
|
+
}[]) => boolean;
|
|
13
|
+
//# sourceMappingURL=timeInput.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeInput.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,OAAO,EAAE,UAAU,SAAS;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,EAAE,KAAG,OACrC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells whether the user has cleared part of the time a field holds. react-aria reports no change for that, so the field
|
|
3
|
+
* would go on holding a time it no longer shows.
|
|
4
|
+
*
|
|
5
|
+
* @param hasValue Whether the field holds a time.
|
|
6
|
+
* @param segments The field's segments, as react-aria's field state lists them.
|
|
7
|
+
* @returns `true` when the field holds a time and at least one segment the user can edit shows its placeholder.
|
|
8
|
+
*/
|
|
9
|
+
const isPartlyCleared = (hasValue, segments) => hasValue && segments.some((segment) => segment.isEditable && segment.isPlaceholder);
|
|
10
|
+
|
|
11
|
+
export { isPartlyCleared };
|
|
12
|
+
//# sourceMappingURL=timeInput.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeInput.utils.js","sources":["../../../../../../src/components/atoms/Inputs/TimeInput/utilities/timeInput.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;AAOG;AACI,MAAM,eAAe,GAAG,CAAC,QAAiB,EAAE,QAAoE,KACrH,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,aAAa;;"}
|
|
@@ -5,6 +5,7 @@ var Label = require('./components/Label.cjs');
|
|
|
5
5
|
var Input = require('./Input/Input.cjs');
|
|
6
6
|
var SearchInput = require('./SearchInput/SearchInput.cjs');
|
|
7
7
|
var TextArea = require('./TextArea/TextArea.cjs');
|
|
8
|
+
var TimeInput = require('./TimeInput/TimeInput.cjs');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -16,4 +17,5 @@ exports.TextField = Input.TextField;
|
|
|
16
17
|
exports.SearchInput = SearchInput.SearchInput;
|
|
17
18
|
exports.TextArea = TextArea.TextArea;
|
|
18
19
|
exports.TextAreaBase = TextArea.TextAreaBase;
|
|
20
|
+
exports.TimeInput = TimeInput.TimeInput;
|
|
19
21
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Fields the user types into: `Input` for one line (with `InputBase` and `TextField` for building a custom field),
|
|
3
|
-
* `SearchInput` for a box that filters as you type, `TextArea` for several lines (with `TextAreaBase`),
|
|
4
|
-
* and `HintText` every one of them renders.
|
|
3
|
+
* `SearchInput` for a box that filters as you type, `TextArea` for several lines (with `TextAreaBase`), `TimeInput` for a
|
|
4
|
+
* time of day, and the `Label` and `HintText` every one of them renders.
|
|
5
5
|
*
|
|
6
6
|
* Explicit named re-exports on purpose: `export *` would publish every symbol of every member and private file
|
|
7
7
|
* (import paths are the public API here), so this list is the single source of truth for what Inputs exposes.
|
|
@@ -16,4 +16,6 @@ export type { SearchInputProps } from './SearchInput/SearchInput';
|
|
|
16
16
|
export { SearchInput } from './SearchInput/SearchInput';
|
|
17
17
|
export type { TextAreaProps } from './TextArea/TextArea';
|
|
18
18
|
export { TextArea, TextAreaBase } from './TextArea/TextArea';
|
|
19
|
+
export type { TimeInputProps } from './TimeInput/TimeInput';
|
|
20
|
+
export { TimeInput } from './TimeInput/TimeInput';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Inputs/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Inputs/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -3,4 +3,5 @@ export { Label } from './components/Label.js';
|
|
|
3
3
|
export { Input, InputBase, TextField } from './Input/Input.js';
|
|
4
4
|
export { SearchInput } from './SearchInput/SearchInput.js';
|
|
5
5
|
export { TextArea, TextAreaBase } from './TextArea/TextArea.js';
|
|
6
|
+
export { TimeInput } from './TimeInput/TimeInput.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var date = require('@internationalized/date');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
7
|
+
*
|
|
8
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
9
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
10
|
+
*/
|
|
11
|
+
const toCalendarDate = (value) => {
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
return null;
|
|
14
|
+
try {
|
|
15
|
+
return date.parseDate(value.slice(0, 10));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Reads a form value as a range of calendar dates without throwing, as `toCalendarDate` does for one date.
|
|
23
|
+
*
|
|
24
|
+
* @param value The field's value: a `start` and an `end`, each an ISO date or an ISO date-time whose date part is used.
|
|
25
|
+
* @returns The range, or `null` for an empty value or one whose start or end is not an ISO date.
|
|
26
|
+
*/
|
|
27
|
+
const toCalendarDateRange = (value) => {
|
|
28
|
+
const start = toCalendarDate(value?.start);
|
|
29
|
+
const end = toCalendarDate(value?.end);
|
|
30
|
+
return start && end ? { start, end } : null;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Writes a picked range as the form holds it.
|
|
34
|
+
*
|
|
35
|
+
* @param range The range a date range picker reports, or `null` for none; a time on either end is dropped.
|
|
36
|
+
* @returns The start and end as ISO date strings, or `null` for no range.
|
|
37
|
+
*/
|
|
38
|
+
const toIsoDateRange = (range) => range ? { start: range.start.toString().slice(0, 10), end: range.end.toString().slice(0, 10) } : null;
|
|
39
|
+
|
|
40
|
+
exports.toCalendarDate = toCalendarDate;
|
|
41
|
+
exports.toCalendarDateRange = toCalendarDateRange;
|
|
42
|
+
exports.toIsoDateRange = toIsoDateRange;
|
|
43
|
+
//# sourceMappingURL=dateValue.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValue.utils.cjs","sources":["../../../../../../src/components/forms/__internal__/dateValue/utilities/dateValue.utils.ts"],"sourcesContent":[null],"names":["parseDate"],"mappings":";;;;AAQA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAOA,cAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA+C,KAAuD;IACxI,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC;IAC1C,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC;AACtC,IAAA,OAAO,KAAK,IAAI,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;AAC7C;AAEA;;;;;AAKG;MACU,cAAc,GAAG,CAAC,KAAoF,KACjH,KAAK,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type CalendarDate } from '@internationalized/date';
|
|
2
|
+
/** A start and end date as a form holds them: two ISO date strings (`YYYY-MM-DD`). */
|
|
3
|
+
export interface IsoDateRange {
|
|
4
|
+
start: string;
|
|
5
|
+
end: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
9
|
+
*
|
|
10
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
11
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
12
|
+
*/
|
|
13
|
+
export declare const toCalendarDate: (value: string | null | undefined) => CalendarDate | null;
|
|
14
|
+
/**
|
|
15
|
+
* Reads a form value as a range of calendar dates without throwing, as `toCalendarDate` does for one date.
|
|
16
|
+
*
|
|
17
|
+
* @param value The field's value: a `start` and an `end`, each an ISO date or an ISO date-time whose date part is used.
|
|
18
|
+
* @returns The range, or `null` for an empty value or one whose start or end is not an ISO date.
|
|
19
|
+
*/
|
|
20
|
+
export declare const toCalendarDateRange: (value: Partial<IsoDateRange> | null | undefined) => {
|
|
21
|
+
start: CalendarDate;
|
|
22
|
+
end: CalendarDate;
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* Writes a picked range as the form holds it.
|
|
26
|
+
*
|
|
27
|
+
* @param range The range a date range picker reports, or `null` for none; a time on either end is dropped.
|
|
28
|
+
* @returns The start and end as ISO date strings, or `null` for no range.
|
|
29
|
+
*/
|
|
30
|
+
export declare const toIsoDateRange: (range: {
|
|
31
|
+
start: {
|
|
32
|
+
toString: () => string;
|
|
33
|
+
};
|
|
34
|
+
end: {
|
|
35
|
+
toString: () => string;
|
|
36
|
+
};
|
|
37
|
+
} | null) => IsoDateRange | null;
|
|
38
|
+
//# sourceMappingURL=dateValue.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValue.utils.d.ts","sourceRoot":"","sources":["../../../../../../src/components/forms/__internal__/dateValue/utilities/dateValue.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,yBAAyB,CAAC;AAEvE,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,YAAY,GAAG,IAOhF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,YAAY,CAAA;CAAE,GAAG,IAIlI,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO;IAAE,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC;IAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,IAAI,KAAG,YAAY,GAAG,IAC9B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { parseDate } from '@internationalized/date';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reads a form value as a calendar date without throwing, since a default value may come from an API in another shape.
|
|
5
|
+
*
|
|
6
|
+
* @param value The field's value: an ISO date (`2026-03-01`), or an ISO date-time whose date part is used.
|
|
7
|
+
* @returns The date, or `null` for an empty value or one that is not an ISO date.
|
|
8
|
+
*/
|
|
9
|
+
const toCalendarDate = (value) => {
|
|
10
|
+
if (typeof value !== 'string')
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
return parseDate(value.slice(0, 10));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Reads a form value as a range of calendar dates without throwing, as `toCalendarDate` does for one date.
|
|
21
|
+
*
|
|
22
|
+
* @param value The field's value: a `start` and an `end`, each an ISO date or an ISO date-time whose date part is used.
|
|
23
|
+
* @returns The range, or `null` for an empty value or one whose start or end is not an ISO date.
|
|
24
|
+
*/
|
|
25
|
+
const toCalendarDateRange = (value) => {
|
|
26
|
+
const start = toCalendarDate(value?.start);
|
|
27
|
+
const end = toCalendarDate(value?.end);
|
|
28
|
+
return start && end ? { start, end } : null;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Writes a picked range as the form holds it.
|
|
32
|
+
*
|
|
33
|
+
* @param range The range a date range picker reports, or `null` for none; a time on either end is dropped.
|
|
34
|
+
* @returns The start and end as ISO date strings, or `null` for no range.
|
|
35
|
+
*/
|
|
36
|
+
const toIsoDateRange = (range) => range ? { start: range.start.toString().slice(0, 10), end: range.end.toString().slice(0, 10) } : null;
|
|
37
|
+
|
|
38
|
+
export { toCalendarDate, toCalendarDateRange, toIsoDateRange };
|
|
39
|
+
//# sourceMappingURL=dateValue.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateValue.utils.js","sources":["../../../../../../src/components/forms/__internal__/dateValue/utilities/dateValue.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA;;;;;AAKG;AACI,MAAM,cAAc,GAAG,CAAC,KAAgC,KAAyB;IACtF,IAAI,OAAO,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,IAAI;AAC1C,IAAA,IAAI;QACF,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACtC;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,IAAI;IACb;AACF;AAEA;;;;;AAKG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAA+C,KAAuD;IACxI,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC;IAC1C,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC;AACtC,IAAA,OAAO,KAAK,IAAI,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI;AAC7C;AAEA;;;;;AAKG;MACU,cAAc,GAAG,CAAC,KAAoF,KACjH,KAAK,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG;;"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var DatePickers = require('@flipdish/ui-library/components/organisms/DatePickers');
|
|
5
5
|
var React = require('react');
|
|
6
|
+
var dateValue_utils = require('../../__internal__/dateValue/utilities/dateValue.utils.cjs');
|
|
6
7
|
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
7
8
|
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
8
|
-
var formDatePicker_utils = require('./utilities/formDatePicker.utils.cjs');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
|
|
@@ -17,7 +17,7 @@ var formDatePicker_utils = require('./utilities/formDatePicker.utils.cjs');
|
|
|
17
17
|
const FormDatePicker = ({ name, revalidates, hint, ...datePickerProps }) => {
|
|
18
18
|
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
19
19
|
// An unset, empty or unreadable field is no date; `null` keeps the picker controlled, and a stable date keeps its draft intact.
|
|
20
|
-
const date = React.useMemo(() =>
|
|
20
|
+
const date = React.useMemo(() => dateValue_utils.toCalendarDate(value), [value]);
|
|
21
21
|
// `DatePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
|
|
22
22
|
const handleChange = (next) => onCommit(next ? next.toString() : null);
|
|
23
23
|
// `DatePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","toCalendarDate","useFocusTarget","_jsx","DatePicker"],"mappings":";;;;;;;;;AAqBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAGC,aAAO,CAAC,MAAMC,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormDatePicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","toCalendarDate","useFocusTarget","_jsx","DatePicker"],"mappings":";;;;;;;;;AAqBA;;;;;;AAMG;AACI,MAAM,cAAc,GAAG,CAA4C,EACxE,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,eAAe,EACW,KAAI;IACjC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAAyB,IAAI,EAAE,WAAW,CAAC;;AAE/I,IAAA,MAAM,IAAI,GAAGC,aAAO,CAAC,MAAMC,8BAAc,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;IAE1D,MAAM,YAAY,GAAG,CAAC,IAAsB,KAAK,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC;;IAGxF,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,eAAe,EACnB,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,eAAe,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CAChE;AAEN;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { DatePicker } from '@flipdish/ui-library/components/organisms/DatePickers';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
+
import { toCalendarDate } from '../../__internal__/dateValue/utilities/dateValue.utils.js';
|
|
4
5
|
import { useFocusTarget } from '../../__internal__/formField/hooks/useFocusTarget.js';
|
|
5
6
|
import { useFormField } from '../../__internal__/formField/hooks/useFormField.js';
|
|
6
|
-
import { toCalendarDate } from './utilities/formDatePicker.utils.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A `DatePicker` bound to a react-hook-form field: pressing Apply writes the date to the form as an ISO string
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var DatePickers = require('@flipdish/ui-library/components/organisms/DatePickers');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var dateValue_utils = require('../../__internal__/dateValue/utilities/dateValue.utils.cjs');
|
|
7
|
+
var useFocusTarget = require('../../__internal__/formField/hooks/useFocusTarget.cjs');
|
|
8
|
+
var useFormField = require('../../__internal__/formField/hooks/useFormField.cjs');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A `DateRangePicker` bound to a react-hook-form field: pressing Apply writes the range to the form as `start` and `end`
|
|
12
|
+
* ISO strings (`YYYY-MM-DD`) and validates it at once, and the field's error shows in place of `hint`. Use it when the
|
|
13
|
+
* user picks a start and an end date in a react-hook-form form.
|
|
14
|
+
*
|
|
15
|
+
* @summary date range picker bound to a react-hook-form field
|
|
16
|
+
*/
|
|
17
|
+
const FormDateRangePicker = ({ name, revalidates, hint, ...dateRangePickerProps }) => {
|
|
18
|
+
const { value, ref, onCommit, onBlur, isInvalid, errorMessage, isDisabled, isLocked } = useFormField.useFormField(name, revalidates);
|
|
19
|
+
// An unset or unreadable field is no range; `null` keeps the picker controlled, and a stable range keeps its draft intact.
|
|
20
|
+
const range = React.useMemo(() => dateValue_utils.toCalendarDateRange(value), [value]);
|
|
21
|
+
// `DateRangePicker` reports a change only when Apply is pressed, so the draft the user is browsing never reaches the form.
|
|
22
|
+
const handleChange = (next) => onCommit(dateValue_utils.toIsoDateRange(next));
|
|
23
|
+
// `DateRangePicker`'s ref is its root div; the trigger is the only button in it, the calendar being portalled.
|
|
24
|
+
const focusRef = useFocusTarget.useFocusTarget(ref, 'button');
|
|
25
|
+
return (jsxRuntime.jsx(DatePickers.DateRangePicker
|
|
26
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
27
|
+
, {
|
|
28
|
+
// The form's schema validates; the browser's own `required` check would block the submit before it runs.
|
|
29
|
+
validationBehavior: "aria", ...dateRangePickerProps, ref: focusRef, value: range, onChange: handleChange, onBlur: onBlur, isInvalid: isInvalid, hint: errorMessage ?? hint,
|
|
30
|
+
// Disabled while the form submits: read-only would disable the trigger all the same, without looking it.
|
|
31
|
+
isDisabled: dateRangePickerProps.isDisabled || isDisabled || isLocked }));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.FormDateRangePicker = FormDateRangePicker;
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../src/components/forms/fields/FormDateRangePicker/index.tsx"],"sourcesContent":[null],"names":["useFormField","useMemo","toCalendarDateRange","toIsoDateRange","useFocusTarget","_jsx","DateRangePicker"],"mappings":";;;;;;;;;AAsBA;;;;;;AAMG;AACI,MAAM,mBAAmB,GAAG,CAA4C,EAC7E,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,GAAG,oBAAoB,EACW,KAAI;IACtC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAGA,yBAAY,CAClG,IAAI,EACJ,WAAW,CACZ;;AAED,IAAA,MAAM,KAAK,GAAGC,aAAO,CAAC,MAAMC,mCAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;;AAEhE,IAAA,MAAM,YAAY,GAAgB,CAAC,IAAI,KAAK,QAAQ,CAACC,8BAAc,CAAC,IAAI,CAAC,CAAC;;IAG1E,MAAM,QAAQ,GAAGC,6BAAc,CAAC,GAAG,EAAE,QAAQ,CAAC;IAE9C,QACEC,eAACC;;;;AAEC,QAAA,kBAAkB,EAAC,MAAM,EAAA,GACrB,oBAAoB,EACxB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,YAAY,IAAI,IAAI;;QAE1B,UAAU,EAAE,oBAAoB,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,EAAA,CACrE;AAEN;;"}
|