@apipass/design-system 4.0.0 → 4.2.1

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 (93) hide show
  1. package/dist/lib/embedded-styles.js +1 -1
  2. package/dist/lib/json-viewer.index.cjs +1 -1
  3. package/dist/lib/json-viewer.index.js +4 -2
  4. package/dist/lib/json-viewer.index.js.map +1 -1
  5. package/dist/lib/lib.index.cjs +1 -1
  6. package/dist/lib/lib.index.js +696 -694
  7. package/dist/lib/lib.index.js.map +1 -1
  8. package/dist/lib/style.css +1 -1
  9. package/dist/lib/ui/components/DataTable/DataTable.cjs +1 -1
  10. package/dist/lib/ui/components/Widget/Widget.cjs +1 -1
  11. package/dist/lib/ui/components/WidgetGrid/WidgetGrid.cjs +1 -1
  12. package/dist/lib/ui/primitives/Button/Button.cjs +1 -1
  13. package/dist/lib/ui/primitives/CodeBlock/CodeBlock.cjs +1 -1
  14. package/dist/lib/ui/primitives/CodeEditor/CodeEditor.cjs +1 -1
  15. package/dist/lib/ui/primitives/ComboBox/ComboBox.cjs +1 -1
  16. package/dist/lib/ui/primitives/ComboBox/ComboBox.cjs.map +1 -1
  17. package/dist/lib/ui/primitives/ComboBox/ComboBox.js +60 -37
  18. package/dist/lib/ui/primitives/ComboBox/ComboBox.js.map +1 -1
  19. package/dist/lib/ui/primitives/DateRangePicker/DateRangePicker.cjs +1 -1
  20. package/dist/lib/ui/primitives/FileUpload/FileUpload.cjs +1 -1
  21. package/dist/lib/ui/primitives/FileUpload/FileUpload.js +10 -10
  22. package/dist/lib/ui/primitives/IconButton/IconButton.cjs +1 -1
  23. package/dist/lib/ui/primitives/Input/Input.js +2 -2
  24. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs +2 -0
  25. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.cjs.map +1 -0
  26. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js +95 -0
  27. package/dist/lib/ui/primitives/JsonViewer/JsonEditor.js.map +1 -0
  28. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs +1 -1
  29. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.cjs.map +1 -1
  30. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js +37 -88
  31. package/dist/lib/ui/primitives/JsonViewer/JsonViewer.js.map +1 -1
  32. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs +2 -0
  33. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.cjs.map +1 -0
  34. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js +64 -0
  35. package/dist/lib/ui/primitives/JsonViewer/json-code-mirror.js.map +1 -0
  36. package/dist/lib/ui/primitives/Link/Link.cjs +1 -1
  37. package/dist/lib/ui/primitives/Link/Link.js +3 -3
  38. package/dist/lib/ui/primitives/Menu/Menu.cjs +1 -1
  39. package/dist/lib/ui/primitives/Menu/Menu.cjs.map +1 -1
  40. package/dist/lib/ui/primitives/Menu/Menu.js +65 -45
  41. package/dist/lib/ui/primitives/Menu/Menu.js.map +1 -1
  42. package/dist/lib/ui/primitives/PermissionGate/PermissionGate.cjs.map +1 -1
  43. package/dist/lib/ui/primitives/PermissionGate/PermissionGate.js.map +1 -1
  44. package/dist/lib/ui/primitives/Search/Search.cjs +1 -1
  45. package/dist/lib/ui/primitives/Search/Search.js +8 -8
  46. package/dist/lib/ui/primitives/Select/MultiSelect.cjs +2 -0
  47. package/dist/lib/ui/primitives/Select/MultiSelect.cjs.map +1 -0
  48. package/dist/lib/ui/primitives/Select/MultiSelect.js +113 -0
  49. package/dist/lib/ui/primitives/Select/MultiSelect.js.map +1 -0
  50. package/dist/lib/ui/primitives/Select/Select.cjs +1 -1
  51. package/dist/lib/ui/primitives/Select/Select.cjs.map +1 -1
  52. package/dist/lib/ui/primitives/Select/Select.js +19 -12
  53. package/dist/lib/ui/primitives/Select/Select.js.map +1 -1
  54. package/dist/lib/vendor/@monaco-editor/react/dist/index.cjs +1 -1
  55. package/dist/lib/vendor/@monaco-editor/react/dist/index.cjs.map +1 -1
  56. package/dist/lib/vendor/@monaco-editor/react/dist/index.js +21 -21
  57. package/dist/lib/vendor/@react-aria/interactions/dist/useFocusable.cjs +1 -1
  58. package/dist/lib/vendor/@react-aria/interactions/dist/useFocusable.js +4 -4
  59. package/dist/lib/vendor/@react-aria/ssr/dist/SSRProvider.js.map +1 -1
  60. package/dist/lib/vendor/@react-stately/utils/dist/useControlledState.cjs +1 -1
  61. package/dist/lib/vendor/react-draggable/build/cjs/Draggable.cjs +2 -2
  62. package/dist/lib/vendor/react-draggable/build/cjs/Draggable.js +8 -8
  63. package/dist/lib/vendor/react-grid-layout/build/GridItem.cjs +1 -1
  64. package/dist/lib/vendor/react-grid-layout/build/ReactGridLayout.cjs +1 -1
  65. package/dist/lib/vendor/react-grid-layout/build/ReactGridLayout.js +6 -6
  66. package/dist/lib/vendor/react-grid-layout/build/ReactGridLayout.js.map +1 -1
  67. package/dist/lib/vendor/react-grid-layout/build/ReactGridLayoutPropTypes.js +2 -2
  68. package/dist/lib/vendor/react-grid-layout/build/ResponsiveReactGridLayout.cjs +1 -1
  69. package/dist/lib/vendor/react-grid-layout/build/ResponsiveReactGridLayout.js.map +1 -1
  70. package/dist/lib/vendor/react-grid-layout/build/components/WidthProvider.cjs +1 -1
  71. package/dist/lib/vendor/react-grid-layout/build/components/WidthProvider.js +6 -6
  72. package/dist/lib/vendor/react-grid-layout/build/components/WidthProvider.js.map +1 -1
  73. package/dist/lib/vendor/react-grid-layout/build/utils.cjs +1 -1
  74. package/dist/lib/vendor/react-grid-layout/build/utils.js +27 -27
  75. package/dist/lib/vendor/react-resizable/build/Resizable.cjs +1 -1
  76. package/dist/lib/vendor/react-resizable/build/Resizable.js +17 -17
  77. package/dist/lib/vendor/react-resizable/build/Resizable.js.map +1 -1
  78. package/dist/lib/vendor/react-resizable/build/ResizableBox.cjs +1 -1
  79. package/dist/lib/vendor/react-resizable/build/ResizableBox.js +5 -5
  80. package/dist/lib/vendor/react-resizable/build/ResizableBox.js.map +1 -1
  81. package/dist/lib/vendor/react-resizable/build/utils.cjs +1 -1
  82. package/dist/lib/vendor/react-resizable/build/utils.cjs.map +1 -1
  83. package/dist/lib/vendor/react-resizable/build/utils.js +2 -2
  84. package/dist/lib/vendor/react-toastify/dist/index.cjs +1 -1
  85. package/dist/lib/vendor/react-toastify/dist/index.js +10 -10
  86. package/dist/types/json-viewer.index.d.ts +1 -0
  87. package/dist/types/ui/primitives/JsonViewer/JsonEditor.d.ts +18 -0
  88. package/dist/types/ui/primitives/JsonViewer/json-code-mirror.d.ts +17 -0
  89. package/dist/types/ui/primitives/Menu/Menu.d.ts +1 -1
  90. package/dist/types/ui/primitives/PermissionGate/PermissionGate.d.ts +20 -0
  91. package/dist/types/ui/primitives/Select/MultiSelect.d.ts +15 -0
  92. package/dist/types/ui/primitives/index.d.ts +1 -0
  93. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("react");;/* empty css */const Z=require("../../primitives/Search/Search.cjs"),t=require("../../primitives/Table/Table.cjs"),_=require("../../icons/IconChevronDown.cjs"),A=require("../../icons/IconChevronRight.cjs"),K=require("../../primitives/Pagination/Pagination.cjs"),ee=require("../../primitives/PermissionGate/PermissionGate.cjs"),ae=require("../../layout/Flex/Flex.cjs");function se({action:n,item:c}){const o=n.isAllowed!==!1,d=e.jsx("button",{className:"data-table-row-action-btn","aria-label":n.label,disabled:!o,onClick:o?()=>n.onPress(c):void 0,children:n.icon});return o?d:e.jsx(ee.PermissionGate,{isAllowed:!1,noAccessLabel:n.noAccessLabel??"",children:d})}function M({columns:n,data:c,actions:o,rowActions:d,rowActionsLabel:R="",searchPlaceholder:L="Search...",searchKeys:g=[],isLoading:k=!1,loadingMessage:N="Loading...",emptyMessage:D="No records found",previousLabel:I="Previous",nextLabel:$="Next",pageSize:b=10,nestedColumns:T,getNestedData:S,nestedLoadingMessage:B="Loading...",nestedEmptyMessage:E="No records found",nestedSearchKeys:F,nestedSearchPlaceholder:G,nestedActions:j,nestedPageSize:H}){const[p,O]=h.useState(""),[Q,v]=h.useState(1),[z,J]=h.useState(new Set),[P,w]=h.useState(new Map),q=!!S&&!!T,f=!!d;function U(a){const s=a.id;J(r=>{const i=new Set(r);if(i.has(s))i.delete(s);else if(i.add(s),!P.has(s)){const l=S(a);l instanceof Promise?(w(u=>new Map(u).set(s,{status:"loading",data:[]})),l.then(u=>{w(Y=>new Map(Y).set(s,{status:"loaded",data:u}))})):w(u=>new Map(u).set(s,{status:"loaded",data:l}))}return i})}const x=g.length>0,V=x||!!o,m=h.useMemo(()=>{if(!p.trim()||!x)return c;const a=p.toLowerCase();return c.filter(s=>g.some(r=>String(s[r]??"").toLowerCase().includes(a)))},[c,p,g,x]),y=Math.max(1,Math.ceil(m.length/b)),C=Math.min(Q,y),W=m.slice((C-1)*b,C*b);function X(a,s){return s.render?s.render(a):String(a[s.key]??"")}return e.jsxs(ae.Flex,{direction:"column",gap:"300",className:"data-table",children:[V&&e.jsxs("div",{className:"data-table-toolbar",children:[x&&e.jsx(Z.Search,{placeholder:L,onSearch:a=>{O(a),v(1)},className:"data-table-search"}),o&&e.jsx("div",{className:"data-table-actions",children:o})]}),k?e.jsx("div",{role:"status","aria-live":"polite","aria-label":N,className:"data-table-status",children:N}):m.length===0?e.jsx("div",{role:"status",className:"data-table-status data-table-empty",children:D}):e.jsxs(t.Table,{grid:!0,children:[e.jsxs(t.TableHead,{children:[q&&e.jsx(t.TableColumn,{className:"data-table-expand-col"}),n.map((a,s)=>e.jsx(t.TableColumn,{align:a.align,isRowHeader:s===0,children:a.label},String(a.key))),f&&e.jsx(t.TableColumn,{align:"right",className:"data-table-row-actions-col",children:R})]}),e.jsx(t.TableBody,{children:W.flatMap(a=>{const s=z.has(a.id),r=P.get(a.id),i=[e.jsxs(t.TableRow,{id:a.id,children:[q&&e.jsx(t.TableCell,{className:"data-table-expand-cell",children:e.jsx("button",{className:"data-table-expand-btn","aria-label":s?"Collapse row":"Expand row","aria-expanded":s,onClick:()=>U(a),children:s?e.jsx(_.IconChevronDown,{size:"16"}):e.jsx(A.IconChevronRight,{size:"16"})})}),n.map(l=>e.jsx(t.TableCell,{align:l.align,children:X(a,l)},String(l.key))),f&&e.jsx(t.TableCell,{align:"right",className:"data-table-row-actions-cell",children:e.jsx("div",{className:"data-table-row-actions",children:(typeof d=="function"?d(a):d).map(l=>e.jsx(se,{action:l,item:a},l.key))})})]},a.id)];return s&&i.push(e.jsx(t.TableRow,{id:`${a.id}-nested`,className:"data-table-nested-row",children:e.jsx(t.TableCell,{colSpan:n.length+1+(f?1:0),className:"data-table-nested-cell",children:e.jsx(M,{columns:T,data:(r==null?void 0:r.data)??[],isLoading:!r||r.status==="loading",loadingMessage:B,emptyMessage:E,searchKeys:F,searchPlaceholder:G,actions:j==null?void 0:j(a),pageSize:H??b})})},`${a.id}-nested`)),i})})]}),e.jsx(K.Pagination,{page:C,totalPages:y,onPageChange:v,previousLabel:I,nextLabel:$})]})}exports.DataTable=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("react");;/* empty css */const Z=require("../../primitives/Search/Search.cjs"),t=require("../../primitives/Table/Table.cjs"),_=require("../../icons/IconChevronDown.cjs"),A=require("../../icons/IconChevronRight.cjs"),K=require("../../primitives/Pagination/Pagination.cjs"),ee=require("../../primitives/PermissionGate/PermissionGate.cjs"),ae=require("../../layout/Flex/Flex.cjs");function se({action:n,item:c}){const o=n.isAllowed!==!1,d=e.jsx("button",{className:"data-table-row-action-btn","aria-label":n.label,disabled:!o,onClick:o?()=>n.onPress(c):void 0,children:n.icon});return o?d:e.jsx(ee.PermissionGate,{isAllowed:!1,noAccessLabel:n.noAccessLabel??"",children:d})}function M({columns:n,data:c,actions:o,rowActions:d,rowActionsLabel:R="",searchPlaceholder:L="Search...",searchKeys:g=[],isLoading:k=!1,loadingMessage:N="Loading...",emptyMessage:D="No records found",previousLabel:I="Previous",nextLabel:E="Next",pageSize:b=10,nestedColumns:T,getNestedData:S,nestedLoadingMessage:B="Loading...",nestedEmptyMessage:F="No records found",nestedSearchKeys:G,nestedSearchPlaceholder:H,nestedActions:j,nestedPageSize:$}){const[p,O]=h.useState(""),[Q,v]=h.useState(1),[z,J]=h.useState(new Set),[P,w]=h.useState(new Map),q=!!S&&!!T,f=!!d;function U(a){const s=a.id;J(r=>{const i=new Set(r);if(i.has(s))i.delete(s);else if(i.add(s),!P.has(s)){const l=S(a);l instanceof Promise?(w(u=>new Map(u).set(s,{status:"loading",data:[]})),l.then(u=>{w(Y=>new Map(Y).set(s,{status:"loaded",data:u}))})):w(u=>new Map(u).set(s,{status:"loaded",data:l}))}return i})}const x=g.length>0,V=x||!!o,m=h.useMemo(()=>{if(!p.trim()||!x)return c;const a=p.toLowerCase();return c.filter(s=>g.some(r=>String(s[r]??"").toLowerCase().includes(a)))},[c,p,g,x]),y=Math.max(1,Math.ceil(m.length/b)),C=Math.min(Q,y),W=m.slice((C-1)*b,C*b);function X(a,s){return s.render?s.render(a):String(a[s.key]??"")}return e.jsxs(ae.Flex,{direction:"column",gap:"300",className:"data-table",children:[V&&e.jsxs("div",{className:"data-table-toolbar",children:[x&&e.jsx(Z.Search,{placeholder:L,onSearch:a=>{O(a),v(1)},className:"data-table-search"}),o&&e.jsx("div",{className:"data-table-actions",children:o})]}),k?e.jsx("div",{role:"status","aria-live":"polite","aria-label":N,className:"data-table-status",children:N}):m.length===0?e.jsx("div",{role:"status",className:"data-table-status data-table-empty",children:D}):e.jsxs(t.Table,{grid:!0,children:[e.jsxs(t.TableHead,{children:[q&&e.jsx(t.TableColumn,{className:"data-table-expand-col"}),n.map((a,s)=>e.jsx(t.TableColumn,{align:a.align,isRowHeader:s===0,children:a.label},String(a.key))),f&&e.jsx(t.TableColumn,{align:"right",className:"data-table-row-actions-col",children:R})]}),e.jsx(t.TableBody,{children:W.flatMap(a=>{const s=z.has(a.id),r=P.get(a.id),i=[e.jsxs(t.TableRow,{id:a.id,children:[q&&e.jsx(t.TableCell,{className:"data-table-expand-cell",children:e.jsx("button",{className:"data-table-expand-btn","aria-label":s?"Collapse row":"Expand row","aria-expanded":s,onClick:()=>U(a),children:s?e.jsx(_.IconChevronDown,{size:"16"}):e.jsx(A.IconChevronRight,{size:"16"})})}),n.map(l=>e.jsx(t.TableCell,{align:l.align,children:X(a,l)},String(l.key))),f&&e.jsx(t.TableCell,{align:"right",className:"data-table-row-actions-cell",children:e.jsx("div",{className:"data-table-row-actions",children:(typeof d=="function"?d(a):d).map(l=>e.jsx(se,{action:l,item:a},l.key))})})]},a.id)];return s&&i.push(e.jsx(t.TableRow,{id:`${a.id}-nested`,className:"data-table-nested-row",children:e.jsx(t.TableCell,{colSpan:n.length+1+(f?1:0),className:"data-table-nested-cell",children:e.jsx(M,{columns:T,data:(r==null?void 0:r.data)??[],isLoading:!r||r.status==="loading",loadingMessage:B,emptyMessage:F,searchKeys:G,searchPlaceholder:H,actions:j==null?void 0:j(a),pageSize:$??b})})},`${a.id}-nested`)),i})})]}),e.jsx(K.Pagination,{page:C,totalPages:y,onPageChange:v,previousLabel:I,nextLabel:E})]})}exports.DataTable=M;
