grommet 2.25.0 → 2.25.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/components/Calendar/Calendar.js +232 -292
- package/components/Calendar/utils.js +16 -129
- package/components/Chart/calcs.js +44 -27
- package/components/Chart/stories/Scan.js +11 -9
- package/components/Chart/stories/data.js +16 -17
- package/components/CheckBox/CheckBox.js +3 -2
- package/components/DataChart/DataChart.js +3 -15
- package/components/DataChart/Detail.js +18 -11
- package/components/DataChart/stories/Pad.js +54 -0
- package/components/DateInput/DateInput.js +60 -68
- package/components/DateInput/utils.js +30 -5
- package/components/FileInput/FileInput.js +2 -1
- package/components/FileInput/StyledFileInput.js +1 -1
- package/components/Form/Form.js +6 -1
- package/components/FormField/FormField.js +25 -28
- package/components/Image/Image.js +4 -2
- package/components/Menu/index.d.ts +2 -2
- package/components/Select/SelectContainer.js +24 -36
- package/components/Tabs/Tabs.js +2 -1
- package/components/Video/StyledVideo.js +2 -2
- package/es6/components/Calendar/Calendar.js +230 -292
- package/es6/components/Calendar/utils.js +13 -114
- package/es6/components/Chart/calcs.js +44 -27
- package/es6/components/Chart/stories/Scan.js +10 -9
- package/es6/components/Chart/stories/data.js +16 -17
- package/es6/components/CheckBox/CheckBox.js +3 -2
- package/es6/components/DataChart/DataChart.js +4 -15
- package/es6/components/DataChart/Detail.js +20 -10
- package/es6/components/DataChart/stories/Pad.js +42 -0
- package/es6/components/DateInput/DateInput.js +57 -64
- package/es6/components/DateInput/utils.js +29 -7
- package/es6/components/FileInput/FileInput.js +2 -1
- package/es6/components/FileInput/StyledFileInput.js +1 -1
- package/es6/components/Form/Form.js +6 -1
- package/es6/components/FormField/FormField.js +25 -29
- package/es6/components/Image/Image.js +4 -2
- package/es6/components/Menu/index.d.ts +2 -2
- package/es6/components/Select/SelectContainer.js +25 -37
- package/es6/components/Tabs/Tabs.js +2 -1
- package/es6/components/Video/StyledVideo.js +2 -2
- package/es6/themes/base.d.ts +13 -27
- package/es6/themes/base.js +6 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +44 -42
- package/themes/base.d.ts +13 -27
- package/themes/base.js +6 -1
|
@@ -33,12 +33,12 @@ var _MaskedInput = require("../MaskedInput");
|
|
|
33
33
|
|
|
34
34
|
var _utils = require("../../utils");
|
|
35
35
|
|
|
36
|
-
var _utils2 = require("
|
|
37
|
-
|
|
38
|
-
var _utils3 = require("./utils");
|
|
36
|
+
var _utils2 = require("./utils");
|
|
39
37
|
|
|
40
38
|
var _propTypes = require("./propTypes");
|
|
41
39
|
|
|
40
|
+
var _Calendar3 = require("../Calendar/Calendar");
|
|
41
|
+
|
|
42
42
|
var _excluded = ["buttonProps", "calendarProps", "defaultValue", "disabled", "dropProps", "format", "id", "icon", "inline", "inputProps", "name", "onChange", "onFocus", "plain", "reverse", "value", "messages"],
|
|
43
43
|
_excluded2 = ["icon"];
|
|
44
44
|
|
|
@@ -50,6 +50,30 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
50
50
|
|
|
51
51
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
52
52
|
|
|
53
|
+
var getReference = function getReference(value) {
|
|
54
|
+
var adjustedDate;
|
|
55
|
+
var res;
|
|
56
|
+
if (typeof value === 'string') res = value;else if (Array.isArray(value) && Array.isArray(value[0])) res = value[0].find(function (date) {
|
|
57
|
+
return date;
|
|
58
|
+
});else if (Array.isArray(value) && value.length) {
|
|
59
|
+
res = value[0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (res) {
|
|
63
|
+
var _res;
|
|
64
|
+
|
|
65
|
+
adjustedDate = new Date(res); // if time is not specified in ISOstring, normalize to midnight
|
|
66
|
+
|
|
67
|
+
if (((_res = res) == null ? void 0 : _res.indexOf('T')) === -1) {
|
|
68
|
+
var offset = adjustedDate.getTimezoneOffset();
|
|
69
|
+
var hour = adjustedDate.getHours();
|
|
70
|
+
adjustedDate.setHours(hour, offset);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return adjustedDate;
|
|
75
|
+
};
|
|
76
|
+
|
|
53
77
|
var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
54
78
|
var buttonProps = _ref.buttonProps,
|
|
55
79
|
calendarProps = _ref.calendarProps,
|
|
@@ -95,39 +119,38 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
95
119
|
value = _useFormInput[0],
|
|
96
120
|
setValue = _useFormInput[1];
|
|
97
121
|
|
|
98
|
-
var
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (Array.isArray(value) && value.length) return (0, _utils2.getTimestamp)(value[0]); // check to see if value is not an empty string
|
|
102
|
-
// empty string should behave like undefined
|
|
122
|
+
var _useState = (0, _react.useState)((0, _Calendar3.getOutputFormat)(value)),
|
|
123
|
+
outputFormat = _useState[0],
|
|
124
|
+
setOutputFormat = _useState[1];
|
|
103
125
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// will just rely on the UTC timestamp and don't need to normalize.
|
|
126
|
+
(0, _react.useEffect)(function () {
|
|
127
|
+
setOutputFormat(function (previousFormat) {
|
|
128
|
+
var nextFormat = (0, _Calendar3.getOutputFormat)(value); // when user types, date could become something like 07//2020
|
|
129
|
+
// and value becomes undefined. don't lose the format from the
|
|
130
|
+
// previous valid date
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
return previousFormat !== nextFormat ? previousFormat : nextFormat;
|
|
133
|
+
});
|
|
134
|
+
}, [value]); // keep track of timestamp from original date(s)
|
|
114
135
|
|
|
136
|
+
var _useState2 = (0, _react.useState)(getReference(value)),
|
|
137
|
+
reference = _useState2[0],
|
|
138
|
+
setReference = _useState2[1]; // do we expect multiple dates?
|
|
115
139
|
|
|
116
|
-
var normalizedDate = (0, _utils2.normalizeForTimezone)(value, timestamp, normalize); // do we expect multiple dates?
|
|
117
140
|
|
|
118
141
|
var range = Array.isArray(value) || format && format.includes('-'); // parse format and build a formal schema we can use elsewhere
|
|
119
142
|
|
|
120
143
|
var schema = (0, _react.useMemo)(function () {
|
|
121
|
-
return (0,
|
|
144
|
+
return (0, _utils2.formatToSchema)(format);
|
|
122
145
|
}, [format]); // mask is only used when a format is provided
|
|
123
146
|
|
|
124
147
|
var mask = (0, _react.useMemo)(function () {
|
|
125
|
-
return (0,
|
|
148
|
+
return (0, _utils2.schemaToMask)(schema);
|
|
126
149
|
}, [schema]); // textValue is only used when a format is provided
|
|
127
150
|
|
|
128
|
-
var
|
|
129
|
-
textValue =
|
|
130
|
-
setTextValue =
|
|
151
|
+
var _useState3 = (0, _react.useState)(schema ? (0, _utils2.valueToText)(value, schema) : undefined),
|
|
152
|
+
textValue = _useState3[0],
|
|
153
|
+
setTextValue = _useState3[1]; // Setting the icon through `inputProps` is deprecated.
|
|
131
154
|
// The `icon` prop should be used instead.
|
|
132
155
|
|
|
133
156
|
|
|
@@ -152,17 +175,17 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
152
175
|
|
|
153
176
|
(0, _react.useEffect)(function () {
|
|
154
177
|
if (schema && value !== undefined) {
|
|
155
|
-
var nextTextValue = (0,
|
|
178
|
+
var nextTextValue = (0, _utils2.valueToText)(value, schema);
|
|
156
179
|
|
|
157
|
-
if (!(0,
|
|
180
|
+
if (!(0, _utils2.valuesAreEqual)((0, _utils2.textToValue)(textValue, schema, range, reference), (0, _utils2.textToValue)(nextTextValue, schema, range, reference)) || textValue === '' && nextTextValue !== '') {
|
|
158
181
|
setTextValue(nextTextValue);
|
|
159
182
|
}
|
|
160
183
|
}
|
|
161
|
-
}, [range, schema, textValue,
|
|
184
|
+
}, [range, schema, textValue, reference, value]); // when format and not inline, whether to show the Calendar in a Drop
|
|
162
185
|
|
|
163
|
-
var
|
|
164
|
-
open =
|
|
165
|
-
setOpen =
|
|
186
|
+
var _useState4 = (0, _react.useState)(),
|
|
187
|
+
open = _useState4[0],
|
|
188
|
+
setOpen = _useState4[1];
|
|
166
189
|
|
|
167
190
|
var openCalendar = (0, _react.useCallback)(function () {
|
|
168
191
|
setOpen(true);
|
|
@@ -183,33 +206,23 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
183
206
|
ref: inline ? ref : undefined,
|
|
184
207
|
id: inline && !format ? id : undefined,
|
|
185
208
|
range: range,
|
|
186
|
-
date: range ? undefined :
|
|
209
|
+
date: range ? undefined : value // when caller initializes with empty array, dates should be undefined
|
|
187
210
|
// allowing the user to select both begin and end of the range
|
|
188
211
|
,
|
|
189
|
-
dates: range && value.length ? [
|
|
212
|
+
dates: range && value.length ? [value] : undefined // places focus on days grid when Calendar opens
|
|
190
213
|
,
|
|
191
214
|
initialFocus: open ? 'days' : undefined,
|
|
192
|
-
normalize: normalize,
|
|
193
215
|
onSelect: disabled ? undefined : function (nextValue) {
|
|
194
216
|
var normalizedValue;
|
|
195
217
|
|
|
196
218
|
if (range && Array.isArray(nextValue)) {
|
|
197
219
|
normalizedValue = nextValue[0];
|
|
198
220
|
} // clicking an edge date removes it
|
|
199
|
-
else if (range) normalizedValue = [nextValue, nextValue];else normalizedValue = nextValue;
|
|
200
|
-
// been passed in, indicating that we should stay local if the
|
|
201
|
-
// user first picks a date via the Calendar.
|
|
202
|
-
|
|
221
|
+
else if (range) normalizedValue = [nextValue, nextValue];else normalizedValue = nextValue;
|
|
203
222
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (timestamp === undefined) {
|
|
207
|
-
nextNormalize = false;
|
|
208
|
-
setNormalize(nextNormalize);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (schema) setTextValue((0, _utils3.valueToText)((0, _utils2.normalizeForTimezone)(normalizedValue, undefined, nextNormalize), schema));
|
|
223
|
+
if (schema) setTextValue((0, _utils2.valueToText)(normalizedValue, schema));
|
|
212
224
|
setValue(normalizedValue);
|
|
225
|
+
setReference(getReference(nextValue));
|
|
213
226
|
if (_onChange) _onChange({
|
|
214
227
|
value: normalizedValue
|
|
215
228
|
});
|
|
@@ -221,9 +234,7 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
221
234
|
}, 1);
|
|
222
235
|
}
|
|
223
236
|
}
|
|
224
|
-
},
|
|
225
|
-
timestamp: timestamp
|
|
226
|
-
})));
|
|
237
|
+
}, calendarProps));
|
|
227
238
|
|
|
228
239
|
var formContextValue = (0, _react.useMemo)(function () {
|
|
229
240
|
return {
|
|
@@ -294,27 +305,8 @@ var DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, refArg) {
|
|
|
294
305
|
onChange: function onChange(event) {
|
|
295
306
|
var nextTextValue = event.target.value;
|
|
296
307
|
setTextValue(nextTextValue);
|
|
297
|
-
var
|
|
298
|
-
//
|
|
299
|
-
|
|
300
|
-
if (timestamp === undefined && Date.parse(nextTextValue)) {
|
|
301
|
-
var _Date$toISOString$spl = new Date(nextTextValue).toISOString().split('T');
|
|
302
|
-
|
|
303
|
-
localTimestamp = _Date$toISOString$spl[1];
|
|
304
|
-
} // timestamp will be undefined if no defaultValue or value have
|
|
305
|
-
// been passed in, indicating that we should stay local
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var nextNormalize = normalize;
|
|
309
|
-
|
|
310
|
-
if (timestamp === undefined) {
|
|
311
|
-
nextNormalize = false;
|
|
312
|
-
setNormalize(nextNormalize);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
var nextValue = (0, _utils3.textToValue)(nextTextValue, schema, range, timestamp || localTimestamp, nextNormalize); // reset to original state
|
|
316
|
-
|
|
317
|
-
if (nextValue === undefined) setNormalize(true); // update value even when undefined
|
|
308
|
+
var nextValue = (0, _utils2.textToValue)(nextTextValue, schema, range, reference, outputFormat);
|
|
309
|
+
if (nextValue !== undefined) setReference(getReference(nextValue)); // update value even when undefined
|
|
318
310
|
|
|
319
311
|
setValue(nextValue);
|
|
320
312
|
|
|
@@ -5,8 +5,17 @@ exports.valuesAreEqual = exports.valueToText = exports.textToValue = exports.sch
|
|
|
5
5
|
|
|
6
6
|
var _utils = require("../Calendar/utils");
|
|
7
7
|
|
|
8
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
9
|
+
|
|
10
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
+
|
|
12
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
+
|
|
8
14
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
9
15
|
|
|
16
|
+
// Converting between Date and String types is handled via a "schema".
|
|
17
|
+
// The schema is an array of strings, split into strings with identical
|
|
18
|
+
// characters. So, 'mm/dd/yyyy' will be ['mm', '/', 'dd', '/', 'yyyyy'].
|
|
10
19
|
var formatToSchema = function formatToSchema(format) {
|
|
11
20
|
if (!format) return undefined;
|
|
12
21
|
var result = [];
|
|
@@ -79,7 +88,16 @@ var valueToText = function valueToText(value, schema) {
|
|
|
79
88
|
|
|
80
89
|
if (!value || Array.isArray(value) && !value.length) return text;
|
|
81
90
|
var dates = (Array.isArray(value) ? value : [value]).map(function (v) {
|
|
82
|
-
|
|
91
|
+
// TO DO should we extract this to a reusable function?
|
|
92
|
+
var adjustedDate = new Date(v); // if time is not specified in ISOstring, normalize to midnight
|
|
93
|
+
|
|
94
|
+
if (v.indexOf('T') === -1) {
|
|
95
|
+
var offset = adjustedDate.getTimezoneOffset();
|
|
96
|
+
var hour = adjustedDate.getHours();
|
|
97
|
+
adjustedDate.setHours(hour, offset);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return adjustedDate;
|
|
83
101
|
});
|
|
84
102
|
var dateIndex = 0;
|
|
85
103
|
var parts = {};
|
|
@@ -137,7 +155,7 @@ var pullDigits = function pullDigits(text, index) {
|
|
|
137
155
|
return text.slice(index, end);
|
|
138
156
|
};
|
|
139
157
|
|
|
140
|
-
var textToValue = function textToValue(text, schema, range,
|
|
158
|
+
var textToValue = function textToValue(text, schema, range, reference, outputFormat) {
|
|
141
159
|
if (!text) return range ? [] : undefined;
|
|
142
160
|
var result;
|
|
143
161
|
|
|
@@ -145,10 +163,17 @@ var textToValue = function textToValue(text, schema, range, timestamp, normalize
|
|
|
145
163
|
var leapYear = parts.y % 4 === 0 && parts.y % 100 !== 0 || parts.y % 400 === 0; // Do a little sanity checking on the parts first.
|
|
146
164
|
// If not valid, leave as is.
|
|
147
165
|
|
|
148
|
-
if (!parts.m || !parts.d || !parts.y || parts.y.length < 4 || parts.m.length > 2 || parts.d.length > 2 || parts.m > 12 || parts.d > 31 || (parts.m === "02" || parts.m === "2") && parts.d > (leapYear ? 29 : 28)) return parts;
|
|
149
|
-
|
|
166
|
+
if (!parts.m || !parts.d || !parts.y || parts.y.length < 4 || parts.m.length > 2 || parts.d.length > 2 || parts.m > 12 || parts.d > 31 || (parts.m === "02" || parts.m === "2") && parts.d > (leapYear ? 29 : 28)) return parts; // use time info from reference date
|
|
167
|
+
|
|
168
|
+
var time = reference ? [reference.getHours(), reference.getMinutes(), reference.getSeconds(), reference.getMilliseconds()] : null;
|
|
169
|
+
|
|
170
|
+
var date = _construct(Date, [parts.y, parts.m - 1, parts.d].concat(time)).toISOString();
|
|
150
171
|
|
|
151
|
-
if (
|
|
172
|
+
if (date && outputFormat === 'no timezone') {
|
|
173
|
+
var _handleOffset$toISOSt = (0, _utils.handleOffset)(date).toISOString().split('T');
|
|
174
|
+
|
|
175
|
+
date = _handleOffset$toISOSt[0];
|
|
176
|
+
}
|
|
152
177
|
|
|
153
178
|
if (!range) {
|
|
154
179
|
if (!result) result = date;
|
|
@@ -64,7 +64,7 @@ var formatBytes = function formatBytes(size) {
|
|
|
64
64
|
var ContentsBox = (0, _styledComponents["default"])(_Box.Box).withConfig({
|
|
65
65
|
displayName: "FileInput__ContentsBox",
|
|
66
66
|
componentId: "sc-1jzq7im-0"
|
|
67
|
-
})(["position:relative;", " ", ";", ";", ";"], function (props) {
|
|
67
|
+
})(["cursor:pointer;position:relative;", " ", ";", ";", ";"], function (props) {
|
|
68
68
|
return props.disabled && (0, _utils.disabledStyle)();
|
|
69
69
|
}, function (props) {
|
|
70
70
|
return props.theme.fileInput && props.theme.fileInput.extend;
|
|
@@ -314,6 +314,7 @@ var FileInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
314
314
|
justify: "between"
|
|
315
315
|
}, files.length <= aggregateThreshold && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Message, theme.fileInput.message, message), /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, {
|
|
316
316
|
onSpace: function onSpace(event) {
|
|
317
|
+
event.preventDefault();
|
|
317
318
|
if (controlRef.current === event.target) inputRef.current.click();
|
|
318
319
|
},
|
|
319
320
|
onEnter: function onEnter(event) {
|
|
@@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
14
14
|
var StyledFileInput = _styledComponents["default"].input.withConfig({
|
|
15
15
|
displayName: "StyledFileInput",
|
|
16
16
|
componentId: "sc-rl7ywv-0"
|
|
17
|
-
})(["position:absolute;height:100%;width:100%;", " opacity:0;border:none;", " ", " &::-moz-focus-inner{border:none;outline:none;}"], _utils.inputStyle, function (props) {
|
|
17
|
+
})(["position:absolute;height:100%;width:100%;", " font-size:0;opacity:0;border:none;", " ", " &::-moz-focus-inner{border:none;outline:none;}&::-webkit-file-upload-button{cursor:pointer;}"], _utils.inputStyle, function (props) {
|
|
18
18
|
return !props.disabled && 'cursor: pointer;';
|
|
19
19
|
}, function (props) {
|
|
20
20
|
return props.rightOffset && "\n width: calc(100% - " + props.rightOffset + "px);\n right: " + props.rightOffset + "px;\n ";
|
package/components/Form/Form.js
CHANGED
|
@@ -499,7 +499,12 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
499
499
|
|
|
500
500
|
validationRulesRef.current[name].field = validateName(validateArg, required);
|
|
501
501
|
return function () {
|
|
502
|
-
|
|
502
|
+
delete validationRulesRef.current[name].field;
|
|
503
|
+
var requiredFieldIndex = requiredFields.current.indexOf(name);
|
|
504
|
+
|
|
505
|
+
if (requiredFieldIndex !== -1) {
|
|
506
|
+
requiredFields.current.splice(requiredFieldIndex, 1);
|
|
507
|
+
}
|
|
503
508
|
};
|
|
504
509
|
}
|
|
505
510
|
|
|
@@ -153,21 +153,23 @@ var Input = function Input(_ref2) {
|
|
|
153
153
|
}, rest, extraProps));
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
-
var
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
args[_key] = arguments[_key];
|
|
161
|
-
}
|
|
156
|
+
var useDebounce = function useDebounce() {
|
|
157
|
+
var _useState = (0, _react.useState)(),
|
|
158
|
+
func = _useState[0],
|
|
159
|
+
setFunc = _useState[1];
|
|
162
160
|
|
|
163
|
-
|
|
164
|
-
timeout = null;
|
|
165
|
-
func.apply(void 0, args);
|
|
166
|
-
};
|
|
161
|
+
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
167
162
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
(0, _react.useEffect)(function () {
|
|
164
|
+
var timer;
|
|
165
|
+
if (func) timer = setTimeout(function () {
|
|
166
|
+
return func();
|
|
167
|
+
}, theme.global.debounceDelay);
|
|
168
|
+
return function () {
|
|
169
|
+
return clearTimeout(timer);
|
|
170
|
+
};
|
|
171
|
+
}, [func, theme.global.debounceDelay]);
|
|
172
|
+
return setFunc;
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
@@ -210,13 +212,14 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
210
212
|
contextOnBlur = _formContext$useFormF.onBlur,
|
|
211
213
|
contextOnChange = _formContext$useFormF.onChange;
|
|
212
214
|
|
|
213
|
-
var
|
|
214
|
-
focus =
|
|
215
|
-
setFocus =
|
|
215
|
+
var _useState2 = (0, _react.useState)(),
|
|
216
|
+
focus = _useState2[0],
|
|
217
|
+
setFocus = _useState2[1];
|
|
216
218
|
|
|
217
219
|
var formFieldRef = (0, _refs.useForwardedRef)(ref);
|
|
218
220
|
var formFieldTheme = theme.formField;
|
|
219
|
-
var themeBorder = formFieldTheme.border;
|
|
221
|
+
var themeBorder = formFieldTheme.border;
|
|
222
|
+
var debounce = useDebounce(); // This is here for backwards compatibility. In case the child is a grommet
|
|
220
223
|
// input component, set plain and focusIndicator props, if they aren't
|
|
221
224
|
// already set.
|
|
222
225
|
|
|
@@ -393,17 +396,11 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
393
396
|
onChange: contextOnChange || onChange ? function (event) {
|
|
394
397
|
event.persist();
|
|
395
398
|
if (onChange) onChange(event);
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
// field, but capture their attention before they move on
|
|
402
|
-
// past it. 2 second (2000ms) might be too long depending
|
|
403
|
-
// on how fast people type, and 200ms would be an eye blink
|
|
404
|
-
}, 500);
|
|
405
|
-
debouncedFn();
|
|
406
|
-
}
|
|
399
|
+
if (contextOnChange) debounce(function () {
|
|
400
|
+
return function () {
|
|
401
|
+
return contextOnChange(event);
|
|
402
|
+
};
|
|
403
|
+
});
|
|
407
404
|
} : undefined
|
|
408
405
|
}, containerRest), label && component !== _CheckBox.CheckBox || help ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label && component !== _CheckBox.CheckBox && /*#__PURE__*/_react["default"].createElement(_Text.Text, _extends({
|
|
409
406
|
as: "label",
|
|
@@ -9,7 +9,7 @@ var _StyledImage = require("./StyledImage");
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = require("./propTypes");
|
|
11
11
|
|
|
12
|
-
var _excluded = ["a11yTitle", "fallback", "onError", "opacity", "fill", "src"];
|
|
12
|
+
var _excluded = ["a11yTitle", "fallback", "onError", "onLoad", "opacity", "fill", "src"];
|
|
13
13
|
|
|
14
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
15
|
|
|
@@ -23,6 +23,7 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
23
23
|
var a11yTitle = _ref.a11yTitle,
|
|
24
24
|
fallback = _ref.fallback,
|
|
25
25
|
onError = _ref.onError,
|
|
26
|
+
onLoad = _ref.onLoad,
|
|
26
27
|
opacity = _ref.opacity,
|
|
27
28
|
fill = _ref.fill,
|
|
28
29
|
src = _ref.src,
|
|
@@ -42,7 +43,8 @@ var Image = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
var handleOnLoad = function handleOnLoad() {
|
|
46
|
+
var handleOnLoad = function handleOnLoad(event) {
|
|
47
|
+
if (onLoad) onLoad(event);
|
|
46
48
|
setFallbackInUse(false);
|
|
47
49
|
};
|
|
48
50
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DropProps } from '../Drop';
|
|
3
|
-
import {
|
|
3
|
+
import { ButtonExtendedProps, ButtonType } from '../Button';
|
|
4
4
|
import {
|
|
5
5
|
A11yTitleType,
|
|
6
6
|
AlignSelfType,
|
|
@@ -31,7 +31,7 @@ export interface MenuProps {
|
|
|
31
31
|
dropProps?: DropProps;
|
|
32
32
|
gridArea?: GridAreaType;
|
|
33
33
|
icon?: boolean | React.ReactNode;
|
|
34
|
-
items:
|
|
34
|
+
items: ButtonExtendedProps[] | ButtonExtendedProps[][];
|
|
35
35
|
justifyContent?: JustifyContentType;
|
|
36
36
|
label?: string | React.ReactNode;
|
|
37
37
|
margin?: MarginType;
|
|
@@ -42,8 +42,10 @@ var OptionsBox = _styledComponents["default"].div.withConfig({
|
|
|
42
42
|
var SelectOption = (0, _styledComponents["default"])(_Button.Button).withConfig({
|
|
43
43
|
displayName: "SelectContainer__SelectOption",
|
|
44
44
|
componentId: "sc-1wi0ul8-1"
|
|
45
|
-
})(["", " display:block;width:100%;"], function (props) {
|
|
45
|
+
})(["", " ", " display:block;width:100%;"], function (props) {
|
|
46
46
|
return props.selected && props.textComponent && _utils.selectedStyle;
|
|
47
|
+
}, function (props) {
|
|
48
|
+
return props.active && (0, _utils.getHoverIndicatorStyle)(!props.children && !props.theme.select.options ? undefined : 'background', props.theme);
|
|
47
49
|
});
|
|
48
50
|
var ClearButton = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
49
51
|
var clear = _ref.clear,
|
|
@@ -96,28 +98,24 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
96
98
|
|
|
97
99
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _defaultProps.defaultProps.theme;
|
|
98
100
|
|
|
99
|
-
var _useState = (0, _react.useState)(-1),
|
|
101
|
+
var _useState = (0, _react.useState)(usingKeyboard ? 0 : -1),
|
|
100
102
|
activeIndex = _useState[0],
|
|
101
103
|
setActiveIndex = _useState[1];
|
|
102
104
|
|
|
103
|
-
var _useState2 = (0, _react.useState)(),
|
|
105
|
+
var _useState2 = (0, _react.useState)(usingKeyboard),
|
|
104
106
|
keyboardNavigation = _useState2[0],
|
|
105
107
|
setKeyboardNavigation = _useState2[1];
|
|
106
108
|
|
|
107
109
|
var searchRef = (0, _react.useRef)();
|
|
108
110
|
var optionsRef = (0, _react.useRef)();
|
|
109
111
|
var clearRef = (0, _react.useRef)();
|
|
112
|
+
var activeRef = (0, _react.useRef)(); // for keyboard/screenreader, keep the active option in focus
|
|
113
|
+
|
|
110
114
|
(0, _react.useEffect)(function () {
|
|
111
|
-
var
|
|
115
|
+
var _activeRef$current;
|
|
112
116
|
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
var index = activeIndex;
|
|
116
|
-
if (clear && clear.position !== 'bottom' && clearButton) index += 1;
|
|
117
|
-
var optionNode = optionsNode.children[index];
|
|
118
|
-
if (optionNode) optionNode.focus();
|
|
119
|
-
}
|
|
120
|
-
}, [activeIndex, clear]); // set initial focus
|
|
117
|
+
if (activeIndex) (_activeRef$current = activeRef.current) == null ? void 0 : _activeRef$current.focus();
|
|
118
|
+
}, [activeIndex]); // set initial focus
|
|
121
119
|
|
|
122
120
|
(0, _react.useEffect)(function () {
|
|
123
121
|
// need to wait for Drop to be ready
|
|
@@ -133,11 +131,8 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
133
131
|
}
|
|
134
132
|
} else if (clear && clearButton && clearButton.focus && clear.position !== 'bottom') {
|
|
135
133
|
(0, _utils.setFocusWithoutScroll)(clearButton);
|
|
136
|
-
} else if (
|
|
137
|
-
|
|
138
|
-
// first child as the active index when the drop opens
|
|
139
|
-
(0, _utils.setFocusWithoutScroll)(optionsNode.children[0]);
|
|
140
|
-
setActiveIndex(0);
|
|
134
|
+
} else if (usingKeyboard && activeRef.current) {
|
|
135
|
+
(0, _utils.setFocusWithoutScroll)(activeRef.current);
|
|
141
136
|
} else if (optionsNode) {
|
|
142
137
|
(0, _utils.setFocusWithoutScroll)(optionsNode);
|
|
143
138
|
}
|
|
@@ -145,21 +140,7 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
145
140
|
return function () {
|
|
146
141
|
return clearTimeout(timer);
|
|
147
142
|
};
|
|
148
|
-
}, [onSearch, usingKeyboard, clear]);
|
|
149
|
-
|
|
150
|
-
(0, _react.useEffect)(function () {
|
|
151
|
-
if (keyboardNavigation) {
|
|
152
|
-
// 100ms was empirically determined
|
|
153
|
-
var timer = setTimeout(function () {
|
|
154
|
-
return setKeyboardNavigation(false);
|
|
155
|
-
}, 100);
|
|
156
|
-
return function () {
|
|
157
|
-
return clearTimeout(timer);
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return undefined;
|
|
162
|
-
}, [keyboardNavigation]);
|
|
143
|
+
}, [onSearch, usingKeyboard, clear]);
|
|
163
144
|
var optionLabel = (0, _react.useCallback)(function (index) {
|
|
164
145
|
return (0, _utils2.applyKey)(options[index], labelKey);
|
|
165
146
|
}, [labelKey, options]);
|
|
@@ -378,7 +359,10 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
378
359
|
role: "listbox",
|
|
379
360
|
tabIndex: "-1",
|
|
380
361
|
ref: optionsRef,
|
|
381
|
-
"aria-multiselectable": multiple
|
|
362
|
+
"aria-multiselectable": multiple,
|
|
363
|
+
onMouseMove: function onMouseMove() {
|
|
364
|
+
return setKeyboardNavigation(false);
|
|
365
|
+
}
|
|
382
366
|
}, shouldShowClearButton('top') && /*#__PURE__*/_react["default"].createElement(ClearButton, {
|
|
383
367
|
ref: clearRef,
|
|
384
368
|
clear: clear,
|
|
@@ -415,8 +399,13 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
415
399
|
|
|
416
400
|
return /*#__PURE__*/_react["default"].createElement(SelectOption // eslint-disable-next-line react/no-array-index-key
|
|
417
401
|
, {
|
|
418
|
-
key: index
|
|
419
|
-
|
|
402
|
+
key: index // merge optionRef and activeRef
|
|
403
|
+
,
|
|
404
|
+
ref: function ref(node) {
|
|
405
|
+
// eslint-disable-next-line no-param-reassign
|
|
406
|
+
if (optionRef) optionRef.current = node;
|
|
407
|
+
if (optionActive) activeRef.current = node;
|
|
408
|
+
},
|
|
420
409
|
tabIndex: optionSelected ? '0' : '-1',
|
|
421
410
|
role: "option",
|
|
422
411
|
"aria-setsize": options.length,
|
|
@@ -427,7 +416,6 @@ var SelectContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref)
|
|
|
427
416
|
plain: !child ? undefined : true,
|
|
428
417
|
align: "start",
|
|
429
418
|
kind: !child ? 'option' : undefined,
|
|
430
|
-
hoverIndicator: !child ? undefined : 'background',
|
|
431
419
|
label: !child ? optionLabel(index) : undefined,
|
|
432
420
|
disabled: optionDisabled || undefined,
|
|
433
421
|
active: optionActive,
|
package/components/Tabs/Tabs.js
CHANGED
|
@@ -318,6 +318,7 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
318
318
|
}, rest, {
|
|
319
319
|
background: theme.tabs.background
|
|
320
320
|
}), /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
|
|
321
|
+
flex: false,
|
|
321
322
|
direction: overflow ? 'row' : 'column'
|
|
322
323
|
}, tabsHeaderStyles), overflow && /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
323
324
|
a11yTitle: "Previous Tab",
|
|
@@ -338,7 +339,7 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
338
339
|
ref: headerRef,
|
|
339
340
|
as: _Box.Box,
|
|
340
341
|
direction: "row",
|
|
341
|
-
justify: justify,
|
|
342
|
+
justify: overflow ? 'start' : justify,
|
|
342
343
|
alignSelf: alignControls,
|
|
343
344
|
flex: !!overflow,
|
|
344
345
|
wrap: false,
|
|
@@ -70,9 +70,9 @@ var headStyle = (0, _styledComponents.css)(["::after{content:'';height:100%;widt
|
|
|
70
70
|
var StyledVideoScrubber = _styledComponents["default"].div.withConfig({
|
|
71
71
|
displayName: "StyledVideo__StyledVideoScrubber",
|
|
72
72
|
componentId: "sc-w4v8h9-3"
|
|
73
|
-
})(["cursor:pointer;width:100%;height:100%;", "
|
|
73
|
+
})(["cursor:pointer;width:100%;height:100%;", ";&:focus{", "}"], function (props) {
|
|
74
74
|
return props.value && headStyle;
|
|
75
|
-
});
|
|
75
|
+
}, (0, _utils.focusStyle)());
|
|
76
76
|
|
|
77
77
|
exports.StyledVideoScrubber = StyledVideoScrubber;
|
|
78
78
|
StyledVideoScrubber.defaultProps = {};
|