@krak-stack/registry 0.10.2 → 0.10.4

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.10.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve DataTable galleries with multiple tag columns, optional lazy-loaded cover images, and an initial view setting that respects saved preferences. Custom tag renderers no longer receive an extra badge wrapper. Existing single-tag configurations remain supported.
8
+ - 852280e: Update effect-form to 1.1.1 so date-only changes enable Save and unsaved-change detection.
9
+
10
+ ## 0.10.3
11
+
12
+ ### Patch Changes
13
+
14
+ - 098424e: Expose optional ThemeSwitcher trigger and portalled menu class hooks. Preserve default appearance, localized choices, keyboard interactions and theme persistence; consumers own custom colors and selected-state styling.
15
+
3
16
  ## 0.10.2
4
17
 
5
18
  ### Patch Changes
@@ -281,6 +281,21 @@ export interface DataTableExportFeature {
281
281
  actions?: readonly DataTableExportAction[];
282
282
  onError?: (error: unknown, action: DataTableExportAction) => void;
283
283
  }
284
+ export interface DataTableGalleryFeature<TData> {
285
+ name: string;
286
+ description?: string;
287
+ /** Column IDs in display order. Custom cell renderers own their presentation. */
288
+ tags?: readonly string[];
289
+ /** Legacy single-tag configuration. Used when tags is not supplied. */
290
+ tag?: string;
291
+ tagIcon?: ReactNode;
292
+ /** Optional cover image. Missing or failed images leave a text-only card. */
293
+ image?: {
294
+ getSrc: (row: TData) => string | null | undefined;
295
+ /** Omit for a decorative image; the card title already identifies the row. */
296
+ getAlt?: (row: TData) => string;
297
+ };
298
+ }
284
299
  export interface DataTableFeatures<TData> {
285
300
  toolbar?: false | {
286
301
  /** Additional `MenubarMenu` controls rendered at the start of the toolbar. */
@@ -305,12 +320,7 @@ export interface DataTableFeatures<TData> {
305
320
  items: readonly DataTableRowAction<TData>[];
306
321
  };
307
322
  export?: false | DataTableExportFeature;
308
- gallery?: false | {
309
- name: string;
310
- description?: string;
311
- tag?: string;
312
- tagIcon?: ReactNode;
313
- };
323
+ gallery?: false | DataTableGalleryFeature<TData>;
314
324
  grouping?: false | DataTableGroupingFeature<TData>;
315
325
  reordering?: false | {
316
326
  onReorder: (rows: TData[]) => void;
@@ -490,6 +500,8 @@ export interface DataTableProps<TData extends RowData> {
490
500
  initialState?: Partial<DataTablePublicState> & {
491
501
  /** Initial visibility defaults; saved user preferences take precedence. */
492
502
  columnVisibility?: Readonly<Record<string, boolean>>;
503
+ /** Initial view only; a saved user preference takes precedence. */
504
+ view?: DataTableView;
493
505
  };
494
506
  locale?: string;
495
507
  onStateChange?: (state: DataTablePublicState) => void;
@@ -3528,6 +3528,44 @@ var DataTableBody = ({
3528
3528
  }, row.id))
3529
3529
  });
3530
3530
  };