2
2
  //# sourceMappingURL=DataTable.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("../../../vendor/clsx/dist/clsx.cjs"),i=require("react");;/* empty css */const y=require("../../primitives/Tooltip/Tooltip.cjs"),z=require("../../icons/IconInfo.cjs"),B=require("../../icons/IconChevronDown.cjs"),u=require("../../primitives/IconButton/IconButton.cjs"),S=i.forwardRef(function({title:g,description:o,descriptionButtonLabel:x,headerActions:n,isCollapsible:s,collapseButtonLabel:m,expandButtonLabel:h,collapsed:a,defaultCollapsed:j,onCollapsedChange:r,children:w,className:f,...v},I){const d=i.useId(),c=a!==void 0,[p,N]=i.useState(j??!1),t=s===!0&&(c?a===!0:p);function q(){const l=!t;c||N(l),r==null||r(l)}return e.jsxs("div",{ref:I,className:b.clsx("widget",f),...v,"data-collapsed":t||void 0,children:[e.jsxs("div",{className:"widget-header widget-drag-handle",children:[e.jsxs("span",{className:"widget-header-title-group",children:[e.jsx("span",{className:"widget-header-title",children:g}),o&&e.jsx(y.Tooltip,{content:o,placement:"bottom",offset:4,children:e.jsx(u.IconButton,{"aria-label":x,variant:"subtle",size:"small",className:"widget-header-description-trigger",children:e.jsx(z.IconInfo,{size:"14"})})})]}),(n||s)&&e.jsxs("div",{className:"widget-header-actions",children:[n,s&&e.jsx(u.IconButton,{"aria-label":t?h:m,"aria-expanded":!t,"aria-controls":d,variant:"subtle",size:"small",className:"widget-header-collapse-trigger",onPress:q,children:e.jsx(B.IconChevronDown,{size:"16",className:"widget-header-collapse-indicator"})})]})]}),e.jsx("div",{id:d,className:"widget-body",hidden:t,children:w})]})});exports.Widget=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("../../../vendor/clsx/dist/clsx.cjs"),r=require("react");;/* empty css */const y=require("../../primitives/Tooltip/Tooltip.cjs"),z=require("../../icons/IconInfo.cjs"),B=require("../../icons/IconChevronDown.cjs"),u=require("../../primitives/IconButton/IconButton.cjs"),R=r.forwardRef(function({title:g,description:o,descriptionButtonLabel:x,headerActions:n,isCollapsible:s,collapseButtonLabel:m,expandButtonLabel:h,collapsed:a,defaultCollapsed:j,onCollapsedChange:i,children:w,className:f,...v},I){const d=r.useId(),c=a!==void 0,[p,N]=r.useState(j??!1),t=s===!0&&(c?a===!0:p);function q(){const l=!t;c||N(l),i==null||i(l)}return e.jsxs("div",{ref:I,className:b.clsx("widget",f),...v,"data-collapsed":t||void 0,children:[e.jsxs("div",{className:"widget-header widget-drag-handle",children:[e.jsxs("span",{className:"widget-header-title-group",children:[e.jsx("span",{className:"widget-header-title",children:g}),o&&e.jsx(y.Tooltip,{content:o,placement:"bottom",offset:4,children:e.jsx(u.IconButton,{"aria-label":x,variant:"subtle",size:"small",className:"widget-header-description-trigger",children:e.jsx(z.IconInfo,{size:"14"})})})]}),(n||s)&&e.jsxs("div",{className:"widget-header-actions",children:[n,s&&e.jsx(u.IconButton,{"aria-label":t?h:m,"aria-expanded":!t,"aria-controls":d,variant:"subtle",size:"small",className:"widget-header-collapse-trigger",onPress:q,children:e.jsx(B.IconChevronDown,{size:"16",className:"widget-header-collapse-indicator"})})]})]}),e.jsx("div",{id:d,className:"widget-body",hidden:t,children:w})]})});exports.Widget=R;
2
2
  //# sourceMappingURL=Widget.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),A=require("../../../vendor/clsx/dist/clsx.cjs"),D=require("react"),l=require("../../../_virtual/index.cjs");;/* empty css */;/* empty css */;/* empty css */const G=l.WidthProvider(l),T=".widget-drag-handle",_=".widget-header-actions";function S({layout:c,onLayoutChange:r,cols:u=12,rowHeight:o=80,isEditable:n=!1,isDraggable:m,isResizable:E,className:q,style:R,children:i}){const b=c.map(({id:e,x:t,y:a,w:s,h:d})=>({i:e,x:t,y:a,w:s,h:d}));function x(e){r==null||r(e.map(({i:t,x:a,y:s,w:d,h:y})=>({id:t,x:a,y:s,w:d,h:y})))}return g.jsx(G,{className:A.clsx("widget-grid",q),style:R,layout:b,cols:u,rowHeight:o,isDraggable:m??n,isResizable:E??n,draggableHandle:T,draggableCancel:_,onLayoutChange:x,children:(Array.isArray(i)?i:[i]).map(e=>D.isValidElement(e)?g.jsx("div",{className:"widget-grid-item",children:e},e.key):e)})}exports.WidgetGrid=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("../../../vendor/clsx/dist/clsx.cjs"),D=require("react"),c=require("../../../_virtual/index.cjs");;/* empty css */;/* empty css */;/* empty css */const G=c.WidthProvider(c),T=".widget-drag-handle",_=".widget-header-actions";function S({layout:g,onLayoutChange:r,cols:u=12,rowHeight:o=80,isEditable:n=!1,isDraggable:m,isResizable:E,className:R,style:q,children:i}){const b=g.map(({id:e,x:t,y:a,w:s,h:d})=>({i:e,x:t,y:a,w:s,h:d}));function x(e){r==null||r(e.map(({i:t,x:a,y:s,w:d,h:y})=>({id:t,x:a,y:s,w:d,h:y})))}return l.jsx(G,{className:A.clsx("widget-grid",R),style:q,layout:b,cols:u,rowHeight:o,isDraggable:m??n,isResizable:E??n,draggableHandle:T,draggableCancel:_,onLayoutChange:x,children:(Array.isArray(i)?i:[i]).map(e=>D.isValidElement(e)?l.jsx("div",{className:"widget-grid-item",children:e},e.key):e)})}exports.WidgetGrid=S;
2
2
  //# sourceMappingURL=WidgetGrid.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),l=require("../../../vendor/clsx/dist/clsx.cjs"),d=require("react"),i=require("react-aria-components");;/* empty css */const B=d.forwardRef(function({className:e,size:r="medium",variant:s="primary",...t},o){const c=l.clsx(e,"button",`button-size-${r}`,`button-variant-${s}`),{style:h,...u}=t;return m(t)?a.jsx(i.Link,{...u,className:c,ref:o,children:t.children}):a.jsx(i.Button,{...u,className:c,ref:o,children:t.children})}),b=d.forwardRef(function({className:e,size:r="medium",variant:s="danger-primary",...t},o){const c=l.clsx(e,"button",`button-size-${r}`,`button-variant-${s}`),{style:h,...u}=t;return m(t)?a.jsx(i.Link,{...u,className:c,ref:o,children:t.children}):a.jsx(i.Button,{...u,className:c,ref:o,children:t.children})});function m(n){return"href"in n}const x=({align:n="start",className:e,...r})=>{const s=l.clsx(e,"button-group",`button-group-align-${n}`);return a.jsx("div",{className:s,...r})};exports.Button=B;exports.ButtonDanger=b;exports.ButtonGroup=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),l=require("../../../vendor/clsx/dist/clsx.cjs"),d=require("react"),i=require("react-aria-components");;/* empty css */const b=d.forwardRef(function({className:e,size:r="medium",variant:s="primary",...t},o){const c=l.clsx(e,"button",`button-size-${r}`,`button-variant-${s}`),{style:h,...u}=t;return m(t)?a.jsx(i.Link,{...u,className:c,ref:o,children:t.children}):a.jsx(i.Button,{...u,className:c,ref:o,children:t.children})}),x=d.forwardRef(function({className:e,size:r="medium",variant:s="danger-primary",...t},o){const c=l.clsx(e,"button",`button-size-${r}`,`button-variant-${s}`),{style:h,...u}=t;return m(t)?a.jsx(i.Link,{...u,className:c,ref:o,children:t.children}):a.jsx(i.Button,{...u,className:c,ref:o,children:t.children})});function m(n){return"href"in n}const B=({align:n="start",className:e,...r})=>{const s=l.clsx(e,"button-group",`button-group-align-${n}`);return a.jsx("div",{className:s,...r})};exports.Button=b;exports.ButtonDanger=x;exports.ButtonGroup=B;
2
2
  //# sourceMappingURL=Button.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react");;/* empty css */const a=require("../IconButton/IconButton.cjs"),l=require("../../icons/IconCheck.cjs"),d=require("../../icons/IconCopy.cjs");function u({text:c,copyLabel:n="Copy",copiedLabel:i="Copied"}){const[o,t]=s.useState(!1);function r(){navigator.clipboard.writeText(c).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)}).catch(()=>{})}return e.jsxs("div",{className:"codeblock","data-copied":o||void 0,children:[e.jsx("code",{className:"codeblock-text",children:c}),e.jsx(a.IconButton,{"aria-label":o?i:n,variant:"subtle",size:"small",onPress:r,children:o?e.jsx(l.IconCheck,{}):e.jsx(d.IconCopy,{})})]})}exports.CodeBlock=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react");;/* empty css */const a=require("../IconButton/IconButton.cjs"),l=require("../../icons/IconCheck.cjs"),d=require("../../icons/IconCopy.cjs");function u({text:c,copyLabel:n="Copy",copiedLabel:i="Copied"}){const[o,t]=r.useState(!1);function s(){navigator.clipboard.writeText(c).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)}).catch(()=>{})}return e.jsxs("div",{className:"codeblock","data-copied":o||void 0,children:[e.jsx("code",{className:"codeblock-text",children:c}),e.jsx(a.IconButton,{"aria-label":o?i:n,variant:"subtle",size:"small",onPress:s,children:o?e.jsx(l.IconCheck,{}):e.jsx(d.IconCopy,{})})]})}exports.CodeBlock=u;
