@alulore/kumiko 0.19.1 → 0.20.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 (136) hide show
  1. package/dist/board/board-api.d.ts +2 -1
  2. package/dist/board/board-api.js +1 -1
  3. package/dist/board/board-motion.js +29 -1
  4. package/dist/board/board-slots.d.ts +14 -7
  5. package/dist/board/board-slots.js +5 -3
  6. package/dist/board/board.d.ts +20 -5
  7. package/dist/board/board.js +28 -5
  8. package/dist/board/keep-capture.d.ts +10 -5
  9. package/dist/board/keep-capture.js +48 -13
  10. package/dist/cooldown/cooldown-button.d.ts +30 -0
  11. package/dist/cooldown/cooldown-button.js +75 -0
  12. package/dist/cooldown/cooldown-labels.d.ts +8 -0
  13. package/dist/cooldown/cooldown-labels.js +4 -0
  14. package/dist/cooldown/cooldown-time.d.ts +8 -0
  15. package/dist/cooldown/cooldown-time.js +20 -0
  16. package/dist/cooldown/cooldown.css +21 -0
  17. package/dist/cooldown/index.d.ts +4 -0
  18. package/dist/cooldown/index.js +4 -0
  19. package/dist/cooldown/use-cooldown.d.ts +30 -0
  20. package/dist/cooldown/use-cooldown.js +63 -0
  21. package/dist/dialog/dialog-content.d.ts +5 -0
  22. package/dist/dialog/dialog-content.js +7 -0
  23. package/dist/empty-state/empty-state-labels.d.ts +14 -0
  24. package/dist/empty-state/empty-state-labels.js +10 -0
  25. package/dist/empty-state/empty-state.css +134 -0
  26. package/dist/empty-state/empty-state.d.ts +34 -0
  27. package/dist/empty-state/empty-state.js +61 -0
  28. package/dist/empty-state/index.d.ts +2 -0
  29. package/dist/empty-state/index.js +2 -0
  30. package/dist/form/choice-fields.d.ts +34 -0
  31. package/dist/form/choice-fields.js +41 -0
  32. package/dist/form/error-line.d.ts +8 -0
  33. package/dist/form/error-line.js +47 -0
  34. package/dist/form/field-props.d.ts +12 -0
  35. package/dist/form/field-props.js +8 -0
  36. package/dist/form/field-shell.d.ts +18 -0
  37. package/dist/form/field-shell.js +51 -0
  38. package/dist/form/focus-invalid.d.ts +5 -0
  39. package/dist/form/focus-invalid.js +17 -0
  40. package/dist/form/form-context.d.ts +2 -0
  41. package/dist/form/form-context.js +3 -0
  42. package/dist/form/form-parts.d.ts +20 -0
  43. package/dist/form/form-parts.js +73 -0
  44. package/dist/form/form.css +128 -0
  45. package/dist/form/index.d.ts +10 -0
  46. package/dist/form/index.js +9 -0
  47. package/dist/form/shown-error.d.ts +12 -0
  48. package/dist/form/shown-error.js +27 -0
  49. package/dist/form/submit-errors.d.ts +36 -0
  50. package/dist/form/submit-errors.js +46 -0
  51. package/dist/form/text-fields.d.ts +18 -0
  52. package/dist/form/text-fields.js +21 -0
  53. package/dist/form/use-app-form.d.ts +1655 -0
  54. package/dist/form/use-app-form.js +94 -0
  55. package/dist/form/use-dialog-link.d.ts +5 -0
  56. package/dist/form/use-dialog-link.js +30 -0
  57. package/dist/form/value-fields.d.ts +16 -0
  58. package/dist/form/value-fields.js +15 -0
  59. package/dist/map/geo.d.ts +20 -0
  60. package/dist/map/geo.js +41 -0
  61. package/dist/map/index.d.ts +5 -0
  62. package/dist/map/index.js +4 -0
  63. package/dist/map/label-overlap.d.ts +13 -0
  64. package/dist/map/label-overlap.js +23 -0
  65. package/dist/map/load-map.d.ts +12 -0
  66. package/dist/map/load-map.js +22 -0
  67. package/dist/map/location-map.d.ts +39 -0
  68. package/dist/map/location-map.js +171 -0
  69. package/dist/map/map-frame.d.ts +18 -0
  70. package/dist/map/map-frame.js +6 -0
  71. package/dist/map/map-pin.d.ts +4 -0
  72. package/dist/map/map-pin.js +38 -0
  73. package/dist/map/map-popup.d.ts +17 -0
  74. package/dist/map/map-popup.js +101 -0
  75. package/dist/map/map-source.d.ts +52 -0
  76. package/dist/map/map-source.js +59 -0
  77. package/dist/map/map.css +311 -0
  78. package/dist/map/marker-pins.d.ts +29 -0
  79. package/dist/map/marker-pins.js +144 -0
  80. package/dist/map/markers-map.d.ts +57 -0
  81. package/dist/map/markers-map.js +154 -0
  82. package/dist/map/use-label-overlap.d.ts +9 -0
  83. package/dist/map/use-label-overlap.js +55 -0
  84. package/dist/map/use-map.d.ts +49 -0
  85. package/dist/map/use-map.js +201 -0
  86. package/dist/media/encoding.d.ts +32 -0
  87. package/dist/media/encoding.js +59 -0
  88. package/dist/media/errors.d.ts +33 -0
  89. package/dist/media/errors.js +26 -0
  90. package/dist/media/image.d.ts +9 -0
  91. package/dist/media/image.js +35 -0
  92. package/dist/media/index.d.ts +10 -0
  93. package/dist/media/index.js +10 -0
  94. package/dist/media/load-mediabunny.d.ts +7 -0
  95. package/dist/media/load-mediabunny.js +13 -0
  96. package/dist/media/media-upload.d.ts +40 -0
  97. package/dist/media/media-upload.js +132 -0
  98. package/dist/media/media.css +101 -0
  99. package/dist/media/probe.d.ts +19 -0
  100. package/dist/media/probe.js +49 -0
  101. package/dist/media/sizes.d.ts +28 -0
  102. package/dist/media/sizes.js +51 -0
  103. package/dist/media/slideshow.d.ts +43 -0
  104. package/dist/media/slideshow.js +174 -0
  105. package/dist/media/timeline.d.ts +59 -0
  106. package/dist/media/timeline.js +105 -0
  107. package/dist/media/transcode.d.ts +35 -0
  108. package/dist/media/transcode.js +132 -0
  109. package/dist/media/upload.d.ts +21 -0
  110. package/dist/media/upload.js +54 -0
  111. package/dist/media/use-media-job.d.ts +79 -0
  112. package/dist/media/use-media-job.js +143 -0
  113. package/dist/server-render.test.js +93 -0
  114. package/dist/smooth-caret/caret-controller.js +16 -3
  115. package/dist/table/table-labels.d.ts +2 -0
  116. package/dist/table/table-labels.js +1 -0
  117. package/dist/table/table-sections.js +10 -2
  118. package/dist/table/table.css +1 -0
  119. package/dist/theme/define-theme.d.ts +38 -0
  120. package/dist/theme/define-theme.js +56 -0
  121. package/dist/theme/index.d.ts +3 -0
  122. package/dist/theme/index.js +3 -0
  123. package/dist/theme/theme-style.d.ts +6 -0
  124. package/dist/theme/theme-style.js +11 -0
  125. package/dist/theme/theme-types.d.ts +1 -0
  126. package/dist/theme/theme-types.js +26 -0
  127. package/dist/theme/tokens-1.generated.d.ts +1 -0
  128. package/dist/theme/tokens-1.generated.js +404 -0
  129. package/dist/theme/tokens-2.generated.d.ts +1 -0
  130. package/dist/theme/tokens-2.generated.js +404 -0
  131. package/dist/theme/tokens-3.generated.d.ts +1 -0
  132. package/dist/theme/tokens-3.generated.js +158 -0
  133. package/dist/theme/tokens.generated.d.ts +2 -0
  134. package/dist/theme/tokens.generated.js +6 -0
  135. package/dist/undo/undo-provider.js +24 -9
  136. package/package.json +82 -5
