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
|
@@ -6,7 +6,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
6
6
|
|
|
7
7
|
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; }
|
|
8
8
|
|
|
9
|
-
import React, { Children, cloneElement, forwardRef, useContext, useState } from 'react';
|
|
9
|
+
import React, { Children, cloneElement, forwardRef, useContext, useState, useEffect } from 'react';
|
|
10
10
|
import styled, { ThemeContext } from 'styled-components';
|
|
11
11
|
import { defaultProps } from '../../default-props';
|
|
12
12
|
import { containsFocus, shouldKeepFocus } from '../../utils/DOM';
|
|
@@ -129,21 +129,22 @@ var Input = function Input(_ref2) {
|
|
|
129
129
|
}, rest, extraProps));
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
var
|
|
133
|
-
var
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
args[_key] = arguments[_key];
|
|
137
|
-
}
|
|
132
|
+
var useDebounce = function useDebounce() {
|
|
133
|
+
var _useState = useState(),
|
|
134
|
+
func = _useState[0],
|
|
135
|
+
setFunc = _useState[1];
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
var timer;
|
|
140
|
+
if (func) timer = setTimeout(function () {
|
|
141
|
+
return func();
|
|
142
|
+
}, theme.global.debounceDelay);
|
|
143
|
+
return function () {
|
|
144
|
+
return clearTimeout(timer);
|
|
142
145
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
timeout = setTimeout(later, wait);
|
|
146
|
-
};
|
|
146
|
+
}, [func, theme.global.debounceDelay]);
|
|
147
|
+
return setFunc;
|
|
147
148
|
};
|
|
148
149
|
|
|
149
150
|
var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
@@ -185,13 +186,14 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
185
186
|
contextOnBlur = _formContext$useFormF.onBlur,
|
|
186
187
|
contextOnChange = _formContext$useFormF.onChange;
|
|
187
188
|
|
|
188
|
-
var
|
|
189
|
-
focus =
|
|
190
|
-
setFocus =
|
|
189
|
+
var _useState2 = useState(),
|
|
190
|
+
focus = _useState2[0],
|
|
191
|
+
setFocus = _useState2[1];
|
|
191
192
|
|
|
192
193
|
var formFieldRef = useForwardedRef(ref);
|
|
193
194
|
var formFieldTheme = theme.formField;
|
|
194
|
-
var themeBorder = formFieldTheme.border;
|
|
195
|
+
var themeBorder = formFieldTheme.border;
|
|
196
|
+
var debounce = useDebounce(); // This is here for backwards compatibility. In case the child is a grommet
|
|
195
197
|
// input component, set plain and focusIndicator props, if they aren't
|
|
196
198
|
// already set.
|
|
197
199
|
|
|
@@ -202,9 +204,12 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
if (child && child.type && grommetInputNames.indexOf(child.type.displayName) !== -1 && child.props.plain === undefined && child.props.focusIndicator === undefined) {
|
|
207
|
+
var _formFieldTheme$check;
|
|
208
|
+
|
|
205
209
|
return /*#__PURE__*/cloneElement(child, {
|
|
206
210
|
plain: true,
|
|
207
|
-
focusIndicator: false
|
|
211
|
+
focusIndicator: false,
|
|
212
|
+
pad: 'CheckBox'.indexOf(child.type.displayName) !== -1 ? formFieldTheme == null ? void 0 : (_formFieldTheme$check = formFieldTheme.checkBox) == null ? void 0 : _formFieldTheme$check.pad : undefined
|
|
208
213
|
});
|
|
209
214
|
}
|
|
210
215
|
|
|
@@ -368,17 +373,11 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
368
373
|
onChange: contextOnChange || onChange ? function (event) {
|
|
369
374
|
event.persist();
|
|
370
375
|
if (onChange) onChange(event);
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
// field, but capture their attention before they move on
|
|
377
|
-
// past it. 2 second (2000ms) might be too long depending
|
|
378
|
-
// on how fast people type, and 200ms would be an eye blink
|
|
379
|
-
}, 500);
|
|
380
|
-
debouncedFn();
|
|
381
|
-
}
|
|
376
|
+
if (contextOnChange) debounce(function () {
|
|
377
|
+
return function () {
|
|
378
|
+
return contextOnChange(event);
|
|
379
|
+
};
|
|
380
|
+
});
|
|
382
381
|
} : undefined
|
|
383
382
|
}, containerRest), label && component !== CheckBox || help ? /*#__PURE__*/React.createElement(React.Fragment, null, label && component !== CheckBox && /*#__PURE__*/React.createElement(Text, _extends({
|
|
384
383
|
as: "label",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["children", "full", "containerTarget", "theme", "options", "messages"];
|
|
1
|
+
var _excluded = ["children", "full", "containerTarget", "theme", "options", "messages", "onAnalytics"];
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@ import { OptionsContext } from '../../contexts/OptionsContext';
|
|
|
15
15
|
import { format as _format, MessageContext } from '../../contexts/MessageContext';
|
|
16
16
|
import defaultMessages from '../../languages/default.json';
|
|
17
17
|
import { GrommetPropTypes } from './propTypes';
|
|
18
|
+
import { AnalyticsProvider } from '../../contexts/AnalyticsContext';
|
|
18
19
|
var FullGlobalStyle = createGlobalStyle(["body{margin:0;}"]);
|
|
19
20
|
|
|
20
21
|
var deviceResponsive = function deviceResponsive(userAgent, theme) {
|
|
@@ -52,6 +53,7 @@ var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
52
53
|
_props$options = props.options,
|
|
53
54
|
options = _props$options === void 0 ? defaultOptions : _props$options,
|
|
54
55
|
messagesProp = props.messages,
|
|
56
|
+
onAnalytics = props.onAnalytics,
|
|
55
57
|
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
56
58
|
|
|
57
59
|
var background = props.background,
|
|
@@ -132,11 +134,13 @@ var Grommet = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
132
134
|
value: options
|
|
133
135
|
}, /*#__PURE__*/React.createElement(MessageContext.Provider, {
|
|
134
136
|
value: messages
|
|
137
|
+
}, /*#__PURE__*/React.createElement(AnalyticsProvider, {
|
|
138
|
+
onAnalytics: onAnalytics
|
|
135
139
|
}, /*#__PURE__*/React.createElement(StyledGrommet, _extends({
|
|
136
140
|
full: full
|
|
137
141
|
}, rest, {
|
|
138
142
|
ref: grommetRef
|
|
139
|
-
}), children), full && /*#__PURE__*/React.createElement(FullGlobalStyle, null)))))));
|
|
143
|
+
}), children), full && /*#__PURE__*/React.createElement(FullGlobalStyle, null))))))));
|
|
140
144
|
});
|
|
141
145
|
Grommet.displayName = 'Grommet';
|
|
142
146
|
Grommet.propTypes = GrommetPropTypes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["color", "fill", "level"];
|
|
1
|
+
var _excluded = ["color", "fill", "level", "weight"];
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
@@ -12,6 +12,7 @@ var Heading = /*#__PURE__*/forwardRef(function (_ref, ref // munged to avoid sty
|
|
|
12
12
|
var color = _ref.color,
|
|
13
13
|
fill = _ref.fill,
|
|
14
14
|
level = _ref.level,
|
|
15
|
+
weight = _ref.weight,
|
|
15
16
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
16
17
|
|
|
17
18
|
return (
|
|
@@ -21,7 +22,8 @@ var Heading = /*#__PURE__*/forwardRef(function (_ref, ref // munged to avoid sty
|
|
|
21
22
|
as: "h" + level,
|
|
22
23
|
colorProp: color,
|
|
23
24
|
fillProp: fill,
|
|
24
|
-
level: +level
|
|
25
|
+
level: +level,
|
|
26
|
+
weight: weight
|
|
25
27
|
}, rest, {
|
|
26
28
|
ref: ref
|
|
27
29
|
}))
|
|
@@ -10,7 +10,7 @@ var sizeStyle = function sizeStyle(props) {
|
|
|
10
10
|
|
|
11
11
|
if (levelStyle) {
|
|
12
12
|
var data = levelStyle[size];
|
|
13
|
-
var styles = [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)];
|
|
13
|
+
var styles = [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)];
|
|
14
14
|
|
|
15
15
|
if (props.responsive && headingTheme.responsiveBreakpoint) {
|
|
16
16
|
var breakpoint = props.theme.global.breakpoints[headingTheme.responsiveBreakpoint];
|
|
@@ -12,7 +12,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
12
12
|
responsive: PropTypes.bool,
|
|
13
13
|
size: PropTypes.oneOfType([PropTypes.oneOf(['small', 'medium', 'large', 'xlarge']), PropTypes.string]),
|
|
14
14
|
textAlign: PropTypes.oneOf(['start', 'center', 'end', 'justify']),
|
|
15
|
-
truncate: PropTypes.bool
|
|
15
|
+
truncate: PropTypes.bool,
|
|
16
|
+
weight: PropTypes.oneOfType([PropTypes.oneOf(['normal', 'bold', 'lighter', 'bolder']), PropTypes.number, PropTypes.string])
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["a11yTitle", "fallback", "onError", "opacity", "fill", "src"];
|
|
1
|
+
var _excluded = ["a11yTitle", "fallback", "onError", "onLoad", "opacity", "fill", "src"];
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ var Image = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
11
11
|
var a11yTitle = _ref.a11yTitle,
|
|
12
12
|
fallback = _ref.fallback,
|
|
13
13
|
onError = _ref.onError,
|
|
14
|
+
onLoad = _ref.onLoad,
|
|
14
15
|
opacity = _ref.opacity,
|
|
15
16
|
fill = _ref.fill,
|
|
16
17
|
src = _ref.src,
|
|
@@ -30,7 +31,8 @@ var Image = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
var handleOnLoad = function handleOnLoad() {
|
|
34
|
+
var handleOnLoad = function handleOnLoad(event) {
|
|
35
|
+
if (onLoad) onLoad(event);
|
|
34
36
|
setFallbackInUse(false);
|
|
35
37
|
};
|
|
36
38
|
|
|
@@ -12,6 +12,7 @@ import { Keyboard } from '../Keyboard';
|
|
|
12
12
|
import { ResponsiveContext } from '../../contexts/ResponsiveContext';
|
|
13
13
|
import { OptionsContext } from '../../contexts/OptionsContext';
|
|
14
14
|
import { ContainerTargetContext } from '../../contexts/ContainerTargetContext';
|
|
15
|
+
import { useAnalytics } from '../../contexts/AnalyticsContext';
|
|
15
16
|
import { backgroundIsDark, findVisibleParent, PortalContext } from '../../utils';
|
|
16
17
|
import { StyledLayer, StyledContainer, StyledOverlay } from './StyledLayer';
|
|
17
18
|
var HiddenAnchor = styled.a.withConfig({
|
|
@@ -57,6 +58,29 @@ var LayerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
57
58
|
var nextPortalContext = useMemo(function () {
|
|
58
59
|
return [].concat(portalContext, [portalId]);
|
|
59
60
|
}, [portalContext, portalId]);
|
|
61
|
+
var sendAnalytics = useAnalytics();
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var start = new Date();
|
|
64
|
+
var element = layerRef.current;
|
|
65
|
+
var isHidden = position === 'hidden';
|
|
66
|
+
|
|
67
|
+
if (!isHidden) {
|
|
68
|
+
sendAnalytics({
|
|
69
|
+
type: 'layerOpen',
|
|
70
|
+
element: element
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return function () {
|
|
75
|
+
if (!isHidden) {
|
|
76
|
+
sendAnalytics({
|
|
77
|
+
type: 'layerClose',
|
|
78
|
+
element: element,
|
|
79
|
+
elapsed: new Date().getTime() - start.getTime()
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}, [sendAnalytics, layerRef, position]);
|
|
60
84
|
useEffect(function () {
|
|
61
85
|
if (position !== 'hidden') {
|
|
62
86
|
var node = layerRef.current || containerRef.current || ref.current;
|
|
@@ -13,6 +13,7 @@ import { Keyboard } from '../Keyboard';
|
|
|
13
13
|
import { Pagination } from '../Pagination';
|
|
14
14
|
import { Text } from '../Text';
|
|
15
15
|
import { focusStyle, genericStyles, normalizeColor, normalizeShow, unfocusStyle, useForwardedRef, usePagination } from '../../utils';
|
|
16
|
+
import { useAnalytics } from '../../contexts/AnalyticsContext';
|
|
16
17
|
import { ListPropTypes } from './propTypes';
|
|
17
18
|
var StyledList = styled.ul.withConfig({
|
|
18
19
|
displayName: "List__StyledList",
|
|
@@ -201,6 +202,7 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
201
202
|
setOrderingData = _useState5[1];
|
|
202
203
|
|
|
203
204
|
var draggingRef = useRef();
|
|
205
|
+
var sendAnalytics = useAnalytics();
|
|
204
206
|
var ariaProps = {
|
|
205
207
|
role: onClickItem || onOrder ? 'listbox' : 'list'
|
|
206
208
|
};
|
|
@@ -246,6 +248,13 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
246
248
|
adjustedEvent.item = data[active];
|
|
247
249
|
adjustedEvent.index = active;
|
|
248
250
|
onClickItem(adjustedEvent);
|
|
251
|
+
sendAnalytics({
|
|
252
|
+
type: 'listItemClick',
|
|
253
|
+
element: listRef.current,
|
|
254
|
+
event: adjustedEvent,
|
|
255
|
+
item: data[active],
|
|
256
|
+
index: active
|
|
257
|
+
});
|
|
249
258
|
}
|
|
250
259
|
} : undefined,
|
|
251
260
|
onUp: (onClickItem || onOrder) && active ? function () {
|
|
@@ -400,6 +409,13 @@ var List = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
400
409
|
// accessibility guidelines that focus remains on `ul`
|
|
401
410
|
|
|
402
411
|
listRef.current.focus();
|
|
412
|
+
sendAnalytics({
|
|
413
|
+
type: 'listItemClick',
|
|
414
|
+
element: listRef.current,
|
|
415
|
+
event: adjustedEvent,
|
|
416
|
+
item: item,
|
|
417
|
+
index: index
|
|
418
|
+
});
|
|
403
419
|
}
|
|
404
420
|
},
|
|
405
421
|
onMouseOver: function onMouseOver() {
|
|
@@ -284,21 +284,23 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
284
284
|
// go to the first menu item instead.
|
|
285
285
|
,
|
|
286
286
|
tabIndex: activeItemIndex === constants.none ? '-1' : undefined
|
|
287
|
-
}, buttonProps), typeof content === 'function' ? function () {
|
|
287
|
+
}, theme.menu.item, buttonProps), typeof content === 'function' ? function () {
|
|
288
288
|
return content(_extends({}, props, {
|
|
289
289
|
drop: true
|
|
290
290
|
}));
|
|
291
291
|
} : content));
|
|
292
292
|
|
|
293
293
|
var menuItem = function menuItem(item, index) {
|
|
294
|
+
var _theme$menu$item, _theme$menu$item2, _theme$menu$item3;
|
|
295
|
+
|
|
294
296
|
// Determine whether the label is done as a child or
|
|
295
297
|
// as an option Button kind property.
|
|
296
298
|
var child = !theme.button.option ? /*#__PURE__*/React.createElement(Box, {
|
|
297
299
|
align: "start",
|
|
298
300
|
pad: "small",
|
|
299
301
|
direction: "row",
|
|
300
|
-
gap: item.gap,
|
|
301
|
-
justify: item.justify
|
|
302
|
+
gap: item.gap || ((_theme$menu$item = theme.menu.item) == null ? void 0 : _theme$menu$item.gap),
|
|
303
|
+
justify: item.justify || ((_theme$menu$item2 = theme.menu.item) == null ? void 0 : _theme$menu$item2.justify)
|
|
302
304
|
}, item.reverse && item.label, item.icon, !item.reverse && item.label) : undefined; // if we have a child, turn on plain, and hoverIndicator
|
|
303
305
|
|
|
304
306
|
return (
|
|
@@ -320,9 +322,10 @@ var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
320
322
|
focusIndicator: false,
|
|
321
323
|
plain: !child ? undefined : true,
|
|
322
324
|
align: "start",
|
|
323
|
-
justify: item.justify,
|
|
324
325
|
kind: !child ? 'option' : undefined,
|
|
325
326
|
hoverIndicator: !child ? undefined : 'background'
|
|
327
|
+
}, theme.menu.item, {
|
|
328
|
+
justify: item.justify || ((_theme$menu$item3 = theme.menu.item) == null ? void 0 : _theme$menu$item3.justify)
|
|
326
329
|
}, !child ? item : _extends({}, item, {
|
|
327
330
|
gap: undefined,
|
|
328
331
|
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
|
|
|
@@ -28,8 +28,12 @@ var Circle = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
28
28
|
var centerY = width / 2;
|
|
29
29
|
var radius = width / 2 - strokeWidth / 2; // truncate to avoid floating point arithmetic errors
|
|
30
30
|
// see: https://github.com/grommet/grommet/issues/6190
|
|
31
|
+
// Choose a scale factor at least 3 orders of magnitude above max
|
|
32
|
+
|
|
33
|
+
var scalePower = Math.max(5, Math.ceil(Math.log10(max)) + 3);
|
|
34
|
+
var scale = Math.pow(10, scalePower);
|
|
35
|
+
var anglePer = Math.floor((type === 'semicircle' ? 180 : 360) / max * scale) / scale; // (type === 'semicircle' ? 180 : 360) / max;
|
|
31
36
|
|
|
32
|
-
var anglePer = Math.floor((type === 'semicircle' ? 180 : 360) / max * 10000) / 10000;
|
|
33
37
|
var someHighlight = (values || []).some(function (v) {
|
|
34
38
|
return v.highlight;
|
|
35
39
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var _excluded = ["actions", "gridProps", "parent", "responsive", "subtitle", "title"];
|
|
2
|
-
|
|
3
|
-
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); }
|
|
1
|
+
var _excluded = ["actions", "gridProps", "parent", "responsive", "size", "subtitle", "title"];
|
|
4
2
|
|
|
5
3
|
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; }
|
|
6
4
|
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
7
|
import React, { forwardRef, useContext } from 'react';
|
|
8
8
|
import { ThemeContext } from 'styled-components';
|
|
9
9
|
import { Box } from '../Box';
|
|
@@ -12,14 +12,24 @@ import { Heading } from '../Heading';
|
|
|
12
12
|
import { Grid } from '../Grid';
|
|
13
13
|
import { Paragraph } from '../Paragraph';
|
|
14
14
|
import { ResponsiveContext } from '../../contexts/ResponsiveContext';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
|
|
16
|
+
var sizeStyle = function sizeStyle(size, feature, theme) {
|
|
17
|
+
var _ref, _theme$pageHeader$siz;
|
|
18
|
+
|
|
19
|
+
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]);
|
|
20
|
+
|
|
21
|
+
return style;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
var PageHeader = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
25
|
+
var actions = _ref2.actions,
|
|
26
|
+
gridPropsProp = _ref2.gridProps,
|
|
27
|
+
parent = _ref2.parent,
|
|
28
|
+
responsive = _ref2.responsive,
|
|
29
|
+
size = _ref2.size,
|
|
30
|
+
subtitle = _ref2.subtitle,
|
|
31
|
+
title = _ref2.title,
|
|
32
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
23
33
|
|
|
24
34
|
var theme = useContext(ThemeContext);
|
|
25
35
|
var breakpoint = useContext(ResponsiveContext);
|
|
@@ -42,7 +52,7 @@ var PageHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
42
52
|
ref: ref,
|
|
43
53
|
direction: "column",
|
|
44
54
|
gap: "none",
|
|
45
|
-
pad: theme
|
|
55
|
+
pad: sizeStyle(size, 'pad', theme)
|
|
46
56
|
}, rest), /*#__PURE__*/React.createElement(Grid, _extends({
|
|
47
57
|
columns: columns,
|
|
48
58
|
rows: rows,
|
|
@@ -53,9 +63,9 @@ var PageHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
63
|
gridArea: "parent"
|
|
54
64
|
}, theme.pageHeader.parent), parent), /*#__PURE__*/React.createElement(Box, {
|
|
55
65
|
gridArea: "title"
|
|
56
|
-
}, typeof title === 'string' ? /*#__PURE__*/React.createElement(Heading,
|
|
66
|
+
}, typeof title === 'string' ? /*#__PURE__*/React.createElement(Heading, sizeStyle(size, 'title', theme), title) : title), /*#__PURE__*/React.createElement(Box, {
|
|
57
67
|
gridArea: "subtitle"
|
|
58
|
-
}, typeof subtitle === 'string' ? /*#__PURE__*/React.createElement(Paragraph,
|
|
68
|
+
}, typeof subtitle === 'string' ? /*#__PURE__*/React.createElement(Paragraph, sizeStyle(size, 'subtitle', theme), subtitle) : subtitle), /*#__PURE__*/React.createElement(Box, _extends({
|
|
59
69
|
gridArea: "actions"
|
|
60
70
|
}, actionsProps), actions)));
|
|
61
71
|
});
|
|
@@ -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 };
|
|
@@ -11,6 +11,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
11
11
|
gridProps: GridPropTypes,
|
|
12
12
|
parent: PropTypes.element,
|
|
13
13
|
responsive: PropTypes.bool,
|
|
14
|
+
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
14
15
|
subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
15
16
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
16
17
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Anchor, Button, PageHeader, Page, PageContent } from 'grommet';
|
|
3
|
+
export var Size = function Size() {
|
|
4
|
+
return (
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
// Uncomment <Grommet> lines when using outside of storybook
|
|
7
|
+
// <Grommet theme={...}>
|
|
8
|
+
React.createElement(Page, null, /*#__PURE__*/React.createElement(PageContent, null, /*#__PURE__*/React.createElement(PageHeader, {
|
|
9
|
+
title: "Small PageHeader",
|
|
10
|
+
subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
|
|
11
|
+
actions: /*#__PURE__*/React.createElement(Button, {
|
|
12
|
+
label: "Page-level action"
|
|
13
|
+
}),
|
|
14
|
+
parent: /*#__PURE__*/React.createElement(Anchor, {
|
|
15
|
+
label: "Parent Page"
|
|
16
|
+
}),
|
|
17
|
+
size: "small"
|
|
18
|
+
}), /*#__PURE__*/React.createElement(PageHeader, {
|
|
19
|
+
title: "Medium PageHeader (default)",
|
|
20
|
+
subtitle: "Grommet helps you build responsive and accessible \n mobile-first projects for the web with an easy to use component \n library.",
|
|
21
|
+
actions: /*#__PURE__*/React.createElement(Button, {
|
|
22
|
+
label: "Page-level action"
|
|
23
|
+
}),
|
|
24
|
+
parent: /*#__PURE__*/React.createElement(Anchor, {
|
|
25
|
+
label: "Parent Page"
|
|
26
|
+
})
|
|
27
|
+
}), /*#__PURE__*/React.createElement(PageHeader, {
|
|
28
|
+
title: "Large PageHeader",
|
|
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.createElement(Button, {
|
|
31
|
+
label: "Page-level action"
|
|
32
|
+
}),
|
|
33
|
+
parent: /*#__PURE__*/React.createElement(Anchor, {
|
|
34
|
+
label: "Parent Page"
|
|
35
|
+
}),
|
|
36
|
+
size: "large"
|
|
37
|
+
}))) // </Grommet>
|
|
38
|
+
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
export default {
|
|
42
|
+
title: 'Layout/PageHeader/Size'
|
|
43
|
+
};
|