2
2
  //# sourceMappingURL=CodeBlock.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("../../../vendor/clsx/dist/clsx.cjs"),u=require("react"),F=require("../../../vendor/@monaco-editor/react/dist/index.cjs");;/* empty css */const m=require("../Fieldset/Fieldset.cjs"),g=require("../Button/Button.cjs");function j({value:d,defaultValue:s,onChange:o,language:i="javascript",theme:n="vs",height:r="300px",isDisabled:t=!1,isReadOnly:a=!1,options:f,className:p,editorRef:l}){const[c,v]=u.useState(!1),E=u.useRef(null);function N(x,R){l&&(l.current=x),x.onDidFocusEditorWidget(()=>v(!0)),x.onDidBlurEditorWidget(()=>v(!1))}const C=h.clsx("code-editor-wrapper",p,{"code-editor-focused":c,"code-editor-disabled":t});return e.jsx("div",{ref:E,className:C,"data-disabled":t||void 0,style:{height:r},children:e.jsx(F.default,{height:"100%",value:d,defaultValue:s,language:i,theme:n,onChange:o,onMount:N,loading:e.jsx("div",{className:"code-editor-loading"}),options:{readOnly:a||t,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbersMinChars:3,...f}})})}function q({className:d,label:s,description:o,errorMessage:i,...n}){const r=u.useId(),t=h.clsx(d,"field");return e.jsxs("div",{className:t,children:[s&&e.jsx(m.Label,{htmlFor:r,children:s}),e.jsx(j,{...n}),o&&e.jsx(m.Description,{children:o}),i&&typeof i=="string"&&e.jsx(m.FieldError,{children:i})]})}const y="Clique no editor e pressione F1 para visualizar os atalhos do teclado";function B({title:d,shortcutHint:s=y,onBeautify:o,className:i,isDisabled:n=!1,isReadOnly:r=!1,...t}){const a=u.useRef(null),f=!n&&!r;function p(){var l,c;if(o){o();return}(c=(l=a.current)==null?void 0:l.getAction("editor.action.formatDocument"))==null||c.run()}return e.jsxs("div",{className:h.clsx("code-editor-panel",i),children:[f&&e.jsxs("div",{className:"code-editor-panel-header",children:[e.jsxs("div",{className:"code-editor-panel-title-group",children:[e.jsx("span",{className:"code-editor-panel-title",children:d}),s&&e.jsxs("span",{className:"code-editor-panel-hint",children:["(",s,")"]})]}),e.jsx(g.Button,{size:"small",variant:"primary",onPress:p,children:"Beautify"})]}),e.jsx(j,{...t,isDisabled:n,isReadOnly:r,editorRef:a})]})}exports.CodeEditor=j;exports.CodeEditorField=q;exports.CodeEditorPanel=B;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("../../../vendor/clsx/dist/clsx.cjs"),u=require("react"),F=require("../../../vendor/@monaco-editor/react/dist/index.cjs");;/* empty css */const m=require("../Fieldset/Fieldset.cjs"),g=require("../Button/Button.cjs");function j({value:d,defaultValue:s,onChange:o,language:i="javascript",theme:n="vs",height:r="300px",isDisabled:t=!1,isReadOnly:a=!1,options:f,className:p,editorRef:l}){const[c,v]=u.useState(!1),E=u.useRef(null);function N(x,B){l&&(l.current=x),x.onDidFocusEditorWidget(()=>v(!0)),x.onDidBlurEditorWidget(()=>v(!1))}const C=h.clsx("code-editor-wrapper",p,{"code-editor-focused":c,"code-editor-disabled":t});return e.jsx("div",{ref:E,className:C,"data-disabled":t||void 0,style:{height:r},children:e.jsx(F.default,{height:"100%",value:d,defaultValue:s,language:i,theme:n,onChange:o,onMount:N,loading:e.jsx("div",{className:"code-editor-loading"}),options:{readOnly:a||t,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbersMinChars:3,...f}})})}function q({className:d,label:s,description:o,errorMessage:i,...n}){const r=u.useId(),t=h.clsx(d,"field");return e.jsxs("div",{className:t,children:[s&&e.jsx(m.Label,{htmlFor:r,children:s}),e.jsx(j,{...n}),o&&e.jsx(m.Description,{children:o}),i&&typeof i=="string"&&e.jsx(m.FieldError,{children:i})]})}const y="Clique no editor e pressione F1 para visualizar os atalhos do teclado";function R({title:d,shortcutHint:s=y,onBeautify:o,className:i,isDisabled:n=!1,isReadOnly:r=!1,...t}){const a=u.useRef(null),f=!n&&!r;function p(){var l,c;if(o){o();return}(c=(l=a.current)==null?void 0:l.getAction("editor.action.formatDocument"))==null||c.run()}return e.jsxs("div",{className:h.clsx("code-editor-panel",i),children:[f&&e.jsxs("div",{className:"code-editor-panel-header",children:[e.jsxs("div",{className:"code-editor-panel-title-group",children:[e.jsx("span",{className:"code-editor-panel-title",children:d}),s&&e.jsxs("span",{className:"code-editor-panel-hint",children:["(",s,")"]})]}),e.jsx(g.Button,{size:"small",variant:"primary",onPress:p,children:"Beautify"})]}),e.jsx(j,{...t,isDisabled:n,isReadOnly:r,editorRef:a})]})}exports.CodeEditor=j;exports.CodeEditorField=q;exports.CodeEditorPanel=R;
2
2
  //# sourceMappingURL=CodeEditor.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("../../../vendor/clsx/dist/clsx.cjs"),g=require("react"),s=require("react-aria-components");;/* empty css */const q=require("../../hooks/useOverlayPortal.cjs"),t=require("../Fieldset/Fieldset.cjs"),f=require("../Input/Input.cjs"),p=require("../../icons/IconChevronDown.cjs"),x=require("../ListBox/ListBox.cjs"),I=require("../../icons/IconCheck.cjs");function N({className:o,label:r,description:n,errorMessage:c,placeholder:i,children:b,items:d,...j}){const C=u.clsx(o,"combobox-container"),a=g.useRef(null),h=q.useOverlayPortalContainer();return e.jsx(m,{className:C,...j,children:e.jsxs(t.Field,{children:[r&&e.jsx(t.Label,{children:r}),e.jsxs(s.Group,{className:"combobox",children:[e.jsx(f.Input,{className:"combobox-input",placeholder:i,onPointerDown:B=>{var l;document.activeElement===B.currentTarget&&((l=a.current)==null||l.click())}}),e.jsx(s.Button,{ref:a,className:"combobox-trigger",children:e.jsx(p.IconChevronDown,{"aria-hidden":"true"})})]}),e.jsx(s.Popover,{UNSTABLE_portalContainer:h,children:e.jsx(x.ListBox,{items:d,children:b})}),n&&e.jsx(t.Description,{children:n}),e.jsx(t.FieldError,{children:c})]})})}function m({...o}){return e.jsx(s.ComboBox,{menuTrigger:"focus",...o})}function v({children:o,className:r,...n}){const c=u.clsx(r,"combobox-item"),i=typeof o=="string"?o:"";return e.jsx(x.ListBoxItem,{textValue:i,className:c,...n,children:e.jsxs(e.Fragment,{children:[e.jsx(I.IconCheck,{className:"combobox-item-check"}),o]})})}exports.ComboBox=m;exports.ComboBoxField=N;exports.ComboBoxItem=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("../../../vendor/clsx/dist/clsx.cjs"),x=require("react"),c=require("react-aria-components");;/* empty css */const v=require("../../hooks/useOverlayPortal.cjs"),s=require("../Fieldset/Fieldset.cjs"),g=require("../Input/Input.cjs"),B=require("../../icons/IconChevronDown.cjs"),b=require("../ListBox/ListBox.cjs"),q=require("../../icons/IconCheck.cjs");function N(o){const n=o.getRootNode();return n instanceof ShadowRoot||n instanceof Document?n.activeElement:null}function I(o){x.useEffect(()=>{const n=o.current;if(!n)return;function t(r){r.preventDefault()}return n.addEventListener("mousedown",t),()=>n.removeEventListener("mousedown",t)},[o])}function F({className:o,label:n,description:t,errorMessage:r,placeholder:i,children:f,items:j,...p}){const h=m.clsx(o,"combobox-container"),u=x.useRef(null);I(u);const C=v.useOverlayPortalContainer();return e.jsx(d,{className:h,...p,children:e.jsxs(s.Field,{children:[n&&e.jsx(s.Label,{children:n}),e.jsxs(c.Group,{className:"combobox",children:[e.jsx(g.Input,{className:"combobox-input",placeholder:i,onPointerDown:a=>{var l;N(a.currentTarget)===a.currentTarget&&((l=u.current)==null||l.click())}}),e.jsx(c.Button,{ref:u,className:"combobox-trigger",children:e.jsx(B.IconChevronDown,{"aria-hidden":"true"})})]}),e.jsx(c.Popover,{className:"combobox-popover",UNSTABLE_portalContainer:C,children:e.jsx(b.ListBox,{items:j,children:f})}),t&&e.jsx(s.Description,{children:t}),e.jsx(s.FieldError,{children:r})]})})}function d({...o}){return e.jsx(c.ComboBox,{menuTrigger:"focus",...o})}function E({children:o,className:n,...t}){const r=m.clsx(n,"combobox-item"),i=typeof o=="string"?o:"";return e.jsx(b.ListBoxItem,{textValue:i,className:r,...t,children:e.jsxs(e.Fragment,{children:[e.jsx(q.IconCheck,{className:"combobox-item-check"}),o]})})}exports.ComboBox=d;exports.ComboBoxField=F;exports.ComboBoxItem=E;
2
2
  //# sourceMappingURL=ComboBox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.cjs","sources":["../../../../../src/ui/primitives/ComboBox/ComboBox.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useOverlayPortalContainer } from \"hooks\";\nimport { IconCheck, IconChevronDown } from \"icons\";\nimport {\n Description,\n Field,\n FieldError,\n Input,\n ListBox,\n ListBoxItem,\n Label,\n SharedFieldProps,\n type ListBoxItemProps,\n} from \"primitives\";\nimport { useRef } from \"react\";\nimport {\n Button as RACButton,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Popover as RACPopover,\n type ComboBoxProps as RACComboBoxProps,\n} from \"react-aria-components\";\nimport \"./combobox.css\";\n\nexport interface ComboBoxFieldProps<T extends object>\n extends Omit<ComboBoxProps<T>, \"children\">,\n SharedFieldProps {\n items?: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\nexport function ComboBoxField<T extends object>({\n className,\n label,\n description,\n errorMessage,\n placeholder,\n children,\n items,\n ...props\n}: ComboBoxFieldProps<T>) {\n const classNames = clsx(className, \"combobox-container\");\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n // Sem container explícito o dropdown faz portal no document.body — fora da\n // shadow root do MFE, sem CSS. Ver ui/hooks/useOverlayPortal.\n const portalContainer = useOverlayPortalContainer();\n return (\n <ComboBox className={classNames} {...props}>\n <Field>\n {label && <Label>{label}</Label>}\n <RACGroup className=\"combobox\">\n <Input\n className=\"combobox-input\"\n placeholder={placeholder}\n onPointerDown={(event) => {\n if (document.activeElement === event.currentTarget) {\n triggerRef.current?.click();\n }\n }}\n />\n <RACButton ref={triggerRef} className=\"combobox-trigger\">\n <IconChevronDown aria-hidden=\"true\" />\n </RACButton>\n </RACGroup>\n <RACPopover UNSTABLE_portalContainer={portalContainer}>\n <ListBox items={items}>{children}</ListBox>\n </RACPopover>\n {description && <Description>{description}</Description>}\n <FieldError>{errorMessage}</FieldError>\n </Field>\n </ComboBox>\n );\n}\n\nexport type ComboBoxProps<T extends object> = RACComboBoxProps<T>;\nexport function ComboBox<T extends object>({ ...props }: ComboBoxProps<T>) {\n return <RACComboBox<T> menuTrigger=\"focus\" {...props} />;\n}\n\nexport type ComboBoxItemProps = ListBoxItemProps;\nexport function ComboBoxItem({ children, className, ...props }: ComboBoxItemProps) {\n const classNames = clsx(className, \"combobox-item\");\n const textValue = typeof children === \"string\" ? children : \"\";\n return (\n <ListBoxItem textValue={textValue} className={classNames} {...props}>\n <>\n <IconCheck className=\"combobox-item-check\" />\n {children}\n </>\n </ListBoxItem>\n );\n}\n"],"names":["ComboBoxField","className","label","description","errorMessage","placeholder","children","items","props","classNames","clsx","triggerRef","useRef","portalContainer","useOverlayPortalContainer","ComboBox","Field","jsx","Label","jsxs","RACGroup","Input","event","_a","RACButton","IconChevronDown","RACPopover","ListBox","Description","FieldError","RACComboBox","ComboBoxItem","textValue","ListBoxItem","Fragment","IconCheck"],"mappings":"2eA8BO,SAASA,EAAgC,CAC9C,UAAAC,EACA,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,MAAAC,EACA,GAAGC,CACL,EAA0B,CACxB,M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B,EAAa,GAAGD,EAC5D,SAAAW,EAAAA,KAAAe,EAAAA,SAAA,CACE,SAAA,CAAAjB,EAAAA,IAACkB,EAAAA,UAAA,CAAU,UAAU,qBAAA,CAAsB,EAC1C7B,CAAA,CAAA,CACH,CAAA,CACF,CAEJ"}
