@zohodesk/components 1.0.0-temp-259.3 → 1.0.0-temp-259.5

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 (57) hide show
  1. package/es/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +3 -3
  2. package/es/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +6 -6
  3. package/es/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +6 -6
  4. package/es/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +3 -3
  5. package/es/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -1
  6. package/es/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -3
  7. package/es/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +4 -4
  8. package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +1 -1
  9. package/es/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -1
  10. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +75 -75
  11. package/es/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -1
  12. package/es/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +4 -4
  13. package/es/Tag/__tests__/__snapshots__/Tag.spec.js.snap +48 -48
  14. package/es/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +3 -3
  15. package/es/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +10 -10
  16. package/es/v1/Button/Button.js +56 -25
  17. package/es/v1/Button/README.md +4 -2
  18. package/es/v1/Button/__tests__/Button.spec.js +3 -3
  19. package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +144 -21
  20. package/es/v1/Button/constants/index.js +3 -3
  21. package/es/v1/Button/constants/presets.js +11 -0
  22. package/es/v1/Button/css/cssJSLogic.js +5 -6
  23. package/es/v1/Button/props/defaultProps.js +3 -0
  24. package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +31 -527
  25. package/es/v1/helpers/colorHelpers/border/borderColor.module.css +24 -408
  26. package/es/v1/helpers/colorHelpers/colorHelper.js +8 -5
  27. package/es/v1/helpers/colorHelpers/paletteUtilities.README.md +141 -336
  28. package/es/v1/helpers/colorHelpers/text/textColor.module.css +72 -288
  29. package/lib/ColorSelect/__tests__/__snapshots__/ColorMultiSelect.spec.js.snap +3 -3
  30. package/lib/ColorSelect/__tests__/__snapshots__/ColorSingleSelect.spec.js.snap +6 -6
  31. package/lib/DateTime/__tests__/__snapshots__/DateTime.spec.js.snap +6 -6
  32. package/lib/DateTime/__tests__/__snapshots__/DateTimePopupHeader.spec.js.snap +3 -3
  33. package/lib/DateTime/__tests__/__snapshots__/DateWidget.spec.js.snap +1 -1
  34. package/lib/DateTime/__tests__/__snapshots__/Time.spec.js.snap +3 -3
  35. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +4 -4
  36. package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +1 -1
  37. package/lib/Select/__tests__/__snapshots__/GroupSelect.spec.js.snap +1 -1
  38. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +75 -75
  39. package/lib/Select/__tests__/__snapshots__/SelectWithIcon.spec.js.snap +1 -1
  40. package/lib/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +4 -4
  41. package/lib/Tag/__tests__/__snapshots__/Tag.spec.js.snap +48 -48
  42. package/lib/TextBoxIcon/__tests__/__snapshots__/TextBoxIcon.spec.js.snap +3 -3
  43. package/lib/shared/ArrowIcon/__tests__/__snapshots__/ArrowIcon.spec.js.snap +10 -10
  44. package/lib/v1/Button/Button.js +49 -25
  45. package/lib/v1/Button/README.md +4 -2
  46. package/lib/v1/Button/__tests__/Button.spec.js +2 -2
  47. package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +144 -21
  48. package/lib/v1/Button/constants/index.js +3 -3
  49. package/lib/v1/Button/constants/presets.js +13 -1
  50. package/lib/v1/Button/css/cssJSLogic.js +10 -13
  51. package/lib/v1/Button/props/defaultProps.js +3 -0
  52. package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +31 -527
  53. package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +24 -408
  54. package/lib/v1/helpers/colorHelpers/colorHelper.js +8 -5
  55. package/lib/v1/helpers/colorHelpers/paletteUtilities.README.md +141 -336
  56. package/lib/v1/helpers/colorHelpers/text/textColor.module.css +72 -288
  57. package/package.json +7 -7
@@ -6,8 +6,7 @@ import React, { forwardRef, memo, useMemo } from 'react';
6
6
  import { withComponentRegistrar } from '@zohodesk/dotkit/es/react/ComponentRegistry';
7
7
  import Icon from '@zohodesk/icons/es/Icon';
