@setsquare/ui 0.7.0 → 0.8.0
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 +44 -0
- package/README.md +5 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/keyshortcuts.d.ts +13 -0
- package/dist/lib/keyshortcuts.d.ts.map +1 -0
- package/dist/lib/keyshortcuts.js +21 -0
- package/dist/lib/keyshortcuts.js.map +1 -0
- package/dist/lib/search-match.d.ts +31 -0
- package/dist/lib/search-match.d.ts.map +1 -0
- package/dist/lib/search-match.js +82 -0
- package/dist/lib/search-match.js.map +1 -0
- package/dist/lib/search-shortcut.d.ts +16 -0
- package/dist/lib/search-shortcut.d.ts.map +1 -0
- package/dist/lib/search-shortcut.js +49 -0
- package/dist/lib/search-shortcut.js.map +1 -0
- package/dist/ui/button.d.ts +3 -2
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +7 -4
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/search.d.ts +19 -3
- package/dist/ui/search.d.ts.map +1 -1
- package/dist/ui/search.js +55 -23
- package/dist/ui/search.js.map +1 -1
- package/dist/ui/tree.d.ts +5 -3
- package/dist/ui/tree.d.ts.map +1 -1
- package/dist/ui/tree.js +4 -2
- package/dist/ui/tree.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0 — 2026-10-14
|
|
4
|
+
|
|
5
|
+
- **Search finds items by words that aren't in their label.** `SearchItem` takes `keywords?: string[]`: what people
|
|
6
|
+
call an item rather than its name, so "mp4" or "export" finds "Render the whole video (MP4)". Keywords are matched
|
|
7
|
+
as well as the label, in `AppSearch` and `CommandSearch` alike, and are never shown or made part of the item's
|
|
8
|
+
accessible name. An item without keywords is matched on its label, as before.
|
|
9
|
+
- **A query of several words matches when every word appears**, in the label or the keywords, in any order: "video
|
|
10
|
+
render", "render video" and "render mp4" all find that item. Before, the whole query had to appear in the label as
|
|
11
|
+
typed. Matching is still the locale's, ignoring case and accents (`Intl.Collator` with `sensitivity: 'base'`, as
|
|
12
|
+
`useFilter` was).
|
|
13
|
+
- **Results are ranked within each section.** An item with the words in its label comes before one found through its
|
|
14
|
+
keywords, and one where they start a word before one where they are inside a word; otherwise items keep the order
|
|
15
|
+
given. This can reorder results for items without keywords too: "port" now lists "Portal" before "Import". Sections
|
|
16
|
+
keep their order, and the empty state shows when nothing matches. React Aria's `Autocomplete` can only filter, not
|
|
17
|
+
reorder, so the dialog now holds the field's text and gives the menu the ranked items; `Autocomplete` still moves
|
|
18
|
+
through them from the field, and points it at the first result as you type.
|
|
19
|
+
- **⌘K / Ctrl+K is left alone where something else wants it.** `AppSearch` used to take the key everywhere. It now
|
|
20
|
+
leaves it to a text field, text area or editor being typed in (Ctrl+K deletes to the end of the line on macOS and
|
|
21
|
+
inserts a link in most editors), to a handler that already took it (`preventDefault`), to ⌘⇧K and ⌘⌥K, and to an
|
|
22
|
+
input method composing.
|
|
23
|
+
- **One search on a page has the shortcut.** With two `AppSearch` on a page, ⌘K opened both. Now the first mounted
|
|
24
|
+
that asks has it, which is usually the layout's; when it unmounts, the next takes over. `shortcut={false}` gives it
|
|
25
|
+
up. Only the one with the shortcut shows ⌘K and sets `aria-keyshortcuts`; `SearchTrigger` takes `shortcut` too.
|
|
26
|
+
- **Fix: `aria-keyshortcuts` reaches the element.** React Aria's components pass only the DOM attributes they know,
|
|
27
|
+
and dropped `aria-keyshortcuts`, so it never reached the page: not on the search's trigger, though its README said
|
|
28
|
+
so, nor from a product that passed it. `Button`, `IconButton`, `LinkButton` and `Tree` now take it
|
|
29
|
+
(`KeyshortcutsProps`) and set it on their element after rendering, so it isn't in the server's HTML. This also fixes
|
|
30
|
+
`@setsquare/ui-blocks`, whose Undo and Redo buttons and outline pass it: theirs reach the page from this version on.
|
|
31
|
+
A `ref` given to `Button`, `IconButton` or `LinkButton` still gets the element, now through `useImperativeHandle`.
|
|
32
|
+
- **An item `id` used twice is a console error.** React Aria keys the search's menu by id across all its sections, so
|
|
33
|
+
a repeated one showed the first item twice and hid the other, silently. `CommandSearch` now logs the ids.
|
|
34
|
+
- **Docs.** The AppSearch page's example and the design-system demo's search have keywords. The README says how
|
|
35
|
+
matching and ranking work, and what a product has to get right: unique ids, what a server component can pass,
|
|
36
|
+
the router, the locale, the shortcut, and the sizes checked.
|
|
37
|
+
- **Tests.** Unit tests for the matching (several words in any order, accents, the locale's collation, keyword-only
|
|
38
|
+
matches after label matches, word starts before the middle of words, sections) and browser checks in the dashboard
|
|
39
|
+
shell's search: a keyword finding an item named by its label alone, the ranked order with the field pointing at the
|
|
40
|
+
first result (`aria-activedescendant`), words in any order, and the empty state. Unit tests for the shortcut's
|
|
41
|
+
rules and the duplicate ids. `test/browser/search.mjs` drives the shortcut in Chromium: what opens on ⌘K and Ctrl+K
|
|
42
|
+
and what is left alone, two searches on a page, `shortcut={false}`, `aria-keyshortcuts` on both triggers and on
|
|
43
|
+
`Button`, `IconButton`, `LinkButton` and `Tree` (set, and taken off), and the console error. `blocks-shortcuts`
|
|
44
|
+
checks the builder's Undo, Redo and outline say their keys. `package:verify` renders a search from a server component in a Next.js app, with `href` items,
|
|
45
|
+
element icons and keywords, and checks Ctrl+K opens it and a keyword finds its link.
|
|
46
|
+
|
|
3
47
|
## 0.7.0 — 2026-10-13
|
|
4
48
|
|
|
5
49
|
- **`Rail`, new: layout option C's navigation.** A full-height rail, `--rail-width` wide (72px at AA, 88px at AAA),
|
package/README.md
CHANGED
|
@@ -344,12 +344,13 @@ The positioning, target, link, reflow, text-spacing and motion scans run in the
|
|
|
344
344
|
|
|
345
345
|
- **Types:** `tsc` on React 19.
|
|
346
346
|
- **Lint rules:** ESLint's `RuleTester`, and oxlint loading the built plugin through `jsPlugins`.
|
|
347
|
-
- **Unit:** the pagination window: seven slots on every page of an 8-, 20- and 239-page list, and a gap only where two or more pages are left out. The `Rail` and `AppHeader` as the server renders them: with `navigation="rail"`, no collapse toggle and no rule, only the phone's trigger (hidden by a container query until the shell measures, absent at a forced size wider than a phone), and the rail's words over the sidebar's app-wide ones. Live status on `SidebarItem` and `RailItem`: the status label, detail and warning words in the name (after a count), the badges hidden from it, a type error for `status` without `statusLabel`, a custom drawing as the icon, and the collapsed sidebar's tooltip in English and in a product's words.
|
|
347
|
+
- **Unit:** the pagination window: seven slots on every page of an 8-, 20- and 239-page list, and a gap only where two or more pages are left out. The `Rail` and `AppHeader` as the server renders them: with `navigation="rail"`, no collapse toggle and no rule, only the phone's trigger (hidden by a container query until the shell measures, absent at a forced size wider than a phone), and the rail's words over the sidebar's app-wide ones. Live status on `SidebarItem` and `RailItem`: the status label, detail and warning words in the name (after a count), the badges hidden from it, a type error for `status` without `statusLabel`, a custom drawing as the icon, and the collapsed sidebar's tooltip in English and in a product's words. The search's matching: every word of a query in the label or keywords in any order, case and accents ignored by the locale's collation, keyword-only matches after label matches and word starts before the middle of words, within each section. Its shortcut's rules (what counts as ⌘K / Ctrl+K, a field or editor keeping it, the first search to ask having it) and its check for an item id used twice.
|
|
348
348
|
- **Words:** a lint rule of this repository's (`scripts/lint/words.mjs`) fails English written into the components' JSX, a template that builds a sentence, a list joined in code, and `Intl` formatting in the runtime's locale; its tests fail each way 0.5.0 did it. Unit tests cover the ICU formatter, its development and production fallbacks, `SetsquareLocale`'s layering, and every count label in Polish (one, few, many).
|
|
349
349
|
- **Contrast:** `scripts/check-contrast.mjs` computes every token pair the usage notes promise, in all four themes. It doesn't check colours a product adds.
|
|
350
350
|
- **Browser (Chromium only):** the design-system previews on React 19, loaded as the design-system artifact loads them:
|
|
351
351
|
- axe-core on every preview in all four themes;
|
|
352
|
-
-
|
|
352
|
+
- the search's ⌘K / Ctrl+K on a page of its own: left to text fields, text areas, editors and a handler that took the key; one search on a page holding it, showing it and setting `aria-keyshortcuts`, and the next taking over; `shortcut={false}`; the console error for an item id used twice; and `aria-keyshortcuts` reaching the element through `Button`, `IconButton`, `LinkButton` and `Tree`, which React Aria's own components drop, and the page builder's Undo, Redo and outline saying their keys;
|
|
353
|
+
- keyboard and focus behaviour for the dashboard shell (with its search finding by keyword, in ranked order), forms, feedback states, and the slider, date, file and selection controls;
|
|
353
354
|
- the site shell: the phone menu opening, pushing the page down and closing on Escape from the panel or the button; the current page's weight and marker; one order for the header, the phone menu and the footer; a sticky header covering no focused control; and the header fitting at seven widths from 320px to 1280px, either side of `lg` among them;
|
|
354
355
|
- the motion rule on the Hero card's media: the motion check exempts it only for its visible pause control, Pause stops it, reduced motion never starts it, and nothing waits hidden for it;
|
|
355
356
|
- code blocks copying, announcing a second copy, a terminal copying its commands only, and a refused copy; the theme switcher's choice, System following the operating system, the level, and the theme script running under a CSP that allows only its published hash;
|
|
@@ -368,8 +369,8 @@ The positioning, target, link, reflow, text-spacing and motion scans run in the
|
|
|
368
369
|
- nothing on any preview running off its width, no text cut off or spilling with WCAG 1.4.12's spacing applied, and nothing but a loading indicator moving past five seconds, at AA and AAA;
|
|
369
370
|
- every preview inside `SetsquareLocale` at `locale="ar"` with every word pseudo-translated, failing on any of the package's English left in text, hidden text or names, with a control run that leaves the words in English and has to find them. It reads what a card shows as it loads, not what it shows after it's used;
|
|
370
371
|
- the page checks above, each also run on a page built to fail.
|
|
371
|
-
- **Packaging:** `pnpm package:verify` packs the tarball and installs it into a new Next.js app. It builds the app, loads it in both levels, and runs the page checks and the lint plugin from the installed package. It also follows a sidebar link on the freshly started app, to check the templates' page transition runs with its `nav-forward` type. The root layout's `ThemeScript` is checked to put a stored dark theme on `<html>` before any of the page's own JavaScript runs, and the footer's `ThemeSwitcher` to change it for the next page load. A route on the site templates is checked too: the current page, reflow at 320px, the Menu as a link to the footer's navigation with JavaScript off, and the swap to the Menu button when the page hydrates, in the same place and keeping focus. `@setsquare/ui-blocks`' `ContentBuilder` is rendered from a Next.js page and checked to hydrate with no console errors, with the browser on a different platform from the server's.
|
|
372
|
-
- **The docs site** (`apps/docs`): `pnpm test:site` loads every page of its production build in all four themes at 1280px, and at AA and AAA at 390px (and each component the Playground shows). Each run has axe, positioning, targets, underlined links, sideways overflow and console errors. The dark run puts the browser on a different platform from the server's (Windows beside a Mac server, a Mac beside any other), so anything rendered differently on the two shows up as a hydration error. Visible focus runs in three of them (light, dark AAA and 390px AAA: both themes, both levels, both layouts) and cursors in three (light, light AAA and 390px AAA), and both check the sidebar and header, which are the same on every page, on the home page only; a check fails if that selector ever leaves out a control in a page's content. It also fails on console errors, sideways overflow, and any internal link to a page it doesn't check, and it follows a sidebar link, in Chromium and in WebKit, to check that the navigation stays client-side, runs the page transition, and covers the old page while it leaves. It also tries a shadcn/ui theme from the Playground: that it reaches every page, lasts through a reload without a flash, resets, and that a paste can set nothing but valid token values. The findings it accepts are listed in `test/site/pages.mjs`, each with its reason. The site brings its own palette, so its build runs the contrast audit against those colours.
|
|
372
|
+
- **Packaging:** `pnpm package:verify` packs the tarball and installs it into a new Next.js app. It builds the app, loads it in both levels, and runs the page checks and the lint plugin from the installed package. It also follows a sidebar link on the freshly started app, to check the templates' page transition runs with its `nav-forward` type. An `AppSearch` rendered from a server component, with `href` items, element icons and keywords, is checked to open on Ctrl+K and find its link by a keyword. The root layout's `ThemeScript` is checked to put a stored dark theme on `<html>` before any of the page's own JavaScript runs, and the footer's `ThemeSwitcher` to change it for the next page load. A route on the site templates is checked too: the current page, reflow at 320px, the Menu as a link to the footer's navigation with JavaScript off, and the swap to the Menu button when the page hydrates, in the same place and keeping focus. `@setsquare/ui-blocks`' `ContentBuilder` is rendered from a Next.js page and checked to hydrate with no console errors, with the browser on a different platform from the server's.
|
|
373
|
+
- **The docs site** (`apps/docs`): `pnpm test:site` loads every page of its production build in all four themes at 1280px, and at AA and AAA at 390px (and each component the Playground shows). Each run has axe, positioning, targets, underlined links, sideways overflow and console errors. The dark run puts the browser on a different platform from the server's (Windows beside a Mac server, a Mac beside any other), so anything rendered differently on the two shows up as a hydration error. Visible focus runs in three of them (light, dark AAA and 390px AAA: both themes, both levels, both layouts) and cursors in three (light, light AAA and 390px AAA), and both check the sidebar and header, which are the same on every page, on the home page only; a check fails if that selector ever leaves out a control in a page's content. It also fails on console errors, sideways overflow, and any internal link to a page it doesn't check, and it follows a sidebar link, in Chromium and in WebKit, to check that the navigation stays client-side, runs the page transition, and covers the old page while it leaves. It also tries a shadcn/ui theme from the Playground: that it reaches every page, lasts through a reload without a flash, resets, and that a paste can set nothing but valid token values. It searches from the header by keyword ("modal" finds Dialog, "tap target" finds `--target-min`) and by names read from the repository (`ConfirmDialog`, a page's heading, a lint rule, a page check). The site's build fails if a page, component or token search lists has no keywords in `apps/docs/lib/search-keywords.ts`, if keywords are left for one that's gone, or if anything `@setsquare/ui` exports finds nothing. The findings it accepts are listed in `test/site/pages.mjs`, each with its reason. The site brings its own palette, so its build runs the contrast audit against those colours.
|
|
373
374
|
- **Not tested:** other browsers; real screen readers (VoiceOver, NVDA and JAWS haven't been run on these components); Windows High Contrast; pasting files into the drop zone; everything that depends on a product's content.
|
|
374
375
|
|
|
375
376
|
## Developing
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type { SetsquareLocaleProps, SetsquareLabels } from './lib/locale.js';
|
|
|
11
11
|
export { useElementWidth } from './lib/use-element-width.js';
|
|
12
12
|
export { Button, LinkButton } from './ui/button.js';
|
|
13
13
|
export type { ButtonProps, LinkButtonProps } from './ui/button.js';
|
|
14
|
+
export type { KeyshortcutsProps } from './lib/keyshortcuts.js';
|
|
14
15
|
export { buttonTargetStyles, buttonVisualStyles } from './ui/button-styles.js';
|
|
15
16
|
export type { ButtonVariant, ButtonVisualSize } from './ui/button-styles.js';
|
|
16
17
|
export { TextLink } from './ui/text-link.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":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,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGpD,yFAAyF;AACzF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO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AAE,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Ref, type RefObject } from 'react';
|
|
2
|
+
/** `aria-keyshortcuts`, as a prop this package's components take and pass on. */
|
|
3
|
+
export interface KeyshortcutsProps {
|
|
4
|
+
/** The keys that press or move to it, in ARIA's form: "Meta+K Control+K". Set on the element. */
|
|
5
|
+
'aria-keyshortcuts'?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* React Aria's components pass only the DOM attributes they know, and drop `aria-keyshortcuts`. Give the component
|
|
9
|
+
* the ref this returns: the attribute is set on its element (or taken off when `keys` is empty) after each render,
|
|
10
|
+
* and the element is handed on to `ref`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useKeyshortcuts<T extends Element>(keys: string | undefined, ref?: Ref<T>): RefObject<T | null>;
|
|
13
|
+
//# sourceMappingURL=keyshortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyshortcuts.d.ts","sourceRoot":"","sources":["../../src/lib/keyshortcuts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgD,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/F,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,iGAAiG;IACjG,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAC/C,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GACX,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CASrB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useImperativeHandle, useLayoutEffect, useRef } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* React Aria's components pass only the DOM attributes they know, and drop `aria-keyshortcuts`. Give the component
|
|
5
|
+
* the ref this returns: the attribute is set on its element (or taken off when `keys` is empty) after each render,
|
|
6
|
+
* and the element is handed on to `ref`.
|
|
7
|
+
*/
|
|
8
|
+
export function useKeyshortcuts(keys, ref) {
|
|
9
|
+
const element = useRef(null);
|
|
10
|
+
useImperativeHandle(ref, () => element.current);
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
if (!element.current)
|
|
13
|
+
return;
|
|
14
|
+
if (keys)
|
|
15
|
+
element.current.setAttribute('aria-keyshortcuts', keys);
|
|
16
|
+
else
|
|
17
|
+
element.current.removeAttribute('aria-keyshortcuts');
|
|
18
|
+
});
|
|
19
|
+
return element;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=keyshortcuts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyshortcuts.js","sourceRoot":"","sources":["../../src/lib/keyshortcuts.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAA4B,MAAM,OAAO,CAAC;AAQ/F;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAwB,EACxB,GAAY;IAEZ,MAAM,OAAO,GAAG,MAAM,CAAI,IAAI,CAAC,CAAC;IAChC,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAY,CAAC,CAAC;IACrD,eAAe,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO;QAC7B,IAAI,IAAI;YAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;;YAC7D,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SearchItem, SearchSection } from '../ui/search.js';
|
|
2
|
+
/**
|
|
3
|
+
* The collator search matches with: the locale's, ignoring case and accents. The same options as React Aria's
|
|
4
|
+
* `useFilter({ sensitivity: 'base' })`, which the search used before it ranked.
|
|
5
|
+
*/
|
|
6
|
+
export declare const searchCollator: (locale: string) => Intl.Collator;
|
|
7
|
+
/** How an item matched a query, or null if it didn't. Lower sorts first, compared in this order. */
|
|
8
|
+
export interface SearchRank {
|
|
9
|
+
/** The query's words found only in the keywords, not the label. */
|
|
10
|
+
inKeywords: number;
|
|
11
|
+
/** The query's words found only in the middle of a word. */
|
|
12
|
+
midWord: number;
|
|
13
|
+
}
|
|
14
|
+
/** The query's words: split on white space, so their order doesn't matter. */
|
|
15
|
+
export declare const searchWords: (query: string) => string[];
|
|
16
|
+
/**
|
|
17
|
+
* Every word must appear in the label or a keyword. A word counts where it is found best: in the label before
|
|
18
|
+
* the keywords, and at the start of a word before the middle of one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function rankSearchItem(item: Pick<SearchItem, 'label' | 'keywords'>, words: string[], collator: Intl.Collator): SearchRank | null;
|
|
21
|
+
/**
|
|
22
|
+
* The sections with only the items that match, best first within each section and otherwise in their given
|
|
23
|
+
* order. Sections keep their order, and one with nothing left is dropped. An empty query keeps everything.
|
|
24
|
+
*/
|
|
25
|
+
export declare function searchSections(sections: SearchSection[], query: string, collator: Intl.Collator): SearchSection[];
|
|
26
|
+
/**
|
|
27
|
+
* Item ids used more than once across all the sections. React Aria keys the whole menu by id, so a repeated one
|
|
28
|
+
* shows the first item in the second's place and hides the second.
|
|
29
|
+
*/
|
|
30
|
+
export declare function duplicateIds(sections: SearchSection[]): string[];
|
|
31
|
+
//# sourceMappingURL=search-match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-match.d.ts","sourceRoot":"","sources":["../../src/lib/search-match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,KAAG,IAAI,CAAC,QACgB,CAAC;AAkBtE,oGAAoG;AACpG,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8EAA8E;AAC9E,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAAM,EACW,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,EAC5C,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACtB,UAAU,GAAG,IAAI,CAoBnB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,aAAa,EAAE,EACzB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACtB,aAAa,EAAE,CAgBjB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAMhE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The collator search matches with: the locale's, ignoring case and accents. The same options as React Aria's
|
|
3
|
+
* `useFilter({ sensitivity: 'base' })`, which the search used before it ranked.
|
|
4
|
+
*/
|
|
5
|
+
export const searchCollator = (locale) => new Intl.Collator(locale, { usage: 'search', sensitivity: 'base' });
|
|
6
|
+
/** A letter, digit or mark before a match puts it in the middle of a word. */
|
|
7
|
+
const WORD_CHARACTER = /[\p{L}\p{N}\p{M}]/u;
|
|
8
|
+
/** Where `word` first appears in `text` at the start of a word, else anywhere, else null. Both already NFC. */
|
|
9
|
+
function find(text, word, collator) {
|
|
10
|
+
let found = null;
|
|
11
|
+
for (let at = 0; at + word.length <= text.length; at++) {
|
|
12
|
+
if (collator.compare(text.slice(at, at + word.length), word) !== 0)
|
|
13
|
+
continue;
|
|
14
|
+
if (at === 0 || !WORD_CHARACTER.test(text.charAt(at - 1)))
|
|
15
|
+
return 'start';
|
|
16
|
+
found = 'middle';
|
|
17
|
+
}
|
|
18
|
+
return found;
|
|
19
|
+
}
|
|
20
|
+
/** The query's words: split on white space, so their order doesn't matter. */
|
|
21
|
+
export const searchWords = (query) => query.normalize('NFC').trim().split(/\s+/u).filter(Boolean);
|
|
22
|
+
/**
|
|
23
|
+
* Every word must appear in the label or a keyword. A word counts where it is found best: in the label before
|
|
24
|
+
* the keywords, and at the start of a word before the middle of one.
|
|
25
|
+
*/
|
|
26
|
+
export function rankSearchItem(item, words, collator) {
|
|
27
|
+
const label = item.label.normalize('NFC');
|
|
28
|
+
const keywords = item.keywords?.map((k) => k.normalize('NFC')) ?? [];
|
|
29
|
+
const rank = { inKeywords: 0, midWord: 0 };
|
|
30
|
+
for (const word of words) {
|
|
31
|
+
const inLabel = find(label, word, collator);
|
|
32
|
+
if (inLabel) {
|
|
33
|
+
if (inLabel === 'middle')
|
|
34
|
+
rank.midWord++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
let inKeyword = null;
|
|
38
|
+
for (const keyword of keywords) {
|
|
39
|
+
inKeyword = find(keyword, word, collator) ?? inKeyword;
|
|
40
|
+
if (inKeyword === 'start')
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
if (!inKeyword)
|
|
44
|
+
return null;
|
|
45
|
+
rank.inKeywords++;
|
|
46
|
+
if (inKeyword === 'middle')
|
|
47
|
+
rank.midWord++;
|
|
48
|
+
}
|
|
49
|
+
return rank;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The sections with only the items that match, best first within each section and otherwise in their given
|
|
53
|
+
* order. Sections keep their order, and one with nothing left is dropped. An empty query keeps everything.
|
|
54
|
+
*/
|
|
55
|
+
export function searchSections(sections, query, collator) {
|
|
56
|
+
const words = searchWords(query);
|
|
57
|
+
if (words.length === 0)
|
|
58
|
+
return sections;
|
|
59
|
+
return sections.flatMap((section) => {
|
|
60
|
+
const items = section.items
|
|
61
|
+
.map((item, index) => ({ item, index, rank: rankSearchItem(item, words, collator) }))
|
|
62
|
+
.filter((m) => m.rank !== null)
|
|
63
|
+
.sort((a, b) => a.rank.inKeywords - b.rank.inKeywords ||
|
|
64
|
+
a.rank.midWord - b.rank.midWord ||
|
|
65
|
+
a.index - b.index)
|
|
66
|
+
.map((m) => m.item);
|
|
67
|
+
return items.length > 0 ? [{ ...section, items }] : [];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Item ids used more than once across all the sections. React Aria keys the whole menu by id, so a repeated one
|
|
72
|
+
* shows the first item in the second's place and hides the second.
|
|
73
|
+
*/
|
|
74
|
+
export function duplicateIds(sections) {
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
const repeated = new Set();
|
|
77
|
+
for (const { items } of sections)
|
|
78
|
+
for (const { id } of items)
|
|
79
|
+
(seen.has(id) ? repeated : seen).add(id);
|
|
80
|
+
return [...repeated];
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=search-match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-match.js","sourceRoot":"","sources":["../../src/lib/search-match.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAiB,EAAE,CAC9D,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAItE,8EAA8E;AAC9E,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAE5C,+GAA+G;AAC/G,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,QAAuB;IAC/D,IAAI,KAAK,GAAU,IAAI,CAAC;IACxB,KAAK,IAAI,EAAE,GAAG,CAAC,E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G,CAAC,CAAC,IAAI,CAAC,OAAO;YAC/B,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CACpB;aACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,QAAyB;IACpD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,QAAQ;QAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,IAAI,KAAK;YAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⌘K / Ctrl+K for `AppSearch`. One search on a page has the shortcut: the first mounted that asks for it, usually
|
|
3
|
+
* the layout's, which outlives the pages under it. The key is left alone when something else wants it: a handler
|
|
4
|
+
* that already took it (`preventDefault`), a field or editor being typed in (Ctrl+K deletes to the end of the line
|
|
5
|
+
* in a macOS text field, and inserts a link in most editors), or an input method composing.
|
|
6
|
+
*/
|
|
7
|
+
/** Asks for the shortcut; the first to ask has it until it lets go. Returns the letting go. */
|
|
8
|
+
export declare function claimSearchShortcut(id: string): () => void;
|
|
9
|
+
export declare const subscribeSearchShortcut: (listener: () => void) => () => void;
|
|
10
|
+
/** Whether `id` has the shortcut. Before anything has asked (the first render), each one that will ask has it. */
|
|
11
|
+
export declare const hasSearchShortcut: (id: string) => boolean;
|
|
12
|
+
/** A field or editor that takes typing, where Ctrl+K and ⌘K may already mean something. */
|
|
13
|
+
export declare function isTextEntry(target: EventTarget | null): boolean;
|
|
14
|
+
/** ⌘K or Ctrl+K, alone, that nothing else has claimed. */
|
|
15
|
+
export declare function isSearchShortcut(e: KeyboardEvent): boolean;
|
|
16
|
+
//# sourceMappingURL=search-shortcut.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-shortcut.d.ts","sourceRoot":"","sources":["../../src/lib/search-shortcut.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,IAAI,CAQ1D;AAED,eAAO,MAAM,uBAAuB,aAAc,MAAM,IAAI,eAK3D,CAAC;AAEF,kHAAkH;AAClH,eAAO,MAAM,iBAAiB,OAAQ,MAAM,YAA4C,CAAC;AAIzF,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAK/D;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAU1D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⌘K / Ctrl+K for `AppSearch`. One search on a page has the shortcut: the first mounted that asks for it, usually
|
|
3
|
+
* the layout's, which outlives the pages under it. The key is left alone when something else wants it: a handler
|
|
4
|
+
* that already took it (`preventDefault`), a field or editor being typed in (Ctrl+K deletes to the end of the line
|
|
5
|
+
* in a macOS text field, and inserts a link in most editors), or an input method composing.
|
|
6
|
+
*/
|
|
7
|
+
const owners = [];
|
|
8
|
+
const listeners = new Set();
|
|
9
|
+
const notify = () => listeners.forEach((l) => l());
|
|
10
|
+
/** Asks for the shortcut; the first to ask has it until it lets go. Returns the letting go. */
|
|
11
|
+
export function claimSearchShortcut(id) {
|
|
12
|
+
owners.push(id);
|
|
13
|
+
notify();
|
|
14
|
+
return () => {
|
|
15
|
+
const at = owners.indexOf(id);
|
|
16
|
+
if (at >= 0)
|
|
17
|
+
owners.splice(at, 1);
|
|
18
|
+
notify();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const subscribeSearchShortcut = (listener) => {
|
|
22
|
+
listeners.add(listener);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** Whether `id` has the shortcut. Before anything has asked (the first render), each one that will ask has it. */
|
|
28
|
+
export const hasSearchShortcut = (id) => owners.length === 0 || owners[0] === id;
|
|
29
|
+
const TEXT_INPUT = new Set(['text', 'search', 'email', 'url', 'tel', 'password', 'number']);
|
|
30
|
+
/** A field or editor that takes typing, where Ctrl+K and ⌘K may already mean something. */
|
|
31
|
+
export function isTextEntry(target) {
|
|
32
|
+
if (!target || typeof target.tagName !== 'string')
|
|
33
|
+
return false;
|
|
34
|
+
const el = target;
|
|
35
|
+
if (el.isContentEditable || el.tagName === 'TEXTAREA')
|
|
36
|
+
return true;
|
|
37
|
+
return el.tagName === 'INPUT' && TEXT_INPUT.has(el.type);
|
|
38
|
+
}
|
|
39
|
+
/** ⌘K or Ctrl+K, alone, that nothing else has claimed. */
|
|
40
|
+
export function isSearchShortcut(e) {
|
|
41
|
+
return ((e.metaKey || e.ctrlKey) &&
|
|
42
|
+
!e.altKey &&
|
|
43
|
+
!e.shiftKey &&
|
|
44
|
+
e.key.toLowerCase() === 'k' &&
|
|
45
|
+
!e.defaultPrevented &&
|
|
46
|
+
!e.isComposing &&
|
|
47
|
+
!isTextEntry(e.composedPath?.()[0] ?? e.target));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=search-shortcut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-short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IAAI,CAAC,MAAM,IAAI,OAAQ,MAAkB,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7E,MAAM,EAAE,GAAG,MAAqB,CAAC;IACjC,IAAI,EAAE,CAAC,iBAAiB,IAAI,EAAE,CAAC,OAAO,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,EAAE,CAAC,OAAO,KAAK,OAAO,IAAI,UAAU,CAAC,GAAG,CAAE,EAAuB,CAAC,IAAI,CAAC,CAAC;AACjF,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,CAAgB;IAC/C,OAAO,CACL,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC,CAAC,MAAM;QACT,CAAC,CAAC,CAAC,QAAQ;QACX,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,GAAG;QAC3B,CAAC,CAAC,CAAC,gBAAgB;QACnB,CAAC,CAAC,CAAC,WAAW;QACd,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAChD,CAAC;AACJ,CAAC"}
|
package/dist/ui/button.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { composeRenderProps, type ButtonProps as RACButtonProps, type LinkProps as RACLinkProps } from 'react-aria-components';
|
|
2
2
|
import { type ButtonVariant, type ButtonVisualSize } from './button-styles.js';
|
|
3
|
+
import { type KeyshortcutsProps } from '../lib/keyshortcuts.js';
|
|
3
4
|
export type { ButtonVariant, ButtonVisualSize };
|
|
4
5
|
interface LayerProps {
|
|
5
6
|
variant?: ButtonVariant;
|
|
@@ -12,14 +13,14 @@ interface LayerProps {
|
|
|
12
13
|
/** Layer 2, the painted box. */
|
|
13
14
|
visualClassName?: string;
|
|
14
15
|
}
|
|
15
|
-
export interface ButtonProps extends Omit<RACButtonProps, 'className'>, LayerProps {
|
|
16
|
+
export interface ButtonProps extends Omit<RACButtonProps, 'className'>, LayerProps, KeyshortcutsProps {
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* React Aria Button. One `primary` per view; `outline` is the default.
|
|
19
20
|
* `isPending` keeps it focusable, announces the wait and swaps any leading icon for a spinner.
|
|
20
21
|
*/
|
|
21
22
|
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
22
|
-
export interface LinkButtonProps extends Omit<RACLinkProps, 'className'>, LayerProps {
|
|
23
|
+
export interface LinkButtonProps extends Omit<RACLinkProps, 'className'>, LayerProps, KeyshortcutsProps {
|
|
23
24
|
}
|
|
24
25
|
/** A link that looks like a button — for navigation, never for actions. Same three layers as Button. */
|
|
25
26
|
export declare const LinkButton: import("react").ForwardRefExoticComponent<LinkButtonProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
package/dist/ui/button.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAClB,KAAK,WAAW,IAAI,cAAc,EAClC,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,kBAAkB,EAClB,KAAK,WAAW,IAAI,cAAc,EAClC,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC;AAEhD,UAAU,UAAU;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,mGAAmG;IACnG,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,oDAAoD;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,iBAAiB;CAAG;AAE7E;;;GAGG;AACH,eAAO,MAAM,MAAM,2GAsCjB,CAAC;AAEH,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,iBAAiB;CAAG;AAE3E,wGAAwG;AACxG,eAAO,MAAM,UAAU,+GA8BrB,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/ui/button.js
CHANGED
|
@@ -4,13 +4,15 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { Button as RACButton, Link as RACLink, composeRenderProps, } from 'react-aria-components';
|
|
5
5
|
import { buttonTargetStyles, buttonVisualStyles, } from './button-styles.js';
|
|
6
6
|
import { SpinnerIcon } from './spinner.js';
|
|
7
|
+
import { useKeyshortcuts } from '../lib/keyshortcuts.js';
|
|
7
8
|
/**
|
|
8
9
|
* React Aria Button. One `primary` per view; `outline` is the default.
|
|
9
10
|
* `isPending` keeps it focusable, announces the wait and swaps any leading icon for a spinner.
|
|
10
11
|
*/
|
|
11
|
-
export const Button = forwardRef(function Button({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, ...props }, ref) {
|
|
12
|
+
export const Button = forwardRef(function Button({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, 'aria-keyshortcuts': keys, ...props }, ref) {
|
|
12
13
|
const iconOnly = visualSize === 'icon' || visualSize === 'icon-sm';
|
|
13
|
-
|
|
14
|
+
const target = useKeyshortcuts(keys, ref);
|
|
15
|
+
return (_jsx(RACButton, { ref: target, ...props, className: buttonTargetStyles({ fullWidth, className }), children: composeRenderProps(children, (kids, { isPending }) => (_jsx("span", { className: buttonVisualStyles({
|
|
14
16
|
variant,
|
|
15
17
|
visualSize,
|
|
16
18
|
fullWidth,
|
|
@@ -18,8 +20,9 @@ export const Button = forwardRef(function Button({ variant = 'outline', visualSi
|
|
|
18
20
|
}), children: isPending && iconOnly ? (_jsx(SpinnerIcon, {})) : (_jsxs(_Fragment, { children: [isPending && _jsx(SpinnerIcon, {}), kids] })) }))) }));
|
|
19
21
|
});
|
|
20
22
|
/** A link that looks like a button — for navigation, never for actions. Same three layers as Button. */
|
|
21
|
-
export const LinkButton = forwardRef(function LinkButton({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, ...props }, ref) {
|
|
22
|
-
|
|
23
|
+
export const LinkButton = forwardRef(function LinkButton({ variant = 'outline', visualSize = 'default', fullWidth, className, visualClassName, children, 'aria-keyshortcuts': keys, ...props }, ref) {
|
|
24
|
+
const target = useKeyshortcuts(keys, ref);
|
|
25
|
+
return (_jsx(RACLink, { ref: target, ...props, className: buttonTargetStyles({ fullWidth, className }), children: composeRenderProps(children, (kids) => (_jsx("span", { className: buttonVisualStyles({
|
|
23
26
|
variant,
|
|
24
27
|
visualSize,
|
|
25
28
|
fullWidth,
|
package/dist/ui/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/ui/button.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,IAAI,IAAI,OAAO,EACf,kBAAkB,GAGnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO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AED,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,CACvB,KAAC,WAAW,KAAG,CAChB,CAAC,CAAC,CAAC,CACF,8BACG,SAAS,IAAI,KAAC,WAAW,KAAG,EAC5B,IAAI,IACJ,CACJ,GACI,CACR,CAAC,GACQ,CACb,CAAC;AACJ,CAAC,CAAC,CAAC;AAKH,wGAAwG;AACxG,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAqC,SAAS,UAAU,CAC1F,EACE,OAAO,GAAG,SAAS,EACnB,UAAU,GAAG,SAAS,EACtB,SAAS,EACT,SAAS,EACT,eAAe,EACf,QAAQ,EACR,mBAAmB,EAAE,IAAI,EACzB,GAAG,KAAK,EACT,EACD,GAAG;IAEH,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CACL,KAAC,OAAO,IAAC,GAAG,EAAE,MAAM,KAAM,KAAK,EAAE,SAAS,EAAE,kBAAkB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,YACrF,kBAAkB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CACtC,eACE,SAAS,EAAE,kBAAkB,CAAC;gBAC5B,OAAO;gBACP,UAAU;gBACV,SAAS;gBACT,SAAS,EAAE,eAAe;aAC3B,CAAC,YAED,IAAI,GACA,CACR,CAAC,GACM,CACX,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/ui/search.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export interface SearchItem {
|
|
|
6
6
|
description?: string;
|
|
7
7
|
icon?: IconProp;
|
|
8
8
|
href?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Other words that find it: what people call it rather than its name ("mp4", "export"). Matched as well as
|
|
11
|
+
* the label, ranked after label matches, and never shown or read out.
|
|
12
|
+
*/
|
|
13
|
+
keywords?: string[];
|
|
9
14
|
}
|
|
10
15
|
/** The search's own words, for the `labels` prop. */
|
|
11
16
|
export interface SearchLabels {
|
|
@@ -40,6 +45,8 @@ export interface SearchTriggerProps {
|
|
|
40
45
|
/** Icon-only, for narrow headers, named `labels.search`. */
|
|
41
46
|
compact?: boolean;
|
|
42
47
|
labels?: Partial<SearchLabels>;
|
|
48
|
+
/** Shows ⌘K and sets `aria-keyshortcuts`. Default true; false when the shortcut doesn't open this search. */
|
|
49
|
+
shortcut?: boolean;
|
|
43
50
|
className?: string;
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
@@ -47,7 +54,7 @@ export interface SearchTriggerProps {
|
|
|
47
54
|
* shortcut also in `aria-keyshortcuts`. No `aria-label`: one that left out the shortcut would no longer contain
|
|
48
55
|
* the visible text (2.5.3 Label in Name, as axe and the Setsquare SDK measure it).
|
|
49
56
|
*/
|
|
50
|
-
export declare function SearchTrigger({ onPress, placeholder, compact, labels: given, className, }: SearchTriggerProps): import("react").JSX.Element;
|
|
57
|
+
export declare function SearchTrigger({ onPress, placeholder, compact, labels: given, shortcut, className, }: SearchTriggerProps): import("react").JSX.Element;
|
|
51
58
|
export interface AppSearchProps {
|
|
52
59
|
sections: SearchSection[];
|
|
53
60
|
onAction?: (id: Key) => void;
|
|
@@ -57,8 +64,17 @@ export interface AppSearchProps {
|
|
|
57
64
|
placeholder?: string;
|
|
58
65
|
/** For the trigger and the dialog. */
|
|
59
66
|
labels?: Partial<SearchLabels>;
|
|
67
|
+
/**
|
|
68
|
+
* Opens on ⌘K / Ctrl+K. Default true. One search on a page has the shortcut, the first mounted that asks;
|
|
69
|
+
* false gives it up, for a second search on the page.
|
|
70
|
+
*/
|
|
71
|
+
shortcut?: boolean;
|
|
60
72
|
className?: string;
|
|
61
73
|
}
|
|
62
|
-
/**
|
|
63
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Trigger + dialog + the ⌘K / Ctrl+K shortcut, wired together. The shortcut is left alone when focus is in a field
|
|
76
|
+
* or editor, when another handler has already taken it, and in every search on the page but the one that has it
|
|
77
|
+
* (see `shortcut`); the trigger shows ⌘K only on that one.
|
|
78
|
+
*/
|
|
79
|
+
export declare function AppSearch({ sections, onAction, compact, defaultOpen, placeholder, labels, shortcut, className, }: AppSearchProps): import("react").JSX.Element;
|
|
64
80
|
//# sourceMappingURL=search.d.ts.map
|
package/dist/ui/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/ui/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAcL,KAAK,GAAG,EACT,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/ui/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAcL,KAAK,GAAG,EACT,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAatD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AACD,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,YAAY,EAAE,YAK1B,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,EAAE,C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,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAmB,EACnB,WAAW,EACX,MAAM,EACN,QAAe,EACf,SAAS,GACV,EAAE,cAAc,+BAyChB"}
|
package/dist/ui/search.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { Autocomplete, Button as RACButton, Collection, Dialog, Header, Input, Menu, MenuItem, MenuSection, Modal, ModalOverlay, SearchField,
|
|
3
|
+
import { useEffect, useId, useMemo, useState, useSyncExternalStore } from 'react';
|
|
4
|
+
import { Autocomplete, Button as RACButton, Collection, Dialog, Header, Input, Menu, MenuItem, MenuSection, Modal, ModalOverlay, SearchField, useLocale, } from 'react-aria-components';
|
|
5
5
|
import { Search, SearchX } from 'lucide-react';
|
|
6
6
|
import { cn } from '../lib/cn.js';
|
|
7
7
|
import { fieldBox, fieldInput } from './field.js';
|
|
@@ -9,6 +9,9 @@ import { IconButton } from './icon-button.js';
|
|
|
9
9
|
import { renderIcon } from './icon.js';
|
|
10
10
|
import { Kbd } from './kbd.js';
|
|
11
11
|
import { useLabels } from '../lib/locale.js';
|
|
12
|
+
import { duplicateIds, searchCollator, searchSections } from '../lib/search-match.js';
|
|
13
|
+
import { useKeyshortcuts } from '../lib/keyshortcuts.js';
|
|
14
|
+
import { claimSearchShortcut, hasSearchShortcut, isSearchShortcut, subscribeSearchShortcut, } from '../lib/search-shortcut.js';
|
|
12
15
|
import { itemVisual, rowTarget } from './menu.js';
|
|
13
16
|
export const searchLabels = {
|
|
14
17
|
search: 'Search',
|
|
@@ -19,42 +22,71 @@ export const searchLabels = {
|
|
|
19
22
|
/** The search dialog: type to filter, arrow keys to move, Enter to go, Escape to close. */
|
|
20
23
|
export function CommandSearch({ isOpen, onOpenChange, sections, onAction, placeholder, labels: given, }) {
|
|
21
24
|
const t = useLabels('search', searchLabels, given);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const repeated = JSON.stringify(duplicateIds(sections));
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (repeated !== '[]')
|
|
28
|
+
console.error(`Search: item ids must be unique across all sections, and these are used more than once: ${repeated}. React Aria keys the menu by id, so for each, one item is hidden and the other shown twice.`);
|
|
29
|
+
}, [repeated]);
|
|
30
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange, isDismissable: true, "data-overlay": true, className: "fixed inset-0 z-(--z-popover) flex items-start justify-center bg-overlay px-4 pt-[12vh]", children: _jsx(Modal, { "data-sheet": "top", className: "w-full max-w-[40rem] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground shadow-(--shadow-lg) outline-none", children: _jsx(Dialog, { "aria-label": t('search'), className: "flex max-h-[70vh] flex-col outline-none", children: _jsx(SearchBody, { sections: sections, onAction: (id) => {
|
|
31
|
+
onAction?.(id);
|
|
32
|
+
onOpenChange(false);
|
|
33
|
+
}, placeholder: placeholder ?? t('placeholder'), t: t }) }) }) }));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Inside the dialog, so the text starts empty each time it opens. React Aria's Autocomplete can only filter a
|
|
37
|
+
* collection in its own order, so the search holds the text, ranks the items itself and gives the menu only
|
|
38
|
+
* those; Autocomplete still moves through them from the field.
|
|
39
|
+
*/
|
|
40
|
+
function SearchBody({ sections, onAction, placeholder, t, }) {
|
|
41
|
+
const [query, setQuery] = useState('');
|
|
42
|
+
const { locale } = useLocale();
|
|
43
|
+
const collator = useMemo(() => searchCollator(locale), [locale]);
|
|
44
|
+
const results = useMemo(() => searchSections(sections, query, collator), [sections, query, collator]);
|
|
45
|
+
return (_jsxs(Autocomplete, { inputValue: query, onInputChange: setQuery, children: [_jsx(SearchField, { "aria-label": t('search'),
|
|
46
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
47
|
+
autoFocus: true, className: "border-b border-border p-3", children: _jsxs("div", { className: fieldBox, children: [_jsx(Search, { "aria-hidden": "true", className: "pointer-events-none absolute top-1/2 left-2.5 size-5 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { placeholder: placeholder, className: cn(fieldInput, 'pr-14 pl-10 [&::-webkit-search-cancel-button]:hidden') }), _jsx(Kbd, { className: "pointer-events-none absolute top-1/2 right-2 -translate-y-1/2", children: t('escapeKey') })] }) }), _jsx(Menu, { items: results, onAction: onAction, renderEmptyState: () => (_jsxs("div", { className: "flex flex-col items-center gap-2 px-4 py-10 text-center text-sm text-muted-foreground", children: [_jsx(SearchX, { "aria-hidden": "true", className: "size-6" }), t('noResults')] })), className: "relative min-h-0 flex-1 overflow-auto p-2 outline-none", children: (section) => (_jsxs(MenuSection, { id: section.id, className: "not-first:mt-2", children: [_jsx(Header, { className: "px-3 pt-1 pb-1 text-[13px] leading-5 font-semibold text-muted-foreground", children: section.title }), _jsx(Collection, { items: section.items, children: (item) => (_jsx(MenuItem, { id: item.id, href: item.href, textValue: item.label, className: cn('group/item', rowTarget), children: _jsxs("span", { className: itemVisual, children: [item.icon && renderIcon(item.icon, 'size-5 shrink-0 text-muted-foreground'), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "truncate font-medium", children: item.label }), item.description && (_jsx("span", { className: "truncate text-[13px] text-muted-foreground", children: item.description }))] })] }) })) })] })) })] }));
|
|
30
48
|
}
|
|
31
49
|
/**
|
|
32
50
|
* Opens the search dialog. Looks like a field; is a button named by what it shows, "Search ⌘K", with the
|
|
33
51
|
* shortcut also in `aria-keyshortcuts`. No `aria-label`: one that left out the shortcut would no longer contain
|
|
34
52
|
* the visible text (2.5.3 Label in Name, as axe and the Setsquare SDK measure it).
|
|
35
53
|
*/
|
|
36
|
-
export function SearchTrigger({ onPress, placeholder, compact, labels: given, className, }) {
|
|
54
|
+
export function SearchTrigger({ onPress, placeholder, compact, labels: given, shortcut = true, className, }) {
|
|
37
55
|
const t = useLabels('search', searchLabels, given);
|
|
56
|
+
const keys = shortcut ? 'Meta+K Control+K' : undefined;
|
|
57
|
+
const target = useKeyshortcuts(keys);
|
|
38
58
|
if (compact) {
|
|
39
|
-
return (_jsx(IconButton, { label: t('search'), icon: Search, onPress: onPress, "aria-haspopup": "dialog", "aria-keyshortcuts":
|
|
59
|
+
return (_jsx(IconButton, { label: t('search'), icon: Search, onPress: onPress, "aria-haspopup": "dialog", "aria-keyshortcuts": keys }));
|
|
40
60
|
}
|
|
41
|
-
return (_jsxs(RACButton, { onPress: onPress, "aria-haspopup": "dialog",
|
|
61
|
+
return (_jsxs(RACButton, { ref: target, onPress: onPress, "aria-haspopup": "dialog", className: cn(
|
|
42
62
|
// Looks like a field, so it is built like one: the button is the target, the box is painted behind it.
|
|
43
|
-
'field-paint flex h-control-target w-64 min-w-0 cursor-pointer items-center gap-2 pr-2 pl-2.5 text-left text-sm text-muted-foreground outline-none', 'data-hovered:before:bg-accent data-focus-visible:before:focus-ring', className), children: [_jsx(Search, { "aria-hidden": "true", className: "size-5 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: placeholder ?? t('search') }),
|
|
63
|
+
'field-paint flex h-control-target w-64 min-w-0 cursor-pointer items-center gap-2 pr-2 pl-2.5 text-left text-sm text-muted-foreground outline-none', 'data-hovered:before:bg-accent data-focus-visible:before:focus-ring', className), children: [_jsx(Search, { "aria-hidden": "true", className: "size-5 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: placeholder ?? t('search') }), shortcut && (_jsxs(_Fragment, { children: [' ', _jsx(Kbd, { children: "\u2318K" })] }))] }));
|
|
44
64
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Trigger + dialog + the ⌘K / Ctrl+K shortcut, wired together. The shortcut is left alone when focus is in a field
|
|
67
|
+
* or editor, when another handler has already taken it, and in every search on the page but the one that has it
|
|
68
|
+
* (see `shortcut`); the trigger shows ⌘K only on that one.
|
|
69
|
+
*/
|
|
70
|
+
export function AppSearch({ sections, onAction, compact, defaultOpen = false, placeholder, labels, shortcut = true, className, }) {
|
|
47
71
|
const [isOpen, setOpen] = useState(defaultOpen);
|
|
72
|
+
const id = useId();
|
|
73
|
+
const has = useSyncExternalStore(subscribeSearchShortcut, () => hasSearchShortcut(id), () => true);
|
|
48
74
|
useEffect(() => {
|
|
75
|
+
if (!shortcut)
|
|
76
|
+
return;
|
|
77
|
+
const letGo = claimSearchShortcut(id);
|
|
49
78
|
const onKey = (e) => {
|
|
50
|
-
if ((
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
if (!hasSearchShortcut(id) || !isSearchShortcut(e))
|
|
80
|
+
return;
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
setOpen(true);
|
|
54
83
|
};
|
|
55
84
|
document.addEventListener('keydown', onKey);
|
|
56
|
-
return () =>
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
return () => {
|
|
86
|
+
document.removeEventListener('keydown', onKey);
|
|
87
|
+
letGo();
|
|
88
|
+
};
|
|
89
|
+
}, [id, shortcut]);
|
|
90
|
+
return (_jsxs(_Fragment, { children: [_jsx(SearchTrigger, { onPress: () => setOpen(true), compact: compact, labels: labels, shortcut: shortcut && has, className: className }), _jsx(CommandSearch, { isOpen: isOpen, onOpenChange: setOpen, sections: sections, onAction: onAction, placeholder: placeholder, labels: labels })] }));
|
|
59
91
|
}
|
|
60
92
|
//# sourceMappingURL=search.js.map
|
package/dist/ui/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/ui/search.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/ui/search.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EACL,YAAY,EACZ,MAAM,IAAI,SAAS,EACnB,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,YAAY,EACZ,WAAW,EACX,SAAS,GAEV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAyBlD,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,MAAM,EAAE,QAAQ;IA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C,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC/C,KAAK,EAAE,CAAC;QACV,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;IACnB,OAAO,CACL,8BACE,KAAC,aAAa,IACZ,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAC5B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,IAAI,GAAG,EACzB,SAAS,EAAE,SAAS,GACpB,EACF,KAAC,aAAa,IACZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,GACd,IACD,CACJ,CAAC;AACJ,CAAC"}
|
package/dist/ui/tree.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import { TreeSection as RACTreeSection, type TreeItemProps as RACTreeItemProps, type TreeProps as RACTreeProps } from 'react-aria-components';
|
|
3
|
+
import { type KeyshortcutsProps } from '../lib/keyshortcuts.js';
|
|
3
4
|
import { type IconProp } from './icon.js';
|
|
4
5
|
/** A tree is named by a visible heading (`aria-labelledby`) or, when it has none, by `aria-label`. */
|
|
5
6
|
type TreeName = {
|
|
@@ -7,8 +8,9 @@ type TreeName = {
|
|
|
7
8
|
} | {
|
|
8
9
|
'aria-labelledby': string;
|
|
9
10
|
};
|
|
10
|
-
export type TreeProps<T extends object> = Omit<RACTreeProps<T>, 'className' | 'aria-label' | 'aria-labelledby'> & TreeName & {
|
|
11
|
+
export type TreeProps<T extends object> = Omit<RACTreeProps<T>, 'className' | 'aria-label' | 'aria-labelledby'> & TreeName & KeyshortcutsProps & {
|
|
11
12
|
className?: string;
|
|
13
|
+
ref?: Ref<HTMLDivElement>;
|
|
12
14
|
};
|
|
13
15
|
/**
|
|
14
16
|
* Nested things people open, close and act on: the blocks of a page, the steps of a workflow and their outcomes,
|
|
@@ -25,7 +27,7 @@ export type TreeProps<T extends object> = Omit<RACTreeProps<T>, 'className' | 'a
|
|
|
25
27
|
* button, which is how a keyboard or screen reader drag starts: Enter on it, ↑ ↓ to a drop place, Enter to drop,
|
|
26
28
|
* Esc to cancel.
|
|
27
29
|
*/
|
|
28
|
-
export declare function Tree<T extends object>({ className, ...props }: TreeProps<T>): import("react").JSX.Element;
|
|
30
|
+
export declare function Tree<T extends object>({ className, ref, 'aria-keyshortcuts': keys, ...props }: TreeProps<T>): import("react").JSX.Element;
|
|
29
31
|
export interface TreeItemProps<T extends object = object> extends Omit<RACTreeItemProps<T>, 'className' | 'children' | 'textValue' | 'style'> {
|
|
30
32
|
/** What the row is called. A string is also its `textValue`. */
|
|
31
33
|
title: ReactNode;
|
package/dist/ui/tree.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/ui/tree.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/ui/tree.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAML,WAAW,IAAI,cAAc,EAE7B,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,SAAS,IAAI,YAAY,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAmB,KAAK,iBAA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mF;IACnF,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,4GAA4G;IAC5G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAClD,KAAK,EACL,SAAS,EACT,IAAI,EACJ,WAAW,EACX,MAAM,EACN,WAAW,EACX,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,SAAS,EACT,cAAc,EAAE,QAAe,EAC/B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,CAAC,CAAC,CAAC,+BA+GlB;AAED,iEAAiE;AACjE,KAAK,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAErF,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,IAAI,CAC9D,mBAAmB,CAAC,CAAC,CAAC,EACtB,WAAW,CACZ;IACC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,+BAEzF;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,+BAW9F"}
|
package/dist/ui/tree.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { ChevronRight, GripVertical } from 'lucide-react';
|
|
4
4
|
import { Button as RACButton, Tree as RACTree, TreeHeader as RACTreeHeader, TreeItem as RACTreeItem, TreeItemContent, TreeSection as RACTreeSection, useLocale, } from 'react-aria-components';
|
|
5
5
|
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { useKeyshortcuts } from '../lib/keyshortcuts.js';
|
|
6
7
|
import { formatList } from '../lib/labels.js';
|
|
7
8
|
import { SelectionCheckbox } from './checkbox.js';
|
|
8
9
|
import { renderIcon } from './icon.js';
|
|
@@ -21,8 +22,9 @@ import { renderIcon } from './icon.js';
|
|
|
21
22
|
* button, which is how a keyboard or screen reader drag starts: Enter on it, ↑ ↓ to a drop place, Enter to drop,
|
|
22
23
|
* Esc to cancel.
|
|
23
24
|
*/
|
|
24
|
-
export function Tree({ className, ...props }) {
|
|
25
|
-
|
|
25
|
+
export function Tree({ className, ref, 'aria-keyshortcuts': keys, ...props }) {
|
|
26
|
+
const tree = useKeyshortcuts(keys, ref);
|
|
27
|
+
return (_jsx(RACTree, { ...props, ref: tree, className: cn('relative flex max-h-[inherit] flex-col gap-(--nav-item-gap) overflow-auto text-sm outline-none data-focus-visible:focus-ring',
|
|
26
28
|
// Dropping onto the tree itself (an empty tree, or the end of it).
|
|
27
29
|
'data-drop-target:bg-brand-subtle data-drop-target:outline-2 data-drop-target:outline-solid data-drop-target:outline-brand data-drop-target:-outline-offset-2', className) }));
|
|
28
30
|
}
|
package/dist/ui/tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/ui/tree.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,MAAM,IAAI,SAAS,EACnB,IAAI,IAAI,OAAO,EACf,UAAU,IAAI,aAAa,EAC3B,QAAQ,IAAI,WAAW,EACvB,eAAe,EACf,WAAW,IAAI,cAAc,EAC7B,SAAS,GAGV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AAmB,EAAE,SAAS,EAAE,GAAG,KAAK,EAAuB;IACxF,OAAO,KAAC,cAAc,OAAK,KAAK,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AAC7D,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAA+C;IAC7F,OAAO,CACL,KAAC,aAAa,IACZ,SAAS,EAAE,EAAE,CACX,qEAAqE,EACrE,SAAS,CACV,YAEA,QAAQ,GACK,CACjB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@setsquare/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React Aria components, design tokens, a dashboard shell and a site shell, with a switch between WCAG 2.2 AA and AAA sizing, spacing and contrast.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/Worktree-Amigos/setsquare-ui#readme",
|