@@ -0,0 +1,128 @@
1
+ @import "../input/input.css";
2
+
3
+ @layer kumiko {
4
+ :where(:root) {
5
+ --kumiko-form-gap: 0.75rem;
6
+ --kumiko-form-label-gap: 0.375rem;
7
+ --kumiko-form-message-gap: 0.25rem;
8
+ --kumiko-form-inline-gap: 0.625rem;
9
+ --kumiko-form-group-gap: 0.5rem;
10
+ --kumiko-form-inline-label-weight: 400;
11
+ --kumiko-form-inline-label-size: 0.9375rem;
12
+ --kumiko-form-required-color: var(--kumiko-input-invalid);
13
+ --kumiko-form-error-color: var(--kumiko-input-invalid);
14
+ --kumiko-form-error-size: 0.875rem;
15
+ --kumiko-form-actions-gap: 0.5rem;
16
+ }
17
+
18
+ /* The form stacks its fields, and its error and actions after them. */
19
+ :where([data-kumiko-form]) {
20
+ display: grid;
21
+ gap: var(--kumiko-form-gap);
22
+ }
23
+
24
+ /*
25
+ * Spacing groups a field: the label sits close above its control, the description and error closer under it,
26
+ * and the reserved error line plus the form gap keep fields apart.
27
+ * These rules override the field rules in input.css, which other stylesheets import again, so they carry real
28
+ * specificity: a `:where()` here would only win when form.css happened to load last.
29
+ */
30
+ [data-kumiko-form-field] {
31
+ gap: 0;
32
+ }
33
+
34
+ [data-kumiko-form-field]:not([data-inline]) > [data-slot="field-label"] {
35
+ margin-block-end: var(--kumiko-form-label-gap);
36
+ }
37
+
38
+ [data-kumiko-form-field] > :is([data-slot="field-description"], [data-kumiko-form-error-line]) {
39
+ margin-block-start: var(--kumiko-form-message-gap);
40
+ }
41
+
42
+ /*
43
+ * A checkbox or a switch sits before its label, in one row. Its description and error start under the control,
44
+ * like every other field's.
45
+ */
46
+ [data-kumiko-form-field][data-inline] {
47
+ grid-template-columns: auto 1fr;
48
+ align-items: center;
49
+ column-gap: var(--kumiko-form-inline-gap);
50
+ }
51
+
52
+ :where(
53
+ [data-kumiko-form-field][data-inline] > [data-slot="field-description"],
54
+ [data-kumiko-form-field][data-inline] > [data-kumiko-form-error-line]
55
+ ) {
56
+ grid-column: 1 / -1;
57
+ }
58
+
59
+ /*
60
+ * One line is always kept for the error, so an error that comes and goes moves nothing. A longer one grows the
61
+ * line to its measured height, which reduced motion makes instant. Before the first measure the line fits.
62
+ */
63
+ :where([data-kumiko-form-error-line]) {
64
+ font-size: var(--kumiko-input-message-size);
65
+ min-block-size: 1lh;
66
+ block-size: var(--kumiko-form-error-height, auto);
67
+ overflow: clip;
68
+ transition: block-size var(--kumiko-move-duration) var(--kumiko-move-ease);
69
+ }
70
+
71
+ :where([data-kumiko-form-error-line] [data-slot="field-error"]) {
72
+ transition: opacity var(--kumiko-fade-duration) var(--kumiko-enter-ease);
73
+
74
+ @starting-style {
75
+ opacity: 0;
76
+ }
77
+ }
78
+
79
+ /* The error that just went away fades out in its place, then is removed. */
80
+ :where([data-kumiko-form-error-leaving]) {
81
+ margin: 0;
82
+ color: var(--kumiko-input-invalid);
83
+ opacity: 0;
84
+ transition: opacity var(--kumiko-fade-duration) var(--kumiko-exit-ease);
85
+
86
+ @starting-style {
87
+ opacity: 1;
88
+ }
89
+ }
90
+
91
+ :where([data-kumiko-form-field][data-inline] > [data-slot="field-label"]) {
92
+ font-weight: var(--kumiko-form-inline-label-weight);
93
+ font-size: var(--kumiko-form-inline-label-size);
94
+ }
95
+
96
+ /* A required field's label ends with a mark. The empty alternative keeps screen readers from reading it. */
97
+ :where([data-kumiko-form-field] > [data-slot="field-label"][data-required])::after {
98
+ content: " *";
99
+ content: " *" / "";
100
+ color: var(--kumiko-form-required-color);
101
+ }
102
+
103
+ /* A list fills its field, like a text box, instead of fitting its widest option. */
104
+ :where([data-kumiko-form-field] [data-slot="select-trigger"]) {
105
+ inline-size: 100%;
106
+ --kumiko-select-trigger-max-width: 100%;
107
+ }
108
+
109
+ :where([data-kumiko-form-group]) {
110
+ display: grid;
111
+ gap: var(--kumiko-form-group-gap);
112
+ justify-items: start;
113
+ }
114
+
115
+ :where([data-kumiko-form-error]) {
116
+ margin: 0;
117
+ color: var(--kumiko-form-error-color);
118
+ font-size: var(--kumiko-form-error-size);
119
+ }
120
+
121
+ /* The footer row. In an opened dialog the dialog's own stylesheet lays out the same row. */
122
+ :where([data-kumiko-actions]) {
123
+ display: flex;
124
+ flex-wrap: wrap;
125
+ gap: var(--kumiko-form-actions-gap);
126
+ justify-content: flex-end;
127
+ }
128
+ }
@@ -0,0 +1,10 @@
1
+ export { FieldShell, useShownError, type FieldShellProps } from "./field-shell";
2
+ export type { FieldProps } from "./field-props";
3
+ export { CheckboxField, CheckboxGroupField, SelectField, SwitchField, type CheckboxFieldProps, type CheckboxGroupFieldProps, type Option, type SelectFieldProps, type SwitchFieldProps } from "./choice-fields";
4
+ export { Actions, Form, FormError, SubmitButton, type FormProps } from "./form-parts";
5
+ export { useFieldContext, useFormContext } from "./form-context";
6
+ export { shownError, errorText } from "./shown-error";
7
+ export { submitErrors, type SubmitErrors } from "./submit-errors";
8
+ export { OtpField, TextareaField, TextField, type OtpFieldProps, type TextareaFieldProps, type TextFieldProps } from "./text-fields";
9
+ export { useAppForm, withForm } from "./use-app-form";
10
+ export { FileField, SliderField, type FileFieldProps, type SliderFieldProps } from "./value-fields";
@@ -0,0 +1,9 @@
1
+ export { FieldShell, useShownError } from "./field-shell";
2
+ export { CheckboxField, CheckboxGroupField, SelectField, SwitchField } from "./choice-fields";
3
+ export { Actions, Form, FormError, SubmitButton } from "./form-parts";
4
+ export { useFieldContext, useFormContext } from "./form-context";
5
+ export { shownError, errorText } from "./shown-error";
6
+ export { submitErrors } from "./submit-errors";
7
+ export { OtpField, TextareaField, TextField } from "./text-fields";
8
+ export { useAppForm, withForm } from "./use-app-form";
9
+ export { FileField, SliderField } from "./value-fields";
@@ -0,0 +1,12 @@
1
+ /** The words of one error: a string, or the `message` of an object such as a Standard Schema issue. */
2
+ export declare function errorText(error: unknown): string | undefined;
3
+ interface ErrorFacts {
4
+ isBlurred: boolean;
5
+ errors: readonly unknown[];
6
+ }
7
+ /**
8
+ * The one rule for when a field shows an error, used by every field: the first error with words, once the field
9
+ * has been left or a submit has been tried. Before that the field stays quiet, so no one is told off mid-typing.
10
+ */
11
+ export declare function shownError(meta: ErrorFacts, submissionAttempts: number): string | undefined;
12
+ export {};
@@ -0,0 +1,27 @@
1
+ /** The words of one error: a string, or the `message` of an object such as a Standard Schema issue. */
2
+ export function errorText(error) {
3
+ if (typeof error === "string") {
4
+ return error === "" ? undefined : error;
5
+ }
6
+ if (typeof error === "object" && error !== null && "message" in error) {
7
+ const { message } = error;
8
+ return typeof message === "string" && message !== "" ? message : undefined;
9
+ }
10
+ return undefined;
11
+ }
12
+ /**
13
+ * The one rule for when a field shows an error, used by every field: the first error with words, once the field
14
+ * has been left or a submit has been tried. Before that the field stays quiet, so no one is told off mid-typing.
15
+ */
16
+ export function shownError(meta, submissionAttempts) {
17
+ if (!meta.isBlurred && submissionAttempts === 0) {
18
+ return undefined;
19
+ }
20
+ for (const error of meta.errors) {
21
+ const text = errorText(error);
22
+ if (text !== undefined) {
23
+ return text;
24
+ }
25
+ }
26
+ return undefined;
27
+ }
@@ -0,0 +1,36 @@
1
+ import type { AnyFormApi } from "@tanstack/react-form";
2
+ /**
3
+ * What `onSubmit` returns when the server said no. The form shows `form` in `<form.FormError />` and each of
4
+ * `fields` beside its field.
5
+ */
6
+ export interface SubmitErrors {
7
+ readonly kumikoSubmitErrors: true;
8
+ readonly form?: string;
9
+ readonly fields?: Readonly<Record<string, string>>;
10
+ }
11
+ /** Tells the form that a submit failed on the server, with a message for the form, for fields, or for both. */
12
+ export declare function submitErrors(errors: {
13
+ form?: string;
14
+ fields?: Record<string, string>;
15
+ }): SubmitErrors;
16
+ export declare function isSubmitErrors(value: unknown): value is SubmitErrors;
17
+ /**
18
+ * Thrown inside the form's own `onSubmit` once a failure is on show, so TanStack Form counts the submit as failed
19
+ * (`isSubmitSuccessful` false, `isSubmitted` false). The form hides it from `handleSubmit()`.
20
+ */
21
+ export declare class SubmitFailedError extends Error {
22
+ constructor();
23
+ }
24
+ /** The words for something `onSubmit` threw. */
25
+ export declare function failureMessage(error: unknown): string;
26
+ /**
27
+ * Puts a failure into TanStack Form's own error maps, all under `onDynamic`: no validation of the default kind
28
+ * touches that key, so the messages keep through blurs. A field's message goes when that field changes
29
+ * (`clearServerError`), the form's when any field changes, and all of them when a new submit starts
30
+ * (`clearServerErrors`).
31
+ */
32
+ export declare function showServerErrors(form: AnyFormApi, errors: SubmitErrors): void;
33
+ /** Lets go of a field's server message and the form's, because the field changed. */
34
+ export declare function clearServerError(form: AnyFormApi, name: string): void;
35
+ /** Lets go of every server message, because a new submit starts. */
36
+ export declare function clearServerErrors(form: AnyFormApi): void;
@@ -0,0 +1,46 @@
1
+ /** Tells the form that a submit failed on the server, with a message for the form, for fields, or for both. */
2
+ export function submitErrors(errors) {
3
+ return { kumikoSubmitErrors: true, ...errors };
4
+ }
5
+ export function isSubmitErrors(value) {
6
+ return typeof value === "object" && value !== null && "kumikoSubmitErrors" in value;
7
+ }
8
+ /**
9
+ * Thrown inside the form's own `onSubmit` once a failure is on show, so TanStack Form counts the submit as failed
10
+ * (`isSubmitSuccessful` false, `isSubmitted` false). The form hides it from `handleSubmit()`.
11
+ */
12
+ export class SubmitFailedError extends Error {
13
+ constructor() {
14
+ super("The submit failed.");
15
+ this.name = "SubmitFailedError";
16
+ }
17
+ }
18
+ /** The words for something `onSubmit` threw. */
19
+ export function failureMessage(error) {
20
+ if (error instanceof Error && error.message !== "") {
21
+ return error.message;
22
+ }
23
+ return typeof error === "string" && error !== "" ? error : "Something went wrong.";
24
+ }
25
+ /**
26
+ * Puts a failure into TanStack Form's own error maps, all under `onDynamic`: no validation of the default kind
27
+ * touches that key, so the messages keep through blurs. A field's message goes when that field changes
28
+ * (`clearServerError`), the form's when any field changes, and all of them when a new submit starts
29
+ * (`clearServerErrors`).
30
+ */
31
+ export function showServerErrors(form, errors) {
32
+ form.setErrorMap({ onDynamic: { form: errors.form, fields: { ...errors.fields } } });
33
+ }
34
+ /** Lets go of a field's server message and the form's, because the field changed. */
35
+ export function clearServerError(form, name) {
36
+ form.setFieldMeta(name, (meta) => meta.errorMap.onDynamic === undefined
37
+ ? meta
38
+ : { ...meta, errorMap: { ...meta.errorMap, onDynamic: undefined } });
39
+ if (form.state.errorMap.onDynamic !== undefined) {
40
+ form.setErrorMap({ onDynamic: undefined });
41
+ }
42
+ }
43
+ /** Lets go of every server message, because a new submit starts. */
44
+ export function clearServerErrors(form) {
45
+ form.setErrorMap({ onDynamic: { form: undefined, fields: {} } });
46
+ }
@@ -0,0 +1,18 @@
1
+ import { type InputProps } from "../input";
2
+ import { type OTPInputProps } from "../otp-input";
3
+ import { type TextareaProps } from "../textarea";
4
+ import { type FieldProps } from "./field-props";
5
+ type Controlled = "value" | "defaultValue" | "onValueChange" | "name" | "required" | "disabled";
6
+ export type TextFieldProps = FieldProps & Omit<InputProps, Controlled>;
7
+ /** A line of text, bound to a form field whose value is a `string`. Takes any `type` of `Input`. */
8
+ export declare function TextField({ label, description, required, disabled, ...input }: TextFieldProps): React.JSX.Element;
9
+ export type TextareaFieldProps = FieldProps & Omit<TextareaProps, Controlled>;
10
+ /** Several lines of text, bound to a form field whose value is a `string`. */
11
+ export declare function TextareaField({ label, description, required, disabled, ...input }: TextareaFieldProps): React.JSX.Element;
12
+ export type OtpFieldProps = FieldProps & Omit<OTPInputProps, Controlled | "maxLength"> & {
13
+ /** How many characters the code has. @defaultValue 6 */
14
+ length?: number;
15
+ };
16
+ /** A one-time code, bound to a form field whose value is a `string`. Digits by default. */
17
+ export declare function OtpField({ label, description, required, disabled, length, ...input }: OtpFieldProps): React.JSX.Element;
18
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Input } from "../input";
3
+ import { OTPInput } from "../otp-input";
4
+ import { Textarea } from "../textarea";
5
+ import { useFieldValue } from "./field-props";
6
+ import { FieldShell } from "./field-shell";
7
+ /** A line of text, bound to a form field whose value is a `string`. Takes any `type` of `Input`. */
8
+ export function TextField({ label, description, required, disabled, ...input }) {
9
+ const [value, setValue] = useFieldValue();
10
+ return (_jsx(FieldShell, { label: label, description: description, disabled: disabled, children: _jsx(Input, { ...input, required: required, value: value, onValueChange: setValue }) }));
11
+ }
12
+ /** Several lines of text, bound to a form field whose value is a `string`. */
13
+ export function TextareaField({ label, description, required, disabled, ...input }) {
14
+ const [value, setValue] = useFieldValue();
15
+ return (_jsx(FieldShell, { label: label, description: description, disabled: disabled, children: _jsx(Textarea, { ...input, required: required, value: value, onValueChange: setValue }) }));
16
+ }
17
+ /** A one-time code, bound to a form field whose value is a `string`. Digits by default. */
18
+ export function OtpField({ label, description, required, disabled, length = 6, ...input }) {
19
+ const [value, setValue] = useFieldValue();
20
+ return (_jsx(FieldShell, { label: label, description: description, disabled: disabled, children: _jsx(OTPInput, { pattern: "digits", inputMode: "numeric", ...input, required: required, maxLength: length, value: value, onValueChange: setValue }) }));
21
+ }