@bysages/react 0.2.2 → 0.3.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/README.md +16 -2
- 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 +23 -0
- package/dist/components/avatar/index.mjs +15 -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/bento/index.d.mts +26 -0
- package/dist/components/bento/index.mjs +41 -0
- package/dist/components/block-ui/index.d.mts +12 -0
- package/dist/components/block-ui/index.mjs +24 -0
- package/dist/components/breadcrumb/index.d.mts +32 -0
- package/dist/components/breadcrumb/index.mjs +35 -0
- package/dist/components/browser/index.d.mts +23 -0
- package/dist/components/browser/index.mjs +70 -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 +229 -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/data-view/index.d.mts +18 -0
- package/dist/components/data-view/index.mjs +64 -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/deferred-content/index.d.mts +16 -0
- package/dist/components/deferred-content/index.mjs +34 -0
- package/dist/components/descriptions/index.d.mts +33 -0
- package/dist/components/descriptions/index.mjs +50 -0
- package/dist/components/dialog/index.d.mts +9 -0
- package/dist/components/dialog/index.mjs +11 -0
- package/dist/components/dock/index.d.mts +25 -0
- package/dist/components/dock/index.mjs +51 -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 +24 -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 +19 -0
- package/dist/components/input/index.mjs +2 -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/order-list/index.d.mts +21 -0
- package/dist/components/order-list/index.mjs +162 -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/result/index.d.mts +31 -0
- package/dist/components/result/index.mjs +59 -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 +2 -0
- package/dist/components/select/index.mjs +2 -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/spotlight/index.d.mts +12 -0
- package/dist/components/spotlight/index.mjs +33 -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 +20 -0
- package/dist/components/tabs/index.mjs +24 -0
- package/dist/components/tags-input/index.d.mts +17 -0
- package/dist/components/tags-input/index.mjs +22 -0
- package/dist/components/terminal/index.d.mts +17 -0
- package/dist/components/terminal/index.mjs +65 -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 +26 -0
- package/dist/components/timeline/index.mjs +40 -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/toolbar/index.d.mts +17 -0
- package/dist/components/toolbar/index.mjs +29 -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/user/index.d.mts +20 -0
- package/dist/components/user/index.mjs +42 -0
- package/dist/components/virtual-list/index.d.mts +17 -0
- package/dist/components/virtual-list/index.mjs +52 -0
- package/dist/components/watermark/index.d.mts +16 -0
- package/dist/components/watermark/index.mjs +80 -0
- package/dist/index-CsfxYv6J.d.mts +10383 -0
- package/dist/index-DFN9F5Zt.d.mts +42 -0
- package/dist/index-Uefyw7Im.d.mts +108 -0
- package/dist/index-uPyYiWaL.d.mts +1813 -0
- package/dist/index.d.mts +141 -15446
- package/dist/index.mjs +141 -4871
- package/dist/input-2oezH-dY.mjs +58 -0
- package/dist/mentions-DMIBCBOd.mjs +181 -0
- package/dist/select-D1xiT1oJ.mjs +68 -0
- package/package.json +103 -9
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { DatePicker } from "@ark-ui/react/date-picker";
|
|
4
|
+
//#region src/components/calendar/index.tsx
|
|
5
|
+
function chevron(dir) {
|
|
6
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
7
|
+
width: 16,
|
|
8
|
+
height: 16,
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
fill: "none",
|
|
11
|
+
stroke: "currentColor",
|
|
12
|
+
strokeWidth: 1.75,
|
|
13
|
+
"aria-hidden": true,
|
|
14
|
+
style: dir === "left" ? { transform: "rotate(180deg)" } : void 0,
|
|
15
|
+
children: /* @__PURE__ */ jsx("path", { d: "m9 5 7 7-7 7" })
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** The date-picker's month grid, standing on the page without its
|
|
19
|
+
* popup: always open, the trigger gone, the vessel a quiet card. The
|
|
20
|
+
* title zooms out through month and year grids; the grids themselves
|
|
21
|
+
* are the shared machinery — value, range selection, and focus ride
|
|
22
|
+
* Ark's own contract. */
|
|
23
|
+
function Calendar({ value, min, max, onValueChange, children, ...rest }) {
|
|
24
|
+
injectComponentStyle("calendar");
|
|
25
|
+
injectComponentStyle("date-picker");
|
|
26
|
+
const title = (dp) => {
|
|
27
|
+
const d = dp.focusedValue;
|
|
28
|
+
if (!d) return "";
|
|
29
|
+
if (dp.view === "day") return dp.format(d, {
|
|
30
|
+
month: "long",
|
|
31
|
+
year: "numeric"
|
|
32
|
+
});
|
|
33
|
+
if (dp.view === "month") return dp.format(d, { year: "numeric" });
|
|
34
|
+
const decade = Math.floor(d.year / 10) * 10;
|
|
35
|
+
return `${decade} - ${decade + 9}`;
|
|
36
|
+
};
|
|
37
|
+
const header = /* @__PURE__ */ jsx("div", {
|
|
38
|
+
"data-scope": "calendar",
|
|
39
|
+
"data-part": "header",
|
|
40
|
+
children: /* @__PURE__ */ jsxs(DatePicker.ViewControl, { children: [
|
|
41
|
+
/* @__PURE__ */ jsx(DatePicker.PrevTrigger, { children: chevron("left") }),
|
|
42
|
+
/* @__PURE__ */ jsx(DatePicker.Context, { children: (dp) => /* @__PURE__ */ jsx(DatePicker.ViewTrigger, { children: title(dp) }) }),
|
|
43
|
+
/* @__PURE__ */ jsx(DatePicker.NextTrigger, { children: chevron("right") })
|
|
44
|
+
] })
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
47
|
+
...rest,
|
|
48
|
+
"data-scope": "calendar",
|
|
49
|
+
"data-part": "root",
|
|
50
|
+
children: [/* @__PURE__ */ jsxs(DatePicker.Root, {
|
|
51
|
+
open: true,
|
|
52
|
+
closeOnSelect: true,
|
|
53
|
+
inline: true,
|
|
54
|
+
...value !== void 0 ? { value } : {},
|
|
55
|
+
...min !== void 0 ? { min } : {},
|
|
56
|
+
...max !== void 0 ? { max } : {},
|
|
57
|
+
onValueChange: (details) => onValueChange?.(details.value),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsxs(DatePicker.View, {
|
|
60
|
+
view: "day",
|
|
61
|
+
children: [header, /* @__PURE__ */ jsxs(DatePicker.Table, { children: [/* @__PURE__ */ jsx(DatePicker.TableHead, { children: /* @__PURE__ */ jsx(DatePicker.TableRow, { children: /* @__PURE__ */ jsx(DatePicker.Context, { children: (dp) => dp.weekDays.map((day, id) => /* @__PURE__ */ jsx(DatePicker.TableHeader, {
|
|
62
|
+
"aria-label": day.long,
|
|
63
|
+
children: day.narrow
|
|
64
|
+
}, id)) }) }) }), /* @__PURE__ */ jsx(DatePicker.TableBody, { children: /* @__PURE__ */ jsx(DatePicker.Context, { children: (dp) => dp.weeks.map((week, id) => /* @__PURE__ */ jsx(DatePicker.TableRow, { children: week.map((day, id2) => /* @__PURE__ */ jsx(DatePicker.TableCell, {
|
|
65
|
+
value: day,
|
|
66
|
+
children: /* @__PURE__ */ jsx(DatePicker.TableCellTrigger, { children: day.day })
|
|
67
|
+
}, id2)) }, id)) }) })] })]
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsxs(DatePicker.View, {
|
|
70
|
+
view: "month",
|
|
71
|
+
children: [header, /* @__PURE__ */ jsx(DatePicker.Table, {
|
|
72
|
+
columns: 3,
|
|
73
|
+
children: /* @__PURE__ */ jsx(DatePicker.TableBody, { children: /* @__PURE__ */ jsx(DatePicker.Context, { children: (dp) => dp.getMonthsGrid({ columns: 3 }).map((months, id) => /* @__PURE__ */ jsx(DatePicker.TableRow, { children: months.map((month, id2) => /* @__PURE__ */ jsx(DatePicker.TableCell, {
|
|
74
|
+
value: month.value,
|
|
75
|
+
columns: 3,
|
|
76
|
+
children: /* @__PURE__ */ jsx(DatePicker.TableCellTrigger, { children: month.label })
|
|
77
|
+
}, id2)) }, id)) }) })
|
|
78
|
+
})]
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ jsxs(DatePicker.View, {
|
|
81
|
+
view: "year",
|
|
82
|
+
children: [header, /* @__PURE__ */ jsx(DatePicker.Table, {
|
|
83
|
+
columns: 3,
|
|
84
|
+
children: /* @__PURE__ */ jsx(DatePicker.TableBody, { children: /* @__PURE__ */ jsx(DatePicker.Context, { children: (dp) => dp.getYearsGrid({ columns: 3 }).map((years, id) => /* @__PURE__ */ jsx(DatePicker.TableRow, { children: years.map((year, id2) => /* @__PURE__ */ jsx(DatePicker.TableCell, {
|
|
85
|
+
value: year.value,
|
|
86
|
+
columns: 3,
|
|
87
|
+
children: /* @__PURE__ */ jsx(DatePicker.TableCellTrigger, { children: year.label })
|
|
88
|
+
}, id2)) }, id)) }) })
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
}), children]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { Calendar };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/card/index.d.ts
|
|
3
|
+
export declare const Card: {
|
|
4
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
}): import("react").JSX.Element | null;
|
|
7
|
+
displayName: string;
|
|
8
|
+
} & {
|
|
9
|
+
Root: {
|
|
10
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
}): import("react").JSX.Element | null;
|
|
13
|
+
displayName: string;
|
|
14
|
+
};
|
|
15
|
+
Header: {
|
|
16
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
}): import("react").JSX.Element | null;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
Title: {
|
|
22
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
23
|
+
asChild?: boolean;
|
|
24
|
+
}): import("react").JSX.Element | null;
|
|
25
|
+
displayName: string;
|
|
26
|
+
};
|
|
27
|
+
Description: {
|
|
28
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
29
|
+
asChild?: boolean;
|
|
30
|
+
}): import("react").JSX.Element | null;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
33
|
+
Content: {
|
|
34
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
35
|
+
asChild?: boolean;
|
|
36
|
+
}): import("react").JSX.Element | null;
|
|
37
|
+
displayName: string;
|
|
38
|
+
};
|
|
39
|
+
Footer: {
|
|
40
|
+
({ asChild, children, ...rest }: HTMLAttributes<HTMLElement> & {
|
|
41
|
+
asChild?: boolean;
|
|
42
|
+
}): import("react").JSX.Element | null;
|
|
43
|
+
displayName: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Children, cloneElement, isValidElement } from "react";
|
|
4
|
+
//#region src/components/card/index.tsx
|
|
5
|
+
/** A vessel: round, resting at the first elevation, one hairline for its
|
|
6
|
+
* edge. Root, Header, Title, Description, Content, Footer — sections
|
|
7
|
+
* carry their own whitespace, so any subset composes. */
|
|
8
|
+
function part(name, tag) {
|
|
9
|
+
const Tag = tag;
|
|
10
|
+
const Component = ({ asChild, children, ...rest }) => {
|
|
11
|
+
const partProps = {
|
|
12
|
+
...rest,
|
|
13
|
+
"data-scope": "card",
|
|
14
|
+
"data-part": name.toLowerCase()
|
|
15
|
+
};
|
|
16
|
+
if (asChild) {
|
|
17
|
+
const child = Children.only(children);
|
|
18
|
+
return isValidElement(child) ? cloneElement(child, partProps) : null;
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
21
|
+
...partProps,
|
|
22
|
+
children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
Component.displayName = "Card" + name;
|
|
26
|
+
return Component;
|
|
27
|
+
}
|
|
28
|
+
const Root = part("Root", "section");
|
|
29
|
+
const Header = part("Header", "header");
|
|
30
|
+
const Title = part("Title", "h3");
|
|
31
|
+
const Description = part("Description", "p");
|
|
32
|
+
const Content = part("Content", "div");
|
|
33
|
+
const Footer = part("Footer", "footer");
|
|
34
|
+
const Card = Object.assign(Root, {
|
|
35
|
+
Root,
|
|
36
|
+
Header,
|
|
37
|
+
Title,
|
|
38
|
+
Description,
|
|
39
|
+
Content,
|
|
40
|
+
Footer
|
|
41
|
+
});
|
|
42
|
+
injectComponentStyle("card");
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Card };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Carousel as Carousel$1 } from "@ark-ui/react/carousel";
|
|
2
|
+
//#region src/components/carousel/index.d.ts
|
|
3
|
+
/** Ark's Carousel, dressed in the paper-and-ink system: slides ride in one
|
|
4
|
+
* hairline-clipped lane, the triggers are quiet outline controls, and the
|
|
5
|
+
* current indicator alone carries the ink. The API is Ark's own — Root,
|
|
6
|
+
* Control, PrevTrigger, NextTrigger, ItemGroup, Item, IndicatorGroup,
|
|
7
|
+
* Indicator, AutoplayTrigger, ProgressText. */
|
|
8
|
+
export declare const Carousel: typeof Carousel$1;
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { Carousel as Carousel$1 } from "@ark-ui/react/carousel";
|
|
3
|
+
//#region src/components/carousel/index.tsx
|
|
4
|
+
/** Ark's Carousel, dressed in the paper-and-ink system: slides ride in one
|
|
5
|
+
* hairline-clipped lane, the triggers are quiet outline controls, and the
|
|
6
|
+
* current indicator alone carries the ink. The API is Ark's own — Root,
|
|
7
|
+
* Control, PrevTrigger, NextTrigger, ItemGroup, Item, IndicatorGroup,
|
|
8
|
+
* Indicator, AutoplayTrigger, ProgressText. */
|
|
9
|
+
const Carousel = Carousel$1;
|
|
10
|
+
injectComponentStyle("carousel");
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Carousel };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/cascade-select/index.d.ts
|
|
3
|
+
export interface CascadeSelectNode {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
children?: CascadeSelectNode[];
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A corridor of linked columns: pick a branch and the next column
|
|
11
|
+
* dissolves open beside it, until a leaf click settles the whole path.
|
|
12
|
+
* `value` is the selected path (or paths, when `multiple`) — the joined
|
|
13
|
+
* labels ride the trigger. `highlightTrigger: "hover"` turns the
|
|
14
|
+
* classic cascading menu: pointing is enough to unfold. `filterable`
|
|
15
|
+
* swaps the corridor for a flat list of matching paths while a query
|
|
16
|
+
* runs — each hit still reads as its full route.
|
|
17
|
+
*/
|
|
18
|
+
export interface CascadeSelectProps extends HTMLAttributes<HTMLDivElement> {
|
|
19
|
+
value?: string[][];
|
|
20
|
+
data: CascadeSelectNode[];
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
highlightTrigger?: "click" | "hover";
|
|
23
|
+
filterable?: boolean;
|
|
24
|
+
multiple?: boolean;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** One rung of the control-height ladder for the trigger. */
|
|
27
|
+
size?: "sm" | "md" | "lg";
|
|
28
|
+
onValueChange?: (value: string[][]) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare function CascadeSelect({ value, data, placeholder, highlightTrigger, filterable, multiple, disabled, size, onValueChange, ...rest }: CascadeSelectProps): import("react").JSX.Element;
|
|
31
|
+
//#endregion
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { t as Input } from "../../input-2oezH-dY.mjs";
|
|
2
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useId, useMemo, useState } from "react";
|
|
5
|
+
import { Portal } from "@ark-ui/react/portal";
|
|
6
|
+
import { useEnvironmentContext } from "@ark-ui/react/environment";
|
|
7
|
+
import { useFilter, useLocaleContext } from "@ark-ui/react/locale";
|
|
8
|
+
import * as cascade from "@zag-js/cascade-select";
|
|
9
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
10
|
+
//#region src/components/cascade-select/index.tsx
|
|
11
|
+
const chevronDown = /* @__PURE__ */ jsx("svg", {
|
|
12
|
+
viewBox: "0 0 24 24",
|
|
13
|
+
fill: "none",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeWidth: 2,
|
|
16
|
+
strokeLinecap: "round",
|
|
17
|
+
strokeLinejoin: "round",
|
|
18
|
+
"aria-hidden": "true",
|
|
19
|
+
children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
|
|
20
|
+
});
|
|
21
|
+
const chevronRight = /* @__PURE__ */ jsx("svg", {
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "none",
|
|
24
|
+
stroke: "currentColor",
|
|
25
|
+
strokeWidth: 2,
|
|
26
|
+
strokeLinecap: "round",
|
|
27
|
+
strokeLinejoin: "round",
|
|
28
|
+
"aria-hidden": "true",
|
|
29
|
+
children: /* @__PURE__ */ jsx("path", { d: "m9 18 6-6-6-6" })
|
|
30
|
+
});
|
|
31
|
+
const checkGlyph = /* @__PURE__ */ jsx("svg", {
|
|
32
|
+
viewBox: "0 0 24 24",
|
|
33
|
+
fill: "none",
|
|
34
|
+
stroke: "currentColor",
|
|
35
|
+
strokeWidth: 3,
|
|
36
|
+
strokeLinecap: "round",
|
|
37
|
+
strokeLinejoin: "round",
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: /* @__PURE__ */ jsx("path", { d: "m5 12.5 5 5L19 7" })
|
|
40
|
+
});
|
|
41
|
+
function CascadeSelect({ value, data, placeholder = "Select…", highlightTrigger, filterable = false, multiple = false, disabled = false, size = "md", onValueChange, ...rest }) {
|
|
42
|
+
injectComponentStyle("cascade-select");
|
|
43
|
+
const id = useId();
|
|
44
|
+
const locale = useLocaleContext();
|
|
45
|
+
const env = useEnvironmentContext();
|
|
46
|
+
const collection = cascade.collection({
|
|
47
|
+
nodeToValue: (node) => node.value,
|
|
48
|
+
nodeToString: (node) => node.label,
|
|
49
|
+
nodeToChildren: (node) => node.children ?? [],
|
|
50
|
+
rootNode: {
|
|
51
|
+
value: "ROOT",
|
|
52
|
+
label: "",
|
|
53
|
+
children: data
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const service = useMachine(cascade.machine, {
|
|
57
|
+
id,
|
|
58
|
+
collection,
|
|
59
|
+
dir: locale.dir,
|
|
60
|
+
getRootNode: env.getRootNode.bind(env),
|
|
61
|
+
disabled: disabled || void 0,
|
|
62
|
+
multiple: multiple || void 0,
|
|
63
|
+
...value !== void 0 ? { value } : {},
|
|
64
|
+
...highlightTrigger != null ? { highlightTrigger } : {},
|
|
65
|
+
onValueChange(details) {
|
|
66
|
+
onValueChange?.(details.value);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const api = cascade.connect(service, normalizeProps);
|
|
70
|
+
const [query, setQuery] = useState("");
|
|
71
|
+
const filterFns = useFilter({ sensitivity: "base" });
|
|
72
|
+
const filtering = filterable && query.trim().length > 0;
|
|
73
|
+
/** The corridor's answer to a query: every leaf whose route matches —
|
|
74
|
+
* the query may land on any hop, and the whole route still shows. */
|
|
75
|
+
const matchPaths = useMemo(() => {
|
|
76
|
+
if (!filtering) return [];
|
|
77
|
+
const q = query.trim();
|
|
78
|
+
const hits = [];
|
|
79
|
+
const walk = (nodes, path, labels, matched) => {
|
|
80
|
+
for (const node of nodes ?? []) {
|
|
81
|
+
const hit = matched || filterFns.contains(node.label, q);
|
|
82
|
+
const nextPath = [...path, node.value];
|
|
83
|
+
const nextLabels = [...labels, node.label];
|
|
84
|
+
if (node.children?.length) walk(node.children, nextPath, nextLabels, hit);
|
|
85
|
+
else if (hit) hits.push({
|
|
86
|
+
path: nextPath,
|
|
87
|
+
labels: nextLabels
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
walk(data, [], [], false);
|
|
92
|
+
return hits;
|
|
93
|
+
}, [
|
|
94
|
+
filtering,
|
|
95
|
+
query,
|
|
96
|
+
filterFns,
|
|
97
|
+
data
|
|
98
|
+
]);
|
|
99
|
+
const isSelected = (path) => (value ?? []).some((p) => p.join("/") === path.join("/"));
|
|
100
|
+
function pickMatch(path) {
|
|
101
|
+
if (multiple) {
|
|
102
|
+
const current = value ?? [];
|
|
103
|
+
const key = path.join("/");
|
|
104
|
+
const next = current.some((p) => p.join("/") === key) ? current.filter((p) => p.join("/") !== key) : [...current, path];
|
|
105
|
+
api.setValue(next);
|
|
106
|
+
} else {
|
|
107
|
+
api.selectValue(path);
|
|
108
|
+
api.setOpen(false);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** The machine's `valueAsString` only updates through its select
|
|
112
|
+
* event, so an externally-set `value` would render the placeholder
|
|
113
|
+
* forever — resolve the labels from the data instead. */
|
|
114
|
+
function labelsFor(path) {
|
|
115
|
+
const out = [];
|
|
116
|
+
let nodes = data;
|
|
117
|
+
for (const entry of path) {
|
|
118
|
+
const node = nodes?.find((n) => n.value === entry);
|
|
119
|
+
if (!node) return null;
|
|
120
|
+
out.push(node.label);
|
|
121
|
+
nodes = node.children;
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
const display = (value ?? []).map((path) => labelsFor(path)?.join(" / ")).filter((label) => label != null).join(", ");
|
|
126
|
+
/** One column per walk of the highlighted path — the list binds to
|
|
127
|
+
* the node, the next column hangs off its highlighted child. */
|
|
128
|
+
function renderColumn(node, indexPath, valuePath) {
|
|
129
|
+
const nodeProps = {
|
|
130
|
+
item: node,
|
|
131
|
+
indexPath,
|
|
132
|
+
value: valuePath
|
|
133
|
+
};
|
|
134
|
+
const nodeState = api.getItemState(nodeProps);
|
|
135
|
+
const children = collection.getNodeChildren(node);
|
|
136
|
+
const list = /* @__PURE__ */ jsx("ul", {
|
|
137
|
+
...api.getListProps(nodeProps),
|
|
138
|
+
children: children.map((item, index) => {
|
|
139
|
+
const itemValue = collection.getNodeValue(item);
|
|
140
|
+
const itemProps = {
|
|
141
|
+
item,
|
|
142
|
+
indexPath: [...indexPath, index],
|
|
143
|
+
value: [...valuePath, itemValue]
|
|
144
|
+
};
|
|
145
|
+
const itemState = api.getItemState(itemProps);
|
|
146
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
147
|
+
...api.getItemProps(itemProps),
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ jsx("span", {
|
|
150
|
+
...api.getItemTextProps(itemProps),
|
|
151
|
+
children: item.label
|
|
152
|
+
}),
|
|
153
|
+
itemState.hasChildren ? /* @__PURE__ */ jsx("span", {
|
|
154
|
+
"data-scope": "cascade-select",
|
|
155
|
+
"data-part": "branch-indicator",
|
|
156
|
+
"aria-hidden": "true",
|
|
157
|
+
children: chevronRight
|
|
158
|
+
}) : null,
|
|
159
|
+
/* @__PURE__ */ jsx("span", {
|
|
160
|
+
...api.getItemIndicatorProps(itemProps),
|
|
161
|
+
children: checkGlyph
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
}, itemValue);
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
const next = nodeState.highlightedChild;
|
|
168
|
+
const child = next != null && collection.isBranchNode(next) ? renderColumn(next, [...indexPath, nodeState.highlightedIndex], [...valuePath, collection.getNodeValue(next)]) : null;
|
|
169
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [list, child] });
|
|
170
|
+
}
|
|
171
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
172
|
+
...rest,
|
|
173
|
+
...api.getRootProps(),
|
|
174
|
+
"data-size": size,
|
|
175
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
176
|
+
...api.getControlProps(),
|
|
177
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
178
|
+
...api.getTriggerProps(),
|
|
179
|
+
onClick: (event) => {
|
|
180
|
+
api.getTriggerProps().onClick?.(event);
|
|
181
|
+
setQuery("");
|
|
182
|
+
},
|
|
183
|
+
disabled: disabled || void 0,
|
|
184
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
185
|
+
...api.getValueTextProps(),
|
|
186
|
+
children: display || placeholder
|
|
187
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
188
|
+
...api.getIndicatorProps(),
|
|
189
|
+
children: chevronDown
|
|
190
|
+
})]
|
|
191
|
+
})
|
|
192
|
+
}), /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx("div", {
|
|
193
|
+
...api.getPositionerProps(),
|
|
194
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
195
|
+
...api.getContentProps(),
|
|
196
|
+
"data-size": size,
|
|
197
|
+
children: [filterable ? /* @__PURE__ */ jsx("div", {
|
|
198
|
+
"data-scope": "cascade-select",
|
|
199
|
+
"data-part": "search",
|
|
200
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
201
|
+
size: "sm",
|
|
202
|
+
value: query,
|
|
203
|
+
onValueChange: setQuery,
|
|
204
|
+
placeholder: "Filter…",
|
|
205
|
+
"aria-label": "Filter options"
|
|
206
|
+
})
|
|
207
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
208
|
+
"data-scope": "cascade-select",
|
|
209
|
+
"data-part": "corridor",
|
|
210
|
+
"data-flow": filtering ? "flat" : "columns",
|
|
211
|
+
children: filtering ? matchPaths.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
212
|
+
"data-scope": "cascade-select",
|
|
213
|
+
"data-part": "empty",
|
|
214
|
+
children: "Nothing matches"
|
|
215
|
+
}) : matchPaths.map((hit) => /* @__PURE__ */ jsx("button", {
|
|
216
|
+
type: "button",
|
|
217
|
+
"data-scope": "cascade-select",
|
|
218
|
+
"data-part": "match",
|
|
219
|
+
"data-selected": isSelected(hit.path) || void 0,
|
|
220
|
+
onClick: () => pickMatch(hit.path),
|
|
221
|
+
children: hit.labels.join(" / ")
|
|
222
|
+
}, hit.path.join("/"))) : renderColumn(collection.rootNode, [], [])
|
|
223
|
+
})]
|
|
224
|
+
})
|
|
225
|
+
}) })]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
export { CascadeSelect };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Checkbox as Checkbox$1 } from "@ark-ui/react/checkbox";
|
|
3
|
+
//#region src/components/checkbox/index.d.ts
|
|
4
|
+
type CheckboxRootProps = ComponentProps<typeof Checkbox$1.Root> & {
|
|
5
|
+
/** One rung for the control's box: the tick scales with it. */
|
|
6
|
+
size?: "sm" | "md" | "lg";
|
|
7
|
+
};
|
|
8
|
+
declare function CheckboxRoot({ size, ...rest }: CheckboxRootProps): import("react").JSX.Element;
|
|
9
|
+
/** Ark's Checkbox, dressed in the paper-and-ink system: a square-cut seal
|
|
10
|
+
* that fills flat with primary ink when ticked, the mark springing into
|
|
11
|
+
* place. The API is Ark's own — Root, Label, Control, Indicator,
|
|
12
|
+
* HiddenInput. */
|
|
13
|
+
export declare const Checkbox: Omit<typeof Checkbox$1, "Root"> & {
|
|
14
|
+
Root: typeof CheckboxRoot;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Checkbox as Checkbox$1 } from "@ark-ui/react/checkbox";
|
|
4
|
+
//#region src/components/checkbox/index.tsx
|
|
5
|
+
function CheckboxRoot({ size = "md", ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
7
|
+
...rest,
|
|
8
|
+
"data-size": size
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/** Ark's Checkbox, dressed in the paper-and-ink system: a square-cut seal
|
|
12
|
+
* that fills flat with primary ink when ticked, the mark springing into
|
|
13
|
+
* place. The API is Ark's own — Root, Label, Control, Indicator,
|
|
14
|
+
* HiddenInput. */
|
|
15
|
+
const Checkbox = {
|
|
16
|
+
...Checkbox$1,
|
|
17
|
+
Root: CheckboxRoot
|
|
18
|
+
};
|
|
19
|
+
injectComponentStyle("checkbox");
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Checkbox };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/checkbox-group/index.d.ts
|
|
3
|
+
export interface CheckboxOption {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckboxGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
value?: string[];
|
|
10
|
+
options: CheckboxOption[];
|
|
11
|
+
layout?: "vertical" | "horizontal";
|
|
12
|
+
/** One register for every box: falls onto each root's data-size for
|
|
13
|
+
* the stylesheet to retune. */
|
|
14
|
+
size?: "sm" | "md" | "lg";
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
onValueChange?: (value: string[]) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One question, many answers: a labelled stack (or row) of the seal-cut
|
|
21
|
+
* checkboxes bound to a single array. Toggling a box adds or removes its
|
|
22
|
+
* value; the group itself is semantics (`role="group"`), the boxes stay
|
|
23
|
+
* the machine-driven originals. Inside a `Field.Root` the group picks up
|
|
24
|
+
* the field context, so the invalid and disabled states a Form routes to
|
|
25
|
+
* its name dress every box at once.
|
|
26
|
+
*/
|
|
27
|
+
export declare function CheckboxGroup({ value, options, layout, size, invalid, disabled, onValueChange, ...rest }: CheckboxGroupProps): import("react").JSX.Element;
|
|
28
|
+
//#endregion
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { useFieldContext } from "@ark-ui/react/field";
|
|
5
|
+
import { Checkbox } from "@ark-ui/react/checkbox";
|
|
6
|
+
//#region src/components/checkbox-group/index.tsx
|
|
7
|
+
const checkGlyph = /* @__PURE__ */ jsx("svg", {
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
fill: "none",
|
|
10
|
+
stroke: "currentColor",
|
|
11
|
+
strokeWidth: 3,
|
|
12
|
+
strokeLinecap: "round",
|
|
13
|
+
strokeLinejoin: "round",
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
children: /* @__PURE__ */ jsx("path", { d: "m5 12.5 5 5L19 7" })
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* One question, many answers: a labelled stack (or row) of the seal-cut
|
|
19
|
+
* checkboxes bound to a single array. Toggling a box adds or removes its
|
|
20
|
+
* value; the group itself is semantics (`role="group"`), the boxes stay
|
|
21
|
+
* the machine-driven originals. Inside a `Field.Root` the group picks up
|
|
22
|
+
* the field context, so the invalid and disabled states a Form routes to
|
|
23
|
+
* its name dress every box at once.
|
|
24
|
+
*/
|
|
25
|
+
function CheckboxGroup({ value = [], options, layout = "vertical", size = "md", invalid = false, disabled = false, onValueChange, ...rest }) {
|
|
26
|
+
injectComponentStyle("checkbox-group");
|
|
27
|
+
injectComponentStyle("checkbox");
|
|
28
|
+
const field = useFieldContext();
|
|
29
|
+
const uid = useId();
|
|
30
|
+
const selected = new Set(value);
|
|
31
|
+
const isInvalid = invalid || field?.invalid === true;
|
|
32
|
+
const isDisabled = disabled || field?.disabled === true;
|
|
33
|
+
function toggle(option) {
|
|
34
|
+
const next = new Set(selected);
|
|
35
|
+
if (next.has(option)) next.delete(option);
|
|
36
|
+
else next.add(option);
|
|
37
|
+
onValueChange?.([...next]);
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx("div", {
|
|
40
|
+
...rest,
|
|
41
|
+
role: "group",
|
|
42
|
+
"data-scope": "checkbox-group",
|
|
43
|
+
"data-part": "root",
|
|
44
|
+
"data-layout": layout,
|
|
45
|
+
"data-invalid": isInvalid ? "" : void 0,
|
|
46
|
+
children: options.map((option) => /* @__PURE__ */ jsxs(Checkbox.Root, {
|
|
47
|
+
ids: {
|
|
48
|
+
label: `${uid}:${option.value}:label`,
|
|
49
|
+
hiddenInput: `${uid}:${option.value}:input`
|
|
50
|
+
},
|
|
51
|
+
"data-size": size,
|
|
52
|
+
checked: selected.has(option.value),
|
|
53
|
+
invalid: isInvalid,
|
|
54
|
+
disabled: isDisabled || option.disabled === true,
|
|
55
|
+
onCheckedChange: () => toggle(option.value),
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Checkbox.Control, { children: /* @__PURE__ */ jsx(Checkbox.Indicator, { children: checkGlyph }) }),
|
|
58
|
+
/* @__PURE__ */ jsx(Checkbox.Label, { children: option.label }),
|
|
59
|
+
/* @__PURE__ */ jsx(Checkbox.HiddenInput, {})
|
|
60
|
+
]
|
|
61
|
+
}, option.value))
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { CheckboxGroup };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/components/chip/index.d.ts
|
|
3
|
+
/** A counting coin: the numeric value, capped at `max` with an ellipsis
|
|
4
|
+
* of the remainder ("99+"). */
|
|
5
|
+
export interface ChipProps extends HTMLAttributes<HTMLSpanElement> {
|
|
6
|
+
value: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
tone?: "ink" | "info" | "success" | "warning" | "danger";
|
|
9
|
+
variant?: "solid" | "subtle" | "outline";
|
|
10
|
+
}
|
|
11
|
+
export declare function Chip({ value, max, tone, variant, ...rest }: ChipProps): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { injectComponentStyle } from "@bysages/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/chip/index.tsx
|
|
4
|
+
function Chip({ value, max, tone = "ink", variant = "solid", ...rest }) {
|
|
5
|
+
injectComponentStyle("chip");
|
|
6
|
+
const text = max != null && value > max ? `${max}+` : String(value);
|
|
7
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8
|
+
...rest,
|
|
9
|
+
"data-scope": "chip",
|
|
10
|
+
"data-part": "root",
|
|
11
|
+
"data-tone": tone,
|
|
12
|
+
"data-variant": variant,
|
|
13
|
+
children: text
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Chip };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { Clipboard as Clipboard$1 } from "@ark-ui/react/clipboard";
|
|
3
|
+
//#region src/components/clipboard/index.d.ts
|
|
4
|
+
/** Ark's Clipboard, dressed in the paper-and-ink system: a hairline value
|
|
5
|
+
* field beside an icon-sized copy trigger whose ink turns bamboo while the
|
|
6
|
+
* copy is confirmed. The API is Ark's own — Root, Label, Control, Input,
|
|
7
|
+
* Trigger, Indicator, Context, HiddenInput. */
|
|
8
|
+
type ClipboardRootProps = ComponentProps<typeof Clipboard$1.Root> & {
|
|
9
|
+
/** One rung of the control-height ladder for the value field and
|
|
10
|
+
* its copy seal. */
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
};
|
|
13
|
+
declare function ClipboardRoot({ size, ...rest }: ClipboardRootProps): import("react").JSX.Element;
|
|
14
|
+
export declare const Clipboard: Omit<typeof Clipboard$1, "Root"> & {
|
|
15
|
+
Root: typeof ClipboardRoot;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|