@lumx/react 2.2.19 → 2.2.20-alpha-type.1

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.
Files changed (96) hide show
  1. package/esm/_internal/AutocompleteMultiple.js.map +1 -1
  2. package/esm/_internal/ButtonRoot.js.map +1 -1
  3. package/esm/_internal/Checkbox2.js +3 -1
  4. package/esm/_internal/Checkbox2.js.map +1 -1
  5. package/esm/_internal/ClickAwayProvider.js +90 -12
  6. package/esm/_internal/ClickAwayProvider.js.map +1 -1
  7. package/esm/_internal/DatePickerField.js +18 -11
  8. package/esm/_internal/DatePickerField.js.map +1 -1
  9. package/esm/_internal/Dialog2.js +2 -2
  10. package/esm/_internal/Dialog2.js.map +1 -1
  11. package/esm/_internal/Dropdown2.js.map +1 -1
  12. package/esm/_internal/GenericBlock.js +90 -0
  13. package/esm/_internal/GenericBlock.js.map +1 -0
  14. package/esm/_internal/Lightbox2.js +2 -2
  15. package/esm/_internal/Lightbox2.js.map +1 -1
  16. package/esm/_internal/LinkPreview.js +22 -12
  17. package/esm/_internal/LinkPreview.js.map +1 -1
  18. package/esm/_internal/Popover2.js +21 -8
  19. package/esm/_internal/Popover2.js.map +1 -1
  20. package/esm/_internal/SelectMultiple.js +16 -4
  21. package/esm/_internal/SelectMultiple.js.map +1 -1
  22. package/esm/_internal/TextField.js.map +1 -1
  23. package/esm/_internal/Thumbnail2.js.map +1 -1
  24. package/esm/_internal/alert-dialog.js +2 -2
  25. package/esm/_internal/autocomplete.js +2 -1
  26. package/esm/_internal/autocomplete.js.map +1 -1
  27. package/esm/_internal/button.js +2 -1
  28. package/esm/_internal/button.js.map +1 -1
  29. package/esm/_internal/comment-block.js +2 -1
  30. package/esm/_internal/comment-block.js.map +1 -1
  31. package/esm/_internal/date-picker.js +3 -2
  32. package/esm/_internal/date-picker.js.map +1 -1
  33. package/esm/_internal/dialog.js +2 -2
  34. package/esm/_internal/dropdown.js +2 -1
  35. package/esm/_internal/dropdown.js.map +1 -1
  36. package/esm/_internal/expansion-panel.js +1 -1
  37. package/esm/_internal/generic-block.js +12 -0
  38. package/esm/_internal/generic-block.js.map +1 -0
  39. package/esm/_internal/lightbox.js +3 -2
  40. package/esm/_internal/lightbox.js.map +1 -1
  41. package/esm/_internal/popover.js +2 -1
  42. package/esm/_internal/popover.js.map +1 -1
  43. package/esm/_internal/select.js +2 -1
  44. package/esm/_internal/select.js.map +1 -1
  45. package/esm/_internal/side-navigation.js +2 -1
  46. package/esm/_internal/side-navigation.js.map +1 -1
  47. package/esm/_internal/slideshow.js +2 -1
  48. package/esm/_internal/slideshow.js.map +1 -1
  49. package/esm/_internal/text-field.js +2 -1
  50. package/esm/_internal/text-field.js.map +1 -1
  51. package/esm/_internal/tooltip.js +2 -1
  52. package/esm/_internal/tooltip.js.map +1 -1
  53. package/esm/_internal/type.js.map +1 -1
  54. package/esm/_internal/useFocusTrap.js +62 -78
  55. package/esm/_internal/useFocusTrap.js.map +1 -1
  56. package/esm/index.js +3 -2
  57. package/esm/index.js.map +1 -1
  58. package/package.json +5 -5
  59. package/src/components/autocomplete/Autocomplete.tsx +4 -4
  60. package/src/components/button/Button.stories.tsx +1 -0
  61. package/src/components/button/ButtonRoot.tsx +4 -4
  62. package/src/components/checkbox/Checkbox.tsx +2 -1
  63. package/src/components/checkbox/__snapshots__/Checkbox.test.tsx.snap +4 -0
  64. package/src/components/date-picker/DatePickerField.tsx +15 -16
  65. package/src/components/date-picker/types.ts +2 -2
  66. package/src/components/dialog/Dialog.stories.tsx +57 -13
  67. package/src/components/dialog/Dialog.tsx +3 -3
  68. package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +82 -14
  69. package/src/components/dropdown/Dropdown.tsx +4 -3
  70. package/src/components/generic-block/GenericBlock.stories.tsx +149 -0
  71. package/src/components/generic-block/GenericBlock.test.tsx +28 -0
  72. package/src/components/generic-block/GenericBlock.tsx +120 -0
  73. package/src/components/generic-block/__snapshots__/GenericBlock.test.tsx.snap +92 -0
  74. package/src/components/generic-block/index.ts +1 -0
  75. package/src/components/lightbox/Lightbox.tsx +1 -1
  76. package/src/components/link-preview/LinkPreview.test.tsx +50 -55
  77. package/src/components/link-preview/LinkPreview.tsx +43 -16
  78. package/src/components/popover/Popover.tsx +20 -4
  79. package/src/components/select/Select.stories.tsx +2 -0
  80. package/src/components/select/Select.tsx +11 -1
  81. package/src/components/select/SelectMultiple.stories.tsx +2 -0
  82. package/src/components/select/SelectMultiple.tsx +11 -1
  83. package/src/components/select/constants.ts +2 -0
  84. package/src/components/table/__snapshots__/Table.test.tsx.snap +5 -0
  85. package/src/components/text-field/TextField.tsx +4 -4
  86. package/src/components/thumbnail/Thumbnail.tsx +2 -2
  87. package/src/hooks/useCallbackOnEscape.ts +21 -13
  88. package/src/hooks/useFocusTrap.ts +68 -51
  89. package/src/index.ts +1 -0
  90. package/src/stories/generated/GenericBlock/Demos.stories.tsx +6 -0
  91. package/src/utils/focus/getFirstAndLastFocusable.test.ts +6 -0
  92. package/src/utils/focus/getFirstAndLastFocusable.ts +2 -2
  93. package/src/utils/makeListenerTowerContext.ts +32 -0
  94. package/src/utils/type.ts +3 -0
  95. package/types.d.ts +70 -16
  96. package/src/components/link-preview/__snapshots__/LinkPreview.test.tsx.snap +0 -51
