@kizunacms/ui 0.0.0-stage → 0.1.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/LICENSE.MD +9 -0
- package/README.md +20 -2
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/admin.css +2158 -0
- package/dist/client.cjs +99 -0
- package/dist/client.d.cts +46 -0
- package/dist/client.d.mts +46 -0
- package/dist/client.mjs +45 -0
- package/dist/controls/AdminLink.cjs +21 -0
- package/dist/controls/AdminLink.d.cts +16 -0
- package/dist/controls/AdminLink.d.mts +16 -0
- package/dist/controls/AdminLink.mjs +20 -0
- package/dist/controls/Avatar.cjs +15 -0
- package/dist/controls/Avatar.d.cts +17 -0
- package/dist/controls/Avatar.d.mts +17 -0
- package/dist/controls/Avatar.mjs +14 -0
- package/dist/controls/Button.cjs +20 -0
- package/dist/controls/Button.d.cts +18 -0
- package/dist/controls/Button.d.mts +18 -0
- package/dist/controls/Button.mjs +18 -0
- package/dist/controls/ButtonTip.cjs +40 -0
- package/dist/controls/ButtonTip.mjs +39 -0
- package/dist/controls/Checkbox.cjs +27 -0
- package/dist/controls/Checkbox.d.cts +15 -0
- package/dist/controls/Checkbox.d.mts +15 -0
- package/dist/controls/Checkbox.mjs +26 -0
- package/dist/controls/ChipsInput.cjs +145 -0
- package/dist/controls/ChipsInput.mjs +143 -0
- package/dist/controls/ConfirmDialog.cjs +63 -0
- package/dist/controls/ConfirmDialog.d.cts +38 -0
- package/dist/controls/ConfirmDialog.d.mts +38 -0
- package/dist/controls/ConfirmDialog.mjs +62 -0
- package/dist/controls/Counter.cjs +18 -0
- package/dist/controls/Counter.mjs +17 -0
- package/dist/controls/InfoTip.cjs +29 -0
- package/dist/controls/InfoTip.d.cts +11 -0
- package/dist/controls/InfoTip.d.mts +11 -0
- package/dist/controls/InfoTip.mjs +28 -0
- package/dist/controls/LocalTime.cjs +62 -0
- package/dist/controls/LocalTime.d.cts +30 -0
- package/dist/controls/LocalTime.d.mts +30 -0
- package/dist/controls/LocalTime.mjs +61 -0
- package/dist/controls/Logo.cjs +56 -0
- package/dist/controls/Logo.d.cts +13 -0
- package/dist/controls/Logo.d.mts +13 -0
- package/dist/controls/Logo.mjs +54 -0
- package/dist/controls/MenuButton.cjs +118 -0
- package/dist/controls/MenuButton.d.cts +88 -0
- package/dist/controls/MenuButton.d.mts +88 -0
- package/dist/controls/MenuButton.mjs +117 -0
- package/dist/controls/Select.cjs +67 -0
- package/dist/controls/Select.d.cts +42 -0
- package/dist/controls/Select.d.mts +42 -0
- package/dist/controls/Select.mjs +66 -0
- package/dist/controls/Status.cjs +31 -0
- package/dist/controls/Status.d.cts +14 -0
- package/dist/controls/Status.d.mts +14 -0
- package/dist/controls/Status.mjs +30 -0
- package/dist/controls/TrailingButton.cjs +22 -0
- package/dist/controls/TrailingButton.d.cts +18 -0
- package/dist/controls/TrailingButton.d.mts +18 -0
- package/dist/controls/TrailingButton.mjs +21 -0
- package/dist/controls/icon.cjs +42 -0
- package/dist/controls/icon.mjs +38 -0
- package/dist/inputs/Affixed.cjs +49 -0
- package/dist/inputs/Affixed.mjs +47 -0
- package/dist/inputs/CheckboxField.cjs +22 -0
- package/dist/inputs/CheckboxField.d.cts +10 -0
- package/dist/inputs/CheckboxField.d.mts +10 -0
- package/dist/inputs/CheckboxField.mjs +21 -0
- package/dist/inputs/DateField.cjs +22 -0
- package/dist/inputs/DateField.d.cts +10 -0
- package/dist/inputs/DateField.d.mts +10 -0
- package/dist/inputs/DateField.mjs +21 -0
- package/dist/inputs/DateTimeField.cjs +56 -0
- package/dist/inputs/DateTimeField.d.cts +10 -0
- package/dist/inputs/DateTimeField.d.mts +10 -0
- package/dist/inputs/DateTimeField.mjs +55 -0
- package/dist/inputs/EmailField.cjs +20 -0
- package/dist/inputs/EmailField.d.cts +10 -0
- package/dist/inputs/EmailField.d.mts +10 -0
- package/dist/inputs/EmailField.mjs +19 -0
- package/dist/inputs/FallbackReset.cjs +23 -0
- package/dist/inputs/FallbackReset.mjs +21 -0
- package/dist/inputs/FieldFor.cjs +48 -0
- package/dist/inputs/FieldFor.d.cts +16 -0
- package/dist/inputs/FieldFor.d.mts +16 -0
- package/dist/inputs/FieldFor.mjs +46 -0
- package/dist/inputs/FieldFrame.cjs +97 -0
- package/dist/inputs/FieldFrame.d.cts +29 -0
- package/dist/inputs/FieldFrame.d.mts +29 -0
- package/dist/inputs/FieldFrame.mjs +95 -0
- package/dist/inputs/FieldList.cjs +39 -0
- package/dist/inputs/FieldList.d.cts +16 -0
- package/dist/inputs/FieldList.d.mts +16 -0
- package/dist/inputs/FieldList.mjs +38 -0
- package/dist/inputs/FileField.cjs +363 -0
- package/dist/inputs/FileField.d.cts +10 -0
- package/dist/inputs/FileField.d.mts +10 -0
- package/dist/inputs/FileField.mjs +362 -0
- package/dist/inputs/FocalPointPicker.cjs +114 -0
- package/dist/inputs/FocalPointPicker.mjs +113 -0
- package/dist/inputs/JsonField.cjs +21 -0
- package/dist/inputs/JsonField.d.cts +10 -0
- package/dist/inputs/JsonField.d.mts +10 -0
- package/dist/inputs/JsonField.mjs +20 -0
- package/dist/inputs/NumberField.cjs +42 -0
- package/dist/inputs/NumberField.d.cts +10 -0
- package/dist/inputs/NumberField.d.mts +10 -0
- package/dist/inputs/NumberField.mjs +41 -0
- package/dist/inputs/PasswordField.cjs +41 -0
- package/dist/inputs/PasswordField.d.cts +26 -0
- package/dist/inputs/PasswordField.d.mts +26 -0
- package/dist/inputs/PasswordField.mjs +39 -0
- package/dist/inputs/PickerButton.cjs +56 -0
- package/dist/inputs/PickerButton.mjs +55 -0
- package/dist/inputs/RelationshipField.cjs +162 -0
- package/dist/inputs/RelationshipField.d.cts +10 -0
- package/dist/inputs/RelationshipField.d.mts +10 -0
- package/dist/inputs/RelationshipField.mjs +161 -0
- package/dist/inputs/SelectField.cjs +79 -0
- package/dist/inputs/SelectField.d.cts +10 -0
- package/dist/inputs/SelectField.d.mts +10 -0
- package/dist/inputs/SelectField.mjs +78 -0
- package/dist/inputs/SlugField.cjs +71 -0
- package/dist/inputs/SlugField.d.cts +11 -0
- package/dist/inputs/SlugField.d.mts +11 -0
- package/dist/inputs/SlugField.mjs +69 -0
- package/dist/inputs/TextBox.cjs +41 -0
- package/dist/inputs/TextBox.d.cts +35 -0
- package/dist/inputs/TextBox.d.mts +35 -0
- package/dist/inputs/TextBox.mjs +39 -0
- package/dist/inputs/TextField.cjs +61 -0
- package/dist/inputs/TextField.d.cts +10 -0
- package/dist/inputs/TextField.d.mts +10 -0
- package/dist/inputs/TextField.mjs +60 -0
- package/dist/inputs/TitleField.cjs +76 -0
- package/dist/inputs/TitleField.mjs +75 -0
- package/dist/inputs/UrlField.cjs +20 -0
- package/dist/inputs/UrlField.d.cts +10 -0
- package/dist/inputs/UrlField.d.mts +10 -0
- package/dist/inputs/UrlField.mjs +19 -0
- package/dist/inputs/values.cjs +4 -0
- package/dist/inputs/values.d.cts +19 -0
- package/dist/inputs/values.d.mts +19 -0
- package/dist/inputs/values.mjs +4 -0
- package/dist/screens/AccountView.cjs +173 -0
- package/dist/screens/AccountView.d.cts +18 -0
- package/dist/screens/AccountView.d.mts +18 -0
- package/dist/screens/AccountView.mjs +172 -0
- package/dist/screens/AdminShell.cjs +136 -0
- package/dist/screens/AdminShell.d.cts +31 -0
- package/dist/screens/AdminShell.d.mts +31 -0
- package/dist/screens/AdminShell.mjs +135 -0
- package/dist/screens/AuthViews.cjs +260 -0
- package/dist/screens/AuthViews.d.cts +48 -0
- package/dist/screens/AuthViews.d.mts +48 -0
- package/dist/screens/AuthViews.mjs +255 -0
- package/dist/screens/CreateView.cjs +37 -0
- package/dist/screens/CreateView.d.cts +12 -0
- package/dist/screens/CreateView.d.mts +12 -0
- package/dist/screens/CreateView.mjs +36 -0
- package/dist/screens/DashboardView.cjs +39 -0
- package/dist/screens/DashboardView.d.cts +12 -0
- package/dist/screens/DashboardView.d.mts +12 -0
- package/dist/screens/DashboardView.mjs +38 -0
- package/dist/screens/DocumentForm.cjs +214 -0
- package/dist/screens/DocumentForm.d.cts +77 -0
- package/dist/screens/DocumentForm.d.mts +77 -0
- package/dist/screens/DocumentForm.mjs +213 -0
- package/dist/screens/DocumentView.cjs +53 -0
- package/dist/screens/DocumentView.d.cts +17 -0
- package/dist/screens/DocumentView.d.mts +17 -0
- package/dist/screens/DocumentView.mjs +52 -0
- package/dist/screens/FileView.cjs +74 -0
- package/dist/screens/FileView.d.cts +17 -0
- package/dist/screens/FileView.d.mts +17 -0
- package/dist/screens/FileView.mjs +73 -0
- package/dist/screens/FilesView.cjs +212 -0
- package/dist/screens/FilesView.d.cts +34 -0
- package/dist/screens/FilesView.d.mts +34 -0
- package/dist/screens/FilesView.mjs +211 -0
- package/dist/screens/GlobalView.cjs +28 -0
- package/dist/screens/GlobalView.d.cts +16 -0
- package/dist/screens/GlobalView.d.mts +16 -0
- package/dist/screens/GlobalView.mjs +27 -0
- package/dist/screens/ListParts.cjs +138 -0
- package/dist/screens/ListParts.mjs +135 -0
- package/dist/screens/ListView.cjs +155 -0
- package/dist/screens/ListView.d.cts +28 -0
- package/dist/screens/ListView.d.mts +28 -0
- package/dist/screens/ListView.mjs +154 -0
- package/dist/screens/LogoutView.cjs +45 -0
- package/dist/screens/LogoutView.d.cts +10 -0
- package/dist/screens/LogoutView.d.mts +10 -0
- package/dist/screens/LogoutView.mjs +44 -0
- package/dist/screens/MessageView.cjs +13 -0
- package/dist/screens/MessageView.d.cts +12 -0
- package/dist/screens/MessageView.d.mts +12 -0
- package/dist/screens/MessageView.mjs +12 -0
- package/dist/screens/ScreenHeader.cjs +101 -0
- package/dist/screens/ScreenHeader.d.cts +33 -0
- package/dist/screens/ScreenHeader.d.mts +33 -0
- package/dist/screens/ScreenHeader.mjs +98 -0
- package/dist/shared.cjs +55 -0
- package/dist/shared.d.cts +9 -0
- package/dist/shared.d.mts +9 -0
- package/dist/shared.mjs +9 -0
- package/dist/state/AdminProvider.cjs +188 -0
- package/dist/state/AdminProvider.d.cts +106 -0
- package/dist/state/AdminProvider.d.mts +106 -0
- package/dist/state/AdminProvider.mjs +186 -0
- package/dist/state/admin-path.cjs +132 -0
- package/dist/state/admin-path.d.cts +101 -0
- package/dist/state/admin-path.d.mts +101 -0
- package/dist/state/admin-path.mjs +131 -0
- package/dist/state/admin-sections.cjs +49 -0
- package/dist/state/admin-sections.d.cts +39 -0
- package/dist/state/admin-sections.d.mts +39 -0
- package/dist/state/admin-sections.mjs +48 -0
- package/dist/state/choice-search.cjs +95 -0
- package/dist/state/choice-search.mjs +94 -0
- package/dist/state/definition.cjs +53 -0
- package/dist/state/definition.d.cts +123 -0
- package/dist/state/definition.d.mts +123 -0
- package/dist/state/definition.mjs +48 -0
- package/dist/state/form-data.cjs +266 -0
- package/dist/state/form-data.d.cts +123 -0
- package/dist/state/form-data.d.mts +123 -0
- package/dist/state/form-data.mjs +245 -0
- package/dist/state/form-field.cjs +60 -0
- package/dist/state/form-field.d.cts +135 -0
- package/dist/state/form-field.d.mts +135 -0
- package/dist/state/form-field.mjs +56 -0
- package/dist/state/form-state.cjs +11 -0
- package/dist/state/form-state.d.cts +61 -0
- package/dist/state/form-state.d.mts +61 -0
- package/dist/state/form-state.mjs +11 -0
- package/dist/state/kept-focus.cjs +42 -0
- package/dist/state/kept-focus.mjs +41 -0
- package/dist/state/list-query.cjs +116 -0
- package/dist/state/list-query.d.cts +57 -0
- package/dist/state/list-query.d.mts +57 -0
- package/dist/state/list-query.mjs +108 -0
- package/dist/state/picker.cjs +48 -0
- package/dist/state/picker.mjs +47 -0
- package/dist/state/sidebar.cjs +15 -0
- package/dist/state/sidebar.d.cts +7 -0
- package/dist/state/sidebar.d.mts +7 -0
- package/dist/state/sidebar.mjs +14 -0
- package/dist/state/unsaved-guard.cjs +56 -0
- package/dist/state/unsaved-guard.mjs +54 -0
- package/dist/state/uploads.cjs +104 -0
- package/dist/state/uploads.mjs +102 -0
- package/package.json +89 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_icon = require("./icon.cjs");
|
|
4
|
+
const require_definition = require("../state/definition.cjs");
|
|
5
|
+
const require_ButtonTip = require("./ButtonTip.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let lucide_react = require("lucide-react");
|
|
9
|
+
let _base_ui_react_combobox = require("@base-ui/react/combobox");
|
|
10
|
+
let _dnd_kit_core = require("@dnd-kit/core");
|
|
11
|
+
let _dnd_kit_sortable = require("@dnd-kit/sortable");
|
|
12
|
+
let _dnd_kit_utilities = require("@dnd-kit/utilities");
|
|
13
|
+
//#region src/controls/ChipsInput.tsx
|
|
14
|
+
/**
|
|
15
|
+
* Keeps a dragged chip on its row and inside the field.
|
|
16
|
+
*/
|
|
17
|
+
const alongTheField = ({ transform, draggingNodeRect, containerNodeRect }) => {
|
|
18
|
+
if (draggingNodeRect === null || containerNodeRect === null) return {
|
|
19
|
+
...transform,
|
|
20
|
+
y: 0
|
|
21
|
+
};
|
|
22
|
+
const leftmost = containerNodeRect.left - draggingNodeRect.left;
|
|
23
|
+
const rightmost = containerNodeRect.right - draggingNodeRect.right;
|
|
24
|
+
return {
|
|
25
|
+
...transform,
|
|
26
|
+
x: Math.min(Math.max(transform.x, leftmost), rightmost),
|
|
27
|
+
y: 0
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Returns the controlled value of a `Combobox.Root` that takes several values, and a way to reorder it.
|
|
32
|
+
*/
|
|
33
|
+
const useChipsValue = (initial) => {
|
|
34
|
+
const [value, setValue] = (0, react.useState)(initial);
|
|
35
|
+
return {
|
|
36
|
+
value,
|
|
37
|
+
onValueChange: (next) => setValue(next),
|
|
38
|
+
reorder: setValue
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
const Chip = (props) => {
|
|
42
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = (0, _dnd_kit_sortable.useSortable)({
|
|
43
|
+
id: props.value,
|
|
44
|
+
disabled: !props.sortable
|
|
45
|
+
});
|
|
46
|
+
const { role: _role, tabIndex: _tabIndex, ...sortableAttributes } = attributes;
|
|
47
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_combobox.Combobox.Chip, {
|
|
48
|
+
ref: setNodeRef,
|
|
49
|
+
className: "kz-chip",
|
|
50
|
+
"data-dragging": isDragging ? "" : void 0,
|
|
51
|
+
"aria-label": props.label,
|
|
52
|
+
style: {
|
|
53
|
+
transform: _dnd_kit_utilities.CSS.Translate.toString(transform),
|
|
54
|
+
transition
|
|
55
|
+
},
|
|
56
|
+
...sortableAttributes,
|
|
57
|
+
...listeners,
|
|
58
|
+
onMouseDown: (event) => event.preventBaseUIHandler(),
|
|
59
|
+
children: props.children
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Renders the input of a `Combobox.Root` that takes several values, with a chip for each value picked.
|
|
64
|
+
*/
|
|
65
|
+
const ChipsInput = (props) => {
|
|
66
|
+
const chooseLabelId = (0, react.useId)();
|
|
67
|
+
const dndId = (0, react.useId)();
|
|
68
|
+
const sensors = (0, _dnd_kit_core.useSensors)((0, _dnd_kit_core.useSensor)(_dnd_kit_core.PointerSensor, { activationConstraint: { distance: 4 } }), (0, _dnd_kit_core.useSensor)(_dnd_kit_core.KeyboardSensor, { coordinateGetter: _dnd_kit_sortable.sortableKeyboardCoordinates }));
|
|
69
|
+
const sortable = props.onReorder !== void 0 && !props.readOnly;
|
|
70
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_combobox.Combobox.InputGroup, {
|
|
71
|
+
className: "kz-input kz-combobox",
|
|
72
|
+
"data-many": "",
|
|
73
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_combobox.Combobox.Value, { children: (values) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_core.DndContext, {
|
|
74
|
+
id: dndId,
|
|
75
|
+
sensors,
|
|
76
|
+
collisionDetection: _dnd_kit_core.closestCenter,
|
|
77
|
+
modifiers: [alongTheField],
|
|
78
|
+
onDragEnd: (event) => {
|
|
79
|
+
const { active, over } = event;
|
|
80
|
+
if (over === null || active.id === over.id) return;
|
|
81
|
+
props.onReorder?.((0, _dnd_kit_sortable.arrayMove)(values, values.indexOf(String(active.id)), values.indexOf(String(over.id))));
|
|
82
|
+
},
|
|
83
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_dnd_kit_sortable.SortableContext, {
|
|
84
|
+
id: `${dndId}-chips`,
|
|
85
|
+
items: values,
|
|
86
|
+
strategy: _dnd_kit_sortable.horizontalListSortingStrategy,
|
|
87
|
+
disabled: !sortable,
|
|
88
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_combobox.Combobox.Chips, {
|
|
89
|
+
className: "kz-combobox__chips",
|
|
90
|
+
"aria-label": props.label,
|
|
91
|
+
children: [values.map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Chip, {
|
|
92
|
+
value,
|
|
93
|
+
sortable,
|
|
94
|
+
label: props.labelOf(value),
|
|
95
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
96
|
+
className: "kz-ellipsis",
|
|
97
|
+
children: props.labelOf(value)
|
|
98
|
+
}), props.readOnly ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonTip.ButtonTip, {
|
|
99
|
+
label: `Remove ${props.labelOf(value)}`,
|
|
100
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_combobox.Combobox.ChipRemove, {
|
|
101
|
+
className: "kz-chip__remove",
|
|
102
|
+
"aria-label": `Remove ${props.labelOf(value)}`,
|
|
103
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
|
|
104
|
+
...require_icon.CHIP_X_ICON,
|
|
105
|
+
"aria-hidden": true
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
}, value)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_combobox.Combobox.Input, {
|
|
110
|
+
className: "kz-combobox__input",
|
|
111
|
+
placeholder: values.length === 0 ? props.placeholder : "",
|
|
112
|
+
readOnly: props.readOnly
|
|
113
|
+
})]
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
}) }), props.readOnly ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [props.clearable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonTip.ButtonTip, {
|
|
117
|
+
label: `Clear ${require_definition.inSentence(props.label)}`,
|
|
118
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_combobox.Combobox.Clear, {
|
|
119
|
+
className: "kz-field-button",
|
|
120
|
+
"aria-label": `Clear ${require_definition.inSentence(props.label)}`,
|
|
121
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
|
|
122
|
+
...require_icon.X_ICON,
|
|
123
|
+
"aria-hidden": true
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonTip.ButtonTip, {
|
|
127
|
+
label: `Choose ${require_definition.inSentence(props.label)}`,
|
|
128
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_combobox.Combobox.Trigger, {
|
|
129
|
+
className: "kz-field-button",
|
|
130
|
+
"aria-labelledby": chooseLabelId,
|
|
131
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
132
|
+
id: chooseLabelId,
|
|
133
|
+
hidden: true,
|
|
134
|
+
children: ["Choose ", require_definition.inSentence(props.label)]
|
|
135
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
136
|
+
...require_icon.CHEVRON_ICON,
|
|
137
|
+
"aria-hidden": true
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
})] })]
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
//#endregion
|
|
144
|
+
exports.ChipsInput = ChipsInput;
|
|
145
|
+
exports.useChipsValue = useChipsValue;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { CHEVRON_ICON, CHIP_X_ICON, X_ICON } from "./icon.mjs";
|
|
3
|
+
import { inSentence } from "../state/definition.mjs";
|
|
4
|
+
import { ButtonTip } from "./ButtonTip.mjs";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDownIcon, XIcon } from "lucide-react";
|
|
8
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
9
|
+
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
10
|
+
import { SortableContext, arrayMove, horizontalListSortingStrategy, sortableKeyboardCoordinates, useSortable } from "@dnd-kit/sortable";
|
|
11
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
12
|
+
//#region src/controls/ChipsInput.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Keeps a dragged chip on its row and inside the field.
|
|
15
|
+
*/
|
|
16
|
+
const alongTheField = ({ transform, draggingNodeRect, containerNodeRect }) => {
|
|
17
|
+
if (draggingNodeRect === null || containerNodeRect === null) return {
|
|
18
|
+
...transform,
|
|
19
|
+
y: 0
|
|
20
|
+
};
|
|
21
|
+
const leftmost = containerNodeRect.left - draggingNodeRect.left;
|
|
22
|
+
const rightmost = containerNodeRect.right - draggingNodeRect.right;
|
|
23
|
+
return {
|
|
24
|
+
...transform,
|
|
25
|
+
x: Math.min(Math.max(transform.x, leftmost), rightmost),
|
|
26
|
+
y: 0
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Returns the controlled value of a `Combobox.Root` that takes several values, and a way to reorder it.
|
|
31
|
+
*/
|
|
32
|
+
const useChipsValue = (initial) => {
|
|
33
|
+
const [value, setValue] = useState(initial);
|
|
34
|
+
return {
|
|
35
|
+
value,
|
|
36
|
+
onValueChange: (next) => setValue(next),
|
|
37
|
+
reorder: setValue
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const Chip = (props) => {
|
|
41
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
42
|
+
id: props.value,
|
|
43
|
+
disabled: !props.sortable
|
|
44
|
+
});
|
|
45
|
+
const { role: _role, tabIndex: _tabIndex, ...sortableAttributes } = attributes;
|
|
46
|
+
return /* @__PURE__ */ jsx(Combobox.Chip, {
|
|
47
|
+
ref: setNodeRef,
|
|
48
|
+
className: "kz-chip",
|
|
49
|
+
"data-dragging": isDragging ? "" : void 0,
|
|
50
|
+
"aria-label": props.label,
|
|
51
|
+
style: {
|
|
52
|
+
transform: CSS.Translate.toString(transform),
|
|
53
|
+
transition
|
|
54
|
+
},
|
|
55
|
+
...sortableAttributes,
|
|
56
|
+
...listeners,
|
|
57
|
+
onMouseDown: (event) => event.preventBaseUIHandler(),
|
|
58
|
+
children: props.children
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Renders the input of a `Combobox.Root` that takes several values, with a chip for each value picked.
|
|
63
|
+
*/
|
|
64
|
+
const ChipsInput = (props) => {
|
|
65
|
+
const chooseLabelId = useId();
|
|
66
|
+
const dndId = useId();
|
|
67
|
+
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
68
|
+
const sortable = props.onReorder !== void 0 && !props.readOnly;
|
|
69
|
+
return /* @__PURE__ */ jsxs(Combobox.InputGroup, {
|
|
70
|
+
className: "kz-input kz-combobox",
|
|
71
|
+
"data-many": "",
|
|
72
|
+
children: [/* @__PURE__ */ jsx(Combobox.Value, { children: (values) => /* @__PURE__ */ jsx(DndContext, {
|
|
73
|
+
id: dndId,
|
|
74
|
+
sensors,
|
|
75
|
+
collisionDetection: closestCenter,
|
|
76
|
+
modifiers: [alongTheField],
|
|
77
|
+
onDragEnd: (event) => {
|
|
78
|
+
const { active, over } = event;
|
|
79
|
+
if (over === null || active.id === over.id) return;
|
|
80
|
+
props.onReorder?.(arrayMove(values, values.indexOf(String(active.id)), values.indexOf(String(over.id))));
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ jsx(SortableContext, {
|
|
83
|
+
id: `${dndId}-chips`,
|
|
84
|
+
items: values,
|
|
85
|
+
strategy: horizontalListSortingStrategy,
|
|
86
|
+
disabled: !sortable,
|
|
87
|
+
children: /* @__PURE__ */ jsxs(Combobox.Chips, {
|
|
88
|
+
className: "kz-combobox__chips",
|
|
89
|
+
"aria-label": props.label,
|
|
90
|
+
children: [values.map((value) => /* @__PURE__ */ jsxs(Chip, {
|
|
91
|
+
value,
|
|
92
|
+
sortable,
|
|
93
|
+
label: props.labelOf(value),
|
|
94
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
95
|
+
className: "kz-ellipsis",
|
|
96
|
+
children: props.labelOf(value)
|
|
97
|
+
}), props.readOnly ? null : /* @__PURE__ */ jsx(ButtonTip, {
|
|
98
|
+
label: `Remove ${props.labelOf(value)}`,
|
|
99
|
+
children: /* @__PURE__ */ jsx(Combobox.ChipRemove, {
|
|
100
|
+
className: "kz-chip__remove",
|
|
101
|
+
"aria-label": `Remove ${props.labelOf(value)}`,
|
|
102
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
103
|
+
...CHIP_X_ICON,
|
|
104
|
+
"aria-hidden": true
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})]
|
|
108
|
+
}, value)), /* @__PURE__ */ jsx(Combobox.Input, {
|
|
109
|
+
className: "kz-combobox__input",
|
|
110
|
+
placeholder: values.length === 0 ? props.placeholder : "",
|
|
111
|
+
readOnly: props.readOnly
|
|
112
|
+
})]
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}) }), props.readOnly ? null : /* @__PURE__ */ jsxs(Fragment$1, { children: [props.clearable ? /* @__PURE__ */ jsx(ButtonTip, {
|
|
116
|
+
label: `Clear ${inSentence(props.label)}`,
|
|
117
|
+
children: /* @__PURE__ */ jsx(Combobox.Clear, {
|
|
118
|
+
className: "kz-field-button",
|
|
119
|
+
"aria-label": `Clear ${inSentence(props.label)}`,
|
|
120
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
121
|
+
...X_ICON,
|
|
122
|
+
"aria-hidden": true
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
}) : null, /* @__PURE__ */ jsx(ButtonTip, {
|
|
126
|
+
label: `Choose ${inSentence(props.label)}`,
|
|
127
|
+
children: /* @__PURE__ */ jsxs(Combobox.Trigger, {
|
|
128
|
+
className: "kz-field-button",
|
|
129
|
+
"aria-labelledby": chooseLabelId,
|
|
130
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
131
|
+
id: chooseLabelId,
|
|
132
|
+
hidden: true,
|
|
133
|
+
children: ["Choose ", inSentence(props.label)]
|
|
134
|
+
}), /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
135
|
+
...CHEVRON_ICON,
|
|
136
|
+
"aria-hidden": true
|
|
137
|
+
})]
|
|
138
|
+
})
|
|
139
|
+
})] })]
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ChipsInput, useChipsValue };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_Button = require("./Button.cjs");
|
|
4
|
+
const require_Status = require("./Status.cjs");
|
|
5
|
+
let _base_ui_react_alert_dialog = require("@base-ui/react/alert-dialog");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
//#region src/controls/ConfirmDialog.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Asks the person to confirm an action in a dialog. Pass `formAction` and `hidden` to confirm by sending a form, or
|
|
10
|
+
* `onConfirm` to confirm with a click.
|
|
11
|
+
*/
|
|
12
|
+
const ConfirmDialog = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Root, {
|
|
13
|
+
open: props.open,
|
|
14
|
+
onOpenChange: props.onOpenChange,
|
|
15
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_alert_dialog.AlertDialog.Portal, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Backdrop, { className: "kz-layer kz-backdrop" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_alert_dialog.AlertDialog.Popup, {
|
|
16
|
+
className: "kz-layer kz-dialog",
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Title, {
|
|
19
|
+
className: "kz-dialog__title",
|
|
20
|
+
children: props.title
|
|
21
|
+
}),
|
|
22
|
+
props.text === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Description, {
|
|
23
|
+
className: "kz-dialog__text",
|
|
24
|
+
children: props.text
|
|
25
|
+
}),
|
|
26
|
+
"onConfirm" in props ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
27
|
+
className: "kz-dialog__actions",
|
|
28
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Close, {
|
|
29
|
+
className: "kz-button kz-button--secondary",
|
|
30
|
+
children: props.cancelLabel
|
|
31
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
|
|
32
|
+
onClick: props.onConfirm,
|
|
33
|
+
children: props.confirmLabel
|
|
34
|
+
})]
|
|
35
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
36
|
+
action: props.formAction,
|
|
37
|
+
className: "kz-dialog__actions",
|
|
38
|
+
children: [
|
|
39
|
+
Object.entries(props.hidden).map(([name, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
40
|
+
type: "hidden",
|
|
41
|
+
name,
|
|
42
|
+
value
|
|
43
|
+
}, name)),
|
|
44
|
+
props.message === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Status.Status, {
|
|
45
|
+
state: "failed",
|
|
46
|
+
children: props.message
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_alert_dialog.AlertDialog.Close, {
|
|
49
|
+
className: "kz-button kz-button--secondary",
|
|
50
|
+
children: props.cancelLabel
|
|
51
|
+
}),
|
|
52
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
|
|
53
|
+
type: "submit",
|
|
54
|
+
disabled: props.pending === true,
|
|
55
|
+
children: props.confirmLabel
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
})] })
|
|
61
|
+
});
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.ConfirmDialog = ConfirmDialog;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/controls/ConfirmDialog.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Asks the person to confirm an action in a dialog. Pass `formAction` and `hidden` to confirm by sending a form, or
|
|
6
|
+
* `onConfirm` to confirm with a click.
|
|
7
|
+
*/
|
|
8
|
+
declare const ConfirmDialog: (props: {
|
|
9
|
+
open: boolean;
|
|
10
|
+
onOpenChange: (open: boolean) => void;
|
|
11
|
+
title: string;
|
|
12
|
+
confirmLabel: string;
|
|
13
|
+
cancelLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Disables the confirm button of a form while it is sent.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
pending?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* An error shown beside the buttons of a form.
|
|
22
|
+
*/
|
|
23
|
+
message?: string;
|
|
24
|
+
/**
|
|
25
|
+
* A line under the title that names what the question is about.
|
|
26
|
+
*/
|
|
27
|
+
text?: string;
|
|
28
|
+
} & ({
|
|
29
|
+
formAction: (formData: FormData) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The values the form sends with the confirmation, by input name.
|
|
32
|
+
*/
|
|
33
|
+
hidden: Record<string, string>;
|
|
34
|
+
} | {
|
|
35
|
+
onConfirm: () => void;
|
|
36
|
+
})) => _$react.JSX.Element;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ConfirmDialog };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/controls/ConfirmDialog.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Asks the person to confirm an action in a dialog. Pass `formAction` and `hidden` to confirm by sending a form, or
|
|
6
|
+
* `onConfirm` to confirm with a click.
|
|
7
|
+
*/
|
|
8
|
+
declare const ConfirmDialog: (props: {
|
|
9
|
+
open: boolean;
|
|
10
|
+
onOpenChange: (open: boolean) => void;
|
|
11
|
+
title: string;
|
|
12
|
+
confirmLabel: string;
|
|
13
|
+
cancelLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Disables the confirm button of a form while it is sent.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
pending?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* An error shown beside the buttons of a form.
|
|
22
|
+
*/
|
|
23
|
+
message?: string;
|
|
24
|
+
/**
|
|
25
|
+
* A line under the title that names what the question is about.
|
|
26
|
+
*/
|
|
27
|
+
text?: string;
|
|
28
|
+
} & ({
|
|
29
|
+
formAction: (formData: FormData) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The values the form sends with the confirmation, by input name.
|
|
32
|
+
*/
|
|
33
|
+
hidden: Record<string, string>;
|
|
34
|
+
} | {
|
|
35
|
+
onConfirm: () => void;
|
|
36
|
+
})) => _$react.JSX.Element;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ConfirmDialog };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "./Button.mjs";
|
|
3
|
+
import { Status } from "./Status.mjs";
|
|
4
|
+
import { AlertDialog } from "@base-ui/react/alert-dialog";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/controls/ConfirmDialog.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Asks the person to confirm an action in a dialog. Pass `formAction` and `hidden` to confirm by sending a form, or
|
|
9
|
+
* `onConfirm` to confirm with a click.
|
|
10
|
+
*/
|
|
11
|
+
const ConfirmDialog = (props) => /* @__PURE__ */ jsx(AlertDialog.Root, {
|
|
12
|
+
open: props.open,
|
|
13
|
+
onOpenChange: props.onOpenChange,
|
|
14
|
+
children: /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [/* @__PURE__ */ jsx(AlertDialog.Backdrop, { className: "kz-layer kz-backdrop" }), /* @__PURE__ */ jsxs(AlertDialog.Popup, {
|
|
15
|
+
className: "kz-layer kz-dialog",
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(AlertDialog.Title, {
|
|
18
|
+
className: "kz-dialog__title",
|
|
19
|
+
children: props.title
|
|
20
|
+
}),
|
|
21
|
+
props.text === void 0 ? null : /* @__PURE__ */ jsx(AlertDialog.Description, {
|
|
22
|
+
className: "kz-dialog__text",
|
|
23
|
+
children: props.text
|
|
24
|
+
}),
|
|
25
|
+
"onConfirm" in props ? /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: "kz-dialog__actions",
|
|
27
|
+
children: [/* @__PURE__ */ jsx(AlertDialog.Close, {
|
|
28
|
+
className: "kz-button kz-button--secondary",
|
|
29
|
+
children: props.cancelLabel
|
|
30
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
31
|
+
onClick: props.onConfirm,
|
|
32
|
+
children: props.confirmLabel
|
|
33
|
+
})]
|
|
34
|
+
}) : /* @__PURE__ */ jsxs("form", {
|
|
35
|
+
action: props.formAction,
|
|
36
|
+
className: "kz-dialog__actions",
|
|
37
|
+
children: [
|
|
38
|
+
Object.entries(props.hidden).map(([name, value]) => /* @__PURE__ */ jsx("input", {
|
|
39
|
+
type: "hidden",
|
|
40
|
+
name,
|
|
41
|
+
value
|
|
42
|
+
}, name)),
|
|
43
|
+
props.message === void 0 ? null : /* @__PURE__ */ jsx(Status, {
|
|
44
|
+
state: "failed",
|
|
45
|
+
children: props.message
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsx(AlertDialog.Close, {
|
|
48
|
+
className: "kz-button kz-button--secondary",
|
|
49
|
+
children: props.cancelLabel
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx(Button, {
|
|
52
|
+
type: "submit",
|
|
53
|
+
disabled: props.pending === true,
|
|
54
|
+
children: props.confirmLabel
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
})] })
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
62
|
+
export { ConfirmDialog };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
+
//#region src/controls/Counter.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Shows a count against its limit, marked when the count goes over.
|
|
6
|
+
*/
|
|
7
|
+
const Counter = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
8
|
+
className: "kz-counter",
|
|
9
|
+
"data-over": props.count > props.limit ? "" : void 0,
|
|
10
|
+
"aria-live": "polite",
|
|
11
|
+
children: [
|
|
12
|
+
props.count,
|
|
13
|
+
" / ",
|
|
14
|
+
props.limit
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.Counter = Counter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsxs } from "react/jsx-runtime";
|
|
2
|
+
//#region src/controls/Counter.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Shows a count against its limit, marked when the count goes over.
|
|
5
|
+
*/
|
|
6
|
+
const Counter = (props) => /* @__PURE__ */ jsxs("span", {
|
|
7
|
+
className: "kz-counter",
|
|
8
|
+
"data-over": props.count > props.limit ? "" : void 0,
|
|
9
|
+
"aria-live": "polite",
|
|
10
|
+
children: [
|
|
11
|
+
props.count,
|
|
12
|
+
" / ",
|
|
13
|
+
props.limit
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Counter };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_icon = require("./icon.cjs");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let lucide_react = require("lucide-react");
|
|
6
|
+
let _base_ui_react_popover = require("@base-ui/react/popover");
|
|
7
|
+
//#region src/controls/InfoTip.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Shows an info icon that reveals `text` on hover, on a click or on a tap.
|
|
10
|
+
*/
|
|
11
|
+
const InfoTip = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_popover.Popover.Root, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Trigger, {
|
|
12
|
+
openOnHover: true,
|
|
13
|
+
className: "kz-info",
|
|
14
|
+
"aria-label": props.text,
|
|
15
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.InfoIcon, {
|
|
16
|
+
...require_icon.ICON,
|
|
17
|
+
"aria-hidden": true
|
|
18
|
+
})
|
|
19
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Positioner, {
|
|
20
|
+
className: "kz-layer",
|
|
21
|
+
side: "right",
|
|
22
|
+
sideOffset: 8,
|
|
23
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Popup, {
|
|
24
|
+
className: "kz-tooltip",
|
|
25
|
+
children: props.text
|
|
26
|
+
})
|
|
27
|
+
}) })] });
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.InfoTip = InfoTip;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/controls/InfoTip.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Shows an info icon that reveals `text` on hover, on a click or on a tap.
|
|
6
|
+
*/
|
|
7
|
+
declare const InfoTip: (props: {
|
|
8
|
+
text: string;
|
|
9
|
+
}) => _$react.JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InfoTip };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/controls/InfoTip.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Shows an info icon that reveals `text` on hover, on a click or on a tap.
|
|
6
|
+
*/
|
|
7
|
+
declare const InfoTip: (props: {
|
|
8
|
+
text: string;
|
|
9
|
+
}) => _$react.JSX.Element;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { InfoTip };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ICON } from "./icon.mjs";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { InfoIcon } from "lucide-react";
|
|
5
|
+
import { Popover } from "@base-ui/react/popover";
|
|
6
|
+
//#region src/controls/InfoTip.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Shows an info icon that reveals `text` on hover, on a click or on a tap.
|
|
9
|
+
*/
|
|
10
|
+
const InfoTip = (props) => /* @__PURE__ */ jsxs(Popover.Root, { children: [/* @__PURE__ */ jsx(Popover.Trigger, {
|
|
11
|
+
openOnHover: true,
|
|
12
|
+
className: "kz-info",
|
|
13
|
+
"aria-label": props.text,
|
|
14
|
+
children: /* @__PURE__ */ jsx(InfoIcon, {
|
|
15
|
+
...ICON,
|
|
16
|
+
"aria-hidden": true
|
|
17
|
+
})
|
|
18
|
+
}), /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(Popover.Positioner, {
|
|
19
|
+
className: "kz-layer",
|
|
20
|
+
side: "right",
|
|
21
|
+
sideOffset: 8,
|
|
22
|
+
children: /* @__PURE__ */ jsx(Popover.Popup, {
|
|
23
|
+
className: "kz-tooltip",
|
|
24
|
+
children: props.text
|
|
25
|
+
})
|
|
26
|
+
}) })] });
|
|
27
|
+
//#endregion
|
|
28
|
+
export { InfoTip };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/controls/LocalTime.tsx
|
|
6
|
+
const DAY = 1440 * 60 * 1e3;
|
|
7
|
+
const sameDay = (one, other) => one.toDateString() === other.toDateString();
|
|
8
|
+
const timeAgoOf = (moment, now) => {
|
|
9
|
+
const minutes = Math.floor((now.getTime() - moment.getTime()) / 6e4);
|
|
10
|
+
const clock = moment.toLocaleTimeString(void 0, { timeStyle: "short" });
|
|
11
|
+
if (minutes >= 0 && sameDay(moment, now)) {
|
|
12
|
+
if (minutes < 1) return "Just now";
|
|
13
|
+
if (minutes < 60) return minutes === 1 ? "1 minute ago" : `${minutes} minutes ago`;
|
|
14
|
+
const hours = Math.floor(minutes / 60);
|
|
15
|
+
return hours === 1 ? "1 hour ago" : `${hours} hours ago`;
|
|
16
|
+
}
|
|
17
|
+
if (minutes >= 0 && sameDay(moment, new Date(now.getTime() - DAY))) return `Yesterday, ${clock}`;
|
|
18
|
+
return moment.toLocaleString(void 0, {
|
|
19
|
+
dateStyle: "medium",
|
|
20
|
+
timeStyle: "short"
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Shows an ISO date or moment in the browser's language and time zone. Until the browser renders it, it shows the
|
|
25
|
+
* stored date.
|
|
26
|
+
*/
|
|
27
|
+
const LocalTime = (props) => {
|
|
28
|
+
const [text, setText] = (0, react.useState)(props.value.slice(0, 10));
|
|
29
|
+
(0, react.useEffect)(() => {
|
|
30
|
+
const date = new Date(props.day === true ? `${props.value.slice(0, 10)}T00:00:00Z` : props.value);
|
|
31
|
+
if (Number.isNaN(date.getTime())) {
|
|
32
|
+
setText(props.value);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (props.day === true) {
|
|
36
|
+
setText(date.toLocaleDateString(void 0, {
|
|
37
|
+
dateStyle: "medium",
|
|
38
|
+
timeZone: "UTC"
|
|
39
|
+
}));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (props.relative === true) {
|
|
43
|
+
setText(timeAgoOf(date, /* @__PURE__ */ new Date()));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setText(date.toLocaleString(void 0, props.dateOnly === true ? { dateStyle: "medium" } : {
|
|
47
|
+
dateStyle: "medium",
|
|
48
|
+
timeStyle: "short"
|
|
49
|
+
}));
|
|
50
|
+
}, [
|
|
51
|
+
props.value,
|
|
52
|
+
props.dateOnly,
|
|
53
|
+
props.relative,
|
|
54
|
+
props.day
|
|
55
|
+
]);
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
|
|
57
|
+
dateTime: props.value,
|
|
58
|
+
children: text
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.LocalTime = LocalTime;
|