@synertech/ui 0.46.1 → 0.46.3
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/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/badge/Badge.cjs +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/banner/Banner.cjs +1 -1
- package/dist/components/banner/Banner.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.cjs +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/calendar/Calendar.cjs +1 -1
- package/dist/components/calendar/Calendar.js +1 -1
- package/dist/components/chart/ChartLegend.cjs +1 -1
- package/dist/components/chart/ChartLegend.js +1 -1
- 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/chip/Chip.cjs +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/circular-progress/CircularProgress.cjs +1 -1
- package/dist/components/circular-progress/CircularProgress.js +1 -1
- package/dist/components/datagrid/DataGrid.cjs +1 -1
- package/dist/components/datagrid/DataGrid.js +1 -1
- package/dist/components/device-mockup/DeviceMockup.cjs +1 -1
- package/dist/components/device-mockup/DeviceMockup.js +1 -1
- package/dist/components/drawer/Drawer.cjs +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/dropdown/DropdownItem.cjs +1 -1
- package/dist/components/dropdown/DropdownItem.js +1 -1
- package/dist/components/dropdown/DropdownRadio.cjs +1 -1
- package/dist/components/dropdown/DropdownRadio.js +1 -1
- package/dist/components/dropdown/DropdownSubMenu.cjs +1 -1
- package/dist/components/dropdown/DropdownSubMenu.js +1 -1
- package/dist/components/dropdown/DropdownTrigger.cjs +1 -1
- package/dist/components/dropdown/DropdownTrigger.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/form/mention-input/MentionInput.cjs +1 -1
- package/dist/components/form/mention-input/MentionInput.js +1 -1
- 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 +2 -2
- package/dist/components/help-button/HelpButton.js +3 -3
- package/dist/components/image-uploader/ImageUploader.cjs +1 -1
- package/dist/components/image-uploader/ImageUploader.js +1 -1
- package/dist/components/indicator/Indicator.cjs +1 -1
- package/dist/components/indicator/Indicator.js +1 -1
- package/dist/components/label/Label.cjs +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/modal/Modal.cjs +1 -1
- package/dist/components/modal/Modal.js +1 -1
- package/dist/components/pagination/Pagination.cjs +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/progress-bar/ProgressBar.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/schema-editor/SchemaEditor.cjs +1 -1
- package/dist/components/schema-editor/SchemaEditor.js +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.cjs +1 -1
- package/dist/components/schema-editor/legend/SchemaLegend.js +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.cjs +1 -1
- package/dist/components/schema-editor/relations/SchemaRelationRenderer.js +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.cjs +1 -1
- package/dist/components/schema-editor/tables/SchemaTableRenderer.js +1 -1
- package/dist/components/schema-editor/utils/foreign-keys.cjs +1 -0
- package/dist/components/schema-editor/utils/foreign-keys.js +1 -0
- package/dist/components/schema-editor/utils/geometry.cjs +1 -1
- package/dist/components/schema-editor/utils/geometry.js +1 -1
- package/dist/components/schema-editor/utils/sql-export.cjs +5 -5
- package/dist/components/schema-editor/utils/sql-export.js +5 -5
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/sidebar/Sidebar.cjs +1 -1
- package/dist/components/sidebar/Sidebar.js +1 -1
- package/dist/components/slider/Slider.cjs +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/stat-card/StatCard.cjs +1 -1
- package/dist/components/stat-card/StatCard.js +1 -1
- package/dist/components/table/TableHeader.cjs +1 -1
- package/dist/components/table/TableHeader.js +1 -1
- package/dist/components/tabs/TabsTrigger.cjs +1 -1
- package/dist/components/tabs/TabsTrigger.js +1 -1
- package/dist/components/toast/Toast.cjs +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/tooltip/Tooltip.cjs +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/wizard/Wizard.cjs +1 -1
- package/dist/components/wizard/Wizard.js +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.cjs +1 -1
- package/dist/components/workflow-editor/WorkflowEditor.js +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/lib/editable-target.cjs +1 -0
- package/dist/lib/editable-target.js +1 -0
- package/dist/styles.css +82 -143
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useCallback as M,useId as S,useRef as E}from"react";import{createPortal as O}from"react-dom";import{useDialogA11y as T}from"../../hooks/useDialogA11y.js";import{cn as n}from"../../lib/cn.js";import{useUILabels as j}from"../../lib/i18n.js";import{Fragment as $,jsx as e,jsxs as s}from"react/jsx-runtime";var A={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},B={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},g={left:{enter:"animate-in slide-in-from-left duration-300",exit:"animate-out slide-out-to-left duration-200"},right:{enter:"animate-in slide-in-from-right duration-300",exit:"animate-out slide-out-to-right duration-200"},top:{enter:"animate-in slide-in-from-top duration-300",exit:"animate-out slide-out-to-top duration-200"},bottom:{enter:"animate-in slide-in-from-bottom duration-300",exit:"animate-out slide-out-to-bottom duration-200"}},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:t,onClose:o,children:h,position:r="right",size:b="md",customWidth:
|
|
1
|
+
"use client";import{useCallback as M,useId as S,useRef as E}from"react";import{createPortal as O}from"react-dom";import{useDialogA11y as T}from"../../hooks/useDialogA11y.js";import{cn as n}from"../../lib/cn.js";import{useUILabels as j}from"../../lib/i18n.js";import{Fragment as $,jsx as e,jsxs as s}from"react/jsx-runtime";var A={left:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},right:{sm:"w-64",md:"w-80",lg:"w-96",xl:"w-[32rem]",full:"w-full",half:"w-1/2 h-full"},top:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"},bottom:{sm:"h-64",md:"h-80",lg:"h-96",xl:"h-[32rem]",full:"h-full",half:"w-1/2 h-full"}},B={left:"left-0 top-0 bottom-0",right:"right-0 top-0 bottom-0",top:"top-0 left-0 right-0",bottom:"bottom-0 left-0 right-0"},g={left:{enter:"animate-in slide-in-from-left duration-300",exit:"animate-out slide-out-to-left duration-200"},right:{enter:"animate-in slide-in-from-right duration-300",exit:"animate-out slide-out-to-right duration-200"},top:{enter:"animate-in slide-in-from-top duration-300",exit:"animate-out slide-out-to-top duration-200"},bottom:{enter:"animate-in slide-in-from-bottom duration-300",exit:"animate-out slide-out-to-bottom duration-200"}},H=e("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})});function U({open:t,onClose:o,children:h,position:r="right",size:b="md",customWidth:i,customHeight:l,showOverlay:p=!0,closeOnOverlayClick:d=!0,closeOnEscape:w=!0,title:a,footer:u,className:y,overlayClassName:x,closeLabel:v,"aria-label":D,trapFocus:k=!0,initialFocus:N,returnFocus:R,lockScroll:C=!0}){let I=!!(i||l),f=E(null),P=j(),m=`${S()}-drawer-title`,{dialogRef:z,dialogProps:F}=T({open:t,onClose:o,closeOnEscape:w,trapFocus:k,initialFocus:N,returnFocus:R,lockScroll:C,keepInteractive:[f]}),L=M(()=>{d&&o()},[d,o]);if(!t)return null;let c=s($,{children:[p&&e("div",{ref:f,className:n("fixed inset-0 bg-black/50 z-40 transition-opacity",t?"animate-in fade-in duration-200":"animate-out fade-out duration-150",x),onClick:L,"aria-hidden":"true"}),s("div",{ref:z,...F,"aria-labelledby":a?m:void 0,"aria-label":a?void 0:D,className:n("fixed z-50 bg-white dark:bg-gray-900","shadow-xl overflow-hidden","flex flex-col focus:outline-none",B[r],!I&&A[r][b],t?g[r].enter:g[r].exit,y),style:{...i?{width:i}:{},...l?{height:l}:{}},children:[a&&s("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[e("h2",{id:m,className:"text-lg font-semibold text-gray-900 dark:text-white",children:a}),e("button",{type:"button",onClick:o,className:n("rounded-lg p-1.5 text-gray-500 dark:text-gray-400 hover:bg-gray-100 hover:text-gray-900","dark:hover:bg-gray-800 dark:hover:text-white","focus:outline-none focus:ring-2 focus:ring-gray-300 dark:focus:ring-gray-600"),"aria-label":v??P.closeDrawer,children:H})]}),e("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:h}),u&&e("div",{className:"px-6 py-4 border-t border-gray-200 dark:border-gray-700",children:u})]})]});return typeof document<"u"?O(c,document.body):c}U.displayName="Drawer";export{U as Drawer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},E=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!w.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(a=v(e,r))||a.enumerable});return t};var M=t=>E(c({},"__esModule",{value:!0}),t);var R={};C(R,{DropdownItem:()=>u});module.exports=M(R);var d=require("./Dropdown.cjs"),p=require("../../lib/cn.cjs"),n=require("react/jsx-runtime"),O={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-
|
|
1
|
+
"use strict";"use client";var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},E=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!w.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(a=v(e,r))||a.enumerable});return t};var M=t=>E(c({},"__esModule",{value:!0}),t);var R={};C(R,{DropdownItem:()=>u});module.exports=M(R);var d=require("./Dropdown.cjs"),p=require("../../lib/cn.cjs"),n=require("react/jsx-runtime"),O={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"};function u({children:t,icon:e,iconPosition:o="left",description:a,shortcut:r,variant:i="default",closeOnSelect:m,onSelect:g,disabled:s=!1,className:f,onClick:x,index:S,...h}){let{setIsOpen:b,closeOnSelect:k}=(0,d.useDropdownContext)(),y=m??k;return(0,n.jsxs)("button",{role:"menuitem",type:"button",tabIndex:-1,disabled:s,"data-disabled":s||void 0,onClick:l=>{s||(g?.(),x?.(l),y&&b(!1))},onMouseEnter:l=>{s||l.currentTarget.focus({preventScroll:!0})},className:(0,p.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","focus:bg-gray-100 dark:focus:bg-gray-700",O[i],s&&"opacity-50 cursor-not-allowed hover:bg-transparent",f),...h,children:[e&&o==="left"&&(0,n.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:e}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block truncate",children:t}),a&&(0,n.jsx)("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]}),e&&o==="right"&&(0,n.jsx)("span",{className:"ml-2 shrink-0 w-5 h-5",children:e}),r&&(0,n.jsx)("span",{className:"ml-auto pl-4 text-xs text-gray-500 dark:text-gray-400",children:r})]})}u.displayName="DropdownItem";0&&(module.exports={DropdownItem});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDropdownContext as b}from"./Dropdown.js";import{cn as k}from"../../lib/cn.js";import{jsx as t,jsxs as l}from"react/jsx-runtime";var y={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-
|
|
1
|
+
"use client";import{useDropdownContext as b}from"./Dropdown.js";import{cn as k}from"../../lib/cn.js";import{jsx as t,jsxs as l}from"react/jsx-runtime";var y={default:"text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",danger:"text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",success:"text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-900/20"};function v({children:c,icon:n,iconPosition:o="left",description:a,shortcut:s,variant:d="default",closeOnSelect:p,onSelect:u,disabled:e=!1,className:i,onClick:m,index:N,...g}){let{setIsOpen:f,closeOnSelect:x}=b(),h=p??x;return l("button",{role:"menuitem",type:"button",tabIndex:-1,disabled:e,"data-disabled":e||void 0,onClick:r=>{e||(u?.(),m?.(r),h&&f(!1))},onMouseEnter:r=>{e||r.currentTarget.focus({preventScroll:!0})},className:k("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","focus:bg-gray-100 dark:focus:bg-gray-700",y[d],e&&"opacity-50 cursor-not-allowed hover:bg-transparent",i),...g,children:[n&&o==="left"&&t("span",{className:"mr-2 shrink-0 w-5 h-5",children:n}),l("span",{className:"flex-1 min-w-0",children:[t("span",{className:"block truncate",children:c}),a&&t("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:a})]}),n&&o==="right"&&t("span",{className:"ml-2 shrink-0 w-5 h-5",children:n}),s&&t("span",{className:"ml-auto pl-4 text-xs text-gray-500 dark:text-gray-400",children:s})]})}v.displayName="DropdownItem";export{v as DropdownItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var y=(e,o)=>{for(var r in o)m(e,r,{get:o[r],enumerable:!0})},N=(e,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of C(o))!k.call(e,t)&&t!==r&&m(e,t,{get:()=>o[t],enumerable:!(s=R(o,t))||s.enumerable});return e};var D=e=>N(m({},"__esModule",{value:!0}),e);var V={};y(V,{DropdownRadioGroup:()=>b,DropdownRadioItem:()=>v});module.exports=D(V);var a=require("react"),x=require("./Dropdown.cjs"),f=require("../../lib/cn.cjs"),n=require("react/jsx-runtime"),h=(0,a.createContext)(null);function G(){let e=(0,a.useContext)(h);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function b({value:e,defaultValue:o="",onValueChange:r,children:s,className:t}){let[c,p]=(0,a.useState)(o),u=e!==void 0,i=u?e:c,d=(0,a.useCallback)(g=>{u||p(g),r?.(g)},[u,r]),l=(0,a.useMemo)(()=>({value:i,onValueChange:d}),[i,d]);return(0,n.jsx)(h.Provider,{value:l,children:(0,n.jsx)("div",{role:"group",className:t,children:s})})}b.displayName="DropdownRadioGroup";function v({value:e,children:o,icon:r,description:s,disabled:t=!1,closeOnChange:c=!0,className:p}){let{value:u,onValueChange:i}=G(),{setIsOpen:d}=(0,x.useDropdownContext)(),l=u===e;return(0,n.jsxs)("button",{role:"menuitemradio",type:"button",tabIndex:-1,"aria-checked":l,disabled:t,"data-disabled":t||void 0,onClick:()=>{t||(i(e),c&&d(!1))},onMouseEnter:w=>{t||w.currentTarget.focus({preventScroll:!0})},className:(0,f.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",t&&"opacity-50 cursor-not-allowed hover:bg-transparent",p),children:[(0,n.jsx)("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||(0,n.jsx)("span",{className:(0,f.cn)("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",l?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:l&&(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block truncate",children:o}),s&&(0,n.jsx)("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:s})]}),l&&!r&&(0,n.jsx)("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}v.displayName="DropdownRadioItem";0&&(module.exports={DropdownRadioGroup,DropdownRadioItem});
|
|
1
|
+
"use strict";"use client";var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var y=(e,o)=>{for(var r in o)m(e,r,{get:o[r],enumerable:!0})},N=(e,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of C(o))!k.call(e,t)&&t!==r&&m(e,t,{get:()=>o[t],enumerable:!(s=R(o,t))||s.enumerable});return e};var D=e=>N(m({},"__esModule",{value:!0}),e);var V={};y(V,{DropdownRadioGroup:()=>b,DropdownRadioItem:()=>v});module.exports=D(V);var a=require("react"),x=require("./Dropdown.cjs"),f=require("../../lib/cn.cjs"),n=require("react/jsx-runtime"),h=(0,a.createContext)(null);function G(){let e=(0,a.useContext)(h);if(!e)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return e}function b({value:e,defaultValue:o="",onValueChange:r,children:s,className:t}){let[c,p]=(0,a.useState)(o),u=e!==void 0,i=u?e:c,d=(0,a.useCallback)(g=>{u||p(g),r?.(g)},[u,r]),l=(0,a.useMemo)(()=>({value:i,onValueChange:d}),[i,d]);return(0,n.jsx)(h.Provider,{value:l,children:(0,n.jsx)("div",{role:"group",className:t,children:s})})}b.displayName="DropdownRadioGroup";function v({value:e,children:o,icon:r,description:s,disabled:t=!1,closeOnChange:c=!0,className:p}){let{value:u,onValueChange:i}=G(),{setIsOpen:d}=(0,x.useDropdownContext)(),l=u===e;return(0,n.jsxs)("button",{role:"menuitemradio",type:"button",tabIndex:-1,"aria-checked":l,disabled:t,"data-disabled":t||void 0,onClick:()=>{t||(i(e),c&&d(!1))},onMouseEnter:w=>{t||w.currentTarget.focus({preventScroll:!0})},className:(0,f.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",t&&"opacity-50 cursor-not-allowed hover:bg-transparent",p),children:[(0,n.jsx)("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||(0,n.jsx)("span",{className:(0,f.cn)("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",l?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:l&&(0,n.jsx)("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block truncate",children:o}),s&&(0,n.jsx)("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:s})]}),l&&!r&&(0,n.jsx)("svg",{className:"ml-auto w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}v.displayName="DropdownRadioItem";0&&(module.exports={DropdownRadioGroup,DropdownRadioItem});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as h,useCallback as b,useMemo as v,createContext as w,useContext as R}from"react";import{useDropdownContext as C}from"./Dropdown.js";import{cn as g}from"../../lib/cn.js";import{jsx as e,jsxs as m}from"react/jsx-runtime";var f=w(null);function k(){let o=R(f);if(!o)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return o}function y({value:o,defaultValue:i="",onValueChange:r,children:s,className:t}){let[d,c]=h(i),a=o!==void 0,l=a?o:d,u=b(p=>{a||c(p),r?.(p)},[a,r]),n=v(()=>({value:l,onValueChange:u}),[l,u]);return e(f.Provider,{value:n,children:e("div",{role:"group",className:t,children:s})})}y.displayName="DropdownRadioGroup";function N({value:o,children:i,icon:r,description:s,disabled:t=!1,closeOnChange:d=!0,className:c}){let{value:a,onValueChange:l}=k(),{setIsOpen:u}=C(),n=a===o;return m("button",{role:"menuitemradio",type:"button",tabIndex:-1,"aria-checked":n,disabled:t,"data-disabled":t||void 0,onClick:()=>{t||(l(o),d&&u(!1))},onMouseEnter:x=>{t||x.currentTarget.focus({preventScroll:!0})},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",t&&"opacity-50 cursor-not-allowed hover:bg-transparent",c),children:[e("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||e("span",{className:g("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",n?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:n&&e("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),m("span",{className:"flex-1 min-w-0",children:[e("span",{className:"block truncate",children:i}),s&&e("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:s})]}),n&&!r&&e("svg",{className:"ml-auto w-4 h-4 text-blue-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}N.displayName="DropdownRadioItem";export{y as DropdownRadioGroup,N as DropdownRadioItem};
|
|
1
|
+
"use client";import{useState as h,useCallback as b,useMemo as v,createContext as w,useContext as R}from"react";import{useDropdownContext as C}from"./Dropdown.js";import{cn as g}from"../../lib/cn.js";import{jsx as e,jsxs as m}from"react/jsx-runtime";var f=w(null);function k(){let o=R(f);if(!o)throw new Error("DropdownRadioItem must be used within a DropdownRadioGroup");return o}function y({value:o,defaultValue:i="",onValueChange:r,children:s,className:t}){let[d,c]=h(i),a=o!==void 0,l=a?o:d,u=b(p=>{a||c(p),r?.(p)},[a,r]),n=v(()=>({value:l,onValueChange:u}),[l,u]);return e(f.Provider,{value:n,children:e("div",{role:"group",className:t,children:s})})}y.displayName="DropdownRadioGroup";function N({value:o,children:i,icon:r,description:s,disabled:t=!1,closeOnChange:d=!0,className:c}){let{value:a,onValueChange:l}=k(),{setIsOpen:u}=C(),n=a===o;return m("button",{role:"menuitemradio",type:"button",tabIndex:-1,"aria-checked":n,disabled:t,"data-disabled":t||void 0,onClick:()=>{t||(l(o),d&&u(!1))},onMouseEnter:x=>{t||x.currentTarget.focus({preventScroll:!0})},className:g("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",t&&"opacity-50 cursor-not-allowed hover:bg-transparent",c),children:[e("span",{className:"mr-2 shrink-0 w-4 h-4",children:r||e("span",{className:g("flex items-center justify-center w-4 h-4 rounded-full border-2 transition-colors",n?"border-blue-600":"border-gray-300 dark:border-gray-600"),children:n&&e("span",{className:"w-2 h-2 rounded-full bg-blue-600"})})}),m("span",{className:"flex-1 min-w-0",children:[e("span",{className:"block truncate",children:i}),s&&e("span",{className:"block text-xs text-gray-500 dark:text-gray-400 truncate",children:s})]}),n&&!r&&e("svg",{className:"ml-auto w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})]})}N.displayName="DropdownRadioItem";export{y as DropdownRadioGroup,N as DropdownRadioItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var M=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var K=(r,t)=>{for(var
|
|
1
|
+
"use strict";"use client";var M=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var K=(r,t)=>{for(var a in t)M(r,a,{get:t[a],enumerable:!0})},H=(r,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of q(t))!B.call(r,n)&&n!==a&&M(r,n,{get:()=>t[n],enumerable:!(l=A(t,n))||l.enumerable});return r};var W=r=>H(M({},"__esModule",{value:!0}),r);var V={};K(V,{DropdownSubMenu:()=>L,DropdownSubMenuContent:()=>I,DropdownSubMenuTrigger:()=>F});module.exports=W(V);var e=require("react"),S=require("react-dom"),R=require("./Dropdown.cjs"),k=require("./hooks/useClickOutside.cjs"),E=require("./hooks/usePositioning.cjs"),y=require("./menu-navigation.cjs"),N=require("../../lib/aria-hide.cjs"),x=require("../../lib/cn.cjs"),d=require("react/jsx-runtime"),j=100,O=(0,e.createContext)(null);function T(){let r=(0,e.useContext)(O);if(!r)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return r}function L({children:r}){let{isOpen:t}=(0,R.useDropdownContext)(),[a,l]=(0,e.useState)(!1),n=(0,e.useRef)(null),p=(0,e.useRef)(null),i=(0,e.useRef)(null),s=(0,e.useRef)(!1),m=t&&a,o=(0,e.useCallback)(()=>{i.current!==null&&(clearTimeout(i.current),i.current=null)},[]),g=(0,e.useCallback)(()=>{o(),i.current=setTimeout(()=>{i.current=null,l(!1)},j)},[o]),f=(0,e.useCallback)(()=>{o(),s.current=!0,l(!0)},[o]),c=(0,e.useCallback)(()=>{let h=s.current;return s.current=!1,h},[]);(0,e.useEffect)(()=>{t||(o(),s.current=!1,l(!1))},[t,o]),(0,e.useEffect)(()=>o,[o]);let b=(0,e.useMemo)(()=>({isOpen:m,setIsOpen:l,triggerRef:n,contentRef:p,scheduleClose:g,cancelClose:o,openWithFocus:f,takeFocusRequest:c}),[m,g,o,f,c]);return(0,d.jsx)(O.Provider,{value:b,children:(0,d.jsx)("div",{className:"relative",children:r})})}L.displayName="DropdownSubMenu";function F({children:r,icon:t,disabled:a=!1,className:l}){let{isOpen:n,setIsOpen:p,triggerRef:i,scheduleClose:s,cancelClose:m,openWithFocus:o}=T();return(0,d.jsxs)("button",{ref:i,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":n,disabled:a,"data-disabled":a||void 0,onMouseEnter:c=>{a||(m(),c.currentTarget.focus({preventScroll:!0}),p(!0))},onMouseLeave:s,onClick:a?void 0:o,onKeyDown:c=>{a||(c.key==="ArrowRight"||c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:(0,x.cn)("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",a&&"opacity-50 cursor-not-allowed hover:bg-transparent",n&&"bg-gray-100 dark:bg-gray-700",l),children:[t&&(0,d.jsx)("span",{className:"mr-2 shrink-0 w-5 h-5",children:t}),(0,d.jsx)("span",{className:"flex-1",children:r}),(0,d.jsx)("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}F.displayName="DropdownSubMenuTrigger";function I({children:r,sideOffset:t=0,className:a}){let{contentId:l}=(0,R.useDropdownContext)(),{isOpen:n,setIsOpen:p,triggerRef:i,contentRef:s,scheduleClose:m,cancelClose:o,takeFocusRequest:g}=T(),[f,c]=(0,e.useState)(!1),b=(0,E.usePositioning)({triggerRef:i,contentRef:s,isOpen:n,side:"right",align:"start",sideOffset:t,avoidCollisions:!0});(0,k.useClickOutside)(s,()=>p(!1),n,{isInside:u=>!!i.current?.contains(u)}),(0,e.useEffect)(()=>{let u=s.current;if(u)return(0,N.registerFloatingLayer)(u,()=>i.current)},[s,i]);let h=(0,e.useCallback)(()=>{o(),p(!0)},[o,p]),P=u=>{(u.key==="ArrowLeft"||u.key==="Escape")&&(u.preventDefault(),o(),p(!1),i.current?.focus())};(0,e.useEffect)(()=>{if(!n||!f||!g())return;let u=s.current;if(u)return(0,y.focusFirstItem)(u)},[n,f,s,g]),(0,e.useLayoutEffect)(()=>{let u=0;if(!n){c(!1);return}let D=()=>{let w=i.current?.getBoundingClientRect(),v=s.current?.getBoundingClientRect();if(b.isReady&&!!w&&!!v&&w.width>0&&w.height>0&&v.width>0&&v.height>0){c(!0);return}u=requestAnimationFrame(D)};return c(!1),u=requestAnimationFrame(D),()=>{u&&cancelAnimationFrame(u)}},[n,b.isReady,i,s]);let C=(0,d.jsx)("div",{ref:s,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[y.MENU_OWNER_ATTRIBUTE]:l,onMouseEnter:h,onMouseLeave:m,onKeyDown:P,style:{position:"fixed",top:b.top,left:b.left,visibility:n&&f?"visible":"hidden",opacity:n&&f?1:0,pointerEvents:n&&f?"auto":"none"},className:(0,x.cn)("z-[61] min-w-40 overflow-hidden rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&f&&"animate-in fade-in-0 zoom-in-95 duration-150",a),children:(0,d.jsx)("div",{className:"py-1",children:r})});return typeof document<"u"?(0,S.createPortal)(C,document.body):C}I.displayName="DropdownSubMenuContent";0&&(module.exports={DropdownSubMenu,DropdownSubMenuContent,DropdownSubMenuTrigger});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as O,useContext as T,useState as C,useRef as
|
|
1
|
+
"use client";import{createContext as O,useContext as T,useState as C,useRef as y,useEffect as h,useLayoutEffect as L,useCallback as b,useMemo as F}from"react";import{createPortal as I}from"react-dom";import{useDropdownContext as D}from"./Dropdown.js";import{useClickOutside as P}from"./hooks/useClickOutside.js";import{usePositioning as A}from"./hooks/usePositioning.js";import{MENU_OWNER_ATTRIBUTE as q,focusFirstItem as B}from"./menu-navigation.js";import{registerFloatingLayer as K}from"../../lib/aria-hide.js";import{cn as S}from"../../lib/cn.js";import{jsx as f,jsxs as _}from"react/jsx-runtime";var H=100,k=O(null);function E(){let i=T(k);if(!i)throw new Error("DropdownSubMenu components must be used within a DropdownSubMenu");return i}function W({children:i}){let{isOpen:c}=D(),[u,l]=C(!1),n=y(null),d=y(null),r=y(null),t=y(!1),p=c&&u,e=b(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]),m=b(()=>{e(),r.current=setTimeout(()=>{r.current=null,l(!1)},H)},[e]),a=b(()=>{e(),t.current=!0,l(!0)},[e]),s=b(()=>{let w=t.current;return t.current=!1,w},[]);h(()=>{c||(e(),t.current=!1,l(!1))},[c,e]),h(()=>e,[e]);let g=F(()=>({isOpen:p,setIsOpen:l,triggerRef:n,contentRef:d,scheduleClose:m,cancelClose:e,openWithFocus:a,takeFocusRequest:s}),[p,m,e,a,s]);return f(k.Provider,{value:g,children:f("div",{className:"relative",children:i})})}W.displayName="DropdownSubMenu";function j({children:i,icon:c,disabled:u=!1,className:l}){let{isOpen:n,setIsOpen:d,triggerRef:r,scheduleClose:t,cancelClose:p,openWithFocus:e}=E();return _("button",{ref:r,role:"menuitem",type:"button",tabIndex:-1,"aria-haspopup":"menu","aria-expanded":n,disabled:u,"data-disabled":u||void 0,onMouseEnter:s=>{u||(p(),s.currentTarget.focus({preventScroll:!0}),d(!0))},onMouseLeave:t,onClick:u?void 0:e,onKeyDown:s=>{u||(s.key==="ArrowRight"||s.key==="Enter"||s.key===" ")&&(s.preventDefault(),e())},className:S("relative flex w-full items-center px-3 py-2 text-left text-sm","outline-none transition-colors","text-gray-700 dark:text-gray-200","hover:bg-gray-100 dark:hover:bg-gray-700","focus:bg-gray-100 dark:focus:bg-gray-700",u&&"opacity-50 cursor-not-allowed hover:bg-transparent",n&&"bg-gray-100 dark:bg-gray-700",l),children:[c&&f("span",{className:"mr-2 shrink-0 w-5 h-5",children:c}),f("span",{className:"flex-1",children:i}),f("svg",{className:"ml-auto w-4 h-4 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:f("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})}j.displayName="DropdownSubMenuTrigger";function V({children:i,sideOffset:c=0,className:u}){let{contentId:l}=D(),{isOpen:n,setIsOpen:d,triggerRef:r,contentRef:t,scheduleClose:p,cancelClose:e,takeFocusRequest:m}=E(),[a,s]=C(!1),g=A({triggerRef:r,contentRef:t,isOpen:n,side:"right",align:"start",sideOffset:c,avoidCollisions:!0});P(t,()=>d(!1),n,{isInside:o=>!!r.current?.contains(o)}),h(()=>{let o=t.current;if(o)return K(o,()=>r.current)},[t,r]);let w=b(()=>{e(),d(!0)},[e,d]),N=o=>{(o.key==="ArrowLeft"||o.key==="Escape")&&(o.preventDefault(),e(),d(!1),r.current?.focus())};h(()=>{if(!n||!a||!m())return;let o=t.current;if(o)return B(o)},[n,a,t,m]),L(()=>{let o=0;if(!n){s(!1);return}let x=()=>{let v=r.current?.getBoundingClientRect(),M=t.current?.getBoundingClientRect();if(g.isReady&&!!v&&!!M&&v.width>0&&v.height>0&&M.width>0&&M.height>0){s(!0);return}o=requestAnimationFrame(x)};return s(!1),o=requestAnimationFrame(x),()=>{o&&cancelAnimationFrame(o)}},[n,g.isReady,r,t]);let R=f("div",{ref:t,role:"menu","aria-orientation":"vertical","aria-hidden":!n,tabIndex:-1,[q]:l,onMouseEnter:w,onMouseLeave:p,onKeyDown:N,style:{position:"fixed",top:g.top,left:g.left,visibility:n&&a?"visible":"hidden",opacity:n&&a?1:0,pointerEvents:n&&a?"auto":"none"},className:S("z-[61] min-w-40 overflow-hidden rounded-lg outline-none","border border-gray-200 bg-white shadow-lg","dark:border-gray-700 dark:bg-gray-800",n&&a&&"animate-in fade-in-0 zoom-in-95 duration-150",u),children:f("div",{className:"py-1",children:i})});return typeof document<"u"?I(R,document.body):R}V.displayName="DropdownSubMenuContent";export{W as DropdownSubMenu,V as DropdownSubMenuContent,j as DropdownSubMenuTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},D=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!k.call(t,n)&&n!==o&&c(t,n,{get:()=>e[n],enumerable:!(s=w(e,n))||s.enumerable});return t};var N=t=>D(c({},"__esModule",{value:!0}),t);var R={};v(R,{DropdownTrigger:()=>g});module.exports=N(R);var i=require("react"),u=require("./Dropdown.cjs"),l=require("../../lib/cn.cjs"),r=require("react/jsx-runtime"),f=(0,i.memo)(({isOpen:t})=>(0,r.jsx)("span",{className:(0,l.cn)("inline-block transition-transform",t&&"rotate-180"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));f.displayName="ChevronIcon";function g({asChild:t=!1,disabled:e=!1,children:o,className:s}){let{isOpen:n,setIsOpen:p,triggerRef:m,triggerId:y,contentId:b}=(0,u.useDropdownContext)(),d={ref:m,id:y,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?b:void 0,disabled:e,onClick:()=>{e||p(!n)},onKeyDown:a=>{e||((a.key==="Enter"||a.key===" ")&&(a.preventDefault(),p(!n)),a.key==="ArrowDown"&&!n&&(a.preventDefault(),p(!0)))}};return t&&(0,i.isValidElement)(o)?(0,i.cloneElement)(o,{...d,className:(0,l.cn)(o.props.className,s)}):(0,r.jsxs)("button",{type:"button",...d,className:(0,l.cn)("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300
|
|
1
|
+
"use strict";"use client";var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var v=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},D=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of h(e))!k.call(t,n)&&n!==o&&c(t,n,{get:()=>e[n],enumerable:!(s=w(e,n))||s.enumerable});return t};var N=t=>D(c({},"__esModule",{value:!0}),t);var R={};v(R,{DropdownTrigger:()=>g});module.exports=N(R);var i=require("react"),u=require("./Dropdown.cjs"),l=require("../../lib/cn.cjs"),r=require("react/jsx-runtime"),f=(0,i.memo)(({isOpen:t})=>(0,r.jsx)("span",{className:(0,l.cn)("inline-block transition-transform",t&&"rotate-180"),children:(0,r.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));f.displayName="ChevronIcon";function g({asChild:t=!1,disabled:e=!1,children:o,className:s}){let{isOpen:n,setIsOpen:p,triggerRef:m,triggerId:y,contentId:b}=(0,u.useDropdownContext)(),d={ref:m,id:y,"aria-haspopup":"menu","aria-expanded":n,"aria-controls":n?b:void 0,disabled:e,onClick:()=>{e||p(!n)},onKeyDown:a=>{e||((a.key==="Enter"||a.key===" ")&&(a.preventDefault(),p(!n)),a.key==="ArrowDown"&&!n&&(a.preventDefault(),p(!0)))}};return t&&(0,i.isValidElement)(o)?(0,i.cloneElement)(o,{...d,className:(0,l.cn)(o.props.className,s)}):(0,r.jsxs)("button",{type:"button",...d,className:(0,l.cn)("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300 text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",s),children:[o,(0,r.jsx)(f,{isOpen:n})]})}g.displayName="DropdownTrigger";0&&(module.exports={DropdownTrigger});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{cloneElement as g,isValidElement as m,memo as y}from"react";import{useDropdownContext as b}from"./Dropdown.js";import{cn as a}from"../../lib/cn.js";import{jsx as o,jsxs as h}from"react/jsx-runtime";var c=y(({isOpen:r})=>o("span",{className:a("inline-block transition-transform",r&&"rotate-180"),children:o("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));c.displayName="ChevronIcon";function w({asChild:r=!1,disabled:i=!1,children:t,className:l}){let{isOpen:e,setIsOpen:s,triggerRef:d,triggerId:u,contentId:f}=b(),p={ref:d,id:u,"aria-haspopup":"menu","aria-expanded":e,"aria-controls":e?f:void 0,disabled:i,onClick:()=>{i||s(!e)},onKeyDown:n=>{i||((n.key==="Enter"||n.key===" ")&&(n.preventDefault(),s(!e)),n.key==="ArrowDown"&&!e&&(n.preventDefault(),s(!0)))}};return r&&m(t)?g(t,{...p,className:a(t.props.className,l)}):h("button",{type:"button",...p,className:a("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300
|
|
1
|
+
"use client";import{cloneElement as g,isValidElement as m,memo as y}from"react";import{useDropdownContext as b}from"./Dropdown.js";import{cn as a}from"../../lib/cn.js";import{jsx as o,jsxs as h}from"react/jsx-runtime";var c=y(({isOpen:r})=>o("span",{className:a("inline-block transition-transform",r&&"rotate-180"),children:o("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}));c.displayName="ChevronIcon";function w({asChild:r=!1,disabled:i=!1,children:t,className:l}){let{isOpen:e,setIsOpen:s,triggerRef:d,triggerId:u,contentId:f}=b(),p={ref:d,id:u,"aria-haspopup":"menu","aria-expanded":e,"aria-controls":e?f:void 0,disabled:i,onClick:()=>{i||s(!e)},onKeyDown:n=>{i||((n.key==="Enter"||n.key===" ")&&(n.preventDefault(),s(!e)),n.key==="ArrowDown"&&!e&&(n.preventDefault(),s(!0)))}};return r&&m(t)?g(t,{...p,className:a(t.props.className,l)}):h("button",{type:"button",...p,className:a("inline-flex items-center justify-center gap-2","rounded-md px-4 py-2","bg-white border border-gray-300 text-sm font-medium text-gray-700","hover:bg-gray-50","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors",l),children:[t,o(c,{isOpen:e})]})}w.displayName="DropdownTrigger";export{w as DropdownTrigger};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var H=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var ve=(c,l)=>{for(var u in l)H(c,u,{get:l[u],enumerable:!0})},ke=(c,l,u,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let b of he(l))!ye.call(c,b)&&b!==u&&H(c,b,{get:()=>l[b],enumerable:!(x=me(l,b))||x.enumerable});return c};var Fe=c=>ke(H({},"__esModule",{value:!0}),c);var Ee={};ve(Ee,{FileSelector:()=>Le});module.exports=Fe(Ee);var a=require("react"),g=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},te=c=>{if(c===0)return"0 B";let l=["B","KB","MB","GB"],u=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,u)).toFixed(u===0?0:1)} ${l[u]}`},j=c=>c.webkitRelativePath||c.name,Se=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(c){let l=[],u=async x=>{if(x.isFile){let b=await new Promise((h,r)=>x.file(h,r));l.push(b)}else if(x.isDirectory){let b=x.createReader(),h=()=>new Promise((L,A)=>b.readEntries(L,A)),r=await h();for(;r.length>0;){for(let L of r)await u(L);r=await h()}}};for(let x of c)await u(x);return l}function Le({value:c,onChange:l,accept:u,multiple:x=!1,maxSize:b=10*1024*1024,maxFiles:h,mode:r="file",variant:L="dropzone",size:A="md",disabled:o=!1,readOnly:s=!1,label:U,helperText:z,error:F,showFileList:V=!0,placeholder:G,browseLabel:B,browseFolderLabel:K,labels:re,icon:oe,onReject:_,className:se}){let i=(0,v.useUILabels)(re),[ie,P]=(0,a.useState)([]),[Z,R]=(0,a.useState)(!1),k=(0,a.useRef)(null),M=(0,a.useRef)(null),S=(0,a.useId)(),w=c!==void 0,N=w?c.map((e,f)=>({file:e,id:`ctrl-${f}`})):ie,d=we[A],D=x||r!=="file";(0,a.useEffect)(()=>{r==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let T=(0,a.useMemo)(()=>te(b),[b]),W=(0,a.useMemo)(()=>u?u.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):i.fileSelectorAllFiles,[u,i.fileSelectorAllFiles]),q=r==="directory"?i.fileSelectorDropFolder:r==="both"?i.fileSelectorDropFilesOrFolders:x?i.fileSelectorDropFiles:i.fileSelectorDropFile,ne=r==="directory"?i.fileSelectorBrowseFolder:i.fileSelectorBrowse,le=i.fileSelectorBrowseFolder,J=(0,v.formatUILabel)(i.fileSelectorTooLarge,{maxSize:T}),Q=(0,v.formatUILabel)(i.fileSelectorTypeNotAccepted,{accept:W}),X=(0,a.useCallback)(e=>{if(e.size>b)return J;if(u){let f=u.split(",").map(n=>n.trim()),p=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!f.some(n=>n.startsWith(".")?p===n.toLowerCase():n.endsWith("/*")?e.type.startsWith(n.replace("/*","/")):e.type===n))return Q}return null},[u,b,J,Q]),E=(0,a.useCallback)(e=>{if(o||s)return;let f=Array.from(e),p=[];for(let m of f){let n=X(m);n?_?.(m,n):p.push(m)}if(p.length!==0)if(w)if(D){let n=[...c??[],...p],y=h?n.slice(0,h):n;l?.(y)}else l?.([p[0]]);else P(m=>{let n=p.map(y=>({file:y,id:`file-${++De}`}));if(D){let y=[...m,...n],ee=h?y.slice(0,h):y,be=ee.map(xe=>xe.file);return l?.(be),ee}return l?.([p[0]]),[n[0]]})},[o,s,w,D,h,c,l,_,X]),ae=(0,a.useCallback)(e=>{if(!(o||s)){if(w){let f=(c??[]).filter((p,m)=>m!==e);l?.(f)}else P(f=>{let p=f.filter((m,n)=>n!==e);return l?.(p.map(m=>m.file)),p});k.current&&(k.current.value="")}},[o,s,w,c,l]),ce=(0,a.useCallback)(()=>{o||s||(w?l?.([]):(P([]),l?.([])),k.current&&(k.current.value=""))},[o,s,w,l]),Y=(0,a.useCallback)(e=>{e.target.files&&e.target.files.length>0&&E(e.target.files)},[E]),ue=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&R(!0)},[o,s]),fe=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!1)},[]),pe=(0,a.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),R(!1),o||s)return;let f=e.dataTransfer.items;if(f&&f.length>0&&(r==="directory"||r==="both")){let p=[];for(let n=0;n<f.length;n++){let y=f[n].webkitGetAsEntry?.();y&&p.push(y)}if(p.some(n=>n.isDirectory)){Ce(p).then(n=>{n.length>0&&E(n)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)},[o,s,r,E]),I=(0,a.useCallback)(()=>{!o&&!s&&k.current?.click()},[o,s]),O=(0,a.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),C=N.length>0,ge=oe||(r==="directory"?Ne:Se),de=V&&C&&(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap),children:[N.map((e,f)=>(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",d.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",te(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ae(f),className:"shrink-0 ml-2 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,v.formatUILabel)(i.fileSelectorRemove,{name:j(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:ce,className:(0,g.cn)("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",d.subtext),children:i.fileSelectorRemoveAll})]}),$=(0,g.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",d.button,F&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap,se),children:[U&&(0,t.jsx)("label",{htmlFor:S,className:(0,g.cn)("block font-medium text-gray-700 dark:text-gray-300",d.text),children:U}),(0,t.jsx)("input",{ref:k,id:S,type:"file",accept:r!=="directory"?u:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:o||s,"aria-describedby":F?`${S}-error`:z?`${S}-helper`:void 0,"aria-invalid":!!F}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:Y,className:"sr-only",disabled:o||s,tabIndex:-1,"aria-hidden":"true"}),L==="dropzone"?(0,t.jsxs)("div",{role:r==="both"?"group":"button",tabIndex:r==="both"?void 0:o||s?-1:0,onClick:r==="both"?void 0:I,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),I())},onDragOver:ue,onDragLeave:fe,onDrop:pe,className:(0,g.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d.dropzone,Z&&!o&&!s?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!o&&!s&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",r!=="both"&&!o&&!s&&"cursor-pointer",o&&"opacity-50 cursor-not-allowed",s&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?i.fileSelectorDropZone:G||q,children:[(0,t.jsx)("div",{className:(0,g.cn)("text-gray-400 dark:text-gray-500 mb-2",d.icon,Z&&"text-blue-500 dark:text-blue-400"),children:ge}),(0,t.jsxs)("p",{className:(0,g.cn)("text-gray-600 dark:text-gray-400",d.text),children:[G||q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:B||ne})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center gap-3 mt-1",d.text),children:[(0,t.jsx)("button",{type:"button",onClick:I,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:B||i.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:O,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:K||le})]}),(0,t.jsx)("p",{className:(0,g.cn)("text-gray-400 dark:text-gray-500 mt-1",d.subtext),children:D&&h?(0,v.formatUILabel)(i.fileSelectorConstraintsMaxFiles,{accept:W,maxSize:T,maxFiles:h}):(0,v.formatUILabel)(i.fileSelectorConstraints,{accept:W,maxSize:T})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(C?i.fileSelectorChangeFiles:i.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:O,disabled:o||s,className:$,children:K||i.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(r==="directory"?C?i.fileSelectorChangeFolder:i.fileSelectorChooseFolder:C?i.fileSelectorChangeFile:i.fileSelectorChooseFile)}),!C&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-400 dark:text-gray-500",d.text),children:r==="directory"?i.fileSelectorNoFolder:r==="both"?i.fileSelectorNoFileOrFolder:i.fileSelectorNoFile}),C&&!V&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-600 dark:text-gray-400 truncate",d.text),children:N.length===1?j(N[0].file):(0,v.formatUILabel)(i.fileSelectorFilesSelected,{count:N.length})})]}),de,F&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,g.cn)("text-red-600 dark:text-red-400",d.subtext),role:"alert",children:F}),z&&!F&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,g.cn)("text-gray-400 dark:text-gray-500",d.subtext),children:z})]})}0&&(module.exports={FileSelector});
|
|
1
|
+
"use strict";"use client";var H=Object.defineProperty;var me=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var ve=(c,l)=>{for(var u in l)H(c,u,{get:l[u],enumerable:!0})},ke=(c,l,u,x)=>{if(l&&typeof l=="object"||typeof l=="function")for(let b of he(l))!ye.call(c,b)&&b!==u&&H(c,b,{get:()=>l[b],enumerable:!(x=me(l,b))||x.enumerable});return c};var Fe=c=>ke(H({},"__esModule",{value:!0}),c);var Ee={};ve(Ee,{FileSelector:()=>Le});module.exports=Fe(Ee);var a=require("react"),g=require("../../lib/cn.cjs"),v=require("../../lib/i18n.cjs"),t=require("react/jsx-runtime"),we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},te=c=>{if(c===0)return"0 B";let l=["B","KB","MB","GB"],u=Math.floor(Math.log(c)/Math.log(1024));return`${(c/Math.pow(1024,u)).toFixed(u===0?0:1)} ${l[u]}`},j=c=>c.webkitRelativePath||c.name,Se=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(c){let l=[],u=async x=>{if(x.isFile){let b=await new Promise((h,r)=>x.file(h,r));l.push(b)}else if(x.isDirectory){let b=x.createReader(),h=()=>new Promise((L,A)=>b.readEntries(L,A)),r=await h();for(;r.length>0;){for(let L of r)await u(L);r=await h()}}};for(let x of c)await u(x);return l}function Le({value:c,onChange:l,accept:u,multiple:x=!1,maxSize:b=10*1024*1024,maxFiles:h,mode:r="file",variant:L="dropzone",size:A="md",disabled:o=!1,readOnly:s=!1,label:U,helperText:z,error:F,showFileList:V=!0,placeholder:G,browseLabel:B,browseFolderLabel:K,labels:re,icon:oe,onReject:_,className:se}){let i=(0,v.useUILabels)(re),[ie,P]=(0,a.useState)([]),[Z,R]=(0,a.useState)(!1),k=(0,a.useRef)(null),M=(0,a.useRef)(null),S=(0,a.useId)(),w=c!==void 0,N=w?c.map((e,f)=>({file:e,id:`ctrl-${f}`})):ie,d=we[A],D=x||r!=="file";(0,a.useEffect)(()=>{r==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),r==="both"&&M.current&&M.current.setAttribute("webkitdirectory","")},[r]);let T=(0,a.useMemo)(()=>te(b),[b]),W=(0,a.useMemo)(()=>u?u.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):i.fileSelectorAllFiles,[u,i.fileSelectorAllFiles]),q=r==="directory"?i.fileSelectorDropFolder:r==="both"?i.fileSelectorDropFilesOrFolders:x?i.fileSelectorDropFiles:i.fileSelectorDropFile,ne=r==="directory"?i.fileSelectorBrowseFolder:i.fileSelectorBrowse,le=i.fileSelectorBrowseFolder,J=(0,v.formatUILabel)(i.fileSelectorTooLarge,{maxSize:T}),Q=(0,v.formatUILabel)(i.fileSelectorTypeNotAccepted,{accept:W}),X=(0,a.useCallback)(e=>{if(e.size>b)return J;if(u){let f=u.split(",").map(n=>n.trim()),p=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!f.some(n=>n.startsWith(".")?p===n.toLowerCase():n.endsWith("/*")?e.type.startsWith(n.replace("/*","/")):e.type===n))return Q}return null},[u,b,J,Q]),E=(0,a.useCallback)(e=>{if(o||s)return;let f=Array.from(e),p=[];for(let m of f){let n=X(m);n?_?.(m,n):p.push(m)}if(p.length!==0)if(w)if(D){let n=[...c??[],...p],y=h?n.slice(0,h):n;l?.(y)}else l?.([p[0]]);else P(m=>{let n=p.map(y=>({file:y,id:`file-${++De}`}));if(D){let y=[...m,...n],ee=h?y.slice(0,h):y,be=ee.map(xe=>xe.file);return l?.(be),ee}return l?.([p[0]]),[n[0]]})},[o,s,w,D,h,c,l,_,X]),ae=(0,a.useCallback)(e=>{if(!(o||s)){if(w){let f=(c??[]).filter((p,m)=>m!==e);l?.(f)}else P(f=>{let p=f.filter((m,n)=>n!==e);return l?.(p.map(m=>m.file)),p});k.current&&(k.current.value="")}},[o,s,w,c,l]),ce=(0,a.useCallback)(()=>{o||s||(w?l?.([]):(P([]),l?.([])),k.current&&(k.current.value=""))},[o,s,w,l]),Y=(0,a.useCallback)(e=>{e.target.files&&e.target.files.length>0&&E(e.target.files)},[E]),ue=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!o&&!s&&R(!0)},[o,s]),fe=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),R(!1)},[]),pe=(0,a.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),R(!1),o||s)return;let f=e.dataTransfer.items;if(f&&f.length>0&&(r==="directory"||r==="both")){let p=[];for(let n=0;n<f.length;n++){let y=f[n].webkitGetAsEntry?.();y&&p.push(y)}if(p.some(n=>n.isDirectory)){Ce(p).then(n=>{n.length>0&&E(n)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&E(e.dataTransfer.files)},[o,s,r,E]),I=(0,a.useCallback)(()=>{!o&&!s&&k.current?.click()},[o,s]),O=(0,a.useCallback)(()=>{!o&&!s&&M.current?.click()},[o,s]),C=N.length>0,ge=oe||(r==="directory"?Ne:Se),de=V&&C&&(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap),children:[N.map((e,f)=>(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",d.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",te(e.file.size),")"]})]}),!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:()=>ae(f),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,v.formatUILabel)(i.fileSelectorRemove,{name:j(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!o&&!s&&(0,t.jsx)("button",{type:"button",onClick:ce,className:(0,g.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",d.subtext),children:i.fileSelectorRemoveAll})]}),$=(0,g.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",d.button,F&&"border-red-300 dark:border-red-600");return(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col",d.gap,se),children:[U&&(0,t.jsx)("label",{htmlFor:S,className:(0,g.cn)("block font-medium text-gray-700 dark:text-gray-300",d.text),children:U}),(0,t.jsx)("input",{ref:k,id:S,type:"file",accept:r!=="directory"?u:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:o||s,"aria-describedby":F?`${S}-error`:z?`${S}-helper`:void 0,"aria-invalid":!!F}),r==="both"&&(0,t.jsx)("input",{ref:M,type:"file",onChange:Y,className:"sr-only",disabled:o||s,tabIndex:-1,"aria-hidden":"true"}),L==="dropzone"?(0,t.jsxs)("div",{role:r==="both"?"group":"button",tabIndex:r==="both"?void 0:o||s?-1:0,onClick:r==="both"?void 0:I,onKeyDown:r==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),I())},onDragOver:ue,onDragLeave:fe,onDrop:pe,className:(0,g.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",d.dropzone,Z&&!o&&!s?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!o&&!s&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",r!=="both"&&!o&&!s&&"cursor-pointer",o&&"opacity-50 cursor-not-allowed",s&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":r==="both"?i.fileSelectorDropZone:G||q,children:[(0,t.jsx)("div",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mb-2",d.icon,Z&&"text-blue-600 dark:text-blue-400"),children:ge}),(0,t.jsxs)("p",{className:(0,g.cn)("text-gray-600 dark:text-gray-400",d.text),children:[G||q," ",!o&&!s&&r!=="both"&&(0,t.jsx)("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:B||ne})]}),r==="both"&&!o&&!s&&(0,t.jsxs)("div",{className:(0,g.cn)("flex items-center gap-3 mt-1",d.text),children:[(0,t.jsx)("button",{type:"button",onClick:I,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:B||i.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:O,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:K||le})]}),(0,t.jsx)("p",{className:(0,g.cn)("text-gray-500 dark:text-gray-400 mt-1",d.subtext),children:D&&h?(0,v.formatUILabel)(i.fileSelectorConstraintsMaxFiles,{accept:W,maxSize:T,maxFiles:h}):(0,v.formatUILabel)(i.fileSelectorConstraints,{accept:W,maxSize:T})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[r==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(C?i.fileSelectorChangeFiles:i.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:O,disabled:o||s,className:$,children:K||i.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:I,disabled:o||s,className:$,children:B||(r==="directory"?C?i.fileSelectorChangeFolder:i.fileSelectorChooseFolder:C?i.fileSelectorChangeFile:i.fileSelectorChooseFile)}),!C&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.text),children:r==="directory"?i.fileSelectorNoFolder:r==="both"?i.fileSelectorNoFileOrFolder:i.fileSelectorNoFile}),C&&!V&&(0,t.jsx)("span",{className:(0,g.cn)("text-gray-600 dark:text-gray-400 truncate",d.text),children:N.length===1?j(N[0].file):(0,v.formatUILabel)(i.fileSelectorFilesSelected,{count:N.length})})]}),de,F&&(0,t.jsx)("p",{id:`${S}-error`,className:(0,g.cn)("text-red-600 dark:text-red-400",d.subtext),role:"alert",children:F}),z&&!F&&(0,t.jsx)("p",{id:`${S}-helper`,className:(0,g.cn)("text-gray-500 dark:text-gray-400",d.subtext),children:z})]})}0&&(module.exports={FileSelector});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as te,useRef as re,useCallback as m,useEffect as ve,useMemo as oe,useId as ke}from"react";import{cn as p}from"../../lib/cn.js";import{formatUILabel as L,useUILabels as Fe}from"../../lib/i18n.js";import{Fragment as Le,jsx as n,jsxs as h}from"react/jsx-runtime";var we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},se=u=>{if(u===0)return"0 B";let l=["B","KB","MB","GB"],g=Math.floor(Math.log(u)/Math.log(1024));return`${(u/Math.pow(1024,g)).toFixed(g===0?0:1)} ${l[g]}`},j=u=>u.webkitRelativePath||u.name,Se=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(u){let l=[],g=async x=>{if(x.isFile){let v=await new Promise((b,t)=>x.file(b,t));l.push(v)}else if(x.isDirectory){let v=x.createReader(),b=()=>new Promise((E,z)=>v.readEntries(E,z)),t=await b();for(;t.length>0;){for(let E of t)await g(E);t=await b()}}};for(let x of u)await g(x);return l}function Me({value:u,onChange:l,accept:g,multiple:x=!1,maxSize:v=10*1024*1024,maxFiles:b,mode:t="file",variant:E="dropzone",size:z="md",disabled:r=!1,readOnly:o=!1,label:U,helperText:P,error:F,showFileList:V=!0,placeholder:G,browseLabel:M,browseFolderLabel:K,labels:ie,icon:ne,onReject:_,className:le}){let s=Fe(ie),[ae,R]=te([]),[Z,T]=te(!1),k=re(null),A=re(null),S=ke(),w=u!==void 0,N=w?u.map((e,a)=>({file:e,id:`ctrl-${a}`})):ae,f=we[z],D=x||t!=="file";ve(()=>{t==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),t==="both"&&A.current&&A.current.setAttribute("webkitdirectory","")},[t]);let W=oe(()=>se(v),[v]),$=oe(()=>g?g.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[g,s.fileSelectorAllFiles]),q=t==="directory"?s.fileSelectorDropFolder:t==="both"?s.fileSelectorDropFilesOrFolders:x?s.fileSelectorDropFiles:s.fileSelectorDropFile,ce=t==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,ue=s.fileSelectorBrowseFolder,J=L(s.fileSelectorTooLarge,{maxSize:W}),Q=L(s.fileSelectorTypeNotAccepted,{accept:$}),X=m(e=>{if(e.size>v)return J;if(g){let a=g.split(",").map(i=>i.trim()),c=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!a.some(i=>i.startsWith(".")?c===i.toLowerCase():i.endsWith("/*")?e.type.startsWith(i.replace("/*","/")):e.type===i))return Q}return null},[g,v,J,Q]),I=m(e=>{if(r||o)return;let a=Array.from(e),c=[];for(let d of a){let i=X(d);i?_?.(d,i):c.push(d)}if(c.length!==0)if(w)if(D){let i=[...u??[],...c],y=b?i.slice(0,b):i;l?.(y)}else l?.([c[0]]);else R(d=>{let i=c.map(y=>({file:y,id:`file-${++De}`}));if(D){let y=[...d,...i],ee=b?y.slice(0,b):y,he=ee.map(ye=>ye.file);return l?.(he),ee}return l?.([c[0]]),[i[0]]})},[r,o,w,D,b,u,l,_,X]),fe=m(e=>{if(!(r||o)){if(w){let a=(u??[]).filter((c,d)=>d!==e);l?.(a)}else R(a=>{let c=a.filter((d,i)=>i!==e);return l?.(c.map(d=>d.file)),c});k.current&&(k.current.value="")}},[r,o,w,u,l]),pe=m(()=>{r||o||(w?l?.([]):(R([]),l?.([])),k.current&&(k.current.value=""))},[r,o,w,l]),Y=m(e=>{e.target.files&&e.target.files.length>0&&I(e.target.files)},[I]),ge=m(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&T(!0)},[r,o]),de=m(e=>{e.preventDefault(),e.stopPropagation(),T(!1)},[]),be=m(e=>{if(e.preventDefault(),e.stopPropagation(),T(!1),r||o)return;let a=e.dataTransfer.items;if(a&&a.length>0&&(t==="directory"||t==="both")){let c=[];for(let i=0;i<a.length;i++){let y=a[i].webkitGetAsEntry?.();y&&c.push(y)}if(c.some(i=>i.isDirectory)){Ce(c).then(i=>{i.length>0&&I(i)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&I(e.dataTransfer.files)},[r,o,t,I]),B=m(()=>{!r&&!o&&k.current?.click()},[r,o]),O=m(()=>{!r&&!o&&A.current?.click()},[r,o]),C=N.length>0,xe=ne||(t==="directory"?Ne:Se),me=V&&C&&h("div",{className:p("flex flex-col",f.gap),children:[N.map((e,a)=>h("div",{className:p("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",f.fileItem),children:[h("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-400 dark:text-gray-500",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),n("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),h("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["(",se(e.file.size),")"]})]}),!r&&!o&&n("button",{type:"button",onClick:()=>fe(a),className:"shrink-0 ml-2 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":L(s.fileSelectorRemove,{name:j(e.file)}),children:n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!r&&!o&&n("button",{type:"button",onClick:pe,className:p("self-start text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400 transition-colors cursor-pointer",f.subtext),children:s.fileSelectorRemoveAll})]}),H=p("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",f.button,F&&"border-red-300 dark:border-red-600");return h("div",{className:p("flex flex-col",f.gap,le),children:[U&&n("label",{htmlFor:S,className:p("block font-medium text-gray-700 dark:text-gray-300",f.text),children:U}),n("input",{ref:k,id:S,type:"file",accept:t!=="directory"?g:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:r||o,"aria-describedby":F?`${S}-error`:P?`${S}-helper`:void 0,"aria-invalid":!!F}),t==="both"&&n("input",{ref:A,type:"file",onChange:Y,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),E==="dropzone"?h("div",{role:t==="both"?"group":"button",tabIndex:t==="both"?void 0:r||o?-1:0,onClick:t==="both"?void 0:B,onKeyDown:t==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),B())},onDragOver:ge,onDragLeave:de,onDrop:be,className:p("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",f.dropzone,Z&&!r&&!o?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!r&&!o&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",t!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":t==="both"?s.fileSelectorDropZone:G||q,children:[n("div",{className:p("text-gray-400 dark:text-gray-500 mb-2",f.icon,Z&&"text-blue-500 dark:text-blue-400"),children:xe}),h("p",{className:p("text-gray-600 dark:text-gray-400",f.text),children:[G||q," ",!r&&!o&&t!=="both"&&n("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:M||ce})]}),t==="both"&&!r&&!o&&h("div",{className:p("flex items-center gap-3 mt-1",f.text),children:[n("button",{type:"button",onClick:B,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:M||s.fileSelectorBrowseFiles}),n("span",{className:"text-gray-300 dark:text-gray-600",children:"\xB7"}),n("button",{type:"button",onClick:O,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:K||ue})]}),n("p",{className:p("text-gray-400 dark:text-gray-500 mt-1",f.subtext),children:D&&b?L(s.fileSelectorConstraintsMaxFiles,{accept:$,maxSize:W,maxFiles:b}):L(s.fileSelectorConstraints,{accept:$,maxSize:W})})]}):h("div",{className:"flex items-center gap-2",children:[t==="both"?h(Le,{children:[n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(C?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),n("button",{type:"button",onClick:O,disabled:r||o,className:H,children:K||s.fileSelectorChooseFolder})]}):n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(t==="directory"?C?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:C?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!C&&n("span",{className:p("text-gray-400 dark:text-gray-500",f.text),children:t==="directory"?s.fileSelectorNoFolder:t==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),C&&!V&&n("span",{className:p("text-gray-600 dark:text-gray-400 truncate",f.text),children:N.length===1?j(N[0].file):L(s.fileSelectorFilesSelected,{count:N.length})})]}),me,F&&n("p",{id:`${S}-error`,className:p("text-red-600 dark:text-red-400",f.subtext),role:"alert",children:F}),P&&!F&&n("p",{id:`${S}-helper`,className:p("text-gray-400 dark:text-gray-500",f.subtext),children:P})]})}export{Me as FileSelector};
|
|
1
|
+
"use client";import{useState as te,useRef as re,useCallback as m,useEffect as ve,useMemo as oe,useId as ke}from"react";import{cn as p}from"../../lib/cn.js";import{formatUILabel as L,useUILabels as Fe}from"../../lib/i18n.js";import{Fragment as Le,jsx as n,jsxs as h}from"react/jsx-runtime";var we={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},se=u=>{if(u===0)return"0 B";let l=["B","KB","MB","GB"],g=Math.floor(Math.log(u)/Math.log(1024));return`${(u/Math.pow(1024,g)).toFixed(g===0?0:1)} ${l[g]}`},j=u=>u.webkitRelativePath||u.name,Se=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ne=n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),De=0;async function Ce(u){let l=[],g=async x=>{if(x.isFile){let v=await new Promise((b,t)=>x.file(b,t));l.push(v)}else if(x.isDirectory){let v=x.createReader(),b=()=>new Promise((E,z)=>v.readEntries(E,z)),t=await b();for(;t.length>0;){for(let E of t)await g(E);t=await b()}}};for(let x of u)await g(x);return l}function Me({value:u,onChange:l,accept:g,multiple:x=!1,maxSize:v=10*1024*1024,maxFiles:b,mode:t="file",variant:E="dropzone",size:z="md",disabled:r=!1,readOnly:o=!1,label:U,helperText:P,error:F,showFileList:V=!0,placeholder:G,browseLabel:M,browseFolderLabel:K,labels:ie,icon:ne,onReject:_,className:le}){let s=Fe(ie),[ae,R]=te([]),[Z,T]=te(!1),k=re(null),A=re(null),S=ke(),w=u!==void 0,N=w?u.map((e,a)=>({file:e,id:`ctrl-${a}`})):ae,f=we[z],D=x||t!=="file";ve(()=>{t==="directory"&&k.current&&k.current.setAttribute("webkitdirectory",""),t==="both"&&A.current&&A.current.setAttribute("webkitdirectory","")},[t]);let W=oe(()=>se(v),[v]),$=oe(()=>g?g.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[g,s.fileSelectorAllFiles]),q=t==="directory"?s.fileSelectorDropFolder:t==="both"?s.fileSelectorDropFilesOrFolders:x?s.fileSelectorDropFiles:s.fileSelectorDropFile,ce=t==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,ue=s.fileSelectorBrowseFolder,J=L(s.fileSelectorTooLarge,{maxSize:W}),Q=L(s.fileSelectorTypeNotAccepted,{accept:$}),X=m(e=>{if(e.size>v)return J;if(g){let a=g.split(",").map(i=>i.trim()),c=`.${e.name.split(".").pop()?.toLowerCase()}`;if(!a.some(i=>i.startsWith(".")?c===i.toLowerCase():i.endsWith("/*")?e.type.startsWith(i.replace("/*","/")):e.type===i))return Q}return null},[g,v,J,Q]),I=m(e=>{if(r||o)return;let a=Array.from(e),c=[];for(let d of a){let i=X(d);i?_?.(d,i):c.push(d)}if(c.length!==0)if(w)if(D){let i=[...u??[],...c],y=b?i.slice(0,b):i;l?.(y)}else l?.([c[0]]);else R(d=>{let i=c.map(y=>({file:y,id:`file-${++De}`}));if(D){let y=[...d,...i],ee=b?y.slice(0,b):y,he=ee.map(ye=>ye.file);return l?.(he),ee}return l?.([c[0]]),[i[0]]})},[r,o,w,D,b,u,l,_,X]),fe=m(e=>{if(!(r||o)){if(w){let a=(u??[]).filter((c,d)=>d!==e);l?.(a)}else R(a=>{let c=a.filter((d,i)=>i!==e);return l?.(c.map(d=>d.file)),c});k.current&&(k.current.value="")}},[r,o,w,u,l]),pe=m(()=>{r||o||(w?l?.([]):(R([]),l?.([])),k.current&&(k.current.value=""))},[r,o,w,l]),Y=m(e=>{e.target.files&&e.target.files.length>0&&I(e.target.files)},[I]),ge=m(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&T(!0)},[r,o]),de=m(e=>{e.preventDefault(),e.stopPropagation(),T(!1)},[]),be=m(e=>{if(e.preventDefault(),e.stopPropagation(),T(!1),r||o)return;let a=e.dataTransfer.items;if(a&&a.length>0&&(t==="directory"||t==="both")){let c=[];for(let i=0;i<a.length;i++){let y=a[i].webkitGetAsEntry?.();y&&c.push(y)}if(c.some(i=>i.isDirectory)){Ce(c).then(i=>{i.length>0&&I(i)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&I(e.dataTransfer.files)},[r,o,t,I]),B=m(()=>{!r&&!o&&k.current?.click()},[r,o]),O=m(()=>{!r&&!o&&A.current?.click()},[r,o]),C=N.length>0,xe=ne||(t==="directory"?Ne:Se),me=V&&C&&h("div",{className:p("flex flex-col",f.gap),children:[N.map((e,a)=>h("div",{className:p("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",f.fileItem),children:[h("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),n("span",{className:"truncate text-gray-700 dark:text-gray-300",children:j(e.file)}),h("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",se(e.file.size),")"]})]}),!r&&!o&&n("button",{type:"button",onClick:()=>fe(a),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":L(s.fileSelectorRemove,{name:j(e.file)}),children:n("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),D&&N.length>1&&!r&&!o&&n("button",{type:"button",onClick:pe,className:p("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",f.subtext),children:s.fileSelectorRemoveAll})]}),H=p("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1",f.button,F&&"border-red-300 dark:border-red-600");return h("div",{className:p("flex flex-col",f.gap,le),children:[U&&n("label",{htmlFor:S,className:p("block font-medium text-gray-700 dark:text-gray-300",f.text),children:U}),n("input",{ref:k,id:S,type:"file",accept:t!=="directory"?g:void 0,multiple:D,onChange:Y,className:"sr-only",disabled:r||o,"aria-describedby":F?`${S}-error`:P?`${S}-helper`:void 0,"aria-invalid":!!F}),t==="both"&&n("input",{ref:A,type:"file",onChange:Y,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),E==="dropzone"?h("div",{role:t==="both"?"group":"button",tabIndex:t==="both"?void 0:r||o?-1:0,onClick:t==="both"?void 0:B,onKeyDown:t==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),B())},onDragOver:ge,onDragLeave:de,onDrop:be,className:p("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",f.dropzone,Z&&!r&&!o?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!r&&!o&&"hover:border-blue-400 dark:hover:border-blue-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",t!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",F&&"border-red-300 dark:border-red-600"),"aria-label":t==="both"?s.fileSelectorDropZone:G||q,children:[n("div",{className:p("text-gray-500 dark:text-gray-400 mb-2",f.icon,Z&&"text-blue-600 dark:text-blue-400"),children:xe}),h("p",{className:p("text-gray-600 dark:text-gray-400",f.text),children:[G||q," ",!r&&!o&&t!=="both"&&n("span",{className:"text-blue-600 dark:text-blue-400 font-medium",children:M||ce})]}),t==="both"&&!r&&!o&&h("div",{className:p("flex items-center gap-3 mt-1",f.text),children:[n("button",{type:"button",onClick:B,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:M||s.fileSelectorBrowseFiles}),n("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),n("button",{type:"button",onClick:O,className:"text-blue-600 dark:text-blue-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 rounded",children:K||ue})]}),n("p",{className:p("text-gray-500 dark:text-gray-400 mt-1",f.subtext),children:D&&b?L(s.fileSelectorConstraintsMaxFiles,{accept:$,maxSize:W,maxFiles:b}):L(s.fileSelectorConstraints,{accept:$,maxSize:W})})]}):h("div",{className:"flex items-center gap-2",children:[t==="both"?h(Le,{children:[n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(C?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),n("button",{type:"button",onClick:O,disabled:r||o,className:H,children:K||s.fileSelectorChooseFolder})]}):n("button",{type:"button",onClick:B,disabled:r||o,className:H,children:M||(t==="directory"?C?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:C?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!C&&n("span",{className:p("text-gray-500 dark:text-gray-400",f.text),children:t==="directory"?s.fileSelectorNoFolder:t==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),C&&!V&&n("span",{className:p("text-gray-600 dark:text-gray-400 truncate",f.text),children:N.length===1?j(N[0].file):L(s.fileSelectorFilesSelected,{count:N.length})})]}),me,F&&n("p",{id:`${S}-error`,className:p("text-red-600 dark:text-red-400",f.subtext),role:"alert",children:F}),P&&!F&&n("p",{id:`${S}-helper`,className:p("text-gray-500 dark:text-gray-400",f.subtext),children:P})]})}export{Me as FileSelector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var X=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ce=(l,d)=>{for(var m in d)X(l,m,{get:d[m],enumerable:!0})},Ee=(l,d,m,M)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of ye(d))!Ne.call(l,f)&&f!==m&&X(l,f,{get:()=>d[f],enumerable:!(M=xe(d,f))||M.enumerable});return l};var Se=l=>Ee(X({},"__esModule",{value:!0}),l);var we={};Ce(we,{MentionInput:()=>le});module.exports=Se(we);var a=require("react"),oe=require("react-dom/client"),L=require("../../../lib/cn.cjs"),ae=require("../../../lib/i18n.cjs"),R=require("../shared/inputStyles.cjs"),ie=require("../shared/InputWrapper.cjs"),se=require("../../chip/Chip.cjs"),c=require("react/jsx-runtime"),Me=l=>(0,c.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[l.avatar&&(0,c.jsx)("img",{src:l.avatar,alt:l.label,className:"w-6 h-6 rounded-full"}),(0,c.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:l.label})]}),le=(0,a.forwardRef)(({label:l,inline:d=!1,size:m="md",labelColor:M,borderColor:f,textColor:k,disabled:g=!1,readOnly:C=!1,error:$=!1,helperText:ce,hideLabel:de=!1,icon:B,iconPosition:K="left",mentionTrigger:b="@",suggestions:w=[],onMentionSearch:W,onMentionSelect:F,onMentionRemove:Q,renderSuggestion:U,value:p,onChange:h,placeholder:H,loading:ue=!1,loadingLabel:fe,maxSuggestions:O=10,chipVariant:j="soft",chipColor:G="primary",chipSize:J="sm"},I)=>{let Y=(0,a.useId)(),Z=(0,ae.useUILabels)(),ee=Z.chipRemove,s=(0,a.useRef)(null),[_,T]=(0,a.useState)(!1),[D,P]=(0,a.useState)(0),[Ie,V]=(0,a.useState)(""),pe=(0,L.cn)((0,R.getBaseInputClasses)({size:m,error:$,disabled:g,readOnly:C,icon:B,iconPosition:K}),"min-h-[42px]","whitespace-pre-wrap","break-words"),me={...f&&{borderColor:f},...k&&{color:k}},ge=f||k?me:void 0,v=(0,a.useCallback)(()=>{if(!s.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){let u=i.getAttribute("data-mention-id"),x=i.getAttribute("data-mention-label")||"",A=i.getAttribute("data-mention-avatar")||void 0,y=`@${x}`,S=t;n.push({trigger:b,suggestion:{id:u||"",label:x,avatar:A},startIndex:S,endIndex:S+y.length}),e+=y,t+=y.length}else i.childNodes.forEach(o)}};return s.current.childNodes.forEach(o),{text:e,mentions:n}},[b]),te=(0,a.useCallback)((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",(0,oe.createRoot)(t).render((0,c.jsx)(se.Chip,{label:e.label,variant:j,color:G,size:J,closable:!g&&!C,removeLabel:ee,onClose:n,disabled:g,avatar:e.avatar?(0,c.jsx)("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[j,G,J,g,C,ee]),E=(0,a.useCallback)(e=>{if(!s.current)return;let n=s.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=v();h?.(t);let o=p?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&Q?.(o)}},[v,h,Q,p?.mentions]),be=(0,a.useCallback)(()=>{if(!s.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${b}(\\w*)$`));if(o){let i=o[1];V(i),T(!0),P(0),W?.(i)}else T(!1),V("");let r=v();h?.(r)},[b,W,h,v]),ne=(0,a.useCallback)(e=>{let n=s.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,i=r.textContent||"",u=o.startOffset,A=i.substring(0,u).lastIndexOf(b);if(A===-1)return!1;let y=i.substring(0,A),S=i.substring(u),N=te(e,()=>{E(e.id)});if(y?(r.textContent=y,r.parentNode?.insertBefore(N,r.nextSibling)):(r.parentNode?.insertBefore(N,r),r.remove()),S){let ve=document.createTextNode(S);N.parentNode?.insertBefore(ve,N.nextSibling)}let re=document.createTextNode(" ");N.parentNode?.insertBefore(re,N.nextSibling);let z=document.createRange();return z.setStartAfter(re),z.collapse(!0),t.removeAllRanges(),t.addRange(z),!0},[b,te,E]),q=(0,a.useCallback)(e=>{let n=ne(e);if(T(!1),V(""),!n)return;let t=v();h?.(t),F?.(e),s.current?.focus()},[ne,v,h,F]),he=(0,a.useCallback)(e=>{let n=w.slice(0,O);if(_&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),P(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),P(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[D]&&q(n[D]);return;case"Escape":e.preventDefault(),T(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){e.preventDefault();let u=i.getAttribute("data-mention-id");u&&E(u);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let i=r.previousSibling;if(i&&i.nodeType===Node.ELEMENT_NODE){let u=i;if(u.hasAttribute("data-mention-id")){e.preventDefault();let x=u.getAttribute("data-mention-id");x&&E(x);return}}}}}},[_,w,D,O,q,E]);return(0,a.useEffect)(()=>{s.current&&(!(s.current.textContent||s.current.querySelector("[data-mention-id]"))&&H?s.current.setAttribute("data-placeholder",H):s.current.removeAttribute("data-placeholder"))},[H,p]),(0,a.useEffect)(()=>{s.current&&p?.text===""&&p?.mentions.length===0&&s.current.innerHTML.trim()&&(s.current.innerHTML="")},[p?.text,p?.mentions.length]),(0,c.jsx)(ie.InputWrapper,{label:l,hideLabel:de,labelColor:M,error:$,helperText:ce,inline:d,htmlFor:Y,children:(0,c.jsxs)("div",{className:"relative w-full",children:[B&&(0,c.jsx)("span",{className:(0,R.getIconClasses)(K),children:B}),(0,c.jsx)("div",{ref:e=>{typeof I=="function"?I(e):I&&(I.current=e),s.current=e},id:Y,contentEditable:!g&&!C,suppressContentEditableWarning:!0,onInput:be,onKeyDown:he,className:(0,L.cn)(pe,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-
|
|
1
|
+
"use strict";"use client";var X=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ce=(l,d)=>{for(var m in d)X(l,m,{get:d[m],enumerable:!0})},Ee=(l,d,m,M)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of ye(d))!Ne.call(l,f)&&f!==m&&X(l,f,{get:()=>d[f],enumerable:!(M=xe(d,f))||M.enumerable});return l};var Se=l=>Ee(X({},"__esModule",{value:!0}),l);var we={};Ce(we,{MentionInput:()=>le});module.exports=Se(we);var a=require("react"),oe=require("react-dom/client"),L=require("../../../lib/cn.cjs"),ae=require("../../../lib/i18n.cjs"),R=require("../shared/inputStyles.cjs"),ie=require("../shared/InputWrapper.cjs"),se=require("../../chip/Chip.cjs"),c=require("react/jsx-runtime"),Me=l=>(0,c.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[l.avatar&&(0,c.jsx)("img",{src:l.avatar,alt:l.label,className:"w-6 h-6 rounded-full"}),(0,c.jsx)("span",{className:"text-sm text-gray-900 dark:text-white",children:l.label})]}),le=(0,a.forwardRef)(({label:l,inline:d=!1,size:m="md",labelColor:M,borderColor:f,textColor:k,disabled:g=!1,readOnly:C=!1,error:$=!1,helperText:ce,hideLabel:de=!1,icon:B,iconPosition:K="left",mentionTrigger:b="@",suggestions:w=[],onMentionSearch:W,onMentionSelect:F,onMentionRemove:Q,renderSuggestion:U,value:p,onChange:h,placeholder:H,loading:ue=!1,loadingLabel:fe,maxSuggestions:O=10,chipVariant:j="soft",chipColor:G="primary",chipSize:J="sm"},I)=>{let Y=(0,a.useId)(),Z=(0,ae.useUILabels)(),ee=Z.chipRemove,s=(0,a.useRef)(null),[_,T]=(0,a.useState)(!1),[D,P]=(0,a.useState)(0),[Ie,V]=(0,a.useState)(""),pe=(0,L.cn)((0,R.getBaseInputClasses)({size:m,error:$,disabled:g,readOnly:C,icon:B,iconPosition:K}),"min-h-[42px]","whitespace-pre-wrap","break-words"),me={...f&&{borderColor:f},...k&&{color:k}},ge=f||k?me:void 0,v=(0,a.useCallback)(()=>{if(!s.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){let u=i.getAttribute("data-mention-id"),x=i.getAttribute("data-mention-label")||"",A=i.getAttribute("data-mention-avatar")||void 0,y=`@${x}`,S=t;n.push({trigger:b,suggestion:{id:u||"",label:x,avatar:A},startIndex:S,endIndex:S+y.length}),e+=y,t+=y.length}else i.childNodes.forEach(o)}};return s.current.childNodes.forEach(o),{text:e,mentions:n}},[b]),te=(0,a.useCallback)((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",(0,oe.createRoot)(t).render((0,c.jsx)(se.Chip,{label:e.label,variant:j,color:G,size:J,closable:!g&&!C,removeLabel:ee,onClose:n,disabled:g,avatar:e.avatar?(0,c.jsx)("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[j,G,J,g,C,ee]),E=(0,a.useCallback)(e=>{if(!s.current)return;let n=s.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=v();h?.(t);let o=p?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&Q?.(o)}},[v,h,Q,p?.mentions]),be=(0,a.useCallback)(()=>{if(!s.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${b}(\\w*)$`));if(o){let i=o[1];V(i),T(!0),P(0),W?.(i)}else T(!1),V("");let r=v();h?.(r)},[b,W,h,v]),ne=(0,a.useCallback)(e=>{let n=s.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,i=r.textContent||"",u=o.startOffset,A=i.substring(0,u).lastIndexOf(b);if(A===-1)return!1;let y=i.substring(0,A),S=i.substring(u),N=te(e,()=>{E(e.id)});if(y?(r.textContent=y,r.parentNode?.insertBefore(N,r.nextSibling)):(r.parentNode?.insertBefore(N,r),r.remove()),S){let ve=document.createTextNode(S);N.parentNode?.insertBefore(ve,N.nextSibling)}let re=document.createTextNode(" ");N.parentNode?.insertBefore(re,N.nextSibling);let z=document.createRange();return z.setStartAfter(re),z.collapse(!0),t.removeAllRanges(),t.addRange(z),!0},[b,te,E]),q=(0,a.useCallback)(e=>{let n=ne(e);if(T(!1),V(""),!n)return;let t=v();h?.(t),F?.(e),s.current?.focus()},[ne,v,h,F]),he=(0,a.useCallback)(e=>{let n=w.slice(0,O);if(_&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),P(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),P(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[D]&&q(n[D]);return;case"Escape":e.preventDefault(),T(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let i=r;if(i.hasAttribute("data-mention-id")){e.preventDefault();let u=i.getAttribute("data-mention-id");u&&E(u);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let i=r.previousSibling;if(i&&i.nodeType===Node.ELEMENT_NODE){let u=i;if(u.hasAttribute("data-mention-id")){e.preventDefault();let x=u.getAttribute("data-mention-id");x&&E(x);return}}}}}},[_,w,D,O,q,E]);return(0,a.useEffect)(()=>{s.current&&(!(s.current.textContent||s.current.querySelector("[data-mention-id]"))&&H?s.current.setAttribute("data-placeholder",H):s.current.removeAttribute("data-placeholder"))},[H,p]),(0,a.useEffect)(()=>{s.current&&p?.text===""&&p?.mentions.length===0&&s.current.innerHTML.trim()&&(s.current.innerHTML="")},[p?.text,p?.mentions.length]),(0,c.jsx)(ie.InputWrapper,{label:l,hideLabel:de,labelColor:M,error:$,helperText:ce,inline:d,htmlFor:Y,children:(0,c.jsxs)("div",{className:"relative w-full",children:[B&&(0,c.jsx)("span",{className:(0,R.getIconClasses)(K),children:B}),(0,c.jsx)("div",{ref:e=>{typeof I=="function"?I(e):I&&(I.current=e),s.current=e},id:Y,contentEditable:!g&&!C,suppressContentEditableWarning:!0,onInput:be,onKeyDown:he,className:(0,L.cn)(pe,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:ge,role:"textbox","aria-label":l,"aria-multiline":"true",tabIndex:C||g?-1:0}),_&&w.length>0&&(0,c.jsx)("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:ue?(0,c.jsx)("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:fe??Z.mentionInputLoading}):w.slice(0,O).map((e,n)=>(0,c.jsx)("div",{onClick:()=>q(e),className:(0,L.cn)(n===D&&"bg-gray-100 dark:bg-gray-600"),children:U?U(e):Me(e)},e.id))})]})})});le.displayName="MentionInput";0&&(module.exports={MentionInput});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{forwardRef as ge,useCallback as u,useEffect as ee,useId as be,useRef as he,useState as _}from"react";import{createRoot as ve}from"react-dom/client";import{cn as P}from"../../../lib/cn.js";import{useUILabels as xe}from"../../../lib/i18n.js";import{getBaseInputClasses as ye,getIconClasses as Ne}from"../shared/inputStyles.js";import{InputWrapper as Ce}from"../shared/InputWrapper.js";import{Chip as Ee}from"../../chip/Chip.js";import{jsx as l,jsxs as te}from"react/jsx-runtime";var Se=c=>te("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[c.avatar&&l("img",{src:c.avatar,alt:c.label,className:"w-6 h-6 rounded-full"}),l("span",{className:"text-sm text-gray-900 dark:text-white",children:c.label})]}),Me=ge(({label:c,inline:ne=!1,size:re="md",labelColor:oe,borderColor:I,textColor:T,disabled:f=!1,readOnly:x=!1,error:V=!1,helperText:ae,hideLabel:ie=!1,icon:D,iconPosition:q="left",mentionTrigger:p="@",suggestions:C=[],onMentionSearch:z,onMentionSelect:X,onMentionRemove:$,renderSuggestion:K,value:d,onChange:m,placeholder:A,loading:se=!1,loadingLabel:le,maxSuggestions:L=10,chipVariant:W="soft",chipColor:F="primary",chipSize:Q="sm"},E)=>{let U=be(),j=xe(),G=j.chipRemove,i=he(null),[R,S]=_(!1),[M,k]=_(0),[we,B]=_(""),ce=P(ye({size:re,error:V,disabled:f,readOnly:x,icon:D,iconPosition:q}),"min-h-[42px]","whitespace-pre-wrap","break-words"),de={...I&&{borderColor:I},...T&&{color:T}},ue=I||T?de:void 0,g=u(()=>{if(!i.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){let s=a.getAttribute("data-mention-id"),b=a.getAttribute("data-mention-label")||"",w=a.getAttribute("data-mention-avatar")||void 0,h=`@${b}`,N=t;n.push({trigger:p,suggestion:{id:s||"",label:b,avatar:w},startIndex:N,endIndex:N+h.length}),e+=h,t+=h.length}else a.childNodes.forEach(o)}};return i.current.childNodes.forEach(o),{text:e,mentions:n}},[p]),J=u((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",ve(t).render(l(Ee,{label:e.label,variant:W,color:F,size:Q,closable:!f&&!x,removeLabel:G,onClose:n,disabled:f,avatar:e.avatar?l("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[W,F,Q,f,x,G]),y=u(e=>{if(!i.current)return;let n=i.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=g();m?.(t);let o=d?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&$?.(o)}},[g,m,$,d?.mentions]),fe=u(()=>{if(!i.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${p}(\\w*)$`));if(o){let a=o[1];B(a),S(!0),k(0),z?.(a)}else S(!1),B("");let r=g();m?.(r)},[p,z,m,g]),Y=u(e=>{let n=i.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,a=r.textContent||"",s=o.startOffset,w=a.substring(0,s).lastIndexOf(p);if(w===-1)return!1;let h=a.substring(0,w),N=a.substring(s),v=J(e,()=>{y(e.id)});if(h?(r.textContent=h,r.parentNode?.insertBefore(v,r.nextSibling)):(r.parentNode?.insertBefore(v,r),r.remove()),N){let me=document.createTextNode(N);v.parentNode?.insertBefore(me,v.nextSibling)}let Z=document.createTextNode(" ");v.parentNode?.insertBefore(Z,v.nextSibling);let O=document.createRange();return O.setStartAfter(Z),O.collapse(!0),t.removeAllRanges(),t.addRange(O),!0},[p,J,y]),H=u(e=>{let n=Y(e);if(S(!1),B(""),!n)return;let t=g();m?.(t),X?.(e),i.current?.focus()},[Y,g,m,X]),pe=u(e=>{let n=C.slice(0,L);if(R&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),k(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),k(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[M]&&H(n[M]);return;case"Escape":e.preventDefault(),S(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){e.preventDefault();let s=a.getAttribute("data-mention-id");s&&y(s);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let a=r.previousSibling;if(a&&a.nodeType===Node.ELEMENT_NODE){let s=a;if(s.hasAttribute("data-mention-id")){e.preventDefault();let b=s.getAttribute("data-mention-id");b&&y(b);return}}}}}},[R,C,M,L,H,y]);return ee(()=>{i.current&&(!(i.current.textContent||i.current.querySelector("[data-mention-id]"))&&A?i.current.setAttribute("data-placeholder",A):i.current.removeAttribute("data-placeholder"))},[A,d]),ee(()=>{i.current&&d?.text===""&&d?.mentions.length===0&&i.current.innerHTML.trim()&&(i.current.innerHTML="")},[d?.text,d?.mentions.length]),l(Ce,{label:c,hideLabel:ie,labelColor:oe,error:V,helperText:ae,inline:ne,htmlFor:U,children:te("div",{className:"relative w-full",children:[D&&l("span",{className:Ne(q),children:D}),l("div",{ref:e=>{typeof E=="function"?E(e):E&&(E.current=e),i.current=e},id:U,contentEditable:!f&&!x,suppressContentEditableWarning:!0,onInput:fe,onKeyDown:pe,className:P(ce,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-
|
|
1
|
+
"use client";import{forwardRef as ge,useCallback as u,useEffect as ee,useId as be,useRef as he,useState as _}from"react";import{createRoot as ve}from"react-dom/client";import{cn as P}from"../../../lib/cn.js";import{useUILabels as xe}from"../../../lib/i18n.js";import{getBaseInputClasses as ye,getIconClasses as Ne}from"../shared/inputStyles.js";import{InputWrapper as Ce}from"../shared/InputWrapper.js";import{Chip as Ee}from"../../chip/Chip.js";import{jsx as l,jsxs as te}from"react/jsx-runtime";var Se=c=>te("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer",children:[c.avatar&&l("img",{src:c.avatar,alt:c.label,className:"w-6 h-6 rounded-full"}),l("span",{className:"text-sm text-gray-900 dark:text-white",children:c.label})]}),Me=ge(({label:c,inline:ne=!1,size:re="md",labelColor:oe,borderColor:I,textColor:T,disabled:f=!1,readOnly:x=!1,error:V=!1,helperText:ae,hideLabel:ie=!1,icon:D,iconPosition:q="left",mentionTrigger:p="@",suggestions:C=[],onMentionSearch:z,onMentionSelect:X,onMentionRemove:$,renderSuggestion:K,value:d,onChange:m,placeholder:A,loading:se=!1,loadingLabel:le,maxSuggestions:L=10,chipVariant:W="soft",chipColor:F="primary",chipSize:Q="sm"},E)=>{let U=be(),j=xe(),G=j.chipRemove,i=he(null),[R,S]=_(!1),[M,k]=_(0),[we,B]=_(""),ce=P(ye({size:re,error:V,disabled:f,readOnly:x,icon:D,iconPosition:q}),"min-h-[42px]","whitespace-pre-wrap","break-words"),de={...I&&{borderColor:I},...T&&{color:T}},ue=I||T?de:void 0,g=u(()=>{if(!i.current)return{text:"",mentions:[]};let e="",n=[],t=0,o=r=>{if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"",t+=(r.textContent||"").length;else if(r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){let s=a.getAttribute("data-mention-id"),b=a.getAttribute("data-mention-label")||"",w=a.getAttribute("data-mention-avatar")||void 0,h=`@${b}`,N=t;n.push({trigger:p,suggestion:{id:s||"",label:b,avatar:w},startIndex:N,endIndex:N+h.length}),e+=h,t+=h.length}else a.childNodes.forEach(o)}};return i.current.childNodes.forEach(o),{text:e,mentions:n}},[p]),J=u((e,n)=>{let t=document.createElement("span");return t.contentEditable="false",t.setAttribute("data-mention-id",e.id),t.setAttribute("data-mention-label",e.label),e.avatar&&t.setAttribute("data-mention-avatar",e.avatar),t.className="inline-block align-middle mx-0.5",t.style.userSelect="none",ve(t).render(l(Ee,{label:e.label,variant:W,color:F,size:Q,closable:!f&&!x,removeLabel:G,onClose:n,disabled:f,avatar:e.avatar?l("img",{src:e.avatar,alt:e.label,className:"w-full h-full object-cover"}):void 0})),t},[W,F,Q,f,x,G]),y=u(e=>{if(!i.current)return;let n=i.current.querySelector(`[data-mention-id="${e}"]`);if(n){n.remove();let t=g();m?.(t);let o=d?.mentions.find(r=>r.suggestion.id===e)?.suggestion;o&&$?.(o)}},[g,m,$,d?.mentions]),fe=u(()=>{if(!i.current)return;let e=window.getSelection();if(!e||e.rangeCount===0)return;let n=e.getRangeAt(0),t="";n.startContainer.nodeType===Node.TEXT_NODE&&(t=n.startContainer.textContent?.substring(0,n.startOffset)||"");let o=t.match(new RegExp(`${p}(\\w*)$`));if(o){let a=o[1];B(a),S(!0),k(0),z?.(a)}else S(!1),B("");let r=g();m?.(r)},[p,z,m,g]),Y=u(e=>{let n=i.current;if(!n)return!1;let t=window.getSelection();if(!t||t.rangeCount===0)return!1;let o=t.getRangeAt(0);if(o.startContainer.nodeType!==Node.TEXT_NODE||!n.contains(o.startContainer))return!1;let r=o.startContainer,a=r.textContent||"",s=o.startOffset,w=a.substring(0,s).lastIndexOf(p);if(w===-1)return!1;let h=a.substring(0,w),N=a.substring(s),v=J(e,()=>{y(e.id)});if(h?(r.textContent=h,r.parentNode?.insertBefore(v,r.nextSibling)):(r.parentNode?.insertBefore(v,r),r.remove()),N){let me=document.createTextNode(N);v.parentNode?.insertBefore(me,v.nextSibling)}let Z=document.createTextNode(" ");v.parentNode?.insertBefore(Z,v.nextSibling);let O=document.createRange();return O.setStartAfter(Z),O.collapse(!0),t.removeAllRanges(),t.addRange(O),!0},[p,J,y]),H=u(e=>{let n=Y(e);if(S(!1),B(""),!n)return;let t=g();m?.(t),X?.(e),i.current?.focus()},[Y,g,m,X]),pe=u(e=>{let n=C.slice(0,L);if(R&&n.length>0)switch(e.key){case"ArrowDown":e.preventDefault(),k(t=>t<n.length-1?t+1:0);return;case"ArrowUp":e.preventDefault(),k(t=>t>0?t-1:n.length-1);return;case"Enter":case"Tab":e.preventDefault(),n[M]&&H(n[M]);return;case"Escape":e.preventDefault(),S(!1);return}if(e.key==="Backspace"){let t=window.getSelection();if(!t||t.rangeCount===0)return;let o=t.getRangeAt(0);if(o.collapsed&&o.startOffset===0){let r=o.startContainer.previousSibling;if(r&&r.nodeType===Node.ELEMENT_NODE){let a=r;if(a.hasAttribute("data-mention-id")){e.preventDefault();let s=a.getAttribute("data-mention-id");s&&y(s);return}}}if(o.collapsed&&o.startContainer.nodeType===Node.TEXT_NODE){let r=o.startContainer;if(o.startOffset===0){let a=r.previousSibling;if(a&&a.nodeType===Node.ELEMENT_NODE){let s=a;if(s.hasAttribute("data-mention-id")){e.preventDefault();let b=s.getAttribute("data-mention-id");b&&y(b);return}}}}}},[R,C,M,L,H,y]);return ee(()=>{i.current&&(!(i.current.textContent||i.current.querySelector("[data-mention-id]"))&&A?i.current.setAttribute("data-placeholder",A):i.current.removeAttribute("data-placeholder"))},[A,d]),ee(()=>{i.current&&d?.text===""&&d?.mentions.length===0&&i.current.innerHTML.trim()&&(i.current.innerHTML="")},[d?.text,d?.mentions.length]),l(Ce,{label:c,hideLabel:ie,labelColor:oe,error:V,helperText:ae,inline:ne,htmlFor:U,children:te("div",{className:"relative w-full",children:[D&&l("span",{className:Ne(q),children:D}),l("div",{ref:e=>{typeof E=="function"?E(e):E&&(E.current=e),i.current=e},id:U,contentEditable:!f&&!x,suppressContentEditableWarning:!0,onInput:fe,onKeyDown:pe,className:P(ce,"empty:before:content-[attr(data-placeholder)] empty:before:text-gray-500 empty:before:dark:text-gray-400"),style:ue,role:"textbox","aria-label":c,"aria-multiline":"true",tabIndex:x||f?-1:0}),R&&C.length>0&&l("div",{onMouseDown:e=>e.preventDefault(),className:"absolute z-10 mt-1 w-full max-h-60 overflow-auto rounded-lg border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 shadow-lg",children:se?l("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:le??j.mentionInputLoading}):C.slice(0,L).map((e,n)=>l("div",{onClick:()=>H(e),className:P(n===M&&"bg-gray-100 dark:bg-gray-600"),children:K?K(e):Se(e)},e.id))})]})})});Me.displayName="MentionInput";export{Me as MentionInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},b=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!i.call(e,t)&&t!==o&&n(e,t,{get:()=>r[t],enumerable:!(a=g(r,t))||a.enumerable});return e};var x=e=>b(n({},"__esModule",{value:!0}),e);var k={};p(k,{getBaseInputClasses:()=>m,getHelperTextClasses:()=>y,getIconClasses:()=>f,getLabelClasses:()=>u});module.exports=x(k);var s=require("../../../lib/cn.cjs"),c=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],m=({size:e="md",error:r,disabled:o,readOnly:a,icon:t,iconPosition:l})=>(0,s.cn)("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-300",c(e),t&&l==="left"?"pl-9":"",t&&l==="right"?"pr-9":"",o?"opacity-50 cursor-not-allowed":"",a?"bg-gray-100 dark:bg-gray-600 cursor-default":"",r?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),u=(e,r)=>(0,s.cn)("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!r&&"text-gray-900 dark:text-white"),y=e=>(0,s.cn)("mt-1 text-xs",e?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),f=e=>(0,s.cn)("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");0&&(module.exports={getBaseInputClasses,getHelperTextClasses,getIconClasses,getLabelClasses});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as
|
|
1
|
+
import{cn as t}from"../../../lib/cn.js";var l=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],d=({size:e="md",error:r,disabled:a,readOnly:n,icon:o,iconPosition:s})=>t("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-none focus:ring-0","dark:bg-gray-700 dark:placeholder-gray-300",l(e),o&&s==="left"?"pl-9":"",o&&s==="right"?"pr-9":"",a?"opacity-50 cursor-not-allowed":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",r?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600"),i=(e,r)=>t("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!r&&"text-gray-900 dark:text-white"),p=e=>t("mt-1 text-xs",e?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),b=e=>t("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");export{d as getBaseInputClasses,p as getHelperTextClasses,b as getIconClasses,i as getLabelClasses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var v=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var oe=(n,a)=>{for(var c in a)v(n,c,{get:a[c],enumerable:!0})},ne=(n,a,c,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of ae(a))!te.call(n,l)&&l!==c&&v(n,l,{get:()=>a[l],enumerable:!(d=re(a,l))||d.enumerable});return n};var se=n=>ne(v({},"__esModule",{value:!0}),n);var de={};oe(de,{Header:()=>le});module.exports=se(de);var h=require("react"),s=require("../../lib/cn.cjs"),B=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function le({logo:n,logoHref:a="/",onLogoClick:c,navItems:d=[],actions:l,rightContent:p,variant:t="default",size:b="md",backgroundColor:g,textColor:P,hoverColor:R,navItemTextColor:j,navItemHoverColor:D,navItemBgHover:O,navItemActiveColor:T,sticky:W=!1,fixed:z=!1,showSearch:k=!1,onSearch:N,searchPlaceholder:Q,menuLabel:_,className:q,containerClassName:A}){let w=(0,B.useUILabels)(),u=Q??w.headerSearchPlaceholder,[f,E]=(0,h.useState)(!1),[C,F]=(0,h.useState)(null),[m,L]=(0,h.useState)(""),U=()=>{E(!f)},G=r=>{F(C===r?null:r)},M=r=>{r.preventDefault(),N&&N(m)},J=(0,s.cn)(W&&"sticky top-0 z-50",z&&"fixed top-0 left-0 right-0 z-50"),K=(0,s.cn)(t==="default"&&!g&&"bg-gray-900 text-white",t==="transparent"&&!g&&"bg-transparent",t==="bordered"&&!g&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",t==="shadow"&&!g&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),V=(0,s.cn)(b==="sm"&&"py-2",b==="md"&&"py-4",b==="lg"&&"py-6"),X=g||"",Y=P||"",Z=R||"",$=(0,s.cn)(J,K,V,X,Y,q),I=(r,i,x=!1)=>{let ee=r.children&&r.children.length>0,H=C===i,y=(0,s.cn)("px-4 py-2 transition-colors flex items-center gap-2",x?"block w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(T||"border-current"),j||(t==="default"||t==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),D||Z||(t==="default"||t==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),O||"");if(ee)return(0,e.jsxs)("div",{className:x?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>G(i),className:y,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,s.cn)("w-4 h-4 transition-transform",H&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),H&&(0,e.jsx)("div",{className:(0,s.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",x?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(o=>(0,e.jsx)("a",{href:o.href,onClick:o.onClick,target:o.external?"_blank":void 0,rel:o.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[o.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:o.icon}),(0,e.jsx)("span",{children:o.label}),o.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:o.badge}),o.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},o.href??o.label))})]},r.href??r.label);let S=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),r.badge&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return r.onClick?(0,e.jsx)("button",{type:"button",onClick:r.onClick,className:y,children:S},r.href??r.label):(0,e.jsx)("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:y,children:S},r.href??r.label)};return(0,e.jsxs)("header",{className:$,children:[(0,e.jsxs)("nav",{className:(0,s.cn)("container mx-auto flex items-center justify-between px-4",A),children:[n&&(0,e.jsx)("div",{className:"flex items-center",children:a?(0,e.jsx)("a",{href:a,onClick:c,className:"flex items-center hover:opacity-80 transition-opacity",children:n}):(0,e.jsx)("div",{className:"flex items-center",children:n})}),k&&(0,e.jsx)("form",{onSubmit:M,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:d.map((r,i)=>I(r,i,!1))}),(l||p)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[l,p]}),d.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,s.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",t==="default"||t==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:U,"aria-label":_??w.headerToggleMenu,"aria-expanded":f,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),f&&d.length>0&&(0,e.jsx)("div",{className:(0,s.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",t==="default"||t==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[k&&(0,e.jsx)("form",{onSubmit:M,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":u,value:m,onChange:r=>L(r.target.value),placeholder:u,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((r,i)=>I(r,i,!0)),(l||p)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[l,p]})]})})]})}0&&(module.exports={Header});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as x}from"react";import{cn as
|
|
1
|
+
"use client";import{useState as x}from"react";import{cn as o}from"../../lib/cn.js";import{useUILabels as ee}from"../../lib/i18n.js";import{Fragment as re,jsx as r,jsxs as n}from"react/jsx-runtime";function ne({logo:p,logoHref:y="/",onLogoClick:S,navItems:d=[],actions:c,rightContent:i,variant:a="default",size:u="md",backgroundColor:l,textColor:B,hoverColor:P,navItemTextColor:R,navItemHoverColor:j,navItemBgHover:D,navItemActiveColor:O,sticky:T=!1,fixed:W=!1,showSearch:v=!1,onSearch:k,searchPlaceholder:z,menuLabel:Q,className:_,containerClassName:q}){let N=ee(),g=z??N.headerSearchPlaceholder,[h,A]=x(!1),[w,E]=x(null),[b,C]=x(""),F=()=>{A(!h)},U=e=>{E(w===e?null:e)},L=e=>{e.preventDefault(),k&&k(b)},G=o(T&&"sticky top-0 z-50",W&&"fixed top-0 left-0 right-0 z-50"),J=o(a==="default"&&!l&&"bg-gray-900 text-white",a==="transparent"&&!l&&"bg-transparent",a==="bordered"&&!l&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!l&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),K=o(u==="sm"&&"py-2",u==="md"&&"py-4",u==="lg"&&"py-6"),V=l||"",X=B||"",Y=P||"",Z=o(G,J,K,V,X,_),M=(e,s,f=!1)=>{let $=e.children&&e.children.length>0,I=w===s,m=o("px-4 py-2 transition-colors flex items-center gap-2",f?"block w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(O||"border-current"),R||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),j||Y||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-blue-600 dark:hover:text-blue-400"),D||"");if($)return n("div",{className:f?"w-full":"relative",children:[n("button",{type:"button",onClick:()=>U(s),className:m,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:o("w-4 h-4 transition-transform",I&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),I&&r("div",{className:o("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",f?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(t=>r("a",{href:t.href,onClick:t.onClick,target:t.external?"_blank":void 0,rel:t.external?"noopener noreferrer":void 0,className:"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700",children:n("div",{className:"flex items-center gap-2",children:[t.icon&&r("span",{className:"w-5 h-5",children:t.icon}),r("span",{children:t.label}),t.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:t.badge}),t.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})},t.href??t.label))})]},e.href??e.label);let H=n(re,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),e.badge&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return e.onClick?r("button",{type:"button",onClick:e.onClick,className:m,children:H},e.href??e.label):r("a",{href:e.href,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:m,children:H},e.href??e.label)};return n("header",{className:Z,children:[n("nav",{className:o("container mx-auto flex items-center justify-between px-4",q),children:[p&&r("div",{className:"flex items-center",children:y?r("a",{href:y,onClick:S,className:"flex items-center hover:opacity-80 transition-opacity",children:p}):r("div",{className:"flex items-center",children:p})}),v&&r("form",{onSubmit:L,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),r("div",{className:"hidden md:flex items-center gap-2",children:d.map((e,s)=>M(e,s,!1))}),(c||i)&&n("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[c,i]}),d.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:o("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-none",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:F,"aria-label":Q??N.headerToggleMenu,"aria-expanded":h,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),h&&d.length>0&&r("div",{className:o("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:n("div",{className:"flex flex-col py-2 px-4",children:[v&&r("form",{onSubmit:L,className:"mb-4",children:r("input",{type:"search","aria-label":g,value:b,onChange:e=>C(e.target.value),placeholder:g,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),d.map((e,s)=>M(e,s,!0)),(c||i)&&n("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[c,i]})]})})]})}export{ne as Header};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";"use client";var j=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(t,a)=>{for(var s in a)E(t,s,{get:a[s],enumerable:!0})},W=(t,a,s,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of J(a))!X.call(t,l)&&l!==s&&E(t,l,{get:()=>a[l],enumerable:!(d=F(a,l))||d.enumerable});return t};var H=(t,a,s)=>(s=t!=null?j(Q(t)):{},W(a||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t)),Z=t=>W(E({},"__esModule",{value:!0}),t);var ue={};Y(ue,{HelpButton:()=>$,WithHelpButton:()=>ce});module.exports=Z(ue);var o=require("react"),_=H(require("dompurify"),1),U=H(require("react-markdown"),1),A=H(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,e.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),te=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,e.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,e.jsx)("polyline",{points:"7 3 7 8 15 8"})]}),re=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,e.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),oe=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,e.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),ae=(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),(0,e.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),se={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},ne={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},le={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ie=[A.default],de={h1:({...t})=>(0,e.jsx)("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({...t})=>(0,e.jsx)("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({...t})=>(0,e.jsx)("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({...t})=>(0,e.jsx)("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({...t})=>(0,e.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({...t})=>(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({className:t,children:a,...s})=>!t?.includes("language-")?(0,e.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}):(0,e.jsx)("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...t}),strong:({...t})=>(0,e.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({...t})=>(0,e.jsx)("em",{className:"italic",...t}),blockquote:({...t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function $({content:t,markdown:a=!1,position:s="bottom",size:d="sm",className:l="",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,markdownEditor:h,markdownEditorUnavailableLabel:R,labels:M}){let r=(0,D.useUILabels)(M),[y,L]=(0,o.useState)(!1),[c,
|
|
1
|
+
"use strict";"use client";var j=Object.create;var E=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(t,a)=>{for(var s in a)E(t,s,{get:a[s],enumerable:!0})},W=(t,a,s,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of J(a))!X.call(t,l)&&l!==s&&E(t,l,{get:()=>a[l],enumerable:!(d=F(a,l))||d.enumerable});return t};var H=(t,a,s)=>(s=t!=null?j(Q(t)):{},W(a||!t||!t.__esModule?E(s,"default",{value:t,enumerable:!0}):s,t)),Z=t=>W(E({},"__esModule",{value:!0}),t);var ue={};Y(ue,{HelpButton:()=>$,WithHelpButton:()=>ce});module.exports=Z(ue);var o=require("react"),_=H(require("dompurify"),1),U=H(require("react-markdown"),1),A=H(require("remark-gfm"),1),D=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime"),ee=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,e.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),te=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,e.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,e.jsx)("polyline",{points:"7 3 7 8 15 8"})]}),re=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,e.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),oe=(0,e.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,e.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]}),ae=(0,e.jsxs)("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,e.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10"}),(0,e.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z",fill:"currentColor"})]}),se={xs:"w-4 h-4 text-[10px]",sm:"w-5 h-5 text-xs",md:"w-6 h-6 text-sm",lg:"w-7 h-7 text-base"},ne={top:"bottom-full left-1/2 -translate-x-1/2 mb-2",bottom:"top-full left-1/2 -translate-x-1/2 mt-2",left:"right-full top-1/2 -translate-y-1/2 mr-2",right:"left-full top-1/2 -translate-y-1/2 ml-2"},le={sm:"w-56",md:"w-72",lg:"w-96",xl:"w-[32rem]"},ie=[A.default],de={h1:({...t})=>(0,e.jsx)("h1",{className:"text-xl font-bold mb-2 text-gray-900 dark:text-gray-100",...t}),h2:({...t})=>(0,e.jsx)("h2",{className:"text-lg font-semibold mt-4 mb-2 text-gray-900 dark:text-gray-100",...t}),h3:({...t})=>(0,e.jsx)("h3",{className:"text-base font-semibold mt-3 mb-1 text-gray-900 dark:text-gray-100",...t}),p:({...t})=>(0,e.jsx)("p",{className:"my-1 text-gray-700 dark:text-gray-300",...t}),ul:({...t})=>(0,e.jsx)("ul",{className:"list-disc list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),ol:({...t})=>(0,e.jsx)("ol",{className:"list-decimal list-inside space-y-1 my-2 text-gray-700 dark:text-gray-300",...t}),code:({className:t,children:a,...s})=>!t?.includes("language-")?(0,e.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}):(0,e.jsx)("code",{className:"block bg-gray-100 dark:bg-gray-800 rounded-lg p-3 my-2 overflow-x-auto text-sm font-mono text-gray-900 dark:text-gray-100",...s,children:a}),pre:({...t})=>(0,e.jsx)("pre",{className:"my-2",...t}),a:({...t})=>(0,e.jsx)("a",{className:"text-blue-600 dark:text-blue-400 hover:underline",...t}),strong:({...t})=>(0,e.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",...t}),em:({...t})=>(0,e.jsx)("em",{className:"italic",...t}),blockquote:({...t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 my-2 italic text-gray-600 dark:text-gray-400",...t})};function $({content:t,markdown:a=!1,position:s="bottom",size:d="sm",className:l="",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,markdownEditor:h,markdownEditorUnavailableLabel:R,labels:M}){let r=(0,D.useUILabels)(M),[y,L]=(0,o.useState)(!1),[c,x]=(0,o.useState)(!1),[v,b]=(0,o.useState)(""),[I,k]=(0,o.useState)(!1),[S,n]=(0,o.useState)(null),T=(0,o.useRef)(null),O=(0,o.useRef)(null),P=(0,o.useRef)(null),i=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!y)return;let g=w=>{T.current&&!T.current.contains(w.target)&&O.current&&!O.current.contains(w.target)&&(c||L(!1))},z=w=>{w.key==="Escape"&&(c?(x(!1),b("")):L(!1))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",z)}},[y,c]),(0,o.useEffect)(()=>{c&&P.current&&P.current.focus()},[c]),(0,o.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let G=(0,o.useCallback)(()=>{b(typeof t=="string"?t:""),x(!0),n(null)},[t]),K=(0,o.useCallback)(()=>{x(!1),b(""),n(null)},[]),q=(0,o.useCallback)(async()=>{if(!m){n({type:"error",text:r.helpButtonNoSave});return}k(!0);try{await m(v)?(n({type:"success",text:r.helpButtonSaved}),x(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonSaveError})}catch{n({type:"error",text:r.helpButtonSaveError})}finally{k(!1)}},[v,m,r]),V=(0,o.useCallback)(async()=>{if(u&&confirm(r.helpButtonResetConfirm)){k(!0);try{await u()?(n({type:"success",text:r.helpButtonResetDone}),x(!1),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(null),2e3)):n({type:"error",text:r.helpButtonResetError})}catch{n({type:"error",text:r.helpButtonResetError})}finally{k(!1)}}},[u,r]),N=t;return C?(0,e.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,e.jsx)("button",{type:"button",ref:T,onClick:()=>L(!y),className:`
|
|
2
2
|
${se[d]}
|
|
3
3
|
inline-flex items-center justify-center
|
|
4
4
|
rounded-full border border-gray-300 dark:border-gray-600
|
|
@@ -19,4 +19,4 @@
|
|
|
19
19
|
rounded-xl shadow-xl
|
|
20
20
|
text-sm text-gray-700 dark:text-gray-300
|
|
21
21
|
animate-in fade-in-0 zoom-in-95 duration-150
|
|
22
|
-
`,role:"tooltip",children:[(p||f)&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:p&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:p})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:q,disabled:I,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-
|
|
22
|
+
`,role:"tooltip",children:[(p||f)&&(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:p&&(0,e.jsx)("h3",{className:"text-sm font-semibold",children:p})}),f&&(0,e.jsx)("div",{className:"flex items-center gap-1",children:c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{type:"button",onClick:q,disabled:I,className:"p-1.5 rounded-md hover:bg-green-100 dark:hover:bg-green-900/30 text-green-700 dark:text-green-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonSave,children:I?ae:te}),(0,e.jsx)("button",{type:"button",onClick:K,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonCancel,children:re}),u&&(0,e.jsx)("button",{type:"button",onClick:V,disabled:I,className:"p-1.5 rounded-md hover:bg-orange-100 dark:hover:bg-orange-900/30 text-orange-700 dark:text-orange-400 transition-colors disabled:opacity-50 cursor-pointer",title:r.helpButtonReset,children:oe})]}):(0,e.jsx)("button",{type:"button",onClick:G,className:"p-1.5 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors cursor-pointer",title:r.helpButtonEdit,children:ee})})]}),S&&(0,e.jsx)("div",{className:`px-4 py-2 text-xs ${S.type==="success"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400"}`,children:S.text}),(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:c?a?h?(0,e.jsx)(h,{value:v,onChange:b,placeholder:r.markdownEditorPlaceholder}):(0,e.jsx)("p",{role:"alert",className:"p-3 text-sm text-gray-500 dark:text-gray-400",children:R??r.markdownEditorUnavailable}):(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("textarea",{ref:P,"aria-label":r.helpButtonContent,value:v,onChange:g=>b(g.target.value),className:"w-full h-64 p-3 text-sm bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 text-gray-700 dark:text-gray-300 font-mono",placeholder:r.helpButtonContentPlaceholder})}):typeof N=="string"?(0,e.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:a?(0,e.jsx)(U.default,{remarkPlugins:ie,components:de,children:N}):(0,e.jsx)("div",{dangerouslySetInnerHTML:{__html:_.default.sanitize(N)}})}):N})]})]}):null}function ce({children:t,content:a,markdown:s=!1,position:d="bottom",size:l="sm",visible:C=!0,editable:f=!1,onSave:m,onReset:u,width:B="md",title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r}){return(0,e.jsxs)("div",{className:"inline-flex items-center gap-2.5",children:[t,(0,e.jsx)($,{content:a,markdown:s,position:d,size:l,visible:C,editable:f,onSave:m,onReset:u,width:B,title:p,className:h,markdownEditor:R,markdownEditorUnavailableLabel:M,labels:r})]})}0&&(module.exports={HelpButton,WithHelpButton});
|