@planningcenter/tapestry-react 2.9.0-rc.2 → 2.9.0-rc.4
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.
|
@@ -198,9 +198,9 @@ function Button(_ref) {
|
|
|
198
198
|
buttonProps.hover = undefined;
|
|
199
199
|
buttonProps.active = undefined;
|
|
200
200
|
} else {
|
|
201
|
-
buttonProps.focus = {
|
|
201
|
+
buttonProps.focus = _objectSpread(_objectSpread({}, buttonProps.focus), {}, {
|
|
202
202
|
zIndex: 5
|
|
203
|
-
};
|
|
203
|
+
});
|
|
204
204
|
buttonProps.cursor = 'pointer';
|
|
205
205
|
buttonProps.touchAction = 'manipulation';
|
|
206
206
|
buttonProps.onClick = onClick;
|
|
@@ -250,7 +250,7 @@ function Button(_ref) {
|
|
|
250
250
|
if (restProps.as) {
|
|
251
251
|
buttonProps.to = to; // remove type if it is not a button
|
|
252
252
|
|
|
253
|
-
if (restProps.as !==
|
|
253
|
+
if (restProps.as !== 'button') {
|
|
254
254
|
buttonProps = _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
255
255
|
type: null
|
|
256
256
|
});
|
|
@@ -275,7 +275,7 @@ function Button(_ref) {
|
|
|
275
275
|
restProps = (0, _utils.mergeProps)(restProps, wrapperProps);
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
if (buttonProps.type && restProps.as && restProps.as !==
|
|
278
|
+
if (buttonProps.type && restProps.as && restProps.as !== 'button') {
|
|
279
279
|
console.log("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
280
280
|
}
|
|
281
281
|
}
|
|
@@ -27,10 +27,13 @@ var _utils = require("../utils");
|
|
|
27
27
|
|
|
28
28
|
var _utils2 = require("./utils");
|
|
29
29
|
|
|
30
|
+
var isMobile = typeof window !== 'undefined' ? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) : false;
|
|
31
|
+
|
|
30
32
|
var TimeField = function TimeField(_ref) {
|
|
31
33
|
var ignoredKeys = _ref.ignoredKeys,
|
|
32
34
|
interval = _ref.interval,
|
|
33
|
-
isIOS = _ref.isIOS,
|
|
35
|
+
_ref$isIOS = _ref.isIOS,
|
|
36
|
+
isIOS = _ref$isIOS === void 0 ? false : _ref$isIOS,
|
|
34
37
|
max = _ref.max,
|
|
35
38
|
min = _ref.min,
|
|
36
39
|
onChange = _ref.onChange,
|
|
@@ -236,13 +239,18 @@ var TimeField = function TimeField(_ref) {
|
|
|
236
239
|
return onChange([hours, minutes]);
|
|
237
240
|
};
|
|
238
241
|
|
|
239
|
-
var
|
|
242
|
+
var handleMobileChange = function handleMobileChange(event) {
|
|
240
243
|
var _event$target$value$s = event.target.value.split(':'),
|
|
241
244
|
hours = _event$target$value$s[0],
|
|
242
245
|
minutes = _event$target$value$s[1];
|
|
243
246
|
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
if (hours || minutes) {
|
|
248
|
+
setHours(hours);
|
|
249
|
+
setMinutes(minutes);
|
|
250
|
+
} else {
|
|
251
|
+
setHours(0);
|
|
252
|
+
setMinutes(0);
|
|
253
|
+
}
|
|
246
254
|
};
|
|
247
255
|
|
|
248
256
|
(0, _react.useEffect)(function () {
|
|
@@ -254,11 +262,11 @@ var TimeField = function TimeField(_ref) {
|
|
|
254
262
|
|
|
255
263
|
updateTime([hours, minutes]);
|
|
256
264
|
}, [hours, minutes]);
|
|
257
|
-
return isIOS ? /*#__PURE__*/_react["default"].createElement(_Input["default"], (0, _extends2["default"])({}, restProps, {
|
|
265
|
+
return isMobile || isIOS ? /*#__PURE__*/_react["default"].createElement(_Input["default"], (0, _extends2["default"])({}, restProps, {
|
|
258
266
|
type: "time",
|
|
259
267
|
autoWidth: hours + ":" + (0, _utils.padNumber)(minutes, 2) + " " + meridiem,
|
|
260
268
|
value: (0, _utils.padNumber)(hours, 2) + ":" + (0, _utils.padNumber)(minutes, 2),
|
|
261
|
-
onChange:
|
|
269
|
+
onChange: handleMobileChange
|
|
262
270
|
})) : /*#__PURE__*/_react["default"].createElement(_InputBox["default"], (0, _extends2["default"])({
|
|
263
271
|
ref: ref,
|
|
264
272
|
inline: true
|
|
@@ -191,9 +191,9 @@ export function Button(_ref) {
|
|
|
191
191
|
buttonProps.hover = undefined;
|
|
192
192
|
buttonProps.active = undefined;
|
|
193
193
|
} else {
|
|
194
|
-
buttonProps.focus = {
|
|
194
|
+
buttonProps.focus = _objectSpread(_objectSpread({}, buttonProps.focus), {}, {
|
|
195
195
|
zIndex: 5
|
|
196
|
-
};
|
|
196
|
+
});
|
|
197
197
|
buttonProps.cursor = 'pointer';
|
|
198
198
|
buttonProps.touchAction = 'manipulation';
|
|
199
199
|
buttonProps.onClick = onClick;
|
|
@@ -243,7 +243,7 @@ export function Button(_ref) {
|
|
|
243
243
|
if (restProps.as) {
|
|
244
244
|
buttonProps.to = to; // remove type if it is not a button
|
|
245
245
|
|
|
246
|
-
if (restProps.as !==
|
|
246
|
+
if (restProps.as !== 'button') {
|
|
247
247
|
buttonProps = _objectSpread(_objectSpread({}, buttonProps), {}, {
|
|
248
248
|
type: null
|
|
249
249
|
});
|
|
@@ -260,7 +260,7 @@ export function Button(_ref) {
|
|
|
260
260
|
restProps = mergeProps(restProps, wrapperProps);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
if (buttonProps.type && restProps.as && restProps.as !==
|
|
263
|
+
if (buttonProps.type && restProps.as && restProps.as !== 'button') {
|
|
264
264
|
console.log("Tapestry-React: <Button/> type prop is only supported by <button> and not <" + restProps.as + ">.");
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -8,6 +8,7 @@ import InputField from '../Input/InputField';
|
|
|
8
8
|
import NumberField from '../NumberField';
|
|
9
9
|
import { noop, padNumber } from '../utils';
|
|
10
10
|
import { addHoursToTime, addMinutesToTime, addTimeToDate, getTimeFromDate } from './utils';
|
|
11
|
+
var isMobile = typeof window !== 'undefined' ? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) : false;
|
|
11
12
|
|
|
12
13
|
var _ref2 = /*#__PURE__*/React.createElement(Box, {
|
|
13
14
|
as: "span",
|
|
@@ -19,7 +20,8 @@ var _ref2 = /*#__PURE__*/React.createElement(Box, {
|
|
|
19
20
|
var TimeField = function TimeField(_ref) {
|
|
20
21
|
var ignoredKeys = _ref.ignoredKeys,
|
|
21
22
|
interval = _ref.interval,
|
|
22
|
-
isIOS = _ref.isIOS,
|
|
23
|
+
_ref$isIOS = _ref.isIOS,
|
|
24
|
+
isIOS = _ref$isIOS === void 0 ? false : _ref$isIOS,
|
|
23
25
|
max = _ref.max,
|
|
24
26
|
min = _ref.min,
|
|
25
27
|
onChange = _ref.onChange,
|
|
@@ -226,13 +228,18 @@ var TimeField = function TimeField(_ref) {
|
|
|
226
228
|
return onChange([hours, minutes]);
|
|
227
229
|
};
|
|
228
230
|
|
|
229
|
-
var
|
|
231
|
+
var handleMobileChange = function handleMobileChange(event) {
|
|
230
232
|
var _event$target$value$s = event.target.value.split(':'),
|
|
231
233
|
hours = _event$target$value$s[0],
|
|
232
234
|
minutes = _event$target$value$s[1];
|
|
233
235
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
if (hours || minutes) {
|
|
237
|
+
setHours(hours);
|
|
238
|
+
setMinutes(minutes);
|
|
239
|
+
} else {
|
|
240
|
+
setHours(0);
|
|
241
|
+
setMinutes(0);
|
|
242
|
+
}
|
|
236
243
|
};
|
|
237
244
|
|
|
238
245
|
useEffect(function () {
|
|
@@ -244,11 +251,11 @@ var TimeField = function TimeField(_ref) {
|
|
|
244
251
|
|
|
245
252
|
updateTime([hours, minutes]);
|
|
246
253
|
}, [hours, minutes]);
|
|
247
|
-
return isIOS ? /*#__PURE__*/React.createElement(Input, _extends({}, restProps, {
|
|
254
|
+
return isMobile || isIOS ? /*#__PURE__*/React.createElement(Input, _extends({}, restProps, {
|
|
248
255
|
type: "time",
|
|
249
256
|
autoWidth: hours + ":" + padNumber(minutes, 2) + " " + meridiem,
|
|
250
257
|
value: padNumber(hours, 2) + ":" + padNumber(minutes, 2),
|
|
251
|
-
onChange:
|
|
258
|
+
onChange: handleMobileChange
|
|
252
259
|
})) : /*#__PURE__*/React.createElement(InputBox, _extends({
|
|
253
260
|
ref: ref,
|
|
254
261
|
inline: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.9.0-rc.
|
|
3
|
+
"version": "2.9.0-rc.4",
|
|
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/Button/Button.tsx
CHANGED
|
@@ -258,7 +258,7 @@ export function Button({
|
|
|
258
258
|
buttonProps.opacity = 0.65
|
|
259
259
|
buttonProps['aria-disabled'] = true
|
|
260
260
|
buttonProps.cursor = 'not-allowed'
|
|
261
|
-
buttonProps.onClick = (event) =>
|
|
261
|
+
buttonProps.onClick = (event) => event.preventDefault()
|
|
262
262
|
buttonProps.onKeyDown = (event) => {
|
|
263
263
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
264
264
|
event.preventDefault()
|
|
@@ -271,7 +271,7 @@ export function Button({
|
|
|
271
271
|
buttonProps.hover = undefined
|
|
272
272
|
buttonProps.active = undefined
|
|
273
273
|
} else {
|
|
274
|
-
buttonProps.focus = { zIndex: 5 }
|
|
274
|
+
buttonProps.focus = { ...buttonProps.focus, zIndex: 5 }
|
|
275
275
|
buttonProps.cursor = 'pointer'
|
|
276
276
|
buttonProps.touchAction = 'manipulation'
|
|
277
277
|
buttonProps.onClick = onClick
|
|
@@ -323,7 +323,7 @@ export function Button({
|
|
|
323
323
|
buttonProps.to = to
|
|
324
324
|
|
|
325
325
|
// remove type if it is not a button
|
|
326
|
-
if ((restProps as any).as !==
|
|
326
|
+
if ((restProps as any).as !== 'button') {
|
|
327
327
|
buttonProps = {
|
|
328
328
|
...buttonProps,
|
|
329
329
|
type: null,
|
|
@@ -362,10 +362,12 @@ export function Button({
|
|
|
362
362
|
if (
|
|
363
363
|
buttonProps.type &&
|
|
364
364
|
(restProps as any).as &&
|
|
365
|
-
(restProps as any).as !==
|
|
365
|
+
(restProps as any).as !== 'button'
|
|
366
366
|
) {
|
|
367
367
|
console.log(
|
|
368
|
-
`Tapestry-React: <Button/> type prop is only supported by <button> and not <${
|
|
368
|
+
`Tapestry-React: <Button/> type prop is only supported by <button> and not <${
|
|
369
|
+
(restProps as any).as
|
|
370
|
+
}>.`
|
|
369
371
|
)
|
|
370
372
|
}
|
|
371
373
|
}
|
|
@@ -5,7 +5,7 @@ import Input from '../Input/Input'
|
|
|
5
5
|
import InputBox from '../Input/InputBox'
|
|
6
6
|
import InputField from '../Input/InputField'
|
|
7
7
|
import NumberField from '../NumberField'
|
|
8
|
-
import {
|
|
8
|
+
import { noop, padNumber } from '../utils'
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
11
|
addHoursToTime,
|
|
@@ -49,10 +49,17 @@ type TimeFieldProps = {
|
|
|
49
49
|
value: [number, number]
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
const isMobile =
|
|
53
|
+
typeof window !== 'undefined'
|
|
54
|
+
? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
55
|
+
navigator.userAgent
|
|
56
|
+
)
|
|
57
|
+
: false
|
|
58
|
+
|
|
52
59
|
const TimeField = ({
|
|
53
60
|
ignoredKeys,
|
|
54
61
|
interval,
|
|
55
|
-
isIOS,
|
|
62
|
+
isIOS = false,
|
|
56
63
|
max,
|
|
57
64
|
min,
|
|
58
65
|
onChange,
|
|
@@ -241,10 +248,16 @@ const TimeField = ({
|
|
|
241
248
|
return onChange([hours, minutes])
|
|
242
249
|
}
|
|
243
250
|
|
|
244
|
-
const
|
|
251
|
+
const handleMobileChange = (event: any) => {
|
|
245
252
|
const [hours, minutes] = event.target.value.split(':')
|
|
246
|
-
|
|
247
|
-
|
|
253
|
+
|
|
254
|
+
if (hours || minutes) {
|
|
255
|
+
setHours(hours)
|
|
256
|
+
setMinutes(minutes)
|
|
257
|
+
} else {
|
|
258
|
+
setHours(0)
|
|
259
|
+
setMinutes(0)
|
|
260
|
+
}
|
|
248
261
|
}
|
|
249
262
|
|
|
250
263
|
useEffect(() => {
|
|
@@ -256,13 +269,13 @@ const TimeField = ({
|
|
|
256
269
|
updateTime([hours, minutes])
|
|
257
270
|
}, [hours, minutes])
|
|
258
271
|
|
|
259
|
-
return isIOS ? (
|
|
272
|
+
return isMobile || isIOS ? (
|
|
260
273
|
<Input
|
|
261
274
|
{...restProps}
|
|
262
275
|
type="time"
|
|
263
276
|
autoWidth={`${hours}:${padNumber(minutes, 2)} ${meridiem}`}
|
|
264
277
|
value={`${padNumber(hours, 2)}:${padNumber(minutes, 2)}`}
|
|
265
|
-
onChange={
|
|
278
|
+
onChange={handleMobileChange}
|
|
266
279
|
/>
|
|
267
280
|
) : (
|
|
268
281
|
<InputBox ref={ref} inline {...restProps}>
|