grommet 2.54.0 → 2.56.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/Button/Button.js +7 -4
- package/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +86 -0
- 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/FormField/FormField.js +1 -1
- package/components/Grommet/Grommet.js +2 -1
- package/components/Grommet/index.d.ts +27 -0
- package/components/Grommet/propTypes.js +33 -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/Stepper/StepConnector.js +68 -0
- package/components/Stepper/Stepper.js +309 -0
- package/components/Stepper/StepperContext.js +43 -0
- package/components/Stepper/StepperDescription.js +26 -0
- package/components/Stepper/StepperHelperText.js +44 -0
- package/components/Stepper/StepperIndicator.js +74 -0
- package/components/Stepper/StepperLabel.js +41 -0
- package/components/Stepper/StepperStep.js +127 -0
- package/components/Stepper/StyledStepper.js +124 -0
- package/components/Stepper/index.d.ts +80 -0
- package/components/Stepper/index.js +18 -0
- package/components/Stepper/propTypes.js +35 -0
- package/components/Stepper/stories/DisabledSteps.stories.js +45 -0
- package/components/Stepper/stories/ErrorStates.stories.js +45 -0
- package/components/Stepper/stories/HorizontalSteps.stories.js +50 -0
- package/components/Stepper/stories/Interactive.stories.js +60 -0
- package/components/Stepper/stories/KeyboardNavigation.stories.js +64 -0
- package/components/Stepper/stories/NestedSubSteps.stories.js +70 -0
- package/components/Stepper/stories/ReadOnly.stories.js +43 -0
- package/components/Stepper/stories/ThemingLightDark.stories.js +58 -0
- package/components/Stepper/stories/VerticalSteps.stories.js +67 -0
- package/components/Tab/Tab.js +19 -6
- package/components/Tabs/Tabs.js +156 -22
- 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/components/TimeInput/README.md +2 -0
- package/components/TimeInput/StyledTimeInput.js +73 -0
- package/components/TimeInput/TimeInput.js +689 -0
- package/components/TimeInput/TimeInputPopup.js +393 -0
- package/components/TimeInput/index.d.ts +41 -0
- package/components/TimeInput/index.js +6 -0
- package/components/TimeInput/propTypes.js +35 -0
- package/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/components/TimeInput/useSectionedTimeField.js +359 -0
- package/components/TimeInput/utils.js +187 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +12 -0
- package/es6/components/Button/Button.js +7 -4
- package/es6/components/Button/stories/CustomThemed/ChildrenPlainOption.stories.js +81 -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/FormField/FormField.js +1 -1
- package/es6/components/Grommet/Grommet.js +2 -1
- package/es6/components/Grommet/index.d.ts +27 -0
- package/es6/components/Grommet/propTypes.js +33 -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/Stepper/StepConnector.js +63 -0
- package/es6/components/Stepper/Stepper.js +306 -0
- package/es6/components/Stepper/StepperContext.js +39 -0
- package/es6/components/Stepper/StepperDescription.js +21 -0
- package/es6/components/Stepper/StepperHelperText.js +39 -0
- package/es6/components/Stepper/StepperIndicator.js +69 -0
- package/es6/components/Stepper/StepperLabel.js +36 -0
- package/es6/components/Stepper/StepperStep.js +122 -0
- package/es6/components/Stepper/StyledStepper.js +120 -0
- package/es6/components/Stepper/index.d.ts +80 -0
- package/es6/components/Stepper/index.js +6 -0
- package/es6/components/Stepper/propTypes.js +30 -0
- package/es6/components/Stepper/stories/DisabledSteps.stories.js +41 -0
- package/es6/components/Stepper/stories/ErrorStates.stories.js +41 -0
- package/es6/components/Stepper/stories/HorizontalSteps.stories.js +46 -0
- package/es6/components/Stepper/stories/Interactive.stories.js +56 -0
- package/es6/components/Stepper/stories/KeyboardNavigation.stories.js +60 -0
- package/es6/components/Stepper/stories/NestedSubSteps.stories.js +66 -0
- package/es6/components/Stepper/stories/ReadOnly.stories.js +39 -0
- package/es6/components/Stepper/stories/ThemingLightDark.stories.js +54 -0
- package/es6/components/Stepper/stories/VerticalSteps.stories.js +63 -0
- package/es6/components/Tab/Tab.js +19 -6
- package/es6/components/Tabs/Tabs.js +157 -23
- 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/components/TimeInput/README.md +2 -0
- package/es6/components/TimeInput/StyledTimeInput.js +68 -0
- package/es6/components/TimeInput/TimeInput.js +685 -0
- package/es6/components/TimeInput/TimeInputPopup.js +389 -0
- package/es6/components/TimeInput/index.d.ts +41 -0
- package/es6/components/TimeInput/index.js +1 -0
- package/es6/components/TimeInput/propTypes.js +30 -0
- package/es6/components/TimeInput/stories/Controlled.stories.tsx +29 -0
- package/es6/components/TimeInput/stories/Disabled.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Form.stories.tsx +38 -0
- package/es6/components/TimeInput/stories/ReadOnly.stories.tsx +13 -0
- package/es6/components/TimeInput/stories/Simple.stories.tsx +19 -0
- package/es6/components/TimeInput/stories/Step.stories.tsx +14 -0
- package/es6/components/TimeInput/stories/ThemingLightDark.stories.tsx +22 -0
- package/es6/components/TimeInput/stories/Uncontrolled.stories.tsx +22 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +356 -0
- package/es6/components/TimeInput/utils.js +183 -0
- package/es6/components/index.d.ts +2 -0
- package/es6/components/index.js +2 -0
- package/es6/index.d.ts +2 -0
- package/es6/languages/default.json +27 -1
- package/es6/themes/base.d.ts +109 -0
- package/es6/themes/base.js +208 -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/index.d.ts +2 -0
- package/languages/default.json +27 -1
- package/package.json +51 -53
- package/themes/base.d.ts +109 -0
- package/themes/base.js +208 -0
- package/utils/index.d.ts +1 -0
- package/utils/styles.js +23 -12
- package/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -79
- package/es6/components/TextInput/stories/CustomThemed/CustomSuggestions.stories.tsx +0 -180
- package/es6/components/TextInput/stories/CustomThemed/Themed.stories.js +0 -74
|
@@ -3,21 +3,51 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.Cards = void 0;
|
|
5
5
|
var _react = _interopRequireWildcard(require("react"));
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
|
+
var _AnnounceContext = require("../../contexts/AnnounceContext");
|
|
6
8
|
var _DataContext = require("../../contexts/DataContext");
|
|
9
|
+
var _MessageContext = require("../../contexts/MessageContext");
|
|
7
10
|
var _Box = require("../Box");
|
|
8
11
|
var _Card = require("../Card");
|
|
9
12
|
var _CardBody = require("../CardBody");
|
|
10
13
|
var _Grid = require("../Grid");
|
|
11
14
|
var _InfiniteScroll = require("../InfiniteScroll");
|
|
15
|
+
var _Keyboard = require("../Keyboard");
|
|
12
16
|
var _Pagination = require("../Pagination");
|
|
13
17
|
var _utils = require("../../utils");
|
|
14
18
|
var _propTypes = require("./propTypes");
|
|
15
19
|
var _useThemeValue2 = require("../../utils/useThemeValue");
|
|
16
|
-
var
|
|
20
|
+
var _StyledCellContainer = require("./StyledCellContainer");
|
|
21
|
+
var _excluded = ["as", "children", "data", "margin", "onMore", "pad", "paginate", "show", "size", "step", "sizeKey", "onOrder"],
|
|
22
|
+
_excluded2 = ["keyboard"];
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
24
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
18
25
|
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); }
|
|
19
26
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
20
27
|
var emptyData = [];
|
|
28
|
+
var HiddenText = _styledComponents["default"].span.withConfig({
|
|
29
|
+
displayName: "Cards__HiddenText",
|
|
30
|
+
componentId: "sc-1f9ilr5-0"
|
|
31
|
+
})(["position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;"]);
|
|
32
|
+
var indexForItem = function indexForItem(data, item) {
|
|
33
|
+
var index = data.indexOf(item);
|
|
34
|
+
if (index === -1) {
|
|
35
|
+
// If the item isn't in the data, try to find it by id. This allows for
|
|
36
|
+
// reordering to work when the items provided to Cards are different objects
|
|
37
|
+
// than those in the data array, as long as they share an id.
|
|
38
|
+
return data.findIndex(function (d) {
|
|
39
|
+
return d.id === item.id;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return index;
|
|
43
|
+
};
|
|
44
|
+
var reorder = function reorder(array, source, target) {
|
|
45
|
+
var result = array.slice(0);
|
|
46
|
+
var tmp = result[source];
|
|
47
|
+
if (source < target) for (var i = source; i < target; i += 1) result[i] = result[i + 1];else for (var _i = source; _i > target; _i -= 1) result[_i] = result[_i - 1];
|
|
48
|
+
result[target] = tmp;
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
21
51
|
var Cards = exports.Cards = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
22
52
|
var _ref$as = _ref.as,
|
|
23
53
|
as = _ref$as === void 0 ? 'ul' : _ref$as,
|
|
@@ -31,12 +61,19 @@ var Cards = exports.Cards = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
31
61
|
size = _ref.size,
|
|
32
62
|
_ref$step = _ref.step,
|
|
33
63
|
step = _ref$step === void 0 ? paginate ? 50 : undefined : _ref$step,
|
|
64
|
+
sizeKey = _ref.sizeKey,
|
|
65
|
+
onOrder = _ref.onOrder,
|
|
34
66
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
67
|
var _useThemeValue = (0, _useThemeValue2.useThemeValue)(),
|
|
36
68
|
theme = _useThemeValue.theme;
|
|
37
|
-
var
|
|
38
|
-
|
|
69
|
+
var announce = (0, _react.useContext)(_AnnounceContext.AnnounceContext);
|
|
70
|
+
var _useContext = (0, _react.useContext)(_MessageContext.MessageContext),
|
|
71
|
+
format = _useContext.format;
|
|
72
|
+
var _useContext2 = (0, _react.useContext)(_DataContext.DataContext),
|
|
73
|
+
contextData = _useContext2.data,
|
|
74
|
+
unfilteredData = _useContext2.unfilteredData;
|
|
39
75
|
var data = dataProp || contextData || emptyData;
|
|
76
|
+
var unfiltered = unfilteredData || data;
|
|
40
77
|
var _usePagination = (0, _utils.usePagination)(_extends({
|
|
41
78
|
data: data,
|
|
42
79
|
page: (0, _utils.normalizeShow)(showProp, step),
|
|
@@ -49,7 +86,128 @@ var Cards = exports.Cards = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
49
86
|
pad: pad,
|
|
50
87
|
margin: margin
|
|
51
88
|
}) : undefined;
|
|
52
|
-
|
|
89
|
+
var _useState = (0, _react.useState)(),
|
|
90
|
+
dragging = _useState[0],
|
|
91
|
+
setDragging = _useState[1];
|
|
92
|
+
var _useState2 = (0, _react.useState)(),
|
|
93
|
+
orderedData = _useState2[0],
|
|
94
|
+
setOrderedData = _useState2[1];
|
|
95
|
+
var _useState3 = (0, _react.useState)(),
|
|
96
|
+
unfilteredOrder = _useState3[0],
|
|
97
|
+
setUnfilteredOrder = _useState3[1];
|
|
98
|
+
var hintId = (0, _utils.useId)();
|
|
99
|
+
var currentItems = orderedData || (!paginate ? data : items);
|
|
100
|
+
var renderItem = function renderItem(item, index) {
|
|
101
|
+
var move = function move(count) {
|
|
102
|
+
var newIndex = Math.max(0, Math.min(index + count, currentItems.length - 1));
|
|
103
|
+
onOrder(reorder(unfiltered, indexForItem(unfiltered, item), indexForItem(unfiltered, currentItems[newIndex])));
|
|
104
|
+
announce(format({
|
|
105
|
+
id: 'cards.moved',
|
|
106
|
+
values: {
|
|
107
|
+
source: newIndex + 1,
|
|
108
|
+
target: currentItems.length
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
112
|
+
var onOrderProps = onOrder ? {
|
|
113
|
+
tabIndex: 0,
|
|
114
|
+
'aria-roledescription': format({
|
|
115
|
+
id: 'cards.description'
|
|
116
|
+
}),
|
|
117
|
+
'aria-describedby': hintId,
|
|
118
|
+
draggable: true,
|
|
119
|
+
onDragStart: function onDragStart(event) {
|
|
120
|
+
event.dataTransfer.setData('text/plain', '');
|
|
121
|
+
// allowed per
|
|
122
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API#define_the_drag_effect
|
|
123
|
+
// eslint-disable-next-line no-param-reassign
|
|
124
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
125
|
+
setDragging(index);
|
|
126
|
+
},
|
|
127
|
+
onDragEnd: function onDragEnd() {
|
|
128
|
+
setDragging(undefined);
|
|
129
|
+
setOrderedData(undefined);
|
|
130
|
+
setUnfilteredOrder(undefined);
|
|
131
|
+
},
|
|
132
|
+
onDragEnter: function onDragEnter(event) {
|
|
133
|
+
if (dragging !== undefined && dragging !== index) {
|
|
134
|
+
// Ignore synthetic re-fires caused by entering
|
|
135
|
+
// a child of this element
|
|
136
|
+
if (event.currentTarget.contains(event.relatedTarget)) return;
|
|
137
|
+
// eslint-disable-next-line no-param-reassign
|
|
138
|
+
event.dataTransfer.dropEffect = 'move';
|
|
139
|
+
setUnfilteredOrder(reorder(unfiltered, indexForItem(unfiltered, currentItems[dragging]), indexForItem(unfiltered, item)));
|
|
140
|
+
setOrderedData(reorder(currentItems, dragging, index));
|
|
141
|
+
setDragging(index);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onDragOver: function onDragOver(event) {
|
|
145
|
+
if (dragging !== undefined) {
|
|
146
|
+
// preventDefault is required to allow the drop to occur
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
onDrop: function onDrop() {
|
|
151
|
+
if (unfilteredOrder) {
|
|
152
|
+
onOrder(unfilteredOrder);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
keyboard: {
|
|
156
|
+
onUp: function onUp(event) {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
move(-1);
|
|
159
|
+
},
|
|
160
|
+
onDown: function onDown(event) {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
move(1);
|
|
163
|
+
},
|
|
164
|
+
onLeft: function onLeft(event) {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
move(-1);
|
|
167
|
+
},
|
|
168
|
+
onRight: function onRight(event) {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
move(1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} : {};
|
|
174
|
+
var keyboard = onOrderProps.keyboard,
|
|
175
|
+
wrapperProps = _objectWithoutPropertiesLoose(onOrderProps, _excluded2);
|
|
176
|
+
var content;
|
|
177
|
+
if (children) {
|
|
178
|
+
content = children(item, index);
|
|
179
|
+
} else {
|
|
180
|
+
var _ref2, _ref3;
|
|
181
|
+
content = /*#__PURE__*/_react["default"].createElement(_Card.Card, {
|
|
182
|
+
key: item.id || index.toString(),
|
|
183
|
+
as: !(onOrder || sizeKey) && as === 'ul' ? 'li' : undefined
|
|
184
|
+
}, /*#__PURE__*/_react["default"].createElement(_CardBody.CardBody, null, (_ref2 = (_ref3 = typeof item === 'string' && item) != null ? _ref3 : typeof item === 'object' && Object.values(item)[0]) != null ? _ref2 : index));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// If the items are orderable or sized by a property, wrap them in a
|
|
188
|
+
// StyledCellContainer to apply the drag and drop handlers and/or
|
|
189
|
+
// size styles
|
|
190
|
+
if (onOrder || sizeKey) {
|
|
191
|
+
var round = theme.card.container.round;
|
|
192
|
+
content = /*#__PURE__*/_react["default"].createElement(_StyledCellContainer.StyledCellContainer, _extends({
|
|
193
|
+
key: "_container_" + ((item == null ? void 0 : item.id) || index),
|
|
194
|
+
as: as === 'ul' ? 'li' : undefined
|
|
195
|
+
}, wrapperProps, {
|
|
196
|
+
size: sizeKey ? item[sizeKey] : undefined,
|
|
197
|
+
round: round
|
|
198
|
+
}), content);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Keyboard is only applied if onOrder is provided
|
|
202
|
+
return keyboard ? /*#__PURE__*/_react["default"].createElement(_Keyboard.Keyboard, _extends({
|
|
203
|
+
key: "_keyboard_" + ((item == null ? void 0 : item.id) || index)
|
|
204
|
+
}, keyboard), content) : content;
|
|
205
|
+
};
|
|
206
|
+
return /*#__PURE__*/_react["default"].createElement(Container, containerProps, onOrder && /*#__PURE__*/_react["default"].createElement(HiddenText, {
|
|
207
|
+
id: hintId
|
|
208
|
+
}, format({
|
|
209
|
+
id: 'cards.reorderHint'
|
|
210
|
+
})), /*#__PURE__*/_react["default"].createElement(_Grid.Grid, _extends({
|
|
53
211
|
ref: ref,
|
|
54
212
|
as: as,
|
|
55
213
|
gap: theme.cards.grid.gap,
|
|
@@ -57,7 +215,7 @@ var Cards = exports.Cards = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
57
215
|
margin: !paginate && margin || 'none',
|
|
58
216
|
pad: !paginate && pad || 'none'
|
|
59
217
|
}, rest), /*#__PURE__*/_react["default"].createElement(_InfiniteScroll.InfiniteScroll, {
|
|
60
|
-
items:
|
|
218
|
+
items: currentItems,
|
|
61
219
|
onMore: onMore,
|
|
62
220
|
show: !paginate ? showProp : undefined,
|
|
63
221
|
step: step,
|
|
@@ -68,11 +226,7 @@ var Cards = exports.Cards = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
68
226
|
}, marker);
|
|
69
227
|
}
|
|
70
228
|
}, function (item, index) {
|
|
71
|
-
|
|
72
|
-
return children ? children(item, index) : /*#__PURE__*/_react["default"].createElement(_Card.Card, {
|
|
73
|
-
key: index.toString(),
|
|
74
|
-
as: as === 'ul' ? 'li' : undefined
|
|
75
|
-
}, /*#__PURE__*/_react["default"].createElement(_CardBody.CardBody, null, (_ref2 = (_ref3 = typeof item === 'string' && item) != null ? _ref3 : typeof item === 'object' && Object.values(item)[0]) != null ? _ref2 : index));
|
|
229
|
+
return renderItem(item, index);
|
|
76
230
|
})), paginate && data.length > step && items && items.length ? /*#__PURE__*/_react["default"].createElement(_Pagination.Pagination, _extends({
|
|
77
231
|
alignSelf: "end"
|
|
78
232
|
}, paginationProps)) : null);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.StyledCellContainer = void 0;
|
|
5
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
6
|
+
var _utils = require("../../utils");
|
|
7
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
+
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); }
|
|
9
|
+
var sizeStyles = function sizeStyles(size) {
|
|
10
|
+
return size && typeof size === 'object' ? "\n " + (size != null && size.columns ? "grid-column: span " + size.columns + ";" : '') + "\n " + (size != null && size.rows ? "grid-row: span " + size.rows + ";" : '') + "\n " : '';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// display: grid makes the single child fill the wrapper (stretch in both axes)
|
|
14
|
+
var StyledCellContainer = exports.StyledCellContainer = _styledComponents["default"].div.withConfig(_extends({}, _utils.styledComponentsConfig, {
|
|
15
|
+
// 'size' passes isPropValid (valid for input/select), filter it to
|
|
16
|
+
// prevent the object value from reaching the DOM as an attribute.
|
|
17
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
18
|
+
return prop !== 'size' && _utils.styledComponentsConfig.shouldForwardProp(prop);
|
|
19
|
+
}
|
|
20
|
+
})).withConfig({
|
|
21
|
+
displayName: "StyledCellContainer",
|
|
22
|
+
componentId: "sc-183y88f-0"
|
|
23
|
+
})(["display:grid;", " ", " ", " &:focus{", "}&:focus:not(:focus-visible){", "}"], function (props) {
|
|
24
|
+
return props.size ? sizeStyles(props.size) : undefined;
|
|
25
|
+
}, function (props) {
|
|
26
|
+
return props.draggable ? 'cursor: move;' : undefined;
|
|
27
|
+
}, function (props) {
|
|
28
|
+
return props.round && (0, _utils.roundStyle)(props.round, props.responsive, props.theme);
|
|
29
|
+
}, (0, _utils.focusStyle)(), (0, _utils.unfocusStyle)());
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MarginType,
|
|
7
7
|
PadType,
|
|
8
8
|
} from '../../utils';
|
|
9
|
-
import { GridSizeType } from '../Grid';
|
|
9
|
+
import { GridProps, GridSizeType } from '../Grid';
|
|
10
10
|
import { PaginationType } from '../Pagination';
|
|
11
11
|
|
|
12
12
|
export interface CardsProps<CardType = any> {
|
|
@@ -18,10 +18,12 @@ export interface CardsProps<CardType = any> {
|
|
|
18
18
|
gridArea?: GridAreaType;
|
|
19
19
|
margin?: MarginType;
|
|
20
20
|
onMore?: () => void;
|
|
21
|
+
onOrder?: () => void;
|
|
21
22
|
pad?: PadType;
|
|
22
23
|
paginate?: boolean | PaginationType;
|
|
23
24
|
show?: number | { page?: number };
|
|
24
25
|
size?: GridSizeType;
|
|
26
|
+
sizeKey?: string;
|
|
25
27
|
step?: number;
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -35,6 +37,7 @@ type ulProps = Omit<
|
|
|
35
37
|
|
|
36
38
|
export interface CardsExtendedProps<CardType>
|
|
37
39
|
extends CardsProps<CardType>,
|
|
40
|
+
Omit<GridProps, keyof CardsProps<CardType>>,
|
|
38
41
|
ulProps {}
|
|
39
42
|
|
|
40
43
|
declare class Cards<CardType = any> extends React.Component<
|
|
@@ -13,10 +13,12 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
13
13
|
data: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].shape({})])),
|
|
14
14
|
children: _propTypes["default"].func,
|
|
15
15
|
onMore: _propTypes["default"].func,
|
|
16
|
+
onOrder: _propTypes["default"].func,
|
|
16
17
|
paginate: _propTypes["default"].oneOfType([_propTypes["default"].bool, _propTypes["default"].object]),
|
|
17
18
|
show: _propTypes["default"].oneOfType([_propTypes["default"].number, _propTypes["default"].shape({
|
|
18
19
|
page: _propTypes["default"].number
|
|
19
20
|
})]),
|
|
21
|
+
sizeKey: _propTypes["default"].string,
|
|
20
22
|
step: _propTypes["default"].number
|
|
21
23
|
});
|
|
22
24
|
}
|
|
@@ -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),
|