@sth87/shadcn-design-system 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/cjs/components/Checkbox/Checkbox.cjs +1 -1
  2. package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  3. package/dist/cjs/components/Input/Input.cjs +1 -1
  4. package/dist/cjs/components/Input/Input.cjs.map +1 -1
  5. package/dist/cjs/components/Rate/Rate.cjs +1 -1
  6. package/dist/cjs/components/Rate/Rate.cjs.map +1 -1
  7. package/dist/cjs/components/Sheet/Sheet.cjs +1 -1
  8. package/dist/cjs/components/Sheet/Sheet.cjs.map +1 -1
  9. package/dist/cjs/components/Slider/Slider.cjs +1 -1
  10. package/dist/cjs/components/Slider/Slider.cjs.map +1 -1
  11. package/dist/cjs/components/Stepper/Stepper.cjs +1 -1
  12. package/dist/cjs/components/Stepper/Stepper.cjs.map +1 -1
  13. package/dist/cjs/components/Stepper/StepperWrapper.cjs +1 -1
  14. package/dist/cjs/components/Stepper/StepperWrapper.cjs.map +1 -1
  15. package/dist/cjs/components/Switch/Switch.cjs +1 -1
  16. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  17. package/dist/cjs/components/Table/data-table-column-header.cjs +1 -1
  18. package/dist/cjs/components/Table/data-table-column-header.cjs.map +1 -1
  19. package/dist/cjs/components/Tabs/classes.cjs +1 -1
  20. package/dist/cjs/components/Tabs/classes.cjs.map +1 -1
  21. package/dist/cjs/components/TimeGridView.cjs +1 -1
  22. package/dist/cjs/components/TimeGridView.cjs.map +1 -1
  23. package/dist/cjs/components/Toast/Toast.cjs +1 -1
  24. package/dist/cjs/components/Toast/Toast.cjs.map +1 -1
  25. package/dist/cjs/components/WheelColumn.cjs +1 -1
  26. package/dist/cjs/components/WheelColumn.cjs.map +1 -1
  27. package/dist/cjs/packages/ui/src/components/calendar.cjs +1 -1
  28. package/dist/cjs/packages/ui/src/components/calendar.cjs.map +1 -1
  29. package/dist/cjs/styles/index.css +1 -1
  30. package/dist/esm/components/Checkbox/Checkbox.js +20 -20
  31. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  32. package/dist/esm/components/Input/Input.js +43 -43
  33. package/dist/esm/components/Input/Input.js.map +1 -1
  34. package/dist/esm/components/Rate/Rate.js +15 -15
  35. package/dist/esm/components/Rate/Rate.js.map +1 -1
  36. package/dist/esm/components/Sheet/Sheet.js +25 -25
  37. package/dist/esm/components/Sheet/Sheet.js.map +1 -1
  38. package/dist/esm/components/Slider/Slider.js +139 -139
  39. package/dist/esm/components/Slider/Slider.js.map +1 -1
  40. package/dist/esm/components/Stepper/Stepper.js +52 -52
  41. package/dist/esm/components/Stepper/Stepper.js.map +1 -1
  42. package/dist/esm/components/Stepper/StepperWrapper.js +25 -25
  43. package/dist/esm/components/Stepper/StepperWrapper.js.map +1 -1
  44. package/dist/esm/components/Switch/Switch.js +19 -19
  45. package/dist/esm/components/Switch/Switch.js.map +1 -1
  46. package/dist/esm/components/Table/data-table-column-header.js +22 -22
  47. package/dist/esm/components/Table/data-table-column-header.js.map +1 -1
  48. package/dist/esm/components/Tabs/classes.js +128 -128
  49. package/dist/esm/components/Tabs/classes.js.map +1 -1
  50. package/dist/esm/components/TimeGridView.js +27 -27
  51. package/dist/esm/components/TimeGridView.js.map +1 -1
  52. package/dist/esm/components/Toast/Toast.js +26 -26
  53. package/dist/esm/components/Toast/Toast.js.map +1 -1
  54. package/dist/esm/components/WheelColumn.js +9 -9
  55. package/dist/esm/components/WheelColumn.js.map +1 -1
  56. package/dist/esm/packages/ui/src/components/calendar.js +73 -73
  57. package/dist/esm/packages/ui/src/components/calendar.js.map +1 -1
  58. package/dist/esm/styles/index.css +1 -1
  59. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),o=require("react"),F=require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");const M=require("../../packages/ui/src/components/label.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");const a=require("../../packages/ui/src/lib/utils.cjs"),f=require("lucide-react");require("react-day-picker");require("../../packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("vaul");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const p=require("../Tooltip/Tooltip.cjs"),D=require("motion/react"),L=require("../../utils/css.cjs"),b=o.forwardRef((g,j)=>{const{label:r,infoTooltip:t,helperText:i,state:c,variant:C="default",size:v="default",color:N,labelPosition:s="right",labelAlignment:d="center",icon:w,animation:T,id:k,onCheckedChange:u,...y}=g,[I,x]=o.useState(!1),S=o.useId(),n=k||S,P={default:"ds:text-muted-foreground",success:"ds:text-success",warning:"ds:text-warning",error:"ds:text-error"},R=l=>{l&&(x(!0),setTimeout(()=>x(!1),800)),u?.(l)},q=s==="top"||s==="bottom",z=q?"flex-col":"flex-row",A=q?"gap-1.5":"gap-2",_=d==="start"?"items-start":d==="center"?"items-center":"items-end",m="flex gap-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-70";return e.jsxs("div",{className:a.cn("ds:flex ds:flex-col ds:gap-1.5 ds:relative",{}),children:[e.jsxs("div",{className:a.cn("ds:flex",z,A,_),children:[(s==="top"||s==="left")&&r&&e.jsxs("label",{htmlFor:n,className:m,children:[r,t&&e.jsx(p.Tooltip,{content:t,children:e.jsx(f.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]}),e.jsxs("div",{className:"ds:relative ds:inline-flex",children:[e.jsx(F.Checkbox,{ref:j,id:n,...y,variant:C,size:v,color:N,icon:w,onCheckedChange:T?R:u}),e.jsx(D.AnimatePresence,{children:I&&e.jsx("div",{className:"ds:pointer-events-none ds:absolute ds:inset-0",children:[...Array(12)].map((l,h)=>e.jsx(L.ConfettiPiece,{index:h},h))})})]}),(s==="bottom"||s==="right")&&r&&e.jsxs(M.Label,{htmlFor:n,className:m,children:[r,t&&e.jsx(p.Tooltip,{content:t,children:e.jsx(f.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]})]}),i&&e.jsx("div",{className:"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2",children:i&&e.jsx("p",{className:a.cn("ds:text-xs",c?P?.[c]:""),children:i})})]})});b.displayName="Checkbox";exports.default=b;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),o=require("react"),F=require("../../packages/ui/src/components/checkbox.cjs");require("@radix-ui/react-slot");require("../../packages/ui/src/components/button.cjs");require("../../packages/ui/src/components/button-group.cjs");require("../../packages/ui/src/components/input.cjs");require("../../packages/ui/src/components/textarea.cjs");const M=require("../../packages/ui/src/components/label.cjs");require("../../packages/ui/src/components/select.cjs");require("../../packages/ui/src/components/combobox.cjs");require("@radix-ui/react-tooltip");const a=require("../../packages/ui/src/lib/utils.cjs"),f=require("lucide-react");require("react-day-picker");require("../../packages/ui/src/components/popover.cjs");require("@radix-ui/react-separator");require("../../packages/ui/src/components/switch.cjs");require("vaul");require("@radix-ui/react-scroll-area");require("../../packages/ui/src/components/tree-view.cjs");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-avatar");require("../../packages/ui/src/components/badge.cjs");require("@radix-ui/react-collapsible");require("cmdk");require("@radix-ui/react-dialog");require("@radix-ui/react-dropdown-menu");require("../../packages/ui/src/components/input-otp.cjs");require("../../packages/ui/src/components/radio-group.cjs");require("../../packages/ui/src/components/sidebar.cjs");require("@radix-ui/react-slider");require("../../packages/ui/src/components/tabs.cjs");require("../../packages/ui/src/components/toggle.cjs");const p=require("../Tooltip/Tooltip.cjs"),D=require("motion/react"),L=require("../../utils/css.cjs"),b=o.forwardRef((g,j)=>{const{label:r,infoTooltip:t,helperText:i,state:d,variant:C="default",size:v="default",color:N,labelPosition:s="right",labelAlignment:c="center",icon:w,animation:T,id:k,onCheckedChange:u,...y}=g,[I,x]=o.useState(!1),S=o.useId(),n=k||S,P={default:"ds:text-muted-foreground",success:"ds:text-success",warning:"ds:text-warning",error:"ds:text-error"},R=l=>{l&&(x(!0),setTimeout(()=>x(!1),800)),u?.(l)},q=s==="top"||s==="bottom",z=q?"ds:flex-col":"ds:flex-row",A=q?"ds:gap-1.5":"ds:gap-2",_=c==="start"?"ds:items-start":c==="center"?"ds:items-center":"ds:items-end",m="ds:flex ds:gap-2 ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70";return e.jsxs("div",{className:a.cn("ds:flex ds:flex-col ds:gap-1.5 ds:relative",{}),children:[e.jsxs("div",{className:a.cn("ds:flex",z,A,_),children:[(s==="top"||s==="left")&&r&&e.jsxs("label",{htmlFor:n,className:m,children:[r,t&&e.jsx(p.Tooltip,{content:t,children:e.jsx(f.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]}),e.jsxs("div",{className:"ds:relative ds:inline-flex",children:[e.jsx(F.Checkbox,{ref:j,id:n,...y,variant:C,size:v,color:N,icon:w,onCheckedChange:T?R:u}),e.jsx(D.AnimatePresence,{children:I&&e.jsx("div",{className:"ds:pointer-events-none ds:absolute ds:inset-0",children:[...Array(12)].map((l,h)=>e.jsx(L.ConfettiPiece,{index:h},h))})})]}),(s==="bottom"||s==="right")&&r&&e.jsxs(M.Label,{htmlFor:n,className:m,children:[r,t&&e.jsx(p.Tooltip,{content:t,children:e.jsx(f.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]})]}),i&&e.jsx("div",{className:"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2",children:i&&e.jsx("p",{className:a.cn("ds:text-xs",d?P?.[d]:""),children:i})})]})});b.displayName="Checkbox";exports.default=b;
2
2
  //# sourceMappingURL=Checkbox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Checkbox as SCheckbox } from \"@dsui/ui/components/checkbox\";\nimport { cn } from \"@dsui/ui/index\";\nimport { Tooltip } from \"../Tooltip/Tooltip\";\nimport { Label } from \"../Label\";\nimport { Info } from \"lucide-react\";\nimport { AnimatePresence } from \"motion/react\";\nimport { ConfettiPiece } from \"@/utils/css\";\nimport type { CheckedState } from \"@radix-ui/react-checkbox\";\n\nexport type CheckboxProps = Omit<\n React.ComponentPropsWithoutRef<typeof SCheckbox>,\n \"onCheckedChange\" | \"variant\" | \"size\" | \"color\" | \"icon\"\n> & {\n onCheckedChange?: (checked: CheckedState) => void;\n variant?: \"default\" | \"circle\";\n size?: \"sm\" | \"default\" | \"lg\";\n color?:\n | \"primary\"\n | \"secondary\"\n | \"accent\"\n | \"destructive\"\n | \"muted\"\n | \"success\"\n | \"error\"\n | \"warning\";\n icon?: React.ReactNode;\n label?: React.ReactNode;\n labelPosition?: \"top\" | \"left\" | \"right\" | \"bottom\";\n labelAlignment?: \"start\" | \"center\" | \"end\";\n infoTooltip?: React.ReactNode;\n helperText?: React.ReactNode;\n state?: \"default\" | \"error\" | \"success\" | \"warning\";\n animation?: \"confetti\" | undefined;\n};\n\nconst Checkbox = React.forwardRef<HTMLButtonElement, CheckboxProps>(\n (props, ref) => {\n const {\n label,\n infoTooltip,\n helperText,\n state,\n variant = \"default\",\n size = \"default\",\n color,\n labelPosition = \"right\",\n labelAlignment = \"center\",\n icon,\n animation,\n id,\n onCheckedChange,\n ...rest\n } = props;\n const [showConfetti, setShowConfetti] = useState(false);\n const generatedId = React.useId();\n const inputId = id || generatedId;\n\n // State\n const helperTextStyles = {\n default: \"ds:text-muted-foreground\",\n success: \"ds:text-success\",\n warning: \"ds:text-warning\",\n error: \"ds:text-error\",\n };\n\n const handleCheckedChange = (checked: CheckedState) => {\n if (checked) {\n setShowConfetti(true);\n setTimeout(() => setShowConfetti(false), 800);\n }\n onCheckedChange?.(checked);\n };\n\n const isVertical = labelPosition === \"top\" || labelPosition === \"bottom\";\n const flexDirection = isVertical ? \"flex-col\" : \"flex-row\";\n const gapClass = isVertical ? \"gap-1.5\" : \"gap-2\";\n\n const alignmentClass =\n labelAlignment === \"start\"\n ? \"items-start\"\n : labelAlignment === \"center\"\n ? \"items-center\"\n : \"items-end\";\n\n const labelClass =\n \"flex gap-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-70\";\n\n return (\n <div className={cn(\"ds:flex ds:flex-col ds:gap-1.5 ds:relative\", {})}>\n <div className={cn(\"ds:flex\", flexDirection, gapClass, alignmentClass)}>\n {(labelPosition === \"top\" || labelPosition === \"left\") && label && (\n <label htmlFor={inputId} className={labelClass}>\n {label}\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </label>\n )}\n\n <div className=\"ds:relative ds:inline-flex\">\n <SCheckbox\n ref={ref}\n id={inputId}\n {...rest}\n variant={variant}\n size={size}\n color={color}\n icon={icon}\n onCheckedChange={\n animation ? handleCheckedChange : onCheckedChange\n }\n />\n\n <AnimatePresence>\n {showConfetti && (\n <div className=\"ds:pointer-events-none ds:absolute ds:inset-0\">\n {[...Array(12)].map((_, i) => (\n <ConfettiPiece key={i} index={i} />\n ))}\n </div>\n )}\n </AnimatePresence>\n </div>\n\n {(labelPosition === \"bottom\" || labelPosition === \"right\") &&\n label && (\n <Label htmlFor={inputId} className={labelClass}>\n {label}\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </Label>\n )}\n </div>\n\n {helperText && (\n <div className=\"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2\">\n {helperText && (\n <p\n className={cn(\n \"ds:text-xs\",\n state ? helperTextStyles?.[state] : \"\"\n )}\n >\n {helperText}\n </p>\n )}\n </div>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","label","infoTooltip","helperText","state","variant","size","color","labelPosition","labelAlignment","icon","animation","id","onCheckedChange","rest","showConfetti","setShowConfetti","useState","generatedId","inputId","helperTextStyles","handleCheckedChange","checked","isVertical","flexDirection","gapClass","alignmentClass","labelClass","cn","jsxs","Tooltip","jsx","Info","SCheckbox","AnimatePresence","_","i","ConfettiPiece","Label"],"mappings":"wsDAoCMA,EAAWC,EAAM,WACrB,CAACC,EAAOC,IAAQ,CACd,KAAM,CAAA,MACJC,EACA,YAAAC,EACA,WAAAC,EACA,MAAAC,EACA,QAAAC,EAAU,UACV,KAAAC,EAAO,UACP,MAAAC,EACA,cAAAC,EAAgB,QAChB,eAAAC,EAAiB,SACjB,KAAAC,EACA,UAAAC,EACA,GAAAC,EACA,gBAAAC,EACA,GAAGC,CAAA,EACDf,EACE,CAACgB,EAAcC,CAAe,EAAIC,EAAAA,SAAS,EAAK,EAChDC,EAAcpB,EAAM,MAAA,EACpBqB,EAAUP,GAAMM,EAGhBE,EAAmB,CACvB,QAAS,2BACT,QAAS,kBACT,QAAS,kBACT,MAAO,eAAA,EAGHC,EAAuBC,GAA0B,CACjDA,IACFN,EAAgB,EAAI,EACpB,WAAW,IAAMA,EAAgB,EAAK,EAAG,GAAG,GAE9CH,IAAkBS,CAAO,CAC3B,EAEMC,EAAaf,IAAkB,OAASA,I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A,EAEN,EAEC7B,GACC4B,EAAAA,IAAC,MAAA,CAAI,UAAU,iEACZ,SAAA5B,GACC4B,EAAAA,IAAC,IAAA,CACC,UAAWH,EAAAA,GACT,aACAxB,EAAQgB,IAAmBhB,CAAK,EAAI,EAAA,EAGrC,SAAAD,CAAA,CAAA,CACH,CAEJ,CAAA,EAEJ,CAEJ,CACF,EAEAN,EAAS,YAAc"}
1
+ {"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Checkbox as SCheckbox } from \"@dsui/ui/components/checkbox\";\nimport { cn } from \"@dsui/ui/index\";\nimport { Tooltip } from \"../Tooltip/Tooltip\";\nimport { Label } from \"../Label\";\nimport { Info } from \"lucide-react\";\nimport { AnimatePresence } from \"motion/react\";\nimport { ConfettiPiece } from \"@/utils/css\";\nimport type { CheckedState } from \"@radix-ui/react-checkbox\";\n\nexport type CheckboxProps = Omit<\n React.ComponentPropsWithoutRef<typeof SCheckbox>,\n \"onCheckedChange\" | \"variant\" | \"size\" | \"color\" | \"icon\"\n> & {\n onCheckedChange?: (checked: CheckedState) => void;\n variant?: \"default\" | \"circle\";\n size?: \"sm\" | \"default\" | \"lg\";\n color?:\n | \"primary\"\n | \"secondary\"\n | \"accent\"\n | \"destructive\"\n | \"muted\"\n | \"success\"\n | \"error\"\n | \"warning\";\n icon?: React.ReactNode;\n label?: React.ReactNode;\n labelPosition?: \"top\" | \"left\" | \"right\" | \"bottom\";\n labelAlignment?: \"start\" | \"center\" | \"end\";\n infoTooltip?: React.ReactNode;\n helperText?: React.ReactNode;\n state?: \"default\" | \"error\" | \"success\" | \"warning\";\n animation?: \"confetti\" | undefined;\n};\n\nconst Checkbox = React.forwardRef<HTMLButtonElement, CheckboxProps>(\n (props, ref) => {\n const {\n label,\n infoTooltip,\n helperText,\n state,\n variant = \"default\",\n size = \"default\",\n color,\n labelPosition = \"right\",\n labelAlignment = \"center\",\n icon,\n animation,\n id,\n onCheckedChange,\n ...rest\n } = props;\n const [showConfetti, setShowConfetti] = useState(false);\n const generatedId = React.useId();\n const inputId = id || generatedId;\n\n // State\n const helperTextStyles = {\n default: \"ds:text-muted-foreground\",\n success: \"ds:text-success\",\n warning: \"ds:text-warning\",\n error: \"ds:text-error\",\n };\n\n const handleCheckedChange = (checked: CheckedState) => {\n if (checked) {\n setShowConfetti(true);\n setTimeout(() => setShowConfetti(false), 800);\n }\n onCheckedChange?.(checked);\n };\n\n const isVertical = labelPosition === \"top\" || labelPosition === \"bottom\";\n const flexDirection = isVertical ? \"ds:flex-col\" : \"ds:flex-row\";\n const gapClass = isVertical ? \"ds:gap-1.5\" : \"ds:gap-2\";\n\n const alignmentClass =\n labelAlignment === \"start\"\n ? \"ds:items-start\"\n : labelAlignment === \"center\"\n ? \"ds:items-center\"\n : \"ds:items-end\";\n\n const labelClass =\n \"ds:flex ds:gap-2 ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70\";\n\n return (\n <div className={cn(\"ds:flex ds:flex-col ds:gap-1.5 ds:relative\", {})}>\n <div className={cn(\"ds:flex\", flexDirection, gapClass, alignmentClass)}>\n {(labelPosition === \"top\" || labelPosition === \"left\") && label && (\n <label htmlFor={inputId} className={labelClass}>\n {label}\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </label>\n )}\n\n <div className=\"ds:relative ds:inline-flex\">\n <SCheckbox\n ref={ref}\n id={inputId}\n {...rest}\n variant={variant}\n size={size}\n color={color}\n icon={icon}\n onCheckedChange={\n animation ? handleCheckedChange : onCheckedChange\n }\n />\n\n <AnimatePresence>\n {showConfetti && (\n <div className=\"ds:pointer-events-none ds:absolute ds:inset-0\">\n {[...Array(12)].map((_, i) => (\n <ConfettiPiece key={i} index={i} />\n ))}\n </div>\n )}\n </AnimatePresence>\n </div>\n\n {(labelPosition === \"bottom\" || labelPosition === \"right\") &&\n label && (\n <Label htmlFor={inputId} className={labelClass}>\n {label}\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </Label>\n )}\n </div>\n\n {helperText && (\n <div className=\"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2\">\n {helperText && (\n <p\n className={cn(\n \"ds:text-xs\",\n state ? helperTextStyles?.[state] : \"\"\n )}\n >\n {helperText}\n </p>\n )}\n </div>\n )}\n </div>\n );\n }\n);\n\nCheckbox.displayName = \"Checkbox\";\nexport default Checkbox;\n"],"names":["Checkbox","React","props","ref","label","infoTooltip","helperText","state","variant","size","color","labelPosition","labelAlignment","icon","animation","id","onCheckedChange","rest","showConfetti","setShowConfetti","useState","generatedId","inputId","helperTextStyles","handleCheckedChange","checked","isVertical","flexDirection","gapClass","alignmentClass","labelClass","cn","jsxs","Tooltip","jsx","Info","SCheckbox","AnimatePresence","_","i","ConfettiPiece","Label"],"mappings":"wsDAoCMA,EAAWC,EAAM,WACrB,CAACC,EAAOC,IAAQ,CACd,KAAM,CAAA,MACJC,EACA,YAAAC,EACA,WAAAC,EACA,MAAAC,EACA,QAAAC,EAAU,UACV,KAAAC,EAAO,UACP,MAAAC,EACA,cAAAC,EAAgB,QAChB,eAAAC,EAAiB,SACjB,KAAAC,EACA,UAAAC,EACA,GAAAC,EACA,gBAAAC,EACA,GAAGC,CAAA,EACDf,EACE,CAACgB,EAAcC,CAAe,EAAIC,EAAAA,SAAS,EAAK,EAChDC,EAAcpB,EAAM,MAAA,EACpBqB,EAAUP,GAAMM,EAGhBE,EAAmB,CACvB,QAAS,2BACT,QAAS,kBACT,QAAS,kBACT,MAAO,eAAA,EAGHC,EAAuBC,GAA0B,CACjDA,IACFN,EAAgB,EAAI,EACpB,WAAW,IAAMA,EAAgB,EAAK,EAAG,GAAG,GAE9CH,IAAkBS,CAAO,CAC3B,EAEMC,EAAaf,IAAkB,OAASA,IAAkB,SAC1DgB,EAAgBD,E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B,EAAAA,IAAC,MAAA,CAAI,UAAU,iEACZ,SAAA5B,GACC4B,EAAAA,IAAC,IAAA,CACC,UAAWH,EAAAA,GACT,aACAxB,EAAQgB,IAAmBhB,CAAK,EAAI,EAAA,EAGrC,SAAAD,CAAA,CAAA,CACH,CAEJ,CAAA,EAEJ,CAEJ,CACF,EAEAN,EAAS,YAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),r=require("react"),Q=require("../../packages/ui/src/components/input.cjs"),a=require("../../packages/ui/src/lib/utils.cjs"),W=require("../FloatLabel.cjs"),m=require("lucide-react"),Y=require("use-mask-input"),Z=require("../Tooltip/Tooltip.cjs"),F=require("../../packages/ui/src/components/label.cjs"),D=r.forwardRef(({className:_,label:v,helperText:p,state:N,size:l,isFloatLabel:c,type:d,mask:f,maskOptions:E,maxLength:x,showCharCount:M,infoTooltip:j,clearable:b,onClear:P,prefixIcon:o,suffixIcon:i,placeholder:B=" ",required:w,...e},H)=>{const[g,R]=r.useState(()=>typeof e.value=="string"?e.value.length:typeof e.defaultValue=="string"?e.defaultValue.length:0),O=t=>{R(t.target.value.length),e.onChange&&e.onChange(t)},T=()=>{if(n.current){n.current.value="",R(0);const t={target:n.current,currentTarget:n.current};e.onChange?.(t),P&&P()}},C=r.useId(),n=r.useRef(null),U=r.useCallback(t=>{if(n&&(n.current=t),f&&t){const u=Y.withMask(f,E);typeof u=="function"&&u(t)}},[f,E]);r.useImperativeHandle(H,()=>n.current);const[V,X]=r.useState(!1),A={default:"ds:text-muted-foreground",success:"ds:text-success",warning:"ds:text-warning",error:"ds:text-error"},y=c?l==="xl"||l==="lg"?l:"xl":l||"normal",k=(()=>{const t={xs:{prefix:"pl-8",suffix:"pr-8"},sm:{prefix:"pl-9",suffix:"pr-9"},normal:{prefix:"pl-10",suffix:"pr-10"},lg:{prefix:"pl-11",suffix:"pr-11"},xl:{prefix:"pl-12",suffix:"pr-12"}};return t[y]||t.normal})(),q={xs:"size-3",sm:"size-3.5",normal:"size-4",lg:"size-4",xl:"size-4"}[y]||"size-4",G=()=>{const t=d==="number"||d==="password"||d==="datetime"||b&&(g>0||e?.value);return t&&i?d==="password"&&b&&(g>0||e?.value)?"pr-20":"pr-16":t?d==="password"&&b&&(g>0||e?.value)?"pr-16":"pr-10":i?k.suffix:""},I=(()=>{const t={xs:{left:"left-2.5",right:"right-2.5"},sm:{left:"left-3",right:"right-3"},normal:{left:"left-3",right:"right-3"},lg:{left:"left-3.5",right:"right-3.5"},xl:{left:"left-4",right:"right-4"}};return t[y]||t.normal})(),J=()=>{if(n.current){const t=Number(e.step||1),u=e.max?Number(e.max):1/0,z=Number(n.current.value||0),S=Math.min(z+t,u);n.current.value=String(S);const h=new Event("input",{bubbles:!0});n.current.dispatchEvent(h),e.onChange?.(h)}},K=()=>{if(n.current){const t=Number(e.step||1),u=e.min?Number(e.min):-1/0,z=Number(n.current.value||0),S=Math.max(z-t,u);n.current.value=String(S);const h=new Event("input",{bubbles:!0});n.current.dispatchEvent(h),e.onChange?.(h)}};return s.jsx("div",{className:_,children:s.jsxs("div",{className:a.cn("ds:flex ds:flex-col ds:gap-1.5 ds:relative ds:flex-auto",{"ds:floating-label ds:relative":c}),children:[!c&&v&&s.jsxs(F.Label,{htmlFor:C,className:"ds:flex ds:gap-2 ds:text-sm ds:font-medium ds:leading-none ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70",children:[s.jsxs("span",{children:[v,w&&s.jsx("span",{className:"ds:text-error ds:ml-0.5",children:"*"})]}),j&&s.jsx(Z.Tooltip,{content:j,children:s.jsx(m.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]}),s.jsxs("div",{className:"ds:relative",children:[o&&s.jsx("div",{className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0",I.left),children:r.isValidElement(o)?r.cloneElement(o,{className:a.cn(q,o.props?.className)}):o}),s.jsx(Q.Input,{ref:U,id:C,className:a.cn("ds:peer",{"ds:pt-5 ds:pb-1":c&&l!=="lg","ds:[&::-webkit-outer-spin-button]:appearance-none ds:[&::-webkit-inner-spin-button]:appearance-none ds:[-moz-appearance:textfield] ds:pr-8":d==="number"},o&&k.prefix,f&&"ds:placeholder:text-slate-400 ds:placeholder:opacity-100",G()),state:N,size:c?l==="xl"||l==="lg"?l:"xl":l,type:d==="password"?V?"text":"password":d,placeholder:B,maxLength:x,onChange:O,required:w,...e}),c&&s.jsx(W.FloatingLabel,{htmlFor:C,size:l,infoTooltip:j,required:w,children:v}),d==="number"&&s.jsxs("div",{className:"ds:absolute ds:right-1 ds:top-0 ds:h-full ds:flex ds:flex-col ds:gap-0.5",children:[s.jsx("button",{type:"button",onClick:J,disabled:e.disabled,className:a.cn("ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform","ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent"),tabIndex:-1,children:s.jsx(m.ChevronUp,{className:"ds:size-3"})}),s.jsx("button",{type:"button",onClick:K,disabled:e.disabled,className:a.cn("ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform","ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent"),tabIndex:-1,children:s.jsx(m.ChevronDown,{className:"ds:size-3"})})]}),b&&(g>0||e?.value)&&!e.disabled&&d!=="number"&&s.jsx("button",{type:"button",tabIndex:-1,className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors ds:cursor-pointer",d==="password"?i?"ds:right-14":"ds:right-10":i?"ds:right-10":"ds:right-2"),onClick:T,disabled:e.disabled,children:s.jsx(m.X,{className:"ds:size-4"})}),d==="password"&&s.jsx("button",{type:"button",tabIndex:-1,className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors",i?"ds:right-10":"ds:right-2"),onClick:()=>X(t=>!t),disabled:e.disabled,children:V?s.jsx(m.EyeOff,{className:"ds:size-4"}):s.jsx(m.Eye,{className:"ds:size-4"})}),i&&s.jsx("div",{className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0",I.right),children:r.isValidElement(i)?r.cloneElement(i,{className:a.cn(q,i.props?.className)}):i})]}),(p||M&&typeof x=="number")&&s.jsxs("div",{className:"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2",children:[p&&s.jsx("p",{className:a.cn("ds:text-xs",N?A?.[N]:""),children:p}),M&&typeof x=="number"&&s.jsxs("span",{className:"ds:ml-auto ds:text-muted-foreground",children:[g," / ",x]})]})]})})});D.displayName="Input";exports.default=D;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),r=require("react"),Q=require("../../packages/ui/src/components/input.cjs"),a=require("../../packages/ui/src/lib/utils.cjs"),W=require("../FloatLabel.cjs"),m=require("lucide-react"),Y=require("use-mask-input"),Z=require("../Tooltip/Tooltip.cjs"),F=require("../../packages/ui/src/components/label.cjs"),D=r.forwardRef(({className:_,label:v,helperText:p,state:N,size:l,isFloatLabel:c,type:d,mask:f,maskOptions:E,maxLength:x,showCharCount:M,infoTooltip:j,clearable:b,onClear:P,prefixIcon:o,suffixIcon:i,placeholder:B=" ",required:w,...e},H)=>{const[g,R]=r.useState(()=>typeof e.value=="string"?e.value.length:typeof e.defaultValue=="string"?e.defaultValue.length:0),O=t=>{R(t.target.value.length),e.onChange&&e.onChange(t)},T=()=>{if(n.current){n.current.value="",R(0);const t={target:n.current,currentTarget:n.current};e.onChange?.(t),P&&P()}},C=r.useId(),n=r.useRef(null),U=r.useCallback(t=>{if(n&&(n.current=t),f&&t){const u=Y.withMask(f,E);typeof u=="function"&&u(t)}},[f,E]);r.useImperativeHandle(H,()=>n.current);const[V,X]=r.useState(!1),A={default:"ds:text-muted-foreground",success:"ds:text-success",warning:"ds:text-warning",error:"ds:text-error"},y=c?l==="xl"||l==="lg"?l:"xl":l||"normal",k=(()=>{const t={xs:{prefix:"ds:pl-8",suffix:"ds:pr-8"},sm:{prefix:"ds:pl-9",suffix:"ds:pr-9"},normal:{prefix:"ds:pl-10",suffix:"ds:pr-10"},lg:{prefix:"ds:pl-11",suffix:"ds:pr-11"},xl:{prefix:"ds:pl-12",suffix:"ds:pr-12"}};return t[y]||t.normal})(),q={xs:"ds:size-3",sm:"ds:size-3.5",normal:"ds:size-4",lg:"ds:size-4",xl:"ds:size-4"}[y]||"ds:size-4",G=()=>{const t=d==="number"||d==="password"||d==="datetime"||b&&(g>0||e?.value);return t&&i?d==="password"&&b&&(g>0||e?.value)?"ds:pr-20":"ds:pr-16":t?d==="password"&&b&&(g>0||e?.value)?"ds:pr-16":"ds:pr-10":i?k.suffix:""},I=(()=>{const t={xs:{left:"ds:left-2.5",right:"ds:right-2.5"},sm:{left:"ds:left-3",right:"ds:right-3"},normal:{left:"ds:left-3",right:"ds:right-3"},lg:{left:"ds:left-3.5",right:"ds:right-3.5"},xl:{left:"ds:left-4",right:"ds:right-4"}};return t[y]||t.normal})(),J=()=>{if(n.current){const t=Number(e.step||1),u=e.max?Number(e.max):1/0,z=Number(n.current.value||0),S=Math.min(z+t,u);n.current.value=String(S);const h=new Event("input",{bubbles:!0});n.current.dispatchEvent(h),e.onChange?.(h)}},K=()=>{if(n.current){const t=Number(e.step||1),u=e.min?Number(e.min):-1/0,z=Number(n.current.value||0),S=Math.max(z-t,u);n.current.value=String(S);const h=new Event("input",{bubbles:!0});n.current.dispatchEvent(h),e.onChange?.(h)}};return s.jsx("div",{className:_,children:s.jsxs("div",{className:a.cn("ds:flex ds:flex-col ds:gap-1.5 ds:relative ds:flex-auto",{"ds:floating-label ds:relative":c}),children:[!c&&v&&s.jsxs(F.Label,{htmlFor:C,className:"ds:flex ds:gap-2 ds:text-sm ds:font-medium ds:leading-none ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70",children:[s.jsxs("span",{children:[v,w&&s.jsx("span",{className:"ds:text-error ds:ml-0.5",children:"*"})]}),j&&s.jsx(Z.Tooltip,{content:j,children:s.jsx(m.Info,{className:"ds:size-3.5 ds:min-w-3.5"})})]}),s.jsxs("div",{className:"ds:relative",children:[o&&s.jsx("div",{className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0",I.left),children:r.isValidElement(o)?r.cloneElement(o,{className:a.cn(q,o.props?.className)}):o}),s.jsx(Q.Input,{ref:U,id:C,className:a.cn("ds:peer",{"ds:pt-5 ds:pb-1":c&&l!=="lg","ds:[&::-webkit-outer-spin-button]:appearance-none ds:[&::-webkit-inner-spin-button]:appearance-none ds:[-moz-appearance:textfield] ds:pr-8":d==="number"},o&&k.prefix,f&&"ds:placeholder:text-slate-400 ds:placeholder:opacity-100",G()),state:N,size:c?l==="xl"||l==="lg"?l:"xl":l,type:d==="password"?V?"text":"password":d,placeholder:B,maxLength:x,onChange:O,required:w,...e}),c&&s.jsx(W.FloatingLabel,{htmlFor:C,size:l,infoTooltip:j,required:w,children:v}),d==="number"&&s.jsxs("div",{className:"ds:absolute ds:right-1 ds:top-0 ds:h-full ds:flex ds:flex-col ds:gap-0.5",children:[s.jsx("button",{type:"button",onClick:J,disabled:e.disabled,className:a.cn("ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform","ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent"),tabIndex:-1,children:s.jsx(m.ChevronUp,{className:"ds:size-3"})}),s.jsx("button",{type:"button",onClick:K,disabled:e.disabled,className:a.cn("ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform","ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent"),tabIndex:-1,children:s.jsx(m.ChevronDown,{className:"ds:size-3"})})]}),b&&(g>0||e?.value)&&!e.disabled&&d!=="number"&&s.jsx("button",{type:"button",tabIndex:-1,className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors ds:cursor-pointer",d==="password"?i?"ds:right-14":"ds:right-10":i?"ds:right-10":"ds:right-2"),onClick:T,disabled:e.disabled,children:s.jsx(m.X,{className:"ds:size-4"})}),d==="password"&&s.jsx("button",{type:"button",tabIndex:-1,className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors",i?"ds:right-10":"ds:right-2"),onClick:()=>X(t=>!t),disabled:e.disabled,children:V?s.jsx(m.EyeOff,{className:"ds:size-4"}):s.jsx(m.Eye,{className:"ds:size-4"})}),i&&s.jsx("div",{className:a.cn("ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0",I.right),children:r.isValidElement(i)?r.cloneElement(i,{className:a.cn(q,i.props?.className)}):i})]}),(p||M&&typeof x=="number")&&s.jsxs("div",{className:"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2",children:[p&&s.jsx("p",{className:a.cn("ds:text-xs",N?A?.[N]:""),children:p}),M&&typeof x=="number"&&s.jsxs("span",{className:"ds:ml-auto ds:text-muted-foreground",children:[g," / ",x]})]})]})})});D.displayName="Input";exports.default=D;
2
2
  //# sourceMappingURL=Input.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.cjs","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { type ChangeEvent } from \"react\";\nimport {\n Input as SInput,\n type InputProps as SInputProps,\n} from \"@dsui/ui/components/input\";\nimport { cn } from \"@dsui/ui/lib/utils\";\nimport { FloatingLabel } from \"@/components/FloatLabel\";\nimport { Eye, EyeOff, ChevronDown, ChevronUp, Info, X } from \"lucide-react\";\nimport { withMask, type Options } from \"use-mask-input\";\nimport { Tooltip } from \"../Tooltip/Tooltip\";\nimport { Label } from \"../Label\";\n\n// Re-export base input props to avoid external dependency issues\nexport type BaseInputProps = Omit<React.ComponentProps<\"input\">, \"size\"> & {\n size?: \"normal\" | \"sm\" | \"xs\" | \"lg\" | \"xl\";\n state?: \"default\" | \"success\" | \"error\" | \"warning\";\n};\n\nexport type InputProps = BaseInputProps & {\n label?: string;\n helperText?: React.ReactNode;\n isFloatLabel?: boolean;\n mask?: string;\n maskOptions?: {\n placeholder?: string;\n inputFormat?: string;\n outputFormat?: string;\n showMaskOnHover?: boolean;\n showMaskOnFocus?: boolean;\n separate?: boolean;\n } & Options;\n maxLength?: number;\n showCharCount?: boolean;\n infoTooltip?: React.ReactNode;\n clearable?: boolean;\n onClear?: () => void;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n required?: boolean;\n};\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n label,\n helperText,\n state,\n size,\n isFloatLabel,\n type,\n mask,\n maskOptions,\n maxLength,\n showCharCount,\n infoTooltip,\n clearable,\n onClear,\n prefixIcon,\n suffixIcon,\n placeholder = \" \",\n required,\n ...props\n },\n ref\n ) => {\n // Character count state\n const [charCount, setCharCount] = React.useState(() => {\n if (typeof props.value === \"string\") return props.value.length;\n if (typeof props.defaultValue === \"string\")\n return props.defaultValue.length;\n return 0;\n });\n\n const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {\n setCharCount(e.target.value.length);\n if (props.onChange) props.onChange(e);\n };\n\n const handleClear = () => {\n if (innerRef.current) {\n innerRef.current.value = \"\";\n setCharCount(0);\n const event = {\n target: innerRef.current,\n currentTarget: innerRef.current,\n } as React.ChangeEvent<HTMLInputElement>;\n props.onChange?.(event);\n if (onClear) onClear();\n }\n };\n\n const inputId = React.useId();\n const innerRef = React.useRef<HTMLInputElement>(null);\n\n // Combine refs\n const combinedRef = React.useCallback(\n (element: HTMLInputElement | null) => {\n // Set innerRef\n if (innerRef) {\n (\n innerRef as React.MutableRefObject<HTMLInputElement | null>\n ).current = element;\n }\n\n // Apply mask if provided\n if (mask && element) {\n const maskRefCallback = withMask(mask, maskOptions);\n if (typeof maskRefCallback === \"function\") {\n maskRefCallback(element);\n }\n }\n },\n [mask, maskOptions]\n );\n\n // Expose ref to parent\n React.useImperativeHandle(ref, () => innerRef.current!);\n\n const [showPassword, setShowPassword] = React.useState(false);\n\n // State\n const helperTextStyles = {\n default: \"ds:text-muted-foreground\",\n success: \"ds:text-success\",\n warning: \"ds:text-warning\",\n error: \"ds:text-error\",\n };\n\n // Calculate current size\n const currentSize = isFloatLabel\n ? size === \"xl\" || size === \"lg\"\n ? size\n : \"xl\"\n : size || \"normal\";\n\n // Calculate padding based on size and icons\n const getPadding = () => {\n const sizeMap = {\n xs: { prefix: \"pl-8\", suffix: \"pr-8\" },\n sm: { prefix: \"pl-9\", suffix: \"pr-9\" },\n normal: { prefix: \"pl-10\", suffix: \"pr-10\" },\n lg: { prefix: \"pl-11\", suffix: \"pr-11\" },\n xl: { prefix: \"pl-12\", suffix: \"pr-12\" },\n };\n\n return sizeMap[currentSize as keyof typeof sizeMap] || sizeMap.normal;\n };\n\n const padding = getPadding();\n\n // Get icon size class based on current size\n const getIconSizeClass = () => {\n const sizeMap = {\n xs: \"size-3\",\n sm: \"size-3.5\",\n normal: \"size-4\",\n lg: \"size-4\",\n xl: \"size-4\",\n };\n return sizeMap[currentSize as keyof typeof sizeMap] || \"size-4\";\n };\n\n const iconSizeClass = getIconSizeClass();\n\n // Calculate right padding considering built-in icons\n const getRightPadding = () => {\n const hasBuiltInSuffix =\n type === \"number\" ||\n type === \"password\" ||\n type === \"datetime\" ||\n (clearable && (charCount > 0 || props?.value));\n\n if (hasBuiltInSuffix && suffixIcon) {\n return type === \"password\" &&\n clearable &&\n (charCount > 0 || props?.value)\n ? \"pr-20\" // password + clear + custom icon\n : \"pr-16\"; // one built-in + custom icon\n }\n\n if (hasBuiltInSuffix) {\n return type === \"password\" &&\n clearable &&\n (charCount > 0 || props?.value)\n ? \"pr-16\" // password + clear\n : \"pr-10\"; // single built-in icon\n }\n\n if (suffixIcon) {\n return padding.suffix;\n }\n\n return \"\";\n };\n\n // Icon position calculations\n const getIconPosition = () => {\n const sizeMap = {\n xs: { left: \"left-2.5\", right: \"right-2.5\" },\n sm: { left: \"left-3\", right: \"right-3\" },\n normal: { left: \"left-3\", right: \"right-3\" },\n lg: { left: \"left-3.5\", right: \"right-3.5\" },\n xl: { left: \"left-4\", right: \"right-4\" },\n };\n\n return sizeMap[currentSize as keyof typeof sizeMap] || sizeMap.normal;\n };\n\n const iconPosition = getIconPosition();\n\n /* Spinner Button Handlers */\n const handleIncrement = () => {\n if (innerRef.current) {\n const step = Number(props.step || 1);\n const max = props.max ? Number(props.max) : Infinity;\n const currentValue = Number(innerRef.current.value || 0);\n const newValue = Math.min(currentValue + step, max);\n\n innerRef.current.value = String(newValue);\n const event = new Event(\"input\", { bubbles: true });\n innerRef.current.dispatchEvent(event);\n props.onChange?.(event as unknown as ChangeEvent<HTMLInputElement>);\n }\n };\n\n const handleDecrement = () => {\n if (innerRef.current) {\n const step = Number(props.step || 1);\n const min = props.min ? Number(props.min) : -Infinity;\n const currentValue = Number(innerRef.current.value || 0);\n const newValue = Math.max(currentValue - step, min);\n\n innerRef.current.value = String(newValue);\n const event = new Event(\"input\", { bubbles: true });\n innerRef.current.dispatchEvent(event);\n props.onChange?.(event as unknown as ChangeEvent<HTMLInputElement>);\n }\n };\n /* End Spinner Button Handlers */\n\n return (\n <div className={className}>\n <div\n className={cn(\"ds:flex ds:flex-col ds:gap-1.5 ds:relative ds:flex-auto\", {\n \"ds:floating-label ds:relative\": isFloatLabel,\n })}\n >\n {!isFloatLabel && label && (\n <Label\n htmlFor={inputId}\n className=\"ds:flex ds:gap-2 ds:text-sm ds:font-medium ds:leading-none ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70\"\n >\n <span>\n {label}\n {required && <span className=\"ds:text-error ds:ml-0.5\">*</span>}\n </span>\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </Label>\n )}\n\n <div className=\"ds:relative\">\n {/* Prefix Icon */}\n {prefixIcon && (\n <div\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0\",\n iconPosition.left\n )}\n >\n {React.isValidElement(prefixIcon)\n ? React.cloneElement(prefixIcon, {\n className: cn(\n iconSizeClass,\n (prefixIcon.props as any)?.className\n ),\n } as Partial<unknown>)\n : prefixIcon}\n </div>\n )}\n\n <SInput\n ref={combinedRef}\n id={inputId}\n className={cn(\n \"ds:peer\",\n {\n \"ds:pt-5 ds:pb-1\": isFloatLabel && size !== \"lg\",\n \"ds:[&::-webkit-outer-spin-button]:appearance-none ds:[&::-webkit-inner-spin-button]:appearance-none ds:[-moz-appearance:textfield] ds:pr-8\":\n type === \"number\",\n // \"[-webkit-text-fill-color:var(--foreground)]\": mask,\n },\n prefixIcon && padding.prefix,\n mask && \"ds:placeholder:text-slate-400 ds:placeholder:opacity-100\",\n getRightPadding()\n // className,\n )}\n state={state}\n size={\n isFloatLabel\n ? size === \"xl\" || size === \"lg\"\n ? size\n : \"xl\"\n : size\n }\n type={\n type === \"password\"\n ? showPassword\n ? \"text\"\n : \"password\"\n : type\n }\n placeholder={placeholder}\n maxLength={maxLength}\n onChange={handleInput}\n required={required}\n {...props}\n />\n {isFloatLabel && (\n <FloatingLabel\n htmlFor={inputId}\n size={size}\n infoTooltip={infoTooltip}\n required={required}\n >\n {label}\n </FloatingLabel>\n )}\n\n {/* Spinner Buttons */}\n {type === \"number\" && (\n <div className=\"ds:absolute ds:right-1 ds:top-0 ds:h-full ds:flex ds:flex-col ds:gap-0.5\">\n <button\n type=\"button\"\n onClick={handleIncrement}\n disabled={props.disabled}\n className={cn(\n \"ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform\",\n \"ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent\"\n )}\n tabIndex={-1}\n >\n <ChevronUp className=\"ds:size-3\" />\n </button>\n <button\n type=\"button\"\n onClick={handleDecrement}\n disabled={props.disabled}\n className={cn(\n \"ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform\",\n \"ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent\"\n )}\n tabIndex={-1}\n >\n <ChevronDown className=\"ds:size-3\" />\n </button>\n </div>\n )}\n\n {/* Clear Button */}\n {clearable &&\n (charCount > 0 || props?.value) &&\n !props.disabled &&\n type !== \"number\" && (\n <button\n type=\"button\"\n tabIndex={-1}\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors ds:cursor-pointer\",\n type === \"password\"\n ? suffixIcon\n ? \"ds:right-14\"\n : \"ds:right-10\"\n : suffixIcon\n ? \"ds:right-10\"\n : \"ds:right-2\"\n )}\n onClick={handleClear}\n disabled={props.disabled}\n >\n <X className=\"ds:size-4\" />\n </button>\n )}\n\n {/* Show/Hide Password Button */}\n {type === \"password\" && (\n <button\n type=\"button\"\n tabIndex={-1}\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors\",\n suffixIcon ? \"ds:right-10\" : \"ds:right-2\"\n )}\n onClick={() => setShowPassword((prev) => !prev)}\n disabled={props.disabled}\n >\n {showPassword ? (\n <EyeOff className=\"ds:size-4\" />\n ) : (\n <Eye className=\"ds:size-4\" />\n )}\n </button>\n )}\n\n {/* Suffix Icon */}\n {suffixIcon && (\n <div\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0\",\n iconPosition.right\n )}\n >\n {React.isValidElement(suffixIcon)\n ? React.cloneElement(suffixIcon, {\n className: cn(\n iconSizeClass,\n (suffixIcon.props as any)?.className\n ),\n } as Partial<unknown>)\n : suffixIcon}\n </div>\n )}\n </div>\n\n {(helperText || (showCharCount && typeof maxLength === \"number\")) && (\n <div className=\"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2\">\n {helperText && (\n <p\n className={cn(\n \"ds:text-xs\",\n state ? helperTextStyles?.[state] : \"\"\n )}\n >\n {helperText}\n </p>\n )}\n {showCharCount && typeof maxLength === \"number\" && (\n <span className=\"ds:ml-auto ds:text-muted-foreground\">\n {charCount} / {maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n </div>\n );\n }\n);\n\nInput.displayName = \"Input\";\nexport default Input;\n"],"names":["Input","React","className","label","helperText","state","size","isFloatLabel","type","mask","maskOptions","maxLength","showCharCount","infoTooltip","clearable","onClear","prefixIcon","suffixIcon","placeholder","required","props","ref","charCount","setCharCount","handleInput","e","handleClear","innerRef","event","inputId","combinedRef","element","maskRefCallback","withMask","showPassword","setShowPassword","helperTextStyles","currentSize","padding","sizeMap","iconSizeClass","getRightPadding","hasBuiltInSuffix","iconPosition","handleIncrement","step","max","currentValue","newValue","handleDecrement","min","jsx","jsxs","cn","Label","Tooltip","Info","SInput","FloatingLabel","ChevronUp","ChevronDown","X","prev","EyeOff","Eye"],"mappings":"8bAyCMA,EAAQC,EAAM,WAClB,CACE,CACE,UAAAC,EAAA,MACAC,EACA,WAAAC,EACA,MAAAC,EACA,KAAAC,EACA,aAAAC,EACA,KAAAC,EACA,KAAAC,EACA,YAAAC,EACA,UAAAC,EACA,cAAAC,EACA,YAAAC,EACA,UAAAC,EACA,QAAAC,EACA,WAAAC,EACA,WAAAC,EACA,YAAAC,EAAc,IACd,SAA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EAAA,CAAE,UAAU,WAAA,CAAY,CAAA,CAAA,EAK9BrD,IAAS,YACR2C,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,SAAU,GACV,UAAWE,EAAAA,GACT,uGACApC,EAAa,cAAgB,YAAA,EAE/B,QAAS,IAAMkB,EAAiB2B,GAAS,CAACA,CAAI,EAC9C,SAAU1C,EAAM,SAEf,SAAAc,QACE6B,EAAAA,OAAA,CAAO,UAAU,YAAY,EAE9BZ,EAAAA,IAACa,EAAAA,IAAA,CAAI,UAAU,WAAA,CAAY,CAAA,CAAA,EAMhC/C,GACCkC,EAAAA,IAAC,MAAA,CACC,UAAWE,EAAAA,GACT,mFACAV,EAAa,KAAA,EAGd,WAAM,eAAe1B,CAAU,EAC5BhB,EAAM,aAAagB,EAAY,CAC7B,UAAWoC,EAAAA,GACTb,EACCvB,EAAW,OAAe,SAAA,CAC7B,CACmB,EACrBA,CAAA,CAAA,CACN,EAEJ,GAEEb,GAAeQ,GAAiB,OAAOD,GAAc,WACrDyC,OAAC,MAAA,CAAI,UAAU,iEACZ,SAAA,CAAAhD,GACC+C,EAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,aACAhD,EAAQ+B,IAAmB/B,CAAK,EAAI,EAAA,EAGrC,SAAAD,CAAA,CAAA,EAGJQ,GAAiB,OAAOD,GAAc,UACrCyC,EAAAA,KAAC,OAAA,CAAK,UAAU,sCACb,SAAA,CAAA9B,EAAU,MAAIX,CAAA,CAAA,CACjB,CAAA,CAAA,CAEJ,CAAA,CAAA,CAAA,EAGN,CAEJ,CACF,EAEAX,EAAM,YAAc"}
