@clicoh/orion-library 1.2.0-beta.1 → 1.2.0-beta.10

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 (105) hide show
  1. package/dist/components/01-atoms/Button/Button.d.ts +4 -1
  2. package/dist/components/01-atoms/Button/Button.d.ts.map +1 -1
  3. package/dist/components/01-atoms/Button/Button.jsx +16 -2
  4. package/dist/components/01-atoms/Button/Button.jsx.map +1 -1
  5. package/dist/components/01-atoms/IconButton/IconButton.d.ts +28 -0
  6. package/dist/components/01-atoms/IconButton/IconButton.d.ts.map +1 -0
  7. package/dist/components/01-atoms/IconButton/IconButton.jsx +32 -0
  8. package/dist/components/01-atoms/IconButton/IconButton.jsx.map +1 -0
  9. package/dist/components/01-atoms/IconButton/index.d.ts +2 -0
  10. package/dist/components/01-atoms/IconButton/index.d.ts.map +1 -0
  11. package/dist/components/01-atoms/IconButton/index.js +2 -0
  12. package/dist/components/01-atoms/IconButton/index.js.map +1 -0
  13. package/dist/components/01-atoms/Input/Input.d.ts.map +1 -1
  14. package/dist/components/01-atoms/Input/Input.jsx +3 -2
  15. package/dist/components/01-atoms/Input/Input.jsx.map +1 -1
  16. package/dist/components/01-atoms/Input/utils/border.d.ts +2 -1
  17. package/dist/components/01-atoms/Input/utils/border.d.ts.map +1 -1
  18. package/dist/components/01-atoms/Input/utils/border.js +2 -2
  19. package/dist/components/01-atoms/Input/utils/border.js.map +1 -1
  20. package/dist/components/01-atoms/MultiSelect/MultiSelect.jsx +1 -1
  21. package/dist/components/01-atoms/MultiSelect/MultiSelect.jsx.map +1 -1
  22. package/dist/components/01-atoms/ProgressBar/ProgressBar.d.ts +12 -1
  23. package/dist/components/01-atoms/ProgressBar/ProgressBar.d.ts.map +1 -1
  24. package/dist/components/01-atoms/ProgressBar/ProgressBar.jsx +18 -2
  25. package/dist/components/01-atoms/ProgressBar/ProgressBar.jsx.map +1 -1
  26. package/dist/components/01-atoms/Radio/Radio.jsx +1 -1
  27. package/dist/components/01-atoms/Radio/Radio.jsx.map +1 -1
  28. package/dist/components/01-atoms/Switch/Switch.d.ts +5 -2
  29. package/dist/components/01-atoms/Switch/Switch.d.ts.map +1 -1
  30. package/dist/components/01-atoms/Switch/Switch.jsx +15 -12
  31. package/dist/components/01-atoms/Switch/Switch.jsx.map +1 -1
  32. package/dist/components/01-atoms/Textarea/Textarea.d.ts +38 -0
  33. package/dist/components/01-atoms/Textarea/Textarea.d.ts.map +1 -0
  34. package/dist/components/01-atoms/Textarea/Textarea.jsx +50 -0
  35. package/dist/components/01-atoms/Textarea/Textarea.jsx.map +1 -0
  36. package/dist/components/01-atoms/Textarea/index.d.ts +2 -0
  37. package/dist/components/01-atoms/Textarea/index.d.ts.map +1 -0
  38. package/dist/components/01-atoms/Textarea/index.js +2 -0
  39. package/dist/components/01-atoms/Textarea/index.js.map +1 -0
  40. package/dist/components/01-atoms/Toast/Toast.d.ts.map +1 -1
  41. package/dist/components/01-atoms/Toast/Toast.jsx +3 -1
  42. package/dist/components/01-atoms/Toast/Toast.jsx.map +1 -1
  43. package/dist/components/01-atoms/index.d.ts +2 -0
  44. package/dist/components/01-atoms/index.d.ts.map +1 -1
  45. package/dist/components/01-atoms/index.js +2 -0
  46. package/dist/components/01-atoms/index.js.map +1 -1
  47. package/dist/components/02-molecules/Accordion/Accordion.d.ts +15 -4
  48. package/dist/components/02-molecules/Accordion/Accordion.d.ts.map +1 -1
  49. package/dist/components/02-molecules/Accordion/Accordion.jsx +20 -6
  50. package/dist/components/02-molecules/Accordion/Accordion.jsx.map +1 -1
  51. package/dist/components/02-molecules/Accordion/AccordionContext.d.ts +5 -1
  52. package/dist/components/02-molecules/Accordion/AccordionContext.d.ts.map +1 -1
  53. package/dist/components/02-molecules/Accordion/AccordionContext.jsx +4 -3
  54. package/dist/components/02-molecules/Accordion/AccordionContext.jsx.map +1 -1
  55. package/dist/components/02-molecules/Accordion/AccordionSection.d.ts +2 -1
  56. package/dist/components/02-molecules/Accordion/AccordionSection.d.ts.map +1 -1
  57. package/dist/components/02-molecules/Accordion/AccordionSection.jsx +35 -8
  58. package/dist/components/02-molecules/Accordion/AccordionSection.jsx.map +1 -1
  59. package/dist/components/02-molecules/Accordion/index.d.ts +1 -0
  60. package/dist/components/02-molecules/Accordion/index.d.ts.map +1 -1
  61. package/dist/components/02-molecules/Accordion/index.js.map +1 -1
  62. package/dist/components/02-molecules/Autocomplete/Autocomplete.d.ts +10 -1
  63. package/dist/components/02-molecules/Autocomplete/Autocomplete.d.ts.map +1 -1
  64. package/dist/components/02-molecules/Autocomplete/Autocomplete.jsx +29 -10
  65. package/dist/components/02-molecules/Autocomplete/Autocomplete.jsx.map +1 -1
  66. package/dist/components/02-molecules/DatePicker/DatePicker.jsx +1 -1
  67. package/dist/components/02-molecules/DatePicker/DatePicker.jsx.map +1 -1
  68. package/dist/components/02-molecules/Filter/Filter.d.ts +1 -0
  69. package/dist/components/02-molecules/Filter/Filter.d.ts.map +1 -1
  70. package/dist/components/02-molecules/Filter/Filter.jsx +25 -4
  71. package/dist/components/02-molecules/Filter/Filter.jsx.map +1 -1
  72. package/dist/components/02-molecules/Filter/index.d.ts +1 -0
  73. package/dist/components/02-molecules/Filter/index.d.ts.map +1 -1
  74. package/dist/components/02-molecules/Filter/index.js +1 -0
  75. package/dist/components/02-molecules/Filter/index.js.map +1 -1
  76. package/dist/components/02-molecules/Filter/types.d.ts +24 -5
  77. package/dist/components/02-molecules/Filter/types.d.ts.map +1 -1
  78. package/dist/components/02-molecules/Filter/utils/pruneOrphanValues.d.ts +34 -0
  79. package/dist/components/02-molecules/Filter/utils/pruneOrphanValues.d.ts.map +1 -0
  80. package/dist/components/02-molecules/Filter/utils/pruneOrphanValues.js +70 -0
  81. package/dist/components/02-molecules/Filter/utils/pruneOrphanValues.js.map +1 -0
  82. package/dist/components/02-molecules/ImageViewer/ImageViewer.d.ts +55 -5
  83. package/dist/components/02-molecules/ImageViewer/ImageViewer.d.ts.map +1 -1
  84. package/dist/components/02-molecules/ImageViewer/ImageViewer.jsx +118 -27
  85. package/dist/components/02-molecules/ImageViewer/ImageViewer.jsx.map +1 -1
  86. package/dist/components/02-molecules/ImageViewer/ImageViewerImage.d.ts +40 -0
  87. package/dist/components/02-molecules/ImageViewer/ImageViewerImage.d.ts.map +1 -0
  88. package/dist/components/02-molecules/ImageViewer/ImageViewerImage.jsx +108 -0
  89. package/dist/components/02-molecules/ImageViewer/ImageViewerImage.jsx.map +1 -0
  90. package/dist/components/02-molecules/Modal/Modal.d.ts +5 -1
  91. package/dist/components/02-molecules/Modal/Modal.d.ts.map +1 -1
  92. package/dist/components/02-molecules/Modal/Modal.jsx +7 -5
  93. package/dist/components/02-molecules/Modal/Modal.jsx.map +1 -1
  94. package/dist/components/02-molecules/index.d.ts +1 -0
  95. package/dist/components/02-molecules/index.d.ts.map +1 -1
  96. package/dist/components/02-molecules/index.js +1 -0
  97. package/dist/components/02-molecules/index.js.map +1 -1
  98. package/dist/components/03-organisms/MapView/MapView.d.ts +11 -3
  99. package/dist/components/03-organisms/MapView/MapView.d.ts.map +1 -1
  100. package/dist/components/03-organisms/MapView/MapView.jsx +33 -4
  101. package/dist/components/03-organisms/MapView/MapView.jsx.map +1 -1
  102. package/dist/components/04-templates/SideFilterTemplate/SideFilterTemplate.d.ts.map +1 -1
  103. package/dist/components/04-templates/SideFilterTemplate/SideFilterTemplate.jsx +4 -1
  104. package/dist/components/04-templates/SideFilterTemplate/SideFilterTemplate.jsx.map +1 -1
  105. package/package.json +3 -2
