@zohodesk/components 1.0.0-temp-199.22 → 1.0.0-temp-249.1

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 (103) hide show
  1. package/README.md +29 -0
  2. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +6 -0
  3. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +6 -0
  4. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +6 -0
  5. package/es/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +5 -5
  6. package/es/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +6 -6
  7. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +3 -3
  8. package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -1
  9. package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -3
  10. package/es/ListItem/ListItem.js +0 -1
  11. package/es/ListItem/ListItem.module.css +18 -17
  12. package/es/ListItem/ListItemWithAvatar.js +2 -4
  13. package/es/ListItem/ListItemWithCheckBox.js +2 -4
  14. package/es/ListItem/ListItemWithIcon.js +2 -4
  15. package/es/ListItem/ListItemWithRadio.js +2 -4
  16. package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1 -1
  17. package/es/MultiSelect/AdvancedGroupMultiSelect.js +2 -6
  18. package/es/MultiSelect/MultiSelect.js +2 -2
  19. package/es/MultiSelect/Suggestions.js +2 -7
  20. package/es/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +1 -1
  21. package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +3 -3
  22. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +3 -3
  23. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +1 -1
  24. package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +1 -1
  25. package/es/MultiSelect/props/defaultProps.js +0 -2
  26. package/es/MultiSelect/props/propTypes.js +3 -11
  27. package/es/Provider/LibraryContext.js +11 -3
  28. package/es/Select/GroupSelect.js +1 -1
  29. package/es/Select/Select.js +5 -3
  30. package/es/Select/SelectWithAvatar.js +3 -3
  31. package/es/Select/SelectWithIcon.js +3 -10
  32. package/es/Select/__tests__/Select.spec.js +5 -0
  33. package/es/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -1
  34. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +111 -121
  35. package/es/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -1
  36. package/es/Select/props/defaultProps.js +2 -4
  37. package/es/Select/props/propTypes.js +5 -12
  38. package/es/TextBoxIcon/TextBoxIcon.js +0 -1
  39. package/es/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +39 -39
  40. package/es/common/common.module.css +1 -1
  41. package/es/shared/InputFieldLine/InputFieldLine.js +2 -1
  42. package/es/shared/InputFieldLine/InputFieldLine.module.css +13 -7
  43. package/es/shared/InputFieldLine/__tests__/__snapshots__/InputFieldLine.spec.js.snap +19 -19
  44. package/es/shared/InputFieldLine/props/defaultProps.js +2 -2
  45. package/es/shared/InputFieldLine/props/propTypes.js +1 -1
  46. package/es/v1/Label/Label.js +95 -33
  47. package/es/v1/Label/__tests__/Label.spec.js +214 -0
  48. package/es/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +451 -0
  49. package/es/v1/Label/constants/index.js +8 -0
  50. package/es/v1/Label/css/Label_v1.module.css +42 -0
  51. package/es/v1/Label/css/cssJSLogic.js +44 -0
  52. package/es/v1/Label/props/defaultProps.js +14 -9
  53. package/es/v1/Label/props/propTypes.js +34 -14
  54. package/lib/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +5 -5
  55. package/lib/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +6 -6
  56. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +3 -3
  57. package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -1
  58. package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -3
  59. package/lib/ListItem/ListItem.js +0 -1
  60. package/lib/ListItem/ListItem.module.css +18 -17
  61. package/lib/ListItem/ListItemWithAvatar.js +3 -5
  62. package/lib/ListItem/ListItemWithCheckBox.js +2 -4
  63. package/lib/ListItem/ListItemWithIcon.js +3 -5
  64. package/lib/ListItem/ListItemWithRadio.js +2 -4
  65. package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +1 -1
  66. package/lib/MultiSelect/AdvancedGroupMultiSelect.js +3 -8
  67. package/lib/MultiSelect/MultiSelect.js +2 -2
  68. package/lib/MultiSelect/Suggestions.js +2 -6
  69. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedGroupMultiSelect.spec.js.snap +1 -1
  70. package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +3 -3
  71. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +3 -3
  72. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectWithAvatar.spec.js.snap +1 -1
  73. package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +1 -1
  74. package/lib/MultiSelect/props/defaultProps.js +0 -2
  75. package/lib/MultiSelect/props/propTypes.js +5 -13
  76. package/lib/Provider/LibraryContext.js +11 -3
  77. package/lib/Select/GroupSelect.js +1 -2
  78. package/lib/Select/Select.js +8 -5
  79. package/lib/Select/SelectWithAvatar.js +3 -4
  80. package/lib/Select/SelectWithIcon.js +3 -10
  81. package/lib/Select/__tests__/Select.spec.js +5 -0
  82. package/lib/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -1
  83. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +111 -121
  84. package/lib/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -1
  85. package/lib/Select/props/defaultProps.js +3 -5
  86. package/lib/Select/props/propTypes.js +5 -12
  87. package/lib/TextBoxIcon/TextBoxIcon.js +0 -1
  88. package/lib/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +39 -39
  89. package/lib/common/common.module.css +1 -1
  90. package/lib/shared/InputFieldLine/InputFieldLine.js +2 -1
  91. package/lib/shared/InputFieldLine/InputFieldLine.module.css +13 -7
  92. package/lib/shared/InputFieldLine/__tests__/__snapshots__/InputFieldLine.spec.js.snap +19 -19
  93. package/lib/shared/InputFieldLine/props/defaultProps.js +2 -2
  94. package/lib/shared/InputFieldLine/props/propTypes.js +1 -1
  95. package/lib/v1/Label/Label.js +103 -36
  96. package/lib/v1/Label/__tests__/Label.spec.js +221 -0
  97. package/lib/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +451 -0
  98. package/lib/v1/Label/constants/index.js +16 -0
  99. package/lib/v1/Label/css/Label_v1.module.css +42 -0
  100. package/lib/v1/Label/css/cssJSLogic.js +45 -0
  101. package/lib/v1/Label/props/defaultProps.js +16 -11
  102. package/lib/v1/Label/props/propTypes.js +36 -16
  103. package/package.json +10 -10
