grommet 2.25.1 → 2.25.2
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 +82 -9
- package/components/Button/StyledButtonKind.js +9 -3
- package/components/Button/index.d.ts +1 -1
- package/components/Button/propTypes.js +1 -1
- package/components/DataChart/DataChart.js +11 -13
- package/components/DataChart/XAxis.js +29 -18
- 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/Form/Form.js +72 -4
- package/components/FormField/FormField.js +4 -1
- 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/Layer/LayerContainer.js +18 -0
- package/components/Menu/Menu.js +7 -4
- 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 +77 -44
- 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 +9 -1
- 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 +14 -2
- 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/DataChart/DataChart.js +11 -13
- package/es6/components/DataChart/XAxis.js +29 -19
- 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/Form/Form.js +70 -4
- package/es6/components/FormField/FormField.js +4 -1
- 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/Layer/LayerContainer.js +17 -0
- package/es6/components/Menu/Menu.js +7 -4
- 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 +76 -45
- 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 +8 -1
- 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 +40 -8
- package/es6/themes/base.js +43 -0
- package/es6/utils/mixins.js +3 -0
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/package.json +36 -30
- package/themes/base.d.ts +40 -8
- package/themes/base.js +43 -0
- package/tools/pack.js +20 -13
- package/tools/release-stable.js +2 -4
- 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
|
//
|
|
@@ -529,9 +575,16 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
529
575
|
};
|
|
530
576
|
}, [onChange, pendingValidation, touched, validateOn, validationResults.errors, validationResults.infos, value, valueProp]);
|
|
531
577
|
return /*#__PURE__*/_react["default"].createElement("form", _extends({
|
|
532
|
-
ref:
|
|
578
|
+
ref: formRef
|
|
533
579
|
}, rest, {
|
|
534
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
|
+
});
|
|
535
588
|
setPendingValidation(undefined);
|
|
536
589
|
|
|
537
590
|
if (!valueProp) {
|
|
@@ -543,6 +596,10 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
543
596
|
|
|
544
597
|
setTouched(defaultTouched);
|
|
545
598
|
setValidationResults(defaultValidationResults);
|
|
599
|
+
analyticsRef.current = {
|
|
600
|
+
start: new Date(),
|
|
601
|
+
errors: {}
|
|
602
|
+
};
|
|
546
603
|
|
|
547
604
|
if (_onReset) {
|
|
548
605
|
event.persist(); // extract from React's synthetic event pool
|
|
@@ -573,6 +630,7 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
573
630
|
};
|
|
574
631
|
if (onValidate) onValidate(nextValidationResults);
|
|
575
632
|
validationResultsRef.current = nextValidationResults;
|
|
633
|
+
updateAnalytics();
|
|
576
634
|
return nextValidationResults;
|
|
577
635
|
});
|
|
578
636
|
|
|
@@ -584,6 +642,16 @@ var Form = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
|
|
|
584
642
|
adjustedEvent.touched = touched;
|
|
585
643
|
|
|
586
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;
|
|
587
655
|
}
|
|
588
656
|
}
|
|
589
657
|
}), /*#__PURE__*/_react["default"].createElement(_FormContext.FormContext.Provider, {
|
|
@@ -230,9 +230,12 @@ var FormField = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
if (child && child.type && grommetInputNames.indexOf(child.type.displayName) !== -1 && child.props.plain === undefined && child.props.focusIndicator === undefined) {
|
|
233
|
+
var _formFieldTheme$check;
|
|
234
|
+
|
|
233
235
|
return /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
234
236
|
plain: true,
|
|
235
|
-
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
|
|
236
239
|
});
|
|
237
240
|
}
|
|
238
241
|
|
|
@@ -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
|
|
|
@@ -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,22 @@ 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
|
+
sendAnalytics({
|
|
89
|
+
type: 'layerOpen',
|
|
90
|
+
element: element
|
|
91
|
+
});
|
|
92
|
+
return function () {
|
|
93
|
+
sendAnalytics({
|
|
94
|
+
type: 'layerClose',
|
|
95
|
+
element: element,
|
|
96
|
+
elapsed: new Date().getTime() - start.getTime()
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}, [sendAnalytics, layerRef]);
|
|
82
100
|
(0, _react.useEffect)(function () {
|
|
83
101
|
if (position !== 'hidden') {
|
|
84
102
|
var node = layerRef.current || containerRef.current || ref.current;
|
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,
|
|
@@ -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
|
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
GridAreaType,
|
|
6
6
|
MarginType,
|
|
7
7
|
} from '../../utils';
|
|
8
|
+
import { BoxProps } from '../Box/index';
|
|
8
9
|
|
|
9
10
|
import { GridProps } from '../Grid';
|
|
10
11
|
export interface PageHeaderProps {
|
|
@@ -16,11 +17,19 @@ export interface PageHeaderProps {
|
|
|
16
17
|
gridProps?: GridProps;
|
|
17
18
|
parent?: JSX.Element;
|
|
18
19
|
responsive?: boolean;
|
|
20
|
+
size?: 'small' | 'medium' | 'large';
|
|
19
21
|
subtitle?: string | JSX.Element;
|
|
20
22
|
title?: string | JSX.Element;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
type divProps = Omit<JSX.IntrinsicElements['div'], 'onClick' | 'title'>;
|
|
26
|
+
|
|
27
|
+
export interface PageHeaderExtendedProps
|
|
28
|
+
extends BoxProps,
|
|
29
|
+
PageHeaderProps,
|
|
30
|
+
divProps {}
|
|
31
|
+
|
|
32
|
+
declare const PageHeader: React.FC<PageHeaderExtendedProps>;
|
|
24
33
|
export type PageHeaderType = PageHeaderProps;
|
|
25
34
|
|
|
26
35
|
export { PageHeader };
|
|
@@ -21,6 +21,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
21
21
|
gridProps: _propTypes2.GridPropTypes,
|
|
22
22
|
parent: _propTypes["default"].element,
|
|
23
23
|
responsive: _propTypes["default"].bool,
|
|
24
|
+
size: _propTypes["default"].oneOf(['small', 'medium', 'large']),
|
|
24
25
|
subtitle: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
|
|
25
26
|
title: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element])
|
|
26
27
|
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Size = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
|
|
8
|
+
var _grommet = require("grommet");
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
var Size = function Size() {
|
|
13
|
+
return (
|
|
14
|
+
/*#__PURE__*/
|
|
15
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
16
|
+
// <Grommet theme={...}>
|
|
17
|
+
_react["default"].createElement(_grommet.Page, null, /*#__PURE__*/_react["default"].createElement(_grommet.PageContent, null, /*#__PURE__*/_react["default"].createElement(_grommet.PageHeader, {
|
|
18
|
+
title: "Small PageHeader",
|
|
19
|
+
subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
|
|
20
|
+
actions: /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
|
|
21
|
+
label: "Page-level action"
|
|
22
|
+
}),
|
|
23
|
+
parent: /*#__PURE__*/_react["default"].createElement(_grommet.Anchor, {
|
|
24
|
+
label: "Parent Page"
|
|
25
|
+
}),
|
|
26
|
+
size: "small"
|
|
27
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.PageHeader, {
|
|
28
|
+
title: "Medium PageHeader (default)",
|
|
29
|
+
subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
|
|
30
|
+
actions: /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
|
|
31
|
+
label: "Page-level action"
|
|
32
|
+
}),
|
|
33
|
+
parent: /*#__PURE__*/_react["default"].createElement(_grommet.Anchor, {
|
|
34
|
+
label: "Parent Page"
|
|
35
|
+
})
|
|
36
|
+
}), /*#__PURE__*/_react["default"].createElement(_grommet.PageHeader, {
|
|
37
|
+
title: "Large PageHeader",
|
|
38
|
+
subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
|
|
39
|
+
actions: /*#__PURE__*/_react["default"].createElement(_grommet.Button, {
|
|
40
|
+
label: "Page-level action"
|
|
41
|
+
}),
|
|
42
|
+
parent: /*#__PURE__*/_react["default"].createElement(_grommet.Anchor, {
|
|
43
|
+
label: "Parent Page"
|
|
44
|
+
}),
|
|
45
|
+
size: "large"
|
|
46
|
+
}))) // </Grommet>
|
|
47
|
+
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.Size = Size;
|
|
52
|
+
var _default = {
|
|
53
|
+
title: 'Layout/PageHeader/Size'
|
|
54
|
+
};
|
|
55
|
+
exports["default"] = _default;
|