@kizunacms/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/LICENSE.MD +9 -0
  2. package/README.md +20 -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,76 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_Checkbox = require("../controls/Checkbox.cjs");
4
+ const require_FieldFrame = require("./FieldFrame.cjs");
5
+ const require_values = require("./values.cjs");
6
+ const require_Counter = require("../controls/Counter.cjs");
7
+ const require_FallbackReset = require("./FallbackReset.cjs");
8
+ let react = require("react");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ let _base_ui_react_input = require("@base-ui/react/input");
11
+ //#region src/inputs/TitleField.tsx
12
+ /**
13
+ * Renders a search title with the ending the CMS adds to it, and the checkbox that leaves the ending out.
14
+ */
15
+ const TitleField = (props) => {
16
+ const { field } = props;
17
+ const ending = field.ending;
18
+ const [value, setValue] = (0, react.useState)(require_values.textOf(props.value));
19
+ const [leftOut, setLeftOut] = (0, react.useState)(require_values.textOf(props.formValues?.[ending.leaveOutWith]) === "on");
20
+ const shown = value === "" ? field.placeholder ?? "" : value;
21
+ const whole = shown === "" || leftOut ? shown : `${shown} ${ending.text}`;
22
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
23
+ className: "kz-stack kz-stack--attached",
24
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldFrame.FieldFrame, {
25
+ field,
26
+ ...field.showsInFull === void 0 ? {} : { aside: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Counter.Counter, {
27
+ count: whole.length,
28
+ limit: field.showsInFull
29
+ }) },
30
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
31
+ className: "kz-titled kz-affix",
32
+ children: [
33
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_input.Input, {
34
+ className: "kz-input",
35
+ value,
36
+ onValueChange: setValue,
37
+ placeholder: field.placeholder,
38
+ readOnly: field.readOnly
39
+ }),
40
+ shown === "" || leftOut ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
41
+ className: "kz-ending",
42
+ "aria-hidden": true,
43
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
44
+ className: "kz-ending-under",
45
+ children: shown
46
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
47
+ className: "kz-ending__text",
48
+ children: ` ${ending.text}`
49
+ })]
50
+ }),
51
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FallbackReset.FallbackReset, {
52
+ field,
53
+ value,
54
+ onReset: () => setValue("")
55
+ })
56
+ ]
57
+ })
58
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldFrame.FieldFrame, {
59
+ field: {
60
+ name: ending.leaveOutWith,
61
+ label: "Absolute title",
62
+ input: "checkbox",
63
+ required: false,
64
+ readOnly: field.readOnly
65
+ },
66
+ inline: true,
67
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Checkbox.Checkbox, {
68
+ checked: leftOut,
69
+ onCheckedChange: setLeftOut,
70
+ readOnly: field.readOnly
71
+ })
72
+ })]
73
+ });
74
+ };
75
+ //#endregion
76
+ exports.TitleField = TitleField;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { Checkbox } from "../controls/Checkbox.mjs";
3
+ import { FieldFrame } from "./FieldFrame.mjs";
4
+ import { textOf } from "./values.mjs";
5
+ import { Counter } from "../controls/Counter.mjs";
6
+ import { FallbackReset } from "./FallbackReset.mjs";
7
+ import { useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { Input } from "@base-ui/react/input";
10
+ //#region src/inputs/TitleField.tsx
11
+ /**
12
+ * Renders a search title with the ending the CMS adds to it, and the checkbox that leaves the ending out.
13
+ */
14
+ const TitleField = (props) => {
15
+ const { field } = props;
16
+ const ending = field.ending;
17
+ const [value, setValue] = useState(textOf(props.value));
18
+ const [leftOut, setLeftOut] = useState(textOf(props.formValues?.[ending.leaveOutWith]) === "on");
19
+ const shown = value === "" ? field.placeholder ?? "" : value;
20
+ const whole = shown === "" || leftOut ? shown : `${shown} ${ending.text}`;
21
+ return /* @__PURE__ */ jsxs("div", {
22
+ className: "kz-stack kz-stack--attached",
23
+ children: [/* @__PURE__ */ jsx(FieldFrame, {
24
+ field,
25
+ ...field.showsInFull === void 0 ? {} : { aside: /* @__PURE__ */ jsx(Counter, {
26
+ count: whole.length,
27
+ limit: field.showsInFull
28
+ }) },
29
+ children: /* @__PURE__ */ jsxs("div", {
30
+ className: "kz-titled kz-affix",
31
+ children: [
32
+ /* @__PURE__ */ jsx(Input, {
33
+ className: "kz-input",
34
+ value,
35
+ onValueChange: setValue,
36
+ placeholder: field.placeholder,
37
+ readOnly: field.readOnly
38
+ }),
39
+ shown === "" || leftOut ? null : /* @__PURE__ */ jsxs("div", {
40
+ className: "kz-ending",
41
+ "aria-hidden": true,
42
+ children: [/* @__PURE__ */ jsx("span", {
43
+ className: "kz-ending-under",
44
+ children: shown
45
+ }), /* @__PURE__ */ jsx("span", {
46
+ className: "kz-ending__text",
47
+ children: ` ${ending.text}`
48
+ })]
49
+ }),
50
+ /* @__PURE__ */ jsx(FallbackReset, {
51
+ field,
52
+ value,
53
+ onReset: () => setValue("")
54
+ })
55
+ ]
56
+ })
57
+ }), /* @__PURE__ */ jsx(FieldFrame, {
58
+ field: {
59
+ name: ending.leaveOutWith,
60
+ label: "Absolute title",
61
+ input: "checkbox",
62
+ required: false,
63
+ readOnly: field.readOnly
64
+ },
65
+ inline: true,
66
+ children: /* @__PURE__ */ jsx(Checkbox, {
67
+ checked: leftOut,
68
+ onCheckedChange: setLeftOut,
69
+ readOnly: field.readOnly
70
+ })
71
+ })]
72
+ });
73
+ };
74
+ //#endregion
75
+ export { TitleField };
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_FieldFrame = require("./FieldFrame.cjs");
4
+ const require_TextBox = require("./TextBox.cjs");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ //#region src/inputs/UrlField.tsx
7
+ /**
8
+ * Renders a `url` field.
9
+ */
10
+ const UrlField = (props) => {
11
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldFrame.FieldFrame, {
12
+ field: props.field,
13
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_TextBox.TextBox, {
14
+ ...props,
15
+ inputMode: "url"
16
+ })
17
+ });
18
+ };
19
+ //#endregion
20
+ exports.UrlField = UrlField;
@@ -0,0 +1,10 @@
1
+ import { FieldProps } from "./values.cjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/inputs/UrlField.d.ts
5
+ /**
6
+ * Renders a `url` field.
7
+ */
8
+ declare const UrlField: (props: FieldProps) => _$react.JSX.Element;
9
+ //#endregion
10
+ export { UrlField };
@@ -0,0 +1,10 @@
1
+ import { FieldProps } from "./values.mjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/inputs/UrlField.d.ts
5
+ /**
6
+ * Renders a `url` field.
7
+ */
8
+ declare const UrlField: (props: FieldProps) => _$react.JSX.Element;
9
+ //#endregion
10
+ export { UrlField };
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { FieldFrame } from "./FieldFrame.mjs";
3
+ import { TextBox } from "./TextBox.mjs";
4
+ import { jsx } from "react/jsx-runtime";
5
+ //#region src/inputs/UrlField.tsx
6
+ /**
7
+ * Renders a `url` field.
8
+ */
9
+ const UrlField = (props) => {
10
+ return /* @__PURE__ */ jsx(FieldFrame, {
11
+ field: props.field,
12
+ children: /* @__PURE__ */ jsx(TextBox, {
13
+ ...props,
14
+ inputMode: "url"
15
+ })
16
+ });
17
+ };
18
+ //#endregion
19
+ export { UrlField };
@@ -0,0 +1,4 @@
1
+ //#region src/inputs/values.ts
2
+ const textOf = (value) => Array.isArray(value) ? value.join(", ") : value ?? "";
3
+ //#endregion
4
+ exports.textOf = textOf;
@@ -0,0 +1,19 @@
1
+ import { FormField } from "../state/form-field.cjs";
2
+
3
+ //#region src/inputs/values.d.ts
4
+ /**
5
+ * The props every field component takes.
6
+ */
7
+ interface FieldProps {
8
+ field: FormField;
9
+ /**
10
+ * The field's value as the form holds it.
11
+ */
12
+ value: string | string[] | undefined;
13
+ /**
14
+ * Every value in the form, by field name.
15
+ */
16
+ formValues?: Record<string, string | string[]>;
17
+ }
18
+ //#endregion
19
+ export { FieldProps };
@@ -0,0 +1,19 @@
1
+ import { FormField } from "../state/form-field.mjs";
2
+
3
+ //#region src/inputs/values.d.ts
4
+ /**
5
+ * The props every field component takes.
6
+ */
7
+ interface FieldProps {
8
+ field: FormField;
9
+ /**
10
+ * The field's value as the form holds it.
11
+ */
12
+ value: string | string[] | undefined;
13
+ /**
14
+ * Every value in the form, by field name.
15
+ */
16
+ formValues?: Record<string, string | string[]>;
17
+ }
18
+ //#endregion
19
+ export { FieldProps };
@@ -0,0 +1,4 @@
1
+ //#region src/inputs/values.ts
2
+ const textOf = (value) => Array.isArray(value) ? value.join(", ") : value ?? "";
3
+ //#endregion
4
+ export { textOf };
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_Button = require("../controls/Button.cjs");
4
+ const require_Status = require("../controls/Status.cjs");
5
+ const require_AdminProvider = require("../state/AdminProvider.cjs");
6
+ const require_Select = require("../controls/Select.cjs");
7
+ const require_form_state = require("../state/form-state.cjs");
8
+ const require_FieldFrame = require("../inputs/FieldFrame.cjs");
9
+ const require_form_data = require("../state/form-data.cjs");
10
+ const require_PasswordField = require("../inputs/PasswordField.cjs");
11
+ const require_FieldFor = require("../inputs/FieldFor.cjs");
12
+ const require_FieldList = require("../inputs/FieldList.cjs");
13
+ const require_kept_focus = require("../state/kept-focus.cjs");
14
+ const require_unsaved_guard = require("../state/unsaved-guard.cjs");
15
+ const require_ScreenHeader = require("./ScreenHeader.cjs");
16
+ let react = require("react");
17
+ let react_jsx_runtime = require("react/jsx-runtime");
18
+ let _base_ui_react_form = require("@base-ui/react/form");
19
+ //#region src/screens/AccountView.tsx
20
+ const SYSTEM_THEME = "system";
21
+ const EMAIL_FIELD = {
22
+ name: "email",
23
+ label: "Email",
24
+ input: "email",
25
+ required: false,
26
+ readOnly: true
27
+ };
28
+ const statusOf = (state, pending, changed) => pending ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Status.Status, {
29
+ state: "saving",
30
+ children: "Saving"
31
+ }) : state.message !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Status.Status, {
32
+ state: "failed",
33
+ children: state.message
34
+ }) : state.saved && !changed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Status.Status, {
35
+ state: "saved",
36
+ children: "Saved"
37
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Status.Status, {});
38
+ /**
39
+ * Shows the editor's own account, where they change their own fields, the theme and their password.
40
+ */
41
+ const AccountView = (props) => {
42
+ const { action, theme } = require_AdminProvider.useAdmin();
43
+ const [state, formAction, pending] = (0, react.useActionState)(action, require_form_state.INITIAL_FORM_STATE);
44
+ const [passwordState, passwordAction, passwordPending] = (0, react.useActionState)(action, require_form_state.INITIAL_FORM_STATE);
45
+ const [, themeAction] = (0, react.useActionState)(action, require_form_state.INITIAL_FORM_STATE);
46
+ const formId = (0, react.useId)();
47
+ const accountForm = (0, react.useRef)(null);
48
+ const passwordForm = (0, react.useRef)(null);
49
+ const accountSaves = require_unsaved_guard.useSavedCount(state);
50
+ const passwordSaves = require_unsaved_guard.useSavedCount(passwordState);
51
+ const accountChanged = require_unsaved_guard.useUnsavedGuard(accountForm, String(accountSaves));
52
+ const passwordChanged = require_unsaved_guard.useUnsavedGuard(passwordForm, String(passwordSaves));
53
+ require_kept_focus.useKeptFocus(accountForm, String(accountSaves));
54
+ require_kept_focus.useKeptFocus(passwordForm, String(passwordState.submissions));
55
+ const [chosenTheme, setChosenTheme] = (0, react.useState)(theme ?? SYSTEM_THEME);
56
+ const { editor } = props;
57
+ const values = state.values ?? props.values;
58
+ const chooseTheme = (value) => {
59
+ setChosenTheme(value ?? SYSTEM_THEME);
60
+ const formData = new FormData();
61
+ formData.set("$intent", require_form_data.THEME_INTENT);
62
+ formData.set("theme", value ?? SYSTEM_THEME);
63
+ (0, react.startTransition)(() => themeAction(formData));
64
+ };
65
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_ScreenHeader.ScreenHeader, {
66
+ title: "Account",
67
+ children: [statusOf(state, pending, accountChanged), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
68
+ type: "submit",
69
+ form: formId,
70
+ disabled: pending,
71
+ focusableWhenDisabled: true,
72
+ children: "Save"
73
+ })]
74
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
75
+ className: "kz-form__columns",
76
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
77
+ className: "kz-form__main",
78
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
79
+ className: "kz-section",
80
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_form.Form, {
81
+ ref: accountForm,
82
+ id: formId,
83
+ action: formAction,
84
+ errors: state.errors,
85
+ className: "kz-stack",
86
+ children: [
87
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
88
+ type: "hidden",
89
+ name: "$intent",
90
+ value: require_form_data.UPDATE_ACCOUNT_INTENT
91
+ }),
92
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
93
+ className: "kz-stack",
94
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldList.FieldList, {
95
+ fields: props.fields,
96
+ values
97
+ })
98
+ }, accountSaves),
99
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldFor.FieldFor, {
100
+ field: EMAIL_FIELD,
101
+ value: editor.email
102
+ })
103
+ ]
104
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldFrame.FieldFrame, {
105
+ field: {
106
+ name: "theme",
107
+ label: "Theme",
108
+ input: "select",
109
+ required: false,
110
+ readOnly: false
111
+ },
112
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Select.Select, {
113
+ items: [
114
+ {
115
+ value: SYSTEM_THEME,
116
+ label: "System"
117
+ },
118
+ {
119
+ value: "light",
120
+ label: "Light"
121
+ },
122
+ {
123
+ value: "dark",
124
+ label: "Dark"
125
+ }
126
+ ],
127
+ value: chosenTheme,
128
+ onValueChange: chooseTheme
129
+ })
130
+ })]
131
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_form.Form, {
132
+ ref: passwordForm,
133
+ action: passwordAction,
134
+ errors: passwordState.errors,
135
+ className: "kz-section",
136
+ children: [
137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
138
+ type: "hidden",
139
+ name: "$intent",
140
+ value: require_form_data.CHANGE_PASSWORD_INTENT
141
+ }),
142
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
143
+ className: "kz-stack",
144
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PasswordField.PasswordField, {
145
+ name: "currentPassword",
146
+ label: "Current password",
147
+ autoComplete: "current-password",
148
+ required: true
149
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PasswordField.PasswordField, {
150
+ name: "password",
151
+ label: "New password",
152
+ autoComplete: "new-password",
153
+ placeholder: "At least 12 characters",
154
+ required: true
155
+ })]
156
+ }, passwordState.submissions),
157
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
158
+ className: "kz-actions",
159
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Button.Button, {
160
+ type: "submit",
161
+ variant: "secondary",
162
+ disabled: passwordPending,
163
+ focusableWhenDisabled: true,
164
+ children: "Change password"
165
+ }), statusOf(passwordState, passwordPending, passwordChanged)]
166
+ })
167
+ ]
168
+ })]
169
+ })
170
+ })] });
171
+ };
172
+ //#endregion
173
+ exports.AccountView = AccountView;
@@ -0,0 +1,18 @@
1
+ import { FormField, FormValues } from "../state/form-field.cjs";
2
+ import { AdminEditor } from "../state/definition.cjs";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/screens/AccountView.d.ts
6
+ /**
7
+ * Shows the editor's own account, where they change their own fields, the theme and their password.
8
+ */
9
+ declare const AccountView: (props: {
10
+ editor: AdminEditor;
11
+ /**
12
+ * The editors collection's own fields.
13
+ */
14
+ fields: FormField[];
15
+ values: FormValues;
16
+ }) => _$react.JSX.Element;
17
+ //#endregion
18
+ export { AccountView };
@@ -0,0 +1,18 @@
1
+ import { FormField, FormValues } from "../state/form-field.mjs";
2
+ import { AdminEditor } from "../state/definition.mjs";
3
+ import * as _$react from "react";
4
+
5
+ //#region src/screens/AccountView.d.ts
6
+ /**
7
+ * Shows the editor's own account, where they change their own fields, the theme and their password.
8
+ */
9
+ declare const AccountView: (props: {
10
+ editor: AdminEditor;
11
+ /**
12
+ * The editors collection's own fields.
13
+ */
14
+ fields: FormField[];
15
+ values: FormValues;
16
+ }) => _$react.JSX.Element;
17
+ //#endregion
18
+ export { AccountView };
@@ -0,0 +1,172 @@
1
+ "use client";
2
+ import { Button } from "../controls/Button.mjs";
3
+ import { Status } from "../controls/Status.mjs";
4
+ import { useAdmin } from "../state/AdminProvider.mjs";
5
+ import { Select } from "../controls/Select.mjs";
6
+ import { INITIAL_FORM_STATE } from "../state/form-state.mjs";
7
+ import { FieldFrame } from "../inputs/FieldFrame.mjs";
8
+ import { CHANGE_PASSWORD_INTENT, THEME_INTENT, UPDATE_ACCOUNT_INTENT } from "../state/form-data.mjs";
9
+ import { PasswordField } from "../inputs/PasswordField.mjs";
10
+ import { FieldFor } from "../inputs/FieldFor.mjs";
11
+ import { FieldList } from "../inputs/FieldList.mjs";
12
+ import { useKeptFocus } from "../state/kept-focus.mjs";
13
+ import { useSavedCount, useUnsavedGuard } from "../state/unsaved-guard.mjs";
14
+ import { ScreenHeader } from "./ScreenHeader.mjs";
15
+ import { startTransition, useActionState, useId, useRef, useState } from "react";
16
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
+ import { Form } from "@base-ui/react/form";
18
+ //#region src/screens/AccountView.tsx
19
+ const SYSTEM_THEME = "system";
20
+ const EMAIL_FIELD = {
21
+ name: "email",
22
+ label: "Email",
23
+ input: "email",
24
+ required: false,
25
+ readOnly: true
26
+ };
27
+ const statusOf = (state, pending, changed) => pending ? /* @__PURE__ */ jsx(Status, {
28
+ state: "saving",
29
+ children: "Saving"
30
+ }) : state.message !== void 0 ? /* @__PURE__ */ jsx(Status, {
31
+ state: "failed",
32
+ children: state.message
33
+ }) : state.saved && !changed ? /* @__PURE__ */ jsx(Status, {
34
+ state: "saved",
35
+ children: "Saved"
36
+ }) : /* @__PURE__ */ jsx(Status, {});
37
+ /**
38
+ * Shows the editor's own account, where they change their own fields, the theme and their password.
39
+ */
40
+ const AccountView = (props) => {
41
+ const { action, theme } = useAdmin();
42
+ const [state, formAction, pending] = useActionState(action, INITIAL_FORM_STATE);
43
+ const [passwordState, passwordAction, passwordPending] = useActionState(action, INITIAL_FORM_STATE);
44
+ const [, themeAction] = useActionState(action, INITIAL_FORM_STATE);
45
+ const formId = useId();
46
+ const accountForm = useRef(null);
47
+ const passwordForm = useRef(null);
48
+ const accountSaves = useSavedCount(state);
49
+ const passwordSaves = useSavedCount(passwordState);
50
+ const accountChanged = useUnsavedGuard(accountForm, String(accountSaves));
51
+ const passwordChanged = useUnsavedGuard(passwordForm, String(passwordSaves));
52
+ useKeptFocus(accountForm, String(accountSaves));
53
+ useKeptFocus(passwordForm, String(passwordState.submissions));
54
+ const [chosenTheme, setChosenTheme] = useState(theme ?? SYSTEM_THEME);
55
+ const { editor } = props;
56
+ const values = state.values ?? props.values;
57
+ const chooseTheme = (value) => {
58
+ setChosenTheme(value ?? SYSTEM_THEME);
59
+ const formData = new FormData();
60
+ formData.set("$intent", THEME_INTENT);
61
+ formData.set("theme", value ?? SYSTEM_THEME);
62
+ startTransition(() => themeAction(formData));
63
+ };
64
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(ScreenHeader, {
65
+ title: "Account",
66
+ children: [statusOf(state, pending, accountChanged), /* @__PURE__ */ jsx(Button, {
67
+ type: "submit",
68
+ form: formId,
69
+ disabled: pending,
70
+ focusableWhenDisabled: true,
71
+ children: "Save"
72
+ })]
73
+ }), /* @__PURE__ */ jsx("div", {
74
+ className: "kz-form__columns",
75
+ children: /* @__PURE__ */ jsxs("div", {
76
+ className: "kz-form__main",
77
+ children: [/* @__PURE__ */ jsxs("div", {
78
+ className: "kz-section",
79
+ children: [/* @__PURE__ */ jsxs(Form, {
80
+ ref: accountForm,
81
+ id: formId,
82
+ action: formAction,
83
+ errors: state.errors,
84
+ className: "kz-stack",
85
+ children: [
86
+ /* @__PURE__ */ jsx("input", {
87
+ type: "hidden",
88
+ name: "$intent",
89
+ value: UPDATE_ACCOUNT_INTENT
90
+ }),
91
+ /* @__PURE__ */ jsx("div", {
92
+ className: "kz-stack",
93
+ children: /* @__PURE__ */ jsx(FieldList, {
94
+ fields: props.fields,
95
+ values
96
+ })
97
+ }, accountSaves),
98
+ /* @__PURE__ */ jsx(FieldFor, {
99
+ field: EMAIL_FIELD,
100
+ value: editor.email
101
+ })
102
+ ]
103
+ }), /* @__PURE__ */ jsx(FieldFrame, {
104
+ field: {
105
+ name: "theme",
106
+ label: "Theme",
107
+ input: "select",
108
+ required: false,
109
+ readOnly: false
110
+ },
111
+ children: /* @__PURE__ */ jsx(Select, {
112
+ items: [
113
+ {
114
+ value: SYSTEM_THEME,
115
+ label: "System"
116
+ },
117
+ {
118
+ value: "light",
119
+ label: "Light"
120
+ },
121
+ {
122
+ value: "dark",
123
+ label: "Dark"
124
+ }
125
+ ],
126
+ value: chosenTheme,
127
+ onValueChange: chooseTheme
128
+ })
129
+ })]
130
+ }), /* @__PURE__ */ jsxs(Form, {
131
+ ref: passwordForm,
132
+ action: passwordAction,
133
+ errors: passwordState.errors,
134
+ className: "kz-section",
135
+ children: [
136
+ /* @__PURE__ */ jsx("input", {
137
+ type: "hidden",
138
+ name: "$intent",
139
+ value: CHANGE_PASSWORD_INTENT
140
+ }),
141
+ /* @__PURE__ */ jsxs("div", {
142
+ className: "kz-stack",
143
+ children: [/* @__PURE__ */ jsx(PasswordField, {
144
+ name: "currentPassword",
145
+ label: "Current password",
146
+ autoComplete: "current-password",
147
+ required: true
148
+ }), /* @__PURE__ */ jsx(PasswordField, {
149
+ name: "password",
150
+ label: "New password",
151
+ autoComplete: "new-password",
152
+ placeholder: "At least 12 characters",
153
+ required: true
154
+ })]
155
+ }, passwordState.submissions),
156
+ /* @__PURE__ */ jsxs("div", {
157
+ className: "kz-actions",
158
+ children: [/* @__PURE__ */ jsx(Button, {
159
+ type: "submit",
160
+ variant: "secondary",
161
+ disabled: passwordPending,
162
+ focusableWhenDisabled: true,
163
+ children: "Change password"
164
+ }), statusOf(passwordState, passwordPending, passwordChanged)]
165
+ })
166
+ ]
167
+ })]
168
+ })
169
+ })] });
170
+ };
171
+ //#endregion
172
+ export { AccountView };