@chayns-ui/core 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +5 -1
  2. package/dist/button.css +16 -0
  3. package/dist/checkbox.css +83 -0
  4. package/dist/components/accordion/Accordion.d.ts.map +1 -1
  5. package/dist/components/accordion/Accordion.js +3 -0
  6. package/dist/components/accordion/Accordion.js.map +1 -1
  7. package/dist/components/checkbox/Checkbox.d.ts +4 -0
  8. package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
  9. package/dist/components/checkbox/Checkbox.js +27 -0
  10. package/dist/components/checkbox/Checkbox.js.map +1 -0
  11. package/dist/components/checkbox/Checkbox.types.d.ts +9 -0
  12. package/dist/components/checkbox/Checkbox.types.d.ts.map +1 -0
  13. package/dist/components/list/List.d.ts +14 -2
  14. package/dist/components/list/List.d.ts.map +1 -1
  15. package/dist/components/list/List.js +79 -6
  16. package/dist/components/list/List.js.map +1 -1
  17. package/dist/components/list/List.types.d.ts +17 -77
  18. package/dist/components/list/List.types.d.ts.map +1 -1
  19. package/dist/components/list/ListContext.d.ts +6 -0
  20. package/dist/components/list/ListContext.d.ts.map +1 -0
  21. package/dist/components/list/ListContext.js +14 -0
  22. package/dist/components/list/ListContext.js.map +1 -0
  23. package/dist/components/message-box/MessageBox.d.ts +4 -0
  24. package/dist/components/message-box/MessageBox.d.ts.map +1 -0
  25. package/dist/components/message-box/MessageBox.js +19 -0
  26. package/dist/components/message-box/MessageBox.js.map +1 -0
  27. package/dist/components/message-box/MessageBox.types.d.ts +13 -0
  28. package/dist/components/message-box/MessageBox.types.d.ts.map +1 -0
  29. package/dist/components/popup/Popup.d.ts +6 -3
  30. package/dist/components/popup/Popup.d.ts.map +1 -1
  31. package/dist/components/popup/Popup.js +102 -90
  32. package/dist/components/popup/Popup.js.map +1 -1
  33. package/dist/components/popup/Popup.types.d.ts +17 -7
  34. package/dist/components/popup/Popup.types.d.ts.map +1 -1
  35. package/dist/components/popup/PopupList.d.ts.map +1 -1
  36. package/dist/components/popup/PopupList.js +7 -5
  37. package/dist/components/popup/PopupList.js.map +1 -1
  38. package/dist/components/radio-group/RadioGroup.d.ts +6 -0
  39. package/dist/components/radio-group/RadioGroup.d.ts.map +1 -0
  40. package/dist/components/radio-group/RadioGroup.js +69 -0
  41. package/dist/components/radio-group/RadioGroup.js.map +1 -0
  42. package/dist/components/radio-group/RadioGroup.types.d.ts +30 -0
  43. package/dist/components/radio-group/RadioGroup.types.d.ts.map +1 -0
  44. package/dist/components/radio-group/RadioGroupContext.d.ts +11 -0
  45. package/dist/components/radio-group/RadioGroupContext.d.ts.map +1 -0
  46. package/dist/components/radio-group/RadioGroupContext.js +12 -0
  47. package/dist/components/radio-group/RadioGroupContext.js.map +1 -0
  48. package/dist/components/segmented-control/SegmentedControl.d.ts +16 -0
  49. package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -0
  50. package/dist/components/segmented-control/SegmentedControl.js +146 -0
  51. package/dist/components/segmented-control/SegmentedControl.js.map +1 -0
  52. package/dist/components/segmented-control/SegmentedControl.types.d.ts +41 -0
  53. package/dist/components/segmented-control/SegmentedControl.types.d.ts.map +1 -0
  54. package/dist/components/segmented-control/SegmentedControlContext.d.ts +11 -0
  55. package/dist/components/segmented-control/SegmentedControlContext.d.ts.map +1 -0
  56. package/dist/components/segmented-control/SegmentedControlContext.js +12 -0
  57. package/dist/components/segmented-control/SegmentedControlContext.js.map +1 -0
  58. package/dist/components/switch/Switch.d.ts +4 -0
  59. package/dist/components/switch/Switch.d.ts.map +1 -0
  60. package/dist/components/switch/Switch.js +28 -0
  61. package/dist/components/switch/Switch.js.map +1 -0
  62. package/dist/components/switch/Switch.types.d.ts +9 -0
  63. package/dist/components/switch/Switch.types.d.ts.map +1 -0
  64. package/dist/components/text-area/TextArea.d.ts +4 -0
  65. package/dist/components/text-area/TextArea.d.ts.map +1 -0
  66. package/dist/components/text-area/TextArea.js +45 -0
  67. package/dist/components/text-area/TextArea.js.map +1 -0
  68. package/dist/components/text-area/TextArea.types.d.ts +15 -0
  69. package/dist/components/text-area/TextArea.types.d.ts.map +1 -0
  70. package/dist/components/text-field/TextField.d.ts +4 -0
  71. package/dist/components/text-field/TextField.d.ts.map +1 -0
  72. package/dist/components/text-field/TextField.js +45 -0
  73. package/dist/components/text-field/TextField.js.map +1 -0
  74. package/dist/components/text-field/TextField.types.d.ts +15 -0
  75. package/dist/components/text-field/TextField.types.d.ts.map +1 -0
  76. package/dist/index.d.ts +15 -2
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +9 -3
  79. package/dist/list.css +33 -44
  80. package/dist/message-box.css +26 -0
  81. package/dist/radio-group.css +102 -0
  82. package/dist/segmented-control.css +79 -0
  83. package/dist/styles.css +7 -0
  84. package/dist/switch.css +76 -0
  85. package/dist/text-area.css +136 -0
  86. package/dist/text-field.css +138 -0
  87. package/package.json +8 -1
  88. package/dist/components/list-item/ListItem.d.ts +0 -4
  89. package/dist/components/list-item/ListItem.d.ts.map +0 -1
  90. package/dist/components/list-item/ListItem.js +0 -42
  91. package/dist/components/list-item/ListItem.js.map +0 -1
  92. package/dist/components/list-item/list-item-body/ListItemBody.d.ts +0 -10
  93. package/dist/components/list-item/list-item-body/ListItemBody.d.ts.map +0 -1
  94. package/dist/components/list-item/list-item-body/ListItemBody.js +0 -30
  95. package/dist/components/list-item/list-item-body/ListItemBody.js.map +0 -1
