@planningcenter/tapestry-react 2.3.0 → 2.5.0
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/cjs/Button/Button.js +13 -9
- package/dist/cjs/Scrim/Scrim.js +1 -1
- package/dist/cjs/Sidebar/Sidebar.js +1 -1
- package/dist/esm/Button/Button.js +13 -9
- package/dist/esm/Scrim/Scrim.js +1 -1
- package/dist/esm/Sidebar/Sidebar.js +1 -1
- package/dist/types/Button/Button.d.ts +5 -1
- package/package.json +2 -2
- package/src/Button/Button.tsx +21 -6
- package/src/Scrim/Scrim.tsx +1 -1
- package/src/Sidebar/Sidebar.js +3 -2
- package/src/.DS_Store +0 -0
|
@@ -54,8 +54,10 @@ function Button(_ref) {
|
|
|
54
54
|
title = _ref.title,
|
|
55
55
|
to = _ref.to,
|
|
56
56
|
tooltip = _ref.tooltip,
|
|
57
|
+
_ref$type = _ref.type,
|
|
58
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
57
59
|
variant = _ref.variant,
|
|
58
|
-
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["children", "disabled", "external", "icon", "iconLeft", "iconRight", "onClick", "onKeyDown", "size", "spinner", "square", "theme", "title", "to", "tooltip", "variant"]);
|
|
60
|
+
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["children", "disabled", "external", "icon", "iconLeft", "iconRight", "onClick", "onKeyDown", "size", "spinner", "square", "theme", "title", "to", "tooltip", "type", "variant"]);
|
|
59
61
|
var buttonThemes = (0, _system.useThemeValue)('button.themes');
|
|
60
62
|
|
|
61
63
|
var _useBoxSize = (0, _system.useBoxSize)(size),
|
|
@@ -80,7 +82,8 @@ function Button(_ref) {
|
|
|
80
82
|
strokeAlign: 'inside',
|
|
81
83
|
strokeWeight: 1,
|
|
82
84
|
userSelect: 'none',
|
|
83
|
-
zIndex: 1
|
|
85
|
+
zIndex: 1,
|
|
86
|
+
type: type
|
|
84
87
|
};
|
|
85
88
|
var spinnerColor;
|
|
86
89
|
|
|
@@ -229,12 +232,13 @@ function Button(_ref) {
|
|
|
229
232
|
|
|
230
233
|
|
|
231
234
|
if (restProps.as) {
|
|
232
|
-
buttonProps.to = to;
|
|
233
|
-
} // set button type to prevent nested buttons from unintentionally submiting forms
|
|
235
|
+
buttonProps.to = to; // remove type if it is not a button
|
|
234
236
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
if (restProps.as !== "button") {
|
|
238
|
+
buttonProps = _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
239
|
+
type: null
|
|
240
|
+
});
|
|
241
|
+
}
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -255,8 +259,8 @@ function Button(_ref) {
|
|
|
255
259
|
restProps = (0, _utils.mergeProps)(restProps, wrapperProps);
|
|
256
260
|
}
|
|
257
261
|
|
|
258
|
-
if (
|
|
259
|
-
throw Error("Tapestry-React: <Button/>
|
|
262
|
+
if (type && restProps.as && restProps.as !== "button") {
|
|
263
|
+
throw Error("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
260
264
|
}
|
|
261
265
|
}
|
|
262
266
|
|
package/dist/cjs/Scrim/Scrim.js
CHANGED
|
@@ -42,7 +42,7 @@ function Sidebar(_ref) {
|
|
|
42
42
|
}, restProps), (0, _react.jsx)(_reactStickyBox["default"], {
|
|
43
43
|
css: flexColumnCss
|
|
44
44
|
}, _react2.Children.map(children, function (child) {
|
|
45
|
-
if (child && child.type !== Sidebar.List
|
|
45
|
+
if (child && child.type !== Sidebar.List && child.type !== Sidebar.Item) {
|
|
46
46
|
console.warn("Invalid component nesting. " + child.type + " cannot appear as a child of <Sidebar>. Only <Sidebar.List/> or <Sidebar.Item/> may be used.");
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -46,8 +46,10 @@ export function Button(_ref) {
|
|
|
46
46
|
title = _ref.title,
|
|
47
47
|
to = _ref.to,
|
|
48
48
|
tooltip = _ref.tooltip,
|
|
49
|
+
_ref$type = _ref.type,
|
|
50
|
+
type = _ref$type === void 0 ? 'button' : _ref$type,
|
|
49
51
|
variant = _ref.variant,
|
|
50
|
-
restProps = _objectWithoutPropertiesLoose(_ref, ["children", "disabled", "external", "icon", "iconLeft", "iconRight", "onClick", "onKeyDown", "size", "spinner", "square", "theme", "title", "to", "tooltip", "variant"]);
|
|
52
|
+
restProps = _objectWithoutPropertiesLoose(_ref, ["children", "disabled", "external", "icon", "iconLeft", "iconRight", "onClick", "onKeyDown", "size", "spinner", "square", "theme", "title", "to", "tooltip", "type", "variant"]);
|
|
51
53
|
|
|
52
54
|
var buttonThemes = useThemeValue('button.themes');
|
|
53
55
|
|
|
@@ -73,7 +75,8 @@ export function Button(_ref) {
|
|
|
73
75
|
strokeAlign: 'inside',
|
|
74
76
|
strokeWeight: 1,
|
|
75
77
|
userSelect: 'none',
|
|
76
|
-
zIndex: 1
|
|
78
|
+
zIndex: 1,
|
|
79
|
+
type: type
|
|
77
80
|
};
|
|
78
81
|
var spinnerColor;
|
|
79
82
|
|
|
@@ -222,12 +225,13 @@ export function Button(_ref) {
|
|
|
222
225
|
|
|
223
226
|
|
|
224
227
|
if (restProps.as) {
|
|
225
|
-
buttonProps.to = to;
|
|
226
|
-
} // set button type to prevent nested buttons from unintentionally submiting forms
|
|
228
|
+
buttonProps.to = to; // remove type if it is not a button
|
|
227
229
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
if (restProps.as !== "button") {
|
|
231
|
+
buttonProps = _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
232
|
+
type: null
|
|
233
|
+
});
|
|
234
|
+
}
|
|
231
235
|
}
|
|
232
236
|
|
|
233
237
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -240,8 +244,8 @@ export function Button(_ref) {
|
|
|
240
244
|
restProps = mergeProps(restProps, wrapperProps);
|
|
241
245
|
}
|
|
242
246
|
|
|
243
|
-
if (
|
|
244
|
-
throw Error("Tapestry-React: <Button/>
|
|
247
|
+
if (type && restProps.as && restProps.as !== "button") {
|
|
248
|
+
throw Error("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
245
249
|
}
|
|
246
250
|
}
|
|
247
251
|
|
package/dist/esm/Scrim/Scrim.js
CHANGED
|
@@ -28,7 +28,7 @@ function Sidebar(_ref) {
|
|
|
28
28
|
}, restProps), jsx(StickyBox, {
|
|
29
29
|
css: flexColumnCss
|
|
30
30
|
}, Children.map(children, function (child) {
|
|
31
|
-
if (child && child.type !== Sidebar.List
|
|
31
|
+
if (child && child.type !== Sidebar.List && child.type !== Sidebar.Item) {
|
|
32
32
|
console.warn("Invalid component nesting. " + child.type + " cannot appear as a child of <Sidebar>. Only <Sidebar.List/> or <Sidebar.Item/> may be used.");
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -64,6 +64,10 @@ declare type ButtonProps = {
|
|
|
64
64
|
* Wraps button in a [`<Tooltip />`](./tooltip). Accepts any valid Tooltip props.
|
|
65
65
|
*/
|
|
66
66
|
tooltip?: string | Object;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the button type to `button`, `submit`, or `reset`. Default is `button`. Type is only valid for `<button>`s.
|
|
69
|
+
*/
|
|
70
|
+
type?: 'button' | 'submit' | 'reset';
|
|
67
71
|
/**
|
|
68
72
|
* Determines the modified style of the button.
|
|
69
73
|
*/
|
|
@@ -74,7 +78,7 @@ declare type ButtonProps = {
|
|
|
74
78
|
mediaQueries?: object;
|
|
75
79
|
} & StackViewProps;
|
|
76
80
|
declare type Props = React.RefAttributes<any> & React.HTMLAttributes<any> & ButtonProps & MediaQueries<ButtonProps>;
|
|
77
|
-
export declare function Button({ children, disabled, external, icon, iconLeft, iconRight, onClick, onKeyDown, size, spinner, square, theme, title, to, tooltip, variant, ...restProps }: Props): JSX.Element;
|
|
81
|
+
export declare function Button({ children, disabled, external, icon, iconLeft, iconRight, onClick, onKeyDown, size, spinner, square, theme, title, to, tooltip, type, variant, ...restProps }: Props): JSX.Element;
|
|
78
82
|
export declare namespace Button {
|
|
79
83
|
var Input: React.ForwardRefExoticComponent<Pick<React.RefAttributes<any> & React.HTMLAttributes<any> & {
|
|
80
84
|
children: React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any>) | (new (props: any) => React.Component<any, any, any>)> | ((inputProps: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "A collection of flexible React components to help you build resilient, accessible user interfaces quickly and effectively.",
|
|
5
5
|
"author": "Front End Systems Engineering <frontend@pco.bz>",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"typescript": "^4.1.5"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@planningcenter/icons": "^14.
|
|
91
|
+
"@planningcenter/icons": "^14.11.0",
|
|
92
92
|
"@planningcenter/react-beautiful-dnd": "^13.2.1",
|
|
93
93
|
"@popmotion/popcorn": "^0.4.4",
|
|
94
94
|
"@popperjs/core": "^2.11.6",
|
package/src/Button/Button.tsx
CHANGED
|
@@ -91,6 +91,11 @@ type ButtonProps = {
|
|
|
91
91
|
*/
|
|
92
92
|
tooltip?: string | Object
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Sets the button type to `button`, `submit`, or `reset`. Default is `button`. Type is only valid for `<button>`s.
|
|
96
|
+
*/
|
|
97
|
+
type?: 'button' | 'submit' | 'reset'
|
|
98
|
+
|
|
94
99
|
/**
|
|
95
100
|
* Determines the modified style of the button.
|
|
96
101
|
*/
|
|
@@ -125,6 +130,7 @@ export function Button({
|
|
|
125
130
|
title,
|
|
126
131
|
to,
|
|
127
132
|
tooltip,
|
|
133
|
+
type = 'button',
|
|
128
134
|
variant,
|
|
129
135
|
...restProps
|
|
130
136
|
}: Props) {
|
|
@@ -153,6 +159,7 @@ export function Button({
|
|
|
153
159
|
strokeWeight: 1,
|
|
154
160
|
userSelect: 'none',
|
|
155
161
|
zIndex: 1,
|
|
162
|
+
type,
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
let spinnerColor
|
|
@@ -296,11 +303,14 @@ export function Button({
|
|
|
296
303
|
// pass to if as is defined
|
|
297
304
|
if ((restProps as any).as) {
|
|
298
305
|
buttonProps.to = to
|
|
299
|
-
}
|
|
300
306
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
// remove type if it is not a button
|
|
308
|
+
if ((restProps as any).as !== "button") {
|
|
309
|
+
buttonProps = {
|
|
310
|
+
...buttonProps,
|
|
311
|
+
type: null,
|
|
312
|
+
}
|
|
313
|
+
}
|
|
304
314
|
}
|
|
305
315
|
|
|
306
316
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -330,9 +340,14 @@ export function Button({
|
|
|
330
340
|
tooltip = tooltipProps
|
|
331
341
|
restProps = mergeProps(restProps, wrapperProps)
|
|
332
342
|
}
|
|
333
|
-
|
|
343
|
+
|
|
344
|
+
if (
|
|
345
|
+
type &&
|
|
346
|
+
(restProps as any).as &&
|
|
347
|
+
(restProps as any).as !== "button"
|
|
348
|
+
) {
|
|
334
349
|
throw Error(
|
|
335
|
-
`Tapestry-React: <Button/>
|
|
350
|
+
`Tapestry-React: <Button/> type prop is only supported by <button> and not <${(restProps as any).as}>.`
|
|
336
351
|
)
|
|
337
352
|
}
|
|
338
353
|
}
|
package/src/Scrim/Scrim.tsx
CHANGED
package/src/Sidebar/Sidebar.js
CHANGED
|
@@ -30,8 +30,9 @@ function Sidebar({ children, ...restProps }: Props) {
|
|
|
30
30
|
<StickyBox css={flexColumnCss}>
|
|
31
31
|
{Children.map(children, (child) => {
|
|
32
32
|
if (
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
child &&
|
|
34
|
+
child.type !== Sidebar.List &&
|
|
35
|
+
child.type !== Sidebar.Item
|
|
35
36
|
) {
|
|
36
37
|
console.warn(
|
|
37
38
|
`Invalid component nesting. ${child.type} cannot appear as a child of <Sidebar>. Only <Sidebar.List/> or <Sidebar.Item/> may be used.`
|
package/src/.DS_Store
DELETED
|
Binary file
|