@dxc-technology/halstack-react 0.0.0-2d619b4 → 0.0.0-2e14697

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.
Files changed (190) hide show
  1. package/README.md +27 -47
  2. package/dist/index.d.mts +3861 -0
  3. package/dist/index.d.ts +3861 -0
  4. package/dist/index.js +13814 -0
  5. package/dist/index.mjs +13727 -0
  6. package/package.json +93 -68
  7. package/babel.config.js +0 -8
  8. package/dist/BackgroundColorContext.js +0 -46
  9. package/dist/ThemeContext.js +0 -240
  10. package/dist/accordion/Accordion.js +0 -353
  11. package/dist/accordion-group/AccordionGroup.js +0 -186
  12. package/dist/alert/Alert.js +0 -403
  13. package/dist/alert/index.d.ts +0 -51
  14. package/dist/badge/Badge.js +0 -63
  15. package/dist/box/Box.js +0 -156
  16. package/dist/button/Button.js +0 -238
  17. package/dist/card/Card.js +0 -254
  18. package/dist/checkbox/Checkbox.js +0 -300
  19. package/dist/checkbox/Checkbox.stories.js +0 -144
  20. package/dist/checkbox/readme.md +0 -116
  21. package/dist/chip/Chip.js +0 -265
  22. package/dist/common/OpenSans.css +0 -81
  23. package/dist/common/RequiredComponent.js +0 -40
  24. package/dist/common/fonts/OpenSans-Bold.ttf +0 -0
  25. package/dist/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  26. package/dist/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  27. package/dist/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  28. package/dist/common/fonts/OpenSans-Italic.ttf +0 -0
  29. package/dist/common/fonts/OpenSans-Light.ttf +0 -0
  30. package/dist/common/fonts/OpenSans-LightItalic.ttf +0 -0
  31. package/dist/common/fonts/OpenSans-Regular.ttf +0 -0
  32. package/dist/common/fonts/OpenSans-SemiBold.ttf +0 -0
  33. package/dist/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  34. package/dist/common/utils.js +0 -22
  35. package/dist/common/variables.js +0 -1434
  36. package/dist/date/Date.js +0 -379
  37. package/dist/date/Date.stories.js +0 -205
  38. package/dist/date/readme.md +0 -73
  39. package/dist/dialog/Dialog.js +0 -218
  40. package/dist/dropdown/Dropdown.js +0 -544
  41. package/dist/file-input/FileInput.js +0 -641
  42. package/dist/file-input/FileItem.js +0 -263
  43. package/dist/footer/Footer.js +0 -395
  44. package/dist/footer/Footer.stories.js +0 -94
  45. package/dist/footer/dxc_logo.svg +0 -15
  46. package/dist/footer/readme.md +0 -41
  47. package/dist/header/Header.js +0 -403
  48. package/dist/header/Header.stories.js +0 -176
  49. package/dist/header/close_icon.svg +0 -1
  50. package/dist/header/dxc_logo_black.svg +0 -8
  51. package/dist/header/hamb_menu_black.svg +0 -1
  52. package/dist/header/hamb_menu_white.svg +0 -1
  53. package/dist/header/readme.md +0 -33
  54. package/dist/heading/Heading.js +0 -218
  55. package/dist/input-text/InputText.js +0 -707
  56. package/dist/input-text/InputText.stories.js +0 -209
  57. package/dist/input-text/error.svg +0 -1
  58. package/dist/input-text/readme.md +0 -91
  59. package/dist/layout/ApplicationLayout.js +0 -331
  60. package/dist/layout/facebook.svg +0 -45
  61. package/dist/layout/linkedin.svg +0 -50
  62. package/dist/layout/twitter.svg +0 -53
  63. package/dist/link/Link.js +0 -237
  64. package/dist/link/readme.md +0 -51
  65. package/dist/main.d.ts +0 -6
  66. package/dist/main.js +0 -359
  67. package/dist/new-date/NewDate.js +0 -400
  68. package/dist/new-date/index.d.ts +0 -86
  69. package/dist/new-input-text/NewInputText.js +0 -977
  70. package/dist/new-input-text/index.d.ts +0 -120
  71. package/dist/new-textarea/NewTextarea.js +0 -365
  72. package/dist/new-textarea/index.d.ts +0 -101
  73. package/dist/number/Number.js +0 -138
  74. package/dist/number/NumberContext.js +0 -16
  75. package/dist/number/index.d.ts +0 -95
  76. package/dist/paginator/Paginator.js +0 -289
  77. package/dist/paginator/images/next.svg +0 -3
  78. package/dist/paginator/images/nextPage.svg +0 -3
  79. package/dist/paginator/images/previous.svg +0 -3
  80. package/dist/paginator/images/previousPage.svg +0 -3
  81. package/dist/paginator/readme.md +0 -50
  82. package/dist/password/Password.js +0 -200
  83. package/dist/password/index.d.ts +0 -80
  84. package/dist/password/styles.css +0 -3
  85. package/dist/progress-bar/ProgressBar.js +0 -242
  86. package/dist/progress-bar/ProgressBar.stories.js +0 -280
  87. package/dist/progress-bar/readme.md +0 -63
  88. package/dist/radio/Radio.js +0 -209
  89. package/dist/radio/Radio.stories.js +0 -166
  90. package/dist/radio/readme.md +0 -70
  91. package/dist/resultsetTable/ResultsetTable.js +0 -358
  92. package/dist/resultsetTable/arrow_downward-24px_wht.svg +0 -1
  93. package/dist/resultsetTable/arrow_upward-24px_wht.svg +0 -1
  94. package/dist/resultsetTable/unfold_more-24px_wht.svg +0 -1
  95. package/dist/select/Select.js +0 -549
  96. package/dist/sidenav/Sidenav.js +0 -179
  97. package/dist/slider/Slider.js +0 -319
  98. package/dist/slider/Slider.stories.js +0 -241
  99. package/dist/slider/readme.md +0 -64
  100. package/dist/spinner/Spinner.js +0 -381
  101. package/dist/spinner/Spinner.stories.js +0 -183
  102. package/dist/spinner/readme.md +0 -65
  103. package/dist/switch/Switch.js +0 -222
  104. package/dist/switch/Switch.stories.js +0 -134
  105. package/dist/switch/readme.md +0 -133
  106. package/dist/table/Table.js +0 -132
  107. package/dist/tabs/Tabs.js +0 -343
  108. package/dist/tabs/Tabs.stories.js +0 -130
  109. package/dist/tabs/readme.md +0 -78
  110. package/dist/tabs-for-sections/TabsForSections.js +0 -92
  111. package/dist/tabs-for-sections/readme.md +0 -78
  112. package/dist/tag/Tag.js +0 -282
  113. package/dist/textarea/Textarea.js +0 -264
  114. package/dist/toggle/Toggle.js +0 -220
  115. package/dist/toggle/Toggle.stories.js +0 -297
  116. package/dist/toggle/readme.md +0 -80
  117. package/dist/toggle-group/ToggleGroup.js +0 -223
  118. package/dist/upload/Upload.js +0 -205
  119. package/dist/upload/Upload.stories.js +0 -72
  120. package/dist/upload/buttons-upload/ButtonsUpload.js +0 -139
  121. package/dist/upload/buttons-upload/drag-drop-icon.svg +0 -4
  122. package/dist/upload/buttons-upload/upload-button.svg +0 -1
  123. package/dist/upload/dragAndDropArea/DragAndDropArea.js +0 -329
  124. package/dist/upload/dragAndDropArea/upload_drop.svg +0 -4
  125. package/dist/upload/dragAndDropArea/upload_file.svg +0 -4
  126. package/dist/upload/file-upload/FileToUpload.js +0 -184
  127. package/dist/upload/file-upload/audio-icon.svg +0 -4
  128. package/dist/upload/file-upload/close.svg +0 -4
  129. package/dist/upload/file-upload/file-icon.svg +0 -4
  130. package/dist/upload/file-upload/video-icon.svg +0 -4
  131. package/dist/upload/files-upload/FilesToUpload.js +0 -123
  132. package/dist/upload/readme.md +0 -37
  133. package/dist/upload/transaction/Transaction.js +0 -175
  134. package/dist/upload/transaction/audio-icon-err.svg +0 -4
  135. package/dist/upload/transaction/audio-icon.svg +0 -4
  136. package/dist/upload/transaction/error-icon.svg +0 -4
  137. package/dist/upload/transaction/file-icon-err.svg +0 -4
  138. package/dist/upload/transaction/file-icon.svg +0 -4
  139. package/dist/upload/transaction/image-icon-err.svg +0 -4
  140. package/dist/upload/transaction/image-icon.svg +0 -4
  141. package/dist/upload/transaction/success-icon.svg +0 -4
  142. package/dist/upload/transaction/video-icon-err.svg +0 -4
  143. package/dist/upload/transaction/video-icon.svg +0 -4
  144. package/dist/upload/transactions/Transactions.js +0 -138
  145. package/dist/useTheme.js +0 -22
  146. package/dist/wizard/Wizard.js +0 -411
  147. package/dist/wizard/invalid_icon.svg +0 -5
  148. package/dist/wizard/valid_icon.svg +0 -5
  149. package/dist/wizard/validation-wrong.svg +0 -6
  150. package/test/Accordion.test.js +0 -33
  151. package/test/AccordionGroup.test.js +0 -125
  152. package/test/Alert.test.js +0 -53
  153. package/test/Box.test.js +0 -10
  154. package/test/Button.test.js +0 -18
  155. package/test/Card.test.js +0 -30
  156. package/test/Checkbox.test.js +0 -45
  157. package/test/Chip.test.js +0 -25
  158. package/test/Date.test.js +0 -393
  159. package/test/Dialog.test.js +0 -23
  160. package/test/Dropdown.test.js +0 -145
  161. package/test/FileInput.test.js +0 -39
  162. package/test/Footer.test.js +0 -99
  163. package/test/Header.test.js +0 -39
  164. package/test/Heading.test.js +0 -35
  165. package/test/InputText.test.js +0 -240
  166. package/test/Link.test.js +0 -43
  167. package/test/NewDate.test.js +0 -203
  168. package/test/NewInputText.test.js +0 -866
  169. package/test/NewTextarea.test.js +0 -252
  170. package/test/Number.test.js +0 -241
  171. package/test/Paginator.test.js +0 -177
  172. package/test/Password.test.js +0 -76
  173. package/test/ProgressBar.test.js +0 -35
  174. package/test/Radio.test.js +0 -37
  175. package/test/ResultsetTable.test.js +0 -329
  176. package/test/Select.test.js +0 -212
  177. package/test/Sidenav.test.js +0 -45
  178. package/test/Slider.test.js +0 -82
  179. package/test/Spinner.test.js +0 -32
  180. package/test/Switch.test.js +0 -45
  181. package/test/Table.test.js +0 -36
  182. package/test/Tabs.test.js +0 -109
  183. package/test/TabsForSections.test.js +0 -34
  184. package/test/Tag.test.js +0 -32
  185. package/test/TextArea.test.js +0 -52
  186. package/test/ToggleGroup.test.js +0 -81
  187. package/test/Upload.test.js +0 -60
  188. package/test/Wizard.test.js +0 -130
  189. package/test/mocks/pngMock.js +0 -1
  190. package/test/mocks/svgMock.js +0 -1