@@ -0,0 +1,146 @@
1
+ import { SegmentedControlContext, useSegmentedControlContext } from "./SegmentedControlContext.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { forwardRef, useId, useLayoutEffect, useRef, useState } from "react";
4
+ //#region src/components/segmented-control/SegmentedControl.tsx
5
+ function getOrderedSegments(segments) {
6
+ return [...segments.entries()].filter(([, element]) => !element.disabled).sort(([, first], [, second]) => {
7
+ return first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
8
+ });
9
+ }
10
+ var Segment = forwardRef(function Segment({ children, className, disabled, value, ...buttonProps }, ref) {
11
+ const control = useSegmentedControlContext();
12
+ const localRef = useRef(null);
13
+ const isSelected = control.value === value;
14
+ const resolvedClassName = [
15
+ "chayns-segmented-control__segment",
16
+ isSelected ? "chayns-segmented-control__segment--selected" : "",
17
+ className
18
+ ].filter(Boolean).join(" ");
19
+ useLayoutEffect(() => {
20
+ if (localRef.current === null) return;
21
+ return control.registerSegment(value, localRef.current);
22
+ }, [control, value]);
23
+ function setRef(element) {
24
+ localRef.current = element;
25
+ if (typeof ref === "function") ref(element);
26
+ else if (ref !== null) ref.current = element;
27
+ }
28
+ function handleKeyDown(event) {
29
+ if ([
30
+ "ArrowDown",
31
+ "ArrowLeft",
32
+ "ArrowRight",
33
+ "ArrowUp",
34
+ "End",
35
+ "Home"
36
+ ].includes(event.key)) {
37
+ event.preventDefault();
38
+ control.moveFocus(value, event.key);
39
+ }
40
+ }
41
+ return /* @__PURE__ */ jsx("button", {
42
+ ...buttonProps,
43
+ "aria-checked": isSelected,
44
+ className: resolvedClassName,
45
+ disabled,
46
+ onClick: () => control.selectValue(value),
47
+ onKeyDown: handleKeyDown,
48
+ ref: setRef,
49
+ role: "radio",
50
+ tabIndex: isSelected ? 0 : -1,
51
+ type: "button",
52
+ children
53
+ });
54
+ });
55
+ var SegmentedControlRoot = forwardRef(function SegmentedControlRoot({ children, className, defaultValue, label, onValueChange, value, ...rootProps }, ref) {
56
+ const labelId = useId();
57
+ const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
58
+ const segments = useRef(/* @__PURE__ */ new Map());
59
+ const segmentsElement = useRef(null);
60
+ const [indicator, setIndicator] = useState({
61
+ offset: 0,
62
+ width: 0
63
+ });
64
+ const selectedValue = value ?? uncontrolledValue ?? "";
65
+ const resolvedClassName = ["chayns-segmented-control", className].filter(Boolean).join(" ");
66
+ function selectValue(nextValue) {
67
+ if (value === void 0) setUncontrolledValue(nextValue);
68
+ onValueChange?.(nextValue);
69
+ }
70
+ function registerSegment(segmentValue, element) {
71
+ segments.current.set(segmentValue, element);
72
+ return () => {
73
+ segments.current.delete(segmentValue);
74
+ };
75
+ }
76
+ function moveFocus(currentValue, key) {
77
+ const enabledSegments = getOrderedSegments(segments.current);
78
+ const currentIndex = enabledSegments.findIndex(([segmentValue]) => segmentValue === currentValue);
79
+ if (currentIndex === -1 || enabledSegments.length === 0) return;
80
+ let targetIndex = currentIndex;
81
+ if (key === "Home") targetIndex = 0;
82
+ else if (key === "End") targetIndex = enabledSegments.length - 1;
83
+ else if (key === "ArrowLeft" || key === "ArrowUp") targetIndex = (currentIndex - 1 + enabledSegments.length) % enabledSegments.length;
84
+ else if (key === "ArrowRight" || key === "ArrowDown") targetIndex = (currentIndex + 1) % enabledSegments.length;
85
+ const nextSegment = enabledSegments[targetIndex];
86
+ if (nextSegment === void 0) return;
87
+ const [nextValue, nextElement] = nextSegment;
88
+ selectValue(nextValue);
89
+ nextElement.focus();
90
+ }
91
+ useLayoutEffect(() => {
92
+ const container = segmentsElement.current;
93
+ const selectedSegment = segments.current.get(selectedValue);
94
+ if (container === null || selectedSegment === void 0) return;
95
+ const observedContainer = container;
96
+ const observedSegment = selectedSegment;
97
+ function updateIndicator() {
98
+ const paddingInlineStart = Number.parseFloat(window.getComputedStyle(observedContainer).paddingInlineStart);
99
+ setIndicator({
100
+ offset: observedSegment.offsetLeft - (Number.isNaN(paddingInlineStart) ? 0 : paddingInlineStart),
101
+ width: observedSegment.offsetWidth
102
+ });
103
+ }
104
+ updateIndicator();
105
+ if (typeof ResizeObserver === "undefined") return;
106
+ const observer = new ResizeObserver(updateIndicator);
107
+ observer.observe(observedContainer);
108
+ return () => observer.disconnect();
109
+ }, [selectedValue]);
110
+ return /* @__PURE__ */ jsx(SegmentedControlContext.Provider, {
111
+ value: {
112
+ moveFocus,
113
+ registerSegment,
114
+ selectValue,
115
+ value: selectedValue
116
+ },
117
+ children: /* @__PURE__ */ jsxs("div", {
118
+ ...rootProps,
119
+ "aria-labelledby": labelId,
120
+ className: resolvedClassName,
121
+ ref,
122
+ role: "radiogroup",
123
+ children: [/* @__PURE__ */ jsx("span", {
124
+ className: "chayns-segmented-control__label",
125
+ id: labelId,
126
+ children: label
127
+ }), /* @__PURE__ */ jsxs("div", {
128
+ className: "chayns-segmented-control__segments",
129
+ ref: segmentsElement,
130
+ children: [/* @__PURE__ */ jsx("span", {
131
+ "aria-hidden": "true",
132
+ className: "chayns-segmented-control__indicator",
133
+ style: {
134
+ transform: `translateX(${indicator.offset}px)`,
135
+ width: indicator.width
136
+ }
137
+ }), children]
138
+ })]
139
+ })
140
+ });
141
+ });
142
+ var SegmentedControl = Object.assign(SegmentedControlRoot, { Segment });
143
+ //#endregion
144
+ export { SegmentedControl as default };
145
+
146
+ //# sourceMappingURL=SegmentedControl.js.map
@@ -0,0 +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,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;EAE1D,IAAI,cAAc,QAAQ,oBAAoB,KAAA,GAC5C;EAGF,MAAM,oBAAoB;EAC1B,MAAM,kBAAkB;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"}
@@ -0,0 +1,41 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ export interface ControlledSelection {
3
+ /** Controlled selected segment value. */
4
+ value: string;
5
+ /** Receives the next value after activation. */
6
+ onValueChange: (value: string) => void;
7
+ defaultValue?: never;
8
+ }
9
+ export interface UncontrolledSelection {
10
+ /** Initial selected segment value. */
11
+ defaultValue: string;
12
+ /** Controlled value is not accepted for uncontrolled use. */
13
+ value?: never;
14
+ /** Receives the next value after activation. */
15
+ onValueChange?: (value: string) => void;
16
+ }
17
+ /** Props for a labelled, single-selection segmented radiogroup. */
18
+ export type SegmentedControlProps = Omit<ComponentPropsWithRef<'div'>, 'aria-labelledby' | 'children' | 'role'> & (ControlledSelection | UncontrolledSelection) & {
19
+ /** Visible, localized group label. */
20
+ label: Exclude<ReactNode, boolean | null | undefined>;
21
+ /** SegmentedControl.Segment children. */
22
+ children: ReactNode;
23
+ /** SegmentedControl owns the radiogroup semantics and label relationship. */
24
+ role?: never;
25
+ 'aria-labelledby'?: never;
26
+ };
27
+ /** Props for a visible-label native button segment. */
28
+ export interface SegmentProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-checked' | 'children' | 'onClick' | 'onKeyDown' | 'role' | 'tabIndex' | 'type'> {
29
+ /** Stable value that identifies this segment in its control. */
30
+ value: string;
31
+ /** Visible, localized button label. */
32
+ children: Exclude<ReactNode, boolean | null | undefined>;
33
+ /** SegmentedControl owns the native button semantics and interactions. */
34
+ type?: never;
35
+ role?: never;
36
+ 'aria-checked'?: never;
37
+ tabIndex?: never;
38
+ onClick?: never;
39
+ onKeyDown?: never;
40
+ }
41
+ //# sourceMappingURL=SegmentedControl.types.d.ts.map
@@ -0,0 +1 @@
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,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,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,KAAK,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB"}
@@ -0,0 +1,11 @@
1
+ interface SegmentedControlContextValue {
2
+ moveFocus: (currentValue: string, key: string) => void;
3
+ registerSegment: (value: string, element: HTMLButtonElement) => () => void;
4
+ selectValue: (value: string) => void;
5
+ value: string;
6
+ }
7
+ declare const SegmentedControlContext: import("react").Context<SegmentedControlContextValue | null>;
8
+ declare function useSegmentedControlContext(): SegmentedControlContextValue;
9
+ export { SegmentedControlContext, useSegmentedControlContext };
10
+ export type { SegmentedControlContextValue };
11
+ //# sourceMappingURL=SegmentedControlContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControlContext.d.ts","sourceRoot":"","sources":["../../../src/components/segmented-control/SegmentedControlContext.ts"],"names":[],"mappings":"AAEA,UAAU,4BAA4B;IACpC,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,MAAM,IAAI,CAAC;IAC3E,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,uBAAuB,8DAA2D,CAAC;AAEzF,iBAAS,0BAA0B,iCAQlC;AAED,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,CAAC;AAC/D,YAAY,EAAE,4BAA4B,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createContext, useContext } from "react";
2
+ //#region src/components/segmented-control/SegmentedControlContext.ts
3
+ var SegmentedControlContext = createContext(null);
4
+ function useSegmentedControlContext() {
5
+ const context = useContext(SegmentedControlContext);
6
+ if (context === null) throw new Error("SegmentedControl.Segment must be rendered within SegmentedControl.");
7
+ return context;
8
+ }
9
+ //#endregion
10
+ export { SegmentedControlContext, useSegmentedControlContext };
11
+
12
+ //# sourceMappingURL=SegmentedControlContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControlContext.js","names":[],"sources":["../../../src/components/segmented-control/SegmentedControlContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\ninterface SegmentedControlContextValue {\n moveFocus: (currentValue: string, key: string) => void;\n registerSegment: (value: string, element: HTMLButtonElement) => () => void;\n selectValue: (value: string) => void;\n value: string;\n}\n\nconst SegmentedControlContext = createContext<SegmentedControlContextValue | null>(null);\n\nfunction useSegmentedControlContext() {\n const context = useContext(SegmentedControlContext);\n\n if (context === null) {\n throw new Error('SegmentedControl.Segment must be rendered within SegmentedControl.');\n }\n\n return context;\n}\n\nexport { SegmentedControlContext, useSegmentedControlContext };\nexport type { SegmentedControlContextValue };\n"],"mappings":";;AASA,IAAM,0BAA0B,cAAmD,IAAI;AAEvF,SAAS,6BAA6B;CACpC,MAAM,UAAU,WAAW,uBAAuB;CAElD,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,oEAAoE;CAGtF,OAAO;AACT"}
@@ -0,0 +1,4 @@
1
+ import type { SwitchProps } from './Switch.types.js';
2
+ declare function Switch({ children, className, ...inputProps }: SwitchProps): import("react").JSX.Element;
3
+ export default Switch;
4
+ //# sourceMappingURL=Switch.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,28 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ //#region src/components/switch/Switch.tsx
3
+ function Switch({ children, className, ...inputProps }) {
4
+ const inputClassName = ["chayns-switch__input", className].filter(Boolean).join(" ");
5
+ return /* @__PURE__ */ jsxs("label", {
6
+ className: "chayns-switch",
7
+ children: [
8
+ /* @__PURE__ */ jsx("span", {
9
+ className: "chayns-switch__label",
10
+ children
11
+ }),
12
+ /* @__PURE__ */ jsx("input", {
13
+ ...inputProps,
14
+ className: inputClassName,
15
+ type: "checkbox"
16
+ }),
17
+ /* @__PURE__ */ jsx("span", {
18
+ "aria-hidden": "true",
19
+ className: "chayns-switch__control",
20
+ children: /* @__PURE__ */ jsx("span", { className: "chayns-switch__knob" })
21
+ })
22
+ ]
23
+ });
24
+ }
25
+ //#endregion
26
+ export { Switch as default };
27
+
28
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +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"}
@@ -0,0 +1,9 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ /** Props for a visible-label native checkbox used as an immediate setting. */
3
+ export interface SwitchProps extends Omit<ComponentPropsWithRef<'input'>, 'children' | 'type'> {
4
+ /** Visible, localized label associated with the native checkbox. */
5
+ children: Exclude<ReactNode, boolean | null | undefined>;
6
+ /** Switch owns its native input type. */
7
+ type?: never;
8
+ }
9
+ //# sourceMappingURL=Switch.types.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,4 @@
1
+ import type { TextAreaProps } from './TextArea.types.js';
2
+ declare function TextArea({ className, counter, error, helpText, id, placeholder, ...textareaProps }: TextAreaProps): import("react").JSX.Element;
3
+ export default TextArea;
4
+ //# sourceMappingURL=TextArea.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,45 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ //#region src/components/text-area/TextArea.tsx
4
+ function TextArea({ className, counter, error, helpText, id, placeholder, ...textareaProps }) {
5
+ const generatedId = useId();
6
+ const textareaId = id ?? generatedId;
7
+ const hasError = error !== void 0;
8
+ const helpId = helpText !== void 0 ? `${textareaId}-help` : void 0;
9
+ const errorId = hasError ? `${textareaId}-error` : void 0;
10
+ const describedBy = [helpId, errorId].filter(Boolean).join(" ") || void 0;
11
+ const textareaClassName = ["chayns-text-area__input", className].filter(Boolean).join(" ");
12
+ return /* @__PURE__ */ jsxs("div", {
13
+ className: `chayns-text-area${hasError ? " chayns-text-area--error" : ""}`,
14
+ children: [
15
+ /* @__PURE__ */ jsx("textarea", {
16
+ ...textareaProps,
17
+ "aria-describedby": describedBy,
18
+ "aria-invalid": hasError || void 0,
19
+ className: textareaClassName,
20
+ id: textareaId,
21
+ placeholder: placeholder === void 0 ? void 0 : " "
22
+ }),
23
+ placeholder !== void 0 ? /* @__PURE__ */ jsx("label", {
24
+ className: "chayns-text-area__label",
25
+ htmlFor: textareaId,
26
+ children: placeholder
27
+ }) : null,
28
+ helpText !== void 0 || hasError || counter !== void 0 ? /* @__PURE__ */ jsxs("div", {
29
+ className: "chayns-text-area__help",
30
+ children: [/* @__PURE__ */ jsxs("div", { children: [helpText !== void 0 ? /* @__PURE__ */ jsx("div", {
31
+ id: helpId,
32
+ children: helpText
33
+ }) : null, hasError ? /* @__PURE__ */ jsx("div", {
34
+ className: "chayns-text-area__error",
35
+ id: errorId,
36
+ children: error
37
+ }) : null] }), counter !== void 0 ? /* @__PURE__ */ jsx("div", { children: counter }) : null]
38
+ }) : null
39
+ ]
40
+ });
41
+ }
42
+ //#endregion
43
+ export { TextArea as default };
44
+
45
+ //# sourceMappingURL=TextArea.js.map
@@ -0,0 +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"}
@@ -0,0 +1,15 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ /** Props for a native multi-line textarea with optional help and error content. */
3
+ export interface TextAreaProps extends Omit<ComponentPropsWithRef<'textarea'>, 'aria-describedby' | 'aria-invalid' | 'children'> {
4
+ /** Supporting content linked to the textarea. */
5
+ helpText?: ReactNode;
6
+ /** Validation content linked to the textarea and reflected through aria-invalid. */
7
+ error?: ReactNode;
8
+ /** Visible, consumer-provided counter content. */
9
+ counter?: ReactNode;
10
+ /** Description IDs are generated from the documented help/error slots. */
11
+ 'aria-describedby'?: never;
12
+ /** Invalid state is derived exclusively from the documented error slot. */
13
+ 'aria-invalid'?: never;
14
+ }
15
+ //# sourceMappingURL=TextArea.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextArea.types.d.ts","sourceRoot":"","sources":["../../../src/components/text-area/TextArea.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,mFAAmF;AACnF,MAAM,WAAW,aAAc,SAAQ,IAAI,CACzC,qBAAqB,CAAC,UAAU,CAAC,EACjC,kBAAkB,GAAG,cAAc,GAAG,UAAU,CACjD;IACC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,oFAAoF;IACpF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAE3B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ import type { TextFieldProps } from './TextField.types.js';
2
+ declare function TextField({ className, counter, error, helpText, id, placeholder, ...inputProps }: TextFieldProps): import("react").JSX.Element;
3
+ export default TextField;
4
+ //# sourceMappingURL=TextField.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,45 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ //#region src/components/text-field/TextField.tsx
4
+ function TextField({ className, counter, error, helpText, id, placeholder, ...inputProps }) {
5
+ const generatedId = useId();
6
+ const inputId = id ?? generatedId;
7
+ const hasError = error !== void 0;
8
+ const helpId = helpText !== void 0 ? `${inputId}-help` : void 0;
9
+ const errorId = hasError ? `${inputId}-error` : void 0;
10
+ const describedBy = [helpId, errorId].filter(Boolean).join(" ") || void 0;
11
+ const inputClassName = ["chayns-text-field__input", className].filter(Boolean).join(" ");
12
+ return /* @__PURE__ */ jsxs("div", {
13
+ className: `chayns-text-field${hasError ? " chayns-text-field--error" : ""}`,
14
+ children: [
15
+ /* @__PURE__ */ jsx("input", {
16
+ ...inputProps,
17
+ "aria-describedby": describedBy,
18
+ "aria-invalid": hasError || void 0,
19
+ className: inputClassName,
20
+ id: inputId,
21
+ placeholder: placeholder === void 0 ? void 0 : " "
22
+ }),
23
+ placeholder !== void 0 ? /* @__PURE__ */ jsx("label", {
24
+ className: "chayns-text-field__label",
25
+ htmlFor: inputId,
26
+ children: placeholder
27
+ }) : null,
28
+ helpText !== void 0 || hasError || counter !== void 0 ? /* @__PURE__ */ jsxs("div", {
29
+ className: "chayns-text-field__help",
30
+ children: [/* @__PURE__ */ jsxs("div", { children: [helpText !== void 0 ? /* @__PURE__ */ jsx("div", {
31
+ id: helpId,
32
+ children: helpText
33
+ }) : null, hasError ? /* @__PURE__ */ jsx("div", {
34
+ className: "chayns-text-field__error",
35
+ id: errorId,
36
+ children: error
37
+ }) : null] }), counter !== void 0 ? /* @__PURE__ */ jsx("div", { children: counter }) : null]
38
+ }) : null
39
+ ]
40
+ });
41
+ }
42
+ //#endregion
43
+ export { TextField as default };
44
+
45
+ //# sourceMappingURL=TextField.js.map
@@ -0,0 +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"}
@@ -0,0 +1,15 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from 'react';
2
+ /** Props for a native single-line input with optional help and error content. */
3
+ export interface TextFieldProps extends Omit<ComponentPropsWithRef<'input'>, 'aria-describedby' | 'aria-invalid' | 'children'> {
4
+ /** Supporting content linked to the input. */
5
+ helpText?: ReactNode;
6
+ /** Validation content linked to the input and reflected through aria-invalid. */
7
+ error?: ReactNode;
8
+ /** Visible, consumer-provided counter content. */
9
+ counter?: ReactNode;
10
+ /** Description IDs are generated from the documented help/error slots. */
11
+ 'aria-describedby'?: never;
12
+ /** Invalid state is derived exclusively from the documented error slot. */
13
+ 'aria-invalid'?: never;
14
+ }
15
+ //# sourceMappingURL=TextField.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextField.types.d.ts","sourceRoot":"","sources":["../../../src/components/text-field/TextField.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9D,iFAAiF;AACjF,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,qBAAqB,CAAC,OAAO,CAAC,EAC9B,kBAAkB,GAAG,cAAc,GAAG,UAAU,CACjD;IACC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,iFAAiF;IACjF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kDAAkD;IAClD,OAAO,CAAC,EAAE,SAAS,CAAC;IAEpB,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,KAAK,CAAC;IAE3B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,20 @@ export { default as Button } from './components/button/Button.js';
2
2
  export { default as IconButton } from './components/icon-button/IconButton.js';