8
8
  import Flex from '@zohodesk/layout/es/Flex/Flex';
9
- import { isRenderable } from '@zohodesk/utils/es/renderNode';
10
- import renderNode from '@zohodesk/utils/es/renderNode';
9
+ import renderNode, { isRenderable } from '@zohodesk/utils/es/renderNode';
11
10
  import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
12
11
  import { ICON_PLACEMENT, LOADER_PLACEMENT, STATUS, TYPOGRAPHY_SIZE_MAP, VARIANT } from "./constants";
13
12
  import Typography from "../../Typography/Typography";
@@ -73,9 +72,10 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
73
72
  text: textAttributes = DUMMY_OBJECT
74
73
  } = customAttributes || DUMMY_OBJECT;
75
74
  const iconTagAttributes = { ...iconAttributes,
76
- 'data-test-id': testId ? `${testId}_icon` : undefined
75
+ ...(testId && {
76
+ 'data-test-id': `${testId}_icon`
77
+ })
77
78
  };
78
- const showIcon = variant !== VARIANT.TEXT && (renderIcon || iconName);
79
79
 
80
80
  const _renderLoader = () => {
81
81
  if (!isLoading) return null;
@@ -84,13 +84,15 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
84
84
  if (hasCustomLoader && !isOverlay) return renderNode(renderLoader, {
85
85
  status: STATUS.LOADING
86
86
  });
87
- return /*#__PURE__*/React.createElement(Flex, _extends({
87
+ return /*#__PURE__*/React.createElement(Flex, {
88
88
  $ui_displayMode: "flex",
89
89
  $ui_alignItems: "center",
90
90
  $ui_justifyContent: "center",
91
91
  $ui_className: isOverlay ? loaderOverlayClass : '',
92
- testId: testId ? `${testId}_loader` : undefined
93
- }, hasCustomLoader ? undefined : loaderAttributes), hasCustomLoader ? renderNode(renderLoader, {
92
+ testId: testId ? `${testId}_loader` : undefined,
93
+ customId: customId ? `${customId}_loader` : undefined,
94
+ $tagAttributes_container: hasCustomLoader ? undefined : loaderAttributes
95
+ }, hasCustomLoader ? renderNode(renderLoader, {
94
96
  status: STATUS.LOADING
95
97
  }) : /*#__PURE__*/React.createElement(Spinner, {
96
98
  customClass: loaderClassName
@@ -104,13 +106,15 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
104
106
  if (hasCustomSuccess && !isOverlay) return renderNode(renderSuccess, {
105
107
  status: STATUS.SUCCESS
106
108
  });
107
- return /*#__PURE__*/React.createElement(Flex, _extends({
109
+ return /*#__PURE__*/React.createElement(Flex, {
108
110
  $ui_displayMode: "flex",
109
111
  $ui_alignItems: "center",
110
112
  $ui_justifyContent: "center",
111
113
  $ui_className: isOverlay ? successOverlayClass : '',
112
- testId: testId ? `${testId}_success` : undefined
113
- }, hasCustomSuccess ? undefined : successAttributes), hasCustomSuccess ? renderNode(renderSuccess, {
114
+ testId: testId ? `${testId}_success` : undefined,
115
+ customId: customId ? `${customId}_success` : undefined,
116
+ $tagAttributes_container: hasCustomSuccess ? undefined : successAttributes
117
+ }, hasCustomSuccess ? renderNode(renderSuccess, {
114
118
  status: STATUS.SUCCESS
115
119
  }) : /*#__PURE__*/React.createElement(SuccessTick, {
116
120
  customClass: successClassName
@@ -118,14 +122,18 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
118
122
  };
119
123
 
120
124
  const _renderIconNode = () => {
125
+ const showIcon = variant !== VARIANT.TEXT && (renderIcon || iconName);
121
126
  if (!showIcon) return null;
122
- if (isRenderable(renderIcon)) return renderNode(renderIcon);
127
+ if (isRenderable(renderIcon)) return renderNode(renderIcon, {
128
+ iconName,
129
+ iconSize
130
+ });
123
131
  return /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
124
132
  iconClass: iconClassName,
125
133
  name: iconName,
126
134
  size: iconSize,
127
135
  tagAttributes: iconTagAttributes,
128
- dataId: testId ? `${testId}_icon` : undefined
136
+ dataId: customId ? `${customId}_icon` : undefined
129
137
  }));
130
138
  };
131
139
 
@@ -135,31 +143,40 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
135
143
  const showLoaderAfter = isLoading && loaderPlacement === LOADER_PLACEMENT.END;
136
144
  const showSuccessStart = isSuccess && loaderPlacement === LOADER_PLACEMENT.START;
137
145
  const showSuccessAfter = isSuccess && loaderPlacement === LOADER_PLACEMENT.END;
138
- return /*#__PURE__*/React.createElement(Flex, _extends({
146
+ return /*#__PURE__*/React.createElement(Flex, {
139
147
  $ui_displayMode: "flex",
140
148
  $ui_direction: "row",
141
149
  $flag_shrink: true,
142
150
  $ui_alignItems: "center",
143
151
  $ui_justifyContent: "center",
144
- $ui_className: contentWrapperClass
145
- }, contentWrapperAttributes), showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null, isRenderable(renderBefore) ? renderNode(renderBefore, props) : null, iconPlacement === ICON_PLACEMENT.LEFT ? _renderIconNode() : null, shouldShowText ? typeof children === 'string' ? /*#__PURE__*/React.createElement(Typography, _extends({
146
- $ui_size: getTypographySize(size)
152
+ $ui_className: contentWrapperClass,
153
+ $tagAttributes_container: contentWrapperAttributes
154
+ }, showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null, isRenderable(renderBefore) ? renderNode(renderBefore, props) : null, iconPlacement === ICON_PLACEMENT.START ? _renderIconNode() : null, shouldShowText ? typeof children === 'string' ? /*#__PURE__*/React.createElement(Typography, _extends({
155
+ size: getTypographySize(size)
147
156
  }, contentProps, {
148
157
  tagAttributes: textAttributes,
149
- $ui_className: textClassName,
150
- $flag_dotted: variant !== VARIANT.ICON
151
- }), children) : children : null, iconPlacement === ICON_PLACEMENT.RIGHT ? _renderIconNode() : null, isRenderable(renderAfter) ? renderNode(renderAfter, props) : null, showLoaderAfter ? _renderLoader() : null, showSuccessAfter ? _renderSuccess() : null);
158
+ customClass: textClassName,
159
+ isDotted: true
160
+ }), children) : children : null, iconPlacement === ICON_PLACEMENT.END ? _renderIconNode() : null, isRenderable(renderAfter) ? renderNode(renderAfter, props) : null, showLoaderAfter ? _renderLoader() : null, showSuccessAfter ? _renderSuccess() : null);
152
161
  };
153
162
 
154
163
  const containerAttributes = { ...buttonAttributes,
155
- 'data-id': isDisabled ? `${customId}_disabled` : customId,
156
- 'data-test-id': isDisabled ? `${testId}_disabled` : testId,
157
- 'data-selector-id': dataSelectorId,
158
- 'data-title': title
164
+ ...(customId && {
165
+ 'data-id': isDisabled ? `${customId}_disabled` : customId
166
+ }),
167
+ ...(testId && {
168
+ 'data-test-id': isDisabled ? `${testId}_disabled` : testId
169
+ }),
170
+ ...(dataSelectorId && {
171
+ 'data-selector-id': dataSelectorId
172
+ }),
173
+ ...(title && {
174
+ 'data-title': title
175
+ })
159
176
  };
160
177
  return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes, {
161
178
  "aria-busy": isLoading,
162
- disabled: isDisabledState,
179
+ "aria-disabled": isDisabledState,
163
180
  "aria-pressed": isSelected
164
181
  }, a11yAttributes, {
165
182
  ref: ref,
@@ -208,7 +225,21 @@ const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
208
225
  const isDisabledState = isDisabled || isLoading;
209
226
  const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
210
227
  const classNames = useMemo(() => cssJSLogic({
211
- props
228
+ props: {
229
+ palette,
230
+ appearance,
231
+ hoverAppearance,
232
+ selectedAppearance,
233
+ size,
234
+ variant,
235
+ status,
236
+ isDisabled,
237
+ isSelected,
238
+ shape,
239
+ loaderPlacement,
240
+ disabledAppearance,
241
+ customClass
242
+ }
212
243
  }), [palette, appearance, hoverAppearance, selectedAppearance, size, variant, status, isDisabled, isSelected, shape, loaderPlacement, disabledAppearance, customClass]);
213
244
 
214
245
  const handleClick = event => {
@@ -52,6 +52,7 @@ import {
52
52
  BRAND_GHOST,
53
53
  BRAND_TEXT_ONLY,
54
54
  SECONDARY_GHOST_BRAND_TINTED_ONSELECT,
55
+ SECONDARY_GHOST_CANCEL,
55
56
  BRAND_TINTED_OUTLINE,
56
57
  BRAND_TEXT_TINTED_HOVER
57
58
  } from '@zohodesk/components/es/v1/Button/constants/presets';
@@ -66,7 +67,7 @@ import {
66
67
  ```jsx
67
68
  <Button variant="icon" iconName="ZD-plus" iconSize={20} />
68
69
 
69
- <Button variant="iconWithText" iconName="ZD-plus" iconPlacement="left">
70
+ <Button variant="iconWithText" iconName="ZD-plus" iconPlacement="start">
70
71
  Add Item
71
72
  </Button>
72
73
  ```
@@ -109,7 +110,7 @@ import {
109
110
  | `shape` | `oneOf: pill, rectangle, roundedRectangle` | `roundedRectangle` | Border shape |
110
111
  | `iconName` | `string` | — | Icon name from `@zohodesk/icons` |
111
112
  | `iconSize` | `number` | `16` | Icon size in pixels |
112
- | `iconPlacement` | `oneOf: left, right` | `left` | Icon position relative to text |
113
+ | `iconPlacement` | `oneOf: start, end` | `start` | Icon position relative to text |
113
114
  | `disabledAppearance` | `oneOf: none, dull, strike` | `dull` | Visual style when disabled |
114
115
  | `isDisabled` | `bool` | `false` | Disables the button |
115
116
  | `isSelected` | `bool` | `false` | Selected/pressed state (`aria-pressed`) |
@@ -143,6 +144,7 @@ Ready-made palette + appearance combinations exported from `constants/presets`:
143
144
  | `SUCCESS_TEXT_ONLY` | `success` | `{ bg: false }` | Text only, no border |
144
145
  | `SUCCESS_TINTED_OUTLINE` | `successLighter` | `{ border: true }` | Tinted fill, success border |
145
146
  | `SECONDARY_GHOST_BRAND_TINTED_ONSELECT` | `secondary` | `{ bg: false, border: true }` | Secondary ghost; selected state switches to brand tint |
147
+ | `SECONDARY_GHOST_CANCEL` | `secondary` | `{ bg: false, border: true }` | Secondary ghost without a selected state; cancel / dismiss buttons |
146
148
  | `BLACK_TEXT_BRAND_ONHOVER` | `brand` | `{ bg: false, text: 'black' }` | Black text, brand color on hover |
147
149
  | `BRAND_BG_ONSELECT` | `brand` | `{ bg: false, border: true }` | Ghost without a defined selected state |
148
150
  | `BRAND_TEXT_TINTED_HOVER` | `brandLighter` | `{ bg: false }` | Ghost that becomes tinted on hover |
@@ -6,7 +6,7 @@ import userEvent from '@testing-library/user-event';
6
6
  import Button from "../index";
7
7
  import '@testing-library/jest-dom';
8
8
  import { PALETTE, VARIANT, SIZE, STATUS, LOADER_PLACEMENT, SHAPE, DISABLED_APPEARANCE, BUTTON_TYPE } from "../constants";
9
- import { BRAND_GHOST, BRAND_TEXT_ONLY, BRAND_TINTED_OUTLINE, SUCCESS_GHOST, SUCCESS_TEXT_ONLY, SUCCESS_TINTED_OUTLINE, SECONDARY_GHOST_BRAND_TINTED_ONSELECT, BLACK_TEXT_BRAND_ONHOVER, BRAND_BG_ONSELECT, BRAND_TEXT_TINTED_HOVER, BRAND_TEXT_TINTED_DANGER_HOVER } from "../constants/presets";
9
+ import { BRAND_GHOST, BRAND_TEXT_ONLY, BRAND_TINTED_OUTLINE, SUCCESS_GHOST, SUCCESS_TEXT_ONLY, SUCCESS_TINTED_OUTLINE, SECONDARY_GHOST_BRAND_TINTED_ONSELECT, SECONDARY_GHOST_CANCEL, BLACK_TEXT_BRAND_ONHOVER, BRAND_BG_ONSELECT, BRAND_TEXT_TINTED_HOVER, BRAND_TEXT_TINTED_DANGER_HOVER } from "../constants/presets";
10
10
  afterEach(() => {
11
11
  cleanup();
12
12
  });
@@ -119,7 +119,7 @@ describe('Button', () => {
119
119
  } = render( /*#__PURE__*/React.createElement(Button, {
120
120
  variant: "iconWithText",
121
121
  iconName: "ZD-plus",
122
- iconPlacement: "right"
122
+ iconPlacement: "end"
123
123
  }, "Button"));
124
124
  expect(asFragment()).toMatchSnapshot();
125
125
  });
@@ -347,7 +347,7 @@ describe('Button', () => {
347
347
  expect(asFragment()).toMatchSnapshot();
348
348
  });
349
349
  describe('Presets', () => {
350
- const presets = [['BRAND_GHOST', BRAND_GHOST], ['BRAND_TEXT_ONLY', BRAND_TEXT_ONLY], ['BRAND_TINTED_OUTLINE', BRAND_TINTED_OUTLINE], ['SUCCESS_GHOST', SUCCESS_GHOST], ['SUCCESS_TEXT_ONLY', SUCCESS_TEXT_ONLY], ['SUCCESS_TINTED_OUTLINE', SUCCESS_TINTED_OUTLINE], ['SECONDARY_GHOST_BRAND_TINTED_ONSELECT', SECONDARY_GHOST_BRAND_TINTED_ONSELECT], ['BLACK_TEXT_BRAND_ONHOVER', BLACK_TEXT_BRAND_ONHOVER], ['BRAND_BG_ONSELECT', BRAND_BG_ONSELECT], ['BRAND_TEXT_TINTED_HOVER', BRAND_TEXT_TINTED_HOVER], ['BRAND_TEXT_TINTED_DANGER_HOVER', BRAND_TEXT_TINTED_DANGER_HOVER]];
350
+ const presets = [['BRAND_GHOST', BRAND_GHOST], ['BRAND_TEXT_ONLY', BRAND_TEXT_ONLY], ['BRAND_TINTED_OUTLINE', BRAND_TINTED_OUTLINE], ['SUCCESS_GHOST', SUCCESS_GHOST], ['SUCCESS_TEXT_ONLY', SUCCESS_TEXT_ONLY], ['SUCCESS_TINTED_OUTLINE', SUCCESS_TINTED_OUTLINE], ['SECONDARY_GHOST_BRAND_TINTED_ONSELECT', SECONDARY_GHOST_BRAND_TINTED_ONSELECT], ['SECONDARY_GHOST_CANCEL', SECONDARY_GHOST_CANCEL], ['BLACK_TEXT_BRAND_ONHOVER', BLACK_TEXT_BRAND_ONHOVER], ['BRAND_BG_ONSELECT', BRAND_BG_ONSELECT], ['BRAND_TEXT_TINTED_HOVER', BRAND_TEXT_TINTED_HOVER], ['BRAND_TEXT_TINTED_DANGER_HOVER', BRAND_TEXT_TINTED_DANGER_HOVER]];
351
351
  test.each(presets)('Should render preset %s', (_name, preset) => {
352
352
  const {
353
353
  asFragment