@agility/plenum-ui 1.3.35 → 1.3.37
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/lib/components/ToggleSwitch/ToggleSwitch.d.ts +29 -0
- package/lib/components/ToggleSwitch/ToggleSwitch.stories.d.ts +9 -0
- package/lib/components/ToggleSwitch/ToggleSwitch.test.d.ts +1 -0
- package/lib/components/ToggleSwitch/index.d.ts +1 -0
- package/lib/index.d.ts +14 -14
- package/lib/index.esm.js +31 -17
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +31 -17
- package/lib/index.js.map +1 -1
- package/lib/tailwind.css +43 -2
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
export interface IToggleSwitchProps {
|
|
3
|
+
/** size state */
|
|
4
|
+
size?: "sm" | "md" | "lg";
|
|
5
|
+
/** Toggle Switch label */
|
|
6
|
+
label?: string | null;
|
|
7
|
+
/** A Classname string to be used for the label*/
|
|
8
|
+
labelStyles?: string;
|
|
9
|
+
/** A Classname string to style the Switch Group*/
|
|
10
|
+
groupStyles?: string;
|
|
11
|
+
/** Toggle Switch ID */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** Disabled state */
|
|
14
|
+
isDisabled?: boolean;
|
|
15
|
+
/** The value used when using this component inside a form, if it is checked.*/
|
|
16
|
+
value: "on" | "off";
|
|
17
|
+
/** Whether or not the switch is checked. */
|
|
18
|
+
isChecked: boolean;
|
|
19
|
+
/** If field is required */
|
|
20
|
+
isRequired?: boolean;
|
|
21
|
+
/** Error state */
|
|
22
|
+
/** Message or description */
|
|
23
|
+
/** The function to call when the switch is toggled. */
|
|
24
|
+
onChange?: (value: string) => void;
|
|
25
|
+
/** The name used when using this component inside a form.*/
|
|
26
|
+
name: string;
|
|
27
|
+
}
|
|
28
|
+
/** Comment */
|
|
29
|
+
export declare const ToggleSwitch: FC<IToggleSwitchProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta } from "@storybook/react/types-6-0";
|
|
2
|
+
import { Story } from "@storybook/react";
|
|
3
|
+
import { IToggleSwitchProps } from "./ToggleSwitch";
|
|
4
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const AllVariations: Story<IToggleSwitchProps>;
|
|
7
|
+
export declare const ToggleSwitchComponentSm: Story<IToggleSwitchProps>;
|
|
8
|
+
export declare const ToggleSwitchComponentMd: Story<IToggleSwitchProps>;
|
|
9
|
+
export declare const ToggleSwitchComponentLg: Story<IToggleSwitchProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ToggleSwitch";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
1
|
+
export * from "./components/Button";
|
|
2
|
+
export * from "./components/Combobox";
|
|
3
|
+
export * from "./components/Dropdown";
|
|
4
|
+
export * from "./components/ButtonDropdown";
|
|
5
|
+
export * from "./components/ToggleSwitch";
|
|
6
|
+
export * from "./components/TreeView";
|
|
7
|
+
export * from "./components/Avatar";
|
|
8
|
+
export * from "./components/Forms/TextInput";
|
|
9
|
+
export * from "./components/Forms/TextInputAddon";
|
|
10
|
+
export * from "./components/Forms/TextInputSelect";
|
|
11
|
+
export * from "./components/Forms/Radio";
|
|
12
|
+
export * from "./components/Forms/Textarea";
|
|
13
|
+
export * from "./components/Forms/Select";
|
|
14
|
+
export * from "./components/Forms/Checkbox";
|
package/lib/index.esm.js
CHANGED
|
@@ -7037,11 +7037,11 @@ var Button = function (_a, ref) {
|
|
|
7037
7037
|
: function () {
|
|
7038
7038
|
}, disabled: isDisabled, "aria-disabled": isDisabled },
|
|
7039
7039
|
iconObj &&
|
|
7040
|
-
(isLoading ? (React__default.createElement(Loader, { classes: "h-5 w-5 border-2" })) : (React__default.createElement(React__default.Fragment, null, iconObj))),
|
|
7040
|
+
(isLoading ? (React__default.createElement(Loader, { classes: "h-5 w-5 border-2 m-0" })) : (React__default.createElement(React__default.Fragment, null, iconObj))),
|
|
7041
7041
|
icon &&
|
|
7042
|
-
(isLoading ? (React__default.createElement(Loader, { classes: "h-5 w-5 border-2" })) : (React__default.createElement(DynamicIcons, { icon: icon, className: iconStyles, outline: false }))),
|
|
7043
|
-
!icon && !iconObj && isLoading && (React__default.createElement(Loader, { classes: "h-5 w-5 border-2" })),
|
|
7044
|
-
label && React__default.createElement("span", null, label))) : (React__default.createElement("a", { type: isSubmit ? "submit" : "button", title: asLink.title || title, href: asLink.href, className: cn("inline-flex items-center justify-center space-x-2 rounded border transition-all", { "w-full": isWidthFull === true }, { "px-4 py-2 text-sm": size === "sm" }, { "px-5 py-2 text-base": size === "base" }, { "px-5 py-2 text-lg": size === "lg" }, {
|
|
7042
|
+
(isLoading ? (React__default.createElement(Loader, { classes: "h-5 w-5 border-2 m-0" })) : (React__default.createElement(DynamicIcons, { icon: icon, className: iconStyles, outline: false }))),
|
|
7043
|
+
!icon && !iconObj && isLoading && (React__default.createElement(Loader, { classes: "h-5 w-5 border-2 m-0" })),
|
|
7044
|
+
label && React__default.createElement("span", null, label))) : (React__default.createElement("a", { type: isSubmit ? "submit" : "button", title: asLink.title || title, href: asLink.href, target: asLink.target, className: cn("inline-flex items-center justify-center space-x-2 rounded border transition-all", { "w-full": isWidthFull === true }, { "px-4 py-2 text-sm": size === "sm" }, { "px-5 py-2 text-base": size === "base" }, { "px-5 py-2 text-lg": size === "lg" }, {
|
|
7045
7045
|
"cursor-auto opacity-50": isDisabled
|
|
7046
7046
|
}, {
|
|
7047
7047
|
"active: border-purple-600 bg-purple-600 text-white hover:border-purple-700 hover:bg-purple-700 active:border-purple-800 active:bg-purple-800": type === "primary"
|
|
@@ -7311,19 +7311,33 @@ var ButtonDropDown = function (_a) {
|
|
|
7311
7311
|
};
|
|
7312
7312
|
|
|
7313
7313
|
/** Comment */
|
|
7314
|
-
var
|
|
7315
|
-
var _b = _a.
|
|
7316
|
-
var
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7314
|
+
var ToggleSwitch = function (_a) {
|
|
7315
|
+
var _b = _a.size, size = _b === void 0 ? "md" : _b, _c = _a.label, label = _c === void 0 ? "Label" : _c, labelStyles = _a.labelStyles, groupStyles = _a.groupStyles, isDisabled = _a.isDisabled, _d = _a.value, value = _d === void 0 ? "off" : _d, _e = _a.isChecked, isChecked = _e === void 0 ? false : _e, _f = _a.id, id = _f === void 0 ? "" : _f, name = _a.name, onChange = _a.onChange;
|
|
7316
|
+
var _g = useState(isChecked), t_isChecked = _g[0], T_setIsChecked = _g[1];
|
|
7317
|
+
var _h = useState(t_isChecked ? "on" : "off"), toggleValue = _h[0], setToggleValue = _h[1];
|
|
7318
|
+
var handleToggleChange = function (v) {
|
|
7319
|
+
if (v === null)
|
|
7320
|
+
return;
|
|
7321
|
+
T_setIsChecked(v);
|
|
7322
|
+
setToggleValue(!v ? "off" : "on");
|
|
7323
|
+
onChange && onChange(toggleValue);
|
|
7324
|
+
};
|
|
7325
|
+
var switchStyles = cn("relative inline-flex flex-shrink-0", "border-2 border-transparent rounded-full cursor-pointer", "transition-colors ease-in-out duration-200 focus:outline-none", "focus-visible:ring-2 focus-visible:ring-purple-500 focus-visible:ring-opacity-75", "focus-within:ring-2 focus-within:ring-purple-500 focus-within:ring-opacity-75", "focus:ring-2 focus:ring-purple-500 focus:ring-opacity-75", { "bg-purple-600": t_isChecked }, { "bg-gray-200": !t_isChecked }, { "h-[38px] w-[74px]": size === "lg" }, { "h-[28px] w-[64px]": size === "md" }, { "h-[18px] w-[34px]": size === "sm" }, isDisabled && "opacity-75 !bg-purple-300");
|
|
7321
7326
|
// the circular button inside the switch
|
|
7322
|
-
var toggleStyles = cn("pointer-events-none inline-block rounded-full bg-white", " transform ring-0 transition ease-in-out duration-200", { "translate-x-9":
|
|
7323
|
-
return (React__default.createElement(
|
|
7324
|
-
React__default.createElement(
|
|
7325
|
-
React__default.createElement(
|
|
7326
|
-
|
|
7327
|
+
var toggleStyles = cn("pointer-events-none inline-block rounded-full bg-white", " transform ring-0 transition ease-in-out duration-200", { "translate-x-9": t_isChecked }, { "translate-x-0": !t_isChecked }, { "h-[34px] w-[34px]": size === "lg" }, { "h-[24px] w-[24px]": size === "md" }, { "h-[14px] w-[14px] translate-x-4": size === "sm" && t_isChecked }, { "h-[14px] w-[14px] translate-x-0": size === "sm" && !t_isChecked });
|
|
7328
|
+
return (React__default.createElement(ue.Group, null,
|
|
7329
|
+
React__default.createElement("div", { className: cn("flex items-center justify-between text-center", groupStyles && groupStyles) },
|
|
7330
|
+
label && (React__default.createElement(ue.Label, { className: cn("mr-2", labelStyles && labelStyles
|
|
7331
|
+
// isDisabled && "opacity-50"
|
|
7332
|
+
) }, label)),
|
|
7333
|
+
React__default.createElement(ue, { checked: t_isChecked || toggleValue === "on" || value === "on", name: name, value: toggleValue, id: id, className: switchStyles, onChange: isDisabled
|
|
7334
|
+
? function () { return handleToggleChange(null); }
|
|
7335
|
+
: function () { return handleToggleChange(!t_isChecked); }, "aria-disabled": isDisabled },
|
|
7336
|
+
React__default.createElement("span", { className: "sr-only" },
|
|
7337
|
+
"Use space to toggle ",
|
|
7338
|
+
toggleValue,
|
|
7339
|
+
"."),
|
|
7340
|
+
React__default.createElement("span", { "aria-hidden": "true", className: toggleStyles })))));
|
|
7327
7341
|
};
|
|
7328
7342
|
|
|
7329
7343
|
/**
|
|
@@ -12790,5 +12804,5 @@ var Checkbox = function (_a) {
|
|
|
12790
12804
|
message && (React__default.createElement("p", { id: "".concat(id, "-description"), className: "text-gray-500" }, message)))));
|
|
12791
12805
|
};
|
|
12792
12806
|
|
|
12793
|
-
export { Avatar, _Button as Button, ButtonDropDown, Checkbox, Combobox, Dropdown, Placeholder, Radio, Select,
|
|
12807
|
+
export { Avatar, _Button as Button, ButtonDropDown, Checkbox, Combobox, Dropdown, Placeholder, Radio, Select, _TextInput as TextInput, _TextInputAddon as TextInputAddon, TextInputSelect, _Textarea as Textarea, ToggleSwitch, _TreeView as TreeView };
|
|
12794
12808
|
//# sourceMappingURL=index.esm.js.map
|