@primer/react 0.0.0-20260223024855 → 0.0.0-20260223110740

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,"file":"useRefObjectAsForwardedRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefObjectAsForwardedRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAA;AAGlD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAIjH"}
1
+ {"version":3,"file":"useRefObjectAsForwardedRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useRefObjectAsForwardedRef.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAA;AAGlD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAEjH"}
@@ -9,7 +9,7 @@ import { useImperativeHandle } from 'react';
9
9
  * **NOTE**: The `refObject` should be passed to the underlying element, NOT the `forwardedRef`.
10
10
  */
11
11
  function useRefObjectAsForwardedRef(forwardedRef, refObject) {
12
- const $ = c(4);
12
+ const $ = c(2);
13
13
  let t0;
14
14
  if ($[0] !== refObject.current) {
15
15
  t0 = () => refObject.current;
@@ -18,15 +18,7 @@ function useRefObjectAsForwardedRef(forwardedRef, refObject) {
18
18
  } else {
19
19
  t0 = $[1];
20
20
  }
21
- let t1;
22
- if ($[2] !== refObject) {
23
- t1 = [refObject];
24
- $[2] = refObject;
25
- $[3] = t1;
26
- } else {
27
- t1 = $[3];
28
- }
29
- useImperativeHandle(forwardedRef, t0, t1);
21
+ useImperativeHandle(forwardedRef, t0);
30
22
  }
31
23
 
32
24
  export { useRefObjectAsForwardedRef };
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollFlash.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollFlash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QAoB7F"}
1
+ {"version":3,"file":"useScrollFlash.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollFlash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QAe7F"}
@@ -1,3 +1,4 @@
1
+ import { c } from 'react-compiler-runtime';
1
2
  import { useEffect } from 'react';
2
3
 
3
4
  /**
@@ -5,23 +6,30 @@ import { useEffect } from 'react';
5
6
  * @param scrollContainerRef The ref of the scrollable content
6
7
  */
7
8
  function useScrollFlash(scrollContainerRef) {
8
- // https://adxlv.computer/projects/flash-scrollers/
9
- useEffect(() => {
10
- const scrollContainer = scrollContainerRef.current;
11
- if (!scrollContainer) {
12
- return;
13
- }
14
-
15
- // Defer to the next frame to avoid forcing a synchronous reflow
16
- // when the effect runs immediately after React commits DOM changes.
17
- const id = requestAnimationFrame(() => {
9
+ const $ = c(3);
10
+ let t0;
11
+ let t1;
12
+ if ($[0] !== scrollContainerRef) {
13
+ t0 = () => {
14
+ const scrollContainer = scrollContainerRef.current;
15
+ if (!scrollContainer) {
16
+ return;
17
+ }
18
18
  const currentScroll = scrollContainer.scrollTop;
19
- const altScroll = currentScroll < 1 ? currentScroll + 1 : currentScroll - 1;
19
+ const maxScroll = scrollContainer.scrollHeight;
20
+ const altScroll = currentScroll < Math.min(1, maxScroll) ? currentScroll + 1 : currentScroll - 1;
20
21
  scrollContainer.scrollTop = altScroll;
21
22
  scrollContainer.scrollTop = currentScroll;
22
- });
23
- return () => cancelAnimationFrame(id);
24
- }, [scrollContainerRef]);
23
+ };
24
+ t1 = [scrollContainerRef];
25
+ $[0] = scrollContainerRef;
26
+ $[1] = t0;
27
+ $[2] = t1;
28
+ } else {
29
+ t0 = $[1];
30
+ t1 = $[2];
31
+ }
32
+ useEffect(t0, t1);
25
33
  }
26
34
 
27
35
  export { useScrollFlash as default };
@@ -1,56 +1,8 @@
1
1
  import React from 'react';
2
- /**
3
- * useSlots - Extract slot components from children for SSR-compatible slot APIs.
4
- *
5
- * Given a list of children and a config mapping slot names to component types,
6
- * separates children into two groups: matched slots and the rest.
7
- *
8
- * Config: { leadingVisual: LeadingVisual, description: Description }
9
- *
10
- * Children: Matching: Output:
11
- * +----------------+ slots = {
12
- * | LeadingVisual | -> matches slot 0 --> leadingVisual: <LeadingVisual />
13
- * | "Project name" | -> no match --> description: <Description />
14
- * | Description | -> matches slot 1 --> }
15
- * | TrailingVisual | -> no match --> rest = ["Project name", <TrailingVisual />]
16
- * +----------------+
17
- *
18
- * Performance-sensitive: called per item in lists (e.g. 100-item ActionList
19
- * calls this 101 times per render).
20
- *
21
- * Once all slots are filled, remaining children skip matching entirely in
22
- * production (single integer comparison). In dev, we still scan for duplicates
23
- * to emit a warning.
24
- *
25
- * Flow per child:
26
- *
27
- * child ──> isValidElement? ──no──> rest[]
28
- * |
29
- * yes
30
- * |
31
- * v
32
- * all slots filled? ──yes──> rest[] (prod)
33
- * | |
34
- * no [dev: check for
35
- * | duplicate warning]
36
- * v
37
- * match against unfilled slots
38
- * |
39
- * found match? ──no──> rest[]
40
- * |
41
- * yes
42
- * |
43
- * v
44
- * slots[key] = child, slotsFound++
45
- *
46
- * Slot config supports two matcher styles:
47
- * 1. Component reference: { visual: LeadingVisual }
48
- * 2. Component + test fn: { block: [Description, props => props.variant === 'block'] }
49
- */
50
- type Props = any;
51
2
  type ComponentMatcher = React.ElementType<Props>;
52
3
  type ComponentAndPropsMatcher = [ComponentMatcher, (props: Props) => boolean];
53
4
  export type SlotConfig = Record<string, ComponentMatcher | ComponentAndPropsMatcher>;
5
+ type Props = any;
54
6
  type SlotElements<Config extends SlotConfig> = {
55
7
  [Property in keyof Config]: SlotValue<Config, Property>;
56
8
  };
@@ -58,7 +10,11 @@ type SlotValue<Config, Property extends keyof Config> = Config[Property] extends
58
10
  infer ElementType extends React.ElementType,
59
11
  infer _testFn
60
12
  ] ? React.ReactElement<React.ComponentPropsWithoutRef<ElementType>, ElementType> : never;
