@navikt/ds-react 6.6.1 → 6.7.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 (258) hide show
  1. package/cjs/chat/Chat.d.ts +2 -1
  2. package/cjs/chat/Chat.js +2 -1
  3. package/cjs/chat/Chat.js.map +1 -1
  4. package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
  5. package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
  6. package/cjs/date/monthpicker/MonthCaption.js +1 -1
  7. package/cjs/date/utils/labels.d.ts +2 -2
  8. package/cjs/form/ReadOnlyIcon.d.ts +2 -2
  9. package/cjs/form/combobox/Combobox.js +7 -22
  10. package/cjs/form/combobox/Combobox.js.map +1 -1
  11. package/cjs/form/combobox/ComboboxProvider.js +2 -2
  12. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  13. package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -2
  14. package/cjs/form/combobox/ComboboxWrapper.js +4 -2
  15. package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
  16. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
  17. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  18. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  19. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +13 -15
  20. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  21. package/cjs/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  22. package/cjs/form/combobox/Input/{inputContext.js → Input.context.js} +22 -22
  23. package/cjs/form/combobox/Input/Input.context.js.map +1 -0
  24. package/cjs/form/combobox/Input/Input.js +2 -2
  25. package/cjs/form/combobox/Input/Input.js.map +1 -1
  26. package/cjs/form/combobox/Input/InputController.d.ts +3 -0
  27. package/cjs/form/combobox/Input/InputController.js +70 -0
  28. package/cjs/form/combobox/Input/InputController.js.map +1 -0
  29. package/cjs/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  30. package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -0
  31. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
  32. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  33. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  34. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +7 -13
  35. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  36. package/cjs/form/combobox/customOptionsContext.d.ts +4 -4
  37. package/cjs/form/combobox/customOptionsContext.js +10 -13
  38. package/cjs/form/combobox/customOptionsContext.js.map +1 -1
  39. package/cjs/form/combobox/types.d.ts +1 -1
  40. package/cjs/help-text/HelpTextIcon.d.ts +1 -1
  41. package/cjs/index.d.ts +1 -0
  42. package/cjs/index.js +4 -2
  43. package/cjs/index.js.map +1 -1
  44. package/cjs/overlay/dismiss/DismissableLayer.d.ts +70 -0
  45. package/cjs/overlay/dismiss/DismissableLayer.js +253 -0
  46. package/cjs/overlay/dismiss/DismissableLayer.js.map +1 -0
  47. package/cjs/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  48. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js +65 -0
  49. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  50. package/cjs/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  51. package/cjs/overlay/dismiss/util/useEscapeKeydown.js +19 -0
  52. package/cjs/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  53. package/cjs/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  54. package/cjs/overlay/dismiss/util/useFocusOutside.js +42 -0
  55. package/cjs/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  56. package/cjs/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  57. package/cjs/overlay/dismiss/util/usePointerDownOutside.js +84 -0
  58. package/cjs/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  59. package/cjs/overlays/floating/Floating.d.ts +53 -0
  60. package/cjs/overlays/floating/Floating.js +215 -0
  61. package/cjs/overlays/floating/Floating.js.map +1 -0
  62. package/cjs/overlays/floating/Floating.utils.d.ts +18 -0
  63. package/cjs/overlays/floating/Floating.utils.js +52 -0
  64. package/cjs/overlays/floating/Floating.utils.js.map +1 -0
  65. package/cjs/popover/Popover.js +13 -28
  66. package/cjs/popover/Popover.js.map +1 -1
  67. package/cjs/progress-bar/ProgressBar.d.ts +72 -0
  68. package/cjs/progress-bar/ProgressBar.js +86 -0
  69. package/cjs/progress-bar/ProgressBar.js.map +1 -0
  70. package/cjs/progress-bar/index.d.ts +1 -0
  71. package/cjs/progress-bar/index.js +10 -0
  72. package/cjs/progress-bar/index.js.map +1 -0
  73. package/cjs/tabs/Tabs.context.d.ts +7 -3
  74. package/cjs/tabs/Tabs.context.js +1 -0
  75. package/cjs/tabs/Tabs.context.js.map +1 -1
  76. package/cjs/timeline/AxisLabels.d.ts +1 -1
  77. package/cjs/toggle-group/ToggleGroup.context.d.ts +7 -3
  78. package/cjs/toggle-group/ToggleGroup.context.js +1 -0
  79. package/cjs/toggle-group/ToggleGroup.context.js.map +1 -1
  80. package/cjs/typography/BodyLong.d.ts +7 -7
  81. package/cjs/typography/BodyLong.js +5 -5
  82. package/cjs/typography/BodyShort.d.ts +5 -5
  83. package/cjs/typography/BodyShort.js +3 -3
  84. package/cjs/typography/Detail.d.ts +5 -5
  85. package/cjs/typography/Detail.js +3 -3
  86. package/cjs/typography/ErrorMessage.d.ts +5 -5
  87. package/cjs/typography/ErrorMessage.js +3 -3
  88. package/cjs/typography/Heading.d.ts +6 -6
  89. package/cjs/typography/Heading.js +3 -3
  90. package/cjs/typography/Label.d.ts +5 -5
  91. package/cjs/typography/Label.js +3 -3
  92. package/cjs/typography/types.d.ts +3 -3
  93. package/cjs/util/hooks/descendants/useDescendant.d.ts +2 -2
  94. package/cjs/util/hooks/descendants/useDescendant.js +49 -52
  95. package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
  96. package/cjs/util/types/AsChild.d.ts +14 -0
  97. package/cjs/util/types/AsChild.js +3 -0
  98. package/cjs/util/types/AsChild.js.map +1 -0
  99. package/esm/chat/Chat.d.ts +2 -1
  100. package/esm/chat/Chat.js +1 -0
  101. package/esm/chat/Chat.js.map +1 -1
  102. package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
  103. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  104. package/esm/date/monthpicker/MonthCaption.js +1 -1
  105. package/esm/date/utils/labels.d.ts +2 -2
  106. package/esm/form/ReadOnlyIcon.d.ts +2 -2
  107. package/esm/form/combobox/Combobox.js +8 -23
  108. package/esm/form/combobox/Combobox.js.map +1 -1
  109. package/esm/form/combobox/ComboboxProvider.js +1 -1
  110. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  111. package/esm/form/combobox/ComboboxWrapper.d.ts +1 -2
  112. package/esm/form/combobox/ComboboxWrapper.js +4 -2
  113. package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
  114. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +3 -3
  115. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  116. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  117. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -16
  118. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  119. package/esm/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  120. package/esm/form/combobox/Input/{inputContext.js → Input.context.js} +22 -21
  121. package/esm/form/combobox/Input/Input.context.js.map +1 -0
  122. package/esm/form/combobox/Input/Input.js +1 -1
  123. package/esm/form/combobox/Input/Input.js.map +1 -1
  124. package/esm/form/combobox/Input/InputController.d.ts +3 -0
  125. package/esm/form/combobox/Input/InputController.js +41 -0
  126. package/esm/form/combobox/Input/InputController.js.map +1 -0
  127. package/esm/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  128. package/esm/form/combobox/Input/ToggleListButton.js.map +1 -0
  129. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  130. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  131. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  132. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -14
  133. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  134. package/esm/form/combobox/customOptionsContext.d.ts +4 -4
  135. package/esm/form/combobox/customOptionsContext.js +10 -12
  136. package/esm/form/combobox/customOptionsContext.js.map +1 -1
  137. package/esm/form/combobox/types.d.ts +1 -1
  138. package/esm/help-text/HelpTextIcon.d.ts +1 -1
  139. package/esm/index.d.ts +1 -0
  140. package/esm/index.js +1 -0
  141. package/esm/index.js.map +1 -1
  142. package/esm/overlay/dismiss/DismissableLayer.d.ts +70 -0
  143. package/esm/overlay/dismiss/DismissableLayer.js +226 -0
  144. package/esm/overlay/dismiss/DismissableLayer.js.map +1 -0
  145. package/esm/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  146. package/esm/overlay/dismiss/util/dispatchCustomEvent.js +58 -0
  147. package/esm/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  148. package/esm/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  149. package/esm/overlay/dismiss/util/useEscapeKeydown.js +15 -0
  150. package/esm/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  151. package/esm/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  152. package/esm/overlay/dismiss/util/useFocusOutside.js +38 -0
  153. package/esm/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  154. package/esm/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  155. package/esm/overlay/dismiss/util/usePointerDownOutside.js +80 -0
  156. package/esm/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  157. package/esm/overlays/floating/Floating.d.ts +53 -0
  158. package/esm/overlays/floating/Floating.js +188 -0
  159. package/esm/overlays/floating/Floating.js.map +1 -0
  160. package/esm/overlays/floating/Floating.utils.d.ts +18 -0
  161. package/esm/overlays/floating/Floating.utils.js +48 -0
  162. package/esm/overlays/floating/Floating.utils.js.map +1 -0
  163. package/esm/popover/Popover.js +16 -31
  164. package/esm/popover/Popover.js.map +1 -1
  165. package/esm/progress-bar/ProgressBar.d.ts +72 -0
  166. package/esm/progress-bar/ProgressBar.js +57 -0
  167. package/esm/progress-bar/ProgressBar.js.map +1 -0
  168. package/esm/progress-bar/index.d.ts +1 -0
  169. package/esm/progress-bar/index.js +3 -0
  170. package/esm/progress-bar/index.js.map +1 -0
  171. package/esm/tabs/Tabs.context.d.ts +7 -3
  172. package/esm/tabs/Tabs.context.js +1 -0
  173. package/esm/tabs/Tabs.context.js.map +1 -1
  174. package/esm/timeline/AxisLabels.d.ts +1 -1
  175. package/esm/toggle-group/ToggleGroup.context.d.ts +7 -3
  176. package/esm/toggle-group/ToggleGroup.context.js +1 -0
  177. package/esm/toggle-group/ToggleGroup.context.js.map +1 -1
  178. package/esm/typography/BodyLong.d.ts +7 -7
  179. package/esm/typography/BodyLong.js +5 -5
  180. package/esm/typography/BodyShort.d.ts +5 -5
  181. package/esm/typography/BodyShort.js +3 -3
  182. package/esm/typography/Detail.d.ts +5 -5
  183. package/esm/typography/Detail.js +3 -3
  184. package/esm/typography/ErrorMessage.d.ts +5 -5
  185. package/esm/typography/ErrorMessage.js +3 -3
  186. package/esm/typography/Heading.d.ts +6 -6
  187. package/esm/typography/Heading.js +3 -3
  188. package/esm/typography/Label.d.ts +5 -5
  189. package/esm/typography/Label.js +3 -3
  190. package/esm/typography/types.d.ts +3 -3
  191. package/esm/util/hooks/descendants/useDescendant.d.ts +2 -2
  192. package/esm/util/hooks/descendants/useDescendant.js +49 -52
  193. package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
  194. package/esm/util/types/AsChild.d.ts +14 -0
  195. package/esm/util/types/AsChild.js +2 -0
  196. package/esm/util/types/AsChild.js.map +1 -0
  197. package/package.json +16 -5
  198. package/src/chat/Chat.tsx +2 -1
  199. package/src/date/datepicker/parts/DropdownCaption.tsx +5 -1
  200. package/src/date/monthpicker/MonthCaption.tsx +1 -1
  201. package/src/form/combobox/Combobox.tsx +6 -76
  202. package/src/form/combobox/ComboboxProvider.tsx +1 -1
  203. package/src/form/combobox/ComboboxWrapper.tsx +4 -3
  204. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +3 -3
  205. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
  206. package/src/form/combobox/Input/{inputContext.tsx → Input.context.tsx} +30 -33
  207. package/src/form/combobox/Input/Input.tsx +1 -1
  208. package/src/form/combobox/Input/InputController.tsx +102 -0
  209. package/src/form/combobox/{ToggleListButton.tsx → Input/ToggleListButton.tsx} +1 -1
  210. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
  211. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +12 -26
  212. package/src/form/combobox/{combobox-utils.test.ts → __tests__/combobox-utils.test.ts} +1 -1
  213. package/src/form/combobox/{combobox.test.tsx → __tests__/combobox.test.tsx} +2 -3
  214. package/src/form/combobox/customOptionsContext.tsx +14 -18
  215. package/src/form/combobox/types.ts +3 -1
  216. package/src/index.ts +1 -0
  217. package/src/overlay/README.md +5 -0
  218. package/src/overlay/dismiss/DismissableLayer.tsx +368 -0
  219. package/src/overlay/dismiss/util/dispatchCustomEvent.ts +77 -0
  220. package/src/overlay/dismiss/util/useEscapeKeydown.ts +21 -0
  221. package/src/overlay/dismiss/util/useFocusOutside.ts +52 -0
  222. package/src/overlay/dismiss/util/usePointerDownOutside.ts +95 -0
  223. package/src/overlays/floating/Floating.tsx +399 -0
  224. package/src/overlays/floating/Floating.utils.ts +63 -0
  225. package/src/popover/Popover.tsx +38 -70
  226. package/src/progress-bar/ProgressBar.tsx +149 -0
  227. package/src/progress-bar/index.ts +2 -0
  228. package/src/tabs/Tabs.context.ts +2 -0
  229. package/src/toggle-group/ToggleGroup.context.ts +1 -0
  230. package/src/typography/BodyLong.tsx +7 -7
  231. package/src/typography/BodyShort.tsx +5 -5
  232. package/src/typography/Detail.tsx +5 -5
  233. package/src/typography/ErrorMessage.tsx +5 -5
  234. package/src/typography/Heading.tsx +6 -6
  235. package/src/typography/Label.tsx +5 -5
  236. package/src/typography/types.ts +3 -3
  237. package/src/util/hooks/descendants/useDescendant.tsx +55 -68
  238. package/src/util/types/AsChild.ts +15 -0
  239. package/cjs/form/combobox/ClearButton.d.ts +0 -7
  240. package/cjs/form/combobox/ClearButton.js +0 -28
  241. package/cjs/form/combobox/ClearButton.js.map +0 -1
  242. package/cjs/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  243. package/cjs/form/combobox/FilteredOptions/CheckIcon.js +0 -12
  244. package/cjs/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  245. package/cjs/form/combobox/Input/inputContext.js.map +0 -1
  246. package/cjs/form/combobox/ToggleListButton.js.map +0 -1
  247. package/esm/form/combobox/ClearButton.d.ts +0 -7
  248. package/esm/form/combobox/ClearButton.js +0 -21
  249. package/esm/form/combobox/ClearButton.js.map +0 -1
  250. package/esm/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  251. package/esm/form/combobox/FilteredOptions/CheckIcon.js +0 -7
  252. package/esm/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  253. package/esm/form/combobox/Input/inputContext.js.map +0 -1
  254. package/esm/form/combobox/ToggleListButton.js.map +0 -1
  255. package/src/form/combobox/ClearButton.tsx +0 -29
  256. package/src/form/combobox/FilteredOptions/CheckIcon.tsx +0 -23
  257. /package/cjs/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
  258. /package/esm/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"selectedOptionsContext.js","sourceRoot":"","sources":["../../../../src/form/combobox/SelectedOptions/selectedOptionsContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAiBlE,MAAM,sBAAsB,GAAG,aAAa,CAC1C,EAAgC,CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EACtC,QAAQ,EACR,KAAK,GAON,EAAE,EAAE;IACH,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAAC;IACrD,MAAM,EACJ,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,GAAG,uBAAuB,EAAE,CAAC;IAC9B,MAAM,EACJ,cAAc,EACd,aAAa,EACb,eAAe,EAAE,uBAAuB,EACxC,gBAAgB,EAChB,OAAO,EACP,WAAW,GACZ,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,uBAAuB,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAE5D,EAAE,CAAC,CAAC;IACN,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CACH,uBAAuB,aAAvB,uBAAuB,cAAvB,uBAAuB,GAAI,CAAC,GAAG,aAAa,EAAE,GAAG,uBAAuB,CAAC,EAC3E,CAAC,aAAa,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAClE,CAAC;IAEF,MAAM,iBAAiB,GAAG,WAAW,CACnC,CAAC,MAAsB,EAAE,EAAE;QACzB,MAAM,cAAc,GA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G,WAAW,CAC9B,CACE,MAAsB,EACtB,KAA+C,EAC/C,EAAE;QACF,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,CAAC;YAC5C,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,UAAU,EAAE,CAAC;IACf,CAAC,EACD;QACE,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,oBAAoB;QACpB,eAAe;KAChB,CACF,CAAC;IAEF,MAAM,mBAAmB,GAAG,WAAW,CAAmB,eAAe,CAAC,CAAC;IAE3E,MAAM,cAAc,GAClB,CAAC,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,CAAA,IAAI,eAAe,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC;IAEtE,MAAM,oBAAoB,GAAG;QAC3B,iBAAiB;QACjB,aAAa;QACb,oBAAoB;QACpB,mBAAmB;QACnB,eAAe;QACf,kBAAkB;QAClB,YAAY;QACZ,WAAW,EAAE,WAAW,oCACnB,WAAW,KACd,cAAc,GACf;KACF,CAAC;IAEF,OAAO,CACL,oBAAC,8BAA8B,oBAAK,oBAAoB,GACrD,QAAQ,CACsB,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,CAAC"}
