@wonderflow/react-components 12.1.0 → 12.1.2
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/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +3 -2
- package/dist/components/icon-button/icon-button.module.css +1 -1
- package/dist/components/overlay-container/overlay-container.d.ts.map +1 -1
- package/dist/components/overlay-container/overlay-container.js +2 -1
- package/dist/components/pagination/pagination.module.css +1 -1
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/popover/popover.js +2 -1
- package/dist/components/star-meter/star-meter.js +1 -1
- package/dist/components/text/text.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +2 -1
- package/dist/utils/browser.d.ts +2 -0
- package/dist/utils/browser.d.ts.map +1 -0
- package/dist/utils/browser.js +18 -0
- package/dist/utils/browser.test.d.ts +2 -0
- package/dist/utils/browser.test.d.ts.map +1 -0
- package/dist/utils/browser.test.js +7 -0
- package/dist/utils/convertions.test.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAC+B,yBAAyB,EAG7D,SAAS,EAEV,MAAM,OAAO,CAAC;AAMf,OAAO,EAEM,cAAc,EAC1B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAC+B,yBAAyB,EAG7D,SAAS,EAEV,MAAM,OAAO,CAAC;AAMf,OAAO,EAEM,cAAc,EAC1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAiB,SAAS,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAsB,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,aAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,oBAAY,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC;IAC5D;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC,CAAC,CAAC;AAEJ,aAAK,qBAAqB,GAAG,yBAAyB,CAAC,iBAAiB,CAAC,GAAG;IAC1E,MAAM,EAAE,yBAAyB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAA;AAqBD,eAAO,MAAM,YAAY,uBAyKE,CAAC"}
|
|
@@ -22,6 +22,7 @@ import { mergeRefs } from 'react-merge-refs';
|
|
|
22
22
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
23
23
|
import { useUIDSeed } from 'react-uid';
|
|
24
24
|
import { Menu, Skeleton, Stack, Text, Textfield, } from '../..';
|
|
25
|
+
import { isBrowser } from '../../utils/browser';
|
|
25
26
|
import * as styles from './autocomplete.module.css';
|
|
26
27
|
import { AutocompleteOption } from './autocomplete-option';
|
|
27
28
|
const AutocompleteAnimation = {
|
|
@@ -63,7 +64,7 @@ export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly
|
|
|
63
64
|
}, [debounceQuery, children]);
|
|
64
65
|
const isFocusWithin = useFocusWithin(autocompleteRef, {
|
|
65
66
|
onChange: (isFocusWithin) => {
|
|
66
|
-
const m = document.getElementById(seedID('autocomplete-menu'));
|
|
67
|
+
const m = isBrowser() && document.getElementById(seedID('autocomplete-menu'));
|
|
67
68
|
if (isFocusWithin || m) {
|
|
68
69
|
setIsOpen(true);
|
|
69
70
|
}
|
|
@@ -107,7 +108,7 @@ export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly
|
|
|
107
108
|
setValue(String(val));
|
|
108
109
|
setOptionValues(currentValues);
|
|
109
110
|
}, [filteredOptions, val]);
|
|
110
|
-
return (_jsxs("div", { ref: autocompleteRef, className: styles.Autocomplete, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { "aria-haspopup": true, "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, role: "combobox", ref: mergeRefs([setTriggerRef, forwardedRef]), id: seedID('autocomplete-trigger'), onChange: handleFilter, "data-testid": "Autocomplete", "data-current-value": value, value: query, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), visible && createPortal(_jsx(AnimatePresence, { children: _jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: styles.PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(LazyMotion, { features: domMax, strict: true, children: _jsx(m.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsxs(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: styles.OptionsList, maxHeight: maxHeight, "aria-labelledby": seedID('autocomplete-trigger'), children: [(filteredOptions.length === 0 && !busy) && _jsx(Text, { as: "div", textAlign: "center", children: emptyContent }), busy
|
|
111
|
+
return (_jsxs("div", { ref: autocompleteRef, className: styles.Autocomplete, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { "aria-haspopup": true, "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, role: "combobox", ref: mergeRefs([setTriggerRef, forwardedRef]), id: seedID('autocomplete-trigger'), onChange: handleFilter, "data-testid": "Autocomplete", "data-current-value": value, value: query, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), isBrowser() && visible && createPortal(_jsx(AnimatePresence, { children: _jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: styles.PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(LazyMotion, { features: domMax, strict: true, children: _jsx(m.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsxs(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: styles.OptionsList, maxHeight: maxHeight, "aria-labelledby": seedID('autocomplete-trigger'), children: [(filteredOptions.length === 0 && !busy) && _jsx(Text, { as: "div", textAlign: "center", children: emptyContent }), busy
|
|
111
112
|
? _jsx(Stack, { hPadding: 8, as: "span", children: _jsx(Skeleton, { count: 3 }) })
|
|
112
113
|
: Children.map(filteredOptions, child => isValidElement(child) && cloneElement(child, {
|
|
113
114
|
onClick: handleOptionClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.IconButton{padding:0}.IconButton[data-icon-button-squared=false]{border-radius:
|
|
1
|
+
@layer components{.IconButton{padding:0}.IconButton[data-icon-button-squared=false]{border-radius:50%}.IconButton[data-button-dimension=small]{inline-size:1.5rem;min-inline-size:1.5rem;padding:0}.IconButton[data-button-dimension=regular]{block-size:2.5rem;inline-size:2.5rem;min-inline-size:2.5rem;padding:0}.IconButton[data-button-dimension=big]{inline-size:3rem;min-inline-size:3rem;padding:0}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay-container.d.ts","sourceRoot":"","sources":["../../../src/components/overlay-container/overlay-container.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"overlay-container.d.ts","sourceRoot":"","sources":["../../../src/components/overlay-container/overlay-container.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAS7C,oBAAY,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,qBAAqB,CA8C9D,CAAC"}
|
|
@@ -19,6 +19,7 @@ import { useEffect } from 'react';
|
|
|
19
19
|
import { createPortal } from 'react-dom';
|
|
20
20
|
import { useUIDSeed } from 'react-uid';
|
|
21
21
|
import { OverlayProvider } from '../..';
|
|
22
|
+
import { isBrowser } from '../../utils/browser';
|
|
22
23
|
import * as styles from './overlay-container.module.css';
|
|
23
24
|
export const OverlayContainer = ({ children, root, overlayColor = 'dark', index = 4, obfuscate = true, onClose, }) => {
|
|
24
25
|
const seedID = useUIDSeed();
|
|
@@ -28,5 +29,5 @@ export const OverlayContainer = ({ children, root, overlayColor = 'dark', index
|
|
|
28
29
|
}
|
|
29
30
|
}, [root]);
|
|
30
31
|
const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (_jsx("div", { "data-overlay-container": true, "data-overlay-container-obfuscate": obfuscate, className: styles.OverlayContainer, style: { zIndex: index }, children: _jsxs(LazyMotion, { features: domMax, children: [obfuscate && (_jsx(m.span, { className: styles.Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 }, exit: { opacity: 0 } }, seedID('modal-backdrop'))), children] }) })) }) }));
|
|
31
|
-
return createPortal(content, root ?? document.body);
|
|
32
|
+
return isBrowser() ? createPortal(content, root ?? document.body) : null;
|
|
32
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.Pagination{font-size:.875rem;list-style:none;margin:0;padding:0}.Pagination,.Pagination>li>a{align-items:center;display:inline-flex}.Pagination>li>a{border-radius:.25rem;color:var(--dimmed-
|
|
1
|
+
@layer components{.Pagination{font-size:.875rem;list-style:none;margin:0;padding:0}.Pagination,.Pagination>li>a{align-items:center;display:inline-flex}.Pagination>li>a{border-radius:.25rem;color:var(--dimmed-7);cursor:pointer;font-weight:600;height:2rem;justify-content:center;line-height:1.25rem;min-width:2rem;padding:0 .5rem;-webkit-user-select:none;user-select:none}.Pagination>li>a[aria-current=page]{background-color:var(--cta-default);color:var(--cta-foreground)}.Pagination>li>a[aria-disabled=true]{opacity:.5}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EAAE,aAAa,EAAY,kBAAkB,EAC3D,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAgBA,OAAO,EACL,aAAa,EAAE,aAAa,EAAY,kBAAkB,EAC3D,MAAM,gBAAgB,CAAC;AAUxB,OAAO,EAML,SAAS,EAKV,MAAM,OAAO,CAAC;AASf,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAA;AA0BD,eAAO,MAAM,OAAO;;;iEAgIlB,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { createPortal } from 'react-dom';
|
|
|
8
8
|
import { mergeRefs } from 'react-merge-refs';
|
|
9
9
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
10
10
|
import { useUIDSeed } from 'react-uid';
|
|
11
|
+
import { isBrowser } from '../../utils/browser';
|
|
11
12
|
import * as styles from './popover.module.css';
|
|
12
13
|
const cssEasingToArray = (cssEasing) => {
|
|
13
14
|
const [x1, y1, x2, y2] = cssEasing.replace(/[^0-9.,]+/g, '').split(',').map(i => parseFloat(i));
|
|
@@ -97,7 +98,7 @@ export const Popover = forwardRef(({ children, trigger, offset = 8, placement =
|
|
|
97
98
|
'aria-controls': seedID('popover-dialog'),
|
|
98
99
|
'aria-expanded': isOpen,
|
|
99
100
|
...otherProps,
|
|
100
|
-
}), visible && createPortal(_jsx(AnimatePresence, { children: _jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: styles.PopUp }), children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: PopoverAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(children, child => isValidElement(child) && cloneElement(child, {
|
|
101
|
+
}), isBrowser() && visible && createPortal(_jsx(AnimatePresence, { children: _jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: styles.PopUp }), children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: PopoverAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(children, child => isValidElement(child) && cloneElement(child, {
|
|
101
102
|
id: seedID('popover-dialog'),
|
|
102
103
|
'aria-labelledby': seedID('popover-trigger'),
|
|
103
104
|
})) }) }) }, seedID('tooltip-content')) }), root ?? document.body)] }));
|
|
@@ -61,5 +61,5 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
61
61
|
return (_jsx(Symbol, { source: "star", weight: "solid", className: styles.Icon, dimension: properties[dimension].iconSize, fill: fillType }, starIndex));
|
|
62
62
|
});
|
|
63
63
|
}, [dimension, properties, roundValue]);
|
|
64
|
-
return (_jsxs(Stack, { inline: true, direction: "row", vAlign: "center", columnGap: 8, className: clsx(styles.StarMeter, className), role: "meter", fill: false, "aria-valuenow": clamp(value, 0, starCount), "aria-valuemin": 0, "aria-valuemax": starCount, "aria-labelledby": seedID('star-meter'), "data-star-meter-dimension": dimension, ref: forwardedRef, ...otherProps, children: [_jsx("svg", { "aria-hidden": "true", className: styles.Gradient, width: "100", height: "50", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: _jsx("defs", { children: _jsxs("linearGradient", { id: "HalfStar", children: [_jsx("stop", { offset: "0", style: { stopColor: 'var(--star-color)' } }), _jsx("stop", { offset: "50%", style: { stopColor: 'var(--star-color)' } }), _jsx("stop", { offset: "50.1%", style: { stopColor: 'var(--star-dimmed-color)' } }), _jsx("stop", { offset: "100%", style: { stopColor: 'var(--star-dimmed-color)' } })] }) }) }), _jsx(Stack, { direction: "row", columnGap: dimension === 'small' ? 2 : 4, vAlign: "center", children: starType(starCount, value) }), _jsx(Text, { preventResponsive: true, id: seedID('star-meter'), variant: properties[dimension].labelSize, children: _jsx("b", { children: (!hideLabel && label) ?? value.toString() }) })] }));
|
|
64
|
+
return (_jsxs(Stack, { inline: true, direction: "row", vAlign: "center", columnGap: 8, className: clsx(styles.StarMeter, className), role: "meter", fill: false, "aria-valuenow": clamp(value, 0, starCount), "aria-valuemin": 0, "aria-valuemax": starCount, "aria-labelledby": seedID('star-meter'), "data-star-meter-dimension": dimension, ref: forwardedRef, ...otherProps, children: [_jsx("svg", { "aria-hidden": "true", className: styles.Gradient, width: "100", height: "50", version: "1.1", xmlns: "http://www.w3.org/2000/svg", children: _jsx("defs", { children: _jsxs("linearGradient", { id: "HalfStar", children: [_jsx("stop", { offset: "0", style: { stopColor: 'var(--star-color)' } }), _jsx("stop", { offset: "50%", style: { stopColor: 'var(--star-color)' } }), _jsx("stop", { offset: "50.1%", style: { stopColor: 'var(--star-dimmed-color)' } }), _jsx("stop", { offset: "100%", style: { stopColor: 'var(--star-dimmed-color)' } })] }) }) }), _jsx(Stack, { direction: "row", columnGap: dimension === 'small' ? 2 : 4, vAlign: "center", children: starType(starCount, value) }), _jsx(Text, { preventResponsive: true, preventBreakWord: true, id: seedID('star-meter'), variant: properties[dimension].labelSize, children: _jsx("b", { children: (!hideLabel && label) ?? value.toString() }) })] }));
|
|
65
65
|
});
|
|
@@ -77,7 +77,7 @@ export const Text = forwardRef(({ children, className, variant = 'body-1', color
|
|
|
77
77
|
return label;
|
|
78
78
|
}, [children]);
|
|
79
79
|
const generatedID = slugify(String(id ?? getTextFromChildren()), { lower: true, replacement: '_' });
|
|
80
|
-
return (_jsxs(Wrapper, { ref: forwardedRef, "data-text-variant": variant, "data-text-color": color, "data-text-prevent-responsive": preventResponsive, "data-text-truncate": truncate, "data-text-decorator": hasStart || hasEnd, "data-text-prevent-break-word": preventBreakWord, className: clsx(styles.Text, className), style: { ...dynamicStyle, ...style }, id: id || (isTitle &&
|
|
80
|
+
return (_jsxs(Wrapper, { ref: forwardedRef, "data-text-variant": variant, "data-text-color": color, "data-text-prevent-responsive": preventResponsive, "data-text-truncate": truncate, "data-text-decorator": hasStart || hasEnd, "data-text-prevent-break-word": preventBreakWord, className: clsx(styles.Text, className), style: { ...dynamicStyle, ...style }, id: id || (isTitle && anchor) ? generatedID : undefined, ...otherProps, children: [hasStart
|
|
81
81
|
&& isValidElement(decoratorStart)
|
|
82
82
|
&& cloneElement(decoratorStart, {
|
|
83
83
|
...decoratorStart.props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EACgE,SAAS,EAC/E,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/tooltip.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EACgE,SAAS,EAC/E,MAAM,OAAO,CAAC;AAUf,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,eAAe,CAAC,YAAY,CAoFjD,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { createPortal } from 'react-dom';
|
|
|
5
5
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
7
|
import { Elevator } from '../..';
|
|
8
|
+
import { isBrowser } from '../../utils/browser';
|
|
8
9
|
import * as styles from './tooltip.module.css';
|
|
9
10
|
export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, style, maxWidth = '40ch', fill = false, interactive = false, delay = 500, root, }) => {
|
|
10
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -43,5 +44,5 @@ export const Tooltip = ({ children, trigger, placement = 'bottom-start', open, s
|
|
|
43
44
|
ref: setTriggerRef,
|
|
44
45
|
tabIndex: 0,
|
|
45
46
|
'aria-describedby': id,
|
|
46
|
-
})), visible && createPortal(_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: id, "data-theme": "dark", ...getTooltipProps({ className: styles.Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: styles.Arrow }) })] }) }), root ?? document.body)] }));
|
|
47
|
+
})), isBrowser() && visible && createPortal(_jsx(Elevator, { resting: 1, children: _jsxs("div", { ref: setTooltipRef, role: "tooltip", id: id, "data-theme": "dark", ...getTooltipProps({ className: styles.Balloon, style: dynamycStyle }), children: [children, _jsx("div", { ...getArrowProps({ className: styles.Arrow }) })] }) }), root ?? document.body)] }));
|
|
47
48
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/utils/browser.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,SAAS,2BAEiB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Wonderflow Design Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export const isBrowser = () => (typeof window !== 'undefined'
|
|
17
|
+
&& window.document
|
|
18
|
+
&& window.document.documentElement);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.test.d.ts","sourceRoot":"","sources":["../../src/utils/browser.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { cssRelativeUnitsToPixel } from './conversions';
|
|
2
2
|
describe('cssRelativeUnitsToPixel()', () => {
|
|
3
3
|
const rightCases = ['20rem', '20em'];
|
|
4
|
-
const wrongCases = ['abc', '20Rem', '20eM', '20ReM', '20EM', '20px', '20%'];
|
|
5
4
|
rightCases.map(c => it(`should return 320 with input "${c}"`, () => {
|
|
6
5
|
const res = cssRelativeUnitsToPixel(c);
|
|
7
6
|
expect(res).toBe(320);
|
|
8
7
|
}));
|
|
8
|
+
const wrongCases = ['abc', '20Rem', '20eM', '20ReM', '20EM', '20px', '20%'];
|
|
9
9
|
wrongCases.map(c => it(`should return -1 with input "${c}"`, () => {
|
|
10
10
|
const res = cssRelativeUnitsToPixel(c);
|
|
11
11
|
expect(res).toBe(-1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.2",
|
|
4
4
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"@types/react-dom": "17.0.14",
|
|
83
83
|
"@types/react-table": "7.7.12",
|
|
84
84
|
"@types/react-test-renderer": "18.0.0",
|
|
85
|
-
"@wonderflow/config": "12.1.
|
|
86
|
-
"@wonderflow/tokens": "12.1.
|
|
85
|
+
"@wonderflow/config": "12.1.2",
|
|
86
|
+
"@wonderflow/tokens": "12.1.2",
|
|
87
87
|
"babel-loader": "8.2.5",
|
|
88
88
|
"cpy-cli": "3.1.1",
|
|
89
89
|
"postcss": "8.4.17",
|