@lattice-php/lattice 0.3.0 → 0.4.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 (134) hide show
  1. package/dist/chat/components/chat-box.js +1 -1
  2. package/dist/chat/components/chat-box.js.map +1 -1
  3. package/dist/chat/components/message.js +1 -1
  4. package/dist/chat/components/message.js.map +1 -1
  5. package/dist/chat/transport.d.ts +2 -0
  6. package/dist/chat/transport.js +23 -3
  7. package/dist/chat/transport.js.map +1 -1
  8. package/dist/core/api.d.ts +14 -7
  9. package/dist/core/api.js +77 -1
  10. package/dist/core/api.js.map +1 -1
  11. package/dist/core/components/badge.js +3 -3
  12. package/dist/core/components/badge.js.map +1 -1
  13. package/dist/core/components/button.js +15 -15
  14. package/dist/core/components/button.js.map +1 -1
  15. package/dist/core/components/card.js +1 -1
  16. package/dist/core/components/card.js.map +1 -1
  17. package/dist/core/components/chart.js +1 -1
  18. package/dist/core/components/chart.js.map +1 -1
  19. package/dist/core/components/checkbox.js +1 -1
  20. package/dist/core/components/checkbox.js.map +1 -1
  21. package/dist/core/components/control.js +4 -4
  22. package/dist/core/components/control.js.map +1 -1
  23. package/dist/core/components/dialog.d.ts +1 -1
  24. package/dist/core/components/dialog.js +2 -1
  25. package/dist/core/components/dialog.js.map +1 -1
  26. package/dist/core/components/floating-panel.js +2 -2
  27. package/dist/core/components/floating-panel.js.map +1 -1
  28. package/dist/core/components/heading.js +1 -1
  29. package/dist/core/components/heading.js.map +1 -1
  30. package/dist/core/components/popover.d.ts +1 -1
  31. package/dist/core/components/popover.js +1 -1
  32. package/dist/core/components/popover.js.map +1 -1
  33. package/dist/core/components/section.js +2 -2
  34. package/dist/core/components/section.js.map +1 -1
  35. package/dist/core/components/segmented-pills.js +1 -1
  36. package/dist/core/components/segmented-pills.js.map +1 -1
  37. package/dist/core/components/stack.js +7 -1
  38. package/dist/core/components/stack.js.map +1 -1
  39. package/dist/core/components/tabs.js +1 -1
  40. package/dist/core/components/tabs.js.map +1 -1
  41. package/dist/core/types.d.ts +3 -1
  42. package/dist/form/components/base/affix-group.d.ts +17 -0
  43. package/dist/form/components/base/affix-group.js +49 -0
  44. package/dist/form/components/base/affix-group.js.map +1 -0
  45. package/dist/form/components/base/label.js +1 -1
  46. package/dist/form/components/base/label.js.map +1 -1
  47. package/dist/form/components/base/submit-button.js +1 -1
  48. package/dist/form/components/base/submit-button.js.map +1 -1
  49. package/dist/form/components/base/textarea.js +1 -1
  50. package/dist/form/components/base/textarea.js.map +1 -1
  51. package/dist/form/components/fields/file-upload.js +34 -2
  52. package/dist/form/components/fields/file-upload.js.map +1 -1
  53. package/dist/form/components/fields/number-input.js +21 -15
  54. package/dist/form/components/fields/number-input.js.map +1 -1
  55. package/dist/form/components/fields/password-input.js +21 -15
  56. package/dist/form/components/fields/password-input.js.map +1 -1
  57. package/dist/form/components/fields/rich-editor.js +2 -2
  58. package/dist/form/components/fields/rich-editor.js.map +1 -1
  59. package/dist/form/components/fields/text-input.js +19 -13
  60. package/dist/form/components/fields/text-input.js.map +1 -1
  61. package/dist/form/components/form.js +1 -1
  62. package/dist/form/components/form.js.map +1 -1
  63. package/dist/form/skeleton.js +1 -1
  64. package/dist/form/skeleton.js.map +1 -1
  65. package/dist/i18n/translatable.d.ts +4 -0
  66. package/dist/i18n/translatable.js +24 -0
  67. package/dist/i18n/translatable.js.map +1 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +2 -1
  70. package/dist/lattice.css +99 -6
  71. package/dist/layout/callouts.js +1 -1
  72. package/dist/layout/callouts.js.map +1 -1
  73. package/dist/layout/components.js +3 -1
  74. package/dist/layout/components.js.map +1 -1
  75. package/dist/layout/dropdown.js +2 -1
  76. package/dist/layout/dropdown.js.map +1 -1
  77. package/dist/layout/menu-item.js +31 -10
  78. package/dist/layout/menu-item.js.map +1 -1
  79. package/dist/layout/sidebar.js +1 -1
  80. package/dist/layout/sidebar.js.map +1 -1
  81. package/dist/layout/topbar.d.ts +3 -0
  82. package/dist/layout/topbar.js +15 -0
  83. package/dist/layout/topbar.js.map +1 -0
  84. package/dist/page.js +15 -10
  85. package/dist/page.js.map +1 -1
  86. package/dist/realtime/build-effects.d.ts +4 -0
  87. package/dist/realtime/build-effects.js +23 -0
  88. package/dist/realtime/build-effects.js.map +1 -0
  89. package/dist/realtime/listeners.d.ts +8 -0
  90. package/dist/realtime/listeners.js +31 -0
  91. package/dist/realtime/listeners.js.map +1 -0
  92. package/dist/realtime/subscriptions.d.ts +4 -0
  93. package/dist/realtime/subscriptions.js +45 -0
  94. package/dist/realtime/subscriptions.js.map +1 -0
  95. package/dist/registry.js +2 -1
  96. package/dist/registry.js.map +1 -1
  97. package/dist/remote/components/chat-box.d.ts +3 -0
  98. package/dist/remote/components/chat-box.js +65 -0
  99. package/dist/remote/components/chat-box.js.map +1 -0
  100. package/dist/remote/components/data-list.d.ts +10 -0
  101. package/dist/remote/components/data-list.js +106 -0
  102. package/dist/remote/components/data-list.js.map +1 -0
  103. package/dist/remote/index.d.ts +1 -0
  104. package/dist/remote/index.js +15 -0
  105. package/dist/remote/index.js.map +1 -0
  106. package/dist/table/components/cells/text-cell.js +1 -1
  107. package/dist/table/components/cells/text-cell.js.map +1 -1
  108. package/dist/table/components/column-filter-control.d.ts +2 -1
  109. package/dist/table/components/column-filter-control.js +28 -19
  110. package/dist/table/components/column-filter-control.js.map +1 -1
  111. package/dist/table/components/column-header.js +2 -2
  112. package/dist/table/components/column-header.js.map +1 -1
  113. package/dist/table/components/filter-bar.d.ts +7 -6
  114. package/dist/table/components/filter-bar.js +51 -28
  115. package/dist/table/components/filter-bar.js.map +1 -1
  116. package/dist/table/components/filter-controls.js +2 -2
  117. package/dist/table/components/filter-controls.js.map +1 -1
  118. package/dist/table/components/filter-stack-bar.js +4 -3
  119. package/dist/table/components/filter-stack-bar.js.map +1 -1
  120. package/dist/table/components/filter-value-input.js +1 -1
  121. package/dist/table/components/filter-value-input.js.map +1 -1
  122. package/dist/table/components/sort-bar.js +1 -1
  123. package/dist/table/components/sort-bar.js.map +1 -1
  124. package/dist/table/components/table.js +25 -16
  125. package/dist/table/components/table.js.map +1 -1
  126. package/dist/table/use-table.d.ts +1 -0
  127. package/dist/table/use-table.js +4 -0
  128. package/dist/table/use-table.js.map +1 -1
  129. package/dist/toast/toast.js +5 -2
  130. package/dist/toast/toast.js.map +1 -1
  131. package/dist/toast/toaster.js +4 -3
  132. package/dist/toast/toaster.js.map +1 -1
  133. package/dist/types/generated.d.ts +88 -4
  134. package/package.json +20 -1
