@planningcenter/tapestry 2.9.1-rc.0 → 2.9.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/checkbox/Checkbox.d.ts +12 -2
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.js +5 -1
- package/dist/components/checkbox/Checkbox.js.map +1 -1
- package/dist/components/radio/Radio.d.ts +27 -4
- package/dist/components/radio/Radio.d.ts.map +1 -1
- package/dist/components/radio/Radio.js +10 -2
- package/dist/components/radio/Radio.js.map +1 -1
- package/dist/components/toggle-switch/ToggleSwitch.d.ts +21 -4
- package/dist/components/toggle-switch/ToggleSwitch.d.ts.map +1 -1
- package/dist/components/toggle-switch/ToggleSwitch.js +5 -1
- package/dist/components/toggle-switch/ToggleSwitch.js.map +1 -1
- package/dist/reactRender.css +5 -12
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +5 -12
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +5 -12
- package/dist/unstable.css.map +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,13 @@ interface CheckboxBaseProps {
|
|
|
9
9
|
}
|
|
10
10
|
interface CheckboxWithLabel extends CheckboxBaseProps {
|
|
11
11
|
"aria-labelledby"?: never;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Label content for the checkbox. When using non-string content
|
|
14
|
+
* (e.g. JSX), it must not contain interactive elements. This
|
|
15
|
+
* includes native HTML elements such as `<a>` and `<button>`, as
|
|
16
|
+
* well as Tapestry or Tapestry-React interactive components.
|
|
17
|
+
*/
|
|
18
|
+
label: React.ReactNode;
|
|
13
19
|
}
|
|
14
20
|
interface CheckboxWithAriaLabelledBy extends CheckboxBaseProps {
|
|
15
21
|
"aria-labelledby": string;
|
|
@@ -22,9 +28,13 @@ export type CheckboxElementProps = Omit<InputHTMLAttributes<HTMLInputElement>, k
|
|
|
22
28
|
* Supports various sizes, error states, and disabled states.
|
|
23
29
|
*
|
|
24
30
|
* **Required:** You must provide either:
|
|
25
|
-
* - `label` - Label
|
|
31
|
+
* - `label` - Label content for the checkbox
|
|
26
32
|
* - `aria-labelledby` - ID of an external element that provides the label
|
|
27
33
|
*
|
|
34
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
35
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
36
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
37
|
+
*
|
|
28
38
|
* @component
|
|
29
39
|
*/
|
|
30
40
|
export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAIpB,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAe,MAAM,OAAO,CAAA;AAI3E,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,UAAU,iBAAiB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,UAAU,iBAAkB,SAAQ,iBAAiB;IACnD,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAIpB,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAe,MAAM,OAAO,CAAA;AAI3E,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,UAAU,iBAAiB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,YAAY,CAAA;CACpB;AAED,UAAU,iBAAkB,SAAQ,iBAAiB;IACnD,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB;;;;;OAKG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,UAAU,0BAA2B,SAAQ,iBAAiB;IAC5D,iBAAiB,EAAE,MAAM,CAAA;IACzB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,0BAA0B,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,aAAa,GAAG,MAAM,CAC7B,GACC,aAAa,CAAA;AAEf;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,+FAqEpB,CAAA"}
|
|
@@ -8,9 +8,13 @@ import { useId } from '../../utilities/useId.js';
|
|
|
8
8
|
* Supports various sizes, error states, and disabled states.
|
|
9
9
|
*
|
|
10
10
|
* **Required:** You must provide either:
|
|
11
|
-
* - `label` - Label
|
|
11
|
+
* - `label` - Label content for the checkbox
|
|
12
12
|
* - `aria-labelledby` - ID of an external element that provides the label
|
|
13
13
|
*
|
|
14
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
15
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
16
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
17
|
+
*
|
|
14
18
|
* @component
|
|
15
19
|
*/
|
|
16
20
|
const Checkbox = forwardRef(({ className, description, id, indeterminate = false, invalid, label, size = "md", ...restProps }, ref) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes, useCallback } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type CheckboxSize = \"md\" | \"sm\"\n\ninterface CheckboxBaseProps {\n description?: string\n indeterminate?: boolean\n invalid?: boolean\n size?: CheckboxSize\n}\n\ninterface CheckboxWithLabel extends CheckboxBaseProps {\n \"aria-labelledby\"?: never\n label:
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sources":["../../../src/components/checkbox/Checkbox.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport Icon from \"@utilities/Icon\"\nimport classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes, useCallback } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type CheckboxSize = \"md\" | \"sm\"\n\ninterface CheckboxBaseProps {\n description?: string\n indeterminate?: boolean\n invalid?: boolean\n size?: CheckboxSize\n}\n\ninterface CheckboxWithLabel extends CheckboxBaseProps {\n \"aria-labelledby\"?: never\n /**\n * Label content for the checkbox. When using non-string content\n * (e.g. JSX), it must not contain interactive elements. This\n * includes native HTML elements such as `<a>` and `<button>`, as\n * well as Tapestry or Tapestry-React interactive components.\n */\n label: React.ReactNode\n}\n\ninterface CheckboxWithAriaLabelledBy extends CheckboxBaseProps {\n \"aria-labelledby\": string\n label?: never\n}\n\nexport type CheckboxProps = CheckboxWithLabel | CheckboxWithAriaLabelledBy\n\nexport type CheckboxElementProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n keyof CheckboxProps | \"type\"\n> &\n CheckboxProps\n\n/**\n * A checkbox component that renders as a checkbox input with label.\n * Supports various sizes, error states, and disabled states.\n *\n * **Required:** You must provide either:\n * - `label` - Label content for the checkbox\n * - `aria-labelledby` - ID of an external element that provides the label\n *\n * When using non-string content for `label` (e.g. JSX), it must not contain\n * interactive elements. This includes native HTML elements such as `<a>` and\n * `<button>`, as well as Tapestry or Tapestry-React interactive components.\n *\n * @component\n */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxElementProps>(\n (\n {\n className,\n description,\n id,\n indeterminate = false,\n invalid,\n label,\n size = \"md\",\n ...restProps\n }: CheckboxElementProps,\n ref\n ) => {\n const callbackRef = useCallback(\n (element: HTMLInputElement | null) => {\n if (element) {\n element.indeterminate = indeterminate\n }\n\n // Handle the forwarded ref\n if (typeof ref === \"function\") {\n ref(element)\n } else if (ref && typeof ref === \"object\") {\n ref.current = element\n }\n },\n [ref, indeterminate]\n )\n\n const combinedClassName = classNames(\n \"tds-checkbox\",\n size && size === \"sm\" && `tds-checkbox--sm`,\n invalid && \"tds-checkbox--invalid\",\n className\n )\n\n const stableId = useId()\n const checkboxId = id || `tds-checkbox-${stableId}`\n\n return (\n <div className={combinedClassName}>\n <input\n {...restProps}\n aria-describedby={\n description ? `${checkboxId}-description` : undefined\n }\n aria-invalid={invalid}\n id={checkboxId}\n ref={callbackRef}\n type=\"checkbox\"\n />\n {label && <label htmlFor={checkboxId}>{label}</label>}\n {description && (\n <p\n id={`${checkboxId}-description`}\n className=\"tds-checkbox-description\"\n >\n <Icon\n className=\"tds-checkbox-description-invalid-icon\"\n symbol=\"general#exclamation-triangle\"\n aria-hidden\n />\n {description}\n </p>\n )}\n </div>\n )\n }\n)\n\nCheckbox.displayName = \"Checkbox\"\n"],"names":[],"mappings":";;;;;AAyCA;;;;;;;;;;;;;AAaG;AACI,MAAM,QAAQ,GAAG,UAAU,CAChC,CACE,EACE,SAAS,EACT,WAAW,EACX,EAAE,EACF,aAAa,GAAG,KAAK,EACrB,OAAO,EACP,KAAK,EACL,IAAI,GAAG,IAAI,EACX,GAAG,SAAS,EACS,EACvB,GAAG,KACD;AACF,IAAA,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,OAAgC,KAAI;QACnC,IAAI,OAAO,EAAE;AACX,YAAA,OAAO,CAAC,aAAa,GAAG,aAAa;QACvC;;AAGA,QAAA,IAAI,OAAO,GAAG,KAAK,UAAU,E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Q,CAAC,WAAW,GAAG,UAAU;;;;"}
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import React, { InputHTMLAttributes } from "react";
|
|
2
2
|
export type RadioSize = "md" | "sm";
|
|
3
|
-
|
|
3
|
+
interface RadioBaseProps {
|
|
4
4
|
description?: string;
|
|
5
|
-
label: string;
|
|
6
5
|
name: string;
|
|
7
6
|
size?: RadioSize;
|
|
8
7
|
}
|
|
8
|
+
interface RadioWithLabel extends RadioBaseProps {
|
|
9
|
+
"aria-labelledby"?: never;
|
|
10
|
+
/**
|
|
11
|
+
* Label content for the radio. When using non-string content
|
|
12
|
+
* (e.g. JSX), it must not contain interactive elements. This
|
|
13
|
+
* includes native HTML elements such as `<a>` and `<button>`, as
|
|
14
|
+
* well as Tapestry or Tapestry-React interactive components.
|
|
15
|
+
*/
|
|
16
|
+
label: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface RadioWithAriaLabelledBy extends RadioBaseProps {
|
|
19
|
+
"aria-labelledby": string;
|
|
20
|
+
label?: never;
|
|
21
|
+
}
|
|
22
|
+
export type RadioProps = RadioWithLabel | RadioWithAriaLabelledBy;
|
|
9
23
|
export type RadioElementProps = Omit<InputHTMLAttributes<HTMLInputElement>, keyof RadioProps | "type"> & RadioProps;
|
|
10
24
|
/**
|
|
11
25
|
* A radio component that renders as a radio input with label.
|
|
12
26
|
* Supports various sizes.
|
|
13
|
-
*
|
|
27
|
+
* Must have a name attribute.
|
|
28
|
+
*
|
|
29
|
+
* **Required:** You must provide either:
|
|
30
|
+
* - `label` - Label content for the radio
|
|
31
|
+
* - `aria-labelledby` - ID of an external element that provides the label
|
|
32
|
+
*
|
|
33
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
34
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
35
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
14
36
|
*
|
|
15
37
|
* @component
|
|
16
38
|
*/
|
|
17
|
-
export declare const Radio: React.ForwardRefExoticComponent<
|
|
39
|
+
export declare const Radio: React.ForwardRefExoticComponent<RadioElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
40
|
+
export {};
|
|
18
41
|
//# sourceMappingURL=Radio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/radio/Radio.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAI9D,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAA;AAEnC,
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../src/components/radio/Radio.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAI9D,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAA;AAEnC,UAAU,cAAc;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED,UAAU,cAAe,SAAQ,cAAc;IAC7C,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB;;;;;OAKG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,UAAU,uBAAwB,SAAQ,cAAc;IACtD,iBAAiB,EAAE,MAAM,CAAA;IACzB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,uBAAuB,CAAA;AAEjE,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,UAAU,GAAG,MAAM,CAC1B,GACC,UAAU,CAAA;AAEZ;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,4FAuCjB,CAAA"}
|
|
@@ -5,7 +5,15 @@ import { useId } from '../../utilities/useId.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* A radio component that renders as a radio input with label.
|
|
7
7
|
* Supports various sizes.
|
|
8
|
-
*
|
|
8
|
+
* Must have a name attribute.
|
|
9
|
+
*
|
|
10
|
+
* **Required:** You must provide either:
|
|
11
|
+
* - `label` - Label content for the radio
|
|
12
|
+
* - `aria-labelledby` - ID of an external element that provides the label
|
|
13
|
+
*
|
|
14
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
15
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
16
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
9
17
|
*
|
|
10
18
|
* @component
|
|
11
19
|
*/
|
|
@@ -15,7 +23,7 @@ const Radio = forwardRef(({ className, description, id, label, size = "md", ...r
|
|
|
15
23
|
const radioId = id || `tds-radio-${stableId}`;
|
|
16
24
|
return (React.createElement("div", { className: combinedClassName },
|
|
17
25
|
React.createElement("input", { ...restProps, "aria-describedby": description ? `${radioId}-description` : undefined, id: radioId, ref: ref, type: "radio" }),
|
|
18
|
-
React.createElement("label", { htmlFor: radioId }, label),
|
|
26
|
+
label && React.createElement("label", { htmlFor: radioId }, label),
|
|
19
27
|
description && (React.createElement("p", { id: `${radioId}-description`, className: "tds-radio-description" }, description))));
|
|
20
28
|
});
|
|
21
29
|
Radio.displayName = "Radio";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../src/components/radio/Radio.tsx"],"sourcesContent":["import classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type RadioSize = \"md\" | \"sm\"\n\
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../src/components/radio/Radio.tsx"],"sourcesContent":["import classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type RadioSize = \"md\" | \"sm\"\n\ninterface RadioBaseProps {\n description?: string\n name: string\n size?: RadioSize\n}\n\ninterface RadioWithLabel extends RadioBaseProps {\n \"aria-labelledby\"?: never\n /**\n * Label content for the radio. When using non-string content\n * (e.g. JSX), it must not contain interactive elements. This\n * includes native HTML elements such as `<a>` and `<button>`, as\n * well as Tapestry or Tapestry-React interactive components.\n */\n label: React.ReactNode\n}\n\ninterface RadioWithAriaLabelledBy extends RadioBaseProps {\n \"aria-labelledby\": string\n label?: never\n}\n\nexport type RadioProps = RadioWithLabel | RadioWithAriaLabelledBy\n\nexport type RadioElementProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n keyof RadioProps | \"type\"\n> &\n RadioProps\n\n/**\n * A radio component that renders as a radio input with label.\n * Supports various sizes.\n * Must have a name attribute.\n *\n * **Required:** You must provide either:\n * - `label` - Label content for the radio\n * - `aria-labelledby` - ID of an external element that provides the label\n *\n * When using non-string content for `label` (e.g. JSX), it must not contain\n * interactive elements. This includes native HTML elements such as `<a>` and\n * `<button>`, as well as Tapestry or Tapestry-React interactive components.\n *\n * @component\n */\nexport const Radio = forwardRef<HTMLInputElement, RadioElementProps>(\n (\n {\n className,\n description,\n id,\n label,\n size = \"md\",\n ...restProps\n }: RadioElementProps,\n ref\n ) => {\n const combinedClassName = classNames(\n \"tds-radio\",\n size && size === \"sm\" && `tds-radio--sm`,\n className\n )\n\n const stableId = useId()\n const radioId = id || `tds-radio-${stableId}`\n\n return (\n <div className={combinedClassName}>\n <input\n {...restProps}\n aria-describedby={description ? `${radioId}-description` : undefined}\n id={radioId}\n ref={ref}\n type=\"radio\"\n />\n {label && <label htmlFor={radioId}>{label}</label>}\n {description && (\n <p id={`${radioId}-description`} className=\"tds-radio-description\">\n {description}\n </p>\n )}\n </div>\n )\n }\n)\n\nRadio.displayName = \"Radio\"\n"],"names":[],"mappings":";;;;AAqCA;;;;;;;;;;;;;;AAcG;AACI,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EACE,SAAS,EACT,WAAW,EACX,EAAE,EACF,KAAK,EACL,IAAI,GAAG,IAAI,EACX,GAAG,SAAS,EACM,EACpB,GAAG,KACD;AACF,IAAA,MAAM,iBAAiB,GAAG,UAAU,CAClC,WAAW,EACX,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAA,aAAA,CAAe,EACxC,SAAS,CACV;AAED,IAAA,MAAM,QAAQ,GAAG,KAAK,EAAE;AACxB,IAAA,MAAM,OAAO,GAAG,EAAE,IAAI,CAAA,UAAA,EAAa,QAAQ,EAAE;AAE7C,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,iBAAiB,EAAA;QAC/B,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAA,GACM,SAAS,EAAA,kBAAA,EACK,WAAW,GAAG,CAAA,EAAG,OAAO,CAAA,YAAA,CAAc,GAAG,SAAS,EACpE,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,OAAO,EAAA,CACZ;AACD,QAAA,KAAK,IAAI,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,OAAO,EAAE,OAAO,EAAA,EAAG,KAAK,CAAS;AACjD,QAAA,WAAW,KACV,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAG,EAAE,EAAE,CAAA,EAAG,OAAO,CAAA,YAAA,CAAc,EAAE,SAAS,EAAC,uBAAuB,EAAA,EAC/D,WAAW,CACV,CACL,CACG;AAEV,CAAC;AAGH,KAAK,CAAC,WAAW,GAAG,OAAO;;;;"}
|
|
@@ -9,24 +9,41 @@ interface ToggleSwitchBaseProps {
|
|
|
9
9
|
required?: never;
|
|
10
10
|
size?: ToggleSwitchSize;
|
|
11
11
|
}
|
|
12
|
-
interface
|
|
12
|
+
interface ToggleSwitchWithVisibleLabel extends ToggleSwitchBaseProps {
|
|
13
13
|
"aria-labelledby"?: never;
|
|
14
|
-
hideLabel?:
|
|
14
|
+
hideLabel?: false;
|
|
15
|
+
/**
|
|
16
|
+
* Label content for the toggle switch. When using non-string content
|
|
17
|
+
* (e.g. JSX), it must not contain interactive elements. This
|
|
18
|
+
* includes native HTML elements such as `<a>` and `<button>`, as
|
|
19
|
+
* well as Tapestry or Tapestry-React interactive components.
|
|
20
|
+
*/
|
|
21
|
+
label: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
interface ToggleSwitchWithHiddenLabel extends ToggleSwitchBaseProps {
|
|
24
|
+
"aria-labelledby"?: never;
|
|
25
|
+
hideLabel: true;
|
|
26
|
+
/** Label text for the toggle switch, used as an accessible `aria-label`. */
|
|
15
27
|
label: string;
|
|
16
28
|
}
|
|
17
29
|
interface ToggleSwitchWithAriaLabelledBy extends ToggleSwitchBaseProps {
|
|
18
30
|
"aria-labelledby": string;
|
|
19
31
|
hideLabel?: never;
|
|
32
|
+
/** Not available when `aria-labelledby` is provided. */
|
|
20
33
|
label?: never;
|
|
21
34
|
}
|
|
22
|
-
export type ToggleSwitchProps =
|
|
35
|
+
export type ToggleSwitchProps = ToggleSwitchWithVisibleLabel | ToggleSwitchWithHiddenLabel | ToggleSwitchWithAriaLabelledBy;
|
|
23
36
|
export type ToggleSwitchElementProps = Omit<InputHTMLAttributes<HTMLInputElement>, keyof ToggleSwitchProps | "type" | "required" | "aria-required"> & ToggleSwitchProps;
|
|
24
37
|
/**
|
|
25
38
|
* A toggle switch component that renders as a checkbox input styled as a switch.
|
|
26
39
|
*
|
|
27
40
|
* **Required:** You must provide either:
|
|
28
|
-
* - `label` - Label
|
|
41
|
+
* - `label` - Label content for the switch (must be a string when `hideLabel` is true)
|
|
29
42
|
* - `aria-labelledby` - ID of an external element that provides the label
|
|
43
|
+
*
|
|
44
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
45
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
46
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
30
47
|
*/
|
|
31
48
|
export declare const ToggleSwitch: React.ForwardRefExoticComponent<ToggleSwitchElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
32
49
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleSwitch.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-switch/ToggleSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAI9D,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAA;AAE1C,UAAU,qBAAqB;IAC7B,cAAc,CAAC,EAAE,KAAK,CAAA;IACtB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,eAAe,CAAC,EAAE,KAAK,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,CAAC,EAAE,gBAAgB,CAAA;CACxB;AAED,UAAU,
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-switch/ToggleSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,EAAc,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAI9D,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAAA;AAE1C,UAAU,qBAAqB;IAC7B,cAAc,CAAC,EAAE,KAAK,CAAA;IACtB,YAAY,CAAC,EAAE,KAAK,CAAA;IACpB,eAAe,CAAC,EAAE,KAAK,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,CAAC,EAAE,gBAAgB,CAAA;CACxB;AAED,UAAU,4BAA6B,SAAQ,qBAAqB;IAClE,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB;;;;;OAKG;IACH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,UAAU,2BAA4B,SAAQ,qBAAqB;IACjE,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB,SAAS,EAAE,IAAI,CAAA;IACf,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,8BAA+B,SAAQ,qBAAqB;IACpE,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,wDAAwD;IACxD,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,MAAM,iBAAiB,GACzB,4BAA4B,GAC5B,2BAA2B,GAC3B,8BAA8B,CAAA;AAElC,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,eAAe,CAChE,GACC,iBAAiB,CAAA;AAEnB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,mGA0DxB,CAAA"}
|
|
@@ -6,8 +6,12 @@ import { useId } from '../../utilities/useId.js';
|
|
|
6
6
|
* A toggle switch component that renders as a checkbox input styled as a switch.
|
|
7
7
|
*
|
|
8
8
|
* **Required:** You must provide either:
|
|
9
|
-
* - `label` - Label
|
|
9
|
+
* - `label` - Label content for the switch (must be a string when `hideLabel` is true)
|
|
10
10
|
* - `aria-labelledby` - ID of an external element that provides the label
|
|
11
|
+
*
|
|
12
|
+
* When using non-string content for `label` (e.g. JSX), it must not contain
|
|
13
|
+
* interactive elements. This includes native HTML elements such as `<a>` and
|
|
14
|
+
* `<button>`, as well as Tapestry or Tapestry-React interactive components.
|
|
11
15
|
*/
|
|
12
16
|
const ToggleSwitch = forwardRef(({ "aria-describedby": ariaDescribedby, checked, className, description, hideLabel = false, id, label, size = "md", ...restProps }, ref) => {
|
|
13
17
|
const combinedClassName = classNames("tds-toggle-switch", size && size === "sm" && `tds-toggle-switch--sm`, hideLabel && `tds-toggle-switch--hide-label`, className);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleSwitch.js","sources":["../../../src/components/toggle-switch/ToggleSwitch.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type ToggleSwitchSize = \"md\" | \"sm\"\n\ninterface ToggleSwitchBaseProps {\n \"aria-invalid\"?: never\n \"aria-label\"?: never\n \"aria-required\"?: never\n description?: string\n required?: never\n size?: ToggleSwitchSize\n}\n\ninterface
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.js","sources":["../../../src/components/toggle-switch/ToggleSwitch.tsx"],"sourcesContent":["import \"./index.css\"\n\nimport classNames from \"classnames\"\nimport React, { forwardRef, InputHTMLAttributes } from \"react\"\n\nimport { useId } from \"../../utilities/useId\"\n\nexport type ToggleSwitchSize = \"md\" | \"sm\"\n\ninterface ToggleSwitchBaseProps {\n \"aria-invalid\"?: never\n \"aria-label\"?: never\n \"aria-required\"?: never\n description?: string\n required?: never\n size?: ToggleSwitchSize\n}\n\ninterface ToggleSwitchWithVisibleLabel extends ToggleSwitchBaseProps {\n \"aria-labelledby\"?: never\n hideLabel?: false\n /**\n * Label content for the toggle switch. When using non-string content\n * (e.g. JSX), it must not contain interactive elements. This\n * includes native HTML elements such as `<a>` and `<button>`, as\n * well as Tapestry or Tapestry-React interactive components.\n */\n label: React.ReactNode\n}\n\ninterface ToggleSwitchWithHiddenLabel extends ToggleSwitchBaseProps {\n \"aria-labelledby\"?: never\n hideLabel: true\n /** Label text for the toggle switch, used as an accessible `aria-label`. */\n label: string\n}\n\ninterface ToggleSwitchWithAriaLabelledBy extends ToggleSwitchBaseProps {\n \"aria-labelledby\": string\n hideLabel?: never\n /** Not available when `aria-labelledby` is provided. */\n label?: never\n}\n\nexport type ToggleSwitchProps =\n | ToggleSwitchWithVisibleLabel\n | ToggleSwitchWithHiddenLabel\n | ToggleSwitchWithAriaLabelledBy\n\nexport type ToggleSwitchElementProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n keyof ToggleSwitchProps | \"type\" | \"required\" | \"aria-required\"\n> &\n ToggleSwitchProps\n\n/**\n * A toggle switch component that renders as a checkbox input styled as a switch.\n *\n * **Required:** You must provide either:\n * - `label` - Label content for the switch (must be a string when `hideLabel` is true)\n * - `aria-labelledby` - ID of an external element that provides the label\n *\n * When using non-string content for `label` (e.g. JSX), it must not contain\n * interactive elements. This includes native HTML elements such as `<a>` and\n * `<button>`, as well as Tapestry or Tapestry-React interactive components.\n */\nexport const ToggleSwitch = forwardRef<\n HTMLInputElement,\n ToggleSwitchElementProps\n>(\n (\n {\n \"aria-describedby\": ariaDescribedby,\n checked,\n className,\n description,\n hideLabel = false,\n id,\n label,\n size = \"md\",\n ...restProps\n }: ToggleSwitchElementProps,\n ref\n ) => {\n const combinedClassName = classNames(\n \"tds-toggle-switch\",\n size && size === \"sm\" && `tds-toggle-switch--sm`,\n hideLabel && `tds-toggle-switch--hide-label`,\n className\n )\n\n const stableId = useId()\n const toggleSwitchId = id || `tds-toggle-switch-${stableId}`\n\n return (\n <div className={combinedClassName}>\n <div className=\"tds-toggle-switch-track\" aria-hidden=\"true\"></div>\n <input\n {...restProps}\n id={toggleSwitchId}\n type=\"checkbox\"\n role=\"switch\"\n aria-checked={checked}\n aria-label={hideLabel ? (label as string) : undefined}\n aria-describedby={\n description && !hideLabel\n ? `${toggleSwitchId}-description`\n : ariaDescribedby\n }\n checked={checked}\n ref={ref}\n />\n {label && !hideLabel && <label htmlFor={toggleSwitchId}>{label}</label>}\n {description && !hideLabel && (\n <p\n id={`${toggleSwitchId}-description`}\n className=\"tds-toggle-switch-description\"\n >\n {description}\n </p>\n )}\n </div>\n )\n }\n)\n\nToggleSwitch.displayName = \"ToggleSwitch\"\n"],"names":[],"mappings":";;;;AAuDA;;;;;;;;;;AAUG;AACI,MAAM,YAAY,GAAG,UAAU,CAIpC,C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,SAAS,EAAC,+BAA+B,EAAA,EAExC,WAAW,CACV,CACL,CACG;AAEV,CAAC;AAGH,YAAY,CAAC,WAAW,GAAG,cAAc;;;;"}
|
package/dist/reactRender.css
CHANGED
|
@@ -2286,10 +2286,9 @@ a[class="tds-btn"]{
|
|
|
2286
2286
|
--tds-toggle-switch-description-color:var(--t-text-color-secondary);
|
|
2287
2287
|
|
|
2288
2288
|
display:var(--tds-toggle-switch-display);
|
|
2289
|
-
grid-template-
|
|
2290
|
-
grid-
|
|
2291
|
-
|
|
2292
|
-
column-gap:var(--tds-toggle-switch-column-gap);
|
|
2289
|
+
grid-template-columns:auto;
|
|
2290
|
+
grid-auto-columns:1fr;
|
|
2291
|
+
gap:var(--t-spacing-fourth) var(--tds-toggle-switch-column-gap);
|
|
2293
2292
|
-webkit-user-select:none;
|
|
2294
2293
|
-moz-user-select:none;
|
|
2295
2294
|
user-select:none;
|
|
@@ -2297,7 +2296,6 @@ a[class="tds-btn"]{
|
|
|
2297
2296
|
|
|
2298
2297
|
.tds-toggle-switch input[type="checkbox"]{
|
|
2299
2298
|
position:absolute;
|
|
2300
|
-
grid-area:input;
|
|
2301
2299
|
width:var(--tds-toggle-switch-track-width);
|
|
2302
2300
|
height:var(--tds-toggle-switch-track-height);
|
|
2303
2301
|
margin:0;
|
|
@@ -2312,7 +2310,7 @@ a[class="tds-btn"]{
|
|
|
2312
2310
|
|
|
2313
2311
|
.tds-toggle-switch label{
|
|
2314
2312
|
display:inline-flex;
|
|
2315
|
-
grid-area:
|
|
2313
|
+
grid-area:1 / 2;
|
|
2316
2314
|
-moz-column-gap:var(--tds-toggle-switch-column-gap);
|
|
2317
2315
|
column-gap:var(--tds-toggle-switch-column-gap);
|
|
2318
2316
|
margin-top:-.09375em;
|
|
@@ -2323,10 +2321,6 @@ a[class="tds-btn"]{
|
|
|
2323
2321
|
cursor:var(--tds-toggle-switch-cursor);
|
|
2324
2322
|
}
|
|
2325
2323
|
|
|
2326
|
-
.tds-toggle-switch:has(.tds-toggle-switch-description){
|
|
2327
|
-
row-gap:var(--t-spacing-fourth);
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
2324
|
.tds-toggle-switch:not(:has(input:disabled)):has(input:hover){
|
|
2331
2325
|
--tds-toggle-switch-track-background-color:var(--t-fill-color-neutral-025);
|
|
2332
2326
|
}
|
|
@@ -2354,7 +2348,6 @@ a[class="tds-btn"]{
|
|
|
2354
2348
|
.tds-toggle-switch-track{
|
|
2355
2349
|
position:relative;
|
|
2356
2350
|
flex-shrink:0;
|
|
2357
|
-
grid-area:input;
|
|
2358
2351
|
width:var(--tds-toggle-switch-track-width);
|
|
2359
2352
|
height:var(--tds-toggle-switch-track-height);
|
|
2360
2353
|
outline:var(--tds-toggle-switch-track-outline);
|
|
@@ -2387,7 +2380,7 @@ a[class="tds-btn"]{
|
|
|
2387
2380
|
|
|
2388
2381
|
.tds-toggle-switch-description{
|
|
2389
2382
|
display:flex;
|
|
2390
|
-
grid-area:
|
|
2383
|
+
grid-area:2 / 2;
|
|
2391
2384
|
align-items:flex-start;
|
|
2392
2385
|
margin:0;
|
|
2393
2386
|
font-size:var(--tds-toggle-switch-description-font-size);
|