@zohodesk/dot 1.8.2 → 1.8.4
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 +13 -0
- package/es/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
- package/es/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
- package/es/form/fields/Fields.module.css +8 -3
- package/es/form/fields/RadioField/RadioField.js +40 -14
- package/es/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
- package/es/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
- package/es/form/fields/RadioField/props/defaultProps.js +1 -0
- package/es/form/fields/RadioField/props/propTypes.js +6 -0
- package/es/form/fields/ValidationMessage/ValidationMessage.js +57 -16
- package/es/form/fields/ValidationMessage/__tests__/__snapshots__/ValidationMessage.spec.js.snap +2 -2
- package/es/form/fields/ValidationMessage/props/defaultProps.js +2 -1
- package/es/form/fields/ValidationMessage/props/propTypes.js +18 -4
- package/es/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
- package/lib/FlipCard/__tests__/__snapshots__/FlipCard.spec.js.snap +74 -74
- package/lib/form/fields/CheckBoxField/__tests__/__snapshots__/CheckBoxField.spec.js.snap +3 -3
- package/lib/form/fields/Fields.module.css +8 -3
- package/lib/form/fields/RadioField/RadioField.js +39 -15
- package/lib/form/fields/RadioField/__tests__/RadioField.spec.js +33 -0
- package/lib/form/fields/RadioField/__tests__/__snapshots__/RadioField.spec.js.snap +573 -77
- package/lib/form/fields/RadioField/props/defaultProps.js +1 -0
- package/lib/form/fields/RadioField/props/propTypes.js +6 -0
- package/lib/form/fields/ValidationMessage/ValidationMessage.js +73 -18
- package/lib/form/fields/ValidationMessage/__tests__/__snapshots__/ValidationMessage.spec.js.snap +2 -2
- package/lib/form/fields/ValidationMessage/props/defaultProps.js +2 -1
- package/lib/form/fields/ValidationMessage/props/propTypes.js +18 -4
- package/lib/list/AvatarFlip/__tests__/__snapshots__/AvatarFlip.spec.js.snap +1 -1
- package/package.json +9 -9
|
@@ -32,7 +32,7 @@ exports[`CheckBoxField rendering the custom children 1`] = `
|
|
|
32
32
|
tabindex="0"
|
|
33
33
|
>
|
|
34
34
|
<div
|
|
35
|
-
class="boxContainer
|
|
35
|
+
class="boxContainer medium filled shrinkOff"
|
|
36
36
|
data-id="boxComponent"
|
|
37
37
|
data-selector-id="box"
|
|
38
38
|
data-test-id="boxComponent"
|
|
@@ -123,7 +123,7 @@ exports[`CheckBoxField rendering the custom label children via renderLabelProps
|
|
|
123
123
|
tabindex="0"
|
|
124
124
|
>
|
|
125
125
|
<div
|
|
126
|
-
class="boxContainer
|
|
126
|
+
class="boxContainer medium filled shrinkOff"
|
|
127
127
|
data-id="boxComponent"
|
|
128
128
|
data-selector-id="box"
|
|
129
129
|
data-test-id="boxComponent"
|
|
@@ -214,7 +214,7 @@ exports[`CheckBoxField rendering the defult props 1`] = `
|
|
|
214
214
|
tabindex="0"
|
|
215
215
|
>
|
|
216
216
|
<div
|
|
217
|
-
class="boxContainer
|
|
217
|
+
class="boxContainer medium filled shrinkOff"
|
|
218
218
|
data-id="boxComponent"
|
|
219
219
|
data-selector-id="box"
|
|
220
220
|
data-test-id="boxComponent"
|
|
@@ -71,11 +71,16 @@
|
|
|
71
71
|
}
|
|
72
72
|
.radioBox {
|
|
73
73
|
max-width: 100% ;
|
|
74
|
-
height: var(--zd_size36) ;
|
|
75
74
|
transition: border var(--zd_transition3);
|
|
76
|
-
padding: 0 var(--zd_size10) ;
|
|
77
75
|
border: 1px solid var(--zdt_radiofield_box_border);
|
|
78
|
-
border-radius: 6px
|
|
76
|
+
border-radius: 6px;
|
|
77
|
+
}
|
|
78
|
+
.radioBox.primaryTextOnly {
|
|
79
|
+
height: var(--zd_size36) ;
|
|
80
|
+
padding: 0 var(--zd_size10) ;
|
|
81
|
+
}
|
|
82
|
+
.radioBox.withSecondaryText {
|
|
83
|
+
padding: var(--zd_size18) var(--zd_size16) ;
|
|
79
84
|
}
|
|
80
85
|
.hoverableRadioBox:hover, .radioBoxActive {
|
|
81
86
|
border-color: var(--zdt_radiofield_box_active_border)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**** Libraries ****/
|
|
2
2
|
import React, { PureComponent } from 'react';
|
|
3
|
+
import { compileClassNames } from '@zohodesk/utils';
|
|
3
4
|
import { defaultProps } from "./props/defaultProps";
|
|
4
5
|
import { propTypes } from "./props/propTypes";
|
|
5
6
|
/**** Components ****/
|
|
@@ -99,6 +100,7 @@ export default class RadioField extends PureComponent {
|
|
|
99
100
|
isReadOnly,
|
|
100
101
|
isBoxStyle,
|
|
101
102
|
variant,
|
|
103
|
+
customClass,
|
|
102
104
|
customProps
|
|
103
105
|
} = this.props;
|
|
104
106
|
const {
|
|
@@ -108,8 +110,14 @@ export default class RadioField extends PureComponent {
|
|
|
108
110
|
ValidationMessageProps1 = {},
|
|
109
111
|
ValidationMessageProps2 = {}
|
|
110
112
|
} = customProps;
|
|
113
|
+
const {
|
|
114
|
+
customWrapperClass = '',
|
|
115
|
+
customLabelClass = '',
|
|
116
|
+
customRadioWrapperClass = '',
|
|
117
|
+
customRadioClass = ''
|
|
118
|
+
} = customClass;
|
|
111
119
|
return /*#__PURE__*/React.createElement("div", {
|
|
112
|
-
className: `${style.container} ${isDisabled ? style.disabled : isReadOnly ? style.readonly : ''}`,
|
|
120
|
+
className: `${style.container} ${isDisabled ? style.disabled : isReadOnly ? style.readonly : ''} ${customWrapperClass}`,
|
|
113
121
|
"data-title": isDisabled ? title : null,
|
|
114
122
|
"data-selector-id": dataSelectorId
|
|
115
123
|
}, labelName && /*#__PURE__*/React.createElement(Label, {
|
|
@@ -117,7 +125,7 @@ export default class RadioField extends PureComponent {
|
|
|
117
125
|
size: "medium",
|
|
118
126
|
id: id,
|
|
119
127
|
palette: isMandatory ? 'mandatory' : isDisabled ? 'primary' : 'default',
|
|
120
|
-
customClass: `${style.fieldLabel} ${isMandatory ? style.labelMandatory : ''}`,
|
|
128
|
+
customClass: `${style.fieldLabel} ${isMandatory ? style.labelMandatory : ''} ${customLabelClass}`,
|
|
121
129
|
dataId: isDisabled ? `${dataId}_label_disabled` : isMandatory ? `${dataId}_label_mandatory` : `${dataId}_label`,
|
|
122
130
|
...LabelProps
|
|
123
131
|
}), /*#__PURE__*/React.createElement("div", {
|
|
@@ -128,14 +136,32 @@ export default class RadioField extends PureComponent {
|
|
|
128
136
|
value,
|
|
129
137
|
disabled = false,
|
|
130
138
|
tooltip,
|
|
131
|
-
infoTooltip
|
|
139
|
+
infoTooltip,
|
|
140
|
+
secondaryText,
|
|
141
|
+
renderRightPlaceholderNode,
|
|
142
|
+
customProps
|
|
132
143
|
} = option;
|
|
133
144
|
let isDisabledState = disabled || isDisabled;
|
|
134
145
|
let isChecked = selectedValue == value;
|
|
146
|
+
const rightPlaceholderNode = !!infoTooltip ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Icon, {
|
|
147
|
+
name: "ZD-GN-info",
|
|
148
|
+
size: "16",
|
|
149
|
+
title: infoTooltip,
|
|
150
|
+
iconClass: style.infoIcon,
|
|
151
|
+
...InfoIconProps
|
|
152
|
+
}), renderRightPlaceholderNode) : renderRightPlaceholderNode;
|
|
153
|
+
const radioBoxClasses = isBoxStyle ? compileClassNames({
|
|
154
|
+
[customRadioClass]: !!customRadioClass,
|
|
155
|
+
[style.radioBox]: true,
|
|
156
|
+
[style.withSecondaryText]: !!secondaryText,
|
|
157
|
+
[style.primaryTextOnly]: !secondaryText,
|
|
158
|
+
[style.hoverableRadioBox]: !isDisabledState,
|
|
159
|
+
[style.radioBoxActive]: isChecked
|
|
160
|
+
}) : '';
|
|
135
161
|
return /*#__PURE__*/React.createElement("span", {
|
|
136
|
-
key:
|
|
137
|
-
className: `${!isBoxStyle ? style.radio : ''} ${style.radioWrap}`
|
|
138
|
-
}, /*#__PURE__*/React.createElement(Radio, {
|
|
162
|
+
key: text,
|
|
163
|
+
className: `${!isBoxStyle ? style.radio : ''} ${style.radioWrap} ${customRadioWrapperClass}`
|
|
164
|
+
}, /*#__PURE__*/React.createElement(Radio, { ...customProps,
|
|
139
165
|
id: index,
|
|
140
166
|
value: value,
|
|
141
167
|
name: id,
|
|
@@ -153,22 +179,22 @@ export default class RadioField extends PureComponent {
|
|
|
153
179
|
dataId: dataId,
|
|
154
180
|
isReadOnly: isReadOnly,
|
|
155
181
|
variant: variant,
|
|
182
|
+
secondaryText: secondaryText,
|
|
156
183
|
...RadioProps,
|
|
157
184
|
a11y: {
|
|
158
185
|
tabIndex: !!selectedValue ? isChecked ? '0' : '-1' : index === 0 ? '0' : '-1',
|
|
159
186
|
...RadioProps.a11y
|
|
160
187
|
},
|
|
161
188
|
customClass: {
|
|
162
|
-
customRadioWrap:
|
|
189
|
+
customRadioWrap: radioBoxClasses,
|
|
163
190
|
...RadioProps.customClass
|
|
191
|
+
},
|
|
192
|
+
customProps: { ...RadioProps.customProps,
|
|
193
|
+
LabelProps: { ...(RadioProps.customProps ? RadioProps.customProps.LabelProps : undefined),
|
|
194
|
+
renderRightPlaceholderNode: rightPlaceholderNode
|
|
195
|
+
}
|
|
164
196
|
}
|
|
165
|
-
}
|
|
166
|
-
name: "ZD-GN-info",
|
|
167
|
-
size: "16",
|
|
168
|
-
title: infoTooltip,
|
|
169
|
-
iconClass: style.infoIcon,
|
|
170
|
-
...InfoIconProps
|
|
171
|
-
}) : null));
|
|
197
|
+
}));
|
|
172
198
|
})), validationMessage && /*#__PURE__*/React.createElement(ValidationMessage, {
|
|
173
199
|
text: validationMessage,
|
|
174
200
|
palette: validationPalette,
|
|
@@ -17,6 +17,22 @@ const options = [{
|
|
|
17
17
|
text: 'Kolkata',
|
|
18
18
|
value: '4'
|
|
19
19
|
}];
|
|
20
|
+
let optionsWithsecondaryText = [{
|
|
21
|
+
text: 'Chennai',
|
|
22
|
+
value: '1',
|
|
23
|
+
secondaryText: 'Tamil Nadu Capital'
|
|
24
|
+
}, {
|
|
25
|
+
text: 'Mumbai',
|
|
26
|
+
value: '2',
|
|
27
|
+
secondaryText: 'Maharashtra Capital',
|
|
28
|
+
tooltip: 'Disabled Option',
|
|
29
|
+
disabled: true
|
|
30
|
+
}, {
|
|
31
|
+
text: 'Delhi',
|
|
32
|
+
value: '3',
|
|
33
|
+
secondaryText: 'Capital of India',
|
|
34
|
+
infoTooltip: 'Capital of India'
|
|
35
|
+
}];
|
|
20
36
|
describe('RadioField', () => {
|
|
21
37
|
test('rendering the defult props', () => {
|
|
22
38
|
const {
|
|
@@ -43,4 +59,21 @@ describe('RadioField', () => {
|
|
|
43
59
|
}));
|
|
44
60
|
expect(asFragment()).toMatchSnapshot();
|
|
45
61
|
});
|
|
62
|
+
test('rendering with secondaryTextOptions', () => {
|
|
63
|
+
const {
|
|
64
|
+
asFragment
|
|
65
|
+
} = render( /*#__PURE__*/React.createElement(RadioField, {
|
|
66
|
+
options: optionsWithsecondaryText
|
|
67
|
+
}));
|
|
68
|
+
expect(asFragment()).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
test('rendering with secondaryTextOptions & isBoxStyle', () => {
|
|
71
|
+
const {
|
|
72
|
+
asFragment
|
|
73
|
+
} = render( /*#__PURE__*/React.createElement(RadioField, {
|
|
74
|
+
options: optionsWithsecondaryText,
|
|
75
|
+
isBoxStyle: true
|
|
76
|
+
}));
|
|
77
|
+
expect(asFragment()).toMatchSnapshot();
|
|
78
|
+
});
|
|
46
79
|
});
|