@dxc-technology/halstack-react 0.0.0-9b45027 → 0.0.0-9bd9511
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -11
- package/HalstackContext.d.ts +13 -0
- package/HalstackContext.js +318 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +124 -179
- package/accordion/Accordion.stories.tsx +115 -27
- package/accordion/Accordion.test.js +56 -0
- package/accordion/types.d.ts +12 -11
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +28 -77
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +108 -0
- package/accordion-group/types.d.ts +19 -12
- package/alert/Alert.js +18 -46
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +75 -0
- package/alert/types.d.ts +3 -3
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +6 -16
- package/badge/types.d.ts +5 -0
- package/bleed/Bleed.d.ts +2 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.js +34 -63
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +13 -0
- package/box/types.d.ts +5 -4
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +98 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/bulleted-list/types.js +5 -0
- package/button/Button.js +61 -100
- package/button/Button.stories.tsx +159 -8
- package/button/Button.test.js +26 -0
- package/button/types.d.ts +8 -8
- package/card/Card.js +44 -70
- package/card/Card.test.js +39 -0
- package/card/types.d.ts +4 -3
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +115 -162
- package/checkbox/Checkbox.stories.tsx +198 -130
- package/checkbox/Checkbox.test.js +128 -0
- package/checkbox/types.d.ts +14 -6
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +29 -91
- package/chip/Chip.stories.tsx +98 -13
- package/chip/Chip.test.js +42 -0
- package/chip/types.d.ts +8 -16
- package/common/utils.js +1 -6
- package/common/variables.d.ts +1431 -0
- package/common/variables.js +480 -554
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +215 -0
- package/date-input/DateInput.js +164 -300
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +648 -0
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +116 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +63 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +101 -0
- package/date-input/types.d.ts +71 -13
- package/dialog/Dialog.js +52 -84
- package/dialog/Dialog.stories.tsx +99 -22
- package/dialog/Dialog.test.js +56 -0
- package/dialog/types.d.ts +4 -3
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +240 -323
- package/dropdown/Dropdown.stories.tsx +255 -64
- package/dropdown/Dropdown.test.js +479 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +60 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +70 -0
- package/dropdown/types.d.ts +30 -19
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +224 -351
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +445 -0
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +48 -97
- package/file-input/types.d.ts +24 -7
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/flex/types.js +5 -0
- package/footer/Footer.js +36 -143
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +92 -0
- package/footer/Icons.js +1 -5
- package/footer/types.d.ts +7 -6
- package/header/Header.js +112 -177
- package/header/Header.stories.tsx +189 -36
- package/header/Header.test.js +66 -0
- package/header/Icons.js +2 -6
- package/header/types.d.ts +4 -3
- package/heading/Heading.js +8 -29
- package/heading/Heading.test.js +169 -0
- package/heading/types.d.ts +3 -3
- package/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -164
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +11 -10
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +15 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -106
- package/link/Link.stories.tsx +159 -52
- package/link/Link.test.js +65 -0
- package/link/types.d.ts +9 -29
- package/main.d.ts +11 -15
- package/main.js +48 -121
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +95 -0
- package/nav-tabs/NavTabs.stories.tsx +260 -0
- package/nav-tabs/NavTabs.test.js +75 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +120 -0
- package/nav-tabs/types.d.ts +53 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.js +21 -38
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +406 -0
- package/number-input/NumberInputContext.js +0 -5
- package/number-input/numberInputContextTypes.d.ts +1 -1
- package/number-input/types.d.ts +21 -14
- package/package.json +22 -25
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -38
- package/paginator/Paginator.js +31 -82
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +266 -0
- package/paginator/types.d.ts +1 -1
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +28 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +28 -54
- package/password-input/PasswordInput.test.js +138 -0
- package/password-input/types.d.ts +18 -15
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +65 -84
- package/progress-bar/ProgressBar.stories.jsx +47 -12
- package/progress-bar/ProgressBar.test.js +93 -0
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +95 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +61 -66
- package/radio-group/RadioGroup.js +99 -129
- package/radio-group/RadioGroup.stories.tsx +171 -36
- package/radio-group/RadioGroup.test.js +620 -0
- package/radio-group/types.d.ts +85 -7
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +48 -0
- package/resultsetTable/ResultsetTable.js +66 -157
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +292 -0
- package/resultsetTable/types.d.ts +5 -5
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +90 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +144 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +81 -0
- package/select/Select.js +201 -485
- package/select/Select.stories.tsx +600 -201
- package/select/Select.test.js +1845 -0
- package/select/types.d.ts +62 -22
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +164 -74
- package/sidenav/Sidenav.stories.tsx +249 -149
- package/sidenav/Sidenav.test.js +37 -0
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +143 -164
- package/slider/Slider.stories.tsx +72 -9
- package/slider/Slider.test.js +222 -0
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +12 -41
- package/spinner/Spinner.stories.jsx +27 -1
- package/spinner/Spinner.test.js +55 -0
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +148 -107
- package/switch/Switch.stories.tsx +53 -42
- package/switch/Switch.test.js +180 -0
- package/switch/types.d.ts +13 -5
- package/table/Table.js +5 -23
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +21 -0
- package/table/types.d.ts +3 -3
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +115 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +318 -139
- package/tabs/Tabs.stories.tsx +119 -13
- package/tabs/Tabs.test.js +295 -0
- package/tabs/types.d.ts +21 -7
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +36 -75
- package/tag/Tag.stories.tsx +37 -27
- package/tag/Tag.test.js +49 -0
- package/tag/types.d.ts +25 -16
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +57 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +68 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +109 -0
- package/text-input/TextInput.js +232 -438
- package/text-input/TextInput.stories.tsx +310 -197
- package/text-input/TextInput.test.js +1404 -0
- package/text-input/types.d.ts +55 -17
- package/textarea/Textarea.js +53 -96
- package/textarea/Textarea.stories.jsx +93 -13
- package/textarea/Textarea.test.js +360 -0
- package/textarea/types.d.ts +22 -15
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +23 -57
- package/toggle-group/ToggleGroup.stories.tsx +46 -4
- package/toggle-group/ToggleGroup.test.js +124 -0
- package/toggle-group/types.d.ts +19 -11
- package/translatedLabelsType.d.ts +82 -0
- package/translatedLabelsType.js +5 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +119 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1 -1
- package/useTheme.js +3 -9
- package/useTranslatedLabels.d.ts +3 -0
- package/useTranslatedLabels.js +15 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +68 -98
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +114 -0
- package/wizard/types.d.ts +12 -7
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/common/RequiredComponent.js +0 -32
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/list/List.d.ts +0 -8
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -11
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -239
- package/stack/Stack.d.ts +0 -10
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -166
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- /package/{radio → badge}/types.js +0 -0
package/checkbox/Checkbox.js
CHANGED
|
@@ -1,196 +1,164 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
|
-
var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
|
|
23
|
-
|
|
24
|
-
var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
|
|
25
|
-
|
|
26
|
-
var _variables = require("../common/variables.js");
|
|
27
|
-
|
|
14
|
+
var _variables = require("../common/variables");
|
|
28
15
|
var _utils = require("../common/utils.js");
|
|
29
|
-
|
|
16
|
+
var _uuid = require("uuid");
|
|
30
17
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
31
|
-
|
|
18
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
32
19
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
33
|
-
|
|
34
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
35
|
-
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
36
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
-
|
|
38
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
var checkedIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
24
|
+
fill: "currentColor",
|
|
25
|
+
focusable: "false",
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
viewBox: "0 0 24 24"
|
|
28
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
29
|
+
d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
|
|
30
|
+
}));
|
|
31
|
+
var DxcCheckbox = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
41
32
|
var checked = _ref.checked,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
_ref$defaultChecked = _ref.defaultChecked,
|
|
34
|
+
defaultChecked = _ref$defaultChecked === void 0 ? false : _ref$defaultChecked,
|
|
35
|
+
value = _ref.value,
|
|
36
|
+
_ref$label = _ref.label,
|
|
37
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
38
|
+
_ref$labelPosition = _ref.labelPosition,
|
|
39
|
+
labelPosition = _ref$labelPosition === void 0 ? "before" : _ref$labelPosition,
|
|
40
|
+
_ref$name = _ref.name,
|
|
41
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
42
|
+
_ref$disabled = _ref.disabled,
|
|
43
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
44
|
+
_ref$optional = _ref.optional,
|
|
45
|
+
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
46
|
+
onChange = _ref.onChange,
|
|
47
|
+
margin = _ref.margin,
|
|
48
|
+
_ref$size = _ref.size,
|
|
49
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
50
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
51
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
52
|
+
var _useState = (0, _react.useState)("label-checkbox-".concat((0, _uuid.v4)())),
|
|
53
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
54
|
+
labelId = _useState2[0];
|
|
55
|
+
var _useState3 = (0, _react.useState)(defaultChecked),
|
|
56
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
57
|
+
innerChecked = _useState4[0],
|
|
58
|
+
setInnerChecked = _useState4[1];
|
|
59
|
+
var checkboxRef = (0, _react.useRef)(null);
|
|
70
60
|
var colorsTheme = (0, _useTheme["default"])();
|
|
71
61
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
if (typeof onChange === "function") {
|
|
83
|
-
onChange(!checked);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
62
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
63
|
+
var handleCheckboxChange = function handleCheckboxChange() {
|
|
64
|
+
var _checkboxRef$current;
|
|
65
|
+
document.activeElement !== (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) && (checkboxRef === null || checkboxRef === void 0 ? void 0 : (_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 ? void 0 : _checkboxRef$current.focus());
|
|
66
|
+
var newChecked = checked !== null && checked !== void 0 ? checked : innerChecked;
|
|
67
|
+
checked !== null && checked !== void 0 ? checked : setInnerChecked(function (innerChecked) {
|
|
68
|
+
return !innerChecked;
|
|
69
|
+
});
|
|
70
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(!newChecked);
|
|
86
71
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
72
|
+
var handleKeyboard = function handleKeyboard(event) {
|
|
73
|
+
switch (event.key) {
|
|
74
|
+
case " ":
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
handleCheckboxChange();
|
|
77
|
+
}
|
|
90
78
|
};
|
|
91
|
-
|
|
92
79
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
93
|
-
theme: colorsTheme
|
|
94
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
95
|
-
id: name,
|
|
96
|
-
brightness: _variables.componentTokens,
|
|
97
|
-
label: label,
|
|
98
|
-
labelPosition: labelPosition,
|
|
80
|
+
theme: colorsTheme["checkbox"]
|
|
81
|
+
}, /*#__PURE__*/_react["default"].createElement(MainContainer, {
|
|
99
82
|
disabled: disabled,
|
|
83
|
+
onClick: disabled ? undefined : handleCheckboxChange,
|
|
100
84
|
margin: margin,
|
|
101
85
|
size: size,
|
|
86
|
+
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
102
87
|
backgroundType: backgroundType,
|
|
103
|
-
|
|
104
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
105
|
-
|
|
106
|
-
inputProps: {
|
|
107
|
-
name: name,
|
|
108
|
-
"aria-label": label,
|
|
109
|
-
role: "checkbox",
|
|
110
|
-
"aria-checked": checked != undefined ? checked : innerChecked
|
|
111
|
-
},
|
|
112
|
-
onChange: handlerCheckboxChange,
|
|
113
|
-
value: value,
|
|
88
|
+
ref: ref
|
|
89
|
+
}, label && labelPosition === "before" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
90
|
+
id: labelId,
|
|
114
91
|
disabled: disabled,
|
|
115
|
-
disableRipple: true,
|
|
116
|
-
className: "test",
|
|
117
|
-
tabIndex: tabIndex
|
|
118
|
-
}), /*#__PURE__*/_react["default"].createElement(CheckboxBlackBack, {
|
|
119
|
-
labelPosition: labelPosition,
|
|
120
|
-
disabled: disabled,
|
|
121
|
-
checked: checked != undefined ? checked : innerChecked,
|
|
122
92
|
backgroundType: backgroundType
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
93
|
+
}, label, optional && " ".concat(translatedLabels.formFields.optionalLabel)), /*#__PURE__*/_react["default"].createElement(ValueInput, {
|
|
94
|
+
type: "checkbox",
|
|
95
|
+
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
96
|
+
name: name,
|
|
97
|
+
"aria-hidden": "true",
|
|
98
|
+
value: value,
|
|
126
99
|
disabled: disabled,
|
|
127
|
-
|
|
100
|
+
readOnly: true
|
|
101
|
+
}), /*#__PURE__*/_react["default"].createElement(CheckboxContainer, null, /*#__PURE__*/_react["default"].createElement(Checkbox, {
|
|
102
|
+
onKeyDown: handleKeyboard,
|
|
103
|
+
role: "checkbox",
|
|
104
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
105
|
+
"aria-checked": checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
106
|
+
"aria-disabled": disabled,
|
|
107
|
+
"aria-required": !disabled && !optional,
|
|
108
|
+
"aria-labelledby": labelId,
|
|
128
109
|
backgroundType: backgroundType,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
110
|
+
checked: checked !== null && checked !== void 0 ? checked : innerChecked,
|
|
111
|
+
disabled: disabled,
|
|
112
|
+
ref: checkboxRef
|
|
113
|
+
}, (checked !== null && checked !== void 0 ? checked : innerChecked) && checkedIcon)), label && labelPosition === "after" && /*#__PURE__*/_react["default"].createElement(LabelContainer, {
|
|
114
|
+
id: labelId,
|
|
115
|
+
disabled: disabled,
|
|
116
|
+
backgroundType: backgroundType
|
|
117
|
+
}, optional && "".concat(translatedLabels.formFields.optionalLabel, " "), label)));
|
|
118
|
+
});
|
|
134
119
|
var sizes = {
|
|
135
120
|
small: "120px",
|
|
136
121
|
medium: "240px",
|
|
137
122
|
large: "480px",
|
|
138
123
|
fillParent: "100%",
|
|
139
|
-
fitContent: "
|
|
124
|
+
fitContent: "fit-content"
|
|
140
125
|
};
|
|
141
|
-
|
|
142
126
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
143
127
|
if (size === "fillParent") {
|
|
144
128
|
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
145
129
|
}
|
|
146
|
-
|
|
147
130
|
return sizes[size];
|
|
148
131
|
};
|
|
149
|
-
|
|
150
132
|
var getDisabledColor = function getDisabledColor(props, element) {
|
|
151
133
|
switch (element) {
|
|
152
134
|
case "check":
|
|
153
135
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledCheckColorOnDark : props.theme.disabledCheckColor;
|
|
154
|
-
break;
|
|
155
|
-
|
|
156
136
|
case "background":
|
|
157
137
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBackgroundColorCheckedOnDark : props.theme.disabledBackgroundColorChecked;
|
|
158
|
-
break;
|
|
159
|
-
|
|
160
138
|
case "border":
|
|
161
139
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;
|
|
162
|
-
break;
|
|
163
|
-
|
|
164
140
|
case "label":
|
|
165
141
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledFontColorOnDark : props.theme.disabledFontColor;
|
|
166
|
-
break;
|
|
167
142
|
}
|
|
168
143
|
};
|
|
169
|
-
|
|
170
|
-
var getNotDisabledColor = function getNotDisabledColor(props, element) {
|
|
144
|
+
var getEnabledColor = function getEnabledColor(props, element) {
|
|
171
145
|
switch (element) {
|
|
172
146
|
case "check":
|
|
173
147
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.checkColorOnDark : props.theme.checkColor;
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
148
|
case "background":
|
|
177
149
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.backgroundColorCheckedOnDark : props.theme.backgroundColorChecked;
|
|
178
|
-
|
|
179
|
-
|
|
150
|
+
case "hoverBackground":
|
|
151
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
|
|
180
152
|
case "border":
|
|
181
153
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.borderColorOnDark : props.theme.borderColor;
|
|
182
|
-
|
|
183
|
-
|
|
154
|
+
case "hoverBorder":
|
|
155
|
+
return props.backgroundType && props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
|
|
184
156
|
case "label":
|
|
185
157
|
return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
|
|
186
|
-
break;
|
|
187
158
|
}
|
|
188
159
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
|
|
192
|
-
}, function (props) {
|
|
193
|
-
return props.disabled ? "not-allowed" : "pointer";
|
|
160
|
+
var LabelContainer = _styledComponents["default"].span(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
161
|
+
return props.disabled ? getDisabledColor(props, "label") : getEnabledColor(props, "label");
|
|
194
162
|
}, function (props) {
|
|
195
163
|
return props.theme.fontFamily;
|
|
196
164
|
}, function (props) {
|
|
@@ -198,56 +166,41 @@ var LabelContainer = _styledComponents["default"].span(_templateObject || (_temp
|
|
|
198
166
|
}, function (props) {
|
|
199
167
|
return props.theme.fontWeight;
|
|
200
168
|
});
|
|
201
|
-
|
|
202
|
-
var CheckboxContainer = _styledComponents["default"].span(
|
|
203
|
-
|
|
169
|
+
var ValueInput = _styledComponents["default"].input(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: none;\n"])));
|
|
170
|
+
var CheckboxContainer = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 24px;\n width: 24px;\n"])));
|
|
171
|
+
var Checkbox = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 18px;\n width: 18px;\n border: 2px solid\n ", ";\n border-radius: 2px;\n background-color: ", ";\n color: ", ";\n\n &:focus {\n outline: 2px solid\n ", ";\n outline-offset: 2px;\n }\n svg {\n position: absolute;\n width: 22px;\n height: 22px;\n }\n ", "\n"])), function (props) {
|
|
172
|
+
return props.disabled ? getDisabledColor(props, "border") : getEnabledColor(props, "border");
|
|
204
173
|
}, function (props) {
|
|
205
|
-
return props.
|
|
174
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getEnabledColor(props, "check") : "transparent";
|
|
206
175
|
}, function (props) {
|
|
207
|
-
return props.
|
|
176
|
+
return props.disabled ? getDisabledColor(props, "background") : getEnabledColor(props, "background");
|
|
208
177
|
}, function (props) {
|
|
209
|
-
return props.
|
|
178
|
+
return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
|
|
210
179
|
}, function (props) {
|
|
211
|
-
return props.
|
|
180
|
+
return props.disabled && "pointer-events: none;";
|
|
181
|
+
});
|
|
182
|
+
var MainContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n align-items: center;\n gap: ", ";\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n cursor: ", ";\n\n &:hover ", " {\n border: 2px solid\n ", ";\n background-color: ", ";\n color: ", ";\n }\n"])), function (props) {
|
|
183
|
+
return props.theme.checkLabelSpacing;
|
|
212
184
|
}, function (props) {
|
|
213
185
|
return calculateWidth(props.margin, props.size);
|
|
214
186
|
}, function (props) {
|
|
215
|
-
return props.
|
|
216
|
-
}, function (props) {
|
|
217
|
-
return props.labelPosition === "before" ? "row-reverse" : "row";
|
|
218
|
-
}, function (props) {
|
|
219
|
-
return props.isLabelHovered ? props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor : getNotDisabledColor(props, "border");
|
|
220
|
-
}, function (props) {
|
|
221
|
-
return getDisabledColor(props, "border");
|
|
222
|
-
}, function (props) {
|
|
223
|
-
return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
|
|
224
|
-
}, function (props) {
|
|
225
|
-
return props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
|
|
226
|
-
}, function (props) {
|
|
227
|
-
return props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
|
|
228
|
-
}, function (props) {
|
|
229
|
-
return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
|
|
230
|
-
}, function (props) {
|
|
231
|
-
return props.labelPosition === "before" && props.label ? props.theme.checkLabelSpacing : "0";
|
|
187
|
+
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
232
188
|
}, function (props) {
|
|
233
|
-
return props.
|
|
189
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
|
|
234
190
|
}, function (props) {
|
|
235
|
-
return props.
|
|
191
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
|
|
236
192
|
}, function (props) {
|
|
237
|
-
return props.
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
var CheckboxBlackBack = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n background-color: ", ";\n width: 16px;\n height: 16px;\n position: absolute;\n left: ", ";\n right: ", ";\n z-index: 0;\n margin-left: ", ";\n margin-right: ", ";\n"])), function (props) {
|
|
241
|
-
return !props.checked ? "transparent" : props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check");
|
|
193
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
|
|
242
194
|
}, function (props) {
|
|
243
|
-
return props.
|
|
195
|
+
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
244
196
|
}, function (props) {
|
|
245
|
-
return props.
|
|
197
|
+
return props.disabled ? "not-allowed" : "pointer";
|
|
198
|
+
}, Checkbox, function (props) {
|
|
199
|
+
return props.disabled ? getDisabledColor(props, "border") : getEnabledColor(props, "hoverBorder");
|
|
246
200
|
}, function (props) {
|
|
247
|
-
return props.
|
|
201
|
+
return props.checked ? props.disabled ? getDisabledColor(props, "check") : getEnabledColor(props, "check") : "transparent";
|
|
248
202
|
}, function (props) {
|
|
249
|
-
return props.
|
|
203
|
+
return props.disabled ? getDisabledColor(props, "background") : getEnabledColor(props, "hoverBackground");
|
|
250
204
|
});
|
|
251
|
-
|
|
252
205
|
var _default = DxcCheckbox;
|
|
253
206
|
exports["default"] = _default;
|