@lattice-php/lattice 0.61.0 → 0.63.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/vite.d.ts +12 -1
- package/dist/vite.js +27 -2
- package/dist/vite.js.map +1 -1
- package/dist-standalone/chunks/chart-view-DDMYuMfl.js +59 -0
- package/dist-standalone/chunks/{date-picker-field-B09aCbOL.js → date-picker-view-C900j9vx.js} +1 -1
- package/dist-standalone/chunks/dist-Dd8dg4q5.js +106 -0
- package/dist-standalone/chunks/{field-rjVaymdj.js → pattern-input-view-fft15W-u.js} +1 -1
- package/dist-standalone/chunks/rich-editor-view-NSVl9YGe.js +53 -0
- package/dist-standalone/chunks/runtime-2lXh8My2.js +162 -0
- package/dist-standalone/chunks/{subscriptions-P9PiNr3N.js → subscriptions-C7Y-lvpC.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
package/dist/provider-base.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { updateAppearance } from "./appearance/index.js";
|
|
2
|
-
import { Toaster } from "./toast/toaster.js";
|
|
3
2
|
import { useFlashEffects } from "./effects/use-flash-effects.js";
|
|
4
3
|
import { EventBridge } from "./event-bridge.js";
|
|
5
|
-
import {
|
|
4
|
+
import { useCloseModalsOnNavigate, useInertiaNavigation } from "./inertia-navigation.js";
|
|
6
5
|
import { RegistryProvider } from "@lattice-php/core/registry-context";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
7
|
import { ActionInteractionProvider } from "@lattice-php/action/components/action-trigger-provider";
|
|
9
8
|
import { NavigationProvider } from "@lattice-php/ui/navigation";
|
|
10
|
-
import { ModalProvider } from "@lattice-php/ui/modal";
|
|
9
|
+
import { ModalProvider } from "@lattice-php/ui/components/modal/modal-host";
|
|
11
10
|
import { SpriteProvider } from "@lattice-php/ui/icons/sprite";
|
|
11
|
+
import { Toaster } from "@lattice-php/ui/toast";
|
|
12
12
|
//#region resources/js/provider-base.tsx
|
|
13
13
|
var defaultSprite = { href: "" };
|
|
14
|
-
function ProviderBase({ children, registry, sprite = defaultSprite, toaster = true }) {
|
|
14
|
+
function ProviderBase({ children, initialUrl, registry, sprite = defaultSprite, toaster = true }) {
|
|
15
15
|
useFlashEffects();
|
|
16
16
|
useCloseModalsOnNavigate();
|
|
17
|
+
const navigation = useInertiaNavigation(initialUrl);
|
|
17
18
|
return /* @__PURE__ */ jsx(RegistryProvider, {
|
|
18
19
|
registry,
|
|
19
20
|
children: /* @__PURE__ */ jsx(NavigationProvider, {
|
|
20
|
-
adapter:
|
|
21
|
+
adapter: navigation,
|
|
21
22
|
children: /* @__PURE__ */ jsx(ActionInteractionProvider, { children: /* @__PURE__ */ jsx(SpriteProvider, {
|
|
22
23
|
sprite,
|
|
23
24
|
children: /* @__PURE__ */ jsxs(ModalProvider, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-base.js","names":[],"sources":["../resources/js/provider-base.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { ActionInteractionProvider } from \"@lattice-php/action/components/action-trigger-provider\";\nimport type { Registry } from \"@lattice-php/core/registry\";\nimport { RegistryProvider } from \"@lattice-php/core/registry-context\";\nimport { useFlashEffects } from \"./effects/use-flash-effects\";\nimport { NavigationProvider } from \"@lattice-php/ui/navigation\";\nimport { ModalProvider } from \"@lattice-php/ui/modal\";\nimport { EventBridge } from \"./event-bridge\";\nimport {
|
|
1
|
+
{"version":3,"file":"provider-base.js","names":[],"sources":["../resources/js/provider-base.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { ActionInteractionProvider } from \"@lattice-php/action/components/action-trigger-provider\";\nimport type { Registry } from \"@lattice-php/core/registry\";\nimport { RegistryProvider } from \"@lattice-php/core/registry-context\";\nimport { useFlashEffects } from \"./effects/use-flash-effects\";\nimport { NavigationProvider } from \"@lattice-php/ui/navigation\";\nimport { ModalProvider } from \"@lattice-php/ui/components/modal/modal-host\";\nimport { EventBridge } from \"./event-bridge\";\nimport { useCloseModalsOnNavigate, useInertiaNavigation } from \"./inertia-navigation\";\nimport type { SpriteValue } from \"@lattice-php/ui/icons/sprite\";\nimport { SpriteProvider } from \"@lattice-php/ui/icons/sprite\";\nimport { Toaster } from \"@lattice-php/ui/toast\";\nimport { updateAppearance } from \"./appearance\";\n\nconst defaultSprite: SpriteValue = { href: \"\" };\n\nexport type ProviderBaseProps = {\n children: ReactNode;\n /** The url of the page being rendered, so the first render already knows it (SSR included). */\n initialUrl?: string;\n registry: Registry;\n sprite?: SpriteValue;\n toaster?: boolean;\n};\n\nexport function ProviderBase({\n children,\n initialUrl,\n registry,\n sprite = defaultSprite,\n toaster = true,\n}: ProviderBaseProps) {\n useFlashEffects();\n useCloseModalsOnNavigate();\n const navigation = useInertiaNavigation(initialUrl);\n\n return (\n <RegistryProvider registry={registry}>\n <NavigationProvider adapter={navigation}>\n <ActionInteractionProvider>\n <SpriteProvider sprite={sprite}>\n <ModalProvider>\n {children}\n <EventBridge onAppearanceChange={updateAppearance} />\n {toaster ? <Toaster /> : null}\n </ModalProvider>\n </SpriteProvider>\n </ActionInteractionProvider>\n </NavigationProvider>\n </RegistryProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAcA,IAAM,gBAA6B,EAAE,MAAM,GAAG;AAW9C,SAAgB,aAAa,EAC3B,UACA,YACA,UACA,SAAS,eACT,UAAU,QACU;CACpB,gBAAgB;CAChB,yBAAyB;CACzB,MAAM,aAAa,qBAAqB,UAAU;CAElD,OACE,oBAAC,kBAAD;EAA4B;EAC1B,UAAA,oBAAC,oBAAD;GAAoB,SAAS;GAC3B,UAAA,oBAAC,2BAAD,EAAA,UACE,oBAAC,gBAAD;IAAwB;IACtB,UAAA,qBAAC,eAAD,EAAA,UAAA;KACG;KACD,oBAAC,aAAD,EAAa,oBAAoB,iBAAmB,CAAA;KACnD,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI;IACZ,EAAA,CAAA;GACD,CAAA,EACS,CAAA;EACT,CAAA;CACJ,CAAA;AAEtB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { buildEffects } from "./build-effects.js";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
4
|
import { useEffectDispatcher } from "@lattice-php/ui/effects/use-effect-dispatcher";
|
|
5
|
+
import { useT } from "@lattice-php/ui/i18n";
|
|
6
6
|
import { useEcho, useEchoPresence, useEchoPublic } from "@laravel/echo-react";
|
|
7
7
|
//#region resources/js/realtime/subscriptions.tsx
|
|
8
8
|
function useListenerHandler(listener) {
|
|
@@ -37,7 +37,7 @@ function Listener({ listener }) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function Subscriptions({ listeners }) {
|
|
40
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
40
|
+
return /* @__PURE__ */ jsx(Fragment, { children: listeners.map((listener, index) => /* @__PURE__ */ jsx(Listener, { listener }, `${listener.visibility}:${listener.channel}:${index}`)) });
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
43
|
export { Subscriptions as default };
|
|
@@ -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/ui/effects/use-effect-dispatcher\";\nimport { useT } from \"@lattice-php/ui/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,
|
|
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/ui/effects/use-effect-dispatcher\";\nimport { useT } from \"@lattice-php/ui/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,UAAA,EAAA,UACG,UAAU,KAAK,UAAU,UACxB,oBAAC,UAAD,EAAgF,SAAW,GAA5E,GAAG,SAAS,WAAW,GAAG,SAAS,QAAQ,GAAG,OAA8B,CAC5F,EACD,CAAA;AAEN"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { remoteJson } from "@lattice-php/core/api";
|
|
3
3
|
import { materializeSchema } from "@lattice-php/core/materialize";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
5
|
import { Renderer } from "@lattice-php/core/renderer";
|
|
5
6
|
import { useT } from "@lattice-php/ui/i18n";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region resources/js/remote/components/data-list.tsx
|
|
8
8
|
function label(value) {
|
|
9
9
|
if (value === null || value === void 0) return "";
|
package/dist/runtime.d.ts
CHANGED
|
@@ -11,15 +11,15 @@ export { RenderNode } from '@lattice-php/core/renderer';
|
|
|
11
11
|
export { coerceColor, toneProps } from '@lattice-php/ui/lib/color';
|
|
12
12
|
export { nodeIdentity } from '@lattice-php/core/test-id';
|
|
13
13
|
export { requestSignedUpload, xhrTransfer } from '@lattice-php/core/upload';
|
|
14
|
-
export { SimpleField } from '@lattice-php/form/components/
|
|
14
|
+
export { SimpleField } from '@lattice-php/form/components/base/simple-field';
|
|
15
15
|
export { RICH_EDITOR_EXTENSION, ToolbarIconButton } from '@lattice-php/form/rich-editor';
|
|
16
16
|
export * from '@lattice-php/form/toolkit';
|
|
17
17
|
export { useTable } from '@lattice-php/table/hooks/use-table';
|
|
18
18
|
export { useTableSelection } from '@lattice-php/table/hooks/use-table-selection';
|
|
19
19
|
export { getBulkActionNodes } from '@lattice-php/table/lib/bulk';
|
|
20
20
|
export { useAction } from '@lattice-php/action/hooks/use-action';
|
|
21
|
-
export { MODAL_MISSING_ERROR, useEmbeddedModal, useModal } from '@lattice-php/ui/modal';
|
|
22
|
-
export { Badge, Button,
|
|
21
|
+
export { MODAL_MISSING_ERROR, useEmbeddedModal, useModal, } from '@lattice-php/ui/components/modal/modal-host';
|
|
22
|
+
export { Badge, Button, cn, CodeBlock, ConfirmDialog, CopyButton, Dialog, DialogContent, DialogHeader, DialogTitle, formatDateValue, IconButton, InfoTooltip, NativeSelect, PreviewableImage, SegmentedControl, Spinner, useDebouncedCallback, useFormatContext, usePersistentState, } from '@lattice-php/ui';
|
|
23
|
+
export { Checkbox, Combobox, Input, Label, Textarea } from '@lattice-php/form';
|
|
23
24
|
export * from '@lattice-php/ui/i18n';
|
|
24
25
|
export { announce, attachTreeItemInstruction, combine, draggable, dropTargetForElements, extractTreeItemInstruction, } from './dnd/index.js';
|
|
25
|
-
export type { Variant } from './toast/index.js';
|
package/dist/runtime.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { initializeAppearance, updateAppearance, useAppearance } from "./appearance/index.js";
|
|
2
|
-
import { onToast } from "./toast/toast.js";
|
|
3
|
-
import { onCallout } from "./toast/callout.js";
|
|
4
|
-
import { Toaster } from "./toast/toaster.js";
|
|
5
|
-
import Callouts from "./layout/components/callouts.js";
|
|
6
2
|
import { OutletProvider, useOutlet } from "./layout/hooks/context.js";
|
|
7
3
|
import { layoutComponents } from "./layout/plugin.js";
|
|
8
4
|
import SchemaLayout from "./layout/components/schema-layout.js";
|
|
@@ -19,15 +15,16 @@ import { router } from "@inertiajs/react";
|
|
|
19
15
|
import { apiFetch, apiJson, setRefRefreshEndpoint, xsrfToken } from "@lattice-php/core/api";
|
|
20
16
|
import { useExtensionRegistry } from "@lattice-php/core/registry-context";
|
|
21
17
|
import { RenderNode } from "@lattice-php/core/renderer";
|
|
22
|
-
import { nodeIdentity } from "@lattice-php/core/test-id";
|
|
23
18
|
import { NavigationProvider, defaultNavigation, useNavigation } from "@lattice-php/ui/navigation";
|
|
24
|
-
import { MODAL_MISSING_ERROR, useEmbeddedModal, useModal } from "@lattice-php/ui/modal";
|
|
25
|
-
import {
|
|
19
|
+
import { MODAL_MISSING_ERROR, useEmbeddedModal, useModal } from "@lattice-php/ui/components/modal/modal-host";
|
|
20
|
+
import { Checkbox, Combobox, Input, Label, Textarea } from "@lattice-php/form";
|
|
21
|
+
import { Badge, Button, CodeBlock, ConfirmDialog, CopyButton, Dialog, DialogContent, DialogHeader, DialogTitle, IconButton, InfoTooltip, NativeSelect, PreviewableImage, SegmentedControl, Spinner, cn, formatDateValue, useDebouncedCallback, useFormatContext, usePersistentState } from "@lattice-php/ui";
|
|
26
22
|
import { callAction, runAction, useCallAction } from "@lattice-php/action";
|
|
27
23
|
import { ActionConfirmOverlay } from "@lattice-php/action/components/action-confirm-overlay";
|
|
28
24
|
import { coerceColor, toneProps } from "@lattice-php/ui/lib/color";
|
|
25
|
+
import { nodeIdentity } from "@lattice-php/core/test-id";
|
|
29
26
|
import { requestSignedUpload, xhrTransfer } from "@lattice-php/core/upload";
|
|
30
|
-
import { SimpleField } from "@lattice-php/form/components/
|
|
27
|
+
import { SimpleField } from "@lattice-php/form/components/base/simple-field";
|
|
31
28
|
import { RICH_EDITOR_EXTENSION, ToolbarIconButton } from "@lattice-php/form/rich-editor";
|
|
32
29
|
import { useTable } from "@lattice-php/table/hooks/use-table";
|
|
33
30
|
import { useTableSelection } from "@lattice-php/table/hooks/use-table-selection";
|
|
@@ -35,4 +32,4 @@ import { getBulkActionNodes } from "@lattice-php/table/lib/bulk";
|
|
|
35
32
|
import { useAction } from "@lattice-php/action/hooks/use-action";
|
|
36
33
|
export * from "@lattice-php/ui/i18n";
|
|
37
34
|
export * from "@lattice-php/form/toolkit";
|
|
38
|
-
export { ActionConfirmOverlay, Badge, Button,
|
|
35
|
+
export { ActionConfirmOverlay, Badge, Button, Checkbox, CodeBlock, Combobox, ConfirmDialog, CopyButton, Dialog, DialogContent, DialogHeader, DialogTitle, EventBridge, Icon, IconButton, IconRenderer, IconRendererProvider, InfoTooltip, Input, LATTICE_EVENT, LATTICE_REF_HEADER, Label, MODAL_MISSING_ERROR, NativeSelect, NavigationProvider, OutletProvider, PreviewableImage, Provider, RICH_EDITOR_EXTENSION, RealtimeListeners, RenderNode, Renderer, SchemaLayout, SegmentedControl, SimpleField, Spinner, SpriteProvider, Textarea, ToolbarIconButton, announce, apiFetch, apiJson, attachTreeItemInstruction, builtinEffectHandlers, callAction, cn, coerceColor, columnCell, combine, copyToClipboard, createLatticeApp, createLayoutResolver, createPageResolver, createRegistry, defaultNavigation, dispatchActionError, dispatchEffects, draggable, dropTargetForElements, eagerComponent, effectHandler, extendRegistry, extractTreeItemInstruction, formatDateValue, getActionEffects, getBulkActionNodes, inertiaNavigation, initializeAppearance, isActionEffect, layoutComponents, lazyComponent, loadPluginModules, mergeEffectHandlers, navigationPlugin, nodeIdentity, pageComponentName, registry, requestSignedUpload, router, runAction, setRefRefreshEndpoint, toneProps, updateAppearance, useAction, useAppearance, useCallAction, useColumnRegistry, useComponentRegistry, useDebouncedCallback, useEffectDispatcher, useEmbeddedModal, useExtensionRegistry, useFormatContext, useModal, useNavigation, useOutlet, usePersistentState, useTable, useTableSelection, withHeaders, withRefHeader, withVisitHeaders, xhrTransfer, xsrfToken };
|
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Breadcrumb, Node, RemoteAccess } from '@lattice-php/core';
|
|
2
|
+
import { Size, Translatable, Variant } from '@lattice-php/ui';
|
|
3
3
|
import { Effect } from '@lattice-php/ui/effects/types';
|
|
4
4
|
export type ActionNodeType = "action" | "action.bulk" | "action.group";
|
|
5
|
-
export type Breadcrumbs = Record<string, never>;
|
|
6
5
|
export type CalendarNodeType = "calendar";
|
|
7
|
-
export type Callouts = Record<string, never>;
|
|
8
6
|
export type ChannelVisibility = "public" | "private" | "presence";
|
|
9
7
|
export type ChatNodeType = "chat.box" | "chat.part.text" | "chat.part.tool-call";
|
|
10
8
|
export type ColumnNodeType = "column.badge" | "column.boolean" | "column.icon" | "column.image" | "column.money" | "column.number" | "column.stack" | "column.text";
|
|
11
9
|
export type ComponentPropsMap = {
|
|
12
|
-
breadcrumbs: Breadcrumbs;
|
|
13
|
-
callouts: Callouts;
|
|
14
|
-
dropdown: Dropdown;
|
|
15
10
|
fragment: Fragment;
|
|
16
|
-
menu: Menu;
|
|
17
|
-
"menu-item": MenuItem;
|
|
18
11
|
notifications: Notifications;
|
|
19
12
|
outlet: Outlet;
|
|
20
13
|
"remote.data-list": DataList;
|
|
21
|
-
sidebar: Sidebar;
|
|
22
|
-
"sidebar.footer": SidebarFooter;
|
|
23
|
-
topbar: Topbar;
|
|
24
14
|
};
|
|
25
15
|
export type DataList = {
|
|
26
16
|
dataEndpoint: string | null;
|
|
27
17
|
emptyLabel: string | null;
|
|
28
18
|
remote: RemoteAccess | null;
|
|
29
19
|
};
|
|
30
|
-
export type Dropdown = {
|
|
31
|
-
placement: Placement;
|
|
32
|
-
trigger: Node[];
|
|
33
|
-
};
|
|
34
20
|
export type FilterNodeType = "filter.date-range" | "filter.media-type" | "filter.select" | "filter.ternary" | "filter.toggle";
|
|
35
21
|
export type FormFieldNodeType = "field.builder" | "field.checkbox" | "field.choice" | "field.color-picker" | "field.date-input" | "field.date-time-input" | "field.file-upload" | "field.hidden-input" | "field.media-picker" | "field.number-input" | "field.otp" | "field.password-input" | "field.pattern-input" | "field.repeater" | "field.rich-editor" | "field.select" | "field.text-input" | "field.textarea" | "field.time-input" | "field.toggle" | "field.tree" | "wizard" | "wizard-step";
|
|
36
22
|
export type FormNodeType = "field.builder" | "field.checkbox" | "field.choice" | "field.color-picker" | "field.date-input" | "field.date-time-input" | "field.file-upload" | "field.hidden-input" | "field.media-picker" | "field.number-input" | "field.otp" | "field.password-input" | "field.pattern-input" | "field.repeater" | "field.rich-editor" | "field.select" | "field.text-input" | "field.textarea" | "field.time-input" | "field.toggle" | "field.tree" | "form" | "wizard" | "wizard-step";
|
|
@@ -51,7 +37,7 @@ export type I18nConfig = {
|
|
|
51
37
|
readonly saveMissing: boolean;
|
|
52
38
|
readonly timezone: string | null;
|
|
53
39
|
};
|
|
54
|
-
export type LayoutNodeType = "
|
|
40
|
+
export type LayoutNodeType = "outlet";
|
|
55
41
|
export type Listen = {
|
|
56
42
|
readonly channel: string;
|
|
57
43
|
effects: Effect[];
|
|
@@ -60,18 +46,6 @@ export type Listen = {
|
|
|
60
46
|
};
|
|
61
47
|
export type MapNodeType = "map";
|
|
62
48
|
export type MediumNodeType = "media.library";
|
|
63
|
-
export type Menu = Record<string, never>;
|
|
64
|
-
export type MenuItem = {
|
|
65
|
-
action: Node | null;
|
|
66
|
-
effects: Effect[];
|
|
67
|
-
href: string | null;
|
|
68
|
-
icon: string | null;
|
|
69
|
-
label: string | null;
|
|
70
|
-
method: HttpMethod | null;
|
|
71
|
-
modal: Node<"modal"> | null;
|
|
72
|
-
prefix: Affix | null;
|
|
73
|
-
suffix: Affix | null;
|
|
74
|
-
};
|
|
75
49
|
export type NodeType = "action" | "action.bulk" | "action.group" | "api-reference" | "avatar" | "badge" | "breadcrumbs" | "button" | "calendar" | "callouts" | "card" | "chart" | "chat.box" | "chat.part.text" | "chat.part.tool-call" | "code-block" | "collapsible" | "description-list" | "dropdown" | "entry.badge" | "entry.boolean" | "entry.component" | "entry.date" | "entry.text" | "field.builder" | "field.checkbox" | "field.choice" | "field.color-picker" | "field.date-input" | "field.date-time-input" | "field.file-upload" | "field.hidden-input" | "field.media-picker" | "field.number-input" | "field.otp" | "field.password-input" | "field.pattern-input" | "field.repeater" | "field.rich-editor" | "field.select" | "field.text-input" | "field.textarea" | "field.time-input" | "field.toggle" | "field.tree" | "floating-panel" | "form" | "fragment" | "grid" | "heading" | "icon" | "image" | "link" | "map" | "media.library" | "menu" | "menu-item" | "modal" | "notifications" | "outlet" | "pdf" | "popover" | "progress" | "raw-block" | "remote.data-list" | "search.box" | "search.categories" | "search.input" | "search.preview" | "search.recent" | "search.results" | "section" | "segmented-control" | "separator" | "sidebar" | "sidebar.footer" | "signature" | "stack" | "tab" | "table" | "tabs" | "text" | "tooltip" | "topbar" | "tree" | "wizard" | "wizard-step";
|
|
76
50
|
export type NotificationItem = {
|
|
77
51
|
readonly actions: Node[];
|
|
@@ -112,17 +86,9 @@ export type PagePayload = {
|
|
|
112
86
|
export type PdfNodeType = "pdf";
|
|
113
87
|
export type RemoteNodeType = "remote.data-list";
|
|
114
88
|
export type SearchNodeType = "search.box" | "search.categories" | "search.input" | "search.preview" | "search.recent" | "search.results";
|
|
115
|
-
export type Sidebar = {
|
|
116
|
-
collapsible: boolean;
|
|
117
|
-
rememberState: boolean;
|
|
118
|
-
};
|
|
119
|
-
export type SidebarFooter = Record<string, never>;
|
|
120
89
|
export type SignatureExampleNodeType = "signature";
|
|
121
90
|
export type TableNodeType = "table";
|
|
122
|
-
export type
|
|
123
|
-
sticky: boolean;
|
|
124
|
-
};
|
|
125
|
-
export type UiNodeType = "avatar" | "badge" | "button" | "card" | "chart" | "code-block" | "collapsible" | "description-list" | "entry.badge" | "entry.boolean" | "entry.component" | "entry.date" | "entry.text" | "floating-panel" | "grid" | "heading" | "icon" | "image" | "link" | "modal" | "popover" | "progress" | "raw-block" | "section" | "segmented-control" | "separator" | "stack" | "tab" | "tabs" | "text" | "tooltip";
|
|
91
|
+
export type UiNodeType = "avatar" | "badge" | "breadcrumbs" | "button" | "callouts" | "card" | "chart" | "code-block" | "collapsible" | "description-list" | "dropdown" | "entry.badge" | "entry.boolean" | "entry.component" | "entry.date" | "entry.text" | "floating-panel" | "grid" | "heading" | "icon" | "image" | "link" | "menu" | "menu-item" | "modal" | "popover" | "progress" | "raw-block" | "section" | "segmented-control" | "separator" | "sidebar" | "sidebar.footer" | "stack" | "tab" | "tabs" | "text" | "tooltip" | "topbar";
|
|
126
92
|
export type UnreadCount = {
|
|
127
93
|
readonly unreadCount: number;
|
|
128
94
|
};
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconTypesOptions, SvgSpriteOptions } from '@lattice-php/vite-svg-sprite';
|
|
1
|
+
import { IconTypesOptions, Sprite, SvgSpriteOptions } from '@lattice-php/vite-svg-sprite';
|
|
2
2
|
import { Plugin, PluginOption, UserConfig } from 'vite';
|
|
3
3
|
type InlineDependency = string | RegExp;
|
|
4
4
|
type ConfigWithTest = UserConfig & {
|
|
@@ -83,4 +83,15 @@ export declare function discoverComponentPackages(appRoot: string): LatticeCompo
|
|
|
83
83
|
export declare function componentPackagesPlugin(packages: LatticeComponentPackage[]): Plugin;
|
|
84
84
|
export declare function latticeConfig(options?: LatticeViteOptions): ConfigWithTest;
|
|
85
85
|
export declare function resolveIconOptions(options: LatticeViteOptions, packages?: LatticeComponentPackage[]): SvgSpriteOptions | null;
|
|
86
|
+
/**
|
|
87
|
+
* Builds the same icon sprite the `lattice()` Vite plugin serves, outside of
|
|
88
|
+
* Vite: ui's icon set, every discovered component package's icons, and the
|
|
89
|
+
* app's own `icons.dirs`. The result is a `SpriteValue` for `SpriteProvider`
|
|
90
|
+
* (`href: ""` inlines the markup), which is what a Storybook, a design-system
|
|
91
|
+
* export, a prerender script, or a test needs to render `Icon` without a
|
|
92
|
+
* dev server or an emitted asset.
|
|
93
|
+
*/
|
|
94
|
+
export declare function buildLatticeSprite(options?: LatticeViteOptions): Sprite & {
|
|
95
|
+
href: "";
|
|
96
|
+
};
|
|
86
97
|
export {};
|
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { refreshTypeScriptTypes } from "./vite-typescript-refresh.js";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { svgSprite } from "@lattice-php/vite-svg-sprite";
|
|
4
|
+
import { buildSprite, svgSprite } from "@lattice-php/vite-svg-sprite";
|
|
5
5
|
import { searchForWorkspaceRoot } from "vite";
|
|
6
6
|
//#region resources/js/vite.ts
|
|
7
7
|
function lattice(options = {}) {
|
|
@@ -232,6 +232,31 @@ function resolveIconOptions(options, packages = []) {
|
|
|
232
232
|
} }
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Builds the same icon sprite the `lattice()` Vite plugin serves, outside of
|
|
237
|
+
* Vite: ui's icon set, every discovered component package's icons, and the
|
|
238
|
+
* app's own `icons.dirs`. The result is a `SpriteValue` for `SpriteProvider`
|
|
239
|
+
* (`href: ""` inlines the markup), which is what a Storybook, a design-system
|
|
240
|
+
* export, a prerender script, or a test needs to render `Icon` without a
|
|
241
|
+
* dev server or an emitted asset.
|
|
242
|
+
*/
|
|
243
|
+
function buildLatticeSprite(options = {}) {
|
|
244
|
+
const { appRoot } = resolveRoots(options);
|
|
245
|
+
const iconOptions = resolveIconOptions(options, discoverComponentPackages(appRoot));
|
|
246
|
+
if (!iconOptions) return {
|
|
247
|
+
href: "",
|
|
248
|
+
ids: [],
|
|
249
|
+
source: ""
|
|
250
|
+
};
|
|
251
|
+
const { iconDirs = [], symbolId, svgoConfig } = iconOptions;
|
|
252
|
+
return {
|
|
253
|
+
href: "",
|
|
254
|
+
...buildSprite(iconDirs, {
|
|
255
|
+
symbolId,
|
|
256
|
+
svgoConfig
|
|
257
|
+
})
|
|
258
|
+
};
|
|
259
|
+
}
|
|
235
260
|
function resolveRoots(options) {
|
|
236
261
|
const appRoot = options.appRoot ?? process.cwd();
|
|
237
262
|
return {
|
|
@@ -240,6 +265,6 @@ function resolveRoots(options) {
|
|
|
240
265
|
};
|
|
241
266
|
}
|
|
242
267
|
//#endregion
|
|
243
|
-
export { collectComponentPackages, collectRootComponentPackage, componentPackagesPlugin, discoverComponentPackages, lattice, latticeConfig, resolveIconOptions };
|
|
268
|
+
export { buildLatticeSprite, collectComponentPackages, collectRootComponentPackage, componentPackagesPlugin, discoverComponentPackages, lattice, latticeConfig, resolveIconOptions };
|
|
244
269
|
|
|
245
270
|
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { IconTypesOptions, SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\nimport { refreshTypeScriptTypes } from \"./vite-typescript-refresh.ts\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: Partial<IconTypesOptions> | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n /** Refresh generated TypeScript types via the dev server. Defaults to `true`. */\n typescript?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const { appRoot } = resolveRoots(options);\n const packages = discoverComponentPackages(appRoot);\n const plugins: PluginOption[] = [\n corePlugin(options),\n optionalPeersPlugin(),\n componentPackagesPlugin(packages),\n typescriptPlugin(options),\n ];\n const iconOptions = resolveIconOptions(options, packages);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\n/** A Composer package that contributes a Lattice component plugin. */\nexport type LatticeComponentPackage = {\n name: string;\n /** Absolute path to the package's installed directory. */\n dir: string;\n /** Absolute path to the package's JS plugin entry. */\n plugin: string;\n /** Absolute path to the package's stylesheet, when it declares one. */\n css?: string;\n /** Absolute path to the package's icon directory, when it declares one. */\n icons?: string;\n};\n\ntype LatticeManifest = { plugin?: string; css?: string; icons?: string };\n\ntype InstalledPackage = {\n name: string;\n \"install-path\"?: string;\n extra?: { lattice?: LatticeManifest };\n};\n\ntype RootPackageJson = {\n name?: string;\n extra?: { lattice?: LatticeManifest };\n};\n\nfunction resolveManifestPaths(\n manifest: LatticeManifest,\n dir: string,\n): Pick<LatticeComponentPackage, \"css\" | \"icons\"> {\n return {\n ...(typeof manifest.css === \"string\" ? { css: path.resolve(dir, manifest.css) } : {}),\n ...(typeof manifest.icons === \"string\" ? { icons: path.resolve(dir, manifest.icons) } : {}),\n };\n}\n\n/**\n * Resolve every Composer package that declares `extra.lattice.plugin` into an\n * absolute plugin-entry path. `installPathsRelativeTo` is `vendor/composer` (the\n * dir `installed.json` records its `install-path`s against).\n */\nexport function collectComponentPackages(\n installed: { packages?: InstalledPackage[] } | InstalledPackage[],\n installPathsRelativeTo: string,\n): LatticeComponentPackage[] {\n const packages = Array.isArray(installed) ? installed : (installed.packages ?? []);\n\n return packages.flatMap((pkg) => {\n const manifest = pkg.extra?.lattice ?? {};\n const entry = manifest.plugin;\n\n if (typeof entry !== \"string\") {\n return [];\n }\n\n const dir = path.resolve(installPathsRelativeTo, pkg[\"install-path\"] ?? `../${pkg.name}`);\n\n return [\n {\n name: pkg.name,\n dir,\n plugin: path.resolve(dir, entry),\n ...resolveManifestPaths(manifest, dir),\n },\n ];\n });\n}\n\n/**\n * Resolve the composer ROOT project's own `extra.lattice.plugin` — Composer\n * never lists the root package in `installed.json`, so a component package\n * declaring the plugin entry in its own composer.json would otherwise be\n * invisible to its own dev server (e.g. inside a testbench workbench, where\n * the package itself is the app root).\n */\nexport function collectRootComponentPackage(\n composerJson: RootPackageJson,\n appRoot: string,\n): LatticeComponentPackage[] {\n const manifest = composerJson.extra?.lattice ?? {};\n\n if (typeof manifest.plugin !== \"string\" || typeof composerJson.name !== \"string\") {\n return [];\n }\n\n return [\n {\n name: composerJson.name,\n dir: appRoot,\n plugin: path.resolve(appRoot, manifest.plugin),\n ...resolveManifestPaths(manifest, appRoot),\n },\n ];\n}\n\n/**\n * Read `<appRoot>/vendor/composer/installed.json` and `<appRoot>/composer.json`\n * and collect every component package they contribute.\n */\nexport function discoverComponentPackages(appRoot: string): LatticeComponentPackage[] {\n const composerDir = path.resolve(appRoot, \"vendor/composer\");\n\n let installed: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(composerDir, \"installed.json\"), \"utf8\");\n installed = collectComponentPackages(JSON.parse(raw), composerDir);\n } catch {\n installed = [];\n }\n\n let root: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(appRoot, \"composer.json\"), \"utf8\");\n root = collectRootComponentPackage(JSON.parse(raw), appRoot);\n } catch {\n root = [];\n }\n\n return [...installed, ...root];\n}\n\nconst VIRTUAL_PLUGINS_ID = \"virtual:lattice/plugins\";\nconst RESOLVED_VIRTUAL_PLUGINS_ID = `\\0${VIRTUAL_PLUGINS_ID}`;\n\n/**\n * Exposes the discovered component packages as `virtual:lattice/plugins` — a\n * module whose default export is the array of their plugin objects,\n * ready for `extendRegistry(registry, ...plugins)`. Also grants Vite filesystem\n * access to each package dir so its source compiles from `vendor/` (or a symlink).\n */\nexport function componentPackagesPlugin(packages: LatticeComponentPackage[]): Plugin {\n return {\n name: \"lattice:component-packages\",\n config(config) {\n if (packages.length === 0) {\n return {};\n }\n\n const workspaceRoot = searchForWorkspaceRoot(config.root ?? process.cwd());\n // Vite's mergeAlias puts plugin-config aliases in front of the user config's,\n // so this specific `/css` alias wins over a user's broader package-dir alias.\n const alias = Object.fromEntries(\n packages.flatMap((pkg) => (pkg.css ? [[`@${pkg.name}/css`, pkg.css]] : [])),\n );\n\n return {\n ...(Object.keys(alias).length > 0 ? { resolve: { alias } } : {}),\n server: { fs: { allow: [workspaceRoot, ...packages.map((pkg) => pkg.dir)] } },\n };\n },\n resolveId(id) {\n return id === VIRTUAL_PLUGINS_ID ? RESOLVED_VIRTUAL_PLUGINS_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_PLUGINS_ID) {\n return null;\n }\n\n const imports = packages\n .map((pkg, index) => `import p${index} from ${JSON.stringify(pkg.plugin)};`)\n .join(\"\\n\");\n const list = packages.map((_, index) => `p${index}`).join(\", \");\n\n return `${imports}\\nexport default [${list}];\\n`;\n },\n };\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n // A react alias would break SSR: Vite only externalizes bare specifiers,\n // so an absolute path inlines react's CJS into the SSR module runner.\n // `dedupe` alone keeps the app on a single React copy, symlinks included.\n ...(options.source\n ? {\n alias: {\n \"@lattice-php/lattice/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n \"@lattice-php/action\": path.resolve(root, \"../action/resources/js\"),\n \"@lattice-php/core\": path.resolve(root, \"../core/resources/js\"),\n \"@lattice-php/form\": path.resolve(root, \"../form/resources/js\"),\n \"@lattice-php/table\": path.resolve(root, \"../table/resources/js\"),\n \"@lattice-php/ui/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/ui\": path.resolve(root, \"../ui/resources/js\"),\n },\n }\n : {}),\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n \"@lattice-php/action\",\n \"@lattice-php/core\",\n \"@lattice-php/form\",\n \"@lattice-php/table\",\n \"@lattice-php/ui\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nconst OPTIONAL_PEER_STUB_PREFIX = \"\\0lattice-optional-peer/\";\n\n/**\n * Real-time listeners statically import their optional Echo peers. A consumer\n * that never uses real-time should still build, so stub a missing peer with\n * hooks that throw — the `RealtimeListeners` error boundary then degrades\n * gracefully and warns to install the peer, exactly as when it is absent.\n */\nconst OPTIONAL_PEER_STUBS: Record<string, string> = {\n \"@laravel/echo-react\": [\n \"const missing = () => {\",\n \" throw new Error(\",\n ' \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",',\n \" );\",\n \"};\",\n \"export const useEcho = missing;\",\n \"export const useEchoPublic = missing;\",\n \"export const useEchoPresence = missing;\",\n \"export const useEchoNotification = missing;\",\n ].join(\"\\n\"),\n};\n\nfunction optionalPeersPlugin(): Plugin {\n return {\n name: \"lattice:optional-peers\",\n enforce: \"pre\",\n async resolveId(id) {\n if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) {\n return null;\n }\n\n const installed = await this.resolve(id, undefined, { skipSelf: true });\n\n return installed ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;\n },\n load(id) {\n if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) {\n return null;\n }\n\n return OPTIONAL_PEER_STUBS[id.slice(OPTIONAL_PEER_STUB_PREFIX.length)] ?? null;\n },\n };\n}\n\n/**\n * Refreshes `node.props` typings from the app's own `php artisan\n * lattice:typescript` whenever the dev server starts — installing or updating\n * a component package would otherwise leave its generated types stale until\n * someone remembers to run the command by hand. Dev-server only: a production\n * build machine may not have PHP installed, and the generated file is a dev\n * ergonomics artifact, not a build input.\n *\n * Module-private like its siblings `optionalPeersPlugin`/`corePlugin` — the\n * `refreshTypeScriptTypes` DI seam it defers to lives in\n * `./vite-typescript-refresh`, which isn't part of the published `vite`\n * subpath either (see that module for why).\n */\nfunction typescriptPlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice:typescript\",\n apply: \"serve\",\n configureServer(server) {\n const typescript = options.typescript ?? true;\n\n if (typescript === false) {\n return;\n }\n\n const { appRoot } = resolveRoots(options);\n\n refreshTypeScriptTypes(appRoot, server.config.logger);\n },\n };\n}\n\nexport function resolveIconOptions(\n options: LatticeViteOptions,\n packages: LatticeComponentPackage[] = [],\n): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/ui\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [\n path.resolve(root, \"../ui/resources/icons\"),\n ...packages.flatMap((pkg) => (pkg.icons ? [pkg.icons] : [])),\n ...dirs,\n ],\n ...(dts === false ? {} : { dts: { ...defaultTypes, ...dts } }),\n };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,EAAE,YAAY,aAAa,OAAO;CACxC,MAAM,WAAW,0BAA0B,OAAO;CAClD,MAAM,UAA0B;EAC9B,WAAW,OAAO;EAClB,oBAAoB;EACpB,wBAAwB,QAAQ;EAChC,iBAAiB,OAAO;CAC1B;CACA,MAAM,cAAc,mBAAmB,SAAS,QAAQ;CAExD,IAAI,aACF,QAAQ,KAAK,UAAU,WAAW,CAAC;CAGrC,OAAO;AACT;AA4BA,SAAS,qBACP,UACA,KACgD;CAChD,OAAO;EACL,GAAI,OAAO,SAAS,QAAQ,WAAW,EAAE,KAAK,KAAK,QAAQ,KAAK,SAAS,GAAG,EAAE,IAAI,CAAC;EACnF,GAAI,OAAO,SAAS,UAAU,WAAW,EAAE,OAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,EAAE,IAAI,CAAC;CAC3F;AACF;;;;;;AAOA,SAAgB,yBACd,WACA,wBAC2B;CAG3B,QAFiB,MAAM,QAAQ,SAAS,IAAI,YAAa,UAAU,YAAY,CAAC,EAAA,CAEhE,SAAS,QAAQ;EAC/B,MAAM,WAAW,IAAI,OAAO,WAAW,CAAC;EACxC,MAAM,QAAQ,SAAS;EAEvB,IAAI,OAAO,UAAU,UACnB,OAAO,CAAC;EAGV,MA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EAAE,OAAO,CAAC,GAAG,KAAK,GAAG,kBADP,UAAU,OAAO,CAAC,IAAI;CAE1C,MAAM,eAAe;EACnB,MAAM;EACN,eAAe;EACf,kBAAkB;CACpB;CAEA,OAAO;EACL,GAAG;EACH,UAAU;GACR,KAAK,QAAQ,MAAM,uBAAuB;GAC1C,GAAG,SAAS,SAAS,QAAS,IAAI,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAE;GAC3D,GAAG;EACL;EACA,GAAI,QAAQ,QAAQ,CAAC,IAAI,EAAE,KAAK;GAAE,GAAG;GAAc,GAAG;EAAI,EAAE;CAC9D;AACF;AAEA,SAAS,aAAa,SAAoC;CACxD,MAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI;CAG/C,OAAO;EAAE;EAAS,MAFL,QAAQ,QAAQ,KAAK,QAAQ,SAAS,4BAA4B;CAExD;AACzB"}
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { buildSprite, svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { IconTypesOptions, Sprite, SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\nimport { refreshTypeScriptTypes } from \"./vite-typescript-refresh.ts\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: Partial<IconTypesOptions> | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n /** Refresh generated TypeScript types via the dev server. Defaults to `true`. */\n typescript?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const { appRoot } = resolveRoots(options);\n const packages = discoverComponentPackages(appRoot);\n const plugins: PluginOption[] = [\n corePlugin(options),\n optionalPeersPlugin(),\n componentPackagesPlugin(packages),\n typescriptPlugin(options),\n ];\n const iconOptions = resolveIconOptions(options, packages);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\n/** A Composer package that contributes a Lattice component plugin. */\nexport type LatticeComponentPackage = {\n name: string;\n /** Absolute path to the package's installed directory. */\n dir: string;\n /** Absolute path to the package's JS plugin entry. */\n plugin: string;\n /** Absolute path to the package's stylesheet, when it declares one. */\n css?: string;\n /** Absolute path to the package's icon directory, when it declares one. */\n icons?: string;\n};\n\ntype LatticeManifest = { plugin?: string; css?: string; icons?: string };\n\ntype InstalledPackage = {\n name: string;\n \"install-path\"?: string;\n extra?: { lattice?: LatticeManifest };\n};\n\ntype RootPackageJson = {\n name?: string;\n extra?: { lattice?: LatticeManifest };\n};\n\nfunction resolveManifestPaths(\n manifest: LatticeManifest,\n dir: string,\n): Pick<LatticeComponentPackage, \"css\" | \"icons\"> {\n return {\n ...(typeof manifest.css === \"string\" ? { css: path.resolve(dir, manifest.css) } : {}),\n ...(typeof manifest.icons === \"string\" ? { icons: path.resolve(dir, manifest.icons) } : {}),\n };\n}\n\n/**\n * Resolve every Composer package that declares `extra.lattice.plugin` into an\n * absolute plugin-entry path. `installPathsRelativeTo` is `vendor/composer` (the\n * dir `installed.json` records its `install-path`s against).\n */\nexport function collectComponentPackages(\n installed: { packages?: InstalledPackage[] } | InstalledPackage[],\n installPathsRelativeTo: string,\n): LatticeComponentPackage[] {\n const packages = Array.isArray(installed) ? installed : (installed.packages ?? []);\n\n return packages.flatMap((pkg) => {\n const manifest = pkg.extra?.lattice ?? {};\n const entry = manifest.plugin;\n\n if (typeof entry !== \"string\") {\n return [];\n }\n\n const dir = path.resolve(installPathsRelativeTo, pkg[\"install-path\"] ?? `../${pkg.name}`);\n\n return [\n {\n name: pkg.name,\n dir,\n plugin: path.resolve(dir, entry),\n ...resolveManifestPaths(manifest, dir),\n },\n ];\n });\n}\n\n/**\n * Resolve the composer ROOT project's own `extra.lattice.plugin` — Composer\n * never lists the root package in `installed.json`, so a component package\n * declaring the plugin entry in its own composer.json would otherwise be\n * invisible to its own dev server (e.g. inside a testbench workbench, where\n * the package itself is the app root).\n */\nexport function collectRootComponentPackage(\n composerJson: RootPackageJson,\n appRoot: string,\n): LatticeComponentPackage[] {\n const manifest = composerJson.extra?.lattice ?? {};\n\n if (typeof manifest.plugin !== \"string\" || typeof composerJson.name !== \"string\") {\n return [];\n }\n\n return [\n {\n name: composerJson.name,\n dir: appRoot,\n plugin: path.resolve(appRoot, manifest.plugin),\n ...resolveManifestPaths(manifest, appRoot),\n },\n ];\n}\n\n/**\n * Read `<appRoot>/vendor/composer/installed.json` and `<appRoot>/composer.json`\n * and collect every component package they contribute.\n */\nexport function discoverComponentPackages(appRoot: string): LatticeComponentPackage[] {\n const composerDir = path.resolve(appRoot, \"vendor/composer\");\n\n let installed: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(composerDir, \"installed.json\"), \"utf8\");\n installed = collectComponentPackages(JSON.parse(raw), composerDir);\n } catch {\n installed = [];\n }\n\n let root: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(appRoot, \"composer.json\"), \"utf8\");\n root = collectRootComponentPackage(JSON.parse(raw), appRoot);\n } catch {\n root = [];\n }\n\n return [...installed, ...root];\n}\n\nconst VIRTUAL_PLUGINS_ID = \"virtual:lattice/plugins\";\nconst RESOLVED_VIRTUAL_PLUGINS_ID = `\\0${VIRTUAL_PLUGINS_ID}`;\n\n/**\n * Exposes the discovered component packages as `virtual:lattice/plugins` — a\n * module whose default export is the array of their plugin objects,\n * ready for `extendRegistry(registry, ...plugins)`. Also grants Vite filesystem\n * access to each package dir so its source compiles from `vendor/` (or a symlink).\n */\nexport function componentPackagesPlugin(packages: LatticeComponentPackage[]): Plugin {\n return {\n name: \"lattice:component-packages\",\n config(config) {\n if (packages.length === 0) {\n return {};\n }\n\n const workspaceRoot = searchForWorkspaceRoot(config.root ?? process.cwd());\n // Vite's mergeAlias puts plugin-config aliases in front of the user config's,\n // so this specific `/css` alias wins over a user's broader package-dir alias.\n const alias = Object.fromEntries(\n packages.flatMap((pkg) => (pkg.css ? [[`@${pkg.name}/css`, pkg.css]] : [])),\n );\n\n return {\n ...(Object.keys(alias).length > 0 ? { resolve: { alias } } : {}),\n server: { fs: { allow: [workspaceRoot, ...packages.map((pkg) => pkg.dir)] } },\n };\n },\n resolveId(id) {\n return id === VIRTUAL_PLUGINS_ID ? RESOLVED_VIRTUAL_PLUGINS_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_PLUGINS_ID) {\n return null;\n }\n\n const imports = packages\n .map((pkg, index) => `import p${index} from ${JSON.stringify(pkg.plugin)};`)\n .join(\"\\n\");\n const list = packages.map((_, index) => `p${index}`).join(\", \");\n\n return `${imports}\\nexport default [${list}];\\n`;\n },\n };\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n // A react alias would break SSR: Vite only externalizes bare specifiers,\n // so an absolute path inlines react's CJS into the SSR module runner.\n // `dedupe` alone keeps the app on a single React copy, symlinks included.\n ...(options.source\n ? {\n alias: {\n \"@lattice-php/lattice/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n \"@lattice-php/action\": path.resolve(root, \"../action/resources/js\"),\n \"@lattice-php/core\": path.resolve(root, \"../core/resources/js\"),\n \"@lattice-php/form\": path.resolve(root, \"../form/resources/js\"),\n \"@lattice-php/table\": path.resolve(root, \"../table/resources/js\"),\n \"@lattice-php/ui/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/ui\": path.resolve(root, \"../ui/resources/js\"),\n },\n }\n : {}),\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n \"@lattice-php/action\",\n \"@lattice-php/core\",\n \"@lattice-php/form\",\n \"@lattice-php/table\",\n \"@lattice-php/ui\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nconst OPTIONAL_PEER_STUB_PREFIX = \"\\0lattice-optional-peer/\";\n\n/**\n * Real-time listeners statically import their optional Echo peers. A consumer\n * that never uses real-time should still build, so stub a missing peer with\n * hooks that throw — the `RealtimeListeners` error boundary then degrades\n * gracefully and warns to install the peer, exactly as when it is absent.\n */\nconst OPTIONAL_PEER_STUBS: Record<string, string> = {\n \"@laravel/echo-react\": [\n \"const missing = () => {\",\n \" throw new Error(\",\n ' \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",',\n \" );\",\n \"};\",\n \"export const useEcho = missing;\",\n \"export const useEchoPublic = missing;\",\n \"export const useEchoPresence = missing;\",\n \"export const useEchoNotification = missing;\",\n ].join(\"\\n\"),\n};\n\nfunction optionalPeersPlugin(): Plugin {\n return {\n name: \"lattice:optional-peers\",\n enforce: \"pre\",\n async resolveId(id) {\n if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) {\n return null;\n }\n\n const installed = await this.resolve(id, undefined, { skipSelf: true });\n\n return installed ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;\n },\n load(id) {\n if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) {\n return null;\n }\n\n return OPTIONAL_PEER_STUBS[id.slice(OPTIONAL_PEER_STUB_PREFIX.length)] ?? null;\n },\n };\n}\n\n/**\n * Refreshes `node.props` typings from the app's own `php artisan\n * lattice:typescript` whenever the dev server starts — installing or updating\n * a component package would otherwise leave its generated types stale until\n * someone remembers to run the command by hand. Dev-server only: a production\n * build machine may not have PHP installed, and the generated file is a dev\n * ergonomics artifact, not a build input.\n *\n * Module-private like its siblings `optionalPeersPlugin`/`corePlugin` — the\n * `refreshTypeScriptTypes` DI seam it defers to lives in\n * `./vite-typescript-refresh`, which isn't part of the published `vite`\n * subpath either (see that module for why).\n */\nfunction typescriptPlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice:typescript\",\n apply: \"serve\",\n configureServer(server) {\n const typescript = options.typescript ?? true;\n\n if (typescript === false) {\n return;\n }\n\n const { appRoot } = resolveRoots(options);\n\n refreshTypeScriptTypes(appRoot, server.config.logger);\n },\n };\n}\n\nexport function resolveIconOptions(\n options: LatticeViteOptions,\n packages: LatticeComponentPackage[] = [],\n): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/ui\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [\n path.resolve(root, \"../ui/resources/icons\"),\n ...packages.flatMap((pkg) => (pkg.icons ? [pkg.icons] : [])),\n ...dirs,\n ],\n ...(dts === false ? {} : { dts: { ...defaultTypes, ...dts } }),\n };\n}\n\n/**\n * Builds the same icon sprite the `lattice()` Vite plugin serves, outside of\n * Vite: ui's icon set, every discovered component package's icons, and the\n * app's own `icons.dirs`. The result is a `SpriteValue` for `SpriteProvider`\n * (`href: \"\"` inlines the markup), which is what a Storybook, a design-system\n * export, a prerender script, or a test needs to render `Icon` without a\n * dev server or an emitted asset.\n */\nexport function buildLatticeSprite(options: LatticeViteOptions = {}): Sprite & { href: \"\" } {\n const { appRoot } = resolveRoots(options);\n const iconOptions = resolveIconOptions(options, discoverComponentPackages(appRoot));\n\n if (!iconOptions) {\n return { href: \"\", ids: [], source: \"\" };\n }\n\n const { iconDirs = [], symbolId, svgoConfig } = iconOptions;\n\n return { href: \"\", ...buildSprite(iconDirs, { symbolId, svgoConfig }) };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,EAAE,YAAY,aAAa,OAAO;CACxC,MAAM,WAAW,0BAA0B,OAAO;CAClD,MAAM,UAA0B;EAC9B,WAAW,OAAO;EAClB,oBAAoB;EACpB,wBAAwB,QAAQ;EAChC,iBAAiB,OAAO;CAC1B;CACA,MAAM,cAAc,mBAAmB,SAAS,QAAQ;CAExD,IAAI,aACF,QAAQ,KAAK,UAAU,WAAW,CAAC;CAGrC,OAAO;AACT;AA4BA,SAAS,qBACP,UACA,KACgD;CAChD,OAAO;EACL,GAAI,OAAO,SAAS,QAAQ,WAAW,EAAE,KAAK,KAAK,QAAQ,KAAK,SAAS,GAAG,EAAE,IAAI,CAAC;EACnF,GAAI,OAAO,SAAS,UAAU,WAAW,EAAE,OAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,EAAE,IAAI,CAAC;CAC3F;AACF;;;;;;AAOA,SAAgB,yBACd,WACA,wBAC2B;CAG3B,QAFiB,MAAM,QAAQ,SAAS,IAAI,YAAa,UAAU,YAAY,CAAC,EAAA,CAEhE,S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