@dxc-technology/halstack-react 0.0.0-e1a279c → 0.0.0-e1c01f0

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 (200) hide show
  1. package/README.md +46 -0
  2. package/dist/index.d.mts +6670 -0
  3. package/dist/index.d.ts +6670 -0
  4. package/dist/index.js +14442 -0
  5. package/dist/index.mjs +14385 -0
  6. package/package.json +69 -68
  7. package/BackgroundColorContext.js +0 -50
  8. package/ThemeContext.js +0 -246
  9. package/V3Select/V3Select.js +0 -455
  10. package/V3Select/index.d.ts +0 -27
  11. package/V3Textarea/V3Textarea.js +0 -260
  12. package/V3Textarea/index.d.ts +0 -27
  13. package/accordion/Accordion.d.ts +0 -4
  14. package/accordion/Accordion.js +0 -258
  15. package/accordion/types.d.ts +0 -68
  16. package/accordion/types.js +0 -5
  17. package/accordion-group/AccordionGroup.d.ts +0 -7
  18. package/accordion-group/AccordionGroup.js +0 -170
  19. package/accordion-group/types.d.ts +0 -72
  20. package/accordion-group/types.js +0 -5
  21. package/alert/Alert.d.ts +0 -4
  22. package/alert/Alert.js +0 -290
  23. package/alert/Alert.stories.tsx +0 -170
  24. package/alert/types.d.ts +0 -49
  25. package/alert/types.js +0 -5
  26. package/badge/Badge.js +0 -59
  27. package/box/Box.d.ts +0 -4
  28. package/box/Box.js +0 -129
  29. package/box/Box.stories.tsx +0 -132
  30. package/box/types.d.ts +0 -47
  31. package/box/types.js +0 -5
  32. package/button/Button.d.ts +0 -4
  33. package/button/Button.js +0 -177
  34. package/button/Button.stories.tsx +0 -276
  35. package/button/types.d.ts +0 -57
  36. package/button/types.js +0 -5
  37. package/card/Card.d.ts +0 -4
  38. package/card/Card.js +0 -165
  39. package/card/types.d.ts +0 -69
  40. package/card/types.js +0 -5
  41. package/checkbox/Checkbox.d.ts +0 -4
  42. package/checkbox/Checkbox.js +0 -253
  43. package/checkbox/Checkbox.stories.tsx +0 -192
  44. package/checkbox/types.d.ts +0 -60
  45. package/checkbox/types.js +0 -5
  46. package/chip/Chip.js +0 -221
  47. package/chip/Chip.stories.tsx +0 -121
  48. package/chip/index.d.ts +0 -22
  49. package/common/OpenSans.css +0 -81
  50. package/common/RequiredComponent.js +0 -32
  51. package/common/fonts/OpenSans-Bold.ttf +0 -0
  52. package/common/fonts/OpenSans-BoldItalic.ttf +0 -0
  53. package/common/fonts/OpenSans-ExtraBold.ttf +0 -0
  54. package/common/fonts/OpenSans-ExtraBoldItalic.ttf +0 -0
  55. package/common/fonts/OpenSans-Italic.ttf +0 -0
  56. package/common/fonts/OpenSans-Light.ttf +0 -0
  57. package/common/fonts/OpenSans-LightItalic.ttf +0 -0
  58. package/common/fonts/OpenSans-Regular.ttf +0 -0
  59. package/common/fonts/OpenSans-SemiBold.ttf +0 -0
  60. package/common/fonts/OpenSans-SemiBoldItalic.ttf +0 -0
  61. package/common/utils.js +0 -22
  62. package/common/variables.js +0 -1577
  63. package/date/Date.js +0 -373
  64. package/date/index.d.ts +0 -27
  65. package/date-input/DateInput.d.ts +0 -4
  66. package/date-input/DateInput.js +0 -361
  67. package/date-input/DateInput.stories.tsx +0 -138
  68. package/date-input/types.d.ts +0 -100
  69. package/date-input/types.js +0 -5
  70. package/dialog/Dialog.d.ts +0 -4
  71. package/dialog/Dialog.js +0 -165
  72. package/dialog/Dialog.stories.tsx +0 -212
  73. package/dialog/types.d.ts +0 -43
  74. package/dialog/types.js +0 -5
  75. package/dropdown/Dropdown.d.ts +0 -4
  76. package/dropdown/Dropdown.js +0 -417
  77. package/dropdown/types.d.ts +0 -89
  78. package/dropdown/types.js +0 -5
  79. package/file-input/FileInput.js +0 -532
  80. package/file-input/FileItem.js +0 -193
  81. package/file-input/index.d.ts +0 -81
  82. package/footer/Footer.d.ts +0 -4
  83. package/footer/Footer.js +0 -266
  84. package/footer/Footer.stories.jsx +0 -151
  85. package/footer/Icons.js +0 -77
  86. package/footer/types.d.ts +0 -61
  87. package/footer/types.js +0 -5
  88. package/header/Header.d.ts +0 -7
  89. package/header/Header.js +0 -324
  90. package/header/Icons.js +0 -34
  91. package/header/types.d.ts +0 -45
  92. package/header/types.js +0 -5
  93. package/heading/Heading.js +0 -176
  94. package/heading/index.d.ts +0 -17
  95. package/input-text/Icons.js +0 -22
  96. package/input-text/InputText.js +0 -611
  97. package/input-text/index.d.ts +0 -36
  98. package/layout/ApplicationLayout.js +0 -235
  99. package/layout/Icons.js +0 -55
  100. package/link/Link.d.ts +0 -3
  101. package/link/Link.js +0 -161
  102. package/link/Link.stories.tsx +0 -70
  103. package/link/types.d.ts +0 -74
  104. package/link/types.js +0 -5
  105. package/main.d.ts +0 -44
  106. package/main.js +0 -363
  107. package/number-input/NumberInput.d.ts +0 -4
  108. package/number-input/NumberInput.js +0 -86
  109. package/number-input/NumberInput.stories.tsx +0 -115
  110. package/number-input/NumberInputContext.js +0 -16
  111. package/number-input/types.d.ts +0 -117
  112. package/number-input/types.js +0 -5
  113. package/paginator/Icons.js +0 -66
  114. package/paginator/Paginator.d.ts +0 -4
  115. package/paginator/Paginator.js +0 -198
  116. package/paginator/Paginator.stories.tsx +0 -63
  117. package/paginator/types.d.ts +0 -38
  118. package/paginator/types.js +0 -5
  119. package/password-input/PasswordInput.d.ts +0 -4
  120. package/password-input/PasswordInput.js +0 -162
  121. package/password-input/PasswordInput.stories.tsx +0 -131
  122. package/password-input/types.d.ts +0 -100
  123. package/password-input/types.js +0 -5
  124. package/progress-bar/ProgressBar.d.ts +0 -4
  125. package/progress-bar/ProgressBar.js +0 -170
  126. package/progress-bar/ProgressBar.stories.jsx +0 -58
  127. package/progress-bar/types.d.ts +0 -37
  128. package/progress-bar/types.js +0 -5
  129. package/radio/Radio.d.ts +0 -4
  130. package/radio/Radio.js +0 -174
  131. package/radio/Radio.stories.tsx +0 -192
  132. package/radio/types.d.ts +0 -54
  133. package/radio/types.js +0 -5
  134. package/resultsetTable/ResultsetTable.js +0 -274
  135. package/resultsetTable/index.d.ts +0 -19
  136. package/select/Select.js +0 -865
  137. package/select/Select.stories.tsx +0 -572
  138. package/select/index.d.ts +0 -131
  139. package/sidenav/Sidenav.d.ts +0 -9
  140. package/sidenav/Sidenav.js +0 -136
  141. package/sidenav/types.d.ts +0 -50
  142. package/sidenav/types.js +0 -5
  143. package/slider/Slider.d.ts +0 -4
  144. package/slider/Slider.js +0 -317
  145. package/slider/Slider.stories.tsx +0 -177
  146. package/slider/types.d.ts +0 -78
  147. package/slider/types.js +0 -5
  148. package/spinner/Spinner.d.ts +0 -4
  149. package/spinner/Spinner.js +0 -250
  150. package/spinner/Spinner.stories.jsx +0 -102
  151. package/spinner/types.d.ts +0 -32
  152. package/spinner/types.js +0 -5
  153. package/switch/Switch.d.ts +0 -4
  154. package/switch/Switch.js +0 -179
  155. package/switch/Switch.stories.tsx +0 -160
  156. package/switch/types.d.ts +0 -58
  157. package/switch/types.js +0 -5
  158. package/table/Table.d.ts +0 -4
  159. package/table/Table.js +0 -118
  160. package/table/Table.stories.jsx +0 -276
  161. package/table/types.d.ts +0 -21
  162. package/table/types.js +0 -5
  163. package/tabs/Tabs.d.ts +0 -4
  164. package/tabs/Tabs.js +0 -211
  165. package/tabs/types.d.ts +0 -71
  166. package/tabs/types.js +0 -5
  167. package/tag/Tag.d.ts +0 -4
  168. package/tag/Tag.js +0 -193
  169. package/tag/Tag.stories.tsx +0 -145
  170. package/tag/types.d.ts +0 -60
  171. package/tag/types.js +0 -5
  172. package/text-input/TextInput.js +0 -825
  173. package/text-input/index.d.ts +0 -135
  174. package/textarea/Textarea.js +0 -317
  175. package/textarea/Textarea.stories.jsx +0 -135
  176. package/textarea/index.d.ts +0 -117
  177. package/toggle/Toggle.js +0 -186
  178. package/toggle/index.d.ts +0 -21
  179. package/toggle-group/ToggleGroup.js +0 -243
  180. package/toggle-group/ToggleGroup.stories.tsx +0 -178
  181. package/toggle-group/index.d.ts +0 -21
  182. package/upload/Upload.js +0 -201
  183. package/upload/buttons-upload/ButtonsUpload.js +0 -111
  184. package/upload/buttons-upload/Icons.js +0 -40
  185. package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
  186. package/upload/dragAndDropArea/Icons.js +0 -39
  187. package/upload/file-upload/FileToUpload.js +0 -115
  188. package/upload/file-upload/Icons.js +0 -66
  189. package/upload/files-upload/FilesToUpload.js +0 -109
  190. package/upload/index.d.ts +0 -15
  191. package/upload/transaction/Icons.js +0 -160
  192. package/upload/transaction/Transaction.js +0 -104
  193. package/upload/transactions/Transactions.js +0 -94
  194. package/useTheme.js +0 -22
  195. package/wizard/Icons.js +0 -65
  196. package/wizard/Wizard.d.ts +0 -4
  197. package/wizard/Wizard.js +0 -231
  198. package/wizard/Wizard.stories.jsx +0 -224
  199. package/wizard/types.d.ts +0 -64
  200. package/wizard/types.js +0 -5
