@sb1/ffe-form-react 21.0.6 → 21.0.8
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/es/ToggleSwitch.js +6 -6
- package/lib/ToggleSwitch.js +5 -5
- package/package.json +4 -4
package/es/ToggleSwitch.js
CHANGED
|
@@ -20,17 +20,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, {
|
|
24
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
23
|
+
import React, { useId } from 'react';
|
|
25
24
|
import classNames from 'classnames';
|
|
26
25
|
import i18n from './i18n/i18n';
|
|
27
26
|
export var ToggleSwitch = function (_a) {
|
|
28
|
-
var children = _a.children, className = _a.className, description = _a.description, hideOnOff = _a.hideOnOff, onText = _a.onText, offText = _a.offText,
|
|
29
|
-
var generatedId =
|
|
27
|
+
var children = _a.children, className = _a.className, description = _a.description, hideOnOff = _a.hideOnOff, onText = _a.onText, offText = _a.offText, providedId = _a.id, _b = _a.value, value = _b === void 0 ? 'on' : _b, _c = _a.locale, locale = _c === void 0 ? 'nb' : _c, checked = _a.checked, rest = __rest(_a, ["children", "className", "description", "hideOnOff", "onText", "offText", "id", "value", "locale", "checked"]);
|
|
28
|
+
var generatedId = useId();
|
|
29
|
+
var id = providedId !== null && providedId !== void 0 ? providedId : generatedId;
|
|
30
30
|
var text = i18n[locale];
|
|
31
31
|
return (React.createElement("div", { className: classNames('ffe-toggle-switch', { 'ffe-toggle-switch--hide-on-off': hideOnOff }, className) },
|
|
32
|
-
React.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id:
|
|
33
|
-
React.createElement("label", { className: "ffe-toggle-switch__label", htmlFor:
|
|
32
|
+
React.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id: id, value: value, checked: !!checked }, rest)),
|
|
33
|
+
React.createElement("label", { className: "ffe-toggle-switch__label", htmlFor: id },
|
|
34
34
|
React.createElement("span", { className: "ffe-toggle-switch__label-text" },
|
|
35
35
|
children,
|
|
36
36
|
description && (React.createElement("span", { className: "ffe-toggle-switch__label-description" }, description))),
|
package/lib/ToggleSwitch.js
CHANGED
|
@@ -50,16 +50,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
exports.ToggleSwitch = void 0;
|
|
52
52
|
var react_1 = __importStar(require("react"));
|
|
53
|
-
var uuid_1 = require("uuid");
|
|
54
53
|
var classnames_1 = __importDefault(require("classnames"));
|
|
55
54
|
var i18n_1 = __importDefault(require("./i18n/i18n"));
|
|
56
55
|
var ToggleSwitch = function (_a) {
|
|
57
|
-
var children = _a.children, className = _a.className, description = _a.description, hideOnOff = _a.hideOnOff, onText = _a.onText, offText = _a.offText,
|
|
58
|
-
var generatedId = (0, react_1.
|
|
56
|
+
var children = _a.children, className = _a.className, description = _a.description, hideOnOff = _a.hideOnOff, onText = _a.onText, offText = _a.offText, providedId = _a.id, _b = _a.value, value = _b === void 0 ? 'on' : _b, _c = _a.locale, locale = _c === void 0 ? 'nb' : _c, checked = _a.checked, rest = __rest(_a, ["children", "className", "description", "hideOnOff", "onText", "offText", "id", "value", "locale", "checked"]);
|
|
57
|
+
var generatedId = (0, react_1.useId)();
|
|
58
|
+
var id = providedId !== null && providedId !== void 0 ? providedId : generatedId;
|
|
59
59
|
var text = i18n_1.default[locale];
|
|
60
60
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-toggle-switch', { 'ffe-toggle-switch--hide-on-off': hideOnOff }, className) },
|
|
61
|
-
react_1.default.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id:
|
|
62
|
-
react_1.default.createElement("label", { className: "ffe-toggle-switch__label", htmlFor:
|
|
61
|
+
react_1.default.createElement("input", __assign({ className: "ffe-toggle-switch__input", type: "checkbox", id: id, value: value, checked: !!checked }, rest)),
|
|
62
|
+
react_1.default.createElement("label", { className: "ffe-toggle-switch__label", htmlFor: id },
|
|
63
63
|
react_1.default.createElement("span", { className: "ffe-toggle-switch__label-text" },
|
|
64
64
|
children,
|
|
65
65
|
description && (react_1.default.createElement("span", { className: "ffe-toggle-switch__label-description" }, description))),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-form-react",
|
|
3
|
-
"version": "21.0.
|
|
3
|
+
"version": "21.0.8",
|
|
4
4
|
"description": "React component for form elements in ffe",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"test:watch": "ffe-buildtool jest --watch"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sb1/ffe-collapse-react": "^5.0.
|
|
30
|
-
"@sb1/ffe-form": "^29.1.
|
|
29
|
+
"@sb1/ffe-collapse-react": "^5.0.5",
|
|
30
|
+
"@sb1/ffe-form": "^29.1.5",
|
|
31
31
|
"@sb1/ffe-icons-react": "^11.0.2",
|
|
32
32
|
"@types/uuid": "^9.0.0",
|
|
33
33
|
"classnames": "^2.3.1"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "831354c828a1fcd6fb4b4e6c561dfe3068dce76e"
|
|
48
48
|
}
|