@contember/react-utils 1.2.6 → 1.3.0-alpha.10

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 (261) hide show
  1. package/dist/development/context/createNonNullableContextFactory.cjs +17 -0
  2. package/dist/development/context/createNonNullableContextFactory.cjs.map +1 -0
  3. package/dist/development/context/createNonNullableContextFactory.js.map +1 -1
  4. package/dist/development/context/createOptionalContextFactory.cjs +13 -0
  5. package/dist/development/context/createOptionalContextFactory.cjs.map +1 -0
  6. package/dist/development/debug-context/Constants.cjs +25 -0
  7. package/dist/development/debug-context/Constants.cjs.map +1 -0
  8. package/dist/development/debug-context/Context.cjs +72 -0
  9. package/dist/development/debug-context/Context.cjs.map +1 -0
  10. package/dist/development/debug-context/Context.js +4 -3
  11. package/dist/development/debug-context/Context.js.map +1 -1
  12. package/dist/development/hooks/unwrapRefValue.cjs +11 -0
  13. package/dist/development/hooks/unwrapRefValue.cjs.map +1 -0
  14. package/dist/development/hooks/useAbortController.cjs +17 -0
  15. package/dist/development/hooks/useAbortController.cjs.map +1 -0
  16. package/dist/development/hooks/useAddClassNameDuringResize.cjs +32 -0
  17. package/dist/development/hooks/useAddClassNameDuringResize.cjs.map +1 -0
  18. package/dist/development/hooks/useArrayMapMemo.cjs +11 -0
  19. package/dist/development/hooks/useArrayMapMemo.cjs.map +1 -0
  20. package/dist/development/hooks/useAutoHeightTextArea.cjs +41 -0
  21. package/dist/development/hooks/useAutoHeightTextArea.cjs.map +1 -0
  22. package/dist/development/hooks/useChildrenAsLabel.cjs +53 -0
  23. package/dist/development/hooks/useChildrenAsLabel.cjs.map +1 -0
  24. package/dist/development/hooks/useCloseOnClickOutside.cjs +25 -0
  25. package/dist/development/hooks/useCloseOnClickOutside.cjs.map +1 -0
  26. package/dist/development/hooks/useCloseOnClickOutside.js +25 -0
  27. package/dist/development/hooks/useCloseOnClickOutside.js.map +1 -0
  28. package/dist/development/hooks/useCloseOnEscape.cjs +20 -0
  29. package/dist/development/hooks/useCloseOnEscape.cjs.map +1 -0
  30. package/dist/development/hooks/useCloseOnEscape.js +20 -0
  31. package/dist/development/hooks/useCloseOnEscape.js.map +1 -0
  32. package/dist/development/hooks/useComposeRef.cjs +31 -0
  33. package/dist/development/hooks/useComposeRef.cjs.map +1 -0
  34. package/dist/development/hooks/useConstantLengthInvariant.cjs +15 -0
  35. package/dist/development/hooks/useConstantLengthInvariant.cjs.map +1 -0
  36. package/dist/development/hooks/useConstantLengthInvariant.js.map +1 -1
  37. package/dist/development/hooks/useConstantValueInvariant.cjs +15 -0
  38. package/dist/development/hooks/useConstantValueInvariant.cjs.map +1 -0
  39. package/dist/development/hooks/useConstantValueInvariant.js.map +1 -1
  40. package/dist/development/hooks/useContainerWidth.cjs +14 -0
  41. package/dist/development/hooks/useContainerWidth.cjs.map +1 -0
  42. package/dist/development/hooks/useDebounce.cjs +15 -0
  43. package/dist/development/hooks/useDebounce.cjs.map +1 -0
  44. package/dist/development/hooks/useDebounceCallback.cjs +19 -0
  45. package/dist/development/hooks/useDebounceCallback.cjs.map +1 -0
  46. package/dist/development/hooks/useDocumentTitle.cjs +22 -0
  47. package/dist/development/hooks/useDocumentTitle.cjs.map +1 -0
  48. package/dist/development/hooks/useElementSize.cjs +37 -0
  49. package/dist/development/hooks/useElementSize.cjs.map +1 -0
  50. package/dist/development/hooks/useElementTopOffset.cjs +29 -0
  51. package/dist/development/hooks/useElementTopOffset.cjs.map +1 -0
  52. package/dist/development/hooks/useEventHandler.cjs +19 -0
  53. package/dist/development/hooks/useEventHandler.cjs.map +1 -0
  54. package/dist/development/hooks/useExpectSameValueReference.cjs +24 -0
  55. package/dist/development/hooks/useExpectSameValueReference.cjs.map +1 -0
  56. package/dist/development/hooks/useForceRender.cjs +9 -0
  57. package/dist/development/hooks/useForceRender.cjs.map +1 -0
  58. package/dist/development/hooks/useId.cjs +13 -0
  59. package/dist/development/hooks/useId.cjs.map +1 -0
  60. package/dist/development/hooks/useId.js.map +1 -1
  61. package/dist/development/hooks/useIsMounted.cjs +18 -0
  62. package/dist/development/hooks/useIsMounted.cjs.map +1 -0
  63. package/dist/development/hooks/useObjectMemo.cjs +27 -0
  64. package/dist/development/hooks/useObjectMemo.cjs.map +1 -0
  65. package/dist/development/hooks/useOnElementClickOutsideCallback.cjs +20 -0
  66. package/dist/development/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
  67. package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
  68. package/dist/development/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
  69. package/dist/development/hooks/useOnElementMutation.cjs +35 -0
  70. package/dist/development/hooks/useOnElementMutation.cjs.map +1 -0
  71. package/dist/development/hooks/useOnElementResize.cjs +42 -0
  72. package/dist/development/hooks/useOnElementResize.cjs.map +1 -0
  73. package/dist/development/hooks/useOnScrollWithin.cjs +52 -0
  74. package/dist/development/hooks/useOnScrollWithin.cjs.map +1 -0
  75. package/dist/development/hooks/useOnWindowResize.cjs +36 -0
  76. package/dist/development/hooks/useOnWindowResize.cjs.map +1 -0
  77. package/dist/development/hooks/usePreviousValue.cjs +12 -0
  78. package/dist/development/hooks/usePreviousValue.cjs.map +1 -0
  79. package/dist/development/hooks/useScrollOffsets.cjs +67 -0
  80. package/dist/development/hooks/useScrollOffsets.cjs.map +1 -0
  81. package/dist/development/hooks/useStoredState.cjs +23 -0
  82. package/dist/development/hooks/useStoredState.cjs.map +1 -0
  83. package/dist/development/hooks/useUpdatedRef.cjs +10 -0
  84. package/dist/development/hooks/useUpdatedRef.cjs.map +1 -0
  85. package/dist/development/hooks/useWindowSize.cjs +20 -0
  86. package/dist/development/hooks/useWindowSize.cjs.map +1 -0
  87. package/dist/development/index.cjs +116 -0
  88. package/dist/development/index.cjs.map +1 -0
  89. package/dist/development/index.js +4 -0
  90. package/dist/development/index.js.map +1 -1
  91. package/dist/development/referentiallyStable/emptyArray.cjs +5 -0
  92. package/dist/development/referentiallyStable/emptyArray.cjs.map +1 -0
  93. package/dist/development/referentiallyStable/emptyObject.cjs +5 -0
  94. package/dist/development/referentiallyStable/emptyObject.cjs.map +1 -0
  95. package/dist/development/referentiallyStable/identityFunction.cjs +5 -0
  96. package/dist/development/referentiallyStable/identityFunction.cjs.map +1 -0
  97. package/dist/development/referentiallyStable/noop.cjs +5 -0
  98. package/dist/development/referentiallyStable/noop.cjs.map +1 -0
  99. package/dist/development/referentiallyStable/returnFalse.cjs +5 -0
  100. package/dist/development/referentiallyStable/returnFalse.cjs.map +1 -0
  101. package/dist/development/referentiallyStable/returnTrue.cjs +5 -0
  102. package/dist/development/referentiallyStable/returnTrue.cjs.map +1 -0
  103. package/dist/development/referentiallyStable/useReferentiallyStableCallback.cjs +12 -0
  104. package/dist/development/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
  105. package/dist/development/theming/ColorSchemeProvider.cjs +16 -0
  106. package/dist/development/theming/ColorSchemeProvider.cjs.map +1 -0
  107. package/dist/development/theming/ColorSchemeProvider.js +8 -10
  108. package/dist/development/theming/ColorSchemeProvider.js.map +1 -1
  109. package/dist/development/theming/GlobalClassNamePrefixContext.cjs +6 -0
  110. package/dist/development/theming/GlobalClassNamePrefixContext.cjs.map +1 -0
  111. package/dist/development/theming/contexts.cjs +12 -0
  112. package/dist/development/theming/contexts.cjs.map +1 -0
  113. package/dist/development/theming/useClassName.cjs +17 -0
  114. package/dist/development/theming/useClassName.cjs.map +1 -0
  115. package/dist/development/theming/useClassName.js.map +1 -1
  116. package/dist/development/theming/useClassNameFactory.cjs +22 -0
  117. package/dist/development/theming/useClassNameFactory.cjs.map +1 -0
  118. package/dist/development/theming/useClassNameFactory.js.map +1 -1
  119. package/dist/development/theming/useThemedClassName.cjs +17 -0
  120. package/dist/development/theming/useThemedClassName.cjs.map +1 -0
  121. package/dist/development/theming/useThemedClassNameFactory.cjs +29 -0
  122. package/dist/development/theming/useThemedClassNameFactory.cjs.map +1 -0
  123. package/dist/development/theming/useThemedClassNameFactory.js.map +1 -1
  124. package/dist/production/context/createNonNullableContextFactory.cjs +17 -0
  125. package/dist/production/context/createNonNullableContextFactory.cjs.map +1 -0
  126. package/dist/production/context/createNonNullableContextFactory.js.map +1 -1
  127. package/dist/production/context/createOptionalContextFactory.cjs +13 -0
  128. package/dist/production/context/createOptionalContextFactory.cjs.map +1 -0
  129. package/dist/production/debug-context/Constants.cjs +25 -0
  130. package/dist/production/debug-context/Constants.cjs.map +1 -0
  131. package/dist/production/debug-context/Context.cjs +68 -0
  132. package/dist/production/debug-context/Context.cjs.map +1 -0
  133. package/dist/production/debug-context/Context.js +3 -2
  134. package/dist/production/debug-context/Context.js.map +1 -1
  135. package/dist/production/hooks/unwrapRefValue.cjs +11 -0
  136. package/dist/production/hooks/unwrapRefValue.cjs.map +1 -0
  137. package/dist/production/hooks/useAbortController.cjs +17 -0
  138. package/dist/production/hooks/useAbortController.cjs.map +1 -0
  139. package/dist/production/hooks/useAddClassNameDuringResize.cjs +32 -0
  140. package/dist/production/hooks/useAddClassNameDuringResize.cjs.map +1 -0
  141. package/dist/production/hooks/useArrayMapMemo.cjs +9 -0
  142. package/dist/production/hooks/useArrayMapMemo.cjs.map +1 -0
  143. package/dist/production/hooks/useAutoHeightTextArea.cjs +41 -0
  144. package/dist/production/hooks/useAutoHeightTextArea.cjs.map +1 -0
  145. package/dist/production/hooks/useChildrenAsLabel.cjs +52 -0
  146. package/dist/production/hooks/useChildrenAsLabel.cjs.map +1 -0
  147. package/dist/production/hooks/useChildrenAsLabel.js.map +1 -1
  148. package/dist/production/hooks/useCloseOnClickOutside.cjs +25 -0
  149. package/dist/production/hooks/useCloseOnClickOutside.cjs.map +1 -0
  150. package/dist/production/hooks/useCloseOnClickOutside.js +25 -0
  151. package/dist/production/hooks/useCloseOnClickOutside.js.map +1 -0
  152. package/dist/production/hooks/useCloseOnEscape.cjs +20 -0
  153. package/dist/production/hooks/useCloseOnEscape.cjs.map +1 -0
  154. package/dist/production/hooks/useCloseOnEscape.js +20 -0
  155. package/dist/production/hooks/useCloseOnEscape.js.map +1 -0
  156. package/dist/production/hooks/useComposeRef.cjs +31 -0
  157. package/dist/production/hooks/useComposeRef.cjs.map +1 -0
  158. package/dist/production/hooks/useConstantLengthInvariant.cjs +6 -0
  159. package/dist/production/hooks/useConstantLengthInvariant.cjs.map +1 -0
  160. package/dist/production/hooks/useConstantValueInvariant.cjs +6 -0
  161. package/dist/production/hooks/useConstantValueInvariant.cjs.map +1 -0
  162. package/dist/production/hooks/useContainerWidth.cjs +14 -0
  163. package/dist/production/hooks/useContainerWidth.cjs.map +1 -0
  164. package/dist/production/hooks/useDebounce.cjs +15 -0
  165. package/dist/production/hooks/useDebounce.cjs.map +1 -0
  166. package/dist/production/hooks/useDebounceCallback.cjs +19 -0
  167. package/dist/production/hooks/useDebounceCallback.cjs.map +1 -0
  168. package/dist/production/hooks/useDocumentTitle.cjs +22 -0
  169. package/dist/production/hooks/useDocumentTitle.cjs.map +1 -0
  170. package/dist/production/hooks/useElementSize.cjs +37 -0
  171. package/dist/production/hooks/useElementSize.cjs.map +1 -0
  172. package/dist/production/hooks/useElementTopOffset.cjs +29 -0
  173. package/dist/production/hooks/useElementTopOffset.cjs.map +1 -0
  174. package/dist/production/hooks/useEventHandler.cjs +19 -0
  175. package/dist/production/hooks/useEventHandler.cjs.map +1 -0
  176. package/dist/production/hooks/useExpectSameValueReference.cjs +15 -0
  177. package/dist/production/hooks/useExpectSameValueReference.cjs.map +1 -0
  178. package/dist/production/hooks/useForceRender.cjs +9 -0
  179. package/dist/production/hooks/useForceRender.cjs.map +1 -0
  180. package/dist/production/hooks/useId.cjs +13 -0
  181. package/dist/production/hooks/useId.cjs.map +1 -0
  182. package/dist/production/hooks/useId.js.map +1 -1
  183. package/dist/production/hooks/useIsMounted.cjs +18 -0
  184. package/dist/production/hooks/useIsMounted.cjs.map +1 -0
  185. package/dist/production/hooks/useObjectMemo.cjs +27 -0
  186. package/dist/production/hooks/useObjectMemo.cjs.map +1 -0
  187. package/dist/production/hooks/useOnElementClickOutsideCallback.cjs +20 -0
  188. package/dist/production/hooks/useOnElementClickOutsideCallback.cjs.map +1 -0
  189. package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.cjs +33 -0
  190. package/dist/production/hooks/useOnElementMouseEnterDelayedCallback.cjs.map +1 -0
  191. package/dist/production/hooks/useOnElementMutation.cjs +35 -0
  192. package/dist/production/hooks/useOnElementMutation.cjs.map +1 -0
  193. package/dist/production/hooks/useOnElementResize.cjs +42 -0
  194. package/dist/production/hooks/useOnElementResize.cjs.map +1 -0
  195. package/dist/production/hooks/useOnScrollWithin.cjs +52 -0
  196. package/dist/production/hooks/useOnScrollWithin.cjs.map +1 -0
  197. package/dist/production/hooks/useOnWindowResize.cjs +36 -0
  198. package/dist/production/hooks/useOnWindowResize.cjs.map +1 -0
  199. package/dist/production/hooks/usePreviousValue.cjs +12 -0
  200. package/dist/production/hooks/usePreviousValue.cjs.map +1 -0
  201. package/dist/production/hooks/useScrollOffsets.cjs +67 -0
  202. package/dist/production/hooks/useScrollOffsets.cjs.map +1 -0
  203. package/dist/production/hooks/useStoredState.cjs +23 -0
  204. package/dist/production/hooks/useStoredState.cjs.map +1 -0
  205. package/dist/production/hooks/useUpdatedRef.cjs +10 -0
  206. package/dist/production/hooks/useUpdatedRef.cjs.map +1 -0
  207. package/dist/production/hooks/useWindowSize.cjs +20 -0
  208. package/dist/production/hooks/useWindowSize.cjs.map +1 -0
  209. package/dist/production/index.cjs +116 -0
  210. package/dist/production/index.cjs.map +1 -0
  211. package/dist/production/index.js +4 -0
  212. package/dist/production/index.js.map +1 -1
  213. package/dist/production/referentiallyStable/emptyArray.cjs +5 -0
  214. package/dist/production/referentiallyStable/emptyArray.cjs.map +1 -0
  215. package/dist/production/referentiallyStable/emptyObject.cjs +5 -0
  216. package/dist/production/referentiallyStable/emptyObject.cjs.map +1 -0
  217. package/dist/production/referentiallyStable/identityFunction.cjs +5 -0
  218. package/dist/production/referentiallyStable/identityFunction.cjs.map +1 -0
  219. package/dist/production/referentiallyStable/noop.cjs +5 -0
  220. package/dist/production/referentiallyStable/noop.cjs.map +1 -0
  221. package/dist/production/referentiallyStable/returnFalse.cjs +5 -0
  222. package/dist/production/referentiallyStable/returnFalse.cjs.map +1 -0
  223. package/dist/production/referentiallyStable/returnTrue.cjs +5 -0
  224. package/dist/production/referentiallyStable/returnTrue.cjs.map +1 -0
  225. package/dist/production/referentiallyStable/useReferentiallyStableCallback.cjs +12 -0
  226. package/dist/production/referentiallyStable/useReferentiallyStableCallback.cjs.map +1 -0
  227. package/dist/production/theming/ColorSchemeProvider.cjs +12 -0
  228. package/dist/production/theming/ColorSchemeProvider.cjs.map +1 -0
  229. package/dist/production/theming/ColorSchemeProvider.js +4 -6
  230. package/dist/production/theming/ColorSchemeProvider.js.map +1 -1
  231. package/dist/production/theming/GlobalClassNamePrefixContext.cjs +6 -0
  232. package/dist/production/theming/GlobalClassNamePrefixContext.cjs.map +1 -0
  233. package/dist/production/theming/contexts.cjs +12 -0
  234. package/dist/production/theming/contexts.cjs.map +1 -0
  235. package/dist/production/theming/useClassName.cjs +17 -0
  236. package/dist/production/theming/useClassName.cjs.map +1 -0
  237. package/dist/production/theming/useClassName.js.map +1 -1
  238. package/dist/production/theming/useClassNameFactory.cjs +22 -0
  239. package/dist/production/theming/useClassNameFactory.cjs.map +1 -0
  240. package/dist/production/theming/useClassNameFactory.js.map +1 -1
  241. package/dist/production/theming/useThemedClassName.cjs +17 -0
  242. package/dist/production/theming/useThemedClassName.cjs.map +1 -0
  243. package/dist/production/theming/useThemedClassNameFactory.cjs +29 -0
  244. package/dist/production/theming/useThemedClassNameFactory.cjs.map +1 -0
  245. package/dist/production/theming/useThemedClassNameFactory.js.map +1 -1
  246. package/dist/types/debug-context/Context.d.ts.map +1 -1
  247. package/dist/types/hooks/index.d.ts +2 -0
  248. package/dist/types/hooks/index.d.ts.map +1 -1
  249. package/dist/types/hooks/useCloseOnClickOutside.d.ts +7 -0
  250. package/dist/types/hooks/useCloseOnClickOutside.d.ts.map +1 -0
  251. package/dist/types/hooks/useCloseOnEscape.d.ts +5 -0
  252. package/dist/types/hooks/useCloseOnEscape.d.ts.map +1 -0
  253. package/dist/types/theming/ColorSchemeProvider.d.ts +3 -4
  254. package/dist/types/theming/ColorSchemeProvider.d.ts.map +1 -1
  255. package/dist/types/tsconfig.tsbuildinfo +1 -1
  256. package/package.json +10 -3
  257. package/src/debug-context/Context.tsx +3 -3
  258. package/src/hooks/index.ts +2 -0
  259. package/src/hooks/useCloseOnClickOutside.ts +27 -0
  260. package/src/hooks/useCloseOnEscape.ts +18 -0
  261. package/src/theming/ColorSchemeProvider.tsx +8 -11
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const unwrapRefValue = require("./unwrapRefValue.cjs");
5
+ const Context = require("../debug-context/Context.cjs");
6
+ function useOnScrollWithin(refOrElement, callback, interval = 1e3 / 60) {
7
+ const scopedConsoleRef = Context.useScopedConsoleRef("useOnScrollWithin");
8
+ const callbackRef = react.useRef(callback);
9
+ callbackRef.current = callback;
10
+ const lastTimeStamp = react.useRef(0);
11
+ react.useLayoutEffect(() => {
12
+ const element = unwrapRefValue.unwrapRefValue(refOrElement);
13
+ let timeoutID = void 0;
14
+ if (element) {
15
+ let debouncedHandler = function(event) {
16
+ clearTimeout(timeoutID);
17
+ const delta = event.timeStamp - lastTimeStamp.current;
18
+ scopedConsoleRef.current.logged("event:element.scroll:delta", delta);
19
+ if (delta > interval) {
20
+ scopedConsoleRef.current.warned("event:element.scroll:immediately", event);
21
+ callbackRef.current(event);
22
+ lastTimeStamp.current = event.timeStamp;
23
+ } else {
24
+ timeoutID = setTimeout(() => {
25
+ scopedConsoleRef.current.warned("event:element.scroll:debounced", event);
26
+ lastTimeStamp.current = event.timeStamp;
27
+ callbackRef.current(event);
28
+ }, interval);
29
+ }
30
+ };
31
+ if (element instanceof HTMLElement) {
32
+ if (element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement) {
33
+ window.addEventListener("scroll", debouncedHandler, { capture: true, passive: true });
34
+ window.addEventListener("resize", debouncedHandler);
35
+ return () => {
36
+ window.removeEventListener("scroll", debouncedHandler);
37
+ window.removeEventListener("resize", debouncedHandler);
38
+ };
39
+ } else {
40
+ element.addEventListener("scroll", debouncedHandler, { passive: true, capture: true });
41
+ return () => {
42
+ element.removeEventListener("scroll", debouncedHandler);
43
+ };
44
+ }
45
+ } else {
46
+ throw new Error("Exhaustive error: Expecting element to be instance of HTMLElement");
47
+ }
48
+ }
49
+ }, [interval, refOrElement, scopedConsoleRef]);
50
+ }
51
+ exports.useOnScrollWithin = useOnScrollWithin;
52
+ //# sourceMappingURL=useOnScrollWithin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnScrollWithin.cjs","sources":["../../../src/hooks/useOnScrollWithin.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\n\n/**\n * Invokes callback on scroll event within the scroll container\n *\n * @param refOrElement - Scroll container\n * @param callback - Callback that is invoked on scroll event\n * @param interval - Specifies how often should scroll event invoke callback\n */\nexport function useOnScrollWithin(\n\trefOrElement: RefObjectOrElement<HTMLElement | null> | null,\n\tcallback: (event: Event) => void,\n\tinterval: number = 1000 / 60,\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnScrollWithin')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tuseLayoutEffect(() => {\n\t\tconst element = unwrapRefValue(refOrElement)\n\n\t\tlet timeoutID: number | undefined = undefined\n\n\t\tif (element) {\n\t\t\tfunction debouncedHandler(event: Event) {\n\t\t\t\tclearTimeout(timeoutID)\n\n\t\t\t\tconst delta = event.timeStamp - lastTimeStamp.current\n\t\t\t\tscopedConsoleRef.current.logged('event:element.scroll:delta', delta)\n\n\t\t\t\tif (delta > interval) {\n\t\t\t\t\tscopedConsoleRef.current.warned('event:element.scroll:immediately', event)\n\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t} else {\n\t\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\t\tscopedConsoleRef.current.warned('event:element.scroll:debounced', event)\n\t\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t\t}, interval)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (element instanceof HTMLElement) {\n\t\t\t\tif (element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement) {\n\t\t\t\t\twindow.addEventListener('scroll', debouncedHandler, { capture: true, passive: true })\n\t\t\t\t\twindow.addEventListener('resize', debouncedHandler)\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\twindow.removeEventListener('scroll', debouncedHandler)\n\t\t\t\t\t\twindow.removeEventListener('resize', debouncedHandler)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\telement.addEventListener('scroll', debouncedHandler, { passive: true, capture: true })\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\telement.removeEventListener('scroll', debouncedHandler)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error('Exhaustive error: Expecting element to be instance of HTMLElement')\n\t\t\t}\n\t\t}\n\t}, [interval, refOrElement, scopedConsoleRef])\n}\n"],"names":["useScopedConsoleRef","useRef","useLayoutEffect","unwrapRefValue"],"mappings":";;;;;AAWO,SAAS,kBACf,cACA,UACA,WAAmB,MAAO,IACzB;AACK,QAAA,mBAAmBA,4BAAoB,mBAAmB;AAE1D,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgBA,aAAe,CAAC;AAEtCC,QAAAA,gBAAgB,MAAM;AACf,UAAA,UAAUC,8BAAe,YAAY;AAE3C,QAAI,YAAgC;AAEpC,QAAI,SAAS;AACH,UAAA,mBAAT,SAA0B,OAAc;AACvC,qBAAa,SAAS;AAEhB,cAAA,QAAQ,MAAM,YAAY,cAAc;AAC7B,yBAAA,QAAQ,OAAO,8BAA8B,KAAK;AAEnE,YAAI,QAAQ,UAAU;AACJ,2BAAA,QAAQ,OAAO,oCAAoC,KAAK;AACzE,sBAAY,QAAQ,KAAK;AACzB,wBAAc,UAAU,MAAM;AAAA,QAAA,OACxB;AACN,sBAAY,WAAW,MAAM;AACX,6BAAA,QAAQ,OAAO,kCAAkC,KAAK;AACvE,0BAAc,UAAU,MAAM;AAC9B,wBAAY,QAAQ,KAAK;AAAA,aACvB,QAAQ;AAAA,QACZ;AAAA,MAAA;AAGD,UAAI,mBAAmB,aAAa;AAC/B,YAAA,mBAAmB,mBAAmB,mBAAmB,iBAAiB;AACtE,iBAAA,iBAAiB,UAAU,kBAAkB,EAAE,SAAS,MAAM,SAAS,MAAM;AAC7E,iBAAA,iBAAiB,UAAU,gBAAgB;AAElD,iBAAO,MAAM;AACL,mBAAA,oBAAoB,UAAU,gBAAgB;AAC9C,mBAAA,oBAAoB,UAAU,gBAAgB;AAAA,UAAA;AAAA,QACtD,OACM;AACE,kBAAA,iBAAiB,UAAU,kBAAkB,EAAE,SAAS,MAAM,SAAS,MAAM;AAErF,iBAAO,MAAM;AACJ,oBAAA,oBAAoB,UAAU,gBAAgB;AAAA,UAAA;AAAA,QAExD;AAAA,MAAA,OACM;AACA,cAAA,IAAI,MAAM,mEAAmE;AAAA,MACpF;AAAA,IACD;AAAA,EACE,GAAA,CAAC,UAAU,cAAc,gBAAgB,CAAC;AAC9C;;"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const Context = require("../debug-context/Context.cjs");
5
+ function useOnWindowResize(callback, interval = 300) {
6
+ const scopedConsoleRef = Context.useScopedConsoleRef("useOnWindowResize");
7
+ const callbackRef = react.useRef(callback);
8
+ callbackRef.current = callback;
9
+ const lastTimeStamp = react.useRef(0);
10
+ react.useLayoutEffect(() => {
11
+ let timeoutID = void 0;
12
+ function debouncedHandler(event) {
13
+ clearTimeout(timeoutID);
14
+ const delta = event.timeStamp - lastTimeStamp.current;
15
+ scopedConsoleRef.current.logged("window.resize:delta", delta);
16
+ if (delta > interval) {
17
+ scopedConsoleRef.current.warned("event:window.resize:immediately", null);
18
+ callbackRef.current(event);
19
+ lastTimeStamp.current = event.timeStamp;
20
+ } else {
21
+ timeoutID = setTimeout(() => {
22
+ scopedConsoleRef.current.warned("event:window.resize:debounced", null);
23
+ lastTimeStamp.current = event.timeStamp;
24
+ callbackRef.current(event);
25
+ }, interval);
26
+ }
27
+ }
28
+ window.addEventListener("resize", debouncedHandler);
29
+ return () => {
30
+ clearTimeout(timeoutID);
31
+ window.removeEventListener("resize", debouncedHandler);
32
+ };
33
+ }, [callbackRef, interval, scopedConsoleRef]);
34
+ }
35
+ exports.useOnWindowResize = useOnWindowResize;
36
+ //# sourceMappingURL=useOnWindowResize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnWindowResize.cjs","sources":["../../../src/hooks/useOnWindowResize.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\n\nexport function useOnWindowResize(\n\tcallback: (event: Event) => void,\n\tinterval: number = 300,\n) {\n\tconst scopedConsoleRef = useScopedConsoleRef('useOnWindowResize')\n\n\tconst callbackRef = useRef(callback); callbackRef.current = callback\n\tconst lastTimeStamp = useRef<number>(0)\n\n\tuseLayoutEffect(() => {\n\t\tlet timeoutID: number | undefined = undefined\n\n\t\tfunction debouncedHandler(event: Event) {\n\t\t\tclearTimeout(timeoutID)\n\n\t\t\tconst delta = event.timeStamp - lastTimeStamp.current\n\t\t\tscopedConsoleRef.current.logged('window.resize:delta', delta)\n\n\t\t\tif (delta > interval) {\n\t\t\t\tscopedConsoleRef.current.warned('event:window.resize:immediately', null)\n\t\t\t\tcallbackRef.current(event)\n\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t} else {\n\t\t\t\ttimeoutID = setTimeout(() => {\n\t\t\t\t\tscopedConsoleRef.current.warned('event:window.resize:debounced', null)\n\t\t\t\t\tlastTimeStamp.current = event.timeStamp\n\t\t\t\t\tcallbackRef.current(event)\n\t\t\t\t}, interval)\n\t\t\t}\n\t\t}\n\n\t\twindow.addEventListener('resize', debouncedHandler)\n\n\t\treturn () => {\n\t\t\tclearTimeout(timeoutID)\n\t\t\twindow.removeEventListener('resize', debouncedHandler)\n\t\t}\n\t}, [callbackRef, interval, scopedConsoleRef])\n}\n"],"names":["useScopedConsoleRef","useRef","useLayoutEffect"],"mappings":";;;;AAGgB,SAAA,kBACf,UACA,WAAmB,KAClB;AACK,QAAA,mBAAmBA,4BAAoB,mBAAmB;AAE1D,QAAA,cAAcC,aAAO,QAAQ;AAAG,cAAY,UAAU;AACtD,QAAA,gBAAgBA,aAAe,CAAC;AAEtCC,QAAAA,gBAAgB,MAAM;AACrB,QAAI,YAAgC;AAEpC,aAAS,iBAAiB,OAAc;AACvC,mBAAa,SAAS;AAEhB,YAAA,QAAQ,MAAM,YAAY,cAAc;AAC7B,uBAAA,QAAQ,OAAO,uBAAuB,KAAK;AAE5D,UAAI,QAAQ,UAAU;AACJ,yBAAA,QAAQ,OAAO,mCAAmC,IAAI;AACvE,oBAAY,QAAQ,KAAK;AACzB,sBAAc,UAAU,MAAM;AAAA,MAAA,OACxB;AACN,oBAAY,WAAW,MAAM;AACX,2BAAA,QAAQ,OAAO,iCAAiC,IAAI;AACrE,wBAAc,UAAU,MAAM;AAC9B,sBAAY,QAAQ,KAAK;AAAA,WACvB,QAAQ;AAAA,MACZ;AAAA,IACD;AAEO,WAAA,iBAAiB,UAAU,gBAAgB;AAElD,WAAO,MAAM;AACZ,mBAAa,SAAS;AACf,aAAA,oBAAoB,UAAU,gBAAgB;AAAA,IAAA;AAAA,EAEpD,GAAA,CAAC,aAAa,UAAU,gBAAgB,CAAC;AAC7C;;"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const usePreviousValue = (value) => {
5
+ const ref = react.useRef(value);
6
+ react.useEffect(() => {
7
+ ref.current = value;
8
+ });
9
+ return ref.current;
10
+ };
11
+ exports.usePreviousValue = usePreviousValue;
12
+ //# sourceMappingURL=usePreviousValue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreviousValue.cjs","sources":["../../../src/hooks/usePreviousValue.ts"],"sourcesContent":["import { useEffect, useRef } from 'react'\n\nexport const usePreviousValue = <Value>(value: Value) => {\n\tconst ref = useRef<Value>(value)\n\tuseEffect(() => {\n\t\tref.current = value\n\t})\n\treturn ref.current\n}\n"],"names":["useRef","useEffect"],"mappings":";;;AAEa,MAAA,mBAAmB,CAAQ,UAAiB;AAClD,QAAA,MAAMA,aAAc,KAAK;AAC/BC,QAAAA,UAAU,MAAM;AACf,QAAI,UAAU;AAAA,EAAA,CACd;AACD,SAAO,IAAI;AACZ;;"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utilities = require("@contember/utilities");
4
+ const react = require("react");
5
+ const unwrapRefValue = require("./unwrapRefValue.cjs");
6
+ const useOnScrollWithin = require("./useOnScrollWithin.cjs");
7
+ const useOnWindowResize = require("./useOnWindowResize.cjs");
8
+ const Context = require("../debug-context/Context.cjs");
9
+ const useReferentiallyStableCallback = require("../referentiallyStable/useReferentiallyStableCallback.cjs");
10
+ function useScrollOffsets(refOrElement, interval = 1e3 / 60) {
11
+ const { logged } = Context.useScopedConsoleRef("useScrollOffsets").current;
12
+ const [top, setTop] = react.useState(0);
13
+ const [bottom, setBottom] = react.useState(0);
14
+ const [left, setLeft] = react.useState(0);
15
+ const [right, setRight] = react.useState(0);
16
+ const updateScrollOffsetsState = useReferentiallyStableCallback.useReferentiallyStableCallback((offsets) => {
17
+ logged("Update the offsets:", {
18
+ previous: { bottom, left, right, top },
19
+ next: offsets
20
+ });
21
+ if (offsets.bottom !== bottom)
22
+ setBottom(offsets.bottom);
23
+ if (offsets.left !== left)
24
+ setLeft(offsets.left);
25
+ if (offsets.right !== right)
26
+ setRight(offsets.right);
27
+ if (offsets.top !== top)
28
+ setTop(offsets.top);
29
+ });
30
+ const handler = useReferentiallyStableCallback.useReferentiallyStableCallback(() => {
31
+ const maybeScrollContent = unwrapRefValue.unwrapRefValue(refOrElement) ?? document;
32
+ if (maybeScrollContent) {
33
+ getElementScrollOffsets(maybeScrollContent).then(updateScrollOffsetsState);
34
+ }
35
+ });
36
+ useOnScrollWithin.useOnScrollWithin(refOrElement, handler, interval);
37
+ useOnWindowResize.useOnWindowResize(handler);
38
+ react.useLayoutEffect(handler, [handler]);
39
+ return react.useMemo(() => ({ bottom, left, right, top }), [bottom, left, right, top]);
40
+ }
41
+ function isIntrinsicScrollElement(element) {
42
+ return element instanceof HTMLBodyElement || element instanceof HTMLHtmlElement || element instanceof DocumentType || element instanceof Document || element instanceof HTMLDocument;
43
+ }
44
+ function getIntrinsicScrollContainer(element) {
45
+ const html = document.body.parentElement;
46
+ utilities.assert("HTML element exists", html, (value) => value instanceof HTMLElement);
47
+ if (isIntrinsicScrollElement(element)) {
48
+ return html;
49
+ } else {
50
+ return element;
51
+ }
52
+ }
53
+ async function getElementScrollOffsets(element) {
54
+ const isIntrinsicScrolling = isIntrinsicScrollElement(element);
55
+ const scrollContainer = getIntrinsicScrollContainer(element);
56
+ const { scrollLeft, scrollTop, scrollHeight, scrollWidth } = scrollContainer;
57
+ const { height: scrollContainerHeight, width: scrollContainerWidth } = await utilities.getElementDimensions(scrollContainer);
58
+ const height = isIntrinsicScrolling ? window.innerHeight : scrollContainerHeight;
59
+ const width = isIntrinsicScrolling ? window.innerWidth : scrollContainerWidth;
60
+ const left = Math.round(scrollLeft);
61
+ const top = Math.round(scrollTop);
62
+ const right = Math.round(scrollWidth - width - left);
63
+ const bottom = Math.round(scrollHeight - height - top);
64
+ return { bottom, left, right, top };
65
+ }
66
+ exports.useScrollOffsets = useScrollOffsets;
67
+ //# sourceMappingURL=useScrollOffsets.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollOffsets.cjs","sources":["../../../src/hooks/useScrollOffsets.ts"],"sourcesContent":["import { assert, getElementDimensions } from '@contember/utilities'\nimport { useLayoutEffect, useMemo, useState } from 'react'\nimport { useScopedConsoleRef } from '../debug-context'\nimport { useReferentiallyStableCallback } from '../referentiallyStable'\nimport { RefObjectOrElement, unwrapRefValue } from './unwrapRefValue'\nimport { useOnScrollWithin } from './useOnScrollWithin'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport type Offsets = {\n\tbottom: number;\n\tleft: number;\n\tright: number;\n\ttop: number;\n}\n\nexport function useScrollOffsets(refOrElement: RefObjectOrElement<HTMLElement | null> | null, interval: number = 1000 / 60) {\n\tconst { logged } = useScopedConsoleRef('useScrollOffsets').current\n\n\tconst [top, setTop] = useState(0)\n\tconst [bottom, setBottom] = useState(0)\n\tconst [left, setLeft] = useState(0)\n\tconst [right, setRight] = useState(0)\n\n\tconst updateScrollOffsetsState = useReferentiallyStableCallback((offsets: Offsets) => {\n\t\tlogged('Update the offsets:', {\n\t\t\tprevious: { bottom, left, right, top },\n\t\t\tnext: offsets,\n\t\t})\n\n\t\tif (offsets.bottom !== bottom) setBottom(offsets.bottom)\n\t\tif (offsets.left !== left) setLeft(offsets.left)\n\t\tif (offsets.right !== right) setRight(offsets.right)\n\t\tif (offsets.top !== top) setTop(offsets.top)\n\t})\n\n\tconst handler = useReferentiallyStableCallback(() => {\n\t\tconst maybeScrollContent = unwrapRefValue(refOrElement) ?? document\n\n\t\tif (maybeScrollContent) {\n\t\t\tgetElementScrollOffsets(maybeScrollContent).then(updateScrollOffsetsState)\n\t\t}\n\t})\n\n\tuseOnScrollWithin(refOrElement, handler, interval)\n\tuseOnWindowResize(handler)\n\tuseLayoutEffect(handler, [handler])\n\n\treturn useMemo(() => ({ bottom, left, right, top }), [bottom, left, right, top])\n}\n\nfunction isIntrinsicScrollElement(element: unknown): element is Document {\n\treturn element instanceof HTMLBodyElement\n\t\t|| element instanceof HTMLHtmlElement\n\t\t|| element instanceof DocumentType\n\t\t|| element instanceof Document\n\t\t|| element instanceof HTMLDocument\n}\n\nfunction getIntrinsicScrollContainer(element: HTMLElement | Document): HTMLElement {\n\tconst html = document.body.parentElement\n\tassert('HTML element exists', html, (value): value is HTMLElement => value instanceof HTMLElement)\n\n\tif (isIntrinsicScrollElement(element)) {\n\t\treturn html\n\t} else {\n\t\treturn element\n\t}\n}\n\nasync function getElementScrollOffsets(element: HTMLElement | Document): Promise<Offsets> {\n\tconst isIntrinsicScrolling = isIntrinsicScrollElement(element)\n\tconst scrollContainer = getIntrinsicScrollContainer(element)\n\n\tconst { scrollLeft, scrollTop, scrollHeight, scrollWidth } = scrollContainer\n\tconst { height: scrollContainerHeight, width: scrollContainerWidth } = await getElementDimensions(scrollContainer)\n\n\tconst height = isIntrinsicScrolling ? window.innerHeight : scrollContainerHeight\n\tconst width = isIntrinsicScrolling ? window.innerWidth : scrollContainerWidth\n\n\tconst left = Math.round(scrollLeft)\n\tconst top = Math.round(scrollTop)\n\n\tconst right = Math.round(scrollWidth - width - left)\n\tconst bottom = Math.round(scrollHeight - height - top)\n\n\treturn { bottom, left, right, top }\n}\n"],"names":["useScopedConsoleRef","useState","useReferentiallyStableCallback","unwrapRefValue","useOnScrollWithin","useOnWindowResize","useLayoutEffect","useMemo","assert","getElementDimensions"],"mappings":";;;;;;;;;AAeO,SAAS,iBAAiB,cAA6D,WAAmB,MAAO,IAAI;AAC3H,QAAM,EAAE,OAAW,IAAAA,QAAA,oBAAoB,kBAAkB,EAAE;AAE3D,QAAM,CAAC,KAAK,MAAM,IAAIC,eAAS,CAAC;AAChC,QAAM,CAAC,QAAQ,SAAS,IAAIA,eAAS,CAAC;AACtC,QAAM,CAAC,MAAM,OAAO,IAAIA,eAAS,CAAC;AAClC,QAAM,CAAC,OAAO,QAAQ,IAAIA,eAAS,CAAC;AAE9B,QAAA,2BAA2BC,8DAA+B,CAAC,YAAqB;AACrF,WAAO,uBAAuB;AAAA,MAC7B,UAAU,EAAE,QAAQ,MAAM,OAAO,IAAI;AAAA,MACrC,MAAM;AAAA,IAAA,CACN;AAED,QAAI,QAAQ,WAAW;AAAQ,gBAAU,QAAQ,MAAM;AACvD,QAAI,QAAQ,SAAS;AAAM,cAAQ,QAAQ,IAAI;AAC/C,QAAI,QAAQ,UAAU;AAAO,eAAS,QAAQ,KAAK;AACnD,QAAI,QAAQ,QAAQ;AAAK,aAAO,QAAQ,GAAG;AAAA,EAAA,CAC3C;AAEK,QAAA,UAAUA,+BAAAA,+BAA+B,MAAM;AAC9C,UAAA,qBAAqBC,eAAAA,eAAe,YAAY,KAAK;AAE3D,QAAI,oBAAoB;AACC,8BAAA,kBAAkB,EAAE,KAAK,wBAAwB;AAAA,IAC1E;AAAA,EAAA,CACA;AAEiBC,oBAAAA,kBAAA,cAAc,SAAS,QAAQ;AACjDC,oBAAA,kBAAkB,OAAO;AACTC,QAAAA,gBAAA,SAAS,CAAC,OAAO,CAAC;AAElC,SAAOC,MAAQ,QAAA,OAAO,EAAE,QAAQ,MAAM,OAAO,QAAQ,CAAC,QAAQ,MAAM,OAAO,GAAG,CAAC;AAChF;AAEA,SAAS,yBAAyB,SAAuC;AACjE,SAAA,mBAAmB,mBACtB,mBAAmB,mBACnB,mBAAmB,gBACnB,mBAAmB,YACnB,mBAAmB;AACxB;AAEA,SAAS,4BAA4B,SAA8C;AAC5E,QAAA,OAAO,SAAS,KAAK;AAC3BC,YAAA,OAAO,uBAAuB,MAAM,CAAC,UAAgC,iBAAiB,WAAW;AAE7F,MAAA,yBAAyB,OAAO,GAAG;AAC/B,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACR;AACD;AAEA,eAAe,wBAAwB,SAAmD;AACnF,QAAA,uBAAuB,yBAAyB,OAAO;AACvD,QAAA,kBAAkB,4BAA4B,OAAO;AAE3D,QAAM,EAAE,YAAY,WAAW,cAAc,gBAAgB;AACvD,QAAA,EAAE,QAAQ,uBAAuB,OAAO,yBAAyB,MAAMC,UAAAA,qBAAqB,eAAe;AAE3G,QAAA,SAAS,uBAAuB,OAAO,cAAc;AACrD,QAAA,QAAQ,uBAAuB,OAAO,aAAa;AAEnD,QAAA,OAAO,KAAK,MAAM,UAAU;AAC5B,QAAA,MAAM,KAAK,MAAM,SAAS;AAEhC,QAAM,QAAQ,KAAK,MAAM,cAAc,QAAQ,IAAI;AACnD,QAAM,SAAS,KAAK,MAAM,eAAe,SAAS,GAAG;AAErD,SAAO,EAAE,QAAQ,MAAM,OAAO,IAAI;AACnC;;"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const createStoredStateHook = (getStorage) => {
5
+ return (key, initializeValue) => {
6
+ const storage = getStorage();
7
+ const [value, setValue] = react.useState(() => {
8
+ const value2 = storage.getItem(key);
9
+ const parsedValue = value2 !== null ? JSON.parse(value2) : void 0;
10
+ return initializeValue(parsedValue);
11
+ });
12
+ return [value, react.useCallback((value2) => {
13
+ setValue((current) => {
14
+ const newValue = typeof value2 === "function" ? value2(current) : value2;
15
+ storage.setItem(key, JSON.stringify(newValue));
16
+ return newValue;
17
+ });
18
+ }, [key, storage])];
19
+ };
20
+ };
21
+ const useSessionStorageState = createStoredStateHook(() => sessionStorage);
22
+ exports.useSessionStorageState = useSessionStorageState;
23
+ //# sourceMappingURL=useStoredState.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStoredState.cjs","sources":["../../../src/hooks/useStoredState.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\nimport { Serializable } from '../types'\n\nexport type SetState<V extends Serializable> = (value: V | ((current: V) => V)) => void;\nexport type ValueInitializer<V extends Serializable> = (storedValue: V | undefined) => V;\n\nconst createStoredStateHook = (getStorage: () => Storage) => {\n\treturn <V extends Serializable>(key: string, initializeValue: ValueInitializer<V>): [V, SetState<V>] => {\n\t\tconst storage = getStorage()\n\t\tconst [value, setValue] = useState<V>(() => {\n\t\t\tconst value = storage.getItem(key)\n\t\t\tconst parsedValue: V | undefined = value !== null ? JSON.parse(value) : undefined\n\t\t\treturn initializeValue(parsedValue)\n\t\t})\n\t\treturn [value, useCallback(value => {\n\t\t\tsetValue(current => {\n\t\t\t\tconst newValue = typeof value === 'function' ? (value as (current: V) => V)(current) : value\n\t\t\t\tstorage.setItem(key, JSON.stringify(newValue))\n\t\t\t\treturn newValue\n\t\t\t})\n\t\t}, [key, storage])]\n\t}\n\n}\n\nexport const useSessionStorageState = createStoredStateHook(() => sessionStorage)\n"],"names":["useState","value","useCallback"],"mappings":";;;AAMA,MAAM,wBAAwB,CAAC,eAA8B;AACrD,SAAA,CAAyB,KAAa,oBAA2D;AACvG,UAAM,UAAU;AAChB,UAAM,CAAC,OAAO,QAAQ,IAAIA,eAAY,MAAM;AACrCC,YAAAA,SAAQ,QAAQ,QAAQ,GAAG;AACjC,YAAM,cAA6BA,WAAU,OAAO,KAAK,MAAMA,MAAK,IAAI;AACxE,aAAO,gBAAgB,WAAW;AAAA,IAAA,CAClC;AACD,WAAO,CAAC,OAAOC,kBAAY,CAAAD,WAAS;AACnC,eAAS,CAAW,YAAA;AACnB,cAAM,WAAW,OAAOA,WAAU,aAAcA,OAA4B,OAAO,IAAIA;AACvF,gBAAQ,QAAQ,KAAK,KAAK,UAAU,QAAQ,CAAC;AACtC,eAAA;AAAA,MAAA,CACP;AAAA,IACC,GAAA,CAAC,KAAK,OAAO,CAAC,CAAC;AAAA,EAAA;AAGpB;AAEa,MAAA,yBAAyB,sBAAsB,MAAM,cAAc;;"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ function useUpdatedRef(value) {
5
+ const ref = react.useRef(value);
6
+ ref.current = value;
7
+ return ref;
8
+ }
9
+ exports.useUpdatedRef = useUpdatedRef;
10
+ //# sourceMappingURL=useUpdatedRef.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUpdatedRef.cjs","sources":["../../../src/hooks/useUpdatedRef.ts"],"sourcesContent":["import { useRef } from 'react'\n\n/**\n * Returns a stable mutable object with value that is updated upon each call\n *\n * @param value - Value that could update after initial call\n * @returns Mutable ref object with updated value\n */\nexport function useUpdatedRef<T>(value: T) {\n\tconst ref = useRef(value)\n\tref.current = value\n\n\treturn ref\n}\n"],"names":["useRef"],"mappings":";;;AAQO,SAAS,cAAiB,OAAU;AACpC,QAAA,MAAMA,aAAO,KAAK;AACxB,MAAI,UAAU;AAEP,SAAA;AACR;;"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const useOnWindowResize = require("./useOnWindowResize.cjs");
5
+ function useWindowSize() {
6
+ const [width, setWidth] = react.useState(window.innerWidth);
7
+ const [height, setHeight] = react.useState(window.innerHeight);
8
+ useOnWindowResize.useOnWindowResize(() => {
9
+ const { innerHeight, innerWidth } = window;
10
+ if (innerHeight !== height) {
11
+ setHeight(innerHeight);
12
+ }
13
+ if (innerWidth !== width) {
14
+ setWidth(innerWidth);
15
+ }
16
+ });
17
+ return react.useMemo(() => ({ height, width }), [height, width]);
18
+ }
19
+ exports.useWindowSize = useWindowSize;
20
+ //# sourceMappingURL=useWindowSize.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWindowSize.cjs","sources":["../../../src/hooks/useWindowSize.ts"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport { useOnWindowResize } from './useOnWindowResize'\n\nexport function useWindowSize() {\n const [width, setWidth] = useState(window.innerWidth)\n const [height, setHeight] = useState(window.innerHeight)\n\n useOnWindowResize(() => {\n const { innerHeight, innerWidth } = window\n if (innerHeight !== height) {\n setHeight(innerHeight)\n }\n\n if (innerWidth !== width) {\n setWidth(innerWidth)\n }\n })\n\n return useMemo(() => ({ height, width }), [height, width])\n}\n"],"names":["useState","useOnWindowResize","useMemo"],"mappings":";;;;AAGO,SAAS,gBAAgB;AAC9B,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAS,OAAO,UAAU;AACpD,QAAM,CAAC,QAAQ,SAAS,IAAIA,MAAAA,SAAS,OAAO,WAAW;AAEvDC,oBAAAA,kBAAkB,MAAM;AAChB,UAAA,EAAE,aAAa,WAAe,IAAA;AACpC,QAAI,gBAAgB,QAAQ;AAC1B,gBAAU,WAAW;AAAA,IACvB;AAEA,QAAI,eAAe,OAAO;AACxB,eAAS,UAAU;AAAA,IACrB;AAAA,EAAA,CACD;AAEM,SAAAC,MAAA,QAAQ,OAAO,EAAE,QAAQ,MAAU,IAAA,CAAC,QAAQ,KAAK,CAAC;AAC3D;;"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const createNonNullableContextFactory = require("./context/createNonNullableContextFactory.cjs");
4
+ const createOptionalContextFactory = require("./context/createOptionalContextFactory.cjs");
5
+ const Constants = require("./debug-context/Constants.cjs");
6
+ const Context = require("./debug-context/Context.cjs");
7
+ const unwrapRefValue = require("./hooks/unwrapRefValue.cjs");
8
+ const useAbortController = require("./hooks/useAbortController.cjs");
9
+ const useAddClassNameDuringResize = require("./hooks/useAddClassNameDuringResize.cjs");
10
+ const useArrayMapMemo = require("./hooks/useArrayMapMemo.cjs");
11
+ const useAutoHeightTextArea = require("./hooks/useAutoHeightTextArea.cjs");
12
+ const useChildrenAsLabel = require("./hooks/useChildrenAsLabel.cjs");
13
+ const useCloseOnClickOutside = require("./hooks/useCloseOnClickOutside.cjs");
14
+ const useCloseOnEscape = require("./hooks/useCloseOnEscape.cjs");
15
+ const useComposeRef = require("./hooks/useComposeRef.cjs");
16
+ const useConstantLengthInvariant = require("./hooks/useConstantLengthInvariant.cjs");
17
+ const useConstantValueInvariant = require("./hooks/useConstantValueInvariant.cjs");
18
+ const useContainerWidth = require("./hooks/useContainerWidth.cjs");
19
+ const useDebounce = require("./hooks/useDebounce.cjs");
20
+ const useDebounceCallback = require("./hooks/useDebounceCallback.cjs");
21
+ const useDocumentTitle = require("./hooks/useDocumentTitle.cjs");
22
+ const useElementSize = require("./hooks/useElementSize.cjs");
23
+ const useElementTopOffset = require("./hooks/useElementTopOffset.cjs");
24
+ const useEventHandler = require("./hooks/useEventHandler.cjs");
25
+ const useExpectSameValueReference = require("./hooks/useExpectSameValueReference.cjs");
26
+ const useForceRender = require("./hooks/useForceRender.cjs");
27
+ const useId = require("./hooks/useId.cjs");
28
+ const useIsMounted = require("./hooks/useIsMounted.cjs");
29
+ const useObjectMemo = require("./hooks/useObjectMemo.cjs");
30
+ const useOnElementClickOutsideCallback = require("./hooks/useOnElementClickOutsideCallback.cjs");
31
+ const useOnElementMouseEnterDelayedCallback = require("./hooks/useOnElementMouseEnterDelayedCallback.cjs");
32
+ const useOnElementMutation = require("./hooks/useOnElementMutation.cjs");
33
+ const useOnElementResize = require("./hooks/useOnElementResize.cjs");
34
+ const useOnScrollWithin = require("./hooks/useOnScrollWithin.cjs");
35
+ const useOnWindowResize = require("./hooks/useOnWindowResize.cjs");
36
+ const usePreviousValue = require("./hooks/usePreviousValue.cjs");
37
+ const useScrollOffsets = require("./hooks/useScrollOffsets.cjs");
38
+ const useStoredState = require("./hooks/useStoredState.cjs");
39
+ const useUpdatedRef = require("./hooks/useUpdatedRef.cjs");
40
+ const useWindowSize = require("./hooks/useWindowSize.cjs");
41
+ const emptyArray = require("./referentiallyStable/emptyArray.cjs");
42
+ const emptyObject = require("./referentiallyStable/emptyObject.cjs");
43
+ const identityFunction = require("./referentiallyStable/identityFunction.cjs");
44
+ const noop = require("./referentiallyStable/noop.cjs");
45
+ const returnFalse = require("./referentiallyStable/returnFalse.cjs");
46
+ const returnTrue = require("./referentiallyStable/returnTrue.cjs");
47
+ const useReferentiallyStableCallback = require("./referentiallyStable/useReferentiallyStableCallback.cjs");
48
+ const ColorSchemeProvider = require("./theming/ColorSchemeProvider.cjs");
49
+ const GlobalClassNamePrefixContext = require("./theming/GlobalClassNamePrefixContext.cjs");
50
+ const contexts = require("./theming/contexts.cjs");
51
+ const useClassName = require("./theming/useClassName.cjs");
52
+ const useClassNameFactory = require("./theming/useClassNameFactory.cjs");
53
+ const useThemedClassName = require("./theming/useThemedClassName.cjs");
54
+ const useThemedClassNameFactory = require("./theming/useThemedClassNameFactory.cjs");
55
+ exports.createNonNullableContextFactory = createNonNullableContextFactory.createNonNullableContextFactory;
56
+ exports.createOptionalContextFactory = createOptionalContextFactory.createOptionalContextFactory;
57
+ exports.isNoopScopedConsole = Constants.isNoopScopedConsole;
58
+ exports.noopLog = Constants.noopLog;
59
+ exports.noopLogged = Constants.noopLogged;
60
+ exports.noopScopedConsole = Constants.noopScopedConsole;
61
+ exports.DebugChildren = Context.DebugChildren;
62
+ exports.ScopedConsoleContext = Context.ScopedConsoleContext;
63
+ exports.useScopedConsoleRef = Context.useScopedConsoleRef;
64
+ exports.unwrapRefValue = unwrapRefValue.unwrapRefValue;
65
+ exports.useAbortController = useAbortController.useAbortController;
66
+ exports.useAddClassNameDuringResize = useAddClassNameDuringResize.useAddClassNameDuringResize;
67
+ exports.useArrayMapMemo = useArrayMapMemo.useArrayMapMemo;
68
+ exports.useAutoHeightTextArea = useAutoHeightTextArea.useAutoHeightTextArea;
69
+ exports.getChildrenAsLabel = useChildrenAsLabel.getChildrenAsLabel;
70
+ exports.useChildrenAsLabel = useChildrenAsLabel.useChildrenAsLabel;
71
+ exports.useCloseOnClickOutside = useCloseOnClickOutside.useCloseOnClickOutside;
72
+ exports.useCloseOnEscape = useCloseOnEscape.useCloseOnEscape;
73
+ exports.useComposeRef = useComposeRef.useComposeRef;
74
+ exports.useConstantLengthInvariant = useConstantLengthInvariant.useConstantLengthInvariant;
75
+ exports.useConstantValueInvariant = useConstantValueInvariant.useConstantValueInvariant;
76
+ exports.ContainerWidthContext = useContainerWidth.ContainerWidthContext;
77
+ exports.useContainerWidth = useContainerWidth.useContainerWidth;
78
+ exports.useDebounce = useDebounce.useDebounce;
79
+ exports.useDebounceCallback = useDebounceCallback.useDebounceCallback;
80
+ exports.useDocumentTitle = useDocumentTitle.useDocumentTitle;
81
+ exports.useElementSize = useElementSize.useElementSize;
82
+ exports.useElementTopOffset = useElementTopOffset.useElementTopOffset;
83
+ exports.useEventHandler = useEventHandler.useEventHandler;
84
+ exports.useExpectSameValueReference = useExpectSameValueReference.useExpectSameValueReference;
85
+ exports.useForceRender = useForceRender.useForceRender;
86
+ exports.useId = useId.useId;
87
+ exports.useIsMounted = useIsMounted.useIsMounted;
88
+ exports.useObjectMemo = useObjectMemo.useObjectMemo;
89
+ exports.useOnElementClickOutsideCallback = useOnElementClickOutsideCallback.useOnElementClickOutsideCallback;
90
+ exports.useOnElementMouseEnterDelayedCallback = useOnElementMouseEnterDelayedCallback.useOnElementMouseEnterDelayedCallback;
91
+ exports.useOnElementMutation = useOnElementMutation.useOnElementMutation;
92
+ exports.useOnElementResize = useOnElementResize.useOnElementResize;
93
+ exports.useOnScrollWithin = useOnScrollWithin.useOnScrollWithin;
94
+ exports.useOnWindowResize = useOnWindowResize.useOnWindowResize;
95
+ exports.usePreviousValue = usePreviousValue.usePreviousValue;
96
+ exports.useScrollOffsets = useScrollOffsets.useScrollOffsets;
97
+ exports.useSessionStorageState = useStoredState.useSessionStorageState;
98
+ exports.useUpdatedRef = useUpdatedRef.useUpdatedRef;
99
+ exports.useWindowSize = useWindowSize.useWindowSize;
100
+ exports.emptyArray = emptyArray.emptyArray;
101
+ exports.emptyObject = emptyObject.emptyObject;
102
+ exports.identityFunction = identityFunction.identityFunction;
103
+ exports.noop = noop.noop;
104
+ exports.returnFalse = returnFalse.returnFalse;
105
+ exports.returnTrue = returnTrue.returnTrue;
106
+ exports.useReferentiallyStableCallback = useReferentiallyStableCallback.useReferentiallyStableCallback;
107
+ exports.ColorSchemeProvider = ColorSchemeProvider.ColorSchemeProvider;
108
+ exports.GlobalClassNamePrefixContext = GlobalClassNamePrefixContext.GlobalClassNamePrefixContext;
109
+ exports.ColorSchemeContext = contexts.ColorSchemeContext;
110
+ exports.DEFAULT_COLOR_SCHEME = contexts.DEFAULT_COLOR_SCHEME;
111
+ exports.useColorScheme = contexts.useColorScheme;
112
+ exports.useClassName = useClassName.useClassName;
113
+ exports.useClassNameFactory = useClassNameFactory.useClassNameFactory;
114
+ exports.useThemedClassName = useThemedClassName.useThemedClassName;
115
+ exports.useThemedClassNameFactory = useThemedClassNameFactory.useThemedClassNameFactory;
116
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,6 +8,8 @@ import { useAddClassNameDuringResize } from "./hooks/useAddClassNameDuringResize
8
8
  import { useArrayMapMemo } from "./hooks/useArrayMapMemo.js";
