@synertech/ui 0.45.1 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +115 -17
- package/README.md +47 -5
- package/dist/components/area-chart/AreaChart.cjs +1 -1
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/avatar/Avatar.cjs +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/badge/Badge.cjs +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/bar-chart/BarChart.cjs +1 -1
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/box-plot/BoxPlot.cjs +1 -1
- package/dist/components/box-plot/BoxPlot.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/bullet-chart/BulletChart.cjs +1 -1
- package/dist/components/bullet-chart/BulletChart.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.cjs +1 -1
- package/dist/components/candlestick-chart/CandlestickChart.js +1 -1
- package/dist/components/chart/ChartBrush.cjs +1 -1
- package/dist/components/chart/ChartBrush.js +1 -1
- package/dist/components/chart/ChartExportButton.cjs +1 -1
- package/dist/components/chart/ChartExportButton.js +1 -1
- package/dist/components/chart/utils/export.cjs +1 -2
- package/dist/components/chart/utils/export.js +1 -2
- package/dist/components/chart/utils/keyboard.cjs +1 -0
- package/dist/components/chart/utils/keyboard.js +1 -0
- package/dist/components/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -2
- package/dist/components/datagrid/DataGrid.js +1 -2
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/dropdown/Dropdown.cjs +1 -1
- package/dist/components/dropdown/Dropdown.js +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.cjs +1 -1
- package/dist/components/dropdown/DropdownCheckboxItem.js +1 -1
- package/dist/components/dropdown/DropdownContent.cjs +1 -1
- package/dist/components/dropdown/DropdownContent.js +1 -1
- package/dist/components/dropdown/DropdownItem.cjs +1 -1
- package/dist/components/dropdown/DropdownItem.js +1 -1
- package/dist/components/dropdown/DropdownRadio.cjs +1 -1
- package/dist/components/dropdown/DropdownRadio.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/hooks/index.cjs +1 -1
- package/dist/components/dropdown/hooks/index.js +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.cjs +1 -1
- package/dist/components/dropdown/hooks/useClickOutside.js +1 -1
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.js +1 -1
- package/dist/components/dropdown/menu-navigation.cjs +1 -0
- package/dist/components/dropdown/menu-navigation.js +1 -0
- package/dist/components/dumbbell-chart/DumbbellChart.cjs +1 -1
- package/dist/components/dumbbell-chart/DumbbellChart.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/form/input/Input.cjs +1 -1
- package/dist/components/form/input/Input.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +1 -1
- package/dist/components/form/mention-input/MentionInput.js +1 -1
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/funnel-chart/FunnelChart.cjs +1 -1
- package/dist/components/funnel-chart/FunnelChart.js +1 -1
- package/dist/components/gantt-chart/GanttChart.cjs +1 -1
- package/dist/components/gantt-chart/GanttChart.js +1 -1
- package/dist/components/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/heat-map/Heatmap.cjs +1 -1
- package/dist/components/heat-map/Heatmap.js +1 -1
- package/dist/components/help-button/HelpButton.cjs +7 -7
- package/dist/components/help-button/HelpButton.js +7 -7
- package/dist/components/help-button/MarkdownEditor.cjs +1 -1
- package/dist/components/help-button/MarkdownEditor.js +1 -1
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/indicator/Indicator.cjs +1 -1
- package/dist/components/indicator/Indicator.js +1 -1
- package/dist/components/label/Label.cjs +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/line-chart/LineChart.cjs +1 -1
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pie-chart/PieChart.cjs +1 -1
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.cjs +1 -1
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.cjs +1 -1
- package/dist/components/schema-editor/toolbar/SchemaToolbar.js +1 -1
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/tabs/Tabs.cjs +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/TabsContent.cjs +1 -1
- package/dist/components/tabs/TabsContent.js +1 -1
- package/dist/components/tabs/TabsContext.cjs +1 -1
- package/dist/components/tabs/TabsContext.js +1 -1
- package/dist/components/tabs/TabsList.cjs +1 -1
- package/dist/components/tabs/TabsList.js +1 -1
- package/dist/components/tabs/TabsTrigger.cjs +1 -1
- package/dist/components/tabs/TabsTrigger.js +1 -1
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tooltip/Tooltip.cjs +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.cjs +1 -1
- package/dist/components/waterfall-chart/WaterfallChart.js +1 -1
- package/dist/components/wizard/Wizard.cjs +1 -1
- package/dist/components/wizard/Wizard.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.cjs +1 -1
- package/dist/components/workflow-editor/toolbar/WorkflowToolbar.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +814 -172
- package/dist/index.d.ts +814 -172
- package/dist/index.js +1 -1
- package/dist/lib/aria-hide.cjs +1 -1
- package/dist/lib/aria-hide.js +1 -1
- package/dist/lib/csv.cjs +2 -0
- package/dist/lib/csv.js +2 -0
- package/dist/lib/i18n.cjs +1 -1
- package/dist/lib/i18n.js +1 -1
- package/dist/lib/server-labels.cjs +1 -0
- package/dist/lib/server-labels.js +1 -0
- package/dist/lib/ui-labels.cjs +1 -0
- package/dist/lib/ui-labels.js +1 -0
- package/dist/styles.css +3152 -309
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var T=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var $=(d,o)=>{for(var h in o)T(d,h,{get:o[h],enumerable:!0})},X=(d,o,h,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of G(o))!Y.call(d,a)&&a!==h&&T(d,a,{get:()=>o[a],enumerable:!(s=U(o,a))||s.enumerable});return d};var J=d=>X(T({},"__esModule",{value:!0}),d);var oe={};$(oe,{SchemaTableRenderer:()=>te});module.exports=J(oe);var i=require("react"),g=require("../../../lib/cn.cjs"),c=require("../utils/geometry.cjs"),_=require("../utils/schema-helpers.cjs"),e=require("react/jsx-runtime"),D=()=>(0,e.jsxs)("svg",{className:"w-3.5 h-3.5 text-indigo-500 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"})]}),S=()=>(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"})]}),Q=({collapsed:d})=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:d?(0,e.jsx)("path",{d:"M6 3l5 5-5 5V3z"}):(0,e.jsx)("path",{d:"M3 6l5 5 5-5H3z"})}),E=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-500 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"})}),H=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-500 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"})}),Z=()=>(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"})}),O=()=>(0,e.jsxs)("svg",{className:"w-3 h-3 text-gray-300",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"})]}),ee=(0,i.memo)(function({field:o,tableId:h,editable:s,readOnly:a,disabled:l,onFieldChange:y}){let[k,x]=(0,i.useState)(!1),[f,b]=(0,i.useState)(o.defaultValue??""),p=s&&!a&&!l,v=()=>{x(!1),y?.(h,o.id,{defaultValue:f||void 0})};return p?k?(0,e.jsx)("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${o.name}`,value:f,onChange:u=>b(u.target.value),onBlur:v,onKeyDown:u=>{u.key==="Enter"&&v(),u.key==="Escape"&&x(!1)},onMouseDown:u=>u.stopPropagation(),autoFocus:!0}):o.defaultValue?(0,e.jsxs)("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:u=>{u.stopPropagation(),b(o.defaultValue??""),x(!0)},onMouseDown:u=>u.stopPropagation(),title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):(0,e.jsx)("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:u=>{u.stopPropagation(),b(""),x(!0)},onMouseDown:u=>u.stopPropagation(),title:"Set default value",children:"= \u2205"}):o.defaultValue?(0,e.jsxs)("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):null}),te=(0,i.memo)(function({table:o,selected:h,disabled:s,readOnly:a,editable:l,dropTarget:y,fieldTypes:k,onTableNameChange:x,onTableNotesChange:f,onToggleCollapse:b,onFieldChange:p,onFieldAdd:v,onFieldRemove:u,onFieldReorder:R,onResizeStart:V}){let I=o.width??c.DEFAULT_TABLE_WIDTH,w=o.collapsed??!1,C=k.length>0?k:_.DEFAULT_FIELD_TYPES,[F,P]=(0,i.useState)(null),[L,N]=(0,i.useState)(null),m=(0,i.useRef)(null),K=(0,i.useCallback)(t=>{x?.(o.id,t.target.value)},[o.id,x]),B=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{name:n})},[o.id,p]),z=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{type:n})},[o.id,p]),M=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{primaryKey:!n})},[o.id,p]),W=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{nullable:!n})},[o.id,p]),A=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{indexed:!n})},[o.id,p]),q=(0,i.useCallback)((t,n)=>{p?.(o.id,t,{unique:!n})},[o.id,p]),j=(0,i.useCallback)(()=>{v?.(o.id)},[o.id,v]);return(0,e.jsxs)("div",{"data-table-id":o.id,className:(0,g.cn)("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,y?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":h?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",s&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:I,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[(0,e.jsxs)("div",{className:(0,g.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:c.HEADER_HEIGHT},children:[l&&!a&&!s?(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":"Table name",value:o.name,onChange:K,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:o.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(),b?.(o.id)},onMouseDown:t=>t.stopPropagation(),"aria-label":w?"Expand table":"Collapse table",children:(0,e.jsx)(Q,{collapsed:w})})]}),!w&&(l&&!a&&!s?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:c.NOTES_ROW_HEIGHT},children:(0,e.jsx)("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:o.notes??"",onChange:t=>f?.(o.id,t.target.value),onMouseDown:t=>t.stopPropagation()})}):o.notes?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:c.NOTES_ROW_HEIGHT},children:(0,e.jsx)("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!w&&(0,e.jsxs)("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((t,n)=>(0,e.jsxs)("div",{"data-field-id":t.id,"data-table-id":o.id,className:(0,g.cn)("flex items-center gap-1.5 pr-2 relative group",l&&!a&&!s?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",y?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",F===n&&"opacity-40",L===n&&"!border-t-2 !border-t-blue-400"),style:{height:c.FIELD_ROW_HEIGHT},draggable:l&&!a&&!s,onDragStart:r=>{!l||a||s||(r.stopPropagation(),m.current=n,P(n),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(n)))},onDragOver:r=>{m.current!==null&&(r.preventDefault(),r.stopPropagation(),N(n))},onDragLeave:()=>{L===n&&N(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),m.current!==null&&m.current!==n&&R?.(o.id,m.current,n),m.current=null,P(null),N(null)},onDragEnd:()=>{m.current=null,P(null),N(null)},children:[(0,e.jsx)("div",{"data-connection-side":"left","data-field-id":t.id,"data-table-id":o.id,className:(0,g.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",y?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:c.FIELD_ROW_HEIGHT/2-5}}),l&&!a&&!s&&(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:c.FIELD_ROW_HEIGHT/2-6},children:(0,e.jsx)(O,{})}),l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",t.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),W(t.id,t.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:t.nullable?"Nullable":"Not nullable",children:"?"}):(0,e.jsx)("span",{className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center",t.nullable?"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:[l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}),(0,e.jsx)(S,{})]}):t.primaryKey?l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:(0,e.jsx)(D,{})}):(0,e.jsx)(D,{}):t.foreignKey?(0,e.jsx)(S,{}):l&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),M(t.id,!1)},onMouseDown:r=>r.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",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"}),l&&!a&&!s?(0,e.jsx)("input",{className:(0,g.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":"Field name",value:t.name,onChange:r=>B(t.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):(0,e.jsx)("span",{className:(0,g.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}),l&&!a&&!s?(0,e.jsxs)("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:t.type,onChange:r=>z(t.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[C.map(r=>(0,e.jsx)("option",{value:r,children:r},r)),!C.includes(t.type)&&(0,e.jsx)("option",{value:t.type,children:t.type})]}):(0,e.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:t.type}),(0,e.jsx)(ee,{field:t,tableId:o.id,editable:l,readOnly:a,disabled:s,onFieldChange:p}),t.indexed&&(0,e.jsx)(E,{}),t.unique&&(0,e.jsx)(H,{}),l&&!a&&!s&&(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,g.cn)("cursor-pointer transition-opacity",t.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),A(t.id,t.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:t.indexed?"Indexed (click to remove)":"Add index",children:(0,e.jsx)(E,{})}),(0,e.jsx)("button",{type:"button",className:(0,g.cn)("cursor-pointer transition-opacity",t.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),q(t.id,t.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:t.unique?"Unique (click to remove)":"Add unique constraint",children:(0,e.jsx)(H,{})}),(0,e.jsx)("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),u?.(o.id,t.id)},onMouseDown:r=>r.stopPropagation(),title:"Remove field",children:(0,e.jsx)(Z,{})})]}),(0,e.jsx)("div",{"data-connection-side":"right","data-field-id":t.id,"data-table-id":o.id,className:(0,g.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",y?"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:c.FIELD_ROW_HEIGHT/2-5}})]},t.id)),l&&!a&&!s&&(0,e.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:c.ADD_BUTTON_HEIGHT},onClick:t=>{t.stopPropagation(),j()},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"})}),"Add field"]})]}),!s&&!a&&(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 n=o.height??(0,c.getTableHeight)(o,l);V?.(o.id,t.clientX,t.clientY,I,n)},children:(0,e.jsxs)("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-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 C=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var Q=(h,o)=>{for(var m in o)C(h,m,{get:o[m],enumerable:!0})},Z=(h,o,m,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of X(o))!J.call(h,a)&&a!==m&&C(h,a,{get:()=>o[a],enumerable:!(s=Y(o,a))||s.enumerable});return h};var $=h=>Z(C({},"__esModule",{value:!0}),h);var ae={};Q(ae,{SchemaTableRenderer:()=>re});module.exports=$(ae);var l=require("react"),g=require("../../../lib/cn.cjs"),d=require("../utils/geometry.cjs"),_=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 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"})]}),V=()=>(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"})]}),O=({collapsed:h})=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:h?(0,e.jsx)("path",{d:"M6 3l5 5-5 5V3z"}):(0,e.jsx)("path",{d:"M3 6l5 5 5-5H3z"})}),F=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-amber-500 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"})}),H=()=>(0,e.jsx)("svg",{className:"w-3.5 h-3.5 text-purple-500 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"})}),ee=()=>(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"})}),te=()=>(0,e.jsxs)("svg",{className:"w-3 h-3 text-gray-300",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,l.memo)(function({field:o,tableId:m,editable:s,readOnly:a,disabled:c,onFieldChange:b,labels:x}){let[k,v]=(0,l.useState)(!1),[f,u]=(0,l.useState)(o.defaultValue??""),w=s&&!a&&!c,N=()=>{v(!1),b?.(m,o.id,{defaultValue:f||void 0})};return w?k?(0,e.jsx)("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":(0,M.formatUILabel)(x.schemaEditorDefaultValueFor,{field:o.name}),value:f,onChange:p=>u(p.target.value),onBlur:N,onKeyDown:p=>{p.key==="Enter"&&N(),p.key==="Escape"&&v(!1)},onMouseDown:p=>p.stopPropagation(),autoFocus:!0}):o.defaultValue?(0,e.jsxs)("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:p=>{p.stopPropagation(),u(o.defaultValue??""),v(!0)},onMouseDown:p=>p.stopPropagation(),title:(0,M.formatUILabel)(x.schemaEditorDefaultValue,{value:o.defaultValue}),children:["= ",o.defaultValue]}):(0,e.jsx)("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:p=>{p.stopPropagation(),u(""),v(!0)},onMouseDown:p=>p.stopPropagation(),title:x.schemaEditorSetDefaultValue,children:"= \u2205"}):o.defaultValue?(0,e.jsxs)("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:(0,M.formatUILabel)(x.schemaEditorDefaultValue,{value:o.defaultValue}),children:["= ",o.defaultValue]}):null}),re=(0,l.memo)(function({table:o,selected:m,disabled:s,readOnly:a,editable:c,dropTarget:b,fieldTypes:x,onTableNameChange:k,onTableNotesChange:v,onToggleCollapse:f,onFieldChange:u,onFieldAdd:w,onFieldRemove:N,onFieldReorder:p,onResizeStart:K,labels:i}){let L=o.width??d.DEFAULT_TABLE_WIDTH,D=o.collapsed??!1,S=x.length>0?x:_.DEFAULT_FIELD_TYPES,[B,T]=(0,l.useState)(null),[R,E]=(0,l.useState)(null),y=(0,l.useRef)(null),z=(0,l.useCallback)(t=>{k?.(o.id,t.target.value)},[o.id,k]),W=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{name:n})},[o.id,u]),U=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{type:n})},[o.id,u]),I=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{primaryKey:!n})},[o.id,u]),A=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{nullable:!n})},[o.id,u]),q=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{indexed:!n})},[o.id,u]),j=(0,l.useCallback)((t,n)=>{u?.(o.id,t,{unique:!n})},[o.id,u]),G=(0,l.useCallback)(()=>{w?.(o.id)},[o.id,w]);return(0,e.jsxs)("div",{"data-table-id":o.id,className:(0,g.cn)("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,b?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":m?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",s&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:L,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[(0,e.jsxs)("div",{className:(0,g.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:d.HEADER_HEIGHT},children:[c&&!a&&!s?(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":i.schemaEditorTableName,value:o.name,onChange:z,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:o.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(),f?.(o.id)},onMouseDown:t=>t.stopPropagation(),"aria-label":D?i.schemaEditorExpandTable:i.schemaEditorCollapseTable,children:(0,e.jsx)(O,{collapsed:D})})]}),!D&&(c&&!a&&!s?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:d.NOTES_ROW_HEIGHT},children:(0,e.jsx)("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":i.schemaEditorTableNotes,placeholder:i.schemaEditorNotesPlaceholder,value:o.notes??"",onChange:t=>v?.(o.id,t.target.value),onMouseDown:t=>t.stopPropagation()})}):o.notes?(0,e.jsx)("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:d.NOTES_ROW_HEIGHT},children:(0,e.jsx)("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!D&&(0,e.jsxs)("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((t,n)=>(0,e.jsxs)("div",{"data-field-id":t.id,"data-table-id":o.id,className:(0,g.cn)("flex items-center gap-1.5 pr-2 relative group",c&&!a&&!s?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",b?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",B===n&&"opacity-40",R===n&&"!border-t-2 !border-t-blue-400"),style:{height:d.FIELD_ROW_HEIGHT},draggable:c&&!a&&!s,onDragStart:r=>{!c||a||s||(r.stopPropagation(),y.current=n,T(n),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(n)))},onDragOver:r=>{y.current!==null&&(r.preventDefault(),r.stopPropagation(),E(n))},onDragLeave:()=>{R===n&&E(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),y.current!==null&&y.current!==n&&p?.(o.id,y.current,n),y.current=null,T(null),E(null)},onDragEnd:()=>{y.current=null,T(null),E(null)},children:[(0,e.jsx)("div",{"data-connection-side":"left","data-field-id":t.id,"data-table-id":o.id,className:(0,g.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-blue-400"),style:{top:d.FIELD_ROW_HEIGHT/2-5}}),c&&!a&&!s&&(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:d.FIELD_ROW_HEIGHT/2-6},children:(0,e.jsx)(te,{})}),c&&!a&&!s?(0,e.jsx)("button",{type:"button",className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",t.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),A(t.id,t.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:t.nullable?i.schemaEditorNullable:i.schemaEditorNotNullable,children:"?"}):(0,e.jsx)("span",{className:(0,g.cn)("w-4 text-xs font-bold flex-shrink-0 text-center",t.nullable?"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&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:i.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(P,{})}):(0,e.jsx)(P,{}),(0,e.jsx)(V,{})]}):t.primaryKey?c&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(t.id,!0)},onMouseDown:r=>r.stopPropagation(),title:i.schemaEditorRemovePrimaryKey,children:(0,e.jsx)(P,{})}):(0,e.jsx)(P,{}):t.foreignKey?(0,e.jsx)(V,{}):c&&!a&&!s?(0,e.jsx)("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),I(t.id,!1)},onMouseDown:r=>r.stopPropagation(),title:i.schemaEditorSetPrimaryKey,"aria-label":i.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&&!a&&!s?(0,e.jsx)("input",{className:(0,g.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":i.schemaEditorFieldName,value:t.name,onChange:r=>W(t.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):(0,e.jsx)("span",{className:(0,g.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&&!a&&!s?(0,e.jsxs)("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:t.type,onChange:r=>U(t.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[S.map(r=>(0,e.jsx)("option",{value:r,children:r},r)),!S.includes(t.type)&&(0,e.jsx)("option",{value:t.type,children:t.type})]}):(0,e.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:t.type}),(0,e.jsx)(oe,{field:t,tableId:o.id,editable:c,readOnly:a,disabled:s,onFieldChange:u,labels:i}),t.indexed&&(0,e.jsx)(F,{}),t.unique&&(0,e.jsx)(H,{}),c&&!a&&!s&&(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,g.cn)("cursor-pointer transition-opacity",t.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),q(t.id,t.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:t.indexed?i.schemaEditorRemoveIndex:i.schemaEditorAddIndex,children:(0,e.jsx)(F,{})}),(0,e.jsx)("button",{type:"button",className:(0,g.cn)("cursor-pointer transition-opacity",t.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),j(t.id,t.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:t.unique?i.schemaEditorRemoveUnique:i.schemaEditorAddUnique,children:(0,e.jsx)(H,{})}),(0,e.jsx)("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),N?.(o.id,t.id)},onMouseDown:r=>r.stopPropagation(),title:i.schemaEditorRemoveField,children:(0,e.jsx)(ee,{})})]}),(0,e.jsx)("div",{"data-connection-side":"right","data-field-id":t.id,"data-table-id":o.id,className:(0,g.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:d.FIELD_ROW_HEIGHT/2-5}})]},t.id)),c&&!a&&!s&&(0,e.jsxs)("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:d.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"})}),i.schemaEditorAddField]})]}),!s&&!a&&(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 n=o.height??(0,d.getTableHeight)(o,c);K?.(o.id,t.clientX,t.clientY,L,n)},children:(0,e.jsxs)("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-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 V,useCallback as g,useRef as Y,useState as D}from"react";import{cn as p}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as $,DEFAULT_TABLE_WIDTH as X,FIELD_ROW_HEIGHT as w,getTableHeight as J,HEADER_HEIGHT as Q,NOTES_ROW_HEIGHT as E}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as Z}from"../utils/schema-helpers.js";import{jsx as t,jsxs as c}from"react/jsx-runtime";var N=()=>c("svg",{className:"w-3.5 h-3.5 text-indigo-500 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"})]}),H=()=>c("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"})]}),O=({collapsed:P})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:P?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),_=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-500 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"})}),R=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-500 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"})}),ee=()=>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"})}),te=()=>c("svg",{className:"w-3 h-3 text-gray-300",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"})]}),oe=V(function({field:o,tableId:M,editable:n,readOnly:s,disabled:i,onFieldChange:x}){let[b,d]=D(!1),[v,m]=D(o.defaultValue??""),u=n&&!s&&!i,y=()=>{d(!1),x?.(M,o.id,{defaultValue:v||void 0})};return u?b?t("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":`Default value for ${o.name}`,value:v,onChange:l=>m(l.target.value),onBlur:y,onKeyDown:l=>{l.key==="Enter"&&y(),l.key==="Escape"&&d(!1)},onMouseDown:l=>l.stopPropagation(),autoFocus:!0}):o.defaultValue?c("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:l=>{l.stopPropagation(),m(o.defaultValue??""),d(!0)},onMouseDown:l=>l.stopPropagation(),title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:l=>{l.stopPropagation(),m(""),d(!0)},onMouseDown:l=>l.stopPropagation(),title:"Set default value",children:"= \u2205"}):o.defaultValue?c("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:`Default: ${o.defaultValue}`,children:["= ",o.defaultValue]}):null}),ie=V(function({table:o,selected:M,disabled:n,readOnly:s,editable:i,dropTarget:x,fieldTypes:b,onTableNameChange:d,onTableNotesChange:v,onToggleCollapse:m,onFieldChange:u,onFieldAdd:y,onFieldRemove:l,onFieldReorder:F,onResizeStart:K}){let C=o.width??X,k=o.collapsed??!1,L=b.length>0?b:Z,[B,T]=D(null),[S,f]=D(null),h=Y(null),z=g(e=>{d?.(o.id,e.target.value)},[o.id,d]),W=g((e,a)=>{u?.(o.id,e,{name:a})},[o.id,u]),A=g((e,a)=>{u?.(o.id,e,{type:a})},[o.id,u]),I=g((e,a)=>{u?.(o.id,e,{primaryKey:!a})},[o.id,u]),q=g((e,a)=>{u?.(o.id,e,{nullable:!a})},[o.id,u]),j=g((e,a)=>{u?.(o.id,e,{indexed:!a})},[o.id,u]),U=g((e,a)=>{u?.(o.id,e,{unique:!a})},[o.id,u]),G=g(()=>{y?.(o.id)},[o.id,y]);return c("div",{"data-table-id":o.id,className:p("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,x?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":M?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:C,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[c("div",{className:p("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:Q},children:[i&&!s&&!n?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":"Table name",value:o.name,onChange:z,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:o.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(),m?.(o.id)},onMouseDown:e=>e.stopPropagation(),"aria-label":k?"Expand table":"Collapse table",children:t(O,{collapsed:k})})]}),!k&&(i&&!s&&!n?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:E},children:t("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":"Table notes",placeholder:"Add notes...",value:o.notes??"",onChange:e=>v?.(o.id,e.target.value),onMouseDown:e=>e.stopPropagation()})}):o.notes?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:E},children:t("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!k&&c("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((e,a)=>c("div",{"data-field-id":e.id,"data-table-id":o.id,className:p("flex items-center gap-1.5 pr-2 relative group",i&&!s&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",x?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-750",B===a&&"opacity-40",S===a&&"!border-t-2 !border-t-blue-400"),style:{height:w},draggable:i&&!s&&!n,onDragStart:r=>{!i||s||n||(r.stopPropagation(),h.current=a,T(a),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(a)))},onDragOver:r=>{h.current!==null&&(r.preventDefault(),r.stopPropagation(),f(a))},onDragLeave:()=>{S===a&&f(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),h.current!==null&&h.current!==a&&F?.(o.id,h.current,a),h.current=null,T(null),f(null)},onDragEnd:()=>{h.current=null,T(null),f(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":o.id,className:p("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",x?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:w/2-5}}),i&&!s&&!n&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:w/2-6},children:t(te,{})}),i&&!s&&!n?t("button",{type:"button",className:p("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),q(e.id,e.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:e.nullable?"Nullable":"Not nullable",children:"?"}):t("span",{className:p("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?c("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i&&!s&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:t(N,{})}):t(N,{}),t(H,{})]}):e.primaryKey?i&&!s&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:"Primary Key (click to remove)",children:t(N,{})}):t(N,{}):e.foreignKey?t(H,{}):i&&!s&&!n?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),I(e.id,!1)},onMouseDown:r=>r.stopPropagation(),title:"Set as Primary Key","aria-label":"Set as primary key",children:c("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"}),i&&!s&&!n?t("input",{className:p("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":"Field name",value:e.name,onChange:r=>W(e.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):t("span",{className:p("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}),i&&!s&&!n?c("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:r=>A(e.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[L.map(r=>t("option",{value:r,children:r},r)),!L.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:e.type}),t(oe,{field:e,tableId:o.id,editable:i,readOnly:s,disabled:n,onFieldChange:u}),e.indexed&&t(_,{}),e.unique&&t(R,{}),i&&!s&&!n&&c("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:p("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),j(e.id,e.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:e.indexed?"Indexed (click to remove)":"Add index",children:t(_,{})}),t("button",{type:"button",className:p("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),U(e.id,e.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:e.unique?"Unique (click to remove)":"Add unique constraint",children:t(R,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),l?.(o.id,e.id)},onMouseDown:r=>r.stopPropagation(),title:"Remove field",children:t(ee,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":o.id,className:p("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",x?"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:w/2-5}})]},e.id)),i&&!s&&!n&&c("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 hover:bg-gray-50 dark:hover:bg-gray-750 transition-colors cursor-pointer",style:{height:$},onClick:e=>{e.stopPropagation(),G()},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"})}),"Add field"]})]}),!n&&!s&&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=o.height??J(o,i);K?.(o.id,e.clientX,e.clientY,C,a)},children:c("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-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{ie as SchemaTableRenderer};
|
|
1
|
+
import{memo as B,useCallback as g,useRef as J,useState as P}from"react";import{cn as d}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as Q,DEFAULT_TABLE_WIDTH as Z,FIELD_ROW_HEIGHT as D,getTableHeight as $,HEADER_HEIGHT as O,NOTES_ROW_HEIGHT as F}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as ee}from"../utils/schema-helpers.js";import{formatUILabel as L}from"../../../lib/ui-labels.js";import{jsx as t,jsxs as p}from"react/jsx-runtime";var E=()=>p("svg",{className:"w-3.5 h-3.5 text-indigo-500 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"})]}),H=()=>p("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"})]}),te=({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"})}),_=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-500 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"})}),K=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-500 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"})}),oe=()=>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"})}),re=()=>p("svg",{className:"w-3 h-3 text-gray-300",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"})]}),ae=B(function({field:o,tableId:T,editable:n,readOnly:i,disabled:l,onFieldChange:x,labels:h}){let[b,y]=P(!1),[v,c]=P(o.defaultValue??""),k=n&&!i&&!l,f=()=>{y(!1),x?.(T,o.id,{defaultValue:v||void 0})};return k?b?t("input",{className:"text-xs w-16 text-emerald-500 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":L(h.schemaEditorDefaultValueFor,{field:o.name}),value:v,onChange:u=>c(u.target.value),onBlur:f,onKeyDown:u=>{u.key==="Enter"&&f(),u.key==="Escape"&&y(!1)},onMouseDown:u=>u.stopPropagation(),autoFocus:!0}):o.defaultValue?p("button",{type:"button",className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:u=>{u.stopPropagation(),c(o.defaultValue??""),y(!0)},onMouseDown:u=>u.stopPropagation(),title:L(h.schemaEditorDefaultValue,{value:o.defaultValue}),children:["= ",o.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-300 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:u=>{u.stopPropagation(),c(""),y(!0)},onMouseDown:u=>u.stopPropagation(),title:h.schemaEditorSetDefaultValue,children:"= \u2205"}):o.defaultValue?p("span",{className:"text-xs text-emerald-500 flex-shrink-0 truncate max-w-16",title:L(h.schemaEditorDefaultValue,{value:o.defaultValue}),children:["= ",o.defaultValue]}):null}),ue=B(function({table:o,selected:T,disabled:n,readOnly:i,editable:l,dropTarget:x,fieldTypes:h,onTableNameChange:b,onTableNotesChange:y,onToggleCollapse:v,onFieldChange:c,onFieldAdd:k,onFieldRemove:f,onFieldReorder:u,onResizeStart:z,labels:s}){let S=o.width??Z,w=o.collapsed??!1,R=h.length>0?h:ee,[W,I]=P(null),[V,N]=P(null),m=J(null),U=g(e=>{b?.(o.id,e.target.value)},[o.id,b]),A=g((e,a)=>{c?.(o.id,e,{name:a})},[o.id,c]),q=g((e,a)=>{c?.(o.id,e,{type:a})},[o.id,c]),C=g((e,a)=>{c?.(o.id,e,{primaryKey:!a})},[o.id,c]),j=g((e,a)=>{c?.(o.id,e,{nullable:!a})},[o.id,c]),G=g((e,a)=>{c?.(o.id,e,{indexed:!a})},[o.id,c]),Y=g((e,a)=>{c?.(o.id,e,{unique:!a})},[o.id,c]),X=g(()=>{k?.(o.id)},[o.id,k]);return p("div",{"data-table-id":o.id,className:d("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",o.height?"flex flex-col":void 0,x?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":T?"border-blue-500 shadow-blue-100 dark:shadow-blue-900/30":"border-gray-300 dark:border-gray-600",n&&"opacity-60",o.locked&&"!cursor-default"),style:{left:o.x,top:o.y,width:S,height:o.height,userSelect:"none",overflow:o.height?"hidden":void 0},children:[p("div",{className:d("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:O},children:[l&&!i&&!n?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":s.schemaEditorTableName,value:o.name,onChange:U,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:o.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(),v?.(o.id)},onMouseDown:e=>e.stopPropagation(),"aria-label":w?s.schemaEditorExpandTable:s.schemaEditorCollapseTable,children:t(te,{collapsed:w})})]}),!w&&(l&&!i&&!n?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:F},children:t("input",{className:"w-full text-xs italic text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-400 dark:placeholder-gray-500","aria-label":s.schemaEditorTableNotes,placeholder:s.schemaEditorNotesPlaceholder,value:o.notes??"",onChange:e=>y?.(o.id,e.target.value),onMouseDown:e=>e.stopPropagation()})}):o.notes?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:F},children:t("span",{className:"text-xs italic text-gray-400 dark:text-gray-500 truncate",children:o.notes})}):null),!w&&p("div",{className:o.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[o.fields.map((e,a)=>p("div",{"data-field-id":e.id,"data-table-id":o.id,className:d("flex items-center gap-1.5 pr-2 relative group",l&&!i&&!n?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",x?"bg-blue-50/50 dark:bg-blue-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",W===a&&"opacity-40",V===a&&"!border-t-2 !border-t-blue-400"),style:{height:D},draggable:l&&!i&&!n,onDragStart:r=>{!l||i||n||(r.stopPropagation(),m.current=a,I(a),r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",String(a)))},onDragOver:r=>{m.current!==null&&(r.preventDefault(),r.stopPropagation(),N(a))},onDragLeave:()=>{V===a&&N(null)},onDrop:r=>{r.preventDefault(),r.stopPropagation(),m.current!==null&&m.current!==a&&u?.(o.id,m.current,a),m.current=null,I(null),N(null)},onDragEnd:()=>{m.current=null,I(null),N(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":o.id,className:d("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",x?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-blue-400"),style:{top:D/2-5}}),l&&!i&&!n&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:D/2-6},children:t(re,{})}),l&&!i&&!n?t("button",{type:"button",className:d("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-400":"text-transparent"),onClick:r=>{r.stopPropagation(),j(e.id,e.nullable??!1)},onMouseDown:r=>r.stopPropagation(),title:e.nullable?s.schemaEditorNullable:s.schemaEditorNotNullable,children:"?"}):t("span",{className:d("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?p("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l&&!i&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),C(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:s.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}),t(H,{})]}):e.primaryKey?l&&!i&&!n?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:r=>{r.stopPropagation(),C(e.id,!0)},onMouseDown:r=>r.stopPropagation(),title:s.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}):e.foreignKey?t(H,{}):l&&!i&&!n?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-300 hover:text-indigo-400 transition-colors cursor-pointer",onClick:r=>{r.stopPropagation(),C(e.id,!1)},onMouseDown:r=>r.stopPropagation(),title:s.schemaEditorSetPrimaryKey,"aria-label":s.schemaEditorSetPrimaryKey,children:p("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&&!i&&!n?t("input",{className:d("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":s.schemaEditorFieldName,value:e.name,onChange:r=>A(e.id,r.target.value),onMouseDown:r=>r.stopPropagation()}):t("span",{className:d("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&&!i&&!n?p("select",{className:"text-xs text-gray-400 dark:text-gray-500 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:r=>q(e.id,r.target.value),onMouseDown:r=>r.stopPropagation(),children:[R.map(r=>t("option",{value:r,children:r},r)),!R.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:e.type}),t(ae,{field:e,tableId:o.id,editable:l,readOnly:i,disabled:n,onFieldChange:c,labels:s}),e.indexed&&t(_,{}),e.unique&&t(K,{}),l&&!i&&!n&&p("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:d("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),G(e.id,e.indexed??!1)},onMouseDown:r=>r.stopPropagation(),title:e.indexed?s.schemaEditorRemoveIndex:s.schemaEditorAddIndex,children:t(_,{})}),t("button",{type:"button",className:d("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:r=>{r.stopPropagation(),Y(e.id,e.unique??!1)},onMouseDown:r=>r.stopPropagation(),title:e.unique?s.schemaEditorRemoveUnique:s.schemaEditorAddUnique,children:t(K,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-300 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:r=>{r.stopPropagation(),f?.(o.id,e.id)},onMouseDown:r=>r.stopPropagation(),title:s.schemaEditorRemoveField,children:t(oe,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":o.id,className:d("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",x?"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:D/2-5}})]},e.id)),l&&!i&&!n&&p("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-400 hover:text-blue-500 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"})}),s.schemaEditorAddField]})]}),!n&&!i&&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=o.height??$(o,l);z?.(o.id,e.clientX,e.clientY,S,a)},children:p("svg",{className:"w-full h-full text-gray-300 group-hover/resize:text-blue-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 y=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var K=(i,r)=>{for(var n in r)y(i,n,{get:r[n],enumerable:!0})},W=(i,r,n,g)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of Y(r))!j.call(i,s)&&s!==n&&y(i,s,{get:()=>r[s],enumerable:!(g=U(r,s))||g.enumerable});return i};var X=i=>W(y({},"__esModule",{value:!0}),i);var d0={};K(d0,{SchemaToolbar:()=>g0});module.exports=X(d0);var a=require("react"),M=require("../../../lib/cn.cjs"),e=require("../../button/Button.cjs"),u=require("../../button-group/ButtonGroup.cjs"),t=require("../../tooltip/Tooltip.cjs"),m=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"})}),$=()=>(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"})}),o0=()=>(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"})}),a0=()=>(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"})}),e0=()=>(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"})}),t0=()=>(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"})}),r0=()=>(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"})}),l0=()=>(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"})}),i0=()=>(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"})}),s0=()=>(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"})}),n0=()=>(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"})}),g0=(0,a.memo)(function({zoom:r,onZoomIn:n,onZoomOut:g,onResetView:s,onFitToContent:N,onAddTable:R,onExportJSON:x,onImportJSON:C,onExportSQL:d,onUndo:z,onRedo:k,canUndo:H=!1,canRedo:I=!1,onAutoLayout:f,disabled:l,className:O}){let[L,w]=(0,a.useState)(!1),[T,b]=(0,a.useState)(!1),[V,S]=(0,a.useState)(!1),[B,E]=(0,a.useState)(""),[c,h]=(0,a.useState)(""),[A,Z]=(0,a.useState)(""),J=(0,a.useCallback)(()=>{E(x()),w(!0)},[x]),D=(0,a.useCallback)(()=>{c.trim()&&(C(c.trim()),h(""),b(!1))},[c,C]),P=(0,a.useCallback)(()=>{h(""),b(!1)},[]),Q=(0,a.useCallback)(()=>{w(!1)},[]),q=(0,a.useCallback)(()=>{d&&(Z(d()),S(!0))},[d]),F=(0,a.useCallback)(()=>{S(!1)},[]),G=Math.round(r*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",O),"data-testid":"schema-toolbar",onMouseDown:p=>p.stopPropagation(),children:[(0,o.jsxs)(u.ButtonGroup,{size:"sm",children:[(0,o.jsx)(t.Tooltip,{content:"Zoom in",size:"sm",position:"bottom",children:(0,o.jsx)(e.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:n,disabled:l,"aria-label":"Zoom in"})}),(0,o.jsx)(t.Tooltip,{content:"Zoom out",size:"sm",position:"bottom",children:(0,o.jsx)(e.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:g,disabled:l,"aria-label":"Zoom out"})})]}),(0,o.jsxs)("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 min-w-[3ch] text-center select-none",children:[G,"%"]}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Reset view",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(o0,{}),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":"Reset view"})}),(0,o.jsx)(t.Tooltip,{content:"Fit to content",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(a0,{}),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:N,disabled:l,"aria-label":"Fit to content"})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Add table",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(e0,{}),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":"Add table"})}),(0,o.jsx)("div",{className:"w-px h-5 bg-gray-200 dark:bg-gray-600"}),(0,o.jsx)(t.Tooltip,{content:"Export JSON",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(t0,{}),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":"Export JSON"})}),(0,o.jsx)(t.Tooltip,{content:"Import JSON",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(r0,{}),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:()=>b(!0),disabled:l,"aria-label":"Import JSON"})}),d&&(0,o.jsx)(t.Tooltip,{content:"Export SQL",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(l0,{}),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":"Export SQL"})}),(z||k)&&(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)(u.ButtonGroup,{size:"sm",children:[(0,o.jsx)(t.Tooltip,{content:"Undo (Ctrl+Z)",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(i0,{}),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||!H,"aria-label":"Undo"})}),(0,o.jsx)(t.Tooltip,{content:"Redo (Ctrl+Y)",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(s0,{}),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||!I,"aria-label":"Redo"})})]})]}),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.jsx)(t.Tooltip,{content:"Auto layout",size:"sm",position:"bottom",children:(0,o.jsx)(e.Button,{icon:(0,o.jsx)(n0,{}),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,"aria-label":"Auto layout"})})]})]}),(0,o.jsx)(m.Modal,{isOpen:L,onClose:Q,title:"Export Schema",description:"Copy the JSON below to save your schema.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",children:(0,o.jsx)(v.Input,{label:"Schema JSON",multiline:!0,rows:12,value:B,readOnly:!0,size:"sm"})}),(0,o.jsx)(m.Modal,{isOpen:T,onClose:P,title:"Import Schema",description:"Paste schema JSON to load it into the editor.",size:"lg",showSubmit:!0,submitLabel:"Import",onSubmitClick:D,showCancel:!0,cancelLabel:"Cancel",children:(0,o.jsx)(v.Input,{label:"Schema JSON",multiline:!0,rows:12,value:c,onChange:p=>h(p.target.value),placeholder:'{"tables": [], "relations": []}',size:"sm"})}),(0,o.jsx)(m.Modal,{isOpen:V,onClose:F,title:"Export SQL",description:"Generated PostgreSQL CREATE TABLE statements.",size:"lg",showSubmit:!1,showCancel:!0,cancelLabel:"Close",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 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 +1 @@
|
|
|
1
|
-
import{memo as
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";"use client";var U=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Le=(a,o)=>{for(var c in o)U(a,c,{get:o[c],enumerable:!0})},Ie=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Ee(o))!Ne.call(a,i)&&i!==c&&U(a,i,{get:()=>o[i],enumerable:!(l=ye(o,i))||l.enumerable});return a};var De=a=>Ie(U({},"__esModule",{value:!0}),a);var Ke={};Le(Ke,{Select:()=>He});module.exports=De(Ke);var r=require("react"),ce=require("react-dom"),ue=require("../../lib/aria-hide.cjs"),n=require("react/jsx-runtime"),_=()=>{},Ce=[],Se=(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Me=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.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"})}),Ae=(0,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Oe=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),O={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-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-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 Re(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 Te=(0,r.memo)((0,r.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:P,optionId:g,onClick:m,onMouseEnter:I,index:w},R){let V=()=>{i||m(o.value)},E=()=>{i||I(w)};return(0,n.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:k(O[P].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-blue-50 dark:bg-blue-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:V,onMouseEnter:E,children:[o.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,n.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,n.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,n.jsx)("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:Oe}):null]})}));function He({options:a=Ce,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:P=!1,disabled:g=!1,readOnly:m=!1,loading:I=!1,size:w="md",variant:R="default",placeholder:V="Select...",label:E,description:q,helperText:F,error:D,required:Q=!1,noOptionsText:de="No options",onSearchChange:X,name:Z,className:pe,triggerClassName:fe,contentClassName:ge,maxHeight:B=256}){let C=(0,r.useId)(),$=`${C}-label`,G=`${C}-trigger`,J=`${C}-listbox`,v=(0,r.useRef)(null),W=(0,r.useRef)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)([]),S=o!==void 0,[be,ne]=(0,r.useState)(c??""),N=S?o:be,[u,Y]=(0,r.useState)(!1),[j,M]=(0,r.useState)(""),[s,f]=(0,r.useState)(-1),[T,re]=(0,r.useState)(null),p=(0,r.useMemo)(()=>i?Re(a,j):a,[a,j,i]),H=(0,r.useMemo)(()=>a.find(e=>e.value===N)??null,[a,N]),x=(0,r.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),L=(0,r.useCallback)(e=>{S||ne(e),(l??_)(e),Y(!1),M(""),f(-1),v.current?.focus()},[S,l]),me=(0,r.useCallback)(e=>{e.stopPropagation(),S||ne(""),(l??_)(""),M(""),v.current?.focus()},[S,l]),A=(0,r.useCallback)(()=>{g||m||(Y(!0),M(""),f(-1))},[g,m]),b=(0,r.useCallback)(()=>{Y(!1),M(""),f(-1),v.current?.focus()},[]),he=(0,r.useCallback)(()=>{u?b():A()},[u,b,A]),h=(0,r.useCallback)((e,t)=>{let d=p.length;if(d===0)return-1;let y=e;for(let K=0;K<d;K++)if(y=((y+t)%d+d)%d,!x.has(p[y].value))return y;return-1},[p,x]),ve=(0,r.useCallback)(e=>{if(!(g||m)){if(u){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(p.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(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}}},[g,m,u,A,b,s,p,x,h,L]),oe=(0,r.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(p.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<p.length){let t=p[s];x.has(t.value)||L(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[s,p,x,h,L,b]),xe=(0,r.useCallback)(e=>{let t=e.target.value;M(t),f(-1),(X??_)(t)},[X]);(0,r.useEffect)(()=>{if(!u)return;let e=t=>{let d=t.target;v.current?.contains(d)||W.current?.contains(d)||b()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[u,b]),(0,r.useEffect)(()=>{if(!u||!v.current){re(null);return}let e=()=>{let t=v.current;if(!t)return;let d=t.getBoundingClientRect(),y=window.innerHeight-d.bottom,K=d.top,se=B+8,le=y<se&&K>y?"top":"bottom";re({top:le==="bottom"?d.bottom+window.scrollY+4:d.top+window.scrollY-se,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)}},[u,B]),(0,r.useEffect)(()=>{u&&i&&ee.current?.focus()},[u,i]),(0,r.useEffect)(()=>{let e=W.current;if(!(!u||!e))return(0,ue.registerFloatingLayer)(e,()=>v.current)},[u]),(0,r.useEffect)(()=>{if(s>=0){let e=te.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let z=N!==""&&N!==void 0,ke=P&&z&&!g&&!m&&!I,ae=!g&&!m,we=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",O[w].trigger,ie[R].trigger,!D&&ae&&ie[R].focus,D&&"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",m&&"cursor-default",!g&&!m&&"cursor-pointer",fe);return(0,n.jsxs)("div",{className:k("flex flex-col gap-1",pe),children:[E?(0,n.jsxs)("label",{id:$,htmlFor:G,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[E,Q?(0,n.jsx)("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,q?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:q}):null,(0,n.jsxs)("button",{ref:v,id:G,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?J:void 0,"aria-labelledby":E?$:void 0,"aria-required":Q||void 0,"aria-invalid":D?!0:void 0,"aria-activedescendant":u&&s>=0?`${C}-option-${s}`:void 0,disabled:g,className:we,onClick:ae?he:void 0,onKeyDown:ve,children:[(0,n.jsxs)("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!z&&"text-gray-400 dark:text-gray-500"),children:[H?.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,n.jsx)("span",{className:"truncate",children:z&&H?H.label:V})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[I?(0,n.jsx)("span",{className:"text-gray-400",children:Ae}):null,ke?(0,n.jsx)("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:me,onMouseDown:e=>e.preventDefault(),children:Me}):null,(0,n.jsx)("span",{className:k("text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Se})]})]}),D?(0,n.jsx)("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:D}):F?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:F}):null,Z?(0,n.jsx)("input",{type:"hidden",name:Z,value:N??""}):null,u&&T?(0,ce.createPortal)((0,n.jsxs)("div",{ref:W,role:"listbox",id:J,"aria-labelledby":E?$: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",O[w].content,ge),style:{top:T.top,left:T.left,width:T.width,position:"absolute"},onKeyDown:oe,children:[i?(0,n.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,n.jsx)("input",{ref:ee,type:"text",role:"searchbox","aria-label":"Search options",className:k(O[w].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:j,onChange:xe,onKeyDown:oe})}):null,(0,n.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:B},children:p.length===0?(0,n.jsx)("div",{className:k(O[w].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:de}):p.map((e,t)=>(0,n.jsx)(Te,{option:e,isSelected:e.value===N,isHighlighted:t===s,isDisabled:I||x.has(e.value),sizeKey:w,optionId:`${C}-option-${t}`,onClick:L,onMouseEnter:f,index:t,ref:d=>{te.current[t]=d}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
|
|
1
|
+
"use strict";"use client";var q=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var Ae=(s,o)=>{for(var c in o)q(s,c,{get:o[c],enumerable:!0})},Pe=(s,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Oe(o))!Te.call(s,i)&&i!==c&&q(s,i,{get:()=>o[i],enumerable:!(l=Me(o,i))||l.enumerable});return s};var Re=s=>Pe(q({},"__esModule",{value:!0}),s);var je={};Ae(je,{Select:()=>Ye});module.exports=Re(je);var r=require("react"),ue=require("react-dom"),de=require("../../lib/aria-hide.cjs"),pe=require("../../lib/i18n.cjs"),n=require("react/jsx-runtime"),F=()=>{},He=[],Ke=(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ve=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.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,n.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,n.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,n.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),$e=(0,n.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,n.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"}},ce={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function w(...s){let o="";for(let c=0;c<s.length;c++){let l=s[c];l&&(o&&(o+=" "),o+=l)}return o}function We(s,o){if(!o)return s;let c=o.toLowerCase();return s.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,r.memo)((0,r.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:B,optionId:g,onClick:m,onMouseEnter:I,index:k},R){let $=()=>{i||m(o.value)},E=()=>{i||I(k)};return(0,n.jsxs)("div",{ref:R,id:g,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:w(P[B].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-blue-50 dark:bg-blue-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:$,onMouseEnter:E,children:[o.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,n.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,n.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,n.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,n.jsx)("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:$e}):null]})}));function Ye({options:s=He,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:B=!1,disabled:g=!1,readOnly:m=!1,loading:I=!1,size:k="md",variant:R="default",placeholder:$,label:E,description:Q,helperText:X,error:D,required:Z=!1,noOptionsText:fe,clearLabel:ge,searchLabel:be,searchPlaceholder:me,onSearchChange:G,name:J,className:he,triggerClassName:ve,contentClassName:xe,maxHeight:W=256}){let C=(0,pe.useUILabels)(),we=$??C.selectPlaceholder,ke=fe??C.selectNoOptions,S=(0,r.useId)(),U=`${S}-label`,ee=`${S}-trigger`,te=`${S}-listbox`,v=(0,r.useRef)(null),Y=(0,r.useRef)(null),ne=(0,r.useRef)(null),re=(0,r.useRef)([]),M=o!==void 0,[ye,oe]=(0,r.useState)(c??""),L=M?o:ye,[p,j]=(0,r.useState)(!1),[z,O]=(0,r.useState)(""),[a,f]=(0,r.useState)(-1),[T,se]=(0,r.useState)(null),d=(0,r.useMemo)(()=>i?We(s,z):s,[s,z,i]),H=(0,r.useMemo)(()=>s.find(e=>e.value===L)??null,[s,L]),x=(0,r.useMemo)(()=>{let e=new Set;for(let t of s)t.disabled&&e.add(t.value);return e},[s]),N=(0,r.useCallback)(e=>{M||oe(e),(l??F)(e),j(!1),O(""),f(-1),v.current?.focus()},[M,l]),Ee=(0,r.useCallback)(e=>{e.stopPropagation(),M||oe(""),(l??F)(""),O(""),v.current?.focus()},[M,l]),A=(0,r.useCallback)(()=>{g||m||(j(!0),O(""),f(-1))},[g,m]),b=(0,r.useCallback)(()=>{j(!1),O(""),f(-1),v.current?.focus()},[]),Le=(0,r.useCallback)(()=>{p?b():A()},[p,b,A]),h=(0,r.useCallback)((e,t)=>{let u=d.length;if(u===0)return-1;let y=e;for(let V=0;V<u;V++)if(y=((y+t)%u+u)%u,!x.has(d[y].value))return y;return-1},[d,x]),Ne=(0,r.useCallback)(e=>{if(!(g||m)){if(p){switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(a,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(a,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(d.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),a>=0&&a<d.length){let t=d[a];x.has(t.value)||N(t.value)}break}case" ":if(e.preventDefault(),a>=0&&a<d.length){let t=d[a];x.has(t.value)||N(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}}},[g,m,p,A,b,a,d,x,h,N]),Ie=(0,r.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=h(a,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=h(a,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=h(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=h(d.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),a>=0&&a<d.length){let t=d[a];x.has(t.value)||N(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[a,d,x,h,N,b]),De=(0,r.useCallback)(e=>{let t=e.target.value;O(t),f(-1),(G??F)(t)},[G]);(0,r.useEffect)(()=>{if(!p)return;let e=t=>{let u=t.target;v.current?.contains(u)||Y.current?.contains(u)||b()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[p,b]),(0,r.useEffect)(()=>{if(!p||!v.current){se(null);return}let e=()=>{let t=v.current;if(!t)return;let u=t.getBoundingClientRect(),y=window.innerHeight-u.bottom,V=u.top,le=W+8,ie=y<le&&V>y?"top":"bottom";se({top:ie==="bottom"?u.bottom+window.scrollY+4:u.top+window.scrollY-le,left:u.left+window.scrollX,width:u.width,placement:ie})};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&&T!==null;(0,r.useEffect)(()=>{K&&i&&ne.current?.focus()},[K,i]),(0,r.useEffect)(()=>{let e=Y.current;if(!(!K||!e))return(0,de.registerFloatingLayer)(e,()=>v.current)},[K]),(0,r.useEffect)(()=>{if(a>=0){let e=re.current[a];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[a]);let _=L!==""&&L!==void 0,Ce=B&&_&&!g&&!m&&!I,ae=!g&&!m,Se=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",P[k].trigger,ce[R].trigger,!D&&ae&&ce[R].focus,D&&"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",m&&"cursor-default",!g&&!m&&"cursor-pointer",ve);return(0,n.jsxs)("div",{className:w("flex flex-col gap-1",he),children:[E?(0,n.jsxs)("label",{id:U,htmlFor:ee,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[E,Z?(0,n.jsx)("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Q?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Q}):null,(0,n.jsxs)("button",{ref:v,id:ee,type:"button",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-controls":p?te:void 0,"aria-labelledby":E?U:void 0,"aria-required":Z||void 0,"aria-invalid":D?!0:void 0,"aria-activedescendant":p&&a>=0?`${S}-option-${a}`:void 0,disabled:g,className:Se,onClick:ae?Le:void 0,onKeyDown:Ne,children:[(0,n.jsxs)("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!_&&"text-gray-400 dark:text-gray-500"),children:[H?.icon?(0,n.jsx)("span",{className:"flex shrink-0 items-center",children:H.icon}):null,(0,n.jsx)("span",{className:"truncate",children:_&&H?H.label:we})]}),(0,n.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[I?(0,n.jsx)("span",{className:"text-gray-400",children:Be}):null,Ce?(0,n.jsx)("span",{role:"button",tabIndex:-1,"aria-label":ge??C.selectClear,className:"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:Ve}):null,(0,n.jsx)("span",{className:w("text-gray-400 transition-transform duration-200",p&&"rotate-180"),children:Ke})]})]}),D?(0,n.jsx)("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:D}):X?(0,n.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,J?(0,n.jsx)("input",{type:"hidden",name:J,value:L??""}):null,p&&T?(0,ue.createPortal)((0,n.jsxs)("div",{ref:Y,role:"listbox",id:te,"aria-labelledby":E?U: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",P[k].content,xe),style:{top:T.top,left:T.left,width:T.width,position:"absolute"},onKeyDown:Ie,children:[i?(0,n.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,n.jsx)("input",{ref:ne,type:"text",role:"searchbox","aria-label":be??C.selectSearch,className:w(P[k].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:me??C.selectSearchPlaceholder,value:z,onChange:De})}):null,(0,n.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:W},children:d.length===0?(0,n.jsx)("div",{className:w(P[k].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ke}):d.map((e,t)=>(0,n.jsx)(Ue,{option:e,isSelected:e.value===L,isHighlighted:t===a,isDisabled:I||x.has(e.value),sizeKey:k,optionId:`${S}-option-${t}`,onClick:N,onMouseEnter:f,index:t,ref:u=>{re.current[t]=u}},e.value))})]}),document.body):null]})}0&&(module.exports={Select});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as R,useRef as $,useEffect as T,useCallback as h,useMemo as Q,useId as Ne,memo as Le,forwardRef as Ie}from"react";import{createPortal as De}from"react-dom";import{registerFloatingLayer as Ce}from"../../lib/aria-hide.js";import{jsx as n,jsxs as v}from"react/jsx-runtime";var X=()=>{},Se=[],Me=n("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ae=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Oe=v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[n("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),n("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Re=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),H={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-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function w(...c){let o="";for(let u=0;u<c.length;u++){let l=c[u];l&&(o&&(o+=" "),o+=l)}return o}function Te(c,o){if(!o)return c;let u=o.toLowerCase();return c.filter(l=>{if(l.label.toLowerCase().includes(u)||l.value.toLowerCase().includes(u))return!0;if(l.keywords){for(let d of l.keywords)if(d.toLowerCase().includes(u))return!0}return!1})}var He=Le(Ie(function({option:o,isSelected:u,isHighlighted:l,isDisabled:d,sizeKey:W,optionId:f,onClick:b,onMouseEnter:D,index:y},K){let Y=()=>{d||b(o.value)},N=()=>{d||D(y)};return v("div",{ref:K,id:f,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":l||void 0,className:w(H[W].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!d&&"bg-blue-50 dark:bg-blue-900/30",u&&!l&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:Y,onMouseEnter:N,children:[o.icon?n("span",{className:"flex shrink-0 items-center",children:o.icon}):null,v("span",{className:"flex flex-col min-w-0 flex-1",children:[n("span",{className:"truncate",children:o.label}),o.description?n("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?n("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:Re}):null]})}));function Be({options:c=Se,value:o,defaultValue:u,onValueChange:l,searchable:d=!1,clearable:W=!1,disabled:f=!1,readOnly:b=!1,loading:D=!1,size:y="md",variant:K="default",placeholder:Y="Select...",label:N,description:Z,helperText:G,error:C,required:J=!1,noOptionsText:fe="No options",onSearchChange:ee,name:te,className:ge,triggerClassName:be,contentClassName:me,maxHeight:j=256}){let S=Ne(),z=`${S}-label`,ne=`${S}-trigger`,re=`${S}-listbox`,x=$(null),U=$(null),oe=$(null),ae=$([]),M=o!==void 0,[he,se]=R(u??""),L=M?o:he,[a,_]=R(!1),[q,A]=R(""),[r,p]=R(-1),[P,le]=R(null),i=Q(()=>d?Te(c,q):c,[c,q,d]),V=Q(()=>c.find(e=>e.value===L)??null,[c,L]),k=Q(()=>{let e=new Set;for(let t of c)t.disabled&&e.add(t.value);return e},[c]),I=h(e=>{M||se(e),(l??X)(e),_(!1),A(""),p(-1),x.current?.focus()},[M,l]),ve=h(e=>{e.stopPropagation(),M||se(""),(l??X)(""),A(""),x.current?.focus()},[M,l]),O=h(()=>{f||b||(_(!0),A(""),p(-1))},[f,b]),g=h(()=>{_(!1),A(""),p(-1),x.current?.focus()},[]),xe=h(()=>{a?g():O()},[a,g,O]),m=h((e,t)=>{let s=i.length;if(s===0)return-1;let E=e;for(let B=0;B<s;B++)if(E=((E+t)%s+s)%s,!k.has(i[E].value))return E;return-1},[i,k]),ke=h(e=>{if(!(f||b)){if(a){switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(i.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(t.value)}break}case" ":if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(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(),O();break;case"Enter":case" ":e.preventDefault(),O();break}}},[f,b,a,O,g,r,i,k,m,I]),ie=h(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(i.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<i.length){let t=i[r];k.has(t.value)||I(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[r,i,k,m,I,g]),we=h(e=>{let t=e.target.value;A(t),p(-1),(ee??X)(t)},[ee]);T(()=>{if(!a)return;let e=t=>{let s=t.target;x.current?.contains(s)||U.current?.contains(s)||g()};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[a,g]),T(()=>{if(!a||!x.current){le(null);return}let e=()=>{let t=x.current;if(!t)return;let s=t.getBoundingClientRect(),E=window.innerHeight-s.bottom,B=s.top,ue=j+8,de=E<ue&&B>E?"top":"bottom";le({top:de==="bottom"?s.bottom+window.scrollY+4:s.top+window.scrollY-ue,left:s.left+window.scrollX,width:s.width,placement:de})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[a,j]),T(()=>{a&&d&&oe.current?.focus()},[a,d]),T(()=>{let e=U.current;if(!(!a||!e))return Ce(e,()=>x.current)},[a]),T(()=>{if(r>=0){let e=ae.current[r];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[r]);let F=L!==""&&L!==void 0,ye=W&&F&&!f&&!b&&!D,ce=!f&&!b,Ee=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",H[y].trigger,pe[K].trigger,!C&&ce&&pe[K].focus,C&&"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",b&&"cursor-default",!f&&!b&&"cursor-pointer",be);return v("div",{className:w("flex flex-col gap-1",ge),children:[N?v("label",{id:z,htmlFor:ne,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[N,J?n("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,Z?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z}):null,v("button",{ref:x,id:ne,type:"button",role:"combobox","aria-expanded":a,"aria-haspopup":"listbox","aria-controls":a?re:void 0,"aria-labelledby":N?z:void 0,"aria-required":J||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":a&&r>=0?`${S}-option-${r}`:void 0,disabled:f,className:Ee,onClick:ce?xe:void 0,onKeyDown:ke,children:[v("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!F&&"text-gray-400 dark:text-gray-500"),children:[V?.icon?n("span",{className:"flex shrink-0 items-center",children:V.icon}):null,n("span",{className:"truncate",children:F&&V?V.label:Y})]}),v("span",{className:"flex items-center gap-1 shrink-0",children:[D?n("span",{className:"text-gray-400",children:Oe}):null,ye?n("span",{role:"button",tabIndex:-1,"aria-label":"Clear selection",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:ve,onMouseDown:e=>e.preventDefault(),children:Ae}):null,n("span",{className:w("text-gray-400 transition-transform duration-200",a&&"rotate-180"),children:Me})]})]}),C?n("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:C}):G?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:G}):null,te?n("input",{type:"hidden",name:te,value:L??""}):null,a&&P?De(v("div",{ref:U,role:"listbox",id:re,"aria-labelledby":N?z: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",H[y].content,me),style:{top:P.top,left:P.left,width:P.width,position:"absolute"},onKeyDown:ie,children:[d?n("div",{className:"border-b border-gray-200 dark:border-gray-700",children:n("input",{ref:oe,type:"text",role:"searchbox","aria-label":"Search options",className:w(H[y].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:"Search...",value:q,onChange:we,onKeyDown:ie})}):null,n("div",{className:"overflow-y-auto",style:{maxHeight:j},children:i.length===0?n("div",{className:w(H[y].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:fe}):i.map((e,t)=>n(He,{option:e,isSelected:e.value===L,isHighlighted:t===r,isDisabled:D||k.has(e.value),sizeKey:y,optionId:`${S}-option-${t}`,onClick:I,onMouseEnter:p,index:t,ref:s=>{ae.current[t]=s}},e.value))})]}),document.body):null]})}export{Be as Select};
|
|
1
|
+
"use client";import{useState as R,useRef as U,useEffect as H,useCallback as h,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 n,jsxs as v}from"react/jsx-runtime";var G=()=>{},Ke=[],Ve=n("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Be=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("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=v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[n("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),n("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),We=n("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:n("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"}},fe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}};function k(...i){let o="";for(let u=0;u<i.length;u++){let a=i[u];a&&(o&&(o+=" "),o+=a)}return o}function Ue(i,o){if(!o)return i;let u=o.toLowerCase();return i.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 Ye=Te(Ae(function({option:o,isSelected:u,isHighlighted:a,isDisabled:d,sizeKey:Y,optionId:f,onClick:b,onMouseEnter:D,index:y},V){let j=()=>{d||b(o.value)},L=()=>{d||D(y)};return v("div",{ref:V,id:f,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":a||void 0,className:k(K[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",a&&!d&&"bg-blue-50 dark:bg-blue-900/30",u&&!a&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:L,children:[o.icon?n("span",{className:"flex shrink-0 items-center",children:o.icon}):null,v("span",{className:"flex flex-col min-w-0 flex-1",children:[n("span",{className:"truncate",children:o.label}),o.description?n("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?n("span",{className:"ml-auto text-blue-600 dark:text-blue-400",children:We}):null]})}));function Fe({options:i=Ke,value:o,defaultValue:u,onValueChange:a,searchable:d=!1,clearable:Y=!1,disabled:f=!1,readOnly:b=!1,loading:D=!1,size:y="md",variant:V="default",placeholder:j,label:L,description:J,helperText:ee,error:C,required:te=!1,noOptionsText:ge,clearLabel:be,searchLabel:me,searchPlaceholder:he,onSearchChange:ne,name:re,className:ve,triggerClassName:xe,contentClassName:we,maxHeight:z=256}){let S=He(),ke=j??S.selectPlaceholder,ye=ge??S.selectNoOptions,M=Oe(),_=`${M}-label`,oe=`${M}-trigger`,se=`${M}-listbox`,x=U(null),q=U(null),ae=U(null),le=U([]),O=o!==void 0,[Ee,ie]=R(u??""),N=O?o:Ee,[c,F]=R(!1),[Q,T]=R(""),[r,p]=R(-1),[A,ce]=R(null),l=Z(()=>d?Ue(i,Q):i,[i,Q,d]),B=Z(()=>i.find(e=>e.value===N)??null,[i,N]),w=Z(()=>{let e=new Set;for(let t of i)t.disabled&&e.add(t.value);return e},[i]),I=h(e=>{O||ie(e),(a??G)(e),F(!1),T(""),p(-1),x.current?.focus()},[O,a]),Le=h(e=>{e.stopPropagation(),O||ie(""),(a??G)(""),T(""),x.current?.focus()},[O,a]),P=h(()=>{f||b||(F(!0),T(""),p(-1))},[f,b]),g=h(()=>{F(!1),T(""),p(-1),x.current?.focus()},[]),Ne=h(()=>{c?g():P()},[c,g,P]),m=h((e,t)=>{let s=l.length;if(s===0)return-1;let E=e;for(let W=0;W<s;W++)if(E=((E+t)%s+s)%s,!w.has(l[E].value))return E;return-1},[l,w]),Ie=h(e=>{if(!(f||b)){if(c){switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];w.has(t.value)||I(t.value)}break}case" ":if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];w.has(t.value)||I(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,b,c,P,g,r,l,w,m,I]),De=h(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=m(r,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=m(r,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=m(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=m(l.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),r>=0&&r<l.length){let t=l[r];w.has(t.value)||I(t.value)}break}case"Escape":e.preventDefault(),g();break;case"Tab":g();break}},[r,l,w,m,I,g]),Ce=h(e=>{let t=e.target.value;T(t),p(-1),(ne??G)(t)},[ne]);H(()=>{if(!c)return;let e=t=>{let s=t.target;x.current?.contains(s)||q.current?.contains(s)||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 s=t.getBoundingClientRect(),E=window.innerHeight-s.bottom,W=s.top,de=z+8,pe=E<de&&W>E?"top":"bottom";ce({top:pe==="bottom"?s.bottom+window.scrollY+4:s.top+window.scrollY-de,left:s.left+window.scrollX,width:s.width,placement:pe})};return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[c,z]);let $=c&&A!==null;H(()=>{$&&d&&ae.current?.focus()},[$,d]),H(()=>{let e=q.current;if(!(!$||!e))return Re(e,()=>x.current)},[$]),H(()=>{if(r>=0){let e=le.current[r];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[r]);let X=N!==""&&N!==void 0,Se=Y&&X&&!f&&!b&&!D,ue=!f&&!b,Me=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",K[y].trigger,fe[V].trigger,!C&&ue&&fe[V].focus,C&&"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",b&&"cursor-default",!f&&!b&&"cursor-pointer",xe);return v("div",{className:k("flex flex-col gap-1",ve),children:[L?v("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[L,te?n("span",{className:"text-red-500 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,v("button",{ref:x,id:oe,type:"button",role:"combobox","aria-expanded":c,"aria-haspopup":"listbox","aria-controls":c?se:void 0,"aria-labelledby":L?_:void 0,"aria-required":te||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":c&&r>=0?`${M}-option-${r}`:void 0,disabled:f,className:Me,onClick:ue?Ne:void 0,onKeyDown:Ie,children:[v("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-400 dark:text-gray-500"),children:[B?.icon?n("span",{className:"flex shrink-0 items-center",children:B.icon}):null,n("span",{className:"truncate",children:X&&B?B.label:ke})]}),v("span",{className:"flex items-center gap-1 shrink-0",children:[D?n("span",{className:"text-gray-400",children:$e}):null,Se?n("span",{role:"button",tabIndex:-1,"aria-label":be??S.selectClear,className:"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:Be}):null,n("span",{className:k("text-gray-400 transition-transform duration-200",c&&"rotate-180"),children:Ve})]})]}),C?n("p",{role:"alert",className:"text-xs text-red-500 dark:text-red-400",children:C}):ee?n("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,re?n("input",{type:"hidden",name:re,value:N??""}):null,c&&A?Pe(v("div",{ref:q,role:"listbox",id:se,"aria-labelledby":L?_: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[y].content,we),style:{top:A.top,left:A.left,width:A.width,position:"absolute"},onKeyDown:De,children:[d?n("div",{className:"border-b border-gray-200 dark:border-gray-700",children:n("input",{ref:ae,type:"text",role:"searchbox","aria-label":me??S.selectSearch,className:k(K[y].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-400 dark:placeholder:text-gray-500"),placeholder:he??S.selectSearchPlaceholder,value:Q,onChange:Ce})}):null,n("div",{className:"overflow-y-auto",style:{maxHeight:z},children:l.length===0?n("div",{className:k(K[y].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ye}):l.map((e,t)=>n(Ye,{option:e,isSelected:e.value===N,isHighlighted:t===r,isDisabled:D||w.has(e.value),sizeKey:y,optionId:`${M}-option-${t}`,onClick:I,onMouseEnter:p,index:t,ref:s=>{le.current[t]=s}},e.value))})]}),document.body):null]})}export{Fe as Select};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var i=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var i=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var I=(a,e)=>{for(var n in e)i(a,n,{get:e[n],enumerable:!0})},S=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of P(e))!z.call(a,t)&&t!==n&&i(a,t,{get:()=>e[t],enumerable:!(o=N(e,t))||o.enumerable});return a};var O=a=>S(i({},"__esModule",{value:!0}),a);var R={};I(R,{Tabs:()=>C});module.exports=O(R);var s=require("react"),m=require("../../lib/cn.cjs"),g=require("./TabsContext.cjs"),u=require("react/jsx-runtime");function C({children:a,defaultValue:e="",value:n,onValueChange:o,variant:t="underline",size:d="md",color:b="default",fullWidth:c=!1,orientation:r="horizontal",className:V}){let[y,h]=(0,s.useState)(e),p=(0,s.useId)(),l=n!==void 0,T=l?n:y,f=(0,s.useCallback)(v=>{l||h(v),o?.(v)},[l,o]),x=(0,s.useMemo)(()=>({value:T,onValueChange:f,variant:t,size:d,color:b,orientation:r,fullWidth:c,baseId:p}),[T,f,t,d,b,r,c,p]);return(0,u.jsx)(g.TabsContext.Provider,{value:x,children:(0,u.jsx)("div",{className:(0,m.cn)("w-full",r==="vertical"&&"flex gap-4",V),"data-orientation":r,children:a})})}C.displayName="Tabs";0&&(module.exports={Tabs});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as C,useCallback as V,useId as y,useMemo as h}from"react";import{cn as x}from"../../lib/cn.js";import{TabsContext as N}from"./TabsContext.js";import{jsx as c}from"react/jsx-runtime";function P({children:p,defaultValue:T="",value:t,onValueChange:s,variant:n="underline",size:o="md",color:r="default",fullWidth:l=!1,orientation:e="horizontal",className:f}){let[v,m]=C(T),i=y(),a=t!==void 0,u=a?t:v,d=V(b=>{a||m(b),s?.(b)},[a,s]),g=h(()=>({value:u,onValueChange:d,variant:n,size:o,color:r,orientation:e,fullWidth:l,baseId:i}),[u,d,n,o,r,e,l,i]);return c(N.Provider,{value:g,children:c("div",{className:x("w-full",e==="vertical"&&"flex gap-4",f),"data-orientation":e,children:p})})}P.displayName="Tabs";export{P as Tabs};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var r=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var m=(e,t)=>{for(var s in t)r(e,s,{get:t[s],enumerable:!0})},g=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of u(t))!p.call(e,n)&&n!==s&&r(e,n,{get:()=>t[n],enumerable:!(a=f(t,n))||a.enumerable});return e};var h=e=>g(r({},"__esModule",{value:!0}),e);var v={};m(v,{TabsContent:()=>c});module.exports=h(v);var d=require("../../lib/cn.cjs"),o=require("./TabsContext.cjs"),b=require("react/jsx-runtime");function c({value:e,children:t,className:s,forceMount:a=!1}){let{value:n,baseId:l}=(0,o.useTabsContext)(),i=n===e;return!i&&!a?null:(0,b.jsx)("div",{role:"tabpanel",id:(0,o.getTabsId)(l,"panel",e),"aria-labelledby":(0,o.getTabsId)(l,"tab",e),hidden:!i,tabIndex:0,className:(0,d.cn)("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 rounded-md",!i&&"hidden",s),children:t})}c.displayName="TabsContent";0&&(module.exports={TabsContent});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{cn as
|
|
1
|
+
"use client";import{cn as l}from"../../lib/cn.js";import{getTabsId as s,useTabsContext as d}from"./TabsContext.js";import{jsx as b}from"react/jsx-runtime";function c({value:e,children:o,className:a,forceMount:i=!1}){let{value:r,baseId:n}=d(),t=r===e;return!t&&!i?null:b("div",{role:"tabpanel",id:s(n,"panel",e),"aria-labelledby":s(n,"tab",e),hidden:!t,tabIndex:0,className:l("mt-4 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 rounded-md",!t&&"hidden",a),children:o})}c.displayName="TabsContent";export{c as TabsContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var n in e)s(t,n,{get:e[n],enumerable:!0})},c=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of b(e))!p.call(t,a)&&a!==n&&s(t,a,{get:()=>e[a],enumerable:!(r=l(e,a))||r.enumerable});return t};var T=t=>c(s({},"__esModule",{value:!0}),t);var f={};u(f,{TabsContext:()=>i,TabsListContext:()=>d,getTabsId:()=>x,useTabsContext:()=>g});module.exports=T(f);var o=require("react"),i=(0,o.createContext)(null);function x(t,e,n){let r=n.replace(/[^a-zA-Z0-9-]/g,a=>`_${a.charCodeAt(0).toString(16).padStart(4,"0")}`);return`${t}-${e}-${r}`}var d=(0,o.createContext)({fallbackTabStopId:null});function g(){let t=(0,o.useContext)(i);if(!t)throw new Error("Tabs components must be used within a Tabs provider");return t}0&&(module.exports={TabsContext,TabsListContext,getTabsId,useTabsContext});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as
|
|
1
|
+
"use client";import{createContext as e,useContext as s}from"react";var i=e(null);function b(t,a,n){let o=n.replace(/[^a-zA-Z0-9-]/g,r=>`_${r.charCodeAt(0).toString(16).padStart(4,"0")}`);return`${t}-${a}-${o}`}var p=e({fallbackTabStopId:null});function u(){let t=s(i);if(!t)throw new Error("Tabs components must be used within a Tabs provider");return t}export{i as TabsContext,p as TabsListContext,b as getTabsId,u as useTabsContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var n in e)m(r,n,{get:e[n],enumerable:!0})},P=(r,e,n,b)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D(e))!v.call(r,i)&&i!==n&&m(r,i,{get:()=>e[i],enumerable:!(b=S(e,i))||b.enumerable});return r};var I=r=>P(m({},"__esModule",{value:!0}),r);var F={};N(F,{TabsList:()=>x});module.exports=I(F);var a=require("react"),d=require("../../lib/cn.cjs"),u=require("./TabsContext.cjs"),p=require("react/jsx-runtime"),q={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function E(r){return Array.from(r.querySelectorAll('[role="tab"]')).filter(e=>e.closest('[role="tablist"]')===r&&!e.hasAttribute("disabled")&&e.getAttribute("aria-disabled")!=="true")}function x({children:r,className:e,bgColor:n,gap:b="none"}){let{variant:i,orientation:f,fullWidth:A}=(0,u.useTabsContext)(),T=(0,a.useRef)(null),[L,k]=(0,a.useState)(null);(0,a.useEffect)(()=>{let t=T.current;if(!t)return;let c=E(t),s=c.some(l=>l.getAttribute("aria-selected")==="true")?null:c[0]?.id??null;k(l=>l===s?l:s)});let w=(0,a.useMemo)(()=>({fallbackTabStopId:L}),[L]),K=t=>{if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let c=t.currentTarget,g=t.target.closest('[role="tab"]');if(!g||g.closest('[role="tablist"]')!==c)return;let s=E(c);if(s.length===0)return;let l=f==="vertical",h=!l&&getComputedStyle(c).direction==="rtl",C=l?"ArrowDown":h?"ArrowLeft":"ArrowRight",R=l?"ArrowUp":h?"ArrowRight":"ArrowLeft",y=s.indexOf(g),o;t.key===C?o=s[(y+1)%s.length]:t.key===R?o=s[y<=0?s.length-1:y-1]:t.key==="Home"?o=s[0]:t.key==="End"&&(o=s[s.length-1]),o&&(t.preventDefault(),o.focus(),o.getAttribute("aria-selected")!=="true"&&o.click())},H=(0,d.cn)("flex",f==="vertical"?"flex-col":"flex-row items-center",q[b]),M={underline:"border-b border-gray-200 dark:border-gray-700",pills:(0,d.cn)("p-1 rounded-lg",n||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:(0,d.cn)("p-1 rounded-lg",n||"bg-gray-100/50 dark:bg-gray-800/50")};return(0,p.jsx)(u.TabsListContext.Provider,{value:w,children:(0,p.jsx)("div",{ref:T,role:"tablist","aria-orientation":f,onKeyDown:K,className:(0,d.cn)(H,M[i],A&&"w-full",e),children:r})})}x.displayName="TabsList";0&&(module.exports={TabsList});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{cn as
|
|
1
|
+
"use client";import{useEffect as H,useMemo as M,useRef as C,useState as R}from"react";import{cn as i}from"../../lib/cn.js";import{TabsListContext as S,useTabsContext as D}from"./TabsContext.js";import{jsx as m}from"react/jsx-runtime";var v={none:"gap-0",sm:"gap-1",md:"gap-2",lg:"gap-4"};function y(a){return Array.from(a.querySelectorAll('[role="tab"]')).filter(o=>o.closest('[role="tablist"]')===a&&!o.hasAttribute("disabled")&&o.getAttribute("aria-disabled")!=="true")}function N({children:a,className:o,bgColor:b,gap:p="none"}){let{variant:T,orientation:c,fullWidth:L}=D(),g=C(null),[u,h]=R(null);H(()=>{let e=g.current;if(!e)return;let l=y(e),t=l.some(r=>r.getAttribute("aria-selected")==="true")?null:l[0]?.id??null;h(r=>r===t?r:t)});let E=M(()=>({fallbackTabStopId:u}),[u]),x=e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let l=e.currentTarget,n=e.target.closest('[role="tab"]');if(!n||n.closest('[role="tablist"]')!==l)return;let t=y(l);if(t.length===0)return;let r=c==="vertical",f=!r&&getComputedStyle(l).direction==="rtl",w=r?"ArrowDown":f?"ArrowLeft":"ArrowRight",K=r?"ArrowUp":f?"ArrowRight":"ArrowLeft",d=t.indexOf(n),s;e.key===w?s=t[(d+1)%t.length]:e.key===K?s=t[d<=0?t.length-1:d-1]:e.key==="Home"?s=t[0]:e.key==="End"&&(s=t[t.length-1]),s&&(e.preventDefault(),s.focus(),s.getAttribute("aria-selected")!=="true"&&s.click())},A=i("flex",c==="vertical"?"flex-col":"flex-row items-center",v[p]),k={underline:"border-b border-gray-200 dark:border-gray-700",pills:i("p-1 rounded-lg",b||"bg-gray-100 dark:bg-gray-800"),enclosed:"border-b border-gray-200 dark:border-gray-700",soft:i("p-1 rounded-lg",b||"bg-gray-100/50 dark:bg-gray-800/50")};return m(S.Provider,{value:E,children:m("div",{ref:g,role:"tablist","aria-orientation":c,onKeyDown:x,className:i(A,k[T],L&&"w-full",o),children:a})})}N.displayName="TabsList";export{N as TabsList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var s=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var P=(e,r)=>{for(var t in r)s(e,t,{get:r[t],enumerable:!0})},A=(e,r,t,l)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of B(r))!L.call(e,a)&&a!==t&&s(e,a,{get:()=>r[a],enumerable:!(l=D(r,a))||l.enumerable});return e};var H=e=>A(s({},"__esModule",{value:!0}),e);var W={};P(W,{TabsTrigger:()=>w});module.exports=H(W);var h=require("react"),d=require("../../lib/cn.cjs"),o=require("./TabsContext.cjs"),n=require("react/jsx-runtime"),M={sm:"px-3 py-1.5 text-xs gap-1.5",md:"px-4 py-2 text-sm gap-2",lg:"px-5 py-2.5 text-base gap-2"},k={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},u={default:{underline:{active:"text-gray-900 dark:text-white border-gray-900 dark:border-white",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300"},pills:{active:"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"},enclosed:{active:"bg-white dark:bg-gray-800 text-gray-900 dark:text-white border-gray-200 dark:border-gray-700 border-b-white dark:border-b-gray-800",inactive:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 border-transparent"},soft:{active:"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-700/50"}},primary:{underline:{active:"text-blue-600 dark:text-blue-400 border-blue-600 dark:border-blue-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-blue-600 dark:hover:text-blue-400"},pills:{active:"bg-blue-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400"},enclosed:{active:"bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400 border-blue-200 dark:border-blue-800 border-b-blue-50 dark:border-b-blue-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 border-transparent"},soft:{active:"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20"}},secondary:{underline:{active:"text-purple-600 dark:text-purple-400 border-purple-600 dark:border-purple-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-purple-600 dark:hover:text-purple-400"},pills:{active:"bg-purple-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400"},enclosed:{active:"bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400 border-purple-200 dark:border-purple-800 border-b-purple-50 dark:border-b-purple-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 border-transparent"},soft:{active:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/20"}},success:{underline:{active:"text-green-600 dark:text-green-400 border-green-600 dark:border-green-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-green-600 dark:hover:text-green-400"},pills:{active:"bg-green-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400"},enclosed:{active:"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800 border-b-green-50 dark:border-b-green-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 border-transparent"},soft:{active:"bg-green-100 dark:bg-green-900/50 text-green-700 dark:text-green-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-green-600 dark:hover:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"}},warning:{underline:{active:"text-yellow-600 dark:text-yellow-400 border-yellow-600 dark:border-yellow-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-yellow-600 dark:hover:text-yellow-400"},pills:{active:"bg-yellow-500 text-gray-900",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400"},enclosed:{active:"bg-yellow-50 dark:bg-yellow-900/20 text-yellow-600 dark:text-yellow-400 border-yellow-200 dark:border-yellow-800 border-b-yellow-50 dark:border-b-yellow-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 border-transparent"},soft:{active:"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-yellow-600 dark:hover:text-yellow-400 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"}},error:{underline:{active:"text-red-600 dark:text-red-400 border-red-600 dark:border-red-400",inactive:"text-gray-500 dark:text-gray-400 border-transparent hover:text-red-600 dark:hover:text-red-400"},pills:{active:"bg-red-600 text-white",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400"},enclosed:{active:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 border-b-red-50 dark:border-b-red-900/20",inactive:"text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 border-transparent"},soft:{active:"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300",inactive:"text-gray-600 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20"}}},O={underline:"border-b-2 -mb-px",pills:"rounded-md",enclosed:"border border-b-0 rounded-t-md -mb-px",soft:"rounded-md"};function w({value:e,children:r,disabled:t=!1,icon:l,endIcon:a,className:f,activeClassName:m,inactiveClassName:T}){let{value:C,onValueChange:N,variant:b,size:g,color:v,fullWidth:R,baseId:y}=(0,o.useTabsContext)(),{fallbackTabStopId:S}=(0,h.useContext)(o.TabsListContext),i=C===e,c=(0,o.getTabsId)(y,"tab",e),z=!t&&(i||S===c),p=()=>{t||N(e)},I=x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),p())},E=(0,d.cn)("inline-flex items-center justify-center font-medium transition-all duration-200","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500",M[g],R&&"flex-1"),K=i?(0,d.cn)(u[v][b].active,m):(0,d.cn)(u[v][b].inactive,T),V=t?"opacity-50 cursor-not-allowed":"cursor-pointer";return(0,n.jsxs)("button",{type:"button",role:"tab",id:c,"aria-selected":i,"aria-controls":i?(0,o.getTabsId)(y,"panel",e):void 0,"aria-disabled":t,tabIndex:z?0:-1,onClick:p,onKeyDown:I,disabled:t,className:(0,d.cn)(E,O[b],K,V,f),children:[l&&(0,n.jsx)("span",{className:(0,d.cn)("shrink-0",k[g]),children:l}),(0,n.jsx)("span",{children:r}),a&&(0,n.jsx)("span",{className:(0,d.cn)("shrink-0",k[g]),children:a})]})}w.displayName="TabsTrigger";0&&(module.exports={TabsTrigger});
|