@onewelcome/react-lib-components 8.6.0 → 8.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/cjs/Button/BaseButton.cjs.js +1 -1
  2. package/dist/cjs/Button/BaseButton.cjs.js.map +1 -1
  3. package/dist/cjs/ContextMenu/ContextMenu.cjs.js +1 -1
  4. package/dist/cjs/ContextMenu/ContextMenu.cjs.js.map +1 -1
  5. package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js +2 -0
  6. package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js.map +1 -0
  7. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
  8. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
  9. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  10. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
  11. package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
  12. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js +2 -0
  13. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -0
  14. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -0
  15. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js.map +1 -0
  16. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js +2 -0
  17. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js.map +1 -0
  18. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js +2 -0
  19. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js.map +1 -0
  20. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js +2 -0
  21. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js.map +1 -0
  22. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js +2 -0
  23. package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js.map +1 -0
  24. package/dist/cjs/DatePicker/DatePicker.cjs.js +1 -1
  25. package/dist/cjs/DatePicker/DatePicker.cjs.js.map +1 -1
  26. package/dist/cjs/DatePicker/DatePicker.module.scss.cjs.js +1 -1
  27. package/dist/cjs/Form/FormGroup/FormGroup.cjs.js +1 -1
  28. package/dist/cjs/Form/FormGroup/FormGroup.cjs.js.map +1 -1
  29. package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js +1 -1
  30. package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js.map +1 -1
  31. package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
  32. package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
  33. package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js +1 -1
  34. package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
  35. package/dist/cjs/Form/Select/useSelectPositionList.cjs.js +1 -1
  36. package/dist/cjs/Form/Select/useSelectPositionList.cjs.js.map +1 -1
  37. package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js +1 -1
  38. package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js.map +1 -1
  39. package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js +1 -1
  40. package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
  41. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
  42. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
  43. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
  44. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
  45. package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
  46. package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
  47. package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
  48. package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
  49. package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
  50. package/dist/cjs/src/components/DataGrid/testUtils.d.ts +7 -1
  51. package/dist/cjs/src/components/DatePicker/DatePicker.d.ts +4 -1
  52. package/dist/cjs/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
  53. package/dist/cjs/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
  54. package/dist/cjs/src/hooks/useClickOutside.cjs.js +2 -0
  55. package/dist/cjs/src/hooks/useClickOutside.cjs.js.map +1 -0
  56. package/dist/cjs/src/hooks/useClickOutside.d.ts +2 -0
  57. package/dist/cjs/src/index.cjs.js +1 -1
  58. package/dist/cjs/src/index.d.ts +1 -0
  59. package/dist/esm/Button/BaseButton.esm.js +5 -2
  60. package/dist/esm/Button/BaseButton.esm.js.map +1 -1
  61. package/dist/esm/ContextMenu/ContextMenu.esm.js +6 -8
  62. package/dist/esm/ContextMenu/ContextMenu.esm.js.map +1 -1
  63. package/dist/esm/ContextMenu/ContextMenuItem.esm.js +3 -3
  64. package/dist/esm/ContextMenu/ContextMenuItem.esm.js.map +1 -1
  65. package/dist/esm/ContextMenu/ContextMenuItem.module.scss.esm.js +2 -2
  66. package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js +35 -0
  67. package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js.map +1 -0
  68. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js +16 -7
  69. package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js.map +1 -1
  70. package/dist/esm/DataGrid/DataGridFilters/DataGridFilters.interfaces.esm.js.map +1 -1
  71. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js +15 -12
  72. package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js.map +1 -1
  73. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js +138 -0
  74. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js.map +1 -0
  75. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js +8 -0
  76. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js.map +1 -0
  77. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js +54 -0
  78. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js.map +1 -0
  79. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js +51 -0
  80. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js.map +1 -0
  81. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js +29 -0
  82. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js.map +1 -0
  83. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js +26 -0
  84. package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js.map +1 -0
  85. package/dist/esm/DatePicker/DatePicker.esm.js +3 -1
  86. package/dist/esm/DatePicker/DatePicker.esm.js.map +1 -1
  87. package/dist/esm/DatePicker/DatePicker.module.scss.esm.js +2 -2
  88. package/dist/esm/Form/FormGroup/FormGroup.esm.js +2 -2
  89. package/dist/esm/Form/FormGroup/FormGroup.esm.js.map +1 -1
  90. package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js +1 -1
  91. package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js.map +1 -1
  92. package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js +9 -5
  93. package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js.map +1 -1
  94. package/dist/esm/Form/Select/SingleSelect/Select.esm.js +9 -5
  95. package/dist/esm/Form/Select/SingleSelect/Select.esm.js.map +1 -1
  96. package/dist/esm/Form/Select/useSelectPositionList.esm.js +8 -11
  97. package/dist/esm/Form/Select/useSelectPositionList.esm.js.map +1 -1
  98. package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js +2 -2
  99. package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js.map +1 -1
  100. package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js +2 -2
  101. package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js.map +1 -1
  102. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
  103. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
  104. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
  105. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
  106. package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
  107. package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
  108. package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
  109. package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
  110. package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
  111. package/dist/esm/src/components/DataGrid/testUtils.d.ts +7 -1
  112. package/dist/esm/src/components/DatePicker/DatePicker.d.ts +4 -1
  113. package/dist/esm/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
  114. package/dist/esm/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
  115. package/dist/esm/src/hooks/useClickOutside.d.ts +2 -0
  116. package/dist/esm/src/hooks/useClickOutside.esm.js +38 -0
  117. package/dist/esm/src/hooks/useClickOutside.esm.js.map +1 -0
  118. package/dist/esm/src/index.d.ts +1 -0
  119. package/dist/esm/src/index.esm.js +1 -0
  120. package/dist/esm/src/index.esm.js.map +1 -1
  121. package/package.json +7 -3
  122. package/src/components/Button/BaseButton.tsx +7 -4
  123. package/src/components/ContextMenu/ContextMenu.tsx +5 -13
  124. package/src/components/DataGrid/DataGridBody/__snapshots__/DataGridBody.test.tsx.snap +4 -4
  125. package/src/components/DataGrid/DataGridFilters/DataGridDateFilter.tsx +65 -0
  126. package/src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx +25 -5
  127. package/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts +18 -1
  128. package/src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx +53 -33
  129. package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss +134 -0
  130. package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.tsx +267 -0
  131. package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.tsx +103 -0
  132. package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.tsx +121 -0
  133. package/{dist/esm/src/hooks/useBodyClick.esm.js → src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.ts} +14 -17
  134. package/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.tsx +50 -0
  135. package/src/components/DataGrid/testUtils.ts +48 -15
  136. package/src/components/DatePicker/DatePicker.module.scss +32 -9
  137. package/src/components/DatePicker/DatePicker.tsx +15 -1
  138. package/src/components/Form/FormGroup/FormGroup.tsx +6 -1
  139. package/src/components/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +2 -2
  140. package/src/components/Form/Select/MultiSelect/MultiSelect.tsx +13 -13
  141. package/src/components/Form/Select/SingleSelect/Select.tsx +13 -13
  142. package/src/components/Form/Select/useSelectPositionList.ts +8 -12
  143. package/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
  144. package/src/components/Form/Wrapper/Wrapper/Wrapper.tsx +3 -0
  145. package/src/hooks/{useBodyClick.ts → useClickOutside.ts} +17 -11
  146. package/src/index.ts +1 -0
  147. package/dist/cjs/src/hooks/useBodyClick.cjs.js +0 -2
  148. package/dist/cjs/src/hooks/useBodyClick.cjs.js.map +0 -1
  149. package/dist/cjs/src/hooks/useBodyClick.d.ts +0 -1
  150. package/dist/esm/src/hooks/useBodyClick.d.ts +0 -1
  151. package/dist/esm/src/hooks/useBodyClick.esm.js.map +0 -1
  152. /package/dist/cjs/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
  153. /package/dist/esm/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Select.esm.js","sources":["../../../../../../../src/components/Form/Select/SingleSelect/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n Fragment,\n ReactElement,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useBodyClick } from \"../../../../hooks/useBodyClick\";\nimport { useDetermineStatusIcon } from \"../../../../hooks/useDetermineStatusIcon\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { filterProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.getAttribute(\"data-value\")!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"]\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n const syncDisplayValue = (val: string) => {\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n }\n });\n };\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(\n child =>\n (child as ReactElement).props.children.toLowerCase().match(filter.toLowerCase()) !== null\n );\n\n const internalChildren = _internalRenderChildren(filteredChildren as ReactElement[]);\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return _internalRenderChildren(filteredChildren as ReactElement[]);\n }\n\n return _internalRenderChildren(children);\n\n function _internalRenderChildren(internalChildren: ReactElement[]) {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n },\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n },\n isSelected: child.props.value === value,\n isSearching: isSearching,\n selectOpened: expanded,\n childIndex: index,\n hasFocus: focusedSelectItem === index,\n shouldClick: shouldClick,\n isAddBtnFocused: addBtnRef.current === document.activeElement\n });\n });\n }\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const icon = useDetermineStatusIcon({ success, error });\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n setFocusedSelectItem(0);\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n }, [expanded, customSelectButtonRef.current, shouldFocusButtonAfterClose]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value]);\n\n useBodyClick(\n (event: MouseEvent) => !(event.target as Element).closest(\".custom-select\") && expanded,\n () => {\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n },\n expanded\n );\n\n const additionalClasses = [];\n expanded && additionalClasses.push(classes.expanded);\n error && additionalClasses.push(classes.error);\n disabled && additionalClasses.push(classes.disabled);\n className && additionalClasses.push(className);\n success && additionalClasses.push(classes.success);\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <Fragment>\n <select\n {...filterProps(rest, /^data-/, false)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div\n {...filterProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses.join(\" \")}`}\n >\n {searchVisible && renderSearch()}\n <button\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses.join(\" \")} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n </div>\n <div className={classes[\"status\"]}>{icon || renderChevronIcon()}</div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\"\n style={{ maxHeight: optionsListMaxHeight.list }}\n >\n {renderOptions()}\n </ul>\n {renderAddNew()}\n </div>\n </div>\n </div>\n </Fragment>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAyBH,MAAM,eAAe,GAAmE,CACtF,EACE,QAAQ,EACR,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,iBAA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SAAS,EAAE,kCAAkC,EAC7C,IAAI,EAAC,SAAS,EACd,KAAK,EAAE,EAAE,SAAS,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAE9C,EAAA,aAAa,EAAE,CACb;AACJ,oBAAA,YAAY,EAAE,CACX,CACF,CACF,CACG,EACX;AACJ,CAAC,CAAC;AACK,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC;;;;"}
1
+ {"version":3,"file":"Select.esm.js","sources":["../../../../../../../src/components/Form/Select/SingleSelect/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n ReactElement,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useClickOutside } from \"../../../../hooks/useClickOutside\";\nimport { useDetermineStatusIcon } from \"../../../../hooks/useDetermineStatusIcon\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { filterProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.getAttribute(\"data-value\")!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"]\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n const syncDisplayValue = (val: string) => {\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n }\n });\n };\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(\n child =>\n (child as ReactElement).props.children.toLowerCase().match(filter.toLowerCase()) !== null\n );\n\n const internalChildren = _internalRenderChildren(filteredChildren as ReactElement[]);\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return _internalRenderChildren(filteredChildren as ReactElement[]);\n }\n\n return _internalRenderChildren(children);\n\n function _internalRenderChildren(internalChildren: ReactElement[]) {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n },\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n },\n isSelected: child.props.value === value,\n isSearching: isSearching,\n selectOpened: expanded,\n childIndex: index,\n hasFocus: focusedSelectItem === index,\n shouldClick: shouldClick,\n isAddBtnFocused: addBtnRef.current === document.activeElement\n });\n });\n }\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const icon = useDetermineStatusIcon({ success, error });\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n setFocusedSelectItem(0);\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n }, [expanded, customSelectButtonRef.current, shouldFocusButtonAfterClose]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value]);\n\n const myElementRef = useRef<HTMLDivElement>(null);\n\n useClickOutside(myElementRef, () => {\n if (!expanded) {\n return;\n }\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n }, [expanded]);\n\n const additionalClasses = [];\n expanded && additionalClasses.push(classes.expanded);\n error && additionalClasses.push(classes.error);\n disabled && additionalClasses.push(classes.disabled);\n className && additionalClasses.push(className);\n success && additionalClasses.push(classes.success);\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <div ref={myElementRef}>\n <select\n {...filterProps(rest, /^data-/, false)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div\n {...filterProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses.join(\" \")}`}\n >\n {searchVisible && renderSearch()}\n <button\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses.join(\" \")} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n </div>\n <div className={classes[\"status\"]}>{icon || renderChevronIcon()}</div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\"\n style={{ maxHeight: optionsListMaxHeight.list }}\n >\n {renderOptions()}\n </ul>\n {renderAddNew()}\n </div>\n </div>\n </div>\n </div>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAwBH,MAAM,eAAe,GAAmE,CACtF,EACE,QAAQ,EACR,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,SAAS,EACT,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,KAAK,GAAG,KAAK,EACb,OAAO,GAAG,KAAK,EACf,KAAK,EACL,UAAU,GAAG,iBAAiB,EAC9B,cAAc,GAAG,kBAAkB,EACnC,QAAQ,EACR,MAAM,EACN,MAAM,EACN,cAAc,EACd,GAAG,IAAI,EACW,EACpB,GAAG,KACD;IACF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3C,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AACxD,IAAA,MAAM,mBAAmB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAA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oBAAA,EAAA,IAAA,EAAA,EAAA,OAAO,CAAQ,CAC3D;AACN,gBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAG,EAAA,IAAI,IAAI,iBAAiB,EAAE,CAAO,CAC/D;YACT,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAC,wBAAwB,EAAA;AACrC,gBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,GAAG,EAAE,mBAAmB,EACxB,SAAS,EAAE,CAAA,aAAA,EAAgB,OAAO,CAAC,cAAc,CAAC,CAAE,CAAA,EACpD,KAAK,EAAE;wBACL,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM;AACpC,wBAAA,OAAO,EAAE,OAAO;wBAChB,SAAS,EAAE,oBAAoB,CAAC,OAAO;wBACvC,aAAa,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM;AACzC,wBAAA,MAAM,EAAE,YAAY,KAAK,QAAQ,CAAC,KAAK,GAAG,SAAS,GAAG,SAAS;AAC/D,wBAAA,SAAS,EAAE,KAAK;AACjB,qBAAA,EAAA;oBAED,KACE,CAAA,aAAA,CAAA,IAAA,EAAA,EAAA,SAAS,EAAE,kCAAkC,EAC7C,IAAI,EAAC,SAAS,EACd,KAAK,EAAE,EAAE,SAAS,EAAE,oBAAoB,CAAC,IAAI,EAAE,EAE9C,EAAA,aAAa,EAAE,CACb;AACJ,oBAAA,YAAY,EAAE,CACX,CACF,CACF,CACF,EACN;AACJ,CAAC,CAAC;AACK,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC;;;;"}
@@ -28,20 +28,17 @@ const useSelectPositionList = ({ expanded, optionListReference, addBtnRef, conta
28
28
  rePositionList();
29
29
  }, [expanded]);
30
30
  const rePositionList = () => {
31
+ var _a;
31
32
  if (!expanded || !optionListReference.current || !containerReference.current) {
32
33
  return;
33
34
  }
34
- // Check whether there is more space above or below the select
35
- // Check space between the bottom of select and top of viewport
36
- const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;
37
- // Check space between the top of the select and bottom of viewport
38
- const spaceOnBottomOfSelect = window.innerHeight - containerReference.current.getBoundingClientRect().top;
39
- // Set position as if there's more space on the bottom
40
- let position = Position.Below;
41
- // Set the position of the select
42
- if (spaceOnTopOfSelect > spaceOnBottomOfSelect) {
43
- position = Position.Above;
44
- }
35
+ const listHeight = (_a = optionListReference.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height;
36
+ const viewportRelativeRect = containerReference.current.getBoundingClientRect();
37
+ const spaceOnTopOfSelect = viewportRelativeRect.top;
38
+ const spaceOnBottomOfSelect = window.innerHeight - viewportRelativeRect.bottom;
39
+ const position = listHeight > spaceOnBottomOfSelect && spaceOnTopOfSelect > spaceOnBottomOfSelect
40
+ ? Position.Above
41
+ : Position.Below;
45
42
  setListPosition(position);
46
43
  // Calculate the potential max height of the options list
47
44
  calculateOptionListMaxHeight(position);
@@ -1 +1 @@
1
- {"version":3,"file":"useSelectPositionList.esm.js","sources":["../../../../../../src/components/Form/Select/useSelectPositionList.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\nimport { Position, UseSelectPositionListParams } from \"./Select.interfaces\";\n\n/** @scope .*/\nexport const useSelectPositionList = ({\n expanded,\n optionListReference,\n addBtnRef,\n containerReference\n}: UseSelectPositionListParams) => {\n const [optionsListMaxHeight, setOptionsListMaxHeight] = useState<{\n wrapper?: string;\n list?: string;\n }>({\n wrapper: undefined,\n list: undefined\n });\n const [opacity, setOpacity] = useState(0); // We set opacity because otherwise if we calculate the max height you see the list full height for a split second and then it shortens.\n const [listPosition, setListPosition] = useState<Position>(Position.Below);\n\n useEffect(() => {\n rePositionList();\n }, [expanded]);\n\n const rePositionList = () => {\n if (!expanded || !optionListReference.current || !containerReference.current) {\n return;\n }\n\n // Check whether there is more space above or below the select\n // Check space between the bottom of select and top of viewport\n const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;\n\n // Check space between the top of the select and bottom of viewport\n const spaceOnBottomOfSelect =\n window.innerHeight - containerReference.current.getBoundingClientRect().top;\n\n // Set position as if there's more space on the bottom\n let position = Position.Below;\n\n // Set the position of the select\n if (spaceOnTopOfSelect > spaceOnBottomOfSelect) {\n position = Position.Above;\n }\n\n setListPosition(position);\n\n // Calculate the potential max height of the options list\n calculateOptionListMaxHeight(position);\n };\n\n const calculateOptionListMaxHeight = (position: Position) => {\n // Calculate max height if there's more space below the select\n const listHeight = optionListReference.current?.getBoundingClientRect().height;\n const addNewButtonHeightWithMargin = addBtnRef.current\n ? addBtnRef.current.getBoundingClientRect().height +\n parseInt(getComputedStyle(addBtnRef.current).marginBottom)\n : 0;\n const transformOrigin = position === Position.Below ? \"top\" : \"bottom\";\n\n if (!containerReference.current) {\n console.error(\n \"The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand\"\n );\n return;\n }\n\n const availableSpace =\n transformOrigin === \"top\"\n ? window.innerHeight - containerReference.current.getBoundingClientRect().bottom - 16\n : containerReference.current.getBoundingClientRect().top - 16;\n\n if (listHeight && availableSpace < listHeight + addNewButtonHeightWithMargin) {\n const maxHeightObject = {\n wrapper: `${availableSpace}px`,\n list:\n addNewButtonHeightWithMargin > 0\n ? `${availableSpace - addNewButtonHeightWithMargin}px`\n : \"none\"\n };\n setOptionsListMaxHeight(maxHeightObject);\n setOpacity(100);\n return;\n }\n\n setOptionsListMaxHeight({ wrapper: undefined, list: undefined });\n setOpacity(100);\n };\n\n return {\n optionsListMaxHeight,\n opacity,\n setOpacity,\n listPosition,\n setListPosition\n };\n};\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;AAcG;AAKH;AACO,MAAM,qBAAqB,GAAG,CAAC,EACpC,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EACU,KAAI;AAChC,IAAA,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAG7D;AACD,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC,CAAC;AACH,IAAA,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC1C,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAW,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE3E,SAAS,CAAC,MAAK;AACb,QAAA,cAAc,EAAE,CAAC;AACnB,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,cAAc,GAAG,MAAK;AAC1B,QAAA,IAAI,CAAC,QAAQ,IAAI,CAAC,mBAAmB,CAAC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;YAC5E,OAAO;SACR;;;QAID,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC;;AAGrF,QAAA,MAAM,qBAAqB,GACzB,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAC;;AAG9E,QAAA,IAAI,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;;AAG9B,QAAA,IAAI,kBAAkB,GAAG,qBAAqB,EAAE;AAC9C,YAAA,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;SAC3B;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sBAAE,MAAM;aACb,CAAC;YACF,uBAAuB,CAAC,eAAe,CAAC,CAAC;YACzC,UAAU,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO;SACR;QAED,uBAAuB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACjE,UAAU,CAAC,GAAG,CAAC,CAAC;AAClB,KAAC,CAAC;IAEF,OAAO;QACL,oBAAoB;QACpB,OAAO;QACP,UAAU;QACV,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useSelectPositionList.esm.js","sources":["../../../../../../src/components/Form/Select/useSelectPositionList.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\nimport { Position, UseSelectPositionListParams } from \"./Select.interfaces\";\n\n/** @scope .*/\nexport const useSelectPositionList = ({\n expanded,\n optionListReference,\n addBtnRef,\n containerReference\n}: UseSelectPositionListParams) => {\n const [optionsListMaxHeight, setOptionsListMaxHeight] = useState<{\n wrapper?: string;\n list?: string;\n }>({\n wrapper: undefined,\n list: undefined\n });\n const [opacity, setOpacity] = useState(0); // We set opacity because otherwise if we calculate the max height you see the list full height for a split second and then it shortens.\n const [listPosition, setListPosition] = useState<Position>(Position.Below);\n\n useEffect(() => {\n rePositionList();\n }, [expanded]);\n\n const rePositionList = () => {\n if (!expanded || !optionListReference.current || !containerReference.current) {\n return;\n }\n\n const listHeight = optionListReference.current?.getBoundingClientRect().height;\n\n const viewportRelativeRect = containerReference.current.getBoundingClientRect();\n\n const spaceOnTopOfSelect = viewportRelativeRect.top;\n const spaceOnBottomOfSelect = window.innerHeight - viewportRelativeRect.bottom;\n\n const position =\n listHeight > spaceOnBottomOfSelect && spaceOnTopOfSelect > spaceOnBottomOfSelect\n ? Position.Above\n : Position.Below;\n\n setListPosition(position);\n\n // Calculate the potential max height of the options list\n calculateOptionListMaxHeight(position);\n };\n\n const calculateOptionListMaxHeight = (position: Position) => {\n // Calculate max height if there's more space below the select\n const listHeight = optionListReference.current?.getBoundingClientRect().height;\n const addNewButtonHeightWithMargin = addBtnRef.current\n ? addBtnRef.current.getBoundingClientRect().height +\n parseInt(getComputedStyle(addBtnRef.current).marginBottom)\n : 0;\n const transformOrigin = position === Position.Below ? \"top\" : \"bottom\";\n\n if (!containerReference.current) {\n console.error(\n \"The containerReference is empty for some reason in the SelectService.ts for the Select component in react-lib-components. We are trying to calculate the option list max height on expand\"\n );\n return;\n }\n\n const availableSpace =\n transformOrigin === \"top\"\n ? window.innerHeight - containerReference.current.getBoundingClientRect().bottom - 16\n : containerReference.current.getBoundingClientRect().top - 16;\n\n if (listHeight && availableSpace < listHeight + addNewButtonHeightWithMargin) {\n const maxHeightObject = {\n wrapper: `${availableSpace}px`,\n list:\n addNewButtonHeightWithMargin > 0\n ? `${availableSpace - addNewButtonHeightWithMargin}px`\n : \"none\"\n };\n setOptionsListMaxHeight(maxHeightObject);\n setOpacity(100);\n return;\n }\n\n setOptionsListMaxHeight({ wrapper: undefined, list: undefined });\n setOpacity(100);\n };\n\n return {\n optionsListMaxHeight,\n opacity,\n setOpacity,\n listPosition,\n setListPosition\n };\n};\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;AAcG;AAKH;AACO,MAAM,qBAAqB,GAAG,CAAC,EACpC,QAAQ,EACR,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EACU,KAAI;AAChC,IAAA,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAG7D;AACD,QAAA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CAAC;QACjE,UAAU,CAAC,GAAG,CAAC,CAAC;AAClB,KAAC,CAAC;IAEF,OAAO;QACL,oBAAoB;QACpB,OAAO;QACP,UAAU;QACV,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ;;;;"}
@@ -20,7 +20,7 @@ import { withReadOnly } from '../../../withReadOnly.esm.js';
20
20
  * See the License for the specific language governing permissions and
21
21
  * limitations under the License.
22
22
  */
23
- const InputWrapperComponent = ({ type, name, inputProps, helperText, helperProps, value, className, error, success, onChange, onBlur, onFocus, disabled, ...rest }, ref) => {
23
+ const InputWrapperComponent = ({ type, name, inputProps, helperText, helperProps, value, className, error, errorMessageProps, success, onChange, onBlur, onFocus, disabled, ...rest }, ref) => {
24
24
  var _a, _b, _c, _d;
25
25
  const { errorId, hasFocus, setHasFocus, helperId, labelId } = useWrapper();
26
26
  const { prefix, suffix } = inputProps !== null && inputProps !== void 0 ? inputProps : {};
@@ -35,7 +35,7 @@ const InputWrapperComponent = ({ type, name, inputProps, helperText, helperProps
35
35
  return (React.createElement(Wrapper, { ...rest, ref: ref, name: name, className: `${classes["input-wrapper"]} ${className !== null && className !== void 0 ? className : ""}`, labelProps: {
36
36
  id: labelId,
37
37
  className: labelClasses.join(" ")
38
- }, errorId: errorId, error: error, helperId: helperId, helperText: helperText, helperProps: {
38
+ }, errorId: errorId, error: error, errorMessageProps: errorMessageProps, helperId: helperId, helperText: helperText, helperProps: {
39
39
  ...helperProps,
40
40
  className: `${classes["input-wrapper-helper"]} ${(_c = helperProps === null || helperProps === void 0 ? void 0 : helperProps.className) !== null && _c !== void 0 ? _c : ""} `
41
41
  }, disabled: disabled },
@@ -1 +1 @@
1
- {"version":3,"file":"InputWrapper.esm.js","sources":["../../../../../../../src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ForwardRefRenderFunction, ComponentPropsWithRef, useRef } from \"react\";\nimport { Input, Type, Props as InputProps } from \"../../Input/Input\";\nimport classes from \"./InputWrapper.module.scss\";\nimport { Wrapper, WrapperProps } from \"../Wrapper/Wrapper\";\nimport { useWrapper } from \"../../../../hooks/useWrapper\";\nimport { withReadOnly } from \"../../../withReadOnly\";\n\ninterface PartialInputProps extends Partial<InputProps> {}\n\nexport interface Props extends ComponentPropsWithRef<\"div\">, WrapperProps {\n label: string;\n type: Type;\n name: string;\n inputProps?: PartialInputProps;\n value: string;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;\n success?: boolean;\n}\n\nconst InputWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n type,\n name,\n inputProps,\n helperText,\n helperProps,\n value,\n className,\n error,\n success,\n onChange,\n onBlur,\n onFocus,\n disabled,\n ...rest\n }: Props,\n ref\n) => {\n const { errorId, hasFocus, setHasFocus, helperId, labelId } = useWrapper();\n const { prefix, suffix } = inputProps ?? {};\n const input = useRef<HTMLInputElement>(null);\n const labelClasses = [classes[\"input-label\"]];\n hasFocus && labelClasses.push(classes[\"focus\"]);\n\n const inputWrapperClasses = [];\n inputProps?.wrapperProps?.className &&\n inputWrapperClasses.push(inputProps?.wrapperProps?.className);\n disabled && inputWrapperClasses.push(classes[\"disabled\"]);\n const readValue = rest[\"data-readonlyview\"] as boolean;\n return (\n <Wrapper\n {...rest}\n ref={ref}\n name={name}\n className={`${classes[\"input-wrapper\"]} ${className ?? \"\"}`}\n labelProps={{\n id: labelId,\n className: labelClasses.join(\" \")\n }}\n errorId={errorId}\n error={error}\n helperId={helperId}\n helperText={helperText}\n helperProps={{\n ...helperProps,\n className: `${classes[\"input-wrapper-helper\"]} ${helperProps?.className ?? \"\"} `\n }}\n disabled={disabled}\n >\n <Input\n {...inputProps}\n prefix={prefix}\n suffix={suffix}\n readOnlyView={readValue}\n wrapperProps={{\n className: inputWrapperClasses.join(\" \")\n }}\n ref={inputProps?.ref || input}\n aria-labelledby={labelId}\n aria-describedby={error ? errorId : helperId}\n onChange={onChange}\n onFocus={e => {\n onFocus?.(e);\n setHasFocus(true);\n }}\n onBlur={e => {\n onBlur?.(e);\n setHasFocus(false);\n }}\n className={`\n ${inputProps?.className ?? \"\"}`}\n name={name}\n success={success}\n error={error}\n id={name}\n value={value}\n type={type}\n />\n </Wrapper>\n );\n};\n\nexport const InputWrapper = withReadOnly(React.forwardRef(InputWrapperComponent));\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAuBH,MAAM,qBAAqB,GAAoD,CAC7E,EACE,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,UAAU,EACV,WAAW,EACX,KAAK,EACL,SAAS,EACT,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,GAAG,IAAI,EACD,EACR,GAAG,KACD;;AACF,IAAA,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;AAC3E,IAAA,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,KAAA,CAAA,GAAV,UAAU,GAAI,EAAE,CAAC;AAC5C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAC7C,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC9C,QAAQ,IAAI,YAAY,CAAC,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A,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA,CAAE,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,CAAA,CACM,EACV;AACJ,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC;;;;"}
1
+ {"version":3,"file":"InputWrapper.esm.js","sources":["../../../../../../../src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ForwardRefRenderFunction, ComponentPropsWithRef, useRef } from \"react\";\nimport { Input, Type, Props as InputProps } from \"../../Input/Input\";\nimport classes from \"./InputWrapper.module.scss\";\nimport { Wrapper, WrapperProps } from \"../Wrapper/Wrapper\";\nimport { useWrapper } from \"../../../../hooks/useWrapper\";\nimport { withReadOnly } from \"../../../withReadOnly\";\n\ninterface PartialInputProps extends Partial<InputProps> {}\n\nexport interface Props extends ComponentPropsWithRef<\"div\">, WrapperProps {\n label: string;\n type: Type;\n name: string;\n inputProps?: PartialInputProps;\n value: string;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;\n success?: boolean;\n}\n\nconst InputWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n type,\n name,\n inputProps,\n helperText,\n helperProps,\n value,\n className,\n error,\n errorMessageProps,\n success,\n onChange,\n onBlur,\n onFocus,\n disabled,\n ...rest\n }: Props,\n ref\n) => {\n const { errorId, hasFocus, setHasFocus, helperId, labelId } = useWrapper();\n const { prefix, suffix } = inputProps ?? {};\n const input = useRef<HTMLInputElement>(null);\n const labelClasses = [classes[\"input-label\"]];\n hasFocus && labelClasses.push(classes[\"focus\"]);\n\n const inputWrapperClasses = [];\n inputProps?.wrapperProps?.className &&\n inputWrapperClasses.push(inputProps?.wrapperProps?.className);\n disabled && inputWrapperClasses.push(classes[\"disabled\"]);\n const readValue = rest[\"data-readonlyview\"] as boolean;\n return (\n <Wrapper\n {...rest}\n ref={ref}\n name={name}\n className={`${classes[\"input-wrapper\"]} ${className ?? \"\"}`}\n labelProps={{\n id: labelId,\n className: labelClasses.join(\" \")\n }}\n errorId={errorId}\n error={error}\n errorMessageProps={errorMessageProps}\n helperId={helperId}\n helperText={helperText}\n helperProps={{\n ...helperProps,\n className: `${classes[\"input-wrapper-helper\"]} ${helperProps?.className ?? \"\"} `\n }}\n disabled={disabled}\n >\n <Input\n {...inputProps}\n prefix={prefix}\n suffix={suffix}\n readOnlyView={readValue}\n wrapperProps={{\n className: inputWrapperClasses.join(\" \")\n }}\n ref={inputProps?.ref || input}\n aria-labelledby={labelId}\n aria-describedby={error ? errorId : helperId}\n onChange={onChange}\n onFocus={e => {\n onFocus?.(e);\n setHasFocus(true);\n }}\n onBlur={e => {\n onBlur?.(e);\n setHasFocus(false);\n }}\n className={`\n ${inputProps?.className ?? \"\"}`}\n name={name}\n success={success}\n error={error}\n id={name}\n value={value}\n type={type}\n />\n </Wrapper>\n );\n};\n\nexport const InputWrapper = withReadOnly(React.forwardRef(InputWrapperComponent));\n"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AAuBH,MAAM,qBAAqB,GAAoD,CAC7E,EACE,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,UA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,OAAO,GAAG,QAAQ,EAC5C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,IAAG;AACX,gBAAA,OAAO,aAAP,OAAO,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAP,OAAO,CAAG,CAAC,CAAC,CAAC;gBACb,WAAW,CAAC,IAAI,CAAC,CAAC;AACpB,aAAC,EACD,MAAM,EAAE,CAAC,IAAG;AACV,gBAAA,MAAM,aAAN,MAAM,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAN,MAAM,CAAG,CAAC,CAAC,CAAC;gBACZ,WAAW,CAAC,KAAK,CAAC,CAAC;aACpB,EACD,SAAS,EAAE,CAAA;AACR,SAAA,EAAA,CAAA,EAAA,GAAA,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,UAAU,CAAE,SAAS,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA,CAAE,EAChC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,CAAA,CACM,EACV;AACJ,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC;;;;"}
@@ -18,7 +18,7 @@ import classes from './Wrapper.module.scss.esm.js';
18
18
  * See the License for the specific language governing permissions and
19
19
  * limitations under the License.
20
20
  */
21
- const WrapperComponent = ({ children, className, error, errorMessage, errorId, errorMessageIcon, errorMessageIconPosition, helperText, helperId, required, helperProps, helperIndent, labelProps, label, disabled, name, innerClassName, ...rest }, ref) => {
21
+ const WrapperComponent = ({ children, className, error, errorMessage, errorId, errorMessageIcon, errorMessageIconPosition, errorMessageProps, helperText, helperId, required, helperProps, helperIndent, labelProps, label, disabled, name, innerClassName, ...rest }, ref) => {
22
22
  const renderChildren = () => React.Children.map(children, child => React.cloneElement(child, {
23
23
  disabled
24
24
  }));
@@ -28,7 +28,7 @@ const WrapperComponent = ({ children, className, error, errorMessage, errorId, e
28
28
  error && labelClasses.push(classes["error"]);
29
29
  disabled && labelClasses.push(classes["disabled"]);
30
30
  return (React.createElement("div", { ...rest, ref: ref, className: `${classes.wrapper} ${className !== null && className !== void 0 ? className : ""}` },
31
- React.createElement(FormGroup, { disabled: disabled, error: error, errorMessage: errorMessage, errorId: errorId, errorMessageIcon: errorMessageIcon, errorMessageIconPosition: errorMessageIconPosition, helperText: helperText, helperId: helperId, helperProps: helperProps },
31
+ React.createElement(FormGroup, { disabled: disabled, error: error, errorMessage: errorMessage, errorId: errorId, errorMessageIcon: errorMessageIcon, errorMessageIconPosition: errorMessageIconPosition, errorMessageProps: errorMessageProps, helperText: helperText, helperId: helperId, helperProps: helperProps },
32
32
  React.createElement("div", { className: ` ${innerClassName ? innerClassName : ""}` },
33
33
  label && (React.createElement(Label, { ...labelProps, className: `${classes.label} ${labelClasses.join(" ")}`, htmlFor: name }, label)),
34
34
  renderChildren()))));
@@ -1 +1 @@
1
- {"version":3,"file":"Wrapper.esm.js","sources":["../../../../../../../src/components/Form/Wrapper/Wrapper/Wrapper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ForwardRefRenderFunction, ComponentPropsWithRef, ReactElement } from \"react\";\nimport { FormGroup, Props as FormGroupProps } from \"../../FormGroup/FormGroup\";\nimport { Label, Props as LabelProps } from \"../../Label/Label\";\nimport classes from \"./Wrapper.module.scss\";\nimport { Props as HelperProps } from \"../../FormHelperText/FormHelperText\";\nimport { FormElement } from \"../../form.interfaces\";\n\nexport interface Props extends ComponentPropsWithRef<\"div\">, FormGroupProps {\n children: ReactElement | ReactElement[];\n helperIndent?: number;\n label?: string;\n labelProps?: LabelProps;\n name: string;\n /** This does NOT add validation! It simply adds an asterix on the Label! */\n required?: boolean;\n innerClassName?: string;\n}\n\n/** For components that extend this component we create an interface (InputWrapper, SelectWrapper, etc.) */\nexport interface WrapperProps extends Omit<FormElement, \"success\"> {\n errorMessage?: string;\n helperText?: string;\n helperProps?: HelperProps;\n label?: string;\n name: string;\n required?: boolean;\n disabled?: boolean;\n}\n\nconst WrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n children,\n className,\n error,\n errorMessage,\n errorId,\n errorMessageIcon,\n errorMessageIconPosition,\n helperText,\n helperId,\n required,\n helperProps,\n helperIndent,\n labelProps,\n label,\n disabled,\n name,\n innerClassName,\n ...rest\n }: Props,\n ref\n) => {\n const renderChildren = () =>\n React.Children.map(children, child =>\n React.cloneElement(child, {\n disabled\n })\n );\n\n const labelClasses = [classes[\"form-input-label\"]];\n\n labelProps?.className && labelClasses.push(labelProps.className);\n required && labelClasses.push(classes[\"required\"]);\n error && labelClasses.push(classes[\"error\"]);\n disabled && labelClasses.push(classes[\"disabled\"]);\n\n return (\n <div {...rest} ref={ref} className={`${classes.wrapper} ${className ?? \"\"}`}>\n <FormGroup\n disabled={disabled}\n error={error}\n errorMessage={errorMessage}\n errorId={errorId}\n errorMessageIcon={errorMessageIcon}\n errorMessageIconPosition={errorMessageIconPosition}\n helperText={helperText}\n helperId={helperId}\n helperProps={helperProps}\n >\n <div className={` ${innerClassName ? innerClassName : \"\"}`}>\n {label && (\n <Label\n {...labelProps}\n className={`${classes.label} ${labelClasses.join(\" \")}`}\n htmlFor={name}\n >\n {label}\n </Label>\n )}\n {renderChildren()}\n </div>\n </FormGroup>\n </div>\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,CAAC,SAAS,EACR,EAAA,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,EAClC,wBAAwB,EAAE,wBAAwB,EAClD,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EAAA;AAExB,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,CAAI,CAAA,EAAA,cAAc,GAAG,cAAc,GAAG,EAAE,CAAE,CAAA,EAAA;AACvD,gBAAA,KAAK,KACJ,KAAC,CAAA,aAAA,CAAA,KAAK,EACA,EAAA,GAAA,UAAU,EACd,SAAS,EAAE,CAAA,EAAG,OAAO,CAAC,KAAK,CAAA,CAAA,EAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,CAAA,EACvD,OAAO,EAAE,IAAI,EAAA,EAEZ,KAAK,CACA,CACT;AACA,gBAAA,cAAc,EAAE,CACb,CACI,CACR,EACN;AACJ,CAAC,CAAC;AAEW,MAAA,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB;;;;"}
1
+ {"version":3,"file":"Wrapper.esm.js","sources":["../../../../../../../src/components/Form/Wrapper/Wrapper/Wrapper.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ForwardRefRenderFunction, ComponentPropsWithRef, ReactElement } from \"react\";\nimport { FormGroup, Props as FormGroupProps } from \"../../FormGroup/FormGroup\";\nimport { Label, Props as LabelProps } from \"../../Label/Label\";\nimport classes from \"./Wrapper.module.scss\";\nimport { Props as HelperProps } from \"../../FormHelperText/FormHelperText\";\nimport { FormElement } from \"../../form.interfaces\";\n\nexport interface Props extends ComponentPropsWithRef<\"div\">, FormGroupProps {\n children: ReactElement | ReactElement[];\n helperIndent?: number;\n label?: string;\n labelProps?: LabelProps;\n name: string;\n /** This does NOT add validation! It simply adds an asterix on the Label! */\n required?: boolean;\n innerClassName?: string;\n}\n\n/** For components that extend this component we create an interface (InputWrapper, SelectWrapper, etc.) */\nexport interface WrapperProps extends Omit<FormElement, \"success\"> {\n errorMessage?: string;\n helperText?: string;\n helperProps?: HelperProps;\n errorMessageProps?: ComponentPropsWithRef<\"span\">;\n label?: string;\n name: string;\n required?: boolean;\n disabled?: boolean;\n}\n\nconst WrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (\n {\n children,\n className,\n error,\n errorMessage,\n errorId,\n errorMessageIcon,\n errorMessageIconPosition,\n errorMessageProps,\n helperText,\n helperId,\n required,\n helperProps,\n helperIndent,\n labelProps,\n label,\n disabled,\n name,\n innerClassName,\n ...rest\n }: Props,\n ref\n) => {\n const renderChildren = () =>\n React.Children.map(children, child =>\n React.cloneElement(child, {\n disabled\n })\n );\n\n const labelClasses = [classes[\"form-input-label\"]];\n\n labelProps?.className && labelClasses.push(labelProps.className);\n required && labelClasses.push(classes[\"required\"]);\n error && labelClasses.push(classes[\"error\"]);\n disabled && labelClasses.push(classes[\"disabled\"]);\n\n return (\n <div {...rest} ref={ref} className={`${classes.wrapper} ${className ?? \"\"}`}>\n <FormGroup\n disabled={disabled}\n error={error}\n errorMessage={errorMessage}\n errorId={errorId}\n errorMessageIcon={errorMessageIcon}\n errorMessageIconPosition={errorMessageIconPosition}\n errorMessageProps={errorMessageProps}\n helperText={helperText}\n helperId={helperId}\n helperProps={helperProps}\n >\n <div className={` ${innerClassName ? innerClassName : \"\"}`}>\n {label && (\n <Label\n {...labelProps}\n className={`${classes.label} ${labelClasses.join(\" \")}`}\n htmlFor={name}\n >\n {label}\n </Label>\n )}\n {renderChildren()}\n </div>\n </FormGroup>\n </div>\n );\n};\n\nexport const Wrapper = React.forwardRef(WrapperComponent);\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;AAcG;AAgCH,MAAM,gBAAgB,GAAoD,CACxE,EACE,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,GAAG,IAAI,EACD,EACR,GAAG,KACD;IACF,MAAM,cAAc,GAAG,MACrB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,IAChC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;QACxB,QAAQ;AACT,KAAA,CAAC,CACH,CAAC;IAEJ,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAEnD,IAAA,CAAA,UAAU,KAAV,IAAA,IAAA,UAAU,KAAV,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,UAAU,CAAE,SAAS,KAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjE,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACnD,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7C,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnD,QACE,gCAAS,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,CAAA,EAAG,OAAO,CAAC,OAAO,IAAI,SAAS,KAAA,IAAA,IAAT,SAAS,KAAT,KAAA,CAAA,GAAA,SAAS,GAAI,EAAE,CAAE,CAAA,EAAA;AACzE,QAAA,KAAA,CAAA,aAAA,CAAC,SAAS,EACR,EAAA,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,gBAAgB,EAClC,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EAAA;AAExB,YAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,CAAI,CAAA,EAAA,cAAc,GAAG,cAAc,GAAG,EAAE,CAAE,CAAA,EAAA;AACvD,gBAAA,KAAK,KACJ,KAAC,CAAA,aAAA,CAAA,KAAK,EACA,EAAA,GAAA,UAAU,EACd,SAAS,EAAE,CAAA,EAAG,OAAO,CAAC,KAAK,CAAA,CAAA,EAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAE,CAAA,EACvD,OAAO,EAAE,IAAI,EAAA,EAEZ,KAAK,CACA,CACT;AACA,gBAAA,cAAc,EAAE,CACb,CACI,CACR,EACN;AACJ,CAAC,CAAC;AAEW,MAAA,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB;;;;"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { DateTimeFilter } from "./DataGridFilters.interfaces";
3
+ type Props = {
4
+ domRoot?: HTMLElement;
5
+ dateFilterValue?: DateTimeFilter;
6
+ onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;
7
+ };
8
+ export declare const DataGridDateFilter: ({ domRoot, dateFilterValue, onDateFilterValueChange }: Props) => React.JSX.Element;
9
+ export {};
@@ -5,9 +5,10 @@ export interface DataGridFilterTagProps extends ComponentPropsWithRef<"div"> {
5
5
  triggerRef: React.Ref<HTMLButtonElement>;
6
6
  filter?: Filter;
7
7
  mode: FilterEditorMode;
8
- onFilterRemove: () => void;
8
+ onFilterRemove?: () => void;
9
9
  onFilterOpen: () => void;
10
10
  translations?: TagTranslations;
11
+ dateTagCaption?: string;
11
12
  }
12
13
  export declare const DataGridFilterTagComponent: ForwardRefRenderFunction<HTMLDivElement, DataGridFilterTagProps>;
13
14
  export declare const DataGridFilterTag: React.ForwardRefExoticComponent<Omit<DataGridFilterTagProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
@@ -21,7 +21,7 @@ export type FiltersAction = {
21
21
  export type FiltersState = {
22
22
  filters: Filter[];
23
23
  };
24
- export type FilterEditorMode = "ADD" | "EDIT";
24
+ export type FilterEditorMode = "ADD" | "EDIT" | "ADD_DATE";
25
25
  export declare enum DefaultOperators {
26
26
  is = "is",
27
27
  isNot = "is not",
@@ -47,6 +47,9 @@ export interface PopoverTranslations {
47
47
  }
48
48
  export interface TagTranslations {
49
49
  addButtonCaption?: string;
50
+ or?: string;
51
+ other?: string;
52
+ dateIs?: string;
50
53
  }
51
54
  export interface ToolbarTranslations {
52
55
  clearButtonCaption?: string;
@@ -60,3 +63,9 @@ export interface KeyValuePair<TKey = string, TValue = string> {
60
63
  key: TKey;
61
64
  value: TValue;
62
65
  }
66
+ export type DateTimeFilterType = "THIRTY_SECONDS" | "ONE_MINUTE" | "FIVE_MINUTES" | "ONE_HOUR" | "TWENTY_FOUR_HOURS" | "CUSTOM";
67
+ export interface DateTimeFilter {
68
+ fromDate: string;
69
+ toDate: string;
70
+ type: DateTimeFilterType;
71
+ }
@@ -1,8 +1,10 @@
1
1
  import React from "react";
2
- import { DataGridColumnMetadata, Filter, FiltersTranslations } from "./DataGridFilters.interfaces";
2
+ import { DataGridColumnMetadata, DateTimeFilter, Filter, FiltersTranslations } from "./DataGridFilters.interfaces";
3
3
  export interface DataGridToolbarProps {
4
- columnsMetadata: DataGridColumnMetadata[];
4
+ columnsMetadata?: DataGridColumnMetadata[];
5
5
  customEditTagContent?: React.ReactElement;
6
+ dateFilterValue?: DateTimeFilter;
7
+ onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;
6
8
  filterValues?: Filter[];
7
9
  translations?: FiltersTranslations;
8
10
  onFilterAdd?: (filter: Filter) => void;
@@ -10,4 +12,4 @@ export interface DataGridToolbarProps {
10
12
  onFilterDelete?: (id: string) => void;
11
13
  onFiltersClear?: () => void;
12
14
  }
13
- export declare const DataGridToolbar: ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, onFiltersClear, customEditTagContent }: DataGridToolbarProps) => React.JSX.Element;
15
+ export declare const DataGridToolbar: ({ columnsMetadata, filterValues, translations, onFilterAdd, onFilterEdit, onFilterDelete, dateFilterValue, onDateFilterValueChange, onFiltersClear, customEditTagContent }: DataGridToolbarProps) => React.JSX.Element;
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { DateTimeFilter, DateTimeFilterType } from "../DataGridFilters.interfaces";
3
+ export type DateTimePickerTranslations = {
4
+ errors: {
5
+ dateFormatError: string;
6
+ };
7
+ previousMonth: string;
8
+ nextMonth: string;
9
+ from: string;
10
+ to: string;
11
+ cancel: string;
12
+ apply: string;
13
+ dateInputPlaceholder: string;
14
+ };
15
+ export type Props = {
16
+ popoverRef: React.RefObject<HTMLDivElement>;
17
+ anchorRef?: React.RefObject<HTMLDivElement>;
18
+ isOpen: boolean;
19
+ onTagCaptionChange: (value: string) => void;
20
+ setPickerOpen: (open: boolean) => void;
21
+ translations?: DateTimePickerTranslations;
22
+ dateFilterValue?: DateTimeFilter;
23
+ onDateFilterValueChange?: (dateTimeFilter: DateTimeFilter) => void;
24
+ };
25
+ export type SideMenuItem = {
26
+ id: DateTimeFilterType;
27
+ name: string;
28
+ rangeSeconds?: number;
29
+ };
30
+ export declare const dateFormat = "yyyy-mm-dd hh:mm:ss";
31
+ export declare const DateTimePicker: ({ anchorRef, popoverRef, isOpen, setPickerOpen, onTagCaptionChange, translations, dateFilterValue, onDateFilterValueChange }: Props) => React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { DateRange } from "react-day-picker";
3
+ type Props = {
4
+ previousMonth: string;
5
+ nextMonth: string;
6
+ selectedDate: DateRange | undefined;
7
+ disableDateRangePickers: boolean;
8
+ setSelectedDate: React.Dispatch<React.SetStateAction<DateRange>>;
9
+ setFromDateText: React.Dispatch<React.SetStateAction<string>>;
10
+ setToDateText: React.Dispatch<React.SetStateAction<string>>;
11
+ setFromDateError: React.Dispatch<React.SetStateAction<string>>;
12
+ setToDateError: React.Dispatch<React.SetStateAction<string>>;
13
+ };
14
+ export declare const DateTimePickerCalendarSection: ({ previousMonth, nextMonth, selectedDate, disableDateRangePickers, setSelectedDate, setFromDateText, setFromDateError, setToDateError, setToDateText }: Props) => React.JSX.Element;
15
+ export {};
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { DateRange } from "react-day-picker";
3
+ export type Props = {
4
+ from: string;
5
+ to: string;
6
+ dateInputPlaceholder: string;
7
+ dateFormatError: string;
8
+ fromDateText: string;
9
+ toDateText: string;
10
+ fromDateError: string;
11
+ toDateError: string;
12
+ setSelectedDate: React.Dispatch<React.SetStateAction<DateRange>>;
13
+ setFromDateText: React.Dispatch<React.SetStateAction<string>>;
14
+ setToDateText: React.Dispatch<React.SetStateAction<string>>;
15
+ setFromDateError: React.Dispatch<React.SetStateAction<string>>;
16
+ setToDateError: React.Dispatch<React.SetStateAction<string>>;
17
+ };
18
+ export declare const DateTimePickerInputSection: ({ from, to, dateInputPlaceholder, dateFormatError, toDateText, fromDateText, fromDateError, toDateError, setSelectedDate, setFromDateText, setToDateText, setFromDateError, setToDateError }: Props) => React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { Locale } from "date-fns";
2
+ export declare const THIRTY_SECONDS = "THIRTY_SECONDS";
3
+ export declare const ONE_MINUTE = "ONE_MINUTE";
4
+ export declare const FIVE_MINUTES = "FIVE_MINUTES";
5
+ export declare const ONE_HOUR = "ONE_HOUR";
6
+ export declare const TWENTY_FOUR_HOURS = "TWENTY_FOUR_HOURS";
7
+ export declare const CUSTOM_DATE_RANGE = "CUSTOM";
8
+ export declare const getMonthName: (date: Date, locale?: Locale) => string;
9
+ export declare const getYearFromDate: (date: Date) => string;
10
+ export declare const formatInputDate: (date: Date) => string;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { SideMenuItem } from "./DateTimePicker";
3
+ import { DateTimeFilterType } from "../DataGridFilters.interfaces";
4
+ type Props = {
5
+ sideMenuItems: SideMenuItem[];
6
+ selectedItemId: string;
7
+ onItemSelect: (id: DateTimeFilterType) => void;
8
+ };
9
+ export declare const SideMenu: ({ sideMenuItems, selectedItemId, onItemSelect }: Props) => React.JSX.Element;
10
+ export {};
@@ -1,4 +1,4 @@
1
- import { Filter } from "./DataGridFilters/DataGridFilters.interfaces";
1
+ import { DateTimeFilter, Filter } from "./DataGridFilters/DataGridFilters.interfaces";
2
2
  /**
3
3
  * @scope .
4
4
  * @scopeException stories/DataGrid/DataGrid.stories.tsx
@@ -14,3 +14,9 @@ export declare const useMockFilteringLogic: <T extends {
14
14
  setGridData: import("react").Dispatch<import("react").SetStateAction<T[]>>;
15
15
  filters: Filter[];
16
16
  };
17
+ export declare const useMockFilteringByDateLogic: <T extends {
18
+ [k: string]: string | Date;
19
+ }>(data: T[], dateFieldKey: string, filterValue: DateTimeFilter | undefined) => {
20
+ gridData: T[];
21
+ setGridData: import("react").Dispatch<import("react").SetStateAction<T[]>>;
22
+ };
@@ -1,5 +1,5 @@
1
1
  import React, { ComponentPropsWithoutRef } from "react";
2
- import { DateRange } from "react-day-picker";
2
+ import { DateRange, CustomComponents } from "react-day-picker";
3
3
  import * as locales from "date-fns/locale";
4
4
  export interface Props extends ComponentPropsWithoutRef<any> {
5
5
  onSelect: (date: Date | DateRange | undefined) => void;
@@ -7,5 +7,8 @@ export interface Props extends ComponentPropsWithoutRef<any> {
7
7
  value: Date | DateRange | undefined;
8
8
  required?: boolean;
9
9
  locale?: keyof typeof locales;
10
+ numberOfMonths?: number;
11
+ components?: Partial<CustomComponents>;
12
+ disabled?: boolean;
10
13
  }
11
14
  export declare const DatePicker: ({ onSelect, value, required, mode, locale, ...rest }: Props) => React.JSX.Element;
@@ -9,6 +9,7 @@ export interface Props extends ComponentPropsWithRef<"div"> {
9
9
  errorMessageIconPosition?: "before" | "after";
10
10
  errorMessage?: string;
11
11
  errorId?: string;
12
+ errorMessageProps?: ComponentPropsWithRef<"span">;
12
13
  helperText?: string;
13
14
  helperId?: string;
14
15
  helperProps?: HelperProps;
@@ -18,6 +18,7 @@ export interface WrapperProps extends Omit<FormElement, "success"> {
18
18
  errorMessage?: string;
19
19
  helperText?: string;
20
20
  helperProps?: HelperProps;
21
+ errorMessageProps?: ComponentPropsWithRef<"span">;
21
22
  label?: string;
22
23
  name: string;
23
24
  required?: boolean;
@@ -0,0 +1,2 @@
1
+ import { DependencyList } from "react";
2
+ export declare const useClickOutside: (myElementRef: React.RefObject<HTMLElement>, onClickOutside: (event: MouseEvent) => void, dependencies?: DependencyList) => void;
@@ -0,0 +1,38 @@
1
+ import { useEffect } from 'react';
2
+
3
+ /*
4
+ * Copyright 2022 OneWelcome B.V.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ const useClickOutside = (myElementRef, onClickOutside, dependencies) => {
19
+ function eventListener(event) {
20
+ const myElement = myElementRef === null || myElementRef === void 0 ? void 0 : myElementRef.current;
21
+ if (!myElement) {
22
+ return;
23
+ }
24
+ const clickedInsideMyElement = myElement.contains(event.target);
25
+ if (!clickedInsideMyElement) {
26
+ onClickOutside(event);
27
+ }
28
+ }
29
+ useEffect(() => {
30
+ setTimeout(() => window.addEventListener("click", eventListener));
31
+ return () => {
32
+ setTimeout(() => window.removeEventListener("click", eventListener));
33
+ };
34
+ }, dependencies);
35
+ };
36
+
37
+ export { useClickOutside };
38
+ //# sourceMappingURL=useClickOutside.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClickOutside.esm.js","sources":["../../../../../../src/hooks/useClickOutside.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DependencyList, useEffect } from \"react\";\n\nexport const useClickOutside = (\n myElementRef: React.RefObject<HTMLElement>,\n onClickOutside: (event: MouseEvent) => void,\n dependencies?: DependencyList\n) => {\n function eventListener(event: MouseEvent) {\n const myElement = myElementRef?.current;\n if (!myElement) {\n return;\n }\n const clickedInsideMyElement = myElement.contains(event.target as Node);\n\n if (!clickedInsideMyElement) {\n onClickOutside(event);\n }\n }\n useEffect(() => {\n setTimeout(() => window.addEventListener(\"click\", eventListener));\n\n return () => {\n setTimeout(() => window.removeEventListener(\"click\", eventListener));\n };\n }, dependencies);\n};\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;AAcG;AAIU,MAAA,eAAe,GAAG,CAC7B,YAA0C,EAC1C,cAA2C,EAC3C,YAA6B,KAC3B;IACF,SAAS,aAAa,CAAC,KAAiB,EAAA;QACtC,MAAM,SAAS,GAAG,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAZ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,YAAY,CAAE,OAAO,CAAC;QACxC,IAAI,CAAC,SAAS,EAAE;YACd,OAAO;SACR;QACD,MAAM,sBAAsB,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,CAAC;QAExE,IAAI,CAAC,sBAAsB,EAAE;YAC3B,cAAc,CAAC,KAAK,CAAC,CAAC;SACvB;KACF;IACD,SAAS,CAAC,MAAK;AACb,QAAA,UAAU,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AAElE,QAAA,OAAO,MAAK;AACV,YAAA,UAAU,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AACvE,SAAC,CAAC;KACH,EAAE,YAAY,CAAC,CAAC;AACnB;;;;"}
@@ -42,6 +42,7 @@ export type { Props as StepProps } from "./components/Stepper/Step";
42
42
  export { Pagination } from "./components/Pagination/Pagination";
43
43
  export type { Props as PaginationProps, PageChangeLabels, PaginationTranslations, PageSize } from "./components/Pagination/Pagination";
44
44
  export { useRepeater } from "./hooks/useRepeater";
45
+ export { useClickOutside } from "./hooks/useClickOutside";
45
46
  export { useFullHeightCollapse } from "./hooks/useFullHeightCollapse";
46
47
  export { usePosition } from "./hooks/usePosition";
47
48
  export type { Placement } from "./hooks/usePosition";
@@ -20,6 +20,7 @@ export { Spinner } from '../Spinner/Spinner.esm.js';
20
20
  export { Stepper } from '../Stepper/Stepper.esm.js';
21
21
  export { Pagination } from '../Pagination/Pagination.esm.js';
22
22
  export { useRepeater } from './hooks/useRepeater.esm.js';
23
+ export { useClickOutside } from './hooks/useClickOutside.esm.js';
23
24
  export { useFullHeightCollapse } from './hooks/useFullHeightCollapse.esm.js';
24
25
  export { usePosition } from './hooks/usePosition.esm.js';
25
26
  export { useDebouncedCallback } from './hooks/useDebouncedCallback.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "homepage": "http://onewelcome.github.io/react-lib-components",
3
3
  "name": "@onewelcome/react-lib-components",
4
- "version": "8.6.0",
4
+ "version": "8.7.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "OneWelcome B.V.",
7
7
  "main": "dist/cjs/src/index.cjs.js",
@@ -45,9 +45,13 @@
45
45
  "storybook": "storybook dev -p 6006"
46
46
  },
47
47
  "peerDependencies": {
48
+ "date-fns": "^4.1.0",
48
49
  "react": ">=16",
49
- "react-dom": ">=16",
50
- "react-day-picker": "^9.1.3"
50
+ "react-day-picker": "^9.4.1",
51
+ "react-dom": ">=16"
52
+ },
53
+ "overrides": {
54
+ "cross-spawn": ">=7.0.5"
51
55
  },
52
56
  "engines": {
53
57
  "node": ">=16"