@planningcenter/tapestry-react 2.4.0 → 2.5.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/dist/cjs/Button/Button.js +13 -9
- package/dist/cjs/Checkbox/Checkbox.js +1 -17
- package/dist/cjs/Pagination/Pagination.js +16 -10
- package/dist/esm/Button/Button.js +13 -9
- package/dist/esm/Checkbox/Checkbox.js +1 -17
- package/dist/esm/Pagination/Pagination.js +17 -11
- package/dist/types/Button/Button.d.ts +5 -1
- package/dist/types/Pagination/Pagination.d.ts +14 -2
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/Button/Button.tsx +22 -7
- package/src/Checkbox/Checkbox.js +2 -16
- package/src/Pagination/Pagination.mdx +1 -0
- package/src/Pagination/Pagination.tsx +33 -5
|
@@ -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
|
-
|
|
262
|
+
if (type && restProps.as && restProps.as !== "button") {
|
|
263
|
+
console.log("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
260
264
|
}
|
|
261
265
|
}
|
|
262
266
|
|
|
@@ -85,24 +85,8 @@ function Checkbox(_ref) {
|
|
|
85
85
|
wrapperProps = _useAccessibilityViol.wrapperProps;
|
|
86
86
|
|
|
87
87
|
(0, _react.useLayoutEffect)(function () {
|
|
88
|
-
function findParent(node, findMatch) {
|
|
89
|
-
if (node && node !== document.documentElement) {
|
|
90
|
-
var matchFound = findMatch(node.parentNode);
|
|
91
|
-
|
|
92
|
-
if (matchFound) {
|
|
93
|
-
return node.parentNode;
|
|
94
|
-
} else {
|
|
95
|
-
return findParent(node.parentNode, findMatch);
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
88
|
if (label === undefined) {
|
|
103
|
-
var labelParent =
|
|
104
|
-
return parentNode.tagName === 'LABEL';
|
|
105
|
-
});
|
|
89
|
+
var labelParent = ref.current.closest('label') !== null;
|
|
106
90
|
|
|
107
91
|
if (!labelParent) {
|
|
108
92
|
setNeedsParentLabel(true);
|
|
@@ -75,9 +75,7 @@ var NavButton = function NavButton(_ref) {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
function Pagination(_ref2) {
|
|
78
|
-
var
|
|
79
|
-
activeColor = _ref2$activeColor === void 0 ? '#5b8bf7' : _ref2$activeColor,
|
|
80
|
-
currentPage = _ref2.currentPage,
|
|
78
|
+
var currentPage = _ref2.currentPage,
|
|
81
79
|
_ref2$onPageChange = _ref2.onPageChange,
|
|
82
80
|
onPageChange = _ref2$onPageChange === void 0 ? function () {
|
|
83
81
|
return null;
|
|
@@ -85,11 +83,19 @@ function Pagination(_ref2) {
|
|
|
85
83
|
visiblePages = _ref2.visiblePages,
|
|
86
84
|
_ref2$totalPages = _ref2.totalPages,
|
|
87
85
|
totalPages = _ref2$totalPages === void 0 ? 0 : _ref2$totalPages,
|
|
88
|
-
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["
|
|
86
|
+
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["currentPage", "onPageChange", "visiblePages", "totalPages"]);
|
|
89
87
|
|
|
90
88
|
var _useThemeValue = (0, _system.useThemeValue)('breakpoints'),
|
|
91
89
|
xsBreakpoint = _useThemeValue.xs;
|
|
92
90
|
|
|
91
|
+
var _useThemeProps = (0, _system.useThemeProps)('pagination', _objectSpread({}, restProps)),
|
|
92
|
+
_useThemeProps$active = _useThemeProps.activeColor,
|
|
93
|
+
activeColor = _useThemeProps$active === void 0 ? '#5b8bf7' : _useThemeProps$active,
|
|
94
|
+
navButtonProps = _useThemeProps.navButtonProps,
|
|
95
|
+
pageLinkProps = _useThemeProps.pageLinkProps,
|
|
96
|
+
activePageLinkProps = _useThemeProps.activePageLinkProps,
|
|
97
|
+
themeProps = (0, _objectWithoutPropertiesLoose2["default"])(_useThemeProps, ["activeColor", "navButtonProps", "pageLinkProps", "activePageLinkProps"]);
|
|
98
|
+
|
|
93
99
|
var currentWidth = (0, _windowSize.useWindowWidth)();
|
|
94
100
|
|
|
95
101
|
function renderGap(key) {
|
|
@@ -125,10 +131,10 @@ function Pagination(_ref2) {
|
|
|
125
131
|
square: true,
|
|
126
132
|
title: number,
|
|
127
133
|
variant: isCurrentPage ? 'fill' : 'naked'
|
|
128
|
-
}, isCurrentPage && {
|
|
134
|
+
}, pageLinkProps, isCurrentPage && _objectSpread({
|
|
129
135
|
backgroundColor: activeColor,
|
|
130
136
|
color: '#fff'
|
|
131
|
-
}));
|
|
137
|
+
}, activePageLinkProps)));
|
|
132
138
|
}
|
|
133
139
|
|
|
134
140
|
function renderPageLinks() {
|
|
@@ -151,22 +157,22 @@ function Pagination(_ref2) {
|
|
|
151
157
|
shrink: 0,
|
|
152
158
|
spacing: 0.5,
|
|
153
159
|
width: "100%"
|
|
154
|
-
},
|
|
160
|
+
}, themeProps), /*#__PURE__*/_react["default"].createElement(_Group["default"], {
|
|
155
161
|
spacing: 0.5
|
|
156
|
-
}, /*#__PURE__*/_react["default"].createElement(NavButton, {
|
|
162
|
+
}, /*#__PURE__*/_react["default"].createElement(NavButton, (0, _extends2["default"])({
|
|
157
163
|
disabled: currentPage === 1,
|
|
158
164
|
iconName: "general.leftChevron",
|
|
159
165
|
onClick: onPageChange.bind(null, currentPage - 1),
|
|
160
166
|
tooltip: {
|
|
161
167
|
title: 'Previous Page'
|
|
162
168
|
}
|
|
163
|
-
}), /*#__PURE__*/_react["default"].createElement(NavButton, {
|
|
169
|
+
}, navButtonProps)), /*#__PURE__*/_react["default"].createElement(NavButton, (0, _extends2["default"])({
|
|
164
170
|
disabled: currentPage === totalPages,
|
|
165
171
|
iconName: "general.rightChevron",
|
|
166
172
|
onClick: onPageChange.bind(null, currentPage + 1),
|
|
167
173
|
tooltip: {
|
|
168
174
|
title: 'Next Page'
|
|
169
175
|
}
|
|
170
|
-
})), renderPageLinks());
|
|
176
|
+
}, navButtonProps))), renderPageLinks());
|
|
171
177
|
}
|
|
172
178
|
}
|
|
@@ -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
|
-
|
|
247
|
+
if (type && restProps.as && restProps.as !== "button") {
|
|
248
|
+
console.log("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
245
249
|
}
|
|
246
250
|
}
|
|
247
251
|
|
|
@@ -65,24 +65,8 @@ function Checkbox(_ref) {
|
|
|
65
65
|
wrapperProps = _useAccessibilityViol.wrapperProps;
|
|
66
66
|
|
|
67
67
|
useLayoutEffect(function () {
|
|
68
|
-
function findParent(node, findMatch) {
|
|
69
|
-
if (node && node !== document.documentElement) {
|
|
70
|
-
var matchFound = findMatch(node.parentNode);
|
|
71
|
-
|
|
72
|
-
if (matchFound) {
|
|
73
|
-
return node.parentNode;
|
|
74
|
-
} else {
|
|
75
|
-
return findParent(node.parentNode, findMatch);
|
|
76
|
-
}
|
|
77
|
-
} else {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
68
|
if (label === undefined) {
|
|
83
|
-
var labelParent =
|
|
84
|
-
return parentNode.tagName === 'LABEL';
|
|
85
|
-
});
|
|
69
|
+
var labelParent = ref.current.closest('label') !== null;
|
|
86
70
|
|
|
87
71
|
if (!labelParent) {
|
|
88
72
|
setNeedsParentLabel(true);
|
|
@@ -14,7 +14,7 @@ import StackView from '../StackView';
|
|
|
14
14
|
import { range } from '../utils';
|
|
15
15
|
import { parseColor } from '../system/utils';
|
|
16
16
|
import { useWindowWidth } from '@react-hook/window-size';
|
|
17
|
-
import { useThemeValue } from '../system';
|
|
17
|
+
import { useThemeValue, useThemeProps } from '../system';
|
|
18
18
|
|
|
19
19
|
function getVisiblePages(currentPage, totalPages, visiblePages) {
|
|
20
20
|
var start = Math.max(1, Math.min(totalPages - visiblePages + 1, Math.floor(currentPage - visiblePages / 2 + 1)));
|
|
@@ -59,9 +59,7 @@ var NavButton = function NavButton(_ref) {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
export default function Pagination(_ref2) {
|
|
62
|
-
var
|
|
63
|
-
activeColor = _ref2$activeColor === void 0 ? '#5b8bf7' : _ref2$activeColor,
|
|
64
|
-
currentPage = _ref2.currentPage,
|
|
62
|
+
var currentPage = _ref2.currentPage,
|
|
65
63
|
_ref2$onPageChange = _ref2.onPageChange,
|
|
66
64
|
onPageChange = _ref2$onPageChange === void 0 ? function () {
|
|
67
65
|
return null;
|
|
@@ -69,11 +67,19 @@ export default function Pagination(_ref2) {
|
|
|
69
67
|
visiblePages = _ref2.visiblePages,
|
|
70
68
|
_ref2$totalPages = _ref2.totalPages,
|
|
71
69
|
totalPages = _ref2$totalPages === void 0 ? 0 : _ref2$totalPages,
|
|
72
|
-
restProps = _objectWithoutPropertiesLoose(_ref2, ["
|
|
70
|
+
restProps = _objectWithoutPropertiesLoose(_ref2, ["currentPage", "onPageChange", "visiblePages", "totalPages"]);
|
|
73
71
|
|
|
74
72
|
var _useThemeValue = useThemeValue('breakpoints'),
|
|
75
73
|
xsBreakpoint = _useThemeValue.xs;
|
|
76
74
|
|
|
75
|
+
var _useThemeProps = useThemeProps('pagination', _objectSpread({}, restProps)),
|
|
76
|
+
_useThemeProps$active = _useThemeProps.activeColor,
|
|
77
|
+
activeColor = _useThemeProps$active === void 0 ? '#5b8bf7' : _useThemeProps$active,
|
|
78
|
+
navButtonProps = _useThemeProps.navButtonProps,
|
|
79
|
+
pageLinkProps = _useThemeProps.pageLinkProps,
|
|
80
|
+
activePageLinkProps = _useThemeProps.activePageLinkProps,
|
|
81
|
+
themeProps = _objectWithoutPropertiesLoose(_useThemeProps, ["activeColor", "navButtonProps", "pageLinkProps", "activePageLinkProps"]);
|
|
82
|
+
|
|
77
83
|
var currentWidth = useWindowWidth();
|
|
78
84
|
|
|
79
85
|
function renderGap(key) {
|
|
@@ -109,10 +115,10 @@ export default function Pagination(_ref2) {
|
|
|
109
115
|
square: true,
|
|
110
116
|
title: number,
|
|
111
117
|
variant: isCurrentPage ? 'fill' : 'naked'
|
|
112
|
-
}, isCurrentPage && {
|
|
118
|
+
}, pageLinkProps, isCurrentPage && _objectSpread({
|
|
113
119
|
backgroundColor: activeColor,
|
|
114
120
|
color: '#fff'
|
|
115
|
-
}));
|
|
121
|
+
}, activePageLinkProps)));
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
function renderPageLinks() {
|
|
@@ -135,22 +141,22 @@ export default function Pagination(_ref2) {
|
|
|
135
141
|
shrink: 0,
|
|
136
142
|
spacing: 0.5,
|
|
137
143
|
width: "100%"
|
|
138
|
-
},
|
|
144
|
+
}, themeProps), /*#__PURE__*/React.createElement(Group, {
|
|
139
145
|
spacing: 0.5
|
|
140
|
-
}, /*#__PURE__*/React.createElement(NavButton, {
|
|
146
|
+
}, /*#__PURE__*/React.createElement(NavButton, _extends({
|
|
141
147
|
disabled: currentPage === 1,
|
|
142
148
|
iconName: "general.leftChevron",
|
|
143
149
|
onClick: onPageChange.bind(null, currentPage - 1),
|
|
144
150
|
tooltip: {
|
|
145
151
|
title: 'Previous Page'
|
|
146
152
|
}
|
|
147
|
-
}), /*#__PURE__*/React.createElement(NavButton, {
|
|
153
|
+
}, navButtonProps)), /*#__PURE__*/React.createElement(NavButton, _extends({
|
|
148
154
|
disabled: currentPage === totalPages,
|
|
149
155
|
iconName: "general.rightChevron",
|
|
150
156
|
onClick: onPageChange.bind(null, currentPage + 1),
|
|
151
157
|
tooltip: {
|
|
152
158
|
title: 'Next Page'
|
|
153
159
|
}
|
|
154
|
-
})), renderPageLinks());
|
|
160
|
+
}, navButtonProps))), renderPageLinks());
|
|
155
161
|
}
|
|
156
162
|
}
|
|
@@ -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: {
|
|
@@ -2,15 +2,27 @@ export declare type PaginationProps = {
|
|
|
2
2
|
/**
|
|
3
3
|
* Change the color of the active page
|
|
4
4
|
*/
|
|
5
|
-
activeColor
|
|
5
|
+
activeColor?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Accepts any valid [Button](/button) props.
|
|
8
|
+
*/
|
|
9
|
+
activePageLinkProps?: object;
|
|
6
10
|
/**
|
|
7
11
|
* Current visible page number
|
|
8
12
|
*/
|
|
9
13
|
currentPage: number;
|
|
14
|
+
/**
|
|
15
|
+
* Accepts any valid [Button](/button) props.
|
|
16
|
+
*/
|
|
17
|
+
navButtonProps?: object;
|
|
10
18
|
/**
|
|
11
19
|
* Callback when new page is requested
|
|
12
20
|
*/
|
|
13
21
|
onPageChange: (nextPage: number) => undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Accepts any valid [Button](/button) props.
|
|
24
|
+
*/
|
|
25
|
+
pageLinkProps?: object;
|
|
14
26
|
/**
|
|
15
27
|
* Total available pages
|
|
16
28
|
*/
|
|
@@ -20,4 +32,4 @@ export declare type PaginationProps = {
|
|
|
20
32
|
*/
|
|
21
33
|
visiblePages?: number;
|
|
22
34
|
};
|
|
23
|
-
export default function Pagination({
|
|
35
|
+
export default function Pagination({ currentPage, onPageChange, visiblePages, totalPages, ...restProps }: PaginationProps): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
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",
|
package/src/.DS_Store
ADDED
|
Binary file
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
343
|
+
|
|
344
|
+
if (
|
|
345
|
+
type &&
|
|
346
|
+
(restProps as any).as &&
|
|
347
|
+
(restProps as any).as !== "button"
|
|
348
|
+
) {
|
|
349
|
+
console.log(
|
|
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/Checkbox/Checkbox.js
CHANGED
|
@@ -120,23 +120,9 @@ function Checkbox({
|
|
|
120
120
|
`Tapestry-React: <Checkbox/> must define a "label" prop or have a parent that renders a label for proper accessibility.`
|
|
121
121
|
)
|
|
122
122
|
useLayoutEffect(() => {
|
|
123
|
-
function findParent(node, findMatch) {
|
|
124
|
-
if (node && node !== document.documentElement) {
|
|
125
|
-
const matchFound = findMatch(node.parentNode)
|
|
126
|
-
if (matchFound) {
|
|
127
|
-
return node.parentNode
|
|
128
|
-
} else {
|
|
129
|
-
return findParent(node.parentNode, findMatch)
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
return null
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
123
|
if (label === undefined) {
|
|
136
|
-
const labelParent =
|
|
137
|
-
|
|
138
|
-
(parentNode) => parentNode.tagName === 'LABEL'
|
|
139
|
-
)
|
|
124
|
+
const labelParent = ref.current.closest('label') !== null
|
|
125
|
+
|
|
140
126
|
if (!labelParent) {
|
|
141
127
|
setNeedsParentLabel(true)
|
|
142
128
|
}
|
|
@@ -7,7 +7,7 @@ import StackView from '../StackView'
|
|
|
7
7
|
import { range } from '../utils'
|
|
8
8
|
import { parseColor } from '../system/utils'
|
|
9
9
|
import { useWindowWidth } from '@react-hook/window-size'
|
|
10
|
-
import { useThemeValue } from '../system'
|
|
10
|
+
import { useThemeValue, useThemeProps } from '../system'
|
|
11
11
|
|
|
12
12
|
function getVisiblePages(currentPage, totalPages, visiblePages) {
|
|
13
13
|
const start = Math.max(
|
|
@@ -40,18 +40,33 @@ export type PaginationProps = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Change the color of the active page
|
|
42
42
|
*/
|
|
43
|
-
activeColor
|
|
43
|
+
activeColor?: string
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Accepts any valid [Button](/button) props.
|
|
47
|
+
*/
|
|
48
|
+
activePageLinkProps?: object
|
|
44
49
|
|
|
45
50
|
/**
|
|
46
51
|
* Current visible page number
|
|
47
52
|
*/
|
|
48
53
|
currentPage: number
|
|
49
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Accepts any valid [Button](/button) props.
|
|
57
|
+
*/
|
|
58
|
+
navButtonProps?: object
|
|
59
|
+
|
|
50
60
|
/**
|
|
51
61
|
* Callback when new page is requested
|
|
52
62
|
*/
|
|
53
63
|
onPageChange: (nextPage: number) => undefined
|
|
54
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Accepts any valid [Button](/button) props.
|
|
67
|
+
*/
|
|
68
|
+
pageLinkProps?: object
|
|
69
|
+
|
|
55
70
|
/**
|
|
56
71
|
* Total available pages
|
|
57
72
|
*/
|
|
@@ -83,7 +98,6 @@ const NavButton = ({ disabled, iconName, ...props }) => {
|
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
export default function Pagination({
|
|
86
|
-
activeColor = '#5b8bf7',
|
|
87
101
|
currentPage,
|
|
88
102
|
onPageChange = () => null,
|
|
89
103
|
visiblePages,
|
|
@@ -91,6 +105,13 @@ export default function Pagination({
|
|
|
91
105
|
...restProps
|
|
92
106
|
}: PaginationProps) {
|
|
93
107
|
const { xs: xsBreakpoint } = useThemeValue('breakpoints')
|
|
108
|
+
const {
|
|
109
|
+
activeColor = '#5b8bf7',
|
|
110
|
+
navButtonProps,
|
|
111
|
+
pageLinkProps,
|
|
112
|
+
activePageLinkProps,
|
|
113
|
+
...themeProps
|
|
114
|
+
} = useThemeProps('pagination', { ...restProps })
|
|
94
115
|
|
|
95
116
|
const currentWidth = useWindowWidth()
|
|
96
117
|
|
|
@@ -123,7 +144,12 @@ export default function Pagination({
|
|
|
123
144
|
square
|
|
124
145
|
title={number}
|
|
125
146
|
variant={isCurrentPage ? 'fill' : 'naked'}
|
|
126
|
-
{...
|
|
147
|
+
{...pageLinkProps}
|
|
148
|
+
{...(isCurrentPage && {
|
|
149
|
+
backgroundColor: activeColor,
|
|
150
|
+
color: '#fff',
|
|
151
|
+
...activePageLinkProps,
|
|
152
|
+
})}
|
|
127
153
|
/>
|
|
128
154
|
)
|
|
129
155
|
}
|
|
@@ -150,7 +176,7 @@ export default function Pagination({
|
|
|
150
176
|
shrink={0}
|
|
151
177
|
spacing={0.5}
|
|
152
178
|
width="100%"
|
|
153
|
-
{...
|
|
179
|
+
{...themeProps}
|
|
154
180
|
>
|
|
155
181
|
<Group spacing={0.5}>
|
|
156
182
|
<NavButton
|
|
@@ -158,12 +184,14 @@ export default function Pagination({
|
|
|
158
184
|
iconName="general.leftChevron"
|
|
159
185
|
onClick={onPageChange.bind(null, currentPage - 1)}
|
|
160
186
|
tooltip={{ title: 'Previous Page' }}
|
|
187
|
+
{...navButtonProps}
|
|
161
188
|
/>
|
|
162
189
|
<NavButton
|
|
163
190
|
disabled={currentPage === totalPages}
|
|
164
191
|
iconName="general.rightChevron"
|
|
165
192
|
onClick={onPageChange.bind(null, currentPage + 1)}
|
|
166
193
|
tooltip={{ title: 'Next Page' }}
|
|
194
|
+
{...navButtonProps}
|
|
167
195
|
/>
|
|
168
196
|
</Group>
|
|
169
197
|
{renderPageLinks()}
|