@synertech/ui 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/use-synertech-ui/SKILL.md +249 -15
- package/dist/components/checkbox/Checkbox.cjs +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox/CheckboxGroup.cjs +1 -1
- package/dist/components/checkbox/CheckboxGroup.js +1 -1
- package/dist/components/date-picker/DatePicker.cjs +1 -0
- package/dist/components/date-picker/DatePicker.js +1 -0
- package/dist/components/date-picker/DateRangePicker.cjs +1 -0
- package/dist/components/date-picker/DateRangePicker.js +1 -0
- package/dist/components/date-picker/date-field.cjs +1 -0
- package/dist/components/date-picker/date-field.js +1 -0
- package/dist/components/date-picker/date-input.cjs +1 -0
- package/dist/components/date-picker/date-input.js +1 -0
- package/dist/components/date-picker/index.cjs +1 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/form/form-field/FormField.cjs +1 -0
- package/dist/components/form/form-field/FormField.js +1 -0
- package/dist/components/form/form-field/index.cjs +1 -0
- package/dist/components/form/form-field/index.js +1 -0
- package/dist/components/form/index.cjs +1 -1
- package/dist/components/form/index.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 +5 -5
- package/dist/components/form/mention-input/MentionInput.js +5 -5
- package/dist/components/form/number-input/NumberInput.cjs +1 -1
- package/dist/components/form/number-input/NumberInput.js +1 -1
- package/dist/components/form/shared/InputWrapper.cjs +1 -1
- package/dist/components/form/shared/InputWrapper.js +1 -1
- package/dist/components/form/shared/field-error.cjs +1 -0
- package/dist/components/form/shared/field-error.js +1 -0
- package/dist/components/form/shared/inputStyles.cjs +1 -1
- package/dist/components/form/shared/inputStyles.js +1 -1
- package/dist/components/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/help-button/HelpButton.cjs +4 -12
- package/dist/components/help-button/HelpButton.js +4 -12
- package/dist/components/help-button/MarkdownEditor.cjs +1 -1
- package/dist/components/help-button/MarkdownEditor.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/popover/Popover.cjs +1 -0
- package/dist/components/popover/Popover.js +1 -0
- package/dist/components/popover/PopoverClose.cjs +1 -0
- package/dist/components/popover/PopoverClose.js +1 -0
- package/dist/components/popover/PopoverContent.cjs +1 -0
- package/dist/components/popover/PopoverContent.js +1 -0
- package/dist/components/popover/PopoverTrigger.cjs +1 -0
- package/dist/components/popover/PopoverTrigger.js +1 -0
- package/dist/components/popover/index.cjs +1 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.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/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/switch/Switch.cjs +1 -0
- package/dist/components/switch/Switch.js +1 -0
- package/dist/components/switch/index.cjs +1 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/toast/Toaster.cjs +1 -0
- package/dist/components/toast/Toaster.js +1 -0
- package/dist/components/toast/index.cjs +1 -1
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast-store.cjs +1 -0
- package/dist/components/toast/toast-store.js +1 -0
- package/dist/components/tooltip/Tooltip.cjs +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/index.d.cts +3041 -2348
- package/dist/index.d.ts +3041 -2348
- package/dist/lib/layer-document.cjs +1 -1
- package/dist/lib/layer-document.js +1 -1
- package/dist/lib/ui-labels.cjs +1 -1
- package/dist/lib/ui-labels.js +1 -1
- package/dist/styles-no-preflight.css +557 -13
- package/dist/styles.css +557 -13
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{memo as z,useCallback as p,useRef as J,useState as D}from"react";import{cn as c}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as Q,DEFAULT_TABLE_WIDTH as Z,FIELD_ROW_HEIGHT as P,getTableHeight as $,hasNotesRow as ee,HEADER_HEIGHT as te,NOTES_ROW_HEIGHT as H}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as re}from"../utils/schema-helpers.js";import{formatUILabel as M}from"../../../lib/ui-labels.js";import{jsx as t,jsxs as d}from"react/jsx-runtime";var E=()=>d("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),_=()=>d("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),t("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),oe=({collapsed:I})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:I?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),K=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),B=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ae=()=>t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M4 8h8"})}),ne=()=>d("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"5",cy:"4",r:"1.5"}),t("circle",{cx:"11",cy:"4",r:"1.5"}),t("circle",{cx:"5",cy:"8",r:"1.5"}),t("circle",{cx:"11",cy:"8",r:"1.5"}),t("circle",{cx:"5",cy:"12",r:"1.5"}),t("circle",{cx:"11",cy:"12",r:"1.5"})]}),ie=z(function({field:r,tableId:T,editable:y,readOnly:x,disabled:b,onFieldChange:h,labels:u}){let[v,m]=D(!1),[k,i]=D(r.defaultValue??""),f=y&&!x&&!b,w=()=>{m(!1),h?.(T,r.id,{defaultValue:k||void 0})};return f?v?t("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 outline-none focus:ring-0 p-0 flex-shrink-0","aria-label":M(u.schemaEditorDefaultValueFor,{field:r.name}),value:k,onChange:s=>i(s.target.value),onBlur:w,onKeyDown:s=>{s.key==="Enter"&&w(),s.key==="Escape"&&m(!1)},onPointerDown:s=>s.stopPropagation(),autoFocus:!0}):r.defaultValue?d("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:s=>{s.stopPropagation(),i(r.defaultValue??""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:M(u.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:s=>{s.stopPropagation(),i(""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:u.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?d("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:M(u.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),ue=z(function({table:r,selected:T,disabled:y,readOnly:x,editable:b,dropTarget:h,fieldTypes:u,onTableNameChange:v,onTableNotesChange:m,onToggleCollapse:k,onFieldChange:i,onFieldAdd:f,onFieldRemove:w,onFieldReorder:s,onResizeStart:W,labels:n}){let R=r.width??Z,C=r.collapsed??!1,l=b&&!x&&!y,V=u.length>0?u:re,[U,L]=D(null),[F,N]=D(null),g=J(null),A=p(e=>{v?.(r.id,e.target.value)},[r.id,v]),q=p((e,a)=>{i?.(r.id,e,{name:a})},[r.id,i]),j=p((e,a)=>{i?.(r.id,e,{type:a})},[r.id,i]),S=p((e,a)=>{i?.(r.id,e,{primaryKey:!a})},[r.id,i]),O=p((e,a)=>{i?.(r.id,e,{nullable:!a})},[r.id,i]),G=p((e,a)=>{i?.(r.id,e,{indexed:!a})},[r.id,i]),Y=p((e,a)=>{i?.(r.id,e,{unique:!a})},[r.id,i]),X=p(()=>{f?.(r.id)},[r.id,f]);return d("div",{"data-table-id":r.id,className:c("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,h?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":T?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:R,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[d("div",{className:c("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:te},children:[l?t("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:A,onPointerDown:e=>e.stopPropagation()}):t("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),t("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:e=>{e.stopPropagation(),k?.(r.id)},onPointerDown:e=>e.stopPropagation(),"aria-label":C?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:t(oe,{collapsed:C})})]}),ee(r,l)&&(l?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:e=>m?.(r.id,e.target.value),onPointerDown:e=>e.stopPropagation()})}):t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!C&&d("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((e,a)=>d("div",{"data-field-id":e.id,"data-table-id":r.id,className:c("flex items-center gap-1.5 pr-2 relative group",l?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",h?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",U===a&&"opacity-40",F===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:P},draggable:l,onDragStart:o=>{l&&(o.stopPropagation(),g.current=a,L(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{g.current!==null&&(o.preventDefault(),o.stopPropagation(),N(a))},onDragLeave:()=>{F===a&&N(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),g.current!==null&&g.current!==a&&s?.(r.id,g.current,a),g.current=null,L(null),N(null)},onDragEnd:()=>{g.current=null,L(null),N(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:P/2-5}}),l&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:P/2-6},children:t(ne,{})}),l?t("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),O(e.id,e.nullable??!1)},onPointerDown:o=>o.stopPropagation(),title:e.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):t("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?d("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}),t(_,{})]}):e.primaryKey?l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}):e.foreignKey?t(_,{}):l?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!1)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:d("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):t("span",{className:"w-3.5 flex-shrink-0"}),l?t("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none outline-none focus:ring-0 p-0 truncate cursor-text",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:e.name,onChange:o=>q(e.id,o.target.value),onPointerDown:o=>o.stopPropagation()}):t("span",{className:c("flex-1 min-w-0 text-xs truncate",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:e.name}),l?d("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none outline-none focus:ring-0 p-0 cursor-pointer text-right",value:e.type,onChange:o=>j(e.id,o.target.value),onPointerDown:o=>o.stopPropagation(),children:[V.map(o=>t("option",{value:o,children:o},o)),!V.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:e.type}),t(ie,{field:e,tableId:r.id,editable:b,readOnly:x,disabled:y,onFieldChange:i,labels:n}),e.indexed&&t(K,{}),e.unique&&t(B,{}),l&&d("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),G(e.id,e.indexed??!1)},onPointerDown:o=>o.stopPropagation(),title:e.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:t(K,{})}),t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),Y(e.id,e.unique??!1)},onPointerDown:o=>o.stopPropagation(),title:e.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:t(B,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),w?.(r.id,e.id)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:t(ae,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:P/2-5}})]},e.id)),l&&d("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:Q},onClick:e=>{e.stopPropagation(),X()},onPointerDown:e=>e.stopPropagation(),children:[t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!y&&!x&&t("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onPointerDown:e=>{if(e.stopPropagation(),e.button!==0)return;e.preventDefault();let a=r.height??$(r,l);W?.(r.id,e.clientX,e.clientY,R,a,e.pointerId)},children:d("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[t("path",{d:"M12 2v10H2",opacity:"0"}),t("path",{d:"M6 12L12 6"}),t("path",{d:"M10 12L12 10"})]})})]})});export{ue as SchemaTableRenderer};
|
|
1
|
+
import{memo as z,useCallback as u,useRef as J,useState as D}from"react";import{cn as c}from"../../../lib/cn.js";import{ADD_BUTTON_HEIGHT as Q,DEFAULT_TABLE_WIDTH as Z,FIELD_ROW_HEIGHT as P,getTableHeight as $,hasNotesRow as ee,HEADER_HEIGHT as te,NOTES_ROW_HEIGHT as H}from"../utils/geometry.js";import{DEFAULT_FIELD_TYPES as re}from"../utils/schema-helpers.js";import{formatUILabel as M}from"../../../lib/ui-labels.js";import{jsx as t,jsxs as d}from"react/jsx-runtime";var E=()=>d("svg",{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]}),_=()=>d("svg",{className:"w-3.5 h-3.5 flex-shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"8",cy:"8",r:"6",className:"fill-blue-500"}),t("path",{d:"M5 8h6M8 5l3 3-3 3",stroke:"white",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]}),oe=({collapsed:I})=>t("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"currentColor",children:I?t("path",{d:"M6 3l5 5-5 5V3z"}):t("path",{d:"M3 6l5 5 5-5H3z"})}),K=()=>t("svg",{className:"w-3.5 h-3.5 text-amber-700 dark:text-amber-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M3 2v12M7 4h6M7 8h4M7 12h5"})}),B=()=>t("svg",{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400 flex-shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t("path",{d:"M4 2v8a4 4 0 008 0V2"})}),ae=()=>t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M4 8h8"})}),ne=()=>d("svg",{className:"w-3 h-3 text-gray-500 dark:text-gray-400",viewBox:"0 0 16 16",fill:"currentColor",children:[t("circle",{cx:"5",cy:"4",r:"1.5"}),t("circle",{cx:"11",cy:"4",r:"1.5"}),t("circle",{cx:"5",cy:"8",r:"1.5"}),t("circle",{cx:"11",cy:"8",r:"1.5"}),t("circle",{cx:"5",cy:"12",r:"1.5"}),t("circle",{cx:"11",cy:"12",r:"1.5"})]}),ie=z(function({field:r,tableId:T,editable:y,readOnly:x,disabled:b,onFieldChange:h,labels:p}){let[v,m]=D(!1),[f,i]=D(r.defaultValue??""),k=y&&!x&&!b,w=()=>{m(!1),h?.(T,r.id,{defaultValue:f||void 0})};return k?v?t("input",{className:"text-xs w-16 text-emerald-700 dark:text-emerald-400 bg-transparent border-b border-emerald-300 rounded-sm outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-synertech-primary-500 p-0 flex-shrink-0","aria-label":M(p.schemaEditorDefaultValueFor,{field:r.name}),value:f,onChange:s=>i(s.target.value),onBlur:w,onKeyDown:s=>{s.key==="Enter"&&w(),s.key==="Escape"&&m(!1)},onPointerDown:s=>s.stopPropagation(),autoFocus:!0}):r.defaultValue?d("button",{type:"button",className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16 cursor-pointer",onClick:s=>{s.stopPropagation(),i(r.defaultValue??""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:M(p.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):t("button",{type:"button",className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0 opacity-0 group-hover:opacity-30 hover:!opacity-100 cursor-pointer transition-opacity",onClick:s=>{s.stopPropagation(),i(""),m(!0)},onPointerDown:s=>s.stopPropagation(),title:p.schemaEditorSetDefaultValue,children:"= \u2205"}):r.defaultValue?d("span",{className:"text-xs text-emerald-700 dark:text-emerald-400 flex-shrink-0 truncate max-w-16",title:M(p.schemaEditorDefaultValue,{value:r.defaultValue}),children:["= ",r.defaultValue]}):null}),pe=z(function({table:r,selected:T,disabled:y,readOnly:x,editable:b,dropTarget:h,fieldTypes:p,onTableNameChange:v,onTableNotesChange:m,onToggleCollapse:f,onFieldChange:i,onFieldAdd:k,onFieldRemove:w,onFieldReorder:s,onResizeStart:W,labels:n}){let R=r.width??Z,C=r.collapsed??!1,l=b&&!x&&!y,V=p.length>0?p:re,[U,L]=D(null),[F,N]=D(null),g=J(null),A=u(e=>{v?.(r.id,e.target.value)},[r.id,v]),q=u((e,a)=>{i?.(r.id,e,{name:a})},[r.id,i]),j=u((e,a)=>{i?.(r.id,e,{type:a})},[r.id,i]),S=u((e,a)=>{i?.(r.id,e,{primaryKey:!a})},[r.id,i]),O=u((e,a)=>{i?.(r.id,e,{nullable:!a})},[r.id,i]),G=u((e,a)=>{i?.(r.id,e,{indexed:!a})},[r.id,i]),Y=u((e,a)=>{i?.(r.id,e,{unique:!a})},[r.id,i]),X=u(()=>{k?.(r.id)},[r.id,k]);return d("div",{"data-table-id":r.id,className:c("absolute bg-white dark:bg-gray-800 border-2 border-dashed rounded-lg shadow-sm cursor-grab active:cursor-grabbing",r.height?"flex flex-col":void 0,h?"border-green-400 shadow-green-100 dark:shadow-green-900/30 shadow-md":T?"border-synertech-primary-500 shadow-synertech-primary-100 dark:shadow-synertech-primary-900/30":"border-gray-300 dark:border-gray-600",r.locked&&"!cursor-default"),style:{left:r.x,top:r.y,width:R,height:r.height,userSelect:"none",overflow:r.height?"hidden":void 0},children:[d("div",{className:c("flex items-center justify-between px-3 gap-2","bg-gray-50 dark:bg-gray-700 border-b border-gray-200 dark:border-gray-600"),style:{height:te},children:[l?t("input",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 bg-transparent border-none rounded-sm outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-synertech-primary-500 p-0 truncate cursor-text","aria-label":n.schemaEditorTableName,value:r.name,onChange:A,onPointerDown:e=>e.stopPropagation()}):t("span",{className:"flex-1 min-w-0 text-sm font-semibold text-gray-800 dark:text-gray-100 truncate",children:r.name}),t("button",{type:"button",className:"flex-shrink-0 p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-500 dark:text-gray-400",onClick:e=>{e.stopPropagation(),f?.(r.id)},onPointerDown:e=>e.stopPropagation(),"aria-label":C?n.schemaEditorExpandTable:n.schemaEditorCollapseTable,children:t(oe,{collapsed:C})})]}),ee(r,l)&&(l?t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("input",{className:"w-full text-xs italic text-gray-500 dark:text-gray-400 bg-transparent border-none rounded-sm outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-synertech-primary-500 p-0 placeholder-gray-500 dark:placeholder-gray-400","aria-label":n.schemaEditorTableNotes,placeholder:n.schemaEditorNotesPlaceholder,value:r.notes??"",onChange:e=>m?.(r.id,e.target.value),onPointerDown:e=>e.stopPropagation()})}):t("div",{className:"px-3 border-b border-gray-100 dark:border-gray-700 flex items-center",style:{height:H},children:t("span",{className:"text-xs italic text-gray-500 dark:text-gray-400 truncate",children:r.notes})})),!C&&d("div",{className:r.height?"overflow-y-auto flex-1 min-h-0":void 0,children:[r.fields.map((e,a)=>d("div",{"data-field-id":e.id,"data-table-id":r.id,className:c("flex items-center gap-1.5 pr-2 relative group",l?"pl-[18px]":"pl-2","border-b border-gray-100 dark:border-gray-700 last:border-b-0",h?"bg-synertech-primary-50/50 dark:bg-synertech-primary-900/10":"hover:bg-gray-50 dark:hover:bg-gray-700/50",U===a&&"opacity-40",F===a&&"!border-t-2 !border-t-synertech-primary-400"),style:{height:P},draggable:l,onDragStart:o=>{l&&(o.stopPropagation(),g.current=a,L(a),o.dataTransfer.effectAllowed="move",o.dataTransfer.setData("text/plain",String(a)))},onDragOver:o=>{g.current!==null&&(o.preventDefault(),o.stopPropagation(),N(a))},onDragLeave:()=>{F===a&&N(null)},onDrop:o=>{o.preventDefault(),o.stopPropagation(),g.current!==null&&g.current!==a&&s?.(r.id,g.current,a),g.current=null,L(null),N(null)},onDragEnd:()=>{g.current=null,L(null),N(null)},children:[t("div",{"data-connection-side":"left","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -left-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-synertech-primary-400"),style:{top:P/2-5}}),l&&t("span",{className:"absolute left-[3px] cursor-grab active:cursor-grabbing opacity-0 group-hover:opacity-100 transition-opacity z-10",style:{top:P/2-6},children:t(ne,{})}),l?t("button",{type:"button",className:c("w-4 text-xs font-bold flex-shrink-0 text-center cursor-pointer",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),onClick:o=>{o.stopPropagation(),O(e.id,e.nullable??!1)},onPointerDown:o=>o.stopPropagation(),title:e.nullable?n.schemaEditorNullable:n.schemaEditorNotNullable,children:"?"}):t("span",{className:c("w-4 text-xs font-bold flex-shrink-0 text-center",e.nullable?"text-gray-500 dark:text-gray-400":"text-transparent"),children:e.nullable?"?":""}),e.primaryKey&&e.foreignKey?d("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}),t(_,{})]}):e.primaryKey?l?t("button",{type:"button",className:"flex-shrink-0 cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!0)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemovePrimaryKey,children:t(E,{})}):t(E,{}):e.foreignKey?t(_,{}):l?t("button",{type:"button",className:"w-3.5 h-3.5 flex-shrink-0 rounded text-gray-500 dark:text-gray-400 hover:text-indigo-400 transition-colors cursor-pointer",onClick:o=>{o.stopPropagation(),S(e.id,!1)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorSetPrimaryKey,"aria-label":n.schemaEditorSetPrimaryKey,children:d("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",opacity:"0.3",children:[t("path",{d:"M10 1l2 2-5 5M8.5 4.5L11 7"}),t("circle",{cx:"4.5",cy:"11.5",r:"3"})]})}):t("span",{className:"w-3.5 flex-shrink-0"}),l?t("input",{className:c("flex-1 min-w-0 text-xs bg-transparent border-none rounded-sm outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-synertech-primary-500 p-0 truncate cursor-text",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),"aria-label":n.schemaEditorFieldName,value:e.name,onChange:o=>q(e.id,o.target.value),onPointerDown:o=>o.stopPropagation()}):t("span",{className:c("flex-1 min-w-0 text-xs truncate",e.primaryKey?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"),children:e.name}),l?d("select",{className:"text-xs text-gray-500 dark:text-gray-400 bg-transparent border-none rounded-sm outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-synertech-primary-500 p-0 cursor-pointer text-right",value:e.type,onChange:o=>j(e.id,o.target.value),onPointerDown:o=>o.stopPropagation(),children:[V.map(o=>t("option",{value:o,children:o},o)),!V.includes(e.type)&&t("option",{value:e.type,children:e.type})]}):t("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:e.type}),t(ie,{field:e,tableId:r.id,editable:b,readOnly:x,disabled:y,onFieldChange:i,labels:n}),e.indexed&&t(K,{}),e.unique&&t(B,{}),l&&d("div",{className:"absolute right-1 top-0 bottom-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity bg-gradient-to-l from-white via-white to-transparent dark:from-gray-800 dark:via-gray-800 pl-4 pr-1 z-10",children:[t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.indexed?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),G(e.id,e.indexed??!1)},onPointerDown:o=>o.stopPropagation(),title:e.indexed?n.schemaEditorRemoveIndex:n.schemaEditorAddIndex,children:t(K,{})}),t("button",{type:"button",className:c("cursor-pointer transition-opacity",e.unique?"opacity-100":"opacity-30 hover:opacity-100"),onClick:o=>{o.stopPropagation(),Y(e.id,e.unique??!1)},onPointerDown:o=>o.stopPropagation(),title:e.unique?n.schemaEditorRemoveUnique:n.schemaEditorAddUnique,children:t(B,{})}),t("button",{type:"button",className:"p-0.5 rounded text-gray-500 dark:text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 cursor-pointer",onClick:o=>{o.stopPropagation(),w?.(r.id,e.id)},onPointerDown:o=>o.stopPropagation(),title:n.schemaEditorRemoveField,children:t(ae,{})})]}),t("div",{"data-connection-side":"right","data-field-id":e.id,"data-table-id":r.id,className:c("absolute -right-[5px] w-2.5 h-2.5 rounded-full border-2 border-white dark:border-gray-800 cursor-crosshair z-10 transition-all",h?"opacity-100 bg-green-400 scale-150 shadow-[0_0_6px_rgba(74,222,128,0.6)]":"opacity-0 group-hover:opacity-100 bg-green-400"),style:{top:P/2-5}})]},e.id)),l&&d("button",{type:"button",className:"flex items-center justify-center w-full gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-synertech-primary-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors cursor-pointer",style:{height:Q},onClick:e=>{e.stopPropagation(),X()},onPointerDown:e=>e.stopPropagation(),children:[t("svg",{className:"w-3 h-3",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:t("path",{d:"M8 4v8M4 8h8"})}),n.schemaEditorAddField]})]}),!y&&!x&&t("div",{"data-resize-handle":"corner",className:"absolute -bottom-[5px] -right-[5px] w-[14px] h-[14px] cursor-nwse-resize z-20 group/resize",onPointerDown:e=>{if(e.stopPropagation(),e.button!==0)return;e.preventDefault();let a=r.height??$(r,l);W?.(r.id,e.clientX,e.clientY,R,a,e.pointerId)},children:d("svg",{className:"w-full h-full text-gray-500 dark:text-gray-400 group-hover/resize:text-synertech-primary-400 transition-colors",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[t("path",{d:"M12 2v10H2",opacity:"0"}),t("path",{d:"M6 12L12 6"}),t("path",{d:"M10 12L12 10"})]})})]})});export{pe as SchemaTableRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var F=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Re=(a,o)=>{for(var c in o)F(a,c,{get:o[c],enumerable:!0})},He=(a,o,c,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Ae(o))!Pe.call(a,i)&&i!==c&&F(a,i,{get:()=>o[i],enumerable:!(l=Te(o,i))||l.enumerable});return a};var Ke=a=>He(F({},"__esModule",{value:!0}),a);var _e={};Re(_e,{Select:()=>ze});module.exports=Ke(_e);var n=require("react"),ue=require("react-dom"),de=require("../../lib/aria-hide.cjs"),H=require("../../lib/owner-document.cjs"),pe=require("../../lib/i18n.cjs"),r=require("react/jsx-runtime"),Q=()=>{},Ve=[],Be=(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),$e=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),We=(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,r.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,r.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Ue=(0,r.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),R={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},ce={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function k(...a){let o="";for(let c=0;c<a.length;c++){let l=a[c];l&&(o&&(o+=" "),o+=l)}return o}function Ye(a,o){if(!o)return a;let c=o.toLowerCase();return a.filter(l=>{if(l.label.toLowerCase().includes(c)||l.value.toLowerCase().includes(c))return!0;if(l.keywords){for(let i of l.keywords)if(i.toLowerCase().includes(c))return!0}return!1})}var je=(0,n.memo)((0,n.forwardRef)(function({option:o,isSelected:c,isHighlighted:l,isDisabled:i,sizeKey:$,optionId:m,onClick:y,onMouseEnter:w,index:E},K){let W=()=>{i||y(o.value)},N=()=>{i||w(E)};return(0,r.jsxs)("div",{ref:K,id:m,role:"option","aria-selected":c,"aria-disabled":i||void 0,"data-highlighted":l||void 0,className:k(R[$].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",l&&!i&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",c&&!l&&"bg-gray-50 dark:bg-gray-700/50",i&&"opacity-50 cursor-not-allowed"),onClick:W,onMouseEnter:N,children:[o.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:o.icon}):null,(0,r.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"truncate",children:o.label}),o.description?(0,r.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),c?(0,r.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Ue}):null]})}));function ze({options:a=Ve,value:o,defaultValue:c,onValueChange:l,searchable:i=!1,clearable:$=!1,disabled:m=!1,readOnly:y=!1,loading:w=!1,size:E="md",variant:K="default",placeholder:W,label:N,description:X,helperText:Z,error:C,required:G=!1,noOptionsText:fe,clearLabel:ge,searchLabel:me,searchPlaceholder:he,onSearchChange:J,name:ee,className:be,triggerClassName:ye,contentClassName:xe,maxHeight:U=256}){let S=(0,pe.useUILabels)(),ve=W??S.selectPlaceholder,ke=fe??S.selectNoOptions,M=(0,n.useId)(),Y=`${M}-label`,te=`${M}-trigger`,re=`${M}-listbox`,h=(0,n.useRef)(null),j=(0,n.useRef)(null),ne=(0,n.useRef)(null),oe=(0,n.useRef)([]),O=o!==void 0,[we,ae]=(0,n.useState)(c??""),I=O?o:we,[d,z]=(0,n.useState)(!1),[_,T]=(0,n.useState)(""),[s,f]=(0,n.useState)(-1),[L,se]=(0,n.useState)(null),u=(0,n.useMemo)(()=>i?Ye(a,_):a,[a,_,i]),V=(0,n.useMemo)(()=>a.find(e=>e.value===I)??null,[a,I]),v=(0,n.useMemo)(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),D=(0,n.useCallback)(e=>{w||(O||ae(e),(l??Q)(e),z(!1),T(""),f(-1),h.current?.focus())},[O,l,w]),Ee=(0,n.useCallback)(e=>{e.stopPropagation(),O||ae(""),(l??Q)(""),T(""),h.current?.focus()},[O,l]),A=(0,n.useCallback)(()=>{m||y||(z(!0),T(""),f(-1))},[m,y]),b=(0,n.useCallback)(()=>{z(!1),T(""),f(-1),h.current?.focus()},[]),Le=(0,n.useCallback)(()=>{d?b():A()},[d,b,A]),x=(0,n.useCallback)((e,t)=>{let g=u.length;if(g===0)return-1;let p=e;for(let P=0;P<g;P++)if(p=((p+t)%g+g)%g,!v.has(u[p].value))return p;return-1},[u,v]),Ne=(0,n.useCallback)(e=>{if(!(m||y)){if(d){switch(e.key){case"ArrowDown":{e.preventDefault();let t=x(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=x(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=x(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=x(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}break}case" ":if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}else b();break;case"Escape":e.preventDefault(),b();break;case"Tab":b();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break}}},[m,y,d,A,b,s,u,v,x,D]),Ie=(0,n.useCallback)(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=x(s,1);t!==-1&&f(t);break}case"ArrowUp":{e.preventDefault();let t=x(s,-1);t!==-1&&f(t);break}case"Home":{e.preventDefault();let t=x(-1,1);t!==-1&&f(t);break}case"End":{e.preventDefault();let t=x(u.length,-1);t!==-1&&f(t);break}case"Enter":{if(e.preventDefault(),s>=0&&s<u.length){let t=u[s];v.has(t.value)||D(t.value)}break}case"Escape":e.preventDefault(),b();break;case"Tab":b();break}},[s,u,v,x,D,b]),De=(0,n.useCallback)(e=>{let t=e.target.value;T(t),f(-1),(J??Q)(t)},[J]);(0,n.useEffect)(()=>{if(!d)return;let e=g=>{let p=g.target;h.current?.contains(p)||j.current?.contains(p)||b()},t=(0,H.ownerDocumentOf)(h.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[d,b]),(0,n.useEffect)(()=>{if(!d||!h.current){se(null);return}let e=(0,H.ownerWindowOf)(h.current),t=()=>{let g=h.current;if(!g)return;let p=g.getBoundingClientRect(),P=e.innerHeight-p.bottom,Me=p.top,Oe=U+8,ie=P<Oe&&Me>P?"top":"bottom";se({top:ie==="bottom"?p.bottom+e.scrollY+4:p.top+e.scrollY-4,left:p.left+e.scrollX,width:p.width,placement:ie})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[d,U]);let B=d&&L!==null;(0,n.useEffect)(()=>{B&&i&&ne.current?.focus()},[B,i]),(0,n.useEffect)(()=>{let e=j.current;if(!(!B||!e))return(0,de.registerFloatingLayer)(e,()=>h.current)},[B]),(0,n.useEffect)(()=>{if(s>=0){let e=oe.current[s];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[s]);let q=I!==""&&I!==void 0,Ce=$&&q&&!m&&!y&&!w,le=!m&&!y,Se=k("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",R[E].trigger,ce[K].trigger,!C&&le&&ce[K].focus,C&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",m&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",y&&"cursor-default",!m&&!y&&"cursor-pointer",ye);return(0,r.jsxs)("div",{className:k("flex flex-col gap-1",be),children:[N?(0,r.jsxs)("label",{id:Y,htmlFor:te,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[N,G?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,X?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:X}):null,(0,r.jsxs)("button",{ref:h,id:te,type:"button",role:"combobox","aria-expanded":d,"aria-haspopup":"listbox","aria-controls":d?re:void 0,"aria-labelledby":N?Y:void 0,"aria-required":G||void 0,"aria-invalid":C?!0:void 0,"aria-activedescendant":d&&s>=0?`${M}-option-${s}`:void 0,disabled:m,className:Se,onClick:le?Le:void 0,onKeyDown:Ne,children:[(0,r.jsxs)("span",{className:k("flex items-center gap-2 min-w-0 flex-1 truncate",!q&&"text-gray-600 dark:text-gray-300"),children:[V?.icon?(0,r.jsx)("span",{className:"flex shrink-0 items-center",children:V.icon}):null,(0,r.jsx)("span",{className:"truncate",children:q&&V?V.label:ve})]}),(0,r.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[w?(0,r.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:We}):null,Ce?(0,r.jsx)("span",{role:"button",tabIndex:-1,"aria-label":ge??S.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ee,onMouseDown:e=>e.preventDefault(),children:$e}):null,(0,r.jsx)("span",{className:k("text-gray-500 dark:text-gray-400 transition-transform duration-200",d&&"rotate-180"),children:Be})]})]}),C?(0,r.jsx)("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:C}):Z?(0,r.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z}):null,ee?(0,r.jsx)("input",{type:"hidden",name:ee,value:I??""}):null,d&&L?(0,ue.createPortal)((0,r.jsxs)("div",{ref:j,role:"listbox",id:re,"aria-labelledby":N?Y:void 0,className:k("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",R[E].content,xe),"data-placement":L.placement,style:{top:L.top,left:L.left,width:L.width,position:"absolute",translate:L.placement==="top"?"0 -100%":void 0},onKeyDown:Ie,children:[i?(0,r.jsx)("div",{className:"border-b border-gray-200 dark:border-gray-700",children:(0,r.jsx)("input",{ref:ne,type:"text",role:"searchbox","aria-label":me??S.selectSearch,className:k(R[E].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:he??S.selectSearchPlaceholder,value:_,onChange:De})}):null,(0,r.jsx)("div",{className:"overflow-y-auto",style:{maxHeight:U},children:u.length===0?(0,r.jsx)("div",{className:k(R[E].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ke}):u.map((e,t)=>(0,r.jsx)(je,{option:e,isSelected:e.value===I,isHighlighted:t===s,isDisabled:w||v.has(e.value),sizeKey:E,optionId:`${M}-option-${t}`,onClick:D,onMouseEnter:f,index:t,ref:g=>{oe.current[t]=g}},e.value))})]}),(0,H.ownerDocumentOf)(h.current).body):null]})}0&&(module.exports={Select});
|
|
1
|
+
"use strict";"use client";var Ie=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var Lt=(o,s)=>{for(var a in s)Ie(o,a,{get:s[a],enumerable:!0})},Nt=(o,s,a,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let g of wt(s))!Ct.call(o,g)&&g!==a&&Ie(o,g,{get:()=>s[g],enumerable:!(c=kt(s,g))||c.enumerable});return o};var It=o=>Nt(Ie({},"__esModule",{value:!0}),o);var zt={};Lt(zt,{Select:()=>Ht});module.exports=It(zt);var r=require("react"),Xe=require("react-dom"),Ze=require("../../lib/aria-hide.cjs"),X=require("../../lib/owner-document.cjs"),j=require("../../lib/i18n.cjs"),Ge=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),St=[],Me=[],Q=o=>o.preventDefault(),Mt=(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ye=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.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"})}),Et=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Dt=(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,t.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Ot=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),S={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",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},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",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},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",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},Se={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},Tt="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Bt="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function m(...o){let s="";for(let a=0;a<o.length;a++){let c=o[a];c&&(s&&(s+=" "),s+=c)}return s}function Rt(o,s){if(!s)return o;let a=s.toLowerCase();return o.filter(c=>{if(c.label.toLowerCase().includes(a)||c.value.toLowerCase().includes(a))return!0;if(c.keywords){for(let g of c.keywords)if(g.toLowerCase().includes(a))return!0}return!1})}function Qe(o,s){if(o!==void 0)return Array.isArray(o)?s?new Set(o).size===o.length?o:Array.from(new Set(o)):o.slice(0,1):o===""?Me:[o]}function Je(o,s,a,c,g){return m(S[o].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!c&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",a&&!s&&!g&&"bg-gray-50 dark:bg-gray-700/50",c&&"opacity-50 cursor-not-allowed")}var At=(0,r.memo)((0,r.forwardRef)(function({option:s,isSelected:a,isHighlighted:c,isDisabled:g,multiple:R,sizeKey:U,optionId:ae,onClick:se,onMouseEnter:oe,index:b},v){let f=()=>{g||se(s.value)},x=()=>{g||oe(b)};return(0,t.jsxs)("div",{ref:v,id:ae,role:"option","aria-selected":a,"aria-disabled":g||void 0,"data-highlighted":c||void 0,className:Je(U,c,a,g,R),onMouseDown:Q,onClick:f,onMouseEnter:x,children:[R?(0,t.jsx)("span",{"aria-hidden":"true",className:m("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",a?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:a?Vt:null}):null,s.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:s.icon}):null,(0,t.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"truncate",children:s.label}),s.description?(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:s.description}):null]}),a&&!R?(0,t.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Ot}):null]})}));function Ht(o){let{options:s=St,multiple:a=!1,value:c,defaultValue:g,onValueChange:R,maxTagCount:U,creatable:ae=!1,searchable:se=!1,clearable:oe=!1,disabled:b=!1,readOnly:v=!1,loading:f=!1,size:x="md",variant:le="default",placeholder:et,label:Z,description:Ee,helperText:De,error:tt,required:Oe=!1,noOptionsText:rt,clearLabel:Ve,searchLabel:nt,searchPlaceholder:at,labels:st,onSearchChange:Pe,name:ie,className:ot,triggerClassName:Te,contentClassName:lt,maxHeight:ce=256}=o,w=a&&ae,O=se||w,N=(0,j.useUILabels)(st),Be=et??N.selectPlaceholder,it=rt??N.selectNoOptions,A=(0,r.useId)(),de=`${A}-label`,ue=`${A}-trigger`,pe=`${A}-listbox`,h=(0,Ge.describeField)(ue,{description:Ee,helperText:De,error:tt}),y=(0,r.useRef)(null),ge=(0,r.useRef)(null),fe=(0,r.useRef)(null),he=(0,r.useRef)(null),me=(0,r.useRef)([]),Re=c!==void 0,[be,ct]=(0,r.useState)(()=>Qe(g,a)??Me),Ae=(0,r.useMemo)(()=>Qe(c,a),[c,a]),i=(0,r.useMemo)(()=>Ae??(a?be:be.slice(0,1)),[Ae,be,a]),[u,ye]=(0,r.useState)(!1),[H,z]=(0,r.useState)(""),[p,k]=(0,r.useState)(-1),[V,He]=(0,r.useState)(null),F=(0,r.useMemo)(()=>{let e=new Map;for(let n of s)e.has(n.value)||e.set(n.value,n);return e},[s]),W=(0,r.useMemo)(()=>{if(!w)return s;let e=[];for(let n of i)F.has(n)||e.push({value:n,label:n});return e.length>0?[...s,...e]:s},[w,s,i,F]),I=(0,r.useMemo)(()=>O?Rt(W,H):W,[W,H,O]),M=H.trim(),$=(0,r.useMemo)(()=>{if(!w||M==="")return null;let e=M.toLowerCase();return W.find(n=>n.label.toLowerCase()===e)??null},[w,M,W]),xe=w&&M!==""&&$===null,P=xe?I.length:-1,T=I.length+(xe?1:0),_=(0,r.useMemo)(()=>new Set(i),[i]),G=(0,r.useMemo)(()=>a?null:F.get(i[0]??"")??null,[a,F,i]),ve=(0,r.useMemo)(()=>{let e=new Set;for(let n of s)n.disabled&&e.add(n.value);return e},[s]),J=(0,r.useCallback)(e=>e<I.length&&ve.has(I[e].value),[I,ve]),ze=(0,r.useCallback)(e=>F.get(e)?.label??e,[F]),K=(0,r.useCallback)(e=>{Re||ct(e),R?.(a?e:e[0]??"")},[Re,R,a]),dt=(0,r.useCallback)(e=>{f||(K([e]),ye(!1),z(""),k(-1),y.current?.focus())},[K,f]),E=(0,r.useCallback)(e=>{f||K(e)},[K,f]),ut=(0,r.useCallback)(e=>{E(_.has(e)?i.filter(n=>n!==e):[...i,e])},[E,_,i]),pt=(0,r.useCallback)(e=>{E(i.filter(n=>n!==e))},[E,i]),ee=(0,r.useCallback)(()=>{i.length!==0&&E(i.slice(0,-1))},[E,i]),q=(0,r.useCallback)(()=>{if(!w||M===""||f||$?.disabled)return;let e=$?$.value:M;_.has(e)||E([...i,e]),z(""),k(-1)},[w,M,$,f,_,E,i]),ke=a?ut:dt,we=(0,r.useCallback)(e=>{if(e===P){q();return}e<0||e>=I.length||J(e)||ke(I[e].value)},[P,q,I,J,ke]),Ce=(0,r.useCallback)(()=>{((u&&O?he.current:null)??y.current)?.focus()},[u,O]),Fe=(0,r.useCallback)(e=>{e.stopPropagation(),K(Me),z(""),Ce()},[K,Ce]),B=(0,r.useCallback)(()=>{b||v||(ye(!0),z(""),k(-1))},[b,v]),C=(0,r.useCallback)(()=>{ye(!1),z(""),k(-1),y.current?.focus()},[]),gt=(0,r.useCallback)(()=>{u?C():B()},[u,C,B]),Y=(0,r.useCallback)((e,n)=>{let l=T;if(l===0)return-1;let d=e;for(let D=0;D<l;D++)if(d=((d+n)%l+l)%l,!J(d))return d;return-1},[T,J]),te=(0,r.useCallback)((e,n)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let l=Y(p,1);l!==-1&&k(l);break}case"ArrowUp":{e.preventDefault();let l=Y(p,-1);l!==-1&&k(l);break}case"Home":{e.preventDefault();let l=Y(-1,1);l!==-1&&k(l);break}case"End":{e.preventDefault();let l=Y(T,-1);l!==-1&&k(l);break}case"Enter":{e.preventDefault(),p>=0&&p<T?we(p):w&&q();break}case" ":if(n)break;e.preventDefault(),p>=0&&p<T?we(p):C();break;case"Backspace":a&&(!n||H==="")&&(n||e.preventDefault(),ee());break;case"Escape":e.preventDefault(),C();break;case"Tab":C();break}},[Y,p,T,we,w,q,C,a,H,ee]),ft=(0,r.useCallback)(e=>{if(!(b||v)){if(u){te(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),B();break;case"Enter":case" ":e.preventDefault(),B();break;case"Backspace":a&&i.length>0&&(e.preventDefault(),ee());break}}},[b,v,u,te,B,a,i.length,ee]),ht=(0,r.useCallback)(e=>te(e,!0),[te]),mt=(0,r.useCallback)(e=>{let n=e.target.value;z(n),k(-1),Pe?.(n)},[Pe]),L=!b&&!v,bt=(0,r.useCallback)(e=>{L&&(y.current?.contains(e.target)||e.preventDefault())},[L]),yt=(0,r.useCallback)(()=>{L&&(u?C():(y.current?.focus(),B()))},[L,u,C,B]);(0,r.useEffect)(()=>{if(!u)return;let e=l=>{let d=l.target;y.current?.contains(d)||ge.current?.contains(d)||fe.current?.contains(d)||C()},n=(0,X.ownerDocumentOf)(y.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[u,C]);let xt=a?i.length:0;(0,r.useEffect)(()=>{if(!u||!y.current){He(null);return}let e=(0,X.ownerWindowOf)(y.current),n=()=>{let l=a?ge.current:y.current;if(!l)return;let d=l.getBoundingClientRect(),D=e.innerHeight-d.bottom,Ne=d.top,vt=ce+8,qe=D<vt&&Ne>D?"top":"bottom";He({top:qe==="bottom"?d.bottom+e.scrollY+4:d.top+e.scrollY-4,left:d.left+e.scrollX,width:d.width,placement:qe})};return n(),e.addEventListener("scroll",n,!0),e.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n,!0),e.removeEventListener("resize",n)}},[u,ce,a,xt]);let re=u&&V!==null;(0,r.useEffect)(()=>{re&&O&&he.current?.focus()},[re,O]),(0,r.useEffect)(()=>{let e=fe.current;if(!(!re||!e))return(0,Ze.registerFloatingLayer)(e,()=>y.current)},[re]),(0,r.useEffect)(()=>{if(p>=0){let e=me.current[p];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[p]);let ne=i.length>0,Ke=oe&&ne&&!b&&!v&&!f,je=L&&!f,Ue=u&&p>=0?`${A}-option-${p}`:void 0,We={ref:y,id:ue,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?pe:void 0,"aria-labelledby":Z?de:void 0,"aria-required":Oe||void 0,"aria-invalid":h.invalid||void 0,"aria-describedby":h.describedBy,"aria-activedescendant":Ue,disabled:b,onKeyDown:ft},$e=f?(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Dt}):null,_e=(0,t.jsx)("span",{className:m("text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Mt}),Le;if(a){let e=U===void 0||!Number.isFinite(U)?i.length:Math.max(0,Math.floor(U)),n=i.slice(0,e),l=i.length-n.length;Le=(0,t.jsxs)("div",{ref:ge,className:m("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].frame,Se[le].trigger,!h.invalid&&L&&Tt,h.invalid&&Bt,b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",L&&"cursor-pointer",Te),onMouseDown:bt,onClick:yt,children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[n.map(d=>{let D=ze(d);return(0,t.jsxs)("span",{className:m("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",S[x].tag,!je&&"pr-2"),children:[(0,t.jsx)("span",{className:"min-w-0 truncate","aria-hidden":"true",children:D}),je?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":(0,j.formatUILabel)(N.selectRemoveValue,{label:D}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:Q,onClick:Ne=>{Ne.stopPropagation(),pt(d),Ce()},children:Et}):null]},d)}),l>0?(0,t.jsx)("span",{"aria-hidden":"true",className:m("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",S[x].tag,"pr-2"),children:(0,j.formatUILabel)(N.selectMoreValues,{count:l})}):null,(0,t.jsx)("button",{...We,className:m("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",S[x].combobox,L?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:ne?(0,t.jsx)("span",{className:"sr-only",children:i.map(ze).join(", ")}):(0,t.jsx)("span",{className:"truncate text-gray-600 dark:text-gray-300",children:Be})})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:Q,onClick:Fe,children:Ye}):null,_e]})]})}else{let e=m("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].trigger,Se[le].trigger,!h.invalid&&L&&Se[le].focus,h.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",!b&&!v&&"cursor-pointer",Te);Le=(0,t.jsxs)("button",{...We,className:e,onClick:L?gt:void 0,children:[(0,t.jsxs)("span",{className:m("flex items-center gap-2 min-w-0 flex-1 truncate",!ne&&"text-gray-600 dark:text-gray-300"),children:[G?.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:G.icon}):null,(0,t.jsx)("span",{className:"truncate",children:ne&&G?G.label:Be})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("span",{role:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Fe,onMouseDown:Q,children:Ye}):null,_e]})]})}return(0,t.jsxs)("div",{className:m("flex flex-col gap-1",ot),children:[Z?(0,t.jsxs)("label",{id:de,htmlFor:ue,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[Z,Oe?(0,t.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,h.hasDescription?(0,t.jsx)("p",{id:h.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ee}):null,Le,h.message!==void 0?(0,t.jsx)("p",{id:h.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:h.message}):h.showHelper?(0,t.jsx)("p",{id:h.ids.helper,className:m("text-xs",h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:De}):null,ie?a?i.map(e=>(0,t.jsx)("input",{type:"hidden",name:ie,value:e},e)):(0,t.jsx)("input",{type:"hidden",name:ie,value:i[0]??""}):null,u&&V?(0,Xe.createPortal)((0,t.jsxs)("div",{ref:fe,className:m("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",S[x].content,lt),"data-placement":V.placement,style:{top:V.top,left:V.left,width:V.width,position:"absolute",translate:V.placement==="top"?"0 -100%":void 0},onKeyDown:ht,children:[O?(0,t.jsx)("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:(0,t.jsx)("input",{ref:he,type:"text",role:"searchbox","aria-label":nt??N.selectSearch,"aria-controls":pe,"aria-activedescendant":Ue,className:m(S[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:at??N.selectSearchPlaceholder,value:H,onChange:mt})}):null,(0,t.jsxs)("div",{role:"listbox",id:pe,"aria-labelledby":Z?de:void 0,"aria-multiselectable":a||void 0,className:"overflow-y-auto",style:{maxHeight:ce},children:[I.map((e,n)=>(0,t.jsx)(At,{option:e,isSelected:_.has(e.value),isHighlighted:n===p,isDisabled:f||ve.has(e.value),multiple:a,sizeKey:x,optionId:`${A}-option-${n}`,onClick:ke,onMouseEnter:k,index:n,ref:l=>{me.current[n]=l}},e.value)),xe?(0,t.jsxs)("div",{ref:e=>{me.current[P]=e},id:`${A}-option-${P}`,role:"option","aria-selected":!1,"aria-disabled":f||void 0,"data-highlighted":P===p||void 0,className:Je(x,P===p,!1,f,a),onMouseDown:Q,onClick:f?void 0:q,onMouseEnter:f?void 0:()=>k(P),children:[(0,t.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Pt}),(0,t.jsx)("span",{className:"truncate",children:(0,j.formatUILabel)(N.selectCreateOption,{label:M})})]}):null]}),T===0?(0,t.jsx)("div",{className:m(S[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:it}):null]}),(0,X.ownerDocumentOf)(y.current).body):null]})}0&&(module.exports={Select});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as H,useRef as U,useEffect as K,useCallback as x,useMemo as Z,useId as Ae,memo as Pe,forwardRef as Re}from"react";import{createPortal as He}from"react-dom";import{registerFloatingLayer as Ke}from"../../lib/aria-hide.js";import{ownerDocumentOf as pe,ownerWindowOf as Ve}from"../../lib/owner-document.js";import{useUILabels as Be}from"../../lib/i18n.js";import{jsx as r,jsxs as v}from"react/jsx-runtime";var G=()=>{},$e=[],We=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ue=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ye=v("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),je=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),V={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base"}},fe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}};function w(...l){let o="";for(let u=0;u<l.length;u++){let a=l[u];a&&(o&&(o+=" "),o+=a)}return o}function ze(l,o){if(!o)return l;let u=o.toLowerCase();return l.filter(a=>{if(a.label.toLowerCase().includes(u)||a.value.toLowerCase().includes(u))return!0;if(a.keywords){for(let d of a.keywords)if(d.toLowerCase().includes(u))return!0}return!1})}var _e=Pe(Re(function({option:o,isSelected:u,isHighlighted:a,isDisabled:d,sizeKey:Y,optionId:g,onClick:b,onMouseEnter:E,index:L},B){let j=()=>{d||b(o.value)},I=()=>{d||E(L)};return v("div",{ref:B,id:g,role:"option","aria-selected":u,"aria-disabled":d||void 0,"data-highlighted":a||void 0,className:w(V[Y].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",a&&!d&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",u&&!a&&"bg-gray-50 dark:bg-gray-700/50",d&&"opacity-50 cursor-not-allowed"),onClick:j,onMouseEnter:I,children:[o.icon?r("span",{className:"flex shrink-0 items-center",children:o.icon}):null,v("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:o.label}),o.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),u?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:je}):null]})}));function Ge({options:l=$e,value:o,defaultValue:u,onValueChange:a,searchable:d=!1,clearable:Y=!1,disabled:g=!1,readOnly:b=!1,loading:E=!1,size:L="md",variant:B="default",placeholder:j,label:I,description:J,helperText:ee,error:S,required:te=!1,noOptionsText:ge,clearLabel:me,searchLabel:he,searchPlaceholder:be,onSearchChange:re,name:ne,className:ye,triggerClassName:xe,contentClassName:ve,maxHeight:z=256}){let M=Be(),ke=j??M.selectPlaceholder,we=ge??M.selectNoOptions,O=Ae(),_=`${O}-label`,oe=`${O}-trigger`,ae=`${O}-listbox`,m=U(null),q=U(null),se=U(null),le=U([]),T=o!==void 0,[Ee,ie]=H(u??""),D=T?o:Ee,[i,F]=H(!1),[Q,A]=H(""),[n,p]=H(-1),[N,ce]=H(null),s=Z(()=>d?ze(l,Q):l,[l,Q,d]),$=Z(()=>l.find(e=>e.value===D)??null,[l,D]),k=Z(()=>{let e=new Set;for(let t of l)t.disabled&&e.add(t.value);return e},[l]),C=x(e=>{E||(T||ie(e),(a??G)(e),F(!1),A(""),p(-1),m.current?.focus())},[T,a,E]),Le=x(e=>{e.stopPropagation(),T||ie(""),(a??G)(""),A(""),m.current?.focus()},[T,a]),P=x(()=>{g||b||(F(!0),A(""),p(-1))},[g,b]),h=x(()=>{F(!1),A(""),p(-1),m.current?.focus()},[]),Ne=x(()=>{i?h():P()},[i,h,P]),y=x((e,t)=>{let f=s.length;if(f===0)return-1;let c=e;for(let R=0;R<f;R++)if(c=((c+t)%f+f)%f,!k.has(s[c].value))return c;return-1},[s,k]),Ie=x(e=>{if(!(g||b)){if(i){switch(e.key){case"ArrowDown":{e.preventDefault();let t=y(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=y(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=y(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=y(s.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}break}case" ":if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}else h();break;case"Escape":e.preventDefault(),h();break;case"Tab":h();break}return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),P();break;case"Enter":case" ":e.preventDefault(),P();break}}},[g,b,i,P,h,n,s,k,y,C]),De=x(e=>{switch(e.key){case"ArrowDown":{e.preventDefault();let t=y(n,1);t!==-1&&p(t);break}case"ArrowUp":{e.preventDefault();let t=y(n,-1);t!==-1&&p(t);break}case"Home":{e.preventDefault();let t=y(-1,1);t!==-1&&p(t);break}case"End":{e.preventDefault();let t=y(s.length,-1);t!==-1&&p(t);break}case"Enter":{if(e.preventDefault(),n>=0&&n<s.length){let t=s[n];k.has(t.value)||C(t.value)}break}case"Escape":e.preventDefault(),h();break;case"Tab":h();break}},[n,s,k,y,C,h]),Ce=x(e=>{let t=e.target.value;A(t),p(-1),(re??G)(t)},[re]);K(()=>{if(!i)return;let e=f=>{let c=f.target;m.current?.contains(c)||q.current?.contains(c)||h()},t=pe(m.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[i,h]),K(()=>{if(!i||!m.current){ce(null);return}let e=Ve(m.current),t=()=>{let f=m.current;if(!f)return;let c=f.getBoundingClientRect(),R=e.innerHeight-c.bottom,Oe=c.top,Te=z+8,de=R<Te&&Oe>R?"top":"bottom";ce({top:de==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:de})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[i,z]);let W=i&&N!==null;K(()=>{W&&d&&se.current?.focus()},[W,d]),K(()=>{let e=q.current;if(!(!W||!e))return Ke(e,()=>m.current)},[W]),K(()=>{if(n>=0){let e=le.current[n];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[n]);let X=D!==""&&D!==void 0,Se=Y&&X&&!g&&!b&&!E,ue=!g&&!b,Me=w("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",V[L].trigger,fe[B].trigger,!S&&ue&&fe[B].focus,S&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",g&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",b&&"cursor-default",!g&&!b&&"cursor-pointer",xe);return v("div",{className:w("flex flex-col gap-1",ye),children:[I?v("label",{id:_,htmlFor:oe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[I,te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,J?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:J}):null,v("button",{ref:m,id:oe,type:"button",role:"combobox","aria-expanded":i,"aria-haspopup":"listbox","aria-controls":i?ae:void 0,"aria-labelledby":I?_:void 0,"aria-required":te||void 0,"aria-invalid":S?!0:void 0,"aria-activedescendant":i&&n>=0?`${O}-option-${n}`:void 0,disabled:g,className:Me,onClick:ue?Ne:void 0,onKeyDown:Ie,children:[v("span",{className:w("flex items-center gap-2 min-w-0 flex-1 truncate",!X&&"text-gray-600 dark:text-gray-300"),children:[$?.icon?r("span",{className:"flex shrink-0 items-center",children:$.icon}):null,r("span",{className:"truncate",children:X&&$?$.label:ke})]}),v("span",{className:"flex items-center gap-1 shrink-0",children:[E?r("span",{className:"text-gray-500 dark:text-gray-400",children:Ye}):null,Se?r("span",{role:"button",tabIndex:-1,"aria-label":me??M.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Le,onMouseDown:e=>e.preventDefault(),children:Ue}):null,r("span",{className:w("text-gray-500 dark:text-gray-400 transition-transform duration-200",i&&"rotate-180"),children:We})]})]}),S?r("p",{role:"alert",className:"text-xs text-red-600 dark:text-red-400",children:S}):ee?r("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:ee}):null,ne?r("input",{type:"hidden",name:ne,value:D??""}):null,i&&N?He(v("div",{ref:q,role:"listbox",id:ae,"aria-labelledby":I?_:void 0,className:w("fixed z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",V[L].content,ve),"data-placement":N.placement,style:{top:N.top,left:N.left,width:N.width,position:"absolute",translate:N.placement==="top"?"0 -100%":void 0},onKeyDown:De,children:[d?r("div",{className:"border-b border-gray-200 dark:border-gray-700",children:r("input",{ref:se,type:"text",role:"searchbox","aria-label":he??M.selectSearch,className:w(V[L].searchInput,"w-full outline-none bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:be??M.selectSearchPlaceholder,value:Q,onChange:Ce})}):null,r("div",{className:"overflow-y-auto",style:{maxHeight:z},children:s.length===0?r("div",{className:w(V[L].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:we}):s.map((e,t)=>r(_e,{option:e,isSelected:e.value===D,isHighlighted:t===n,isDisabled:E||k.has(e.value),sizeKey:L,optionId:`${O}-option-${t}`,onClick:C,onMouseEnter:p,index:t,ref:f=>{le.current[t]=f}},e.value))})]}),pe(m.current).body):null]})}export{Ge as Select};
|
|
1
|
+
"use client";import{useState as X,useRef as Z,useEffect as G,useCallback as i,useMemo as M,useId as wt,memo as Ct,forwardRef as Lt}from"react";import{createPortal as Nt}from"react-dom";import{registerFloatingLayer as It}from"../../lib/aria-hide.js";import{ownerDocumentOf as Ze,ownerWindowOf as St}from"../../lib/owner-document.js";import{formatUILabel as Ee,useUILabels as Mt}from"../../lib/i18n.js";import{describeField as Et}from"../form/shared/field-error.js";import{jsx as r,jsxs as f}from"react/jsx-runtime";var Dt=[],Oe=[],J=l=>l.preventDefault(),Ot=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ge=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=f("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Tt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Bt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Rt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),E={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",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},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",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},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",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},De={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},At="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Ht="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function m(...l){let a="";for(let n=0;n<l.length;n++){let u=l[n];u&&(a&&(a+=" "),a+=u)}return a}function zt(l,a){if(!a)return l;let n=a.toLowerCase();return l.filter(u=>{if(u.label.toLowerCase().includes(n)||u.value.toLowerCase().includes(n))return!0;if(u.keywords){for(let w of u.keywords)if(w.toLowerCase().includes(n))return!0}return!1})}function Je(l,a){if(l!==void 0)return Array.isArray(l)?a?new Set(l).size===l.length?l:Array.from(new Set(l)):l.slice(0,1):l===""?Oe:[l]}function et(l,a,n,u,w){return m(E[l].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",a&&!u&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",n&&!a&&!w&&"bg-gray-50 dark:bg-gray-700/50",u&&"opacity-50 cursor-not-allowed")}var Ft=Ct(Lt(function({option:a,isSelected:n,isHighlighted:u,isDisabled:w,multiple:H,sizeKey:W,optionId:le,onClick:ie,onMouseEnter:ce,index:b},v){let g=()=>{w||ie(a.value)},x=()=>{w||ce(b)};return f("div",{ref:v,id:le,role:"option","aria-selected":n,"aria-disabled":w||void 0,"data-highlighted":u||void 0,className:et(W,u,n,w,H),onMouseDown:J,onClick:g,onMouseEnter:x,children:[H?r("span",{"aria-hidden":"true",className:m("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",n?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:n?Bt:null}):null,a.icon?r("span",{className:"flex shrink-0 items-center",children:a.icon}):null,f("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:a.label}),a.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:a.description}):null]}),n&&!H?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Tt}):null]})}));function qt(l){let{options:a=Dt,multiple:n=!1,value:u,defaultValue:w,onValueChange:H,maxTagCount:W,creatable:le=!1,searchable:ie=!1,clearable:ce=!1,disabled:b=!1,readOnly:v=!1,loading:g=!1,size:x="md",variant:de="default",placeholder:tt,label:ee,description:Ve,helperText:Pe,error:rt,required:Te=!1,noOptionsText:nt,clearLabel:Be,searchLabel:at,searchPlaceholder:st,labels:ot,onSearchChange:Re,name:ue,className:lt,triggerClassName:Ae,contentClassName:it,maxHeight:pe=256}=l,C=n&&le,P=ie||C,I=Mt(ot),He=tt??I.selectPlaceholder,ct=nt??I.selectNoOptions,z=wt(),ge=`${z}-label`,fe=`${z}-trigger`,he=`${z}-listbox`,h=Et(fe,{description:Ve,helperText:Pe,error:rt}),y=Z(null),me=Z(null),be=Z(null),ye=Z(null),xe=Z([]),ze=u!==void 0,[ve,dt]=X(()=>Je(w,n)??Oe),Fe=M(()=>Je(u,n),[u,n]),o=M(()=>Fe??(n?ve:ve.slice(0,1)),[Fe,ve,n]),[d,ke]=X(!1),[F,K]=X(""),[p,k]=X(-1),[T,Ke]=X(null),j=M(()=>{let e=new Map;for(let t of a)e.has(t.value)||e.set(t.value,t);return e},[a]),$=M(()=>{if(!C)return a;let e=[];for(let t of o)j.has(t)||e.push({value:t,label:t});return e.length>0?[...a,...e]:a},[C,a,o,j]),S=M(()=>P?zt($,F):$,[$,F,P]),D=F.trim(),_=M(()=>{if(!C||D==="")return null;let e=D.toLowerCase();return $.find(t=>t.label.toLowerCase()===e)??null},[C,D,$]),we=C&&D!==""&&_===null,B=we?S.length:-1,R=S.length+(we?1:0),q=M(()=>new Set(o),[o]),te=M(()=>n?null:j.get(o[0]??"")??null,[n,j,o]),Ce=M(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),re=i(e=>e<S.length&&Ce.has(S[e].value),[S,Ce]),je=i(e=>j.get(e)?.label??e,[j]),U=i(e=>{ze||dt(e),H?.(n?e:e[0]??"")},[ze,H,n]),ut=i(e=>{g||(U([e]),ke(!1),K(""),k(-1),y.current?.focus())},[U,g]),O=i(e=>{g||U(e)},[U,g]),pt=i(e=>{O(q.has(e)?o.filter(t=>t!==e):[...o,e])},[O,q,o]),gt=i(e=>{O(o.filter(t=>t!==e))},[O,o]),ne=i(()=>{o.length!==0&&O(o.slice(0,-1))},[O,o]),Y=i(()=>{if(!C||D===""||g||_?.disabled)return;let e=_?_.value:D;q.has(e)||O([...o,e]),K(""),k(-1)},[C,D,_,g,q,O,o]),Le=n?pt:ut,Ne=i(e=>{if(e===B){Y();return}e<0||e>=S.length||re(e)||Le(S[e].value)},[B,Y,S,re,Le]),Ie=i(()=>{((d&&P?ye.current:null)??y.current)?.focus()},[d,P]),Ue=i(e=>{e.stopPropagation(),U(Oe),K(""),Ie()},[U,Ie]),A=i(()=>{b||v||(ke(!0),K(""),k(-1))},[b,v]),L=i(()=>{ke(!1),K(""),k(-1),y.current?.focus()},[]),ft=i(()=>{d?L():A()},[d,L,A]),Q=i((e,t)=>{let s=R;if(s===0)return-1;let c=e;for(let V=0;V<s;V++)if(c=((c+t)%s+s)%s,!re(c))return c;return-1},[R,re]),ae=i((e,t)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let s=Q(p,1);s!==-1&&k(s);break}case"ArrowUp":{e.preventDefault();let s=Q(p,-1);s!==-1&&k(s);break}case"Home":{e.preventDefault();let s=Q(-1,1);s!==-1&&k(s);break}case"End":{e.preventDefault();let s=Q(R,-1);s!==-1&&k(s);break}case"Enter":{e.preventDefault(),p>=0&&p<R?Ne(p):C&&Y();break}case" ":if(t)break;e.preventDefault(),p>=0&&p<R?Ne(p):L();break;case"Backspace":n&&(!t||F==="")&&(t||e.preventDefault(),ne());break;case"Escape":e.preventDefault(),L();break;case"Tab":L();break}},[Q,p,R,Ne,C,Y,L,n,F,ne]),ht=i(e=>{if(!(b||v)){if(d){ae(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),A();break;case"Enter":case" ":e.preventDefault(),A();break;case"Backspace":n&&o.length>0&&(e.preventDefault(),ne());break}}},[b,v,d,ae,A,n,o.length,ne]),mt=i(e=>ae(e,!0),[ae]),bt=i(e=>{let t=e.target.value;K(t),k(-1),Re?.(t)},[Re]),N=!b&&!v,yt=i(e=>{N&&(y.current?.contains(e.target)||e.preventDefault())},[N]),xt=i(()=>{N&&(d?L():(y.current?.focus(),A()))},[N,d,L,A]);G(()=>{if(!d)return;let e=s=>{let c=s.target;y.current?.contains(c)||me.current?.contains(c)||be.current?.contains(c)||L()},t=Ze(y.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[d,L]);let vt=n?o.length:0;G(()=>{if(!d||!y.current){Ke(null);return}let e=St(y.current),t=()=>{let s=n?me.current:y.current;if(!s)return;let c=s.getBoundingClientRect(),V=e.innerHeight-c.bottom,Me=c.top,kt=pe+8,Xe=V<kt&&Me>V?"top":"bottom";Ke({top:Xe==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:Xe})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[d,pe,n,vt]);let se=d&&T!==null;G(()=>{se&&P&&ye.current?.focus()},[se,P]),G(()=>{let e=be.current;if(!(!se||!e))return It(e,()=>y.current)},[se]),G(()=>{if(p>=0){let e=xe.current[p];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[p]);let oe=o.length>0,We=ce&&oe&&!b&&!v&&!g,$e=N&&!g,_e=d&&p>=0?`${z}-option-${p}`:void 0,qe={ref:y,id:fe,type:"button",role:"combobox","aria-expanded":d,"aria-haspopup":"listbox","aria-controls":d?he:void 0,"aria-labelledby":ee?ge:void 0,"aria-required":Te||void 0,"aria-invalid":h.invalid||void 0,"aria-describedby":h.describedBy,"aria-activedescendant":_e,disabled:b,onKeyDown:ht},Ye=g?r("span",{className:"text-gray-500 dark:text-gray-400",children:Pt}):null,Qe=r("span",{className:m("text-gray-500 dark:text-gray-400 transition-transform duration-200",d&&"rotate-180"),children:Ot}),Se;if(n){let e=W===void 0||!Number.isFinite(W)?o.length:Math.max(0,Math.floor(W)),t=o.slice(0,e),s=o.length-t.length;Se=f("div",{ref:me,className:m("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].frame,De[de].trigger,!h.invalid&&N&&At,h.invalid&&Ht,b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",N&&"cursor-pointer",Ae),onMouseDown:yt,onClick:xt,children:[f("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[t.map(c=>{let V=je(c);return f("span",{className:m("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",E[x].tag,!$e&&"pr-2"),children:[r("span",{className:"min-w-0 truncate","aria-hidden":"true",children:V}),$e?r("button",{type:"button",tabIndex:-1,"aria-label":Ee(I.selectRemoveValue,{label:V}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:J,onClick:Me=>{Me.stopPropagation(),gt(c),Ie()},children:Vt}):null]},c)}),s>0?r("span",{"aria-hidden":"true",className:m("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",E[x].tag,"pr-2"),children:Ee(I.selectMoreValues,{count:s})}):null,r("button",{...qe,className:m("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",E[x].combobox,N?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:oe?r("span",{className:"sr-only",children:o.map(je).join(", ")}):r("span",{className:"truncate text-gray-600 dark:text-gray-300",children:He})})]}),f("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("button",{type:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:J,onClick:Ue,children:Ge}):null,Qe]})]})}else{let e=m("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].trigger,De[de].trigger,!h.invalid&&N&&De[de].focus,h.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",!b&&!v&&"cursor-pointer",Ae);Se=f("button",{...qe,className:e,onClick:N?ft:void 0,children:[f("span",{className:m("flex items-center gap-2 min-w-0 flex-1 truncate",!oe&&"text-gray-600 dark:text-gray-300"),children:[te?.icon?r("span",{className:"flex shrink-0 items-center",children:te.icon}):null,r("span",{className:"truncate",children:oe&&te?te.label:He})]}),f("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("span",{role:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ue,onMouseDown:J,children:Ge}):null,Qe]})]})}return f("div",{className:m("flex flex-col gap-1",lt),children:[ee?f("label",{id:ge,htmlFor:fe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[ee,Te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,h.hasDescription?r("p",{id:h.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ve}):null,Se,h.message!==void 0?r("p",{id:h.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:h.message}):h.showHelper?r("p",{id:h.ids.helper,className:m("text-xs",h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:Pe}):null,ue?n?o.map(e=>r("input",{type:"hidden",name:ue,value:e},e)):r("input",{type:"hidden",name:ue,value:o[0]??""}):null,d&&T?Nt(f("div",{ref:be,className:m("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",E[x].content,it),"data-placement":T.placement,style:{top:T.top,left:T.left,width:T.width,position:"absolute",translate:T.placement==="top"?"0 -100%":void 0},onKeyDown:mt,children:[P?r("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:r("input",{ref:ye,type:"text",role:"searchbox","aria-label":at??I.selectSearch,"aria-controls":he,"aria-activedescendant":_e,className:m(E[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:st??I.selectSearchPlaceholder,value:F,onChange:bt})}):null,f("div",{role:"listbox",id:he,"aria-labelledby":ee?ge:void 0,"aria-multiselectable":n||void 0,className:"overflow-y-auto",style:{maxHeight:pe},children:[S.map((e,t)=>r(Ft,{option:e,isSelected:q.has(e.value),isHighlighted:t===p,isDisabled:g||Ce.has(e.value),multiple:n,sizeKey:x,optionId:`${z}-option-${t}`,onClick:Le,onMouseEnter:k,index:t,ref:s=>{xe.current[t]=s}},e.value)),we?f("div",{ref:e=>{xe.current[B]=e},id:`${z}-option-${B}`,role:"option","aria-selected":!1,"aria-disabled":g||void 0,"data-highlighted":B===p||void 0,className:et(x,B===p,!1,g,n),onMouseDown:J,onClick:g?void 0:Y,onMouseEnter:g?void 0:()=>k(B),children:[r("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Rt}),r("span",{className:"truncate",children:Ee(I.selectCreateOption,{label:D})})]}):null]}),R===0?r("div",{className:m(E[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ct}):null]}),Ze(y.current).body):null]})}export{qt as Select};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var i=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},f=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of s(e))!P.call(t,l)&&l!==o&&p(t,l,{get:()=>e[l],enumerable:!(r=c(e,l))||r.enumerable});return t};var m=t=>f(p({},"__esModule",{value:!0}),t);var n={};i(n,{Select:()=>S.Select});module.exports=m(n);var S=require("./Select.cjs");0&&(module.exports={Select});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Select as
|
|
1
|
+
import{Select as l}from"./Select.js";export{l as Select};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var P=Object.defineProperty;var
|
|
1
|
+
"use strict";"use client";var P=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var ce=(r,e)=>{for(var t in e)P(r,t,{get:e[t],enumerable:!0})},be=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of de(e))!ue.call(r,n)&&n!==t&&P(r,n,{get:()=>e[n],enumerable:!(o=ie(e,n))||o.enumerable});return r};var me=r=>be(P({},"__esModule",{value:!0}),r);var Ne={};ce(Ne,{Slider:()=>j});module.exports=me(Ne);var i=require("react"),l=require("../../lib/cn.cjs"),O=require("../form/shared/field-error.cjs"),k=require("../../lib/css-value.cjs"),a=require("react/jsx-runtime"),ge={sm:"h-1",md:"h-1.5",lg:"h-2"},pe={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},ye={sm:14,md:16,lg:20},fe="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",he={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},ve={sm:"h-4",md:"h-5",lg:"h-6"},ke={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},we={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},Ce={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},Se={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},_=(r,e,t)=>Math.min(t,Math.max(e,r)),V=(r,e,t)=>t>e?(_(r,e,t)-e)/(t-e)*100:0,v=(r,e)=>{let t=(.5-r/100)*e,o=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${o}px)`},xe=(r,e,t,o)=>{if(!r)return[];if(Array.isArray(r))return r;let n=o>0?o:1,d=Math.floor((t-e)/n);return d<=0||d>20?[{value:e},{value:t}]:Array.from({length:d+1},(c,w)=>({value:e+w*n}))},j=(0,i.forwardRef)(({value:r,defaultValue:e,onValueChange:t,min:o=0,max:n=100,step:d=1,size:c="md",color:w="primary",disabled:g=!1,readOnly:C=!1,label:S,description:$,error:q,showValue:I=!1,showTooltip:T=!1,valueFormat:E,marks:H,trackColor:D,fillColor:G,thumbColor:J,className:K,containerClassName:Q,id:U,"aria-describedby":X,...Y},Z)=>{let A=(0,k.safeCssColor)(D),x=(0,k.safeCssColor)(G),p=(0,k.safeCssColor)(J),[ee,re]=(0,i.useState)(e??o),F=r!==void 0,m=_(F?r:ee,o,n),te=(0,i.useId)(),N=U??te,u=(0,O.describeField)(N,{helperText:$,error:q,own:X}),z=u.invalid,y=!g&&!C,f=z?"error":w,L=V(m,o,n),h=ye[c],ae=s=>{if(!y)return;let b=Number(s.target.value);F||re(b),t?.(b)},R=(0,i.useMemo)(()=>xe(H,o,n,d),[H,o,n,d]),oe=R.some(s=>s.label!=null),W=E?E(m):`${m}`,B={width:v(L,h)};x&&(B.backgroundColor=x);let M={left:v(L,h)};p&&(M.backgroundColor=p,M.borderColor=p);let ne=A?{backgroundColor:A}:{};return(0,a.jsxs)("div",{className:(0,l.cn)("w-full",Q),children:[(S||I)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[S?(0,a.jsx)("label",{htmlFor:N,className:(0,l.cn)("text-sm font-medium text-gray-700 dark:text-gray-200",g&&"opacity-50"),children:S}):(0,a.jsx)("span",{}),I&&(0,a.jsx)("span",{className:(0,l.cn)("text-sm font-semibold tabular-nums",Se[f]),children:W})]}),(0,a.jsxs)("div",{className:(0,l.cn)("relative flex items-center",ve[c],g&&"opacity-50"),children:[(0,a.jsx)("input",{ref:Z,type:"range",id:N,min:o,max:n,step:d,value:m,onChange:ae,disabled:g,readOnly:C,"aria-invalid":z||void 0,"aria-readonly":C||void 0,"aria-describedby":u.describedBy,tabIndex:y?void 0:-1,className:(0,l.cn)("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",fe,he[c],!y&&"pointer-events-none cursor-default",K),...Y}),(0,a.jsxs)("div",{className:(0,l.cn)("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ge[c]),style:ne,children:[(0,a.jsx)("div",{className:(0,l.cn)("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",x?"":ke[f]),style:B}),R.map((s,b)=>{let se=V(s.value,o,n),le=s.value<=m;return(0,a.jsx)("span",{"data-slider-mark":"",className:(0,l.cn)("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",le?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:v(se,h)}},`mark-${s.value}-${b}`)})]}),(0,a.jsx)("div",{"data-slider-thumb":"",className:(0,l.cn)("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",pe[c],p?"":we[f],y&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",Ce[f],T&&"peer-hover:*:opacity-100 peer-focus-visible:*:opacity-100 peer-active:*:opacity-100"),style:M,children:T&&(0,a.jsx)("span",{"data-slider-tooltip":"",className:"pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700",children:W})})]}),oe&&(0,a.jsx)("div",{className:"relative mt-1.5 h-4",children:R.map((s,b)=>s.label!=null?(0,a.jsx)("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:v(V(s.value,o,n),h)},children:s.label},`mark-label-${s.value}-${b}`):null)}),u.showHelper&&(0,a.jsx)("p",{id:u.ids.helper,className:(0,l.cn)("mt-1.5 text-sm",z?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:$}),u.message!==void 0&&(0,a.jsx)("p",{id:u.ids.error,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:u.message})]})});j.displayName="Slider";0&&(module.exports={Slider});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as
|
|
1
|
+
"use client";import{useState as ne,useId as se,useMemo as le,forwardRef as ie}from"react";import{cn as l}from"../../lib/cn.js";import{describeField as de}from"../form/shared/field-error.js";import{safeCssColor as M}from"../../lib/css-value.js";import{jsx as n,jsxs as v}from"react/jsx-runtime";var ue={sm:"h-1",md:"h-1.5",lg:"h-2"},ce={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},be={sm:14,md:16,lg:20},me="[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0",ge={sm:"[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5",md:"[&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4",lg:"[&::-webkit-slider-thumb]:h-5 [&::-webkit-slider-thumb]:w-5 [&::-moz-range-thumb]:h-5 [&::-moz-range-thumb]:w-5"},pe={sm:"h-4",md:"h-5",lg:"h-6"},ye={primary:"bg-synertech-primary-600 dark:bg-synertech-primary-500",success:"bg-green-600 dark:bg-green-500",warning:"bg-yellow-500 dark:bg-yellow-400",error:"bg-red-600 dark:bg-red-500",info:"bg-cyan-600 dark:bg-cyan-500",neutral:"bg-gray-600 dark:bg-gray-400"},fe={primary:"border-synertech-primary-600 dark:border-synertech-primary-500",success:"border-green-600 dark:border-green-500",warning:"border-yellow-500 dark:border-yellow-400",error:"border-red-600 dark:border-red-500",info:"border-cyan-600 dark:border-cyan-500",neutral:"border-gray-600 dark:border-gray-400"},he={primary:"peer-focus-visible:ring-synertech-primary-500",success:"peer-focus-visible:ring-green-500",warning:"peer-focus-visible:ring-yellow-500",error:"peer-focus-visible:ring-red-500",info:"peer-focus-visible:ring-cyan-500",neutral:"peer-focus-visible:ring-gray-500"},ve={primary:"text-synertech-primary-600 dark:text-synertech-primary-400",success:"text-green-700 dark:text-green-400",warning:"text-yellow-700 dark:text-yellow-400",error:"text-red-600 dark:text-red-400",info:"text-cyan-700 dark:text-cyan-400",neutral:"text-gray-700 dark:text-gray-300"},B=(r,e,t)=>Math.min(t,Math.max(e,r)),P=(r,e,t)=>t>e?(B(r,e,t)-e)/(t-e)*100:0,h=(r,e)=>{let t=(.5-r/100)*e,a=Math.round(Math.abs(t)*1e3)/1e3;return`calc(${r}% ${t<0?"-":"+"} ${a}px)`},ke=(r,e,t,a)=>{if(!r)return[];if(Array.isArray(r))return r;let s=a>0?a:1,i=Math.floor((t-e)/s);return i<=0||i>20?[{value:e},{value:t}]:Array.from({length:i+1},(u,k)=>({value:e+k*s}))},we=ie(({value:r,defaultValue:e,onValueChange:t,min:a=0,max:s=100,step:i=1,size:u="md",color:k="primary",disabled:m=!1,readOnly:w=!1,label:C,description:V,error:O,showValue:$=!1,showTooltip:I=!1,valueFormat:T,marks:E,trackColor:_,fillColor:j,thumbColor:q,className:D,containerClassName:G,id:J,"aria-describedby":K,...Q},U)=>{let H=M(_),S=M(j),g=M(q),[X,Y]=ne(e??a),A=r!==void 0,b=B(A?r:X,a,s),Z=se(),x=J??Z,d=de(x,{helperText:V,error:O,own:K}),N=d.invalid,p=!m&&!w,y=N?"error":k,F=P(b,a,s),f=be[u],ee=o=>{if(!p)return;let c=Number(o.target.value);A||Y(c),t?.(c)},z=le(()=>ke(E,a,s,i),[E,a,s,i]),re=z.some(o=>o.label!=null),L=T?T(b):`${b}`,W={width:h(F,f)};S&&(W.backgroundColor=S);let R={left:h(F,f)};g&&(R.backgroundColor=g,R.borderColor=g);let te=H?{backgroundColor:H}:{};return v("div",{className:l("w-full",G),children:[(C||$)&&v("div",{className:"flex items-center justify-between mb-1.5",children:[C?n("label",{htmlFor:x,className:l("text-sm font-medium text-gray-700 dark:text-gray-200",m&&"opacity-50"),children:C}):n("span",{}),$&&n("span",{className:l("text-sm font-semibold tabular-nums",ve[y]),children:L})]}),v("div",{className:l("relative flex items-center",pe[u],m&&"opacity-50"),children:[n("input",{ref:U,type:"range",id:x,min:a,max:s,step:i,value:b,onChange:ee,disabled:m,readOnly:w,"aria-invalid":N||void 0,"aria-readonly":w||void 0,"aria-describedby":d.describedBy,tabIndex:p?void 0:-1,className:l("peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer appearance-none bg-transparent opacity-0",me,ge[u],!p&&"pointer-events-none cursor-default",D),...Q}),v("div",{className:l("pointer-events-none relative w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",ue[u]),style:te,children:[n("div",{className:l("absolute inset-y-0 left-0 rounded-full transition-[width] duration-150 ease-out",S?"":ye[y]),style:W}),z.map((o,c)=>{let ae=P(o.value,a,s),oe=o.value<=b;return n("span",{"data-slider-mark":"",className:l("absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full",oe?"bg-white/80":"bg-gray-400 dark:bg-gray-500"),style:{left:h(ae,f)}},`mark-${o.value}-${c}`)})]}),n("div",{"data-slider-thumb":"",className:l("pointer-events-none absolute top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-white shadow transition-transform dark:bg-gray-100",ce[u],g?"":fe[y],p&&"peer-hover:scale-110 peer-active:scale-110","peer-focus-visible:scale-110 peer-focus-visible:ring-2 peer-focus-visible:ring-offset-2",he[y],I&&"peer-hover:*:opacity-100 peer-focus-visible:*:opacity-100 peer-active:*:opacity-100"),style:R,children:I&&n("span",{"data-slider-tooltip":"",className:"pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2 rounded bg-gray-900 px-1.5 py-0.5 text-xs font-medium text-white opacity-0 transition-opacity dark:bg-gray-700",children:L})})]}),re&&n("div",{className:"relative mt-1.5 h-4",children:z.map((o,c)=>o.label!=null?n("span",{className:"absolute -translate-x-1/2 whitespace-nowrap text-xs text-gray-500 dark:text-gray-400",style:{left:h(P(o.value,a,s),f)},children:o.label},`mark-label-${o.value}-${c}`):null)}),d.showHelper&&n("p",{id:d.ids.helper,className:l("mt-1.5 text-sm",N?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:V}),d.message!==void 0&&n("p",{id:d.ids.error,className:"mt-1.5 text-sm text-red-600 dark:text-red-400",children:d.message})]})});we.displayName="Slider";export{we as Slider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var b=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var q=(r,t)=>{for(var o in t)b(r,o,{get:t[o],enumerable:!0})},Z=(r,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of F(t))!W.call(r,n)&&n!==o&&b(r,n,{get:()=>t[n],enumerable:!(l=B(t,n))||l.enumerable});return r};var A=r=>Z(b({},"__esModule",{value:!0}),r);var J={};q(J,{Switch:()=>C});module.exports=A(J);var u=require("react"),a=require("../../lib/cn.cjs"),N=require("../form/shared/field-error.cjs"),e=require("react/jsx-runtime"),G={sm:{track:"h-4 w-7",thumb:"size-2 peer-checked:translate-x-3 rtl:peer-checked:-translate-x-3",label:"text-xs",description:"text-xs"},md:{track:"h-5 w-9",thumb:"size-3 peer-checked:translate-x-4 rtl:peer-checked:-translate-x-4",label:"text-sm",description:"text-xs"},lg:{track:"h-6 w-11",thumb:"size-4 peer-checked:translate-x-5 rtl:peer-checked:-translate-x-5",label:"text-base",description:"text-sm"}},C=(0,u.forwardRef)(({checked:r,defaultChecked:t,onCheckedChange:o,onChange:l,onClick:n,label:f,description:k,error:E,size:z="md",labelPosition:x="right",name:R,value:g,disabled:i=!1,readOnly:d=!1,required:y=!1,id:I,className:S,style:T,"aria-describedby":M,...L},P)=>{let D=(0,u.useId)(),m=I||D,s=(0,N.describeField)(m,{description:k,error:E,own:M}),p=G[z],h=s.invalid,H=c=>{d||(l?.(c),o?.(c.target.checked))},j=c=>{n?.(c),d&&c.preventDefault()},v=(0,e.jsxs)("span",{className:(0,a.cn)("relative inline-flex shrink-0",i&&"opacity-50"),children:[(0,e.jsx)("input",{ref:P,type:"checkbox",role:"switch",id:m,name:R,...g!==void 0&&{value:g},...r!==void 0?{checked:r}:{defaultChecked:t},onChange:H,onClick:j,disabled:i,required:y,"aria-readonly":d||void 0,"aria-invalid":h||void 0,"aria-describedby":s.describedBy,className:(0,a.cn)("peer absolute -inset-1 z-10 m-0 appearance-none opacity-0",i?"cursor-not-allowed":d?"cursor-default":"cursor-pointer"),...L}),(0,e.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("block rounded-full border-2 transition-colors duration-200 motion-reduce:transition-none",p.track,"bg-white dark:bg-gray-800",h?"border-red-600 dark:border-red-400":"border-gray-500 dark:border-gray-400","peer-checked:border-synertech-primary-600 peer-checked:bg-synertech-primary-600","dark:peer-checked:border-synertech-primary-500 dark:peer-checked:bg-synertech-primary-500","peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-solid",h?"peer-focus-visible:outline-red-600 dark:peer-focus-visible:outline-red-400":"peer-focus-visible:outline-synertech-primary-500")}),(0,e.jsx)("span",{"aria-hidden":"true",className:(0,a.cn)("pointer-events-none absolute start-1 top-1 rounded-full transition-[translate,scale,background-color] duration-200 motion-reduce:transition-none",p.thumb,"bg-gray-500 dark:bg-gray-400","peer-checked:scale-125 peer-checked:bg-synertech-on-primary","forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none")})]}),w=!!f||s.hasDescription?(0,e.jsxs)("span",{className:"flex min-w-0 flex-col gap-0.5",children:[f?(0,e.jsxs)("label",{htmlFor:m,className:(0,a.cn)(p.label,i?"cursor-not-allowed text-gray-400 dark:text-gray-500":h?"cursor-pointer text-red-600 dark:text-red-400":d?"cursor-default":"cursor-pointer"),children:[f,y&&(0,e.jsx)("span",{className:"ms-1 text-red-600 dark:text-red-400","aria-hidden":"true",children:"*"})]}):null,s.hasDescription&&(0,e.jsx)("span",{id:s.ids.description,className:(0,a.cn)(p.description,i?"cursor-not-allowed text-gray-400 dark:text-gray-500":"text-gray-500 dark:text-gray-400"),children:k})]}):null;return(0,e.jsxs)("div",{className:(0,a.cn)("inline-flex flex-col",S),style:T,children:[(0,e.jsx)("div",{className:(0,a.cn)("flex items-start gap-3",x==="left"?"justify-between":"justify-start"),children:x==="left"?(0,e.jsxs)(e.Fragment,{children:[w,v]}):(0,e.jsxs)(e.Fragment,{children:[v,w]})}),s.message!==void 0&&(0,e.jsx)("p",{id:s.ids.error,className:"mt-1 text-xs text-red-600 dark:text-red-400",children:s.message})]})});C.displayName="Switch";0&&(module.exports={Switch});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{forwardRef as H,useId as j}from"react";import{cn as t}from"../../lib/cn.js";import{describeField as B}from"../form/shared/field-error.js";import{Fragment as x,jsx as r,jsxs as a}from"react/jsx-runtime";var F={sm:{track:"h-4 w-7",thumb:"size-2 peer-checked:translate-x-3 rtl:peer-checked:-translate-x-3",label:"text-xs",description:"text-xs"},md:{track:"h-5 w-9",thumb:"size-3 peer-checked:translate-x-4 rtl:peer-checked:-translate-x-4",label:"text-sm",description:"text-xs"},lg:{track:"h-6 w-11",thumb:"size-4 peer-checked:translate-x-5 rtl:peer-checked:-translate-x-5",label:"text-base",description:"text-sm"}},W=H(({checked:p,defaultChecked:g,onCheckedChange:y,onChange:v,onClick:w,label:c,description:h,error:N,size:C="md",labelPosition:u="right",name:E,value:f,disabled:s=!1,readOnly:n=!1,required:m=!1,id:z,className:R,style:I,"aria-describedby":S,...T},M)=>{let L=j(),l=z||L,e=B(l,{description:h,error:N,own:S}),i=F[C],d=e.invalid,P=o=>{n||(v?.(o),y?.(o.target.checked))},D=o=>{w?.(o),n&&o.preventDefault()},b=a("span",{className:t("relative inline-flex shrink-0",s&&"opacity-50"),children:[r("input",{ref:M,type:"checkbox",role:"switch",id:l,name:E,...f!==void 0&&{value:f},...p!==void 0?{checked:p}:{defaultChecked:g},onChange:P,onClick:D,disabled:s,required:m,"aria-readonly":n||void 0,"aria-invalid":d||void 0,"aria-describedby":e.describedBy,className:t("peer absolute -inset-1 z-10 m-0 appearance-none opacity-0",s?"cursor-not-allowed":n?"cursor-default":"cursor-pointer"),...T}),r("span",{"aria-hidden":"true",className:t("block rounded-full border-2 transition-colors duration-200 motion-reduce:transition-none",i.track,"bg-white dark:bg-gray-800",d?"border-red-600 dark:border-red-400":"border-gray-500 dark:border-gray-400","peer-checked:border-synertech-primary-600 peer-checked:bg-synertech-primary-600","dark:peer-checked:border-synertech-primary-500 dark:peer-checked:bg-synertech-primary-500","peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-solid",d?"peer-focus-visible:outline-red-600 dark:peer-focus-visible:outline-red-400":"peer-focus-visible:outline-synertech-primary-500")}),r("span",{"aria-hidden":"true",className:t("pointer-events-none absolute start-1 top-1 rounded-full transition-[translate,scale,background-color] duration-200 motion-reduce:transition-none",i.thumb,"bg-gray-500 dark:bg-gray-400","peer-checked:scale-125 peer-checked:bg-synertech-on-primary","forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none")})]}),k=!!c||e.hasDescription?a("span",{className:"flex min-w-0 flex-col gap-0.5",children:[c?a("label",{htmlFor:l,className:t(i.label,s?"cursor-not-allowed text-gray-400 dark:text-gray-500":d?"cursor-pointer text-red-600 dark:text-red-400":n?"cursor-default":"cursor-pointer"),children:[c,m&&r("span",{className:"ms-1 text-red-600 dark:text-red-400","aria-hidden":"true",children:"*"})]}):null,e.hasDescription&&r("span",{id:e.ids.description,className:t(i.description,s?"cursor-not-allowed text-gray-400 dark:text-gray-500":"text-gray-500 dark:text-gray-400"),children:h})]}):null;return a("div",{className:t("inline-flex flex-col",R),style:I,children:[r("div",{className:t("flex items-start gap-3",u==="left"?"justify-between":"justify-start"),children:u==="left"?a(x,{children:[k,b]}):a(x,{children:[b,k]})}),e.message!==void 0&&r("p",{id:e.ids.error,className:"mt-1 text-xs text-red-600 dark:text-red-400",children:e.message})]})});W.displayName="Switch";export{W as Switch};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(o,t)=>{for(var p in t)c(o,p,{get:t[p],enumerable:!0})},m=(o,t,p,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of w(t))!S.call(o,r)&&r!==p&&c(o,r,{get:()=>t[r],enumerable:!(e=i(t,r))||e.enumerable});return o};var x=o=>m(c({},"__esModule",{value:!0}),o);var s={};f(s,{Switch:()=>h.Switch});module.exports=x(s);var h=require("./Switch.cjs");0&&(module.exports={Switch});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Switch as r}from"./Switch.js";export{r as Switch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var c=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var F=(t,
|
|
1
|
+
"use strict";"use client";var c=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var F=(t,o)=>{for(var n in o)c(t,n,{get:o[n],enumerable:!0})},O=(t,o,n,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Z(o))!E.call(t,s)&&s!==n&&c(t,s,{get:()=>o[s],enumerable:!(a=j(o,s))||a.enumerable});return t};var S=t=>O(c({},"__esModule",{value:!0}),t);var X={};F(X,{Toast:()=>v});module.exports=S(X);var i=require("react"),l=require("../../lib/cn.cjs"),y=require("../../lib/i18n.cjs"),C=require("../dropdown/hooks/useLatest.cjs"),e=require("react/jsx-runtime"),U={"top-left":"fixed z-[70] top-4 left-4","top-center":"fixed z-[70] top-4 left-1/2 -translate-x-1/2","top-right":"fixed z-[70] top-4 right-4","bottom-left":"fixed z-[70] bottom-4 left-4","bottom-center":"fixed z-[70] bottom-4 left-1/2 -translate-x-1/2","bottom-right":"fixed z-[70] bottom-4 right-4"};function q({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function A({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function D({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function h({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function G({className:t}){return(0,e.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:(0,e.jsx)("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var J={success:q,error:A,warning:D,info:h,default:h},K={success:{solid:"bg-green-700 text-white border-green-700",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-gray-900 border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},Q={success:"text-green-700 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-700 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function v({children:t,title:o,description:n,type:a="default",variant:s="soft",icon:N,action:g,onClose:u,closable:T=!0,closeLabel:L,position:b,duration:d,className:M,onMouseEnter:R,onMouseLeave:I,onFocus:W,onBlur:H,...P}){let z=(0,y.useUILabels)(),B=J[a],V=(0,e.jsx)(B,{className:"w-5 h-5"}),f=t??n,[m,x]=(0,i.useState)(!1),[p,w]=(0,i.useState)(!1),k=(0,C.useLatest)(u);return(0,i.useEffect)(()=>{if(!d||d<=0||m||p)return;let r=setTimeout(()=>k.current?.(),d);return()=>clearTimeout(r)},[d,m,p,k]),(0,e.jsxs)("div",{role:"alert",className:(0,l.cn)("flex items-start gap-3 p-4 rounded-lg border shadow-lg min-w-[320px] max-w-md","animate-in slide-in-from-top-2 fade-in duration-300",K[a][s],b&&U[b],M),...P,onMouseEnter:r=>{R?.(r),x(!0)},onMouseLeave:r=>{I?.(r),x(!1)},onFocus:r=>{W?.(r),w(!0)},onBlur:r=>{H?.(r),w(!1)},children:[(0,e.jsx)("div",{className:(0,l.cn)("flex-shrink-0 mt-0.5",s!=="solid"&&Q[a]),children:N??V}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[o&&(0,e.jsx)("div",{className:"font-semibold text-sm mb-1",children:o}),f&&(0,e.jsx)("div",{className:"text-sm",children:f}),g&&(0,e.jsx)("div",{className:"mt-3",children:g})]}),T&&(0,e.jsx)("button",{type:"button",onClick:u,className:(0,l.cn)("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":L??z.toastClose,children:(0,e.jsx)(G,{className:"w-4 h-4"})})]})}v.displayName="Toast";0&&(module.exports={Toast});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useEffect as z,useState as p}from"react";import{cn as n}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{useLatest as V}from"../dropdown/hooks/useLatest.js";import{jsx as e,jsxs as k}from"react/jsx-runtime";var j={"top-left":"fixed z-[70] top-4 left-4","top-center":"fixed z-[70] top-4 left-1/2 -translate-x-1/2","top-right":"fixed z-[70] top-4 right-4","bottom-left":"fixed z-[70] bottom-4 left-4","bottom-center":"fixed z-[70] bottom-4 left-1/2 -translate-x-1/2","bottom-right":"fixed z-[70] bottom-4 right-4"};function Z({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function E({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function F({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function w({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function O({className:t}){return e("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var S={success:Z,error:E,warning:F,info:w,default:w},U={success:{solid:"bg-green-700 text-white border-green-700",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-gray-900 border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},q={success:"text-green-700 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-700 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function A({children:t,title:a,description:h,type:s="default",variant:i="soft",icon:y,action:d,onClose:l,closable:C=!0,closeLabel:v,position:c,duration:
|
|
1
|
+
"use client";import{useEffect as z,useState as p}from"react";import{cn as n}from"../../lib/cn.js";import{useUILabels as B}from"../../lib/i18n.js";import{useLatest as V}from"../dropdown/hooks/useLatest.js";import{jsx as e,jsxs as k}from"react/jsx-runtime";var j={"top-left":"fixed z-[70] top-4 left-4","top-center":"fixed z-[70] top-4 left-1/2 -translate-x-1/2","top-right":"fixed z-[70] top-4 right-4","bottom-left":"fixed z-[70] bottom-4 left-4","bottom-center":"fixed z-[70] bottom-4 left-1/2 -translate-x-1/2","bottom-right":"fixed z-[70] bottom-4 right-4"};function Z({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M9 12L11 14L15 10M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function E({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 8V12M12 16H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function F({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.65 18.3 1.55 18.65 1.55 18.99C1.55 19.34 1.64 19.69 1.81 19.99C1.99 20.29 2.24 20.55 2.54 20.72C2.84 20.901 3.18 20.99 3.53 21H20.47C20.82 20.99 21.16 20.901 21.46 20.72C21.76 20.55 22.01 20.29 22.19 19.99C22.36 19.69 22.449 19.34 22.448 18.99C22.447 18.65 22.35 18.3 22.18 18L13.71 3.86C13.53 3.57 13.28 3.32 12.98 3.15C12.68 2.99 12.34 2.9 12 2.9C11.66 2.9 11.32 2.99 11.02 3.15C10.72 3.32 10.47 3.57 10.29 3.86Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function w({className:t}){return e("svg",{className:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M13 16H12V12H11M12 8H12.01M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function O({className:t}){return e("svg",{className:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var S={success:Z,error:E,warning:F,info:w,default:w},U={success:{solid:"bg-green-700 text-white border-green-700",outlined:"bg-white text-green-700 border-green-600 dark:bg-gray-900 dark:text-green-400",soft:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800"},error:{solid:"bg-red-600 text-white border-red-600",outlined:"bg-white text-red-700 border-red-600 dark:bg-gray-900 dark:text-red-400",soft:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800"},warning:{solid:"bg-yellow-500 text-gray-900 border-yellow-500",outlined:"bg-white text-yellow-700 border-yellow-500 dark:bg-gray-900 dark:text-yellow-400",soft:"bg-yellow-50 text-yellow-700 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-400 dark:border-yellow-800"},info:{solid:"bg-blue-600 text-white border-blue-600",outlined:"bg-white text-blue-700 border-blue-600 dark:bg-gray-900 dark:text-blue-400",soft:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-400 dark:border-blue-800"},default:{solid:"bg-gray-700 text-white border-gray-700",outlined:"bg-white text-gray-700 border-gray-300 dark:bg-gray-900 dark:text-gray-300",soft:"bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700"}},q={success:"text-green-700 dark:text-green-400",error:"text-red-600 dark:text-red-400",warning:"text-yellow-700 dark:text-yellow-400",info:"text-blue-600 dark:text-blue-400",default:"text-gray-600 dark:text-gray-400"};function A({children:t,title:a,description:h,type:s="default",variant:i="soft",icon:y,action:d,onClose:l,closable:C=!0,closeLabel:v,position:c,duration:r,className:N,onMouseEnter:T,onMouseLeave:L,onFocus:M,onBlur:R,...I}){let W=B(),H=S[s],P=e(H,{className:"w-5 h-5"}),g=t??h,[u,b]=p(!1),[f,m]=p(!1),x=V(l);return z(()=>{if(!r||r<=0||u||f)return;let o=setTimeout(()=>x.current?.(),r);return()=>clearTimeout(o)},[r,u,f,x]),k("div",{role:"alert",className:n("flex items-start gap-3 p-4 rounded-lg border shadow-lg min-w-[320px] max-w-md","animate-in slide-in-from-top-2 fade-in duration-300",U[s][i],c&&j[c],N),...I,onMouseEnter:o=>{T?.(o),b(!0)},onMouseLeave:o=>{L?.(o),b(!1)},onFocus:o=>{M?.(o),m(!0)},onBlur:o=>{R?.(o),m(!1)},children:[e("div",{className:n("flex-shrink-0 mt-0.5",i!=="solid"&&q[s]),children:y??P}),k("div",{className:"flex-1 min-w-0",children:[a&&e("div",{className:"font-semibold text-sm mb-1",children:a}),g&&e("div",{className:"text-sm",children:g}),d&&e("div",{className:"mt-3",children:d})]}),C&&e("button",{type:"button",onClick:l,className:n("flex-shrink-0 rounded-md p-1 transition-colors hover:bg-black/10 dark:hover:bg-white/10","focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-current"),"aria-label":v??W.toastClose,children:e(O,{className:"w-4 h-4"})})]})}A.displayName="Toast";export{A as Toast};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";"use client";var H=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var ne=(e,n)=>{for(var c in n)H(e,c,{get:n[c],enumerable:!0})},re=(e,n,c,y)=>{if(n&&typeof n=="object"||typeof n=="function")for(let g of te(n))!oe.call(e,g)&&g!==c&&H(e,g,{get:()=>n[g],enumerable:!(y=ee(n,g))||y.enumerable});return e};var se=e=>re(H({},"__esModule",{value:!0}),e);var ve={};ne(ve,{Toaster:()=>z,useToast:()=>pe});module.exports=se(ve);var r=require("react"),E=require("../../lib/cn.cjs"),O=require("../../lib/focus.cjs"),x=require("../../lib/i18n.cjs"),D=require("../../lib/layer-document.cjs"),M=require("../dropdown/hooks/useLatest.cjs"),U=require("./Toast.cjs"),a=require("./toast-store.cjs"),s=require("react/jsx-runtime"),ie=5e3,S=3,ae={"top-left":"top-4 left-4 right-4 sm:right-auto","top-center":"top-4 left-4 right-4 sm:right-auto sm:left-1/2 sm:-translate-x-1/2","top-right":"top-4 right-4 left-4 sm:left-auto","bottom-left":"bottom-4 left-4 right-4 sm:right-auto","bottom-center":"bottom-4 left-4 right-4 sm:right-auto sm:left-1/2 sm:-translate-x-1/2","bottom-right":"bottom-4 right-4 left-4 sm:left-auto"},le={success:{tinted:"bg-green-600 dark:bg-green-400",solid:"bg-white/70"},error:{tinted:"bg-red-600 dark:bg-red-400",solid:"bg-white/70"},warning:{tinted:"bg-yellow-500 dark:bg-yellow-400",solid:"bg-gray-900/50"},info:{tinted:"bg-blue-600 dark:bg-blue-400",solid:"bg-white/70"},default:{tinted:"bg-gray-500 dark:bg-gray-400",solid:"bg-white/70"}};function ce(){return(0,s.jsxs)("svg",{className:"h-5 w-5 motion-safe:animate-spin",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),(0,s.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ue(e,n){let c=Number(e.duration??(e.loading?0:n));return Number.isFinite(c)&&c>0?c:0}function de(e,n){return e.altKey||e.ctrlKey||e.metaKey?!1:e.key===n||e.code===n}function k(e){let n=e.current;return e.current=null,n?.isConnected?(n.focus(),!0):!1}function fe({record:e,paused:n,duration:c,variant:y,closable:g,showProgress:N,onFocusLeaving:p}){let L=(0,r.useRef)(null),v=ue(e,c),{id:h,version:T,closing:b,action:d}=e,l=e.variant??y;(0,r.useEffect)(()=>{if(!v||n||b)return;let i=setTimeout(()=>(0,a.closeToast)(h,"timeout"),v);return()=>clearTimeout(i)},[h,T,v,n,b]);let f=(0,M.useLatest)(p);return(0,r.useLayoutEffect)(()=>{let i=L.current;b&&i&&f.current(i)},[b,f]),(0,r.useLayoutEffect)(()=>{let i=L.current;return()=>{i&&f.current(i)}},[f]),(0,s.jsxs)("li",{ref:L,"data-closing":b?"":void 0,className:(0,E.cn)("relative pointer-events-auto",b&&"pointer-events-none animate-out fade-out duration-150"),children:[(0,s.jsx)(U.Toast,{role:void 0,title:e.title,type:e.type,variant:l,icon:e.icon??(e.loading?(0,s.jsx)(ce,{}):void 0),closable:e.closable??g,onClose:()=>(0,a.closeToast)(h,"close"),className:(0,E.cn)("w-full max-sm:min-w-0 max-sm:max-w-none",e.className),action:d&&(0,s.jsx)("button",{type:"button",className:(0,E.cn)("inline-flex items-center rounded-md border border-current px-2.5 py-1 text-sm font-medium","transition-colors hover:bg-black/5 dark:hover:bg-white/10","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"),onClick:i=>{d.onClick?.(i),i.defaultPrevented||(0,a.closeToast)(h,"action")},children:d.label}),children:e.description}),N&&v>0&&!b&&(0,s.jsx)("div",{"aria-hidden":"true",className:"absolute inset-x-px bottom-px h-0.5 overflow-hidden rounded-b-[7px] motion-reduce:hidden",children:(0,s.jsx)("div",{"data-toast-progress":"",className:(0,E.cn)("h-full origin-left rtl:origin-right",le[e.type][l==="solid"?"solid":"tinted"]),style:n?void 0:{animation:`synertech-toast-countdown ${v}ms linear forwards`}},n?"held":`run-${T}`)})]})}var me=()=>()=>{},ge=()=>!0,be=()=>!1;function z({position:e="bottom-right",max:n=S,duration:c=ie,variant:y="soft",closable:g=!0,showProgress:N=!0,hotkey:p="F8",label:L,className:v}){let h=(0,x.useUILabels)(),T=(0,D.useLayerDocument)(),b=(0,r.useSyncExternalStore)(a.subscribeToasts,a.getToasts,a.getServerToasts),d=(0,r.useSyncExternalStore)(me,ge,be),l=(0,r.useRef)(null),f=(0,r.useRef)(null),i=(0,r.useRef)(!1),P=(0,r.useRef)(!1),[B,K]=(0,r.useState)(!1),[V,A]=(0,r.useState)(!1),[W,_]=(0,r.useState)(!1),$=B||V||W;(0,r.useEffect)(()=>(0,a.registerToaster)(),[]),(0,r.useEffect)(()=>{if(!d)return;let t=l.current,o=t?.ownerDocument??document,u=m=>K(!!t?.contains(m.target)),w=m=>{m.relatedTarget||K(!1)};return o.addEventListener("pointerover",u),o.addEventListener("pointerout",w),()=>{o.removeEventListener("pointerover",u),o.removeEventListener("pointerout",w)}},[d,T]);let q=Number.isFinite(n)&&n>=1?Math.floor(n):S,R=b.slice(-q),X=e.startsWith("top")?[...R].reverse():R,F=R.length>0;(0,r.useEffect)(()=>{if(!d)return;let t=l.current?.ownerDocument??document,o=()=>_(t.visibilityState==="hidden");return o(),t.addEventListener("visibilitychange",o),()=>t.removeEventListener("visibilitychange",o)},[d,T]);let C=(0,M.useLatest)(F);(0,r.useEffect)(()=>{if(!d||p===!1)return;let t=l.current?.ownerDocument??document,o=u=>{u.defaultPrevented||!de(u,p)||C.current&&(u.preventDefault(),i.current=!0,l.current?.focus(),i.current=!1)};return t.addEventListener("keydown",o),()=>t.removeEventListener("keydown",o)},[d,p,C,T]),(0,r.useEffect)(()=>{if(F)return;let t=l.current;t?.contains(t.ownerDocument.activeElement)&&(k(f)||t.blur())},[F]);let j=t=>{let o=l.current,u=t.ownerDocument.activeElement;if(!o||!u||!t.contains(u))return;(Array.from(o.querySelectorAll("li")).some(m=>m!==t&&!m.hasAttribute("data-closing"))||!k(f))&&o.focus()},G=t=>{let o=l.current;if(!o||t.defaultPrevented)return;if(t.key==="Escape"){t.preventDefault(),k(f)||o.blur();return}if(t.key!=="Tab"||!P.current)return;let u=(0,O.getFocusableElements)(o),w=o.ownerDocument.activeElement,m=w?u.indexOf(w):-1,Z=t.shiftKey?m===-1?-1:m-1:m+1,I=u[Z];if(I){t.preventDefault(),I.focus();return}f.current?.isConnected&&(t.preventDefault(),k(f))},J=t=>{let o=t.relatedTarget;o&&l.current?.contains(o)||(f.current=o,P.current=i.current,A(!0))},Q=t=>{let o=t.relatedTarget;o&&l.current?.contains(o)||(P.current=!1,A(!1))};if(!d)return null;let Y=L??(p===!1?h.toasterRegion:(0,x.formatUILabel)(h.toasterRegionHotkey,{hotkey:p}));return(0,s.jsx)(D.LayerPortal,{keepLive:!0,children:(0,s.jsx)("section",{ref:l,"aria-label":Y,tabIndex:-1,"data-position":e,className:(0,E.cn)("fixed z-[70] pointer-events-none sm:w-96","rounded-lg focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-synertech-primary-500",ae[e],v),onKeyDown:G,onFocus:J,onBlur:Q,children:(0,s.jsx)("ol",{"aria-live":"polite","aria-relevant":"additions text",className:"flex flex-col gap-2",children:X.map(t=>(0,s.jsx)(fe,{record:t,paused:$,duration:c,variant:y,closable:g,showProgress:N,onFocusLeaving:j},t.id))})})})}z.displayName="Toaster";function pe(){return a.toast}0&&(module.exports={Toaster,useToast});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useEffect as h,useLayoutEffect as C,useRef as T,useState as R,useSyncExternalStore as I}from"react";import{cn as w}from"../../lib/cn.js";import{getFocusableElements as Z}from"../../lib/focus.js";import{formatUILabel as ee,useUILabels as te}from"../../lib/i18n.js";import{LayerPortal as oe,useLayerDocument as ne}from"../../lib/layer-document.js";import{useLatest as O}from"../dropdown/hooks/useLatest.js";import{Toast as re}from"./Toast.js";import{closeToast as F,getServerToasts as se,getToasts as ie,registerToaster as ae,subscribeToasts as le,toast as ce}from"./toast-store.js";import{jsx as c,jsxs as U}from"react/jsx-runtime";var ue=5e3,S=3,de={"top-left":"top-4 left-4 right-4 sm:right-auto","top-center":"top-4 left-4 right-4 sm:right-auto sm:left-1/2 sm:-translate-x-1/2","top-right":"top-4 right-4 left-4 sm:left-auto","bottom-left":"bottom-4 left-4 right-4 sm:right-auto","bottom-center":"bottom-4 left-4 right-4 sm:right-auto sm:left-1/2 sm:-translate-x-1/2","bottom-right":"bottom-4 right-4 left-4 sm:left-auto"},fe={success:{tinted:"bg-green-600 dark:bg-green-400",solid:"bg-white/70"},error:{tinted:"bg-red-600 dark:bg-red-400",solid:"bg-white/70"},warning:{tinted:"bg-yellow-500 dark:bg-yellow-400",solid:"bg-gray-900/50"},info:{tinted:"bg-blue-600 dark:bg-blue-400",solid:"bg-white/70"},default:{tinted:"bg-gray-500 dark:bg-gray-400",solid:"bg-white/70"}};function me(){return U("svg",{className:"h-5 w-5 motion-safe:animate-spin",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[c("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),c("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ge(t,n){let f=Number(t.duration??(t.loading?0:n));return Number.isFinite(f)&&f>0?f:0}function be(t,n){return t.altKey||t.ctrlKey||t.metaKey?!1:t.key===n||t.code===n}function E(t){let n=t.current;return t.current=null,n?.isConnected?(n.focus(),!0):!1}function pe({record:t,paused:n,duration:f,variant:L,closable:k,showProgress:x,onFocusLeaving:m}){let y=T(null),g=ge(t,f),{id:b,version:p,closing:d,action:a}=t,s=t.variant??L;h(()=>{if(!g||n||d)return;let r=setTimeout(()=>F(b,"timeout"),g);return()=>clearTimeout(r)},[b,p,g,n,d]);let l=O(m);return C(()=>{let r=y.current;d&&r&&l.current(r)},[d,l]),C(()=>{let r=y.current;return()=>{r&&l.current(r)}},[l]),U("li",{ref:y,"data-closing":d?"":void 0,className:w("relative pointer-events-auto",d&&"pointer-events-none animate-out fade-out duration-150"),children:[c(re,{role:void 0,title:t.title,type:t.type,variant:s,icon:t.icon??(t.loading?c(me,{}):void 0),closable:t.closable??k,onClose:()=>F(b,"close"),className:w("w-full max-sm:min-w-0 max-sm:max-w-none",t.className),action:a&&c("button",{type:"button",className:w("inline-flex items-center rounded-md border border-current px-2.5 py-1 text-sm font-medium","transition-colors hover:bg-black/5 dark:hover:bg-white/10","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"),onClick:r=>{a.onClick?.(r),r.defaultPrevented||F(b,"action")},children:a.label}),children:t.description}),x&&g>0&&!d&&c("div",{"aria-hidden":"true",className:"absolute inset-x-px bottom-px h-0.5 overflow-hidden rounded-b-[7px] motion-reduce:hidden",children:c("div",{"data-toast-progress":"",className:w("h-full origin-left rtl:origin-right",fe[t.type][s==="solid"?"solid":"tinted"]),style:n?void 0:{animation:`synertech-toast-countdown ${g}ms linear forwards`}},n?"held":`run-${p}`)})]})}var ve=()=>()=>{},he=()=>!0,ye=()=>!1;function Te({position:t="bottom-right",max:n=S,duration:f=ue,variant:L="soft",closable:k=!0,showProgress:x=!0,hotkey:m="F8",label:y,className:g}){let b=te(),p=ne(),d=I(le,ie,se),a=I(ve,he,ye),s=T(null),l=T(null),r=T(!1),D=T(!1),[z,H]=R(!1),[B,M]=R(!1),[V,W]=R(!1),_=z||B||V;h(()=>ae(),[]),h(()=>{if(!a)return;let e=s.current,o=e?.ownerDocument??document,i=u=>H(!!e?.contains(u.target)),v=u=>{u.relatedTarget||H(!1)};return o.addEventListener("pointerover",i),o.addEventListener("pointerout",v),()=>{o.removeEventListener("pointerover",i),o.removeEventListener("pointerout",v)}},[a,p]);let $=Number.isFinite(n)&&n>=1?Math.floor(n):S,N=d.slice(-$),q=t.startsWith("top")?[...N].reverse():N,P=N.length>0;h(()=>{if(!a)return;let e=s.current?.ownerDocument??document,o=()=>W(e.visibilityState==="hidden");return o(),e.addEventListener("visibilitychange",o),()=>e.removeEventListener("visibilitychange",o)},[a,p]);let K=O(P);h(()=>{if(!a||m===!1)return;let e=s.current?.ownerDocument??document,o=i=>{i.defaultPrevented||!be(i,m)||K.current&&(i.preventDefault(),r.current=!0,s.current?.focus(),r.current=!1)};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)},[a,m,K,p]),h(()=>{if(P)return;let e=s.current;e?.contains(e.ownerDocument.activeElement)&&(E(l)||e.blur())},[P]);let X=e=>{let o=s.current,i=e.ownerDocument.activeElement;if(!o||!i||!e.contains(i))return;(Array.from(o.querySelectorAll("li")).some(u=>u!==e&&!u.hasAttribute("data-closing"))||!E(l))&&o.focus()},j=e=>{let o=s.current;if(!o||e.defaultPrevented)return;if(e.key==="Escape"){e.preventDefault(),E(l)||o.blur();return}if(e.key!=="Tab"||!D.current)return;let i=Z(o),v=o.ownerDocument.activeElement,u=v?i.indexOf(v):-1,Y=e.shiftKey?u===-1?-1:u-1:u+1,A=i[Y];if(A){e.preventDefault(),A.focus();return}l.current?.isConnected&&(e.preventDefault(),E(l))},G=e=>{let o=e.relatedTarget;o&&s.current?.contains(o)||(l.current=o,D.current=r.current,M(!0))},J=e=>{let o=e.relatedTarget;o&&s.current?.contains(o)||(D.current=!1,M(!1))};if(!a)return null;let Q=y??(m===!1?b.toasterRegion:ee(b.toasterRegionHotkey,{hotkey:m}));return c(oe,{keepLive:!0,children:c("section",{ref:s,"aria-label":Q,tabIndex:-1,"data-position":t,className:w("fixed z-[70] pointer-events-none sm:w-96","rounded-lg focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-synertech-primary-500",de[t],g),onKeyDown:j,onFocus:G,onBlur:J,children:c("ol",{"aria-live":"polite","aria-relevant":"additions text",className:"flex flex-col gap-2",children:q.map(e=>c(pe,{record:e,paused:_,duration:f,variant:L,closable:k,showProgress:x,onFocusLeaving:X},e.id))})})})}Te.displayName="Toaster";function Re(){return ce}export{Te as Toaster,Re as useToast};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var x=(t,o)=>{for(var a in o)r(t,a,{get:o[a],enumerable:!0})},P=(t,o,a,T)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of n(o))!f.call(t,s)&&s!==a&&r(t,s,{get:()=>o[s],enumerable:!(T=m(o,s))||T.enumerable});return t};var y=t=>P(r({},"__esModule",{value:!0}),t);var g={};x(g,{Toast:()=>p.Toast,Toaster:()=>e.Toaster,toast:()=>i.toast,useToast:()=>e.useToast});module.exports=y(g);var p=require("./Toast.cjs"),e=require("./Toaster.cjs"),i=require("./toast-store.cjs");0&&(module.exports={Toast,Toaster,toast,useToast});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Toast as
|
|
1
|
+
import{Toast as s}from"./Toast.js";import{Toaster as e,useToast as r}from"./Toaster.js";import{toast as p}from"./toast-store.js";export{s as Toast,e as Toaster,p as toast,r as useToast};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var g=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var o in t)g(e,o,{get:t[o],enumerable:!0})},h=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of P(t))!M.call(e,n)&&n!==o&&g(e,n,{get:()=>t[n],enumerable:!(s=w(t,n))||s.enumerable});return e};var b=e=>h(g({},"__esModule",{value:!0}),e);var I={};C(I,{TOAST_EXIT_MS:()=>V,closeToast:()=>y,getServerToasts:()=>E,getToasts:()=>A,registerToaster:()=>j,resetToastStore:()=>H,subscribeToasts:()=>S,toast:()=>B});module.exports=b(I);var N=require("react"),V=150,R=[],a=R,p=new Set,i=new Map,x=0,c=0,T=!1,m=!1;function f(e){a=e;for(let t of p)t()}function S(e){return p.add(e),()=>{p.delete(e)}}function A(){return a}function E(){return R}function j(){return c+=1,c>1&&!m&&(m=!0,console.warn("[@synertech/ui] Several <Toaster /> are mounted: each one draws every toast. Mount one, near the root of the application.")),()=>{c-=1}}function k(e){let t=i.get(e);t!==void 0&&(clearTimeout(t),i.delete(e))}function d(e,t,o){let s=t?.id??`synertech-toast-${++x}`;if(typeof document>"u")return s;let n=a.find(l=>l.id===s),r={type:"default",...t,...o,id:s,title:e,loading:o.loading??!1,version:n?n.version+1:0,closing:!1};return n?(k(s),f(a.map(l=>l.id===s?r:l))):f([...a,r]),c===0&&!T&&setTimeout(()=>{c>0||T||(T=!0,console.warn("[@synertech/ui] toast() was called and no <Toaster /> is mounted: the toast waits, and is drawn when one is."))},0),s}function y(e,t){let o=a.find(s=>s.id===e);!o||o.closing||(f(a.map(s=>s.id===e?{...s,closing:!0}:s)),i.set(e,setTimeout(()=>{i.delete(e),f(a.filter(s=>s.id!==e))},V)),o.onClose?.(t))}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(0,N.isValidElement)(e)&&"title"in e}function O(e,t,o){if(!_(e))return d(e,t,o);let{title:s,...n}=e;return d(s,{...t,...n},o)}function v(e,t,o,s,n){if(t===void 0){y(e,"dismiss");return}let r=typeof t=="function"?t(o):t;O(r,{...s,id:e},{type:n})}function u(e){return(t,o)=>d(t,o,{type:e})}var B=Object.assign((e,t)=>d(e,t,{}),{success:u("success"),error:u("error"),warning:u("warning"),info:u("info"),loading:(e,t)=>d(e,t,{loading:!0}),promise(e,t,o){let s=typeof e=="function"?new Promise(r=>r(e())):e,n=O(t.loading,{...o,duration:void 0},{loading:!0});return s.then(r=>v(n,t.success,r,o,"success"),r=>v(n,t.error,r,o,"error")),s},dismiss(e){let t=e===void 0?a.map(o=>o.id):[e];for(let o of t)y(o,"dismiss")}});function H(){for(let e of i.values())clearTimeout(e);i.clear(),a=R,x=0,T=!1,m=!1;for(let e of p)e()}0&&(module.exports={TOAST_EXIT_MS,closeToast,getServerToasts,getToasts,registerToaster,resetToastStore,subscribeToasts,toast});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isValidElement as V}from"react";var x=150,m=[],a=m,p=new Set,i=new Map,y=0,c=0,T=!1,g=!1;function f(e){a=e;for(let t of p)t()}function M(e){return p.add(e),()=>{p.delete(e)}}function C(){return a}function h(){return m}function b(){return c+=1,c>1&&!g&&(g=!0,console.warn("[@synertech/ui] Several <Toaster /> are mounted: each one draws every toast. Mount one, near the root of the application.")),()=>{c-=1}}function O(e){let t=i.get(e);t!==void 0&&(clearTimeout(t),i.delete(e))}function d(e,t,o){let s=t?.id??`synertech-toast-${++y}`;if(typeof document>"u")return s;let n=a.find(l=>l.id===s),r={type:"default",...t,...o,id:s,title:e,loading:o.loading??!1,version:n?n.version+1:0,closing:!1};return n?(O(s),f(a.map(l=>l.id===s?r:l))):f([...a,r]),c===0&&!T&&setTimeout(()=>{c>0||T||(T=!0,console.warn("[@synertech/ui] toast() was called and no <Toaster /> is mounted: the toast waits, and is drawn when one is."))},0),s}function v(e,t){let o=a.find(s=>s.id===e);!o||o.closing||(f(a.map(s=>s.id===e?{...s,closing:!0}:s)),i.set(e,setTimeout(()=>{i.delete(e),f(a.filter(s=>s.id!==e))},x)),o.onClose?.(t))}function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!V(e)&&"title"in e}function N(e,t,o){if(!w(e))return d(e,t,o);let{title:s,...n}=e;return d(s,{...t,...n},o)}function R(e,t,o,s,n){if(t===void 0){v(e,"dismiss");return}let r=typeof t=="function"?t(o):t;N(r,{...s,id:e},{type:n})}function u(e){return(t,o)=>d(t,o,{type:e})}var S=Object.assign((e,t)=>d(e,t,{}),{success:u("success"),error:u("error"),warning:u("warning"),info:u("info"),loading:(e,t)=>d(e,t,{loading:!0}),promise(e,t,o){let s=typeof e=="function"?new Promise(r=>r(e())):e,n=N(t.loading,{...o,duration:void 0},{loading:!0});return s.then(r=>R(n,t.success,r,o,"success"),r=>R(n,t.error,r,o,"error")),s},dismiss(e){let t=e===void 0?a.map(o=>o.id):[e];for(let o of t)v(o,"dismiss")}});function A(){for(let e of i.values())clearTimeout(e);i.clear(),a=m,y=0,T=!1,g=!1;for(let e of p)e()}export{x as TOAST_EXIT_MS,v as closeToast,h as getServerToasts,C as getToasts,b as registerToaster,A as resetToastStore,M as subscribeToasts,S as toast};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var N=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.prototype.hasOwnProperty;var K=(e,r)=>{for(var s in r)N(e,s,{get:r[s],enumerable:!0})},Q=(e,r,s,b)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of G(r))!J.call(e,i)&&i!==s&&N(e,i,{get:()=>r[i],enumerable:!(b=q(r,i))||b.enumerable});return e};var U=e=>Q(N({},"__esModule",{value:!0}),e);var et={};K(et,{Tooltip:()=>B});module.exports=U(et);var t=require("react"),A=require("react-dom"),S=require("../dropdown/hooks/usePositioning.cjs"),V=require("../../lib/aria-hide.cjs"),E=require("../../lib/owner-document.cjs"),R=require("../../lib/cn.cjs"),f=require("react/jsx-runtime"),X={default:"bg-gray-900 text-white dark:bg-gray-700",light:"bg-white text-gray-900 border border-gray-200 shadow-lg dark:bg-gray-800 dark:text-white dark:border-gray-600",error:"bg-red-600 text-white",success:"bg-green-700 text-white",warning:"bg-yellow-500 text-gray-900",info:"bg-blue-600 text-white"},Y={default:{top:"border-t-gray-900 dark:border-t-gray-700",bottom:"border-b-gray-900 dark:border-b-gray-700",left:"border-l-gray-900 dark:border-l-gray-700",right:"border-r-gray-900 dark:border-r-gray-700"},light:{top:"border-t-white dark:border-t-gray-800",bottom:"border-b-white dark:border-b-gray-800",left:"border-l-white dark:border-l-gray-800",right:"border-r-white dark:border-r-gray-800"},error:{top:"border-t-red-600",bottom:"border-b-red-600",left:"border-l-red-600",right:"border-r-red-600"},success:{top:"border-t-green-700",bottom:"border-b-green-700",left:"border-l-green-700",right:"border-r-green-700"},warning:{top:"border-t-yellow-500",bottom:"border-b-yellow-500",left:"border-l-yellow-500",right:"border-r-yellow-500"},info:{top:"border-t-blue-600",bottom:"border-b-blue-600",left:"border-l-blue-600",right:"border-r-blue-600"}},Z={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},_={sm:"border-4",md:"border-[5px]",lg:"border-[6px]"},$={top:"top-full -translate-x-1/2 border-l-transparent border-r-transparent border-b-transparent",bottom:"bottom-full -translate-x-1/2 border-l-transparent border-r-transparent border-t-transparent",left:"left-full -translate-y-1/2 border-t-transparent border-b-transparent border-r-transparent",right:"right-full -translate-y-1/2 border-t-transparent border-b-transparent border-l-transparent"};function tt({anchorRef:e,content:r,position:s,offset:b,variant:i,size:p,showArrow:v,maxWidth:g,contentClassName:k}){let c=(0,t.useRef)(null),o=(0,S.usePositioning)({triggerRef:e,contentRef:c,isOpen:!0,side:s,align:"center",sideOffset:b}),d=o.actualSide,l=d==="top"||d==="bottom",[y,C]=(0,t.useState)(null);return(0,t.useLayoutEffect)(()=>{if(!o.isReady)return;let a=e.current?.getBoundingClientRect(),m=c.current?.getBoundingClientRect();if(!a||!m)return;let M=l?a.left+a.width/2-o.left:a.top+a.height/2-o.top,P=l?m.width:m.height;C(Math.min(Math.max(M,10),Math.max(10,P-10)))},[e,o.isReady,o.top,o.left,l]),(0,t.useEffect)(()=>{let a=c.current;if(a)return(0,V.registerFloatingLayer)(a,()=>e.current)},[e]),(0,f.jsxs)("div",{ref:c,role:"tooltip","data-side":d,style:{position:"fixed",top:o.top,left:o.left,opacity:o.isReady?1:0},className:(0,R.cn)("z-[70] whitespace-normal wrap-break-word rounded-md","transition-opacity duration-150",X[i],Z[p],g,k),children:[r,v&&(0,f.jsx)("span",{className:(0,R.cn)("absolute w-0 h-0 border-solid",_[p],$[d],Y[i][d]),style:l?{left:y??"50%"}:{top:y??"50%"},"aria-hidden":"true"})]})}function B({children:e,content:r,position:s="top",variant:b="default",size:i="md",trigger:p="hover",open:v,delay:g=0,showArrow:k=!0,maxWidth:c="max-w-xs",className:o,contentClassName:d,disabled:l=!1,offset:y,onMouseEnter:C,onMouseLeave:a,onFocus:m,onBlur:M,onClick:P,...H}){let[O,T]=(0,t.useState)(!1),h=(0,t.useRef)(null),w=(0,t.useRef)(null),[D,W]=(0,t.useState)(!1);(0,t.useEffect)(()=>W(!0),[]);let u=(0,t.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]);(0,t.useEffect)(()=>u,[u]);let z=(0,t.useCallback)(()=>{l||(u(),g>0?h.current=setTimeout(()=>{h.current=null,T(!0)},g):T(!0))},[g,l,u]),L=(0,t.useCallback)(()=>{u(),T(!1)},[u]),F=(0,t.useCallback)(()=>{l||T(n=>!n)},[l]),j=p==="manual"?v:O,x=p==="hover",I=p==="click";return(0,f.jsxs)("div",{ref:w,className:(0,R.cn)("relative inline-flex",o),...H,onMouseEnter:n=>{C?.(n),x&&z()},onMouseLeave:n=>{a?.(n),x&&L()},onFocus:n=>{m?.(n),x&&z()},onBlur:n=>{M?.(n),x&&L()},onClick:n=>{P?.(n),I&&F()},children:[e,j&&!l&&D&&w.current?(0,A.createPortal)((0,f.jsx)(tt,{anchorRef:w,content:r,position:s,offset:y??8,variant:b,size:i,showArrow:k,maxWidth:c,contentClassName:d}),(0,E.ownerDocumentOf)(w.current).body):null]})}B.displayName="Tooltip";0&&(module.exports={Tooltip});
|