@protonradio/proton-ui 0.12.0 → 0.12.2

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 (42) hide show
  1. package/dist/components/ButtonGroup/ButtonGroup.cjs.js +1 -1
  2. package/dist/components/ButtonGroup/ButtonGroup.cjs.js.map +1 -1
  3. package/dist/components/ButtonGroup/ButtonGroup.es.js +30 -16
  4. package/dist/components/ButtonGroup/ButtonGroup.es.js.map +1 -1
  5. package/dist/components/Checkbox/CheckboxInput/CheckboxInput.cjs.js +1 -1
  6. package/dist/components/Checkbox/CheckboxInput/CheckboxInput.cjs.js.map +1 -1
  7. package/dist/components/Checkbox/CheckboxInput/CheckboxInput.es.js +48 -48
  8. package/dist/components/Checkbox/CheckboxInput/CheckboxInput.es.js.map +1 -1
  9. package/dist/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.cjs.js +1 -1
  10. package/dist/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.cjs.js.map +1 -1
  11. package/dist/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.es.js +43 -43
  12. package/dist/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.es.js.map +1 -1
  13. package/dist/components/Input/BaseInput/Input.cjs.js +1 -1
  14. package/dist/components/Input/BaseInput/Input.cjs.js.map +1 -1
  15. package/dist/components/Input/BaseInput/Input.es.js +62 -62
  16. package/dist/components/Input/BaseInput/Input.es.js.map +1 -1
  17. package/dist/components/Popover/Popover.cjs.js.map +1 -1
  18. package/dist/components/Popover/Popover.es.js.map +1 -1
  19. package/dist/components/Select/Select.cjs.js +1 -1
  20. package/dist/components/Select/Select.cjs.js.map +1 -1
  21. package/dist/components/Select/Select.es.js +40 -29
  22. package/dist/components/Select/Select.es.js.map +1 -1
  23. package/dist/components/Switch/Switch.cjs.js +1 -1
  24. package/dist/components/Switch/Switch.cjs.js.map +1 -1
  25. package/dist/components/Switch/Switch.es.js +27 -26
  26. package/dist/components/Switch/Switch.es.js.map +1 -1
  27. package/dist/components/Table/DataTable/DataTable.cjs.js +1 -1
  28. package/dist/components/Table/DataTable/DataTable.cjs.js.map +1 -1
  29. package/dist/components/Table/DataTable/DataTable.es.js +6 -6
  30. package/dist/components/Table/DataTable/DataTable.es.js.map +1 -1
  31. package/dist/components/Tooltip/ResponsiveTooltip.cjs.js.map +1 -1
  32. package/dist/components/Tooltip/ResponsiveTooltip.es.js.map +1 -1
  33. package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
  34. package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
  35. package/dist/constants.d.ts +6 -0
  36. package/dist/design/darkTheme/colors.cjs.js +1 -1
  37. package/dist/design/darkTheme/colors.cjs.js.map +1 -1
  38. package/dist/design/darkTheme/colors.es.js +14 -14
  39. package/dist/design/darkTheme/colors.es.js.map +1 -1
  40. package/dist/index.d.ts +20 -14
  41. package/dist/style.css +1 -1
  42. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxRadioGroup.es.js","sources":["../../../../src/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, ReactNode } from \"react\";\nimport { RadioGroup as RadixRadioGroup } from \"radix-ui\";\nimport { CheckboxIndicator } from \"../CheckboxIndicator\";\n\nimport { csx } from \"../../../utils\";\nimport \"../CheckboxInput/CheckboxInput.css\";\nimport \"./CheckboxRadioGroup.css\";\n\nexport interface CheckboxRadioGroupItem {\n /**\n * Unique value for the radio option.\n */\n value: string;\n\n /**\n * Label displayed next to the radio button.\n */\n label: string | ReactNode;\n\n /**\n * Optional description text below the label.\n */\n description?: string | ReactNode;\n\n /**\n * Whether this specific option is disabled.\n * @default false\n */\n isDisabled?: boolean;\n}\n\nexport interface CheckboxRadioGroupProps {\n /**\n * The name attribute for the radio group (for form submission).\n */\n name: string;\n\n /**\n * Array of radio options.\n */\n items: CheckboxRadioGroupItem[];\n\n /**\n * Currently selected value (controlled mode).\n */\n value?: string;\n\n /**\n * Default selected value (uncontrolled mode).\n */\n defaultValue?: string;\n\n /**\n * Callback when selection changes.\n */\n onChange?: (value: string) => void;\n\n /**\n * Whether the entire group is disabled.\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Whether selection is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Error message or element.\n */\n error?: ReactNode | string;\n\n /**\n * Layout orientation.\n * @default \"vertical\"\n */\n orientation?: \"vertical\" | \"horizontal\";\n\n /**\n * Whether radio buttons are round or square.\n * @default false\n */\n round?: boolean;\n\n /**\n * Test ID for the group.\n */\n \"data-testid\"?: string;\n}\n\n/**\n * A declaritive radio group for single-select lists.\n *\n * API:\n * - {@link CheckboxRadioGroupProps}\n * - {@link CheckboxRadioGroupItem}\n */\nexport const CheckboxRadioGroup = forwardRef<\n HTMLDivElement,\n CheckboxRadioGroupProps\n>(\n (\n {\n name,\n items,\n value,\n defaultValue,\n onChange,\n isDisabled = false,\n isRequired = false,\n orientation = \"vertical\",\n round = false,\n error,\n \"data-testid\": testId,\n },\n ref,\n ) => {\n const errorId = typeof error === \"string\" ? `${name}-error` : undefined;\n\n return (\n <div>\n <RadixRadioGroup.Root\n ref={ref}\n name={name}\n value={value}\n defaultValue={defaultValue}\n onValueChange={onChange}\n disabled={isDisabled}\n required={isRequired}\n orientation={orientation}\n className={csx(\n \"proton-CheckboxRadioGroup\",\n `proton-CheckboxRadioGroup--${orientation}`,\n )}\n aria-invalid={Boolean(error)}\n aria-errormessage={errorId}\n data-testid={testId}\n >\n {items.map((item) => {\n const itemId = `${name}-${item.value}`;\n const itemDisabled = isDisabled || item.isDisabled;\n const descriptionId =\n typeof item.description === \"string\"\n ? `${itemId}-description`\n : undefined;\n\n return (\n <div\n key={item.value}\n className={csx(\n itemDisabled && \"proton-CheckboxInput--disabled\",\n )}\n >\n <div\n className={csx(\n \"proton-CheckboxInput__container\",\n round && \"proton-CheckboxInput__container--round\",\n )}\n >\n <RadixRadioGroup.Item\n id={itemId}\n value={item.value}\n disabled={item.isDisabled}\n className={csx(\n \"proton-CheckboxInput__input\",\n round && \"proton-CheckboxInput__input--round\",\n error && \"proton-CheckboxInput__input--error\",\n )}\n aria-describedby={descriptionId}\n >\n <RadixRadioGroup.Indicator\n className={csx(\n !round && \"proton-CheckboxRadioGroup__checkmark\",\n )}\n forceMount\n >\n <CheckboxIndicator round={round} />\n </RadixRadioGroup.Indicator>\n </RadixRadioGroup.Item>\n\n {typeof item.label === \"string\" ? (\n <label\n htmlFor={itemId}\n className=\"proton-CheckboxInput__label\"\n >\n {item.label}\n </label>\n ) : (\n item.label\n )}\n </div>\n\n {typeof item.description === \"string\" ? (\n <div\n id={descriptionId}\n className=\"proton-CheckboxRadioGroup__description\"\n >\n {item.description}\n </div>\n ) : (\n item.description\n )}\n </div>\n );\n })}\n </RadixRadioGroup.Root>\n\n {typeof error === \"string\" ? (\n <div\n role=\"alert\"\n className=\"proton-CheckboxInput__error\"\n id={errorId}\n >\n {error}\n </div>\n ) : (\n error\n )}\n </div>\n );\n },\n);\n\nCheckboxRadioGroup.displayName = \"ProtonUICheckboxRadioGroup\";\n"],"names":["CheckboxRadioGroup","forwardRef","name","items","value","defaultValue","onChange","isDisabled","isRequired","orientation","round","error","testId","ref","errorId","jsx","RadixRadioGroup","csx","item","itemId","itemDisabled","descriptionId","jsxs","CheckboxIndicator"],"mappings":";;;;;;;AAqGO,MAAMA,IAAqBC;AAAA,EAIhC,CACE;AAAA,IACE,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,OAAAC;AAAA,IACA,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,YAAAC,IAAa;AAAA,IACb,aAAAC,IAAc;AAAA,IACd,OAAAC,IAAQ;AAAA,IACR,OAAAC;AAAA,IACA,eAAeC;AAAA,EAAA,GAEjBC,MACG;AACH,UAAMC,IAAU,OAAOH,KAAU,WAAW,GAAGT,CAAI,WAAW;AAE9D,kCACG,O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BAAAA,EAAAA,IAACQ,KAAkB,OAAAb,EAAA,CAAc;AAAA,8BAAA;AAAA,4BAAA;AAAA,0BACnC;AAAA,wBAAA;AAAA,wBAGD,OAAOQ,EAAK,SAAU,WACrBH,gBAAAA,EAAAA;AAAAA,0BAAC;AAAA,0BAAA;AAAA,4BACC,SAASI;AAAA,4BACT,WAAU;AAAA,4BAET,UAAAD,EAAK;AAAA,0BAAA;AAAA,wBAAA,IAGRA,EAAK;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBAAA;AAAA,kBAIR,OAAOA,EAAK,eAAgB,WAC3BH,gBAAAA,EAAAA;AAAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,IAAIM;AAAA,sBACJ,WAAU;AAAA,sBAET,UAAAH,EAAK;AAAA,oBAAA;AAAA,kBAAA,IAGRA,EAAK;AAAA,gBAAA;AAAA,cAAA;AAAA,cApDFA,EAAK;AAAA,YAAA;AAAA,UAwDhB,CAAC;AAAA,QAAA;AAAA,MAAA;AAAA,MAGF,OAAOP,KAAU,WAChBI,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,IAAID;AAAA,UAEH,UAAAH;AAAA,QAAA;AAAA,MAAA,IAGHA;AAAA,IAAA,GAEJ;AAAA,EAEJ;AACF;AAEAX,EAAmB,cAAc;"}