3531
+ var GalleryImage = ({ src, alt }) => {
3532
+ const [failed, setFailed] = useState(false);
3533
+ if (failed)
3534
+ return null;
3535
+ return /* @__PURE__ */ jsx15("img", {
3536
+ src,
3537
+ alt,
3538
+ loading: "lazy",
3539
+ decoding: "async",
3540
+ className: "aspect-video w-full object-cover",
3541
+ onError: () => setFailed(true)
3542
+ });
3543
+ };
3544
+ var GalleryTag = ({
3545
+ row,
3546
+ column,
3547
+ icon,
3548
+ locale,
3549
+ labels
3550
+ }) => {
3551
+ const value = row.values.get(column.id);
3552
+ if ((value == null || value === "") && !column.colDef.cellRenderer)
3553
+ return null;
3554
+ const content = renderCell(row, column, locale, labels);
3555
+ return column.colDef.cellRenderer || column.colDef.valueFormatter ? /* @__PURE__ */ jsxs9("div", {
3556
+ className: "flex min-w-0 items-center gap-1",
3557
+ children: [
3558
+ icon,
3559
+ content
3560
+ ]
3561
+ }) : /* @__PURE__ */ jsxs9(Badge, {
3562
+ variant: "secondary",
3563
+ children: [
3564
+ icon,
3565
+ content
3566
+ ]
3567
+ });
3568
+ };
3531
3569
  var GalleryCard = ({
3532
3570
  tableAtom
3533
3571
  }) => {
@@ -3538,14 +3576,17 @@ var GalleryCard = ({
3538
3576
  const gallery = store.config.features.gallery;
3539
3577
  if (!row || !gallery)
3540
3578
  return null;
3541
- const find = (id) => id ? model.visibleColumns.find((column) => column.id === id) : undefined;
3579
+ const find = (id) => id ? model.columns.find((column) => column.id === id) : undefined;
3542
3580
  const name = find(gallery.name);
3543
3581
  const description = find(gallery.description);
3544
- const tag = find(gallery.tag);
3582
+ const tagIds = [
3583
+ ...new Set(gallery.tags ?? (gallery.tag ? [gallery.tag] : []))
3584
+ ];
3585
+ const imageSrc = gallery.image?.getSrc(row.data);
3545
3586
  const selection = store.config.features.selection;
3546
3587
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
3547
3588
  const draggable = canDragRows(store);
3548
- return /* @__PURE__ */ jsx15(Card, {
3589
+ return /* @__PURE__ */ jsxs9(Card, {
3549
3590
  className: cn("data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-primary relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=after]:border-b-2 data-[drop-position=before]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
3550
3591
  "data-table-row": row.id,
3551
3592
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -3556,47 +3597,56 @@ var GalleryCard = ({
3556
3597
  }
3557
3598
  },
3558
3599
  tabIndex: store.config.onRowClicked ? 0 : undefined,
3559
- children: /* @__PURE__ */ jsxs9(CardHeader, {
3560
- className: "pr-12",
3561
- children: [
3562
- /* @__PURE__ */ jsxs9("div", {
3563
- className: "flex items-center gap-2",
3564
- children: [
3565
- selection ? /* @__PURE__ */ jsx15(Checkbox, {
3566
- "aria-label": store.config.labels.selectRow,
3567
- checked: !!store.state.rowSelection[row.id],
3568
- disabled: !selectable,
3569
- onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3570
- onClick: (event) => event.stopPropagation()
3571
- }) : null,
3572
- draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3600
+ children: [
3601
+ imageSrc ? /* @__PURE__ */ jsx15(GalleryImage, {
3602
+ src: imageSrc,
3603
+ alt: gallery.image?.getAlt?.(row.data) ?? ""
3604
+ }, imageSrc) : null,
3605
+ /* @__PURE__ */ jsxs9(CardHeader, {
3606
+ className: cn("relative", hasRowActionMenu(store) && "pr-12"),
3607
+ children: [
3608
+ selection || draggable || tagIds.length ? /* @__PURE__ */ jsxs9("div", {
3609
+ className: "flex flex-wrap items-center gap-2",
3610
+ children: [
3611
+ selection ? /* @__PURE__ */ jsx15(Checkbox, {
3612
+ "aria-label": store.config.labels.selectRow,
3613
+ checked: !!store.state.rowSelection[row.id],
3614
+ disabled: !selectable,
3615
+ onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3616
+ onClick: (event) => event.stopPropagation()
3617
+ }) : null,
3618
+ draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3619
+ tableAtom
3620
+ }) : null,
3621
+ tagIds.map((id) => {
3622
+ const column = find(id);
3623
+ return column ? /* @__PURE__ */ jsx15(GalleryTag, {
3624
+ row,
3625
+ column,
3626
+ locale: store.config.locale,
3627
+ labels: store.config.labels,
3628
+ icon: id === gallery.tag ? gallery.tagIcon : undefined
3629
+ }, id) : null;
3630
+ })
3631
+ ]
3632
+ }) : null,
3633
+ /* @__PURE__ */ jsx15(CardTitle, {
3634
+ children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3635
+ }),
3636
+ description ? /* @__PURE__ */ jsx15("div", {
3637
+ className: "text-muted-foreground line-clamp-3 text-sm",
3638
+ children: renderCell(row, description, store.config.locale, store.config.labels)
3639
+ }) : null,
3640
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3641
+ className: "absolute top-0 right-4",
3642
+ onClick: (event) => event.stopPropagation(),
3643
+ children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3573
3644
  tableAtom
3574
- }) : null,
3575
- tag ? /* @__PURE__ */ jsxs9(Badge, {
3576
- variant: "secondary",
3577
- children: [
3578
- gallery.tagIcon,
3579
- renderCell(row, tag, store.config.locale, store.config.labels)
3580
- ]
3581
- }) : null
3582
- ]
3583
- }),
3584
- /* @__PURE__ */ jsx15(CardTitle, {
3585
- children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3586
- }),
3587
- description ? /* @__PURE__ */ jsx15("div", {
3588
- className: "text-muted-foreground line-clamp-3 text-sm",
3589
- children: renderCell(row, description, store.config.locale, store.config.labels)
3590
- }) : null,
3591
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3592
- className: "absolute top-4 right-4",
3593
- onClick: (event) => event.stopPropagation(),
3594
- children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3595
- tableAtom
3596
- })
3597
- }) : null
3598
- ]
3599
- })
3645
+ })
3646
+ }) : null
3647
+ ]
3648
+ })
3649
+ ]
3600
3650
  });
