@panneau/ui 0.0.0-stage → 5.0.0-alpha.1
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/README.md +74 -2
- package/dist/alert/Alert.css +78 -0
- package/dist/alert/Alert.d.ts +30 -0
- package/dist/alert/Alert.d.ts.map +1 -0
- package/dist/alert/Alert.js +64 -0
- package/dist/alert/Alert.js.map +1 -0
- package/dist/alert/Alert.module.js +30 -0
- package/dist/alert/Alert.module.js.map +1 -0
- package/dist/badge/Badge.css +60 -0
- package/dist/badge/Badge.d.ts +15 -0
- package/dist/badge/Badge.d.ts.map +1 -0
- package/dist/badge/Badge.js +21 -0
- package/dist/badge/Badge.js.map +1 -0
- package/dist/badge/Badge.module.js +22 -0
- package/dist/badge/Badge.module.js.map +1 -0
- package/dist/button/Button.css +112 -0
- package/dist/button/Button.d.ts +26 -0
- package/dist/button/Button.d.ts.map +1 -0
- package/dist/button/Button.js +39 -0
- package/dist/button/Button.js.map +1 -0
- package/dist/button/Button.module.js +28 -0
- package/dist/button/Button.module.js.map +1 -0
- package/dist/card/Card.css +50 -0
- package/dist/card/Card.d.ts +20 -0
- package/dist/card/Card.d.ts.map +1 -0
- package/dist/card/Card.js +38 -0
- package/dist/card/Card.js.map +1 -0
- package/dist/card/Card.module.js +18 -0
- package/dist/card/Card.module.js.map +1 -0
- package/dist/checkbox/Checkbox.css +79 -0
- package/dist/checkbox/Checkbox.d.ts +11 -0
- package/dist/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/checkbox/Checkbox.js +43 -0
- package/dist/checkbox/Checkbox.js.map +1 -0
- package/dist/checkbox/Checkbox.module.js +16 -0
- package/dist/checkbox/Checkbox.module.js.map +1 -0
- package/dist/checkbox/ChoiceChrome.d.ts +15 -0
- package/dist/checkbox/ChoiceChrome.d.ts.map +1 -0
- package/dist/checkbox/ChoiceChrome.js +36 -0
- package/dist/checkbox/ChoiceChrome.js.map +1 -0
- package/dist/combo-box/ComboBox.css +26 -0
- package/dist/combo-box/ComboBox.d.ts +30 -0
- package/dist/combo-box/ComboBox.d.ts.map +1 -0
- package/dist/combo-box/ComboBox.js +106 -0
- package/dist/combo-box/ComboBox.js.map +1 -0
- package/dist/combo-box/ComboBox.module.js +14 -0
- package/dist/combo-box/ComboBox.module.js.map +1 -0
- package/dist/date-picker/DatePicker.css +135 -0
- package/dist/date-picker/DatePicker.d.ts +12 -0
- package/dist/date-picker/DatePicker.d.ts.map +1 -0
- package/dist/date-picker/DatePicker.js +93 -0
- package/dist/date-picker/DatePicker.js.map +1 -0
- package/dist/date-picker/DatePicker.module.js +30 -0
- package/dist/date-picker/DatePicker.module.js.map +1 -0
- package/dist/dialog/Dialog.css +126 -0
- package/dist/dialog/Dialog.d.ts +31 -0
- package/dist/dialog/Dialog.d.ts.map +1 -0
- package/dist/dialog/Dialog.js +61 -0
- package/dist/dialog/Dialog.js.map +1 -0
- package/dist/dialog/Dialog.module.js +30 -0
- package/dist/dialog/Dialog.module.js.map +1 -0
- package/dist/disclosure/Disclosure.css +54 -0
- package/dist/disclosure/Disclosure.d.ts +20 -0
- package/dist/disclosure/Disclosure.d.ts.map +1 -0
- package/dist/disclosure/Disclosure.js +43 -0
- package/dist/disclosure/Disclosure.js.map +1 -0
- package/dist/disclosure/Disclosure.module.js +22 -0
- package/dist/disclosure/Disclosure.module.js.map +1 -0
- package/dist/field/Field.css +145 -0
- package/dist/field/Field.module.js +30 -0
- package/dist/field/Field.module.js.map +1 -0
- package/dist/field/FieldParts.d.ts +32 -0
- package/dist/field/FieldParts.d.ts.map +1 -0
- package/dist/field/FieldParts.js +56 -0
- package/dist/field/FieldParts.js.map +1 -0
- package/dist/field/Fieldset.d.ts +22 -0
- package/dist/field/Fieldset.d.ts.map +1 -0
- package/dist/field/Fieldset.js +50 -0
- package/dist/field/Fieldset.js.map +1 -0
- package/dist/icon/Icon.css +5 -0
- package/dist/icon/Icon.d.ts +31 -0
- package/dist/icon/Icon.d.ts.map +1 -0
- package/dist/icon/Icon.js +29 -0
- package/dist/icon/Icon.js.map +1 -0
- package/dist/icon/Icon.module.js +8 -0
- package/dist/icon/Icon.module.js.map +1 -0
- package/dist/icon/namedIcons.d.ts +16 -0
- package/dist/icon/namedIcons.d.ts.map +1 -0
- package/dist/icon/namedIcons.js +90 -0
- package/dist/icon/namedIcons.js.map +1 -0
- package/dist/icon-button/IconButton.css +9 -0
- package/dist/icon-button/IconButton.d.ts +15 -0
- package/dist/icon-button/IconButton.d.ts.map +1 -0
- package/dist/icon-button/IconButton.js +26 -0
- package/dist/icon-button/IconButton.js.map +1 -0
- package/dist/icon-button/IconButton.module.js +12 -0
- package/dist/icon-button/IconButton.module.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/intl/messages.d.ts +2 -0
- package/dist/intl/messages.d.ts.map +1 -0
- package/dist/intl/messages.js +1 -0
- package/dist/intl/usePanneauIntl.d.ts +7 -0
- package/dist/intl/usePanneauIntl.d.ts.map +1 -0
- package/dist/intl/usePanneauIntl.js +22 -0
- package/dist/intl/usePanneauIntl.js.map +1 -0
- package/dist/locales/index.d.ts +15 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/index.js +21 -0
- package/dist/locales/index.js.map +1 -0
- package/dist/menu/Menu.d.ts +27 -0
- package/dist/menu/Menu.d.ts.map +1 -0
- package/dist/menu/Menu.js +57 -0
- package/dist/menu/Menu.js.map +1 -0
- package/dist/number-input/NumberInput.css +57 -0
- package/dist/number-input/NumberInput.d.ts +21 -0
- package/dist/number-input/NumberInput.d.ts.map +1 -0
- package/dist/number-input/NumberInput.js +82 -0
- package/dist/number-input/NumberInput.js.map +1 -0
- package/dist/number-input/NumberInput.module.js +16 -0
- package/dist/number-input/NumberInput.module.js.map +1 -0
- package/dist/popover/Popover.css +32 -0
- package/dist/popover/Popover.d.ts +18 -0
- package/dist/popover/Popover.d.ts.map +1 -0
- package/dist/popover/Popover.js +41 -0
- package/dist/popover/Popover.js.map +1 -0
- package/dist/popover/Popover.module.js +14 -0
- package/dist/popover/Popover.module.js.map +1 -0
- package/dist/radio-group/RadioGroup.css +83 -0
- package/dist/radio-group/RadioGroup.d.ts +12 -0
- package/dist/radio-group/RadioGroup.d.ts.map +1 -0
- package/dist/radio-group/RadioGroup.js +61 -0
- package/dist/radio-group/RadioGroup.js.map +1 -0
- package/dist/radio-group/RadioGroup.module.js +20 -0
- package/dist/radio-group/RadioGroup.module.js.map +1 -0
- package/dist/root/PanneauRoot.css +251 -0
- package/dist/root/PanneauRoot.d.ts +34 -0
- package/dist/root/PanneauRoot.d.ts.map +1 -0
- package/dist/root/PanneauRoot.js +84 -0
- package/dist/root/PanneauRoot.js.map +1 -0
- package/dist/root/PanneauRoot.module.js +12 -0
- package/dist/root/PanneauRoot.module.js.map +1 -0
- package/dist/select/ListBox.css +104 -0
- package/dist/select/ListBox.module.js +32 -0
- package/dist/select/ListBox.module.js.map +1 -0
- package/dist/select/Select.d.ts +45 -0
- package/dist/select/Select.d.ts.map +1 -0
- package/dist/select/Select.js +136 -0
- package/dist/select/Select.js.map +1 -0
- package/dist/spinner/Spinner.css +40 -0
- package/dist/spinner/Spinner.d.ts +11 -0
- package/dist/spinner/Spinner.d.ts.map +1 -0
- package/dist/spinner/Spinner.js +25 -0
- package/dist/spinner/Spinner.js.map +1 -0
- package/dist/spinner/Spinner.module.js +18 -0
- package/dist/spinner/Spinner.module.js.map +1 -0
- package/dist/switch/Switch.css +69 -0
- package/dist/switch/Switch.d.ts +11 -0
- package/dist/switch/Switch.d.ts.map +1 -0
- package/dist/switch/Switch.js +33 -0
- package/dist/switch/Switch.js.map +1 -0
- package/dist/switch/Switch.module.js +15 -0
- package/dist/switch/Switch.module.js.map +1 -0
- package/dist/tabs/Tabs.css +83 -0
- package/dist/tabs/Tabs.d.ts +27 -0
- package/dist/tabs/Tabs.d.ts.map +1 -0
- package/dist/tabs/Tabs.js +141 -0
- package/dist/tabs/Tabs.js.map +1 -0
- package/dist/tabs/Tabs.module.js +16 -0
- package/dist/tabs/Tabs.module.js.map +1 -0
- package/dist/text-area/TextArea.css +8 -0
- package/dist/text-area/TextArea.d.ts +11 -0
- package/dist/text-area/TextArea.d.ts.map +1 -0
- package/dist/text-area/TextArea.js +41 -0
- package/dist/text-area/TextArea.js.map +1 -0
- package/dist/text-area/TextArea.module.js +8 -0
- package/dist/text-area/TextArea.module.js.map +1 -0
- package/dist/text-input/TextInput.d.ts +17 -0
- package/dist/text-input/TextInput.d.ts.map +1 -0
- package/dist/text-input/TextInput.js +61 -0
- package/dist/text-input/TextInput.js.map +1 -0
- package/dist/theme/bootstrap.d.ts +8 -0
- package/dist/theme/bootstrap.d.ts.map +1 -0
- package/dist/theme/bootstrap.js +61 -0
- package/dist/theme/bootstrap.js.map +1 -0
- package/dist/theme/theme.d.ts +23 -0
- package/dist/theme/theme.d.ts.map +1 -0
- package/dist/theme/theme.js +30 -0
- package/dist/theme/theme.js.map +1 -0
- package/dist/time-input/TimeInput.d.ts +8 -0
- package/dist/time-input/TimeInput.d.ts.map +1 -0
- package/dist/time-input/TimeInput.js +45 -0
- package/dist/time-input/TimeInput.js.map +1 -0
- package/dist/toast/Toast.css +109 -0
- package/dist/toast/Toast.d.ts +39 -0
- package/dist/toast/Toast.d.ts.map +1 -0
- package/dist/toast/Toast.js +152 -0
- package/dist/toast/Toast.js.map +1 -0
- package/dist/toast/Toast.module.js +30 -0
- package/dist/toast/Toast.module.js.map +1 -0
- package/dist/tooltip/Tooltip.css +25 -0
- package/dist/tooltip/Tooltip.d.ts +19 -0
- package/dist/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/tooltip/Tooltip.js +29 -0
- package/dist/tooltip/Tooltip.js.map +1 -0
- package/dist/tooltip/Tooltip.module.js +12 -0
- package/dist/tooltip/Tooltip.module.js.map +1 -0
- package/dist/utils/cx.d.ts +3 -0
- package/dist/utils/cx.d.ts.map +1 -0
- package/dist/utils/cx.js +9 -0
- package/dist/utils/cx.js.map +1 -0
- package/package.json +48 -5
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/icon/namedIcons.tsx
|
|
4
|
+
var entries = /* @__PURE__ */ new Map();
|
|
5
|
+
var components = /* @__PURE__ */ new Map();
|
|
6
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
var imports = null;
|
|
8
|
+
function subscribe(listener) {
|
|
9
|
+
listeners.add(listener);
|
|
10
|
+
return () => {
|
|
11
|
+
listeners.delete(listener);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function setEntry(name, entry) {
|
|
15
|
+
entries.set(name, entry);
|
|
16
|
+
listeners.forEach((listener) => listener());
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Loads a Lucide icon by its name (`send`, `calendar-days`: the names of lucide.dev/icons), and
|
|
20
|
+
* resolves with its component, or with `null` for a name Lucide doesn't have. Each icon is its own
|
|
21
|
+
* module, and so is the list of names: neither is in the bundle until a named icon is used.
|
|
22
|
+
*/
|
|
23
|
+
function loadNamedIcon(name) {
|
|
24
|
+
const entry = entries.get(name);
|
|
25
|
+
if (entry?.status === "loaded") return Promise.resolve(entry.icon);
|
|
26
|
+
if (entry?.status === "missing") return Promise.resolve(null);
|
|
27
|
+
if (entry === void 0) setEntry(name, { status: "loading" });
|
|
28
|
+
imports ??= import("lucide-react/dynamicIconImports.mjs").then((module) => module.default);
|
|
29
|
+
return imports.then((all) => {
|
|
30
|
+
const load = Object.hasOwn(all, name) ? all[name] : void 0;
|
|
31
|
+
return load !== void 0 ? load().then((module) => module.default) : null;
|
|
32
|
+
}).then((icon) => {
|
|
33
|
+
if (icon === null) {
|
|
34
|
+
console.warn(`[panneau] Lucide has no icon named "${name}".`);
|
|
35
|
+
setEntry(name, { status: "missing" });
|
|
36
|
+
} else setEntry(name, {
|
|
37
|
+
status: "loaded",
|
|
38
|
+
icon
|
|
39
|
+
});
|
|
40
|
+
return icon;
|
|
41
|
+
}, (error) => {
|
|
42
|
+
entries.delete(name);
|
|
43
|
+
imports = null;
|
|
44
|
+
throw error;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* An icon component for a Lucide icon name, as definitions name them (`"icon": "send"`). It goes
|
|
49
|
+
* wherever an icon component goes (`<Button icon={getNamedIcon('send')}>`), and is the same
|
|
50
|
+
* component for the same name. It loads the icon the first time it renders (`loadNamedIcon()`),
|
|
51
|
+
* and renders an empty space of the same size until then. A name Lucide doesn't have renders
|
|
52
|
+
* nothing.
|
|
53
|
+
*/
|
|
54
|
+
function getNamedIcon(name) {
|
|
55
|
+
const existing = components.get(name);
|
|
56
|
+
if (existing !== void 0) return existing;
|
|
57
|
+
const NamedIcon = ({ size = 24, className, ...props }) => {
|
|
58
|
+
const entry = useSyncExternalStore(subscribe, () => entries.get(name), () => entries.get(name));
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (entries.get(name) === void 0) loadNamedIcon(name).catch(() => void 0);
|
|
61
|
+
}, []);
|
|
62
|
+
if (entry?.status === "loaded") {
|
|
63
|
+
const Loaded = entry.icon;
|
|
64
|
+
return /* @__PURE__ */ jsx(Loaded, {
|
|
65
|
+
size,
|
|
66
|
+
className,
|
|
67
|
+
...props
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (entry?.status === "missing") return null;
|
|
71
|
+
const { "aria-hidden": hidden, "aria-label": label, role } = props;
|
|
72
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
73
|
+
width: size,
|
|
74
|
+
height: size,
|
|
75
|
+
viewBox: "0 0 24 24",
|
|
76
|
+
className,
|
|
77
|
+
"aria-hidden": hidden,
|
|
78
|
+
"aria-label": label,
|
|
79
|
+
role,
|
|
80
|
+
"data-loading": ""
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
NamedIcon.displayName = `NamedIcon(${name})`;
|
|
84
|
+
components.set(name, NamedIcon);
|
|
85
|
+
return NamedIcon;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { getNamedIcon, loadNamedIcon };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=namedIcons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namedIcons.js","names":[],"sources":["../../src/icon/namedIcons.tsx"],"sourcesContent":["import { useEffect, useSyncExternalStore } from 'react';\n\nimport type { IconComponent } from './Icon';\n\ntype IconImports = Readonly<Record<string, () => Promise<{ default: IconComponent }>>>;\n\ntype Entry =\n { status: 'loading' } | { status: 'loaded'; icon: IconComponent } | { status: 'missing' };\n\nconst entries = new Map<string, Entry>();\nconst components = new Map<string, IconComponent>();\nconst listeners = new Set<() => void>();\nlet imports: Promise<IconImports> | null = null;\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nfunction setEntry(name: string, entry: Entry) {\n entries.set(name, entry);\n listeners.forEach((listener) => listener());\n}\n\n/**\n * Loads a Lucide icon by its name (`send`, `calendar-days`: the names of lucide.dev/icons), and\n * resolves with its component, or with `null` for a name Lucide doesn't have. Each icon is its own\n * module, and so is the list of names: neither is in the bundle until a named icon is used.\n */\nexport function loadNamedIcon(name: string): Promise<IconComponent | null> {\n const entry = entries.get(name);\n if (entry?.status === 'loaded') {\n return Promise.resolve(entry.icon);\n }\n if (entry?.status === 'missing') {\n return Promise.resolve(null);\n }\n if (entry === undefined) {\n setEntry(name, { status: 'loading' });\n }\n imports ??= import('lucide-react/dynamicIconImports.mjs').then(\n (module) => module.default as unknown as IconImports,\n );\n return imports\n .then((all) => {\n const load = Object.hasOwn(all, name) ? all[name] : undefined;\n return load !== undefined ? load().then((module) => module.default) : null;\n })\n .then(\n (icon) => {\n if (icon === null) {\n console.warn(`[panneau] Lucide has no icon named \"${name}\".`);\n setEntry(name, { status: 'missing' });\n } else {\n setEntry(name, { status: 'loaded', icon });\n }\n return icon;\n },\n (error: unknown) => {\n // A chunk that failed to load (offline): the icon is loaded again when it mounts.\n entries.delete(name);\n imports = null;\n throw error;\n },\n );\n}\n\n/**\n * An icon component for a Lucide icon name, as definitions name them (`\"icon\": \"send\"`). It goes\n * wherever an icon component goes (`<Button icon={getNamedIcon('send')}>`), and is the same\n * component for the same name. It loads the icon the first time it renders (`loadNamedIcon()`),\n * and renders an empty space of the same size until then. A name Lucide doesn't have renders\n * nothing.\n */\nexport function getNamedIcon(name: string): IconComponent {\n const existing = components.get(name);\n if (existing !== undefined) {\n return existing;\n }\n const NamedIcon: IconComponent = ({ size = 24, className, ...props }) => {\n const entry = useSyncExternalStore(\n subscribe,\n () => entries.get(name),\n () => entries.get(name),\n );\n useEffect(() => {\n if (entries.get(name) === undefined) {\n loadNamedIcon(name).catch(() => undefined);\n }\n }, []);\n if (entry?.status === 'loaded') {\n const Loaded = entry.icon;\n return <Loaded size={size} className={className} {...props} />;\n }\n if (entry?.status === 'missing') {\n return null;\n }\n const { 'aria-hidden': hidden, 'aria-label': label, role } = props;\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n className={className}\n aria-hidden={hidden}\n aria-label={label}\n role={role}\n data-loading=\"\"\n />\n );\n };\n NamedIcon.displayName = `NamedIcon(${name})`;\n components.set(name, NamedIcon);\n return NamedIcon;\n}\n"],"mappings":";;;AASA,IAAM,0BAAU,IAAI,IAAmB;AACvC,IAAM,6BAAa,IAAI,IAA2B;AAClD,IAAM,4BAAY,IAAI,IAAgB;AACtC,IAAI,UAAuC;AAE3C,SAAS,UAAU,UAAkC;CACjD,UAAU,IAAI,QAAQ;CACtB,aAAa;EACT,UAAU,OAAO,QAAQ;CAC7B;AACJ;AAEA,SAAS,SAAS,MAAc,OAAc;CAC1C,QAAQ,IAAI,MAAM,KAAK;CACvB,UAAU,SAAS,aAAa,SAAS,CAAC;AAC9C;;;;;;AAOA,SAAgB,cAAc,MAA6C;CACvE,MAAM,QAAQ,QAAQ,IAAI,IAAI;CAC9B,IAAI,OAAO,WAAW,UAClB,OAAO,QAAQ,QAAQ,MAAM,IAAI;CAErC,IAAI,OAAO,WAAW,WAClB,OAAO,QAAQ,QAAQ,IAAI;CAE/B,IAAI,UAAU,KAAA,GACV,SAAS,MAAM,EAAE,QAAQ,UAAU,CAAC;CAExC,YAAY,OAAO,sCAAsC,CAAC,MACrD,WAAW,OAAO,OACvB;CACA,OAAO,QACF,MAAM,QAAQ;EACX,MAAM,OAAO,OAAO,OAAO,KAAK,IAAI,IAAI,IAAI,QAAQ,KAAA;EACpD,OAAO,SAAS,KAAA,IAAY,KAAK,CAAC,CAAC,MAAM,WAAW,OAAO,OAAO,IAAI;CAC1E,CAAC,CAAC,CACD,MACI,SAAS;EACN,IAAI,SAAS,MAAM;GACf,QAAQ,KAAK,uCAAuC,KAAI,GAAI;GAC5D,SAAS,MAAM,EAAE,QAAQ,UAAU,CAAC;EACxC,OACI,SAAS,MAAM;GAAE,QAAQ;GAAU;EAAK,CAAC;EAE7C,OAAO;CACX,IACC,UAAmB;EAEhB,QAAQ,OAAO,IAAI;EACnB,UAAU;EACV,MAAM;CACV,CACJ;AACR;;;;;;;;AASA,SAAgB,aAAa,MAA6B;CACtD,MAAM,WAAW,WAAW,IAAI,IAAI;CACpC,IAAI,aAAa,KAAA,GACb,OAAO;CAEX,MAAM,aAA4B,EAAE,OAAO,IAAI,WAAW,GAAG,YAAY;EACrE,MAAM,QAAQ,qBACV,iBACM,QAAQ,IAAI,IAAI,SAChB,QAAQ,IAAI,IAAI,CAC1B;EACA,gBAAgB;GACZ,IAAI,QAAQ,IAAI,IAAI,MAAM,KAAA,GACtB,cAAc,IAAI,CAAC,CAAC,YAAY,KAAA,CAAS;EAEjD,GAAG,CAAA,CAAE;EACL,IAAI,OAAO,WAAW,UAAU;GAC5B,MAAM,SAAS,MAAM;GACrB,OAAO,oBAAC,QAAD;IAAc;IAAiB;IAAW,GAAI;GAAM,CAAA;EAC/D;EACA,IAAI,OAAO,WAAW,WAClB,OAAO;EAEX,MAAM,EAAE,eAAe,QAAQ,cAAc,OAAO,SAAS;EAC7D,OACI,oBAAC,OAAD;GACI,OAAO;GACP,QAAQ;GACR,SAAQ;GACG;GACX,eAAa;GACb,cAAY;GACN;GACN,gBAAa;EAAE,CAAA;CAG3B;CACA,UAAU,cAAc,aAAa,KAAI;CACzC,WAAW,IAAI,MAAM,SAAS;CAC9B,OAAO;AACX"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* Doubled classes: more specific than the button's own padding, whatever the CSS order. */
|
|
2
|
+
.panneau-iconButton-eXWLoz.panneau-iconButton-eXWLoz {
|
|
3
|
+
width: var(--panneau-control-height);
|
|
4
|
+
padding: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.panneau-iconButton-eXWLoz.panneau-sm-i6-bGf {
|
|
8
|
+
width: var(--panneau-control-height-sm);
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type ButtonProps } from '../button/Button';
|
|
3
|
+
import type { IconComponent } from '../icon/Icon';
|
|
4
|
+
export interface IconButtonProps extends Omit<ButtonProps, 'icon' | 'iconEnd' | 'children' | 'fullWidth' | 'aria-label'> {
|
|
5
|
+
icon: IconComponent;
|
|
6
|
+
/** Accessible label, also shown as a tooltip. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Shows the label in a tooltip on hover and focus. Defaults to true. */
|
|
9
|
+
showTooltip?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
/** A square button with only an icon. Its label is announced and shown as a tooltip. */
|
|
14
|
+
export declare function IconButton({ icon, label, variant, size, showTooltip, className, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=IconButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../src/icon-button/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,MAAM,WAAW,eAAgB,SAAQ,IAAI,CACzC,WAAW,EACX,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAC/D;IACG,IAAI,EAAE,aAAa,CAAC;IACpB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,EACvB,IAAI,EACJ,KAAK,EACL,OAAiB,EACjB,IAAW,EACX,WAAkB,EAClB,SAAS,EACT,GAAG,KAAK,EACX,EAAE,eAAe,+BAejB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cx } from "../utils/cx.js";
|
|
2
|
+
import { Button } from "../button/Button.js";
|
|
3
|
+
import { Tooltip } from "../tooltip/Tooltip.js";
|
|
4
|
+
import IconButton_module_default from "./IconButton.module.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/icon-button/IconButton.tsx
|
|
7
|
+
/** A square button with only an icon. Its label is announced and shown as a tooltip. */
|
|
8
|
+
function IconButton({ icon, label, variant = "ghost", size = "md", showTooltip = true, className, ...props }) {
|
|
9
|
+
const button = /* @__PURE__ */ jsx(Button, {
|
|
10
|
+
...props,
|
|
11
|
+
variant,
|
|
12
|
+
size,
|
|
13
|
+
icon,
|
|
14
|
+
"aria-label": label,
|
|
15
|
+
className: cx(IconButton_module_default.iconButton, size === "sm" && IconButton_module_default.sm, className)
|
|
16
|
+
});
|
|
17
|
+
if (!showTooltip) return button;
|
|
18
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
19
|
+
content: label,
|
|
20
|
+
children: button
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { IconButton };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=IconButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.js","names":["styles"],"sources":["../../src/icon-button/IconButton.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nimport { Button, type ButtonProps } from '../button/Button';\nimport type { IconComponent } from '../icon/Icon';\nimport { Tooltip } from '../tooltip/Tooltip';\nimport { cx } from '../utils/cx';\nimport styles from './IconButton.module.css';\n\nexport interface IconButtonProps extends Omit<\n ButtonProps,\n 'icon' | 'iconEnd' | 'children' | 'fullWidth' | 'aria-label'\n> {\n icon: IconComponent;\n /** Accessible label, also shown as a tooltip. */\n label: string;\n /** Shows the label in a tooltip on hover and focus. Defaults to true. */\n showTooltip?: boolean;\n className?: string;\n style?: CSSProperties;\n}\n\n/** A square button with only an icon. Its label is announced and shown as a tooltip. */\nexport function IconButton({\n icon,\n label,\n variant = 'ghost',\n size = 'md',\n showTooltip = true,\n className,\n ...props\n}: IconButtonProps) {\n const button = (\n <Button\n {...props}\n variant={variant}\n size={size}\n icon={icon}\n aria-label={label}\n className={cx(styles.iconButton, size === 'sm' && styles.sm, className)}\n />\n );\n if (!showTooltip) {\n return button;\n }\n return <Tooltip content={label}>{button}</Tooltip>;\n}\n"],"mappings":";;;;;;;AAsBA,SAAgB,WAAW,EACvB,MACA,OACA,UAAU,SACV,OAAO,MACP,cAAc,MACd,WACA,GAAG,SACa;CAChB,MAAM,SACF,oBAAC,QAAD;EACI,GAAI;EACK;EACH;EACA;EACN,cAAY;EACZ,WAAW,GAAGA,0BAAO,YAAY,SAAS,QAAQA,0BAAO,IAAI,SAAS;CAAE,CAAA;CAGhF,IAAI,CAAC,aACD,OAAO;CAEX,OAAO,oBAAC,SAAD;EAAS,SAAS;EAAQ,UAAA;CAAgB,CAAA;AACrD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./IconButton.css";
|
|
2
|
+
//#region src/icon-button/IconButton.module.css
|
|
3
|
+
var iconButton = "panneau-iconButton-eXWLoz";
|
|
4
|
+
var sm = "panneau-sm-i6-bGf";
|
|
5
|
+
var IconButton_module_default = {
|
|
6
|
+
iconButton,
|
|
7
|
+
sm
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { IconButton_module_default as default, iconButton, sm };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=IconButton.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.module.js","names":[],"sources":["../../src/icon-button/IconButton.module.css"],"sourcesContent":["/* Doubled classes: more specific than the button's own padding, whatever the CSS order. */\n.iconButton.iconButton {\n width: var(--panneau-control-height);\n padding: 0;\n}\n\n.iconButton.sm {\n width: var(--panneau-control-height-sm);\n}\n"],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { Alert, type AlertProps, type AlertTone } from './alert/Alert';
|
|
2
|
+
export { Badge, type BadgeProps, type BadgeTone } from './badge/Badge';
|
|
3
|
+
export { Button, type ButtonProps, type ButtonVariant } from './button/Button';
|
|
4
|
+
export { Card, type CardProps } from './card/Card';
|
|
5
|
+
export { Checkbox, type CheckboxProps } from './checkbox/Checkbox';
|
|
6
|
+
export { type ChoiceChromeProps } from './checkbox/ChoiceChrome';
|
|
7
|
+
export { ComboBox, type ComboBoxItem, type ComboBoxProps } from './combo-box/ComboBox';
|
|
8
|
+
export { DatePicker, type DatePickerProps } from './date-picker/DatePicker';
|
|
9
|
+
export { Dialog, type DialogProps, DialogTrigger } from './dialog/Dialog';
|
|
10
|
+
export { Disclosure, type DisclosureProps } from './disclosure/Disclosure';
|
|
11
|
+
export { type FieldChromeProps } from './field/FieldParts';
|
|
12
|
+
export { Fieldset, type FieldsetProps } from './field/Fieldset';
|
|
13
|
+
export { Icon, type IconComponent, type IconProps, type IconSize } from './icon/Icon';
|
|
14
|
+
export { getNamedIcon, loadNamedIcon } from './icon/namedIcons';
|
|
15
|
+
export { IconButton, type IconButtonProps } from './icon-button/IconButton';
|
|
16
|
+
export { usePanneauIntl } from './intl/usePanneauIntl';
|
|
17
|
+
export { Menu, MenuItem, type MenuItemProps, type MenuProps, MenuSeparator, MenuTrigger, } from './menu/Menu';
|
|
18
|
+
export { NumberInput, type NumberInputProps } from './number-input/NumberInput';
|
|
19
|
+
export { Popover, type PopoverProps, PopoverTrigger } from './popover/Popover';
|
|
20
|
+
export { RadioGroup, type RadioGroupProps } from './radio-group/RadioGroup';
|
|
21
|
+
export { PanneauRoot, type PanneauRootProps, usePortalContainer } from './root/PanneauRoot';
|
|
22
|
+
export { type MultipleSelectProps, type OptionValue, Select, type SelectBaseProps, type SelectOption, type SelectProps, type SingleSelectProps, } from './select/Select';
|
|
23
|
+
export { Spinner, type SpinnerProps } from './spinner/Spinner';
|
|
24
|
+
export { Switch, type SwitchProps } from './switch/Switch';
|
|
25
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, } from './tabs/Tabs';
|
|
26
|
+
export { TextArea, type TextAreaProps } from './text-area/TextArea';
|
|
27
|
+
export { TextInput, type TextInputProps } from './text-input/TextInput';
|
|
28
|
+
export { bootstrapTheme } from './theme/bootstrap';
|
|
29
|
+
export { type ColorScheme, type Theme } from './theme/theme';
|
|
30
|
+
export { TimeInput, type TimeInputProps } from './time-input/TimeInput';
|
|
31
|
+
export { type ToastContent, type ToastOptions, type ToastTone, type Toasts, useToast, } from './toast/Toast';
|
|
32
|
+
export { Tooltip, type TooltipProps } from './tooltip/Tooltip';
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACH,IAAI,EACJ,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,aAAa,EACb,WAAW,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EACH,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,MAAM,EACN,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACH,GAAG,EACH,OAAO,EACP,KAAK,YAAY,EACjB,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,IAAI,EACJ,KAAK,SAAS,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EACH,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,QAAQ,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Icon } from "./icon/Icon.js";
|
|
2
|
+
import { usePanneauIntl } from "./intl/usePanneauIntl.js";
|
|
3
|
+
import { Spinner } from "./spinner/Spinner.js";
|
|
4
|
+
import { Button } from "./button/Button.js";
|
|
5
|
+
import { useToast } from "./toast/Toast.js";
|
|
6
|
+
import { PanneauRoot, usePortalContainer } from "./root/PanneauRoot.js";
|
|
7
|
+
import { Tooltip } from "./tooltip/Tooltip.js";
|
|
8
|
+
import { IconButton } from "./icon-button/IconButton.js";
|
|
9
|
+
import { Alert } from "./alert/Alert.js";
|
|
10
|
+
import { Badge } from "./badge/Badge.js";
|
|
11
|
+
import { Card } from "./card/Card.js";
|
|
12
|
+
import { Checkbox } from "./checkbox/Checkbox.js";
|
|
13
|
+
import { Popover, PopoverTrigger } from "./popover/Popover.js";
|
|
14
|
+
import { ComboBox } from "./combo-box/ComboBox.js";
|
|
15
|
+
import { DatePicker } from "./date-picker/DatePicker.js";
|
|
16
|
+
import { Dialog, DialogTrigger } from "./dialog/Dialog.js";
|
|
17
|
+
import { Disclosure } from "./disclosure/Disclosure.js";
|
|
18
|
+
import { Fieldset } from "./field/Fieldset.js";
|
|
19
|
+
import { getNamedIcon, loadNamedIcon } from "./icon/namedIcons.js";
|
|
20
|
+
import { Menu, MenuItem, MenuSeparator, MenuTrigger } from "./menu/Menu.js";
|
|
21
|
+
import { NumberInput } from "./number-input/NumberInput.js";
|
|
22
|
+
import { RadioGroup } from "./radio-group/RadioGroup.js";
|
|
23
|
+
import { Select } from "./select/Select.js";
|
|
24
|
+
import { Switch } from "./switch/Switch.js";
|
|
25
|
+
import { Tab, TabList, TabPanel, Tabs } from "./tabs/Tabs.js";
|
|
26
|
+
import { TextArea } from "./text-area/TextArea.js";
|
|
27
|
+
import { TextInput } from "./text-input/TextInput.js";
|
|
28
|
+
import { bootstrapTheme } from "./theme/bootstrap.js";
|
|
29
|
+
import { TimeInput } from "./time-input/TimeInput.js";
|
|
30
|
+
export { Alert, Badge, Button, Card, Checkbox, ComboBox, DatePicker, Dialog, DialogTrigger, Disclosure, Fieldset, Icon, IconButton, Menu, MenuItem, MenuSeparator, MenuTrigger, NumberInput, PanneauRoot, Popover, PopoverTrigger, RadioGroup, Select, Spinner, Switch, Tab, TabList, TabPanel, Tabs, TextArea, TextInput, TimeInput, Tooltip, bootstrapTheme, getNamedIcon, loadNamedIcon, usePanneauIntl, usePortalContainer, useToast };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/intl/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { uiMessages as messages } from "@panneau/intl";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl';
|
|
2
|
+
/**
|
|
3
|
+
* The react-intl object of the closest `IntlProvider`. Without a provider, an English one with the
|
|
4
|
+
* default messages, so that Panneau components also render outside of an internationalized app.
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePanneauIntl(): IntlShape;
|
|
7
|
+
//# sourceMappingURL=usePanneauIntl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePanneauIntl.d.ts","sourceRoot":"","sources":["../../src/intl/usePanneauIntl.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,SAAS,EAA+B,MAAM,YAAY,CAAC;AAItF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,SAAS,CAO1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { use } from "react";
|
|
2
|
+
import { IntlContext, createIntl, createIntlCache } from "react-intl";
|
|
3
|
+
//#region src/intl/usePanneauIntl.ts
|
|
4
|
+
var fallback = null;
|
|
5
|
+
/**
|
|
6
|
+
* The react-intl object of the closest `IntlProvider`. Without a provider, an English one with the
|
|
7
|
+
* default messages, so that Panneau components also render outside of an internationalized app.
|
|
8
|
+
*/
|
|
9
|
+
function usePanneauIntl() {
|
|
10
|
+
const intl = use(IntlContext);
|
|
11
|
+
if (intl !== null && intl !== void 0) return intl;
|
|
12
|
+
fallback ??= createIntl({
|
|
13
|
+
locale: "en",
|
|
14
|
+
defaultLocale: "en",
|
|
15
|
+
messages: {}
|
|
16
|
+
}, createIntlCache());
|
|
17
|
+
return fallback;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { usePanneauIntl };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=usePanneauIntl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePanneauIntl.js","names":[],"sources":["../../src/intl/usePanneauIntl.ts"],"sourcesContent":["import { use } from 'react';\nimport { IntlContext, type IntlShape, createIntl, createIntlCache } from 'react-intl';\n\nlet fallback: IntlShape | null = null;\n\n/**\n * The react-intl object of the closest `IntlProvider`. Without a provider, an English one with the\n * default messages, so that Panneau components also render outside of an internationalized app.\n */\nexport function usePanneauIntl(): IntlShape {\n const intl = use(IntlContext) as IntlShape | null | undefined;\n if (intl !== null && intl !== undefined) {\n return intl;\n }\n fallback ??= createIntl({ locale: 'en', defaultLocale: 'en', messages: {} }, createIntlCache());\n return fallback;\n}\n"],"mappings":";;;AAGA,IAAI,WAA6B;;;;;AAMjC,SAAgB,iBAA4B;CACxC,MAAM,OAAO,IAAI,WAAW;CAC5B,IAAI,SAAS,QAAQ,SAAS,KAAA,GAC1B,OAAO;CAEX,aAAa,WAAW;EAAE,QAAQ;EAAM,eAAe;EAAM,UAAU,CAAC;CAAE,GAAG,gBAAgB,CAAC;CAC9F,OAAO;AACX"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The English messages of `@panneau/ui`, by id. They are also the default messages.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Use `en`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages
|
|
5
|
+
* of every package.
|
|
6
|
+
*/
|
|
7
|
+
export declare const en: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* The French messages of `@panneau/ui`, by id.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Use `fr`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages
|
|
12
|
+
* of every package.
|
|
13
|
+
*/
|
|
14
|
+
export declare const fr: Record<string, string>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAgC,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAErC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { messages } from "../intl/messages.js";
|
|
2
|
+
import { fr as fr$1, getDefaultMessages } from "@panneau/intl";
|
|
3
|
+
//#region src/locales/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The English messages of `@panneau/ui`, by id. They are also the default messages.
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use `en`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages
|
|
8
|
+
* of every package.
|
|
9
|
+
*/
|
|
10
|
+
var en = getDefaultMessages(messages);
|
|
11
|
+
/**
|
|
12
|
+
* The French messages of `@panneau/ui`, by id.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Use `fr`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages
|
|
15
|
+
* of every package.
|
|
16
|
+
*/
|
|
17
|
+
var fr = Object.fromEntries(Object.entries(fr$1).filter(([id]) => id in en));
|
|
18
|
+
//#endregion
|
|
19
|
+
export { en, fr };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["allFr"],"sources":["../../src/locales/index.ts"],"sourcesContent":["import { fr as allFr, getDefaultMessages } from '@panneau/intl';\n\nimport { messages } from '../intl/messages';\n\n/**\n * The English messages of `@panneau/ui`, by id. They are also the default messages.\n *\n * @deprecated Use `en`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const en: Record<string, string> = getDefaultMessages(messages);\n\n/**\n * The French messages of `@panneau/ui`, by id.\n *\n * @deprecated Use `fr`, or `withPanneauMessages()`, from `@panneau/intl`: they have the messages\n * of every package.\n */\nexport const fr: Record<string, string> = Object.fromEntries(\n Object.entries(allFr).filter(([id]) => id in en),\n);\n"],"mappings":";;;;;;;;;AAUA,IAAa,KAA6B,mBAAmB,QAAQ;;;;;;;AAQrE,IAAa,KAA6B,OAAO,YAC7C,OAAO,QAAQA,IAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,MAAM,EAAE,CACnD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type MenuItemProps as AriaMenuItemProps, type MenuProps as AriaMenuProps } from 'react-aria-components';
|
|
3
|
+
import { type IconComponent } from '../icon/Icon';
|
|
4
|
+
export interface MenuProps<T extends object> extends Omit<AriaMenuProps<T>, 'className' | 'style'> {
|
|
5
|
+
className?: string;
|
|
6
|
+
popoverClassName?: string;
|
|
7
|
+
placement?: 'bottom start' | 'bottom end' | 'top start' | 'top end';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A menu of actions, inside a `MenuTrigger` with its button as the first child. Arrow keys move
|
|
11
|
+
* between items, and typing a letter jumps to an item.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Menu<T extends object>({ className, popoverClassName, placement, ...props }: MenuProps<T>): import("react").JSX.Element;
|
|
14
|
+
export interface MenuItemProps extends Omit<AriaMenuItemProps, 'className' | 'style' | 'children'> {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
icon?: IconComponent;
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Styles the item as destructive. */
|
|
19
|
+
isDanger?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/** An item of a `Menu`. */
|
|
23
|
+
export declare function MenuItem({ children, icon, description, isDanger, className, textValue, ...props }: MenuItemProps): import("react").JSX.Element;
|
|
24
|
+
/** A line between groups of menu items. */
|
|
25
|
+
export declare function MenuSeparator(): import("react").JSX.Element;
|
|
26
|
+
export { MenuTrigger } from 'react-aria-components';
|
|
27
|
+
//# sourceMappingURL=Menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../src/menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAGH,KAAK,aAAa,IAAI,iBAAiB,EACvC,KAAK,SAAS,IAAI,aAAa,EAGlC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAQ,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAKxD,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;CACvE;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,EACnC,SAAS,EACT,gBAAgB,EAChB,SAA0B,EAC1B,GAAG,KAAK,EACX,EAAE,SAAS,CAAC,CAAC,CAAC,+BAMd;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;IAC9F,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,2BAA2B;AAC3B,wBAAgB,QAAQ,CAAC,EACrB,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,QAAgB,EAChB,SAAS,EACT,SAAS,EACT,GAAG,KAAK,EACX,EAAE,aAAa,+BAqBf;AAED,2CAA2C;AAC3C,wBAAgB,aAAa,gCAE5B;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { cx } from "../utils/cx.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import { PopoverSurface } from "../popover/Popover.js";
|
|
4
|
+
import ListBox_module_default from "../select/ListBox.module.js";
|
|
5
|
+
import { Menu, MenuItem, MenuTrigger, Separator, Text } from "react-aria-components";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
//#region src/menu/Menu.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A menu of actions, inside a `MenuTrigger` with its button as the first child. Arrow keys move
|
|
11
|
+
* between items, and typing a letter jumps to an item.
|
|
12
|
+
*/
|
|
13
|
+
function Menu$1({ className, popoverClassName, placement = "bottom start", ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx(PopoverSurface, {
|
|
15
|
+
placement,
|
|
16
|
+
className: popoverClassName,
|
|
17
|
+
children: /* @__PURE__ */ jsx(Menu, {
|
|
18
|
+
...props,
|
|
19
|
+
className: cx(ListBox_module_default.listBox, className)
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** An item of a `Menu`. */
|
|
24
|
+
function MenuItem$1({ children, icon, description, isDanger = false, className, textValue, ...props }) {
|
|
25
|
+
return /* @__PURE__ */ jsxs(MenuItem, {
|
|
26
|
+
...props,
|
|
27
|
+
textValue: textValue ?? (typeof children === "string" ? children : void 0),
|
|
28
|
+
className: cx(ListBox_module_default.item, className),
|
|
29
|
+
"data-danger": isDanger || void 0,
|
|
30
|
+
children: [icon !== void 0 ? /* @__PURE__ */ jsx(Icon, { icon }) : null, /* @__PURE__ */ jsxs("span", {
|
|
31
|
+
className: ListBox_module_default.itemText,
|
|
32
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
33
|
+
slot: "label",
|
|
34
|
+
className: ListBox_module_default.itemLabel,
|
|
35
|
+
children
|
|
36
|
+
}), description !== void 0 ? /* @__PURE__ */ jsx(Text, {
|
|
37
|
+
slot: "description",
|
|
38
|
+
className: ListBox_module_default.itemDescription,
|
|
39
|
+
children: description
|
|
40
|
+
}) : null]
|
|
41
|
+
})]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** A line between groups of menu items. */
|
|
45
|
+
function MenuSeparator() {
|
|
46
|
+
const $ = c(1);
|
|
47
|
+
let t0;
|
|
48
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
+
t0 = /* @__PURE__ */ jsx(Separator, { className: ListBox_module_default.separator });
|
|
50
|
+
$[0] = t0;
|
|
51
|
+
} else t0 = $[0];
|
|
52
|
+
return t0;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Menu$1 as Menu, MenuItem$1 as MenuItem, MenuSeparator, MenuTrigger };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=Menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Menu.js","names":["Menu","AriaMenu","styles","MenuItem","AriaMenuItem","_c"],"sources":["../../src/menu/Menu.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n Menu as AriaMenu,\n MenuItem as AriaMenuItem,\n type MenuItemProps as AriaMenuItemProps,\n type MenuProps as AriaMenuProps,\n Separator,\n Text,\n} from 'react-aria-components';\n\nimport { Icon, type IconComponent } from '../icon/Icon';\nimport { PopoverSurface } from '../popover/Popover';\nimport styles from '../select/ListBox.module.css';\nimport { cx } from '../utils/cx';\n\nexport interface MenuProps<T extends object> extends Omit<AriaMenuProps<T>, 'className' | 'style'> {\n className?: string;\n popoverClassName?: string;\n placement?: 'bottom start' | 'bottom end' | 'top start' | 'top end';\n}\n\n/**\n * A menu of actions, inside a `MenuTrigger` with its button as the first child. Arrow keys move\n * between items, and typing a letter jumps to an item.\n */\nexport function Menu<T extends object>({\n className,\n popoverClassName,\n placement = 'bottom start',\n ...props\n}: MenuProps<T>) {\n return (\n <PopoverSurface placement={placement} className={popoverClassName}>\n <AriaMenu {...props} className={cx(styles.listBox, className)} />\n </PopoverSurface>\n );\n}\n\nexport interface MenuItemProps extends Omit<AriaMenuItemProps, 'className' | 'style' | 'children'> {\n children?: ReactNode;\n icon?: IconComponent;\n description?: string;\n /** Styles the item as destructive. */\n isDanger?: boolean;\n className?: string;\n}\n\n/** An item of a `Menu`. */\nexport function MenuItem({\n children,\n icon,\n description,\n isDanger = false,\n className,\n textValue,\n ...props\n}: MenuItemProps) {\n return (\n <AriaMenuItem\n {...props}\n textValue={textValue ?? (typeof children === 'string' ? children : undefined)}\n className={cx(styles.item, className)}\n data-danger={isDanger || undefined}\n >\n {icon !== undefined ? <Icon icon={icon} /> : null}\n <span className={styles.itemText}>\n <Text slot=\"label\" className={styles.itemLabel}>\n {children}\n </Text>\n {description !== undefined ? (\n <Text slot=\"description\" className={styles.itemDescription}>\n {description}\n </Text>\n ) : null}\n </span>\n </AriaMenuItem>\n );\n}\n\n/** A line between groups of menu items. */\nexport function MenuSeparator() {\n return <Separator className={styles.separator} />;\n}\n\nexport { MenuTrigger } from 'react-aria-components';\n"],"mappings":";;;;;;;;;;;;AAyBA,SAAgBA,OAAuB,EACnC,WACA,kBACA,YAAY,gBACZ,GAAG,SACU;CACb,OACI,oBAAC,gBAAD;EAA2B;EAAW,WAAW;EAC7C,UAAA,oBAACC,MAAD;GAAU,GAAI;GAAO,WAAW,GAAGC,uBAAO,SAAS,SAAS;EAAE,CAAA;CAClD,CAAA;AAExB;;AAYA,SAAgBC,WAAS,EACrB,UACA,MACA,aACA,WAAW,OACX,WACA,WACA,GAAG,SACW;CACd,OACI,qBAACC,UAAD;EACI,GAAI;EACJ,WAAW,cAAc,OAAO,aAAa,WAAW,WAAW,KAAA;EACnE,WAAW,GAAGF,uBAAO,MAAM,SAAS;EACpC,eAAa,YAAY,KAAA;EAJ7B,UAAA,CAMK,SAAS,KAAA,IAAY,oBAAC,MAAD,EAAY,KAAK,CAAA,IAAM,MAC7C,qBAAC,QAAD;GAAM,WAAWA,uBAAO;GAAxB,UAAA,CACI,oBAAC,MAAD;IAAM,MAAK;IAAQ,WAAWA,uBAAO;IAChC;GACC,CAAA,GACL,gBAAgB,KAAA,IACb,oBAAC,MAAD;IAAM,MAAK;IAAc,WAAWA,uBAAO;IACtC,UAAA;GACC,CAAA,IACN,IACF;EACI,CAAA,CAAA;;AAEtB;;AAGA,SAAO,gBAAA;CAAA,MAAA,IAAAG,EAAA,CAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,OAAA,IAAA,2BAAA,GAAA;EACI,KAAA,oBAAC,WAAD,EAAsB,WAAAH,uBAAM,UAAU,CAAA;EAAI,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OAA1C;AAA0C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.panneau-control-4aptNi.panneau-control-4aptNi {
|
|
2
|
+
padding-inline-end: 0;
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.panneau-input-qqs-MV {
|
|
7
|
+
font-variant-numeric: tabular-nums;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.panneau-steppers-JoTs6w {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-self: stretch;
|
|
14
|
+
border-inline-start: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.panneau-stepper-sAGR2f {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex: 1 1 0;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: 1.75rem;
|
|
23
|
+
padding: 0;
|
|
24
|
+
color: var(--panneau-color-text-muted);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
background: transparent;
|
|
27
|
+
border: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.panneau-stepper-sAGR2f + .panneau-stepper-sAGR2f {
|
|
31
|
+
border-top: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.panneau-stepper-sAGR2f[data-hovered] {
|
|
35
|
+
color: var(--panneau-color-text);
|
|
36
|
+
background-color: var(--panneau-color-hover);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.panneau-stepper-sAGR2f[data-pressed] {
|
|
40
|
+
background-color: var(--panneau-color-pressed);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.panneau-stepper-sAGR2f[data-disabled] {
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
opacity: 0.5;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Touch screens have their own keyboard for numbers: the steppers would be too small. */
|
|
49
|
+
@media (pointer: coarse) {
|
|
50
|
+
.panneau-steppers-JoTs6w {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.panneau-control-4aptNi.panneau-control-4aptNi {
|
|
55
|
+
padding-inline-end: var(--panneau-space-3);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type NumberFieldProps as AriaNumberFieldProps } from 'react-aria-components';
|
|
3
|
+
import { type FieldChromeProps } from '../field/FieldParts';
|
|
4
|
+
export interface NumberInputProps extends Omit<AriaNumberFieldProps, 'className' | 'style' | 'children' | 'isInvalid' | 'validate' | 'value' | 'defaultValue' | 'onChange'>, FieldChromeProps {
|
|
5
|
+
/** The number, or `null` when empty. */
|
|
6
|
+
value?: number | null;
|
|
7
|
+
defaultValue?: number | null;
|
|
8
|
+
/** Called with the number, or `null` when the input is cleared. */
|
|
9
|
+
onChange?: (value: number | null) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** Content after the number, inside the control: a unit. */
|
|
12
|
+
suffix?: ReactNode;
|
|
13
|
+
controlClassName?: string;
|
|
14
|
+
inputClassName?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A number input, formatted for the locale, with steppers and arrow keys. An empty input is
|
|
18
|
+
* `null`, not `NaN`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function NumberInput({ label, description, errors, value, defaultValue, onChange, placeholder, suffix, className, labelClassName, descriptionClassName, errorsClassName, controlClassName, inputClassName, isRequired, isReadOnly, ...props }: NumberInputProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=NumberInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../src/number-input/NumberInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EACH,KAAK,gBAAgB,IAAI,oBAAoB,EAKhD,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,KAAK,gBAAgB,EAKxB,MAAM,qBAAqB,CAAC;AAK7B,MAAM,WAAW,gBACb,SACI,IAAI,CACA,oBAAoB,EAClB,WAAW,GACX,OAAO,GACP,UAAU,GACV,WAAW,GACX,UAAU,GACV,OAAO,GACP,cAAc,GACd,UAAU,CACf,EACD,gBAAgB;IACpB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,WAAW,EACX,MAAW,EACX,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,MAAM,EACN,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,GAAG,KAAK,EACX,EAAE,gBAAgB,+BA4ClB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { cx } from "../utils/cx.js";
|
|
2
|
+
import { Icon } from "../icon/Icon.js";
|
|
3
|
+
import Field_module_default from "../field/Field.module.js";
|
|
4
|
+
import { FieldDescription, FieldErrors, FieldLabel } from "../field/FieldParts.js";
|
|
5
|
+
import NumberInput_module_default from "./NumberInput.module.js";
|
|
6
|
+
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
7
|
+
import { Button, Group, Input, NumberField } from "react-aria-components";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/number-input/NumberInput.tsx
|
|
10
|
+
function toAria(value) {
|
|
11
|
+
return value === null ? NaN : value;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A number input, formatted for the locale, with steppers and arrow keys. An empty input is
|
|
15
|
+
* `null`, not `NaN`.
|
|
16
|
+
*/
|
|
17
|
+
function NumberInput({ label, description, errors = [], value, defaultValue, onChange, placeholder, suffix, className, labelClassName, descriptionClassName, errorsClassName, controlClassName, inputClassName, isRequired, isReadOnly, ...props }) {
|
|
18
|
+
const invalid = errors.length > 0;
|
|
19
|
+
return /* @__PURE__ */ jsxs(NumberField, {
|
|
20
|
+
...props,
|
|
21
|
+
value: toAria(value),
|
|
22
|
+
defaultValue: toAria(defaultValue),
|
|
23
|
+
onChange: (next) => onChange?.(Number.isNaN(next) ? null : next),
|
|
24
|
+
isRequired,
|
|
25
|
+
isReadOnly,
|
|
26
|
+
isInvalid: invalid,
|
|
27
|
+
validationBehavior: "aria",
|
|
28
|
+
className: cx(Field_module_default.field, className),
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
31
|
+
isRequired,
|
|
32
|
+
className: labelClassName,
|
|
33
|
+
children: label
|
|
34
|
+
}),
|
|
35
|
+
/* @__PURE__ */ jsxs(Group, {
|
|
36
|
+
className: cx(Field_module_default.control, NumberInput_module_default.control, controlClassName),
|
|
37
|
+
"data-invalid": invalid || void 0,
|
|
38
|
+
"data-readonly": isReadOnly || void 0,
|
|
39
|
+
children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Input, {
|
|
41
|
+
placeholder,
|
|
42
|
+
className: cx(Field_module_default.bare, NumberInput_module_default.input, inputClassName)
|
|
43
|
+
}),
|
|
44
|
+
suffix !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: Field_module_default.adornment,
|
|
46
|
+
children: suffix
|
|
47
|
+
}) : null,
|
|
48
|
+
isReadOnly !== true ? /* @__PURE__ */ jsxs("span", {
|
|
49
|
+
className: NumberInput_module_default.steppers,
|
|
50
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
51
|
+
slot: "increment",
|
|
52
|
+
className: NumberInput_module_default.stepper,
|
|
53
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
54
|
+
icon: ChevronUp,
|
|
55
|
+
size: "xs"
|
|
56
|
+
})
|
|
57
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
58
|
+
slot: "decrement",
|
|
59
|
+
className: NumberInput_module_default.stepper,
|
|
60
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
61
|
+
icon: ChevronDown,
|
|
62
|
+
size: "xs"
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
}) : null
|
|
66
|
+
]
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx(FieldDescription, {
|
|
69
|
+
className: descriptionClassName,
|
|
70
|
+
children: description
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(FieldErrors, {
|
|
73
|
+
errors,
|
|
74
|
+
className: errorsClassName
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { NumberInput };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=NumberInput.js.map
|