@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
@@ -9,6 +9,7 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './Popover2.js';
14
15
  import './mergeRefs.js';
@@ -19,10 +20,10 @@ import 'moment';
19
20
  export { D as DatePicker, a as DatePickerControlled, b as DatePickerField } from './DatePickerField.js';
20
21
  import 'lodash/range';
21
22
  import 'moment-range';
22
- import './useFocusTrap.js';
23
- import 'react-dom';
24
23
  import './ClickAwayProvider.js';
25
24
  import 'lodash/pull';
25
+ import './useFocusTrap.js';
26
+ import 'react-dom';
26
27
  import './InputHelper.js';
27
28
  import './InputLabel.js';
28
29
  import './TextField.js';
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"date-picker.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -16,11 +16,11 @@ import './partitionMulti.js';
16
16
  import 'lodash/get';
17
17
  import './type.js';
18
18
  import './mergeRefs.js';
19
+ import './ClickAwayProvider.js';
20
+ import 'lodash/pull';
19
21
  import './useFocusTrap.js';
20
22
  import 'react-dom';
21
- import './ClickAwayProvider.js';
22
23
  export { D as Dialog } from './Dialog2.js';
23
- import 'lodash/pull';
24
24
  import './useDelayedVisibility.js';
25
25
  import './useDisableBodyScroll.js';
26
26
  import './Progress2.js';
@@ -7,14 +7,15 @@ import 'lodash/isEmpty';
7
7
  import 'lodash/kebabCase';
8
8
  import 'lodash/noop';
9
9
  import './constants.js';
10
+ import 'lodash/last';
10
11
  import 'lodash/get';
11
12
  import './type.js';
12
13
  import './Popover2.js';
13
14
  import './mergeRefs.js';
14
15
  import './renderLink.js';
15
- import 'react-dom';
16
16
  import './ClickAwayProvider.js';
17
17
  import 'lodash/pull';
18
+ import 'react-dom';
18
19
  import './List2.js';
19
20
  export { D as Dropdown } from './Dropdown2.js';
20
21
  //# sourceMappingURL=dropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"dropdown.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -23,9 +23,9 @@ import './renderLink.js';
23
23
  import './ButtonRoot.js';
24
24
  import './IconButton.js';
25
25
  import 'lodash/isFunction';
26
- import 'react-dom';
27
26
  import './ClickAwayProvider.js';
28
27
  import 'lodash/pull';
28
+ import 'react-dom';
29
29
  import './DragHandle.js';
30
30
  export { E as ExpansionPanel } from './ExpansionPanel.js';
31
31
  import './Tooltip2.js';
@@ -0,0 +1,12 @@
1
+ import './_rollupPluginBabelHelpers.js';
2
+ import './components.js';
3
+ import 'react';
4
+ import './getRootClassName.js';
5
+ import 'lodash/isBoolean';
6
+ import 'lodash/isEmpty';
7
+ import 'lodash/kebabCase';
8
+ import 'lodash/noop';
9
+ import 'lodash/castArray';
10
+ import './FlexBox.js';
11
+ export { G as GenericBlock } from './GenericBlock.js';
12
+ //# sourceMappingURL=generic-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generic-block.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -9,16 +9,17 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './Popover2.js';
14
15
  import './mergeRefs.js';
15
16
  import './renderLink.js';
16
17
  import './ButtonRoot.js';
17
18
  import './IconButton.js';
18
- import './useFocusTrap.js';
19
- import 'react-dom';
20
19
  import './ClickAwayProvider.js';
21
20
  import 'lodash/pull';
21
+ import './useFocusTrap.js';
22
+ import 'react-dom';
22
23
  import './useDelayedVisibility.js';
23
24
  import './useDisableBodyScroll.js';
24
25
  export { L as Lightbox } from './Lightbox2.js';
