@planningcenter/tapestry 2.8.0 → 2.9.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/toggle-switch/ToggleSwitch.d.ts +33 -0
- package/dist/components/toggle-switch/ToggleSwitch.d.ts.map +1 -0
- package/dist/components/toggle-switch/ToggleSwitch.js +27 -0
- package/dist/components/toggle-switch/ToggleSwitch.js.map +1 -0
- package/dist/reactRender.css +656 -506
- package/dist/reactRender.css.map +1 -1
- package/dist/reactRenderLegacy.css +656 -506
- package/dist/reactRenderLegacy.css.map +1 -1
- package/dist/unstable.css +157 -7
- package/dist/unstable.css.map +1 -1
- package/dist/unstable.d.ts +1 -0
- package/dist/unstable.d.ts.map +1 -1
- package/dist/unstable.js +1 -0
- package/dist/unstable.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "./index.css";
|
|
2
|
+
import React, { InputHTMLAttributes } from "react";
|
|
3
|
+
export type ToggleSwitchSize = "md" | "sm";
|
|
4
|
+
interface ToggleSwitchBaseProps {
|
|
5
|
+
"aria-invalid"?: never;
|
|
6
|
+
"aria-label"?: never;
|
|
7
|
+
"aria-required"?: never;
|
|
8
|
+
description?: string;
|
|
9
|
+
required?: never;
|
|
10
|
+
size?: ToggleSwitchSize;
|
|
11
|
+
}
|
|
12
|
+
interface ToggleSwitchWithLabel extends ToggleSwitchBaseProps {
|
|
13
|
+
"aria-labelledby"?: never;
|
|
14
|
+
hideLabel?: boolean;
|
|
15
|
+
label: string;
|
|
16
|
+
}
|
|
17
|
+
interface ToggleSwitchWithAriaLabelledBy extends ToggleSwitchBaseProps {
|
|
18
|
+
"aria-labelledby": string;
|
|
19
|
+
hideLabel?: never;
|
|
20
|
+
label?: never;
|
|
21
|
+
}
|
|
22
|
+
export type ToggleSwitchProps = ToggleSwitchWithLabel | ToggleSwitchWithAriaLabelledBy;
|
|
23
|
+
export type ToggleSwitchElementProps = Omit<InputHTMLAttributes<HTMLInputElement>, keyof ToggleSwitchProps | "type" | "required" | "aria-required"> & ToggleSwitchProps;
|
|
24
|
+
/**
|
|
25
|
+
* A toggle switch component that renders as a checkbox input styled as a switch.
|
|
26
|
+
*
|
|
27
|
+
* **Required:** You must provide either:
|
|
28
|
+
* - `label` - Label text for the switch (optionally use `hideLabel` to make it invisible but still accessible)
|
|
29
|
+
* - `aria-labelledby` - ID of an external element that provides the label
|
|
30
|
+
*/
|
|
31
|
+
export declare const ToggleSwitch: React.ForwardRefExoticComponent<ToggleSwitchElementProps & React.RefAttributes<HTMLInputElement>>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=ToggleSwitch.d.ts.map
|
|
@@ -0,0 +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,qBAAsB,SAAQ,qBAAqB;IAC3D,iBAAiB,CAAC,EAAE,KAAK,CAAA;IACzB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,8BAA+B,SAAQ,qBAAqB;IACpE,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,KAAK,CAAA;IACjB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED,MAAM,MAAM,iBAAiB,GACzB,qBAAqB,GACrB,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;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,mGA0DxB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { useId } from '../../utilities/useId.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A toggle switch component that renders as a checkbox input styled as a switch.
|
|
7
|
+
*
|
|
8
|
+
* **Required:** You must provide either:
|
|
9
|
+
* - `label` - Label text for the switch (optionally use `hideLabel` to make it invisible but still accessible)
|
|
10
|
+
* - `aria-labelledby` - ID of an external element that provides the label
|
|
11
|
+
*/
|
|
12
|
+
const ToggleSwitch = forwardRef(({ "aria-describedby": ariaDescribedby, checked, className, description, hideLabel = false, id, label, size = "md", ...restProps }, ref) => {
|
|
13
|
+
const combinedClassName = classNames("tds-toggle-switch", size && size === "sm" && `tds-toggle-switch--sm`, hideLabel && `tds-toggle-switch--hide-label`, className);
|
|
14
|
+
const stableId = useId();
|
|
15
|
+
const toggleSwitchId = id || `tds-toggle-switch-${stableId}`;
|
|
16
|
+
return (React.createElement("div", { className: combinedClassName },
|
|
17
|
+
React.createElement("div", { className: "tds-toggle-switch-track", "aria-hidden": "true" }),
|
|
18
|
+
React.createElement("input", { ...restProps, id: toggleSwitchId, type: "checkbox", role: "switch", "aria-checked": checked, "aria-label": hideLabel ? label : undefined, "aria-describedby": description && !hideLabel
|
|
19
|
+
? `${toggleSwitchId}-description`
|
|
20
|
+
: ariaDescribedby, checked: checked, ref: ref }),
|
|
21
|
+
label && !hideLabel && React.createElement("label", { htmlFor: toggleSwitchId }, label),
|
|
22
|
+
description && !hideLabel && (React.createElement("p", { id: `${toggleSwitchId}-description`, className: "tds-toggle-switch-description" }, description))));
|
|
23
|
+
});
|
|
24
|
+
ToggleSwitch.displayName = "ToggleSwitch";
|
|
25
|
+
|
|
26
|
+
export { ToggleSwitch };
|
|
27
|
+
//# sourceMappingURL=ToggleSwitch.js.map
|
|
@@ -0,0 +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 ToggleSwitchWithLabel extends ToggleSwitchBaseProps {\n \"aria-labelledby\"?: never\n hideLabel?: boolean\n label: string\n}\n\ninterface ToggleSwitchWithAriaLabelledBy extends ToggleSwitchBaseProps {\n \"aria-labelledby\": string\n hideLabel?: never\n label?: never\n}\n\nexport type ToggleSwitchProps =\n | ToggleSwitchWithLabel\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 text for the switch (optionally use `hideLabel` to make it invisible but still accessible)\n * - `aria-labelledby` - ID of an external element that provides the label\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 : 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":";;;;AAwCA;;;;;;AAMG;AACI,MAAM,YAAY,GAAG,UAAU,CAIpC,CACE,EACE,kBAAkB,EAAE,eAAe,EACnC,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,GAAG,KAAK,EACjB,EAAE,EACF,KAAK,EACL,IAAI,GAAG,IAAI,EACX,GAAG,SAAS,EACa,EAC3B,GAAG,KACD;IACF,MAAM,iBAAiB,GAAG,UAAU,CAClC,mBAAmB,EACnB,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAA,qBAAA,CAAuB,EAChD,SAAS,IAAI,+BAA+B,EAC5C,SAAS,CACV;AAED,IAAA,MAAM,QAAQ,GAAG,KAAK,EAAE;AACxB,IAAA,MAAM,cAAc,GAAG,EAAE,IAAI,CAAA,kBAAA,EAAqB,QAAQ,EAAE;AAE5D,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,iBAAiB,EAAA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