@@ -8,9 +8,9 @@ export default {
8
8
  dataId: '',
9
9
  customClass: '',
10
10
  customProps: {},
11
- size: 'medium',
12
11
  borderColor: 'default',
13
12
  border: 'bottom',
14
13
  a11yAttributes: {},
15
- tagAttribute: {}
14
+ tagAttributes: {},
15
+ size: 'auto'
16
16
  };
@@ -12,7 +12,7 @@ export default {
12
12
  customProps: PropTypes.shape({ ...ContainerProps
13
13
  }),
14
14
  onClick: PropTypes.func,
15
- size: PropTypes.oneOf(['medium', 'xmedium']),
15
+ size: PropTypes.oneOf(['auto', 'medium', 'xmedium']),
16
16
  border: PropTypes.oneOf(['bottom', 'all', 'none']),
17
17
  borderColor: PropTypes.oneOf(['default', 'dark', 'error', 'transparent']),
18
18
  children: PropTypes.node,
@@ -1,40 +1,102 @@
1
- import React from 'react';
2
- import { defaultProps } from "./props/defaultProps";
3
- import { propTypes } from "./props/propTypes";
4
- import style from "../../Label/Label.module.css";
5
- import colors from "../../Label/LabelColors.module.css";
6
- export default function Label(props) {
1
+ import React from 'react'; // props
2
+
3
+ import defaultProps from "./props/defaultProps";
4
+ import propTypes from "./props/propTypes"; // methods
5
+
6
+ import cssJSLogic from "./css/cssJSLogic";
7
+ import { renderNode } from '@zohodesk/utils'; // hoc
8
+
9
+ import { withComponentRegistrar } from '@zohodesk/dotkit/es/react/ComponentRegistry'; // constants
10
+
11
+ import { DISPLAY_MODE, FONT_SIZE } from "./constants"; // components
12
+
13
+ import Flex from '@zohodesk/layout/es/Flex/Flex';
14
+ import Typography from "../../Typography/Typography"; // css
15
+
16
+ import style from "./css/Label_v1.module.css";
17
+
18
+ const Label = props => {
7
19
  const {
8
- text,
9
- type,
10
- palette,
11
- size,
12
- clipped,
13
20
  htmlFor,
14
- title,
15
21
  onClick,
16
- dataId,
17
- dataSelectorId,
18
- variant,
19
- customClass,
20
- id,
21
- a11y = {}
22
+ text,
23
+ customId,
24
+ testId,
25
+ tagAttributes,
26
+ a11yAttributes,
27
+ customProps,
28
+ isRequired,
29
+ requiredType,
30
+ isClipped,
31
+ size,
32
+ fontWeight,
33
+ layout,
34
+ renderRightPlaceholderNode,
35
+ renderLeftPlaceholderNode,
36
+ i18nKeys
22
37
  } = props;
23
38
  const {
24
- tabIndex
25
- } = a11y;
26
- return /*#__PURE__*/React.createElement("label", {
27
- className: `${style.label} ${style[type]} ${style[size]} ${colors[palette]} ${style[`font_${variant}`]}
28
- ${clipped ? style.dotted : ''} ${onClick ? style.pointer : style.cursor} ${customClass} `,
29
- htmlFor: htmlFor,
30
- "data-title": title,
31
- "data-id": dataId,
32
- "data-test-id": dataId,
33
- "data-selector-id": dataSelectorId,
34
- onClick: onClick,
35
- id: id,
36
- tabIndex: tabIndex
37
- }, text);
38
- }
39
+ container: tagAttributes_container,
40
+ label: tagAttributes_label
41
+ } = tagAttributes;
42
+ const {
43
+ container: a11yAttributes_container,
44
+ label: a11yAttributes_label
45
+ } = a11yAttributes;
46
+ const {
47
+ container: customProps_container,
48
+ label: customProps_label
49
+ } = customProps;
50
+ const {
51
+ requiredText: i18n_requiredText = 'Required'
52
+ } = i18nKeys;
53
+ const {
54
+ labelClass,
55
+ requiredClass,
56
+ containerClass
57
+ } = cssJSLogic({ ...props,
58
+ style
59
+ });
60
+ const a11yAttributes_requiredText = {
61
+ 'aria-hidden': 'true'
62
+ };
63
+
64
+ const renderRequired = () => /*#__PURE__*/React.createElement(Typography, {
65
+ $ui_tagName: "span",
66
+ $ui_className: requiredClass,
67
+ $a11yAttributes_text: a11yAttributes_requiredText,
68
+ $ui_size: FONT_SIZE[size],
69
+ $ui_weight: fontWeight,
70
+ $i18n_dataTitle: ""
71
+ }, requiredType === 'text' ? `(${i18n_requiredText})` : '*');
72
+
73
+ return /*#__PURE__*/React.createElement(Flex, { ...customProps_container,
74
+ $tagAttributes_container: { ...tagAttributes_container,
75
+ 'data-selector-id': customId
76
+ },
77
+ $ui_displayMode: DISPLAY_MODE[layout],
78
+ $ui_alignItems: "center",
79
+ $a11yAttributes_container: a11yAttributes_container,
80
+ testId: testId,
81
+ customId: customId,
82
+ $ui_className: containerClass
83
+ }, renderNode(renderLeftPlaceholderNode), /*#__PURE__*/React.createElement(Typography, { ...customProps_label,
84
+ $tagAttributes_text: { ...tagAttributes_label,
85
+ htmlFor,
86
+ onClick
87
+ },
88
+ $ui_tagName: "label",
89
+ $ui_className: labelClass,
90
+ $i18n_dataTitle: text,
91
+ $a11yAttributes_text: a11yAttributes_label,
92
+ $ui_size: FONT_SIZE[size],
93
+ $ui_weight: fontWeight,
94
+ $flag_dotted: isClipped
95
+ }, text, isRequired && !isClipped ? renderRequired() : null), isRequired && isClipped ? renderRequired() : null, renderNode(renderRightPlaceholderNode));
96
+ };
97
+
98
+ export default withComponentRegistrar(Label, {
99
+ name: 'ZDC_V1_Label'
100
+ });
39
101
  Label.defaultProps = defaultProps;