1
+ {"version":3,"file":"CheckboxRadioGroup.es.js","sources":["../../../../src/components/Checkbox/CheckboxRadioGroup/CheckboxRadioGroup.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, type ReactNode, useId } from \"react\";\nimport { RadioGroup as RadixRadioGroup } from \"radix-ui\";\nimport { CheckboxIndicator } from \"../CheckboxIndicator\";\n\nimport { csx } from \"../../../utils\";\nimport \"../CheckboxInput/CheckboxInput.css\";\nimport \"./CheckboxRadioGroup.css\";\n\nexport interface CheckboxRadioGroupItem {\n /**\n * Unique value for the radio option.\n */\n value: string;\n\n /**\n * Label displayed next to the radio button.\n */\n label: string | ReactNode;\n\n /**\n * Optional description text below the label.\n */\n description?: string | ReactNode;\n\n /**\n * Whether this specific option is disabled.\n * @default false\n */\n isDisabled?: boolean;\n}\n\nexport interface CheckboxRadioGroupProps {\n /**\n * The name attribute for the radio group (for form submission).\n */\n name: string;\n\n /**\n * Array of radio options.\n */\n items: CheckboxRadioGroupItem[];\n\n /**\n * Currently selected value (controlled mode).\n */\n value?: string;\n\n /**\n * Default selected value (uncontrolled mode).\n */\n defaultValue?: string;\n\n /**\n * Callback when selection changes.\n */\n onChange?: (value: string) => void;\n\n /**\n * Whether the entire group is disabled.\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Whether selection is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Error message or element.\n */\n error?: ReactNode | string;\n\n /**\n * Layout orientation.\n * @default \"vertical\"\n */\n orientation?: \"vertical\" | \"horizontal\";\n\n /**\n * Whether radio buttons are round or square.\n * @default false\n */\n round?: boolean;\n\n /**\n * Test ID for the group.\n */\n \"data-testid\"?: string;\n}\n\n/**\n * A declaritive radio group for single-select lists.\n *\n * API:\n * - {@link CheckboxRadioGroupProps}\n * - {@link CheckboxRadioGroupItem}\n */\nexport const CheckboxRadioGroup = forwardRef<\n HTMLDivElement,\n CheckboxRadioGroupProps\n>(\n (\n {\n name,\n items,\n value,\n defaultValue,\n onChange,\n isDisabled = false,\n isRequired = false,\n orientation = \"vertical\",\n round = false,\n error,\n \"data-testid\": testId,\n },\n ref,\n ) => {\n const idBase = useId();\n const errorId = typeof error === \"string\" ? `${idBase}-error` : undefined;\n\n return (\n <div>\n <RadixRadioGroup.Root\n ref={ref}\n name={name}\n value={value}\n defaultValue={defaultValue}\n onValueChange={onChange}\n disabled={isDisabled}\n required={isRequired}\n orientation={orientation}\n className={csx(\n \"proton-CheckboxRadioGroup\",\n `proton-CheckboxRadioGroup--${orientation}`,\n )}\n aria-invalid={Boolean(error)}\n aria-errormessage={errorId}\n data-testid={testId}\n >\n {items.map((item, index) => {\n const itemId = `${idBase}-item-${index}`;\n const itemDisabled = isDisabled || item.isDisabled;\n const descriptionId =\n typeof item.description === \"string\"\n ? `${itemId}-description`\n : undefined;\n\n return (\n <div\n key={item.value}\n className={csx(\n itemDisabled && \"proton-CheckboxInput--disabled\",\n )}\n >\n <div\n className={csx(\n \"proton-CheckboxInput__container\",\n round && \"proton-CheckboxInput__container--round\",\n )}\n >\n <RadixRadioGroup.Item\n id={itemId}\n value={item.value}\n disabled={item.isDisabled}\n className={csx(\n \"proton-CheckboxInput__input\",\n round && \"proton-CheckboxInput__input--round\",\n error && \"proton-CheckboxInput__input--error\",\n )}\n aria-describedby={descriptionId}\n >\n <RadixRadioGroup.Indicator\n className={csx(\n !round && \"proton-CheckboxRadioGroup__checkmark\",\n )}\n forceMount\n >\n <CheckboxIndicator round={round} />\n </RadixRadioGroup.Indicator>\n </RadixRadioGroup.Item>\n\n {typeof item.label === \"string\" ? (\n <label\n htmlFor={itemId}\n className=\"proton-CheckboxInput__label\"\n >\n {item.label}\n </label>\n ) : (\n item.label\n )}\n </div>\n\n {typeof item.description === \"string\" ? (\n <div\n id={descriptionId}\n className=\"proton-CheckboxRadioGroup__description\"\n >\n {item.description}\n </div>\n ) : (\n item.description\n )}\n </div>\n );\n })}\n </RadixRadioGroup.Root>\n\n {typeof error === \"string\" ? (\n <div\n role=\"alert\"\n className=\"proton-CheckboxInput__error\"\n id={errorId}\n >\n {error}\n </div>\n ) : (\n error\n )}\n </div>\n );\n },\n);\n\nCheckboxRadioGroup.displayName = \"ProtonUICheckboxRadioGroup\";\n"],"names":["CheckboxRadioGroup","forwardRef","name","items","value","defaultValue","onChange","isDisabled","isRequired","orientation","round","error","testId","ref","idBase","useId","errorId","jsx","RadixRadioGroup","csx","item","index","itemId","itemDisabled","descriptionId","jsxs","CheckboxIndicator"],"mappings":";;;;;;;AAqGO,MAAMA,IAAqBC;AAAA,EAIhC,CACE;AAAA,IACE,MAAAC;AAAA,IACA,OAAAC;AAAA,I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-runtime.cjs.js"),s=require("react"),D=require("../../../hooks/useMergedRef.cjs.js"),B=require("../../ThemeProvider.cjs.js");;/* empty css */const K=require("../../../utils/copy.cjs.js"),o=require("../../../utils/string.cjs.js"),P=s.forwardRef(({prefix:l,suffix:f,description:u,descriptionPosition:j="top",isDisabled:R,error:i,onChange:m,label:x,name:c,placeholder:T,type:z="text",value:y,autoFocus:F,autoComplete:k,isRequired:_=!1,isReadOnly:W=!1,onSubmit:b,onClear:E,"data-testid":A},M)=>{const N=s.useRef(null),a=s.useRef(null),p=s.useRef(null),r=s.useRef(null),{className:O}=B.useTheme(),S=D.useMergedRef(N,M);s.useEffect(()=>{if(!r.current)return;const e={containerWidth:200,prefixWidth:32,suffixWidth:32};let d=null;const w=()=>{d!==null&&cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var $,g;if(r.current){if(r.current){const t=r.current.offsetWidth||e.containerWidth;t!==e.containerWidth&&(r.current.style.setProperty("--container-width",`${t}px`),e.containerWidth=t)}if(a.current){const t=a.current.offsetWidth||e.prefixWidth;t!==e.prefixWidth&&(($=r.current)==null||$.style.setProperty("--prefix-width",`${t}px`),e.prefixWidth=t)}if(p.current){const t=p.current.offsetWidth||e.suffixWidth;t!==e.suffixWidth&&((g=r.current)==null||g.style.setProperty("--suffix-width",`${t}px`),e.suffixWidth=t)}}})};w();const h=new ResizeObserver(w);return r.current&&h.observe(r.current),a.current&&h.observe(a.current),p.current&&h.observe(p.current),()=>{d!==null&&cancelAnimationFrame(d),h.disconnect()}},[l,f]);const q=`${c}-input`,I=`${c}-error`,v=`${c}-description`;return n.jsxRuntimeExports.jsxs("div",{ref:r,className:"proton-Input__container",children:[u&&j==="top"&&n.jsxRuntimeExports.jsx("div",{id:v,className:"proton-Input__text","aria-live":"polite",children:u}),n.jsxRuntimeExports.jsxs("div",{className:o.csx("proton-Input__container-inner",l&&"proton-Input__has-prefix",f&&"proton-Input__has-suffix"),children:[l&&n.jsxRuntimeExports.jsx("div",{ref:a,className:o.csx("proton-Input__descriptor","proton-Input__prefix"),children:l}),n.jsxRuntimeExports.jsx("input",{id:q,name:c,type:z,value:y,onChange:e=>{m==null||m(e.target.value)},onKeyDown:e=>{switch(e.key){case"Enter":b&&(e.preventDefault(),b(e));break;case"Escape":E&&(e.preventDefault(),E());break}},onCopy:async()=>{var e;return await K.copyTextToClipboard(((e=N.current)==null?void 0:e.value)||"")},disabled:R,readOnly:W,required:_,autoFocus:F,autoComplete:k?"on":"off",placeholder:x?void 0:T,"aria-label":x||c,"aria-invalid":!!i,"aria-errormessage":typeof i=="string"?i:I,"aria-required":_,"aria-readonly":W,"aria-describedby":i?I:u?v:void 0,"aria-disabled":R,"data-testid":A,ref:S,className:o.csx("proton-Input",i&&"proton-Input--error",x&&"proton-Input__label-top",O)}),n.jsxRuntimeExports.jsxs("label",{htmlFor:q,className:o.csx("proton-Input__label",y&&"proton-Input__label--filled"),children:[x,_&&n.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",children:" *"})]}),f&&n.jsxRuntimeExports.jsx("div",{ref:p,className:o.csx("proton-Input__descriptor","proton-Input__suffix"),children:f})]}),i?n.jsxRuntimeExports.jsx("div",{role:"alert",className:o.csx("proton-Input__error","proton-Input__text"),id:I,children:i}):u&&j==="bottom"?n.jsxRuntimeExports.jsx("div",{id:v,className:"proton-Input__text","aria-live":"polite",children:u}):null]})});P.displayName="ProtonUIInput";exports.Input=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../../node_modules/react/jsx-runtime.cjs.js"),i=require("react"),D=require("../../../hooks/useMergedRef.cjs.js"),K=require("../../ThemeProvider.cjs.js");;/* empty css */const U=require("../../../utils/copy.cjs.js"),o=require("../../../utils/string.cjs.js"),g=i.forwardRef(({prefix:d,suffix:l,description:u,descriptionPosition:j="top",isDisabled:R,error:s,onChange:h,label:f,name:W,placeholder:z,type:F="text",value:y,autoFocus:k,autoComplete:A,isRequired:m=!1,isReadOnly:b=!1,onSubmit:E,onClear:N,"data-testid":M},O)=>{const q=i.useRef(null),a=i.useRef(null),c=i.useRef(null),r=i.useRef(null),{className:S}=K.useTheme(),B=D.useMergedRef(q,O),_=i.useId();i.useEffect(()=>{if(!r.current)return;const e={containerWidth:200,prefixWidth:32,suffixWidth:32};let p=null;const $=()=>{p!==null&&cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var P,T;if(r.current){if(r.current){const t=r.current.offsetWidth||e.containerWidth;t!==e.containerWidth&&(r.current.style.setProperty("--container-width",`${t}px`),e.containerWidth=t)}if(a.current){const t=a.current.offsetWidth||e.prefixWidth;t!==e.prefixWidth&&((P=r.current)==null||P.style.setProperty("--prefix-width",`${t}px`),e.prefixWidth=t)}if(c.current){const t=c.current.offsetWidth||e.suffixWidth;t!==e.suffixWidth&&((T=r.current)==null||T.style.setProperty("--suffix-width",`${t}px`),e.suffixWidth=t)}}})};$();const x=new ResizeObserver($);return r.current&&x.observe(r.current),a.current&&x.observe(a.current),c.current&&x.observe(c.current),()=>{p!==null&&cancelAnimationFrame(p),x.disconnect()}},[d,l]);const w=`${_}-input`,I=`${_}-error`,v=`${_}-description`;return n.jsxRuntimeExports.jsxs("div",{ref:r,className:"proton-Input__container",children:[u&&j==="top"&&n.jsxRuntimeExports.jsx("div",{id:v,className:"proton-Input__text","aria-live":"polite",children:u}),n.jsxRuntimeExports.jsxs("div",{className:o.csx("proton-Input__container-inner",d&&"proton-Input__has-prefix",l&&"proton-Input__has-suffix"),children:[d&&n.jsxRuntimeExports.jsx("div",{ref:a,className:o.csx("proton-Input__descriptor","proton-Input__prefix"),children:d}),n.jsxRuntimeExports.jsx("input",{id:w,name:W,type:F,value:y,onChange:e=>{h==null||h(e.target.value)},onKeyDown:e=>{switch(e.key){case"Enter":E&&(e.preventDefault(),E(e));break;case"Escape":N&&(e.preventDefault(),N());break}},onCopy:async()=>{var e;return await U.copyTextToClipboard(((e=q.current)==null?void 0:e.value)||"")},disabled:R,readOnly:b,required:m,autoFocus:k,autoComplete:A?"on":"off",placeholder:f?void 0:z,"aria-label":f||W,"aria-invalid":!!s,"aria-errormessage":s?I:void 0,"aria-required":m,"aria-readonly":b,"aria-describedby":s?I:u?v:void 0,"aria-disabled":R,"data-testid":M,ref:B,className:o.csx("proton-Input",s&&"proton-Input--error",f&&"proton-Input__label-top",S)}),n.jsxRuntimeExports.jsxs("label",{htmlFor:w,className:o.csx("proton-Input__label",y&&"proton-Input__label--filled"),children:[f,m&&n.jsxRuntimeExports.jsx("span",{"aria-hidden":"true",children:" *"})]}),l&&n.jsxRuntimeExports.jsx("div",{ref:c,className:o.csx("proton-Input__descriptor","proton-Input__suffix"),children:l})]}),s?n.jsxRuntimeExports.jsx("div",{role:"alert",className:o.csx("proton-Input__error","proton-Input__text"),id:I,children:s}):u&&j==="bottom"?n.jsxRuntimeExports.jsx("div",{id:v,className:"proton-Input__text","aria-live":"polite",children:u}):null]})});g.displayName="ProtonUIInput";exports.Input=g;
2
2
  //# sourceMappingURL=Input.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.cjs.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useRef, type ForwardedRef } from \"react\";\n\nimport { useMergedRef } from \"../../../hooks/useMergedRef\";\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: ForwardedRef<HTMLInputElement>,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const setInputRef = useMergedRef(inputRef, forwardedRef);\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const prevSizes = {\n containerWidth: 200,\n prefixWidth: 32,\n suffixWidth: 32,\n };\n\n let rafId: number | null = null;\n\n const updateSizes = () => {\n if (rafId !== null) cancelAnimationFrame(rafId);\n\n rafId = requestAnimationFrame(() => {\n if (!containerRef.current) return;\n\n if (containerRef.current) {\n const containerWidth =\n containerRef.current.offsetWidth || prevSizes.containerWidth;\n\n if (containerWidth !== prevSizes.containerWidth) {\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n prevSizes.containerWidth = containerWidth;\n }\n }\n\n if (prefixRef.current) {\n const prefixWidth =\n prefixRef.current.offsetWidth || prevSizes.prefixWidth;\n\n if (prefixWidth !== prevSizes.prefixWidth) {\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n prevSizes.prefixWidth = prefixWidth;\n }\n }\n\n if (suffixRef.current) {\n const suffixWidth =\n suffixRef.current.offsetWidth || prevSizes.suffixWidth;\n\n if (suffixWidth !== prevSizes.suffixWidth) {\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n prevSizes.suffixWidth = suffixWidth;\n }\n }\n });\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${name}-input`;\n const errorId = `${name}-error`;\n const descriptionId = `${name}-description`;\n\n return (\n <div ref={containerRef} className=\"proton-Input__container\">\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div\n className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}\n >\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value || \"\")\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={typeof error === \"string\" ? error : errorId}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={setInputRef}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","setInputRef","useMergedRef","useEffect","prevSizes","rafId","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","copyTextToClipboard"],"mappings":"mXAiHaA,EAAQC,EAAAA,WACnB,CACE,CACE,OAAAC,EACA,OAAAC,EACA,YAAAC,EACA,oBAAAC,EAAsB,MACtB,WAAAC,EACA,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,KAAAC,EACA,YAAAC,EACA,KAAAC,EAAO,OACP,MAAAC,EACA,UAAAC,EACA,aAAAC,EACA,WAAAC,EAAa,GACb,WAAAC,EAAa,GACb,SAAAC,EACA,QAAAC,EACA,cAAeC,CAAA,EAEjBC,IACG,CACH,MAAMC,EAAWC,EAAAA,OAAyB,IAAI,EACxCC,EAAYD,EAAAA,OAAuB,IAAI,EACvCE,EAAYF,EAAAA,OAAuB,IAAI,EACvCG,EAAeH,EAAAA,OAAuB,IAAI,EAC1C,CAAE,UAAAI,CAAA,EAAcC,WAAA,EAChBC,EAAcC,EAAAA,aAAaR,EAAUD,CAAY,EAGvDU,EAAAA,UAAU,IAAM,CACd,GAAI,CAACL,EAAa,QAAS,OAE3B,MAAMM,EAAY,CAChB,eAAgB,IAChB,YAAa,GACb,YAAa,EAAA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EACAO,GAAc6B,EAAAA,kBAAAA,IAAC,OAAA,CAAK,cAAY,OAAO,SAAA,IAAA,CAAE,CAAA,CAAA,CAAA,EAG3C1C,GACC0C,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKpB,EACL,UAAWqB,EAAAA,IACT,2BACA,sBAAA,EAGD,SAAA3C,CAAA,CAAA,CACH,CAAA,CAAA,EAIHI,EACCsC,EAAAA,kBAAAA,IAAC,MAAA,CACC,KAAK,QACL,UAAWC,EAAAA,IAAI,sBAAuB,oBAAoB,EAC1D,GAAIJ,EAEH,SAAAnC,CAAA,CAAA,EAEDH,GAAeC,IAAwB,SACzCwC,EAAAA,kBAAAA,IAAC,MAAA,CACC,GAAIF,EACJ,UAAU,qBACV,YAAU,SAET,SAAAvC,CAAA,CAAA,EAED,IAAA,EACN,CAEJ,CACF,EAEAJ,EAAM,YAAc"}
1
+ {"version":3,"file":"Input.cjs.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useId, useRef, type ForwardedRef } from \"react\";\n\nimport { useMergedRef } from \"../../../hooks/useMergedRef\";\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: ForwardedRef<HTMLInputElement>,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const setInputRef = useMergedRef(inputRef, forwardedRef);\n const idBase = useId();\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const prevSizes = {\n containerWidth: 200,\n prefixWidth: 32,\n suffixWidth: 32,\n };\n\n let rafId: number | null = null;\n\n const updateSizes = () => {\n if (rafId !== null) cancelAnimationFrame(rafId);\n\n rafId = requestAnimationFrame(() => {\n if (!containerRef.current) return;\n\n if (containerRef.current) {\n const containerWidth =\n containerRef.current.offsetWidth || prevSizes.containerWidth;\n\n if (containerWidth !== prevSizes.containerWidth) {\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n prevSizes.containerWidth = containerWidth;\n }\n }\n\n if (prefixRef.current) {\n const prefixWidth =\n prefixRef.current.offsetWidth || prevSizes.prefixWidth;\n\n if (prefixWidth !== prevSizes.prefixWidth) {\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n prevSizes.prefixWidth = prefixWidth;\n }\n }\n\n if (suffixRef.current) {\n const suffixWidth =\n suffixRef.current.offsetWidth || prevSizes.suffixWidth;\n\n if (suffixWidth !== prevSizes.suffixWidth) {\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n prevSizes.suffixWidth = suffixWidth;\n }\n }\n });\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${idBase}-input`;\n const errorId = `${idBase}-error`;\n const descriptionId = `${idBase}-description`;\n\n return (\n <div ref={containerRef} className=\"proton-Input__container\">\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div\n className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}\n >\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value || \"\")\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={error ? errorId : undefined}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={setInputRef}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","setInputRef","useMergedRef","idBase","useId","useEffect","prevSizes","rafId","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","copyTextToClipboard"],"mappings":"mXAiHaA,EAAQC,EAAAA,WACnB,CACE,CACE,OAAAC,EACA,OAAAC,EACA,YAAAC,EACA,oBAAAC,EAAsB,MACtB,WAAAC,EACA,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,KAAAC,EACA,YAAAC,EACA,KAAAC,EAAO,OACP,MAAAC,EACA,UAAAC,EACA,aAAAC,EACA,WAAAC,EAAa,GACb,WAAAC,EAAa,GACb,SAAAC,EACA,QAAAC,EACA,cAAeC,CAAA,EAEjBC,IACG,CACH,MAAMC,EAAWC,EAAAA,OAAyB,IAAI,EACxCC,EAAYD,EAAAA,OAAuB,IAAI,EACvCE,EAAYF,EAAAA,OAAuB,IAAI,EACvCG,EAAeH,EAAAA,OAAuB,IAAI,EAC1C,CAAE,UAAAI,CAAA,EAAcC,WAAA,EAChBC,EAAcC,EAAAA,aAAaR,EAAUD,CAAY,EACjDU,EAASC,EAAAA,MAAA,EAGfC,EAAAA,UAAU,IAAM,CACd,GAAI,CAACP,EAAa,QAAS,OAE3B,MAAMQ,EAAY,CAChB,eAAgB,IAChB,YAAa,GACb,YAAa,EAAA,EAGf,IAAIC,EAAuB,KAE3B,M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AK,cAAY,OAAO,SAAA,IAAA,CAAE,CAAA,CAAA,CAAA,EAG3C5C,GACC4C,EAAAA,kBAAAA,IAAC,MAAA,CACC,IAAKtB,EACL,UAAWuB,EAAAA,IACT,2BACA,sBAAA,EAGD,SAAA7C,CAAA,CAAA,CACH,CAAA,CAAA,EAIHI,EACCwC,EAAAA,kBAAAA,IAAC,MAAA,CACC,KAAK,QACL,UAAWC,EAAAA,IAAI,sBAAuB,oBAAoB,EAC1D,GAAIJ,EAEH,SAAArC,CAAA,CAAA,EAEDH,GAAeC,IAAwB,SACzC0C,EAAAA,kBAAAA,IAAC,MAAA,CACC,GAAIF,EACJ,UAAU,qBACV,YAAU,SAET,SAAAzC,CAAA,CAAA,EAED,IAAA,EACN,CAEJ,CACF,EAEAJ,EAAM,YAAc"}
@@ -1,44 +1,44 @@
1
1
  import { j as n } from "../../../node_modules/react/jsx-runtime.es.js";
2
- import { forwardRef as B, useRef as x, useEffect as K } from "react";
3
- import { useMergedRef as M } from "../../../hooks/useMergedRef.es.js";
4
- import { useTheme as S } from "../../ThemeProvider.es.js";
2
+ import { forwardRef as M, useRef as h, useId as S, useEffect as U } from "react";
3
+ import { useMergedRef as g } from "../../../hooks/useMergedRef.es.js";
4
+ import { useTheme as G } from "../../ThemeProvider.es.js";
5
5
  /* empty css */
6
- import { copyTextToClipboard as U } from "../../../utils/copy.es.js";
6
+ import { copyTextToClipboard as H } from "../../../utils/copy.es.js";
7
7
  import { csx as o } from "../../../utils/string.es.js";
8
- const G = B(
8
+ const J = M(
9
9
  ({
10
- prefix: f,
10
+ prefix: u,
11
11
  suffix: d,
12
12
  description: s,
13
13
  descriptionPosition: W = "top",
14
14
  isDisabled: y,
15
15
  error: i,
16
16
  onChange: m,
17
- label: l,
18
- name: a,
19
- placeholder: k,
20
- type: A = "text",
21
- value: b,
22
- autoFocus: P,
23
- autoComplete: T,
24
- isRequired: _ = !1,
25
- isReadOnly: j = !1,
26
- onSubmit: N,
27
- onClear: w,
17
+ label: f,
18
+ name: b,
19
+ placeholder: A,
20
+ type: P = "text",
21
+ value: j,
22
+ autoFocus: T,
23
+ autoComplete: B,
24
+ isRequired: x = !1,
25
+ isReadOnly: N = !1,
26
+ onSubmit: w,
27
+ onClear: R,
28
28
  "data-testid": D
29
29
  }, O) => {
30
- const R = x(null), p = x(null), c = x(null), r = x(null), { className: g } = S(), q = M(R, O);
31
- K(() => {
30
+ const $ = h(null), a = h(null), c = h(null), r = h(null), { className: q } = G(), K = g($, O), _ = S();
31
+ U(() => {
32
32
  if (!r.current) return;
33
33
  const t = {
34
34
  containerWidth: 200,
35
35
  prefixWidth: 32,
36
36
  suffixWidth: 32
37
37
  };
38
- let u = null;
39
- const z = () => {
40
- u !== null && cancelAnimationFrame(u), u = requestAnimationFrame(() => {
41
- var E, F;
38
+ let p = null;
39
+ const E = () => {
40
+ p !== null && cancelAnimationFrame(p), p = requestAnimationFrame(() => {
41
+ var F, k;
42
42
  if (r.current) {
43
43
  if (r.current) {
44
44
  const e = r.current.offsetWidth || t.containerWidth;
@@ -47,16 +47,16 @@ const G = B(
47
47
  `${e}px`
48
48
  ), t.containerWidth = e);
49
49
  }
50
- if (p.current) {
51
- const e = p.current.offsetWidth || t.prefixWidth;
52
- e !== t.prefixWidth && ((E = r.current) == null || E.style.setProperty(
50
+ if (a.current) {
51
+ const e = a.current.offsetWidth || t.prefixWidth;
52
+ e !== t.prefixWidth && ((F = r.current) == null || F.style.setProperty(
53
53
  "--prefix-width",
54
54
  `${e}px`
55
55
  ), t.prefixWidth = e);
56
56
  }
57
57
  if (c.current) {
58
58
  const e = c.current.offsetWidth || t.suffixWidth;
59
- e !== t.suffixWidth && ((F = r.current) == null || F.style.setProperty(
59
+ e !== t.suffixWidth && ((k = r.current) == null || k.style.setProperty(
60
60
  "--suffix-width",
61
61
  `${e}px`
62
62
  ), t.suffixWidth = e);
@@ -64,13 +64,13 @@ const G = B(
64
64
  }
65
65
  });
66
66
  };
67
- z();
68
- const h = new ResizeObserver(z);
69
- return r.current && h.observe(r.current), p.current && h.observe(p.current), c.current && h.observe(c.current), () => {
70
- u !== null && cancelAnimationFrame(u), h.disconnect();
67
+ E();
68
+ const l = new ResizeObserver(E);
69
+ return r.current && l.observe(r.current), a.current && l.observe(a.current), c.current && l.observe(c.current), () => {
70
+ p !== null && cancelAnimationFrame(p), l.disconnect();
71
71
  };
72
- }, [f, d]);
73
- const $ = `${a}-input`, I = `${a}-error`, v = `${a}-description`;
72
+ }, [u, d]);
73
+ const z = `${_}-input`, I = `${_}-error`, v = `${_}-description`;
74
74
  return /* @__PURE__ */ n.jsxs("div", { ref: r, className: "proton-Input__container", children: [
75
75
  s && W === "top" && /* @__PURE__ */ n.jsx(
76
76
  "div",
@@ -86,79 +86,79 @@ const G = B(
86
86
  {
87
87
  className: o(
88
88
  "proton-Input__container-inner",
89
- f && "proton-Input__has-prefix",
89
+ u && "proton-Input__has-prefix",
90
90
  d && "proton-Input__has-suffix"
91
91
  ),
92
92
  children: [
93
- f && /* @__PURE__ */ n.jsx(
93
+ u && /* @__PURE__ */ n.jsx(
94
94
  "div",
95
95
  {
96
- ref: p,
96
+ ref: a,
97
97
  className: o(
98
98
  "proton-Input__descriptor",
99
99
  "proton-Input__prefix"
100
100
  ),
101
- children: f
101
+ children: u
102
102
  }
103
103
  ),
104
104
  /* @__PURE__ */ n.jsx(
105
105
  "input",
106
106
  {
107
- id: $,
108
- name: a,
109
- type: A,
110
- value: b,
107
+ id: z,
108
+ name: b,
109
+ type: P,
110
+ value: j,
111
111
  onChange: (t) => {
112
112
  m == null || m(t.target.value);
113
113
  },
114
114
  onKeyDown: (t) => {
115
115
  switch (t.key) {
116
116
  case "Enter":
117
- N && (t.preventDefault(), N(t));
117
+ w && (t.preventDefault(), w(t));
118
118
  break;
119
119
  case "Escape":
120
- w && (t.preventDefault(), w());
120
+ R && (t.preventDefault(), R());
121
121
  break;
122
122
  }
123
123
  },
124
124
  onCopy: async () => {
125
125
  var t;
126
- return await U(((t = R.current) == null ? void 0 : t.value) || "");
126
+ return await H(((t = $.current) == null ? void 0 : t.value) || "");
127
127
  },
128
128
  disabled: y,
129
- readOnly: j,
130
- required: _,
131
- autoFocus: P,
132
- autoComplete: T ? "on" : "off",
133
- placeholder: l ? void 0 : k,
134
- "aria-label": l || a,
129
+ readOnly: N,
130
+ required: x,
131
+ autoFocus: T,
132
+ autoComplete: B ? "on" : "off",
133
+ placeholder: f ? void 0 : A,
134
+ "aria-label": f || b,
135
135
  "aria-invalid": !!i,
136
- "aria-errormessage": typeof i == "string" ? i : I,
137
- "aria-required": _,
138
- "aria-readonly": j,
136
+ "aria-errormessage": i ? I : void 0,
137
+ "aria-required": x,
138
+ "aria-readonly": N,
139
139
  "aria-describedby": i ? I : s ? v : void 0,
140
140
  "aria-disabled": y,
141
141
  "data-testid": D,
142
- ref: q,
142
+ ref: K,
143
143
  className: o(
144
144
  "proton-Input",
145
145
  i && "proton-Input--error",
146
- l && "proton-Input__label-top",
147
- g
146
+ f && "proton-Input__label-top",
147
+ q
148
148
  )
149
149
  }
150
150
  ),
151
151
  /* @__PURE__ */ n.jsxs(
152
152
  "label",
153
153
  {
154
- htmlFor: $,
154
+ htmlFor: z,
155
155
  className: o(
156
156
  "proton-Input__label",
157
- b && "proton-Input__label--filled"
157
+ j && "proton-Input__label--filled"
158
158
  ),
159
159
  children: [
160
- l,
161
- _ && /* @__PURE__ */ n.jsx("span", { "aria-hidden": "true", children: " *" })
160
+ f,
161
+ x && /* @__PURE__ */ n.jsx("span", { "aria-hidden": "true", children: " *" })
162
162
  ]
163
163
  }
164
164
  ),
@@ -196,8 +196,8 @@ const G = B(
196
196
  ] });
197
197
  }
198
198
  );
199
- G.displayName = "ProtonUIInput";
199
+ J.displayName = "ProtonUIInput";
200
200
  export {
201
- G as Input
201
+ J as Input
202
202
  };
203
203
  //# sourceMappingURL=Input.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.es.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useRef, type ForwardedRef } from \"react\";\n\nimport { useMergedRef } from \"../../../hooks/useMergedRef\";\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: ForwardedRef<HTMLInputElement>,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const setInputRef = useMergedRef(inputRef, forwardedRef);\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const prevSizes = {\n containerWidth: 200,\n prefixWidth: 32,\n suffixWidth: 32,\n };\n\n let rafId: number | null = null;\n\n const updateSizes = () => {\n if (rafId !== null) cancelAnimationFrame(rafId);\n\n rafId = requestAnimationFrame(() => {\n if (!containerRef.current) return;\n\n if (containerRef.current) {\n const containerWidth =\n containerRef.current.offsetWidth || prevSizes.containerWidth;\n\n if (containerWidth !== prevSizes.containerWidth) {\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n prevSizes.containerWidth = containerWidth;\n }\n }\n\n if (prefixRef.current) {\n const prefixWidth =\n prefixRef.current.offsetWidth || prevSizes.prefixWidth;\n\n if (prefixWidth !== prevSizes.prefixWidth) {\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n prevSizes.prefixWidth = prefixWidth;\n }\n }\n\n if (suffixRef.current) {\n const suffixWidth =\n suffixRef.current.offsetWidth || prevSizes.suffixWidth;\n\n if (suffixWidth !== prevSizes.suffixWidth) {\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n prevSizes.suffixWidth = suffixWidth;\n }\n }\n });\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${name}-input`;\n const errorId = `${name}-error`;\n const descriptionId = `${name}-description`;\n\n return (\n <div ref={containerRef} className=\"proton-Input__container\">\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div\n className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}\n >\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value || \"\")\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={typeof error === \"string\" ? error : errorId}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={setInputRef}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","setInputRef","useMergedRef","useEffect","prevSizes","rafId","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":";;;;;;;AAiHO,MAAMA,IAAQC;AAAA,EACnB,CACE;AAAA,IACE,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,qBAA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cAAA;AAAA,gBACC,SAASH;AAAA,gBACT,WAAWK;AAAA,kBACT;AAAA,kBACAjC,KAAS;AAAA,gBAAA;AAAA,gBAGV,UAAA;AAAA,kBAAAJ;AAAA,kBACAO,KAAc6B,gBAAAA,EAAAA,IAAC,QAAA,EAAK,eAAY,QAAO,UAAA,KAAA,CAAE;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,YAG3C1C,KACC0C,gBAAAA,EAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAKpB;AAAA,gBACL,WAAWqB;AAAA,kBACT;AAAA,kBACA;AAAA,gBAAA;AAAA,gBAGD,UAAA3C;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,MAIHI,IACCsC,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAWC,EAAI,uBAAuB,oBAAoB;AAAA,UAC1D,IAAIJ;AAAA,UAEH,UAAAnC;AAAA,QAAA;AAAA,MAAA,IAEDH,KAAeC,MAAwB,WACzCwC,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAIF;AAAA,UACJ,WAAU;AAAA,UACV,aAAU;AAAA,UAET,UAAAvC;AAAA,QAAA;AAAA,MAAA,IAED;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AAEAJ,EAAM,cAAc;"}
1
+ {"version":3,"file":"Input.es.js","sources":["../../../../src/components/Input/BaseInput/Input.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useEffect, useId, useRef, type ForwardedRef } from \"react\";\n\nimport { useMergedRef } from \"../../../hooks/useMergedRef\";\nimport { useTheme } from \"../../ThemeProvider\";\nimport { csx } from \"../../../utils\";\nimport \"./Input.css\";\nimport { copyTextToClipboard } from \"../../../utils/copy\";\n\nexport interface BaseInputProps {\n /**\n * onChange handler for the input\n */\n onChange?: (value: string) => void;\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Description text shown above the input. */\n description?: React.ReactNode | string;\n\n /**\n * The position of the description text.\n * @default \"top\"\n */\n descriptionPosition?: \"top\" | \"bottom\";\n\n /** Error state that changes the input's visual style and displays an error message. */\n error?: React.ReactNode | string;\n\n /**\n * Label for the input element.\n * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.\n */\n label?: string;\n\n /** Test ID for the component. */\n \"data-testid\"?: string;\n\n /** Content to display before the input. Typically used for icons. */\n prefix?: React.ReactNode;\n\n /** Content to display after the input. Typically used for icons. */\n suffix?: React.ReactNode;\n\n /**\n * Should the browser's autocomplete be enabled?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n autoComplete?: boolean;\n\n /**\n * Should the input be autofocused?\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus\n */\n autoFocus?: boolean;\n\n /**\n * The name attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name\n */\n name: string;\n\n /**\n * The placeholder text to display when the input is empty.\n * @note label takes precedence over placeholder, if both are provided.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder\n */\n placeholder?: string;\n\n /**\n * The type attribute of the input element.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type\n * @default \"text\"\n */\n type?: string;\n\n /**\n * The value of the input.\n * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value\n */\n value?: string;\n\n /**\n * Whether the input is required.\n * @default false\n */\n isRequired?: boolean;\n\n /**\n * Whether the input is read-only.\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Called when the input is submitted (e.g. by pressing Enter).\n */\n onSubmit?: React.FormEventHandler<HTMLInputElement>;\n\n /**\n * Called when the input is cleared (e.g. by pressing Escape).\n */\n onClear?: () => void;\n}\n\n/**\n * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.\n *\n * API:\n * - {@link BaseInputProps}\n */\nexport const Input = forwardRef<HTMLInputElement, BaseInputProps>(\n (\n {\n prefix,\n suffix,\n description,\n descriptionPosition = \"top\",\n isDisabled,\n error,\n onChange,\n label,\n name,\n placeholder,\n type = \"text\",\n value,\n autoFocus,\n autoComplete,\n isRequired = false,\n isReadOnly = false,\n onSubmit,\n onClear,\n \"data-testid\": testId,\n },\n forwardedRef: ForwardedRef<HTMLInputElement>,\n ) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const prefixRef = useRef<HTMLDivElement>(null);\n const suffixRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const { className } = useTheme();\n const setInputRef = useMergedRef(inputRef, forwardedRef);\n const idBase = useId();\n\n // Control dynamic prefix and suffix widths using ResizeObserver\n useEffect(() => {\n if (!containerRef.current) return;\n\n const prevSizes = {\n containerWidth: 200,\n prefixWidth: 32,\n suffixWidth: 32,\n };\n\n let rafId: number | null = null;\n\n const updateSizes = () => {\n if (rafId !== null) cancelAnimationFrame(rafId);\n\n rafId = requestAnimationFrame(() => {\n if (!containerRef.current) return;\n\n if (containerRef.current) {\n const containerWidth =\n containerRef.current.offsetWidth || prevSizes.containerWidth;\n\n if (containerWidth !== prevSizes.containerWidth) {\n containerRef.current.style.setProperty(\n \"--container-width\",\n `${containerWidth}px`\n );\n prevSizes.containerWidth = containerWidth;\n }\n }\n\n if (prefixRef.current) {\n const prefixWidth =\n prefixRef.current.offsetWidth || prevSizes.prefixWidth;\n\n if (prefixWidth !== prevSizes.prefixWidth) {\n containerRef.current?.style.setProperty(\n \"--prefix-width\",\n `${prefixWidth}px`\n );\n prevSizes.prefixWidth = prefixWidth;\n }\n }\n\n if (suffixRef.current) {\n const suffixWidth =\n suffixRef.current.offsetWidth || prevSizes.suffixWidth;\n\n if (suffixWidth !== prevSizes.suffixWidth) {\n containerRef.current?.style.setProperty(\n \"--suffix-width\",\n `${suffixWidth}px`\n );\n prevSizes.suffixWidth = suffixWidth;\n }\n }\n });\n };\n\n updateSizes();\n\n const resizeObserver = new ResizeObserver(updateSizes);\n\n if (containerRef.current) {\n resizeObserver.observe(containerRef.current);\n }\n if (prefixRef.current) {\n resizeObserver.observe(prefixRef.current);\n }\n if (suffixRef.current) {\n resizeObserver.observe(suffixRef.current);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n resizeObserver.disconnect();\n };\n }, [prefix, suffix]);\n\n const inputId = `${idBase}-input`;\n const errorId = `${idBase}-error`;\n const descriptionId = `${idBase}-description`;\n\n return (\n <div ref={containerRef} className=\"proton-Input__container\">\n {description && descriptionPosition === \"top\" && (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n )}\n <div\n className={csx(\n \"proton-Input__container-inner\",\n prefix && \"proton-Input__has-prefix\",\n suffix && \"proton-Input__has-suffix\"\n )}\n >\n {prefix && (\n <div\n ref={prefixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__prefix\"\n )}\n >\n {prefix}\n </div>\n )}\n\n <input\n id={inputId}\n name={name}\n type={type}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(e.target.value);\n }}\n onKeyDown={(e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case \"Enter\":\n if (onSubmit) {\n e.preventDefault();\n onSubmit(e);\n }\n break;\n case \"Escape\":\n if (onClear) {\n e.preventDefault();\n onClear();\n }\n break;\n }\n }}\n onCopy={async () =>\n await copyTextToClipboard(inputRef.current?.value || \"\")\n }\n disabled={isDisabled}\n readOnly={isReadOnly}\n required={isRequired}\n autoFocus={autoFocus}\n autoComplete={autoComplete ? \"on\" : \"off\"}\n placeholder={label ? undefined : placeholder}\n aria-label={label || name}\n aria-invalid={Boolean(error)}\n aria-errormessage={error ? errorId : undefined}\n aria-required={isRequired}\n aria-readonly={isReadOnly}\n aria-describedby={\n error ? errorId : description ? descriptionId : undefined\n }\n aria-disabled={isDisabled}\n data-testid={testId}\n ref={setInputRef}\n className={csx(\n \"proton-Input\",\n error && \"proton-Input--error\",\n label && \"proton-Input__label-top\",\n className\n )}\n />\n\n <label\n htmlFor={inputId}\n className={csx(\n \"proton-Input__label\",\n value && \"proton-Input__label--filled\"\n )}\n >\n {label}\n {isRequired && <span aria-hidden=\"true\"> *</span>}\n </label>\n\n {suffix && (\n <div\n ref={suffixRef}\n className={csx(\n \"proton-Input__descriptor\",\n \"proton-Input__suffix\"\n )}\n >\n {suffix}\n </div>\n )}\n </div>\n\n {error ? (\n <div\n role=\"alert\"\n className={csx(\"proton-Input__error\", \"proton-Input__text\")}\n id={errorId}\n >\n {error}\n </div>\n ) : description && descriptionPosition === \"bottom\" ? (\n <div\n id={descriptionId}\n className=\"proton-Input__text\"\n aria-live=\"polite\"\n >\n {description}\n </div>\n ) : null}\n </div>\n );\n }\n);\n\nInput.displayName = \"ProtonUIInput\";\n"],"names":["Input","forwardRef","prefix","suffix","description","descriptionPosition","isDisabled","error","onChange","label","name","placeholder","type","value","autoFocus","autoComplete","isRequired","isReadOnly","onSubmit","onClear","testId","forwardedRef","inputRef","useRef","prefixRef","suffixRef","containerRef","className","useTheme","setInputRef","useMergedRef","idBase","useId","useEffect","prevSizes","rafId","updateSizes","containerWidth","prefixWidth","_a","suffixWidth","_b","resizeObserver","inputId","errorId","descriptionId","jsxs","jsx","csx","e","copyTextToClipboard"],"mappings":";;;;;;;AAiHO,MAAMA,IAAQC;AAAA,EACnB,CACE;AAAA,IACE,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,qBAAAC,IAAsB;AAAA,IACtB,YAAAC;AAAA,IACA,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,YAAAC,IAAa;AAAA,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AAA,YAG3C5C,KACC4C,gBAAAA,EAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAKtB;AAAA,gBACL,WAAWuB;AAAA,kBACT;AAAA,kBACA;AAAA,gBAAA;AAAA,gBAGD,UAAA7C;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA;AAAA,MAAA;AAAA,MAIHI,IACCwC,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAWC,EAAI,uBAAuB,oBAAoB;AAAA,UAC1D,IAAIJ;AAAA,UAEH,UAAArC;AAAA,QAAA;AAAA,MAAA,IAEDH,KAAeC,MAAwB,WACzC0C,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,IAAIF;AAAA,UACJ,WAAU;AAAA,UACV,aAAU;AAAA,UAET,UAAAzC;AAAA,QAAA;AAAA,MAAA,IAED;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AAEAJ,EAAM,cAAc;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.cjs.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as RadixPopover } from \"radix-ui\";\nimport { CSSProperties, ReactNode } from \"react\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { csx } from \"../../utils/string\";\nimport { Overlay } from \"../Overlay/Overlay\";\n\nimport \"../Elevation/Elevation.css\";\nimport \"./Popover.css\";\n\n/** Radix `Popover.Content` `side` */\nexport type PopoverSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n/** Radix `Popover.Content` `align`*/\nexport type PopoverAlign = \"start\" | \"center\" | \"end\";\n\nexport interface PopoverProps {\n /**\n * Popover alignment\n * {@link PopoverAlign}\n */\n align?: PopoverAlign;\n /**\n * Show an arrow pointing to the trigger.\n * @default false\n */\n arrow?: boolean;\n /**\n * The content of the popover.\n */\n children: ReactNode;\n /**\n * Constrain the width of the popover to the width of the trigger.\n */\n constrainWidth?: boolean;\n /**\n * Default open state (uncontrolled mode).\n */\n defaultOpen?: boolean;\n /**\n * Test id for the popover content.\n */\n \"data-testid\"?: string;\n /**\n * Control open state (controlled mode).\n */\n open?: boolean;\n /**\n * Whether the popover is disabled.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Callback when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger element for the popover.\n */\n trigger: ReactNode;\n /**\n * Popover side placement\n * {@link PopoverSide}\n */\n side?: PopoverSide;\n}\n\n/**\n * A popover component that handles positioning and supports controlled and uncontrolled modes.\n *\n * A popover displays interactive content in context with a trigger element.\n * A tooltip displays a description of an element on hover or focus.\n *\n * API:\n * - {@link PopoverProps}\n */\nexport function Popover({\n trigger,\n children,\n open,\n isDisabled = false,\n defaultOpen,\n onOpenChange,\n side = \"top\",\n align = \"center\",\n arrow = false,\n constrainWidth = false,\n \"data-testid\": testId,\n}: PopoverProps) {\n const { className: themeClass, style: themeStyle } = useTheme();\n\n return (\n <RadixPopover.Root\n open={isDisabled ? false : open}\n defaultOpen={defaultOpen}\n onOpenChange={(newOpen) => {\n if (isDisabled) return;\n onOpenChange?.(newOpen);\n }}\n >\n <RadixPopover.Trigger asChild>\n <div aria-disabled={isDisabled}>{trigger}</div>\n </RadixPopover.Trigger>\n\n {!isDisabled && (\n <RadixPopover.Portal>\n <RadixPopover.Content\n side={side}\n sideOffset={2}\n align={align}\n style={themeStyle as CSSProperties}\n className={csx(\n \"proton-Popover\",\n \"proton-Elevation--glass\",\n constrainWidth && \"proton-Popover__constrained\",\n themeClass,\n )}\n data-testid={testId}\n >\n <Overlay\n arrow={\n arrow && (\n <RadixPopover.Arrow width={8} height={8}>\n <svg width={8} height={8} viewBox=\"0 0 8 8\">\n <path d=\"M0 0 L4 4 L8 0\" />\n </svg>\n </RadixPopover.Arrow>\n )\n }\n >\n {children}\n </Overlay>\n </RadixPopover.Content>\n </RadixPopover.Portal>\n )}\n </RadixPopover.Root>\n );\n}\n\nPopover.displayName = \"ProtonUIPopover\";\n"],"names":["Popover","trigger","children","open","isDisabled","defaultOpen","onOpenChange","side","align","arrow","constrainWidth","testId","themeClass","themeStyle","useTheme","jsxs","RadixPopover","newOpen","jsx","csx","Overlay"],"mappings":"qWA4EO,SAASA,EAAQ,CACtB,QAAAC,EACA,SAAAC,EACA,KAAAC,EACA,WAAAC,EAAa,GACb,YAAAC,EACA,aAAAC,EACA,KAAAC,EAAO,MACP,MAAAC,EAAQ,SACR,MAAAC,EAAQ,GACR,eAAAC,EAAiB,GACjB,cAAeC,CACjB,EAAiB,CACf,KAAM,CAAE,UAAWC,EAAY,MAAOC,CAAA,EAAeC,EAAAA,SAAA,EAErD,OACEC,EAAAA,kBAAAA,KAACC,EAAAA,QAAa,KAAb,CACC,KAAMZ,EAAa,GAAQD,EAC3B,YAAAE,EACA,aAAeY,GAAY,CACrBb,GACJE,GAAA,MAAAA,EAAeW,EACjB,EAEA,SAAA,CAAAC,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,QAAb,CAAqB,QAAO,GAC3B,iCAAC,MAAA,CAAI,gBAAeZ,EAAa,SAAAH,CAAA,CAAQ,CAAA,CAC3C,EAEC,CAACG,GACAc,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,OAAb,CACC,SAAAE,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,QAAb,CACC,KAAAT,EACA,WAAY,EACZ,MAAAC,EACA,MAAOK,EACP,UAAWM,EAAAA,IACT,iBACA,0BACAT,GAAkB,8BAClBE,CAAA,EAEF,cAAaD,EAEb,SAAAO,EAAAA,kBAAAA,IAACE,EAAAA,QAAA,CACC,MACEX,GACES,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,MAAb,CAAmB,MAAO,EAAG,OAAQ,EACpC,SAAAE,EAAAA,kBAAAA,IAAC,OAAI,MAAO,EAAG,OAAQ,EAAG,QAAQ,UAChC,iCAAC,OAAA,CAAK,EAAE,gBAAA,CAAiB,CAAA,CAC3B,CAAA,CACF,EAIH,SAAAhB,CAAA,CAAA,CACH,CAAA,CACF,CACF,CAAA,CAAA,CAAA,CAIR,CAEAF,EAAQ,YAAc"}
1
+ {"version":3,"file":"Popover.cjs.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as RadixPopover } from \"radix-ui\";\nimport { CSSProperties, ReactNode } from \"react\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { csx } from \"../../utils/string\";\nimport type { RadixAlign, RadixSide } from \"../../constants/placement\";\nimport { Overlay } from \"../Overlay/Overlay\";\n\nimport \"../Elevation/Elevation.css\";\nimport \"./Popover.css\";\n\n/** Radix `Popover.Content` `side` */\nexport type PopoverSide = RadixSide;\n/** Radix `Popover.Content` `align`*/\nexport type PopoverAlign = RadixAlign;\n\nexport interface PopoverProps {\n /**\n * Popover alignment\n * {@link PopoverAlign}\n * @default \"center\"\n */\n align?: PopoverAlign;\n /**\n * Show an arrow pointing to the trigger.\n * @default false\n */\n arrow?: boolean;\n /**\n * The content of the popover.\n */\n children: ReactNode;\n /**\n * Constrain the width of the popover to the width of the trigger.\n */\n constrainWidth?: boolean;\n /**\n * Default open state (uncontrolled mode).\n */\n defaultOpen?: boolean;\n /**\n * Test id for the popover content.\n */\n \"data-testid\"?: string;\n /**\n * Control open state (controlled mode).\n */\n open?: boolean;\n /**\n * Whether the popover is disabled.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Callback when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger element for the popover.\n */\n trigger: ReactNode;\n /**\n * Popover side placement\n * {@link PopoverSide}\n * @default \"top\"\n */\n side?: PopoverSide;\n}\n\n/**\n * A popover component that handles positioning and supports controlled and uncontrolled modes.\n *\n * A popover displays interactive content in context with a trigger element.\n * A tooltip displays a description of an element on hover or focus.\n *\n * API:\n * - {@link PopoverProps}\n */\nexport function Popover({\n trigger,\n children,\n open,\n isDisabled = false,\n defaultOpen,\n onOpenChange,\n side = \"top\",\n align = \"center\",\n arrow = false,\n constrainWidth = false,\n \"data-testid\": testId,\n}: PopoverProps) {\n const { className: themeClass, style: themeStyle } = useTheme();\n\n return (\n <RadixPopover.Root\n open={isDisabled ? false : open}\n defaultOpen={defaultOpen}\n onOpenChange={(newOpen) => {\n if (isDisabled) return;\n onOpenChange?.(newOpen);\n }}\n >\n <RadixPopover.Trigger asChild>\n <div aria-disabled={isDisabled}>{trigger}</div>\n </RadixPopover.Trigger>\n\n {!isDisabled && (\n <RadixPopover.Portal>\n <RadixPopover.Content\n side={side}\n sideOffset={2}\n align={align}\n style={themeStyle as CSSProperties}\n className={csx(\n \"proton-Popover\",\n \"proton-Elevation--glass\",\n constrainWidth && \"proton-Popover__constrained\",\n themeClass,\n )}\n data-testid={testId}\n >\n <Overlay\n arrow={\n arrow && (\n <RadixPopover.Arrow width={8} height={8}>\n <svg width={8} height={8} viewBox=\"0 0 8 8\">\n <path d=\"M0 0 L4 4 L8 0\" />\n </svg>\n </RadixPopover.Arrow>\n )\n }\n >\n {children}\n </Overlay>\n </RadixPopover.Content>\n </RadixPopover.Portal>\n )}\n </RadixPopover.Root>\n );\n}\n\nPopover.displayName = \"ProtonUIPopover\";\n"],"names":["Popover","trigger","children","open","isDisabled","defaultOpen","onOpenChange","side","align","arrow","constrainWidth","testId","themeClass","themeStyle","useTheme","jsxs","RadixPopover","newOpen","jsx","csx","Overlay"],"mappings":"qWA+EO,SAASA,EAAQ,CACtB,QAAAC,EACA,SAAAC,EACA,KAAAC,EACA,WAAAC,EAAa,GACb,YAAAC,EACA,aAAAC,EACA,KAAAC,EAAO,MACP,MAAAC,EAAQ,SACR,MAAAC,EAAQ,GACR,eAAAC,EAAiB,GACjB,cAAeC,CACjB,EAAiB,CACf,KAAM,CAAE,UAAWC,EAAY,MAAOC,CAAA,EAAeC,EAAAA,SAAA,EAErD,OACEC,EAAAA,kBAAAA,KAACC,EAAAA,QAAa,KAAb,CACC,KAAMZ,EAAa,GAAQD,EAC3B,YAAAE,EACA,aAAeY,GAAY,CACrBb,GACJE,GAAA,MAAAA,EAAeW,EACjB,EAEA,SAAA,CAAAC,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,QAAb,CAAqB,QAAO,GAC3B,iCAAC,MAAA,CAAI,gBAAeZ,EAAa,SAAAH,CAAA,CAAQ,CAAA,CAC3C,EAEC,CAACG,GACAc,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,OAAb,CACC,SAAAE,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,QAAb,CACC,KAAAT,EACA,WAAY,EACZ,MAAAC,EACA,MAAOK,EACP,UAAWM,EAAAA,IACT,iBACA,0BACAT,GAAkB,8BAClBE,CAAA,EAEF,cAAaD,EAEb,SAAAO,EAAAA,kBAAAA,IAACE,EAAAA,QAAA,CACC,MACEX,GACES,EAAAA,kBAAAA,IAACF,EAAAA,QAAa,MAAb,CAAmB,MAAO,EAAG,OAAQ,EACpC,SAAAE,EAAAA,kBAAAA,IAAC,OAAI,MAAO,EAAG,OAAQ,EAAG,QAAQ,UAChC,iCAAC,OAAA,CAAK,EAAE,gBAAA,CAAiB,CAAA,CAC3B,CAAA,CACF,EAIH,SAAAhB,CAAA,CAAA,CACH,CAAA,CACF,CACF,CAAA,CAAA,CAAA,CAIR,CAEAF,EAAQ,YAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.es.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as RadixPopover } from \"radix-ui\";\nimport { CSSProperties, ReactNode } from \"react\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { csx } from \"../../utils/string\";\nimport { Overlay } from \"../Overlay/Overlay\";\n\nimport \"../Elevation/Elevation.css\";\nimport \"./Popover.css\";\n\n/** Radix `Popover.Content` `side` */\nexport type PopoverSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n/** Radix `Popover.Content` `align`*/\nexport type PopoverAlign = \"start\" | \"center\" | \"end\";\n\nexport interface PopoverProps {\n /**\n * Popover alignment\n * {@link PopoverAlign}\n */\n align?: PopoverAlign;\n /**\n * Show an arrow pointing to the trigger.\n * @default false\n */\n arrow?: boolean;\n /**\n * The content of the popover.\n */\n children: ReactNode;\n /**\n * Constrain the width of the popover to the width of the trigger.\n */\n constrainWidth?: boolean;\n /**\n * Default open state (uncontrolled mode).\n */\n defaultOpen?: boolean;\n /**\n * Test id for the popover content.\n */\n \"data-testid\"?: string;\n /**\n * Control open state (controlled mode).\n */\n open?: boolean;\n /**\n * Whether the popover is disabled.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Callback when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger element for the popover.\n */\n trigger: ReactNode;\n /**\n * Popover side placement\n * {@link PopoverSide}\n */\n side?: PopoverSide;\n}\n\n/**\n * A popover component that handles positioning and supports controlled and uncontrolled modes.\n *\n * A popover displays interactive content in context with a trigger element.\n * A tooltip displays a description of an element on hover or focus.\n *\n * API:\n * - {@link PopoverProps}\n */\nexport function Popover({\n trigger,\n children,\n open,\n isDisabled = false,\n defaultOpen,\n onOpenChange,\n side = \"top\",\n align = \"center\",\n arrow = false,\n constrainWidth = false,\n \"data-testid\": testId,\n}: PopoverProps) {\n const { className: themeClass, style: themeStyle } = useTheme();\n\n return (\n <RadixPopover.Root\n open={isDisabled ? false : open}\n defaultOpen={defaultOpen}\n onOpenChange={(newOpen) => {\n if (isDisabled) return;\n onOpenChange?.(newOpen);\n }}\n >\n <RadixPopover.Trigger asChild>\n <div aria-disabled={isDisabled}>{trigger}</div>\n </RadixPopover.Trigger>\n\n {!isDisabled && (\n <RadixPopover.Portal>\n <RadixPopover.Content\n side={side}\n sideOffset={2}\n align={align}\n style={themeStyle as CSSProperties}\n className={csx(\n \"proton-Popover\",\n \"proton-Elevation--glass\",\n constrainWidth && \"proton-Popover__constrained\",\n themeClass,\n )}\n data-testid={testId}\n >\n <Overlay\n arrow={\n arrow && (\n <RadixPopover.Arrow width={8} height={8}>\n <svg width={8} height={8} viewBox=\"0 0 8 8\">\n <path d=\"M0 0 L4 4 L8 0\" />\n </svg>\n </RadixPopover.Arrow>\n )\n }\n >\n {children}\n </Overlay>\n </RadixPopover.Content>\n </RadixPopover.Portal>\n )}\n </RadixPopover.Root>\n );\n}\n\nPopover.displayName = \"ProtonUIPopover\";\n"],"names":["Popover","trigger","children","open","isDisabled","defaultOpen","onOpenChange","side","align","arrow","constrainWidth","testId","themeClass","themeStyle","useTheme","jsxs","RadixPopover","newOpen","jsx","csx","Overlay"],"mappings":";;;;;;;AA4EO,SAASA,EAAQ;AAAA,EACtB,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,aAAAC;AAAA,EACA,cAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,OAAAC,IAAQ;AAAA,EACR,gBAAAC,IAAiB;AAAA,EACjB,eAAeC;AACjB,GAAiB;AACf,QAAM,EAAE,WAAWC,GAAY,OAAOC,EAAA,IAAeC,EAAA;AAErD,SACEC,gBAAAA,EAAAA;AAAAA,IAACC,EAAa;AAAA,IAAb;AAAA,MACC,MAAMZ,IAAa,KAAQD;AAAA,MAC3B,aAAAE;AAAA,MACA,cAAc,CAACY,MAAY;AACzB,QAAIb,KACJE,KAAA,QAAAA,EAAeW;AAAA,MACjB;AAAA,MAEA,UAAA;AAAA,QAAAC,gBAAAA,EAAAA,IAACF,EAAa,SAAb,EAAqB,SAAO,IAC3B,gCAAC,OAAA,EAAI,iBAAeZ,GAAa,UAAAH,EAAA,CAAQ,EAAA,CAC3C;AAAA,QAEC,CAACG,KACAc,gBAAAA,EAAAA,IAACF,EAAa,QAAb,EACC,UAAAE,gBAAAA,EAAAA;AAAAA,UAACF,EAAa;AAAA,UAAb;AAAA,YACC,MAAAT;AAAA,YACA,YAAY;AAAA,YACZ,OAAAC;AAAA,YACA,OAAOK;AAAA,YACP,WAAWM;AAAA,cACT;AAAA,cACA;AAAA,cACAT,KAAkB;AAAA,cAClBE;AAAA,YAAA;AAAA,YAEF,eAAaD;AAAA,YAEb,UAAAO,gBAAAA,EAAAA;AAAAA,cAACE;AAAA,cAAA;AAAA,gBACC,OACEX,KACES,gBAAAA,EAAAA,IAACF,EAAa,OAAb,EAAmB,OAAO,GAAG,QAAQ,GACpC,UAAAE,gBAAAA,EAAAA,IAAC,SAAI,OAAO,GAAG,QAAQ,GAAG,SAAQ,WAChC,gCAAC,QAAA,EAAK,GAAE,iBAAA,CAAiB,EAAA,CAC3B,EAAA,CACF;AAAA,gBAIH,UAAAhB;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEAF,EAAQ,cAAc;"}
1
+ {"version":3,"file":"Popover.es.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as RadixPopover } from \"radix-ui\";\nimport { CSSProperties, ReactNode } from \"react\";\nimport { useTheme } from \"../ThemeProvider\";\nimport { csx } from \"../../utils/string\";\nimport type { RadixAlign, RadixSide } from \"../../constants/placement\";\nimport { Overlay } from \"../Overlay/Overlay\";\n\nimport \"../Elevation/Elevation.css\";\nimport \"./Popover.css\";\n\n/** Radix `Popover.Content` `side` */\nexport type PopoverSide = RadixSide;\n/** Radix `Popover.Content` `align`*/\nexport type PopoverAlign = RadixAlign;\n\nexport interface PopoverProps {\n /**\n * Popover alignment\n * {@link PopoverAlign}\n * @default \"center\"\n */\n align?: PopoverAlign;\n /**\n * Show an arrow pointing to the trigger.\n * @default false\n */\n arrow?: boolean;\n /**\n * The content of the popover.\n */\n children: ReactNode;\n /**\n * Constrain the width of the popover to the width of the trigger.\n */\n constrainWidth?: boolean;\n /**\n * Default open state (uncontrolled mode).\n */\n defaultOpen?: boolean;\n /**\n * Test id for the popover content.\n */\n \"data-testid\"?: string;\n /**\n * Control open state (controlled mode).\n */\n open?: boolean;\n /**\n * Whether the popover is disabled.\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Callback when open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The trigger element for the popover.\n */\n trigger: ReactNode;\n /**\n * Popover side placement\n * {@link PopoverSide}\n * @default \"top\"\n */\n side?: PopoverSide;\n}\n\n/**\n * A popover component that handles positioning and supports controlled and uncontrolled modes.\n *\n * A popover displays interactive content in context with a trigger element.\n * A tooltip displays a description of an element on hover or focus.\n *\n * API:\n * - {@link PopoverProps}\n */\nexport function Popover({\n trigger,\n children,\n open,\n isDisabled = false,\n defaultOpen,\n onOpenChange,\n side = \"top\",\n align = \"center\",\n arrow = false,\n constrainWidth = false,\n \"data-testid\": testId,\n}: PopoverProps) {\n const { className: themeClass, style: themeStyle } = useTheme();\n\n return (\n <RadixPopover.Root\n open={isDisabled ? false : open}\n defaultOpen={defaultOpen}\n onOpenChange={(newOpen) => {\n if (isDisabled) return;\n onOpenChange?.(newOpen);\n }}\n >\n <RadixPopover.Trigger asChild>\n <div aria-disabled={isDisabled}>{trigger}</div>\n </RadixPopover.Trigger>\n\n {!isDisabled && (\n <RadixPopover.Portal>\n <RadixPopover.Content\n side={side}\n sideOffset={2}\n align={align}\n style={themeStyle as CSSProperties}\n className={csx(\n \"proton-Popover\",\n \"proton-Elevation--glass\",\n constrainWidth && \"proton-Popover__constrained\",\n themeClass,\n )}\n data-testid={testId}\n >\n <Overlay\n arrow={\n arrow && (\n <RadixPopover.Arrow width={8} height={8}>\n <svg width={8} height={8} viewBox=\"0 0 8 8\">\n <path d=\"M0 0 L4 4 L8 0\" />\n </svg>\n </RadixPopover.Arrow>\n )\n }\n >\n {children}\n </Overlay>\n </RadixPopover.Content>\n </RadixPopover.Portal>\n )}\n </RadixPopover.Root>\n );\n}\n\nPopover.displayName = \"ProtonUIPopover\";\n"],"names":["Popover","trigger","children","open","isDisabled","defaultOpen","onOpenChange","side","align","arrow","constrainWidth","testId","themeClass","themeStyle","useTheme","jsxs","RadixPopover","new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AA,EAAK,GAAE,iBAAA,CAAiB,EAAA,CAC3B,EAAA,CACF;AAAA,gBAIH,UAAAhB;AAAA,cAAA;AAAA,YAAA;AAAA,UACH;AAAA,QAAA,EACF,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEAF,EAAQ,cAAc;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/react/jsx-runtime.cjs.js"),c=require("react"),o=require("radix-ui"),B=require("../ThemeProvider.cjs.js"),A=require("../../hooks/useBreakpoint.cjs.js"),C=require("../ActionMenu/ActionMenu.cjs.js");;/* empty css */;/* empty css */;/* empty css */const R=require("../../utils/string.cjs.js"),U=require("../../constants/breakpoint.cjs.js"),V=require("../Icon/IconComponents/CaretDown.cjs.js"),g=c.forwardRef(({disabled:s,isOpen:r,onClick:n,isRounded:i,selectedItem:a,"data-testid":l},j)=>e.jsxRuntimeExports.jsxs("button",{ref:j,type:"button",role:"combobox","aria-expanded":r,"aria-autocomplete":"none","data-state":r?"open":"closed","data-testid":l,disabled:s,onClick:n,className:R.csx("proton-Select__trigger","proton-Elevation--glass",s&&"proton-Select__trigger--disabled",!r&&"proton-Select__trigger--closed",r&&"proton-Select__trigger--opened",i&&"proton-Select__trigger--rounded"),children:[e.jsxRuntimeExports.jsx("span",{className:"proton-Select__value",children:a?a.label:"Select an option"}),e.jsxRuntimeExports.jsx("span",{className:R.csx("proton-Select__trigger_icon",r&&"proton-Select__trigger_icon--flipped"),children:e.jsxRuntimeExports.jsx(V.CaretDown,{size:16})})]}));g.displayName="ProtonUISelectButton";function N({label:s,name:r,isDisabled:n,disabledKeys:i,selectedKey:a,onSelectionChange:l,defaultSelectedKey:j,onOpen:m,onClose:S,items:h,isRounded:_=!1,"data-testid":f}){const[E,d]=c.useState(!1),p=a!==void 0,[k,v]=c.useState(j??""),{className:I,style:M}=B.useTheme(),T=A.useBreakpoint(U.BREAKPOINTS.MEDIUM),y=c.useRef(null),u=c.useRef(null),x=p?a:k,b=h.find(t=>t.key===x),q=t=>{p||v(t),l==null||l(t),u.current&&(u.current.value=t,u.current.dispatchEvent(new Event("change",{bubbles:!0})))},P=t=>{d(t),t?m==null||m():S==null||S()};c.useEffect(()=>{p&&v(a)},[p]);const w=h.map(t=>({key:t.key,label:t.label,to:t.to,onAction:()=>{q(t.key),d(!1)}}));return T?e.jsxRuntimeExports.jsxs("div",{className:"proton-Select","aria-label":s||r,"aria-disabled":n,children:[s&&e.jsxRuntimeExports.jsx("div",{className:"proton-Select__label","data-testid":"select-label",children:s}),e.jsxRuntimeExports.jsx("input",{ref:u,type:"hidden",name:r,value:x,"data-testid":"hidden-select-container"}),e.jsxRuntimeExports.jsx(g,{isOpen:E,isRounded:_,ref:y,disabled:n,"data-testid":f,onClick:()=>d(!0),selectedItem:b}),e.jsxRuntimeExports.jsx(C.ActionMenu,{isOpen:E,onClose:()=>d(!1),actions:w,selectedKeys:[x],disabledKeys:i})]}):e.jsxRuntimeExports.jsxs("div",{className:"proton-Select","aria-label":s||r,"aria-disabled":n,children:[s&&e.jsxRuntimeExports.jsx("div",{className:"proton-Select__label","data-testid":"select-label",children:s}),e.jsxRuntimeExports.jsx("input",{ref:u,type:"hidden",name:r,value:x,"data-testid":"hidden-select-container"}),e.jsxRuntimeExports.jsxs(o.Select.Root,{value:x,onValueChange:q,onOpenChange:P,disabled:n,children:[e.jsxRuntimeExports.jsx(o.Select.Trigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(g,{isRounded:_,isOpen:E,ref:y,disabled:n,"data-testid":f,selectedItem:b})}),e.jsxRuntimeExports.jsx(o.Select.Portal,{children:e.jsxRuntimeExports.jsx(o.Select.Content,{className:R.csx("proton-Menu","proton-MenuTrigger__menu","proton-Elevation--glass",I),style:M,position:"popper",children:e.jsxRuntimeExports.jsx(o.Select.Viewport,{children:h.map(t=>e.jsxRuntimeExports.jsx(o.Select.Item,{value:t.key,disabled:i==null?void 0:i.includes(t.key),className:"proton-Menu__item",children:e.jsxRuntimeExports.jsx(o.Select.ItemText,{children:t.label})},t.key))})})})]})]})}N.displayName="ProtonUISelect";exports.Select=N;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/react/jsx-runtime.cjs.js"),c=require("react"),o=require("radix-ui"),B=require("../ThemeProvider.cjs.js"),A=require("../../hooks/useBreakpoint.cjs.js"),C=require("../ActionMenu/ActionMenu.cjs.js");;/* empty css */;/* empty css */;/* empty css */const R=require("../../utils/string.cjs.js"),U=require("../../constants/breakpoint.cjs.js"),V=require("../Icon/IconComponents/CaretDown.cjs.js"),g=c.forwardRef(({disabled:s,isOpen:r,onClick:n,isRounded:i,selectedItem:a,ariaLabel:l,"data-testid":m},u)=>e.jsxRuntimeExports.jsxs("button",{ref:u,type:"button",role:"combobox","aria-label":l,"aria-expanded":r,"aria-autocomplete":"none","data-state":r?"open":"closed","data-testid":m,disabled:s,onClick:n,className:R.csx("proton-Select__trigger","proton-Elevation--glass",s&&"proton-Select__trigger--disabled",!r&&"proton-Select__trigger--closed",r&&"proton-Select__trigger--opened",i&&"proton-Select__trigger--rounded"),children:[e.jsxRuntimeExports.jsx("span",{className:"proton-Select__value",children:a?a.label:"Select an option"}),e.jsxRuntimeExports.jsx("span",{className:R.csx("proton-Select__trigger_icon",r&&"proton-Select__trigger_icon--flipped"),children:e.jsxRuntimeExports.jsx(V.CaretDown,{size:16})})]}));g.displayName="ProtonUISelectButton";function N({label:s,name:r,isDisabled:n,disabledKeys:i,selectedKey:a,onSelectionChange:l,defaultSelectedKey:m,onOpen:u,onClose:S,items:h,isRounded:_=!1,"data-testid":f}){const[E,p]=c.useState(!1),j=a!==void 0,[k,v]=c.useState(m??""),{className:I,style:M}=B.useTheme(),T=A.useBreakpoint(U.BREAKPOINTS.MEDIUM),b=c.useRef(null),x=c.useRef(null),d=j?a:k,y=h.find(t=>t.key===d),q=t=>{j||v(t),l==null||l(t),x.current&&(x.current.value=t,x.current.dispatchEvent(new Event("change",{bubbles:!0})))},P=t=>{p(t),t?u==null||u():S==null||S()};c.useEffect(()=>{j&&v(a)},[j]);const w=h.map(t=>({key:t.key,label:t.label,to:t.to,onAction:()=>{q(t.key),p(!1)}}));return T?e.jsxRuntimeExports.jsxs("div",{className:"proton-Select","aria-label":s||r,"aria-disabled":n,children:[s&&e.jsxRuntimeExports.jsx("div",{className:"proton-Select__label","data-testid":"select-label",children:s}),e.jsxRuntimeExports.jsx("input",{ref:x,type:"hidden",name:r,value:d,"data-testid":"hidden-select-container"}),e.jsxRuntimeExports.jsx(g,{isOpen:E,isRounded:_,ref:b,disabled:n,ariaLabel:s||r,"data-testid":f,onClick:()=>p(!0),selectedItem:y}),e.jsxRuntimeExports.jsx(C.ActionMenu,{isOpen:E,onClose:()=>p(!1),actions:w,selectedKeys:[d],disabledKeys:i})]}):e.jsxRuntimeExports.jsxs("div",{className:"proton-Select","aria-label":s||r,"aria-disabled":n,children:[s&&e.jsxRuntimeExports.jsx("div",{className:"proton-Select__label","data-testid":"select-label",children:s}),e.jsxRuntimeExports.jsx("input",{ref:x,type:"hidden",name:r,value:d,"data-testid":"hidden-select-container"}),e.jsxRuntimeExports.jsxs(o.Select.Root,{value:d,onValueChange:q,onOpenChange:P,disabled:n,children:[e.jsxRuntimeExports.jsx(o.Select.Trigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(g,{isRounded:_,isOpen:E,ref:b,disabled:n,ariaLabel:s||r,"data-testid":f,selectedItem:y})}),e.jsxRuntimeExports.jsx(o.Select.Portal,{children:e.jsxRuntimeExports.jsx(o.Select.Content,{className:R.csx("proton-Menu","proton-MenuTrigger__menu","proton-Elevation--glass",I),style:M,position:"popper",children:e.jsxRuntimeExports.jsx(o.Select.Viewport,{children:h.map(t=>e.jsxRuntimeExports.jsx(o.Select.Item,{value:t.key,disabled:i==null?void 0:i.includes(t.key),className:"proton-Menu__item",children:e.jsxRuntimeExports.jsx(o.Select.ItemText,{children:t.label})},t.key))})})})]})]})}N.displayName="ProtonUISelect";exports.Select=N;
2
2
  //# sourceMappingURL=Select.cjs.js.map