grommet 2.25.0 → 2.25.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/components/Anchor/Anchor.js +14 -1
- package/components/Button/Button.js +81 -8
- package/components/Button/StyledButtonKind.js +9 -3
- package/components/Button/index.d.ts +1 -1
- package/components/Button/propTypes.js +1 -1
- 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 +14 -28
- package/components/DataChart/Detail.js +18 -11
- package/components/DataChart/XAxis.js +29 -18
- package/components/DataChart/stories/Pad.js +54 -0
- package/components/DataTable/DataTable.js +13 -9
- package/components/DataTable/buildState.js +2 -2
- package/components/DataTable/index.d.ts +4 -1
- package/components/DataTable/stories/SpaceX.js +3 -1
- package/components/DataTable/stories/SpaceXUngrouped.js +6 -2
- 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 +78 -5
- package/components/FormField/FormField.js +29 -29
- package/components/Grommet/Grommet.js +7 -2
- package/components/Grommet/index.d.ts +1 -0
- package/components/Grommet/propTypes.js +2 -1
- package/components/Heading/Heading.js +4 -2
- package/components/Heading/StyledHeading.js +1 -1
- package/components/Heading/index.d.ts +1 -0
- package/components/Heading/propTypes.js +2 -1
- package/components/Image/Image.js +4 -2
- package/components/Layer/LayerContainer.js +25 -0
- package/components/List/List.js +17 -0
- package/components/Menu/Menu.js +7 -4
- package/components/Menu/index.d.ts +2 -2
- package/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
- package/components/Meter/Circle.js +5 -1
- package/components/PageHeader/PageHeader.js +22 -13
- package/components/PageHeader/index.d.ts +10 -1
- package/components/PageHeader/propTypes.js +1 -0
- package/components/PageHeader/stories/Size.js +55 -0
- package/components/Select/SelectContainer.js +96 -75
- package/components/Select/stories/Clear.js +7 -1
- package/components/Select/utils.js +1 -0
- package/components/Spinner/Spinner.js +1 -0
- package/components/Tab/Tab.js +1 -1
- package/components/Tabs/Tabs.js +11 -2
- package/components/Video/StyledVideo.js +2 -2
- package/contexts/AnalyticsContext/AnalyticsContext.js +65 -0
- package/contexts/AnalyticsContext/index.d.ts +7 -0
- package/contexts/AnalyticsContext/index.js +11 -0
- package/contexts/index.js +8 -0
- package/es6/components/Anchor/Anchor.js +15 -3
- package/es6/components/Button/Button.js +83 -11
- package/es6/components/Button/StyledButtonKind.js +9 -3
- package/es6/components/Button/index.d.ts +1 -1
- package/es6/components/Button/propTypes.js +1 -1
- 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 +15 -28
- package/es6/components/DataChart/Detail.js +20 -10
- package/es6/components/DataChart/XAxis.js +29 -19
- package/es6/components/DataChart/stories/Pad.js +42 -0
- package/es6/components/DataTable/DataTable.js +13 -9
- package/es6/components/DataTable/buildState.js +2 -2
- package/es6/components/DataTable/index.d.ts +4 -1
- package/es6/components/DataTable/stories/SpaceX.js +3 -1
- package/es6/components/DataTable/stories/SpaceXUngrouped.js +6 -2
- 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 +76 -5
- package/es6/components/FormField/FormField.js +29 -30
- package/es6/components/Grommet/Grommet.js +6 -2
- package/es6/components/Grommet/index.d.ts +1 -0
- package/es6/components/Grommet/propTypes.js +2 -1
- package/es6/components/Heading/Heading.js +4 -2
- package/es6/components/Heading/StyledHeading.js +1 -1
- package/es6/components/Heading/index.d.ts +1 -0
- package/es6/components/Heading/propTypes.js +2 -1
- package/es6/components/Image/Image.js +4 -2
- package/es6/components/Layer/LayerContainer.js +24 -0
- package/es6/components/List/List.js +16 -0
- package/es6/components/Menu/Menu.js +7 -4
- package/es6/components/Menu/index.d.ts +2 -2
- package/es6/components/Menu/stories/CustomThemed/Themed.tsx +6 -0
- package/es6/components/Meter/Circle.js +5 -1
- package/es6/components/PageHeader/PageHeader.js +24 -14
- package/es6/components/PageHeader/index.d.ts +10 -1
- package/es6/components/PageHeader/propTypes.js +1 -0
- package/es6/components/PageHeader/stories/Size.js +43 -0
- package/es6/components/Select/SelectContainer.js +96 -77
- package/es6/components/Select/stories/Clear.js +7 -1
- package/es6/components/Select/utils.js +1 -0
- package/es6/components/Spinner/Spinner.js +1 -0
- package/es6/components/Tab/Tab.js +1 -1
- package/es6/components/Tabs/Tabs.js +10 -2
- package/es6/components/Video/StyledVideo.js +2 -2
- package/es6/contexts/AnalyticsContext/AnalyticsContext.js +47 -0
- package/es6/contexts/AnalyticsContext/index.d.ts +7 -0
- package/es6/contexts/AnalyticsContext/index.js +1 -0
- package/es6/contexts/index.js +1 -0
- package/es6/themes/base.d.ts +51 -33
- package/es6/themes/base.js +49 -1
- package/es6/utils/DOM.js +4 -0
- package/es6/utils/mixins.js +3 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +56 -48
- package/themes/base.d.ts +51 -33
- package/themes/base.js +49 -1
- package/tools/pack.js +20 -13
- package/tools/release-stable.js +2 -4
- package/utils/DOM.js +9 -2
- package/utils/mixins.js +7 -1
package/components/Form/Form.js
CHANGED
|
@@ -5,8 +5,12 @@ exports.Form = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
+
var _contexts = require("../../contexts");
|
|
9
|
+
|
|
8
10
|
var _MessageContext = require("../../contexts/MessageContext");
|
|
9
11
|
|
|
12
|
+
var _utils = require("../../utils");
|
|
13
|
+
|
|
10
14
|
var _FormContext = require("./FormContext");
|
|
11
15
|
|
|
12
16
|
var _propTypes = require("./propTypes");
|
|
@@ -195,6 +199,8 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
195
199
|
valueProp = _ref2.value,
|
|
196
200
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
197
201
|
|
|
202
|
+
var formRef = (0, _utils.useForwardedRef)(ref);
|
|
203
|
+
|
|
198
204
|
var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
|
|
199
205
|
format = _useContext.format;
|
|
200
206
|
|
|
@@ -238,6 +244,11 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
238
244
|
|
|
239
245
|
var validationRulesRef = (0, _react.useRef)({});
|
|
240
246
|
var requiredFields = (0, _react.useRef)([]);
|
|
247
|
+
var analyticsRef = (0, _react.useRef)({
|
|
248
|
+
start: new Date(),
|
|
249
|
+
errors: {}
|
|
250
|
+
});
|
|
251
|
+
var sendAnalytics = (0, _contexts.useAnalytics)();
|
|
241
252
|
var buildValid = (0, _react.useCallback)(function (nextErrors) {
|
|
242
253
|
var valid = false;
|
|
243
254
|
valid = requiredFields.current.filter(function (n) {
|
|
@@ -260,6 +271,19 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
260
271
|
});
|
|
261
272
|
};
|
|
262
273
|
|
|
274
|
+
var updateAnalytics = function updateAnalytics() {
|
|
275
|
+
var _validationResultsRef;
|
|
276
|
+
|
|
277
|
+
var errorFields = Object.keys((_validationResultsRef = validationResultsRef.current) == null ? void 0 : _validationResultsRef.errors);
|
|
278
|
+
var errorCounts = analyticsRef.current.errors;
|
|
279
|
+
|
|
280
|
+
if (errorFields.length > 0) {
|
|
281
|
+
errorFields.forEach(function (key) {
|
|
282
|
+
errorCounts[key] = (errorCounts[key] || 0) + 1;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
263
287
|
var applyValidationRules = (0, _react.useCallback)(function (validationRules) {
|
|
264
288
|
var _validateForm = validateForm(validationRules, value, format, messages),
|
|
265
289
|
validatedErrors = _validateForm[0],
|
|
@@ -284,6 +308,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
284
308
|
valid: buildValid(nextErrors)
|
|
285
309
|
}));
|
|
286
310
|
validationResultsRef.current = nextValidationResults;
|
|
311
|
+
updateAnalytics();
|
|
287
312
|
return nextValidationResults;
|
|
288
313
|
});
|
|
289
314
|
}, [buildValid, format, messages, onValidate, value]); // Validate all fields holding values onMount if set to
|
|
@@ -331,17 +356,38 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
331
356
|
// as the user fixes them (basically act like validate=change for that)
|
|
332
357
|
|
|
333
358
|
(0, _react.useEffect)(function () {
|
|
334
|
-
var
|
|
359
|
+
var _validationResultsRef2;
|
|
335
360
|
|
|
336
361
|
var validationRules = Object.entries(validationRulesRef.current);
|
|
337
362
|
|
|
338
|
-
if ((
|
|
363
|
+
if ((_validationResultsRef2 = validationResultsRef.current) != null && _validationResultsRef2.errors && Object.keys(validationResultsRef.current.errors).length > 0) {
|
|
339
364
|
applyValidationRules(validationRules.filter(function (_ref6) {
|
|
340
365
|
var n = _ref6[0];
|
|
341
366
|
return touched[n] && validationResultsRef.current.errors[n];
|
|
342
367
|
}));
|
|
343
368
|
}
|
|
344
|
-
}, [applyValidationRules, touched]);
|
|
369
|
+
}, [applyValidationRules, touched]);
|
|
370
|
+
(0, _react.useEffect)(function () {
|
|
371
|
+
var element = formRef.current;
|
|
372
|
+
analyticsRef.current = {
|
|
373
|
+
start: new Date(),
|
|
374
|
+
errors: {}
|
|
375
|
+
};
|
|
376
|
+
sendAnalytics({
|
|
377
|
+
type: 'formOpen',
|
|
378
|
+
element: element
|
|
379
|
+
});
|
|
380
|
+
return function () {
|
|
381
|
+
if (!analyticsRef.current.submitted) {
|
|
382
|
+
sendAnalytics({
|
|
383
|
+
type: 'formClose',
|
|
384
|
+
element: element,
|
|
385
|
+
errors: analyticsRef.current.errors,
|
|
386
|
+
elapsed: new Date().getTime() - analyticsRef.current.start.getTime()
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}, [sendAnalytics, formRef]); // There are three basic patterns of handling form input value state:
|
|
345
391
|
//
|
|
346
392
|
// 1 - form controlled
|
|
347
393
|
//
|
|
@@ -499,7 +545,12 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
499
545
|
|
|
500
546
|
validationRulesRef.current[name].field = validateName(validateArg, required);
|
|
501
547
|
return function () {
|
|
502
|
-
|
|
548
|
+
delete validationRulesRef.current[name].field;
|
|
549
|
+
var requiredFieldIndex = requiredFields.current.indexOf(name);
|
|
550
|
+
|
|
551
|
+
if (requiredFieldIndex !== -1) {
|
|
552
|
+
requiredFields.current.splice(requiredFieldIndex, 1);
|
|
553
|
+
}
|
|
503
554
|
};
|
|
504
555
|
}
|
|
505
556
|
|
|
@@ -524,9 +575,16 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
524
575
|
};
|
|
525
576
|
}, [onChange, pendingValidation, touched, validateOn, validationResults.errors, validationResults.infos, value, valueProp]);
|
|
526
577
|
return /*#__PURE__*/_react["default"].createElement("form", _extends({
|
|
527
|
-
ref:
|
|
578
|
+
ref: formRef
|
|
528
579
|
}, rest, {
|
|
529
580
|
onReset: function onReset(event) {
|
|
581
|
+
sendAnalytics({
|
|
582
|
+
type: 'formReset',
|
|
583
|
+
element: formRef.current,
|
|
584
|
+
data: event,
|
|
585
|
+
errors: analyticsRef.current.errors,
|
|
586
|
+
elapsed: new Date().getTime() - analyticsRef.current.start.getTime()
|
|
587
|
+
});
|
|
530
588
|
setPendingValidation(undefined);
|
|
531
589
|
|
|
532
590
|
if (!valueProp) {
|
|
@@ -538,6 +596,10 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
538
596
|
|
|
539
597
|
setTouched(defaultTouched);
|
|
540
598
|
setValidationResults(defaultValidationResults);
|
|
599
|
+
analyticsRef.current = {
|
|
600
|
+
start: new Date(),
|
|
601
|
+
errors: {}
|
|
602
|
+
};
|
|
541
603
|
|
|
542
604
|
if (_onReset) {
|
|
543
605
|
event.persist(); // extract from React's synthetic event pool
|
|
@@ -568,6 +630,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
568
630
|
};
|
|
569
631
|
if (onValidate) onValidate(nextValidationResults);
|
|
570
632
|
validationResultsRef.current = nextValidationResults;
|
|
633
|
+
updateAnalytics();
|
|
571
634
|
return nextValidationResults;
|
|
572
635
|
});
|
|
573
636
|
|
|
@@ -579,6 +642,16 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
579
642
|
adjustedEvent.touched = touched;
|
|
580
643
|
|
|
581
644
|
_onSubmit(adjustedEvent);
|
|
645
|
+
|
|
646
|
+
sendAnalytics({
|
|
647
|
+
type: 'formSubmit',
|
|
648
|
+
element: formRef.current,
|
|
649
|
+
data: adjustedEvent,
|
|
650
|
+
errors: analyticsRef.current.errors,
|
|
651
|
+
elapsed: new Date().getTime() - analyticsRef.current.start.getTime()
|
|
652
|
+
});
|
|
653
|
+
analyticsRef.current.errors = {};
|
|
654
|
+
analyticsRef.current.submitted = true;
|
|
582
655
|
}
|
|
583
656
|
}
|
|
584
657
|
}), /*#__PURE__*/_react["default"].createElement(_FormContext.FormContext.Provider, {
|
|
@@ -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
|
|
|
@@ -227,9 +230,12 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
227
230
|
}
|
|
228
231
|
|
|
229
232
|
if (child && child.type && grommetInputNames.indexOf(child.type.displayName) !== -1 && child.props.plain === undefined && child.props.focusIndicator === undefined) {
|
|
233
|
+
var _formFieldTheme$check;
|
|
234
|
+
|
|
230
235
|
return /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
231
236
|
plain: true,
|
|
232
|
-
focusIndicator: false
|
|
237
|
+
focusIndicator: false,
|
|
238
|
+
pad: 'CheckBox'.indexOf(child.type.displayName) !== -1 ? formFieldTheme == null ? void 0 : (_formFieldTheme$check = formFieldTheme.checkBox) == null ? void 0 : _formFieldTheme$check.pad : undefined
|
|
233
239
|
});
|
|
234
240
|
}
|
|
235
241
|
|
|
@@ -393,17 +399,11 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
393
399
|
onChange: contextOnChange || onChange ? function (event) {
|
|
394
400
|
event.persist();
|
|
395
401
|
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
|
-
}
|
|
402
|
+
if (contextOnChange) debounce(function () {
|
|
403
|
+
return function () {
|
|
404
|
+
return contextOnChange(event);
|
|
405
|
+
};
|
|
406
|
+
});
|
|
407
407
|
} : undefined
|
|
408
408
|
}, 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
409
|
as: "label",
|
|
@@ -25,7 +25,9 @@ var _default = _interopRequireDefault(require("../../languages/default.json"));
|
|
|
25
25
|
|
|
26
26
|
var _propTypes = require("./propTypes");
|
|
27
27
|
|
|
28
|
-
var
|
|
28
|
+
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
29
|
+
|
|
30
|
+
var _excluded = ["children", "full", "containerTarget", "theme", "options", "messages", "onAnalytics"];
|
|
29
31
|
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
33
|
|
|
@@ -74,6 +76,7 @@ var Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
74
76
|
_props$options = props.options,
|
|
75
77
|
options = _props$options === void 0 ? defaultOptions : _props$options,
|
|
76
78
|
messagesProp = props.messages,
|
|
79
|
+
onAnalytics = props.onAnalytics,
|
|
77
80
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
81
|
|
|
79
82
|
var background = props.background,
|
|
@@ -154,11 +157,13 @@ var Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
154
157
|
value: options
|
|
155
158
|
}, /*#__PURE__*/_react["default"].createElement(_MessageContext.MessageContext.Provider, {
|
|
156
159
|
value: messages
|
|
160
|
+
}, /*#__PURE__*/_react["default"].createElement(_AnalyticsContext.AnalyticsProvider, {
|
|
161
|
+
onAnalytics: onAnalytics
|
|
157
162
|
}, /*#__PURE__*/_react["default"].createElement(_StyledGrommet.StyledGrommet, _extends({
|
|
158
163
|
full: full
|
|
159
164
|
}, rest, {
|
|
160
165
|
ref: grommetRef
|
|
161
|
-
}), children), full && /*#__PURE__*/_react["default"].createElement(FullGlobalStyle, null)))))));
|
|
166
|
+
}), children), full && /*#__PURE__*/_react["default"].createElement(FullGlobalStyle, null))))))));
|
|
162
167
|
});
|
|
163
168
|
exports.Grommet = Grommet;
|
|
164
169
|
Grommet.displayName = 'Grommet';
|
|
@@ -9,7 +9,7 @@ var _StyledHeading = require("./StyledHeading");
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = require("./propTypes");
|
|
11
11
|
|
|
12
|
-
var _excluded = ["color", "fill", "level"];
|
|
12
|
+
var _excluded = ["color", "fill", "level", "weight"];
|
|
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
|
|
|
@@ -24,6 +24,7 @@ var Heading = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref // munged
|
|
|
24
24
|
var color = _ref.color,
|
|
25
25
|
fill = _ref.fill,
|
|
26
26
|
level = _ref.level,
|
|
27
|
+
weight = _ref.weight,
|
|
27
28
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
28
29
|
|
|
29
30
|
return (
|
|
@@ -33,7 +34,8 @@ var Heading = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref // munged
|
|
|
33
34
|
as: "h" + level,
|
|
34
35
|
colorProp: color,
|
|
35
36
|
fillProp: fill,
|
|
36
|
-
level: +level
|
|
37
|
+
level: +level,
|
|
38
|
+
weight: weight
|
|
37
39
|
}, rest, {
|
|
38
40
|
ref: ref
|
|
39
41
|
}))
|
|
@@ -21,7 +21,7 @@ var sizeStyle = function sizeStyle(props) {
|
|
|
21
21
|
|
|
22
22
|
if (levelStyle) {
|
|
23
23
|
var data = levelStyle[size];
|
|
24
|
-
var styles = [(0, _styledComponents.css)(["font-size:", ";line-height:", ";max-width:", ";font-weight:", ";"], data ? data.size : size, data ? data.height : 'normal', props.fillProp && 'none' || data && data.maxWidth || levelStyle.medium.maxWidth, levelStyle.font.weight || headingTheme.weight)];
|
|
24
|
+
var styles = [(0, _styledComponents.css)(["font-size:", ";line-height:", ";max-width:", ";font-weight:", ";"], data ? data.size : size, data ? data.height : 'normal', props.fillProp && 'none' || data && data.maxWidth || levelStyle.medium.maxWidth, props.weight || levelStyle.font.weight || headingTheme.weight)];
|
|
25
25
|
|
|
26
26
|
if (props.responsive && headingTheme.responsiveBreakpoint) {
|
|
27
27
|
var breakpoint = props.theme.global.breakpoints[headingTheme.responsiveBreakpoint];
|
|
@@ -21,7 +21,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
21
21
|
responsive: _propTypes["default"].bool,
|
|
22
22
|
size: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['small', 'medium', 'large', 'xlarge']), _propTypes["default"].string]),
|
|
23
23
|
textAlign: _propTypes["default"].oneOf(['start', 'center', 'end', 'justify']),
|
|
24
|
-
truncate: _propTypes["default"].bool
|
|
24
|
+
truncate: _propTypes["default"].bool,
|
|
25
|
+
weight: _propTypes["default"].oneOfType([_propTypes["default"].oneOf(['normal', 'bold', 'lighter', 'bolder']), _propTypes["default"].number, _propTypes["default"].string])
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -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
|
|
|
@@ -19,6 +19,8 @@ var _OptionsContext = require("../../contexts/OptionsContext");
|
|
|
19
19
|
|
|
20
20
|
var _ContainerTargetContext = require("../../contexts/ContainerTargetContext");
|
|
21
21
|
|
|
22
|
+
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
23
|
+
|
|
22
24
|
var _utils = require("../../utils");
|
|
23
25
|
|
|
24
26
|
var _StyledLayer = require("./StyledLayer");
|
|
@@ -79,6 +81,29 @@ var LayerContainer = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
79
81
|
var nextPortalContext = (0, _react.useMemo)(function () {
|
|
80
82
|
return [].concat(portalContext, [portalId]);
|
|
81
83
|
}, [portalContext, portalId]);
|
|
84
|
+
var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
|
|
85
|
+
(0, _react.useEffect)(function () {
|
|
86
|
+
var start = new Date();
|
|
87
|
+
var element = layerRef.current;
|
|
88
|
+
var isHidden = position === 'hidden';
|
|
89
|
+
|
|
90
|
+
if (!isHidden) {
|
|
91
|
+
sendAnalytics({
|
|
92
|
+
type: 'layerOpen',
|
|
93
|
+
element: element
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return function () {
|
|
98
|
+
if (!isHidden) {
|
|
99
|
+
sendAnalytics({
|
|
100
|
+
type: 'layerClose',
|
|
101
|
+
element: element,
|
|
102
|
+
elapsed: new Date().getTime() - start.getTime()
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [sendAnalytics, layerRef, position]);
|
|
82
107
|
(0, _react.useEffect)(function () {
|
|
83
108
|
if (position !== 'hidden') {
|
|
84
109
|
var node = layerRef.current || containerRef.current || ref.current;
|
package/components/List/List.js
CHANGED
|
@@ -21,6 +21,8 @@ var _Text = require("../Text");
|
|
|
21
21
|
|
|
22
22
|
var _utils = require("../../utils");
|
|
23
23
|
|
|
24
|
+
var _AnalyticsContext = require("../../contexts/AnalyticsContext");
|
|
25
|
+
|
|
24
26
|
var _propTypes = require("./propTypes");
|
|
25
27
|
|
|
26
28
|
var _excluded = ["a11yTitle", "aria-label", "action", "as", "background", "border", "children", "data", "defaultItemProps", "disabled", "focus", "itemKey", "itemProps", "onActive", "onClickItem", "onKeyDown", "onMore", "onOrder", "pad", "paginate", "primaryKey", "secondaryKey", "show", "step"];
|
|
@@ -221,6 +223,7 @@ var List = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
221
223
|
setOrderingData = _useState5[1];
|
|
222
224
|
|
|
223
225
|
var draggingRef = (0, _react.useRef)();
|
|
226
|
+
var sendAnalytics = (0, _AnalyticsContext.useAnalytics)();
|
|
224
227
|
var ariaProps = {
|
|
225
228
|
role: onClickItem || onOrder ? 'listbox' : 'list'
|
|
226
229
|
};
|
|
@@ -266,6 +269,13 @@ var List = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
266
269
|
adjustedEvent.item = data[active];
|
|
267
270
|
adjustedEvent.index = active;
|
|
268
271
|
onClickItem(adjustedEvent);
|
|
272
|
+
sendAnalytics({
|
|
273
|
+
type: 'listItemClick',
|
|
274
|
+
element: listRef.current,
|
|
275
|
+
event: adjustedEvent,
|
|
276
|
+
item: data[active],
|
|
277
|
+
index: active
|
|
278
|
+
});
|
|
269
279
|
}
|
|
270
280
|
} : undefined,
|
|
271
281
|
onUp: (onClickItem || onOrder) && active ? function () {
|
|
@@ -420,6 +430,13 @@ var List = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
420
430
|
// accessibility guidelines that focus remains on `ul`
|
|
421
431
|
|
|
422
432
|
listRef.current.focus();
|
|
433
|
+
sendAnalytics({
|
|
434
|
+
type: 'listItemClick',
|
|
435
|
+
element: listRef.current,
|
|
436
|
+
event: adjustedEvent,
|
|
437
|
+
item: item,
|
|
438
|
+
index: index
|
|
439
|
+
});
|
|
423
440
|
}
|
|
424
441
|
},
|
|
425
442
|
onMouseOver: function onMouseOver() {
|
package/components/Menu/Menu.js
CHANGED
|
@@ -304,21 +304,23 @@ var Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
304
304
|
// go to the first menu item instead.
|
|
305
305
|
,
|
|
306
306
|
tabIndex: activeItemIndex === constants.none ? '-1' : undefined
|
|
307
|
-
}, buttonProps), typeof content === 'function' ? function () {
|
|
307
|
+
}, theme.menu.item, buttonProps), typeof content === 'function' ? function () {
|
|
308
308
|
return content(_extends({}, props, {
|
|
309
309
|
drop: true
|
|
310
310
|
}));
|
|
311
311
|
} : content));
|
|
312
312
|
|
|
313
313
|
var menuItem = function menuItem(item, index) {
|
|
314
|
+
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3;
|
|
315
|
+
|
|
314
316
|
// Determine whether the label is done as a child or
|
|
315
317
|
// as an option Button kind property.
|
|
316
318
|
var child = !theme.button.option ? /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
317
319
|
align: "start",
|
|
318
320
|
pad: "small",
|
|
319
321
|
direction: "row",
|
|
320
|
-
gap: item.gap,
|
|
321
|
-
justify: item.justify
|
|
322
|
+
gap: item.gap || ((_theme$menu$item = theme.menu.item) == null ? void 0 : _theme$menu$item.gap),
|
|
323
|
+
justify: item.justify || ((_theme$menu$item2 = theme.menu.item) == null ? void 0 : _theme$menu$item2.justify)
|
|
322
324
|
}, item.reverse && item.label, item.icon, !item.reverse && item.label) : undefined; // if we have a child, turn on plain, and hoverIndicator
|
|
323
325
|
|
|
324
326
|
return (
|
|
@@ -340,9 +342,10 @@ var Menu = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
340
342
|
focusIndicator: false,
|
|
341
343
|
plain: !child ? undefined : true,
|
|
342
344
|
align: "start",
|
|
343
|
-
justify: item.justify,
|
|
344
345
|
kind: !child ? 'option' : undefined,
|
|
345
346
|
hoverIndicator: !child ? undefined : 'background'
|
|
347
|
+
}, theme.menu.item, {
|
|
348
|
+
justify: item.justify || ((_theme$menu$item3 = theme.menu.item) == null ? void 0 : _theme$menu$item3.justify)
|
|
346
349
|
}, !child ? item : _extends({}, item, {
|
|
347
350
|
gap: undefined,
|
|
348
351
|
icon: undefined,
|
|
@@ -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;
|
|
@@ -60,10 +60,16 @@ const customBreakpoints: ThemeType = {
|
|
|
60
60
|
},
|
|
61
61
|
},
|
|
62
62
|
menu: {
|
|
63
|
+
background: 'light-3',
|
|
63
64
|
icons: {
|
|
64
65
|
down: FormDown,
|
|
65
66
|
up: FormUp,
|
|
66
67
|
},
|
|
68
|
+
item: {
|
|
69
|
+
color: 'brand',
|
|
70
|
+
style: { fontFamily: 'Arial', fontWeight: 'bold' },
|
|
71
|
+
},
|
|
72
|
+
extend: `border: 3px solid gray`,
|
|
67
73
|
},
|
|
68
74
|
};
|
|
69
75
|
|
|
@@ -43,8 +43,12 @@ var Circle = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
43
43
|
var centerY = width / 2;
|
|
44
44
|
var radius = width / 2 - strokeWidth / 2; // truncate to avoid floating point arithmetic errors
|
|
45
45
|
// see: https://github.com/grommet/grommet/issues/6190
|
|
46
|
+
// Choose a scale factor at least 3 orders of magnitude above max
|
|
47
|
+
|
|
48
|
+
var scalePower = Math.max(5, Math.ceil(Math.log10(max)) + 3);
|
|
49
|
+
var scale = Math.pow(10, scalePower);
|
|
50
|
+
var anglePer = Math.floor((type === 'semicircle' ? 180 : 360) / max * scale) / scale; // (type === 'semicircle' ? 180 : 360) / max;
|
|
46
51
|
|
|
47
|
-
var anglePer = Math.floor((type === 'semicircle' ? 180 : 360) / max * 10000) / 10000;
|
|
48
52
|
var someHighlight = (values || []).some(function (v) {
|
|
49
53
|
return v.highlight;
|
|
50
54
|
});
|
|
@@ -19,24 +19,33 @@ var _Paragraph = require("../Paragraph");
|
|
|
19
19
|
|
|
20
20
|
var _ResponsiveContext = require("../../contexts/ResponsiveContext");
|
|
21
21
|
|
|
22
|
-
var _excluded = ["actions", "gridProps", "parent", "responsive", "subtitle", "title"];
|
|
22
|
+
var _excluded = ["actions", "gridProps", "parent", "responsive", "size", "subtitle", "title"];
|
|
23
23
|
|
|
24
24
|
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); }
|
|
25
25
|
|
|
26
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
27
|
|
|
28
|
+
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; }
|
|
29
|
+
|
|
28
30
|
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); }
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
var sizeStyle = function sizeStyle(size, feature, theme) {
|
|
33
|
+
var _ref, _theme$pageHeader$siz;
|
|
34
|
+
|
|
35
|
+
var style = _extends({}, theme.pageHeader[feature], (_ref = size && ((_theme$pageHeader$siz = theme.pageHeader.size[size]) == null ? void 0 : _theme$pageHeader$siz[feature])) != null ? _ref : theme.pageHeader[feature]);
|
|
36
|
+
|
|
37
|
+
return style;
|
|
38
|
+
};
|
|
31
39
|
|
|
32
|
-
var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (
|
|
33
|
-
var actions =
|
|
34
|
-
gridPropsProp =
|
|
35
|
-
parent =
|
|
36
|
-
responsive =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
41
|
+
var actions = _ref2.actions,
|
|
42
|
+
gridPropsProp = _ref2.gridProps,
|
|
43
|
+
parent = _ref2.parent,
|
|
44
|
+
responsive = _ref2.responsive,
|
|
45
|
+
size = _ref2.size,
|
|
46
|
+
subtitle = _ref2.subtitle,
|
|
47
|
+
title = _ref2.title,
|
|
48
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
40
49
|
|
|
41
50
|
var theme = (0, _react.useContext)(_styledComponents.ThemeContext);
|
|
42
51
|
var breakpoint = (0, _react.useContext)(_ResponsiveContext.ResponsiveContext);
|
|
@@ -59,7 +68,7 @@ var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
59
68
|
ref: ref,
|
|
60
69
|
direction: "column",
|
|
61
70
|
gap: "none",
|
|
62
|
-
pad: theme
|
|
71
|
+
pad: sizeStyle(size, 'pad', theme)
|
|
63
72
|
}, rest), /*#__PURE__*/_react["default"].createElement(_Grid.Grid, _extends({
|
|
64
73
|
columns: columns,
|
|
65
74
|
rows: rows,
|
|
@@ -70,9 +79,9 @@ var PageHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
70
79
|
gridArea: "parent"
|
|
71
80
|
}, theme.pageHeader.parent), parent), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
72
81
|
gridArea: "title"
|
|
73
|
-
}, typeof title === 'string' ? /*#__PURE__*/_react["default"].createElement(_Heading.Heading,
|
|
82
|
+
}, typeof title === 'string' ? /*#__PURE__*/_react["default"].createElement(_Heading.Heading, sizeStyle(size, 'title', theme), title) : title), /*#__PURE__*/_react["default"].createElement(_Box.Box, {
|
|
74
83
|
gridArea: "subtitle"
|
|
75
|
-
}, typeof subtitle === 'string' ? /*#__PURE__*/_react["default"].createElement(_Paragraph.Paragraph,
|
|
84
|
+
}, typeof subtitle === 'string' ? /*#__PURE__*/_react["default"].createElement(_Paragraph.Paragraph, sizeStyle(size, 'subtitle', theme), subtitle) : subtitle), /*#__PURE__*/_react["default"].createElement(_Box.Box, _extends({
|
|
76
85
|
gridArea: "actions"
|
|
77
86
|
}, actionsProps), actions)));
|
|
78
87
|
});
|