1
+ {"version":3,"file":"Input.cjs","sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import React, { type ChangeEvent } from \"react\";\nimport {\n Input as SInput,\n type InputProps as SInputProps,\n} from \"@dsui/ui/components/input\";\nimport { cn } from \"@dsui/ui/lib/utils\";\nimport { FloatingLabel } from \"@/components/FloatLabel\";\nimport { Eye, EyeOff, ChevronDown, ChevronUp, Info, X } from \"lucide-react\";\nimport { withMask, type Options } from \"use-mask-input\";\nimport { Tooltip } from \"../Tooltip/Tooltip\";\nimport { Label } from \"../Label\";\n\n// Re-export base input props to avoid external dependency issues\nexport type BaseInputProps = Omit<React.ComponentProps<\"input\">, \"size\"> & {\n size?: \"normal\" | \"sm\" | \"xs\" | \"lg\" | \"xl\";\n state?: \"default\" | \"success\" | \"error\" | \"warning\";\n};\n\nexport type InputProps = BaseInputProps & {\n label?: string;\n helperText?: React.ReactNode;\n isFloatLabel?: boolean;\n mask?: string;\n maskOptions?: {\n placeholder?: string;\n inputFormat?: string;\n outputFormat?: string;\n showMaskOnHover?: boolean;\n showMaskOnFocus?: boolean;\n separate?: boolean;\n } & Options;\n maxLength?: number;\n showCharCount?: boolean;\n infoTooltip?: React.ReactNode;\n clearable?: boolean;\n onClear?: () => void;\n prefixIcon?: React.ReactNode;\n suffixIcon?: React.ReactNode;\n required?: boolean;\n};\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n label,\n helperText,\n state,\n size,\n isFloatLabel,\n type,\n mask,\n maskOptions,\n maxLength,\n showCharCount,\n infoTooltip,\n clearable,\n onClear,\n prefixIcon,\n suffixIcon,\n placeholder = \" \",\n required,\n ...props\n },\n ref\n ) => {\n // Character count state\n const [charCount, setCharCount] = React.useState(() => {\n if (typeof props.value === \"string\") return props.value.length;\n if (typeof props.defaultValue === \"string\")\n return props.defaultValue.length;\n return 0;\n });\n\n const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {\n setCharCount(e.target.value.length);\n if (props.onChange) props.onChange(e);\n };\n\n const handleClear = () => {\n if (innerRef.current) {\n innerRef.current.value = \"\";\n setCharCount(0);\n const event = {\n target: innerRef.current,\n currentTarget: innerRef.current,\n } as React.ChangeEvent<HTMLInputElement>;\n props.onChange?.(event);\n if (onClear) onClear();\n }\n };\n\n const inputId = React.useId();\n const innerRef = React.useRef<HTMLInputElement>(null);\n\n // Combine refs\n const combinedRef = React.useCallback(\n (element: HTMLInputElement | null) => {\n // Set innerRef\n if (innerRef) {\n (\n innerRef as React.MutableRefObject<HTMLInputElement | null>\n ).current = element;\n }\n\n // Apply mask if provided\n if (mask && element) {\n const maskRefCallback = withMask(mask, maskOptions);\n if (typeof maskRefCallback === \"function\") {\n maskRefCallback(element);\n }\n }\n },\n [mask, maskOptions]\n );\n\n // Expose ref to parent\n React.useImperativeHandle(ref, () => innerRef.current!);\n\n const [showPassword, setShowPassword] = React.useState(false);\n\n // State\n const helperTextStyles = {\n default: \"ds:text-muted-foreground\",\n success: \"ds:text-success\",\n warning: \"ds:text-warning\",\n error: \"ds:text-error\",\n };\n\n // Calculate current size\n const currentSize = isFloatLabel\n ? size === \"xl\" || size === \"lg\"\n ? size\n : \"xl\"\n : size || \"normal\";\n\n // Calculate padding based on size and icons\n const getPadding = () => {\n const sizeMap = {\n xs: { prefix: \"ds:pl-8\", suffix: \"ds:pr-8\" },\n sm: { prefix: \"ds:pl-9\", suffix: \"ds:pr-9\" },\n normal: { prefix: \"ds:pl-10\", suffix: \"ds:pr-10\" },\n lg: { prefix: \"ds:pl-11\", suffix: \"ds:pr-11\" },\n xl: { prefix: \"ds:pl-12\", suffix: \"ds:pr-12\" },\n };\n\n return sizeMap[currentSize as keyof typeof sizeMap] || sizeMap.normal;\n };\n\n const padding = getPadding();\n\n // Get icon size class based on current size\n const getIconSizeClass = () => {\n const sizeMap = {\n xs: \"ds:size-3\",\n sm: \"ds:size-3.5\",\n normal: \"ds:size-4\",\n lg: \"ds:size-4\",\n xl: \"ds:size-4\",\n };\n return sizeMap[currentSize as keyof typeof sizeMap] || \"ds:size-4\";\n };\n\n const iconSizeClass = getIconSizeClass();\n\n // Calculate right padding considering built-in icons\n const getRightPadding = () => {\n const hasBuiltInSuffix =\n type === \"number\" ||\n type === \"password\" ||\n type === \"datetime\" ||\n (clearable && (charCount > 0 || props?.value));\n\n if (hasBuiltInSuffix && suffixIcon) {\n return type === \"password\" &&\n clearable &&\n (charCount > 0 || props?.value)\n ? \"ds:pr-20\" // password + clear + custom icon\n : \"ds:pr-16\"; // one built-in + custom icon\n }\n\n if (hasBuiltInSuffix) {\n return type === \"password\" &&\n clearable &&\n (charCount > 0 || props?.value)\n ? \"ds:pr-16\" // password + clear\n : \"ds:pr-10\"; // single built-in icon\n }\n\n if (suffixIcon) {\n return padding.suffix;\n }\n\n return \"\";\n };\n\n // Icon position calculations\n const getIconPosition = () => {\n const sizeMap = {\n xs: { left: \"ds:left-2.5\", right: \"ds:right-2.5\" },\n sm: { left: \"ds:left-3\", right: \"ds:right-3\" },\n normal: { left: \"ds:left-3\", right: \"ds:right-3\" },\n lg: { left: \"ds:left-3.5\", right: \"ds:right-3.5\" },\n xl: { left: \"ds:left-4\", right: \"ds:right-4\" },\n };\n\n return sizeMap[currentSize as keyof typeof sizeMap] || sizeMap.normal;\n };\n\n const iconPosition = getIconPosition();\n\n /* Spinner Button Handlers */\n const handleIncrement = () => {\n if (innerRef.current) {\n const step = Number(props.step || 1);\n const max = props.max ? Number(props.max) : Infinity;\n const currentValue = Number(innerRef.current.value || 0);\n const newValue = Math.min(currentValue + step, max);\n\n innerRef.current.value = String(newValue);\n const event = new Event(\"input\", { bubbles: true });\n innerRef.current.dispatchEvent(event);\n props.onChange?.(event as unknown as ChangeEvent<HTMLInputElement>);\n }\n };\n\n const handleDecrement = () => {\n if (innerRef.current) {\n const step = Number(props.step || 1);\n const min = props.min ? Number(props.min) : -Infinity;\n const currentValue = Number(innerRef.current.value || 0);\n const newValue = Math.max(currentValue - step, min);\n\n innerRef.current.value = String(newValue);\n const event = new Event(\"input\", { bubbles: true });\n innerRef.current.dispatchEvent(event);\n props.onChange?.(event as unknown as ChangeEvent<HTMLInputElement>);\n }\n };\n /* End Spinner Button Handlers */\n\n return (\n <div className={className}>\n <div\n className={cn(\"ds:flex ds:flex-col ds:gap-1.5 ds:relative ds:flex-auto\", {\n \"ds:floating-label ds:relative\": isFloatLabel,\n })}\n >\n {!isFloatLabel && label && (\n <Label\n htmlFor={inputId}\n className=\"ds:flex ds:gap-2 ds:text-sm ds:font-medium ds:leading-none ds:peer-disabled:cursor-not-allowed ds:peer-disabled:opacity-70\"\n >\n <span>\n {label}\n {required && <span className=\"ds:text-error ds:ml-0.5\">*</span>}\n </span>\n {infoTooltip && (\n <Tooltip content={infoTooltip}>\n <Info className=\"ds:size-3.5 ds:min-w-3.5\" />\n </Tooltip>\n )}\n </Label>\n )}\n\n <div className=\"ds:relative\">\n {/* Prefix Icon */}\n {prefixIcon && (\n <div\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0\",\n iconPosition.left\n )}\n >\n {React.isValidElement(prefixIcon)\n ? React.cloneElement(prefixIcon, {\n className: cn(\n iconSizeClass,\n (prefixIcon.props as any)?.className\n ),\n } as Partial<unknown>)\n : prefixIcon}\n </div>\n )}\n\n <SInput\n ref={combinedRef}\n id={inputId}\n className={cn(\n \"ds:peer\",\n {\n \"ds:pt-5 ds:pb-1\": isFloatLabel && size !== \"lg\",\n \"ds:[&::-webkit-outer-spin-button]:appearance-none ds:[&::-webkit-inner-spin-button]:appearance-none ds:[-moz-appearance:textfield] ds:pr-8\":\n type === \"number\",\n // \"[-webkit-text-fill-color:var(--foreground)]\": mask,\n },\n prefixIcon && padding.prefix,\n mask && \"ds:placeholder:text-slate-400 ds:placeholder:opacity-100\",\n getRightPadding()\n // className,\n )}\n state={state}\n size={\n isFloatLabel\n ? size === \"xl\" || size === \"lg\"\n ? size\n : \"xl\"\n : size\n }\n type={\n type === \"password\"\n ? showPassword\n ? \"text\"\n : \"password\"\n : type\n }\n placeholder={placeholder}\n maxLength={maxLength}\n onChange={handleInput}\n required={required}\n {...props}\n />\n {isFloatLabel && (\n <FloatingLabel\n htmlFor={inputId}\n size={size}\n infoTooltip={infoTooltip}\n required={required}\n >\n {label}\n </FloatingLabel>\n )}\n\n {/* Spinner Buttons */}\n {type === \"number\" && (\n <div className=\"ds:absolute ds:right-1 ds:top-0 ds:h-full ds:flex ds:flex-col ds:gap-0.5\">\n <button\n type=\"button\"\n onClick={handleIncrement}\n disabled={props.disabled}\n className={cn(\n \"ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform\",\n \"ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent\"\n )}\n tabIndex={-1}\n >\n <ChevronUp className=\"ds:size-3\" />\n </button>\n <button\n type=\"button\"\n onClick={handleDecrement}\n disabled={props.disabled}\n className={cn(\n \"ds:h-1/2 ds:w-6 ds:flex ds:items-center ds:justify-center ds:rounded ds:cursor-pointer ds:hover:scale-150 ds:transition-transform\",\n \"ds:disabled:opacity-50 ds:disabled:cursor-not-allowed ds:disabled:hover:bg-transparent\"\n )}\n tabIndex={-1}\n >\n <ChevronDown className=\"ds:size-3\" />\n </button>\n </div>\n )}\n\n {/* Clear Button */}\n {clearable &&\n (charCount > 0 || props?.value) &&\n !props.disabled &&\n type !== \"number\" && (\n <button\n type=\"button\"\n tabIndex={-1}\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors ds:cursor-pointer\",\n type === \"password\"\n ? suffixIcon\n ? \"ds:right-14\"\n : \"ds:right-10\"\n : suffixIcon\n ? \"ds:right-10\"\n : \"ds:right-2\"\n )}\n onClick={handleClear}\n disabled={props.disabled}\n >\n <X className=\"ds:size-4\" />\n </button>\n )}\n\n {/* Show/Hide Password Button */}\n {type === \"password\" && (\n <button\n type=\"button\"\n tabIndex={-1}\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:p-1 ds:rounded ds:hover:bg-accent ds:transition-colors\",\n suffixIcon ? \"ds:right-10\" : \"ds:right-2\"\n )}\n onClick={() => setShowPassword((prev) => !prev)}\n disabled={props.disabled}\n >\n {showPassword ? (\n <EyeOff className=\"ds:size-4\" />\n ) : (\n <Eye className=\"ds:size-4\" />\n )}\n </button>\n )}\n\n {/* Suffix Icon */}\n {suffixIcon && (\n <div\n className={cn(\n \"ds:absolute ds:top-1/2 ds:-translate-y-1/2 ds:text-muted-foreground ds:leading-0\",\n iconPosition.right\n )}\n >\n {React.isValidElement(suffixIcon)\n ? React.cloneElement(suffixIcon, {\n className: cn(\n iconSizeClass,\n (suffixIcon.props as any)?.className\n ),\n } as Partial<unknown>)\n : suffixIcon}\n </div>\n )}\n </div>\n\n {(helperText || (showCharCount && typeof maxLength === \"number\")) && (\n <div className=\"ds:flex ds:items-center ds:justify-between ds:text-xs ds:gap-2\">\n {helperText && (\n <p\n className={cn(\n \"ds:text-xs\",\n state ? helperTextStyles?.[state] : \"\"\n )}\n >\n {helperText}\n </p>\n )}\n {showCharCount && typeof maxLength === \"number\" && (\n <span className=\"ds:ml-auto ds:text-muted-foreground\">\n {charCount} / {maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n </div>\n );\n }\n);\n\nInput.displayName = \"Input\";\nexport default Input;\n"],"names":["Input","React","className","label","helperText","state","size","isFloatLabel","type","mask","maskOptions","maxLength","showCharCount","infoTooltip","clearable","onClear","prefixIcon","suffixIcon","placeholder","required","props","ref","charCount","setCharCount","handleInput","e","handleClear","innerRef","event","inputId","combinedRef","element","maskRefCallback","withMask","showPassword","setShowPassword","helperTextStyles","currentSize","padding","sizeMap","iconSizeClass","getRightPadding","hasBuiltInSuffix","iconPosition","handleIncrement","step","max","currentValue","newValue","handleDecrement","min","jsx","jsxs","cn","Label","Tooltip","Info","SInput","FloatingLabel","ChevronUp","ChevronDown","X","prev","EyeOff","Eye"],"mappings":"8bAyCMA,EAAQC,EAAM,WAClB,CACE,CACE,UAAAC,EAAA,MACAC,EACA,WAAAC,EACA,MAAAC,EACA,KAAAC,EACA,aAAAC,EACA,KAAAC,EACA,KAAAC,EACA,YAAAC,EACA,UAAAC,EACA,cAAAC,EACA,YAAAC,EACA,UAAAC,EACA,QAAAC,E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M,SAEhB,SAAA+B,EAAAA,IAACU,EAAAA,EAAA,CAAE,UAAU,WAAA,CAAY,CAAA,CAAA,EAK9BrD,IAAS,YACR2C,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,SAAU,GACV,UAAWE,EAAAA,GACT,uGACApC,EAAa,cAAgB,YAAA,EAE/B,QAAS,IAAMkB,EAAiB2B,GAAS,CAACA,CAAI,EAC9C,SAAU1C,EAAM,SAEf,SAAAc,QACE6B,EAAAA,OAAA,CAAO,UAAU,YAAY,EAE9BZ,EAAAA,IAACa,EAAAA,IAAA,CAAI,UAAU,WAAA,CAAY,CAAA,CAAA,EAMhC/C,GACCkC,EAAAA,IAAC,MAAA,CACC,UAAWE,EAAAA,GACT,mFACAV,EAAa,KAAA,EAGd,WAAM,eAAe1B,CAAU,EAC5BhB,EAAM,aAAagB,EAAY,CAC7B,UAAWoC,EAAAA,GACTb,EACCvB,EAAW,OAAe,SAAA,CAC7B,CACmB,EACrBA,CAAA,CAAA,CACN,EAEJ,GAEEb,GAAeQ,GAAiB,OAAOD,GAAc,WACrDyC,OAAC,MAAA,CAAI,UAAU,iEACZ,SAAA,CAAAhD,GACC+C,EAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,aACAhD,EAAQ+B,IAAmB/B,CAAK,EAAI,EAAA,EAGrC,SAAAD,CAAA,CAAA,EAGJQ,GAAiB,OAAOD,GAAc,UACrCyC,EAAAA,KAAC,OAAA,CAAK,UAAU,sCACb,SAAA,CAAA9B,EAAU,MAAIX,CAAA,CAAA,CACjB,CAAA,CAAA,CAEJ,CAAA,CAAA,CAAA,EAGN,CAEJ,CACF,EAEAX,EAAM,YAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),i=require("react"),k=require("lucide-react"),R=require("../../packages/ui/src/lib/utils.cjs"),b=i.forwardRef(({count:u=5,value:x,defaultValue:j=0,allowHalf:a=!1,allowClear:N=!0,size:d="middle",color:V="warning",character:f,className:D,style:A,disabled:l=!1,autoFocus:F=!1,keyboard:q=!0,tooltips:v,onChange:m,onHoverChange:M,onFocus:E,onBlur:L,onKeyDown:$},c)=>{const[B,p]=i.useState(j),[o,S]=i.useState(null),K=i.useRef(null),n=x!==void 0?x:B,_={small:20,middle:24,large:32},P={primary:"text-primary [&_svg]:fill-primary",secondary:"text-secondary [&_svg]:fill-secondary",accent:"text-accent [&_svg]:fill-accent",destructive:"text-destructive [&_svg]:fill-destructive",muted:"text-muted-foreground [&_svg]:fill-muted-foreground",success:"text-success [&_svg]:fill-success",error:"text-error [&_svg]:fill-error",warning:"text-yellow-400 [&_svg]:fill-yellow-400"},g=(e,s)=>{if(l)return;const t=s?e+.5:e+1;N&&t===n?(p(0),m?.(0)):(p(t),m?.(t))},h=(e,s)=>{if(l)return;const t=s?e+.5:e+1;S(t),M?.(t)},T=()=>{S(null),M?.(0)},C=e=>{if(!q||l)return;$?.(e);const s=a?.5:1;let t=n;switch(e.key){case"ArrowRight":case"ArrowUp":e.preventDefault(),t=Math.min(n+s,u);break;case"ArrowLeft":case"ArrowDown":e.preventDefault(),t=Math.max(n-s,0);break;case"Home":e.preventDefault(),t=a?.5:1;break;case"End":e.preventDefault(),t=u;break;default:return}p(t),m?.(t)},H=()=>{E?.()},O=()=>{L?.()},U=e=>{const s=o!==null?o:n;return s>=e+1?100:s>e&&s<e+1?(s-e)*100:0},z=e=>{if(!a)return!1;const t=(o!==null?o:n)-e;return t>0&&t<=.5},w=(e=!1)=>typeof f=="function"?f({count:u,value:n,defaultValue:j,allowHalf:a,allowClear:N,size:d,disabled:l}):e?r.jsx(k.StarHalf,{className:"ds:w-full ds:h-full"}):f||r.jsx(k.Star,{className:"ds:w-full ds:h-full"}),G=e=>{if(!(!v||!v[e]))return v[e]};return r.jsx("div",{ref:e=>{K.current=e,typeof c=="function"?c(e):c&&(c.current=e)},className:R.cn("ds:inline-flex ds:items-center ds:gap-1",l&&"ds:opacity-50 ds:cursor-not-allowed",!l&&"ds:cursor-pointer",D),style:A,onMouseLeave:T,onKeyDown:C,onFocus:H,onBlur:O,tabIndex:l?-1:0,role:"slider","aria-label":"Rate","aria-valuemin":0,"aria-valuemax":u,"aria-valuenow":n,"aria-disabled":l,autoFocus:F,children:Array.from({length:u},(e,s)=>{const t=U(s),y=G(s),J=z(s);return r.jsxs("div",{className:"ds:relative ds:group",title:y,children:[r.jsxs("div",{className:"ds:relative ds:inline-flex",style:{width:`${_[d]}px`,height:`${_[d]}px`},children:[r.jsx("div",{className:"ds:text-muted-foreground/30 ds:pointer-events-none",children:w(!1)}),t>0&&r.jsx("div",{className:R.cn("ds:absolute ds:inset-0 ds:pointer-events-none",P[V]),children:J?w(!0):r.jsx("div",{className:"ds:overflow-hidden",style:{width:`${t}%`},children:w(!1)})}),!l&&r.jsx(r.Fragment,{children:a?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ds:absolute ds:inset-0 ds:w-1/2 ds:cursor-pointer",onClick:()=>g(s,!0),onMouseEnter:()=>h(s,!0)}),r.jsx("div",{className:"ds:absolute ds:inset-0 ds:left-1/2 ds:w-1/2 ds:cursor-pointer",onClick:()=>g(s,!1),onMouseEnter:()=>h(s,!1)})]}):r.jsx("div",{className:"ds:absolute ds:inset-0 ds:cursor-pointer",onClick:()=>g(s,!1),onMouseEnter:()=>h(s,!1)})})]}),y&&(o===s+1||a&&o===s+.5)&&r.jsx("div",{className:"ds:absolute ds:top-full ds:left-1/2 ds:-translate-x-1/2 ds:mt-1 ds:px-2 ds:py-1 ds:text-xs ds:bg-foreground ds:text-background ds:rounded ds:whitespace-nowrap ds:z-10",children:y})]},s)})})});b.displayName="Rate";exports.default=b;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),d=require("react"),k=require("lucide-react"),R=require("../../packages/ui/src/lib/utils.cjs"),b=d.forwardRef(({count:u=5,value:x,defaultValue:j=0,allowHalf:a=!1,allowClear:N=!0,size:i="middle",color:V="warning",character:f,className:D,style:A,disabled:l=!1,autoFocus:F=!1,keyboard:q=!0,tooltips:v,onChange:m,onHoverChange:M,onFocus:E,onBlur:L,onKeyDown:$},c)=>{const[B,p]=d.useState(j),[o,S]=d.useState(null),K=d.useRef(null),n=x!==void 0?x:B,_={small:20,middle:24,large:32},P={primary:"ds:text-primary ds:[&_svg]:fill-primary",secondary:"ds:text-secondary ds:[&_svg]:fill-secondary",accent:"ds:text-accent ds:[&_svg]:fill-accent",destructive:"ds:text-destructive ds:[&_svg]:fill-destructive",muted:"ds:text-muted-foreground ds:[&_svg]:fill-muted-foreground",success:"ds:text-success ds:[&_svg]:fill-success",error:"ds:text-error ds:[&_svg]:fill-error",warning:"ds:text-yellow-400 ds:[&_svg]:fill-yellow-400"},g=(e,s)=>{if(l)return;const t=s?e+.5:e+1;N&&t===n?(p(0),m?.(0)):(p(t),m?.(t))},h=(e,s)=>{if(l)return;const t=s?e+.5:e+1;S(t),M?.(t)},T=()=>{S(null),M?.(0)},C=e=>{if(!q||l)return;$?.(e);const s=a?.5:1;let t=n;switch(e.key){case"ArrowRight":case"ArrowUp":e.preventDefault(),t=Math.min(n+s,u);break;case"ArrowLeft":case"ArrowDown":e.preventDefault(),t=Math.max(n-s,0);break;case"Home":e.preventDefault(),t=a?.5:1;break;case"End":e.preventDefault(),t=u;break;default:return}p(t),m?.(t)},H=()=>{E?.()},O=()=>{L?.()},U=e=>{const s=o!==null?o:n;return s>=e+1?100:s>e&&s<e+1?(s-e)*100:0},z=e=>{if(!a)return!1;const t=(o!==null?o:n)-e;return t>0&&t<=.5},w=(e=!1)=>typeof f=="function"?f({count:u,value:n,defaultValue:j,allowHalf:a,allowClear:N,size:i,disabled:l}):e?r.jsx(k.StarHalf,{className:"ds:w-full ds:h-full"}):f||r.jsx(k.Star,{className:"ds:w-full ds:h-full"}),G=e=>{if(!(!v||!v[e]))return v[e]};return r.jsx("div",{ref:e=>{K.current=e,typeof c=="function"?c(e):c&&(c.current=e)},className:R.cn("ds:inline-flex ds:items-center ds:gap-1",l&&"ds:opacity-50 ds:cursor-not-allowed",!l&&"ds:cursor-pointer",D),style:A,onMouseLeave:T,onKeyDown:C,onFocus:H,onBlur:O,tabIndex:l?-1:0,role:"slider","aria-label":"Rate","aria-valuemin":0,"aria-valuemax":u,"aria-valuenow":n,"aria-disabled":l,autoFocus:F,children:Array.from({length:u},(e,s)=>{const t=U(s),y=G(s),J=z(s);return r.jsxs("div",{className:"ds:relative ds:group",title:y,children:[r.jsxs("div",{className:"ds:relative ds:inline-flex",style:{width:`${_[i]}px`,height:`${_[i]}px`},children:[r.jsx("div",{className:"ds:text-muted-foreground/30 ds:pointer-events-none",children:w(!1)}),t>0&&r.jsx("div",{className:R.cn("ds:absolute ds:inset-0 ds:pointer-events-none",P[V]),children:J?w(!0):r.jsx("div",{className:"ds:overflow-hidden",style:{width:`${t}%`},children:w(!1)})}),!l&&r.jsx(r.Fragment,{children:a?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ds:absolute ds:inset-0 ds:w-1/2 ds:cursor-pointer",onClick:()=>g(s,!0),onMouseEnter:()=>h(s,!0)}),r.jsx("div",{className:"ds:absolute ds:inset-0 ds:left-1/2 ds:w-1/2 ds:cursor-pointer",onClick:()=>g(s,!1),onMouseEnter:()=>h(s,!1)})]}):r.jsx("div",{className:"ds:absolute ds:inset-0 ds:cursor-pointer",onClick:()=>g(s,!1),onMouseEnter:()=>h(s,!1)})})]}),y&&(o===s+1||a&&o===s+.5)&&r.jsx("div",{className:"ds:absolute ds:top-full ds:left-1/2 ds:-translate-x-1/2 ds:mt-1 ds:px-2 ds:py-1 ds:text-xs ds:bg-foreground ds:text-background ds:rounded ds:whitespace-nowrap ds:z-10",children:y})]},s)})})});b.displayName="Rate";exports.default=b;
2
2
  //# sourceMappingURL=Rate.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Rate.cjs","sources":["../../../../src/components/Rate/Rate.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useState, useRef } from \"react\";\nimport type { KeyboardEvent } from \"react\";\nimport { Star, StarHalf } from \"lucide-react\";\nimport { cn } from \"@dsui/ui/lib/utils\";\n\nexport interface RateProps {\n // Display\n count?: number;\n value?: number;\n defaultValue?: number;\n allowHalf?: boolean;\n allowClear?: boolean;\n\n // Appearance\n size?: \"small\" | \"middle\" | \"large\";\n color?:\n | \"primary\"\n | \"secondary\"\n | \"accent\"\n | \"destructive\"\n | \"muted\"\n | \"success\"\n | \"error\"\n | \"warning\";\n character?: React.ReactNode | ((rateProps: RateProps) => React.ReactNode);\n className?: string;\n style?: React.CSSProperties;\n\n // Interaction\n disabled?: boolean;\n autoFocus?: boolean;\n keyboard?: boolean;\n\n // Tooltips\n tooltips?: string[];\n\n // Callbacks\n onChange?: (value: number) => void;\n onHoverChange?: (value: number) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n}\n\nconst Rate = React.forwardRef<HTMLDivElement, RateProps>(\n (\n {\n count = 5,\n value: controlledValue,\n defaultValue = 0,\n allowHalf = false,\n allowClear = true,\n size = \"middle\",\n color = \"warning\",\n character,\n className,\n style,\n disabled = false,\n autoFocus = false,\n keyboard = true,\n tooltips,\n onChange,\n onHoverChange,\n onFocus,\n onBlur,\n onKeyDown,\n },\n ref\n ) => {\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [hoverValue, setHoverValue] = useState<number | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Use controlled or uncontrolled value\n const value =\n controlledValue !== undefined ? controlledValue : internalValue;\n\n // Size in pixels\n const sizeMap = {\n small: 20,\n middle: 24,\n large: 32,\n };\n\n // Color mapping for filled stars\n const colorMap = {\n primary: \"text-primary [&_svg]:fill-primary\",\n secondary: \"text-secondary [&_svg]:fill-secondary\",\n accent: \"text-accent [&_svg]:fill-accent\",\n destructive: \"text-destructive [&_svg]:fill-destructive\",\n muted: \"text-muted-foreground [&_svg]:fill-muted-foreground\",\n success: \"text-success [&_svg]:fill-success\",\n error: \"text-error [&_svg]:fill-error\",\n warning: \"text-yellow-400 [&_svg]:fill-yellow-400\",\n };\n\n // Handle star click\n const handleStarClick = (starIndex: number, isHalf: boolean) => {\n if (disabled) return;\n\n const newValue = isHalf ? starIndex + 0.5 : starIndex + 1;\n\n // If clicking the same value and allowClear is true, clear the rating\n if (allowClear && newValue === value) {\n setInternalValue(0);\n onChange?.(0);\n } else {\n setInternalValue(newValue);\n onChange?.(newValue);\n }\n };\n\n // Handle star hover\n const handleStarHover = (starIndex: number, isHalf: boolean) => {\n if (disabled) return;\n\n const newHoverValue = isHalf ? starIndex + 0.5 : starIndex + 1;\n setHoverValue(newHoverValue);\n onHoverChange?.(newHoverValue);\n };\n\n // Handle mouse leave\n const handleMouseLeave = () => {\n setHoverValue(null);\n onHoverChange?.(0);\n };\n\n // Handle keyboard navigation\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!keyboard || disabled) return;\n\n onKeyDown?.(event);\n\n const step = allowHalf ? 0.5 : 1;\n let newValue = value;\n\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n event.preventDefault();\n newValue = Math.min(value + step, count);\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n event.preventDefault();\n newValue = Math.max(value - step, 0);\n break;\n case \"Home\":\n event.preventDefault();\n newValue = allowHalf ? 0.5 : 1;\n break;\n case \"End\":\n event.preventDefault();\n newValue = count;\n break;\n default:\n return;\n }\n\n setInternalValue(newValue);\n onChange?.(newValue);\n };\n\n // Handle focus\n const handleFocus = () => {\n onFocus?.();\n };\n\n // Handle blur\n const handleBlur = () => {\n onBlur?.();\n };\n\n // Get star fill percentage\n const getStarFill = (starIndex: number) => {\n const currentValue = hoverValue !== null ? hoverValue : value;\n\n if (currentValue >= starIndex + 1) {\n return 100; // Full star\n } else if (currentValue > starIndex && currentValue < starIndex + 1) {\n return (currentValue - starIndex) * 100; // Partial star\n }\n return 0; // Empty star\n };\n\n // Check if star should show as half\n const isHalfStar = (starIndex: number) => {\n if (!allowHalf) return false;\n const currentValue = hoverValue !== null ? hoverValue : value;\n const fill = currentValue - starIndex;\n return fill > 0 && fill <= 0.5;\n };\n\n // Render character\n const renderCharacter = (isHalf: boolean = false) => {\n if (typeof character === \"function\") {\n return character({\n count,\n value,\n defaultValue,\n allowHalf,\n allowClear,\n size,\n disabled,\n });\n }\n if (isHalf) {\n return <StarHalf className=\"ds:w-full ds:h-full\" />;\n }\n return character || <Star className=\"ds:w-full ds:h-full\" />;\n };\n\n // Get tooltip for star\n const getTooltip = (starIndex: number) => {\n if (!tooltips || !tooltips[starIndex]) return undefined;\n return tooltips[starIndex];\n };\n\n return (\n <div\n ref={(node) => {\n containerRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n className={cn(\n \"ds:inline-flex ds:items-center ds:gap-1\",\n disabled && \"ds:opacity-50 ds:cursor-not-allowed\",\n !disabled && \"ds:cursor-pointer\",\n className\n )}\n style={style}\n onMouseLeave={handleMouseLeave}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n tabIndex={disabled ? -1 : 0}\n role=\"slider\"\n aria-label=\"Rate\"\n aria-valuemin={0}\n aria-valuemax={count}\n aria-valuenow={value}\n aria-disabled={disabled}\n autoFocus={autoFocus}\n >\n {Array.from({ length: count }, (_, index) => {\n const fillPercentage = getStarFill(index);\n const tooltip = getTooltip(index);\n const showHalfStar = isHalfStar(index);\n\n return (\n <div key={index} className=\"ds:relative ds:group\" title={tooltip}>\n {/* Container for half stars */}\n <div\n className=\"ds:relative ds:inline-flex\"\n style={{\n width: `${sizeMap[size]}px`,\n height: `${sizeMap[size]}px`,\n }}\n >\n {/* Empty star background */}\n <div className=\"ds:text-muted-foreground/30 ds:pointer-events-none\">\n {renderCharacter(false)}\n </div>\n\n {/* Filled star overlay */}\n {fillPercentage > 0 && (\n <div\n className={cn(\n \"ds:absolute ds:inset-0 ds:pointer-events-none\",\n colorMap[color]\n )}\n >\n {showHalfStar ? (\n renderCharacter(true)\n ) : (\n <div\n className=\"ds:overflow-hidden\"\n style={{ width: `${fillPercentage}%` }}\n >\n {renderCharacter(false)}\n </div>\n )}\n </div>\n )}\n\n {/* Interactive overlay for clicking and hovering */}\n {!disabled && (\n <>\n {allowHalf ? (\n <>\n {/* Left half */}\n <div\n className=\"ds:absolute ds:inset-0 ds:w-1/2 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, true)}\n onMouseEnter={() => handleStarHover(index, true)}\n />\n {/* Right half */}\n <div\n className=\"ds:absolute ds:inset-0 ds:left-1/2 ds:w-1/2 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, false)}\n onMouseEnter={() => handleStarHover(index, false)}\n />\n </>\n ) : (\n <div\n className=\"ds:absolute ds:inset-0 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, false)}\n onMouseEnter={() => handleStarHover(index, false)}\n />\n )}\n </>\n )}\n </div>\n\n {/* Show tooltip text below star on hover */}\n {tooltip &&\n (hoverValue === index + 1 ||\n (allowHalf && hoverValue === index + 0.5)) && (\n <div className=\"ds:absolute ds:top-full ds:left-1/2 ds:-translate-x-1/2 ds:mt-1 ds:px-2 ds:py-1 ds:text-xs ds:bg-foreground ds:text-background ds:rounded ds:whitespace-nowrap ds:z-10\">\n {tooltip}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n }\n);\n\nRate.displayName = \"Rate\";\n\nexport default Rate;\n"],"names":["Rate","React","count","controlledValue","defaultValue","allowHalf","allowClear","size","color","character","className","style","disabled","autoFocus","keyboard","tooltips","onChange","onHoverChange","onFocus","onBlur","onKeyDown","ref","internalValue","setInternalValue","useState","hoverValue","setHoverValue","containerRef","useRef","value","sizeMap","colorMap","handleStarClick","starIndex","isHalf","newValue","handleStarHover","newHoverValue","handleMouseLeave","handleKeyDown","event","step","handleFocus","handleBlur","getStarFill","currentValue","isHalfStar","fill","renderCharacter","jsx","StarHalf","Star","getTooltip","node","cn","_","index","fillPercentage","tooltip","showHalfStar","jsxs","Fragment"],"mappings":"+OA8CMA,EAAOC,EAAM,WACjB,CACE,CACE,MAAAC,EAAQ,EACR,MAAOC,EACP,aAAAC,EAAe,EACf,UAAAC,EAAY,GACZ,WAAAC,EAAa,GACb,KAAAC,EAAO,SACP,MAAAC,EAAQ,UACR,UAAAC,EACA,UAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,SAAAC,EACA,SAAAC,EACA,cAAAC,EACA,QAAAC,EACA,OAAAC,EACA,UAAAC,CAAA,EAEFC,IACG,CACH,KAAM,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAASpB,CAAY,EACzD,CAACqB,EAAYC,CAAa,EAAIF,EAAAA,SAAwB,IAAI,EAC1DG,EAAeC,EAAAA,OAAuB,IAAI,EAG1CC,EACJ1B,IAAoB,OAAYA,EAAkBmB,EAG9CQ,EAAU,CACd,MAAO,GACP,OAAQ,GACR,MAAO,EAAA,EAIHC,EAAW,CACf,QAAS,oCACT,UAAW,wCACX,OAAQ,kCACR,YAAa,4CACb,MAAO,sDACP,QAAS,oCACT,MAAO,gCACP,QAAS,yCAAA,EAILC,EAAkB,CAACC,EAAmBC,IAAoB,CAC9D,GAAItB,EAAU,OAEd,MAAMuB,EAAWD,EAASD,EAAY,GAAMA,EAAY,EAGpD3B,GAAc6B,IAAaN,GAC7BN,EAAiB,CAAC,EAClBP,IAAW,CAAC,IAEZO,EAAiBY,CAAQ,EACzBnB,IAAWmB,CAAQ,EAEvB,EAGMC,EAAkB,CAACH,EAAmBC,IAAoB,CAC9D,GAAItB,EAAU,OAEd,MAAMyB,EAAgBH,EAASD,EAAY,GAAMA,EAAY,EAC7DP,EAAcW,CAAa,EAC3BpB,IAAgBoB,CAAa,CAC/B,EAGMC,EAAmB,IAAM,CAC7BZ,EAAc,IAAI,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C,MAAAY,EAAAA,SAAA,CACG,SAAAxD,EACCuD,EAAAA,KAAAC,WAAA,CAEE,SAAA,CAAAZ,EAAAA,IAAC,MAAA,CACC,UAAU,oDACV,QAAS,IAAMjB,EAAgBwB,EAAO,EAAI,EAC1C,aAAc,IAAMpB,EAAgBoB,EAAO,EAAI,CAAA,CAAA,EAGjDP,EAAAA,IAAC,MAAA,CACC,UAAU,gEACV,QAAS,IAAMjB,EAAgBwB,EAAO,EAAK,EAC3C,aAAc,IAAMpB,EAAgBoB,EAAO,EAAK,CAAA,CAAA,CAClD,CAAA,CACF,EAEAP,EAAAA,IAAC,MAAA,CACC,UAAU,2CACV,QAAS,IAAMjB,EAAgBwB,EAAO,EAAK,EAC3C,aAAc,IAAMpB,EAAgBoB,EAAO,EAAK,CAAA,CAAA,CAClD,CAEJ,CAAA,CAAA,CAAA,EAKHE,IACEjC,IAAe+B,EAAQ,GACrBnD,GAAaoB,IAAe+B,EAAQ,KACrCP,EAAAA,IAAC,MAAA,CAAI,UAAU,yKACZ,SAAAS,CAAA,CACH,CAAA,CAAA,EAtEIF,CAwEV,CAEJ,CAAC,CAAA,CAAA,CAGP,CACF,EAEAxD,EAAK,YAAc"}
1
+ {"version":3,"file":"Rate.cjs","sources":["../../../../src/components/Rate/Rate.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useState, useRef } from \"react\";\nimport type { KeyboardEvent } from \"react\";\nimport { Star, StarHalf } from \"lucide-react\";\nimport { cn } from \"@dsui/ui/lib/utils\";\n\nexport interface RateProps {\n // Display\n count?: number;\n value?: number;\n defaultValue?: number;\n allowHalf?: boolean;\n allowClear?: boolean;\n\n // Appearance\n size?: \"small\" | \"middle\" | \"large\";\n color?:\n | \"primary\"\n | \"secondary\"\n | \"accent\"\n | \"destructive\"\n | \"muted\"\n | \"success\"\n | \"error\"\n | \"warning\";\n character?: React.ReactNode | ((rateProps: RateProps) => React.ReactNode);\n className?: string;\n style?: React.CSSProperties;\n\n // Interaction\n disabled?: boolean;\n autoFocus?: boolean;\n keyboard?: boolean;\n\n // Tooltips\n tooltips?: string[];\n\n // Callbacks\n onChange?: (value: number) => void;\n onHoverChange?: (value: number) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;\n}\n\nconst Rate = React.forwardRef<HTMLDivElement, RateProps>(\n (\n {\n count = 5,\n value: controlledValue,\n defaultValue = 0,\n allowHalf = false,\n allowClear = true,\n size = \"middle\",\n color = \"warning\",\n character,\n className,\n style,\n disabled = false,\n autoFocus = false,\n keyboard = true,\n tooltips,\n onChange,\n onHoverChange,\n onFocus,\n onBlur,\n onKeyDown,\n },\n ref\n ) => {\n const [internalValue, setInternalValue] = useState(defaultValue);\n const [hoverValue, setHoverValue] = useState<number | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Use controlled or uncontrolled value\n const value =\n controlledValue !== undefined ? controlledValue : internalValue;\n\n // Size in pixels\n const sizeMap = {\n small: 20,\n middle: 24,\n large: 32,\n };\n\n // Color mapping for filled stars\n const colorMap = {\n primary: \"ds:text-primary ds:[&_svg]:fill-primary\",\n secondary: \"ds:text-secondary ds:[&_svg]:fill-secondary\",\n accent: \"ds:text-accent ds:[&_svg]:fill-accent\",\n destructive: \"ds:text-destructive ds:[&_svg]:fill-destructive\",\n muted: \"ds:text-muted-foreground ds:[&_svg]:fill-muted-foreground\",\n success: \"ds:text-success ds:[&_svg]:fill-success\",\n error: \"ds:text-error ds:[&_svg]:fill-error\",\n warning: \"ds:text-yellow-400 ds:[&_svg]:fill-yellow-400\",\n };\n\n // Handle star click\n const handleStarClick = (starIndex: number, isHalf: boolean) => {\n if (disabled) return;\n\n const newValue = isHalf ? starIndex + 0.5 : starIndex + 1;\n\n // If clicking the same value and allowClear is true, clear the rating\n if (allowClear && newValue === value) {\n setInternalValue(0);\n onChange?.(0);\n } else {\n setInternalValue(newValue);\n onChange?.(newValue);\n }\n };\n\n // Handle star hover\n const handleStarHover = (starIndex: number, isHalf: boolean) => {\n if (disabled) return;\n\n const newHoverValue = isHalf ? starIndex + 0.5 : starIndex + 1;\n setHoverValue(newHoverValue);\n onHoverChange?.(newHoverValue);\n };\n\n // Handle mouse leave\n const handleMouseLeave = () => {\n setHoverValue(null);\n onHoverChange?.(0);\n };\n\n // Handle keyboard navigation\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!keyboard || disabled) return;\n\n onKeyDown?.(event);\n\n const step = allowHalf ? 0.5 : 1;\n let newValue = value;\n\n switch (event.key) {\n case \"ArrowRight\":\n case \"ArrowUp\":\n event.preventDefault();\n newValue = Math.min(value + step, count);\n break;\n case \"ArrowLeft\":\n case \"ArrowDown\":\n event.preventDefault();\n newValue = Math.max(value - step, 0);\n break;\n case \"Home\":\n event.preventDefault();\n newValue = allowHalf ? 0.5 : 1;\n break;\n case \"End\":\n event.preventDefault();\n newValue = count;\n break;\n default:\n return;\n }\n\n setInternalValue(newValue);\n onChange?.(newValue);\n };\n\n // Handle focus\n const handleFocus = () => {\n onFocus?.();\n };\n\n // Handle blur\n const handleBlur = () => {\n onBlur?.();\n };\n\n // Get star fill percentage\n const getStarFill = (starIndex: number) => {\n const currentValue = hoverValue !== null ? hoverValue : value;\n\n if (currentValue >= starIndex + 1) {\n return 100; // Full star\n } else if (currentValue > starIndex && currentValue < starIndex + 1) {\n return (currentValue - starIndex) * 100; // Partial star\n }\n return 0; // Empty star\n };\n\n // Check if star should show as half\n const isHalfStar = (starIndex: number) => {\n if (!allowHalf) return false;\n const currentValue = hoverValue !== null ? hoverValue : value;\n const fill = currentValue - starIndex;\n return fill > 0 && fill <= 0.5;\n };\n\n // Render character\n const renderCharacter = (isHalf: boolean = false) => {\n if (typeof character === \"function\") {\n return character({\n count,\n value,\n defaultValue,\n allowHalf,\n allowClear,\n size,\n disabled,\n });\n }\n if (isHalf) {\n return <StarHalf className=\"ds:w-full ds:h-full\" />;\n }\n return character || <Star className=\"ds:w-full ds:h-full\" />;\n };\n\n // Get tooltip for star\n const getTooltip = (starIndex: number) => {\n if (!tooltips || !tooltips[starIndex]) return undefined;\n return tooltips[starIndex];\n };\n\n return (\n <div\n ref={(node) => {\n containerRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n className={cn(\n \"ds:inline-flex ds:items-center ds:gap-1\",\n disabled && \"ds:opacity-50 ds:cursor-not-allowed\",\n !disabled && \"ds:cursor-pointer\",\n className\n )}\n style={style}\n onMouseLeave={handleMouseLeave}\n onKeyDown={handleKeyDown}\n onFocus={handleFocus}\n onBlur={handleBlur}\n tabIndex={disabled ? -1 : 0}\n role=\"slider\"\n aria-label=\"Rate\"\n aria-valuemin={0}\n aria-valuemax={count}\n aria-valuenow={value}\n aria-disabled={disabled}\n autoFocus={autoFocus}\n >\n {Array.from({ length: count }, (_, index) => {\n const fillPercentage = getStarFill(index);\n const tooltip = getTooltip(index);\n const showHalfStar = isHalfStar(index);\n\n return (\n <div key={index} className=\"ds:relative ds:group\" title={tooltip}>\n {/* Container for half stars */}\n <div\n className=\"ds:relative ds:inline-flex\"\n style={{\n width: `${sizeMap[size]}px`,\n height: `${sizeMap[size]}px`,\n }}\n >\n {/* Empty star background */}\n <div className=\"ds:text-muted-foreground/30 ds:pointer-events-none\">\n {renderCharacter(false)}\n </div>\n\n {/* Filled star overlay */}\n {fillPercentage > 0 && (\n <div\n className={cn(\n \"ds:absolute ds:inset-0 ds:pointer-events-none\",\n colorMap[color]\n )}\n >\n {showHalfStar ? (\n renderCharacter(true)\n ) : (\n <div\n className=\"ds:overflow-hidden\"\n style={{ width: `${fillPercentage}%` }}\n >\n {renderCharacter(false)}\n </div>\n )}\n </div>\n )}\n\n {/* Interactive overlay for clicking and hovering */}\n {!disabled && (\n <>\n {allowHalf ? (\n <>\n {/* Left half */}\n <div\n className=\"ds:absolute ds:inset-0 ds:w-1/2 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, true)}\n onMouseEnter={() => handleStarHover(index, true)}\n />\n {/* Right half */}\n <div\n className=\"ds:absolute ds:inset-0 ds:left-1/2 ds:w-1/2 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, false)}\n onMouseEnter={() => handleStarHover(index, false)}\n />\n </>\n ) : (\n <div\n className=\"ds:absolute ds:inset-0 ds:cursor-pointer\"\n onClick={() => handleStarClick(index, false)}\n onMouseEnter={() => handleStarHover(index, false)}\n />\n )}\n </>\n )}\n </div>\n\n {/* Show tooltip text below star on hover */}\n {tooltip &&\n (hoverValue === index + 1 ||\n (allowHalf && hoverValue === index + 0.5)) && (\n <div className=\"ds:absolute ds:top-full ds:left-1/2 ds:-translate-x-1/2 ds:mt-1 ds:px-2 ds:py-1 ds:text-xs ds:bg-foreground ds:text-background ds:rounded ds:whitespace-nowrap ds:z-10\">\n {tooltip}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n }\n);\n\nRate.displayName = \"Rate\";\n\nexport default Rate;\n"],"names":["Rate","React","count","controlledValue","defaultValue","allowHalf","allowClear","size","color","character","className","style","disabled","autoFocus","keyboard","tooltips","onChange","onHoverChange","onFocus","onBlur","onKeyDown","ref","internalValue","setInternalValue","useState","hoverValue","setHoverValue","containerRef","useRef","value","sizeMap","colorMap","handleStarClick","starIndex","isHalf","newValue","handleStarHover","newHoverValue","handleMouseLeave","handleKeyDown","event","step","handleFocus","handleBlur","getStarFill","currentValue","isHalfStar","fill","renderCharacter","jsx","StarHalf","Star","getTooltip","node","cn","_","index","fillPercentage","tooltip","showHalfStar","jsxs","Fragment"],"mappings":"+OA8CMA,EAAOC,EAAM,WACjB,CACE,CACE,MAAAC,EAAQ,EACR,MAAOC,EACP,aAAAC,EAAe,EACf,UAAAC,EAAY,GACZ,WAAAC,EAAa,GACb,KAAAC,EAAO,SACP,MAAAC,EAAQ,UACR,UAAAC,EACA,UAAAC,EACA,MAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,SAAAC,EACA,SAAAC,EACA,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MAAA,CACC,UAAU,2CACV,QAAS,IAAMjB,EAAgBwB,EAAO,EAAK,EAC3C,aAAc,IAAMpB,EAAgBoB,EAAO,EAAK,CAAA,CAAA,CAClD,CAEJ,CAAA,CAAA,CAAA,EAKHE,IACEjC,IAAe+B,EAAQ,GACrBnD,GAAaoB,IAAe+B,EAAQ,KACrCP,EAAAA,IAAC,MAAA,CAAI,UAAU,yKACZ,SAAAS,CAAA,CACH,CAAA,CAAA,EAtEIF,CAwEV,CAEJ,CAAC,CAAA,CAAA,CAGP,CACF,EAEAxD,EAAK,YAAc"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("react"),l=require("../../packages/ui/src/components/sheet.cjs"),n=require("../../packages/ui/src/components/drawer.cjs"),s=require("../../packages/ui/src/lib/utils.cjs"),z=require("../../packages/ui/src/components/scroll-area.cjs"),K=require("../../utils/animations.cjs"),P=require("react-device-detect"),H=(f,o)=>{const t=o==="top"||o==="bottom";return{sm:t?"max-h-[20vh]!":"sm:max-w-sm",md:t?"max-h-[40vh]!":"sm:max-w-md",lg:t?"max-h-[60vh]!":"sm:max-w-lg",xl:t?"max-h-[80vh]!":"sm:max-w-xl",full:t?"max-h-full!":"sm:max-w-full"}[f]},R=u.forwardRef((f,o)=>{const{open:t,onOpenChange:p,title:a,description:r,children:i,trigger:m,footer:c,side:v="right",closeOnEsc:A=!0,closeOnOutside:F=!0,showCloseButton:k=!0,autoDrawerOnMobile:E=!0,size:g="md",stickyHeader:h=!1,stickyFooter:x=!1,autoHeight:_=!0,animation:N,className:j,contentClassName:D,headerClassName:y,titleClassName:C,descriptionClassName:w,footerClassName:S,overlayClassName:B}=f,b=u.useMemo(()=>N?K.animationClass(N):{className:""},[N]),I=s.cn("ds:!p-0 ds:!gap-0 ds:flex ds:flex-col",H(g,v),b.className,j),M=s.cn("ds:px-6 ds:pt-6 ds:text-left",y),q=s.cn("ds:px-6 ds:pb-6 ds:flex-col-reverse ds:sm:flex-row ds:sm:justify-end ds:sm:space-x-2",S),O=u.useMemo(()=>a||r?e.jsxs(l.SheetHeader,{className:s.cn("ds:py-4",{"ds:border-b":h},M),children:[a&&e.jsx(l.SheetTitle,{className:C,children:a}),r&&e.jsx(l.SheetDescription,{className:w,children:r})]}):null,[a,r,M,C,w,h]),T=u.useMemo(()=>c?e.jsx(l.SheetFooter,{className:s.cn("ds:py-4",{"ds:border-t":x},q),children:c}):null,[c,q,x]);if(P.isMobile&&E){const d=s.cn("ds:flex ds:flex-col",b.className,j);return e.jsxs(n.Drawer,{open:t,onOpenChange:p,direction:"bottom",children:[m&&e.jsx(n.DrawerTrigger,{asChild:!0,children:m}),e.jsxs(n.DrawerContent,{ref:o,className:s.cn(d,_?"":H(g,"bottom")),children:[(a||r)&&e.jsxs(n.DrawerHeader,{className:y,children:[a&&e.jsx(n.DrawerTitle,{className:C,children:a}),r&&e.jsx(n.DrawerDescription,{className:w,children:r})]}),e.jsx(z.ScrollArea,{className:s.cn("ds:flex ds:flex-col ds:overflow-hidden"),children:i&&e.jsx("div",{className:s.cn("ds:px-4 ds:py-2",D),children:i})}),c&&e.jsx(n.DrawerFooter,{className:S,children:c})]})]})}return e.jsxs(l.Sheet,{open:t,onOpenChange:p,children:[m&&e.jsx(l.SheetTrigger,{asChild:!0,children:m}),e.jsxs(l.SheetContent,{ref:o,side:v,className:s.cn(j,I),onEscapeKeyDown:d=>!A&&d.preventDefault(),onInteractOutside:d=>!F&&d.preventDefault(),overlayClassName:s.cn(B),children:[!k&&e.jsx("style",{children:`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("react"),l=require("../../packages/ui/src/components/sheet.cjs"),n=require("../../packages/ui/src/components/drawer.cjs"),s=require("../../packages/ui/src/lib/utils.cjs"),z=require("../../packages/ui/src/components/scroll-area.cjs"),K=require("../../utils/animations.cjs"),P=require("react-device-detect"),H=(f,o)=>{const t=o==="top"||o==="bottom";return{sm:t?"ds:max-h-[20vh]!":"ds:max-w-sm",md:t?"ds:max-h-[40vh]!":"ds:max-w-md",lg:t?"ds:max-h-[60vh]!":"ds:max-w-lg",xl:t?"ds:max-h-[80vh]!":"ds:max-w-xl",full:t?"ds:max-h-full!":"ds:max-w-full"}[f]},R=u.forwardRef((f,o)=>{const{open:t,onOpenChange:p,title:a,description:r,children:i,trigger:m,footer:c,side:v="right",closeOnEsc:A=!0,closeOnOutside:F=!0,showCloseButton:k=!0,autoDrawerOnMobile:E=!0,size:g="md",stickyHeader:h=!1,stickyFooter:x=!1,autoHeight:_=!0,animation:N,className:j,contentClassName:D,headerClassName:y,titleClassName:C,descriptionClassName:w,footerClassName:S,overlayClassName:B}=f,b=u.useMemo(()=>N?K.animationClass(N):{className:""},[N]),I=s.cn("ds:!p-0 ds:!gap-0 ds:flex ds:flex-col",H(g,v),b.className,j),M=s.cn("ds:px-6 ds:pt-6 ds:text-left",y),q=s.cn("ds:px-6 ds:pb-6 ds:flex-col-reverse ds:sm:flex-row ds:sm:justify-end ds:sm:space-x-2",S),O=u.useMemo(()=>a||r?e.jsxs(l.SheetHeader,{className:s.cn("ds:py-4",{"ds:border-b":h},M),children:[a&&e.jsx(l.SheetTitle,{className:C,children:a}),r&&e.jsx(l.SheetDescription,{className:w,children:r})]}):null,[a,r,M,C,w,h]),T=u.useMemo(()=>c?e.jsx(l.SheetFooter,{className:s.cn("ds:py-4",{"ds:border-t":x},q),children:c}):null,[c,q,x]);if(P.isMobile&&E){const d=s.cn("ds:flex ds:flex-col",b.className,j);return e.jsxs(n.Drawer,{open:t,onOpenChange:p,direction:"bottom",children:[m&&e.jsx(n.DrawerTrigger,{asChild:!0,children:m}),e.jsxs(n.DrawerContent,{ref:o,className:s.cn(d,_?"":H(g,"bottom")),children:[(a||r)&&e.jsxs(n.DrawerHeader,{className:y,children:[a&&e.jsx(n.DrawerTitle,{className:C,children:a}),r&&e.jsx(n.DrawerDescription,{className:w,children:r})]}),e.jsx(z.ScrollArea,{className:s.cn("ds:flex ds:flex-col ds:overflow-hidden"),children:i&&e.jsx("div",{className:s.cn("ds:px-4 ds:py-2",D),children:i})}),c&&e.jsx(n.DrawerFooter,{className:S,children:c})]})]})}return e.jsxs(l.Sheet,{open:t,onOpenChange:p,children:[m&&e.jsx(l.SheetTrigger,{asChild:!0,children:m}),e.jsxs(l.SheetContent,{ref:o,side:v,className:s.cn(j,I),onEscapeKeyDown:d=>!A&&d.preventDefault(),onInteractOutside:d=>!F&&d.preventDefault(),overlayClassName:s.cn(B),children:[!k&&e.jsx("style",{children:`
2
2
  [data-slot="sheet-content"] > [data-slot="sheet-close"] {
3
3
  display: none;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Sheet.cjs","sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Sheet as SSheet,\n SheetContent as SSheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n SheetTrigger,\n SheetClose,\n} from \"@dsui/ui/components/sheet\";\nimport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/lib/utils\";\nimport { ScrollArea } from \"@dsui/ui/components/scroll-area\";\nimport type { BasicAnimation } from \"@/types/variables\";\nimport { animationClass } from \"@/utils/animations\";\nimport { isMobile } from \"react-device-detect\";\n\nexport type SheetSide = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport type SheetSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nexport interface SheetProps {\n // Core props\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n // Content\n title?: React.ReactNode;\n description?: React.ReactNode;\n children?: React.ReactNode;\n trigger?: React.ReactNode;\n footer?: React.ReactNode;\n\n // Behavior\n side?: SheetSide;\n closeOnEsc?: boolean;\n closeOnOutside?: boolean;\n showCloseButton?: boolean;\n autoDrawerOnMobile?: boolean;\n\n // Layout\n size?: SheetSize;\n stickyHeader?: boolean;\n stickyFooter?: boolean;\n autoHeight?: boolean;\n\n // Animation\n animation?: BasicAnimation;\n\n // Styling\n className?: string;\n contentClassName?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n footerClassName?: string;\n overlayClassName?: string;\n}\n\nconst getSizeClasses = (size: SheetSize, side: SheetSide): string => {\n const isVertical = side === \"top\" || side === \"bottom\";\n const sizeMap: Record<SheetSize, string> = {\n sm: isVertical ? \"max-h-[20vh]!\" : \"sm:max-w-sm\",\n md: isVertical ? \"max-h-[40vh]!\" : \"sm:max-w-md\",\n lg: isVertical ? \"max-h-[60vh]!\" : \"sm:max-w-lg\",\n xl: isVertical ? \"max-h-[80vh]!\" : \"sm:max-w-xl\",\n full: isVertical ? \"max-h-full!\" : \"sm:max-w-full\",\n };\n return sizeMap[size];\n};\n\nconst Sheet = React.forwardRef<HTMLDivElement, SheetProps>((props, ref) => {\n const {\n open,\n onOpenChange,\n title,\n description,\n children,\n trigger,\n footer,\n side = \"right\",\n closeOnEsc = true,\n closeOnOutside = true,\n showCloseButton = true,\n autoDrawerOnMobile = true,\n size = \"md\",\n stickyHeader = false,\n stickyFooter = false,\n autoHeight = true,\n animation,\n className,\n contentClassName,\n headerClassName,\n titleClassName,\n descriptionClassName,\n footerClassName,\n overlayClassName,\n } = props;\n\n const animationResult = useMemo(() => {\n return animation ? animationClass(animation) : { className: \"\" };\n }, [animation]);\n\n const contentClasses = cn(\n // Remove default padding and gap to allow custom header/footer\n \"ds:!p-0 ds:!gap-0 ds:flex ds:flex-col\",\n getSizeClasses(size, side),\n animationResult.className,\n className\n );\n\n const headerClasses = cn(\"ds:px-6 ds:pt-6 ds:text-left\", headerClassName);\n\n const footerClasses = cn(\n \"ds:px-6 ds:pb-6 ds:flex-col-reverse ds:sm:flex-row ds:sm:justify-end ds:sm:space-x-2\",\n footerClassName\n );\n\n const headerComponents = useMemo(() => {\n return title || description ? (\n <SheetHeader\n className={cn(\"ds:py-4\", { \"ds:border-b\": stickyHeader }, headerClasses)}\n >\n {title && <SheetTitle className={titleClassName}>{title}</SheetTitle>}\n {description && (\n <SheetDescription className={descriptionClassName}>\n {description}\n </SheetDescription>\n )}\n </SheetHeader>\n ) : null;\n }, [\n title,\n description,\n headerClasses,\n titleClassName,\n descriptionClassName,\n stickyHeader,\n ]);\n\n const footerComponents = useMemo(() => {\n return footer ? (\n <SheetFooter\n className={cn(\"ds:py-4\", { \"ds:border-t\": stickyFooter }, footerClasses)}\n >\n {footer}\n </SheetFooter>\n ) : null;\n }, [footer, footerClasses, stickyFooter]);\n\n // Mobile: use drawer with bottom direction if enabled\n if (isMobile && autoDrawerOnMobile) {\n const drawerContentClasses = cn(\n \"ds:flex ds:flex-col\",\n animationResult.className,\n className\n );\n\n return (\n <Drawer open={open} onOpenChange={onOpenChange} direction=\"bottom\">\n {trigger && <DrawerTrigger asChild>{trigger}</DrawerTrigger>}\n <DrawerContent\n ref={ref}\n className={cn(\n drawerContentClasses,\n autoHeight ? \"\" : getSizeClasses(size, \"bottom\")\n )}\n >\n {(title || description) && (\n <DrawerHeader className={headerClassName}>\n {title && (\n <DrawerTitle className={titleClassName}>{title}</DrawerTitle>\n )}\n {description && (\n <DrawerDescription className={descriptionClassName}>\n {description}\n </DrawerDescription>\n )}\n </DrawerHeader>\n )}\n\n <ScrollArea className={cn(\"ds:flex ds:flex-col ds:overflow-hidden\")}>\n {children && (\n <div className={cn(\"ds:px-4 ds:py-2\", contentClassName)}>\n {children}\n </div>\n )}\n </ScrollArea>\n\n {footer && (\n <DrawerFooter className={footerClassName}>{footer}</DrawerFooter>\n )}\n </DrawerContent>\n </Drawer>\n );\n }\n\n // Desktop: use sheet with original behavior\n return (\n <SSheet open={open} onOpenChange={onOpenChange}>\n {trigger && <SheetTrigger asChild>{trigger}</SheetTrigger>}\n <SSheetContent\n ref={ref}\n side={side}\n className={cn(className, contentClasses)}\n onEscapeKeyDown={(e) => !closeOnEsc && e.preventDefault()}\n onInteractOutside={(e) => !closeOnOutside && e.preventDefault()}\n overlayClassName={cn(overlayClassName)}\n >\n {/* Hide default close button if showCloseButton is false */}\n {!showCloseButton && (\n <style>{`\n [data-slot=\"sheet-content\"] > [data-slot=\"sheet-close\"] {\n display: none;\n }\n `}</style>\n )}\n\n {stickyHeader && headerComponents}\n\n <ScrollArea className=\"ds:flex ds:max-h-full ds:flex-col ds:overflow-hidden\">\n {!stickyHeader && headerComponents}\n {children && (\n <div className={cn(\"ds:px-6 ds:py-4\", contentClassName)}>{children}</div>\n )}\n {!stickyFooter && footerComponents}\n </ScrollArea>\n\n {stickyFooter && footerComponents}\n </SSheetContent>\n </SSheet>\n );\n});\n\nSheet.displayName = \"Sheet\";\n\nexport { SheetClose, DrawerClose };\nexport default Sheet;\n"],"names":["getSizeClasses","size","side","isVertical","Sheet","React","props","ref","open","onOpenChange","title","description","children","trigger","footer","closeOnEsc","closeOnOutside","showCloseButton","autoDrawerOnMobile","stickyHeader","stickyFooter","autoHeight","animation","className","contentClassName","headerClassName","titleClassName","descriptionClassName","footerClassName","overlayClassName","animationResult","useMemo","animationClass","contentClasses","cn","headerClasses","footerClasses","headerComponents","jsxs","SheetHeader","jsx","SheetTitle","SheetDescription","footerComponents","SheetFooter","isMobile","drawerContentClasses","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","ScrollArea","DrawerFooter","SSheet","SheetTrigger","SSheetContent","e"],"mappings":"6cAoEMA,EAAiB,CAACC,EAAiBC,IAA4B,CACnE,MAAMC,EAAaD,IAAS,OAASA,IAAS,SAQ9C,MAP2C,CACzC,GAAIC,EAAa,gBAAkB,cACnC,GAAIA,EAAa,gBAAkB,cACnC,GAAIA,EAAa,gBAAkB,cACnC,GAAIA,EAAa,gBAAkB,cACnC,KAAMA,EAAa,cAAgB,eAAA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EACA,KAAAL,EACA,UAAWgC,EAAAA,GAAGX,EAAWU,CAAc,EACvC,gBAAkByB,GAAM,CAAC3C,GAAc2C,EAAE,eAAA,EACzC,kBAAoBA,GAAM,CAAC1C,GAAkB0C,EAAE,eAAA,EAC/C,iBAAkBxB,EAAAA,GAAGL,CAAgB,EAGpC,SAAA,CAAA,CAACZ,SACC,QAAA,CAAO,SAAA;AAAA;AAAA;AAAA;AAAA,YAIN,EAGHE,GAAgBkB,EAEjBC,EAAAA,KAACe,EAAAA,WAAA,CAAW,UAAU,uDACnB,SAAA,CAAA,CAAClC,GAAgBkB,EACjBzB,SACE,MAAA,CAAI,UAAWsB,EAAAA,GAAG,kBAAmBV,CAAgB,EAAI,SAAAZ,EAAS,EAEpE,CAACQ,GAAgBuB,CAAA,EACpB,EAECvB,GAAgBuB,CAAA,CAAA,CAAA,CACnB,EACF,CAEJ,CAAC,EAEDvC,EAAM,YAAc"}
1
+ {"version":3,"file":"Sheet.cjs","sources":["../../../../src/components/Sheet/Sheet.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport {\n Sheet as SSheet,\n SheetContent as SSheetContent,\n SheetDescription,\n SheetFooter,\n SheetHeader,\n SheetTitle,\n SheetTrigger,\n SheetClose,\n} from \"@dsui/ui/components/sheet\";\nimport {\n Drawer,\n DrawerClose,\n DrawerContent,\n DrawerDescription,\n DrawerFooter,\n DrawerHeader,\n DrawerTitle,\n DrawerTrigger,\n} from \"@dsui/ui/components/drawer\";\nimport { cn } from \"@dsui/ui/lib/utils\";\nimport { ScrollArea } from \"@dsui/ui/components/scroll-area\";\nimport type { BasicAnimation } from \"@/types/variables\";\nimport { animationClass } from \"@/utils/animations\";\nimport { isMobile } from \"react-device-detect\";\n\nexport type SheetSide = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport type SheetSize = \"sm\" | \"md\" | \"lg\" | \"xl\" | \"full\";\n\nexport interface SheetProps {\n // Core props\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n // Content\n title?: React.ReactNode;\n description?: React.ReactNode;\n children?: React.ReactNode;\n trigger?: React.ReactNode;\n footer?: React.ReactNode;\n\n // Behavior\n side?: SheetSide;\n closeOnEsc?: boolean;\n closeOnOutside?: boolean;\n showCloseButton?: boolean;\n autoDrawerOnMobile?: boolean;\n\n // Layout\n size?: SheetSize;\n stickyHeader?: boolean;\n stickyFooter?: boolean;\n autoHeight?: boolean;\n\n // Animation\n animation?: BasicAnimation;\n\n // Styling\n className?: string;\n contentClassName?: string;\n headerClassName?: string;\n titleClassName?: string;\n descriptionClassName?: string;\n footerClassName?: string;\n overlayClassName?: string;\n}\n\nconst getSizeClasses = (size: SheetSize, side: SheetSide): string => {\n const isVertical = side === \"top\" || side === \"bottom\";\n const sizeMap: Record<SheetSize, string> = {\n sm: isVertical ? \"ds:max-h-[20vh]!\" : \"ds:max-w-sm\",\n md: isVertical ? \"ds:max-h-[40vh]!\" : \"ds:max-w-md\",\n lg: isVertical ? \"ds:max-h-[60vh]!\" : \"ds:max-w-lg\",\n xl: isVertical ? \"ds:max-h-[80vh]!\" : \"ds:max-w-xl\",\n full: isVertical ? \"ds:max-h-full!\" : \"ds:max-w-full\",\n };\n return sizeMap[size];\n};\n\nconst Sheet = React.forwardRef<HTMLDivElement, SheetProps>((props, ref) => {\n const {\n open,\n onOpenChange,\n title,\n description,\n children,\n trigger,\n footer,\n side = \"right\",\n closeOnEsc = true,\n closeOnOutside = true,\n showCloseButton = true,\n autoDrawerOnMobile = true,\n size = \"md\",\n stickyHeader = false,\n stickyFooter = false,\n autoHeight = true,\n animation,\n className,\n contentClassName,\n headerClassName,\n titleClassName,\n descriptionClassName,\n footerClassName,\n overlayClassName,\n } = props;\n\n const animationResult = useMemo(() => {\n return animation ? animationClass(animation) : { className: \"\" };\n }, [animation]);\n\n const contentClasses = cn(\n // Remove default padding and gap to allow custom header/footer\n \"ds:!p-0 ds:!gap-0 ds:flex ds:flex-col\",\n getSizeClasses(size, side),\n animationResult.className,\n className\n );\n\n const headerClasses = cn(\"ds:px-6 ds:pt-6 ds:text-left\", headerClassName);\n\n const footerClasses = cn(\n \"ds:px-6 ds:pb-6 ds:flex-col-reverse ds:sm:flex-row ds:sm:justify-end ds:sm:space-x-2\",\n footerClassName\n );\n\n const headerComponents = useMemo(() => {\n return title || description ? (\n <SheetHeader\n className={cn(\"ds:py-4\", { \"ds:border-b\": stickyHeader }, headerClasses)}\n >\n {title && <SheetTitle className={titleClassName}>{title}</SheetTitle>}\n {description && (\n <SheetDescription className={descriptionClassName}>\n {description}\n </SheetDescription>\n )}\n </SheetHeader>\n ) : null;\n }, [\n title,\n description,\n headerClasses,\n titleClassName,\n descriptionClassName,\n stickyHeader,\n ]);\n\n const footerComponents = useMemo(() => {\n return footer ? (\n <SheetFooter\n className={cn(\"ds:py-4\", { \"ds:border-t\": stickyFooter }, footerClasses)}\n >\n {footer}\n </SheetFooter>\n ) : null;\n }, [footer, footerClasses, stickyFooter]);\n\n // Mobile: use drawer with bottom direction if enabled\n if (isMobile && autoDrawerOnMobile) {\n const drawerContentClasses = cn(\n \"ds:flex ds:flex-col\",\n animationResult.className,\n className\n );\n\n return (\n <Drawer open={open} onOpenChange={onOpenChange} direction=\"bottom\">\n {trigger && <DrawerTrigger asChild>{trigger}</DrawerTrigger>}\n <DrawerContent\n ref={ref}\n className={cn(\n drawerContentClasses,\n autoHeight ? \"\" : getSizeClasses(size, \"bottom\")\n )}\n >\n {(title || description) && (\n <DrawerHeader className={headerClassName}>\n {title && (\n <DrawerTitle className={titleClassName}>{title}</DrawerTitle>\n )}\n {description && (\n <DrawerDescription className={descriptionClassName}>\n {description}\n </DrawerDescription>\n )}\n </DrawerHeader>\n )}\n\n <ScrollArea className={cn(\"ds:flex ds:flex-col ds:overflow-hidden\")}>\n {children && (\n <div className={cn(\"ds:px-4 ds:py-2\", contentClassName)}>\n {children}\n </div>\n )}\n </ScrollArea>\n\n {footer && (\n <DrawerFooter className={footerClassName}>{footer}</DrawerFooter>\n )}\n </DrawerContent>\n </Drawer>\n );\n }\n\n // Desktop: use sheet with original behavior\n return (\n <SSheet open={open} onOpenChange={onOpenChange}>\n {trigger && <SheetTrigger asChild>{trigger}</SheetTrigger>}\n <SSheetContent\n ref={ref}\n side={side}\n className={cn(className, contentClasses)}\n onEscapeKeyDown={(e) => !closeOnEsc && e.preventDefault()}\n onInteractOutside={(e) => !closeOnOutside && e.preventDefault()}\n overlayClassName={cn(overlayClassName)}\n >\n {/* Hide default close button if showCloseButton is false */}\n {!showCloseButton && (\n <style>{`\n [data-slot=\"sheet-content\"] > [data-slot=\"sheet-close\"] {\n display: none;\n }\n `}</style>\n )}\n\n {stickyHeader && headerComponents}\n\n <ScrollArea className=\"ds:flex ds:max-h-full ds:flex-col ds:overflow-hidden\">\n {!stickyHeader && headerComponents}\n {children && (\n <div className={cn(\"ds:px-6 ds:py-4\", contentClassName)}>{children}</div>\n )}\n {!stickyFooter && footerComponents}\n </ScrollArea>\n\n {stickyFooter && footerComponents}\n </SSheetContent>\n </SSheet>\n );\n});\n\nSheet.displayName = \"Sheet\";\n\nexport { SheetClose, DrawerClose };\nexport default Sheet;\n"],"names":["getSizeClasses","size","side","isVertical","Sheet","React","props","ref","open","onOpenChange","title","description","children","trigger","footer","closeOnEsc","closeOnOutside","showCloseButton","autoDrawerOnMobile","stickyHeader","stickyFooter","autoHeight","animation","className","contentClassName","headerClassName","titleClassName","descriptionClassName","footerClassName","overlayClassName","animationResult","useMemo","animationClass","contentClasses","cn","headerClasses","footerClasses","headerComponents","jsxs","SheetHeader","jsx","SheetTitle","SheetDescription","footerComponents","SheetFooter","isMobile","drawerContentClasses","Drawer","DrawerTrigger","DrawerContent","DrawerHeader","DrawerTitle","DrawerDescription","ScrollArea","DrawerFooter","SSheet","SheetTrigger","SSheetContent","e"],"mappings":"6cAoEMA,EAAiB,CAACC,EAAiBC,IAA4B,CACnE,MAAMC,EAAaD,IAAS,OAASA,IAAS,SAQ9C,MAP2C,CACzC,GAAIC,EAAa,mBAAqB,cACt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AAW2B,EAAAA,IAACgB,eAAA,CAAa,QAAO,GAAE,SAAA3C,EAAQ,EAC3CyB,EAAAA,KAACmB,EAAAA,aAAA,CACC,IAAAlD,EACA,KAAAL,EACA,UAAWgC,EAAAA,GAAGX,EAAWU,CAAc,EACvC,gBAAkByB,GAAM,CAAC3C,GAAc2C,EAAE,eAAA,EACzC,kBAAoBA,GAAM,CAAC1C,GAAkB0C,EAAE,eAAA,EAC/C,iBAAkBxB,EAAAA,GAAGL,CAAgB,EAGpC,SAAA,CAAA,CAACZ,SACC,QAAA,CAAO,SAAA;AAAA;AAAA;AAAA;AAAA,YAIN,EAGHE,GAAgBkB,EAEjBC,EAAAA,KAACe,EAAAA,WAAA,CAAW,UAAU,uDACnB,SAAA,CAAA,CAAClC,GAAgBkB,EACjBzB,SACE,MAAA,CAAI,UAAWsB,EAAAA,GAAG,kBAAmBV,CAAgB,EAAI,SAAAZ,EAAS,EAEpE,CAACQ,GAAgBuB,CAAA,EACpB,EAECvB,GAAgBuB,CAAA,CAAA,CAAA,CACnB,EACF,CAEJ,CAAC,EAEDvC,EAAM,YAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),n=require("react"),C=require("@radix-ui/react-slider"),s=require("../../packages/ui/src/lib/utils.cjs"),w=require("motion/react"),K=require("@number-flow/react"),tt=require("../Badge/Badge.cjs");function rt(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const h=rt(C),Q={primary:{range:"bg-primary",thumb:"border-primary/50",labelBg:"bg-primary",labelText:"text-primary-foreground"},secondary:{range:"bg-secondary",thumb:"border-secondary/50",labelBg:"bg-secondary",labelText:"text-secondary-foreground"},success:{range:"bg-success",thumb:"border-success/50",labelBg:"bg-success",labelText:"text-success-foreground"},warning:{range:"bg-warning",thumb:"border-warning/50",labelBg:"bg-warning",labelText:"text-warning-foreground"},error:{range:"bg-error",thumb:"border-error/50",labelBg:"bg-error",labelText:"text-error-foreground"},glass:{range:"bg-white/30 backdrop-blur-sm",thumb:"border-white/30 backdrop-blur-sm",labelBg:"bg-white/15",labelText:"text-foreground"},muted:{range:"bg-muted-foreground",thumb:"border-muted-foreground/50",labelBg:"bg-muted",labelText:"text-muted-foreground"},accent:{range:"bg-accent",thumb:"border-accent/50",labelBg:"bg-accent",labelText:"text-accent-foreground"}},et={sm:{track:"data-[orientation=horizontal]:h-1 data-[orientation=vertical]:w-1",thumb:"size-3"},md:{track:"data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5",thumb:"size-4"},lg:{track:"data-[orientation=horizontal]:h-2 data-[orientation=vertical]:w-2",thumb:"size-5"}},U=(a,t)=>a==="horizontal"?t==="bottom"?"bottom":t==="left"?"left":t==="right"?"right":"top":t==="right"?"right":t==="top"?"top":t==="bottom"?"bottom":"left",V=(a,t)=>{const e=t==="top"?"t":t==="bottom"?"b":t==="left"?"l":"r";return{primary:`border-${e}-primary`,secondary:`border-${e}-secondary`,success:`border-${e}-success`,warning:`border-${e}-warning`,error:`border-${e}-error`,glass:`border-${e}-white/15`,muted:`border-${e}-muted`,accent:`border-${e}-accent`}[a]},at=(a,t)=>({"horizontal-top":{badge:"left-1/2 -translate-x-1/2 bottom-full -translate-y-1/2",arrow:"top-full left-1/2 -translate-x-1/2 border-t-[6px] border-l-[6px] border-r-[6px] border-b-0 border-l-transparent border-r-transparent"},"horizontal-bottom":{badge:"left-1/2 -translate-x-1/2 top-full translate-y-1/2",arrow:"bottom-full left-1/2 -translate-x-1/2 border-b-[6px] border-l-[6px] border-r-[6px] border-t-0 border-l-transparent border-r-transparent"},"horizontal-left":{badge:"top-1/2 -translate-y-1/2 right-full -translate-x-1/2",arrow:"left-full top-1/2 -translate-y-1/2 border-l-[6px] border-t-[6px] border-b-[6px] border-r-0 border-t-transparent border-b-transparent"},"horizontal-right":{badge:"top-1/2 -translate-y-1/2 left-full translate-x-1/2",arrow:"right-full top-1/2 -translate-y-1/2 border-r-[6px] border-t-[6px] border-b-[6px] border-l-0 border-t-transparent border-b-transparent"},"vertical-left":{badge:"top-1/2 -translate-y-1/2 right-full -translate-x-1/2",arrow:"left-full top-1/2 -translate-y-1/2 border-l-[6px] border-t-[6px] border-b-[6px] border-r-0 border-t-transparent border-b-transparent"},"vertical-right":{badge:"top-1/2 -translate-y-1/2 left-full translate-x-1/2",arrow:"right-full top-1/2 -translate-y-1/2 border-r-[6px] border-t-[6px] border-b-[6px] border-l-0 border-t-transparent border-b-transparent"},"vertical-top":{badge:"left-1/2 -translate-x-1/2 bottom-full -translate-y-1/2",arrow:"top-full left-1/2 -translate-x-1/2 border-t-[6px] border-l-[6px] border-r-[6px] border-b-0 border-l-transparent border-r-transparent"},"vertical-bottom":{badge:"left-1/2 -translate-x-1/2 top-full translate-y-1/2",arrow:"bottom-full left-1/2 -translate-x-1/2 border-b-[6px] border-l-[6px] border-r-[6px] border-t-0 border-l-transparent border-r-transparent"}})[`${a}-${t}`],ot=(a,t)=>({"horizontal-top":"data-[orientation=horizontal]:bottom-full data-[orientation=horizontal]:left-1/2 data-[orientation=horizontal]:-translate-x-1/2 data-[orientation=horizontal]:-translate-y-1/2","horizontal-bottom":"data-[orientation=horizontal]:top-full data-[orientation=horizontal]:left-1/2 data-[orientation=horizontal]:-translate-x-1/2 data-[orientation=horizontal]:translate-y-1/2","horizontal-left":"data-[orientation=horizontal]:top-1/2 data-[orientation=horizontal]:right-full data-[orientation=horizontal]:-translate-y-1/2 data-[orientation=horizontal]:-translate-x-1/2","horizontal-right":"data-[orientation=horizontal]:top-1/2 data-[orientation=horizontal]:left-full data-[orientation=horizontal]:-translate-y-1/2 data-[orientation=horizontal]:translate-x-1/2","vertical-left":"data-[orientation=vertical]:right-full data-[orientation=vertical]:top-1/2 data-[orientation=vertical]:-translate-x-1/2 data-[orientation=vertical]:-translate-y-1/2","vertical-right":"data-[orientation=vertical]:left-full data-[orientation=vertical]:top-1/2 data-[orientation=vertical]:translate-x-1/2 data-[orientation=vertical]:-translate-y-1/2","vertical-top":"data-[orientation=vertical]:bottom-full data-[orientation=vertical]:left-1/2 data-[orientation=vertical]:-translate-x-1/2 data-[orientation=vertical]:-translate-y-1/2","vertical-bottom":"data-[orientation=vertical]:top-full data-[orientation=vertical]:left-1/2 data-[orientation=vertical]:-translate-x-1/2 data-[orientation=vertical]:translate-y-1/2"})[`${a}-${t}`],W=n.forwardRef(({className:a,color:t="primary",size:e="md",showLabel:i=!1,labelArrow:S=!1,labelAnimation:m="none",labelFormatter:q=c=>`${c}`,labelPosition:b="top",labelColor:d,labelTextColor:l,labelArrowColor:N,sliderColor:O,thumbBorderColor:R,defaultValue:f,value:g,min:z=0,max:j=100,..._},A)=>{const c=n.useMemo(()=>Array.isArray(g)?g:Array.isArray(f)?f:[z,j],[g,f,z,j]),[P,E]=n.useState(!1);n.useEffect(()=>{g!==void 0&&!Array.isArray(g)&&console.error("[Slider] value prop must be an array of numbers, e.g., [50] or [25, 75]"),f!==void 0&&!Array.isArray(f)&&console.error("[Slider] defaultValue prop must be an array of numbers, e.g., [50] or [25, 75]")},[g,f]);const u=_.orientation||"horizontal",I=w.useMotionValue(0),D=w.useMotionValue(0),F=n.useRef(0),G={stiffness:150,damping:15,mass:1},x=w.useSpring(0,G),y=w.useSpring(0,G);n.useEffect(()=>{if(m==="spec"&&c.length>0){const r=c[0],p=r-F.current,v=5,T=Math.max(-v,Math.min(v,p));D.set(T),I.set(r);const Y=-T*12,L=-T*20;x.set(Y),y.set(L),setTimeout(()=>{x.set(0),y.set(0)},100),F.current=r}},[c,m,D,I,x,y]);const k=n.useMemo(()=>{if(O||R)return{range:O||"bg-primary",thumb:R||"border-primary/50"};const r=Q[t];return{range:r.range,thumb:r.thumb}},[t,O,R]),M=n.useMemo(()=>et[e],[e]),H=n.useMemo(()=>{if(d||l)return s.cn(d,l);const r=Q[t],p=U(u,b),v=V(t,p);return t==="glass"?`${r.labelBg} ${r.labelText} backdrop-blur-sm shadow-lg [&>div.arrow]:${v}`:`${r.labelBg} ${r.labelText} [&>div.arrow]:${v}`},[t,b,u,d,l]),B=n.useMemo(()=>{if(N)return N;const r=U(u,b);return V(t,r)},[t,b,u,N]),Z=n.useMemo(()=>i==="hover"?"scale-0 group-hover:scale-100":i==="always"?"scale-100":"hidden",[i]),$=n.useMemo(()=>at(u,b),[b,u]),J=n.useMemo(()=>ot(u,b),[b,u]),X=n.useCallback(r=>m==="spec"?o.jsxs(w.motion.div,{className:s.cn("ds:pointer-events-none ds:absolute ds:z-50 ds:flex ds:flex-col ds:items-center ds:justify-center ds:rounded-md ds:px-3 ds:py-1.5 ds:text-xs ds:shadow-xl",J,d&&d,l&&l,!d&&!l&&H),"data-orientation":u,initial:i==="always"?{opacity:1,y:-5,scale:1}:{opacity:0,y:20,scale:0},animate:P&&i==="hover"||i==="always"?{opacity:1,y:-5,scale:1}:{opacity:0,y:20,scale:0},transition:{type:"tween",duration:.2,ease:"easeOut"},style:{x,rotate:y,whiteSpace:"nowrap"},children:[o.jsx("div",{className:"ds:relative ds:z-1",children:o.jsx(K,{value:c[r],format:{notation:"standard"},isolate:!0})}),S&&o.jsx("div",{className:s.cn("ds:arrow ds:absolute ds:border-transparent",$.arrow,B)})]}):o.jsxs(tt.default,{size:"lg",color:d||l||t==="glass"?"custom":t==="muted"?"muted":t==="accent"?"accent":t,variant:"solid",className:s.cn("ds:transition-transform ds:absolute ds:px-3 ds:rounded-md",$.badge,Z,d&&d,l&&l,!d&&!l&&t==="glass"&&"ds:bg-white/15 ds:text-foreground ds:backdrop-blur-sm ds:shadow-lg ds:[&>div.arrow]:border-t-white/15"),children:[m==="number-flow"?o.jsx(K,{value:c[r],format:{notation:"standard"},isolate:!0}):o.jsx("span",{children:q(c[r])}),S&&o.jsx("div",{className:s.cn("ds:arrow ds:absolute ds:border-transparent",$.arrow,B)})]}),[m,J,d,l,H,u,i,x,y,q,c,t,$,Z,S,B,P]);return i?o.jsxs(h.Root,{ref:A,"data-slot":"slider",defaultValue:f,value:g,min:z,max:j,className:s.cn("ds:relative ds:flex ds:w-full ds:touch-none ds:items-center ds:select-none ds:data-disabled:opacity-50 ds:data-[orientation=vertical]:h-full ds:data-[orientation=vertical]:min-h-44 ds:data-[orientation=vertical]:w-auto ds:data-[orientation=vertical]:flex-col",a),..._,children:[o.jsx(h.Track,{"data-slot":"slider-track",className:s.cn("ds:bg-muted ds:relative ds:grow ds:overflow-hidden ds:rounded-full ds:data-[orientation=horizontal]:w-full ds:data-[orientation=vertical]:h-full",M.track),children:o.jsx(h.Range,{"data-slot":"slider-range",className:s.cn("ds:absolute ds:data-[orientation=horizontal]:h-full ds:data-[orientation=vertical]:w-full",k.range)})}),Array.from({length:c.length},(r,p)=>o.jsx(h.Thumb,{"data-slot":"slider-thumb",className:s.cn("ds:group ds:block ds:shrink-0 ds:rounded-full ds:border ds:bg-white ds:shadow-sm ds:transition-[color,box-shadow] ds:hover:ring-4 ds:focus-visible:ring-4 ds:focus-visible:outline-hidden ds:disabled:pointer-events-none ds:disabled:opacity-50 ds:ring-ring/50",k.thumb,M.thumb),onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),children:X(p)},p))]}):o.jsxs(h.Root,{ref:A,"data-slot":"slider",defaultValue:f,value:g,min:z,max:j,className:s.cn("ds:relative ds:flex ds:w-full ds:touch-none ds:items-center ds:select-none ds:data-disabled:opacity-50 ds:data-[orientation=vertical]:h-full ds:data-[orientation=vertical]:min-h-44 ds:data-[orientation=vertical]:w-auto ds:data-[orientation=vertical]:flex-col",a),..._,children:[o.jsx(h.Track,{"data-slot":"slider-track",className:s.cn("ds:bg-muted ds:relative ds:grow ds:overflow-hidden ds:rounded-full ds:data-[orientation=horizontal]:w-full ds:data-[orientation=vertical]:h-full",M.track),children:o.jsx(h.Range,{"data-slot":"slider-range",className:s.cn("ds:absolute ds:data-[orientation=horizontal]:h-full ds:data-[orientation=vertical]:w-full",k.range)})}),Array.from({length:c.length},(r,p)=>o.jsx(h.Thumb,{"data-slot":"slider-thumb",className:s.cn("ds:block ds:shrink-0 ds:rounded-full ds:border ds:bg-white ds:shadow-sm ds:transition-[color,box-shadow] ds:hover:ring-4 ds:focus-visible:ring-4 ds:focus-visible:outline-hidden ds:disabled:pointer-events-none ds:disabled:opacity-50 ds:ring-ring/50",k.thumb,M.thumb)},p))]})});W.displayName="Slider";exports.default=W;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),d=require("react"),C=require("@radix-ui/react-slider"),o=require("../../packages/ui/src/lib/utils.cjs"),w=require("motion/react"),K=require("@number-flow/react"),tt=require("../Badge/Badge.cjs");function rt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const h=rt(C),Q={primary:{range:"ds:bg-primary",thumb:"ds:border-primary/50",labelBg:"ds:bg-primary",labelText:"ds:text-primary-foreground"},secondary:{range:"ds:bg-secondary",thumb:"ds:border-secondary/50",labelBg:"ds:bg-secondary",labelText:"ds:text-secondary-foreground"},success:{range:"ds:bg-success",thumb:"ds:border-success/50",labelBg:"ds:bg-success",labelText:"ds:text-success-foreground"},warning:{range:"ds:bg-warning",thumb:"ds:border-warning/50",labelBg:"ds:bg-warning",labelText:"ds:text-warning-foreground"},error:{range:"ds:bg-error",thumb:"ds:border-error/50",labelBg:"ds:bg-error",labelText:"ds:text-error-foreground"},glass:{range:"ds:bg-white/30 backdrop-blur-sm",thumb:"ds:border-white/30 backdrop-blur-sm",labelBg:"ds:bg-white/15",labelText:"ds:text-foreground"},muted:{range:"ds:bg-muted-foreground",thumb:"ds:border-muted-foreground/50",labelBg:"ds:bg-muted",labelText:"ds:text-muted-foreground"},accent:{range:"ds:bg-accent",thumb:"ds:border-accent/50",labelBg:"ds:bg-accent",labelText:"ds:text-accent-foreground"}},st={sm:{track:"ds:data-[orientation=horizontal]:h-1 ds:data-[orientation=vertical]:w-1",thumb:"ds:size-3"},md:{track:"ds:data-[orientation=horizontal]:h-1.5 ds:data-[orientation=vertical]:w-1.5",thumb:"ds:size-4"},lg:{track:"ds:data-[orientation=horizontal]:h-2 ds:data-[orientation=vertical]:w-2",thumb:"ds:size-5"}},U=(e,t)=>e==="horizontal"?t==="bottom"?"bottom":t==="left"?"left":t==="right"?"right":"top":t==="right"?"right":t==="top"?"top":t==="bottom"?"bottom":"left",V=(e,t)=>{const s=t==="top"?"t":t==="bottom"?"b":t==="left"?"l":"r";return{primary:`ds:border-${s}-primary`,secondary:`ds:border-${s}-secondary`,success:`ds:border-${s}-success`,warning:`ds:border-${s}-warning`,error:`ds:border-${s}-error`,glass:`ds:border-${s}-white/15`,muted:`ds:border-${s}-muted`,accent:`ds:border-${s}-accent`}[e]},et=(e,t)=>({"horizontal-top":{badge:"ds:left-1/2 ds:-translate-x-1/2 ds:bottom-full ds:-translate-y-1/2",arrow:"ds:top-full left-1/2 ds:-translate-x-1/2 ds:border-t-[6px] ds:border-l-[6px] ds:border-r-[6px] ds:border-b-0 ds:border-l-transparent ds:border-r-transparent"},"horizontal-bottom":{badge:"ds:left-1/2 ds:-translate-x-1/2 ds:top-full ds:translate-y-1/2",arrow:"ds:bottom-full left-1/2 ds:-translate-x-1/2 ds:border-b-[6px] ds:border-l-[6px] ds:border-r-[6px] ds:border-t-0 ds:border-l-transparent ds:border-r-transparent"},"horizontal-left":{badge:"ds:top-1/2 ds:-translate-y-1/2 ds:right-full ds:-translate-x-1/2",arrow:"ds:left-full ds:top-1/2 ds:-translate-y-1/2 ds:border-l-[6px] ds:border-t-[6px] ds:border-b-[6px] ds:border-r-0 ds:border-t-transparent ds:border-b-transparent"},"horizontal-right":{badge:"ds:top-1/2 ds:-translate-y-1/2 ds:left-full ds:translate-x-1/2",arrow:"ds:right-full ds:top-1/2 ds:-translate-y-1/2 ds:border-r-[6px] ds:border-t-[6px] ds:border-b-[6px] ds:border-l-0 ds:border-t-transparent ds:border-b-transparent"},"vertical-left":{badge:"ds:top-1/2 ds:-translate-y-1/2 ds:right-full ds:-translate-x-1/2",arrow:"ds:left-full ds:top-1/2 ds:-translate-y-1/2 ds:border-l-[6px] ds:border-t-[6px] ds:border-b-[6px] ds:border-r-0 ds:border-t-transparent ds:border-b-transparent"},"vertical-right":{badge:"ds:top-1/2 ds:-translate-y-1/2 ds:left-full ds:translate-x-1/2",arrow:"ds:right-full ds:top-1/2 ds:-translate-y-1/2 ds:border-r-[6px] ds:border-t-[6px] ds:border-b-[6px] ds:border-l-0 ds:border-t-transparent ds:border-b-transparent"},"vertical-top":{badge:"ds:left-1/2 ds:-translate-x-1/2 ds:bottom-full ds:-translate-y-1/2",arrow:"ds:top-full ds:left-1/2 ds:-translate-x-1/2 ds:border-t-[6px] ds:border-l-[6px] ds:border-r-[6px] ds:border-b-0 ds:border-l-transparent ds:border-r-transparent"},"vertical-bottom":{badge:"ds:left-1/2 ds:-translate-x-1/2 ds:top-full ds:translate-y-1/2",arrow:"ds:bottom-full ds:left-1/2 ds:-translate-x-1/2 ds:border-b-[6px] ds:border-l-[6px] ds:border-r-[6px] ds:border-t-0 ds:border-l-transparent ds:border-r-transparent"}})[`${e}-${t}`],at=(e,t)=>({"horizontal-top":"ds:data-[orientation=horizontal]:bottom-full ds:data-[orientation=horizontal]:left-1/2 ds:data-[orientation=horizontal]:-translate-x-1/2 ds:data-[orientation=horizontal]:-translate-y-1/2","horizontal-bottom":"ds:data-[orientation=horizontal]:top-full ds:data-[orientation=horizontal]:left-1/2 ds:data-[orientation=horizontal]:-translate-x-1/2 ds:data-[orientation=horizontal]:translate-y-1/2","horizontal-left":"ds:data-[orientation=horizontal]:top-1/2 ds:data-[orientation=horizontal]:right-full ds:data-[orientation=horizontal]:-translate-y-1/2 ds:data-[orientation=horizontal]:-translate-x-1/2","horizontal-right":"ds:data-[orientation=horizontal]:top-1/2 ds:data-[orientation=horizontal]:left-full ds:data-[orientation=horizontal]:-translate-y-1/2 ds:data-[orientation=horizontal]:translate-x-1/2","vertical-left":"ds:data-[orientation=vertical]:right-full ds:data-[orientation=vertical]:top-1/2 ds:data-[orientation=vertical]:-translate-x-1/2 ds:data-[orientation=vertical]:-translate-y-1/2","vertical-right":"ds:data-[orientation=vertical]:left-full ds:data-[orientation=vertical]:top-1/2 ds:data-[orientation=vertical]:translate-x-1/2 ds:data-[orientation=vertical]:-translate-y-1/2","vertical-top":"ds:data-[orientation=vertical]:bottom-full ds:data-[orientation=vertical]:left-1/2 ds:data-[orientation=vertical]:-translate-x-1/2 ds:data-[orientation=vertical]:-translate-y-1/2","vertical-bottom":"ds:data-[orientation=vertical]:top-full ds:data-[orientation=vertical]:left-1/2 ds:data-[orientation=vertical]:-translate-x-1/2 ds:data-[orientation=vertical]:translate-y-1/2"})[`${e}-${t}`],W=d.forwardRef(({className:e,color:t="primary",size:s="md",showLabel:n=!1,labelArrow:S=!1,labelAnimation:m="none",labelFormatter:q=c=>`${c}`,labelPosition:b="top",labelColor:i,labelTextColor:l,labelArrowColor:N,sliderColor:O,thumbBorderColor:R,defaultValue:f,value:g,min:z=0,max:j=100,..._},A)=>{const c=d.useMemo(()=>Array.isArray(g)?g:Array.isArray(f)?f:[z,j],[g,f,z,j]),[P,E]=d.useState(!1);d.useEffect(()=>{g!==void 0&&!Array.isArray(g)&&console.error("[Slider] value prop must be an array of numbers, e.g., [50] or [25, 75]"),f!==void 0&&!Array.isArray(f)&&console.error("[Slider] defaultValue prop must be an array of numbers, e.g., [50] or [25, 75]")},[g,f]);const u=_.orientation||"horizontal",I=w.useMotionValue(0),D=w.useMotionValue(0),F=d.useRef(0),G={stiffness:150,damping:15,mass:1},x=w.useSpring(0,G),y=w.useSpring(0,G);d.useEffect(()=>{if(m==="spec"&&c.length>0){const r=c[0],p=r-F.current,v=5,T=Math.max(-v,Math.min(v,p));D.set(T),I.set(r);const Y=-T*12,L=-T*20;x.set(Y),y.set(L),setTimeout(()=>{x.set(0),y.set(0)},100),F.current=r}},[c,m,D,I,x,y]);const k=d.useMemo(()=>{if(O||R)return{range:O||"ds:bg-primary",thumb:R||"ds:border-primary/50"};const r=Q[t];return{range:r.range,thumb:r.thumb}},[t,O,R]),M=d.useMemo(()=>st[s],[s]),H=d.useMemo(()=>{if(i||l)return o.cn(i,l);const r=Q[t],p=U(u,b),v=V(t,p);return t==="glass"?`${r.labelBg} ${r.labelText} ds:backdrop-blur-sm ds:shadow-lg ds:[&>div.arrow]:${v}`:`${r.labelBg} ${r.labelText} ds:[&>div.arrow]:${v}`},[t,b,u,i,l]),B=d.useMemo(()=>{if(N)return N;const r=U(u,b);return V(t,r)},[t,b,u,N]),Z=d.useMemo(()=>n==="hover"?"ds:scale-0 ds:group-hover:scale-100":n==="always"?"ds:scale-100":"ds:hidden",[n]),$=d.useMemo(()=>et(u,b),[b,u]),J=d.useMemo(()=>at(u,b),[b,u]),X=d.useCallback(r=>m==="spec"?a.jsxs(w.motion.div,{className:o.cn("ds:pointer-events-none ds:absolute ds:z-50 ds:flex ds:flex-col ds:items-center ds:justify-center ds:rounded-md ds:px-3 ds:py-1.5 ds:text-xs ds:shadow-xl",J,i&&i,l&&l,!i&&!l&&H),"data-orientation":u,initial:n==="always"?{opacity:1,y:-5,scale:1}:{opacity:0,y:20,scale:0},animate:P&&n==="hover"||n==="always"?{opacity:1,y:-5,scale:1}:{opacity:0,y:20,scale:0},transition:{type:"tween",duration:.2,ease:"easeOut"},style:{x,rotate:y,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"ds:relative ds:z-1",children:a.jsx(K,{value:c[r],format:{notation:"standard"},isolate:!0})}),S&&a.jsx("div",{className:o.cn("ds:arrow ds:absolute ds:border-transparent",$.arrow,B)})]}):a.jsxs(tt.default,{size:"lg",color:i||l||t==="glass"?"custom":t==="muted"?"muted":t==="accent"?"accent":t,variant:"solid",className:o.cn("ds:transition-transform ds:absolute ds:px-3 ds:rounded-md",$.badge,Z,i&&i,l&&l,!i&&!l&&t==="glass"&&"ds:bg-white/15 ds:text-foreground ds:backdrop-blur-sm ds:shadow-lg ds:[&>div.arrow]:border-t-white/15"),children:[m==="number-flow"?a.jsx(K,{value:c[r],format:{notation:"standard"},isolate:!0}):a.jsx("span",{children:q(c[r])}),S&&a.jsx("div",{className:o.cn("ds:arrow ds:absolute ds:border-transparent",$.arrow,B)})]}),[m,J,i,l,H,u,n,x,y,q,c,t,$,Z,S,B,P]);return n?a.jsxs(h.Root,{ref:A,"data-slot":"slider",defaultValue:f,value:g,min:z,max:j,className:o.cn("ds:relative ds:flex ds:w-full ds:touch-none ds:items-center ds:select-none ds:data-disabled:opacity-50 ds:data-[orientation=vertical]:h-full ds:data-[orientation=vertical]:min-h-44 ds:data-[orientation=vertical]:w-auto ds:data-[orientation=vertical]:flex-col",e),..._,children:[a.jsx(h.Track,{"data-slot":"slider-track",className:o.cn("ds:bg-muted ds:relative ds:grow ds:overflow-hidden ds:rounded-full ds:data-[orientation=horizontal]:w-full ds:data-[orientation=vertical]:h-full",M.track),children:a.jsx(h.Range,{"data-slot":"slider-range",className:o.cn("ds:absolute ds:data-[orientation=horizontal]:h-full ds:data-[orientation=vertical]:w-full",k.range)})}),Array.from({length:c.length},(r,p)=>a.jsx(h.Thumb,{"data-slot":"slider-thumb",className:o.cn("ds:group ds:block ds:shrink-0 ds:rounded-full ds:border ds:bg-white ds:shadow-sm ds:transition-[color,box-shadow] ds:hover:ring-4 ds:focus-visible:ring-4 ds:focus-visible:outline-hidden ds:disabled:pointer-events-none ds:disabled:opacity-50 ds:ring-ring/50",k.thumb,M.thumb),onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),children:X(p)},p))]}):a.jsxs(h.Root,{ref:A,"data-slot":"slider",defaultValue:f,value:g,min:z,max:j,className:o.cn("ds:relative ds:flex ds:w-full ds:touch-none ds:items-center ds:select-none ds:data-disabled:opacity-50 ds:data-[orientation=vertical]:h-full ds:data-[orientation=vertical]:min-h-44 ds:data-[orientation=vertical]:w-auto ds:data-[orientation=vertical]:flex-col",e),..._,children:[a.jsx(h.Track,{"data-slot":"slider-track",className:o.cn("ds:bg-muted ds:relative ds:grow ds:overflow-hidden ds:rounded-full ds:data-[orientation=horizontal]:w-full ds:data-[orientation=vertical]:h-full",M.track),children:a.jsx(h.Range,{"data-slot":"slider-range",className:o.cn("ds:absolute ds:data-[orientation=horizontal]:h-full ds:data-[orientation=vertical]:w-full",k.range)})}),Array.from({length:c.length},(r,p)=>a.jsx(h.Thumb,{"data-slot":"slider-thumb",className:o.cn("ds:block ds:shrink-0 ds:rounded-full ds:border ds:bg-white ds:shadow-sm ds:transition-[color,box-shadow] ds:hover:ring-4 ds:focus-visible:ring-4 ds:focus-visible:outline-hidden ds:disabled:pointer-events-none ds:disabled:opacity-50 ds:ring-ring/50",k.thumb,M.thumb)},p))]})});W.displayName="Slider";exports.default=W;
2
2
  //# sourceMappingURL=Slider.cjs.map