@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
@@ -1,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260225194620
3
+ ## 0.0.0-20260225195902
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -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<Map<string, T> | undefined>>;
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: () => [Map<string, T> | undefined, Dispatch<import("react").SetStateAction<Map<string, T> | undefined>>];
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,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAA;CACxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC;0CA+CG,aAAa,CAAC,CAAC,CAAC;;mCATrB,CAAC;mDAbe,MAAM,CAAC;EAqG9D"}
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(13);
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, incrementKey] = useReducer(_temp, 0);
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
- $[1] = t2;
130
+ $[0] = t1;
142
131
  } else {
143
- t2 = $[1];
132
+ t1 = $[0];
144
133
  }
145
- useIsomorphicLayoutEffect(t2);
146
- let t3;
147
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
148
- t3 = id => {
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
- queueRebuild();
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
- queueRebuild();
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
- $[2] = t3;
160
+ $[1] = setRegistry;
161
+ $[2] = t2;
167
162
  } else {
168
- t3 = $[2];
163
+ t2 = $[2];
169
164
  }
170
- const register = t3;
171
- let t4;
165
+ const register = t2;
166
+ let t3;
172
167
  if ($[3] !== setRegistry) {
173
- t4 = (id_0, value) => {
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(prev_0 => new Map(prev_0).set(id_0, value));
173
+ setRegistry(prev_1 => new Map(prev_1).set(id_0, value));
179
174
  }
180
175
  }
181
176
  };
182
177
  $[3] = setRegistry;
183
- $[4] = t4;
178
+ $[4] = t3;
184
179
  } else {
185
- t4 = $[4];
180
+ t3 = $[4];
186
181
  }
187
- const updateValue = t4;
188
- let t5;
182
+ const updateValue = t3;
183
+ let t4;
189
184
  if ($[5] !== setRegistry) {
190
- t5 = function commitWorkingRegistry() {
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] = t5;
193
+ $[6] = t4;
199
194
  } else {
200
- t5 = $[6];
195
+ t4 = $[6];
201
196
  }
202
- useEffect(t5);
203
- let t6;
204
- if ($[7] !== key || $[8] !== updateValue) {
205
- t6 = {
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] = updateValue;
212
- $[9] = t6;
206
+ $[8] = register;
207
+ $[9] = updateValue;
208
+ $[10] = t5;
213
209
  } else {
214
- t6 = $[9];
210
+ t5 = $[10];
215
211
  }
216
- const contextValue = t6;
217
- let t7;
218
- if ($[10] !== children || $[11] !== contextValue) {
219
- t7 = /*#__PURE__*/jsx(Context.Provider, {
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
- $[10] = children;
224
- $[11] = contextValue;
225
- $[12] = t7;
219
+ $[11] = children;
220
+ $[12] = contextValue;
221
+ $[13] = t6;
226
222
  } else {
227
- t7 = $[12];
223
+ t6 = $[13];
228
224
  }
229
- return t7;
225
+ return t6;
230
226
  }
231
227
  function _temp2(entry) {
232
228
  return entry[1] !== unsetValue;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260225194620",
4
+ "version": "0.0.0-20260225195902",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",