grommet 2.56.0 → 2.56.1
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/COPYRIGHT.md +3 -1
- package/components/Calendar/Calendar.js +2 -1
- package/components/Cards/Cards.js +1 -2
- package/components/DateTimeInput/DateTimeInput.js +1093 -0
- package/components/DateTimeInput/README.md +2 -0
- package/components/DateTimeInput/StyledDateTimeInput.js +74 -0
- package/components/DateTimeInput/index.d.ts +47 -0
- package/components/DateTimeInput/index.js +6 -0
- package/components/DateTimeInput/propTypes.js +42 -0
- package/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/components/Form/Form.js +7 -4
- package/components/Form/index.d.ts +3 -0
- package/components/Form/stories/AggregateValidation.stories.js +6 -8
- package/components/FormField/FormField.js +164 -91
- package/components/Stepper/StepConnector.js +19 -49
- package/components/Stepper/Stepper.js +5 -11
- package/components/Stepper/StepperStep.js +14 -4
- package/components/Stepper/StyledStepper.js +59 -21
- package/components/TimeInput/TimeInput.js +50 -47
- package/components/TimeInput/TimeInputPopup.js +172 -76
- package/components/TimeInput/index.d.ts +3 -0
- package/components/TimeInput/propTypes.js +4 -0
- package/components/TimeInput/useSectionedTimeField.js +33 -34
- package/components/TimeInput/utils.js +31 -26
- package/components/Wizard/StyledWizard.js +16 -0
- package/components/Wizard/Wizard.js +770 -0
- package/components/Wizard/WizardContent.js +90 -0
- package/components/Wizard/WizardContext.js +35 -0
- package/components/Wizard/WizardFooter.js +123 -0
- package/components/Wizard/WizardHeader.js +63 -0
- package/components/Wizard/WizardProgress.js +84 -0
- package/components/Wizard/WizardStepHeader.js +55 -0
- package/components/Wizard/index.d.ts +171 -0
- package/components/Wizard/index.js +19 -0
- package/components/Wizard/propTypes.js +56 -0
- package/components/Wizard/stories/BasicLinear.stories.js +71 -0
- package/components/Wizard/stories/Branching.stories.js +96 -0
- package/components/Wizard/stories/Composable.stories.js +75 -0
- package/components/Wizard/stories/Controlled.stories.js +136 -0
- package/components/Wizard/stories/LongContent.stories.js +118 -0
- package/components/Wizard/stories/Modal.stories.js +143 -0
- package/components/Wizard/stories/NestedSubSteps.stories.js +79 -0
- package/components/Wizard/stories/Validation.stories.js +123 -0
- package/components/index.d.ts +4 -0
- package/components/index.js +12 -0
- package/es6/components/Calendar/Calendar.js +2 -0
- package/es6/components/Cards/Cards.js +1 -2
- package/es6/components/DateTimeInput/DateTimeInput.js +1090 -0
- package/es6/components/DateTimeInput/README.md +2 -0
- package/es6/components/DateTimeInput/StyledDateTimeInput.js +68 -0
- package/es6/components/DateTimeInput/index.d.ts +47 -0
- package/es6/components/DateTimeInput/index.js +3 -0
- package/es6/components/DateTimeInput/propTypes.js +36 -0
- package/es6/components/DateTimeInput/stories/CustomThemed/Custom.stories.tsx +53 -0
- package/es6/components/DateTimeInput/stories/Form.stories.tsx +44 -0
- package/es6/components/DateTimeInput/stories/Inline.stories.tsx +45 -0
- package/es6/components/DateTimeInput/stories/Locale.stories.tsx +59 -0
- package/es6/components/DateTimeInput/stories/Simple.stories.tsx +23 -0
- package/es6/components/Form/Form.js +7 -3
- package/es6/components/Form/index.d.ts +3 -0
- package/es6/components/Form/stories/AggregateValidation.stories.js +6 -9
- package/es6/components/FormField/FormField.js +165 -91
- package/es6/components/Stepper/StepConnector.js +18 -48
- package/es6/components/Stepper/Stepper.js +5 -10
- package/es6/components/Stepper/StepperStep.js +15 -4
- package/es6/components/Stepper/StyledStepper.js +57 -21
- package/es6/components/TimeInput/TimeInput.js +50 -46
- package/es6/components/TimeInput/TimeInputPopup.js +172 -76
- package/es6/components/TimeInput/index.d.ts +3 -0
- package/es6/components/TimeInput/propTypes.js +3 -0
- package/es6/components/TimeInput/useSectionedTimeField.js +34 -35
- package/es6/components/TimeInput/utils.js +25 -21
- package/es6/components/Wizard/StyledWizard.js +11 -0
- package/es6/components/Wizard/Wizard.js +768 -0
- package/es6/components/Wizard/WizardContent.js +87 -0
- package/es6/components/Wizard/WizardContext.js +31 -0
- package/es6/components/Wizard/WizardFooter.js +120 -0
- package/es6/components/Wizard/WizardHeader.js +60 -0
- package/es6/components/Wizard/WizardProgress.js +80 -0
- package/es6/components/Wizard/WizardStepHeader.js +51 -0
- package/es6/components/Wizard/index.d.ts +171 -0
- package/es6/components/Wizard/index.js +7 -0
- package/es6/components/Wizard/propTypes.js +51 -0
- package/es6/components/Wizard/stories/BasicLinear.stories.js +67 -0
- package/es6/components/Wizard/stories/Branching.stories.js +93 -0
- package/es6/components/Wizard/stories/Composable.stories.js +72 -0
- package/es6/components/Wizard/stories/Controlled.stories.js +133 -0
- package/es6/components/Wizard/stories/LongContent.stories.js +115 -0
- package/es6/components/Wizard/stories/Modal.stories.js +141 -0
- package/es6/components/Wizard/stories/NestedSubSteps.stories.js +76 -0
- package/es6/components/Wizard/stories/Validation.stories.js +118 -0
- package/es6/components/index.d.ts +4 -0
- package/es6/components/index.js +4 -0
- package/es6/index.d.ts +4 -0
- package/es6/languages/default.json +28 -0
- package/es6/themes/base.d.ts +115 -0
- package/es6/themes/base.js +158 -0
- package/es6/utils/DOM.js +11 -2
- package/es6/utils/dates.js +10 -0
- package/es6/utils/sectionHelpers.js +57 -0
- package/es6/utils/useSectionedField.js +45 -0
- package/grommet.min.js +2 -1
- package/grommet.min.js.LICENSE.txt +1 -0
- package/grommet.min.js.map +1 -1
- package/index.d.ts +4 -0
- package/languages/default.json +28 -0
- package/package.json +35 -31
- package/themes/base.d.ts +115 -0
- package/themes/base.js +158 -1
- package/tools/license-header.js +2 -0
- package/utils/DOM.js +11 -2
- package/utils/dates.js +11 -1
- package/utils/sectionHelpers.js +61 -0
- package/utils/useSectionedField.js +50 -0
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
var _excluded = ["
|
|
2
|
-
_excluded2 = ["
|
|
3
|
-
_excluded3 = ["
|
|
1
|
+
var _excluded = ["message", "id"],
|
|
2
|
+
_excluded2 = ["error", "info", "message", "type"],
|
|
3
|
+
_excluded3 = ["id"],
|
|
4
|
+
_excluded4 = ["component", "disabled", "invalid", "name", "onChange"],
|
|
5
|
+
_excluded5 = ["children", "className", "component", "contentProps", "disabled", "error", "help", "htmlFor", "info", "label", "margin", "name", "onBlur", "onChange", "onFocus", "pad", "required", "style", "validate", "validateOn"],
|
|
6
|
+
_excluded6 = ["aria-describedby"];
|
|
4
7
|
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); }
|
|
5
8
|
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; }
|
|
9
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
6
11
|
import React, { Children, cloneElement, forwardRef, useContext, useEffect, useMemo, useState } from 'react';
|
|
7
12
|
import styled from 'styled-components';
|
|
8
13
|
import { containsFocus, shouldKeepFocus, withinDropPortal, PortalContext } from '../../utils';
|
|
@@ -21,7 +26,7 @@ import { FormFieldPropTypes } from './propTypes';
|
|
|
21
26
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
22
27
|
import { AnnounceContext } from '../../contexts/AnnounceContext';
|
|
23
28
|
var grommetInputFocusNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
|
|
24
|
-
var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'TimeInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
|
|
29
|
+
var grommetInputNames = ['CheckBox', 'CheckBoxGroup', 'TextInput', 'Select', 'MaskedInput', 'SelectMultiple', 'TextArea', 'DateInput', 'DateTimeInput', 'TimeInput', 'FileInput', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector', 'StarRating', 'ThumbsRating'];
|
|
25
30
|
var grommetInputPadNames = ['CheckBox', 'CheckBoxGroup', 'RadioButton', 'RadioButtonGroup', 'RangeInput', 'RangeSelector'];
|
|
26
31
|
var isGrommetInput = function isGrommetInput(comp) {
|
|
27
32
|
return comp && (grommetInputNames.indexOf(comp.displayName) !== -1 || grommetInputPadNames.indexOf(comp.displayName) !== -1);
|
|
@@ -74,12 +79,22 @@ var ScreenReaderOnly = styled(Text).withConfig({
|
|
|
74
79
|
displayName: "FormField__ScreenReaderOnly",
|
|
75
80
|
componentId: "sc-m9hood-5"
|
|
76
81
|
})(["position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;"]);
|
|
77
|
-
var
|
|
78
|
-
var
|
|
79
|
-
|
|
80
|
-
message = _ref.message,
|
|
81
|
-
type = _ref.type,
|
|
82
|
+
var MessageContent = function MessageContent(_ref) {
|
|
83
|
+
var message = _ref.message,
|
|
84
|
+
id = _ref.id,
|
|
82
85
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
86
|
+
return typeof message === 'string' ? /*#__PURE__*/React.createElement(Text, _extends({
|
|
87
|
+
id: id
|
|
88
|
+
}, rest), message) : /*#__PURE__*/React.createElement(Box, _extends({
|
|
89
|
+
id: id
|
|
90
|
+
}, rest), message);
|
|
91
|
+
};
|
|
92
|
+
var Message = function Message(_ref2) {
|
|
93
|
+
var error = _ref2.error,
|
|
94
|
+
info = _ref2.info,
|
|
95
|
+
message = _ref2.message,
|
|
96
|
+
type = _ref2.type,
|
|
97
|
+
rest = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
83
98
|
var _useThemeValue = useThemeValue(),
|
|
84
99
|
theme = _useThemeValue.theme,
|
|
85
100
|
passThemeFlag = _useThemeValue.passThemeFlag;
|
|
@@ -90,24 +105,36 @@ var Message = function Message(_ref) {
|
|
|
90
105
|
icon = theme.formField[type] && theme.formField[type].icon;
|
|
91
106
|
containerProps = theme.formField[type] && theme.formField[type].container;
|
|
92
107
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
|
|
109
|
+
// id is in rest; extract it so we can place it on the outermost element
|
|
110
|
+
var id = rest.id,
|
|
111
|
+
contentRest = _objectWithoutPropertiesLoose(rest, _excluded3);
|
|
112
|
+
if (icon || containerProps) {
|
|
113
|
+
return /*#__PURE__*/React.createElement(StyledMessageContainer, _extends({
|
|
114
|
+
direction: "row",
|
|
115
|
+
messageType: type
|
|
116
|
+
}, containerProps, passThemeFlag, {
|
|
117
|
+
id: id
|
|
118
|
+
}), icon && /*#__PURE__*/React.createElement(Box, {
|
|
119
|
+
flex: false
|
|
120
|
+
}, icon), /*#__PURE__*/React.createElement(MessageContent, _extends({
|
|
121
|
+
message: message
|
|
122
|
+
}, contentRest)));
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/React.createElement(MessageContent, _extends({
|
|
125
|
+
message: message,
|
|
126
|
+
id: id
|
|
127
|
+
}, contentRest));
|
|
101
128
|
}
|
|
102
129
|
return null;
|
|
103
130
|
};
|
|
104
|
-
var Input = function Input(
|
|
105
|
-
var component =
|
|
106
|
-
disabled =
|
|
107
|
-
invalid =
|
|
108
|
-
name =
|
|
109
|
-
_onChange =
|
|
110
|
-
rest = _objectWithoutPropertiesLoose(
|
|
131
|
+
var Input = function Input(_ref3) {
|
|
132
|
+
var component = _ref3.component,
|
|
133
|
+
disabled = _ref3.disabled,
|
|
134
|
+
invalid = _ref3.invalid,
|
|
135
|
+
name = _ref3.name,
|
|
136
|
+
_onChange = _ref3.onChange,
|
|
137
|
+
rest = _objectWithoutPropertiesLoose(_ref3, _excluded4);
|
|
111
138
|
var formContext = useContext(FormContext);
|
|
112
139
|
var _formContext$useFormI = formContext.useFormInput({
|
|
113
140
|
name: name,
|
|
@@ -138,29 +165,58 @@ var Input = function Input(_ref2) {
|
|
|
138
165
|
"aria-invalid": invalid || undefined
|
|
139
166
|
}, rest, extraProps));
|
|
140
167
|
};
|
|
141
|
-
|
|
168
|
+
|
|
169
|
+
// Adds aria-describedby (linking to the error Message) and aria-invalid to
|
|
170
|
+
// a Grommet input child when the field has an error. Merges with any
|
|
171
|
+
// aria-describedby the consumer already put on the child instead of
|
|
172
|
+
// overwriting it.
|
|
173
|
+
var getChildErrorProps = function getChildErrorProps(child, errorId, error) {
|
|
174
|
+
if (!errorId && !error) return {};
|
|
175
|
+
var props = {};
|
|
176
|
+
if (errorId) {
|
|
177
|
+
var existingDescribedBy = child.props['aria-describedby'];
|
|
178
|
+
props['aria-describedby'] = existingDescribedBy ? existingDescribedBy + " " + errorId : errorId;
|
|
179
|
+
}
|
|
180
|
+
if (error) props['aria-invalid'] = true;
|
|
181
|
+
return props;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// Backwards compatibility: defaults plain/focusIndicator/pad on a Grommet
|
|
185
|
+
// input child, unless the consumer already set plain or focusIndicator.
|
|
186
|
+
// This is the same logic FormField has always had; only pulled out into
|
|
187
|
+
// its own function so it can be reasoned about independent of the newer
|
|
188
|
+
// error-linking logic above.
|
|
189
|
+
var getChildFocusProps = function getChildFocusProps(child, themeBorder, containerFocus, formFieldTheme) {
|
|
190
|
+
var _formFieldTheme$check;
|
|
191
|
+
return !themeBorder || child.props.plain !== undefined || child.props.focusIndicator !== undefined ? {} : {
|
|
192
|
+
plain: true,
|
|
193
|
+
focusIndicator: !containerFocus,
|
|
194
|
+
pad: child.type.displayName === 'CheckBox' ? formFieldTheme == null || (_formFieldTheme$check = formFieldTheme.checkBox) == null ? void 0 : _formFieldTheme$check.pad : undefined
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
var FormField = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
142
198
|
var _theme$formField2, _theme$global$input, _formFieldTheme$disab, _formFieldTheme$disab2;
|
|
143
|
-
var children =
|
|
144
|
-
className =
|
|
145
|
-
component =
|
|
146
|
-
contentProps =
|
|
147
|
-
disabled =
|
|
148
|
-
errorProp =
|
|
149
|
-
help =
|
|
150
|
-
htmlFor =
|
|
151
|
-
infoProp =
|
|
152
|
-
label =
|
|
153
|
-
margin =
|
|
154
|
-
name =
|
|
155
|
-
_onBlur =
|
|
156
|
-
onChange =
|
|
157
|
-
_onFocus =
|
|
158
|
-
pad =
|
|
159
|
-
required =
|
|
160
|
-
style =
|
|
161
|
-
validate =
|
|
162
|
-
validateOn =
|
|
163
|
-
rest = _objectWithoutPropertiesLoose(
|
|
199
|
+
var children = _ref4.children,
|
|
200
|
+
className = _ref4.className,
|
|
201
|
+
component = _ref4.component,
|
|
202
|
+
contentProps = _ref4.contentProps,
|
|
203
|
+
disabled = _ref4.disabled,
|
|
204
|
+
errorProp = _ref4.error,
|
|
205
|
+
help = _ref4.help,
|
|
206
|
+
htmlFor = _ref4.htmlFor,
|
|
207
|
+
infoProp = _ref4.info,
|
|
208
|
+
label = _ref4.label,
|
|
209
|
+
margin = _ref4.margin,
|
|
210
|
+
name = _ref4.name,
|
|
211
|
+
_onBlur = _ref4.onBlur,
|
|
212
|
+
onChange = _ref4.onChange,
|
|
213
|
+
_onFocus = _ref4.onFocus,
|
|
214
|
+
pad = _ref4.pad,
|
|
215
|
+
required = _ref4.required,
|
|
216
|
+
style = _ref4.style,
|
|
217
|
+
validate = _ref4.validate,
|
|
218
|
+
validateOn = _ref4.validateOn,
|
|
219
|
+
rest = _objectWithoutPropertiesLoose(_ref4, _excluded5);
|
|
164
220
|
var _useThemeValue2 = useThemeValue(),
|
|
165
221
|
theme = _useThemeValue2.theme,
|
|
166
222
|
passThemeFlag = _useThemeValue2.passThemeFlag;
|
|
@@ -199,7 +255,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
199
255
|
if (children) {
|
|
200
256
|
Children.map(children, function (child) {
|
|
201
257
|
var _child$props, _child$props2;
|
|
202
|
-
if (((child == null || (_child$props = child.props) == null ? void 0 : _child$props.readOnly) === true || (child == null || (_child$props2 = child.props) == null ? void 0 : _child$props2.readOnlyCopy) === true) && child.type && (
|
|
258
|
+
if (((child == null || (_child$props = child.props) == null ? void 0 : _child$props.readOnly) === true || (child == null || (_child$props2 = child.props) == null ? void 0 : _child$props2.readOnlyCopy) === true) && child.type && (child.type.displayName === 'TextInput' || child.type.displayName === 'DateInput')) {
|
|
203
259
|
readOnly = true;
|
|
204
260
|
}
|
|
205
261
|
});
|
|
@@ -217,37 +273,74 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
217
273
|
return focusIndicatorFlag;
|
|
218
274
|
}, [children, (_theme$formField2 = theme.formField) == null || (_theme$formField2 = _theme$formField2.focus) == null ? void 0 : _theme$formField2.containerFocus]);
|
|
219
275
|
|
|
276
|
+
// Check if child is Select or SelectMultiple and modify htmlFor if needed
|
|
277
|
+
var adjustedHtmlFor = htmlFor;
|
|
278
|
+
if (htmlFor) {
|
|
279
|
+
var isSelectComponent = false;
|
|
280
|
+
|
|
281
|
+
// Check if children contain Select or SelectMultiple
|
|
282
|
+
if (children) {
|
|
283
|
+
Children.forEach(children, function (child) {
|
|
284
|
+
if (child && child.type && (child.type.displayName === 'Select' || child.type.displayName === 'SelectMultiple') && child.props.id === htmlFor) {
|
|
285
|
+
isSelectComponent = true;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// If it's a Select component and htmlFor doesn't end with __input, add it
|
|
291
|
+
if (isSelectComponent && !htmlFor.endsWith('__input')) {
|
|
292
|
+
adjustedHtmlFor = htmlFor + "__input";
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
220
296
|
// This is here for backwards compatibility. In case the child is a grommet
|
|
221
297
|
// input component, set plain and focusIndicator props, if they aren't
|
|
222
298
|
// already set.
|
|
223
299
|
var wantContentPad = component && (component === CheckBox || component === CheckBoxGroup || component === RadioButtonGroup);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
300
|
+
|
|
301
|
+
// id of the error Message, used to link it to its input via
|
|
302
|
+
// aria-describedby. Always computed when there's an error + htmlFor,
|
|
303
|
+
// regardless of theme border config.
|
|
304
|
+
var errorId = error && htmlFor ? "grommet-" + adjustedHtmlFor + "__error" : undefined;
|
|
305
|
+
|
|
306
|
+
// Single Children.map pass applying both the error-linking props
|
|
307
|
+
// (getChildErrorProps) and the plain/focusIndicator/pad backwards-compat
|
|
308
|
+
// defaults (getChildFocusProps) to each Grommet input child. Must run
|
|
309
|
+
// the same way regardless of `error`, or a child's reconciliation key
|
|
310
|
+
// changes between renders - remounting it and losing state (e.g. a
|
|
311
|
+
// typed value) right when the error appears.
|
|
312
|
+
var contents;
|
|
313
|
+
if (children) {
|
|
314
|
+
contents = Children.map(children, function (child) {
|
|
315
|
+
if (!child || !child.type || !isGrommetInput(child.type)) return child;
|
|
316
|
+
if (themeBorder && grommetInputPadNames.indexOf(child.type.displayName) !== -1) {
|
|
317
|
+
wantContentPad = true;
|
|
318
|
+
}
|
|
319
|
+
var newProps = _extends({}, getChildErrorProps(child, errorId, error), getChildFocusProps(child, themeBorder, containerFocus, formFieldTheme));
|
|
320
|
+
return Object.keys(newProps).length ? /*#__PURE__*/cloneElement(child, newProps) : child;
|
|
321
|
+
});
|
|
322
|
+
} else {
|
|
323
|
+
contents = children;
|
|
324
|
+
}
|
|
239
325
|
|
|
240
326
|
// put rest on container, unless we use internal Input
|
|
241
327
|
var containerRest = rest;
|
|
242
328
|
if (inForm) {
|
|
243
329
|
if (!contents) containerRest = {};
|
|
330
|
+
// Merge aria-describedby with the error id rather than
|
|
331
|
+
// letting either one silently win.
|
|
332
|
+
var ariaDescribedBy = rest['aria-describedby'],
|
|
333
|
+
restWithoutAria = _objectWithoutPropertiesLoose(rest, _excluded6);
|
|
334
|
+
var combinedAriaDescribedBy = errorId ? [ariaDescribedBy, errorId].filter(Boolean).join(' ') : ariaDescribedBy;
|
|
244
335
|
contents = contents || /*#__PURE__*/React.createElement(Input, _extends({
|
|
245
336
|
component: component,
|
|
246
337
|
disabled: disabled,
|
|
247
338
|
invalid: !!error,
|
|
248
339
|
name: name,
|
|
249
340
|
label: component === CheckBox ? label : undefined
|
|
250
|
-
},
|
|
341
|
+
}, restWithoutAria, {
|
|
342
|
+
"aria-describedby": combinedAriaDescribedBy || undefined
|
|
343
|
+
}));
|
|
251
344
|
}
|
|
252
345
|
var themeContentProps = _extends({}, formFieldTheme.content);
|
|
253
346
|
if (!pad && !wantContentPad) {
|
|
@@ -267,9 +360,11 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
267
360
|
// fileinput handle
|
|
268
361
|
// use fileinput plain use formfield to drive the border
|
|
269
362
|
var isFileInputComponent;
|
|
270
|
-
if (children
|
|
271
|
-
|
|
272
|
-
|
|
363
|
+
if (children) {
|
|
364
|
+
Children.forEach(children, function (child) {
|
|
365
|
+
if (child && child.type && child.type.displayName === 'FileInput') isFileInputComponent = true;
|
|
366
|
+
});
|
|
367
|
+
}
|
|
273
368
|
if (component && component.displayName === 'FileInput' && !isFileInputComponent) {
|
|
274
369
|
isFileInputComponent = true;
|
|
275
370
|
}
|
|
@@ -308,10 +403,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
308
403
|
} else {
|
|
309
404
|
borderColor = themeBorder && themeBorder.color || 'border';
|
|
310
405
|
}
|
|
311
|
-
var labelStyle;
|
|
312
|
-
if (formKind) {
|
|
313
|
-
labelStyle = _extends({}, formFieldTheme[formKind].label);
|
|
314
|
-
} else labelStyle = _extends({}, formFieldTheme.label);
|
|
406
|
+
var labelStyle = _extends({}, formKind ? formFieldTheme[formKind].label : formFieldTheme.label);
|
|
315
407
|
if (disabled) {
|
|
316
408
|
labelStyle.color = formFieldTheme.disabled && formFieldTheme.disabled.label ? formFieldTheme.disabled.label.color : labelStyle.color;
|
|
317
409
|
}
|
|
@@ -399,26 +491,6 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
399
491
|
}, "*"), /*#__PURE__*/React.createElement(ScreenReaderOnly, null, "required"));
|
|
400
492
|
var showRequiredIndicator = required && requiredIndicator;
|
|
401
493
|
if (typeof required === 'object' && required.indicator === false) showRequiredIndicator = false;
|
|
402
|
-
|
|
403
|
-
// Check if child is Select or SelectMultiple and modify htmlFor if needed
|
|
404
|
-
var adjustedHtmlFor = htmlFor;
|
|
405
|
-
if (htmlFor) {
|
|
406
|
-
var isSelectComponent = false;
|
|
407
|
-
|
|
408
|
-
// Check if children contain Select or SelectMultiple
|
|
409
|
-
if (children) {
|
|
410
|
-
Children.forEach(children, function (child) {
|
|
411
|
-
if (child && child.type && (child.type.displayName === 'Select' || child.type.displayName === 'SelectMultiple') && child.props.id === htmlFor) {
|
|
412
|
-
isSelectComponent = true;
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// If it's a Select component and htmlFor doesn't end with __input, add it
|
|
418
|
-
if (isSelectComponent && !htmlFor.endsWith('__input')) {
|
|
419
|
-
adjustedHtmlFor = htmlFor + "__input";
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
494
|
return /*#__PURE__*/React.createElement(FormFieldBox, _extends({
|
|
423
495
|
ref: formFieldRef,
|
|
424
496
|
className: className,
|
|
@@ -465,7 +537,9 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
465
537
|
}, themeHelpProps))) : undefined, contents, /*#__PURE__*/React.createElement(Message, _extends({
|
|
466
538
|
type: "error",
|
|
467
539
|
message: error
|
|
468
|
-
}, formFieldTheme.error
|
|
540
|
+
}, formFieldTheme.error, {
|
|
541
|
+
id: errorId
|
|
542
|
+
})), /*#__PURE__*/React.createElement(Message, _extends({
|
|
469
543
|
type: "info",
|
|
470
544
|
message: info
|
|
471
545
|
}, themeInfoProps)));
|
|
@@ -1,63 +1,33 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
import React from 'react';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import isPropValid from '@emotion/is-prop-valid';
|
|
3
7
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
4
8
|
import { StyledConnector } from './StyledStepper';
|
|
9
|
+
var StyledStepConnectorGroup = styled.div.withConfig({
|
|
10
|
+
shouldForwardProp: function shouldForwardProp(prop) {
|
|
11
|
+
return isPropValid(prop) && prop !== 'direction';
|
|
12
|
+
}
|
|
13
|
+
}).withConfig({
|
|
14
|
+
displayName: "StepConnector__StyledStepConnectorGroup",
|
|
15
|
+
componentId: "sc-1k7y9sb-0"
|
|
16
|
+
})(["display:flex;flex-direction:column;position:relative;flex:1;overflow:visible;", ""], function (props) {
|
|
17
|
+
return props.direction === 'horizontal' && css(["align-items:center;"]);
|
|
18
|
+
});
|
|
5
19
|
export var StepConnector = function StepConnector(_ref) {
|
|
6
|
-
var _theme$stepper, _theme$global, _theme$global2, _theme$global3, _theme$global4, _theme$global5;
|
|
7
20
|
var step = _ref.step,
|
|
8
21
|
direction = _ref.direction,
|
|
9
22
|
children = _ref.children;
|
|
10
23
|
var _useThemeValue = useThemeValue(),
|
|
11
|
-
theme = _useThemeValue.theme,
|
|
12
24
|
passThemeFlag = _useThemeValue.passThemeFlag;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var minConnectorInlineSize = ((_theme$global5 = theme.global) == null || (_theme$global5 = _theme$global5.edgeSize) == null ? void 0 : _theme$global5.small) || '12px';
|
|
17
|
-
var directionStyle = direction === 'horizontal' ? {
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
minWidth: minConnectorInlineSize
|
|
20
|
-
} : {
|
|
21
|
-
justifyContent: 'flex-start',
|
|
22
|
-
minHeight: minConnectorInlineSize
|
|
23
|
-
};
|
|
24
|
-
var renderChildren = function renderChildren() {
|
|
25
|
-
var _theme$global6;
|
|
26
|
-
if (!children) return null;
|
|
27
|
-
var childIndent = "calc(" + indicatorSize + " + " + (((_theme$global6 = theme.global) == null || (_theme$global6 = _theme$global6.edgeSize) == null ? void 0 : _theme$global6.small) || '12px') + ")";
|
|
28
|
-
return direction === 'horizontal' ? /*#__PURE__*/React.createElement("span", {
|
|
29
|
-
style: {
|
|
30
|
-
display: 'flex',
|
|
31
|
-
flexDirection: 'row',
|
|
32
|
-
alignItems: 'center',
|
|
33
|
-
gap: childGap,
|
|
34
|
-
paddingTop: childPadTop,
|
|
35
|
-
maxWidth: '100%',
|
|
36
|
-
flexWrap: 'wrap',
|
|
37
|
-
justifyContent: 'center'
|
|
38
|
-
}
|
|
39
|
-
}, children) : /*#__PURE__*/React.createElement("ol", {
|
|
40
|
-
style: {
|
|
41
|
-
listStyle: 'none',
|
|
42
|
-
padding: "0 0 0 " + childIndent,
|
|
43
|
-
margin: 0
|
|
44
|
-
}
|
|
45
|
-
}, children);
|
|
46
|
-
};
|
|
47
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
48
|
-
role: "presentation",
|
|
49
|
-
"aria-hidden": children ? undefined : 'true',
|
|
50
|
-
style: _extends({
|
|
51
|
-
display: 'flex',
|
|
52
|
-
flexDirection: 'column',
|
|
53
|
-
position: 'relative',
|
|
54
|
-
flex: 1,
|
|
55
|
-
overflow: 'visible'
|
|
56
|
-
}, directionStyle)
|
|
57
|
-
}, /*#__PURE__*/React.createElement(StyledConnector, _extends({
|
|
25
|
+
return /*#__PURE__*/React.createElement(StyledStepConnectorGroup, _extends({
|
|
26
|
+
direction: direction
|
|
27
|
+
}, passThemeFlag), /*#__PURE__*/React.createElement(StyledConnector, _extends({
|
|
58
28
|
direction: direction,
|
|
59
29
|
status: step.status,
|
|
60
30
|
"aria-hidden": "true",
|
|
61
31
|
isBetween: true
|
|
62
|
-
}, passThemeFlag)),
|
|
32
|
+
}, passThemeFlag)), children);
|
|
63
33
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var _excluded = ["steps", "currentStep", "direction", "clickableSteps", "showDescription", "onStepClick", "aria-label", "children", "id"];
|
|
2
2
|
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; }
|
|
3
3
|
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); }
|
|
4
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
5
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
6
|
import React, { forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
7
|
import { Box } from '../Box';
|
|
6
8
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
7
9
|
import { Keyboard } from '../Keyboard';
|
|
8
|
-
import { StepConnector } from './StepConnector';
|
|
9
10
|
import { StepperContext } from './StepperContext';
|
|
10
11
|
import { StepperStep } from './StepperStep';
|
|
11
12
|
import { StepperPropTypes } from './propTypes';
|
|
@@ -260,22 +261,16 @@ var Stepper = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
260
261
|
step: step,
|
|
261
262
|
stepNumber: parentFlatIndex + 1,
|
|
262
263
|
isLast: isLastParent,
|
|
263
|
-
showConnector: direction === 'horizontal' ?
|
|
264
|
+
showConnector: direction === 'horizontal' ? !isLastParent : !isLastParent || !!childElements,
|
|
264
265
|
direction: direction,
|
|
265
266
|
focusedIndex: focusedIndex,
|
|
266
267
|
index: parentFlatIndex,
|
|
267
268
|
isSubStep: false,
|
|
268
269
|
onFocusStep: updateFocusedIndex,
|
|
269
270
|
stepsRef: stepsRef,
|
|
270
|
-
stepRefs: stepRefs
|
|
271
|
+
stepRefs: stepRefs,
|
|
272
|
+
subSteps: childElements
|
|
271
273
|
}));
|
|
272
|
-
if (!isLastParent || childElements && direction === 'vertical') {
|
|
273
|
-
elements.push(/*#__PURE__*/React.createElement(StepConnector, {
|
|
274
|
-
key: step.id + "-connector",
|
|
275
|
-
step: step,
|
|
276
|
-
direction: direction
|
|
277
|
-
}, childElements));
|
|
278
|
-
}
|
|
279
274
|
});
|
|
280
275
|
return elements;
|
|
281
276
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
// SPDX-FileCopyrightText: © Hewlett Packard Enterprise Development LP
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
4
|
import React, { useContext, useMemo } from 'react';
|
|
3
5
|
import { MessageContext } from '../../contexts/MessageContext';
|
|
4
6
|
import { useThemeValue } from '../../utils/useThemeValue';
|
|
@@ -7,7 +9,8 @@ import { StepperIndicator } from './StepperIndicator';
|
|
|
7
9
|
import { StepperLabel } from './StepperLabel';
|
|
8
10
|
import { StepperDescription } from './StepperDescription';
|
|
9
11
|
import { StepperError, StepperDisabledReason } from './StepperHelperText';
|
|
10
|
-
import {
|
|
12
|
+
import { StepConnector } from './StepConnector';
|
|
13
|
+
import { StyledStepItem, StyledStepButton, StyledStepContent, StyledConnector, StyledSubStepsList } from './StyledStepper';
|
|
11
14
|
export var StepperStep = function StepperStep(_ref) {
|
|
12
15
|
var _step$children, _stepsRef$current;
|
|
13
16
|
var step = _ref.step,
|
|
@@ -18,6 +21,7 @@ export var StepperStep = function StepperStep(_ref) {
|
|
|
18
21
|
focusedIndex = _ref.focusedIndex,
|
|
19
22
|
indexProp = _ref.index,
|
|
20
23
|
isSubStep = _ref.isSubStep,
|
|
24
|
+
subSteps = _ref.subSteps,
|
|
21
25
|
onFocusStep = _ref.onFocusStep,
|
|
22
26
|
stepsRef = _ref.stepsRef,
|
|
23
27
|
stepRefs = _ref.stepRefs;
|
|
@@ -93,7 +97,9 @@ export var StepperStep = function StepperStep(_ref) {
|
|
|
93
97
|
value: stepItemValue
|
|
94
98
|
}, /*#__PURE__*/React.createElement(StyledStepItem, _extends({
|
|
95
99
|
direction: direction,
|
|
96
|
-
isSubStep: isSubStep
|
|
100
|
+
isSubStep: isSubStep,
|
|
101
|
+
isLast: isLast,
|
|
102
|
+
hasSubSteps: !!(subSteps != null && subSteps.length)
|
|
97
103
|
}, passThemeFlag), /*#__PURE__*/React.createElement(StyledStepButton, _extends({
|
|
98
104
|
as: isReadOnly ? 'div' : 'button',
|
|
99
105
|
role: isReadOnly ? 'group' : undefined,
|
|
@@ -114,9 +120,14 @@ export var StepperStep = function StepperStep(_ref) {
|
|
|
114
120
|
direction: direction,
|
|
115
121
|
isSubStep: isSubStep,
|
|
116
122
|
hasDescription: !!step.description
|
|
117
|
-
}, passThemeFlag), /*#__PURE__*/React.createElement(StepperLabel, null), showDescription && /*#__PURE__*/React.createElement(StepperDescription, null), /*#__PURE__*/React.createElement(StepperError, null), /*#__PURE__*/React.createElement(StepperDisabledReason, null))), (showConnector !== undefined ? showConnector : !isLast) && /*#__PURE__*/React.createElement(StyledConnector, _extends({
|
|
123
|
+
}, passThemeFlag), /*#__PURE__*/React.createElement(StepperLabel, null), showDescription && /*#__PURE__*/React.createElement(StepperDescription, null), /*#__PURE__*/React.createElement(StepperError, null), /*#__PURE__*/React.createElement(StepperDisabledReason, null))), (showConnector !== undefined ? showConnector : !isLast) && !(subSteps != null && subSteps.length) && /*#__PURE__*/React.createElement(StyledConnector, _extends({
|
|
118
124
|
direction: direction,
|
|
119
125
|
status: step.status,
|
|
120
126
|
"aria-hidden": "true"
|
|
121
|
-
}, passThemeFlag)))
|
|
127
|
+
}, passThemeFlag)), !!(subSteps != null && subSteps.length) && /*#__PURE__*/React.createElement(StepConnector, {
|
|
128
|
+
step: step,
|
|
129
|
+
direction: direction
|
|
130
|
+
}, /*#__PURE__*/React.createElement(StyledSubStepsList, _extends({
|
|
131
|
+
direction: direction
|
|
132
|
+
}, passThemeFlag), subSteps))));
|
|
122
133
|
};
|