3
3
  export type { ButtonContent, ButtonIcon, ButtonProps, ButtonVariant, } from './components/button/Button.types.js';
4
4
  export type { IconButtonProps } from './components/icon-button/IconButton.types.js';
5
+ export { default as TextField } from './components/text-field/TextField.js';
6
+ export type { TextFieldProps } from './components/text-field/TextField.types.js';
7
+ export { default as TextArea } from './components/text-area/TextArea.js';
8
+ export type { TextAreaProps } from './components/text-area/TextArea.types.js';
9
+ export { default as Checkbox } from './components/checkbox/Checkbox.js';
10
+ export type { CheckboxProps } from './components/checkbox/Checkbox.types.js';
11
+ export { default as Switch } from './components/switch/Switch.js';
12
+ export type { SwitchProps } from './components/switch/Switch.types.js';
13
+ export { default as RadioGroup } from './components/radio-group/RadioGroup.js';
14
+ export type { RadioGroupProps, RadioProps } from './components/radio-group/RadioGroup.types.js';
15
+ export { default as SegmentedControl } from './components/segmented-control/SegmentedControl.js';
16
+ export type { SegmentedControlProps, SegmentProps, } from './components/segmented-control/SegmentedControl.types.js';
17
+ export { default as MessageBox } from './components/message-box/MessageBox.js';
18
+ export type { MessageBoxProps, MessageBoxTone } from './components/message-box/MessageBox.types.js';
5
19
  export { default as Popup } from './components/popup/Popup.js';
