@chayns-ui/core 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +9 -3
  2. package/dist/accordion.css +66 -2
  3. package/dist/avatar.css +5 -11
  4. package/dist/badge.css +3 -3
  5. package/dist/banner.css +89 -0
  6. package/dist/button.css +16 -2
  7. package/dist/card.css +29 -2
  8. package/dist/checkbox.css +24 -13
  9. package/dist/combo-box.css +20 -2
  10. package/dist/components/accordion/Accordion.d.ts +10 -2
  11. package/dist/components/accordion/Accordion.d.ts.map +1 -1
  12. package/dist/components/accordion/Accordion.js +120 -46
  13. package/dist/components/accordion/Accordion.js.map +1 -1
  14. package/dist/components/accordion/Accordion.types.d.ts +24 -1
  15. package/dist/components/accordion/Accordion.types.d.ts.map +1 -1
  16. package/dist/components/accordion/Accordion.types.js +6 -0
  17. package/dist/components/accordion/Accordion.types.js.map +1 -0
  18. package/dist/components/accordion/AccordionContext.d.ts +9 -0
  19. package/dist/components/accordion/AccordionContext.d.ts.map +1 -1
  20. package/dist/components/accordion/AccordionContext.js +8 -2
  21. package/dist/components/accordion/AccordionContext.js.map +1 -1
  22. package/dist/components/accordion-group/AccordionGroup.d.ts +1 -1
  23. package/dist/components/accordion-group/AccordionGroup.d.ts.map +1 -1
  24. package/dist/components/accordion-group/AccordionGroup.js +3 -3
  25. package/dist/components/accordion-group/AccordionGroup.js.map +1 -1
  26. package/dist/components/avatar/Avatar.d.ts +1 -0
  27. package/dist/components/avatar/Avatar.d.ts.map +1 -1
  28. package/dist/components/avatar/Avatar.js +11 -8
  29. package/dist/components/avatar/Avatar.js.map +1 -1
  30. package/dist/components/avatar-group/AvatarGroup.js +1 -1
  31. package/dist/components/badge/Badge.js +1 -1
  32. package/dist/components/banner/Banner.d.ts +3 -0
  33. package/dist/components/banner/Banner.d.ts.map +1 -0
  34. package/dist/components/banner/Banner.js +46 -0
  35. package/dist/components/banner/Banner.js.map +1 -0
  36. package/dist/components/banner/Banner.types.d.ts +24 -0
  37. package/dist/components/banner/Banner.types.d.ts.map +1 -0
  38. package/dist/components/banner/Banner.types.js +11 -0
  39. package/dist/components/banner/Banner.types.js.map +1 -0
  40. package/dist/components/button/Button.d.ts +1 -1
  41. package/dist/components/button/Button.d.ts.map +1 -1
  42. package/dist/components/button/Button.js +8 -3
  43. package/dist/components/button/Button.js.map +1 -1
  44. package/dist/components/button/Button.types.d.ts +6 -2
  45. package/dist/components/button/Button.types.d.ts.map +1 -1
  46. package/dist/components/button/Button.types.js.map +1 -1
  47. package/dist/components/card/Card.d.ts +4 -2
  48. package/dist/components/card/Card.d.ts.map +1 -1
  49. package/dist/components/card/Card.js +24 -8
  50. package/dist/components/card/Card.js.map +1 -1
  51. package/dist/components/card/Card.types.d.ts +10 -12
  52. package/dist/components/card/Card.types.d.ts.map +1 -1
  53. package/dist/components/checkbox/Checkbox.d.ts +1 -1
  54. package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
  55. package/dist/components/checkbox/Checkbox.js +15 -6
  56. package/dist/components/checkbox/Checkbox.js.map +1 -1
  57. package/dist/components/checkbox/Checkbox.types.d.ts +2 -0
  58. package/dist/components/checkbox/Checkbox.types.d.ts.map +1 -1
  59. package/dist/components/combo-box/ComboBox.d.ts.map +1 -1
  60. package/dist/components/combo-box/ComboBox.js +20 -3
  61. package/dist/components/combo-box/ComboBox.js.map +1 -1
  62. package/dist/components/date-time-picker/DateTimePicker.d.ts +4 -0
  63. package/dist/components/date-time-picker/DateTimePicker.d.ts.map +1 -0
  64. package/dist/components/date-time-picker/DateTimePicker.js +339 -0
  65. package/dist/components/date-time-picker/DateTimePicker.js.map +1 -0
  66. package/dist/components/date-time-picker/DateTimePicker.types.d.ts +26 -0
  67. package/dist/components/date-time-picker/DateTimePicker.types.d.ts.map +1 -0
  68. package/dist/components/date-time-picker/DateTimePicker.types.js +12 -0
  69. package/dist/components/date-time-picker/DateTimePicker.types.js.map +1 -0
  70. package/dist/components/icon-button/IconButton.d.ts +7 -2
  71. package/dist/components/icon-button/IconButton.d.ts.map +1 -1
  72. package/dist/components/icon-button/IconButton.js +8 -3
  73. package/dist/components/icon-button/IconButton.js.map +1 -1
  74. package/dist/components/icon-button/IconButton.types.d.ts +3 -1
  75. package/dist/components/icon-button/IconButton.types.d.ts.map +1 -1
  76. package/dist/components/list/List.js +1 -1
  77. package/dist/components/popup/Popup.js +1 -1
  78. package/dist/components/popup/PopupList.js +1 -1
  79. package/dist/components/radio-group/RadioGroup.d.ts.map +1 -1
  80. package/dist/components/radio-group/RadioGroup.js +17 -8
  81. package/dist/components/radio-group/RadioGroup.js.map +1 -1
  82. package/dist/components/radio-group/RadioGroup.types.d.ts +5 -3
  83. package/dist/components/radio-group/RadioGroup.types.d.ts.map +1 -1
  84. package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -1
  85. package/dist/components/segmented-control/SegmentedControl.js +12 -5
  86. package/dist/components/segmented-control/SegmentedControl.js.map +1 -1
  87. package/dist/components/segmented-control/SegmentedControl.types.d.ts +5 -2
  88. package/dist/components/segmented-control/SegmentedControl.types.d.ts.map +1 -1
  89. package/dist/components/skeleton/Skeleton.d.ts +4 -0
  90. package/dist/components/skeleton/Skeleton.d.ts.map +1 -0
  91. package/dist/components/skeleton/Skeleton.js +20 -0
  92. package/dist/components/skeleton/Skeleton.js.map +1 -0
  93. package/dist/components/skeleton/Skeleton.types.d.ts +11 -0
  94. package/dist/components/skeleton/Skeleton.types.d.ts.map +1 -0
  95. package/dist/components/skeleton/Skeleton.types.js +10 -0
  96. package/dist/components/skeleton/Skeleton.types.js.map +1 -0
  97. package/dist/components/split-button/SplitButton.d.ts +1 -1
  98. package/dist/components/split-button/SplitButton.d.ts.map +1 -1
  99. package/dist/components/split-button/SplitButton.js +9 -17
  100. package/dist/components/split-button/SplitButton.js.map +1 -1
  101. package/dist/components/switch/Switch.d.ts +1 -1
  102. package/dist/components/switch/Switch.d.ts.map +1 -1
  103. package/dist/components/switch/Switch.js +13 -5
  104. package/dist/components/switch/Switch.js.map +1 -1
  105. package/dist/components/switch/Switch.types.d.ts +2 -0
  106. package/dist/components/switch/Switch.types.d.ts.map +1 -1
  107. package/dist/components/text-area/TextArea.d.ts +1 -1
  108. package/dist/components/text-area/TextArea.d.ts.map +1 -1
  109. package/dist/components/text-area/TextArea.js +5 -4
  110. package/dist/components/text-area/TextArea.js.map +1 -1
  111. package/dist/components/text-field/TextField.d.ts +1 -1
  112. package/dist/components/text-field/TextField.d.ts.map +1 -1
  113. package/dist/components/text-field/TextField.js +5 -4
  114. package/dist/components/text-field/TextField.js.map +1 -1
  115. package/dist/date-time-picker.css +121 -0
  116. package/dist/index.d.ts +12 -5
  117. package/dist/index.d.ts.map +1 -1
  118. package/dist/index.js +8 -2
  119. package/dist/list.css +4 -4
  120. package/dist/radio-group.css +13 -1
  121. package/dist/segmented-control.css +24 -7
  122. package/dist/skeleton.css +41 -0
  123. package/dist/split-button.css +1 -1
  124. package/dist/styles.css +3 -1
  125. package/dist/switch.css +18 -5
  126. package/dist/text-area.css +2 -2
  127. package/dist/text-field.css +1 -1
  128. package/package.json +4 -2
  129. package/dist/components/message-box/MessageBox.d.ts +0 -4
  130. package/dist/components/message-box/MessageBox.d.ts.map +0 -1
  131. package/dist/components/message-box/MessageBox.js +0 -19
  132. package/dist/components/message-box/MessageBox.js.map +0 -1
  133. package/dist/components/message-box/MessageBox.types.d.ts +0 -13
  134. package/dist/components/message-box/MessageBox.types.d.ts.map +0 -1
  135. package/dist/message-box.css +0 -26
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","names":[],"sources":["../../../src/components/radio-group/RadioGroup.tsx"],"sourcesContent":["import { forwardRef, useState } from 'react';\n\nimport { RadioGroupContext, useRadioGroupContext } from './RadioGroupContext.js';\nimport type { RadioGroupProps, RadioProps } from './RadioGroup.types.js';\n\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { children, className, disabled, value, ...inputProps },\n ref,\n) {\n const group = useRadioGroupContext();\n const isDisabled = group.disabled || disabled === true;\n const inputClassName = ['chayns-radio__input', className].filter(Boolean).join(' ');\n\n return (\n <label className=\"chayns-radio\">\n <input\n {...inputProps}\n checked={group.value === value}\n className={inputClassName}\n disabled={isDisabled}\n name={group.name}\n onChange={() => group.selectValue(value)}\n ref={ref}\n type=\"radio\"\n value={value}\n />\n <span aria-hidden=\"true\" className=\"chayns-radio__control\" />\n <span className=\"chayns-radio__label\">{children}</span>\n </label>\n );\n});\n\nconst RadioGroupRoot = forwardRef<HTMLFieldSetElement, RadioGroupProps>(function RadioGroupRoot(\n {\n children,\n className,\n defaultValue,\n disabled,\n label,\n name,\n onValueChange,\n value,\n ...fieldsetProps\n },\n ref,\n) {\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n const isControlled = value !== undefined;\n const selectedValue = isControlled ? value : uncontrolledValue;\n const resolvedClassName = ['chayns-radio-group', className].filter(Boolean).join(' ');\n\n function selectValue(nextValue: string) {\n if (!isControlled) {\n setUncontrolledValue(nextValue);\n }\n\n onValueChange?.(nextValue);\n }\n\n return (\n <RadioGroupContext.Provider\n value={{ disabled: disabled === true, name, selectValue, value: selectedValue }}\n >\n <fieldset {...fieldsetProps} className={resolvedClassName} disabled={disabled} ref={ref}>\n <legend className=\"chayns-radio-group__legend\">{label}</legend>\n <div className=\"chayns-radio-group__options\">{children}</div>\n </fieldset>\n </RadioGroupContext.Provider>\n );\n});\n\nconst RadioGroup = Object.assign(RadioGroupRoot, { Radio });\n\nexport default RadioGroup;\n"],"mappings":";;;;AAKA,IAAM,QAAQ,WAAyC,SAAS,MAC9D,EAAE,UAAU,WAAW,UAAU,OAAO,GAAG,cAC3C,KACA;CACA,MAAM,QAAQ,qBAAqB;CACnC,MAAM,aAAa,MAAM,YAAY,aAAa;CAClD,MAAM,iBAAiB,CAAC,uBAAuB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAElF,OACE,qBAAC,SAAD;EAAO,WAAU;EAAjB,UAAA;GACE,oBAAC,SAAD;IACE,GAAI;IACJ,SAAS,MAAM,UAAU;IACzB,WAAW;IACX,UAAU;IACV,MAAM,MAAM;IACZ,gBAAgB,MAAM,YAAY,KAAK;IAClC;IACL,MAAK;IACE;GACR,CAAA;GACD,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;GAAyB,CAAA;GAC5D,oBAAC,QAAD;IAAM,WAAU;IAAuB;GAAe,CAAA;EACjD;;AAEX,CAAC;AAED,IAAM,iBAAiB,WAAiD,SAAS,eAC/E,EACE,UACA,WACA,cACA,UACA,OACA,MACA,eACA,OACA,GAAG,iBAEL,KACA;CACA,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,YAAY;CACvE,MAAM,eAAe,UAAU,KAAA;CAC/B,MAAM,gBAAgB,eAAe,QAAQ;CAC7C,MAAM,oBAAoB,CAAC,sBAAsB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEpF,SAAS,YAAY,WAAmB;EACtC,IAAI,CAAC,cACH,qBAAqB,SAAS;EAGhC,gBAAgB,SAAS;CAC3B;CAEA,OACE,oBAAC,kBAAkB,UAAnB;EACE,OAAO;GAAE,UAAU,aAAa;GAAM;GAAM;GAAa,OAAO;EAAc;EAE9E,UAAA,qBAAC,YAAD;GAAU,GAAI;GAAe,WAAW;GAA6B;GAAe;GAApF,UAAA,CACE,oBAAC,UAAD;IAAQ,WAAU;IAA8B,UAAA;GAAc,CAAA,GAC9D,oBAAC,OAAD;IAAK,WAAU;IAA+B;GAAc,CAAA,CACpD;;CACgB,CAAA;AAEhC,CAAC;AAED,IAAM,aAAa,OAAO,OAAO,gBAAgB,EAAE,MAAM,CAAC"}
1
+ {"version":3,"file":"RadioGroup.js","names":[],"sources":["../../../src/components/radio-group/RadioGroup.tsx"],"sourcesContent":["import { forwardRef, useState } from 'react';\n\nimport { RadioGroupContext, useRadioGroupContext } from './RadioGroupContext.js';\nimport type { RadioGroupProps, RadioProps } from './RadioGroup.types.js';\n\nconst Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(\n { children, className, description, disabled, onChange, value, ...inputProps },\n ref,\n) {\n const group = useRadioGroupContext();\n const isDisabled = group.disabled || disabled === true;\n const inputClassName = ['chayns-radio__input', className].filter(Boolean).join(' ');\n\n return (\n <label className=\"chayns-radio\">\n <input\n {...inputProps}\n checked={group.value === value}\n className={inputClassName}\n disabled={isDisabled}\n name={group.name}\n onChange={(event) => {\n onChange?.(event);\n if (!event.defaultPrevented) {\n group.selectValue(value);\n }\n }}\n ref={ref}\n type=\"radio\"\n value={value}\n />\n <span aria-hidden=\"true\" className=\"chayns-radio__control\" />\n <span className=\"chayns-radio__content\">\n <span className=\"chayns-radio__label\">{children}</span>\n {description !== undefined ? (\n <span className=\"chayns-radio__description\">{description}</span>\n ) : null}\n </span>\n </label>\n );\n});\n\nconst RadioGroupRoot = forwardRef<HTMLFieldSetElement, RadioGroupProps>(function RadioGroupRoot(\n {\n children,\n className,\n defaultValue,\n disabled,\n label,\n name,\n onValueChange,\n value,\n ...fieldsetProps\n },\n ref,\n) {\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n const isControlled = value !== undefined;\n const selectedValue = isControlled ? value : uncontrolledValue;\n const resolvedClassName = ['chayns-radio-group', className].filter(Boolean).join(' ');\n\n function selectValue(nextValue: string) {\n if (!isControlled) {\n setUncontrolledValue(nextValue);\n }\n\n onValueChange?.(nextValue);\n }\n\n return (\n <RadioGroupContext.Provider\n value={{ disabled: disabled === true, name, selectValue, value: selectedValue }}\n >\n <fieldset {...fieldsetProps} className={resolvedClassName} disabled={disabled} ref={ref}>\n {label !== undefined ? (\n <legend className=\"chayns-radio-group__legend\">{label}</legend>\n ) : null}\n <div className=\"chayns-radio-group__options\">{children}</div>\n </fieldset>\n </RadioGroupContext.Provider>\n );\n});\n\nconst RadioGroup = Object.assign(RadioGroupRoot, { Radio });\n\nexport default RadioGroup;\n"],"mappings":";;;;AAK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;GAAM;GAAa,OAAO;EAAc;EAE9E,UAAA,qBAAC,YAAD;GAAU,GAAI;GAAe,WAAW;GAA6B;GAAe;GAApF,UAAA,CACG,UAAU,KAAA,IACT,oBAAC,UAAD;IAAQ,WAAU;IAA8B,UAAA;GAAc,CAAA,IAC5D,MACJ,oBAAC,OAAD;IAAK,WAAU;IAA+B;GAAc,CAAA,CACpD;;CACgB,CAAA;AAEhC,CAAC;AAED,IAAM,aAAa,OAAO,OAAO,gBAAgB,EAAE,MAAM,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from 'react';
2
2
  /** Props for a labelled native radio fieldset. */
3
3
  export interface RadioGroupProps extends Omit<ComponentPropsWithRef<'fieldset'>, 'children' | 'name'> {
4
- /** Visible, localized group label rendered as its legend. */
5
- label: Exclude<ReactNode, boolean | null | undefined>;
4
+ /** Optional visible, localized group label rendered as its legend. */
5
+ label?: Exclude<ReactNode, boolean | null | undefined>;
6
6
  /** Shared native name forwarded to every Radio. */
7
7
  name: string;
8
8
  /** Controlled selected option value. */
@@ -20,11 +20,13 @@ export interface RadioProps extends Omit<ComponentPropsWithRef<'input'>, 'childr
20
20
  value: string;
21
21
  /** Visible, localized option label. */
22
22
  children: Exclude<ReactNode, boolean | null | undefined>;
23
+ /** Optional localized supporting text associated with the radio label. */
24
+ description?: ReactNode;
23
25
  /** RadioGroup owns the input type and selection relationship. */
24
26
  type?: never;
25
27
  name?: never;
26
28
  checked?: never;
27
29
  defaultChecked?: never;
28
- onChange?: never;
30
+ onChange?: ComponentPropsWithRef<'input'>['onChange'];
29
31
  }
30
32
  //# sourceMappingURL=RadioGroup.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.types.d.ts","sourceRoot":"","sources":["../../../src/components/radio-group/RadioGroup.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,kDAAkD;AAClD,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EACjC,UAAU,GAAG,MAAM,CACpB;IACC,sEAAsE;IACtE,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACvD,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iCAAiC;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,gEAAgE;AAChE,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,qBAAqB,CAAC,OAAO,CAAC,EAC9B,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,gBAAgB,GAAG,UAAU,CACzE;IACC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAEzD,0EAA0E;IAC1E,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,iEAAiE;IACjE,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,cAAc,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC;CACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAqMvF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;CAAmD,CAAC;AAE1E,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAkNvF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;CAAmD,CAAC;AAE1E,eAAe,gBAAgB,CAAC"}
@@ -1,13 +1,14 @@
1
+ import ButtonIcon from "../button/button-icon/ButtonIcon.js";
1
2
  import { SegmentedControlContext, useSegmentedControlContext } from "./SegmentedControlContext.js";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { forwardRef, useId, useLayoutEffect, useRef, useState } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
4
5
  //#region src/components/segmented-control/SegmentedControl.tsx
5
6
  function getOrderedSegments(segments) {
6
7
  return [...segments.entries()].filter(([, element]) => !element.disabled).sort(([, first], [, second]) => {
7
8
  return first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
8
9
  });
9
10
  }
10
- var Segment = forwardRef(function Segment({ children, className, disabled, value, ...buttonProps }, ref) {
11
+ var Segment = forwardRef(function Segment({ children, className, disabled, icon, onClick, onKeyDown, value, ...buttonProps }, ref) {
11
12
  const control = useSegmentedControlContext();
12
13
  const localRef = useRef(null);
13
14
  const isSelected = control.value === value;
@@ -26,6 +27,8 @@ var Segment = forwardRef(function Segment({ children, className, disabled, value
26
27
  else if (ref !== null) ref.current = element;
27
28
  }
28
29
  function handleKeyDown(event) {
30
+ onKeyDown?.(event);
31
+ if (event.defaultPrevented) return;
29
32
  if ([
30
33
  "ArrowDown",
31
34
  "ArrowLeft",
@@ -38,18 +41,22 @@ var Segment = forwardRef(function Segment({ children, className, disabled, value
38
41
  control.moveFocus(value, event.key);
39
42
  }
40
43
  }
41
- return /* @__PURE__ */ jsx("button", {
44
+ function handleClick(event) {
45
+ onClick?.(event);
46
+ if (!event.defaultPrevented) control.selectValue(value);
47
+ }
48
+ return /* @__PURE__ */ jsxs("button", {
42
49
  ...buttonProps,
43
50
  "aria-checked": isSelected,
44
51
  className: resolvedClassName,
45
52
  disabled,
46
- onClick: () => control.selectValue(value),
53
+ onClick: handleClick,
47
54
  onKeyDown: handleKeyDown,
48
55
  ref: setRef,
49
56
  role: "radio",
50
57
  tabIndex: isSelected ? 0 : -1,
51
58
  type: "button",
52
- children
59
+ children: [icon ? /* @__PURE__ */ jsx(ButtonIcon, { icon }) : null, children]
53
60
  });
54
61
  });
55
62
  var SegmentedControlRoot = forwardRef(function SegmentedControlRoot({ children, className, defaultValue, label, onValueChange, value, ...rootProps }, ref) {
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["import { forwardRef, useId, useLayoutEffect, useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\n\nimport { SegmentedControlContext, useSegmentedControlContext } from './SegmentedControlContext.js';\nimport type { SegmentedControlProps, SegmentProps } from './SegmentedControl.types.js';\n\nfunction getOrderedSegments(segments: Map<string, HTMLButtonElement>) {\n return [...segments.entries()]\n .filter(([, element]) => !element.disabled)\n .sort(([, first], [, second]) => {\n const position = first.compareDocumentPosition(second);\n return position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n });\n}\n\nconst Segment = forwardRef<HTMLButtonElement, SegmentProps>(function Segment(\n { children, className, disabled, value, ...buttonProps },\n ref,\n) {\n const control = useSegmentedControlContext();\n const localRef = useRef<HTMLButtonElement>(null);\n const isSelected = control.value === value;\n const resolvedClassName = [\n 'chayns-segmented-control__segment',\n isSelected ? 'chayns-segmented-control__segment--selected' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n useLayoutEffect(() => {\n if (localRef.current === null) {\n return undefined;\n }\n\n return control.registerSegment(value, localRef.current);\n }, [control, value]);\n\n function setRef(element: HTMLButtonElement | null) {\n localRef.current = element;\n\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref !== null) {\n ref.current = element;\n }\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLButtonElement>) {\n const keys = ['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'End', 'Home'];\n\n if (keys.includes(event.key)) {\n event.preventDefault();\n control.moveFocus(value, event.key);\n }\n }\n\n return (\n <button\n {...buttonProps}\n aria-checked={isSelected}\n className={resolvedClassName}\n disabled={disabled}\n onClick={() => control.selectValue(value)}\n onKeyDown={handleKeyDown}\n ref={setRef}\n role=\"radio\"\n tabIndex={isSelected ? 0 : -1}\n type=\"button\"\n >\n {children}\n </button>\n );\n});\n\nconst SegmentedControlRoot = forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControlRoot(\n { children, className, defaultValue, label, onValueChange, value, ...rootProps },\n ref,\n ) {\n const labelId = useId();\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n const segments = useRef(new Map<string, HTMLButtonElement>());\n const segmentsElement = useRef<HTMLDivElement>(null);\n const [indicator, setIndicator] = useState({ offset: 0, width: 0 });\n const selectedValue = value ?? uncontrolledValue ?? '';\n const resolvedClassName = ['chayns-segmented-control', className].filter(Boolean).join(' ');\n\n function selectValue(nextValue: string) {\n if (value === undefined) {\n setUncontrolledValue(nextValue);\n }\n\n onValueChange?.(nextValue);\n }\n\n function registerSegment(segmentValue: string, element: HTMLButtonElement) {\n segments.current.set(segmentValue, element);\n\n return () => {\n segments.current.delete(segmentValue);\n };\n }\n\n function moveFocus(currentValue: string, key: string) {\n const enabledSegments = getOrderedSegments(segments.current);\n const currentIndex = enabledSegments.findIndex(\n ([segmentValue]) => segmentValue === currentValue,\n );\n\n if (currentIndex === -1 || enabledSegments.length === 0) {\n return;\n }\n\n let targetIndex = currentIndex;\n\n if (key === 'Home') {\n targetIndex = 0;\n } else if (key === 'End') {\n targetIndex = enabledSegments.length - 1;\n } else if (key === 'ArrowLeft' || key === 'ArrowUp') {\n targetIndex = (currentIndex - 1 + enabledSegments.length) % enabledSegments.length;\n } else if (key === 'ArrowRight' || key === 'ArrowDown') {\n targetIndex = (currentIndex + 1) % enabledSegments.length;\n }\n\n const nextSegment = enabledSegments[targetIndex];\n\n if (nextSegment === undefined) {\n return;\n }\n\n const [nextValue, nextElement] = nextSegment;\n selectValue(nextValue);\n nextElement.focus();\n }\n\n useLayoutEffect(() => {\n const container = segmentsElement.current;\n const selectedSegment = segments.current.get(selectedValue);\n\n if (container === null || selectedSegment === undefined) {\n return undefined;\n }\n\n const observedContainer = container;\n const observedSegment = selectedSegment;\n\n function updateIndicator() {\n const paddingInlineStart = Number.parseFloat(\n window.getComputedStyle(observedContainer).paddingInlineStart,\n );\n\n setIndicator({\n offset:\n observedSegment.offsetLeft -\n (Number.isNaN(paddingInlineStart) ? 0 : paddingInlineStart),\n width: observedSegment.offsetWidth,\n });\n }\n\n updateIndicator();\n\n if (typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const observer = new ResizeObserver(updateIndicator);\n observer.observe(observedContainer);\n\n return () => observer.disconnect();\n }, [selectedValue]);\n\n return (\n <SegmentedControlContext.Provider\n value={{ moveFocus, registerSegment, selectValue, value: selectedValue }}\n >\n <div\n {...rootProps}\n aria-labelledby={labelId}\n className={resolvedClassName}\n ref={ref}\n role=\"radiogroup\"\n >\n <span className=\"chayns-segmented-control__label\" id={labelId}>\n {label}\n </span>\n <div className=\"chayns-segmented-control__segments\" ref={segmentsElement}>\n <span\n aria-hidden=\"true\"\n className=\"chayns-segmented-control__indicator\"\n style={{ transform: `translateX(${indicator.offset}px)`, width: indicator.width }}\n />\n {children}\n </div>\n </div>\n </SegmentedControlContext.Provider>\n );\n },\n);\n\nconst SegmentedControl = Object.assign(SegmentedControlRoot, { Segment });\n\nexport default SegmentedControl;\n"],"mappings":";;;;AAMA,SAAS,mBAAmB,UAA0C;CACpE,OAAO,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC,CAC3B,QAAQ,GAAG,a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AkB;EAExB,SAAS,kBAAkB;GACzB,MAAM,qBAAqB,OAAO,WAChC,OAAO,iBAAiB,iBAAiB,CAAC,CAAC,kBAC7C;GAEA,aAAa;IACX,QACE,gBAAgB,cACf,OAAO,MAAM,kBAAkB,IAAI,IAAI;IAC1C,OAAO,gBAAgB;GACzB,CAAC;EACH;EAEA,gBAAgB;EAEhB,IAAI,OAAO,mBAAmB,aAC5B;EAGF,MAAM,WAAW,IAAI,eAAe,eAAe;EACnD,SAAS,QAAQ,iBAAiB;EAElC,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,aAAa,CAAC;CAElB,OACE,oBAAC,wBAAwB,UAAzB;EACE,OAAO;GAAE;GAAW;GAAiB;GAAa,OAAO;EAAc;EAEvE,UAAA,qBAAC,OAAD;GACE,GAAI;GACJ,mBAAiB;GACjB,WAAW;GACN;GACL,MAAK;GALP,UAAA,CAOE,oBAAC,QAAD;IAAM,WAAU;IAAkC,IAAI;IACnD,UAAA;GACG,CAAA,GACN,qBAAC,OAAD;IAAK,WAAU;IAAqC,KAAK;IAAzD,UAAA,CACE,oBAAC,QAAD;KACE,eAAY;KACZ,WAAU;KACV,OAAO;MAAE,WAAW,cAAc,UAAU,OAAO;MAAM,OAAO,UAAU;KAAM;IACjF,CAAA,GACA,QACE;GACF,CAAA,CAAA;;CAC2B,CAAA;AAEtC,CACF;AAEA,IAAM,mBAAmB,OAAO,OAAO,sBAAsB,EAAE,QAAQ,CAAC"}
1
+ {"version":3,"file":"SegmentedControl.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControl.tsx"],"sourcesContent":["import { forwardRef, useId, useLayoutEffect, useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\n\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport { SegmentedControlContext, useSegmentedControlContext } from './SegmentedControlContext.js';\nimport type { SegmentedControlProps, SegmentProps } from './SegmentedControl.types.js';\n\nfunction getOrderedSegments(segments: Map<string, HTMLButtonElement>) {\n return [...segments.entries()]\n .filter(([, element]) => !element.disabled)\n .sort(([, first], [, second]) => {\n const position = first.compareDocumentPosition(second);\n return position & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;\n });\n}\n\nconst Segment = forwardRef<HTMLButtonElement, SegmentProps>(function Segment(\n { children, className, disabled, icon, onClick, onKeyDown, value, ...buttonProps },\n ref,\n) {\n const control = useSegmentedControlContext();\n const localRef = useRef<HTMLButtonElement>(null);\n const isSelected = control.value === value;\n const resolvedClassName = [\n 'chayns-segmented-control__segment',\n isSelected ? 'chayns-segmented-control__segment--selected' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n useLayoutEffect(() => {\n if (localRef.current === null) {\n return undefined;\n }\n\n return control.registerSegment(value, localRef.current);\n }, [control, value]);\n\n function setRef(element: HTMLButtonElement | null) {\n localRef.current = element;\n\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref !== null) {\n ref.current = element;\n }\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLButtonElement>) {\n onKeyDown?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n const keys = ['ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'End', 'Home'];\n\n if (keys.includes(event.key)) {\n event.preventDefault();\n control.moveFocus(value, event.key);\n }\n }\n\n function handleClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (!event.defaultPrevented) {\n control.selectValue(value);\n }\n }\n\n return (\n <button\n {...buttonProps}\n aria-checked={isSelected}\n className={resolvedClassName}\n disabled={disabled}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n ref={setRef}\n role=\"radio\"\n tabIndex={isSelected ? 0 : -1}\n type=\"button\"\n >\n {icon ? <ButtonIcon icon={icon} /> : null}\n {children}\n </button>\n );\n});\n\nconst SegmentedControlRoot = forwardRef<HTMLDivElement, SegmentedControlProps>(\n function SegmentedControlRoot(\n { children, className, defaultValue, label, onValueChange, value, ...rootProps },\n ref,\n ) {\n const labelId = useId();\n const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n const segments = useRef(new Map<string, HTMLButtonElement>());\n const segmentsElement = useRef<HTMLDivElement>(null);\n const [indicator, setIndicator] = useState({ offset: 0, width: 0 });\n const selectedValue = value ?? uncontrolledValue ?? '';\n const resolvedClassName = ['chayns-segmented-control', className].filter(Boolean).join(' ');\n\n function selectValue(nextValue: string) {\n if (value === undefined) {\n setUncontrolledValue(nextValue);\n }\n\n onValueChange?.(nextValue);\n }\n\n function registerSegment(segmentValue: string, element: HTMLButtonElement) {\n segments.current.set(segmentValue, element);\n\n return () => {\n segments.current.delete(segmentValue);\n };\n }\n\n function moveFocus(currentValue: string, key: string) {\n const enabledSegments = getOrderedSegments(segments.current);\n const currentIndex = enabledSegments.findIndex(\n ([segmentValue]) => segmentValue === currentValue,\n );\n\n if (currentIndex === -1 || enabledSegments.length === 0) {\n return;\n }\n\n let targetIndex = currentIndex;\n\n if (key === 'Home') {\n targetIndex = 0;\n } else if (key === 'End') {\n targetIndex = enabledSegments.length - 1;\n } else if (key === 'ArrowLeft' || key === 'ArrowUp') {\n targetIndex = (currentIndex - 1 + enabledSegments.length) % enabledSegments.length;\n } else if (key === 'ArrowRight' || key === 'ArrowDown') {\n targetIndex = (currentIndex + 1) % enabledSegments.length;\n }\n\n const nextSegment = enabledSegments[targetIndex];\n\n if (nextSegment === undefined) {\n return;\n }\n\n const [nextValue, nextElement] = nextSegment;\n selectValue(nextValue);\n nextElement.focus();\n }\n\n useLayoutEffect(() => {\n const container = segmentsElement.current;\n const selectedSegment = segments.current.get(selectedValue);\n\n if (container === null || selectedSegment === undefined) {\n return undefined;\n }\n\n const observedContainer = container;\n const observedSegment = selectedSegment;\n\n function updateIndicator() {\n const paddingInlineStart = Number.parseFloat(\n window.getComputedStyle(observedContainer).paddingInlineStart,\n );\n\n setIndicator({\n offset:\n observedSegment.offsetLeft -\n (Number.isNaN(paddingInlineStart) ? 0 : paddingInlineStart),\n width: observedSegment.offsetWidth,\n });\n }\n\n updateIndicator();\n\n if (typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const observer = new ResizeObserver(updateIndicator);\n observer.observe(observedContainer);\n\n return () => observer.disconnect();\n }, [selectedValue]);\n\n return (\n <SegmentedControlContext.Provider\n value={{ moveFocus, registerSegment, selectValue, value: selectedValue }}\n >\n <div\n {...rootProps}\n aria-labelledby={labelId}\n className={resolvedClassName}\n ref={ref}\n role=\"radiogroup\"\n >\n <span className=\"chayns-segmented-control__label\" id={labelId}>\n {label}\n </span>\n <div className=\"chayns-segmented-control__segments\" ref={segmentsElement}>\n <span\n aria-hidden=\"true\"\n className=\"chayns-segmented-control__indicator\"\n style={{ transform: `translateX(${indicator.offset}px)`, width: indicator.width }}\n />\n {children}\n </div>\n </div>\n </SegmentedControlContext.Provider>\n );\n },\n);\n\nconst SegmentedControl = Object.assign(SegmentedControlRoot, { Segment });\n\nexport default SegmentedControl;\n"],"mappings":";;;;;AAOA,SAAS,mBAAmB,UAA0C;CACpE,OAAO,CAAC,GAAG,SAAS,QAAQ,CAAC,CAAC,CAC3B,QAAQ,GAAG,aAAa,CAAC,QAAQ,QAAQ,CAAC,CAC1C,MAAM,GAAG,QAAQ,GAAG,YAAY;EAE/B,OADiB,MAAM,wBAAwB,MACxC,IAAW,KAAK,8BAA8B,KAAK;CAC5D,CAAC;AACL;AAEA,IAAM,UAAU,WAA4C,SAAS,QACnE,EAAE,UAAU,WAAW,UAAU,MAAM,SAAS,WAAW,OAAO,GAAG,eACrE,KACA;CACA,MAAM,UAAU,2BAA2B;CAC3C,MAAM,WAAW,OAA0B,IAAI;CAC/C,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,oBAAoB;EACxB;EACA,aAAa,gDAAgD;EAC7D;CACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,sBAAsB;EACpB,IAAI,SAAS,YAAY,MACvB;EAGF,OAAO,QAAQ,gBAAgB,OAAO,SAAS,OAAO;CACxD,GAAG,CAAC,SAAS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aAAa,CAAC;CAElB,OACE,oBAAC,wBAAwB,UAAzB;EACE,OAAO;GAAE;GAAW;GAAiB;GAAa,OAAO;EAAc;EAEvE,UAAA,qBAAC,OAAD;GACE,GAAI;GACJ,mBAAiB;GACjB,WAAW;GACN;GACL,MAAK;GALP,UAAA,CAOE,oBAAC,QAAD;IAAM,WAAU;IAAkC,IAAI;IACnD,UAAA;GACG,CAAA,GACN,qBAAC,OAAD;IAAK,WAAU;IAAqC,KAAK;IAAzD,UAAA,CACE,oBAAC,QAAD;KACE,eAAY;KACZ,WAAU;KACV,OAAO;MAAE,WAAW,cAAc,UAAU,OAAO;MAAM,OAAO,UAAU;KAAM;IACjF,CAAA,GACA,QACE;GACF,CAAA,CAAA;;CAC2B,CAAA;AAEtC,CACF;AAEA,IAAM,mBAAmB,OAAO,OAAO,sBAAsB,EAAE,QAAQ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ import type { ButtonIcon } from '../button/Button.types.js';
2
3
  export interface ControlledSelection {
3
4
  /** Controlled selected segment value. */
4
5
  value: string;
@@ -30,12 +31,14 @@ export interface SegmentProps extends Omit<ComponentPropsWithRef<'button'>, 'ari
30
31
  value: string;
31
32
  /** Visible, localized button label. */
32
33
  children: Exclude<ReactNode, boolean | null | undefined>;
34
+ /** Optional leading FontAwesome icon shown with the segment label. */
35
+ icon?: ButtonIcon;
33
36
  /** SegmentedControl owns the native button semantics and interactions. */
34
37
  type?: never;
35
38
  role?: never;
36
39
  'aria-checked'?: never;
37
40
  tabIndex?: never;
38
- onClick?: never;
39
- onKeyDown?: never;
41
+ onClick?: ComponentPropsWithRef<'button'>['onClick'];
42
+ onKeyDown?: ComponentPropsWithRef<'button'>['onKeyDown'];
40
43
  }
41
44
  //# sourceMappingURL=SegmentedControl.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.types.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControl.types.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AA0E;IAC1E,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,cAAc,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB"}
1
+ {"version":3,"file":"SegmentedControl.types.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControl.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gDAAgD;IAChD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,mEAAmE;AACnE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,qBAAqB,CAAC,KAAK,CAAC,EAC5B,iBAAiB,GAAG,UAAU,GAAG,MAAM,CACxC,GACC,CAAC,mBAAmB,GAAG,qBAAqB,CAAC,GAAG;IAC9C,sCAAsC;IACtC,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACtD,yCAAyC;IACzC,QAAQ,EAAE,SAAS,CAAC;IACpB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,CAAC;AAEJ,uDAAuD;AACvD,MAAM,WAAW,YAAa,SAAQ,IAAI,CACxC,qBAAqB,CAAC,QAAQ,CAAC,EAC/B,cAAc,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CACrF;IACC,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACzD,sEAAsE;IACtE,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,cAAc,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,SAAS,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC;CAC1D"}
@@ -0,0 +1,4 @@
1
+ import type { SkeletonProps } from './Skeleton.types.js';
2
+ declare const Skeleton: import("react").ForwardRefExoticComponent<Omit<SkeletonProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
3
+ export default Skeleton;
4
+ //# sourceMappingURL=Skeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/Skeleton.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,QAAA,MAAM,QAAQ,uHAsBZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { forwardRef } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/components/skeleton/Skeleton.tsx
4
+ var Skeleton = forwardRef(function Skeleton({ "aria-hidden": _ariaHidden, children: _children, className, role: _role, shape = "rounded", tabIndex: _tabIndex, ...divProps }, ref) {
5
+ const resolvedClassName = [
6
+ "chayns-skeleton",
7
+ `chayns-skeleton--${shape}`,
8
+ className
9
+ ].filter(Boolean).join(" ");
10
+ return /* @__PURE__ */ jsx("div", {
11
+ ...divProps,
12
+ "aria-hidden": "true",
13
+ className: resolvedClassName,
14
+ ref
15
+ });
16
+ });
17
+ //#endregion
18
+ export { Skeleton as default };
19
+
20
+ //# sourceMappingURL=Skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.js","names":[],"sources":["../../../src/components/skeleton/Skeleton.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport type { SkeletonProps } from './Skeleton.types.js';\n\nconst Skeleton = forwardRef<HTMLDivElement, SkeletonProps>(function Skeleton(\n {\n 'aria-hidden': _ariaHidden,\n children: _children,\n className,\n role: _role,\n shape = 'rounded',\n tabIndex: _tabIndex,\n ...divProps\n },\n ref,\n) {\n void _ariaHidden;\n void _children;\n void _role;\n void _tabIndex;\n\n const resolvedClassName = ['chayns-skeleton', `chayns-skeleton--${shape}`, className]\n .filter(Boolean)\n .join(' ');\n\n return <div {...divProps} aria-hidden=\"true\" className={resolvedClassName} ref={ref} />;\n});\n\nexport default Skeleton;\n"],"mappings":";;;AAIA,IAAM,WAAW,WAA0C,SAAS,SAClE,EACE,eAAe,aACf,UAAU,WACV,WACA,MAAM,OACN,QAAQ,WACR,UAAU,WACV,GAAG,YAEL,KACA;CAMA,MAAM,oBAAoB;EAAC;EAAmB,oBAAoB;EAAS;CAAS,CAAC,CAClF,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;CAEX,OAAO,oBAAC,OAAD;EAAK,GAAI;EAAU,eAAY;EAAO,WAAW;EAAwB;CAAM,CAAA;AACxF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ export declare const SKELETON_SHAPES: readonly ["square", "rounded", "circular"];
3
+ export type SkeletonShape = (typeof SKELETON_SHAPES)[number];
4
+ export interface SkeletonProps extends Omit<ComponentPropsWithRef<'div'>, 'aria-hidden' | 'children' | 'role' | 'tabIndex'> {
5
+ shape?: SkeletonShape;
6
+ children?: never;
7
+ role?: never;
8
+ tabIndex?: never;
9
+ 'aria-hidden'?: never;
10
+ }
11
+ //# sourceMappingURL=Skeleton.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.types.d.ts","sourceRoot":"","sources":["../../../src/components/skeleton/Skeleton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAEnD,eAAO,MAAM,eAAe,4CAA6C,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,qBAAqB,CAAC,KAAK,CAAC,EAC5B,aAAa,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CACjD;IACC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB"}
@@ -0,0 +1,10 @@
1
+ //#region src/components/skeleton/Skeleton.types.ts
2
+ var SKELETON_SHAPES = [
3
+ "square",
4
+ "rounded",
5
+ "circular"
6
+ ];
7
+ //#endregion
8
+ export { SKELETON_SHAPES };
9
+
10
+ //# sourceMappingURL=Skeleton.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.types.js","names":[],"sources":["../../../src/components/skeleton/Skeleton.types.ts"],"sourcesContent":["import type { ComponentPropsWithRef } from 'react';\n\nexport const SKELETON_SHAPES = ['square', 'rounded', 'circular'] as const;\nexport type SkeletonShape = (typeof SKELETON_SHAPES)[number];\n\nexport interface SkeletonProps extends Omit<\n ComponentPropsWithRef<'div'>,\n 'aria-hidden' | 'children' | 'role' | 'tabIndex'\n> {\n shape?: SkeletonShape;\n children?: never;\n role?: never;\n tabIndex?: never;\n 'aria-hidden'?: never;\n}\n"],"mappings":";AAEA,IAAa,kBAAkB;CAAC;CAAU;CAAW;AAAU"}
@@ -1,4 +1,4 @@
1
1
  import type { SplitButtonProps } from './SplitButton.types.js';
2
- declare const SplitButton: ({ children, className, disabled, icon, items, onClick, variant, ...containerProps }: SplitButtonProps) => import("react").JSX.Element;
2
+ declare const SplitButton: import("react").ForwardRefExoticComponent<Omit<SplitButtonProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
3
3
  export default SplitButton;
4
4
  //# sourceMappingURL=SplitButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SplitButton.d.ts","sourceRoot":"","sources":["../../../src/components/split-button/SplitButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,QAAA,MAAM,WAAW,GAAI,qFASlB,gBAAgB,gCA+ClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SplitButton.d.ts","sourceRoot":"","sources":["../../../src/components/split-button/SplitButton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,QAAA,MAAM,WAAW,0HAwCf,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -1,30 +1,21 @@
1
1
  import ButtonIcon from "../button/button-icon/ButtonIcon.js";
2
2
  import Button from "../button/Button.js";
3
3
  import PopupList from "../popup/PopupList.js";
4
+ import { forwardRef, useId } from "react";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { useId } from "react";
6
6
  //#region src/components/split-button/SplitButton.tsx
7
- var SplitButton = ({ children, className, disabled, icon, items, onClick, variant, ...containerProps }) => {
7
+ var SplitButton = forwardRef(function SplitButton({ children, className, disabled, icon, items, onClick, variant, ...containerProps }, ref) {
8
8
  const labelId = useId();
9
9
  return /* @__PURE__ */ jsxs("div", {
10
10
  ...containerProps,
11
11
  className: ["chayns-split-button", className].filter(Boolean).join(" "),
12
- children: [icon ? /* @__PURE__ */ jsx(Button, {
12
+ ref,
13
+ children: [/* @__PURE__ */ jsx(Button, {
13
14
  "aria-labelledby": labelId,
14
15
  className: "chayns-split-button__primary",
15
- ...disabled ? { disabled: true } : {},
16
- icon,
17
- ...onClick ? { onClick } : {},
18
- variant,
19
- children: /* @__PURE__ */ jsx("span", {
20
- id: labelId,
21
- children
22
- })
23
- }) : /* @__PURE__ */ jsx(Button, {
24
- "aria-labelledby": labelId,
25
- className: "chayns-split-button__primary",
26
- ...disabled ? { disabled: true } : {},
27
- ...onClick ? { onClick } : {},
16
+ disabled,
17
+ ...icon ? { icon } : {},
18
+ onClick,
28
19
  variant,
29
20
  children: /* @__PURE__ */ jsx("span", {
30
21
  id: labelId,
@@ -34,6 +25,7 @@ var SplitButton = ({ children, className, disabled, icon, items, onClick, varian
34
25
  items,
35
26
  trigger: /* @__PURE__ */ jsx("button", {
36
27
  "aria-labelledby": labelId,
28
+ "aria-haspopup": "menu",
37
29
  className: `chayns-split-button__trigger chayns-button--${variant}`,
38
30
  ...disabled ? { disabled: true } : {},
39
31
  type: "button",
@@ -45,7 +37,7 @@ var SplitButton = ({ children, className, disabled, icon, items, onClick, varian
45
37
  })
46
38
  })]
47
39
  });
48
- };
40
+ });
49
41
  //#endregion
50
42
  export { SplitButton as default };
51
43
 
@@ -1 +1 @@
1
- {"version":3,"file":"SplitButton.js","names":[],"sources":["../../../src/components/split-button/SplitButton.tsx"],"sourcesContent":["import { useId } from 'react';\n\nimport Button from '../button/Button.js';\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport PopupList from '../popup/PopupList.js';\nimport type { SplitButtonProps } from './SplitButton.types.js';\n\nconst SplitButton = ({\n children,\n className,\n disabled,\n icon,\n items,\n onClick,\n variant,\n ...containerProps\n}: SplitButtonProps) => {\n const labelId = useId();\n\n return (\n <div\n {...containerProps}\n className={['chayns-split-button', className].filter(Boolean).join(' ')}\n >\n {icon ? (\n <Button\n aria-labelledby={labelId}\n className=\"chayns-split-button__primary\"\n {...(disabled ? { disabled: true } : {})}\n icon={icon}\n {...(onClick ? { onClick } : {})}\n variant={variant}\n >\n <span id={labelId}>{children}</span>\n </Button>\n ) : (\n <Button\n aria-labelledby={labelId}\n className=\"chayns-split-button__primary\"\n {...(disabled ? { disabled: true } : {})}\n {...(onClick ? { onClick } : {})}\n variant={variant}\n >\n <span id={labelId}>{children}</span>\n </Button>\n )}\n <PopupList\n items={items}\n trigger={\n <button\n aria-labelledby={labelId}\n className={`chayns-split-button__trigger chayns-button--${variant}`}\n {...(disabled ? { disabled: true } : {})}\n type=\"button\"\n >\n <span aria-hidden=\"true\" className=\"chayns-split-button__chevron\">\n <ButtonIcon icon=\"fa-chevron-down\" />\n </span>\n </button>\n }\n />\n </div>\n );\n};\n\nexport default SplitButton;\n"],"mappings":";;;;;;AAOA,IAAM,eAAe,EACnB,UACA,WACA,UACA,MACA,OACA,SACA,SACA,GAAG,qBACmB;CACtB,MAAM,UAAU,MAAM;CAEtB,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,CAAC,uBAAuB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAFxE,UAAA,CAIG,OACC,oBAAC,QAAD;GACE,mBAAiB;GACjB,WAAU;GACV,GAAK,WAAW,EAAE,UAAU,KAAK,IAAI,CAAC;GAChC;GACN,GAAK,UAAU,EAAE,QAAQ,IAAI,CAAC;GACrB;GAET,UAAA,oBAAC,QAAD;IAAM,IAAI;IAAU;GAAe,CAAA;EAC7B,CAAA,IAER,oBAAC,QAAD;GACE,mBAAiB;GACjB,WAAU;GACV,GAAK,WAAW,EAAE,UAAU,KAAK,IAAI,CAAC;GACtC,GAAK,UAAU,EAAE,QAAQ,IAAI,CAAC;GACrB;GAET,UAAA,oBAAC,QAAD;IAAM,IAAI;IAAU;GAAe,CAAA;EAC7B,CAAA,GAEV,oBAAC,WAAD;GACS;GACP,SACE,oBAAC,UAAD;IACE,mBAAiB;IACjB,WAAW,+CAA+C;IAC1D,GAAK,WAAW,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,MAAK;IAEL,UAAA,oBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KACjC,UAAA,oBAAC,YAAD,EAAY,MAAK,kBAAmB,CAAA;IAChC,CAAA;GACA,CAAA;EAEX,CAAA,CACE;;AAET"}
1
+ {"version":3,"file":"SplitButton.js","names":[],"sources":["../../../src/components/split-button/SplitButton.tsx"],"sourcesContent":["import { forwardRef, useId } from 'react';\n\nimport Button from '../button/Button.js';\nimport ButtonIcon from '../button/button-icon/ButtonIcon.js';\nimport PopupList from '../popup/PopupList.js';\nimport type { SplitButtonProps } from './SplitButton.types.js';\n\nconst SplitButton = forwardRef<HTMLDivElement, SplitButtonProps>(function SplitButton(\n { children, className, disabled, icon, items, onClick, variant, ...containerProps },\n ref,\n) {\n const labelId = useId();\n\n return (\n <div\n {...containerProps}\n className={['chayns-split-button', className].filter(Boolean).join(' ')}\n ref={ref}\n >\n <Button\n aria-labelledby={labelId}\n className=\"chayns-split-button__primary\"\n disabled={disabled}\n {...(icon ? { icon } : {})}\n onClick={onClick}\n variant={variant}\n >\n <span id={labelId}>{children}</span>\n </Button>\n <PopupList\n items={items}\n trigger={\n <button\n aria-labelledby={labelId}\n aria-haspopup=\"menu\"\n className={`chayns-split-button__trigger chayns-button--${variant}`}\n {...(disabled ? { disabled: true } : {})}\n type=\"button\"\n >\n <span aria-hidden=\"true\" className=\"chayns-split-button__chevron\">\n <ButtonIcon icon=\"fa-chevron-down\" />\n </span>\n </button>\n }\n />\n </div>\n );\n});\n\nexport default SplitButton;\n"],"mappings":";;;;;;AAOA,IAAM,cAAc,WAA6C,SAAS,YACxE,EAAE,UAAU,WAAW,UAAU,MAAM,OAAO,SAAS,SAAS,GAAG,kBACnE,KACA;CACA,MAAM,UAAU,MAAM;CAEtB,OACE,qBAAC,OAAD;EACE,GAAI;EACJ,WAAW,CAAC,uBAAuB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACjE;EAHP,UAAA,CAKE,oBAAC,QAAD;GACE,mBAAiB;GACjB,WAAU;GACA;GACV,GAAK,OAAO,EAAE,KAAK,IAAI,CAAC;GACf;GACA;GAET,UAAA,oBAAC,QAAD;IAAM,IAAI;IAAU;GAAe,CAAA;EAC7B,CAAA,GACR,oBAAC,WAAD;GACS;GACP,SACE,oBAAC,UAAD;IACE,mBAAiB;IACjB,iBAAc;IACd,WAAW,+CAA+C;IAC1D,GAAK,WAAW,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,MAAK;IAEL,UAAA,oBAAC,QAAD;KAAM,eAAY;KAAO,WAAU;KACjC,UAAA,oBAAC,YAAD,EAAY,MAAK,kBAAmB,CAAA;IAChC,CAAA;GACA,CAAA;EAEX,CAAA,CACE;;AAET,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { SwitchProps } from './Switch.types.js';
2
- declare function Switch({ children, className, ...inputProps }: SwitchProps): import("react").JSX.Element;
2
+ declare const Switch: import("react").ForwardRefExoticComponent<Omit<SwitchProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
3
3
  export default Switch;
4
4
  //# sourceMappingURL=Switch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/components/switch/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,iBAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,EAAE,WAAW,+BAYlE;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../../src/components/switch/Switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,QAAA,MAAM,MAAM,uHAoBV,CAAC;AAEH,eAAe,MAAM,CAAC"}
@@ -1,17 +1,25 @@
1
+ import { forwardRef } from "react";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  //#region src/components/switch/Switch.tsx
3
- function Switch({ children, className, ...inputProps }) {
4
+ var Switch = forwardRef(function Switch({ children, className, description, ...inputProps }, ref) {
4
5
  const inputClassName = ["chayns-switch__input", className].filter(Boolean).join(" ");
5
6
  return /* @__PURE__ */ jsxs("label", {
6
7
  className: "chayns-switch",
7
8
  children: [
8
- /* @__PURE__ */ jsx("span", {
9
- className: "chayns-switch__label",
10
- children
9
+ /* @__PURE__ */ jsxs("span", {
10
+ className: "chayns-switch__content",
11
+ children: [/* @__PURE__ */ jsx("span", {
12
+ className: "chayns-switch__label",
13
+ children
14
+ }), description !== void 0 ? /* @__PURE__ */ jsx("span", {
15
+ className: "chayns-switch__description",
16
+ children: description
17
+ }) : null]
11
18
  }),
12
19
  /* @__PURE__ */ jsx("input", {
13
20
  ...inputProps,
14
21
  className: inputClassName,
22
+ ref,
15
23
  type: "checkbox"
16
24
  }),
17
25
  /* @__PURE__ */ jsx("span", {
@@ -21,7 +29,7 @@ function Switch({ children, className, ...inputProps }) {
21
29
  })
22
30
  ]
23
31
  });
24
- }
32
+ });
25
33
  //#endregion
26
34
  export { Switch as default };
27
35
 
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","names":[],"sources":["../../../src/components/switch/Switch.tsx"],"sourcesContent":["import type { SwitchProps } from './Switch.types.js';\n\nfunction Switch({ children, className, ...inputProps }: SwitchProps) {\n const inputClassName = ['chayns-switch__input', className].filter(Boolean).join(' ');\n\n return (\n <label className=\"chayns-switch\">\n <span className=\"chayns-switch__label\">{children}</span>\n <input {...inputProps} className={inputClassName} type=\"checkbox\" />\n <span aria-hidden=\"true\" className=\"chayns-switch__control\">\n <span className=\"chayns-switch__knob\" />\n </span>\n </label>\n );\n}\n\nexport default Switch;\n"],"mappings":";;AAEA,SAAS,OAAO,EAAE,UAAU,WAAW,GAAG,cAA2B;CACnE,MAAM,iBAAiB,CAAC,wBAAwB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEnF,OACE,qBAAC,SAAD;EAAO,WAAU;EAAjB,UAAA;GACE,oBAAC,QAAD;IAAM,WAAU;IAAwB;GAAe,CAAA;GACvD,oBAAC,SAAD;IAAO,GAAI;IAAY,WAAW;IAAgB,MAAK;GAAY,CAAA;GACnE,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IACjC,UAAA,oBAAC,QAAD,EAAM,WAAU,sBAAuB,CAAA;GACnC,CAAA;EACD;;AAEX"}
1
+ {"version":3,"file":"Switch.js","names":[],"sources":["../../../src/components/switch/Switch.tsx"],"sourcesContent":["import { forwardRef } from 'react';\n\nimport type { SwitchProps } from './Switch.types.js';\n\nconst Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(\n { children, className, description, ...inputProps },\n ref,\n) {\n const inputClassName = ['chayns-switch__input', className].filter(Boolean).join(' ');\n\n return (\n <label className=\"chayns-switch\">\n <span className=\"chayns-switch__content\">\n <span className=\"chayns-switch__label\">{children}</span>\n {description !== undefined ? (\n <span className=\"chayns-switch__description\">{description}</span>\n ) : null}\n </span>\n <input {...inputProps} className={inputClassName} ref={ref} type=\"checkbox\" />\n <span aria-hidden=\"true\" className=\"chayns-switch__control\">\n <span className=\"chayns-switch__knob\" />\n </span>\n </label>\n );\n});\n\nexport default Switch;\n"],"mappings":";;;AAIA,IAAM,SAAS,WAA0C,SAAS,OAChE,EAAE,UAAU,WAAW,aAAa,GAAG,cACvC,KACA;CACA,MAAM,iBAAiB,CAAC,wBAAwB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEnF,OACE,qBAAC,SAAD;EAAO,WAAU;EAAjB,UAAA;GACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAwB;IAAe,CAAA,GACtD,gBAAgB,KAAA,IACf,oBAAC,QAAD;KAAM,WAAU;KAA8B,UAAA;IAAkB,CAAA,IAC9D,IACA;;GACN,oBAAC,SAAD;IAAO,GAAI;IAAY,WAAW;IAAqB;IAAK,MAAK;GAAY,CAAA;GAC7E,oBAAC,QAAD;IAAM,eAAY;IAAO,WAAU;IACjC,UAAA,oBAAC,QAAD,EAAM,WAAU,sBAAuB,CAAA;GACnC,CAAA;EACD;;AAEX,CAAC"}
@@ -3,6 +3,8 @@ import type { ComponentPropsWithRef, ReactNode } from 'react';
3
3
  export interface SwitchProps extends Omit<ComponentPropsWithRef<'input'>, 'children' | 'type'> {
4
4
  /** Visible, localized label associated with the native checkbox. */
5
5
  children: Exclude<ReactNode, boolean | null | undefined>;
6
+ /** Optional localized supporting text associated with the switch label. */
7
+ description?: ReactNode;
6
8
  /** Switch owns its native input type. */
7
9
  type?: never;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.types.d.ts","sourceRoot":"","sources":["../../../src/components/switch/Switch.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,8EAA8E;AAC9E,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5F,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAEzD,yCAAyC;IACzC,IAAI,CAAC,EAAE,KAAK,CAAC;CACd"}
1
+ {"version":3,"file":"Switch.types.d.ts","sourceRoot":"","sources":["../../../src/components/switch/Switch.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,8EAA8E;AAC9E,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5F,oEAAoE;IACpE,QAAQ,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAEzD,2EAA2E;IAC3E,WAAW,CAAC,EAAE,SAAS,CAAC;IAExB,yCAAyC;IACzC,IAAI,CAAC,EAAE,KAAK,CAAC;CACd"}
@@ -1,4 +1,4 @@
1
1
  import type { TextAreaProps } from './TextArea.types.js';
2
- declare function TextArea({ className, counter, error, helpText, id, placeholder, ...textareaProps }: TextAreaProps): import("react").JSX.Element;
2
+ declare const TextArea: import("react").ForwardRefExoticComponent<Omit<TextAreaProps, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
3
3
  export default TextArea;
4
4
  //# sourceMappingURL=TextArea.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/text-area/TextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,iBAAS,QAAQ,CAAC,EAChB,SAAS,EACT,OAAO,EACP,KAAK,EACL,QAAQ,EACR,EAAE,EACF,WAAW,EACX,GAAG,aAAa,EACjB,EAAE,aAAa,+BAuCf;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/text-area/TextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,QAAA,MAAM,QAAQ,4HA2CZ,CAAC;AAEH,eAAe,QAAQ,CAAC"}
@@ -1,7 +1,7 @@
1
+ import { forwardRef, useId } from "react";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useId } from "react";
3
3
  //#region src/components/text-area/TextArea.tsx
4
- function TextArea({ className, counter, error, helpText, id, placeholder, ...textareaProps }) {
4
+ var TextArea = forwardRef(function TextArea({ className, counter, error, helpText, id, placeholder, ...textareaProps }, ref) {
5
5
  const generatedId = useId();
6
6
  const textareaId = id ?? generatedId;
7
7
  const hasError = error !== void 0;
@@ -18,7 +18,8 @@ function TextArea({ className, counter, error, helpText, id, placeholder, ...tex
18
18
  "aria-invalid": hasError || void 0,
19
19
  className: textareaClassName,
20
20
  id: textareaId,
21
- placeholder: placeholder === void 0 ? void 0 : " "
21
+ placeholder: placeholder === void 0 ? void 0 : " ",
22
+ ref
22
23
  }),
23
24
  placeholder !== void 0 ? /* @__PURE__ */ jsx("label", {
24
25
  className: "chayns-text-area__label",
@@ -38,7 +39,7 @@ function TextArea({ className, counter, error, helpText, id, placeholder, ...tex
38
39
  }) : null
39
40
  ]
40
41
  });
41
- }
42
+ });
42
43
  //#endregion
43
44
  export { TextArea as default };
44
45
 
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.js","names":[],"sources":["../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import { useId } from 'react';\n\nimport type { TextAreaProps } from './TextArea.types.js';\n\nfunction TextArea({\n className,\n counter,\n error,\n helpText,\n id,\n placeholder,\n ...textareaProps\n}: TextAreaProps) {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const hasError = error !== undefined;\n const helpId = helpText !== undefined ? `${textareaId}-help` : undefined;\n const errorId = hasError ? `${textareaId}-error` : undefined;\n const describedBy = [helpId, errorId].filter(Boolean).join(' ') || undefined;\n const textareaClassName = ['chayns-text-area__input', className].filter(Boolean).join(' ');\n\n return (\n <div className={`chayns-text-area${hasError ? ' chayns-text-area--error' : ''}`}>\n <textarea\n {...textareaProps}\n aria-describedby={describedBy}\n aria-invalid={hasError || undefined}\n className={textareaClassName}\n id={textareaId}\n placeholder={placeholder === undefined ? undefined : ' '}\n />\n {placeholder !== undefined ? (\n <label className=\"chayns-text-area__label\" htmlFor={textareaId}>\n {placeholder}\n </label>\n ) : null}\n {helpText !== undefined || hasError || counter !== undefined ? (\n <div className=\"chayns-text-area__help\">\n <div>\n {helpText !== undefined ? <div id={helpId}>{helpText}</div> : null}\n {hasError ? (\n <div className=\"chayns-text-area__error\" id={errorId}>\n {error}\n </div>\n ) : null}\n </div>\n {counter !== undefined ? <div>{counter}</div> : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport default TextArea;\n"],"mappings":";;;AAIA,SAAS,SAAS,EAChB,WACA,SACA,OACA,UACA,IACA,aACA,GAAG,iBACa;CAChB,MAAM,cAAc,MAAM;CAC1B,MAAM,aAAa,MAAM;CACzB,MAAM,WAAW,UAAU,KAAA;CAC3B,MAAM,SAAS,aAAa,KAAA,IAAY,GAAG,WAAW,SAAS,KAAA;CAC/D,MAAM,UAAU,WAAW,GAAG,WAAW,UAAU,KAAA;CACnD,MAAM,cAAc,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CACnE,MAAM,oBAAoB,CAAC,2BAA2B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEzF,OACE,qBAAC,OAAD;EAAK,WAAW,mBAAmB,WAAW,6BAA6B;EAA3E,UAAA;GACE,oBAAC,YAAD;IACE,GAAI;IACJ,oBAAkB;IAClB,gBAAc,YAAY,KAAA;IAC1B,WAAW;IACX,IAAI;IACJ,aAAa,gBAAgB,KAAA,IAAY,KAAA,IAAY;GACtD,CAAA;GACA,gBAAgB,KAAA,IACf,oBAAC,SAAD;IAAO,WAAU;IAA0B,SAAS;IACjD,UAAA;GACI,CAAA,IACL;GACH,aAAa,KAAA,KAAa,YAAY,YAAY,KAAA,IACjD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,qBAAC,OAAD,EAAA,UAAA,CACG,aAAa,KAAA,IAAY,oBAAC,OAAD;KAAK,IAAI;KAAS,UAAA;IAAc,CAAA,IAAI,MAC7D,WACC,oBAAC,OAAD;KAAK,WAAU;KAA0B,IAAI;KAC1C,UAAA;IACE,CAAA,IACH,IACD,EAAA,CAAA,GACJ,YAAY,KAAA,IAAY,oBAAC,OAAD,EAAA,UAAM,QAAa,CAAA,IAAI,IAC7C;GACH,CAAA,IAAA;EACD;;AAET"}
1
+ {"version":3,"file":"TextArea.js","names":[],"sources":["../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import { forwardRef, useId } from 'react';\n\nimport type { TextAreaProps } from './TextArea.types.js';\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n { className, counter, error, helpText, id, placeholder, ...textareaProps },\n ref,\n) {\n const generatedId = useId();\n const textareaId = id ?? generatedId;\n const hasError = error !== undefined;\n const helpId = helpText !== undefined ? `${textareaId}-help` : undefined;\n const errorId = hasError ? `${textareaId}-error` : undefined;\n const describedBy = [helpId, errorId].filter(Boolean).join(' ') || undefined;\n const textareaClassName = ['chayns-text-area__input', className].filter(Boolean).join(' ');\n\n return (\n <div className={`chayns-text-area${hasError ? ' chayns-text-area--error' : ''}`}>\n <textarea\n {...textareaProps}\n aria-describedby={describedBy}\n aria-invalid={hasError || undefined}\n className={textareaClassName}\n id={textareaId}\n placeholder={placeholder === undefined ? undefined : ' '}\n ref={ref}\n />\n {placeholder !== undefined ? (\n <label className=\"chayns-text-area__label\" htmlFor={textareaId}>\n {placeholder}\n </label>\n ) : null}\n {helpText !== undefined || hasError || counter !== undefined ? (\n <div className=\"chayns-text-area__help\">\n <div>\n {helpText !== undefined ? <div id={helpId}>{helpText}</div> : null}\n {hasError ? (\n <div className=\"chayns-text-area__error\" id={errorId}>\n {error}\n </div>\n ) : null}\n </div>\n {counter !== undefined ? <div>{counter}</div> : null}\n </div>\n ) : null}\n </div>\n );\n});\n\nexport default TextArea;\n"],"mappings":";;;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TextField.types.js';
2
- declare function TextField({ className, counter, error, helpText, id, placeholder, ...inputProps }: TextFieldProps): import("react").JSX.Element;
2
+ declare const TextField: import("react").ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
3
3
  export default TextField;
4
4
  //# sourceMappingURL=TextField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/text-field/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,iBAAS,SAAS,CAAC,EACjB,SAAS,EACT,OAAO,EACP,KAAK,EACL,QAAQ,EACR,EAAE,EACF,WAAW,EACX,GAAG,UAAU,EACd,EAAE,cAAc,+BAuChB;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../src/components/text-field/TextField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,QAAA,MAAM,SAAS,0HA2Cb,CAAC;AAEH,eAAe,SAAS,CAAC"}
@@ -1,7 +1,7 @@
1
+ import { forwardRef, useId } from "react";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useId } from "react";
3
3
  //#region src/components/text-field/TextField.tsx
4
- function TextField({ className, counter, error, helpText, id, placeholder, ...inputProps }) {
4
+ var TextField = forwardRef(function TextField({ className, counter, error, helpText, id, placeholder, ...inputProps }, ref) {
5
5
  const generatedId = useId();
6
6
  const inputId = id ?? generatedId;
7
7
  const hasError = error !== void 0;
@@ -18,7 +18,8 @@ function TextField({ className, counter, error, helpText, id, placeholder, ...in
18
18
  "aria-invalid": hasError || void 0,
19
19
  className: inputClassName,
20
20
  id: inputId,
21
- placeholder: placeholder === void 0 ? void 0 : " "
21
+ placeholder: placeholder === void 0 ? void 0 : " ",
22
+ ref
22
23
  }),
23
24
  placeholder !== void 0 ? /* @__PURE__ */ jsx("label", {
24
25
  className: "chayns-text-field__label",
@@ -38,7 +39,7 @@ function TextField({ className, counter, error, helpText, id, placeholder, ...in
38
39
  }) : null
39
40
  ]
40
41
  });
41
- }
42
+ });
42
43
  //#endregion
43
44
  export { TextField as default };
44
45
 
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.js","names":[],"sources":["../../../src/components/text-field/TextField.tsx"],"sourcesContent":["import { useId } from 'react';\n\nimport type { TextFieldProps } from './TextField.types.js';\n\nfunction TextField({\n className,\n counter,\n error,\n helpText,\n id,\n placeholder,\n ...inputProps\n}: TextFieldProps) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const hasError = error !== undefined;\n const helpId = helpText !== undefined ? `${inputId}-help` : undefined;\n const errorId = hasError ? `${inputId}-error` : undefined;\n const describedBy = [helpId, errorId].filter(Boolean).join(' ') || undefined;\n const inputClassName = ['chayns-text-field__input', className].filter(Boolean).join(' ');\n\n return (\n <div className={`chayns-text-field${hasError ? ' chayns-text-field--error' : ''}`}>\n <input\n {...inputProps}\n aria-describedby={describedBy}\n aria-invalid={hasError || undefined}\n className={inputClassName}\n id={inputId}\n placeholder={placeholder === undefined ? undefined : ' '}\n />\n {placeholder !== undefined ? (\n <label className=\"chayns-text-field__label\" htmlFor={inputId}>\n {placeholder}\n </label>\n ) : null}\n {helpText !== undefined || hasError || counter !== undefined ? (\n <div className=\"chayns-text-field__help\">\n <div>\n {helpText !== undefined ? <div id={helpId}>{helpText}</div> : null}\n {hasError ? (\n <div className=\"chayns-text-field__error\" id={errorId}>\n {error}\n </div>\n ) : null}\n </div>\n {counter !== undefined ? <div>{counter}</div> : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport default TextField;\n"],"mappings":";;;AAIA,SAAS,UAAU,EACjB,WACA,SACA,OACA,UACA,IACA,aACA,GAAG,cACc;CACjB,MAAM,cAAc,MAAM;CAC1B,MAAM,UAAU,MAAM;CACtB,MAAM,WAAW,UAAU,KAAA;CAC3B,MAAM,SAAS,aAAa,KAAA,IAAY,GAAG,QAAQ,SAAS,KAAA;CAC5D,MAAM,UAAU,WAAW,GAAG,QAAQ,UAAU,KAAA;CAChD,MAAM,cAAc,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CACnE,MAAM,iBAAiB,CAAC,4BAA4B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEvF,OACE,qBAAC,OAAD;EAAK,WAAW,oBAAoB,WAAW,8BAA8B;EAA7E,UAAA;GACE,oBAAC,SAAD;IACE,GAAI;IACJ,oBAAkB;IAClB,gBAAc,YAAY,KAAA;IAC1B,WAAW;IACX,IAAI;IACJ,aAAa,gBAAgB,KAAA,IAAY,KAAA,IAAY;GACtD,CAAA;GACA,gBAAgB,KAAA,IACf,oBAAC,SAAD;IAAO,WAAU;IAA2B,SAAS;IAClD,UAAA;GACI,CAAA,IACL;GACH,aAAa,KAAA,KAAa,YAAY,YAAY,KAAA,IACjD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,qBAAC,OAAD,EAAA,UAAA,CACG,aAAa,KAAA,IAAY,oBAAC,OAAD;KAAK,IAAI;KAAS,UAAA;IAAc,CAAA,IAAI,MAC7D,WACC,oBAAC,OAAD;KAAK,WAAU;KAA2B,IAAI;KAC3C,UAAA;IACE,CAAA,IACH,IACD,EAAA,CAAA,GACJ,YAAY,KAAA,IAAY,oBAAC,OAAD,EAAA,UAAM,QAAa,CAAA,IAAI,IAC7C;GACH,CAAA,IAAA;EACD;;AAET"}
1
+ {"version":3,"file":"TextField.js","names":[],"sources":["../../../src/components/text-field/TextField.tsx"],"sourcesContent":["import { forwardRef, useId } from 'react';\n\nimport type { TextFieldProps } from './TextField.types.js';\n\nconst TextField = forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n { className, counter, error, helpText, id, placeholder, ...inputProps },\n ref,\n) {\n const generatedId = useId();\n const inputId = id ?? generatedId;\n const hasError = error !== undefined;\n const helpId = helpText !== undefined ? `${inputId}-help` : undefined;\n const errorId = hasError ? `${inputId}-error` : undefined;\n const describedBy = [helpId, errorId].filter(Boolean).join(' ') || undefined;\n const inputClassName = ['chayns-text-field__input', className].filter(Boolean).join(' ');\n\n return (\n <div className={`chayns-text-field${hasError ? ' chayns-text-field--error' : ''}`}>\n <input\n {...inputProps}\n aria-describedby={describedBy}\n aria-invalid={hasError || undefined}\n className={inputClassName}\n id={inputId}\n placeholder={placeholder === undefined ? undefined : ' '}\n ref={ref}\n />\n {placeholder !== undefined ? (\n <label className=\"chayns-text-field__label\" htmlFor={inputId}>\n {placeholder}\n </label>\n ) : null}\n {helpText !== undefined || hasError || counter !== undefined ? (\n <div className=\"chayns-text-field__help\">\n <div>\n {helpText !== undefined ? <div id={helpId}>{helpText}</div> : null}\n {hasError ? (\n <div className=\"chayns-text-field__error\" id={errorId}>\n {error}\n </div>\n ) : null}\n </div>\n {counter !== undefined ? <div>{counter}</div> : null}\n </div>\n ) : null}\n </div>\n );\n});\n\nexport default TextField;\n"],"mappings":";;;AAIA,IAAM,YAAY,WAA6C,SAAS,UACtE,EAAE,WAAW,SAAS,OAAO,UAAU,IAAI,aAAa,GAAG,cAC3D,KACA;CACA,MAAM,cAAc,MAAM;CAC1B,MAAM,UAAU,MAAM;CACtB,MAAM,WAAW,UAAU,KAAA;CAC3B,MAAM,SAAS,aAAa,KAAA,IAAY,GAAG,QAAQ,SAAS,KAAA;CAC5D,MAAM,UAAU,WAAW,GAAG,QAAQ,UAAU,KAAA;CAChD,MAAM,cAAc,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CACnE,MAAM,iBAAiB,CAAC,4BAA4B,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAEvF,OACE,qBAAC,OAAD;EAAK,WAAW,oBAAoB,WAAW,8BAA8B;EAA7E,UAA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