@xeonr/platform-ui 1.3.1 → 1.5.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.
Files changed (90) hide show
  1. package/dist/index.d.ts +12 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +22 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/kit/Anchored.d.ts +13 -2
  6. package/dist/kit/Anchored.d.ts.map +1 -1
  7. package/dist/kit/Anchored.js +47 -18
  8. package/dist/kit/Anchored.js.map +1 -1
  9. package/dist/kit/Badge.d.ts +1 -0
  10. package/dist/kit/Badge.d.ts.map +1 -1
  11. package/dist/kit/Badge.js +14 -0
  12. package/dist/kit/Badge.js.map +1 -1
  13. package/dist/kit/Button.d.ts +8 -2
  14. package/dist/kit/Button.d.ts.map +1 -1
  15. package/dist/kit/Button.js +17 -3
  16. package/dist/kit/Button.js.map +1 -1
  17. package/dist/kit/Chip.d.ts +6 -0
  18. package/dist/kit/Chip.d.ts.map +1 -1
  19. package/dist/kit/Chip.js +2 -1
  20. package/dist/kit/Chip.js.map +1 -1
  21. package/dist/kit/CodeEditor.js +1 -1
  22. package/dist/kit/Color.d.ts +69 -0
  23. package/dist/kit/Color.d.ts.map +1 -0
  24. package/dist/kit/Color.js +150 -0
  25. package/dist/kit/Color.js.map +1 -0
  26. package/dist/kit/Combobox.d.ts +5 -1
  27. package/dist/kit/Combobox.d.ts.map +1 -1
  28. package/dist/kit/Combobox.js +39 -28
  29. package/dist/kit/Combobox.js.map +1 -1
  30. package/dist/kit/Controls.d.ts +184 -0
  31. package/dist/kit/Controls.d.ts.map +1 -0
  32. package/dist/kit/Controls.js +344 -0
  33. package/dist/kit/Controls.js.map +1 -0
  34. package/dist/kit/DatePicker.d.ts +125 -0
  35. package/dist/kit/DatePicker.d.ts.map +1 -0
  36. package/dist/kit/DatePicker.js +438 -0
  37. package/dist/kit/DatePicker.js.map +1 -0
  38. package/dist/kit/Dropzone.d.ts +41 -0
  39. package/dist/kit/Dropzone.d.ts.map +1 -0
  40. package/dist/kit/Dropzone.js +118 -0
  41. package/dist/kit/Dropzone.js.map +1 -0
  42. package/dist/kit/Form.d.ts +86 -13
  43. package/dist/kit/Form.d.ts.map +1 -1
  44. package/dist/kit/Form.js +124 -13
  45. package/dist/kit/Form.js.map +1 -1
  46. package/dist/kit/Icon.d.ts +4 -0
  47. package/dist/kit/Icon.d.ts.map +1 -1
  48. package/dist/kit/Icon.js +5 -1
  49. package/dist/kit/Icon.js.map +1 -1
  50. package/dist/kit/List.d.ts +55 -8
  51. package/dist/kit/List.d.ts.map +1 -1
  52. package/dist/kit/List.js +43 -6
  53. package/dist/kit/List.js.map +1 -1
  54. package/dist/kit/Menu.d.ts +71 -9
  55. package/dist/kit/Menu.d.ts.map +1 -1
  56. package/dist/kit/Menu.js +119 -21
  57. package/dist/kit/Menu.js.map +1 -1
  58. package/dist/kit/Modal.d.ts +37 -4
  59. package/dist/kit/Modal.d.ts.map +1 -1
  60. package/dist/kit/Modal.js +42 -14
  61. package/dist/kit/Modal.js.map +1 -1
  62. package/dist/kit/MultiCombobox.d.ts +48 -1
  63. package/dist/kit/MultiCombobox.d.ts.map +1 -1
  64. package/dist/kit/MultiCombobox.js +100 -27
  65. package/dist/kit/MultiCombobox.js.map +1 -1
  66. package/dist/kit/Picker.d.ts +6 -1
  67. package/dist/kit/Picker.d.ts.map +1 -1
  68. package/dist/kit/Picker.js +10 -5
  69. package/dist/kit/Picker.js.map +1 -1
  70. package/dist/kit/Popover.d.ts +13 -1
  71. package/dist/kit/Popover.d.ts.map +1 -1
  72. package/dist/kit/Popover.js +31 -9
  73. package/dist/kit/Popover.js.map +1 -1
  74. package/dist/kit/Skeleton.d.ts +44 -3
  75. package/dist/kit/Skeleton.d.ts.map +1 -1
  76. package/dist/kit/Skeleton.js +39 -1
  77. package/dist/kit/Skeleton.js.map +1 -1
  78. package/dist/kit/Stepper.d.ts +33 -0
  79. package/dist/kit/Stepper.d.ts.map +1 -0
  80. package/dist/kit/Stepper.js +97 -0
  81. package/dist/kit/Stepper.js.map +1 -0
  82. package/dist/theme/brand.js +4 -4
  83. package/dist/theme/brand.js.map +1 -1
  84. package/dist/theme/paint.d.ts +1 -1
  85. package/dist/theme/paint.js +1 -1
  86. package/dist/theme/tokens.d.ts +1 -0
  87. package/dist/theme/tokens.d.ts.map +1 -1
  88. package/dist/theme/tokens.js +17 -14
  89. package/dist/theme/tokens.js.map +1 -1
  90. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ import { type KeyboardEvent, type ReactNode, type Ref } from "react";
