@proedis/react 1.5.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +188 -0
  2. package/cjs/components/RenderWhen/RenderWhen.js +1 -1
  3. package/cjs/components/RenderWhen/RenderWhen.js.map +1 -1
  4. package/cjs/hooks/useAutoControlledState.js.map +1 -1
  5. package/cjs/hooks/useClickOutside.js +7 -0
  6. package/cjs/hooks/useClickOutside.js.map +1 -1
  7. package/cjs/hooks/useDataManager.js.map +1 -1
  8. package/cjs/hooks/useDataSelector.js +53 -19
  9. package/cjs/hooks/useDataSelector.js.map +1 -1
  10. package/cjs/hooks/useDebouncedCallback.js.map +1 -1
  11. package/cjs/hooks/useElementType.js.map +1 -1
  12. package/cjs/hooks/useEnhancedEffect.js.map +1 -1
  13. package/cjs/hooks/useEvent.js.map +1 -1
  14. package/cjs/hooks/useForkRef.js +37 -9
  15. package/cjs/hooks/useForkRef.js.map +1 -1
  16. package/cjs/hooks/useInputValue.js.map +1 -1
  17. package/cjs/hooks/useObjectState.js.map +1 -1
  18. package/cjs/hooks/useSafeState.js.map +1 -1
  19. package/cjs/hooks/useSyncedRef.js +37 -5
  20. package/cjs/hooks/useSyncedRef.js.map +1 -1
  21. package/cjs/hooks/useUnmountEffect.js.map +1 -1
  22. package/cjs/hooks/useWindowSize.js.map +1 -1
  23. package/cjs/package.json +3 -0
  24. package/cjs/utils/compose.js.map +1 -1
  25. package/cjs/utils/contextBuilder.js.map +1 -1
  26. package/cjs/utils/shorthands.js +5 -6
  27. package/cjs/utils/shorthands.js.map +1 -1
  28. package/esm/components/RenderWhen/RenderWhen.js +1 -1
  29. package/esm/components/RenderWhen/RenderWhen.js.map +1 -1
  30. package/esm/hooks/useAutoControlledState.js.map +1 -1
  31. package/esm/hooks/useClickOutside.js +7 -0
  32. package/esm/hooks/useClickOutside.js.map +1 -1
  33. package/esm/hooks/useDataManager.js.map +1 -1
  34. package/esm/hooks/useDataSelector.js +53 -19
  35. package/esm/hooks/useDataSelector.js.map +1 -1
  36. package/esm/hooks/useDebouncedCallback.js.map +1 -1
  37. package/esm/hooks/useElementType.js.map +1 -1
  38. package/esm/hooks/useEnhancedEffect.js.map +1 -1
  39. package/esm/hooks/useEvent.js.map +1 -1
  40. package/esm/hooks/useForkRef.js +37 -9
  41. package/esm/hooks/useForkRef.js.map +1 -1
  42. package/esm/hooks/useInputValue.js.map +1 -1
  43. package/esm/hooks/useObjectState.js.map +1 -1
  44. package/esm/hooks/useSafeState.js.map +1 -1
  45. package/esm/hooks/useSyncedRef.js +37 -5
  46. package/esm/hooks/useSyncedRef.js.map +1 -1
  47. package/esm/hooks/useUnmountEffect.js.map +1 -1
  48. package/esm/hooks/useWindowSize.js.map +1 -1
  49. package/esm/package.json +3 -0
  50. package/esm/utils/compose.js.map +1 -1
  51. package/esm/utils/contextBuilder.js.map +1 -1
  52. package/esm/utils/shorthands.js +5 -6
  53. package/esm/utils/shorthands.js.map +1 -1
  54. package/package.json +13 -3
  55. package/types/hooks/useClickOutside.d.ts +10 -2
  56. package/types/hooks/useForkRef.d.ts +31 -4
  57. package/types/hooks/useSyncedRef.d.ts +36 -5
  58. package/tsconfig.declaration.tsbuildinfo +0 -1
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ <div align="center">
2
+
3
+ # `@proedis/react`
4
+
5
+ **The framework-agnostic half of a Proedis React app: typed contexts, shorthand props, and the
6
+ twenty hooks you would otherwise rewrite.** ⚛️
7
+
8
+ [![npm](https://img.shields.io/npm/v/@proedis/react.svg?style=flat-square&color=cb3837&logo=npm)](https://www.npmjs.com/package/@proedis/react)
9
+ [![license](https://img.shields.io/npm/l/@proedis/react.svg?style=flat-square&color=blue)](https://github.com/proedis/Npm.Suite/blob/master/LICENSE)
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ ## ✨ What's in the box
16
+
17
+ No UI kit, no styling, no opinions about how anything looks. 🎨
18
+
19
+ | | |
20
+ | --- | --- |
21
+ | **Contexts** | `contextBuilder` — a context and its hook, with a real error instead of `undefined` |
22
+ | **Component props** | `UIComponentProps` / `UIVoidComponentProps`, the shared prop surface every component starts from |
23
+ | **Shorthands** | `ShorthandItem`, `createShorthandFactory`, `creatableComponent` — accept props *or* a node for the same slot |
24
+ | **Components** | `RenderWhen`, `compose` |
25
+ | **State hooks** | `useAutoControlledState`, `useObjectState`, `useSafeState`, `useInputValue`, `useDataManager`, `useDataSelector` |
26
+ | **Ref hooks** | `useSyncedRef`, `useForkRef` |
27
+ | **Effect hooks** | `useEnhancedEffect`, `useUnmountEffect`, `useDebouncedCallback` |
28
+ | **DOM hooks** | `useEvent`, `useClickOutside`, `useWindowSize`, `useElementType` |
29
+
30
+ ## 📦 Installation
31
+
32
+ ```bash
33
+ yarn add @proedis/react
34
+ ```
35
+
36
+ `react` is a peer, accepted from **18 up to 19** — a range verified by compiling the emitted
37
+ declarations against `@types/react` 18 and 19 with `skipLibCheck` off, not by hoping.
38
+
39
+ ## 🚀 Quick start
40
+
41
+ ```tsx
42
+ import { contextBuilder, RenderWhen, useSyncedRef } from '@proedis/react';
43
+
44
+ /** A context that fails loudly when consumed outside its provider */
45
+ const [ TicketContext, useTicketContext ] = contextBuilder<TicketContextValue>('Ticket');
46
+
47
+ function TicketPanel() {
48
+ const { ticket } = useTicketContext();
49
+
50
+ return (
51
+ <RenderWhen
52
+ condition={ticket.isOpen}
53
+ isTrue={<TicketBody ticket={ticket} />}
54
+ isFalse={<ClosedBanner />}
55
+ />
56
+ );
57
+ }
58
+ ```
59
+
60
+ ## 📖 API
61
+
62
+ ### 🏗️ `contextBuilder(name, initialContext?)`
63
+
64
+ Returns a `[ Context, useContext ]` pair. The hook throws a named error when it runs outside its
65
+ provider, so a missing provider is a message that tells you which context is missing — instead of an
66
+ `undefined` that explodes three components later.
67
+
68
+ ```tsx
69
+ const [ AuthContext, useAuthContext ] = contextBuilder<AuthContextValue>('Auth');
70
+
71
+ <AuthContext.Provider value={value}>…</AuthContext.Provider>
72
+
73
+ const { user } = useAuthContext(); // throws outside the provider, with the name in the message
74
+ ```
75
+
76
+ ### 🎛️ `UIComponentProps` and `UIVoidComponentProps`
77
+
78
+ The prop surface every Proedis component starts from — `className`, `style`, the element type
79
+ override, and children for the non-void one. Compose your own strict props on top:
80
+
81
+ ```tsx
82
+ interface StrictButtonProps {
83
+ color?: ButtonColor;
84
+ loading?: boolean;
85
+ }
86
+
87
+ type ButtonProps = UIComponentProps<StrictButtonProps>;
88
+ ```
89
+
90
+ The second parameter is there for a component wrapping another one's props:
91
+ `UIComponentProps<StrictProps, BaseProps>` keeps your strict props authoritative and inherits the rest.
92
+
93
+ ### 🎁 Shorthands
94
+
95
+ A shorthand slot accepts **either** a ready node **or** the props to build one — which is what lets a
96
+ component expose `icon={'user'}` and `icon={<CustomIcon />}` through a single prop.
97
+
98
+ | Symbol | What it is |
99
+ | --- | --- |
100
+ | `ShorthandItem<Props>` | a node, or the props of the component filling the slot |
101
+ | `ShorthandCollection<Props>` | an array of them, each carrying a `key` |
102
+ | `ShorthandContent` | plain renderable content |
103
+ | `createShorthandFactory(Component, mapValueToProps, computeKey?)` | build the factory that turns a value into an element |
104
+ | `creatableComponent(Component, …)` | attach a `create` method to a component |
105
+ | `renderShorthandContent({ children, content })` | pick between `children` and a `content` prop, in that order |
106
+
107
+ ### 🔀 `RenderWhen` and `compose`
108
+
109
+ `RenderWhen` takes a `condition` and then **one of two shapes**, and the type will not let you mix
110
+ them: either children with an optional boolean `isFalse` inversion, or an `isTrue` / `isFalse` pair of
111
+ nodes and no children at all.
112
+
113
+ ```tsx
114
+ /** children form — render them when the condition holds */
115
+ <RenderWhen condition={isAdmin}>
116
+ <AdminPanel />
117
+ </RenderWhen>
118
+
119
+ /** children form, inverted — 'isFalse' is a boolean here */
120
+ <RenderWhen condition={isAdmin} isFalse>
121
+ <RequestAccess />
122
+ </RenderWhen>
123
+
124
+ /** ternary form — no children, both branches as nodes */
125
+ <RenderWhen condition={isAdmin} isTrue={<AdminPanel />} isFalse={<RequestAccess />} />
126
+ ```
127
+
128
+ ⚠️ `isFalse` means two different things across the two shapes: a boolean inversion with children, a
129
+ node without them. Passing children *and* a node is a compile error, which is the point.
130
+
131
+ `compose(...components)` nests a list of providers into one component, which turns a stack of eight
132
+ providers at the root of an app into a single element.
133
+
134
+ ### 🪝 The hooks
135
+
136
+ | Hook | What it gives you |
137
+ | --- | --- |
138
+ | `useSyncedRef(value)` | a **stable** container whose `current` always reads the latest value — the way to let an effect or a handler see fresh data without being rebuilt |
139
+ | `useForkRef(...refs)` | one ref callback assigning to several refs, for a component that both exposes a ref and keeps one |
140
+ | `useEnhancedEffect` | `useLayoutEffect` in a browser, `useEffect` everywhere else, so SSR stays quiet |
141
+ | `useUnmountEffect(callback)` | run something once, on unmount, always the latest version of it |
142
+ | `useSafeState(initial)` | `useState` whose setter is a no-op after unmount |
143
+ | `useAutoControlledState(…)` | one state that works controlled *or* uncontrolled, the standard prop/defaultProp pattern |
144
+ | `useObjectState(values, options?)` | object state with per-key setters and an `onChange` notification |
145
+ | `useInputValue(initial?)` | value plus change handler for an uncontrolled-ish input |
146
+ | `useDebouncedCallback(fn, delay)` | a debounced callback that always calls the newest `fn` |
147
+ | `useDataManager()` | add / update / remove over a local collection |
148
+ | `useDataSelector(data, options?)` | a selection that is **always** backed by the current data |
149
+ | `useEvent(target, type, handler)` | a DOM listener attached once, calling the newest handler |
150
+ | `useClickOutside(target, callback)` | the outside-click primitive behind every dropdown |
151
+ | `useWindowSize(options?)` | viewport size, debounced |
152
+ | `useElementType(props, default)` | resolve the `as` prop into the element to render |
153
+
154
+ 💡 Several of these are built on `useSyncedRef`, and that is the pattern worth internalising: keep the
155
+ *subscription* stable and let it read a moving value, instead of tearing it down whenever the value
156
+ changes.
157
+
158
+ ⚠️ Read a `useSyncedRef` container from an effect, a handler or a cleanup — **not while rendering**. The
159
+ value is written during render, which is what makes it current for the commit it belongs to, and a
160
+ render that gets discarded leaves the container holding something that was never committed.
161
+
162
+ ## 🔀 Migrating to 2.x
163
+
164
+ | Change | What to do |
165
+ | --- | --- |
166
+ | `useDataSelector` reconciles during render | Nothing, in most cases — and one render fewer per data change. The selection was previously corrected by an effect calling `setState`, so a render could show a selection the data no longer backed. |
167
+ | `onSelectedChange` fires once per real transition | Check any listener that counted calls. It used to fire from two places — synchronously inside the setter, and again from the reconciliation effect — so it also reported things that were not changes: selecting what was already selected, clearing an already empty selection (twice), and resolving `defaultSelected` against the data at mount. It now fires after the commit, once, and only when the resolved selection actually changed. The notification on unmount is unchanged. |
168
+ | No notification for the initial selection | If you relied on being told at mount what `defaultSelected` resolved to, read `selected` instead. The first value is not a transition, so nothing is reported — where before a `defaultSelected` that was not identity-equal to its item in the data produced a notification and an extra render. |
169
+ | A selection restores itself when its item comes back | Nothing to do, but know the shape: the hook stores what you *asked* for and resolves it against the current data on every render. An item that leaves the data and later returns — a filter applied and removed — becomes selected again, and that is reported. It used to store the resolved item and drop it for good. |
170
+ | `useForkRef` parameter type | Now a minimal structural `{ current: T \| null \| undefined }` rather than `React.MutableRefObject`. That is what keeps the same signature valid across `@types/react` 18 and 19; anything that was passing a real ref keeps working. |
171
+ | `RenderWhen` condition grouping | Its condition is now explicitly parenthesised. Same behaviour, but note the shape it always had: with the `isFalse` **inversion**, children render when the condition is false *even if there are no children* to render. |
172
+
173
+ ## 🤝 Compatibility
174
+
175
+ | Requirement | Range |
176
+ | --- | --- |
177
+ | `react` | `>=18.0.0 <20.0.0` (peer) |
178
+ | `typescript` | `>=5.2.0` |
179
+ | Runtime | ES2022 — roughly Safari 16.4 / Chrome 94 |
180
+
181
+ Public signatures deliberately avoid `React.RefObject`, `React.MutableRefObject` and
182
+ `ReturnType<typeof React.useRef<T>>`: those aliases changed meaning between React 18 and 19, and are
183
+ the reason a hook can typecheck under one major and be rejected under the other. Minimal structural
184
+ shapes are used instead.
185
+
186
+ ## 📄 License
187
+
188
+ MIT © [Proedis S.r.l.](https://proedis.net)
@@ -35,7 +35,7 @@ const RenderWhen = (props) => {
35
35
  /** Get props from StrictConditionNode type */
36
36
  const { children, isFalse: invertConditionLogic } = props;
37
37
  /** Check if the node must render or not */
38
- if (children && (!invertConditionLogic && condition) || (invertConditionLogic && !condition)) {
38
+ if ((children && !invertConditionLogic && condition) || (invertConditionLogic && !condition)) {
39
39
  return (jsxRuntime.jsx(React__namespace.Fragment, { children: children }));
40
40
  }
41
41
  /** Return Empty */
@@ -1 +1 @@
1
- {"version":3,"file":"RenderWhen.js","sources":["../../../../src/components/RenderWhen/RenderWhen.tsx"],"sourcesContent":[null],"names":["_jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AAEc;AACd,MAAM,UAAU,GAA6C,CAAC,KAAK,KAAI;;;;AAKrE,IAAA,MAAM,EACJ,SAAS,EACV,GAAG,KAAK,CAAC;;IAIV,IAAI,UAAU,IAAI,KAAK,EAAE;;QAEvB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;;AAG1D,QAAA,IAAI,QAAQ,KAAK,CAAC,oBAAoB,IAAI,SAAS,CAAC,KAAK,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE;YAC5F,QACEA,eAACC,gBAAK,CAAC,QAAQ,EACZ,EAAA,QAAA,EAAA,QAAQ,EACM,CAAA,EACjB;AACH,SAAA;;AAGD,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;;IAID,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;;AAIrE,IAAA,QACED,cAAC,CAAAC,gBAAK,CAAC,QAAQ,cACZ,SAAS,GAAG,eAAe,GAAG,gBAAgB,EAAA,CAChC,EACjB;AAEJ,EAAE;AAEF,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
1
+ {"version":3,"file":"RenderWhen.js","sources":["../../../../src/components/RenderWhen/RenderWhen.tsx"],"sourcesContent":[null],"names":["_jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AAEc;AACd,MAAM,UAAU,GAA6C,CAAC,KAAK,KAAI;;;;AAKrE,IAAA,MAAM,EACJ,SAAS,EACV,GAAG,KAAK;;AAIT,IAAA,IAAI,UAAU,IAAI,KAAK,EAAE;;QAEvB,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,KAAK;;AAGzD,QAAA,IAAI,CAAC,QAAQ,IAAI,CAAC,oBAAoB,IAAI,SAAS,MAAM,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE;YAC5F,QACEA,eAACC,gBAAK,CAAC,QAAQ,EAAA,EAAA,QAAA,EACZ,QAAQ,EAAA,CACM;QAErB;;AAGA,QAAA,OAAO,IAAI;IACb;;IAIA,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK;;AAIpE,IAAA,QACED,cAAA,CAACC,gBAAK,CAAC,QAAQ,cACZ,SAAS,GAAG,eAAe,GAAG,gBAAgB,EAAA,CAChC;AAGrB;AAEA,UAAU,CAAC,WAAW,GAAG,YAAY;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAutoControlledState.js","sources":["../../../src/hooks/useAutoControlledState.ts"],"sourcesContent":[null],"names":["React","useEnhancedEffect","useSafeState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA;;AAEc;AAEd;;;;;;;;AAQG;AACa,SAAA,sBAAsB,CACpC,YAA2B,EAC3B,OAA0C,EAAA;AAI1C;;;;AAIG;IACH,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;AAG9C;;;;;AAKG;IACH,MAAM,gBAAgB,GAAGA,gBAAK,CAAC,MAAM,CAAU,KAAK,KAAK,SAAS,CAAC,CAAC;AAGpE;;;AAGG;IACHC,mCAAiB,CACf,MAAK;AACH,QAAA,gBAAgB,CAAC,OAAO,GAAG,KAAK,KAAK,SAAS,CAAC;AACjD,KAAC,EACD,CAAE,KAAK,CAAE,CACV,CAAC;AAGF;;;;;;AAMG;IACH,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGC,yBAAY,CACtC,MAAK;;AAEH,QAAA,MAAM,WAAW,GAAG,KAAK,KAAK,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;;QAGnE,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,YAAA,OAAO,WAAW,CAAC;AACpB,SAAA;;QAGD,OAAO,OAAO,YAAY,KAAK,UAAU;cACpC,YAAwB,EAAE;cAC3B,YAAY,CAAC;AACnB,KAAC,CACF,CAAC;AAGF;;;;AAIG;IACH,MAAM,WAAW,GAA4CF,gBAAK,CAAC,WAAW,CAC5E,CAAC,QAAQ,KAAI;;QAEX,IAAI,gBAAgB,CAAC,OAAO,EAAE;YAC5B,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpB,SAAA;AACH,KAAC,EACD,CAAE,QAAQ,CAAE,CACb,CAAC;;IAIF,OAAO;QACL,KAAK,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;QACnC,WAAW;QACX,QAAQ;KACA,CAAC;AAEb;;;;"}
1
+ {"version":3,"file":"useAutoControlledState.js","sources":["../../../src/hooks/useAutoControlledState.ts"],"sourcesContent":[null],"names":["React","useEnhancedEffect","useSafeState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BA;;AAEc;AAEd;;;;;;;;AAQG;AACG,SAAU,sBAAsB,CACpC,YAA2B,EAC3B,OAA0C,EAAA;AAI1C;;;;AAIG;IACH,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,OAAO,IAAI,EAAE;AAG7C;;;;;AAKG;IACH,MAAM,gBAAgB,GAAGA,gBAAK,CAAC,MAAM,CAAU,KAAK,KAAK,SAAS,CAAC;AAGnE;;;AAGG;IACHC,mCAAiB,CACf,MAAK;AACH,QAAA,gBAAgB,CAAC,OAAO,GAAG,KAAK,KAAK,SAAS;AAChD,IAAA,CAAC,EACD,CAAE,KAAK,CAAE,CACV;AAGD;;;;;;AAMG;IACH,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGC,yBAAY,CACtC,MAAK;;AAEH,QAAA,MAAM,WAAW,GAAG,KAAK,KAAK,SAAS,GAAG,YAAY,GAAG,SAAS;;AAGlE,QAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,YAAA,OAAO,WAAW;QACpB;;QAGA,OAAO,OAAO,YAAY,KAAK;cAC1B,YAAwB;cACzB,YAAY;AAClB,IAAA,CAAC,CACF;AAGD;;;;AAIG;IACH,MAAM,WAAW,GAA4CF,gBAAK,CAAC,WAAW,CAC5E,CAAC,QAAQ,KAAI;;AAEX,QAAA,IAAI,gBAAgB,CAAC,OAAO,EAAE;YAC5B,QAAQ,CAAC,QAAQ,CAAC;QACpB;AACF,IAAA,CAAC,EACD,CAAE,QAAQ,CAAE,CACb;;IAID,OAAO;QACL,KAAK,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;QACnC,WAAW;QACX;KACQ;AAEZ;;;;"}
@@ -11,6 +11,13 @@ const DEFAULT_EVENTS = [
11
11
  /**
12
12
  * Use this hook to fire an event every time a click occurs outside
13
13
  * the provided target element
14
+ *
15
+ * The target is typed as the minimal structural shape the hook actually reads instead of
16
+ * 'React.RefObject<T> | React.MutableRefObject<T>'. Those aliases changed meaning between
17
+ * @types/react 18 and 19: in 19 'useRef<T>(null)' yields 'RefObject<T | null>', which no
18
+ * longer satisfies 'RefObject<T>' and made every call site fail to compile. The
19
+ * implementation already null-checks 'current', so admitting it in the type costs nothing.
20
+ *
14
21
  * @param target
15
22
  * @param callback
16
23
  * @param events
@@ -1 +1 @@
1
- {"version":3,"file":"useClickOutside.js","sources":["../../../src/hooks/useClickOutside.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAMA;AACA,MAAM,cAAc,GAA6C;IAC/D,WAAW;IACX,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
1
+ {"version":3,"file":"useClickOutside.js","sources":["../../../src/hooks/useClickOutside.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAIA;AACA,MAAM,cAAc,GAA6C;IAC/D,WAAW;IACX;CACD;AAGD;;;;;;;;;;;;;AAaG;AACG,SAAU,eAAe,CAC7B,MAAkD,EAClD,QAAuB,EACvB,SAAmD,cAAc,EAAA;;AAIjE,IAAA,MAAM,aAAa,GAAGA,yBAAY,CAAC,MAAM,CAAC;AAC1C,IAAA,MAAM,gBAAgB,GAAGA,yBAAY,CAAC,QAAQ,CAAC;;IAG/CC,mCAAiB,CACf,MAAK;AAEH;;;;;;AAMG;QACH,SAAS,OAAO,CAAoB,KAAY,EAAA;;AAE9C,YAAA,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE;gBAClC;YACF;;AAGA,YAAA,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK;AACrC,YAAA,MAAM,EAAE,GAAG,gBAAgB,CAAC,OAAO;AAEnC,YAAA,IACE,CAAC;AACE,oBAAC,CAAC,CAAC,WAAW,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAmB,CAAC,CAAC,EAAE;;AAEpF,gBAAA,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;YACtB;QACF;;AAGA,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,KAAI;;AAE3B,YAAA,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAClE,QAAA,CAAC,CAAC;;AAGF,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,KAAI;;AAE3B,gBAAA,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC;AAClD,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC;IACH,CAAC;;IAED,CAAE,gBAAgB,EAAE,aAAa,EAAE,GAAG,MAAM,CAAE,CAC/C;AAEH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDataManager.js","sources":["../../../src/hooks/useDataManager.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA;;AAEc;SACE,cAAc,GAAA;;;;AAK5B,IAAA,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,SAAS,CAAC,CAAC;AAC3E,IAAA,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,SAAS,CAAC,CAAC;;;;AAM3E,IAAA,MAAM,aAAa,GAAGA,gBAAK,CAAC,WAAW,CACrC,MAAM,WAAW,CAAC,SAAS,CAAC,EAC5B,EAAE,CACH,CAAC;AAEF,IAAA,MAAM,aAAa,GAAGA,gBAAK,CAAC,WAAW,CACrC,MAAM,WAAW,CAAC,SAAS,CAAC,EAC5B,EAAE,CACH,CAAC;IAEF,MAAM,qBAAqB,GAAGA,gBAAK,CAAC,WAAW,CAC7C,CAAC,OAAsB,KAAK,MAAM,WAAW,CAAC,OAAO,CAAC,EACtD,EAAE,CACH,CAAC;IAEF,MAAM,qBAAqB,GAAGA,gBAAK,CAAC,WAAW,CAC7C,CAAC,OAAsB,KAAK,MAAM,WAAW,CAAC,OAAO,CAAC,EACtD,EAAE,CACH,CAAC;;;;IAMF,OAAO;QACL,QAAQ;QACR,aAAa;QACb,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,WAAW;QACX,WAAW;QACX,QAAQ;KACT,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"useDataManager.js","sources":["../../../src/hooks/useDataManager.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiCA;;AAEc;SACE,cAAc,GAAA;;;;AAK5B,IAAA,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,SAAS,CAAC;AAC1E,IAAA,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,SAAS,CAAC;;;;AAM1E,IAAA,MAAM,aAAa,GAAGA,gBAAK,CAAC,WAAW,CACrC,MAAM,WAAW,CAAC,SAAS,CAAC,EAC5B,EAAE,CACH;AAED,IAAA,MAAM,aAAa,GAAGA,gBAAK,CAAC,WAAW,CACrC,MAAM,WAAW,CAAC,SAAS,CAAC,EAC5B,EAAE,CACH;IAED,MAAM,qBAAqB,GAAGA,gBAAK,CAAC,WAAW,CAC7C,CAAC,OAAsB,KAAK,MAAM,WAAW,CAAC,OAAO,CAAC,EACtD,EAAE,CACH;IAED,MAAM,qBAAqB,GAAGA,gBAAK,CAAC,WAAW,CAC7C,CAAC,OAAsB,KAAK,MAAM,WAAW,CAAC,OAAO,CAAC,EACtD,EAAE,CACH;;;;IAMD,OAAO;QACL,QAAQ;QACR,aAAa;QACb,aAAa;QACb,qBAAqB;QACrB,qBAAqB;QACrB,WAAW;QACX,WAAW;QACX;KACD;AAEH;;;;"}
@@ -36,7 +36,7 @@ function useDataSelector(data, options) {
36
36
  // ----
37
37
  // Internal State
38
38
  // ----
39
- const [selected, setSelectedBase] = React__namespace.useState(options?.defaultSelected);
39
+ const [requestedSelection, setRequestedSelection] = React__namespace.useState(options?.defaultSelected);
40
40
  // ----
41
41
  // Internal Hooks
42
42
  // ----
@@ -61,34 +61,68 @@ function useDataSelector(data, options) {
61
61
  return selectableData.includes(item) ? item : undefined;
62
62
  }, [data, userDefinedComparer]);
63
63
  const setSelected = React__namespace.useCallback((item) => {
64
- const sourceItem = getSourceItem(item);
65
- setSelectedBase(sourceItem);
66
- const { current: currentUserDefinedOnSelectChange } = userDefinedOnSelectChange;
67
- if (typeof currentUserDefinedOnSelectChange === 'function') {
68
- currentUserDefinedOnSelectChange(sourceItem);
69
- }
70
- }, [getSourceItem, userDefinedOnSelectChange]);
64
+ setRequestedSelection(item);
65
+ }, []);
71
66
  const clearSelected = React__namespace.useCallback(() => setSelected(undefined), [setSelected]);
72
67
  const createSelectorHandler = React__namespace.useCallback((item) => () => setSelected(item), [setSelected]);
73
68
  // ----
74
69
  // Selected Assertion
75
70
  // ----
71
+ /**
72
+ * Resolve the requested selection against the data as it is *now*, while rendering.
73
+ *
74
+ * 'getSourceItem' already answers every case the reconciliation has to cover: it returns the matching
75
+ * source item, or 'undefined' when the requested one is not in the data any more — and 'undefined' in,
76
+ * 'undefined' out. So the whole thing is one derivation.
77
+ *
78
+ * It used to be an effect that called setState, which meant every data change that invalidated the
79
+ * selection rendered twice: once with the stale selection, once with the corrected one. Deriving it
80
+ * here means a render never shows a selection the data does not back.
81
+ */
82
+ const selected = getSourceItem(requestedSelection);
83
+ // ----
84
+ // Selection Change Notification
85
+ // ----
86
+ /**
87
+ * Notify the consumer once per actual change, from a single place.
88
+ *
89
+ * There used to be two sources for this callback — a synchronous call inside the setter and the
90
+ * reconciliation effect calling that same setter — and between them they reported things that were not
91
+ * changes: selecting what was already selected notified, clearing an already empty selection notified
92
+ * twice, and resolving `defaultSelected` against the data notified at mount. Watching the resolved
93
+ * value reports each transition exactly once, after the commit that made it real.
94
+ */
95
+ const lastNotifiedSelection = React__namespace.useRef(selected);
76
96
  React__namespace.useEffect(() => {
77
- /** Get source item from data */
78
- const sourceItem = getSourceItem(selected);
79
- /** If selected exists, but source item not, remove selection */
80
- if (selected && !sourceItem) {
81
- setSelected(undefined);
97
+ if (lastNotifiedSelection.current === selected) {
98
+ return;
82
99
  }
83
- /** If both items exist, but are different, replace selection */
84
- else if (!!selected && !!sourceItem && selected !== sourceItem) {
85
- setSelected(sourceItem);
100
+ lastNotifiedSelection.current = selected;
101
+ const { current: currentUserDefinedOnSelectChange } = userDefinedOnSelectChange;
102
+ if (typeof currentUserDefinedOnSelectChange === 'function') {
103
+ currentUserDefinedOnSelectChange(selected);
86
104
  }
87
- }, [getSourceItem, setSelected, selected]);
105
+ }, [selected, userDefinedOnSelectChange]);
88
106
  // ----
89
- // Clear Selected on Unmount
107
+ // Unmount Notification
90
108
  // ----
91
- useUnmountEffect.useUnmountEffect(clearSelected);
109
+ /**
110
+ * Report the selection as gone when the component unmounts.
111
+ *
112
+ * This was `useUnmountEffect(clearSelected)`, and it notified only as a side effect of how the
113
+ * callback used to be wired: `clearSelected` went through the setter, and the setter notified
114
+ * synchronously. Now that notifying belongs to an effect — and effects do not run on the way out —
115
+ * that call became inert, which dropped a notification every consumer had always received.
116
+ *
117
+ * It fires unconditionally, which is what the old path did: it resolved `undefined` through
118
+ * `getSourceItem` and reported it even when nothing was selected to begin with.
119
+ */
120
+ useUnmountEffect.useUnmountEffect(() => {
121
+ const { current: currentUserDefinedOnSelectChange } = userDefinedOnSelectChange;
122
+ if (typeof currentUserDefinedOnSelectChange === 'function') {
123
+ currentUserDefinedOnSelectChange(undefined);
124
+ }
125
+ });
92
126
  // ----
93
127
  // Return utilities
94
128
  // ----
@@ -1 +1 @@
1
- {"version":3,"file":"useDataSelector.js","sources":["../../../src/hooks/useDataSelector.ts"],"sourcesContent":[null],"names":["React","useSyncedRef","useUnmountEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;AAEc;AAEd;;;;;AAKG;AACa,SAAA,eAAe,CAC7B,IAA4B,EAC5B,OAAmC,EAAA;;;;AAMnC,IAAA,MAAM,CAAE,QAAQ,EAAE,eAAe,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,OAAO,EAAE,eAAe,CAAC,CAAC;;;;IAM9F,MAAM,yBAAyB,GAAGC,yBAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC1E,MAAM,mBAAmB,GAAGA,yBAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;;;;IAM5D,MAAM,aAAa,GAAGD,gBAAK,CAAC,WAAW,CACrC,CAAC,IAAmB,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ChB,CAAC;;;;AAMF,IAAAA,gBAAK,CAAC,SAAS,CACb,MAAK;;AAEH,QAAA,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;;AAG3C,QAAA,IAAI,QAAQ,IAAI,CAAC,UAAU,EAAE;YAC3B,WAAW,CAAC,SAAS,CAAC,CAAC;AACxB,SAAA;;aAEI,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,UAAU,IAAI,QAAQ,KAAK,UAAU,EAAE;YAC9D,WAAW,CAAC,UAAU,CAAC,CAAC;AACzB,SAAA;KACF,EACD,CAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,CAAE,CACzC,CAAC;;;;IAMFE,iCAAgB,CAAC,aAAa,CAAC,CAAC;;;;IAMhC,OAAO;QACL,aAAa;QACb,qBAAqB;QACrB,QAAQ;QACR,WAAW;KACZ,CAAC;AAEJ,CAAC;AAGD,eAAe,CAAC,UAAU,GAAG,CAAwB,KAAQ,EAAE,MAAS,MACtE,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CACvB;;;;"}
1
+ {"version":3,"file":"useDataSelector.js","sources":["../../../src/hooks/useDataSelector.ts"],"sourcesContent":[null],"names":["React","useSyncedRef","useUnmountEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;AAEc;AAEd;;;;;AAKG;AACG,SAAU,eAAe,CAC7B,IAA4B,EAC5B,OAAmC,EAAA;;;;AAMnC,IAAA,MAAM,CAAE,kBAAkB,EAAE,qBAAqB,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAgB,OAAO,EAAE,eAAe,CAAC;;;;IAM7G,MAAM,yBAAyB,GAAGC,yBAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACzE,MAAM,mBAAmB,GAAGA,yBAAY,CAAC,OAAO,EAAE,QAAQ,CAAC;;;;IAM3D,MAAM,aAAa,GAAGD,gBAAK,CAAC,WAAW,CACrC,CAAC,IAAmB,KAAmB;;AAErC,QA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AExC,QAAA,MAAM,EAAE,OAAO,EAAE,gCAAgC,EAAE,GAAG,yBAAyB;AAC/E,QAAA,IAAI,OAAO,gCAAgC,KAAK,UAAU,EAAE;YAC1D,gCAAgC,CAAC,QAAQ,CAAC;QAC5C;AACF,IAAA,CAAC,EACD,CAAE,QAAQ,EAAE,yBAAyB,CAAE,CACxC;;;;AAMD;;;;;;;;;;AAUG;IACHE,iCAAgB,CAAC,MAAK;AACpB,QAAA,MAAM,EAAE,OAAO,EAAE,gCAAgC,EAAE,GAAG,yBAAyB;AAE/E,QAAA,IAAI,OAAO,gCAAgC,KAAK,UAAU,EAAE;YAC1D,gCAAgC,CAAC,SAAS,CAAC;QAC7C;AACF,IAAA,CAAC,CAAC;;;;IAMF,OAAO;QACL,aAAa;QACb,qBAAqB;QACrB,QAAQ;QACR;KACD;AAEH;AAGA,eAAe,CAAC,UAAU,GAAG,CAAwB,KAAQ,EAAE,MAAS,MACtE,KAAK,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CACvB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDebouncedCallback.js","sources":["../../../src/hooks/useDebouncedCallback.ts"],"sourcesContent":[null],"names":["React","useSyncedRef","useUnmountEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;AASG;SACa,oBAAoB,CAClC,QAAY,EACZ,IAA0B,EAC1B,QAAgB,EAAA;;IAIhB,MAAM,OAAO,GAAGA,gBAAK,CAAC,MAAM,CAA4C,SAAS,CAAC,CAAC;AACnF,IAAA,MAAM,gBAAgB,GAAGC,yBAAY,CAAC,QAAQ,CAAC,CAAC;;AAGhD,IAAA,MAAM,eAAe,GAAGD,gBAAK,CAAC,WAAW,CACvC,MAAK;QACH,IAAI,OAAO,CAAC,OAAO,EAAE;AACnB,YAAA,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC9B,YAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;AAC7B,SAAA;KACF,EACD,EAAE,CACH,CAAC;;IAGFE,iCAAgB,CAAC,MAAK;AACpB,QAAA,eAAe,EAAE,CAAC;AACpB,KAAC,CAAC,CAAC;;IAGH,OAAOF,gBAAK,CAAC,WAAW,CACtB,CAAC,GAAG,IAAI,KAAI;;AAEV,QAAA,eAAe,EAAE,CAAC;;AAGlB,QAAA,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,MAAK;AAChC,YAAA,gBAAgB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;SACnC,EAAE,QAAQ,CAAC,CAAC;KACd,EACD,CAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,CAAE,CAChD,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"useDebouncedCallback.js","sources":["../../../src/hooks/useDebouncedCallback.ts"],"sourcesContent":[null],"names":["React","useSyncedRef","useUnmountEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;;;;;;;;AASG;SACa,oBAAoB,CAClC,QAAY,EACZ,IAA0B,EAC1B,QAAgB,EAAA;;IAIhB,MAAM,OAAO,GAAGA,gBAAK,CAAC,MAAM,CAA4C,SAAS,CAAC;AAClF,IAAA,MAAM,gBAAgB,GAAGC,yBAAY,CAAC,QAAQ,CAAC;;AAG/C,IAAA,MAAM,eAAe,GAAGD,gBAAK,CAAC,WAAW,CACvC,MAAK;AACH,QAAA,IAAI,OAAO,CAAC,OAAO,EAAE;AACnB,YAAA,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC;AAC7B,YAAA,OAAO,CAAC,OAAO,GAAG,SAAS;QAC7B;IACF,CAAC,EACD,EAAE,CACH;;IAGDE,iCAAgB,CAAC,MAAK;AACpB,QAAA,eAAe,EAAE;AACnB,IAAA,CAAC,CAAC;;IAGF,OAAOF,gBAAK,CAAC,WAAW,CACtB,CAAC,GAAG,IAAI,KAAI;;AAEV,QAAA,eAAe,EAAE;;AAGjB,QAAA,OAAO,CAAC,OAAO,GAAG,UAAU,CAAC,MAAK;AAChC,YAAA,gBAAgB,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;QACnC,CAAC,EAAE,QAAQ,CAAC;IACd,CAAC,EACD,CAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,CAAE,CAChD;AAEH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useElementType.js","sources":["../../../src/hooks/useElementType.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAiCA;;AAEc;AAEd;;;;;;;AAOG;AACG,SAAU,cAAc,CAC5B,SAAmE,EACnE,KAAY,EACZ,kBAAsC,EACtC,UAAkC,EAAA;;AAIlC,IAAA,MAAM,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,SAAgB,CAAC;;IAGjE,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,KAAK,qBAAqB,EAAE,EAAE,EAAE;QACtD,OAAO,KAAK,CAAC,EAAE,CAAC;AACjB,KAAA;;AAGD,IAAA,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;AACpC,QAAA,MAAM,mBAAmB,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAE9C,QAAA,IAAI,mBAAmB,EAAE;AACvB,YAAA,OAAO,mBAAmB,CAAC;AAC5B,SAAA;AACF,KAAA;;AAGD,IAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAClC,QAAA,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC;AACtE,KAAA;;IAGD,IAAI,KAAK,CAAC,IAAI,EAAE;AACd,QAAA,OAAO,GAAG,CAAC;AACZ,KAAA;;AAGD,IAAA,OAAO,qBAAqB,EAAE,EAAE,IAAI,kBAAkB,IAAI,KAAK,CAAC;AAClE;;;;"}
1
+ {"version":3,"file":"useElementType.js","sources":["../../../src/hooks/useElementType.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAiCA;;AAEc;AAEd;;;;;;;AAOG;AACG,SAAU,cAAc,CAC5B,SAAmE,EACnE,KAAY,EACZ,kBAAsC,EACtC,UAAkC,EAAA;;AAIlC,IAAA,MAAM,EAAE,YAAY,EAAE,qBAAqB,EAAE,GAAG,SAAgB;;AAGhE,IAAA,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,KAAK,qBAAqB,EAAE,EAAE,EAAE;QACtD,OAAO,KAAK,CAAC,EAAE;IACjB;;AAGA,IAAA,IAAI,OAAO,UAAU,KAAK,UAAU,EAAE;AACpC,QAAA,MAAM,mBAAmB,GAAG,UAAU,CAAC,KAAK,CAAC;QAE7C,IAAI,mBAAmB,EAAE;AACvB,YAAA,OAAO,mBAAmB;QAC5B;IACF;;AAGA,IAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAClC,QAAA,OAAO,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO;IACtE;;AAGA,IAAA,IAAI,KAAK,CAAC,IAAI,EAAE;AACd,QAAA,OAAO,GAAG;IACZ;;AAGA,IAAA,OAAO,qBAAqB,EAAE,EAAE,IAAI,kBAAkB,IAAI,KAAK;AACjE;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEnhancedEffect.js","sources":["../../../src/hooks/useEnhancedEffect.ts"],"sourcesContent":[null],"names":["isBrowser","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAGA,eAAS;MACtCC,gBAAK,CAAC,eAAe;AACvB,MAAEA,gBAAK,CAAC;;;;"}
1
+ {"version":3,"file":"useEnhancedEffect.js","sources":["../../../src/hooks/useEnhancedEffect.ts"],"sourcesContent":[null],"names":["isBrowser","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAGA;MAC7BC,gBAAK,CAAC;AACR,MAAEA,gBAAK,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEvent.js","sources":["../../../src/hooks/useEvent.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAkBA;;;;;;AAMG;SACa,QAAQ,CACtB,IAAO,EACP,QAA0B,EAC1B,OAAyB,EAAA;;AAIzB,IAAA,MAAM,EACJ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,QAAQ,CAAC,eAAe,EAClC,GAAG,OAAO,IAAI,EAAE,CAAC;AAGlB;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,GAAGA,yBAAY,CAAmB,QAAQ,CAAC,CAAC;IAGzDC,mCAAiB,CACf,MAAK;;AAEH,QAAA,IAAI,QAAQ,EAAE;YACZ,OAAO;AACR,SAAA;AAED;;;;;AAKG;QACH,MAAM,aAAa,GAAqB,CAAC,KAAK,MAC5C,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAE,KAAK,CAAE,CAAC,CACzC,CAAC;;AAGF,QAAA,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;;AAG7C,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AAClD,SAAC,CAAC;KACH,EACD,CAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAE,CACpC,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"useEvent.js","sources":["../../../src/hooks/useEvent.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAkBA;;;;;;AAMG;SACa,QAAQ,CACtB,IAAO,EACP,QAA0B,EAC1B,OAAyB,EAAA;;AAIzB,IAAA,MAAM,EACJ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,QAAQ,CAAC,eAAe,EAClC,GAAG,OAAO,IAAI,EAAE;AAGjB;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,GAAGA,yBAAY,CAAmB,QAAQ,CAAC;IAGxDC,mCAAiB,CACf,MAAK;;QAEH,IAAI,QAAQ,EAAE;YACZ;QACF;AAEA;;;;;AAKG;QACH,MAAM,aAAa,GAAqB,CAAC,KAAK,MAC5C,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAE,KAAK,CAAE,CAAC,CACzC;;AAGD,QAAA,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,aAAa,CAAC;;AAG5C,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,aAAa,CAAC;AACjD,QAAA,CAAC;IACH,CAAC,EACD,CAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAE,CACpC;AAEH;;;;"}
@@ -21,21 +21,49 @@ function _interopNamespaceDefault(e) {
21
21
 
22
22
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
23
23
 
24
+ /* --------
25
+ * Hook Definition
26
+ * -------- */
24
27
  /**
25
- * Group multiple ref object into a single ref that will
26
- * assign the referenced element to each single ref.
28
+ * Merge several refs into the single ref callback a JSX element can accept.
27
29
  *
28
- * @param refs
30
+ * The returned callback assigns the element to every ref it was given, which is how a component both
31
+ * exposes a ref to its parent and keeps one for itself.
32
+ *
33
+ * Its identity is **stable** as long as the same ref containers are passed, which matters beyond
34
+ * tidiness: React calls a ref callback with `null` and then with the node again every time the
35
+ * callback's identity changes.
36
+ *
37
+ * @param refs The refs to assign to
38
+ * @returns A ref callback, stable across renders that pass the same refs
39
+ *
40
+ * @example
41
+ * const Input = React.forwardRef<HTMLInputElement, Props>((props, ref) => {
42
+ * const innerRef = React.useRef<HTMLInputElement>(null);
43
+ * const handleRef = useForkRef(innerRef, ref as MutableRefLike<HTMLInputElement>);
44
+ *
45
+ * return <input {...props} ref={handleRef} />;
46
+ * });
29
47
  */
30
48
  function useForkRef(...refs) {
31
49
  return React__namespace.useCallback((refValue) => {
32
- refs.forEach((ref) => ref.current = refValue ?? undefined);
50
+ refs.forEach((ref) => {
51
+ ref.current = refValue ?? undefined;
52
+ });
33
53
  },
34
- // react-hooks/exhaustive-deps will warn the next line because
35
- // the array will always change at each call of the hook.
36
- // In this case, could disable the warning because the ref hook used
37
- // as arguments won't change, because ref objects are immutable
38
- // eslint-disable-next-line react-hooks/exhaustive-deps
54
+ /**
55
+ * The rest parameter is a new array on every render, so the refs are spread into the dependency
56
+ * list one by one: ref containers are stable, so the callback survives every render that passes
57
+ * the same ones.
58
+ *
59
+ * Both hook rules object to this, and neither has a better answer here. 'exhaustive-deps' wants the
60
+ * array itself, which changes identity every render and would rebuild the callback each time.
61
+ * 'use-memo' wants a literal, which cannot express a variadic list. Routing the refs through a
62
+ * synced container satisfies both — and then the React Compiler refuses the memoization outright,
63
+ * because it cannot prove a closure reading 'ref.current' is stable. This is the shape the compiler
64
+ * is meant to replace: with it enabled, drop the useCallback entirely and let it do the work.
65
+ */
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo
39
67
  [...refs]);
40
68
  }
41
69
 
@@ -1 +1 @@
1
- {"version":3,"file":"useForkRef.js","sources":["../../../src/hooks/useForkRef.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;AAKG;AACa,SAAA,UAAU,CAAI,GAAG,IAA0C,EAAA;AACzE,IAAA,OAAOA,gBAAK,CAAC,WAAW,CACtB,CAAC,QAAkB,KAAI;AACrB,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,GAAG,QAAQ,IAAI,SAAS,CAAC,CAAC;KAC5D;;;;;;AAMD,IAAA,CAAE,GAAG,IAAI,CAAE,CACZ,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useForkRef.js","sources":["../../../src/hooks/useForkRef.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA;;AAEc;AAEd;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,SAAU,UAAU,CAAI,GAAG,IAAyB,EAAA;AACxD,IAAA,OAAOA,gBAAK,CAAC,WAAW,CACtB,CAAC,QAAkB,KAAI;AACrB,QAAA,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;AACnB,YAAA,GAAG,CAAC,OAAO,GAAG,QAAQ,IAAI,SAAS;AACrC,QAAA,CAAC,CAAC;IACJ,CAAC;AACD;;;;;;;;;;;AAWG;;AAEH,IAAA,CAAE,GAAG,IAAI,CAAE,CACZ;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useInputValue.js","sources":["../../../src/hooks/useInputValue.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGM,SAAU,aAAa,CAAC,YAAqB,EAAA;;;;AASjD,IAAA,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAS,YAAY,IAAI,EAAE,CAAC,CAAC;;;;IAMvE,MAAM,sBAAsB,GAAGA,gBAAK,CAAC,WAAW,CAC9C,CAAC,KAAK,KAAI;AACR,QAAA,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KACrC,EACD,EAAE,CACH,CAAC;;;;AAMF,IAAA,OAAO,CAAE,KAAK,EAAE,sBAAsB,EAAE,QAAQ,CAAE,CAAC;AAErD;;;;"}
1
+ {"version":3,"file":"useInputValue.js","sources":["../../../src/hooks/useInputValue.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGM,SAAU,aAAa,CAAC,YAAqB,EAAA;;;;AASjD,IAAA,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAS,YAAY,IAAI,EAAE,CAAC;;;;IAMtE,MAAM,sBAAsB,GAAGA,gBAAK,CAAC,WAAW,CAC9C,CAAC,KAAK,KAAI;AACR,QAAA,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC;IACrC,CAAC,EACD,EAAE,CACH;;;;AAMD,IAAA,OAAO,CAAE,KAAK,EAAE,sBAAsB,EAAE,QAAQ,CAAE;AAEpD;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectState.js","sources":["../../../src/hooks/useObjectState.ts"],"sourcesContent":[null],"names":["useSafeState","useSyncedRef","React","getValueAt","setValueAt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA;;;;;;AAMG;AACa,SAAA,cAAc,CAC5B,aAAsC,EACtC,OAAuC,EAAA;;IAIvC,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGA,yBAAY,CAAC,aAAa,CAAC,CAAC;;IAGxD,MAAM,gBAAgB,GAAGC,yBAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzD,IAAAC,gBAAK,CAAC,SAAS,CACb,MAAK;AACH,QAAA,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,gBAAgB,CAAC;AAEtD,QAAA,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;YACzC,eAAe,CAAC,KAAK,CAAC,CAAC;AACxB,SAAA;AACH,KAAC,EACD,CAAE,gBAAgB,EAAE,KAAK,CAAE,CAC5B,CAAC;;IAGF,MAAM,QAAQ,GAAGA,gBAAK,CAAC,WAAW,CAChC,CAAC,SAAS,KAAI;AACZ,QAAA,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;AACnC,YAAA,QAAQ,CAAC,CAAC,IAAI,MAAM;gBAClB,GAAG,SAAS,CAAC,IAAI,CAAC;AACnB,aAAA,CAAC,CAAC,CAAC;AACL,SAAA;AACI,aAAA;AACH,YAAA,QAAQ,CAAC,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;AAC5B,SAAA;AACH,KAAC,EACD,CAAE,QAAQ,CAAE,CACb,CAAC;;IAGF,MAAM,QAAQ,GAAGA,gBAAK,CAAC,WAAW,CAChC,CAAkC,IAAU,MAC1CC,gBAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CACxB,EACD,CAAE,KAAK,CAAE,CACV,CAAC;;IAGF,MAAM,QAAQ,GAAGD,gBAAK,CAAC,WAAW,CAChC,CAAkC,IAAU,EAAE,KAAoC,KAAI;QACpF,QAAQ,CAAC,CAAC,IAAI,MACZE,gBAAU,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CACnD,CAAC,CAAC;AACL,KAAC,EACD,CAAE,QAAQ,CAAE,CACb,CAAC;;IAGF,OAAO,CAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAE,CAAC;AAErD;;;;"}
1
+ {"version":3,"file":"useObjectState.js","sources":["../../../src/hooks/useObjectState.ts"],"sourcesContent":[null],"names":["useSafeState","useSyncedRef","React","getValueAt","setValueAt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA;;;;;;AAMG;AACG,SAAU,cAAc,CAC5B,aAAsC,EACtC,OAAuC,EAAA;;IAIvC,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGA,yBAAY,CAAC,aAAa,CAAC;;IAGvD,MAAM,gBAAgB,GAAGC,yBAAY,CAAC,OAAO,EAAE,QAAQ,CAAC;AACxD,IAAAC,gBAAK,CAAC,SAAS,CACb,MAAK;AACH,QAAA,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,gBAAgB;AAErD,QAAA,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE;YACzC,eAAe,CAAC,KAAK,CAAC;QACxB;AACF,IAAA,CAAC,EACD,CAAE,gBAAgB,EAAE,KAAK,CAAE,CAC5B;;IAGD,MAAM,QAAQ,GAAGA,gBAAK,CAAC,WAAW,CAChC,CAAC,SAAS,KAAI;AACZ,QAAA,IAAI,OAAO,SAAS,KAAK,UAAU,EAA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AK,CAAC;AAC5B,SAAC,CAAC;KACH,EACD,EAAE,CACH,CAAC;;IAGF,MAAM,cAAc,GAAGD,gBAAK,CAAC,WAAW,CACtC,CAAC,QAAQ,KAAI;QACX,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpB,SAAA;KACF,EACD,EAAE,CACH,CAAC;;AAGF,IAAA,OAAO,CAAE,KAAK,EAAE,cAAc,CAAE,CAAC;AAEnC;;;;"}
1
+ {"version":3,"file":"useSafeState.js","sources":["../../../src/hooks/useSafeState.ts"],"sourcesContent":[null],"names":["React","useEnhancedEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;;;;;AAMG;AACG,SAAU,YAAY,CAC1B,YAA2B,EAAA;;AAI3B,IAAA,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAI,YAAY,CAAC;;IAG3D,MAAM,SAAS,GAAGA,gBAAK,CAAC,MAAM,CAAU,KAAK,CAAC;;IAG9CC,mCAAiB,CACf,MAAK;AACH,QAAA,SAAS,CAAC,OAAO,GAAG,IAAI;AAExB,QAAA,OAAO,MAAK;AACV,YAAA,SAAS,CAAC,OAAO,GAAG,KAAK;AAC3B,QAAA,CAAC;IACH,CAAC,EACD,EAAE,CACH;;IAGD,MAAM,cAAc,GAAGD,gBAAK,CAAC,WAAW,CACtC,CAAC,QAAQ,KAAI;AACX,QAAA,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,QAAQ,CAAC,QAAQ,CAAC;QACpB;IACF,CAAC,EACD,EAAE,CACH;;AAGD,IAAA,OAAO,CAAE,KAAK,EAAE,cAAc,CAAE;AAElC;;;;"}
@@ -22,15 +22,47 @@ function _interopNamespaceDefault(e) {
22
22
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
23
23
 
24
24
  /**
25
- * An augmented version of the useRef function.
26
- * It will return a 'ref' style object with the
27
- * current key memoized, returning each time
28
- * the most updated version of the value
25
+ * Keep the latest value passed to a component inside a stable, read only ref container.
29
26
  *
30
- * @param value The value to store into ref object
27
+ * The container identity never changes, so it can sit in a dependency array without ever
28
+ * invalidating it — which is the whole point: it lets an event handler, a debounce timer or a
29
+ * cleanup function read the *current* value without the effect that owns them having to be torn
30
+ * down and rebuilt on every render.
31
+ *
32
+ * The returned object is frozen and exposes `current` as a getter, so a consumer can read the value
33
+ * but cannot write it.
34
+ *
35
+ * @param value The value to keep in sync
36
+ * @returns A stable container whose `current` always reads the latest value
37
+ *
38
+ * @example
39
+ * function useAutoSave(onSave: () => void, delay: number) {
40
+ * const latestOnSave = useSyncedRef(onSave);
41
+ *
42
+ * React.useEffect(
43
+ * () => {
44
+ * // the interval is created once, and still calls the newest callback
45
+ * const id = setInterval(() => latestOnSave.current(), delay);
46
+ * return () => clearInterval(id);
47
+ * },
48
+ * [ delay, latestOnSave ]
49
+ * );
50
+ * }
51
+ *
52
+ * @remarks
53
+ * ⚠️ Read `current` from an effect, an event handler or a cleanup function — **not while rendering**.
54
+ * The value is written during render, which is what makes it available to the very commit it belongs
55
+ * to, and reading a ref during render is not something React guarantees anything about: a render that
56
+ * gets discarded leaves the container holding a value that was never committed.
57
+ *
58
+ * That write is also why `react-hooks/refs` is switched off just below. Every alternative loses the
59
+ * guarantee this hook exists to provide — writing in an effect makes `current` lag one commit behind,
60
+ * which is precisely the bug the callers of this hook are avoiding. The exposure is bounded: the
61
+ * container is only ever read after a commit, and every commit writes it again.
31
62
  */
32
63
  function useSyncedRef(value) {
33
64
  const ref = React__namespace.useRef(value);
65
+ // eslint-disable-next-line react-hooks/refs -- see the remark above: the render time write is the contract
34
66
  ref.current = value;
35
67
  return React__namespace.useMemo(() => Object.freeze({
36
68
  get current() {
@@ -1 +1 @@
1
- {"version":3,"file":"useSyncedRef.js","sources":["../../../src/hooks/useSyncedRef.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;AAOG;AACG,SAAU,YAAY,CAAI,KAAQ,EAAA;IACtC,MAAM,GAAG,GAAGA,gBAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEhC,IAAA,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IAEpB,OAAOA,gBAAK,CAAC,OAAO,CAClB,MACE,MAAM,CAAC,MAAM,CAAC;AACZ,QAAA,IAAI,OAAO,GAAA;YACT,OAAO,GAAG,CAAC,OAAO,CAAC;SACpB;KACF,CAAC,EACJ,EAAE,CACH,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useSyncedRef.js","sources":["../../../src/hooks/useSyncedRef.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCG;AACG,SAAU,YAAY,CAAI,KAAQ,EAAA;IACtC,MAAM,GAAG,GAAGA,gBAAK,CAAC,MAAM,CAAC,KAAK,CAAC;;AAG/B,IAAA,GAAG,CAAC,OAAO,GAAG,KAAK;IAEnB,OAAOA,gBAAK,CAAC,OAAO,CAClB,MAAM,MAAM,CAAC,MAAM,CAAC;AAClB,QAAA,IAAI,OAAO,GAAA;YACT,OAAO,GAAG,CAAC,OAAO;QACpB;KACD,CAAC,EACF,EAAE,CACH;AACH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useUnmountEffect.js","sources":["../../../src/hooks/useUnmountEffect.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAIA;;;;;;AAMG;AACG,SAAU,gBAAgB,CAC9B,QAA0B,EAAA;;AAI1B,IAAA,MAAM,eAAe,GAAGA,yBAAY,CAAC,QAAQ,CAAC,CAAC;;AAG/C,IAAAC,mCAAiB,CACf,MAAM,MAAK;QACT,eAAe,CAAC,OAAO,EAAE,CAAC;AAC5B,KAAC,EACD,CAAE,eAAe,CAAE,CACpB,CAAC;AAEJ;;;;"}
1
+ {"version":3,"file":"useUnmountEffect.js","sources":["../../../src/hooks/useUnmountEffect.ts"],"sourcesContent":[null],"names":["useSyncedRef","useEnhancedEffect"],"mappings":";;;;;AAIA;;;;;;AAMG;AACG,SAAU,gBAAgB,CAC9B,QAA0B,EAAA;;AAI1B,IAAA,MAAM,eAAe,GAAGA,yBAAY,CAAC,QAAQ,CAAC;;AAG9C,IAAAC,mCAAiB,CACf,MAAM,MAAK;QACT,eAAe,CAAC,OAAO,EAAE;AAC3B,IAAA,CAAC,EACD,CAAE,eAAe,CAAE,CACpB;AAEH;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWindowSize.js","sources":["../../../src/hooks/useWindowSize.ts"],"sourcesContent":[null],"names":["React","useEnhancedEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,aAAa,CAAC,OAA8B,EAAA;AAE1D,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;;;;AAKnC,IAAA,MAAM,CAAE,WAAW,EAAE,cAAc,CAAE,GAAGA,gBAAK,CAAC,QAAQ,CAAa,OAAO;AACxE,QAAA,MAAM,EAAE,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC;AAC9D,QAAA,KAAK,EAAG,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,UAAU,GAAG,CAAC;AAC9D,KAAA,CAAC,CAAC,CAAC;;;;AAMJ,IAAA,MAAM,sBAAsB,GAAGA,gBAAK,CAAC,WAAW,CAC9C,MAAM,cAAc,CAAC,CAAC,IAAI,KAAI;AAC5B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,QAAA,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;AAC/B,QAAA,OAAO,IAAI,CAAC;AACd,KAAC,CAAC,EACF,EAAE,CACH,CAAC;;;;IAMFC,mCAA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EAAE;YACZ;QACF;;AAGA,QAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,sBAAsB,CAAC;;AAGzD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC;AAC9D,QAAA,CAAC;AACH,IAAA,CAAC,EACD,CAAE,QAAQ,EAAE,sBAAsB,CAAE,CACrC;;;;AAMD,IAAA,OAAO,WAAW;AAEpB;;;;"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"compose.js","sources":["../../../src/utils/compose.tsx"],"sourcesContent":[null],"names":["_jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACa,SAAA,OAAO,CAAC,GAAG,UAAgC,EAAA;IAEzD,MAAM,iBAAiB,GAAqD,CAAC,KAAK,MAChFA,cAAA,CAACC,gBAAK,CAAC,QAAQ,EACZ,EAAA,QAAA,EAAA,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAI;;AAE7C,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;;AAE3B,gBAAA,MAAM,CAAE,SAAS,EAAE,cAAc,CAAE,GAAG,QAAQ,CAAC;;gBAE/C,QACED,eAAC,SAAS,EAAA,EAAA,GAAK,cAAc,EAC1B,QAAA,EAAA,QAAQ,EACC,CAAA,EACZ;AACH,aAAA;;AAGD,YAAA,QACEA,cAAC,CAAA,QAAQ,cACN,QAAQ,EAAA,CACA,EACX;AACJ,SAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAA,CACH,CAClB,CAAC;AAEF,IAAA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB,CAAC;AAEpD,IAAA,OAAO,iBAAiB,CAAC;AAE3B;;;;"}
1
+ {"version":3,"file":"compose.js","sources":["../../../src/utils/compose.tsx"],"sourcesContent":[null],"names":["_jsx","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACG,SAAU,OAAO,CAAC,GAAG,UAAgC,EAAA;IAEzD,MAAM,iBAAiB,GAAqD,CAAC,KAAK,MAChFA,cAAA,CAACC,gBAAK,CAAC,QAAQ,EAAA,EAAA,QAAA,EACZ,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAI;;AAE7C,YAAA,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;;AAE3B,gBAAA,MAAM,CAAE,SAAS,EAAE,cAAc,CAAE,GAAG,QAAQ;;gBAE9C,QACED,eAAC,SAAS,EAAA,EAAA,GAAK,cAAc,EAAA,QAAA,EAC1B,QAAQ,EAAA,CACC;YAEhB;;AAGA,YAAA,QACEA,cAAA,CAAC,QAAQ,cACN,QAAQ,EAAA,CACA;AAEf,QAAA,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAA,CACH,CAClB;AAED,IAAA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;AAEnD,IAAA,OAAO,iBAAiB;AAE1B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"contextBuilder.js","sources":["../../../src/utils/contextBuilder.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;AAMG;AACa,SAAA,cAAc,CAAsB,IAAY,EAAE,cAAkB,EAAA;;IAGlF,MAAM,WAAW,GAAGA,gBAAK,CAAC,aAAa,CAAgB,cAAc,CAAC,CAAC;;IAGvE,MAAM,cAAc,GAAY,MAAK;;QAEnC,MAAM,YAAY,GAAGA,gBAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;;QAEnD,IAAI,CAAC,YAAY,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAA,yCAAA,CAA2C,CAAC,CAAC;AAC3F,SAAA;;AAED,QAAA,OAAO,YAAY,CAAC;AACtB,KAAC,CAAC;;AAGF,IAAA,WAAW,CAAC,WAAW,GAAG,IAAI,CAAC;AAE/B,IAAA,OAAO,CAAE,WAAW,EAAE,cAAc,CAAE,CAAC;AACzC;;;;"}
1
+ {"version":3,"file":"contextBuilder.js","sources":["../../../src/utils/contextBuilder.ts"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;AAMG;AACG,SAAU,cAAc,CAAsB,IAAY,EAAE,cAAkB,EAAA;;IAGlF,MAAM,WAAW,GAAGA,gBAAK,CAAC,aAAa,CAAgB,cAAc,CAAC;;IAGtE,MAAM,cAAc,GAAY,MAAK;;QAEnC,MAAM,YAAY,GAAGA,gBAAK,CAAC,UAAU,CAAC,WAAW,CAAC;;QAElD,IAAI,CAAC,YAAY,EAAE;AACjB,YAAA,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAA,yCAAA,CAA2C,CAAC;QAC3F;;AAEA,QAAA,OAAO,YAAY;AACrB,IAAA,CAAC;;AAGD,IAAA,WAAW,CAAC,WAAW,GAAG,IAAI;AAE9B,IAAA,OAAO,CAAE,WAAW,EAAE,cAAc,CAAE;AACxC;;;;"}