@@ -1,117 +0,0 @@
1
- type Size = "small" | "medium" | "large" | "fillParent";
2
- type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
3
- type Margin = {
4
- top?: Space;
5
- bottom?: Space;
6
- left?: Space;
7
- right?: Space;
8
- };
9
-
10
- type Props = {
11
- /**
12
- * Text to be placed above the textarea.
13
- */
14
- label?: string;
15
- /**
16
- * Name attribute of the textarea element.
17
- */
18
- name?: string;
19
- /**
20
- * Value of the textarea. If undefined, the component will be uncontrolled and the value will be managed internally.
21
- */
22
- value?: string;
23
- /**
24
- * Helper text to be placed above the textarea.
25
- */
26
- helperText?: string;
27
- /**
28
- * Text to be put as placeholder of the textarea.
29
- */
30
- placeholder?: string;
31
- /**
32
- * If true, the component will be disabled.
33
- */
34
- disabled?: boolean;
35
- /**
36
- * If true, the textarea will be optional, showing '(Optional)'
37
- * next to the label. Otherwise, the field will be considered required
38
- * and an error will be passed as a parameter to the OnBlur and onChange functions
39
- * when it has not been filled.
40
- */
41
- optional?: boolean;
42
- /**
43
- * Defines the textarea's ability to resize vertically. It can be:
44
- * - 'auto': The textarea grows or shrinks automatically in order to fit the content.
45
- * - 'manual': The height of the textarea is enabled to be manually modified.
46
- * - 'none': The textarea has a fixed height and can't be modified.
47
- */
48
- verticalGrow?: "auto" | "manual" | "none";
49
- /**
50
- * Number of rows of the textarea.
51
- */
52
- rows?: number;
53
- /**
54
- * This function will be called when the user types within the textarea.
55
- * An object including the current value and the error (if the value
56
- * entered is not valid) will be passed to this function.
57
- * If there is no error, error will be null.
58
- */
59
- onChange?: (val: { value: string; error: string }) => void;
60
- /**
61
- * This function will be called when the textarea loses the focus. An
62
- * object including the textarea value and the error (if the value entered
63
- * is not valid) will be passed to this function. If there is no error,
64
- * error will be null.
65
- */
66
- onBlur?: (val: { value: string; error: string }) => void;
67
- /**
68
- * If it is defined, the component will change its appearance, showing
69
- * the error below the textarea. If it is not defined, the error
70
- * messages will be managed internally, but never displayed on its own.
71
- */
72
- error?: string;
73
- /**
74
- * Regular expression that defines the valid format allowed by the
75
- * textarea. This will be checked both when the textarea loses the focus
76
- * and while typing within it. If the string entered does not match the
77
- * pattern, the onBlur and onChange functions will be called with the
78
- * current value and an internal error informing that this value does not
79
- * match the pattern. If the pattern is met, the error parameter of both
80
- * events will be null.
81
- */
82
- pattern?: string;
83
- /**
84
- * Specifies the minimun and maximum length allowed by the textarea.
85
- * This will be checked both when the textarea loses the
86
- * focus and while typing within it. If the string entered does not
87
- * comply the length, the onBlur and onChange functions will be called
88
- * with the current value and an internal error informing that the value
89
- * length does not comply the specified range. If a valid length is
90
- * reached, the error parameter of both events will be null.
91
- */
92
- length?: { min: number; max: number };
93
- /**
94
- * HTML autocomplete attribute. Lets the user specify if any permission the user agent has to provide automated assistance in filling out the textarea value.
95
- * Its value must be one of all the possible values of the HTML autocomplete attribute: 'on', 'off', 'email', 'username', 'new-password', ...
96
- */
97
- autocomplete?: string;
98
- /**
99
- * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge').
100
- * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes.
101
- */
102
- margin?: Space | Margin;
103
- /**
104
- * Size of the component ('small' | 'medium' | 'large' | 'fillParent').
105
- */
106
- size?: Size;
107
- /**
108
- * Value of the tabindex attribute.
109
- */
110
- tabIndex?: number;
111
- /**
112
- * Reference to the component.
113
- */
114
- ref?: React.RefObject<HTMLDivElement>;
115
- };
116
-
117
- export default function DxcTextarea(props: Props): JSX.Element;
package/toggle/Toggle.js DELETED
@@ -1,186 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
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 _react = _interopRequireDefault(require("react"));
19
-
20
- var _lab = require("@material-ui/lab");
21
-
22
- var _propTypes = _interopRequireDefault(require("prop-types"));
23
-
24
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
25
-
26
- var _utils = require("../common/utils.js");
27
-
28
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
29
-
30
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
31
-
32
- 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); }
33
-
34
- 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; }
35
-
36
- var DxcToggle = function DxcToggle(_ref) {
37
- var _ref$label = _ref.label,
38
- label = _ref$label === void 0 ? "" : _ref$label,
39
- _ref$iconSrc = _ref.iconSrc,
40
- iconSrc = _ref$iconSrc === void 0 ? "" : _ref$iconSrc,
41
- _ref$mode = _ref.mode,
42
- mode = _ref$mode === void 0 ? "basic" : _ref$mode,
43
- _ref$theme = _ref.theme,
44
- theme = _ref$theme === void 0 ? "light" : _ref$theme,
45
- _ref$disableRipple = _ref.disableRipple,
46
- disableRipple = _ref$disableRipple === void 0 ? false : _ref$disableRipple,
47
- _ref$iconPosition = _ref.iconPosition,
48
- iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
49
- _ref$disabled = _ref.disabled,
50
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
51
- onClick = _ref.onClick,
52
- _ref$selected = _ref.selected,
53
- selected = _ref$selected === void 0 ? false : _ref$selected,
54
- margin = _ref.margin,
55
- _ref$size = _ref.size,
56
- size = _ref$size === void 0 ? "fitContent" : _ref$size;
57
- var colorsTheme = (0, _useTheme["default"])();
58
-
59
- var handlerToggleClick = function handlerToggleClick() {
60
- if (!disabled && typeof onClick === "function") {
61
- onClick(!selected);
62
- }
63
- };
64
-
65
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
66
- theme: colorsTheme
67
- }, /*#__PURE__*/_react["default"].createElement(DxcToggleContainer, {
68
- margin: margin,
69
- brightness: theme,
70
- disabled: disabled,
71
- disableRipple: disableRipple,
72
- selected: selected,
73
- label: label,
74
- mode: mode,
75
- iconPosition: iconPosition,
76
- value: true,
77
- size: size,
78
- onClick: handlerToggleClick
79
- }, /*#__PURE__*/_react["default"].createElement(_lab.ToggleButton, {
80
- disabled: disabled,
81
- disableRipple: disableRipple,
82
- selected: selected,
83
- label: label,
84
- value: true
85
- }, /*#__PURE__*/_react["default"].createElement(ContentContainer, {
86
- iconPosition: iconPosition,
87
- label: label,
88
- iconSrc: iconSrc
89
- }, iconSrc !== "" && /*#__PURE__*/_react["default"].createElement(IconContainer, {
90
- iconPosition: iconPosition,
91
- label: label,
92
- src: iconSrc
93
- }), label !== "" && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, label)))));
94
- };
95
-
96
- var sizes = {
97
- small: "42px",
98
- medium: "120px",
99
- large: "240px",
100
- fillParent: "100%",
101
- fitContent: "unset"
102
- };
103
-
104
- var calculateWidth = function calculateWidth(margin, size) {
105
- if (size === "fillParent") {
106
- return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
107
- }
108
-
109
- return sizes[size];
110
- };
111
-
112
- var DxcToggleContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n & {\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n\n opacity: ", ";\n cursor: ", ";\n display: inline-block;\n width: ", ";\n }\n\n .MuiToggleButton-label {\n font-size: 14px;\n font-family: ", ";\n color: ", ";\n }\n .MuiButtonBase-root {\n width: ", ";\n min-height: ", ";\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root {\n min-width: 42px;\n height: 43px;\n border: ", ";\n\n border-radius: 4px !important;\n }\n\n .MuiToggleButton-root.Mui-selected {\n background-color: ", ";\n &:hover {\n background-color: ", ";\n .MuiToggleButton-label {\n color: ", ";\n }\n }\n }\n\n .MuiToggleButton-root:last-child,\n .MuiToggleButton-root:first-child,\n .MuiToggleButton-root:not(:first-child) {\n padding: ", ";\n }\n\n .MuiTouchRipple-child {\n background-color: ", ";\n }\n"])), function (props) {
113
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? spaces[props.margin] : "0px";
114
- }, function (props) {
115
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? spaces[props.margin.top] : "";
116
- }, function (props) {
117
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? spaces[props.margin.right] : "";
118
- }, function (props) {
119
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? spaces[props.margin.bottom] : "";
120
- }, function (props) {
121
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? spaces[props.margin.left] : "";
122
- }, function (props) {
123
- return props.disabled ? "0.5" : "1";
124
- }, function (props) {
125
- return props.disabled ? "not-allowed" : "pointer";
126
- }, function (props) {
127
- return calculateWidth(props.margin, props.size);
128
- }, function (props) {
129
- return props.theme.fontFamily;
130
- }, function (props) {
131
- return props.brightness === "dark" && props.mode === "outlined" ? props.theme.white : props.theme.black;
132
- }, function (props) {
133
- return calculateWidth(props.margin, props.size);
134
- }, function (props) {
135
- return props.mode === "outlined" ? "41px" : "43px";
136
- }, function (props) {
137
- return props.mode !== "outlined" ? props.theme.darkWhite : "transparent";
138
- }, function (props) {
139
- return props.mode === "basic" ? props.theme.lightGrey : props.brightness === "dark" ? props.theme.darkGrey : props.theme.darkWhite;
140
- }, function (props) {
141
- return props.brightness === "dark" && props.mode === "outlined" ? props.theme.white : props.theme.black;
142
- }, function (props) {
143
- return props.mode === "basic" ? "none !important" : props.brightness === "dark" && !props.selected ? "2px solid ".concat(props.theme.white, " !important") : props.brightness === "dark" && props.selected ? "2px solid ".concat(props.theme.yellow, " !important") : "2px solid ".concat(props.theme.black, " !important");
144
- }, function (props) {
145
- return props.mode === "outlined" ? props.brightness === "light" ? props.theme.darkWhite : "transparent" : props.theme.yellow;
146
- }, function (props) {
147
- return props.mode === "basic" && props.brightness === "light" ? props.theme.black : props.mode === "basic" && props.brightness === "dark" ? props.theme.lightBlack : props.brightness === "light" ? props.theme.lightGrey : props.theme.darkGrey;
148
- }, function (props) {
149
- return props.mode === "basic" ? props.theme.yellow : props.brightness === "dark" && props.mode === "outlined" ? props.theme.white : props.theme.black;
150
- }, function (props) {
151
- return props.label !== "" && props.size !== "small" ? props.mode === "outlined" ? "8px 30px " : "12px 30px" : props.mode === "outlined" ? "8px 10px " : "12px 10px";
152
- }, function (props) {
153
- return props.mode === "basic" ? props.selected === false ? props.theme.yellow : props.theme.darkWhite : props.selected === false ? props.theme.lightGrey : props.theme.white;
154
- });
155
-
156
- var ContentContainer = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n line-height: 1;\n display: flex;\n align-items: center;\n flex-direction: ", ";\n"])), function (props) {
157
- return props.iconPosition === "after" ? "row-reverse" : "row";
158
- });
159
-
160
- var IconContainer = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 20px;\n height: 20px;\n line-height: 1;\n margin-right: ", ";\n margin-left: ", ";\n"])), function (props) {
161
- return props.label !== "" && props.iconPosition === "before" ? "10px" : "";
162
- }, function (props) {
163
- return props.label !== "" && props.iconPosition === "after" ? "10px" : "";
164
- });
165
-
166
- var LabelContainer = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])([""])));
167
-
168
- DxcToggle.propTypes = {
169
- size: _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(sizes))),
170
- theme: _propTypes["default"].oneOf(["light", "dark", ""]),
171
- mode: _propTypes["default"].oneOf(["basic", "outlined", ""]),
172
- iconPosition: _propTypes["default"].oneOf(["before", "after", ""]),
173
- iconSrc: _propTypes["default"].string,
174
- selected: _propTypes["default"].bool,
175
- disabled: _propTypes["default"].bool,
176
- disableRipple: _propTypes["default"].bool,
177
- onClick: _propTypes["default"].func,
178
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
179
- top: _propTypes["default"].oneOf(Object.keys(spaces)),
180
- bottom: _propTypes["default"].oneOf(Object.keys(spaces)),
181
- left: _propTypes["default"].oneOf(Object.keys(spaces)),
182
- right: _propTypes["default"].oneOf(Object.keys(spaces))
183
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(spaces)))])
184
- };
185
- var _default = DxcToggle;
186
- exports["default"] = _default;
package/toggle/index.d.ts DELETED
@@ -1,21 +0,0 @@
1
- type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
2
- type Margin = {
3
- top?: Space;
4
- bottom?: Space;
5
- left?: Space;
6
- right?: Space;
7
- };
8
-
9
- type Props = {
10
- label?: string;
11
- helperText?: string;
12
- value?: any;
13
- onChange?: void;
14
- disabled?: boolean,
15
- options?: any;
16
- multiple?: boolean;
17
- margin?: Space | Margin;
18
- tabIndex?: number;
19
- };
20
-
21
- export default function DxcToggle(props: Props): JSX.Element;
@@ -1,243 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
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 _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
15
-
16
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
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 _uuid = require("uuid");
25
-
26
- var _propTypes = _interopRequireDefault(require("prop-types"));
27
-
28
- var _variables = require("../common/variables.js");
29
-
30
- var _useTheme = _interopRequireDefault(require("../useTheme.js"));
31
-
32
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
33
-
34
- 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); }
35
-
36
- 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; }
37
-
38
- var DxcToggleGroup = function DxcToggleGroup(_ref) {
39
- var label = _ref.label,
40
- helperText = _ref.helperText,
41
- value = _ref.value,
42
- onChange = _ref.onChange,
43
- _ref$disabled = _ref.disabled,
44
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
45
- _ref$options = _ref.options,
46
- options = _ref$options === void 0 ? [] : _ref$options,
47
- margin = _ref.margin,
48
- _ref$multiple = _ref.multiple,
49
- multiple = _ref$multiple === void 0 ? false : _ref$multiple,
50
- _ref$tabIndex = _ref.tabIndex,
51
- tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
52
- var colorsTheme = (0, _useTheme["default"])();
53
-
54
- var _useState = (0, _react.useState)(multiple ? [] : null),
55
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
56
- selectedValue = _useState2[0],
57
- setSelectedValue = _useState2[1];
58
-
59
- var _useState3 = (0, _react.useState)("toggle-group-".concat((0, _uuid.v4)())),
60
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
61
- toggleGroupId = _useState4[0];
62
-
63
- var handleToggleChange = function handleToggleChange(selectedOption) {
64
- var newSelectedOptions;
65
-
66
- if (value == null) {
67
- if (multiple) {
68
- newSelectedOptions = selectedValue.map(function (value) {
69
- return value;
70
- });
71
-
72
- if (newSelectedOptions.includes(selectedOption)) {
73
- var index = newSelectedOptions.indexOf(selectedOption);
74
- newSelectedOptions.splice(index, 1);
75
- } else {
76
- newSelectedOptions.push(selectedOption);
77
- }
78
-
79
- setSelectedValue(newSelectedOptions);
80
- } else setSelectedValue(selectedOption === selectedValue ? null : selectedOption);
81
- } else if (multiple) {
82
- newSelectedOptions = value.map(function (v) {
83
- return v;
84
- });
85
-
86
- if (newSelectedOptions.includes(selectedOption)) {
87
- var _index = newSelectedOptions.indexOf(selectedOption);
88
-
89
- newSelectedOptions.splice(_index, 1);
90
- } else newSelectedOptions.push(selectedOption);
91
- }
92
-
93
- typeof onChange === "function" && onChange(multiple ? newSelectedOptions : selectedOption);
94
- };
95
-
96
- var handleKeyPress = function handleKeyPress(event, optionValue) {
97
- event.preventDefault();
98
- if (!disabled && (event.nativeEvent.code === "Enter" || event.nativeEvent.code === "Space")) handleToggleChange(optionValue);
99
- };
100
-
101
- return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
102
- theme: colorsTheme.toggleGroup
103
- }, /*#__PURE__*/_react["default"].createElement(ToggleGroup, {
104
- margin: margin,
105
- disabled: disabled
106
- }, /*#__PURE__*/_react["default"].createElement(Label, {
107
- htmlFor: toggleGroupId,
108
- disabled: disabled
109
- }, label), /*#__PURE__*/_react["default"].createElement(HelperText, {
110
- disabled: disabled
111
- }, helperText), /*#__PURE__*/_react["default"].createElement(OptionsContainer, {
112
- id: toggleGroupId,
113
- role: multiple ? "group" : "radiogroup"
114
- }, options.map(function (option, i) {
115
- return /*#__PURE__*/_react["default"].createElement(ToggleContainer, {
116
- selected: multiple ? value ? value.includes(option.value) : selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
117
- role: multiple ? "switch" : "radio",
118
- "aria-checked": multiple ? value ? value.includes(option.value) : selectedValue.includes(option.value) : value ? option.value === value : option.value === selectedValue,
119
- tabIndex: !disabled ? tabIndex : -1,
120
- onClick: function onClick() {
121
- return !disabled && handleToggleChange(option.value);
122
- },
123
- isFirst: i === 0,
124
- isLast: i === options.length - 1,
125
- isIcon: option.iconSrc || option.icon,
126
- optionLabel: option.label,
127
- disabled: disabled,
128
- onKeyPress: function onKeyPress(event) {
129
- handleKeyPress(event, option.value);
130
- },
131
- key: "toggle-".concat(i, "-").concat(option.label)
132
- }, /*#__PURE__*/_react["default"].createElement(OptionContent, null, option.icon && /*#__PURE__*/_react["default"].createElement(IconContainer, {
133
- optionLabel: option.label
134
- }, (0, _typeof2["default"])(option.icon) === "object" ? option.icon : /*#__PURE__*/_react["default"].createElement(option.icon)), option.iconSrc && /*#__PURE__*/_react["default"].createElement(Icon, {
135
- src: option.iconSrc,
136
- optionLabel: option.label
137
- }), option.label && /*#__PURE__*/_react["default"].createElement(LabelContainer, null, option.label)));
138
- }))));
139
- };
140
-
141
- var Label = _styledComponents["default"].label(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
142
- return props.disabled ? props.theme.disabledLabelFontColor : props.theme.labelFontColor;
143
- }, function (props) {
144
- return props.theme.labelFontFamily;
145
- }, function (props) {
146
- return props.theme.labelFontSize;
147
- }, function (props) {
148
- return props.theme.labelFontStyle;
149
- }, function (props) {
150
- return props.theme.labelFontWeight;
151
- }, function (props) {
152
- return props.theme.labelLineHeight;
153
- });
154
-
155
- var HelperText = _styledComponents["default"].span(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: ", ";\n"])), function (props) {
156
- return props.disabled ? props.theme.disabledHelperTextFontcolor : props.theme.helperTextFontColor;
157
- }, function (props) {
158
- return props.theme.helperTextFontFamily;
159
- }, function (props) {
160
- return props.theme.helperTextFontSize;
161
- }, function (props) {
162
- return props.theme.helperTextFontStyle;
163
- }, function (props) {
164
- return props.theme.helperTextFontWeight;
165
- }, function (props) {
166
- return props.theme.helperTextLineHeight;
167
- });
168
-
169
- var ToggleGroup = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n flex-direction: column;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
170
- return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
171
- }, function (props) {
172
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.top ? _variables.spaces[props.margin.top] : "";
173
- }, function (props) {
174
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.right ? _variables.spaces[props.margin.right] : "";
175
- }, function (props) {
176
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.bottom ? _variables.spaces[props.margin.bottom] : "";
177
- }, function (props) {
178
- return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
179
- });
180
-
181
- var OptionsContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n opacity: 1;\n height: calc(48px - 4px - 4px);\n border-width: ", ";\n border-style: ", ";\n border-radius: ", ";\n border-color: ", ";\n background-color: ", ";\n padding: 4px;\n margin-top: ", ";\n"])), function (props) {
182
- return props.theme.containerBorderThickness;
183
- }, function (props) {
184
- return props.theme.containerBorderStyle;
185
- }, function (props) {
186
- return props.theme.containerBorderRadius;
187
- }, function (props) {
188
- return props.theme.containerBorderColor;
189
- }, function (props) {
190
- return props.theme.containerBackgroundColor;
191
- }, function (props) {
192
- return props.theme.containerMarginTop;
193
- });
194
-
195
- var ToggleContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-right: ", ";\n\n ", "\n"])), function (props) {
196
- return !props.isLast && "4px";
197
- }, function (props) {
198
- return "\n background-color: ".concat(props.selected ? props.disabled ? props.theme.selectedDisabledBackgroundColor : props.theme.selectedBackgroundColor : props.disabled ? props.theme.unselectedDisabledBackgroundColor : props.theme.unselectedBackgroundColor, ";\n border-width: ").concat(props.theme.optionBorderThickness, ";\n border-style: ").concat(props.theme.optionBorderStyle, ";\n border-radius: ").concat(props.theme.optionBorderRadius, ";\n padding-left: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingLeft : props.theme.iconPaddingLeft, ";\n padding-right: ").concat(props.optionLabel && props.isIcon || props.optionLabel && !props.isIcon ? props.theme.labelPaddingRight : props.theme.iconPaddingRight, ";\n ").concat(!props.disabled ? ":hover {\n background-color: ".concat(props.selected ? props.theme.selectedHoverBackgroundColor : props.theme.unselectedHoverBackgroundColor, ";\n }\n :active {\n background-color: ").concat(props.selected ? props.theme.selectedActiveBackgroundColor : props.theme.unselectedActiveBackgroundColor, ";\n color: #ffffff;\n } \n :focus {\n border-color: transparent;\n box-shadow: 0 0 0 ").concat(props.theme.optionFocusBorderThickness, " ").concat(props.backgroundType === "dark" ? props.theme.focusColorOnDark : props.theme.focusColor, ";\n }\n &:focus-visible {\n outline: none;\n }\n cursor: pointer;\n color: ").concat(props.selected ? props.theme.selectedFontColor : props.theme.unselectedFontColor, ";\n") : "color: ".concat(props.selected ? props.theme.selectedDisabledFontColor : props.theme.unselectedDisabledFontColor, ";\n cursor: not-allowed;"), "\n ");
199
- });
200
-
201
- var LabelContainer = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
202
- return props.theme.optionLabelFontFamily;
203
- }, function (props) {
204
- return props.theme.optionLabelFontSize;
205
- }, function (props) {
206
- return props.theme.optionLabelFontStyle;
207
- }, function (props) {
208
- return props.theme.optionLabelFontWeight;
209
- });
210
-
211
- var OptionContent = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: row;\n"])));
212
-
213
- var Icon = _styledComponents["default"].img(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 24px;\n width: 24px;\n margin-right: ", ";\n"])), function (props) {
214
- return props.optionLabel && props.theme.iconMarginRight;
215
- });
216
-
217
- var IconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n margin-right: ", ";\n height: 24px;\n width: 24px;\n overflow: hidden;\n display: flex;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
218
- return props.optionLabel && props.theme.iconMarginRight;
219
- });
220
-
221
- DxcToggleGroup.propTypes = {
222
- label: _propTypes["default"].string,
223
- helperText: _propTypes["default"].string,
224
- value: _propTypes["default"].any,
225
- onChange: _propTypes["default"].func,
226
- disabled: _propTypes["default"].bool,
227
- multiple: _propTypes["default"].bool,
228
- options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
229
- value: _propTypes["default"].any.isRequired,
230
- label: _propTypes["default"].string,
231
- icon: _propTypes["default"].oneOfType([_propTypes["default"].element, _propTypes["default"].func]),
232
- iconSrc: _propTypes["default"].string
233
- })),
234
- margin: _propTypes["default"].oneOfType([_propTypes["default"].shape({
235
- top: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
236
- bottom: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
237
- left: _propTypes["default"].oneOf(Object.keys(_variables.spaces)),
238
- right: _propTypes["default"].oneOf(Object.keys(_variables.spaces))
239
- }), _propTypes["default"].oneOf((0, _toConsumableArray2["default"])(Object.keys(_variables.spaces)))]),
240
- tabIndex: _propTypes["default"].number
241
- };
242
- var _default = DxcToggleGroup;
243
- exports["default"] = _default;