6
20
  export { default as PopupList } from './components/popup/PopupList.js';
7
21
  export type { PopupListItem, PopupListProps, PopupProps } from './components/popup/Popup.types.js';
@@ -14,8 +28,7 @@ export { default as AvatarGroup } from './components/avatar-group/AvatarGroup.js
14
28
  export type { AvatarProps } from './components/avatar/Avatar.types.js';
15
29
  export type { AvatarGroupProps } from './components/avatar-group/AvatarGroup.types.js';
16
30
  export { default as List } from './components/list/List.js';
17
- export { default as ListItem } from './components/list-item/ListItem.js';
18
- export type { ListProps, ListItemProps } from './components/list/List.types.js';
31
+ export type { ListItemActionProps, ListItemPartProps, ListItemProps, ListItemStatusProps, ListProps, } from './components/list/List.types.js';
19
32
  export { default as Accordion } from './components/accordion/Accordion.js';
20
33
  export { default as AccordionGroup } from './components/accordion-group/AccordionGroup.js';
21
34
  export type { AccordionProps, AccordionGroupProps, } from './components/accordion/Accordion.types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC/E,YAAY,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,aAAa,GACd,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAEpF,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACvE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAEnG,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAEvF,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvE,YA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,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAC3F,YAAY,EACV,cAAc,EACd,mBAAmB,GACpB,MAAM,2CAA2C,CAAC"}
