reshaped 2.10.19 → 2.11.1
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/CHANGELOG.md +1 -36
- package/bundle.css +1 -1
- package/bundle.js +4 -4
- package/components/Actionable/Actionable.js +4 -4
- package/components/Actionable/tests/Actionable.stories.js +1 -1
- package/components/MenuItem/tests/MenuItem.stories.js +1 -1
- package/components/PinField/PinField.types.d.ts +1 -1
- package/components/PinField/PinFieldControlled.js +6 -6
- package/components/PinField/tests/PinField.stories.js +4 -4
- package/components/View/View.js +2 -0
- package/components/_private/Expandable/Expandable.js +7 -3
- package/components/_private/Expandable/Expandable.module.css +1 -1
- package/package.json +1 -1
@@ -45,10 +45,10 @@ const Actionable = forwardRef((props, ref) => {
|
|
45
45
|
const isEnter = event.key === keys.ENTER;
|
46
46
|
if (!isSpace && !isEnter)
|
47
47
|
return;
|
48
|
-
if (
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
if (rootAttributes.role !== "button")
|
49
|
+
return;
|
50
|
+
event.preventDefault();
|
51
|
+
handlePress(event);
|
52
52
|
};
|
53
53
|
return (_jsx(TagName, Object.assign({ ref: ref }, rootAttributes, { className: rootClassNames, onClick: handlePress, onKeyDown: handleKeyDown, children: children })));
|
54
54
|
});
|
@@ -62,7 +62,7 @@ export const focusRing = () => (<Example>
|
|
62
62
|
</Example.Item>
|
63
63
|
</Example>);
|
64
64
|
export const edgeCases = () => (<Example>
|
65
|
-
<Example.Item title="
|
65
|
+
<Example.Item title="form submit">
|
66
66
|
<form onSubmit={(e) => {
|
67
67
|
e.preventDefault();
|
68
68
|
alert("Submitted");
|
@@ -14,7 +14,7 @@ export default {
|
|
14
14
|
};
|
15
15
|
export const size = () => (<Example>
|
16
16
|
<Example.Item title="size: small">
|
17
|
-
<MenuItem size="small" icon={IconZap}
|
17
|
+
<MenuItem size="small" icon={IconZap} onClick={() => { }}>
|
18
18
|
Menu item
|
19
19
|
</MenuItem>
|
20
20
|
</Example.Item>
|
@@ -3,7 +3,7 @@ export type Size = "medium" | "large" | "xlarge";
|
|
3
3
|
type BaseProps = {
|
4
4
|
name: string;
|
5
5
|
valueLength?: number;
|
6
|
-
|
6
|
+
pattern?: "alphabetic" | "numeric" | "alphanumeric";
|
7
7
|
size?: G.Responsive<Size>;
|
8
8
|
variant?: "outline" | "faded";
|
9
9
|
onChange?: G.ChangeHandler<string>;
|
@@ -21,8 +21,8 @@ const patternMap = {
|
|
21
21
|
alphanumeric: regExpAlphaNumericChar,
|
22
22
|
};
|
23
23
|
const PinFieldControlled = (props) => {
|
24
|
-
const { valueLength = 4, value, onChange, name,
|
25
|
-
const
|
24
|
+
const { valueLength = 4, value, onChange, name, pattern = "numeric", size = "medium", variant = "outline", className, attributes, inputAttributes, } = props;
|
25
|
+
const patternRegexp = patternMap[pattern];
|
26
26
|
const responsiveInputSize = responsivePropDependency(size, (value) => sizeMap[value]);
|
27
27
|
const responsiveTextVariant = responsivePropDependency(size, (value) => value === "medium" ? "body-3" : "body-2");
|
28
28
|
const responsiveRadius = responsivePropDependency(size, (value) => value === "xlarge" ? "medium" : "small");
|
@@ -57,8 +57,8 @@ const PinFieldControlled = (props) => {
|
|
57
57
|
el.selectionStart = nextSelectionStart;
|
58
58
|
el.selectionEnd = nextSelectionStart + 1;
|
59
59
|
}
|
60
|
-
setFocusedIndex(el.selectionStart);
|
61
|
-
}, []);
|
60
|
+
setFocusedIndex(Math.min(el.selectionStart, valueLength - 1));
|
61
|
+
}, [valueLength]);
|
62
62
|
/**
|
63
63
|
* Using onNextFrame here to wait for the native behavior first
|
64
64
|
*/
|
@@ -117,7 +117,7 @@ const PinFieldControlled = (props) => {
|
|
117
117
|
const handleInput = (event) => {
|
118
118
|
const el = event.target;
|
119
119
|
const nextValue = el.value;
|
120
|
-
const matcher = new RegExp(`^${
|
120
|
+
const matcher = new RegExp(`^${patternRegexp}+$`);
|
121
121
|
if (nextValue && !nextValue.match(matcher))
|
122
122
|
return;
|
123
123
|
if (el.selectionStart === null)
|
@@ -156,6 +156,6 @@ const PinFieldControlled = (props) => {
|
|
156
156
|
},
|
157
157
|
}, children: value[i] && _jsx(Text, { variant: responsiveTextVariant, children: value[i] }) }, i));
|
158
158
|
}
|
159
|
-
return (_jsxs(View, { gap: 2, direction: "row", className: [s.root, className], attributes: attributes, children: [nodes, _jsx("input", Object.assign({}, inputAttributes, formControl.attributes, { type: "text", className: s.input, onFocus: handleFocus, onBlur: handleBlur, onPaste: handlePaste, onInput: handleInput, value: value, name: name, maxLength: valueLength, ref: inputRef, autoComplete: (inputAttributes === null || inputAttributes === void 0 ? void 0 : inputAttributes.autoComplete) || "one-time-code", inputMode:
|
159
|
+
return (_jsxs(View, { gap: 2, direction: "row", className: [s.root, className], attributes: attributes, children: [nodes, _jsx("input", Object.assign({}, inputAttributes, formControl.attributes, { type: "text", className: s.input, onFocus: handleFocus, onBlur: handleBlur, onPaste: handlePaste, onInput: handleInput, value: value, name: name, maxLength: valueLength, ref: inputRef, autoComplete: (inputAttributes === null || inputAttributes === void 0 ? void 0 : inputAttributes.autoComplete) || "one-time-code", inputMode: pattern === "numeric" ? "numeric" : undefined, pattern: `${patternRegexp}{${valueLength}}` }))] }));
|
160
160
|
};
|
161
161
|
export default PinFieldControlled;
|
@@ -15,8 +15,8 @@ export const base = () => (<Example>
|
|
15
15
|
<PinField name="pin"/>
|
16
16
|
</Example.Item>
|
17
17
|
|
18
|
-
<Example.Item title="defaultValue:
|
19
|
-
<PinField name="pin2" defaultValue="
|
18
|
+
<Example.Item title="defaultValue: 1234">
|
19
|
+
<PinField name="pin2" defaultValue="1234"/>
|
20
20
|
</Example.Item>
|
21
21
|
|
22
22
|
<Example.Item title="value: 12">
|
@@ -28,11 +28,11 @@ export const base = () => (<Example>
|
|
28
28
|
</Example.Item>
|
29
29
|
|
30
30
|
<Example.Item title="defaultValue: ab, charPattern: alphabetic">
|
31
|
-
<PinField name="pin5" defaultValue="ab"
|
31
|
+
<PinField name="pin5" defaultValue="ab" pattern="alphabetic"/>
|
32
32
|
</Example.Item>
|
33
33
|
|
34
34
|
<Example.Item title="defaultValue: ab, charPattern: alphanumeric">
|
35
|
-
<PinField name="pin6" defaultValue="ab"
|
35
|
+
<PinField name="pin6" defaultValue="ab" pattern="alphanumeric"/>
|
36
36
|
</Example.Item>
|
37
37
|
</Example>);
|
38
38
|
export const variant = () => (<Example>
|
package/components/View/View.js
CHANGED
@@ -129,6 +129,8 @@ const View = (props) => {
|
|
129
129
|
}
|
130
130
|
if (child.type === React.Fragment) {
|
131
131
|
return child.props.children.map((child) => {
|
132
|
+
if (!child)
|
133
|
+
return null;
|
132
134
|
const index = renderedIndex;
|
133
135
|
renderedItemIndex += 1;
|
134
136
|
return renderItem({ child, index });
|
@@ -7,17 +7,21 @@ import { onNextFrame } from "../../../utilities/animation.js";
|
|
7
7
|
const Expandable = (props) => {
|
8
8
|
const { children, active, attributes } = props;
|
9
9
|
const [animated, setAnimated] = React.useState(false);
|
10
|
-
const rootClassNames = classNames(s.root, active && s["--active"]);
|
10
|
+
const rootClassNames = classNames(s.root, active && animated && s["--active"], !active && !animated && s["--hidden"]);
|
11
11
|
const handleTransitionEnd = (e) => {
|
12
12
|
if (e.propertyName !== "height")
|
13
13
|
return;
|
14
|
+
if (active)
|
15
|
+
return;
|
14
16
|
onNextFrame(() => {
|
15
17
|
setAnimated(false);
|
16
18
|
});
|
17
19
|
};
|
18
20
|
React.useEffect(() => {
|
19
|
-
|
21
|
+
if (!active)
|
22
|
+
return;
|
23
|
+
setAnimated(active);
|
20
24
|
}, [active]);
|
21
|
-
return (_jsx("div", Object.assign({}, attributes, { className: rootClassNames, onTransitionEnd: handleTransitionEnd, role: "region", hidden: !active
|
25
|
+
return (_jsx("div", Object.assign({}, attributes, { className: rootClassNames, onTransitionEnd: handleTransitionEnd, role: "region", hidden: !active, children: _jsx("div", { className: s.inner, children: children }) })));
|
22
26
|
};
|
23
27
|
export default Expandable;
|
@@ -1 +1 @@
|
|
1
|
-
.root{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--rs-duration-slow) var(--rs-easing-standard)}.--active{grid-template-rows:1fr}.inner{overflow:hidden}
|
1
|
+
.root{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--rs-duration-slow) var(--rs-easing-standard)}.--active{grid-template-rows:1fr}.--hidden{display:none}.inner{overflow:hidden}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "2.
|
4
|
+
"version": "2.11.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|