@kizunacms/ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/LICENSE.MD +9 -0
  2. package/README.md +18 -2
  3. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  4. package/dist/admin.css +2158 -0
  5. package/dist/client.cjs +99 -0
  6. package/dist/client.d.cts +46 -0
  7. package/dist/client.d.mts +46 -0
  8. package/dist/client.mjs +45 -0
  9. package/dist/controls/AdminLink.cjs +21 -0
  10. package/dist/controls/AdminLink.d.cts +16 -0
  11. package/dist/controls/AdminLink.d.mts +16 -0
  12. package/dist/controls/AdminLink.mjs +20 -0
  13. package/dist/controls/Avatar.cjs +15 -0
  14. package/dist/controls/Avatar.d.cts +17 -0
  15. package/dist/controls/Avatar.d.mts +17 -0
  16. package/dist/controls/Avatar.mjs +14 -0
  17. package/dist/controls/Button.cjs +20 -0
  18. package/dist/controls/Button.d.cts +18 -0
  19. package/dist/controls/Button.d.mts +18 -0
  20. package/dist/controls/Button.mjs +18 -0
  21. package/dist/controls/ButtonTip.cjs +40 -0
  22. package/dist/controls/ButtonTip.mjs +39 -0
  23. package/dist/controls/Checkbox.cjs +27 -0
  24. package/dist/controls/Checkbox.d.cts +15 -0
  25. package/dist/controls/Checkbox.d.mts +15 -0
  26. package/dist/controls/Checkbox.mjs +26 -0
  27. package/dist/controls/ChipsInput.cjs +145 -0
  28. package/dist/controls/ChipsInput.mjs +143 -0
  29. package/dist/controls/ConfirmDialog.cjs +63 -0
  30. package/dist/controls/ConfirmDialog.d.cts +38 -0
  31. package/dist/controls/ConfirmDialog.d.mts +38 -0
  32. package/dist/controls/ConfirmDialog.mjs +62 -0
  33. package/dist/controls/Counter.cjs +18 -0
  34. package/dist/controls/Counter.mjs +17 -0
  35. package/dist/controls/InfoTip.cjs +29 -0
  36. package/dist/controls/InfoTip.d.cts +11 -0
  37. package/dist/controls/InfoTip.d.mts +11 -0
  38. package/dist/controls/InfoTip.mjs +28 -0
  39. package/dist/controls/LocalTime.cjs +62 -0
  40. package/dist/controls/LocalTime.d.cts +30 -0
  41. package/dist/controls/LocalTime.d.mts +30 -0
  42. package/dist/controls/LocalTime.mjs +61 -0
  43. package/dist/controls/Logo.cjs +56 -0
  44. package/dist/controls/Logo.d.cts +13 -0
  45. package/dist/controls/Logo.d.mts +13 -0
  46. package/dist/controls/Logo.mjs +54 -0
  47. package/dist/controls/MenuButton.cjs +118 -0
  48. package/dist/controls/MenuButton.d.cts +88 -0
  49. package/dist/controls/MenuButton.d.mts +88 -0
  50. package/dist/controls/MenuButton.mjs +117 -0
  51. package/dist/controls/Select.cjs +67 -0
  52. package/dist/controls/Select.d.cts +42 -0
  53. package/dist/controls/Select.d.mts +42 -0
  54. package/dist/controls/Select.mjs +66 -0
  55. package/dist/controls/Status.cjs +31 -0
  56. package/dist/controls/Status.d.cts +14 -0
  57. package/dist/controls/Status.d.mts +14 -0
  58. package/dist/controls/Status.mjs +30 -0
  59. package/dist/controls/TrailingButton.cjs +22 -0
  60. package/dist/controls/TrailingButton.d.cts +18 -0
  61. package/dist/controls/TrailingButton.d.mts +18 -0
  62. package/dist/controls/TrailingButton.mjs +21 -0
  63. package/dist/controls/icon.cjs +42 -0
  64. package/dist/controls/icon.mjs +38 -0
  65. package/dist/inputs/Affixed.cjs +49 -0
  66. package/dist/inputs/Affixed.mjs +47 -0
  67. package/dist/inputs/CheckboxField.cjs +22 -0
  68. package/dist/inputs/CheckboxField.d.cts +10 -0
  69. package/dist/inputs/CheckboxField.d.mts +10 -0
  70. package/dist/inputs/CheckboxField.mjs +21 -0
  71. package/dist/inputs/DateField.cjs +22 -0
  72. package/dist/inputs/DateField.d.cts +10 -0
  73. package/dist/inputs/DateField.d.mts +10 -0
  74. package/dist/inputs/DateField.mjs +21 -0
  75. package/dist/inputs/DateTimeField.cjs +56 -0
  76. package/dist/inputs/DateTimeField.d.cts +10 -0
  77. package/dist/inputs/DateTimeField.d.mts +10 -0
  78. package/dist/inputs/DateTimeField.mjs +55 -0
  79. package/dist/inputs/EmailField.cjs +20 -0
  80. package/dist/inputs/EmailField.d.cts +10 -0
  81. package/dist/inputs/EmailField.d.mts +10 -0
  82. package/dist/inputs/EmailField.mjs +19 -0
  83. package/dist/inputs/FallbackReset.cjs +23 -0
  84. package/dist/inputs/FallbackReset.mjs +21 -0
  85. package/dist/inputs/FieldFor.cjs +48 -0
  86. package/dist/inputs/FieldFor.d.cts +16 -0
  87. package/dist/inputs/FieldFor.d.mts +16 -0
  88. package/dist/inputs/FieldFor.mjs +46 -0
  89. package/dist/inputs/FieldFrame.cjs +97 -0
  90. package/dist/inputs/FieldFrame.d.cts +29 -0
  91. package/dist/inputs/FieldFrame.d.mts +29 -0
  92. package/dist/inputs/FieldFrame.mjs +95 -0
  93. package/dist/inputs/FieldList.cjs +39 -0
  94. package/dist/inputs/FieldList.d.cts +16 -0
  95. package/dist/inputs/FieldList.d.mts +16 -0
  96. package/dist/inputs/FieldList.mjs +38 -0
  97. package/dist/inputs/FileField.cjs +363 -0
  98. package/dist/inputs/FileField.d.cts +10 -0
  99. package/dist/inputs/FileField.d.mts +10 -0
  100. package/dist/inputs/FileField.mjs +362 -0
  101. package/dist/inputs/FocalPointPicker.cjs +114 -0
  102. package/dist/inputs/FocalPointPicker.mjs +113 -0
  103. package/dist/inputs/JsonField.cjs +21 -0
  104. package/dist/inputs/JsonField.d.cts +10 -0
  105. package/dist/inputs/JsonField.d.mts +10 -0
  106. package/dist/inputs/JsonField.mjs +20 -0
  107. package/dist/inputs/NumberField.cjs +42 -0
  108. package/dist/inputs/NumberField.d.cts +10 -0
  109. package/dist/inputs/NumberField.d.mts +10 -0
  110. package/dist/inputs/NumberField.mjs +41 -0
  111. package/dist/inputs/PasswordField.cjs +41 -0
  112. package/dist/inputs/PasswordField.d.cts +26 -0
  113. package/dist/inputs/PasswordField.d.mts +26 -0
  114. package/dist/inputs/PasswordField.mjs +39 -0
  115. package/dist/inputs/PickerButton.cjs +56 -0
  116. package/dist/inputs/PickerButton.mjs +55 -0
  117. package/dist/inputs/RelationshipField.cjs +162 -0
  118. package/dist/inputs/RelationshipField.d.cts +10 -0
  119. package/dist/inputs/RelationshipField.d.mts +10 -0
  120. package/dist/inputs/RelationshipField.mjs +161 -0
  121. package/dist/inputs/SelectField.cjs +79 -0
  122. package/dist/inputs/SelectField.d.cts +10 -0
  123. package/dist/inputs/SelectField.d.mts +10 -0
  124. package/dist/inputs/SelectField.mjs +78 -0
  125. package/dist/inputs/SlugField.cjs +71 -0
  126. package/dist/inputs/SlugField.d.cts +11 -0
  127. package/dist/inputs/SlugField.d.mts +11 -0
  128. package/dist/inputs/SlugField.mjs +69 -0
  129. package/dist/inputs/TextBox.cjs +41 -0
  130. package/dist/inputs/TextBox.d.cts +35 -0
  131. package/dist/inputs/TextBox.d.mts +35 -0
  132. package/dist/inputs/TextBox.mjs +39 -0
  133. package/dist/inputs/TextField.cjs +61 -0
  134. package/dist/inputs/TextField.d.cts +10 -0
  135. package/dist/inputs/TextField.d.mts +10 -0
  136. package/dist/inputs/TextField.mjs +60 -0
  137. package/dist/inputs/TitleField.cjs +76 -0
  138. package/dist/inputs/TitleField.mjs +75 -0
  139. package/dist/inputs/UrlField.cjs +20 -0
  140. package/dist/inputs/UrlField.d.cts +10 -0
  141. package/dist/inputs/UrlField.d.mts +10 -0
  142. package/dist/inputs/UrlField.mjs +19 -0
  143. package/dist/inputs/values.cjs +4 -0
  144. package/dist/inputs/values.d.cts +19 -0
  145. package/dist/inputs/values.d.mts +19 -0
  146. package/dist/inputs/values.mjs +4 -0
  147. package/dist/screens/AccountView.cjs +173 -0
  148. package/dist/screens/AccountView.d.cts +18 -0
  149. package/dist/screens/AccountView.d.mts +18 -0
  150. package/dist/screens/AccountView.mjs +172 -0
  151. package/dist/screens/AdminShell.cjs +136 -0
  152. package/dist/screens/AdminShell.d.cts +31 -0
  153. package/dist/screens/AdminShell.d.mts +31 -0
  154. package/dist/screens/AdminShell.mjs +135 -0
  155. package/dist/screens/AuthViews.cjs +260 -0
  156. package/dist/screens/AuthViews.d.cts +48 -0
  157. package/dist/screens/AuthViews.d.mts +48 -0
  158. package/dist/screens/AuthViews.mjs +255 -0
  159. package/dist/screens/CreateView.cjs +37 -0
  160. package/dist/screens/CreateView.d.cts +12 -0
  161. package/dist/screens/CreateView.d.mts +12 -0
  162. package/dist/screens/CreateView.mjs +36 -0
  163. package/dist/screens/DashboardView.cjs +39 -0
  164. package/dist/screens/DashboardView.d.cts +12 -0
  165. package/dist/screens/DashboardView.d.mts +12 -0
  166. package/dist/screens/DashboardView.mjs +38 -0
  167. package/dist/screens/DocumentForm.cjs +214 -0
  168. package/dist/screens/DocumentForm.d.cts +77 -0
  169. package/dist/screens/DocumentForm.d.mts +77 -0
  170. package/dist/screens/DocumentForm.mjs +213 -0
  171. package/dist/screens/DocumentView.cjs +53 -0
  172. package/dist/screens/DocumentView.d.cts +17 -0
  173. package/dist/screens/DocumentView.d.mts +17 -0
  174. package/dist/screens/DocumentView.mjs +52 -0
  175. package/dist/screens/FileView.cjs +74 -0
  176. package/dist/screens/FileView.d.cts +17 -0
  177. package/dist/screens/FileView.d.mts +17 -0
  178. package/dist/screens/FileView.mjs +73 -0
  179. package/dist/screens/FilesView.cjs +212 -0
  180. package/dist/screens/FilesView.d.cts +34 -0
  181. package/dist/screens/FilesView.d.mts +34 -0
  182. package/dist/screens/FilesView.mjs +211 -0
  183. package/dist/screens/GlobalView.cjs +28 -0
  184. package/dist/screens/GlobalView.d.cts +16 -0
  185. package/dist/screens/GlobalView.d.mts +16 -0
  186. package/dist/screens/GlobalView.mjs +27 -0
  187. package/dist/screens/ListParts.cjs +138 -0
  188. package/dist/screens/ListParts.mjs +135 -0
  189. package/dist/screens/ListView.cjs +155 -0
  190. package/dist/screens/ListView.d.cts +28 -0
  191. package/dist/screens/ListView.d.mts +28 -0
  192. package/dist/screens/ListView.mjs +154 -0
  193. package/dist/screens/LogoutView.cjs +45 -0
  194. package/dist/screens/LogoutView.d.cts +10 -0
  195. package/dist/screens/LogoutView.d.mts +10 -0
  196. package/dist/screens/LogoutView.mjs +44 -0
  197. package/dist/screens/MessageView.cjs +13 -0
  198. package/dist/screens/MessageView.d.cts +12 -0
  199. package/dist/screens/MessageView.d.mts +12 -0
  200. package/dist/screens/MessageView.mjs +12 -0
  201. package/dist/screens/ScreenHeader.cjs +101 -0
  202. package/dist/screens/ScreenHeader.d.cts +33 -0
  203. package/dist/screens/ScreenHeader.d.mts +33 -0
  204. package/dist/screens/ScreenHeader.mjs +98 -0
  205. package/dist/shared.cjs +55 -0
  206. package/dist/shared.d.cts +9 -0
  207. package/dist/shared.d.mts +9 -0
  208. package/dist/shared.mjs +9 -0
  209. package/dist/state/AdminProvider.cjs +188 -0
  210. package/dist/state/AdminProvider.d.cts +106 -0
  211. package/dist/state/AdminProvider.d.mts +106 -0
  212. package/dist/state/AdminProvider.mjs +186 -0
  213. package/dist/state/admin-path.cjs +132 -0
  214. package/dist/state/admin-path.d.cts +101 -0
  215. package/dist/state/admin-path.d.mts +101 -0
  216. package/dist/state/admin-path.mjs +131 -0
  217. package/dist/state/admin-sections.cjs +49 -0
  218. package/dist/state/admin-sections.d.cts +39 -0
  219. package/dist/state/admin-sections.d.mts +39 -0
  220. package/dist/state/admin-sections.mjs +48 -0
  221. package/dist/state/choice-search.cjs +95 -0
  222. package/dist/state/choice-search.mjs +94 -0
  223. package/dist/state/definition.cjs +53 -0
  224. package/dist/state/definition.d.cts +123 -0
  225. package/dist/state/definition.d.mts +123 -0
  226. package/dist/state/definition.mjs +48 -0
  227. package/dist/state/form-data.cjs +266 -0
  228. package/dist/state/form-data.d.cts +123 -0
  229. package/dist/state/form-data.d.mts +123 -0
  230. package/dist/state/form-data.mjs +245 -0
  231. package/dist/state/form-field.cjs +60 -0
  232. package/dist/state/form-field.d.cts +135 -0
  233. package/dist/state/form-field.d.mts +135 -0
  234. package/dist/state/form-field.mjs +56 -0
  235. package/dist/state/form-state.cjs +11 -0
  236. package/dist/state/form-state.d.cts +61 -0
  237. package/dist/state/form-state.d.mts +61 -0
  238. package/dist/state/form-state.mjs +11 -0
  239. package/dist/state/kept-focus.cjs +42 -0
  240. package/dist/state/kept-focus.mjs +41 -0
  241. package/dist/state/list-query.cjs +116 -0
  242. package/dist/state/list-query.d.cts +57 -0
  243. package/dist/state/list-query.d.mts +57 -0
  244. package/dist/state/list-query.mjs +108 -0
  245. package/dist/state/picker.cjs +48 -0
  246. package/dist/state/picker.mjs +47 -0
  247. package/dist/state/sidebar.cjs +15 -0
  248. package/dist/state/sidebar.d.cts +7 -0
  249. package/dist/state/sidebar.d.mts +7 -0
  250. package/dist/state/sidebar.mjs +14 -0
  251. package/dist/state/unsaved-guard.cjs +56 -0
  252. package/dist/state/unsaved-guard.mjs +54 -0
  253. package/dist/state/uploads.cjs +104 -0
  254. package/dist/state/uploads.mjs +102 -0
  255. package/package.json +89 -3
