@crispy-seed/data-table 0.1.0 → 0.1.2

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 (51) hide show
  1. package/README.md +25 -13
  2. package/dist/index.cjs +4563 -2
  3. package/dist/index.d.ts +8 -1
  4. package/dist/index.js +4547 -1
  5. package/package.json +1 -2
  6. package/dist/DataTable-12s-8LMBtS2u.cjs +0 -1532
  7. package/dist/DataTable-12s-Bd20OuMs.js +0 -1482
  8. package/dist/DataTable-12s-Zml1x9Kr-12s-CTRzgvMT.cjs +0 -161
  9. package/dist/DataTable-12s-Zml1x9Kr-12s-Coi-3lUa.js +0 -153
  10. package/dist/Menu-12s-Db_zr1AP.cjs +0 -104
  11. package/dist/Menu-12s-Di5JADW4.js +0 -78
  12. package/dist/Select-12s-1Uh7XbkG.js +0 -219
  13. package/dist/Select-12s-D8DdKT-U.cjs +0 -250
  14. package/dist/body-cells-12s-BnOVUTKN.js +0 -453
  15. package/dist/body-cells-12s-BoOTcg-l.cjs +0 -462
  16. package/dist/column-calc-12s-C6IPSOaF.js +0 -129
  17. package/dist/column-calc-12s-CKuSpe-l.cjs +0 -149
  18. package/dist/column-layout-12s-CTu5yT_D.cjs +0 -120
  19. package/dist/column-layout-12s-s7wnxkMN.js +0 -99
  20. package/dist/column-menu-12s-BPE9N1gs.cjs +0 -427
  21. package/dist/column-menu-12s-mRBk-4oa.js +0 -407
  22. package/dist/editors-12s-BO9Mp034.js +0 -525
  23. package/dist/editors-12s-DO8TZkYV.cjs +0 -555
  24. package/dist/resize-12s-jQY-PX67.cjs +0 -58
  25. package/dist/resize-12s-nsMvrmLt.js +0 -58
  26. package/dist/states-12s-CLO_uVue.cjs +0 -125
  27. package/dist/states-12s-DEFSxJCO.js +0 -122
  28. package/dist/toolbar-12s-AVU-sbDW.js +0 -69
  29. package/dist/toolbar-12s-CaLgJrDo.cjs +0 -71
  30. package/dist/useDataTable-12s-BHiDUubw-12s-CBeCwTe7.js +0 -61
  31. package/dist/useDataTable-12s-BHiDUubw-12s-Dgvt7XDk.cjs +0 -61
  32. package/dist/useDataTableColumnCalc-12s-DTQQTtEJ-12s-CvD14JYo.cjs +0 -207
  33. package/dist/useDataTableColumnCalc-12s-DTQQTtEJ-12s-DsEse3uq.js +0 -183
  34. package/dist/useDataTableColumns-12s-Cn2ZAzFL-12s-CD6goR59.js +0 -289
  35. package/dist/useDataTableColumns-12s-Cn2ZAzFL-12s-CUk_CpYT.cjs +0 -292
  36. package/dist/useDataTableEdit-12s-9Wb_UCrN-12s-BoOHq3GB.js +0 -98
  37. package/dist/useDataTableEdit-12s-9Wb_UCrN-12s-De6YHBba.cjs +0 -98
  38. package/dist/useDataTableFilter-12s-ZzbmWMin-12s-CWyBeFna.js +0 -74
  39. package/dist/useDataTableFilter-12s-ZzbmWMin-12s-lpjzZY3_.cjs +0 -74
  40. package/dist/useDataTableInfiniteScroll-12s-8ZG31URd-12s-BexjP6iO.js +0 -104
  41. package/dist/useDataTableInfiniteScroll-12s-8ZG31URd-12s-Bt8gojr9.cjs +0 -104
  42. package/dist/useDataTableRow-12s-CPYaDa1p-12s-BmUSAnPe.js +0 -30
  43. package/dist/useDataTableRow-12s-CPYaDa1p-12s-D-DRjwAe.cjs +0 -30
  44. package/dist/useDataTableScroll-12s-BKDCr0en-12s-C7f2vHeG.js +0 -61
  45. package/dist/useDataTableScroll-12s-BKDCr0en-12s-CUvUYMtt.cjs +0 -61
  46. package/dist/useDataTableSearch-12s-Ck3iWcpX-12s-B-65V6gH.js +0 -37
  47. package/dist/useDataTableSearch-12s-Ck3iWcpX-12s-DhVfN2Hq.cjs +0 -37
  48. package/dist/useDataTableSelection-12s-BIDtiRQq-12s-IS__VAnU.cjs +0 -71
  49. package/dist/useDataTableSelection-12s-BIDtiRQq-12s-O6M_BhrH.js +0 -71
  50. package/dist/useDataTableSort-12s-DvJYtmeS-12s-C5VGnsq4.cjs +0 -78
  51. package/dist/useDataTableSort-12s-DvJYtmeS-12s-DABSNt6U.js +0 -78