@@ -1,16 +1,16 @@
1
1
  import React from "react";
2
2
  import { ComboboxOption } from "./types.js";
3
- type CustomOptionsContextType = {
3
+ type CustomOptionsContextValue = {
4
4
  customOptions: ComboboxOption[];
5
5
  removeCustomOption: (option: ComboboxOption) => void;
6
6
  addCustomOption: (option: ComboboxOption) => void;
7
7
  setCustomOptions: React.Dispatch<React.SetStateAction<ComboboxOption[]>>;
8
8
  };
9
- export declare const CustomOptionsProvider: ({ children, value, }: {
9
+ declare const useComboboxCustomOptions: <S extends boolean = true>(strict?: S) => S extends true ? CustomOptionsContextValue : CustomOptionsContextValue | undefined;
10
+ declare const CustomOptionsProvider: ({ children, value, }: {
10
11
  children: any;
11
12
  value: {
12
13
  isMultiSelect?: boolean;
13
14
  };
14
15
  }) => React.JSX.Element;
15
- export declare const useCustomOptionsContext: () => CustomOptionsContextType;
16
- export {};
16
+ export { CustomOptionsProvider, useComboboxCustomOptions };
@@ -1,7 +1,11 @@
1
- import React, { createContext, useCallback, useContext, useState } from "react";
2
- import { useInputContext } from "./Input/inputContext.js";
3
- const CustomOptionsContext = createContext({});
4
- export const CustomOptionsProvider = ({ children, value, }) => {
1
+ import React, { useCallback, useState } from "react";
2
+ import { createContext } from "../../util/create-context.js";
3
+ import { useInputContext } from "./Input/Input.context.js";
4
+ const [ComboboxCustomOptionsProvider, useComboboxCustomOptions] = createContext({
5
+ name: "ComboboxCustomOptions",
6
+ errorMessage: "useComboboxCustomOptions must be used within a ComboboxCustomOptionsProvider",
7
+ });
8
+ const CustomOptionsProvider = ({ children, value, }) => {
5
9
  const [customOptions, setCustomOptions] = useState([]);
6
10
  const { focusInput } = useInputContext();
7
11
  const { isMultiSelect } = value;
@@ -24,13 +28,7 @@ export const CustomOptionsProvider = ({ children, value, }) => {
24
28
  addCustomOption,
25
29
  setCustomOptions,
26
30
  };
27
- return (React.createElement(CustomOptionsContext.Provider, { value: customOptionsState }, children));
28
- };
29
- export const useCustomOptionsContext = () => {
30
- const context = useContext(CustomOptionsContext);
31
- if (!context) {
32
- throw new Error("useCustomOptionsContext must be used within a CustomOptionsProvider");
33
- }
34
- return context;
31
+ return (React.createElement(ComboboxCustomOptionsProvider, Object.assign({}, customOptionsState), children));
35
32
  };
33
+ export { CustomOptionsProvider, useComboboxCustomOptions };
36
34
  //# sourceMappingURL=customOptionsContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customOptionsContext.js","sourceRoot":"","sources":["../../../src/form/combobox/customOptionsContext.tsx"],"names":[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EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,CAC1D,CAAC;QACF,UAAU,EAAE,CAAC;IACf,CAAC,EACD,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAC/B,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,MAAsB,EAAE,EAAE;QACzB,IAAI,aAAa,EAAE,CAAC;YAClB,gBAAgB,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,UAAU,EAAE,CAAC;IACf,CAAC,EACD,CAAC,UAAU,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAC9C,CAAC;IAEF,MAAM,kBAAkB,GAAG;QACzB,aAAa;QACb,kBAAkB;QAClB,eAAe;QACf,gBAAgB;KACjB,CAAC;IAEF,OAAO,CACL,oBAAC,6BAA6B,oBAAK,kBAAkB,GAClD,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC"}
@@ -92,7 +92,7 @@ export interface ComboboxProps extends FormFieldProps, Omit<InputHTMLAttributes<
92
92
  *
93
93
  * @param event
94
94
  */
95
- onClear?: (event: React.PointerEvent | React.KeyboardEvent) => void;
95
+ onClear?: (event: React.PointerEvent | React.KeyboardEvent | React.MouseEvent) => void;
96
96
  /**
97
97
  * Callback function triggered whenever an option is selected or de-selected.
98
98
  *
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  export declare const HelpTextIcon: ({ title, filled, }: {
3
3
  title: string;
4
- filled?: boolean | undefined;
4
+ filled?: boolean;
5
5
  }) => React.JSX.Element;
package/esm/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export { Modal, type ModalProps } from "./modal/index.js";
24
24
  export { Pagination, type PaginationProps } from "./pagination/index.js";
25
25
  export { Popover, type PopoverProps } from "./popover/index.js";
26
26
  export { Portal, type PortalProps } from "./portal/index.js";
27
+ export { ProgressBar, type ProgressBarProps } from "./progress-bar/index.js";
27
28
  export { Provider, type ProviderProps } from "./provider/index.js";
28
29
  export { ReadMore, type ReadMoreProps } from "./read-more/index.js";
29
30
  export { Skeleton, type SkeletonProps } from "./skeleton/index.js";
package/esm/index.js CHANGED
@@ -25,6 +25,7 @@ export { Modal } from "./modal/index.js";
25
25
  export { Pagination } from "./pagination/index.js";
26
26
  export { Popover } from "./popover/index.js";
27
27
  export { Portal } from "./portal/index.js";
28
+ export { ProgressBar } from "./progress-bar/index.js";
28
29
  export { Provider } from "./provider/index.js";
29
30
  export { ReadMore } from "./read-more/index.js";
30
31
  export { Skeleton } from "./skeleton/index.js";
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAmB,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,IAAI,EAAkB,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAmB,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,GAMnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,cAAc,GAIf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,aAAa,EAA2B,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,UAAU,EACV,6BAA6B,GAE9B,MAAM,eAAe,CAA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AyB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,KAAK,EACL,UAAU,GAGX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,MAAM,EAA2C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,MAAM,EAAoB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,MAAM,EAAoB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAsB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAuB,MAAM,kBAAkB,CAAC;AAElE;;GAEG;AACH,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAmB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,70 @@
1
+ import React, { CSSProperties } from "react";
2
+ import { AsChild } from "../../util/types/AsChild.js";
3
+ import { CustomFocusEvent, CustomPointerDownEvent } from "./util/dispatchCustomEvent.js";
4
+ interface DismissableLayerBaseProps {
5
+ /**
6
+ * When `true`, hover/focus/click interactions will be disabled on elements outside
7
+ * the `DismissableLayer`. Users will need to click twice on outside elements to
8
+ * interact with them: once to close the `DismissableLayer`, and again to trigger the element.
9
+ */
10
+ disableOutsidePointerEvents?: boolean;
11
+ /**
12
+ * Event handler called when the escape key is down.
13
+ * Can be prevented.
14
+ */
15
+ onEscapeKeyDown?: (event: KeyboardEvent) => void;
16
+ /**
17
+ * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.
18
+ * Can be prevented.
19
+ */
20
+ onPointerDownOutside?: (event: CustomPointerDownEvent) => void;
21
+ /**
22
+ * Event handler called when the focus moves outside of the `DismissableLayer`.
23
+ * Can be prevented.
24
+ */
25
+ onFocusOutside?: (event: CustomFocusEvent) => void;
26
+ /**
27
+ * Event handler called when an interaction happens outside the `DismissableLayer`.
28
+ * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.
29
+ * Can be prevented.
30
+ */
31
+ onInteractOutside?: (event: CustomPointerDownEvent | CustomFocusEvent) => void;
32
+ /**
33
+ * Handler called when the `DismissableLayer` should be dismissed
34
+ */
35
+ onDismiss?: () => void;
36
+ /**
37
+ * Stops `onDismiss` from beeing called when interacting with the `safeZone` elements.
38
+ * `safeZone.dismissable` is only needed when its element does not have a `tabIndex` since it will not receive focus-events.
39
+ */
40
+ safeZone?: {
41
+ anchor?: Element | null;
42
+ dismissable?: Element | null;
43
+ };
44
+ style?: CSSProperties;
45
+ /**
46
+ * Disables layer from beeing counted in context for nested `DismissableLayer`.
47
+ */
48
+ enabled?: boolean;
49
+ }
50
+ type DismissableLayerProps = DismissableLayerBaseProps & AsChild;
51
+ export declare const DismissableDescendantsProvider: React.Provider<import("../../util/hooks/descendants/descendant.js").DescendantsManager<HTMLDivElement, {
52
+ disableOutsidePointerEvents: boolean;
53
+ }>>, useDismissableDescendantsContext: <S extends boolean = true>(strict?: S) => S extends true ? import("../../util/hooks/descendants/descendant.js").DescendantsManager<HTMLDivElement, {
54
+ disableOutsidePointerEvents: boolean;
55
+ }> : import("../../util/hooks/descendants/descendant.js").DescendantsManager<HTMLDivElement, {
56
+ disableOutsidePointerEvents: boolean;
57
+ }> | undefined, useDismissableDescendants: () => import("../../util/hooks/descendants/descendant.js").DescendantsManager<HTMLDivElement, {
58
+ disableOutsidePointerEvents: boolean;
59
+ }>, useDismissableDescendant: (options?: import("../../util/hooks/descendants/descendant.js").DescendantOptions<{
60
+ disableOutsidePointerEvents: boolean;
61
+ }> | undefined) => {
62
+ descendants: import("../../util/hooks/descendants/descendant.js").DescendantsManager<HTMLDivElement, {
63
+ disableOutsidePointerEvents: boolean;
64
+ }>;
65
+ index: number;
66
+ enabledIndex: number;
67
+ register: (instance: HTMLDivElement | null) => void;
68
+ };
69
+ declare const DismissableLayer: React.ForwardRefExoticComponent<DismissableLayerProps & React.RefAttributes<HTMLDivElement>>;
70
+ export { DismissableLayer, type DismissableLayerProps };
@@ -0,0 +1,226 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { forwardRef, useEffect, useMemo, useRef, useState, } from "react";
13
+ import { Slot } from "../../util/Slot.js";
14
+ import { useMergeRefs } from "../../util/hooks/index.js";
15
+ import { createDescendantContext } from "../../util/hooks/descendants/useDescendant.js";
16
+ import { useEscapeKeydown } from "./util/useEscapeKeydown.js";
17
+ import { useFocusOutside } from "./util/useFocusOutside.js";
18
+ import { usePointerDownOutside } from "./util/usePointerDownOutside.js";
19
+ export const [DismissableDescendantsProvider, useDismissableDescendantsContext, useDismissableDescendants, useDismissableDescendant,] = createDescendantContext();
20
+ let originalBodyPointerEvents;
21
+ const DismissableLayer = forwardRef((props, ref) => {
22
+ const context = useDismissableDescendantsContext(false);
23
+ /**
24
+ * To correctly handle nested DismissableLayer,
25
+ * we only initialize the `Descendants`-API for the root layer to aboid resetting context
26
+ */
27
+ return context ? (React.createElement(DismissableLayerNode, Object.assign({ ref: ref }, props))) : (React.createElement(DismissableRoot, null,
28
+ React.createElement(DismissableLayerNode, Object.assign({ ref: ref }, props))));
29
+ });
30
+ /**
31
+ * DismissableRoot
32
+ *
33
+ * Used to initialize the `Descendants`-API at the root layer.
34
+ * All subsequent layers will use the same context.
35
+ */
36
+ const DismissableRoot = ({ children }) => {
37
+ const descendants = useDismissableDescendants();
38
+ return (React.createElement(DismissableDescendantsProvider, { value: descendants }, children));
39
+ };
40
+ const DismissableLayerNode = forwardRef((_a, ref) => {
41
+ var _b;
42
+ var { children, asChild, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, safeZone, disableOutsidePointerEvents = false, enabled = true } = _a, rest = __rest(_a, ["children", "asChild", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "onDismiss", "safeZone", "disableOutsidePointerEvents", "enabled"]);
43
+ const { register, index, descendants } = useDismissableDescendant({
44
+ disableOutsidePointerEvents,
45
+ disabled: !enabled,
46
+ });
47
+ /**
48
+ * `node` will be set to the ref of the component or nested component
49
+ * Ex: If
50
+ * ```
51
+ * <DismissableLayer asChild>
52
+ * <Popover />
53
+ * </DismissableLayer>
54
+ * ```
55
+ * `node` will in this case be the Popover-element.
56
+ * We use State her and not ref since we want to trigger a rerender when the node changes.
57
+ */
58
+ const [node, setNode] = useState(null);
59
+ const mergedRefs = useMergeRefs(setNode, register, ref);
60
+ /**
61
+ * In some cases the `node.ownerDocument` can differ from global document.
62
+ * This can happend when portaling elements or using web-components
63
+ */
64
+ const ownerDocument = (_b = node === null || node === void 0 ? void 0 : node.ownerDocument) !== null && _b !== void 0 ? _b : globalThis === null || globalThis === void 0 ? void 0 : globalThis.document;
65
+ const hasInteractedOutsideRef = useRef(false);
66
+ const hasPointerDownOutsideRef = useRef(false);
67
+ const pointerEnabled = useMemo(() => {
68
+ let lastIndex = -1;
69
+ const descendantNodes = descendants.enabledValues();
70
+ descendantNodes.forEach((obj, _index) => {
71
+ if (obj.disableOutsidePointerEvents) {
72
+ lastIndex = _index;
73
+ }
74
+ });
75
+ return {
76
+ /**
77
+ * Makes sure we stop events at the highest layer with pointer events disabled.
78
+ * If not checked, we risk closing every layer when clicking outside the layer.
79
+ */
80
+ isPointerEventsEnabled: index >= lastIndex,
81
+ /**
82
+ * If we find a node with `disableOutsidePointerEvents` we want to disable pointer events on the body.
83
+ */
84
+ isBodyPointerEventsDisabled: lastIndex > -1,
85
+ };
86
+ }, [descendants, index]);
87
+ /**
88
+ * We want to prevent the Layer from closing when the trigger, anchor element, or its child elements are interacted with.
89
+ *
90
+ * To achieve this, we check if the event target is the trigger, anchor or a child. If it is, we prevent default event behavior.
91
+ *
92
+ * The `pointerDownOutside` and `focusOutside` handlers already check if the event target is within the DismissableLayer (`node`).
93
+ * However, since we don't add a `tabIndex` to the Popover/Tooltip, the `focusOutside` handler doesn't correctly handle focus events.
94
+ * Therefore, we also need to check that neither the trigger (`anchor`) nor the DismissableLayer (`dismissable`) are the event targets.
95
+ */
96
+ function handleOutsideEvent(event) {
97
+ var _a, _b;
98
+ if ((!(safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor) && !(safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable)) || !enabled) {
99
+ return;
100
+ }
101
+ if (!event.defaultPrevented) {
102
+ hasInteractedOutsideRef.current = true;
103
+ if (event.detail.originalEvent.type === "pointerdown") {
104
+ hasPointerDownOutsideRef.current = true;
105
+ }
106
+ }
107
+ const target = event.target;
108
+ /**
109
+ * pointerdown-events works as expected, but focus-events does not.
110
+ * For focus-event we need to also check `safeZone.dismissable` (the Popover/Tooltip itself) since it does not have a tabIndex.
111
+ */
112
+ if (event.detail.originalEvent.type === "pointerdown") {
113
+ const targetIsTrigger = ((_a = safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor) === null || _a === void 0 ? void 0 : _a.contains(target)) || target === (safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor);
114
+ targetIsTrigger && event.preventDefault();
115
+ }
116
+ else {
117
+ const targetIsNotTrigger = target instanceof HTMLElement &&
118
+ ![safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor, safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable].some((element) => element === null || element === void 0 ? void 0 : element.contains(target)) &&
119
+ !target.contains((_b = safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable) !== null && _b !== void 0 ? _b : null);
120
+ !targetIsNotTrigger && event.preventDefault();
121
+ }
122
+ /**
123
+ * In Safari, if the trigger element is inside a container with tabIndex={0}, a click on the trigger
124
+ * will first fire a 'pointerdownoutside' event on the trigger itself. However, it will then fire a
125
+ * 'focusoutside' event on the container.
126
+ *
127
+ * To handle this, we ignore any 'focusoutside' events if a 'pointerdownoutside' event has already occurred.
128
+ * 'pointerdownoutside' event is sufficient to indicate interaction outside the DismissableLayer.
129
+ */
130
+ if (event.detail.originalEvent.type === "focusin" &&
131
+ hasPointerDownOutsideRef.current) {
132
+ event.preventDefault();
133
+ }
134
+ hasPointerDownOutsideRef.current = false;
135
+ hasInteractedOutsideRef.current = false;
136
+ }
137
+ const pointerDownOutside = usePointerDownOutside((event) => {
138
+ if (!pointerEnabled.isPointerEventsEnabled || !enabled) {
139
+ return;
140
+ }
141
+ /**
142
+ * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault based certain cases.
143
+ */
144
+ onPointerDownOutside === null || onPointerDownOutside === void 0 ? void 0 : onPointerDownOutside(event);
145
+ onInteractOutside === null || onInteractOutside === void 0 ? void 0 : onInteractOutside(event);
146
+ /**
147
+ * Add safeZone to prevent closing when interacting with trigger/anchor or its children.
148
+ */
149
+ safeZone && handleOutsideEvent(event);
150
+ /**
151
+ * Both `onPointerDownOutside` and `onInteractOutside` are able to preventDefault the event, thus stopping call for `onDismiss`.
152
+ */
153
+ if (!event.defaultPrevented && onDismiss) {
154
+ onDismiss();
155
+ }
156
+ }, ownerDocument);
157
+ const focusOutside = useFocusOutside((event) => {
158
+ if (!enabled) {
159
+ return;
160
+ }
161
+ /**
162
+ * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault based certain cases.
163
+ */
164
+ onFocusOutside === null || onFocusOutside === void 0 ? void 0 : onFocusOutside(event);
165
+ onInteractOutside === null || onInteractOutside === void 0 ? void 0 : onInteractOutside(event);
166
+ /**
167
+ * Add safeZone to prevent closing when interacting with trigger/anchor or its children.
168
+ */
169
+ safeZone && handleOutsideEvent(event);
170
+ /**
171
+ * Both `onFocusOutside` and `onInteractOutside` are able to preventDefault the event, thus stopping call for `onDismiss`.
172
+ */
173
+ if (!event.defaultPrevented && onDismiss) {
174
+ onDismiss();
175
+ }
176
+ }, ownerDocument);
177
+ useEscapeKeydown((event) => {
178
+ if (!enabled) {
179
+ return;
180
+ }
181
+ /**
182
+ * The deepest nested element will always be last in the descendants list.
183
+ * This allows us to only close the highest layer when pressing escape.
184
+ *
185
+ * In some cases a layer might still exist, but be disabled. We want to ignore these layers.
186
+ */
187
+ const isHighestLayer = index === descendants.enabledCount() - 1;
188
+ if (!isHighestLayer) {
189
+ return;
190
+ }
191
+ /**
192
+ * We call this before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault based certain cases.
193
+ */
194
+ onEscapeKeyDown === null || onEscapeKeyDown === void 0 ? void 0 : onEscapeKeyDown(event);
195
+ /**
196
+ * `onEscapeKeyDown` is able to preventDefault the event, thus stopping call for `onDismiss`.
197
+ * We want to `preventDefault` the escape-event to avoid sideeffect from other elements on screen
198
+ */
199
+ if (!event.defaultPrevented && onDismiss) {
200
+ event.preventDefault();
201
+ onDismiss();
202
+ }
203
+ }, ownerDocument);
204
+ /**
205
+ * If `disableOutsidePointerEvents` is true,
206
+ * we want to disable pointer events on the body when the first layer is opened.
207
+ */
208
+ useEffect(() => {
209
+ if (!node || !disableOutsidePointerEvents || index !== 0 || !enabled) {
210
+ return;
211
+ }
212
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
213
+ ownerDocument.body.style.pointerEvents = "none";
214
+ return () => {
215
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
216
+ };
217
+ }, [node, ownerDocument, disableOutsidePointerEvents, index, enabled]);
218
+ const Comp = asChild ? Slot : "div";
219
+ return (React.createElement(Comp, Object.assign({ ref: mergedRefs }, rest, { onFocusCapture: focusOutside.onFocusCapture, onBlurCapture: focusOutside.onBlurCapture, onPointerDownCapture: pointerDownOutside.onPointerDownCapture, style: Object.assign({ pointerEvents: pointerEnabled.isBodyPointerEventsDisabled
220
+ ? pointerEnabled.isPointerEventsEnabled
221
+ ? "auto"
222
+ : "none"
223
+ : undefined }, rest.style) }), children));
224
+ });
225
+ export { DismissableLayer };
226
+ //# sourceMappingURL=DismissableLayer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DismissableLayer.js","sourceRoot":"","sources":["../../../src/overlay/dismiss/DismissableLayer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAEZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAMrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAsDrE,MAAM,CAAC,MAAM,CACX,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACzB,GAAG,uBAAuB,EAGxB,CAAC;AAEJ,IAAI,yBAAiC,CAAC;AAEtC,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,KAA4B,EAAE,GAAG,EAAE,EAAE;IACpC,MAAM,OAAO,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAExD;;;OAGG;IACH,OAAO,OAAO,CAAC,CAAC,CAAC,CACf,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAC9C,CAAC,CAAC,CAAC,CACF,oBAAC,eAAe;QACd,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAC7B,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE;IACtE,MAAM,WAAW,GAAG,yBAAyB,EAAE,C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AM,CAAC;QAEhD,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,yBAAyB,CAAC;QACrE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,2BAA2B,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvE,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAEpC,OAAO,CACL,oBAAC,IAAI,kBACH,GAAG,EAAE,UAAU,IACX,IAAI,IACR,cAAc,EAAE,YAAY,CAAC,cAAc,EAC3C,aAAa,EAAE,YAAY,CAAC,aAAa,EACzC,oBAAoB,EAAE,kBAAkB,CAAC,oBAAoB,EAC7D,KAAK,kBACH,aAAa,EAAE,cAAc,CAAC,2BAA2B;gBACvD,CAAC,CAAC,cAAc,CAAC,sBAAsB;oBACrC,CAAC,CAAC,MAAM;oBACR,CAAC,CAAC,MAAM;gBACV,CAAC,CAAC,SAAS,IACV,IAAI,CAAC,KAAK,MAGd,QAAQ,CACJ,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAA8B,CAAC"}
@@ -0,0 +1,50 @@
1
+ type CustomFocusEvent = CustomEvent<{
2
+ originalEvent: FocusEvent;
3
+ }>;
4
+ type CustomPointerDownEvent = CustomEvent<{
5
+ originalEvent: PointerEvent;
6
+ }>;
7
+ export { CustomFocusEvent, CustomPointerDownEvent };
8
+ export declare const CUSTOM_EVENTS: {
9
+ FOCUS_OUTSIDE: string;
10
+ POINTER_DOWN_OUTSIDE: string;
11
+ };
12
+ /**
13
+ * Use of `discrete` flushes custom event dispatch. This is to mimic the behavior React has for `discrete` events.
14
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L318
15
+ *
16
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
17
+ *
18
+ * Internally, React prioritises events in the following order:
19
+ * - discrete
20
+ * - continuous
21
+ * - default
22
+ *
23
+ * `discrete` is an important distinction as updates within these events are applied immediately.
24
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
25
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
26
+ * dispatched by another `discrete` event.
27
+ *
28
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
29
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
30
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
31
+ * For example:
32
+ *
33
+ * dispatching a known click 👎
34
+ * target.dispatchEvent(new Event(‘click’))
35
+ *
36
+ * dispatching a custom type within a non-discrete event 👎
37
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
38
+ *
39
+ * dispatching a custom type within a `discrete` event 👍
40
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
41
+ *
42
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
43
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
44
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
45
+ */
46
+ export declare function dispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(name: string, handler: ((event: E) => void) | undefined, detail: {
47
+ originalEvent: OriginalEvent;
48
+ } & (E extends CustomEvent<infer D> ? D : never), { discrete }?: {
49
+ discrete: boolean;
50
+ }): void;
@@ -0,0 +1,58 @@
1
+ import ReactDOM from "react-dom";
2
+ export const CUSTOM_EVENTS = {
3
+ FOCUS_OUTSIDE: "AKSEL_FOCUS_OUTSIDE",
4
+ POINTER_DOWN_OUTSIDE: "AKSEL_POINTER_DOWN_OUTSIDE",
5
+ };
6
+ /**
7
+ * Use of `discrete` flushes custom event dispatch. This is to mimic the behavior React has for `discrete` events.
8
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L318
9
+ *
10
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
11
+ *
12
+ * Internally, React prioritises events in the following order:
13
+ * - discrete
14
+ * - continuous
15
+ * - default
16
+ *
17
+ * `discrete` is an important distinction as updates within these events are applied immediately.
18
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
19
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
20
+ * dispatched by another `discrete` event.
21
+ *
22
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
23
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
24
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
25
+ * For example:
26
+ *
27
+ * dispatching a known click 👎
28
+ * target.dispatchEvent(new Event(‘click’))
29
+ *
30
+ * dispatching a custom type within a non-discrete event 👎
31
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
32
+ *
33
+ * dispatching a custom type within a `discrete` event 👍
34
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
35
+ *
36
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
37
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
38
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
39
+ */
40
+ export function dispatchCustomEvent(name, handler, detail, { discrete } = { discrete: false }) {
41
+ if (!handler) {
42
+ return;
43
+ }
44
+ const target = detail.originalEvent.target;
45
+ const event = new CustomEvent(name, {
46
+ bubbles: false,
47
+ cancelable: true,
48
+ detail,
49
+ });
50
+ target.addEventListener(name, handler, { once: true });
51
+ if (discrete && target) {
52
+ ReactDOM.flushSync(() => target.dispatchEvent(event));
53
+ }
54
+ else {
55
+ target.dispatchEvent(event);
56
+ }
57
+ }
58
+ //# sourceMappingURL=dispatchCustomEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatchCustomEvent.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/dispatchCustomEvent.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AASjC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE,qBAAqB;IACpC,oBAAoB,EAAE,4BAA4B;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,mBAAmB,CAIjC,IAAY,EACZ,OAAyC,EACzC,MAEU,EACV,EAAE,QAAQ,KAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE;IAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAwB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAExE,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useEscapeKeydown(callback?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
@@ -0,0 +1,15 @@
1
+ import { useEffect } from "react";
2
+ import { useCallbackRef } from "../../../util/hooks/index.js";
3
+ export function useEscapeKeydown(callback, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
4
+ const onEscapeKeyDown = useCallbackRef(callback);
5
+ useEffect(() => {
6
+ const handleKeyDown = (event) => {
7
+ if (event.key === "Escape") {
8
+ onEscapeKeyDown(event);
9
+ }
10
+ };
11
+ ownerDocument.addEventListener("keydown", handleKeyDown, true);
12
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, true);
13
+ }, [onEscapeKeyDown, ownerDocument]);
14
+ }
15
+ //# sourceMappingURL=useEscapeKeydown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEscapeKeydown.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/useEscapeKeydown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,UAAU,gBAAgB,CAC9B,QAAyC,EACzC,gBAA0B,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;IAE9C,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEjD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC7C,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,eAAe,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QAC/D,OAAO,GAAG,EAAE,CACV,aAAa,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { CustomFocusEvent } from "./dispatchCustomEvent.js";
2
+ /**
3
+ * Tracks focus outside a React subtree. Returns props for the subtree root.
4
+ */
5
+ export declare function useFocusOutside(callback?: (event: CustomFocusEvent) => void, ownerDocument?: Document): {
6
+ onFocusCapture: () => boolean;
7
+ onBlurCapture: () => boolean;
8
+ };
@@ -0,0 +1,38 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { useCallbackRef } from "../../../util/hooks/index.js";
3
+ import { CUSTOM_EVENTS, dispatchCustomEvent, } from "./dispatchCustomEvent.js";
4
+ /**
5
+ * Tracks focus outside a React subtree. Returns props for the subtree root.
6
+ */
7
+ export function useFocusOutside(callback, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
8
+ const handleFocusOutside = useCallbackRef(callback);
9
+ const isFocusInsideReactTreeRef = useRef(false);
10
+ useEffect(() => {
11
+ const handleFocus = (event) => {
12
+ if (event.target && !isFocusInsideReactTreeRef.current) {
13
+ const eventDetail = { originalEvent: event };
14
+ /**
15
+ * The `DismisableLayer`-API is based on the ability to stop events from propagating and in the end calling `onDismiss`
16
+ * if `useFocusOutside`-callback runs `event.preventDefault()`.
17
+ *
18
+ * Because of the `focusin`-event not being cancelable,
19
+ * we need to use a custom event to ensure that the event is cancelable.
20
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event
21
+ * > The focusin event is not cancelable.
22
+ */
23
+ dispatchCustomEvent(CUSTOM_EVENTS.FOCUS_OUTSIDE, handleFocusOutside, eventDetail);
24
+ }
25
+ };
26
+ ownerDocument.addEventListener("focusin", handleFocus);
27
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
28
+ }, [ownerDocument, handleFocusOutside]);
29
+ /**
30
+ * By directly setting isFocusInsideReactTreeRef on focus-events at the root of the "dismissable" element,
31
+ * we can eliminate the need for DOM traversal to verify if the focused element is within the react tree.
32
+ */
33
+ return {
34
+ onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),
35
+ onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),
36
+ };
37
+ }
38
+ //# sourceMappingURL=useFocusOutside.js.map