@pega/cosmos-react-core 3.0.0-dev.28.0 → 3.0.0-dev.30.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/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +23 -22
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/Currency/CurrencyInput.types.d.ts +1 -1
- package/lib/components/Currency/CurrencyInput.types.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.types.js.map +1 -1
- package/lib/components/DateTime/DateTime.types.d.ts +13 -9
- package/lib/components/DateTime/DateTime.types.d.ts.map +1 -1
- package/lib/components/DateTime/DateTime.types.js.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts +6 -2
- package/lib/components/DateTime/Input/DateInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.js +11 -10
- package/lib/components/DateTime/Input/DateInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.d.ts +16 -29
- package/lib/components/DateTime/Input/DateRangeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.js +95 -82
- package/lib/components/DateTime/Input/DateRangeInput.js.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.js +3 -2
- package/lib/components/DateTime/Input/DateTimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts.map +1 -1
- package/lib/components/DateTime/Input/TimeInput.js +3 -2
- package/lib/components/DateTime/Input/TimeInput.js.map +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.d.ts +46 -0
- package/lib/components/DateTime/Input/TimeRangeInput.d.ts.map +1 -0
- package/lib/components/DateTime/Input/TimeRangeInput.js +74 -0
- package/lib/components/DateTime/Input/TimeRangeInput.js.map +1 -0
- package/lib/components/DateTime/Input/WeekInput.js +2 -2
- package/lib/components/DateTime/Input/WeekInput.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +1 -1
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/TimePicker.d.ts +1 -1
- package/lib/components/DateTime/Picker/TimePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/TimePicker.js.map +1 -1
- package/lib/components/DateTime/index.d.ts +2 -0
- package/lib/components/DateTime/index.d.ts.map +1 -1
- package/lib/components/DateTime/index.js +1 -0
- package/lib/components/DateTime/index.js.map +1 -1
- package/lib/components/FieldValueList/FieldValueList.js +1 -1
- package/lib/components/FieldValueList/FieldValueList.js.map +1 -1
- package/lib/components/Flex/Flex.d.ts +10 -9
- package/lib/components/Flex/Flex.d.ts.map +1 -1
- package/lib/components/Flex/Flex.js.map +1 -1
- package/lib/components/Grid/Grid.d.ts +1 -1
- package/lib/components/Grid/Grid.d.ts.map +1 -1
- package/lib/components/Grid/Grid.types.d.ts +10 -8
- package/lib/components/Grid/Grid.types.d.ts.map +1 -1
- package/lib/components/Grid/Grid.types.js.map +1 -1
- package/lib/components/Icon/iconNames.d.ts +1 -1
- package/lib/components/Icon/iconNames.d.ts.map +1 -1
- package/lib/components/Icon/iconNames.js.map +1 -1
- package/lib/components/Icon/index.d.ts +1 -1
- package/lib/components/Icon/index.d.ts.map +1 -1
- package/lib/components/Icon/index.js.map +1 -1
- package/lib/components/Input/Input.styles.d.ts +1 -0
- package/lib/components/Input/Input.styles.d.ts.map +1 -1
- package/lib/components/Input/Input.styles.js +31 -0
- package/lib/components/Input/Input.styles.js.map +1 -1
- package/lib/components/Link/Link.d.ts +4 -1
- package/lib/components/Link/Link.d.ts.map +1 -1
- package/lib/components/Link/Link.js +37 -9
- package/lib/components/Link/Link.js.map +1 -1
- package/lib/components/Location/LocationView.d.ts.map +1 -1
- package/lib/components/Location/LocationView.js +2 -2
- package/lib/components/Location/LocationView.js.map +1 -1
- package/lib/components/Number/NumberInput.d.ts +1 -1
- package/lib/components/Number/NumberInput.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.js +4 -4
- package/lib/components/Number/NumberInput.js.map +1 -1
- package/lib/components/Number/NumberInput.styles.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.styles.js +2 -0
- package/lib/components/Number/NumberInput.styles.js.map +1 -1
- package/lib/components/Number/NumberInput.types.d.ts +54 -20
- package/lib/components/Number/NumberInput.types.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.types.js.map +1 -1
- package/lib/components/Number/NumberRangeInput.d.ts +6 -0
- package/lib/components/Number/NumberRangeInput.d.ts.map +1 -0
- package/lib/components/Number/NumberRangeInput.js +30 -0
- package/lib/components/Number/NumberRangeInput.js.map +1 -0
- package/lib/components/Number/index.d.ts +3 -2
- package/lib/components/Number/index.d.ts.map +1 -1
- package/lib/components/Number/index.js +1 -0
- package/lib/components/Number/index.js.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts +1 -0
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
- package/lib/components/RadioCheckGroup/index.d.ts +1 -1
- package/lib/components/RadioCheckGroup/index.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/index.js +1 -1
- package/lib/components/RadioCheckGroup/index.js.map +1 -1
- package/lib/components/Slider/Slider.styles.d.ts +1 -1
- package/lib/components/SummaryItem/SummaryItem.d.ts +2 -2
- package/lib/hooks/useI18n.d.ts +13 -1
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +13 -1
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +15 -1
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +13 -1
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/utils.d.ts +1 -1
- package/lib/styles/utils.d.ts.map +1 -1
- package/lib/styles/utils.js.map +1 -1
- package/lib/types/types.d.ts +3 -0
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +1 -1
- package/lib/components/DateTime/types.d.ts +0 -9
- package/lib/components/DateTime/types.d.ts.map +0 -1
- package/lib/components/DateTime/types.js +0 -2
- package/lib/components/DateTime/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAUlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAkB9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,sBAAsB,yGAwBjC,CAAC;AAGH,QAAA,MAAM,gBAAgB,EAAE,iBAAiB,CAAC,qBAAqB,GAAG,YAAY,CAsN7E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { defaultThemeProp } from '../../../theme';
|
|
|
6
6
|
import Selectable, { StyledSelectable } from '../../Badges/Selection';
|
|
7
7
|
import { StyledFormControl } from '../../FormControl';
|
|
8
8
|
import Flex from '../../Flex';
|
|
9
|
-
import { useConsolidatedRef, useActiveDescendant, useDirection, useI18n, useUID } from '../../../hooks';
|
|
9
|
+
import { useConsolidatedRef, useActiveDescendant, useDirection, useI18n, useUID, useTheme } from '../../../hooks';
|
|
10
10
|
import { cap, tryCatch } from '../../../utils';
|
|
11
11
|
import { StyledBareButton } from '../../Button/BareButton';
|
|
12
12
|
import VisuallyHiddenText from '../../VisuallyHiddenText';
|
|
@@ -40,6 +40,7 @@ const MultiSelectInput = forwardRef((props, ref) => {
|
|
|
40
40
|
const { selected = [], value, onRemove, onChange, onKeyDown, onResolveSuggestion, actions, readOnly, disabled, status, placeholder, autoFocus, pauseDescendantEvaluation, onSelectedFocus, onSelectedBlur, 'aria-controls': ariaControls, ...restProps } = props;
|
|
41
41
|
const t = useI18n();
|
|
42
42
|
const id = useUID();
|
|
43
|
+
const { base: { 'content-width': { xs: xsContentWidth } } } = useTheme();
|
|
43
44
|
const inputRef = useConsolidatedRef(ref);
|
|
44
45
|
const listRef = useRef(null);
|
|
45
46
|
const [focusDescendant, setFocusDescendant] = useState(null);
|
|
@@ -116,30 +117,30 @@ const MultiSelectInput = forwardRef((props, ref) => {
|
|
|
116
117
|
? `${id}-inputDescription ${id}-searchDescription`
|
|
117
118
|
: `${id}-inputDescription`;
|
|
118
119
|
}, [id]);
|
|
119
|
-
return (_jsxs(Flex, { as: StyledMultiSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, container: { alignItems: 'center' }, ...{
|
|
120
|
+
return (_jsxs(Flex, { as: StyledMultiSelectInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, container: { alignItems: 'center', justify: 'between' }, ...{
|
|
120
121
|
readOnly,
|
|
121
122
|
disabled,
|
|
122
123
|
status
|
|
123
|
-
}, children: [selected.length > 0 && (_jsx(Flex, { ref: listRef, id: id, as: 'ul', role: 'listbox', container: { alignItems: 'center', wrap: 'wrap' }, "aria-label": t('selected_items'), children: selected.map((element, idx) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
}, children: [_jsxs(Flex, { container: { wrap: 'wrap' }, item: { grow: 1 }, children: [selected.length > 0 && (_jsx(Flex, { ref: listRef, id: id, as: 'ul', role: 'listbox', container: { alignItems: 'center', wrap: 'wrap' }, "aria-label": t('selected_items'), children: selected.map((element, idx) => {
|
|
125
|
+
return (_jsx(Selectable, { as: 'li', role: 'option', id: element.id.toString(), status: status, onClick: e => {
|
|
126
|
+
const mouseClick = e.detail !== 0;
|
|
127
|
+
if (!readOnly && !disabled && !mouseClick) {
|
|
128
|
+
handleSelectedRemoval(element.id, idx);
|
|
129
|
+
}
|
|
130
|
+
}, onRemove: () => {
|
|
131
|
+
if (!readOnly && !disabled) {
|
|
132
|
+
handleSelectedRemoval(element.id, idx);
|
|
133
|
+
}
|
|
134
|
+
}, onKeyDown: (e) => {
|
|
135
|
+
// prevent browser's Back on FF
|
|
136
|
+
if (e.key === 'Backspace')
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
}, tabIndex: '-1', "aria-label": `${t('remove')} ${element.text}`, "aria-describedby": ariaDescribedBy, children: element.text }, element.id));
|
|
139
|
+
}) })), _jsx(Flex, { item: { grow: 1, basis: xsContentWidth }, children: _jsx("input", { size: 5, ref: inputRef, value: value,
|
|
140
|
+
// no-op avoids react uncontrolled warning
|
|
141
|
+
onChange: onChange || (() => { }), onKeyDown: onInputKeyDown, readOnly: readOnly || !onChange, disabled: disabled, placeholder: selected?.length ? undefined : placeholder, autoComplete: 'off',
|
|
142
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
143
|
+
autoFocus: autoFocus, "aria-controls": !pauseDescendantEvaluation ? id : ariaControls, ...restProps }) })] }), actions, _jsx(VisuallyHiddenText, { id: `${id}-inputDescription`, children: `${t('combobox_open_close')} ` }), _jsx(VisuallyHiddenText, { id: `${id}-searchDescription`, children: t('combobox_search_instructions') })] }));
|
|
143
144
|
});
|
|
144
145
|
export default MultiSelectInput;
|
|
145
146
|
//# sourceMappingURL=MultiSelectInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,OAAO,EACP,MAAM,EACP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5E,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;IAC/D,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAA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AAS,GACb,GACG,EACN,OAAO,EAER,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,mBAAmB,YAC7C,GAAG,CAAC,CAAC,qBAAqB,CAAC,GAAG,GACZ,EACrB,KAAC,kBAAkB,IAAC,EAAE,EAAE,GAAG,EAAE,oBAAoB,YAC9C,CAAC,CAAC,8BAA8B,CAAC,GACf,IAChB,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import {\n FunctionComponent,\n forwardRef,\n Ref,\n PropsWithoutRef,\n KeyboardEvent,\n useRef,\n useCallback,\n useMemo,\n useState,\n useEffect\n} from 'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport { ForwardProps } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport Selectable, { StyledSelectable } from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport {\n useConsolidatedRef,\n useActiveDescendant,\n useDirection,\n useI18n,\n useUID\n} from '../../../hooks';\nimport { cap, tryCatch } from '../../../utils';\nimport { StyledBareButton } from '../../Button/BareButton';\nimport VisuallyHiddenText from '../../VisuallyHiddenText';\nimport { StyledSelectInput } from '../ComboBox.styles';\n\nimport { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {\n const { background } = theme.components.badges.selectable.base;\n const { 'foreground-color': foreground } = theme.base.palette;\n const boxShadowColor = tryCatch(() => transparentize(0.45, foreground));\n\n return css`\n ul {\n list-style: none;\n\n &[data-active-scope='true'] ${StyledSelectable}[data-current='true'] {\n color: ${theme.base.palette.interactive};\n box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};\n outline: none;\n\n ${StyledBareButton} {\n color: ${theme.base.palette.interactive};\n }\n }\n }\n\n ${StyledSelectable} {\n margin: calc(0.25 * ${theme.base.spacing});\n }\n `;\n});\nStyledMultiSelectInput.defaultProps = defaultThemeProp;\n\nconst MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MultiSelectInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n selected = [],\n value,\n onRemove,\n onChange,\n onKeyDown,\n onResolveSuggestion,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n pauseDescendantEvaluation,\n onSelectedFocus,\n onSelectedBlur,\n 'aria-controls': ariaControls,\n ...restProps\n } = props;\n const t = useI18n();\n const id = useUID();\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [activeItemId, setActiveItemId] = useState<string | null>(null);\n const { start, end } = useDirection();\n\n const uadConfig = useMemo(\n () => ({\n focusEl: inputRef.current,\n scope: listRef.current,\n selector: 'li[role=\"option\"]',\n orientation: 'horizontal' as const,\n focusDescendantEl: focusDescendant,\n clearFocusDescendant: () => {\n setFocusDescendant(null);\n },\n pauseDescendantEvaluation,\n onClick: (el: HTMLElement) => {\n el.click();\n }\n }),\n [pauseDescendantEvaluation, selected, focusDescendant]\n );\n\n const { activeDescendant } = useActiveDescendant(uadConfig, [\n pauseDescendantEvaluation,\n selected\n ]);\n\n const handleSelectedRemoval = useCallback(\n (selectionId, idx) => {\n if (!pauseDescendantEvaluation && idx === selected.length - 1) {\n if (selected.length > 1) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] as HTMLElement) ||\n null\n );\n } else {\n onSelectedBlur?.();\n }\n }\n onRemove?.(selectionId, idx);\n inputRef.current?.focus();\n },\n [selected, onRemove, onSelectedBlur, uadConfig]\n );\n\n useEffect(() => {\n // Maintain active item & prev. val only as it changes.\n if (activeDescendant?.id && activeDescendant.id !== activeItemId) {\n setActiveItemId(activeDescendant.id);\n }\n }, [activeDescendant]);\n\n const onInputKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (selected.length && inputRef.current?.selectionStart === 0) {\n const lastIndex = selected.length - 1;\n if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] as HTMLElement) ||\n null\n );\n onSelectedFocus?.();\n }\n\n const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]\n ?.id;\n const onLastItem = activeItemId === lastSelectableId;\n\n if (\n !pauseDescendantEvaluation &&\n ((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')\n ) {\n onSelectedBlur?.();\n }\n\n if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {\n handleSelectedRemoval(selected[lastIndex].id, lastIndex);\n }\n }\n onKeyDown?.(e);\n },\n [\n pauseDescendantEvaluation,\n activeItemId,\n onKeyDown,\n handleSelectedRemoval,\n selected,\n readOnly,\n disabled\n ]\n );\n\n const ariaDescribedBy = useMemo(() => {\n return onChange\n ? `${id}-inputDescription ${id}-searchDescription`\n : `${id}-inputDescription`;\n }, [id]);\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center' }}\n {...{\n readOnly,\n disabled,\n status\n }}\n >\n {selected.length > 0 && (\n <Flex\n ref={listRef}\n id={id}\n as='ul'\n role='listbox'\n container={{ alignItems: 'center', wrap: 'wrap' }}\n aria-label={t('selected_items')}\n >\n {selected.map((element, idx) => {\n return (\n <Selectable\n as='li'\n key={element.id}\n role='option'\n id={element.id.toString()}\n status={status}\n onClick={e => {\n const mouseClick = e.detail !== 0;\n\n if (!readOnly && !disabled && !mouseClick) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onRemove={() => {\n if (!readOnly && !disabled) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onKeyDown={(e: KeyboardEvent<Element>) => {\n // prevent browser's Back on FF\n if (e.key === 'Backspace') e.preventDefault();\n }}\n tabIndex='-1'\n aria-label={`${t('remove')} ${element.text}`}\n aria-describedby={ariaDescribedBy}\n >\n {element.text}\n </Selectable>\n );\n })}\n </Flex>\n )}\n <Flex item={{ grow: 1 }} container>\n <input\n size={5}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onInputKeyDown}\n readOnly={readOnly || !onChange}\n disabled={disabled}\n placeholder={selected?.length ? undefined : placeholder}\n autoComplete='off'\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n aria-controls={!pauseDescendantEvaluation ? id : ariaControls}\n {...restProps}\n />\n </Flex>\n {actions}\n\n <VisuallyHiddenText id={`${id}-inputDescription`}>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`}>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n </Flex>\n );\n }\n);\n\nexport default MultiSelectInput;\n"]}
|
|
1
|
+
{"version":3,"file":"MultiSelectInput.js","sourceRoot":"","sources":["../../../../src/components/ComboBox/MultiSelectInput/MultiSelectInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,UAAU,EAIV,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,YAA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'react';\nimport styled, { css } from 'styled-components';\nimport { transparentize } from 'polished';\n\nimport { ForwardProps } from '../../../types';\nimport { defaultThemeProp } from '../../../theme';\nimport Selectable, { StyledSelectable } from '../../Badges/Selection';\nimport { StyledFormControl } from '../../FormControl';\nimport Flex from '../../Flex';\nimport {\n useConsolidatedRef,\n useActiveDescendant,\n useDirection,\n useI18n,\n useUID,\n useTheme\n} from '../../../hooks';\nimport { cap, tryCatch } from '../../../utils';\nimport { StyledBareButton } from '../../Button/BareButton';\nimport VisuallyHiddenText from '../../VisuallyHiddenText';\nimport { StyledSelectInput } from '../ComboBox.styles';\n\nimport { MultiSelectInputProps } from './MultiSelectInput.types';\n\nexport const StyledMultiSelectInput = styled(StyledSelectInput)(({ theme }) => {\n const { background } = theme.components.badges.selectable.base;\n const { 'foreground-color': foreground } = theme.base.palette;\n const boxShadowColor = tryCatch(() => transparentize(0.45, foreground));\n\n return css`\n ul {\n list-style: none;\n\n &[data-active-scope='true'] ${StyledSelectable}[data-current='true'] {\n color: ${theme.base.palette.interactive};\n box-shadow: 0 0 0.5rem -0.125rem ${boxShadowColor}, inset 0 0 0 0.125rem ${background};\n outline: none;\n\n ${StyledBareButton} {\n color: ${theme.base.palette.interactive};\n }\n }\n }\n\n ${StyledSelectable} {\n margin: calc(0.25 * ${theme.base.spacing});\n }\n `;\n});\nStyledMultiSelectInput.defaultProps = defaultThemeProp;\n\nconst MultiSelectInput: FunctionComponent<MultiSelectInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<MultiSelectInputProps>, ref: Ref<HTMLInputElement>) => {\n const {\n selected = [],\n value,\n onRemove,\n onChange,\n onKeyDown,\n onResolveSuggestion,\n actions,\n readOnly,\n disabled,\n status,\n placeholder,\n autoFocus,\n pauseDescendantEvaluation,\n onSelectedFocus,\n onSelectedBlur,\n 'aria-controls': ariaControls,\n ...restProps\n } = props;\n const t = useI18n();\n const id = useUID();\n const {\n base: {\n 'content-width': { xs: xsContentWidth }\n }\n } = useTheme();\n const inputRef = useConsolidatedRef<HTMLInputElement>(ref);\n const listRef = useRef<HTMLUListElement>(null);\n const [focusDescendant, setFocusDescendant] = useState<HTMLElement | null>(null);\n const [activeItemId, setActiveItemId] = useState<string | null>(null);\n const { start, end } = useDirection();\n\n const uadConfig = useMemo(\n () => ({\n focusEl: inputRef.current,\n scope: listRef.current,\n selector: 'li[role=\"option\"]',\n orientation: 'horizontal' as const,\n focusDescendantEl: focusDescendant,\n clearFocusDescendant: () => {\n setFocusDescendant(null);\n },\n pauseDescendantEvaluation,\n onClick: (el: HTMLElement) => {\n el.click();\n }\n }),\n [pauseDescendantEvaluation, selected, focusDescendant]\n );\n\n const { activeDescendant } = useActiveDescendant(uadConfig, [\n pauseDescendantEvaluation,\n selected\n ]);\n\n const handleSelectedRemoval = useCallback(\n (selectionId, idx) => {\n if (!pauseDescendantEvaluation && idx === selected.length - 1) {\n if (selected.length > 1) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[idx - 1] as HTMLElement) ||\n null\n );\n } else {\n onSelectedBlur?.();\n }\n }\n onRemove?.(selectionId, idx);\n inputRef.current?.focus();\n },\n [selected, onRemove, onSelectedBlur, uadConfig]\n );\n\n useEffect(() => {\n // Maintain active item & prev. val only as it changes.\n if (activeDescendant?.id && activeDescendant.id !== activeItemId) {\n setActiveItemId(activeDescendant.id);\n }\n }, [activeDescendant]);\n\n const onInputKeyDown = useCallback(\n (e: KeyboardEvent<HTMLInputElement>) => {\n if (selected.length && inputRef.current?.selectionStart === 0) {\n const lastIndex = selected.length - 1;\n if (pauseDescendantEvaluation && e.key === `Arrow${cap(start)}`) {\n setFocusDescendant(\n (listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex] as HTMLElement) ||\n null\n );\n onSelectedFocus?.();\n }\n\n const lastSelectableId = listRef.current?.querySelectorAll(uadConfig.selector)[lastIndex]\n ?.id;\n const onLastItem = activeItemId === lastSelectableId;\n\n if (\n !pauseDescendantEvaluation &&\n ((onLastItem && e.key === `Arrow${cap(end)}`) || e.key === 'ArrowDown')\n ) {\n onSelectedBlur?.();\n }\n\n if (['Backspace', 'Delete'].includes(e.key) && !(readOnly || disabled)) {\n handleSelectedRemoval(selected[lastIndex].id, lastIndex);\n }\n }\n onKeyDown?.(e);\n },\n [\n pauseDescendantEvaluation,\n activeItemId,\n onKeyDown,\n handleSelectedRemoval,\n selected,\n readOnly,\n disabled\n ]\n );\n\n const ariaDescribedBy = useMemo(() => {\n return onChange\n ? `${id}-inputDescription ${id}-searchDescription`\n : `${id}-inputDescription`;\n }, [id]);\n\n return (\n <Flex\n as={StyledMultiSelectInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center', justify: 'between' }}\n {...{\n readOnly,\n disabled,\n status\n }}\n >\n <Flex container={{ wrap: 'wrap' }} item={{ grow: 1 }}>\n {selected.length > 0 && (\n <Flex\n ref={listRef}\n id={id}\n as='ul'\n role='listbox'\n container={{ alignItems: 'center', wrap: 'wrap' }}\n aria-label={t('selected_items')}\n >\n {selected.map((element, idx) => {\n return (\n <Selectable\n as='li'\n key={element.id}\n role='option'\n id={element.id.toString()}\n status={status}\n onClick={e => {\n const mouseClick = e.detail !== 0;\n\n if (!readOnly && !disabled && !mouseClick) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onRemove={() => {\n if (!readOnly && !disabled) {\n handleSelectedRemoval(element.id, idx);\n }\n }}\n onKeyDown={(e: KeyboardEvent<Element>) => {\n // prevent browser's Back on FF\n if (e.key === 'Backspace') e.preventDefault();\n }}\n tabIndex='-1'\n aria-label={`${t('remove')} ${element.text}`}\n aria-describedby={ariaDescribedBy}\n >\n {element.text}\n </Selectable>\n );\n })}\n </Flex>\n )}\n <Flex item={{ grow: 1, basis: xsContentWidth }}>\n <input\n size={5}\n ref={inputRef}\n value={value}\n // no-op avoids react uncontrolled warning\n onChange={onChange || (() => {})}\n onKeyDown={onInputKeyDown}\n readOnly={readOnly || !onChange}\n disabled={disabled}\n placeholder={selected?.length ? undefined : placeholder}\n autoComplete='off'\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n aria-controls={!pauseDescendantEvaluation ? id : ariaControls}\n {...restProps}\n />\n </Flex>\n </Flex>\n {actions}\n\n <VisuallyHiddenText id={`${id}-inputDescription`}>\n {`${t('combobox_open_close')} `}\n </VisuallyHiddenText>\n <VisuallyHiddenText id={`${id}-searchDescription`}>\n {t('combobox_search_instructions')}\n </VisuallyHiddenText>\n </Flex>\n );\n }\n);\n\nexport default MultiSelectInput;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NoChildrenProp, OmitStrict } from '../../types';
|
|
2
|
-
import NumberInputProps from '../Number/NumberInput.types';
|
|
2
|
+
import type { NumberInputProps } from '../Number/NumberInput.types';
|
|
3
3
|
export default interface CurrencyInputProps extends OmitStrict<NumberInputProps, 'numberOfDecimals'>, NoChildrenProp {
|
|
4
4
|
/** Callback fired when the component gets focus */
|
|
5
5
|
onFocus?: (value: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"CurrencyInput.types.d.ts","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,MAAM,CAAC,OAAO,WAAW,kBACvB,SAAQ,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,EACtD,cAAc;IAChB,mDAAmD;IACnD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,qDAAqD;IACrD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,6GAA6G;IAC7G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;SAEK;IACL,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyInput.types.js","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NoChildrenProp, OmitStrict } from '../../types';\nimport NumberInputProps from '../Number/NumberInput.types';\n\nexport default interface CurrencyInputProps\n extends OmitStrict<NumberInputProps, 'numberOfDecimals'>,\n NoChildrenProp {\n /** Callback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: string) => void;\n /** Three letter currency shorthand ISO code. If not provided or invalid, component renders as NumberInput */\n currencyISOCode?: string;\n /** Always show ISO code\n * @default false\n * */\n alwaysShowISOCode?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CurrencyInput.types.js","sourceRoot":"","sources":["../../../src/components/Currency/CurrencyInput.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NoChildrenProp, OmitStrict } from '../../types';\nimport type { NumberInputProps } from '../Number/NumberInput.types';\n\nexport default interface CurrencyInputProps\n extends OmitStrict<NumberInputProps, 'numberOfDecimals'>,\n NoChildrenProp {\n /** Callback fired when the component gets focus */\n onFocus?: (value: string) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: string) => void;\n /** Three letter currency shorthand ISO code. If not provided or invalid, component renders as NumberInput */\n currencyISOCode?: string;\n /** Always show ISO code\n * @default false\n * */\n alwaysShowISOCode?: boolean;\n}\n"]}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { NoChildrenProp } from '../../types';
|
|
2
2
|
import { FormControlProps } from '../FormControl';
|
|
3
3
|
export interface DateTimeProperties {
|
|
4
|
-
/**
|
|
5
|
-
* Date as ISO8601 string, timestamp or native Date object.
|
|
6
|
-
* Requires onChange prop to update value for controlled inputs.
|
|
7
|
-
*/
|
|
8
|
-
value?: string | number | Date;
|
|
9
|
-
/**
|
|
10
|
-
* Date as ISO8601 string, timestamp or native Date object. Sets the value for an uncontrolled input.
|
|
11
|
-
*/
|
|
12
|
-
defaultValue?: string | number | Date;
|
|
13
4
|
/** Date as ISO8601 string, timestamp or native Date object. Defines minimum available value that can be set by the user. */
|
|
14
5
|
min?: string | number | Date;
|
|
15
6
|
/** Date as ISO8601 string, timestamp or native Date object. Defines maximum available value that can be set by the user. */
|
|
@@ -55,7 +46,20 @@ export interface DateTimeCallbacks {
|
|
|
55
46
|
onResolveSuggestion?: FormControlProps['onResolveSuggestion'];
|
|
56
47
|
}
|
|
57
48
|
export default interface DateTimeProps extends DateTimeProperties, DateTimeCallbacks, NoChildrenProp {
|
|
49
|
+
/**
|
|
50
|
+
* Date as ISO8601 string, timestamp or native Date object.
|
|
51
|
+
* Requires onChange prop to update value for controlled inputs.
|
|
52
|
+
*/
|
|
53
|
+
value?: string | number | Date;
|
|
54
|
+
/**
|
|
55
|
+
* Date as ISO8601 string, timestamp or native Date object. Sets the value for an uncontrolled input.
|
|
56
|
+
*/
|
|
57
|
+
defaultValue?: string | number | Date;
|
|
58
58
|
}
|
|
59
|
+
export declare type DateRangeCallbackParameter = {
|
|
60
|
+
start: DateTimeCallbackParameter;
|
|
61
|
+
end: DateTimeCallbackParameter;
|
|
62
|
+
};
|
|
59
63
|
export declare type AbsoluteVariant = 'date' | 'datetime' | 'time' | 'week' | 'month' | 'year' | 'monthyear' | 'quarteryear';
|
|
60
64
|
export declare type DateTimeVariant = AbsoluteVariant | 'relative';
|
|
61
65
|
export declare type DateTimeFormat = 'short' | 'long' | 'numeric';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTime.types.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC
|
|
1
|
+
{"version":3,"file":"DateTime.types.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,4HAA4H;IAC5H,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7B,4HAA4H;IAC5H,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,EAAE,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC5B,oDAAoD;IACpD,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,uCAAuC;IACvC,WAAW,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAC9C,6GAA6G;IAC7G,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACxC,+FAA+F;IAC/F,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,iDAAiD;I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oot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties {\n
|
|
1
|
+
{"version":3,"file":"DateTime.types.js","sourceRoot":"","sources":["../../../src/components/DateTime/DateTime.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NoChildrenProp } from '../../types';\nimport { FormControlProps } from '../FormControl';\n\nexport interface DateTimeProperties {\n /** Date as ISO8601 string, timestamp or native Date object. Defines minimum available value that can be set by the user. */\n min?: string | number | Date;\n /** Date as ISO8601 string, timestamp or native Date object. Defines maximum available value that can be set by the user. */\n max?: string | number | Date;\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /** Set visual state based on a validation state. */\n status?: FormControlProps['status'];\n /** Pass a string or a fragment with an Icon and string. */\n label?: FormControlProps['label'];\n /** Visually hides the label region. */\n labelHidden?: FormControlProps['labelHidden'];\n /** It is recommended to pass a simple string to offer guidance. Text will be styled based on status prop. */\n info?: FormControlProps['info'];\n /** Indicate if the field is required. The browser defaults to false. */\n required?: FormControlProps['required'];\n /** Disable the control. The browser defaults to false. */\n disabled?: FormControlProps['disabled'];\n /** Makes the input non editable and non clickable. The browser defaults to false. */\n readOnly?: FormControlProps['readOnly'];\n /** Sets html name attribute for the underlying control. Useful for mapping to a data field. */\n name?: FormControlProps['name'];\n /** Automatically focuses the input on render. */\n autoFocus?: boolean;\n}\n\nexport type DateTimeValueErrorState = 'incomplete' | 'invalid';\n\nexport type DateTimeCallbackParameter = {\n valueAsISOString: string;\n valueAsTimestamp: number | undefined;\n state?: DateTimeValueErrorState;\n};\n\nexport interface DateTimeCallbacks {\n /** Callback fired when input value changes. */\n onChange?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component gets focused. */\n onFocus?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when the component loses focus. */\n onBlur?: (value: DateTimeCallbackParameter) => void;\n /** Callback fired when AI suggestion is accepted/rejected */\n onResolveSuggestion?: FormControlProps['onResolveSuggestion'];\n}\n\nexport default interface DateTimeProps\n extends DateTimeProperties,\n DateTimeCallbacks,\n NoChildrenProp {\n /**\n * Date as ISO8601 string, timestamp or native Date object.\n * Requires onChange prop to update value for controlled inputs.\n */\n value?: string | number | Date;\n /**\n * Date as ISO8601 string, timestamp or native Date object. Sets the value for an uncontrolled input.\n */\n defaultValue?: string | number | Date;\n}\n\nexport type DateRangeCallbackParameter = {\n start: DateTimeCallbackParameter;\n end: DateTimeCallbackParameter;\n};\n\nexport type AbsoluteVariant =\n | 'date'\n | 'datetime'\n | 'time'\n | 'week'\n | 'month'\n | 'year'\n | 'monthyear'\n | 'quarteryear';\nexport type DateTimeVariant = AbsoluteVariant | 'relative';\nexport type DateTimeFormat = 'short' | 'long' | 'numeric';\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FunctionComponent,
|
|
1
|
+
import { FunctionComponent, Dispatch, SetStateAction, ComponentType } from 'react';
|
|
2
2
|
import { ForwardProps } from '../../../types';
|
|
3
|
+
import type DatePickerProps from '../Picker/DatePicker.types';
|
|
3
4
|
import { FormControlProps } from '../../FormControl';
|
|
4
5
|
import DateTimeProps from '../DateTime.types';
|
|
5
6
|
export interface DateInputProps extends DateTimeProps {
|
|
@@ -9,7 +10,10 @@ export interface DateInputProps extends DateTimeProps {
|
|
|
9
10
|
*/
|
|
10
11
|
showWeekNumber?: boolean;
|
|
11
12
|
/** Changes default date picker */
|
|
12
|
-
picker?:
|
|
13
|
+
picker?: {
|
|
14
|
+
renderer: ComponentType;
|
|
15
|
+
rendererProps?: Partial<DatePickerProps> & ForwardProps;
|
|
16
|
+
};
|
|
13
17
|
/** Pass a heading and content to show additional information on the field. */
|
|
14
18
|
additionalInfo?: FormControlProps['additionalInfo'];
|
|
15
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAMjB,
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAMjB,QAAQ,EACR,cAAc,EAGd,aAAa,EACd,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,OAAO,KAAK,eAAe,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAqB,MAAM,mBAAmB,CAAC;AACxE,OAAO,aAA4C,MAAM,mBAAmB,CAAC;AAgB7E,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kCAAkC;IAClC,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE,aAAa,CAAC;QACxB,aAAa,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,YAAY,CAAC;KACzD,CAAC;IACF,8EAA8E;IAC9E,cAAc,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,eAAe,qHAE3B,CAAC;AAsCF,QAAA,MAAM,SAAS,EAAE,iBAAiB,CAAC,cAAc,GAAG,YAAY,CA8R/D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -52,7 +52,7 @@ const convertToCallbackParameter = (date, parts) => {
|
|
|
52
52
|
};
|
|
53
53
|
const DateInput = forwardRef((props, ref) => {
|
|
54
54
|
const { locale } = useConfiguration();
|
|
55
|
-
const { defaultValue, value = defaultValue, min, max, id, label, labelHidden, info = getDateFormat(locale).join(''), status, required, readOnly, disabled, onChange, onFocus, onBlur, onResolveSuggestion, showWeekNumber, picker, autoFocus, additionalInfo, ...restProps } = props;
|
|
55
|
+
const { defaultValue, value = defaultValue, min, max, id, label, labelHidden, info = getDateFormat(locale).join(''), status, required, readOnly, disabled, onChange, onFocus, onBlur, onResolveSuggestion, showWeekNumber, picker: { renderer: PickerComp = DatePicker, rendererProps = {} } = {}, autoFocus, additionalInfo, ...restProps } = props;
|
|
56
56
|
const t = useI18n();
|
|
57
57
|
const date = value !== undefined ? parseToDate(value) : undefined;
|
|
58
58
|
const [yearInputRef, monthInputRef, dayInputRef] = [
|
|
@@ -79,6 +79,7 @@ const DateInput = forwardRef((props, ref) => {
|
|
|
79
79
|
: undefined;
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
+
const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();
|
|
82
83
|
const inputContainerRef = useRef(null);
|
|
83
84
|
const onFocusChange = (focused) => {
|
|
84
85
|
const callbackParam = convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts());
|
|
@@ -88,9 +89,9 @@ const DateInput = forwardRef((props, ref) => {
|
|
|
88
89
|
if (inputContainerRef.current)
|
|
89
90
|
inputContainerRef.current.scrollTop = 0;
|
|
90
91
|
onBlur?.(callbackParam);
|
|
92
|
+
setOpen(false);
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
|
-
const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();
|
|
94
95
|
const onInputChange = () => {
|
|
95
96
|
onChange?.(convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts()));
|
|
96
97
|
buttonEl?.setAttribute('aria-label', generatePickerButtonAriaLabel(currentlySelectedDate(), 'date', locale, t, open));
|
|
@@ -122,20 +123,20 @@ const DateInput = forwardRef((props, ref) => {
|
|
|
122
123
|
return currentlySelectedDate();
|
|
123
124
|
}
|
|
124
125
|
}));
|
|
125
|
-
const
|
|
126
|
-
setInputValue(selected);
|
|
127
|
-
setOpen(false);
|
|
128
|
-
setTimeout(() => buttonEl?.focus());
|
|
129
|
-
onInputChange();
|
|
130
|
-
}, min: min, max: max, showWeekNumber: showWeekNumber }));
|
|
131
|
-
const PickerButton = (_jsxs(_Fragment, { children: [_jsx(Button, { variant: 'simple', icon: true, ref: setButtonEl, onClick: () => setOpen(cur => !cur), "aria-label": generatePickerButtonAriaLabel(currentlySelectedDate(), 'date', locale, t, open), readOnly: readOnly, disabled: disabled, children: _jsx(Icon, { name: open ? 'times' : 'calendar' }) }), _jsx(Popover, { show: open, ref: setPopoverRef, target: buttonEl, placement: 'bottom-end', strategy: 'fixed', modifiers: [
|
|
126
|
+
const PickerButton = (_jsxs(_Fragment, { children: [_jsx(Button, { variant: 'simple', icon: true, ref: setButtonEl, onClick: () => setOpen(cur => !cur), "aria-label": generatePickerButtonAriaLabel(currentlySelectedDate(), 'date', locale, t, open), readOnly: readOnly, disabled: disabled, children: _jsx(Icon, { name: open ? 'times' : 'calendar' }) }), open && (_jsx(Popover, { ref: setPopoverRef, target: buttonEl, placement: 'bottom-end', strategy: 'fixed', modifiers: [
|
|
132
127
|
{
|
|
133
128
|
name: 'flip',
|
|
134
129
|
options: {
|
|
135
130
|
fallbackPlacements: ['top-end', 'right', 'left']
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
|
-
], children:
|
|
133
|
+
], children: _jsx(PickerComp, { selected: currentlySelectedDate(), min: min, max: max, showWeekNumber: showWeekNumber, ...rendererProps, onChange: selected => {
|
|
134
|
+
setInputValue(selected);
|
|
135
|
+
setOpen(false);
|
|
136
|
+
setTimeout(() => buttonEl?.focus());
|
|
137
|
+
onInputChange();
|
|
138
|
+
rendererProps?.onChange?.(selected);
|
|
139
|
+
} }) }))] }));
|
|
139
140
|
const orderedRefs = [];
|
|
140
141
|
const Comp = (_jsxs(Flex, { as: StyledDateInput, forwardedAs: StyledFormControl, hasSuggestion: status === 'pending' && !!onResolveSuggestion, container: { alignItems: 'center', wrap: 'nowrap' }, status: status, readOnly: readOnly, disabled: disabled, ref: containerRef, onClick: (e) => {
|
|
141
142
|
if (e.target === containerRef.current)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,MAAM,EAKN,mBAAmB,EACnB,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,UAAU,MAAM,sBAAsB,CAAC;AAC9C,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAoB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,cAAc,EAAE,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD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B,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,IACR,EAAE,EAAC,UAAU,qBACI,EAAE,EACnB,OAAO,EAAC,QAAQ,KACZ;YACF,KAAK;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,mBAAmB;YACnB,cAAc;SACf,EACD,GAAG,EAAE,GAAG,YAEP,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n ClipboardEvent,\n FunctionComponent,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useRef,\n RefObject,\n ReactNode,\n Dispatch,\n SetStateAction,\n useImperativeHandle,\n useEffect\n} from 'react';\nimport styled from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport { useConfiguration, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport FormField from '../../FormField';\nimport Flex from '../../Flex';\nimport Button from '../../Button';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as timesIcon from '../../Icon/icons/times.icon';\nimport * as calendarIcon from '../../Icon/icons/calendar.icon';\nimport DatePicker from '../Picker/DatePicker';\nimport Popover from '../../Popover';\nimport { FormControlProps, StyledFormControl } from '../../FormControl';\nimport DateTimeProps, { DateTimeCallbackParameter } from '../DateTime.types';\n\nimport {\n getDateFormat,\n parsePastedTextToDate,\n parseToDate,\n validateDate,\n generatePickerButtonAriaLabel\n} from './utils';\nimport StyledDateTime, { StyledInputContainer } from './DateTime.styles';\nimport useAutoFocusNextInput from './useAutoFocusNextInput';\nimport PartInput from './PartInput';\nimport usePickerButton from './usePickerButton';\n\nregisterIcon(timesIcon, calendarIcon);\n\nexport interface DateInputProps extends DateTimeProps {\n /**\n * Display additional column with week number in date picker popover.\n * @default false\n */\n showWeekNumber?: boolean;\n /** Changes default date picker */\n picker?: ReactNode;\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n}\n\nexport interface DateInputRefObject {\n readonly value: Date | undefined;\n setOpen: Dispatch<SetStateAction<boolean>>;\n buttonEl: HTMLElement | null;\n}\n\nexport const StyledDateInput = styled(StyledDateTime)<DateInputProps>`\n padding-inline-end: 0;\n`;\n\nStyledDateInput.defaultProps = defaultThemeProp;\n\nconst convertToCallbackParameter = (\n date: Date,\n parts: (string | undefined)[]\n): DateTimeCallbackParameter => {\n if (parts.every(Boolean)) {\n const [year, monthIndex, day] = parts.map(Number);\n\n if (!validateDate(year, monthIndex + 1, day)) {\n return {\n valueAsISOString: '',\n valueAsTimestamp: NaN,\n state: 'invalid'\n };\n }\n\n date.setUTCFullYear(year, monthIndex, day);\n return {\n valueAsISOString: date.toISOString(),\n valueAsTimestamp: date.getTime()\n };\n }\n if (parts.every(p => !p)) {\n return {\n valueAsISOString: '',\n valueAsTimestamp: undefined\n };\n }\n return {\n valueAsISOString: '',\n valueAsTimestamp: NaN,\n state: 'incomplete'\n };\n};\n\nconst DateInput: FunctionComponent<DateInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<DateInputProps>, ref: Ref<DateInputRefObject>) => {\n const { locale } = useConfiguration();\n const {\n defaultValue,\n value = defaultValue,\n min,\n max,\n id,\n label,\n labelHidden,\n info = getDateFormat(locale).join(''),\n status,\n required,\n readOnly,\n disabled,\n onChange,\n onFocus,\n onBlur,\n onResolveSuggestion,\n showWeekNumber,\n picker,\n autoFocus,\n additionalInfo,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const date = value !== undefined ? parseToDate(value) : undefined;\n\n const [yearInputRef, monthInputRef, dayInputRef] = [\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null)\n ];\n\n const pickParts = () => {\n const month = monthInputRef.current?.value\n ? (Number(monthInputRef.current.value) - 1).toString()\n : undefined;\n return [\n yearInputRef.current?.value || undefined,\n month,\n dayInputRef.current?.value || undefined\n ];\n };\n\n const currentlySelectedDate = () => {\n const parts = pickParts();\n if (parts.every(Boolean)) {\n const [year, monthIndex, day] = parts.map(Number);\n\n return validateDate(year, monthIndex + 1, day)\n ? new Date(Date.UTC(year, monthIndex, day))\n : undefined;\n }\n };\n\n const inputContainerRef = useRef<HTMLDivElement>(null);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(\n date ? new Date(date) : new Date(),\n pickParts()\n );\n if (onFocus && focused) onFocus(callbackParam);\n if (!focused) {\n if (inputContainerRef.current) inputContainerRef.current.scrollTop = 0;\n onBlur?.(callbackParam);\n }\n };\n\n const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();\n\n const onInputChange = () => {\n onChange?.(convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts()));\n buttonEl?.setAttribute(\n 'aria-label',\n generatePickerButtonAriaLabel(currentlySelectedDate(), 'date', locale, t, open)\n );\n };\n\n const setInputValue = (newValue: Date) => {\n dayInputRef.current!.value = newValue.getUTCDate().toString().padStart(2, '0');\n monthInputRef.current!.value = (newValue.getUTCMonth() + 1).toString().padStart(2, '0');\n yearInputRef.current!.value = newValue.getUTCFullYear().toString();\n };\n\n const onPaste = (e: ClipboardEvent) => {\n const text = e.clipboardData.getData('text');\n const newDate = parsePastedTextToDate(text, locale, date || new Date());\n if (newDate) {\n e.preventDefault();\n setInputValue(newDate);\n onInputChange();\n }\n };\n\n const displayNames = new Intl.DisplayNames(locale, { style: 'long', type: 'dateTimeField' });\n\n const DayInput = (\n <PartInput\n key='day'\n placeholder={t('day_placeholder')}\n aria-label={displayNames.of('day')}\n value={date?.getUTCDate()}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n readOnly={readOnly}\n min={1}\n max={31}\n ref={dayInputRef}\n />\n );\n\n const MonthInput = (\n <PartInput\n key='month'\n placeholder={t('month_placeholder')}\n aria-label={displayNames.of('month')}\n value={date ? date?.getUTCMonth() + 1 : undefined}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n readOnly={readOnly}\n min={1}\n max={12}\n ref={monthInputRef}\n />\n );\n\n const YearInput = (\n <PartInput\n key='year'\n placeholder={t('year_placeholder')}\n aria-label={displayNames.of('year')}\n value={date?.getUTCFullYear()}\n onChange={onInputChange}\n size={4}\n maxLength={4}\n readOnly={readOnly}\n min={1}\n ref={yearInputRef}\n />\n );\n\n const containerRef = useRef<HTMLElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n useImperativeHandle(ref, () => ({\n setOpen,\n buttonEl,\n get value() {\n return currentlySelectedDate();\n }\n }));\n\n const Picker = (\n <DatePicker\n selected={currentlySelectedDate()}\n onChange={selected => {\n setInputValue(selected);\n setOpen(false);\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n }}\n min={min}\n max={max}\n showWeekNumber={showWeekNumber}\n />\n );\n\n const PickerButton = (\n <>\n <Button\n variant='simple'\n icon\n ref={setButtonEl}\n onClick={() => setOpen(cur => !cur)}\n aria-label={generatePickerButtonAriaLabel(\n currentlySelectedDate(),\n 'date',\n locale,\n t,\n open\n )}\n readOnly={readOnly}\n disabled={disabled}\n >\n <Icon name={open ? 'times' : 'calendar'} />\n </Button>\n <Popover\n show={open}\n ref={setPopoverRef}\n target={buttonEl}\n placement='bottom-end'\n strategy='fixed'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-end', 'right', 'left']\n }\n }\n ]}\n >\n {picker || Picker}\n </Popover>\n </>\n );\n\n const orderedRefs: RefObject<HTMLInputElement>[] = [];\n\n const Comp = (\n <Flex\n as={StyledDateInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n ref={containerRef}\n onClick={(e: MouseEvent) => {\n if (e.target === containerRef.current) orderedRefs[0].current?.focus();\n }}\n {...restProps}\n >\n <Flex\n ref={inputContainerRef}\n as={StyledInputContainer}\n container={{ alignItems: 'center', wrap: 'wrap' }}\n onPaste={onPaste}\n >\n {getDateFormat(locale).map(part => {\n switch (part) {\n case 'DD':\n orderedRefs.push(dayInputRef);\n return DayInput;\n case 'MM':\n orderedRefs.push(monthInputRef);\n return MonthInput;\n case 'YYYY':\n orderedRefs.push(yearInputRef);\n return YearInput;\n default:\n return part;\n }\n })}\n </Flex>\n {!readOnly && PickerButton}\n </Flex>\n );\n\n useEffect(() => {\n if (autoFocus) orderedRefs[0].current?.focus();\n }, [autoFocus]);\n\n useAutoFocusNextInput(orderedRefs);\n\n return label ? (\n <FormField\n as='fieldset'\n aria-labelledby={id}\n labelAs='legend'\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n required,\n disabled,\n onResolveSuggestion,\n additionalInfo\n }}\n ref={ref}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default DateInput;\n"]}
|
|
1
|
+
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,UAAU,EAGV,MAAM,EAIN,mBAAmB,EACnB,SAAS,EAEV,MAAM,OAAO,CAAC;AACf,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,UAAU,MAA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BACP,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;4BAC9B,OAAO,QAAQ,CAAC;wBAClB,KAAK,IAAI;4BACP,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;4BAChC,OAAO,UAAU,CAAC;wBACpB,KAAK,MAAM;4BACT,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;4BAC/B,OAAO,SAAS,CAAC;wBACnB;4BACE,OAAO,IAAI,CAAC;qBACf;gBACH,CAAC,CAAC,GACG,EACN,CAAC,QAAQ,IAAI,YAAY,IACrB,CACR,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS;YAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;IACjD,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEnC,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,KAAC,SAAS,IACR,EAAE,EAAC,UAAU,qBACI,EAAE,EACnB,OAAO,EAAC,QAAQ,KACZ;YACF,KAAK;YACL,WAAW;YACX,EAAE;YACF,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,QAAQ;YACR,mBAAmB;YACnB,cAAc;SACf,EACD,GAAG,EAAE,GAAG,YAEP,IAAI,GACK,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CACL,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import {\n ClipboardEvent,\n FunctionComponent,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useRef,\n RefObject,\n Dispatch,\n SetStateAction,\n useImperativeHandle,\n useEffect,\n ComponentType\n} from 'react';\nimport styled from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport { useConfiguration, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport FormField from '../../FormField';\nimport Flex from '../../Flex';\nimport Button from '../../Button';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as timesIcon from '../../Icon/icons/times.icon';\nimport * as calendarIcon from '../../Icon/icons/calendar.icon';\nimport DatePicker from '../Picker/DatePicker';\nimport type DatePickerProps from '../Picker/DatePicker.types';\nimport Popover from '../../Popover';\nimport { FormControlProps, StyledFormControl } from '../../FormControl';\nimport DateTimeProps, { DateTimeCallbackParameter } from '../DateTime.types';\n\nimport {\n getDateFormat,\n parsePastedTextToDate,\n parseToDate,\n validateDate,\n generatePickerButtonAriaLabel\n} from './utils';\nimport StyledDateTime, { StyledInputContainer } from './DateTime.styles';\nimport useAutoFocusNextInput from './useAutoFocusNextInput';\nimport PartInput from './PartInput';\nimport usePickerButton from './usePickerButton';\n\nregisterIcon(timesIcon, calendarIcon);\n\nexport interface DateInputProps extends DateTimeProps {\n /**\n * Display additional column with week number in date picker popover.\n * @default false\n */\n showWeekNumber?: boolean;\n /** Changes default date picker */\n picker?: {\n renderer: ComponentType;\n rendererProps?: Partial<DatePickerProps> & ForwardProps;\n };\n /** Pass a heading and content to show additional information on the field. */\n additionalInfo?: FormControlProps['additionalInfo'];\n}\n\nexport interface DateInputRefObject {\n readonly value: Date | undefined;\n setOpen: Dispatch<SetStateAction<boolean>>;\n buttonEl: HTMLElement | null;\n}\n\nexport const StyledDateInput = styled(StyledDateTime)<DateInputProps>`\n padding-inline-end: 0;\n`;\n\nStyledDateInput.defaultProps = defaultThemeProp;\n\nconst convertToCallbackParameter = (\n date: Date,\n parts: (string | undefined)[]\n): DateTimeCallbackParameter => {\n if (parts.every(Boolean)) {\n const [year, monthIndex, day] = parts.map(Number);\n\n if (!validateDate(year, monthIndex + 1, day)) {\n return {\n valueAsISOString: '',\n valueAsTimestamp: NaN,\n state: 'invalid'\n };\n }\n\n date.setUTCFullYear(year, monthIndex, day);\n return {\n valueAsISOString: date.toISOString(),\n valueAsTimestamp: date.getTime()\n };\n }\n if (parts.every(p => !p)) {\n return {\n valueAsISOString: '',\n valueAsTimestamp: undefined\n };\n }\n return {\n valueAsISOString: '',\n valueAsTimestamp: NaN,\n state: 'incomplete'\n };\n};\n\nconst DateInput: FunctionComponent<DateInputProps & ForwardProps> = forwardRef(\n (props: PropsWithoutRef<DateInputProps>, ref: Ref<DateInputRefObject>) => {\n const { locale } = useConfiguration();\n const {\n defaultValue,\n value = defaultValue,\n min,\n max,\n id,\n label,\n labelHidden,\n info = getDateFormat(locale).join(''),\n status,\n required,\n readOnly,\n disabled,\n onChange,\n onFocus,\n onBlur,\n onResolveSuggestion,\n showWeekNumber,\n picker: { renderer: PickerComp = DatePicker, rendererProps = {} } = {},\n autoFocus,\n additionalInfo,\n ...restProps\n } = props;\n\n const t = useI18n();\n\n const date = value !== undefined ? parseToDate(value) : undefined;\n\n const [yearInputRef, monthInputRef, dayInputRef] = [\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null),\n useRef<HTMLInputElement>(null)\n ];\n\n const pickParts = () => {\n const month = monthInputRef.current?.value\n ? (Number(monthInputRef.current.value) - 1).toString()\n : undefined;\n return [\n yearInputRef.current?.value || undefined,\n month,\n dayInputRef.current?.value || undefined\n ];\n };\n\n const currentlySelectedDate = () => {\n const parts = pickParts();\n if (parts.every(Boolean)) {\n const [year, monthIndex, day] = parts.map(Number);\n\n return validateDate(year, monthIndex + 1, day)\n ? new Date(Date.UTC(year, monthIndex, day))\n : undefined;\n }\n };\n\n const [open, setOpen, , setPopoverRef, buttonEl, setButtonEl] = usePickerButton();\n\n const inputContainerRef = useRef<HTMLDivElement>(null);\n\n const onFocusChange = (focused: boolean) => {\n const callbackParam = convertToCallbackParameter(\n date ? new Date(date) : new Date(),\n pickParts()\n );\n if (onFocus && focused) onFocus(callbackParam);\n if (!focused) {\n if (inputContainerRef.current) inputContainerRef.current.scrollTop = 0;\n onBlur?.(callbackParam);\n setOpen(false);\n }\n };\n\n const onInputChange = () => {\n onChange?.(convertToCallbackParameter(date ? new Date(date) : new Date(), pickParts()));\n buttonEl?.setAttribute(\n 'aria-label',\n generatePickerButtonAriaLabel(currentlySelectedDate(), 'date', locale, t, open)\n );\n };\n\n const setInputValue = (newValue: Date) => {\n dayInputRef.current!.value = newValue.getUTCDate().toString().padStart(2, '0');\n monthInputRef.current!.value = (newValue.getUTCMonth() + 1).toString().padStart(2, '0');\n yearInputRef.current!.value = newValue.getUTCFullYear().toString();\n };\n\n const onPaste = (e: ClipboardEvent) => {\n const text = e.clipboardData.getData('text');\n const newDate = parsePastedTextToDate(text, locale, date || new Date());\n if (newDate) {\n e.preventDefault();\n setInputValue(newDate);\n onInputChange();\n }\n };\n\n const displayNames = new Intl.DisplayNames(locale, { style: 'long', type: 'dateTimeField' });\n\n const DayInput = (\n <PartInput\n key='day'\n placeholder={t('day_placeholder')}\n aria-label={displayNames.of('day')}\n value={date?.getUTCDate()}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n readOnly={readOnly}\n min={1}\n max={31}\n ref={dayInputRef}\n />\n );\n\n const MonthInput = (\n <PartInput\n key='month'\n placeholder={t('month_placeholder')}\n aria-label={displayNames.of('month')}\n value={date ? date?.getUTCMonth() + 1 : undefined}\n onChange={onInputChange}\n size={2}\n maxLength={2}\n readOnly={readOnly}\n min={1}\n max={12}\n ref={monthInputRef}\n />\n );\n\n const YearInput = (\n <PartInput\n key='year'\n placeholder={t('year_placeholder')}\n aria-label={displayNames.of('year')}\n value={date?.getUTCFullYear()}\n onChange={onInputChange}\n size={4}\n maxLength={4}\n readOnly={readOnly}\n min={1}\n ref={yearInputRef}\n />\n );\n\n const containerRef = useRef<HTMLElement>(null);\n useFocusWithin([containerRef], onFocusChange);\n\n useImperativeHandle(ref, () => ({\n setOpen,\n buttonEl,\n get value() {\n return currentlySelectedDate();\n }\n }));\n\n const PickerButton = (\n <>\n <Button\n variant='simple'\n icon\n ref={setButtonEl}\n onClick={() => setOpen(cur => !cur)}\n aria-label={generatePickerButtonAriaLabel(\n currentlySelectedDate(),\n 'date',\n locale,\n t,\n open\n )}\n readOnly={readOnly}\n disabled={disabled}\n >\n <Icon name={open ? 'times' : 'calendar'} />\n </Button>\n {open && (\n <Popover\n ref={setPopoverRef}\n target={buttonEl}\n placement='bottom-end'\n strategy='fixed'\n modifiers={[\n {\n name: 'flip',\n options: {\n fallbackPlacements: ['top-end', 'right', 'left']\n }\n }\n ]}\n >\n <PickerComp\n selected={currentlySelectedDate()}\n min={min}\n max={max}\n showWeekNumber={showWeekNumber}\n {...rendererProps}\n onChange={selected => {\n setInputValue(selected);\n setOpen(false);\n setTimeout(() => buttonEl?.focus());\n onInputChange();\n rendererProps?.onChange?.(selected);\n }}\n />\n </Popover>\n )}\n </>\n );\n\n const orderedRefs: RefObject<HTMLInputElement>[] = [];\n\n const Comp = (\n <Flex\n as={StyledDateInput}\n forwardedAs={StyledFormControl}\n hasSuggestion={status === 'pending' && !!onResolveSuggestion}\n container={{ alignItems: 'center', wrap: 'nowrap' }}\n status={status}\n readOnly={readOnly}\n disabled={disabled}\n ref={containerRef}\n onClick={(e: MouseEvent) => {\n if (e.target === containerRef.current) orderedRefs[0].current?.focus();\n }}\n {...restProps}\n >\n <Flex\n ref={inputContainerRef}\n as={StyledInputContainer}\n container={{ alignItems: 'center', wrap: 'wrap' }}\n onPaste={onPaste}\n >\n {getDateFormat(locale).map(part => {\n switch (part) {\n case 'DD':\n orderedRefs.push(dayInputRef);\n return DayInput;\n case 'MM':\n orderedRefs.push(monthInputRef);\n return MonthInput;\n case 'YYYY':\n orderedRefs.push(yearInputRef);\n return YearInput;\n default:\n return part;\n }\n })}\n </Flex>\n {!readOnly && PickerButton}\n </Flex>\n );\n\n useEffect(() => {\n if (autoFocus) orderedRefs[0].current?.focus();\n }, [autoFocus]);\n\n useAutoFocusNextInput(orderedRefs);\n\n return label ? (\n <FormField\n as='fieldset'\n aria-labelledby={id}\n labelAs='legend'\n {...{\n label,\n labelHidden,\n id,\n info,\n status,\n required,\n disabled,\n onResolveSuggestion,\n additionalInfo\n }}\n ref={ref}\n >\n {Comp}\n </FormField>\n ) : (\n Comp\n );\n }\n);\n\nexport default DateInput;\n"]}
|
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { ForwardProps } from '../../../types';
|
|
3
3
|
import { FormControlProps } from '../../FormControl';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import type { DateRangeCallbackParameter, DateTimeProperties } from '../DateTime.types';
|
|
5
|
+
import DateTimeProps from '../DateTime.types';
|
|
6
6
|
export interface DateRangeInputProps extends DateTimeProperties {
|
|
7
|
+
/** Object of range boundaries. */
|
|
8
|
+
value?: {
|
|
9
|
+
start?: DateTimeProps['value'];
|
|
10
|
+
end?: DateTimeProps['value'];
|
|
11
|
+
};
|
|
7
12
|
/**
|
|
8
13
|
* Display additional column with week number in date picker popover.
|
|
9
14
|
* @default false
|
|
10
15
|
*/
|
|
11
16
|
showWeekNumber?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Pass a string or a fragment with an Icon and string for second part of DataRangeInput.
|
|
18
|
-
*/
|
|
19
|
-
toLabel: FormControlProps['label'];
|
|
20
|
-
/**
|
|
21
|
-
* Pass an object with "heading" and "content" properties to show AdditionalInfo for second part of DataRangeInput.
|
|
22
|
-
*/
|
|
17
|
+
/** Pass a string or a fragment with an Icon and string for first part of DataRangeInput. */
|
|
18
|
+
fromLabel?: FormControlProps['label'];
|
|
19
|
+
/** Pass a string or a fragment with an Icon and string for second part of DataRangeInput. */
|
|
20
|
+
toLabel?: FormControlProps['label'];
|
|
21
|
+
/** Pass an object with "heading" and "content" properties to show AdditionalInfo for second part of DataRangeInput. */
|
|
23
22
|
toAdditionalInfo?: FormControlProps['additionalInfo'];
|
|
24
|
-
/**
|
|
25
|
-
* Pass an object with "heading" and "content" properties to show AdditionalInfo for first part of DataRangeInput.
|
|
26
|
-
*/
|
|
23
|
+
/** Pass an object with "heading" and "content" properties to show AdditionalInfo for first part of DataRangeInput. */
|
|
27
24
|
fromAdditionalInfo?: FormControlProps['additionalInfo'];
|
|
28
|
-
/**
|
|
29
|
-
* Date as ISO8601 string, timestamp or native Date object. Requires onChange prop to update value for controlled inputs.
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
fromValue?: string | number | Date;
|
|
33
|
-
/**
|
|
34
|
-
* Date as ISO8601 string, timestamp or native Date object. Requires onChange prop to update value for controlled inputs.
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
toValue?: string | number | Date;
|
|
38
25
|
/** Callback fired when input value changes. */
|
|
39
|
-
onChange
|
|
26
|
+
onChange: (value: DateRangeCallbackParameter) => void;
|
|
40
27
|
/** Callback fired when the component gets focused. */
|
|
41
|
-
onFocus?: (value:
|
|
28
|
+
onFocus?: (value: DateRangeCallbackParameter) => void;
|
|
42
29
|
/** Callback fired when the component loses focus. */
|
|
43
|
-
onBlur?: (value:
|
|
30
|
+
onBlur?: (value: DateRangeCallbackParameter) => void;
|
|
44
31
|
/** Automatically focuses the input on render. */
|
|
45
32
|
autoFocus?: boolean;
|
|
46
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateRangeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DateRangeInput.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Input/DateRangeInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAOlB,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAIrD,OAAO,KAAK,EACV,0BAA0B,EAE1B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAM9C,MAAM,WAAW,m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