61
- /** Extract slot components from children. See file header for details. */
13
+ /**
14
+ * Extract components from `children` so we can render them in different places,
15
+ * allowing us to implement components with SSR-compatible slot APIs.
16
+ * Note: We can only extract direct children, not nested ones.
17
+ */
62
18
  export declare function useSlots<Config extends SlotConfig>(children: React.ReactNode, config: Config): [Partial<SlotElements<Config>>, React.ReactNode[]];
63
19
  export {};
64
20
  //# sourceMappingURL=useSlots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSlots.d.ts","sourceRoot":"","sources":["../../src/hooks/useSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAKH,KAAK,KAAK,GAAG,GAAG,CAAA;AAChB,KAAK,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;AAChD,KAAK,wBAAwB,GAAG,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,CAAA;AAE7E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,wBAAwB,CAAC,CAAA;AAEpF,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI;KAC5C,QAAQ,IAAI,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;CACxD,CAAA;AAED,KAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,SAAS,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,CAAC,WAAW,GAC9F,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GACtF,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAS;IAC9B,MAAM,WAAW,SAAS,KAAK,CAAC,WAAW;IAE3C,MAAM,OAAO;CACd,GACD,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,GAC5E,KAAK,CAAA;AAeX,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,MAAM,SAAS,UAAU,EAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,MAAM,EAAE,MAAM,GACb,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAqDpD"}
