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
|
@@ -3,5 +3,6 @@ export var applyKey = function applyKey(option, key) {
|
|
|
3
3
|
if (typeof key === 'object') return applyKey(option, key.key);
|
|
4
4
|
if (typeof key === 'function') return key(option);
|
|
5
5
|
if (key !== undefined) return option[key];
|
|
6
|
+
if (typeof option === 'object' && Object.keys(option)) return option[Object.keys(option)[0]];
|
|
6
7
|
return option;
|
|
7
8
|
};
|
|
@@ -50,7 +50,7 @@ var Tab = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
50
50
|
var tabStyles = {};
|
|
51
51
|
var tabRef = useForwardedRef(ref);
|
|
52
52
|
useLayoutEffect(function () {
|
|
53
|
-
if (tabRef.current) {
|
|
53
|
+
if (tabRef.current && tabsContextRef) {
|
|
54
54
|
tabsContextRef.current = tabRef.current;
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -18,6 +18,7 @@ import { StyledTabPanel, StyledTabs, StyledTabsHeader } from './StyledTabs';
|
|
|
18
18
|
import { normalizeColor } from '../../utils';
|
|
19
19
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
20
20
|
import { TabsPropTypes } from './propTypes';
|
|
21
|
+
import { useAnalytics } from '../../contexts/AnalyticsContext/AnalyticsContext';
|
|
21
22
|
var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
22
23
|
var alignControls = _ref.alignControls,
|
|
23
24
|
children = _ref.children,
|
|
@@ -67,6 +68,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
67
68
|
|
|
68
69
|
var headerRef = useRef();
|
|
69
70
|
var size = useContext(ResponsiveContext);
|
|
71
|
+
var sendAnalytics = useAnalytics();
|
|
70
72
|
|
|
71
73
|
if (activeIndex !== propsActiveIndex && propsActiveIndex !== undefined) {
|
|
72
74
|
setActiveIndex(propsActiveIndex);
|
|
@@ -233,6 +235,11 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
233
235
|
}, [tabRefs, disableLeftArrow, disableRightArrow, activeIndex, headerRef, overflow, updateArrowState]);
|
|
234
236
|
var getTabsContext = useCallback(function (index) {
|
|
235
237
|
var activateTab = function activateTab(nextIndex) {
|
|
238
|
+
sendAnalytics({
|
|
239
|
+
type: 'activateTab',
|
|
240
|
+
element: tabRefs[nextIndex].current
|
|
241
|
+
});
|
|
242
|
+
|
|
236
243
|
if (propsActiveIndex === undefined) {
|
|
237
244
|
setActiveIndex(nextIndex);
|
|
238
245
|
}
|
|
@@ -254,7 +261,7 @@ var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
254
261
|
setActiveTitle: setActiveTitle,
|
|
255
262
|
setFocusIndex: setFocusIndex
|
|
256
263
|
};
|
|
257
|
-
}, [activeIndex, onActive, propsActiveIndex, tabRefs]);
|
|
264
|
+
}, [activeIndex, onActive, propsActiveIndex, sendAnalytics, tabRefs]);
|
|
258
265
|
var tabs = React.Children.map(children, function (child, index) {
|
|
259
266
|
return /*#__PURE__*/React.createElement(TabsContext.Provider, {
|
|
260
267
|
value: getTabsContext(index)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
export var AnalyticsContext = /*#__PURE__*/React.createContext(function () {});
|
|
3
|
+
export var useAnalytics = function useAnalytics() {
|
|
4
|
+
return useContext(AnalyticsContext);
|
|
5
|
+
};
|
|
6
|
+
export var AnalyticsProvider = function AnalyticsProvider(_ref) {
|
|
7
|
+
var onAnalytics = _ref.onAnalytics,
|
|
8
|
+
children = _ref.children;
|
|
9
|
+
var lastUrlRef = useRef();
|
|
10
|
+
var sendAnalytics = useCallback(function (data) {
|
|
11
|
+
return onAnalytics && onAnalytics(data);
|
|
12
|
+
}, [onAnalytics]);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
var observer;
|
|
15
|
+
|
|
16
|
+
if (onAnalytics) {
|
|
17
|
+
observer = new window.MutationObserver(function () {
|
|
18
|
+
var _window, _window$location;
|
|
19
|
+
|
|
20
|
+
var url = (_window = window) == null ? void 0 : (_window$location = _window.location) == null ? void 0 : _window$location.href;
|
|
21
|
+
var previousUrl = lastUrlRef.current;
|
|
22
|
+
|
|
23
|
+
if (url !== previousUrl) {
|
|
24
|
+
lastUrlRef.current = url;
|
|
25
|
+
sendAnalytics({
|
|
26
|
+
type: 'pageView',
|
|
27
|
+
url: url,
|
|
28
|
+
previousUrl: previousUrl
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
observer.observe(document, {
|
|
33
|
+
subtree: true,
|
|
34
|
+
childList: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return function () {
|
|
39
|
+
var _observer;
|
|
40
|
+
|
|
41
|
+
return (_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
42
|
+
};
|
|
43
|
+
}, [sendAnalytics, onAnalytics]);
|
|
44
|
+
return /*#__PURE__*/React.createElement(AnalyticsContext.Provider, {
|
|
45
|
+
value: sendAnalytics
|
|
46
|
+
}, children);
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AnalyticsContext';
|
package/es6/contexts/index.js
CHANGED
package/es6/themes/base.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { Anchor } from '../components/Anchor';
|
|
|
32
32
|
import { Box } from '../components/Box';
|
|
33
33
|
import { Text, TextProps } from '../components/Text';
|
|
34
34
|
import { LayerPositionType, LayerProps } from '../components/Layer';
|
|
35
|
-
import { DropProps } from '../components/Drop';
|
|
35
|
+
import { DropProps, DropType } from '../components/Drop';
|
|
36
36
|
import {
|
|
37
37
|
AreasType,
|
|
38
38
|
GridColumnsType,
|
|
@@ -141,16 +141,19 @@ interface ButtonKindType {
|
|
|
141
141
|
| {
|
|
142
142
|
color?: ColorType;
|
|
143
143
|
width?: string;
|
|
144
|
+
radius?: string;
|
|
144
145
|
}
|
|
145
146
|
| boolean;
|
|
146
147
|
color?: ColorType;
|
|
147
148
|
font?: {
|
|
148
149
|
weight?: number | string;
|
|
149
150
|
};
|
|
151
|
+
icon?: React.ReactNode | Icon;
|
|
150
152
|
padding?: {
|
|
151
153
|
vertical?: string;
|
|
152
154
|
horizontal?: string;
|
|
153
155
|
};
|
|
156
|
+
reverse?: boolean;
|
|
154
157
|
extend?: ExtendType;
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -195,7 +198,13 @@ interface ButtonType {
|
|
|
195
198
|
secondary?: ButtonKindType;
|
|
196
199
|
})
|
|
197
200
|
| { [key: string]: ButtonKindType };
|
|
198
|
-
disabled?:
|
|
201
|
+
disabled?:
|
|
202
|
+
| (ButtonKindType & {
|
|
203
|
+
default?: ButtonKindType;
|
|
204
|
+
primary?: ButtonKindType;
|
|
205
|
+
secondary?: ButtonKindType;
|
|
206
|
+
})
|
|
207
|
+
| ({ [key: string]: ButtonKindType } & { opacity?: OpacityType });
|
|
199
208
|
hover?:
|
|
200
209
|
| (ButtonKindType & {
|
|
201
210
|
default?: ButtonKindType;
|
|
@@ -232,6 +241,7 @@ interface ButtonType {
|
|
|
232
241
|
};
|
|
233
242
|
};
|
|
234
243
|
};
|
|
244
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
235
245
|
transition?: {
|
|
236
246
|
timing?: string;
|
|
237
247
|
duration?: number;
|
|
@@ -368,11 +378,12 @@ export interface ThemeType {
|
|
|
368
378
|
color?: ColorType;
|
|
369
379
|
size?: string;
|
|
370
380
|
};
|
|
371
|
-
shadow?:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
381
|
+
shadow?:
|
|
382
|
+
| string
|
|
383
|
+
| {
|
|
384
|
+
color?: ColorType;
|
|
385
|
+
size?: string;
|
|
386
|
+
};
|
|
376
387
|
};
|
|
377
388
|
font?: {
|
|
378
389
|
face?: string;
|
|
@@ -771,6 +782,9 @@ export interface ThemeType {
|
|
|
771
782
|
margin?: MarginType;
|
|
772
783
|
pad?: PadType;
|
|
773
784
|
};
|
|
785
|
+
checkBox: {
|
|
786
|
+
pad: PadType;
|
|
787
|
+
};
|
|
774
788
|
disabled?: {
|
|
775
789
|
background?: BackgroundType;
|
|
776
790
|
border?: {
|
|
@@ -1025,7 +1039,8 @@ export interface ThemeType {
|
|
|
1025
1039
|
};
|
|
1026
1040
|
menu?: {
|
|
1027
1041
|
background?: BackgroundType;
|
|
1028
|
-
|
|
1042
|
+
item?: ButtonType;
|
|
1043
|
+
drop?: DropType;
|
|
1029
1044
|
extend?: ExtendType;
|
|
1030
1045
|
group?: {
|
|
1031
1046
|
container?: BoxProps;
|
|
@@ -1163,6 +1178,23 @@ export interface ThemeType {
|
|
|
1163
1178
|
};
|
|
1164
1179
|
subtitle?: ParagraphProps;
|
|
1165
1180
|
title?: HeadingProps;
|
|
1181
|
+
size?: {
|
|
1182
|
+
small?: {
|
|
1183
|
+
pad?: PadType;
|
|
1184
|
+
subtitle?: ParagraphProps;
|
|
1185
|
+
title?: ParagraphProps;
|
|
1186
|
+
};
|
|
1187
|
+
medium?: {
|
|
1188
|
+
pad?: PadType;
|
|
1189
|
+
subtitle?: ParagraphProps;
|
|
1190
|
+
title?: ParagraphProps;
|
|
1191
|
+
};
|
|
1192
|
+
large?: {
|
|
1193
|
+
pad?: PadType;
|
|
1194
|
+
subtitle?: ParagraphProps;
|
|
1195
|
+
title?: ParagraphProps;
|
|
1196
|
+
};
|
|
1197
|
+
};
|
|
1166
1198
|
small?: {
|
|
1167
1199
|
areas?: AreasType;
|
|
1168
1200
|
columns?: GridColumnsType;
|
package/es6/themes/base.js
CHANGED
|
@@ -527,10 +527,12 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
527
527
|
// font: {
|
|
528
528
|
// weight: undefined,
|
|
529
529
|
// },
|
|
530
|
+
// icon: undefined,
|
|
530
531
|
// padding: {
|
|
531
532
|
// vertical: undefined,
|
|
532
533
|
// horizontal: undefined,
|
|
533
534
|
// },
|
|
535
|
+
// reverse: undefined,
|
|
534
536
|
// extend: undefined,
|
|
535
537
|
// },
|
|
536
538
|
// primary: {
|
|
@@ -540,10 +542,12 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
540
542
|
// background: undefined,
|
|
541
543
|
// border: undefined,
|
|
542
544
|
// color: undefined,
|
|
545
|
+
// icon: undefined,
|
|
543
546
|
// padding: {
|
|
544
547
|
// vertical: undefined,
|
|
545
548
|
// horizontal: undefined,
|
|
546
549
|
// },
|
|
550
|
+
// reverse: undefined,
|
|
547
551
|
// extend: undefined,
|
|
548
552
|
// },
|
|
549
553
|
// secondary: {
|
|
@@ -553,20 +557,24 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
553
557
|
// background: undefined,
|
|
554
558
|
// border: undefined,
|
|
555
559
|
// color: undefined,
|
|
560
|
+
// icon: undefined,
|
|
556
561
|
// padding: {
|
|
557
562
|
// vertical: undefined,
|
|
558
563
|
// horizontal: undefined,
|
|
559
564
|
// },
|
|
565
|
+
// reverse: undefined,
|
|
560
566
|
// extend: undefined,
|
|
561
567
|
// },
|
|
562
568
|
// option: {
|
|
563
569
|
// background: undefined,
|
|
564
570
|
// border: undefined,
|
|
565
571
|
// color: undefined,
|
|
572
|
+
// icon: undefined,
|
|
566
573
|
// padding: {
|
|
567
574
|
// vertical: undefined,
|
|
568
575
|
// horizontal: undefined,
|
|
569
576
|
// },
|
|
577
|
+
// reverse: undefined,
|
|
570
578
|
// extend: undefined,
|
|
571
579
|
// },
|
|
572
580
|
active: {
|
|
@@ -955,6 +963,9 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
955
963
|
position: 'inner',
|
|
956
964
|
side: 'bottom'
|
|
957
965
|
},
|
|
966
|
+
// checkBox: {
|
|
967
|
+
// pad: undefined,
|
|
968
|
+
// },
|
|
958
969
|
content: {
|
|
959
970
|
// margin: undefined,
|
|
960
971
|
pad: 'small'
|
|
@@ -1142,6 +1153,7 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
1142
1153
|
},
|
|
1143
1154
|
menu: {
|
|
1144
1155
|
// background: undefined,
|
|
1156
|
+
// item: undefined,
|
|
1145
1157
|
// extend: undefined,
|
|
1146
1158
|
drop: {
|
|
1147
1159
|
align: {
|
|
@@ -1438,6 +1450,37 @@ export var generate = function generate(baseSpacing, scale) {
|
|
|
1438
1450
|
margin: 'none',
|
|
1439
1451
|
fill: true
|
|
1440
1452
|
},
|
|
1453
|
+
size: {
|
|
1454
|
+
small: {
|
|
1455
|
+
pad: {
|
|
1456
|
+
top: 'medium',
|
|
1457
|
+
bottom: 'small'
|
|
1458
|
+
},
|
|
1459
|
+
subtitle: {
|
|
1460
|
+
size: 'small'
|
|
1461
|
+
},
|
|
1462
|
+
title: {
|
|
1463
|
+
size: 'small'
|
|
1464
|
+
}
|
|
1465
|
+
},
|
|
1466
|
+
// medium: {
|
|
1467
|
+
// // pad: undefined,
|
|
1468
|
+
// // subtitle: {},
|
|
1469
|
+
// // title: {},
|
|
1470
|
+
// },
|
|
1471
|
+
large: {
|
|
1472
|
+
pad: {
|
|
1473
|
+
top: 'xlarge',
|
|
1474
|
+
bottom: 'large'
|
|
1475
|
+
},
|
|
1476
|
+
subtitle: {
|
|
1477
|
+
size: 'large'
|
|
1478
|
+
},
|
|
1479
|
+
title: {
|
|
1480
|
+
size: 'large'
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
},
|
|
1441
1484
|
small: {
|
|
1442
1485
|
areas: [['parent', 'parent'], ['title', 'actions'], ['subtitle', 'actions']],
|
|
1443
1486
|
columns: [['small', 'flex'], 'auto'],
|
package/es6/utils/mixins.js
CHANGED
|
@@ -8,6 +8,9 @@ export var parseMetricToNum = function parseMetricToNum(metric) {
|
|
|
8
8
|
|
|
9
9
|
return parseFloat(metric.match(/\d+(\.\d+)?/), 10);
|
|
10
10
|
};
|
|
11
|
+
export var edgeToNum = function edgeToNum(size, theme) {
|
|
12
|
+
return size ? parseMetricToNum(theme.global.edgeSize[size] || size) : 0;
|
|
13
|
+
};
|
|
11
14
|
export var fontSize = function fontSize(size, lineHeight) {
|
|
12
15
|
return css(["font-size:", ";line-height:", ";"], function (props) {
|
|
13
16
|
return parseMetricToNum(size) / parseMetricToNum(props.theme.global.font.size) * 1 + "rem";
|