@zohodesk/components 1.5.2 → 1.5.3
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/README.md +10 -0
- package/assets/Appearance/dark/mode/Component_DarkMode.module.css +2 -0
- package/assets/Appearance/light/mode/Component_LightMode.module.css +2 -0
- package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +2 -0
- package/es/CheckBox/CheckBox.js +21 -10
- package/es/CheckBox/CheckBox.module.css +21 -6
- package/es/CheckBox/__tests__/CheckBox.spec.js +9 -0
- package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
- package/es/CheckBox/props/propTypes.js +4 -1
- package/es/Label/Label.js +19 -1
- package/es/Label/__tests__/Label.spec.js +58 -0
- package/es/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
- package/es/Label/props/defaultProps.js +1 -0
- package/es/Label/props/propTypes.js +7 -1
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +7 -7
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +7 -7
- package/es/Radio/Radio.js +20 -9
- package/es/Radio/Radio.module.css +38 -5
- package/es/Radio/__tests__/Radio.spec.js +10 -0
- package/es/Radio/__tests__/__snapshots__/Radio.spec.js.snap +154 -81
- package/es/Radio/props/propTypes.js +4 -1
- package/lib/CheckBox/CheckBox.js +23 -9
- package/lib/CheckBox/CheckBox.module.css +21 -6
- package/lib/CheckBox/__tests__/CheckBox.spec.js +21 -12
- package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
- package/lib/CheckBox/props/propTypes.js +5 -1
- package/lib/Label/Label.js +21 -1
- package/lib/Label/__tests__/Label.spec.js +58 -0
- package/lib/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
- package/lib/Label/props/defaultProps.js +1 -0
- package/lib/Label/props/propTypes.js +8 -1
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +7 -7
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +7 -7
- package/lib/Radio/Radio.js +22 -8
- package/lib/Radio/Radio.module.css +38 -5
- package/lib/Radio/__tests__/Radio.spec.js +10 -0
- package/lib/Radio/__tests__/__snapshots__/Radio.spec.js.snap +154 -81
- package/lib/Radio/props/propTypes.js +5 -1
- package/package.json +9 -9
|
@@ -7,6 +7,8 @@ exports.propTypes = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _propTypes2 = require("../../Typography/props/propTypes");
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
13
|
|
|
12
14
|
var propTypes = {
|
|
@@ -15,6 +17,7 @@ var propTypes = {
|
|
|
15
17
|
checked: _propTypes["default"].bool,
|
|
16
18
|
dataId: _propTypes["default"].string,
|
|
17
19
|
dataSelectorId: _propTypes["default"].string,
|
|
20
|
+
secondaryText: _propTypes["default"].string,
|
|
18
21
|
disabled: _propTypes["default"].bool,
|
|
19
22
|
disabledTitle: _propTypes["default"].string,
|
|
20
23
|
getRef: _propTypes["default"].func,
|
|
@@ -46,7 +49,8 @@ var propTypes = {
|
|
|
46
49
|
}),
|
|
47
50
|
customProps: _propTypes["default"].shape({
|
|
48
51
|
CheckBoxProps: _propTypes["default"].object,
|
|
49
|
-
LabelProps: _propTypes["default"].object
|
|
52
|
+
LabelProps: _propTypes["default"].object,
|
|
53
|
+
secondaryTextProps: _propTypes["default"].exact(_propTypes2.propTypes)
|
|
50
54
|
}),
|
|
51
55
|
renderRightPlaceholderNode: _propTypes["default"].node
|
|
52
56
|
};
|
package/lib/Label/Label.js
CHANGED
|
@@ -13,12 +13,18 @@ var _defaultProps = require("./props/defaultProps");
|
|
|
13
13
|
|
|
14
14
|
var _propTypes = require("./props/propTypes");
|
|
15
15
|
|
|
16
|
+
var _Flex = _interopRequireDefault(require("@zohodesk/layout/es/Flex/Flex"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("@zohodesk/utils");
|
|
19
|
+
|
|
16
20
|
var _LabelModule = _interopRequireDefault(require("./Label.module.css"));
|
|
17
21
|
|
|
18
22
|
var _LabelColorsModule = _interopRequireDefault(require("./LabelColors.module.css"));
|
|
19
23
|
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
25
|
|
|
26
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
|
+
|
|
22
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
29
|
|
|
24
30
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -65,12 +71,17 @@ var Label = /*#__PURE__*/function (_React$Component) {
|
|
|
65
71
|
dataId = _this$props.dataId,
|
|
66
72
|
dataSelectorId = _this$props.dataSelectorId,
|
|
67
73
|
variant = _this$props.variant,
|
|
74
|
+
customProps = _this$props.customProps,
|
|
68
75
|
customClass = _this$props.customClass,
|
|
69
76
|
id = _this$props.id,
|
|
77
|
+
renderRightPlaceholderNode = _this$props.renderRightPlaceholderNode,
|
|
70
78
|
_this$props$a11y = _this$props.a11y,
|
|
71
79
|
a11y = _this$props$a11y === void 0 ? {} : _this$props$a11y;
|
|
80
|
+
var containerProps = customProps.containerProps,
|
|
81
|
+
rightPlaceholderNodeProps = customProps.rightPlaceholderNodeProps;
|
|
72
82
|
var tabIndex = a11y.tabIndex;
|
|
73
|
-
|
|
83
|
+
|
|
84
|
+
var labelElement = /*#__PURE__*/_react["default"].createElement("label", {
|
|
74
85
|
className: "".concat(_LabelModule["default"].label, " ").concat(_LabelModule["default"][type], " ").concat(_LabelModule["default"][size], " ").concat(_LabelColorsModule["default"][palette], " ").concat(_LabelModule["default"]["font_".concat(variant)], "\n ").concat(clipped ? _LabelModule["default"].dotted : '', " ").concat(onClick ? _LabelModule["default"].pointer : _LabelModule["default"].cursor, " ").concat(customClass, " "),
|
|
75
86
|
htmlFor: htmlFor,
|
|
76
87
|
"data-title": title,
|
|
@@ -81,6 +92,15 @@ var Label = /*#__PURE__*/function (_React$Component) {
|
|
|
81
92
|
id: id,
|
|
82
93
|
tabIndex: tabIndex
|
|
83
94
|
}, text);
|
|
95
|
+
|
|
96
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _utils.isRenderable)(renderRightPlaceholderNode) ? /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({
|
|
97
|
+
$ui_displayMode: "flex",
|
|
98
|
+
$ui_direction: "row",
|
|
99
|
+
$ui_alignItems: "center"
|
|
100
|
+
}, containerProps), labelElement, /*#__PURE__*/_react["default"].createElement(_Flex["default"], _extends({
|
|
101
|
+
$ui_displayMode: "flex",
|
|
102
|
+
$ui_alignItems: "center"
|
|
103
|
+
}, rightPlaceholderNodeProps), (0, _utils.renderNode)(renderRightPlaceholderNode))) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, labelElement));
|
|
84
104
|
}
|
|
85
105
|
}]);
|
|
86
106
|
|
|
@@ -103,4 +103,62 @@ describe('Label', function () {
|
|
|
103
103
|
|
|
104
104
|
expect(asFragment()).toMatchSnapshot();
|
|
105
105
|
});
|
|
106
|
+
test('rendering with renderRightPlaceholderNode', function () {
|
|
107
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Label["default"], {
|
|
108
|
+
text: "New Feature",
|
|
109
|
+
id: "label_new",
|
|
110
|
+
renderRightPlaceholderNode: /*#__PURE__*/_react["default"].createElement("span", {
|
|
111
|
+
style: {
|
|
112
|
+
background: '#27ae60',
|
|
113
|
+
color: 'white',
|
|
114
|
+
padding: '2px 6px',
|
|
115
|
+
borderRadius: '3px',
|
|
116
|
+
fontSize: '10px',
|
|
117
|
+
fontWeight: 'bold'
|
|
118
|
+
}
|
|
119
|
+
}, "NEW")
|
|
120
|
+
})),
|
|
121
|
+
asFragment = _render12.asFragment;
|
|
122
|
+
|
|
123
|
+
expect(asFragment()).toMatchSnapshot();
|
|
124
|
+
});
|
|
125
|
+
test('rendering with customProps - containerProps & rightPlaceholderNodeProps', function () {
|
|
126
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Label["default"], {
|
|
127
|
+
text: "Premium Feature",
|
|
128
|
+
id: "label_premium",
|
|
129
|
+
size: "large",
|
|
130
|
+
palette: "danger",
|
|
131
|
+
renderRightPlaceholderNode: /*#__PURE__*/_react["default"].createElement("span", {
|
|
132
|
+
style: {
|
|
133
|
+
fontSize: '10px',
|
|
134
|
+
background: '#f39c12',
|
|
135
|
+
color: 'white',
|
|
136
|
+
padding: '1px 4px',
|
|
137
|
+
borderRadius: '2px'
|
|
138
|
+
}
|
|
139
|
+
}, "PRO"),
|
|
140
|
+
customProps: {
|
|
141
|
+
containerProps: {
|
|
142
|
+
$ui_alignItems: 'center',
|
|
143
|
+
$tagAttributes_container: {
|
|
144
|
+
style: {
|
|
145
|
+
gap: '6px'
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
rightPlaceholderNodeProps: {
|
|
150
|
+
$ui_displayMode: 'flex',
|
|
151
|
+
$ui_alignItems: 'center',
|
|
152
|
+
$tagAttributes_container: {
|
|
153
|
+
style: {
|
|
154
|
+
gap: '6px'
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
})),
|
|
160
|
+
asFragment = _render13.asFragment;
|
|
161
|
+
|
|
162
|
+
expect(asFragment()).toMatchSnapshot();
|
|
163
|
+
});
|
|
106
164
|
});
|
|
@@ -310,3 +310,69 @@ exports[`Label rendering the variant of- primary 1`] = `
|
|
|
310
310
|
</label>
|
|
311
311
|
</DocumentFragment>
|
|
312
312
|
`;
|
|
313
|
+
|
|
314
|
+
exports[`Label rendering with customProps - containerProps & rightPlaceholderNodeProps 1`] = `
|
|
315
|
+
<DocumentFragment>
|
|
316
|
+
<div
|
|
317
|
+
class="flex row alignItems_center"
|
|
318
|
+
data-id="flex"
|
|
319
|
+
data-test-id="flex"
|
|
320
|
+
style="gap: 6px;"
|
|
321
|
+
>
|
|
322
|
+
<label
|
|
323
|
+
class="label title large danger font_default
|
|
324
|
+
cursor "
|
|
325
|
+
data-id="label"
|
|
326
|
+
data-selector-id="label"
|
|
327
|
+
data-test-id="label"
|
|
328
|
+
id="label_premium"
|
|
329
|
+
>
|
|
330
|
+
Premium Feature
|
|
331
|
+
</label>
|
|
332
|
+
<div
|
|
333
|
+
class="flex row alignItems_center"
|
|
334
|
+
data-id="flex"
|
|
335
|
+
data-test-id="flex"
|
|
336
|
+
style="gap: 6px;"
|
|
337
|
+
>
|
|
338
|
+
<span
|
|
339
|
+
style="font-size: 10px; background: rgb(243, 156, 18); color: white; padding: 1px 4px; border-radius: 2px;"
|
|
340
|
+
>
|
|
341
|
+
PRO
|
|
342
|
+
</span>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
</DocumentFragment>
|
|
346
|
+
`;
|
|
347
|
+
|
|
348
|
+
exports[`Label rendering with renderRightPlaceholderNode 1`] = `
|
|
349
|
+
<DocumentFragment>
|
|
350
|
+
<div
|
|
351
|
+
class="flex row alignItems_center"
|
|
352
|
+
data-id="flex"
|
|
353
|
+
data-test-id="flex"
|
|
354
|
+
>
|
|
355
|
+
<label
|
|
356
|
+
class="label title medium default font_default
|
|
357
|
+
cursor "
|
|
358
|
+
data-id="label"
|
|
359
|
+
data-selector-id="label"
|
|
360
|
+
data-test-id="label"
|
|
361
|
+
id="label_new"
|
|
362
|
+
>
|
|
363
|
+
New Feature
|
|
364
|
+
</label>
|
|
365
|
+
<div
|
|
366
|
+
class="flex row alignItems_center"
|
|
367
|
+
data-id="flex"
|
|
368
|
+
data-test-id="flex"
|
|
369
|
+
>
|
|
370
|
+
<span
|
|
371
|
+
style="background: rgb(39, 174, 96); color: white; padding: 2px 6px; border-radius: 3px; font-size: 10px; font-weight: bold;"
|
|
372
|
+
>
|
|
373
|
+
NEW
|
|
374
|
+
</span>
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
377
|
+
</DocumentFragment>
|
|
378
|
+
`;
|
|
@@ -7,6 +7,8 @@ exports.propTypes = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _propTypes2 = _interopRequireDefault(require("@zohodesk/layout/es/Flex/props/propTypes"));
|
|
11
|
+
|
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
13
|
|
|
12
14
|
var propTypes = {
|
|
@@ -21,10 +23,15 @@ var propTypes = {
|
|
|
21
23
|
title: _propTypes["default"].string,
|
|
22
24
|
type: _propTypes["default"].oneOf(['title', 'subtitle']),
|
|
23
25
|
variant: _propTypes["default"].oneOf(['primary', 'default']),
|
|
26
|
+
customProps: _propTypes["default"].shape({
|
|
27
|
+
containerProps: _propTypes["default"].exact(_propTypes2["default"]),
|
|
28
|
+
rightPlaceholderNodeProps: _propTypes["default"].exact(_propTypes2["default"])
|
|
29
|
+
}),
|
|
24
30
|
customClass: _propTypes["default"].string,
|
|
25
31
|
a11y: _propTypes["default"].shape({
|
|
26
32
|
tabIndex: _propTypes["default"].string
|
|
27
33
|
}),
|
|
28
|
-
id: _propTypes["default"].string
|
|
34
|
+
id: _propTypes["default"].string,
|
|
35
|
+
renderRightPlaceholderNode: _propTypes["default"].oneOfType([_propTypes["default"].node, _propTypes["default"].func])
|
|
29
36
|
};
|
|
30
37
|
exports.propTypes = propTypes;
|
|
@@ -35,7 +35,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with renderValueRightPlacehol
|
|
|
35
35
|
tabindex="-1"
|
|
36
36
|
>
|
|
37
37
|
<div
|
|
38
|
-
class="boxContainer
|
|
38
|
+
class="boxContainer medium filled shrinkOff"
|
|
39
39
|
data-id="boxComponent"
|
|
40
40
|
data-selector-id="box"
|
|
41
41
|
data-test-id="boxComponent"
|
|
@@ -136,7 +136,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with renderValueRightPlacehol
|
|
|
136
136
|
tabindex="-1"
|
|
137
137
|
>
|
|
138
138
|
<div
|
|
139
|
-
class="boxContainer
|
|
139
|
+
class="boxContainer medium filled shrinkOff"
|
|
140
140
|
data-id="boxComponent"
|
|
141
141
|
data-selector-id="box"
|
|
142
142
|
data-test-id="boxComponent"
|
|
@@ -237,7 +237,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with secondaryValue text and
|
|
|
237
237
|
tabindex="-1"
|
|
238
238
|
>
|
|
239
239
|
<div
|
|
240
|
-
class="boxContainer
|
|
240
|
+
class="boxContainer medium filled shrinkOff"
|
|
241
241
|
data-id="boxComponent"
|
|
242
242
|
data-selector-id="box"
|
|
243
243
|
data-test-id="boxComponent"
|
|
@@ -337,7 +337,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with secondaryValue text and
|
|
|
337
337
|
tabindex="-1"
|
|
338
338
|
>
|
|
339
339
|
<div
|
|
340
|
-
class="boxContainer
|
|
340
|
+
class="boxContainer medium filled shrinkOff"
|
|
341
341
|
data-id="boxComponent"
|
|
342
342
|
data-selector-id="box"
|
|
343
343
|
data-test-id="boxComponent"
|
|
@@ -437,7 +437,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with secondaryValue 1`] = `
|
|
|
437
437
|
tabindex="-1"
|
|
438
438
|
>
|
|
439
439
|
<div
|
|
440
|
-
class="boxContainer
|
|
440
|
+
class="boxContainer medium filled shrinkOff"
|
|
441
441
|
data-id="boxComponent"
|
|
442
442
|
data-selector-id="box"
|
|
443
443
|
data-test-id="boxComponent"
|
|
@@ -537,7 +537,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with secondaryValue text and
|
|
|
537
537
|
tabindex="-1"
|
|
538
538
|
>
|
|
539
539
|
<div
|
|
540
|
-
class="boxContainer
|
|
540
|
+
class="boxContainer medium filled shrinkOff"
|
|
541
541
|
data-id="boxComponent"
|
|
542
542
|
data-selector-id="box"
|
|
543
543
|
data-test-id="boxComponent"
|
|
@@ -637,7 +637,7 @@ exports[`ListItemWithCheckBox rendering the defult props 1`] = `
|
|
|
637
637
|
tabindex="-1"
|
|
638
638
|
>
|
|
639
639
|
<div
|
|
640
|
-
class="boxContainer
|
|
640
|
+
class="boxContainer medium filled shrinkOff"
|
|
641
641
|
data-id="boxComponent"
|
|
642
642
|
data-selector-id="box"
|
|
643
643
|
data-test-id="boxComponent"
|
|
@@ -36,7 +36,7 @@ exports[`ListItemWithRadio ListItemWithRadio with renderValueRightPlaceholderNod
|
|
|
36
36
|
>
|
|
37
37
|
<div
|
|
38
38
|
class="radio
|
|
39
|
-
hoverprimary medium filled centerPathprimary
|
|
39
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
40
40
|
data-id="boxComponent"
|
|
41
41
|
data-selector-id="box"
|
|
42
42
|
data-test-id="boxComponent"
|
|
@@ -136,7 +136,7 @@ exports[`ListItemWithRadio ListItemWithRadio with renderValueRightPlaceholderNod
|
|
|
136
136
|
>
|
|
137
137
|
<div
|
|
138
138
|
class="radio
|
|
139
|
-
hoverprimary medium filled centerPathprimary
|
|
139
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
140
140
|
data-id="boxComponent"
|
|
141
141
|
data-selector-id="box"
|
|
142
142
|
data-test-id="boxComponent"
|
|
@@ -236,7 +236,7 @@ exports[`ListItemWithRadio ListItemWithRadio with secondaryValue text and LHS a
|
|
|
236
236
|
>
|
|
237
237
|
<div
|
|
238
238
|
class="radio
|
|
239
|
-
hoverprimary medium filled centerPathprimary
|
|
239
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
240
240
|
data-id="boxComponent"
|
|
241
241
|
data-selector-id="box"
|
|
242
242
|
data-test-id="boxComponent"
|
|
@@ -335,7 +335,7 @@ exports[`ListItemWithRadio ListItemWithRadio with secondaryValue text and LHS a
|
|
|
335
335
|
>
|
|
336
336
|
<div
|
|
337
337
|
class="radio
|
|
338
|
-
hoverprimary medium filled centerPathprimary
|
|
338
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
339
339
|
data-id="boxComponent"
|
|
340
340
|
data-selector-id="box"
|
|
341
341
|
data-test-id="boxComponent"
|
|
@@ -434,7 +434,7 @@ exports[`ListItemWithRadio ListItemWithRadio with secondaryValue 1`] = `
|
|
|
434
434
|
>
|
|
435
435
|
<div
|
|
436
436
|
class="radio
|
|
437
|
-
hoverprimary medium filled centerPathprimary
|
|
437
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
438
438
|
data-id="boxComponent"
|
|
439
439
|
data-selector-id="box"
|
|
440
440
|
data-test-id="boxComponent"
|
|
@@ -533,7 +533,7 @@ exports[`ListItemWithRadio ListItemWithRadio with secondaryValue text and LHS al
|
|
|
533
533
|
>
|
|
534
534
|
<div
|
|
535
535
|
class="radio
|
|
536
|
-
hoverprimary medium filled centerPathprimary
|
|
536
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
537
537
|
data-id="boxComponent"
|
|
538
538
|
data-selector-id="box"
|
|
539
539
|
data-test-id="boxComponent"
|
|
@@ -632,7 +632,7 @@ exports[`ListItemWithRadio rendering the defult props 1`] = `
|
|
|
632
632
|
>
|
|
633
633
|
<div
|
|
634
634
|
class="radio
|
|
635
|
-
hoverprimary medium filled centerPathprimary
|
|
635
|
+
hoverprimary medium filled centerPathprimary shrinkOff"
|
|
636
636
|
data-id="boxComponent"
|
|
637
637
|
data-selector-id="box"
|
|
638
638
|
data-test-id="boxComponent"
|
package/lib/Radio/Radio.js
CHANGED
|
@@ -15,6 +15,8 @@ var _propTypes = require("./props/propTypes");
|
|
|
15
15
|
|
|
16
16
|
var _Label = _interopRequireDefault(require("../Label/Label"));
|
|
17
17
|
|
|
18
|
+
var _Typography = _interopRequireDefault(require("../Typography/Typography"));
|
|
19
|
+
|
|
18
20
|
var _Layout = require("../Layout");
|
|
19
21
|
|
|
20
22
|
var _CssProvider = _interopRequireDefault(require("../Provider/CssProvider"));
|
|
@@ -101,13 +103,16 @@ var Radio = /*#__PURE__*/function (_React$Component) {
|
|
|
101
103
|
customProps = _this$props3.customProps,
|
|
102
104
|
children = _this$props3.children,
|
|
103
105
|
a11y = _this$props3.a11y,
|
|
106
|
+
secondaryText = _this$props3.secondaryText,
|
|
104
107
|
renderRightPlaceholderNode = _this$props3.renderRightPlaceholderNode;
|
|
105
108
|
var _customClass$customRa = customClass.customRadioWrap,
|
|
106
109
|
customRadioWrap = _customClass$customRa === void 0 ? '' : _customClass$customRa,
|
|
107
110
|
_customClass$customRa2 = customClass.customRadio,
|
|
108
111
|
customRadio = _customClass$customRa2 === void 0 ? '' : _customClass$customRa2,
|
|
109
112
|
_customClass$customLa = customClass.customLabel,
|
|
110
|
-
customLabel = _customClass$customLa === void 0 ? '' : _customClass$customLa
|
|
113
|
+
customLabel = _customClass$customLa === void 0 ? '' : _customClass$customLa,
|
|
114
|
+
_customClass$customSe = customClass.customSecondaryText,
|
|
115
|
+
customSecondaryText = _customClass$customSe === void 0 ? '' : _customClass$customSe;
|
|
111
116
|
var accessMode = isReadOnly ? _RadioModule["default"].readonly : disabled ? (0, _CssProvider["default"])('isDisabled') : _RadioModule["default"].pointer;
|
|
112
117
|
var toolTip = disabled ? disabledTitle : title ? title : null;
|
|
113
118
|
var isEditable = !(isReadOnly || disabled);
|
|
@@ -124,7 +129,9 @@ var Radio = /*#__PURE__*/function (_React$Component) {
|
|
|
124
129
|
var _customProps$Containe = customProps.ContainerProps,
|
|
125
130
|
ContainerProps = _customProps$Containe === void 0 ? {} : _customProps$Containe,
|
|
126
131
|
_customProps$LabelPro = customProps.LabelProps,
|
|
127
|
-
LabelProps = _customProps$LabelPro === void 0 ? {} : _customProps$LabelPro
|
|
132
|
+
LabelProps = _customProps$LabelPro === void 0 ? {} : _customProps$LabelPro,
|
|
133
|
+
_customProps$secondar = customProps.secondaryTextProps,
|
|
134
|
+
secondaryTextProps = _customProps$secondar === void 0 ? {} : _customProps$secondar;
|
|
128
135
|
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, _extends({
|
|
129
136
|
dataId: value ? value.toLowerCase() : 'RadioComp',
|
|
130
137
|
isCover: false,
|
|
@@ -143,7 +150,8 @@ var Radio = /*#__PURE__*/function (_React$Component) {
|
|
|
143
150
|
"aria-labelledby": ariaLabelledby,
|
|
144
151
|
"aria-readonly": ariaReadonly
|
|
145
152
|
}, ContainerProps), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
146
|
-
className: "".concat(_RadioModule["default"].radio, " ").concat(checked ? "".concat(_RadioModule["default"]["rdBox".concat(palette)]) : '', " \n ").concat(!isEditable ? '' : "".concat(_RadioModule["default"]["hover".concat(palette)]), " ").concat(_RadioModule["default"][size], " ").concat(isFilled ? _RadioModule["default"].filled : '', " ").concat(_RadioModule["default"]["centerPath".concat(palette)], " ").concat(customRadio, " ").concat(!isEditable ? "".concat(_RadioModule["default"].disabled) : '')
|
|
153
|
+
className: "".concat(_RadioModule["default"].radio, " ").concat(checked ? "".concat(_RadioModule["default"]["rdBox".concat(palette)]) : '', " \n ").concat(!isEditable ? '' : "".concat(_RadioModule["default"]["hover".concat(palette)]), " ").concat(_RadioModule["default"][size], " ").concat(isFilled ? _RadioModule["default"].filled : '', " ").concat(_RadioModule["default"]["centerPath".concat(palette)], " ").concat(customRadio, " ").concat(!isEditable ? "".concat(_RadioModule["default"].disabled) : '', " ").concat(secondaryText ? _RadioModule["default"].withSecondaryText : ''),
|
|
154
|
+
align: secondaryText ? "start" : undefined
|
|
147
155
|
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
148
156
|
type: "hidden",
|
|
149
157
|
id: id,
|
|
@@ -164,10 +172,10 @@ var Radio = /*#__PURE__*/function (_React$Component) {
|
|
|
164
172
|
cy: "20",
|
|
165
173
|
r: "11.03",
|
|
166
174
|
className: "".concat(_RadioModule["default"].centerPath)
|
|
167
|
-
}) : null))), text && /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
175
|
+
}) : null))), (text || secondaryText) && /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
168
176
|
flexible: true,
|
|
169
|
-
className:
|
|
170
|
-
}, /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
|
|
177
|
+
className: _RadioModule["default"].labelContainer
|
|
178
|
+
}, text && /*#__PURE__*/_react["default"].createElement(_Label["default"], _extends({
|
|
171
179
|
text: text,
|
|
172
180
|
palette: labelPalette,
|
|
173
181
|
size: labelSize,
|
|
@@ -176,8 +184,14 @@ var Radio = /*#__PURE__*/function (_React$Component) {
|
|
|
176
184
|
dataId: "".concat(text, "_label"),
|
|
177
185
|
variant: variant,
|
|
178
186
|
title: toolTip ? toolTip : text,
|
|
179
|
-
customClass: "".concat(checked && active ? "".concat(_RadioModule["default"]["".concat(palette, "checkedActive")]) : '', " \n
|
|
180
|
-
}, LabelProps))
|
|
187
|
+
customClass: "".concat(checked && active ? "".concat(_RadioModule["default"]["".concat(palette, "checkedActive")]) : '', " ").concat(disabled ? "".concat(_RadioModule["default"].disabled) : '', "\n ").concat(_RadioModule["default"]["".concat(palette, "Label")], " ").concat(isEditable ? _RadioModule["default"].pointer : '', " ").concat(isReadOnly ? _RadioModule["default"].readonly : '', " ").concat(customLabel)
|
|
188
|
+
}, LabelProps)), secondaryText ? /*#__PURE__*/_react["default"].createElement(_Typography["default"], _extends({
|
|
189
|
+
$ui_size: "12",
|
|
190
|
+
$ui_lineHeight: "1.2"
|
|
191
|
+
}, secondaryTextProps, {
|
|
192
|
+
$i18n_dataTitle: toolTip ? null : secondaryText,
|
|
193
|
+
$ui_className: "".concat(_RadioModule["default"].secondaryText, " ").concat(customSecondaryText)
|
|
194
|
+
}), secondaryText) : null), children, renderRightPlaceholderNode ? renderRightPlaceholderNode : null);
|
|
181
195
|
}
|
|
182
196
|
}]);
|
|
183
197
|
|
|
@@ -10,20 +10,25 @@
|
|
|
10
10
|
}[dir=ltr] .varClass {
|
|
11
11
|
--radio_label_margin: 0 0 0 var(--zd_size6);
|
|
12
12
|
}[dir=rtl] .varClass {
|
|
13
|
-
--radio_label_margin: 0 var(--zd_size6)
|
|
13
|
+
--radio_label_margin: 0 0 0 var(--zd_size6);
|
|
14
14
|
}
|
|
15
|
+
|
|
15
16
|
.container {
|
|
16
17
|
composes: varClass;
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
.pointer {
|
|
19
21
|
cursor: pointer;
|
|
20
22
|
}
|
|
23
|
+
|
|
21
24
|
.readonly, .disabled {
|
|
22
25
|
cursor: default;
|
|
23
26
|
}
|
|
27
|
+
|
|
24
28
|
.disabled {
|
|
25
29
|
opacity: 0.7
|
|
26
30
|
}
|
|
31
|
+
|
|
27
32
|
.radio {
|
|
28
33
|
composes: offSelection from '../common/common.module.css';
|
|
29
34
|
width: var(--radio_width);
|
|
@@ -32,10 +37,12 @@
|
|
|
32
37
|
background: var(--radio_bg_color);
|
|
33
38
|
border-radius: 50%;
|
|
34
39
|
}
|
|
40
|
+
|
|
35
41
|
.radio,
|
|
36
42
|
.centerPath {
|
|
37
43
|
fill: var(--radio_fill);
|
|
38
44
|
}
|
|
45
|
+
|
|
39
46
|
.filled {
|
|
40
47
|
--radio_bg_color: var(--zdt_radio_default_bg);
|
|
41
48
|
}
|
|
@@ -44,48 +51,66 @@
|
|
|
44
51
|
--radio_width: var(--zd_size16);
|
|
45
52
|
--radio_height: var(--zd_size16);
|
|
46
53
|
}
|
|
54
|
+
|
|
47
55
|
.small {
|
|
48
56
|
--radio_width: var(--zd_size13);
|
|
49
57
|
--radio_height: var(--zd_size13);
|
|
50
58
|
}
|
|
59
|
+
|
|
60
|
+
.medium.withSecondaryText {
|
|
61
|
+
margin-top: var(--zd_size1) ;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.small.withSecondaryText {
|
|
65
|
+
margin-top: var(--zd_size3) ;
|
|
66
|
+
}
|
|
67
|
+
|
|
51
68
|
.radioLabel {
|
|
52
69
|
font-size: 0 ;
|
|
53
70
|
display: block;
|
|
54
71
|
}
|
|
72
|
+
|
|
55
73
|
.rdBox {
|
|
56
74
|
fill: none;
|
|
57
75
|
stroke-width: var(--radio_stroke_width);
|
|
58
76
|
stroke-linecap: round;
|
|
59
77
|
stroke: inherit;
|
|
60
78
|
}
|
|
79
|
+
|
|
61
80
|
.centerPath {
|
|
62
81
|
--radio_fill: inherit;
|
|
63
82
|
stroke-width: var(--radio_inner_stroke_width);
|
|
64
83
|
transform-origin: center;
|
|
65
84
|
}
|
|
85
|
+
|
|
66
86
|
[dir=ltr] .checked .centerPath {
|
|
67
87
|
animation: circleAnimate var(--zd_transition3) ease forwards;
|
|
68
88
|
}
|
|
89
|
+
|
|
69
90
|
[dir=rtl] .checked .centerPath {
|
|
70
91
|
animation: circleAnimate var(--zd_transition3) ease forwards;
|
|
71
92
|
}
|
|
93
|
+
|
|
72
94
|
.rdBoxprimary,
|
|
73
95
|
.hoverEfffect:hover .hoverprimary
|
|
96
|
+
|
|
74
97
|
/* .hoverEfffect:focus .hoverprimary */
|
|
75
|
-
{
|
|
98
|
+
{
|
|
76
99
|
--radio_stroke_color: var(--zdt_radio_primary_stroke);
|
|
77
100
|
}
|
|
78
101
|
|
|
79
102
|
.rdBoxdanger,
|
|
80
103
|
.hoverEfffect:hover .hoverdanger
|
|
104
|
+
|
|
81
105
|
/* .hoverEfffect:focus .hoverdanger */
|
|
82
|
-
|
|
106
|
+
{
|
|
83
107
|
--radio_stroke_color: var(--zdt_radio_danger_stroke);
|
|
84
108
|
}
|
|
85
109
|
|
|
86
110
|
.centerPathprimary {
|
|
87
111
|
--radio_fill: var(--zdt_radio_primary_fill);
|
|
88
112
|
}
|
|
113
|
+
|
|
89
114
|
.centerPathdanger {
|
|
90
115
|
--radio_fill: var(--zdt_radio_danger_fill);
|
|
91
116
|
}
|
|
@@ -102,14 +127,22 @@
|
|
|
102
127
|
--label_text_color: var(--zdt_radio_label_danger_text);
|
|
103
128
|
}
|
|
104
129
|
|
|
105
|
-
.
|
|
130
|
+
.secondaryText {
|
|
131
|
+
color: var(--zdt_radio_secondary_text);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.labelContainer {
|
|
135
|
+
composes: dflex flexcolumn from '../common/common.module.css';
|
|
136
|
+
gap: var(--zd_size4) ;
|
|
106
137
|
margin: var(--radio_label_margin);
|
|
107
138
|
}
|
|
139
|
+
|
|
108
140
|
@keyframes circleAnimate {
|
|
109
141
|
0% {
|
|
110
142
|
transform: scale(0);
|
|
111
143
|
}
|
|
144
|
+
|
|
112
145
|
100% {
|
|
113
146
|
transform: scale(1);
|
|
114
147
|
}
|
|
115
|
-
}
|
|
148
|
+
}
|
|
@@ -243,4 +243,14 @@ describe('Radio', function () {
|
|
|
243
243
|
|
|
244
244
|
expect(asFragment()).toMatchSnapshot();
|
|
245
245
|
});
|
|
246
|
+
test('rendering secondaryText with checked state', function () {
|
|
247
|
+
var _render25 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Radio["default"], {
|
|
248
|
+
secondaryText: "Secondary text",
|
|
249
|
+
text: "Radio Text",
|
|
250
|
+
checked: true
|
|
251
|
+
})),
|
|
252
|
+
asFragment = _render25.asFragment;
|
|
253
|
+
|
|
254
|
+
expect(asFragment()).toMatchSnapshot();
|
|
255
|
+
});
|
|
246
256
|
});
|