@@ -1 +1 @@
1
- {"version":3,"file":"AutocompleteMultiple.js","sources":["../../../src/components/autocomplete/Autocomplete.tsx","../../../src/components/autocomplete/AutocompleteMultiple.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode, RefObject, SyntheticEvent, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Dropdown, IconButtonProps, Offset, Placement, TextField, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { useFocus } from '@lumx/react/hooks/useFocus';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\n/**\n * Defines the props of the component.\n */\nexport interface AutocompleteProps extends GenericProps {\n /**\n * Whether the suggestions list should display anchored to the input or to the wrapper.\n * @see {@link DropdownProps#anchorToInput}\n */\n anchorToInput?: boolean;\n /**\n * Props to pass to the clear button (minus those already set by the TextField props).\n * If not specified, the button won't be displayed.\n * @see {@link TextFieldProps#clearButtonProps}\n */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /**\n * Reference to the <input> or <textarea> element.\n * @see {@link TextFieldProps#inputRef}\n */\n inputRef?: RefObject<HTMLInputElement>;\n /**\n * The offset that will be applied to the Dropdown position.\n * @see {@link DropdownProps#offset}\n */\n offset?: Offset;\n /**\n * The preferred Dropdown location against the anchor element.\n * @see {@link DropdownProps#placement}\n */\n placement?: Placement;\n /**\n * Whether the dropdown should fit to the anchor width or not.\n * @see {@link DropdownProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * The error related to the component.\n * @see {@link TextFieldProps#error}\n */\n error?: string | ReactNode;\n /**\n * Whether the text field is displayed with error style or not.\n * @see {@link TextFieldProps#hasError}\n */\n hasError?: boolean;\n /**\n * Whether the text box should be focused upon closing the suggestions or not.\n */\n shouldFocusOnClose?: boolean;\n /**\n * The helper message of the text field.\n * @see {@link TextFieldProps#helper}\n */\n helper?: string;\n /**\n * The icon of the text field (SVG path).\n * @see {@link TextFieldProps#icon}\n */\n icon?: string;\n /**\n * Whether the component is disabled or not.\n * @see {@link TextFieldProps#isDisabled}\n */\n isDisabled?: boolean;\n /**\n * Whether the component is required or not.\n * @see {@link TextFieldProps#isRequired}\n */\n isRequired?: boolean;\n /**\n * Whether the text field is displayed with valid style or not.\n * @see {@link TextFieldProps#isValid}\n */\n isValid?: boolean;\n /**\n * The label of the text field displayed in a label tag.\n * @see {@link TextFieldProps#label}\n */\n label?: string;\n /**\n * The placeholder message of the text field.\n * @see {@link TextFieldProps#placeholder}\n */\n placeholder?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** List of suggestions to display during autocomplete. */\n children: React.ReactNode;\n /**\n * The list of chips to be displayed before the text field input.\n */\n chips?: React.ReactNode;\n /**\n * The value of the text field.\n * @see {@link TextFieldProps#value}\n */\n value: string;\n /**\n * Whether the suggestions from the autocomplete should be displayed or not.\n * @see {@link DropdownProps#isOpen}\n */\n isOpen: boolean;\n /**\n * The native input name property.\n * @see {@link TextFieldProps#name}\n */\n name?: string;\n /**\n * Whether a click in the Autocomplete dropdown would close it or not.\n * @see {@link DropdownProps#closeOnClick}\n */\n closeOnClick?: boolean;\n /**\n * Whether a click anywhere out of the Autocomplete would close it or not.\n * @see {@link DropdownProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether an escape key press would close the Autocomplete or not.\n * @see {@link DropdownProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * The function called on blur.\n * @see {@link TextFieldProps#onBlur}\n */\n onBlur?(event: React.FocusEvent): void;\n /**\n * On change callback.\n * @see {@link TextFieldProps#onChange}\n */\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n /**\n * The function called on close.\n * @see {@link DropdownProps#onClose}\n */\n onClose?(): void;\n /**\n * The function called on focus.\n * @see {@link TextFieldProps#onFocus}\n */\n onFocus?(event: React.FocusEvent): void;\n /**\n * The function called when the bottom of the dropdown is reached.\n * @see {@link DropdownProps#onInfiniteScroll}\n */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Autocomplete';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AutocompleteProps> = {\n anchorToInput: false,\n closeOnClick: false,\n closeOnClickAway: true,\n closeOnEscape: true,\n shouldFocusOnClose: false,\n};\n\n/**\n * Autocomplete component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorToInput,\n children,\n chips,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n disabled,\n error,\n fitToAnchorWidth,\n hasError,\n helper,\n icon,\n inputRef,\n clearButtonProps,\n isDisabled = disabled,\n isRequired,\n isOpen,\n isValid,\n label,\n name,\n offset,\n onBlur,\n onChange,\n onClose,\n onFocus,\n onInfiniteScroll,\n placeholder,\n placement,\n shouldFocusOnClose,\n theme,\n value,\n ...forwardedProps\n } = props;\n const inputAnchorRef = useRef<HTMLElement>(null);\n const textFieldRef = useRef(null);\n useFocus(inputAnchorRef.current, !isOpen && shouldFocusOnClose);\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n <TextField\n chips={chips}\n error={error}\n hasError={hasError}\n helper={helper}\n icon={icon}\n inputRef={mergeRefs(inputAnchorRef, inputRef) as any}\n clearButtonProps={clearButtonProps}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isValid={isValid}\n label={label}\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n textFieldRef={textFieldRef}\n theme={theme}\n value={value}\n />\n <Dropdown\n anchorRef={anchorToInput ? inputAnchorRef : textFieldRef}\n closeOnClick={closeOnClick}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n onInfiniteScroll={onInfiniteScroll}\n placement={placement}\n shouldFocusOnOpen={false}\n theme={theme}\n >\n {children}\n </Dropdown>\n </div>\n );\n});\nAutocomplete.displayName = COMPONENT_NAME;\nAutocomplete.className = CLASSNAME;\nAutocomplete.defaultProps = DEFAULT_PROPS;\n","import { mdiClose } from '@lumx/icons';\nimport { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport classNames from 'classnames';\nimport React, { forwardRef, ReactNode } from 'react';\n\n/**\n * Defines the props of the component.\n */\nexport interface AutocompleteMultipleProps extends AutocompleteProps {\n /** Selected values. */\n values: any[];\n /** Alignment of the chips in the autocomplete. */\n chipsAlignment?: HorizontalAlignment;\n /** Selected value render function. Default: Renders the value inside of a Chip. */\n selectedChipRender(\n choice: any,\n index: number,\n onClear?: (event: React.MouseEvent, choice: any) => void,\n isDisabled?: boolean,\n ): ReactNode | string;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'AutocompleteMultiple';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AutocompleteMultipleProps> = {\n closeOnClickAway: true,\n closeOnEscape: true,\n selectedChipRender(choice, index, onClear, isDisabled) {\n const onClick = (event: React.MouseEvent) => onClear && onClear(event, choice);\n return (\n <Chip\n key={index}\n after={onClear && <Icon icon={mdiClose} size={Size.xxs} />}\n isDisabled={isDisabled}\n size={Size.s}\n onAfterClick={onClick}\n onClick={onClick}\n >\n {choice}\n </Chip>\n );\n },\n values: [],\n};\n\n/**\n * AutocompleteMultiple component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorToInput,\n children,\n // `chipsAlignment` needs to be here to remove it from `forwardedProps`.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chipsAlignment,\n className,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n hasError,\n helper,\n icon,\n inputRef,\n clearButtonProps,\n isDisabled,\n isRequired,\n isOpen,\n isValid,\n label,\n name,\n offset,\n onBlur,\n onChange,\n onClear,\n onClose,\n onFocus,\n onInfiniteScroll,\n onKeyDown,\n placeholder,\n placement,\n selectedChipRender,\n shouldFocusOnClose,\n theme,\n type,\n value,\n values,\n ...forwardedProps\n } = props;\n\n return (\n <Autocomplete\n ref={ref}\n {...forwardedProps}\n anchorToInput={anchorToInput}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n name={name}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n shouldFocusOnClose={shouldFocusOnClose}\n onFocus={onFocus}\n hasError={hasError}\n helper={helper}\n icon={icon}\n inputRef={inputRef}\n chips={values && values.map((chip: any, index: number) => selectedChipRender(chip, index, onClear))}\n isDisabled={isDisabled}\n isRequired={isRequired}\n clearButtonProps={clearButtonProps}\n isValid={isValid}\n label={label}\n placeholder={placeholder}\n theme={theme}\n type={type}\n isOpen={isOpen}\n closeOnClick={false}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n onClose={onClose}\n offset={offset}\n placement={placement}\n fitToAnchorWidth={fitToAnchorWidth}\n onInfiniteScroll={onInfiniteScroll}\n >\n {children}\n </Autocomplete>\n );\n});\nAutocompleteMultiple.displayName = COMPONENT_NAME;\nAutocompleteMultiple.className = CLASSNAME;\nAutocompleteMultiple.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","anchorToInput","closeOnClick","closeOnClickAway","closeOnEscape","shouldFocusOnClose","Autocomplete","forwardRef","props","ref","children","chips","className","disabled","error","fitToAnchorWidth","hasError","helper","icon","inputRef","clearButtonProps","isDisabled","isRequired","isOpen","isValid","label","name","offset","onBlur","onChange","onClose","onFocus","onInfiniteScroll","placeholder","placement","theme","value","forwardedProps","inputAnchorRef","useRef","textFieldRef","useFocus","current","classNames","handleBasicClasses","prefix","mergeRefs","displayName","defaultProps","selectedChipRender","choice","index","onClear","onClick","event","mdiClose","Size","xxs","s","values","AutocompleteMultiple","chipsAlignment","onKeyDown","type","map","chip"],"mappings":";;;;;;;;;;;AAWA;;;;AAsJA;;;AAGA,IAAMA,cAAc,GAAG,cAA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../src/components/autocomplete/Autocomplete.tsx","../../../src/components/autocomplete/AutocompleteMultiple.tsx"],"sourcesContent":["import React, { forwardRef, ReactNode, SyntheticEvent, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { Dropdown, IconButtonProps, Offset, Placement, TextField, TextFieldProps, Theme } from '@lumx/react';\n\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport { useFocus } from '@lumx/react/hooks/useFocus';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\n\n/**\n * Defines the props of the component.\n */\nexport interface AutocompleteProps extends GenericProps {\n /**\n * Whether the suggestions list should display anchored to the input or to the wrapper.\n * @see {@link DropdownProps#anchorToInput}\n */\n anchorToInput?: boolean;\n /**\n * Props to pass to the clear button (minus those already set by the TextField props).\n * If not specified, the button won't be displayed.\n * @see {@link TextFieldProps#clearButtonProps}\n */\n clearButtonProps?: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /**\n * Reference to the <input> or <textarea> element.\n * @see {@link TextFieldProps#inputRef}\n */\n inputRef?: TextFieldProps['inputRef'];\n /**\n * The offset that will be applied to the Dropdown position.\n * @see {@link DropdownProps#offset}\n */\n offset?: Offset;\n /**\n * The preferred Dropdown location against the anchor element.\n * @see {@link DropdownProps#placement}\n */\n placement?: Placement;\n /**\n * Whether the dropdown should fit to the anchor width or not.\n * @see {@link DropdownProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: boolean;\n /**\n * The error related to the component.\n * @see {@link TextFieldProps#error}\n */\n error?: string | ReactNode;\n /**\n * Whether the text field is displayed with error style or not.\n * @see {@link TextFieldProps#hasError}\n */\n hasError?: boolean;\n /**\n * Whether the text box should be focused upon closing the suggestions or not.\n */\n shouldFocusOnClose?: boolean;\n /**\n * The helper message of the text field.\n * @see {@link TextFieldProps#helper}\n */\n helper?: string;\n /**\n * The icon of the text field (SVG path).\n * @see {@link TextFieldProps#icon}\n */\n icon?: string;\n /**\n * Whether the component is disabled or not.\n * @see {@link TextFieldProps#isDisabled}\n */\n isDisabled?: boolean;\n /**\n * Whether the component is required or not.\n * @see {@link TextFieldProps#isRequired}\n */\n isRequired?: boolean;\n /**\n * Whether the text field is displayed with valid style or not.\n * @see {@link TextFieldProps#isValid}\n */\n isValid?: boolean;\n /**\n * The label of the text field displayed in a label tag.\n * @see {@link TextFieldProps#label}\n */\n label?: string;\n /**\n * The placeholder message of the text field.\n * @see {@link TextFieldProps#placeholder}\n */\n placeholder?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** List of suggestions to display during autocomplete. */\n children: React.ReactNode;\n /**\n * The list of chips to be displayed before the text field input.\n */\n chips?: React.ReactNode;\n /**\n * The value of the text field.\n * @see {@link TextFieldProps#value}\n */\n value: string;\n /**\n * Whether the suggestions from the autocomplete should be displayed or not.\n * @see {@link DropdownProps#isOpen}\n */\n isOpen: boolean;\n /**\n * The native input name property.\n * @see {@link TextFieldProps#name}\n */\n name?: string;\n /**\n * Whether a click in the Autocomplete dropdown would close it or not.\n * @see {@link DropdownProps#closeOnClick}\n */\n closeOnClick?: boolean;\n /**\n * Whether a click anywhere out of the Autocomplete would close it or not.\n * @see {@link DropdownProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether an escape key press would close the Autocomplete or not.\n * @see {@link DropdownProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * The function called on blur.\n * @see {@link TextFieldProps#onBlur}\n */\n onBlur?(event: React.FocusEvent): void;\n /**\n * On change callback.\n * @see {@link TextFieldProps#onChange}\n */\n onChange(value: string, name?: string, event?: SyntheticEvent): void;\n /**\n * The function called on close.\n * @see {@link DropdownProps#onClose}\n */\n onClose?(): void;\n /**\n * The function called on focus.\n * @see {@link TextFieldProps#onFocus}\n */\n onFocus?(event: React.FocusEvent): void;\n /**\n * The function called when the bottom of the dropdown is reached.\n * @see {@link DropdownProps#onInfiniteScroll}\n */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Autocomplete';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AutocompleteProps> = {\n anchorToInput: false,\n closeOnClick: false,\n closeOnClickAway: true,\n closeOnEscape: true,\n shouldFocusOnClose: false,\n};\n\n/**\n * Autocomplete component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorToInput,\n children,\n chips,\n className,\n closeOnClick,\n closeOnClickAway,\n closeOnEscape,\n disabled,\n error,\n fitToAnchorWidth,\n hasError,\n helper,\n icon,\n inputRef,\n clearButtonProps,\n isDisabled = disabled,\n isRequired,\n isOpen,\n isValid,\n label,\n name,\n offset,\n onBlur,\n onChange,\n onClose,\n onFocus,\n onInfiniteScroll,\n placeholder,\n placement,\n shouldFocusOnClose,\n theme,\n value,\n ...forwardedProps\n } = props;\n const inputAnchorRef = useRef<HTMLElement>(null);\n const textFieldRef = useRef(null);\n useFocus(inputAnchorRef.current, !isOpen && shouldFocusOnClose);\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n >\n <TextField\n chips={chips}\n error={error}\n hasError={hasError}\n helper={helper}\n icon={icon}\n inputRef={mergeRefs(inputAnchorRef as React.RefObject<HTMLInputElement>, inputRef)}\n clearButtonProps={clearButtonProps}\n isDisabled={isDisabled}\n isRequired={isRequired}\n isValid={isValid}\n label={label}\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n placeholder={placeholder}\n textFieldRef={textFieldRef}\n theme={theme}\n value={value}\n />\n <Dropdown\n anchorRef={anchorToInput ? inputAnchorRef : textFieldRef}\n closeOnClick={closeOnClick}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n onInfiniteScroll={onInfiniteScroll}\n placement={placement}\n shouldFocusOnOpen={false}\n theme={theme}\n >\n {children}\n </Dropdown>\n </div>\n );\n});\nAutocomplete.displayName = COMPONENT_NAME;\nAutocomplete.className = CLASSNAME;\nAutocomplete.defaultProps = DEFAULT_PROPS;\n","import { mdiClose } from '@lumx/icons';\nimport { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';\n\nimport { Comp, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\nimport classNames from 'classnames';\nimport React, { forwardRef, ReactNode } from 'react';\n\n/**\n * Defines the props of the component.\n */\nexport interface AutocompleteMultipleProps extends AutocompleteProps {\n /** Selected values. */\n values: any[];\n /** Alignment of the chips in the autocomplete. */\n chipsAlignment?: HorizontalAlignment;\n /** Selected value render function. Default: Renders the value inside of a Chip. */\n selectedChipRender(\n choice: any,\n index: number,\n onClear?: (event: React.MouseEvent, choice: any) => void,\n isDisabled?: boolean,\n ): ReactNode | string;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'AutocompleteMultiple';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<AutocompleteMultipleProps> = {\n closeOnClickAway: true,\n closeOnEscape: true,\n selectedChipRender(choice, index, onClear, isDisabled) {\n const onClick = (event: React.MouseEvent) => onClear && onClear(event, choice);\n return (\n <Chip\n key={index}\n after={onClear && <Icon icon={mdiClose} size={Size.xxs} />}\n isDisabled={isDisabled}\n size={Size.s}\n onAfterClick={onClick}\n onClick={onClick}\n >\n {choice}\n </Chip>\n );\n },\n values: [],\n};\n\n/**\n * AutocompleteMultiple component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n anchorToInput,\n children,\n // `chipsAlignment` needs to be here to remove it from `forwardedProps`.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n chipsAlignment,\n className,\n closeOnClickAway,\n closeOnEscape,\n fitToAnchorWidth,\n hasError,\n helper,\n icon,\n inputRef,\n clearButtonProps,\n isDisabled,\n isRequired,\n isOpen,\n isValid,\n label,\n name,\n offset,\n onBlur,\n onChange,\n onClear,\n onClose,\n onFocus,\n onInfiniteScroll,\n onKeyDown,\n placeholder,\n placement,\n selectedChipRender,\n shouldFocusOnClose,\n theme,\n type,\n value,\n values,\n ...forwardedProps\n } = props;\n\n return (\n <Autocomplete\n ref={ref}\n {...forwardedProps}\n anchorToInput={anchorToInput}\n className={classNames(\n className,\n handleBasicClasses({\n prefix: CLASSNAME,\n }),\n )}\n name={name}\n value={value}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onBlur={onBlur}\n shouldFocusOnClose={shouldFocusOnClose}\n onFocus={onFocus}\n hasError={hasError}\n helper={helper}\n icon={icon}\n inputRef={inputRef}\n chips={values && values.map((chip: any, index: number) => selectedChipRender(chip, index, onClear))}\n isDisabled={isDisabled}\n isRequired={isRequired}\n clearButtonProps={clearButtonProps}\n isValid={isValid}\n label={label}\n placeholder={placeholder}\n theme={theme}\n type={type}\n isOpen={isOpen}\n closeOnClick={false}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n onClose={onClose}\n offset={offset}\n placement={placement}\n fitToAnchorWidth={fitToAnchorWidth}\n onInfiniteScroll={onInfiniteScroll}\n >\n {children}\n </Autocomplete>\n );\n});\nAutocompleteMultiple.displayName = COMPONENT_NAME;\nAutocompleteMultiple.className = CLASSNAME;\nAutocompleteMultiple.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","anchorToInput","closeOnClick","closeOnClickAway","closeOnEscape","shouldFocusOnClose","Autocomplete","forwardRef","props","ref","children","chips","className","disabled","error","fitToAnchorWidth","hasError","helper","icon","inputRef","clearButtonProps","isDisabled","isRequired","isOpen","isValid","label","name","offset","onBlur","onChange","onClose","onFocus","onInfiniteScroll","placeholder","placement","theme","value","forwardedProps","inputAnchorRef","useRef","textFieldRef","useFocus","current","classNames","handleBasicClasses","prefix","mergeRefs","displayName","defaultProps","selectedChipRender","choice","index","onClear","onClick","event","mdiClose","Size","xxs","s","values","AutocompleteMultiple","chipsAlignment","onKeyDown","type","map","chip"],"mappings":";;;;;;;;;;;AAWA;;;;AAsJA;;;AAGA,IAAMA,cAAc,GAAG,cAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAyC,GAAG;AAC9CC,EAAAA,aAAa,EAAE,KAD+B;AAE9CC,EAAAA,YAAY,EAAE,KAFgC;AAG9CC,EAAAA,gBAAgB,EAAE,IAH4B;AAI9CC,EAAAA,aAAa,EAAE,IAJ+B;AAK9CC,EAAAA,kBAAkB,EAAE;AAL0B,CAAlD;AAQA;;;;;;;;IAOaC,YAAqD,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAExFR,aAFwF,GAmCxFO,KAnCwF,CAExFP,aAFwF;AAAA,MAGxFS,QAHwF,GAmCxFF,KAnCwF,CAGxFE,QAHwF;AAAA,MAIxFC,KAJwF,GAmCxFH,KAnCwF,CAIxFG,KAJwF;AAAA,MAKxFC,SALwF,GAmCxFJ,KAnCwF,CAKxFI,SALwF;AAAA,MAMxFV,YANwF,GAmCxFM,KAnCwF,CAMxFN,YANwF;AAAA,MAOxFC,gBAPwF,GAmCxFK,KAnCwF,CAOxFL,gBAPwF;AAAA,MAQxFC,aARwF,GAmCxFI,KAnCwF,CAQxFJ,aARwF;AAAA,MASxFS,QATwF,GAmCxFL,KAnCwF,CASxFK,QATwF;AAAA,MAUxFC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AAEC,aAjCnB;AAkCI,IAAA,OAAO,EAAE0B,OAlCb;AAmCI,IAAA,MAAM,EAAEH,MAnCZ;AAoCI,IAAA,SAAS,EAAEO,SApCf;AAqCI,IAAA,gBAAgB,EAAEnB,gBArCtB;AAsCI,IAAA,gBAAgB,EAAEiB;AAtCtB,MAwCKtB,QAxCL,CADJ;AA4CH,CArF8F;AAsF/FkD,oBAAoB,CAACb,WAArB,GAAmClD,gBAAnC;AACA+D,oBAAoB,CAAChD,SAArB,GAAiCd,WAAjC;AACA8D,oBAAoB,CAACZ,YAArB,GAAoChD,eAApC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonRoot.js","sources":["../../../src/components/button/ButtonRoot.tsx"],"sourcesContent":["import React, { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';\n\nimport isEmpty from 'lodash/isEmpty';\n\nimport classNames from 'classnames';\n\nimport { Color, ColorPalette, Emphasis, Size, Theme } from '@lumx/react';\nimport { CSS_PREFIX } from '@lumx/react/constants';\nimport { Comp, GenericProps, handleBasicClasses } from '@lumx/react/utils';\nimport { renderLink } from '@lumx/react/utils/renderLink';\n\ntype HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;\n\n/**\n * Button size definition.\n */\nexport type ButtonSize = Extract<Size, 's' | 'm'>;\n\nexport interface BaseButtonProps extends GenericProps {\n /** ARIA button label. */\n ['aria-label']?: string;\n /** Color variant. */\n color?: Color;\n /** Emphasis variant. */\n emphasis?: Emphasis;\n /** Whether or not the button has a background color in low emphasis. */\n hasBackground?: boolean;\n /** Native anchor href property. It determines whether the Button will be a <button> or an <a>. */\n href?: string;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is selected or not. */\n isSelected?: boolean;\n /** Native button name property. */\n name?: string;\n /** Size variant. */\n size?: ButtonSize;\n /** Native anchor target property. */\n target?: '_self' | '_blank' | '_parent' | '_top';\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native button type. */\n type?: HTMLButtonProps['type'];\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\nexport interface ButtonRootProps extends BaseButtonProps {\n variant: 'button' | 'icon';\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'ButtonRoot';\n\nexport const BUTTON_WRAPPER_CLASSNAME = `${CSS_PREFIX}-button-wrapper`;\nexport const BUTTON_CLASSNAME = `${CSS_PREFIX}-button`;\n\n/**\n * Render a button wrapper with the ButtonRoot inside.\n *\n * @param props Component props.\n * @return React element.\n */\nconst renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {\n const { color, emphasis, variant, fullWidth } = props;\n\n const adaptedColor =\n emphasis === Emphasis.low && (color === ColorPalette.light ? ColorPalette.dark : ColorPalette.light);\n\n const wrapperClassName = classNames(\n handleBasicClasses({\n color: adaptedColor,\n prefix: BUTTON_WRAPPER_CLASSNAME,\n variant,\n fullWidth,\n }),\n );\n const buttonProps = { ...props, hasBackground: false };\n\n return (\n <div className={wrapperClassName}>\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <ButtonRoot {...buttonProps} />\n </div>\n );\n};\n\n/**\n * ButtonRoot component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorElement> = forwardRef((props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n className,\n color,\n disabled,\n emphasis,\n hasBackground,\n href,\n isDisabled = disabled,\n isSelected,\n isActive,\n isFocused,\n isHovered,\n linkAs,\n name,\n size,\n target,\n theme,\n variant,\n type = 'button',\n fullWidth,\n ...forwardedProps\n } = props;\n\n const adaptedColor =\n color ||\n (emphasis !== Emphasis.high && theme === Theme.dark && ColorPalette.light) ||\n (emphasis === Emphasis.high && ColorPalette.primary) ||\n ColorPalette.dark;\n\n if (hasBackground) {\n return renderButtonWrapper({ ...props, ref, variant, color: adaptedColor });\n }\n\n const buttonClassName = classNames(\n className,\n handleBasicClasses({\n color: adaptedColor,\n emphasis,\n isSelected,\n isDisabled,\n isActive,\n isFocused,\n isHovered,\n prefix: BUTTON_CLASSNAME,\n size,\n theme: emphasis === Emphasis.high && theme,\n variant,\n fullWidth,\n }),\n );\n\n /**\n * If the linkAs prop is used, we use the linkAs component instead of a <button>.\n * If there is an href attribute, we display an <a> instead of a <button>.\n *\n * However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.\n */\n if ((linkAs || !isEmpty(props.href)) && !isDisabled) {\n return renderLink(\n {\n linkAs,\n ...forwardedProps,\n 'aria-label': ariaLabel,\n href,\n target,\n className: buttonClassName,\n ref: ref as RefObject<HTMLAnchorElement>,\n },\n children,\n );\n }\n return (\n <button\n {...forwardedProps}\n disabled={isDisabled}\n aria-disabled={isDisabled}\n aria-label={ariaLabel}\n ref={ref as RefObject<HTMLButtonElement>}\n className={buttonClassName}\n name={name}\n type={\n // eslint-disable-next-line react/button-has-type\n type\n }\n >\n {children}\n </button>\n );\n});\nButtonRoot.displayName = COMPONENT_NAME;\nButtonRoot.defaultProps = {};\n"],"names":["COMPONENT_NAME","BUTTON_WRAPPER_CLASSNAME","CSS_PREFIX","BUTTON_CLASSNAME","renderButtonWrapper","props","color","emphasis","variant","fullWidth","adaptedColor","Emphasis","low","ColorPalette","light","dark","wrapperClassName","classNames","handleBasicClasses","prefix","buttonProps","hasBackground","ButtonRoot","forwardRef","ref","ariaLabel","children","className","disabled","href","isDisabled","isSelected","isActive","isFocused","isHovered","linkAs","name","size","target","theme","type","forwardedProps","high","Theme","primary","buttonClassName","isEmpty","renderLink","displayName","defaultProps"],"mappings":";;;;;;;AAmDA;;;AAGA,IAAMA,cAAc,GAAG,YAAvB;AAEO,IAAMC,wBAAwB,aAAMC,UAAN,oBAA9B;AACA,IAAMC,gBAAgB,aAAMD,UAAN,YAAtB;AAEP;;;;;;;AAMA,IAAME,mBAA8C,GAAG,SAAjDA,m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AAA,IAAI,EAAET,IAPV;AAQI,IAAA,IAAI;AAEAI,IAAAA;AAVR,MAaKd,QAbL,CADJ;AAiBH,CA3FiG;AA4FlGJ,UAAU,CAAC0B,WAAX,GAAyBhD,cAAzB;AACAsB,UAAU,CAAC2B,YAAX,GAA0B,EAA1B;;;;"}
1
+ {"version":3,"file":"ButtonRoot.js","sources":["../../../src/components/button/ButtonRoot.tsx"],"sourcesContent":["import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';\n\nimport isEmpty from 'lodash/isEmpty';\n\nimport classNames from 'classnames';\n\nimport { Color, ColorPalette, Emphasis, Size, Theme } from '@lumx/react';\nimport { CSS_PREFIX } from '@lumx/react/constants';\nimport { Comp, GenericProps, handleBasicClasses } from '@lumx/react/utils';\nimport { renderLink } from '@lumx/react/utils/renderLink';\n\ntype HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;\n\n/**\n * Button size definition.\n */\nexport type ButtonSize = Extract<Size, 's' | 'm'>;\n\nexport interface BaseButtonProps\n extends GenericProps,\n Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'> {\n /** Color variant. */\n color?: Color;\n /** Emphasis variant. */\n emphasis?: Emphasis;\n /** Whether or not the button has a background color in low emphasis. */\n hasBackground?: boolean;\n /** Native anchor href property. It determines whether the Button will be a <button> or an <a>. */\n href?: string;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Whether the component is selected or not. */\n isSelected?: boolean;\n /** Native button name property. */\n name?: string;\n /** Size variant. */\n size?: ButtonSize;\n /** Native anchor target property. */\n target?: '_self' | '_blank' | '_parent' | '_top';\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native button type. */\n type?: HTMLButtonProps['type'];\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\nexport interface ButtonRootProps extends BaseButtonProps {\n variant: 'button' | 'icon';\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'ButtonRoot';\n\nexport const BUTTON_WRAPPER_CLASSNAME = `${CSS_PREFIX}-button-wrapper`;\nexport const BUTTON_CLASSNAME = `${CSS_PREFIX}-button`;\n\n/**\n * Render a button wrapper with the ButtonRoot inside.\n *\n * @param props Component props.\n * @return React element.\n */\nconst renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {\n const { color, emphasis, variant, fullWidth } = props;\n\n const adaptedColor =\n emphasis === Emphasis.low && (color === ColorPalette.light ? ColorPalette.dark : ColorPalette.light);\n\n const wrapperClassName = classNames(\n handleBasicClasses({\n color: adaptedColor,\n prefix: BUTTON_WRAPPER_CLASSNAME,\n variant,\n fullWidth,\n }),\n );\n const buttonProps = { ...props, hasBackground: false };\n\n return (\n <div className={wrapperClassName}>\n {/* eslint-disable-next-line @typescript-eslint/no-use-before-define */}\n <ButtonRoot {...buttonProps} />\n </div>\n );\n};\n\n/**\n * ButtonRoot component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const ButtonRoot: Comp<ButtonRootProps, HTMLButtonElement | HTMLAnchorElement> = forwardRef((props, ref) => {\n const {\n 'aria-label': ariaLabel,\n children,\n className,\n color,\n disabled,\n emphasis,\n hasBackground,\n href,\n isDisabled = disabled,\n isSelected,\n isActive,\n isFocused,\n isHovered,\n linkAs,\n name,\n size,\n target,\n theme,\n variant,\n type = 'button',\n fullWidth,\n ...forwardedProps\n } = props;\n\n const adaptedColor =\n color ||\n (emphasis !== Emphasis.high && theme === Theme.dark && ColorPalette.light) ||\n (emphasis === Emphasis.high && ColorPalette.primary) ||\n ColorPalette.dark;\n\n if (hasBackground) {\n return renderButtonWrapper({ ...props, ref, variant, color: adaptedColor });\n }\n\n const buttonClassName = classNames(\n className,\n handleBasicClasses({\n color: adaptedColor,\n emphasis,\n isSelected,\n isDisabled,\n isActive,\n isFocused,\n isHovered,\n prefix: BUTTON_CLASSNAME,\n size,\n theme: emphasis === Emphasis.high && theme,\n variant,\n fullWidth,\n }),\n );\n\n /**\n * If the linkAs prop is used, we use the linkAs component instead of a <button>.\n * If there is an href attribute, we display an <a> instead of a <button>.\n *\n * However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.\n */\n if ((linkAs || !isEmpty(props.href)) && !isDisabled) {\n return renderLink(\n {\n linkAs,\n ...forwardedProps,\n 'aria-label': ariaLabel,\n href,\n target,\n className: buttonClassName,\n ref: ref as RefObject<HTMLAnchorElement>,\n },\n children,\n );\n }\n return (\n <button\n {...forwardedProps}\n disabled={isDisabled}\n aria-disabled={isDisabled}\n aria-label={ariaLabel}\n ref={ref as RefObject<HTMLButtonElement>}\n className={buttonClassName}\n name={name}\n type={\n // eslint-disable-next-line react/button-has-type\n type\n }\n >\n {children}\n </button>\n );\n});\nButtonRoot.displayName = COMPONENT_NAME;\nButtonRoot.defaultProps = {};\n"],"names":["COMPONENT_NAME","BUTTON_WRAPPER_CLASSNAME","CSS_PREFIX","BUTTON_CLASSNAME","renderButtonWrapper","props","color","emphasis","variant","fullWidth","adaptedColor","Emphasis","low","ColorPalette","light","dark","wrapperClassName","classNames","handleBasicClasses","prefix","buttonProps","hasBackground","ButtonRoot","forwardRef","ref","ariaLabel","children","className","disabled","href","isDisabled","isSelected","isActive","isFocused","isHovered","linkAs","name","size","target","theme","type","forwardedProps","high","Theme","primary","buttonClassName","isEmpty","renderLink","displayName","defaultProps"],"mappings":";;;;;;;AAmDA;;;AAGA,IAAMA,cAAc,GAAG,YAAvB;AAEO,IAAMC,wBAAwB,aAAMC,UAAN,oBAA9B;AACA,IAAMC,gBAAgB,aAAMD,UAAN,YAAtB;AAEP;;;;;;;AAMA,IAAME,mBAA8C,GAAG,SAAjDA,mBAAiD,CAACC,KAAD,EAAW;AAAA,MACtDC,KADsD,GACdD,KADc,CACtDC,KADsD;AAAA,MAC/CC,QAD+C,GACdF,KADc,CAC/CE,QAD+C;AAAA,MACrCC,OADqC,GACdH,KADc,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AsB,UAAU,CAAC2B,YAAX,GAA0B,EAA1B;;;;"}
@@ -86,7 +86,8 @@ var Checkbox = forwardRef(function (props, ref) {
86
86
  name: name,
87
87
  value: value,
88
88
  checked: isChecked,
89
- onChange: handleChange
89
+ onChange: handleChange,
90
+ "aria-describedby": helper ? "".concat(inputId, "-helper") : undefined
90
91
  }, inputProps)), React.createElement("div", {
91
92
  className: "".concat(CLASSNAME, "__input-placeholder")
92
93
  }, React.createElement("div", {
@@ -102,6 +103,7 @@ var Checkbox = forwardRef(function (props, ref) {
102
103
  className: "".concat(CLASSNAME, "__label"),
103
104
  theme: theme
104
105
  }, label), helper && React.createElement(InputHelper, {
106
+ id: "".concat(inputId, "-helper"),
105
107
  className: "".concat(CLASSNAME, "__helper"),
106
108
  theme: theme
107
109
  }, helper)));
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox2.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent, InputHTMLAttributes } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { mdiCheck } from '@lumx/icons';\n\nimport { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface CheckboxProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Native input ref. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label text. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(isChecked: boolean, value?: string, name?: string, event?: SyntheticEvent): void;\n /** optional props for input */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Checkbox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CheckboxProps> = {\n theme: Theme.light,\n};\n\n/**\n * Checkbox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n inputRef,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n inputProps = {},\n ...forwardedProps\n } = props;\n const inputId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(!isChecked, value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n ref={inputRef}\n type=\"checkbox\"\n id={inputId}\n className={`${CLASSNAME}__input-native`}\n tabIndex={isDisabled ? -1 : 0}\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n {...inputProps}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiCheck} />\n </div>\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={inputId} className={`${CLASSNAME}__label`} theme={theme}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nCheckbox.displayName = COMPONENT_NAME;\nCheckbox.className = CLASSNAME;\nCheckbox.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","Checkbox","forwardRef","props","ref","checked","className","disabled","helper","id","inputRef","isChecked","isDisabled","label","name","onChange","value","inputProps","forwardedProps","inputId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","mdiCheck","displayName","defaultProps"],"mappings":";;;;;;;;;AAUA;;;;AA4BA;;;AAGA,IAAMA,cAAc,GAAG,UAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAqC,GAAG;AAC1CC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AAD6B,CAA9C;AAIA;;;;;;;;IAOaC,QAA6C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAEhFC,OAFgF,GAiBhFF,KAjBgF,CAEhFE,OAFgF;AAAA,MAGhFC,SAHgF,GAiBhFH,KAjBgF,CAGhFG,SAHgF;AAAA,MAIhFC,QAJgF,GAiBhFJ,KAjBgF,CAIhFI,QAJgF;AAAA,MAKhFC,MALgF,GAiBhFL,KAjBgF,CAKhFK,MALgF;AAAA,MAMhFC,EANgF,GAiBhFN,KAjBgF,CAMhFM,EANgF;AAAA,MAOhFC,QAPgF,GAiBhFP,KAjBgF,CAOhFO,QAPgF;AAAA,yBAiBhFP,KAjBgF,CAQhFQ,SARgF;AAAA,MAQhFA,SARgF,iCAQpEN,OARoE;AAAA,0BAiBhFF,KAjBgF,CAShFS,UATgF;AAAA,MAShFA,UATgF,kCASnEL,QATmE;AAAA,MAUhFM,KAVgF,GAiBhFV,KAjBgF,CAUhFU,KAVgF;AAAA,MAWhFC,IAXgF,GAiBhFX,KAjBgF,CAWhFW,IAXgF;AAAA,MAYhFC,QAZgF,GAiBhFZ,KAjBgF,CAYhFY,QAZgF;AAAA,MAahFj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AAQ,EAAEY;AATd,KAUQN,UAVR,EADJ,EAcI;AAAK,IAAA,SAAS,YAAKtB,SAAL;AAAd,KACI;AAAK,IAAA,SAAS,YAAKA,SAAL;AAAd,IADJ,EAGI;AAAK,IAAA,SAAS,YAAKA,SAAL;AAAd,KACI,oBAAC,IAAD;AAAM,IAAA,IAAI,EAAEkC;AAAZ,IADJ,CAHJ,CAdJ,CAdJ,EAqCI;AAAK,IAAA,SAAS,YAAKlC,SAAL;AAAd,KACKkB,KAAK,IACF,oBAAC,UAAD;AAAY,IAAA,OAAO,EAAEM,OAArB;AAA8B,IAAA,SAAS,YAAKxB,SAAL,YAAvC;AAAgE,IAAA,KAAK,EAAEG;AAAvE,KACKe,KADL,CAFR,EAMKL,MAAM,IACH,oBAAC,WAAD;AAAa,IAAA,SAAS,YAAKb,SAAL,aAAtB;AAAgD,IAAA,KAAK,EAAEG;AAAvD,KACKU,MADL,CAPR,CArCJ,CADJ;AAoDH,CA9EsE;AA+EvEP,QAAQ,CAAC6B,WAAT,GAAuBpC,cAAvB;AACAO,QAAQ,CAACK,SAAT,GAAqBX,SAArB;AACAM,QAAQ,CAAC8B,YAAT,GAAwBlC,aAAxB;;;;"}
1
+ {"version":3,"file":"Checkbox2.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useMemo, forwardRef, ReactNode, SyntheticEvent, InputHTMLAttributes } from 'react';\n\nimport classNames from 'classnames';\nimport { uid } from 'uid';\n\nimport { mdiCheck } from '@lumx/icons';\n\nimport { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface CheckboxProps extends GenericProps {\n /** Helper text. */\n helper?: string;\n /** Native input id property. */\n id?: string;\n /** Native input ref. */\n inputRef?: React.Ref<HTMLInputElement>;\n /** Whether it is checked or not. */\n isChecked?: boolean;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Label text. */\n label?: ReactNode;\n /** Native input name property. */\n name?: string;\n /** Theme adapting the component to light or dark background. */\n theme?: Theme;\n /** Native input value property. */\n value?: string;\n /** On change callback. */\n onChange?(isChecked: boolean, value?: string, name?: string, event?: SyntheticEvent): void;\n /** optional props for input */\n inputProps?: InputHTMLAttributes<HTMLInputElement>;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Checkbox';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<CheckboxProps> = {\n theme: Theme.light,\n};\n\n/**\n * Checkbox component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n checked,\n className,\n disabled,\n helper,\n id,\n inputRef,\n isChecked = checked,\n isDisabled = disabled,\n label,\n name,\n onChange,\n theme,\n value,\n inputProps = {},\n ...forwardedProps\n } = props;\n const inputId = useMemo(() => id || `${CLASSNAME.toLowerCase()}-${uid()}`, [id]);\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(!isChecked, value, name, event);\n }\n };\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isChecked,\n isDisabled,\n isUnchecked: !isChecked,\n prefix: CLASSNAME,\n theme,\n }),\n )}\n >\n <div className={`${CLASSNAME}__input-wrapper`}>\n <input\n ref={inputRef}\n type=\"checkbox\"\n id={inputId}\n className={`${CLASSNAME}__input-native`}\n tabIndex={isDisabled ? -1 : 0}\n name={name}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n aria-describedby={helper ? `${inputId}-helper` : undefined}\n {...inputProps}\n />\n\n <div className={`${CLASSNAME}__input-placeholder`}>\n <div className={`${CLASSNAME}__input-background`} />\n\n <div className={`${CLASSNAME}__input-indicator`}>\n <Icon icon={mdiCheck} />\n </div>\n </div>\n </div>\n\n <div className={`${CLASSNAME}__content`}>\n {label && (\n <InputLabel htmlFor={inputId} className={`${CLASSNAME}__label`} theme={theme}>\n {label}\n </InputLabel>\n )}\n {helper && (\n <InputHelper id={`${inputId}-helper`} className={`${CLASSNAME}__helper`} theme={theme}>\n {helper}\n </InputHelper>\n )}\n </div>\n </div>\n );\n});\nCheckbox.displayName = COMPONENT_NAME;\nCheckbox.className = CLASSNAME;\nCheckbox.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","theme","Theme","light","Checkbox","forwardRef","props","ref","checked","className","disabled","helper","id","inputRef","isChecked","isDisabled","label","name","onChange","value","inputProps","forwardedProps","inputId","useMemo","toLowerCase","uid","handleChange","event","classNames","handleBasicClasses","isUnchecked","prefix","undefined","mdiCheck","displayName","defaultProps"],"mappings":";;;;;;;;;AAUA;;;;AA4BA;;;AAGA,IAAMA,cAAc,GAAG,UAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;AAEA;;;;AAGA,IAAMG,aAAqC,GAAG;AAC1CC,EAAAA,KAAK,EAAEC,KAAK,CAACC;AAD6B,CAA9C;AAIA;;;;;;;;IAOaC,QAA6C,GAAGC,UAAU,CAAC,UAACC,KAAD,EAAQC,GAAR,EAAgB;AAAA,MAEhFC,OAFgF,GAiBhFF,KAjBgF,CAEhFE,OAFgF;AAAA,MAGhFC,SAHgF,GAiBhFH,KAjBgF,CAGhFG,SAHgF;AAAA,MAIhFC,QAJgF,GAiBhFJ,KAjBgF,CAIhFI,QAJgF;AAAA,MAKhFC,MALgF,GAiBhFL,KAjBgF,CAKhFK,MALgF;AAAA,MAMhFC,EANgF,GAiBhFN,KAjBgF,CAMhFM,EANgF;AAAA,MAOhFC,QAPgF,GAiBhFP,KAjBgF,CAOhFO,QAPgF;AAAA,yBAiBhFP,KAjBgF,CAQhFQ,SARgF;AAAA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G,EAAEe,QADT;AAEI,IAAA,IAAI,EAAC,UAFT;AAGI,IAAA,EAAE,EAAES,OAHR;AAII,IAAA,SAAS,YAAKxB,SAAL,mBAJb;AAKI,IAAA,QAAQ,EAAEiB,UAAU,GAAG,CAAC,CAAJ,GAAQ,CALhC;AAMI,IAAA,IAAI,EAAEE,IANV;AAOI,IAAA,KAAK,EAAEE,KAPX;AAQI,IAAA,OAAO,EAAEL,SARb;AASI,IAAA,QAAQ,EAAEY,YATd;AAUI,wBAAkBf,MAAM,aAAMW,OAAN,eAAyBU;AAVrD,KAWQZ,UAXR,EADJ,EAeI;AAAK,IAAA,SAAS,YAAKtB,SAAL;AAAd,KACI;AAAK,IAAA,SAAS,YAAKA,SAAL;AAAd,IADJ,EAGI;AAAK,IAAA,SAAS,YAAKA,SAAL;AAAd,KACI,oBAAC,IAAD;AAAM,IAAA,IAAI,EAAEmC;AAAZ,IADJ,CAHJ,CAfJ,CAdJ,EAsCI;AAAK,IAAA,SAAS,YAAKnC,SAAL;AAAd,KACKkB,KAAK,IACF,oBAAC,UAAD;AAAY,IAAA,OAAO,EAAEM,OAArB;AAA8B,IAAA,SAAS,YAAKxB,SAAL,YAAvC;AAAgE,IAAA,KAAK,EAAEG;AAAvE,KACKe,KADL,CAFR,EAMKL,MAAM,IACH,oBAAC,WAAD;AAAa,IAAA,EAAE,YAAKW,OAAL,YAAf;AAAsC,IAAA,SAAS,YAAKxB,SAAL,aAA/C;AAAyE,IAAA,KAAK,EAAEG;AAAhF,KACKU,MADL,CAPR,CAtCJ,CADJ;AAqDH,CA/EsE;AAgFvEP,QAAQ,CAAC8B,WAAT,GAAuBrC,cAAvB;AACAO,QAAQ,CAACK,SAAT,GAAqBX,SAArB;AACAM,QAAQ,CAAC+B,YAAT,GAAwBnC,aAAxB;;;;"}
@@ -3,30 +3,108 @@ import React, { useEffect, createContext, useContext } from 'react';
3
3
  import { f as onEscapePressed } from './getRootClassName.js';
4
4
  import isEmpty from 'lodash/isEmpty';
5
5
  import { D as DOCUMENT } from './constants.js';
6
+ import last from 'lodash/last';
6
7
  import pull from 'lodash/pull';
7
8
 
9
+ /** CSS selector listing all tabbable elements. */
10
+ var TABBABLE_ELEMENTS_SELECTOR = "a[href], button, textarea, input:not([type=\"hidden\"]):not([hidden]), [tabindex]";
11
+ /** CSS selector matching element that are disabled (should not receive focus). */
12
+
13
+ var DISABLED_SELECTOR = "[hidden], [tabindex=\"-1\"], [disabled]:not([disabled=\"false\"]), [aria-disabled]:not([aria-disabled=\"false\"])";
14
+
15
+ var isNotDisabled = function isNotDisabled(element) {
16
+ return !element.matches(DISABLED_SELECTOR);
17
+ };
8
18
  /**
9
- * Triggers a callback when the escape key is pressed.
19
+ * Get first and last elements focusable in an element.
20
+ *
21
+ * @param parentElement The element in which to search focusable elements.
22
+ * @return first and last focusable elements
23
+ */
24
+
25
+
26
+ function getFirstAndLastFocusable(parentElement) {
27
+ var focusableElements = Array.from(parentElement.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR)); // First non disabled element.
28
+
29
+ var first = focusableElements.find(isNotDisabled); // Last non disabled element.
30
+
31
+ var last = focusableElements.reverse().find(isNotDisabled);
32
+
33
+ if (last && first) {
34
+ return {
35
+ first: first,
36
+ last: last
37
+ };
38
+ }
39
+
40
+ return {};
41
+ }
42
+
43
+ /**
44
+ * Keep track of listeners, only the last registered listener gets activated at any point (previously registered
45
+ * listener are disabled).
46
+ * When a listener gets unregistered, the previously registered listener gets enabled again.
47
+ */
48
+ function makeListenerTowerContext() {
49
+ var LISTENERS = [];
50
+ return {
51
+ register: function register(listener) {
52
+ var _last;
53
+
54
+ // Disable previous listener.
55
+ (_last = last(LISTENERS)) === null || _last === void 0 ? void 0 : _last.disable(); // Keep track of current listener.
56
+
57
+ LISTENERS.push(listener); // Enable current listener.
58
+
59
+ listener.enable();
60
+ },
61
+ unregister: function unregister(listener) {
62
+ var _last2;
63
+
64
+ // Disable current listener.
65
+ listener.disable(); // Remove current listener.
66
+
67
+ pull(LISTENERS, listener); // Enable previous listener.
68
+
69
+ (_last2 = last(LISTENERS)) === null || _last2 === void 0 ? void 0 : _last2.enable();
70
+ }
71
+ };
72
+ }
73
+
74
+ var LISTENERS = makeListenerTowerContext();
75
+ /**
76
+ * Register a global listener on 'Escape' key pressed.
77
+ *
78
+ * If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous
79
+ * one gets activated again.
10
80
  *
11
81
  * @param callback Callback
12
82
  * @param closeOnEscape Disables the hook when false
13
- * @param rootElement Element on which to listen the escape key
14
83
  */