9
9
  import { useAutoHeightTextArea } from "./hooks/useAutoHeightTextArea.js";
10
10
  import { getChildrenAsLabel, useChildrenAsLabel } from "./hooks/useChildrenAsLabel.js";
11
+ import { useCloseOnClickOutside } from "./hooks/useCloseOnClickOutside.js";
12
+ import { useCloseOnEscape } from "./hooks/useCloseOnEscape.js";
11
13
  import { useComposeRef } from "./hooks/useComposeRef.js";
12
14
  import { useConstantLengthInvariant } from "./hooks/useConstantLengthInvariant.js";
13
15
  import { useConstantValueInvariant } from "./hooks/useConstantValueInvariant.js";
@@ -77,6 +79,8 @@ export {
77
79
  useChildrenAsLabel,
78
80
  useClassName,
79
81
  useClassNameFactory,
82
+ useCloseOnClickOutside,
83
+ useCloseOnEscape,
80
84
  useColorScheme,
81
85
  useComposeRef,
82
86
  useConstantLengthInvariant,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const emptyArray = Object.freeze([]);
4
+ exports.emptyArray = emptyArray;
5
+ //# sourceMappingURL=emptyArray.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emptyArray.cjs","sources":["../../../src/referentiallyStable/emptyArray.ts"],"sourcesContent":["export const emptyArray = Object.freeze<any>([]) as any[]\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,OAAO,OAAY,CAAE,CAAA;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const emptyObject = Object.freeze({});
4
+ exports.emptyObject = emptyObject;
5
+ //# sourceMappingURL=emptyObject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emptyObject.cjs","sources":["../../../src/referentiallyStable/emptyObject.ts"],"sourcesContent":["export const emptyObject = Object.freeze({})\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,OAAO,OAAO,CAAE,CAAA;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const identityFunction = (value) => value;
4
+ exports.identityFunction = identityFunction;
5
+ //# sourceMappingURL=identityFunction.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityFunction.cjs","sources":["../../../src/referentiallyStable/identityFunction.ts"],"sourcesContent":["export const identityFunction = <Value>(value: Value) => value\n"],"names":[],"mappings":";;AAAa,MAAA,mBAAmB,CAAQ,UAAiB;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const noop = () => void 0;
4
+ exports.noop = noop;
5
+ //# sourceMappingURL=noop.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.cjs","sources":["../../../src/referentiallyStable/noop.ts"],"sourcesContent":["export const noop = () => undefined\n"],"names":[],"mappings":";;AAAO,MAAM,OAAO,MAAM;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const returnFalse = () => false;
4
+ exports.returnFalse = returnFalse;
5
+ //# sourceMappingURL=returnFalse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"returnFalse.cjs","sources":["../../../src/referentiallyStable/returnFalse.ts"],"sourcesContent":["export const returnFalse = () => false\n"],"names":[],"mappings":";;AAAO,MAAM,cAAc,MAAM;;"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const returnTrue = () => true;
4
+ exports.returnTrue = returnTrue;
5
+ //# sourceMappingURL=returnTrue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"returnTrue.cjs","sources":["../../../src/referentiallyStable/returnTrue.ts"],"sourcesContent":["export const returnTrue = () => true\n"],"names":[],"mappings":";;AAAO,MAAM,aAAa,MAAM;;"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const useReferentiallyStableCallback = (callback) => {
5
+ const ref = react.useRef(callback);
6
+ ref.current = callback;
7
+ return react.useCallback((...args) => {
8
+ return ref.current(...args);
9
+ }, []);
10
+ };
11
+ exports.useReferentiallyStableCallback = useReferentiallyStableCallback;
12
+ //# sourceMappingURL=useReferentiallyStableCallback.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReferentiallyStableCallback.cjs","sources":["../../../src/referentiallyStable/useReferentiallyStableCallback.ts"],"sourcesContent":["import { useCallback, useRef } from 'react'\n\n// TODO: Should be possible to remove when React.useEvent() lands\nexport const useReferentiallyStableCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n\tconst ref = useRef(callback)\n\tref.current = callback\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\treturn useCallback<T>(((...args: any[]) => {\n\t\treturn ref.current(...args)\n\t}) as T, [])\n}\n"],"names":["useRef","useCallback"],"mappings":";;;AAGa,MAAA,iCAAiC,CAAoC,aAAmB;AAC9F,QAAA,MAAMA,aAAO,QAAQ;AAC3B,MAAI,UAAU;AAEP,SAAAC,MAAA,YAAgB,IAAI,SAAgB;AACnC,WAAA,IAAI,QAAQ,GAAG,IAAI;AAAA,EAC3B,GAAS,CAAE,CAAA;AACZ;;"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const react = require("react");
5
+ const contexts = require("./contexts.cjs");
6
+ const ColorSchemeProvider = react.memo(({ children, scheme }) => {
7
+ const inheritedColorScheme = contexts.useColorScheme();
8
+ return /* @__PURE__ */ jsxRuntime.jsx(contexts.ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children });
9
+ });
10
+ ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
11
+ exports.ColorSchemeProvider = ColorSchemeProvider;
12
+ //# sourceMappingURL=ColorSchemeProvider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorSchemeProvider.cjs","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps = {\n\tchildren: React.ReactNode\n\tscheme?: string\n}\n\nexport const ColorSchemeProvider = memo(({ children, scheme }: ColorSchemeProviderProps) => {\n\tconst inheritedColorScheme = useColorScheme()\n\n\treturn (\n\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t)\n})\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":["memo","useColorScheme","ColorSchemeContext"],"mappings":";;;;;AAQO,MAAM,sBAAsBA,MAAAA,KAAK,CAAC,EAAE,UAAU,aAAuC;AAC3F,QAAM,uBAAuBC,SAAAA;AAE7B,wCACEC,SAAmB,mBAAA,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAAS,CAAA;AAEhF,CAAC;AACD,oBAAoB,cAAc;;"}
@@ -1,12 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { memo } from "react";
3
3
  import { useColorScheme, ColorSchemeContext } from "./contexts.js";
