@krak-stack/registry 0.11.7 → 0.11.9
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/CHANGELOG.md +54 -0
- package/README.md +39 -0
- package/dist/components/app-switcher/html.d.ts +2 -2
- package/dist/components/asset-input/html.d.ts +70 -0
- package/dist/components/asset-input/html.js +1549 -0
- package/dist/components/asset-input/index.d.ts +280 -0
- package/dist/components/asset-input/react.d.ts +32 -0
- package/dist/components/asset-input/react.js +2269 -0
- package/dist/components/asset-input/schema.d.ts +93 -0
- package/dist/components/asset-input/upload.d.ts +15 -0
- package/dist/components/asset-table/html.d.ts +110 -0
- package/dist/components/asset-table/html.js +4934 -0
- package/dist/components/asset-table/index.d.ts +225 -0
- package/dist/components/asset-table/react.d.ts +21 -0
- package/dist/components/asset-table/react.js +8241 -0
- package/dist/components/asset-table/schema.d.ts +73 -0
- package/dist/components/audit-log-table/html.js +47 -13
- package/dist/components/audit-log-table/react.js +36 -12
- package/dist/components/copy-button/html.d.ts +2 -2
- package/dist/components/danger-confirmation/html.d.ts +2 -2
- package/dist/components/data-table/classes.d.ts +2 -0
- package/dist/components/data-table/html.d.ts +58 -0
- package/dist/components/data-table/html.js +47 -13
- package/dist/components/data-table/index.d.ts +51 -1
- package/dist/components/data-table/react.d.ts +1 -0
- package/dist/components/data-table/react.js +36 -12
- package/dist/components/data-table/schema.d.ts +93 -3
- package/dist/components/date-input/html.d.ts +2 -2
- package/dist/components/docs/html.js +22 -4
- package/dist/components/docs/react.js +33 -2
- package/dist/components/editable-text/html.d.ts +2 -2
- package/dist/components/editing-locale-switcher/html.d.ts +2 -2
- package/dist/components/effect-form/react.js +343 -138
- package/dist/components/file-input/classes.d.ts +1 -1
- package/dist/components/file-input/file-type.d.ts +1 -0
- package/dist/components/file-input/html.d.ts +8 -1
- package/dist/components/file-input/html.js +170 -12
- package/dist/components/file-input/index.d.ts +1 -0
- package/dist/components/file-input/react.d.ts +9 -1
- package/dist/components/file-input/react.js +277 -127
- package/dist/components/file-input/schema.d.ts +1 -0
- package/dist/components/form/react.d.ts +5 -5
- package/dist/components/form/react.js +343 -138
- package/dist/components/icon-input/html.js +19 -5
- package/dist/components/icon-input/react.js +70 -13
- package/dist/components/locale-switcher/html.d.ts +2 -2
- package/dist/components/map-menu/html.d.ts +10 -4
- package/dist/components/map-menu/html.js +13 -8
- package/dist/components/map-menu/index.d.ts +5 -4
- package/dist/components/map-menu/react.d.ts +28 -17
- package/dist/components/map-menu/react.js +84 -178
- package/dist/components/map-menu/schema.d.ts +6 -0
- package/dist/components/map-menu/shared.d.ts +4 -0
- package/dist/components/permissions-input/classes.d.ts +8 -0
- package/dist/components/permissions-input/html.d.ts +41 -0
- package/dist/components/permissions-input/html.js +130 -0
- package/dist/components/permissions-input/index.d.ts +80 -0
- package/dist/components/permissions-input/react.d.ts +7 -0
- package/dist/components/permissions-input/react.js +201 -0
- package/dist/components/permissions-input/schema.d.ts +33 -0
- package/dist/components/phone-number-input/html.js +48 -14
- package/dist/components/phone-number-input/react.js +67 -10
- package/dist/components/presence-transition/index.d.ts +2 -2
- package/dist/components/search-menu/html.d.ts +2 -2
- package/dist/components/sidebar-layout/html.d.ts +3 -2
- package/dist/components/sidebar-layout/html.js +20 -2
- package/dist/components/sidebar-layout/index.d.ts +1 -0
- package/dist/components/sidebar-layout/react.js +33 -2
- package/dist/components/time-input/html.d.ts +2 -2
- package/dist/components/timezone-input/html.js +48 -14
- package/dist/components/timezone-input/react.js +67 -10
- package/dist/components/tracking-notice/html.d.ts +4 -4
- package/dist/components/tracking-notice/index.d.ts +2 -2
- package/dist/components/upload-attachment/classes.d.ts +3 -2
- package/dist/components/upload-attachment/html.d.ts +1 -1
- package/dist/components/upload-attachment/html.js +7 -5
- package/dist/components/upload-attachment/react.d.ts +3 -1
- package/dist/components/upload-attachment/react.js +25 -17
- package/dist/components/virtualized-combobox/classes.d.ts +12 -0
- package/dist/components/virtualized-combobox/html.d.ts +45 -3
- package/dist/components/virtualized-combobox/html.js +48 -14
- package/dist/components/virtualized-combobox/index.d.ts +55 -4
- package/dist/components/virtualized-combobox/react.d.ts +6 -2
- package/dist/components/virtualized-combobox/react.js +67 -10
- package/dist/components/virtualized-combobox/schema.d.ts +60 -4
- package/dist/components/webhook-delivery-table/html.js +47 -13
- package/dist/components/webhook-delivery-table/react.js +36 -12
- package/dist/lib/access/index.d.ts +61 -0
- package/dist/lib/access/index.js +92 -0
- package/dist/lib/access/table/classes.d.ts +13 -0
- package/dist/lib/access/table/html.d.ts +39 -0
- package/dist/lib/access/table/html.js +157 -0
- package/dist/lib/access/table/index.d.ts +32 -0
- package/dist/lib/access/table/react.d.ts +3 -0
- package/dist/lib/access/table/react.js +195 -0
- package/dist/lib/access/table/schema.d.ts +43 -0
- package/dist/lib/docs.integrations.server.js +23 -1
- package/dist/lib/docs.js +33 -2
- package/dist/lib/docs.server.js +29 -2
- package/dist/lib/documentation-toolkit.js +23 -1
- package/dist/lib/effect-ui-adapter/use-model.d.ts +1 -1
- package/dist/lib/effect-ui-adapter/use-model.js +19 -11
- package/dist/lib/lucide-effect.d.ts +19 -19
- package/dist/lib/lucide-effect.js +38 -38
- package/dist/services/assets/library.d.ts +221 -0
- package/dist/services/assets/schema.d.ts +3 -0
- package/dist/services/assets/url.d.ts +12 -0
- package/dist/services/assets/use-library.d.ts +20 -0
- package/package.json +13 -1
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
useCallback,
|
|
7
7
|
useEffect,
|
|
8
8
|
useImperativeHandle,
|
|
9
|
-
useRef
|
|
9
|
+
useRef,
|
|
10
|
+
useState
|
|
10
11
|
} from "react";
|
|
11
12
|
import { Button } from "@/components/ui/button";
|
|
12
13
|
import { InputGroup, InputGroupInput } from "@/components/ui/input-group";
|
|
@@ -19,8 +20,15 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/reac
|
|
|
19
20
|
|
|
20
21
|
// ../../src/components/virtualized-combobox/classes.ts
|
|
21
22
|
var virtualizedComboboxClasses = {
|
|
22
|
-
itemLabel: "min-w-0 truncate"
|
|
23
|
+
itemLabel: "min-w-0 truncate",
|
|
24
|
+
groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
|
|
25
|
+
itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
|
|
26
|
+
itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
|
|
27
|
+
itemImage: "size-full object-cover",
|
|
28
|
+
itemDescription: "text-muted-foreground block truncate text-xs"
|
|
23
29
|
};
|
|
30
|
+
var virtualizedComboboxGroupHeight = 36;
|
|
31
|
+
var virtualizedComboboxDetailHeight = 52;
|
|
24
32
|
var resolveVirtualizedComboboxClasses = (overrides) => ({
|
|
25
33
|
...virtualizedComboboxClasses,
|
|
26
34
|
...overrides
|
|
@@ -31,10 +39,14 @@ import { Schema as Schema2 } from "effect";
|
|
|
31
39
|
import { Component, UiSchema } from "effect/ui";
|
|
32
40
|
|
|
33
41
|
// ../../src/components/virtualized-combobox/schema.ts
|
|
34
|
-
import { Schema, Struct } from "effect";
|
|
42
|
+
import { Predicate, Schema, Struct } from "effect";
|
|
43
|
+
var Icon = Schema.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
|
|
35
44
|
var VirtualizedComboboxOptionSchema = Schema.Struct({
|
|
36
45
|
value: Schema.String.pipe(Schema.mutableKey),
|
|
37
|
-
label: Schema.String.pipe(Schema.mutableKey)
|
|
46
|
+
label: Schema.String.pipe(Schema.mutableKey),
|
|
47
|
+
description: Schema.optionalKey(Schema.String),
|
|
48
|
+
imageSrc: Schema.optionalKey(Schema.String),
|
|
49
|
+
icon: Schema.optionalKey(Icon)
|
|
38
50
|
}).annotate({ identifier: "VirtualizedComboboxOption" });
|
|
39
51
|
var VirtualizedComboboxLabelsSchema = Schema.Struct({
|
|
40
52
|
clear: Schema.optionalKey(Schema.String),
|
|
@@ -59,6 +71,8 @@ var htmlFields = {
|
|
|
59
71
|
emptyLabel: Schema.String,
|
|
60
72
|
placeholder: Schema.String,
|
|
61
73
|
triggerLabel: Schema.optionalKey(Schema.String),
|
|
74
|
+
triggerIcon: Schema.optionalKey(Icon),
|
|
75
|
+
itemHeight: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
62
76
|
filter: Schema.optionalKey(Schema.Literals(["contains", "none"])),
|
|
63
77
|
messages: Schema.optionalKey(Schema.Record(Schema.String, Schema.Struct({
|
|
64
78
|
...VirtualizedComboboxLabelsSchema.fields,
|
|
@@ -148,7 +162,8 @@ var VirtualizedComboboxEvents = UiSchema.TaggedEnum(events).annotate({
|
|
|
148
162
|
});
|
|
149
163
|
var VirtualizedComboboxMessage = UiSchema.TaggedEnum({
|
|
150
164
|
...events,
|
|
151
|
-
Highlighted: { value: Schema2.String }
|
|
165
|
+
Highlighted: { value: Schema2.String },
|
|
166
|
+
ImageFailed: { src: Schema2.String }
|
|
152
167
|
}).annotate({ identifier: "VirtualizedComboboxMessage" });
|
|
153
168
|
var virtualizedComboboxOptions = {
|
|
154
169
|
name: "VirtualizedCombobox",
|
|
@@ -156,6 +171,7 @@ var virtualizedComboboxOptions = {
|
|
|
156
171
|
model: Schema2.Struct({
|
|
157
172
|
open: Schema2.Boolean,
|
|
158
173
|
searchValue: Schema2.String,
|
|
174
|
+
failedImages: Schema2.Array(Schema2.String),
|
|
159
175
|
highlight: Schema2.NullOr(Schema2.Struct({ value: Schema2.String, id: Schema2.Int }))
|
|
160
176
|
}).annotate({ identifier: "VirtualizedComboboxModel" }),
|
|
161
177
|
message: VirtualizedComboboxMessage,
|
|
@@ -175,17 +191,24 @@ var update = Component.define(virtualizedComboboxOptions).update({
|
|
|
175
191
|
ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
|
|
176
192
|
Highlighted: ($, { value }) => $.evolve({
|
|
177
193
|
highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
|
|
178
|
-
})
|
|
194
|
+
}),
|
|
195
|
+
ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
|
|
179
196
|
});
|
|
180
197
|
|
|
181
198
|
// ../../src/components/virtualized-combobox/react.tsx
|
|
182
199
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
183
200
|
"use client";
|
|
184
201
|
var optionEquals = (item, selected) => item.value === selected.value;
|
|
202
|
+
var hasOptionDetails = ({
|
|
203
|
+
description,
|
|
204
|
+
imageSrc,
|
|
205
|
+
icon
|
|
206
|
+
}) => Boolean(description || imageSrc || icon);
|
|
185
207
|
var VirtualizedComboboxList = ({
|
|
186
208
|
classes,
|
|
187
209
|
emptyLabel,
|
|
188
210
|
groupSelections,
|
|
211
|
+
itemHeight,
|
|
189
212
|
itemIndexRef,
|
|
190
213
|
locale = "en",
|
|
191
214
|
messages: messageOverrides,
|
|
@@ -198,6 +221,8 @@ var VirtualizedComboboxList = ({
|
|
|
198
221
|
const labels = virtualizedComboboxMessages(locale, messageOverrides);
|
|
199
222
|
const entries = selectionEntries(filteredItems, selectedValues, groupSelections, labels);
|
|
200
223
|
const scrollRef = useRef(null);
|
|
224
|
+
const [failedImages, setFailedImages] = useState(() => new Set);
|
|
225
|
+
const rowHeight = itemHeight ?? (filteredItems.some(hasOptionDetails) ? virtualizedComboboxDetailHeight : 36);
|
|
201
226
|
const virtualizer = useVirtualizer({
|
|
202
227
|
count: entries.length,
|
|
203
228
|
getScrollElement: () => scrollRef.current,
|
|
@@ -205,7 +230,7 @@ var VirtualizedComboboxList = ({
|
|
|
205
230
|
const entry = entries[index];
|
|
206
231
|
return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
|
|
207
232
|
},
|
|
208
|
-
estimateSize: () =>
|
|
233
|
+
estimateSize: (index) => entries[index]?.kind === "group" ? virtualizedComboboxGroupHeight : rowHeight,
|
|
209
234
|
overscan: 8
|
|
210
235
|
});
|
|
211
236
|
useEffect(() => {
|
|
@@ -247,7 +272,7 @@ var VirtualizedComboboxList = ({
|
|
|
247
272
|
return /* @__PURE__ */ jsx(ComboboxPrimitive.Group, {
|
|
248
273
|
className: "contents",
|
|
249
274
|
children: /* @__PURE__ */ jsx(ComboboxPrimitive.GroupLabel, {
|
|
250
|
-
className:
|
|
275
|
+
className: `absolute top-0 left-0 w-full ${virtualizedComboboxClasses.groupLabel}`,
|
|
251
276
|
"data-index": virtualItem.index,
|
|
252
277
|
ref: virtualizer.measureElement,
|
|
253
278
|
style,
|
|
@@ -255,6 +280,8 @@ var VirtualizedComboboxList = ({
|
|
|
255
280
|
})
|
|
256
281
|
}, entry.key);
|
|
257
282
|
}
|
|
283
|
+
const details = entry.item;
|
|
284
|
+
const image = details.imageSrc && !failedImages.has(details.imageSrc) ? details.imageSrc : undefined;
|
|
258
285
|
return /* @__PURE__ */ jsxs(ComboboxPrimitive.Item, {
|
|
259
286
|
"aria-posinset": entry.index + 1,
|
|
260
287
|
"aria-setsize": filteredItems.length,
|
|
@@ -265,10 +292,38 @@ var VirtualizedComboboxList = ({
|
|
|
265
292
|
style,
|
|
266
293
|
value: entry.item,
|
|
267
294
|
children: [
|
|
268
|
-
renderItem?.(entry.item) ?? /* @__PURE__ */
|
|
295
|
+
renderItem?.(entry.item) ?? (hasOptionDetails(details) ? /* @__PURE__ */ jsxs("span", {
|
|
296
|
+
className: virtualizedComboboxClasses.itemContent,
|
|
297
|
+
children: [
|
|
298
|
+
(image || details.icon) && /* @__PURE__ */ jsx("span", {
|
|
299
|
+
"aria-hidden": "true",
|
|
300
|
+
className: virtualizedComboboxClasses.itemMedia,
|
|
301
|
+
children: image ? /* @__PURE__ */ jsx("img", {
|
|
302
|
+
src: image,
|
|
303
|
+
alt: "",
|
|
304
|
+
loading: "lazy",
|
|
305
|
+
onError: () => setFailedImages((failed) => new Set(failed).add(image)),
|
|
306
|
+
className: virtualizedComboboxClasses.itemImage
|
|
307
|
+
}) : details.icon
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ jsxs("span", {
|
|
310
|
+
className: "min-w-0 flex-1",
|
|
311
|
+
children: [
|
|
312
|
+
/* @__PURE__ */ jsx("span", {
|
|
313
|
+
className: cn("block", virtualizedComboboxClasses.itemLabel),
|
|
314
|
+
children: entry.item.label
|
|
315
|
+
}),
|
|
316
|
+
details.description && /* @__PURE__ */ jsx("span", {
|
|
317
|
+
className: virtualizedComboboxClasses.itemDescription,
|
|
318
|
+
children: details.description
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
269
324
|
className: virtualizedComboboxClasses.itemLabel,
|
|
270
325
|
children: entry.item.label
|
|
271
|
-
}),
|
|
326
|
+
})),
|
|
272
327
|
/* @__PURE__ */ jsx(ComboboxPrimitive.ItemIndicator, {
|
|
273
328
|
className: "absolute right-2 flex size-4 items-center justify-center",
|
|
274
329
|
children: /* @__PURE__ */ jsx(Check, {})
|
|
@@ -286,6 +341,7 @@ var VirtualizedComboboxContent = ({
|
|
|
286
341
|
contentClassName,
|
|
287
342
|
emptyLabel,
|
|
288
343
|
groupSelections,
|
|
344
|
+
itemHeight,
|
|
289
345
|
itemIndexRef,
|
|
290
346
|
locale = "en",
|
|
291
347
|
messages: messageOverrides,
|
|
@@ -317,6 +373,7 @@ var VirtualizedComboboxContent = ({
|
|
|
317
373
|
classes,
|
|
318
374
|
emptyLabel,
|
|
319
375
|
groupSelections,
|
|
376
|
+
itemHeight,
|
|
320
377
|
itemIndexRef,
|
|
321
378
|
locale,
|
|
322
379
|
messages: messageOverrides,
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
import type { View } from "effect/ui";
|
|
3
|
+
import type { Html } from "effect/ui/html";
|
|
2
4
|
export declare const VirtualizedComboboxOptionSchema: Schema.Struct<{
|
|
3
5
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
4
6
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
7
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
8
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
9
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
10
|
+
size: number;
|
|
11
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
12
|
+
size: number;
|
|
13
|
+
}) => View.Input<Msg, never>>>;
|
|
5
14
|
}>;
|
|
6
15
|
export type VirtualizedComboboxOption<TData = never> = typeof VirtualizedComboboxOptionSchema.Type & {
|
|
7
16
|
data?: TData;
|
|
@@ -11,10 +20,10 @@ export declare const VirtualizedComboboxLabelsSchema: Schema.Struct<{
|
|
|
11
20
|
readonly search: Schema.optionalKey<Schema.String>;
|
|
12
21
|
readonly selectMore: Schema.optionalKey<Schema.String>;
|
|
13
22
|
}>;
|
|
14
|
-
declare const VirtualizedComboboxClassesOverridesSchema: Schema.$Record<Schema.Literals<"itemLabel"[]>, Schema.optionalKey<Schema.String>>;
|
|
23
|
+
declare const VirtualizedComboboxClassesOverridesSchema: Schema.$Record<Schema.Literals<("groupLabel" | "itemContent" | "itemDescription" | "itemImage" | "itemLabel" | "itemMedia")[]>, Schema.optionalKey<Schema.String>>;
|
|
15
24
|
export type VirtualizedComboboxClassesOverrides = typeof VirtualizedComboboxClassesOverridesSchema.Type;
|
|
16
25
|
export declare const VirtualizedComboboxSharedPropsSchema: Schema.Struct<{
|
|
17
|
-
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<"itemLabel"[]>, Schema.optionalKey<Schema.String>>>;
|
|
26
|
+
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<("groupLabel" | "itemContent" | "itemDescription" | "itemImage" | "itemLabel" | "itemMedia")[]>, Schema.optionalKey<Schema.String>>>;
|
|
18
27
|
readonly ariaLabel: Schema.String;
|
|
19
28
|
readonly ariaInvalid: Schema.optionalKey<Schema.Boolean>;
|
|
20
29
|
readonly contentClassName: Schema.optionalKey<Schema.String>;
|
|
@@ -22,6 +31,13 @@ export declare const VirtualizedComboboxSharedPropsSchema: Schema.Struct<{
|
|
|
22
31
|
readonly items: Schema.$Array<Schema.Struct<{
|
|
23
32
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
24
33
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
34
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
35
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
36
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
37
|
+
size: number;
|
|
38
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
39
|
+
size: number;
|
|
40
|
+
}) => View.Input<Msg, never>>>;
|
|
25
41
|
}>>;
|
|
26
42
|
readonly locale: Schema.optionalKey<Schema.String>;
|
|
27
43
|
readonly open: Schema.optionalKey<Schema.Boolean>;
|
|
@@ -30,7 +46,7 @@ export declare const VirtualizedComboboxSharedPropsSchema: Schema.Struct<{
|
|
|
30
46
|
}>;
|
|
31
47
|
export type VirtualizedComboboxSharedProps = typeof VirtualizedComboboxSharedPropsSchema.Type;
|
|
32
48
|
export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Schema.Struct<{
|
|
33
|
-
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<"itemLabel"[]>, Schema.optionalKey<Schema.String>>>;
|
|
49
|
+
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<("groupLabel" | "itemContent" | "itemDescription" | "itemImage" | "itemLabel" | "itemMedia")[]>, Schema.optionalKey<Schema.String>>>;
|
|
34
50
|
readonly ariaLabel: Schema.String;
|
|
35
51
|
readonly ariaInvalid: Schema.optionalKey<Schema.Boolean>;
|
|
36
52
|
readonly contentClassName: Schema.optionalKey<Schema.String>;
|
|
@@ -38,6 +54,13 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
38
54
|
readonly items: Schema.$Array<Schema.Struct<{
|
|
39
55
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
40
56
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
57
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
58
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
59
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
60
|
+
size: number;
|
|
61
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
62
|
+
size: number;
|
|
63
|
+
}) => View.Input<Msg, never>>>;
|
|
41
64
|
}>>;
|
|
42
65
|
readonly locale: Schema.optionalKey<Schema.String>;
|
|
43
66
|
readonly open: Schema.optionalKey<Schema.Boolean>;
|
|
@@ -46,6 +69,12 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
46
69
|
readonly emptyLabel: Schema.String;
|
|
47
70
|
readonly placeholder: Schema.String;
|
|
48
71
|
readonly triggerLabel: Schema.optionalKey<Schema.String>;
|
|
72
|
+
readonly triggerIcon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
73
|
+
size: number;
|
|
74
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
75
|
+
size: number;
|
|
76
|
+
}) => View.Input<Msg, never>>>;
|
|
77
|
+
readonly itemHeight: Schema.optionalKey<Schema.Int>;
|
|
49
78
|
readonly filter: Schema.optionalKey<Schema.Literals<readonly ["contains", "none"]>>;
|
|
50
79
|
readonly messages: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
51
80
|
readonly clear: Schema.optionalKey<Schema.String>;
|
|
@@ -57,9 +86,16 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
57
86
|
readonly value: Schema.NullOr<Schema.Struct<{
|
|
58
87
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
59
88
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
89
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
90
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
91
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
92
|
+
size: number;
|
|
93
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
94
|
+
size: number;
|
|
95
|
+
}) => View.Input<Msg, never>>>;
|
|
60
96
|
}>>;
|
|
61
97
|
}>, Schema.Struct<{
|
|
62
|
-
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<"itemLabel"[]>, Schema.optionalKey<Schema.String>>>;
|
|
98
|
+
readonly classes: Schema.optional<Schema.$Record<Schema.Literals<("groupLabel" | "itemContent" | "itemDescription" | "itemImage" | "itemLabel" | "itemMedia")[]>, Schema.optionalKey<Schema.String>>>;
|
|
63
99
|
readonly ariaLabel: Schema.String;
|
|
64
100
|
readonly ariaInvalid: Schema.optionalKey<Schema.Boolean>;
|
|
65
101
|
readonly contentClassName: Schema.optionalKey<Schema.String>;
|
|
@@ -67,6 +103,13 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
67
103
|
readonly items: Schema.$Array<Schema.Struct<{
|
|
68
104
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
69
105
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
106
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
107
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
108
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
109
|
+
size: number;
|
|
110
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
111
|
+
size: number;
|
|
112
|
+
}) => View.Input<Msg, never>>>;
|
|
70
113
|
}>>;
|
|
71
114
|
readonly locale: Schema.optionalKey<Schema.String>;
|
|
72
115
|
readonly open: Schema.optionalKey<Schema.Boolean>;
|
|
@@ -75,6 +118,12 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
75
118
|
readonly emptyLabel: Schema.String;
|
|
76
119
|
readonly placeholder: Schema.String;
|
|
77
120
|
readonly triggerLabel: Schema.optionalKey<Schema.String>;
|
|
121
|
+
readonly triggerIcon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
122
|
+
size: number;
|
|
123
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
124
|
+
size: number;
|
|
125
|
+
}) => View.Input<Msg, never>>>;
|
|
126
|
+
readonly itemHeight: Schema.optionalKey<Schema.Int>;
|
|
78
127
|
readonly filter: Schema.optionalKey<Schema.Literals<readonly ["contains", "none"]>>;
|
|
79
128
|
readonly messages: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{
|
|
80
129
|
readonly clear: Schema.optionalKey<Schema.String>;
|
|
@@ -86,6 +135,13 @@ export declare const VirtualizedComboboxPropsSchema: Schema.Union<readonly [Sche
|
|
|
86
135
|
readonly value: Schema.$Array<Schema.Struct<{
|
|
87
136
|
readonly value: Schema.mutableKey<Schema.String>;
|
|
88
137
|
readonly label: Schema.mutableKey<Schema.String>;
|
|
138
|
+
readonly description: Schema.optionalKey<Schema.String>;
|
|
139
|
+
readonly imageSrc: Schema.optionalKey<Schema.String>;
|
|
140
|
+
readonly icon: Schema.optionalKey<Schema.declare<<Msg>(h: Html.H<Msg>, options: {
|
|
141
|
+
size: number;
|
|
142
|
+
}) => View.Input<Msg, never>, <Msg>(h: Html.H<Msg>, options: {
|
|
143
|
+
size: number;
|
|
144
|
+
}) => View.Input<Msg, never>>>;
|
|
89
145
|
}>>;
|
|
90
146
|
}>]>;
|
|
91
147
|
export type VirtualizedComboboxProps = typeof VirtualizedComboboxPropsSchema.Type;
|
|
@@ -493,6 +493,7 @@ var tableClasses = {
|
|
|
493
493
|
actionTrigger: `size-8 ${cellTriggerFocus}`,
|
|
494
494
|
actionsCell: "sticky right-0 z-20 w-10 min-w-10 cursor-default bg-background p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
|
|
495
495
|
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
496
|
+
row: "h-16 [&:where(:not(:last-child))>td]:border-b",
|
|
496
497
|
header: "relative h-12 p-0",
|
|
497
498
|
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
498
499
|
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
@@ -559,6 +560,7 @@ var DataTableItemSchema = Schema4.Struct({
|
|
|
559
560
|
value: Schema4.NonEmptyString,
|
|
560
561
|
label: Schema4.String
|
|
561
562
|
}).annotate({ identifier: "DataTableItem" });
|
|
563
|
+
var TableIconSchema = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableIcon" });
|
|
562
564
|
var DataTableReferenceSchema = Schema4.Struct({
|
|
563
565
|
label: Schema4.String,
|
|
564
566
|
description: Schema4.optionalKey(Schema4.String),
|
|
@@ -598,11 +600,15 @@ var DataTableActionSchema = Schema4.Struct({
|
|
|
598
600
|
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
599
601
|
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
600
602
|
}).annotate({ identifier: "DataTableAction" });
|
|
603
|
+
var DataTableRowActionSchema = Schema4.Struct({
|
|
604
|
+
...DataTableActionSchema.fields,
|
|
605
|
+
icon: Schema4.optionalKey(TableIconSchema)
|
|
606
|
+
}).annotate({ identifier: "DataTableRowAction" });
|
|
601
607
|
var DataTableRowSchema = Schema4.Struct({
|
|
602
608
|
id: Schema4.NonEmptyString,
|
|
603
609
|
label: Schema4.String,
|
|
604
610
|
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
605
|
-
actions: Schema4.optionalKey(Schema4.Array(
|
|
611
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableRowActionSchema)),
|
|
606
612
|
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
607
613
|
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
608
614
|
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
@@ -637,11 +643,10 @@ var DataTableBadgeOptionSchema = Schema4.Struct({
|
|
|
637
643
|
"muted"
|
|
638
644
|
]))
|
|
639
645
|
}).annotate({ identifier: "DataTableBadgeOption" });
|
|
640
|
-
var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
|
|
641
646
|
var DataTableBadgeOptionsSchema = Schema4.Struct({
|
|
642
647
|
options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
|
|
643
648
|
...fields,
|
|
644
|
-
icon: Schema4.optionalKey(
|
|
649
|
+
icon: Schema4.optionalKey(TableIconSchema)
|
|
645
650
|
}))))
|
|
646
651
|
}).annotate({ identifier: "DataTableBadgeOptions" });
|
|
647
652
|
var DataTableFieldSchema = Schema4.Union([
|
|
@@ -656,6 +661,7 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
656
661
|
type: Schema4.Literal("number"),
|
|
657
662
|
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
658
663
|
locale: Schema4.optionalKey(Schema4.String),
|
|
664
|
+
format: Schema4.optionalKey(Schema4.Literal("bytes")),
|
|
659
665
|
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
660
666
|
currency: Schema4.optionalKey(Schema4.String),
|
|
661
667
|
unit: Schema4.optionalKey(Schema4.String),
|
|
@@ -665,7 +671,14 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
665
671
|
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
666
672
|
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
667
673
|
}),
|
|
668
|
-
Schema4.Struct({
|
|
674
|
+
Schema4.Struct({
|
|
675
|
+
...column,
|
|
676
|
+
type: Schema4.Literal("reference"),
|
|
677
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
678
|
+
imageVariant: Schema4.optionalKey(Schema4.Literals(["circle", "square"])),
|
|
679
|
+
fallbackIcons: Schema4.optionalKey(Schema4.Record(Schema4.String, TableIconSchema))
|
|
680
|
+
}).annotate({ identifier: "DataTableReferenceOptions" }))
|
|
681
|
+
}),
|
|
669
682
|
Schema4.Struct({
|
|
670
683
|
...column,
|
|
671
684
|
type: Schema4.Literal("date"),
|
|
@@ -952,9 +965,17 @@ var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
|
952
965
|
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
953
966
|
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
954
967
|
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
968
|
+
var formatBytes = (bytes, locale) => {
|
|
969
|
+
const [unit, scale] = bytes >= 1024 ** 2 ? ["megabyte", 1024 ** 2] : bytes >= 1024 ? ["kilobyte", 1024] : ["byte", 1];
|
|
970
|
+
return new Intl.NumberFormat(locale, {
|
|
971
|
+
style: "unit",
|
|
972
|
+
unit,
|
|
973
|
+
maximumFractionDigits: 1
|
|
974
|
+
}).format(bytes / scale);
|
|
975
|
+
};
|
|
955
976
|
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
956
|
-
const { locale,
|
|
957
|
-
return new Intl.NumberFormat(locale ?? defaultLocale,
|
|
977
|
+
const { locale, format, ...intlOptions } = options ?? {};
|
|
978
|
+
return format === "bytes" ? formatBytes(value, locale ?? defaultLocale) : new Intl.NumberFormat(locale ?? defaultLocale, intlOptions).format(value);
|
|
958
979
|
};
|
|
959
980
|
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
960
981
|
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
@@ -2093,6 +2114,7 @@ var DataTable = Html2.component({
|
|
|
2093
2114
|
filterColumnId,
|
|
2094
2115
|
childSearch,
|
|
2095
2116
|
icon,
|
|
2117
|
+
rowIcon,
|
|
2096
2118
|
separatorBefore
|
|
2097
2119
|
}) => {
|
|
2098
2120
|
if (children || filterEditor) {
|
|
@@ -2165,7 +2187,7 @@ var DataTable = Html2.component({
|
|
|
2165
2187
|
value: id,
|
|
2166
2188
|
closeOnClick: !searchLabel
|
|
2167
2189
|
});
|
|
2168
|
-
const content = part.children(checked !== undefined && h.span.attr("aria-hidden", "true").class("w-3").children(checked ? "✓" : ""), indicator(icon), name);
|
|
2190
|
+
const content = part.children(rowIcon?.(h, { size: 16, className: "shrink-0" }), checked !== undefined && h.span.attr("aria-hidden", "true").class("w-3").children(checked ? "✓" : ""), indicator(icon), name);
|
|
2169
2191
|
return separatorBefore ? h.div.children(MenuSeparator(h, menu), content) : content;
|
|
2170
2192
|
})))));
|
|
2171
2193
|
}
|
|
@@ -2282,12 +2304,18 @@ var DataTable = Html2.component({
|
|
|
2282
2304
|
}
|
|
2283
2305
|
case "boolean":
|
|
2284
2306
|
return isTableBoolean(value) ? h.label.attr("data-slot", "data-table-boolean-cell").class(cn(booleanCellControl, column.editable && !disabled && "hover:bg-muted/50 cursor-pointer")).children(check(keyOf("edit", row.id, column.id), `${column.headerName}: ${row.label}`, value, (value) => edit(DataTableEdit.SetBoolean({ value })), { readOnly: !column.editable || disabled }, true)) : empty;
|
|
2285
|
-
case "reference":
|
|
2286
|
-
|
|
2287
|
-
|
|
2307
|
+
case "reference": {
|
|
2308
|
+
if (!isTableReference(value))
|
|
2309
|
+
return empty;
|
|
2310
|
+
const image = value.imageSrc && !model.failedImages.includes(value.imageSrc) ? value.imageSrc : undefined;
|
|
2311
|
+
const fallbackIcons = column.typeOptions?.fallbackIcons;
|
|
2312
|
+
const fallbackIcon = fallbackIcons && Object.hasOwn(fallbackIcons, row.id) ? fallbackIcons[row.id] : undefined;
|
|
2313
|
+
return h.div.class(tableClasses.reference).children(h.span.class(cn(tableClasses.referenceAvatar, column.typeOptions?.imageVariant === "square" ? "rounded-md" : "rounded-full")).children((!image || !fallbackIcon) && h.span.attr("aria-hidden", "true").children(fallbackIcon?.(h, { size: 16 }) ?? tableInitials(value.label)), image && h.img.attrs({
|
|
2314
|
+
src: image,
|
|
2288
2315
|
alt: "",
|
|
2289
2316
|
loading: "lazy"
|
|
2290
|
-
}).class("absolute inset-0 size-full object-cover").on("error", DataTableMessage.ReferenceImageFailed({ src:
|
|
2317
|
+
}).class("absolute inset-0 size-full object-cover").on("error", DataTableMessage.ReferenceImageFailed({ src: image }))), h.div.class(tableClasses.referenceText).children(h.span.class(tableClasses.referenceName).attr("title", value.label).children(value.label), value.description && h.span.class(tableClasses.referenceDescription).children(value.description)));
|
|
2318
|
+
}
|
|
2291
2319
|
case "list": {
|
|
2292
2320
|
const current = isTableList(value) ? value : [];
|
|
2293
2321
|
const visible = current.slice(0, column.visibleCount ?? 3);
|
|
@@ -2374,13 +2402,19 @@ var DataTable = Html2.component({
|
|
|
2374
2402
|
};
|
|
2375
2403
|
const dragHandle = (row) => draggable && h.span.attr("aria-hidden", "true").class("inline-flex size-8 cursor-grab items-center justify-center text-muted-foreground").draggable({ [RowDrag]: row.id }, { effectAllowed: "move" }).on("dragstart", DataTableMessage.DragStarted({ rowId: row.id })).on("dragend", DataTableMessage.DragEnded()).children(GripVertical(h, { size: 16 }));
|
|
2376
2404
|
const rowControls = (row, siblings, key) => {
|
|
2377
|
-
const items = tableRowActions(row, siblings, reorder, copy)
|
|
2405
|
+
const items = tableRowActions(row, siblings, reorder, copy).map((item) => {
|
|
2406
|
+
if ("icon" in item) {
|
|
2407
|
+
const { icon, ...action } = item;
|
|
2408
|
+
return { ...action, rowIcon: icon };
|
|
2409
|
+
}
|
|
2410
|
+
return { ...item, icon: undefined };
|
|
2411
|
+
});
|
|
2378
2412
|
return items.length > 0 && menu(keyOf("row", key, row.id), copy.actions, `${copy.actions}: ${row.label}`, items, false, undefined, false, "actions");
|
|
2379
2413
|
};
|
|
2380
2414
|
const renderRow = (row, siblings, key, group) => {
|
|
2381
2415
|
const primary = row.actions?.find(({ id, disabled }) => id === row.primaryActionId && !disabled);
|
|
2382
2416
|
const activate = props.rowActivation ? DataTableMessage.RowActivated({ rowId: row.id }) : primary && DataTableMessage.RowActionRequested({ rowId: row.id, actionId: primary.id });
|
|
2383
|
-
const tr = h.tr.key(keyOf(key, row.id)).class(cn("group/row hover:bg-muted/50 data-[selected]:bg-muted/40
|
|
2417
|
+
const tr = h.tr.key(keyOf(key, row.id)).class(cn("group/row hover:bg-muted/50 data-[selected]:bg-muted/40", tableClasses.row, props.rowActivation && "cursor-pointer")).attr("data-selected", selected.has(row.id) ? "" : undefined);
|
|
2384
2418
|
const rowElement = props.rowActivation && activate ? tr.attr("tabindex", "0").on("click", activate).on("keydown", (event) => !event.repeat && !event.composing && (event.key === "Enter" || event.key === " ") ? activate : undefined, { preventDefault: true }) : tr;
|
|
2385
2419
|
const ignoreActivation = () => {
|
|
2386
2420
|
return;
|
|
@@ -639,6 +639,7 @@ var tableClasses = {
|
|
|
639
639
|
actionTrigger: `size-8 ${cellTriggerFocus}`,
|
|
640
640
|
actionsCell: "sticky right-0 z-20 w-10 min-w-10 cursor-default bg-background p-0 transition-colors group-hover/row:bg-[color-mix(in_oklab,var(--muted)_50%,var(--background))]",
|
|
641
641
|
actionsAlign: "flex min-h-12 items-center justify-end pe-1",
|
|
642
|
+
row: "h-16 [&:where(:not(:last-child))>td]:border-b",
|
|
642
643
|
header: "relative h-12 p-0",
|
|
643
644
|
stickyHeader: "sticky top-0 z-30 bg-background",
|
|
644
645
|
stickyHeaderRule: "after:border-border after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b",
|
|
@@ -711,6 +712,7 @@ var DataTableItemSchema = Schema4.Struct({
|
|
|
711
712
|
value: Schema4.NonEmptyString,
|
|
712
713
|
label: Schema4.String
|
|
713
714
|
}).annotate({ identifier: "DataTableItem" });
|
|
715
|
+
var TableIconSchema = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableIcon" });
|
|
714
716
|
var DataTableReferenceSchema = Schema4.Struct({
|
|
715
717
|
label: Schema4.String,
|
|
716
718
|
description: Schema4.optionalKey(Schema4.String),
|
|
@@ -750,11 +752,15 @@ var DataTableActionSchema = Schema4.Struct({
|
|
|
750
752
|
variant: Schema4.optionalKey(Schema4.Literals(["default", "destructive"])),
|
|
751
753
|
disabled: Schema4.optionalKey(Schema4.Boolean)
|
|
752
754
|
}).annotate({ identifier: "DataTableAction" });
|
|
755
|
+
var DataTableRowActionSchema = Schema4.Struct({
|
|
756
|
+
...DataTableActionSchema.fields,
|
|
757
|
+
icon: Schema4.optionalKey(TableIconSchema)
|
|
758
|
+
}).annotate({ identifier: "DataTableRowAction" });
|
|
753
759
|
var DataTableRowSchema = Schema4.Struct({
|
|
754
760
|
id: Schema4.NonEmptyString,
|
|
755
761
|
label: Schema4.String,
|
|
756
762
|
cells: Schema4.Record(Schema4.String, DataTableCellValueSchema),
|
|
757
|
-
actions: Schema4.optionalKey(Schema4.Array(
|
|
763
|
+
actions: Schema4.optionalKey(Schema4.Array(DataTableRowActionSchema)),
|
|
758
764
|
primaryActionId: Schema4.optionalKey(Schema4.String),
|
|
759
765
|
groups: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
|
|
760
766
|
selectable: Schema4.optionalKey(Schema4.Boolean),
|
|
@@ -789,11 +795,10 @@ var DataTableBadgeOptionSchema = Schema4.Struct({
|
|
|
789
795
|
"muted"
|
|
790
796
|
]))
|
|
791
797
|
}).annotate({ identifier: "DataTableBadgeOption" });
|
|
792
|
-
var BadgeIcon = Schema4.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "DataTableBadgeIcon" });
|
|
793
798
|
var DataTableBadgeOptionsSchema = Schema4.Struct({
|
|
794
799
|
options: Schema4.optionalKey(Schema4.Array(DataTableBadgeOptionSchema.mapFields((fields) => ({
|
|
795
800
|
...fields,
|
|
796
|
-
icon: Schema4.optionalKey(
|
|
801
|
+
icon: Schema4.optionalKey(TableIconSchema)
|
|
797
802
|
}))))
|
|
798
803
|
}).annotate({ identifier: "DataTableBadgeOptions" });
|
|
799
804
|
var DataTableFieldSchema = Schema4.Union([
|
|
@@ -808,6 +813,7 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
808
813
|
type: Schema4.Literal("number"),
|
|
809
814
|
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
810
815
|
locale: Schema4.optionalKey(Schema4.String),
|
|
816
|
+
format: Schema4.optionalKey(Schema4.Literal("bytes")),
|
|
811
817
|
style: Schema4.optionalKey(Schema4.Literals(["decimal", "percent", "currency", "unit"])),
|
|
812
818
|
currency: Schema4.optionalKey(Schema4.String),
|
|
813
819
|
unit: Schema4.optionalKey(Schema4.String),
|
|
@@ -817,7 +823,14 @@ var DataTableFieldSchema = Schema4.Union([
|
|
|
817
823
|
exportFormat: Schema4.optionalKey(Schema4.Literals(["raw", "formatted"]))
|
|
818
824
|
}).annotate({ identifier: "DataTableNumberFormat" }))
|
|
819
825
|
}),
|
|
820
|
-
Schema4.Struct({
|
|
826
|
+
Schema4.Struct({
|
|
827
|
+
...column,
|
|
828
|
+
type: Schema4.Literal("reference"),
|
|
829
|
+
typeOptions: Schema4.optionalKey(Schema4.Struct({
|
|
830
|
+
imageVariant: Schema4.optionalKey(Schema4.Literals(["circle", "square"])),
|
|
831
|
+
fallbackIcons: Schema4.optionalKey(Schema4.Record(Schema4.String, TableIconSchema))
|
|
832
|
+
}).annotate({ identifier: "DataTableReferenceOptions" }))
|
|
833
|
+
}),
|
|
821
834
|
Schema4.Struct({
|
|
822
835
|
...column,
|
|
823
836
|
type: Schema4.Literal("date"),
|
|
@@ -1096,9 +1109,17 @@ var isTableBoolean = Schema5.is(Schema5.Boolean);
|
|
|
1096
1109
|
var isTableReference = Schema5.is(DataTableReferenceSchema);
|
|
1097
1110
|
var isTableList = Schema5.is(Schema5.Array(DataTableItemSchema));
|
|
1098
1111
|
var tableInitials = (label) => label.trim().split(/\s+/).slice(0, 2).map((word) => word.slice(0, 1)).join("").toLocaleUpperCase();
|
|
1112
|
+
var formatBytes = (bytes, locale) => {
|
|
1113
|
+
const [unit, scale] = bytes >= 1024 ** 2 ? ["megabyte", 1024 ** 2] : bytes >= 1024 ? ["kilobyte", 1024] : ["byte", 1];
|
|
1114
|
+
return new Intl.NumberFormat(locale, {
|
|
1115
|
+
style: "unit",
|
|
1116
|
+
unit,
|
|
1117
|
+
maximumFractionDigits: 1
|
|
1118
|
+
}).format(bytes / scale);
|
|
1119
|
+
};
|
|
1099
1120
|
var formatNumberValue = (value, options, defaultLocale = "en") => {
|
|
1100
|
-
const { locale,
|
|
1101
|
-
return new Intl.NumberFormat(locale ?? defaultLocale,
|
|
1121
|
+
const { locale, format, ...intlOptions } = options ?? {};
|
|
1122
|
+
return format === "bytes" ? formatBytes(value, locale ?? defaultLocale) : new Intl.NumberFormat(locale ?? defaultLocale, intlOptions).format(value);
|
|
1102
1123
|
};
|
|
1103
1124
|
var tableBooleanLabel = (value, options) => (value ? options?.trueLabel : options?.falseLabel) ?? String(value);
|
|
1104
1125
|
var decodeDateInput = Schema5.decodeUnknownOption(DataTableDateInputSchema);
|
|
@@ -2031,6 +2052,7 @@ var DataTableReferenceCell = ({
|
|
|
2031
2052
|
if (!item)
|
|
2032
2053
|
return emptyLabel;
|
|
2033
2054
|
const initials = tableInitials(item.label);
|
|
2055
|
+
const image = item.imageSrc && item.imageSrc !== failedImage ? item.imageSrc : undefined;
|
|
2034
2056
|
return /* @__PURE__ */ jsxs3("div", {
|
|
2035
2057
|
className: tableClasses.reference,
|
|
2036
2058
|
children: [
|
|
@@ -2040,14 +2062,16 @@ var DataTableReferenceCell = ({
|
|
|
2040
2062
|
"aria-hidden": "true",
|
|
2041
2063
|
className: "[&_svg]:size-4",
|
|
2042
2064
|
children: item.icon
|
|
2043
|
-
}) :
|
|
2044
|
-
src:
|
|
2045
|
-
alt: item.label,
|
|
2065
|
+
}) : image ? /* @__PURE__ */ jsx3("img", {
|
|
2066
|
+
src: image,
|
|
2067
|
+
alt: item.fallbackIcon ? "" : item.label,
|
|
2068
|
+
loading: "lazy",
|
|
2046
2069
|
className: "size-full object-cover",
|
|
2047
|
-
onError: () => setFailedImage(
|
|
2070
|
+
onError: () => setFailedImage(image)
|
|
2048
2071
|
}) : /* @__PURE__ */ jsx3("span", {
|
|
2049
2072
|
"aria-hidden": "true",
|
|
2050
|
-
|
|
2073
|
+
className: "[&_svg]:size-4",
|
|
2074
|
+
children: item.fallbackIcon ?? initials
|
|
2051
2075
|
})
|
|
2052
2076
|
}),
|
|
2053
2077
|
/* @__PURE__ */ jsxs3("div", {
|
|
@@ -3584,7 +3608,7 @@ var TableDataRow = ({
|
|
|
3584
3608
|
ref: measureRef,
|
|
3585
3609
|
"data-index": virtualIndex,
|
|
3586
3610
|
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3587
|
-
className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary
|
|
3611
|
+
className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary data-[drag-source=true]:opacity-40 data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=before]:[&>td]:border-t-2", tableClasses.row, store.config.onRowClicked && "cursor-pointer"),
|
|
3588
3612
|
"data-state": store.state.rowSelection[row.id] && "selected",
|
|
3589
3613
|
"data-table-row": row.id,
|
|
3590
3614
|
onClick: () => store.config.onRowClicked?.(row.data),
|