15
84
 
16
85
  function useCallbackOnEscape(callback) {
17
86
  var closeOnEscape = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
18
- var rootElement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
19
87
  useEffect(function () {
20
- if (closeOnEscape && callback && rootElement) {
21
- var onKeyDown = onEscapePressed(callback);
22
- rootElement.addEventListener('keydown', onKeyDown);
23
- return function () {
24
- return rootElement.removeEventListener('keydown', onKeyDown);
25
- };
88
+ var rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
89
+
90
+ if (!closeOnEscape || !callback || !rootElement) {
91
+ return undefined;
26
92
  }
27
93
 
28
- return undefined;
29
- }, [callback, closeOnEscape, rootElement]);
94
+ var onKeyDown = onEscapePressed(callback);
95
+ var listener = {
96
+ enable: function enable() {
97
+ return rootElement.addEventListener('keydown', onKeyDown);
98
+ },
99
+ disable: function disable() {
100
+ return rootElement.removeEventListener('keydown', onKeyDown);
101
+ }
102
+ };
103
+ LISTENERS.register(listener);
104
+ return function () {
105
+ return LISTENERS.unregister(listener);
106
+ };
107
+ }, [callback, closeOnEscape]);
30
108
  }
31
109
 
32
110
  var EVENT_TYPES = ['mousedown', 'touchstart'];