1
+ {"version":3,"file":"useSlots.d.ts","sourceRoot":"","sources":["../../src/hooks/useSlots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAOzB,KAAK,gBAAgB,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;AAEhD,KAAK,wBAAwB,GAAG,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,CAAA;AAE7E,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,wBAAwB,CAAC,CAAA;AAIpF,KAAK,KAAK,GAAG,GAAG,CAAA;AAEhB,KAAK,YAAY,CAAC,MAAM,SAAS,UAAU,IAAI;KAC5C,QAAQ,IAAI,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC;CACxD,CAAA;AAED,KAAK,SAAS,CAAC,MAAM,EAAE,QAAQ,SAAS,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,CAAC,WAAW,GAC9F,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,GACtF,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAS;IAC9B,MAAM,WAAW,SAAS,KAAK,CAAC,WAAW;IAE3C,MAAM,OAAO;CACd,GACD,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,GAC5E,KAAK,CAAA;AAEX;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,SAAS,UAAU,EAChD,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,MAAM,EAAE,MAAM,GACb,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CA8CpD"}
@@ -2,85 +2,29 @@ import React from 'react';
2
2
  import { warning } from '../utils/warning.js';
3
3
  import { isSlot } from '../utils/is-slot.js';
4
4
 
5
- /**
6
- * useSlots - Extract slot components from children for SSR-compatible slot APIs.
7
- *
8
- * Given a list of children and a config mapping slot names to component types,
9
- * separates children into two groups: matched slots and the rest.
10
- *
11
- * Config: { leadingVisual: LeadingVisual, description: Description }
12
- *
13
- * Children: Matching: Output:
14
- * +----------------+ slots = {
15
- * | LeadingVisual | -> matches slot 0 --> leadingVisual: <LeadingVisual />
16
- * | "Project name" | -> no match --> description: <Description />
17
- * | Description | -> matches slot 1 --> }
18
- * | TrailingVisual | -> no match --> rest = ["Project name", <TrailingVisual />]
19
- * +----------------+
20
- *
21
- * Performance-sensitive: called per item in lists (e.g. 100-item ActionList
22
- * calls this 101 times per render).
23
- *
24
- * Once all slots are filled, remaining children skip matching entirely in
25
- * production (single integer comparison). In dev, we still scan for duplicates
26
- * to emit a warning.
27
- *
28
- * Flow per child:
29
- *
30
- * child ──> isValidElement? ──no──> rest[]
31
- * |
32
- * yes
33
- * |
34
- * v
35
- * all slots filled? ──yes──> rest[] (prod)
36
- * | |
37
- * no [dev: check for
38
- * | duplicate warning]
39
- * v
40
- * match against unfilled slots
41
- * |
42
- * found match? ──no──> rest[]
43
- * |
44
- * yes
45
- * |
46
- * v
47
- * slots[key] = child, slotsFound++
48
- *
49
- * Slot config supports two matcher styles:
50
- * 1. Component reference: { visual: LeadingVisual }
51
- * 2. Component + test fn: { block: [Description, props => props.variant === 'block'] }
52
- */
5
+ // slot config allows 2 options:
6
+ // 1. Component to match, example: { leadingVisual: LeadingVisual }
53
7
 
54
- // --- Types ---
8
+ // 2. Component to match + a test function, example: { blockDescription: [Description, props => props.variant === 'block'] }
55
9
 
10
+ // We don't know what the props are yet, we set them later based on slot config
56
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
12
 
58
- // --- Matching ---
59
-
60
- /** Check if a child element matches a slot config entry, either by direct type comparison or slot symbol. */
61
- function childMatchesSlot(child, slotValue) {
62
- if (Array.isArray(slotValue)) {
63
- const [component, testFn] = slotValue;
64
- return (child.type === component || isSlot(child, component)) && testFn(child.props);
65
- }
66
- return child.type === slotValue || isSlot(child, slotValue);
67
- }
68
-
69
- // --- Hook ---
13
+ // useful for narrowing types, third option is not possible
70
14
 
71
- /** Extract slot components from children. See file header for details. */
15
+ /**
16
+ * Extract components from `children` so we can render them in different places,
17
+ * allowing us to implement components with SSR-compatible slot APIs.
18
+ * Note: We can only extract direct children, not nested ones.
19
+ */
72
20
  function useSlots(children, config) {
21
+ // Object mapping slot names to their elements
22
+ const slots = mapValues(config, () => undefined);
23
+
24
+ // Array of elements that are not slots
73
25
  const rest = [];
74
26
  const keys = Object.keys(config);
75
27
  const values = Object.values(config);
76
- const totalSlots = keys.length;
77
-
78
- // Initialize all slot keys to undefined so callers can check `slots.x === undefined`
79
- const slots = {};
80
- for (let i = 0; i < totalSlots; i++) {
81
- slots[keys[i]] = undefined;
82
- }
83
- let slotsFound = 0;
84
28
 
85
29
  // eslint-disable-next-line github/array-foreach
86
30
  React.Children.forEach(children, child => {
@@ -88,63 +32,41 @@ function useSlots(children, config) {
88
32
  rest.push(child);
89
33
  return;
90
34
  }
91
-
92
- // Short-circuit: all slots filled, no more matching needed
93
- if (slotsFound === totalSlots) {
94
- if (process.env.NODE_ENV !== "production" && warnIfDuplicate(child, keys, values, totalSlots)) {
95
- return;
35
+ const index = values.findIndex(value => {
36
+ if (Array.isArray(value)) {
37
+ const [component, testFn] = value;
38
+ return (child.type === component || isSlot(child, component)) && testFn(child.props);
39
+ } else {
40
+ return child.type === value || isSlot(child, value);
96
41
  }
97
- rest.push(child);
98
- return;
99
- }
42
+ });
100
43
 
101
- // Try to match child against a slot
102
- const matchedIndex = findMatchingSlot(child, values, totalSlots);
103
- if (matchedIndex === -1) {
44
+ // If the child is not a slot, add it to the `rest` array
45
+ if (index === -1) {
104
46
  rest.push(child);
105
47
  return;
106
48
  }
107
- const slotKey = keys[matchedIndex];
49
+ const slotKey = keys[index];
108
50
 
109
- // Duplicate: slot already filled by an earlier child
110
- if (slots[slotKey] !== undefined) {
111
- if (process.env.NODE_ENV !== "production") {
112
- process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(slotKey)}" slot. Only the first will be rendered.`) : void 0;
113
- }
51
+ // If slot is already filled, ignore duplicates
52
+ if (slots[slotKey]) {
53
+ process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(slotKey)}" slot. Only the first will be rendered.`) : void 0;
114
54
  return;
115
55
  }
56
+
57
+ // If the child is a slot, add it to the `slots` object
58
+
116
59
  slots[slotKey] = child;
117
- slotsFound++;
118
60
  });
119
61
  return [slots, rest];
120
62
  }
121
63
 
122
- // --- Helpers ---
123
-
124
- /**
125
- * Find the first slot config entry matching this child.
126
- * Returns the config index, or -1 if no match.
127
- */
128
- function findMatchingSlot(child, values, totalSlots) {
129
- for (let i = 0; i < totalSlots; i++) {
130
- if (childMatchesSlot(child, values[i])) return i;
131
- }
132
- return -1;
133
- }
134
-
135
- /**
136
- * Dev-only: check if a child duplicates an already-filled slot.
137
- * Returns true (and warns) if a duplicate is found, false otherwise.
138
- * Used in the short-circuit path where all slots are already filled.
139
- */
140
- function warnIfDuplicate(child, keys, values, totalSlots) {
141
- for (let i = 0; i < totalSlots; i++) {
142
- if (childMatchesSlot(child, values[i])) {
143
- process.env.NODE_ENV !== "production" ? warning(true, `Found duplicate "${String(keys[i])}" slot. Only the first will be rendered.`) : void 0;
144
- return true;
145
- }
146
- }
147
- return false;
64
+ /** Map the values of an object */
65
+ function mapValues(obj, fn) {
66
+ return Object.keys(obj).reduce((result, key) => {
67
+ result[key] = fn(obj[key]);
68
+ return result;
69
+ }, {});
148
70
  }
149
71
 
150
72
  export { useSlots };
@@ -1027,7 +1027,7 @@
1027
1027
  },
1028
1028
  {
1029
1029
  "id": "components-autocomplete-features--in-overlay-with-custom-scroll-container-ref",
1030
- "code": "() => {\n const scrollContainerRef = useRef<HTMLElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const [isOpen, setIsOpen] = useState(false)\n const [selectedItem, setSelectedItem] = useState<Datum>()\n const handleOpen = () => {\n setIsOpen(true)\n inputRef.current && inputRef.current.focus()\n }\n const selectChange = (item: Datum[] | Datum) => {\n setIsOpen(false)\n if (Array.isArray(item) && item.length) setSelectedItem(item[0])\n triggerRef.current?.focus()\n }\n return (\n <form className={classes.FormPadding}>\n <span id=\"selected-item-status\">\n Selected item: {selectedItem ? selectedItem.text : 'none'}\n </span>\n\n <AnchoredOverlay\n open={isOpen}\n onOpen={handleOpen}\n onClose={() => setIsOpen(false)}\n width=\"large\"\n focusTrapSettings={{\n initialFocusRef: inputRef,\n }}\n side=\"inside-top\"\n anchorRef={triggerRef}\n renderAnchor={(props) => (\n <Button {...props} aria-describedby=\"selected-item-status\">\n open overlay\n </Button>\n )}\n preventOverflow={false}\n >\n <Autocomplete>\n <div className={classes.OverlayFlexCol}>\n <div className={classes.OverlayInputBar}>\n <Autocomplete.Input\n ref={inputRef}\n className={classes.OverlayInput}\n block\n aria-label=\"Search\"\n />\n </div>\n <div\n ref={scrollContainerRef as RefObject<HTMLDivElement>}\n className={classes.OverlayScroll}\n >\n <Autocomplete.Menu\n items={items}\n selectedItemIds={[]}\n customScrollContainerRef={scrollContainerRef}\n aria-labelledby=\"autocompleteLabel\"\n onSelectedChange={selectChange}\n />\n </div>\n </div>\n </Autocomplete>\n </AnchoredOverlay>\n </form>\n )\n}"
1030
+ "code": "() => {\n const scrollContainerRef = useRef<HTMLElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const [isOpen, setIsOpen] = useState(false)\n const [selectedItem, setSelectedItem] = useState<Datum>()\n const handleOpen = () => {\n setIsOpen(true)\n inputRef.current && inputRef.current.focus()\n }\n const selectChange = (item: Datum[] | Datum) => {\n setIsOpen(false)\n if (Array.isArray(item) && item.length) setSelectedItem(item[0])\n triggerRef.current?.focus()\n }\n return (\n <form className={classes.FormPadding}>\n Selected item: {selectedItem ? selectedItem.text : 'none'}\n <AnchoredOverlay\n open={isOpen}\n onOpen={handleOpen}\n onClose={() => setIsOpen(false)}\n width=\"large\"\n focusTrapSettings={{\n initialFocusRef: inputRef,\n }}\n side=\"inside-top\"\n anchorRef={triggerRef}\n renderAnchor={(props) => <Button {...props}>open overlay</Button>}\n preventOverflow={false}\n >\n <Autocomplete>\n <div className={classes.OverlayFlexCol}>\n <div className={classes.OverlayInputBar}>\n <Autocomplete.Input\n ref={inputRef}\n className={classes.OverlayInput}\n block\n aria-label=\"Search\"\n />\n </div>\n <div\n ref={scrollContainerRef as RefObject<HTMLDivElement>}\n className={classes.OverlayScroll}\n >\n <Autocomplete.Menu\n items={items}\n selectedItemIds={[]}\n customScrollContainerRef={scrollContainerRef}\n aria-labelledby=\"autocompleteLabel\"\n onSelectedChange={selectChange}\n />\n </div>\n </div>\n </Autocomplete>\n </AnchoredOverlay>\n </form>\n )\n}"
1031
1031
  },
1032
1032
  {
1033
1033
  "id": "components-autocomplete-features--in-a-dialog",
@@ -3244,8 +3244,8 @@
3244
3244
  "code": "() => {\n const [tokens, setTokens] = useState([...mockTokens])\n const onTokenRemove = (tokenId: string | number) => {\n setTokens(\n tokens.filter((token: { id: string | number }) => token.id !== tokenId),\n )\n }\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label id=\"form-label\">\n TextInputWithTokens\n </FormControl.Label>\n <TextInputWithTokens onTokenRemove={onTokenRemove} tokens={tokens} />\n </FormControl>\n <FormControl>\n <FormControl.Label id=\"autocomplete-label\">\n Autocomplete\n </FormControl.Label>\n <Autocomplete>\n <Autocomplete.Input block />\n <Autocomplete.Overlay>\n <Autocomplete.Menu\n aria-labelledby=\"autocomplete-label\"\n items={[\n {\n text: 'css',\n id: '0',\n },\n {\n text: 'css-in-js',\n id: '1',\n },\n {\n text: 'styled-system',\n id: '2',\n },\n {\n text: 'javascript',\n id: '3',\n },\n {\n text: 'typescript',\n id: '4',\n },\n {\n text: 'react',\n id: '5',\n },\n {\n text: 'design-systems',\n id: '6',\n },\n ]}\n selectedItemIds={[]}\n />\n </Autocomplete.Overlay>\n </Autocomplete>\n </FormControl>\n <FormControl>\n <FormControl.Label>Select</FormControl.Label>\n <Select>\n <Select.Option value=\"figma\">Figma</Select.Option>\n <Select.Option value=\"css\">Primer CSS</Select.Option>\n <Select.Option value=\"prc\">Primer React components</Select.Option>\n <Select.Option value=\"pvc\">Primer ViewComponents</Select.Option>\n </Select>\n </FormControl>\n <FormControl>\n <FormControl.Label>Textarea</FormControl.Label>\n <Textarea />\n </FormControl>\n </div>\n )\n}"
3245
3245
  },
3246
3246
  {
3247
- "id": "components-formcontrol-features--with-custom-input",
3248
- "code": "() => {\n const [value, setValue] = React.useState('mona lisa')\n const [validationResult, setValidationResult] = React.useState('')\n const doesValueContainSpaces = (inputValue: string) => /\\s/g.test(inputValue)\n const handleInputChange = (e: {\n currentTarget: {\n value: React.SetStateAction<string>\n }\n }) => {\n setValue(e.currentTarget.value)\n }\n React.useEffect(() => {\n if (doesValueContainSpaces(value)) {\n setValidationResult('noSpaces')\n } else if (value) {\n setValidationResult('validName')\n }\n }, [value])\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label htmlFor=\"custom-input\">\n GitHub handle\n </FormControl.Label>\n <CustomTextInput\n id=\"custom-input\"\n aria-describedby=\"custom-input-validation custom-input-caption\"\n aria-invalid={validationResult === 'noSpaces'}\n onChange={handleInputChange}\n />\n {validationResult === 'noSpaces' && (\n <FormControl.Validation id=\"custom-input-validation\" variant=\"error\">\n GitHub handles cannot contain spaces\n </FormControl.Validation>\n )}\n {validationResult === 'validName' && (\n <FormControl.Validation\n id=\"custom-input-validation\"\n variant=\"success\"\n >\n Valid name\n </FormControl.Validation>\n )}\n <FormControl.Caption id=\"custom-input-caption\">\n With or without &quot;@&quot;. For example &quot;monalisa&quot; or\n &quot;@monalisa&quot;\n </FormControl.Caption>\n </FormControl>\n\n <CheckboxGroup>\n <CheckboxGroup.Label>Checkboxes</CheckboxGroup.Label>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-one\"\n aria-describedby=\"custom-checkbox-one-caption\"\n value=\"checkOne\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-one\">\n Checkbox one\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-one-caption\">\n Hint text for checkbox one\n </FormControl.Caption>\n </FormControl>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-two\"\n aria-describedby=\"custom-checkbox-two-caption\"\n value=\"checkTwo\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-two\">\n Checkbox two\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-two-caption\">\n Hint text for checkbox two\n </FormControl.Caption>\n </FormControl>\n </CheckboxGroup>\n </div>\n )\n}"
3247
+ "id": "components-formcontrol-features--form-control-with-custom-input",
3248
+ "code": "() => {\n const [value, setValue] = React.useState('mona lisa')\n const [validationResult, setValidationResult] = React.useState('')\n const doesValueContainSpaces = (inputValue: string) => /\\s/g.test(inputValue)\n const handleInputChange = (e: {\n currentTarget: {\n value: React.SetStateAction<string>\n }\n }) => {\n setValue(e.currentTarget.value)\n }\n React.useEffect(() => {\n if (doesValueContainSpaces(value)) {\n setValidationResult('noSpaces')\n } else if (value) {\n setValidationResult('validName')\n }\n }, [value])\n return (\n <div className={classes.GridContainer}>\n <FormControl>\n <FormControl.Label htmlFor=\"custom-input\">\n GitHub handle\n </FormControl.Label>\n <CustomTextInput\n id=\"custom-input\"\n aria-describedby=\"custom-input-caption custom-input-validation\"\n aria-invalid={validationResult === 'noSpaces'}\n onChange={handleInputChange}\n />\n {validationResult === 'noSpaces' && (\n <FormControl.Validation id=\"custom-input-validation\" variant=\"error\">\n GitHub handles cannot contain spaces\n </FormControl.Validation>\n )}\n {validationResult === 'validName' && (\n <FormControl.Validation\n id=\"custom-input-validation\"\n variant=\"success\"\n >\n Valid name\n </FormControl.Validation>\n )}\n <FormControl.Caption id=\"custom-input-caption\">\n With or without &quot;@&quot;. For example &quot;monalisa&quot; or\n &quot;@monalisa&quot;\n </FormControl.Caption>\n </FormControl>\n\n <CheckboxGroup>\n <CheckboxGroup.Label>Checkboxes</CheckboxGroup.Label>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-one\"\n aria-describedby=\"custom-checkbox-one-caption\"\n value=\"checkOne\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-one\">\n Checkbox one\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-one-caption\">\n Hint text for checkbox one\n </FormControl.Caption>\n </FormControl>\n <FormControl layout=\"horizontal\">\n <CustomCheckboxInput\n id=\"custom-checkbox-two\"\n aria-describedby=\"custom-checkbox-two-caption\"\n value=\"checkTwo\"\n />\n <FormControl.Label htmlFor=\"custom-checkbox-two\">\n Checkbox two\n </FormControl.Label>\n <FormControl.Caption id=\"custom-checkbox-two-caption\">\n Hint text for checkbox two\n </FormControl.Caption>\n </FormControl>\n </CheckboxGroup>\n </div>\n )\n}"
3249
3249
  },
3250
3250
  {
3251
3251
  "id": "components-formcontrol-features--with-checkbox-and-radio-inputs",
@@ -6403,12 +6403,6 @@
6403
6403
  "type": "(newActiveDescendant: HTMLElement | undefined, previousActiveDescendant: HTMLElement | undefined, directlyActivated: boolean) => void | undefined",
6404
6404
  "defaultValue": "undefined",
6405
6405
  "description": "Callback function that is called when the active descendant changes."
6406
- },
6407
- {
6408
- "name": "virtualized",
6409
- "type": "boolean",
6410
- "defaultValue": "false",
6411
- "description": "If true, enables client-side list virtualization. Only the visible items plus a small overscan buffer are rendered in the DOM, dramatically improving performance for large lists. Recommended for lists with more than 100 items. Has no effect when `groupMetadata` is provided."
6412
6406
  }
6413
6407
  ],
6414
6408
  "subcomponents": []
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260223024855",
4
+ "version": "0.0.0-20260223110740",
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",
@@ -83,7 +83,6 @@
83
83
  "@primer/live-region-element": "^0.7.1",
84
84
  "@primer/octicons-react": "^19.21.0",
85
85
  "@primer/primitives": "10.x || 11.x",
86
- "@tanstack/react-virtual": "^3.13.18",
87
86
  "clsx": "^2.1.1",
88
87
  "color2k": "^2.0.3",
89
88
  "deepmerge": "^4.3.1",
@@ -108,6 +107,7 @@
108
107
  "@figma/code-connect": "1.3.2",
109
108
  "@primer/css": "^21.5.1",
110
109
  "@primer/doc-gen": "^0.0.1",
110
+ "@tanstack/react-virtual": "^3.13.12",
111
111
  "@rollup/plugin-babel": "6.1.0",
112
112
  "@rollup/plugin-commonjs": "29.0.0",
113
113
  "@rollup/plugin-json": "6.1.0",