@zohodesk/components 1.0.0-temp-199.21 → 1.0.0-temp-249
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 +12 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +6 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +6 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +6 -0
- package/es/ListItem/ListItem.module.css +18 -17
- package/es/ListItem/ListItemWithAvatar.js +2 -4
- package/es/ListItem/ListItemWithCheckBox.js +2 -4
- package/es/ListItem/ListItemWithIcon.js +2 -4
- package/es/ListItem/ListItemWithRadio.js +2 -4
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +2 -6
- package/es/MultiSelect/MultiSelect.js +2 -2
- package/es/MultiSelect/Suggestions.js +2 -7
- package/es/MultiSelect/props/defaultProps.js +0 -2
- package/es/MultiSelect/props/propTypes.js +3 -11
- package/es/Provider/LibraryContext.js +11 -3
- package/es/Select/GroupSelect.js +1 -1
- package/es/Select/SelectWithAvatar.js +3 -3
- package/es/Select/SelectWithIcon.js +3 -10
- package/es/Select/props/defaultProps.js +2 -4
- package/es/Select/props/propTypes.js +3 -11
- package/es/common/common.module.css +1 -1
- package/es/v1/Label/Label.js +94 -33
- package/es/v1/Label/__tests__/Label.spec.js +204 -0
- package/es/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +428 -0
- package/es/v1/Label/constants/index.js +8 -0
- package/es/v1/Label/css/Label_v1.module.css +34 -0
- package/es/v1/Label/css/cssJSLogic.js +44 -0
- package/es/v1/Label/props/defaultProps.js +14 -9
- package/es/v1/Label/props/propTypes.js +34 -14
- package/lib/ListItem/ListItem.module.css +18 -17
- package/lib/ListItem/ListItemWithAvatar.js +3 -5
- package/lib/ListItem/ListItemWithCheckBox.js +2 -4
- package/lib/ListItem/ListItemWithIcon.js +3 -5
- package/lib/ListItem/ListItemWithRadio.js +2 -4
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +3 -8
- package/lib/MultiSelect/MultiSelect.js +2 -2
- package/lib/MultiSelect/Suggestions.js +2 -6
- package/lib/MultiSelect/props/defaultProps.js +0 -2
- package/lib/MultiSelect/props/propTypes.js +5 -13
- package/lib/Provider/LibraryContext.js +11 -3
- package/lib/Select/GroupSelect.js +1 -2
- package/lib/Select/SelectWithAvatar.js +3 -4
- package/lib/Select/SelectWithIcon.js +3 -10
- package/lib/Select/props/defaultProps.js +3 -5
- package/lib/Select/props/propTypes.js +3 -11
- package/lib/common/common.module.css +1 -1
- package/lib/v1/Label/Label.js +102 -36
- package/lib/v1/Label/__tests__/Label.spec.js +211 -0
- package/lib/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +428 -0
- package/lib/v1/Label/constants/index.js +16 -0
- package/lib/v1/Label/css/Label_v1.module.css +34 -0
- package/lib/v1/Label/css/cssJSLogic.js +45 -0
- package/lib/v1/Label/props/defaultProps.js +16 -11
- package/lib/v1/Label/props/propTypes.js +36 -16
- package/package.json +7 -7
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
|
+
import Label from "../Label"; // Hoisted enum values (PropTypes.oneOf enforcement)
|
|
4
|
+
|
|
5
|
+
const REQUIRED_TYPE_VALUES = ['asterisk', 'text'];
|
|
6
|
+
const SIZE_VALUES = ['small', 'medium'];
|
|
7
|
+
const PALETTE_VALUES = ['default', 'secondary'];
|
|
8
|
+
const TEXT_WEIGHT_VALUES = ['regular', 'semibold'];
|
|
9
|
+
const LAYOUT_VALUES = ['inline', 'block'];
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
describe('Label - Snapshot', () => {
|
|
12
|
+
test('Render with default props', () => {
|
|
13
|
+
const {
|
|
14
|
+
asFragment
|
|
15
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
16
|
+
text: "Label text"
|
|
17
|
+
}));
|
|
18
|
+
expect(asFragment()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
test.each(REQUIRED_TYPE_VALUES)('Render with requiredType=%s', value => {
|
|
21
|
+
const {
|
|
22
|
+
asFragment
|
|
23
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
24
|
+
text: "Label text",
|
|
25
|
+
isRequired: true,
|
|
26
|
+
requiredType: value
|
|
27
|
+
}));
|
|
28
|
+
expect(asFragment()).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
test.each(SIZE_VALUES)('Render with size=%s', value => {
|
|
31
|
+
const {
|
|
32
|
+
asFragment
|
|
33
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
34
|
+
text: "Label text",
|
|
35
|
+
size: value
|
|
36
|
+
}));
|
|
37
|
+
expect(asFragment()).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
test.each(PALETTE_VALUES)('Render with palette=%s', value => {
|
|
40
|
+
const {
|
|
41
|
+
asFragment
|
|
42
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
43
|
+
text: "Label text",
|
|
44
|
+
palette: value
|
|
45
|
+
}));
|
|
46
|
+
expect(asFragment()).toMatchSnapshot();
|
|
47
|
+
});
|
|
48
|
+
test.each(TEXT_WEIGHT_VALUES)('Render with textWeight=%s', value => {
|
|
49
|
+
const {
|
|
50
|
+
asFragment
|
|
51
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
52
|
+
text: "Label text",
|
|
53
|
+
textWeight: value
|
|
54
|
+
}));
|
|
55
|
+
expect(asFragment()).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
test.each(LAYOUT_VALUES)('Render with layout=%s', value => {
|
|
58
|
+
const {
|
|
59
|
+
asFragment
|
|
60
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
61
|
+
text: "Label text",
|
|
62
|
+
layout: value
|
|
63
|
+
}));
|
|
64
|
+
expect(asFragment()).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
test('Render with shouldHighlightRequired=true', () => {
|
|
67
|
+
const {
|
|
68
|
+
asFragment
|
|
69
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
70
|
+
text: "Label text",
|
|
71
|
+
isRequired: true,
|
|
72
|
+
shouldHighlightRequired: true
|
|
73
|
+
}));
|
|
74
|
+
expect(asFragment()).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
test('Render with isClipped=true', () => {
|
|
77
|
+
const {
|
|
78
|
+
asFragment
|
|
79
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
80
|
+
text: "Label text",
|
|
81
|
+
isClipped: true
|
|
82
|
+
}));
|
|
83
|
+
expect(asFragment()).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
test('Render with isRequired=true', () => {
|
|
86
|
+
const {
|
|
87
|
+
asFragment
|
|
88
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
89
|
+
text: "Label text",
|
|
90
|
+
isRequired: true
|
|
91
|
+
}));
|
|
92
|
+
expect(asFragment()).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
test('Render with isDisabled=true', () => {
|
|
95
|
+
const {
|
|
96
|
+
asFragment
|
|
97
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
98
|
+
text: "Label text",
|
|
99
|
+
isDisabled: true
|
|
100
|
+
}));
|
|
101
|
+
expect(asFragment()).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
test('Render with isReadOnly=true', () => {
|
|
104
|
+
const {
|
|
105
|
+
asFragment
|
|
106
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
107
|
+
text: "Label text",
|
|
108
|
+
isReadOnly: true
|
|
109
|
+
}));
|
|
110
|
+
expect(asFragment()).toMatchSnapshot();
|
|
111
|
+
});
|
|
112
|
+
test('Render with htmlFor', () => {
|
|
113
|
+
const {
|
|
114
|
+
asFragment
|
|
115
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
116
|
+
text: "Label text",
|
|
117
|
+
htmlFor: "input-id"
|
|
118
|
+
}));
|
|
119
|
+
expect(asFragment()).toMatchSnapshot();
|
|
120
|
+
});
|
|
121
|
+
test('Render with i18nKeys', () => {
|
|
122
|
+
const {
|
|
123
|
+
asFragment
|
|
124
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
125
|
+
text: "Label text",
|
|
126
|
+
isRequired: true,
|
|
127
|
+
requiredType: "text",
|
|
128
|
+
i18nKeys: {
|
|
129
|
+
requiredText: 'Custom Required'
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
expect(asFragment()).toMatchSnapshot();
|
|
133
|
+
});
|
|
134
|
+
test('Render with customClass', () => {
|
|
135
|
+
const {
|
|
136
|
+
asFragment
|
|
137
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
138
|
+
text: "Label text",
|
|
139
|
+
customClass: {
|
|
140
|
+
container: 'custom-container',
|
|
141
|
+
label: 'custom-label'
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
expect(asFragment()).toMatchSnapshot();
|
|
145
|
+
});
|
|
146
|
+
test('Render with customProps', () => {
|
|
147
|
+
const {
|
|
148
|
+
asFragment
|
|
149
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
150
|
+
text: "Label text",
|
|
151
|
+
customProps: {
|
|
152
|
+
container: {
|
|
153
|
+
$flag_shrink: true
|
|
154
|
+
},
|
|
155
|
+
label: {
|
|
156
|
+
$ui_lineClamp: '2'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
expect(asFragment()).toMatchSnapshot();
|
|
161
|
+
});
|
|
162
|
+
test('Render with customId and testId', () => {
|
|
163
|
+
const {
|
|
164
|
+
asFragment
|
|
165
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
166
|
+
text: "Label text",
|
|
167
|
+
customId: "label-customId",
|
|
168
|
+
testId: "label-testId"
|
|
169
|
+
}));
|
|
170
|
+
expect(asFragment()).toMatchSnapshot();
|
|
171
|
+
});
|
|
172
|
+
test('Render with tag attributes', () => {
|
|
173
|
+
const {
|
|
174
|
+
asFragment
|
|
175
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
176
|
+
text: "Label text",
|
|
177
|
+
tagAttributes: {
|
|
178
|
+
container: {
|
|
179
|
+
'data-custom-attr': 'true'
|
|
180
|
+
},
|
|
181
|
+
label: {
|
|
182
|
+
'data-custom-attr': 'true'
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
expect(asFragment()).toMatchSnapshot();
|
|
187
|
+
});
|
|
188
|
+
test('Render with a11y attributes', () => {
|
|
189
|
+
const {
|
|
190
|
+
asFragment
|
|
191
|
+
} = render( /*#__PURE__*/React.createElement(Label, {
|
|
192
|
+
text: "Label text",
|
|
193
|
+
a11yAttributes: {
|
|
194
|
+
container: {
|
|
195
|
+
role: 'group'
|
|
196
|
+
},
|
|
197
|
+
label: {
|
|
198
|
+
'aria-label': 'Custom label'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
expect(asFragment()).toMatchSnapshot();
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Label - Snapshot Render with a11y attributes 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="inlineFlex row alignItems_center container default"
|
|
7
|
+
data-id="flex"
|
|
8
|
+
data-test-id="flex"
|
|
9
|
+
role="group"
|
|
10
|
+
>
|
|
11
|
+
<label
|
|
12
|
+
aria-label="Custom label"
|
|
13
|
+
class="size14 font_regular label"
|
|
14
|
+
data-title="Label text"
|
|
15
|
+
>
|
|
16
|
+
Label text
|
|
17
|
+
</label>
|
|
18
|
+
</div>
|
|
19
|
+
</DocumentFragment>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`Label - Snapshot Render with customClass 1`] = `
|
|
23
|
+
<DocumentFragment>
|
|
24
|
+
<div
|
|
25
|
+
class="inlineFlex row alignItems_center container default custom-container"
|
|
26
|
+
data-id="flex"
|
|
27
|
+
data-test-id="flex"
|
|
28
|
+
>
|
|
29
|
+
<label
|
|
30
|
+
class="size14 font_regular label custom-label"
|
|
31
|
+
data-title="Label text"
|
|
32
|
+
>
|
|
33
|
+
Label text
|
|
34
|
+
</label>
|
|
35
|
+
</div>
|
|
36
|
+
</DocumentFragment>
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
exports[`Label - Snapshot Render with customId and testId 1`] = `
|
|
40
|
+
<DocumentFragment>
|
|
41
|
+
<div
|
|
42
|
+
class="inlineFlex row alignItems_center container default"
|
|
43
|
+
data-id="label-customId"
|
|
44
|
+
data-selector-id="label-customId"
|
|
45
|
+
data-test-id="label-testId"
|
|
46
|
+
>
|
|
47
|
+
<label
|
|
48
|
+
class="size14 font_regular label"
|
|
49
|
+
data-title="Label text"
|
|
50
|
+
>
|
|
51
|
+
Label text
|
|
52
|
+
</label>
|
|
53
|
+
</div>
|
|
54
|
+
</DocumentFragment>
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
exports[`Label - Snapshot Render with customProps 1`] = `
|
|
58
|
+
<DocumentFragment>
|
|
59
|
+
<div
|
|
60
|
+
class="inlineFlex row alignItems_center shrink container default"
|
|
61
|
+
data-id="flex"
|
|
62
|
+
data-test-id="flex"
|
|
63
|
+
>
|
|
64
|
+
<label
|
|
65
|
+
class="size14 lineclamp_2 font_regular label"
|
|
66
|
+
data-title="Label text"
|
|
67
|
+
>
|
|
68
|
+
Label text
|
|
69
|
+
</label>
|
|
70
|
+
</div>
|
|
71
|
+
</DocumentFragment>
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`Label - Snapshot Render with default props 1`] = `
|
|
75
|
+
<DocumentFragment>
|
|
76
|
+
<div
|
|
77
|
+
class="inlineFlex row alignItems_center container default"
|
|
78
|
+
data-id="flex"
|
|
79
|
+
data-test-id="flex"
|
|
80
|
+
>
|
|
81
|
+
<label
|
|
82
|
+
class="size14 font_regular label"
|
|
83
|
+
data-title="Label text"
|
|
84
|
+
>
|
|
85
|
+
Label text
|
|
86
|
+
</label>
|
|
87
|
+
</div>
|
|
88
|
+
</DocumentFragment>
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
exports[`Label - Snapshot Render with htmlFor 1`] = `
|
|
92
|
+
<DocumentFragment>
|
|
93
|
+
<div
|
|
94
|
+
class="inlineFlex row alignItems_center container default"
|
|
95
|
+
data-id="flex"
|
|
96
|
+
data-test-id="flex"
|
|
97
|
+
>
|
|
98
|
+
<label
|
|
99
|
+
class="size14 font_regular label"
|
|
100
|
+
data-title="Label text"
|
|
101
|
+
for="input-id"
|
|
102
|
+
>
|
|
103
|
+
Label text
|
|
104
|
+
</label>
|
|
105
|
+
</div>
|
|
106
|
+
</DocumentFragment>
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
exports[`Label - Snapshot Render with i18nKeys 1`] = `
|
|
110
|
+
<DocumentFragment>
|
|
111
|
+
<div
|
|
112
|
+
class="inlineFlex row alignItems_center container default"
|
|
113
|
+
data-id="flex"
|
|
114
|
+
data-test-id="flex"
|
|
115
|
+
>
|
|
116
|
+
<label
|
|
117
|
+
class="size14 font_regular label"
|
|
118
|
+
data-title="Label text"
|
|
119
|
+
>
|
|
120
|
+
Label text
|
|
121
|
+
<span
|
|
122
|
+
aria-hidden="true"
|
|
123
|
+
class="size14 font_regular requiredCommon flexshrink requiredText"
|
|
124
|
+
>
|
|
125
|
+
(Custom Required)
|
|
126
|
+
</span>
|
|
127
|
+
</label>
|
|
128
|
+
</div>
|
|
129
|
+
</DocumentFragment>
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
exports[`Label - Snapshot Render with isClipped=true 1`] = `
|
|
133
|
+
<DocumentFragment>
|
|
134
|
+
<div
|
|
135
|
+
class="inlineFlex row alignItems_center container default"
|
|
136
|
+
data-id="flex"
|
|
137
|
+
data-test-id="flex"
|
|
138
|
+
>
|
|
139
|
+
<label
|
|
140
|
+
class="dotted size14 font_regular label"
|
|
141
|
+
data-title="Label text"
|
|
142
|
+
>
|
|
143
|
+
Label text
|
|
144
|
+
</label>
|
|
145
|
+
</div>
|
|
146
|
+
</DocumentFragment>
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
exports[`Label - Snapshot Render with isDisabled=true 1`] = `
|
|
150
|
+
<DocumentFragment>
|
|
151
|
+
<div
|
|
152
|
+
class="inlineFlex row alignItems_center container disabled"
|
|
153
|
+
data-id="flex"
|
|
154
|
+
data-test-id="flex"
|
|
155
|
+
>
|
|
156
|
+
<label
|
|
157
|
+
class="size14 font_regular label"
|
|
158
|
+
data-title="Label text"
|
|
159
|
+
>
|
|
160
|
+
Label text
|
|
161
|
+
</label>
|
|
162
|
+
</div>
|
|
163
|
+
</DocumentFragment>
|
|
164
|
+
`;
|
|
165
|
+
|
|
166
|
+
exports[`Label - Snapshot Render with isReadOnly=true 1`] = `
|
|
167
|
+
<DocumentFragment>
|
|
168
|
+
<div
|
|
169
|
+
class="inlineFlex row alignItems_center container readonly default"
|
|
170
|
+
data-id="flex"
|
|
171
|
+
data-test-id="flex"
|
|
172
|
+
>
|
|
173
|
+
<label
|
|
174
|
+
class="size14 font_regular label"
|
|
175
|
+
data-title="Label text"
|
|
176
|
+
>
|
|
177
|
+
Label text
|
|
178
|
+
</label>
|
|
179
|
+
</div>
|
|
180
|
+
</DocumentFragment>
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
exports[`Label - Snapshot Render with isRequired=true 1`] = `
|
|
184
|
+
<DocumentFragment>
|
|
185
|
+
<div
|
|
186
|
+
class="inlineFlex row alignItems_center container default"
|
|
187
|
+
data-id="flex"
|
|
188
|
+
data-test-id="flex"
|
|
189
|
+
>
|
|
190
|
+
<label
|
|
191
|
+
class="size14 font_regular label"
|
|
192
|
+
data-title="Label text"
|
|
193
|
+
>
|
|
194
|
+
Label text
|
|
195
|
+
<span
|
|
196
|
+
aria-hidden="true"
|
|
197
|
+
class="size14 font_regular requiredCommon flexshrink asterisk"
|
|
198
|
+
>
|
|
199
|
+
*
|
|
200
|
+
</span>
|
|
201
|
+
</label>
|
|
202
|
+
</div>
|
|
203
|
+
</DocumentFragment>
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
exports[`Label - Snapshot Render with layout=block 1`] = `
|
|
207
|
+
<DocumentFragment>
|
|
208
|
+
<div
|
|
209
|
+
class="flex row alignItems_center container default"
|
|
210
|
+
data-id="flex"
|
|
211
|
+
data-test-id="flex"
|
|
212
|
+
>
|
|
213
|
+
<label
|
|
214
|
+
class="size14 font_regular label"
|
|
215
|
+
data-title="Label text"
|
|
216
|
+
>
|
|
217
|
+
Label text
|
|
218
|
+
</label>
|
|
219
|
+
</div>
|
|
220
|
+
</DocumentFragment>
|
|
221
|
+
`;
|
|
222
|
+
|
|
223
|
+
exports[`Label - Snapshot Render with layout=inline 1`] = `
|
|
224
|
+
<DocumentFragment>
|
|
225
|
+
<div
|
|
226
|
+
class="inlineFlex row alignItems_center container default"
|
|
227
|
+
data-id="flex"
|
|
228
|
+
data-test-id="flex"
|
|
229
|
+
>
|
|
230
|
+
<label
|
|
231
|
+
class="size14 font_regular label"
|
|
232
|
+
data-title="Label text"
|
|
233
|
+
>
|
|
234
|
+
Label text
|
|
235
|
+
</label>
|
|
236
|
+
</div>
|
|
237
|
+
</DocumentFragment>
|
|
238
|
+
`;
|
|
239
|
+
|
|
240
|
+
exports[`Label - Snapshot Render with palette=default 1`] = `
|
|
241
|
+
<DocumentFragment>
|
|
242
|
+
<div
|
|
243
|
+
class="inlineFlex row alignItems_center container default"
|
|
244
|
+
data-id="flex"
|
|
245
|
+
data-test-id="flex"
|
|
246
|
+
>
|
|
247
|
+
<label
|
|
248
|
+
class="size14 font_regular label"
|
|
249
|
+
data-title="Label text"
|
|
250
|
+
>
|
|
251
|
+
Label text
|
|
252
|
+
</label>
|
|
253
|
+
</div>
|
|
254
|
+
</DocumentFragment>
|
|
255
|
+
`;
|
|
256
|
+
|
|
257
|
+
exports[`Label - Snapshot Render with palette=secondary 1`] = `
|
|
258
|
+
<DocumentFragment>
|
|
259
|
+
<div
|
|
260
|
+
class="inlineFlex row alignItems_center container secondary"
|
|
261
|
+
data-id="flex"
|
|
262
|
+
data-test-id="flex"
|
|
263
|
+
>
|
|
264
|
+
<label
|
|
265
|
+
class="size14 font_regular label"
|
|
266
|
+
data-title="Label text"
|
|
267
|
+
>
|
|
268
|
+
Label text
|
|
269
|
+
</label>
|
|
270
|
+
</div>
|
|
271
|
+
</DocumentFragment>
|
|
272
|
+
`;
|
|
273
|
+
|
|
274
|
+
exports[`Label - Snapshot Render with requiredType=asterisk 1`] = `
|
|
275
|
+
<DocumentFragment>
|
|
276
|
+
<div
|
|
277
|
+
class="inlineFlex row alignItems_center container default"
|
|
278
|
+
data-id="flex"
|
|
279
|
+
data-test-id="flex"
|
|
280
|
+
>
|
|
281
|
+
<label
|
|
282
|
+
class="size14 font_regular label"
|
|
283
|
+
data-title="Label text"
|
|
284
|
+
>
|
|
285
|
+
Label text
|
|
286
|
+
<span
|
|
287
|
+
aria-hidden="true"
|
|
288
|
+
class="size14 font_regular requiredCommon flexshrink asterisk"
|
|
289
|
+
>
|
|
290
|
+
*
|
|
291
|
+
</span>
|
|
292
|
+
</label>
|
|
293
|
+
</div>
|
|
294
|
+
</DocumentFragment>
|
|
295
|
+
`;
|
|
296
|
+
|
|
297
|
+
exports[`Label - Snapshot Render with requiredType=text 1`] = `
|
|
298
|
+
<DocumentFragment>
|
|
299
|
+
<div
|
|
300
|
+
class="inlineFlex row alignItems_center container default"
|
|
301
|
+
data-id="flex"
|
|
302
|
+
data-test-id="flex"
|
|
303
|
+
>
|
|
304
|
+
<label
|
|
305
|
+
class="size14 font_regular label"
|
|
306
|
+
data-title="Label text"
|
|
307
|
+
>
|
|
308
|
+
Label text
|
|
309
|
+
<span
|
|
310
|
+
aria-hidden="true"
|
|
311
|
+
class="size14 font_regular requiredCommon flexshrink requiredText"
|
|
312
|
+
>
|
|
313
|
+
(Required)
|
|
314
|
+
</span>
|
|
315
|
+
</label>
|
|
316
|
+
</div>
|
|
317
|
+
</DocumentFragment>
|
|
318
|
+
`;
|
|
319
|
+
|
|
320
|
+
exports[`Label - Snapshot Render with shouldHighlightRequired=true 1`] = `
|
|
321
|
+
<DocumentFragment>
|
|
322
|
+
<div
|
|
323
|
+
class="inlineFlex row alignItems_center container required"
|
|
324
|
+
data-id="flex"
|
|
325
|
+
data-test-id="flex"
|
|
326
|
+
>
|
|
327
|
+
<label
|
|
328
|
+
class="size14 font_regular label"
|
|
329
|
+
data-title="Label text"
|
|
330
|
+
>
|
|
331
|
+
Label text
|
|
332
|
+
<span
|
|
333
|
+
aria-hidden="true"
|
|
334
|
+
class="size14 font_regular requiredCommon flexshrink asterisk"
|
|
335
|
+
>
|
|
336
|
+
*
|
|
337
|
+
</span>
|
|
338
|
+
</label>
|
|
339
|
+
</div>
|
|
340
|
+
</DocumentFragment>
|
|
341
|
+
`;
|
|
342
|
+
|
|
343
|
+
exports[`Label - Snapshot Render with size=medium 1`] = `
|
|
344
|
+
<DocumentFragment>
|
|
345
|
+
<div
|
|
346
|
+
class="inlineFlex row alignItems_center container default"
|
|
347
|
+
data-id="flex"
|
|
348
|
+
data-test-id="flex"
|
|
349
|
+
>
|
|
350
|
+
<label
|
|
351
|
+
class="size14 font_regular label"
|
|
352
|
+
data-title="Label text"
|
|
353
|
+
>
|
|
354
|
+
Label text
|
|
355
|
+
</label>
|
|
356
|
+
</div>
|
|
357
|
+
</DocumentFragment>
|
|
358
|
+
`;
|
|
359
|
+
|
|
360
|
+
exports[`Label - Snapshot Render with size=small 1`] = `
|
|
361
|
+
<DocumentFragment>
|
|
362
|
+
<div
|
|
363
|
+
class="inlineFlex row alignItems_center container default"
|
|
364
|
+
data-id="flex"
|
|
365
|
+
data-test-id="flex"
|
|
366
|
+
>
|
|
367
|
+
<label
|
|
368
|
+
class="size13 font_regular label"
|
|
369
|
+
data-title="Label text"
|
|
370
|
+
>
|
|
371
|
+
Label text
|
|
372
|
+
</label>
|
|
373
|
+
</div>
|
|
374
|
+
</DocumentFragment>
|
|
375
|
+
`;
|
|
376
|
+
|
|
377
|
+
exports[`Label - Snapshot Render with tag attributes 1`] = `
|
|
378
|
+
<DocumentFragment>
|
|
379
|
+
<div
|
|
380
|
+
class="inlineFlex row alignItems_center container default"
|
|
381
|
+
data-custom-attr="true"
|
|
382
|
+
data-id="flex"
|
|
383
|
+
data-test-id="flex"
|
|
384
|
+
>
|
|
385
|
+
<label
|
|
386
|
+
class="size14 font_regular label"
|
|
387
|
+
data-custom-attr="true"
|
|
388
|
+
data-title="Label text"
|
|
389
|
+
>
|
|
390
|
+
Label text
|
|
391
|
+
</label>
|
|
392
|
+
</div>
|
|
393
|
+
</DocumentFragment>
|
|
394
|
+
`;
|
|
395
|
+
|
|
396
|
+
exports[`Label - Snapshot Render with textWeight=regular 1`] = `
|
|
397
|
+
<DocumentFragment>
|
|
398
|
+
<div
|
|
399
|
+
class="inlineFlex row alignItems_center container default"
|
|
400
|
+
data-id="flex"
|
|
401
|
+
data-test-id="flex"
|
|
402
|
+
>
|
|
403
|
+
<label
|
|
404
|
+
class="size14 font_regular label"
|
|
405
|
+
data-title="Label text"
|
|
406
|
+
>
|
|
407
|
+
Label text
|
|
408
|
+
</label>
|
|
409
|
+
</div>
|
|
410
|
+
</DocumentFragment>
|
|
411
|
+
`;
|
|
412
|
+
|
|
413
|
+
exports[`Label - Snapshot Render with textWeight=semibold 1`] = `
|
|
414
|
+
<DocumentFragment>
|
|
415
|
+
<div
|
|
416
|
+
class="inlineFlex row alignItems_center container default"
|
|
417
|
+
data-id="flex"
|
|
418
|
+
data-test-id="flex"
|
|
419
|
+
>
|
|
420
|
+
<label
|
|
421
|
+
class="size14 font_semibold label"
|
|
422
|
+
data-title="Label text"
|
|
423
|
+
>
|
|
424
|
+
Label text
|
|
425
|
+
</label>
|
|
426
|
+
</div>
|
|
427
|
+
</DocumentFragment>
|
|
428
|
+
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
--local-label-cursor: pointer;
|
|
3
|
+
max-width: 100% ;
|
|
4
|
+
}
|
|
5
|
+
.label {
|
|
6
|
+
/*css:theme-validation:ignore*/
|
|
7
|
+
color: var(--local-label-text-color);
|
|
8
|
+
cursor: var(--local-label-cursor);
|
|
9
|
+
}
|
|
10
|
+
.default {
|
|
11
|
+
--local-label-text-color: var(--zdt_v1_label_text);
|
|
12
|
+
}
|
|
13
|
+
.secondary {
|
|
14
|
+
--local-label-text-color: var(--zdt_v1_label_secondary_text);
|
|
15
|
+
}
|
|
16
|
+
.required {
|
|
17
|
+
--local-label-text-color: var(--zdt_v1_label_required_text);
|
|
18
|
+
}
|
|
19
|
+
.disabled:not(.required) {
|
|
20
|
+
--local-label-text-color: var(--zdt_v1_label_disabled_text);
|
|
21
|
+
}
|
|
22
|
+
.disabled, .readonly {
|
|
23
|
+
--local-label-cursor: not-allowed;
|
|
24
|
+
}
|
|
25
|
+
.requiredCommon {
|
|
26
|
+
color: var(--zdt_v1_label_required_text);
|
|
27
|
+
cursor: var(--local-label-cursor);
|
|
28
|
+
}
|
|
29
|
+
.requiredText {
|
|
30
|
+
margin-inline-start: var(--zd_size4) ;
|
|
31
|
+
}
|
|
32
|
+
.asterisk {
|
|
33
|
+
margin-inline-start: var(--zd_size2) ;
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import compileClassNames from '@zohodesk/utils/es/compileClassNames';
|
|
2
|
+
import commonStyle from "../../../common/common.module.css";
|
|
3
|
+
export default function cssJSLogic(_ref) {
|
|
4
|
+
let {
|
|
5
|
+
style,
|
|
6
|
+
...props
|
|
7
|
+
} = _ref;
|
|
8
|
+
const {
|
|
9
|
+
shouldHighlightRequired,
|
|
10
|
+
isRequired,
|
|
11
|
+
isDisabled,
|
|
12
|
+
customClass,
|
|
13
|
+
requiredType,
|
|
14
|
+
palette,
|
|
15
|
+
isReadOnly
|
|
16
|
+
} = props;
|
|
17
|
+
const {
|
|
18
|
+
label: customClass_label,
|
|
19
|
+
container: customClass_container
|
|
20
|
+
} = customClass;
|
|
21
|
+
const labelClass = compileClassNames({
|
|
22
|
+
[style.label]: true,
|
|
23
|
+
[customClass_label]: !!customClass_label
|
|
24
|
+
});
|
|
25
|
+
const requiredClass = compileClassNames({
|
|
26
|
+
[style.requiredCommon]: true,
|
|
27
|
+
[commonStyle.flexshrink]: true,
|
|
28
|
+
[style.requiredText]: requiredType === 'text',
|
|
29
|
+
[style.asterisk]: requiredType === 'asterisk'
|
|
30
|
+
});
|
|
31
|
+
const containerClass = compileClassNames({
|
|
32
|
+
[style.container]: true,
|
|
33
|
+
[style.required]: isRequired && shouldHighlightRequired,
|
|
34
|
+
[style.readonly]: isReadOnly,
|
|
35
|
+
[style.disabled]: isDisabled,
|
|
36
|
+
[style[palette]]: palette && !(isRequired && shouldHighlightRequired) && !isDisabled,
|
|
37
|
+
[customClass_container]: !!customClass_container
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
labelClass,
|
|
41
|
+
requiredClass,
|
|
42
|
+
containerClass
|
|
43
|
+
};
|
|
44
|
+
}
|