@@ -112,5 +190,5 @@ var ClickAwayProvider = function ClickAwayProvider(_ref) {
112
190
  };
113
191
  ClickAwayProvider.displayName = 'ClickAwayProvider';
114
192
 
115
- export { ClickAwayProvider as C, useCallbackOnEscape as u };
193
+ export { ClickAwayProvider as C, getFirstAndLastFocusable as g, makeListenerTowerContext as m, useCallbackOnEscape as u };
116
194
  //# sourceMappingURL=ClickAwayProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClickAwayProvider.js","sources":["../../../src/hooks/useCallbackOnEscape.ts","../../../src/hooks/useClickAway.tsx","../../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx"],"sourcesContent":["import { DOCUMENT } from '@lumx/react/constants';\nimport { Callback, onEscapePressed } from '@lumx/react/utils';\nimport { useEffect } from 'react';\n\n/**\n * Triggers a callback when the escape key is pressed.\n *\n * @param callback Callback\n * @param closeOnEscape Disables the hook when false\n * @param rootElement Element on which to listen the escape key\n */\nexport function useCallbackOnEscape(\n callback: Callback | undefined,\n closeOnEscape = true,\n rootElement = DOCUMENT?.body,\n) {\n useEffect(() => {\n if (closeOnEscape && callback && rootElement) {\n const onKeyDown = onEscapePressed(callback);\n rootElement.addEventListener('keydown', onKeyDown);\n return () => rootElement.removeEventListener('keydown', onKeyDown);\n }\n return undefined;\n }, [callback, closeOnEscape, rootElement]);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(target: HTMLElement, refs: Array<RefObject<HTMLElement>>): boolean {\n // The target element is not contained in any of the listed element references.\n return !refs.some((e) => e?.current?.contains(target));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements from which we want to detect the click away.\n */\n refs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, refs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = refs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n if (isClickAway(evt.target as HTMLElement, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, refs]);\n}\n","import React, { createContext, useContext, useEffect } from 'react';\nimport pull from 'lodash/pull';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\nconst ClickAwayAncestorContext = createContext<ClickAwayParameters['refs'] | null>(null);\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree we trying to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayParameters> = ({ children, callback, refs }) => {\n const ancestorChildrenRefs = useContext(ClickAwayAncestorContext);\n\n useEffect(() => {\n const { current: currentRefs } = refs;\n const { current: currentAncestorChildrenRefs } = ancestorChildrenRefs || {};\n if (!currentAncestorChildrenRefs || !currentRefs) {\n return undefined;\n }\n // Push current refs to parent.\n currentAncestorChildrenRefs.push(...currentRefs);\n return () => {\n // Pull current refs from parent.\n pull(currentAncestorChildrenRefs, ...currentRefs);\n };\n }, [ancestorChildrenRefs, refs]);\n\n useClickAway({ callback, refs });\n return <ClickAwayAncestorContext.Provider value={refs}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n"],"names":["useCallbackOnEscape","callback","closeOnEscape","rootElement","DOCUMENT","body","useEffect","onKeyDown","onEscapePressed","addEventListener","removeEventListener","undefined","EVENT_TYPES","isClickAway","target","refs","some","e","current","contains","useClickAway","currentRefs","isEmpty","listener","evt","forEach","evtType","document","ClickAwayAncestorContext","createContext","ClickAwayProvider","children","ancestorChildrenRefs","useContext","currentAncestorChildrenRefs","push","pull","displayName"],"mappings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CAAT;AAcAK,EAAAA,YAAY,CAAC;AAAEnB,IAAAA,QAAQ,EAARA,QAAF;AAAYc,IAAAA,IAAI,EAAJA;AAAZ,GAAD,CAAZ;AACA,SAAO,oBAAC,wBAAD,CAA0B,QAA1B;AAAmC,IAAA,KAAK,EAAEA;AAA1C,KAAiDgB,QAAjD,CAAP;AACH;AACDD,iBAAiB,CAACO,WAAlB,GAAgC,mBAAhC;;;;"}
