@zohodesk/components 1.5.2 → 1.5.4-temp-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 (63) hide show
  1. package/README.md +21 -0
  2. package/assets/Appearance/dark/mode/Component_DarkMode.module.css +2 -0
  3. package/assets/Appearance/light/mode/Component_LightMode.module.css +2 -0
  4. package/assets/Appearance/pureDark/mode/Component_PureDarkMode.module.css +2 -0
  5. package/es/CheckBox/CheckBox.js +21 -10
  6. package/es/CheckBox/CheckBox.module.css +21 -6
  7. package/es/CheckBox/__tests__/CheckBox.spec.js +9 -0
  8. package/es/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
  9. package/es/CheckBox/props/propTypes.js +4 -1
  10. package/es/DropBox/DropBoxElement/DropBoxElement.js +1 -1
  11. package/es/DropBox/utils/isMobilePopover.js +3 -14
  12. package/es/Label/Label.js +19 -1
  13. package/es/Label/__tests__/Label.spec.js +58 -0
  14. package/es/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
  15. package/es/Label/props/defaultProps.js +1 -0
  16. package/es/Label/props/propTypes.js +7 -1
  17. package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +7 -7
  18. package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +7 -7
  19. package/es/Popup/Popup.js +32 -1045
  20. package/es/Radio/Radio.js +20 -9
  21. package/es/Radio/Radio.module.css +38 -5
  22. package/es/Radio/__tests__/Radio.spec.js +10 -0
  23. package/es/Radio/__tests__/__snapshots__/Radio.spec.js.snap +154 -81
  24. package/es/Radio/props/propTypes.js +4 -1
  25. package/es/Tag/Tag.js +5 -2
  26. package/es/Tag/props/propTypes.js +2 -0
  27. package/es/utils/Common.js +1 -1
  28. package/es/v1/Popup/Popup.js +2 -2
  29. package/lib/CheckBox/CheckBox.js +23 -9
  30. package/lib/CheckBox/CheckBox.module.css +21 -6
  31. package/lib/CheckBox/__tests__/CheckBox.spec.js +21 -12
  32. package/lib/CheckBox/__tests__/__snapshots__/CheckBox.spec.js.snap +162 -93
  33. package/lib/CheckBox/props/propTypes.js +5 -1
  34. package/lib/DropBox/DropBoxElement/DropBoxElement.js +5 -5
  35. package/lib/DropBox/utils/isMobilePopover.js +4 -14
  36. package/lib/Label/Label.js +21 -1
  37. package/lib/Label/__tests__/Label.spec.js +58 -0
  38. package/lib/Label/__tests__/__snapshots__/Label.spec.js.snap +66 -0
  39. package/lib/Label/props/defaultProps.js +1 -0
  40. package/lib/Label/props/propTypes.js +8 -1
  41. package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +7 -7
  42. package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +7 -7
  43. package/lib/Popup/Popup.js +36 -1149
  44. package/lib/Radio/Radio.js +22 -8
  45. package/lib/Radio/Radio.module.css +38 -5
  46. package/lib/Radio/__tests__/Radio.spec.js +10 -0
  47. package/lib/Radio/__tests__/__snapshots__/Radio.spec.js.snap +154 -81
  48. package/lib/Radio/props/propTypes.js +5 -1
  49. package/lib/Tag/Tag.js +6 -2
  50. package/lib/Tag/props/propTypes.js +2 -0
  51. package/lib/utils/Common.js +1 -1
  52. package/lib/v1/Popup/Popup.js +4 -4
  53. package/package.json +9 -9
  54. package/es/DropBox/DropBoxPositionMapping.js +0 -142
  55. package/es/Popup/PositionMapping.js +0 -72
  56. package/es/Popup/Registry.js +0 -36
  57. package/es/Popup/intersectionObserver.js +0 -49
  58. package/es/Popup/viewPort.js +0 -373
  59. package/lib/DropBox/DropBoxPositionMapping.js +0 -149
  60. package/lib/Popup/PositionMapping.js +0 -81
  61. package/lib/Popup/Registry.js +0 -46
  62. package/lib/Popup/intersectionObserver.js +0 -72
  63. package/lib/Popup/viewPort.js +0 -367
@@ -1,10 +1,12 @@
1
1
  import PropTypes from 'prop-types';