4
- const ColorSchemeProvider = memo(
5
- ({ children, scheme }) => {
6
- const inheritedColorScheme = useColorScheme();
7
- return /* @__PURE__ */ jsx(ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children });
8
- }
9
- );
4
+ const ColorSchemeProvider = memo(({ children, scheme }) => {
5
+ const inheritedColorScheme = useColorScheme();
6
+ return /* @__PURE__ */ jsx(ColorSchemeContext.Provider, { value: scheme ?? inheritedColorScheme, children });
7
+ });
10
8
  ColorSchemeProvider.displayName = "Interface.ColorSchemeProvider";
11
9
  export {
12
10
  ColorSchemeProvider
@@ -1 +1 @@
1
- {"version":3,"file":"ColorSchemeProvider.js","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { KebabCase } from '@contember/utilities'\nimport { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps<T extends KebabCase<string>> = {\n\tchildren: React.ReactNode\n\tscheme?: T\n}\n\nexport const ColorSchemeProvider = memo(\n\t<T extends KebabCase<string>>({ children, scheme }: ColorSchemeProviderProps<T>) => {\n\t\tconst inheritedColorScheme = useColorScheme()\n\n\t\treturn (\n\t\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t\t)\n\t},\n)\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":[],"mappings":";;;AASO,MAAM,sBAAsB;AAAA,EAClC,CAA8B,EAAE,UAAU,aAA0C;AACnF,UAAM,uBAAuB;AAE7B,+BACE,mBAAmB,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAAS,CAAA;AAAA,EAEhF;AACD;AACA,oBAAoB,cAAc;"}
1
+ {"version":3,"file":"ColorSchemeProvider.js","sources":["../../../src/theming/ColorSchemeProvider.tsx"],"sourcesContent":["import { memo } from 'react'\nimport { ColorSchemeContext, useColorScheme } from './contexts'\n\nexport type ColorSchemeProviderProps = {\n\tchildren: React.ReactNode\n\tscheme?: string\n}\n\nexport const ColorSchemeProvider = memo(({ children, scheme }: ColorSchemeProviderProps) => {\n\tconst inheritedColorScheme = useColorScheme()\n\n\treturn (\n\t\t<ColorSchemeContext.Provider value={scheme ?? inheritedColorScheme}>{children}</ColorSchemeContext.Provider>\n\t)\n})\nColorSchemeProvider.displayName = 'Interface.ColorSchemeProvider'\n"],"names":[],"mappings":";;;AAQO,MAAM,sBAAsB,KAAK,CAAC,EAAE,UAAU,aAAuC;AAC3F,QAAM,uBAAuB;AAE7B,6BACE,mBAAmB,UAAnB,EAA4B,OAAO,UAAU,sBAAuB,SAAS,CAAA;AAEhF,CAAC;AACD,oBAAoB,cAAc;"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const GlobalClassNamePrefixContext = react.createContext("cui-");
5
+ exports.GlobalClassNamePrefixContext = GlobalClassNamePrefixContext;
6
+ //# sourceMappingURL=GlobalClassNamePrefixContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalClassNamePrefixContext.cjs","sources":["../../../src/theming/GlobalClassNamePrefixContext.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport const GlobalClassNamePrefixContext = createContext<string>('cui-')\n"],"names":["createContext"],"mappings":";;;AAEa,MAAA,+BAA+BA,oBAAsB,MAAM;;"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const createOptionalContextFactory = require("../context/createOptionalContextFactory.cjs");
4
+ const DEFAULT_COLOR_SCHEME = "system";
5
+ const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory.createOptionalContextFactory(
6
+ "Interface.ColorScheme",
7
+ DEFAULT_COLOR_SCHEME
8
+ );
9
+ exports.ColorSchemeContext = ColorSchemeContext;
10
+ exports.DEFAULT_COLOR_SCHEME = DEFAULT_COLOR_SCHEME;
11
+ exports.useColorScheme = useColorScheme;
12
+ //# sourceMappingURL=contexts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.cjs","sources":["../../../src/theming/contexts.ts"],"sourcesContent":["import { createOptionalContextFactory } from '../context'\n\nexport const DEFAULT_COLOR_SCHEME = 'system'\n\n\n/**\n * @group UI\n *\n * @description\n * Provides the current color scheme, possible values are `'light'`, `'dark'` or `'system'`.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme\n *\n */\nexport const [ColorSchemeContext, useColorScheme] = createOptionalContextFactory<string>(\n\t'Interface.ColorScheme',\n\tDEFAULT_COLOR_SCHEME,\n)\n"],"names":["createOptionalContextFactory"],"mappings":";;;AAEO,MAAM,uBAAuB;AAYvB,MAAA,CAAC,oBAAoB,cAAc,IAAIA,6BAAA;AAAA,EACnD;AAAA,EACA;AACD;;;;"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utilities = require("@contember/utilities");
4
+ const react = require("react");
5
+ const GlobalClassNamePrefixContext = require("./GlobalClassNamePrefixContext.cjs");
6
+ function useClassName(componentClassName, additionalClassName = null, prefixOverride) {
7
+ const contextPrefix = react.useContext(GlobalClassNamePrefixContext.GlobalClassNamePrefixContext);
8
+ const classNamePrefix = prefixOverride === null || prefixOverride === "" ? "" : prefixOverride || contextPrefix;
9
+ const componentClassNameList = utilities.flatClassNameList(componentClassName).map(
10
+ (componentClassName2) => `${classNamePrefix}${componentClassName2}`
11
+ );
12
+ return utilities.deduplicateClassName(componentClassNameList.concat(
13
+ utilities.flatClassNameList(additionalClassName)
14
+ )).join(" ");
15
+ }
16
+ exports.useClassName = useClassName;
17
+ //# sourceMappingURL=useClassName.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClassName.cjs","sources":["../../../src/theming/useClassName.ts"],"sourcesContent":["import { NestedClassName, deduplicateClassName, flatClassNameList } from '@contember/utilities'\nimport { useContext } from 'react'\nimport { GlobalClassNamePrefixContext } from './GlobalClassNamePrefixContext'\n\n/**\n * Hook for component class name accepting outer class name\n *\n * @param componentClassName - Component class name\n * @param additionalClassName - Additional class name\n * @param prefixOverride - Context component prefix override\n * @returns Prefixed component class name.\n */\nexport function useClassName (\n\tcomponentClassName: NestedClassName,\n\tadditionalClassName: NestedClassName = null,\n\tprefixOverride?: string | null | undefined,\n) {\n\tconst contextPrefix = useContext(GlobalClassNamePrefixContext)\n\tconst classNamePrefix: string = prefixOverride === null || prefixOverride === '' ? '' : prefixOverride || contextPrefix\n\n\tconst componentClassNameList: string[] = flatClassNameList(componentClassName).map(\n\t\tcomponentClassName => `${classNamePrefix}${componentClassName}`,\n\t)\n\n\treturn deduplicateClassName(componentClassNameList.concat(\n\t\tflatClassNameList(additionalClassName),\n\t)).join(' ')\n}\n"],"names":["useContext","GlobalClassNamePrefixContext","flatClassNameList","componentClassName","deduplicateClassName"],"mappings":";;;;;AAYO,SAAS,aACf,oBACA,sBAAuC,MACvC,gBACC;AACK,QAAA,gBAAgBA,iBAAWC,6BAAAA,4BAA4B;AAC7D,QAAM,kBAA0B,mBAAmB,QAAQ,mBAAmB,KAAK,KAAK,kBAAkB;AAEpG,QAAA,yBAAmCC,UAAAA,kBAAkB,kBAAkB,EAAE;AAAA,IAC9E,CAAAC,wBAAsB,GAAG,eAAe,GAAGA,mBAAkB;AAAA,EAAA;AAG9D,SAAOC,UAAAA,qBAAqB,uBAAuB;AAAA,IAClDF,UAAAA,kBAAkB,mBAAmB;AAAA,EAAA,CACrC,EAAE,KAAK,GAAG;AACZ;;"}