1
+ {"version":3,"file":"ClickAwayProvider.js","sources":["../../../src/utils/focus/getFirstAndLastFocusable.ts","../../../src/utils/makeListenerTowerContext.ts","../../../src/hooks/useCallbackOnEscape.ts","../../../src/hooks/useClickAway.tsx","../../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx"],"sourcesContent":["/** CSS selector listing all tabbable elements. */\nconst TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type=\"hidden\"]):not([hidden]), [tabindex]`;\n\n/** CSS selector matching element that are disabled (should not receive focus). */\nconst DISABLED_SELECTOR = `[hidden], [tabindex=\"-1\"], [disabled]:not([disabled=\"false\"]), [aria-disabled]:not([aria-disabled=\"false\"])`;\n\nconst isNotDisabled = (element: HTMLElement) => !element.matches(DISABLED_SELECTOR);\n\n/**\n * Get first and last elements focusable in an element.\n *\n * @param parentElement The element in which to search focusable elements.\n * @return first and last focusable elements\n */\nexport function getFirstAndLastFocusable(parentElement: HTMLElement) {\n const focusableElements = Array.from(parentElement.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR));\n\n // First non disabled element.\n const first = focusableElements.find(isNotDisabled);\n // Last non disabled element.\n const last = focusableElements.reverse().find(isNotDisabled);\n\n if (last && first) {\n return { first, last };\n }\n return {};\n}\n","import last from 'lodash/last';\nimport pull from 'lodash/pull';\n\nexport type Listener = { enable(): void; disable(): void };\n\n/**\n * Keep track of listeners, only the last registered listener gets activated at any point (previously registered\n * listener are disabled).\n * When a listener gets unregistered, the previously registered listener gets enabled again.\n */\nexport function makeListenerTowerContext() {\n const LISTENERS: Listener[] = [];\n\n return {\n register(listener: Listener) {\n // Disable previous listener.\n last(LISTENERS)?.disable();\n // Keep track of current listener.\n LISTENERS.push(listener);\n // Enable current listener.\n listener.enable();\n },\n unregister(listener: Listener) {\n // Disable current listener.\n listener.disable();\n // Remove current listener.\n pull(LISTENERS, listener);\n // Enable previous listener.\n last(LISTENERS)?.enable();\n },\n };\n}\n","import { DOCUMENT } from '@lumx/react/constants';\nimport { Callback, onEscapePressed } from '@lumx/react/utils';\nimport { useEffect } from 'react';\nimport { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';\n\nconst LISTENERS = makeListenerTowerContext();\n\n/**\n * Register a global listener on 'Escape' key pressed.\n *\n * If multiple listener are registered, only the last one is maintained. When a listener is unregistered, the previous\n * one gets activated again.\n *\n * @param callback Callback\n * @param closeOnEscape Disables the hook when false\n */\nexport function useCallbackOnEscape(callback: Callback | undefined, closeOnEscape = true) {\n useEffect(() => {\n const rootElement = DOCUMENT?.body;\n if (!closeOnEscape || !callback || !rootElement) {\n return undefined;\n }\n const onKeyDown = onEscapePressed(callback);\n\n const listener: Listener = {\n enable: () => rootElement.addEventListener('keydown', onKeyDown),\n disable: () => rootElement.removeEventListener('keydown', onKeyDown),\n };\n\n LISTENERS.register(listener);\n return () => LISTENERS.unregister(listener);\n }, [callback, closeOnEscape]);\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils';\n\nimport isEmpty from 'lodash/isEmpty';\n\nconst EVENT_TYPES = ['mousedown', 'touchstart'];\n\nfunction isClickAway(target: HTMLElement, refs: Array<RefObject<HTMLElement>>): boolean {\n // The target element is not contained in any of the listed element references.\n return !refs.some((e) => e?.current?.contains(target));\n}\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements from which we want to detect the click away.\n */\n refs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, refs }: ClickAwayParameters): void {\n useEffect(() => {\n const { current: currentRefs } = refs;\n if (!callback || !currentRefs || isEmpty(currentRefs)) {\n return undefined;\n }\n const listener: EventListener = (evt) => {\n if (isClickAway(evt.target as HTMLElement, currentRefs)) {\n callback(evt);\n }\n };\n\n EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n }, [callback, refs]);\n}\n","import React, { createContext, useContext, useEffect } from 'react';\nimport pull from 'lodash/pull';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\nconst ClickAwayAncestorContext = createContext<ClickAwayParameters['refs'] | null>(null);\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree we trying to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayParameters> = ({ children, callback, refs }) => {\n const ancestorChildrenRefs = useContext(ClickAwayAncestorContext);\n\n useEffect(() => {\n const { current: currentRefs } = refs;\n const { current: currentAncestorChildrenRefs } = ancestorChildrenRefs || {};\n if (!currentAncestorChildrenRefs || !currentRefs) {\n return undefined;\n }\n // Push current refs to parent.\n currentAncestorChildrenRefs.push(...currentRefs);\n return () => {\n // Pull current refs from parent.\n pull(currentAncestorChildrenRefs, ...currentRefs);\n };\n }, [ancestorChildrenRefs, refs]);\n\n useClickAway({ callback, refs });\n return <ClickAwayAncestorContext.Provider value={refs}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n"],"names":["TABBABLE_ELEMENTS_SELECTOR","DISABLED_SELECTOR","isNotDisabled","element","matches","getFirstAndLastFocusable","parentElement","focusableElements","Array","from","querySelectorAll","first","find","last","reverse","makeListenerTowerContext","LISTENERS","register","listener","disable","push","enable","unregister","pull","useCallbackOnEscape","callback","closeOnEscape","useEffect","rootElement","DOCUMENT","body","undefined","onKeyDown","onEscapePressed","addEventListener","removeEventListener","EVENT_TYPES","isClickAway","target","refs","some","e","current","contains","useClickAway","currentRefs","isEmpty","evt","forEach","evtType","document","ClickAwayAncestorContext","createContext","ClickAwayProvider","children","ancestorChildrenRefs","useContext","currentAncestorChildrenRefs","displayName"],"mappings":";;;;;;;;AAAA;AACA,IAAMA,0BAA0B,sFAAhC;AAEA;;AACA,IAAMC,iBAAiB,sHAAvB;;AAEA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,OAAD;AAAA,SAA0B,CAACA,OAAO,CAACC,OAAR,CAAgBH,iBAAhB,CAA3B;AAAA,CAAtB;AAEA;;;;;;;;AAMO,SAASI,wBAAT,CAAkCC,aAAlC,EAA8D;AACjE,MAAMC,iBAAiB,GAAGC,KAAK,CAACC,IAAN,CAAWH,aAAa,CAACI,gBAAd,CAA4CV,0BAA5C,CAAX,CAA1B,CADiE;;AAIjE,MAAMW,KAAK,GAAGJ,iBAAiB,CAACK,IAAlB,CAAuBV,aAAvB,CAAd,CAJiE;;AAMjE,MAAMW,IAAI,GAAGN,iBAAiB,CAACO,OAAlB,GAA4BF,IAA5B,CAAiCV,aAAjC,CAAb;;AAEA,MAAIW,IAAI,IAAIF,KAAZ,EAAmB;AACf,WAAO;AAAEA,MAAAA,KAAK,EAALA,KAAF;AAASE,MAAAA,IAAI,EAAJA;AAAT,KAAP;AACH;;AACD,SAAO,EAAP;AACH;;ACrBD;;;;;AAKO,SAASE,wBAAT,GAAoC;AACvC,MAAMC,SAAqB,GAAG,EAA9B;AAEA,SAAO;AACHC,IAAAA,QADG,oBACMC,QADN,EAC0B;AAAA;;AACzB;AACA,eAAAL,IAAI,CAACG,SAAD,CAAJ,gDAAiBG,OAAjB,GAFyB;;AAIzBH,MAAAA,SAAS,CAACI,IAAV,CAAeF,QAAf,EAJyB;;AAMzBA,MAAAA,QA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MAAXc,IAAW,QAAXA,IAAW;AAC9F,MAAMgB,oBAAoB,GAAGC,UAAU,CAACL,wBAAD,CAAvC;AAEAxB,EAAAA,SAAS,CAAC,YAAM;AAAA,QACKkB,WADL,GACqBN,IADrB,CACJG,OADI;;AAAA,gBAEqCa,oBAAoB,IAAI,EAF7D;AAAA,QAEKE,2BAFL,SAEJf,OAFI;;AAGZ,QAAI,CAACe,2BAAD,IAAgC,CAACZ,WAArC,EAAkD;AAC9C,aAAOd,SAAP;AACH,KALW;;;AAOZ0B,IAAAA,2BAA2B,CAACrC,IAA5B,OAAAqC,2BAA2B,qBAASZ,WAAT,EAA3B;AACA,WAAO,YAAM;AACT;AACAtB,MAAAA,IAAI,MAAJ,UAAKkC,2BAAL,4BAAqCZ,WAArC;AACH,KAHD;AAIH,GAZQ,EAYN,CAACU,oBAAD,EAAuBhB,IAAvB,CAZM,CAAT;AAcAK,EAAAA,YAAY,CAAC;AAAEnB,IAAAA,QAAQ,EAARA,QAAF;AAAYc,IAAAA,IAAI,EAAJA;AAAZ,GAAD,CAAZ;AACA,SAAO,oBAAC,wBAAD,CAA0B,QAA1B;AAAmC,IAAA,KAAK,EAAEA;AAA1C,KAAiDe,QAAjD,CAAP;AACH;AACDD,iBAAiB,CAACK,WAAlB,GAAgC,mBAAhC;;;;"}
@@ -263,13 +263,17 @@ var DatePickerField = forwardRef(function (props, ref) {
263
263
  value = props.value,
264
264
  forwardedProps = _objectWithoutProperties(props, ["defaultMonth", "disabled", "isDisabled", "locale", "maxDate", "minDate", "name", "nextButtonProps", "onChange", "previousButtonProps", "value"]);
265
265
 
266
- var wrapperRef = useRef(null);
266
+ var _useState = useState(null),
267
+ _useState2 = _slicedToArray(_useState, 2),
268
+ wrapperElement = _useState2[0],
269
+ setWrapperElement = _useState2[1];
270
+
267
271
  var anchorRef = useRef(null);
268
272
 
269
- var _useState = useState(false),
270
- _useState2 = _slicedToArray(_useState, 2),
271
- isOpen = _useState2[0],
272
- setIsOpen = _useState2[1];
273
+ var _useState3 = useState(false),
274
+ _useState4 = _slicedToArray(_useState3, 2),
275
+ isOpen = _useState4[0],
276
+ setIsOpen = _useState4[1];
273
277
 
274
278
  var toggleSimpleMenu = function toggleSimpleMenu() {
275
279
  setIsOpen(!isOpen);
@@ -287,8 +291,12 @@ var DatePickerField = forwardRef(function (props, ref) {
287
291
  }; // Handle focus trap.
288
292
 
289
293
 
290
- var todayOrSelectedDateRef = useRef(null);
291
- useFocusTrap(todayOrSelectedDateRef.current && wrapperRef.current, todayOrSelectedDateRef.current);
294
+ var _useState5 = useState(null),
295
+ _useState6 = _slicedToArray(_useState5, 2),
296
+ todayOrSelectedDate = _useState6[0],
297
+ setTodayOrSelectedDate = _useState6[1];
298
+
299
+ useFocusTrap(isOpen && wrapperElement, todayOrSelectedDate);
292
300
 
293
301
  var onTextFieldChange = function onTextFieldChange(textFieldValue, textFieldName, event) {
294
302
  if (!textFieldValue) {
@@ -320,19 +328,18 @@ var DatePickerField = forwardRef(function (props, ref) {
320
328
  onClose: onClose,
321
329
  closeOnClickAway: true,
322
330
  closeOnEscape: true
323
- }, React.createElement("div", {
324
- ref: wrapperRef
325
331
  }, React.createElement(DatePicker, {
332
+ ref: setWrapperElement,
326
333
  locale: locale,
327
334
  maxDate: maxDate,
328
335
  minDate: minDate,
329
336
  value: value,
330
337
  onChange: onDatePickerChange,
331
- todayOrSelectedDateRef: todayOrSelectedDateRef,
338
+ todayOrSelectedDateRef: setTodayOrSelectedDate,
332
339
  defaultMonth: defaultMonth,
333
340
  nextButtonProps: nextButtonProps,
334
341
  previousButtonProps: previousButtonProps
335
- }))) : null);
342
+ })) : null);
336
343
  });
