@lerianstudio/sindarian-ui 1.3.0-beta.1 → 1.3.0-beta.2
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/dist/components/ui/autocomplete/index.d.ts +1 -1
- package/dist/components/ui/autocomplete/index.d.ts.map +1 -1
- package/dist/components/ui/autocomplete/index.js +41 -5
- package/dist/esm/components/ui/autocomplete/index.d.ts +1 -1
- package/dist/esm/components/ui/autocomplete/index.d.ts.map +1 -1
- package/dist/esm/components/ui/autocomplete/index.js +41 -5
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ export type AutocompleteContentProps = React.ComponentProps<typeof CommandPrimit
|
|
|
34
34
|
side?: Side;
|
|
35
35
|
onPointerDownOutside?: (event: MouseEvent | TouchEvent) => void;
|
|
36
36
|
};
|
|
37
|
-
export declare function AutocompleteContent({ className, position, side, ref, children, onMouseEnter, onMouseLeave, onPointerDownOutside, ...props }: AutocompleteContentProps): React.JSX.Element
|
|
37
|
+
export declare function AutocompleteContent({ className, position, side, ref, children, onMouseEnter, onMouseLeave, onPointerDownOutside, ...props }: AutocompleteContentProps): React.JSX.Element;
|
|
38
38
|
export declare function AutocompleteGroup({ className, ...props }: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>): React.JSX.Element;
|
|
39
39
|
export declare function AutocompleteItem({ className, value, onSelect, ...props }: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>): React.JSX.Element;
|
|
40
40
|
export type AutocompleteProps = React.ComponentProps<typeof CommandPrimitive> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/autocomplete/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAmB,MAAM,MAAM,CAAA;AAInE,MAAM,MAAM,uBAAuB,GACjC,KAAK,CAAC,kBAAkB,CAAC,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,KAAK,EACT,EAAE,KAAK,CAAC,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,qBAsB9D;AAED,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAClD,OAAO,gBAAgB,CACxB,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,CAAA;IACrC,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAA;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAEpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IAEtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,KAAK,EACL,YAAY,EACZ,aAAa,EACb,OAAO,EACP,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAmInB"}
|
|
@@ -165,6 +165,17 @@ function AutocompleteContent({ className, position = 'popper', side = 'bottom',
|
|
|
165
165
|
const { open, addOption, setOpen, onScrollbar, setOnScrollbar, inputRef } = useAutocomplete();
|
|
166
166
|
react_1.default.useImperativeHandle(ref, () => _ref.current);
|
|
167
167
|
(0, use_click_away_1.useClickAway)(_ref, (event) => {
|
|
168
|
+
/**
|
|
169
|
+
* ⛔ THE `open` GUARD IS LOAD-BEARING SINCE THIS LIST STOPPED UNMOUNTING.
|
|
170
|
+
* While the panel returned `null` this handler was inert by accident: its
|
|
171
|
+
* ref pointed at nothing. Now that the list stays in the DOM (see the return
|
|
172
|
+
* below), every click anywhere on the page reaches here — and without this
|
|
173
|
+
* line each one would call `setOpen(false)` and blur the input. A consumer
|
|
174
|
+
* form carrying ten of these would run ten handlers per click.
|
|
175
|
+
*/
|
|
176
|
+
if (!open) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
168
179
|
// Should not close when clicking on the scrollbar
|
|
169
180
|
if (onScrollbar) {
|
|
170
181
|
return;
|
|
@@ -207,17 +218,42 @@ function AutocompleteContent({ className, position = 'popper', side = 'bottom',
|
|
|
207
218
|
react_1.default.useEffect(() => {
|
|
208
219
|
_searchChildren(children);
|
|
209
220
|
}, [children]);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
221
|
+
/**
|
|
222
|
+
* ⛔ THE LIST STAYS IN THE DOM, THE OPTIONS DO NOT — and the split is the whole
|
|
223
|
+
* fix (#150).
|
|
224
|
+
*
|
|
225
|
+
* cmdk puts `aria-controls={listId}` on the input it renders and `id={listId}`
|
|
226
|
+
* on this list. Returning `null` while closed therefore left the input naming
|
|
227
|
+
* an element that did not exist, which axe-core reports as a CRITICAL
|
|
228
|
+
* `aria-valid-attr-value` violation — measured as 10 failing cases across five
|
|
229
|
+
* forms in a consumer, in both the populated and the empty state. A screen
|
|
230
|
+
* reader following the reference resolved it to nothing.
|
|
231
|
+
*
|
|
232
|
+
* ⛔ AND NOT "KEEP EVERYTHING MOUNTED", which is the obvious reading of the
|
|
233
|
+
* fix and is too expensive. Only the LIST carries the id; the options carry
|
|
234
|
+
* the cost. One consumer form puts up to ten of these on screen, each holding
|
|
235
|
+
* a page of up to a hundred options — roughly a thousand permanently present
|
|
236
|
+
* nodes for an id that is one element. `{open ? children : null}` keeps the
|
|
237
|
+
* reference resolvable and the DOM the size it was.
|
|
238
|
+
*
|
|
239
|
+
* ⚠️ `hidden` AND NOT A CLASS. It removes the subtree from the accessibility
|
|
240
|
+
* tree as well as from view, so a closed panel is not an empty `listbox` that
|
|
241
|
+
* a screen reader can reach into.
|
|
242
|
+
*
|
|
243
|
+
* ⚠️ THE ENTRY ANIMATION IS NOT LOST, because there was none to lose: the
|
|
244
|
+
* className carries `animate-in` with no `fade-in-*` / `zoom-in-*` / `slide-in-*`
|
|
245
|
+
* companion, so every `--tw-enter-*` variable sits at its default and the
|
|
246
|
+
* keyframe is a no-op today. Should a real one be added later, it belongs on a
|
|
247
|
+
* wrapper INSIDE this list — that subtree still mounts with the children.
|
|
248
|
+
*/
|
|
249
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "relative", hidden: !open, children: (0, jsx_runtime_1.jsx)(cmdk_1.Command.List, { ref: _ref, className: (0, utils_1.cn)('bg-popover text-popover-foreground animate-in absolute top-1 z-50 max-h-96 w-full min-w-32 overflow-x-hidden overflow-y-auto rounded-md border shadow-md outline-hidden', position === 'popper' &&
|
|
214
250
|
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), "data-side": side, ...props, onMouseEnter: (e) => {
|
|
215
251
|
onMouseEnter?.(e);
|
|
216
252
|
setOnScrollbar(true);
|
|
217
253
|
}, onMouseLeave: (e) => {
|
|
218
254
|
onMouseLeave?.(e);
|
|
219
255
|
setOnScrollbar(false);
|
|
220
|
-
}, children: children }) }));
|
|
256
|
+
}, children: open ? children : null }) }));
|
|
221
257
|
}
|
|
222
258
|
function AutocompleteGroup({ className, ...props }) {
|
|
223
259
|
return ((0, jsx_runtime_1.jsx)(cmdk_1.Command.Group, { "data-slot": "autocomplete-group", className: (0, utils_1.cn)('text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium', className), ...props }));
|
|
@@ -34,7 +34,7 @@ export type AutocompleteContentProps = React.ComponentProps<typeof CommandPrimit
|
|
|
34
34
|
side?: Side;
|
|
35
35
|
onPointerDownOutside?: (event: MouseEvent | TouchEvent) => void;
|
|
36
36
|
};
|
|
37
|
-
export declare function AutocompleteContent({ className, position, side, ref, children, onMouseEnter, onMouseLeave, onPointerDownOutside, ...props }: AutocompleteContentProps): React.JSX.Element
|
|
37
|
+
export declare function AutocompleteContent({ className, position, side, ref, children, onMouseEnter, onMouseLeave, onPointerDownOutside, ...props }: AutocompleteContentProps): React.JSX.Element;
|
|
38
38
|
export declare function AutocompleteGroup({ className, ...props }: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>): React.JSX.Element;
|
|
39
39
|
export declare function AutocompleteItem({ className, value, onSelect, ...props }: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>): React.JSX.Element;
|
|
40
40
|
export type AutocompleteProps = React.ComponentProps<typeof CommandPrimitive> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/autocomplete/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAmB,MAAM,MAAM,CAAA;AAInE,MAAM,MAAM,uBAAuB,GACjC,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,GAAG;IAC3C,sCAAsC;IACtC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,EAAE,CAAA;IAC7B,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,6BAA6B;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,WAAW,EAA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K,IAAI,CAAA;IACnD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAEpB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IAEtC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,KAAK,EACL,YAAY,EACZ,aAAa,EACb,OAAO,EACP,SAAS,EACT,IAAI,EAAE,QAAQ,EACd,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,qBAmInB"}
|
|
@@ -117,6 +117,17 @@ export function AutocompleteContent({ className, position = 'popper', side = 'bo
|
|
|
117
117
|
const { open, addOption, setOpen, onScrollbar, setOnScrollbar, inputRef } = useAutocomplete();
|
|
118
118
|
React.useImperativeHandle(ref, () => _ref.current);
|
|
119
119
|
useClickAway(_ref, (event) => {
|
|
120
|
+
/**
|
|
121
|
+
* ⛔ THE `open` GUARD IS LOAD-BEARING SINCE THIS LIST STOPPED UNMOUNTING.
|
|
122
|
+
* While the panel returned `null` this handler was inert by accident: its
|
|
123
|
+
* ref pointed at nothing. Now that the list stays in the DOM (see the return
|
|
124
|
+
* below), every click anywhere on the page reaches here — and without this
|
|
125
|
+
* line each one would call `setOpen(false)` and blur the input. A consumer
|
|
126
|
+
* form carrying ten of these would run ten handlers per click.
|
|
127
|
+
*/
|
|
128
|
+
if (!open) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
120
131
|
// Should not close when clicking on the scrollbar
|
|
121
132
|
if (onScrollbar) {
|
|
122
133
|
return;
|
|
@@ -159,17 +170,42 @@ export function AutocompleteContent({ className, position = 'popper', side = 'bo
|
|
|
159
170
|
React.useEffect(() => {
|
|
160
171
|
_searchChildren(children);
|
|
161
172
|
}, [children]);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
173
|
+
/**
|
|
174
|
+
* ⛔ THE LIST STAYS IN THE DOM, THE OPTIONS DO NOT — and the split is the whole
|
|
175
|
+
* fix (#150).
|
|
176
|
+
*
|
|
177
|
+
* cmdk puts `aria-controls={listId}` on the input it renders and `id={listId}`
|
|
178
|
+
* on this list. Returning `null` while closed therefore left the input naming
|
|
179
|
+
* an element that did not exist, which axe-core reports as a CRITICAL
|
|
180
|
+
* `aria-valid-attr-value` violation — measured as 10 failing cases across five
|
|
181
|
+
* forms in a consumer, in both the populated and the empty state. A screen
|
|
182
|
+
* reader following the reference resolved it to nothing.
|
|
183
|
+
*
|
|
184
|
+
* ⛔ AND NOT "KEEP EVERYTHING MOUNTED", which is the obvious reading of the
|
|
185
|
+
* fix and is too expensive. Only the LIST carries the id; the options carry
|
|
186
|
+
* the cost. One consumer form puts up to ten of these on screen, each holding
|
|
187
|
+
* a page of up to a hundred options — roughly a thousand permanently present
|
|
188
|
+
* nodes for an id that is one element. `{open ? children : null}` keeps the
|
|
189
|
+
* reference resolvable and the DOM the size it was.
|
|
190
|
+
*
|
|
191
|
+
* ⚠️ `hidden` AND NOT A CLASS. It removes the subtree from the accessibility
|
|
192
|
+
* tree as well as from view, so a closed panel is not an empty `listbox` that
|
|
193
|
+
* a screen reader can reach into.
|
|
194
|
+
*
|
|
195
|
+
* ⚠️ THE ENTRY ANIMATION IS NOT LOST, because there was none to lose: the
|
|
196
|
+
* className carries `animate-in` with no `fade-in-*` / `zoom-in-*` / `slide-in-*`
|
|
197
|
+
* companion, so every `--tw-enter-*` variable sits at its default and the
|
|
198
|
+
* keyframe is a no-op today. Should a real one be added later, it belongs on a
|
|
199
|
+
* wrapper INSIDE this list — that subtree still mounts with the children.
|
|
200
|
+
*/
|
|
201
|
+
return (_jsx("div", { className: "relative", hidden: !open, children: _jsx(CommandPrimitive.List, { ref: _ref, className: cn('bg-popover text-popover-foreground animate-in absolute top-1 z-50 max-h-96 w-full min-w-32 overflow-x-hidden overflow-y-auto rounded-md border shadow-md outline-hidden', position === 'popper' &&
|
|
166
202
|
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', className), "data-side": side, ...props, onMouseEnter: (e) => {
|
|
167
203
|
onMouseEnter?.(e);
|
|
168
204
|
setOnScrollbar(true);
|
|
169
205
|
}, onMouseLeave: (e) => {
|
|
170
206
|
onMouseLeave?.(e);
|
|
171
207
|
setOnScrollbar(false);
|
|
172
|
-
}, children: children }) }));
|
|
208
|
+
}, children: open ? children : null }) }));
|
|
173
209
|
}
|
|
174
210
|
export function AutocompleteGroup({ className, ...props }) {
|
|
175
211
|
return (_jsx(CommandPrimitive.Group, { "data-slot": "autocomplete-group", className: cn('text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium', className), ...props }));
|