package/dist/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  import Button from "./components/button/Button.js";
2
2
  import IconButton from "./components/icon-button/IconButton.js";
3
- import Popup from "./components/popup/Popup.js";
3
+ import TextField from "./components/text-field/TextField.js";
4
+ import TextArea from "./components/text-area/TextArea.js";
5
+ import Checkbox from "./components/checkbox/Checkbox.js";
6
+ import Switch from "./components/switch/Switch.js";
7
+ import RadioGroup from "./components/radio-group/RadioGroup.js";
8
+ import SegmentedControl from "./components/segmented-control/SegmentedControl.js";
9
+ import MessageBox from "./components/message-box/MessageBox.js";
10
+ import Popup_default from "./components/popup/Popup.js";
4
11
  import PopupList from "./components/popup/PopupList.js";
5
12
  import SplitButton from "./components/split-button/SplitButton.js";
6
13
  import Card from "./components/card/Card.js";
7
14
  import Avatar from "./components/avatar/Avatar.js";
8
15
  import AvatarGroup from "./components/avatar-group/AvatarGroup.js";
9
16
  import List from "./components/list/List.js";
10
- import ListItem from "./components/list-item/ListItem.js";
11
17
  import Accordion from "./components/accordion/Accordion.js";
12
18
  import AccordionGroup from "./components/accordion-group/AccordionGroup.js";
13
- export { Accordion, AccordionGroup, Avatar, AvatarGroup, Button, Card, IconButton, List, ListItem, Popup, PopupList, SplitButton };
19
+ export { Accordion, AccordionGroup, Avatar, AvatarGroup, Button, Card, Checkbox, IconButton, List, MessageBox, Popup_default as Popup, PopupList, RadioGroup, SegmentedControl, SplitButton, Switch, TextArea, TextField };