@veracity/vui 0.2.0 → 0.2.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.
- package/avatar/avatar.js +5 -5
- package/box/box.js +6 -6
- package/button/button.js +19 -23
- package/button/button.types.d.ts +33 -3
- package/button/buttonIcon.js +3 -3
- package/button/buttonText.js +3 -3
- package/button/buttons.js +8 -8
- package/button/context.js +1 -1
- package/button/theme.js +0 -6
- package/buttonGroup/buttonGroup.js +5 -10
- package/buttonGroup/context.js +1 -1
- package/card/card.js +4 -4
- package/checkbox/checkbox.js +12 -12
- package/checkbox/checkboxGroup.js +7 -7
- package/checkbox/checkboxGroup.types.d.ts +1 -1
- package/checkbox/context.js +1 -1
- package/checkbox/theme.js +5 -2
- package/core/globalStyle.js +2 -3
- package/core/resetCSS.js +1 -1
- package/core/styled.js +11 -7
- package/core/utils.js +9 -9
- package/core/v.js +1 -1
- package/divider/divider.js +6 -6
- package/heading/heading.js +6 -6
- package/heading/headings.js +6 -6
- package/icon/icon.js +6 -6
- package/icons/library.js +9 -5
- package/image/image.js +4 -4
- package/input/context.js +1 -1
- package/input/input.js +11 -16
- package/input/inputIcon.js +3 -3
- package/input/inputInput.js +4 -4
- package/link/link.js +6 -6
- package/list/context.js +1 -1
- package/list/list.js +6 -11
- package/list/listHeading.js +3 -3
- package/list/listIcon.js +3 -3
- package/list/listItem.js +8 -8
- package/list/listText.js +3 -3
- package/notification/context.js +1 -1
- package/notification/notification.js +6 -11
- package/notification/notificationButton.js +3 -3
- package/notification/notificationIcon.js +3 -3
- package/notification/notificationText.js +3 -3
- package/notification/notificationTitle.js +3 -3
- package/p/p.js +6 -6
- package/package.json +1 -1
- package/panel/panel.js +4 -4
- package/radio/context.js +1 -1
- package/radio/radio.js +58 -13
- package/radio/radioGroup.js +25 -17
- package/radio/radioGroup.types.d.ts +1 -1
- package/radio/theme.js +5 -2
- package/skeleton/skeleton.js +6 -6
- package/spinner/spinner.js +5 -5
- package/svg/svg.js +12 -12
- package/switch/context.js +1 -1
- package/switch/switch.js +12 -50
- package/switch/switch.types.d.ts +2 -2
- package/switch/switchButton.js +19 -21
- package/switch/switchLabel.js +3 -3
- package/system/custom.d.ts +11 -7
- package/system/custom.js +24 -13
- package/system/system.d.ts +4 -3
- package/system/system.js +2 -2
- package/system/tables.d.ts +14 -0
- package/system/tables.js +2 -0
- package/t/t.js +6 -6
- package/tag/context.js +1 -1
- package/tag/index.d.ts +1 -0
- package/tag/index.js +1 -0
- package/tag/tag.d.ts +2 -0
- package/tag/tag.js +14 -12
- package/tag/tag.types.d.ts +1 -0
- package/tag/tagButton.d.ts +3 -0
- package/tag/tagButton.js +30 -0
- package/tag/tagIcon.js +3 -3
- package/tag/tagText.js +3 -3
- package/tag/theme.d.ts +26 -0
- package/tag/theme.js +32 -3
- package/textarea/textarea.js +9 -9
- package/theme/components.d.ts +26 -0
- package/theme/defaultTheme.d.ts +26 -0
- package/theme/foundations/shadows.js +2 -2
- package/theme/index.d.ts +16 -0
- package/theme/index.js +33 -1
- package/utils/assertion.js +1 -2
- package/utils/function.js +9 -5
- package/utils/object.js +3 -3
package/p/p.js
CHANGED
|
@@ -35,17 +35,17 @@ var styled_components_1 = __importDefault(require("styled-components"));
|
|
|
35
35
|
var core_1 = require("../core");
|
|
36
36
|
var system_1 = require("../system");
|
|
37
37
|
var utils_1 = require("../utils");
|
|
38
|
-
exports.PBase = styled_components_1.default.p.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t", "\n"], ["\n\t", "\n"])), system_1.system);
|
|
39
|
-
exports.P = core_1.vui(function (props, ref) {
|
|
40
|
-
var _a = core_1.omitThemingProps(props), align = _a.align, casing = _a.casing, children = _a.children, className = _a.className, decoration = _a.decoration, text = _a.text, weight = _a.weight, rest = __rest(_a, ["align", "casing", "children", "className", "decoration", "text", "weight"]);
|
|
41
|
-
var styles = core_1.useStyleConfig('P', props);
|
|
42
|
-
var aliasedProps = utils_1.filterUndefined({
|
|
38
|
+
exports.PBase = styled_components_1.default.p.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t", "\n"], ["\n\t", "\n"])), system_1.system);
|
|
39
|
+
exports.P = (0, core_1.vui)(function (props, ref) {
|
|
40
|
+
var _a = (0, core_1.omitThemingProps)(props), align = _a.align, casing = _a.casing, children = _a.children, className = _a.className, decoration = _a.decoration, text = _a.text, weight = _a.weight, rest = __rest(_a, ["align", "casing", "children", "className", "decoration", "text", "weight"]);
|
|
41
|
+
var styles = (0, core_1.useStyleConfig)('P', props);
|
|
42
|
+
var aliasedProps = (0, utils_1.filterUndefined)({
|
|
43
43
|
fontWeight: weight,
|
|
44
44
|
textAlign: align,
|
|
45
45
|
textDecoration: decoration,
|
|
46
46
|
textTransform: casing
|
|
47
47
|
});
|
|
48
|
-
return (react_1.default.createElement(exports.PBase, __assign({ className: utils_1.cs('vui-p', className), ref: ref, transitionDuration: "fast" }, styles, aliasedProps, rest), children !== null && children !== void 0 ? children : text));
|
|
48
|
+
return (react_1.default.createElement(exports.PBase, __assign({ className: (0, utils_1.cs)('vui-p', className), ref: ref, transitionDuration: "fast" }, styles, aliasedProps, rest), children !== null && children !== void 0 ? children : text));
|
|
49
49
|
});
|
|
50
50
|
exports.P.displayName = 'P';
|
|
51
51
|
exports.default = exports.P;
|
package/package.json
CHANGED
package/panel/panel.js
CHANGED
|
@@ -30,10 +30,10 @@ var react_1 = __importDefault(require("react"));
|
|
|
30
30
|
var box_1 = __importDefault(require("../box"));
|
|
31
31
|
var core_1 = require("../core");
|
|
32
32
|
var utils_1 = require("../utils");
|
|
33
|
-
exports.Panel = core_1.vui(function (props, ref) {
|
|
34
|
-
var _a = core_1.omitThemingProps(props), className = _a.className, rest = __rest(_a, ["className"]);
|
|
35
|
-
var styles = core_1.useStyleConfig('Panel', props);
|
|
36
|
-
return (react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", className: utils_1.cs('vui-panel', className), p: 2, ref: ref }, styles, rest)));
|
|
33
|
+
exports.Panel = (0, core_1.vui)(function (props, ref) {
|
|
34
|
+
var _a = (0, core_1.omitThemingProps)(props), className = _a.className, rest = __rest(_a, ["className"]);
|
|
35
|
+
var styles = (0, core_1.useStyleConfig)('Panel', props);
|
|
36
|
+
return (react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", className: (0, utils_1.cs)('vui-panel', className), p: 2, ref: ref }, styles, rest)));
|
|
37
37
|
});
|
|
38
38
|
exports.Panel.displayName = 'Panel';
|
|
39
39
|
exports.default = exports.Panel;
|
package/radio/context.js
CHANGED
|
@@ -18,6 +18,6 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.useRadioGroup = exports.RadioGroupProvider = void 0;
|
|
20
20
|
var core_1 = require("../core");
|
|
21
|
-
var _a = __read(core_1.createContext({ isOptional: true }), 2), RadioGroupProvider = _a[0], useRadioGroup = _a[1];
|
|
21
|
+
var _a = __read((0, core_1.createContext)({ isOptional: true }), 2), RadioGroupProvider = _a[0], useRadioGroup = _a[1];
|
|
22
22
|
exports.RadioGroupProvider = RadioGroupProvider;
|
|
23
23
|
exports.useRadioGroup = useRadioGroup;
|
package/radio/radio.js
CHANGED
|
@@ -14,6 +14,25 @@ var __assign = (this && this.__assign) || function () {
|
|
|
14
14
|
};
|
|
15
15
|
return __assign.apply(this, arguments);
|
|
16
16
|
};
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
17
36
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
37
|
var t = {};
|
|
19
38
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -25,12 +44,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
25
44
|
}
|
|
26
45
|
return t;
|
|
27
46
|
};
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
28
63
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
65
|
};
|
|
31
66
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
67
|
exports.Radio = exports.RadioControl = exports.RadioBase = exports.RadioInput = void 0;
|
|
33
|
-
var react_1 =
|
|
68
|
+
var react_1 = __importStar(require("react"));
|
|
34
69
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
35
70
|
var context_1 = require("./context");
|
|
36
71
|
var core_1 = require("../core");
|
|
@@ -39,24 +74,34 @@ var system_1 = require("../system");
|
|
|
39
74
|
var t_1 = __importDefault(require("../t"));
|
|
40
75
|
var utils_1 = require("../utils");
|
|
41
76
|
exports.RadioInput = styled_components_1.default.input(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tcursor: inherit;\n\theight: 100%;\n\tleft: 0;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: 0;\n\twidth: 100%;\n\tz-index: 1;\n"], ["\n\tcursor: inherit;\n\theight: 100%;\n\tleft: 0;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: 0;\n\twidth: 100%;\n\tz-index: 1;\n"])));
|
|
42
|
-
exports.RadioBase = styled_components_1.default.label.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\twidth: fit-content;\n\n\t:hover .vui-radioControl {\n\t\tcolor: ", ";\n\t}\n\n\t&.disabled {\n\t\tcolor: var(--vui-colors-disabled-font);\n\t\tcursor: not-allowed;\n\n\t\t.vui-radioControl {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\twidth: fit-content;\n\n\t:hover .vui-radioControl {\n\t\tcolor: ", ";\n\t}\n\n\t&.disabled {\n\t\tcolor: var(--vui-colors-disabled-font);\n\t\tcursor: not-allowed;\n\n\t\t.vui-radioControl {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"])), function (p) { return core_1.th.color(p.controlHoverColor)(p); }, system_1.system);
|
|
43
|
-
exports.RadioControl = styled_components_1.default.span.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t", "\n"], ["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t", "\n"])), system_1.system);
|
|
44
|
-
exports.Radio = core_1.vui(function (props, ref) {
|
|
45
|
-
var _a;
|
|
46
|
-
var
|
|
77
|
+
exports.RadioBase = styled_components_1.default.label.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\twidth: fit-content;\n\n\t:hover .vui-radioControl {\n\t\tcolor: ", ";\n\t}\n\n\t&.disabled {\n\t\tcolor: var(--vui-colors-disabled-font);\n\t\tcursor: not-allowed;\n\n\t\t.vui-radioControl {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\twidth: fit-content;\n\n\t:hover .vui-radioControl {\n\t\tcolor: ", ";\n\t}\n\n\t&.disabled {\n\t\tcolor: var(--vui-colors-disabled-font);\n\t\tcursor: not-allowed;\n\n\t\t.vui-radioControl {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"])), function (p) { return core_1.th.color(p.controlHoverColor)(p); }, system_1.system);
|
|
78
|
+
exports.RadioControl = styled_components_1.default.span.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t", "\n"], ["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t", "\n"])), system_1.system);
|
|
79
|
+
exports.Radio = (0, core_1.vui)(function (props, ref) {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
var _c = (_a = (0, context_1.useRadioGroup)()) !== null && _a !== void 0 ? _a : {}, groupDefaultValue = _c.defaultValue, groupIsChecked = _c.isChecked, groupOnChange = _c.onChange, groupValue = _c.value, radioGroupProps = __rest(_c, ["defaultValue", "isChecked", "onChange", "value"]);
|
|
82
|
+
var defaultIsChecked = groupIsChecked !== undefined ? groupIsChecked === props.value : undefined;
|
|
47
83
|
var mergedProps = __assign(__assign({}, radioGroupProps), props);
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
84
|
+
var _d = (0, core_1.omitThemingProps)(mergedProps), _e = _d.checked, checked = _e === void 0 ? groupValue !== undefined ? props.value === groupValue : undefined : _e, children = _d.children, className = _d.className, _f = _d.defaultChecked, defaultChecked = _f === void 0 ? groupDefaultValue !== undefined ? props.value === groupDefaultValue : undefined : _f, disabled = _d.disabled, _g = _d.icon, iconProp = _g === void 0 ? 'cuiRadioUnselected' : _g, _h = _d.iconChecked, iconChecked = _h === void 0 ? 'cuiRadioSelected' : _h, id = _d.id, inputProps = _d.inputProps, inputRef = _d.inputRef, label = _d.label, name = _d.name, onChange = _d.onChange, required = _d.required, value = _d.value, rest = __rest(_d, ["checked", "children", "className", "defaultChecked", "disabled", "icon", "iconChecked", "id", "inputProps", "inputRef", "label", "name", "onChange", "required", "value"]);
|
|
85
|
+
var _j = __read((0, react_1.useState)((_b = defaultIsChecked !== null && defaultIsChecked !== void 0 ? defaultIsChecked : checked) !== null && _b !== void 0 ? _b : defaultChecked), 2), isChecked = _j[0], setIsChecked = _j[1];
|
|
86
|
+
var styles = (0, core_1.useStyleConfig)('Radio', mergedProps);
|
|
87
|
+
var _k = styles.control, controlColor = _k.color, hoverColor = _k.hoverColor, controlStyles = __rest(_k, ["color", "hoverColor"]);
|
|
88
|
+
var icon = isChecked ? iconChecked : iconProp;
|
|
52
89
|
var controlMr = children || label ? 1 : 0;
|
|
53
|
-
var color =
|
|
54
|
-
var controlHoverColor =
|
|
90
|
+
var color = isChecked ? controlColor : 'grey.60';
|
|
91
|
+
var controlHoverColor = isChecked ? hoverColor : 'grey.90';
|
|
92
|
+
(0, react_1.useEffect)(function () {
|
|
93
|
+
if (groupIsChecked !== undefined) {
|
|
94
|
+
setIsChecked(groupIsChecked === value);
|
|
95
|
+
}
|
|
96
|
+
else if (checked !== undefined) {
|
|
97
|
+
setIsChecked(checked);
|
|
98
|
+
}
|
|
99
|
+
}, [checked, groupIsChecked]);
|
|
55
100
|
function handleOnChange(e) {
|
|
56
101
|
groupOnChange === null || groupOnChange === void 0 ? void 0 : groupOnChange(e);
|
|
57
102
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
58
103
|
}
|
|
59
|
-
return (react_1.default.createElement(exports.RadioBase, __assign({ className: utils_1.cs('vui-radio', disabled && 'disabled', className), controlHoverColor: controlHoverColor, ref: ref }, styles.container, rest),
|
|
104
|
+
return (react_1.default.createElement(exports.RadioBase, __assign({ className: (0, utils_1.cs)('vui-radio', disabled && 'disabled', className), controlHoverColor: controlHoverColor, ref: ref }, styles.container, rest),
|
|
60
105
|
react_1.default.createElement(exports.RadioControl, __assign({ borderRadius: "50%", className: "vui-radioControl", color: color, focusWithinRing: 3, mr: controlMr, transitionDuration: "fast" }, controlStyles),
|
|
61
106
|
react_1.default.createElement(exports.RadioInput, __assign({ className: "vui-radioInput", onChange: handleOnChange, ref: inputRef, type: "radio" }, { checked: checked, defaultChecked: defaultChecked, disabled: disabled, id: id, name: name, required: required, value: value }, inputProps)),
|
|
62
107
|
react_1.default.createElement(icon_1.default, { className: "vui-radioIcon", h: "100%", name: icon, w: "100%" })), children !== null && children !== void 0 ? children : (label && (react_1.default.createElement(t_1.default, __assign({ className: "vui-radioLabel", lineHeight: "normal" }, styles.label), label)))));
|
package/radio/radioGroup.js
CHANGED
|
@@ -71,27 +71,35 @@ var context_1 = require("./context");
|
|
|
71
71
|
var core_1 = require("../core");
|
|
72
72
|
var system_1 = require("../system");
|
|
73
73
|
var utils_1 = require("../utils");
|
|
74
|
-
exports.RadioGroupBase = styled_components_1.default.div.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tdisplay: flex;\n\tflex-direction: column;\n\n\t", "\n"], ["\n\tdisplay: flex;\n\tflex-direction: column;\n\n\t", "\n"])), system_1.system);
|
|
75
|
-
exports.RadioGroup = core_1.vui(function (props, ref) {
|
|
76
|
-
var className = props.className, colorScheme = props.colorScheme,
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setValue(e.target.value);
|
|
74
|
+
exports.RadioGroupBase = styled_components_1.default.div.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tdisplay: flex;\n\tflex-direction: column;\n\n\t", "\n"], ["\n\tdisplay: flex;\n\tflex-direction: column;\n\n\t", "\n"])), system_1.system);
|
|
75
|
+
exports.RadioGroup = (0, core_1.vui)(function (props, ref) {
|
|
76
|
+
var className = props.className, colorScheme = props.colorScheme, defaultValue = props.defaultValue, disabled = props.disabled, isRow = props.isRow, name = props.name, onBlur = props.onBlur, onChange = props.onChange, onFocus = props.onFocus, size = props.size, value = props.value, variant = props.variant, rest = __rest(props, ["className", "colorScheme", "defaultValue", "disabled", "isRow", "name", "onBlur", "onChange", "onFocus", "size", "value", "variant"]);
|
|
77
|
+
var _a = __read((0, react_1.useState)(value !== null && value !== void 0 ? value : defaultValue), 2), isChecked = _a[0], setIsChecked = _a[1];
|
|
78
|
+
var handleOnChange = (0, react_1.useCallback)(function (e) {
|
|
79
|
+
console.log('group onchange', e.target.value);
|
|
80
|
+
setIsChecked(e.target.value);
|
|
82
81
|
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
83
82
|
}, [onChange]);
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
var context = (0, react_1.useMemo)(function () {
|
|
84
|
+
return (0, utils_1.filterUndefined)({
|
|
85
|
+
colorScheme: colorScheme,
|
|
86
|
+
defaultValue: defaultValue,
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
isChecked: isChecked,
|
|
89
|
+
name: name,
|
|
90
|
+
onBlur: onBlur,
|
|
91
|
+
onChange: handleOnChange,
|
|
92
|
+
onFocus: onFocus,
|
|
93
|
+
size: size,
|
|
94
|
+
value: value,
|
|
95
|
+
variant: variant
|
|
96
|
+
});
|
|
97
|
+
}, [colorScheme, defaultValue, disabled, handleOnChange, isChecked, name, onBlur, onFocus, size, value, variant]);
|
|
98
|
+
var aliasedProps = (0, utils_1.filterUndefined)({
|
|
99
|
+
flexDirection: isRow ? 'row' : undefined
|
|
92
100
|
});
|
|
93
101
|
return (react_1.default.createElement(context_1.RadioGroupProvider, { value: context },
|
|
94
|
-
react_1.default.createElement(exports.RadioGroupBase, __assign({ className: utils_1.cs('vui-radioGroup', className), ref: ref }, aliasedProps, rest))));
|
|
102
|
+
react_1.default.createElement(exports.RadioGroupBase, __assign({ className: (0, utils_1.cs)('vui-radioGroup', className), ref: ref }, aliasedProps, rest))));
|
|
95
103
|
});
|
|
96
104
|
exports.RadioGroup.displayName = 'RadioGroup';
|
|
97
105
|
exports.default = exports.RadioGroup;
|
|
@@ -4,10 +4,10 @@ import { ThemingProps } from '../theme';
|
|
|
4
4
|
export interface RadioGroupProps extends SystemProps, ThemingProps<'Radio'> {
|
|
5
5
|
colorScheme?: 'blue' | 'prussian';
|
|
6
6
|
disabled?: boolean;
|
|
7
|
+
isRow?: boolean;
|
|
7
8
|
name?: string;
|
|
8
9
|
onBlur?: FocusEventHandler;
|
|
9
10
|
onChange?: ChangeEventHandler;
|
|
10
11
|
onFocus?: FocusEventHandler;
|
|
11
|
-
row?: boolean;
|
|
12
12
|
value?: number | string;
|
|
13
13
|
}
|
package/radio/theme.js
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function variantDefault(props) {
|
|
4
4
|
var c = props.colorScheme;
|
|
5
|
-
var
|
|
5
|
+
var control = {
|
|
6
6
|
color: c + ".80",
|
|
7
7
|
hoverColor: c + ".90"
|
|
8
8
|
};
|
|
9
|
+
if (c === 'prussian') {
|
|
10
|
+
control.hoverColor = 'prussian.70';
|
|
11
|
+
}
|
|
9
12
|
return {
|
|
10
|
-
control:
|
|
13
|
+
control: control
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
16
|
var defaultProps = {
|
package/skeleton/skeleton.js
CHANGED
|
@@ -35,15 +35,15 @@ var styled_components_1 = __importDefault(require("styled-components"));
|
|
|
35
35
|
var core_1 = require("../core");
|
|
36
36
|
var system_1 = require("../system");
|
|
37
37
|
var utils_1 = require("../utils");
|
|
38
|
-
exports.SkeletonBase = styled_components_1.default.div.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tanimation: vui-pulse 1.5s ease-in-out 0.5s infinite;\n\n\t", "\n"], ["\n\tanimation: vui-pulse 1.5s ease-in-out 0.5s infinite;\n\n\t", "\n"])), system_1.system);
|
|
39
|
-
exports.Skeleton = core_1.vui(function (props, ref) {
|
|
40
|
-
var _a = core_1.omitThemingProps(props), className = _a.className, _b = _a.repeat, repeat = _b === void 0 ? 1 : _b, rest = __rest(_a, ["className", "repeat"]);
|
|
41
|
-
var styles = core_1.useStyleConfig('Skeleton', props);
|
|
38
|
+
exports.SkeletonBase = styled_components_1.default.div.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tanimation: vui-pulse 1.5s ease-in-out 0.5s infinite;\n\n\t", "\n"], ["\n\tanimation: vui-pulse 1.5s ease-in-out 0.5s infinite;\n\n\t", "\n"])), system_1.system);
|
|
39
|
+
exports.Skeleton = (0, core_1.vui)(function (props, ref) {
|
|
40
|
+
var _a = (0, core_1.omitThemingProps)(props), className = _a.className, _b = _a.repeat, repeat = _b === void 0 ? 1 : _b, rest = __rest(_a, ["className", "repeat"]);
|
|
41
|
+
var styles = (0, core_1.useStyleConfig)('Skeleton', props);
|
|
42
42
|
var arr = Array(repeat).fill(0);
|
|
43
|
-
var aliasedProps = utils_1.filterUndefined({
|
|
43
|
+
var aliasedProps = (0, utils_1.filterUndefined)({
|
|
44
44
|
w: props.variant === 'circle' ? styles.h : undefined
|
|
45
45
|
});
|
|
46
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, arr.map(function (_, i) { return (react_1.default.createElement(exports.SkeletonBase, __assign({ className: utils_1.cs('vui-skeleton', className), key: i, ref: ref }, styles, aliasedProps, rest))); })));
|
|
46
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, arr.map(function (_, i) { return (react_1.default.createElement(exports.SkeletonBase, __assign({ className: (0, utils_1.cs)('vui-skeleton', className), key: i, ref: ref }, styles, aliasedProps, rest))); })));
|
|
47
47
|
});
|
|
48
48
|
exports.Skeleton.displayName = 'Skeleton';
|
|
49
49
|
exports.default = exports.Skeleton;
|
package/spinner/spinner.js
CHANGED
|
@@ -38,21 +38,21 @@ var core_1 = require("../core");
|
|
|
38
38
|
var system_1 = require("../system");
|
|
39
39
|
var t_1 = __importDefault(require("../t"));
|
|
40
40
|
var utils_1 = require("../utils");
|
|
41
|
-
exports.SpinnerCircle = styled_components_1.default.div.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tdisplay: flex;\n\tflex-shrink: 0;\n\n\t", "\n\n\tanimation-duration: ", ";\n"], ["\n\tdisplay: flex;\n\tflex-shrink: 0;\n\n\t", "\n\n\tanimation-duration: ", ";\n"])), system_1.system, function (p) { return p.speed; });
|
|
42
|
-
exports.Spinner = core_1.vui(function (props, ref) {
|
|
41
|
+
exports.SpinnerCircle = styled_components_1.default.div.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tdisplay: flex;\n\tflex-shrink: 0;\n\n\t", "\n\n\tanimation-duration: ", ";\n"], ["\n\tdisplay: flex;\n\tflex-shrink: 0;\n\n\t", "\n\n\tanimation-duration: ", ";\n"])), system_1.system, function (p) { return p.speed; });
|
|
42
|
+
exports.Spinner = (0, core_1.vui)(function (props, ref) {
|
|
43
43
|
var _a;
|
|
44
44
|
var className = props.className, emptyColor = props.emptyColor, size = props.size, _b = props.speed, speedProp = _b === void 0 ? 'normal' : _b, text = props.text, _c = props.textPosition, textPosition = _c === void 0 ? 'bottom' : _c, thickness = props.thickness, rest = __rest(props, ["className", "emptyColor", "size", "speed", "text", "textPosition", "thickness"]);
|
|
45
|
-
var styles = core_1.useStyleConfig('Spinner', props);
|
|
45
|
+
var styles = (0, core_1.useStyleConfig)('Spinner', props);
|
|
46
46
|
var isCustomSize = typeof size === 'number';
|
|
47
47
|
var positionProps = consts_1.spinnerPositionMapping[textPosition];
|
|
48
48
|
var speed = (_a = consts_1.spinnerSpeedMapping[speedProp]) !== null && _a !== void 0 ? _a : speedProp;
|
|
49
|
-
var circleProps = utils_1.filterUndefined({
|
|
49
|
+
var circleProps = (0, utils_1.filterUndefined)({
|
|
50
50
|
borderColor: emptyColor,
|
|
51
51
|
borderWidth: isCustomSize ? thickness !== null && thickness !== void 0 ? thickness : 4 : thickness,
|
|
52
52
|
h: isCustomSize ? size : undefined,
|
|
53
53
|
w: isCustomSize ? size : undefined
|
|
54
54
|
});
|
|
55
|
-
return (react_1.default.createElement(box_1.default, __assign({ center: true, className: utils_1.cs('vui-spinner', className), ref: ref, transitionDuration: "fast" }, styles.container, positionProps.container, rest),
|
|
55
|
+
return (react_1.default.createElement(box_1.default, __assign({ center: true, className: (0, utils_1.cs)('vui-spinner', className), ref: ref, transitionDuration: "fast" }, styles.container, positionProps.container, rest),
|
|
56
56
|
react_1.default.createElement(exports.SpinnerCircle, __assign({ animation: "spin", borderRadius: "round", className: "vui-spinnerCircle", speed: speed }, styles.circle, positionProps.circle, circleProps)),
|
|
57
57
|
text && (react_1.default.createElement(t_1.default, __assign({ className: "vui-spinnerText" }, styles.text), text))));
|
|
58
58
|
});
|
package/svg/svg.js
CHANGED
|
@@ -108,21 +108,21 @@ var helpers_1 = require("./helpers");
|
|
|
108
108
|
var core_1 = require("../core");
|
|
109
109
|
var system_1 = require("../system");
|
|
110
110
|
var utils_1 = require("../utils");
|
|
111
|
-
exports.SvgBase = styled_components_1.default.svg.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t& > path:nth-child(1) {\n\t\tfill: ", ";\n\t}\n\n\t& > path:nth-child(2) {\n\t\tfill: ", ";\n\t}\n\n\t", "\n"], ["\n\t& > path:nth-child(1) {\n\t\tfill: ", ";\n\t}\n\n\t& > path:nth-child(2) {\n\t\tfill: ", ";\n\t}\n\n\t", "\n"])), function (p) { var _a, _b, _c; return core_1.th.color((_c = (_b = (_a = p.fill) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : p.fill) !== null && _c !== void 0 ? _c : '')(p); }, function (p) { var _a, _b, _c; return core_1.th.color((_c = (_b = (_a = p.fill) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : p.fill) !== null && _c !== void 0 ? _c : '')(p); }, system_1.system);
|
|
112
|
-
exports.Svg = core_1.vui(function (props, ref) {
|
|
111
|
+
exports.SvgBase = styled_components_1.default.svg.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\t& > path:nth-child(1) {\n\t\tfill: ", ";\n\t}\n\n\t& > path:nth-child(2) {\n\t\tfill: ", ";\n\t}\n\n\t", "\n"], ["\n\t& > path:nth-child(1) {\n\t\tfill: ", ";\n\t}\n\n\t& > path:nth-child(2) {\n\t\tfill: ", ";\n\t}\n\n\t", "\n"])), function (p) { var _a, _b, _c; return core_1.th.color((_c = (_b = (_a = p.fill) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : p.fill) !== null && _c !== void 0 ? _c : '')(p); }, function (p) { var _a, _b, _c; return core_1.th.color((_c = (_b = (_a = p.fill) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : p.fill) !== null && _c !== void 0 ? _c : '')(p); }, system_1.system);
|
|
112
|
+
exports.Svg = (0, core_1.vui)(function (props, ref) {
|
|
113
113
|
var children = props.children, className = props.className, src = props.src, rest = __rest(props, ["children", "className", "src"]);
|
|
114
|
-
var _a = __read(react_1.useState(helpers_1.initState()), 2), state = _a[0], setState = _a[1];
|
|
115
|
-
var isMountedRef = react_1.useRef(false);
|
|
116
|
-
var srcRef = react_1.useRef(src);
|
|
114
|
+
var _a = __read((0, react_1.useState)((0, helpers_1.initState)()), 2), state = _a[0], setState = _a[1];
|
|
115
|
+
var isMountedRef = (0, react_1.useRef)(false);
|
|
116
|
+
var srcRef = (0, react_1.useRef)(src);
|
|
117
117
|
var _b = state.content, content = _b === void 0 ? '' : _b, _c = state.svgAttributes, svgAttributes = _c === void 0 ? {} : _c;
|
|
118
118
|
var innerHTML = !children ? { __html: content } : undefined;
|
|
119
|
-
react_1.useEffect(function () {
|
|
119
|
+
(0, react_1.useEffect)(function () {
|
|
120
120
|
isMountedRef.current = true;
|
|
121
121
|
return function () {
|
|
122
122
|
isMountedRef.current = false;
|
|
123
123
|
};
|
|
124
124
|
}, []);
|
|
125
|
-
react_1.useEffect(function () {
|
|
125
|
+
(0, react_1.useEffect)(function () {
|
|
126
126
|
srcRef.current = src;
|
|
127
127
|
function loadSvg(src) {
|
|
128
128
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -134,9 +134,9 @@ exports.Svg = core_1.vui(function (props, ref) {
|
|
|
134
134
|
return [4 /*yield*/, cache_1.default.get(src)];
|
|
135
135
|
case 1:
|
|
136
136
|
response = _a.sent();
|
|
137
|
-
content_1 = helpers_1.getSvgContent(response);
|
|
138
|
-
svgEl = helpers_1.stringToHTML(response);
|
|
139
|
-
svgAttributes_1 = helpers_1.getAttributes(svgEl);
|
|
137
|
+
content_1 = (0, helpers_1.getSvgContent)(response);
|
|
138
|
+
svgEl = (0, helpers_1.stringToHTML)(response);
|
|
139
|
+
svgAttributes_1 = (0, helpers_1.getAttributes)(svgEl);
|
|
140
140
|
svgAttributes_1['data-src'] = src !== null && src !== void 0 ? src : '';
|
|
141
141
|
// Update state only when requested 'src' and current 'src' are the same
|
|
142
142
|
if (srcRef.current === src && isMountedRef.current) {
|
|
@@ -147,7 +147,7 @@ exports.Svg = core_1.vui(function (props, ref) {
|
|
|
147
147
|
error_1 = _a.sent();
|
|
148
148
|
console.error(error_1); // eslint-disable-line no-console
|
|
149
149
|
if (isMountedRef.current) {
|
|
150
|
-
setState(helpers_1.initState());
|
|
150
|
+
setState((0, helpers_1.initState)());
|
|
151
151
|
}
|
|
152
152
|
return [3 /*break*/, 3];
|
|
153
153
|
case 3: return [2 /*return*/];
|
|
@@ -157,7 +157,7 @@ exports.Svg = core_1.vui(function (props, ref) {
|
|
|
157
157
|
}
|
|
158
158
|
src && loadSvg(src);
|
|
159
159
|
}, [src]);
|
|
160
|
-
return (react_1.default.createElement(exports.SvgBase, __assign({ className: utils_1.cs('vui-svg', className), dangerouslySetInnerHTML: innerHTML, ref: ref, xmlns: "http://www.w3.org/2000/svg" }, svgAttributes, rest), children));
|
|
160
|
+
return (react_1.default.createElement(exports.SvgBase, __assign({ className: (0, utils_1.cs)('vui-svg', className), dangerouslySetInnerHTML: innerHTML, ref: ref, xmlns: "http://www.w3.org/2000/svg" }, svgAttributes, rest), children));
|
|
161
161
|
});
|
|
162
162
|
exports.Svg.displayName = 'Svg';
|
|
163
163
|
exports.default = exports.Svg;
|
package/switch/context.js
CHANGED
|
@@ -18,6 +18,6 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.useSwitch = exports.SwitchProvider = void 0;
|
|
20
20
|
var core_1 = require("../core");
|
|
21
|
-
var _a = __read(core_1.createContext({ isOptional: true }), 2), SwitchProvider = _a[0], useSwitch = _a[1];
|
|
21
|
+
var _a = __read((0, core_1.createContext)({ isOptional: true }), 2), SwitchProvider = _a[0], useSwitch = _a[1];
|
|
22
22
|
exports.SwitchProvider = SwitchProvider;
|
|
23
23
|
exports.useSwitch = useSwitch;
|
package/switch/switch.js
CHANGED
|
@@ -44,22 +44,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
44
44
|
}
|
|
45
45
|
return t;
|
|
46
46
|
};
|
|
47
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
-
if (!m) return o;
|
|
50
|
-
var i = m.call(o), r, ar = [], e;
|
|
51
|
-
try {
|
|
52
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
-
}
|
|
54
|
-
catch (error) { e = { error: error }; }
|
|
55
|
-
finally {
|
|
56
|
-
try {
|
|
57
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
-
}
|
|
59
|
-
finally { if (e) throw e.error; }
|
|
60
|
-
}
|
|
61
|
-
return ar;
|
|
62
|
-
};
|
|
63
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
49
|
};
|
|
@@ -74,56 +58,34 @@ var core_1 = require("../core");
|
|
|
74
58
|
var system_1 = require("../system");
|
|
75
59
|
var t_1 = require("../t");
|
|
76
60
|
var utils_1 = require("../utils");
|
|
77
|
-
exports.SwitchBase = styled_components_1.default.label.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tline-height: normal;\n\twidth: fit-content;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tline-height: normal;\n\twidth: fit-content;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"])), t_1.TBase, system_1.system);
|
|
78
|
-
exports.Switch = core_1.vui(function (props, ref) {
|
|
61
|
+
exports.SwitchBase = styled_components_1.default.label.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tline-height: normal;\n\twidth: fit-content;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\talign-items: center;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tline-height: normal;\n\twidth: fit-content;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tcolor: var(--vui-colors-disabled-font);\n\t\t}\n\t}\n\n\t", "\n"])), t_1.TBase, system_1.system);
|
|
62
|
+
exports.Switch = (0, core_1.vui)(function (props, ref) {
|
|
79
63
|
var _a;
|
|
80
64
|
var button = props.button, checked = props.checked, children = props.children, className = props.className, colorScheme = props.colorScheme, defaultChecked = props.defaultChecked, disabled = props.disabled, id = props.id, innerLabelOff = props.innerLabelOff, innerLabelOn = props.innerLabelOn, inputRef = props.inputRef, labelLeft = props.labelLeft, labelRight = props.labelRight, name = props.name, onBlur = props.onBlur, onChange = props.onChange, onFocus = props.onFocus, required = props.required, size = props.size, value = props.value, variant = props.variant, rest = __rest(props, ["button", "checked", "children", "className", "colorScheme", "defaultChecked", "disabled", "id", "innerLabelOff", "innerLabelOn", "inputRef", "labelLeft", "labelRight", "name", "onBlur", "onChange", "onFocus", "required", "size", "value", "variant"]);
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, [checked]);
|
|
86
|
-
var handleOnChange = react_1.useCallback(function (e) {
|
|
87
|
-
setIsChecked(e.target.checked);
|
|
88
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(e);
|
|
89
|
-
}, [onChange]);
|
|
90
|
-
var context = react_1.useMemo(function () {
|
|
91
|
-
return utils_1.filterUndefined({
|
|
65
|
+
var styles = (0, core_1.useStyleConfig)('Switch', props);
|
|
66
|
+
var context = (0, react_1.useMemo)(function () {
|
|
67
|
+
return (0, utils_1.filterUndefined)({
|
|
68
|
+
checked: checked,
|
|
92
69
|
colorScheme: colorScheme,
|
|
93
70
|
defaultChecked: defaultChecked,
|
|
94
71
|
disabled: disabled,
|
|
95
|
-
isChecked: isChecked,
|
|
96
72
|
name: name,
|
|
97
73
|
onBlur: onBlur,
|
|
98
|
-
onChange:
|
|
74
|
+
onChange: onChange,
|
|
99
75
|
onFocus: onFocus,
|
|
100
76
|
required: required,
|
|
101
77
|
size: size,
|
|
102
78
|
value: value,
|
|
103
79
|
variant: variant
|
|
104
80
|
});
|
|
105
|
-
}, [
|
|
106
|
-
|
|
107
|
-
defaultChecked,
|
|
108
|
-
disabled,
|
|
109
|
-
handleOnChange,
|
|
110
|
-
isChecked,
|
|
111
|
-
name,
|
|
112
|
-
onBlur,
|
|
113
|
-
onFocus,
|
|
114
|
-
required,
|
|
115
|
-
size,
|
|
116
|
-
value,
|
|
117
|
-
variant
|
|
118
|
-
]);
|
|
119
|
-
var aliasedProps = utils_1.filterUndefined({
|
|
120
|
-
'data-checked': isChecked ? true : false,
|
|
81
|
+
}, [checked, colorScheme, defaultChecked, disabled, name, onBlur, onChange, onFocus, required, size, value, variant]);
|
|
82
|
+
var aliasedProps = (0, utils_1.filterUndefined)({
|
|
121
83
|
'data-disabled': disabled ? true : false
|
|
122
84
|
});
|
|
123
85
|
return (react_1.default.createElement(context_1.SwitchProvider, { value: context },
|
|
124
|
-
react_1.default.createElement(exports.SwitchBase, __assign({ className: utils_1.cs('vui-switch', className), ref: ref }, styles.container, aliasedProps, rest),
|
|
125
|
-
utils_1.isReactText(labelLeft) ? react_1.default.createElement(switchLabel_1.SwitchLabel, { mr: 1, text: labelLeft }) : labelLeft, (_a = children !== null && children !== void 0 ? children : button) !== null && _a !== void 0 ? _a : react_1.default.createElement(switchButton_1.SwitchButton, __assign({}, { id: id, innerLabelOff: innerLabelOff, innerLabelOn: innerLabelOn, inputRef: inputRef })),
|
|
126
|
-
utils_1.isReactText(labelRight) ? react_1.default.createElement(switchLabel_1.SwitchLabel, { ml: 1, text: labelRight }) : labelRight)));
|
|
86
|
+
react_1.default.createElement(exports.SwitchBase, __assign({ className: (0, utils_1.cs)('vui-switch', className), ref: ref }, styles.container, aliasedProps, rest),
|
|
87
|
+
(0, utils_1.isReactText)(labelLeft) ? react_1.default.createElement(switchLabel_1.SwitchLabel, { mr: 1, text: labelLeft }) : labelLeft, (_a = children !== null && children !== void 0 ? children : button) !== null && _a !== void 0 ? _a : react_1.default.createElement(switchButton_1.SwitchButton, __assign({}, { id: id, innerLabelOff: innerLabelOff, innerLabelOn: innerLabelOn, inputRef: inputRef })),
|
|
88
|
+
(0, utils_1.isReactText)(labelRight) ? react_1.default.createElement(switchLabel_1.SwitchLabel, { ml: 1, text: labelRight }) : labelRight)));
|
|
127
89
|
});
|
|
128
90
|
exports.Switch.displayName = 'Switch';
|
|
129
91
|
exports.Switch.Button = switchButton_1.SwitchButton;
|
package/switch/switch.types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SystemProps } from '../system';
|
|
|
4
4
|
import { ThemingProps } from '../theme';
|
|
5
5
|
export interface SwitchButtonProps extends SystemProps, ThemingProps<'Switch'> {
|
|
6
6
|
checked?: boolean;
|
|
7
|
-
colorScheme?: 'blue' | 'green' | 'prussian'
|
|
7
|
+
colorScheme?: 'blue' | 'green' | 'prussian';
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
innerLabelOff?: ReactNode;
|
|
10
10
|
innerLabelOn?: ReactNode;
|
|
@@ -20,7 +20,7 @@ export interface SwitchButtonProps extends SystemProps, ThemingProps<'Switch'> {
|
|
|
20
20
|
export interface SwitchProps extends SystemProps, ThemingProps<'Switch'> {
|
|
21
21
|
button?: ReactNode;
|
|
22
22
|
checked?: boolean;
|
|
23
|
-
colorScheme?: 'blue' | 'green' | 'prussian'
|
|
23
|
+
colorScheme?: 'blue' | 'green' | 'prussian';
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
innerLabelOff?: ReactNode;
|
|
26
26
|
innerLabelOn?: ReactNode;
|
package/switch/switchButton.js
CHANGED
|
@@ -71,25 +71,23 @@ var context_1 = require("./context");
|
|
|
71
71
|
var core_1 = require("../core");
|
|
72
72
|
var system_1 = require("../system");
|
|
73
73
|
var utils_1 = require("../utils");
|
|
74
|
-
exports.SwitchInput = styled_components_1.default.input.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tcursor: inherit;\n\theight: calc(100% + 10px);\n\tleft: -5px;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: -5px;\n\twidth: calc(100% + 10px);\n\tz-index: 1;\n\n\t", "\n"], ["\n\tcursor: inherit;\n\theight: calc(100% + 10px);\n\tleft: -5px;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: -5px;\n\twidth: calc(100% + 10px);\n\tz-index: 1;\n\n\t", "\n"])), system_1.system);
|
|
75
|
-
exports.SwitchThumb = styled_components_1.default.span.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: absolute;\n\n\t", "\n"], ["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: absolute;\n\n\t", "\n"])), system_1.system);
|
|
76
|
-
exports.SwitchTrack = styled_components_1.default.span.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\talign-items: center;\n\tdisplay: inline-flex;\n\tflex: 1;\n\tposition: relative;\n\n\t", "\n"], ["\n\talign-items: center;\n\tdisplay: inline-flex;\n\tflex: 1;\n\tposition: relative;\n\n\t", "\n"])), system_1.system);
|
|
77
|
-
exports.SwitchButtonBase = styled_components_1.default.span.withConfig(core_1.forwardPropConfig(system_1.system))(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\tcolor: white;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tborder-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-font);\n\t\t}\n\n\t\t", " {\n\t\t\t--x-ring-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-bg);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\tcolor: white;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tborder-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-font);\n\t\t}\n\n\t\t", " {\n\t\t\t--x-ring-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-bg);\n\t\t}\n\t}\n\n\t", "\n"])), exports.SwitchThumb, exports.SwitchTrack, system_1.system);
|
|
78
|
-
exports.SwitchButton = core_1.vui(function (props, ref) {
|
|
74
|
+
exports.SwitchInput = styled_components_1.default.input.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tcursor: inherit;\n\theight: calc(100% + 10px);\n\tleft: -5px;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: -5px;\n\twidth: calc(100% + 10px);\n\tz-index: 1;\n\n\t", "\n"], ["\n\tcursor: inherit;\n\theight: calc(100% + 10px);\n\tleft: -5px;\n\tmargin: 0;\n\topacity: 0;\n\tpadding: 0;\n\tposition: absolute;\n\ttop: -5px;\n\twidth: calc(100% + 10px);\n\tz-index: 1;\n\n\t", "\n"])), system_1.system);
|
|
75
|
+
exports.SwitchThumb = styled_components_1.default.span.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: absolute;\n\n\t", "\n"], ["\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: absolute;\n\n\t", "\n"])), system_1.system);
|
|
76
|
+
exports.SwitchTrack = styled_components_1.default.span.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\talign-items: center;\n\tdisplay: inline-flex;\n\tflex: 1;\n\tposition: relative;\n\n\t", "\n"], ["\n\talign-items: center;\n\tdisplay: inline-flex;\n\tflex: 1;\n\tposition: relative;\n\n\t", "\n"])), system_1.system);
|
|
77
|
+
exports.SwitchButtonBase = styled_components_1.default.span.withConfig((0, core_1.forwardPropConfig)(system_1.system))(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n\tcolor: white;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tborder-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-font);\n\t\t}\n\n\t\t", " {\n\t\t\t--x-ring-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-bg);\n\t\t}\n\t}\n\n\t", "\n"], ["\n\tcolor: white;\n\tcursor: pointer;\n\tdisplay: inline-flex;\n\tflex-shrink: 0;\n\tposition: relative;\n\n\t&[data-disabled='true'] {\n\t\tcursor: not-allowed;\n\n\t\t", " {\n\t\t\tborder-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-font);\n\t\t}\n\n\t\t", " {\n\t\t\t--x-ring-color: var(--vui-colors-disabled-border);\n\t\t\tbackground-color: var(--vui-colors-disabled-bg);\n\t\t}\n\t}\n\n\t", "\n"])), exports.SwitchThumb, exports.SwitchTrack, system_1.system);
|
|
78
|
+
exports.SwitchButton = (0, core_1.vui)(function (props, ref) {
|
|
79
79
|
var _a;
|
|
80
|
-
var
|
|
80
|
+
var switchProps = (_a = (0, context_1.useSwitch)()) !== null && _a !== void 0 ? _a : {};
|
|
81
81
|
var mergedProps = __assign(__assign({}, switchProps), props);
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
react_1.useEffect(function () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}, [checked, isControlled, switchIsChecked]);
|
|
82
|
+
var _b = (0, core_1.omitThemingProps)(mergedProps), checked = _b.checked, className = _b.className, defaultChecked = _b.defaultChecked, disabled = _b.disabled, id = _b.id, innerLabelOff = _b.innerLabelOff, innerLabelOn = _b.innerLabelOn, inputProps = _b.inputProps, inputRef = _b.inputRef, name = _b.name, onBlur = _b.onBlur, onChange = _b.onChange, onFocus = _b.onFocus, required = _b.required, value = _b.value, rest = __rest(_b, ["checked", "className", "defaultChecked", "disabled", "id", "innerLabelOff", "innerLabelOn", "inputProps", "inputRef", "name", "onBlur", "onChange", "onFocus", "required", "value"]);
|
|
83
|
+
var isControlled = (0, react_1.useRef)(checked !== undefined).current;
|
|
84
|
+
var _c = __read((0, react_1.useState)(checked !== null && checked !== void 0 ? checked : defaultChecked), 2), isChecked = _c[0], setIsChecked = _c[1];
|
|
85
|
+
var _d = __read((0, react_1.useState)(false), 2), isFocused = _d[0], setIsFocused = _d[1];
|
|
86
|
+
var styles = (0, core_1.useStyleConfig)('Switch', mergedProps);
|
|
87
|
+
var _e = styles.button, thumbStyles = _e.thumb, trackStyles = _e.track, buttonStyles = __rest(_e, ["thumb", "track"]);
|
|
88
|
+
(0, react_1.useEffect)(function () {
|
|
89
|
+
isControlled && setIsChecked(checked);
|
|
90
|
+
}, [checked, isControlled]);
|
|
93
91
|
function handleOnBlur(e) {
|
|
94
92
|
setIsFocused(false);
|
|
95
93
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
|
|
@@ -105,22 +103,22 @@ exports.SwitchButton = core_1.vui(function (props, ref) {
|
|
|
105
103
|
var hDiff = (thumbStyles.h - trackStyles.h) / 2;
|
|
106
104
|
var thumbOffset = "calc(100% - " + Math.abs(hDiff - thumbStyles.h) + "px)";
|
|
107
105
|
var labelOffset = thumbStyles.h - hDiff + 4 + "px";
|
|
108
|
-
var buttonAliasedProps = utils_1.filterUndefined({
|
|
106
|
+
var buttonAliasedProps = (0, utils_1.filterUndefined)({
|
|
109
107
|
'data-checked': isChecked ? true : false,
|
|
110
108
|
'data-disabled': disabled ? true : false,
|
|
111
109
|
'data-focused': isFocused ? true : false
|
|
112
110
|
});
|
|
113
|
-
var thumbAliasedProps = utils_1.filterUndefined({
|
|
111
|
+
var thumbAliasedProps = (0, utils_1.filterUndefined)({
|
|
114
112
|
left: isChecked ? thumbOffset : -hDiff,
|
|
115
113
|
ring: isFocused ? thumbStyles.ring : 0
|
|
116
114
|
});
|
|
117
|
-
var trackAliasedProps = utils_1.filterUndefined({
|
|
115
|
+
var trackAliasedProps = (0, utils_1.filterUndefined)({
|
|
118
116
|
bg: isChecked ? trackStyles.bg : 'grey.50',
|
|
119
117
|
pl: isChecked ? 1 : labelOffset,
|
|
120
118
|
pr: isChecked ? labelOffset : 1,
|
|
121
119
|
ring: isFocused ? trackStyles.ring : disabled ? 1 : 0
|
|
122
120
|
});
|
|
123
|
-
return (react_1.default.createElement(exports.SwitchButtonBase, __assign({ className: utils_1.cs('vui-switchButton', className), ref: ref }, buttonStyles, buttonAliasedProps, rest),
|
|
121
|
+
return (react_1.default.createElement(exports.SwitchButtonBase, __assign({ className: (0, utils_1.cs)('vui-switchButton', className), ref: ref }, buttonStyles, buttonAliasedProps, rest),
|
|
124
122
|
react_1.default.createElement(exports.SwitchInput, __assign({ className: "vui-switchInput", onBlur: handleOnBlur, onChange: handleOnChange, onFocus: handleOnFocus, ref: inputRef, type: "checkbox" }, { checked: checked, defaultChecked: defaultChecked, disabled: disabled, id: id, name: name, required: required, value: value }, inputProps)),
|
|
125
123
|
react_1.default.createElement(exports.SwitchTrack, __assign({ borderRadius: "round", className: "vui-switchTrack", transitionDuration: "fast" }, trackStyles, trackAliasedProps),
|
|
126
124
|
!isChecked && innerLabelOff,
|
package/switch/switchLabel.js
CHANGED
|
@@ -19,11 +19,11 @@ var react_1 = __importDefault(require("react"));
|
|
|
19
19
|
var context_1 = require("./context");
|
|
20
20
|
var core_1 = require("../core");
|
|
21
21
|
var t_1 = __importDefault(require("../t"));
|
|
22
|
-
exports.SwitchLabel = core_1.vui(function (props, ref) {
|
|
22
|
+
exports.SwitchLabel = (0, core_1.vui)(function (props, ref) {
|
|
23
23
|
var _a;
|
|
24
|
-
var switchProps = (_a = context_1.useSwitch()) !== null && _a !== void 0 ? _a : {};
|
|
24
|
+
var switchProps = (_a = (0, context_1.useSwitch)()) !== null && _a !== void 0 ? _a : {};
|
|
25
25
|
var mergedProps = __assign(__assign({}, switchProps), props);
|
|
26
|
-
var styles = core_1.useStyleConfig('Switch', mergedProps);
|
|
26
|
+
var styles = (0, core_1.useStyleConfig)('Switch', mergedProps);
|
|
27
27
|
return react_1.default.createElement(t_1.default, __assign({ className: "vui-switchLabel", display: "flex", ref: ref }, styles.label, props));
|
|
28
28
|
});
|
|
29
29
|
exports.SwitchLabel.displayName = 'SwitchLabel';
|