@zohodesk/components 1.0.0-temp-259.2 → 1.0.0-temp-260
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 +21 -3
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +20 -5
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +20 -5
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +20 -5
- package/es/AdvancedPopup/AdvancedPopup.js +105 -0
- package/es/v1/Button/Button.js +107 -159
- package/es/v1/Button/README.md +2 -3
- package/es/v1/Button/__tests__/Button.spec.js +6 -14
- package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +169 -249
- package/es/v1/Button/constants/index.js +20 -26
- package/es/v1/Button/css/Button_v1.module.css +16 -37
- package/es/v1/Button/css/cssJSLogic.js +28 -56
- package/es/v1/Button/props/defaultProps.js +6 -2
- package/es/v1/Button/props/propTypes.js +8 -26
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
- package/es/v1/helpers/colorHelpers/colorHelper.js +139 -117
- package/es/v1/helpers/colorHelpers/constants/index.js +4 -45
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/lib/AdvancedPopup/AdvancedPopup.js +122 -0
- package/lib/v1/Button/Button.js +119 -178
- package/lib/v1/Button/README.md +2 -3
- package/lib/v1/Button/__tests__/Button.spec.js +52 -66
- package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +169 -249
- package/lib/v1/Button/constants/index.js +28 -31
- package/lib/v1/Button/css/Button_v1.module.css +16 -37
- package/lib/v1/Button/css/cssJSLogic.js +19 -42
- package/lib/v1/Button/props/defaultProps.js +5 -1
- package/lib/v1/Button/props/propTypes.js +7 -41
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
- package/lib/v1/helpers/colorHelpers/colorHelper.js +153 -127
- package/lib/v1/helpers/colorHelpers/constants/index.js +4 -45
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/package.json +4 -4
- package/es/v1/Button/constants/presets.js +0 -147
- package/lib/v1/Button/constants/presets.js +0 -165
package/README.md
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zohodesk/components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reusable React UI primitives for building DOT applications. This package is part of the **DOT System** (**D**esign **O**ptimization **T**hinking).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @zohodesk/components
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Import the UI building blocks you need from `@zohodesk/components` and use them in your React app for common interface patterns, including:
|
|
14
|
+
|
|
15
|
+
- Buttons, inputs, and form controls
|
|
16
|
+
- Overlays, dialogs, and selection patterns
|
|
17
|
+
- Avatars, tabs, and other shared UI primitives
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import * as components from '@zohodesk/components';
|
|
21
|
+
```
|
|
4
22
|
|
|
5
23
|
## Changelog
|
|
6
24
|
|
|
7
|
-
See [CHANGELOG.md](
|
|
25
|
+
See [CHANGELOG.md](https://unpkg.com/@zohodesk/components/CHANGELOG.md) for details on release history and updates.
|
|
@@ -16,15 +16,30 @@
|
|
|
16
16
|
--zdt_v1_label_secondary_text: hsla(217, calc(var(--zd-saturation, 1) * 13.73%), calc(70.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
17
17
|
|
|
18
18
|
/* palette - universal color tokens */
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
19
|
+
--zdt_v1_palette_brand_filled_text: var(--zdt_cta_secondary_text);
|
|
20
|
+
--zdt_v1_palette_brand_bg: var(--zdt_cta_primary_bg);
|
|
21
|
+
--zdt_v1_palette_brand_text: var(--zdt_cta_primary_text);
|
|
22
|
+
--zdt_v1_palette_brand_border: var(--zdt_cta_primary_border);
|
|
23
|
+
--zdt_v1_palette_brand_hover_bg: var(--zdt_cta_primary_hover_bg);
|
|
24
|
+
--zdt_v1_palette_brand_hover_text: var(--zdt_cta_primary_hover_text);
|
|
25
|
+
--zdt_v1_palette_brand_hover_border: var(--zdt_cta_primary_hover_border);
|
|
26
|
+
--zdt_v1_palette_brand_light_bg: var(--zdt_cta_primary_light_bg);
|
|
27
|
+
--zdt_v1_palette_brand_light_hover_bg: var(--zdt_cta_primary_light_hover_bg);
|
|
28
|
+
--zdt_v1_palette_brand_light_border: var(--zdt_cta_primary_light_border);
|
|
29
|
+
--zdt_v1_palette_grey_light_bg: hsla(217, calc(var(--zd-saturation, 1) * 23.23%), calc(19.41% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
30
|
+
--zdt_v1_palette_grey_light_border: hsla(218, calc(var(--zd-saturation, 1) * 23.08%), calc(22.94% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
31
|
+
--zdt_v1_palette_grey_light_hover_bg: hsla(218, calc(var(--zd-saturation, 1) * 23.08%), calc(22.94% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
24
32
|
--zdt_v1_palette_grey_bg: hsla(217, calc(var(--zd-saturation, 1) * 13.73%), calc(70.00% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
33
|
+
--zdt_v1_palette_grey_text: hsla(217, calc(var(--zd-saturation, 1) * 13.73%), calc(70.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
34
|
+
--zdt_v1_palette_grey_border: hsla(217, calc(var(--zd-saturation, 1) * 13.73%), calc(70.00% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
25
35
|
--zdt_v1_palette_grey_hover_bg: hsla(217, calc(var(--zd-saturation, 1) * 7.76%), calc(54.51% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
26
36
|
--zdt_v1_palette_grey_hover_text: hsla(217, calc(var(--zd-saturation, 1) * 13.73%), calc(70.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
37
|
+
--zdt_v1_palette_grey_hover_border: hsla(217, calc(var(--zd-saturation, 1) * 7.76%), calc(54.51% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
38
|
+
--zdt_v1_palette_blue_bg: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
39
|
+
--zdt_v1_palette_blue_text: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
40
|
+
--zdt_v1_palette_blue_border: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
27
41
|
--zdt_v1_palette_blue_hover_bg: hsla(213, calc(var(--zd-saturation, 1) * 85.45%), calc(43.14% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
42
|
+
--zdt_v1_palette_blue_hover_text: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(71.57% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
28
43
|
--zdt_v1_palette_blue_hover_border: hsla(213, calc(var(--zd-saturation, 1) * 85.45%), calc(43.14% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
29
44
|
--zdt_v1_palette_blue_light_bg: hsla(213, calc(var(--zd-saturation, 1) * 27.27%), calc(23.73% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
|
|
30
45
|
--zdt_v1_palette_blue_light_border: hsla(208, calc(var(--zd-saturation, 1) * 85.19%), calc(73.53% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
@@ -16,15 +16,30 @@
|
|
|
16
16
|
--zdt_v1_label_secondary_text: hsla(220, calc(var(--zd-saturation, 1) * 10.45%), calc(39.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
17
17
|
|
|
18
18
|
/* palette - universal color tokens */
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
19
|
+
--zdt_v1_palette_brand_filled_text: var(--zdt_cta_secondary_text);
|
|
20
|
+
--zdt_v1_palette_brand_bg: var(--zdt_cta_primary_bg);
|
|
21
|
+
--zdt_v1_palette_brand_text: var(--zdt_cta_primary_text);
|
|
22
|
+
--zdt_v1_palette_brand_border: var(--zdt_cta_primary_border);
|
|
23
|
+
--zdt_v1_palette_brand_hover_bg: var(--zdt_cta_primary_hover_bg);
|
|
24
|
+
--zdt_v1_palette_brand_hover_text: var(--zdt_cta_primary_hover_text);
|
|
25
|
+
--zdt_v1_palette_brand_hover_border: var(--zdt_cta_primary_hover_border);
|
|
26
|
+
--zdt_v1_palette_brand_light_bg: var(--zdt_cta_primary_light_bg);
|
|
27
|
+
--zdt_v1_palette_brand_light_hover_bg: var(--zdt_cta_primary_light_hover_bg);
|
|
28
|
+
--zdt_v1_palette_brand_light_border: var(--zdt_cta_primary_light_border);
|
|
29
|
+
--zdt_v1_palette_grey_light_bg: hsla(216, calc(var(--zd-saturation, 1) * 38.46%), calc(97.45% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
30
|
+
--zdt_v1_palette_grey_light_border: hsla(210, calc(var(--zd-saturation, 1) * 33.33%), calc(94.12% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
31
|
+
--zdt_v1_palette_grey_light_hover_bg: hsla(210, calc(var(--zd-saturation, 1) * 33.33%), calc(94.12% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
24
32
|
--zdt_v1_palette_grey_bg: hsla(220, calc(var(--zd-saturation, 1) * 10.45%), calc(39.41% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
33
|
+
--zdt_v1_palette_grey_text: hsla(220, calc(var(--zd-saturation, 1) * 10.45%), calc(39.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
34
|
+
--zdt_v1_palette_grey_border: hsla(220, calc(var(--zd-saturation, 1) * 10.45%), calc(39.41% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
25
35
|
--zdt_v1_palette_grey_hover_bg: hsla(218, calc(var(--zd-saturation, 1) * 9.76%), calc(51.76% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
26
36
|
--zdt_v1_palette_grey_hover_text: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(0.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
37
|
+
--zdt_v1_palette_grey_hover_border: hsla(218, calc(var(--zd-saturation, 1) * 9.76%), calc(51.76% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
38
|
+
--zdt_v1_palette_blue_bg: hsla(212, calc(var(--zd-saturation, 1) * 91.84%), calc(48.04% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
39
|
+
--zdt_v1_palette_blue_text: hsla(212, calc(var(--zd-saturation, 1) * 91.84%), calc(48.04% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
40
|
+
--zdt_v1_palette_blue_border: hsla(212, calc(var(--zd-saturation, 1) * 91.84%), calc(48.04% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
27
41
|
--zdt_v1_palette_blue_hover_bg: hsla(213, calc(var(--zd-saturation, 1) * 100.00%), calc(36.08% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
42
|
+
--zdt_v1_palette_blue_hover_text: hsla(213, calc(var(--zd-saturation, 1) * 100.00%), calc(36.08% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
28
43
|
--zdt_v1_palette_blue_hover_border: hsla(213, calc(var(--zd-saturation, 1) * 100.00%), calc(36.08% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
29
44
|
--zdt_v1_palette_blue_light_bg: hsla(212, calc(var(--zd-saturation, 1) * 86.67%), calc(97.06% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
|
|
30
45
|
--zdt_v1_palette_blue_light_border: hsla(208, calc(var(--zd-saturation, 1) * 85.19%), calc(73.53% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
@@ -16,15 +16,30 @@
|
|
|
16
16
|
--zdt_v1_label_secondary_text: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(60.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
17
17
|
|
|
18
18
|
/* palette - universal color tokens */
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
19
|
+
--zdt_v1_palette_brand_filled_text: var(--zdt_cta_secondary_text);
|
|
20
|
+
--zdt_v1_palette_brand_bg: var(--zdt_cta_primary_bg);
|
|
21
|
+
--zdt_v1_palette_brand_text: var(--zdt_cta_primary_text);
|
|
22
|
+
--zdt_v1_palette_brand_border: var(--zdt_cta_primary_border);
|
|
23
|
+
--zdt_v1_palette_brand_hover_bg: var(--zdt_cta_primary_hover_bg);
|
|
24
|
+
--zdt_v1_palette_brand_hover_text: var(--zdt_cta_primary_hover_text);
|
|
25
|
+
--zdt_v1_palette_brand_hover_border: var(--zdt_cta_primary_hover_border);
|
|
26
|
+
--zdt_v1_palette_brand_light_bg: var(--zdt_cta_primary_light_bg);
|
|
27
|
+
--zdt_v1_palette_brand_light_hover_bg: var(--zdt_cta_primary_light_hover_bg);
|
|
28
|
+
--zdt_v1_palette_brand_light_border: var(--zdt_cta_primary_light_border);
|
|
29
|
+
--zdt_v1_palette_grey_light_bg: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(14.90% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
30
|
+
--zdt_v1_palette_grey_light_border: hsla(0, calc(var(--zd-saturation, 1) * 2.33%), calc(8.43% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
31
|
+
--zdt_v1_palette_grey_light_hover_bg: hsla(0, calc(var(--zd-saturation, 1) * 2.33%), calc(8.43% + var(--zdc_darker_lowest)), calc(1 + var(--zdc_alpha_high)));
|
|
24
32
|
--zdt_v1_palette_grey_bg: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(60.00% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
33
|
+
--zdt_v1_palette_grey_text: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(60.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
34
|
+
--zdt_v1_palette_grey_border: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(60.00% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
25
35
|
--zdt_v1_palette_grey_hover_bg: hsla(217, calc(var(--zd-saturation, 1) * 7.76%), calc(54.51% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
26
36
|
--zdt_v1_palette_grey_hover_text: hsla(0, calc(var(--zd-saturation, 1) * 0.00%), calc(60.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
|
|
37
|
+
--zdt_v1_palette_grey_hover_border: hsla(217, calc(var(--zd-saturation, 1) * 7.76%), calc(54.51% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
38
|
+
--zdt_v1_palette_blue_bg: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
39
|
+
--zdt_v1_palette_blue_text: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
40
|
+
--zdt_v1_palette_blue_border: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(63.92% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
27
41
|
--zdt_v1_palette_blue_hover_bg: hsla(213, calc(var(--zd-saturation, 1) * 85.45%), calc(43.14% + var(--zdc_darker_low)), calc(1 + var(--zdc_alpha_low)));
|
|
42
|
+
--zdt_v1_palette_blue_hover_text: hsla(212, calc(var(--zd-saturation, 1) * 100.00%), calc(71.57% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
28
43
|
--zdt_v1_palette_blue_hover_border: hsla(213, calc(var(--zd-saturation, 1) * 85.45%), calc(43.14% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
|
|
29
44
|
--zdt_v1_palette_blue_light_bg: hsla(213, calc(var(--zd-saturation, 1) * 19.57%), calc(18.04% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
|
|
30
45
|
--zdt_v1_palette_blue_light_border: hsla(208, calc(var(--zd-saturation, 1) * 85.19%), calc(73.53% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { useAdvancedPopup } from '@zohodesk/dotkit/es/react/components/Popup/hooks/useAdvancedPopup.js';
|
|
5
|
+
import { getLibraryConfig } from "../Provider/Config.js";
|
|
6
|
+
|
|
7
|
+
const AdvancedPopup = PopupComponent => {
|
|
8
|
+
const wrapper = props => {
|
|
9
|
+
const positionMetaRef = useRef(null);
|
|
10
|
+
const triggerMetaRef = useRef(null);
|
|
11
|
+
const initialPlacementRef = useRef(props.defaultPosition);
|
|
12
|
+
|
|
13
|
+
const getRootElement = () => {
|
|
14
|
+
return getLibraryConfig('getRootElement');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getMobileWidth = () => {
|
|
18
|
+
return getLibraryConfig('mobileWidth');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
isArrow,
|
|
23
|
+
defaultPosition,
|
|
24
|
+
customOrder,
|
|
25
|
+
isAbsolutePositioningNeeded,
|
|
26
|
+
isOutsideScrollBlocked,
|
|
27
|
+
sizeModifiers,
|
|
28
|
+
checkBeforeClose,
|
|
29
|
+
scrollDebounceTime,
|
|
30
|
+
needResizeHandling,
|
|
31
|
+
popupGroup
|
|
32
|
+
} = props;
|
|
33
|
+
const {
|
|
34
|
+
setTriggerElement,
|
|
35
|
+
setContainerElement,
|
|
36
|
+
togglePopup,
|
|
37
|
+
openPopupOnly,
|
|
38
|
+
closePopupOnly,
|
|
39
|
+
closePopupFromRange,
|
|
40
|
+
isPopupOpen,
|
|
41
|
+
isPopupReady,
|
|
42
|
+
removeClose,
|
|
43
|
+
recomputePosition,
|
|
44
|
+
isMobile,
|
|
45
|
+
position
|
|
46
|
+
} = useAdvancedPopup({
|
|
47
|
+
strategy: isAbsolutePositioningNeeded === false ? 'fixed' : 'absolute',
|
|
48
|
+
groupName: popupGroup,
|
|
49
|
+
checkBeforeClose,
|
|
50
|
+
getRootElement,
|
|
51
|
+
scrollDebounceTime,
|
|
52
|
+
enableResizeHandling: needResizeHandling,
|
|
53
|
+
sizeModifiers,
|
|
54
|
+
onPositionChange: meta => {
|
|
55
|
+
positionMetaRef.current = meta;
|
|
56
|
+
},
|
|
57
|
+
onVisibilityChange: isVisible => {
|
|
58
|
+
triggerMetaRef.current = isVisible;
|
|
59
|
+
},
|
|
60
|
+
middleware: {
|
|
61
|
+
autoPlacement: {
|
|
62
|
+
initialPlacement: initialPlacementRef.current,
|
|
63
|
+
placementOrder: customOrder
|
|
64
|
+
},
|
|
65
|
+
arrow: {
|
|
66
|
+
isRequired: !!isArrow
|
|
67
|
+
},
|
|
68
|
+
scrollable: !isOutsideScrollBlocked,
|
|
69
|
+
applyStyles: true,
|
|
70
|
+
mobile: {
|
|
71
|
+
isEnabled: true,
|
|
72
|
+
breakpoint: getMobileWidth()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return /*#__PURE__*/React.createElement(PopupComponent, _extends({}, props, {
|
|
77
|
+
getTargetRef: setTriggerElement,
|
|
78
|
+
getContainerRef: setContainerElement,
|
|
79
|
+
togglePopup: (e, initialPlacement) => {
|
|
80
|
+
initialPlacementRef.current = initialPlacement;
|
|
81
|
+
togglePopup(e);
|
|
82
|
+
},
|
|
83
|
+
openPopupOnly: (e, initialPlacement) => {
|
|
84
|
+
initialPlacementRef.current = initialPlacement;
|
|
85
|
+
openPopupOnly(e);
|
|
86
|
+
},
|
|
87
|
+
closePopupOnly: closePopupOnly,
|
|
88
|
+
closePopupFromRange: closePopupFromRange,
|
|
89
|
+
removeClose: removeClose,
|
|
90
|
+
recomputePosition: recomputePosition,
|
|
91
|
+
isMobile: isMobile,
|
|
92
|
+
position: position?.view,
|
|
93
|
+
positions: position?.views,
|
|
94
|
+
positionsOffset: position?.viewsOffset,
|
|
95
|
+
targetOffset: position?.targetOffset,
|
|
96
|
+
popupOffset: position?.popupOffset,
|
|
97
|
+
isPopupOpen: isPopupOpen,
|
|
98
|
+
isPopupReady: isPopupReady
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return wrapper;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export default AdvancedPopup;
|
package/es/v1/Button/Button.js
CHANGED
|
@@ -6,32 +6,31 @@ 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 Typography from "../../Typography/Typography";
|
|
9
10
|
import { isRenderable } from '@zohodesk/utils/es/renderNode';
|
|
10
11
|
import renderNode from '@zohodesk/utils/es/renderNode';
|
|
12
|
+
import propTypes from "./props/propTypes";
|
|
13
|
+
import defaultProps from "./props/defaultProps";
|
|
11
14
|
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
12
15
|
import { ICON_PLACEMENT, LOADER_PLACEMENT, STATUS, TYPOGRAPHY_SIZE_MAP, VARIANT } from "./constants";
|
|
13
|
-
import Typography from "../../Typography/Typography";
|
|
14
16
|
import Spinner from "../shared/Spinner/Spinner";
|
|
15
17
|
import SuccessTick from "../shared/SuccessTick/SuccessTick";
|
|
16
18
|
import cssJSLogic from "./css/cssJSLogic";
|
|
17
|
-
import propTypes from "./props/propTypes";
|
|
18
|
-
import defaultProps from "./props/defaultProps";
|
|
19
19
|
|
|
20
20
|
const getTypographySize = size => TYPOGRAPHY_SIZE_MAP[size] || '13';
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
23
23
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
isDisabledState,
|
|
28
|
-
overlayActive,
|
|
24
|
+
palette,
|
|
25
|
+
bgAppearance,
|
|
26
|
+
borderAppearance,
|
|
29
27
|
variant,
|
|
30
|
-
|
|
28
|
+
status,
|
|
31
29
|
loaderPlacement,
|
|
32
30
|
size,
|
|
33
31
|
iconName,
|
|
34
32
|
iconSize,
|
|
33
|
+
iconPlacement,
|
|
35
34
|
renderIcon,
|
|
36
35
|
renderBefore,
|
|
37
36
|
renderAfter,
|
|
@@ -39,87 +38,104 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
|
|
|
39
38
|
renderSuccess,
|
|
40
39
|
children,
|
|
41
40
|
type,
|
|
41
|
+
onClick,
|
|
42
|
+
isDisabled,
|
|
43
|
+
isReadOnly,
|
|
42
44
|
isSelected,
|
|
45
|
+
shape,
|
|
46
|
+
paletteShade,
|
|
47
|
+
disabledAppearance,
|
|
43
48
|
title,
|
|
44
49
|
customProps,
|
|
45
50
|
customAttributes,
|
|
46
51
|
a11yAttributes,
|
|
47
52
|
customId,
|
|
48
|
-
testId
|
|
49
|
-
dataSelectorId,
|
|
50
|
-
handleClick,
|
|
51
|
-
classNames
|
|
53
|
+
testId
|
|
52
54
|
} = props;
|
|
55
|
+
const isLoading = status === STATUS.LOADING;
|
|
56
|
+
const isSuccess = status === STATUS.SUCCESS;
|
|
57
|
+
const isDisabledState = isDisabled || isLoading;
|
|
58
|
+
const isInteractionDisabled = isDisabledState || isReadOnly;
|
|
59
|
+
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
60
|
+
const {
|
|
61
|
+
text: contentProps = DUMMY_OBJECT,
|
|
62
|
+
icon: iconProps = DUMMY_OBJECT
|
|
63
|
+
} = customProps;
|
|
64
|
+
const iconTagAttributes = useMemo(() => ({ ...(iconProps.tagAttributes || DUMMY_OBJECT),
|
|
65
|
+
'data-test-id': testId ? `${testId}_icon` : undefined
|
|
66
|
+
}), [iconProps.tagAttributes, testId]);
|
|
67
|
+
const classes = useMemo(() => cssJSLogic({
|
|
68
|
+
props
|
|
69
|
+
}), [palette, bgAppearance, borderAppearance, paletteShade, size, variant, status, isDisabled, isReadOnly, isSelected, shape, loaderPlacement, disabledAppearance, props.customClass]);
|
|
53
70
|
const {
|
|
54
71
|
loaderOverlayClass,
|
|
55
72
|
successOverlayClass,
|
|
56
73
|
contentWrapperClass,
|
|
57
74
|
textClassName,
|
|
58
75
|
buttonClassName,
|
|
59
|
-
iconClassName
|
|
60
|
-
|
|
61
|
-
successClassName
|
|
62
|
-
} = classNames;
|
|
63
|
-
const {
|
|
64
|
-
text: contentProps = DUMMY_OBJECT,
|
|
65
|
-
icon: iconProps = DUMMY_OBJECT
|
|
66
|
-
} = customProps || DUMMY_OBJECT;
|
|
67
|
-
const {
|
|
68
|
-
button: buttonAttributes = DUMMY_OBJECT,
|
|
69
|
-
contentWrapper: contentWrapperAttributes = DUMMY_OBJECT,
|
|
70
|
-
loader: loaderAttributes = DUMMY_OBJECT,
|
|
71
|
-
success: successAttributes = DUMMY_OBJECT,
|
|
72
|
-
icon: iconAttributes = DUMMY_OBJECT,
|
|
73
|
-
text: textAttributes = DUMMY_OBJECT
|
|
74
|
-
} = customAttributes || DUMMY_OBJECT;
|
|
75
|
-
const iconTagAttributes = { ...iconAttributes,
|
|
76
|
-
'data-test-id': testId ? `${testId}_icon` : undefined
|
|
77
|
-
};
|
|
76
|
+
iconClassName
|
|
77
|
+
} = classes;
|
|
78
78
|
const showIcon = variant !== VARIANT.TEXT && (renderIcon || iconName);
|
|
79
79
|
|
|
80
|
+
const _handleClick = event => {
|
|
81
|
+
if (isInteractionDisabled) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onClick(event);
|
|
86
|
+
};
|
|
87
|
+
|
|
80
88
|
const _renderLoader = () => {
|
|
81
|
-
if (!isLoading)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
if (!isLoading) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (isRenderable(renderLoader)) {
|
|
94
|
+
return renderNode(renderLoader, {
|
|
95
|
+
status
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const loaderClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? loaderOverlayClass : '';
|
|
100
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
88
101
|
$ui_displayMode: "flex",
|
|
89
102
|
$ui_alignItems: "center",
|
|
90
103
|
$ui_justifyContent: "center",
|
|
91
|
-
$ui_className:
|
|
104
|
+
$ui_className: loaderClassName,
|
|
92
105
|
testId: testId ? `${testId}_loader` : undefined
|
|
93
|
-
},
|
|
94
|
-
status: STATUS.LOADING
|
|
95
|
-
}) : /*#__PURE__*/React.createElement(Spinner, {
|
|
96
|
-
customClass: loaderClassName
|
|
97
|
-
}));
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Spinner, null));
|
|
98
107
|
};
|
|
99
108
|
|
|
100
109
|
const _renderSuccess = () => {
|
|
101
|
-
if (!isSuccess)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
if (!isSuccess) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (isRenderable(renderSuccess)) {
|
|
115
|
+
return renderNode(renderSuccess, {
|
|
116
|
+
status
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const successClassName = loaderPlacement === LOADER_PLACEMENT.OVERLAY ? successOverlayClass : '';
|
|
121
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
108
122
|
$ui_displayMode: "flex",
|
|
109
123
|
$ui_alignItems: "center",
|
|
110
124
|
$ui_justifyContent: "center",
|
|
111
|
-
$ui_className:
|
|
125
|
+
$ui_className: successClassName,
|
|
112
126
|
testId: testId ? `${testId}_success` : undefined
|
|
113
|
-
},
|
|
114
|
-
status: STATUS.SUCCESS
|
|
115
|
-
}) : /*#__PURE__*/React.createElement(SuccessTick, {
|
|
116
|
-
customClass: successClassName
|
|
117
|
-
}));
|
|
127
|
+
}, /*#__PURE__*/React.createElement(SuccessTick, null));
|
|
118
128
|
};
|
|
119
129
|
|
|
120
130
|
const _renderIconNode = () => {
|
|
121
|
-
if (!showIcon)
|
|
122
|
-
|
|
131
|
+
if (!showIcon) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (isRenderable(renderIcon)) {
|
|
136
|
+
return renderNode(renderIcon);
|
|
137
|
+
}
|
|
138
|
+
|
|
123
139
|
return /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
|
|
124
140
|
iconClass: iconClassName,
|
|
125
141
|
name: iconName,
|
|
@@ -129,126 +145,58 @@ export const ButtonPresentational = /*#__PURE__*/forwardRef(function ButtonPrese
|
|
|
129
145
|
}));
|
|
130
146
|
};
|
|
131
147
|
|
|
148
|
+
const _renderBeforeNode = () => {
|
|
149
|
+
if (!isRenderable(renderBefore)) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return renderNode(renderBefore, props);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const _renderAfterNode = () => {
|
|
157
|
+
if (!isRenderable(renderAfter)) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return renderNode(renderAfter, props);
|
|
162
|
+
};
|
|
163
|
+
|
|
132
164
|
const _renderContent = () => {
|
|
133
|
-
const shouldShowText = variant !== VARIANT.ICON && children
|
|
165
|
+
const shouldShowText = variant !== VARIANT.ICON && children !== undefined && children !== null;
|
|
134
166
|
const showLoaderStart = isLoading && loaderPlacement === LOADER_PLACEMENT.START;
|
|
135
167
|
const showLoaderAfter = isLoading && loaderPlacement === LOADER_PLACEMENT.END;
|
|
136
168
|
const showSuccessStart = isSuccess && loaderPlacement === LOADER_PLACEMENT.START;
|
|
137
169
|
const showSuccessAfter = isSuccess && loaderPlacement === LOADER_PLACEMENT.END;
|
|
138
|
-
return /*#__PURE__*/React.createElement(Flex,
|
|
170
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
139
171
|
$ui_displayMode: "flex",
|
|
140
172
|
$ui_direction: "row",
|
|
141
173
|
$flag_shrink: true,
|
|
142
174
|
$ui_alignItems: "center",
|
|
143
175
|
$ui_justifyContent: "center",
|
|
144
176
|
$ui_className: contentWrapperClass
|
|
145
|
-
},
|
|
146
|
-
$ui_size: getTypographySize(size)
|
|
147
|
-
}, contentProps, {
|
|
148
|
-
tagAttributes: textAttributes,
|
|
177
|
+
}, showLoaderStart ? _renderLoader() : null, showSuccessStart ? _renderSuccess() : null, _renderBeforeNode(), iconPlacement === ICON_PLACEMENT.LEFT ? _renderIconNode() : null, shouldShowText ? /*#__PURE__*/React.createElement(Typography, _extends({}, contentProps, {
|
|
149
178
|
$ui_className: textClassName,
|
|
179
|
+
$ui_size: getTypographySize(size),
|
|
150
180
|
$flag_dotted: variant !== VARIANT.ICON
|
|
151
|
-
}), children) :
|
|
181
|
+
}), children) : null, iconPlacement === ICON_PLACEMENT.RIGHT ? _renderIconNode() : null, _renderAfterNode(), showLoaderAfter ? _renderLoader() : null, showSuccessAfter ? _renderSuccess() : null);
|
|
152
182
|
};
|
|
153
183
|
|
|
154
|
-
const containerAttributes = { ...
|
|
155
|
-
'data-id':
|
|
156
|
-
'data-test-id':
|
|
157
|
-
'data-selector-id': dataSelectorId,
|
|
184
|
+
const containerAttributes = { ...customAttributes,
|
|
185
|
+
'data-id': customId,
|
|
186
|
+
'data-test-id': testId,
|
|
158
187
|
'data-title': title
|
|
159
188
|
};
|
|
160
|
-
return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes, {
|
|
161
|
-
"aria-busy": isLoading,
|
|
162
|
-
disabled: isDisabledState,
|
|
163
|
-
"aria-pressed": isSelected
|
|
164
|
-
}, a11yAttributes, {
|
|
189
|
+
return /*#__PURE__*/React.createElement("button", _extends({}, containerAttributes, a11yAttributes, {
|
|
165
190
|
ref: ref,
|
|
166
191
|
type: type,
|
|
167
192
|
className: cn(buttonClassName),
|
|
168
|
-
|
|
193
|
+
"aria-busy": isLoading,
|
|
194
|
+
"aria-disabled": isDisabledState,
|
|
195
|
+
"aria-readonly": isReadOnly,
|
|
196
|
+
"aria-pressed": isSelected,
|
|
197
|
+
onClick: _handleClick
|
|
169
198
|
}), _renderContent(), overlayActive ? isLoading ? _renderLoader() : _renderSuccess() : null);
|
|
170
199
|
});
|
|
171
|
-
ButtonPresentational.displayName = 'ButtonPresentational';
|
|
172
|
-
const Button = /*#__PURE__*/forwardRef(function Button(props, ref) {
|
|
173
|
-
const {
|
|
174
|
-
palette,
|
|
175
|
-
appearance,
|
|
176
|
-
hoverAppearance,
|
|
177
|
-
selectedAppearance,
|
|
178
|
-
variant,
|
|
179
|
-
status,
|
|
180
|
-
loaderPlacement,
|
|
181
|
-
size,
|
|
182
|
-
iconName,
|
|
183
|
-
iconSize,
|
|
184
|
-
iconPlacement,
|
|
185
|
-
renderIcon,
|
|
186
|
-
renderBefore,
|
|
187
|
-
renderAfter,
|
|
188
|
-
renderLoader,
|
|
189
|
-
renderSuccess,
|
|
190
|
-
children,
|
|
191
|
-
type,
|
|
192
|
-
onClick,
|
|
193
|
-
isDisabled,
|
|
194
|
-
isSelected,
|
|
195
|
-
shape,
|
|
196
|
-
disabledAppearance,
|
|
197
|
-
title,
|
|
198
|
-
customProps,
|
|
199
|
-
customAttributes,
|
|
200
|
-
a11yAttributes,
|
|
201
|
-
customId,
|
|
202
|
-
testId,
|
|
203
|
-
dataSelectorId
|
|
204
|
-
} = props;
|
|
205
|
-
const isLoading = status === STATUS.LOADING;
|
|
206
|
-
const isSuccess = status === STATUS.SUCCESS;
|
|
207
|
-
const isDisabledState = isDisabled || isLoading;
|
|
208
|
-
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
209
|
-
const classNames = useMemo(() => cssJSLogic({
|
|
210
|
-
props
|
|
211
|
-
}), [palette, appearance, hoverAppearance, selectedAppearance, size, variant, status, isDisabled, isSelected, shape, loaderPlacement, disabledAppearance, props.customClass]);
|
|
212
|
-
|
|
213
|
-
const handleClick = event => {
|
|
214
|
-
if (isDisabledState) return;
|
|
215
|
-
onClick(event);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const essentials = {
|
|
219
|
-
isLoading,
|
|
220
|
-
isSuccess,
|
|
221
|
-
isDisabled,
|
|
222
|
-
isDisabledState,
|
|
223
|
-
overlayActive,
|
|
224
|
-
variant,
|
|
225
|
-
iconPlacement,
|
|
226
|
-
loaderPlacement,
|
|
227
|
-
size,
|
|
228
|
-
iconName,
|
|
229
|
-
iconSize,
|
|
230
|
-
renderIcon,
|
|
231
|
-
renderBefore,
|
|
232
|
-
renderAfter,
|
|
233
|
-
renderLoader,
|
|
234
|
-
renderSuccess,
|
|
235
|
-
children,
|
|
236
|
-
type,
|
|
237
|
-
isSelected,
|
|
238
|
-
title,
|
|
239
|
-
customProps,
|
|
240
|
-
customAttributes,
|
|
241
|
-
a11yAttributes,
|
|
242
|
-
customId,
|
|
243
|
-
testId,
|
|
244
|
-
dataSelectorId,
|
|
245
|
-
handleClick
|
|
246
|
-
};
|
|
247
|
-
return /*#__PURE__*/React.createElement(ButtonPresentational, _extends({}, essentials, {
|
|
248
|
-
classNames: classNames,
|
|
249
|
-
ref: ref
|
|
250
|
-
}));
|
|
251
|
-
});
|
|
252
200
|
Button.propTypes = propTypes;
|
|
253
201
|
Button.defaultProps = defaultProps;
|
|
254
202
|
Button.displayName = 'Button';
|
package/es/v1/Button/README.md
CHANGED
|
@@ -62,9 +62,8 @@ import Button from '@zohodesk/components/es/v1/Button/Button';
|
|
|
62
62
|
| `customId` | `string` | — | `data-id` attribute for automation |
|
|
63
63
|
| `testId` | `string` | — | `data-test-id` attribute for testing |
|
|
64
64
|
| `palette` | `oneOf: default, primary, secondary, danger, success` | `default` | Color palette |
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `selectedAppearance` | `array of: border, text, bg` | `['bg', 'border']` | Which treatments are colored when `isSelected` |
|
|
65
|
+
| `bgAppearance` | `oneOf: filled, onHover, none` | `filled` | Background behavior |
|
|
66
|
+
| `borderAppearance` | `oneOf: default, onHover, none` | `default` | Border behavior |
|
|
68
67
|
| `variant` | `oneOf: text, icon, iconWithText` | `text` | Display variant |
|
|
69
68
|
| `size` | `oneOf: small, medium, large, full` | `medium` | Size variant |
|
|
70
69
|
| `status` | `oneOf: default, loading, success` | `default` | Status state |
|
|
@@ -28,29 +28,21 @@ describe('Button - Component', () => {
|
|
|
28
28
|
}));
|
|
29
29
|
expect(asFragment()).toMatchSnapshot();
|
|
30
30
|
});
|
|
31
|
-
const
|
|
32
|
-
test.each(
|
|
31
|
+
const bgAppearance = ['default', 'onHover', 'none'];
|
|
32
|
+
test.each(bgAppearance)('Should render bgAppearance of buttons - %s', bg => {
|
|
33
33
|
const {
|
|
34
34
|
asFragment
|
|
35
35
|
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
36
|
-
|
|
36
|
+
bgAppearance: bg
|
|
37
37
|
}));
|
|
38
38
|
expect(asFragment()).toMatchSnapshot();
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
const borderAppearance = ['default', 'onHover', 'none'];
|
|
41
|
+
test.each(borderAppearance)('Should render borderAppearance of buttons - %s', border => {
|
|
41
42
|
const {
|
|
42
43
|
asFragment
|
|
43
44
|
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
44
|
-
|
|
45
|
-
}));
|
|
46
|
-
expect(asFragment()).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
test.each(appearanceCombos.map(combo => [combo]))('Should render selectedAppearance of buttons - %s', appearance => {
|
|
49
|
-
const {
|
|
50
|
-
asFragment
|
|
51
|
-
} = render( /*#__PURE__*/React.createElement(Button, {
|
|
52
|
-
isSelected: true,
|
|
53
|
-
selectedAppearance: appearance
|
|
45
|
+
borderAppearance: border
|
|
54
46
|
}));
|
|
55
47
|
expect(asFragment()).toMatchSnapshot();
|
|
56
48
|
});
|