@lattice-php/lattice 0.25.0 → 0.27.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.
Files changed (150) hide show
  1. package/dist/action/components/action-form.js +3 -3
  2. package/dist/action/components/action-form.js.map +1 -1
  3. package/dist/action/components/action-group.js +1 -1
  4. package/dist/action/components/action-group.js.map +1 -1
  5. package/dist/action/components/action.js +3 -2
  6. package/dist/action/components/action.js.map +1 -1
  7. package/dist/action/hooks/use-action.js +4 -3
  8. package/dist/action/hooks/use-action.js.map +1 -1
  9. package/dist/appearance/index.d.ts +1 -1
  10. package/dist/appearance/index.js +8 -8
  11. package/dist/appearance/index.js.map +1 -1
  12. package/dist/chat/components/chat-box.js +1 -1
  13. package/dist/chat/components/prompt-input.js +1 -2
  14. package/dist/chat/components/prompt-input.js.map +1 -1
  15. package/dist/core/api.d.ts +13 -0
  16. package/dist/core/api.js +38 -4
  17. package/dist/core/api.js.map +1 -1
  18. package/dist/core/component-ref.d.ts +3 -0
  19. package/dist/core/component-ref.js +20 -2
  20. package/dist/core/component-ref.js.map +1 -1
  21. package/dist/core/headers.js +1 -1
  22. package/dist/core/index.js +4 -4
  23. package/dist/create-app.js +8 -3
  24. package/dist/create-app.js.map +1 -1
  25. package/dist/dnd/index.d.ts +16 -0
  26. package/dist/dnd/index.js +13 -0
  27. package/dist/form/components/base/submit-button.d.ts +4 -3
  28. package/dist/form/components/base/submit-button.js +2 -1
  29. package/dist/form/components/base/submit-button.js.map +1 -1
  30. package/dist/form/components/fields/date-picker-field.js +2 -2
  31. package/dist/form/components/fields/date-picker-field.js.map +1 -1
  32. package/dist/form/components/fields/file-upload.js +3 -2
  33. package/dist/form/components/fields/file-upload.js.map +1 -1
  34. package/dist/form/components/fields/number-input.js +1 -1
  35. package/dist/form/components/fields/number-input.js.map +1 -1
  36. package/dist/form/components/fields/rich-editor-field.js +1 -1
  37. package/dist/form/components/fields/rich-editor-field.js.map +1 -1
  38. package/dist/form/components/fields/row-action-menu.js +3 -3
  39. package/dist/form/components/fields/row-action-menu.js.map +1 -1
  40. package/dist/form/components/fields/row-actions.d.ts +1 -1
  41. package/dist/form/components/fields/row-actions.js +4 -4
  42. package/dist/form/components/fields/row-actions.js.map +1 -1
  43. package/dist/form/components/fields/select.js +4 -3
  44. package/dist/form/components/fields/select.js.map +1 -1
  45. package/dist/form/components/fields/toggle.js +1 -1
  46. package/dist/form/components/fields/toggle.js.map +1 -1
  47. package/dist/form/components/form.js +69 -29
  48. package/dist/form/components/form.js.map +1 -1
  49. package/dist/form/components/wizard.js +1 -1
  50. package/dist/form/components/wizard.js.map +1 -1
  51. package/dist/form/hooks/use-form-resolver.js +1 -1
  52. package/dist/form/hooks/use-form-resolver.js.map +1 -1
  53. package/dist/form/hooks/values.d.ts +8 -0
  54. package/dist/form/hooks/values.js +18 -1
  55. package/dist/form/hooks/values.js.map +1 -1
  56. package/dist/i18n/backend.js +1 -1
  57. package/dist/i18n/instance.js +1 -1
  58. package/dist/i18n/timezone.js +1 -1
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.js +5 -5
  61. package/dist/inertia.d.ts +7 -0
  62. package/dist/inertia.js +19 -1
  63. package/dist/inertia.js.map +1 -1
  64. package/dist/lattice.css +189 -116
  65. package/dist/notifications/components/notification-item.js +3 -1
  66. package/dist/notifications/components/notification-item.js.map +1 -1
  67. package/dist/notifications/components/notifications.js +2 -4
  68. package/dist/notifications/components/notifications.js.map +1 -1
  69. package/dist/remote/components/data-list.js +2 -2
  70. package/dist/table/components/bulk-bar.js +3 -1
  71. package/dist/table/components/bulk-bar.js.map +1 -1
  72. package/dist/table/components/cells/badge-cell.js +3 -6
  73. package/dist/table/components/cells/badge-cell.js.map +1 -1
  74. package/dist/table/components/cells/text-cell.js +6 -9
  75. package/dist/table/components/cells/text-cell.js.map +1 -1
  76. package/dist/table/components/column-filter-control.js +2 -2
  77. package/dist/table/components/column-filter-control.js.map +1 -1
  78. package/dist/table/components/filter-bar.js +1 -1
  79. package/dist/table/components/filter-bar.js.map +1 -1
  80. package/dist/table/components/pagination.js +6 -6
  81. package/dist/table/components/pagination.js.map +1 -1
  82. package/dist/table/hooks/use-table.js +3 -2
  83. package/dist/table/hooks/use-table.js.map +1 -1
  84. package/dist/table/lib/bulk.d.ts +3 -2
  85. package/dist/table/lib/bulk.js +2 -1
  86. package/dist/table/lib/bulk.js.map +1 -1
  87. package/dist/toast/toast.js +3 -1
  88. package/dist/toast/toast.js.map +1 -1
  89. package/dist/toast/variant-styles.js +15 -1
  90. package/dist/toast/variant-styles.js.map +1 -1
  91. package/dist/types/generated.d.ts +14 -9
  92. package/dist/ui/action-menu-context.d.ts +1 -1
  93. package/dist/ui/action-menu-context.js +1 -1
  94. package/dist/ui/action-menu-context.js.map +1 -1
  95. package/dist/ui/affix-group.js +1 -1
  96. package/dist/ui/affix-group.js.map +1 -1
  97. package/dist/ui/badge.d.ts +4 -7
  98. package/dist/ui/badge.js +11 -17
  99. package/dist/ui/badge.js.map +1 -1
  100. package/dist/ui/button.d.ts +6 -5
  101. package/dist/ui/button.js +154 -15
  102. package/dist/ui/button.js.map +1 -1
  103. package/dist/ui/chart-view.js +9 -7
  104. package/dist/ui/chart-view.js.map +1 -1
  105. package/dist/ui/checkbox.js +1 -1
  106. package/dist/ui/checkbox.js.map +1 -1
  107. package/dist/ui/confirm-dialog.d.ts +4 -3
  108. package/dist/ui/confirm-dialog.js +3 -2
  109. package/dist/ui/confirm-dialog.js.map +1 -1
  110. package/dist/ui/control.d.ts +1 -1
  111. package/dist/ui/control.js +1 -1
  112. package/dist/ui/control.js.map +1 -1
  113. package/dist/ui/dialog.js +1 -1
  114. package/dist/ui/dialog.js.map +1 -1
  115. package/dist/ui/dropdown-menu.d.ts +2 -2
  116. package/dist/ui/dropdown-menu.js +2 -2
  117. package/dist/ui/dropdown-menu.js.map +1 -1
  118. package/dist/ui/fragment.js +1 -1
  119. package/dist/ui/icon-button.d.ts +3 -3
  120. package/dist/ui/icon-button.js +6 -6
  121. package/dist/ui/icon-button.js.map +1 -1
  122. package/dist/ui/image-preview.js +1 -1
  123. package/dist/ui/image-preview.js.map +1 -1
  124. package/dist/ui/index.d.ts +2 -2
  125. package/dist/ui/index.js +2 -2
  126. package/dist/ui/info-tooltip.js +1 -1
  127. package/dist/ui/info-tooltip.js.map +1 -1
  128. package/dist/ui/input-otp.js +1 -1
  129. package/dist/ui/input-otp.js.map +1 -1
  130. package/dist/ui/label.js +1 -1
  131. package/dist/ui/label.js.map +1 -1
  132. package/dist/ui/password-input.js +1 -1
  133. package/dist/ui/password-input.js.map +1 -1
  134. package/dist/ui/progress.js +2 -2
  135. package/dist/ui/progress.js.map +1 -1
  136. package/dist/ui/text.js +1 -1
  137. package/dist/ui/tooltip.js +1 -1
  138. package/dist/ui/tooltip.js.map +1 -1
  139. package/dist-standalone/chunks/{chart-view-DEwGTt9d.js → chart-view-CpYsLvzR.js} +4 -4
  140. package/dist-standalone/chunks/date-picker-field-lX8N40Ii.js +1 -0
  141. package/dist-standalone/chunks/{page-props-D3FnL614.js → page-props-ClpVjpOc.js} +1 -1
  142. package/dist-standalone/chunks/{rich-editor-field-B9Nv1qia.js → rich-editor-field-C71csVJv.js} +2 -2
  143. package/dist-standalone/chunks/{subscriptions-C-0lSr7X.js → subscriptions-Bt2s3IF3.js} +1 -1
  144. package/dist-standalone/chunks/use-effect-dispatcher-DGFXSzA6.js +97 -0
  145. package/dist-standalone/lattice.css +1 -1
  146. package/dist-standalone/lattice.js +15 -15
  147. package/dist-standalone/manifest.json +8 -8
  148. package/package.json +9 -1
  149. package/dist-standalone/chunks/date-picker-field-CCQ9nWx0.js +0 -1
  150. package/dist-standalone/chunks/use-effect-dispatcher-EVZxmfoo.js +0 -97
@@ -1,10 +1,12 @@
1
- import { initializeTheme } from "./appearance/index.js";
1
+ import { initializeAppearance } from "./appearance/index.js";
2
+ import { setRefRefreshEndpoint } from "./core/api.js";
3
+ import { isRecord } from "./core/materialize.js";
2
4
  import { extendRegistry } from "./core/registry.js";
3
5
  import { setDefaultRegistry } from "./core/registry-context.js";
4
6
  import "./i18n/instance.js";
5
7
  import { LocaleReload } from "./i18n/locale-reload.js";
6
8
  import { i18nConfigFromPageProps } from "./i18n/shared-props.js";
7
- import { createLayoutResolver, createPageResolver, withVisitHeaders } from "./inertia.js";
9
+ import { createLayoutResolver, createPageResolver, registerRefRenewal, withVisitHeaders } from "./inertia.js";
8
10
  import { ProviderBase } from "./provider-base.js";
9
11
  import { registry } from "./registry.js";
10
12
  import { createInertiaApp } from "@inertiajs/react";
