@cocso-ui/react 1.11.0 → 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.
Files changed (92) hide show
  1. package/dist/cjs/components/breadcrumb/breadcrumb.d.ts +24 -3
  2. package/dist/cjs/components/breadcrumb/breadcrumb.js +44 -2
  3. package/dist/cjs/components/breadcrumb/breadcrumb.module.css.js +2 -2
  4. package/dist/cjs/components/card/card.d.ts +49 -2
  5. package/dist/cjs/components/card/card.js +76 -10
  6. package/dist/cjs/components/card/card.module.css.js +2 -2
  7. package/dist/cjs/components/copy-button/copy-button.d.ts +29 -0
  8. package/dist/cjs/components/copy-button/copy-button.js +67 -0
  9. package/dist/cjs/components/empty-state/empty-state.d.ts +30 -0
  10. package/dist/cjs/components/empty-state/empty-state.js +50 -0
  11. package/dist/cjs/components/empty-state/empty-state.module.css.js +9 -0
  12. package/dist/cjs/components/file-uploader/file-uploader.d.ts +80 -0
  13. package/dist/cjs/components/file-uploader/file-uploader.js +258 -0
  14. package/dist/cjs/components/file-uploader/file-uploader.module.css.js +9 -0
  15. package/dist/cjs/components/form-field/form-field-context.d.ts +31 -0
  16. package/dist/cjs/components/form-field/form-field-context.js +53 -0
  17. package/dist/cjs/components/form-field/form-field-parts.d.ts +52 -0
  18. package/dist/cjs/components/form-field/form-field-parts.js +109 -0
  19. package/dist/cjs/components/form-field/form-field.d.ts +44 -0
  20. package/dist/cjs/components/form-field/form-field.js +61 -0
  21. package/dist/cjs/components/form-field/form-field.module.css.js +9 -0
  22. package/dist/cjs/components/info-popover/info-popover.d.ts +43 -0
  23. package/dist/cjs/components/info-popover/info-popover.js +57 -0
  24. package/dist/cjs/components/info-popover/info-popover.module.css.js +9 -0
  25. package/dist/cjs/components/loading-overlay/loading-overlay.d.ts +33 -0
  26. package/dist/cjs/components/loading-overlay/loading-overlay.js +68 -0
  27. package/dist/cjs/components/loading-overlay/loading-overlay.module.css.js +9 -0
  28. package/dist/cjs/components/number-input/number-input.d.ts +39 -0
  29. package/dist/cjs/components/number-input/number-input.js +167 -0
  30. package/dist/cjs/components/section-header/section-header.d.ts +48 -0
  31. package/dist/cjs/components/section-header/section-header.js +210 -0
  32. package/dist/cjs/components/section-header/section-header.module.css.js +9 -0
  33. package/dist/cjs/components/segmented-control/segmented-control.d.ts +55 -0
  34. package/dist/cjs/components/segmented-control/segmented-control.js +119 -0
  35. package/dist/cjs/components/segmented-control/segmented-control.module.css.js +9 -0
  36. package/dist/cjs/components/selection-chip/selection-chip.d.ts +22 -0
  37. package/dist/cjs/components/selection-chip/selection-chip.js +32 -0
  38. package/dist/cjs/components/selection-chip/selection-chip.module.css.js +9 -0
  39. package/dist/cjs/components/skeleton/skeleton.d.ts +7 -1
  40. package/dist/cjs/components/skeleton/skeleton.js +20 -2
  41. package/dist/cjs/components/summary-card/summary-card.d.ts +47 -0
  42. package/dist/cjs/components/summary-card/summary-card.js +89 -0
  43. package/dist/cjs/components/summary-card/summary-card.module.css.js +9 -0
  44. package/dist/cjs/index.d.ts +15 -2
  45. package/dist/cjs/index.js +24 -0
  46. package/dist/esm/components/breadcrumb/breadcrumb.d.mts +24 -3
  47. package/dist/esm/components/breadcrumb/breadcrumb.mjs +44 -2
  48. package/dist/esm/components/breadcrumb/breadcrumb.module.css.mjs +1 -1
  49. package/dist/esm/components/card/card.d.mts +49 -2
  50. package/dist/esm/components/card/card.mjs +76 -10
  51. package/dist/esm/components/card/card.module.css.mjs +1 -1
  52. package/dist/esm/components/copy-button/copy-button.d.mts +29 -0
  53. package/dist/esm/components/copy-button/copy-button.mjs +65 -0
  54. package/dist/esm/components/empty-state/empty-state.d.mts +30 -0
  55. package/dist/esm/components/empty-state/empty-state.mjs +48 -0
  56. package/dist/esm/components/empty-state/empty-state.module.css.mjs +3 -0
  57. package/dist/esm/components/file-uploader/file-uploader.d.mts +80 -0
  58. package/dist/esm/components/file-uploader/file-uploader.mjs +256 -0
  59. package/dist/esm/components/file-uploader/file-uploader.module.css.mjs +3 -0
  60. package/dist/esm/components/form-field/form-field-context.d.mts +31 -0
  61. package/dist/esm/components/form-field/form-field-context.mjs +49 -0
  62. package/dist/esm/components/form-field/form-field-parts.d.mts +52 -0
  63. package/dist/esm/components/form-field/form-field-parts.mjs +105 -0
  64. package/dist/esm/components/form-field/form-field.d.mts +44 -0
  65. package/dist/esm/components/form-field/form-field.mjs +59 -0
  66. package/dist/esm/components/form-field/form-field.module.css.mjs +3 -0
  67. package/dist/esm/components/info-popover/info-popover.d.mts +43 -0
  68. package/dist/esm/components/info-popover/info-popover.mjs +55 -0
  69. package/dist/esm/components/info-popover/info-popover.module.css.mjs +3 -0
  70. package/dist/esm/components/loading-overlay/loading-overlay.d.mts +33 -0
  71. package/dist/esm/components/loading-overlay/loading-overlay.mjs +66 -0
  72. package/dist/esm/components/loading-overlay/loading-overlay.module.css.mjs +3 -0
  73. package/dist/esm/components/number-input/number-input.d.mts +39 -0
  74. package/dist/esm/components/number-input/number-input.mjs +165 -0
  75. package/dist/esm/components/section-header/section-header.d.mts +48 -0
  76. package/dist/esm/components/section-header/section-header.mjs +208 -0
  77. package/dist/esm/components/section-header/section-header.module.css.mjs +3 -0
  78. package/dist/esm/components/segmented-control/segmented-control.d.mts +55 -0
  79. package/dist/esm/components/segmented-control/segmented-control.mjs +117 -0
  80. package/dist/esm/components/segmented-control/segmented-control.module.css.mjs +3 -0
  81. package/dist/esm/components/selection-chip/selection-chip.d.mts +22 -0
  82. package/dist/esm/components/selection-chip/selection-chip.mjs +30 -0
  83. package/dist/esm/components/selection-chip/selection-chip.module.css.mjs +3 -0
  84. package/dist/esm/components/skeleton/skeleton.d.mts +7 -1
  85. package/dist/esm/components/skeleton/skeleton.mjs +20 -2
  86. package/dist/esm/components/summary-card/summary-card.d.mts +47 -0
  87. package/dist/esm/components/summary-card/summary-card.mjs +87 -0
  88. package/dist/esm/components/summary-card/summary-card.module.css.mjs +3 -0
  89. package/dist/esm/index.css +2 -2
  90. package/dist/esm/index.d.mts +15 -2
  91. package/dist/esm/index.mjs +12 -0
  92. package/package.json +1 -1