337
344
  DatePickerField.displayName = COMPONENT_NAME$2;
338
345
 
@@ -1 +1 @@
1
- {"version":3,"file":"DatePickerField.js","sources":["../../../src/components/date-picker/constants.ts","../../../../lumx-core/src/js/date-picker.ts","../../../src/components/date-picker/DatePickerControlled.tsx","../../../src/components/date-picker/DatePicker.tsx","../../../src/components/date-picker/DatePickerField.tsx"],"sourcesContent":["import { getRootClassName } from '@lumx/react/utils';\n\n/**\n * Component display name.\n */\nexport const COMPONENT_NAME = 'DatePicker';\n\n/**\n * Component default class name and class prefix.\n */\nexport const CLASSNAME = getRootClassName(COMPONENT_NAME);\n","import range from 'lodash/range';\nimport mMoment, { Moment } from 'moment';\nimport { extendMoment } from 'moment-range';\n\nconst moment = extendMoment(mMoment as any);\n\nconst DAYS_PER_WEEK = 7;\n\ninterface AnnotatedDate {\n date: Moment;\n isDisplayed: boolean;\n isClickable: boolean;\n isToday: boolean;\n}\n\n/**\n * Get the list of days in a week based on locale.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @return The list of days in a week based on locale.\n */\nexport function getWeekDays(locale: string): Moment[] {\n return range(DAYS_PER_WEEK).map((_, i) => moment().locale(locale).weekday(i));\n}\n\n/**\n * Get month calendar based on locale and start date.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @param selectedMonth The selected month.\n * @return The list of days in a week based on locale.\n */\nexport function getMonthCalendar(locale: string, selectedMonth?: Moment): Moment[] {\n const firstDayOfMonth = moment(selectedMonth).startOf('month');\n const endDayOfMonth = moment(selectedMonth).endOf('month');\n // The first day of the week depends on the locale used. In FR the first day is a monday but in EN the first day is sunday\n const firstDay = firstDayOfMonth.locale(locale).startOf('week');\n const monthRange = moment.range(firstDay.toDate(), endDayOfMonth.toDate());\n\n return Array.from(monthRange.by('day'));\n}\n\n/**\n * Get month calendar based on locale and start date.\n * Each day is annotated to know if they are displayed and/or clickable.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @param minDate The first selectable date.\n * @param maxDate The last selectable date.\n * @param selectedMonth The selected month.\n * @return The list of days in a week based on locale.\n */\nexport function getAnnotatedMonthCalendar(\n locale: string,\n minDate?: Date,\n maxDate?: Date,\n selectedMonth?: Moment,\n): AnnotatedDate[] {\n const month = moment(selectedMonth).locale(locale).month();\n\n const clickableRange = moment.range(minDate as Date, maxDate as Date);\n\n return getMonthCalendar(locale, selectedMonth).map((date) => {\n return {\n date,\n isClickable: clickableRange.contains(date),\n isDisplayed: date.month() === month,\n isToday: date.isSame(moment(), 'day'),\n };\n });\n}\n","import React, { forwardRef } from 'react';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { DatePickerProps, Emphasis, IconButton, Toolbar } from '@lumx/react';\nimport { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';\nimport { getAnnotatedMonthCalendar, getWeekDays } from '@lumx/core/js/date-picker';\nimport { Comp } from '@lumx/react/utils';\nimport { CLASSNAME } from './constants';\n\n/**\n * Defines the props of the component.\n */\nexport interface DatePickerControlledProps extends DatePickerProps {\n /** Selected month to display. */\n selectedMonth: Date;\n /** On previous month change callback. */\n onPrevMonthChange(): void;\n /** On next month change callback. */\n onNextMonthChange(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DatePickerControlled';\n\n/**\n * DatePickerControlled component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePickerControlled: Comp<DatePickerControlledProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n locale,\n maxDate,\n minDate,\n nextButtonProps,\n onChange,\n onNextMonthChange,\n onPrevMonthChange,\n previousButtonProps,\n selectedMonth,\n todayOrSelectedDateRef,\n value,\n } = props;\n const days = React.useMemo(() => {\n return getAnnotatedMonthCalendar(locale, minDate, maxDate, moment(selectedMonth));\n }, [locale, minDate, maxDate, selectedMonth]);\n\n const weekDays = React.useMemo(() => {\n return getWeekDays(locale);\n }, [locale]);\n\n return (\n <div ref={ref} className={`${CLASSNAME}`}>\n <Toolbar\n className={`${CLASSNAME}__toolbar`}\n after={\n <IconButton\n {...nextButtonProps}\n emphasis={Emphasis.low}\n icon={mdiChevronRight}\n onClick={onNextMonthChange}\n />\n }\n before={\n <IconButton\n {...previousButtonProps}\n emphasis={Emphasis.low}\n icon={mdiChevronLeft}\n onClick={onPrevMonthChange}\n />\n }\n label={\n <span className={`${CLASSNAME}__month`}>\n {moment(selectedMonth).locale(locale).format('MMMM YYYY')}\n </span>\n }\n />\n <div className={`${CLASSNAME}__calendar`}>\n <div className={`${CLASSNAME}__week-days ${CLASSNAME}__days-wrapper`}>\n {weekDays.map((weekDay) => (\n <div key={weekDay.unix()} className={`${CLASSNAME}__day-wrapper`}>\n <span className={`${CLASSNAME}__week-day`}>\n {weekDay.format('dddd').slice(0, 1).toLocaleUpperCase()}\n </span>\n </div>\n ))}\n </div>\n\n <div className={`${CLASSNAME}__month-days ${CLASSNAME}__days-wrapper`}>\n {days.map((annotatedDate) => {\n if (annotatedDate.isDisplayed) {\n return (\n <div key={annotatedDate.date.unix()} className={`${CLASSNAME}__day-wrapper`}>\n <button\n ref={\n (value && annotatedDate.date.isSame(value, 'day')) ||\n (!value && annotatedDate.isToday)\n ? todayOrSelectedDateRef\n : null\n }\n className={classNames(`${CLASSNAME}__month-day`, {\n [`${CLASSNAME}__month-day--is-selected`]:\n value && annotatedDate.date.isSame(value, 'day'),\n [`${CLASSNAME}__month-day--is-today`]:\n annotatedDate.isClickable && annotatedDate.isToday,\n })}\n disabled={!annotatedDate.isClickable}\n type=\"button\"\n onClick={() => onChange(moment(annotatedDate.date).toDate())}\n >\n <span>{annotatedDate.date.format('DD')}</span>\n </button>\n </div>\n );\n }\n return <div key={annotatedDate.date.unix()} className={`${CLASSNAME}__day-wrapper`} />;\n })}\n </div>\n </div>\n </div>\n );\n});\nDatePickerControlled.displayName = COMPONENT_NAME;\nDatePickerControlled.className = CLASSNAME;\n","import moment from 'moment';\nimport React, { forwardRef, useState } from 'react';\nimport { Comp } from '@lumx/react/utils';\nimport { CLASSNAME, COMPONENT_NAME } from './constants';\nimport { DatePickerControlled } from './DatePickerControlled';\nimport { DatePickerProps } from './types';\n\n/**\n * DatePicker component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePicker: Comp<DatePickerProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { defaultMonth, locale, value, onChange, ...forwardedProps } = props;\n let castedValue;\n if (value) {\n castedValue = moment(value);\n } else if (defaultMonth) {\n castedValue = moment(defaultMonth);\n }\n if (castedValue && !castedValue.isValid()) {\n // eslint-disable-next-line no-console\n console.warn(`[@lumx/react/DatePicker] Invalid date provided ${castedValue}`);\n }\n const selectedDay = castedValue && castedValue.isValid() ? castedValue : moment();\n\n const [monthOffset, setMonthOffset] = useState(0);\n\n const setPrevMonth = () => setMonthOffset(monthOffset - 1);\n const setNextMonth = () => setMonthOffset(monthOffset + 1);\n\n const onDatePickerChange = (newDate?: Date) => {\n onChange(newDate);\n setMonthOffset(0);\n };\n\n const selectedMonth = moment(selectedDay).locale(locale).add(monthOffset, 'months').toDate();\n\n return (\n <DatePickerControlled\n ref={ref}\n {...forwardedProps}\n defaultMonth={defaultMonth}\n locale={locale}\n value={value}\n onPrevMonthChange={setPrevMonth}\n onNextMonthChange={setNextMonth}\n selectedMonth={selectedMonth}\n onChange={onDatePickerChange}\n />\n );\n});\nDatePicker.displayName = COMPONENT_NAME;\nDatePicker.className = CLASSNAME;\n","import { DatePicker, Placement, Popover, TextField, IconButtonProps } from '@lumx/react';\nimport { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';\n\nimport moment from 'moment';\n\nimport React, { forwardRef, SyntheticEvent, useCallback, useRef, useState } from 'react';\n\nimport { useFocus } from '@lumx/react/hooks/useFocus';\nimport { Comp, GenericProps } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DatePickerFieldProps extends GenericProps {\n /** Default month. */\n defaultMonth?: Date;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Locale (language or region) to use. */\n locale: string;\n /** Date after which dates can't be selected. */\n maxDate?: Date;\n /** Date before which dates can't be selected. */\n minDate?: Date;\n /** Native input name property. */\n name?: string;\n /** Props to pass to the next month button (minus those already set by the DatePickerControlled props). */\n nextButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Props to pass to the previous month button (minus those already set by the DatePickerControlled props). */\n previousButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Currently selected date. */\n value: Date | undefined;\n /** On change callback. */\n onChange(value: Date | undefined, name?: string, event?: SyntheticEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DatePickerField';\n\n/**\n * DatePickerField component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n defaultMonth,\n disabled,\n isDisabled = disabled,\n locale,\n maxDate,\n minDate,\n name,\n nextButtonProps,\n onChange,\n previousButtonProps,\n value,\n ...forwardedProps\n } = props;\n const wrapperRef = useRef(null);\n const anchorRef = useRef(null);\n\n const [isOpen, setIsOpen] = useState(false);\n\n const toggleSimpleMenu = () => {\n setIsOpen(!isOpen);\n };\n\n const onClose = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n useFocus(anchorRef.current, isOpen);\n const handleKeyboardNav = (evt: React.KeyboardEvent) => {\n if ((evt.key === 'Enter' || evt.key === ' ') && toggleSimpleMenu) {\n toggleSimpleMenu();\n }\n };\n\n // Handle focus trap.\n const todayOrSelectedDateRef = useRef<HTMLButtonElement>(null);\n useFocusTrap(todayOrSelectedDateRef.current && wrapperRef.current, todayOrSelectedDateRef.current);\n\n const onTextFieldChange = (textFieldValue: string, textFieldName?: string, event?: SyntheticEvent) => {\n if (!textFieldValue) {\n onChange(undefined, textFieldName, event);\n }\n };\n\n const onDatePickerChange = (newDate?: Date) => {\n onChange(newDate, name);\n onClose();\n };\n\n return (\n <>\n <TextField\n ref={ref}\n {...forwardedProps}\n name={name}\n forceFocusStyle={isOpen}\n textFieldRef={anchorRef}\n value={value ? moment(value).locale(locale).format('LL') : ''}\n onClick={toggleSimpleMenu}\n onChange={onTextFieldChange}\n onKeyPress={handleKeyboardNav}\n isDisabled={isDisabled}\n readOnly\n />\n {isOpen ? (\n <Popover\n anchorRef={anchorRef}\n placement={Placement.BOTTOM_START}\n isOpen={isOpen}\n onClose={onClose}\n closeOnClickAway\n closeOnEscape\n >\n <div ref={wrapperRef}>\n <DatePicker\n locale={locale}\n maxDate={maxDate}\n minDate={minDate}\n value={value}\n onChange={onDatePickerChange}\n todayOrSelectedDateRef={todayOrSelectedDateRef}\n defaultMonth={defaultMonth}\n nextButtonProps={nextButtonProps}\n previousButtonProps={previousButtonProps}\n />\n </div>\n </Popover>\n ) : null}\n </>\n );\n});\nDatePickerField.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","moment","extendMoment","mMoment","DAYS_PER_WEEK","getWeekDays","locale","range","map","_","i","weekday","getMonthCalendar","selectedMonth","firstDayOfMonth","startOf","endDayOfMonth","endOf","firstDay","monthRange","toDate","Array","from","by","getAnnotatedMonthCalendar","minDate","maxDate","month","clickableRange","date","isClickable","contains","isDisplayed","isToday","isSame","DatePickerControlled","forwardRef","props","ref","nextButtonProps","onChange","onNextMonthChange","onPrevMonthChange","previousButtonProps","todayOrSelectedDateRef","value","days","React","useMemo","weekDays","Emphasis","low","mdiChevronRight","mdiChevronLeft","format","weekDay","unix","slice","toLocaleUpperCase","annotatedDate","classNames","displayName","className","DatePicker","defaultMonth","forwardedProps","castedValue","isValid","console","warn","selectedDay","useState","monthOffset","setMonthOffset","setPrevMonth","setNextMonth","onDatePickerChange","newDate","add","DatePickerField","disabled","isDisabled","name","wrapperRef","useRef","anchorRef","isOpen","setIsOpen","toggleSimpleMenu","onClose","useCallback","useFocus","current","handleKeyboardNav","evt","key","useFocusTrap","onTextFieldChange","textFieldValue","textFieldName","event","undefined","Placement","BOTTOM_START"],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;;AAGO,IAAMA,cAAc,GAAG,YAAvB;AAEP;;;;AAGO,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;;ACNP,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OI,IAAA,YAAY,EAAEoB,YAPlB;AAQI,IAAA,eAAe,EAAEzB,eARrB;AASI,IAAA,mBAAmB,EAAEI;AATzB,IADJ,CARJ,CADG,GAuBH,IArCR,CADJ;AAyCH,CA3FoF;AA4FrFoC,eAAe,CAAClB,WAAhB,GAA8B/D,gBAA9B;;;;"}
1
+ {"version":3,"file":"DatePickerField.js","sources":["../../../src/components/date-picker/constants.ts","../../../../lumx-core/src/js/date-picker.ts","../../../src/components/date-picker/DatePickerControlled.tsx","../../../src/components/date-picker/DatePicker.tsx","../../../src/components/date-picker/DatePickerField.tsx"],"sourcesContent":["import { getRootClassName } from '@lumx/react/utils';\n\n/**\n * Component display name.\n */\nexport const COMPONENT_NAME = 'DatePicker';\n\n/**\n * Component default class name and class prefix.\n */\nexport const CLASSNAME = getRootClassName(COMPONENT_NAME);\n","import range from 'lodash/range';\nimport mMoment, { Moment } from 'moment';\nimport { extendMoment } from 'moment-range';\n\nconst moment = extendMoment(mMoment as any);\n\nconst DAYS_PER_WEEK = 7;\n\ninterface AnnotatedDate {\n date: Moment;\n isDisplayed: boolean;\n isClickable: boolean;\n isToday: boolean;\n}\n\n/**\n * Get the list of days in a week based on locale.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @return The list of days in a week based on locale.\n */\nexport function getWeekDays(locale: string): Moment[] {\n return range(DAYS_PER_WEEK).map((_, i) => moment().locale(locale).weekday(i));\n}\n\n/**\n * Get month calendar based on locale and start date.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @param selectedMonth The selected month.\n * @return The list of days in a week based on locale.\n */\nexport function getMonthCalendar(locale: string, selectedMonth?: Moment): Moment[] {\n const firstDayOfMonth = moment(selectedMonth).startOf('month');\n const endDayOfMonth = moment(selectedMonth).endOf('month');\n // The first day of the week depends on the locale used. In FR the first day is a monday but in EN the first day is sunday\n const firstDay = firstDayOfMonth.locale(locale).startOf('week');\n const monthRange = moment.range(firstDay.toDate(), endDayOfMonth.toDate());\n\n return Array.from(monthRange.by('day'));\n}\n\n/**\n * Get month calendar based on locale and start date.\n * Each day is annotated to know if they are displayed and/or clickable.\n *\n * @param locale The locale using to generate the order of days in a week.\n * @param minDate The first selectable date.\n * @param maxDate The last selectable date.\n * @param selectedMonth The selected month.\n * @return The list of days in a week based on locale.\n */\nexport function getAnnotatedMonthCalendar(\n locale: string,\n minDate?: Date,\n maxDate?: Date,\n selectedMonth?: Moment,\n): AnnotatedDate[] {\n const month = moment(selectedMonth).locale(locale).month();\n\n const clickableRange = moment.range(minDate as Date, maxDate as Date);\n\n return getMonthCalendar(locale, selectedMonth).map((date) => {\n return {\n date,\n isClickable: clickableRange.contains(date),\n isDisplayed: date.month() === month,\n isToday: date.isSame(moment(), 'day'),\n };\n });\n}\n","import React, { forwardRef } from 'react';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { DatePickerProps, Emphasis, IconButton, Toolbar } from '@lumx/react';\nimport { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';\nimport { getAnnotatedMonthCalendar, getWeekDays } from '@lumx/core/js/date-picker';\nimport { Comp } from '@lumx/react/utils';\nimport { CLASSNAME } from './constants';\n\n/**\n * Defines the props of the component.\n */\nexport interface DatePickerControlledProps extends DatePickerProps {\n /** Selected month to display. */\n selectedMonth: Date;\n /** On previous month change callback. */\n onPrevMonthChange(): void;\n /** On next month change callback. */\n onNextMonthChange(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DatePickerControlled';\n\n/**\n * DatePickerControlled component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePickerControlled: Comp<DatePickerControlledProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n locale,\n maxDate,\n minDate,\n nextButtonProps,\n onChange,\n onNextMonthChange,\n onPrevMonthChange,\n previousButtonProps,\n selectedMonth,\n todayOrSelectedDateRef,\n value,\n } = props;\n const days = React.useMemo(() => {\n return getAnnotatedMonthCalendar(locale, minDate, maxDate, moment(selectedMonth));\n }, [locale, minDate, maxDate, selectedMonth]);\n\n const weekDays = React.useMemo(() => {\n return getWeekDays(locale);\n }, [locale]);\n\n return (\n <div ref={ref} className={`${CLASSNAME}`}>\n <Toolbar\n className={`${CLASSNAME}__toolbar`}\n after={\n <IconButton\n {...nextButtonProps}\n emphasis={Emphasis.low}\n icon={mdiChevronRight}\n onClick={onNextMonthChange}\n />\n }\n before={\n <IconButton\n {...previousButtonProps}\n emphasis={Emphasis.low}\n icon={mdiChevronLeft}\n onClick={onPrevMonthChange}\n />\n }\n label={\n <span className={`${CLASSNAME}__month`}>\n {moment(selectedMonth).locale(locale).format('MMMM YYYY')}\n </span>\n }\n />\n <div className={`${CLASSNAME}__calendar`}>\n <div className={`${CLASSNAME}__week-days ${CLASSNAME}__days-wrapper`}>\n {weekDays.map((weekDay) => (\n <div key={weekDay.unix()} className={`${CLASSNAME}__day-wrapper`}>\n <span className={`${CLASSNAME}__week-day`}>\n {weekDay.format('dddd').slice(0, 1).toLocaleUpperCase()}\n </span>\n </div>\n ))}\n </div>\n\n <div className={`${CLASSNAME}__month-days ${CLASSNAME}__days-wrapper`}>\n {days.map((annotatedDate) => {\n if (annotatedDate.isDisplayed) {\n return (\n <div key={annotatedDate.date.unix()} className={`${CLASSNAME}__day-wrapper`}>\n <button\n ref={\n (value && annotatedDate.date.isSame(value, 'day')) ||\n (!value && annotatedDate.isToday)\n ? todayOrSelectedDateRef\n : null\n }\n className={classNames(`${CLASSNAME}__month-day`, {\n [`${CLASSNAME}__month-day--is-selected`]:\n value && annotatedDate.date.isSame(value, 'day'),\n [`${CLASSNAME}__month-day--is-today`]:\n annotatedDate.isClickable && annotatedDate.isToday,\n })}\n disabled={!annotatedDate.isClickable}\n type=\"button\"\n onClick={() => onChange(moment(annotatedDate.date).toDate())}\n >\n <span>{annotatedDate.date.format('DD')}</span>\n </button>\n </div>\n );\n }\n return <div key={annotatedDate.date.unix()} className={`${CLASSNAME}__day-wrapper`} />;\n })}\n </div>\n </div>\n </div>\n );\n});\nDatePickerControlled.displayName = COMPONENT_NAME;\nDatePickerControlled.className = CLASSNAME;\n","import moment from 'moment';\nimport React, { forwardRef, useState } from 'react';\nimport { Comp } from '@lumx/react/utils';\nimport { CLASSNAME, COMPONENT_NAME } from './constants';\nimport { DatePickerControlled } from './DatePickerControlled';\nimport { DatePickerProps } from './types';\n\n/**\n * DatePicker component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePicker: Comp<DatePickerProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { defaultMonth, locale, value, onChange, ...forwardedProps } = props;\n let castedValue;\n if (value) {\n castedValue = moment(value);\n } else if (defaultMonth) {\n castedValue = moment(defaultMonth);\n }\n if (castedValue && !castedValue.isValid()) {\n // eslint-disable-next-line no-console\n console.warn(`[@lumx/react/DatePicker] Invalid date provided ${castedValue}`);\n }\n const selectedDay = castedValue && castedValue.isValid() ? castedValue : moment();\n\n const [monthOffset, setMonthOffset] = useState(0);\n\n const setPrevMonth = () => setMonthOffset(monthOffset - 1);\n const setNextMonth = () => setMonthOffset(monthOffset + 1);\n\n const onDatePickerChange = (newDate?: Date) => {\n onChange(newDate);\n setMonthOffset(0);\n };\n\n const selectedMonth = moment(selectedDay).locale(locale).add(monthOffset, 'months').toDate();\n\n return (\n <DatePickerControlled\n ref={ref}\n {...forwardedProps}\n defaultMonth={defaultMonth}\n locale={locale}\n value={value}\n onPrevMonthChange={setPrevMonth}\n onNextMonthChange={setNextMonth}\n selectedMonth={selectedMonth}\n onChange={onDatePickerChange}\n />\n );\n});\nDatePicker.displayName = COMPONENT_NAME;\nDatePicker.className = CLASSNAME;\n","import { DatePicker, Placement, Popover, TextField, IconButtonProps } from '@lumx/react';\nimport { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';\n\nimport moment from 'moment';\n\nimport React, { forwardRef, SyntheticEvent, useCallback, useRef, useState } from 'react';\n\nimport { useFocus } from '@lumx/react/hooks/useFocus';\nimport { Comp, GenericProps } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DatePickerFieldProps extends GenericProps {\n /** Default month. */\n defaultMonth?: Date;\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Locale (language or region) to use. */\n locale: string;\n /** Date after which dates can't be selected. */\n maxDate?: Date;\n /** Date before which dates can't be selected. */\n minDate?: Date;\n /** Native input name property. */\n name?: string;\n /** Props to pass to the next month button (minus those already set by the DatePickerControlled props). */\n nextButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Props to pass to the previous month button (minus those already set by the DatePickerControlled props). */\n previousButtonProps: Pick<IconButtonProps, 'label'> &\n Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;\n /** Currently selected date. */\n value: Date | undefined;\n /** On change callback. */\n onChange(value: Date | undefined, name?: string, event?: SyntheticEvent): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DatePickerField';\n\n/**\n * DatePickerField component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DatePickerField: Comp<DatePickerFieldProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n defaultMonth,\n disabled,\n isDisabled = disabled,\n locale,\n maxDate,\n minDate,\n name,\n nextButtonProps,\n onChange,\n previousButtonProps,\n value,\n ...forwardedProps\n } = props;\n const [wrapperElement, setWrapperElement] = useState<HTMLDivElement | null>(null);\n const anchorRef = useRef(null);\n\n const [isOpen, setIsOpen] = useState(false);\n\n const toggleSimpleMenu = () => {\n setIsOpen(!isOpen);\n };\n\n const onClose = useCallback(() => {\n setIsOpen(false);\n }, []);\n\n useFocus(anchorRef.current, isOpen);\n const handleKeyboardNav = (evt: React.KeyboardEvent) => {\n if ((evt.key === 'Enter' || evt.key === ' ') && toggleSimpleMenu) {\n toggleSimpleMenu();\n }\n };\n\n // Handle focus trap.\n const [todayOrSelectedDate, setTodayOrSelectedDate] = useState<HTMLButtonElement | null>(null);\n useFocusTrap(isOpen && wrapperElement, todayOrSelectedDate);\n\n const onTextFieldChange = (textFieldValue: string, textFieldName?: string, event?: SyntheticEvent) => {\n if (!textFieldValue) {\n onChange(undefined, textFieldName, event);\n }\n };\n\n const onDatePickerChange = (newDate?: Date) => {\n onChange(newDate, name);\n onClose();\n };\n\n return (\n <>\n <TextField\n ref={ref}\n {...forwardedProps}\n name={name}\n forceFocusStyle={isOpen}\n textFieldRef={anchorRef}\n value={value ? moment(value).locale(locale).format('LL') : ''}\n onClick={toggleSimpleMenu}\n onChange={onTextFieldChange}\n onKeyPress={handleKeyboardNav}\n isDisabled={isDisabled}\n readOnly\n />\n {isOpen ? (\n <Popover\n anchorRef={anchorRef}\n placement={Placement.BOTTOM_START}\n isOpen={isOpen}\n onClose={onClose}\n closeOnClickAway\n closeOnEscape\n >\n <DatePicker\n ref={setWrapperElement}\n locale={locale}\n maxDate={maxDate}\n minDate={minDate}\n value={value}\n onChange={onDatePickerChange}\n todayOrSelectedDateRef={setTodayOrSelectedDate}\n defaultMonth={defaultMonth}\n nextButtonProps={nextButtonProps}\n previousButtonProps={previousButtonProps}\n />\n </Popover>\n ) : null}\n </>\n );\n});\nDatePickerField.displayName = COMPONENT_NAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","moment","extendMoment","mMoment","DAYS_PER_WEEK","getWeekDays","locale","range","map","_","i","weekday","getMonthCalendar","selectedMonth","firstDayOfMonth","startOf","endDayOfMonth","endOf","firstDay","monthRange","toDate","Array","from","by","getAnnotatedMonthCalendar","minDate","maxDate","month","clickableRange","date","isClickable","contains","isDisplayed","isToday","isSame","DatePickerControlled","forwardRef","props","ref","nextButtonProps","onChange","onNextMonthChange","onPrevMonthChange","previousButtonProps","todayOrSelectedDateRef","value","days","React","useMemo","weekDays","Emphasis","low","mdiChevronRight","mdiChevronLeft","format","weekDay","unix","slice","toLocaleUpperCase","annotatedDate","classNames","displayName","className","DatePicker","defaultMonth","forwardedProps","castedValue","isValid","console","warn","selectedDay","useState","monthOffset","setMonthOffset","setPrevMonth","setNextMonth","onDatePickerChange","newDate","add","DatePickerField","disabled","isDisabled","name","wrapperElement","setWrapperElement","anchorRef","useRef","isOpen","setIsOpen","toggleSimpleMenu","onClose","useCallback","useFocus","current","handleKeyboardNav","evt","key","todayOrSelectedDate","setTodayOrSelectedDate","useFocusTrap","onTextFieldChange","textFieldValue","textFieldName","event","undefined","Placement","BOTTOM_START"],"mappings":";;;;;;;;;;;;;;;;;;AAEA;;;;AAGO,IAAMA,cAAc,GAAG,YAAvB;AAEP;;;;AAGO,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;;ACNP,IAAMG,MAAM,GAAGC,YAAY,CAACC,QAAD,CAA3B;AAEA,IAAMC,aAAa,GAAG,CAAtB;;AASA;;;;;;AAMO,SAASC,WAAT,CAAqBC,MAArB,EAA+C;AAClD,SAAOC,KAAK,CAACH,aAAD,CAAL,CAAqBI,GAArB,CAAyB,UAACC,CAAD,EAAIC,CAAJ;AAAA,WAAUT,MAAM,GAAGK,MAAT,CAAgBA,MAAhB,EAAwBK,OAAxB,CAAgCD,CAAhC,CAAV;AAAA,GAAzB,CAAP;AACH;AAED;;;;;;;;AAOO,SAASE,gBAAT,CAA0BN,MAA1B,EAA0CO,aAA1C,EAA4E;AAC/E,MAAMC,eAAe,GAAGb,MAAM,CAACY,aAAD,CAAN,CAAsBE,OAAtB,CAA8B,OAA9B,CAAxB;AACA,MAAMC,aAAa,GAAGf,MAAM,CAACY,aAAD,CAAN,CAAsBI,KAAtB,CAA4B,OAA5B,CAAtB,CAF+E;;AAI/E,MAAMC,QAAQ,GAAGJ,eAAe,CAACR,MAAhB,CAAuBA,MAAvB,EAA+BS,OAA/B,CAAuC,MAAvC,CAAjB;AACA,MAAMI,UAAU,GAAGlB,MAAM,CAACM,KAAP,CAAaW,QAAQ,CAACE,MAAT,EAAb,EAAgCJ,aAAa,CAACI,MAAd,EAAhC,CAAnB;AAEA,SAAOC,KAAK,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