3601
3651
  };
3602
3652
  var DataTableGallery = ({
@@ -3860,6 +3910,7 @@ var DataTable = (props) => {
3860
3910
  schema: DataTablePersistedUiStateSchema,
3861
3911
  defaultValue: () => ({
3862
3912
  ...persistedUiFromState(DEFAULT_UI_STATE),
3913
+ view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
3863
3914
  grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
3864
3915
  })
3865
3916
  });
@@ -145,7 +145,7 @@ declare const RevertButton: ({ locale, messages, original, }: {
145
145
  messages?: FormMessageTranslations;
146
146
  original: string;
147
147
  }) => JSX.Element | undefined;
148
- declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/react-form").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
148
+ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/form-core").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
149
149
  readonly TextField: typeof TextField;
150
150
  readonly TextAreaField: typeof TextAreaField;
151
151
  readonly SelectField: typeof SelectField;
@@ -161,7 +161,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
161
161
  readonly FormError: typeof FormError;
162
162
  readonly FieldWrapper: typeof FieldWrapper;
163
163
  readonly BlockNavigation: typeof BlockNavigation;
164
- }>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
164
+ }>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props, }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
165
165
  readonly TextField: typeof TextField;
166
166
  readonly TextAreaField: typeof TextAreaField;
167
167
  readonly SelectField: typeof SelectField;
@@ -178,7 +178,7 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
178
178
  readonly FieldWrapper: typeof FieldWrapper;
179
179
  readonly BlockNavigation: typeof BlockNavigation;
180
180
  }, TRenderProps>) => import("react").FunctionComponent<import("react").PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
181
- form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
181
+ form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/form-core").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
182
182
  readonly TextField: typeof TextField;
183
183
  readonly TextAreaField: typeof TextAreaField;
184
184
  readonly SelectField: typeof SelectField;
@@ -211,8 +211,8 @@ declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tans
211
211
  readonly FormError: typeof FormError;
212
212
  readonly FieldWrapper: typeof FieldWrapper;
213
213
  readonly BlockNavigation: typeof BlockNavigation;
