@cocso-ui/react 1.10.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/breadcrumb/breadcrumb.d.ts +24 -3
- package/dist/cjs/components/breadcrumb/breadcrumb.js +44 -2
- package/dist/cjs/components/breadcrumb/breadcrumb.module.css.js +2 -2
- package/dist/cjs/components/card/card.d.ts +49 -2
- package/dist/cjs/components/card/card.js +76 -10
- package/dist/cjs/components/card/card.module.css.js +2 -2
- package/dist/cjs/components/copy-button/copy-button.d.ts +29 -0
- package/dist/cjs/components/copy-button/copy-button.js +67 -0
- package/dist/cjs/components/date-time-picker/date-time-picker.js +99 -76
- package/dist/cjs/components/day-picker/day-picker.js +24 -137
- package/dist/cjs/components/day-picker/day-picker.module.css.js +2 -2
- package/dist/cjs/components/empty-state/empty-state.d.ts +30 -0
- package/dist/cjs/components/empty-state/empty-state.js +50 -0
- package/dist/cjs/components/empty-state/empty-state.module.css.js +9 -0
- package/dist/cjs/components/file-uploader/file-uploader.d.ts +80 -0
- package/dist/cjs/components/file-uploader/file-uploader.js +258 -0
- package/dist/cjs/components/file-uploader/file-uploader.module.css.js +9 -0
- package/dist/cjs/components/form-field/form-field-context.d.ts +31 -0
- package/dist/cjs/components/form-field/form-field-context.js +53 -0
- package/dist/cjs/components/form-field/form-field-parts.d.ts +52 -0
- package/dist/cjs/components/form-field/form-field-parts.js +109 -0
- package/dist/cjs/components/form-field/form-field.d.ts +44 -0
- package/dist/cjs/components/form-field/form-field.js +61 -0
- package/dist/cjs/components/form-field/form-field.module.css.js +9 -0
- package/dist/cjs/components/info-popover/info-popover.d.ts +43 -0
- package/dist/cjs/components/info-popover/info-popover.js +57 -0
- package/dist/cjs/components/info-popover/info-popover.module.css.js +9 -0
- package/dist/cjs/components/loading-overlay/loading-overlay.d.ts +33 -0
- package/dist/cjs/components/loading-overlay/loading-overlay.js +68 -0
- package/dist/cjs/components/loading-overlay/loading-overlay.module.css.js +9 -0
- package/dist/cjs/components/number-input/number-input.d.ts +39 -0
- package/dist/cjs/components/number-input/number-input.js +167 -0
- package/dist/cjs/components/picker/year-month-view.js +216 -0
- package/dist/cjs/components/picker/year-month-view.module.css.js +9 -0
- package/dist/cjs/components/section-header/section-header.d.ts +48 -0
- package/dist/cjs/components/section-header/section-header.js +210 -0
- package/dist/cjs/components/section-header/section-header.module.css.js +9 -0
- package/dist/cjs/components/segmented-control/segmented-control.d.ts +55 -0
- package/dist/cjs/components/segmented-control/segmented-control.js +119 -0
- package/dist/cjs/components/segmented-control/segmented-control.module.css.js +9 -0
- package/dist/cjs/components/selection-chip/selection-chip.d.ts +22 -0
- package/dist/cjs/components/selection-chip/selection-chip.js +32 -0
- package/dist/cjs/components/selection-chip/selection-chip.module.css.js +9 -0
- package/dist/cjs/components/skeleton/skeleton.d.ts +7 -1
- package/dist/cjs/components/skeleton/skeleton.js +20 -2
- package/dist/cjs/components/skeleton/skeleton.module.css.js +1 -1
- package/dist/cjs/components/summary-card/summary-card.d.ts +47 -0
- package/dist/cjs/components/summary-card/summary-card.js +89 -0
- package/dist/cjs/components/summary-card/summary-card.module.css.js +9 -0
- package/dist/cjs/index.d.ts +15 -2
- package/dist/cjs/index.js +24 -0
- package/dist/esm/components/breadcrumb/breadcrumb.d.mts +24 -3
- package/dist/esm/components/breadcrumb/breadcrumb.mjs +44 -2
- package/dist/esm/components/breadcrumb/breadcrumb.module.css.mjs +1 -1
- package/dist/esm/components/card/card.d.mts +49 -2
- package/dist/esm/components/card/card.mjs +76 -10
- package/dist/esm/components/card/card.module.css.mjs +1 -1
- package/dist/esm/components/copy-button/copy-button.d.mts +29 -0
- package/dist/esm/components/copy-button/copy-button.mjs +65 -0
- package/dist/esm/components/date-time-picker/date-time-picker.mjs +99 -76
- package/dist/esm/components/day-picker/day-picker.mjs +27 -140
- package/dist/esm/components/day-picker/day-picker.module.css.mjs +1 -1
- package/dist/esm/components/empty-state/empty-state.d.mts +30 -0
- package/dist/esm/components/empty-state/empty-state.mjs +48 -0
- package/dist/esm/components/empty-state/empty-state.module.css.mjs +3 -0
- package/dist/esm/components/file-uploader/file-uploader.d.mts +80 -0
- package/dist/esm/components/file-uploader/file-uploader.mjs +256 -0
- package/dist/esm/components/file-uploader/file-uploader.module.css.mjs +3 -0
- package/dist/esm/components/form-field/form-field-context.d.mts +31 -0
- package/dist/esm/components/form-field/form-field-context.mjs +49 -0
- package/dist/esm/components/form-field/form-field-parts.d.mts +52 -0
- package/dist/esm/components/form-field/form-field-parts.mjs +105 -0
- package/dist/esm/components/form-field/form-field.d.mts +44 -0
- package/dist/esm/components/form-field/form-field.mjs +59 -0
- package/dist/esm/components/form-field/form-field.module.css.mjs +3 -0
- package/dist/esm/components/info-popover/info-popover.d.mts +43 -0
- package/dist/esm/components/info-popover/info-popover.mjs +55 -0
- package/dist/esm/components/info-popover/info-popover.module.css.mjs +3 -0
- package/dist/esm/components/loading-overlay/loading-overlay.d.mts +33 -0
- package/dist/esm/components/loading-overlay/loading-overlay.mjs +66 -0
- package/dist/esm/components/loading-overlay/loading-overlay.module.css.mjs +3 -0
- package/dist/esm/components/number-input/number-input.d.mts +39 -0
- package/dist/esm/components/number-input/number-input.mjs +165 -0
- package/dist/esm/components/picker/year-month-view.mjs +212 -0
- package/dist/esm/components/picker/year-month-view.module.css.mjs +3 -0
- package/dist/esm/components/section-header/section-header.d.mts +48 -0
- package/dist/esm/components/section-header/section-header.mjs +208 -0
- package/dist/esm/components/section-header/section-header.module.css.mjs +3 -0
- package/dist/esm/components/segmented-control/segmented-control.d.mts +55 -0
- package/dist/esm/components/segmented-control/segmented-control.mjs +117 -0
- package/dist/esm/components/segmented-control/segmented-control.module.css.mjs +3 -0
- package/dist/esm/components/selection-chip/selection-chip.d.mts +22 -0
- package/dist/esm/components/selection-chip/selection-chip.mjs +30 -0
- package/dist/esm/components/selection-chip/selection-chip.module.css.mjs +3 -0
- package/dist/esm/components/skeleton/skeleton.d.mts +7 -1
- package/dist/esm/components/skeleton/skeleton.mjs +20 -2
- package/dist/esm/components/summary-card/summary-card.d.mts +47 -0
- package/dist/esm/components/summary-card/summary-card.mjs +87 -0
- package/dist/esm/components/summary-card/summary-card.module.css.mjs +3 -0
- package/dist/esm/index.css +2 -2
- package/dist/esm/index.d.mts +15 -2
- package/dist/esm/index.mjs +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { InputSize } from '../input/input.mjs';
|
|
3
|
+
|
|
4
|
+
interface FormFieldContextValue {
|
|
5
|
+
/** The id the row's control should carry. `FormField.Label` points at it. */
|
|
6
|
+
controlId: string;
|
|
7
|
+
/** The id `FormField.Label` carries, for controls named by `aria-labelledby`. */
|
|
8
|
+
labelId: string;
|
|
9
|
+
/** The input size the row is laid out for. */
|
|
10
|
+
size: InputSize;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The ids and size of the enclosing `FormField`.
|
|
14
|
+
*
|
|
15
|
+
* `FormField.Input` and `FormField.InputTrigger` read this themselves. Any
|
|
16
|
+
* other control placed in the row — a `Select`, a picker trigger, a search
|
|
17
|
+
* box — should take `id={controlId}` so the row's label names it. Returns
|
|
18
|
+
* `null` outside a `FormField`.
|
|
19
|
+
*/
|
|
20
|
+
declare const useFormField: () => FormFieldContextValue | null;
|
|
21
|
+
interface FormFieldProps extends ComponentProps<"div"> {
|
|
22
|
+
/**
|
|
23
|
+
* The input size the row lines up with. The label's height and
|
|
24
|
+
* `FormField.Value`'s inset follow it, and `FormField.Input` /
|
|
25
|
+
* `FormField.InputTrigger` default to it.
|
|
26
|
+
*/
|
|
27
|
+
size?: InputSize;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { useFormField };
|
|
31
|
+
export type { FormFieldContextValue, FormFieldProps };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { input } from '../../ecosystem/codegen/generated/input.mjs';
|
|
3
|
+
import { useContext, createContext, useId } from 'react';
|
|
4
|
+
import { cn } from '../../cn.mjs';
|
|
5
|
+
import styles from './form-field.module.css.mjs';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
const FormFieldContext = /*#__PURE__*/createContext(null);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The ids and size of the enclosing `FormField`.
|
|
12
|
+
*
|
|
13
|
+
* `FormField.Input` and `FormField.InputTrigger` read this themselves. Any
|
|
14
|
+
* other control placed in the row — a `Select`, a picker trigger, a search
|
|
15
|
+
* box — should take `id={controlId}` so the row's label names it. Returns
|
|
16
|
+
* `null` outside a `FormField`.
|
|
17
|
+
*/
|
|
18
|
+
const useFormField = () => useContext(FormFieldContext);
|
|
19
|
+
/**
|
|
20
|
+
* The client half of the `FormField` root: it owns the ids, so it is the part
|
|
21
|
+
* that needs hooks. Kept apart from `form-field.tsx` so the compound object
|
|
22
|
+
* itself stays importable from a React Server Component.
|
|
23
|
+
*/
|
|
24
|
+
function FormFieldScope({
|
|
25
|
+
className,
|
|
26
|
+
size = "small",
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}) {
|
|
30
|
+
const controlId = useId();
|
|
31
|
+
const labelId = useId();
|
|
32
|
+
return /*#__PURE__*/jsx(FormFieldContext.Provider, {
|
|
33
|
+
value: {
|
|
34
|
+
controlId,
|
|
35
|
+
labelId,
|
|
36
|
+
size
|
|
37
|
+
},
|
|
38
|
+
children: /*#__PURE__*/jsx("div", {
|
|
39
|
+
className: cn(input({
|
|
40
|
+
size
|
|
41
|
+
}), styles.root, className),
|
|
42
|
+
"data-cocso-component": "form-field",
|
|
43
|
+
...props,
|
|
44
|
+
children: children
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { FormFieldScope, useFormField };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { InputProps } from '../input/input.mjs';
|
|
4
|
+
import { InputTriggerProps } from '../input-trigger/input-trigger.mjs';
|
|
5
|
+
|
|
6
|
+
interface FormFieldLabelProps extends ComponentProps<"label"> {
|
|
7
|
+
/**
|
|
8
|
+
* Appends a required marker. It is decoration only — mark the control itself
|
|
9
|
+
* `required` so assistive technology announces it.
|
|
10
|
+
*/
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Fixed width of the label column, so labels in one form line up. A number
|
|
14
|
+
* is pixels. Defaults to `--cocso-form-field-label-width`, then 128px, so a
|
|
15
|
+
* form can set the variable once instead of passing this on every row.
|
|
16
|
+
*/
|
|
17
|
+
width?: string | number;
|
|
18
|
+
}
|
|
19
|
+
declare function FormFieldLabel({ className, style: _style, required, width, htmlFor, id, children, ...props }: FormFieldLabelProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
type FormFieldInputProps = InputProps;
|
|
21
|
+
/**
|
|
22
|
+
* The row's text input: an `Input` at the row's size, stretched to the space
|
|
23
|
+
* beside the label, carrying the id the label points at.
|
|
24
|
+
*
|
|
25
|
+
* `type="password"` turns the reveal button on by default. `Input` keeps it
|
|
26
|
+
* opt-in so an existing field does not change on upgrade; a `FormField` row
|
|
27
|
+
* has no such history, and a password typed blind is only checked by
|
|
28
|
+
* submitting it. Pass `passwordToggle={false}` to opt out.
|
|
29
|
+
*
|
|
30
|
+
* Every `FormField.Input` in a row defaults to the row's one id. A row holding
|
|
31
|
+
* two inputs (a range, say) must give the second its own `id` — and an
|
|
32
|
+
* `aria-label` — or the page carries a duplicate id.
|
|
33
|
+
*/
|
|
34
|
+
declare function FormFieldInput({ id, size, type, passwordToggle, stretch, ...props }: FormFieldInputProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
interface FormFieldInputTriggerProps extends Omit<InputTriggerProps, "value"> {
|
|
36
|
+
/** The current value as text. `children`, when given, wins over it. */
|
|
37
|
+
value?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An `InputTrigger` at the row's size — the button a picker or a popover
|
|
41
|
+
* opens from, looking like the inputs around it.
|
|
42
|
+
*
|
|
43
|
+
* Named by the row's label and its own text together (`aria-labelledby`
|
|
44
|
+
* pointing at both). A `<label for>` would replace the button's name and the
|
|
45
|
+
* chosen value would never be announced, so the trigger deliberately carries
|
|
46
|
+
* an id of its own rather than the one the label points at — with both, the
|
|
47
|
+
* self-reference resolves to the label a second time instead of the value.
|
|
48
|
+
*/
|
|
49
|
+
declare function FormFieldInputTrigger({ id, size, value, children, stretch, "aria-labelledby": ariaLabelledBy, ...props }: FormFieldInputTriggerProps): react_jsx_runtime.JSX.Element;
|
|
50
|
+
|
|
51
|
+
export { FormFieldInput, FormFieldInputTrigger, FormFieldLabel };
|
|
52
|
+
export type { FormFieldInputProps, FormFieldInputTriggerProps, FormFieldLabelProps };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { cn } from '../../cn.mjs';
|
|
4
|
+
import styles from './form-field.module.css.mjs';
|
|
5
|
+
import { useFormField } from './form-field-context.mjs';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
import { InputTrigger } from '../input-trigger/input-trigger.mjs';
|
|
8
|
+
import { Input } from '../input/input.mjs';
|
|
9
|
+
|
|
10
|
+
function FormFieldLabel({
|
|
11
|
+
className,
|
|
12
|
+
style: _style,
|
|
13
|
+
required,
|
|
14
|
+
width,
|
|
15
|
+
htmlFor,
|
|
16
|
+
id,
|
|
17
|
+
children,
|
|
18
|
+
...props
|
|
19
|
+
}) {
|
|
20
|
+
const field = useFormField();
|
|
21
|
+
const style = {
|
|
22
|
+
..._style,
|
|
23
|
+
...(width === undefined ? {} : {
|
|
24
|
+
"--cocso-form-field-label-width": typeof width === "number" ? `${width}px` : width
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
return /*#__PURE__*/jsxs("label", {
|
|
28
|
+
className: cn(styles.label, className),
|
|
29
|
+
"data-cocso-component": "form-field-label",
|
|
30
|
+
htmlFor: htmlFor ?? field?.controlId,
|
|
31
|
+
id: id ?? field?.labelId,
|
|
32
|
+
style: style,
|
|
33
|
+
...props,
|
|
34
|
+
children: [children, required && /*#__PURE__*/jsx("span", {
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
className: styles.required,
|
|
37
|
+
children: "*"
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The row's text input: an `Input` at the row's size, stretched to the space
|
|
43
|
+
* beside the label, carrying the id the label points at.
|
|
44
|
+
*
|
|
45
|
+
* `type="password"` turns the reveal button on by default. `Input` keeps it
|
|
46
|
+
* opt-in so an existing field does not change on upgrade; a `FormField` row
|
|
47
|
+
* has no such history, and a password typed blind is only checked by
|
|
48
|
+
* submitting it. Pass `passwordToggle={false}` to opt out.
|
|
49
|
+
*
|
|
50
|
+
* Every `FormField.Input` in a row defaults to the row's one id. A row holding
|
|
51
|
+
* two inputs (a range, say) must give the second its own `id` — and an
|
|
52
|
+
* `aria-label` — or the page carries a duplicate id.
|
|
53
|
+
*/
|
|
54
|
+
function FormFieldInput({
|
|
55
|
+
id,
|
|
56
|
+
size,
|
|
57
|
+
type,
|
|
58
|
+
passwordToggle,
|
|
59
|
+
stretch = true,
|
|
60
|
+
...props
|
|
61
|
+
}) {
|
|
62
|
+
const field = useFormField();
|
|
63
|
+
return /*#__PURE__*/jsx(Input, {
|
|
64
|
+
id: id ?? field?.controlId,
|
|
65
|
+
passwordToggle: passwordToggle ?? type === "password",
|
|
66
|
+
size: size ?? field?.size ?? "small",
|
|
67
|
+
stretch: stretch,
|
|
68
|
+
type: type,
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* An `InputTrigger` at the row's size — the button a picker or a popover
|
|
74
|
+
* opens from, looking like the inputs around it.
|
|
75
|
+
*
|
|
76
|
+
* Named by the row's label and its own text together (`aria-labelledby`
|
|
77
|
+
* pointing at both). A `<label for>` would replace the button's name and the
|
|
78
|
+
* chosen value would never be announced, so the trigger deliberately carries
|
|
79
|
+
* an id of its own rather than the one the label points at — with both, the
|
|
80
|
+
* self-reference resolves to the label a second time instead of the value.
|
|
81
|
+
*/
|
|
82
|
+
function FormFieldInputTrigger({
|
|
83
|
+
id,
|
|
84
|
+
size,
|
|
85
|
+
value,
|
|
86
|
+
children,
|
|
87
|
+
stretch = true,
|
|
88
|
+
"aria-labelledby": ariaLabelledBy,
|
|
89
|
+
...props
|
|
90
|
+
}) {
|
|
91
|
+
const field = useFormField();
|
|
92
|
+
const generatedId = useId();
|
|
93
|
+
const triggerId = id ?? generatedId;
|
|
94
|
+
const labelledBy = ariaLabelledBy ?? (field ? `${field.labelId} ${triggerId}` : undefined);
|
|
95
|
+
return /*#__PURE__*/jsx(InputTrigger, {
|
|
96
|
+
"aria-labelledby": labelledBy,
|
|
97
|
+
id: triggerId,
|
|
98
|
+
size: size ?? field?.size ?? "small",
|
|
99
|
+
stretch: stretch,
|
|
100
|
+
...props,
|
|
101
|
+
children: children ?? value
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { FormFieldInput, FormFieldInputTrigger, FormFieldLabel };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { FormFieldProps } from './form-field-context.mjs';
|
|
4
|
+
export { FormFieldContextValue, useFormField } from './form-field-context.mjs';
|
|
5
|
+
import { FormFieldLabel, FormFieldInput, FormFieldInputTrigger } from './form-field-parts.mjs';
|
|
6
|
+
export { FormFieldInputProps, FormFieldInputTriggerProps, FormFieldLabelProps } from './form-field-parts.mjs';
|
|
7
|
+
|
|
8
|
+
declare function FormFieldRoot(props: FormFieldProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
/**
|
|
10
|
+
* A value that cannot be edited, shown where the input would be — same
|
|
11
|
+
* height and same inset as the inputs around it, so read-only and editable
|
|
12
|
+
* rows start their text on one line.
|
|
13
|
+
*/
|
|
14
|
+
declare function FormFieldValue({ className, ...props }: ComponentProps<"span">): react_jsx_runtime.JSX.Element;
|
|
15
|
+
/**
|
|
16
|
+
* A label beside its control, on one line — the layout of an admin form.
|
|
17
|
+
*
|
|
18
|
+
* `Field` stacks a label over its control with a description and an error
|
|
19
|
+
* under it; this lays them side by side with a fixed label column, so every
|
|
20
|
+
* row of a long form starts its control at the same place. Below 768px the
|
|
21
|
+
* label moves above the control.
|
|
22
|
+
*
|
|
23
|
+
* The label is tied to the control: the root makes an id, `FormField.Label`
|
|
24
|
+
* points at it and `FormField.Input` / `FormField.InputTrigger` carry it. Any
|
|
25
|
+
* other control takes it from `useFormField()`.
|
|
26
|
+
*
|
|
27
|
+
* The compound object lives in a module without `"use client"` so a Server
|
|
28
|
+
* Component can reach `FormField.Label`; the parts that need hooks are
|
|
29
|
+
* client modules of their own.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <FormField>
|
|
33
|
+
* <FormField.Label required width={120}>Email</FormField.Label>
|
|
34
|
+
* <FormField.Input required type="email" />
|
|
35
|
+
* </FormField>
|
|
36
|
+
*/
|
|
37
|
+
declare const FormField: typeof FormFieldRoot & {
|
|
38
|
+
Label: typeof FormFieldLabel;
|
|
39
|
+
Input: typeof FormFieldInput;
|
|
40
|
+
InputTrigger: typeof FormFieldInputTrigger;
|
|
41
|
+
Value: typeof FormFieldValue;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { FormField, FormFieldProps };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { cn } from '../../cn.mjs';
|
|
2
|
+
import styles from './form-field.module.css.mjs';
|
|
3
|
+
import { FormFieldScope } from './form-field-context.mjs';
|
|
4
|
+
export { useFormField } from './form-field-context.mjs';
|
|
5
|
+
import { FormFieldInputTrigger, FormFieldInput, FormFieldLabel } from './form-field-parts.mjs';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function FormFieldRoot(props) {
|
|
9
|
+
return /*#__PURE__*/jsx(FormFieldScope, {
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A value that cannot be edited, shown where the input would be — same
|
|
16
|
+
* height and same inset as the inputs around it, so read-only and editable
|
|
17
|
+
* rows start their text on one line.
|
|
18
|
+
*/
|
|
19
|
+
function FormFieldValue({
|
|
20
|
+
className,
|
|
21
|
+
...props
|
|
22
|
+
}) {
|
|
23
|
+
return /*#__PURE__*/jsx("span", {
|
|
24
|
+
className: cn(styles.value, className),
|
|
25
|
+
"data-cocso-component": "form-field-value",
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A label beside its control, on one line — the layout of an admin form.
|
|
32
|
+
*
|
|
33
|
+
* `Field` stacks a label over its control with a description and an error
|
|
34
|
+
* under it; this lays them side by side with a fixed label column, so every
|
|
35
|
+
* row of a long form starts its control at the same place. Below 768px the
|
|
36
|
+
* label moves above the control.
|
|
37
|
+
*
|
|
38
|
+
* The label is tied to the control: the root makes an id, `FormField.Label`
|
|
39
|
+
* points at it and `FormField.Input` / `FormField.InputTrigger` carry it. Any
|
|
40
|
+
* other control takes it from `useFormField()`.
|
|
41
|
+
*
|
|
42
|
+
* The compound object lives in a module without `"use client"` so a Server
|
|
43
|
+
* Component can reach `FormField.Label`; the parts that need hooks are
|
|
44
|
+
* client modules of their own.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <FormField>
|
|
48
|
+
* <FormField.Label required width={120}>Email</FormField.Label>
|
|
49
|
+
* <FormField.Input required type="email" />
|
|
50
|
+
* </FormField>
|
|
51
|
+
*/
|
|
52
|
+
const FormField = Object.assign(FormFieldRoot, {
|
|
53
|
+
Label: FormFieldLabel,
|
|
54
|
+
Input: FormFieldInput,
|
|
55
|
+
InputTrigger: FormFieldInputTrigger,
|
|
56
|
+
Value: FormFieldValue
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export { FormField };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
import { Popover } from '../popover/popover.mjs';
|
|
4
|
+
|
|
5
|
+
type PopoverRootProps = ComponentProps<typeof Popover>;
|
|
6
|
+
type PopoverContentProps = ComponentProps<typeof Popover.Content>;
|
|
7
|
+
interface InfoPopoverProps extends Pick<PopoverRootProps, "defaultOpen" | "open" | "onOpenChange">, Pick<PopoverContentProps, "side" | "align"> {
|
|
8
|
+
/** The explanation the icon opens. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** Class for the panel. */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Size of the icon in pixels. Defaults to `14`. */
|
|
13
|
+
iconSize?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Accessible name of the icon button, and of the panel it opens. The icon
|
|
16
|
+
* carries no text, so this is all a screen reader announces. Defaults to
|
|
17
|
+
* `"More information"`.
|
|
18
|
+
*/
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Class for the icon button. */
|
|
21
|
+
triggerClassName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Width of the panel. A number is pixels. Defaults to 300px; widen it for
|
|
24
|
+
* longer sentences. Never wider than the viewport less 32px.
|
|
25
|
+
*/
|
|
26
|
+
width?: number | string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* An info icon that folds away an explanation that never changes — how a
|
|
30
|
+
* total is summed, why a duplicate is refused — so the card it explains stays
|
|
31
|
+
* short.
|
|
32
|
+
*
|
|
33
|
+
* Guidance that changes with the value or the state should stay on the page
|
|
34
|
+
* instead: folding it away hides exactly when it matters.
|
|
35
|
+
*
|
|
36
|
+
* Built on `Popover`, so the panel is a labelled dialog on the popover layer
|
|
37
|
+
* and keeps Popover's `popover-content` / `popover-positioner` hooks, as the
|
|
38
|
+
* pickers do. The icon button is `info-popover-trigger`.
|
|
39
|
+
*/
|
|
40
|
+
declare function InfoPopover({ children, className, iconSize, label, triggerClassName, width, side, align, ...rootProps }: InfoPopoverProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
export { InfoPopover };
|
|
43
|
+
export type { InfoPopoverProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { InfoIcon } from '@cocso-ui/react-icons';
|
|
3
|
+
import { cn } from '../../cn.mjs';
|
|
4
|
+
import styles from './info-popover.module.css.mjs';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { Popover } from '../popover/popover.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An info icon that folds away an explanation that never changes — how a
|
|
10
|
+
* total is summed, why a duplicate is refused — so the card it explains stays
|
|
11
|
+
* short.
|
|
12
|
+
*
|
|
13
|
+
* Guidance that changes with the value or the state should stay on the page
|
|
14
|
+
* instead: folding it away hides exactly when it matters.
|
|
15
|
+
*
|
|
16
|
+
* Built on `Popover`, so the panel is a labelled dialog on the popover layer
|
|
17
|
+
* and keeps Popover's `popover-content` / `popover-positioner` hooks, as the
|
|
18
|
+
* pickers do. The icon button is `info-popover-trigger`.
|
|
19
|
+
*/
|
|
20
|
+
function InfoPopover({
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
iconSize = 14,
|
|
24
|
+
label = "More information",
|
|
25
|
+
triggerClassName,
|
|
26
|
+
width = 300,
|
|
27
|
+
side,
|
|
28
|
+
align,
|
|
29
|
+
...rootProps
|
|
30
|
+
}) {
|
|
31
|
+
const style = {
|
|
32
|
+
"--cocso-info-popover-width": typeof width === "number" ? `${width}px` : width
|
|
33
|
+
};
|
|
34
|
+
return /*#__PURE__*/jsxs(Popover, {
|
|
35
|
+
...rootProps,
|
|
36
|
+
children: [/*#__PURE__*/jsx(Popover.Trigger, {
|
|
37
|
+
"aria-label": label,
|
|
38
|
+
className: cn(styles.trigger, triggerClassName),
|
|
39
|
+
"data-cocso-component": "info-popover-trigger",
|
|
40
|
+
children: /*#__PURE__*/jsx(InfoIcon, {
|
|
41
|
+
"aria-hidden": "true",
|
|
42
|
+
size: iconSize
|
|
43
|
+
})
|
|
44
|
+
}), /*#__PURE__*/jsx(Popover.Content, {
|
|
45
|
+
align: align,
|
|
46
|
+
"aria-label": label,
|
|
47
|
+
className: cn(styles.content, className),
|
|
48
|
+
side: side,
|
|
49
|
+
style: style,
|
|
50
|
+
children: children
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { InfoPopover };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
interface LoadingOverlayProps extends Omit<ComponentProps<"div">, "children"> {
|
|
5
|
+
/** Secondary guidance under the message — how long it takes, not to close the window. */
|
|
6
|
+
description?: string;
|
|
7
|
+
/** The main line under the spinner. Also the spinner's accessible name. */
|
|
8
|
+
message?: string;
|
|
9
|
+
/** Renders the overlay only while true; renders nothing otherwise. */
|
|
10
|
+
open: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A layer that covers the whole viewport while a long task runs.
|
|
14
|
+
*
|
|
15
|
+
* For work that takes several seconds and must not be interrupted — an
|
|
16
|
+
* upload, say. It is `position: fixed`, so in a popup window opened with
|
|
17
|
+
* `window.open` it covers that whole window.
|
|
18
|
+
*
|
|
19
|
+
* It blocks the pointer, not the keyboard: content underneath stays in the
|
|
20
|
+
* tab order. Mark it `inert` yourself if the task must not be re-triggered
|
|
21
|
+
* from the keyboard.
|
|
22
|
+
*
|
|
23
|
+
* It sits on `--cocso-z-index-overlay`, the dialog backdrop layer, so it is
|
|
24
|
+
* drawn under an open `Dialog` panel. Override the z-index through
|
|
25
|
+
* `[data-cocso-component="loading-overlay"]` when it has to cover one.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* <LoadingOverlay open={isPending} message="정산 데이터를 업로드하고 있습니다" />
|
|
29
|
+
*/
|
|
30
|
+
declare function LoadingOverlay({ ref, className, open, message, description, ...props }: LoadingOverlayProps): react_jsx_runtime.JSX.Element | null;
|
|
31
|
+
|
|
32
|
+
export { LoadingOverlay };
|
|
33
|
+
export type { LoadingOverlayProps };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from '../../cn.mjs';
|
|
3
|
+
import styles from './loading-overlay.module.css.mjs';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
import { Spinner } from '../spinner/spinner.mjs';
|
|
6
|
+
import { Typography } from '../typography/typography.mjs';
|
|
7
|
+
import { colors } from '../../token/color.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A layer that covers the whole viewport while a long task runs.
|
|
11
|
+
*
|
|
12
|
+
* For work that takes several seconds and must not be interrupted — an
|
|
13
|
+
* upload, say. It is `position: fixed`, so in a popup window opened with
|
|
14
|
+
* `window.open` it covers that whole window.
|
|
15
|
+
*
|
|
16
|
+
* It blocks the pointer, not the keyboard: content underneath stays in the
|
|
17
|
+
* tab order. Mark it `inert` yourself if the task must not be re-triggered
|
|
18
|
+
* from the keyboard.
|
|
19
|
+
*
|
|
20
|
+
* It sits on `--cocso-z-index-overlay`, the dialog backdrop layer, so it is
|
|
21
|
+
* drawn under an open `Dialog` panel. Override the z-index through
|
|
22
|
+
* `[data-cocso-component="loading-overlay"]` when it has to cover one.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <LoadingOverlay open={isPending} message="정산 데이터를 업로드하고 있습니다" />
|
|
26
|
+
*/
|
|
27
|
+
function LoadingOverlay({
|
|
28
|
+
ref,
|
|
29
|
+
className,
|
|
30
|
+
open,
|
|
31
|
+
message = "처리 중입니다",
|
|
32
|
+
description,
|
|
33
|
+
...props
|
|
34
|
+
}) {
|
|
35
|
+
if (!open) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/jsxs("div", {
|
|
39
|
+
"aria-busy": "true",
|
|
40
|
+
className: cn(styles.overlay, className),
|
|
41
|
+
"data-cocso-component": "loading-overlay",
|
|
42
|
+
ref: ref,
|
|
43
|
+
...props,
|
|
44
|
+
children: [/*#__PURE__*/jsx(Spinner, {
|
|
45
|
+
label: message,
|
|
46
|
+
size: "large",
|
|
47
|
+
variant: "primary"
|
|
48
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
49
|
+
className: styles.text,
|
|
50
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
51
|
+
color: colors.textPrimary,
|
|
52
|
+
type: "body",
|
|
53
|
+
weight: "medium",
|
|
54
|
+
children: message
|
|
55
|
+
}), description && /*#__PURE__*/jsx(Typography, {
|
|
56
|
+
className: styles.description,
|
|
57
|
+
color: colors.textSecondary,
|
|
58
|
+
size: "small",
|
|
59
|
+
type: "body",
|
|
60
|
+
children: description
|
|
61
|
+
})]
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { LoadingOverlay };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { InputProps } from '../input/input.mjs';
|
|
3
|
+
|
|
4
|
+
interface NumberInputProps extends Omit<InputProps, "type" | "value" | "defaultValue" | "onChange" | "passwordToggle"> {
|
|
5
|
+
/** Decimal places a user may type. `0`, the default, is a whole amount. */
|
|
6
|
+
maxFractionDigits?: number;
|
|
7
|
+
/** The parsed number on every edit, or `null` when the field is empty. */
|
|
8
|
+
onValueChange: (value: number | null) => void;
|
|
9
|
+
/** The current number. `null` or `undefined` shows an empty field. */
|
|
10
|
+
value: number | null | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An `Input` for amounts, grouped in thousands as the user types.
|
|
14
|
+
*
|
|
15
|
+
* It is a text field with `inputMode`, not `type="number"`: a native number
|
|
16
|
+
* input cannot display a separator. The caret is put back after the same digit
|
|
17
|
+
* when a comma is inserted or removed in front of it.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to the `small` size and the full width of its container, the shape
|
|
20
|
+
* the field had where it came from; both can be overridden.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <Controller
|
|
24
|
+
* control={control}
|
|
25
|
+
* name="amount"
|
|
26
|
+
* render={({ field }) => (
|
|
27
|
+
* <NumberInput
|
|
28
|
+
* aria-label="금액"
|
|
29
|
+
* onBlur={field.onBlur}
|
|
30
|
+
* onValueChange={field.onChange}
|
|
31
|
+
* value={field.value}
|
|
32
|
+
* />
|
|
33
|
+
* )}
|
|
34
|
+
* />
|
|
35
|
+
*/
|
|
36
|
+
declare function NumberInput({ value, onValueChange, maxFractionDigits, onBlur, size, stretch, ...props }: NumberInputProps): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
export { NumberInput };
|
|
39
|
+
export type { NumberInputProps };
|