@@ -1 +1 @@
1
- {"version":3,"file":"lightbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"lightbox.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -6,9 +6,10 @@ import 'lodash/isEmpty';
6
6
  import 'lodash/kebabCase';
7
7
  import 'lodash/noop';
8
8
  import './constants.js';
9
+ import 'lodash/last';
9
10
  export { P as Placement, a as Popover } from './Popover2.js';
10
11
  import './mergeRefs.js';
11
- import 'react-dom';
12
12
  import './ClickAwayProvider.js';
13
13
  import 'lodash/pull';
14
+ import 'react-dom';
14
15
  //# sourceMappingURL=popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"popover.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -9,6 +9,7 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './type.js';
14
15
  import './Popover2.js';
@@ -18,9 +19,9 @@ import './ButtonRoot.js';
18
19
  import './IconButton.js';
19
20
  import 'lodash/isFunction';
20
21
  import './Chip2.js';
21
- import 'react-dom';
22
22
  import './ClickAwayProvider.js';
23
23
  import 'lodash/pull';
24
+ import 'react-dom';
24
25
  import './List2.js';
25
26
  import './Dropdown2.js';
26
27
  import './InputHelper.js';
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"select.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,6 +9,7 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './type.js';
14
15
  import './Popover2.js';
@@ -16,9 +17,9 @@ import './mergeRefs.js';
16
17
  import './renderLink.js';
17
18
  import './ButtonRoot.js';
18
19
  import './IconButton.js';
19
- import 'react-dom';
20
20
  import './ClickAwayProvider.js';
21
21
  import 'lodash/pull';
22
+ import 'react-dom';
22
23
  export { S as SideNavigation, a as SideNavigationItem } from './SideNavigationItem.js';
23
24
  import './Tooltip2.js';
24
25
  //# sourceMappingURL=side-navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"side-navigation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"side-navigation.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,6 +9,7 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './Popover2.js';
14
15
  import './mergeRefs.js';
@@ -17,9 +18,9 @@ import './ButtonRoot.js';
17
18
  import './IconButton.js';
18
19
  import 'lodash/isFunction';
19
20
  import 'lodash/range';
20
- import 'react-dom';
21
21
  import './ClickAwayProvider.js';
22
22
  import 'lodash/pull';
23
+ import 'react-dom';
23
24
  export { c as Slides, S as Slideshow, b as SlideshowControls, a as SlideshowItem } from './Slides.js';
24
25
  import 'lodash/uniqueId';
25
26
  import './Tooltip2.js';
@@ -1 +1 @@
1
- {"version":3,"file":"slideshow.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"slideshow.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -9,15 +9,16 @@ import 'lodash/isEmpty';
9
9
  import 'lodash/kebabCase';
10
10
  import 'lodash/noop';
11
11
  import './constants.js';
12
+ import 'lodash/last';
12
13
  import 'lodash/get';
13
14
  import './Popover2.js';
14
15
  import './mergeRefs.js';
15
16
  import './renderLink.js';
16
17
  import './ButtonRoot.js';
17
18
  import './IconButton.js';
18
- import 'react-dom';
19
19
  import './ClickAwayProvider.js';
20
20
  import 'lodash/pull';
21
+ import 'react-dom';
21
22
  import './InputHelper.js';
22
23
  import './InputLabel.js';
23
24
  export { T as TextField } from './TextField.js';
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"text-field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -7,11 +7,12 @@ import 'lodash/isEmpty';
7
7
  import 'lodash/kebabCase';
8
8
  import 'lodash/noop';
9
9
  import './constants.js';
10
+ import 'lodash/last';
10
11
  import 'lodash/get';
11
12
  import './Popover2.js';
12
13
  import './mergeRefs.js';
13
- import 'react-dom';
14
14
  import './ClickAwayProvider.js';
15
15
  import 'lodash/pull';
16
+ import 'react-dom';
16
17
  export { T as Tooltip } from './Tooltip2.js';
17
18
  //# sourceMappingURL=tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"type.js","sources":["../../../src/utils/type.ts"],"sourcesContent":["import get from 'lodash/get';\nimport { ReactElement, ReactNode, Ref } from 'react';\n\n/** Get types of the values of a record. */\nexport type ValueOf<T extends Record<any, any>> = T[keyof T];\n\n/**\n * Properties of a component to use to determine it's name.\n * In the order of preference.\n */\nconst NAME_PROPERTIES: string[] = [\n 'type',\n 'type.displayName',\n 'displayName',\n 'name',\n 'type.name',\n 'props.mdxType',\n '_reactInternalFiber.elementType.name',\n];\n\n/** LumX Component Type. */\nexport type Comp<P, T = HTMLElement> = {\n (props: P & { ref?: Ref<T> }): ReactElement | null;\n /** React component type. */\n readonly $$typeof: symbol;\n /** Component default props. */\n defaultProps?: Partial<P>;\n /** Component name. */\n displayName?: string;\n /** Component base class name. */\n className?: string;\n};\n\n/**\n * Define a generic props types.\n */\nexport interface GenericProps {\n /**\n * Any prop (particularly any supported prop for a HTML element).\n * E.g. classNames, onClick, disabled, ...\n */\n [propName: string]: any;\n}\n\n/**\n * Callback function type alias (use for readability)\n */\nexport type Callback = () => void;\nexport type Predicate<T> = (t: T) => boolean;\n\n/**\n * Create a predicate function that checks if a ReactNode is a react element from the given component.\n *\n * @param component React function component or the component name\n * @return predicate returning true if value is instance of the component\n */\nexport const isComponent = <C>(component: Comp<C, any> | string) => (instance: ReactNode): instance is ReactElement => {\n const componentName = typeof component === 'string' ? component : component.displayName;\n\n return (\n !!get(instance, '$$typeof') &&\n NAME_PROPERTIES.some((nameProperty: string): boolean => get(instance, nameProperty) === componentName)\n );\n};\n\n/**\n * JS falsy values.\n * (excluding `NaN` as it can't be distinguished from `number`)\n */\nexport type Falsy = false | undefined | null | 0 | '';\n"],"names":["NAME_PROPERTIES","isComponent","component","instance","componentName","displayName","get","some","nameProperty"],"mappings":";;AAMA;;;;AAIA,IAAMA,eAAyB,GAAG,CAC9B,MAD8B,EAE9B,kBAF8B,EAG9B,aAH8B,EAI9B,MAJ8B,EAK9B,WAL8B,EAM9B,eAN8B,EAO9B,sCAP8B,CAAlC;AAUA;;AA8BA;;;;;;IAMaC,WAAW,GAAG,SAAdA,WAAc,CAAIC,SAAJ;AAAA,SAAyC,UAACC,QAAD,EAAmD;AACnH,QAAMC,aAAa,GAAG,OAAOF,SAAP,KAAqB,QAArB,GAAgCA,SAAhC,GAA4CA,SAAS,CAACG,WAA5E;AAEA,WACI,CAAC,CAACC,GAAG,CAACH,QAAD,EAAW,UAAX,CAAL,IACAH,eAAe,CAACO,IAAhB,CAAqB,UAACC,YAAD;AAAA,aAAmCF,GAAG,CAACH,QAAD,EAAWK,YAAX,CAAH,KAAgCJ,aAAnE;AAAA,KAArB,CAFJ;AAIH,GAP0B;AAAA;AAS3B;;;;;;;"}
1
+ {"version":3,"file":"type.js","sources":["../../../src/utils/type.ts"],"sourcesContent":["import get from 'lodash/get';\nimport { ReactElement, ReactNode, Ref } from 'react';\n\n/** Get types of the values of a record. */\nexport type ValueOf<T extends Record<any, any>> = T[keyof T];\n\n/**\n * Properties of a component to use to determine it's name.\n * In the order of preference.\n */\nconst NAME_PROPERTIES: string[] = [\n 'type',\n 'type.displayName',\n 'displayName',\n 'name',\n 'type.name',\n 'props.mdxType',\n '_reactInternalFiber.elementType.name',\n];\n\n/** LumX Component Type. */\nexport type Comp<P, T = HTMLElement> = {\n (props: P & { ref?: Ref<T> }): ReactElement | null;\n /** React component type. */\n readonly $$typeof: symbol;\n /** Component default props. */\n defaultProps?: Partial<P>;\n /** Component name. */\n displayName?: string;\n /** Component base class name. */\n className?: string;\n};\n\n/** Union type of all heading elements */\nexport type HeadingElement = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n/**\n * Define a generic props types.\n */\nexport interface GenericProps {\n /**\n * Any prop (particularly any supported prop for a HTML element).\n * E.g. classNames, onClick, disabled, ...\n */\n [propName: string]: any;\n}\n\n/**\n * Callback function type alias (use for readability)\n */\nexport type Callback = () => void;\nexport type Predicate<T> = (t: T) => boolean;\n\n/**\n * Create a predicate function that checks if a ReactNode is a react element from the given component.\n *\n * @param component React function component or the component name\n * @return predicate returning true if value is instance of the component\n */\nexport const isComponent = <C>(component: Comp<C, any> | string) => (instance: ReactNode): instance is ReactElement => {\n const componentName = typeof component === 'string' ? component : component.displayName;\n\n return (\n !!get(instance, '$$typeof') &&\n NAME_PROPERTIES.some((nameProperty: string): boolean => get(instance, nameProperty) === componentName)\n );\n};\n\n/**\n * JS falsy values.\n * (excluding `NaN` as it can't be distinguished from `number`)\n */\nexport type Falsy = false | undefined | null | 0 | '';\n"],"names":["NAME_PROPERTIES","isComponent","component","instance","componentName","displayName","get","some","nameProperty"],"mappings":";;AAMA;;;;AAIA,IAAMA,eAAyB,GAAG,CAC9B,MAD8B,EAE9B,kBAF8B,EAG9B,aAH8B,EAI9B,MAJ8B,EAK9B,WAL8B,EAM9B,eAN8B,EAO9B,sCAP8B,CAAlC;AAUA;;AAiCA;;;;;;IAMaC,WAAW,GAAG,SAAdA,WAAc,CAAIC,SAAJ;AAAA,SAAyC,UAACC,QAAD,EAAmD;AACnH,QAAMC,aAAa,GAAG,OAAOF,SAAP,KAAqB,QAArB,GAAgCA,SAAhC,GAA4CA,SAAS,CAACG,WAA5E;AAEA,WACI,CAAC,CAACC,GAAG,CAACH,QAAD,EAAW,UAAX,CAAL,IACAH,eAAe,CAACO,IAAhB,CAAqB,UAACC,YAAD;AAAA,aAAmCF,GAAG,CAACH,QAAD,EAAWK,YAAX,CAAH,KAAgCJ,aAAnE;AAAA,KAArB,CAFJ;AAIH,GAP0B;AAAA;AAS3B;;;;;;;"}
@@ -1,101 +1,85 @@
1
1
  import { useEffect } from 'react';
2
2
  import { D as DOCUMENT } from './constants.js';
3
+ import { g as getFirstAndLastFocusable, m as makeListenerTowerContext } from './ClickAwayProvider.js';
3
4
 
4
- /** CSS selector listing all tabbable elements. */
5
- var TABBABLE_ELEMENTS_SELECTOR = "a[href], button, textarea, input:not([type=\"hidden\"]), [tabindex]";
6
- /** CSS selector matching element that are disabled (should not receive focus). */
7
-
8
- var DISABLED_SELECTOR = "[tabindex=\"-1\"], [disabled]:not([disabled=\"false\"]), [aria-disabled]:not([aria-disabled=\"false\"])";
9
-
10
- var isNotDisabled = function isNotDisabled(element) {
11
- return !element.matches(DISABLED_SELECTOR);
12
- };
5
+ var FOCUS_TRAPS = makeListenerTowerContext();
13
6
  /**
14
- * Get first and last elements focusable in an element.
7
+ * Trap 'Tab' focus switch inside the `focusZoneElement`.
8
+ *
9
+ * If multiple focus trap are activated, only the last one is maintained and when a focus trap closes, the previous one
10
+ * gets activated again.
15
11
  *
16
- * @param parentElement The element in which to search focusable elements.
17
- * @return first and last focusable elements
12
+ * @param focusZoneElement The element in which to trap the focus.
13
+ * @param focusElement The element to focus when the focus trap is activated (otherwise the first focusable element
14
+ * will be focused).
18
15
  */
19
16
 
17
+ function useFocusTrap(focusZoneElement, focusElement) {
18
+ useEffect(function () {
19
+ // Body element can be undefined in SSR context.
20
+ var rootElement = DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
20
21
 
21
- function getFirstAndLastFocusable(parentElement) {
22
- var focusableElements = Array.from(parentElement.querySelectorAll(TABBABLE_ELEMENTS_SELECTOR)); // First non disabled element.
22
+ if (!rootElement || !focusZoneElement) {
23
+ return undefined;
24
+ } // Trap 'Tab' key down focus switch into the focus zone.
23
25
 
24
- var first = focusableElements.find(isNotDisabled); // Last non disabled element.
25
26
 
26
- var last = focusableElements.reverse().find(isNotDisabled);
27
+ var trapTabFocusInFocusZone = function trapTabFocusInFocusZone(evt) {
28
+ var key = evt.key;
27
29
 
28
- if (last && first) {
29
- return {
30
- first: first,
31
- last: last
32
- };
33
- }
30
+ if (key !== 'Tab') {
31
+ return;
32
+ }
34
33
 
35
- return {};
36
- }
34
+ var focusable = getFirstAndLastFocusable(focusZoneElement); // Prevent focus switch if no focusable available.
37
35
 
38
- /**
39
- * Add a key down event handler to the given root element (document.body by default) to trap the move of focus
40
- * (TAB and SHIFT-TAB keys) inside the given focusZoneElement.
41
- * Will focus the given focus element when activating the focus trap.
42
- *
43
- * @param focusZoneElement The element in which to trap the focus.
44
- * @param focusElement The element to focus when the focus trap is activated.
45
- * @param rootElement The element on which the key down event will be placed.
46
- */
36
+ if (!focusable.first) {
37
+ evt.preventDefault();
38
+ return;
39
+ }
47
40
 
48
- function useFocusTrap(focusZoneElement, focusElement) {
49
- var rootElement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DOCUMENT === null || DOCUMENT === void 0 ? void 0 : DOCUMENT.body;
50
- useEffect(function () {
51
- if (rootElement && focusZoneElement) {
52
- var _ref;
41
+ if ( // No previous focus
42
+ !document.activeElement || // Previous focus is at the end of the focus zone.
43
+ !evt.shiftKey && document.activeElement === focusable.last || // Previous focus is outside the focus zone
44
+ !focusZoneElement.contains(document.activeElement)) {
45
+ focusable.first.focus();
46
+ evt.preventDefault();
47
+ return;
48
+ }
53
49
 
54
- (_ref = document.activeElement) === null || _ref === void 0 ? void 0 : _ref.blur();
50
+ if ( // Focus order reversed
51
+ evt.shiftKey && // Previous focus is at the start of the focus zone.
52
+ document.activeElement === focusable.first) {
53
+ focusable.last.focus();
54
+ evt.preventDefault();
55
+ }
56
+ };
55
57
 
56
- if (focusElement) {
57
- focusElement.focus();
58
+ var focusTrap = {
59
+ enable: function enable() {
60
+ return rootElement.addEventListener('keydown', trapTabFocusInFocusZone);
61
+ },
62
+ disable: function disable() {
63
+ return rootElement.removeEventListener('keydown', trapTabFocusInFocusZone);
58
64
  }
65
+ }; // SETUP:
66
+
67
+ if (focusElement && focusZoneElement.contains(focusElement)) {
68
+ // Focus the given element.
69
+ focusElement.focus();
70
+ } else {
71
+ var _getFirstAndLastFocus;
59
72
 
60
- var onKeyDown = function onKeyDown(evt) {
61
- var key = evt.key;
62
-
63
- if (key !== 'Tab') {
64
- return;
65
- }
66
-
67
- var focusable = getFirstAndLastFocusable(focusZoneElement); // Prevent focus switch if no focusable available.
68
-
69
- if (!focusable.first) {
70
- evt.preventDefault();
71
- return;
72
- }
73
-
74
- if ( // No previous focus
75
- !document.activeElement || // Previous focus is at the end of the focus zone.
76
- !evt.shiftKey && document.activeElement === focusable.last || // Previous focus is outside the focus zone
77
- !focusZoneElement.contains(document.activeElement)) {
78
- focusable.first.focus();
79
- evt.preventDefault();
80
- return;
81
- }
82
-
83
- if ( // Focus order reversed
84
- evt.shiftKey && // Previous focus is at the start of the focus zone.
85
- document.activeElement === focusable.first) {
86
- focusable.last.focus();
87
- evt.preventDefault();
88
- }
89
- };
90
-
91
- rootElement.addEventListener('keydown', onKeyDown);
92
- return function () {
93
- return rootElement.removeEventListener('keydown', onKeyDown);
94
- };
73
+ // Focus the first focusable element in the zone.
74
+ (_getFirstAndLastFocus = getFirstAndLastFocusable(focusZoneElement).first) === null || _getFirstAndLastFocus === void 0 ? void 0 : _getFirstAndLastFocus.focus();
95
75
  }
96
76
 
97
- return undefined;
98
- }, [focusElement, focusZoneElement, rootElement]);
77
+ FOCUS_TRAPS.register(focusTrap); // TEARDOWN:
78
+
79
+ return function () {
80
+ return FOCUS_TRAPS.unregister(focusTrap);
81
+ };
82
+ }, [focusElement, focusZoneElement]);
99
83
  }
100
84
 
101
85
  export { useFocusTrap as u };
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusTrap.js","sources":["../../../src/utils/focus/getFirstAndLastFocusable.ts","../../../src/hooks/useFocusTrap.ts"],"sourcesContent":["/** CSS selector listing all tabbable elements. */\nconst TABBABLE_ELEMENTS_SELECTOR = `a[href], button, textarea, input:not([type=\"hidden\"]), [tabindex]`;\n\n/** CSS selector matching element that are disabled (should not receive focus). */\nconst DISABLED_SELECTOR = `[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 { useEffect } from 'react';\n\nimport { DOCUMENT } from '@lumx/react/constants';\nimport { getFirstAndLastFocusable } from '@lumx/react/utils/focus/getFirstAndLastFocusable';\n\n/**\n * Add a key down event handler to the given root element (document.body by default) to trap the move of focus\n * (TAB and SHIFT-TAB keys) inside the given focusZoneElement.\n * Will focus the given focus element when activating the focus trap.\n *\n * @param focusZoneElement The element in which to trap the focus.\n * @param focusElement The element to focus when the focus trap is activated.\n * @param rootElement The element on which the key down event will be placed.\n */\nexport function useFocusTrap(\n focusZoneElement: HTMLElement | null,\n focusElement?: HTMLElement | null,\n rootElement = DOCUMENT?.body,\n): void {\n useEffect(() => {\n if (rootElement && focusZoneElement) {\n (document.activeElement as HTMLElement)?.blur();\n if (focusElement) {\n focusElement.focus();\n }\n\n const onKeyDown = (evt: KeyboardEvent) => {\n const { key } = evt;\n if (key !== 'Tab') {\n return;\n }\n const focusable = getFirstAndLastFocusable(focusZoneElement);\n\n // Prevent focus switch if no focusable available.\n if (!focusable.first) {\n evt.preventDefault();\n return;\n }\n\n if (\n // No previous focus\n !document.activeElement ||\n // Previous focus is at the end of the focus zone.\n (!evt.shiftKey && document.activeElement === focusable.last) ||\n // Previous focus is outside the focus zone\n !focusZoneElement.contains(document.activeElement)\n ) {\n focusable.first.focus();\n evt.preventDefault();\n return;\n }\n\n if (\n // Focus order reversed\n evt.shiftKey &&\n // Previous focus is at the start of the focus zone.\n document.activeElement === focusable.first\n ) {\n focusable.last.focus();\n evt.preventDefault();\n }\n };\n rootElement.addEventListener('keydown', onKeyDown);\n return () => rootElement.removeEventListener('keydown', onKeyDown);\n }\n return undefined;\n }, [focusElement, focusZoneElement, rootElement]);\n}\n"],"names":["TABBABLE_ELEMENTS_SELECTOR","DISABLED_SELECTOR","isNotDisabled","element","matches","getFirstAndLastFocusable","parentElement","focusableElements","Array","from","querySelectorAll","first","find","last","reverse","useFocusTrap","focusZoneElement","focusElement","rootElement","DOCUMENT","body","useEffect","document","activeElement","blur","focus","onKeyDown","evt","key","focusable","preventDefault","shiftKey","contains","addEventListener","removeEventListener","undefined"],"mappings":";;;AAAA;AACA,IAAMA,0BAA0B,wEAAhC;AAEA;;AACA,IAAMC,iBAAiB,4GAAvB;;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;;;;;;;;;;AASO,SAASE,YAAT,CACHC,gBADG,EAEHC,YAFG,EAIC;AAAA,MADJC,WACI,uEADUC,QACV,aADUA,QACV,uBADUA,QAAQ,CAAEC,IACpB;AACJC,EAAAA,SAAS,CAAC,YAAM;AACZ,QAAIH,WAAW,IAAIF,gBAAnB,EAAqC;AAAA;;AACjC,cAACM,QAAQ,CAACC,aAAV,8CAAyCC,IAAzC;;AACA,UAAIP,YAAJ,EAAkB;AACdA,QAAAA,YAAY,CAACQ,KAAb;AACH;;AAED,UAAMC,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD,EAAwB;AAAA,YAC9BC,GAD8B,GACtBD,GADsB,CAC9BC,GAD8B;;AAEtC,YAAIA,GAAG,KAAK,KAAZ,EAAmB;AACf;AACH;;AACD,YAAMC,SAAS,GAAGxB,wBAAwB,CAACW,gBAAD,CAA1C,CALsC;;AAQtC,YAAI,CAACa,SAAS,CAAClB,KAAf,EAAsB;AAClBgB,UAAAA,GAAG,CAACG,cAAJ;AACA;AACH;;AAED;AAEI,SAACR,QAAQ,CAACC,aAAV;AAEC,SAACI,GAAG,CAACI,QAAL,IAAiBT,QAAQ,CAACC,aAAT,KAA2BM,SAAS,CAAChB,IAFvD;AAIA,SAACG,gBAAgB,CAACgB,QAAjB,CAA0BV,QAAQ,CAACC,aAAnC,CANL,EAOE;AACEM,UAAAA,SAAS,CAAClB,KAAV,CAAgBc,KAAhB;AACAE,UAAAA,GAAG,CAACG,cAAJ;AACA;AACH;;AAED;AAEIH,QAAAA,GAAG,CAACI,QAAJ;AAEAT,QAAAA,QAAQ,CAACC,aAAT,KAA2BM,SAAS,CAAClB,KAJzC,EAKE;AACEkB,UAAAA,SAAS,CAAChB,IAAV,CAAeY,KAAf;AACAE,UAAAA,GAAG,CAACG,cAAJ;AACH;AACJ,OAnCD;;AAoCAZ,MAAAA,WAAW,CAACe,gBAAZ,CAA6B,SAA7B,EAAwCP,SAAxC;AACA,aAAO;AAAA,eAAMR,WAAW,CAACgB,mBAAZ,CAAgC,SAAhC,EAA2CR,SAA3C,CAAN;AAAA,OAAP;AACH;;AACD,WAAOS,SAAP;AACH,GA/CQ,EA+CN,CAAClB,YAAD,EAAeD,gBAAf,EAAiCE,WAAjC,CA/CM,CAAT;AAgDH;;;;"}
1
+ {"version":3,"file":"useFocusTrap.js","sources":["../../../src/hooks/useFocusTrap.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { DOCUMENT } from '@lumx/react/constants';\nimport { getFirstAndLastFocusable } from '@lumx/react/utils/focus/getFirstAndLastFocusable';\nimport { Falsy } from '@lumx/react/utils';\nimport { Listener, makeListenerTowerContext } from '@lumx/react/utils/makeListenerTowerContext';\n\nconst FOCUS_TRAPS = makeListenerTowerContext();\n\n/**\n * Trap 'Tab' focus switch inside the `focusZoneElement`.\n *\n * If multiple focus trap are activated, only the last one is maintained and when a focus trap closes, the previous one\n * gets activated again.\n *\n * @param focusZoneElement The element in which to trap the focus.\n * @param focusElement The element to focus when the focus trap is activated (otherwise the first focusable element\n * will be focused).\n */\nexport function useFocusTrap(focusZoneElement: HTMLElement | Falsy, focusElement?: HTMLElement | null): void {\n useEffect(() => {\n // Body element can be undefined in SSR context.\n const rootElement = DOCUMENT?.body;\n\n if (!rootElement || !focusZoneElement) {\n return undefined;\n }\n\n // Trap 'Tab' key down focus switch into the focus zone.\n const trapTabFocusInFocusZone = (evt: KeyboardEvent) => {\n const { key } = evt;\n if (key !== 'Tab') {\n return;\n }\n const focusable = getFirstAndLastFocusable(focusZoneElement);\n\n // Prevent focus switch if no focusable available.\n if (!focusable.first) {\n evt.preventDefault();\n return;\n }\n\n if (\n // No previous focus\n !document.activeElement ||\n // Previous focus is at the end of the focus zone.\n (!evt.shiftKey && document.activeElement === focusable.last) ||\n // Previous focus is outside the focus zone\n !focusZoneElement.contains(document.activeElement)\n ) {\n focusable.first.focus();\n evt.preventDefault();\n return;\n }\n\n if (\n // Focus order reversed\n evt.shiftKey &&\n // Previous focus is at the start of the focus zone.\n document.activeElement === focusable.first\n ) {\n focusable.last.focus();\n evt.preventDefault();\n }\n };\n\n const focusTrap: Listener = {\n enable: () => rootElement.addEventListener('keydown', trapTabFocusInFocusZone),\n disable: () => rootElement.removeEventListener('keydown', trapTabFocusInFocusZone),\n };\n\n // SETUP:\n if (focusElement && focusZoneElement.contains(focusElement)) {\n // Focus the given element.\n focusElement.focus();\n } else {\n // Focus the first focusable element in the zone.\n getFirstAndLastFocusable(focusZoneElement).first?.focus();\n }\n FOCUS_TRAPS.register(focusTrap);\n\n // TEARDOWN:\n return () => FOCUS_TRAPS.unregister(focusTrap);\n }, [focusElement, focusZoneElement]);\n}\n"],"names":["FOCUS_TRAPS","makeListenerTowerContext","useFocusTrap","focusZoneElement","focusElement","useEffect","rootElement","DOCUMENT","body","undefined","trapTabFocusInFocusZone","evt","key","focusable","getFirstAndLastFocusable","first","preventDefault","document","activeElement","shiftKey","last","contains","focus","focusTrap","enable","addEventListener","disable","removeEventListener","register","unregister"],"mappings":";;;;AAOA,IAAMA,WAAW,GAAGC,wBAAwB,EAA5C;AAEA;;;;;;;;;;;AAUO,SAASC,YAAT,CAAsBC,gBAAtB,EAA6DC,YAA7D,EAAsG;AACzGC,EAAAA,SAAS,CAAC,YAAM;AACZ;AACA,QAAMC,WAAW,GAAGC,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEC,IAA9B;;AAEA,QAAI,CAACF,WAAD,IAAgB,CAACH,gBAArB,EAAuC;AACnC,aAAOM,SAAP;AACH,KANW;;;AASZ,QAAMC,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACC,GAAD,EAAwB;AAAA,UAC5CC,GAD4C,GACpCD,GADoC,CAC5CC,GAD4C;;AAEpD,UAAIA,GAAG,KAAK,KAAZ,EAAmB;AACf;AACH;;AACD,UAAMC,SAAS,GAAGC,wBAAwB,CAACX,gBAAD,CAA1C,CALoD;;AAQpD,UAAI,CAACU,SAAS,CAACE,KAAf,EAAsB;AAClBJ,QAAAA,GAAG,CAACK,cAAJ;AACA;AACH;;AAED;AAEI,OAACC,QAAQ,CAACC,aAAV;AAEC,OAACP,GAAG,CAACQ,QAAL,IAAiBF,QAAQ,CAACC,aAAT,KAA2BL,SAAS,CAACO,IAFvD;AAIA,OAACjB,gBAAgB,CAACkB,QAAjB,CAA0BJ,QAAQ,CAACC,aAAnC,CANL,EAOE;AACEL,QAAAA,SAAS,CAACE,KAAV,CAAgBO,KAAhB;AACAX,QAAAA,GAAG,CAACK,cAAJ;AACA;AACH;;AAED;AAEIL,MAAAA,GAAG,CAACQ,QAAJ;AAEAF,MAAAA,QAAQ,CAACC,aAAT,KAA2BL,SAAS,CAACE,KAJzC,EAKE;AACEF,QAAAA,SAAS,CAACO,IAAV,CAAeE,KAAf;AACAX,QAAAA,GAAG,CAACK,cAAJ;AACH;AACJ,KAnCD;;AAqCA,QAAMO,SAAmB,GAAG;AACxBC,MAAAA,MAAM,EAAE;AAAA,eAAMlB,WAAW,CAACmB,gBAAZ,CAA6B,SAA7B,EAAwCf,uBAAxC,CAAN;AAAA,OADgB;AAExBgB,MAAAA,OAAO,EAAE;AAAA,eAAMpB,WAAW,CAACqB,mBAAZ,CAAgC,SAAhC,EAA2CjB,uBAA3C,CAAN;AAAA;AAFe,KAA5B,CA9CY;;AAoDZ,QAAIN,YAAY,IAAID,gBAAgB,CAACkB,QAAjB,CAA0BjB,YAA1B,CAApB,EAA6D;AACzD;AACAA,MAAAA,YAAY,CAACkB,KAAb;AACH,KAHD,MAGO;AAAA;;AACH;AACA,+BAAAR,wBAAwB,CAACX,gBAAD,CAAxB,CAA2CY,KAA3C,gFAAkDO,KAAlD;AACH;;AACDtB,IAAAA,WAAW,CAAC4B,QAAZ,CAAqBL,SAArB,EA3DY;;AA8DZ,WAAO;AAAA,aAAMvB,WAAW,CAAC6B,UAAZ,CAAuBN,SAAvB,CAAN;AAAA,KAAP;AACH,GA/DQ,EA+DN,CAACnB,YAAD,EAAeD,gBAAf,CA/DM,CAAT;AAgEH;;;;"}
package/esm/index.js CHANGED
@@ -37,11 +37,11 @@ import 'moment';
37
37
  export { D as DatePicker, a as DatePickerControlled, b as DatePickerField } from './_internal/DatePickerField.js';
38
38
  import 'lodash/range';
39
39
  import 'moment-range';
40
+ import './_internal/ClickAwayProvider.js';
41
+ import 'lodash/pull';
40
42
  import './_internal/useFocusTrap.js';
41
43
  import 'react-dom';
42
- import './_internal/ClickAwayProvider.js';
43
44
  export { D as Dialog } from './_internal/Dialog2.js';
44
- import 'lodash/pull';
45
45
  import './_internal/useDelayedVisibility.js';
46
46
  import './_internal/useDisableBodyScroll.js';
47
47
  export { D as DEFAULT_PROPS, a as Divider } from './_internal/Divider2.js';
@@ -52,6 +52,7 @@ export { E as ExpansionPanel } from './_internal/ExpansionPanel.js';
52
52
  export { F as Flag } from './_internal/Flag2.js';
53
53
  import 'lodash/castArray';
54
54
  export { F as FlexBox } from './_internal/FlexBox.js';
55
+ export { G as GenericBlock } from './_internal/GenericBlock.js';
55
56
  export { G as Grid, a as GridItem } from './_internal/GridItem.js';
56
57
  import 'lodash/isObject';
57
58
  export { a as ImageBlock, I as ImageBlockCaptionPosition } from './_internal/ImageBlock.js';
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^2.2.19",
11
- "@lumx/icons": "^2.2.19",
10
+ "@lumx/core": "^2.2.20-alpha-type.1",
11
+ "@lumx/icons": "^2.2.20-alpha-type.1",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.2.6",
@@ -111,7 +111,7 @@
111
111
  },
112
112
  "scripts": {
113
113
  "build": "rollup -c && yarn generate:types",
114
- "generate:types": "dts-bundle-generator --no-check --external-types=react --external-imports=moment -o dist/types.d.ts src/index.ts",
114
+ "generate:types": "dts-bundle-generator --no-check --external-imports=react -o dist/types.d.ts src/index.ts",
115
115
  "prepare": "install-peers || exit 0",
116
116
  "prepublishOnly": "yarn build",
117
117
  "test": "jest --config jest/index.js --coverage --notify --passWithNoTests --detectOpenHandles --runInBand",
@@ -120,6 +120,6 @@
120
120
  "build:storybook": "cd storybook && ./build"
121
121
  },
122
122
  "sideEffects": false,
123
- "version": "2.2.19",
124
- "gitHead": "075b14a949b8ed5897d5fa8087ea4ff993d90eb5"
123
+ "version": "2.2.20-alpha-type.1",
124
+ "gitHead": "ad74227be3187c488044780000f5f66007af2132"
125
125
  }
@@ -1,8 +1,8 @@
1
- import React, { forwardRef, ReactNode, RefObject, SyntheticEvent, useRef } from 'react';
1
+ import React, { forwardRef, ReactNode, SyntheticEvent, useRef } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import { Dropdown, IconButtonProps, Offset, Placement, TextField, Theme } from '@lumx/react';
5
+ import { Dropdown, IconButtonProps, Offset, Placement, TextField, TextFieldProps, Theme } from '@lumx/react';
6
6
 
7
7
  import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
8
8
 
@@ -29,7 +29,7 @@ export interface AutocompleteProps extends GenericProps {
29
29
  * Reference to the <input> or <textarea> element.
30
30
  * @see {@link TextFieldProps#inputRef}
31
31
  */
32
- inputRef?: RefObject<HTMLInputElement>;
32
+ inputRef?: TextFieldProps['inputRef'];
33
33
  /**
34
34
  * The offset that will be applied to the Dropdown position.
35
35
  * @see {@link DropdownProps#offset}
@@ -244,7 +244,7 @@ export const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef(
244
244
  hasError={hasError}
245
245
  helper={helper}
246
246
  icon={icon}
247
- inputRef={mergeRefs(inputAnchorRef, inputRef) as any}
247
+ inputRef={mergeRefs(inputAnchorRef as React.RefObject<HTMLInputElement>, inputRef)}
248
248
  clearButtonProps={clearButtonProps}
249
249
  isDisabled={isDisabled}
250
250
  isRequired={isRequired}
@@ -13,6 +13,7 @@ const DEFAULT_PROPS = Button.defaultProps as any;
13
13
  export const SimpleButton = ({ theme }: any) => {
14
14
  return (
15
15
  <Button
16
+ aria-pressed={boolean('isSelected', Boolean(DEFAULT_PROPS.isSelected))}
16
17
  emphasis={emphasis('Emphasis', DEFAULT_PROPS.emphasis)}
17
18
  theme={theme}
18
19
  rightIcon={select('Right icon', { none: undefined, mdiSend }, undefined)}
@@ -1,4 +1,4 @@
1
- import React, { ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';
1
+ import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, forwardRef, RefObject } from 'react';
2
2
 
3
3
  import isEmpty from 'lodash/isEmpty';
4
4
 
@@ -16,9 +16,9 @@ type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>
16
16
  */
17
17
  export type ButtonSize = Extract<Size, 's' | 'm'>;
18
18
 
19
- export interface BaseButtonProps extends GenericProps {
20
- /** ARIA button label. */
21
- ['aria-label']?: string;
19
+ export interface BaseButtonProps
20
+ extends GenericProps,
21
+ Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'> {
22
22
  /** Color variant. */
23
23
  color?: Color;
24
24
  /** Emphasis variant. */
@@ -112,6 +112,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
112
112
  value={value}
113
113
  checked={isChecked}
114
114
  onChange={handleChange}
115
+ aria-describedby={helper ? `${inputId}-helper` : undefined}
115
116
  {...inputProps}
116
117
  />
117
118
 
@@ -131,7 +132,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
131
132
  </InputLabel>
132
133
  )}
133
134
  {helper && (
134
- <InputHelper className={`${CLASSNAME}__helper`} theme={theme}>
135
+ <InputHelper id={`${inputId}-helper`} className={`${CLASSNAME}__helper`} theme={theme}>
135
136
  {helper}
136
137
  </InputHelper>
137
138
  )}