@wonderflow/react-components 3.0.0-beta.10 → 3.0.0-beta.14
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/datetime/datetime.d.ts +7 -0
- package/datetime/datetime.js +16 -0
- package/datetime/index.d.ts +2 -0
- package/datetime/index.js +1 -0
- package/drawer/drawer.d.ts +4 -0
- package/dropdown/dropdown.js +20 -7
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/input-group/input-group.js +3 -3
- package/list/list.js +1 -1
- package/list/list.module.css +1 -1
- package/package.json +15 -10
- package/select/select.js +2 -2
- package/star-meter/star-meter.d.ts +4 -0
- package/star-meter/star-meter.js +4 -4
- package/text/text.js +1 -1
- package/textfield/textfield.js +4 -4
- package/themes/dark.css +1 -1
- package/themes/light.css +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export declare type DatetimeProps = HTMLAttributes<HTMLTimeElement> & {
|
|
3
|
+
date: string;
|
|
4
|
+
locale?: string | string[];
|
|
5
|
+
options?: Intl.DateTimeFormatOptions;
|
|
6
|
+
};
|
|
7
|
+
export declare const Datetime: ({ date, locale, options, ...otherProps }: DatetimeProps) => JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
export const Datetime = ({ date, locale = 'en-US', options, ...otherProps }) => {
|
|
4
|
+
const [datetime, setDateTime] = useState('');
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const timeDate = new Date(date);
|
|
7
|
+
const humanDate = new Intl.DateTimeFormat(locale, {
|
|
8
|
+
year: 'numeric',
|
|
9
|
+
month: 'long',
|
|
10
|
+
day: 'numeric',
|
|
11
|
+
...options
|
|
12
|
+
}).format(timeDate);
|
|
13
|
+
setDateTime(humanDate);
|
|
14
|
+
}, [date, locale, options]);
|
|
15
|
+
return (_jsx("time", { dateTime: date, ...otherProps, children: datetime }, void 0));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Datetime } from './datetime';
|
package/drawer/drawer.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export declare type DrawerProps = PropsWithChildren<PropsWithClass> & {
|
|
|
35
35
|
side?: 'left' | 'right';
|
|
36
36
|
/**
|
|
37
37
|
* Disable the modal behavior of the drawer.
|
|
38
|
+
* If `false`, disable the prop `closeOnClickOutside` and
|
|
39
|
+
* the page is not blocked when the drawer is open.
|
|
38
40
|
*/
|
|
39
41
|
isModal?: boolean;
|
|
40
42
|
};
|
|
@@ -76,6 +78,8 @@ export declare const Drawer: import("react").ForwardRefExoticComponent<PropsWith
|
|
|
76
78
|
side?: "left" | "right" | undefined;
|
|
77
79
|
/**
|
|
78
80
|
* Disable the modal behavior of the drawer.
|
|
81
|
+
* If `false`, disable the prop `closeOnClickOutside` and
|
|
82
|
+
* the page is not blocked when the drawer is open.
|
|
79
83
|
*/
|
|
80
84
|
isModal?: boolean | undefined;
|
|
81
85
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
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));
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { ClampText } from './clamp-text';
|
|
|
16
16
|
export type { ClampTextProps } from './clamp-text';
|
|
17
17
|
export { Container } from './container';
|
|
18
18
|
export type { ContainerProps } from './container';
|
|
19
|
+
export { Datetime } from './datetime';
|
|
20
|
+
export type { DatetimeProps } from './datetime';
|
|
19
21
|
export { Drawer } from './drawer';
|
|
20
22
|
export type { DrawerProps } from './drawer';
|
|
21
23
|
export { Table } from './table';
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { Chip } from './chip';
|
|
|
8
8
|
export { CircularProgress } from './circular-progress';
|
|
9
9
|
export { ClampText } from './clamp-text';
|
|
10
10
|
export { Container } from './container';
|
|
11
|
+
export { Datetime } from './datetime';
|
|
11
12
|
export { Drawer } from './drawer';
|
|
12
13
|
export { Table } from './table';
|
|
13
14
|
export { Disclosure } from './disclosure';
|
|
@@ -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/list/list.js
CHANGED
|
@@ -19,5 +19,5 @@ export const List = forwardRef(({ as: Wrapper = 'ul', children, marker = 'circle
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
const isUnordered = useMemo(() => Wrapper === 'ul', [Wrapper]);
|
|
22
|
-
return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Text, { as: "li", size: sizes[dimension].text, children: [isUnordered && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), child.props.children] }, void 0))) }, void 0));
|
|
22
|
+
return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Text, { as: "li", size: sizes[dimension].text, children: [(isUnordered && !hideMarker) && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, "data-list-default-marker": marker === 'circle', dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), child.props.children] }, void 0))) }, void 0));
|
|
23
23
|
});
|
package/list/list.module.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.List{--marker-size:0.89rem;--marker-gap:0.44rem}.List[data-list-
|
|
1
|
+
.List{--marker-size:0.89rem;--marker-gap:0.44rem}.List[data-list-ordered=false]{list-style:none;padding:0}.List[data-list-ordered=false] li{padding-inline-start:calc(var(--marker-size) + var(--marker-gap));position:relative}.List[data-list-ordered=true] li{padding-inline-start:var(--marker-gap)}.List[data-list-ordered=true] li::marker{color:var(--dimmed-5)}.List[data-list-size=small]{--marker-size:0.77rem;--marker-gap:0.44rem}.List[data-list-size=big]{--marker-size:1.11rem;--marker-gap:0.89rem}.List[data-list-no-marker=true]{--marker-size:0;--marker-gap:0;list-style:none;padding:0}.Marker{block-size:var(--marker-size);inline-size:var(--marker-size);left:0;position:absolute;top:calc(var(--marker-size)/2.4)}.Marker[data-list-default-marker=true]{transform:scale(.7)}.List[data-list-size=small] .Marker{top:3px}.List[data-list-size=big] .Marker{top:calc(var(--marker-size)/3)}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
3
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.14",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/wonderflow-bv/react-components/issues"
|
|
27
27
|
},
|
|
28
|
-
"homepage": "https://
|
|
28
|
+
"homepage": "https://design.wonderflow.ai/",
|
|
29
29
|
"browserslist": [
|
|
30
30
|
"last 2 Chrome versions",
|
|
31
31
|
"last 2 Firefox versions",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@wonderflow/tokens": "1.3.7",
|
|
68
|
-
"ahooks": "3.1.
|
|
68
|
+
"ahooks": "3.1.2",
|
|
69
69
|
"clsx": "1.1.1",
|
|
70
70
|
"framer-motion": "4.1.17",
|
|
71
71
|
"postcss": "^8.4.5",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"react-data-table-component": "7.4.6",
|
|
74
74
|
"react-dom": "^17.0",
|
|
75
75
|
"react-focus-on": "3.5.4",
|
|
76
|
-
"react-loading-skeleton": "3.0.
|
|
76
|
+
"react-loading-skeleton": "3.0.2",
|
|
77
77
|
"react-masonry-css": "1.0.16",
|
|
78
78
|
"react-paginate": "8.1.0",
|
|
79
79
|
"react-popper-tooltip": "4.3.1",
|
|
@@ -89,8 +89,8 @@
|
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@babel/core": "7.16.5",
|
|
92
|
-
"@commitlint/cli": "
|
|
93
|
-
"@commitlint/config-conventional": "
|
|
92
|
+
"@commitlint/cli": "16.0.0",
|
|
93
|
+
"@commitlint/config-conventional": "16.0.0",
|
|
94
94
|
"@semantic-release/exec": "6.0.3",
|
|
95
95
|
"@semantic-release/git": "10.0.1",
|
|
96
96
|
"@semantic-release/github": "8.0.2",
|
|
@@ -132,15 +132,15 @@
|
|
|
132
132
|
"semantic-release": "18.0.1",
|
|
133
133
|
"storybook-addon-themes": "6.1.0",
|
|
134
134
|
"storybook-css-modules-preset": "1.1.1",
|
|
135
|
-
"style-dictionary": "3.
|
|
135
|
+
"style-dictionary": "3.1.1",
|
|
136
136
|
"styled-components": "5.3.3",
|
|
137
|
-
"stylelint": "14.
|
|
137
|
+
"stylelint": "14.2.0",
|
|
138
138
|
"svgo": "2.8.0",
|
|
139
139
|
"svgstore": "3.0.1",
|
|
140
140
|
"typescript": "4.5.4",
|
|
141
141
|
"typescript-plugin-css-modules": "3.4.0",
|
|
142
142
|
"webpack": "5.65.0",
|
|
143
|
-
"yargs": "17.3.
|
|
143
|
+
"yargs": "17.3.1"
|
|
144
144
|
},
|
|
145
145
|
"resolutions": {
|
|
146
146
|
"rc": "1.2.8"
|
|
@@ -162,7 +162,12 @@
|
|
|
162
162
|
"plugins": [
|
|
163
163
|
"commit-analyzer-fail-on-no-release",
|
|
164
164
|
"@semantic-release/release-notes-generator",
|
|
165
|
-
|
|
165
|
+
[
|
|
166
|
+
"@semantic-release/github",
|
|
167
|
+
{
|
|
168
|
+
"addReleases": true
|
|
169
|
+
}
|
|
170
|
+
],
|
|
166
171
|
[
|
|
167
172
|
"@semantic-release/npm",
|
|
168
173
|
{
|
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';
|
|
@@ -26,6 +26,10 @@ export declare type StarMeterProps = {
|
|
|
26
26
|
* Set the size of the star meter.
|
|
27
27
|
*/
|
|
28
28
|
dimension?: 'small' | 'regular' | 'big';
|
|
29
|
+
/**
|
|
30
|
+
* Hide the label indicator.
|
|
31
|
+
*/
|
|
32
|
+
hideLabel?: boolean;
|
|
29
33
|
};
|
|
30
34
|
declare type PolymorphicStarMeter = Polymorphic.ForwardRefComponent<Polymorphic.IntrinsicElement<typeof Stack>, Polymorphic.OwnProps<typeof Stack> & StarMeterProps>;
|
|
31
35
|
export declare const StarMeter: PolymorphicStarMeter;
|
package/star-meter/star-meter.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
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
|
-
export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, label, dimension = 'regular', ...otherProps }, forwardedRef) => {
|
|
8
|
-
const
|
|
7
|
+
export const StarMeter = forwardRef(({ className, value = 0, starCount = 5, label, dimension = 'regular', hideLabel = false, ...otherProps }, forwardedRef) => {
|
|
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/text/text.js
CHANGED
|
@@ -7,5 +7,5 @@ export const Text = forwardRef(({ children, className, size, sentiment, dimmed,
|
|
|
7
7
|
'--maxW': maxWidth,
|
|
8
8
|
'--tAlign': textAlign
|
|
9
9
|
};
|
|
10
|
-
return (_jsx(Wrapper, { ref: forwardedRef, "data-text-size": size, "data-text-weight": weight, "data-text-sentiment": sentiment, "data-text-dimmed": dimmed, "data-text-responsive": responsive, className: clsx(TextClass, className), style: { ...dynamicStyle, ...style }, ...otherProps, children: children }, void 0));
|
|
10
|
+
return (_jsx(Wrapper, { ref: forwardedRef, "data-text-size": size, "data-text-weight": weight, "data-text-sentiment": sentiment, "data-text-dimmed": dimmed, "data-text-responsive": size === 14 ? 14 : responsive, className: clsx(TextClass, className), style: { ...dynamicStyle, ...style }, ...otherProps, children: children }, void 0));
|
|
11
11
|
});
|
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