grommet 2.31.0 → 2.32.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/Accordion/Accordion.js +4 -2
- package/components/Accordion/index.d.ts +1 -0
- package/components/Accordion/propTypes.js +1 -0
- package/components/AccordionPanel/AccordionPanel.js +2 -1
- package/components/Box/Box.js +14 -4
- package/components/Box/stories/Border.js +15 -1
- package/components/Button/BusyAnimation.js +51 -0
- package/components/Button/Button.js +64 -4
- package/components/Button/StyledButton.js +4 -2
- package/components/Button/StyledButtonKind.js +8 -4
- package/components/Button/index.d.ts +7 -0
- package/components/Button/propTypes.js +6 -0
- package/components/Button/stories/Busy.js +45 -0
- package/components/Calendar/stories/Dual.js +4 -6
- package/components/Data/DataForm.js +6 -2
- package/components/Data/filter.js +9 -1
- package/components/Data/stories/Complex.js +63 -6
- package/components/Data/stories/Inline.js +19 -2
- package/components/DataFilter/DataFilter.js +11 -1
- package/components/DataFilters/DataFilters.js +13 -10
- package/components/DataTable/Body.js +16 -13
- package/components/DataTable/DataTable.js +4 -1
- package/components/DataTable/GroupedBody.js +1 -0
- package/components/DataTable/Header.js +1 -0
- package/components/DataTable/buildState.js +12 -10
- package/components/DataTable/stories/Controlled.js +2 -1
- package/components/DataTable/stories/ControlledGrouped.js +2 -1
- package/components/DataTable/stories/CustomThemed/Custom.js +0 -1
- package/components/DataTable/stories/CustomThemed/Fill.js +2 -1
- package/components/DataTable/stories/GroupedOnSelect.js +2 -1
- package/components/DataTable/stories/NoPrimary.js +0 -1
- package/components/DataTable/stories/OnUpdate.js +2 -1
- package/components/DataTable/stories/Served.js +2 -1
- package/components/DataTable/stories/Tunable.js +2 -1
- package/components/DataTable/stories/rowDetails.js +2 -1
- package/components/DataTableColumns/DataTableColumns.js +5 -0
- package/components/DataTableColumns/stories/Simple.js +4 -3
- package/components/DataTableGroupBy/DataTableGroupBy.js +67 -0
- package/components/DataTableGroupBy/README.md +2 -0
- package/components/DataTableGroupBy/index.d.ts +20 -0
- package/components/DataTableGroupBy/index.js +6 -0
- package/components/DataTableGroupBy/propTypes.js +17 -0
- package/components/DataTableGroupBy/stories/Simple.js +50 -0
- package/components/DateInput/DateInput.js +1 -1
- package/components/Drop/DropContainer.js +2 -2
- package/components/DropButton/DropButton.js +2 -2
- package/components/FileInput/FileInput.js +82 -53
- package/components/Form/Form.js +95 -44
- package/components/Form/stories/TriggerValidationUsingFormField.js +109 -0
- package/components/FormField/FormField.js +4 -2
- package/components/FormField/index.d.ts +1 -0
- package/components/FormField/propTypes.js +2 -1
- package/components/Grid/stories/CustomThemed/Responsive.js +0 -1
- package/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/components/Layer/Layer.js +1 -1
- package/components/Layer/LayerContainer.js +2 -2
- package/components/List/index.d.ts +2 -2
- package/components/NameValueList/NameValueList.js +1 -1
- package/components/SelectMultiple/SelectMultiple.js +13 -10
- package/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/components/Tip/stories/HeaderActions.js +0 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +6 -0
- package/es6/components/Accordion/Accordion.js +4 -2
- package/es6/components/Accordion/index.d.ts +1 -0
- package/es6/components/Accordion/propTypes.js +1 -0
- package/es6/components/AccordionPanel/AccordionPanel.js +2 -1
- package/es6/components/Box/Box.js +14 -4
- package/es6/components/Box/stories/Border.js +15 -1
- package/es6/components/Button/BusyAnimation.js +41 -0
- package/es6/components/Button/Button.js +64 -5
- package/es6/components/Button/StyledButton.js +4 -2
- package/es6/components/Button/StyledButtonKind.js +8 -4
- package/es6/components/Button/index.d.ts +7 -0
- package/es6/components/Button/propTypes.js +6 -0
- package/es6/components/Button/stories/Busy.js +37 -0
- package/es6/components/Calendar/stories/Dual.js +4 -6
- package/es6/components/Data/DataForm.js +4 -1
- package/es6/components/Data/filter.js +9 -1
- package/es6/components/Data/stories/Complex.js +64 -7
- package/es6/components/Data/stories/Inline.js +20 -3
- package/es6/components/DataFilter/DataFilter.js +11 -1
- package/es6/components/DataFilters/DataFilters.js +13 -10
- package/es6/components/DataTable/Body.js +15 -13
- package/es6/components/DataTable/DataTable.js +4 -1
- package/es6/components/DataTable/GroupedBody.js +1 -0
- package/es6/components/DataTable/buildState.js +12 -10
- package/es6/components/DataTableColumns/DataTableColumns.js +5 -0
- package/es6/components/DataTableColumns/stories/Simple.js +5 -4
- package/es6/components/DataTableGroupBy/DataTableGroupBy.js +60 -0
- package/es6/components/DataTableGroupBy/README.md +2 -0
- package/es6/components/DataTableGroupBy/index.d.ts +20 -0
- package/es6/components/DataTableGroupBy/index.js +1 -0
- package/es6/components/DataTableGroupBy/propTypes.js +11 -0
- package/es6/components/DataTableGroupBy/stories/Simple.js +45 -0
- package/es6/components/DateInput/DateInput.js +1 -1
- package/es6/components/Drop/DropContainer.js +2 -2
- package/es6/components/DropButton/DropButton.js +2 -2
- package/es6/components/FileInput/FileInput.js +83 -53
- package/es6/components/Form/Form.js +95 -44
- package/es6/components/Form/stories/TriggerValidationUsingFormField.js +102 -0
- package/es6/components/FormField/FormField.js +4 -2
- package/es6/components/FormField/index.d.ts +1 -0
- package/es6/components/FormField/propTypes.js +2 -1
- package/es6/components/InfiniteScroll/InfiniteScroll.js +1 -0
- package/es6/components/Layer/Layer.js +1 -1
- package/es6/components/Layer/LayerContainer.js +2 -2
- package/es6/components/List/index.d.ts +2 -2
- package/es6/components/NameValueList/NameValueList.js +1 -1
- package/es6/components/SelectMultiple/SelectMultiple.js +13 -10
- package/es6/components/SelectMultiple/SelectMultipleValue.js +1 -1
- package/es6/components/index.d.ts +1 -0
- package/es6/components/index.js +1 -0
- package/es6/index.d.ts +1 -0
- package/es6/languages/default.json +15 -2
- package/es6/themes/base.js +1 -1
- package/grommet.min.js +1 -1
- package/grommet.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/languages/default.json +15 -2
- package/package.json +37 -36
- package/themes/base.js +1 -1
|
@@ -129,11 +129,13 @@ var validateForm = function validateForm(validationRules, formValue, format, mes
|
|
|
129
129
|
var name = _ref[0],
|
|
130
130
|
_ref$ = _ref[1],
|
|
131
131
|
field = _ref$.field,
|
|
132
|
-
input = _ref$.input
|
|
132
|
+
input = _ref$.input,
|
|
133
|
+
validateOn = _ref$.validateOn;
|
|
133
134
|
if (!omitValid) {
|
|
134
135
|
nextErrors[name] = undefined;
|
|
135
136
|
nextInfos[name] = undefined;
|
|
136
137
|
}
|
|
138
|
+
if (!validateOn) return;
|
|
137
139
|
var result;
|
|
138
140
|
if (input) {
|
|
139
141
|
// input() a validation function supplied through useFormInput()
|
|
@@ -157,6 +159,9 @@ var validateForm = function validateForm(validationRules, formValue, format, mes
|
|
|
157
159
|
});
|
|
158
160
|
return [nextErrors, nextInfos];
|
|
159
161
|
};
|
|
162
|
+
var isInstantValidate = function isInstantValidate(validateOn) {
|
|
163
|
+
return ['blur', 'change'].includes(validateOn);
|
|
164
|
+
};
|
|
160
165
|
var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
161
166
|
var children = _ref2.children,
|
|
162
167
|
_ref2$errors = _ref2.errors,
|
|
@@ -170,7 +175,7 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
170
175
|
_onSubmit = _ref2.onSubmit,
|
|
171
176
|
onValidate = _ref2.onValidate,
|
|
172
177
|
_ref2$validate = _ref2.validate,
|
|
173
|
-
|
|
178
|
+
validateOnProp = _ref2$validate === void 0 ? 'submit' : _ref2$validate,
|
|
174
179
|
valueProp = _ref2.value,
|
|
175
180
|
rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
176
181
|
var formRef = useForwardedRef(ref);
|
|
@@ -185,12 +190,15 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
185
190
|
var _useState2 = useState(defaultTouched),
|
|
186
191
|
touched = _useState2[0],
|
|
187
192
|
setTouched = _useState2[1];
|
|
188
|
-
var _useState3 = useState(
|
|
193
|
+
var _useState3 = useState(validateOnProp),
|
|
194
|
+
validateOn = _useState3[0],
|
|
195
|
+
setValidateOn = _useState3[1];
|
|
196
|
+
var _useState4 = useState({
|
|
189
197
|
errors: errorsProp,
|
|
190
198
|
infos: infosProp
|
|
191
199
|
}),
|
|
192
|
-
validationResults =
|
|
193
|
-
setValidationResults =
|
|
200
|
+
validationResults = _useState4[0],
|
|
201
|
+
setValidationResults = _useState4[1];
|
|
194
202
|
// maintain a copy of validationResults in a ref for useEffects
|
|
195
203
|
// which can't depend on validationResults directly without
|
|
196
204
|
// causing infinite renders.
|
|
@@ -198,16 +206,16 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
198
206
|
// Simulated onMount state. Consider Form to be mounted once it has
|
|
199
207
|
// accounted for values originating from controlled inputs (available
|
|
200
208
|
// at second rendering).
|
|
201
|
-
var
|
|
202
|
-
mounted =
|
|
203
|
-
setMounted =
|
|
209
|
+
var _useState5 = useState('unmounted'),
|
|
210
|
+
mounted = _useState5[0],
|
|
211
|
+
setMounted = _useState5[1];
|
|
204
212
|
useEffect(function () {
|
|
205
213
|
if (!mounted) setMounted('mounting');else if (mounted === 'mounting') setMounted('mounted');
|
|
206
214
|
}, [mounted]);
|
|
207
215
|
// `pendingValidation` is the name of the FormField awaiting validation.
|
|
208
|
-
var
|
|
209
|
-
pendingValidation =
|
|
210
|
-
setPendingValidation =
|
|
216
|
+
var _useState6 = useState(undefined),
|
|
217
|
+
pendingValidation = _useState6[0],
|
|
218
|
+
setPendingValidation = _useState6[1];
|
|
211
219
|
var validationRulesRef = useRef({});
|
|
212
220
|
var requiredFields = useRef([]);
|
|
213
221
|
var analyticsRef = useRef({
|
|
@@ -279,16 +287,20 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
279
287
|
var validationRules = Object.entries(validationRulesRef.current);
|
|
280
288
|
// Use simulated onMount state to account for values provided by
|
|
281
289
|
// controlled inputs.
|
|
282
|
-
if (mounted !== 'mounted' &&
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
290
|
+
if (mounted !== 'mounted' && (isInstantValidate(validateOn) || validationRules.some(function (_ref3) {
|
|
291
|
+
var v = _ref3[1];
|
|
292
|
+
return isInstantValidate(v.validateOn);
|
|
293
|
+
})) && Object.keys(value).length > 0 && Object.keys(touched).length === 0) {
|
|
294
|
+
applyValidationRules(validationRules.filter(function (_ref4) {
|
|
295
|
+
var n = _ref4[0],
|
|
296
|
+
v = _ref4[1];
|
|
297
|
+
return getFieldValue(n, value) && v.validateOn;
|
|
286
298
|
})
|
|
287
299
|
// Exlude empty arrays which may be initial values in
|
|
288
300
|
// an input such as DateInput.
|
|
289
|
-
.filter(function (
|
|
290
|
-
var n =
|
|
291
|
-
return !(Array.isArray(value
|
|
301
|
+
.filter(function (_ref5) {
|
|
302
|
+
var n = _ref5[0];
|
|
303
|
+
return !(Array.isArray(getFieldValue(n, value)) && getFieldValue(n, value).length === 0);
|
|
292
304
|
}));
|
|
293
305
|
}
|
|
294
306
|
}, [applyValidationRules, mounted, touched, validateOn, value]);
|
|
@@ -298,10 +310,14 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
298
310
|
useEffect(function () {
|
|
299
311
|
var validationRules = Object.entries(validationRulesRef.current);
|
|
300
312
|
var timer = setTimeout(function () {
|
|
301
|
-
if (pendingValidation &&
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
313
|
+
if (pendingValidation && (isInstantValidate(validateOn) || validationRules.some(function (_ref6) {
|
|
314
|
+
var v = _ref6[1];
|
|
315
|
+
return isInstantValidate(v.validateOn);
|
|
316
|
+
}))) {
|
|
317
|
+
applyValidationRules(validationRules.filter(function (_ref7) {
|
|
318
|
+
var n = _ref7[0],
|
|
319
|
+
v = _ref7[1];
|
|
320
|
+
return (touched[n] || pendingValidation.includes(n)) && v.validateOn;
|
|
305
321
|
}));
|
|
306
322
|
setPendingValidation(undefined);
|
|
307
323
|
}
|
|
@@ -323,8 +339,8 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
323
339
|
var _validationResultsRef2;
|
|
324
340
|
var validationRules = Object.entries(validationRulesRef.current);
|
|
325
341
|
if ((_validationResultsRef2 = validationResultsRef.current) != null && _validationResultsRef2.errors && Object.keys(validationResultsRef.current.errors).length > 0) {
|
|
326
|
-
applyValidationRules(validationRules.filter(function (
|
|
327
|
-
var n =
|
|
342
|
+
applyValidationRules(validationRules.filter(function (_ref8) {
|
|
343
|
+
var n = _ref8[0];
|
|
328
344
|
return touched[n] && validationResultsRef.current.errors[n];
|
|
329
345
|
}));
|
|
330
346
|
}
|
|
@@ -384,14 +400,14 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
384
400
|
// they can have access to it.
|
|
385
401
|
//
|
|
386
402
|
var formContextValue = useMemo(function () {
|
|
387
|
-
var useFormInput = function useFormInput(
|
|
388
|
-
var name =
|
|
389
|
-
componentValue =
|
|
390
|
-
initialValue =
|
|
391
|
-
validateArg =
|
|
392
|
-
var
|
|
393
|
-
inputValue =
|
|
394
|
-
setInputValue =
|
|
403
|
+
var useFormInput = function useFormInput(_ref9) {
|
|
404
|
+
var name = _ref9.name,
|
|
405
|
+
componentValue = _ref9.value,
|
|
406
|
+
initialValue = _ref9.initialValue,
|
|
407
|
+
validateArg = _ref9.validate;
|
|
408
|
+
var _useState7 = useState(initialValue),
|
|
409
|
+
inputValue = _useState7[0],
|
|
410
|
+
setInputValue = _useState7[1];
|
|
395
411
|
var formValue = name ? getFieldValue(name, value) : undefined;
|
|
396
412
|
// for dynamic forms, we need to track when an input has been added to
|
|
397
413
|
// the form value. if the input is unmounted, we will delete its
|
|
@@ -483,15 +499,26 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
483
499
|
if (initialValue !== undefined) setInputValue(nextComponentValue);
|
|
484
500
|
}];
|
|
485
501
|
};
|
|
486
|
-
var useFormField = function useFormField(
|
|
487
|
-
var errorArg =
|
|
488
|
-
infoArg =
|
|
489
|
-
name =
|
|
490
|
-
required =
|
|
491
|
-
disabled =
|
|
492
|
-
validateArg =
|
|
502
|
+
var useFormField = function useFormField(_ref10) {
|
|
503
|
+
var errorArg = _ref10.error,
|
|
504
|
+
infoArg = _ref10.info,
|
|
505
|
+
name = _ref10.name,
|
|
506
|
+
required = _ref10.required,
|
|
507
|
+
disabled = _ref10.disabled,
|
|
508
|
+
validateArg = _ref10.validate,
|
|
509
|
+
validateOnArg = _ref10.validateOn;
|
|
493
510
|
var error = disabled ? undefined : errorArg || validationResults.errors[name];
|
|
494
511
|
var info = infoArg || validationResults.infos[name];
|
|
512
|
+
useEffect(function () {
|
|
513
|
+
setValidateOn(function (prevValues) {
|
|
514
|
+
var _extends2;
|
|
515
|
+
if (typeof prevValues === 'string') {
|
|
516
|
+
var _ref11;
|
|
517
|
+
return _ref11 = {}, _ref11[name] = validateOnArg || validateOnProp, _ref11;
|
|
518
|
+
}
|
|
519
|
+
return _extends({}, prevValues, (_extends2 = {}, _extends2[name] = validateOnArg || validateOnProp, _extends2));
|
|
520
|
+
});
|
|
521
|
+
}, [validateOnArg, name]);
|
|
495
522
|
|
|
496
523
|
// Create validation rules for field
|
|
497
524
|
useEffect(function () {
|
|
@@ -504,8 +531,21 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
504
531
|
validationRulesRef.current[name] = {};
|
|
505
532
|
}
|
|
506
533
|
validationRulesRef.current[name].field = validateName(validateArg, required);
|
|
534
|
+
|
|
535
|
+
// priority is given to validateOn prop on formField, if it is
|
|
536
|
+
// undefined, then we will use the validate prop value of Form.
|
|
537
|
+
// The reason we don't want to add validateOn = "submit" here is
|
|
538
|
+
// because we don't want to trigger validation of "submit" field
|
|
539
|
+
// when the user is typing in the instant (blur, change)
|
|
540
|
+
// validation fields.
|
|
541
|
+
if (validateOnArg && validateOnArg !== 'submit') {
|
|
542
|
+
validationRulesRef.current[name].validateOn = validateOnArg;
|
|
543
|
+
} else if (!validateOnArg && validateOnProp !== 'submit') {
|
|
544
|
+
validationRulesRef.current[name].validateOn = validateOnProp;
|
|
545
|
+
}
|
|
507
546
|
return function () {
|
|
508
547
|
delete validationRulesRef.current[name].field;
|
|
548
|
+
delete validationRulesRef.current[name].validateOn;
|
|
509
549
|
var requiredFieldIndex = requiredFields.current.indexOf(name);
|
|
510
550
|
if (requiredFieldIndex !== -1) {
|
|
511
551
|
requiredFields.current.splice(requiredFieldIndex, 1);
|
|
@@ -513,15 +553,15 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
513
553
|
};
|
|
514
554
|
}
|
|
515
555
|
return undefined;
|
|
516
|
-
}, [error, name, required, validateArg, disabled]);
|
|
556
|
+
}, [error, name, required, validateArg, disabled, validateOnArg]);
|
|
517
557
|
return {
|
|
518
558
|
error: error,
|
|
519
559
|
info: info,
|
|
520
560
|
inForm: true,
|
|
521
|
-
onBlur: validateOn === 'blur' ? function () {
|
|
561
|
+
onBlur: validateOnArg === 'blur' || validateOn[name] === 'blur' ? function () {
|
|
522
562
|
return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
|
|
523
563
|
} : undefined,
|
|
524
|
-
onChange: validateOn === 'change' ? function () {
|
|
564
|
+
onChange: validateOnArg === 'change' || validateOn[name] === 'change' ? function () {
|
|
525
565
|
return setPendingValidation(pendingValidation ? [].concat(pendingValidation, [name]) : [name]);
|
|
526
566
|
} : undefined
|
|
527
567
|
};
|
|
@@ -531,7 +571,7 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
531
571
|
useFormInput: useFormInput,
|
|
532
572
|
kind: kind
|
|
533
573
|
};
|
|
534
|
-
}, [onChange, kind, pendingValidation, touched, validateOn, validationResults.errors, validationResults.infos, value, valueProp]);
|
|
574
|
+
}, [onChange, kind, pendingValidation, touched, validateOn, validationResults.errors, validationResults.infos, value, valueProp, validateOnProp]);
|
|
535
575
|
return /*#__PURE__*/React.createElement("form", _extends({
|
|
536
576
|
ref: formRef
|
|
537
577
|
}, rest, {
|
|
@@ -569,7 +609,18 @@ var Form = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
569
609
|
// otherwise.
|
|
570
610
|
event.preventDefault();
|
|
571
611
|
setPendingValidation(undefined);
|
|
572
|
-
|
|
612
|
+
// adding validateOn: "submit" prop to the undefined validateOn fields
|
|
613
|
+
// as we want to trigger "submit" validation once form is submitted
|
|
614
|
+
var newValidationRulesRef = Object.keys(validationRulesRef.current).reduce(function (acc, key) {
|
|
615
|
+
acc[key] = validationRulesRef.current[key];
|
|
616
|
+
if (!acc[key].validateOn) {
|
|
617
|
+
acc[key] = _extends({}, validationRulesRef.current[key], {
|
|
618
|
+
validateOn: 'submit'
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return acc;
|
|
622
|
+
}, {});
|
|
623
|
+
var _validateForm2 = validateForm(Object.entries(newValidationRulesRef), value, format, messages, true),
|
|
573
624
|
nextErrors = _validateForm2[0],
|
|
574
625
|
nextInfos = _validateForm2[1];
|
|
575
626
|
setValidationResults(function () {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StatusGood } from "grommet-icons/es6/icons/StatusGood";
|
|
3
|
+
import { Box, Button, Form, FormField, Heading } from 'grommet';
|
|
4
|
+
export var TriggerValidationUsingFormField = function TriggerValidationUsingFormField() {
|
|
5
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
6
|
+
fill: true,
|
|
7
|
+
align: "center",
|
|
8
|
+
justify: "center"
|
|
9
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
10
|
+
width: "medium"
|
|
11
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
12
|
+
alignSelf: "center",
|
|
13
|
+
level: "2"
|
|
14
|
+
}, "Validate On"), /*#__PURE__*/React.createElement(Form, {
|
|
15
|
+
onReset: function onReset(event) {
|
|
16
|
+
return console.log(event);
|
|
17
|
+
},
|
|
18
|
+
onSubmit: function onSubmit(_ref) {
|
|
19
|
+
var value = _ref.value;
|
|
20
|
+
return console.log('Submit', value);
|
|
21
|
+
}
|
|
22
|
+
}, /*#__PURE__*/React.createElement(FormField, {
|
|
23
|
+
label: "Blur",
|
|
24
|
+
name: "blur",
|
|
25
|
+
"aria-label": "blur",
|
|
26
|
+
required: true,
|
|
27
|
+
validate: [{
|
|
28
|
+
regexp: /^[a-z]/i
|
|
29
|
+
}, function (name) {
|
|
30
|
+
if (name && name.length === 1) return 'must be >1 character';
|
|
31
|
+
return undefined;
|
|
32
|
+
}, function (name) {
|
|
33
|
+
if (name === 'good') return {
|
|
34
|
+
message: /*#__PURE__*/React.createElement(Box, {
|
|
35
|
+
align: "end"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(StatusGood, null)),
|
|
37
|
+
status: 'info'
|
|
38
|
+
};
|
|
39
|
+
return undefined;
|
|
40
|
+
}],
|
|
41
|
+
validateOn: "blur"
|
|
42
|
+
}), /*#__PURE__*/React.createElement(FormField, {
|
|
43
|
+
label: "Submit",
|
|
44
|
+
name: "submit",
|
|
45
|
+
"aria-label": "submit",
|
|
46
|
+
required: true,
|
|
47
|
+
validate: [{
|
|
48
|
+
regexp: /^[a-z]/i
|
|
49
|
+
}, function (name) {
|
|
50
|
+
if (name && name.length === 1) return 'must be >1 character';
|
|
51
|
+
return undefined;
|
|
52
|
+
}, function (name) {
|
|
53
|
+
if (name === 'good') return {
|
|
54
|
+
message: /*#__PURE__*/React.createElement(Box, {
|
|
55
|
+
align: "end"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(StatusGood, null)),
|
|
57
|
+
status: 'info'
|
|
58
|
+
};
|
|
59
|
+
return undefined;
|
|
60
|
+
}],
|
|
61
|
+
validateOn: "submit"
|
|
62
|
+
}), /*#__PURE__*/React.createElement(FormField, {
|
|
63
|
+
label: "Change",
|
|
64
|
+
name: "change",
|
|
65
|
+
"aria-label": "change",
|
|
66
|
+
required: true,
|
|
67
|
+
validate: [{
|
|
68
|
+
regexp: /^[a-z]/i
|
|
69
|
+
}, function (name) {
|
|
70
|
+
if (name && name.length === 1) return 'must be >1 character';
|
|
71
|
+
return undefined;
|
|
72
|
+
}, function (name) {
|
|
73
|
+
if (name === 'good') return {
|
|
74
|
+
message: /*#__PURE__*/React.createElement(Box, {
|
|
75
|
+
align: "end"
|
|
76
|
+
}, /*#__PURE__*/React.createElement(StatusGood, null)),
|
|
77
|
+
status: 'info'
|
|
78
|
+
};
|
|
79
|
+
return undefined;
|
|
80
|
+
}],
|
|
81
|
+
validateOn: "change"
|
|
82
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
83
|
+
direction: "row",
|
|
84
|
+
justify: "between",
|
|
85
|
+
margin: {
|
|
86
|
+
top: 'medium'
|
|
87
|
+
}
|
|
88
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
89
|
+
label: "Cancel"
|
|
90
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
91
|
+
type: "reset",
|
|
92
|
+
label: "Reset"
|
|
93
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
94
|
+
type: "submit",
|
|
95
|
+
label: "Update",
|
|
96
|
+
primary: true
|
|
97
|
+
})))));
|
|
98
|
+
};
|
|
99
|
+
TriggerValidationUsingFormField.storyName = 'Trigger Validation using Form Field';
|
|
100
|
+
export default {
|
|
101
|
+
title: 'Input/Form/Trigger Validation using Form Field'
|
|
102
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _excluded = ["error", "info", "message", "type"],
|
|
2
2
|
_excluded2 = ["component", "disabled", "invalid", "name", "onChange"],
|
|
3
|
-
_excluded3 = ["children", "className", "component", "contentProps", "disabled", "error", "help", "htmlFor", "info", "label", "margin", "name", "onBlur", "onChange", "onFocus", "pad", "required", "style", "validate"];
|
|
3
|
+
_excluded3 = ["children", "className", "component", "contentProps", "disabled", "error", "help", "htmlFor", "info", "label", "margin", "name", "onBlur", "onChange", "onFocus", "pad", "required", "style", "validate", "validateOn"];
|
|
4
4
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
import React, { Children, cloneElement, forwardRef, useContext, useState, useEffect } from 'react';
|
|
@@ -153,6 +153,7 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
153
153
|
required = _ref3.required,
|
|
154
154
|
style = _ref3.style,
|
|
155
155
|
validate = _ref3.validate,
|
|
156
|
+
validateOn = _ref3.validateOn,
|
|
156
157
|
rest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
157
158
|
var theme = useContext(ThemeContext) || defaultProps.theme;
|
|
158
159
|
var formContext = useContext(FormContext);
|
|
@@ -162,7 +163,8 @@ var FormField = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
162
163
|
info: infoProp,
|
|
163
164
|
name: name,
|
|
164
165
|
required: required,
|
|
165
|
-
validate: validate
|
|
166
|
+
validate: validate,
|
|
167
|
+
validateOn: validateOn
|
|
166
168
|
}),
|
|
167
169
|
error = _formContext$useFormF.error,
|
|
168
170
|
info = _formContext$useFormF.info,
|
|
@@ -28,7 +28,8 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
28
28
|
// regular expression
|
|
29
29
|
message: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
30
30
|
status: PropTypes.oneOf(['error', 'info'])
|
|
31
|
-
}), PropTypes.func]))])
|
|
31
|
+
}), PropTypes.func]))]),
|
|
32
|
+
validateOn: PropTypes.oneOf(['blur', 'submit', 'change'])
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
export var FormFieldPropTypes = PropType;
|
|
@@ -205,6 +205,7 @@ var InfiniteScroll = function InfiniteScroll(_ref) {
|
|
|
205
205
|
while (replace && i <= lastPage) {
|
|
206
206
|
if (!pageHeights[i] && pageHeights[i] !== pageHeights[0]) {
|
|
207
207
|
if (!nextPageHeights) nextPageHeights = [].concat(pageHeights || []);
|
|
208
|
+
// set to first page height
|
|
208
209
|
var _nextPageHeights = nextPageHeights;
|
|
209
210
|
nextPageHeights[i] = _nextPageHeights[0];
|
|
210
211
|
}
|
|
@@ -54,7 +54,7 @@ var Layer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
54
54
|
}
|
|
55
55
|
setTimeout(function () {
|
|
56
56
|
// we add the id and query here so the unit tests work
|
|
57
|
-
var clone = containerTarget
|
|
57
|
+
var clone = containerTarget.getRootNode().getElementById('layerClone');
|
|
58
58
|
if (clone) {
|
|
59
59
|
containerTarget.removeChild(clone);
|
|
60
60
|
layerContainer.remove();
|
|
@@ -104,8 +104,8 @@ var LayerContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
104
104
|
var onClickDocument = function onClickDocument(event) {
|
|
105
105
|
// determine which portal id the target is in, if any
|
|
106
106
|
var clickedPortalId = null;
|
|
107
|
-
var node =
|
|
108
|
-
while (clickedPortalId === null && node !== document && node
|
|
107
|
+
var node = event.composed && event.composedPath()[0] || event.target;
|
|
108
|
+
while (clickedPortalId === null && node && node !== document && !(node instanceof ShadowRoot)) {
|
|
109
109
|
// check if user click occurred within the layer
|
|
110
110
|
var attr = node.getAttribute('data-g-portal-id');
|
|
111
111
|
if (attr !== null && attr !== '') clickedPortalId = parseInt(attr, 10);
|
|
@@ -43,7 +43,7 @@ export interface ListProps<ListItemType> {
|
|
|
43
43
|
| string[]
|
|
44
44
|
| { light: string | string[]; dark: string | string[] };
|
|
45
45
|
border?: BorderType;
|
|
46
|
-
children?:
|
|
46
|
+
children?: (...args: any[]) => any;
|
|
47
47
|
data?: ListItemType[];
|
|
48
48
|
disabled?: string[];
|
|
49
49
|
gridArea?: GridAreaType;
|
|
@@ -69,7 +69,7 @@ export interface ListProps<ListItemType> {
|
|
|
69
69
|
action?: (item: ListItemType, index: number) => void;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
type ulProps = JSX.IntrinsicElements['ul']
|
|
72
|
+
type ulProps = Omit<JSX.IntrinsicElements['ul'], 'children'>;
|
|
73
73
|
|
|
74
74
|
export interface ListExtendedProps<ListItemType>
|
|
75
75
|
extends ListProps<ListItemType>,
|
|
@@ -47,9 +47,9 @@ var NameValueList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
47
47
|
}, /*#__PURE__*/React.createElement(Grid, _extends({
|
|
48
48
|
as: "dl",
|
|
49
49
|
ref: ref,
|
|
50
|
+
align: align,
|
|
50
51
|
columns: columns,
|
|
51
52
|
gap: gap,
|
|
52
|
-
fill: layout === 'grid',
|
|
53
53
|
margin: "none" // override browser default margin for dl
|
|
54
54
|
}, rest)));
|
|
55
55
|
});
|
|
@@ -38,7 +38,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
38
38
|
defaultValue = _ref.defaultValue,
|
|
39
39
|
disabled = _ref.disabled,
|
|
40
40
|
disabledKey = _ref.disabledKey,
|
|
41
|
-
|
|
41
|
+
dropAlignProp = _ref.dropAlign,
|
|
42
42
|
dropHeight = _ref.dropHeight,
|
|
43
43
|
dropProps = _ref.dropProps,
|
|
44
44
|
dropTarget = _ref.dropTarget,
|
|
@@ -86,6 +86,16 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
86
86
|
var selectBoxRef = useRef();
|
|
87
87
|
var dropButtonRef = useForwardedRef(ref);
|
|
88
88
|
var usingKeyboard = useKeyboard();
|
|
89
|
+
var dropAlign = useMemo(function () {
|
|
90
|
+
return dropAlignProp || (showSelectedInline ? {
|
|
91
|
+
top: 'top',
|
|
92
|
+
right: 'right',
|
|
93
|
+
left: 'left'
|
|
94
|
+
} : {
|
|
95
|
+
top: 'bottom',
|
|
96
|
+
left: 'left'
|
|
97
|
+
});
|
|
98
|
+
}, [dropAlignProp, showSelectedInline]);
|
|
89
99
|
|
|
90
100
|
// value is used for what we receive in valueProp and the basis for
|
|
91
101
|
// what we send with onChange
|
|
@@ -349,11 +359,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
349
359
|
fill: "horizontal",
|
|
350
360
|
alignSelf: "start"
|
|
351
361
|
}, dropButtonProps, {
|
|
352
|
-
dropAlign: dropAlign
|
|
353
|
-
top: 'top',
|
|
354
|
-
right: 'right',
|
|
355
|
-
left: 'left'
|
|
356
|
-
},
|
|
362
|
+
dropAlign: dropAlign,
|
|
357
363
|
dropTarget: dropTarget || selectBoxRef.current
|
|
358
364
|
}), selectValue || displayLabelKey ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Box, {
|
|
359
365
|
direction: "row"
|
|
@@ -396,10 +402,7 @@ var SelectMultiple = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
396
402
|
}, rest)), displaySelectIcon)), !open && (value == null ? void 0 : value.length) > 0 && (selectValue || displayLabelKey))) : /*#__PURE__*/React.createElement(Box, {
|
|
397
403
|
width: width
|
|
398
404
|
}, /*#__PURE__*/React.createElement(StyledSelectDropButton, _extends({}, dropButtonProps, {
|
|
399
|
-
dropAlign: dropAlign
|
|
400
|
-
top: 'bottom',
|
|
401
|
-
left: 'left'
|
|
402
|
-
},
|
|
405
|
+
dropAlign: dropAlign,
|
|
403
406
|
dropTarget: dropTarget,
|
|
404
407
|
alignSelf: alignSelf,
|
|
405
408
|
tabIndex: "0"
|
|
@@ -54,7 +54,7 @@ var SelectMultipleValue = function SelectMultipleValue(_ref) {
|
|
|
54
54
|
onSelectChange(event, {
|
|
55
55
|
option: optionValue,
|
|
56
56
|
value: intermediate.filter(function (v) {
|
|
57
|
-
return typeof v === 'object' ? applyKey(v, valueKey || labelKey)
|
|
57
|
+
return typeof v === 'object' ? applyKey(v, valueKey || labelKey) !== applyKey(optionValue, valueKey || labelKey) : v !== optionValue;
|
|
58
58
|
})
|
|
59
59
|
});
|
|
60
60
|
if (valueIndex !== intermediate.length - 1) {
|
|
@@ -25,6 +25,7 @@ export * from './DataSort';
|
|
|
25
25
|
export * from './DataSummary';
|
|
26
26
|
export * from './DataTable';
|
|
27
27
|
export * from './DataTableColumns';
|
|
28
|
+
export * from './DataTableGroupBy';
|
|
28
29
|
export * from './DataView';
|
|
29
30
|
export * from './DateInput';
|
|
30
31
|
export * from './Diagram';
|
package/es6/components/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from './DataSort';
|
|
|
25
25
|
export * from './DataSummary';
|
|
26
26
|
export * from './DataTable';
|
|
27
27
|
export * from './DataTableColumns';
|
|
28
|
+
export * from './DataTableGroupBy';
|
|
28
29
|
export * from './DataView';
|
|
29
30
|
export * from './DateInput';
|
|
30
31
|
export * from './Diagram';
|
package/es6/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from './components/RoutedButton';
|
|
|
58
58
|
export * from './components/Select';
|
|
59
59
|
export * from './components/SelectMultiple';
|
|
60
60
|
export * from './components/Sidebar';
|
|
61
|
+
export * from './components/Skeleton';
|
|
61
62
|
export * from './components/SkipLink';
|
|
62
63
|
export * from './components/SkipLinks';
|
|
63
64
|
export * from './components/SkipLinkTarget';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"button": {
|
|
3
|
+
"busy": "button is in a busy state",
|
|
4
|
+
"success": "button action succeeded"
|
|
5
|
+
},
|
|
2
6
|
"calendar": {
|
|
3
7
|
"previousMove": "Moved to {date}",
|
|
4
8
|
"previous": "Go to {date}",
|
|
@@ -18,7 +22,11 @@
|
|
|
18
22
|
"dataFilters": {
|
|
19
23
|
"clear": "Clear filters",
|
|
20
24
|
"heading": "Filters",
|
|
21
|
-
"open": "Open filters"
|
|
25
|
+
"open": "Open filters",
|
|
26
|
+
"openSet": {
|
|
27
|
+
"singular": "Open filters, {number} filter applied",
|
|
28
|
+
"plural": "Open filters, {number} filters applied"
|
|
29
|
+
}
|
|
22
30
|
},
|
|
23
31
|
"dataForm": {
|
|
24
32
|
"reset": "Undo changes",
|
|
@@ -43,7 +51,12 @@
|
|
|
43
51
|
"dataTableColumns": {
|
|
44
52
|
"open": "Open column selector",
|
|
45
53
|
"order": "Order columns",
|
|
46
|
-
"select": "Select columns"
|
|
54
|
+
"select": "Select columns",
|
|
55
|
+
"tip": "Manage columns"
|
|
56
|
+
},
|
|
57
|
+
"dataTableGroupBy": {
|
|
58
|
+
"clear": "Clear group",
|
|
59
|
+
"label": "Group by"
|
|
47
60
|
},
|
|
48
61
|
"dataView": {
|
|
49
62
|
"label": "View"
|
package/es6/themes/base.js
CHANGED
|
@@ -29,7 +29,7 @@ var accentColors = ['#6FFFB0', '#FD6FFF', '#81FCED', '#FFCA58'];
|
|
|
29
29
|
var neutralColors = ['#00873D', '#3D138D', '#00739D', '#A2423D'];
|
|
30
30
|
var statusColors = {
|
|
31
31
|
critical: '#FF4040',
|
|
32
|
-
error: '#
|
|
32
|
+
error: '#B30000',
|
|
33
33
|
warning: '#FFAA15',
|
|
34
34
|
ok: '#00C781',
|
|
35
35
|
unknown: '#CCCCCC',
|