grommet 2.42.0 → 2.43.0
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/all/stories/Colors.js +6 -6
- package/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
- package/components/Box/stories/Background.js +4 -10
- package/components/Calendar/Calendar.js +6 -3
- package/components/Card/stories/Simple.js +2 -2
- package/components/Data/stories/Cards.js +3 -2
- package/components/Data/stories/Properties.js +3 -2
- package/components/FormField/FormField.js +9 -2
- package/components/FormField/stories/ThresholdValidation.js +5 -1
- package/components/Grommet/index.d.ts +19 -1
- package/components/Grommet/propTypes.js +18 -0
- package/components/Grommet/stories/Theme.js +1 -1
- package/components/Grommet/stories/Vars.js +2 -2
- package/components/List/List.js +27 -3
- package/components/List/stories/RenderedList.js +1 -1
- package/components/Meter/Meter.js +36 -17
- package/components/Meter/index.d.ts +18 -0
- package/components/Meter/propTypes.js +18 -0
- package/components/Pagination/stories/CustomThemed/Custom.tsx +8 -2
- package/components/Pagination/stories/NumberEdgePages.js +2 -0
- package/components/Pagination/stories/NumberMiddlePages.js +2 -0
- package/components/Pagination/stories/Simple.js +4 -2
- package/components/Pagination/stories/Size.js +3 -0
- package/components/Pagination/stories/Steps.js +3 -0
- package/components/RadioButton/RadioButton.js +14 -3
- package/components/RadioButton/stories/Children.js +16 -3
- package/components/RadioButtonGroup/stories/Children.js +13 -1
- package/components/Tabs/stories/Scrollable.js +2 -1
- package/components/TextInput/TextInput.js +7 -2
- package/es6/all/stories/Colors.js +6 -6
- package/es6/components/Accordion/stories/CustomThemed/Rich.tsx +1 -1
- package/es6/components/Box/stories/Background.js +4 -10
- package/es6/components/Calendar/Calendar.js +6 -3
- package/es6/components/Card/stories/Simple.js +3 -3
- package/es6/components/Data/stories/Cards.js +4 -3
- package/es6/components/Data/stories/Properties.js +4 -3
- package/es6/components/FormField/FormField.js +10 -3
- package/es6/components/FormField/stories/ThresholdValidation.js +5 -1
- package/es6/components/Grommet/index.d.ts +19 -1
- package/es6/components/Grommet/propTypes.js +18 -0
- package/es6/components/Grommet/stories/Theme.js +1 -1
- package/es6/components/Grommet/stories/Vars.js +2 -2
- package/es6/components/List/List.js +27 -3
- package/es6/components/List/stories/RenderedList.js +1 -1
- package/es6/components/Meter/Meter.js +37 -18
- package/es6/components/Meter/index.d.ts +18 -0
- package/es6/components/Meter/propTypes.js +18 -0
- package/es6/components/Pagination/stories/CustomThemed/Custom.tsx +8 -2
- package/es6/components/Pagination/stories/NumberEdgePages.js +2 -0
- package/es6/components/Pagination/stories/NumberMiddlePages.js +2 -0
- package/es6/components/Pagination/stories/Simple.js +4 -2
- package/es6/components/Pagination/stories/Size.js +3 -0
- package/es6/components/Pagination/stories/Steps.js +3 -0
- package/es6/components/RadioButton/RadioButton.js +15 -4
- package/es6/components/RadioButton/stories/Children.js +16 -3
- package/es6/components/RadioButtonGroup/stories/Children.js +12 -1
- package/es6/components/Tabs/stories/Scrollable.js +2 -1
- package/es6/components/TextInput/TextInput.js +7 -2
- package/es6/languages/default.json +18 -0
- package/es6/utils/useId.js +3 -2
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +18 -0
- package/package.json +26 -26
- package/utils/useId.js +5 -2
- package/components/CheckBox/stories/InsideButton.js +0 -38
- package/es6/components/CheckBox/stories/InsideButton.js +0 -32
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
var _excluded = ["background", "color", "direction", "size", "thickness", "type", "reverse", "value", "values"];
|
|
1
|
+
var _excluded = ["aria-label", "background", "color", "direction", "max", "messages", "size", "thickness", "type", "reverse", "value", "values"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { forwardRef, useMemo } from 'react';
|
|
4
|
+
import React, { forwardRef, useContext, useMemo } from 'react';
|
|
5
5
|
import { Bar } from './Bar';
|
|
6
6
|
import { Circle } from './Circle';
|
|
7
7
|
import { MeterPropTypes } from './propTypes';
|
|
8
8
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
9
|
-
|
|
10
|
-
var max = 100;
|
|
11
|
-
if (values && values.length > 1) {
|
|
12
|
-
max = 0;
|
|
13
|
-
values.forEach(function (v) {
|
|
14
|
-
max += v.value;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return max;
|
|
18
|
-
};
|
|
9
|
+
import { MessageContext } from '../../contexts/MessageContext';
|
|
19
10
|
var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
20
|
-
var
|
|
11
|
+
var _messages$meter;
|
|
12
|
+
var ariaLabel = _ref['aria-label'],
|
|
13
|
+
_ref$background = _ref.background,
|
|
21
14
|
background = _ref$background === void 0 ? {
|
|
22
15
|
color: 'light-2',
|
|
23
16
|
opacity: 'medium'
|
|
@@ -25,6 +18,8 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
18
|
color = _ref.color,
|
|
26
19
|
_ref$direction = _ref.direction,
|
|
27
20
|
direction = _ref$direction === void 0 ? 'horizontal' : _ref$direction,
|
|
21
|
+
maxProp = _ref.max,
|
|
22
|
+
messages = _ref.messages,
|
|
28
23
|
_ref$size = _ref.size,
|
|
29
24
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
30
25
|
_ref$thickness = _ref.thickness,
|
|
@@ -37,6 +32,8 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
37
32
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
38
33
|
var _useThemeValue = useThemeValue(),
|
|
39
34
|
theme = _useThemeValue.theme;
|
|
35
|
+
var _useContext = useContext(MessageContext),
|
|
36
|
+
format = _useContext.format;
|
|
40
37
|
|
|
41
38
|
// normalize values to an array of objects
|
|
42
39
|
var values = useMemo(function () {
|
|
@@ -48,14 +45,35 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
48
45
|
return [];
|
|
49
46
|
}, [color, value, valuesProp]);
|
|
50
47
|
var reverse = direction === 'horizontal' && (theme.dir === 'rtl' || reverseProp) && !(theme.dir === 'rtl' && reverseProp);
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
var max = useMemo(function () {
|
|
49
|
+
var maxValue = 100;
|
|
50
|
+
if ((values == null ? void 0 : values.length) > 1) {
|
|
51
|
+
maxValue = values.reduce(function (total, currentValue) {
|
|
52
|
+
return total + currentValue.value;
|
|
53
|
+
}, 0);
|
|
54
|
+
}
|
|
55
|
+
return maxProp || maxValue || 100;
|
|
56
|
+
}, [maxProp, values]);
|
|
57
|
+
var messageId = (values == null ? void 0 : values.length) === 1 ? 'singular' : 'plural';
|
|
58
|
+
var meterType = type || 'bar';
|
|
59
|
+
var meterAriaLabel = ariaLabel || format({
|
|
60
|
+
id: "meter." + meterType + "." + messageId,
|
|
61
|
+
messages: messages == null || (_messages$meter = messages.meter) == null ? void 0 : _messages$meter[meterType],
|
|
62
|
+
values: {
|
|
63
|
+
meterValue: value || values.map(function (item) {
|
|
64
|
+
var _item$value;
|
|
65
|
+
return (_item$value = item.value) != null ? _item$value : 0;
|
|
66
|
+
}).join(', ') || 0,
|
|
67
|
+
type: type,
|
|
68
|
+
max: max
|
|
69
|
+
}
|
|
70
|
+
});
|
|
54
71
|
var content;
|
|
55
72
|
if (type === 'bar') {
|
|
56
73
|
content = /*#__PURE__*/React.createElement(Bar, _extends({
|
|
57
74
|
ref: ref,
|
|
58
|
-
|
|
75
|
+
"aria-label": meterAriaLabel,
|
|
76
|
+
max: max,
|
|
59
77
|
values: values,
|
|
60
78
|
size: size,
|
|
61
79
|
thickness: thickness,
|
|
@@ -65,8 +83,9 @@ var Meter = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
65
83
|
}, rest));
|
|
66
84
|
} else if (type === 'circle' || type === 'pie' || type === 'semicircle') {
|
|
67
85
|
content = /*#__PURE__*/React.createElement(Circle, _extends({
|
|
86
|
+
"aria-label": meterAriaLabel,
|
|
68
87
|
ref: ref,
|
|
69
|
-
max:
|
|
88
|
+
max: max,
|
|
70
89
|
values: values,
|
|
71
90
|
size: size,
|
|
72
91
|
thickness: thickness,
|
|
@@ -16,6 +16,24 @@ export interface MeterProps {
|
|
|
16
16
|
gridArea?: GridAreaType;
|
|
17
17
|
margin?: MarginType;
|
|
18
18
|
max?: number;
|
|
19
|
+
messages?: {
|
|
20
|
+
bar?: {
|
|
21
|
+
singular?: string;
|
|
22
|
+
plural?: string;
|
|
23
|
+
};
|
|
24
|
+
circle?: {
|
|
25
|
+
singular?: string;
|
|
26
|
+
plural?: string;
|
|
27
|
+
};
|
|
28
|
+
pie?: {
|
|
29
|
+
singular?: string;
|
|
30
|
+
plural?: string;
|
|
31
|
+
};
|
|
32
|
+
semicircle?: {
|
|
33
|
+
singular?: string;
|
|
34
|
+
plural?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
19
37
|
reverse?: boolean;
|
|
20
38
|
round?: boolean;
|
|
21
39
|
size?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'full' | string;
|
|
@@ -10,6 +10,24 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
10
10
|
})]),
|
|
11
11
|
color: PropTypes.string,
|
|
12
12
|
max: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
13
|
+
messages: PropTypes.shape({
|
|
14
|
+
bar: PropTypes.shape({
|
|
15
|
+
singular: PropTypes.string,
|
|
16
|
+
plural: PropTypes.string
|
|
17
|
+
}),
|
|
18
|
+
circle: PropTypes.shape({
|
|
19
|
+
singular: PropTypes.string,
|
|
20
|
+
plural: PropTypes.string
|
|
21
|
+
}),
|
|
22
|
+
pie: PropTypes.shape({
|
|
23
|
+
singular: PropTypes.string,
|
|
24
|
+
plural: PropTypes.string
|
|
25
|
+
}),
|
|
26
|
+
semicirlce: PropTypes.shape({
|
|
27
|
+
singular: PropTypes.string,
|
|
28
|
+
plural: PropTypes.string
|
|
29
|
+
})
|
|
30
|
+
}),
|
|
13
31
|
reverse: PropTypes.bool,
|
|
14
32
|
round: PropTypes.bool,
|
|
15
33
|
size: PropTypes.oneOfType([PropTypes.oneOf(['xsmall', 'small', 'medium', 'large', 'xlarge', 'full']), PropTypes.string]),
|
|
@@ -52,7 +52,10 @@ export const Custom = () => (
|
|
|
52
52
|
<Text margin={{ bottom: 'small' }}>
|
|
53
53
|
Custom Theme via theme.pagination.button
|
|
54
54
|
</Text>
|
|
55
|
-
<Pagination
|
|
55
|
+
<Pagination
|
|
56
|
+
aria-label="Pagination with custom button theme"
|
|
57
|
+
numberItems={237}
|
|
58
|
+
/>
|
|
56
59
|
</Box>
|
|
57
60
|
<Box
|
|
58
61
|
align="start"
|
|
@@ -62,7 +65,10 @@ export const Custom = () => (
|
|
|
62
65
|
<Text margin={{ bottom: 'small' }}>
|
|
63
66
|
Custom Theme via theme.pagination.button
|
|
64
67
|
</Text>
|
|
65
|
-
<Pagination
|
|
68
|
+
<Pagination
|
|
69
|
+
aria-label="Pagination with custom button theme and black background"
|
|
70
|
+
numberItems={237}
|
|
71
|
+
/>
|
|
66
72
|
</Box>
|
|
67
73
|
</Box>
|
|
68
74
|
</Grommet>
|
|
@@ -9,10 +9,12 @@ export var NumberEdgePages = function NumberEdgePages() {
|
|
|
9
9
|
pad: "small",
|
|
10
10
|
gap: "medium"
|
|
11
11
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "numberEdgePages = 2 (number of pages on start/end)"), /*#__PURE__*/React.createElement(Pagination, {
|
|
12
|
+
"aria-label": "Pagination with 2 pages at the start and end",
|
|
12
13
|
numberItems: 237,
|
|
13
14
|
page: 10,
|
|
14
15
|
numberEdgePages: 2
|
|
15
16
|
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "numberEdgePages = 0"), /*#__PURE__*/React.createElement(Pagination, {
|
|
17
|
+
"aria-label": "Pagination with no pages at the start and end",
|
|
16
18
|
numberItems: 237,
|
|
17
19
|
page: 10,
|
|
18
20
|
numberEdgePages: 0
|
|
@@ -9,10 +9,12 @@ export var NumberMiddlePages = function NumberMiddlePages() {
|
|
|
9
9
|
pad: "small",
|
|
10
10
|
gap: "medium"
|
|
11
11
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "numberMiddlePages = 4 (number of pages in the middle)"), /*#__PURE__*/React.createElement(Pagination, {
|
|
12
|
+
"aria-label": "Pagination with 4 pages in the middle",
|
|
12
13
|
numberItems: 237,
|
|
13
14
|
page: 10,
|
|
14
15
|
numberMiddlePages: 4
|
|
15
16
|
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "numberMiddlePages = 5 (number of pages in the middle)"), /*#__PURE__*/React.createElement(Pagination, {
|
|
17
|
+
"aria-label": "Pagination with 5 pages in the middle",
|
|
16
18
|
numberItems: 237,
|
|
17
19
|
page: 10,
|
|
18
20
|
numberMiddlePages: 5
|
|
@@ -10,13 +10,15 @@ export var Simple = function Simple() {
|
|
|
10
10
|
pad: "small",
|
|
11
11
|
gap: "medium"
|
|
12
12
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "Default"), /*#__PURE__*/React.createElement(Pagination, {
|
|
13
|
+
"aria-label": "Pagination with default settings",
|
|
13
14
|
numberItems: 237
|
|
14
15
|
})), /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Text, null, "Box Props"), /*#__PURE__*/React.createElement(Pagination, {
|
|
15
16
|
numberItems: 1237,
|
|
16
17
|
page: 24,
|
|
17
|
-
background: "
|
|
18
|
+
background: "dark-1",
|
|
18
19
|
pad: "medium",
|
|
19
|
-
margin: "small"
|
|
20
|
+
margin: "small",
|
|
21
|
+
"aria-label": "Pagination with custom background and spacing"
|
|
20
22
|
})))
|
|
21
23
|
// </Grommet>
|
|
22
24
|
);
|
|
@@ -10,12 +10,15 @@ export var Size = function Size() {
|
|
|
10
10
|
pad: "small",
|
|
11
11
|
gap: "medium"
|
|
12
12
|
}, /*#__PURE__*/React.createElement(Text, null, "Small"), /*#__PURE__*/React.createElement(Pagination, {
|
|
13
|
+
"aria-label": "Pagination with small size",
|
|
13
14
|
numberItems: 237,
|
|
14
15
|
size: "small"
|
|
15
16
|
}), /*#__PURE__*/React.createElement(Text, null, "Medium (Default)"), /*#__PURE__*/React.createElement(Pagination, {
|
|
17
|
+
"aria-label": "Pagination with medium size",
|
|
16
18
|
numberItems: 237,
|
|
17
19
|
size: "medium"
|
|
18
20
|
}), /*#__PURE__*/React.createElement(Text, null, "Large"), /*#__PURE__*/React.createElement(Pagination, {
|
|
21
|
+
"aria-label": "Pagination with large size",
|
|
19
22
|
numberItems: 237,
|
|
20
23
|
size: "large"
|
|
21
24
|
}))
|
|
@@ -12,17 +12,20 @@ export var Steps = function Steps() {
|
|
|
12
12
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
13
13
|
fill: "horizontal"
|
|
14
14
|
}, /*#__PURE__*/React.createElement(Text, null, "Pagination with stepOptions"), /*#__PURE__*/React.createElement(Pagination, {
|
|
15
|
+
"aria-label": "Pagination with step options to change items per page",
|
|
15
16
|
numberItems: 237,
|
|
16
17
|
stepOptions: true
|
|
17
18
|
})), /*#__PURE__*/React.createElement(Box, {
|
|
18
19
|
fill: "horizontal"
|
|
19
20
|
}, /*#__PURE__*/React.createElement(Text, null, "Pagination with stepOptions and summary"), /*#__PURE__*/React.createElement(Pagination, {
|
|
21
|
+
"aria-label": "Pagination with step options and summary of items per page",
|
|
20
22
|
numberItems: 237,
|
|
21
23
|
stepOptions: true,
|
|
22
24
|
summary: true
|
|
23
25
|
})), /*#__PURE__*/React.createElement(Box, {
|
|
24
26
|
fill: "horizontal"
|
|
25
27
|
}, /*#__PURE__*/React.createElement(Text, null, "Pagination with custom step sizes"), /*#__PURE__*/React.createElement(Pagination, {
|
|
28
|
+
"aria-label": "Pagination with custom step sizes and summary",
|
|
26
29
|
numberItems: 237,
|
|
27
30
|
stepOptions: [10, 20, 30, 1000],
|
|
28
31
|
summary: true
|
|
@@ -2,7 +2,7 @@ var _excluded = ["a11yTitle", "checked", "children", "disabled", "focus", "focus
|
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { forwardRef, useState } from 'react';
|
|
5
|
-
import { normalizeColor, removeUndefined } from '../../utils';
|
|
5
|
+
import { normalizeColor, removeUndefined, useKeyboard } from '../../utils';
|
|
6
6
|
import { StyledRadioButton, StyledRadioButtonContainer, StyledRadioButtonIcon, StyledRadioButtonInput, StyledRadioButtonLabel, StyledRadioButtonBox } from './StyledRadioButton';
|
|
7
7
|
import { RadioButtonPropTypes } from './propTypes';
|
|
8
8
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
@@ -12,8 +12,9 @@ var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
12
12
|
checked = _ref.checked,
|
|
13
13
|
children = _ref.children,
|
|
14
14
|
disabled = _ref.disabled,
|
|
15
|
-
|
|
16
|
-
focusIndicator = _ref.focusIndicator,
|
|
15
|
+
focusProp = _ref.focus,
|
|
16
|
+
_ref$focusIndicator = _ref.focusIndicator,
|
|
17
|
+
focusIndicator = _ref$focusIndicator === void 0 ? true : _ref$focusIndicator,
|
|
17
18
|
id = _ref.id,
|
|
18
19
|
label = _ref.label,
|
|
19
20
|
name = _ref.name,
|
|
@@ -25,6 +26,10 @@ var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
26
|
var _useState = useState(),
|
|
26
27
|
hover = _useState[0],
|
|
27
28
|
setHover = _useState[1];
|
|
29
|
+
var _useState2 = useState(focusProp),
|
|
30
|
+
focus = _useState2[0],
|
|
31
|
+
setFocus = _useState2[1];
|
|
32
|
+
var usingKeyboard = useKeyboard();
|
|
28
33
|
var normalizedLabel = typeof label === 'string' ? /*#__PURE__*/React.createElement(StyledRadioButtonLabel, passThemeFlag, label) : label;
|
|
29
34
|
var Icon = theme.radioButton.icons.circle;
|
|
30
35
|
var borderColor = normalizeColor(theme.radioButton.border.color, theme);
|
|
@@ -49,6 +54,12 @@ var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
49
54
|
},
|
|
50
55
|
focus: focus,
|
|
51
56
|
focusIndicator: focusIndicator,
|
|
57
|
+
onFocus: function onFocus() {
|
|
58
|
+
return setFocus(true);
|
|
59
|
+
},
|
|
60
|
+
onBlur: function onBlur() {
|
|
61
|
+
return setFocus(false);
|
|
62
|
+
},
|
|
52
63
|
onMouseEnter: function onMouseEnter() {
|
|
53
64
|
return setHover(true);
|
|
54
65
|
},
|
|
@@ -76,7 +87,7 @@ var RadioButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
76
87
|
focus: focus && focusIndicator,
|
|
77
88
|
hover: hover
|
|
78
89
|
}) : /*#__PURE__*/React.createElement(StyledRadioButtonBox, _extends({
|
|
79
|
-
focus: focus && focusIndicator,
|
|
90
|
+
focus: focus && focusIndicator && usingKeyboard,
|
|
80
91
|
align: "center",
|
|
81
92
|
justify: "center",
|
|
82
93
|
width: theme.radioButton.size,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Box, Button, RadioButton } from 'grommet';
|
|
3
3
|
import { Ascend } from "grommet-icons/es6/icons/Ascend";
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { focusStyle, useKeyboard } from 'grommet/utils';
|
|
6
|
+
var StyledRadioChild = styled(Box).withConfig({
|
|
7
|
+
displayName: "Children__StyledRadioChild",
|
|
8
|
+
componentId: "sc-1occfxm-0"
|
|
9
|
+
})(["", ""], function (props) {
|
|
10
|
+
return props.focus && props.keyboard && focusStyle();
|
|
11
|
+
});
|
|
4
12
|
export var Children = function Children() {
|
|
5
13
|
var _React$useState = React.useState(),
|
|
6
14
|
selected = _React$useState[0],
|
|
7
15
|
setSelected = _React$useState[1];
|
|
16
|
+
var usingKeyboard = useKeyboard();
|
|
8
17
|
return /*#__PURE__*/React.createElement(Box, {
|
|
9
18
|
align: "center",
|
|
10
19
|
pad: "large",
|
|
@@ -17,10 +26,14 @@ export var Children = function Children() {
|
|
|
17
26
|
return setSelected(event.target.value);
|
|
18
27
|
}
|
|
19
28
|
}, function (_ref) {
|
|
20
|
-
var checked = _ref.checked
|
|
21
|
-
|
|
29
|
+
var checked = _ref.checked,
|
|
30
|
+
focus = _ref.focus;
|
|
31
|
+
return /*#__PURE__*/React.createElement(StyledRadioChild, {
|
|
32
|
+
focus: focus,
|
|
33
|
+
keyboard: usingKeyboard
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Ascend, {
|
|
22
35
|
color: checked ? 'brand' : 'status-unknown'
|
|
23
|
-
});
|
|
36
|
+
}));
|
|
24
37
|
}), /*#__PURE__*/React.createElement(Button, {
|
|
25
38
|
label: "clear",
|
|
26
39
|
onClick: function onClick() {
|
|
@@ -2,10 +2,19 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { Box, RadioButtonGroup } from 'grommet';
|
|
3
3
|
import { Ascend } from "grommet-icons/es6/icons/Ascend";
|
|
4
4
|
import { Descend } from "grommet-icons/es6/icons/Descend";
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { focusStyle, useKeyboard } from 'grommet/utils';
|
|
7
|
+
var StyledRadioChild = styled(Box).withConfig({
|
|
8
|
+
displayName: "Children__StyledRadioChild",
|
|
9
|
+
componentId: "sc-19d15gj-0"
|
|
10
|
+
})(["", ""], function (props) {
|
|
11
|
+
return props.focus && props.keyboard && focusStyle();
|
|
12
|
+
});
|
|
5
13
|
export var Children = function Children() {
|
|
6
14
|
var _useState = useState(),
|
|
7
15
|
value = _useState[0],
|
|
8
16
|
setValue = _useState[1];
|
|
17
|
+
var usingKeyboard = useKeyboard();
|
|
9
18
|
return /*#__PURE__*/React.createElement(Box, {
|
|
10
19
|
align: "center",
|
|
11
20
|
pad: "large"
|
|
@@ -25,7 +34,9 @@ export var Children = function Children() {
|
|
|
25
34
|
var Icon = option === 'asc' ? Ascend : Descend;
|
|
26
35
|
var background;
|
|
27
36
|
if (checked) background = 'brand';else if (hover) background = 'light-4';else if (focus) background = 'light-4';else background = 'light-2';
|
|
28
|
-
return /*#__PURE__*/React.createElement(
|
|
37
|
+
return /*#__PURE__*/React.createElement(StyledRadioChild, {
|
|
38
|
+
focus: focus,
|
|
39
|
+
keyboard: usingKeyboard,
|
|
29
40
|
background: background,
|
|
30
41
|
pad: "xsmall"
|
|
31
42
|
}, /*#__PURE__*/React.createElement(Icon, null));
|
|
@@ -17,7 +17,8 @@ var ScrollableTabs = function ScrollableTabs() {
|
|
|
17
17
|
overflow: "auto",
|
|
18
18
|
pad: "xlarge",
|
|
19
19
|
align: "center",
|
|
20
|
-
background: "light-2"
|
|
20
|
+
background: "light-2",
|
|
21
|
+
tabIndex: 0
|
|
21
22
|
}, /*#__PURE__*/React.createElement(Heading, null, "Title"), /*#__PURE__*/React.createElement(Paragraph, null, /*#__PURE__*/React.createElement(Text, {
|
|
22
23
|
weight: "bold"
|
|
23
24
|
}, "This is a tab with a lot of content. If you scroll down, the tabs header remains in view.")), /*#__PURE__*/React.createElement(Paragraph, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam porttitor ipsum a ligula tincidunt, tempor posuere massa gravida. Morbi at magna lacus. Vivamus eu consequat lectus. Quisque a aliquam risus. Ut vel dignissim nunc. Etiam rhoncus pellentesque porttitor. Sed nec gravida nisl. Cras justo ex, condimentum at dolor vel, lacinia efficitur dui. Nullam pellentesque metus nec felis gravida, vel suscipit sem condimentum. Ut hendrerit varius enim. Donec congue vestibulum neque accumsan fermentum. Nulla facilisi. Praesent ornare id magna vitae malesuada. Aenean nulla enim, pretium ac est vel, tristique condimentum ex. Phasellus ante enim, pellentesque ut arcu sit amet, semper sodales dolor."), /*#__PURE__*/React.createElement(Paragraph, null, "Proin sollicitudin dui eget diam mollis mattis eget id magna. Pellentesque tristique aliquet leo, a euismod velit molestie non. Donec lacinia, lectus quis mollis pretium, turpis erat sollicitudin mauris, vitae luctus velit lacus eu metus. Nam pulvinar mauris vitae massa faucibus, id semper sapien facilisis. Integer a congue ex. Vestibulum dapibus est fermentum felis hendrerit vulputate. Fusce libero odio, posuere sit amet mi vitae, cursus aliquam nulla. Nunc ornare augue vitae mauris ultricies gravida. In quis enim at nisi semper ultrices. Nunc posuere sed libero in facilisis."), /*#__PURE__*/React.createElement(Paragraph, null, "Etiam sit amet ligula nunc. Pellentesque pulvinar nisl ornare dui molestie, sed faucibus elit rhoncus. In nec pellentesque enim, eget ultricies tortor. Phasellus tincidunt ultrices tortor vitae malesuada. Proin rhoncus maximus mauris, a commodo tortor blandit quis. Phasellus tincidunt luctus dapibus. Sed in imperdiet enim. Vivamus varius ut dolor non scelerisque. Praesent volutpat ligula sodales augue auctor tempor. Quisque eleifend eleifend turpis nec egestas. Nunc dapibus semper commodo. Sed volutpat arcu eleifend ipsum volutpat, eu sagittis leo hendrerit. Nulla consequat justo non erat finibus cursus. Integer porttitor ante in ultrices semper."), /*#__PURE__*/React.createElement(Paragraph, null, "Praesent vel tellus sagittis, fringilla arcu vel, sodales turpis. Nam id accumsan nibh. Pellentesque eget diam eleifend, ultrices diam ac, suscipit ipsum. Curabitur euismod sodales sem vel ultricies. Proin euismod ipsum eros, ut efficitur felis pharetra finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut tincidunt posuere augue at porttitor. Sed venenatis iaculis est, sit amet interdum magna varius ut. In euismod scelerisque velit, vel aliquet enim. Etiam lacinia justo nec nibh aliquam, et pulvinar eros luctus. Fusce quis nisi eu tellus imperdiet bibendum ac id nulla. Proin ut tincidunt libero. Phasellus sed velit eu risus hendrerit suscipit at eget felis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Phasellus at blandit est. Phasellus fringilla nibh ac est scelerisque, id faucibus enim interdum."))), /*#__PURE__*/React.createElement(Tab, {
|
|
@@ -42,7 +42,7 @@ var defaultDropAlign = {
|
|
|
42
42
|
left: 'left'
|
|
43
43
|
};
|
|
44
44
|
var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
45
|
-
var _inputRef$current;
|
|
45
|
+
var _inputRef$current, _inputRef$current2;
|
|
46
46
|
var a11yTitle = _ref.a11yTitle,
|
|
47
47
|
defaultSuggestion = _ref.defaultSuggestion,
|
|
48
48
|
defaultValue = _ref.defaultValue,
|
|
@@ -231,6 +231,11 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
231
231
|
return clearTimeout(timer);
|
|
232
232
|
};
|
|
233
233
|
}, [activeSuggestionIndex, showDrop]);
|
|
234
|
+
useEffect(function () {
|
|
235
|
+
if (readOnly && inputRef != null && inputRef.current && inputRef.current.scrollLeft > 0) {
|
|
236
|
+
inputRef.current.scrollLeft = 0;
|
|
237
|
+
}
|
|
238
|
+
}, [readOnly, inputRef, inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.scrollLeft]);
|
|
234
239
|
var setValueFromSuggestion = function setValueFromSuggestion(event, suggestion) {
|
|
235
240
|
// if we stole the focus in the drop, perhaps by interacting with
|
|
236
241
|
// a suggestion button or the scrollbar, give it back
|
|
@@ -259,7 +264,7 @@ var TextInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
259
264
|
}, [activeSuggestionIndex]);
|
|
260
265
|
|
|
261
266
|
// account for input value in both controlled and uncontrolled scenarios
|
|
262
|
-
var hasValue = value || ((_inputRef$
|
|
267
|
+
var hasValue = value || ((_inputRef$current2 = inputRef.current) == null ? void 0 : _inputRef$current2.value);
|
|
263
268
|
var showStyledPlaceholder = useMemo(function () {
|
|
264
269
|
return placeholder && typeof placeholder !== 'string' && !hasValue;
|
|
265
270
|
}, [hasValue, placeholder]);
|
|
@@ -104,6 +104,24 @@
|
|
|
104
104
|
"openMenu": "Open Menu",
|
|
105
105
|
"closeMenu": "Close Menu"
|
|
106
106
|
},
|
|
107
|
+
"meter": {
|
|
108
|
+
"bar": {
|
|
109
|
+
"singular": "Bar meter with value {meterValue} out of {max}",
|
|
110
|
+
"plural": "Bar meter with values {meterValue} out of {max}"
|
|
111
|
+
},
|
|
112
|
+
"circle": {
|
|
113
|
+
"singular": "Circle meter with value {meterValue} out of {max}",
|
|
114
|
+
"plural": "Circle meter with values {meterValue} out of {max}"
|
|
115
|
+
},
|
|
116
|
+
"pie": {
|
|
117
|
+
"singular": "Pie meter with value {meterValue} out of {max}",
|
|
118
|
+
"plural": "Pie meter with values {meterValue} out of {max}"
|
|
119
|
+
},
|
|
120
|
+
"semicircle": {
|
|
121
|
+
"singular": "Semicircle meter with value {meterValue} out of {max}",
|
|
122
|
+
"plural": "Semicircle meter with values {meterValue} out of {max}"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
107
125
|
"pagination": {
|
|
108
126
|
"stepLabel": "Items per page",
|
|
109
127
|
"summary": "Showing {start}-{end} of {total}",
|
package/es6/utils/useId.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
var _React$useId;
|
|
2
|
+
import React, { useState } from 'react';
|
|
2
3
|
var currentId = 0;
|
|
3
4
|
var getId = function getId() {
|
|
4
5
|
// eslint-disable-next-line no-plusplus
|
|
@@ -12,5 +13,5 @@ var useIdGrommet = function useIdGrommet() {
|
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
// Polyfill React 18's useId for compatibility with React 16 and 17
|
|
15
|
-
var useId =
|
|
16
|
+
var useId = (_React$useId = React.useId) != null ? _React$useId : useIdGrommet;
|
|
16
17
|
export { useId };
|