@webority/ui-react 0.14.0 → 0.15.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/dist/types/components/AppCommandPalette.d.ts +62 -0
- package/dist/types/components/AppConfirmDialog.d.ts +1 -1
- package/dist/types/components/AppSegmented.d.ts +11 -42
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/useCommandPaletteShortcut.d.ts +20 -0
- package/dist/ui-react.js +929 -756
- package/package.json +3 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "@webority/ui-elements";
|
|
2
|
+
/**
|
|
3
|
+
* App-wide "search and jump": a top-anchored dialog with a search input over a grouped list
|
|
4
|
+
* of results. Pair it with `useCommandPaletteShortcut` to open it on Ctrl+K / Cmd+K.
|
|
5
|
+
*
|
|
6
|
+
* The overlay is `AppModal`, so the backdrop, Escape, the focus trap and returning focus to
|
|
7
|
+
* whatever was focused before it opened all come from there. The list behaviour (the active
|
|
8
|
+
* result, ArrowUp / ArrowDown across groups with wrap-around, Enter, the pointer, scrolling the
|
|
9
|
+
* active result into view) is the shared `<wui-command-palette>` element, the same one the
|
|
10
|
+
* Razor `<app-command-palette>` uses.
|
|
11
|
+
*
|
|
12
|
+
* You own the search: `query` is controlled, and `groups` is whatever your search returned
|
|
13
|
+
* for it. The palette does not filter. Selecting a result calls its `onSelect`, then `onClose`.
|
|
14
|
+
*
|
|
15
|
+
* @param {object} props
|
|
16
|
+
* @param {boolean} props.open
|
|
17
|
+
* @param {() => void} props.onClose Called on Escape, a backdrop click, and after a selection.
|
|
18
|
+
* @param {string} [props.query=''] The search text (controlled).
|
|
19
|
+
* @param {(value: string) => void} [props.onQueryChange] Called with the new text as the user types.
|
|
20
|
+
* @param {string} [props.placeholder='Search…']
|
|
21
|
+
* @param {{ key: string, label: import('react').ReactNode, items: { key: string,
|
|
22
|
+
* label: import('react').ReactNode, description?: import('react').ReactNode,
|
|
23
|
+
* icon?: string | import('react').ReactNode, meta?: import('react').ReactNode,
|
|
24
|
+
* onSelect?: () => void }[] }[]} [props.groups=[]] Results, rendered in order under
|
|
25
|
+
* their group headings. Keys must be unique within their group; groups with no items are
|
|
26
|
+
* left out. `icon` is a library icon name or a node; `meta` is short trailing text or a node.
|
|
27
|
+
* @param {boolean} [props.loading=false] Shows the library spinner in the input.
|
|
28
|
+
* @param {import('react').ReactNode} [props.emptyText='No results'] Shown when the query is
|
|
29
|
+
* not blank, nothing is loading, and no group has items.
|
|
30
|
+
* @param {import('react').ReactNode} [props.footer] Content under the list, such as key hints.
|
|
31
|
+
* @param {string} [props.ariaLabel='Search'] Accessible name of the dialog and its input.
|
|
32
|
+
* @param {boolean} [props.highlight=true] Bold the query inside each string label,
|
|
33
|
+
* case-insensitively. A label given as a node renders as it is.
|
|
34
|
+
* @param {string} [props.id] Seeds the result and heading ids; defaults to a generated id.
|
|
35
|
+
* @param {string} [props.className] Extra classes on the dialog card.
|
|
36
|
+
*/
|
|
37
|
+
export default function AppCommandPalette({ open, onClose, query, onQueryChange, placeholder, groups, loading, emptyText, footer, ariaLabel, highlight, id, className, ...rest }: {
|
|
38
|
+
open: boolean;
|
|
39
|
+
onClose: () => void;
|
|
40
|
+
query?: string;
|
|
41
|
+
onQueryChange?: (value: string) => void;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
groups?: {
|
|
44
|
+
key: string;
|
|
45
|
+
label: import('react').ReactNode;
|
|
46
|
+
items: {
|
|
47
|
+
key: string;
|
|
48
|
+
label: import('react').ReactNode;
|
|
49
|
+
description?: import('react').ReactNode;
|
|
50
|
+
icon?: string | import('react').ReactNode;
|
|
51
|
+
meta?: import('react').ReactNode;
|
|
52
|
+
onSelect?: () => void;
|
|
53
|
+
}[];
|
|
54
|
+
}[];
|
|
55
|
+
loading?: boolean;
|
|
56
|
+
emptyText?: import('react').ReactNode;
|
|
57
|
+
footer?: import('react').ReactNode;
|
|
58
|
+
ariaLabel?: string;
|
|
59
|
+
highlight?: boolean;
|
|
60
|
+
id?: string;
|
|
61
|
+
className?: string;
|
|
62
|
+
}): import("react").JSX.Element;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* 1024px PNG and a 64px one land identically. Decorative like the tone artwork: it renders
|
|
15
15
|
* aria-hidden with an empty alt, and the title plus message carry the meaning.
|
|
16
16
|
* @param {number} [props.iconSize] Width and height of the illustration in px, for the tone
|
|
17
|
-
* artwork and a custom `image` alike. Unset, it is
|
|
17
|
+
* artwork and a custom `image` alike. Unset, it is 120px with a message and 84px without.
|
|
18
18
|
* @param {string} [props.confirmPhrase]
|
|
19
19
|
* @param {() => void} props.onConfirm
|
|
20
20
|
* @param {string} [props.cancelLabel="Cancel"]
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* or a compact view/range toggle above a chart.
|
|
5
|
-
*
|
|
6
|
-
* Past four options the row runs out of width — reach for `AppSelect` instead.
|
|
7
|
-
* For a boolean use `AppSwitch`; for a filter that can be off use `AppChoiceChip`.
|
|
8
|
-
*
|
|
9
|
-
* Built on real `<input type="radio">` elements inside labels, so arrow-key
|
|
10
|
-
* navigation, the single tab stop, and the "2 of 3" screen-reader announcement all
|
|
11
|
-
* come from the browser rather than hand-written key handling — and the control
|
|
12
|
-
* posts inside a plain form with no JavaScript.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} props
|
|
15
|
-
* @param {{ value: string, label: string, note?: string, icon?: string, disabled?: boolean }[]} props.options
|
|
16
|
-
* `note` renders as a smaller, muted sub-line under the label — a supporting detail
|
|
17
|
-
* ("Last 7 days") without shrinking the label itself. Optional; segments without one are
|
|
18
|
-
* unaffected.
|
|
19
|
-
* @param {string} props.value The selected option's value.
|
|
20
|
-
* @param {(value: string) => void} props.onChange
|
|
21
|
-
* @param {string} props.label Accessible name for the group.
|
|
22
|
-
* @param {string} [props.name] Field name. Defaults to a generated one.
|
|
23
|
-
* @param {'sm'|'md'|'lg'} [props.size='md']
|
|
24
|
-
* @param {boolean} [props.fullWidth=false] Segments share the row equally, filling the container.
|
|
25
|
-
* @param {boolean} [props.disabled=false] Disables the whole control.
|
|
26
|
-
* @param {string} [props.className]
|
|
27
|
-
*/
|
|
28
|
-
export default function AppSegmented({ options, value, onChange, label, name, size, fullWidth, disabled, className, ...rest }: {
|
|
29
|
-
options: {
|
|
30
|
-
value: string;
|
|
31
|
-
label: string;
|
|
32
|
-
note?: string;
|
|
33
|
-
icon?: string;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
}[];
|
|
36
|
-
value: string;
|
|
37
|
-
onChange: (value: string) => void;
|
|
38
|
-
label: string;
|
|
39
|
-
name?: string;
|
|
40
|
-
size?: 'sm' | 'md' | 'lg';
|
|
41
|
-
fullWidth?: boolean;
|
|
42
|
-
disabled?: boolean;
|
|
1
|
+
export default function AppSegmented({ options, value, onChange, label, name, size, fullWidth, bordered, disabled, className, ...rest }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
bordered?: boolean;
|
|
43
4
|
className?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
label: any;
|
|
8
|
+
name: any;
|
|
9
|
+
onChange: any;
|
|
10
|
+
options?: any[];
|
|
11
|
+
size?: string;
|
|
12
|
+
value: any;
|
|
44
13
|
}): import("react").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { default as AppChip } from "./components/AppChip.jsx";
|
|
|
15
15
|
export { default as AppChoiceCard } from "./components/AppChoiceCard.jsx";
|
|
16
16
|
export { default as AppChoiceChip } from "./components/AppChoiceChip.jsx";
|
|
17
17
|
export { default as AppColorField } from "./components/AppColorField.jsx";
|
|
18
|
+
export { default as AppCommandPalette } from "./components/AppCommandPalette.jsx";
|
|
18
19
|
export { default as AppCompareTable } from "./components/AppCompareTable.jsx";
|
|
19
20
|
export { default as AppConfirmDialog } from "./components/AppConfirmDialog.jsx";
|
|
20
21
|
export { default as AppConsentBanner } from "./components/AppConsentBanner.jsx";
|
|
@@ -83,4 +84,5 @@ export { default as AppWizard } from "./components/AppWizard.jsx";
|
|
|
83
84
|
export { default as AppWorkspaceSwitcher } from "./components/AppWorkspaceSwitcher.jsx";
|
|
84
85
|
export { MODAL_ICONS } from "./components/ModalIcons.jsx";
|
|
85
86
|
export { dismissAll, errorToast, toast } from "./components/toast.js";
|
|
87
|
+
export { useCommandPaletteShortcut } from "./lib/useCommandPaletteShortcut.js";
|
|
86
88
|
export { usePagination } from "./lib/usePagination.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `onOpen` when the user presses Ctrl+K (Windows, Linux) or Cmd+K (macOS) anywhere on
|
|
3
|
+
* the page, and stops the browser's own use of the chord (Ctrl+K focuses the address bar in
|
|
4
|
+
* some browsers). Pair it with `AppCommandPalette`:
|
|
5
|
+
*
|
|
6
|
+
* const [open, setOpen] = useState(false);
|
|
7
|
+
* useCommandPaletteShortcut(() => setOpen(true));
|
|
8
|
+
*
|
|
9
|
+
* Kept deliberately simple: it fires whatever has focus, including a text field or another
|
|
10
|
+
* open dialog, and it ignores a held key's auto-repeat. A chord with Alt or Shift held is left
|
|
11
|
+
* alone, so Ctrl+Shift+K stays available to the page. The listener is removed on unmount, and
|
|
12
|
+
* a new `onOpen` each render is fine: the latest one is always called.
|
|
13
|
+
*
|
|
14
|
+
* @param {() => void} onOpen Called on the chord.
|
|
15
|
+
* @param {{ key?: string }} [options] `key` is the letter to pair with Ctrl / Cmd (default `k`),
|
|
16
|
+
* matched case-insensitively.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useCommandPaletteShortcut(onOpen: () => void, { key }?: {
|
|
19
|
+
key?: string;
|
|
20
|
+
}): void;
|