@@ -0,0 +1,117 @@
1
+ "use client";
2
+ import { ICON } from "./icon.mjs";
3
+ import { useAdmin } from "../state/AdminProvider.mjs";
4
+ import { INITIAL_FORM_STATE } from "../state/form-state.mjs";
5
+ import { useActionState } from "react";
6
+ import { clsx } from "clsx";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { CheckIcon } from "lucide-react";
9
+ import { Form } from "@base-ui/react/form";
10
+ import { Menu } from "@base-ui/react/menu";
11
+ //#region src/controls/MenuButton.tsx
12
+ const EntryContent = (props) => {
13
+ const Icon = props.entry.icon;
14
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
15
+ Icon === void 0 || !props.iconed ? null : /* @__PURE__ */ jsx("span", {
16
+ className: "kz-menu__icon",
17
+ children: /* @__PURE__ */ jsx(Icon, {
18
+ ...ICON,
19
+ "aria-hidden": true
20
+ })
21
+ }),
22
+ /* @__PURE__ */ jsx("span", {
23
+ className: "kz-menu__label",
24
+ children: props.entry.label
25
+ }),
26
+ "current" in props.entry && props.entry.current === true ? /* @__PURE__ */ jsx(CheckIcon, {
27
+ className: "kz-menu__check",
28
+ ...ICON,
29
+ "aria-hidden": true
30
+ }) : null
31
+ ] });
32
+ };
33
+ /**
34
+ * Renders a button that opens a menu of links and actions.
35
+ */
36
+ const MenuButton = (props) => {
37
+ const { Link } = useAdmin();
38
+ const ordered = [...props.entries.filter((entry) => entry.danger !== true), ...props.entries.filter((entry) => entry.danger === true)];
39
+ const iconed = ordered.every((entry) => entry.icon !== void 0);
40
+ const entries = ordered.map((entry, index) => /* @__PURE__ */ jsx(MenuEntryItem, {
41
+ entry,
42
+ iconed,
43
+ separated: index > 0 && (entry.separated === true || entry.danger === true && ordered[index - 1]?.danger !== true),
44
+ Link
45
+ }, entry.label));
46
+ return /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
47
+ className: props.className,
48
+ ...props.label === void 0 ? {} : { "aria-label": props.label },
49
+ children: props.children
50
+ }), /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
51
+ className: "kz-layer",
52
+ side: props.side ?? "bottom",
53
+ align: props.align ?? "end",
54
+ sideOffset: 8,
55
+ children: /* @__PURE__ */ jsx(Menu.Popup, {
56
+ className: clsx("kz-popup kz-menu", props.menuClassName),
57
+ children: props.heading === void 0 ? entries : /* @__PURE__ */ jsxs(Menu.Group, { children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
58
+ className: "kz-menu__heading",
59
+ children: props.heading
60
+ }), entries] })
61
+ })
62
+ }) })] });
63
+ };
64
+ /**
65
+ * A menu item that posts its intent to the admin's action. It keeps the menu open until the action answers.
66
+ */
67
+ const IntentItem = (props) => {
68
+ const { action } = useAdmin();
69
+ const [, formAction, pending] = useActionState(action, INITIAL_FORM_STATE);
70
+ return /* @__PURE__ */ jsxs(Form, {
71
+ action: formAction,
72
+ className: "kz-menu__form",
73
+ children: [/* @__PURE__ */ jsx("input", {
74
+ type: "hidden",
75
+ name: "$intent",
76
+ value: props.entry.intent
77
+ }), /* @__PURE__ */ jsx(Menu.Item, {
78
+ className: props.className,
79
+ render: /* @__PURE__ */ jsx("button", { type: "submit" }),
80
+ nativeButton: true,
81
+ closeOnClick: false,
82
+ disabled: pending,
83
+ children: /* @__PURE__ */ jsx(EntryContent, {
84
+ entry: props.entry,
85
+ iconed: props.iconed
86
+ })
87
+ })]
88
+ });
89
+ };
90
+ const MenuEntryItem = (props) => {
91
+ const { entry, Link } = props;
92
+ const className = clsx("kz-menu__item", entry.danger === true && "kz-menu__item--danger");
93
+ const item = "intent" in entry ? /* @__PURE__ */ jsx(IntentItem, {
94
+ entry,
95
+ iconed: props.iconed,
96
+ className
97
+ }) : "href" in entry ? /* @__PURE__ */ jsx(Menu.LinkItem, {
98
+ className,
99
+ closeOnClick: true,
100
+ ...entry.plain === true ? { href: entry.href } : { render: /* @__PURE__ */ jsx(Link, { href: entry.href }) },
101
+ ...entry.current === true ? { "aria-current": "true" } : {},
102
+ children: /* @__PURE__ */ jsx(EntryContent, {
103
+ entry,
104
+ iconed: props.iconed
105
+ })
106
+ }) : /* @__PURE__ */ jsx(Menu.Item, {
107
+ className,
108
+ onClick: entry.onClick,
109
+ children: /* @__PURE__ */ jsx(EntryContent, {
110
+ entry,
111
+ iconed: props.iconed
112
+ })
113
+ });
114
+ return props.separated ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Menu.Separator, { className: "kz-menu__separator" }), item] }) : item;
115
+ };
116
+ //#endregion
117
+ export { MenuButton };
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_icon = require("./icon.cjs");
4
+ let clsx = require("clsx");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let lucide_react = require("lucide-react");
7
+ let _base_ui_react_select = require("@base-ui/react/select");
8
+ //#region src/controls/Select.tsx
9
+ const listOf = (value) => Array.isArray(value) ? value : value === void 0 || value === "" ? [] : [value];
10
+ /**
11
+ * Renders a select in the admin's style. It takes its name from the surrounding `Field.Root`.
12
+ */
13
+ const Select = (props) => {
14
+ const readOnly = props.readOnly === true;
15
+ const trigger = props.button === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Trigger, {
16
+ className: "kz-input kz-select",
17
+ ...props["aria-label"] === void 0 ? {} : { "aria-label": props["aria-label"] },
18
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Value, {
19
+ className: "kz-select__value",
20
+ ...props.placeholder === void 0 ? {} : { placeholder: props.placeholder }
21
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Icon, {
22
+ className: "kz-select__icon",
23
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
24
+ ...require_icon.CHEVRON_ICON,
25
+ "aria-hidden": true
26
+ })
27
+ })]
28
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Trigger, {
29
+ className: props.button.className,
30
+ "aria-label": props.button.label,
31
+ title: props.button.label,
32
+ children: props.button.children
33
+ });
34
+ const popup = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Positioner, {
35
+ className: "kz-layer",
36
+ side: "bottom",
37
+ align: "start",
38
+ sideOffset: 8,
39
+ alignItemWithTrigger: false,
40
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.Popup, {
41
+ className: (0, clsx.clsx)("kz-popup kz-menu", props.button === void 0 && "kz-menu--select"),
42
+ children: props.items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Item, {
43
+ value: item.value,
44
+ className: "kz-menu__item",
45
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.ItemText, {
46
+ className: "kz-menu__label",
47
+ children: item.label
48
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_select.Select.ItemIndicator, {
49
+ className: "kz-menu__check",
50
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
51
+ ...require_icon.ICON,
52
+ "aria-hidden": true
53
+ })
54
+ })]
55
+ }, item.value ?? ""))
56
+ })
57
+ }) });
58
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Root, {
59
+ items: props.items,
60
+ ...props.value === void 0 ? { defaultValue: listOf(props.defaultValue)[0] ?? null } : { value: props.value },
61
+ readOnly,
62
+ ...props.onValueChange === void 0 ? {} : { onValueChange: (value) => props.onValueChange(value) },
63
+ children: [trigger, popup]
64
+ });
65
+ };
66
+ //#endregion
67
+ exports.Select = Select;
@@ -0,0 +1,42 @@
1
+ import * as _$react from "react";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/controls/Select.d.ts
5
+ /**
6
+ * One choice of a `Select`. A `null` value is the choice of nothing.
7
+ */
8
+ interface SelectItem {
9
+ value: string | null;
10
+ label: string;
11
+ }
12
+ /**
13
+ * Renders a select in the admin's style. It takes its name from the surrounding `Field.Root`.
14
+ */
15
+ declare const Select: (props: {
16
+ items: readonly SelectItem[];
17
+ /**
18
+ * The value chosen when the select first shows. A list starts on its first value.
19
+ */
20
+ defaultValue?: string | string[] | undefined;
21
+ /**
22
+ * The value chosen, when `onValueChange` keeps it.
23
+ */
24
+ value?: string | null;
25
+ readOnly?: boolean;
26
+ /**
27
+ * The text shown while nothing is chosen.
28
+ */
29
+ placeholder?: string;
30
+ onValueChange?: (value: string | null) => void;
31
+ /**
32
+ * Shows the select as this button instead of a field.
33
+ */
34
+ button?: {
35
+ className: string;
36
+ label: string;
37
+ children: ReactNode;
38
+ };
39
+ "aria-label"?: string;
40
+ }) => _$react.JSX.Element;
41
+ //#endregion
42
+ export { Select, SelectItem };
@@ -0,0 +1,42 @@
1
+ import * as _$react from "react";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/controls/Select.d.ts
5
+ /**
6
+ * One choice of a `Select`. A `null` value is the choice of nothing.
7
+ */
8
+ interface SelectItem {
9
+ value: string | null;
10
+ label: string;
11
+ }
12
+ /**
13
+ * Renders a select in the admin's style. It takes its name from the surrounding `Field.Root`.
14
+ */
15
+ declare const Select: (props: {
16
+ items: readonly SelectItem[];
17
+ /**
18
+ * The value chosen when the select first shows. A list starts on its first value.
19
+ */
20
+ defaultValue?: string | string[] | undefined;
21
+ /**
22
+ * The value chosen, when `onValueChange` keeps it.
23
+ */
24
+ value?: string | null;
25
+ readOnly?: boolean;
26
+ /**
27
+ * The text shown while nothing is chosen.
28
+ */
29
+ placeholder?: string;
30
+ onValueChange?: (value: string | null) => void;
31
+ /**
32
+ * Shows the select as this button instead of a field.
33
+ */
34
+ button?: {
35
+ className: string;
36
+ label: string;
37
+ children: ReactNode;
38
+ };
39
+ "aria-label"?: string;
40
+ }) => _$react.JSX.Element;
41
+ //#endregion
42
+ export { Select, SelectItem };
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { CHEVRON_ICON, ICON } from "./icon.mjs";
3
+ import { clsx } from "clsx";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { CheckIcon, ChevronDownIcon } from "lucide-react";
6
+ import { Select } from "@base-ui/react/select";
7
+ //#region src/controls/Select.tsx
8
+ const listOf = (value) => Array.isArray(value) ? value : value === void 0 || value === "" ? [] : [value];
9
+ /**
10
+ * Renders a select in the admin's style. It takes its name from the surrounding `Field.Root`.
11
+ */
12
+ const Select$1 = (props) => {
13
+ const readOnly = props.readOnly === true;
14
+ const trigger = props.button === void 0 ? /* @__PURE__ */ jsxs(Select.Trigger, {
15
+ className: "kz-input kz-select",
16
+ ...props["aria-label"] === void 0 ? {} : { "aria-label": props["aria-label"] },
17
+ children: [/* @__PURE__ */ jsx(Select.Value, {
18
+ className: "kz-select__value",
19
+ ...props.placeholder === void 0 ? {} : { placeholder: props.placeholder }
20
+ }), /* @__PURE__ */ jsx(Select.Icon, {
21
+ className: "kz-select__icon",
22
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, {
23
+ ...CHEVRON_ICON,
24
+ "aria-hidden": true
25
+ })
26
+ })]
27
+ }) : /* @__PURE__ */ jsx(Select.Trigger, {
28
+ className: props.button.className,
29
+ "aria-label": props.button.label,
30
+ title: props.button.label,
31
+ children: props.button.children
32
+ });
33
+ const popup = /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Positioner, {
34
+ className: "kz-layer",
35
+ side: "bottom",
36
+ align: "start",
37
+ sideOffset: 8,
38
+ alignItemWithTrigger: false,
39
+ children: /* @__PURE__ */ jsx(Select.Popup, {
40
+ className: clsx("kz-popup kz-menu", props.button === void 0 && "kz-menu--select"),
41
+ children: props.items.map((item) => /* @__PURE__ */ jsxs(Select.Item, {
42
+ value: item.value,
43
+ className: "kz-menu__item",
44
+ children: [/* @__PURE__ */ jsx(Select.ItemText, {
45
+ className: "kz-menu__label",
46
+ children: item.label
47
+ }), /* @__PURE__ */ jsx(Select.ItemIndicator, {
48
+ className: "kz-menu__check",
49
+ children: /* @__PURE__ */ jsx(CheckIcon, {
50
+ ...ICON,
51
+ "aria-hidden": true
52
+ })
53
+ })]
54
+ }, item.value ?? ""))
55
+ })
56
+ }) });
57
+ return /* @__PURE__ */ jsxs(Select.Root, {
58
+ items: props.items,
59
+ ...props.value === void 0 ? { defaultValue: listOf(props.defaultValue)[0] ?? null } : { value: props.value },
60
+ readOnly,
61
+ ...props.onValueChange === void 0 ? {} : { onValueChange: (value) => props.onValueChange(value) },
62
+ children: [trigger, popup]
63
+ });
64
+ };
65
+ //#endregion
66
+ export { Select$1 as Select };
@@ -0,0 +1,31 @@
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_icon = require("./icon.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let lucide_react = require("lucide-react");
5
+ //#region src/controls/Status.tsx
6
+ /**
7
+ * Shows a line of status text with an icon for its state. `'saving'` shows a spinner, `'saved'` a tick and `'failed'`
8
+ * an alert.
9
+ */
10
+ const Status = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
11
+ className: "kz-save",
12
+ role: "status",
13
+ children: [
14
+ props.state === "saving" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LoaderCircleIcon, {
15
+ className: "kz-spin",
16
+ ...require_icon.ICON,
17
+ "aria-hidden": true
18
+ }) : null,
19
+ props.state === "saved" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
20
+ ...require_icon.ICON,
21
+ "aria-hidden": true
22
+ }) : null,
23
+ props.state === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CircleAlertIcon, {
24
+ ...require_icon.ICON,
25
+ "aria-hidden": true
26
+ }) : null,
27
+ props.children
28
+ ]
29
+ });
30
+ //#endregion
31
+ exports.Status = Status;
@@ -0,0 +1,14 @@
1
+ import * as _$react from "react";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/controls/Status.d.ts
5
+ /**
6
+ * Shows a line of status text with an icon for its state. `'saving'` shows a spinner, `'saved'` a tick and `'failed'`
7
+ * an alert.
8
+ */
9
+ declare const Status: (props: {
10
+ state?: "saving" | "saved" | "failed";
11
+ children?: ReactNode;
12
+ }) => _$react.JSX.Element;
13
+ //#endregion
14
+ export { Status };
@@ -0,0 +1,14 @@
1
+ import * as _$react from "react";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region src/controls/Status.d.ts
5
+ /**
6
+ * Shows a line of status text with an icon for its state. `'saving'` shows a spinner, `'saved'` a tick and `'failed'`
7
+ * an alert.
8
+ */
9
+ declare const Status: (props: {
10
+ state?: "saving" | "saved" | "failed";
11
+ children?: ReactNode;
12
+ }) => _$react.JSX.Element;
13
+ //#endregion
14
+ export { Status };
@@ -0,0 +1,30 @@
1
+ import { ICON } from "./icon.mjs";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { CheckIcon, CircleAlertIcon, LoaderCircleIcon } from "lucide-react";
4
+ //#region src/controls/Status.tsx
5
+ /**
6
+ * Shows a line of status text with an icon for its state. `'saving'` shows a spinner, `'saved'` a tick and `'failed'`
7
+ * an alert.
8
+ */
9
+ const Status = (props) => /* @__PURE__ */ jsxs("span", {
10
+ className: "kz-save",
11
+ role: "status",
12
+ children: [
13
+ props.state === "saving" ? /* @__PURE__ */ jsx(LoaderCircleIcon, {
14
+ className: "kz-spin",
15
+ ...ICON,
16
+ "aria-hidden": true
17
+ }) : null,
18
+ props.state === "saved" ? /* @__PURE__ */ jsx(CheckIcon, {
19
+ ...ICON,
20
+ "aria-hidden": true
21
+ }) : null,
22
+ props.state === "failed" ? /* @__PURE__ */ jsx(CircleAlertIcon, {
23
+ ...ICON,
24
+ "aria-hidden": true
25
+ }) : null,
26
+ props.children
27
+ ]
28
+ });
29
+ //#endregion
30
+ export { Status };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_ButtonTip = require("./ButtonTip.cjs");
4
+ let _base_ui_react_button = require("@base-ui/react/button");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ //#region src/controls/TrailingButton.tsx
7
+ /**
8
+ * Renders an icon button at the end of an input. Put the input and the button in a `kz-affix`.
9
+ */
10
+ const TrailingButton = (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ButtonTip.ButtonTip, {
11
+ label: props.label,
12
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_button.Button, {
13
+ type: "button",
14
+ className: "kz-field-button kz-trailing",
15
+ "aria-label": props.label,
16
+ onClick: props.onClick,
17
+ ...props.onPointerMove === void 0 ? {} : { onPointerMove: props.onPointerMove },
18
+ children: props.children
19
+ })
20
+ });
21
+ //#endregion
22
+ exports.TrailingButton = TrailingButton;
@@ -0,0 +1,18 @@
1
+ import * as _$react from "react";
2
+ import { MouseEvent, PointerEvent, ReactNode } from "react";
3
+
4
+ //#region src/controls/TrailingButton.d.ts
5
+ /**
6
+ * Renders an icon button at the end of an input. Put the input and the button in a `kz-affix`.
7
+ */
8
+ declare const TrailingButton: (props: {
9
+ /**
10
+ * Names the button for screen readers and in its tooltip.
11
+ */
12
+ label: string;
13
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
14
+ onPointerMove?: (event: PointerEvent<HTMLButtonElement>) => void;
15
+ children: ReactNode;
16
+ }) => _$react.JSX.Element;
17
+ //#endregion
18
+ export { TrailingButton };
@@ -0,0 +1,18 @@
1
+ import * as _$react from "react";
2
+ import { MouseEvent, PointerEvent, ReactNode } from "react";
3
+
4
+ //#region src/controls/TrailingButton.d.ts
5
+ /**
6
+ * Renders an icon button at the end of an input. Put the input and the button in a `kz-affix`.
7
+ */
8
+ declare const TrailingButton: (props: {
9
+ /**
10
+ * Names the button for screen readers and in its tooltip.
11
+ */
12
+ label: string;
13
+ onClick: (event: MouseEvent<HTMLButtonElement>) => void;
14
+ onPointerMove?: (event: PointerEvent<HTMLButtonElement>) => void;
15
+ children: ReactNode;
16
+ }) => _$react.JSX.Element;
17
+ //#endregion
18
+ export { TrailingButton };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { ButtonTip } from "./ButtonTip.mjs";
3
+ import { Button } from "@base-ui/react/button";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/controls/TrailingButton.tsx
6
+ /**
7
+ * Renders an icon button at the end of an input. Put the input and the button in a `kz-affix`.
8
+ */
9
+ const TrailingButton = (props) => /* @__PURE__ */ jsx(ButtonTip, {
10
+ label: props.label,
11
+ children: /* @__PURE__ */ jsx(Button, {
12
+ type: "button",
13
+ className: "kz-field-button kz-trailing",
14
+ "aria-label": props.label,
15
+ onClick: props.onClick,
16
+ ...props.onPointerMove === void 0 ? {} : { onPointerMove: props.onPointerMove },
17
+ children: props.children
18
+ })
19
+ });
20
+ //#endregion
21
+ export { TrailingButton };
@@ -0,0 +1,42 @@
1
+ //#region src/controls/icon.ts
2
+ /**
3
+ * The line every icon draws, in pixels on screen.
4
+ */
5
+ const LINE = 4 / 3;
6
+ /**
7
+ * The heavier line a cross draws, since its thin diagonals look lighter than the straight lines beside it.
8
+ */
9
+ const CROSS_LINE = 1.7;
10
+ /**
11
+ * Icon props at `size` that draw a `line` pixels wide, whatever the size.
12
+ */
13
+ const iconAt = (size, line = LINE) => ({
14
+ size,
15
+ strokeWidth: line * 24 / size
16
+ });
17
+ /**
18
+ * The size of every icon in a button, a field or a menu.
19
+ */
20
+ const ICON = iconAt(16);
21
+ /**
22
+ * The size of every chevron in a field, drawn so it matches the 16px icons beside it.
23
+ */
24
+ const CHEVRON_ICON = iconAt(18);
25
+ /**
26
+ * The size of the tick inside a checkbox.
27
+ */
28
+ const CHECK_ICON = iconAt(12);
29
+ /**
30
+ * The size of a cross in a button, drawn so it matches the 16px icons beside it.
31
+ */
32
+ const X_ICON = iconAt(20, CROSS_LINE);
33
+ /**
34
+ * The size of the cross that removes a chip.
35
+ */
36
+ const CHIP_X_ICON = iconAt(14, CROSS_LINE);
37
+ //#endregion
38
+ exports.CHECK_ICON = CHECK_ICON;
39
+ exports.CHEVRON_ICON = CHEVRON_ICON;
40
+ exports.CHIP_X_ICON = CHIP_X_ICON;
41
+ exports.ICON = ICON;
42
+ exports.X_ICON = X_ICON;
@@ -0,0 +1,38 @@
1
+ //#region src/controls/icon.ts
2
+ /**
3
+ * The line every icon draws, in pixels on screen.
4
+ */
5
+ const LINE = 4 / 3;
6
+ /**
7
+ * The heavier line a cross draws, since its thin diagonals look lighter than the straight lines beside it.
8
+ */
9
+ const CROSS_LINE = 1.7;
10
+ /**
11
+ * Icon props at `size` that draw a `line` pixels wide, whatever the size.
12
+ */
13
+ const iconAt = (size, line = LINE) => ({
14
+ size,
15
+ strokeWidth: line * 24 / size
16
+ });
17
+ /**
18
+ * The size of every icon in a button, a field or a menu.
19
+ */
20
+ const ICON = iconAt(16);
21
+ /**
22
+ * The size of every chevron in a field, drawn so it matches the 16px icons beside it.
23
+ */
24
+ const CHEVRON_ICON = iconAt(18);
25
+ /**
26
+ * The size of the tick inside a checkbox.
27
+ */
28
+ const CHECK_ICON = iconAt(12);
29
+ /**
30
+ * The size of a cross in a button, drawn so it matches the 16px icons beside it.
31
+ */
32
+ const X_ICON = iconAt(20, CROSS_LINE);
33
+ /**
34
+ * The size of the cross that removes a chip.
35
+ */
36
+ const CHIP_X_ICON = iconAt(14, CROSS_LINE);
37
+ //#endregion
38
+ export { CHECK_ICON, CHEVRON_ICON, CHIP_X_ICON, ICON, X_ICON };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ //#region src/inputs/Affixed.tsx
5
+ const hasAffixes = (field) => field.prefix !== void 0 || field.suffix !== void 0;
6
+ /**
7
+ * Returns the input's class, which leaves the frame to `Affixed` when the field has a prefix or a suffix.
8
+ */
9
+ const inputClassOf = (field) => hasAffixes(field) ? "kz-affixed__input" : "kz-input";
10
+ /**
11
+ * Focuses the input on a press on the prefix or the suffix, as a press anywhere else in the frame does.
12
+ */
13
+ const focusInput = (event) => {
14
+ if (event.target instanceof HTMLInputElement) return;
15
+ const input = event.currentTarget.querySelector("input");
16
+ if (input === null) return;
17
+ event.preventDefault();
18
+ input.focus();
19
+ };
20
+ /**
21
+ * Renders the field's frame with its prefix and suffix around the input. Give the input `inputClassOf(field)`.
22
+ *
23
+ * @example
24
+ * <Affixed field={field}>
25
+ * <Input className={inputClassOf(field)} defaultValue={value} />
26
+ * </Affixed>
27
+ */
28
+ const Affixed = (props) => {
29
+ const { field } = props;
30
+ if (!hasAffixes(field)) return props.children;
31
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
32
+ className: "kz-input kz-affixed",
33
+ onPointerDown: focusInput,
34
+ children: [
35
+ field.prefix === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
36
+ className: "kz-affixed__text",
37
+ children: field.prefix
38
+ }),
39
+ props.children,
40
+ field.suffix === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
41
+ className: "kz-affixed__text",
42
+ children: field.suffix
43
+ })
44
+ ]
45
+ });
46
+ };
47
+ //#endregion
48
+ exports.Affixed = Affixed;
49
+ exports.inputClassOf = inputClassOf;