@wonderflow/react-components 3.0.0-beta.11 → 3.0.0-beta.12
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/dropdown/dropdown.js +20 -7
- package/input-group/input-group.js +3 -3
- package/package.json +1 -1
- package/select/select.js +2 -2
- package/star-meter/star-meter.js +2 -2
- package/textfield/textfield.js +4 -4
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
package/dropdown/dropdown.js
CHANGED
|
@@ -9,6 +9,24 @@ import { DropdownItem } from './item/dropdown-item';
|
|
|
9
9
|
import { DropdownItemCheckbox } from './item-checkbox/dropdown-item-checkbox';
|
|
10
10
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
11
11
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
12
|
+
const DropdownAnimation = {
|
|
13
|
+
visible: {
|
|
14
|
+
y: 0,
|
|
15
|
+
opacity: 1,
|
|
16
|
+
transition: {
|
|
17
|
+
ease: [0, 0, 0.34, 1],
|
|
18
|
+
duration: 0.1
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
hidden: {
|
|
22
|
+
y: -5,
|
|
23
|
+
opacity: 0,
|
|
24
|
+
transition: {
|
|
25
|
+
ease: [0.3, 0.07, 1, 1],
|
|
26
|
+
duration: 0.1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
12
30
|
export const Dropdown = forwardRef(({ className, children, trigger, offset = 8, placement = 'auto-start' }, forwardedRef) => {
|
|
13
31
|
const renderedChildren = Children.toArray(children).filter(Boolean);
|
|
14
32
|
const seedID = useUIDSeed();
|
|
@@ -25,12 +43,7 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
25
43
|
offset: [0, offset],
|
|
26
44
|
closeOnOutsideClick: false
|
|
27
45
|
});
|
|
28
|
-
const isFocusWithin = useFocusWithin(popupRef
|
|
29
|
-
onBlur: (e) => e.relatedTarget && setIsOpen(false),
|
|
30
|
-
onChange: (isFocusWithin) => {
|
|
31
|
-
!isFocusWithin && setIsOpen(false);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
46
|
+
const isFocusWithin = useFocusWithin(popupRef);
|
|
34
47
|
useClickAway(() => {
|
|
35
48
|
setIsOpen(false);
|
|
36
49
|
}, popupRef);
|
|
@@ -41,7 +54,7 @@ export const Dropdown = forwardRef(({ className, children, trigger, offset = 8,
|
|
|
41
54
|
'aria-haspopup': 'true',
|
|
42
55
|
'aria-controls': seedID('dropdown-menu'),
|
|
43
56
|
'aria-expanded': isOpen
|
|
44
|
-
})), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, {
|
|
57
|
+
})), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), className: PopUp, ...getTooltipProps({ className: PopUp }), children: _jsx(motion.div, { variants: DropdownAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(renderedChildren, (child) => cloneElement(child, {
|
|
45
58
|
id: seedID('dropdown-menu'),
|
|
46
59
|
'aria-labelledby': seedID('dropdown-trigger')
|
|
47
60
|
})) }, void 0) }, void 0)) }, void 0)] }, void 0));
|
|
@@ -5,11 +5,11 @@ import { Stack, Text } from '../';
|
|
|
5
5
|
import { useUIDSeed } from 'react-uid';
|
|
6
6
|
import { End, InputField, Start, InputGroup as InputGroupClass } from './input-group.module.css';
|
|
7
7
|
export const InputGroup = forwardRef(({ className, input, end, start, label, dimension = 'regular', ...otherProps }, forwardedRef) => {
|
|
8
|
-
const
|
|
9
|
-
return (_jsxs(Stack, { rowGap: 4, horizontalAlign: "stretch", verticalAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor:
|
|
8
|
+
const seedID = useUIDSeed();
|
|
9
|
+
return (_jsxs(Stack, { rowGap: 4, horizontalAlign: "stretch", verticalAlign: "start", fill: false, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('field'), children: label }, void 0), _jsxs(Stack, { as: "fieldset", direction: "row", verticalAlign: "start", horizontalAlign: "start", fill: false, inline: true, ref: forwardedRef, className: clsx(InputGroupClass, className), "data-input-group-has-end": Boolean(end), "data-input-group-has-start": !!start, ...otherProps, children: [_jsx("div", { className: Start, children: Children.map(start, (child) => cloneElement(child, {
|
|
10
10
|
dimension
|
|
11
11
|
})) }, void 0), _jsx("div", { className: InputField, children: Children.map(input, (child) => cloneElement(child, {
|
|
12
|
-
id:
|
|
12
|
+
id: seedID('field'),
|
|
13
13
|
dimension
|
|
14
14
|
})) }, void 0), _jsx("div", { className: End, children: Children.map(end, (child) => cloneElement(child, {
|
|
15
15
|
dimension
|
package/package.json
CHANGED
package/select/select.js
CHANGED
|
@@ -5,12 +5,12 @@ import { Select as SelectClass, FieldContainer, Icon as IconClass, Field } from
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
7
|
export const Select = forwardRef(({ children, className, disabled = false, icon = 'sort-alt', label, kind = 'single', dimension = 'regular', onChange, ...otherProps }, forwardedRef) => {
|
|
8
|
-
const
|
|
8
|
+
const seedID = useUIDSeed();
|
|
9
9
|
const iconSizes = {
|
|
10
10
|
small: 14,
|
|
11
11
|
regular: 16,
|
|
12
12
|
big: 24
|
|
13
13
|
};
|
|
14
|
-
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(SelectClass, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "aria-disabled": disabled, horizontalAlign: "start", verticalAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor:
|
|
14
|
+
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(SelectClass, className), "data-select-is-multiple": kind === 'multiple', "data-select-has-label": Boolean(label), "data-select-dimension": dimension, "aria-disabled": disabled, horizontalAlign: "start", verticalAlign: "start", inline: true, tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('select'), children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [_jsx("select", { disabled: disabled, className: Field, id: seedID('select'), multiple: kind === 'multiple', onChange: onChange, ref: forwardedRef, ...otherProps, children: children }, void 0), kind === 'single' && (_jsx(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] }, void 0))] }, void 0)] }, void 0));
|
|
15
15
|
});
|
|
16
16
|
Select.displayName = 'Select';
|
package/star-meter/star-meter.js
CHANGED
|
@@ -5,7 +5,7 @@ import { useUIDSeed } from 'react-uid';
|
|
|
5
5
|
import { Text, Stack, Icon } from '../';
|
|
6
6
|
import { StarMeter as StarMeterClass, Gradient, Icon as IconClass } from './star-meter.module.css';
|
|
7
7
|
export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, label, dimension = 'regular', hideLabel = false, ...otherProps }, forwardedRef) => {
|
|
8
|
-
const
|
|
8
|
+
const seedID = useUIDSeed();
|
|
9
9
|
const labelSize = {
|
|
10
10
|
small: 14,
|
|
11
11
|
regular: 16,
|
|
@@ -40,5 +40,5 @@ export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, labe
|
|
|
40
40
|
return _jsx(Icon, { name: "star", className: IconClass, dimension: 16, fill: fillType }, starIndex);
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
|
-
return (_jsxs(Stack, { inline: true, direction: "row", verticalAlign: "center", columnGap: 8, className: clsx(StarMeterClass, className), role: "meter", "aria-valuenow": clamp(value, 0, starCount), "aria-valuemin": 0, "aria-valuemax": starCount, "aria-labelledby":
|
|
43
|
+
return (_jsxs(Stack, { inline: true, direction: "row", verticalAlign: "center", columnGap: 8, className: clsx(StarMeterClass, className), role: "meter", "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: 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)' } }, void 0), _jsx("stop", { offset: "50%", style: { stopColor: 'var(--star-color)' } }, void 0), _jsx("stop", { offset: "50.1%", style: { stopColor: 'var(--star-dimmed-color)' } }, void 0), _jsx("stop", { offset: "100%", style: { stopColor: 'var(--star-dimmed-color)' } }, void 0)] }, void 0) }, void 0) }, void 0), _jsx(Stack, { direction: "row", columnGap: 2, children: starType(starCount, value) }, void 0), _jsx(Text, { dimmed: 6, id: seedID('star-meter'), size: labelSize[dimension], weight: "bold", children: !hideLabel && _jsx(_Fragment, { children: label || value.toString() }, void 0) }, void 0)] }, void 0));
|
|
44
44
|
});
|
package/textfield/textfield.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useUIDSeed } from 'react-uid';
|
|
|
7
7
|
import { Textfield as TextfieldClass, FieldContainer, InputField, Icon as IconClass, IconButton as IconButtonClass } from './textfield.module.css';
|
|
8
8
|
export const Textfield = forwardRef(({ children, className, disabled = false, icon, label, textarea, readOnly, invalid, iconPosition = 'right', dimension = 'regular', type, onChange, ...otherProps }, forwardedRef) => {
|
|
9
9
|
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
10
|
-
const
|
|
10
|
+
const seedID = useUIDSeed();
|
|
11
11
|
const isPassword = type === 'password';
|
|
12
12
|
const handlePasswordVisibility = useCallback(() => {
|
|
13
13
|
setPasswordVisible(visibility => !visibility);
|
|
@@ -28,8 +28,8 @@ export const Textfield = forwardRef(({ children, className, disabled = false, ic
|
|
|
28
28
|
disabled,
|
|
29
29
|
onChange
|
|
30
30
|
};
|
|
31
|
-
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor:
|
|
32
|
-
? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id:
|
|
33
|
-
: (_jsx(BaseField, { className: InputField, id:
|
|
31
|
+
return (_jsxs(Stack, { as: "fieldset", rowGap: 4, className: clsx(TextfieldClass, className), "data-textfield-has-icon": isPassword || Boolean(icon), "data-textfield-icon-position": iconPosition, "data-textfield-dimension": dimension, "data-textfield-invalid": invalid, "aria-disabled": disabled, horizontalAlign: "stretch", verticalAlign: "start", tabIndex: disabled ? 0 : undefined, children: [label && _jsx(Text, { as: "label", size: dimension === 'small' ? 14 : 16, htmlFor: seedID('field'), children: label }, void 0), _jsxs("div", { className: FieldContainer, children: [textarea
|
|
32
|
+
? (_jsx(BaseField, { ref: forwardedRef, as: "textarea", id: seedID('field'), ...commonProps, ...otherProps }, void 0))
|
|
33
|
+
: (_jsx(BaseField, { className: InputField, id: seedID('field'), ref: forwardedRef, type: passwordVisible ? 'text' : type, ...commonProps, ...otherProps }, void 0)), isPassword && (_jsx(IconButton, { className: IconButtonClass, dimension: actionSizes[dimension], onClick: handlePasswordVisibility, kind: "flat", "aria-label": "Reveal password", icon: passwordVisible ? 'eye-slash' : 'eye' }, void 0)), !textarea && icon && type !== 'password' && (_jsx(Icon, { className: IconClass, name: icon, dimension: iconSizes[dimension] }, void 0))] }, void 0)] }, void 0));
|
|
34
34
|
});
|
|
35
35
|
Textfield.displayName = 'Textfield';
|
package/themes/dark.css
CHANGED