@@ -1,525 +0,0 @@
1
- 'use client';
2
- function __insertCSS(code) {
3
- if (!code || typeof document == 'undefined') return
4
- let head = document.head || document.getElementsByTagName('head')[0]
5
- let style = document.createElement('style')
6
- style.type = 'text/css'
7
- head.appendChild(style)
8
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
9
- }
10
-
11
- import { S as SelectRoot, a as SelectTrigger, b as SelectValue, c as SelectPlaceholder, d as SelectSuffixIcon, e as SelectPositioner, f as SelectContent, g as SelectScrollArea, h as SelectItem, i as SelectItemBody, j as SelectItemLabel, k as SelectItemIndicator } from './Select-12s-1Uh7XbkG.js';
12
- import * as React from 'react';
13
- import React__default, { forwardRef, useRef, useCallback } from 'react';
14
- import { jsx, jsxs } from 'react/jsx-runtime';
15
- import { w as withScaleFeedback, c as createSlotRecipeContext, a as createWithStateProps, s as splitMultipleVariantsProps, b as clsx, I as InternalIcon, t as composeRefs, C as CheckboxRoot, e as CheckboxControl, f as CheckboxIndicator, g as CheckboxHiddenInput, u as IconChevronDownSmallLine_default, v as IconCheckmarkFatFill_default, x as IconPersonCircleLine_default } from './DataTable-12s-Bd20OuMs.js';
16
- import { R as RATING_FILLED, a as RATING_EMPTY, b as RATING_STAR_D, c as CHECKBOX_CELL_CHECKED_ICON, A as AvatarRoot, d as AvatarImage, e as AvatarFallback, t as toDateTimeInputValue, f as toDateInputValue } from './body-cells-12s-BnOVUTKN.js';
17
- import { Switch, useSwitchContext } from '@seed-design/react-switch';
18
- import { switchStyle } from '@seed-design/css/recipes/switch';
19
- import { switchmark } from '@seed-design/css/recipes/switchmark';
20
- import { Primitive } from '@seed-design/react-primitive';
21
- import { TextField, useTextFieldContext } from '@seed-design/react-text-field';
22
- import { useFieldContext } from '@seed-design/react-field';
23
- import { textInput } from '@seed-design/css/recipes/text-input';
24
- import { mergeProps } from '@seed-design/dom-utils';
25
-
26
- const { withContext: withContext$1, ClassNamesProvider } = createSlotRecipeContext(switchStyle);
27
- const { withContext: withControlContext, PropsProvider: ControlPropsProvider, withProvider: withControlProvider } = createSlotRecipeContext(switchmark);
28
- const withStateProps$1 = createWithStateProps([
29
- useSwitchContext
30
- ]);
31
- const SwitchRoot = /*#__PURE__*/ React__default.forwardRef(({ className, ...props }, ref)=>{
32
- const [{ switch: switchVariantProps, switchmark: switchmarkVariantProps }, otherProps] = splitMultipleVariantsProps(props, {
33
- switchmark,
34
- switch: switchStyle
35
- });
36
- const classNames = switchStyle(switchVariantProps);
37
- return /*#__PURE__*/ jsx(ControlPropsProvider, {
38
- value: switchmarkVariantProps,
39
- children: /*#__PURE__*/ jsx(ClassNamesProvider, {
40
- value: classNames,
41
- children: /*#__PURE__*/ jsx(Switch.Root, {
42
- ref: ref,
43
- className: clsx(classNames.root, className),
44
- ...otherProps
45
- })
46
- })
47
- });
48
- });
49
- SwitchRoot.displayName = "SwitchRoot";
50
- const SwitchControl = withScaleFeedback(withControlProvider(Switch.Control, "root"));
51
- const SwitchThumb = withControlContext(Switch.Thumb, "thumb");
52
- withContext$1(withStateProps$1(Primitive.span), "label");
53
- const SwitchHiddenInput = Switch.HiddenInput;
54
-
55
- // src/use-layout-effect.tsx
56
- var useLayoutEffect2 = globalThis?.document ? React.useLayoutEffect : ()=>{};
57
-
58
- const { withProvider, withContext, useClassNames } = createSlotRecipeContext(textInput);
59
- const withFieldStateProps = createWithStateProps([
60
- {
61
- useContext: useFieldContext,
62
- strict: false
63
- }
64
- ]);
65
- const withStateProps = createWithStateProps([
66
- useTextFieldContext,
67
- {
68
- useContext: useFieldContext,
69
- strict: false
70
- }
71
- ]);
72
- const TextFieldRoot = withProvider(withFieldStateProps(TextField.Root), "root");
73
- const TextFieldPrefixIcon = withContext(withStateProps(InternalIcon), "prefixIcon");
74
- withContext(withStateProps(Primitive.span), "prefixText");
75
- withContext(withStateProps(InternalIcon), "suffixIcon");
76
- withContext(withStateProps(Primitive.span), "suffixText");
77
- const TextFieldInput = /*#__PURE__*/ forwardRef(({ className, ...otherProps }, ref)=>{
78
- const classNames = useClassNames();
79
- const textFieldContext = useTextFieldContext();
80
- const fieldContext = useFieldContext({
81
- strict: false
82
- });
83
- const mergedProps = mergeProps(fieldContext ? fieldContext.stateProps : {}, fieldContext ? fieldContext.inputAriaAttributes : {}, textFieldContext.inputProps, fieldContext ? fieldContext.inputProps : {}, otherProps);
84
- if (// if not in field, then must have aria-label or aria-labelledby
85
- !fieldContext && !otherProps["aria-label"] && !otherProps["aria-labelledby"]) {
86
- console.warn("TextFieldInput: Please provide `aria-label` or `aria-labelledby` for accessibility, or put `TextFieldInput` inside a `Field` where a `FieldLabel` is provided.");
87
- }
88
- return /*#__PURE__*/ jsx(TextField.Input, {
89
- ref: ref,
90
- ...mergedProps,
91
- className: clsx(classNames.value, className)
92
- });
93
- });
94
- TextFieldInput.displayName = "TextFieldInput";
95
- const TextFieldTextarea = /*#__PURE__*/ forwardRef(({ className, autoresize = true, ...otherProps }, ref)=>{
96
- const classNames = useClassNames();
97
- const textFieldContext = useTextFieldContext();
98
- const fieldContext = useFieldContext({
99
- strict: false
100
- });
101
- const mergedProps = mergeProps(fieldContext ? fieldContext.stateProps : {}, fieldContext ? fieldContext.inputAriaAttributes : {}, textFieldContext.inputProps, fieldContext ? fieldContext.inputProps : {}, otherProps);
102
- if (// if not in field, then must have aria-label or aria-labelledby
103
- !fieldContext && !otherProps["aria-label"] && !otherProps["aria-labelledby"]) {
104
- console.warn("TextFieldTextarea: Please provide `aria-label` or `aria-labelledby` for accessibility, or put `TextFieldTextarea` inside a `Field` where a `FieldLabel` is provided.");
105
- }
106
- // referenced from React Spectrum
107
- const inputRef = useRef(null);
108
- // biome-ignore lint/correctness/useExhaustiveDependencies: intended
109
- const onHeightChange = useCallback(()=>{
110
- if (!inputRef.current) return;
111
- if (otherProps.style?.height) return;
112
- if (!autoresize) return;
113
- // Quiet textareas always grow based on their text content.
114
- // Standard textareas also grow by default, unless an explicit height is set.
115
- const input = inputRef.current;
116
- const prevAlignment = input.style.alignSelf;
117
- const prevOverflow = input.style.overflow;
118
- // Firefox scroll position is lost when overflow: 'hidden' is applied so we skip applying it.
119
- // The measure/applied height is also incorrect/reset if we turn on and off
120
- // overflow: hidden in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1787062
121
- const isFirefox = "MozAppearance" in input.style;
122
- if (!isFirefox) {
123
- input.style.overflow = "hidden";
124
- }
125
- input.style.alignSelf = "start";
126
- input.style.height = "auto";
127
- // offsetHeight - clientHeight accounts for the border/padding.
128
- input.style.height = `${input.scrollHeight + (input.offsetHeight - input.clientHeight)}px`;
129
- input.style.overflow = prevOverflow;
130
- input.style.alignSelf = prevAlignment;
131
- }, [
132
- inputRef,
133
- otherProps.style?.height,
134
- autoresize
135
- ]);
136
- useLayoutEffect2(()=>{
137
- if (inputRef.current) {
138
- onHeightChange();
139
- }
140
- }, [
141
- onHeightChange,
142
- textFieldContext.value,
143
- inputRef
144
- ]);
145
- return /*#__PURE__*/ jsx(TextField.Textarea, {
146
- ref: composeRefs(inputRef, ref),
147
- ...mergedProps,
148
- className: clsx(classNames.value, className)
149
- });
150
- });
151
- TextFieldTextarea.displayName = "TextFieldTextarea";
152
-
153
- /** The raw value a live editor reads, distinct from `DataTableColumn.value` (the
154
- * accessor sort/search/filter/export share): `editValue` returns whatever TYPE the
155
- * editor itself expects -- a real `boolean` for `editor: "switch"`/`type:
156
- * "checkbox"`, a `number` for `type: "rating"`, the option's own string for `select`/
157
- * `reference`/`actor` -- where `value`/`render` may format that same field for
158
- * display. Falls back to the table's own accessor when the column supplies none. */ function resolveEditValue(column, row, fallback) {
159
- return column.editValue ? column.editValue(row) : fallback;
160
- }
161
- function EditPendingIndicator() {
162
- return /*#__PURE__*/ jsxs("svg", {
163
- className: "seed-data-table-edit-pending",
164
- width: 14,
165
- height: 14,
166
- viewBox: "0 0 16 16",
167
- fill: "none",
168
- role: "presentation",
169
- "aria-hidden": "true",
170
- children: [
171
- /*#__PURE__*/ jsx("circle", {
172
- cx: 8,
173
- cy: 8,
174
- r: 6.5,
175
- stroke: "currentColor",
176
- strokeOpacity: 0.25,
177
- strokeWidth: 2
178
- }),
179
- /*#__PURE__*/ jsx("path", {
180
- d: "M14.5 8a6.5 6.5 0 0 0-6.5-6.5",
181
- stroke: "currentColor",
182
- strokeWidth: 2,
183
- strokeLinecap: "round"
184
- })
185
- ]
186
- });
187
- }
188
- function EditError({ message }) {
189
- return /*#__PURE__*/ jsx("span", {
190
- className: "seed-data-table-edit-error",
191
- children: message
192
- });
193
- }
194
- ////////////////////////////////////////////////////////////////////////////////////
195
- // -- plain editable: text/number (seed TextField) and date/datetime (a native input,
196
- // styled the same way, per `cellType`) -- both double-click gated, Enter/blur
197
- // commits, Escape cancels. -------------------------------------------------------
198
- function TextEditor({ column, value, pending, onCommit, onCancel }) {
199
- const [draft, setDraft] = React.useState(()=>value == null ? "" : String(value));
200
- return(// `size="medium"` (seed's smallest fixed `TextField` size, 40px min-height,
201
- // `text-input.ts`'s own token) -- the default `size="large"` overflowed a 36px
202
- // table row (same class of fix as `toolbar.tsx`'s `SearchBox`, which made the
203
- // same call for its own 32px-ish search box).
204
- /*#__PURE__*/ jsx(TextFieldRoot, {
205
- size: "medium",
206
- style: {
207
- width: "100%"
208
- },
209
- onClick: (event)=>event.stopPropagation(),
210
- onKeyDown: (event)=>event.stopPropagation(),
211
- children: /*#__PURE__*/ jsx(TextFieldInput, {
212
- autoFocus: true,
213
- type: column.cellType === "number" ? "number" : "text",
214
- "aria-label": `Edit ${column.key}`,
215
- value: draft,
216
- disabled: pending,
217
- onChange: (event)=>setDraft(event.target.value),
218
- onBlur: ()=>onCommit(draft),
219
- onKeyDown: (event)=>{
220
- if (event.key === "Enter") onCommit(draft);
221
- else if (event.key === "Escape") onCancel();
222
- }
223
- })
224
- }));
225
- }
226
- function DateEditor({ column, value, pending, onCommit, onCancel }) {
227
- const isDateTime = column.cellType === "datetime";
228
- const [draft, setDraft] = React.useState(()=>isDateTime ? toDateTimeInputValue(value) : toDateInputValue(value));
229
- return(// See `TextEditor`'s own comment above -- same `size="medium"` fix.
230
- /*#__PURE__*/ jsx(TextFieldRoot, {
231
- size: "medium",
232
- style: {
233
- width: "100%"
234
- },
235
- onClick: (event)=>event.stopPropagation(),
236
- onKeyDown: (event)=>event.stopPropagation(),
237
- children: /*#__PURE__*/ jsx(TextFieldInput, {
238
- autoFocus: true,
239
- type: isDateTime ? "datetime-local" : "date",
240
- "aria-label": `Edit ${column.key}`,
241
- value: draft,
242
- disabled: pending,
243
- onChange: (event)=>setDraft(event.target.value),
244
- onBlur: ()=>onCommit(draft),
245
- onKeyDown: (event)=>{
246
- if (event.key === "Enter") onCommit(draft);
247
- else if (event.key === "Escape") onCancel();
248
- }
249
- })
250
- }));
251
- }
252
- ////////////////////////////////////////////////////////////////////////////////////
253
- // -- editor: "select" -- double-click opens seed's own Select, auto-opened (seed's
254
- // `SelectRoot` takes `defaultOpen` directly -- unlike crisp's closed-API `Select`,
255
- // which needs a synthetic click on its own trigger to start open). -------------
256
- function SelectEditor({ column, value, pending, onCommit, onCancel }) {
257
- const options = column.options ?? [];
258
- const current = value == null ? "" : String(value);
259
- return /*#__PURE__*/ jsxs(SelectRoot, {
260
- // Controlled open, per docs/examples/react/select/controlled-open.tsx --
261
- // this editor is only ever mounted while the cell IS editing, so it always
262
- // wants to start (and stay) open; `onOpenChange(false)` is what tells us
263
- // the popover wants to close for ANY reason (Escape, an outside click, OR
264
- // the internal auto-close a single-select commit already triggers), so
265
- // `onCancel` alone now covers the Escape gap the old raw `document`
266
- // listener existed for, without a second, independent listener.
267
- open: true,
268
- onOpenChange: (next)=>{
269
- if (!next) onCancel();
270
- },
271
- disabled: pending,
272
- value: current ? [
273
- current
274
- ] : [],
275
- onValueChange: (next)=>onCommit(next[0] ?? ""),
276
- children: [
277
- /*#__PURE__*/ jsxs(SelectTrigger, {
278
- "aria-label": `Edit ${column.key}`,
279
- children: [
280
- /*#__PURE__*/ jsx(SelectValue, {}),
281
- /*#__PURE__*/ jsx(SelectPlaceholder, {
282
- children: "Select…"
283
- }),
284
- /*#__PURE__*/ jsx(SelectSuffixIcon, {
285
- svg: /*#__PURE__*/ jsx(IconChevronDownSmallLine_default, {})
286
- })
287
- ]
288
- }),
289
- /*#__PURE__*/ jsx(SelectPositioner, {
290
- children: /*#__PURE__*/ jsx(SelectContent, {
291
- children: /*#__PURE__*/ jsx(SelectScrollArea, {
292
- children: options.map((option)=>/*#__PURE__*/ jsxs(SelectItem, {
293
- value: option.value,
294
- label: option.label,
295
- children: [
296
- /*#__PURE__*/ jsx(SelectItemBody, {
297
- children: /*#__PURE__*/ jsx(SelectItemLabel, {})
298
- }),
299
- /*#__PURE__*/ jsx(SelectItemIndicator, {
300
- selected: /*#__PURE__*/ jsx(IconCheckmarkFatFill_default, {})
301
- })
302
- ]
303
- }, option.value))
304
- })
305
- })
306
- })
307
- ]
308
- });
309
- }
310
- ////////////////////////////////////////////////////////////////////////////////////
311
- // -- editor: "reference" / "actor" -- same picker, search-enabled, each option
312
- // carrying a small avatar (a photo for a real one, a generic person glyph for
313
- // none) -- `actor` is `reference` over people specifically (crisp's own #449/
314
- // #432 `ReferenceCell` shape), so the two share one component; only the search
315
- // placeholder differs. Seed's `Select` has no built-in search combobox (unlike
316
- // crisp's own `Select`), so this filters `refOptions` itself against a small
317
- // `TextField` rendered as the content's own first row. --------------------------
318
- function ReferenceEditor({ column, value, pending, onCommit, onCancel }) {
319
- const [query, setQuery] = React.useState("");
320
- const options = column.refOptions ?? [];
321
- const filtered = query.trim() ? options.filter((option)=>option.label.toLowerCase().includes(query.trim().toLowerCase())) : options;
322
- const current = value == null ? "" : String(value);
323
- const isActor = column.editor === "actor";
324
- return /*#__PURE__*/ jsxs(SelectRoot, {
325
- // See `SelectEditor`'s own comment above -- same controlled-open wiring.
326
- open: true,
327
- onOpenChange: (next)=>{
328
- if (!next) onCancel();
329
- },
330
- disabled: pending,
331
- value: current ? [
332
- current
333
- ] : [],
334
- onValueChange: (next)=>onCommit(next[0] ?? ""),
335
- children: [
336
- /*#__PURE__*/ jsxs(SelectTrigger, {
337
- "aria-label": `Edit ${column.key}`,
338
- children: [
339
- /*#__PURE__*/ jsx(SelectValue, {}),
340
- /*#__PURE__*/ jsx(SelectPlaceholder, {
341
- children: isActor ? "Assign…" : "Select…"
342
- }),
343
- /*#__PURE__*/ jsx(SelectSuffixIcon, {
344
- svg: /*#__PURE__*/ jsx(IconChevronDownSmallLine_default, {})
345
- })
346
- ]
347
- }),
348
- /*#__PURE__*/ jsx(SelectPositioner, {
349
- children: /*#__PURE__*/ jsxs(SelectContent, {
350
- children: [
351
- /*#__PURE__*/ jsx(TextFieldRoot, {
352
- size: "medium",
353
- style: {
354
- margin: 4
355
- },
356
- onKeyDown: (event)=>{
357
- // The listbox's own typeahead/arrow handling lives on THIS field's
358
- // sibling items, not on the field itself -- stop everything except
359
- // Escape from also driving the listbox's own keyboard nav. Escape
360
- // itself needs no special-casing to "reach" anything any more: it's
361
- // SelectContent's own `DismissibleLayer` (Select.tsx) that closes the
362
- // listbox, and that dismissal is a document-level listener outside
363
- // this React subtree entirely -- a synthetic `stopPropagation` here
364
- // was never able to block it either way, so the controlled `open`
365
- // above (via `onOpenChange`) is what actually ends this cell's edit.
366
- if (event.key !== "Escape") event.stopPropagation();
367
- },
368
- children: /*#__PURE__*/ jsx(TextFieldInput, {
369
- autoFocus: true,
370
- "aria-label": isActor ? "Search people" : `Search ${column.key}`,
371
- placeholder: isActor ? "Search people…" : "Search…",
372
- value: query,
373
- onChange: (event)=>setQuery(event.target.value)
374
- })
375
- }),
376
- /*#__PURE__*/ jsxs(SelectScrollArea, {
377
- children: [
378
- filtered.length === 0 && /*#__PURE__*/ jsx("div", {
379
- style: {
380
- padding: "6px 12px",
381
- opacity: 0.63,
382
- fontSize: 13
383
- },
384
- children: isActor ? "No users" : "No results"
385
- }),
386
- filtered.map((option)=>/*#__PURE__*/ jsxs(SelectItem, {
387
- value: option.value,
388
- label: option.label,
389
- children: [
390
- /*#__PURE__*/ jsxs(SelectItemBody, {
391
- children: [
392
- /*#__PURE__*/ jsx(ReferenceAvatar, {
393
- avatar: option.avatar
394
- }),
395
- /*#__PURE__*/ jsx(SelectItemLabel, {})
396
- ]
397
- }),
398
- /*#__PURE__*/ jsx(SelectItemIndicator, {
399
- selected: /*#__PURE__*/ jsx(IconCheckmarkFatFill_default, {})
400
- })
401
- ]
402
- }, option.value))
403
- ]
404
- })
405
- ]
406
- })
407
- })
408
- ]
409
- });
410
- }
411
- function ReferenceAvatar({ avatar }) {
412
- return /*#__PURE__*/ jsxs(AvatarRoot, {
413
- size: "20",
414
- children: [
415
- avatar && /*#__PURE__*/ jsx(AvatarImage, {
416
- src: avatar,
417
- alt: ""
418
- }),
419
- /*#__PURE__*/ jsx(AvatarFallback, {
420
- children: /*#__PURE__*/ jsx(IconPersonCircleLine_default, {})
421
- })
422
- ]
423
- });
424
- }
425
- ////////////////////////////////////////////////////////////////////////////////////
426
- // -- always-live editors: no double-click gate, no separate rest/edit state --
427
- // interacting with the widget IS the commit gesture (crisp's own #453/#760/#761).
428
- function SwitchEditor({ column, value, pending, onCommit }) {
429
- const checked = value === true || value === "true";
430
- return /*#__PURE__*/ jsxs("span", {
431
- className: "seed-data-table-edit-picker",
432
- children: [
433
- /*#__PURE__*/ jsxs(SwitchRoot, {
434
- size: "16",
435
- checked: checked,
436
- disabled: pending,
437
- onCheckedChange: (next)=>onCommit(String(next)),
438
- children: [
439
- /*#__PURE__*/ jsx(SwitchControl, {
440
- children: /*#__PURE__*/ jsx(SwitchThumb, {})
441
- }),
442
- /*#__PURE__*/ jsx(SwitchHiddenInput, {
443
- "aria-label": `Edit ${column.key}`
444
- })
445
- ]
446
- }),
447
- pending && /*#__PURE__*/ jsx(EditPendingIndicator, {})
448
- ]
449
- });
450
- }
451
- function CheckboxEditor({ column, value, pending, onCommit }) {
452
- const checked = value === true || value === "true";
453
- return /*#__PURE__*/ jsxs("span", {
454
- className: "seed-data-table-edit-picker",
455
- children: [
456
- /*#__PURE__*/ jsxs(CheckboxRoot, {
457
- checked: checked,
458
- disabled: pending,
459
- onCheckedChange: (next)=>onCommit(String(next)),
460
- children: [
461
- /*#__PURE__*/ jsx(CheckboxControl, {
462
- children: /*#__PURE__*/ jsx(CheckboxIndicator, {
463
- checked: CHECKBOX_CELL_CHECKED_ICON
464
- })
465
- }),
466
- /*#__PURE__*/ jsx(CheckboxHiddenInput, {
467
- "aria-label": `Edit ${column.key}`
468
- })
469
- ]
470
- }),
471
- pending && /*#__PURE__*/ jsx(EditPendingIndicator, {})
472
- ]
473
- });
474
- }
475
- function RatingEditor({ column, value, pending, onCommit }) {
476
- const maxRating = column.maxRating ?? 5;
477
- const rating = typeof value === "number" ? value : Number(value) || 0;
478
- return /*#__PURE__*/ jsxs("span", {
479
- className: "seed-data-table-edit-picker",
480
- children: [
481
- /*#__PURE__*/ jsx("span", {
482
- role: "group",
483
- "aria-label": `Edit ${column.key}`,
484
- style: {
485
- display: "inline-flex",
486
- alignItems: "center",
487
- gap: 2
488
- },
489
- children: Array.from({
490
- length: maxRating
491
- }, (_, index)=>{
492
- const starValue = index + 1;
493
- return /*#__PURE__*/ jsx("button", {
494
- type: "button",
495
- disabled: pending,
496
- "aria-label": `Set ${starValue} out of ${maxRating}`,
497
- "aria-pressed": starValue <= rating,
498
- onClick: ()=>onCommit(String(starValue)),
499
- style: {
500
- border: "none",
501
- background: "none",
502
- padding: 0,
503
- cursor: "pointer",
504
- lineHeight: 0
505
- },
506
- children: /*#__PURE__*/ jsx("svg", {
507
- width: 16,
508
- height: 16,
509
- viewBox: "0 0 16 16",
510
- fill: "none",
511
- "aria-hidden": "true",
512
- children: /*#__PURE__*/ jsx("path", {
513
- d: RATING_STAR_D,
514
- fill: starValue <= rating ? RATING_FILLED : RATING_EMPTY
515
- })
516
- })
517
- }, index);
518
- })
519
- }),
520
- pending && /*#__PURE__*/ jsx(EditPendingIndicator, {})
521
- ]
522
- });
523
- }
524
-
525
- export { CheckboxEditor as C, DateEditor as D, EditError as E, RatingEditor as R, SwitchEditor as S, TextEditor as T, SelectEditor as a, ReferenceEditor as b, TextFieldRoot as c, TextFieldPrefixIcon as d, TextFieldInput as e, resolveEditValue as r };