@@ -0,0 +1,38 @@
1
+ import { type DetailedHTMLProps, type ReactNode, type TextareaHTMLAttributes } from 'react';
2
+ type TextareaProps = {
3
+ label: string;
4
+ textarea: Omit<DetailedHTMLProps<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'placeholder'>;
5
+ helperText?: string;
6
+ error?: string;
7
+ placeholder?: string;
8
+ hideLabel?: boolean;
9
+ };
10
+ /**
11
+ * Textarea component for multi-line text, matching Input's border, color, disabled and error
12
+ * states. It uses a static label above the field instead of Input's floating notch: a floating
13
+ * label has no natural resting place once the field grows past one line.
14
+ *
15
+ * @component
16
+ * @example
17
+ * // Example usage of Textarea component
18
+ * <Textarea
19
+ * label="Observaciones"
20
+ * textarea={{ value: 'Texto', rows: 3, onChange: () => console.log('Textarea changed') }}
21
+ * placeholder="Notas operativas"
22
+ * helperText="Opcional"
23
+ * error="Campo requerido"
24
+ * />
25
+ *
26
+ * @param {Object} props - The properties of the Textarea component.
27
+ * @param {string} props.label - The label text shown above the field.
28
+ * @param {Object} props.textarea - Native textarea attributes (value, rows, onChange, disabled, ...).
29
+ * @param {string} [props.helperText] - Optional helper text to be displayed below the field.
30
+ * @param {string} [props.error] - Optional error message to be displayed below the field.
31
+ * @param {string} [props.placeholder] - Placeholder shown inside the field.
32
+ * @param {boolean} [props.hideLabel] - Keeps the label for assistive technology only.
33
+ *
34
+ * @returns {ReactNode} The rendered Textarea component.
35
+ */
36
+ export declare function Textarea({ label, textarea, helperText, error, placeholder, hideLabel, }: TextareaProps): ReactNode;
37
+ export {};
38
+ //# sourceMappingURL=Textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../../../src/components/01-atoms/Textarea/Textarea.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAE5B,MAAM,OAAO,CAAC;AAGf,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,CACZ,iBAAiB,CACf,sBAAsB,CAAC,mBAAmB,CAAC,EAC3C,mBAAmB,CACpB,EACD,aAAa,CACd,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,QAAQ,EACR,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAiB,GAClB,EAAE,aAAa,GAAG,SAAS,CA+C3B"}
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import clsx from 'clsx';
3
+ import { useId, } from 'react';
4
+ import { RenderErrorOrHelperText } from '../Input/utils/RenderErrorOrHelperText';
5
+ /**
6
+ * Textarea component for multi-line text, matching Input's border, color, disabled and error
7
+ * states. It uses a static label above the field instead of Input's floating notch: a floating
8
+ * label has no natural resting place once the field grows past one line.
9
+ *
10
+ * @component
11
+ * @example
12
+ * // Example usage of Textarea component
13
+ * <Textarea
14
+ * label="Observaciones"
15
+ * textarea={{ value: 'Texto', rows: 3, onChange: () => console.log('Textarea changed') }}
16
+ * placeholder="Notas operativas"
17
+ * helperText="Opcional"
18
+ * error="Campo requerido"
19
+ * />
20
+ *
21
+ * @param {Object} props - The properties of the Textarea component.
22
+ * @param {string} props.label - The label text shown above the field.
23
+ * @param {Object} props.textarea - Native textarea attributes (value, rows, onChange, disabled, ...).
24
+ * @param {string} [props.helperText] - Optional helper text to be displayed below the field.
25
+ * @param {string} [props.error] - Optional error message to be displayed below the field.
26
+ * @param {string} [props.placeholder] - Placeholder shown inside the field.
27
+ * @param {boolean} [props.hideLabel] - Keeps the label for assistive technology only.
28
+ *
29
+ * @returns {ReactNode} The rendered Textarea component.
30
+ */
31
+ export function Textarea({ label, textarea, helperText, error, placeholder, hideLabel = false, }) {
32
+ const generatedId = useId();
33
+ const id = textarea.id ?? generatedId;
34
+ const descriptionId = error || helperText ? `${id}-description` : undefined;
35
+ const describedBy = [textarea['aria-describedby'], descriptionId].filter(Boolean).join(' ') ||
36
+ undefined;
37
+ const textareaClasses = clsx('w-full resize-y rounded-lg border bg-transparent p-3.5 text-sm text-black transition-colors outline-none placeholder:text-gray-2 dark:text-white dark:placeholder:text-gray-2', 'disabled:border-gray-3 disabled:text-gray-3 dark:disabled:border-gray-2 dark:disabled:text-gray-2 disabled:cursor-not-allowed', error
38
+ ? 'border-error focus:border-error focus:ring-error dark:border-error-dark dark:focus:border-error-dark dark:focus:ring-error-dark focus:ring-2'
39
+ : 'border-black hover:border-gray-1 focus:border-lavender focus:ring-lavender dark:border-white dark:hover:border-gray-2 focus:ring-2', textarea.className);
40
+ return (<div className="w-full max-w-full">
41
+ {hideLabel ? (<label htmlFor={id} className="sr-only">
42
+ {label}
43
+ </label>) : (<label htmlFor={id} className="text-gray-1 mb-1.5 ml-0.5 block text-xs font-semibold">
44
+ {label}
45
+ </label>)}
46
+ <textarea {...textarea} id={id} className={textareaClasses} placeholder={placeholder} aria-invalid={error ? true : textarea['aria-invalid']} aria-describedby={describedBy}/>
47
+ <RenderErrorOrHelperText id={descriptionId} disabled={textarea.disabled} helperText={helperText} error={error}/>
48
+ </div>);
49
+ }
50
+ //# sourceMappingURL=Textarea.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Textarea.jsx","sourceRoot":"","sources":["../../../../src/components/01-atoms/Textarea/Textarea.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAIL,KAAK,GACN,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAiBjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,KAAK,EACL,QAAQ,EACR,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,GAAG,KAAK,GACH;IACd,MAAM,WAAW,GAAG,KAAK,EAAE,CAAC;IAC5B,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,WAAW,CAAC;IACtC,MAAM,aAAa,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,S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AAC,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Textarea } from './Textarea';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/01-atoms/Textarea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { Textarea } from './Textarea';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/01-atoms/Textarea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../src/components/01-atoms/Toast/Toast.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,KAAK,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AA+B5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAY9D"}
1
+ {"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../src/components/01-atoms/Toast/Toast.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,KAAK,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AA+B5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAgB9D"}
@@ -27,7 +27,9 @@ const backgroundClasses = {
27
27
  * @returns {void}
28
28
  */
29
29
  export function showToast(content, type) {
30
- toastFn(<Paragraph className="text-black dark:text-white">{content}</Paragraph>, {
30
+ // A render function instead of an element: react-toastify clones a plain element
31
+ // with `closeToast`/`toastProps`, which `Paragraph` would forward to the DOM `<p>`.
32
+ toastFn(() => (<Paragraph className="text-black dark:text-white">{content}</Paragraph>), {
31
33
  position: 'top-right',
32
34
  hideProgressBar: true,
33
35
  pauseOnFocusLoss: false,
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.jsx","sourceRoot":"","sources":["../../../../src/components/01-atoms/Toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,MAAM,WAAW,GAAG,IAAI,CAAC,sCAAsC,CAAC,CAAC;AAEjE,MAAM,KAAK,GAA4B;IACrC,OAAO,EAAE,CACP,CAAC,OAAO,CACN,WAAW,CAAC,MAAM,CAClB,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,iCAAiC,CAAC,CAAC,EAChE,CACH;IACD,OAAO,EAAE,CACP,CAAC,SAAS,CACR,WAAW,CAAC,MAAM,CAClB,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,iCAAiC,CAAC,CAAC,EAChE,CACH;IACD,KAAK,EAAE,CACL,CAAC,OAAO,CACN,WAAW,CAAC,MAAM,CAClB,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC,EAC5D,CACH;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAyB;IAC9C,OAAO,EAAE,qCAAqC;IAC9C,OAAO,EAAE,qCAAqC;IAC9C,KAAK,EAAE,iCAAiC;CACzC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,OA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AAqC;IAC9C,OAAO,EAAE,qCAAqC;IAC9C,KAAK,EAAE,iCAAiC;CACzC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,OAAkB,EAAE,IAAU;IACtD,iFAAiF;IACjF,oFAAoF;IACpF,OAAO,CACL,GAAG,EAAE,CAAC,CACJ,CAAC,SAAS,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CACxE,EACD;QACE,QAAQ,EAAE,WAAW;QACrB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,KAAK;QACvB,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QACvB,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC;KACnC,CACF,CAAC;AACJ,CAAC"}
@@ -2,8 +2,10 @@ export * from './List';
2
2
  export * from './Logo';
3
3
  export * from './Badge';
4
4
  export * from './Input';
5
+ export * from './Textarea';
5
6
  export * from './Radio';
6
7
  export * from './Button';
8
+ export * from './IconButton';
7
9
  export * from './Select';
8
10
  export * from './Heading';
9
11
  export * from './Checkbox';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/01-atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/01-atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
@@ -2,8 +2,10 @@ export * from './List';
2
2
  export * from './Logo';
3
3
  export * from './Badge';
4
4
  export * from './Input';
5
+ export * from './Textarea';
5
6
  export * from './Radio';
6
7
  export * from './Button';
8
+ export * from './IconButton';
7
9
  export * from './Select';
8
10
  export * from './Heading';
9
11
  export * from './Checkbox';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/01-atoms/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AAC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ReactNode } from 'react';
2
2
  import { AccordionSectionProps } from './AccordionSection';
3
+ import { type AccordionModifier } from './AccordionContext';
4
+ export type { AccordionModifier };
3
5
  type AccordionProps = {
4
6
  children: ReactElement<AccordionSectionProps> | ReactElement<AccordionSectionProps>[];
5
7
  className?: string;
8
+ modifier?: AccordionModifier;
9
+ defaultActivated?: string[];
6
10
  };
7
11
  /**
8
12
  * Accordion component for displaying a list of collapsible sections.
@@ -11,16 +15,23 @@ type AccordionProps = {
11
15
  * @example
12
16
  * // Example usage of Accordion component
13
17
  * <Accordion className="custom-class">
14
- * <AccordionSection title="Section 1">Content 1</AccordionSection>
15
- * <AccordionSection title="Section 2">Content 2</AccordionSection>
18
+ * <AccordionSection title="Section 1" id="1">Content 1</AccordionSection>
19
+ * <AccordionSection title="Section 2" id="2">Content 2</AccordionSection>
20
+ * </Accordion>
21
+ *
22
+ * @example
23
+ * // Flat headers, with the first section open on mount
24
+ * <Accordion modifier="plain" defaultActivated={['1']}>
25
+ * <AccordionSection title="Section 1" id="1">Content 1</AccordionSection>
16
26
  * </Accordion>
17
27
  *
18
28
  * @param {Object} props - The properties of the Accordion component.
19
29
  * @param {ReactElement<AccordionSectionProps> | ReactElement<AccordionSectionProps>[]} props.children - The AccordionSection components to be displayed within the Accordion.
20
30
  * @param {string} [props.className] - Optional additional class names for the Accordion container.
31
+ * @param {AccordionModifier} [props.modifier='pill'] - `pill` draws each header as a pill with a bottom border; `plain` draws a flat header and separates the sections with a rule.
32
+ * @param {string[]} [props.defaultActivated=[]] - Ids of the sections that start open. Read on mount only; afterwards the user toggles them.
21
33
  *
22
34
  * @returns {ReactNode} The rendered Accordion component.
23
35
  */
24
- export declare function Accordion({ children, className }: AccordionProps): ReactNode;
25
- export {};
36
+ export declare function Accordion({ children, className, modifier, defaultActivated, }: AccordionProps): ReactNode;
26
37
  //# sourceMappingURL=Accordion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/Accordion.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,KAAK,cAAc,GAAG;IACpB,QAAQ,EACJ,YAAY,CAAC,qBAAqB,CAAC,GACnC,YAAY,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,cAAc,GAAG,SAAS,CAM5E"}
1
+ {"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/Accordion.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,KAAK,cAAc,GAAG;IACpB,QAAQ,EACJ,YAAY,CAAC,qBAAqB,CAAC,GACnC,YAAY,CAAC,qBAAqB,CAAC,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAOF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,QAAiB,EACjB,gBAAgB,GACjB,EAAE,cAAc,GAAG,SAAS,CAW5B"}
@@ -1,7 +1,11 @@
1
1
  'use client';
2
2
  import React from 'react';
3
- import { AccordionContextProvider } from './AccordionContext';
3
+ import { AccordionContextProvider, } from './AccordionContext';
4
4
  import clsx from 'clsx';
5
+ const styleMap = {
6
+ pill: 'gap-3',
7
+ plain: 'divide-gray-5 dark:divide-gray-1 divide-y',
8
+ };
5
9
  /**
6
10
  * Accordion component for displaying a list of collapsible sections.
7
11
  *
@@ -9,19 +13,29 @@ import clsx from 'clsx';
9
13
  * @example
10
14
  * // Example usage of Accordion component
11
15
  * <Accordion className="custom-class">
12
- * <AccordionSection title="Section 1">Content 1</AccordionSection>
13
- * <AccordionSection title="Section 2">Content 2</AccordionSection>
16
+ * <AccordionSection title="Section 1" id="1">Content 1</AccordionSection>
17
+ * <AccordionSection title="Section 2" id="2">Content 2</AccordionSection>
18
+ * </Accordion>
19
+ *
20
+ * @example
21
+ * // Flat headers, with the first section open on mount
22
+ * <Accordion modifier="plain" defaultActivated={['1']}>
23
+ * <AccordionSection title="Section 1" id="1">Content 1</AccordionSection>
14
24
  * </Accordion>
15
25
  *
16
26
  * @param {Object} props - The properties of the Accordion component.
17
27
  * @param {ReactElement<AccordionSectionProps> | ReactElement<AccordionSectionProps>[]} props.children - The AccordionSection components to be displayed within the Accordion.
18
28
  * @param {string} [props.className] - Optional additional class names for the Accordion container.
29
+ * @param {AccordionModifier} [props.modifier='pill'] - `pill` draws each header as a pill with a bottom border; `plain` draws a flat header and separates the sections with a rule.
30
+ * @param {string[]} [props.defaultActivated=[]] - Ids of the sections that start open. Read on mount only; afterwards the user toggles them.
19
31
  *
20
32
  * @returns {ReactNode} The rendered Accordion component.
21
33
  */
22
- export function Accordion({ children, className }) {
23
- return (<div className={clsx('grid gap-3', className)}>
24
- <AccordionContextProvider>{children}</AccordionContextProvider>
34
+ export function Accordion({ children, className, modifier = 'pill', defaultActivated, }) {
35
+ return (<div className={clsx('grid', styleMap[modifier], className)}>
36
+ <AccordionContextProvider defaultActivated={defaultActivated} modifier={modifier}>
37
+ {children}
38
+ </AccordionContextProvider>
25
39
  </div>);
26
40
  }
27
41
  //# sourceMappingURL=Accordion.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"Accordion.jsx","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAkB;IAC/D,OAAO,CACL,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAC5C;MAAA,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,EAAE,wBAAwB,CAChE;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"Accordion.jsx","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/Accordion.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,KAAkC,MAAM,OAAO,CAAC;AAEvD,OAAO,EAEL,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AAaxB,MAAM,QAAQ,GAAsC;IAClD,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,2CAA2C;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,QAAQ,EACR,SAAS,EACT,QAAQ,GAAG,MAAM,EACjB,gBAAgB,GACD;IACf,OAAO,CACL,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAC1D;MAAA,CAAC,wBAAwB,CACvB,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAEnB;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,wBAAwB,CAC5B;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC"}
@@ -1,9 +1,13 @@
1
+ export type AccordionModifier = 'pill' | 'plain';
1
2
  export interface AccordionContextProps {
2
3
  activated: string[];
3
4
  toggleId: (id: string) => void;
5
+ modifier: AccordionModifier;
4
6
  }
5
- export declare function AccordionContextProvider({ children, }: {
7
+ export declare function AccordionContextProvider({ children, defaultActivated, modifier, }: {
6
8
  readonly children: React.ReactNode;
9
+ readonly defaultActivated?: string[];
10
+ readonly modifier?: AccordionModifier;
7
11
  }): import("react").JSX.Element;
8
12
  export declare function useAccordionContext(): AccordionContextProps;
9
13
  //# sourceMappingURL=AccordionContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionContext.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionContext.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAMD,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CACpC,+BAwBA;AAED,wBAAgB,mBAAmB,0BAUlC"}
1
+ {"version":3,"file":"AccordionContext.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionContext.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAMD,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,gBAAqB,EACrB,QAAiB,GAClB,EAAE;IACD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CACvC,+BAyBA;AAED,wBAAgB,mBAAmB,0BAUlC"}
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
  import { createContext, useContext, useMemo, useState } from 'react';
3
3
  const AccordionContext = createContext(undefined);
4
- export function AccordionContextProvider({ children, }) {
5
- const [activated, setActivated] = useState([]);
4
+ export function AccordionContextProvider({ children, defaultActivated = [], modifier = 'pill', }) {
5
+ const [activated, setActivated] = useState(defaultActivated);
6
6
  const stableActivated = useMemo(() => [...activated], [activated]);
7
7
  const toggleId = (id) => {
8
8
  if (activated.includes(id)) {
@@ -15,7 +15,8 @@ export function AccordionContextProvider({ children, }) {
15
15
  const value = useMemo(() => ({
16
16
  activated: stableActivated,
17
17
  toggleId,
18
- }), [stableActivated]);
18
+ modifier,
19
+ }), [stableActivated, modifier]);
19
20
  return (<AccordionContext.Provider value={value}>
20
21
  {children}
21
22
  </AccordionContext.Provider>);
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionContext.jsx","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAOrE,MAAM,gBAAgB,GAAG,aAAa,CACpC,SAAS,CACV,CAAC;AAEF,MAAM,UAAU,wBAAwB,CAAC,EACvC,QAAQ,GAGT;IACC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACzD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,CAAC,EAAU,EAAE,EAAE;QAC9B,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YAC3B,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,CAAC,GAAG,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS,EAAE,eAAe;QAC1B,QAAQ;KACT,CAAC,EACF,CAAC,eAAe,CAAC,CAClB,CAAC;IAEF,OAAO,CACL,CAAC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACtC;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"AccordionContext.jsx","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUrE,MAAM,gBAAgB,GAAG,aAAa,CACpC,SAAS,CACV,CAAC;AAEF,MAAM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
7
7
  /**
8
8
  * AccordionSection component for displaying a collapsible section within an Accordion.
9
+ * The header takes the `modifier` of the parent Accordion.
9
10
  *
10
11
  * @component
11
12
  * @example
@@ -17,7 +18,7 @@ export type AccordionSectionProps = {
17
18
  * @param {Object} props - The properties of the AccordionSection component.
18
19
  * @param {string} props.title - The title of the section.
19
20
  * @param {ReactNode} props.children - The content to be displayed within the section.
20
- * @param {string} props.id - The unique identifier for the section.
21
+ * @param {string} props.id - The unique identifier for the section, also used by the Accordion `defaultActivated` prop.
21
22
  *
22
23
  * @returns {ReactNode} The rendered AccordionSection component.
23
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionSection.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,EAAE,GACH,EAAE,qBAAqB,GAAG,SAAS,CA+DnC"}
1
+ {"version":3,"file":"AccordionSection.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionSection.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAOf,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA0BF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,EAAE,GACH,EAAE,qBAAqB,GAAG,SAAS,CA8EnC"}
@@ -2,9 +2,28 @@
2
2
  import clsx from 'clsx';
3
3
  import { useCallback, useEffect, useId, useRef, useState, } from 'react';
4
4
  import { FaChevronDown } from 'react-icons/fa';
5
- import { useAccordionContext } from './AccordionContext';
5
+ import { useAccordionContext, } from './AccordionContext';
6
+ const triggerStyleMap = {
7
+ pill: 'mb-2 rounded-full border-b-[3px] px-4 py-2',
8
+ plain: 'rounded-sm py-3',
9
+ };
10
+ const triggerStateStyleMap = {
11
+ pill: {
12
+ active: 'border-lavender dark:border-lavender-dark',
13
+ inactive: 'border-gray-2 dark:border-gray-1',
14
+ },
15
+ plain: {
16
+ active: '',
17
+ inactive: '',
18
+ },
19
+ };
20
+ const chevronStyleMap = {
21
+ pill: '',
22
+ plain: 'size-3 text-gray-1 dark:text-gray-2',
23
+ };
6
24
  /**
7
25
  * AccordionSection component for displaying a collapsible section within an Accordion.
26
+ * The header takes the `modifier` of the parent Accordion.
8
27
  *
9
28
  * @component
10
29
  * @example
@@ -16,7 +35,7 @@ import { useAccordionContext } from './AccordionContext';
16
35
  * @param {Object} props - The properties of the AccordionSection component.
17
36
  * @param {string} props.title - The title of the section.
18
37
  * @param {ReactNode} props.children - The content to be displayed within the section.
19
- * @param {string} props.id - The unique identifier for the section.
38
+ * @param {string} props.id - The unique identifier for the section, also used by the Accordion `defaultActivated` prop.
20
39
  *
21
40
  * @returns {ReactNode} The rendered AccordionSection component.
22
41
  */
@@ -24,7 +43,8 @@ export function AccordionSection({ title, children, id, }) {
24
43
  const context = useAccordionContext();
25
44
  const isActivated = context.activated.includes(id);
26
45
  const contentRef = useRef(null);
27
- const [maxHeight, setMaxHeight] = useState('0px');
46
+ // A section that starts open renders at full height instead of animating in.
47
+ const [maxHeight, setMaxHeight] = useState(isActivated ? 'none' : '0px');
28
48
  const generatedId = useId();
29
49
  const triggerId = `${generatedId}-trigger`;
30
50
  const panelId = `${generatedId}-panel`;
@@ -41,15 +61,22 @@ export function AccordionSection({ title, children, id, }) {
41
61
  window.addEventListener('resize', updateHeight);
42
62
  return () => window.removeEventListener('resize', updateHeight);
43
63
  }, [updateHeight]);
64
+ useEffect(() => {
65
+ const content = contentRef.current?.firstElementChild;
66
+ if (!content || typeof ResizeObserver === 'undefined') {
67
+ return;
68
+ }
69
+ const observer = new ResizeObserver(updateHeight);
70
+ observer.observe(content);
71
+ return () => observer.disconnect();
72
+ }, [updateHeight]);
44
73
  return (<section className="text-black dark:text-white">
45
- <button type="button" id={triggerId} aria-expanded={isActivated} aria-controls={panelId} className={clsx('focus-visible:ring-lavender mb-2 flex w-full cursor-pointer items-center justify-between rounded-full border-b-[3px] px-4 py-2 text-left text-sm font-semibold transition-colors duration-300 ease-in-out focus-visible:ring-2 focus-visible:outline-none', isActivated
46
- ? 'border-lavender dark:border-lavender-dark'
47
- : 'border-gray-2 dark:border-gray-1')} onClick={() => context.toggleId(id)}>
74
+ <button type="button" id={triggerId} aria-expanded={isActivated} aria-controls={panelId} className={clsx('focus-visible:ring-lavender flex w-full cursor-pointer items-center justify-between text-left text-sm font-semibold transition-colors duration-300 ease-in-out focus-visible:ring-2 focus-visible:outline-none', triggerStyleMap[context.modifier], triggerStateStyleMap[context.modifier][isActivated ? 'active' : 'inactive'])} onClick={() => context.toggleId(id)}>
48
75
  <span>{title}</span>
49
- <FaChevronDown aria-hidden className={clsx('transition-transform duration-300 ease-in-out', isActivated && 'rotate-180 transform')}/>
76
+ <FaChevronDown aria-hidden className={clsx('transition-transform duration-300 ease-in-out', chevronStyleMap[context.modifier], isActivated && 'rotate-180 transform')}/>
50
77
  </button>
51
78
  <div ref={contentRef} id={panelId} role="region" aria-labelledby={triggerId} hidden={!isActivated} style={{ maxHeight }} className="overflow-hidden text-black transition-all duration-300 ease-in-out dark:text-white">
52
- {children}
79
+ <div>{children}</div>
53
80
  </div>
54
81
  </section>);
55
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionSection.jsx","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/AccordionSection.tsx"],"names":[],"mappings":"A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C,CAAC,IAAI,CACb,gNAAgN,EAChN,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,EACjC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CACpC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CACpC,CACF,CAAC,CACF,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAEpC;QAAA,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CACnB;QAAA,CAAC,aAAa,CACZ,WAAW,CACX,SAAS,CAAC,CAAC,IAAI,CACb,+CAA+C,EAC/C,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,EACjC,WAAW,IAAI,sBAAsB,CACtC,CAAC,EAEN;MAAA,EAAE,MAAM,CACR;MAAA,CAAC,GAAG,CACF,GAAG,CAAC,CAAC,UAAU,CAAC,CAChB,EAAE,CAAC,CAAC,OAAO,CAAC,CACZ,IAAI,CAAC,QAAQ,CACb,eAAe,CAAC,CAAC,SAAS,CAAC,CAC3B,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CACrB,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CACrB,SAAS,CAAC,oFAAoF,CAE9F;QAAA,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,GAAG,CACtB;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,OAAO,CAAC,CACX,CAAC;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { Accordion } from './Accordion';
2
+ export type { AccordionModifier } from './Accordion';
2
3
  export { AccordionSection } from './AccordionSection';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/02-molecules/Accordion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -14,7 +14,11 @@ type AutocompleteInput = {
14
14
  error?: string;
15
15
  value?: string;
16
16
  isMutedWhenEmpty?: boolean;
17
+ hideLabel?: boolean;
18
+ placeholder?: string;
17
19
  toggleButtonLabel?: string;
20
+ /** Hides the dropdown-toggle chevron — use for search-as-you-type fields with no closed list to browse. */
21
+ hideToggleButton?: boolean;
18
22
  noOptionsText?: string;
19
23
  };
20
24
  /**
@@ -41,11 +45,16 @@ type AutocompleteInput = {
41
45
  * @param {string} props.label - The label text for the input field.
42
46
  * @param {string} [props.helperText] - Helper text displayed below the input.
43
47
  * @param {boolean} [props.isMutedWhenEmpty] - Renders the border and label in gray while the field has no value.
48
+ * @param {boolean} [props.hideLabel] - Keeps the label for assistive technology only and drops the floating label. Use it when a heading outside the field already names it.
49
+ * @param {string} [props.placeholder] - Placeholder shown inside the field. Only rendered together with `hideLabel`.
50
+ * @param {string} [props.toggleButtonLabel] - Accessible name of the button that opens and closes the list.
51
+ * @param {boolean} [props.hideToggleButton] - Hides the dropdown-toggle chevron, for search-as-you-type fields with no closed list to browse.
52
+ * @param {string} [props.noOptionsText='No hay opciones'] - Text shown when the query matches nothing.
44
53
  * @param {string} [props.error] - Error message displayed below the input.
45
54
  * @param {string} [props.value=''] - The controlled value of the input.
46
55
  *
47
56
  * @returns {ReactNode} The rendered Autocomplete component.
48
57
  */
49
- export declare function Autocomplete({ options, onSelect, onChange, onDebouncedChange, debounceDelay, onHandleKeyDown, disabled, label, helperText, error, value, isMutedWhenEmpty, toggleButtonLabel, noOptionsText, }: Readonly<AutocompleteInput>): ReactNode;
58
+ export declare function Autocomplete({ options, onSelect, onChange, onDebouncedChange, debounceDelay, onHandleKeyDown, disabled, label, helperText, error, value, isMutedWhenEmpty, hideLabel, placeholder, toggleButtonLabel, hideToggleButton, noOptionsText, }: Readonly<AutocompleteInput>): ReactNode;
50
59
  export {};
51
60
  //# sourceMappingURL=Autocomplete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,CAClB,KAAK,EAAE,MAAM,KACV,IAAI,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,aAAmB,EACnB,eAAe,EACf,QAAQ,EACR,KAAK,EACL,UAAU,EACV,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAiC,GAClC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,SAAS,CA6RzC"}
1
+ {"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/02-molecules/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,iBAAiB,CAAC,EAAE,CAClB,KAAK,EAAE,MAAM,KACV,IAAI,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,GAAG,SAAS,KAAK,IAAI,CAAC;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2GAA2G;IAC3G,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,aAAmB,EACnB,eAAe,EACf,QAAQ,EACR,KAAK,EACL,UAAU,EACV,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,aAAiC,GAClC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,SAAS,CA4SzC"}
@@ -28,16 +28,24 @@ import { debounce } from '../../../utils';
28
28
  * @param {string} props.label - The label text for the input field.
29
29
  * @param {string} [props.helperText] - Helper text displayed below the input.
30
30
  * @param {boolean} [props.isMutedWhenEmpty] - Renders the border and label in gray while the field has no value.
31
+ * @param {boolean} [props.hideLabel] - Keeps the label for assistive technology only and drops the floating label. Use it when a heading outside the field already names it.
32
+ * @param {string} [props.placeholder] - Placeholder shown inside the field. Only rendered together with `hideLabel`.
33
+ * @param {string} [props.toggleButtonLabel] - Accessible name of the button that opens and closes the list.
34
+ * @param {boolean} [props.hideToggleButton] - Hides the dropdown-toggle chevron, for search-as-you-type fields with no closed list to browse.
35
+ * @param {string} [props.noOptionsText='No hay opciones'] - Text shown when the query matches nothing.
31
36
  * @param {string} [props.error] - Error message displayed below the input.
32
37
  * @param {string} [props.value=''] - The controlled value of the input.
33
38
  *
34
39
  * @returns {ReactNode} The rendered Autocomplete component.
35
40
  */
36
- export function Autocomplete({ options, onSelect, onChange, onDebouncedChange, debounceDelay = 200, onHandleKeyDown, disabled, label, helperText, error, value, isMutedWhenEmpty, toggleButtonLabel, noOptionsText = 'No hay opciones', }) {
41
+ export function Autocomplete({ options, onSelect, onChange, onDebouncedChange, debounceDelay = 200, onHandleKeyDown, disabled, label, helperText, error, value, isMutedWhenEmpty, hideLabel, placeholder, toggleButtonLabel, hideToggleButton, noOptionsText = 'No hay opciones', }) {
37
42
  const [query, setQuery] = useState(value ?? '');
38
43
  const [filteredOptions, setFilteredOptions] = useState([]);
39
44
  const [isOpen, setIsOpen] = useState(false);
40
45
  const [activeIndex, setActiveIndex] = useState(-1);
46
+ // True between a keystroke and its debounced remote result: the "no options" row
47
+ // must not flash while the consumer is still fetching.
48
+ const [isSearching, setIsSearching] = useState(false);
41
49
  const listboxId = useId();
42
50
  const containerRef = useRef(null);
43
51
  const justSelectedRef = useRef(false);
@@ -55,9 +63,18 @@ export function Autocomplete({ options, onSelect, onChange, onDebouncedChange, d
55
63
  setFilteredOptions([]);
56
64
  setIsOpen(false);
57
65
  setActiveIndex(-1);
66
+ setIsSearching(false);
58
67
  return;
59
68
  }
60
- const result = await onDebouncedChangeRef.current?.(q);
69
+ let result;
70
+ try {
71
+ result = await onDebouncedChangeRef.current?.(q);
72
+ }
73
+ finally {
74
+ if (latestQueryRef.current === q) {
75
+ setIsSearching(false);
76
+ }
77
+ }
61
78
  if (latestQueryRef.current !== q) {
62
79
  return;
63
80
  }
@@ -84,6 +101,7 @@ export function Autocomplete({ options, onSelect, onChange, onDebouncedChange, d
84
101
  }
85
102
  setFilteredOptions(options.filter((option) => option.label.toLowerCase().includes(newQuery.toLowerCase())));
86
103
  setIsOpen(true);
104
+ setIsSearching(Boolean(onDebouncedChangeRef.current));
87
105
  onChange?.(newQuery);
88
106
  debouncedCallback(newQuery);
89
107
  };
@@ -214,14 +232,15 @@ export function Autocomplete({ options, onSelect, onChange, onDebouncedChange, d
214
232
  'aria-activedescendant': isOpen && activeIndex >= 0
215
233
  ? `${listboxId}-option-${activeIndex}`
216
234
  : undefined,
217
- }} iconR={handleIcon()} helperText={helperText} error={error} isMutedWhenEmpty={isMutedWhenEmpty}/>
218
- {!!isOpen && (<ul id={listboxId} role="listbox" className="dark:bg-black-1 absolute z-40 flex max-h-28 w-full flex-col gap-y-1 overflow-y-auto rounded-md bg-white px-3 py-2 shadow-lg dark:text-white">
219
- {filteredOptions?.length > 0 ? (filteredOptions.map((option, index) => (<li key={option.value} id={`${listboxId}-option-${index}`} role="option" aria-selected={activeIndex === index} className={clsx('hover:bg-gray-5 dark:hover:bg-gray-1 cursor-pointer rounded-sm px-1 py-0.5', activeIndex === index && 'bg-gray-5 dark:bg-gray-1')} onMouseEnter={() => setActiveIndex(index)} onMouseDown={(event) => event.preventDefault()} onClick={() => handleOptionClick(option)}>
220
- {option.label}
221
- </li>))) : hasSearchQuery ? (<li role="option" aria-disabled="true" className="autocomplete-option no-options">
222
- {noOptionsText}
223
- </li>) : null}
224
- </ul>)}
235
+ }} iconR={hideToggleButton ? undefined : handleIcon()} helperText={helperText} error={error} isMutedWhenEmpty={isMutedWhenEmpty} hideLabel={hideLabel} placeholder={placeholder}/>
236
+ {!!isOpen &&
237
+ (filteredOptions.length > 0 || (hasSearchQuery && !isSearching)) && (<ul id={listboxId} role="listbox" className="dark:bg-black-1 absolute z-40 flex max-h-28 w-full flex-col gap-y-1 overflow-y-auto rounded-md bg-white px-3 py-2 shadow-lg dark:text-white">
238
+ {filteredOptions?.length > 0 ? (filteredOptions.map((option, index) => (<li key={option.value} id={`${listboxId}-option-${index}`} role="option" aria-selected={activeIndex === index} className={clsx('hover:bg-gray-5 dark:hover:bg-gray-1 cursor-pointer rounded-sm px-1 py-0.5', activeIndex === index && 'bg-gray-5 dark:bg-gray-1')} onMouseEnter={() => setActiveIndex(index)} onMouseDown={(event) => event.preventDefault()} onClick={() => handleOptionClick(option)}>
239
+ {option.label}
240
+ </li>))) : hasSearchQuery && !isSearching ? (<li role="option" aria-disabled="true" className="autocomplete-option no-options">
241
+ {noOptionsText}
242
+ </li>) : null}
243
+ </ul>)}
225
244
  </div>);
226
245
  }
227
246
  //# sourceMappingURL=Autocomplete.jsx.map