2
+ import { type IconName } from "./Icon.tsx";
3
+ import { type AnchoredAlign, type AnchoredSide } from "./Anchored.tsx";
4
+ /**
5
+ * ColorSwatch: a round well filled with a colour — a button. `icon` draws
6
+ * what the colour paints (a stroke, a fill, text) on top of it, in `ink`.
7
+ * On its own it is the trigger a product hangs its own picker from; in a row
8
+ * of them, `selected` marks the chosen one.
9
+ */
10
+ export declare function ColorSwatch({ color, label, icon, ink, size, selected, disabled, onClick, ...rest }: {
11
+ /** the colour shown: any CSS colour the product holds (a stored hex, a token) */
12
+ color: string;
13
+ /** accessible name — what it is the colour of ("Stroke colour"), or the colour's name */
14
+ label: string;
15
+ icon?: IconName | (string & {}) | undefined;
16
+ /**
17
+ * The icon's colour on the swatch. Default: derived from the swatch —
18
+ * black on a light colour, white on a dark one — so it stays legible on
19
+ * whatever colour the person picked (the page's text colour in a browser
20
+ * without CSS relative colours).
21
+ */
22
+ ink?: string | undefined;
23
+ /** px (default 26) */
24
+ size?: number | undefined;
25
+ selected?: boolean | undefined;
26
+ disabled?: boolean | undefined;
27
+ onClick?: (() => void) | undefined;
28
+ "aria-haspopup"?: "dialog" | "listbox" | undefined;
29
+ "aria-expanded"?: boolean | undefined;
30
+ "aria-selected"?: boolean | undefined;
31
+ role?: string | undefined;
32
+ ref?: Ref<HTMLButtonElement> | undefined;
33
+ tabIndex?: number | undefined;
34
+ onKeyDown?: ((e: KeyboardEvent<HTMLButtonElement>) => void) | undefined;
35
+ }): import("react").JSX.Element;
36
+ export interface ColorPickerProps {
37
+ /** the chosen colour */
38
+ value: string;
39
+ onChange: (color: string) => void;
40
+ /** the palette offered, as CSS colours; a `{ value, label }` names one for assistive tech */
41
+ colors: (string | {
42
+ value: string;
43
+ label: string;
44
+ })[];
45
+ /** accessible name of the trigger ("Stroke colour") */
46
+ label: string;
47
+ /** what the colour paints, drawn on the trigger */
48
+ icon?: IconName | (string & {}) | undefined;
49
+ ink?: string | undefined;
50
+ /** also offer the browser's own colour dialog, for a colour outside the palette (hex values only) */
51
+ custom?: boolean | undefined;
52
+ /** caption beside the custom well (default "Custom…") */
53
+ customLabel?: ReactNode | undefined;
54
+ /** swatches per row (default 6) */
55
+ columns?: number | undefined;
56
+ /** trigger size, px */
57
+ size?: number | undefined;
58
+ disabled?: boolean | undefined;
59
+ side?: AnchoredSide | undefined;
60
+ align?: AnchoredAlign | undefined;
61
+ }
62
+ /**
63
+ * ColorPicker: a ColorSwatch that opens a palette. Arrow keys move through
64
+ * the palette, Enter picks, Escape closes (before any modal it sits in), and
65
+ * the list portals so a toolbar cannot clip it. `custom` adds the browser's
66
+ * colour dialog under the palette for anything else.
67
+ */
68
+ export declare function ColorPicker({ value, onChange, colors, label, icon, ink, custom, customLabel, columns, size, disabled, side, align, }: ColorPickerProps): import("react").JSX.Element;
69
+ //# sourceMappingURL=Color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../src/kit/Color.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAGtH,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAY,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiCjF;;;;;GAKG;AACH,wBAAgB,WAAW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M,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IACtD,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,IAAI,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,qGAAqG;IACrG,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACpC,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,WAAuB,EAAE,OAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAc,GAC9H,EAAE,gBAAgB,+BAkGlB"}
@@ -0,0 +1,150 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import styled, { css } from "styled-components";
4
+ import { v } from "../theme/tokens.js";
5
+ import { Icon } from "./Icon.js";
6
+ import { Anchored } from "./Anchored.js";
7
+ import { useEscapeLayer } from "./layers.js";
8
+ // A colour the person chooses — a pen in an image editor, a label's colour.
9
+ // Added for the upl.im dashboard (1.4), whose editor toolbar had drawn its own
10
+ // colour well. The colour is data, not chrome: it comes from the caller (a
11
+ // value the product stores), never from a literal in the kit.
12
+ const Well = styled.button `
13
+ position: relative;
14
+ flex: none;
15
+ width: ${(p) => p.$size}px;
16
+ height: ${(p) => p.$size}px;
17
+ border-radius: 50%;
18
+ display: inline-grid;
19
+ place-items: center;
20
+ border: 1px solid ${v.line2};
21
+ font-size: ${(p) => Math.round(p.$size * 0.4)}px;
22
+ transition: transform 0.12s ease, box-shadow 0.12s ease;
23
+ /* the colour is the caller's; the ring between it and the selection mark is the surface */
24
+ ${(p) => p.$selected && css `box-shadow: 0 0 0 2px ${v.surface}, 0 0 0 4px ${v.brand};`}
25
+ &:hover:not(:disabled) { transform: scale(1.06); }
26
+ &:disabled { opacity: 0.5; cursor: not-allowed; }
27
+ &:focus-visible { border-radius: 50%; }
28
+ > svg { filter: drop-shadow(0 0 1px ${v.scrim}); }
29
+ /* The default ink is derived from the swatch itself: black on a light
30
+ colour, white on a dark one (OKLCH lightness thresholded at 0.62). A
31
+ browser without relative colour syntax keeps the text colour above. */
32
+ background: var(--x-swatch);
33
+ color: ${v.text};
34
+ color: oklch(from var(--x-swatch) clamp(0, (0.62 - l) * 1000, 1) 0 0);
35
+ `;
36
+ /**
37
+ * ColorSwatch: a round well filled with a colour — a button. `icon` draws
38
+ * what the colour paints (a stroke, a fill, text) on top of it, in `ink`.
39
+ * On its own it is the trigger a product hangs its own picker from; in a row
40
+ * of them, `selected` marks the chosen one.
41
+ */
42
+ export function ColorSwatch({ color, label, icon, ink, size = 26, selected, disabled, onClick, ...rest }) {
43
+ return (_jsx(Well, { type: "button", "aria-label": label, title: label, "$size": size, "$selected": !!selected, disabled: disabled, onClick: onClick, style: { "--x-swatch": color, ...(ink ? { color: ink } : {}) }, ...rest, children: icon ? _jsx(Icon, { name: icon }) : null }));
44
+ }
45
+ const Panel = styled.div `
46
+ padding: 10px;
47
+ background: ${v.surface};
48
+ border: 1px solid ${v.line2};
49
+ border-radius: ${v.rCard};
50
+ box-shadow: ${v.elev};
51
+ > .grid { display: grid; gap: 8px; }
52
+ > .custom {
53
+ display: flex;
54
+ align-items: center;
55
+ gap: 8px;
56
+ margin-top: 10px;
57
+ padding-top: 10px;
58
+ border-top: 1px solid ${v.line};
59
+ font-size: 11.5px;
60
+ color: ${v.muted};
61
+ cursor: pointer;
62
+ input[type="color"] {
63
+ width: 26px;
64
+ height: 26px;
65
+ padding: 0;
66
+ border: 1px solid ${v.line2};
67
+ border-radius: 50%;
68
+ background: none;
69
+ cursor: pointer;
70
+ overflow: hidden;
71
+ }
72
+ input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
73
+ input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
74
+ input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
75
+ }
76
+ `;
77
+ /**
78
+ * ColorPicker: a ColorSwatch that opens a palette. Arrow keys move through
79
+ * the palette, Enter picks, Escape closes (before any modal it sits in), and
80
+ * the list portals so a toolbar cannot clip it. `custom` adds the browser's
81
+ * colour dialog under the palette for anything else.
82
+ */
83
+ export function ColorPicker({ value, onChange, colors, label, icon, ink, custom, customLabel = "Custom…", columns = 6, size, disabled, side, align = "left", }) {
84
+ const [open, setOpen] = useState(false);
85
+ const wrap = useRef(null);
86
+ const layer = useRef(null);
87
+ const cells = useRef([]);
88
+ const list = colors.map((c) => (typeof c === "string" ? { value: c, label: c } : c));
89
+ const chosen = list.findIndex((c) => c.value.toLowerCase() === value.toLowerCase());
90
+ const [active, setActive] = useState(0);
91
+ const close = (refocus) => {
92
+ setOpen(false);
93
+ if (refocus)
94
+ wrap.current?.querySelector("button")?.focus();
95
+ };
96
+ useEscapeLayer(open, () => close(true));
97
+ useEffect(() => {
98
+ if (!open)
99
+ return;
100
+ const onDown = (e) => {
101
+ const t = e.target;
102
+ if (!wrap.current?.contains(t) && !layer.current?.contains(t))
103
+ setOpen(false);
104
+ };
105
+ document.addEventListener("mousedown", onDown, true);
106
+ return () => document.removeEventListener("mousedown", onDown, true);
107
+ }, [open]);
108
+ useEffect(() => {
109
+ if (open)
110
+ cells.current[active]?.focus();
111
+ }, [open, active]);
112
+ const pick = (c) => {
113
+ onChange(c);
114
+ close(true);
115
+ };
116
+ const onKey = (e) => {
117
+ const n = list.length;
118
+ const step = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: columns, ArrowUp: -columns };
119
+ if (e.key in step) {
120
+ e.preventDefault();
121
+ setActive((a) => Math.max(0, Math.min(n - 1, a + step[e.key])));
122
+ }
123
+ else if (e.key === "Home") {
124
+ e.preventDefault();
125
+ setActive(0);
126
+ }
127
+ else if (e.key === "End") {
128
+ e.preventDefault();
129
+ setActive(n - 1);
130
+ }
131
+ else if (e.key === "Tab" && !custom)
132
+ close(false);
133
+ };
134
+ const hex = /^#[0-9a-f]{6}$/i.test(value) ? value : undefined;
135
+ return (_jsxs("span", { ref: wrap, style: { display: "inline-flex" }, children: [_jsx(ColorSwatch, { color: value, label: label, icon: icon, ink: ink, size: size, disabled: disabled, "aria-haspopup": "listbox", "aria-expanded": open, onClick: () => {
136
+ if (open) {
137
+ close(false);
138
+ return;
139
+ }
140
+ setActive(chosen >= 0 ? chosen : 0);
141
+ setOpen(true);
142
+ }, onKeyDown: (e) => {
143
+ if (e.key === "ArrowDown" && !open) {
144
+ e.preventDefault();
145
+ setActive(chosen >= 0 ? chosen : 0);
146
+ setOpen(true);
147
+ }
148
+ } }), open ? (_jsx(Anchored, { anchor: wrap, align: align, side: side, gap: 6, layerRef: layer, children: _jsxs(Panel, { children: [_jsx("div", { className: "grid", role: "listbox", "aria-label": label, style: { gridTemplateColumns: `repeat(${columns}, 24px)` }, onKeyDown: onKey, children: list.map((c, i) => (_jsx(ColorSwatch, { color: c.value, label: c.label, size: 24, ref: (n) => { cells.current[i] = n; }, role: "option", "aria-selected": i === chosen, selected: i === chosen, tabIndex: i === active ? 0 : -1, onClick: () => pick(c.value) }, `${c.value}-${i}`))) }), custom ? (_jsxs("label", { className: "custom", children: [_jsx("input", { type: "color", ...(hex ? { value: hex } : {}), onChange: (e) => onChange(e.target.value), "aria-label": `${label}: custom` }, hex ? "hex" : "none"), customLabel] })) : null] }) })) : null] }));
149
+ }
150
+ //# sourceMappingURL=Color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Color.js","sourceRoot":"","sources":["../../src/kit/Color.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAoE,MAAM,OAAO,CAAC;AACtH,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAiB,MAAM,WAAY,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAyC,MAAM,eAAgB,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,4EAA4E;AAC5E,+EAA+E;AAC/E,2EAA2E;AAC3E,8DAA8D;AAE9D,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAuC;;;WAGtD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK;YACb,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK;;;;sBAIJ,CAAC,CAAC,KAAK;eACd,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC;;;IAG3C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAA,yBAAyB,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC,KAAK,GAAG;;;;wCAIhD,CAAC,CAAC,KAAK;;;;;WAKpC,CAAC,CAAC,IAAI;;CAEhB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,EAA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C,KAAK,CAAC,CAAC,CAAC,MAAM,CAA6H,EAC5J,WAAW,IACN,CACT,CAAC,CAAC,CAAC,IAAI,IACF,GACC,CACZ,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
+ import type { IconName } from "./Icon.tsx";
2
3
  export interface ComboOption<T> {
3
4
  key: string;
4
5
  value: T;
@@ -9,7 +10,7 @@ export interface ComboOption<T> {
9
10
  * query (so it can debounce and hit whichever RPC it needs) — this only owns
10
11
  * the open/highlight/keyboard behaviour.
11
12
  */
12
- export declare function Combobox<T>({ value, onQueryChange, options, onPick, placeholder, label, loading, emptyNote, autoFocus, onSubmit, onBackspaceWhenEmpty }: {
13
+ export declare function Combobox<T>({ value, onQueryChange, options, onPick, placeholder, label, loading, emptyNote, autoFocus, onSubmit, onBackspaceWhenEmpty, icon, disabled }: {
13
14
  value: string;
14
15
  onQueryChange: (q: string) => void;
15
16
  options: ComboOption<T>[];
@@ -36,5 +37,8 @@ export declare function Combobox<T>({ value, onQueryChange, options, onPick, pla
36
37
  * Every chip input does this (it drops the last chip) and fingers expect it.
37
38
  */
38
39
  onBackspaceWhenEmpty?: (() => void) | undefined;
40
+ /** a leading glyph inside the box — `search` for a people or entity finder */
41
+ icon?: IconName | (string & {}) | undefined;
42
+ disabled?: boolean | undefined;
39
43
  }): import("react").JSX.Element;
40
44
  //# sourceMappingURL=Combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../src/kit/Combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAgDpE,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,EAAE,SAAS,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ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AC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;IACxK,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,gEAAgE;IAChE,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACjD;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IAChD,8EAA8E;IAC9E,IAAI,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,+BAoFA"}
@@ -1,10 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import styled from "styled-components";
4
4
  import { v } from "../theme/tokens.js";
5
5
  import { Input } from "./Form.js";
6
6
  import { Icon } from "./Icon.js";
7
7
  import { Anchored } from "./Anchored.js";
8
+ import { InputGroup } from "./Controls.js";
9
+ import { useEscapeLayer } from "./layers.js";
8
10
  const Wrap = styled.div `position: relative;`;
9
11
  const List = styled.div `
10
12
  max-height: 300px;
@@ -41,12 +43,17 @@ const Spin = styled.span `
41
43
  color: ${v.faint};
42
44
  font-size: 11px;
43
45
  `;
46
+ const EndSpin = styled.span `
47
+ margin-right: 6px;
48
+ color: ${v.faint};
49
+ font-size: 11px;
50
+ `;
44
51
  /**
45
52
  * Combobox: typeahead over a caller-supplied option list. The caller owns the
46
53
  * query (so it can debounce and hit whichever RPC it needs) — this only owns
47
54
  * the open/highlight/keyboard behaviour.
48
55
  */
49
- export function Combobox({ value, onQueryChange, options, onPick, placeholder, label, loading, emptyNote, autoFocus, onSubmit, onBackspaceWhenEmpty }) {
56
+ export function Combobox({ value, onQueryChange, options, onPick, placeholder, label, loading, emptyNote, autoFocus, onSubmit, onBackspaceWhenEmpty, icon, disabled }) {
50
57
  const [open, setOpen] = useState(false);
51
58
  const [active, setActive] = useState(0);
52
59
  const ref = useRef(null);
@@ -69,6 +76,10 @@ export function Combobox({ value, onQueryChange, options, onPick, placeholder, l
69
76
  document.addEventListener("mousedown", onDown);
70
77
  return () => document.removeEventListener("mousedown", onDown);
71
78
  }, [open]);
79
+ const shown = open && !disabled && (options.length > 0 || !!emptyNote);
80
+ // Escape closes the list (while there is one to see) before any drawer or
81
+ // modal it sits in (CON-59)
82
+ useEscapeLayer(shown, () => setOpen(false));
72
83
  const pick = (i) => {
73
84
  const opt = options[i];
74
85
  if (!opt)
@@ -76,31 +87,31 @@ export function Combobox({ value, onQueryChange, options, onPick, placeholder, l
76
87
  onPick(opt.value, opt.key);
77
88
  setOpen(false);
78
89
  };
79
- return (_jsxs(Wrap, { ref: ref, children: [_jsx(Input, { value: value, autoFocus: autoFocus, placeholder: placeholder, "aria-label": label ?? placeholder, autoComplete: "off", onChange: (e) => { onQueryChange(e.target.value); setOpen(true); }, onFocus: () => setOpen(true), onKeyDown: (e) => {
80
- if (e.key === "ArrowDown") {
81
- e.preventDefault();
82
- setOpen(true);
83
- setActive((a) => Math.min(a + 1, options.length - 1));
84
- }
85
- else if (e.key === "ArrowUp") {
86
- e.preventDefault();
87
- setActive((a) => Math.max(a - 1, 0));
88
- }
89
- else if (e.key === "Enter") {
90
- e.preventDefault();
91
- if (open && options.length)
92
- pick(active);
93
- else if (onSubmit && value.trim()) {
94
- onSubmit(value.trim());
95
- setOpen(false);
96
- }
97
- }
98
- else if (e.key === "Backspace" && value === "" && onBackspaceWhenEmpty) {
99
- e.preventDefault();
100
- onBackspaceWhenEmpty();
101
- }
102
- else if (e.key === "Escape")
103
- setOpen(false);
104
- } }), loading ? _jsx(Spin, { children: _jsx(Icon, { name: "spinner", spin: true }) }) : null, open && (options.length > 0 || emptyNote) ? (_jsx(Anchored, { anchor: ref, align: "stretch", gap: 5, layerRef: layer, children: _jsxs(List, { role: "listbox", children: [options.map((o, i) => (_jsx(Option, { role: "option", "aria-selected": i === active, "$on": i === active, onMouseEnter: () => setActive(i), onClick: () => pick(i), children: o.render }, o.key))), options.length === 0 && emptyNote ? _jsx(Note, { children: emptyNote }) : null] }) })) : null] }));
90
+ const input = (_jsx(Input, { value: value, autoFocus: autoFocus, disabled: disabled, placeholder: placeholder, "aria-label": label ?? placeholder, autoComplete: "off", onChange: (e) => { onQueryChange(e.target.value); setOpen(true); }, onFocus: () => setOpen(true), onKeyDown: (e) => {
91
+ if (e.key === "ArrowDown") {
92
+ e.preventDefault();
93
+ setOpen(true);
94
+ setActive((a) => Math.min(a + 1, options.length - 1));
95
+ }
96
+ else if (e.key === "ArrowUp") {
97
+ e.preventDefault();
98
+ setActive((a) => Math.max(a - 1, 0));
99
+ }
100
+ else if (e.key === "Enter") {
101
+ e.preventDefault();
102
+ if (open && options.length)
103
+ pick(active);
104
+ else if (onSubmit && value.trim()) {
105
+ onSubmit(value.trim());
106
+ setOpen(false);
107
+ }
108
+ }
109
+ else if (e.key === "Backspace" && value === "" && onBackspaceWhenEmpty) {
110
+ e.preventDefault();
111
+ onBackspaceWhenEmpty();
112
+ }
113
+ } }));
114
+ const spinner = _jsx(Icon, { name: "spinner", spin: true });
115
+ return (_jsxs(Wrap, { ref: ref, children: [icon ? (_jsx(InputGroup, { icon: icon, disabled: disabled, end: loading ? _jsx(EndSpin, { children: spinner }) : undefined, children: input })) : (_jsxs(_Fragment, { children: [input, loading ? _jsx(Spin, { children: spinner }) : null] })), shown ? (_jsx(Anchored, { anchor: ref, align: "stretch", gap: 5, layerRef: layer, children: _jsxs(List, { role: "listbox", children: [options.map((o, i) => (_jsx(Option, { type: "button", role: "option", "aria-selected": i === active, "$on": i === active, onMouseEnter: () => setActive(i), onMouseDown: (e) => e.preventDefault(), onClick: () => pick(i), children: o.render }, o.key))), options.length === 0 && emptyNote ? _jsx(Note, { children: emptyNote }) : null] }) })) : null] }));
105
116
  }
106
117
  //# sourceMappingURL=Combobox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combobox.js","sourceRoot":"","sources":["../../src/kit/Combobox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACpE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAY,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAE1C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA,qBAAqB,CAAC;AAE7C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAA;;;gBAGP,CAAC,CAAC,OAAO;sBACH,CAAC,CAAC,KAAK;mBACV,CAAC,CAAC,KAAK;gBACV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AAK,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,YAC7L,CAAC,CAAC,MAAM,IADE,CAAC,CAAC,GAAG,CAET,CACV,CAAC,EACD,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAC,IAAI,cAAE,SAAS,GAAQ,CAAC,CAAC,CAAC,IAAI,IAC/D,GACE,CACZ,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,184 @@
1
+ import { type ChangeEvent, type CSSProperties, type HTMLAttributes, type MouseEvent, type ReactNode } from "react";
2
+ import { type IconName } from "./Icon.tsx";
3
+ import { type SegmentedTone } from "./Form.tsx";
4
+ export interface InputGroupProps {
5
+ /** a leading glyph — a magnifier on a search box, a globe on a hostname */
6
+ icon?: IconName | (string & {}) | undefined;
7
+ /** fixed text before the value, inside the box (`https://`) */
8
+ prefix?: ReactNode | undefined;
9
+ /** fixed text after the value, inside the box (`.example.com`, `MB`, `%`) */
10
+ suffix?: ReactNode | undefined;
11
+ /** controls at the trailing edge — a clear button, a reveal toggle */
12
+ end?: ReactNode | undefined;
13
+ /** mono value and affixes, for hostnames, ids and paths */
14
+ mono?: boolean | undefined;
15
+ /** draw the group in error; inside a Field with `error` this is automatic */
16
+ invalid?: boolean | undefined;
17
+ /**
18
+ * The group is off: drawn dimmed, and the input inside is disabled too — a
19
+ * direct child element that does not set `disabled` itself gets
20
+ * `disabled` (1.4). An input nested deeper must be disabled by the caller.
21
+ */
22
+ disabled?: boolean | undefined;
23
+ /** the group's width in px (default: its container's) */
24
+ width?: number | undefined;
25
+ style?: CSSProperties | undefined;
26
+ className?: string | undefined;
27
+ /** the input: a kit `Input`, `MonoInput`, or a plain <input> */
28
+ children: ReactNode;
29
+ }
30
+ /**
31
+ * InputGroup: an input with a glyph, fixed text or controls inside its box.
32
+ * The affixes are part of the field — a subdomain box reads `luke` `.upl.im`
33
+ * as one value — and a click anywhere on the box focuses the input. Unlike
34
+ * SearchBox it holds no state of its own, so it does not debounce: the input
35
+ * inside is the caller's, controlled as they like.
36
+ */
37
+ export declare function InputGroup({ icon, prefix, suffix, end, mono, invalid, disabled, width, style, className, children }: InputGroupProps): import("react").JSX.Element;
38
+ export interface NumberInputProps {
39
+ /** the number, or null for an empty box */
40
+ value: number | null;
41
+ /** a parsed number while typing (unclamped), null for an empty box; clamped to min/max on blur */
42
+ onChange: (value: number | null) => void;
43
+ min?: number | undefined;
44
+ max?: number | undefined;
45
+ /** what ArrowUp/ArrowDown and the stepper add (default 1; Shift ×10) */
46
+ step?: number | undefined;
47
+ /** the unit after the value, inside the box (`MB`, `days`, `%`) */
48
+ unit?: ReactNode | undefined;
49
+ /** fixed text before the value (`$`) */
50
+ prefix?: ReactNode | undefined;
51
+ /** − / + buttons at the trailing edge */
52
+ stepper?: boolean | undefined;
53
+ placeholder?: string | undefined;
54
+ disabled?: boolean | undefined;
55
+ /** width of the whole control in px (default: its container's) */
56
+ width?: number | undefined;
57
+ /** accessible name, when no Field label names it */
58
+ label?: string | undefined;
59
+ id?: string | undefined;
60
+ name?: string | undefined;
61
+ autoFocus?: boolean | undefined;
62
+ /** accept a decimal point (default: only when `step` is fractional) */
63
+ decimal?: boolean | undefined;
64
+ }
65
+ /**
66
+ * NumberInput: a number with its unit, its bounds and a keyboard step. Typed
67
+ * text is held as typed ("1." stays "1.") and handed up parsed; the bounds are
68
+ * applied when the field is left, not while a person is half-way through
69
+ * typing "150" into a box whose minimum is 100. A text input with
70
+ * `role="spinbutton"`, not `type="number"`, so a scroll wheel passing over it
71
+ * never changes the value and "e" is not a digit.
72
+ */
73
+ export declare function NumberInput({ value, onChange, min, max, step, unit, prefix, stepper, placeholder, disabled, width, label, id, name, autoFocus, decimal, }: NumberInputProps): import("react").JSX.Element;
74
+ export interface SliderProps {
75
+ /** controlled value; omit it (and pass `defaultValue`) to let the slider hold it */
76
+ value?: number | undefined;
77
+ defaultValue?: number | undefined;
78
+ /** every movement */
79
+ onChange?: ((value: number) => void) | undefined;
80
+ /** once the pointer or key is released — for a value that costs a request to apply */
81
+ onCommit?: ((value: number) => void) | undefined;
82
+ min?: number | undefined;
83
+ max?: number | undefined;
84
+ step?: number | undefined;
85
+ /** accessible name */
86
+ label: string;
87
+ disabled?: boolean | undefined;
88
+ /** show the value beside the track (default true); a function formats it (`(n) => \`${n}px\``) */
89
+ showValue?: boolean | ((value: number) => ReactNode) | undefined;
90
+ /** width of the whole control in px (default: its container's) */
91
+ width?: number | undefined;
92
+ id?: string | undefined;
93
+ }
94
+ /**
95
+ * Slider: a number picked by feel rather than typed — a stroke width, a blur
96
+ * strength, an opacity. A native range input drawn on the tokens, so the
97
+ * keyboard (arrows, Page Up/Down, Home/End) and the slider role come free.
98
+ * Its value is shown beside it, because a slider whose number you cannot see
99
+ * is a slider people overshoot. Reach for NumberInput when the exact value
100
+ * matters more than the gesture.
101
+ */
102
+ export declare function Slider({ value, defaultValue, onChange, onCommit, min, max, step, label, disabled, showValue, width, id }: SliderProps): import("react").JSX.Element;
103
+ export interface CheckboxProps {
104
+ checked: boolean;
105
+ /**
106
+ * Optional (1.4): a box whose row handles the click itself (`onClick`, or a
107
+ * click on the row) needs none; it stays controlled by `checked` either way.
108
+ */
109
+ onChange?: ((checked: boolean, event: ChangeEvent<HTMLInputElement>) => void) | undefined;
110
+ /** some but not all of what it stands for — a select-all over a partial selection */
111
+ indeterminate?: boolean | undefined;
112
+ disabled?: boolean | undefined;
113
+ /** accessible name — the row it selects ("Select report.pdf") */
114
+ label?: string | undefined;
115
+ /** px (default 16) */
116
+ size?: number | undefined;
117
+ id?: string | undefined;
118
+ name?: string | undefined;
119
+ value?: string | undefined;
120
+ title?: string | undefined;
121
+ /** the click, before onChange — stop it here when the row it sits on is itself a link or a button */
122
+ onClick?: ((e: MouseEvent<HTMLInputElement>) => void) | undefined;
123
+ /** on the box (the outer element), for placing it — absolutely over a card's corner, say */
124
+ className?: string | undefined;
125
+ style?: CSSProperties | undefined;
126
+ }
127
+ /**
128
+ * Checkbox: the box alone, with no label around it — for selecting a table
129
+ * row, a list item or a card, where the row is the label. Toggle and CheckRow
130
+ * wrap their input in a <label>, which inside a row that is itself a link
131
+ * changes what a click activates; this is a real checkbox input the row can
132
+ * stop. `indeterminate` is the select-all over a partial selection.
133
+ */
134
+ export declare function Checkbox({ checked, onChange, indeterminate, disabled, label, size, id, name, value, title, onClick, className, style }: CheckboxProps): import("react").JSX.Element;
135
+ /**
136
+ * TriToggle: On / Off / Inherit — a setting that is either set here or left
137
+ * to whatever the level above says (a bucket inheriting its account's
138
+ * default, a folder its bucket's). `undefined` is Inherit. The chosen segment
139
+ * wears the answer's colour — on is ok, off is crit, inherit neutral — so a
140
+ * column of them reads at a glance. `inherit={false}` drops the third option
141
+ * where there is nothing to inherit from; there, `undefined` means not yet
142
+ * chosen and neither On nor Off is shown selected — showing Off would read as
143
+ * a decision nobody made. The first segment keeps the tab stop.
144
+ */
145
+ export declare function TriToggle({ value, onChange, inherit, labels, inheritHint, tones, disabled, label, size }: {
146
+ value: boolean | undefined;
147
+ onChange: (value: boolean | undefined) => void;
148
+ /** offer Inherit (default true); without it, `undefined` shows nothing selected */
149
+ inherit?: boolean | undefined;
150
+ /** the three captions (default On / Off / Inherit) */
151
+ labels?: {
152
+ on?: ReactNode;
153
+ off?: ReactNode;
154
+ inherit?: ReactNode;
155
+ } | undefined;
156
+ /** what Inherit currently resolves to, as its tooltip ("Inherits: on, from the account") */
157
+ inheritHint?: ReactNode | undefined;
158
+ /** the colour each answer wears when chosen (default on: ok, off: crit, inherit: mut) */
159
+ tones?: {
160
+ on?: SegmentedTone;
161
+ off?: SegmentedTone;
162
+ inherit?: SegmentedTone;
163
+ } | undefined;
164
+ disabled?: boolean | undefined;
165
+ /** accessible name of the group */
166
+ label?: string | undefined;
167
+ size?: "sm" | "md" | undefined;
168
+ }): import("react").JSX.Element;
169
+ /**
170
+ * SettingRow: one setting on one line — its name and what it means on the
171
+ * left, its control on the right. The shape of a settings card that is a list
172
+ * of switches (TriToggle, Toggle, Segmented, a NumberInput) rather than a
173
+ * form of fields; stacks under 640px.
174
+ */
175
+ export declare function SettingRow({ label, hint, dim, children, ...rest }: {
176
+ label: ReactNode;
177
+ /** what the setting does, or why it has no effect right now */
178
+ hint?: ReactNode | undefined;
179
+ /** the setting has no effect right now (its name is muted) */
180
+ dim?: boolean | undefined;
181
+ /** the control */
182
+ children?: ReactNode | undefined;
183
+ } & Omit<HTMLAttributes<HTMLDivElement>, "children">): import("react").JSX.Element;
184
+ //# sourceMappingURL=Controls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../src/kit/Controls.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiF,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlM,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAsC,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAyDpF,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,QAAQ,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5C,+DAA+D;IAC/D,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,6EAA6E;IAC7E,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,sEAAsE;IACtE,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,2DAA2D;IAC3D,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;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