@lattice-php/lattice 0.61.0 → 0.62.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/create-app.js +3 -2
- package/dist/create-app.js.map +1 -1
- package/dist/event-bridge.js +1 -1
- package/dist/fragments/fragment.js +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +3 -7
- package/dist/inertia-navigation.d.ts +6 -0
- package/dist/inertia-navigation.js +28 -4
- package/dist/inertia-navigation.js.map +1 -1
- package/dist/lattice.css +16 -0
- package/dist/layout/components/outlet.js.map +1 -1
- package/dist/layout/components/schema-layout.js +1 -1
- package/dist/layout/components/schema-layout.js.map +1 -1
- package/dist/layout/index.d.ts +0 -1
- package/dist/layout/index.js +1 -2
- package/dist/layout/plugin.js +1 -19
- package/dist/layout/plugin.js.map +1 -1
- package/dist/notifications/components/empty-state.js +1 -1
- package/dist/notifications/components/notification-item.js +3 -3
- package/dist/notifications/components/notification-item.js.map +1 -1
- package/dist/notifications/components/notification-list.js +1 -1
- package/dist/notifications/components/notification-list.js.map +1 -1
- package/dist/notifications/components/notifications-echo.js.map +1 -1
- package/dist/notifications/components/notifications-sheet.js +2 -2
- package/dist/notifications/components/notifications-sheet.js.map +1 -1
- package/dist/notifications/components/notifications.js +4 -4
- package/dist/notifications/components/notifications.js.map +1 -1
- package/dist/page.js +2 -1
- package/dist/page.js.map +1 -1
- package/dist/provider-base.d.ts +3 -1
- package/dist/provider-base.js +6 -5
- package/dist/provider-base.js.map +1 -1
- package/dist/realtime/subscriptions.js +3 -3
- package/dist/realtime/subscriptions.js.map +1 -1
- package/dist/remote/components/data-list.js +1 -1
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +6 -9
- package/dist/types/generated.d.ts +4 -38
- package/dist-standalone/chunks/chart-view-CJZkJAHB.js +59 -0
- package/dist-standalone/chunks/{date-picker-field-B09aCbOL.js → date-picker-view-p9mSMvwV.js} +1 -1
- package/dist-standalone/chunks/dist-Dd8dg4q5.js +106 -0
- package/dist-standalone/chunks/{field-rjVaymdj.js → pattern-input-view-CCPpYThT.js} +1 -1
- package/dist-standalone/chunks/rich-editor-view-CBCDtSzk.js +53 -0
- package/dist-standalone/chunks/runtime-DI3n1MuN.js +162 -0
- package/dist-standalone/chunks/{subscriptions-P9PiNr3N.js → subscriptions-C1LRT5gZ.js} +1 -1
- package/dist-standalone/lattice.css +1 -1
- package/dist-standalone/lattice.js +1 -1
- package/dist-standalone/manifest.json +1 -1
- package/dist-standalone/runtime.js +1 -1
- package/dist-standalone/sprite.svg +1 -1
- package/package.json +7 -12
- package/dist/layout/components/breadcrumbs.d.ts +0 -3
- package/dist/layout/components/breadcrumbs.js +0 -41
- package/dist/layout/components/breadcrumbs.js.map +0 -1
- package/dist/layout/components/callouts.d.ts +0 -15
- package/dist/layout/components/callouts.js +0 -89
- package/dist/layout/components/callouts.js.map +0 -1
- package/dist/layout/components/dropdown.d.ts +0 -3
- package/dist/layout/components/dropdown.js +0 -24
- package/dist/layout/components/dropdown.js.map +0 -1
- package/dist/layout/components/menu-item.d.ts +0 -3
- package/dist/layout/components/menu-item.js +0 -137
- package/dist/layout/components/menu-item.js.map +0 -1
- package/dist/layout/components/menu.d.ts +0 -3
- package/dist/layout/components/menu.js +0 -14
- package/dist/layout/components/menu.js.map +0 -1
- package/dist/layout/components/popover.d.ts +0 -17
- package/dist/layout/components/popover.js +0 -46
- package/dist/layout/components/popover.js.map +0 -1
- package/dist/layout/components/sidebar-footer.d.ts +0 -3
- package/dist/layout/components/sidebar-footer.js +0 -12
- package/dist/layout/components/sidebar-footer.js.map +0 -1
- package/dist/layout/components/sidebar.d.ts +0 -3
- package/dist/layout/components/sidebar.js +0 -55
- package/dist/layout/components/sidebar.js.map +0 -1
- package/dist/layout/components/topbar.d.ts +0 -3
- package/dist/layout/components/topbar.js +0 -16
- package/dist/layout/components/topbar.js.map +0 -1
- package/dist/toast/callout.d.ts +0 -5
- package/dist/toast/callout.js +0 -31
- package/dist/toast/callout.js.map +0 -1
- package/dist/toast/index.d.ts +0 -6
- package/dist/toast/index.js +0 -5
- package/dist/toast/toast.d.ts +0 -7
- package/dist/toast/toast.js +0 -47
- package/dist/toast/toast.js.map +0 -1
- package/dist/toast/toaster.d.ts +0 -3
- package/dist/toast/toaster.js +0 -63
- package/dist/toast/toaster.js.map +0 -1
- package/dist/toast/variant-styles.d.ts +0 -6
- package/dist/toast/variant-styles.js +0 -51
- package/dist/toast/variant-styles.js.map +0 -1
- package/dist-standalone/chunks/chart-view-BKbOL4wu.js +0 -59
- package/dist-standalone/chunks/dist-DAHNiLp2.js +0 -106
- package/dist-standalone/chunks/rich-editor-field-D1bcp0AJ.js +0 -53
- package/dist-standalone/chunks/runtime-D0Xtwwcq.js +0 -162
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cn } from "@lattice-php/ui/lib/utils";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { nodeIdentity } from "@lattice-php/core/test-id";
|
|
4
|
-
//#region resources/js/layout/components/topbar.tsx
|
|
5
|
-
var TopbarComponent = ({ children, node }) => {
|
|
6
|
-
const sticky = node.props.sticky;
|
|
7
|
-
return /* @__PURE__ */ jsx("header", {
|
|
8
|
-
"data-lattice-component": nodeIdentity(node),
|
|
9
|
-
className: cn("flex h-14 w-full items-center gap-2 border-b border-lt-border bg-lt-bg px-4 text-lt-fg", sticky && "sticky top-0 z-lt-sticky"),
|
|
10
|
-
children
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { TopbarComponent as default };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=topbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"topbar.js","names":[],"sources":["../../../resources/js/layout/components/topbar.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/core/types\";\nimport { nodeIdentity } from \"@lattice-php/core/test-id\";\nimport { cn } from \"@lattice-php/ui/lib/utils\";\n\nconst TopbarComponent: RendererComponent<\"topbar\"> = ({ children, node }) => {\n const sticky = node.props.sticky;\n\n return (\n <header\n data-lattice-component={nodeIdentity(node)}\n className={cn(\n \"flex h-14 w-full items-center gap-2 border-b border-lt-border bg-lt-bg px-4 text-lt-fg\",\n sticky && \"sticky top-0 z-lt-sticky\",\n )}\n >\n {children}\n </header>\n );\n};\n\nexport default TopbarComponent;\n"],"mappings":";;;;AAIA,IAAM,mBAAgD,EAAE,UAAU,WAAW;CAC3E,MAAM,SAAS,KAAK,MAAM;CAE1B,OACE,oBAAC,UAAD;EACE,0BAAwB,aAAa,IAAI;EACzC,WAAW,GACT,0FACA,UAAU,0BACZ;EAEC;CACK,CAAA;AAEZ"}
|
package/dist/toast/callout.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Callout } from '@lattice-php/ui';
|
|
2
|
-
export type { Callout };
|
|
3
|
-
export declare function normalizeCallout(detail: unknown): Callout | null;
|
|
4
|
-
export declare function onCallout(callback: (callout: Callout) => void): () => void;
|
|
5
|
-
export declare function onRetractCallout(callback: (unique: string) => void): () => void;
|
package/dist/toast/callout.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { coerceMessage, isVariant, subscribeWindowEvent } from "./toast.js";
|
|
2
|
-
import { LATTICE_EVENT } from "@lattice-php/core/event-names";
|
|
3
|
-
import { isTranslatable } from "@lattice-php/ui/i18n/translatable";
|
|
4
|
-
//#region resources/js/toast/callout.ts
|
|
5
|
-
function normalizeCallout(detail) {
|
|
6
|
-
if (typeof detail !== "object" || detail === null) return null;
|
|
7
|
-
const callout = detail;
|
|
8
|
-
const message = coerceMessage(callout.message);
|
|
9
|
-
if (message === null) return null;
|
|
10
|
-
return {
|
|
11
|
-
action: callout.action ?? null,
|
|
12
|
-
dismissible: callout.dismissible !== false,
|
|
13
|
-
message,
|
|
14
|
-
title: typeof callout.title === "string" || isTranslatable(callout.title) ? callout.title : null,
|
|
15
|
-
unique: typeof callout.unique === "string" ? callout.unique : null,
|
|
16
|
-
variant: isVariant(callout.variant) ? callout.variant : "info"
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function onCallout(callback) {
|
|
20
|
-
return subscribeWindowEvent(LATTICE_EVENT.callout, normalizeCallout, callback);
|
|
21
|
-
}
|
|
22
|
-
function onRetractCallout(callback) {
|
|
23
|
-
return subscribeWindowEvent(LATTICE_EVENT.retractCallout, (detail) => {
|
|
24
|
-
const unique = detail?.unique;
|
|
25
|
-
return typeof unique === "string" ? unique : null;
|
|
26
|
-
}, callback);
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
|
-
export { normalizeCallout, onCallout, onRetractCallout };
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=callout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callout.js","names":[],"sources":["../../resources/js/toast/callout.ts"],"sourcesContent":["import { LATTICE_EVENT } from \"@lattice-php/core/event-names\";\nimport type { Callout, RetractCallout } from \"@lattice-php/ui\";\nimport { isTranslatable } from \"@lattice-php/ui/i18n/translatable\";\nimport { coerceMessage, isVariant, subscribeWindowEvent } from \"./toast\";\n\nexport type { Callout };\n\nexport function normalizeCallout(detail: unknown): Callout | null {\n if (typeof detail !== \"object\" || detail === null) {\n return null;\n }\n\n const callout = detail as Record<string, unknown>;\n const message = coerceMessage(callout.message);\n\n if (message === null) {\n return null;\n }\n\n return {\n action: (callout.action as Callout[\"action\"]) ?? null,\n dismissible: callout.dismissible !== false,\n message,\n title:\n typeof callout.title === \"string\" || isTranslatable(callout.title) ? callout.title : null,\n unique: typeof callout.unique === \"string\" ? callout.unique : null,\n variant: isVariant(callout.variant) ? callout.variant : \"info\",\n };\n}\n\nexport function onCallout(callback: (callout: Callout) => void): () => void {\n return subscribeWindowEvent(LATTICE_EVENT.callout, normalizeCallout, callback);\n}\n\nexport function onRetractCallout(callback: (unique: string) => void): () => void {\n return subscribeWindowEvent(\n LATTICE_EVENT.retractCallout,\n (detail) => {\n const unique = (detail as RetractCallout | undefined)?.unique;\n\n return typeof unique === \"string\" ? unique : null;\n },\n callback,\n );\n}\n"],"mappings":";;;;AAOA,SAAgB,iBAAiB,QAAiC;CAChE,IAAI,OAAO,WAAW,YAAY,WAAW,MAC3C,OAAO;CAGT,MAAM,UAAU;CAChB,MAAM,UAAU,cAAc,QAAQ,OAAO;CAE7C,IAAI,YAAY,MACd,OAAO;CAGT,OAAO;EACL,QAAS,QAAQ,UAAgC;EACjD,aAAa,QAAQ,gBAAgB;EACrC;EACA,OACE,OAAO,QAAQ,UAAU,YAAY,eAAe,QAAQ,KAAK,IAAI,QAAQ,QAAQ;EACvF,QAAQ,OAAO,QAAQ,WAAW,WAAW,QAAQ,SAAS;EAC9D,SAAS,UAAU,QAAQ,OAAO,IAAI,QAAQ,UAAU;CAC1D;AACF;AAEA,SAAgB,UAAU,UAAkD;CAC1E,OAAO,qBAAqB,cAAc,SAAS,kBAAkB,QAAQ;AAC/E;AAEA,SAAgB,iBAAiB,UAAgD;CAC/E,OAAO,qBACL,cAAc,iBACb,WAAW;EACV,MAAM,SAAU,QAAuC;EAEvD,OAAO,OAAO,WAAW,WAAW,SAAS;CAC/C,GACA,QACF;AACF"}
|
package/dist/toast/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { normalizeCallout, onCallout, onRetractCallout } from './callout.js';
|
|
2
|
-
export type { Callout } from './callout.js';
|
|
3
|
-
export { Toaster } from './toaster.js';
|
|
4
|
-
export { onToast } from './toast.js';
|
|
5
|
-
export type { ToastMessage, Variant } from './toast.js';
|
|
6
|
-
export { variantStyles } from './variant-styles.js';
|
package/dist/toast/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { onToast } from "./toast.js";
|
|
2
|
-
import { normalizeCallout, onCallout, onRetractCallout } from "./callout.js";
|
|
3
|
-
import { variantStyles } from "./variant-styles.js";
|
|
4
|
-
import { Toaster } from "./toaster.js";
|
|
5
|
-
export { Toaster, normalizeCallout, onCallout, onRetractCallout, onToast, variantStyles };
|
package/dist/toast/toast.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Toast as ToastMessage, Variant } from '@lattice-php/ui';
|
|
2
|
-
export type { ToastMessage, Variant };
|
|
3
|
-
export declare function isVariant(value: unknown): value is Variant;
|
|
4
|
-
export declare function coerceMessage(value: unknown): ToastMessage["message"] | null;
|
|
5
|
-
export declare function subscribeWindowEvent<T>(event: string, normalize: (detail: unknown) => T | null, callback: (value: T) => void): () => void;
|
|
6
|
-
export declare function normalizeToastMessage(value: unknown): ToastMessage | null;
|
|
7
|
-
export declare function onToast(callback: (toast: ToastMessage) => void): () => void;
|
package/dist/toast/toast.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { LATTICE_EVENT } from "@lattice-php/core/event-names";
|
|
2
|
-
import { isTranslatable } from "@lattice-php/ui/i18n/translatable";
|
|
3
|
-
//#region resources/js/toast/toast.ts
|
|
4
|
-
var variants = [
|
|
5
|
-
"primary",
|
|
6
|
-
"secondary",
|
|
7
|
-
"success",
|
|
8
|
-
"info",
|
|
9
|
-
"warning",
|
|
10
|
-
"danger"
|
|
11
|
-
];
|
|
12
|
-
function isVariant(value) {
|
|
13
|
-
return variants.some((variant) => variant === value);
|
|
14
|
-
}
|
|
15
|
-
function coerceMessage(value) {
|
|
16
|
-
const message = typeof value === "string" ? value : isTranslatable(value) ? value : null;
|
|
17
|
-
return message === "" ? null : message;
|
|
18
|
-
}
|
|
19
|
-
function subscribeWindowEvent(event, normalize, callback) {
|
|
20
|
-
const listener = (windowEvent) => {
|
|
21
|
-
const value = normalize(windowEvent.detail);
|
|
22
|
-
if (value !== null) callback(value);
|
|
23
|
-
};
|
|
24
|
-
window.addEventListener(event, listener);
|
|
25
|
-
return () => window.removeEventListener(event, listener);
|
|
26
|
-
}
|
|
27
|
-
function normalizeToastMessage(value) {
|
|
28
|
-
if (typeof value !== "object" || value === null) return null;
|
|
29
|
-
const toast = value;
|
|
30
|
-
const message = coerceMessage(toast.message);
|
|
31
|
-
if (message === null) return null;
|
|
32
|
-
return {
|
|
33
|
-
action: toast.action ?? null,
|
|
34
|
-
dismissible: toast.dismissible !== false,
|
|
35
|
-
duration: typeof toast.duration === "number" ? toast.duration : null,
|
|
36
|
-
message,
|
|
37
|
-
persistent: toast.persistent === true,
|
|
38
|
-
variant: isVariant(toast.variant) ? toast.variant : "success"
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function onToast(callback) {
|
|
42
|
-
return subscribeWindowEvent(LATTICE_EVENT.toast, normalizeToastMessage, callback);
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { coerceMessage, isVariant, normalizeToastMessage, onToast, subscribeWindowEvent };
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=toast.js.map
|
package/dist/toast/toast.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toast.js","names":[],"sources":["../../resources/js/toast/toast.ts"],"sourcesContent":["import { LATTICE_EVENT } from \"@lattice-php/core/event-names\";\nimport type { Toast as ToastMessage, Variant } from \"@lattice-php/ui\";\nimport { isTranslatable } from \"@lattice-php/ui/i18n/translatable\";\n\nexport type { ToastMessage, Variant };\n\nconst variants = [\n \"primary\",\n \"secondary\",\n \"success\",\n \"info\",\n \"warning\",\n \"danger\",\n] as const satisfies readonly Variant[];\n\nexport function isVariant(value: unknown): value is Variant {\n return variants.some((variant) => variant === value);\n}\n\nexport function coerceMessage(value: unknown): ToastMessage[\"message\"] | null {\n const message = typeof value === \"string\" ? value : isTranslatable(value) ? value : null;\n\n return message === \"\" ? null : message;\n}\n\nexport function subscribeWindowEvent<T>(\n event: string,\n normalize: (detail: unknown) => T | null,\n callback: (value: T) => void,\n): () => void {\n const listener = (windowEvent: Event): void => {\n const value = normalize((windowEvent as CustomEvent).detail);\n\n if (value !== null) {\n callback(value);\n }\n };\n\n window.addEventListener(event, listener);\n\n return () => window.removeEventListener(event, listener);\n}\n\nexport function normalizeToastMessage(value: unknown): ToastMessage | null {\n if (typeof value !== \"object\" || value === null) {\n return null;\n }\n\n const toast = value as Record<string, unknown>;\n const message = coerceMessage(toast.message);\n\n if (message === null) {\n return null;\n }\n\n return {\n action: (toast.action as ToastMessage[\"action\"]) ?? null,\n dismissible: toast.dismissible !== false,\n duration: typeof toast.duration === \"number\" ? toast.duration : null,\n message,\n persistent: toast.persistent === true,\n variant: isVariant(toast.variant) ? toast.variant : \"success\",\n };\n}\n\nexport function onToast(callback: (toast: ToastMessage) => void): () => void {\n return subscribeWindowEvent(LATTICE_EVENT.toast, normalizeToastMessage, callback);\n}\n"],"mappings":";;;AAMA,IAAM,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,UAAU,OAAkC;CAC1D,OAAO,SAAS,MAAM,YAAY,YAAY,KAAK;AACrD;AAEA,SAAgB,cAAc,OAAgD;CAC5E,MAAM,UAAU,OAAO,UAAU,WAAW,QAAQ,eAAe,KAAK,IAAI,QAAQ;CAEpF,OAAO,YAAY,KAAK,OAAO;AACjC;AAEA,SAAgB,qBACd,OACA,WACA,UACY;CACZ,MAAM,YAAY,gBAA6B;EAC7C,MAAM,QAAQ,UAAW,YAA4B,MAAM;EAE3D,IAAI,UAAU,MACZ,SAAS,KAAK;CAElB;CAEA,OAAO,iBAAiB,OAAO,QAAQ;CAEvC,aAAa,OAAO,oBAAoB,OAAO,QAAQ;AACzD;AAEA,SAAgB,sBAAsB,OAAqC;CACzE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAGT,MAAM,QAAQ;CACd,MAAM,UAAU,cAAc,MAAM,OAAO;CAE3C,IAAI,YAAY,MACd,OAAO;CAGT,OAAO;EACL,QAAS,MAAM,UAAqC;EACpD,aAAa,MAAM,gBAAgB;EACnC,UAAU,OAAO,MAAM,aAAa,WAAW,MAAM,WAAW;EAChE;EACA,YAAY,MAAM,eAAe;EACjC,SAAS,UAAU,MAAM,OAAO,IAAI,MAAM,UAAU;CACtD;AACF;AAEA,SAAgB,QAAQ,UAAqD;CAC3E,OAAO,qBAAqB,cAAc,OAAO,uBAAuB,QAAQ;AAClF"}
|
package/dist/toast/toaster.d.ts
DELETED
package/dist/toast/toaster.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { onToast } from "./toast.js";
|
|
2
|
-
import { variantStyles } from "./variant-styles.js";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { Icon } from "@lattice-php/ui/icons";
|
|
5
|
-
import { RenderNode } from "@lattice-php/core/renderer";
|
|
6
|
-
import { resolveText } from "@lattice-php/ui/i18n/translatable";
|
|
7
|
-
import * as Toast from "@radix-ui/react-toast";
|
|
8
|
-
import { cn } from "@lattice-php/ui/lib/utils";
|
|
9
|
-
import { useT } from "@lattice-php/ui/i18n";
|
|
10
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
//#region resources/js/toast/toaster.tsx
|
|
12
|
-
var nextId = 0;
|
|
13
|
-
function Toaster({ duration = 4e3 }) {
|
|
14
|
-
const { t } = useT("lattice");
|
|
15
|
-
const [toasts, setToasts] = useState([]);
|
|
16
|
-
function dismiss(id) {
|
|
17
|
-
setToasts((current) => current.filter((toast) => toast.id !== id));
|
|
18
|
-
}
|
|
19
|
-
useEffect(() => onToast((toast) => {
|
|
20
|
-
setToasts((current) => [...current, {
|
|
21
|
-
...toast,
|
|
22
|
-
id: nextId++
|
|
23
|
-
}]);
|
|
24
|
-
}), []);
|
|
25
|
-
return /* @__PURE__ */ jsxs(Toast.Provider, {
|
|
26
|
-
duration,
|
|
27
|
-
swipeDirection: "down",
|
|
28
|
-
children: [toasts.map((toast) => /* @__PURE__ */ jsxs(Toast.Root, {
|
|
29
|
-
className: cn("flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg shadow-lt-lg", variantStyles[toast.variant].accent, "data-[state=open]:animate-lt-toast-in data-[state=closed]:animate-lt-toast-out", "data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=cancel]:translate-y-0 data-[swipe=cancel]:transition-transform"),
|
|
30
|
-
"data-test": `toast-${toast.variant}`,
|
|
31
|
-
duration: toast.persistent ? Infinity : toast.duration ?? duration,
|
|
32
|
-
onOpenChange: (open) => {
|
|
33
|
-
if (!open) dismiss(toast.id);
|
|
34
|
-
},
|
|
35
|
-
children: [
|
|
36
|
-
variantStyles[toast.variant].icon,
|
|
37
|
-
/* @__PURE__ */ jsxs("div", {
|
|
38
|
-
className: "flex min-w-0 flex-1 flex-col gap-2",
|
|
39
|
-
children: [/* @__PURE__ */ jsx(Toast.Title, {
|
|
40
|
-
className: "text-sm text-lt-fg",
|
|
41
|
-
children: resolveText(toast.message, t)
|
|
42
|
-
}), toast.action ? /* @__PURE__ */ jsx("div", {
|
|
43
|
-
className: "flex flex-wrap gap-2",
|
|
44
|
-
children: /* @__PURE__ */ jsx(RenderNode, { node: toast.action })
|
|
45
|
-
}) : null]
|
|
46
|
-
}),
|
|
47
|
-
toast.dismissible ? /* @__PURE__ */ jsx(Toast.Close, {
|
|
48
|
-
"aria-label": t("common.dismiss", "Dismiss"),
|
|
49
|
-
className: "shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg",
|
|
50
|
-
"data-test": "toast-dismiss",
|
|
51
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
52
|
-
name: "x",
|
|
53
|
-
className: "size-lt-icon-md"
|
|
54
|
-
})
|
|
55
|
-
}) : null
|
|
56
|
-
]
|
|
57
|
-
}, toast.id)), /* @__PURE__ */ jsx(Toast.Viewport, { className: "fixed inset-x-0 bottom-0 z-lt-toast mx-auto flex w-full max-w-sm flex-col gap-2 p-4 outline-none" })]
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { Toaster };
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=toaster.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toaster.js","names":[],"sources":["../../resources/js/toast/toaster.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/ui/icons\";\nimport * as Toast from \"@radix-ui/react-toast\";\nimport { useEffect, useState } from \"react\";\nimport { RenderNode } from \"@lattice-php/core/renderer\";\nimport type { Toast as ToastMessage } from \"@lattice-php/ui\";\nimport { onToast } from \"./toast\";\nimport { cn } from \"@lattice-php/ui/lib/utils\";\nimport { useT } from \"@lattice-php/ui/i18n\";\nimport { variantStyles } from \"./variant-styles\";\nimport { resolveText } from \"@lattice-php/ui/i18n/translatable\";\n\ntype ToastItem = ToastMessage & { id: number };\n\nlet nextId = 0;\n\nexport function Toaster({ duration = 4000 }: { duration?: number }) {\n const { t } = useT(\"lattice\");\n const [toasts, setToasts] = useState<ToastItem[]>([]);\n\n function dismiss(id: number): void {\n setToasts((current) => current.filter((toast) => toast.id !== id));\n }\n\n useEffect(\n () =>\n onToast((toast) => {\n setToasts((current) => [...current, { ...toast, id: nextId++ }]);\n }),\n [],\n );\n\n return (\n <Toast.Provider duration={duration} swipeDirection=\"down\">\n {toasts.map((toast) => (\n <Toast.Root\n key={toast.id}\n className={cn(\n \"flex items-start gap-3 rounded-lt border border-l-4 border-lt-border bg-lt-popover p-4 text-lt-popover-fg shadow-lt-lg\",\n variantStyles[toast.variant].accent,\n \"data-[state=open]:animate-lt-toast-in data-[state=closed]:animate-lt-toast-out\",\n \"data-[swipe=move]:translate-y-[var(--radix-toast-swipe-move-y)] data-[swipe=cancel]:translate-y-0 data-[swipe=cancel]:transition-transform\",\n )}\n data-test={`toast-${toast.variant}`}\n duration={toast.persistent ? Infinity : (toast.duration ?? duration)}\n onOpenChange={(open) => {\n if (!open) {\n dismiss(toast.id);\n }\n }}\n >\n {variantStyles[toast.variant].icon}\n <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n <Toast.Title className=\"text-sm text-lt-fg\">\n {resolveText(toast.message, t)}\n </Toast.Title>\n {toast.action ? (\n <div className=\"flex flex-wrap gap-2\">\n <RenderNode node={toast.action} />\n </div>\n ) : null}\n </div>\n {toast.dismissible ? (\n <Toast.Close\n aria-label={t(\"common.dismiss\", \"Dismiss\")}\n className=\"shrink-0 rounded-lt-sm p-1 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg\"\n data-test=\"toast-dismiss\"\n >\n <Icon name=\"x\" className=\"size-lt-icon-md\" />\n </Toast.Close>\n ) : null}\n </Toast.Root>\n ))}\n <Toast.Viewport className=\"fixed inset-x-0 bottom-0 z-lt-toast mx-auto flex w-full max-w-sm flex-col gap-2 p-4 outline-none\" />\n </Toast.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;AAaA,IAAI,SAAS;AAEb,SAAgB,QAAQ,EAAE,WAAW,OAA+B;CAClE,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,CAAC,QAAQ,aAAa,SAAsB,CAAC,CAAC;CAEpD,SAAS,QAAQ,IAAkB;EACjC,WAAW,YAAY,QAAQ,QAAQ,UAAU,MAAM,OAAO,EAAE,CAAC;CACnE;CAEA,gBAEI,SAAS,UAAU;EACjB,WAAW,YAAY,CAAC,GAAG,SAAS;GAAE,GAAG;GAAO,IAAI;EAAS,CAAC,CAAC;CACjE,CAAC,GACH,CAAC,CACH;CAEA,OACE,qBAAC,MAAM,UAAP;EAA0B;EAAU,gBAAe;EAAnD,UAAA,CACG,OAAO,KAAK,UACX,qBAAC,MAAM,MAAP;GAEE,WAAW,GACT,0HACA,cAAc,MAAM,QAAQ,CAAC,QAC7B,kFACA,4IACF;GACA,aAAW,SAAS,MAAM;GAC1B,UAAU,MAAM,aAAa,WAAY,MAAM,YAAY;GAC3D,eAAe,SAAS;IACtB,IAAI,CAAC,MACH,QAAQ,MAAM,EAAE;GAEpB;GAdF,UAAA;IAgBG,cAAc,MAAM,QAAQ,CAAC;IAC9B,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAAC,MAAM,OAAP;MAAa,WAAU;MACpB,UAAA,YAAY,MAAM,SAAS,CAAC;KAClB,CAAA,GACZ,MAAM,SACL,oBAAC,OAAD;MAAK,WAAU;MACb,UAAA,oBAAC,YAAD,EAAY,MAAM,MAAM,OAAS,CAAA;KAC9B,CAAA,IACH,IACD;;IACJ,MAAM,cACL,oBAAC,MAAM,OAAP;KACE,cAAY,EAAE,kBAAkB,SAAS;KACzC,WAAU;KACV,aAAU;KAEV,UAAA,oBAAC,MAAD;MAAM,MAAK;MAAI,WAAU;KAAmB,CAAA;IACjC,CAAA,IACX;GACM;EAnCL,GAAA,MAAM,EAmCD,CACb,GACD,oBAAC,MAAM,UAAP,EAAgB,WAAU,mGAAoG,CAAA,CAChH;;AAEpB"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Icon } from "@lattice-php/ui/icons";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
//#region resources/js/toast/variant-styles.tsx
|
|
4
|
-
var variantStyles = {
|
|
5
|
-
primary: {
|
|
6
|
-
accent: "border-l-lt-primary",
|
|
7
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
8
|
-
name: "info",
|
|
9
|
-
className: "size-lt-icon-lg shrink-0 text-lt-primary"
|
|
10
|
-
})
|
|
11
|
-
},
|
|
12
|
-
secondary: {
|
|
13
|
-
accent: "border-l-lt-secondary",
|
|
14
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
15
|
-
name: "info",
|
|
16
|
-
className: "size-lt-icon-lg shrink-0 text-lt-muted-fg"
|
|
17
|
-
})
|
|
18
|
-
},
|
|
19
|
-
success: {
|
|
20
|
-
accent: "border-l-lt-success",
|
|
21
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
22
|
-
name: "circle-check",
|
|
23
|
-
className: "size-lt-icon-lg shrink-0 text-lt-success"
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
info: {
|
|
27
|
-
accent: "border-l-lt-info",
|
|
28
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
29
|
-
name: "info",
|
|
30
|
-
className: "size-lt-icon-lg shrink-0 text-lt-info"
|
|
31
|
-
})
|
|
32
|
-
},
|
|
33
|
-
warning: {
|
|
34
|
-
accent: "border-l-lt-warning",
|
|
35
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
36
|
-
name: "circle-alert",
|
|
37
|
-
className: "size-lt-icon-lg shrink-0 text-lt-warning"
|
|
38
|
-
})
|
|
39
|
-
},
|
|
40
|
-
danger: {
|
|
41
|
-
accent: "border-l-lt-danger",
|
|
42
|
-
icon: /* @__PURE__ */ jsx(Icon, {
|
|
43
|
-
name: "circle-x",
|
|
44
|
-
className: "size-lt-icon-lg shrink-0 text-lt-danger"
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
//#endregion
|
|
49
|
-
export { variantStyles };
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=variant-styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variant-styles.js","names":[],"sources":["../../resources/js/toast/variant-styles.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/ui/icons\";\nimport type { ReactNode } from \"react\";\nimport type { Variant } from \"@lattice-php/ui\";\n\nexport const variantStyles: Record<Variant, { accent: string; icon: ReactNode }> = {\n primary: {\n accent: \"border-l-lt-primary\",\n icon: <Icon name=\"info\" className=\"size-lt-icon-lg shrink-0 text-lt-primary\" />,\n },\n secondary: {\n accent: \"border-l-lt-secondary\",\n icon: <Icon name=\"info\" className=\"size-lt-icon-lg shrink-0 text-lt-muted-fg\" />,\n },\n success: {\n accent: \"border-l-lt-success\",\n icon: <Icon name=\"circle-check\" className=\"size-lt-icon-lg shrink-0 text-lt-success\" />,\n },\n info: {\n accent: \"border-l-lt-info\",\n icon: <Icon name=\"info\" className=\"size-lt-icon-lg shrink-0 text-lt-info\" />,\n },\n warning: {\n accent: \"border-l-lt-warning\",\n icon: <Icon name=\"circle-alert\" className=\"size-lt-icon-lg shrink-0 text-lt-warning\" />,\n },\n danger: {\n accent: \"border-l-lt-danger\",\n icon: <Icon name=\"circle-x\" className=\"size-lt-icon-lg shrink-0 text-lt-danger\" />,\n },\n};\n"],"mappings":";;;AAIA,IAAa,gBAAsE;CACjF,SAAS;EACP,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAO,WAAU;EAA4C,CAAA;CAChF;CACA,WAAW;EACT,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAO,WAAU;EAA6C,CAAA;CACjF;CACA,SAAS;EACP,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAe,WAAU;EAA4C,CAAA;CACxF;CACA,MAAM;EACJ,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAO,WAAU;EAAyC,CAAA;CAC7E;CACA,SAAS;EACP,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAe,WAAU;EAA4C,CAAA;CACxF;CACA,QAAQ;EACN,QAAQ;EACR,MAAM,oBAAC,MAAD;GAAM,MAAK;GAAW,WAAU;EAA2C,CAAA;CACnF;AACF"}
|