2
+ import { propTypes as TypographyPropTypes } from "../../Typography/props/propTypes";
2
3
  export const propTypes = {
3
4
  active: PropTypes.bool,
4
5
  activeStyle: PropTypes.oneOf(['tick', 'minus']),
5
6
  checked: PropTypes.bool,
6
7
  dataId: PropTypes.string,
7
8
  dataSelectorId: PropTypes.string,
9
+ secondaryText: PropTypes.string,
8
10
  disabled: PropTypes.bool,
9
11
  disabledTitle: PropTypes.string,
10
12
  getRef: PropTypes.func,
@@ -36,7 +38,8 @@ export const propTypes = {
36
38
  }),
37
39
  customProps: PropTypes.shape({
38
40
  CheckBoxProps: PropTypes.object,
39
- LabelProps: PropTypes.object
41
+ LabelProps: PropTypes.object,
42
+ secondaryTextProps: PropTypes.exact(TypographyPropTypes)
40
43
  }),
41
44
  renderRightPlaceholderNode: PropTypes.node
42
45
  };
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import useDropboxPosCalc from "./useDropboxPosCalc";
4
4
  import cssJSLogic from "./css/cssJSLogic";
5
- import { positionMapping } from "../DropBoxPositionMapping.js";
5
+ import { positionMapping } from '@zohodesk/dotkit/es/react/components/Popup/utils/positioning';
6
6
  import { DropBoxElementDefaultProps } from "./props/defaultProps";
7
7
  import { DropBoxElementPropTypes } from "./props/propTypes";
8
8
  import { mergeStyle } from '@zohodesk/utils';
@@ -1,17 +1,6 @@
1
1
  import { getLibraryConfig } from "../../Provider/Config";
2
+ import { isMobilePopover as isMobile } from '@zohodesk/dotkit/es/utils/device.js';
2
3
  export default function isMobilePopover(needResponsive) {
3
- // let { needResponsive } = props;
4
- let windowWidth,
5
- mobileWidth = getLibraryConfig('mobileWidth'),
6
- isModel = false;
7
-
8
- if (needResponsive) {
9
- windowWidth = window.innerWidth;
10
-
11
- if (windowWidth <= mobileWidth) {
12
- isModel = true;
13
- }
14
- }
15
-
16
- return isModel ? true : false;
4
+ const mobileWidth = getLibraryConfig('mobileWidth');
5
+ return isMobile(needResponsive, mobileWidth);
17
6
  }
package/es/Label/Label.js CHANGED
@@ -4,6 +4,8 @@
4
4
  import React from 'react';
5
5
  import { defaultProps } from "./props/defaultProps";
6
6
  import { propTypes } from "./props/propTypes";
7
+ import Flex from '@zohodesk/layout/es/Flex/Flex';
8
+ import { renderNode, isRenderable } from '@zohodesk/utils';
7
9
  import style from "./Label.module.css";
8
10
  import colors from "./LabelColors.module.css";
9
11
  export default class Label extends React.Component {
@@ -20,14 +22,20 @@ export default class Label extends React.Component {
20
22
  dataId,
21
23
  dataSelectorId,
22
24
  variant,
25
+ customProps,
23
26
  customClass,
24
27
  id,
28
+ renderRightPlaceholderNode,
25
29
  a11y = {}
26
30
  } = this.props;
31
+ const {
32
+ containerProps,
33
+ rightPlaceholderNodeProps
34
+ } = customProps;
27
35
  const {
28
36
  tabIndex
29
37
  } = a11y;
30
- return /*#__PURE__*/React.createElement("label", {
38
+ const labelElement = /*#__PURE__*/React.createElement("label", {
31
39
  className: `${style.label} ${style[type]} ${style[size]} ${colors[palette]} ${style[`font_${variant}`]}
32
40
  ${clipped ? style.dotted : ''} ${onClick ? style.pointer : style.cursor} ${customClass} `,
33
41
  htmlFor: htmlFor,
@@ -39,6 +47,16 @@ export default class Label extends React.Component {
39
47
  id: id,
40
48
  tabIndex: tabIndex
41
49
  }, text);
50
+ return /*#__PURE__*/React.createElement(React.Fragment, null, isRenderable(renderRightPlaceholderNode) ? /*#__PURE__*/React.createElement(Flex, {
51
+ $ui_displayMode: "flex",
52
+ $ui_direction: "row",
53
+ $ui_alignItems: "center",
54
+ ...containerProps
55
+ }, labelElement, /*#__PURE__*/React.createElement(Flex, {
56
+ $ui_displayMode: "flex",
57
+ $ui_alignItems: "center",
58
+ ...rightPlaceholderNodeProps
59
+ }, renderNode(renderRightPlaceholderNode))) : /*#__PURE__*/React.createElement(React.Fragment, null, labelElement));
42
60
  }
43
61
 
44
62
  }
@@ -96,4 +96,62 @@ describe('Label', () => {
96
96
  }));
97
97
  expect(asFragment()).toMatchSnapshot();
98
98
  });
