grommet 2.54.0 → 2.55.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/components/Calendar/Calendar.js +24 -16
- package/components/Calendar/index.d.ts +1 -1
- package/components/Calendar/stories/CustomHeader.stories.js +6 -1
- package/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
- package/components/Calendar/stories/Dual.stories.js +23 -11
- package/components/Calendar/stories/HeaderLevel.stories.js +6 -1
- package/components/Calendar/stories/Multiple.stories.js +8 -3
- package/components/Calendar/stories/Simple.stories.js +6 -1
- package/components/Cards/Cards.js +164 -10
- package/components/Cards/StyledCellContainer.js +29 -0
- package/components/Cards/index.d.ts +4 -1
- package/components/Cards/propTypes.js +2 -0
- package/components/Cards/stories/Sizable.stories.js +70 -0
- package/components/Cards/stories/onOrder.stories.js +69 -0
- package/components/DataFilter/DataFilter.js +21 -28
- package/components/DateInput/DateInput.js +57 -24
- package/components/DateInput/index.d.ts +1 -0
- package/components/DateInput/utils.js +2 -2
- package/components/Drop/DropContainer.js +59 -3
- package/components/FileInput/FileInput.js +3 -0
- package/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
- package/components/Form/stories/FieldStates.stories.js +7 -1
- package/components/Grommet/Grommet.js +2 -1
- package/components/Grommet/index.d.ts +6 -0
- package/components/Grommet/propTypes.js +7 -1
- package/components/Layer/LayerContainer.d.ts +40 -0
- package/components/Select/stories/ChildrenRender.stories.js +28 -55
- package/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
- package/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
- package/components/Tag/Tag.js +4 -3
- package/components/Tag/index.d.ts +5 -4
- package/components/Tag/propTypes.js +3 -2
- package/components/TextInput/StyledTextInput.js +4 -2
- package/components/TextInput/TextInput.js +1 -0
- package/es6/components/Calendar/Calendar.js +24 -16
- package/es6/components/Calendar/index.d.ts +1 -1
- package/es6/components/Calendar/stories/CustomHeader.stories.js +6 -1
- package/es6/components/Calendar/stories/CustomThemed/CustomSizeHeading.stories.js +6 -1
- package/es6/components/Calendar/stories/Dual.stories.js +23 -11
- package/es6/components/Calendar/stories/HeaderLevel.stories.js +6 -1
- package/es6/components/Calendar/stories/Multiple.stories.js +8 -3
- package/es6/components/Calendar/stories/Simple.stories.js +6 -1
- package/es6/components/Cards/Cards.js +165 -12
- package/es6/components/Cards/StyledCellContainer.js +24 -0
- package/es6/components/Cards/index.d.ts +4 -1
- package/es6/components/Cards/propTypes.js +2 -0
- package/es6/components/Cards/stories/Sizable.stories.js +65 -0
- package/es6/components/Cards/stories/onOrder.stories.js +64 -0
- package/es6/components/DataFilter/DataFilter.js +21 -28
- package/es6/components/DateInput/DateInput.js +57 -24
- package/es6/components/DateInput/index.d.ts +1 -0
- package/es6/components/DateInput/utils.js +2 -2
- package/es6/components/Drop/DropContainer.js +59 -3
- package/es6/components/FileInput/FileInput.js +3 -0
- package/es6/components/Form/stories/CustomThemed/FieldCustomStates.stories.js +7 -1
- package/es6/components/Form/stories/FieldStates.stories.js +7 -1
- package/es6/components/Grommet/Grommet.js +2 -1
- package/es6/components/Grommet/index.d.ts +6 -0
- package/es6/components/Grommet/propTypes.js +7 -1
- package/es6/components/Layer/LayerContainer.d.ts +40 -0
- package/es6/components/Select/stories/ChildrenRender.stories.js +29 -56
- package/es6/components/SelectMultiple/stories/typescript/Children.stories.tsx +24 -48
- package/es6/components/SelectMultiple/stories/typescript/ValueLabel.stories.tsx +88 -0
- package/es6/components/Tag/Tag.js +4 -3
- package/es6/components/Tag/index.d.ts +5 -4
- package/es6/components/Tag/propTypes.js +3 -2
- package/es6/components/TextInput/StyledTextInput.js +4 -2
- package/es6/components/TextInput/TextInput.js +1 -0
- package/es6/languages/default.json +7 -1
- package/es6/themes/base.d.ts +1 -0
- package/es6/utils/index.d.ts +1 -0
- package/es6/utils/styles.js +23 -12
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/languages/default.json +7 -1
- package/package.json +29 -32
- package/themes/base.d.ts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/styles.js +23 -12
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Sizable = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _grommet = require("grommet");
|
|
7
|
+
var _Cards = require("../Cards");
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
var data = [{
|
|
10
|
+
city: 'Boise',
|
|
11
|
+
state: 'Idaho',
|
|
12
|
+
size: {
|
|
13
|
+
columns: 2,
|
|
14
|
+
rows: 1
|
|
15
|
+
}
|
|
16
|
+
}, {
|
|
17
|
+
city: 'Fort Collins',
|
|
18
|
+
state: 'Colorado'
|
|
19
|
+
}, {
|
|
20
|
+
city: 'Bay Area',
|
|
21
|
+
state: 'California'
|
|
22
|
+
}, {
|
|
23
|
+
city: 'San Diego',
|
|
24
|
+
state: 'California',
|
|
25
|
+
size: {
|
|
26
|
+
columns: 2,
|
|
27
|
+
rows: 1
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
city: 'San Francisco',
|
|
31
|
+
state: 'California',
|
|
32
|
+
size: {
|
|
33
|
+
columns: 1,
|
|
34
|
+
rows: 2
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
city: 'Los Angeles',
|
|
38
|
+
state: 'California'
|
|
39
|
+
}, {
|
|
40
|
+
city: 'Portland',
|
|
41
|
+
state: 'Oregon'
|
|
42
|
+
}, {
|
|
43
|
+
city: 'Seattle',
|
|
44
|
+
state: 'Washington'
|
|
45
|
+
}];
|
|
46
|
+
var Sizable = exports.Sizable = function Sizable() {
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
48
|
+
fill: true
|
|
49
|
+
}, /*#__PURE__*/_react["default"].createElement(_Cards.Cards, {
|
|
50
|
+
id: "myGrid",
|
|
51
|
+
data: data,
|
|
52
|
+
pad: "medium",
|
|
53
|
+
columns: ['flex', 'flex', 'flex'],
|
|
54
|
+
rows: "xsmall",
|
|
55
|
+
sizeKey: "size"
|
|
56
|
+
}, function (datum) {
|
|
57
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Card, {
|
|
58
|
+
key: datum.city,
|
|
59
|
+
pad: "small",
|
|
60
|
+
elevation: "medium"
|
|
61
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.CardBody, null, /*#__PURE__*/_react["default"].createElement(_grommet.Heading, {
|
|
62
|
+
level: 2,
|
|
63
|
+
size: "small",
|
|
64
|
+
margin: "none"
|
|
65
|
+
}, datum.city), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, datum.state)));
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
var _default = exports["default"] = {
|
|
69
|
+
title: 'Visualizations/Cards/Sizable'
|
|
70
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.OnOrder = void 0;
|
|
5
|
+
var _react = _interopRequireDefault(require("react"));
|
|
6
|
+
var _grommet = require("grommet");
|
|
7
|
+
var _Cards = require("../Cards");
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
var data = [{
|
|
10
|
+
id: 'bo',
|
|
11
|
+
city: 'Boise',
|
|
12
|
+
state: 'Idaho'
|
|
13
|
+
}, {
|
|
14
|
+
id: 'fc',
|
|
15
|
+
city: 'Fort Collins',
|
|
16
|
+
state: 'Colorado'
|
|
17
|
+
}, {
|
|
18
|
+
id: 'ba',
|
|
19
|
+
city: 'Bay Area',
|
|
20
|
+
state: 'California'
|
|
21
|
+
}, {
|
|
22
|
+
id: 'sd',
|
|
23
|
+
city: 'San Diego',
|
|
24
|
+
state: 'California'
|
|
25
|
+
}, {
|
|
26
|
+
id: 'sf',
|
|
27
|
+
city: 'San Francisco',
|
|
28
|
+
state: 'California'
|
|
29
|
+
}, {
|
|
30
|
+
id: 'la',
|
|
31
|
+
city: 'Los Angeles',
|
|
32
|
+
state: 'California'
|
|
33
|
+
}, {
|
|
34
|
+
id: 'pt',
|
|
35
|
+
city: 'Portland',
|
|
36
|
+
state: 'Oregon'
|
|
37
|
+
}, {
|
|
38
|
+
id: 'se',
|
|
39
|
+
city: 'Seattle',
|
|
40
|
+
state: 'Washington'
|
|
41
|
+
}];
|
|
42
|
+
var OnOrder = exports.OnOrder = function OnOrder() {
|
|
43
|
+
var _React$useState = _react["default"].useState(data),
|
|
44
|
+
orderedData = _React$useState[0],
|
|
45
|
+
setOrderedData = _React$useState[1];
|
|
46
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Box, {
|
|
47
|
+
fill: true
|
|
48
|
+
}, /*#__PURE__*/_react["default"].createElement(_Cards.Cards, {
|
|
49
|
+
id: "myGrid",
|
|
50
|
+
data: orderedData,
|
|
51
|
+
pad: "medium",
|
|
52
|
+
columns: ['flex', 'flex', 'flex'],
|
|
53
|
+
onOrder: setOrderedData
|
|
54
|
+
}, function (datum) {
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement(_grommet.Card, {
|
|
56
|
+
key: datum.city,
|
|
57
|
+
pad: "medium",
|
|
58
|
+
elevation: "medium"
|
|
59
|
+
}, /*#__PURE__*/_react["default"].createElement(_grommet.CardBody, null, /*#__PURE__*/_react["default"].createElement(_grommet.Heading, {
|
|
60
|
+
level: 2,
|
|
61
|
+
size: "small",
|
|
62
|
+
margin: "none"
|
|
63
|
+
}, datum.city), /*#__PURE__*/_react["default"].createElement(_grommet.Text, null, datum.state)));
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
OnOrder.storyName = 'onOrder';
|
|
67
|
+
var _default = exports["default"] = {
|
|
68
|
+
title: 'Visualizations/Cards/onOrder'
|
|
69
|
+
};
|
|
@@ -43,26 +43,6 @@ var generateOptions = function generateOptions(data, property) {
|
|
|
43
43
|
return 0;
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
// ensure floating point calculations are in integers
|
|
48
|
-
var alignMax = function alignMax(value, interval) {
|
|
49
|
-
var multiplier = Math.pow(10, Math.max((0, _RangeSelector2.getDecimalCount)(value), (0, _RangeSelector2.getDecimalCount)(interval)));
|
|
50
|
-
var integerValue = value * multiplier;
|
|
51
|
-
var integerInterval = interval * multiplier;
|
|
52
|
-
if (value > 0) return (integerValue - integerValue % integerInterval + integerInterval) / multiplier;
|
|
53
|
-
if (value < 0) return (integerValue + integerValue % integerInterval) / multiplier;
|
|
54
|
-
return value;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// ensure floating point calculations are in integers
|
|
58
|
-
var alignMin = function alignMin(value, interval) {
|
|
59
|
-
var multiplier = Math.pow(10, Math.max((0, _RangeSelector2.getDecimalCount)(value), (0, _RangeSelector2.getDecimalCount)(interval)));
|
|
60
|
-
var integerValue = value * multiplier;
|
|
61
|
-
var integerInterval = interval * multiplier;
|
|
62
|
-
if (value > 0) return (integerValue - integerValue % integerInterval) / multiplier;
|
|
63
|
-
if (value < 0) return (integerValue - integerValue % integerInterval - integerInterval) / multiplier;
|
|
64
|
-
return value;
|
|
65
|
-
};
|
|
66
46
|
var booleanOptions = [{
|
|
67
47
|
label: 'true',
|
|
68
48
|
value: true
|
|
@@ -100,21 +80,24 @@ var DataFilter = exports.DataFilter = function DataFilter(_ref) {
|
|
|
100
80
|
|
|
101
81
|
// generate options from all values for property
|
|
102
82
|
var uniqueValues = generateOptions(unfilteredData || data, property);
|
|
103
|
-
// if
|
|
104
|
-
|
|
83
|
+
// if no values, nothing to filter
|
|
84
|
+
// uniqueValues.length === 0 allows single item/value filters to render
|
|
85
|
+
if (uniqueValues.length === 0) return [undefined, undefined];
|
|
105
86
|
// if any values aren't numeric, treat as options
|
|
106
87
|
if (uniqueValues.some(function (v) {
|
|
107
88
|
return v !== undefined && typeof v !== 'number';
|
|
108
89
|
})) return [uniqueValues, undefined];
|
|
109
90
|
// all values are numeric, treat as range
|
|
110
|
-
var delta = uniqueValues[uniqueValues.length - 1] - uniqueValues[0];
|
|
111
|
-
var interval = Number.parseFloat((delta / 3).toPrecision(1));
|
|
112
91
|
var min = uniqueValues[0];
|
|
113
92
|
var max = uniqueValues[uniqueValues.length - 1];
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
93
|
+
// Clean up floating-point precision artifacts, capped to 2 decimal places.
|
|
94
|
+
// Use floor for min and ceil for max so actual data values always fall
|
|
95
|
+
// within the computed range (e.g. -4.859 stays inside [-19.99, -4.85]).
|
|
96
|
+
var maxDecimalPlaces = Math.max((0, _RangeSelector2.getDecimalCount)(uniqueValues[0]), (0, _RangeSelector2.getDecimalCount)(uniqueValues[uniqueValues.length - 1]));
|
|
97
|
+
if (maxDecimalPlaces > 0) {
|
|
98
|
+
var multiplier = Math.pow(10, Math.min(maxDecimalPlaces, 2));
|
|
99
|
+
min = Math.floor(min * multiplier) / multiplier;
|
|
100
|
+
max = Math.ceil(max * multiplier) / multiplier;
|
|
118
101
|
}
|
|
119
102
|
return [undefined, [min, max]];
|
|
120
103
|
}, [children, data, optionsProp, properties, property, rangeProp, unfilteredData]),
|
|
@@ -162,6 +145,16 @@ var DataFilter = exports.DataFilter = function DataFilter(_ref) {
|
|
|
162
145
|
var multiplier = Math.pow(10, decimalCount);
|
|
163
146
|
step = multiplier * delta / (multiplier * defaultRangeSteps);
|
|
164
147
|
} else step = delta / defaultRangeSteps;
|
|
148
|
+
|
|
149
|
+
// Cap step to maximum 2 decimal places to avoid long
|
|
150
|
+
// precision artifacts
|
|
151
|
+
var stepMultiplier = Math.pow(10, 2);
|
|
152
|
+
step = Math.round(step * stepMultiplier) / stepMultiplier;
|
|
153
|
+
|
|
154
|
+
// Ensure step is never 0 or negative (required for RangeSelector)
|
|
155
|
+
if (step <= 0) {
|
|
156
|
+
step = Math.pow(10, -(Math.max((0, _RangeSelector2.getDecimalCount)(range[0]), (0, _RangeSelector2.getDecimalCount)(range[1])) || 1));
|
|
157
|
+
}
|
|
165
158
|
}
|
|
166
159
|
content = /*#__PURE__*/_react["default"].createElement(_RangeSelector.RangeSelector, _extends({
|
|
167
160
|
"aria-label": ariaLabel,
|
|
@@ -90,18 +90,45 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
90
90
|
var ref = (0, _utils.useForwardedRef)(refArg);
|
|
91
91
|
var containerRef = (0, _react.useRef)();
|
|
92
92
|
var readOnly = readOnlyProp || readOnlyCopy;
|
|
93
|
+
var bounds = calendarProps == null ? void 0 : calendarProps.bounds;
|
|
94
|
+
var validateBoundsForForm = (0, _react.useCallback)(function (fieldValue) {
|
|
95
|
+
if (!bounds || !fieldValue) return undefined;
|
|
96
|
+
var isValid = (0, _utils2.validateBounds)(bounds, fieldValue);
|
|
97
|
+
if (!isValid) {
|
|
98
|
+
var _bounds$map = bounds.map(function (date) {
|
|
99
|
+
return (0, _utils.setHoursWithOffset)(date).toISOString();
|
|
100
|
+
}),
|
|
101
|
+
startBound = _bounds$map[0],
|
|
102
|
+
endBound = _bounds$map[1];
|
|
103
|
+
if (startBound && endBound) {
|
|
104
|
+
return formatMessage({
|
|
105
|
+
id: 'dateInput.outOfBounds',
|
|
106
|
+
messages: messages,
|
|
107
|
+
values: {
|
|
108
|
+
start: new Date(startBound).toLocaleDateString(),
|
|
109
|
+
end: new Date(endBound).toLocaleDateString()
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}, [bounds, formatMessage, messages]);
|
|
93
116
|
var _useFormInput = useFormInput({
|
|
94
117
|
name: name,
|
|
95
118
|
value: valueArg,
|
|
96
|
-
initialValue: defaultValue
|
|
119
|
+
initialValue: defaultValue,
|
|
120
|
+
validate: bounds ? validateBoundsForForm : undefined
|
|
97
121
|
}),
|
|
98
122
|
value = _useFormInput[0],
|
|
99
123
|
setValue = _useFormInput[1];
|
|
100
124
|
var usingKeyboard = (0, _utils.useKeyboard)();
|
|
101
125
|
var CalendarIcon = ((_theme$dateInput$icon2 = theme.dateInput.icon) == null ? void 0 : _theme$dateInput$icon2.calendar) || _Calendar.Calendar;
|
|
102
|
-
var _useState = (0, _react.useState)(
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
var _useState = (0, _react.useState)(true),
|
|
127
|
+
withinBounds = _useState[0],
|
|
128
|
+
setWithinBounds = _useState[1];
|
|
129
|
+
var _useState2 = (0, _react.useState)((0, _Calendar3.getOutputFormat)(value)),
|
|
130
|
+
outputFormat = _useState2[0],
|
|
131
|
+
setOutputFormat = _useState2[1];
|
|
105
132
|
(0, _react.useEffect)(function () {
|
|
106
133
|
setOutputFormat(function (previousFormat) {
|
|
107
134
|
var nextFormat = (0, _Calendar3.getOutputFormat)(value);
|
|
@@ -111,11 +138,19 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
111
138
|
return previousFormat !== nextFormat ? previousFormat : nextFormat;
|
|
112
139
|
});
|
|
113
140
|
}, [value]);
|
|
141
|
+
(0, _react.useEffect)(function () {
|
|
142
|
+
if (value === undefined || bounds === undefined) {
|
|
143
|
+
setWithinBounds(true);
|
|
144
|
+
} else {
|
|
145
|
+
var validNextValue = (0, _utils2.validateBounds)(bounds, value);
|
|
146
|
+
setWithinBounds(validNextValue);
|
|
147
|
+
}
|
|
148
|
+
}, [value, bounds]);
|
|
114
149
|
|
|
115
150
|
// keep track of timestamp from original date(s)
|
|
116
|
-
var
|
|
117
|
-
reference =
|
|
118
|
-
setReference =
|
|
151
|
+
var _useState3 = (0, _react.useState)(getReference(value)),
|
|
152
|
+
reference = _useState3[0],
|
|
153
|
+
setReference = _useState3[1];
|
|
119
154
|
|
|
120
155
|
// do we expect multiple dates?
|
|
121
156
|
var range = Array.isArray(value) || format && format.includes('-');
|
|
@@ -131,9 +166,9 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
131
166
|
}, [schema]);
|
|
132
167
|
|
|
133
168
|
// textValue is only used when a format is provided
|
|
134
|
-
var
|
|
135
|
-
textValue =
|
|
136
|
-
setTextValue =
|
|
169
|
+
var _useState4 = (0, _react.useState)(schema ? (0, _utils2.valueToText)(value, schema) : undefined),
|
|
170
|
+
textValue = _useState4[0],
|
|
171
|
+
setTextValue = _useState4[1];
|
|
137
172
|
var readOnlyCopyValidation = formatMessage({
|
|
138
173
|
id: 'input.readOnlyCopy.validation',
|
|
139
174
|
messages: messages
|
|
@@ -142,9 +177,9 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
142
177
|
id: 'input.readOnlyCopy.prompt',
|
|
143
178
|
messages: messages
|
|
144
179
|
});
|
|
145
|
-
var
|
|
146
|
-
tip =
|
|
147
|
-
setTip =
|
|
180
|
+
var _useState5 = (0, _react.useState)(readOnlyCopyPrompt),
|
|
181
|
+
tip = _useState5[0],
|
|
182
|
+
setTip = _useState5[1];
|
|
148
183
|
|
|
149
184
|
// Setting the icon through `inputProps` is deprecated.
|
|
150
185
|
// The `icon` prop should be used instead.
|
|
@@ -196,9 +231,9 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
196
231
|
}, [schema, ref]);
|
|
197
232
|
|
|
198
233
|
// when format and not inline, whether to show the Calendar in a Drop
|
|
199
|
-
var
|
|
200
|
-
open =
|
|
201
|
-
setOpen =
|
|
234
|
+
var _useState6 = (0, _react.useState)(),
|
|
235
|
+
open = _useState6[0],
|
|
236
|
+
setOpen = _useState6[1];
|
|
202
237
|
var openCalendar = (0, _react.useCallback)(function () {
|
|
203
238
|
setOpen(true);
|
|
204
239
|
announce(formatMessage({
|
|
@@ -328,6 +363,7 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
328
363
|
readOnlyProp: readOnly,
|
|
329
364
|
fill: true
|
|
330
365
|
}, passThemeFlag), reverse && (!readOnly || readOnlyCopy) && DateInputButton, /*#__PURE__*/_react["default"].createElement(_MaskedInput.MaskedInput, _extends({
|
|
366
|
+
"aria-invalid": bounds && !withinBounds ? true : undefined,
|
|
331
367
|
readOnly: readOnly,
|
|
332
368
|
ref: ref,
|
|
333
369
|
id: id,
|
|
@@ -342,17 +378,15 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
342
378
|
var nextTextValue = event.target.value;
|
|
343
379
|
setTextValue(nextTextValue);
|
|
344
380
|
var nextValue = (0, _utils2.textToValue)(nextTextValue, schema, range, reference, outputFormat);
|
|
345
|
-
var
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
if (validatedNextValue !== undefined) setReference(getReference(validatedNextValue));
|
|
381
|
+
var validNextValue = (0, _utils2.validateBounds)(bounds, nextValue);
|
|
382
|
+
setWithinBounds(validNextValue);
|
|
383
|
+
if (nextValue !== undefined) setReference(getReference(nextValue));
|
|
350
384
|
// update value even when undefined
|
|
351
|
-
setValue(
|
|
385
|
+
setValue(nextValue);
|
|
352
386
|
if (_onChange) {
|
|
353
387
|
event.persist(); // extract from React synthetic event pool
|
|
354
388
|
var adjustedEvent = event;
|
|
355
|
-
adjustedEvent.value =
|
|
389
|
+
adjustedEvent.value = nextValue;
|
|
356
390
|
_onChange(adjustedEvent);
|
|
357
391
|
}
|
|
358
392
|
},
|
|
@@ -372,7 +406,6 @@ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
372
406
|
if (open && !readOnly) {
|
|
373
407
|
return [input, /*#__PURE__*/_react["default"].createElement(_Drop.Drop, _extends({
|
|
374
408
|
key: "drop",
|
|
375
|
-
overflow: "visible",
|
|
376
409
|
id: id ? id + "__drop" : undefined,
|
|
377
410
|
target: containerRef.current,
|
|
378
411
|
align: _extends({}, calendarDropdownAlign, dropProps),
|
|
@@ -122,7 +122,7 @@ var pullDigits = function pullDigits(text, index) {
|
|
|
122
122
|
return text.slice(index, end);
|
|
123
123
|
};
|
|
124
124
|
var validateBounds = exports.validateBounds = function validateBounds(dateBounds, selectedDate) {
|
|
125
|
-
if (!dateBounds || !selectedDate) return
|
|
125
|
+
if (!dateBounds || !selectedDate) return true;
|
|
126
126
|
var _dateBounds$map = dateBounds.map(function (date) {
|
|
127
127
|
return (0, _utils.setHoursWithOffset)(date).toISOString();
|
|
128
128
|
}),
|
|
@@ -134,7 +134,7 @@ var validateBounds = exports.validateBounds = function validateBounds(dateBounds
|
|
|
134
134
|
var validSelection = isoSelectedDates.every(function (isoSelectedDate) {
|
|
135
135
|
return !endDate && startDate === isoSelectedDate || isoSelectedDate >= startDate && isoSelectedDate <= endDate;
|
|
136
136
|
});
|
|
137
|
-
return validSelection
|
|
137
|
+
return validSelection;
|
|
138
138
|
};
|
|
139
139
|
var textToValue = exports.textToValue = function textToValue(text, schema, range, reference, outputFormat) {
|
|
140
140
|
if (!text) return range ? [] : undefined;
|
|
@@ -178,9 +178,10 @@ var DropContainer = exports.DropContainer = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
178
178
|
|
|
179
179
|
/* If responsive is true and the Drop doesn't have enough room
|
|
180
180
|
to be fully visible and there is more room in the other
|
|
181
|
-
direction, change the Drop to display above/below. If
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
direction, change the Drop to display above/below. If neither
|
|
182
|
+
direction has enough room for the full Drop, prefer the side
|
|
183
|
+
with more available space rather than clamping to the side
|
|
184
|
+
originally requested. */
|
|
184
185
|
if (responsive &&
|
|
185
186
|
// drop is above target
|
|
186
187
|
align.bottom === 'top' &&
|
|
@@ -225,6 +226,61 @@ var DropContainer = exports.DropContainer = /*#__PURE__*/(0, _react.forwardRef)(
|
|
|
225
226
|
// top of drop is aligned to top of target
|
|
226
227
|
top = targetRect.top;
|
|
227
228
|
maxHeight = bottom;
|
|
229
|
+
} else if (responsive &&
|
|
230
|
+
// top of drop is aligned to bottom of target (open below)
|
|
231
|
+
align.top === 'bottom' &&
|
|
232
|
+
// drop is overflowing below window
|
|
233
|
+
targetRect.bottom + containerRect.height >= windowHeight &&
|
|
234
|
+
// the flip anchor (target's top) is on-screen — otherwise
|
|
235
|
+
// flipping pins the drop's bottom off-screen
|
|
236
|
+
targetRect.top > 0 &&
|
|
237
|
+
// there is more room above the target than below it — neither
|
|
238
|
+
// side fits the full drop, so prefer the larger side rather
|
|
239
|
+
// than clamping to the smaller requested side.
|
|
240
|
+
targetRect.top > windowHeight - targetRect.bottom) {
|
|
241
|
+
// bottom of drop is aligned to top of target
|
|
242
|
+
bottom = targetRect.top;
|
|
243
|
+
maxHeight = bottom;
|
|
244
|
+
} else if (responsive &&
|
|
245
|
+
// top of drop is aligned to top of target (open below)
|
|
246
|
+
align.top === 'top' &&
|
|
247
|
+
// drop is overflowing below window
|
|
248
|
+
targetRect.top + containerRect.height >= windowHeight &&
|
|
249
|
+
// height of the drop is larger than the target — otherwise the
|
|
250
|
+
// drop already fits inside the target's vertical span and a
|
|
251
|
+
// flip would pin its bottom to a potentially off-screen
|
|
252
|
+
// target.bottom (mirrors the safety in branch #2 above).
|
|
253
|
+
targetRect.top + containerRect.height > targetRect.bottom &&
|
|
254
|
+
// there is more room above the target than below it
|
|
255
|
+
targetRect.bottom > windowHeight - targetRect.top) {
|
|
256
|
+
// bottom of drop is aligned to bottom of target
|
|
257
|
+
bottom = targetRect.bottom;
|
|
258
|
+
maxHeight = bottom;
|
|
259
|
+
} else if (responsive &&
|
|
260
|
+
// bottom of drop is aligned to top of target (open above)
|
|
261
|
+
align.bottom === 'top' &&
|
|
262
|
+
// drop is overflowing above window
|
|
263
|
+
targetRect.top - containerRect.height <= 0 &&
|
|
264
|
+
// the flip anchor (target's bottom) is on-screen
|
|
265
|
+
targetRect.bottom < windowHeight &&
|
|
266
|
+
// there is more room below the target than above it
|
|
267
|
+
windowHeight - targetRect.bottom > targetRect.top) {
|
|
268
|
+
// top of drop is aligned to bottom of target
|
|
269
|
+
top = targetRect.bottom;
|
|
270
|
+
maxHeight = windowHeight - top;
|
|
271
|
+
} else if (responsive &&
|
|
272
|
+
// bottom of drop is aligned to bottom of target (open above)
|
|
273
|
+
align.bottom === 'bottom' &&
|
|
274
|
+
// drop is overflowing above window
|
|
275
|
+
targetRect.bottom - containerRect.height <= 0 &&
|
|
276
|
+
// height of the drop is larger than the target (mirrors the
|
|
277
|
+
// safety in branch #4 above)
|
|
278
|
+
targetRect.bottom - containerRect.height < targetRect.top &&
|
|
279
|
+
// there is more room below the target than above it
|
|
280
|
+
windowHeight - targetRect.top > targetRect.bottom) {
|
|
281
|
+
// top of drop is aligned to top of target
|
|
282
|
+
top = targetRect.top;
|
|
283
|
+
maxHeight = windowHeight - top;
|
|
228
284
|
} else if (align.top === 'top') {
|
|
229
285
|
top = targetRect.top;
|
|
230
286
|
maxHeight = windowHeight - top;
|
|
@@ -293,6 +293,9 @@ var FileInput = exports.FileInput = /*#__PURE__*/(0, _react.forwardRef)(function
|
|
|
293
293
|
onChange: function onChange(event) {
|
|
294
294
|
event.persist();
|
|
295
295
|
var fileList = event.target.files;
|
|
296
|
+
// If the user cancelled the file picker, fileList will be empty
|
|
297
|
+
// and we should not clear any previously selected files.
|
|
298
|
+
if (!fileList.length && files.length) return;
|
|
296
299
|
var nextFiles = multiple ? [].concat(files) : [];
|
|
297
300
|
var _loop = function _loop(i) {
|
|
298
301
|
// avoid duplicates
|
|
@@ -67,7 +67,13 @@ var customTheme = (0, _utils.deepMerge)(_grommet.grommet, {
|
|
|
67
67
|
var FieldCustomStates = exports.FieldCustomStates = function FieldCustomStates() {
|
|
68
68
|
var inputRef = (0, _react.useRef)();
|
|
69
69
|
(0, _react.useEffect)(function () {
|
|
70
|
-
|
|
70
|
+
var focusTimeout = setTimeout(function () {
|
|
71
|
+
var _inputRef$current;
|
|
72
|
+
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
73
|
+
});
|
|
74
|
+
return function () {
|
|
75
|
+
return clearTimeout(focusTimeout);
|
|
76
|
+
};
|
|
71
77
|
}, []);
|
|
72
78
|
return /*#__PURE__*/_react["default"].createElement(_grommet.Grommet, {
|
|
73
79
|
theme: customTheme
|
|
@@ -8,7 +8,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
8
8
|
var FieldStates = exports.FieldStates = function FieldStates() {
|
|
9
9
|
var inputRef = (0, _react.useRef)();
|
|
10
10
|
(0, _react.useEffect)(function () {
|
|
11
|
-
|
|
11
|
+
var focusTimeout = setTimeout(function () {
|
|
12
|
+
var _inputRef$current;
|
|
13
|
+
(_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
|
|
14
|
+
});
|
|
15
|
+
return function () {
|
|
16
|
+
return clearTimeout(focusTimeout);
|
|
17
|
+
};
|
|
12
18
|
}, []);
|
|
13
19
|
return (
|
|
14
20
|
/*#__PURE__*/
|
|
@@ -79,7 +79,8 @@ var Grommet = exports.Grommet = /*#__PURE__*/(0, _react.forwardRef)(function (pr
|
|
|
79
79
|
}, [messagesProp]);
|
|
80
80
|
(0, _react.useEffect)(function () {
|
|
81
81
|
var onResize = function onResize() {
|
|
82
|
-
|
|
82
|
+
var _document$body$client, _document$body;
|
|
83
|
+
setResponsive((0, _utils.getBreakpoint)((_document$body$client = (_document$body = document.body) == null ? void 0 : _document$body.clientWidth) != null ? _document$body$client : window.innerWidth, theme));
|
|
83
84
|
};
|
|
84
85
|
window.addEventListener('resize', onResize);
|
|
85
86
|
onResize();
|
|
@@ -31,6 +31,11 @@ export interface GrommetProps {
|
|
|
31
31
|
nextMove?: string;
|
|
32
32
|
next?: string;
|
|
33
33
|
};
|
|
34
|
+
cards?: {
|
|
35
|
+
moved?: string;
|
|
36
|
+
reorderHint?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
};
|
|
34
39
|
carousel?: {
|
|
35
40
|
previous?: string;
|
|
36
41
|
next?: string;
|
|
@@ -40,6 +45,7 @@ export interface GrommetProps {
|
|
|
40
45
|
openCalendar?: string;
|
|
41
46
|
enterCalendar?: string;
|
|
42
47
|
exitCalendar?: string;
|
|
48
|
+
outOfBounds?: string;
|
|
43
49
|
};
|
|
44
50
|
dataChart?: {
|
|
45
51
|
detailTitle?: string;
|
|
@@ -38,6 +38,11 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
38
38
|
nextMove: _propTypes["default"].string,
|
|
39
39
|
next: _propTypes["default"].string
|
|
40
40
|
}),
|
|
41
|
+
cards: _propTypes["default"].shape({
|
|
42
|
+
moved: _propTypes["default"].string,
|
|
43
|
+
reorderHint: _propTypes["default"].string,
|
|
44
|
+
description: _propTypes["default"].string
|
|
45
|
+
}),
|
|
41
46
|
carousel: _propTypes["default"].shape({
|
|
42
47
|
previous: _propTypes["default"].string,
|
|
43
48
|
next: _propTypes["default"].string,
|
|
@@ -46,7 +51,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
46
51
|
dateInput: _propTypes["default"].shape({
|
|
47
52
|
openCalendar: _propTypes["default"].string,
|
|
48
53
|
enterCalendar: _propTypes["default"].string,
|
|
49
|
-
exitCalendar: _propTypes["default"].string
|
|
54
|
+
exitCalendar: _propTypes["default"].string,
|
|
55
|
+
outOfBounds: _propTypes["default"].string
|
|
50
56
|
}),
|
|
51
57
|
dataChart: _propTypes["default"].shape({
|
|
52
58
|
detailTitle: _propTypes["default"].string,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnimateType,
|
|
3
|
+
BackgroundType,
|
|
4
|
+
KeyboardType,
|
|
5
|
+
MarginType,
|
|
6
|
+
} from 'grommet/utils';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { LayerPositionType } from '.';
|
|
9
|
+
|
|
10
|
+
interface LayerContainerProps {
|
|
11
|
+
animate?: AnimateType;
|
|
12
|
+
animation?: 'none' | 'slide' | 'fadeIn' | boolean;
|
|
13
|
+
background?: BackgroundType;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
full?: boolean | 'vertical' | 'horizontal';
|
|
16
|
+
id?: string;
|
|
17
|
+
margin?: MarginType;
|
|
18
|
+
modal?: boolean;
|
|
19
|
+
onClickOutside?: (
|
|
20
|
+
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
21
|
+
) => void;
|
|
22
|
+
onEsc?: KeyboardType;
|
|
23
|
+
plain?: boolean;
|
|
24
|
+
position?: LayerPositionType;
|
|
25
|
+
responsive?: boolean;
|
|
26
|
+
target?: object;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type divProps = React.DetailedHTMLProps<
|
|
30
|
+
React.HTMLAttributes<HTMLDivElement>,
|
|
31
|
+
HTMLDivElement
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
interface LayerContainerExtendedProps extends LayerContainerProps, divProps {}
|
|
35
|
+
|
|
36
|
+
declare const LayerContainer: React.ForwardRefExoticComponent<
|
|
37
|
+
LayerContainerExtendedProps & React.RefAttributes<HTMLDivElement>
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
export { LayerContainer };
|