214
- }, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/react-form").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/react-form").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
215
- form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/react-form").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
214
+ }, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/form-core").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/form-core").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/form-core").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/form-core").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: import("react").PropsWithChildren<NoInfer<TRenderProps> & {
215
+ form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/form-core").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
216
216
  readonly TextField: typeof TextField;
217
217
  readonly TextAreaField: typeof TextAreaField;
218
218
  readonly SelectField: typeof SelectField;
@@ -18,7 +18,9 @@ type ThemeProviderProps = {
18
18
  initialTheme?: ThemePayload;
19
19
  scriptDisabled?: boolean;
20
20
  };
21
- type ThemeSwitcherProps = {
21
+ export type ThemeSwitcherProps = {
22
+ className?: string;
23
+ contentClassName?: string;
22
24
  locale?: string;
23
25
  messages?: ThemeSwitcherMessageTranslations;
24
26
  options?: ReadonlyArray<Theme>;
@@ -27,5 +29,5 @@ type ThemeSwitcherProps = {
27
29
  };
28
30
  export declare const ThemeProvider: ({ children, initialTheme, scriptDisabled, }: ThemeProviderProps) => import("react").JSX.Element;
29
31
  export declare const useTheme: () => ThemeProviderState;
30
- export declare const ThemeSwitcher: ({ locale: localeOverride, messages, options, value, onChange, }: ThemeSwitcherProps) => import("react").JSX.Element;
32
+ export declare const ThemeSwitcher: ({ className, contentClassName, locale: localeOverride, messages, options, value, onChange, }: ThemeSwitcherProps) => import("react").JSX.Element;
31
33
  export {};
@@ -264,6 +264,8 @@ var useTheme = () => {
264
264
  return context;
265
265
  };
266
266
  var ThemeSwitcher = ({
267
+ className,
268
+ contentClassName,
267
269
  locale: localeOverride,
268
270
  messages,
269
271
  options = themes,
@@ -279,6 +281,7 @@ var ThemeSwitcher = ({
279
281
  variant: "outline",
280
282
  size: "icon",
281
283
  "aria-label": labels.title,
284
+ className,
282
285
  children: [
283
286
  /* @__PURE__ */ jsx3(Sun, {
284
287
  "aria-hidden": "true",
@@ -300,7 +303,7 @@ var ThemeSwitcher = ({
300
303
  })
301
304
  }),
302
305
  /* @__PURE__ */ jsx3(DropdownMenuContent, {
303
- className: "w-32",
306
+ className: cn("w-32", contentClassName),
304
307
  children: /* @__PURE__ */ jsxs2(DropdownMenuGroup, {
305
308
  children: [
306
309
  /* @__PURE__ */ jsx3(DropdownMenuLabel, {
@@ -3528,6 +3528,44 @@ var DataTableBody = ({
3528
3528
  }, row.id))
3529
3529
  });
3530
3530
  };
3531
+ var GalleryImage = ({ src, alt }) => {
3532
+ const [failed, setFailed] = useState(false);
3533
+ if (failed)
3534
+ return null;
3535
+ return /* @__PURE__ */ jsx15("img", {
3536
+ src,
3537
+ alt,
3538
+ loading: "lazy",
3539
+ decoding: "async",
3540
+ className: "aspect-video w-full object-cover",
3541
+ onError: () => setFailed(true)
3542
+ });
3543
+ };
3544
+ var GalleryTag = ({
3545
+ row,
3546
+ column,
3547
+ icon,
3548
+ locale,
3549
+ labels
3550
+ }) => {
3551
+ const value = row.values.get(column.id);
3552
+ if ((value == null || value === "") && !column.colDef.cellRenderer)
3553
+ return null;
3554
+ const content = renderCell(row, column, locale, labels);
3555
+ return column.colDef.cellRenderer || column.colDef.valueFormatter ? /* @__PURE__ */ jsxs9("div", {
3556
+ className: "flex min-w-0 items-center gap-1",
3557
+ children: [
3558
+ icon,
3559
+ content
3560
+ ]
3561
+ }) : /* @__PURE__ */ jsxs9(Badge, {
3562
+ variant: "secondary",
3563
+ children: [
3564
+ icon,
3565
+ content
3566
+ ]
3567
+ });
3568
+ };
3531
3569
  var GalleryCard = ({
3532
3570
  tableAtom
3533
3571
  }) => {
@@ -3538,14 +3576,17 @@ var GalleryCard = ({
3538
3576
  const gallery = store.config.features.gallery;
3539
3577
  if (!row || !gallery)
3540
3578
  return null;
3541
- const find = (id) => id ? model.visibleColumns.find((column) => column.id === id) : undefined;
3579
+ const find = (id) => id ? model.columns.find((column) => column.id === id) : undefined;
3542
3580
  const name = find(gallery.name);
3543
3581
  const description = find(gallery.description);
3544
- const tag = find(gallery.tag);
3582
+ const tagIds = [
3583
+ ...new Set(gallery.tags ?? (gallery.tag ? [gallery.tag] : []))
3584
+ ];
3585
+ const imageSrc = gallery.image?.getSrc(row.data);
3545
3586
  const selection = store.config.features.selection;
3546
3587
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
3547
3588
  const draggable = canDragRows(store);
3548
- return /* @__PURE__ */ jsx15(Card, {
3589
+ return /* @__PURE__ */ jsxs9(Card, {
3549
3590
  className: cn("data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-primary relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=after]:border-b-2 data-[drop-position=before]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
3550
3591
  "data-table-row": row.id,
3551
3592
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -3556,47 +3597,56 @@ var GalleryCard = ({
3556
3597
  }
3557
3598
  },
3558
3599
  tabIndex: store.config.onRowClicked ? 0 : undefined,
3559
- children: /* @__PURE__ */ jsxs9(CardHeader, {
3560
- className: "pr-12",
3561
- children: [
3562
- /* @__PURE__ */ jsxs9("div", {
3563
- className: "flex items-center gap-2",
3564
- children: [
3565
- selection ? /* @__PURE__ */ jsx15(Checkbox, {
3566
- "aria-label": store.config.labels.selectRow,
3567
- checked: !!store.state.rowSelection[row.id],
3568
- disabled: !selectable,
3569
- onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3570
- onClick: (event) => event.stopPropagation()
3571
- }) : null,
3572
- draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3600
+ children: [
3601
+ imageSrc ? /* @__PURE__ */ jsx15(GalleryImage, {
3602
+ src: imageSrc,
3603
+ alt: gallery.image?.getAlt?.(row.data) ?? ""
3604
+ }, imageSrc) : null,
3605
+ /* @__PURE__ */ jsxs9(CardHeader, {
3606
+ className: cn("relative", hasRowActionMenu(store) && "pr-12"),
3607
+ children: [
3608
+ selection || draggable || tagIds.length ? /* @__PURE__ */ jsxs9("div", {
3609
+ className: "flex flex-wrap items-center gap-2",
3610
+ children: [
3611
+ selection ? /* @__PURE__ */ jsx15(Checkbox, {
3612
+ "aria-label": store.config.labels.selectRow,
3613
+ checked: !!store.state.rowSelection[row.id],
3614
+ disabled: !selectable,
3615
+ onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3616
+ onClick: (event) => event.stopPropagation()
3617
+ }) : null,
3618
+ draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3619
+ tableAtom
3620
+ }) : null,
3621
+ tagIds.map((id) => {
3622
+ const column = find(id);
3623
+ return column ? /* @__PURE__ */ jsx15(GalleryTag, {
3624
+ row,
3625
+ column,
3626
+ locale: store.config.locale,
3627
+ labels: store.config.labels,
3628
+ icon: id === gallery.tag ? gallery.tagIcon : undefined
3629
+ }, id) : null;
3630
+ })
3631
+ ]
3632
+ }) : null,
3633
+ /* @__PURE__ */ jsx15(CardTitle, {
3634
+ children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3635
+ }),
3636
+ description ? /* @__PURE__ */ jsx15("div", {
3637
+ className: "text-muted-foreground line-clamp-3 text-sm",
3638
+ children: renderCell(row, description, store.config.locale, store.config.labels)
3639
+ }) : null,
3640
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3641
+ className: "absolute top-0 right-4",
3642
+ onClick: (event) => event.stopPropagation(),
3643
+ children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3573
3644
  tableAtom
3574
- }) : null,
3575
- tag ? /* @__PURE__ */ jsxs9(Badge, {
3576
- variant: "secondary",
3577
- children: [
3578
- gallery.tagIcon,
3579
- renderCell(row, tag, store.config.locale, store.config.labels)
3580
- ]
3581
- }) : null
3582
- ]
3583
- }),
3584
- /* @__PURE__ */ jsx15(CardTitle, {
3585
- children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3586
- }),
3587
- description ? /* @__PURE__ */ jsx15("div", {
3588
- className: "text-muted-foreground line-clamp-3 text-sm",
3589
- children: renderCell(row, description, store.config.locale, store.config.labels)
3590
- }) : null,
3591
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3592
- className: "absolute top-4 right-4",
3593
- onClick: (event) => event.stopPropagation(),
3594
- children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3595
- tableAtom
3596
- })
3597
- }) : null
3598
- ]
3599
- })
3645
+ })
3646
+ }) : null
3647
+ ]
3648
+ })
3649
+ ]
3600
3650
  });
3601
3651
  };
3602
3652
  var DataTableGallery = ({
@@ -3860,6 +3910,7 @@ var DataTable = (props) => {
3860
3910
  schema: DataTablePersistedUiStateSchema,
3861
3911
  defaultValue: () => ({
3862
3912
  ...persistedUiFromState(DEFAULT_UI_STATE),
3913
+ view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
3863
3914
  grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
3864
3915
  })
3865
3916
  });
@@ -3532,6 +3532,44 @@ var DataTableBody = ({
3532
3532
  }, row.id))
3533
3533
  });
3534
3534
  };
3535
+ var GalleryImage = ({ src, alt }) => {
3536
+ const [failed, setFailed] = useState(false);
3537
+ if (failed)
3538
+ return null;
3539
+ return /* @__PURE__ */ jsx15("img", {
3540
+ src,
3541
+ alt,
3542
+ loading: "lazy",
3543
+ decoding: "async",
3544
+ className: "aspect-video w-full object-cover",
3545
+ onError: () => setFailed(true)
3546
+ });
3547
+ };
3548
+ var GalleryTag = ({
3549
+ row,
3550
+ column,
3551
+ icon,
3552
+ locale,
3553
+ labels
3554
+ }) => {
3555
+ const value = row.values.get(column.id);
3556
+ if ((value == null || value === "") && !column.colDef.cellRenderer)
3557
+ return null;
3558
+ const content = renderCell(row, column, locale, labels);
3559
+ return column.colDef.cellRenderer || column.colDef.valueFormatter ? /* @__PURE__ */ jsxs9("div", {
3560
+ className: "flex min-w-0 items-center gap-1",
3561
+ children: [
3562
+ icon,
3563
+ content
3564
+ ]
3565
+ }) : /* @__PURE__ */ jsxs9(Badge, {
3566
+ variant: "secondary",
3567
+ children: [
3568
+ icon,
3569
+ content
3570
+ ]
3571
+ });
3572
+ };
3535
3573
  var GalleryCard = ({
3536
3574
  tableAtom
3537
3575
  }) => {
@@ -3542,14 +3580,17 @@ var GalleryCard = ({
3542
3580
  const gallery = store.config.features.gallery;
3543
3581
  if (!row || !gallery)
3544
3582
  return null;
3545
- const find = (id) => id ? model.visibleColumns.find((column) => column.id === id) : undefined;
3583
+ const find = (id) => id ? model.columns.find((column) => column.id === id) : undefined;
3546
3584
  const name = find(gallery.name);
3547
3585
  const description = find(gallery.description);
3548
- const tag = find(gallery.tag);
3586
+ const tagIds = [
3587
+ ...new Set(gallery.tags ?? (gallery.tag ? [gallery.tag] : []))
3588
+ ];
3589
+ const imageSrc = gallery.image?.getSrc(row.data);
3549
3590
  const selection = store.config.features.selection;
3550
3591
  const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
3551
3592
  const draggable = canDragRows(store);
3552
- return /* @__PURE__ */ jsx15(Card, {
3593
+ return /* @__PURE__ */ jsxs9(Card, {
3553
3594
  className: cn("data-[drop-position=before]:border-t-primary data-[drop-position=after]:border-b-primary relative gap-3 data-[drag-source=true]:opacity-40 data-[drop-position=after]:border-b-2 data-[drop-position=before]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
3554
3595
  "data-table-row": row.id,
3555
3596
  onClick: () => store.config.onRowClicked?.(row.data),
@@ -3560,47 +3601,56 @@ var GalleryCard = ({
3560
3601
  }
3561
3602
  },
3562
3603
  tabIndex: store.config.onRowClicked ? 0 : undefined,
3563
- children: /* @__PURE__ */ jsxs9(CardHeader, {
3564
- className: "pr-12",
3565
- children: [
3566
- /* @__PURE__ */ jsxs9("div", {
3567
- className: "flex items-center gap-2",
3568
- children: [
3569
- selection ? /* @__PURE__ */ jsx15(Checkbox, {
3570
- "aria-label": store.config.labels.selectRow,
3571
- checked: !!store.state.rowSelection[row.id],
3572
- disabled: !selectable,
3573
- onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3574
- onClick: (event) => event.stopPropagation()
3575
- }) : null,
3576
- draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3604
+ children: [
3605
+ imageSrc ? /* @__PURE__ */ jsx15(GalleryImage, {
3606
+ src: imageSrc,
3607
+ alt: gallery.image?.getAlt?.(row.data) ?? ""
3608
+ }, imageSrc) : null,
3609
+ /* @__PURE__ */ jsxs9(CardHeader, {
3610
+ className: cn("relative", hasRowActionMenu(store) && "pr-12"),
3611
+ children: [
3612
+ selection || draggable || tagIds.length ? /* @__PURE__ */ jsxs9("div", {
3613
+ className: "flex flex-wrap items-center gap-2",
3614
+ children: [
3615
+ selection ? /* @__PURE__ */ jsx15(Checkbox, {
3616
+ "aria-label": store.config.labels.selectRow,
3617
+ checked: !!store.state.rowSelection[row.id],
3618
+ disabled: !selectable,
3619
+ onCheckedChange: (checked) => toggleRow(store, setStore, row.id, checked),
3620
+ onClick: (event) => event.stopPropagation()
3621
+ }) : null,
3622
+ draggable ? /* @__PURE__ */ jsx15(DragHandle, {
3623
+ tableAtom
3624
+ }) : null,
3625
+ tagIds.map((id) => {
3626
+ const column = find(id);
3627
+ return column ? /* @__PURE__ */ jsx15(GalleryTag, {
3628
+ row,
3629
+ column,
3630
+ locale: store.config.locale,
3631
+ labels: store.config.labels,
3632
+ icon: id === gallery.tag ? gallery.tagIcon : undefined
3633
+ }, id) : null;
3634
+ })
3635
+ ]
3636
+ }) : null,
3637
+ /* @__PURE__ */ jsx15(CardTitle, {
3638
+ children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3639
+ }),
3640
+ description ? /* @__PURE__ */ jsx15("div", {
3641
+ className: "text-muted-foreground line-clamp-3 text-sm",
3642
+ children: renderCell(row, description, store.config.locale, store.config.labels)
3643
+ }) : null,
3644
+ hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3645
+ className: "absolute top-0 right-4",
3646
+ onClick: (event) => event.stopPropagation(),
3647
+ children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3577
3648
  tableAtom
3578
- }) : null,
3579
- tag ? /* @__PURE__ */ jsxs9(Badge, {
3580
- variant: "secondary",
3581
- children: [
3582
- gallery.tagIcon,
3583
- renderCell(row, tag, store.config.locale, store.config.labels)
3584
- ]
3585
- }) : null
3586
- ]
3587
- }),
3588
- /* @__PURE__ */ jsx15(CardTitle, {
3589
- children: name ? renderCell(row, name, store.config.locale, store.config.labels) : row.id
3590
- }),
3591
- description ? /* @__PURE__ */ jsx15("div", {
3592
- className: "text-muted-foreground line-clamp-3 text-sm",
3593
- children: renderCell(row, description, store.config.locale, store.config.labels)
3594
- }) : null,
3595
- hasRowActionMenu(store) ? /* @__PURE__ */ jsx15("div", {
3596
- className: "absolute top-4 right-4",
3597
- onClick: (event) => event.stopPropagation(),
3598
- children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
3599
- tableAtom
3600
- })
3601
- }) : null
3602
- ]
3603
- })
3649
+ })
3650
+ }) : null
3651
+ ]
3652
+ })
3653
+ ]
3604
3654
  });
3605
3655
  };
3606
3656
  var DataTableGallery = ({
@@ -3864,6 +3914,7 @@ var DataTable = (props) => {
3864
3914
  schema: DataTablePersistedUiStateSchema,
3865
3915
  defaultValue: () => ({
3866
3916
  ...persistedUiFromState(DEFAULT_UI_STATE),
3917
+ view: props.features?.gallery ? props.initialState?.view ?? "table" : "table",
3867
3918
  grouping: props.features?.grouping ? props.features.grouping.initial ?? [] : []
3868
3919
  })
3869
3920
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -412,7 +412,7 @@
412
412
  "@effect/sql-pg": "^4.1.0",
413
413
  "@iconify/react": "^6.0.2",
414
414
  "@inlang/paraglide-js": "^2.19.0",
415
- "@lucas-barake/effect-form": "1.1.0",
415
+ "@lucas-barake/effect-form": "1.1.1",
416
416
  "@lucas-barake/effect-form-react": "1.1.0",
417
417
  "@tanstack/highlight": "^0.0.10",
418
418
  "@tanstack/react-form": "^1.33.0",