@@ -0,0 +1,258 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var reactIcons = require('@cocso-ui/react-icons');
5
+ var react = require('react');
6
+ var cn = require('../../cn.js');
7
+ var fileUploader_module = require('./file-uploader.module.css.js');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var typography = require('../typography/typography.js');
10
+ var fileRow = require('../file-row/file-row.js');
11
+ var button = require('../button/button.js');
12
+ var sonner = require('sonner');
13
+
14
+ const DEFAULT_MESSAGES = {
15
+ compactPrompt: "끌어다 놓거나 클릭해 등록",
16
+ prompt: "파일을 여기에 끌어다 놓거나, 클릭하여 파일을 선택해주세요",
17
+ maxSizeHint: maxSizeMb => `(최대 ${maxSizeMb}MB)`,
18
+ remove: fileName => `${fileName} 삭제`,
19
+ rejectCount: maxFiles => `최대 ${maxFiles}개의 파일만 업로드할 수 있습니다.`,
20
+ rejectSize: (file, maxSizeMb) => `${file.name}은(는) ${maxSizeMb}MB를 초과합니다.`,
21
+ rejectType: file => `${file.name}은(는) 허용되지 않는 파일 타입입니다.`
22
+ };
23
+ const BYTES_PER_MB = 1024 * 1024;
24
+ const DEFAULT_MAX_SIZE = 3 * BYTES_PER_MB;
25
+ function matchesAccept(file, accept) {
26
+ if (!accept) {
27
+ return true;
28
+ }
29
+ return accept.split(",").map(type => type.trim()).filter(Boolean).some(type => {
30
+ if (type.endsWith("/*")) {
31
+ return file.type.startsWith(type.slice(0, -1));
32
+ }
33
+ return file.type === type || file.name.toLowerCase().endsWith(type.toLowerCase());
34
+ });
35
+ }
36
+
37
+ /**
38
+ * Drag-and-drop or pick files, listed underneath as `FileRow`s.
39
+ *
40
+ * The drop zone is a `<label>` around a real, visually hidden
41
+ * `<input type="file">`, so Tab reaches the input, Enter and Space open the
42
+ * picker natively, and the zone's prompt is the input's accessible name. The
43
+ * zone is drawn focused while the input is. It disappears once `maxFiles` is
44
+ * reached (or one file is chosen when `multiple` is false).
45
+ *
46
+ * Files that fail `accept`, `maxSize` or `maxFiles` are turned away and
47
+ * reported — through `onReject` when given, otherwise as error toasts (which
48
+ * need a `Toaster` mounted).
49
+ */
50
+ function FileUploader({
51
+ ref,
52
+ className,
53
+ style,
54
+ files,
55
+ onFilesChange,
56
+ onRemove,
57
+ onReject,
58
+ maxFiles = 2,
59
+ maxSize = DEFAULT_MAX_SIZE,
60
+ sizeHint,
61
+ compact = false,
62
+ messages: messagesProp,
63
+ multiple = true,
64
+ accept,
65
+ disabled = false,
66
+ onChange,
67
+ ...props
68
+ }) {
69
+ const messages = {
70
+ ...DEFAULT_MESSAGES,
71
+ ...messagesProp
72
+ };
73
+ const [isDragActive, setIsDragActive] = react.useState(false);
74
+ const zoneRef = react.useRef(null);
75
+ const maxSizeMb = Math.round(maxSize / BYTES_PER_MB);
76
+
77
+ // Names and sizes can repeat, so each `File` gets an id the first time it
78
+ // is seen. The caller keeps the same `File` across renders, so the id holds.
79
+ const keys = react.useRef(new WeakMap());
80
+ const nextKey = react.useRef(0);
81
+ const keyFor = file => {
82
+ let key = keys.current.get(file);
83
+ if (key === undefined) {
84
+ key = nextKey.current++;
85
+ keys.current.set(file, key);
86
+ }
87
+ return key;
88
+ };
89
+ const addFiles = incoming => {
90
+ const rejections = [];
91
+ const accepted = [];
92
+ for (const file of Array.from(incoming)) {
93
+ if (!matchesAccept(file, accept)) {
94
+ rejections.push({
95
+ file,
96
+ reason: "type",
97
+ message: messages.rejectType(file)
98
+ });
99
+ } else if (file.size > maxSize) {
100
+ rejections.push({
101
+ file,
102
+ reason: "size",
103
+ message: messages.rejectSize(file, maxSizeMb)
104
+ });
105
+ } else {
106
+ accepted.push(file);
107
+ }
108
+ }
109
+ const remaining = Math.max(0, maxFiles - files.length);
110
+ const added = accepted.slice(0, remaining);
111
+ for (const file of accepted.slice(remaining)) {
112
+ rejections.push({
113
+ file,
114
+ reason: "count",
115
+ message: messages.rejectCount(maxFiles)
116
+ });
117
+ }
118
+ if (rejections.length > 0) {
119
+ if (onReject) {
120
+ onReject(rejections);
121
+ } else {
122
+ // One toast per distinct message: ten files over the count limit
123
+ // say so once, not ten times.
124
+ for (const message of new Set(rejections.map(r => r.message))) {
125
+ sonner.toast.error(message);
126
+ }
127
+ }
128
+ }
129
+ if (added.length > 0) {
130
+ onFilesChange([...files, ...added.map(file => ({
131
+ file,
132
+ name: file.name,
133
+ size: file.size
134
+ }))]);
135
+ }
136
+ };
137
+ const handleDragEnter = event => {
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ if (!disabled) {
141
+ setIsDragActive(true);
142
+ }
143
+ };
144
+ const handleDragOver = event => {
145
+ event.preventDefault();
146
+ event.stopPropagation();
147
+ };
148
+ const handleDragLeave = event => {
149
+ event.preventDefault();
150
+ event.stopPropagation();
151
+ const next = event.relatedTarget;
152
+ if (!(next && zoneRef.current?.contains(next))) {
153
+ setIsDragActive(false);
154
+ }
155
+ };
156
+ const handleDrop = event => {
157
+ event.preventDefault();
158
+ event.stopPropagation();
159
+ setIsDragActive(false);
160
+ if (disabled) {
161
+ return;
162
+ }
163
+ if (event.dataTransfer?.files) {
164
+ addFiles(event.dataTransfer.files);
165
+ }
166
+ };
167
+ const handleRemove = index => {
168
+ const removed = files[index];
169
+ onFilesChange(files.filter((_, i) => i !== index));
170
+ if (removed) {
171
+ onRemove?.(removed.name);
172
+ }
173
+ };
174
+ const hideZone = files.length >= maxFiles || !multiple && files.length >= 1;
175
+ const hint = sizeHint ?? messages.maxSizeHint(maxSizeMb);
176
+ const prompt = compact ? messages.compactPrompt : messages.prompt;
177
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
178
+ className: cn.cn(fileUploader_module.uploader, className),
179
+ "data-cocso-component": "file-uploader",
180
+ style: style,
181
+ children: [!hideZone &&
182
+ /*#__PURE__*/
183
+ // biome-ignore lint/a11y/noNoninteractiveElementInteractions: drag and drop has no keyboard equivalent; the wrapped input is the keyboard path
184
+ jsxRuntime.jsxs("label", {
185
+ className: cn.cn(fileUploader_module.zone, compact && fileUploader_module.compact),
186
+ "data-cocso-component": "file-uploader-dropzone",
187
+ "data-compact": compact || undefined,
188
+ "data-disabled": disabled || undefined,
189
+ "data-drag-active": isDragActive || undefined,
190
+ onDragEnter: handleDragEnter,
191
+ onDragLeave: handleDragLeave,
192
+ onDragOver: handleDragOver,
193
+ onDrop: handleDrop,
194
+ ref: zoneRef,
195
+ children: [/*#__PURE__*/jsxRuntime.jsx("input", {
196
+ accept: accept,
197
+ className: fileUploader_module.input,
198
+ disabled: disabled,
199
+ multiple: multiple,
200
+ ref: ref,
201
+ type: "file",
202
+ ...props,
203
+ onChange: event => {
204
+ onChange?.(event);
205
+ if (event.target.files) {
206
+ addFiles(event.target.files);
207
+ }
208
+ event.target.value = "";
209
+ }
210
+ }), compact && !disabled && /*#__PURE__*/jsxRuntime.jsx(reactIcons.PlusIcon, {
211
+ "aria-hidden": true,
212
+ className: fileUploader_module.icon,
213
+ size: 20
214
+ }), /*#__PURE__*/jsxRuntime.jsxs(typography.Typography, {
215
+ className: fileUploader_module.text,
216
+ render: /*#__PURE__*/jsxRuntime.jsx("span", {}),
217
+ size: "x-small",
218
+ type: "body",
219
+ children: [!disabled && /*#__PURE__*/jsxRuntime.jsx("span", {
220
+ className: fileUploader_module.prompt,
221
+ children: prompt
222
+ }), !disabled && (compact ? " · " : " "), /*#__PURE__*/jsxRuntime.jsx("span", {
223
+ className: fileUploader_module.hint,
224
+ children: hint
225
+ })]
226
+ }), !(compact || disabled) && /*#__PURE__*/jsxRuntime.jsx(reactIcons.PlusIcon, {
227
+ "aria-hidden": true,
228
+ className: fileUploader_module.icon,
229
+ size: 20
230
+ })]
231
+ }), files.length > 0 && /*#__PURE__*/jsxRuntime.jsx("ul", {
232
+ className: fileUploader_module.list,
233
+ "data-cocso-component": "file-uploader-list",
234
+ children: files.map((item, index) => /*#__PURE__*/jsxRuntime.jsx("li", {
235
+ className: fileUploader_module.item,
236
+ children: /*#__PURE__*/jsxRuntime.jsx(fileRow.FileRow, {
237
+ actions: /*#__PURE__*/jsxRuntime.jsx(button.Button, {
238
+ "aria-label": messages.remove(item.name),
239
+ disabled: disabled,
240
+ onClick: () => handleRemove(index),
241
+ size: "x-small",
242
+ svgOnly: true,
243
+ type: "button",
244
+ variant: "ghost",
245
+ children: /*#__PURE__*/jsxRuntime.jsx(reactIcons.CloseIcon, {
246
+ size: 14
247
+ })
248
+ }),
249
+ disabled: disabled,
250
+ name: item.name,
251
+ stretch: true
252
+ })
253
+ }, keyFor(item.file)))
254
+ })]
255
+ });
256
+ }
257
+
258
+ exports.FileUploader = FileUploader;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var styleInject_es = require('../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
4
+
5
+ var css_248z = "@layer components{.file-uploader-module_uploader__H6Mi3{display:flex;flex-direction:column;gap:var(--cocso-spacing-5);width:100%}.file-uploader-module_zone__-lnp-{align-items:center;background-color:var(--cocso-color-surface-secondary);border:1px dashed var(--cocso-color-border-primary);border-radius:var(--cocso-radius-1);color:var(--cocso-color-text-secondary);cursor:pointer;display:flex;flex-direction:column;gap:var(--cocso-spacing-5);justify-content:center;padding:var(--cocso-spacing-8);position:relative;text-align:center;transition:border-color var(--cocso-duration-fast) var(--cocso-easing-default),background-color var(--cocso-duration-fast) var(--cocso-easing-default)}.file-uploader-module_zone__-lnp-:has(.file-uploader-module_input__wft8r:focus-visible){outline:2px solid var(--cocso-color-focus-ring);outline-offset:2px}.file-uploader-module_zone__-lnp-.file-uploader-module_compact__s-Ynq{flex-direction:row;gap:var(--cocso-spacing-4);padding-block:var(--cocso-spacing-5);padding-inline:var(--cocso-spacing-7);text-align:start}.file-uploader-module_zone__-lnp-[data-drag-active=true]{background-color:var(--cocso-color-interactive-primary-subtle);border-color:var(--cocso-color-interactive-primary);border-style:solid;color:var(--cocso-color-text-primary)}.file-uploader-module_zone__-lnp-[data-disabled=true]{border-color:var(--cocso-color-border-secondary);cursor:not-allowed}.file-uploader-module_input__wft8r{border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}.file-uploader-module_text__hTQbR{text-wrap:balance;word-break:keep-all}.file-uploader-module_zone__-lnp-:not(.file-uploader-module_compact__s-Ynq) .file-uploader-module_prompt__bvvKg{display:block}.file-uploader-module_icon__7Pt-y{flex-shrink:0}.file-uploader-module_list__neAsl{display:flex;flex-direction:column;gap:var(--cocso-spacing-5);list-style:none;margin:0;padding:0}.file-uploader-module_item__p8Jns{display:flex}@media (prefers-reduced-motion:reduce){.file-uploader-module_zone__-lnp-{transition:none}}}";
6
+ var styles = {"uploader":"file-uploader-module_uploader__H6Mi3","zone":"file-uploader-module_zone__-lnp-","input":"file-uploader-module_input__wft8r","compact":"file-uploader-module_compact__s-Ynq","text":"file-uploader-module_text__hTQbR","prompt":"file-uploader-module_prompt__bvvKg","icon":"file-uploader-module_icon__7Pt-y","list":"file-uploader-module_list__neAsl","item":"file-uploader-module_item__p8Jns"};
7
+ styleInject_es(css_248z);
8
+
9
+ module.exports = styles;
@@ -0,0 +1,31 @@
1
+ import { ComponentProps } from 'react';
2
+ import { InputSize } from '../input/input.js';
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,53 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var input = require('../../ecosystem/codegen/generated/input.js');
5
+ require('../../ecosystem/codegen/generated/input.css.js');
6
+ var react = require('react');
7
+ var cn = require('../../cn.js');
8
+ var formField_module = require('./form-field.module.css.js');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ const FormFieldContext = /*#__PURE__*/react.createContext(null);
12
+
13
+ /**
14
+ * The ids and size of the enclosing `FormField`.
15
+ *
16
+ * `FormField.Input` and `FormField.InputTrigger` read this themselves. Any
17
+ * other control placed in the row — a `Select`, a picker trigger, a search
18
+ * box — should take `id={controlId}` so the row's label names it. Returns
19
+ * `null` outside a `FormField`.
20
+ */
21
+ const useFormField = () => react.useContext(FormFieldContext);
22
+ /**
23
+ * The client half of the `FormField` root: it owns the ids, so it is the part
24
+ * that needs hooks. Kept apart from `form-field.tsx` so the compound object
25
+ * itself stays importable from a React Server Component.
26
+ */
27
+ function FormFieldScope({
28
+ className,
29
+ size = "small",
30
+ children,
31
+ ...props
32
+ }) {
33
+ const controlId = react.useId();
34
+ const labelId = react.useId();
35
+ return /*#__PURE__*/jsxRuntime.jsx(FormFieldContext.Provider, {
36
+ value: {
37
+ controlId,
38
+ labelId,
39
+ size
40
+ },
41
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
42
+ className: cn.cn(input.input({
43
+ size
44
+ }), formField_module.root, className),
45
+ "data-cocso-component": "form-field",
46
+ ...props,
47
+ children: children
48
+ })
49
+ });
50
+ }
51
+
52
+ exports.FormFieldScope = FormFieldScope;
53
+ exports.useFormField = 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.js';
4
+ import { InputTriggerProps } from '../input-trigger/input-trigger.js';
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,109 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var react = require('react');
5
+ var cn = require('../../cn.js');
6
+ var formField_module = require('./form-field.module.css.js');
7
+ var formFieldContext = require('./form-field-context.js');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var inputTrigger = require('../input-trigger/input-trigger.js');
10
+ var input = require('../input/input.js');
11
+
12
+ function FormFieldLabel({
13
+ className,
14
+ style: _style,
15
+ required,
16
+ width,
17
+ htmlFor,
18
+ id,
19
+ children,
20
+ ...props
21
+ }) {
22
+ const field = formFieldContext.useFormField();
23
+ const style = {
24
+ ..._style,
25
+ ...(width === undefined ? {} : {
26
+ "--cocso-form-field-label-width": typeof width === "number" ? `${width}px` : width
27
+ })
28
+ };
29
+ return /*#__PURE__*/jsxRuntime.jsxs("label", {
30
+ className: cn.cn(formField_module.label, className),
31
+ "data-cocso-component": "form-field-label",
32
+ htmlFor: htmlFor ?? field?.controlId,
33
+ id: id ?? field?.labelId,
34
+ style: style,
35
+ ...props,
36
+ children: [children, required && /*#__PURE__*/jsxRuntime.jsx("span", {
37
+ "aria-hidden": "true",
38
+ className: formField_module.required,
39
+ children: "*"
40
+ })]
41
+ });
42
+ }
43
+ /**
44
+ * The row's text input: an `Input` at the row's size, stretched to the space
45
+ * beside the label, carrying the id the label points at.
46
+ *
47
+ * `type="password"` turns the reveal button on by default. `Input` keeps it
48
+ * opt-in so an existing field does not change on upgrade; a `FormField` row
49
+ * has no such history, and a password typed blind is only checked by
50
+ * submitting it. Pass `passwordToggle={false}` to opt out.
51
+ *
52
+ * Every `FormField.Input` in a row defaults to the row's one id. A row holding
53
+ * two inputs (a range, say) must give the second its own `id` — and an
54
+ * `aria-label` — or the page carries a duplicate id.
55
+ */
56
+ function FormFieldInput({
57
+ id,
58
+ size,
59
+ type,
60
+ passwordToggle,
61
+ stretch = true,
62
+ ...props
63
+ }) {
64
+ const field = formFieldContext.useFormField();
65
+ return /*#__PURE__*/jsxRuntime.jsx(input.Input, {
66
+ id: id ?? field?.controlId,
67
+ passwordToggle: passwordToggle ?? type === "password",
68
+ size: size ?? field?.size ?? "small",
69
+ stretch: stretch,
70
+ type: type,
71
+ ...props
72
+ });
73
+ }
74
+ /**
75
+ * An `InputTrigger` at the row's size — the button a picker or a popover
76
+ * opens from, looking like the inputs around it.
77
+ *
78
+ * Named by the row's label and its own text together (`aria-labelledby`
79
+ * pointing at both). A `<label for>` would replace the button's name and the
80
+ * chosen value would never be announced, so the trigger deliberately carries
81
+ * an id of its own rather than the one the label points at — with both, the
82
+ * self-reference resolves to the label a second time instead of the value.
83
+ */
84
+ function FormFieldInputTrigger({
85
+ id,
86
+ size,
87
+ value,
88
+ children,
89
+ stretch = true,
90
+ "aria-labelledby": ariaLabelledBy,
91
+ ...props
92
+ }) {
93
+ const field = formFieldContext.useFormField();
94
+ const generatedId = react.useId();
95
+ const triggerId = id ?? generatedId;
96
+ const labelledBy = ariaLabelledBy ?? (field ? `${field.labelId} ${triggerId}` : undefined);
97
+ return /*#__PURE__*/jsxRuntime.jsx(inputTrigger.InputTrigger, {
98
+ "aria-labelledby": labelledBy,
99
+ id: triggerId,
100
+ size: size ?? field?.size ?? "small",
101
+ stretch: stretch,
102
+ ...props,
103
+ children: children ?? value
104
+ });
105
+ }
106
+
107
+ exports.FormFieldInput = FormFieldInput;
108
+ exports.FormFieldInputTrigger = FormFieldInputTrigger;
109
+ exports.FormFieldLabel = 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.js';
4
+ export { FormFieldContextValue, useFormField } from './form-field-context.js';
5
+ import { FormFieldLabel, FormFieldInput, FormFieldInputTrigger } from './form-field-parts.js';
6
+ export { FormFieldInputProps, FormFieldInputTriggerProps, FormFieldLabelProps } from './form-field-parts.js';
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,61 @@
1
+ 'use strict';
2
+
3
+ var cn = require('../../cn.js');
4
+ var formField_module = require('./form-field.module.css.js');
5
+ var formFieldContext = require('./form-field-context.js');
6
+ var formFieldParts = require('./form-field-parts.js');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function FormFieldRoot(props) {
10
+ return /*#__PURE__*/jsxRuntime.jsx(formFieldContext.FormFieldScope, {
11
+ ...props
12
+ });
13
+ }
14
+
15
+ /**
16
+ * A value that cannot be edited, shown where the input would be — same
17
+ * height and same inset as the inputs around it, so read-only and editable
18
+ * rows start their text on one line.
19
+ */
20
+ function FormFieldValue({
21
+ className,
22
+ ...props
23
+ }) {
24
+ return /*#__PURE__*/jsxRuntime.jsx("span", {
25
+ className: cn.cn(formField_module.value, className),
26
+ "data-cocso-component": "form-field-value",
27
+ ...props
28
+ });
29
+ }
30
+
31
+ /**
32
+ * A label beside its control, on one line — the layout of an admin form.
33
+ *
34
+ * `Field` stacks a label over its control with a description and an error
35
+ * under it; this lays them side by side with a fixed label column, so every
36
+ * row of a long form starts its control at the same place. Below 768px the
37
+ * label moves above the control.
38
+ *
39
+ * The label is tied to the control: the root makes an id, `FormField.Label`
40
+ * points at it and `FormField.Input` / `FormField.InputTrigger` carry it. Any
41
+ * other control takes it from `useFormField()`.
42
+ *
43
+ * The compound object lives in a module without `"use client"` so a Server
44
+ * Component can reach `FormField.Label`; the parts that need hooks are
45
+ * client modules of their own.
46
+ *
47
+ * @example
48
+ * <FormField>
49
+ * <FormField.Label required width={120}>Email</FormField.Label>
50
+ * <FormField.Input required type="email" />
51
+ * </FormField>
52
+ */
53
+ const FormField = Object.assign(FormFieldRoot, {
54
+ Label: formFieldParts.FormFieldLabel,
55
+ Input: formFieldParts.FormFieldInput,
56
+ InputTrigger: formFieldParts.FormFieldInputTrigger,
57
+ Value: FormFieldValue
58
+ });
59
+
60
+ exports.useFormField = formFieldContext.useFormField;
61
+ exports.FormField = FormField;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var styleInject_es = require('../../node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js');
4
+
5
+ var css_248z = "@layer components{.form-field-module_root__uDXGR{align-items:flex-start;display:flex;gap:var(--cocso-spacing-5);width:100%}.form-field-module_label__PaASx{align-items:center;color:var(--cocso-color-text-secondary);display:flex;flex-shrink:0;font-size:var(--cocso-text-sm);font-weight:var(--cocso-font-weight-medium);gap:var(--cocso-spacing-2);inline-size:var(--cocso-form-field-label-width,128px);min-block-size:var(--cocso-input-height);overflow-wrap:anywhere;word-break:keep-all}.form-field-module_required__WxLi1{color:var(--cocso-color-feedback-danger-text)}.form-field-module_root__uDXGR>:not(.form-field-module_label__PaASx){min-inline-size:0}.form-field-module_value__uaMQ5{align-items:center;color:var(--cocso-color-text-primary);display:flex;font-size:var(--cocso-input-font-size);min-block-size:var(--cocso-input-height);padding-inline:var(--cocso-input-padding-x)}@media (max-width:767px){.form-field-module_root__uDXGR{align-items:stretch;flex-direction:column;gap:var(--cocso-spacing-3)}.form-field-module_label__PaASx{inline-size:auto;min-block-size:0}}}";
6
+ var styles = {"root":"form-field-module_root__uDXGR","label":"form-field-module_label__PaASx","required":"form-field-module_required__WxLi1","value":"form-field-module_value__uaMQ5"};
7
+ styleInject_es(css_248z);
8
+
9
+ module.exports = styles;
@@ -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.js';
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 };