@@ -29,7 +29,7 @@ var FloatingPanelComponent = ({ children, node }) => {
29
29
  const [open, setOpen] = useState(false);
30
30
  if (trigger.length === 0) return /* @__PURE__ */ jsx("div", {
31
31
  "aria-label": label,
32
- className: "fixed z-50 max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-md",
32
+ className: "fixed z-50 max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-lt-md",
33
33
  "data-lattice-component": node.id,
34
34
  role: label ? "group" : void 0,
35
35
  style: placementStyle(placement, offset),
@@ -47,7 +47,7 @@ var FloatingPanelComponent = ({ children, node }) => {
47
47
  className: cn("flex w-fit gap-2", expandsUpward ? "flex-col-reverse" : "flex-col"),
48
48
  children: [/* @__PURE__ */ jsx("button", {
49
49
  "aria-expanded": open,
50
- className: cn("inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-md hover:bg-lt-muted", anchorsToStart ? "self-start" : "self-end"),
50
+ className: cn("inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-lt-md hover:bg-lt-muted", anchorsToStart ? "self-start" : "self-end"),
51
51
  "data-test": node.key ? `${node.key}-trigger` : void 0,
52
52
  onClick: () => setOpen((value) => !value),
53
53
  type: "button",
@@ -1 +1 @@
1
- {"version":3,"file":"floating-panel.js","names":[],"sources":["../../../resources/js/core/components/floating-panel.tsx"],"sourcesContent":["import { type CSSProperties, useState } from \"react\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { FloatingPlacement } from \"@lattice-php/lattice/types/generated\";\nimport { RenderNode } from \"@lattice-php/lattice/core/renderer\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction placementStyle(placement: FloatingPlacement, offset: number): CSSProperties {\n if (placement === \"top-start\") {\n return { left: offset, top: offset };\n }\n\n if (placement === \"top-end\") {\n return { right: offset, top: offset };\n }\n\n if (placement === \"bottom-start\") {\n return { bottom: offset, left: offset };\n }\n\n return { bottom: offset, right: offset };\n}\n\nconst FloatingPanelComponent: RendererComponent<\"floating-panel\"> = ({ children, node }) => {\n const label = node.props.label ?? undefined;\n const offset = Math.max(0, node.props.offset ?? 16);\n const placement = node.props.placement ?? \"bottom-end\";\n const trigger = node.props.trigger ?? [];\n const [open, setOpen] = useState(false);\n\n if (trigger.length === 0) {\n return (\n <div\n aria-label={label}\n className=\"fixed z-50 max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-md\"\n data-lattice-component={node.id}\n role={label ? \"group\" : undefined}\n style={placementStyle(placement, offset)}\n >\n {children}\n </div>\n );\n }\n\n const expandsUpward = placement === \"bottom-start\" || placement === \"bottom-end\";\n const anchorsToStart = placement === \"top-start\" || placement === \"bottom-start\";\n\n return (\n <div\n aria-label={label}\n className=\"fixed z-50 max-w-[calc(100vw-2rem)]\"\n data-lattice-component={node.id}\n role={label ? \"group\" : undefined}\n style={placementStyle(placement, offset)}\n >\n <div className={cn(\"flex w-fit gap-2\", expandsUpward ? \"flex-col-reverse\" : \"flex-col\")}>\n <button\n aria-expanded={open}\n className={cn(\n \"inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-md hover:bg-lt-muted\",\n anchorsToStart ? \"self-start\" : \"self-end\",\n )}\n data-test={node.key ? `${node.key}-trigger` : undefined}\n onClick={() => setOpen((value) => !value)}\n type=\"button\"\n >\n {trigger.map((triggerNode, index) => (\n <RenderNode\n key={triggerNode.key ?? `${triggerNode.type}-${index}`}\n node={triggerNode}\n />\n ))}\n </button>\n <div className={open ? \"block\" : \"hidden\"}>{children}</div>\n </div>\n </div>\n );\n};\n\nexport default FloatingPanelComponent;\n"],"mappings":";;;;;AAMA,SAAS,eAAe,WAA8B,QAA+B;CACnF,IAAI,cAAc,aAChB,OAAO;EAAE,MAAM;EAAQ,KAAK;CAAO;CAGrC,IAAI,cAAc,WAChB,OAAO;EAAE,OAAO;EAAQ,KAAK;CAAO;CAGtC,IAAI,cAAc,gBAChB,OAAO;EAAE,QAAQ;EAAQ,MAAM;CAAO;CAGxC,OAAO;EAAE,QAAQ;EAAQ,OAAO;CAAO;AACzC;AAEA,IAAM,0BAA+D,EAAE,UAAU,WAAW;CAC1F,MAAM,QAAQ,KAAK,MAAM,SAAS,KAAA;CAClC,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,UAAU,EAAE;CAClD,MAAM,YAAY,KAAK,MAAM,aAAa;CAC1C,MAAM,UAAU,KAAK,MAAM,WAAW,CAAC;CACvC,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CAEtC,IAAI,QAAQ,WAAW,GACrB,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,0BAAwB,KAAK;EAC7B,MAAM,QAAQ,UAAU,KAAA;EACxB,OAAO,eAAe,WAAW,MAAM;EAEtC;CACE,CAAA;CAIT,MAAM,gBAAgB,cAAc,kBAAkB,cAAc;CACpE,MAAM,iBAAiB,cAAc,eAAe,cAAc;CAElE,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,0BAAwB,KAAK;EAC7B,MAAM,QAAQ,UAAU,KAAA;EACxB,OAAO,eAAe,WAAW,MAAM;YAEvC,qBAAC,OAAD;GAAK,WAAW,GAAG,oBAAoB,gBAAgB,qBAAqB,UAAU;aAAtF,CACE,oBAAC,UAAD;IACE,iBAAe;IACf,WAAW,GACT,kKACA,iBAAiB,eAAe,UAClC;IACA,aAAW,KAAK,MAAM,GAAG,KAAK,IAAI,YAAY,KAAA;IAC9C,eAAe,SAAS,UAAU,CAAC,KAAK;IACxC,MAAK;cAEJ,QAAQ,KAAK,aAAa,UACzB,oBAAC,YAAD,EAEE,MAAM,YACP,GAFM,YAAY,OAAO,GAAG,YAAY,KAAK,GAAG,OAEhD,CACF;GACK,CAAA,GACR,oBAAC,OAAD;IAAK,WAAW,OAAO,UAAU;IAAW;GAAc,CAAA,CACvD;;CACF,CAAA;AAET"}
1
+ {"version":3,"file":"floating-panel.js","names":[],"sources":["../../../resources/js/core/components/floating-panel.tsx"],"sourcesContent":["import { type CSSProperties, useState } from \"react\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { FloatingPlacement } from \"@lattice-php/lattice/types/generated\";\nimport { RenderNode } from \"@lattice-php/lattice/core/renderer\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction placementStyle(placement: FloatingPlacement, offset: number): CSSProperties {\n if (placement === \"top-start\") {\n return { left: offset, top: offset };\n }\n\n if (placement === \"top-end\") {\n return { right: offset, top: offset };\n }\n\n if (placement === \"bottom-start\") {\n return { bottom: offset, left: offset };\n }\n\n return { bottom: offset, right: offset };\n}\n\nconst FloatingPanelComponent: RendererComponent<\"floating-panel\"> = ({ children, node }) => {\n const label = node.props.label ?? undefined;\n const offset = Math.max(0, node.props.offset ?? 16);\n const placement = node.props.placement ?? \"bottom-end\";\n const trigger = node.props.trigger ?? [];\n const [open, setOpen] = useState(false);\n\n if (trigger.length === 0) {\n return (\n <div\n aria-label={label}\n className=\"fixed z-50 max-w-[calc(100vw-2rem)] rounded-lt border border-lt-border bg-lt-popover p-1 text-lt-popover-fg shadow-lt-md\"\n data-lattice-component={node.id}\n role={label ? \"group\" : undefined}\n style={placementStyle(placement, offset)}\n >\n {children}\n </div>\n );\n }\n\n const expandsUpward = placement === \"bottom-start\" || placement === \"bottom-end\";\n const anchorsToStart = placement === \"top-start\" || placement === \"bottom-start\";\n\n return (\n <div\n aria-label={label}\n className=\"fixed z-50 max-w-[calc(100vw-2rem)]\"\n data-lattice-component={node.id}\n role={label ? \"group\" : undefined}\n style={placementStyle(placement, offset)}\n >\n <div className={cn(\"flex w-fit gap-2\", expandsUpward ? \"flex-col-reverse\" : \"flex-col\")}>\n <button\n aria-expanded={open}\n className={cn(\n \"inline-flex items-center gap-2 rounded-lt border border-lt-border bg-lt-popover px-3 py-1.5 text-sm font-medium text-lt-popover-fg shadow-lt-md hover:bg-lt-muted\",\n anchorsToStart ? \"self-start\" : \"self-end\",\n )}\n data-test={node.key ? `${node.key}-trigger` : undefined}\n onClick={() => setOpen((value) => !value)}\n type=\"button\"\n >\n {trigger.map((triggerNode, index) => (\n <RenderNode\n key={triggerNode.key ?? `${triggerNode.type}-${index}`}\n node={triggerNode}\n />\n ))}\n </button>\n <div className={open ? \"block\" : \"hidden\"}>{children}</div>\n </div>\n </div>\n );\n};\n\nexport default FloatingPanelComponent;\n"],"mappings":";;;;;AAMA,SAAS,eAAe,WAA8B,QAA+B;CACnF,IAAI,cAAc,aAChB,OAAO;EAAE,MAAM;EAAQ,KAAK;CAAO;CAGrC,IAAI,cAAc,WAChB,OAAO;EAAE,OAAO;EAAQ,KAAK;CAAO;CAGtC,IAAI,cAAc,gBAChB,OAAO;EAAE,QAAQ;EAAQ,MAAM;CAAO;CAGxC,OAAO;EAAE,QAAQ;EAAQ,OAAO;CAAO;AACzC;AAEA,IAAM,0BAA+D,EAAE,UAAU,WAAW;CAC1F,MAAM,QAAQ,KAAK,MAAM,SAAS,KAAA;CAClC,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,UAAU,EAAE;CAClD,MAAM,YAAY,KAAK,MAAM,aAAa;CAC1C,MAAM,UAAU,KAAK,MAAM,WAAW,CAAC;CACvC,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CAEtC,IAAI,QAAQ,WAAW,GACrB,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,0BAAwB,KAAK;EAC7B,MAAM,QAAQ,UAAU,KAAA;EACxB,OAAO,eAAe,WAAW,MAAM;EAEtC;CACE,CAAA;CAIT,MAAM,gBAAgB,cAAc,kBAAkB,cAAc;CACpE,MAAM,iBAAiB,cAAc,eAAe,cAAc;CAElE,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,0BAAwB,KAAK;EAC7B,MAAM,QAAQ,UAAU,KAAA;EACxB,OAAO,eAAe,WAAW,MAAM;YAEvC,qBAAC,OAAD;GAAK,WAAW,GAAG,oBAAoB,gBAAgB,qBAAqB,UAAU;aAAtF,CACE,oBAAC,UAAD;IACE,iBAAe;IACf,WAAW,GACT,qKACA,iBAAiB,eAAe,UAClC;IACA,aAAW,KAAK,MAAM,GAAG,KAAK,IAAI,YAAY,KAAA;IAC9C,eAAe,SAAS,UAAU,CAAC,KAAK;IACxC,MAAK;cAEJ,QAAQ,KAAK,aAAa,UACzB,oBAAC,YAAD,EAEE,MAAM,YACP,GAFM,YAAY,OAAO,GAAG,YAAY,KAAK,GAAG,OAEhD,CACF;GACK,CAAA,GACR,oBAAC,OAAD;IAAK,WAAW,OAAO,UAAU;IAAW;GAAc,CAAA,CACvD;;CACF,CAAA;AAET"}
@@ -4,7 +4,7 @@ import { jsx } from "react/jsx-runtime";
4
4
  var HeadingComponent = ({ node }) => {
5
5
  const { text } = node.props;
6
6
  const level = Math.min(Math.max(node.props.level, 1), 6);
7
- const className = cn("max-w-3xl font-semibold tracking-normal text-balance text-lt-fg", level === 1 && "text-4xl leading-tight sm:text-5xl", level === 2 && "text-2xl", level > 2 && "text-lg");
7
+ const className = cn("max-w-3xl font-semibold tracking-normal text-balance text-lt-fg", level === 1 && "text-2xl font-bold leading-tight", level === 2 && "text-xl", level > 2 && "text-base");
8
8
  switch (level) {
9
9
  case 1: return /* @__PURE__ */ jsx("h1", {
10
10
  className,
@@ -1 +1 @@
1
- {"version":3,"file":"heading.js","names":[],"sources":["../../../resources/js/core/components/heading.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nconst HeadingComponent: RendererComponent<\"heading\"> = ({ node }) => {\n const { text } = node.props;\n const level = Math.min(Math.max(node.props.level, 1), 6);\n const className = cn(\n \"max-w-3xl font-semibold tracking-normal text-balance text-lt-fg\",\n level === 1 && \"text-4xl leading-tight sm:text-5xl\",\n level === 2 && \"text-2xl\",\n level > 2 && \"text-lg\",\n );\n\n switch (level) {\n case 1:\n return <h1 className={className}>{text}</h1>;\n case 2:\n return <h2 className={className}>{text}</h2>;\n case 3:\n return <h3 className={className}>{text}</h3>;\n case 4:\n return <h4 className={className}>{text}</h4>;\n case 5:\n return <h5 className={className}>{text}</h5>;\n default:\n return <h6 className={className}>{text}</h6>;\n }\n};\n\nexport default HeadingComponent;\n"],"mappings":";;;AAGA,IAAM,oBAAkD,EAAE,WAAW;CACnE,MAAM,EAAE,SAAS,KAAK;CACtB,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM,OAAO,CAAC,GAAG,CAAC;CACvD,MAAM,YAAY,GAChB,mEACA,UAAU,KAAK,sCACf,UAAU,KAAK,YACf,QAAQ,KAAK,SACf;CAEA,QAAQ,OAAR;EACE,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,SACE,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;CAC/C;AACF"}
1
+ {"version":3,"file":"heading.js","names":[],"sources":["../../../resources/js/core/components/heading.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nconst HeadingComponent: RendererComponent<\"heading\"> = ({ node }) => {\n const { text } = node.props;\n const level = Math.min(Math.max(node.props.level, 1), 6);\n const className = cn(\n \"max-w-3xl font-semibold tracking-normal text-balance text-lt-fg\",\n level === 1 && \"text-2xl font-bold leading-tight\",\n level === 2 && \"text-xl\",\n level > 2 && \"text-base\",\n );\n\n switch (level) {\n case 1:\n return <h1 className={className}>{text}</h1>;\n case 2:\n return <h2 className={className}>{text}</h2>;\n case 3:\n return <h3 className={className}>{text}</h3>;\n case 4:\n return <h4 className={className}>{text}</h4>;\n case 5:\n return <h5 className={className}>{text}</h5>;\n default:\n return <h6 className={className}>{text}</h6>;\n }\n};\n\nexport default HeadingComponent;\n"],"mappings":";;;AAGA,IAAM,oBAAkD,EAAE,WAAW;CACnE,MAAM,EAAE,SAAS,KAAK;CACtB,MAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM,OAAO,CAAC,GAAG,CAAC;CACvD,MAAM,YAAY,GAChB,mEACA,UAAU,KAAK,oCACf,UAAU,KAAK,WACf,QAAQ,KAAK,WACf;CAEA,QAAQ,OAAR;EACE,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,KAAK,GACH,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;EAC7C,SACE,OAAO,oBAAC,MAAD;GAAe;aAAY;EAAS,CAAA;CAC/C;AACF"}
@@ -1,6 +1,6 @@
1
1
  import * as PopoverPrimitive from "@radix-ui/react-popover";
2
2
  import * as React from "react";
3
- export declare const POPOVER_SURFACE = "z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-md";
3
+ export declare const POPOVER_SURFACE = "z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-lt-md";
4
4
  declare function Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>): React.JSX.Element;
5
5
  declare function PopoverTrigger(props: React.ComponentProps<typeof PopoverPrimitive.Trigger>): React.JSX.Element;
6
6
  declare function PopoverClose(props: React.ComponentProps<typeof PopoverPrimitive.Close>): React.JSX.Element;
@@ -3,7 +3,7 @@ import "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import * as PopoverPrimitive from "@radix-ui/react-popover";
5
5
  //#region resources/js/core/components/popover.tsx
6
- var POPOVER_SURFACE = "z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-md";
6
+ var POPOVER_SURFACE = "z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-lt-md";
7
7
  function Popover(props) {
8
8
  return /* @__PURE__ */ jsx(PopoverPrimitive.Root, {
9
9
  "data-slot": "popover",
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../resources/js/core/components/popover.tsx"],"sourcesContent":["import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nexport const POPOVER_SURFACE =\n \"z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-md\";\n\nfunction Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nfunction PopoverTrigger(props: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\n}\n\nfunction PopoverClose(props: React.ComponentProps<typeof PopoverPrimitive.Close>) {\n return <PopoverPrimitive.Close data-slot=\"popover-close\" {...props} />;\n}\n\nfunction PopoverContent({\n align = \"start\",\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n align={align}\n className={cn(POPOVER_SURFACE, className)}\n data-slot=\"popover-content\"\n sideOffset={sideOffset}\n {...props}\n />\n </PopoverPrimitive.Portal>\n );\n}\n\nexport { Popover, PopoverClose, PopoverContent, PopoverTrigger };\n"],"mappings":";;;;;AAIA,IAAa,kBACX;AAEF,SAAS,QAAQ,OAA2D;CAC1E,OAAO,oBAAC,iBAAiB,MAAlB;EAAuB,aAAU;EAAU,GAAI;CAAQ,CAAA;AAChE;AAEA,SAAS,eAAe,OAA8D;CACpF,OAAO,oBAAC,iBAAiB,SAAlB;EAA0B,aAAU;EAAkB,GAAI;CAAQ,CAAA;AAC3E;AAEA,SAAS,aAAa,OAA4D;CAChF,OAAO,oBAAC,iBAAiB,OAAlB;EAAwB,aAAU;EAAgB,GAAI;CAAQ,CAAA;AACvE;AAEA,SAAS,eAAe,EACtB,QAAQ,SACR,WACA,aAAa,GACb,GAAG,SACqD;CACxD,OACE,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,iBAAiB,SAAlB;EACS;EACP,WAAW,GAAG,iBAAiB,SAAS;EACxC,aAAU;EACE;EACZ,GAAI;CACL,CAAA,EACsB,CAAA;AAE7B"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../resources/js/core/components/popover.tsx"],"sourcesContent":["import * as PopoverPrimitive from \"@radix-ui/react-popover\";\nimport * as React from \"react\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nexport const POPOVER_SURFACE =\n \"z-50 rounded-lt-sm border border-lt-border bg-lt-popover text-lt-popover-fg shadow-lt-md\";\n\nfunction Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n return <PopoverPrimitive.Root data-slot=\"popover\" {...props} />;\n}\n\nfunction PopoverTrigger(props: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />;\n}\n\nfunction PopoverClose(props: React.ComponentProps<typeof PopoverPrimitive.Close>) {\n return <PopoverPrimitive.Close data-slot=\"popover-close\" {...props} />;\n}\n\nfunction PopoverContent({\n align = \"start\",\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof PopoverPrimitive.Content>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n align={align}\n className={cn(POPOVER_SURFACE, className)}\n data-slot=\"popover-content\"\n sideOffset={sideOffset}\n {...props}\n />\n </PopoverPrimitive.Portal>\n );\n}\n\nexport { Popover, PopoverClose, PopoverContent, PopoverTrigger };\n"],"mappings":";;;;;AAIA,IAAa,kBACX;AAEF,SAAS,QAAQ,OAA2D;CAC1E,OAAO,oBAAC,iBAAiB,MAAlB;EAAuB,aAAU;EAAU,GAAI;CAAQ,CAAA;AAChE;AAEA,SAAS,eAAe,OAA8D;CACpF,OAAO,oBAAC,iBAAiB,SAAlB;EAA0B,aAAU;EAAkB,GAAI;CAAQ,CAAA;AAC3E;AAEA,SAAS,aAAa,OAA4D;CAChF,OAAO,oBAAC,iBAAiB,OAAlB;EAAwB,aAAU;EAAgB,GAAI;CAAQ,CAAA;AACvE;AAEA,SAAS,eAAe,EACtB,QAAQ,SACR,WACA,aAAa,GACb,GAAG,SACqD;CACxD,OACE,oBAAC,iBAAiB,QAAlB,EAAA,UACE,oBAAC,iBAAiB,SAAlB;EACS;EACP,WAAW,GAAG,iBAAiB,SAAS;EACxC,aAAU;EACE;EACZ,GAAI;CACL,CAAA,EACsB,CAAA;AAE7B"}
@@ -32,7 +32,7 @@ var SectionComponent = ({ children, node }) => {
32
32
  const isCollapsed = collapsible && collapsed;
33
33
  const hasHeader = Boolean(title || description || headerActions.length > 0 || collapsible);
34
34
  return /* @__PURE__ */ jsxs("section", {
35
- className: "flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-6 text-lt-surface-fg shadow-xs",
35
+ className: "flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-6 text-lt-surface-fg shadow-lt-sm",
36
36
  "data-lattice-component": node.id,
37
37
  children: [hasHeader && /* @__PURE__ */ jsxs("div", {
38
38
  className: "flex items-start justify-between gap-4 px-6",
@@ -42,7 +42,7 @@ var SectionComponent = ({ children, node }) => {
42
42
  "aria-expanded": !isCollapsed,
43
43
  "aria-label": isCollapsed ? "Expand section" : "Collapse section",
44
44
  "data-test": prefixedTestId("section-toggle", identity) ?? "section-toggle-default",
45
- className: "mt-0.5 inline-flex shrink-0 items-center rounded-md p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg",
45
+ className: "mt-0.5 inline-flex shrink-0 items-center rounded-lt-sm p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg",
46
46
  onClick: toggle,
47
47
  type: "button",
48
48
  children: /* @__PURE__ */ jsx(Icon, {
@@ -1 +1 @@
1
- {"version":3,"file":"section.js","names":[],"sources":["../../../resources/js/core/components/section.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { Renderer } from \"@lattice-php/lattice/core/renderer\";\nimport { nodeIdentity, prefixedTestId } from \"@lattice-php/lattice/core/test-id\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction readStored(key: string, remember: boolean, fallback: boolean): boolean {\n if (!remember || typeof window === \"undefined\") {\n return fallback;\n }\n\n const stored = window.localStorage.getItem(key);\n\n return stored === null ? fallback : stored === \"true\";\n}\n\nfunction getNodes(value: unknown): Node[] {\n if (!Array.isArray(value)) {\n return [];\n }\n\n return value.filter(\n (node): node is Node =>\n typeof node === \"object\" && node !== null && \"type\" in node && typeof node.type === \"string\",\n );\n}\n\nconst SectionComponent: RendererComponent<\"section\"> = ({ children, node }) => {\n const { title, description } = node.props;\n const collapsible = node.props.collapsible === true;\n const rememberState = node.props.rememberState !== false;\n const headerActions = getNodes(node.props.headerActions);\n const identity = nodeIdentity(node);\n const storageKey = `lattice:section:${identity ?? \"default\"}`;\n\n const [collapsed, setCollapsed] = useState(() =>\n readStored(storageKey, collapsible && rememberState, node.props.collapsed === true),\n );\n\n function toggle(): void {\n setCollapsed((value) => {\n const next = !value;\n\n if (rememberState && typeof window !== \"undefined\") {\n window.localStorage.setItem(storageKey, String(next));\n }\n\n return next;\n });\n }\n\n const isCollapsed = collapsible && collapsed;\n const hasHeader = Boolean(title || description || headerActions.length > 0 || collapsible);\n\n return (\n <section\n className=\"flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-6 text-lt-surface-fg shadow-xs\"\n data-lattice-component={node.id}\n >\n {hasHeader && (\n <div className=\"flex items-start justify-between gap-4 px-6\">\n <div className=\"flex min-w-0 items-start gap-2\">\n {collapsible && (\n <button\n aria-expanded={!isCollapsed}\n aria-label={isCollapsed ? \"Expand section\" : \"Collapse section\"}\n data-test={prefixedTestId(\"section-toggle\", identity) ?? \"section-toggle-default\"}\n className=\"mt-0.5 inline-flex shrink-0 items-center rounded-md p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg\"\n onClick={toggle}\n type=\"button\"\n >\n <Icon\n name=\"chevron-down\"\n className={cn(\n \"size-lt-icon-md transition-transform\",\n isCollapsed && \"-rotate-90\",\n )}\n />\n </button>\n )}\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n {title && <div className=\"font-semibold leading-none\">{title}</div>}\n {description && <div className=\"text-sm text-lt-muted-fg\">{description}</div>}\n </div>\n </div>\n\n {headerActions.length > 0 && (\n <div className=\"flex shrink-0 items-center gap-2\">\n <Renderer nodes={headerActions} />\n </div>\n )}\n </div>\n )}\n\n {!isCollapsed && children && <div className=\"flex flex-col gap-6 px-6\">{children}</div>}\n </section>\n );\n};\n\nexport default SectionComponent;\n"],"mappings":";;;;;;;AAOA,SAAS,WAAW,KAAa,UAAmB,UAA4B;CAC9E,IAAI,CAAC,YAAY,OAAO,WAAW,aACjC,OAAO;CAGT,MAAM,SAAS,OAAO,aAAa,QAAQ,GAAG;CAE9C,OAAO,WAAW,OAAO,WAAW,WAAW;AACjD;AAEA,SAAS,SAAS,OAAwB;CACxC,IAAI,CAAC,MAAM,QAAQ,KAAK,GACtB,OAAO,CAAC;CAGV,OAAO,MAAM,QACV,SACC,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,OAAO,KAAK,SAAS,QACxF;AACF;AAEA,IAAM,oBAAkD,EAAE,UAAU,WAAW;CAC7E,MAAM,EAAE,OAAO,gBAAgB,KAAK;CACpC,MAAM,cAAc,KAAK,MAAM,gBAAgB;CAC/C,MAAM,gBAAgB,KAAK,MAAM,kBAAkB;CACnD,MAAM,gBAAgB,SAAS,KAAK,MAAM,aAAa;CACvD,MAAM,WAAW,aAAa,IAAI;CAClC,MAAM,aAAa,mBAAmB,YAAY;CAElD,MAAM,CAAC,WAAW,gBAAgB,eAChC,WAAW,YAAY,eAAe,eAAe,KAAK,MAAM,cAAc,IAAI,CACpF;CAEA,SAAS,SAAe;EACtB,cAAc,UAAU;GACtB,MAAM,OAAO,CAAC;GAEd,IAAI,iBAAiB,OAAO,WAAW,aACrC,OAAO,aAAa,QAAQ,YAAY,OAAO,IAAI,CAAC;GAGtD,OAAO;EACT,CAAC;CACH;CAEA,MAAM,cAAc,eAAe;CACnC,MAAM,YAAY,QAAQ,SAAS,eAAe,cAAc,SAAS,KAAK,WAAW;CAEzF,OACE,qBAAC,WAAD;EACE,WAAU;EACV,0BAAwB,KAAK;YAF/B,CAIG,aACC,qBAAC,OAAD;GAAK,WAAU;aAAf,CACE,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,eACC,oBAAC,UAAD;KACE,iBAAe,CAAC;KAChB,cAAY,cAAc,mBAAmB;KAC7C,aAAW,eAAe,kBAAkB,QAAQ,KAAK;KACzD,WAAU;KACV,SAAS;KACT,MAAK;eAEL,oBAAC,MAAD;MACE,MAAK;MACL,WAAW,GACT,wCACA,eAAe,YACjB;KACD,CAAA;IACK,CAAA,GAEV,qBAAC,OAAD;KAAK,WAAU;eAAf,CACG,SAAS,oBAAC,OAAD;MAAK,WAAU;gBAA8B;KAAW,CAAA,GACjE,eAAe,oBAAC,OAAD;MAAK,WAAU;gBAA4B;KAAiB,CAAA,CACzE;MACF;OAEJ,cAAc,SAAS,KACtB,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,UAAD,EAAU,OAAO,cAAgB,CAAA;GAC9B,CAAA,CAEJ;MAGN,CAAC,eAAe,YAAY,oBAAC,OAAD;GAAK,WAAU;GAA4B;EAAc,CAAA,CAC/E;;AAEb"}
1
+ {"version":3,"file":"section.js","names":[],"sources":["../../../resources/js/core/components/section.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Icon } from \"@lattice-php/lattice/icons\";\nimport { Renderer } from \"@lattice-php/lattice/core/renderer\";\nimport { nodeIdentity, prefixedTestId } from \"@lattice-php/lattice/core/test-id\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction readStored(key: string, remember: boolean, fallback: boolean): boolean {\n if (!remember || typeof window === \"undefined\") {\n return fallback;\n }\n\n const stored = window.localStorage.getItem(key);\n\n return stored === null ? fallback : stored === \"true\";\n}\n\nfunction getNodes(value: unknown): Node[] {\n if (!Array.isArray(value)) {\n return [];\n }\n\n return value.filter(\n (node): node is Node =>\n typeof node === \"object\" && node !== null && \"type\" in node && typeof node.type === \"string\",\n );\n}\n\nconst SectionComponent: RendererComponent<\"section\"> = ({ children, node }) => {\n const { title, description } = node.props;\n const collapsible = node.props.collapsible === true;\n const rememberState = node.props.rememberState !== false;\n const headerActions = getNodes(node.props.headerActions);\n const identity = nodeIdentity(node);\n const storageKey = `lattice:section:${identity ?? \"default\"}`;\n\n const [collapsed, setCollapsed] = useState(() =>\n readStored(storageKey, collapsible && rememberState, node.props.collapsed === true),\n );\n\n function toggle(): void {\n setCollapsed((value) => {\n const next = !value;\n\n if (rememberState && typeof window !== \"undefined\") {\n window.localStorage.setItem(storageKey, String(next));\n }\n\n return next;\n });\n }\n\n const isCollapsed = collapsible && collapsed;\n const hasHeader = Boolean(title || description || headerActions.length > 0 || collapsible);\n\n return (\n <section\n className=\"flex flex-col gap-6 rounded-lt border border-lt-border bg-lt-surface py-6 text-lt-surface-fg shadow-lt-sm\"\n data-lattice-component={node.id}\n >\n {hasHeader && (\n <div className=\"flex items-start justify-between gap-4 px-6\">\n <div className=\"flex min-w-0 items-start gap-2\">\n {collapsible && (\n <button\n aria-expanded={!isCollapsed}\n aria-label={isCollapsed ? \"Expand section\" : \"Collapse section\"}\n data-test={prefixedTestId(\"section-toggle\", identity) ?? \"section-toggle-default\"}\n className=\"mt-0.5 inline-flex shrink-0 items-center rounded-lt-sm p-0.5 text-lt-muted-fg transition-colors hover:bg-lt-muted hover:text-lt-fg\"\n onClick={toggle}\n type=\"button\"\n >\n <Icon\n name=\"chevron-down\"\n className={cn(\n \"size-lt-icon-md transition-transform\",\n isCollapsed && \"-rotate-90\",\n )}\n />\n </button>\n )}\n <div className=\"flex min-w-0 flex-col gap-1.5\">\n {title && <div className=\"font-semibold leading-none\">{title}</div>}\n {description && <div className=\"text-sm text-lt-muted-fg\">{description}</div>}\n </div>\n </div>\n\n {headerActions.length > 0 && (\n <div className=\"flex shrink-0 items-center gap-2\">\n <Renderer nodes={headerActions} />\n </div>\n )}\n </div>\n )}\n\n {!isCollapsed && children && <div className=\"flex flex-col gap-6 px-6\">{children}</div>}\n </section>\n );\n};\n\nexport default SectionComponent;\n"],"mappings":";;;;;;;AAOA,SAAS,WAAW,KAAa,UAAmB,UAA4B;CAC9E,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MAAK;MACL,WAAW,GACT,wCACA,eAAe,YACjB;KACD,CAAA;IACK,CAAA,GAEV,qBAAC,OAAD;KAAK,WAAU;eAAf,CACG,SAAS,oBAAC,OAAD;MAAK,WAAU;gBAA8B;KAAW,CAAA,GACjE,eAAe,oBAAC,OAAD;MAAK,WAAU;gBAA4B;KAAiB,CAAA,CACzE;MACF;OAEJ,cAAc,SAAS,KACtB,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,UAAD,EAAU,OAAO,cAAgB,CAAA;GAC9B,CAAA,CAEJ;MAGN,CAAC,eAAe,YAAY,oBAAC,OAAD;GAAK,WAAU;GAA4B;EAAc,CAAA,CAC/E;;AAEb"}
@@ -23,7 +23,7 @@ function SegmentedPills({ ariaLabel, autoFocus = false, disabled = false, name,
23
23
  return /* @__PURE__ */ jsx("button", {
24
24
  "aria-checked": isSelected,
25
25
  "data-test": `${name ?? "segment"}-${option.value}`,
26
- className: cn("whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors", isSelected ? "bg-lt-bg text-lt-fg shadow-xs" : "text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg", disabled && "cursor-not-allowed opacity-60"),
26
+ className: cn("whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors", isSelected ? "bg-lt-bg text-lt-fg shadow-lt-xs" : "text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg", disabled && "cursor-not-allowed opacity-60"),
27
27
  disabled,
28
28
  onClick: () => onSelect(option.value),
29
29
  role: "radio",
@@ -1 +1 @@
1
- {"version":3,"file":"segmented-pills.js","names":[],"sources":["../../../resources/js/core/components/segmented-pills.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { Option } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\n/**\n * Presentational segmented pill group. Used by the form choice field (bound to a\n * form value) and the core segmented control (standalone, emits an event).\n */\nexport function SegmentedPills({\n ariaLabel,\n autoFocus = false,\n disabled = false,\n name,\n onSelect,\n options,\n tabIndex,\n value,\n}: {\n ariaLabel?: string;\n autoFocus?: boolean;\n disabled?: boolean;\n name?: string;\n onSelect: (value: string) => void;\n options: Option[];\n tabIndex?: number;\n value: string;\n}) {\n const groupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!autoFocus) {\n return;\n }\n\n const group = groupRef.current;\n const target =\n group?.querySelector<HTMLButtonElement>('button[aria-checked=\"true\"]') ??\n group?.querySelector<HTMLButtonElement>(\"button\");\n\n target?.focus();\n }, [autoFocus]);\n\n return (\n <div\n aria-label={ariaLabel}\n className=\"inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1\"\n ref={groupRef}\n role=\"radiogroup\"\n >\n {options.map((option) => {\n const isSelected = value === option.value;\n\n return (\n <button\n aria-checked={isSelected}\n data-test={`${name ?? \"segment\"}-${option.value}`}\n className={cn(\n \"whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors\",\n isSelected\n ? \"bg-lt-bg text-lt-fg shadow-xs\"\n : \"text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n disabled={disabled}\n key={option.value}\n onClick={() => onSelect(option.value)}\n role=\"radio\"\n tabIndex={tabIndex}\n type=\"button\"\n >\n {option.label}\n </button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,eAAe,EAC7B,WACA,YAAY,OACZ,WAAW,OACX,MACA,UACA,SACA,UACA,SAUC;CACD,MAAM,WAAW,OAAuB,IAAI;CAE5C,gBAAgB;EACd,IAAI,CAAC,WACH;EAGF,MAAM,QAAQ,SAAS;EAKvB,CAHE,OAAO,cAAiC,+BAA6B,KACrE,OAAO,cAAiC,QAAQ,IAE1C,MAAM;CAChB,GAAG,CAAC,SAAS,CAAC;CAEd,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,KAAK;EACL,MAAK;YAEJ,QAAQ,KAAK,WAAW;GACvB,MAAM,aAAa,UAAU,OAAO;GAEpC,OACE,oBAAC,UAAD;IACE,gBAAc;IACd,aAAW,GAAG,QAAQ,UAAU,GAAG,OAAO;IAC1C,WAAW,GACT,qFACA,aACI,kCACA,uDACJ,YAAY,+BACd;IACU;IAEV,eAAe,SAAS,OAAO,KAAK;IACpC,MAAK;IACK;IACV,MAAK;cAEJ,OAAO;GACF,GAPD,OAAO,KAON;EAEZ,CAAC;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"segmented-pills.js","names":[],"sources":["../../../resources/js/core/components/segmented-pills.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport type { Option } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\n/**\n * Presentational segmented pill group. Used by the form choice field (bound to a\n * form value) and the core segmented control (standalone, emits an event).\n */\nexport function SegmentedPills({\n ariaLabel,\n autoFocus = false,\n disabled = false,\n name,\n onSelect,\n options,\n tabIndex,\n value,\n}: {\n ariaLabel?: string;\n autoFocus?: boolean;\n disabled?: boolean;\n name?: string;\n onSelect: (value: string) => void;\n options: Option[];\n tabIndex?: number;\n value: string;\n}) {\n const groupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!autoFocus) {\n return;\n }\n\n const group = groupRef.current;\n const target =\n group?.querySelector<HTMLButtonElement>('button[aria-checked=\"true\"]') ??\n group?.querySelector<HTMLButtonElement>(\"button\");\n\n target?.focus();\n }, [autoFocus]);\n\n return (\n <div\n aria-label={ariaLabel}\n className=\"inline-flex w-fit max-w-full gap-1 overflow-x-auto rounded-lt bg-lt-muted p-1\"\n ref={groupRef}\n role=\"radiogroup\"\n >\n {options.map((option) => {\n const isSelected = value === option.value;\n\n return (\n <button\n aria-checked={isSelected}\n data-test={`${name ?? \"segment\"}-${option.value}`}\n className={cn(\n \"whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors\",\n isSelected\n ? \"bg-lt-bg text-lt-fg shadow-lt-xs\"\n : \"text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg\",\n disabled && \"cursor-not-allowed opacity-60\",\n )}\n disabled={disabled}\n key={option.value}\n onClick={() => onSelect(option.value)}\n role=\"radio\"\n tabIndex={tabIndex}\n type=\"button\"\n >\n {option.label}\n </button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,eAAe,EAC7B,WACA,YAAY,OACZ,WAAW,OACX,MACA,UACA,SACA,UACA,SAUC;CACD,MAAM,WAAW,OAAuB,IAAI;CAE5C,gBAAgB;EACd,IAAI,CAAC,WACH;EAGF,MAAM,QAAQ,SAAS;EAKvB,CAHE,OAAO,cAAiC,+BAA6B,KACrE,OAAO,cAAiC,QAAQ,IAE1C,MAAM;CAChB,GAAG,CAAC,SAAS,CAAC;CAEd,OACE,oBAAC,OAAD;EACE,cAAY;EACZ,WAAU;EACV,KAAK;EACL,MAAK;YAEJ,QAAQ,KAAK,WAAW;GACvB,MAAM,aAAa,UAAU,OAAO;GAEpC,OACE,oBAAC,UAAD;IACE,gBAAc;IACd,aAAW,GAAG,QAAQ,UAAU,GAAG,OAAO;IAC1C,WAAW,GACT,qFACA,aACI,qCACA,uDACJ,YAAY,+BACd;IACU;IAEV,eAAe,SAAS,OAAO,KAAK;IACpC,MAAK;IACK;IACV,MAAK;cAEJ,OAAO;GACF,GAPD,OAAO,KAON;EAEZ,CAAC;CACE,CAAA;AAET"}
@@ -20,6 +20,7 @@ var stackGaps = {
20
20
  xl: "gap-8"
21
21
  };
22
22
  var stackWidths = {
23
+ auto: "w-auto",
23
24
  fill: "min-w-0 flex-1",
24
25
  full: "w-full",
25
26
  lg: "mx-auto w-full max-w-4xl",
@@ -38,6 +39,10 @@ var stackHeights = {
38
39
  full: "h-full",
39
40
  screen: "min-h-screen"
40
41
  };
42
+ var floatClasses = {
43
+ end: "ml-auto",
44
+ start: "mr-auto"
45
+ };
41
46
  var StackComponent = ({ children, node }) => {
42
47
  const align = node.props.align ?? "stretch";
43
48
  const direction = node.props.direction ?? "column";
@@ -45,10 +50,11 @@ var StackComponent = ({ children, node }) => {
45
50
  const width = node.props.width ?? "full";
46
51
  const justify = node.props.justify;
47
52
  const height = node.props.height;
53
+ const float = node.props.float;
48
54
  const isFlex = direction === "row" || justify != null;
49
55
  return /* @__PURE__ */ jsx("div", {
50
56
  "data-lattice-component": node.id,
51
- className: cn(isFlex ? cn("flex", direction === "row" ? "flex-wrap" : "flex-col") : "grid content-start", isFlex ? flexAlignments[align] ?? flexAlignments.stretch : gridAlignments[align] ?? gridAlignments.stretch, stackGaps[gap] ?? stackGaps.md, stackWidths[width] ?? stackWidths.full, justify ? justifyClasses[justify] : null, height ? stackHeights[height] : null),
57
+ className: cn(isFlex ? cn("flex", direction === "row" ? "flex-wrap" : "flex-col") : "grid content-start", isFlex ? flexAlignments[align] ?? flexAlignments.stretch : gridAlignments[align] ?? gridAlignments.stretch, stackGaps[gap] ?? stackGaps.md, stackWidths[width] ?? stackWidths.full, justify ? justifyClasses[justify] : null, height ? stackHeights[height] : null, float ? floatClasses[float] : null),
52
58
  children
53
59
  });
54
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"stack.js","names":[],"sources":["../../../resources/js/core/components/stack.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nconst gridAlignments: Record<string, string> = {\n center: \"justify-items-center text-center\",\n start: \"justify-items-start text-left\",\n stretch: \"justify-items-stretch\",\n};\n\nconst flexAlignments: Record<string, string> = {\n center: \"items-center text-center\",\n start: \"items-center text-left\",\n stretch: \"items-stretch justify-stretch\",\n};\n\nconst stackGaps: Record<string, string> = {\n none: \"gap-0\",\n xs: \"gap-1\",\n lg: \"gap-6\",\n md: \"gap-4\",\n sm: \"gap-2\",\n xl: \"gap-8\",\n};\n\nconst stackWidths: Record<string, string> = {\n fill: \"min-w-0 flex-1\",\n full: \"w-full\",\n lg: \"mx-auto w-full max-w-4xl\",\n md: \"mx-auto w-full max-w-2xl\",\n sm: \"mx-auto w-full max-w-md\",\n};\n\nconst justifyClasses: Record<string, string> = {\n around: \"justify-around\",\n between: \"justify-between\",\n center: \"justify-center\",\n end: \"justify-end\",\n evenly: \"justify-evenly\",\n start: \"justify-start\",\n};\n\nconst stackHeights: Record<string, string> = {\n full: \"h-full\",\n screen: \"min-h-screen\",\n};\n\nconst StackComponent: RendererComponent<\"stack\"> = ({ children, node }) => {\n const align = node.props.align ?? \"stretch\";\n const direction = node.props.direction ?? \"column\";\n const gap = node.props.gap ?? \"md\";\n const width = node.props.width ?? \"full\";\n const justify = node.props.justify;\n const height = node.props.height;\n const isFlex = direction === \"row\" || justify != null;\n\n return (\n <div\n data-lattice-component={node.id}\n className={cn(\n isFlex ? cn(\"flex\", direction === \"row\" ? \"flex-wrap\" : \"flex-col\") : \"grid content-start\",\n isFlex\n ? (flexAlignments[align] ?? flexAlignments.stretch)\n : (gridAlignments[align] ?? gridAlignments.stretch),\n stackGaps[gap] ?? stackGaps.md,\n stackWidths[width] ?? stackWidths.full,\n justify ? justifyClasses[justify] : null,\n height ? stackHeights[height] : null,\n )}\n >\n {children}\n </div>\n );\n};\n\nexport default StackComponent;\n"],"mappings":";;;AAGA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,IAAM,YAAoC;CACxC,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,cAAsC;CAC1C,MAAM;CACN,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,OAAO;AACT;AAEA,IAAM,eAAuC;CAC3C,MAAM;CACN,QAAQ;AACV;AAEA,IAAM,kBAA8C,EAAE,UAAU,WAAW;CACzE,MAAM,QAAQ,KAAK,MAAM,SAAS;CAClC,MAAM,YAAY,KAAK,MAAM,aAAa;CAC1C,MAAM,MAAM,KAAK,MAAM,OAAO;CAC9B,MAAM,QAAQ,KAAK,MAAM,SAAS;CAClC,MAAM,UAAU,KAAK,MAAM;CAC3B,MAAM,SAAS,KAAK,MAAM;CAC1B,MAAM,SAAS,cAAc,SAAS,WAAW;CAEjD,OACE,oBAAC,OAAD;EACE,0BAAwB,KAAK;EAC7B,WAAW,GACT,SAAS,GAAG,QAAQ,cAAc,QAAQ,cAAc,UAAU,IAAI,sBACtE,SACK,eAAe,UAAU,eAAe,UACxC,eAAe,UAAU,eAAe,SAC7C,UAAU,QAAQ,UAAU,IAC5B,YAAY,UAAU,YAAY,MAClC,UAAU,eAAe,WAAW,MACpC,SAAS,aAAa,UAAU,IAClC;EAEC;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"stack.js","names":[],"sources":["../../../resources/js/core/components/stack.tsx"],"sourcesContent":["import type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nconst gridAlignments: Record<string, string> = {\n center: \"justify-items-center text-center\",\n start: \"justify-items-start text-left\",\n stretch: \"justify-items-stretch\",\n};\n\nconst flexAlignments: Record<string, string> = {\n center: \"items-center text-center\",\n start: \"items-center text-left\",\n stretch: \"items-stretch justify-stretch\",\n};\n\nconst stackGaps: Record<string, string> = {\n none: \"gap-0\",\n xs: \"gap-1\",\n lg: \"gap-6\",\n md: \"gap-4\",\n sm: \"gap-2\",\n xl: \"gap-8\",\n};\n\nconst stackWidths: Record<string, string> = {\n auto: \"w-auto\",\n fill: \"min-w-0 flex-1\",\n full: \"w-full\",\n lg: \"mx-auto w-full max-w-4xl\",\n md: \"mx-auto w-full max-w-2xl\",\n sm: \"mx-auto w-full max-w-md\",\n};\n\nconst justifyClasses: Record<string, string> = {\n around: \"justify-around\",\n between: \"justify-between\",\n center: \"justify-center\",\n end: \"justify-end\",\n evenly: \"justify-evenly\",\n start: \"justify-start\",\n};\n\nconst stackHeights: Record<string, string> = {\n full: \"h-full\",\n screen: \"min-h-screen\",\n};\n\nconst floatClasses: Record<string, string> = {\n end: \"ml-auto\",\n start: \"mr-auto\",\n};\n\nconst StackComponent: RendererComponent<\"stack\"> = ({ children, node }) => {\n const align = node.props.align ?? \"stretch\";\n const direction = node.props.direction ?? \"column\";\n const gap = node.props.gap ?? \"md\";\n const width = node.props.width ?? \"full\";\n const justify = node.props.justify;\n const height = node.props.height;\n const float = node.props.float;\n const isFlex = direction === \"row\" || justify != null;\n\n return (\n <div\n data-lattice-component={node.id}\n className={cn(\n isFlex ? cn(\"flex\", direction === \"row\" ? \"flex-wrap\" : \"flex-col\") : \"grid content-start\",\n isFlex\n ? (flexAlignments[align] ?? flexAlignments.stretch)\n : (gridAlignments[align] ?? gridAlignments.stretch),\n stackGaps[gap] ?? stackGaps.md,\n stackWidths[width] ?? stackWidths.full,\n justify ? justifyClasses[justify] : null,\n height ? stackHeights[height] : null,\n float ? floatClasses[float] : null,\n )}\n >\n {children}\n </div>\n );\n};\n\nexport default StackComponent;\n"],"mappings":";;;AAGA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,OAAO;CACP,SAAS;AACX;AAEA,IAAM,YAAoC;CACxC,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,cAAsC;CAC1C,MAAM;CACN,MAAM;CACN,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,IAAM,iBAAyC;CAC7C,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,OAAO;AACT;AAEA,IAAM,eAAuC;CAC3C,MAAM;CACN,QAAQ;AACV;AAEA,IAAM,eAAuC;CAC3C,KAAK;CACL,OAAO;AACT;AAEA,IAAM,kBAA8C,EAAE,UAAU,WAAW;CACzE,MAAM,QAAQ,KAAK,MAAM,SAAS;CAClC,MAAM,YAAY,KAAK,MAAM,aAAa;CAC1C,MAAM,MAAM,KAAK,MAAM,OAAO;CAC9B,MAAM,QAAQ,KAAK,MAAM,SAAS;CAClC,MAAM,UAAU,KAAK,MAAM;CAC3B,MAAM,SAAS,KAAK,MAAM;CAC1B,MAAM,QAAQ,KAAK,MAAM;CACzB,MAAM,SAAS,cAAc,SAAS,WAAW;CAEjD,OACE,oBAAC,OAAD;EACE,0BAAwB,KAAK;EAC7B,WAAW,GACT,SAAS,GAAG,QAAQ,cAAc,QAAQ,cAAc,UAAU,IAAI,sBACtE,SACK,eAAe,UAAU,eAAe,UACxC,eAAe,UAAU,eAAe,SAC7C,UAAU,QAAQ,UAAU,IAC5B,YAAY,UAAU,YAAY,MAClC,UAAU,eAAe,WAAW,MACpC,SAAS,aAAa,UAAU,MAChC,QAAQ,aAAa,SAAS,IAChC;EAEC;CACE,CAAA;AAET"}
@@ -101,7 +101,7 @@ var TabsComponent = ({ children, node }) => {
101
101
  "aria-controls": `${tab.value}-panel`,
102
102
  "aria-selected": isActive,
103
103
  "data-test": `tab-${tab.value}`,
104
- className: cn("whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors", isActive ? "bg-lt-bg text-lt-fg shadow-xs" : "text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg", isVertical && "text-left"),
104
+ className: cn("whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors", isActive ? "bg-lt-bg text-lt-fg shadow-lt-xs" : "text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg", isVertical && "text-left"),
105
105
  id: `${tab.value}-tab`,
106
106
  onClick: () => selectTab(tab),
107
107
  onKeyDown: onTablistKeyDown,
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","names":[],"sources":["../../../resources/js/core/components/tabs.tsx"],"sourcesContent":["import { router } from \"@inertiajs/react\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { Tab } from \"@lattice-php/lattice/types/generated\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\n\ntype TabsContextValue = {\n activeValue: string;\n setActiveValue: (value: string) => void;\n};\n\nconst TabsContext = createContext<TabsContextValue | null>(null);\n\nfunction useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext);\n\n if (!context) {\n return {\n activeValue: \"\",\n setActiveValue: () => {},\n };\n }\n\n return context;\n}\n\ntype TabItem = {\n confirm?: {\n required?: boolean;\n };\n label: string;\n value: string;\n};\n\nfunction getTabs(node: Node): TabItem[] {\n return (node.schema ?? [])\n .filter((child) => child.type === \"tab\")\n .map((child) => {\n const props = child.props as unknown as Tab;\n\n return {\n confirm: props.confirm ? { required: props.confirm.required } : undefined,\n label: props.label,\n value: props.value,\n };\n })\n .filter((tab) => tab.value !== \"\");\n}\n\nfunction queryValue(queryKey: string, tabs: Array<{ value: string }>): string | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n const value = new URLSearchParams(window.location.search).get(queryKey);\n\n if (!value || !tabs.some((tab) => tab.value === value)) {\n return null;\n }\n\n return value;\n}\n\nfunction replaceQueryValue(queryKey: string, value: string): void {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const url = new URL(window.location.href);\n url.searchParams.set(queryKey, value);\n window.history.replaceState(window.history.state, \"\", `${url.pathname}${url.search}${url.hash}`);\n}\n\nfunction queryUrl(queryKey: string, value: string): string {\n if (typeof window === \"undefined\") {\n return \"\";\n }\n\n const url = new URL(window.location.href);\n url.searchParams.set(queryKey, value);\n\n return `${url.pathname}${url.search}${url.hash}`;\n}\n\nexport const TabsComponent: RendererComponent<\"tabs\"> = ({ children, node }) => {\n const { t } = useT(\"lattice\");\n const tabs = useMemo(() => getTabs(node), [node]);\n const firstValue = tabs[0]?.value ?? \"\";\n const queryKey = node.props.queryKey;\n const orientation = node.props.orientation;\n const isVertical = orientation === \"vertical\";\n const serverActiveValue = node.props.activeValue;\n const defaultValue = node.props.defaultValue ?? firstValue;\n const tablistRef = useRef<HTMLDivElement>(null);\n const [activeValue, setActiveTabValue] = useState(\n () => serverActiveValue || (queryValue(queryKey, tabs) ?? defaultValue) || firstValue,\n );\n\n function selectTab(tab: TabItem): void {\n if (tab.confirm?.required) {\n router.visit(queryUrl(queryKey, tab.value), {\n preserveScroll: true,\n });\n\n return;\n }\n\n setActiveTabValue(tab.value);\n replaceQueryValue(queryKey, tab.value);\n }\n\n function selectTabValue(value: string): void {\n const tab = tabs.find((item) => item.value === value);\n\n if (tab) {\n selectTab(tab);\n }\n }\n\n function onTablistKeyDown(event: KeyboardEvent<HTMLButtonElement>): void {\n const nextKey = isVertical ? \"ArrowDown\" : \"ArrowRight\";\n const prevKey = isVertical ? \"ArrowUp\" : \"ArrowLeft\";\n\n if (\n event.key !== nextKey &&\n event.key !== prevKey &&\n event.key !== \"Home\" &&\n event.key !== \"End\"\n ) {\n return;\n }\n\n const buttons = Array.from(\n tablistRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"tab\"]') ?? [],\n );\n\n if (buttons.length === 0) {\n return;\n }\n\n event.preventDefault();\n const current = buttons.indexOf(document.activeElement as HTMLButtonElement);\n\n let index: number;\n if (event.key === \"Home\") {\n index = 0;\n } else if (event.key === \"End\") {\n index = buttons.length - 1;\n } else {\n const delta = event.key === nextKey ? 1 : -1;\n const base = current < 0 ? 0 : current;\n index = (base + delta + buttons.length) % buttons.length;\n }\n\n buttons[index]?.focus();\n }\n\n return (\n <TabsContext.Provider value={{ activeValue, setActiveValue: selectTabValue }}>\n <div\n className={cn(\"gap-6\", isVertical ? \"flex\" : \"grid\")}\n data-lattice-tabs={node.key ?? node.id}\n >\n <div\n aria-label={t(\"a11y.tabs\", \"Tabs\")}\n aria-orientation={orientation}\n className={cn(\n \"gap-1 rounded-lt bg-lt-muted p-1\",\n isVertical ? \"flex flex-col\" : \"inline-flex w-fit max-w-full overflow-x-auto\",\n )}\n ref={tablistRef}\n role=\"tablist\"\n >\n {tabs.map((tab) => {\n const isActive = activeValue === tab.value;\n\n return (\n <button\n aria-controls={`${tab.value}-panel`}\n aria-selected={isActive}\n data-test={`tab-${tab.value}`}\n className={cn(\n \"whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors\",\n isActive\n ? \"bg-lt-bg text-lt-fg shadow-xs\"\n : \"text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg\",\n isVertical && \"text-left\",\n )}\n id={`${tab.value}-tab`}\n key={tab.value}\n onClick={() => selectTab(tab)}\n onKeyDown={onTablistKeyDown}\n role=\"tab\"\n tabIndex={isActive ? 0 : -1}\n type=\"button\"\n >\n {tab.label}\n </button>\n );\n })}\n </div>\n\n <div className={cn(\"min-w-0\", isVertical && \"flex-1\")}>{children}</div>\n </div>\n </TabsContext.Provider>\n );\n};\n\nconst TabComponent: RendererComponent<\"tab\"> = ({ children, node }) => {\n const { activeValue } = useTabsContext();\n const value = node.props.value;\n const isActive = activeValue === value;\n const [hasOpened, setHasOpened] = useState(isActive);\n\n useEffect(() => {\n if (isActive) {\n setHasOpened(true);\n }\n }, [isActive]);\n\n return (\n <section\n aria-labelledby={`${value}-tab`}\n className={cn(\"space-y-8\", !isActive && \"hidden\")}\n hidden={!isActive}\n id={`${value}-panel`}\n role=\"tabpanel\"\n tabIndex={0}\n >\n {hasOpened ? (children as ReactNode) : null}\n </section>\n );\n};\n\nexport default TabComponent;\n"],"mappings":";;;;;;AAaA,IAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,iBAAmC;CAC1C,MAAM,UAAU,WAAW,WAAW;CAEtC,IAAI,CAAC,SACH,OAAO;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/js/core/components/tabs.tsx"],"sourcesContent":["import { router } from \"@inertiajs/react\";\nimport { createContext, useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { KeyboardEvent, ReactNode } from \"react\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport type { Tab } from \"@lattice-php/lattice/types/generated\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\n\ntype TabsContextValue = {\n activeValue: string;\n setActiveValue: (value: string) => void;\n};\n\nconst TabsContext = createContext<TabsContextValue | null>(null);\n\nfunction useTabsContext(): TabsContextValue {\n const context = useContext(TabsContext);\n\n if (!context) {\n return {\n activeValue: \"\",\n setActiveValue: () => {},\n };\n }\n\n return context;\n}\n\ntype TabItem = {\n confirm?: {\n required?: boolean;\n };\n label: string;\n value: string;\n};\n\nfunction getTabs(node: Node): TabItem[] {\n return (node.schema ?? [])\n .filter((child) => child.type === \"tab\")\n .map((child) => {\n const props = child.props as unknown as Tab;\n\n return {\n confirm: props.confirm ? { required: props.confirm.required } : undefined,\n label: props.label,\n value: props.value,\n };\n })\n .filter((tab) => tab.value !== \"\");\n}\n\nfunction queryValue(queryKey: string, tabs: Array<{ value: string }>): string | null {\n if (typeof window === \"undefined\") {\n return null;\n }\n\n const value = new URLSearchParams(window.location.search).get(queryKey);\n\n if (!value || !tabs.some((tab) => tab.value === value)) {\n return null;\n }\n\n return value;\n}\n\nfunction replaceQueryValue(queryKey: string, value: string): void {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const url = new URL(window.location.href);\n url.searchParams.set(queryKey, value);\n window.history.replaceState(window.history.state, \"\", `${url.pathname}${url.search}${url.hash}`);\n}\n\nfunction queryUrl(queryKey: string, value: string): string {\n if (typeof window === \"undefined\") {\n return \"\";\n }\n\n const url = new URL(window.location.href);\n url.searchParams.set(queryKey, value);\n\n return `${url.pathname}${url.search}${url.hash}`;\n}\n\nexport const TabsComponent: RendererComponent<\"tabs\"> = ({ children, node }) => {\n const { t } = useT(\"lattice\");\n const tabs = useMemo(() => getTabs(node), [node]);\n const firstValue = tabs[0]?.value ?? \"\";\n const queryKey = node.props.queryKey;\n const orientation = node.props.orientation;\n const isVertical = orientation === \"vertical\";\n const serverActiveValue = node.props.activeValue;\n const defaultValue = node.props.defaultValue ?? firstValue;\n const tablistRef = useRef<HTMLDivElement>(null);\n const [activeValue, setActiveTabValue] = useState(\n () => serverActiveValue || (queryValue(queryKey, tabs) ?? defaultValue) || firstValue,\n );\n\n function selectTab(tab: TabItem): void {\n if (tab.confirm?.required) {\n router.visit(queryUrl(queryKey, tab.value), {\n preserveScroll: true,\n });\n\n return;\n }\n\n setActiveTabValue(tab.value);\n replaceQueryValue(queryKey, tab.value);\n }\n\n function selectTabValue(value: string): void {\n const tab = tabs.find((item) => item.value === value);\n\n if (tab) {\n selectTab(tab);\n }\n }\n\n function onTablistKeyDown(event: KeyboardEvent<HTMLButtonElement>): void {\n const nextKey = isVertical ? \"ArrowDown\" : \"ArrowRight\";\n const prevKey = isVertical ? \"ArrowUp\" : \"ArrowLeft\";\n\n if (\n event.key !== nextKey &&\n event.key !== prevKey &&\n event.key !== \"Home\" &&\n event.key !== \"End\"\n ) {\n return;\n }\n\n const buttons = Array.from(\n tablistRef.current?.querySelectorAll<HTMLButtonElement>('[role=\"tab\"]') ?? [],\n );\n\n if (buttons.length === 0) {\n return;\n }\n\n event.preventDefault();\n const current = buttons.indexOf(document.activeElement as HTMLButtonElement);\n\n let index: number;\n if (event.key === \"Home\") {\n index = 0;\n } else if (event.key === \"End\") {\n index = buttons.length - 1;\n } else {\n const delta = event.key === nextKey ? 1 : -1;\n const base = current < 0 ? 0 : current;\n index = (base + delta + buttons.length) % buttons.length;\n }\n\n buttons[index]?.focus();\n }\n\n return (\n <TabsContext.Provider value={{ activeValue, setActiveValue: selectTabValue }}>\n <div\n className={cn(\"gap-6\", isVertical ? \"flex\" : \"grid\")}\n data-lattice-tabs={node.key ?? node.id}\n >\n <div\n aria-label={t(\"a11y.tabs\", \"Tabs\")}\n aria-orientation={orientation}\n className={cn(\n \"gap-1 rounded-lt bg-lt-muted p-1\",\n isVertical ? \"flex flex-col\" : \"inline-flex w-fit max-w-full overflow-x-auto\",\n )}\n ref={tablistRef}\n role=\"tablist\"\n >\n {tabs.map((tab) => {\n const isActive = activeValue === tab.value;\n\n return (\n <button\n aria-controls={`${tab.value}-panel`}\n aria-selected={isActive}\n data-test={`tab-${tab.value}`}\n className={cn(\n \"whitespace-nowrap rounded-lt-sm px-3 py-1.5 text-sm font-medium transition-colors\",\n isActive\n ? \"bg-lt-bg text-lt-fg shadow-lt-xs\"\n : \"text-lt-muted-fg hover:bg-lt-bg/60 hover:text-lt-fg\",\n isVertical && \"text-left\",\n )}\n id={`${tab.value}-tab`}\n key={tab.value}\n onClick={() => selectTab(tab)}\n onKeyDown={onTablistKeyDown}\n role=\"tab\"\n tabIndex={isActive ? 0 : -1}\n type=\"button\"\n >\n {tab.label}\n </button>\n );\n })}\n </div>\n\n <div className={cn(\"min-w-0\", isVertical && \"flex-1\")}>{children}</div>\n </div>\n </TabsContext.Provider>\n );\n};\n\nconst TabComponent: RendererComponent<\"tab\"> = ({ children, node }) => {\n const { activeValue } = useTabsContext();\n const value = node.props.value;\n const isActive = activeValue === value;\n const [hasOpened, setHasOpened] = useState(isActive);\n\n useEffect(() => {\n if (isActive) {\n setHasOpened(true);\n }\n }, [isActive]);\n\n return (\n <section\n aria-labelledby={`${value}-tab`}\n className={cn(\"space-y-8\", !isActive && \"hidden\")}\n hidden={!isActive}\n id={`${value}-panel`}\n role=\"tabpanel\"\n tabIndex={0}\n >\n {hasOpened ? (children as ReactNode) : null}\n </section>\n );\n};\n\nexport default TabComponent;\n"],"mappings":";;;;;;AAaA,IAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,iBAAmC;CAC1C,MAAM,UAAU,WAAW,WAAW;CAEtC,IAAI,CAAC,SACH,OAAO;EACL,aAAa;EACb,sBAAsB,CAAC;CACzB;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eType, Option, PageContainer as KnownPageContainer } from '../types/generated';
2
+ import { Node as WireNode, NodeType, Option, PageContainer as KnownPageContainer, ListenerPayload } from '../types/generated';
3
3
  export type { KnownPageContainer, NodeType, WireNode };
4
4
  /** Loose props bag for nodes whose `type` is not a generated built-in. */
5
5
  export type NodeProps = Record<string, unknown>;
6
6
  export type CommonNodeProps = {
7
+ dataBindings?: Record<string, string> | null;
7
8
  hideWhenCollapsed?: boolean | null;
8
9
  };
9
10
  /** A `{ label, value }` pair used by the choice, select and segmented controls. */
@@ -76,6 +77,7 @@ export type PagePayload = {
76
77
  breadcrumbs: PageBreadcrumb[];
77
78
  container: PageContainer;
78
79
  layout: LayoutPayload | null;
80
+ listeners?: ListenerPayload[];
79
81
  schema: Schema;
80
82
  title: string | null;
81
83
  };
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+ import { Affix } from '../../../types/generated';
3
+ /**
4
+ * Wraps a single-line control in a prefix/suffix input group. The control is a
5
+ * render prop receiving the class names that square the corners adjacent to an
6
+ * affix; with no affixes the control renders untouched.
7
+ *
8
+ * The focus ring lives on the group, not the bare input, so it surrounds the
9
+ * whole control — affixes included — instead of being clipped by the opaque
10
+ * affix segments. The control itself stays the focus target; only its own ring
11
+ * is suppressed.
12
+ */
13
+ export declare function AffixGroup({ prefix, suffix, children, }: {
14
+ prefix?: Affix | null;
15
+ suffix?: Affix | null;
16
+ children: (controlClassName: string) => ReactNode;
17
+ }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
@@ -0,0 +1,49 @@
1
+ import { cn } from "../../../lib/utils.js";
2
+ import { IconRenderer } from "../../../icons/icon-renderer.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region resources/js/form/components/base/affix-group.tsx
5
+ function AffixSegment({ affix, side }) {
6
+ return /* @__PURE__ */ jsx("span", {
7
+ "data-slot": `affix-${side}`,
8
+ className: cn("inline-flex h-lt-control-md shrink-0 items-center border border-lt-input bg-lt-muted px-3 text-base whitespace-nowrap text-lt-muted-fg", "group-has-[:focus-visible]:border-lt-ring", side === "start" ? "rounded-l-lt-sm border-r-0" : "rounded-r-lt-sm border-l-0"),
9
+ children: affix.icon ? /* @__PURE__ */ jsx(IconRenderer, {
10
+ className: "size-lt-icon-md",
11
+ icon: affix.icon
12
+ }) : affix.text
13
+ });
14
+ }
15
+ /**
16
+ * Wraps a single-line control in a prefix/suffix input group. The control is a
17
+ * render prop receiving the class names that square the corners adjacent to an
18
+ * affix; with no affixes the control renders untouched.
19
+ *
20
+ * The focus ring lives on the group, not the bare input, so it surrounds the
21
+ * whole control — affixes included — instead of being clipped by the opaque
22
+ * affix segments. The control itself stays the focus target; only its own ring
23
+ * is suppressed.
24
+ */
25
+ function AffixGroup({ prefix, suffix, children }) {
26
+ if (!prefix && !suffix) return children("");
27
+ return /* @__PURE__ */ jsxs("div", {
28
+ className: "group flex w-full rounded-lt-sm transition-[color,box-shadow] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-lt-ring/50",
29
+ "data-slot": "affix-group",
30
+ children: [
31
+ prefix ? /* @__PURE__ */ jsx(AffixSegment, {
32
+ affix: prefix,
33
+ side: "start"
34
+ }) : null,
35
+ /* @__PURE__ */ jsx("div", {
36
+ className: "min-w-0 flex-1",
37
+ children: children(cn("focus-visible:ring-0", prefix && "rounded-l-none", suffix && "rounded-r-none"))
38
+ }),
39
+ suffix ? /* @__PURE__ */ jsx(AffixSegment, {
40
+ affix: suffix,
41
+ side: "end"
42
+ }) : null
43
+ ]
44
+ });
45
+ }
46
+ //#endregion
47
+ export { AffixGroup };
48
+
49
+ //# sourceMappingURL=affix-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affix-group.js","names":[],"sources":["../../../../resources/js/form/components/base/affix-group.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { Affix } from \"@lattice-php/lattice/types/generated\";\nimport { IconRenderer } from \"@lattice-php/lattice/icons\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction AffixSegment({ affix, side }: { affix: Affix; side: \"start\" | \"end\" }) {\n return (\n <span\n data-slot={`affix-${side}`}\n className={cn(\n \"inline-flex h-lt-control-md shrink-0 items-center border border-lt-input bg-lt-muted px-3 text-base whitespace-nowrap text-lt-muted-fg\",\n \"group-has-[:focus-visible]:border-lt-ring\",\n side === \"start\" ? \"rounded-l-lt-sm border-r-0\" : \"rounded-r-lt-sm border-l-0\",\n )}\n >\n {affix.icon ? <IconRenderer className=\"size-lt-icon-md\" icon={affix.icon} /> : affix.text}\n </span>\n );\n}\n\n/**\n * Wraps a single-line control in a prefix/suffix input group. The control is a\n * render prop receiving the class names that square the corners adjacent to an\n * affix; with no affixes the control renders untouched.\n *\n * The focus ring lives on the group, not the bare input, so it surrounds the\n * whole control — affixes included — instead of being clipped by the opaque\n * affix segments. The control itself stays the focus target; only its own ring\n * is suppressed.\n */\nexport function AffixGroup({\n prefix,\n suffix,\n children,\n}: {\n prefix?: Affix | null;\n suffix?: Affix | null;\n children: (controlClassName: string) => ReactNode;\n}) {\n if (!prefix && !suffix) {\n return children(\"\");\n }\n\n return (\n <div\n className=\"group flex w-full rounded-lt-sm transition-[color,box-shadow] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-lt-ring/50\"\n data-slot=\"affix-group\"\n >\n {prefix ? <AffixSegment affix={prefix} side=\"start\" /> : null}\n <div className=\"min-w-0 flex-1\">\n {children(\n cn(\"focus-visible:ring-0\", prefix && \"rounded-l-none\", suffix && \"rounded-r-none\"),\n )}\n </div>\n {suffix ? <AffixSegment affix={suffix} side=\"end\" /> : null}\n </div>\n );\n}\n"],"mappings":";;;;AAKA,SAAS,aAAa,EAAE,OAAO,QAAiD;CAC9E,OACE,oBAAC,QAAD;EACE,aAAW,SAAS;EACpB,WAAW,GACT,0IACA,6CACA,SAAS,UAAU,+BAA+B,4BACpD;YAEC,MAAM,OAAO,oBAAC,cAAD;GAAc,WAAU;GAAkB,MAAM,MAAM;EAAO,CAAA,IAAI,MAAM;CACjF,CAAA;AAEV;;;;;;;;;;;AAYA,SAAgB,WAAW,EACzB,QACA,QACA,YAKC;CACD,IAAI,CAAC,UAAU,CAAC,QACd,OAAO,SAAS,EAAE;CAGpB,OACE,qBAAC,OAAD;EACE,WAAU;EACV,aAAU;YAFZ;GAIG,SAAS,oBAAC,cAAD;IAAc,OAAO;IAAQ,MAAK;GAAS,CAAA,IAAI;GACzD,oBAAC,OAAD;IAAK,WAAU;cACZ,SACC,GAAG,wBAAwB,UAAU,kBAAkB,UAAU,gBAAgB,CACnF;GACG,CAAA;GACJ,SAAS,oBAAC,cAAD;IAAc,OAAO;IAAQ,MAAK;GAAO,CAAA,IAAI;EACpD;;AAET"}
@@ -6,7 +6,7 @@ import * as LabelPrimitive from "@radix-ui/react-label";
6
6
  function Label({ className, ...props }) {
7
7
  return /* @__PURE__ */ jsx(LabelPrimitive.Root, {
8
8
  "data-slot": "label",
9
- className: cn("text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
9
+ className: cn("text-base leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
10
10
  ...props
11
11
  });
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","names":[],"sources":["../../../../resources/js/form/components/base/label.tsx"],"sourcesContent":["import * as LabelPrimitive from \"@radix-ui/react-label\";\nimport * as React from \"react\";\n\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n \"text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Label };\n"],"mappings":";;;;;AAKA,SAAS,MAAM,EAAE,WAAW,GAAG,SAA2D;CACxF,OACE,oBAAC,eAAe,MAAhB;EACE,aAAU;EACV,WAAW,GACT,+LACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
1
+ {"version":3,"file":"label.js","names":[],"sources":["../../../../resources/js/form/components/base/label.tsx"],"sourcesContent":["import * as LabelPrimitive from \"@radix-ui/react-label\";\nimport * as React from \"react\";\n\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n data-slot=\"label\"\n className={cn(\n \"text-base leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Label };\n"],"mappings":";;;;;AAKA,SAAS,MAAM,EAAE,WAAW,GAAG,SAA2D;CACxF,OACE,oBAAC,eAAe,MAAhB;EACE,aAAU;EACV,WAAW,GACT,iMACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -20,7 +20,7 @@ function FormSubmitButton({ label, summaryLabel, variant = "default" }) {
20
20
  variant,
21
21
  children: [processing && /* @__PURE__ */ jsx(Spinner, {}), label]
22
22
  }), hasErrors && /* @__PURE__ */ jsxs("div", {
23
- className: "pointer-events-none absolute bottom-full left-1/2 z-10 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-md transition-opacity group-hover:opacity-100",
23
+ className: "pointer-events-none absolute bottom-full left-1/2 z-10 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",
24
24
  role: "tooltip",
25
25
  children: [/* @__PURE__ */ jsx("p", {
26
26
  className: "mb-1 font-medium text-lt-fg",
@@ -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/core/components/button\";\nimport { Spinner } from \"@lattice-php/lattice/core/components/spinner\";\nimport type { ButtonVariant } from \"@lattice-php/lattice/types/generated\";\nimport { useFormContext } from \"../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-10 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-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/core/components/button\";\nimport { Spinner } from \"@lattice-php/lattice/core/components/spinner\";\nimport type { ButtonVariant } from \"@lattice-php/lattice/types/generated\";\nimport { useFormContext } from \"../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-10 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"}
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
6
6
  function Textarea({ className, ...props }) {
7
7
  return /* @__PURE__ */ jsx("textarea", {
8
8
  "data-slot": "textarea",
9
- className: cn("border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", FOCUS_RING, "aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger", className),
9
+ className: cn("border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-lt-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg", FOCUS_RING, "aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger", className),
10
10
  ...props
11
11
  });
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"textarea.js","names":[],"sources":["../../../../resources/js/form/components/base/textarea.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { FOCUS_RING } from \"@lattice-php/lattice/core/components/control\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\n return (\n <textarea\n data-slot=\"textarea\"\n className={cn(\n \"border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n FOCUS_RING,\n \"aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Textarea };\n"],"mappings":";;;;;AAKA,SAAS,SAAS,EAAE,WAAW,GAAG,SAA2C;CAC3E,OACE,oBAAC,YAAD;EACE,aAAU;EACV,WAAW,GACT,+RACA,YACA,oGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
1
+ {"version":3,"file":"textarea.js","names":[],"sources":["../../../../resources/js/form/components/base/textarea.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { FOCUS_RING } from \"@lattice-php/lattice/core/components/control\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\n\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\n return (\n <textarea\n data-slot=\"textarea\"\n className={cn(\n \"border-lt-input placeholder:text-lt-muted-fg flex field-sizing-content min-h-16 w-full rounded-lt-sm border bg-transparent px-3 py-2 text-base shadow-lt-xs transition-[color,box-shadow] outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-lt-disabled disabled:text-lt-disabled-fg\",\n FOCUS_RING,\n \"aria-invalid:ring-lt-danger/20 dark:aria-invalid:ring-lt-danger/40 aria-invalid:border-lt-danger\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Textarea };\n"],"mappings":";;;;;AAKA,SAAS,SAAS,EAAE,WAAW,GAAG,SAA2C;CAC3E,OACE,oBAAC,YAAD;EACE,aAAU;EACV,WAAW,GACT,wTACA,YACA,oGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -4,12 +4,16 @@ import { useT } from "../../../i18n/instance.js";
4
4
  import { apiFetch } from "../../../core/api.js";
5
5
  import { useFormContext } from "../context.js";
6
6
  import { useFieldScope } from "../field-scope.js";
7
- import { useFormValues } from "../values.js";
7
+ import { useFormValues, useSetFormValue } from "../values.js";
8
8
  import { FormFieldFrame } from "../base/field.js";
9
9
  import { useDependentField } from "../use-dependent-field.js";
10
10
  import { useEffect, useId, useMemo, useRef, useState } from "react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  //#region resources/js/form/components/fields/file-upload.tsx
13
+ function uploadValueEquals(current, next) {
14
+ if (Array.isArray(next)) return Array.isArray(current) && current.length === next.length && current.every((value, index) => value === next[index]);
15
+ return current === next;
16
+ }
13
17
  var FileUploadComponent = ({ node }) => {
14
18
  const { t } = useT("lattice");
15
19
  const props = node.props;
@@ -21,6 +25,7 @@ var FileUploadComponent = ({ node }) => {
21
25
  const errorKey = scope ? scope.errorKey(name) : name;
22
26
  const uploadKey = errorKey;
23
27
  const values = useFormValues();
28
+ const setValue = useSetFormValue();
24
29
  const inputId = useId();
25
30
  const fileInputRef = useRef(null);
26
31
  const previewUrlsRef = useRef(/* @__PURE__ */ new Set());
@@ -40,6 +45,33 @@ var FileUploadComponent = ({ node }) => {
40
45
  existing: true
41
46
  })), [props.files]));
42
47
  const [removedTokens, setRemovedTokens] = useState([]);
48
+ useEffect(() => {
49
+ if (!signed) return;
50
+ const keys = items.filter((item) => !item.existing && item.key && item.status === "ready").map((item) => item.key);
51
+ const next = multiple ? keys : keys[0] ?? "";
52
+ if (scope) {
53
+ if (!uploadValueEquals(scope.getValue(name), next)) scope.setValue(name, next);
54
+ return;
55
+ }
56
+ setValue(name, next);
57
+ }, [
58
+ items,
59
+ multiple,
60
+ name,
61
+ scope,
62
+ setValue,
63
+ signed
64
+ ]);
65
+ useEffect(() => {
66
+ if (!signed || scope) return;
67
+ setValue(`${name}__removed`, removedTokens);
68
+ }, [
69
+ name,
70
+ removedTokens,
71
+ scope,
72
+ setValue,
73
+ signed
74
+ ]);
43
75
  useEffect(() => () => {
44
76
  previewUrlsRef.current.forEach((url) => URL.revokeObjectURL(url));
45
77
  previewUrlsRef.current.clear();
@@ -201,7 +233,7 @@ var FileUploadComponent = ({ node }) => {
201
233
  (!item.existing || !scope) && /* @__PURE__ */ jsx("button", {
202
234
  "aria-label": t("file-upload.remove", "Remove {{name}}", { name: item.name }),
203
235
  className: "inline-flex size-7 shrink-0 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg disabled:pointer-events-none disabled:opacity-50",
204
- "data-test": item.existing ? testIdentity(`${name}-remove-existing`) : void 0,
236
+ "data-test": testIdentity(item.existing ? `${name}-remove-existing` : `${name}-remove`),
205
237
  disabled: locked,
206
238
  onClick: () => removeItem(item.id),
207
239
  type: "button",