@@ -1,300 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
-
5
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports["default"] = void 0;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
-
16
- var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
17
-
18
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
-
20
- var _react = _interopRequireWildcard(require("react"));
21
-
22
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
23
-
24
- var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
25
-
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _RequiredComponent = _interopRequireDefault(require("../common/RequiredComponent"));
29
-
30
- var _variables = require("../common/variables.js");
31
-
32
- var _utils = require("../common/utils.js");
33
-
34
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
35
-
36
- var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext.js"));
37
-
38
- function _templateObject3() {
39
- var data = (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"]);
40
-
41
- _templateObject3 = function _templateObject3() {
42
- return data;
43
- };
44
-
45
- return data;
46
- }
47
-
48
- function _templateObject2() {
49
- var data = (0, _taggedTemplateLiteral2["default"])(["\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n width: ", ";\n display: inline-flex;\n align-items: center;\n cursor: ", ";\n position: relative;\n flex-direction: ", ";\n .MuiCheckbox-colorSecondary {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n &.Mui-disabled {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n opacity: 0.34;\n }\n }\n }\n &.Mui-checked {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n\n &:hover {\n background-color: transparent;\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n background-color: transparent;\n color: ", ";\n }\n }\n }\n }\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n width: 24px;\n height: 24px;\n }\n }\n }\n\n .MuiIconButton-colorSecondary {\n &:hover {\n background-color: transparent;\n }\n }\n .MuiButtonBase-root {\n &:hover {\n .MuiIconButton-label {\n & > .MuiSvgIcon-root {\n color: ", ";\n }\n }\n }\n\n &.Mui-focusVisible {\n .MuiIconButton-label {\n box-shadow: 0 0 0 2px\n ", ";\n }\n }\n z-index: 1;\n margin: ", ";\n margin-left: ", ";\n margin-right: ", ";\n padding: 0px;\n left: ", ";\n right: ", ";\n }\n"]);
50
-
51
- _templateObject2 = function _templateObject2() {
52
- return data;
53
- };
54
-
55
- return data;
56
- }
57
-
58
- function _templateObject() {
59
- var data = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n cursor: ", ";\n font-family: ", ";\n font-size: ", ";\n font-weight: ", ";\n"]);
60
-
61
- _templateObject = function _templateObject() {
62
- return data;
63
- };
64
-
65
- return data;
66
- }
67
-
68
- var DxcCheckbox = function DxcCheckbox(_ref) {
69
- var checked = _ref.checked,
70
- value = _ref.value,
71
- _ref$label = _ref.label,
72
- label = _ref$label === void 0 ? "" : _ref$label,
73
- _ref$labelPosition = _ref.labelPosition,
74
- labelPosition = _ref$labelPosition === void 0 ? "before" : _ref$labelPosition,
75
- _ref$name = _ref.name,
76
- name = _ref$name === void 0 ? "" : _ref$name,
77
- _ref$disabled = _ref.disabled,
78
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
79
- onChange = _ref.onChange,
80
- _ref$required = _ref.required,
81
- required = _ref$required === void 0 ? false : _ref$required,
82
- margin = _ref.margin,
83
- _ref$size = _ref.size,
84
- size = _ref$size === void 0 ? "fitContent" : _ref$size,
85
- _ref$tabIndex = _ref.tabIndex,
86
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
87
-
88
- var _useState = (0, _react.useState)(false),
89
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
90
- innerChecked = _useState2[0],
91
- setInnerChecked = _useState2[1];
92
-
93
- var _useState3 = (0, _react.useState)(false),
94
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
95
- isLabelHovered = _useState4[0],
96
- setIsLabelHovered = _useState4[1];
97
-
98
- var colorsTheme = (0, _useTheme["default"])();
99
- var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
100
-
101
- var handlerCheckboxChange = function handlerCheckboxChange(checkboxValue) {
102
- if (checked === undefined) {
103
- var isChecked = checkboxValue.target.checked === undefined ? !innerChecked : checkboxValue.target.checked;
104
- setInnerChecked(isChecked);
105
-
106
- if (typeof onChange === "function") {
107
- onChange(isChecked);
108
- }
109
- } else {
110
- if (typeof onChange === "function") {
111
- onChange(!checked);
112
- }
113
- }
114
- };
115
-
116
- var handleLabelHover = function handleLabelHover() {
117
- setIsLabelHovered(!isLabelHovered);
118
- };
119
-
120
- return _react["default"].createElement(_styledComponents.ThemeProvider, {
121
- theme: colorsTheme.checkbox
122
- }, _react["default"].createElement(CheckboxContainer, {
123
- id: name,
124
- brightness: _variables.componentTokens,
125
- labelPosition: labelPosition,
126
- disabled: disabled,
127
- margin: margin,
128
- size: size,
129
- backgroundType: backgroundType,
130
- isLabelHovered: isLabelHovered
131
- }, _react["default"].createElement(_Checkbox["default"], {
132
- checked: checked != undefined ? checked : innerChecked,
133
- inputProps: {
134
- name: name,
135
- "aria-label": label,
136
- role: "checkbox",
137
- "aria-checked": checked != undefined ? checked : innerChecked
138
- },
139
- onChange: handlerCheckboxChange,
140
- value: value,
141
- disabled: disabled,
142
- disableRipple: true,
143
- className: "test",
144
- tabIndex: tabIndex
145
- }), _react["default"].createElement(CheckboxBlackBack, {
146
- labelPosition: labelPosition,
147
- disabled: disabled,
148
- checked: checked != undefined ? checked : innerChecked,
149
- backgroundType: backgroundType
150
- }), required && _react["default"].createElement(_RequiredComponent["default"], null), label && _react["default"].createElement(LabelContainer, {
151
- labelPosition: labelPosition,
152
- onClick: disabled === true ? function (e) {} : handlerCheckboxChange,
153
- disabled: disabled,
154
- className: "labelContainer",
155
- backgroundType: backgroundType,
156
- onMouseOver: handleLabelHover,
157
- onMouseOut: handleLabelHover
158
- }, label)));
159
- };
160
-
161
- var sizes = {
162
- small: "120px",
163
- medium: "240px",
164
- large: "480px",
165
- fillParent: "100%",
166
- fitContent: "unset"
167
- };
168
-
169
- var calculateWidth = function calculateWidth(margin, size) {
170
- if (size === "fillParent") {
171
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
172
- }
173
-
174
- return sizes[size];
175
- };
176
-
177
- var getDisabledColor = function getDisabledColor(props, element) {
178
- switch (element) {
179
- case "check":
180
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledCheckColorOnDark : props.theme.disabledCheckColor;
181
- break;
182
-
183
- case "background":
184
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBackgroundColorCheckedOnDark : props.theme.disabledBackgroundColorChecked;
185
- break;
186
-
187
- case "border":
188
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;
189
- break;
190
-
191
- case "label":
192
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.disabledFontColorOnDark : props.theme.disabledFontColor;
193
- break;
194
- }
195
- };
196
-
197
- var getNotDisabledColor = function getNotDisabledColor(props, element) {
198
- switch (element) {
199
- case "check":
200
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.checkColorOnDark : props.theme.checkColor;
201
- break;
202
-
203
- case "background":
204
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.backgroundColorCheckedOnDark : props.theme.backgroundColorChecked;
205
- break;
206
-
207
- case "border":
208
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.borderColorOnDark : props.theme.borderColor;
209
- break;
210
-
211
- case "label":
212
- return props.backgroundType && props.backgroundType === "dark" ? props.theme.fontColorOnDark : props.theme.fontColor;
213
- break;
214
- }
215
- };
216
-
217
- var LabelContainer = _styledComponents["default"].span(_templateObject(), function (props) {
218
- return props.disabled ? getDisabledColor(props, "label") : getNotDisabledColor(props, "label");
219
- }, function (props) {
220
- return props.disabled ? "not-allowed" : "pointer";
221
- }, function (props) {
222
- return props.theme.fontFamily;
223
- }, function (props) {
224
- return props.theme.fontSize;
225
- }, function (props) {
226
- return props.theme.fontWeight;
227
- });
228
-
229
- var CheckboxContainer = _styledComponents["default"].span(_templateObject2(), function (props) {
230
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
231
- }, function (props) {
232
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
233
- }, function (props) {
234
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
235
- }, function (props) {
236
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
237
- }, function (props) {
238
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
239
- }, function (props) {
240
- return calculateWidth(props.margin, props.size);
241
- }, function (props) {
242
- return props.disabled ? "not-allowed" : "pointer";
243
- }, function (props) {
244
- return props.labelPosition === "before" ? "row-reverse" : "row";
245
- }, function (props) {
246
- return props.isLabelHovered ? props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor : getNotDisabledColor(props, "border");
247
- }, function (props) {
248
- return getDisabledColor(props, "border");
249
- }, function (props) {
250
- return props.disabled ? getDisabledColor(props, "background") : getNotDisabledColor(props, "background");
251
- }, function (props) {
252
- return props.backgroundType === "dark" ? props.theme.hoverBackgroundColorCheckedOnDark : props.theme.hoverBackgroundColorChecked;
253
- }, function (props) {
254
- return props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor;
255
- }, function (props) {
256
- return props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor;
257
- }, function (props) {
258
- return props.theme.checkLabelSpacing;
259
- }, function (props) {
260
- return props.labelPosition === "after" ? "0px" : "";
261
- }, function (props) {
262
- return props.labelPosition === "before" ? "0px" : "";
263
- }, function (props) {
264
- return props.labelPosition === "before" ? "unset" : "1px";
265
- }, function (props) {
266
- return props.labelPosition === "before" ? "1px" : "unset";
267
- });
268
-
269
- var CheckboxBlackBack = _styledComponents["default"].span(_templateObject3(), function (props) {
270
- return !props.checked ? "transparent" : props.disabled ? getDisabledColor(props, "check") : getNotDisabledColor(props, "check");
271
- }, function (props) {
272
- return props.labelPosition === "before" ? "unset" : "5px";
273
- }, function (props) {
274
- return props.labelPosition === "before" ? "5px" : "unset";
275
- }, function (props) {
276
- return props.labelPosition === "after" ? "0px" : "";
277
- }, function (props) {
278
- return props.labelPosition === "before" ? "0px" : "";
279
- });
280
-
281
- DxcCheckbox.propTypes = {
282
- checked: _propTypes["default"].bool,
283
- value: _propTypes["default"].any,
284
- label: _propTypes["default"].string,
285
- labelPosition: _propTypes["default"].oneOf(["after", "before", ""]),
286
- name: _propTypes["default"].string,
287
- disabled: _propTypes["default"].bool,
288
- onChange: _propTypes["default"].func,
289
- required: _propTypes["default"].bool,
290
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
291
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
292
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
293
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
294
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
295
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
296
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
297
- tabIndex: _propTypes["default"].number
298
- };
299
- var _default = DxcCheckbox;
300
- exports["default"] = _default;
@@ -1,144 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
6
-
7
- var _react = _interopRequireDefault(require("react"));
8
-
9
- var _react2 = require("@storybook/react");
10
-
11
- var _addonActions = require("@storybook/addon-actions");
12
-
13
- var _addonKnobs = require("@storybook/addon-knobs");
14
-
15
- var _readme = _interopRequireDefault(require("./readme.md"));
16
-
17
- var _Checkbox = _interopRequireDefault(require("./Checkbox"));
18
-
19
- var onChange = (0, _addonActions.action)("onChange");
20
-
21
- onChange.toString = function () {
22
- return "onChangeHandler";
23
- };
24
-
25
- (0, _react2.storiesOf)("Form Components|Checkbox", module).add("Component", function () {
26
- return _react["default"].createElement("div", null, _react["default"].createElement("h3", null, "Light"), _react["default"].createElement("div", null, _react["default"].createElement(_Checkbox["default"], {
27
- checked: false,
28
- theme: "light",
29
- value: "TestValue",
30
- label: "Checkbox",
31
- labelPosition: "after",
32
- onChange: onChange
33
- }), _react["default"].createElement(_Checkbox["default"], {
34
- checked: false,
35
- theme: "light",
36
- value: "TestValue",
37
- label: "Label before",
38
- labelPosition: "before",
39
- onChange: onChange
40
- }), _react["default"].createElement(_Checkbox["default"], {
41
- checked: false,
42
- theme: "light",
43
- value: "TestValue",
44
- label: "Label after",
45
- labelPosition: "after",
46
- onChange: onChange,
47
- required: true
48
- }), _react["default"].createElement(_Checkbox["default"], {
49
- checked: false,
50
- disabled: true,
51
- theme: "light",
52
- value: "TestValue",
53
- label: "Disabled unchecked",
54
- labelPosition: "after",
55
- onChange: onChange
56
- }), _react["default"].createElement(_Checkbox["default"], {
57
- checked: true,
58
- disabled: true,
59
- theme: "light",
60
- value: "TestValue",
61
- label: "Disabled checked",
62
- labelPosition: "after",
63
- onChange: onChange
64
- })), _react["default"].createElement("h3", null, "Dark"), _react["default"].createElement("div", {
65
- style: {
66
- background: "black"
67
- }
68
- }, _react["default"].createElement("div", null, _react["default"].createElement(_Checkbox["default"], {
69
- checked: false,
70
- theme: "dark",
71
- value: "TestValue",
72
- label: "Checkbox",
73
- labelPosition: "after",
74
- onChange: onChange,
75
- required: true
76
- }), _react["default"].createElement(_Checkbox["default"], {
77
- checked: false,
78
- theme: "dark",
79
- value: "TestValue",
80
- label: "Label before",
81
- labelPosition: "before",
82
- onChange: onChange
83
- }), _react["default"].createElement(_Checkbox["default"], {
84
- checked: false,
85
- theme: "dark",
86
- value: "TestValue",
87
- label: "Label after",
88
- labelPosition: "after",
89
- onChange: onChange
90
- }), _react["default"].createElement(_Checkbox["default"], {
91
- checked: false,
92
- disabled: true,
93
- theme: "dark",
94
- value: "TestValue",
95
- label: "Disabled unchecked",
96
- labelPosition: "after",
97
- onChange: onChange
98
- }), _react["default"].createElement(_Checkbox["default"], {
99
- checked: true,
100
- disabled: true,
101
- theme: "dark",
102
- value: "TestValue",
103
- label: "Disabled checked",
104
- labelPosition: "after",
105
- onChange: onChange
106
- }))));
107
- }, {
108
- notes: {
109
- markdown: _readme["default"]
110
- }
111
- });
112
-
113
- var knobProps = function knobProps() {
114
- return {
115
- label: (0, _addonKnobs.text)("Label", "Test Checkbox"),
116
- disabled: (0, _addonKnobs["boolean"])("Disabled", false),
117
- labelPosition: (0, _addonKnobs.select)("Label position", {
118
- before: "before",
119
- after: "after"
120
- }, "before"),
121
- theme: (0, _addonKnobs.select)("Theme", {
122
- light: "light",
123
- dark: "dark"
124
- }, "light"),
125
- disableRipple: (0, _addonKnobs["boolean"])("disableRipple", false),
126
- required: (0, _addonKnobs["boolean"])("Required", false)
127
- };
128
- };
129
-
130
- (0, _react2.storiesOf)("Form Components|Checkbox", module).add("Knobs example", function () {
131
- var props = knobProps();
132
- return _react["default"].createElement("div", {
133
- style: {
134
- background: props.theme === "dark" && "black" || "transparent"
135
- }
136
- }, _react["default"].createElement(_Checkbox["default"], (0, _extends2["default"])({}, props, {
137
- value: "TestValue",
138
- onChange: onChange
139
- })));
140
- }, {
141
- notes: {
142
- markdown: _readme["default"]
143
- }
144
- });
@@ -1,116 +0,0 @@
1
- # DXC Checkbox Component
2
-
3
- ## Usage
4
-
5
- ```js
6
- import { DxcCheckbox } from "@dxc-technology/halstack-react";
7
-
8
- <DxcCheckbox onChange={handleNewValue} label="Test Checkbox" checked={checked} />;
9
- ```
10
-
11
- ## Props
12
-
13
- <table>
14
- <tr style="background-color: grey">
15
- <td>Name</td>
16
- <td>Default</td>
17
- <td>Description</td>
18
- </tr>
19
- <tr>
20
- <td>checked: boolean</td>
21
- <td><code>false</code></td>
22
- <td>If true, the component is checked.</td>
23
- </tr>
24
- <tr>
25
- <td>value: any</td>
26
- <td></td>
27
- <td>Will be passed to the value attribute of the html input element. When inside a form, this value will be only submitted if the checkbox is checked </td>
28
- </tr>
29
- <tr>
30
- <td>label: string</td>
31
- <td></td>
32
- <td>Text to be placed next to the checkbox.</td>
33
- </tr>
34
- <tr>
35
- <td>labelPosition: 'before' | 'after'</td>
36
- <td><code>'before'</code></td>
37
- <td>Whether the label should appear after or before the checkbox.</td>
38
- </tr>
39
- <tr>
40
- <td>theme: 'light' | 'dark'</td>
41
- <td><code>'light'</code></td>
42
- <td>Uses one of the available component themes.</td>
43
- </tr>
44
- <tr>
45
- <td>name: string</td>
46
- <td></td>
47
- <td>Name attribute of the input element.</td>
48
- </tr>
49
- <tr>
50
- <td>disabled: boolean</td>
51
- <td><code>false</code></td>
52
- <td>If true, the component will be disabled.</td>
53
- </tr>
54
- <tr>
55
- <td>required: boolean</td>
56
- <td><code>false</code></td>
57
- <td>If true, a red asterisk will appear before the label to indicate to the user that the field is required.</td>
58
- </tr>
59
- <tr>
60
- <td>disableRipple: boolean</td>
61
- <td><code>false</code></td>
62
- <td>If true, the ripple effect will be disabled.</td>
63
- </tr>
64
- <tr>
65
- <td>onChange: function</td>
66
- <td></td>
67
- <td>This function will be called when the user clicks the checkbox. The new value will be passed as a parameter.<br>
68
- </td>
69
- </tr>
70
- </table>
71
-
72
- ## Examples
73
-
74
- - Basic checkbox - Light theme - Enabled - Label after checkbox - With ripple
75
-
76
- ```js
77
- import React from "react";
78
- import { DxcCheckbox } from "@dxc-technology/halstack-react";
79
-
80
- class App extends React.Component {
81
- state = {
82
- isChecked: true
83
- };
84
- constructor() {
85
- super();
86
- this.handleChange = this.handleChange.bind(this);
87
- }
88
-
89
- handleChange(checked) {
90
- this.setState({
91
- isChecked: checked
92
- });
93
- }
94
-
95
- render() {
96
- return (
97
- <div>
98
- <DxcCheckbox
99
- checked={this.state.isChecked}
100
- value="Checkbox1"
101
- label="Checkbox 1"
102
- labelPosition="after"
103
- theme="light"
104
- name="Checkbox"
105
- disabled={false}
106
- disableRipple={false}
107
- onChange={event => this.handleChange(event)}
108
- />
109
- </div>
110
- );
111
- }
112
- }
113
- export default App;
114
-
115
-
116
- ```