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