@lattice-php/lattice 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action/components/action-form.d.ts +6 -1
- package/dist/action/components/action-form.js +34 -49
- package/dist/action/components/action-form.js.map +1 -1
- package/dist/action/components/action-trigger-provider.d.ts +1 -1
- package/dist/action/components/action-trigger-provider.js.map +1 -1
- package/dist/action/hooks/use-action.d.ts +1 -1
- package/dist/action/hooks/use-action.js +3 -1
- package/dist/action/hooks/use-action.js.map +1 -1
- package/dist/action/index.d.ts +0 -2
- package/dist/action/index.js +1 -2
- package/dist/chat/plugin.d.ts +0 -1
- package/dist/chat/plugin.js.map +1 -1
- package/dist/clipboard/index.d.ts +0 -4
- package/dist/clipboard/index.js +1 -15
- package/dist/{events → core}/event-names.js +1 -1
- package/dist/core/event-names.js.map +1 -0
- package/dist/core/hooks/use-window-event.d.ts +8 -0
- package/dist/core/hooks/use-window-event.js +22 -0
- package/dist/core/hooks/use-window-event.js.map +1 -0
- package/dist/core/index.js +1 -1
- package/dist/core/types.d.ts +8 -61
- package/dist/create-app.d.ts +31 -3
- package/dist/create-app.js +48 -10
- package/dist/create-app.js.map +1 -1
- package/dist/effects/dispatch.js +1 -1
- package/dist/effects/dispatch.js.map +1 -1
- package/dist/effects/registry.d.ts +2 -18
- package/dist/effects/registry.js +5 -9
- package/dist/effects/registry.js.map +1 -1
- package/dist/event-bridge.js +10 -23
- package/dist/event-bridge.js.map +1 -1
- package/dist/form/components/base/field.d.ts +2 -2
- package/dist/form/components/base/field.js +2 -2
- package/dist/form/components/base/field.js.map +1 -1
- package/dist/form/components/fields/color-picker-field.d.ts +2 -0
- package/dist/form/components/fields/color-picker-field.js +57 -0
- package/dist/form/components/fields/color-picker-field.js.map +1 -0
- package/dist/form/components/fields/date-input.js +1 -1
- package/dist/form/components/fields/date-time-input.js +1 -1
- package/dist/form/components/fields/file-upload.js +11 -18
- package/dist/form/components/fields/file-upload.js.map +1 -1
- package/dist/form/components/fields/number-input.js +1 -1
- package/dist/form/components/fields/rich-editor-field.js +35 -276
- package/dist/form/components/fields/rich-editor-field.js.map +1 -1
- package/dist/form/components/fields/row-action-menu.js +2 -2
- package/dist/form/components/fields/row-action-menu.js.map +1 -1
- package/dist/form/components/fields/row-actions.js +3 -1
- package/dist/form/components/fields/row-actions.js.map +1 -1
- package/dist/form/components/fields/select.js +60 -17
- package/dist/form/components/fields/select.js.map +1 -1
- package/dist/form/components/fields/table-rows.js +5 -17
- package/dist/form/components/fields/table-rows.js.map +1 -1
- package/dist/form/components/fields/text-input.js +8 -1
- package/dist/form/components/fields/text-input.js.map +1 -1
- package/dist/form/components/fields/time-input.js +1 -1
- package/dist/form/components/form.js +8 -23
- package/dist/form/components/form.js.map +1 -1
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/components/index.js +2 -1
- package/dist/form/embed.d.ts +5 -0
- package/dist/form/embed.js +4 -1
- package/dist/form/hooks/use-form-resolver.js.map +1 -1
- package/dist/form/index.js +2 -1
- package/dist/form/lib/collect-fields.d.ts +7 -0
- package/dist/form/lib/collect-fields.js +19 -0
- package/dist/form/lib/collect-fields.js.map +1 -0
- package/dist/form/lib/conditions.d.ts +4 -10
- package/dist/form/lib/conditions.js.map +1 -1
- package/dist/form/lib/field-errors.d.ts +3 -0
- package/dist/form/lib/field-errors.js +11 -0
- package/dist/form/lib/field-errors.js.map +1 -0
- package/dist/form/lib/field-props.d.ts +4 -18
- package/dist/form/lib/field-props.js.map +1 -1
- package/dist/form/plugin.js +2 -0
- package/dist/form/plugin.js.map +1 -1
- package/dist/form/rich-editor/builtins.d.ts +6 -0
- package/dist/form/rich-editor/builtins.js +400 -0
- package/dist/form/rich-editor/builtins.js.map +1 -0
- package/dist/form/rich-editor/index.d.ts +7 -0
- package/dist/form/rich-editor/index.js +3 -0
- package/dist/form/rich-editor/registry.d.ts +67 -0
- package/dist/form/rich-editor/registry.js +79 -0
- package/dist/form/rich-editor/registry.js.map +1 -0
- package/dist/form/rich-editor/toolbar-button.d.ts +12 -0
- package/dist/form/rich-editor/toolbar-button.js +28 -0
- package/dist/form/rich-editor/toolbar-button.js.map +1 -0
- package/dist/form/types.d.ts +1 -6
- package/dist/format/date-time.d.ts +3 -2
- package/dist/format/date-time.js.map +1 -1
- package/dist/format/format-context.d.ts +6 -0
- package/dist/format/format-context.js +17 -0
- package/dist/format/format-context.js.map +1 -0
- package/dist/i18n/date-time.d.ts +3 -2
- package/dist/i18n/date-time.js.map +1 -1
- package/dist/i18n/index.js +3 -2
- package/dist/i18n/locale-reload.d.ts +1 -1
- package/dist/i18n/locale-reload.js +7 -6
- package/dist/i18n/locale-reload.js.map +1 -1
- package/dist/i18n/locale.js +1 -1
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/page-props.d.ts +3 -2
- package/dist/i18n/page-props.js +1 -15
- package/dist/i18n/page-props.js.map +1 -1
- package/dist/i18n/shared-props.d.ts +7 -0
- package/dist/i18n/shared-props.js +23 -0
- package/dist/i18n/shared-props.js.map +1 -0
- package/dist/i18n/timezone.js +1 -1
- package/dist/i18n/timezone.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +5 -5
- package/dist/lattice.css +212 -47
- package/dist/layout/components/breadcrumbs.js +3 -1
- package/dist/layout/components/breadcrumbs.js.map +1 -1
- package/dist/layout/components/sidebar.js +15 -48
- package/dist/layout/components/sidebar.js.map +1 -1
- package/dist/layout/plugin.d.ts +0 -1
- package/dist/layout/plugin.js.map +1 -1
- package/dist/lib/color.d.ts +9 -0
- package/dist/lib/color.js +48 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/is-truthy.d.ts +2 -0
- package/dist/lib/is-truthy.js +9 -0
- package/dist/lib/is-truthy.js.map +1 -0
- package/dist/lib/use-debounced-callback.d.ts +10 -0
- package/dist/lib/use-debounced-callback.js +34 -0
- package/dist/lib/use-debounced-callback.js.map +1 -0
- package/dist/lib/use-media-query.d.ts +5 -0
- package/dist/lib/use-media-query.js +26 -0
- package/dist/lib/use-media-query.js.map +1 -0
- package/dist/lib/use-persistent-state.d.ts +13 -0
- package/dist/lib/use-persistent-state.js +62 -0
- package/dist/lib/use-persistent-state.js.map +1 -0
- package/dist/notifications/api.d.ts +6 -6
- package/dist/notifications/api.js.map +1 -1
- package/dist/notifications/components/notifications.js +3 -1
- package/dist/notifications/components/notifications.js.map +1 -1
- package/dist/notifications/plugin.d.ts +0 -1
- package/dist/notifications/plugin.js.map +1 -1
- package/dist/notifications/types.d.ts +2 -10
- package/dist/provider-base.js +1 -1
- package/dist/realtime/build-effects.js +5 -5
- package/dist/realtime/build-effects.js.map +1 -1
- package/dist/realtime/listeners.d.ts +2 -2
- package/dist/realtime/listeners.js +1 -1
- package/dist/realtime/listeners.js.map +1 -1
- package/dist/realtime/subscriptions.d.ts +2 -2
- package/dist/realtime/subscriptions.js.map +1 -1
- package/dist/registry.d.ts +5 -0
- package/dist/registry.js.map +1 -1
- package/dist/remote/components/data-list.js +1 -1
- package/dist/remote/plugin.d.ts +0 -1
- package/dist/remote/plugin.js.map +1 -1
- package/dist/table/components/bulk-bar.js +7 -5
- package/dist/table/components/bulk-bar.js.map +1 -1
- package/dist/table/components/cells/badge-cell.js +4 -1
- package/dist/table/components/cells/badge-cell.js.map +1 -1
- package/dist/table/components/cells/boolean-cell.js +4 -4
- package/dist/table/components/cells/boolean-cell.js.map +1 -1
- package/dist/table/components/cells/copyable-cell.d.ts +9 -0
- package/dist/table/components/cells/copyable-cell.js +17 -0
- package/dist/table/components/cells/copyable-cell.js.map +1 -0
- package/dist/table/components/cells/icon-cell.js +5 -2
- package/dist/table/components/cells/icon-cell.js.map +1 -1
- package/dist/table/components/cells/image-cell.js +8 -9
- package/dist/table/components/cells/image-cell.js.map +1 -1
- package/dist/table/components/cells/money-cell.js +7 -10
- package/dist/table/components/cells/money-cell.js.map +1 -1
- package/dist/table/components/cells/number-cell.js +14 -19
- package/dist/table/components/cells/number-cell.js.map +1 -1
- package/dist/table/components/cells/numeric-cell.d.ts +10 -0
- package/dist/table/components/cells/numeric-cell.js +25 -0
- package/dist/table/components/cells/numeric-cell.js.map +1 -0
- package/dist/table/components/cells/stack-cell.js +1 -1
- package/dist/table/components/cells/text-cell.js +8 -6
- package/dist/table/components/cells/text-cell.js.map +1 -1
- package/dist/table/components/column-filter-control.js +25 -32
- package/dist/table/components/column-filter-control.js.map +1 -1
- package/dist/table/components/column-header.d.ts +3 -3
- package/dist/table/components/column-header.js +5 -3
- package/dist/table/components/column-header.js.map +1 -1
- package/dist/table/components/column-visibility-menu.js +6 -11
- package/dist/table/components/column-visibility-menu.js.map +1 -1
- package/dist/table/components/filter-bar.d.ts +2 -2
- package/dist/table/components/filter-bar.js +13 -22
- package/dist/table/components/filter-bar.js.map +1 -1
- package/dist/table/components/filter-controls.d.ts +2 -1
- package/dist/table/components/filter-controls.js +37 -38
- package/dist/table/components/filter-controls.js.map +1 -1
- package/dist/table/components/filter-value-input.d.ts +0 -1
- package/dist/table/components/filter-value-input.js +21 -20
- package/dist/table/components/filter-value-input.js.map +1 -1
- package/dist/table/components/pagination.js +16 -20
- package/dist/table/components/pagination.js.map +1 -1
- package/dist/table/components/sort-bar.d.ts +3 -3
- package/dist/table/components/sort-bar.js +11 -12
- package/dist/table/components/sort-bar.js.map +1 -1
- package/dist/table/components/table-cell.js.map +1 -1
- package/dist/table/components/table-search.d.ts +9 -0
- package/dist/table/components/table-search.js +72 -0
- package/dist/table/components/table-search.js.map +1 -0
- package/dist/table/components/table.js +73 -21
- package/dist/table/components/table.js.map +1 -1
- package/dist/table/hooks/use-column-visibility.js +29 -58
- package/dist/table/hooks/use-column-visibility.js.map +1 -1
- package/dist/table/hooks/use-expanded-rows.d.ts +8 -0
- package/dist/table/hooks/use-expanded-rows.js +24 -0
- package/dist/table/hooks/use-expanded-rows.js.map +1 -0
- package/dist/table/hooks/use-table.d.ts +5 -3
- package/dist/table/hooks/use-table.js +59 -55
- package/dist/table/hooks/use-table.js.map +1 -1
- package/dist/table/lib/bulk.d.ts +2 -0
- package/dist/table/lib/bulk.js +3 -1
- package/dist/table/lib/bulk.js.map +1 -1
- package/dist/table/lib/payload.d.ts +3 -2
- package/dist/table/lib/payload.js +16 -10
- package/dist/table/lib/payload.js.map +1 -1
- package/dist/table/lib/query.d.ts +5 -5
- package/dist/table/lib/query.js +21 -19
- package/dist/table/lib/query.js.map +1 -1
- package/dist/table/plugin.d.ts +0 -1
- package/dist/table/plugin.js.map +1 -1
- package/dist/table/types.d.ts +5 -81
- package/dist/toast/callout.js +2 -4
- package/dist/toast/callout.js.map +1 -1
- package/dist/toast/index.d.ts +1 -1
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +1 -7
- package/dist/toast/toast.js +3 -15
- package/dist/toast/toast.js.map +1 -1
- package/dist/toast/toaster.js.map +1 -1
- package/dist/types/generated.d.ts +444 -225
- package/dist/types/index.d.ts +1 -1
- package/dist/ui/affix-group.d.ts +2 -1
- package/dist/ui/affix-group.js +9 -7
- package/dist/ui/affix-group.js.map +1 -1
- package/dist/ui/avatar.d.ts +3 -0
- package/dist/ui/avatar.js +52 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/button.d.ts +5 -3
- package/dist/ui/button.js +10 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/chart-view.js +155 -28
- package/dist/ui/chart-view.js.map +1 -1
- package/dist/ui/click-behavior.d.ts +4 -4
- package/dist/ui/click-behavior.js.map +1 -1
- package/dist/ui/collapsible.js +3 -15
- package/dist/ui/collapsible.js.map +1 -1
- package/dist/ui/color-picker.d.ts +8 -0
- package/dist/ui/color-picker.js +59 -0
- package/dist/ui/color-picker.js.map +1 -0
- package/dist/ui/combobox.d.ts +11 -2
- package/dist/ui/combobox.js +57 -11
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/confirm-dialog.js +1 -1
- package/dist/ui/confirm-dialog.js.map +1 -1
- package/dist/ui/control.d.ts +1 -1
- package/dist/ui/copyable-text.d.ts +7 -0
- package/dist/ui/copyable-text.js +21 -13
- package/dist/ui/copyable-text.js.map +1 -1
- package/dist/ui/dialog.d.ts +6 -2
- package/dist/ui/dialog.js +29 -5
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/fragment.js +1 -1
- package/dist/ui/fragment.js.map +1 -1
- package/dist/ui/heading.js +39 -21
- package/dist/ui/heading.js.map +1 -1
- package/dist/ui/icon-button.d.ts +22 -0
- package/dist/ui/icon-button.js +51 -0
- package/dist/ui/icon-button.js.map +1 -0
- package/dist/ui/icon.js +10 -11
- package/dist/ui/icon.js.map +1 -1
- package/dist/ui/image-preview.d.ts +12 -0
- package/dist/ui/image-preview.js +65 -0
- package/dist/ui/image-preview.js.map +1 -0
- package/dist/ui/image.d.ts +3 -0
- package/dist/ui/image.js +21 -0
- package/dist/ui/image.js.map +1 -0
- package/dist/ui/index.d.ts +2 -1
- package/dist/ui/index.js +4 -3
- package/dist/ui/info-tooltip.js +1 -1
- package/dist/ui/info-tooltip.js.map +1 -1
- package/dist/ui/input.d.ts +3 -1
- package/dist/ui/input.js +2 -2
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/modal.js +17 -4
- package/dist/ui/modal.js.map +1 -1
- package/dist/ui/native-select.d.ts +10 -0
- package/dist/ui/native-select.js +23 -0
- package/dist/ui/native-select.js.map +1 -0
- package/dist/ui/pill.d.ts +2 -0
- package/dist/ui/pill.js +10 -0
- package/dist/ui/pill.js.map +1 -0
- package/dist/ui/plugin.js +11 -1
- package/dist/ui/plugin.js.map +1 -1
- package/dist/ui/progress.d.ts +3 -0
- package/dist/ui/progress.js +114 -0
- package/dist/ui/progress.js.map +1 -0
- package/dist/ui/section.js +2 -15
- package/dist/ui/section.js.map +1 -1
- package/dist/ui/segmented-pills.js +2 -1
- package/dist/ui/segmented-pills.js.map +1 -1
- package/dist/ui/separator.d.ts +3 -0
- package/dist/ui/separator.js +15 -0
- package/dist/ui/separator.js.map +1 -0
- package/dist/ui/tabs.js +12 -10
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/text.js +5 -10
- package/dist/ui/text.js.map +1 -1
- package/dist/ui/tree-context.d.ts +33 -0
- package/dist/ui/tree-context.js +135 -0
- package/dist/ui/tree-context.js.map +1 -0
- package/dist/ui/tree.d.ts +19 -0
- package/dist/ui/tree.js +187 -0
- package/dist/ui/tree.js.map +1 -0
- package/dist/ui/use-collapsible-state.d.ts +7 -0
- package/dist/ui/use-collapsible-state.js +21 -0
- package/dist/ui/use-collapsible-state.js.map +1 -0
- package/dist-standalone/chunks/chart-view-C6R5iPra.js +36 -0
- package/dist-standalone/chunks/date-picker-field-DhhEB-Mh.js +1 -0
- package/dist-standalone/chunks/jsx-runtime-Drll_-DD.js +1 -0
- package/dist-standalone/chunks/locale-CXqr7LPR.js +1 -0
- package/dist-standalone/chunks/page-props-DOfg30l5.js +1 -0
- package/dist-standalone/chunks/rich-editor-field-DORXTHPw.js +154 -0
- package/dist-standalone/chunks/{subscriptions-B3UuDBmx.js → subscriptions-B_ISgA7V.js} +1 -1
- package/dist-standalone/chunks/use-effect-dispatcher-D1wPPwHj.js +97 -0
- package/dist-standalone/lattice.css +1 -1
- package/dist-standalone/lattice.js +15 -15
- package/dist-standalone/manifest.json +11 -9
- package/dist-standalone/sprite.svg +1 -1
- package/package.json +6 -1
- package/resources/icons/code-xml.svg +17 -0
- package/resources/icons/heading.svg +17 -0
- package/dist/clipboard/index.js.map +0 -1
- package/dist/events/event-names.js.map +0 -1
- package/dist/table/components/table-action-node.d.ts +0 -4
- package/dist/table/components/table-action-node.js +0 -24
- package/dist/table/components/table-action-node.js.map +0 -1
- package/dist-standalone/chunks/chart-view-CK5fKIkR.js +0 -36
- package/dist-standalone/chunks/date-picker-field-BlCPFhZd.js +0 -1
- package/dist-standalone/chunks/jsx-runtime-CJ_btYLc.js +0 -1
- package/dist-standalone/chunks/rich-editor-field-DH5dS5c1.js +0 -154
- package/dist-standalone/chunks/use-effect-dispatcher-k98Nzf9M.js +0 -97
- /package/dist/{events → core}/event-names.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-media-query.js","names":[],"sources":["../../resources/js/lib/use-media-query.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nfunction matches(query: string, fallback: boolean): boolean {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return fallback;\n }\n\n return window.matchMedia(query).matches;\n}\n\n/**\n * Track a CSS media query. `fallback` is the SSR / no-`matchMedia` value and the\n * initial state before the effect subscribes.\n */\nexport function useMediaQuery(query: string, fallback = false): boolean {\n const [state, setState] = useState(() => matches(query, fallback));\n\n useEffect(() => {\n if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") {\n return;\n }\n\n const media = window.matchMedia(query);\n const update = (): void => setState(media.matches);\n\n update();\n media.addEventListener(\"change\", update);\n\n return () => media.removeEventListener(\"change\", update);\n }, [query]);\n\n return state;\n}\n"],"mappings":";;AAEA,SAAS,QAAQ,OAAe,UAA4B;CAC1D,IAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAChE,OAAO;CAGT,OAAO,OAAO,WAAW,KAAK,EAAE;AAClC;;;;;AAMA,SAAgB,cAAc,OAAe,WAAW,OAAgB;CACtE,MAAM,CAAC,OAAO,YAAY,eAAe,QAAQ,OAAO,QAAQ,CAAC;CAEjE,gBAAgB;EACd,IAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAChE;EAGF,MAAM,QAAQ,OAAO,WAAW,KAAK;EACrC,MAAM,eAAqB,SAAS,MAAM,OAAO;EAEjD,OAAO;EACP,MAAM,iBAAiB,UAAU,MAAM;EAEvC,aAAa,MAAM,oBAAoB,UAAU,MAAM;CACzD,GAAG,CAAC,KAAK,CAAC;CAEV,OAAO;AACT"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
export type PersistentStateOptions<T> = {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
parse?: (raw: string) => T;
|
|
5
|
+
serialize?: (value: T) => string | null;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* `useState` backed by `localStorage`. The SSR guard and read/write `try/catch`
|
|
9
|
+
* live here once; `parse`/`serialize` default to JSON. Persistence happens in
|
|
10
|
+
* the setter (not inside the state updater), so a StrictMode double-invoke never
|
|
11
|
+
* double-writes, and a `serialize` returning `null` removes the key.
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePersistentState<T>(key: string, fallback: T | (() => T), options?: PersistentStateOptions<T>): [T, Dispatch<SetStateAction<T>>];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
//#region resources/js/lib/use-persistent-state.ts
|
|
3
|
+
/**
|
|
4
|
+
* `useState` backed by `localStorage`. The SSR guard and read/write `try/catch`
|
|
5
|
+
* live here once; `parse`/`serialize` default to JSON. Persistence happens in
|
|
6
|
+
* the setter (not inside the state updater), so a StrictMode double-invoke never
|
|
7
|
+
* double-writes, and a `serialize` returning `null` removes the key.
|
|
8
|
+
*/
|
|
9
|
+
function usePersistentState(key, fallback, options = {}) {
|
|
10
|
+
const { enabled = true, parse, serialize } = options;
|
|
11
|
+
const resolveFallback = () => typeof fallback === "function" ? fallback() : fallback;
|
|
12
|
+
const [value, setValue] = useState(() => {
|
|
13
|
+
if (!enabled || typeof window === "undefined") return resolveFallback();
|
|
14
|
+
let raw;
|
|
15
|
+
try {
|
|
16
|
+
raw = window.localStorage.getItem(key);
|
|
17
|
+
} catch {
|
|
18
|
+
return resolveFallback();
|
|
19
|
+
}
|
|
20
|
+
if (raw === null) return resolveFallback();
|
|
21
|
+
try {
|
|
22
|
+
return parse ? parse(raw) : JSON.parse(raw);
|
|
23
|
+
} catch {
|
|
24
|
+
try {
|
|
25
|
+
window.localStorage.removeItem(key);
|
|
26
|
+
} catch {
|
|
27
|
+
return resolveFallback();
|
|
28
|
+
}
|
|
29
|
+
return resolveFallback();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const valueRef = useRef(value);
|
|
33
|
+
valueRef.current = value;
|
|
34
|
+
const persistRef = useRef({
|
|
35
|
+
enabled,
|
|
36
|
+
key,
|
|
37
|
+
serialize
|
|
38
|
+
});
|
|
39
|
+
persistRef.current = {
|
|
40
|
+
enabled,
|
|
41
|
+
key,
|
|
42
|
+
serialize
|
|
43
|
+
};
|
|
44
|
+
return [value, useCallback((action) => {
|
|
45
|
+
const next = typeof action === "function" ? action(valueRef.current) : action;
|
|
46
|
+
valueRef.current = next;
|
|
47
|
+
setValue(next);
|
|
48
|
+
const { enabled: on, key: storageKey, serialize: encode } = persistRef.current;
|
|
49
|
+
if (!on || typeof window === "undefined") return;
|
|
50
|
+
try {
|
|
51
|
+
const encoded = encode ? encode(next) : JSON.stringify(next);
|
|
52
|
+
if (encoded === null) window.localStorage.removeItem(storageKey);
|
|
53
|
+
else window.localStorage.setItem(storageKey, encoded);
|
|
54
|
+
} catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}, [])];
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { usePersistentState };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=use-persistent-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-persistent-state.js","names":[],"sources":["../../resources/js/lib/use-persistent-state.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from \"react\";\nimport { useCallback, useRef, useState } from \"react\";\n\nexport type PersistentStateOptions<T> = {\n enabled?: boolean;\n parse?: (raw: string) => T;\n serialize?: (value: T) => string | null;\n};\n\n/**\n * `useState` backed by `localStorage`. The SSR guard and read/write `try/catch`\n * live here once; `parse`/`serialize` default to JSON. Persistence happens in\n * the setter (not inside the state updater), so a StrictMode double-invoke never\n * double-writes, and a `serialize` returning `null` removes the key.\n */\nexport function usePersistentState<T>(\n key: string,\n fallback: T | (() => T),\n options: PersistentStateOptions<T> = {},\n): [T, Dispatch<SetStateAction<T>>] {\n const { enabled = true, parse, serialize } = options;\n\n const resolveFallback = (): T =>\n typeof fallback === \"function\" ? (fallback as () => T)() : fallback;\n\n const [value, setValue] = useState<T>(() => {\n if (!enabled || typeof window === \"undefined\") {\n return resolveFallback();\n }\n\n let raw: string | null;\n try {\n raw = window.localStorage.getItem(key);\n } catch {\n return resolveFallback();\n }\n\n if (raw === null) {\n return resolveFallback();\n }\n\n try {\n return parse ? parse(raw) : (JSON.parse(raw) as T);\n } catch {\n // Drop corrupt data so it cannot resurface on the next read.\n try {\n window.localStorage.removeItem(key);\n } catch {\n return resolveFallback();\n }\n\n return resolveFallback();\n }\n });\n\n const valueRef = useRef(value);\n valueRef.current = value;\n\n const persistRef = useRef({ enabled, key, serialize });\n persistRef.current = { enabled, key, serialize };\n\n const setPersistentValue = useCallback<Dispatch<SetStateAction<T>>>((action) => {\n const next =\n typeof action === \"function\" ? (action as (prev: T) => T)(valueRef.current) : action;\n\n valueRef.current = next;\n setValue(next);\n\n const { enabled: on, key: storageKey, serialize: encode } = persistRef.current;\n\n if (!on || typeof window === \"undefined\") {\n return;\n }\n\n try {\n const encoded = encode ? encode(next) : JSON.stringify(next);\n\n if (encoded === null) {\n window.localStorage.removeItem(storageKey);\n } else {\n window.localStorage.setItem(storageKey, encoded);\n }\n } catch {\n return;\n }\n }, []);\n\n return [value, setPersistentValue];\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,mBACd,KACA,UACA,UAAqC,CAAC,GACJ;CAClC,MAAM,EAAE,UAAU,MAAM,OAAO,cAAc;CAE7C,MAAM,wBACJ,OAAO,aAAa,aAAc,SAAqB,IAAI;CAE7D,MAAM,CAAC,OAAO,YAAY,eAAkB;EAC1C,IAAI,CAAC,WAAW,OAAO,WAAW,aAChC,OAAO,gBAAgB;EAGzB,IAAI;EACJ,IAAI;GACF,MAAM,OAAO,aAAa,QAAQ,GAAG;EACvC,QAAQ;GACN,OAAO,gBAAgB;EACzB;EAEA,IAAI,QAAQ,MACV,OAAO,gBAAgB;EAGzB,IAAI;GACF,OAAO,QAAQ,MAAM,GAAG,IAAK,KAAK,MAAM,GAAG;EAC7C,QAAQ;GAEN,IAAI;IACF,OAAO,aAAa,WAAW,GAAG;GACpC,QAAQ;IACN,OAAO,gBAAgB;GACzB;GAEA,OAAO,gBAAgB;EACzB;CACF,CAAC;CAED,MAAM,WAAW,OAAO,KAAK;CAC7B,SAAS,UAAU;CAEnB,MAAM,aAAa,OAAO;EAAE;EAAS;EAAK;CAAU,CAAC;CACrD,WAAW,UAAU;EAAE;EAAS;EAAK;CAAU;CA4B/C,OAAO,CAAC,OA1BmB,aAA0C,WAAW;EAC9E,MAAM,OACJ,OAAO,WAAW,aAAc,OAA0B,SAAS,OAAO,IAAI;EAEhF,SAAS,UAAU;EACnB,SAAS,IAAI;EAEb,MAAM,EAAE,SAAS,IAAI,KAAK,YAAY,WAAW,WAAW,WAAW;EAEvE,IAAI,CAAC,MAAM,OAAO,WAAW,aAC3B;EAGF,IAAI;GACF,MAAM,UAAU,SAAS,OAAO,IAAI,IAAI,KAAK,UAAU,IAAI;GAE3D,IAAI,YAAY,MACd,OAAO,aAAa,WAAW,UAAU;QAEzC,OAAO,aAAa,QAAQ,YAAY,OAAO;EAEnD,QAAQ;GACN;EACF;CACF,GAAG,CAAC,CAEW,CAAkB;AACnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function fetchNotifications(endpoint: string, page?: number): Promise<
|
|
3
|
-
export declare function markRead(endpoint: string, id: string): Promise<
|
|
4
|
-
export declare function markAllRead(endpoint: string): Promise<
|
|
5
|
-
export declare function dismiss(endpoint: string, id: string): Promise<
|
|
6
|
-
export declare function clearAll(endpoint: string): Promise<
|
|
1
|
+
import { NotificationList, UnreadCount } from './types.js';
|
|
2
|
+
export declare function fetchNotifications(endpoint: string, page?: number): Promise<NotificationList>;
|
|
3
|
+
export declare function markRead(endpoint: string, id: string): Promise<UnreadCount>;
|
|
4
|
+
export declare function markAllRead(endpoint: string): Promise<UnreadCount>;
|
|
5
|
+
export declare function dismiss(endpoint: string, id: string): Promise<UnreadCount>;
|
|
6
|
+
export declare function clearAll(endpoint: string): Promise<UnreadCount>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../resources/js/notifications/api.ts"],"sourcesContent":["import { apiJson } from \"@lattice-php/lattice/core/api\";\nimport type {
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../resources/js/notifications/api.ts"],"sourcesContent":["import { apiJson } from \"@lattice-php/lattice/core/api\";\nimport type { NotificationList, UnreadCount } from \"./types\";\n\nexport function fetchNotifications(endpoint: string, page = 1): Promise<NotificationList> {\n return apiJson<NotificationList>(`${endpoint}?page=${page}`);\n}\n\nexport function markRead(endpoint: string, id: string): Promise<UnreadCount> {\n return apiJson<UnreadCount>(`${endpoint}/${id}/read`, { method: \"PATCH\" });\n}\n\nexport function markAllRead(endpoint: string): Promise<UnreadCount> {\n return apiJson<UnreadCount>(`${endpoint}/read-all`, { method: \"POST\" });\n}\n\nexport function dismiss(endpoint: string, id: string): Promise<UnreadCount> {\n return apiJson<UnreadCount>(`${endpoint}/${id}`, { method: \"DELETE\" });\n}\n\nexport function clearAll(endpoint: string): Promise<UnreadCount> {\n return apiJson<UnreadCount>(endpoint, { method: \"DELETE\" });\n}\n"],"mappings":";;AAGA,SAAgB,mBAAmB,UAAkB,OAAO,GAA8B;CACxF,OAAO,QAA0B,GAAG,SAAS,QAAQ,MAAM;AAC7D;AAEA,SAAgB,SAAS,UAAkB,IAAkC;CAC3E,OAAO,QAAqB,GAAG,SAAS,GAAG,GAAG,QAAQ,EAAE,QAAQ,QAAQ,CAAC;AAC3E;AAEA,SAAgB,YAAY,UAAwC;CAClE,OAAO,QAAqB,GAAG,SAAS,YAAY,EAAE,QAAQ,OAAO,CAAC;AACxE;AAEA,SAAgB,QAAQ,UAAkB,IAAkC;CAC1E,OAAO,QAAqB,GAAG,SAAS,GAAG,MAAM,EAAE,QAAQ,SAAS,CAAC;AACvE;AAEA,SAAgB,SAAS,UAAwC;CAC/D,OAAO,QAAqB,UAAU,EAAE,QAAQ,SAAS,CAAC;AAC5D"}
|
|
@@ -79,7 +79,9 @@ var NotificationsComponent = ({ node }) => {
|
|
|
79
79
|
open: store.open,
|
|
80
80
|
onOpenChange: store.setOpen,
|
|
81
81
|
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
82
|
-
className: "
|
|
82
|
+
className: "p-0",
|
|
83
|
+
placement: "end",
|
|
84
|
+
width: "sm",
|
|
83
85
|
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
84
86
|
className: "sr-only",
|
|
85
87
|
children: label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.js","names":[],"sources":["../../../resources/js/notifications/components/notifications.tsx"],"sourcesContent":["import { Component, lazy, Suspense, type ReactNode } from \"react\";\nimport { Badge } from \"@lattice-php/lattice/ui/badge\";\nimport { Dialog, DialogContent, DialogTitle } from \"@lattice-php/lattice/ui/dialog\";\nimport {\n Popover as PopoverRoot,\n PopoverContent,\n PopoverTrigger,\n} from \"@lattice-php/lattice/ui/popover\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useNotifications } from \"@lattice-php/lattice/notifications/store\";\nimport type { NotificationItem } from \"@lattice-php/lattice/notifications/types\";\nimport { NotificationList } from \"./notification-list\";\n\nconst NotificationsEcho = lazy(() =>\n import(\"./notifications-echo\").then((m) => ({ default: m.NotificationsEcho })),\n);\n\nclass EchoBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n componentDidCatch(): void {\n console.warn(\n \"[lattice] The notifications bell declares a realtime channel but Echo is unavailable. Install @laravel/echo-react and call configureEcho().\",\n );\n }\n\n render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\nconst NotificationsComponent: RendererComponent<\"notifications\"> = ({ node }) => {\n const { t } = useT(\"lattice\");\n const store = useNotifications({\n endpoint: node.props.endpoint,\n pollingInterval: node.props.pollingInterval,\n });\n\n const label = t(\"notifications.label\", \"Notifications\");\n\n const trigger = (\n <span className=\"relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted\">\n <Icon name=\"bell\" className=\"size-lt-icon-md\" />\n {store.unreadCount > 0 ? (\n <Badge\n variant=\"destructive\"\n data-test=\"notifications-badge\"\n className=\"absolute -right-0.5 -top-0.5 min-w-4 px-1 py-0 text-[10px]\"\n >\n {store.unreadCount}\n </Badge>\n ) : null}\n </span>\n );\n\n const panel = (\n <div className=\"w-80\" data-test=\"notifications-panel\">\n <div className=\"flex items-center justify-between border-b border-lt-border px-3 py-2\">\n <span className=\"text-sm font-medium\">{t(\"notifications.heading\", \"Notifications\")}</span>\n {store.unreadCount > 0 ? (\n <button\n type=\"button\"\n className=\"text-xs text-lt-muted-fg hover:text-lt-fg\"\n onClick={store.markAllRead}\n >\n {t(\"notifications.mark-all-read\", \"Mark all read\")}\n </button>\n ) : null}\n </div>\n <NotificationList\n notifications={store.notifications}\n status={store.status}\n hasMore={store.hasMore}\n onMarkRead={store.markRead}\n onDismiss={store.dismiss}\n onLoadMore={store.loadMore}\n />\n </div>\n );\n\n return (\n <>\n {node.props.channel ? (\n <EchoBoundary>\n <Suspense fallback={null}>\n <NotificationsEcho\n channel={node.props.channel}\n onReceive={(item: NotificationItem) => store.receive(item)}\n />\n </Suspense>\n </EchoBoundary>\n ) : null}\n\n {node.props.slideOut ? (\n <>\n <button\n type=\"button\"\n aria-label={label}\n data-test=\"notifications-trigger\"\n onClick={() => store.setOpen(true)}\n >\n {trigger}\n </button>\n <Dialog open={store.open} onOpenChange={store.setOpen}>\n <DialogContent className=\"
|
|
1
|
+
{"version":3,"file":"notifications.js","names":[],"sources":["../../../resources/js/notifications/components/notifications.tsx"],"sourcesContent":["import { Component, lazy, Suspense, type ReactNode } from \"react\";\nimport { Badge } from \"@lattice-php/lattice/ui/badge\";\nimport { Dialog, DialogContent, DialogTitle } from \"@lattice-php/lattice/ui/dialog\";\nimport {\n Popover as PopoverRoot,\n PopoverContent,\n PopoverTrigger,\n} from \"@lattice-php/lattice/ui/popover\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useNotifications } from \"@lattice-php/lattice/notifications/store\";\nimport type { NotificationItem } from \"@lattice-php/lattice/notifications/types\";\nimport { NotificationList } from \"./notification-list\";\n\nconst NotificationsEcho = lazy(() =>\n import(\"./notifications-echo\").then((m) => ({ default: m.NotificationsEcho })),\n);\n\nclass EchoBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n componentDidCatch(): void {\n console.warn(\n \"[lattice] The notifications bell declares a realtime channel but Echo is unavailable. Install @laravel/echo-react and call configureEcho().\",\n );\n }\n\n render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\nconst NotificationsComponent: RendererComponent<\"notifications\"> = ({ node }) => {\n const { t } = useT(\"lattice\");\n const store = useNotifications({\n endpoint: node.props.endpoint,\n pollingInterval: node.props.pollingInterval,\n });\n\n const label = t(\"notifications.label\", \"Notifications\");\n\n const trigger = (\n <span className=\"relative inline-flex items-center justify-center rounded-lt-sm p-2 hover:bg-lt-muted\">\n <Icon name=\"bell\" className=\"size-lt-icon-md\" />\n {store.unreadCount > 0 ? (\n <Badge\n variant=\"destructive\"\n data-test=\"notifications-badge\"\n className=\"absolute -right-0.5 -top-0.5 min-w-4 px-1 py-0 text-[10px]\"\n >\n {store.unreadCount}\n </Badge>\n ) : null}\n </span>\n );\n\n const panel = (\n <div className=\"w-80\" data-test=\"notifications-panel\">\n <div className=\"flex items-center justify-between border-b border-lt-border px-3 py-2\">\n <span className=\"text-sm font-medium\">{t(\"notifications.heading\", \"Notifications\")}</span>\n {store.unreadCount > 0 ? (\n <button\n type=\"button\"\n className=\"text-xs text-lt-muted-fg hover:text-lt-fg\"\n onClick={store.markAllRead}\n >\n {t(\"notifications.mark-all-read\", \"Mark all read\")}\n </button>\n ) : null}\n </div>\n <NotificationList\n notifications={store.notifications}\n status={store.status}\n hasMore={store.hasMore}\n onMarkRead={store.markRead}\n onDismiss={store.dismiss}\n onLoadMore={store.loadMore}\n />\n </div>\n );\n\n return (\n <>\n {node.props.channel ? (\n <EchoBoundary>\n <Suspense fallback={null}>\n <NotificationsEcho\n channel={node.props.channel}\n onReceive={(item: NotificationItem) => store.receive(item)}\n />\n </Suspense>\n </EchoBoundary>\n ) : null}\n\n {node.props.slideOut ? (\n <>\n <button\n type=\"button\"\n aria-label={label}\n data-test=\"notifications-trigger\"\n onClick={() => store.setOpen(true)}\n >\n {trigger}\n </button>\n <Dialog open={store.open} onOpenChange={store.setOpen}>\n <DialogContent className=\"p-0\" placement=\"end\" width=\"sm\">\n <DialogTitle className=\"sr-only\">{label}</DialogTitle>\n {panel}\n </DialogContent>\n </Dialog>\n </>\n ) : (\n <PopoverRoot open={store.open} onOpenChange={store.setOpen}>\n <PopoverTrigger asChild>\n <button type=\"button\" aria-label={label} data-test=\"notifications-trigger\">\n {trigger}\n </button>\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"p-0\">\n {panel}\n </PopoverContent>\n </PopoverRoot>\n )}\n </>\n );\n};\n\nexport default NotificationsComponent;\n"],"mappings":";;;;;;;;;;AAeA,IAAM,oBAAoB,WACxB,OAAO,2BAAwB,MAAM,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAC/E;AAEA,IAAM,eAAN,cAA2B,UAAwD;CACjF,QAAQ,EAAE,QAAQ,MAAM;CAExB,OAAO,2BAAgD;EACrD,OAAO,EAAE,QAAQ,KAAK;CACxB;CAEA,oBAA0B;EACxB,QAAQ,KACN,6IACF;CACF;CAEA,SAAoB;EAClB,OAAO,KAAK,MAAM,SAAS,OAAO,KAAK,MAAM;CAC/C;AACF;AAEA,IAAM,0BAA8D,EAAE,WAAW;CAC/E,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,QAAQ,iBAAiB;EAC7B,UAAU,KAAK,MAAM;EACrB,iBAAiB,KAAK,MAAM;CAC9B,CAAC;CAED,MAAM,QAAQ,EAAE,uBAAuB,eAAe;CAEtD,MAAM,UACJ,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,oBAAC,MAAD;GAAM,MAAK;GAAO,WAAU;EAAmB,CAAA,GAC9C,MAAM,cAAc,IACnB,oBAAC,OAAD;GACE,SAAQ;GACR,aAAU;GACV,WAAU;aAET,MAAM;EACF,CAAA,IACL,IACA;;CAGR,MAAM,QACJ,qBAAC,OAAD;EAAK,WAAU;EAAO,aAAU;YAAhC,CACE,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,oBAAC,QAAD;IAAM,WAAU;cAAuB,EAAE,yBAAyB,eAAe;GAAQ,CAAA,GACxF,MAAM,cAAc,IACnB,oBAAC,UAAD;IACE,MAAK;IACL,WAAU;IACV,SAAS,MAAM;cAEd,EAAE,+BAA+B,eAAe;GAC3C,CAAA,IACN,IACD;MACL,oBAAC,kBAAD;GACE,eAAe,MAAM;GACrB,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,YAAY,MAAM;GAClB,WAAW,MAAM;GACjB,YAAY,MAAM;EACnB,CAAA,CACE;;CAGP,OACE,qBAAA,YAAA,EAAA,UAAA,CACG,KAAK,MAAM,UACV,oBAAC,cAAD,EAAA,UACE,oBAAC,UAAD;EAAU,UAAU;YAClB,oBAAC,mBAAD;GACE,SAAS,KAAK,MAAM;GACpB,YAAY,SAA2B,MAAM,QAAQ,IAAI;EAC1D,CAAA;CACO,CAAA,EACE,CAAA,IACZ,MAEH,KAAK,MAAM,WACV,qBAAA,YAAA,EAAA,UAAA,CACE,oBAAC,UAAD;EACE,MAAK;EACL,cAAY;EACZ,aAAU;EACV,eAAe,MAAM,QAAQ,IAAI;YAEhC;CACK,CAAA,GACR,oBAAC,QAAD;EAAQ,MAAM,MAAM;EAAM,cAAc,MAAM;YAC5C,qBAAC,eAAD;GAAe,WAAU;GAAM,WAAU;GAAM,OAAM;aAArD,CACE,oBAAC,aAAD;IAAa,WAAU;cAAW;GAAmB,CAAA,GACpD,KACY;;CACT,CAAA,CACR,EAAA,CAAA,IAEF,qBAAC,SAAD;EAAa,MAAM,MAAM;EAAM,cAAc,MAAM;YAAnD,CACE,oBAAC,gBAAD;GAAgB,SAAA;aACd,oBAAC,UAAD;IAAQ,MAAK;IAAS,cAAY;IAAO,aAAU;cAChD;GACK,CAAA;EACM,CAAA,GAChB,oBAAC,gBAAD;GAAgB,OAAM;GAAM,WAAU;aACnC;EACa,CAAA,CACL;GAEf,EAAA,CAAA;AAEN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../../resources/js/notifications/plugin.ts"],"sourcesContent":["import {\n createPlugin,\n eagerComponent,\n type ComponentRegistryFor,\n} from \"@lattice-php/lattice/core/registry\";\nimport
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../../resources/js/notifications/plugin.ts"],"sourcesContent":["import {\n createPlugin,\n eagerComponent,\n type ComponentRegistryFor,\n} from \"@lattice-php/lattice/core/registry\";\nimport type { NotificationNodeType } from \"@lattice-php/lattice/types/generated\";\nimport NotificationsComponent from \"./components/notifications\";\n\nexport const notificationsComponents = createPlugin({\n name: \"lattice/notifications\",\n components: {\n notifications: eagerComponent(NotificationsComponent),\n } satisfies ComponentRegistryFor<NotificationNodeType>,\n});\n"],"mappings":";;;AAQA,IAAa,0BAA0B,aAAa;CAClD,MAAM;CACN,YAAY,EACV,eAAe,eAAe,sBAAsB,EACtD;AACF,CAAC"}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
import { NotificationItem } from '../types/generated.js';
|
|
2
|
-
export type { NotificationItem };
|
|
3
|
-
export type NotificationsResponse = {
|
|
4
|
-
notifications: NotificationItem[];
|
|
5
|
-
unreadCount: number;
|
|
6
|
-
hasMore: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type UnreadCountResponse = {
|
|
9
|
-
unreadCount: number;
|
|
10
|
-
};
|
|
1
|
+
import { NotificationItem, NotificationList, UnreadCount } from '../types/generated.js';
|
|
2
|
+
export type { NotificationItem, NotificationList, UnreadCount };
|
package/dist/provider-base.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { updateAppearance } from "./appearance/index.js";
|
|
2
2
|
import { RegistryContext } from "./core/registry-context.js";
|
|
3
3
|
import { SpriteProvider } from "./icons/sprite.js";
|
|
4
|
-
import { EventBridge } from "./event-bridge.js";
|
|
5
4
|
import { Toaster } from "./toast/toaster.js";
|
|
6
5
|
import { ActionInteractionProvider } from "./action/components/action-trigger-provider.js";
|
|
7
6
|
import { useFlashEffects } from "./effects/use-flash-effects.js";
|
|
7
|
+
import { EventBridge } from "./event-bridge.js";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
//#region resources/js/provider-base.tsx
|
|
10
10
|
var defaultSprite = { href: "" };
|
|
@@ -5,14 +5,14 @@ function buildEffects(effects, payload, t) {
|
|
|
5
5
|
}
|
|
6
6
|
function resolveEffect(effect, payload, t) {
|
|
7
7
|
if (effect.type !== "toast") return effect;
|
|
8
|
-
const
|
|
9
|
-
if (typeof
|
|
10
|
-
const message =
|
|
8
|
+
const props = effect.props;
|
|
9
|
+
if (typeof props !== "object" || props === null) return effect;
|
|
10
|
+
const message = props.message;
|
|
11
11
|
if (!isTranslatable(message)) return effect;
|
|
12
12
|
return {
|
|
13
13
|
...effect,
|
|
14
|
-
|
|
15
|
-
...
|
|
14
|
+
props: {
|
|
15
|
+
...props,
|
|
16
16
|
message: resolveTranslatable(message, payload, t)
|
|
17
17
|
}
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-effects.js","names":[],"sources":["../../resources/js/realtime/build-effects.ts"],"sourcesContent":["import type { Effect } from \"@lattice-php/lattice/types/generated\";\nimport { isTranslatable, resolveTranslatable } from \"@lattice-php/lattice/i18n/translatable\";\nimport type { Translate } from \"@lattice-php/lattice/i18n/translatable\";\n\ntype RawEffect = Record<string, unknown>;\n\nexport function buildEffects(\n effects: readonly RawEffect[],\n payload: Record<string, unknown>,\n t: Translate,\n): Effect[] {\n return effects.map((effect) => resolveEffect(effect, payload, t)) as Effect[];\n}\n\nfunction resolveEffect(\n effect: RawEffect,\n payload: Record<string, unknown>,\n t: Translate,\n): RawEffect {\n if (effect.type !== \"toast\") {\n return effect;\n }\n\n const
|
|
1
|
+
{"version":3,"file":"build-effects.js","names":[],"sources":["../../resources/js/realtime/build-effects.ts"],"sourcesContent":["import type { Effect } from \"@lattice-php/lattice/types/generated\";\nimport { isTranslatable, resolveTranslatable } from \"@lattice-php/lattice/i18n/translatable\";\nimport type { Translate } from \"@lattice-php/lattice/i18n/translatable\";\n\ntype RawEffect = Record<string, unknown>;\n\nexport function buildEffects(\n effects: readonly RawEffect[],\n payload: Record<string, unknown>,\n t: Translate,\n): Effect[] {\n return effects.map((effect) => resolveEffect(effect, payload, t)) as Effect[];\n}\n\nfunction resolveEffect(\n effect: RawEffect,\n payload: Record<string, unknown>,\n t: Translate,\n): RawEffect {\n if (effect.type !== \"toast\") {\n return effect;\n }\n\n const props = effect.props;\n\n if (typeof props !== \"object\" || props === null) {\n return effect;\n }\n\n const message = (props as Record<string, unknown>).message;\n\n if (!isTranslatable(message)) {\n return effect;\n }\n\n return {\n ...effect,\n props: {\n ...(props as Record<string, unknown>),\n message: resolveTranslatable(message, payload, t),\n },\n };\n}\n"],"mappings":";;AAMA,SAAgB,aACd,SACA,SACA,GACU;CACV,OAAO,QAAQ,KAAK,WAAW,cAAc,QAAQ,SAAS,CAAC,CAAC;AAClE;AAEA,SAAS,cACP,QACA,SACA,GACW;CACX,IAAI,OAAO,SAAS,SAClB,OAAO;CAGT,MAAM,QAAQ,OAAO;CAErB,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAGT,MAAM,UAAW,MAAkC;CAEnD,IAAI,CAAC,eAAe,OAAO,GACzB,OAAO;CAGT,OAAO;EACL,GAAG;EACH,OAAO;GACL,GAAI;GACJ,SAAS,oBAAoB,SAAS,SAAS,CAAC;EAClD;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Listen } from '../types/generated.js';
|
|
2
2
|
/**
|
|
3
3
|
* Renders nothing when a page declares no listeners, so the echo-react chunk
|
|
4
4
|
* is only fetched where it is actually needed.
|
|
5
5
|
*/
|
|
6
6
|
export declare function RealtimeListeners({ listeners }: {
|
|
7
|
-
listeners
|
|
7
|
+
listeners: Listen[];
|
|
8
8
|
}): import("react").JSX.Element | null;
|
|
@@ -19,7 +19,7 @@ var EchoBoundary = class extends Component {
|
|
|
19
19
|
* is only fetched where it is actually needed.
|
|
20
20
|
*/
|
|
21
21
|
function RealtimeListeners({ listeners }) {
|
|
22
|
-
if (listeners
|
|
22
|
+
if (listeners.length === 0) return null;
|
|
23
23
|
return /* @__PURE__ */ jsx(EchoBoundary, { children: /* @__PURE__ */ jsx(Suspense, {
|
|
24
24
|
fallback: null,
|
|
25
25
|
children: /* @__PURE__ */ jsx(Subscriptions, { listeners })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.js","names":[],"sources":["../../resources/js/realtime/listeners.tsx"],"sourcesContent":["import { Component, lazy, Suspense } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"file":"listeners.js","names":[],"sources":["../../resources/js/realtime/listeners.tsx"],"sourcesContent":["import { Component, lazy, Suspense } from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { Listen } from \"@lattice-php/lattice/types/generated\";\n\nconst Subscriptions = lazy(() => import(\"./subscriptions\"));\n\nclass EchoBoundary extends Component<{ children: ReactNode }, { failed: boolean }> {\n state = { failed: false };\n\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n\n componentDidCatch(): void {\n console.warn(\n \"[lattice] Real-time listeners are declared but Echo is unavailable. Install @laravel/echo-react and call configureEcho().\",\n );\n }\n\n render(): ReactNode {\n return this.state.failed ? null : this.props.children;\n }\n}\n\n/**\n * Renders nothing when a page declares no listeners, so the echo-react chunk\n * is only fetched where it is actually needed.\n */\nexport function RealtimeListeners({ listeners }: { listeners: Listen[] }) {\n if (listeners.length === 0) {\n return null;\n }\n\n return (\n <EchoBoundary>\n <Suspense fallback={null}>\n <Subscriptions listeners={listeners} />\n </Suspense>\n </EchoBoundary>\n );\n}\n"],"mappings":";;;AAIA,IAAM,gBAAgB,WAAW,OAAO,qBAAkB;AAE1D,IAAM,eAAN,cAA2B,UAAwD;CACjF,QAAQ,EAAE,QAAQ,MAAM;CAExB,OAAO,2BAAgD;EACrD,OAAO,EAAE,QAAQ,KAAK;CACxB;CAEA,oBAA0B;EACxB,QAAQ,KACN,2HACF;CACF;CAEA,SAAoB;EAClB,OAAO,KAAK,MAAM,SAAS,OAAO,KAAK,MAAM;CAC/C;AACF;;;;;AAMA,SAAgB,kBAAkB,EAAE,aAAsC;CACxE,IAAI,UAAU,WAAW,GACvB,OAAO;CAGT,OACE,oBAAC,cAAD,EAAA,UACE,oBAAC,UAAD;EAAU,UAAU;YAClB,oBAAC,eAAD,EAA0B,UAAY,CAAA;CAC9B,CAAA,EACE,CAAA;AAElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.js","names":[],"sources":["../../resources/js/realtime/subscriptions.tsx"],"sourcesContent":["import { useEcho, useEchoPresence, useEchoPublic } from \"@laravel/echo-react\";\nimport { useCallback } from \"react\";\nimport { useEffectDispatcher } from \"@lattice-php/lattice/effects/use-effect-dispatcher\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport { buildEffects } from \"./build-effects\";\nimport type {
|
|
1
|
+
{"version":3,"file":"subscriptions.js","names":[],"sources":["../../resources/js/realtime/subscriptions.tsx"],"sourcesContent":["import { useEcho, useEchoPresence, useEchoPublic } from \"@laravel/echo-react\";\nimport { useCallback } from \"react\";\nimport { useEffectDispatcher } from \"@lattice-php/lattice/effects/use-effect-dispatcher\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport { buildEffects } from \"./build-effects\";\nimport type { Listen } from \"@lattice-php/lattice/types/generated\";\n\nfunction useListenerHandler(listener: Listen): (payload: unknown) => void {\n const { t } = useT(\"lattice\");\n const dispatch = useEffectDispatcher();\n\n return useCallback(\n (payload: unknown) => {\n const data = (typeof payload === \"object\" && payload !== null ? payload : {}) as Record<\n string,\n unknown\n >;\n dispatch(buildEffects(listener.effects, data, t));\n },\n [dispatch, listener, t],\n );\n}\n\nfunction PublicListener({ listener }: { listener: Listen }) {\n useEchoPublic(listener.channel, listener.events, useListenerHandler(listener));\n return null;\n}\n\nfunction PrivateListener({ listener }: { listener: Listen }) {\n useEcho(listener.channel, listener.events, useListenerHandler(listener));\n return null;\n}\n\nfunction PresenceListener({ listener }: { listener: Listen }) {\n useEchoPresence(listener.channel, listener.events, useListenerHandler(listener));\n return null;\n}\n\nfunction Listener({ listener }: { listener: Listen }) {\n switch (listener.visibility) {\n case \"private\":\n return <PrivateListener listener={listener} />;\n case \"presence\":\n return <PresenceListener listener={listener} />;\n default:\n return <PublicListener listener={listener} />;\n }\n}\n\nexport default function Subscriptions({ listeners }: { listeners: Listen[] }) {\n return (\n <>\n {listeners.map((listener, index) => (\n <Listener key={`${listener.visibility}:${listener.channel}:${index}`} listener={listener} />\n ))}\n </>\n );\n}\n"],"mappings":";;;;;;;AAOA,SAAS,mBAAmB,UAA8C;CACxE,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,WAAW,oBAAoB;CAErC,OAAO,aACJ,YAAqB;EACpB,MAAM,OAAQ,OAAO,YAAY,YAAY,YAAY,OAAO,UAAU,CAAC;EAI3E,SAAS,aAAa,SAAS,SAAS,MAAM,CAAC,CAAC;CAClD,GACA;EAAC;EAAU;EAAU;CAAC,CACxB;AACF;AAEA,SAAS,eAAe,EAAE,YAAkC;CAC1D,cAAc,SAAS,SAAS,SAAS,QAAQ,mBAAmB,QAAQ,CAAC;CAC7E,OAAO;AACT;AAEA,SAAS,gBAAgB,EAAE,YAAkC;CAC3D,QAAQ,SAAS,SAAS,SAAS,QAAQ,mBAAmB,QAAQ,CAAC;CACvE,OAAO;AACT;AAEA,SAAS,iBAAiB,EAAE,YAAkC;CAC5D,gBAAgB,SAAS,SAAS,SAAS,QAAQ,mBAAmB,QAAQ,CAAC;CAC/E,OAAO;AACT;AAEA,SAAS,SAAS,EAAE,YAAkC;CACpD,QAAQ,SAAS,YAAjB;EACE,KAAK,WACH,OAAO,oBAAC,iBAAD,EAA2B,SAAW,CAAA;EAC/C,KAAK,YACH,OAAO,oBAAC,kBAAD,EAA4B,SAAW,CAAA;EAChD,SACE,OAAO,oBAAC,gBAAD,EAA0B,SAAW,CAAA;CAChD;AACF;AAEA,SAAwB,cAAc,EAAE,aAAsC;CAC5E,OACE,oBAAA,YAAA,EAAA,UACG,UAAU,KAAK,UAAU,UACxB,oBAAC,UAAD,EAAgF,SAAW,GAA5E,GAAG,SAAS,WAAW,GAAG,SAAS,QAAQ,GAAG,OAA8B,CAC5F,EACD,CAAA;AAEN"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
+
import { ActionNodeType, ChatNodeType, FormNodeType, FragmentNodeType, LayoutNodeType, NodeType, NotificationNodeType, RemoteNodeType, TableNodeType, UiNodeType } from './types/generated.js';
|
|
2
|
+
type RegisteredNodeType = ActionNodeType | ChatNodeType | FormNodeType | FragmentNodeType | LayoutNodeType | NotificationNodeType | RemoteNodeType | TableNodeType | UiNodeType;
|
|
3
|
+
type Assert<T extends true> = T;
|
|
4
|
+
export type AllNodeTypesRegistered = Assert<Exclude<NodeType, RegisteredNodeType> extends never ? true : false>;
|
|
1
5
|
export declare const registry: import('./core/registry.js').Registry;
|
|
6
|
+
export {};
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":[],"sources":["../resources/js/registry.ts"],"sourcesContent":["import { createRegistry } from \"@lattice-php/lattice/core/registry\";\nimport { actionComponents } from \"./action/plugin\";\nimport { chatComponents } from \"./chat/plugin\";\nimport { uiComponents } from \"./ui/plugin\";\nimport { formComponents } from \"./form/plugin\";\nimport { layoutComponents } from \"./layout/plugin\";\nimport { notificationsComponents } from \"./notifications/plugin\";\nimport { remoteComponents } from \"./remote/plugin\";\nimport { tableComponents } from \"./table/plugin\";\n\nexport const registry = createRegistry(\n uiComponents,\n actionComponents,\n formComponents,\n layoutComponents,\n tableComponents,\n chatComponents,\n notificationsComponents,\n remoteComponents,\n);\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../resources/js/registry.ts"],"sourcesContent":["import { createRegistry } from \"@lattice-php/lattice/core/registry\";\nimport type {\n ActionNodeType,\n ChatNodeType,\n FormNodeType,\n FragmentNodeType,\n LayoutNodeType,\n NodeType,\n NotificationNodeType,\n RemoteNodeType,\n TableNodeType,\n UiNodeType,\n} from \"@lattice-php/lattice/types/generated\";\nimport { actionComponents } from \"./action/plugin\";\nimport { chatComponents } from \"./chat/plugin\";\nimport { uiComponents } from \"./ui/plugin\";\nimport { formComponents } from \"./form/plugin\";\nimport { layoutComponents } from \"./layout/plugin\";\nimport { notificationsComponents } from \"./notifications/plugin\";\nimport { remoteComponents } from \"./remote/plugin\";\nimport { tableComponents } from \"./table/plugin\";\n\n// Compile-time totality: every generated NodeType must belong to a registered\n// plugin's union. A new PHP domain fails here until its plugin exists.\ntype RegisteredNodeType =\n | ActionNodeType\n | ChatNodeType\n | FormNodeType\n | FragmentNodeType\n | LayoutNodeType\n | NotificationNodeType\n | RemoteNodeType\n | TableNodeType\n | UiNodeType;\ntype Assert<T extends true> = T;\nexport type AllNodeTypesRegistered = Assert<\n Exclude<NodeType, RegisteredNodeType> extends never ? true : false\n>;\n\nexport const registry = createRegistry(\n uiComponents,\n actionComponents,\n formComponents,\n layoutComponents,\n tableComponents,\n chatComponents,\n notificationsComponents,\n remoteComponents,\n);\n"],"mappings":";;;;;;;;;;AAuCA,IAAa,WAAW,eACtB,cACA,kBACA,gBACA,kBACA,iBACA,gBACA,yBACA,gBACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { materializeSchema } from "../../core/materialize.js";
|
|
1
2
|
import { Renderer } from "../../core/renderer.js";
|
|
2
3
|
import { useT } from "../../i18n/instance.js";
|
|
3
4
|
import { remoteJson } from "../../core/api.js";
|
|
4
|
-
import { materializeSchema } from "../../core/materialize.js";
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region resources/js/remote/components/data-list.tsx
|
package/dist/remote/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../../resources/js/remote/plugin.ts"],"sourcesContent":["import {\n createPlugin,\n eagerComponent,\n type ComponentRegistryFor,\n} from \"@lattice-php/lattice/core/registry\";\nimport
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../../resources/js/remote/plugin.ts"],"sourcesContent":["import {\n createPlugin,\n eagerComponent,\n type ComponentRegistryFor,\n} from \"@lattice-php/lattice/core/registry\";\nimport type { RemoteNodeType } from \"@lattice-php/lattice/types/generated\";\nimport DataListComponent from \"./components/data-list\";\n\nexport const remoteComponents = createPlugin({\n components: {\n \"remote.data-list\": eagerComponent(DataListComponent),\n } satisfies ComponentRegistryFor<RemoteNodeType>,\n name: \"lattice/remote\",\n});\n"],"mappings":";;;AAQA,IAAa,mBAAmB,aAAa;CAC3C,YAAY,EACV,oBAAoB,eAAe,QAAiB,EACtD;CACA,MAAM;AACR,CAAC"}
|
|
@@ -49,14 +49,14 @@ function BulkBar({ actions, selectedKeys, allMatching, total, query, canSelectAl
|
|
|
49
49
|
children: [
|
|
50
50
|
/* @__PURE__ */ jsx("span", {
|
|
51
51
|
className: "font-medium",
|
|
52
|
-
children: allMatching ? t("table.bulk.
|
|
52
|
+
children: allMatching ? t("table.bulk.all-selected", "All {{count}} selected", { count }) : t("table.bulk.selected", "{{count}} selected", { count })
|
|
53
53
|
}),
|
|
54
54
|
canSelectAllMatching && /* @__PURE__ */ jsx("button", {
|
|
55
55
|
type: "button",
|
|
56
56
|
"data-test": "bulk-select-all-matching",
|
|
57
57
|
className: "font-medium text-lt-primary underline underline-offset-2",
|
|
58
58
|
onClick: onSelectAllMatching,
|
|
59
|
-
children: t("table.bulk.
|
|
59
|
+
children: t("table.bulk.select-all-matching", "Select all {{total}} matching", { total })
|
|
60
60
|
}),
|
|
61
61
|
/* @__PURE__ */ jsx("div", {
|
|
62
62
|
className: "flex flex-wrap items-center gap-2",
|
|
@@ -73,14 +73,14 @@ function BulkBar({ actions, selectedKeys, allMatching, total, query, canSelectAl
|
|
|
73
73
|
title: confirming.confirmation.title ?? confirming.label,
|
|
74
74
|
description: confirming.confirmation.description ?? void 0,
|
|
75
75
|
confirmLabel: confirming.confirmation.confirmLabel ?? confirming.label,
|
|
76
|
-
cancelLabel: confirming.confirmation.cancelLabel ?? "Cancel",
|
|
76
|
+
cancelLabel: confirming.confirmation.cancelLabel ?? t("common.cancel", "Cancel"),
|
|
77
77
|
confirmVariant: confirming.variant,
|
|
78
78
|
processing: http.processing,
|
|
79
79
|
onConfirm: () => void submit(confirming),
|
|
80
80
|
onCancel: () => setConfirming(null)
|
|
81
81
|
}),
|
|
82
82
|
filling?.form && /* @__PURE__ */ jsx(ActionForm, {
|
|
83
|
-
cancelLabel: filling.confirmation?.cancelLabel ?? "Cancel",
|
|
83
|
+
cancelLabel: filling.confirmation?.cancelLabel ?? t("common.cancel", "Cancel"),
|
|
84
84
|
componentRef: filling.ref,
|
|
85
85
|
description: filling.confirmation?.description ?? void 0,
|
|
86
86
|
endpoint: filling.endpoint,
|
|
@@ -93,8 +93,10 @@ function BulkBar({ actions, selectedKeys, allMatching, total, query, canSelectAl
|
|
|
93
93
|
setFilling(null);
|
|
94
94
|
onCompleted();
|
|
95
95
|
},
|
|
96
|
+
placement: filling.modalSide ?? "center",
|
|
96
97
|
submitLabel: filling.confirmation?.confirmLabel ?? filling.label,
|
|
97
|
-
title: filling.confirmation?.title ?? filling.label
|
|
98
|
+
title: filling.confirmation?.title ?? filling.label,
|
|
99
|
+
width: filling.modalWidth ?? void 0
|
|
98
100
|
})
|
|
99
101
|
]
|
|
100
102
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk-bar.js","names":[],"sources":["../../../resources/js/table/components/bulk-bar.tsx"],"sourcesContent":["import { useHttp } from \"@inertiajs/react\";\nimport { useState } from \"react\";\nimport { ActionForm, runAction } from \"@lattice-php/lattice/action\";\nimport { getActionEffects } from \"@lattice-php/lattice/effects/dispatch\";\nimport type { ActionResponse } from \"@lattice-php/lattice/effects/dispatch\";\nimport { useEffectDispatcher } from \"@lattice-php/lattice/effects/use-effect-dispatcher\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { Button } from \"@lattice-php/lattice/ui/button\";\nimport { ConfirmDialog } from \"@lattice-php/lattice/ui/confirm-dialog\";\nimport { Spinner } from \"@lattice-php/lattice/ui/spinner\";\nimport { prefixedTestId } from \"@lattice-php/lattice/core/test-id\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { BulkAction } from \"@lattice-php/lattice/table/lib/bulk\";\n\ntype BulkData = {\n allMatching?: boolean;\n selected?: string[];\n};\n\nexport function BulkBar({\n actions,\n selectedKeys,\n allMatching,\n total,\n query,\n canSelectAllMatching,\n onSelectAllMatching,\n onCompleted,\n}: {\n actions: BulkAction[];\n selectedKeys: string[];\n allMatching: boolean;\n total?: number;\n query: Record<string, unknown>;\n canSelectAllMatching: boolean;\n onSelectAllMatching: () => void;\n onCompleted: () => void;\n}) {\n const { t } = useT(\"lattice\");\n const http = useHttp<BulkData, ActionResponse>({});\n const dispatch = useEffectDispatcher();\n const [confirming, setConfirming] = useState<BulkAction | null>(null);\n const [filling, setFilling] = useState<BulkAction | null>(null);\n\n const selectionPayload = (): Record<string, unknown> =>\n allMatching ? { allMatching: true, ...query } : { selected: selectedKeys };\n\n async function submit(action: BulkAction): Promise<void> {\n http.transform((data) => ({ ...data, ...selectionPayload() }));\n\n const ok = await runAction(\n () => http[action.method](action.endpoint, { headers: withHeaders(action.ref ?? \"\") }),\n dispatch,\n );\n\n if (ok) {\n setConfirming(null);\n onCompleted();\n }\n }\n\n function run(action: BulkAction): void {\n if (action.form) {\n setFilling(action);\n\n return;\n }\n\n if (action.confirmation) {\n setConfirming(action);\n\n return;\n }\n\n void submit(action);\n }\n\n const count = allMatching ? (total ?? selectedKeys.length) : selectedKeys.length;\n\n return (\n <div className=\"flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm\">\n <span className=\"font-medium\">\n {allMatching\n ? t(\"table.bulk.
|
|
1
|
+
{"version":3,"file":"bulk-bar.js","names":[],"sources":["../../../resources/js/table/components/bulk-bar.tsx"],"sourcesContent":["import { useHttp } from \"@inertiajs/react\";\nimport { useState } from \"react\";\nimport { ActionForm, runAction } from \"@lattice-php/lattice/action\";\nimport { getActionEffects } from \"@lattice-php/lattice/effects/dispatch\";\nimport type { ActionResponse } from \"@lattice-php/lattice/effects/dispatch\";\nimport { useEffectDispatcher } from \"@lattice-php/lattice/effects/use-effect-dispatcher\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { Button } from \"@lattice-php/lattice/ui/button\";\nimport { ConfirmDialog } from \"@lattice-php/lattice/ui/confirm-dialog\";\nimport { Spinner } from \"@lattice-php/lattice/ui/spinner\";\nimport { prefixedTestId } from \"@lattice-php/lattice/core/test-id\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { BulkAction } from \"@lattice-php/lattice/table/lib/bulk\";\n\ntype BulkData = {\n allMatching?: boolean;\n selected?: string[];\n};\n\nexport function BulkBar({\n actions,\n selectedKeys,\n allMatching,\n total,\n query,\n canSelectAllMatching,\n onSelectAllMatching,\n onCompleted,\n}: {\n actions: BulkAction[];\n selectedKeys: string[];\n allMatching: boolean;\n total?: number;\n query: Record<string, unknown>;\n canSelectAllMatching: boolean;\n onSelectAllMatching: () => void;\n onCompleted: () => void;\n}) {\n const { t } = useT(\"lattice\");\n const http = useHttp<BulkData, ActionResponse>({});\n const dispatch = useEffectDispatcher();\n const [confirming, setConfirming] = useState<BulkAction | null>(null);\n const [filling, setFilling] = useState<BulkAction | null>(null);\n\n const selectionPayload = (): Record<string, unknown> =>\n allMatching ? { allMatching: true, ...query } : { selected: selectedKeys };\n\n async function submit(action: BulkAction): Promise<void> {\n http.transform((data) => ({ ...data, ...selectionPayload() }));\n\n const ok = await runAction(\n () => http[action.method](action.endpoint, { headers: withHeaders(action.ref ?? \"\") }),\n dispatch,\n );\n\n if (ok) {\n setConfirming(null);\n onCompleted();\n }\n }\n\n function run(action: BulkAction): void {\n if (action.form) {\n setFilling(action);\n\n return;\n }\n\n if (action.confirmation) {\n setConfirming(action);\n\n return;\n }\n\n void submit(action);\n }\n\n const count = allMatching ? (total ?? selectedKeys.length) : selectedKeys.length;\n\n return (\n <div className=\"flex flex-wrap items-center gap-3 border-b border-lt-border bg-lt-muted/50 p-4 text-sm\">\n <span className=\"font-medium\">\n {allMatching\n ? t(\"table.bulk.all-selected\", \"All {{count}} selected\", { count })\n : t(\"table.bulk.selected\", \"{{count}} selected\", { count })}\n </span>\n {canSelectAllMatching && (\n <button\n type=\"button\"\n data-test=\"bulk-select-all-matching\"\n className=\"font-medium text-lt-primary underline underline-offset-2\"\n onClick={onSelectAllMatching}\n >\n {t(\"table.bulk.select-all-matching\", \"Select all {{total}} matching\", { total })}\n </button>\n )}\n <div className=\"flex flex-wrap items-center gap-2\">\n {actions.map((action) => (\n <Button\n key={action.id}\n type=\"button\"\n data-test={prefixedTestId(\"bulk-action\", action.id)}\n variant={action.variant}\n disabled={http.processing}\n onClick={() => run(action)}\n >\n {http.processing && <Spinner />}\n {action.label}\n </Button>\n ))}\n </div>\n\n {confirming?.confirmation && (\n <ConfirmDialog\n title={confirming.confirmation.title ?? confirming.label}\n description={confirming.confirmation.description ?? undefined}\n confirmLabel={confirming.confirmation.confirmLabel ?? confirming.label}\n cancelLabel={confirming.confirmation.cancelLabel ?? t(\"common.cancel\", \"Cancel\")}\n confirmVariant={confirming.variant}\n processing={http.processing}\n onConfirm={() => void submit(confirming)}\n onCancel={() => setConfirming(null)}\n />\n )}\n\n {filling?.form && (\n <ActionForm\n cancelLabel={filling.confirmation?.cancelLabel ?? t(\"common.cancel\", \"Cancel\")}\n componentRef={filling.ref}\n description={filling.confirmation?.description ?? undefined}\n endpoint={filling.endpoint}\n extraData={selectionPayload()}\n formNode={filling.form}\n method={filling.method}\n onClose={() => setFilling(null)}\n onSuccess={(response) => {\n dispatch(getActionEffects(response.effects));\n setFilling(null);\n onCompleted();\n }}\n placement={filling.modalSide ?? \"center\"}\n submitLabel={filling.confirmation?.confirmLabel ?? filling.label}\n title={filling.confirmation?.title ?? filling.label}\n width={filling.modalWidth ?? undefined}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAgB,QAAQ,EACtB,SACA,cACA,aACA,OACA,OACA,sBACA,qBACA,eAUC;CACD,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,OAAO,QAAkC,CAAC,CAAC;CACjD,MAAM,WAAW,oBAAoB;CACrC,MAAM,CAAC,YAAY,iBAAiB,SAA4B,IAAI;CACpE,MAAM,CAAC,SAAS,cAAc,SAA4B,IAAI;CAE9D,MAAM,yBACJ,cAAc;EAAE,aAAa;EAAM,GAAG;CAAM,IAAI,EAAE,UAAU,aAAa;CAE3E,eAAe,OAAO,QAAmC;EACvD,KAAK,WAAW,UAAU;GAAE,GAAG;GAAM,GAAG,iBAAiB;EAAE,EAAE;EAO7D,IAAI,MALa,gBACT,KAAK,OAAO,QAAQ,OAAO,UAAU,EAAE,SAAS,YAAY,OAAO,OAAO,EAAE,EAAE,CAAC,GACrF,QACF,GAEQ;GACN,cAAc,IAAI;GAClB,YAAY;EACd;CACF;CAEA,SAAS,IAAI,QAA0B;EACrC,IAAI,OAAO,MAAM;GACf,WAAW,MAAM;GAEjB;EACF;EAEA,IAAI,OAAO,cAAc;GACvB,cAAc,MAAM;GAEpB;EACF;EAEA,OAAY,MAAM;CACpB;CAEA,MAAM,QAAQ,cAAe,SAAS,aAAa,SAAU,aAAa;CAE1E,OACE,qBAAC,OAAD;EAAK,WAAU;YAAf;GACE,oBAAC,QAAD;IAAM,WAAU;cACb,cACG,EAAE,2BAA2B,0BAA0B,EAAE,MAAM,CAAC,IAChE,EAAE,uBAAuB,sBAAsB,EAAE,MAAM,CAAC;GACxD,CAAA;GACL,wBACC,oBAAC,UAAD;IACE,MAAK;IACL,aAAU;IACV,WAAU;IACV,SAAS;cAER,EAAE,kCAAkC,iCAAiC,EAAE,MAAM,CAAC;GACzE,CAAA;GAEV,oBAAC,OAAD;IAAK,WAAU;cACZ,QAAQ,KAAK,WACZ,qBAAC,QAAD;KAEE,MAAK;KACL,aAAW,eAAe,eAAe,OAAO,EAAE;KAClD,SAAS,OAAO;KAChB,UAAU,KAAK;KACf,eAAe,IAAI,MAAM;eAN3B,CAQG,KAAK,cAAc,oBAAC,SAAD,CAAU,CAAA,GAC7B,OAAO,KACF;OATD,OAAO,EASN,CACT;GACE,CAAA;GAEJ,YAAY,gBACX,oBAAC,eAAD;IACE,OAAO,WAAW,aAAa,SAAS,WAAW;IACnD,aAAa,WAAW,aAAa,eAAe,KAAA;IACpD,cAAc,WAAW,aAAa,gBAAgB,WAAW;IACjE,aAAa,WAAW,aAAa,eAAe,EAAE,iBAAiB,QAAQ;IAC/E,gBAAgB,WAAW;IAC3B,YAAY,KAAK;IACjB,iBAAiB,KAAK,OAAO,UAAU;IACvC,gBAAgB,cAAc,IAAI;GACnC,CAAA;GAGF,SAAS,QACR,oBAAC,YAAD;IACE,aAAa,QAAQ,cAAc,eAAe,EAAE,iBAAiB,QAAQ;IAC7E,cAAc,QAAQ;IACtB,aAAa,QAAQ,cAAc,eAAe,KAAA;IAClD,UAAU,QAAQ;IAClB,WAAW,iBAAiB;IAC5B,UAAU,QAAQ;IAClB,QAAQ,QAAQ;IAChB,eAAe,WAAW,IAAI;IAC9B,YAAY,aAAa;KACvB,SAAS,iBAAiB,SAAS,OAAO,CAAC;KAC3C,WAAW,IAAI;KACf,YAAY;IACd;IACA,WAAW,QAAQ,aAAa;IAChC,aAAa,QAAQ,cAAc,gBAAgB,QAAQ;IAC3D,OAAO,QAAQ,cAAc,SAAS,QAAQ;IAC9C,OAAO,QAAQ,cAAc,KAAA;GAC9B,CAAA;EAEA;;AAET"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { coerceColor, namedColor, toneProps } from "../../../lib/color.js";
|
|
2
3
|
import { formatCell } from "../../lib/format.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
//#region resources/js/table/components/cells/badge-cell.tsx
|
|
5
6
|
var BadgeCell = ({ column, props, value }) => {
|
|
6
7
|
const label = formatCell(value, column);
|
|
7
8
|
if (label === "") return null;
|
|
9
|
+
const tone = toneProps(coerceColor(props.colors?.[String(value)]) ?? namedColor("gray"));
|
|
8
10
|
return /* @__PURE__ */ jsx("span", {
|
|
9
|
-
className: cn("lt-cell-badge",
|
|
11
|
+
className: cn("lt-cell-badge", tone.className),
|
|
12
|
+
style: tone.style,
|
|
10
13
|
children: label
|
|
11
14
|
});
|
|
12
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/badge-cell.tsx"],"sourcesContent":["import { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { formatCell } from \"@lattice-php/lattice/table/lib/format\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const BadgeCell: ColumnCellComponent<\"column.badge\"> = ({ column, props, value }) => {\n const label = formatCell(value, column);\n\n if (label === \"\") {\n return null;\n }\n\n const
|
|
1
|
+
{"version":3,"file":"badge-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/badge-cell.tsx"],"sourcesContent":["import { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { coerceColor, namedColor, toneProps } from \"@lattice-php/lattice/lib/color\";\nimport { formatCell } from \"@lattice-php/lattice/table/lib/format\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const BadgeCell: ColumnCellComponent<\"column.badge\"> = ({ column, props, value }) => {\n const label = formatCell(value, column);\n\n if (label === \"\") {\n return null;\n }\n\n const tone = toneProps(coerceColor(props.colors?.[String(value)]) ?? namedColor(\"gray\"));\n\n return (\n <span className={cn(\"lt-cell-badge\", tone.className)} style={tone.style}>\n {label}\n </span>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,aAAkD,EAAE,QAAQ,OAAO,YAAY;CAC1F,MAAM,QAAQ,WAAW,OAAO,MAAM;CAEtC,IAAI,UAAU,IACZ,OAAO;CAGT,MAAM,OAAO,UAAU,YAAY,MAAM,SAAS,OAAO,KAAK,EAAE,KAAK,WAAW,MAAM,CAAC;CAEvF,OACE,oBAAC,QAAD;EAAM,WAAW,GAAG,iBAAiB,KAAK,SAAS;EAAG,OAAO,KAAK;YAC/D;CACG,CAAA;AAEV"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
2
|
import { Icon } from "../../../icons/sprite.js";
|
|
3
|
+
import { useT } from "../../../i18n/instance.js";
|
|
4
|
+
import { isTruthy } from "../../../lib/is-truthy.js";
|
|
3
5
|
import { jsx } from "react/jsx-runtime";
|
|
4
6
|
//#region resources/js/table/components/cells/boolean-cell.tsx
|
|
5
|
-
function isTruthy(value) {
|
|
6
|
-
return value === true || value === 1 || value === "1" || value === "true";
|
|
7
|
-
}
|
|
8
7
|
var BooleanCell = ({ value }) => {
|
|
8
|
+
const { t } = useT("lattice");
|
|
9
9
|
const truthy = isTruthy(value);
|
|
10
10
|
return /* @__PURE__ */ jsx("span", {
|
|
11
|
-
"aria-label":
|
|
11
|
+
"aria-label": truthy ? t("common.yes", "Yes") : t("common.no", "No"),
|
|
12
12
|
role: "img",
|
|
13
13
|
children: /* @__PURE__ */ jsx(Icon, {
|
|
14
14
|
name: truthy ? "check" : "x",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/boolean-cell.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport
|
|
1
|
+
{"version":3,"file":"boolean-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/boolean-cell.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { isTruthy } from \"@lattice-php/lattice/lib/is-truthy\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const BooleanCell: ColumnCellComponent<\"column.boolean\"> = ({ value }) => {\n const { t } = useT(\"lattice\");\n const truthy = isTruthy(value);\n\n return (\n <span aria-label={truthy ? t(\"common.yes\", \"Yes\") : t(\"common.no\", \"No\")} role=\"img\">\n <Icon\n name={truthy ? \"check\" : \"x\"}\n className={cn(\"size-lt-icon-md\", truthy ? \"text-lt-success\" : \"text-lt-muted-fg\")}\n />\n </span>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,eAAsD,EAAE,YAAY;CAC/E,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,SAAS,SAAS,KAAK;CAE7B,OACE,oBAAC,QAAD;EAAM,cAAY,SAAS,EAAE,cAAc,KAAK,IAAI,EAAE,aAAa,IAAI;EAAG,MAAK;YAC7E,oBAAC,MAAD;GACE,MAAM,SAAS,UAAU;GACzB,WAAW,GAAG,mBAAmB,SAAS,oBAAoB,kBAAkB;EACjF,CAAA;CACG,CAAA;AAEV"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TableColumn } from '../../types.js';
|
|
3
|
+
/** Wrap cell content in a copy-to-clipboard affordance when `copyable` is set. */
|
|
4
|
+
export declare function CopyableCell({ children, column, copyable, value, }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
column: TableColumn;
|
|
7
|
+
copyable?: boolean | null;
|
|
8
|
+
value: string;
|
|
9
|
+
}): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CopyableText } from "../../../ui/copyable-text.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region resources/js/table/components/cells/copyable-cell.tsx
|
|
4
|
+
/** Wrap cell content in a copy-to-clipboard affordance when `copyable` is set. */
|
|
5
|
+
function CopyableCell({ children, column, copyable, value }) {
|
|
6
|
+
if (!copyable) return children;
|
|
7
|
+
return /* @__PURE__ */ jsx(CopyableText, {
|
|
8
|
+
value,
|
|
9
|
+
label: column.props.label ?? column.key,
|
|
10
|
+
testId: `copy-${column.key}`,
|
|
11
|
+
children
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CopyableCell };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=copyable-cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyable-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/copyable-cell.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { CopyableText } from \"@lattice-php/lattice/ui/copyable-text\";\nimport type { TableColumn } from \"@lattice-php/lattice/table/types\";\n\n/** Wrap cell content in a copy-to-clipboard affordance when `copyable` is set. */\nexport function CopyableCell({\n children,\n column,\n copyable,\n value,\n}: {\n children: ReactNode;\n column: TableColumn;\n copyable?: boolean | null;\n value: string;\n}): ReactNode {\n if (!copyable) {\n return children;\n }\n\n return (\n <CopyableText\n value={value}\n label={column.props.label ?? column.key}\n testId={`copy-${column.key}`}\n >\n {children}\n </CopyableText>\n );\n}\n"],"mappings":";;;;AAKA,SAAgB,aAAa,EAC3B,UACA,QACA,UACA,SAMY;CACZ,IAAI,CAAC,UACH,OAAO;CAGT,OACE,oBAAC,cAAD;EACS;EACP,OAAO,OAAO,MAAM,SAAS,OAAO;EACpC,QAAQ,QAAQ,OAAO;EAEtB;CACW,CAAA;AAElB"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
2
|
import { IconRenderer } from "../../../icons/icon-renderer.js";
|
|
3
|
+
import { coerceColor, toneProps } from "../../../lib/color.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
//#region resources/js/table/components/cells/icon-cell.tsx
|
|
5
6
|
var IconCell = ({ props, value }) => {
|
|
6
7
|
const icon = props.icons?.[String(value)] ?? props.icon ?? void 0;
|
|
7
8
|
if (!icon) return null;
|
|
8
|
-
const color = props.colors?.[String(value)];
|
|
9
|
+
const color = coerceColor(props.colors?.[String(value)]);
|
|
10
|
+
const tone = color ? toneProps(color) : void 0;
|
|
9
11
|
return /* @__PURE__ */ jsx("span", {
|
|
10
12
|
"aria-label": String(value),
|
|
11
|
-
className: cn("lt-cell-icon",
|
|
13
|
+
className: cn("lt-cell-icon", tone?.className),
|
|
14
|
+
style: tone?.style,
|
|
12
15
|
children: /* @__PURE__ */ jsx(IconRenderer, {
|
|
13
16
|
className: "size-lt-icon-md",
|
|
14
17
|
icon
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/icon-cell.tsx"],"sourcesContent":["import { IconRenderer } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const IconCell: ColumnCellComponent<\"column.icon\"> = ({ props, value }) => {\n const icon = props.icons?.[String(value)] ?? props.icon ?? undefined;\n\n if (!icon) {\n return null;\n }\n\n const color = props.colors?.[String(value)];\n\n return (\n <span\n aria-label={String(value)}\n className={cn(\"lt-cell-icon\",
|
|
1
|
+
{"version":3,"file":"icon-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/icon-cell.tsx"],"sourcesContent":["import { IconRenderer } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { coerceColor, toneProps } from \"@lattice-php/lattice/lib/color\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const IconCell: ColumnCellComponent<\"column.icon\"> = ({ props, value }) => {\n const icon = props.icons?.[String(value)] ?? props.icon ?? undefined;\n\n if (!icon) {\n return null;\n }\n\n const color = coerceColor(props.colors?.[String(value)]);\n const tone = color ? toneProps(color) : undefined;\n\n return (\n <span\n aria-label={String(value)}\n className={cn(\"lt-cell-icon\", tone?.className)}\n style={tone?.style}\n >\n <IconRenderer className=\"size-lt-icon-md\" icon={icon} />\n </span>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,YAAgD,EAAE,OAAO,YAAY;CAChF,MAAM,OAAO,MAAM,QAAQ,OAAO,KAAK,MAAM,MAAM,QAAQ,KAAA;CAE3D,IAAI,CAAC,MACH,OAAO;CAGT,MAAM,QAAQ,YAAY,MAAM,SAAS,OAAO,KAAK,EAAE;CACvD,MAAM,OAAO,QAAQ,UAAU,KAAK,IAAI,KAAA;CAExC,OACE,oBAAC,QAAD;EACE,cAAY,OAAO,KAAK;EACxB,WAAW,GAAG,gBAAgB,MAAM,SAAS;EAC7C,OAAO,MAAM;YAEb,oBAAC,cAAD;GAAc,WAAU;GAAwB;EAAO,CAAA;CACnD,CAAA;AAEV"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { cn } from "../../../lib/utils.js";
|
|
2
|
+
import { PreviewableImage } from "../../../ui/image-preview.js";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region resources/js/table/components/cells/image-cell.tsx
|
|
4
5
|
var ImageCell = ({ column, props, value }) => {
|
|
5
6
|
const url = typeof value === "string" ? value : "";
|
|
6
7
|
if (url === "") return null;
|
|
7
8
|
const size = props.size ?? 32;
|
|
8
|
-
return /* @__PURE__ */ jsx(
|
|
9
|
-
alt: column.props.label ??
|
|
10
|
-
src: url,
|
|
11
|
-
width: size,
|
|
12
|
-
height: size,
|
|
9
|
+
return /* @__PURE__ */ jsx(PreviewableImage, {
|
|
10
|
+
alt: column.props.label ?? "",
|
|
13
11
|
className: cn("object-cover", props.circular ? "rounded-full" : "rounded-lt-sm"),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
12
|
+
height: size,
|
|
13
|
+
previewable: props.previewable,
|
|
14
|
+
src: url,
|
|
15
|
+
testId: `preview-${column.key}`,
|
|
16
|
+
width: size
|
|
18
17
|
});
|
|
19
18
|
};
|
|
20
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/image-cell.tsx"],"sourcesContent":["import { cn } from \"@lattice-php/lattice/lib/utils\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\n\nexport const ImageCell: ColumnCellComponent<\"column.image\"> = ({ column, props, value }) => {\n const url = typeof value === \"string\" ? value : \"\";\n\n if (url === \"\") {\n return null;\n }\n\n const size = props.size ?? 32;\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"image-cell.js","names":[],"sources":["../../../../resources/js/table/components/cells/image-cell.tsx"],"sourcesContent":["import { cn } from \"@lattice-php/lattice/lib/utils\";\nimport type { ColumnCellComponent } from \"@lattice-php/lattice/table/registry\";\nimport { PreviewableImage } from \"@lattice-php/lattice/ui/image-preview\";\n\nexport const ImageCell: ColumnCellComponent<\"column.image\"> = ({ column, props, value }) => {\n const url = typeof value === \"string\" ? value : \"\";\n\n if (url === \"\") {\n return null;\n }\n\n const size = props.size ?? 32;\n\n return (\n <PreviewableImage\n alt={column.props.label ?? \"\"}\n className={cn(\"object-cover\", props.circular ? \"rounded-full\" : \"rounded-lt-sm\")}\n height={size}\n previewable={props.previewable}\n src={url}\n testId={`preview-${column.key}`}\n width={size}\n />\n );\n};\n"],"mappings":";;;;AAIA,IAAa,aAAkD,EAAE,QAAQ,OAAO,YAAY;CAC1F,MAAM,MAAM,OAAO,UAAU,WAAW,QAAQ;CAEhD,IAAI,QAAQ,IACV,OAAO;CAGT,MAAM,OAAO,MAAM,QAAQ;CAE3B,OACE,oBAAC,kBAAD;EACE,KAAK,OAAO,MAAM,SAAS;EAC3B,WAAW,GAAG,gBAAgB,MAAM,WAAW,iBAAiB,eAAe;EAC/E,QAAQ;EACR,aAAa,MAAM;EACnB,KAAK;EACL,QAAQ,WAAW,OAAO;EAC1B,OAAO;CACR,CAAA;AAEL"}
|