@primer/react 0.0.0-20260304094354 → 0.0.0-20260304110422

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Timeline/Timeline.module.css.js"],"names":[],"mappings":"AAAA,6BACE,YAAa,CACb,qBAmBF,CAhBI,qGACE,aAKF,CAHE,yIACE,8BACF,CAGF,oGACE,gBAKF,CAHE,wIACE,iCACF,CAKN,iCAEE,YAAa,CAEb,oCAAgC,CADhC,kCAA8B,CAF9B,iBAkCF,CA7BE,wCASE,mEAA0C,CAN1C,QAAS,CAIT,UAAW,CAFX,aAAc,CADd,MAAO,CAHP,iBAAkB,CAClB,KAAM,CAIN,SAIF,CAEA,yDAEE,gBAAiB,CADjB,qCAeF,CAZE,oEACE,uCACF,CAEA,2FAKE,mEAAwC,CACxC,QAAS,CAFT,gDAA2B,CAH3B,WAAY,CAEZ,sCAAiC,CADjC,mCAKF,CAIJ,yCACE,iBAAkB,CAClB,SACF,CAEA,kCAkBE,kBAAmB,CANnB,4EAA8C,CAE9C,+DAAoC,CAGpC,iBAAkB,CAFlB,kBAAmB,CACnB,6CAAsC,CAftC,YAAa,CAMb,aAAc,CAJd,WAAY,CAgBZ,sBAAuB,CAbvB,iBAAkB,CAFlB,qCAAgC,CAIhC,eAAgB,CANhB,UAkBF,CAEA,mEAbE,gDAoBF,CAPA,iCAME,SAAU,CAFV,8CAAuC,CADvC,oCAA8B,CAD9B,cAAe,CADf,WAMF,CAEA,kCAOE,mEAAwC,CACxC,QAAS,CACT,yGAAuE,CANvE,iCAA2B,CAC3B,QAAS,CACT,+CAA6C,CAC7C,aAAc,CALd,iBAAkB,CAClB,SAYF,CAHE,yDACE,iDACF","file":"Timeline-116393ee.css","sourcesContent":[".Timeline {\n display: flex;\n flex-direction: column;\n\n &:where([data-clip-sidebar]) {\n .TimelineItem:first-child {\n padding-top: 0;\n\n &:where([data-condensed])::before {\n top: var(--base-size-12);\n }\n }\n\n .TimelineItem:last-child {\n padding-bottom: 0;\n\n &:where([data-condensed])::before {\n height: var(--base-size-12);\n }\n }\n }\n}\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--base-size-16) 0;\n margin-left: var(--base-size-16);\n\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: 2px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-muted);\n }\n\n &:where([data-condensed]) {\n padding-top: var(--base-size-4);\n padding-bottom: 0;\n\n &:last-child {\n padding-bottom: var(--base-size-16);\n }\n\n .TimelineBadge {\n height: 16px;\n margin-top: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n color: var(--fgColor-muted);\n background-color: var(--bgColor-default);\n border: 0;\n }\n }\n}\n\n.TimelineBadgeWrapper {\n position: relative;\n z-index: 1;\n}\n\n.TimelineBadge {\n display: flex;\n width: 32px;\n height: 32px;\n margin-right: var(--base-size-8);\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -15px;\n flex-shrink: 0;\n overflow: hidden;\n color: var(--fgColor-muted);\n\n /* TODOl not quite sure if this is the correct migration for this line */\n background-color: var(--timelineBadge-bgColor);\n /* stylelint-disable-next-line primer/colors */\n border-color: var(--bgColor-default);\n border-style: solid;\n border-width: var(--borderWidth-thick);\n border-radius: 50%;\n align-items: center;\n justify-content: center;\n}\n\n.TimelineBody {\n min-width: 0;\n max-width: 100%;\n margin-top: var(--base-size-4);\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: auto;\n}\n\n.TimelineBreak {\n position: relative;\n z-index: 1;\n height: var(--base-size-24);\n margin: 0;\n margin-bottom: calc(-1 * var(--base-size-16));\n margin-left: 0;\n background-color: var(--bgColor-default);\n border: 0;\n border-top: var(--borderWidth-thicker) solid var(--borderColor-default);\n\n &:has(+ [data-condensed]) {\n margin-bottom: calc(-1 * var(--base-size-12));\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/Timeline/Timeline.module.css.js"],"names":[],"mappings":"AAAA,6BACE,YAAa,CACb,qBAmBF,CAhBI,qGACE,aAKF,CAHE,yIACE,8BACF,CAGF,oGACE,gBAKF,CAHE,wIACE,iCACF,CAKN,iCAEE,YAAa,CAEb,oCAAgC,CADhC,kCAA8B,CAF9B,iBAkCF,CA7BE,wCASE,mEAA0C,CAN1C,QAAS,CAIT,UAAW,CAFX,aAAc,CADd,MAAO,CAHP,iBAAkB,CAClB,KAAM,CAIN,SAIF,CAEA,yDAEE,gBAAiB,CADjB,qCAeF,CAZE,oEACE,uCACF,CAEA,2FAKE,mEAAwC,CACxC,QAAS,CAFT,gDAA2B,CAH3B,WAAY,CAEZ,sCAAiC,CADjC,mCAKF,CAIJ,yCACE,iBAAkB,CAClB,SACF,CAEA,kCAkBE,kBAAmB,CANnB,4EAA8C,CAE9C,+DAAoC,CAGpC,iBAAkB,CAFlB,kBAAmB,CACnB,6CAAsC,CAftC,YAAa,CAMb,aAAc,CAJd,WAAY,CAgBZ,sBAAuB,CAbvB,iBAAkB,CAFlB,qCAAgC,CAIhC,eAAgB,CANhB,UAkBF,CAEA,mEAbE,gDAqBF,CARA,iCAOE,SAAU,CAFV,8CAAuC,CADvC,gDAA0C,CAF1C,cAAe,CADf,WAOF,CAEA,kCAOE,mEAAwC,CACxC,QAAS,CACT,yGAAuE,CANvE,iCAA2B,CAC3B,QAAS,CACT,+CAA6C,CAC7C,aAAc,CALd,iBAAkB,CAClB,SAYF,CAHE,yDACE,iDACF","file":"Timeline-19bef8c5.css","sourcesContent":[".Timeline {\n display: flex;\n flex-direction: column;\n\n &:where([data-clip-sidebar]) {\n .TimelineItem:first-child {\n padding-top: 0;\n\n &:where([data-condensed])::before {\n top: var(--base-size-12);\n }\n }\n\n .TimelineItem:last-child {\n padding-bottom: 0;\n\n &:where([data-condensed])::before {\n height: var(--base-size-12);\n }\n }\n }\n}\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--base-size-16) 0;\n margin-left: var(--base-size-16);\n\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: 2px;\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-muted);\n }\n\n &:where([data-condensed]) {\n padding-top: var(--base-size-4);\n padding-bottom: 0;\n\n &:last-child {\n padding-bottom: var(--base-size-16);\n }\n\n .TimelineBadge {\n height: 16px;\n margin-top: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n color: var(--fgColor-muted);\n background-color: var(--bgColor-default);\n border: 0;\n }\n }\n}\n\n.TimelineBadgeWrapper {\n position: relative;\n z-index: 1;\n}\n\n.TimelineBadge {\n display: flex;\n width: 32px;\n height: 32px;\n margin-right: var(--base-size-8);\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -15px;\n flex-shrink: 0;\n overflow: hidden;\n color: var(--fgColor-muted);\n\n /* TODOl not quite sure if this is the correct migration for this line */\n background-color: var(--timelineBadge-bgColor);\n /* stylelint-disable-next-line primer/colors */\n border-color: var(--bgColor-default);\n border-style: solid;\n border-width: var(--borderWidth-thick);\n border-radius: 50%;\n align-items: center;\n justify-content: center;\n}\n\n.TimelineBody {\n min-width: 0;\n max-width: 100%;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: calc(var(--base-size-4) + 1px);\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: auto;\n}\n\n.TimelineBreak {\n position: relative;\n z-index: 1;\n height: var(--base-size-24);\n margin: 0;\n margin-bottom: calc(-1 * var(--base-size-16));\n margin-left: 0;\n background-color: var(--bgColor-default);\n border: 0;\n border-top: var(--borderWidth-thicker) solid var(--borderColor-default);\n\n &:has(+ [data-condensed]) {\n margin-bottom: calc(-1 * var(--base-size-12));\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import './Timeline-116393ee.css';
1
+ import './Timeline-19bef8c5.css';
2
2
 
3
3
  var classes = {"Timeline":"prc-Timeline-Timeline-awSoC","TimelineItem":"prc-Timeline-TimelineItem-QwDVH","TimelineBadge":"prc-Timeline-TimelineBadge-u0qSm","TimelineBadgeWrapper":"prc-Timeline-TimelineBadgeWrapper-SZw4k","TimelineBody":"prc-Timeline-TimelineBody-tjOtb","TimelineBreak":"prc-Timeline-TimelineBreak-X8eti"};
4
4
 
@@ -0,0 +1,32 @@
1
+ import { type Dispatch, type ReactNode } from 'react';
2
+ export interface ProviderProps<T> {
3
+ children: ReactNode;
4
+ /** State setter from `useRegistryState`. */
5
+ setRegistry: Dispatch<React.SetStateAction<ReadonlyMap<string, T> | undefined>>;
6
+ }
7
+ /**
8
+ * Create a "descendant registry" for a component. This allows a parent to store and track an ordered registry of
9
+ * child components, even if they are deeply nested in the tree. For example, a menu component can use this to track
10
+ * every menu item inside of it, including menu items inside of fragments and subcomponents. The order of the resulting
11
+ * `Map` will match the render order in the React tree.
12
+ *
13
+ * Usage:
14
+ * 1. Create a registry at the file level in a similar manner to creating a new React context. Set `T` to the data type
15
+ * of the registry - this can be anything **except** a function.
16
+ * 2. In the parent component, instantiate the registry state via `useRegistryState`. Then wrap `children` in the
17
+ * registry context `Provider` with `setRegistry` set to the state setter function.
18
+ * 3. Register child components via `useRegisterDescendant` or `useRegisterDescendantCallback`.
19
+ * 4. Access the registered data using the value from `useRegistryState`. This will be a map of `string` to `T`, where
20
+ * the string key is a unique and stable identifier for each component which can be used as a `key` if necessary.
21
+ *
22
+ * @note Note that this pattern is not SSR compatible. It won't raise errors or hydration mismatches, but the
23
+ * registry will not be available during SSR. The registry is built during the effect phase, so it will be populated
24
+ * after hydration on the client. The initial `undefined` value can be used to safely show loading UI during SSR/initial
25
+ * render if necessary.
26
+ */
27
+ export declare function createDescendantRegistry<T>(): {
28
+ Provider: ({ children, setRegistry }: ProviderProps<T>) => import("react").JSX.Element;
29
+ useRegistryState: () => [ReadonlyMap<string, T> | undefined, Dispatch<import("react").SetStateAction<ReadonlyMap<string, T> | undefined>>];
30
+ useRegisterDescendant: (value: T) => string;
31
+ };
32
+ //# sourceMappingURL=descendant-registry.d.ts.map
@@ -0,0 +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,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,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;AAQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC;0CAgCG,aAAa,CAAC,CAAC,CAAC;;mCAfrB,CAAC;EA8FxC"}
@@ -0,0 +1,222 @@
1
+ import { c } from 'react-compiler-runtime';
2
+ import { useContext, useId, useEffect, useState, useRef, useReducer, createContext } from 'react';
3
+ import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect.js';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ /**
7
+ * Create a "descendant registry" for a component. This allows a parent to store and track an ordered registry of
8
+ * child components, even if they are deeply nested in the tree. For example, a menu component can use this to track
9
+ * every menu item inside of it, including menu items inside of fragments and subcomponents. The order of the resulting
10
+ * `Map` will match the render order in the React tree.
11
+ *
12
+ * Usage:
13
+ * 1. Create a registry at the file level in a similar manner to creating a new React context. Set `T` to the data type
14
+ * of the registry - this can be anything **except** a function.
15
+ * 2. In the parent component, instantiate the registry state via `useRegistryState`. Then wrap `children` in the
16
+ * registry context `Provider` with `setRegistry` set to the state setter function.
17
+ * 3. Register child components via `useRegisterDescendant` or `useRegisterDescendantCallback`.
18
+ * 4. Access the registered data using the value from `useRegistryState`. This will be a map of `string` to `T`, where
19
+ * the string key is a unique and stable identifier for each component which can be used as a `key` if necessary.
20
+ *
21
+ * @note Note that this pattern is not SSR compatible. It won't raise errors or hydration mismatches, but the
22
+ * registry will not be available during SSR. The registry is built during the effect phase, so it will be populated
23
+ * after hydration on the client. The initial `undefined` value can be used to safely show loading UI during SSR/initial
24
+ * render if necessary.
25
+ */
26
+ function createDescendantRegistry() {
27
+ const Context = /*#__PURE__*/createContext({
28
+ register: () => () => {},
29
+ updateValue: () => {},
30
+ key: -1
31
+ });
32
+
33
+ /**
34
+ * Instantiate descendant registry state. The initial value will be `undefined`, indicating that the registry hasn't
35
+ * been built yet.
36
+ */
37
+ function useRegistryState() {
38
+ return useState();
39
+ }
40
+
41
+ /** Register a descendant component with the registry. */
42
+ function useRegisterDescendant(value) {
43
+ const $ = c(16);
44
+ const {
45
+ register,
46
+ updateValue,
47
+ key
48
+ } = useContext(Context);
49
+ const id = useId();
50
+ let t0;
51
+ if ($[0] !== id || $[1] !== register) {
52
+ t0 = () => register(id);
53
+ $[0] = id;
54
+ $[1] = register;
55
+ $[2] = t0;
56
+ } else {
57
+ t0 = $[2];
58
+ }
59
+ let t1;
60
+ if ($[3] !== id || $[4] !== key || $[5] !== register) {
61
+ t1 = [register, id, key];
62
+ $[3] = id;
63
+ $[4] = key;
64
+ $[5] = register;
65
+ $[6] = t1;
66
+ } else {
67
+ t1 = $[6];
68
+ }
69
+ useEffect(t0, t1);
70
+ let t2;
71
+ if ($[7] !== id || $[8] !== updateValue || $[9] !== value) {
72
+ t2 = () => updateValue(id, value);
73
+ $[7] = id;
74
+ $[8] = updateValue;
75
+ $[9] = value;
76
+ $[10] = t2;
77
+ } else {
78
+ t2 = $[10];
79
+ }
80
+ let t3;
81
+ if ($[11] !== id || $[12] !== key || $[13] !== updateValue || $[14] !== value) {
82
+ t3 = [updateValue, id, value, key];
83
+ $[11] = id;
84
+ $[12] = key;
85
+ $[13] = updateValue;
86
+ $[14] = value;
87
+ $[15] = t3;
88
+ } else {
89
+ t3 = $[15];
90
+ }
91
+ useEffect(t2, t3);
92
+ return id;
93
+ }
94
+ const unsetValue = Symbol('unset');
95
+
96
+ /** Provide context for registering descendant components. This only needs to wrap `children`. */
97
+ function Provider(t0) {
98
+ const $ = c(14);
99
+ const {
100
+ children,
101
+ setRegistry
102
+ } = t0;
103
+ const workingRegistryRef = useRef("queued");
104
+ const [key, rebuildRegistry] = useReducer(_temp, 0);
105
+ let t1;
106
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
107
+ t1 = function instantiateNewRegistry() {
108
+ if (workingRegistryRef.current === "queued") {
109
+ workingRegistryRef.current = new Map();
110
+ }
111
+ };
112
+ $[0] = t1;
113
+ } else {
114
+ t1 = $[0];
115
+ }
116
+ useIsomorphicLayoutEffect(t1);
117
+ let t2;
118
+ if ($[1] !== setRegistry) {
119
+ t2 = id => {
120
+ if (workingRegistryRef.current instanceof Map) {
121
+ workingRegistryRef.current.set(id, unsetValue);
122
+ } else {
123
+ if (workingRegistryRef.current === "idle") {
124
+ workingRegistryRef.current = "queued";
125
+ rebuildRegistry();
126
+ }
127
+ }
128
+ return function unregister() {
129
+ if (workingRegistryRef.current instanceof Map) {
130
+ workingRegistryRef.current.delete(id);
131
+ } else {
132
+ if (workingRegistryRef.current === "idle") {
133
+ setRegistry(prev_0 => {
134
+ const copy = new Map(prev_0);
135
+ copy.delete(id);
136
+ return copy;
137
+ });
138
+ }
139
+ }
140
+ };
141
+ };
142
+ $[1] = setRegistry;
143
+ $[2] = t2;
144
+ } else {
145
+ t2 = $[2];
146
+ }
147
+ const register = t2;
148
+ let t3;
149
+ if ($[3] !== setRegistry) {
150
+ t3 = (id_0, value) => {
151
+ if (workingRegistryRef.current instanceof Map) {
152
+ workingRegistryRef.current.set(id_0, value);
153
+ } else {
154
+ if (workingRegistryRef.current === "idle") {
155
+ setRegistry(prev_1 => new Map(prev_1).set(id_0, value));
156
+ }
157
+ }
158
+ };
159
+ $[3] = setRegistry;
160
+ $[4] = t3;
161
+ } else {
162
+ t3 = $[4];
163
+ }
164
+ const updateValue = t3;
165
+ let t4;
166
+ if ($[5] !== setRegistry) {
167
+ t4 = function commitWorkingRegistry() {
168
+ if (workingRegistryRef.current instanceof Map) {
169
+ const setEntries = Array.from(workingRegistryRef.current.entries()).filter(_temp2);
170
+ setRegistry(new Map(setEntries));
171
+ workingRegistryRef.current = "idle";
172
+ }
173
+ };
174
+ $[5] = setRegistry;
175
+ $[6] = t4;
176
+ } else {
177
+ t4 = $[6];
178
+ }
179
+ useEffect(t4);
180
+ let t5;
181
+ if ($[7] !== key || $[8] !== register || $[9] !== updateValue) {
182
+ t5 = {
183
+ register,
184
+ updateValue,
185
+ key
186
+ };
187
+ $[7] = key;
188
+ $[8] = register;
189
+ $[9] = updateValue;
190
+ $[10] = t5;
191
+ } else {
192
+ t5 = $[10];
193
+ }
194
+ const contextValue = t5;
195
+ let t6;
196
+ if ($[11] !== children || $[12] !== contextValue) {
197
+ t6 = /*#__PURE__*/jsx(Context.Provider, {
198
+ value: contextValue,
199
+ children: children
200
+ });
201
+ $[11] = children;
202
+ $[12] = contextValue;
203
+ $[13] = t6;
204
+ } else {
205
+ t6 = $[13];
206
+ }
207
+ return t6;
208
+ }
209
+ function _temp2(entry) {
210
+ return entry[1] !== unsetValue;
211
+ }
212
+ function _temp(prev) {
213
+ return prev + 1;
214
+ }
215
+ return {
216
+ Provider,
217
+ useRegistryState,
218
+ useRegisterDescendant
219
+ };
220
+ }
221
+
222
+ export { createDescendantRegistry };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260304094354",
4
+ "version": "0.0.0-20260304110422",
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",