@primer/react 0.0.0-20260225194620 → 0.0.0-20260225195902
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.
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@ import { type Dispatch, type ReactNode } from 'react';
|
|
|
2
2
|
interface ProviderProps<T> {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
/** State setter from `useRegistryState`. */
|
|
5
|
-
setRegistry: Dispatch<React.SetStateAction<
|
|
5
|
+
setRegistry: Dispatch<React.SetStateAction<ReadonlyMap<string, T> | undefined>>;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Create a "descendant registry" for a component. This allows a parent to store and track an ordered registry of
|
|
@@ -25,7 +25,7 @@ interface ProviderProps<T> {
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function createDescendantRegistry<T>(): {
|
|
27
27
|
Provider: ({ children, setRegistry }: ProviderProps<T>) => import("react").JSX.Element;
|
|
28
|
-
useRegistryState: () => [
|
|
28
|
+
useRegistryState: () => [ReadonlyMap<string, T> | undefined, Dispatch<import("react").SetStateAction<ReadonlyMap<string, T> | undefined>>];
|
|
29
29
|
useRegisterDescendant: (value: T) => string;
|
|
30
30
|
useRegisterDescendantCallback: (valueCallback: () => T) => string;
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,4CAA4C;IAC5C,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"descendant-registry.d.ts","sourceRoot":"","sources":["../../src/utils/descendant-registry.tsx"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAGd,UAAU,aAAa,CAAC,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,4CAA4C;IAC5C,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAA;CAChF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC;0CA+CG,aAAa,CAAC,CAAC,CAAC;;mCATrB,CAAC;mDAbe,MAAM,CAAC;EAqG9D"}
|
|
@@ -113,81 +113,76 @@ function createDescendantRegistry() {
|
|
|
113
113
|
|
|
114
114
|
/** Provide context for registering descendant components. This only needs to wrap `children`. */
|
|
115
115
|
function Provider(t0) {
|
|
116
|
-
const $ = c(
|
|
116
|
+
const $ = c(14);
|
|
117
117
|
const {
|
|
118
118
|
children,
|
|
119
119
|
setRegistry
|
|
120
120
|
} = t0;
|
|
121
121
|
const workingRegistryRef = useRef("queued");
|
|
122
|
-
const [key,
|
|
122
|
+
const [key, rebuildRegistry] = useReducer(_temp, 0);
|
|
123
123
|
let t1;
|
|
124
124
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
125
|
-
t1 = ()
|
|
126
|
-
workingRegistryRef.current = "queued";
|
|
127
|
-
incrementKey();
|
|
128
|
-
};
|
|
129
|
-
$[0] = t1;
|
|
130
|
-
} else {
|
|
131
|
-
t1 = $[0];
|
|
132
|
-
}
|
|
133
|
-
const queueRebuild = t1;
|
|
134
|
-
let t2;
|
|
135
|
-
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
136
|
-
t2 = function instantiateNewRegistry() {
|
|
125
|
+
t1 = function instantiateNewRegistry() {
|
|
137
126
|
if (workingRegistryRef.current === "queued") {
|
|
138
127
|
workingRegistryRef.current = new Map();
|
|
139
128
|
}
|
|
140
129
|
};
|
|
141
|
-
$[
|
|
130
|
+
$[0] = t1;
|
|
142
131
|
} else {
|
|
143
|
-
|
|
132
|
+
t1 = $[0];
|
|
144
133
|
}
|
|
145
|
-
useIsomorphicLayoutEffect(
|
|
146
|
-
let
|
|
147
|
-
if ($[
|
|
148
|
-
|
|
134
|
+
useIsomorphicLayoutEffect(t1);
|
|
135
|
+
let t2;
|
|
136
|
+
if ($[1] !== setRegistry) {
|
|
137
|
+
t2 = id => {
|
|
149
138
|
if (workingRegistryRef.current instanceof Map) {
|
|
150
139
|
workingRegistryRef.current.set(id, unsetValue);
|
|
151
140
|
} else {
|
|
152
141
|
if (workingRegistryRef.current === "idle") {
|
|
153
|
-
|
|
142
|
+
workingRegistryRef.current = "queued";
|
|
143
|
+
rebuildRegistry();
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
|
-
return ()
|
|
146
|
+
return function unregister() {
|
|
157
147
|
if (workingRegistryRef.current instanceof Map) {
|
|
158
148
|
workingRegistryRef.current.delete(id);
|
|
159
149
|
} else {
|
|
160
150
|
if (workingRegistryRef.current === "idle") {
|
|
161
|
-
|
|
151
|
+
setRegistry(prev_0 => {
|
|
152
|
+
const copy = new Map(prev_0);
|
|
153
|
+
copy.delete(id);
|
|
154
|
+
return copy;
|
|
155
|
+
});
|
|
162
156
|
}
|
|
163
157
|
}
|
|
164
158
|
};
|
|
165
159
|
};
|
|
166
|
-
$[
|
|
160
|
+
$[1] = setRegistry;
|
|
161
|
+
$[2] = t2;
|
|
167
162
|
} else {
|
|
168
|
-
|
|
163
|
+
t2 = $[2];
|
|
169
164
|
}
|
|
170
|
-
const register =
|
|
171
|
-
let
|
|
165
|
+
const register = t2;
|
|
166
|
+
let t3;
|
|
172
167
|
if ($[3] !== setRegistry) {
|
|
173
|
-
|
|
168
|
+
t3 = (id_0, value) => {
|
|
174
169
|
if (workingRegistryRef.current instanceof Map) {
|
|
175
170
|
workingRegistryRef.current.set(id_0, value);
|
|
176
171
|
} else {
|
|
177
172
|
if (workingRegistryRef.current === "idle") {
|
|
178
|
-
setRegistry(
|
|
173
|
+
setRegistry(prev_1 => new Map(prev_1).set(id_0, value));
|
|
179
174
|
}
|
|
180
175
|
}
|
|
181
176
|
};
|
|
182
177
|
$[3] = setRegistry;
|
|
183
|
-
$[4] =
|
|
178
|
+
$[4] = t3;
|
|
184
179
|
} else {
|
|
185
|
-
|
|
180
|
+
t3 = $[4];
|
|
186
181
|
}
|
|
187
|
-
const updateValue =
|
|
188
|
-
let
|
|
182
|
+
const updateValue = t3;
|
|
183
|
+
let t4;
|
|
189
184
|
if ($[5] !== setRegistry) {
|
|
190
|
-
|
|
185
|
+
t4 = function commitWorkingRegistry() {
|
|
191
186
|
if (workingRegistryRef.current instanceof Map) {
|
|
192
187
|
const setEntries = Array.from(workingRegistryRef.current.entries()).filter(_temp2);
|
|
193
188
|
setRegistry(new Map(setEntries));
|
|
@@ -195,38 +190,39 @@ function createDescendantRegistry() {
|
|
|
195
190
|
}
|
|
196
191
|
};
|
|
197
192
|
$[5] = setRegistry;
|
|
198
|
-
$[6] =
|
|
193
|
+
$[6] = t4;
|
|
199
194
|
} else {
|
|
200
|
-
|
|
195
|
+
t4 = $[6];
|
|
201
196
|
}
|
|
202
|
-
useEffect(
|
|
203
|
-
let
|
|
204
|
-
if ($[7] !== key || $[8] !== updateValue) {
|
|
205
|
-
|
|
197
|
+
useEffect(t4);
|
|
198
|
+
let t5;
|
|
199
|
+
if ($[7] !== key || $[8] !== register || $[9] !== updateValue) {
|
|
200
|
+
t5 = {
|
|
206
201
|
register,
|
|
207
202
|
updateValue,
|
|
208
203
|
key
|
|
209
204
|
};
|
|
210
205
|
$[7] = key;
|
|
211
|
-
$[8] =
|
|
212
|
-
$[9] =
|
|
206
|
+
$[8] = register;
|
|
207
|
+
$[9] = updateValue;
|
|
208
|
+
$[10] = t5;
|
|
213
209
|
} else {
|
|
214
|
-
|
|
210
|
+
t5 = $[10];
|
|
215
211
|
}
|
|
216
|
-
const contextValue =
|
|
217
|
-
let
|
|
218
|
-
if ($[
|
|
219
|
-
|
|
212
|
+
const contextValue = t5;
|
|
213
|
+
let t6;
|
|
214
|
+
if ($[11] !== children || $[12] !== contextValue) {
|
|
215
|
+
t6 = /*#__PURE__*/jsx(Context.Provider, {
|
|
220
216
|
value: contextValue,
|
|
221
217
|
children: children
|
|
222
218
|
});
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
219
|
+
$[11] = children;
|
|
220
|
+
$[12] = contextValue;
|
|
221
|
+
$[13] = t6;
|
|
226
222
|
} else {
|
|
227
|
-
|
|
223
|
+
t6 = $[13];
|
|
228
224
|
}
|
|
229
|
-
return
|
|
225
|
+
return t6;
|
|
230
226
|
}
|
|
231
227
|
function _temp2(entry) {
|
|
232
228
|
return entry[1] !== unsetValue;
|
package/package.json
CHANGED