@torq-north/react-tools 1.4.1 → 1.4.3
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/dist/index.cjs +44 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +44 -240
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -2
package/dist/index.es.js
CHANGED
|
@@ -386,154 +386,6 @@ function FieldWrapper(_a) {
|
|
|
386
386
|
return (jsxs(Stack, { direction: "row", alignItems: "center", children: [(icon || showSpace) && (jsx(Box, { minWidth: 32, color: "primary.main", mt: 2, mx: 1, children: icon })), children] }));
|
|
387
387
|
}
|
|
388
388
|
|
|
389
|
-
function getDefaultExportFromCjs (x) {
|
|
390
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var cjs;
|
|
394
|
-
var hasRequiredCjs;
|
|
395
|
-
|
|
396
|
-
function requireCjs () {
|
|
397
|
-
if (hasRequiredCjs) return cjs;
|
|
398
|
-
hasRequiredCjs = 1;
|
|
399
|
-
|
|
400
|
-
var isMergeableObject = function isMergeableObject(value) {
|
|
401
|
-
return isNonNullObject(value)
|
|
402
|
-
&& !isSpecial(value)
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
function isNonNullObject(value) {
|
|
406
|
-
return !!value && typeof value === 'object'
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
function isSpecial(value) {
|
|
410
|
-
var stringValue = Object.prototype.toString.call(value);
|
|
411
|
-
|
|
412
|
-
return stringValue === '[object RegExp]'
|
|
413
|
-
|| stringValue === '[object Date]'
|
|
414
|
-
|| isReactElement(value)
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
418
|
-
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
419
|
-
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
420
|
-
|
|
421
|
-
function isReactElement(value) {
|
|
422
|
-
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
function emptyTarget(val) {
|
|
426
|
-
return Array.isArray(val) ? [] : {}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
430
|
-
return (options.clone !== false && options.isMergeableObject(value))
|
|
431
|
-
? deepmerge(emptyTarget(value), value, options)
|
|
432
|
-
: value
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function defaultArrayMerge(target, source, options) {
|
|
436
|
-
return target.concat(source).map(function(element) {
|
|
437
|
-
return cloneUnlessOtherwiseSpecified(element, options)
|
|
438
|
-
})
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function getMergeFunction(key, options) {
|
|
442
|
-
if (!options.customMerge) {
|
|
443
|
-
return deepmerge
|
|
444
|
-
}
|
|
445
|
-
var customMerge = options.customMerge(key);
|
|
446
|
-
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
450
|
-
return Object.getOwnPropertySymbols
|
|
451
|
-
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
452
|
-
return Object.propertyIsEnumerable.call(target, symbol)
|
|
453
|
-
})
|
|
454
|
-
: []
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
function getKeys(target) {
|
|
458
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
function propertyIsOnObject(object, property) {
|
|
462
|
-
try {
|
|
463
|
-
return property in object
|
|
464
|
-
} catch(_) {
|
|
465
|
-
return false
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
470
|
-
function propertyIsUnsafe(target, key) {
|
|
471
|
-
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
472
|
-
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
473
|
-
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function mergeObject(target, source, options) {
|
|
477
|
-
var destination = {};
|
|
478
|
-
if (options.isMergeableObject(target)) {
|
|
479
|
-
getKeys(target).forEach(function(key) {
|
|
480
|
-
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
getKeys(source).forEach(function(key) {
|
|
484
|
-
if (propertyIsUnsafe(target, key)) {
|
|
485
|
-
return
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
489
|
-
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
490
|
-
} else {
|
|
491
|
-
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
return destination
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
function deepmerge(target, source, options) {
|
|
498
|
-
options = options || {};
|
|
499
|
-
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
500
|
-
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
501
|
-
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
502
|
-
// implementations can use it. The caller may not replace it.
|
|
503
|
-
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
504
|
-
|
|
505
|
-
var sourceIsArray = Array.isArray(source);
|
|
506
|
-
var targetIsArray = Array.isArray(target);
|
|
507
|
-
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
508
|
-
|
|
509
|
-
if (!sourceAndTargetTypesMatch) {
|
|
510
|
-
return cloneUnlessOtherwiseSpecified(source, options)
|
|
511
|
-
} else if (sourceIsArray) {
|
|
512
|
-
return options.arrayMerge(target, source, options)
|
|
513
|
-
} else {
|
|
514
|
-
return mergeObject(target, source, options)
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
deepmerge.all = function deepmergeAll(array, options) {
|
|
519
|
-
if (!Array.isArray(array)) {
|
|
520
|
-
throw new Error('first argument should be an array')
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
return array.reduce(function(prev, next) {
|
|
524
|
-
return deepmerge(prev, next, options)
|
|
525
|
-
}, {})
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
var deepmerge_1 = deepmerge;
|
|
529
|
-
|
|
530
|
-
cjs = deepmerge_1;
|
|
531
|
-
return cjs;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
var cjsExports = requireCjs();
|
|
535
|
-
var deepmerge = /*@__PURE__*/getDefaultExportFromCjs(cjsExports);
|
|
536
|
-
|
|
537
389
|
// https://codesandbox.io/s/github/final-form/react-final-form/tree/master/examples/field-level-validation?file=/index.js:557-691
|
|
538
390
|
function composeValidators() {
|
|
539
391
|
var validators = [];
|
|
@@ -560,18 +412,12 @@ function TextFormField(_a) {
|
|
|
560
412
|
var name = _a.name, label = _a.label, required = _a.required, multiline = _a.multiline, disabled = _a.disabled, placeholder = _a.placeholder, slotProps = _a.slotProps, helperText = _a.helperText, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
561
413
|
var _d = useField(name, __assign({ format: format, validate: required
|
|
562
414
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _d.input, meta = _d.meta;
|
|
563
|
-
var
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
placeholder: placeholder,
|
|
570
|
-
error: meta.touched && meta.error,
|
|
571
|
-
helperText: (meta.touched && meta.error) || helperText,
|
|
572
|
-
slotProps: { input: input },
|
|
573
|
-
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {});
|
|
574
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(TextField, __assign({}, textFieldProps)) }));
|
|
415
|
+
var _e = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {}), textFieldSlotProps = _e.slotProps, remainingTextFieldProps = __rest(_e, ["slotProps"]);
|
|
416
|
+
var inputSlotProp = textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.input;
|
|
417
|
+
var mergedSlotProps = __assign(__assign({}, textFieldSlotProps), { input: typeof inputSlotProp === "function"
|
|
418
|
+
? function (ownerState) { return (__assign(__assign({}, input), inputSlotProp(ownerState))); }
|
|
419
|
+
: __assign(__assign({}, input), inputSlotProp) });
|
|
420
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(TextField, __assign({ fullWidth: true, label: label, required: required, multiline: multiline, disabled: disabled, placeholder: placeholder, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, slotProps: mergedSlotProps }, remainingTextFieldProps)) }));
|
|
575
421
|
}
|
|
576
422
|
|
|
577
423
|
function isGroup(o) {
|
|
@@ -618,32 +464,27 @@ function SelectFormField(_a) {
|
|
|
618
464
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
619
465
|
var _e = useField(name, __assign({ format: format, validate: required
|
|
620
466
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
621
|
-
var
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
onChange: onChange,
|
|
631
|
-
slotProps: {
|
|
632
|
-
input: otherInputProps,
|
|
633
|
-
select: {
|
|
634
|
-
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange(undefined); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
635
|
-
},
|
|
636
|
-
},
|
|
637
|
-
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
467
|
+
var _g = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {}), textFieldSlotProps = _g.slotProps, remainingTextFieldProps = __rest(_g, ["slotProps"]);
|
|
468
|
+
// SlotProps can be an object or a callback; we only support the object form here.
|
|
469
|
+
var inputSlotProps = typeof (textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.input) === "function"
|
|
470
|
+
? undefined
|
|
471
|
+
: textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.input;
|
|
472
|
+
var hasEndAdornment = isClearable || (inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment);
|
|
473
|
+
var mergedSlotProps = __assign(__assign({}, textFieldSlotProps), { input: __assign(__assign({}, otherInputProps), inputSlotProps), select: __assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), (hasEndAdornment && {
|
|
474
|
+
endAdornment: (jsxs(Stack, { direction: "row", spacing: 1, pr: 2, children: [inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment, " ", isClearable && (jsx(IconButton, { size: (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _c === void 0 ? void 0 : _c.size, onClick: function () { return onChange(undefined); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }))] })),
|
|
475
|
+
})) });
|
|
638
476
|
var renderedOptions = useMemo(function () { return renderSelectOptions(options); }, [options]);
|
|
639
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({},
|
|
477
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({ fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsx(MenuItem, {})] })) }));
|
|
640
478
|
}
|
|
641
479
|
|
|
642
480
|
function findTextFor(value, options) {
|
|
643
481
|
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
644
482
|
var option = options_1[_i];
|
|
645
483
|
if (isGroup(option)) {
|
|
646
|
-
|
|
484
|
+
var foundOption = findTextFor(value, option.options);
|
|
485
|
+
if (foundOption) {
|
|
486
|
+
return foundOption;
|
|
487
|
+
}
|
|
647
488
|
}
|
|
648
489
|
else if (typeof option === "string") {
|
|
649
490
|
if (option === value) {
|
|
@@ -656,34 +497,22 @@ function findTextFor(value, options) {
|
|
|
656
497
|
}
|
|
657
498
|
}
|
|
658
499
|
}
|
|
659
|
-
return "Unknown";
|
|
660
500
|
}
|
|
661
501
|
function MultiSelectFormField(_a) {
|
|
662
502
|
var _b, _c;
|
|
663
503
|
var name = _a.name, label = _a.label, required = _a.required, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, isClearable = _a.isClearable, options = _a.options, icon = _a.icon, showSpace = _a.showSpace, format = _a.format, _d = _a.validators, validators = _d === void 0 ? [] : _d;
|
|
664
504
|
var _e = useField(name, __assign({ format: format, validate: required
|
|
665
505
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), _f = _e.input, value = _f.value, onChange = _f.onChange, otherInputProps = __rest(_f, ["value", "onChange"]), meta = _e.meta;
|
|
666
|
-
var
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
value: value ? value : [],
|
|
675
|
-
onChange: onChange,
|
|
676
|
-
slotProps: {
|
|
677
|
-
input: otherInputProps,
|
|
678
|
-
select: {
|
|
679
|
-
endAdornment: isClearable ? (jsx(Box, { pr: 2, children: jsx(IconButton, { size: (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _b === void 0 ? void 0 : _b.size, onClick: function () { return onChange([]); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }) })) : undefined,
|
|
680
|
-
multiple: true,
|
|
681
|
-
renderValue: function (selected) { return (jsx(Box, { whiteSpace: "normal", children: selected.map(function (s) { return findTextFor(s, options); }).join(", ") })); },
|
|
682
|
-
},
|
|
683
|
-
},
|
|
684
|
-
}, (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _c !== void 0 ? _c : {});
|
|
506
|
+
var _g = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) !== null && _b !== void 0 ? _b : {}), textFieldSlotProps = _g.slotProps, remainingTextFieldProps = __rest(_g, ["slotProps"]);
|
|
507
|
+
// SlotProps can be an object or a callback; we only support the object form here.
|
|
508
|
+
var inputSlotProps = typeof (textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.input) === "function"
|
|
509
|
+
? undefined
|
|
510
|
+
: textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.input;
|
|
511
|
+
var mergedSlotProps = __assign(__assign({}, textFieldSlotProps), { input: __assign(__assign({}, otherInputProps), inputSlotProps), select: __assign(__assign({}, textFieldSlotProps === null || textFieldSlotProps === void 0 ? void 0 : textFieldSlotProps.select), { endAdornment: (jsxs(Stack, { direction: "row", spacing: 1, pr: 2, children: [inputSlotProps === null || inputSlotProps === void 0 ? void 0 : inputSlotProps.endAdornment, " ", isClearable && (jsx(IconButton, { size: (_c = slotProps === null || slotProps === void 0 ? void 0 : slotProps.textField) === null || _c === void 0 ? void 0 : _c.size, onClick: function () { return onChange([]); }, children: jsx(CloseIcon, { fontSize: "inherit" }) }))] })), multiple: true, renderValue: function (selected) { return (jsx(Box, { whiteSpace: "normal", children: selected
|
|
512
|
+
.map(function (s) { var _a; return (_a = findTextFor(s, options)) !== null && _a !== void 0 ? _a : "Unknown"; })
|
|
513
|
+
.join(", ") })); } }) });
|
|
685
514
|
var renderedOptions = useMemo(function () { return renderCheckboxSelectOptions(options, value); }, [options, value]);
|
|
686
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({},
|
|
515
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsxs(TextField, __assign({ fullWidth: true, select: true, label: label, required: required, disabled: disabled, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, value: value ? value : [], onChange: onChange, slotProps: mergedSlotProps }, remainingTextFieldProps, { children: [renderedOptions, !options && jsx(MenuItem, {})] })) }));
|
|
687
516
|
}
|
|
688
517
|
|
|
689
518
|
var mustBeChecked = function (v) {
|
|
@@ -691,11 +520,10 @@ var mustBeChecked = function (v) {
|
|
|
691
520
|
};
|
|
692
521
|
|
|
693
522
|
var CheckboxFormField = function (_a) {
|
|
694
|
-
var _b;
|
|
695
|
-
var
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
var checkboxProps = deepmerge(__assign(__assign({}, input), { disabled: disabled }), (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox) !== null && _b !== void 0 ? _b : {});
|
|
523
|
+
var name = _a.name, label = _a.label, mustBeTrue = _a.mustBeTrue, disabled = _a.disabled, helperText = _a.helperText, slotProps = _a.slotProps, icon = _a.icon, showSpace = _a.showSpace, _b = _a.validators, validators = _b === void 0 ? [] : _b, forceError = _a.forceError;
|
|
524
|
+
var _c = useField(name, __assign({ type: "checkbox", validate: mustBeTrue
|
|
525
|
+
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [mustBeChecked], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _c.input, meta = _c.meta;
|
|
526
|
+
var checkboxProps = __assign(__assign(__assign({}, input), { disabled: disabled }), slotProps === null || slotProps === void 0 ? void 0 : slotProps.checkbox);
|
|
699
527
|
return (jsxs(FieldWrapper, { icon: icon, showSpace: showSpace, children: [jsx(FormControlLabel, { control: jsx(FormGroup, { children: jsx(Checkbox, __assign({}, checkboxProps)) }), label: label, disabled: disabled }), ((meta.touched && meta.error) || helperText) && (jsx(FormHelperText, { disabled: disabled, error: (meta.touched && meta.error) || forceError, sx: { marginTop: 0, marginLeft: 2 }, children: meta.error || helperText }))] }));
|
|
700
528
|
};
|
|
701
529
|
|
|
@@ -704,25 +532,11 @@ var DateFormField = function (_a) {
|
|
|
704
532
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c, _d = _a.formatAsDate, formatAsDate = _d === void 0 ? false : _d;
|
|
705
533
|
var _e = useField(name, __assign({ format: format, validate: required
|
|
706
534
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _e.input, meta = _e.meta;
|
|
707
|
-
var
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
views: ["year", "month", "day"],
|
|
711
|
-
slotProps: {
|
|
712
|
-
textField: {
|
|
713
|
-
fullWidth: true,
|
|
714
|
-
required: required,
|
|
715
|
-
color: meta.touched && meta.error ? "error" : undefined,
|
|
716
|
-
error: meta.touched && meta.error,
|
|
717
|
-
helperText: (meta.touched && meta.error) || helperText,
|
|
718
|
-
onFocus: input.onFocus,
|
|
719
|
-
onBlur: input.onBlur,
|
|
720
|
-
},
|
|
721
|
-
},
|
|
722
|
-
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {});
|
|
723
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DatePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) {
|
|
535
|
+
var _f = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.datePicker) !== null && _b !== void 0 ? _b : {}), datePickerSlotProps = _f.slotProps, remainingDatePickerProps = __rest(_f, ["slotProps"]);
|
|
536
|
+
var mergedSlotProps = __assign(__assign({}, datePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta.touched && meta.error ? "error" : undefined, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, datePickerSlotProps === null || datePickerSlotProps === void 0 ? void 0 : datePickerSlotProps.textField) });
|
|
537
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DatePicker, __assign({ label: label, disabled: disabled, views: ["year", "month", "day"], value: input.value ? dayjs(input.value) : null, onChange: function (value) {
|
|
724
538
|
return input.onChange(formatAsDate ? value === null || value === void 0 ? void 0 : value.format("YYYY-MM-DD") : value === null || value === void 0 ? void 0 : value.toJSON());
|
|
725
|
-
} },
|
|
539
|
+
}, slotProps: mergedSlotProps }, remainingDatePickerProps)) }));
|
|
726
540
|
};
|
|
727
541
|
|
|
728
542
|
var DateTimeFormField = function (_a) {
|
|
@@ -730,23 +544,9 @@ var DateTimeFormField = function (_a) {
|
|
|
730
544
|
var name = _a.name, label = _a.label, required = _a.required, icon = _a.icon, showSpace = _a.showSpace, slotProps = _a.slotProps, disabled = _a.disabled, helperText = _a.helperText, format = _a.format, _c = _a.validators, validators = _c === void 0 ? [] : _c;
|
|
731
545
|
var _d = useField(name, __assign({ format: format, validate: required
|
|
732
546
|
? composeValidators.apply(void 0, __spreadArray(__spreadArray([], validators, false), [isRequired], false)) : composeValidators.apply(void 0, validators) }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.field)), input = _d.input, meta = _d.meta;
|
|
733
|
-
var
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
views: ["year", "month", "day"],
|
|
737
|
-
slotProps: {
|
|
738
|
-
textField: {
|
|
739
|
-
fullWidth: true,
|
|
740
|
-
required: required,
|
|
741
|
-
color: meta.touched && meta.error ? "error" : undefined,
|
|
742
|
-
error: meta.touched && meta.error,
|
|
743
|
-
helperText: (meta.touched && meta.error) || helperText,
|
|
744
|
-
onFocus: input.onFocus,
|
|
745
|
-
onBlur: input.onBlur,
|
|
746
|
-
},
|
|
747
|
-
},
|
|
748
|
-
}, (_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {});
|
|
749
|
-
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DateTimePicker, __assign({ value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); } }, dateTimeProps)) }));
|
|
547
|
+
var _e = ((_b = slotProps === null || slotProps === void 0 ? void 0 : slotProps.dateTimePicker) !== null && _b !== void 0 ? _b : {}), dateTimePickerSlotProps = _e.slotProps, remainingDateTimePickerProps = __rest(_e, ["slotProps"]);
|
|
548
|
+
var mergedSlotProps = __assign(__assign({}, dateTimePickerSlotProps), { textField: __assign({ fullWidth: true, required: required, color: meta.touched && meta.error ? "error" : undefined, error: meta.touched && meta.error, helperText: (meta.touched && meta.error) || helperText, onFocus: input.onFocus, onBlur: input.onBlur }, dateTimePickerSlotProps === null || dateTimePickerSlotProps === void 0 ? void 0 : dateTimePickerSlotProps.textField) });
|
|
549
|
+
return (jsx(FieldWrapper, { icon: icon, showSpace: showSpace, children: jsx(DateTimePicker, __assign({ label: label, disabled: disabled, value: input.value ? dayjs(input.value) : null, onChange: function (value) { return input.onChange(value === null || value === void 0 ? void 0 : value.toJSON()); }, slotProps: mergedSlotProps }, remainingDateTimePickerProps)) }));
|
|
750
550
|
};
|
|
751
551
|
|
|
752
552
|
//Courtesy of https://stackoverflow.com/questions/58099124/how-to-use-custom-radio-component-with-react-final-form
|
|
@@ -874,6 +674,10 @@ function FileDisplay(_a) {
|
|
|
874
674
|
return (jsx(Stack, { children: files.map(function (f) { return (jsx(IndividualFile, __assign({ file: f }, individualFileProps), isAsset(f) ? f.id : f.name)); }) }));
|
|
875
675
|
}
|
|
876
676
|
|
|
677
|
+
function getDefaultExportFromCjs (x) {
|
|
678
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
679
|
+
}
|
|
680
|
+
|
|
877
681
|
var propTypes = {exports: {}};
|
|
878
682
|
|
|
879
683
|
var reactIs = {exports: {}};
|