@agility/plenum-ui 1.3.36 → 1.3.38
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/Button/Button.d.ts +1 -1
- 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 +35 -23
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +35 -23
- package/lib/index.js.map +1 -1
- package/lib/tailwind.css +39 -2
- package/lib/util/Loader.d.ts +2 -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
|
@@ -7009,10 +7009,8 @@ var DynamicIcons = function (_a) {
|
|
|
7009
7009
|
};
|
|
7010
7010
|
|
|
7011
7011
|
function Loader(_a) {
|
|
7012
|
-
var
|
|
7013
|
-
var outerLoaderStyles = cn(
|
|
7014
|
-
'w-16 h-16 border-8': !classes
|
|
7015
|
-
});
|
|
7012
|
+
var className = _a.className;
|
|
7013
|
+
var outerLoaderStyles = cn("rounded-full border-purple-700 inline-block border-r-gray-200 animate-spin", className ? className : "w-16 h-16 border-8 m-auto");
|
|
7016
7014
|
return React__default.createElement("div", { className: outerLoaderStyles, role: "status" });
|
|
7017
7015
|
}
|
|
7018
7016
|
|
|
@@ -7037,10 +7035,10 @@ var Button = function (_a, ref) {
|
|
|
7037
7035
|
: function () {
|
|
7038
7036
|
}, disabled: isDisabled, "aria-disabled": isDisabled },
|
|
7039
7037
|
iconObj &&
|
|
7040
|
-
(isLoading ? (React__default.createElement(Loader, {
|
|
7038
|
+
(isLoading ? (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })) : (React__default.createElement(React__default.Fragment, null, iconObj))),
|
|
7041
7039
|
icon &&
|
|
7042
|
-
(isLoading ? (React__default.createElement(Loader, {
|
|
7043
|
-
!icon && !iconObj && isLoading && (React__default.createElement(Loader, {
|
|
7040
|
+
(isLoading ? (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })) : (React__default.createElement(DynamicIcons, { icon: icon, className: iconStyles, outline: false }))),
|
|
7041
|
+
!icon && !iconObj && isLoading && (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })),
|
|
7044
7042
|
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
7043
|
"cursor-auto opacity-50": isDisabled
|
|
7046
7044
|
}, {
|
|
@@ -7053,10 +7051,10 @@ var Button = function (_a, ref) {
|
|
|
7053
7051
|
"border-red-300 bg-red-600 text-white hover:bg-red-700 hover:text-white": type === "danger"
|
|
7054
7052
|
}, className), "aria-disabled": isDisabled },
|
|
7055
7053
|
iconObj &&
|
|
7056
|
-
(isLoading ? (React__default.createElement(Loader, {
|
|
7054
|
+
(isLoading ? (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })) : (React__default.createElement(React__default.Fragment, null, iconObj))),
|
|
7057
7055
|
icon &&
|
|
7058
|
-
(isLoading ? (React__default.createElement(Loader, {
|
|
7059
|
-
!icon && !iconObj && isLoading && (React__default.createElement(Loader, {
|
|
7056
|
+
(isLoading ? (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })) : (React__default.createElement(DynamicIcons, { icon: icon, className: iconStyles, outline: false }))),
|
|
7057
|
+
!icon && !iconObj && isLoading && (React__default.createElement(Loader, { className: "h-5 w-5 border-2" })),
|
|
7060
7058
|
label && React__default.createElement("span", null, label)));
|
|
7061
7059
|
};
|
|
7062
7060
|
var _Button = forwardRef(Button);
|
|
@@ -7311,19 +7309,33 @@ var ButtonDropDown = function (_a) {
|
|
|
7311
7309
|
};
|
|
7312
7310
|
|
|
7313
7311
|
/** Comment */
|
|
7314
|
-
var
|
|
7315
|
-
var _b = _a.
|
|
7316
|
-
var
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7312
|
+
var ToggleSwitch = function (_a) {
|
|
7313
|
+
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;
|
|
7314
|
+
var _g = useState(isChecked), t_isChecked = _g[0], T_setIsChecked = _g[1];
|
|
7315
|
+
var _h = useState(t_isChecked ? "on" : "off"), toggleValue = _h[0], setToggleValue = _h[1];
|
|
7316
|
+
var handleToggleChange = function (v) {
|
|
7317
|
+
if (v === null)
|
|
7318
|
+
return;
|
|
7319
|
+
T_setIsChecked(v);
|
|
7320
|
+
setToggleValue(!v ? "off" : "on");
|
|
7321
|
+
onChange && onChange(toggleValue);
|
|
7322
|
+
};
|
|
7323
|
+
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
7324
|
// 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
|
-
|
|
7325
|
+
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 });
|
|
7326
|
+
return (React__default.createElement(ue.Group, null,
|
|
7327
|
+
React__default.createElement("div", { className: cn("flex items-center justify-between text-center", groupStyles && groupStyles) },
|
|
7328
|
+
label && (React__default.createElement(ue.Label, { className: cn("mr-2", labelStyles && labelStyles
|
|
7329
|
+
// isDisabled && "opacity-50"
|
|
7330
|
+
) }, label)),
|
|
7331
|
+
React__default.createElement(ue, { checked: t_isChecked || toggleValue === "on" || value === "on", name: name, value: toggleValue, id: id, className: switchStyles, onChange: isDisabled
|
|
7332
|
+
? function () { return handleToggleChange(null); }
|
|
7333
|
+
: function () { return handleToggleChange(!t_isChecked); }, "aria-disabled": isDisabled },
|
|
7334
|
+
React__default.createElement("span", { className: "sr-only" },
|
|
7335
|
+
"Use space to toggle ",
|
|
7336
|
+
toggleValue,
|
|
7337
|
+
"."),
|
|
7338
|
+
React__default.createElement("span", { "aria-hidden": "true", className: toggleStyles })))));
|
|
7327
7339
|
};
|
|
7328
7340
|
|
|
7329
7341
|
/**
|
|
@@ -12790,5 +12802,5 @@ var Checkbox = function (_a) {
|
|
|
12790
12802
|
message && (React__default.createElement("p", { id: "".concat(id, "-description"), className: "text-gray-500" }, message)))));
|
|
12791
12803
|
};
|
|
12792
12804
|
|
|
12793
|
-
export { Avatar, _Button as Button, ButtonDropDown, Checkbox, Combobox, Dropdown, Placeholder, Radio, Select,
|
|
12805
|
+
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
12806
|
//# sourceMappingURL=index.esm.js.map
|