1
+ {"version":3,"file":"ComboBox.cjs","sources":["../../../../../src/ui/primitives/ComboBox/ComboBox.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useOverlayPortalContainer } from \"hooks\";\nimport { IconCheck, IconChevronDown } from \"icons\";\nimport {\n Description,\n Field,\n FieldError,\n Input,\n ListBox,\n ListBoxItem,\n Label,\n SharedFieldProps,\n type ListBoxItemProps,\n} from \"primitives\";\nimport { useEffect, useRef } from \"react\";\nimport {\n Button as RACButton,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Popover as RACPopover,\n type ComboBoxProps as RACComboBoxProps,\n} from \"react-aria-components\";\nimport \"./combobox.css\";\n\nexport interface ComboBoxFieldProps<T extends object>\n extends Omit<ComboBoxProps<T>, \"children\">,\n SharedFieldProps {\n items?: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\n\n// `document.activeElement` para no host da shadow root: quem sabe o que está focado\n// dentro dela é a própria raiz. Ver ui/hooks/useOverlayPortal.\nfunction activeElementOf(element: Element): Element | null {\n const root = element.getRootNode();\n return root instanceof ShadowRoot || root instanceof Document\n ? root.activeElement\n : null;\n}\n\n// O react-aria pede `preventFocusOnPress` para o botão do dropdown, mas a implementação\n// dele guarda `document.activeElement` — que dentro de uma shadow root devolve o host, e\n// não o input. O botão fica com o foco de verdade, o input nunca mais recebe blur, e a\n// partir daí só escolher um item fecha o dropdown: clicar fora não fecha nada. Impedir o\n// padrão do mousedown é o que mantém o foco no input, dentro e fora da shadow root.\n//\n// Via listener nativo, e não por prop: o `useButton` do react-aria só repassa ao <button>\n// os handlers que ele mesmo declara, e descarta um `onMouseDown` vindo de fora.\nfunction useKeepFocusOnInput(triggerRef: React.RefObject<HTMLButtonElement | null>): void {\n useEffect(() => {\n const trigger: HTMLButtonElement | null = triggerRef.current;\n if (!trigger) return undefined;\n\n function preventFocus(event: MouseEvent): void {\n event.preventDefault();\n }\n\n trigger.addEventListener(\"mousedown\", preventFocus);\n return () => trigger.removeEventListener(\"mousedown\", preventFocus);\n }, [triggerRef]);\n}\n\nexport function ComboBoxField<T extends object>({\n className,\n label,\n description,\n errorMessage,\n placeholder,\n children,\n items,\n ...props\n}: ComboBoxFieldProps<T>) {\n const classNames = clsx(className, \"combobox-container\");\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useKeepFocusOnInput(triggerRef);\n // Sem container explícito o dropdown faz portal no document.body — fora da\n // shadow root do MFE, sem CSS. Ver ui/hooks/useOverlayPortal.\n const portalContainer = useOverlayPortalContainer();\n return (\n <ComboBox className={classNames} {...props}>\n <Field>\n {label && <Label>{label}</Label>}\n <RACGroup className=\"combobox\">\n <Input\n className=\"combobox-input\"\n placeholder={placeholder}\n onPointerDown={(event) => {\n if (activeElementOf(event.currentTarget) === event.currentTarget) {\n triggerRef.current?.click();\n }\n }}\n />\n <RACButton ref={triggerRef} className=\"combobox-trigger\">\n <IconChevronDown aria-hidden=\"true\" />\n </RACButton>\n </RACGroup>\n <RACPopover\n className=\"combobox-popover\"\n UNSTABLE_portalContainer={portalContainer}\n >\n <ListBox items={items}>{children}</ListBox>\n </RACPopover>\n {description && <Description>{description}</Description>}\n <FieldError>{errorMessage}</FieldError>\n </Field>\n </ComboBox>\n );\n}\n\nexport type ComboBoxProps<T extends object> = RACComboBoxProps<T>;\nexport function ComboBox<T extends object>({ ...props }: ComboBoxProps<T>) {\n return <RACComboBox<T> menuTrigger=\"focus\" {...props} />;\n}\n\nexport type ComboBoxItemProps = ListBoxItemProps;\nexport function ComboBoxItem({ children, className, ...props }: ComboBoxItemProps) {\n const classNames = clsx(className, \"combobox-item\");\n const textValue = typeof children === \"string\" ? children : \"\";\n return (\n <ListBoxItem textValue={textValue} className={classNames} {...props}>\n <>\n <IconCheck className=\"combobox-item-check\" />\n {children}\n </>\n </ListBoxItem>\n );\n}\n"],"names":["activeElementOf","element","root","useKeepFocusOnInput","triggerRef","useEffect","trigger","preventFocus","event","ComboBoxField","className","label","description","errorMessage","placeholder","children","items","props","classNames","clsx","useRef","portalContainer","useOverlayPortalContainer","ComboBox","Field","jsx","Label","jsxs","RACGroup","Input","_a","RACButton","IconChevronDown","RACPopover","ListBox","Description","FieldError","RACComboBox","ComboBoxItem","textValue","ListBoxItem","Fragment","IconCheck"],"mappings":"2eAiCA,SAASA,EAAgBC,EAAkC,CACzD,MAAMC,EAAOD,EAAQ,YAAA,EACrB,OAAOC,aAAgB,YAAcA,aAAgB,SACjDA,EAAK,cACL,IACN,CAUA,SAASC,EAAoBC,EAA6D,CACxFC,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAoCF,EAAW,QACrD,GAAI,CAACE,EAAS,OAEd,SAASC,EAAaC,EAAyB,CAC7CA,EAAM,eAAA,CACR,CAEA,OAAAF,EAAQ,iBAAiB,YAAaC,CAAY,EAC3C,IAAMD,EAAQ,oBAAoB,YAAaC,CAAY,CACpE,EAAG,CAACH,CAAU,CAAC,CACjB,CAEO,SAASK,EAAgC,CAC9C,UAAAC,EACA,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,MAAAC,EACA,GAAGC,CACL,EAA0B,CACxB,MAAMC,EAAaC,EAAAA,KAAKT,EAAW,oBAAoB,EACjDN,EAAagB,EAAAA,OAAiC,IAAI,EACxDjB,EAAoBC,CAAU,EAG9B,MAAMiB,EAAkBC,EAAAA,0BAAA,EACxB,aACGC,EAAA,CAAS,UAAWL,EAAa,GAAGD,EACnC,gBAACO,EAAAA,MAAA,CACE,SAAA,CAAAb,GAASc,EAAAA,IAACC,EAAAA,OAAO,SAAAf,CAAA,CAAM,EACxBgB,EAAAA,KAACC,EAAAA,MAAA,CAAS,UAAU,WAClB,SAAA,CAAAH,EAAAA,IAACI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/dist/clsx.js";
3
- import { useRef as h } from "react";
4
- import { Group as C, Button as g, Popover as B, ComboBox as N } from "react-aria-components";
1
+ import { jsx as r, jsxs as i, Fragment as d } from "react/jsx-runtime";
2
+ import { clsx as u } from "../../../vendor/clsx/dist/clsx.js";
3
+ import { useRef as h, useEffect as g } from "react";
4
+ import { Group as v, Button as N, Popover as C, ComboBox as B } from "react-aria-components";
5
5
  /* empty css */
6
- import { useOverlayPortalContainer as I } from "../../hooks/useOverlayPortal.js";
7
- import { Field as v, Label as F, Description as L, FieldError as k } from "../Fieldset/Fieldset.js";
6
+ import { useOverlayPortalContainer as E } from "../../hooks/useOverlayPortal.js";
7
+ import { Field as F, Label as I, Description as L, FieldError as w } from "../Fieldset/Fieldset.js";
8
8
  import { Input as D } from "../Input/Input.js";
9
- import { IconChevronDown as E } from "../../icons/IconChevronDown.js";
10
- import { ListBox as P, ListBoxItem as T } from "../ListBox/ListBox.js";
11
- import { IconCheck as j } from "../../icons/IconCheck.js";
12
- function z({
13
- className: r,
9
+ import { IconChevronDown as T } from "../../icons/IconChevronDown.js";
10
+ import { ListBox as k, ListBoxItem as O } from "../ListBox/ListBox.js";
11
+ import { IconCheck as P } from "../../icons/IconCheck.js";
12
+ function R(o) {
13
+ const e = o.getRootNode();
14
+ return e instanceof ShadowRoot || e instanceof Document ? e.activeElement : null;
15
+ }
16
+ function j(o) {
17
+ g(() => {
18
+ const e = o.current;
19
+ if (!e) return;
20
+ function t(n) {
21
+ n.preventDefault();
22
+ }
23
+ return e.addEventListener("mousedown", t), () => e.removeEventListener("mousedown", t);
24
+ }, [o]);
25
+ }
26
+ function J({
27
+ className: o,
14
28
  label: e,
15
29
  description: t,
16
30
  errorMessage: n,
17
- placeholder: c,
31
+ placeholder: m,
18
32
  children: l,
19
- items: u,
20
- ...f
33
+ items: f,
34
+ ...p
21
35
  }) {
22
- const p = a(r, "combobox-container"), i = h(null), x = I();
23
- return /* @__PURE__ */ o(w, { className: p, ...f, children: /* @__PURE__ */ m(v, { children: [
24
- e && /* @__PURE__ */ o(F, { children: e }),
25
- /* @__PURE__ */ m(C, { className: "combobox", children: [
26
- /* @__PURE__ */ o(
36
+ const x = u(o, "combobox-container"), c = h(null);
37
+ j(c);
38
+ const b = E();
39
+ return /* @__PURE__ */ r(y, { className: x, ...p, children: /* @__PURE__ */ i(F, { children: [
40
+ e && /* @__PURE__ */ r(I, { children: e }),
41
+ /* @__PURE__ */ i(v, { className: "combobox", children: [
42
+ /* @__PURE__ */ r(
27
43
  D,
28
44
  {
29
45
  className: "combobox-input",
30
- placeholder: c,
31
- onPointerDown: (b) => {
32
- var s;
33
- document.activeElement === b.currentTarget && ((s = i.current) == null || s.click());
46
+ placeholder: m,
47
+ onPointerDown: (s) => {
48
+ var a;
49
+ R(s.currentTarget) === s.currentTarget && ((a = c.current) == null || a.click());
34
50
  }
35
51
  }
36
52
  ),
37
- /* @__PURE__ */ o(g, { ref: i, className: "combobox-trigger", children: /* @__PURE__ */ o(E, { "aria-hidden": "true" }) })
53
+ /* @__PURE__ */ r(N, { ref: c, className: "combobox-trigger", children: /* @__PURE__ */ r(T, { "aria-hidden": "true" }) })
38
54
  ] }),
39
- /* @__PURE__ */ o(B, { UNSTABLE_portalContainer: x, children: /* @__PURE__ */ o(P, { items: u, children: l }) }),
40
- t && /* @__PURE__ */ o(L, { children: t }),
41
- /* @__PURE__ */ o(k, { children: n })
55
+ /* @__PURE__ */ r(
56
+ C,
57
+ {
58
+ className: "combobox-popover",
59
+ UNSTABLE_portalContainer: b,
60
+ children: /* @__PURE__ */ r(k, { items: f, children: l })
61
+ }
62
+ ),
63
+ t && /* @__PURE__ */ r(L, { children: t }),
64
+ /* @__PURE__ */ r(w, { children: n })
42
65
  ] }) });
43
66
  }
44
- function w({ ...r }) {
45
- return /* @__PURE__ */ o(N, { menuTrigger: "focus", ...r });
67
+ function y({ ...o }) {
68
+ return /* @__PURE__ */ r(B, { menuTrigger: "focus", ...o });
46
69
  }
47
- function H({ children: r, className: e, ...t }) {
48
- const n = a(e, "combobox-item");
49
- return /* @__PURE__ */ o(T, { textValue: typeof r == "string" ? r : "", className: n, ...t, children: /* @__PURE__ */ m(d, { children: [
50
- /* @__PURE__ */ o(j, { className: "combobox-item-check" }),
51
- r
70
+ function M({ children: o, className: e, ...t }) {
71
+ const n = u(e, "combobox-item");
72
+ return /* @__PURE__ */ r(O, { textValue: typeof o == "string" ? o : "", className: n, ...t, children: /* @__PURE__ */ i(d, { children: [
73
+ /* @__PURE__ */ r(P, { className: "combobox-item-check" }),
74
+ o
52
75
  ] }) });
53
76
  }
54
77
  export {
55
- w as ComboBox,
56
- z as ComboBoxField,
57
- H as ComboBoxItem
78
+ y as ComboBox,
79
+ J as ComboBoxField,
80
+ M as ComboBoxItem
58
81
  };
59
82
  //# sourceMappingURL=ComboBox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ComboBox.js","sources":["../../../../../src/ui/primitives/ComboBox/ComboBox.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useOverlayPortalContainer } from \"hooks\";\nimport { IconCheck, IconChevronDown } from \"icons\";\nimport {\n Description,\n Field,\n FieldError,\n Input,\n ListBox,\n ListBoxItem,\n Label,\n SharedFieldProps,\n type ListBoxItemProps,\n} from \"primitives\";\nimport { useRef } from \"react\";\nimport {\n Button as RACButton,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Popover as RACPopover,\n type ComboBoxProps as RACComboBoxProps,\n} from \"react-aria-components\";\nimport \"./combobox.css\";\n\nexport interface ComboBoxFieldProps<T extends object>\n extends Omit<ComboBoxProps<T>, \"children\">,\n SharedFieldProps {\n items?: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\nexport function ComboBoxField<T extends object>({\n className,\n label,\n description,\n errorMessage,\n placeholder,\n children,\n items,\n ...props\n}: ComboBoxFieldProps<T>) {\n const classNames = clsx(className, \"combobox-container\");\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n // Sem container explícito o dropdown faz portal no document.body — fora da\n // shadow root do MFE, sem CSS. Ver ui/hooks/useOverlayPortal.\n const portalContainer = useOverlayPortalContainer();\n return (\n <ComboBox className={classNames} {...props}>\n <Field>\n {label && <Label>{label}</Label>}\n <RACGroup className=\"combobox\">\n <Input\n className=\"combobox-input\"\n placeholder={placeholder}\n onPointerDown={(event) => {\n if (document.activeElement === event.currentTarget) {\n triggerRef.current?.click();\n }\n }}\n />\n <RACButton ref={triggerRef} className=\"combobox-trigger\">\n <IconChevronDown aria-hidden=\"true\" />\n </RACButton>\n </RACGroup>\n <RACPopover UNSTABLE_portalContainer={portalContainer}>\n <ListBox items={items}>{children}</ListBox>\n </RACPopover>\n {description && <Description>{description}</Description>}\n <FieldError>{errorMessage}</FieldError>\n </Field>\n </ComboBox>\n );\n}\n\nexport type ComboBoxProps<T extends object> = RACComboBoxProps<T>;\nexport function ComboBox<T extends object>({ ...props }: ComboBoxProps<T>) {\n return <RACComboBox<T> menuTrigger=\"focus\" {...props} />;\n}\n\nexport type ComboBoxItemProps = ListBoxItemProps;\nexport function ComboBoxItem({ children, className, ...props }: ComboBoxItemProps) {\n const classNames = clsx(className, \"combobox-item\");\n const textValue = typeof children === \"string\" ? children : \"\";\n return (\n <ListBoxItem textValue={textValue} className={classNames} {...props}>\n <>\n <IconCheck className=\"combobox-item-check\" />\n {children}\n </>\n </ListBoxItem>\n );\n}\n"],"names":["ComboBoxField","className","label","description","errorMessage","placeholder","children","items","props","classNames","clsx","triggerRef","useRef","portalContainer","useOverlayPortalContainer","ComboBox","Field","jsx","Label","jsxs","RACGroup","Input","event","_a","RACButton","IconChevronDown","RACPopover","ListBox","Description","FieldError","RACComboBox","ComboBoxItem","ListBoxItem","Fragment","IconCheck"],"mappings":";;;;;;;;;;;AA8BO,SAASA,EAAgC;AAAA,EAC9C,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EAC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vB,WAAWG,GAAa,GAAGD,GAC5D,UAAA,gBAAAW,EAAAc,GAAA,EACE,UAAA;AAAA,IAAA,gBAAAhB,EAACiB,GAAA,EAAU,WAAU,sBAAA,CAAsB;AAAA,IAC1C5B;AAAA,EAAA,EAAA,CACH,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"ComboBox.js","sources":["../../../../../src/ui/primitives/ComboBox/ComboBox.tsx"],"sourcesContent":["import { clsx } from \"clsx\";\nimport { useOverlayPortalContainer } from \"hooks\";\nimport { IconCheck, IconChevronDown } from \"icons\";\nimport {\n Description,\n Field,\n FieldError,\n Input,\n ListBox,\n ListBoxItem,\n Label,\n SharedFieldProps,\n type ListBoxItemProps,\n} from \"primitives\";\nimport { useEffect, useRef } from \"react\";\nimport {\n Button as RACButton,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Popover as RACPopover,\n type ComboBoxProps as RACComboBoxProps,\n} from \"react-aria-components\";\nimport \"./combobox.css\";\n\nexport interface ComboBoxFieldProps<T extends object>\n extends Omit<ComboBoxProps<T>, \"children\">,\n SharedFieldProps {\n items?: Iterable<T>;\n children: React.ReactNode | ((item: T) => React.ReactNode);\n}\n\n// `document.activeElement` para no host da shadow root: quem sabe o que está focado\n// dentro dela é a própria raiz. Ver ui/hooks/useOverlayPortal.\nfunction activeElementOf(element: Element): Element | null {\n const root = element.getRootNode();\n return root instanceof ShadowRoot || root instanceof Document\n ? root.activeElement\n : null;\n}\n\n// O react-aria pede `preventFocusOnPress` para o botão do dropdown, mas a implementação\n// dele guarda `document.activeElement` — que dentro de uma shadow root devolve o host, e\n// não o input. O botão fica com o foco de verdade, o input nunca mais recebe blur, e a\n// partir daí só escolher um item fecha o dropdown: clicar fora não fecha nada. Impedir o\n// padrão do mousedown é o que mantém o foco no input, dentro e fora da shadow root.\n//\n// Via listener nativo, e não por prop: o `useButton` do react-aria só repassa ao <button>\n// os handlers que ele mesmo declara, e descarta um `onMouseDown` vindo de fora.\nfunction useKeepFocusOnInput(triggerRef: React.RefObject<HTMLButtonElement | null>): void {\n useEffect(() => {\n const trigger: HTMLButtonElement | null = triggerRef.current;\n if (!trigger) return undefined;\n\n function preventFocus(event: MouseEvent): void {\n event.preventDefault();\n }\n\n trigger.addEventListener(\"mousedown\", preventFocus);\n return () => trigger.removeEventListener(\"mousedown\", preventFocus);\n }, [triggerRef]);\n}\n\nexport function ComboBoxField<T extends object>({\n className,\n label,\n description,\n errorMessage,\n placeholder,\n children,\n items,\n ...props\n}: ComboBoxFieldProps<T>) {\n const classNames = clsx(className, \"combobox-container\");\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useKeepFocusOnInput(triggerRef);\n // Sem container explícito o dropdown faz portal no document.body — fora da\n // shadow root do MFE, sem CSS. Ver ui/hooks/useOverlayPortal.\n const portalContainer = useOverlayPortalContainer();\n return (\n <ComboBox className={classNames} {...props}>\n <Field>\n {label && <Label>{label}</Label>}\n <RACGroup className=\"combobox\">\n <Input\n className=\"combobox-input\"\n placeholder={placeholder}\n onPointerDown={(event) => {\n if (activeElementOf(event.currentTarget) === event.currentTarget) {\n triggerRef.current?.click();\n }\n }}\n />\n <RACButton ref={triggerRef} className=\"combobox-trigger\">\n <IconChevronDown aria-hidden=\"true\" />\n </RACButton>\n </RACGroup>\n <RACPopover\n className=\"combobox-popover\"\n UNSTABLE_portalContainer={portalContainer}\n >\n <ListBox items={items}>{children}</ListBox>\n </RACPopover>\n {description && <Description>{description}</Description>}\n <FieldError>{errorMessage}</FieldError>\n </Field>\n </ComboBox>\n );\n}\n\nexport type ComboBoxProps<T extends object> = RACComboBoxProps<T>;\nexport function ComboBox<T extends object>({ ...props }: ComboBoxProps<T>) {\n return <RACComboBox<T> menuTrigger=\"focus\" {...props} />;\n}\n\nexport type ComboBoxItemProps = ListBoxItemProps;\nexport function ComboBoxItem({ children, className, ...props }: ComboBoxItemProps) {\n const classNames = clsx(className, \"combobox-item\");\n const textValue = typeof children === \"string\" ? children : \"\";\n return (\n <ListBoxItem textValue={textValue} className={classNames} {...props}>\n <>\n <IconCheck className=\"combobox-item-check\" />\n {children}\n </>\n </ListBoxItem>\n );\n}\n"],"names":["activeElementOf","element","root","useKeepFocusOnInput","triggerRef","useEffect","trigger","preventFocus","event","ComboBoxField","className","label","description","errorMessage","placeholder","children","items","props","classNames","clsx","useRef","portalContainer","useOverlayPortalContainer","ComboBox","Field","jsx","Label","jsxs","RACGroup","Input","_a","RACButton","IconChevronDown","RACPopover","ListBox","Description","FieldError","RACComboBox","ComboBoxItem","ListBoxItem","Fragment","IconCheck"],"mappings":";;;;;;;;;;;AAiCA,SAASA,EAAgBC,GAAkC;AACzD,QAAMC,IAAOD,EAAQ,YAAA;AACrB,SAAOC,aAAgB,cAAcA,aAAgB,WACjDA,EAAK,gBACL;AACN;AAUA,SAASC,EAAoBC,GAA6D;AACxF,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAoCF,EAAW;AACrD,QAAI,CAACE,EAAS;AAEd,aAASC,EAAaC,GAAyB;AAC7C,MAAAA,EAAM,eAAA;AAAA,IACR;AAEA,WAAAF,EAAQ,iBAAiB,aAAaC,CAAY,GAC3C,MAAMD,EAAQ,oBAAoB,aAAaC,CAAY;AAAA,EACpE,GAAG,CAACH,CAAU,CAAC;AACjB;AAEO,SAASK,EAAgC;AAAA,EAC9C,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,GAA0B;AACxB,QAAMC,IAAaC,EAAKT,GAAW,oBAAoB,GACjDN,IAAagB,EAAiC,IAAI;AACxD,EAAAjB,EAAoBC,CAAU;AAG9B,QAAMiB,IAAkBC,EAAA;AACxB,2BACGC,GAAA,EAAS,WAAWL,GAAa,GAAGD,GACnC,4BAACO,GAAA,EACE,UAAA;AAAA,IAAAb,KAAS,gBAAAc,EAACC,KAAO,UAAAf,EAAA,CAAM;AAAA,IACxB,gBAAA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AAA,CACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("@internationalized/date"),ye=require("../../../vendor/clsx/dist/clsx.cjs"),h=require("react"),n=require("react-aria-components"),Le=require("./dateRangePresets.cjs");;/* empty css */const z=require("../../icons/IconCalendar.cjs"),Ie=require("../../icons/IconChevronDown.cjs"),G=require("../Text/Text.cjs"),Be=require("../../icons/IconCheck.cjs"),we=require("../../icons/IconChevronLeft.cjs"),Pe=require("../../icons/IconChevronRight.cjs"),Re=require("../../hooks/useOverlayPortal.cjs"),V=require("../Fieldset/Fieldset.cjs"),ae=require("../ListBox/ListBox.cjs"),ne=require("../Button/Button.cjs"),H=()=>new d.Time(0,0,0),re=()=>new d.Time(23,59,59);function Fe({onAnchorChange:a}){const c=h.useContext(n.RangeCalendarStateContext),l=(c==null?void 0:c.anchorDate)??null,m=l==null?void 0:l.toString();return h.useEffect(()=>{a(l)},[m]),null}const C=a=>a&&"hour"in a?new d.Time(a.hour,a.minute,a.second):null,se=a=>!a||!a.start&&!a.end?{range:null,startTime:null,endTime:null,preset:a==null?void 0:a.preset}:{range:a.start&&a.end?{start:d.toCalendarDate(a.start),end:d.toCalendarDate(a.end)}:null,startTime:C(a.start),endTime:C(a.end),preset:a.preset},u=(a,c,l)=>{if(!a)return null;const m=d.toCalendarDate(a);return l||!c?m:d.toCalendarDateTime(m,c)},Ee=(a,c)=>{var l,m;return{preset:a.preset,start:u((l=a.range)==null?void 0:l.start,a.startTime,c),end:u((m=a.range)==null?void 0:m.end,a.endTime,c)}};function Oe({className:a,locale:c,label:l,"aria-label":m,description:K,errorMessage:q,labels:ie,intervals:y,presetKeys:L,presetLabels:I,hideTime:i=!1,minValue:B,maxValue:w,timezone:ce,isDisabled:le=!1,isRequired:oe=!1,value:S,defaultValue:de,onChange:P}){var Y,ee;const ge=Re.useOverlayPortalContainer(),{locale:ue}=n.useLocale(),R=c??ue??"pt-BR",F=ce??d.getLocalTimeZone(),{placeholder:M,relativeLabel:U,absoluteLabel:Z,startDateLabel:me,endDateLabel:pe,cancelLabel:E,applyLabel:O}=ie,x=h.useMemo(()=>{if(y)return y;if(L){if(!I)throw new Error("DateRangePicker: `presetLabels` is required when `presetKeys` is provided.");return Le.createDateRangePresets({locale:R,timezone:F,include:L,labels:I})}},[y,L,I,R,F]),[g,_]=h.useState(()=>se(S??de)),[p,j]=h.useState(g),[he,k]=h.useState(null),[xe,A]=h.useState(!1);h.useEffect(()=>{S!==void 0&&_(se(S))},[S]);const v=t=>({...t,preset:void 0}),je=t=>i?t:{...t,startTime:t.startTime??H(),endTime:t.endTime??re()},fe=t=>{t&&(j(g),k(null)),A(t)},Ce=t=>{k(null);const{start:r,end:o}=t.getValue();j({range:{start:d.toCalendarDate(r),end:d.toCalendarDate(o)},startTime:C(r),endTime:C(o),preset:t})},ke=t=>{k(t),t&&!i&&j(r=>v({...r,startTime:r.startTime??H()}))},De=t=>{k(null),j(r=>je(v({...r,range:t})))},Te=t=>{if(!t)return;k(null);const r=d.toCalendarDate(t),o=C(t);j(s=>{var b,te;const f=i?s.startTime:o??s.startTime??H(),D=u(r,f,i),T=u((b=s.range)==null?void 0:b.end,s.endTime,i),N=!!(D&&T&&T.compare(D)<0);return v({...s,range:{start:r,end:N||!((te=s.range)!=null&&te.end)?r:s.range.end},startTime:f,endTime:N?f:s.endTime})})},Ne=t=>{if(!t)return;const r=d.toCalendarDate(t),o=C(t);j(s=>{var N,b;const f=i?s.endTime:o??s.endTime??re(),D=u(r,f,i),T=u((N=s.range)==null?void 0:N.start,s.startTime,i);return T&&D&&D.compare(T)<0?s:v({...s,range:{start:((b=s.range)==null?void 0:b.start)??r,end:r},endTime:f})})},be=()=>{_(p),P==null||P(Ee(p,i)),A(!1)},Se=()=>A(!1),ve=!!(E||O),$=(()=>{if(g.preset)return g.preset.label;if(g.range){const t=s=>s.toDate(F).toLocaleString(R,{day:"2-digit",month:"2-digit",year:"numeric",...i?{}:{hour:"2-digit",minute:"2-digit",second:"2-digit"}}),r=u(g.range.start,g.startTime,i),o=u(g.range.end,g.endTime,i);if(r&&o)return`${t(r)} — ${t(o)}`}return null})(),qe=!!(x&&x.length>0),J=i?"day":"second",Q=u(((Y=p.range)==null?void 0:Y.start)??he??void 0,p.startTime,i),W=u(((ee=p.range)==null?void 0:ee.end)??void 0,p.endTime,i),X=e.jsxs(V.Field,{className:ye.clsx(a,"date-range-picker"),children:[l&&e.jsx(V.Label,{children:l}),e.jsxs(n.DialogTrigger,{isOpen:xe,onOpenChange:fe,children:[e.jsxs(n.Button,{className:"date-range-picker-trigger",isDisabled:le,"aria-label":l?void 0:m??M,"aria-required":oe||void 0,"data-invalid":q?!0:void 0,children:[g.preset?e.jsxs("span",{className:"date-range-picker-preset-badge",children:[e.jsx(z.IconCalendar,{"aria-hidden":"true"}),g.preset.label]}):e.jsx("span",{className:"date-range-picker-value","data-placeholder":$?void 0:!0,children:$??M}),e.jsx(Ie.IconChevronDown,{"aria-hidden":"true"})]}),e.jsx(n.Popover,{className:"date-range-picker-popover",placement:"bottom start",UNSTABLE_portalContainer:ge,children:e.jsxs(n.Dialog,{className:"date-range-picker-dialog",children:[e.jsxs("div",{className:"date-range-picker-body",children:[qe&&e.jsxs("div",{className:"date-range-picker-presets",children:[e.jsx(G.TextSmallStrong,{className:"date-range-picker-section-title",children:U}),e.jsx(ae.ListBox,{"aria-label":U,className:"date-range-picker-presets-list",selectionMode:"single",selectedKeys:p.preset?[p.preset.id]:[],items:x,onSelectionChange:t=>{const[r]=[...t],o=x==null?void 0:x.find(s=>s.id===r);o&&Ce(o)},children:t=>e.jsxs(ae.ListBoxItem,{id:t.id,textValue:t.label,className:"date-range-picker-preset-item",children:[e.jsx("span",{children:t.label}),e.jsx(Be.IconCheck,{"aria-hidden":"true",className:"date-range-picker-preset-check"})]})})]}),e.jsxs("div",{className:"date-range-picker-absolute",children:[e.jsx(G.TextSmallStrong,{className:"date-range-picker-section-title",children:Z}),e.jsxs("div",{className:"date-range-picker-fields",children:[e.jsxs(n.DateField,{className:"date-range-picker-datefield",granularity:J,value:Q,minValue:B,maxValue:W??w,onChange:Te,children:[e.jsx(n.Label,{className:"date-range-picker-field-label",children:me}),e.jsxs(n.Group,{className:"date-range-picker-input",children:[e.jsx(n.DateInput,{children:t=>e.jsx(n.DateSegment,{segment:t})}),e.jsx(z.IconCalendar,{"aria-hidden":"true"})]})]}),e.jsxs(n.DateField,{className:"date-range-picker-datefield",granularity:J,value:W,minValue:Q??B,maxValue:w,onChange:Ne,children:[e.jsx(n.Label,{className:"date-range-picker-field-label",children:pe}),e.jsxs(n.Group,{className:"date-range-picker-input",children:[e.jsx(n.DateInput,{children:t=>e.jsx(n.DateSegment,{segment:t})}),e.jsx(z.IconCalendar,{"aria-hidden":"true"})]})]})]}),e.jsxs(n.RangeCalendar,{className:"date-range-picker-calendar","aria-label":Z,value:p.range,minValue:B,maxValue:w,onChange:De,children:[e.jsx(Fe,{onAnchorChange:ke}),e.jsxs("header",{className:"date-range-picker-calendar-header",children:[e.jsx(n.Button,{slot:"previous",className:"date-range-picker-calendar-nav",children:e.jsx(we.IconChevronLeft,{"aria-hidden":"true"})}),e.jsx(n.Heading,{className:"date-range-picker-calendar-heading"}),e.jsx(n.Button,{slot:"next",className:"date-range-picker-calendar-nav",children:e.jsx(Pe.IconChevronRight,{"aria-hidden":"true"})})]}),e.jsx(n.CalendarGrid,{className:"date-range-picker-calendar-grid",children:t=>e.jsx(n.CalendarCell,{date:t,className:"date-range-picker-calendar-cell"})})]})]})]}),ve&&e.jsxs("div",{className:"date-range-picker-actions",children:[E&&e.jsx(ne.Button,{variant:"neutral",size:"small",onPress:Se,children:E}),O&&e.jsx(ne.Button,{variant:"primary",size:"small",onPress:be,children:O})]})]})})]}),K&&e.jsx(V.Description,{children:K}),q&&e.jsx(G.Text,{className:"date-range-picker-error",elementType:"span",children:q})]});return c?e.jsx(n.I18nProvider,{locale:c,children:X}):X}exports.DateRangePicker=Oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("@internationalized/date"),ye=require("../../../vendor/clsx/dist/clsx.cjs"),h=require("react"),n=require("react-aria-components"),Le=require("./dateRangePresets.cjs");;/* empty css */const z=require("../../icons/IconCalendar.cjs"),Ie=require("../../icons/IconChevronDown.cjs"),G=require("../Text/Text.cjs"),Be=require("../../icons/IconCheck.cjs"),Re=require("../../icons/IconChevronLeft.cjs"),we=require("../../icons/IconChevronRight.cjs"),Pe=require("../../hooks/useOverlayPortal.cjs"),V=require("../Fieldset/Fieldset.cjs"),ae=require("../ListBox/ListBox.cjs"),ne=require("../Button/Button.cjs"),H=()=>new d.Time(0,0,0),re=()=>new d.Time(23,59,59);function Fe({onAnchorChange:a}){const c=h.useContext(n.RangeCalendarStateContext),l=(c==null?void 0:c.anchorDate)??null,m=l==null?void 0:l.toString();return h.useEffect(()=>{a(l)},[m]),null}const C=a=>a&&"hour"in a?new d.Time(a.hour,a.minute,a.second):null,se=a=>!a||!a.start&&!a.end?{range:null,startTime:null,endTime:null,preset:a==null?void 0:a.preset}:{range:a.start&&a.end?{start:d.toCalendarDate(a.start),end:d.toCalendarDate(a.end)}:null,startTime:C(a.start),endTime:C(a.end),preset:a.preset},u=(a,c,l)=>{if(!a)return null;const m=d.toCalendarDate(a);return l||!c?m:d.toCalendarDateTime(m,c)},Ee=(a,c)=>{var l,m;return{preset:a.preset,start:u((l=a.range)==null?void 0:l.start,a.startTime,c),end:u((m=a.range)==null?void 0:m.end,a.endTime,c)}};function Oe({className:a,locale:c,label:l,"aria-label":m,description:K,errorMessage:q,labels:ie,intervals:y,presetKeys:L,presetLabels:I,hideTime:i=!1,minValue:B,maxValue:R,timezone:ce,isDisabled:le=!1,isRequired:oe=!1,value:S,defaultValue:de,onChange:w}){var $,ee;const ge=Pe.useOverlayPortalContainer(),{locale:ue}=n.useLocale(),P=c??ue??"pt-BR",F=ce??d.getLocalTimeZone(),{placeholder:M,relativeLabel:U,absoluteLabel:Z,startDateLabel:me,endDateLabel:pe,cancelLabel:E,applyLabel:O}=ie,x=h.useMemo(()=>{if(y)return y;if(L){if(!I)throw new Error("DateRangePicker: `presetLabels` is required when `presetKeys` is provided.");return Le.createDateRangePresets({locale:P,timezone:F,include:L,labels:I})}},[y,L,I,P,F]),[g,_]=h.useState(()=>se(S??de)),[p,j]=h.useState(g),[he,k]=h.useState(null),[xe,A]=h.useState(!1);h.useEffect(()=>{S!==void 0&&_(se(S))},[S]);const v=t=>({...t,preset:void 0}),je=t=>i?t:{...t,startTime:t.startTime??H(),endTime:t.endTime??re()},fe=t=>{t&&(j(g),k(null)),A(t)},Ce=t=>{k(null);const{start:r,end:o}=t.getValue();j({range:{start:d.toCalendarDate(r),end:d.toCalendarDate(o)},startTime:C(r),endTime:C(o),preset:t})},ke=t=>{k(t),t&&!i&&j(r=>v({...r,startTime:r.startTime??H()}))},De=t=>{k(null),j(r=>je(v({...r,range:t})))},Te=t=>{if(!t)return;k(null);const r=d.toCalendarDate(t),o=C(t);j(s=>{var b,te;const f=i?s.startTime:o??s.startTime??H(),D=u(r,f,i),T=u((b=s.range)==null?void 0:b.end,s.endTime,i),N=!!(D&&T&&T.compare(D)<0);return v({...s,range:{start:r,end:N||!((te=s.range)!=null&&te.end)?r:s.range.end},startTime:f,endTime:N?f:s.endTime})})},Ne=t=>{if(!t)return;const r=d.toCalendarDate(t),o=C(t);j(s=>{var N,b;const f=i?s.endTime:o??s.endTime??re(),D=u(r,f,i),T=u((N=s.range)==null?void 0:N.start,s.startTime,i);return T&&D&&D.compare(T)<0?s:v({...s,range:{start:((b=s.range)==null?void 0:b.start)??r,end:r},endTime:f})})},be=()=>{_(p),w==null||w(Ee(p,i)),A(!1)},Se=()=>A(!1),ve=!!(E||O),J=(()=>{if(g.preset)return g.preset.label;if(g.range){const t=s=>s.toDate(F).toLocaleString(P,{day:"2-digit",month:"2-digit",year:"numeric",...i?{}:{hour:"2-digit",minute:"2-digit",second:"2-digit"}}),r=u(g.range.start,g.startTime,i),o=u(g.range.end,g.endTime,i);if(r&&o)return`${t(r)} — ${t(o)}`}return null})(),qe=!!(x&&x.length>0),Q=i?"day":"second",W=u((($=p.range)==null?void 0:$.start)??he??void 0,p.startTime,i),X=u(((ee=p.range)==null?void 0:ee.end)??void 0,p.endTime,i),Y=e.jsxs(V.Field,{className:ye.clsx(a,"date-range-picker"),children:[l&&e.jsx(V.Label,{children:l}),e.jsxs(n.DialogTrigger,{isOpen:xe,onOpenChange:fe,children:[e.jsxs(n.Button,{className:"date-range-picker-trigger",isDisabled:le,"aria-label":l?void 0:m??M,"aria-required":oe||void 0,"data-invalid":q?!0:void 0,children:[g.preset?e.jsxs("span",{className:"date-range-picker-preset-badge",children:[e.jsx(z.IconCalendar,{"aria-hidden":"true"}),g.preset.label]}):e.jsx("span",{className:"date-range-picker-value","data-placeholder":J?void 0:!0,children:J??M}),e.jsx(Ie.IconChevronDown,{"aria-hidden":"true"})]}),e.jsx(n.Popover,{className:"date-range-picker-popover",placement:"bottom start",UNSTABLE_portalContainer:ge,children:e.jsxs(n.Dialog,{className:"date-range-picker-dialog",children:[e.jsxs("div",{className:"date-range-picker-body",children:[qe&&e.jsxs("div",{className:"date-range-picker-presets",children:[e.jsx(G.TextSmallStrong,{className:"date-range-picker-section-title",children:U}),e.jsx(ae.ListBox,{"aria-label":U,className:"date-range-picker-presets-list",selectionMode:"single",selectedKeys:p.preset?[p.preset.id]:[],items:x,onSelectionChange:t=>{const[r]=[...t],o=x==null?void 0:x.find(s=>s.id===r);o&&Ce(o)},children:t=>e.jsxs(ae.ListBoxItem,{id:t.id,textValue:t.label,className:"date-range-picker-preset-item",children:[e.jsx("span",{children:t.label}),e.jsx(Be.IconCheck,{"aria-hidden":"true",className:"date-range-picker-preset-check"})]})})]}),e.jsxs("div",{className:"date-range-picker-absolute",children:[e.jsx(G.TextSmallStrong,{className:"date-range-picker-section-title",children:Z}),e.jsxs("div",{className:"date-range-picker-fields",children:[e.jsxs(n.DateField,{className:"date-range-picker-datefield",granularity:Q,value:W,minValue:B,maxValue:X??R,onChange:Te,children:[e.jsx(n.Label,{className:"date-range-picker-field-label",children:me}),e.jsxs(n.Group,{className:"date-range-picker-input",children:[e.jsx(n.DateInput,{children:t=>e.jsx(n.DateSegment,{segment:t})}),e.jsx(z.IconCalendar,{"aria-hidden":"true"})]})]}),e.jsxs(n.DateField,{className:"date-range-picker-datefield",granularity:Q,value:X,minValue:W??B,maxValue:R,onChange:Ne,children:[e.jsx(n.Label,{className:"date-range-picker-field-label",children:pe}),e.jsxs(n.Group,{className:"date-range-picker-input",children:[e.jsx(n.DateInput,{children:t=>e.jsx(n.DateSegment,{segment:t})}),e.jsx(z.IconCalendar,{"aria-hidden":"true"})]})]})]}),e.jsxs(n.RangeCalendar,{className:"date-range-picker-calendar","aria-label":Z,value:p.range,minValue:B,maxValue:R,onChange:De,children:[e.jsx(Fe,{onAnchorChange:ke}),e.jsxs("header",{className:"date-range-picker-calendar-header",children:[e.jsx(n.Button,{slot:"previous",className:"date-range-picker-calendar-nav",children:e.jsx(Re.IconChevronLeft,{"aria-hidden":"true"})}),e.jsx(n.Heading,{className:"date-range-picker-calendar-heading"}),e.jsx(n.Button,{slot:"next",className:"date-range-picker-calendar-nav",children:e.jsx(we.IconChevronRight,{"aria-hidden":"true"})})]}),e.jsx(n.CalendarGrid,{className:"date-range-picker-calendar-grid",children:t=>e.jsx(n.CalendarCell,{date:t,className:"date-range-picker-calendar-cell"})})]})]})]}),ve&&e.jsxs("div",{className:"date-range-picker-actions",children:[E&&e.jsx(ne.Button,{variant:"neutral",size:"small",onPress:Se,children:E}),O&&e.jsx(ne.Button,{variant:"primary",size:"small",onPress:be,children:O})]})]})})]}),K&&e.jsx(V.Description,{children:K}),q&&e.jsx(G.Text,{className:"date-range-picker-error",elementType:"span",children:q})]});return c?e.jsx(n.I18nProvider,{locale:c,children:Y}):Y}exports.DateRangePicker=Oe;
2
2
  //# sourceMappingURL=DateRangePicker.cjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("../../../vendor/clsx/dist/clsx.cjs"),p=require("react");;/* empty css */const y=require("../../icons/IconUploadCloud.cjs"),I=require("../Tag/Tag.cjs"),m=require("../Fieldset/Fieldset.cjs"),j=p.forwardRef(function({className:d,accept:o,multiple:a=!1,isDisabled:r=!1,isInvalid:t=!1,name:c,value:n=[],onChange:s,children:g,...v},F){const[q,u]=p.useState(!1);function N(i){const l=i.target.files;l&&l.length>0&&(s==null||s(a?[...n,...Array.from(l)]:Array.from(l))),i.target.value=""}function U(i){s==null||s(n.filter((l,h)=>h!==i))}return e.jsxs("div",{...v,className:x.clsx(d,"file-upload"),"data-disabled":r||void 0,"data-invalid":t||void 0,children:[e.jsxs("label",{className:"file-upload-dropzone","data-dragging":q||void 0,children:[e.jsx("input",{ref:F,type:"file",className:"file-upload-input",accept:o,multiple:a,disabled:r,name:c,onChange:N,onDragEnter:()=>u(!0),onDragLeave:()=>u(!1),onDrop:()=>u(!1)}),e.jsx(y.IconUploadCloud,{size:"24"}),e.jsx("span",{className:"file-upload-prompt",children:g})]}),n.length>0&&e.jsx("ul",{className:"file-upload-list",children:n.map((i,l)=>e.jsx("li",{children:e.jsx(I.Tag,{variant:"secondary",onRemove:r?void 0:()=>U(l),children:i.name})},`${i.name}-${l}`))})]})});function D({className:f,label:d,description:o,errorMessage:a,isInvalid:r,...t}){const c=r??!!a;return e.jsxs("div",{className:x.clsx(f,"field"),children:[d&&e.jsx(m.Label,{children:d}),e.jsx(j,{isInvalid:c,...t}),o&&e.jsx(m.Description,{children:o}),a&&e.jsx("span",{className:"error-message",children:a})]})}exports.FileUpload=j;exports.FileUploadField=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("../../../vendor/clsx/dist/clsx.cjs"),p=require("react");;/* empty css */const y=require("../../icons/IconUploadCloud.cjs"),I=require("../Tag/Tag.cjs"),m=require("../Fieldset/Fieldset.cjs"),j=p.forwardRef(function({className:d,accept:o,multiple:a=!1,isDisabled:r=!1,isInvalid:t=!1,name:c,value:n=[],onChange:s,children:v,...g},F){const[q,u]=p.useState(!1);function N(i){const l=i.target.files;l&&l.length>0&&(s==null||s(a?[...n,...Array.from(l)]:Array.from(l))),i.target.value=""}function U(i){s==null||s(n.filter((l,h)=>h!==i))}return e.jsxs("div",{...g,className:x.clsx(d,"file-upload"),"data-disabled":r||void 0,"data-invalid":t||void 0,children:[e.jsxs("label",{className:"file-upload-dropzone","data-dragging":q||void 0,children:[e.jsx("input",{ref:F,type:"file",className:"file-upload-input",accept:o,multiple:a,disabled:r,name:c,onChange:N,onDragEnter:()=>u(!0),onDragLeave:()=>u(!1),onDrop:()=>u(!1)}),e.jsx(y.IconUploadCloud,{size:"24"}),e.jsx("span",{className:"file-upload-prompt",children:v})]}),n.length>0&&e.jsx("ul",{className:"file-upload-list",children:n.map((i,l)=>e.jsx("li",{children:e.jsx(I.Tag,{variant:"secondary",onRemove:r?void 0:()=>U(l),children:i.name})},`${i.name}-${l}`))})]})});function R({className:f,label:d,description:o,errorMessage:a,isInvalid:r,...t}){const c=r??!!a;return e.jsxs("div",{className:x.clsx(f,"field"),children:[d&&e.jsx(m.Label,{children:d}),e.jsx(j,{isInvalid:c,...t}),o&&e.jsx(m.Description,{children:o}),a&&e.jsx("span",{className:"error-message",children:a})]})}exports.FileUpload=j;exports.FileUploadField=R;
2
2
  //# sourceMappingURL=FileUpload.cjs.map
@@ -1,11 +1,11 @@
1
1
  import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
2
  import { clsx as u } from "../../../vendor/clsx/dist/clsx.js";
3
- import I, { useState as U } from "react";
3
+ import I, { useState as R } from "react";
4
4
  /* empty css */
5
- import { IconUploadCloud as $ } from "../../icons/IconUploadCloud.js";
5
+ import { IconUploadCloud as U } from "../../icons/IconUploadCloud.js";
6
6
  import { Tag as x } from "../Tag/Tag.js";
7
- import { Label as R, Description as j } from "../Fieldset/Fieldset.js";
8
- const z = I.forwardRef(function({
7
+ import { Label as j, Description as z } from "../Fieldset/Fieldset.js";
8
+ const A = I.forwardRef(function({
9
9
  className: d,
10
10
  accept: t,
11
11
  multiple: e = !1,
@@ -17,7 +17,7 @@ const z = I.forwardRef(function({
17
17
  children: v,
18
18
  ...g
19
19
  }, N) {
20
- const [h, f] = U(!1);
20
+ const [h, f] = R(!1);
21
21
  function y(l) {
22
22
  const i = l.target.files;
23
23
  i && i.length > 0 && (r == null || r(e ? [...n, ...Array.from(i)] : Array.from(i))), l.target.value = "";
@@ -55,7 +55,7 @@ const z = I.forwardRef(function({
55
55
  onDrop: () => f(!1)
56
56
  }
57
57
  ),
58
- /* @__PURE__ */ a($, { size: "24" }),
58
+ /* @__PURE__ */ a(U, { size: "24" }),
59
59
  /* @__PURE__ */ a("span", { className: "file-upload-prompt", children: v })
60
60
  ]
61
61
  }
@@ -82,14 +82,14 @@ function S({
82
82
  }) {
83
83
  const c = o ?? !!e;
84
84
  return /* @__PURE__ */ m("div", { className: u(p, "field"), children: [
85
- d && /* @__PURE__ */ a(R, { children: d }),
86
- /* @__PURE__ */ a(z, { isInvalid: c, ...s }),
87
- t && /* @__PURE__ */ a(j, { children: t }),
85
+ d && /* @__PURE__ */ a(j, { children: d }),
86
+ /* @__PURE__ */ a(A, { isInvalid: c, ...s }),
87
+ t && /* @__PURE__ */ a(z, { children: t }),
88
88
  e && /* @__PURE__ */ a("span", { className: "error-message", children: e })
89
89
  ] });
90
90
  }
91
91
  export {
92
- z as FileUpload,
92
+ A as FileUpload,
93
93
  S as FileUploadField
94
94
  };
95
95
  //# sourceMappingURL=FileUpload.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("../../../vendor/clsx/dist/clsx.cjs"),e=require("react");;/* empty css */const c=require("../Button/Button.cjs"),a=e.forwardRef(function({className:t,...n},u){const s=i.clsx(t,"icon-button");return o.jsx(c.Button,{...n,...u,className:s})}),B=e.forwardRef(function(t,n){return o.jsx(c.ButtonDanger,{...t,...n,className:"icon-button"})});exports.DestructiveIconButton=B;exports.IconButton=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),i=require("../../../vendor/clsx/dist/clsx.cjs"),e=require("react");;/* empty css */const c=require("../Button/Button.cjs"),a=e.forwardRef(function({className:t,...n},r){const s=i.clsx(t,"icon-button");return o.jsx(c.Button,{...n,...r,className:s})}),B=e.forwardRef(function(t,n){return o.jsx(c.ButtonDanger,{...t,...n,className:"icon-button"})});exports.DestructiveIconButton=B;exports.IconButton=a;
2
2
  //# sourceMappingURL=IconButton.cjs.map
@@ -4,7 +4,7 @@ import l from "react";
4
4
  import { TextField as a, Input as f } from "react-aria-components";
5
5
  /* empty css */
6
6
  import { Label as u, Description as d, FieldError as x } from "../Fieldset/Fieldset.js";
7
- function w({
7
+ function D({
8
8
  className: s,
9
9
  placeholder: o,
10
10
  label: t,
@@ -26,6 +26,6 @@ const I = l.forwardRef(function({ className: o, ...t }, n) {
26
26
  });
27
27
  export {
28
28
  I as Input,
29
- w as InputField
29
+ D as InputField
30
30
  };
31
31
  //# sourceMappingURL=Input.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),r=require("react"),T=require("../../../vendor/clsx/dist/clsx.cjs"),d=require("@codemirror/state"),l=require("@codemirror/view"),R=require("@codemirror/language"),a=require("./json-code-mirror.cjs");;/* empty css */const L=require("../../icons/IconChevronDown.cjs"),z=require("../../icons/IconChevronRight.cjs"),V=require("../Button/Button.cjs"),A=220;function v(t,o){o.length>0&&t.dispatch({effects:o.map(f=>R.foldEffect.of(f))})}function H({value:t,onChange:o,expandAllLabel:f,className:b,height:q,isDisabled:w=!1,isReadOnly:S=!1,"aria-label":y}){const E=r.useRef(null),s=r.useRef(null),h=r.useRef(new d.Compartment),u=r.useRef(o),x=r.useRef(t),[g,C]=r.useState(!1),F=a.toCssSize(q??A),i=!w&&!S;u.current=o,r.useEffect(()=>{if(!E.current)return;const e=l.EditorView.updateListener.of(m=>{var j;if(!m.docChanged)return;const p=m.state.doc.toString();x.current=p,(j=u.current)==null||j.call(u,p)}),n=new l.EditorView({parent:E.current,state:d.EditorState.create({doc:t,extensions:[h.current.of([l.EditorView.editable.of(i),d.EditorState.readOnly.of(!i)]),a.jsonEditorTheme,...a.jsonEditorExtensions,e]})});return s.current=n,v(n,a.computeFirstLevelFoldRanges(t)),()=>{n.destroy(),s.current=null}},[]),r.useEffect(()=>{const e=s.current;if(!e)return;const n=e.state.doc.toString();t!==n&&t!==x.current&&(e.dispatch({changes:{from:0,to:n.length,insert:t}}),x.current=t)},[t]),r.useEffect(()=>{const e=s.current;e&&e.dispatch({effects:h.current.reconfigure([l.EditorView.editable.of(i),d.EditorState.readOnly.of(!i)])})},[i]);const I=()=>{const e=s.current;e&&(g?v(e,a.computeFirstLevelFoldRanges(e.state.doc.toString())):R.unfoldAll(e),C(!g))};return c.jsxs("div",{className:T.clsx("json-viewer","json-viewer-editable",b),"data-disabled":w||void 0,children:[c.jsx(V.Button,{"aria-label":f,variant:"subtle",size:"small",className:"json-viewer-expand-all",onPress:I,children:g?c.jsx(L.IconChevronDown,{size:"14"}):c.jsx(z.IconChevronRight,{size:"14"})}),c.jsx("div",{ref:E,className:"json-viewer-content",style:{height:F},"aria-label":y,role:"textbox","aria-multiline":"true"})]})}exports.JsonEditor=H;
2
+ //# sourceMappingURL=JsonEditor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonEditor.cjs","sources":["../../../../../src/ui/primitives/JsonViewer/JsonEditor.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport clsx from \"clsx\";\nimport { Compartment, EditorState } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport { foldEffect, unfoldAll } from \"@codemirror/language\";\nimport { Button } from \"primitives\";\nimport { IconChevronDown, IconChevronRight } from \"icons\";\nimport { computeFirstLevelFoldRanges, jsonEditorExtensions, jsonEditorTheme, toCssSize } from \"./json-code-mirror\";\nimport \"./jsonviewer.css\";\n\nexport interface JsonEditorProps {\n value: string;\n onChange?: (value: string) => void;\n expandAllLabel: string;\n className?: string;\n height?: string | number;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n \"aria-label\"?: string;\n}\n\nconst DEFAULT_HEIGHT = 220;\n\nfunction applyFoldRanges(view: EditorView, ranges: { from: number; to: number }[]) {\n if (ranges.length > 0) view.dispatch({ effects: ranges.map((range) => foldEffect.of(range)) });\n}\n\n/**\n * Editable sibling of `JsonViewer`: same CodeMirror-based visual (syntax\n * colors, gutter, scrollbar, border/background) but with typing enabled.\n * `JsonViewer` stays read-only-only on purpose so its bundle keeps assuming\n * a static document; this component owns the editable/controlled behavior.\n */\nexport function JsonEditor({\n value,\n onChange,\n expandAllLabel,\n className,\n height,\n isDisabled = false,\n isReadOnly = false,\n \"aria-label\": ariaLabel,\n}: JsonEditorProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const viewRef = useRef<EditorView | null>(null);\n const editableCompartment = useRef(new Compartment());\n const onChangeRef = useRef(onChange);\n const lastEmittedRef = useRef(value);\n const [isExpanded, setIsExpanded] = useState(false);\n const editorHeight = toCssSize(height ?? DEFAULT_HEIGHT);\n const isEditable = !isDisabled && !isReadOnly;\n\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateListener = EditorView.updateListener.of((update) => {\n if (!update.docChanged) return;\n const nextText = update.state.doc.toString();\n lastEmittedRef.current = nextText;\n onChangeRef.current?.(nextText);\n });\n const view = new EditorView({\n parent: containerRef.current,\n state: EditorState.create({\n doc: value,\n extensions: [\n editableCompartment.current.of([EditorView.editable.of(isEditable), EditorState.readOnly.of(!isEditable)]),\n jsonEditorTheme,\n ...jsonEditorExtensions,\n updateListener,\n ],\n }),\n });\n viewRef.current = view;\n applyFoldRanges(view, computeFirstLevelFoldRanges(value));\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n const currentText = view.state.doc.toString();\n if (value !== currentText && value !== lastEmittedRef.current) {\n view.dispatch({ changes: { from: 0, to: currentText.length, insert: value } });\n lastEmittedRef.current = value;\n }\n }, [value]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: editableCompartment.current.reconfigure([\n EditorView.editable.of(isEditable),\n EditorState.readOnly.of(!isEditable),\n ]),\n });\n }, [isEditable]);\n\n const toggleExpandAll = () => {\n const view = viewRef.current;\n if (!view) return;\n if (isExpanded) {\n applyFoldRanges(view, computeFirstLevelFoldRanges(view.state.doc.toString()));\n } else {\n unfoldAll(view);\n }\n setIsExpanded(!isExpanded);\n };\n\n return (\n <div className={clsx(\"json-viewer\", \"json-viewer-editable\", className)} data-disabled={isDisabled || undefined}>\n <Button\n aria-label={expandAllLabel}\n variant=\"subtle\"\n size=\"small\"\n className=\"json-viewer-expand-all\"\n onPress={toggleExpandAll}\n >\n {isExpanded ? <IconChevronDown size=\"14\" /> : <IconChevronRight size=\"14\" />}\n </Button>\n <div\n ref={containerRef}\n className=\"json-viewer-content\"\n style={{ height: editorHeight }}\n aria-label={ariaLabel}\n role=\"textbox\"\n aria-multiline=\"true\"\n />\n </div>\n );\n}\n"],"names":["DEFAULT_HEIGHT","applyFoldRanges","view","ranges","range","foldEffect","JsonEditor","value","onChange","expandAllLabel","className","height","isDisabled","isReadOnly","ariaLabel","containerRef","useRef","viewRef","editableCompartment","Compartment","onChangeRef","lastEmittedRef","isExpanded","setIsExpanded","useState","editorHeight","toCssSize","isEditable","useEffect","updateListener","EditorView","update","nextText","_a","EditorState","jsonEditorTheme","jsonEditorExtensions","computeFirstLevelFoldRanges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EAAAA,gBAAA,CAAgB,KAAK,KAAK,EAAKF,EAAAA,IAACG,EAAAA,iBAAA,CAAiB,KAAK,IAAA,CAAK,CAAA,CAAA,EAE5EH,EAAAA,IAAC,MAAA,CACC,IAAK5B,EACL,UAAU,sBACV,MAAO,CAAE,OAAQU,CAAA,EACjB,aAAYX,EACZ,KAAK,UACL,iBAAe,MAAA,CAAA,CACjB,EACF,CAEJ"}
@@ -0,0 +1,95 @@
1
+ import { jsxs as I, jsx as a } from "react/jsx-runtime";
2
+ import { useRef as s, useState as L, useEffect as p } from "react";
3
+ import { clsx as A } from "../../../vendor/clsx/dist/clsx.js";
4
+ import { Compartment as H, EditorState as x } from "@codemirror/state";
5
+ import { EditorView as f } from "@codemirror/view";
6
+ import { foldEffect as N, unfoldAll as O } from "@codemirror/language";
7
+ import { jsonEditorTheme as B, jsonEditorExtensions as D, computeFirstLevelFoldRanges as v, toCssSize as G } from "./json-code-mirror.js";
8
+ /* empty css */
9
+ import { IconChevronDown as J } from "../../icons/IconChevronDown.js";
10
+ import { IconChevronRight as P } from "../../icons/IconChevronRight.js";
11
+ import { Button as U } from "../Button/Button.js";
12
+ const V = 220;
13
+ function j(e, o) {
14
+ o.length > 0 && e.dispatch({ effects: o.map((l) => N.of(l)) });
15
+ }
16
+ function tt({
17
+ value: e,
18
+ onChange: o,
19
+ expandAllLabel: l,
20
+ className: R,
21
+ height: S,
22
+ isDisabled: E = !1,
23
+ isReadOnly: y = !1,
24
+ "aria-label": T
25
+ }) {
26
+ const d = s(null), n = s(null), h = s(new H()), c = s(o), m = s(e), [u, z] = L(!1), C = G(S ?? V), i = !E && !y;
27
+ c.current = o, p(() => {
28
+ if (!d.current) return;
29
+ const t = f.updateListener.of((w) => {
30
+ var b;
31
+ if (!w.docChanged) return;
32
+ const g = w.state.doc.toString();
33
+ m.current = g, (b = c.current) == null || b.call(c, g);
34
+ }), r = new f({
35
+ parent: d.current,
36
+ state: x.create({
37
+ doc: e,
38
+ extensions: [
39
+ h.current.of([f.editable.of(i), x.readOnly.of(!i)]),
40
+ B,
41
+ ...D,
42
+ t
43
+ ]
44
+ })
45
+ });
46
+ return n.current = r, j(r, v(e)), () => {
47
+ r.destroy(), n.current = null;
48
+ };
49
+ }, []), p(() => {
50
+ const t = n.current;
51
+ if (!t) return;
52
+ const r = t.state.doc.toString();
53
+ e !== r && e !== m.current && (t.dispatch({ changes: { from: 0, to: r.length, insert: e } }), m.current = e);
54
+ }, [e]), p(() => {
55
+ const t = n.current;
56
+ t && t.dispatch({
57
+ effects: h.current.reconfigure([
58
+ f.editable.of(i),
59
+ x.readOnly.of(!i)
60
+ ])
61
+ });
62
+ }, [i]);
63
+ const F = () => {
64
+ const t = n.current;
65
+ t && (u ? j(t, v(t.state.doc.toString())) : O(t), z(!u));
66
+ };
67
+ return /* @__PURE__ */ I("div", { className: A("json-viewer", "json-viewer-editable", R), "data-disabled": E || void 0, children: [
68
+ /* @__PURE__ */ a(
69
+ U,
70
+ {
71
+ "aria-label": l,
72
+ variant: "subtle",
73
+ size: "small",
74
+ className: "json-viewer-expand-all",
75
+ onPress: F,
76
+ children: u ? /* @__PURE__ */ a(J, { size: "14" }) : /* @__PURE__ */ a(P, { size: "14" })
77
+ }
78
+ ),
79
+ /* @__PURE__ */ a(
80
+ "div",
81
+ {
82
+ ref: d,
83
+ className: "json-viewer-content",
84
+ style: { height: C },
85
+ "aria-label": T,
86
+ role: "textbox",
87
+ "aria-multiline": "true"
88
+ }
89
+ )
90
+ ] });
91
+ }
92
+ export {
93
+ tt as JsonEditor
94
+ };
95
+ //# sourceMappingURL=JsonEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JsonEditor.js","sources":["../../../../../src/ui/primitives/JsonViewer/JsonEditor.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport clsx from \"clsx\";\nimport { Compartment, EditorState } from \"@codemirror/state\";\nimport { EditorView } from \"@codemirror/view\";\nimport { foldEffect, unfoldAll } from \"@codemirror/language\";\nimport { Button } from \"primitives\";\nimport { IconChevronDown, IconChevronRight } from \"icons\";\nimport { computeFirstLevelFoldRanges, jsonEditorExtensions, jsonEditorTheme, toCssSize } from \"./json-code-mirror\";\nimport \"./jsonviewer.css\";\n\nexport interface JsonEditorProps {\n value: string;\n onChange?: (value: string) => void;\n expandAllLabel: string;\n className?: string;\n height?: string | number;\n isDisabled?: boolean;\n isReadOnly?: boolean;\n \"aria-label\"?: string;\n}\n\nconst DEFAULT_HEIGHT = 220;\n\nfunction applyFoldRanges(view: EditorView, ranges: { from: number; to: number }[]) {\n if (ranges.length > 0) view.dispatch({ effects: ranges.map((range) => foldEffect.of(range)) });\n}\n\n/**\n * Editable sibling of `JsonViewer`: same CodeMirror-based visual (syntax\n * colors, gutter, scrollbar, border/background) but with typing enabled.\n * `JsonViewer` stays read-only-only on purpose so its bundle keeps assuming\n * a static document; this component owns the editable/controlled behavior.\n */\nexport function JsonEditor({\n value,\n onChange,\n expandAllLabel,\n className,\n height,\n isDisabled = false,\n isReadOnly = false,\n \"aria-label\": ariaLabel,\n}: JsonEditorProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const viewRef = useRef<EditorView | null>(null);\n const editableCompartment = useRef(new Compartment());\n const onChangeRef = useRef(onChange);\n const lastEmittedRef = useRef(value);\n const [isExpanded, setIsExpanded] = useState(false);\n const editorHeight = toCssSize(height ?? DEFAULT_HEIGHT);\n const isEditable = !isDisabled && !isReadOnly;\n\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!containerRef.current) return;\n const updateListener = EditorView.updateListener.of((update) => {\n if (!update.docChanged) return;\n const nextText = update.state.doc.toString();\n lastEmittedRef.current = nextText;\n onChangeRef.current?.(nextText);\n });\n const view = new EditorView({\n parent: containerRef.current,\n state: EditorState.create({\n doc: value,\n extensions: [\n editableCompartment.current.of([EditorView.editable.of(isEditable), EditorState.readOnly.of(!isEditable)]),\n jsonEditorTheme,\n ...jsonEditorExtensions,\n updateListener,\n ],\n }),\n });\n viewRef.current = view;\n applyFoldRanges(view, computeFirstLevelFoldRanges(value));\n return () => {\n view.destroy();\n viewRef.current = null;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n const currentText = view.state.doc.toString();\n if (value !== currentText && value !== lastEmittedRef.current) {\n view.dispatch({ changes: { from: 0, to: currentText.length, insert: value } });\n lastEmittedRef.current = value;\n }\n }, [value]);\n\n useEffect(() => {\n const view = viewRef.current;\n if (!view) return;\n view.dispatch({\n effects: editableCompartment.current.reconfigure([\n EditorView.editable.of(isEditable),\n EditorState.readOnly.of(!isEditable),\n ]),\n });\n }, [isEditable]);\n\n const toggleExpandAll = () => {\n const view = viewRef.current;\n if (!view) return;\n if (isExpanded) {\n applyFoldRanges(view, computeFirstLevelFoldRanges(view.state.doc.toString()));\n } else {\n unfoldAll(view);\n }\n setIsExpanded(!isExpanded);\n };\n\n return (\n <div className={clsx(\"json-viewer\", \"json-viewer-editable\", className)} data-disabled={isDisabled || undefined}>\n <Button\n aria-label={expandAllLabel}\n variant=\"subtle\"\n size=\"small\"\n className=\"json-viewer-expand-all\"\n onPress={toggleExpandAll}\n >\n {isExpanded ? <IconChevronDown size=\"14\" /> : <IconChevronRight size=\"14\" />}\n </Button>\n <div\n ref={containerRef}\n className=\"json-viewer-content\"\n style={{ height: editorHeight }}\n aria-label={ariaLabel}\n role=\"textbox\"\n aria-multiline=\"true\"\n />\n </div>\n );\n}\n"],"names":["DEFAULT_HEIGHT","applyFoldRanges","view","ranges","range","foldEffect","JsonEditor","value","onChange","expandAllLabel","className","height","isDisabled","isReadOnly","ariaLabel","containerRef","useRef","viewRef","editableCompartment","Compartment","onChangeRef","lastEmittedRef","isExpanded","setIsExpanded","useState","editorHeight","toCssSize","isEditable","useEffect","updateListener","EditorView","update","nextText","_a","EditorState","jsonEditorTheme","jsonEditorExtensions","computeFirstLevelFoldRanges","currentText","toggleExpandAll","unfoldAll","jsxs","clsx","jsx","Button","Icon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