@planningcenter/tapestry-react 2.10.0-rc.1 → 2.10.0-rc.3
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 +3 -1
- package/dist/cjs/Input/Inline.js +3 -1
- package/dist/cjs/Input/InputBox.js +3 -1
- package/dist/cjs/NumberField/NumberField.js +16 -23
- package/dist/cjs/NumberField/NumberField.test.js +20 -10
- package/dist/cjs/Radio/Radio.js +7 -10
- package/dist/cjs/designTokens/index.js +9 -0
- package/dist/esm/Button/Button.js +2 -1
- package/dist/esm/Input/Inline.js +2 -1
- package/dist/esm/Input/InputBox.js +2 -1
- package/dist/esm/NumberField/NumberField.js +16 -23
- package/dist/esm/NumberField/NumberField.test.js +20 -10
- package/dist/esm/Radio/Radio.js +7 -10
- package/dist/esm/designTokens/index.js +4 -0
- package/dist/types/Button/Button.d.ts +1 -3
- package/dist/types/NumberField/NumberField.d.ts +2 -1
- package/dist/types/Radio/Radio.d.ts +4 -3
- package/dist/types/designTokens/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/Button/Button.tsx +2 -1
- package/src/Input/Inline.js +2 -1
- package/src/Input/InputBox.js +2 -1
- package/src/NumberField/NumberField.test.tsx +12 -8
- package/src/NumberField/NumberField.tsx +19 -25
- package/src/Radio/Radio.tsx +8 -10
- package/src/designTokens/index.ts +4 -0
|
@@ -31,6 +31,8 @@ var _utils = require("../utils");
|
|
|
31
31
|
|
|
32
32
|
var _useAccessibilityViolation = require("../hooks/use-accessibility-violation");
|
|
33
33
|
|
|
34
|
+
var _designTokens = require("../designTokens");
|
|
35
|
+
|
|
34
36
|
var _Input = _interopRequireDefault(require("./Input"));
|
|
35
37
|
|
|
36
38
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -78,7 +80,7 @@ function Button(_ref) {
|
|
|
78
80
|
inline: true,
|
|
79
81
|
lineHeight: lineHeight,
|
|
80
82
|
position: 'relative',
|
|
81
|
-
radius:
|
|
83
|
+
radius: _designTokens.designTokens.borderRadius,
|
|
82
84
|
strokeAlign: 'inside',
|
|
83
85
|
strokeWeight: 1,
|
|
84
86
|
userSelect: 'none',
|
package/dist/cjs/Input/Inline.js
CHANGED
|
@@ -15,6 +15,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _InputField = _interopRequireDefault(require("./InputField"));
|
|
17
17
|
|
|
18
|
+
var _designTokens = require("../designTokens");
|
|
19
|
+
|
|
18
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
19
21
|
|
|
20
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -49,7 +51,7 @@ function Inline(_ref) {
|
|
|
49
51
|
paddingHorizontal: 0.5,
|
|
50
52
|
paddingVertical: 0,
|
|
51
53
|
placeholderColor: light ? 'light-5' : 'foregroundTertiary',
|
|
52
|
-
radius:
|
|
54
|
+
radius: _designTokens.designTokens.inputRadius,
|
|
53
55
|
stroke: undefined
|
|
54
56
|
}, restProps));
|
|
55
57
|
}
|
|
@@ -37,6 +37,8 @@ var _InputContext = _interopRequireDefault(require("./InputContext"));
|
|
|
37
37
|
|
|
38
38
|
var _utils = require("./utils");
|
|
39
39
|
|
|
40
|
+
var _designTokens = require("../designTokens");
|
|
41
|
+
|
|
40
42
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
41
43
|
|
|
42
44
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -305,7 +307,7 @@ var InputBox = /*#__PURE__*/function (_Component) {
|
|
|
305
307
|
alignment: _StackView["default"].CENTER,
|
|
306
308
|
shrink: 0,
|
|
307
309
|
minHeight: boxSize,
|
|
308
|
-
radius:
|
|
310
|
+
radius: _designTokens.designTokens.inputRadius,
|
|
309
311
|
position: "relative",
|
|
310
312
|
cursor: "text",
|
|
311
313
|
outline: 0,
|
|
@@ -62,10 +62,8 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
62
62
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getParsedValues", function (value) {
|
|
63
63
|
return {
|
|
64
64
|
value: Number.parseFloat(value),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// @ts-ignore Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)
|
|
68
|
-
maxValue: Number.parseFloat(_this.props.max)
|
|
65
|
+
minValue: _this.props.min,
|
|
66
|
+
maxValue: _this.props.max
|
|
69
67
|
};
|
|
70
68
|
});
|
|
71
69
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "clampValue", function (valueToCheck) {
|
|
@@ -90,23 +88,22 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
90
88
|
});
|
|
91
89
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleBlur", function (event) {
|
|
92
90
|
var _this$getParsedValues3 = _this.getParsedValues(event.target.value),
|
|
93
|
-
value = _this$getParsedValues3.value,
|
|
94
91
|
minValue = _this$getParsedValues3.minValue,
|
|
95
92
|
maxValue = _this$getParsedValues3.maxValue;
|
|
96
93
|
|
|
94
|
+
var value = Number.parseFloat(event.target.value);
|
|
95
|
+
|
|
97
96
|
if (value < minValue) {
|
|
98
|
-
|
|
99
|
-
_this.props.onChange(minValue);
|
|
97
|
+
_this.props.onChange(minValue.toString());
|
|
100
98
|
} else if (value > maxValue) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_this.props.onChange(
|
|
99
|
+
_this.props.onChange(maxValue.toString());
|
|
100
|
+
} else if (isNaN(value)) {
|
|
101
|
+
value = _this.clampValue(value);
|
|
102
|
+
|
|
103
|
+
_this.props.onChange(value.toString());
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
if (_this.props.onBlur) {
|
|
109
|
-
// @ts-ignore
|
|
110
107
|
_this.props.onBlur(event);
|
|
111
108
|
}
|
|
112
109
|
|
|
@@ -115,12 +112,10 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
115
112
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stepValue", function (baseValue, step) {
|
|
116
113
|
var nextValue = _this.clampValue(baseValue + step);
|
|
117
114
|
|
|
118
|
-
var parsedValue = Number.parseFloat(
|
|
119
|
-
baseValue.toString().indexOf('.') > -1 ? nextValue.toFixed(2) : nextValue);
|
|
115
|
+
var parsedValue = Number.parseFloat(baseValue.toString().indexOf('.') > -1 ? nextValue.toFixed(2) : nextValue.toString());
|
|
120
116
|
|
|
121
117
|
if (_this.isValueValid(parsedValue)) {
|
|
122
|
-
|
|
123
|
-
_this.props.onChange(parsedValue);
|
|
118
|
+
_this.props.onChange(parsedValue.toString());
|
|
124
119
|
}
|
|
125
120
|
});
|
|
126
121
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "incrementValue", function () {
|
|
@@ -220,15 +215,13 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
220
215
|
|
|
221
216
|
if (pad && numberValue !== '') {
|
|
222
217
|
numberValue = (0, _utils.padNumber)(numberValue, pad);
|
|
223
|
-
}
|
|
224
|
-
|
|
218
|
+
}
|
|
225
219
|
|
|
226
|
-
if (parsed.
|
|
220
|
+
if (parsed.minValue !== MIN_VALUE) {
|
|
227
221
|
restProps.min = this.props.min;
|
|
228
|
-
}
|
|
229
|
-
|
|
222
|
+
}
|
|
230
223
|
|
|
231
|
-
if (parsed.
|
|
224
|
+
if (parsed.maxValue !== MAX_VALUE) {
|
|
232
225
|
restProps.max = this.props.max;
|
|
233
226
|
}
|
|
234
227
|
|
|
@@ -6,6 +6,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
|
|
7
7
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
8
|
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
|
|
9
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
12
|
|
|
11
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -18,6 +20,10 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
|
18
20
|
|
|
19
21
|
var _NumberField = _interopRequireDefault(require("./NumberField"));
|
|
20
22
|
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
|
+
|
|
21
27
|
describe('value', function () {
|
|
22
28
|
var TestApp = function TestApp(_ref) {
|
|
23
29
|
var initialValue = _ref.value,
|
|
@@ -27,17 +33,21 @@ describe('value', function () {
|
|
|
27
33
|
value = _useState[0],
|
|
28
34
|
setValue = _useState[1];
|
|
29
35
|
|
|
30
|
-
|
|
36
|
+
var defaultProps = _objectSpread({
|
|
37
|
+
pad: 0,
|
|
38
|
+
highlightOnInteraction: false,
|
|
39
|
+
placeholder: '',
|
|
40
|
+
autoWidth: false
|
|
41
|
+
}, props);
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement(_NumberField["default"], (0, _extends2["default"])({
|
|
31
44
|
"data-testid": "test",
|
|
32
|
-
value: value
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
,
|
|
39
|
-
onChange: setValue
|
|
40
|
-
}));
|
|
45
|
+
value: value,
|
|
46
|
+
onChange: function onChange(newValue) {
|
|
47
|
+
setValue(newValue);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}, defaultProps));
|
|
41
51
|
};
|
|
42
52
|
|
|
43
53
|
var setup = function setup(props) {
|
package/dist/cjs/Radio/Radio.js
CHANGED
|
@@ -83,28 +83,25 @@ var Radio = function Radio(_ref) {
|
|
|
83
83
|
position: "relative"
|
|
84
84
|
}, restProps), /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
85
85
|
innerRef: inputRef,
|
|
86
|
-
as: "input"
|
|
87
|
-
|
|
88
|
-
// Type 'number' is not assignable to type 'string'.ts(2322)
|
|
86
|
+
as: "input" // Type '{ innerRef: MutableRefObject<undefined>; as: string; type: string; id: string; name: string; checked: boolean; value: any; disabled: boolean; onChange: (event: ChangeEvent<HTMLInputElement>) => void; onFocus: (event: FocusEvent<...>) => void; onBlur: (event: FocusEvent<...>) => void; position: "absolute"; }' is not assignable to type 'IntrinsicAttributes & RefAttributes<any> & HTMLAttributes<any> & ImgHTMLAttributes<any> & { children?: any; ... 5 more ...; mediaQueries?: object; } & ... 4 more ... & Variants<...>'.
|
|
87
|
+
// @ts-ignore
|
|
89
88
|
,
|
|
90
|
-
|
|
89
|
+
type: "radio",
|
|
90
|
+
id: typeof id === 'number' ? String(id) : id,
|
|
91
91
|
name: name,
|
|
92
92
|
checked: checked,
|
|
93
93
|
value: value,
|
|
94
94
|
disabled: disabled,
|
|
95
95
|
onChange: function onChange(event) {
|
|
96
|
-
radioEmitter.emit(name, event.target);
|
|
97
|
-
|
|
96
|
+
radioEmitter.emit(name, event.target);
|
|
98
97
|
_onChange && _onChange(event);
|
|
99
98
|
},
|
|
100
99
|
onFocus: function onFocus(event) {
|
|
101
|
-
setFocus(true);
|
|
102
|
-
|
|
100
|
+
setFocus(true);
|
|
103
101
|
_onFocus && _onFocus(event);
|
|
104
102
|
},
|
|
105
103
|
onBlur: function onBlur(event) {
|
|
106
|
-
setFocus(false);
|
|
107
|
-
|
|
104
|
+
setFocus(false);
|
|
108
105
|
_onBlur && _onBlur(event);
|
|
109
106
|
},
|
|
110
107
|
position: "absolute",
|
|
@@ -15,6 +15,7 @@ import { StackView } from '../StackView';
|
|
|
15
15
|
import Tooltip from '../Tooltip';
|
|
16
16
|
import { mergeProps } from '../utils';
|
|
17
17
|
import { useAccessibilityViolation } from '../hooks/use-accessibility-violation';
|
|
18
|
+
import { designTokens } from '../designTokens';
|
|
18
19
|
import Input from './Input';
|
|
19
20
|
|
|
20
21
|
var _ref2 = /*#__PURE__*/React.createElement(Link, {
|
|
@@ -71,7 +72,7 @@ export function Button(_ref) {
|
|
|
71
72
|
inline: true,
|
|
72
73
|
lineHeight: lineHeight,
|
|
73
74
|
position: 'relative',
|
|
74
|
-
radius:
|
|
75
|
+
radius: designTokens.borderRadius,
|
|
75
76
|
strokeAlign: 'inside',
|
|
76
77
|
strokeWeight: 1,
|
|
77
78
|
userSelect: 'none',
|
package/dist/esm/Input/Inline.js
CHANGED
|
@@ -8,6 +8,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import InputField from './InputField';
|
|
11
|
+
import { designTokens } from '../designTokens';
|
|
11
12
|
|
|
12
13
|
function Inline(_ref) {
|
|
13
14
|
var light = _ref.light,
|
|
@@ -40,7 +41,7 @@ function Inline(_ref) {
|
|
|
40
41
|
paddingHorizontal: 0.5,
|
|
41
42
|
paddingVertical: 0,
|
|
42
43
|
placeholderColor: light ? 'light-5' : 'foregroundTertiary',
|
|
43
|
-
radius:
|
|
44
|
+
radius: designTokens.inputRadius,
|
|
44
45
|
stroke: undefined
|
|
45
46
|
}, restProps));
|
|
46
47
|
}
|
|
@@ -18,6 +18,7 @@ import Spinner from '../Spinner';
|
|
|
18
18
|
import StackView from '../StackView';
|
|
19
19
|
import InputContext from './InputContext';
|
|
20
20
|
import { inputs, isTabbable } from './utils';
|
|
21
|
+
import { designTokens } from '../designTokens';
|
|
21
22
|
|
|
22
23
|
// temporary until InputBox is converted to a functional component
|
|
23
24
|
function DocumentEscape(_ref) {
|
|
@@ -294,7 +295,7 @@ var InputBox = /*#__PURE__*/function (_Component) {
|
|
|
294
295
|
alignment: StackView.CENTER,
|
|
295
296
|
shrink: 0,
|
|
296
297
|
minHeight: boxSize,
|
|
297
|
-
radius:
|
|
298
|
+
radius: designTokens.inputRadius,
|
|
298
299
|
position: "relative",
|
|
299
300
|
cursor: "text",
|
|
300
301
|
outline: 0,
|
|
@@ -47,10 +47,8 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
47
47
|
_defineProperty(_assertThisInitialized(_this), "getParsedValues", function (value) {
|
|
48
48
|
return {
|
|
49
49
|
value: Number.parseFloat(value),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// @ts-ignore Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)
|
|
53
|
-
maxValue: Number.parseFloat(_this.props.max)
|
|
50
|
+
minValue: _this.props.min,
|
|
51
|
+
maxValue: _this.props.max
|
|
54
52
|
};
|
|
55
53
|
});
|
|
56
54
|
|
|
@@ -79,23 +77,22 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
79
77
|
|
|
80
78
|
_defineProperty(_assertThisInitialized(_this), "handleBlur", function (event) {
|
|
81
79
|
var _this$getParsedValues3 = _this.getParsedValues(event.target.value),
|
|
82
|
-
value = _this$getParsedValues3.value,
|
|
83
80
|
minValue = _this$getParsedValues3.minValue,
|
|
84
81
|
maxValue = _this$getParsedValues3.maxValue;
|
|
85
82
|
|
|
83
|
+
var value = Number.parseFloat(event.target.value);
|
|
84
|
+
|
|
86
85
|
if (value < minValue) {
|
|
87
|
-
|
|
88
|
-
_this.props.onChange(minValue);
|
|
86
|
+
_this.props.onChange(minValue.toString());
|
|
89
87
|
} else if (value > maxValue) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
_this.props.onChange(
|
|
88
|
+
_this.props.onChange(maxValue.toString());
|
|
89
|
+
} else if (isNaN(value)) {
|
|
90
|
+
value = _this.clampValue(value);
|
|
91
|
+
|
|
92
|
+
_this.props.onChange(value.toString());
|
|
95
93
|
}
|
|
96
94
|
|
|
97
95
|
if (_this.props.onBlur) {
|
|
98
|
-
// @ts-ignore
|
|
99
96
|
_this.props.onBlur(event);
|
|
100
97
|
}
|
|
101
98
|
|
|
@@ -105,12 +102,10 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
105
102
|
_defineProperty(_assertThisInitialized(_this), "stepValue", function (baseValue, step) {
|
|
106
103
|
var nextValue = _this.clampValue(baseValue + step);
|
|
107
104
|
|
|
108
|
-
var parsedValue = Number.parseFloat(
|
|
109
|
-
baseValue.toString().indexOf('.') > -1 ? nextValue.toFixed(2) : nextValue);
|
|
105
|
+
var parsedValue = Number.parseFloat(baseValue.toString().indexOf('.') > -1 ? nextValue.toFixed(2) : nextValue.toString());
|
|
110
106
|
|
|
111
107
|
if (_this.isValueValid(parsedValue)) {
|
|
112
|
-
|
|
113
|
-
_this.props.onChange(parsedValue);
|
|
108
|
+
_this.props.onChange(parsedValue.toString());
|
|
114
109
|
}
|
|
115
110
|
});
|
|
116
111
|
|
|
@@ -215,15 +210,13 @@ var NumberField = /*#__PURE__*/function (_Component) {
|
|
|
215
210
|
|
|
216
211
|
if (pad && numberValue !== '') {
|
|
217
212
|
numberValue = padNumber(numberValue, pad);
|
|
218
|
-
}
|
|
219
|
-
|
|
213
|
+
}
|
|
220
214
|
|
|
221
|
-
if (parsed.
|
|
215
|
+
if (parsed.minValue !== MIN_VALUE) {
|
|
222
216
|
restProps.min = this.props.min;
|
|
223
|
-
}
|
|
224
|
-
|
|
217
|
+
}
|
|
225
218
|
|
|
226
|
-
if (parsed.
|
|
219
|
+
if (parsed.maxValue !== MAX_VALUE) {
|
|
227
220
|
restProps.max = this.props.max;
|
|
228
221
|
}
|
|
229
222
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
|
+
|
|
3
9
|
import React, { useState } from 'react';
|
|
4
10
|
import { render } from '@testing-library/react';
|
|
5
11
|
import '@testing-library/jest-dom/extend-expect';
|
|
@@ -14,17 +20,21 @@ describe('value', function () {
|
|
|
14
20
|
value = _useState[0],
|
|
15
21
|
setValue = _useState[1];
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
var defaultProps = _objectSpread({
|
|
24
|
+
pad: 0,
|
|
25
|
+
highlightOnInteraction: false,
|
|
26
|
+
placeholder: '',
|
|
27
|
+
autoWidth: false
|
|
28
|
+
}, props);
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/React.createElement(NumberField, _extends({
|
|
18
31
|
"data-testid": "test",
|
|
19
|
-
value: value
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
,
|
|
26
|
-
onChange: setValue
|
|
27
|
-
}));
|
|
32
|
+
value: value,
|
|
33
|
+
onChange: function onChange(newValue) {
|
|
34
|
+
setValue(newValue);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}, defaultProps));
|
|
28
38
|
};
|
|
29
39
|
|
|
30
40
|
var setup = function setup(props) {
|
package/dist/esm/Radio/Radio.js
CHANGED
|
@@ -65,28 +65,25 @@ var Radio = function Radio(_ref) {
|
|
|
65
65
|
position: "relative"
|
|
66
66
|
}, restProps), /*#__PURE__*/React.createElement(Box, {
|
|
67
67
|
innerRef: inputRef,
|
|
68
|
-
as: "input"
|
|
69
|
-
|
|
70
|
-
// Type 'number' is not assignable to type 'string'.ts(2322)
|
|
68
|
+
as: "input" // Type '{ innerRef: MutableRefObject<undefined>; as: string; type: string; id: string; name: string; checked: boolean; value: any; disabled: boolean; onChange: (event: ChangeEvent<HTMLInputElement>) => void; onFocus: (event: FocusEvent<...>) => void; onBlur: (event: FocusEvent<...>) => void; position: "absolute"; }' is not assignable to type 'IntrinsicAttributes & RefAttributes<any> & HTMLAttributes<any> & ImgHTMLAttributes<any> & { children?: any; ... 5 more ...; mediaQueries?: object; } & ... 4 more ... & Variants<...>'.
|
|
69
|
+
// @ts-ignore
|
|
71
70
|
,
|
|
72
|
-
|
|
71
|
+
type: "radio",
|
|
72
|
+
id: typeof id === 'number' ? String(id) : id,
|
|
73
73
|
name: name,
|
|
74
74
|
checked: checked,
|
|
75
75
|
value: value,
|
|
76
76
|
disabled: disabled,
|
|
77
77
|
onChange: function onChange(event) {
|
|
78
|
-
radioEmitter.emit(name, event.target);
|
|
79
|
-
|
|
78
|
+
radioEmitter.emit(name, event.target);
|
|
80
79
|
_onChange && _onChange(event);
|
|
81
80
|
},
|
|
82
81
|
onFocus: function onFocus(event) {
|
|
83
|
-
setFocus(true);
|
|
84
|
-
|
|
82
|
+
setFocus(true);
|
|
85
83
|
_onFocus && _onFocus(event);
|
|
86
84
|
},
|
|
87
85
|
onBlur: function onBlur(event) {
|
|
88
|
-
setFocus(false);
|
|
89
|
-
|
|
86
|
+
setFocus(false);
|
|
90
87
|
_onBlur && _onBlur(event);
|
|
91
88
|
},
|
|
92
89
|
position: "absolute",
|
|
@@ -96,9 +96,7 @@ export declare namespace Button {
|
|
|
96
96
|
close: any;
|
|
97
97
|
}) => React.ReactNode);
|
|
98
98
|
size?: "xs" | "sm" | "md" | "lg";
|
|
99
|
-
onClose: () => void;
|
|
100
|
-
* Pass styles for when the button is active.
|
|
101
|
-
*/
|
|
99
|
+
onClose: () => void;
|
|
102
100
|
onOpen: () => void;
|
|
103
101
|
} & {
|
|
104
102
|
children?: any;
|
|
@@ -30,7 +30,8 @@ declare type Props = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Maps to the input's `onBlur` prop.
|
|
32
32
|
*/
|
|
33
|
-
onBlur?:
|
|
33
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
34
|
+
onInput?: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
34
35
|
onKeyDown?: Function;
|
|
35
36
|
/**
|
|
36
37
|
* The amount of 0s to pad the value with.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare type RadioProps = {
|
|
2
3
|
/**
|
|
3
4
|
* Disables the radio component.
|
|
@@ -30,15 +31,15 @@ export declare type RadioProps = {
|
|
|
30
31
|
/**
|
|
31
32
|
* Maps to the internal input's `onChange` prop.
|
|
32
33
|
*/
|
|
33
|
-
onChange?: () =>
|
|
34
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
34
35
|
/**
|
|
35
36
|
* Maps to the internal input's `onFocus` prop.
|
|
36
37
|
*/
|
|
37
|
-
onFocus?: () =>
|
|
38
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
38
39
|
/**
|
|
39
40
|
* Maps to the internal input's `onBlur` prop.
|
|
40
41
|
*/
|
|
41
|
-
onBlur?: () =>
|
|
42
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
42
43
|
};
|
|
43
44
|
declare const Radio: ({ checked, disabled, id, label, name, onBlur, onChange, onFocus, size, value, ...restProps }: RadioProps) => JSX.Element;
|
|
44
45
|
export default Radio;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/tapestry-react",
|
|
3
|
-
"version": "2.10.0-rc.
|
|
3
|
+
"version": "2.10.0-rc.3",
|
|
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
|
@@ -9,6 +9,7 @@ import { StackView, StackViewProps } from '../StackView'
|
|
|
9
9
|
import Tooltip from '../Tooltip'
|
|
10
10
|
import { mergeProps } from '../utils'
|
|
11
11
|
import { useAccessibilityViolation } from '../hooks/use-accessibility-violation'
|
|
12
|
+
import { designTokens } from '../designTokens'
|
|
12
13
|
|
|
13
14
|
import Input from './Input'
|
|
14
15
|
|
|
@@ -164,7 +165,7 @@ export function Button({
|
|
|
164
165
|
inline: true,
|
|
165
166
|
lineHeight,
|
|
166
167
|
position: 'relative',
|
|
167
|
-
radius:
|
|
168
|
+
radius: designTokens.borderRadius,
|
|
168
169
|
strokeAlign: 'inside',
|
|
169
170
|
strokeWeight: 1,
|
|
170
171
|
userSelect: 'none',
|
package/src/Input/Inline.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
import InputField from './InputField'
|
|
5
|
+
import { designTokens } from '../designTokens'
|
|
5
6
|
|
|
6
7
|
type Props = {
|
|
7
8
|
/** Controls the color when hovered and focused. (Defaults `light ? 'light-0' : 'highlight'` */
|
|
@@ -51,7 +52,7 @@ function Inline({
|
|
|
51
52
|
paddingHorizontal={0.5}
|
|
52
53
|
paddingVertical={0}
|
|
53
54
|
placeholderColor={light ? 'light-5' : 'foregroundTertiary'}
|
|
54
|
-
radius={
|
|
55
|
+
radius={designTokens.inputRadius}
|
|
55
56
|
stroke={undefined}
|
|
56
57
|
{...restProps}
|
|
57
58
|
/>
|
package/src/Input/InputBox.js
CHANGED
|
@@ -11,6 +11,7 @@ import StackView from '../StackView'
|
|
|
11
11
|
|
|
12
12
|
import InputContext from './InputContext'
|
|
13
13
|
import { inputs, isTabbable } from './utils'
|
|
14
|
+
import { designTokens } from '../designTokens'
|
|
14
15
|
|
|
15
16
|
export type InputBoxProps = {
|
|
16
17
|
/**
|
|
@@ -389,7 +390,7 @@ class InputBox extends Component<InputBoxProps> {
|
|
|
389
390
|
alignment={StackView.CENTER}
|
|
390
391
|
shrink={0}
|
|
391
392
|
minHeight={boxSize}
|
|
392
|
-
radius={
|
|
393
|
+
radius={designTokens.inputRadius}
|
|
393
394
|
position="relative"
|
|
394
395
|
cursor="text"
|
|
395
396
|
outline={0}
|
|
@@ -7,18 +7,22 @@ import NumberField from './NumberField'
|
|
|
7
7
|
describe('value', () => {
|
|
8
8
|
const TestApp = ({ value: initialValue, ...props }) => {
|
|
9
9
|
const [value, setValue] = useState(initialValue)
|
|
10
|
+
const defaultProps = {
|
|
11
|
+
pad: 0,
|
|
12
|
+
highlightOnInteraction: false,
|
|
13
|
+
placeholder: '',
|
|
14
|
+
autoWidth: false,
|
|
15
|
+
...props,
|
|
16
|
+
}
|
|
10
17
|
return (
|
|
11
18
|
<NumberField
|
|
12
|
-
{...props}
|
|
13
19
|
data-testid="test"
|
|
14
20
|
value={value}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Type 'Dispatch<any>' is not assignable to type '(value: string) => null'.ts(2769)
|
|
21
|
-
onChange={setValue}
|
|
21
|
+
onChange={(newValue) => {
|
|
22
|
+
setValue(newValue)
|
|
23
|
+
return null
|
|
24
|
+
}}
|
|
25
|
+
{...defaultProps}
|
|
22
26
|
/>
|
|
23
27
|
)
|
|
24
28
|
}
|
|
@@ -42,7 +42,9 @@ type Props = {
|
|
|
42
42
|
/**
|
|
43
43
|
* Maps to the input's `onBlur` prop.
|
|
44
44
|
*/
|
|
45
|
-
onBlur?:
|
|
45
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>
|
|
46
|
+
|
|
47
|
+
onInput?: (event: React.FormEvent<HTMLInputElement>) => void
|
|
46
48
|
|
|
47
49
|
onKeyDown?: Function
|
|
48
50
|
|
|
@@ -124,10 +126,8 @@ class NumberField extends Component<Props> {
|
|
|
124
126
|
getParsedValues = (value) => {
|
|
125
127
|
return {
|
|
126
128
|
value: Number.parseFloat(value),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// @ts-ignore Argument of type 'number' is not assignable to parameter of type 'string'.ts(2345)
|
|
130
|
-
maxValue: Number.parseFloat(this.props.max),
|
|
129
|
+
minValue: this.props.min,
|
|
130
|
+
maxValue: this.props.max,
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -148,21 +148,18 @@ class NumberField extends Component<Props> {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
handleBlur = (event) => {
|
|
151
|
-
const {
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
const { minValue, maxValue } = this.getParsedValues(event.target.value)
|
|
152
|
+
let value = Number.parseFloat(event.target.value)
|
|
153
|
+
|
|
154
154
|
if (value < minValue) {
|
|
155
|
-
|
|
156
|
-
this.props.onChange(minValue)
|
|
155
|
+
this.props.onChange(minValue.toString())
|
|
157
156
|
} else if (value > maxValue) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
this.props.onChange(this.clampValue(value))
|
|
157
|
+
this.props.onChange(maxValue.toString())
|
|
158
|
+
} else if (isNaN(value)) {
|
|
159
|
+
value = this.clampValue(value)
|
|
160
|
+
this.props.onChange(value.toString())
|
|
163
161
|
}
|
|
164
162
|
if (this.props.onBlur) {
|
|
165
|
-
// @ts-ignore
|
|
166
163
|
this.props.onBlur(event)
|
|
167
164
|
}
|
|
168
165
|
this.firstTouch = true
|
|
@@ -171,12 +168,12 @@ class NumberField extends Component<Props> {
|
|
|
171
168
|
stepValue = (baseValue, step) => {
|
|
172
169
|
const nextValue = this.clampValue(baseValue + step)
|
|
173
170
|
const parsedValue = Number.parseFloat(
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
baseValue.toString().indexOf('.') > -1
|
|
172
|
+
? nextValue.toFixed(2)
|
|
173
|
+
: nextValue.toString()
|
|
176
174
|
)
|
|
177
175
|
if (this.isValueValid(parsedValue)) {
|
|
178
|
-
|
|
179
|
-
this.props.onChange(parsedValue)
|
|
176
|
+
this.props.onChange(parsedValue.toString())
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
179
|
|
|
@@ -265,13 +262,11 @@ class NumberField extends Component<Props> {
|
|
|
265
262
|
numberValue = padNumber(numberValue, pad)
|
|
266
263
|
}
|
|
267
264
|
|
|
268
|
-
|
|
269
|
-
if (parsed.min !== MIN_VALUE) {
|
|
265
|
+
if (parsed.minValue !== MIN_VALUE) {
|
|
270
266
|
restProps.min = this.props.min
|
|
271
267
|
}
|
|
272
268
|
|
|
273
|
-
|
|
274
|
-
if (parsed.max !== MAX_VALUE) {
|
|
269
|
+
if (parsed.maxValue !== MAX_VALUE) {
|
|
275
270
|
restProps.max = this.props.max
|
|
276
271
|
}
|
|
277
272
|
|
|
@@ -343,7 +338,6 @@ class NumberField extends Component<Props> {
|
|
|
343
338
|
moveFocusOnMax,
|
|
344
339
|
onChange,
|
|
345
340
|
onBlur,
|
|
346
|
-
// @ts-ignore Property 'onInput' does not exist on type 'Readonly<Props>'.ts(2339)
|
|
347
341
|
onInput,
|
|
348
342
|
onKeyDown,
|
|
349
343
|
pad,
|
package/src/Radio/Radio.tsx
CHANGED
|
@@ -52,17 +52,17 @@ export type RadioProps = {
|
|
|
52
52
|
/**
|
|
53
53
|
* Maps to the internal input's `onChange` prop.
|
|
54
54
|
*/
|
|
55
|
-
onChange?: () =>
|
|
55
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Maps to the internal input's `onFocus` prop.
|
|
59
59
|
*/
|
|
60
|
-
onFocus?: () =>
|
|
60
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Maps to the internal input's `onBlur` prop.
|
|
64
64
|
*/
|
|
65
|
-
onBlur?: () =>
|
|
65
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const radioEmitter = mitt()
|
|
@@ -84,6 +84,7 @@ const Radio = ({
|
|
|
84
84
|
const inputRef = useRef()
|
|
85
85
|
const [localChecked, setLocalChecked] = useState(false)
|
|
86
86
|
const [focus, setFocus] = useState(false)
|
|
87
|
+
|
|
87
88
|
// Because radio components are grouped by the name prop we use an event emitter
|
|
88
89
|
// as a way to toggle the state between each one
|
|
89
90
|
useEffect(() => {
|
|
@@ -114,27 +115,24 @@ const Radio = ({
|
|
|
114
115
|
<Box
|
|
115
116
|
innerRef={inputRef}
|
|
116
117
|
as="input"
|
|
118
|
+
// Type '{ innerRef: MutableRefObject<undefined>; as: string; type: string; id: string; name: string; checked: boolean; value: any; disabled: boolean; onChange: (event: ChangeEvent<HTMLInputElement>) => void; onFocus: (event: FocusEvent<...>) => void; onBlur: (event: FocusEvent<...>) => void; position: "absolute"; }' is not assignable to type 'IntrinsicAttributes & RefAttributes<any> & HTMLAttributes<any> & ImgHTMLAttributes<any> & { children?: any; ... 5 more ...; mediaQueries?: object; } & ... 4 more ... & Variants<...>'.
|
|
119
|
+
// @ts-ignore
|
|
117
120
|
type="radio"
|
|
118
|
-
|
|
119
|
-
// Type 'number' is not assignable to type 'string'.ts(2322)
|
|
120
|
-
id={id}
|
|
121
|
+
id={typeof id === 'number' ? String(id) : id}
|
|
121
122
|
name={name}
|
|
122
123
|
checked={checked}
|
|
123
124
|
value={value}
|
|
124
125
|
disabled={disabled}
|
|
125
|
-
onChange={(event) => {
|
|
126
|
+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
126
127
|
radioEmitter.emit(name, event.target)
|
|
127
|
-
// @ts-ignore Expected 0 arguments, but got 1.ts(2554)
|
|
128
128
|
onChange && onChange(event)
|
|
129
129
|
}}
|
|
130
130
|
onFocus={(event) => {
|
|
131
131
|
setFocus(true)
|
|
132
|
-
// @ts-ignore Expected 0 arguments, but got 1.ts(2554)
|
|
133
132
|
onFocus && onFocus(event)
|
|
134
133
|
}}
|
|
135
134
|
onBlur={(event) => {
|
|
136
135
|
setFocus(false)
|
|
137
|
-
// @ts-ignore Expected 0 arguments, but got 1.ts(2554)
|
|
138
136
|
onBlur && onBlur(event)
|
|
139
137
|
}}
|
|
140
138
|
position="absolute"
|