99
+ test('rendering with renderRightPlaceholderNode', () => {
100
+ const {
101
+ asFragment
102
+ } = render( /*#__PURE__*/React.createElement(Label, {
103
+ text: "New Feature",
104
+ id: "label_new",
105
+ renderRightPlaceholderNode: /*#__PURE__*/React.createElement("span", {
106
+ style: {
107
+ background: '#27ae60',
108
+ color: 'white',
109
+ padding: '2px 6px',
110
+ borderRadius: '3px',
111
+ fontSize: '10px',
112
+ fontWeight: 'bold'
113
+ }
114
+ }, "NEW")
115
+ }));
116
+ expect(asFragment()).toMatchSnapshot();
117
+ });
118
+ test('rendering with customProps - containerProps & rightPlaceholderNodeProps', () => {
119
+ const {
120
+ asFragment
121
+ } = render( /*#__PURE__*/React.createElement(Label, {
122
+ text: "Premium Feature",
123
+ id: "label_premium",
124
+ size: "large",
125
+ palette: "danger",
126
+ renderRightPlaceholderNode: /*#__PURE__*/React.createElement("span", {
127
+ style: {
128
+ fontSize: '10px',
129
+ background: '#f39c12',
130
+ color: 'white',
131
+ padding: '1px 4px',
132
+ borderRadius: '2px'
133
+ }
134
+ }, "PRO"),
135
+ customProps: {
136
+ containerProps: {
137
+ $ui_alignItems: 'center',
138
+ $tagAttributes_container: {
139
+ style: {
140
+ gap: '6px'
141
+ }
142
+ }
143
+ },
144
+ rightPlaceholderNodeProps: {
145
+ $ui_displayMode: 'flex',
146
+ $ui_alignItems: 'center',
147
+ $tagAttributes_container: {
148
+ style: {
149
+ gap: '6px'
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }));
155
+ expect(asFragment()).toMatchSnapshot();
156
+ });
99
157
  });
@@ -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
+ `;
@@ -6,6 +6,7 @@ export const defaultProps = {
6
6
  text: 'Label',
7
7
  type: 'title',
8
8
  variant: 'default',
9
+ customProps: {},
9
10
  customClass: '',
10
11
  dataSelectorId: 'label'
11
12
  };
@@ -1,4 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
+ import FlexPropTypes from '@zohodesk/layout/es/Flex/props/propTypes';
2
3
  export const propTypes = {
3
4
  clipped: PropTypes.bool,
4
5
  dataId: PropTypes.string,
@@ -11,9 +12,14 @@ export const propTypes = {
11
12
  title: PropTypes.string,
12
13
  type: PropTypes.oneOf(['title', 'subtitle']),
13
14
  variant: PropTypes.oneOf(['primary', 'default']),
15
+ customProps: PropTypes.shape({
16
+ containerProps: PropTypes.exact(FlexPropTypes),
17
+ rightPlaceholderNodeProps: PropTypes.exact(FlexPropTypes)
18
+ }),
14
19
  customClass: PropTypes.string,
15
20
  a11y: PropTypes.shape({
16
21
  tabIndex: PropTypes.string
17
22
  }),
18
- id: PropTypes.string
23
+ id: PropTypes.string,
24
+ renderRightPlaceholderNode: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
19
25
  };
@@ -35,7 +35,7 @@ exports[`ListItemWithCheckBox ListItemWithCheckBox with renderValueRightPlacehol
35
35
  tabindex="-1"
36
36
  >
37
37
  <div
38
- class="boxContainer medium filled shrinkOff"
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 medium filled shrinkOff"
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 medium filled shrinkOff"
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 medium filled shrinkOff"
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 medium filled shrinkOff"
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 medium filled shrinkOff"
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 medium filled shrinkOff"
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 shrinkOff"
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 shrinkOff"
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 shrinkOff"
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 shrinkOff"
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 shrinkOff"
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 shrinkOff"
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 shrinkOff"
635
+ hoverprimary medium filled centerPathprimary shrinkOff"
636
636
  data-id="boxComponent"
637
637
  data-selector-id="box"
638
638
  data-test-id="boxComponent"