@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,77 @@
1
+ import { FormField, FormValues } from "../state/form-field.cjs";
2
+ import { Fact } from "./ScreenHeader.cjs";
3
+ import * as _$react from "react";
4
+ import { ReactNode } from "react";
5
+
6
+ //#region src/screens/DocumentForm.d.ts
7
+ /**
8
+ * The Delete action of a `DocumentForm`.
9
+ */
10
+ interface Deletion {
11
+ /**
12
+ * The values the delete form sends.
13
+ */
14
+ hidden: Record<string, string>;
15
+ /**
16
+ * The document's title, shown in the dialog that asks.
17
+ */
18
+ title: string;
19
+ /**
20
+ * The word the dialog uses for the document, as in "Delete this article?".
21
+ */
22
+ noun: string;
23
+ }
24
+ /**
25
+ * The props of `DocumentForm`.
26
+ */
27
+ interface DocumentFormProps {
28
+ title: string;
29
+ /**
30
+ * The field whose text the header shows as it is typed.
31
+ */
32
+ titleField?: string;
33
+ /**
34
+ * The facts under the title.
35
+ */
36
+ facts?: Fact[];
37
+ /**
38
+ * The values the form sends beside its fields, like its `$intent`.
39
+ */
40
+ hidden: Record<string, string>;
41
+ fields: FormField[];
42
+ values: FormValues;
43
+ submitLabel: string;
44
+ /**
45
+ * The version of what the form shows, like the document's `updatedAt`. A new revision redraws the inputs.
46
+ */
47
+ revision: string;
48
+ /**
49
+ * Adds a Delete action to the menu beside the save button.
50
+ */
51
+ deletion?: Deletion;
52
+ /**
53
+ * Adds an action that emails the account a link to set its password.
54
+ */
55
+ invite?: {
56
+ hidden: Record<string, string>;
57
+ };
58
+ /**
59
+ * `'document'` puts some fields in a side column and the search metadata under a tab of its own. `'single'` shows
60
+ * every field in one column.
61
+ */
62
+ layout: 'document' | 'single';
63
+ /**
64
+ * Content that fills the main column, which moves every field to the side column.
65
+ */
66
+ preview?: ReactNode;
67
+ /**
68
+ * The field that takes the focus when the form opens, like the title of a new document.
69
+ */
70
+ initialFocus?: string;
71
+ }
72
+ /**
73
+ * Shows the form that saves a document, a global or a file, with its header and actions.
74
+ */
75
+ declare const DocumentForm: (props: DocumentFormProps) => _$react.JSX.Element;
76
+ //#endregion
77
+ export { Deletion, DocumentForm, DocumentFormProps };
@@ -0,0 +1,77 @@
1
+ import { FormField, FormValues } from "../state/form-field.mjs";
2
+ import { Fact } from "./ScreenHeader.mjs";
3
+ import * as _$react from "react";
4
+ import { ReactNode } from "react";
5
+
6
+ //#region src/screens/DocumentForm.d.ts
7
+ /**
8
+ * The Delete action of a `DocumentForm`.
9
+ */
10
+ interface Deletion {
11
+ /**
12
+ * The values the delete form sends.
13
+ */
14
+ hidden: Record<string, string>;
15
+ /**
16
+ * The document's title, shown in the dialog that asks.
17
+ */
18
+ title: string;
19
+ /**
20
+ * The word the dialog uses for the document, as in "Delete this article?".
21
+ */
22
+ noun: string;
23
+ }
24
+ /**
25
+ * The props of `DocumentForm`.
26
+ */
27
+ interface DocumentFormProps {
28
+ title: string;
29
+ /**
30
+ * The field whose text the header shows as it is typed.
31
+ */
32
+ titleField?: string;
33
+ /**
34
+ * The facts under the title.
35
+ */
36
+ facts?: Fact[];
37
+ /**
38
+ * The values the form sends beside its fields, like its `$intent`.
39
+ */
40
+ hidden: Record<string, string>;
41
+ fields: FormField[];
42
+ values: FormValues;
43
+ submitLabel: string;
44
+ /**
45
+ * The version of what the form shows, like the document's `updatedAt`. A new revision redraws the inputs.
46
+ */
47
+ revision: string;
48
+ /**
49
+ * Adds a Delete action to the menu beside the save button.
50
+ */
51
+ deletion?: Deletion;
52
+ /**
53
+ * Adds an action that emails the account a link to set its password.
54
+ */
55
+ invite?: {
56
+ hidden: Record<string, string>;
57
+ };
58
+ /**
59
+ * `'document'` puts some fields in a side column and the search metadata under a tab of its own. `'single'` shows
60
+ * every field in one column.
61
+ */
62
+ layout: 'document' | 'single';
63
+ /**
64
+ * Content that fills the main column, which moves every field to the side column.
65
+ */
66
+ preview?: ReactNode;
67
+ /**
68
+ * The field that takes the focus when the form opens, like the title of a new document.
69
+ */
70
+ initialFocus?: string;
71
+ }
72
+ /**
73
+ * Shows the form that saves a document, a global or a file, with its header and actions.
74
+ */
75
+ declare const DocumentForm: (props: DocumentFormProps) => _$react.JSX.Element;
76
+ //#endregion
77
+ export { Deletion, DocumentForm, DocumentFormProps };
@@ -0,0 +1,213 @@
1
+ "use client";
2
+ import { Button } from "../controls/Button.mjs";
3
+ import { ICON } from "../controls/icon.mjs";
4
+ import { Status } from "../controls/Status.mjs";
5
+ import { ConfirmDialog } from "../controls/ConfirmDialog.mjs";
6
+ import { useAdmin } from "../state/AdminProvider.mjs";
7
+ import { INITIAL_FORM_STATE } from "../state/form-state.mjs";
8
+ import { MenuButton } from "../controls/MenuButton.mjs";
9
+ import { FieldList } from "../inputs/FieldList.mjs";
10
+ import { useKeptFocus } from "../state/kept-focus.mjs";
11
+ import { placedFieldsOf } from "../state/list-query.mjs";
12
+ import { useSavedCount, useUnsavedGuard } from "../state/unsaved-guard.mjs";
13
+ import { ScreenHeader } from "./ScreenHeader.mjs";
14
+ import { Fragment, startTransition, useActionState, useEffect, useId, useRef, useState } from "react";
15
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
+ import { EllipsisIcon, MailIcon, Trash2Icon } from "lucide-react";
17
+ import { Form } from "@base-ui/react/form";
18
+ import { Tabs } from "@base-ui/react/tabs";
19
+ //#region src/screens/DocumentForm.tsx
20
+ const DeleteStep = (props) => {
21
+ const { action } = useAdmin();
22
+ const [state, formAction, pending] = useActionState(action, INITIAL_FORM_STATE);
23
+ return /* @__PURE__ */ jsx(ConfirmDialog, {
24
+ open: props.open,
25
+ onOpenChange: props.onOpenChange,
26
+ title: `Delete this ${props.deletion.noun}?`,
27
+ text: props.deletion.title,
28
+ confirmLabel: "Delete",
29
+ cancelLabel: "Cancel",
30
+ formAction,
31
+ hidden: props.deletion.hidden,
32
+ pending,
33
+ ...state.message === void 0 ? {} : { message: state.message }
34
+ });
35
+ };
36
+ const statusOf = (state, pending, changed, words) => pending ? /* @__PURE__ */ jsx(Status, {
37
+ state: "saving",
38
+ children: words.pending
39
+ }) : state.message !== void 0 ? /* @__PURE__ */ jsx(Status, {
40
+ state: "failed",
41
+ children: state.message
42
+ }) : state.saved && !changed ? /* @__PURE__ */ jsx(Status, {
43
+ state: "saved",
44
+ children: words.done
45
+ }) : /* @__PURE__ */ jsx(Status, {});
46
+ const TabLabel = (props) => /* @__PURE__ */ jsxs(Fragment$1, { children: [props.label, props.errors === 0 ? null : /* @__PURE__ */ jsx("span", {
47
+ className: "kz-tab__count",
48
+ "aria-label": props.errors === 1 ? "1 error" : `${props.errors} errors`,
49
+ children: props.errors
50
+ })] });
51
+ /**
52
+ * Shows the form that saves a document, a global or a file, with its header and actions.
53
+ */
54
+ const DocumentForm = (props) => {
55
+ const { action } = useAdmin();
56
+ const [state, formAction, pending] = useActionState(action, INITIAL_FORM_STATE);
57
+ const [inviteState, inviteAction, invitePending] = useActionState(action, INITIAL_FORM_STATE);
58
+ const [lastAction, setLastAction] = useState("save");
59
+ const [deleting, setDeleting] = useState(false);
60
+ const [tab, setTab] = useState("edit");
61
+ const [typedTitle, setTypedTitle] = useState(void 0);
62
+ const formId = useId();
63
+ const formRef = useRef(null);
64
+ const saves = useSavedCount(state);
65
+ const changed = useUnsavedGuard(formRef, `${props.revision}:${saves}`);
66
+ useKeptFocus(formRef, props.revision);
67
+ useEffect(() => {
68
+ if (props.initialFocus === void 0) return;
69
+ const control = formRef.current?.elements.namedItem(props.initialFocus);
70
+ if (control instanceof HTMLElement) control.focus();
71
+ }, []);
72
+ const values = state.values ?? props.values;
73
+ const { main, aside, seo } = placedFieldsOf(props.fields);
74
+ const isSeo = (name) => seo.some((field) => field.name === name);
75
+ const failed = Object.keys(state.errors);
76
+ const [seenSubmissions, setSeenSubmissions] = useState(state.submissions);
77
+ if (seenSubmissions !== state.submissions) {
78
+ setSeenSubmissions(state.submissions);
79
+ if (failed.length > 0) setTab(failed.every(isSeo) ? "seo" : "edit");
80
+ }
81
+ const list = (fields) => /* @__PURE__ */ jsx(FieldList, {
82
+ fields,
83
+ values
84
+ });
85
+ const mainColumn = (fields) => /* @__PURE__ */ jsx("div", {
86
+ className: "kz-form__main",
87
+ children: /* @__PURE__ */ jsx("div", {
88
+ className: "kz-stack",
89
+ children: list(fields)
90
+ })
91
+ });
92
+ const work = props.preview === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [mainColumn(main), aside.length === 0 ? null : /* @__PURE__ */ jsx("aside", {
93
+ className: "kz-form__sidebar kz-stack",
94
+ "aria-label": "Details",
95
+ children: list(aside)
96
+ })] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
97
+ className: "kz-form__main",
98
+ children: props.preview
99
+ }), /* @__PURE__ */ jsx("aside", {
100
+ className: "kz-form__sidebar kz-stack",
101
+ "aria-label": "Details",
102
+ children: list(props.fields)
103
+ })] });
104
+ const form = (children) => /* @__PURE__ */ jsxs(Form, {
105
+ ref: formRef,
106
+ id: formId,
107
+ action: formAction,
108
+ errors: state.errors,
109
+ className: "kz-form",
110
+ onInput: (event) => {
111
+ const target = event.target;
112
+ if (props.titleField !== void 0 && target.name === props.titleField) setTypedTitle(target.value);
113
+ },
114
+ onSubmit: () => setLastAction("save"),
115
+ children: [Object.entries(props.hidden).map(([name, value]) => /* @__PURE__ */ jsx("input", {
116
+ type: "hidden",
117
+ name,
118
+ value
119
+ }, name)), /* @__PURE__ */ jsx(Fragment, { children }, props.revision)]
120
+ });
121
+ const invite = props.invite;
122
+ const menu = [...invite === void 0 ? [] : [{
123
+ label: "Send invite",
124
+ icon: MailIcon,
125
+ onClick: () => {
126
+ const formData = new FormData();
127
+ for (const [name, value] of Object.entries(invite.hidden)) formData.set(name, value);
128
+ setLastAction("invite");
129
+ startTransition(() => inviteAction(formData));
130
+ }
131
+ }], ...props.deletion === void 0 ? [] : [{
132
+ label: "Delete",
133
+ icon: Trash2Icon,
134
+ danger: true,
135
+ onClick: () => setDeleting(true)
136
+ }]];
137
+ const tabbed = props.layout === "document" && seo.length > 0;
138
+ const header = /* @__PURE__ */ jsxs(ScreenHeader, {
139
+ title: typedTitle?.trim() || props.title,
140
+ ...props.facts === void 0 ? {} : { facts: props.facts },
141
+ ...tabbed ? { tabs: /* @__PURE__ */ jsxs(Tabs.List, {
142
+ className: "kz-tab-list",
143
+ "aria-label": "Sections",
144
+ children: [/* @__PURE__ */ jsx(Tabs.Tab, {
145
+ value: "edit",
146
+ className: "kz-tab",
147
+ children: /* @__PURE__ */ jsx(TabLabel, {
148
+ label: "Edit",
149
+ errors: failed.filter((name) => !isSeo(name)).length
150
+ })
151
+ }), /* @__PURE__ */ jsx(Tabs.Tab, {
152
+ value: "seo",
153
+ className: "kz-tab",
154
+ children: /* @__PURE__ */ jsx(TabLabel, {
155
+ label: "SEO",
156
+ errors: failed.filter(isSeo).length
157
+ })
158
+ })]
159
+ }) } : {},
160
+ children: [
161
+ lastAction === "invite" ? statusOf(inviteState, invitePending, false, {
162
+ pending: "Sending invite",
163
+ done: "Invite sent"
164
+ }) : statusOf(state, pending, changed, {
165
+ pending: "Saving",
166
+ done: "Saved"
167
+ }),
168
+ /* @__PURE__ */ jsx(Button, {
169
+ type: "submit",
170
+ form: formId,
171
+ disabled: pending,
172
+ focusableWhenDisabled: true,
173
+ children: props.submitLabel
174
+ }),
175
+ menu.length === 0 ? null : /* @__PURE__ */ jsx(MenuButton, {
176
+ className: "kz-icon-button kz-icon-button--secondary",
177
+ label: "More",
178
+ entries: menu,
179
+ children: /* @__PURE__ */ jsx(EllipsisIcon, {
180
+ ...ICON,
181
+ "aria-hidden": true
182
+ })
183
+ })
184
+ ]
185
+ });
186
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [tabbed ? /* @__PURE__ */ jsxs(Tabs.Root, {
187
+ value: tab,
188
+ onValueChange: (value) => setTab(String(value)),
189
+ className: "kz-form",
190
+ children: [header, form(/* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Tabs.Panel, {
191
+ value: "edit",
192
+ keepMounted: true,
193
+ tabIndex: -1,
194
+ className: "kz-form__columns",
195
+ children: work
196
+ }), /* @__PURE__ */ jsx(Tabs.Panel, {
197
+ value: "seo",
198
+ keepMounted: true,
199
+ tabIndex: -1,
200
+ className: "kz-form__columns",
201
+ children: mainColumn(seo)
202
+ })] }))]
203
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [header, form(/* @__PURE__ */ jsx("div", {
204
+ className: "kz-form__columns",
205
+ children: props.layout === "document" ? work : mainColumn(props.fields)
206
+ }))] }), props.deletion === void 0 ? null : /* @__PURE__ */ jsx(DeleteStep, {
207
+ deletion: props.deletion,
208
+ open: deleting,
209
+ onOpenChange: setDeleting
210
+ })] });
211
+ };
212
+ //#endregion
213
+ export { DocumentForm };
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_definition = require("../state/definition.cjs");
4
+ const require_form_data = require("../state/form-data.cjs");
5
+ const require_ScreenHeader = require("./ScreenHeader.cjs");
6
+ const require_DocumentForm = require("./DocumentForm.cjs");
7
+ const require_form_field = require("../state/form-field.cjs");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region src/screens/DocumentView.tsx
10
+ /**
11
+ * Shows the form that saves or deletes a document.
12
+ */
13
+ const DocumentView = (props) => {
14
+ const { collection, id, document } = props;
15
+ const title = require_definition.titleOf(collection, document);
16
+ const facts = require_ScreenHeader.updatedFactsOf(document);
17
+ const baseHidden = {
18
+ $collection: collection.name,
19
+ $id: id
20
+ };
21
+ const fields = collection.fields.map((field) => field.name === "password" && collection.login !== void 0 ? {
22
+ ...field,
23
+ label: "New password"
24
+ } : field);
25
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DocumentForm.DocumentForm, {
26
+ title,
27
+ ...collection.titleField === void 0 ? {} : { titleField: collection.titleField },
28
+ facts,
29
+ layout: "document",
30
+ hidden: {
31
+ ...baseHidden,
32
+ $intent: "update"
33
+ },
34
+ fields,
35
+ values: require_form_field.formValuesOf(fields, document),
36
+ submitLabel: "Save",
37
+ revision: String(document["updatedAt"] ?? ""),
38
+ deletion: {
39
+ hidden: {
40
+ ...baseHidden,
41
+ $intent: "delete"
42
+ },
43
+ title,
44
+ noun: require_definition.inSentence(collection.labels.singular)
45
+ },
46
+ ...collection.login?.invites === true ? { invite: { hidden: {
47
+ ...baseHidden,
48
+ $intent: require_form_data.INVITE_INTENT
49
+ } } } : {}
50
+ });
51
+ };
52
+ //#endregion
53
+ exports.DocumentView = DocumentView;
@@ -0,0 +1,17 @@
1
+ import { AdminCollection } from "../state/definition.cjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/screens/DocumentView.d.ts
5
+ /**
6
+ * Shows the form that saves or deletes a document.
7
+ */
8
+ declare const DocumentView: (props: {
9
+ collection: AdminCollection;
10
+ id: string;
11
+ /**
12
+ * The document as its route returns it.
13
+ */
14
+ document: Record<string, unknown>;
15
+ }) => _$react.JSX.Element;
16
+ //#endregion
17
+ export { DocumentView };
@@ -0,0 +1,17 @@
1
+ import { AdminCollection } from "../state/definition.mjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/screens/DocumentView.d.ts
5
+ /**
6
+ * Shows the form that saves or deletes a document.
7
+ */
8
+ declare const DocumentView: (props: {
9
+ collection: AdminCollection;
10
+ id: string;
11
+ /**
12
+ * The document as its route returns it.
13
+ */
14
+ document: Record<string, unknown>;
15
+ }) => _$react.JSX.Element;
16
+ //#endregion
17
+ export { DocumentView };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { inSentence, titleOf } from "../state/definition.mjs";
3
+ import { INVITE_INTENT } from "../state/form-data.mjs";
4
+ import { updatedFactsOf } from "./ScreenHeader.mjs";
5
+ import { DocumentForm } from "./DocumentForm.mjs";
6
+ import { formValuesOf } from "../state/form-field.mjs";
7
+ import { jsx } from "react/jsx-runtime";
8
+ //#region src/screens/DocumentView.tsx
9
+ /**
10
+ * Shows the form that saves or deletes a document.
11
+ */
12
+ const DocumentView = (props) => {
13
+ const { collection, id, document } = props;
14
+ const title = titleOf(collection, document);
15
+ const facts = updatedFactsOf(document);
16
+ const baseHidden = {
17
+ $collection: collection.name,
18
+ $id: id
19
+ };
20
+ const fields = collection.fields.map((field) => field.name === "password" && collection.login !== void 0 ? {
21
+ ...field,
22
+ label: "New password"
23
+ } : field);
24
+ return /* @__PURE__ */ jsx(DocumentForm, {
25
+ title,
26
+ ...collection.titleField === void 0 ? {} : { titleField: collection.titleField },
27
+ facts,
28
+ layout: "document",
29
+ hidden: {
30
+ ...baseHidden,
31
+ $intent: "update"
32
+ },
33
+ fields,
34
+ values: formValuesOf(fields, document),
35
+ submitLabel: "Save",
36
+ revision: String(document["updatedAt"] ?? ""),
37
+ deletion: {
38
+ hidden: {
39
+ ...baseHidden,
40
+ $intent: "delete"
41
+ },
42
+ title,
43
+ noun: inSentence(collection.labels.singular)
44
+ },
45
+ ...collection.login?.invites === true ? { invite: { hidden: {
46
+ ...baseHidden,
47
+ $intent: INVITE_INTENT
48
+ } } } : {}
49
+ });
50
+ };
51
+ //#endregion
52
+ export { DocumentView };
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_definition = require("../state/definition.cjs");
4
+ const require_ScreenHeader = require("./ScreenHeader.cjs");
5
+ const require_DocumentForm = require("./DocumentForm.cjs");
6
+ const require_form_field = require("../state/form-field.cjs");
7
+ const require_FocalPointPicker = require("../inputs/FocalPointPicker.cjs");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region src/screens/FileView.tsx
10
+ const focalPointOf = (value) => {
11
+ if (typeof value !== "object" || value === null) return void 0;
12
+ const { x, y } = value;
13
+ return typeof x === "number" && typeof y === "number" ? {
14
+ x,
15
+ y
16
+ } : void 0;
17
+ };
18
+ /**
19
+ * Shows a file with its own fields beside it. An image shows large, with its focal point to set on it.
20
+ */
21
+ const FileView = (props) => {
22
+ const { store, id, file } = props;
23
+ const filename = typeof file["filename"] === "string" ? file["filename"] : id;
24
+ const url = typeof file["url"] === "string" ? file["url"] : void 0;
25
+ const width = file["width"];
26
+ const height = file["height"];
27
+ const isImage = typeof width === "number" && typeof height === "number" && String(file["contentType"] ?? "").startsWith("image/");
28
+ const facts = [
29
+ ...isImage ? [{
30
+ label: "Size",
31
+ value: `${width} × ${height}`
32
+ }] : [],
33
+ ...typeof file["fileSize"] === "number" ? [{
34
+ label: "File",
35
+ value: require_form_field.fileSizeOf(file["fileSize"])
36
+ }] : [],
37
+ ...require_ScreenHeader.updatedFactsOf(file)
38
+ ];
39
+ const hidden = {
40
+ $store: store.name,
41
+ $id: id
42
+ };
43
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_DocumentForm.DocumentForm, {
44
+ title: filename,
45
+ facts,
46
+ layout: "document",
47
+ hidden: {
48
+ ...hidden,
49
+ $intent: "update"
50
+ },
51
+ fields: store.fields,
52
+ values: require_form_field.formValuesOf(store.fields, file),
53
+ submitLabel: "Save",
54
+ revision: String(file["updatedAt"] ?? ""),
55
+ deletion: {
56
+ hidden: {
57
+ ...hidden,
58
+ $intent: "delete"
59
+ },
60
+ title: filename,
61
+ noun: require_definition.inSentence(store.labels.singular)
62
+ },
63
+ preview: url === void 0 ? null : isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FocalPointPicker.FocalPointPicker, {
64
+ src: url,
65
+ value: focalPointOf(file["focalPoint"])
66
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
67
+ className: "kz-focal__file",
68
+ href: url,
69
+ children: filename
70
+ })
71
+ });
72
+ };
73
+ //#endregion
74
+ exports.FileView = FileView;
@@ -0,0 +1,17 @@
1
+ import { AdminStore } from "../state/definition.cjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/screens/FileView.d.ts
5
+ /**
6
+ * Shows a file with its own fields beside it. An image shows large, with its focal point to set on it.
7
+ */
8
+ declare const FileView: (props: {
9
+ store: AdminStore;
10
+ id: string;
11
+ /**
12
+ * The file as its store's route returns it.
13
+ */
14
+ file: Record<string, unknown>;
15
+ }) => _$react.JSX.Element;
16
+ //#endregion
17
+ export { FileView };
@@ -0,0 +1,17 @@
1
+ import { AdminStore } from "../state/definition.mjs";
2
+ import * as _$react from "react";
3
+
4
+ //#region src/screens/FileView.d.ts
5
+ /**
6
+ * Shows a file with its own fields beside it. An image shows large, with its focal point to set on it.
7
+ */
8
+ declare const FileView: (props: {
9
+ store: AdminStore;
10
+ id: string;
11
+ /**
12
+ * The file as its store's route returns it.
13
+ */
14
+ file: Record<string, unknown>;
15
+ }) => _$react.JSX.Element;
16
+ //#endregion
17
+ export { FileView };