@synertech/ui 0.50.1 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.claude/skills/use-synertech-ui/SKILL.md +9 -1
  2. package/dist/components/accordion/Accordion.cjs +1 -1
  3. package/dist/components/accordion/Accordion.js +1 -1
  4. package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
  5. package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
  6. package/dist/components/chart/ChartPeriodPicker.cjs +1 -1
  7. package/dist/components/chart/ChartPeriodPicker.js +1 -1
  8. package/dist/components/datagrid/DataGrid.cjs +1 -1
  9. package/dist/components/datagrid/DataGrid.js +1 -1
  10. package/dist/components/detachable/Detachable.cjs +1 -1
  11. package/dist/components/detachable/Detachable.js +1 -1
  12. package/dist/components/detachable/useMovableContent.cjs +1 -0
  13. package/dist/components/detachable/useMovableContent.js +1 -0
  14. package/dist/components/drawer/Drawer.cjs +1 -1
  15. package/dist/components/drawer/Drawer.js +1 -1
  16. package/dist/components/dropdown/DropdownContent.cjs +1 -1
  17. package/dist/components/dropdown/DropdownContent.js +1 -1
  18. package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
  19. package/dist/components/dropdown/DropdownSubMenu.js +1 -1
  20. package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
  21. package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
  22. package/dist/components/dropdown/hooks/usePositioning.cjs +1 -1
  23. package/dist/components/dropdown/hooks/usePositioning.js +1 -1
  24. package/dist/components/file-selector/FileSelector.cjs +1 -1
  25. package/dist/components/file-selector/FileSelector.js +1 -1
  26. package/dist/components/form/input/Input.cjs +1 -1
  27. package/dist/components/form/input/Input.js +1 -1
  28. package/dist/components/form/mention-input/MentionInput.cjs +4 -1
  29. package/dist/components/form/mention-input/MentionInput.js +4 -1
  30. package/dist/components/image-uploader/ImageUploader.cjs +1 -1
  31. package/dist/components/image-uploader/ImageUploader.js +1 -1
  32. package/dist/components/modal/Modal.cjs +1 -1
  33. package/dist/components/modal/Modal.js +1 -1
  34. package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
  35. package/dist/components/schema-editor/SchemaEditor.js +1 -1
  36. package/dist/components/schema-editor/SchemaEditor.types.cjs +1 -1
  37. package/dist/components/schema-editor/minimap/SchemaMinimap.cjs +1 -1
  38. package/dist/components/schema-editor/minimap/SchemaMinimap.js +1 -1
  39. package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
  40. package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
  41. package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
  42. package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
  43. package/dist/components/schema-editor/utils/import.cjs +1 -0
  44. package/dist/components/schema-editor/utils/import.js +1 -0
  45. package/dist/components/schema-editor/utils/sql-export.cjs +6 -5
  46. package/dist/components/schema-editor/utils/sql-export.js +7 -6
  47. package/dist/components/select/Select.cjs +1 -1
  48. package/dist/components/select/Select.js +1 -1
  49. package/dist/components/slider/Slider.cjs +1 -1
  50. package/dist/components/slider/Slider.js +1 -1
  51. package/dist/components/wizard/Wizard.cjs +1 -1
  52. package/dist/components/wizard/Wizard.js +1 -1
  53. package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
  54. package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
  55. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.cjs +1 -1
  56. package/dist/components/workflow-editor/nodes/WorkflowNodeRenderer.js +1 -1
  57. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
  58. package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
  59. package/dist/components/workflow-editor/utils/import.cjs +1 -0
  60. package/dist/components/workflow-editor/utils/import.js +1 -0
  61. package/dist/hooks/useDialogA11y.cjs +1 -1
  62. package/dist/hooks/useDialogA11y.js +1 -1
  63. package/dist/index.d.cts +89 -14
  64. package/dist/index.d.ts +89 -14
  65. package/dist/lib/canvas-events.cjs +1 -0
  66. package/dist/lib/canvas-events.js +1 -0
  67. package/dist/lib/dialog-stack.cjs +1 -1
  68. package/dist/lib/dialog-stack.js +1 -1
  69. package/dist/lib/layer-document.cjs +1 -0
  70. package/dist/lib/layer-document.js +1 -0
  71. package/dist/lib/owner-document.cjs +1 -0
  72. package/dist/lib/owner-document.js +1 -0
  73. package/dist/lib/ui-labels.cjs +1 -1
  74. package/dist/lib/ui-labels.js +1 -1
  75. package/dist/styles.css +129 -462
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(p,r)=>{for(var h in r)L(p,h,{get:r[h],enumerable:!0})},Z=(p,r,h,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let g of X(r))!J.call(p,g)&&g!==h&&L(p,g,{get:()=>r[g],enumerable:!(m=Y(r,g))||m.enumerable});return p};var $=p=>Z(L({},"__esModule",{value:!0}),p);var ne={};Q(ne,{SchemaTableRenderer:()=>ae});module.exports=$(ne);var s=require("react"),u=require("../../../lib/cn.cjs"),i=require("../utils/geometry.cjs"),K=require("../utils/schema-helpers.cjs"),M=require("../../../lib/ui-labels.cjs"),e=require("react/jsx-runtime"),P=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),F=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),(0,e.jsx)("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),ee=({collapsed:p})=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:p?(0,e.jsx)("path",{d:"M6 3l5 5-5 5V3z"}):(0,e.jsx)("path",{d:"M3 6l5 5 5-5H3z"})}),H=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),_=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M4 2v8a4 4 0 008 0V2"})}),te=()=>(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M4 8h8"})}),re=()=>(0,e.jsxs)("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"5",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"12",r:"1.5"})]}),oe=(0,s.memo)(function({field:r,tableId:h,editable:m,readOnly:g,disabled:k,onFieldChange:b,labels:y}){let[f,v]=(0,s.useState)(!1),[w,l]=(0,s.useState)(r.defaultValue??""),N=m&&!g&&!k,E=()=>{v(!1),b?.(h,r.id,{defaultValue:w||void 0})};return N?f?(0,e.jsx)("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":(0,M.formatUILabel)(y.schemaEditorDefaultValueFor,{field:r.name}),value:w,onChange:d=>l(d.target.value),onBlur:E,onKeyDown:d=>{d.key==="Enter"&&E(),d.key==="Escape"&&v(!1)},onMouseDown:d=>d.stopPropagation(),autoFocus:!0}):r.defaultValue?(0,e.jsxs)("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:d=>{d.stopPropagation(),l(r.defaultValue??""),v(!0)},onMouseDown:d=>d.stopPropagation(),title:(0,M.formatUILabel)(y.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):(0,e.jsx)("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:d=>{d.stopPropagation(),l(""),v(!0)},onMouseDown:d=>d.stopPropagation(),title:y.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?(0,e.jsxs)("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:(0,M.formatUILabel)(y.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),ae=(0,s.memo)(function({table:r,selected:h,disabled:m,readOnly:g,editable:k,dropTarget:b,fieldTypes:y,onTableNameChange:f,onTableNotesChange:v,onToggleCollapse:w,onFieldChange:l,onFieldAdd:N,onFieldRemove:E,onFieldReorder:d,onResizeStart:B,labels:n}){let S=r.width??i.DEFAULT_TABLE_WIDTH,T=r.collapsed??!1,c=k&&!g&&!m,R=y.length>0?y:K.DEFAULT_FIELD_TYPES,[z,I]=(0,s.useState)(null),[V,D]=(0,s.useState)(null),x=(0,s.useRef)(null),W=(0,s.useCallback)(t=>{f?.(r.id,t.target.value)},[r.id,f]),U=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{name:a})},[r.id,l]),A=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{type:a})},[r.id,l]),C=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{primaryKey:!a})},[r.id,l]),q=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{nullable:!a})},[r.id,l]),j=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{indexed:!a})},[r.id,l]),O=(0,s.useCallback)((t,a)=>{l?.(r.id,t,{unique:!a})},[r.id,l]),G=(0,s.useCallback)(()=>{N?.(r.id)},[r.id,N]);return(0,e.jsxs)("div",{"data-table-id":r.id,className:(0,u.cn)("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,b?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":h?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:S,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[(0,e.jsxs)("div",{className:(0,u.cn)("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:i.HEADER_HEIGHT},children:[c?(0,e.jsx)("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:W,onMouseDown:t=>t.stopPropagation()}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:t=>{t.stopPropagation(),w?.(r.id)},onMouseDown:t=>t.stopPropagation(),"aria-label":T?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:(0,e.jsx)(ee,{collapsed:T})})]}),(0,i.hasNotesRow)(r,c)&&(c?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:i.NOTES_ROW_HEIGHT},children:(0,e.jsx)("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:t=>v?.(r.id,t.target.value),onMouseDown:t=>t.stopPropagation()})}):(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:i.NOTES_ROW_HEIGHT},children:(0,e.jsx)("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!T&&(0,e.jsxs)("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((t,a)=>(0,e.jsxs)("div",{"data-field-id":t.id,"data-table-id":r.id,className:(0,u.cn)("flex items-center gap-1.5 pr-2 relative group",c?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",b?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",z===a&&"opacity-40",V===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:i.FIELD_ROW_HEIGHT},draggable:c,onDragStart:o=>{c&&(o.stopPropagation(),x.current=a,I(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{x.current!==null&&(o.preventDefault(),o.stopPropagation(),D(a))},onDragLeave:()=>{V===a&&D(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),x.current!==null&&x.current!==a&&d?.(r.id,x.current,a),x.current=null,I(null),D(null)},onDragEnd:()=>{x.current=null,I(null),D(null)},children:[(0,e.jsx)("div",{"data-connection-side":"left","data-field-id":t.id,"data-table-id":r.id,className:(0,u.cn)("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",b?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:i.FIELD_ROW_HEIGHT/2-5}}),c&&(0,e.jsx)("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:i.FIELD_ROW_HEIGHT/2-6},children:(0,e.jsx)(re,{})}),c?(0,e.jsx)("button",{type:"button",className:(0,u.cn)("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",t.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),q(t.id,t.nullable??!1)},onMouseDown:o=>o.stopPropagation(),title:t.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):(0,e.jsx)("span",{className:(0,u.cn)("w-4 text-xs font-bold flex-shrink-0 text-center",t.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:t.nullable?"?":""}),t.primaryKey&&t.foreignKey?(0,e.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[c?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),C(t.id,!0)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(P,{})}):(0,e.jsx)(P,{}),(0,e.jsx)(F,{})]}):t.primaryKey?c?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),C(t.id,!0)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(P,{})}):(0,e.jsx)(P,{}):t.foreignKey?(0,e.jsx)(F,{}):c?(0,e.jsx)("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),C(t.id,!1)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):(0,e.jsx)("span",{className:"w-3.5 flex-shrink-0"}),c?(0,e.jsx)("input",{className:(0,u.cn)("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:t.name,onChange:o=>U(t.id,o.target.value),onMouseDown:o=>o.stopPropagation()}):(0,e.jsx)("span",{className:(0,u.cn)("flex-1 min-w-0 text-xs truncate",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:t.name}),c?(0,e.jsxs)("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:t.type,onChange:o=>A(t.id,o.target.value),onMouseDown:o=>o.stopPropagation(),children:[R.map(o=>(0,e.jsx)("option",{value:o,children:o},o)),!R.includes(t.type)&&(0,e.jsx)("option",{value:t.type,children:t.type})]}):(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:t.type}),(0,e.jsx)(oe,{field:t,tableId:r.id,editable:k,readOnly:g,disabled:m,onFieldChange:l,labels:n}),t.indexed&&(0,e.jsx)(H,{}),t.unique&&(0,e.jsx)(_,{}),c&&(0,e.jsxs)("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[(0,e.jsx)("button",{type:"button",className:(0,u.cn)("cursor-pointer transition-opacity",t.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),j(t.id,t.indexed??!1)},onMouseDown:o=>o.stopPropagation(),title:t.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:(0,e.jsx)(H,{})}),(0,e.jsx)("button",{type:"button",className:(0,u.cn)("cursor-pointer transition-opacity",t.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),O(t.id,t.unique??!1)},onMouseDown:o=>o.stopPropagation(),title:t.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:(0,e.jsx)(_,{})}),(0,e.jsx)("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),E?.(r.id,t.id)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:(0,e.jsx)(te,{})})]}),(0,e.jsx)("div",{"data-connection-side":"right","data-field-id":t.id,"data-table-id":r.id,className:(0,u.cn)("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",b?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:i.FIELD_ROW_HEIGHT/2-5}})]},t.id)),c&&(0,e.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:i.ADD_BUTTON_HEIGHT},onClick:t=>{t.stopPropagation(),G()},onMouseDown:t=>t.stopPropagation(),children:[(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!m&&!g&&(0,e.jsx)("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:t=>{t.stopPropagation(),t.preventDefault();let a=r.height??(0,i.getTableHeight)(r,c);B?.(r.id,t.clientX,t.clientY,S,a)},children:(0,e.jsxs)("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,e.jsx)("path",{d:"M12 2v10H2",opacity:"0"}),(0,e.jsx)("path",{d:"M6 12L12 6"}),(0,e.jsx)("path",{d:"M10 12L12 10"})]})})]})});0&&(module.exports={SchemaTableRenderer});
1
+ "use strict";var S=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(u,r)=>{for(var h in r)S(u,h,{get:r[h],enumerable:!0})},Z=(u,r,h,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let g of X(r))!J.call(u,g)&&g!==h&&S(u,g,{get:()=>r[g],enumerable:!(m=Y(r,g))||m.enumerable});return u};var $=u=>Z(S({},"__esModule",{value:!0}),u);var ne={};Q(ne,{SchemaTableRenderer:()=>ae});module.exports=$(ne);var i=require("react"),p=require("../../../lib/cn.cjs"),s=require("../utils/geometry.cjs"),K=require("../utils/schema-helpers.cjs"),I=require("../../../lib/ui-labels.cjs"),e=require("react/jsx-runtime"),D=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),F=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),(0,e.jsx)("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),ee=({collapsed:u})=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:u?(0,e.jsx)("path",{d:"M6 3l5 5-5 5V3z"}):(0,e.jsx)("path",{d:"M3 6l5 5 5-5H3z"})}),H=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),_=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,e.jsx)("path",{d:"M4 2v8a4 4 0 008 0V2"})}),te=()=>(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M4 8h8"})}),re=()=>(0,e.jsxs)("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[(0,e.jsx)("circle",{cx:"5",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"4",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"8",r:"1.5"}),(0,e.jsx)("circle",{cx:"5",cy:"12",r:"1.5"}),(0,e.jsx)("circle",{cx:"11",cy:"12",r:"1.5"})]}),oe=(0,i.memo)(function({field:r,tableId:h,editable:m,readOnly:g,disabled:k,onFieldChange:b,labels:y}){let[f,v]=(0,i.useState)(!1),[w,l]=(0,i.useState)(r.defaultValue??""),N=m&&!g&&!k,P=()=>{v(!1),b?.(h,r.id,{defaultValue:w||void 0})};return N?f?(0,e.jsx)("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":(0,I.formatUILabel)(y.schemaEditorDefaultValueFor,{field:r.name}),value:w,onChange:d=>l(d.target.value),onBlur:P,onKeyDown:d=>{d.key==="Enter"&&P(),d.key==="Escape"&&v(!1)},onPointerDown:d=>d.stopPropagation(),autoFocus:!0}):r.defaultValue?(0,e.jsxs)("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:d=>{d.stopPropagation(),l(r.defaultValue??""),v(!0)},onPointerDown:d=>d.stopPropagation(),title:(0,I.formatUILabel)(y.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):(0,e.jsx)("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:d=>{d.stopPropagation(),l(""),v(!0)},onPointerDown:d=>d.stopPropagation(),title:y.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?(0,e.jsxs)("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:(0,I.formatUILabel)(y.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),ae=(0,i.memo)(function({table:r,selected:h,disabled:m,readOnly:g,editable:k,dropTarget:b,fieldTypes:y,onTableNameChange:f,onTableNotesChange:v,onToggleCollapse:w,onFieldChange:l,onFieldAdd:N,onFieldRemove:P,onFieldReorder:d,onResizeStart:B,labels:n}){let M=r.width??s.DEFAULT_TABLE_WIDTH,T=r.collapsed??!1,c=k&&!g&&!m,R=y.length>0?y:K.DEFAULT_FIELD_TYPES,[z,C]=(0,i.useState)(null),[V,E]=(0,i.useState)(null),x=(0,i.useRef)(null),W=(0,i.useCallback)(t=>{f?.(r.id,t.target.value)},[r.id,f]),U=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{name:a})},[r.id,l]),A=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{type:a})},[r.id,l]),L=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{primaryKey:!a})},[r.id,l]),q=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{nullable:!a})},[r.id,l]),j=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{indexed:!a})},[r.id,l]),O=(0,i.useCallback)((t,a)=>{l?.(r.id,t,{unique:!a})},[r.id,l]),G=(0,i.useCallback)(()=>{N?.(r.id)},[r.id,N]);return(0,e.jsxs)("div",{"data-table-id":r.id,className:(0,p.cn)("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,b?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":h?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:M,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[(0,e.jsxs)("div",{className:(0,p.cn)("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:s.HEADER_HEIGHT},children:[c?(0,e.jsx)("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:W,onPointerDown:t=>t.stopPropagation()}):(0,e.jsx)("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:t=>{t.stopPropagation(),w?.(r.id)},onPointerDown:t=>t.stopPropagation(),"aria-label":T?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:(0,e.jsx)(ee,{collapsed:T})})]}),(0,s.hasNotesRow)(r,c)&&(c?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:s.NOTES_ROW_HEIGHT},children:(0,e.jsx)("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:t=>v?.(r.id,t.target.value),onPointerDown:t=>t.stopPropagation()})}):(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:s.NOTES_ROW_HEIGHT},children:(0,e.jsx)("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!T&&(0,e.jsxs)("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((t,a)=>(0,e.jsxs)("div",{"data-field-id":t.id,"data-table-id":r.id,className:(0,p.cn)("flex items-center gap-1.5 pr-2 relative group",c?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",b?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",z===a&&"opacity-40",V===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:s.FIELD_ROW_HEIGHT},draggable:c,onDragStart:o=>{c&&(o.stopPropagation(),x.current=a,C(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{x.current!==null&&(o.preventDefault(),o.stopPropagation(),E(a))},onDragLeave:()=>{V===a&&E(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),x.current!==null&&x.current!==a&&d?.(r.id,x.current,a),x.current=null,C(null),E(null)},onDragEnd:()=>{x.current=null,C(null),E(null)},children:[(0,e.jsx)("div",{"data-connection-side":"left","data-field-id":t.id,"data-table-id":r.id,className:(0,p.cn)("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",b?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:s.FIELD_ROW_HEIGHT/2-5}}),c&&(0,e.jsx)("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:s.FIELD_ROW_HEIGHT/2-6},children:(0,e.jsx)(re,{})}),c?(0,e.jsx)("button",{type:"button",className:(0,p.cn)("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",t.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),q(t.id,t.nullable??!1)},onPointerDown:o=>o.stopPropagation(),title:t.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):(0,e.jsx)("span",{className:(0,p.cn)("w-4 text-xs font-bold flex-shrink-0 text-center",t.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:t.nullable?"?":""}),t.primaryKey&&t.foreignKey?(0,e.jsxs)("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[c?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),L(t.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}),(0,e.jsx)(F,{})]}):t.primaryKey?c?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),L(t.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}):t.foreignKey?(0,e.jsx)(F,{}):c?(0,e.jsx)("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),L(t.id,!1)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:(0,e.jsxs)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[(0,e.jsx)("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),(0,e.jsx)("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):(0,e.jsx)("span",{className:"w-3.5 flex-shrink-0"}),c?(0,e.jsx)("input",{className:(0,p.cn)("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:t.name,onChange:o=>U(t.id,o.target.value),onPointerDown:o=>o.stopPropagation()}):(0,e.jsx)("span",{className:(0,p.cn)("flex-1 min-w-0 text-xs truncate",t.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:t.name}),c?(0,e.jsxs)("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:t.type,onChange:o=>A(t.id,o.target.value),onPointerDown:o=>o.stopPropagation(),children:[R.map(o=>(0,e.jsx)("option",{value:o,children:o},o)),!R.includes(t.type)&&(0,e.jsx)("option",{value:t.type,children:t.type})]}):(0,e.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:t.type}),(0,e.jsx)(oe,{field:t,tableId:r.id,editable:k,readOnly:g,disabled:m,onFieldChange:l,labels:n}),t.indexed&&(0,e.jsx)(H,{}),t.unique&&(0,e.jsx)(_,{}),c&&(0,e.jsxs)("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[(0,e.jsx)("button",{type:"button",className:(0,p.cn)("cursor-pointer transition-opacity",t.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),j(t.id,t.indexed??!1)},onPointerDown:o=>o.stopPropagation(),title:t.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:(0,e.jsx)(H,{})}),(0,e.jsx)("button",{type:"button",className:(0,p.cn)("cursor-pointer transition-opacity",t.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),O(t.id,t.unique??!1)},onPointerDown:o=>o.stopPropagation(),title:t.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:(0,e.jsx)(_,{})}),(0,e.jsx)("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),P?.(r.id,t.id)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:(0,e.jsx)(te,{})})]}),(0,e.jsx)("div",{"data-connection-side":"right","data-field-id":t.id,"data-table-id":r.id,className:(0,p.cn)("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",b?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:s.FIELD_ROW_HEIGHT/2-5}})]},t.id)),c&&(0,e.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:s.ADD_BUTTON_HEIGHT},onClick:t=>{t.stopPropagation(),G()},onPointerDown:t=>t.stopPropagation(),children:[(0,e.jsx)("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:(0,e.jsx)("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!m&&!g&&(0,e.jsx)("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onPointerDown:t=>{if(t.stopPropagation(),t.button!==0)return;t.preventDefault();let a=r.height??(0,s.getTableHeight)(r,c);B?.(r.id,t.clientX,t.clientY,M,a,t.pointerId)},children:(0,e.jsxs)("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[(0,e.jsx)("path",{d:"M12 2v10H2",opacity:"0"}),(0,e.jsx)("path",{d:"M6 12L12 6"}),(0,e.jsx)("path",{d:"M10 12L12 10"})]})})]})});0&&(module.exports={SchemaTableRenderer});
@@ -1 +1 @@
1
- import{memo as z,useCallback as u,useRef as J,useState as P}from"react";import{cn as c}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as Q,DEFAULT_TABLE_WIDTH as Z,FIELD_ROW_HEIGHT as E,getTableHeight as $,hasNotesRow as ee,HEADER_HEIGHT as te,NOTES_ROW_HEIGHT as H}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as re}from"../utils/schema-helpers.js";import{formatUILabel as S}from"../../../lib/ui-labels.js";import{jsx as t,jsxs as d}from"react/jsx-runtime";var D=()=>d("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),_=()=>d("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),t("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),oe=({collapsed:M})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:M?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),K=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),B=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ae=()=>t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M4 8h8"})}),ne=()=>d("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"5",cy:"4",r:"1.5"}),t("circle",{cx:"11",cy:"4",r:"1.5"}),t("circle",{cx:"5",cy:"8",r:"1.5"}),t("circle",{cx:"11",cy:"8",r:"1.5"}),t("circle",{cx:"5",cy:"12",r:"1.5"}),t("circle",{cx:"11",cy:"12",r:"1.5"})]}),se=z(function({field:r,tableId:T,editable:y,readOnly:x,disabled:b,onFieldChange:h,labels:p}){let[v,m]=P(!1),[k,s]=P(r.defaultValue??""),f=y&&!x&&!b,w=()=>{m(!1),h?.(T,r.id,{defaultValue:k||void 0})};return f?v?t("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":S(p.schemaEditorDefaultValueFor,{field:r.name}),value:k,onChange:i=>s(i.target.value),onBlur:w,onKeyDown:i=>{i.key==="Enter"&&w(),i.key==="Escape"&&m(!1)},onMouseDown:i=>i.stopPropagation(),autoFocus:!0}):r.defaultValue?d("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:i=>{i.stopPropagation(),s(r.defaultValue??""),m(!0)},onMouseDown:i=>i.stopPropagation(),title:S(p.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:i=>{i.stopPropagation(),s(""),m(!0)},onMouseDown:i=>i.stopPropagation(),title:p.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?d("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:S(p.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),pe=z(function({table:r,selected:T,disabled:y,readOnly:x,editable:b,dropTarget:h,fieldTypes:p,onTableNameChange:v,onTableNotesChange:m,onToggleCollapse:k,onFieldChange:s,onFieldAdd:f,onFieldRemove:w,onFieldReorder:i,onResizeStart:W,labels:n}){let R=r.width??Z,I=r.collapsed??!1,l=b&&!x&&!y,V=p.length>0?p:re,[U,C]=P(null),[F,N]=P(null),g=J(null),A=u(e=>{v?.(r.id,e.target.value)},[r.id,v]),q=u((e,a)=>{s?.(r.id,e,{name:a})},[r.id,s]),j=u((e,a)=>{s?.(r.id,e,{type:a})},[r.id,s]),L=u((e,a)=>{s?.(r.id,e,{primaryKey:!a})},[r.id,s]),O=u((e,a)=>{s?.(r.id,e,{nullable:!a})},[r.id,s]),G=u((e,a)=>{s?.(r.id,e,{indexed:!a})},[r.id,s]),Y=u((e,a)=>{s?.(r.id,e,{unique:!a})},[r.id,s]),X=u(()=>{f?.(r.id)},[r.id,f]);return d("div",{"data-table-id":r.id,className:c("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,h?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":T?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:R,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[d("div",{className:c("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:te},children:[l?t("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:A,onMouseDown:e=>e.stopPropagation()}):t("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),t("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:e=>{e.stopPropagation(),k?.(r.id)},onMouseDown:e=>e.stopPropagation(),"aria-label":I?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:t(oe,{collapsed:I})})]}),ee(r,l)&&(l?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:e=>m?.(r.id,e.target.value),onMouseDown:e=>e.stopPropagation()})}):t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!I&&d("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((e,a)=>d("div",{"data-field-id":e.id,"data-table-id":r.id,className:c("flex items-center gap-1.5 pr-2 relative group",l?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",h?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",U===a&&"opacity-40",F===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:E},draggable:l,onDragStart:o=>{l&&(o.stopPropagation(),g.current=a,C(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{g.current!==null&&(o.preventDefault(),o.stopPropagation(),N(a))},onDragLeave:()=>{F===a&&N(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),g.current!==null&&g.current!==a&&i?.(r.id,g.current,a),g.current=null,C(null),N(null)},onDragEnd:()=>{g.current=null,C(null),N(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:E/2-5}}),l&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:E/2-6},children:t(ne,{})}),l?t("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),O(e.id,e.nullable??!1)},onMouseDown:o=>o.stopPropagation(),title:e.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):t("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?d("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),L(e.id,!0)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(D,{})}):t(D,{}),t(_,{})]}):e.primaryKey?l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),L(e.id,!0)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(D,{})}):t(D,{}):e.foreignKey?t(_,{}):l?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),L(e.id,!1)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:d("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):t("span",{className:"w-3.5 flex-shrink-0"}),l?t("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:e.name,onChange:o=>q(e.id,o.target.value),onMouseDown:o=>o.stopPropagation()}):t("span",{className:c("flex-1 min-w-0 text-xs truncate",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:e.name}),l?d("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:o=>j(e.id,o.target.value),onMouseDown:o=>o.stopPropagation(),children:[V.map(o=>t("option",{value:o,children:o},o)),!V.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:e.type}),t(se,{field:e,tableId:r.id,editable:b,readOnly:x,disabled:y,onFieldChange:s,labels:n}),e.indexed&&t(K,{}),e.unique&&t(B,{}),l&&d("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),G(e.id,e.indexed??!1)},onMouseDown:o=>o.stopPropagation(),title:e.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:t(K,{})}),t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),Y(e.id,e.unique??!1)},onMouseDown:o=>o.stopPropagation(),title:e.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:t(B,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),w?.(r.id,e.id)},onMouseDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:t(ae,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:E/2-5}})]},e.id)),l&&d("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:Q},onClick:e=>{e.stopPropagation(),X()},onMouseDown:e=>e.stopPropagation(),children:[t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!y&&!x&&t("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onMouseDown:e=>{e.stopPropagation(),e.preventDefault();let a=r.height??$(r,l);W?.(r.id,e.clientX,e.clientY,R,a)},children:d("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[t("path",{d:"M12 2v10H2",opacity:"0"}),t("path",{d:"M6 12L12 6"}),t("path",{d:"M10 12L12 10"})]})})]})});export{pe as SchemaTableRenderer};
1
+ import{memo as z,useCallback as p,useRef as J,useState as D}from"react";import{cn as c}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as Q,DEFAULT_TABLE_WIDTH as Z,FIELD_ROW_HEIGHT as P,getTableHeight as $,hasNotesRow as ee,HEADER_HEIGHT as te,NOTES_ROW_HEIGHT as H}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as re}from"../utils/schema-helpers.js";import{formatUILabel as M}from"../../../lib/ui-labels.js";import{jsx as t,jsxs as d}from"react/jsx-runtime";var E=()=>d("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),_=()=>d("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),t("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),oe=({collapsed:I})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:I?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),K=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),B=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ae=()=>t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M4 8h8"})}),ne=()=>d("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"5",cy:"4",r:"1.5"}),t("circle",{cx:"11",cy:"4",r:"1.5"}),t("circle",{cx:"5",cy:"8",r:"1.5"}),t("circle",{cx:"11",cy:"8",r:"1.5"}),t("circle",{cx:"5",cy:"12",r:"1.5"}),t("circle",{cx:"11",cy:"12",r:"1.5"})]}),ie=z(function({field:r,tableId:T,editable:y,readOnly:x,disabled:b,onFieldChange:h,labels:u}){let[v,m]=D(!1),[k,i]=D(r.defaultValue??""),f=y&&!x&&!b,w=()=>{m(!1),h?.(T,r.id,{defaultValue:k||void 0})};return f?v?t("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":M(u.schemaEditorDefaultValueFor,{field:r.name}),value:k,onChange:s=>i(s.target.value),onBlur:w,onKeyDown:s=>{s.key==="Enter"&&w(),s.key==="Escape"&&m(!1)},onPointerDown:s=>s.stopPropagation(),autoFocus:!0}):r.defaultValue?d("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:s=>{s.stopPropagation(),i(r.defaultValue??""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:M(u.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:s=>{s.stopPropagation(),i(""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:u.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?d("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:M(u.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),ue=z(function({table:r,selected:T,disabled:y,readOnly:x,editable:b,dropTarget:h,fieldTypes:u,onTableNameChange:v,onTableNotesChange:m,onToggleCollapse:k,onFieldChange:i,onFieldAdd:f,onFieldRemove:w,onFieldReorder:s,onResizeStart:W,labels:n}){let R=r.width??Z,C=r.collapsed??!1,l=b&&!x&&!y,V=u.length>0?u:re,[U,L]=D(null),[F,N]=D(null),g=J(null),A=p(e=>{v?.(r.id,e.target.value)},[r.id,v]),q=p((e,a)=>{i?.(r.id,e,{name:a})},[r.id,i]),j=p((e,a)=>{i?.(r.id,e,{type:a})},[r.id,i]),S=p((e,a)=>{i?.(r.id,e,{primaryKey:!a})},[r.id,i]),O=p((e,a)=>{i?.(r.id,e,{nullable:!a})},[r.id,i]),G=p((e,a)=>{i?.(r.id,e,{indexed:!a})},[r.id,i]),Y=p((e,a)=>{i?.(r.id,e,{unique:!a})},[r.id,i]),X=p(()=>{f?.(r.id)},[r.id,f]);return d("div",{"data-table-id":r.id,className:c("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,h?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":T?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:R,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[d("div",{className:c("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:te},children:[l?t("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:A,onPointerDown:e=>e.stopPropagation()}):t("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),t("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:e=>{e.stopPropagation(),k?.(r.id)},onPointerDown:e=>e.stopPropagation(),"aria-label":C?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:t(oe,{collapsed:C})})]}),ee(r,l)&&(l?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:e=>m?.(r.id,e.target.value),onPointerDown:e=>e.stopPropagation()})}):t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!C&&d("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((e,a)=>d("div",{"data-field-id":e.id,"data-table-id":r.id,className:c("flex items-center gap-1.5 pr-2 relative group",l?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",h?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",U===a&&"opacity-40",F===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:P},draggable:l,onDragStart:o=>{l&&(o.stopPropagation(),g.current=a,L(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{g.current!==null&&(o.preventDefault(),o.stopPropagation(),N(a))},onDragLeave:()=>{F===a&&N(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),g.current!==null&&g.current!==a&&s?.(r.id,g.current,a),g.current=null,L(null),N(null)},onDragEnd:()=>{g.current=null,L(null),N(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:P/2-5}}),l&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:P/2-6},children:t(ne,{})}),l?t("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),O(e.id,e.nullable??!1)},onPointerDown:o=>o.stopPropagation(),title:e.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):t("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?d("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}),t(_,{})]}):e.primaryKey?l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}):e.foreignKey?t(_,{}):l?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!1)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:d("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):t("span",{className:"w-3.5 flex-shrink-0"}),l?t("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:e.name,onChange:o=>q(e.id,o.target.value),onPointerDown:o=>o.stopPropagation()}):t("span",{className:c("flex-1 min-w-0 text-xs truncate",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:e.name}),l?d("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:o=>j(e.id,o.target.value),onPointerDown:o=>o.stopPropagation(),children:[V.map(o=>t("option",{value:o,children:o},o)),!V.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:e.type}),t(ie,{field:e,tableId:r.id,editable:b,readOnly:x,disabled:y,onFieldChange:i,labels:n}),e.indexed&&t(K,{}),e.unique&&t(B,{}),l&&d("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),G(e.id,e.indexed??!1)},onPointerDown:o=>o.stopPropagation(),title:e.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:t(K,{})}),t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),Y(e.id,e.unique??!1)},onPointerDown:o=>o.stopPropagation(),title:e.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:t(B,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),w?.(r.id,e.id)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:t(ae,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:P/2-5}})]},e.id)),l&&d("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:Q},onClick:e=>{e.stopPropagation(),X()},onPointerDown:e=>e.stopPropagation(),children:[t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!y&&!x&&t("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onPointerDown:e=>{if(e.stopPropagation(),e.button!==0)return;e.preventDefault();let a=r.height??$(r,l);W?.(r.id,e.clientX,e.clientY,R,a,e.pointerId)},children:d("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[t("path",{d:"M12 2v10H2",opacity:"0"}),t("path",{d:"M6 12L12 6"}),t("path",{d:"M10 12L12 10"})]})})]})});export{ue as SchemaTableRenderer};
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var X=(n,i)=>{for(var d in i)u(n,d,{get:i[d],enumerable:!0})},Y=(n,i,d,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of K(i))!W.call(n,s)&&s!==d&&u(n,s,{get:()=>i[s],enumerable:!(g=j(i,s))||g.enumerable});return n};var _=n=>Y(u({},"__esModule",{value:!0}),n);var mo={};X(mo,{SchemaToolbar:()=>co});module.exports=_(mo);var e=require("react"),M=require("../../../lib/cn.cjs"),t=require("../../button/Button.cjs"),x=require("../../button-group/ButtonGroup.cjs"),r=require("../../tooltip/Tooltip.cjs"),h=require("../../modal/Modal.cjs"),v=require("../../form/input/Input.cjs"),o=require("react/jsx-runtime"),$=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),oo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),ao=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),eo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),to=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),ro=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),io=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),lo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),no=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),so=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),go=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),co=(0,e.memo)(function({zoom:i,onZoomIn:d,onZoomOut:g,onResetView:s,onFitToContent:T,onAddTable:R,onExportJSON:z,onImportJSON:C,onExportSQL:c,onUndo:k,onRedo:f,canUndo:H=!1,canRedo:L=!1,onAutoLayout:w,disabled:l,className:N,labels:a}){let[V,E]=(0,e.useState)(!1),[S,p]=(0,e.useState)(!1),[O,I]=(0,e.useState)(!1),[B,D]=(0,e.useState)(""),[m,b]=(0,e.useState)(""),[A,q]=(0,e.useState)(""),Z=(0,e.useCallback)(()=>{D(z()),E(!0)},[z]),F=(0,e.useCallback)(()=>{m.trim()&&(C(m.trim()),b(""),p(!1))},[m,C]),J=(0,e.useCallback)(()=>{b(""),p(!1)},[]),U=(0,e.useCallback)(()=>{E(!1)},[]),P=(0,e.useCallback)(()=>{c&&(q(c()),I(!0))},[c]),G=(0,e.useCallback)(()=>{I(!1)},[]),Q=Math.round(i*100);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:(0,M.cn)("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",N),"data-testid":"schema-toolbar",onMouseDown:y=>y.stopPropagation(),children:[(0,o.jsxs)(x.ButtonGroup,{size:"sm",children:[(0,o.jsx)(r.Tooltip,{content:a.editorZoomIn,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)($,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:d,disabled:l,"aria-label":a.editorZoomIn})}),(0,o.jsx)(r.Tooltip,{content:a.editorZoomOut,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(oo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:g,disabled:l,"aria-label":a.editorZoomOut})})]}),(0,o.jsxs)("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[Q,"%"]}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.editorResetView,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(ao,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:l,"aria-label":a.editorResetView})}),(0,o.jsx)(r.Tooltip,{content:a.editorFitToContent,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(eo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:T,disabled:l,"aria-label":a.editorFitToContent})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorAddTable,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(to,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:R,disabled:l,"aria-label":a.schemaEditorAddTable})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.editorExportJson,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(ro,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:Z,disabled:l,"aria-label":a.editorExportJson})}),(0,o.jsx)(r.Tooltip,{content:a.editorImportJson,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(io,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>p(!0),disabled:l,"aria-label":a.editorImportJson})}),c&&(0,o.jsx)(r.Tooltip,{content:a.schemaEditorExportSql,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(lo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:P,disabled:l,"aria-label":a.schemaEditorExportSql})}),(k||f)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsxs)(x.ButtonGroup,{size:"sm",children:[(0,o.jsx)(r.Tooltip,{content:a.schemaEditorUndoTooltip,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(no,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:k,disabled:l||!H,"aria-label":a.schemaEditorUndo})}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorRedoTooltip,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(so,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:f,disabled:l||!L,"aria-label":a.schemaEditorRedo})})]})]}),w&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorAutoLayout,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(go,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:w,disabled:l,"aria-label":a.schemaEditorAutoLayout})})]})]}),(0,o.jsx)(h.Modal,{isOpen:V,onClose:U,title:a.schemaEditorExportTitle,description:a.schemaEditorExportDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:(0,o.jsx)(v.Input,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:B,readOnly:!0,size:"sm"})}),(0,o.jsx)(h.Modal,{isOpen:S,onClose:J,title:a.schemaEditorImportTitle,description:a.schemaEditorImportDescription,size:"lg",showSubmit:!0,submitLabel:a.editorImport,onSubmitClick:F,showCancel:!0,cancelLabel:a.cancel,children:(0,o.jsx)(v.Input,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:m,onChange:y=>b(y.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),(0,o.jsx)(h.Modal,{isOpen:O,onClose:G,title:a.schemaEditorExportSql,description:a.schemaEditorSqlDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:(0,o.jsx)(v.Input,{label:"SQL",multiline:!0,rows:16,value:A,readOnly:!0,size:"sm"})})]})});0&&(module.exports={SchemaToolbar});
1
+ "use strict";var x=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var _=(n,i)=>{for(var d in i)x(n,d,{get:i[d],enumerable:!0})},$=(n,i,d,c)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of X(i))!Y.call(n,s)&&s!==d&&x(n,s,{get:()=>i[s],enumerable:!(c=W(i,s))||c.enumerable});return n};var oo=n=>$(x({},"__esModule",{value:!0}),n);var vo={};_(vo,{SchemaToolbar:()=>ho});module.exports=oo(vo);var e=require("react"),R=require("../../../lib/cn.cjs"),t=require("../../button/Button.cjs"),z=require("../../button-group/ButtonGroup.cjs"),r=require("../../tooltip/Tooltip.cjs"),p=require("../../modal/Modal.cjs"),b=require("../../form/input/Input.cjs"),o=require("react/jsx-runtime"),ao=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),eo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),to=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),ro=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),io=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),lo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),no=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),so=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),go=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),co=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),mo=()=>(0,o.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,o.jsx)("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),ho=(0,e.memo)(function({zoom:i,onZoomIn:d,onZoomOut:c,onResetView:s,onFitToContent:H,onAddTable:L,onExportJSON:C,onImportJSON:k,onExportSQL:m,onUndo:f,onRedo:w,canUndo:N=!1,canRedo:V=!1,onAutoLayout:E,disabled:l,className:S,labels:a}){let[O,I]=(0,e.useState)(!1),[B,u]=(0,e.useState)(!1),[D,T]=(0,e.useState)(!1),[A,q]=(0,e.useState)(""),[h,y]=(0,e.useState)(""),[M,v]=(0,e.useState)(null),[Z,F]=(0,e.useState)(""),J=(0,e.useCallback)(()=>{q(C()),I(!0)},[C]),U=(0,e.useCallback)(()=>{if(!h.trim())return;let g=k(h.trim());if(g)return v(g),!1;y(""),v(null),u(!1)},[h,k]),P=(0,e.useCallback)(()=>{y(""),v(null),u(!1)},[]),G=(0,e.useCallback)(()=>{I(!1)},[]),Q=(0,e.useCallback)(()=>{m&&(F(m()),T(!0))},[m]),j=(0,e.useCallback)(()=>{T(!1)},[]),K=Math.round(i*100);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:(0,R.cn)("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",S),"data-testid":"schema-toolbar",onPointerDown:g=>g.stopPropagation(),children:[(0,o.jsxs)(z.ButtonGroup,{size:"sm",children:[(0,o.jsx)(r.Tooltip,{content:a.editorZoomIn,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(ao,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:d,disabled:l,"aria-label":a.editorZoomIn})}),(0,o.jsx)(r.Tooltip,{content:a.editorZoomOut,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(eo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:c,disabled:l,"aria-label":a.editorZoomOut})})]}),(0,o.jsxs)("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[K,"%"]}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.editorResetView,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(to,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:s,disabled:l,"aria-label":a.editorResetView})}),(0,o.jsx)(r.Tooltip,{content:a.editorFitToContent,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(ro,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:H,disabled:l,"aria-label":a.editorFitToContent})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorAddTable,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(io,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:L,disabled:l,"aria-label":a.schemaEditorAddTable})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.editorExportJson,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(lo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:J,disabled:l,"aria-label":a.editorExportJson})}),(0,o.jsx)(r.Tooltip,{content:a.editorImportJson,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(no,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>u(!0),disabled:l,"aria-label":a.editorImportJson})}),m&&(0,o.jsx)(r.Tooltip,{content:a.schemaEditorExportSql,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(so,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:Q,disabled:l,"aria-label":a.schemaEditorExportSql})}),(f||w)&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsxs)(z.ButtonGroup,{size:"sm",children:[(0,o.jsx)(r.Tooltip,{content:a.schemaEditorUndoTooltip,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(go,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:f,disabled:l||!N,"aria-label":a.schemaEditorUndo})}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorRedoTooltip,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(co,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:w,disabled:l||!V,"aria-label":a.schemaEditorRedo})})]})]}),E&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(r.Tooltip,{content:a.schemaEditorAutoLayout,size:"sm",position:"bottom",children:(0,o.jsx)(t.Button,{icon:(0,o.jsx)(mo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:E,disabled:l,"aria-label":a.schemaEditorAutoLayout})})]})]}),(0,o.jsx)(p.Modal,{isOpen:O,onClose:G,title:a.schemaEditorExportTitle,description:a.schemaEditorExportDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:(0,o.jsx)(b.Input,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:A,readOnly:!0,size:"sm"})}),(0,o.jsx)(p.Modal,{isOpen:B,onClose:P,title:a.schemaEditorImportTitle,description:a.schemaEditorImportDescription,size:"lg",showSubmit:!0,submitLabel:a.editorImport,onSubmitClick:U,showCancel:!0,cancelLabel:a.cancel,children:(0,o.jsx)(b.Input,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:h,onChange:g=>{y(g.target.value),v(null)},placeholder:'{"tables": [], "relations": []}',error:M!==null,helperText:M??void 0,size:"sm"})}),(0,o.jsx)(p.Modal,{isOpen:D,onClose:j,title:a.schemaEditorExportSql,description:a.schemaEditorSqlDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:(0,o.jsx)(b.Input,{label:"SQL",multiline:!0,rows:16,value:Z,readOnly:!0,size:"sm"})})]})});0&&(module.exports={SchemaToolbar});
@@ -1 +1 @@
1
- import{memo as j,useState as l,useCallback as n}from"react";import{cn as K}from"../../../lib/cn.js";import{Button as t}from"../../button/Button.js";import{ButtonGroup as f}from"../../button-group/ButtonGroup.js";import{Tooltip as r}from"../../tooltip/Tooltip.js";import{Modal as h}from"../../modal/Modal.js";import{Input as v}from"../../form/input/Input.js";import{Fragment as p,jsx as o,jsxs as i}from"react/jsx-runtime";var W=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),X=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),Y=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),_=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),$=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),oo=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),ao=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),eo=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),to=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),ro=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),io=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),po=j(function({zoom:w,onZoomIn:E,onZoomOut:I,onResetView:M,onFitToContent:T,onAddTable:R,onExportJSON:b,onImportJSON:y,onExportSQL:s,onUndo:u,onRedo:x,canUndo:H=!1,canRedo:L=!1,onAutoLayout:z,disabled:e,className:N,labels:a}){let[V,C]=l(!1),[S,g]=l(!1),[O,k]=l(!1),[B,D]=l(""),[d,c]=l(""),[A,q]=l(""),Z=n(()=>{D(b()),C(!0)},[b]),F=n(()=>{d.trim()&&(y(d.trim()),c(""),g(!1))},[d,y]),J=n(()=>{c(""),g(!1)},[]),U=n(()=>{C(!1)},[]),P=n(()=>{s&&(q(s()),k(!0))},[s]),G=n(()=>{k(!1)},[]),Q=Math.round(w*100);return i(p,{children:[i("div",{className:K("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",N),"data-testid":"schema-toolbar",onMouseDown:m=>m.stopPropagation(),children:[i(f,{size:"sm",children:[o(r,{content:a.editorZoomIn,size:"sm",position:"bottom",children:o(t,{icon:o(W,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:E,disabled:e,"aria-label":a.editorZoomIn})}),o(r,{content:a.editorZoomOut,size:"sm",position:"bottom",children:o(t,{icon:o(X,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:I,disabled:e,"aria-label":a.editorZoomOut})})]}),i("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[Q,"%"]}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.editorResetView,size:"sm",position:"bottom",children:o(t,{icon:o(Y,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:M,disabled:e,"aria-label":a.editorResetView})}),o(r,{content:a.editorFitToContent,size:"sm",position:"bottom",children:o(t,{icon:o(_,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:T,disabled:e,"aria-label":a.editorFitToContent})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.schemaEditorAddTable,size:"sm",position:"bottom",children:o(t,{icon:o($,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:R,disabled:e,"aria-label":a.schemaEditorAddTable})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.editorExportJson,size:"sm",position:"bottom",children:o(t,{icon:o(oo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:Z,disabled:e,"aria-label":a.editorExportJson})}),o(r,{content:a.editorImportJson,size:"sm",position:"bottom",children:o(t,{icon:o(ao,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>g(!0),disabled:e,"aria-label":a.editorImportJson})}),s&&o(r,{content:a.schemaEditorExportSql,size:"sm",position:"bottom",children:o(t,{icon:o(eo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:P,disabled:e,"aria-label":a.schemaEditorExportSql})}),(u||x)&&i(p,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),i(f,{size:"sm",children:[o(r,{content:a.schemaEditorUndoTooltip,size:"sm",position:"bottom",children:o(t,{icon:o(to,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:u,disabled:e||!H,"aria-label":a.schemaEditorUndo})}),o(r,{content:a.schemaEditorRedoTooltip,size:"sm",position:"bottom",children:o(t,{icon:o(ro,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:x,disabled:e||!L,"aria-label":a.schemaEditorRedo})})]})]}),z&&i(p,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.schemaEditorAutoLayout,size:"sm",position:"bottom",children:o(t,{icon:o(io,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:z,disabled:e,"aria-label":a.schemaEditorAutoLayout})})]})]}),o(h,{isOpen:V,onClose:U,title:a.schemaEditorExportTitle,description:a.schemaEditorExportDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:o(v,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:B,readOnly:!0,size:"sm"})}),o(h,{isOpen:S,onClose:J,title:a.schemaEditorImportTitle,description:a.schemaEditorImportDescription,size:"lg",showSubmit:!0,submitLabel:a.editorImport,onSubmitClick:F,showCancel:!0,cancelLabel:a.cancel,children:o(v,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:d,onChange:m=>c(m.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),o(h,{isOpen:O,onClose:G,title:a.schemaEditorExportSql,description:a.schemaEditorSqlDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:o(v,{label:"SQL",multiline:!0,rows:16,value:A,readOnly:!0,size:"sm"})})]})});export{po as SchemaToolbar};
1
+ import{memo as W,useState as i,useCallback as s}from"react";import{cn as X}from"../../../lib/cn.js";import{Button as t}from"../../button/Button.js";import{ButtonGroup as E}from"../../button-group/ButtonGroup.js";import{Tooltip as r}from"../../tooltip/Tooltip.js";import{Modal as v}from"../../modal/Modal.js";import{Input as p}from"../../form/input/Input.js";import{Fragment as b,jsx as o,jsxs as l}from"react/jsx-runtime";var Y=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z",clipRule:"evenodd"})}),_=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M5 10a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1z",clipRule:"evenodd"})}),$=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),oo=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13 0a1 1 0 01-2 0v-1.586l-2.293 2.293a1 1 0 01-1.414-1.414L13.586 9H12a1 1 0 010-2h4a1 1 0 011 1v4z"})}),ao=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M6 2a2 2 0 00-2 2v12a2 2 0 002 2h8a2 2 0 002-2V4a2 2 0 00-2-2H6zm4 5a1 1 0 011 1v1h1a1 1 0 110 2h-1v1a1 1 0 11-2 0v-1H8a1 1 0 110-2h1V8a1 1 0 011-1z",clipRule:"evenodd"})}),eo=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",clipRule:"evenodd"})}),to=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z",clipRule:"evenodd"})}),ro=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M2 5a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm14 1a1 1 0 11-2 0 1 1 0 012 0zM2 13a2 2 0 012-2h12a2 2 0 012 2v2a2 2 0 01-2 2H4a2 2 0 01-2-2v-2zm14 1a1 1 0 11-2 0 1 1 0 012 0z",clipRule:"evenodd"})}),io=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M7.707 3.293a1 1 0 010 1.414L5.414 7H11a7 7 0 017 7v2a1 1 0 11-2 0v-2a5 5 0 00-5-5H5.414l2.293 2.293a1 1 0 11-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})}),lo=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{fillRule:"evenodd",d:"M12.293 3.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 9H9a5 5 0 00-5 5v2a1 1 0 11-2 0v-2a7 7 0 017-7h5.586l-2.293-2.293a1 1 0 010-1.414z",clipRule:"evenodd"})}),no=()=>o("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:o("path",{d:"M3 3h4v4H3V3zm0 10h4v4H3v-4zm10-10h4v4h-4V3zm0 10h4v4h-4v-4zM7 5h6v1H7V5zm0 8h6v1H7v-1zM5 7v6h1V7H5zm8 0v6h1V7h-1z"})}),uo=W(function({zoom:I,onZoomIn:T,onZoomOut:M,onResetView:R,onFitToContent:H,onAddTable:L,onExportJSON:u,onImportJSON:y,onExportSQL:d,onUndo:x,onRedo:z,canUndo:N=!1,canRedo:V=!1,onAutoLayout:C,disabled:e,className:S,labels:a}){let[O,k]=i(!1),[B,m]=i(!1),[D,f]=i(!1),[A,q]=i(""),[g,h]=i(""),[w,c]=i(null),[Z,F]=i(""),J=s(()=>{q(u()),k(!0)},[u]),U=s(()=>{if(!g.trim())return;let n=y(g.trim());if(n)return c(n),!1;h(""),c(null),m(!1)},[g,y]),P=s(()=>{h(""),c(null),m(!1)},[]),G=s(()=>{k(!1)},[]),Q=s(()=>{d&&(F(d()),f(!0))},[d]),j=s(()=>{f(!1)},[]),K=Math.round(I*100);return l(b,{children:[l("div",{className:X("absolute top-3 left-3 z-20 flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg shadow-md border border-gray-200 dark:border-gray-600 px-2 py-1.5",S),"data-testid":"schema-toolbar",onPointerDown:n=>n.stopPropagation(),children:[l(E,{size:"sm",children:[o(r,{content:a.editorZoomIn,size:"sm",position:"bottom",children:o(t,{icon:o(Y,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:T,disabled:e,"aria-label":a.editorZoomIn})}),o(r,{content:a.editorZoomOut,size:"sm",position:"bottom",children:o(t,{icon:o(_,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:M,disabled:e,"aria-label":a.editorZoomOut})})]}),l("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[K,"%"]}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.editorResetView,size:"sm",position:"bottom",children:o(t,{icon:o($,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:R,disabled:e,"aria-label":a.editorResetView})}),o(r,{content:a.editorFitToContent,size:"sm",position:"bottom",children:o(t,{icon:o(oo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:H,disabled:e,"aria-label":a.editorFitToContent})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.schemaEditorAddTable,size:"sm",position:"bottom",children:o(t,{icon:o(ao,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:L,disabled:e,"aria-label":a.schemaEditorAddTable})}),o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.editorExportJson,size:"sm",position:"bottom",children:o(t,{icon:o(eo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:J,disabled:e,"aria-label":a.editorExportJson})}),o(r,{content:a.editorImportJson,size:"sm",position:"bottom",children:o(t,{icon:o(to,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:()=>m(!0),disabled:e,"aria-label":a.editorImportJson})}),d&&o(r,{content:a.schemaEditorExportSql,size:"sm",position:"bottom",children:o(t,{icon:o(ro,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:Q,disabled:e,"aria-label":a.schemaEditorExportSql})}),(x||z)&&l(b,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),l(E,{size:"sm",children:[o(r,{content:a.schemaEditorUndoTooltip,size:"sm",position:"bottom",children:o(t,{icon:o(io,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:x,disabled:e||!N,"aria-label":a.schemaEditorUndo})}),o(r,{content:a.schemaEditorRedoTooltip,size:"sm",position:"bottom",children:o(t,{icon:o(lo,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:z,disabled:e||!V,"aria-label":a.schemaEditorRedo})})]})]}),C&&l(b,{children:[o("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),o(r,{content:a.schemaEditorAutoLayout,size:"sm",position:"bottom",children:o(t,{icon:o(no,{}),size:"sm",bgColor:"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600",textColor:"text-gray-700 dark:text-gray-200",onClick:C,disabled:e,"aria-label":a.schemaEditorAutoLayout})})]})]}),o(v,{isOpen:O,onClose:G,title:a.schemaEditorExportTitle,description:a.schemaEditorExportDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:o(p,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:A,readOnly:!0,size:"sm"})}),o(v,{isOpen:B,onClose:P,title:a.schemaEditorImportTitle,description:a.schemaEditorImportDescription,size:"lg",showSubmit:!0,submitLabel:a.editorImport,onSubmitClick:U,showCancel:!0,cancelLabel:a.cancel,children:o(p,{label:a.schemaEditorJsonField,multiline:!0,rows:12,value:g,onChange:n=>{h(n.target.value),c(null)},placeholder:'{"tables": [], "relations": []}',error:w!==null,helperText:w??void 0,size:"sm"})}),o(v,{isOpen:D,onClose:j,title:a.schemaEditorExportSql,description:a.schemaEditorSqlDescription,size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:a.editorClose,children:o(p,{label:"SQL",multiline:!0,rows:16,value:Z,readOnly:!0,size:"sm"})})]})});export{uo as SchemaToolbar};
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var n in t)y(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!g.call(e,r)&&r!==n&&y(e,r,{get:()=>t[r],enumerable:!(o=w(t,r))||o.enumerable});return e};var A=e=>S(y({},"__esModule",{value:!0}),e);var K={};b(K,{readSchemaJSON:()=>x});module.exports=A(K);function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var d=e=>typeof e=="string"&&e!=="",u=e=>typeof e=="number"&&Number.isFinite(e),a=(e,t)=>e===void 0||t(e),l=e=>typeof e=="string",p=e=>typeof e=="boolean";function $(e){return c(e)&&d(e.tableId)&&d(e.fieldId)}var I=new Set(["1:1","1:n","n:1","n:n"]);function x(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,reason:"json"}}let n=o=>({ok:!1,reason:"content",path:o});if(!c(t))return n("$");if(!Array.isArray(t.tables))return n("tables");if(!Array.isArray(t.relations))return n("relations");for(let[o,r]of t.tables.entries()){let i=`tables[${o}]`;if(!c(r))return n(i);if(!d(r.id))return n(`${i}.id`);if(!l(r.name))return n(`${i}.name`);if(!u(r.x))return n(`${i}.x`);if(!u(r.y))return n(`${i}.y`);if(!a(r.width,u))return n(`${i}.width`);if(!a(r.height,u))return n(`${i}.height`);if(!a(r.notes,l))return n(`${i}.notes`);if(!a(r.color,l))return n(`${i}.color`);if(!a(r.collapsed,p))return n(`${i}.collapsed`);if(!a(r.locked,p))return n(`${i}.locked`);if(!Array.isArray(r.fields))return n(`${i}.fields`);for(let[k,s]of r.fields.entries()){let f=`${i}.fields[${k}]`;if(!c(s))return n(f);if(!d(s.id))return n(`${f}.id`);if(!l(s.name))return n(`${f}.name`);if(!l(s.type))return n(`${f}.type`);for(let m of["nullable","primaryKey","unique","indexed"])if(!a(s[m],p))return n(`${f}.${m}`);if(!a(s.defaultValue,l))return n(`${f}.defaultValue`);if(s.foreignKey!==void 0&&s.foreignKey!==null&&!$(s.foreignKey))return n(`${f}.foreignKey`)}}for(let[o,r]of t.relations.entries()){let i=`relations[${o}]`;if(!c(r))return n(i);if(!d(r.id))return n(`${i}.id`);if(!$(r.from))return n(`${i}.from`);if(!$(r.to))return n(`${i}.to`);if(r.cardinality!==void 0&&!I.has(String(r.cardinality)))return n(`${i}.cardinality`)}if(t.viewport!==void 0){let o=t.viewport;if(!c(o)||!u(o.x)||!u(o.y)||!u(o.zoom)||o.zoom<=0)return n("viewport")}return{ok:!0,value:t}}0&&(module.exports={readSchemaJSON});
@@ -0,0 +1 @@
1
+ function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var d=e=>typeof e=="string"&&e!=="",u=e=>typeof e=="number"&&Number.isFinite(e),a=(e,i)=>e===void 0||i(e),l=e=>typeof e=="string",y=e=>typeof e=="boolean";function p(e){return c(e)&&d(e.tableId)&&d(e.fieldId)}var k=new Set(["1:1","1:n","n:1","n:n"]);function w(e){let i;try{i=JSON.parse(e)}catch{return{ok:!1,reason:"json"}}let n=o=>({ok:!1,reason:"content",path:o});if(!c(i))return n("$");if(!Array.isArray(i.tables))return n("tables");if(!Array.isArray(i.relations))return n("relations");for(let[o,r]of i.tables.entries()){let t=`tables[${o}]`;if(!c(r))return n(t);if(!d(r.id))return n(`${t}.id`);if(!l(r.name))return n(`${t}.name`);if(!u(r.x))return n(`${t}.x`);if(!u(r.y))return n(`${t}.y`);if(!a(r.width,u))return n(`${t}.width`);if(!a(r.height,u))return n(`${t}.height`);if(!a(r.notes,l))return n(`${t}.notes`);if(!a(r.color,l))return n(`${t}.color`);if(!a(r.collapsed,y))return n(`${t}.collapsed`);if(!a(r.locked,y))return n(`${t}.locked`);if(!Array.isArray(r.fields))return n(`${t}.fields`);for(let[m,s]of r.fields.entries()){let f=`${t}.fields[${m}]`;if(!c(s))return n(f);if(!d(s.id))return n(`${f}.id`);if(!l(s.name))return n(`${f}.name`);if(!l(s.type))return n(`${f}.type`);for(let $ of["nullable","primaryKey","unique","indexed"])if(!a(s[$],y))return n(`${f}.${$}`);if(!a(s.defaultValue,l))return n(`${f}.defaultValue`);if(s.foreignKey!==void 0&&s.foreignKey!==null&&!p(s.foreignKey))return n(`${f}.foreignKey`)}}for(let[o,r]of i.relations.entries()){let t=`relations[${o}]`;if(!c(r))return n(t);if(!d(r.id))return n(`${t}.id`);if(!p(r.from))return n(`${t}.from`);if(!p(r.to))return n(`${t}.to`);if(r.cardinality!==void 0&&!k.has(String(r.cardinality)))return n(`${t}.cardinality`)}if(i.viewport!==void 0){let o=i.viewport;if(!c(o)||!u(o.x)||!u(o.y)||!u(o.zoom)||o.zoom<=0)return n("viewport")}return{ok:!0,value:i}}export{w as readSchemaJSON};
@@ -1,9 +1,10 @@
1
- "use strict";var E=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var N=(e,n)=>{for(var s in n)E(e,s,{get:n[s],enumerable:!0})},A=(e,n,s,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of R(n))!y.call(e,r)&&r!==s&&E(e,r,{get:()=>n[r],enumerable:!(o=S(n,r))||o.enumerable});return e};var $=e=>A(E({},"__esModule",{value:!0}),e);var b={};N(b,{generateSQL:()=>M});module.exports=$(b);var I=require("./foreign-keys.cjs");function a(e){return`"${e.replace(/"/g,'""')}"`}function h(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function L(e){let n=[a(e.name)];return e.type==="serial"||e.type,n.push(h(e.type)),e.primaryKey&&n.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&n.push("NOT NULL"),e.unique&&!e.primaryKey&&n.push("UNIQUE"),e.defaultValue&&n.push(`DEFAULT ${e.defaultValue}`)," "+n.join(" ")}function F(e,n,s){let o=[],r=[];for(let t of e.fields)o.push(L(t));let p=new Set;for(let t of e.fields)for(let d of s.get(t)??[]){let l=n.find(c=>c.id===d.tableId),T=l?.fields.find(c=>c.id===d.fieldId);if(!l||!T)continue;let g=`fk_${e.name}_${t.name}`,u=g;for(let c=2;p.has(u);c++)u=`${g}_${c}`;p.add(u),r.push(` CONSTRAINT ${a(u)} FOREIGN KEY (${a(t.name)}) REFERENCES ${a(l.name)} (${a(T.name)})`)}let i=[];for(let t of e.fields)t.indexed&&!t.primaryKey&&!t.unique&&i.push(`CREATE INDEX ${a(`idx_${e.name}_${t.name}`)} ON ${a(e.name)} (${a(t.name)});`);let m=[...o,...r],f=`CREATE TABLE ${a(e.name)} (
2
- ${m.join(`,
1
+ "use strict";var S=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var M=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},F=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of $(n))!L.call(e,i)&&i!==t&&S(e,i,{get:()=>n[i],enumerable:!(o=N(n,i))||o.enumerable});return e};var b=e=>F(S({},"__esModule",{value:!0}),e);var D={};M(D,{generateSQL:()=>B});module.exports=b(D);var y=require("./foreign-keys.cjs");function a(e){return`"${e.replace(/"/g,'""')}"`}function C(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function O(e,n){let t=[a(e.name),C(e.type)];return n&&t.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&t.push("NOT NULL"),e.unique&&!n&&t.push("UNIQUE"),e.defaultValue&&t.push(`DEFAULT ${e.defaultValue}`)," "+t.join(" ")}function U(e,n){let t=new Set;for(let o of e.fields)for(let i of n.get(o)??[])i.tableId!==e.id&&t.add(i.tableId);return t}function j(e,n,t,o){let i=e.fields.filter(s=>s.primaryKey),f=i.length===1,p=e.fields.map(s=>O(s,f&&s.primaryKey===!0)),d=[],l=[];i.length>1&&d.push(` PRIMARY KEY (${i.map(s=>a(s.name)).join(", ")})`);let r=new Set;for(let s of e.fields)for(let E of t.get(s)??[]){let T=n.find(m=>m.id===E.tableId),I=T?.fields.find(m=>m.id===E.fieldId);if(!T||!I)continue;let R=`fk_${e.name}_${s.name}`,h=R;for(let m=2;r.has(h);m++)h=`${R}_${m}`;r.add(h);let A=`CONSTRAINT ${a(h)} FOREIGN KEY (${a(s.name)}) REFERENCES ${a(T.name)} (${a(I.name)})`;o.has(T.id)?d.push(` ${A}`):l.push(`ALTER TABLE ${a(e.name)} ADD ${A};`)}let c=[];for(let s of e.fields){let E=s.primaryKey&&f;s.indexed&&!E&&!s.unique&&c.push(`CREATE INDEX ${a(`idx_${e.name}_${s.name}`)} ON ${a(e.name)} (${a(s.name)});`)}let u=[...p,...d],g=`CREATE TABLE ${a(e.name)} (
2
+ ${u.join(`,
3
3
  `)}
4
- );`;return i.length>0?f+`
4
+ );`;return{sql:c.length>0?g+`
5
5
 
6
- `+i.join(`
7
- `):f}function M(e){let{tables:n}=e;if(n.length===0)return"-- No tables defined";let s=(0,I.getFieldReferences)(e),o=i=>i.fields.some(m=>s.has(m));return[...n].sort((i,m)=>{let f=o(i),t=o(m);return f&&!t?1:!f&&t?-1:0}).map(i=>F(i,n,s)).join(`
6
+ `+c.join(`
7
+ `):g,deferred:l}}function B(e){let{tables:n}=e;if(n.length===0)return"-- No tables defined";let t=(0,y.getFieldReferences)(e),o=new Set(n.map(r=>r.id)),i=new Map(n.map(r=>[r.id,[...U(r,t)].filter(c=>o.has(c))])),f=new Set,p=[...n],d=[],l=[];for(;p.length>0;){let r=p.findIndex(g=>(i.get(g.id)??[]).every(s=>f.has(s)));r===-1&&(r=0);let[c]=p.splice(r,1);f.add(c.id);let u=j(c,n,t,f);d.push(u.sql),l.push(...u.deferred)}return l.length>0&&d.push(l.join(`
8
+ `)),d.join(`
8
9
 
9
10
  `)}0&&(module.exports={generateSQL});
@@ -1,9 +1,10 @@
1
- import{getFieldReferences as h}from"./foreign-keys.js";function r(e){return`"${e.replace(/"/g,'""')}"`}function g(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function I(e){let n=[r(e.name)];return e.type==="serial"||e.type,n.push(g(e.type)),e.primaryKey&&n.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&n.push("NOT NULL"),e.unique&&!e.primaryKey&&n.push("UNIQUE"),e.defaultValue&&n.push(`DEFAULT ${e.defaultValue}`)," "+n.join(" ")}function S(e,n,m){let a=[],u=[];for(let t of e.fields)a.push(I(t));let p=new Set;for(let t of e.fields)for(let E of m.get(t)??[]){let l=n.find(i=>i.id===E.tableId),d=l?.fields.find(i=>i.id===E.fieldId);if(!l||!d)continue;let T=`fk_${e.name}_${t.name}`,f=T;for(let i=2;p.has(f);i++)f=`${T}_${i}`;p.add(f),u.push(` CONSTRAINT ${r(f)} FOREIGN KEY (${r(t.name)}) REFERENCES ${r(l.name)} (${r(d.name)})`)}let s=[];for(let t of e.fields)t.indexed&&!t.primaryKey&&!t.unique&&s.push(`CREATE INDEX ${r(`idx_${e.name}_${t.name}`)} ON ${r(e.name)} (${r(t.name)});`);let o=[...a,...u],c=`CREATE TABLE ${r(e.name)} (
2
- ${o.join(`,
1
+ import{getFieldReferences as A}from"./foreign-keys.js";function r(e){return`"${e.replace(/"/g,'""')}"`}function y(e){return{text:"TEXT",varchar:"VARCHAR(255)",char:"CHAR(1)",int2:"SMALLINT",int4:"INTEGER",int8:"BIGINT",serial:"SERIAL",bigserial:"BIGSERIAL",float4:"REAL",float8:"DOUBLE PRECISION",numeric:"NUMERIC",decimal:"DECIMAL",bool:"BOOLEAN",date:"DATE",time:"TIME",timestamp:"TIMESTAMP",timestamptz:"TIMESTAMP WITH TIME ZONE",uuid:"UUID",json:"JSON",jsonb:"JSONB",bytea:"BYTEA"}[e]??e.toUpperCase()}function N(e,t){let s=[r(e.name),y(e.type)];return t&&s.push("PRIMARY KEY"),!e.nullable&&!e.primaryKey&&s.push("NOT NULL"),e.unique&&!t&&s.push("UNIQUE"),e.defaultValue&&s.push(`DEFAULT ${e.defaultValue}`)," "+s.join(" ")}function $(e,t){let s=new Set;for(let m of e.fields)for(let a of t.get(m)??[])a.tableId!==e.id&&s.add(a.tableId);return s}function L(e,t,s,m){let a=e.fields.filter(n=>n.primaryKey),d=a.length===1,p=e.fields.map(n=>N(n,d&&n.primaryKey===!0)),c=[],f=[];a.length>1&&c.push(` PRIMARY KEY (${a.map(n=>r(n.name)).join(", ")})`);let i=new Set;for(let n of e.fields)for(let E of s.get(n)??[]){let T=t.find(l=>l.id===E.tableId),S=T?.fields.find(l=>l.id===E.fieldId);if(!T||!S)continue;let I=`fk_${e.name}_${n.name}`,h=I;for(let l=2;i.has(h);l++)h=`${I}_${l}`;i.add(h);let R=`CONSTRAINT ${r(h)} FOREIGN KEY (${r(n.name)}) REFERENCES ${r(T.name)} (${r(S.name)})`;m.has(T.id)?c.push(` ${R}`):f.push(`ALTER TABLE ${r(e.name)} ADD ${R};`)}let o=[];for(let n of e.fields){let E=n.primaryKey&&d;n.indexed&&!E&&!n.unique&&o.push(`CREATE INDEX ${r(`idx_${e.name}_${n.name}`)} ON ${r(e.name)} (${r(n.name)});`)}let u=[...p,...c],g=`CREATE TABLE ${r(e.name)} (
2
+ ${u.join(`,
3
3
  `)}
4
- );`;return s.length>0?c+`
4
+ );`;return{sql:o.length>0?g+`
5
5
 
6
- `+s.join(`
7
- `):c}function y(e){let{tables:n}=e;if(n.length===0)return"-- No tables defined";let m=h(e),a=s=>s.fields.some(o=>m.has(o));return[...n].sort((s,o)=>{let c=a(s),t=a(o);return c&&!t?1:!c&&t?-1:0}).map(s=>S(s,n,m)).join(`
6
+ `+o.join(`
7
+ `):g,deferred:f}}function F(e){let{tables:t}=e;if(t.length===0)return"-- No tables defined";let s=A(e),m=new Set(t.map(i=>i.id)),a=new Map(t.map(i=>[i.id,[...$(i,s)].filter(o=>m.has(o))])),d=new Set,p=[...t],c=[],f=[];for(;p.length>0;){let i=p.findIndex(g=>(a.get(g.id)??[]).every(n=>d.has(n)));i===-1&&(i=0);let[o]=p.splice(i,1);d.add(o.id);let u=L(o,t,s,d);c.push(u.sql),f.push(...u.deferred)}return f.length>0&&c.push(f.join(`
8
+ `)),c.join(`
8
9
 
9
- `)}export{y as generateSQL};
10
+ `)}export{F as generateSQL};
@@ -1 +1 @@
1
- "use strict";"use client";var q=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var Ae=(a,o)=>{for(var c in o)q(a,c,{get:o[c],enumerable:!0})},Pe=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Oe(o))!Te.call(a,i)&&i!==c&&q(a,i,{get:()=>o[i],enumerable:!(l=Me(o,i))||l.enumerable});return a};var Re=a=>Pe(q({},"__esModule",{value:!0}),a);var je={};Ae(je,{Select:()=>Ye});module.exports=Re(je);var n=require("react"),ce=require("react-dom"),de=require("../../lib/aria-hide.cjs"),ue=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),F=()=>{},He=[],Ke=(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,r.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),$e=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),P={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ie={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function v(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function We(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var Ue=(0,n.memo)((0,n.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:B,optionId:g,onClick:h,onMouseEnter:k,index:w},R){let $=()=>{i||h(o.value)},N=()=>{i||k(w)};return(0,r.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:v(P[B].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:$,onMouseEnter:N,children:[o.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,r.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,r.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:$e}):null]})}));function Ye({options:a=He,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:B=!1,disabled:g=!1,readOnly:h=!1,loading:k=!1,size:w="md",variant:R="default",placeholder:$,label:N,description:Q,helperText:X,error:C,required:Z=!1,noOptionsText:pe,clearLabel:fe,searchLabel:ge,searchPlaceholder:me,onSearchChange:G,name:J,className:he,triggerClassName:be,contentClassName:ye,maxHeight:W=256}){let S=(0,ue.useUILabels)(),xe=$??S.selectPlaceholder,ve=pe??S.selectNoOptions,M=(0,n.useId)(),U=`${M}-label`,ee=`${M}-trigger`,te=`${M}-listbox`,y=(0,n.useRef)(null),Y=(0,n.useRef)(null),re=(0,n.useRef)(null),ne=(0,n.useRef)([]),O=o!==void 0,[ke,oe]=(0,n.useState)(c??""),I=O?o:ke,[p,j]=(0,n.useState)(!1),[z,T]=(0,n.useState)(""),[s,f]=(0,n.useState)(-1),[E,ae]=(0,n.useState)(null),u=(0,n.useMemo)(()=>i?We(a,z):a,[a,z,i]),H=(0,n.useMemo)(()=>a.find(e=>e.value===I)??null,[a,I]),x=(0,n.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),D=(0,n.useCallback)(e=>{k||(O||oe(e),(l??F)(e),j(!1),T(""),f(-1),y.current?.focus())},[O,l,k]),we=(0,n.useCallback)(e=>{e.stopPropagation(),O||oe(""),(l??F)(""),T(""),y.current?.focus()},[O,l]),A=(0,n.useCallback)(()=>{g||h||(j(!0),T(""),f(-1))},[g,h]),m=(0,n.useCallback)(()=>{j(!1),T(""),f(-1),y.current?.focus()},[]),Ee=(0,n.useCallback)(()=>{p?m():A()},[p,m,A]),b=(0,n.useCallback)((e,t)=>{let d=u.length;if(d===0)return-1;let L=e;for(let V=0;V<d;V++)if(L=((L+t)%d+d)%d,!x.has(u[L].value))return L;return-1},[u,x]),Le=(0,n.useCallback)(e=>{if(!(g||h)){if(p){switch(e.key){case"ArrowDown":{e.preventDefault();let t=b(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=b(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=b(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=b(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||D(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||D(t.value)}else m();break;case"Escape":e.preventDefault(),m();break;case"Tab":m();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[g,h,p,A,m,s,u,x,b,D]),Ne=(0,n.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=b(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=b(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=b(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=b(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];x.has(t.value)||D(t.value)}break}case"Escape":e.preventDefault(),m();break;case"Tab":m();break}},[s,u,x,b,D,m]),Ie=(0,n.useCallback)(e=>{let t=e.target.value;T(t),f(-1),(G??F)(t)},[G]);(0,n.useEffect)(()=>{if(!p)return;let e=t=>{let d=t.target;y.current?.contains(d)||Y.current?.contains(d)||m()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[p,m]),(0,n.useEffect)(()=>{if(!p||!y.current){ae(null);return}let e=()=>{let t=y.current;if(!t)return;let d=t.getBoundingClientRect(),L=window.innerHeight-d.bottom,V=d.top,Se=W+8,le=L<Se&&V>L?"top":"bottom";ae({top:le==="bottom"?d.bottom+window.scrollY+4:d.top+window.scrollY-4,left:d.left+window.scrollX,width:d.width,placement:le})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[p,W]);let K=p&&E!==null;(0,n.useEffect)(()=>{K&&i&&re.current?.focus()},[K,i]),(0,n.useEffect)(()=>{let e=Y.current;if(!(!K||!e))return(0,de.registerFloatingLayer)(e,()=>y.current)},[K]),(0,n.useEffect)(()=>{if(s>=0){let e=ne.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let _=I!==""&&I!==void 0,De=B&&_&&!g&&!h&&!k,se=!g&&!h,Ce=v("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",P[w].trigger,ie[R].trigger,!C&&se&&ie[R].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",h&&"cursor-default",!g&&!h&&"cursor-pointer",be);return(0,r.jsxs)("div",{className:v("flex flex-col gap-1",he),children:[N?(0,r.jsxs)("label",{id:U,htmlFor:ee,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[N,Z?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Q?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Q}):null,(0,r.jsxs)("button",{ref:y,id:ee,type:"button",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-controls":p?te:void 0,"aria-labelledby":N?U:void 0,"aria-required":Z||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":p&&s>=0?`${M}-option-${s}`:void 0,disabled:g,className:Ce,onClick:se?Ee:void 0,onKeyDown:Le,children:[(0,r.jsxs)("span",{className:v("flex items-center gap-2 min-w-0 flex-1 truncate",!_&&"text-gray-600 dark:text-gray-300"),children:[H?.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,r.jsx)("span",{className:"truncate",children:_&&H?H.label:xe})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[k?(0,r.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Be}):null,De?(0,r.jsx)("span",{role:"button",tabIndex:-1,"aria-label":fe??S.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:we,onMouseDown:e=>e.preventDefault(),children:Ve}):null,(0,r.jsx)("span",{className:v("text-gray-500 dark:text-gray-400 transition-transform duration-200",p&&"rotate-180"),children:Ke})]})]}),C?(0,r.jsx)("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:C}):X?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,J?(0,r.jsx)("input",{type:"hidden",name:J,value:I??""}):null,p&&E?(0,ce.createPortal)((0,r.jsxs)("div",{ref:Y,role:"listbox",id:te,"aria-labelledby":N?U:void 0,className:v("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",P[w].content,ye),"data-placement":E.placement,style:{top:E.top,left:E.left,width:E.width,position:"absolute",translate:E.placement==="top"?"0 -100%":void 0},onKeyDown:Ne,children:[i?(0,r.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,r.jsx)("input",{ref:re,type:"text",role:"searchbox","aria-label":ge??S.selectSearch,className:v(P[w].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:me??S.selectSearchPlaceholder,value:z,onChange:Ie})}):null,(0,r.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:W},children:u.length===0?(0,r.jsx)("div",{className:v(P[w].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ve}):u.map((e,t)=>(0,r.jsx)(Ue,{option:e,isSelected:e.value===I,isHighlighted:t===s,isDisabled:k||x.has(e.value),sizeKey:w,optionId:`${M}-option-${t}`,onClick:D,onMouseEnter:f,index:t,ref:d=>{ne.current[t]=d}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
1
+ "use strict";"use client";var F=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Re=(a,o)=>{for(var c in o)F(a,c,{get:o[c],enumerable:!0})},He=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Ae(o))!Pe.call(a,i)&&i!==c&&F(a,i,{get:()=>o[i],enumerable:!(l=Te(o,i))||l.enumerable});return a};var Ke=a=>He(F({},"__esModule",{value:!0}),a);var _e={};Re(_e,{Select:()=>ze});module.exports=Ke(_e);var n=require("react"),ue=require("react-dom"),de=require("../../lib/aria-hide.cjs"),H=require("../../lib/owner-document.cjs"),pe=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),Q=()=>{},Ve=[],Be=(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),We=(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,r.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Ue=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),R={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ce={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function k(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function Ye(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var je=(0,n.memo)((0,n.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:$,optionId:m,onClick:y,onMouseEnter:w,index:E},K){let W=()=>{i||y(o.value)},N=()=>{i||w(E)};return(0,r.jsxs)("div",{ref:K,id:m,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:k(R[$].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:W,onMouseEnter:N,children:[o.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,r.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,r.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Ue}):null]})}));function ze({options:a=Ve,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:$=!1,disabled:m=!1,readOnly:y=!1,loading:w=!1,size:E="md",variant:K="default",placeholder:W,label:N,description:X,helperText:Z,error:C,required:G=!1,noOptionsText:fe,clearLabel:ge,searchLabel:me,searchPlaceholder:he,onSearchChange:J,name:ee,className:be,triggerClassName:ye,contentClassName:xe,maxHeight:U=256}){let S=(0,pe.useUILabels)(),ve=W??S.selectPlaceholder,ke=fe??S.selectNoOptions,M=(0,n.useId)(),Y=`${M}-label`,te=`${M}-trigger`,re=`${M}-listbox`,h=(0,n.useRef)(null),j=(0,n.useRef)(null),ne=(0,n.useRef)(null),oe=(0,n.useRef)([]),O=o!==void 0,[we,ae]=(0,n.useState)(c??""),I=O?o:we,[d,z]=(0,n.useState)(!1),[_,T]=(0,n.useState)(""),[s,f]=(0,n.useState)(-1),[L,se]=(0,n.useState)(null),u=(0,n.useMemo)(()=>i?Ye(a,_):a,[a,_,i]),V=(0,n.useMemo)(()=>a.find(e=>e.value===I)??null,[a,I]),v=(0,n.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),D=(0,n.useCallback)(e=>{w||(O||ae(e),(l??Q)(e),z(!1),T(""),f(-1),h.current?.focus())},[O,l,w]),Ee=(0,n.useCallback)(e=>{e.stopPropagation(),O||ae(""),(l??Q)(""),T(""),h.current?.focus()},[O,l]),A=(0,n.useCallback)(()=>{m||y||(z(!0),T(""),f(-1))},[m,y]),b=(0,n.useCallback)(()=>{z(!1),T(""),f(-1),h.current?.focus()},[]),Le=(0,n.useCallback)(()=>{d?b():A()},[d,b,A]),x=(0,n.useCallback)((e,t)=>{let g=u.length;if(g===0)return-1;let p=e;for(let P=0;P<g;P++)if(p=((p+t)%g+g)%g,!v.has(u[p].value))return p;return-1},[u,v]),Ne=(0,n.useCallback)(e=>{if(!(m||y)){if(d){switch(e.key){case"ArrowDown":{e.preventDefault();let t=x(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=x(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=x(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=x(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}else b();break;case"Escape":e.preventDefault(),b();break;case"Tab":b();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[m,y,d,A,b,s,u,v,x,D]),Ie=(0,n.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=x(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=x(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=x(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=x(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[s,u,v,x,D,b]),De=(0,n.useCallback)(e=>{let t=e.target.value;T(t),f(-1),(J??Q)(t)},[J]);(0,n.useEffect)(()=>{if(!d)return;let e=g=>{let p=g.target;h.current?.contains(p)||j.current?.contains(p)||b()},t=(0,H.ownerDocumentOf)(h.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[d,b]),(0,n.useEffect)(()=>{if(!d||!h.current){se(null);return}let e=(0,H.ownerWindowOf)(h.current),t=()=>{let g=h.current;if(!g)return;let p=g.getBoundingClientRect(),P=e.innerHeight-p.bottom,Me=p.top,Oe=U+8,ie=P<Oe&&Me>P?"top":"bottom";se({top:ie==="bottom"?p.bottom+e.scrollY+4:p.top+e.scrollY-4,left:p.left+e.scrollX,width:p.width,placement:ie})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[d,U]);let B=d&&L!==null;(0,n.useEffect)(()=>{B&&i&&ne.current?.focus()},[B,i]),(0,n.useEffect)(()=>{let e=j.current;if(!(!B||!e))return(0,de.registerFloatingLayer)(e,()=>h.current)},[B]),(0,n.useEffect)(()=>{if(s>=0){let e=oe.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let q=I!==""&&I!==void 0,Ce=$&&q&&!m&&!y&&!w,le=!m&&!y,Se=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",R[E].trigger,ce[K].trigger,!C&&le&&ce[K].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",m&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",y&&"cursor-default",!m&&!y&&"cursor-pointer",ye);return(0,r.jsxs)("div",{className:k("flex flex-col gap-1",be),children:[N?(0,r.jsxs)("label",{id:Y,htmlFor:te,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[N,G?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,X?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,(0,r.jsxs)("button",{ref:h,id:te,type:"button",role:"combobox","aria-expanded":d,"aria-haspopup":"listbox","aria-controls":d?re:void 0,"aria-labelledby":N?Y:void 0,"aria-required":G||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":d&&s>=0?`${M}-option-${s}`:void 0,disabled:m,className:Se,onClick:le?Le:void 0,onKeyDown:Ne,children:[(0,r.jsxs)("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!q&&"text-gray-600 dark:text-gray-300"),children:[V?.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:V.icon}):null,(0,r.jsx)("span",{className:"truncate",children:q&&V?V.label:ve})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[w?(0,r.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:We}):null,Ce?(0,r.jsx)("span",{role:"button",tabIndex:-1,"aria-label":ge??S.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ee,onMouseDown:e=>e.preventDefault(),children:$e}):null,(0,r.jsx)("span",{className:k("text-gray-500 dark:text-gray-400 transition-transform duration-200",d&&"rotate-180"),children:Be})]})]}),C?(0,r.jsx)("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:C}):Z?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z}):null,ee?(0,r.jsx)("input",{type:"hidden",name:ee,value:I??""}):null,d&&L?(0,ue.createPortal)((0,r.jsxs)("div",{ref:j,role:"listbox",id:re,"aria-labelledby":N?Y:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",R[E].content,xe),"data-placement":L.placement,style:{top:L.top,left:L.left,width:L.width,position:"absolute",translate:L.placement==="top"?"0 -100%":void 0},onKeyDown:Ie,children:[i?(0,r.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,r.jsx)("input",{ref:ne,type:"text",role:"searchbox","aria-label":me??S.selectSearch,className:k(R[E].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:he??S.selectSearchPlaceholder,value:_,onChange:De})}):null,(0,r.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:U},children:u.length===0?(0,r.jsx)("div",{className:k(R[E].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ke}):u.map((e,t)=>(0,r.jsx)(je,{option:e,isSelected:e.value===I,isHighlighted:t===s,isDisabled:w||v.has(e.value),sizeKey:E,optionId:`${M}-option-${t}`,onClick:D,onMouseEnter:f,index:t,ref:g=>{oe.current[t]=g}},e.value))})]}),(0,H.ownerDocumentOf)(h.current).body):null]})}0&&(module.exports={Select});
@@ -1 +1 @@
1
- "use client";import{useState as R,useRef as U,useEffect as H,useCallback as b,useMemo as Z,useId as Oe,memo as Te,forwardRef as Ae}from"react";import{createPortal as Pe}from"react-dom";import{registerFloatingLayer as Re}from"../../lib/aria-hide.js";import{useUILabels as He}from"../../lib/i18n.js";import{jsx as r,jsxs as y}from"react/jsx-runtime";var G=()=>{},Ke=[],Ve=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=y("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),We=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},pe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function k(...i){let o="";for(let d=0;d<i.length;d++){let s=i[d];s&&(o&&(o+=" "),o+=s)}return o}function Ue(i,o){if(!o)return i;let d=o.toLowerCase();return i.filter(s=>{if(s.label.toLowerCase().includes(d)||s.value.toLowerCase().includes(d))return!0;if(s.keywords){for(let u of s.keywords)if(u.toLowerCase().includes(d))return!0}return!1})}var Ye=Te(Ae(function({option:o,isSelected:d,isHighlighted:s,isDisabled:u,sizeKey:Y,optionId:f,onClick:m,onMouseEnter:w,index:E},V){let j=()=>{u||m(o.value)},I=()=>{u||w(E)};return y("div",{ref:V,id:f,role:"option","aria-selected":d,"aria-disabled":u||void 0,"data-highlighted":s||void 0,className:k(K[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!u&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",d&&!s&&"bg-gray-50 dark:bg-gray-700/50",u&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:I,children:[o.icon?r("span",{className:"flex shrink-0 items-center",children:o.icon}):null,y("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:o.label}),o.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),d?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:We}):null]})}));function Fe({options:i=Ke,value:o,defaultValue:d,onValueChange:s,searchable:u=!1,clearable:Y=!1,disabled:f=!1,readOnly:m=!1,loading:w=!1,size:E="md",variant:V="default",placeholder:j,label:I,description:J,helperText:ee,error:S,required:te=!1,noOptionsText:fe,clearLabel:ge,searchLabel:me,searchPlaceholder:he,onSearchChange:re,name:ne,className:be,triggerClassName:ye,contentClassName:xe,maxHeight:z=256}){let M=He(),ve=j??M.selectPlaceholder,ke=fe??M.selectNoOptions,O=Oe(),_=`${O}-label`,oe=`${O}-trigger`,ae=`${O}-listbox`,x=U(null),q=U(null),se=U(null),le=U([]),T=o!==void 0,[we,ie]=R(d??""),D=T?o:we,[c,F]=R(!1),[Q,A]=R(""),[n,p]=R(-1),[L,ce]=R(null),l=Z(()=>u?Ue(i,Q):i,[i,Q,u]),B=Z(()=>i.find(e=>e.value===D)??null,[i,D]),v=Z(()=>{let e=new Set;for(let t of i)t.disabled&&e.add(t.value);return e},[i]),C=b(e=>{w||(T||ie(e),(s??G)(e),F(!1),A(""),p(-1),x.current?.focus())},[T,s,w]),Ee=b(e=>{e.stopPropagation(),T||ie(""),(s??G)(""),A(""),x.current?.focus()},[T,s]),P=b(()=>{f||m||(F(!0),A(""),p(-1))},[f,m]),g=b(()=>{F(!1),A(""),p(-1),x.current?.focus()},[]),Le=b(()=>{c?g():P()},[c,g,P]),h=b((e,t)=>{let a=l.length;if(a===0)return-1;let N=e;for(let W=0;W<a;W++)if(N=((N+t)%a+a)%a,!v.has(l[N].value))return N;return-1},[l,v]),Ne=b(e=>{if(!(f||m)){if(c){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=h(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=h(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||C(t.value)}break}case" ":if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||C(t.value)}else g();break;case"Escape":e.preventDefault(),g();break;case"Tab":g();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),P();break;case"Enter":case" ":e.preventDefault(),P();break}}},[f,m,c,P,g,n,l,v,h,C]),Ie=b(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=h(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=h(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<l.length){let t=l[n];v.has(t.value)||C(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[n,l,v,h,C,g]),De=b(e=>{let t=e.target.value;A(t),p(-1),(re??G)(t)},[re]);H(()=>{if(!c)return;let e=t=>{let a=t.target;x.current?.contains(a)||q.current?.contains(a)||g()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[c,g]),H(()=>{if(!c||!x.current){ce(null);return}let e=()=>{let t=x.current;if(!t)return;let a=t.getBoundingClientRect(),N=window.innerHeight-a.bottom,W=a.top,Me=z+8,ue=N<Me&&W>N?"top":"bottom";ce({top:ue==="bottom"?a.bottom+window.scrollY+4:a.top+window.scrollY-4,left:a.left+window.scrollX,width:a.width,placement:ue})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c,z]);let $=c&&L!==null;H(()=>{$&&u&&se.current?.focus()},[$,u]),H(()=>{let e=q.current;if(!(!$||!e))return Re(e,()=>x.current)},[$]),H(()=>{if(n>=0){let e=le.current[n];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[n]);let X=D!==""&&D!==void 0,Ce=Y&&X&&!f&&!m&&!w,de=!f&&!m,Se=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",K[E].trigger,pe[V].trigger,!S&&de&&pe[V].focus,S&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",f&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",m&&"cursor-default",!f&&!m&&"cursor-pointer",ye);return y("div",{className:k("flex flex-col gap-1",be),children:[I?y("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[I,te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,y("button",{ref:x,id:oe,type:"button",role:"combobox","aria-expanded":c,"aria-haspopup":"listbox","aria-controls":c?ae:void 0,"aria-labelledby":I?_:void 0,"aria-required":te||void 0,"aria-invalid":S?!0:void 0,"aria-activedescendant":c&&n>=0?`${O}-option-${n}`:void 0,disabled:f,className:Se,onClick:de?Le:void 0,onKeyDown:Ne,children:[y("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-600 dark:text-gray-300"),children:[B?.icon?r("span",{className:"flex shrink-0 items-center",children:B.icon}):null,r("span",{className:"truncate",children:X&&B?B.label:ve})]}),y("span",{className:"flex items-center gap-1 shrink-0",children:[w?r("span",{className:"text-gray-500 dark:text-gray-400",children:$e}):null,Ce?r("span",{role:"button",tabIndex:-1,"aria-label":ge??M.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ee,onMouseDown:e=>e.preventDefault(),children:Be}):null,r("span",{className:k("text-gray-500 dark:text-gray-400 transition-transform duration-200",c&&"rotate-180"),children:Ve})]})]}),S?r("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:S}):ee?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,ne?r("input",{type:"hidden",name:ne,value:D??""}):null,c&&L?Pe(y("div",{ref:q,role:"listbox",id:ae,"aria-labelledby":I?_:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",K[E].content,xe),"data-placement":L.placement,style:{top:L.top,left:L.left,width:L.width,position:"absolute",translate:L.placement==="top"?"0 -100%":void 0},onKeyDown:Ie,children:[u?r("div",{className:"border-b border-gray-200 dark:border-gray-700",children:r("input",{ref:se,type:"text",role:"searchbox","aria-label":me??M.selectSearch,className:k(K[E].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:he??M.selectSearchPlaceholder,value:Q,onChange:De})}):null,r("div",{className:"overflow-y-auto",style:{maxHeight:z},children:l.length===0?r("div",{className:k(K[E].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ke}):l.map((e,t)=>r(Ye,{option:e,isSelected:e.value===D,isHighlighted:t===n,isDisabled:w||v.has(e.value),sizeKey:E,optionId:`${O}-option-${t}`,onClick:C,onMouseEnter:p,index:t,ref:a=>{le.current[t]=a}},e.value))})]}),document.body):null]})}export{Fe as Select};
1
+ "use client";import{useState as H,useRef as U,useEffect as K,useCallback as x,useMemo as Z,useId as Ae,memo as Pe,forwardRef as Re}from"react";import{createPortal as He}from"react-dom";import{registerFloatingLayer as Ke}from"../../lib/aria-hide.js";import{ownerDocumentOf as pe,ownerWindowOf as Ve}from"../../lib/owner-document.js";import{useUILabels as Be}from"../../lib/i18n.js";import{jsx as r,jsxs as v}from"react/jsx-runtime";var G=()=>{},$e=[],We=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ue=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ye=v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),je=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),V={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},fe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function w(...l){let o="";for(let u=0;u<l.length;u++){let a=l[u];a&&(o&&(o+=" "),o+=a)}return o}function ze(l,o){if(!o)return l;let u=o.toLowerCase();return l.filter(a=>{if(a.label.toLowerCase().includes(u)||a.value.toLowerCase().includes(u))return!0;if(a.keywords){for(let d of a.keywords)if(d.toLowerCase().includes(u))return!0}return!1})}var _e=Pe(Re(function({option:o,isSelected:u,isHighlighted:a,isDisabled:d,sizeKey:Y,optionId:g,onClick:b,onMouseEnter:E,index:L},B){let j=()=>{d||b(o.value)},I=()=>{d||E(L)};return v("div",{ref:B,id:g,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":a||void 0,className:w(V[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",a&&!d&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",u&&!a&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:I,children:[o.icon?r("span",{className:"flex shrink-0 items-center",children:o.icon}):null,v("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:o.label}),o.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:je}):null]})}));function Ge({options:l=$e,value:o,defaultValue:u,onValueChange:a,searchable:d=!1,clearable:Y=!1,disabled:g=!1,readOnly:b=!1,loading:E=!1,size:L="md",variant:B="default",placeholder:j,label:I,description:J,helperText:ee,error:S,required:te=!1,noOptionsText:ge,clearLabel:me,searchLabel:he,searchPlaceholder:be,onSearchChange:re,name:ne,className:ye,triggerClassName:xe,contentClassName:ve,maxHeight:z=256}){let M=Be(),ke=j??M.selectPlaceholder,we=ge??M.selectNoOptions,O=Ae(),_=`${O}-label`,oe=`${O}-trigger`,ae=`${O}-listbox`,m=U(null),q=U(null),se=U(null),le=U([]),T=o!==void 0,[Ee,ie]=H(u??""),D=T?o:Ee,[i,F]=H(!1),[Q,A]=H(""),[n,p]=H(-1),[N,ce]=H(null),s=Z(()=>d?ze(l,Q):l,[l,Q,d]),$=Z(()=>l.find(e=>e.value===D)??null,[l,D]),k=Z(()=>{let e=new Set;for(let t of l)t.disabled&&e.add(t.value);return e},[l]),C=x(e=>{E||(T||ie(e),(a??G)(e),F(!1),A(""),p(-1),m.current?.focus())},[T,a,E]),Le=x(e=>{e.stopPropagation(),T||ie(""),(a??G)(""),A(""),m.current?.focus()},[T,a]),P=x(()=>{g||b||(F(!0),A(""),p(-1))},[g,b]),h=x(()=>{F(!1),A(""),p(-1),m.current?.focus()},[]),Ne=x(()=>{i?h():P()},[i,h,P]),y=x((e,t)=>{let f=s.length;if(f===0)return-1;let c=e;for(let R=0;R<f;R++)if(c=((c+t)%f+f)%f,!k.has(s[c].value))return c;return-1},[s,k]),Ie=x(e=>{if(!(g||b)){if(i){switch(e.key){case"ArrowDown":{e.preventDefault();let t=y(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=y(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=y(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=y(s.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}break}case" ":if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}else h();break;case"Escape":e.preventDefault(),h();break;case"Tab":h();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),P();break;case"Enter":case" ":e.preventDefault(),P();break}}},[g,b,i,P,h,n,s,k,y,C]),De=x(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=y(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=y(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=y(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=y(s.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}break}case"Escape":e.preventDefault(),h();break;case"Tab":h();break}},[n,s,k,y,C,h]),Ce=x(e=>{let t=e.target.value;A(t),p(-1),(re??G)(t)},[re]);K(()=>{if(!i)return;let e=f=>{let c=f.target;m.current?.contains(c)||q.current?.contains(c)||h()},t=pe(m.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[i,h]),K(()=>{if(!i||!m.current){ce(null);return}let e=Ve(m.current),t=()=>{let f=m.current;if(!f)return;let c=f.getBoundingClientRect(),R=e.innerHeight-c.bottom,Oe=c.top,Te=z+8,de=R<Te&&Oe>R?"top":"bottom";ce({top:de==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:de})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[i,z]);let W=i&&N!==null;K(()=>{W&&d&&se.current?.focus()},[W,d]),K(()=>{let e=q.current;if(!(!W||!e))return Ke(e,()=>m.current)},[W]),K(()=>{if(n>=0){let e=le.current[n];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[n]);let X=D!==""&&D!==void 0,Se=Y&&X&&!g&&!b&&!E,ue=!g&&!b,Me=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",V[L].trigger,fe[B].trigger,!S&&ue&&fe[B].focus,S&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",b&&"cursor-default",!g&&!b&&"cursor-pointer",xe);return v("div",{className:w("flex flex-col gap-1",ye),children:[I?v("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[I,te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,v("button",{ref:m,id:oe,type:"button",role:"combobox","aria-expanded":i,"aria-haspopup":"listbox","aria-controls":i?ae:void 0,"aria-labelledby":I?_:void 0,"aria-required":te||void 0,"aria-invalid":S?!0:void 0,"aria-activedescendant":i&&n>=0?`${O}-option-${n}`:void 0,disabled:g,className:Me,onClick:ue?Ne:void 0,onKeyDown:Ie,children:[v("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-600 dark:text-gray-300"),children:[$?.icon?r("span",{className:"flex shrink-0 items-center",children:$.icon}):null,r("span",{className:"truncate",children:X&&$?$.label:ke})]}),v("span",{className:"flex items-center gap-1 shrink-0",children:[E?r("span",{className:"text-gray-500 dark:text-gray-400",children:Ye}):null,Se?r("span",{role:"button",tabIndex:-1,"aria-label":me??M.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Le,onMouseDown:e=>e.preventDefault(),children:Ue}):null,r("span",{className:w("text-gray-500 dark:text-gray-400 transition-transform duration-200",i&&"rotate-180"),children:We})]})]}),S?r("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:S}):ee?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,ne?r("input",{type:"hidden",name:ne,value:D??""}):null,i&&N?He(v("div",{ref:q,role:"listbox",id:ae,"aria-labelledby":I?_:void 0,className:w("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",V[L].content,ve),"data-placement":N.placement,style:{top:N.top,left:N.left,width:N.width,position:"absolute",translate:N.placement==="top"?"0 -100%":void 0},onKeyDown:De,children:[d?r("div",{className:"border-b border-gray-200 dark:border-gray-700",children:r("input",{ref:se,type:"text",role:"searchbox","aria-label":he??M.selectSearch,className:w(V[L].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:be??M.selectSearchPlaceholder,value:Q,onChange:Ce})}):null,r("div",{className:"overflow-y-auto",style:{maxHeight:z},children:s.length===0?r("div",{className:w(V[L].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:we}):s.map((e,t)=>r(_e,{option:e,isSelected:e.value===D,isHighlighted:t===n,isDisabled:E||k.has(e.value),sizeKey:L,optionId:`${O}-option-${t}`,onClick:C,onMouseEnter:p,index:t,ref:f=>{le.current[t]=f}},e.value))})]}),pe(m.current).body):null]})}export{Ge as Select};
@@ -1 +1 @@
1
- "use strict";"use client";var R=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var se=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},oe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ae(e))!ne.call(r,s)&&s!==t&&R(r,s,{get:()=>e[s],enumerable:!(n=te(e,s))||n.enumerable});return r};var le=r=>oe(R({},"__esModule",{value:!0}),r);var ve={};se(ve,{Slider:()=>O});module.exports=le(ve);var i=require("react"),l=require("../../lib/cn.cjs"),a=require("react/jsx-runtime"),ie={sm:"h-1",md:"h-1.5",lg:"h-2"},de={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ue={sm:14,md:16,lg:20},ce="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",be={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},me={sm:"h-4",md:"h-5",lg:"h-6"},ge={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},pe={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},ye={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},fe={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},B=(r,e,t)=>Math.min(t,Math.max(e,r)),P=(r,e,t)=>t>e?(B(r,e,t)-e)/(t-e)*100:0,w=(r,e)=>{let t=(.5-r/100)*e,n=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${n}px)`},he=(r,e,t,n)=>{if(!r)return[];if(Array.isArray(r))return r;let s=n>0?n:1,d=Math.floor((t-e)/s);return d<=0||d>20?[{value:e},{value:t}]:Array.from({length:d+1},(u,k)=>({value:e+k*s}))},O=(0,i.forwardRef)(({value:r,defaultValue:e,onValueChange:t,min:n=0,max:s=100,step:d=1,size:u="md",color:k="primary",disabled:m=!1,readOnly:S=!1,label:x,description:$,error:C=!1,showValue:V=!1,showTooltip:_=!1,valueFormat:I,marks:T,trackColor:E,fillColor:N,thumbColor:g,className:j,containerClassName:q,id:D,...G},J)=>{let[K,Q]=(0,i.useState)(e??n),A=r!==void 0,b=B(A?r:K,n,s),U=(0,i.useId)(),p=D??U,y=typeof C=="string"?C:void 0,H=!!C,f=!m&&!S,h=H?"error":k,L=P(b,n,s),v=ue[u],X=o=>{if(!f)return;let c=Number(o.target.value);A||Q(c),t?.(c)},z=(0,i.useMemo)(()=>he(T,n,s,d),[T,n,s,d]),Y=z.some(o=>o.label!=null),W=I?I(b):`${b}`,F={width:w(L,v)};N&&(F.backgroundColor=N);let M={left:w(L,v)};g&&(M.backgroundColor=g,M.borderColor=g);let Z=E?{backgroundColor:E}:{};return(0,a.jsxs)("div",{className:(0,l.cn)("w-full",q),children:[(x||V)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[x?(0,a.jsx)("label",{htmlFor:p,className:(0,l.cn)("text-sm font-medium text-gray-700 dark:text-gray-200",m&&"opacity-50"),children:x}):(0,a.jsx)("span",{}),V&&(0,a.jsx)("span",{className:(0,l.cn)("text-sm font-semibold tabular-nums",fe[h]),children:W})]}),(0,a.jsxs)("div",{className:(0,l.cn)("relative flex items-center",me[u],m&&"opacity-50"),children:[(0,a.jsx)("input",{ref:J,type:"range",id:p,min:n,max:s,step:d,value:b,onChange:X,disabled:m,readOnly:S,"aria-invalid":H,"aria-readonly":S||void 0,"aria-describedby":y?`${p}-error`:void 0,tabIndex:f?void 0:-1,className:(0,l.cn)("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",ce,be[u],!f&&"pointer-events-none cursor-default",j),...G}),(0,a.jsxs)("div",{className:(0,l.cn)("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ie[u]),style:Z,children:[(0,a.jsx)("div",{className:(0,l.cn)("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",N?"":ge[h]),style:F}),z.map((o,c)=>{let ee=P(o.value,n,s),re=o.value<=b;return(0,a.jsx)("span",{"data-slider-mark":"",className:(0,l.cn)("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",re?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:w(ee,v)}},`mark-${o.value}-${c}`)})]}),(0,a.jsx)("div",{"data-slider-thumb":"",className:(0,l.cn)("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",de[u],g?"":pe[h],f&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",ye[h]),style:M,children:_&&(0,a.jsx)("span",{"data-slider-tooltip":"",className:(0,l.cn)("pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700","peer-hover:opacity-100 peer-focus-visible:opacity-100 peer-active:opacity-100"),children:W})})]}),Y&&(0,a.jsx)("div",{className:"relative mt-1.5 h-4",children:z.map((o,c)=>o.label!=null?(0,a.jsx)("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:w(P(o.value,n,s),v)},children:o.label},`mark-label-${o.value}-${c}`):null)}),$&&!y&&(0,a.jsx)("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:$}),y&&(0,a.jsx)("p",{id:`${p}-error`,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:y})]})});O.displayName="Slider";0&&(module.exports={Slider});
1
+ "use strict";"use client";var R=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ne=Object.prototype.hasOwnProperty;var se=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},oe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ae(e))!ne.call(r,s)&&s!==t&&R(r,s,{get:()=>e[s],enumerable:!(n=te(e,s))||n.enumerable});return r};var le=r=>oe(R({},"__esModule",{value:!0}),r);var ve={};se(ve,{Slider:()=>_});module.exports=le(ve);var i=require("react"),l=require("../../lib/cn.cjs"),a=require("react/jsx-runtime"),ie={sm:"h-1",md:"h-1.5",lg:"h-2"},de={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ue={sm:14,md:16,lg:20},ce="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",be={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},me={sm:"h-4",md:"h-5",lg:"h-6"},ge={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},pe={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},ye={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},fe={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},O=(r,e,t)=>Math.min(t,Math.max(e,r)),P=(r,e,t)=>t>e?(O(r,e,t)-e)/(t-e)*100:0,w=(r,e)=>{let t=(.5-r/100)*e,n=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${n}px)`},he=(r,e,t,n)=>{if(!r)return[];if(Array.isArray(r))return r;let s=n>0?n:1,d=Math.floor((t-e)/s);return d<=0||d>20?[{value:e},{value:t}]:Array.from({length:d+1},(u,k)=>({value:e+k*s}))},_=(0,i.forwardRef)(({value:r,defaultValue:e,onValueChange:t,min:n=0,max:s=100,step:d=1,size:u="md",color:k="primary",disabled:m=!1,readOnly:S=!1,label:x,description:$,error:C=!1,showValue:V=!1,showTooltip:I=!1,valueFormat:T,marks:E,trackColor:A,fillColor:N,thumbColor:g,className:j,containerClassName:q,id:D,...G},J)=>{let[K,Q]=(0,i.useState)(e??n),H=r!==void 0,b=O(H?r:K,n,s),U=(0,i.useId)(),p=D??U,y=typeof C=="string"?C:void 0,L=!!C,f=!m&&!S,h=L?"error":k,W=P(b,n,s),v=ue[u],X=o=>{if(!f)return;let c=Number(o.target.value);H||Q(c),t?.(c)},z=(0,i.useMemo)(()=>he(E,n,s,d),[E,n,s,d]),Y=z.some(o=>o.label!=null),F=T?T(b):`${b}`,B={width:w(W,v)};N&&(B.backgroundColor=N);let M={left:w(W,v)};g&&(M.backgroundColor=g,M.borderColor=g);let Z=A?{backgroundColor:A}:{};return(0,a.jsxs)("div",{className:(0,l.cn)("w-full",q),children:[(x||V)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[x?(0,a.jsx)("label",{htmlFor:p,className:(0,l.cn)("text-sm font-medium text-gray-700 dark:text-gray-200",m&&"opacity-50"),children:x}):(0,a.jsx)("span",{}),V&&(0,a.jsx)("span",{className:(0,l.cn)("text-sm font-semibold tabular-nums",fe[h]),children:F})]}),(0,a.jsxs)("div",{className:(0,l.cn)("relative flex items-center",me[u],m&&"opacity-50"),children:[(0,a.jsx)("input",{ref:J,type:"range",id:p,min:n,max:s,step:d,value:b,onChange:X,disabled:m,readOnly:S,"aria-invalid":L,"aria-readonly":S||void 0,"aria-describedby":y?`${p}-error`:void 0,tabIndex:f?void 0:-1,className:(0,l.cn)("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",ce,be[u],!f&&"pointer-events-none cursor-default",j),...G}),(0,a.jsxs)("div",{className:(0,l.cn)("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ie[u]),style:Z,children:[(0,a.jsx)("div",{className:(0,l.cn)("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",N?"":ge[h]),style:B}),z.map((o,c)=>{let ee=P(o.value,n,s),re=o.value<=b;return(0,a.jsx)("span",{"data-slider-mark":"",className:(0,l.cn)("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",re?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:w(ee,v)}},`mark-${o.value}-${c}`)})]}),(0,a.jsx)("div",{"data-slider-thumb":"",className:(0,l.cn)("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",de[u],g?"":pe[h],f&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",ye[h],I&&"peer-hover:*:opacity-100 peer-focus-visible:*:opacity-100 peer-active:*:opacity-100"),style:M,children:I&&(0,a.jsx)("span",{"data-slider-tooltip":"",className:"pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700",children:F})})]}),Y&&(0,a.jsx)("div",{className:"relative mt-1.5 h-4",children:z.map((o,c)=>o.label!=null?(0,a.jsx)("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:w(P(o.value,n,s),v)},children:o.label},`mark-label-${o.value}-${c}`):null)}),$&&!y&&(0,a.jsx)("p",{className:"mt-1.5 text-sm text-gray-500 dark:text-gray-400",children:$}),y&&(0,a.jsx)("p",{id:`${p}-error`,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:y})]})});_.displayName="Slider";0&&(module.exports={Slider});