@@ -44,6 +46,7 @@ function createLatticeApp({ registry: registry$1, plugins, sprite, pages = {}, d
44
46
  const baseRegistry = registry$1 ?? registry;
45
47
  const activeRegistry = plugins && plugins.length > 0 ? extendRegistry(baseRegistry, ...plugins) : baseRegistry;
46
48
  setDefaultRegistry(activeRegistry);
49
+ registerRefRenewal();
47
50
  const i18nEnabled = i18n !== false;
48
51
  const pluginI18n = plugins?.flatMap((plugin) => plugin.i18n ? [plugin.i18n] : []) ?? [];
49
52
  const i18nOptions = i18nEnabled ? withPluginNamespaces(i18n ?? {}, pluginI18n) : {};
@@ -61,6 +64,8 @@ function createLatticeApp({ registry: registry$1, plugins, sprite, pages = {}, d
61
64
  withApp: (node, { ssr, page }) => {
62
65
  const pending = [];
63
66
  if (!ssr) {
67
+ const shared = page.props.lattice;
68
+ if (isRecord(shared) && isRecord(shared.urls) && typeof shared.urls.refreshRef === "string") setRefRefreshEndpoint(shared.urls.refreshRef);
64
69
  if (i18nEnabled && i18nConfigFromPageProps(page.props) !== void 0) pending.push(import("./i18n/page-props.js").then((module) => module.configureI18nFromPageProps(page.props, i18nOptions)));
65
70
  const booted = boot?.({ page });
66
71
  if (booted) pending.push(booted);
@@ -77,7 +82,7 @@ function createLatticeApp({ registry: registry$1, plugins, sprite, pages = {}, d
77
82
  }) : shell;
78
83
  }
79
84
  });
80
- initializeTheme();
85
+ initializeAppearance();
81
86
  return app;
82
87
  }
83
88
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"create-app.js","names":[],"sources":["../resources/js/create-app.tsx"],"sourcesContent":["import type { Page as InertiaPage, VisitOptions } from \"@inertiajs/core\";\nimport { createInertiaApp } from \"@inertiajs/react\";\nimport { useEffect, useState, type ReactElement, type ReactNode } from \"react\";\nimport { initializeTheme } from \"./appearance\";\nimport { extendRegistry, type Plugin, type PluginI18n, type Registry } from \"./core/registry\";\nimport { setDefaultRegistry } from \"./core/registry-context\";\nimport type { SpriteValue } from \"./icons/sprite\";\nimport { DEFAULT_NAMESPACE } from \"./i18n/instance\";\nimport { LocaleReload } from \"./i18n/locale-reload\";\nimport { i18nConfigFromPageProps } from \"./i18n/shared-props\";\nimport {\n createLayoutResolver,\n createPageResolver,\n withVisitHeaders,\n type CreateLayoutResolverOptions,\n type PageModules,\n} from \"./inertia\";\nimport { ProviderBase } from \"./provider-base\";\nimport { registry as defaultRegistry } from \"./registry\";\n\ntype InertiaAppOptions = NonNullable<Parameters<typeof createInertiaApp>[0]>;\n\nexport type CreateLatticeAppI18nOptions = {\n /**\n * i18next namespaces to load, e.g. `[\"lattice\", \"app\"]`. Defaults to the\n * package's own. Namespaces declared by plugins are merged in on top.\n */\n namespaces?: string[];\n};\n\nexport type CreateLatticeAppOptions = Omit<\n InertiaAppOptions,\n \"resolve\" | \"layout\" | \"setup\" | \"withApp\" | \"pages\"\n> & {\n registry?: Registry;\n /**\n * Component-package plugins to merge onto the registry — pass the\n * Composer-discovered `virtual:lattice/plugins` here to register vendor\n * components with no manual `extendRegistry` call. A plugin's declared\n * i18n namespace joins the i18n bootstrap automatically.\n */\n plugins?: Plugin[];\n sprite?: SpriteValue;\n /** Normal Inertia page modules, e.g. `import.meta.glob('./pages/**\\/*.tsx')`. */\n pages?: PageModules;\n defaultLayout?: CreateLayoutResolverOptions[\"defaultLayout\"];\n /**\n * Lattice's i18n bootstrap, on by default: when the backend shares the\n * `lattice.i18n` prop, the first render waits for the translation setup (no\n * flash of untranslated fallbacks), `LocaleReload` re-fetches the page after\n * a locale switch, and every visit carries the locale/timezone headers. The\n * i18next chunk only loads when the backend actually shares the prop. Pass\n * `false` to opt out entirely.\n */\n i18n?: CreateLatticeAppI18nOptions | false;\n /**\n * App bootstrap that needs the initial page — e.g. `configureEcho` from a\n * shared connection prop. Runs on the client before the first render; a\n * returned promise delays that render until it resolves.\n */\n boot?: (context: { page: InertiaPage }) => void | Promise<void>;\n /**\n * Compose providers or siblings around the app. Applied inside the Lattice\n * Provider, so the registry, sprite, and toaster contexts are available.\n */\n wrap?: (app: ReactElement) => ReactElement;\n};\n\nfunction withPluginNamespaces(\n options: CreateLatticeAppI18nOptions,\n entries: PluginI18n[],\n): CreateLatticeAppI18nOptions {\n if (entries.length === 0) {\n return options;\n }\n\n const namespaces = new Set([\n ...(options.namespaces ?? [DEFAULT_NAMESPACE]),\n ...entries.map((entry) => entry.namespace),\n ]);\n\n return { ...options, namespaces: [...namespaces] };\n}\n\n// Fail-open: a failed bootstrap renders the app anyway (with fallback strings)\n// rather than a blank page.\nfunction AwaitReady({ ready, children }: { ready: Promise<unknown>; children: ReactNode }) {\n const [isReady, setReady] = useState(false);\n\n useEffect(() => {\n let active = true;\n const reveal = (): void => {\n if (active) {\n setReady(true);\n }\n };\n\n void ready.then(reveal, reveal);\n\n return () => {\n active = false;\n };\n }, [ready]);\n\n return isReady ? children : null;\n}\n\n/**\n * Bootstrap an Inertia app with the Lattice shell: the page/layout resolvers\n * (server-driven Lattice pages and normal Inertia pages alike), the Provider —\n * registry, sprite, flash toasts via Lattice's own Toaster — theme\n * initialization, and the i18n bootstrap. Forwards any other createInertiaApp\n * option.\n */\nexport function createLatticeApp({\n registry,\n plugins,\n sprite,\n pages = {},\n defaultLayout,\n strictMode = true,\n i18n,\n boot,\n wrap,\n ...inertiaOptions\n}: CreateLatticeAppOptions = {}) {\n const baseRegistry = registry ?? defaultRegistry;\n const activeRegistry =\n plugins && plugins.length > 0 ? extendRegistry(baseRegistry, ...plugins) : baseRegistry;\n\n setDefaultRegistry(activeRegistry);\n\n const i18nEnabled = i18n !== false;\n const pluginI18n = plugins?.flatMap((plugin) => (plugin.i18n ? [plugin.i18n] : [])) ?? [];\n const i18nOptions = i18nEnabled ? withPluginNamespaces(i18n ?? {}, pluginI18n) : {};\n const userVisitOptions = inertiaOptions.defaults?.visitOptions;\n const defaults = i18nEnabled\n ? {\n ...inertiaOptions.defaults,\n visitOptions: (href: string, options: VisitOptions): VisitOptions =>\n withVisitHeaders(href, userVisitOptions?.(href, options) ?? options),\n }\n : inertiaOptions.defaults;\n\n const app = createInertiaApp({\n ...inertiaOptions,\n defaults,\n strictMode,\n resolve: createPageResolver(pages),\n layout: createLayoutResolver({ defaultLayout }),\n withApp: (node: ReactElement, { ssr, page }: { ssr: boolean; page: InertiaPage }) => {\n const pending: Promise<unknown>[] = [];\n\n if (!ssr) {\n // Loaded on demand so apps without the shared i18n prop never ship the\n // i18next backend; the disabled-config call still stores the timezone.\n if (i18nEnabled && i18nConfigFromPageProps(page.props) !== undefined) {\n pending.push(\n import(\"./i18n/page-props\").then((module) =>\n module.configureI18nFromPageProps(page.props, i18nOptions),\n ),\n );\n }\n\n const booted = boot?.({ page });\n\n if (booted) {\n pending.push(booted);\n }\n }\n\n const inner = (\n <>\n {node}\n {i18nEnabled ? <LocaleReload /> : null}\n </>\n );\n\n // The whole shell waits, not just the page: anything rendering a\n // translated string (the Toaster included) would otherwise initialize\n // i18next before the backend can register — init runs exactly once,\n // first caller wins.\n const shell = (\n <ProviderBase registry={activeRegistry} sprite={sprite}>\n {wrap ? wrap(inner) : inner}\n </ProviderBase>\n );\n\n return pending.length > 0 ? (\n <AwaitReady ready={Promise.all(pending)}>{shell}</AwaitReady>\n ) : (\n shell\n );\n },\n });\n\n initializeTheme();\n\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;AAoEA,SAAS,qBACP,SACA,SAC6B;CAC7B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,MAAM,aAAa,IAAI,IAAI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C;GAErC,IAAI,CAAC,KAAK;IAGR,IAAI,eAAe,wBAAwB,KAAK,KAAK,MAAM,KAAA,GACzD,QAAQ,KACN,OAAO,wBAAqB,MAAM,WAChC,OAAO,2BAA2B,KAAK,OAAO,WAAW,CAC3D,CACF;IAGF,MAAM,SAAS,OAAO,EAAE,KAAK,CAAC;IAE9B,IAAI,QACF,QAAQ,KAAK,MAAM;GAEvB;GAEA,MAAM,QACJ,qBAAA,YAAA,EAAA,UAAA,CACG,MACA,cAAc,oBAAC,cAAD,CAAe,CAAA,IAAI,IAClC,EAAA,CAAA;GAOJ,MAAM,QACJ,oBAAC,cAAD;IAAc,UAAU;IAAwB;cAC7C,OAAO,KAAK,KAAK,IAAI;GACV,CAAA;GAGhB,OAAO,QAAQ,SAAS,IACtB,oBAAC,YAAD;IAAY,OAAO,QAAQ,IAAI,OAAO;cAAI;GAAkB,CAAA,IAE5D;EAEJ;CACF,CAAC;CAED,gBAAgB;CAEhB,OAAO;AACT"}
1
+ {"version":3,"file":"create-app.js","names":[],"sources":["../resources/js/create-app.tsx"],"sourcesContent":["import type { Page as InertiaPage, VisitOptions } from \"@inertiajs/core\";\nimport { createInertiaApp } from \"@inertiajs/react\";\nimport { useEffect, useState, type ReactElement, type ReactNode } from \"react\";\nimport { initializeAppearance } from \"./appearance\";\nimport { setRefRefreshEndpoint } from \"./core/api\";\nimport { isRecord } from \"./core/materialize\";\nimport { extendRegistry, type Plugin, type PluginI18n, type Registry } from \"./core/registry\";\nimport { setDefaultRegistry } from \"./core/registry-context\";\nimport type { SpriteValue } from \"./icons/sprite\";\nimport { DEFAULT_NAMESPACE } from \"./i18n/instance\";\nimport { LocaleReload } from \"./i18n/locale-reload\";\nimport { i18nConfigFromPageProps } from \"./i18n/shared-props\";\nimport {\n createLayoutResolver,\n createPageResolver,\n registerRefRenewal,\n withVisitHeaders,\n type CreateLayoutResolverOptions,\n type PageModules,\n} from \"./inertia\";\nimport { ProviderBase } from \"./provider-base\";\nimport { registry as defaultRegistry } from \"./registry\";\n\ntype InertiaAppOptions = NonNullable<Parameters<typeof createInertiaApp>[0]>;\n\nexport type CreateLatticeAppI18nOptions = {\n /**\n * i18next namespaces to load, e.g. `[\"lattice\", \"app\"]`. Defaults to the\n * package's own. Namespaces declared by plugins are merged in on top.\n */\n namespaces?: string[];\n};\n\nexport type CreateLatticeAppOptions = Omit<\n InertiaAppOptions,\n \"resolve\" | \"layout\" | \"setup\" | \"withApp\" | \"pages\"\n> & {\n registry?: Registry;\n /**\n * Component-package plugins to merge onto the registry — pass the\n * Composer-discovered `virtual:lattice/plugins` here to register vendor\n * components with no manual `extendRegistry` call. A plugin's declared\n * i18n namespace joins the i18n bootstrap automatically.\n */\n plugins?: Plugin[];\n sprite?: SpriteValue;\n /** Normal Inertia page modules, e.g. `import.meta.glob('./pages/**\\/*.tsx')`. */\n pages?: PageModules;\n defaultLayout?: CreateLayoutResolverOptions[\"defaultLayout\"];\n /**\n * Lattice's i18n bootstrap, on by default: when the backend shares the\n * `lattice.i18n` prop, the first render waits for the translation setup (no\n * flash of untranslated fallbacks), `LocaleReload` re-fetches the page after\n * a locale switch, and every visit carries the locale/timezone headers. The\n * i18next chunk only loads when the backend actually shares the prop. Pass\n * `false` to opt out entirely.\n */\n i18n?: CreateLatticeAppI18nOptions | false;\n /**\n * App bootstrap that needs the initial page — e.g. `configureEcho` from a\n * shared connection prop. Runs on the client before the first render; a\n * returned promise delays that render until it resolves.\n */\n boot?: (context: { page: InertiaPage }) => void | Promise<void>;\n /**\n * Compose providers or siblings around the app. Applied inside the Lattice\n * Provider, so the registry, sprite, and toaster contexts are available.\n */\n wrap?: (app: ReactElement) => ReactElement;\n};\n\nfunction withPluginNamespaces(\n options: CreateLatticeAppI18nOptions,\n entries: PluginI18n[],\n): CreateLatticeAppI18nOptions {\n if (entries.length === 0) {\n return options;\n }\n\n const namespaces = new Set([\n ...(options.namespaces ?? [DEFAULT_NAMESPACE]),\n ...entries.map((entry) => entry.namespace),\n ]);\n\n return { ...options, namespaces: [...namespaces] };\n}\n\n// Fail-open: a failed bootstrap renders the app anyway (with fallback strings)\n// rather than a blank page.\nfunction AwaitReady({ ready, children }: { ready: Promise<unknown>; children: ReactNode }) {\n const [isReady, setReady] = useState(false);\n\n useEffect(() => {\n let active = true;\n const reveal = (): void => {\n if (active) {\n setReady(true);\n }\n };\n\n void ready.then(reveal, reveal);\n\n return () => {\n active = false;\n };\n }, [ready]);\n\n return isReady ? children : null;\n}\n\n/**\n * Bootstrap an Inertia app with the Lattice shell: the page/layout resolvers\n * (server-driven Lattice pages and normal Inertia pages alike), the Provider —\n * registry, sprite, flash toasts via Lattice's own Toaster — theme\n * initialization, and the i18n bootstrap. Forwards any other createInertiaApp\n * option.\n */\nexport function createLatticeApp({\n registry,\n plugins,\n sprite,\n pages = {},\n defaultLayout,\n strictMode = true,\n i18n,\n boot,\n wrap,\n ...inertiaOptions\n}: CreateLatticeAppOptions = {}) {\n const baseRegistry = registry ?? defaultRegistry;\n const activeRegistry =\n plugins && plugins.length > 0 ? extendRegistry(baseRegistry, ...plugins) : baseRegistry;\n\n setDefaultRegistry(activeRegistry);\n registerRefRenewal();\n\n const i18nEnabled = i18n !== false;\n const pluginI18n = plugins?.flatMap((plugin) => (plugin.i18n ? [plugin.i18n] : [])) ?? [];\n const i18nOptions = i18nEnabled ? withPluginNamespaces(i18n ?? {}, pluginI18n) : {};\n const userVisitOptions = inertiaOptions.defaults?.visitOptions;\n const defaults = i18nEnabled\n ? {\n ...inertiaOptions.defaults,\n visitOptions: (href: string, options: VisitOptions): VisitOptions =>\n withVisitHeaders(href, userVisitOptions?.(href, options) ?? options),\n }\n : inertiaOptions.defaults;\n\n const app = createInertiaApp({\n ...inertiaOptions,\n defaults,\n strictMode,\n resolve: createPageResolver(pages),\n layout: createLayoutResolver({ defaultLayout }),\n withApp: (node: ReactElement, { ssr, page }: { ssr: boolean; page: InertiaPage }) => {\n const pending: Promise<unknown>[] = [];\n\n if (!ssr) {\n const shared = page.props.lattice;\n\n if (\n isRecord(shared) &&\n isRecord(shared.urls) &&\n typeof shared.urls.refreshRef === \"string\"\n ) {\n setRefRefreshEndpoint(shared.urls.refreshRef);\n }\n\n // Loaded on demand so apps without the shared i18n prop never ship the\n // i18next backend; the disabled-config call still stores the timezone.\n if (i18nEnabled && i18nConfigFromPageProps(page.props) !== undefined) {\n pending.push(\n import(\"./i18n/page-props\").then((module) =>\n module.configureI18nFromPageProps(page.props, i18nOptions),\n ),\n );\n }\n\n const booted = boot?.({ page });\n\n if (booted) {\n pending.push(booted);\n }\n }\n\n const inner = (\n <>\n {node}\n {i18nEnabled ? <LocaleReload /> : null}\n </>\n );\n\n // The whole shell waits, not just the page: anything rendering a\n // translated string (the Toaster included) would otherwise initialize\n // i18next before the backend can register — init runs exactly once,\n // first caller wins.\n const shell = (\n <ProviderBase registry={activeRegistry} sprite={sprite}>\n {wrap ? wrap(inner) : inner}\n </ProviderBase>\n );\n\n return pending.length > 0 ? (\n <AwaitReady ready={Promise.all(pending)}>{shell}</AwaitReady>\n ) : (\n shell\n );\n },\n });\n\n initializeAppearance();\n\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuEA,SAAS,qBACP,SACA,SAC6B;CAC7B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,MAAM,aAAa,IAAI,IAAI,CACzB,GAAI,QAAQ,cAAc,CAAA,SAAkB,GAC5C,GAAG,QAAQ,KAAK,UAAU,MAAM,SAAS,CAC3C,CAAC;CAED,OAAO;EAAE,GAAG;EAAS,YAAY,CAAC,GAAG,UAAU;CAAE;AACnD;AAIA,SAAS,WAAW,EAAE,OAAO,YAA8D;CACzF,MAAM,CAAC,SAAS,YAAY,SAAS,KAAK;CAE1C,gBAAgB;EACd,IAAI,SAAS;EACb,MAAM,eAAqB;GACzB,IAAI,QACF,SAAS,IAAI;EAEjB;EAEA,MAAW,KAAK,QAAQ,MAAM;EAE9B,aAAa;GACX,SAAS;EACX;CACF,GAAG,CAAC,KAAK,CAAC;CA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ACJ,qBAAA,YAAA,EAAA,UAAA,CACG,MACA,cAAc,oBAAC,cAAD,CAAe,CAAA,IAAI,IAClC,EAAA,CAAA;GAOJ,MAAM,QACJ,oBAAC,cAAD;IAAc,UAAU;IAAwB;cAC7C,OAAO,KAAK,KAAK,IAAI;GACV,CAAA;GAGhB,OAAO,QAAQ,SAAS,IACtB,oBAAC,YAAD;IAAY,OAAO,QAAQ,IAAI,OAAO;cAAI;GAAkB,CAAA,IAE5D;EAEJ;CACF,CAAC;CAED,qBAAqB;CAErB,OAAO;AACT"}
@@ -0,0 +1,16 @@
1
+ export { draggable, dropTargetForElements, monitorForElements, } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
2
+ export type { ElementDragPayload, ElementEventBasePayload, ElementDropTargetEventBasePayload, ElementGetFeedbackArgs, ElementDropTargetGetFeedbackArgs, ElementMonitorGetFeedbackArgs, } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
3
+ export { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
4
+ export { reorder } from '@atlaskit/pragmatic-drag-and-drop/reorder';
5
+ export { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';
6
+ export { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
7
+ export type { AllDragTypes, BaseEventPayload, CleanupFn, DragLocation, DragLocationHistory, DropTargetRecord, ElementDragType, Input, MonitorArgs, Position, } from '@atlaskit/pragmatic-drag-and-drop/types';
8
+ export { attachClosestEdge, extractClosestEdge, } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
9
+ export type { Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
10
+ export { attachInstruction as attachTreeItemInstruction, extractInstruction as extractTreeItemInstruction, } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
11
+ export type { Instruction as TreeItemInstruction, ItemMode as TreeItemMode, } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
12
+ export { getReorderDestinationIndex } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index';
13
+ export { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';
14
+ export { announce, cleanup as cleanupLiveRegion, } from '@atlaskit/pragmatic-drag-and-drop-live-region';
15
+ export { autoScrollForElements, autoScrollWindowForElements, } from '@atlaskit/pragmatic-drag-and-drop-auto-scroll/element';
16
+ export { pointerOutsideOfPreview } from '@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview';
@@ -0,0 +1,13 @@
1
+ import { draggable, dropTargetForElements, monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
2
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
3
+ import { reorder } from "@atlaskit/pragmatic-drag-and-drop/reorder";
4
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
5
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
6
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
7
+ import { attachInstruction as attachTreeItemInstruction, extractInstruction as extractTreeItemInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
8
+ import { getReorderDestinationIndex } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/get-reorder-destination-index";
9
+ import { reorderWithEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge";
10
+ import { announce, cleanup as cleanupLiveRegion } from "@atlaskit/pragmatic-drag-and-drop-live-region";
11
+ import { autoScrollForElements, autoScrollWindowForElements } from "@atlaskit/pragmatic-drag-and-drop-auto-scroll/element";
12
+ import { pointerOutsideOfPreview } from "@atlaskit/pragmatic-drag-and-drop/element/pointer-outside-of-preview";
13
+ export { announce, attachClosestEdge, attachTreeItemInstruction, autoScrollForElements, autoScrollWindowForElements, cleanupLiveRegion, combine, draggable, dropTargetForElements, extractClosestEdge, extractTreeItemInstruction, getReorderDestinationIndex, monitorForElements, pointerOutsideOfPreview, preserveOffsetOnSource, reorder, reorderWithEdge, setCustomNativeDragPreview };
@@ -1,6 +1,7 @@
1
- import { ButtonVariant } from '../../../types/generated.js';
2
- export declare function FormSubmitButton({ label, summaryLabel, variant, }: {
1
+ import { Emphasis, Variant } from '../../../types/generated.js';
2
+ export declare function FormSubmitButton({ label, summaryLabel, variant, emphasis, }: {
3
3
  label: string;
4
4
  summaryLabel: string;
5
- variant?: ButtonVariant;
5
+ variant?: Variant | null;
6
+ emphasis?: Emphasis | null;
6
7
  }): import("react").JSX.Element;
@@ -3,7 +3,7 @@ import { Spinner } from "../../../ui/spinner.js";
3
3
  import { useFormContext } from "../../hooks/context.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region resources/js/form/components/base/submit-button.tsx
6
- function FormSubmitButton({ label, summaryLabel, variant = "default" }) {
6
+ function FormSubmitButton({ label, summaryLabel, variant, emphasis }) {
7
7
  const { componentId, errors, fieldLabels, processing } = useFormContext();
8
8
  const invalidFields = Object.entries(errors).filter(([, message]) => Boolean(message)).map(([name, message]) => ({
9
9
  label: fieldLabels[name] ?? name,
@@ -16,6 +16,7 @@ function FormSubmitButton({ label, summaryLabel, variant = "default" }) {
16
16
  "data-lattice-form": componentId,
17
17
  "data-test": "form-submit",
18
18
  disabled: processing || hasErrors,
19
+ emphasis,
19
20
  type: "submit",
20
21
  variant,
21
22
  children: [processing && /* @__PURE__ */ jsx(Spinner, {}), label]
@@ -1 +1 @@
1
- {"version":3,"file":"submit-button.js","names":[],"sources":["../../../../resources/js/form/components/base/submit-button.tsx"],"sourcesContent":["import { Button } from \"@lattice-php/lattice/ui/button\";\nimport { Spinner } from \"@lattice-php/lattice/ui/spinner\";\nimport type { ButtonVariant } from \"@lattice-php/lattice/types/generated\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\n\nexport function FormSubmitButton({\n label,\n summaryLabel,\n variant = \"default\",\n}: {\n label: string;\n summaryLabel: string;\n variant?: ButtonVariant;\n}) {\n const { componentId, errors, fieldLabels, processing } = useFormContext();\n\n const invalidFields = Object.entries(errors)\n .filter(([, message]) => Boolean(message))\n .map(([name, message]) => ({ label: fieldLabels[name] ?? name, message: message as string }));\n const hasErrors = invalidFields.length > 0;\n\n return (\n <span className=\"group relative inline-flex flex-col\">\n <Button\n data-lattice-form={componentId}\n data-test=\"form-submit\"\n disabled={processing || hasErrors}\n type=\"submit\"\n variant={variant}\n >\n {processing && <Spinner />}\n {label}\n </Button>\n\n {hasErrors && (\n <div\n className=\"pointer-events-none absolute bottom-full left-1/2 z-lt-popover mb-2 w-max max-w-xs -translate-x-1/2 rounded-lt border border-lt-border bg-lt-surface p-3 text-left text-sm opacity-0 shadow-lt-md transition-opacity group-hover:opacity-100\"\n role=\"tooltip\"\n >\n <p className=\"mb-1 font-medium text-lt-fg\">{summaryLabel}</p>\n <ul className=\"space-y-1\">\n {invalidFields.map((field) => (\n <li className=\"text-lt-muted-fg\" key={field.label}>\n <span className=\"font-medium text-lt-fg\">{field.label}</span> — {field.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;AAKA,SAAgB,iBAAiB,EAC/B,OACA,cACA,UAAU,aAKT;CACD,MAAM,EAAE,aAAa,QAAQ,aAAa,eAAe,eAAe;CAExE,MAAM,gBAAgB,OAAO,QAAQ,MAAM,EACxC,QAAQ,GAAG,aAAa,QAAQ,OAAO,CAAC,EACxC,KAAK,CAAC,MAAM,cAAc;EAAE,OAAO,YAAY,SAAS;EAAe;CAAkB,EAAE;CAC9F,MAAM,YAAY,cAAc,SAAS;CAEzC,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,qBAAC,QAAD;GACE,qBAAmB;GACnB,aAAU;GACV,UAAU,cAAc;GACxB,MAAK;GACI;aALX,CAOG,cAAc,oBAAC,SAAD,CAAU,CAAA,GACxB,KACK;MAEP,aACC,qBAAC,OAAD;GACE,WAAU;GACV,MAAK;aAFP,CAIE,oBAAC,KAAD;IAAG,WAAU;cAA+B;GAAgB,CAAA,GAC5D,oBAAC,MAAD;IAAI,WAAU;cACX,cAAc,KAAK,UAClB,qBAAC,MAAD;KAAI,WAAU;eAAd;MACE,oBAAC,QAAD;OAAM,WAAU;iBAA0B,MAAM;MAAY,CAAA;MAAC;MAAI,MAAM;KACrE;OAFkC,MAAM,KAExC,CACL;GACC,CAAA,CACD;IAEH;;AAEV"}
1
+ {"version":3,"file":"submit-button.js","names":[],"sources":["../../../../resources/js/form/components/base/submit-button.tsx"],"sourcesContent":["import { Button } from \"@lattice-php/lattice/ui/button\";\nimport { Spinner } from \"@lattice-php/lattice/ui/spinner\";\nimport type { Emphasis, Variant } from \"@lattice-php/lattice/types/generated\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\n\nexport function FormSubmitButton({\n label,\n summaryLabel,\n variant,\n emphasis,\n}: {\n label: string;\n summaryLabel: string;\n variant?: Variant | null;\n emphasis?: Emphasis | null;\n}) {\n const { componentId, errors, fieldLabels, processing } = useFormContext();\n\n const invalidFields = Object.entries(errors)\n .filter(([, message]) => Boolean(message))\n .map(([name, message]) => ({ label: fieldLabels[name] ?? name, message: message as string }));\n const hasErrors = invalidFields.length > 0;\n\n return (\n <span className=\"group relative inline-flex flex-col\">\n <Button\n data-lattice-form={componentId}\n data-test=\"form-submit\"\n disabled={processing || hasErrors}\n emphasis={emphasis}\n type=\"submit\"\n variant={variant}\n >\n {processing && <Spinner />}\n {label}\n </Button>\n\n {hasErrors && (\n <div\n className=\"pointer-events-none absolute bottom-full left-1/2 z-lt-popover mb-2 w-max max-w-xs -translate-x-1/2 rounded-lt border border-lt-border bg-lt-surface p-3 text-left text-sm opacity-0 shadow-lt-md transition-opacity group-hover:opacity-100\"\n role=\"tooltip\"\n >\n <p className=\"mb-1 font-medium text-lt-fg\">{summaryLabel}</p>\n <ul className=\"space-y-1\">\n {invalidFields.map((field) => (\n <li className=\"text-lt-muted-fg\" key={field.label}>\n <span className=\"font-medium text-lt-fg\">{field.label}</span> — {field.message}\n </li>\n ))}\n </ul>\n </div>\n )}\n </span>\n );\n}\n"],"mappings":";;;;;AAKA,SAAgB,iBAAiB,EAC/B,OACA,cACA,SACA,YAMC;CACD,MAAM,EAAE,aAAa,QAAQ,aAAa,eAAe,eAAe;CAExE,MAAM,gBAAgB,OAAO,QAAQ,MAAM,EACxC,QAAQ,GAAG,aAAa,QAAQ,OAAO,CAAC,EACxC,KAAK,CAAC,MAAM,cAAc;EAAE,OAAO,YAAY,SAAS;EAAe;CAAkB,EAAE;CAC9F,MAAM,YAAY,cAAc,SAAS;CAEzC,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,qBAAC,QAAD;GACE,qBAAmB;GACnB,aAAU;GACV,UAAU,cAAc;GACd;GACV,MAAK;GACI;aANX,CAQG,cAAc,oBAAC,SAAD,CAAU,CAAA,GACxB,KACK;MAEP,aACC,qBAAC,OAAD;GACE,WAAU;GACV,MAAK;aAFP,CAIE,oBAAC,KAAD;IAAG,WAAU;cAA+B;GAAgB,CAAA,GAC5D,oBAAC,MAAD;IAAI,WAAU;cACX,cAAc,KAAK,UAClB,qBAAC,MAAD;KAAI,WAAU;eAAd;MACE,oBAAC,QAAD;OAAM,WAAU;iBAA0B,MAAM;MAAY,CAAA;MAAC;MAAI,MAAM;KACrE;OAFkC,MAAM,KAExC,CACL;GACC,CAAA,CACD;IAEH;;AAEV"}
@@ -108,9 +108,9 @@ function DatePickerField({ mode, label, name, testId, value, min, max, step, dis
108
108
  children: [
109
109
  /* @__PURE__ */ jsx(Button, {
110
110
  ...api.getPrevTriggerProps(),
111
+ emphasis: "ghost",
111
112
  size: "icon",
112
113
  type: "button",
113
- variant: "ghost",
114
114
  children: /* @__PURE__ */ jsx(Icon, {
115
115
  name: "chevron-left",
116
116
  className: "size-lt-icon-md",
@@ -123,9 +123,9 @@ function DatePickerField({ mode, label, name, testId, value, min, max, step, dis
123
123
  }),
124
124
  /* @__PURE__ */ jsx(Button, {
125
125
  ...api.getNextTriggerProps(),
126
+ emphasis: "ghost",
126
127
  size: "icon",
127
128
  type: "button",
128
- variant: "ghost",
129
129
  children: /* @__PURE__ */ jsx(Icon, {
130
130
  name: "chevron-right",
131
131
  className: "size-lt-icon-md",
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker-field.js","names":[],"sources":["../../../../resources/js/form/components/fields/date-picker-field.tsx"],"sourcesContent":["import type { DateValue } from \"@internationalized/date\";\nimport * as datePicker from \"@zag-js/date-picker\";\nimport { normalizeProps, useMachine } from \"@zag-js/react\";\nimport { useId, useMemo } from \"react\";\nimport { Button } from \"@lattice-php/lattice/ui/button\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { useLocale } from \"@lattice-php/lattice/i18n\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { Input } from \"@lattice-php/lattice/ui/input\";\nimport {\n formatDateDisplayValue,\n formatDateTimeDisplayValue,\n formatDateTimeValue,\n formatDateValue,\n formatTimeInputValue,\n parseDateDisplayValue,\n parseDateTimeDisplayValue,\n parseDateTimeValue,\n parseDateValue,\n} from \"./date-picker-value\";\nimport { TimePicker } from \"./time-picker\";\nimport { parseTimeString } from \"./time-picker-columns\";\n\nexport type DatePickerFieldProps = {\n mode: \"date\" | \"date-time\";\n label: string;\n name: string;\n testId: string;\n value: unknown;\n min?: string | null;\n max?: string | null;\n step?: number | null;\n disabled: boolean;\n readOnly: boolean;\n autoFocus?: boolean;\n tabIndex?: number | null;\n timezone?: string;\n onChange: (value: string) => void;\n onBlur?: () => void;\n};\n\nexport function DatePickerField({\n mode,\n label,\n name,\n testId,\n value,\n min,\n max,\n step,\n disabled,\n readOnly,\n autoFocus = false,\n tabIndex,\n timezone = \"UTC\",\n onChange,\n onBlur,\n}: DatePickerFieldProps) {\n const id = useId();\n const { locale } = useLocale();\n const selected = useMemo(\n () =>\n [mode === \"date\" ? parseDateValue(value) : parseDateTimeValue(value, timezone)].filter(\n Boolean,\n ) as DateValue[],\n [mode, timezone, value],\n );\n const service = useMachine(datePicker.machine, {\n id,\n name,\n value: selected.length > 0 ? selected : undefined,\n min: min ? parseDateValue(min) : undefined,\n max: max ? parseDateValue(max) : undefined,\n disabled,\n readOnly,\n locale,\n selectionMode: \"single\",\n timeZone: timezone,\n closeOnSelect: mode === \"date\",\n format(date) {\n return mode === \"date\"\n ? formatDateDisplayValue(date, locale)\n : formatDateTimeDisplayValue(date, locale, timezone);\n },\n parse(text) {\n return mode === \"date\"\n ? parseDateDisplayValue(text, locale)\n : parseDateTimeDisplayValue(text, locale, timezone);\n },\n onValueChange(details) {\n const next = details.value[0];\n\n onChange(mode === \"date\" ? formatDateValue(next) : formatDateTimeValue(next, timezone));\n },\n onOpenChange(details) {\n if (!details.open) {\n onBlur?.();\n }\n },\n });\n const api = datePicker.connect(service, normalizeProps);\n const { name: _inputName, onInput, ...inputProps } = api.getInputProps();\n const submittedValue =\n mode === \"date\" ? formatDateValue(selected[0]) : formatDateTimeValue(selected[0], timezone);\n\n return (\n <div {...api.getRootProps()} className={cn(\"relative\", api.open && \"z-lt-popover\")}>\n <input type=\"hidden\" name={name} value={submittedValue} data-test={`${testId}-value`} />\n <div {...api.getControlProps()} className=\"flex gap-2\">\n <Input\n {...inputProps}\n aria-label={label}\n autoFocus={autoFocus}\n data-test={testId}\n disabled={disabled}\n id={name}\n onInput={(event) => {\n onInput?.(event);\n\n if (mode !== \"date\") {\n return;\n }\n\n const normalized = normalizeDateInputValue(event.currentTarget.value);\n\n if (!normalized) {\n return;\n }\n\n const next = parseDateValue(normalized);\n\n if (!next) {\n return;\n }\n\n event.currentTarget.value = normalized;\n api.setValue([next]);\n event.currentTarget.value = formatDateDisplayValue(next, locale);\n onChange(formatDateValue(next));\n }}\n readOnly={readOnly}\n tabIndex={tabIndex ?? undefined}\n />\n <Button\n {...api.getTriggerProps()}\n aria-label={`Open ${label || name} calendar`}\n disabled={disabled || readOnly}\n size=\"icon\"\n type=\"button\"\n variant=\"secondary\"\n >\n <Icon name=\"calendar\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n </div>\n {api.open ? (\n <div\n {...api.getPositionerProps()}\n className=\"absolute z-lt-popover mt-2 rounded-lt-sm border border-lt-border bg-lt-popover p-3 text-lt-popover-fg shadow-lt-md\"\n >\n <div {...api.getContentProps()} className=\"grid gap-3\">\n <div className=\"flex items-center justify-between gap-2\">\n <Button {...api.getPrevTriggerProps()} size=\"icon\" type=\"button\" variant=\"ghost\">\n <Icon name=\"chevron-left\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n <div {...api.getRangeTextProps()} className=\"text-sm font-medium text-lt-fg\" />\n <Button {...api.getNextTriggerProps()} size=\"icon\" type=\"button\" variant=\"ghost\">\n <Icon name=\"chevron-right\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n </div>\n <table {...api.getTableProps()} className=\"w-full border-collapse text-sm\">\n <thead {...api.getTableHeadProps()}>\n <tr {...api.getTableRowProps()}>\n {api.weekDays.map((day) => (\n <th\n {...api.getTableHeaderProps()}\n aria-label={day.long}\n key={day.value.toString()}\n className=\"size-8 text-center text-xs font-medium text-lt-muted-fg\"\n >\n {day.narrow}\n </th>\n ))}\n </tr>\n </thead>\n <tbody {...api.getTableBodyProps()}>\n {api.weeks.map((week, weekIndex) => (\n <tr {...api.getTableRowProps()} key={weekIndex}>\n {week.map((day) => {\n const state = api.getDayTableCellState({ value: day });\n\n return (\n <td\n {...api.getDayTableCellProps({ value: day })}\n key={day.toString()}\n className=\"p-0 text-center\"\n >\n <button\n {...api.getDayTableCellTriggerProps({ value: day })}\n type=\"button\"\n className={cn(\n \"size-8 rounded-lt-sm text-sm text-lt-fg hover:bg-lt-muted\",\n state.selected && \"bg-lt-primary text-lt-primary-fg\",\n state.outsideRange && \"text-lt-muted-fg\",\n state.disabled && \"cursor-not-allowed opacity-40\",\n )}\n >\n {day.day}\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n {mode === \"date-time\" ? (\n <TimePicker\n value={parseTimeString(formatTimeInputValue(selected[0], timezone))}\n onChange={(next) =>\n api.setTime({ hour: next.hour, minute: next.minute, second: next.second })\n }\n step={step}\n disabled={disabled}\n readOnly={readOnly}\n testId={`${testId}-time`}\n />\n ) : null}\n </div>\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction normalizeDateInputValue(value: string): string | undefined {\n const compact = value.replace(/\\D/g, \"\");\n\n if (compact.length !== 8) {\n return undefined;\n }\n\n return `${compact.slice(0, 4)}-${compact.slice(4, 6)}-${compact.slice(6, 8)}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,gBAAgB,EAC9B,MACA,OACA,MACA,QACA,OACA,KACA,KACA,MACA,UACA,UACA,YAAY,OACZ,UACA,WAAW,OACX,UACA,UACuB;CACvB,MAAM,KAAK,MAAM;CACjB,MAAM,EAAE,WAAW,UAAU;CAC7B,MAAM,WAAW,cAEb,CAAC,SAAS,SAAS,eAAe,KAAK,IAAI,mBAAmB,OAAO,QAAQ,CAAC,EAAE,OAC9E,OACF,GACF;EAAC;EAAM;EAAU;CAAK,CACxB;CACA,MAAM,UAAU,WAAW,WAAW,SAAS;EAC7C;EACA;EACA,OAAO,SAAS,SAAS,IAAI,WAAW,KAAA;EACxC,KAAK,MAAM,eAAe,GAAG,IAAI,KAAA;EACjC,KAAK,MAAM,eAAe,GAAG,IAAI,KAAA;EACjC;EACA;EACA;EACA,eAAe;EACf,UAAU;EACV,eAAe,SAAS;EACxB,OAAO,MAAM;GACX,OAAO,SAAS,SACZ,uBAAuB,MAAM,MAAM,IACnC,2BAA2B,MAAM,QAAQ,QAAQ;EACvD;EACA,MAAM,MAAM;GACV,OAAO,SAAS,SACZ,sBAAsB,MAAM,MAAM,IAClC,0BAA0B,MAAM,QAAQ,QAAQ;EACtD;EACA,cAAc,SAAS;GACrB,MA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E,OAAO,IAAI,CAAC;UAC3C,KAAK,IAAI,SAAS;UAClB,WAAU;SAcR,GAZF,oBAAC,UAAD;UACE,GAAI,IAAI,4BAA4B,EAAE,OAAO,IAAI,CAAC;UAClD,MAAK;UACL,WAAW,GACT,6DACA,MAAM,YAAY,oCAClB,MAAM,gBAAgB,oBACtB,MAAM,YAAY,+BACpB;oBAEC,IAAI;SACC,CAAA,CACN;QAER,CAAC,CACC,CACL;OACI,CAAA,CACF;;MACN,SAAS,cACR,oBAAC,YAAD;OACE,OAAO,gBAAgB,qBAAqB,SAAS,IAAI,QAAQ,CAAC;OAClE,WAAW,SACT,IAAI,QAAQ;QAAE,MAAM,KAAK;QAAM,QAAQ,KAAK;QAAQ,QAAQ,KAAK;OAAO,CAAC;OAErE;OACI;OACA;OACV,QAAQ,GAAG,OAAO;MACnB,CAAA,IACC;KACD;;GACF,CAAA,IACH;EACD;;AAET;AAEA,SAAS,wBAAwB,OAAmC;CAClE,MAAM,UAAU,MAAM,QAAQ,OAAO,EAAE;CAEvC,IAAI,QAAQ,WAAW,GACrB;CAGF,OAAO,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,GAAG,CAAC;AAC5E"}
1
+ {"version":3,"file":"date-picker-field.js","names":[],"sources":["../../../../resources/js/form/components/fields/date-picker-field.tsx"],"sourcesContent":["import type { DateValue } from \"@internationalized/date\";\nimport * as datePicker from \"@zag-js/date-picker\";\nimport { normalizeProps, useMachine } from \"@zag-js/react\";\nimport { useId, useMemo } from \"react\";\nimport { Button } from \"@lattice-php/lattice/ui/button\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { useLocale } from \"@lattice-php/lattice/i18n\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { Input } from \"@lattice-php/lattice/ui/input\";\nimport {\n formatDateDisplayValue,\n formatDateTimeDisplayValue,\n formatDateTimeValue,\n formatDateValue,\n formatTimeInputValue,\n parseDateDisplayValue,\n parseDateTimeDisplayValue,\n parseDateTimeValue,\n parseDateValue,\n} from \"./date-picker-value\";\nimport { TimePicker } from \"./time-picker\";\nimport { parseTimeString } from \"./time-picker-columns\";\n\nexport type DatePickerFieldProps = {\n mode: \"date\" | \"date-time\";\n label: string;\n name: string;\n testId: string;\n value: unknown;\n min?: string | null;\n max?: string | null;\n step?: number | null;\n disabled: boolean;\n readOnly: boolean;\n autoFocus?: boolean;\n tabIndex?: number | null;\n timezone?: string;\n onChange: (value: string) => void;\n onBlur?: () => void;\n};\n\nexport function DatePickerField({\n mode,\n label,\n name,\n testId,\n value,\n min,\n max,\n step,\n disabled,\n readOnly,\n autoFocus = false,\n tabIndex,\n timezone = \"UTC\",\n onChange,\n onBlur,\n}: DatePickerFieldProps) {\n const id = useId();\n const { locale } = useLocale();\n const selected = useMemo(\n () =>\n [mode === \"date\" ? parseDateValue(value) : parseDateTimeValue(value, timezone)].filter(\n Boolean,\n ) as DateValue[],\n [mode, timezone, value],\n );\n const service = useMachine(datePicker.machine, {\n id,\n name,\n value: selected.length > 0 ? selected : undefined,\n min: min ? parseDateValue(min) : undefined,\n max: max ? parseDateValue(max) : undefined,\n disabled,\n readOnly,\n locale,\n selectionMode: \"single\",\n timeZone: timezone,\n closeOnSelect: mode === \"date\",\n format(date) {\n return mode === \"date\"\n ? formatDateDisplayValue(date, locale)\n : formatDateTimeDisplayValue(date, locale, timezone);\n },\n parse(text) {\n return mode === \"date\"\n ? parseDateDisplayValue(text, locale)\n : parseDateTimeDisplayValue(text, locale, timezone);\n },\n onValueChange(details) {\n const next = details.value[0];\n\n onChange(mode === \"date\" ? formatDateValue(next) : formatDateTimeValue(next, timezone));\n },\n onOpenChange(details) {\n if (!details.open) {\n onBlur?.();\n }\n },\n });\n const api = datePicker.connect(service, normalizeProps);\n const { name: _inputName, onInput, ...inputProps } = api.getInputProps();\n const submittedValue =\n mode === \"date\" ? formatDateValue(selected[0]) : formatDateTimeValue(selected[0], timezone);\n\n return (\n <div {...api.getRootProps()} className={cn(\"relative\", api.open && \"z-lt-popover\")}>\n <input type=\"hidden\" name={name} value={submittedValue} data-test={`${testId}-value`} />\n <div {...api.getControlProps()} className=\"flex gap-2\">\n <Input\n {...inputProps}\n aria-label={label}\n autoFocus={autoFocus}\n data-test={testId}\n disabled={disabled}\n id={name}\n onInput={(event) => {\n onInput?.(event);\n\n if (mode !== \"date\") {\n return;\n }\n\n const normalized = normalizeDateInputValue(event.currentTarget.value);\n\n if (!normalized) {\n return;\n }\n\n const next = parseDateValue(normalized);\n\n if (!next) {\n return;\n }\n\n event.currentTarget.value = normalized;\n api.setValue([next]);\n event.currentTarget.value = formatDateDisplayValue(next, locale);\n onChange(formatDateValue(next));\n }}\n readOnly={readOnly}\n tabIndex={tabIndex ?? undefined}\n />\n <Button\n {...api.getTriggerProps()}\n aria-label={`Open ${label || name} calendar`}\n disabled={disabled || readOnly}\n size=\"icon\"\n type=\"button\"\n variant=\"secondary\"\n >\n <Icon name=\"calendar\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n </div>\n {api.open ? (\n <div\n {...api.getPositionerProps()}\n className=\"absolute z-lt-popover mt-2 rounded-lt-sm border border-lt-border bg-lt-popover p-3 text-lt-popover-fg shadow-lt-md\"\n >\n <div {...api.getContentProps()} className=\"grid gap-3\">\n <div className=\"flex items-center justify-between gap-2\">\n <Button {...api.getPrevTriggerProps()} emphasis=\"ghost\" size=\"icon\" type=\"button\">\n <Icon name=\"chevron-left\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n <div {...api.getRangeTextProps()} className=\"text-sm font-medium text-lt-fg\" />\n <Button {...api.getNextTriggerProps()} emphasis=\"ghost\" size=\"icon\" type=\"button\">\n <Icon name=\"chevron-right\" className=\"size-lt-icon-md\" aria-hidden=\"true\" />\n </Button>\n </div>\n <table {...api.getTableProps()} className=\"w-full border-collapse text-sm\">\n <thead {...api.getTableHeadProps()}>\n <tr {...api.getTableRowProps()}>\n {api.weekDays.map((day) => (\n <th\n {...api.getTableHeaderProps()}\n aria-label={day.long}\n key={day.value.toString()}\n className=\"size-8 text-center text-xs font-medium text-lt-muted-fg\"\n >\n {day.narrow}\n </th>\n ))}\n </tr>\n </thead>\n <tbody {...api.getTableBodyProps()}>\n {api.weeks.map((week, weekIndex) => (\n <tr {...api.getTableRowProps()} key={weekIndex}>\n {week.map((day) => {\n const state = api.getDayTableCellState({ value: day });\n\n return (\n <td\n {...api.getDayTableCellProps({ value: day })}\n key={day.toString()}\n className=\"p-0 text-center\"\n >\n <button\n {...api.getDayTableCellTriggerProps({ value: day })}\n type=\"button\"\n className={cn(\n \"size-8 rounded-lt-sm text-sm text-lt-fg hover:bg-lt-muted\",\n state.selected && \"bg-lt-primary text-lt-primary-fg\",\n state.outsideRange && \"text-lt-muted-fg\",\n state.disabled && \"cursor-not-allowed opacity-40\",\n )}\n >\n {day.day}\n </button>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n {mode === \"date-time\" ? (\n <TimePicker\n value={parseTimeString(formatTimeInputValue(selected[0], timezone))}\n onChange={(next) =>\n api.setTime({ hour: next.hour, minute: next.minute, second: next.second })\n }\n step={step}\n disabled={disabled}\n readOnly={readOnly}\n testId={`${testId}-time`}\n />\n ) : null}\n </div>\n </div>\n ) : null}\n </div>\n );\n}\n\nfunction normalizeDateInputValue(value: string): string | undefined {\n const compact = value.replace(/\\D/g, \"\");\n\n if (compact.length !== 8) {\n return undefined;\n }\n\n return `${compact.slice(0, 4)}-${compact.slice(4, 6)}-${compact.slice(6, 8)}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAyCA,SAAgB,gBAAgB,EAC9B,MACA,OACA,MACA,QACA,OACA,KACA,KACA,MACA,UACA,UACA,YAAY,OACZ,UACA,WAAW,OACX,UACA,UACuB;CACvB,MAAM,KAAK,MAAM;CACjB,MAAM,EAAE,WAAW,UAAU;CAC7B,MAAM,WAAW,cAEb,CAAC,SAAS,SAAS,eAAe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,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,GAAG,CAAC,EAAE,GAAG,QAAQ,MAAM,GAAG,CAAC;AAC5E"}
@@ -1,6 +1,6 @@
1
+ import { apiFetch } from "../../../core/api.js";
1
2
  import { useT } from "../../../i18n/instance.js";
2
3
  import { testIdentity } from "../../../core/test-id.js";
3
- import { apiFetch } from "../../../core/api.js";
4
4
  import { useFormContext } from "../../hooks/context.js";
5
5
  import { useFieldScope } from "../../hooks/field-scope.js";
6
6
  import { useFormValues, useSetFormValue } from "../../hooks/values.js";
@@ -100,7 +100,8 @@ var FileUploadComponent = ({ node }) => {
100
100
  ref: componentRef,
101
101
  body: JSON.stringify({
102
102
  ...values,
103
- _upload: uploadKey,
103
+ _sub: "upload",
104
+ _target: uploadKey,
104
105
  filename: file.name,
105
106
  contentType: file.type
106
107
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload.js","names":[],"sources":["../../../../resources/js/form/components/fields/file-upload.tsx"],"sourcesContent":["import { apiFetch } from \"@lattice-php/lattice/core/api\";\nimport { testIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { SignedUpload } from \"@lattice-php/lattice/types/generated\";\nimport { IconButton } from \"@lattice-php/lattice/ui/icon-button\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { FormFieldFrame } from \"@lattice-php/lattice/form/components/base/field\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\nimport { useDependentField } from \"@lattice-php/lattice/form/hooks/use-dependent-field\";\nimport { useFieldScope } from \"@lattice-php/lattice/form/hooks/field-scope\";\nimport { useFormValues, useSetFormValue } from \"@lattice-php/lattice/form/hooks/values\";\n\ntype Item = {\n id: string;\n name: string;\n size: number | null;\n status: \"ready\" | \"uploading\" | \"error\";\n progress: number;\n file?: File;\n key?: string;\n url?: string | null;\n token?: string;\n existing: boolean;\n};\n\nfunction uploadValueEquals(current: unknown, next: string[] | string): boolean {\n if (Array.isArray(next)) {\n return (\n Array.isArray(current) &&\n current.length === next.length &&\n current.every((value, index) => value === next[index])\n );\n }\n\n return current === next;\n}\n\nexport const FileUploadComponent: RendererComponent<\"field.file-upload\"> = ({ node }) => {\n const { t } = useT(\"lattice\");\n const props = node.props;\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { action, componentRef, errors } = useFormContext();\n const name = props.name;\n const scope = useFieldScope();\n const domName = scope ? scope.scopedName(name) : name;\n const errorKey = scope ? scope.errorKey(name) : name;\n const uploadKey = errorKey;\n const values = useFormValues();\n const setValue = useSetFormValue();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const previewUrlsRef = useRef<Set<string>>(new Set());\n const locked = readOnly || disabled;\n const signed = props.signed;\n const multiple = props.multiple;\n const fieldName = multiple ? `${domName}[]` : domName;\n\n const initial = useMemo<Item[]>(\n () =>\n (props.files ?? []).map((file) => ({\n id: crypto.randomUUID(),\n name: file.name,\n size: file.size,\n status: \"ready\" as const,\n progress: 100,\n key: file.key,\n url: file.url,\n token: file.token,\n existing: true,\n })),\n [props.files],\n );\n const [items, setItems] = useState<Item[]>(initial);\n const [removedTokens, setRemovedTokens] = useState<string[]>([]);\n\n useEffect(() => {\n if (!signed) {\n return;\n }\n\n const keys = items\n .filter((item) => !item.existing && item.key && item.status === \"ready\")\n .map((item) => item.key as string);\n const next = multiple ? keys : (keys[0] ?? \"\");\n\n if (scope) {\n if (!uploadValueEquals(scope.getValue(name), next)) {\n scope.setValue(name, next);\n }\n\n return;\n }\n\n setValue(name, next);\n }, [items, multiple, name, scope, setValue, signed]);\n\n useEffect(() => {\n if (!signed || scope) {\n return;\n }\n\n setValue(`${name}__removed`, removedTokens);\n }, [name, removedTokens, scope, setValue, signed]);\n\n useEffect(\n () => () => {\n previewUrlsRef.current.forEach((url) => URL.revokeObjectURL(url));\n previewUrlsRef.current.clear();\n },\n [],\n );\n\n const multipartFiles = useMemo(\n () => items.filter((item) => item.file && !item.existing).map((item) => item.file as File),\n [items],\n );\n useEffect(() => {\n if (signed || !fileInputRef.current) {\n return;\n }\n\n const transfer = new DataTransfer();\n multipartFiles.forEach((file) => transfer.items.add(file));\n fileInputRef.current.files = transfer.files;\n }, [multipartFiles, signed]);\n\n function createPreviewUrl(file: File): string | undefined {\n if (!props.image) {\n return undefined;\n }\n\n const url = URL.createObjectURL(file);\n previewUrlsRef.current.add(url);\n\n return url;\n }\n\n function revokePreviewUrl(item: Item): void {\n if (!item.url || !previewUrlsRef.current.has(item.url)) {\n return;\n }\n\n URL.revokeObjectURL(item.url);\n previewUrlsRef.current.delete(item.url);\n }\n\n async function signAndUpload(item: Item, file: File): Promise<void> {\n const response = await apiFetch(action, {\n method: \"POST\",\n ref: componentRef,\n body: JSON.stringify({\n ...values,\n _upload: uploadKey,\n filename: file.name,\n contentType: file.type,\n }),\n throwOnError: false,\n });\n\n if (!response.ok) {\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, status: \"error\" } : entry)),\n );\n\n return;\n }\n\n const sign = (await response.json()) as SignedUpload;\n\n await new Promise<void>((resolve) => {\n const request = new XMLHttpRequest();\n request.open(sign.method.toUpperCase(), sign.url, true);\n Object.entries(sign.headers).forEach(([key, value]) =>\n request.setRequestHeader(key, String(value)),\n );\n request.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n const progress = Math.round((event.loaded / event.total) * 100);\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, progress } : entry)),\n );\n }\n };\n request.onload = () => {\n setItems((prev) =>\n prev.map((entry) =>\n entry.id === item.id\n ? {\n ...entry,\n status: request.status < 300 ? \"ready\" : \"error\",\n key: sign.key,\n progress: 100,\n }\n : entry,\n ),\n );\n resolve();\n };\n request.onerror = () => {\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, status: \"error\" } : entry)),\n );\n resolve();\n };\n request.send(file);\n });\n }\n\n function addFiles(fileList: FileList | null): void {\n if (!fileList || locked) {\n return;\n }\n\n const incoming = Array.from(fileList);\n const next = incoming.map<Item>((file) => ({\n id: crypto.randomUUID(),\n name: file.name,\n size: file.size,\n status: signed ? \"uploading\" : \"ready\",\n progress: 0,\n file,\n url: createPreviewUrl(file),\n existing: false,\n }));\n\n if (!multiple) {\n items.forEach(revokePreviewUrl);\n\n if (!scope) {\n const replacedTokens = items\n .filter((item) => item.existing && item.token)\n .map((item) => item.token as string);\n\n if (replacedTokens.length > 0) {\n setRemovedTokens((tokens) => [...tokens, ...replacedTokens]);\n }\n }\n }\n\n setItems((prev) => (multiple ? [...prev, ...next] : next));\n\n if (signed) {\n next.forEach((item, index) => void signAndUpload(item, incoming[index]));\n }\n }\n\n function removeItem(id: string): void {\n const target = items.find((item) => item.id === id);\n\n if (target) {\n revokePreviewUrl(target);\n }\n\n if (target?.existing && target.token && !scope) {\n setRemovedTokens((tokens) => [...tokens, target.token as string]);\n }\n\n setItems((prev) => prev.filter((i) => i.id !== id));\n }\n\n if (hidden) {\n return null;\n }\n\n return (\n <FormFieldFrame\n error={errors[errorKey]}\n helperText={props.helperText ?? undefined}\n tooltip={props.tooltip ?? undefined}\n label={props.label ?? \"\"}\n name={name}\n required={required}\n >\n <div\n className=\"flex flex-col gap-3 rounded-lt-sm border border-dashed border-lt-border bg-lt-surface px-4 py-6\"\n data-test={testIdentity(name)}\n onDragOver={(event) => event.preventDefault()}\n onDrop={(event) => {\n event.preventDefault();\n addFiles(event.dataTransfer.files);\n }}\n >\n <button\n className=\"text-sm text-lt-muted-fg\"\n disabled={locked}\n onClick={() => fileInputRef.current?.click()}\n type=\"button\"\n >\n {t(\"form.file-upload.dropzone\", \"Drop files here or click to browse\")}\n </button>\n\n <ul\n className={props.image ? \"grid grid-cols-1 gap-3 sm:grid-cols-2\" : \"flex flex-col gap-2\"}\n >\n {items.map((item) => (\n <li\n className={\n props.image\n ? \"flex min-w-0 items-center gap-3 rounded-lt-sm border border-lt-border bg-lt-bg p-2 text-sm\"\n : \"flex items-center justify-between gap-3 text-sm\"\n }\n key={item.id}\n >\n {props.image && item.url ? (\n <img\n alt={item.name}\n className=\"size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover\"\n data-test={testIdentity(`${name}-preview`)}\n src={item.url}\n />\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <span className=\"block truncate\" data-test={testIdentity(`${name}-item`)}>\n {item.name}\n </span>\n {item.status === \"uploading\" && (\n <span className=\"text-xs text-lt-muted-fg\">{item.progress}%</span>\n )}\n {item.status === \"error\" && (\n <span className=\"text-xs text-lt-danger\">\n {t(\"form.file-upload.failed\", \"Failed\")}\n </span>\n )}\n </div>\n {(!item.existing || !scope) && (\n <IconButton\n size=\"sm\"\n icon=\"x\"\n label={t(\"form.file-upload.remove\", \"Remove {{name}}\", { name: item.name })}\n data-test={testIdentity(\n item.existing ? `${name}-remove-existing` : `${name}-remove`,\n )}\n disabled={locked}\n onClick={() => removeItem(item.id)}\n />\n )}\n {signed && !item.existing && item.key && item.status === \"ready\" && (\n <input\n data-test={testIdentity(`${name}-uploaded`)}\n name={fieldName}\n type=\"hidden\"\n value={item.key}\n />\n )}\n </li>\n ))}\n </ul>\n\n {!scope &&\n removedTokens.map((token) => (\n <input key={token} name={`${name}__removed[]`} type=\"hidden\" value={token} />\n ))}\n\n <input\n accept={props.accept ?? undefined}\n aria-label={props.label ?? name}\n className=\"sr-only\"\n data-test={testIdentity(`${name}-input`)}\n id={inputId}\n multiple={multiple}\n name={signed ? undefined : fieldName}\n onChange={(event) => {\n addFiles(event.target.files);\n if (signed) {\n event.target.value = \"\";\n }\n }}\n ref={fileInputRef}\n type=\"file\"\n />\n </div>\n </FormFieldFrame>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAS,kBAAkB,SAAkB,MAAkC;CAC7E,IAAI,MAAM,QAAQ,IAAI,GACpB,OACE,MAAM,QAAQ,OAAO,KACrB,QAAQ,WAAW,KAAK,UACxB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AAD;KACE,QAAQ,MAAM,UAAU,KAAA;KACxB,cAAY,MAAM,SAAS;KAC3B,WAAU;KACV,aAAW,aAAa,GAAG,KAAK,OAAO;KACvC,IAAI;KACM;KACV,MAAM,SAAS,KAAA,IAAY;KAC3B,WAAW,UAAU;MACnB,SAAS,MAAM,OAAO,KAAK;MAC3B,IAAI,QACF,MAAM,OAAO,QAAQ;KAEzB;KACA,KAAK;KACL,MAAK;IACN,CAAA;GACE;;CACS,CAAA;AAEpB"}
1
+ {"version":3,"file":"file-upload.js","names":[],"sources":["../../../../resources/js/form/components/fields/file-upload.tsx"],"sourcesContent":["import { apiFetch } from \"@lattice-php/lattice/core/api\";\nimport { testIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { SignedUpload } from \"@lattice-php/lattice/types/generated\";\nimport { IconButton } from \"@lattice-php/lattice/ui/icon-button\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport { useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { FormFieldFrame } from \"@lattice-php/lattice/form/components/base/field\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\nimport { useDependentField } from \"@lattice-php/lattice/form/hooks/use-dependent-field\";\nimport { useFieldScope } from \"@lattice-php/lattice/form/hooks/field-scope\";\nimport { useFormValues, useSetFormValue } from \"@lattice-php/lattice/form/hooks/values\";\n\ntype Item = {\n id: string;\n name: string;\n size: number | null;\n status: \"ready\" | \"uploading\" | \"error\";\n progress: number;\n file?: File;\n key?: string;\n url?: string | null;\n token?: string;\n existing: boolean;\n};\n\nfunction uploadValueEquals(current: unknown, next: string[] | string): boolean {\n if (Array.isArray(next)) {\n return (\n Array.isArray(current) &&\n current.length === next.length &&\n current.every((value, index) => value === next[index])\n );\n }\n\n return current === next;\n}\n\nexport const FileUploadComponent: RendererComponent<\"field.file-upload\"> = ({ node }) => {\n const { t } = useT(\"lattice\");\n const props = node.props;\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { action, componentRef, errors } = useFormContext();\n const name = props.name;\n const scope = useFieldScope();\n const domName = scope ? scope.scopedName(name) : name;\n const errorKey = scope ? scope.errorKey(name) : name;\n const uploadKey = errorKey;\n const values = useFormValues();\n const setValue = useSetFormValue();\n const inputId = useId();\n const fileInputRef = useRef<HTMLInputElement>(null);\n const previewUrlsRef = useRef<Set<string>>(new Set());\n const locked = readOnly || disabled;\n const signed = props.signed;\n const multiple = props.multiple;\n const fieldName = multiple ? `${domName}[]` : domName;\n\n const initial = useMemo<Item[]>(\n () =>\n (props.files ?? []).map((file) => ({\n id: crypto.randomUUID(),\n name: file.name,\n size: file.size,\n status: \"ready\" as const,\n progress: 100,\n key: file.key,\n url: file.url,\n token: file.token,\n existing: true,\n })),\n [props.files],\n );\n const [items, setItems] = useState<Item[]>(initial);\n const [removedTokens, setRemovedTokens] = useState<string[]>([]);\n\n useEffect(() => {\n if (!signed) {\n return;\n }\n\n const keys = items\n .filter((item) => !item.existing && item.key && item.status === \"ready\")\n .map((item) => item.key as string);\n const next = multiple ? keys : (keys[0] ?? \"\");\n\n if (scope) {\n if (!uploadValueEquals(scope.getValue(name), next)) {\n scope.setValue(name, next);\n }\n\n return;\n }\n\n setValue(name, next);\n }, [items, multiple, name, scope, setValue, signed]);\n\n useEffect(() => {\n if (!signed || scope) {\n return;\n }\n\n setValue(`${name}__removed`, removedTokens);\n }, [name, removedTokens, scope, setValue, signed]);\n\n useEffect(\n () => () => {\n previewUrlsRef.current.forEach((url) => URL.revokeObjectURL(url));\n previewUrlsRef.current.clear();\n },\n [],\n );\n\n const multipartFiles = useMemo(\n () => items.filter((item) => item.file && !item.existing).map((item) => item.file as File),\n [items],\n );\n useEffect(() => {\n if (signed || !fileInputRef.current) {\n return;\n }\n\n const transfer = new DataTransfer();\n multipartFiles.forEach((file) => transfer.items.add(file));\n fileInputRef.current.files = transfer.files;\n }, [multipartFiles, signed]);\n\n function createPreviewUrl(file: File): string | undefined {\n if (!props.image) {\n return undefined;\n }\n\n const url = URL.createObjectURL(file);\n previewUrlsRef.current.add(url);\n\n return url;\n }\n\n function revokePreviewUrl(item: Item): void {\n if (!item.url || !previewUrlsRef.current.has(item.url)) {\n return;\n }\n\n URL.revokeObjectURL(item.url);\n previewUrlsRef.current.delete(item.url);\n }\n\n async function signAndUpload(item: Item, file: File): Promise<void> {\n const response = await apiFetch(action, {\n method: \"POST\",\n ref: componentRef,\n body: JSON.stringify({\n ...values,\n _sub: \"upload\",\n _target: uploadKey,\n filename: file.name,\n contentType: file.type,\n }),\n throwOnError: false,\n });\n\n if (!response.ok) {\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, status: \"error\" } : entry)),\n );\n\n return;\n }\n\n const sign = (await response.json()) as SignedUpload;\n\n await new Promise<void>((resolve) => {\n const request = new XMLHttpRequest();\n request.open(sign.method.toUpperCase(), sign.url, true);\n Object.entries(sign.headers).forEach(([key, value]) =>\n request.setRequestHeader(key, String(value)),\n );\n request.upload.onprogress = (event) => {\n if (event.lengthComputable) {\n const progress = Math.round((event.loaded / event.total) * 100);\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, progress } : entry)),\n );\n }\n };\n request.onload = () => {\n setItems((prev) =>\n prev.map((entry) =>\n entry.id === item.id\n ? {\n ...entry,\n status: request.status < 300 ? \"ready\" : \"error\",\n key: sign.key,\n progress: 100,\n }\n : entry,\n ),\n );\n resolve();\n };\n request.onerror = () => {\n setItems((prev) =>\n prev.map((entry) => (entry.id === item.id ? { ...entry, status: \"error\" } : entry)),\n );\n resolve();\n };\n request.send(file);\n });\n }\n\n function addFiles(fileList: FileList | null): void {\n if (!fileList || locked) {\n return;\n }\n\n const incoming = Array.from(fileList);\n const next = incoming.map<Item>((file) => ({\n id: crypto.randomUUID(),\n name: file.name,\n size: file.size,\n status: signed ? \"uploading\" : \"ready\",\n progress: 0,\n file,\n url: createPreviewUrl(file),\n existing: false,\n }));\n\n if (!multiple) {\n items.forEach(revokePreviewUrl);\n\n if (!scope) {\n const replacedTokens = items\n .filter((item) => item.existing && item.token)\n .map((item) => item.token as string);\n\n if (replacedTokens.length > 0) {\n setRemovedTokens((tokens) => [...tokens, ...replacedTokens]);\n }\n }\n }\n\n setItems((prev) => (multiple ? [...prev, ...next] : next));\n\n if (signed) {\n next.forEach((item, index) => void signAndUpload(item, incoming[index]));\n }\n }\n\n function removeItem(id: string): void {\n const target = items.find((item) => item.id === id);\n\n if (target) {\n revokePreviewUrl(target);\n }\n\n if (target?.existing && target.token && !scope) {\n setRemovedTokens((tokens) => [...tokens, target.token as string]);\n }\n\n setItems((prev) => prev.filter((i) => i.id !== id));\n }\n\n if (hidden) {\n return null;\n }\n\n return (\n <FormFieldFrame\n error={errors[errorKey]}\n helperText={props.helperText ?? undefined}\n tooltip={props.tooltip ?? undefined}\n label={props.label ?? \"\"}\n name={name}\n required={required}\n >\n <div\n className=\"flex flex-col gap-3 rounded-lt-sm border border-dashed border-lt-border bg-lt-surface px-4 py-6\"\n data-test={testIdentity(name)}\n onDragOver={(event) => event.preventDefault()}\n onDrop={(event) => {\n event.preventDefault();\n addFiles(event.dataTransfer.files);\n }}\n >\n <button\n className=\"text-sm text-lt-muted-fg\"\n disabled={locked}\n onClick={() => fileInputRef.current?.click()}\n type=\"button\"\n >\n {t(\"form.file-upload.dropzone\", \"Drop files here or click to browse\")}\n </button>\n\n <ul\n className={props.image ? \"grid grid-cols-1 gap-3 sm:grid-cols-2\" : \"flex flex-col gap-2\"}\n >\n {items.map((item) => (\n <li\n className={\n props.image\n ? \"flex min-w-0 items-center gap-3 rounded-lt-sm border border-lt-border bg-lt-bg p-2 text-sm\"\n : \"flex items-center justify-between gap-3 text-sm\"\n }\n key={item.id}\n >\n {props.image && item.url ? (\n <img\n alt={item.name}\n className=\"size-16 shrink-0 rounded-lt-sm border border-lt-border object-cover\"\n data-test={testIdentity(`${name}-preview`)}\n src={item.url}\n />\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <span className=\"block truncate\" data-test={testIdentity(`${name}-item`)}>\n {item.name}\n </span>\n {item.status === \"uploading\" && (\n <span className=\"text-xs text-lt-muted-fg\">{item.progress}%</span>\n )}\n {item.status === \"error\" && (\n <span className=\"text-xs text-lt-danger\">\n {t(\"form.file-upload.failed\", \"Failed\")}\n </span>\n )}\n </div>\n {(!item.existing || !scope) && (\n <IconButton\n size=\"sm\"\n icon=\"x\"\n label={t(\"form.file-upload.remove\", \"Remove {{name}}\", { name: item.name })}\n data-test={testIdentity(\n item.existing ? `${name}-remove-existing` : `${name}-remove`,\n )}\n disabled={locked}\n onClick={() => removeItem(item.id)}\n />\n )}\n {signed && !item.existing && item.key && item.status === \"ready\" && (\n <input\n data-test={testIdentity(`${name}-uploaded`)}\n name={fieldName}\n type=\"hidden\"\n value={item.key}\n />\n )}\n </li>\n ))}\n </ul>\n\n {!scope &&\n removedTokens.map((token) => (\n <input key={token} name={`${name}__removed[]`} type=\"hidden\" value={token} />\n ))}\n\n <input\n accept={props.accept ?? undefined}\n aria-label={props.label ?? name}\n className=\"sr-only\"\n data-test={testIdentity(`${name}-input`)}\n id={inputId}\n multiple={multiple}\n name={signed ? undefined : fieldName}\n onChange={(event) => {\n addFiles(event.target.files);\n if (signed) {\n event.target.value = \"\";\n }\n }}\n ref={fileInputRef}\n type=\"file\"\n />\n </div>\n </FormFieldFrame>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,SAAS,kBAAkB,SAAkB,MAAkC;CAC7E,IAAI,MAAM,QAAQ,IAAI,GACpB,OACE,MAAM,QAAQ,OAAO,KACrB,QAAQ,WAAW,KAAK,UACxB,QAAQ,OAAO,OAAO,UAAU,UAAU,KAAK,MAAM;CAIzD,OAAO,YAAY;AACrB;AAEA,IAAa,uBAA+D,EAAE,WAAW;CACvF,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,MAAM,QAAQ,KAAK;CACnB,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,kBAAkB,IAAI;CACvE,MAA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AAM,OAAO,QAAQ;KAEzB;KACA,KAAK;KACL,MAAK;IACN,CAAA;GACE;;CACS,CAAA;AAEpB"}
@@ -14,7 +14,7 @@ var NumberInputComponent = ({ node }) => {
14
14
  className: "flex items-center gap-3",
15
15
  children: [/* @__PURE__ */ jsx("input", {
16
16
  "aria-label": props.label ?? "",
17
- className: "h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:opacity-50",
17
+ className: "h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:accent-lt-disabled",
18
18
  "data-test": testId,
19
19
  disabled: disabled || readOnly,
20
20
  id: name,
@@ -1 +1 @@
1
- {"version":3,"file":"number-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/number-input.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { AffixGroup } from \"@lattice-php/lattice/ui/affix-group\";\nimport { Input } from \"@lattice-php/lattice/ui/input\";\nimport { SimpleField } from \"./simple-field\";\n\nexport const NumberInputComponent: RendererComponent<\"field.number-input\"> = ({ node }) => {\n const props = node.props;\n\n return (\n <SimpleField node={node} label={props.label ?? \"\"}>\n {({ name, testId, value, readOnly, disabled, commit }) => {\n const onChange = (event: React.ChangeEvent<HTMLInputElement>): void =>\n commit(event.target.value);\n\n return props.slider ? (\n <div className=\"flex items-center gap-3\">\n <input\n aria-label={props.label ?? \"\"}\n className=\"h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:opacity-50\"\n data-test={testId}\n disabled={disabled || readOnly}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"range\"\n value={value}\n />\n <output className=\"w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg\">\n {value}\n </output>\n </div>\n ) : (\n <AffixGroup prefix={props.prefix} suffix={props.suffix}>\n {(controlClassName) => (\n <Input\n autoFocus={props.autoFocus ?? false}\n className={controlClassName}\n data-test={testId}\n disabled={disabled}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n placeholder={props.placeholder ?? \"\"}\n readOnly={readOnly}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"number\"\n value={value}\n />\n )}\n </AffixGroup>\n );\n }}\n </SimpleField>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,wBAAiE,EAAE,WAAW;CACzF,MAAM,QAAQ,KAAK;CAEnB,OACE,oBAAC,aAAD;EAAmB;EAAM,OAAO,MAAM,SAAS;aAC3C,EAAE,MAAM,QAAQ,OAAO,UAAU,UAAU,aAAa;GACxD,MAAM,YAAY,UAChB,OAAO,MAAM,OAAO,KAAK;GAE3B,OAAO,MAAM,SACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,SAAD;KACE,cAAY,MAAM,SAAS;KAC3B,WAAU;KACV,aAAW;KACX,UAAU,YAAY;KACtB,IAAI;KACJ,KAAK,MAAM,OAAO,KAAA;KAClB,KAAK,MAAM,OAAO,KAAA;KACZ;KACI;KACV,MAAM,MAAM,QAAQ,KAAA;KACpB,UAAU,MAAM,YAAY,KAAA;KAC5B,MAAK;KACE;IACR,CAAA,GACD,oBAAC,UAAD;KAAQ,WAAU;eACf;IACK,CAAA,CACL;QAEL,oBAAC,YAAD;IAAY,QAAQ,MAAM;IAAQ,QAAQ,MAAM;eAC5C,qBACA,oBAAC,OAAD;KACE,WAAW,MAAM,aAAa;KAC9B,WAAW;KACX,aAAW;KACD;KACV,IAAI;KACJ,KAAK,MAAM,OAAO,KAAA;KAClB,KAAK,MAAM,OAAO,KAAA;KACZ;KACI;KACV,aAAa,MAAM,eAAe;KACxB;KACV,MAAM,MAAM,QAAQ,KAAA;KACpB,UAAU,MAAM,YAAY,KAAA;KAC5B,MAAK;KACE;IACR,CAAA;GAEO,CAAA;EAEhB;CACW,CAAA;AAEjB"}
1
+ {"version":3,"file":"number-input.js","names":[],"sources":["../../../../resources/js/form/components/fields/number-input.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { AffixGroup } from \"@lattice-php/lattice/ui/affix-group\";\nimport { Input } from \"@lattice-php/lattice/ui/input\";\nimport { SimpleField } from \"./simple-field\";\n\nexport const NumberInputComponent: RendererComponent<\"field.number-input\"> = ({ node }) => {\n const props = node.props;\n\n return (\n <SimpleField node={node} label={props.label ?? \"\"}>\n {({ name, testId, value, readOnly, disabled, commit }) => {\n const onChange = (event: React.ChangeEvent<HTMLInputElement>): void =>\n commit(event.target.value);\n\n return props.slider ? (\n <div className=\"flex items-center gap-3\">\n <input\n aria-label={props.label ?? \"\"}\n className=\"h-2 w-full cursor-pointer appearance-none rounded-lt-sm bg-lt-muted accent-lt-primary disabled:cursor-not-allowed disabled:accent-lt-disabled\"\n data-test={testId}\n disabled={disabled || readOnly}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"range\"\n value={value}\n />\n <output className=\"w-10 shrink-0 text-right text-sm tabular-nums text-lt-fg\">\n {value}\n </output>\n </div>\n ) : (\n <AffixGroup prefix={props.prefix} suffix={props.suffix}>\n {(controlClassName) => (\n <Input\n autoFocus={props.autoFocus ?? false}\n className={controlClassName}\n data-test={testId}\n disabled={disabled}\n id={name}\n max={props.max ?? undefined}\n min={props.min ?? undefined}\n name={name}\n onChange={onChange}\n placeholder={props.placeholder ?? \"\"}\n readOnly={readOnly}\n step={props.step ?? undefined}\n tabIndex={props.tabIndex ?? undefined}\n type=\"number\"\n value={value}\n />\n )}\n </AffixGroup>\n );\n }}\n </SimpleField>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,wBAAiE,EAAE,WAAW;CACzF,MAAM,QAAQ,KAAK;CAEnB,OACE,oBAAC,aAAD;EAAmB;EAAM,OAAO,MAAM,SAAS;aAC3C,EAAE,MAAM,QAAQ,OAAO,UAAU,UAAU,aAAa;GACxD,MAAM,YAAY,UAChB,OAAO,MAAM,OAAO,KAAK;GAE3B,OAAO,MAAM,SACX,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,SAAD;KACE,cAAY,MAAM,SAAS;KAC3B,WAAU;KACV,aAAW;KACX,UAAU,YAAY;KACtB,IAAI;KACJ,KAAK,MAAM,OAAO,KAAA;KAClB,KAAK,MAAM,OAAO,KAAA;KACZ;KACI;KACV,MAAM,MAAM,QAAQ,KAAA;KACpB,UAAU,MAAM,YAAY,KAAA;KAC5B,MAAK;KACE;IACR,CAAA,GACD,oBAAC,UAAD;KAAQ,WAAU;eACf;IACK,CAAA,CACL;QAEL,oBAAC,YAAD;IAAY,QAAQ,MAAM;IAAQ,QAAQ,MAAM;eAC5C,qBACA,oBAAC,OAAD;KACE,WAAW,MAAM,aAAa;KAC9B,WAAW;KACX,aAAW;KACD;KACV,IAAI;KACJ,KAAK,MAAM,OAAO,KAAA;KAClB,KAAK,MAAM,OAAO,KAAA;KACZ;KACI;KACV,aAAa,MAAM,eAAe;KACxB;KACV,MAAM,MAAM,QAAQ,KAAA;KACpB,UAAU,MAAM,YAAY,KAAA;KAC5B,MAAK;KACE;IACR,CAAA;GAEO,CAAA;EAEhB;CACW,CAAA;AAEjB"}
@@ -83,7 +83,7 @@ var RichEditorField = ({ node }) => {
83
83
  name: domName,
84
84
  required,
85
85
  children: [/* @__PURE__ */ jsxs("div", {
86
- className: cn("overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[3px] focus-within:ring-lt-ring/50", locked && "opacity-60"),
86
+ className: cn("overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[length:var(--lt-ring-width)] focus-within:ring-lt-ring/50", locked && "opacity-60"),
87
87
  children: [editor && !locked && toolbar.length > 0 && /* @__PURE__ */ jsx(Toolbar, {
88
88
  editor,
89
89
  items: toolbar
@@ -1 +1 @@
1
- {"version":3,"file":"rich-editor-field.js","names":[],"sources":["../../../../resources/js/form/components/fields/rich-editor-field.tsx"],"sourcesContent":["import { Placeholder } from \"@tiptap/extensions\";\nimport { type Editor, EditorContent, useEditor } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { useEffect, useMemo } from \"react\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { FormFieldFrame } from \"@lattice-php/lattice/form/components/base/field\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\nimport { useFieldScope } from \"@lattice-php/lattice/form/hooks/field-scope\";\nimport { useDependentField } from \"@lattice-php/lattice/form/hooks/use-dependent-field\";\nimport { useFieldCommit } from \"@lattice-php/lattice/form/hooks/use-field-commit\";\nimport { useFormValue } from \"@lattice-php/lattice/form/hooks/values\";\nimport { registerBuiltinRichEditorExtensions } from \"@lattice-php/lattice/form/rich-editor/builtins\";\nimport {\n assembleStarterKitOptions,\n assembleTiptapExtensions,\n assembleToolbar,\n resolveRichEditorExtensions,\n type ToolbarEntry,\n} from \"@lattice-php/lattice/form/rich-editor/registry\";\nimport { ToolbarIconButton } from \"@lattice-php/lattice/form/rich-editor/toolbar-button\";\n\nregisterBuiltinRichEditorExtensions();\n\nfunction Toolbar({ editor, items }: { editor: Editor; items: ToolbarEntry[] }) {\n const { t } = useT(\"lattice\");\n\n return (\n <div className=\"flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1\">\n {items.map((item, index) => {\n if (item === \"separator\") {\n // eslint-disable-next-line react/no-array-index-key\n return <span key={`sep-${index}`} className=\"mx-1 h-5 w-px bg-lt-border\" />;\n }\n\n if (\"component\" in item) {\n const Control = item.component;\n\n return <Control editor={editor} key={item.key} />;\n }\n\n const label = t(`form.editor.${item.key}`, item.label);\n\n return (\n <ToolbarIconButton\n active={item.isActive(editor)}\n disabled={item.isDisabled?.(editor) ?? false}\n icon={item.icon}\n key={item.key}\n label={label}\n onClick={() => item.run(editor)}\n testId={`editor-${item.key}`}\n />\n );\n })}\n </div>\n );\n}\n\nconst RichEditorField: RendererComponent<\"field.rich-editor\"> = ({ node }) => {\n const { errors } = useFormContext();\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { change, blur } = useFieldCommit();\n const name = node.props.name;\n const scope = useFieldScope();\n const globalValue = useFormValue(name);\n const storedValue = scope ? scope.getValue(name) : globalValue;\n const domName = scope ? scope.scopedName(name) : name;\n const errorKey = scope ? scope.errorKey(name) : name;\n const locked = readOnly || disabled;\n const initialContent =\n typeof storedValue === \"object\" && storedValue !== null\n ? (storedValue as object)\n : ((node.props.value as object | undefined) ?? \"\");\n\n const resolved = useMemo(\n () => resolveRichEditorExtensions(node.props.extensions),\n [node.props.extensions],\n );\n const toolbar = useMemo(() => assembleToolbar(resolved), [resolved]);\n const extensions = useMemo(\n () => [\n StarterKit.configure(assembleStarterKitOptions(resolved)),\n Placeholder.configure({ placeholder: node.props.placeholder ?? \"\" }),\n ...assembleTiptapExtensions(resolved),\n ],\n [resolved, node.props.placeholder],\n );\n\n const editor = useEditor({\n extensions,\n content: initialContent,\n editable: !locked,\n immediatelyRender: false,\n // Tiptap v3 stops re-rendering per transaction by default, but the toolbar\n // reads isActive/isDisabled during render — without this, selection-only\n // transactions leave those states stale.\n shouldRerenderOnTransaction: true,\n editorProps: {\n attributes: {\n class: \"lattice-prose min-h-32 px-3 py-2 outline-none\",\n },\n },\n onUpdate: ({ editor: instance }) => {\n change(name, instance.isEmpty ? null : instance.getJSON());\n },\n onBlur: () => {\n blur(name);\n },\n });\n\n useEffect(() => {\n editor?.setEditable(!locked);\n }, [editor, locked]);\n\n if (hidden) {\n return null;\n }\n\n const submittedValue = storedValue ? JSON.stringify(storedValue) : \"\";\n\n return (\n <FormFieldFrame\n error={errors[errorKey]}\n helperText={node.props.helperText ?? undefined}\n tooltip={node.props.tooltip ?? undefined}\n label={node.props.label ?? \"\"}\n name={domName}\n required={required}\n >\n <div\n className={cn(\n \"overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[3px] focus-within:ring-lt-ring/50\",\n locked && \"opacity-60\",\n )}\n >\n {editor && !locked && toolbar.length > 0 && <Toolbar editor={editor} items={toolbar} />}\n <EditorContent editor={editor} />\n </div>\n <input name={domName} type=\"hidden\" value={submittedValue} />\n </FormFieldFrame>\n );\n};\n\nexport default RichEditorField;\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,oCAAoC;AAEpC,SAAS,QAAQ,EAAE,QAAQ,SAAoD;CAC7E,MAAM,EAAE,MAAM,KAAK,SAAS;CAE5B,OACE,oBAAC,OAAD;EAAK,WAAU;YACZ,MAAM,KAAK,MAAM,UAAU;GAC1B,IAAI,SAAS,aAEX,OAAO,oBAAC,QAAD,EAA2B,WAAU,6BAA8B,GAAxD,OAAO,OAAiD;GAG5E,IAAI,eAAe,MAAM;IACvB,MAAM,UAAU,KAAK;IAErB,OAAO,oBAAC,SAAD,EAAiB,OAAwB,GAAX,KAAK,GAAM;GAClD;GAEA,MAAM,QAAQ,EAAE,eAAe,KAAK,OAAO,KAAK,KAAK;GAErD,OACE,oBAAC,mBAAD;IACE,QAAQ,KAAK,SAAS,MAAM;IAC5B,UAAU,KAAK,aAAa,MAAM,KAAK;IACvC,MAAM,KAAK;IAEJ;IACP,eAAe,KAAK,IAAI,MAAM;IAC9B,QAAQ,UAAU,KAAK;GACxB,GAJM,KAAK,GAIX;EAEL,CAAC;CACE,CAAA;AAET;AAEA,IAAM,mBAA2D,EAAE,WAAW;CAC5E,MAAM,EAAE,WAAW,eAAe;CAClC,MAAM,EAAE,QAAQ,UAAU,UAAU,aAAa,kBAAkB,IAAI;CACvE,MAAM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AAW,KAAA;EAC/B,OAAO,KAAK,MAAM,SAAS;EAC3B,MAAM;EACI;YANZ,CAQE,qBAAC,OAAD;GACE,WAAW,GACT,qKACA,UAAU,YACZ;aAJF,CAMG,UAAU,CAAC,UAAU,QAAQ,SAAS,KAAK,oBAAC,SAAD;IAAiB;IAAQ,OAAO;GAAU,CAAA,GACtF,oBAAC,eAAD,EAAuB,OAAS,CAAA,CAC7B;MACL,oBAAC,SAAD;GAAO,MAAM;GAAS,MAAK;GAAS,OAAO;EAAiB,CAAA,CAC9C;;AAEpB"}
1
+ {"version":3,"file":"rich-editor-field.js","names":[],"sources":["../../../../resources/js/form/components/fields/rich-editor-field.tsx"],"sourcesContent":["import { Placeholder } from \"@tiptap/extensions\";\nimport { type Editor, EditorContent, useEditor } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { useEffect, useMemo } from \"react\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { FormFieldFrame } from \"@lattice-php/lattice/form/components/base/field\";\nimport { useFormContext } from \"@lattice-php/lattice/form/hooks/context\";\nimport { useFieldScope } from \"@lattice-php/lattice/form/hooks/field-scope\";\nimport { useDependentField } from \"@lattice-php/lattice/form/hooks/use-dependent-field\";\nimport { useFieldCommit } from \"@lattice-php/lattice/form/hooks/use-field-commit\";\nimport { useFormValue } from \"@lattice-php/lattice/form/hooks/values\";\nimport { registerBuiltinRichEditorExtensions } from \"@lattice-php/lattice/form/rich-editor/builtins\";\nimport {\n assembleStarterKitOptions,\n assembleTiptapExtensions,\n assembleToolbar,\n resolveRichEditorExtensions,\n type ToolbarEntry,\n} from \"@lattice-php/lattice/form/rich-editor/registry\";\nimport { ToolbarIconButton } from \"@lattice-php/lattice/form/rich-editor/toolbar-button\";\n\nregisterBuiltinRichEditorExtensions();\n\nfunction Toolbar({ editor, items }: { editor: Editor; items: ToolbarEntry[] }) {\n const { t } = useT(\"lattice\");\n\n return (\n <div className=\"flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1\">\n {items.map((item, index) => {\n if (item === \"separator\") {\n // eslint-disable-next-line react/no-array-index-key\n return <span key={`sep-${index}`} className=\"mx-1 h-5 w-px bg-lt-border\" />;\n }\n\n if (\"component\" in item) {\n const Control = item.component;\n\n return <Control editor={editor} key={item.key} />;\n }\n\n const label = t(`form.editor.${item.key}`, item.label);\n\n return (\n <ToolbarIconButton\n active={item.isActive(editor)}\n disabled={item.isDisabled?.(editor) ?? false}\n icon={item.icon}\n key={item.key}\n label={label}\n onClick={() => item.run(editor)}\n testId={`editor-${item.key}`}\n />\n );\n })}\n </div>\n );\n}\n\nconst RichEditorField: RendererComponent<\"field.rich-editor\"> = ({ node }) => {\n const { errors } = useFormContext();\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { change, blur } = useFieldCommit();\n const name = node.props.name;\n const scope = useFieldScope();\n const globalValue = useFormValue(name);\n const storedValue = scope ? scope.getValue(name) : globalValue;\n const domName = scope ? scope.scopedName(name) : name;\n const errorKey = scope ? scope.errorKey(name) : name;\n const locked = readOnly || disabled;\n const initialContent =\n typeof storedValue === \"object\" && storedValue !== null\n ? (storedValue as object)\n : ((node.props.value as object | undefined) ?? \"\");\n\n const resolved = useMemo(\n () => resolveRichEditorExtensions(node.props.extensions),\n [node.props.extensions],\n );\n const toolbar = useMemo(() => assembleToolbar(resolved), [resolved]);\n const extensions = useMemo(\n () => [\n StarterKit.configure(assembleStarterKitOptions(resolved)),\n Placeholder.configure({ placeholder: node.props.placeholder ?? \"\" }),\n ...assembleTiptapExtensions(resolved),\n ],\n [resolved, node.props.placeholder],\n );\n\n const editor = useEditor({\n extensions,\n content: initialContent,\n editable: !locked,\n immediatelyRender: false,\n // Tiptap v3 stops re-rendering per transaction by default, but the toolbar\n // reads isActive/isDisabled during render — without this, selection-only\n // transactions leave those states stale.\n shouldRerenderOnTransaction: true,\n editorProps: {\n attributes: {\n class: \"lattice-prose min-h-32 px-3 py-2 outline-none\",\n },\n },\n onUpdate: ({ editor: instance }) => {\n change(name, instance.isEmpty ? null : instance.getJSON());\n },\n onBlur: () => {\n blur(name);\n },\n });\n\n useEffect(() => {\n editor?.setEditable(!locked);\n }, [editor, locked]);\n\n if (hidden) {\n return null;\n }\n\n const submittedValue = storedValue ? JSON.stringify(storedValue) : \"\";\n\n return (\n <FormFieldFrame\n error={errors[errorKey]}\n helperText={node.props.helperText ?? undefined}\n tooltip={node.props.tooltip ?? undefined}\n label={node.props.label ?? \"\"}\n name={domName}\n required={required}\n >\n <div\n className={cn(\n \"overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[length:var(--lt-ring-width)] focus-within:ring-lt-ring/50\",\n locked && \"opacity-60\",\n )}\n >\n {editor && !locked && toolbar.length > 0 && <Toolbar editor={editor} items={toolbar} />}\n <EditorContent editor={editor} />\n </div>\n <input name={domName} type=\"hidden\" value={submittedValue} />\n </FormFieldFrame>\n );\n};\n\nexport default RichEditorField;\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,oCAAoC;AAEpC,SAAS,QAAQ,EAAE,QAAQ,SAAoD;CAC7E,MAAM,EAAE,MAAM,KAAK,SAAS;CAE5B,OACE,oBAAC,OAAD;EAAK,WAAU;YACZ,MAAM,KAAK,MAAM,UAAU;GAC1B,IAAI,SAAS,aAEX,OAAO,oBAAC,QAAD,EAA2B,WAAU,6BAA8B,GAAxD,OAAO,OAAiD;GAG5E,IAAI,eAAe,MAAM;IACvB,MAAM,UAAU,KAAK;IAErB,OAAO,oBAAC,SAAD,EAAiB,OAAwB,GAAX,KAAK,GAAM;GAClD;GAEA,MAAM,QAAQ,EAAE,eAAe,KAAK,OAAO,KAAK,KAAK;GAErD,OACE,oBAAC,mBAAD;IACE,QAAQ,KAAK,SAAS,MAAM;IAC5B,UAAU,KAAK,aAAa,MAAM,KAAK;IACvC,MAAM,KAAK;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EACd,QAAQ,YAAY,CAAC,MAAM;CAC7B,GAAG,CAAC,QAAQ,MAAM,CAAC;CAEnB,IAAI,QACF,OAAO;CAGT,MAAM,iBAAiB,cAAc,KAAK,UAAU,WAAW,IAAI;CAEnE,OACE,qBAAC,gBAAD;EACE,OAAO,OAAO;EACd,YAAY,KAAK,MAAM,cAAc,KAAA;EACrC,SAAS,KAAK,MAAM,WAAW,KAAA;EAC/B,OAAO,KAAK,MAAM,SAAS;EAC3B,MAAM;EACI;YANZ,CAQE,qBAAC,OAAD;GACE,WAAW,GACT,6LACA,UAAU,YACZ;aAJF,CAMG,UAAU,CAAC,UAAU,QAAQ,SAAS,KAAK,oBAAC,SAAD;IAAiB;IAAQ,OAAO;GAAU,CAAA,GACtF,oBAAC,eAAD,EAAuB,OAAS,CAAA,CAC7B;MACL,oBAAC,SAAD;GAAO,MAAM;GAAS,MAAK;GAAS,OAAO;EAAiB,CAAA,CAC9C;;AAEpB"}
@@ -28,7 +28,7 @@ function defaultActions(removable) {
28
28
  key: "remove",
29
29
  label: null,
30
30
  icon: null,
31
- destructive: true
31
+ danger: true
32
32
  }];
33
33
  }
34
34
  function toClientAction(action, ctx) {
@@ -38,7 +38,7 @@ function toClientAction(action, ctx) {
38
38
  key: action.key,
39
39
  label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),
40
40
  icon: action.icon ?? builtIn.icon,
41
- destructive: action.destructive,
41
+ danger: action.danger,
42
42
  onClick: () => ctx.onDuplicate(ctx.index)
43
43
  };
44
44
  }
@@ -49,7 +49,7 @@ function toClientAction(action, ctx) {
49
49
  key: action.key,
50
50
  label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),
51
51
  icon: action.icon ?? builtIn.icon,
52
- destructive: action.destructive,
52
+ danger: action.danger,
53
53
  onClick: () => ctx.onRemove(ctx.index)
54
54
  };
55
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"row-action-menu.js","names":[],"sources":["../../../../resources/js/form/components/fields/row-action-menu.ts"],"sourcesContent":["import type { RowAction as WireRowAction } from \"@lattice-php/lattice/types/generated\";\nimport type { RowAction } from \"./row-actions\";\n\ntype RowActionTranslate = (key: string, fallback: string) => string;\n\n/** Translation key + fallback and icon for each built-in; the server sends null labels. */\nconst BUILT_IN: Record<\"duplicate\" | \"remove\", { key: string; fallback: string; icon: string }> = {\n duplicate: { key: \"table.row-actions.duplicate\", fallback: \"Duplicate\", icon: \"copy\" },\n remove: { key: \"table.row-actions.remove\", fallback: \"Remove\", icon: \"trash-2\" },\n};\n\nexport type RowActionContext = {\n index: number;\n removable: boolean;\n onRemove: (index: number) => void;\n onDuplicate: (index: number) => void;\n t: RowActionTranslate;\n};\n\n/**\n * Resolves the declared wire row actions into the click-wired client actions the\n * kebab renders. `null` (undeclared) falls back to the built-in remove; an empty\n * array disables row actions entirely. Remove is dropped while the row is at its\n * minimum, and built-in labels resolve through i18n when the server sends none.\n */\nexport function buildRowActions(\n declared: WireRowAction[] | null,\n ctx: RowActionContext,\n): RowAction[] {\n const source = declared ?? defaultActions(ctx.removable);\n\n return source\n .map((action) => toClientAction(action, ctx))\n .filter((action): action is RowAction => action !== null);\n}\n\nfunction defaultActions(removable: boolean): WireRowAction[] {\n if (!removable) {\n return [];\n }\n\n return [{ type: \"remove\", key: \"remove\", label: null, icon: null, destructive: true }];\n}\n\nfunction toClientAction(action: WireRowAction, ctx: RowActionContext): RowAction | null {\n if (action.type === \"duplicate\") {\n const builtIn = BUILT_IN.duplicate;\n\n return {\n key: action.key,\n label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),\n icon: action.icon ?? builtIn.icon,\n destructive: action.destructive,\n onClick: () => ctx.onDuplicate(ctx.index),\n };\n }\n\n if (action.type === \"remove\") {\n if (!ctx.removable) {\n return null;\n }\n\n const builtIn = BUILT_IN.remove;\n\n return {\n key: action.key,\n label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),\n icon: action.icon ?? builtIn.icon,\n destructive: action.destructive,\n onClick: () => ctx.onRemove(ctx.index),\n };\n }\n\n return null;\n}\n"],"mappings":";;AAMA,IAAM,WAA4F;CAChG,WAAW;EAAE,KAAK;EAA+B,UAAU;EAAa,MAAM;CAAO;CACrF,QAAQ;EAAE,KAAK;EAA4B,UAAU;EAAU,MAAM;CAAU;AACjF;;;;;;;AAgBA,SAAgB,gBACd,UACA,KACa;CAGb,QAFe,YAAY,eAAe,IAAI,SAAS,GAGpD,KAAK,WAAW,eAAe,QAAQ,GAAG,CAAC,EAC3C,QAAQ,WAAgC,WAAW,IAAI;AAC5D;AAEA,SAAS,eAAe,WAAqC;CAC3D,IAAI,CAAC,WACH,OAAO,CAAC;CAGV,OAAO,CAAC;EAAE,MAAM;EAAU,KAAK;EAAU,OAAO;EAAM,MAAM;EAAM,aAAa;CAAK,CAAC;AACvF;AAEA,SAAS,eAAe,QAAuB,KAAyC;CACtF,IAAI,OAAO,SAAS,aAAa;EAC/B,MAAM,UAAU,SAAS;EAEzB,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,KAAK,QAAQ,QAAQ;GAC1D,MAAM,OAAO,QAAQ,QAAQ;GAC7B,aAAa,OAAO;GACpB,eAAe,IAAI,YAAY,IAAI,KAAK;EAC1C;CACF;CAEA,IAAI,OAAO,SAAS,UAAU;EAC5B,IAAI,CAAC,IAAI,WACP,OAAO;EAGT,MAAM,UAAU,SAAS;EAEzB,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,KAAK,QAAQ,QAAQ;GAC1D,MAAM,OAAO,QAAQ,QAAQ;GAC7B,aAAa,OAAO;GACpB,eAAe,IAAI,SAAS,IAAI,KAAK;EACvC;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"row-action-menu.js","names":[],"sources":["../../../../resources/js/form/components/fields/row-action-menu.ts"],"sourcesContent":["import type { RowAction as WireRowAction } from \"@lattice-php/lattice/types/generated\";\nimport type { RowAction } from \"./row-actions\";\n\ntype RowActionTranslate = (key: string, fallback: string) => string;\n\n/** Translation key + fallback and icon for each built-in; the server sends null labels. */\nconst BUILT_IN: Record<\"duplicate\" | \"remove\", { key: string; fallback: string; icon: string }> = {\n duplicate: { key: \"table.row-actions.duplicate\", fallback: \"Duplicate\", icon: \"copy\" },\n remove: { key: \"table.row-actions.remove\", fallback: \"Remove\", icon: \"trash-2\" },\n};\n\nexport type RowActionContext = {\n index: number;\n removable: boolean;\n onRemove: (index: number) => void;\n onDuplicate: (index: number) => void;\n t: RowActionTranslate;\n};\n\n/**\n * Resolves the declared wire row actions into the click-wired client actions the\n * kebab renders. `null` (undeclared) falls back to the built-in remove; an empty\n * array disables row actions entirely. Remove is dropped while the row is at its\n * minimum, and built-in labels resolve through i18n when the server sends none.\n */\nexport function buildRowActions(\n declared: WireRowAction[] | null,\n ctx: RowActionContext,\n): RowAction[] {\n const source = declared ?? defaultActions(ctx.removable);\n\n return source\n .map((action) => toClientAction(action, ctx))\n .filter((action): action is RowAction => action !== null);\n}\n\nfunction defaultActions(removable: boolean): WireRowAction[] {\n if (!removable) {\n return [];\n }\n\n return [{ type: \"remove\", key: \"remove\", label: null, icon: null, danger: true }];\n}\n\nfunction toClientAction(action: WireRowAction, ctx: RowActionContext): RowAction | null {\n if (action.type === \"duplicate\") {\n const builtIn = BUILT_IN.duplicate;\n\n return {\n key: action.key,\n label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),\n icon: action.icon ?? builtIn.icon,\n danger: action.danger,\n onClick: () => ctx.onDuplicate(ctx.index),\n };\n }\n\n if (action.type === \"remove\") {\n if (!ctx.removable) {\n return null;\n }\n\n const builtIn = BUILT_IN.remove;\n\n return {\n key: action.key,\n label: action.label ?? ctx.t(builtIn.key, builtIn.fallback),\n icon: action.icon ?? builtIn.icon,\n danger: action.danger,\n onClick: () => ctx.onRemove(ctx.index),\n };\n }\n\n return null;\n}\n"],"mappings":";;AAMA,IAAM,WAA4F;CAChG,WAAW;EAAE,KAAK;EAA+B,UAAU;EAAa,MAAM;CAAO;CACrF,QAAQ;EAAE,KAAK;EAA4B,UAAU;EAAU,MAAM;CAAU;AACjF;;;;;;;AAgBA,SAAgB,gBACd,UACA,KACa;CAGb,QAFe,YAAY,eAAe,IAAI,SAAS,GAGpD,KAAK,WAAW,eAAe,QAAQ,GAAG,CAAC,EAC3C,QAAQ,WAAgC,WAAW,IAAI;AAC5D;AAEA,SAAS,eAAe,WAAqC;CAC3D,IAAI,CAAC,WACH,OAAO,CAAC;CAGV,OAAO,CAAC;EAAE,MAAM;EAAU,KAAK;EAAU,OAAO;EAAM,MAAM;EAAM,QAAQ;CAAK,CAAC;AAClF;AAEA,SAAS,eAAe,QAAuB,KAAyC;CACtF,IAAI,OAAO,SAAS,aAAa;EAC/B,MAAM,UAAU,SAAS;EAEzB,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,KAAK,QAAQ,QAAQ;GAC1D,MAAM,OAAO,QAAQ,QAAQ;GAC7B,QAAQ,OAAO;GACf,eAAe,IAAI,YAAY,IAAI,KAAK;EAC1C;CACF;CAEA,IAAI,OAAO,SAAS,UAAU;EAC5B,IAAI,CAAC,IAAI,WACP,OAAO;EAGT,MAAM,UAAU,SAAS;EAEzB,OAAO;GACL,KAAK,OAAO;GACZ,OAAO,OAAO,SAAS,IAAI,EAAE,QAAQ,KAAK,QAAQ,QAAQ;GAC1D,MAAM,OAAO,QAAQ,QAAQ;GAC7B,QAAQ,OAAO;GACf,eAAe,IAAI,SAAS,IAAI,KAAK;EACvC;CACF;CAEA,OAAO;AACT"}
@@ -3,7 +3,7 @@ export type RowAction = {
3
3
  label: string;
4
4
  icon: string;
5
5
  onClick: () => void;
6
- destructive?: boolean;
6
+ danger?: boolean;
7
7
  };
8
8
  export declare function RowActions({ actions }: {
9
9
  actions: RowAction[];
@@ -3,8 +3,8 @@ import { Icon } from "../../../icons/sprite.js";
3
3
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../../ui/dropdown-menu.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region resources/js/form/components/fields/row-actions.tsx
6
- function inlineClass(destructive) {
7
- return destructive ? "text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm" : "text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm";
6
+ function inlineClass(danger) {
7
+ return danger ? "text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm" : "text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm";
8
8
  }
9
9
  function RowActions({ actions }) {
10
10
  const { t } = useT("lattice");
@@ -15,7 +15,7 @@ function RowActions({ actions }) {
15
15
  type: "button",
16
16
  "aria-label": action.label,
17
17
  "data-test": `row-action-${action.key}`,
18
- className: inlineClass(action.destructive),
18
+ className: inlineClass(action.danger),
19
19
  onClick: action.onClick,
20
20
  children: /* @__PURE__ */ jsx(Icon, { name: action.icon })
21
21
  });
@@ -34,7 +34,7 @@ function RowActions({ actions }) {
34
34
  className: "min-w-[10rem]",
35
35
  children: actions.map((action) => /* @__PURE__ */ jsx(DropdownMenuItem, {
36
36
  "data-test": `row-action-${action.key}`,
37
- destructive: action.destructive,
37
+ danger: action.danger,
38
38
  icon: action.icon,
39
39
  onClick: action.onClick,
40
40
  children: action.label
@@ -1 +1 @@
1
- {"version":3,"file":"row-actions.js","names":[],"sources":["../../../../resources/js/form/components/fields/row-actions.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/lattice/icons\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@lattice-php/lattice/ui/dropdown-menu\";\n\nexport type RowAction = {\n key: string;\n label: string;\n icon: string;\n onClick: () => void;\n destructive?: boolean;\n};\n\nfunction inlineClass(destructive?: boolean): string {\n return destructive\n ? \"text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm\"\n : \"text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm\";\n}\n\nexport function RowActions({ actions }: { actions: RowAction[] }) {\n const { t } = useT(\"lattice\");\n if (actions.length === 0) {\n return null;\n }\n\n if (actions.length === 1) {\n const action = actions[0];\n return (\n <button\n type=\"button\"\n aria-label={action.label}\n data-test={`row-action-${action.key}`}\n className={inlineClass(action.destructive)}\n onClick={action.onClick}\n >\n <Icon name={action.icon} />\n </button>\n );\n }\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label={t(\"common.action-group.label\", \"Actions\")}\n data-test=\"row-actions-menu\"\n className=\"text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm\"\n >\n <Icon name=\"more-horizontal\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-[10rem]\">\n {actions.map((action) => (\n <DropdownMenuItem\n key={action.key}\n data-test={`row-action-${action.key}`}\n destructive={action.destructive}\n icon={action.icon}\n onClick={action.onClick}\n >\n {action.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"mappings":";;;;;AAiBA,SAAS,YAAY,aAA+B;CAClD,OAAO,cACH,gEACA;AACN;AAEA,SAAgB,WAAW,EAAE,WAAqC;CAChE,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,IAAI,QAAQ,WAAW,GAAG;EACxB,MAAM,SAAS,QAAQ;EACvB,OACE,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,OAAO;GACnB,aAAW,cAAc,OAAO;GAChC,WAAW,YAAY,OAAO,WAAW;GACzC,SAAS,OAAO;aAEhB,oBAAC,MAAD,EAAM,MAAM,OAAO,KAAO,CAAA;EACpB,CAAA;CAEZ;CAEA,OACE,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,qBAAD;EAAqB,SAAA;YACnB,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,EAAE,6BAA6B,SAAS;GACpD,aAAU;GACV,WAAU;aAEV,oBAAC,MAAD,EAAM,MAAK,kBAAmB,CAAA;EACxB,CAAA;CACW,CAAA,GACrB,oBAAC,qBAAD;EAAqB,OAAM;EAAM,WAAU;YACxC,QAAQ,KAAK,WACZ,oBAAC,kBAAD;GAEE,aAAW,cAAc,OAAO;GAChC,aAAa,OAAO;GACpB,MAAM,OAAO;GACb,SAAS,OAAO;aAEf,OAAO;EACQ,GAPX,OAAO,GAOI,CACnB;CACkB,CAAA,CACT,EAAA,CAAA;AAElB"}
1
+ {"version":3,"file":"row-actions.js","names":[],"sources":["../../../../resources/js/form/components/fields/row-actions.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/lattice/icons\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from \"@lattice-php/lattice/ui/dropdown-menu\";\n\nexport type RowAction = {\n key: string;\n label: string;\n icon: string;\n onClick: () => void;\n danger?: boolean;\n};\n\nfunction inlineClass(danger?: boolean): string {\n return danger\n ? \"text-lt-danger hover:text-lt-danger [&_svg]:size-lt-icon-sm\"\n : \"text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm\";\n}\n\nexport function RowActions({ actions }: { actions: RowAction[] }) {\n const { t } = useT(\"lattice\");\n if (actions.length === 0) {\n return null;\n }\n\n if (actions.length === 1) {\n const action = actions[0];\n return (\n <button\n type=\"button\"\n aria-label={action.label}\n data-test={`row-action-${action.key}`}\n className={inlineClass(action.danger)}\n onClick={action.onClick}\n >\n <Icon name={action.icon} />\n </button>\n );\n }\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label={t(\"common.action-group.label\", \"Actions\")}\n data-test=\"row-actions-menu\"\n className=\"text-lt-muted-fg hover:text-lt-fg [&_svg]:size-lt-icon-sm\"\n >\n <Icon name=\"more-horizontal\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-[10rem]\">\n {actions.map((action) => (\n <DropdownMenuItem\n key={action.key}\n data-test={`row-action-${action.key}`}\n danger={action.danger}\n icon={action.icon}\n onClick={action.onClick}\n >\n {action.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n"],"mappings":";;;;;AAiBA,SAAS,YAAY,QAA0B;CAC7C,OAAO,SACH,gEACA;AACN;AAEA,SAAgB,WAAW,EAAE,WAAqC;CAChE,MAAM,EAAE,MAAM,KAAK,SAAS;CAC5B,IAAI,QAAQ,WAAW,GACrB,OAAO;CAGT,IAAI,QAAQ,WAAW,GAAG;EACxB,MAAM,SAAS,QAAQ;EACvB,OACE,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,OAAO;GACnB,aAAW,cAAc,OAAO;GAChC,WAAW,YAAY,OAAO,MAAM;GACpC,SAAS,OAAO;aAEhB,oBAAC,MAAD,EAAM,MAAM,OAAO,KAAO,CAAA;EACpB,CAAA;CAEZ;CAEA,OACE,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,qBAAD;EAAqB,SAAA;YACnB,oBAAC,UAAD;GACE,MAAK;GACL,cAAY,EAAE,6BAA6B,SAAS;GACpD,aAAU;GACV,WAAU;aAEV,oBAAC,MAAD,EAAM,MAAK,kBAAmB,CAAA;EACxB,CAAA;CACW,CAAA,GACrB,oBAAC,qBAAD;EAAqB,OAAM;EAAM,WAAU;YACxC,QAAQ,KAAK,WACZ,oBAAC,kBAAD;GAEE,aAAW,cAAc,OAAO;GAChC,QAAQ,OAAO;GACf,MAAM,OAAO;GACb,SAAS,OAAO;aAEf,OAAO;EACQ,GAPX,OAAO,GAOI,CACnB;CACkB,CAAA,CACT,EAAA,CAAA;AAElB"}
@@ -1,5 +1,5 @@
1
- import { useT } from "../../../i18n/instance.js";
2
1
  import { materializeSchema } from "../../../core/materialize.js";
2
+ import { useT } from "../../../i18n/instance.js";
3
3
  import { cn } from "../../../lib/utils.js";
4
4
  import { Icon } from "../../../icons/sprite.js";
5
5
  import { Renderer } from "../../../core/renderer.js";
@@ -81,8 +81,9 @@ var SelectComponent = ({ node }) => {
81
81
  }
82
82
  postFormAction(action, componentRef, {
83
83
  ...valuesRef.current,
84
- _search: searchKey,
85
- q: query
84
+ _sub: "search",
85
+ _target: searchKey,
86
+ _q: query
86
87
  }, controller.signal).then((response) => {
87
88
  setResults(response?.options ?? []);
88
89
  setLoading(false);