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