40
102
  Label.propTypes = propTypes;
@@ -0,0 +1,214 @@
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 fontWeight=%s', value => {
49
+ const {
50
+ asFragment
51
+ } = render( /*#__PURE__*/React.createElement(Label, {
52
+ text: "Label text",
53
+ fontWeight: 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 isRequired=true isClipped=true', () => {
95
+ const {
96
+ asFragment
97
+ } = render( /*#__PURE__*/React.createElement(Label, {
98
+ text: "Label text",
99
+ isRequired: true,
100
+ isClipped: true
101
+ }));
102
+ expect(asFragment()).toMatchSnapshot();
103
+ });
104
+ test('Render with isDisabled=true', () => {
105
+ const {
106
+ asFragment
107
+ } = render( /*#__PURE__*/React.createElement(Label, {
108
+ text: "Label text",
109
+ isDisabled: true
110
+ }));
111
+ expect(asFragment()).toMatchSnapshot();
112
+ });
113
+ test('Render with isReadOnly=true', () => {
114
+ const {
115
+ asFragment
116
+ } = render( /*#__PURE__*/React.createElement(Label, {
117
+ text: "Label text",
118
+ isReadOnly: true
119
+ }));
120
+ expect(asFragment()).toMatchSnapshot();
121
+ });
122
+ test('Render with htmlFor', () => {
123
+ const {
124
+ asFragment
125
+ } = render( /*#__PURE__*/React.createElement(Label, {
126
+ text: "Label text",
127
+ htmlFor: "input-id"
128
+ }));
129
+ expect(asFragment()).toMatchSnapshot();
130
+ });
131
+ test('Render with i18nKeys', () => {
132
+ const {
133
+ asFragment
134
+ } = render( /*#__PURE__*/React.createElement(Label, {
135
+ text: "Label text",
136
+ isRequired: true,
137
+ requiredType: "text",
138
+ i18nKeys: {
139
+ requiredText: 'Custom Required'
140
+ }
141
+ }));
142
+ expect(asFragment()).toMatchSnapshot();
143
+ });
144
+ test('Render with customClass', () => {
145
+ const {
146
+ asFragment
147
+ } = render( /*#__PURE__*/React.createElement(Label, {
148
+ text: "Label text",
149
+ customClass: {
150
+ container: 'custom-container',
151
+ label: 'custom-label'
152
+ }
153
+ }));
154
+ expect(asFragment()).toMatchSnapshot();
155
+ });
156
+ test('Render with customProps', () => {
157
+ const {
158
+ asFragment
159
+ } = render( /*#__PURE__*/React.createElement(Label, {
160
+ text: "Label text",
161
+ customProps: {
162
+ container: {
163
+ $flag_shrink: true
164
+ },
165
+ label: {
166
+ $ui_lineClamp: '2'
167
+ }
168
+ }
169
+ }));
170
+ expect(asFragment()).toMatchSnapshot();
171
+ });
172
+ test('Render with customId and testId', () => {
173
+ const {
174
+ asFragment
175
+ } = render( /*#__PURE__*/React.createElement(Label, {
176
+ text: "Label text",
177
+ customId: "label-customId",
178
+ testId: "label-testId"
179
+ }));
180
+ expect(asFragment()).toMatchSnapshot();
181
+ });
182
+ test('Render with tag attributes', () => {
183
+ const {
184
+ asFragment
185
+ } = render( /*#__PURE__*/React.createElement(Label, {
186
+ text: "Label text",
187
+ tagAttributes: {
188
+ container: {
189
+ 'data-custom-attr': 'true'
190
+ },
191
+ label: {
192
+ 'data-custom-attr': 'true'
193
+ }
194
+ }
195
+ }));
196
+ expect(asFragment()).toMatchSnapshot();
197
+ });
198
+ test('Render with a11y attributes', () => {
199
+ const {
200
+ asFragment
201
+ } = render( /*#__PURE__*/React.createElement(Label, {
202
+ text: "Label text",
203
+ a11yAttributes: {
204
+ container: {
205
+ role: 'group'
206
+ },
207
+ label: {
208
+ 'aria-label': 'Custom label'
209
+ }
210
+ }
211
+ }));
212
+ expect(asFragment()).toMatchSnapshot();
213
+ });
214
+ });