@bysages/react 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-response-jZy-0Tvv.mjs +127 -0
- package/dist/chevron-BeHvt46K.mjs +17 -0
- package/dist/components/accordion/index.d.mts +7 -0
- package/dist/components/accordion/index.mjs +10 -0
- package/dist/components/affix/index.d.mts +20 -0
- package/dist/components/affix/index.mjs +18 -0
- package/dist/components/ai/index.d.mts +2 -0
- package/dist/components/ai/index.mjs +65 -0
- package/dist/components/ai-action/index.d.mts +14 -0
- package/dist/components/ai-action/index.mjs +18 -0
- package/dist/components/ai-attachments/index.d.mts +19 -0
- package/dist/components/ai-attachments/index.mjs +106 -0
- package/dist/components/ai-message/index.d.mts +11 -0
- package/dist/components/ai-message/index.mjs +15 -0
- package/dist/components/ai-prompt-input/index.d.mts +47 -0
- package/dist/components/ai-prompt-input/index.mjs +135 -0
- package/dist/components/ai-reasoning/index.d.mts +13 -0
- package/dist/components/ai-reasoning/index.mjs +19 -0
- package/dist/components/ai-response/index.d.mts +22 -0
- package/dist/components/ai-response/index.mjs +2 -0
- package/dist/components/ai-source/index.d.mts +17 -0
- package/dist/components/ai-source/index.mjs +27 -0
- package/dist/components/ai-suggestion/index.d.mts +13 -0
- package/dist/components/ai-suggestion/index.mjs +16 -0
- package/dist/components/ai-tool/index.d.mts +21 -0
- package/dist/components/ai-tool/index.mjs +36 -0
- package/dist/components/alert/index.d.mts +23 -0
- package/dist/components/alert/index.mjs +80 -0
- package/dist/components/angle-slider/index.d.mts +16 -0
- package/dist/components/angle-slider/index.mjs +21 -0
- package/dist/components/aspect-ratio/index.d.mts +10 -0
- package/dist/components/aspect-ratio/index.mjs +17 -0
- package/dist/components/autocomplete/index.d.mts +21 -0
- package/dist/components/autocomplete/index.mjs +35 -0
- package/dist/components/avatar/index.d.mts +20 -0
- package/dist/components/avatar/index.mjs +14 -0
- package/dist/components/avatar-group/index.d.mts +11 -0
- package/dist/components/avatar-group/index.mjs +15 -0
- package/dist/components/back-top/index.d.mts +29 -0
- package/dist/components/back-top/index.mjs +82 -0
- package/dist/components/badge/index.d.mts +10 -0
- package/dist/components/badge/index.mjs +15 -0
- package/dist/components/banner/index.d.mts +31 -0
- package/dist/components/banner/index.mjs +63 -0
- package/dist/components/breadcrumb/index.d.mts +32 -0
- package/dist/components/breadcrumb/index.mjs +35 -0
- package/dist/components/button/index.d.mts +19 -0
- package/dist/components/button/index.mjs +29 -0
- package/dist/components/button-group/index.d.mts +24 -0
- package/dist/components/button-group/index.mjs +25 -0
- package/dist/components/calendar/index.d.mts +17 -0
- package/dist/components/calendar/index.mjs +96 -0
- package/dist/components/card/index.d.mts +46 -0
- package/dist/components/card/index.mjs +44 -0
- package/dist/components/carousel/index.d.mts +9 -0
- package/dist/components/carousel/index.mjs +12 -0
- package/dist/components/cascade-select/index.d.mts +31 -0
- package/dist/components/cascade-select/index.mjs +223 -0
- package/dist/components/checkbox/index.d.mts +16 -0
- package/dist/components/checkbox/index.mjs +21 -0
- package/dist/components/checkbox-group/index.d.mts +28 -0
- package/dist/components/checkbox-group/index.mjs +65 -0
- package/dist/components/chip/index.d.mts +12 -0
- package/dist/components/chip/index.mjs +17 -0
- package/dist/components/client-only/index.d.mts +2 -0
- package/dist/components/client-only/index.mjs +2 -0
- package/dist/components/clipboard/index.d.mts +17 -0
- package/dist/components/clipboard/index.mjs +17 -0
- package/dist/components/collapsible/index.d.mts +7 -0
- package/dist/components/collapsible/index.mjs +10 -0
- package/dist/components/collection/index.d.mts +2 -0
- package/dist/components/collection/index.mjs +2 -0
- package/dist/components/color-picker/index.d.mts +20 -0
- package/dist/components/color-picker/index.mjs +25 -0
- package/dist/components/combobox/index.d.mts +17 -0
- package/dist/components/combobox/index.mjs +18 -0
- package/dist/components/command/index.d.mts +43 -0
- package/dist/components/command/index.mjs +137 -0
- package/dist/components/comment/index.d.mts +17 -0
- package/dist/components/comment/index.mjs +47 -0
- package/dist/components/config-provider/index.d.mts +46 -0
- package/dist/components/config-provider/index.mjs +41 -0
- package/dist/components/container/index.d.mts +13 -0
- package/dist/components/container/index.mjs +15 -0
- package/dist/components/date-input/index.d.mts +17 -0
- package/dist/components/date-input/index.mjs +21 -0
- package/dist/components/date-picker/index.d.mts +19 -0
- package/dist/components/date-picker/index.mjs +23 -0
- package/dist/components/descriptions/index.d.mts +25 -0
- package/dist/components/descriptions/index.mjs +32 -0
- package/dist/components/dialog/index.d.mts +9 -0
- package/dist/components/dialog/index.mjs +11 -0
- package/dist/components/download-trigger/index.d.mts +2 -0
- package/dist/components/download-trigger/index.mjs +2 -0
- package/dist/components/drawer/index.d.mts +9 -0
- package/dist/components/drawer/index.mjs +12 -0
- package/dist/components/dynamic-input/index.d.mts +28 -0
- package/dist/components/dynamic-input/index.mjs +83 -0
- package/dist/components/editable/index.d.mts +16 -0
- package/dist/components/editable/index.mjs +17 -0
- package/dist/components/ellipsis/index.d.mts +10 -0
- package/dist/components/ellipsis/index.mjs +19 -0
- package/dist/components/empty/index.d.mts +28 -0
- package/dist/components/empty/index.mjs +32 -0
- package/dist/components/field/index.d.mts +8 -0
- package/dist/components/field/index.mjs +11 -0
- package/dist/components/fieldset/index.d.mts +7 -0
- package/dist/components/fieldset/index.mjs +10 -0
- package/dist/components/file-upload/index.d.mts +18 -0
- package/dist/components/file-upload/index.mjs +23 -0
- package/dist/components/float-button/index.d.mts +59 -0
- package/dist/components/float-button/index.mjs +90 -0
- package/dist/components/floating-panel/index.d.mts +9 -0
- package/dist/components/floating-panel/index.mjs +12 -0
- package/dist/components/focus-trap/index.d.mts +2 -0
- package/dist/components/focus-trap/index.mjs +2 -0
- package/dist/components/form/index.d.mts +2 -0
- package/dist/components/form/index.mjs +67 -0
- package/dist/components/format/index.d.mts +9 -0
- package/dist/components/format/index.mjs +10 -0
- package/dist/components/frame/index.d.mts +10 -0
- package/dist/components/frame/index.mjs +12 -0
- package/dist/components/grid/index.d.mts +13 -0
- package/dist/components/grid/index.mjs +31 -0
- package/dist/components/highlight/index.d.mts +7 -0
- package/dist/components/highlight/index.mjs +11 -0
- package/dist/components/hover-card/index.d.mts +7 -0
- package/dist/components/hover-card/index.mjs +10 -0
- package/dist/components/icon/index.d.mts +19 -0
- package/dist/components/icon/index.mjs +26 -0
- package/dist/components/image/index.d.mts +17 -0
- package/dist/components/image/index.mjs +57 -0
- package/dist/components/image-cropper/index.d.mts +8 -0
- package/dist/components/image-cropper/index.mjs +11 -0
- package/dist/components/image-viewer/index.d.mts +18 -0
- package/dist/components/image-viewer/index.mjs +110 -0
- package/dist/components/input/index.d.mts +16 -0
- package/dist/components/input/index.mjs +21 -0
- package/dist/components/input-group/index.d.mts +17 -0
- package/dist/components/input-group/index.mjs +31 -0
- package/dist/components/json-tree-view/index.d.mts +7 -0
- package/dist/components/json-tree-view/index.mjs +10 -0
- package/dist/components/kbd/index.d.mts +6 -0
- package/dist/components/kbd/index.mjs +14 -0
- package/dist/components/layout/index.d.mts +63 -0
- package/dist/components/layout/index.mjs +133 -0
- package/dist/components/link/index.d.mts +10 -0
- package/dist/components/link/index.mjs +18 -0
- package/dist/components/list/index.d.mts +39 -0
- package/dist/components/list/index.mjs +66 -0
- package/dist/components/listbox/index.d.mts +18 -0
- package/dist/components/listbox/index.mjs +18 -0
- package/dist/components/marquee/index.d.mts +7 -0
- package/dist/components/marquee/index.mjs +10 -0
- package/dist/components/masonry/index.d.mts +11 -0
- package/dist/components/masonry/index.mjs +29 -0
- package/dist/components/mentions/index.d.mts +2 -0
- package/dist/components/mentions/index.mjs +2 -0
- package/dist/components/menu/index.d.mts +20 -0
- package/dist/components/menu/index.mjs +37 -0
- package/dist/components/menubar/index.d.mts +32 -0
- package/dist/components/menubar/index.mjs +35 -0
- package/dist/components/meter/index.d.mts +26 -0
- package/dist/components/meter/index.mjs +59 -0
- package/dist/components/navigation-menu/index.d.mts +8 -0
- package/dist/components/navigation-menu/index.mjs +11 -0
- package/dist/components/number-input/index.d.mts +16 -0
- package/dist/components/number-input/index.mjs +21 -0
- package/dist/components/page-header/index.d.mts +32 -0
- package/dist/components/page-header/index.mjs +34 -0
- package/dist/components/pagination/index.d.mts +18 -0
- package/dist/components/pagination/index.mjs +23 -0
- package/dist/components/password-input/index.d.mts +16 -0
- package/dist/components/password-input/index.mjs +21 -0
- package/dist/components/pin-input/index.d.mts +15 -0
- package/dist/components/pin-input/index.mjs +20 -0
- package/dist/components/popconfirm/index.d.mts +20 -0
- package/dist/components/popconfirm/index.mjs +44 -0
- package/dist/components/popover/index.d.mts +8 -0
- package/dist/components/popover/index.mjs +11 -0
- package/dist/components/presence/index.d.mts +2 -0
- package/dist/components/presence/index.mjs +2 -0
- package/dist/components/progress/index.d.mts +16 -0
- package/dist/components/progress/index.mjs +21 -0
- package/dist/components/progress-group/index.d.mts +22 -0
- package/dist/components/progress-group/index.mjs +56 -0
- package/dist/components/qr-code/index.d.mts +8 -0
- package/dist/components/qr-code/index.mjs +11 -0
- package/dist/components/radio-group/index.d.mts +16 -0
- package/dist/components/radio-group/index.mjs +21 -0
- package/dist/components/rating-group/index.d.mts +16 -0
- package/dist/components/rating-group/index.mjs +21 -0
- package/dist/components/scroll-area/index.d.mts +7 -0
- package/dist/components/scroll-area/index.mjs +10 -0
- package/dist/components/segment-group/index.d.mts +18 -0
- package/dist/components/segment-group/index.mjs +20 -0
- package/dist/components/select/index.d.mts +17 -0
- package/dist/components/select/index.mjs +18 -0
- package/dist/components/separator/index.d.mts +11 -0
- package/dist/components/separator/index.mjs +16 -0
- package/dist/components/signature-pad/index.d.mts +8 -0
- package/dist/components/signature-pad/index.mjs +11 -0
- package/dist/components/skeleton/index.d.mts +7 -0
- package/dist/components/skeleton/index.mjs +13 -0
- package/dist/components/slider/index.d.mts +16 -0
- package/dist/components/slider/index.mjs +21 -0
- package/dist/components/spinner/index.d.mts +9 -0
- package/dist/components/spinner/index.mjs +36 -0
- package/dist/components/split-button/index.d.mts +36 -0
- package/dist/components/split-button/index.mjs +71 -0
- package/dist/components/splitter/index.d.mts +7 -0
- package/dist/components/splitter/index.mjs +10 -0
- package/dist/components/stack/index.d.mts +11 -0
- package/dist/components/stack/index.mjs +32 -0
- package/dist/components/stat/index.d.mts +29 -0
- package/dist/components/stat/index.mjs +37 -0
- package/dist/components/steps/index.d.mts +19 -0
- package/dist/components/steps/index.mjs +24 -0
- package/dist/components/swap/index.d.mts +8 -0
- package/dist/components/swap/index.mjs +11 -0
- package/dist/components/switch/index.d.mts +16 -0
- package/dist/components/switch/index.mjs +21 -0
- package/dist/components/table/index.d.mts +79 -0
- package/dist/components/table/index.mjs +688 -0
- package/dist/components/tabs/index.d.mts +18 -0
- package/dist/components/tabs/index.mjs +23 -0
- package/dist/components/tags-input/index.d.mts +17 -0
- package/dist/components/tags-input/index.mjs +22 -0
- package/dist/components/textarea/index.d.mts +14 -0
- package/dist/components/textarea/index.mjs +20 -0
- package/dist/components/timeline/index.d.mts +24 -0
- package/dist/components/timeline/index.mjs +30 -0
- package/dist/components/timer/index.d.mts +8 -0
- package/dist/components/timer/index.mjs +11 -0
- package/dist/components/toast/index.d.mts +11 -0
- package/dist/components/toast/index.mjs +13 -0
- package/dist/components/toc/index.d.mts +7 -0
- package/dist/components/toc/index.mjs +10 -0
- package/dist/components/toggle/index.d.mts +7 -0
- package/dist/components/toggle/index.mjs +10 -0
- package/dist/components/toggle-group/index.d.mts +15 -0
- package/dist/components/toggle-group/index.mjs +20 -0
- package/dist/components/tooltip/index.d.mts +7 -0
- package/dist/components/tooltip/index.mjs +10 -0
- package/dist/components/tour/index.d.mts +11 -0
- package/dist/components/tour/index.mjs +13 -0
- package/dist/components/transfer/index.d.mts +23 -0
- package/dist/components/transfer/index.mjs +154 -0
- package/dist/components/tree-select/index.d.mts +28 -0
- package/dist/components/tree-select/index.mjs +157 -0
- package/dist/components/tree-view/index.d.mts +19 -0
- package/dist/components/tree-view/index.mjs +18 -0
- package/dist/components/typography/index.d.mts +32 -0
- package/dist/components/typography/index.mjs +34 -0
- package/dist/components/watermark/index.d.mts +16 -0
- package/dist/components/watermark/index.mjs +80 -0
- package/dist/index-DaAbbSz9.d.mts +13416 -0
- package/dist/index-Uefyw7Im.d.mts +108 -0
- package/dist/index-uPyYiWaL.d.mts +1813 -0
- package/dist/index.d.mts +128 -15446
- package/dist/index.mjs +128 -4871
- package/dist/mentions-DMIBCBOd.mjs +181 -0
- package/package.json +77 -4
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
5
|
+
import { useListCollection } from "@ark-ui/react/collection";
|
|
6
|
+
import { Combobox } from "@ark-ui/react/combobox";
|
|
7
|
+
import { Dialog } from "@ark-ui/react/dialog";
|
|
8
|
+
//#region src/components/command/index.tsx
|
|
9
|
+
function Command({ items = [], placeholder, open, autoFilter = true, inputValue, emptyText = "No matching commands", onSelect, onOpenChange, onInputValueChange }) {
|
|
10
|
+
injectComponentStyle("command");
|
|
11
|
+
injectComponentStyle("dialog");
|
|
12
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
13
|
+
const [listOpen, setListOpen] = useState(true);
|
|
14
|
+
const [fieldText, setFieldText] = useState("");
|
|
15
|
+
const { collection, set, filter } = useListCollection({
|
|
16
|
+
initialItems: items.map((entry) => entry.value),
|
|
17
|
+
filter: (value, input) => {
|
|
18
|
+
const entry = items.find((candidate) => candidate.value === value);
|
|
19
|
+
if (!entry) return false;
|
|
20
|
+
const query = input.toLowerCase();
|
|
21
|
+
return entry.label.toLowerCase().includes(query) || value.toLowerCase().includes(query);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
set(items.map((entry) => entry.value));
|
|
26
|
+
if (autoFilter) filter(fieldText);
|
|
27
|
+
}, [items]);
|
|
28
|
+
const currentOpen = open ?? internalOpen;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (currentOpen) setListOpen(true);
|
|
31
|
+
}, [currentOpen]);
|
|
32
|
+
const setOpen = (value) => {
|
|
33
|
+
if (open === void 0) setInternalOpen(value);
|
|
34
|
+
onOpenChange?.(value);
|
|
35
|
+
};
|
|
36
|
+
const available = new Set(collection.items);
|
|
37
|
+
const groups = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const entry of items) {
|
|
39
|
+
if (!available.has(entry.value)) continue;
|
|
40
|
+
const key = entry.group ?? "";
|
|
41
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
42
|
+
groups.get(key).push(entry);
|
|
43
|
+
}
|
|
44
|
+
const row = (entry) => /* @__PURE__ */ jsx(Combobox.Item, {
|
|
45
|
+
item: entry.value,
|
|
46
|
+
asChild: true,
|
|
47
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
"data-scope": "command",
|
|
49
|
+
"data-part": "item",
|
|
50
|
+
children: [/* @__PURE__ */ jsx(Combobox.ItemText, {
|
|
51
|
+
asChild: true,
|
|
52
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
53
|
+
"data-scope": "command",
|
|
54
|
+
"data-part": "item-label",
|
|
55
|
+
children: entry.label
|
|
56
|
+
})
|
|
57
|
+
}), entry.hint ? /* @__PURE__ */ jsx("span", {
|
|
58
|
+
"data-scope": "command",
|
|
59
|
+
"data-part": "item-hint",
|
|
60
|
+
children: entry.hint
|
|
61
|
+
}) : void 0]
|
|
62
|
+
})
|
|
63
|
+
}, entry.value);
|
|
64
|
+
return /* @__PURE__ */ jsx(Dialog.Root, {
|
|
65
|
+
open: currentOpen,
|
|
66
|
+
onOpenChange: (details) => setOpen(details.open),
|
|
67
|
+
children: /* @__PURE__ */ jsxs(Portal, { children: [/* @__PURE__ */ jsx(Dialog.Backdrop, {}), /* @__PURE__ */ jsx(Dialog.Positioner, {
|
|
68
|
+
asChild: true,
|
|
69
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
70
|
+
"data-scope": "command",
|
|
71
|
+
"data-part": "positioner",
|
|
72
|
+
children: /* @__PURE__ */ jsx(Dialog.Content, {
|
|
73
|
+
asChild: true,
|
|
74
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
75
|
+
"data-scope": "command",
|
|
76
|
+
"data-part": "content",
|
|
77
|
+
children: /* @__PURE__ */ jsxs(Combobox.Root, {
|
|
78
|
+
collection,
|
|
79
|
+
inputValue,
|
|
80
|
+
open: listOpen,
|
|
81
|
+
onOpenChange: (details) => setListOpen(details.open),
|
|
82
|
+
inputBehavior: "autohighlight",
|
|
83
|
+
loopFocus: true,
|
|
84
|
+
onInputValueChange: (details) => {
|
|
85
|
+
setFieldText(details.inputValue);
|
|
86
|
+
if (autoFilter) filter(details.inputValue);
|
|
87
|
+
onInputValueChange?.(details.inputValue);
|
|
88
|
+
},
|
|
89
|
+
onValueChange: (details) => {
|
|
90
|
+
const [first] = details.value;
|
|
91
|
+
if (first == null) return;
|
|
92
|
+
onSelect?.(first);
|
|
93
|
+
setOpen(false);
|
|
94
|
+
},
|
|
95
|
+
children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
96
|
+
asChild: true,
|
|
97
|
+
children: /* @__PURE__ */ jsx("input", {
|
|
98
|
+
type: "text",
|
|
99
|
+
placeholder,
|
|
100
|
+
"data-scope": "command",
|
|
101
|
+
"data-part": "input"
|
|
102
|
+
})
|
|
103
|
+
}), /* @__PURE__ */ jsx(Combobox.Content, {
|
|
104
|
+
asChild: true,
|
|
105
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
106
|
+
"data-scope": "command",
|
|
107
|
+
"data-part": "list",
|
|
108
|
+
children: [Array.from(groups, ([group, entries]) => group === "" ? entries.map(row) : /* @__PURE__ */ jsx(Combobox.ItemGroup, {
|
|
109
|
+
asChild: true,
|
|
110
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
111
|
+
"data-scope": "command",
|
|
112
|
+
"data-part": "group",
|
|
113
|
+
children: [/* @__PURE__ */ jsx(Combobox.ItemGroupLabel, {
|
|
114
|
+
asChild: true,
|
|
115
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
116
|
+
"data-scope": "command",
|
|
117
|
+
"data-part": "group-label",
|
|
118
|
+
children: group
|
|
119
|
+
})
|
|
120
|
+
}), entries.map(row)]
|
|
121
|
+
})
|
|
122
|
+
}, group)), groups.size === 0 ? /* @__PURE__ */ jsx("div", {
|
|
123
|
+
"data-scope": "command",
|
|
124
|
+
"data-part": "empty",
|
|
125
|
+
children: emptyText
|
|
126
|
+
}) : null]
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
})] })
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { Command };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/components/comment/index.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A voice on the record: the portrait hangs left (the `avatar` prop),
|
|
5
|
+
* the body carries the byline from `author` and `datetime`, the ink is
|
|
6
|
+
* the children, and `actions` is the row of answers.
|
|
7
|
+
*/
|
|
8
|
+
export interface CommentProps extends HTMLAttributes<HTMLElement> {
|
|
9
|
+
author?: string;
|
|
10
|
+
datetime?: string;
|
|
11
|
+
/** The portrait at the row's head. */
|
|
12
|
+
avatar?: ReactNode;
|
|
13
|
+
/** The row of answers beneath the ink. */
|
|
14
|
+
actions?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function Comment({ author, datetime, avatar, actions, children, ...rest }: CommentProps): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/comment/index.tsx
|
|
4
|
+
function Comment({ author, datetime, avatar, actions, children, ...rest }) {
|
|
5
|
+
injectComponentStyle("comment");
|
|
6
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-scope": "comment",
|
|
9
|
+
"data-part": "root",
|
|
10
|
+
children: [avatar ? /* @__PURE__ */ jsx("div", {
|
|
11
|
+
"data-scope": "comment",
|
|
12
|
+
"data-part": "avatar",
|
|
13
|
+
children: avatar
|
|
14
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
15
|
+
"data-scope": "comment",
|
|
16
|
+
"data-part": "body",
|
|
17
|
+
children: [
|
|
18
|
+
author || datetime ? /* @__PURE__ */ jsxs("header", {
|
|
19
|
+
"data-scope": "comment",
|
|
20
|
+
"data-part": "header",
|
|
21
|
+
children: [author ? /* @__PURE__ */ jsx("span", {
|
|
22
|
+
"data-scope": "comment",
|
|
23
|
+
"data-part": "author",
|
|
24
|
+
children: author
|
|
25
|
+
}) : null, datetime ? /* @__PURE__ */ jsx("time", {
|
|
26
|
+
"data-scope": "comment",
|
|
27
|
+
"data-part": "datetime",
|
|
28
|
+
dateTime: datetime,
|
|
29
|
+
children: datetime
|
|
30
|
+
}) : null]
|
|
31
|
+
}) : null,
|
|
32
|
+
/* @__PURE__ */ jsx("div", {
|
|
33
|
+
"data-scope": "comment",
|
|
34
|
+
"data-part": "content",
|
|
35
|
+
children
|
|
36
|
+
}),
|
|
37
|
+
actions ? /* @__PURE__ */ jsx("div", {
|
|
38
|
+
"data-scope": "comment",
|
|
39
|
+
"data-part": "actions",
|
|
40
|
+
children: actions
|
|
41
|
+
}) : null
|
|
42
|
+
]
|
|
43
|
+
})]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Comment };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ThemeScene } from "@bysages/core";
|
|
2
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/components/config-provider/index.d.ts
|
|
4
|
+
/** The four density tiers the token layer's `[data-density]` selectors
|
|
5
|
+
* name — whitespace and control heights compress, readability never
|
|
6
|
+
* does. */
|
|
7
|
+
export type ConfigDensity = "compact" | "default" | "comfortable" | "spacious";
|
|
8
|
+
/** The named scene registers the token layer's `[data-scene]` selectors
|
|
9
|
+
* retune — "auto" is the engine's own resolution and stays off the
|
|
10
|
+
* subtree vocabulary. */
|
|
11
|
+
export type ConfigScene = Exclude<ThemeScene, "auto">;
|
|
12
|
+
/** The configuration a provider lays over its subtree. Every field is
|
|
13
|
+
* optional: an absent field changes nothing, and the page's own
|
|
14
|
+
* attributes keep ruling. */
|
|
15
|
+
export interface ConfigContext {
|
|
16
|
+
density?: ConfigDensity;
|
|
17
|
+
scene?: ConfigScene;
|
|
18
|
+
/** A mineral pigment theme (qinghua, celadon, zhusha, …) landing as
|
|
19
|
+
* `[data-accent]` on the host element. */
|
|
20
|
+
accent?: string;
|
|
21
|
+
/** Writing direction, landing as the native `dir` attribute. */
|
|
22
|
+
dir?: "ltr" | "rtl";
|
|
23
|
+
/** BCP-47 locale, landing as the native `lang` attribute. */
|
|
24
|
+
locale?: string;
|
|
25
|
+
}
|
|
26
|
+
/** The nearest provider's snapshot, or an empty one when no provider
|
|
27
|
+
* wraps the caller — the hook the date and format families will consume
|
|
28
|
+
* to localize their output. */
|
|
29
|
+
export declare function useConfig(): ConfigContext;
|
|
30
|
+
export interface ConfigProviderProps extends HTMLAttributes<HTMLDivElement> {
|
|
31
|
+
density?: ConfigDensity;
|
|
32
|
+
scene?: ConfigScene;
|
|
33
|
+
accent?: string;
|
|
34
|
+
dir?: "ltr" | "rtl";
|
|
35
|
+
locale?: string;
|
|
36
|
+
children?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The declarative host for global configuration: one element that both
|
|
40
|
+
* carries the token layer's attributes — `[data-density]` and
|
|
41
|
+
* `[data-accent]` fire on any element — and provides the same values to
|
|
42
|
+
* descendants through `useConfig`, so interactive behavior (formatting,
|
|
43
|
+
* messages) and visual theming stay one decision.
|
|
44
|
+
*/
|
|
45
|
+
export declare function ConfigProvider({ density, scene, accent, dir, locale, children, ...rest }: ConfigProviderProps): import("react").JSX.Element;
|
|
46
|
+
//#endregion
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
//#region src/components/config-provider/index.tsx
|
|
4
|
+
const ConfigContextImpl = createContext({});
|
|
5
|
+
/** The nearest provider's snapshot, or an empty one when no provider
|
|
6
|
+
* wraps the caller — the hook the date and format families will consume
|
|
7
|
+
* to localize their output. */
|
|
8
|
+
function useConfig() {
|
|
9
|
+
return useContext(ConfigContextImpl);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The declarative host for global configuration: one element that both
|
|
13
|
+
* carries the token layer's attributes — `[data-density]` and
|
|
14
|
+
* `[data-accent]` fire on any element — and provides the same values to
|
|
15
|
+
* descendants through `useConfig`, so interactive behavior (formatting,
|
|
16
|
+
* messages) and visual theming stay one decision.
|
|
17
|
+
*/
|
|
18
|
+
function ConfigProvider({ density, scene, accent, dir, locale, children, ...rest }) {
|
|
19
|
+
return /* @__PURE__ */ jsx(ConfigContextImpl.Provider, {
|
|
20
|
+
value: {
|
|
21
|
+
density,
|
|
22
|
+
scene,
|
|
23
|
+
accent,
|
|
24
|
+
dir,
|
|
25
|
+
locale
|
|
26
|
+
},
|
|
27
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
28
|
+
...rest,
|
|
29
|
+
"data-scope": "config-provider",
|
|
30
|
+
"data-part": "root",
|
|
31
|
+
...density != null ? { "data-density": density } : {},
|
|
32
|
+
...scene != null ? { "data-scene": scene } : {},
|
|
33
|
+
...accent != null ? { "data-accent": accent } : {},
|
|
34
|
+
...dir != null ? { dir } : {},
|
|
35
|
+
...locale != null ? { lang: locale } : {},
|
|
36
|
+
children
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { ConfigProvider, useConfig };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/container/index.d.ts
|
|
3
|
+
/** The reading frame: content held to a measure and centered on the
|
|
4
|
+
* page. The sizes name typographic measures, not breakpoints — the page
|
|
5
|
+
* owns its edges, the container only owns how long a line of ink runs. */
|
|
6
|
+
export interface ContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
size?: "narrow" | "readable" | "wide" | "full";
|
|
8
|
+
/** Keep the ink off the page edges when the viewport runs narrower
|
|
9
|
+
* than the measure. */
|
|
10
|
+
padding?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function Container({ size, padding, ...rest }: ContainerProps): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/container/index.tsx
|
|
4
|
+
function Container({ size = "readable", padding = true, ...rest }) {
|
|
5
|
+
injectComponentStyle("container");
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-scope": "container",
|
|
9
|
+
"data-part": "root",
|
|
10
|
+
"data-size": size,
|
|
11
|
+
"data-padding": padding ? "" : void 0
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { Container };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { DateInput as DateInput$1, DateInputFocusChangeDetails, DateInputValueChangeDetails } from "@ark-ui/react/date-input";
|
|
3
|
+
//#region src/components/date-input/index.d.ts
|
|
4
|
+
type DateInputRootProps = ComponentProps<typeof DateInput$1.Root> & {
|
|
5
|
+
/** One rung of the control-height ladder for the segmented field. */
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
};
|
|
8
|
+
declare function DateInputRoot({ size, ...rest }: DateInputRootProps): import("react").JSX.Element;
|
|
9
|
+
/** Ark's DateInput, dressed in the paper-and-ink system: a segmented
|
|
10
|
+
* field where the focused segment takes the flat ink fill. The API is
|
|
11
|
+
* Ark's own — Root, Label, Control, SegmentGroup, Segment, SegmentContext,
|
|
12
|
+
* HiddenInput. */
|
|
13
|
+
export declare const DateInput: Omit<typeof DateInput$1, "Root"> & {
|
|
14
|
+
Root: typeof DateInputRoot;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export type { DateInputFocusChangeDetails, DateInputValueChangeDetails };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { DateInput as DateInput$1 } from "@ark-ui/react/date-input";
|
|
4
|
+
//#region src/components/date-input/index.tsx
|
|
5
|
+
function DateInputRoot({ size = "md", ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(DateInput$1.Root, {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-size": size
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/** Ark's DateInput, dressed in the paper-and-ink system: a segmented
|
|
12
|
+
* field where the focused segment takes the flat ink fill. The API is
|
|
13
|
+
* Ark's own — Root, Label, Control, SegmentGroup, Segment, SegmentContext,
|
|
14
|
+
* HiddenInput. */
|
|
15
|
+
const DateInput = {
|
|
16
|
+
...DateInput$1,
|
|
17
|
+
Root: DateInputRoot
|
|
18
|
+
};
|
|
19
|
+
injectComponentStyle("date-input");
|
|
20
|
+
//#endregion
|
|
21
|
+
export { DateInput };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { DatePicker as DatePicker$1, DatePickerFocusChangeDetails, DatePickerOpenChangeDetails, DatePickerValueChangeDetails, DatePickerViewChangeDetails, DatePickerVisibleRangeChangeDetails } from "@ark-ui/react/date-picker";
|
|
3
|
+
//#region src/components/date-picker/index.d.ts
|
|
4
|
+
type DatePickerRootProps$1 = ComponentProps<typeof DatePicker$1.Root> & {
|
|
5
|
+
/** One rung of the control-height ladder for the field row. */
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
};
|
|
8
|
+
declare function DatePickerRoot({ size, ...rest }: DatePickerRootProps$1): import("react").JSX.Element;
|
|
9
|
+
/** Ark's DatePicker, dressed in the paper-and-ink system: the popup
|
|
10
|
+
* dissolves in on elevation, selected days take the flat ink fill, and
|
|
11
|
+
* range middles run subtle with cut corners. The API is Ark's own —
|
|
12
|
+
* Root, Label, Control, Input, Trigger, ClearTrigger, Positioner,
|
|
13
|
+
* Content, View, ViewControl, ViewTrigger, RangeText, PrevTrigger,
|
|
14
|
+
* NextTrigger, Table*, MonthSelect, YearSelect, PresetTrigger. */
|
|
15
|
+
export declare const DatePicker: Omit<typeof DatePicker$1, "Root"> & {
|
|
16
|
+
Root: typeof DatePickerRoot;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export type { DatePickerFocusChangeDetails, DatePickerOpenChangeDetails, DatePickerValueChangeDetails, DatePickerViewChangeDetails, DatePickerVisibleRangeChangeDetails };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { DatePicker as DatePicker$1 } from "@ark-ui/react/date-picker";
|
|
4
|
+
//#region src/components/date-picker/index.tsx
|
|
5
|
+
function DatePickerRoot({ size = "md", ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(DatePicker$1.Root, {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-size": size
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/** Ark's DatePicker, dressed in the paper-and-ink system: the popup
|
|
12
|
+
* dissolves in on elevation, selected days take the flat ink fill, and
|
|
13
|
+
* range middles run subtle with cut corners. The API is Ark's own —
|
|
14
|
+
* Root, Label, Control, Input, Trigger, ClearTrigger, Positioner,
|
|
15
|
+
* Content, View, ViewControl, ViewTrigger, RangeText, PrevTrigger,
|
|
16
|
+
* NextTrigger, Table*, MonthSelect, YearSelect, PresetTrigger. */
|
|
17
|
+
const DatePicker = {
|
|
18
|
+
...DatePicker$1,
|
|
19
|
+
Root: DatePickerRoot
|
|
20
|
+
};
|
|
21
|
+
injectComponentStyle("date-picker");
|
|
22
|
+
//#endregion
|
|
23
|
+
export { DatePicker };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/descriptions/index.d.ts
|
|
3
|
+
/** A ledger laid flat: term and detail pairs in one quiet grid. The
|
|
4
|
+
* horizontal layout reads as a table of two columns; the vertical one
|
|
5
|
+
* stacks each pair for narrow measures. */
|
|
6
|
+
export interface DescriptionsRootProps extends HTMLAttributes<HTMLDListElement> {
|
|
7
|
+
layout?: "horizontal" | "vertical";
|
|
8
|
+
}
|
|
9
|
+
export declare function DescriptionsRoot({ layout, children, ...rest }: DescriptionsRootProps): import("react").JSX.Element;
|
|
10
|
+
export declare const Descriptions: {
|
|
11
|
+
Root: typeof DescriptionsRoot;
|
|
12
|
+
Item: {
|
|
13
|
+
({ children, ...rest }: HTMLAttributes<HTMLElement>): import("react").JSX.Element;
|
|
14
|
+
displayName: string;
|
|
15
|
+
};
|
|
16
|
+
Term: {
|
|
17
|
+
({ children, ...rest }: HTMLAttributes<HTMLElement>): import("react").JSX.Element;
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
20
|
+
Detail: {
|
|
21
|
+
({ children, ...rest }: HTMLAttributes<HTMLElement>): import("react").JSX.Element;
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/descriptions/index.tsx
|
|
4
|
+
function DescriptionsRoot({ layout = "horizontal", children, ...rest }) {
|
|
5
|
+
injectComponentStyle("descriptions");
|
|
6
|
+
return /* @__PURE__ */ jsx("dl", {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-scope": "descriptions",
|
|
9
|
+
"data-part": "root",
|
|
10
|
+
"data-layout": layout,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function part(name, tag) {
|
|
15
|
+
const Tag = tag;
|
|
16
|
+
const Component = ({ children, ...rest }) => /* @__PURE__ */ jsx(Tag, {
|
|
17
|
+
...rest,
|
|
18
|
+
"data-scope": "descriptions",
|
|
19
|
+
"data-part": name.toLowerCase(),
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
Component.displayName = "Descriptions" + name;
|
|
23
|
+
return Component;
|
|
24
|
+
}
|
|
25
|
+
const Descriptions = {
|
|
26
|
+
Root: DescriptionsRoot,
|
|
27
|
+
Item: part("Item", "div"),
|
|
28
|
+
Term: part("Term", "dt"),
|
|
29
|
+
Detail: part("Detail", "dd")
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Descriptions, DescriptionsRoot };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dialog as Dialog$1, DialogOpenChangeDetails } from "@ark-ui/react/dialog";
|
|
2
|
+
//#region src/components/dialog/index.d.ts
|
|
3
|
+
/** Ark's Dialog, dressed in the paper-and-ink system: the sheet dissolves
|
|
4
|
+
* in on elevation, the backdrop fades, and nested overlays stack through
|
|
5
|
+
* the shared z-index ladder. The API is Ark's own — Root, Trigger,
|
|
6
|
+
* Backdrop, Positioner, Content, Title, Description, CloseTrigger. */
|
|
7
|
+
export declare const Dialog: typeof Dialog$1;
|
|
8
|
+
//#endregion
|
|
9
|
+
export type { DialogOpenChangeDetails };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { Dialog as Dialog$1 } from "@ark-ui/react/dialog";
|
|
3
|
+
//#region src/components/dialog/index.tsx
|
|
4
|
+
/** Ark's Dialog, dressed in the paper-and-ink system: the sheet dissolves
|
|
5
|
+
* in on elevation, the backdrop fades, and nested overlays stack through
|
|
6
|
+
* the shared z-index ladder. The API is Ark's own — Root, Trigger,
|
|
7
|
+
* Backdrop, Positioner, Content, Title, Description, CloseTrigger. */
|
|
8
|
+
const Dialog = Dialog$1;
|
|
9
|
+
injectComponentStyle("dialog");
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Dialog };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { DownloadTrigger, DownloadTriggerBaseProps, DownloadTriggerProps, DownloadableData, UseDownloadProps, UseDownloadReturn, useDownload } from "@ark-ui/react/download-trigger";
|
|
2
|
+
export { DownloadTrigger, type DownloadTriggerBaseProps, type DownloadTriggerProps, type DownloadableData, type UseDownloadProps, type UseDownloadReturn, useDownload };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Drawer as Drawer$1 } from "@ark-ui/react/drawer";
|
|
2
|
+
//#region src/components/drawer/index.d.ts
|
|
3
|
+
/** Ark's Drawer, dressed in the paper-and-ink system: a full-height sheet
|
|
4
|
+
* cut flush to the edge it rises from, sliding on the machine's translate
|
|
5
|
+
* under the grabber's hand. The API is Ark's own — Root, Trigger,
|
|
6
|
+
* Backdrop, Positioner, Content, Grabber, GrabberIndicator, Title,
|
|
7
|
+
* Description, CloseTrigger, SwipeArea. */
|
|
8
|
+
export declare const Drawer: typeof Drawer$1;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { Drawer as Drawer$1 } from "@ark-ui/react/drawer";
|
|
3
|
+
//#region src/components/drawer/index.tsx
|
|
4
|
+
/** Ark's Drawer, dressed in the paper-and-ink system: a full-height sheet
|
|
5
|
+
* cut flush to the edge it rises from, sliding on the machine's translate
|
|
6
|
+
* under the grabber's hand. The API is Ark's own — Root, Trigger,
|
|
7
|
+
* Backdrop, Positioner, Content, Grabber, GrabberIndicator, Title,
|
|
8
|
+
* Description, CloseTrigger, SwipeArea. */
|
|
9
|
+
const Drawer = Drawer$1;
|
|
10
|
+
injectComponentStyle("drawer");
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Drawer };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/dynamic-input/index.d.ts
|
|
3
|
+
export interface DynamicInputProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** The rows' values; the group renders one Input per entry. */
|
|
5
|
+
value?: string[];
|
|
6
|
+
/** The fewest rows the group keeps; the remove seals yield first. */
|
|
7
|
+
min?: number;
|
|
8
|
+
/** The most rows the group grows to; the add control yields then. */
|
|
9
|
+
max?: number;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
/** The add control's visible words. */
|
|
12
|
+
addLabel?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
/** One rung of the ladder, handed to every row's field and seals. */
|
|
16
|
+
size?: "sm" | "md" | "lg";
|
|
17
|
+
onValueChange?: (value: string[]) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A column of entry rows: one Input per line, each with a quiet remove
|
|
21
|
+
* seal, and an add row at the tail. The list is controlled — every edit
|
|
22
|
+
* reports a fresh array through `onValueChange` and the caller's array
|
|
23
|
+
* stays the only truth. Deleting never drops below `min`, adding never
|
|
24
|
+
* grows past `max`, and the group always keeps one row: an entry list
|
|
25
|
+
* that emptied itself would leave the reader no place to type.
|
|
26
|
+
*/
|
|
27
|
+
export declare function DynamicInput({ value, min, max, placeholder, addLabel, disabled, invalid, size, onValueChange, children: _children, ...rest }: DynamicInputProps): import("react").JSX.Element;
|
|
28
|
+
//#endregion
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Button } from "../button/index.mjs";
|
|
2
|
+
import { Input } from "../input/index.mjs";
|
|
3
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/dynamic-input/index.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A column of entry rows: one Input per line, each with a quiet remove
|
|
8
|
+
* seal, and an add row at the tail. The list is controlled — every edit
|
|
9
|
+
* reports a fresh array through `onValueChange` and the caller's array
|
|
10
|
+
* stays the only truth. Deleting never drops below `min`, adding never
|
|
11
|
+
* grows past `max`, and the group always keeps one row: an entry list
|
|
12
|
+
* that emptied itself would leave the reader no place to type.
|
|
13
|
+
*/
|
|
14
|
+
function DynamicInput({ value, min = 0, max, placeholder, addLabel = "Add entry", disabled = false, invalid = false, size = "md", onValueChange, children: _children, ...rest }) {
|
|
15
|
+
injectComponentStyle("dynamic-input");
|
|
16
|
+
const values = value ?? [""];
|
|
17
|
+
const update = (index, next) => {
|
|
18
|
+
const rows = values.slice();
|
|
19
|
+
rows[index] = next;
|
|
20
|
+
onValueChange?.(rows);
|
|
21
|
+
};
|
|
22
|
+
const remove = (index) => {
|
|
23
|
+
const rows = values.filter((_, i) => i !== index);
|
|
24
|
+
onValueChange?.(rows.length > 0 ? rows : [""]);
|
|
25
|
+
};
|
|
26
|
+
const add = () => {
|
|
27
|
+
onValueChange?.([...values, ""]);
|
|
28
|
+
};
|
|
29
|
+
const canRemove = values.length > Math.max(min, 1);
|
|
30
|
+
const canAdd = max === void 0 || values.length < max;
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
...rest,
|
|
33
|
+
"data-scope": "dynamic-input",
|
|
34
|
+
"data-part": "root",
|
|
35
|
+
children: [values.map((value, index) => /* @__PURE__ */ jsxs("div", {
|
|
36
|
+
"data-scope": "dynamic-input",
|
|
37
|
+
"data-part": "row",
|
|
38
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
39
|
+
value,
|
|
40
|
+
placeholder,
|
|
41
|
+
disabled,
|
|
42
|
+
invalid,
|
|
43
|
+
size,
|
|
44
|
+
onValueChange: (next) => update(index, next)
|
|
45
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
46
|
+
variant: "ghost",
|
|
47
|
+
square: true,
|
|
48
|
+
size,
|
|
49
|
+
disabled: disabled || !canRemove,
|
|
50
|
+
"aria-label": `Remove entry ${index + 1}`,
|
|
51
|
+
onClick: () => remove(index),
|
|
52
|
+
children: crossIcon()
|
|
53
|
+
})]
|
|
54
|
+
}, index)), /* @__PURE__ */ jsx("div", {
|
|
55
|
+
"data-scope": "dynamic-input",
|
|
56
|
+
"data-part": "add",
|
|
57
|
+
children: /* @__PURE__ */ jsxs(Button, {
|
|
58
|
+
variant: "ghost",
|
|
59
|
+
size,
|
|
60
|
+
disabled: disabled || !canAdd,
|
|
61
|
+
onClick: () => add(),
|
|
62
|
+
children: ["+", addLabel]
|
|
63
|
+
})
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** The one glyph a remove seal needs: a single crossing stroke. */
|
|
68
|
+
function crossIcon() {
|
|
69
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
70
|
+
width: 16,
|
|
71
|
+
height: 16,
|
|
72
|
+
viewBox: "0 0 24 24",
|
|
73
|
+
fill: "none",
|
|
74
|
+
stroke: "currentColor",
|
|
75
|
+
strokeWidth: 1.75,
|
|
76
|
+
strokeLinecap: "round",
|
|
77
|
+
strokeLinejoin: "round",
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" })
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { DynamicInput };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Editable as Editable$1 } from "@ark-ui/react/editable";
|
|
3
|
+
//#region src/components/editable/index.d.ts
|
|
4
|
+
/** Ark's Editable, dressed in the paper-and-ink system: bare ink while
|
|
5
|
+
* reading, the full field recipe while editing. The API is Ark's own —
|
|
6
|
+
* Root, Area, Label, Preview, Input, EditTrigger, SubmitTrigger,
|
|
7
|
+
* CancelTrigger, Control. */
|
|
8
|
+
type EditableRootProps = ComponentProps<typeof Editable$1.Root> & {
|
|
9
|
+
/** One rung of the control-height ladder for the editing field. */
|
|
10
|
+
size?: "sm" | "md" | "lg";
|
|
11
|
+
};
|
|
12
|
+
declare function EditableRoot({ size, ...rest }: EditableRootProps): import("react").JSX.Element;
|
|
13
|
+
export declare const Editable: Omit<typeof Editable$1, "Root"> & {
|
|
14
|
+
Root: typeof EditableRoot;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|