@rjsf/mantine 6.0.0-beta.22 → 6.0.0-beta.23
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 +78 -210
- package/dist/index.cjs.map +4 -4
- package/dist/mantine.esm.js +78 -212
- package/dist/mantine.esm.js.map +4 -4
- package/dist/mantine.umd.js +85 -216
- package/lib/templates/FieldHelpTemplate.js +4 -1
- package/lib/templates/FieldHelpTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +1 -7
- package/lib/widgets/DateTime/AltDateTimeWidget.js +1 -6
- package/lib/widgets/DateTime/AltDateTimeWidget.js.map +1 -1
- package/lib/widgets/DateTime/AltDateWidget.d.ts +1 -7
- package/lib/widgets/DateTime/AltDateWidget.js +6 -39
- package/lib/widgets/DateTime/AltDateWidget.js.map +1 -1
- package/lib/widgets/FileWidget.js +9 -87
- package/lib/widgets/FileWidget.js.map +1 -1
- package/package.json +7 -7
- package/src/templates/FieldHelpTemplate.tsx +5 -1
- package/src/widgets/DateTime/AltDateTimeWidget.tsx +1 -8
- package/src/widgets/DateTime/AltDateWidget.tsx +6 -71
- package/src/widgets/FileWidget.tsx +20 -112
package/dist/mantine.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('@rjsf/utils'), require('@mantine/core'), require('react/jsx-runtime'), require('react'), require('dayjs'), require('dayjs/plugin/customParseFormat'), require('@mantine/dates')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', '@rjsf/utils', '@mantine/core', 'react/jsx-runtime', 'react', 'dayjs', 'dayjs/plugin/customParseFormat', '@mantine/dates'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mantine"] = {}, global.core
|
|
5
|
-
})(this, (function (exports, core
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mantine"] = {}, global.core, global.utils, global.core$1, global.jsxRuntime, global.react, global.dayjs, global.customParseFormat, global.dates));
|
|
5
|
+
})(this, (function (exports, core, utils, core$1, jsxRuntime, react, dayjs, customParseFormat, dates) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/Form/index.ts
|
|
8
8
|
function ArrayFieldItemTemplate(props) {
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
registry,
|
|
14
14
|
uiOptions
|
|
15
15
|
);
|
|
16
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { className: className || "rjsf-array-item", mb: "xs", children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
|
|
17
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.Box, { w: "100%", children }),
|
|
18
|
-
hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { wrap: "nowrap", gap: 2, mb: 7, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { className: className || "rjsf-array-item", mb: "xs", children: /* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "end", justify: "center", children: [
|
|
17
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { w: "100%", children }),
|
|
18
|
+
hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { wrap: "nowrap", gap: 2, mb: 7, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
|
|
19
19
|
] }) }, `array-item-${index}`);
|
|
20
20
|
}
|
|
21
21
|
function ArrayFieldTemplate(props) {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(core.Fieldset, { legend, className, id: fieldPathId.$id, children: [
|
|
64
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Fieldset, { legend, className, id: fieldPathId.$id, children: [
|
|
65
65
|
(uiOptions.description || schema.description) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
66
|
ArrayFieldDescriptionTemplate,
|
|
67
67
|
{
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
registry
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
|
-
/* @__PURE__ */ jsxRuntime.jsxs(core.Box, { className: "row rjsf-array-item-list", children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core$1.Box, { className: "row rjsf-array-item-list", children: [
|
|
76
76
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
77
77
|
items
|
|
78
78
|
] }),
|
|
79
|
-
canAdd && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
canAdd && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
80
|
AddButton2,
|
|
81
81
|
{
|
|
82
82
|
id: utils.buttonId(fieldPathId, "add"),
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
if (!title || !displayLabel) {
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id: utils.titleId(fieldPathId), order: 4, fw: "normal", children: title });
|
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { id: utils.titleId(fieldPathId), order: 4, fw: "normal", children: title });
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// src/utils.ts
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
[onFocus, id]
|
|
182
182
|
);
|
|
183
183
|
const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
184
|
-
core.NumberInput,
|
|
184
|
+
core$1.NumberInput,
|
|
185
185
|
{
|
|
186
186
|
id,
|
|
187
187
|
name: htmlName || id,
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
204
204
|
}
|
|
205
205
|
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
206
|
-
core.TextInput,
|
|
206
|
+
core$1.TextInput,
|
|
207
207
|
{
|
|
208
208
|
id,
|
|
209
209
|
name: htmlName || id,
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
function DescriptionField(props) {
|
|
235
235
|
const { id, description, registry, uiSchema } = props;
|
|
236
236
|
if (description) {
|
|
237
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Text, { id, mt: 3, mb: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(core
|
|
237
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Text, { id, mt: 3, mb: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(core.RichDescription, { description, registry, uiSchema }) });
|
|
238
238
|
}
|
|
239
239
|
return null;
|
|
240
240
|
}
|
|
@@ -386,13 +386,13 @@
|
|
|
386
386
|
}) {
|
|
387
387
|
const { translateString } = registry;
|
|
388
388
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
389
|
-
core.Alert,
|
|
389
|
+
core$1.Alert,
|
|
390
390
|
{
|
|
391
391
|
color: "red",
|
|
392
392
|
variant: "transparent",
|
|
393
|
-
title: /* @__PURE__ */ jsxRuntime.jsx(core.Title, { order: 5, fw: "normal", children: translateString(utils.TranslatableString.ErrorsLabel) }),
|
|
393
|
+
title: /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { order: 5, fw: "normal", children: translateString(utils.TranslatableString.ErrorsLabel) }),
|
|
394
394
|
icon: /* @__PURE__ */ jsxRuntime.jsx(ExclamationCircle, {}),
|
|
395
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { c: "red", children: error.stack }, `error-${index}`)) })
|
|
395
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(core$1.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.List.Item, { c: "red", children: error.stack }, `error-${index}`)) })
|
|
396
396
|
}
|
|
397
397
|
);
|
|
398
398
|
}
|
|
@@ -401,12 +401,12 @@
|
|
|
401
401
|
if (norender) {
|
|
402
402
|
return null;
|
|
403
403
|
}
|
|
404
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Button, { type: "submit", variant: "filled", ...submitButtonProps, children: submitText });
|
|
404
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { type: "submit", variant: "filled", ...submitButtonProps, children: submitText });
|
|
405
405
|
}
|
|
406
406
|
function IconButton(props) {
|
|
407
407
|
const { icon, iconType = "sm", color, onClick, uiSchema, registry, ...otherProps } = props;
|
|
408
408
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
409
|
-
core.ActionIcon,
|
|
409
|
+
core$1.ActionIcon,
|
|
410
410
|
{
|
|
411
411
|
size: iconType,
|
|
412
412
|
color,
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
return null;
|
|
490
490
|
}
|
|
491
491
|
const id = utils.errorId(fieldPathId);
|
|
492
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { id, c: "red", display: "none", children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { children: error }, `field-error-${index}`)) }) });
|
|
492
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { id, c: "red", display: "none", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.List.Item, { children: error }, `field-error-${index}`)) }) });
|
|
493
493
|
}
|
|
494
494
|
function FieldTemplate(props) {
|
|
495
495
|
const {
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
uiOptions
|
|
517
517
|
);
|
|
518
518
|
if (hidden) {
|
|
519
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { display: "none", children });
|
|
519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { display: "none", children });
|
|
520
520
|
}
|
|
521
521
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
522
522
|
WrapIfAdditionalTemplate2,
|
|
@@ -539,18 +539,21 @@
|
|
|
539
539
|
}
|
|
540
540
|
function FieldHelpTemplate(props) {
|
|
541
541
|
const { fieldPathId, help } = props;
|
|
542
|
+
if (!help) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
542
545
|
const id = utils.helpId(fieldPathId);
|
|
543
|
-
return
|
|
546
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Text, { id, size: "sm", my: "xs", c: "dimmed", children: help });
|
|
544
547
|
}
|
|
545
548
|
function GridTemplate(props) {
|
|
546
549
|
const { children, column, fluid = true, ...rest } = props;
|
|
547
550
|
if (column) {
|
|
548
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { ...rest, children });
|
|
551
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { ...rest, children });
|
|
549
552
|
}
|
|
550
553
|
if (fluid) {
|
|
551
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Container, { p: "4", mx: 0, w: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { ...rest, children }) });
|
|
554
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Container, { p: "4", mx: 0, w: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid, { ...rest, children }) });
|
|
552
555
|
}
|
|
553
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { grow: true, ...rest, children });
|
|
556
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid, { grow: true, ...rest, children });
|
|
554
557
|
}
|
|
555
558
|
function ObjectFieldTemplate(props) {
|
|
556
559
|
const {
|
|
@@ -582,7 +585,7 @@
|
|
|
582
585
|
const gridCols = typeof uiOptions?.gridCols === "number" && uiOptions?.gridCols || void 0;
|
|
583
586
|
const gridSpacing = uiOptions?.gridSpacing;
|
|
584
587
|
const gridVerticalSpacing = uiOptions?.gridVerticalSpacing;
|
|
585
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(core.Container, { id: fieldPathId.$id, p: 0, children: [
|
|
588
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Container, { id: fieldPathId.$id, p: 0, children: [
|
|
586
589
|
title && /* @__PURE__ */ jsxRuntime.jsx(
|
|
587
590
|
TitleFieldTemplate,
|
|
588
591
|
{
|
|
@@ -606,7 +609,7 @@
|
|
|
606
609
|
}
|
|
607
610
|
),
|
|
608
611
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
609
|
-
core.SimpleGrid,
|
|
612
|
+
core$1.SimpleGrid,
|
|
610
613
|
{
|
|
611
614
|
cols: gridCols,
|
|
612
615
|
spacing: gridSpacing,
|
|
@@ -614,11 +617,11 @@
|
|
|
614
617
|
mb: "sm",
|
|
615
618
|
children: [
|
|
616
619
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
617
|
-
properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: element.content }, element.name))
|
|
620
|
+
properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { children: element.content }, element.name))
|
|
618
621
|
]
|
|
619
622
|
}
|
|
620
623
|
),
|
|
621
|
-
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { mt: "xs", justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
624
|
+
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { mt: "xs", justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
622
625
|
AddButton2,
|
|
623
626
|
{
|
|
624
627
|
id: utils.buttonId(fieldPathId, "add"),
|
|
@@ -662,11 +665,11 @@
|
|
|
662
665
|
}
|
|
663
666
|
function TitleField(props) {
|
|
664
667
|
const { id, title, optionalDataControl } = props;
|
|
665
|
-
let heading = title ? /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id, order: 3, fw: "normal", children: title }) : null;
|
|
668
|
+
let heading = title ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { id, order: 3, fw: "normal", children: title }) : null;
|
|
666
669
|
if (optionalDataControl) {
|
|
667
|
-
heading = /* @__PURE__ */ jsxRuntime.jsxs(core.Grid, { children: [
|
|
668
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: "auto", children: heading }),
|
|
669
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: "content", children: optionalDataControl })
|
|
670
|
+
heading = /* @__PURE__ */ jsxRuntime.jsxs(core$1.Grid, { children: [
|
|
671
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: "auto", children: heading }),
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: "content", children: optionalDataControl })
|
|
670
673
|
] });
|
|
671
674
|
}
|
|
672
675
|
return heading;
|
|
@@ -699,10 +702,10 @@
|
|
|
699
702
|
...uiSchema,
|
|
700
703
|
[utils.UI_OPTIONS_KEY]: { ...uiOptions, block: true }
|
|
701
704
|
};
|
|
702
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
|
|
703
|
-
/* @__PURE__ */ jsxRuntime.jsxs(core.Grid, { w: "100%", align: "center", children: [
|
|
704
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
705
|
-
core.TextInput,
|
|
705
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "end", justify: "center", children: [
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core$1.Grid, { w: "100%", align: "center", children: [
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: 6, className: "form-additional", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
708
|
+
core$1.TextInput,
|
|
706
709
|
{
|
|
707
710
|
className: "form-group",
|
|
708
711
|
label: keyLabel,
|
|
@@ -714,7 +717,7 @@
|
|
|
714
717
|
onBlur: !readonly ? onKeyRenameBlur : void 0
|
|
715
718
|
}
|
|
716
719
|
) }) }),
|
|
717
|
-
/* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children })
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: 6, className: "form-additional", children })
|
|
718
721
|
] }),
|
|
719
722
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
720
723
|
RemoveButton2,
|
|
@@ -731,7 +734,7 @@
|
|
|
731
734
|
] }) });
|
|
732
735
|
}
|
|
733
736
|
function MultiSchemaFieldTemplate({ selector, optionSchemaField }) {
|
|
734
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(core.Stack, { style: { marginBottom: "1rem" }, children: [
|
|
737
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Stack, { style: { marginBottom: "1rem" }, children: [
|
|
735
738
|
selector,
|
|
736
739
|
optionSchemaField
|
|
737
740
|
] });
|
|
@@ -759,66 +762,21 @@
|
|
|
759
762
|
};
|
|
760
763
|
}
|
|
761
764
|
var templates_default = generateTemplates();
|
|
762
|
-
function
|
|
763
|
-
|
|
765
|
+
function AltDateTimeWidget(props) {
|
|
766
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { time: true, ...props });
|
|
764
768
|
}
|
|
765
769
|
function AltDateWidget(props) {
|
|
766
|
-
const {
|
|
767
|
-
id,
|
|
768
|
-
value,
|
|
769
|
-
required,
|
|
770
|
-
disabled,
|
|
771
|
-
readonly,
|
|
772
|
-
label,
|
|
773
|
-
hideLabel,
|
|
774
|
-
rawErrors,
|
|
775
|
-
options,
|
|
776
|
-
onChange,
|
|
777
|
-
showTime = false,
|
|
778
|
-
registry
|
|
779
|
-
} = props;
|
|
770
|
+
const { id, required, disabled, readonly, label, hideLabel, rawErrors, options, registry } = props;
|
|
780
771
|
const { translateString } = registry;
|
|
781
|
-
const
|
|
782
|
-
react.useEffect(() => {
|
|
783
|
-
setState(utils.parseDateString(value, showTime));
|
|
784
|
-
}, [showTime, value]);
|
|
785
|
-
const handleChange = react.useCallback(
|
|
786
|
-
(property, nextValue) => {
|
|
787
|
-
const nextState = {
|
|
788
|
-
...state,
|
|
789
|
-
[property]: typeof nextValue === "undefined" ? -1 : nextValue
|
|
790
|
-
};
|
|
791
|
-
if (readyForChange(nextState)) {
|
|
792
|
-
onChange(utils.toDateString(nextState, showTime));
|
|
793
|
-
} else {
|
|
794
|
-
setState(nextState);
|
|
795
|
-
}
|
|
796
|
-
},
|
|
797
|
-
[state, onChange, showTime]
|
|
798
|
-
);
|
|
799
|
-
const handleSetNow = react.useCallback(() => {
|
|
800
|
-
if (!disabled && !readonly) {
|
|
801
|
-
const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
|
|
802
|
-
onChange(utils.toDateString(nextState, showTime));
|
|
803
|
-
}
|
|
804
|
-
}, [disabled, readonly, showTime, onChange]);
|
|
805
|
-
const handleClear = react.useCallback(() => {
|
|
806
|
-
if (!disabled && !readonly) {
|
|
807
|
-
onChange("");
|
|
808
|
-
}
|
|
809
|
-
}, [disabled, readonly, onChange]);
|
|
772
|
+
const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
|
|
810
773
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
811
|
-
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
812
|
-
/* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
options.format
|
|
818
|
-
).map((elemProps, i) => {
|
|
819
|
-
const elemId = id + "_" + elemProps.type;
|
|
820
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
821
|
-
core.Select,
|
|
774
|
+
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
775
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
|
|
776
|
+
elements.map((elemProps, i) => {
|
|
777
|
+
const elemId = `${id}_${elemProps.type}`;
|
|
778
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
779
|
+
core$1.Select,
|
|
822
780
|
{
|
|
823
781
|
id: elemId,
|
|
824
782
|
name: elemId,
|
|
@@ -826,7 +784,7 @@
|
|
|
826
784
|
disabled: disabled || readonly,
|
|
827
785
|
data: utils.dateRangeOptions(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
|
|
828
786
|
value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
|
|
829
|
-
onChange: (v) => handleChange(elemProps.type, v),
|
|
787
|
+
onChange: (v) => handleChange(elemProps.type, v || void 0),
|
|
830
788
|
searchable: false,
|
|
831
789
|
allowDeselect: false,
|
|
832
790
|
comboboxProps: { withinPortal: false },
|
|
@@ -834,25 +792,14 @@
|
|
|
834
792
|
}
|
|
835
793
|
) }, i);
|
|
836
794
|
}),
|
|
837
|
-
/* @__PURE__ */ jsxRuntime.jsxs(core.Group, { wrap: "nowrap", gap: 3, children: [
|
|
838
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }),
|
|
839
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) })
|
|
795
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core$1.Group, { wrap: "nowrap", gap: 3, children: [
|
|
796
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }),
|
|
797
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) })
|
|
840
798
|
] })
|
|
841
799
|
] }),
|
|
842
|
-
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
|
|
800
|
+
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
|
|
843
801
|
] });
|
|
844
802
|
}
|
|
845
|
-
AltDateWidget.defaultProps = {
|
|
846
|
-
showTime: false
|
|
847
|
-
};
|
|
848
|
-
function AltDateTimeWidget(props) {
|
|
849
|
-
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
850
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { showTime: true, ...props });
|
|
851
|
-
}
|
|
852
|
-
AltDateTimeWidget.defaultProps = {
|
|
853
|
-
...AltDateWidget?.defaultProps,
|
|
854
|
-
showTime: true
|
|
855
|
-
};
|
|
856
803
|
var dateParser = (input, format) => {
|
|
857
804
|
if (!input) {
|
|
858
805
|
return null;
|
|
@@ -1057,9 +1004,9 @@
|
|
|
1057
1004
|
);
|
|
1058
1005
|
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
|
|
1059
1006
|
return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1060
|
-
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
1007
|
+
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
1061
1008
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1062
|
-
core.Checkbox.Group,
|
|
1009
|
+
core$1.Checkbox.Group,
|
|
1063
1010
|
{
|
|
1064
1011
|
id,
|
|
1065
1012
|
value: selectedIndexes,
|
|
@@ -1069,8 +1016,8 @@
|
|
|
1069
1016
|
error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
|
|
1070
1017
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1071
1018
|
...themeProps,
|
|
1072
|
-
children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1073
|
-
core.Checkbox,
|
|
1019
|
+
children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1020
|
+
core$1.Checkbox,
|
|
1074
1021
|
{
|
|
1075
1022
|
id: utils.optionId(id, i),
|
|
1076
1023
|
name: htmlName || id,
|
|
@@ -1151,7 +1098,7 @@
|
|
|
1151
1098
|
}
|
|
1152
1099
|
),
|
|
1153
1100
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1154
|
-
core.Checkbox,
|
|
1101
|
+
core$1.Checkbox,
|
|
1155
1102
|
{
|
|
1156
1103
|
id,
|
|
1157
1104
|
name: htmlName || name,
|
|
@@ -1212,7 +1159,7 @@
|
|
|
1212
1159
|
[onFocus, id]
|
|
1213
1160
|
);
|
|
1214
1161
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1215
|
-
core.ColorInput,
|
|
1162
|
+
core$1.ColorInput,
|
|
1216
1163
|
{
|
|
1217
1164
|
id,
|
|
1218
1165
|
name,
|
|
@@ -1232,62 +1179,6 @@
|
|
|
1232
1179
|
}
|
|
1233
1180
|
);
|
|
1234
1181
|
}
|
|
1235
|
-
function addNameToDataURL(dataURL, name) {
|
|
1236
|
-
if (dataURL === null) {
|
|
1237
|
-
return null;
|
|
1238
|
-
}
|
|
1239
|
-
return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
|
|
1240
|
-
}
|
|
1241
|
-
function processFile(file) {
|
|
1242
|
-
const { name, size, type } = file;
|
|
1243
|
-
return new Promise((resolve, reject) => {
|
|
1244
|
-
const reader = new window.FileReader();
|
|
1245
|
-
reader.onerror = reject;
|
|
1246
|
-
reader.onload = (event) => {
|
|
1247
|
-
if (typeof event.target?.result === "string") {
|
|
1248
|
-
resolve({
|
|
1249
|
-
dataURL: addNameToDataURL(event.target.result, name),
|
|
1250
|
-
name,
|
|
1251
|
-
size,
|
|
1252
|
-
type
|
|
1253
|
-
});
|
|
1254
|
-
} else {
|
|
1255
|
-
resolve({
|
|
1256
|
-
dataURL: null,
|
|
1257
|
-
name,
|
|
1258
|
-
size,
|
|
1259
|
-
type
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
reader.readAsDataURL(file);
|
|
1264
|
-
});
|
|
1265
|
-
}
|
|
1266
|
-
function processFiles(files) {
|
|
1267
|
-
return Promise.all(Array.from(files).map(processFile));
|
|
1268
|
-
}
|
|
1269
|
-
function extractFileInfo(dataURLs) {
|
|
1270
|
-
return dataURLs.reduce((acc, dataURL) => {
|
|
1271
|
-
if (!dataURL) {
|
|
1272
|
-
return acc;
|
|
1273
|
-
}
|
|
1274
|
-
try {
|
|
1275
|
-
const { blob, name } = utils.dataURItoBlob(dataURL);
|
|
1276
|
-
return [
|
|
1277
|
-
...acc,
|
|
1278
|
-
{
|
|
1279
|
-
dataURL,
|
|
1280
|
-
name,
|
|
1281
|
-
size: blob.size,
|
|
1282
|
-
type: blob.type
|
|
1283
|
-
}
|
|
1284
|
-
];
|
|
1285
|
-
} catch (e) {
|
|
1286
|
-
console.log(e);
|
|
1287
|
-
return acc;
|
|
1288
|
-
}
|
|
1289
|
-
}, []);
|
|
1290
|
-
}
|
|
1291
1182
|
function FileWidget(props) {
|
|
1292
1183
|
const {
|
|
1293
1184
|
id,
|
|
@@ -1305,46 +1196,24 @@
|
|
|
1305
1196
|
multiple,
|
|
1306
1197
|
onChange
|
|
1307
1198
|
} = props;
|
|
1199
|
+
const { filesInfo, handleChange, handleRemove } = utils.useFileWidgetProps(value, onChange, multiple);
|
|
1308
1200
|
const themeProps = cleanupOptions(options);
|
|
1309
|
-
const
|
|
1201
|
+
const handleOnChange = react.useCallback(
|
|
1310
1202
|
(files) => {
|
|
1311
1203
|
if (typeof files === "object") {
|
|
1312
|
-
|
|
1313
|
-
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
|
|
1314
|
-
if (multiple) {
|
|
1315
|
-
onChange(value.concat(newValue));
|
|
1316
|
-
} else {
|
|
1317
|
-
onChange(newValue[0]);
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
return;
|
|
1322
|
-
},
|
|
1323
|
-
[multiple, value, onChange]
|
|
1324
|
-
);
|
|
1325
|
-
const handleRemoveFile = react.useCallback(
|
|
1326
|
-
(index) => {
|
|
1327
|
-
if (multiple) {
|
|
1328
|
-
const newValue = value.filter((_, i) => i !== index);
|
|
1329
|
-
onChange(newValue);
|
|
1330
|
-
} else {
|
|
1331
|
-
onChange(void 0);
|
|
1204
|
+
handleChange(files);
|
|
1332
1205
|
}
|
|
1333
1206
|
},
|
|
1334
|
-
[
|
|
1335
|
-
);
|
|
1336
|
-
const ValueComponent = react.useCallback(
|
|
1337
|
-
(props2) => {
|
|
1338
|
-
const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
|
|
1339
|
-
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1340
|
-
return /* @__PURE__ */ jsxRuntime.jsx(core.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
|
|
1341
|
-
}
|
|
1342
|
-
return null;
|
|
1343
|
-
},
|
|
1344
|
-
[handleRemoveFile]
|
|
1207
|
+
[handleChange]
|
|
1345
1208
|
);
|
|
1209
|
+
const ValueComponent = react.useCallback(() => {
|
|
1210
|
+
if (Array.isArray(filesInfo) && filesInfo.length > 0) {
|
|
1211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(core$1.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Pill, { withRemoveButton: true, onRemove: () => handleRemove(index), children: file.name }, index)) });
|
|
1212
|
+
}
|
|
1213
|
+
return null;
|
|
1214
|
+
}, [handleRemove, filesInfo]);
|
|
1346
1215
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1347
|
-
core.FileInput,
|
|
1216
|
+
core$1.FileInput,
|
|
1348
1217
|
{
|
|
1349
1218
|
id,
|
|
1350
1219
|
name,
|
|
@@ -1356,7 +1225,7 @@
|
|
|
1356
1225
|
label: utils.labelValue(label || void 0, hideLabel, false),
|
|
1357
1226
|
multiple: !!multiple,
|
|
1358
1227
|
valueComponent: ValueComponent,
|
|
1359
|
-
onChange:
|
|
1228
|
+
onChange: handleOnChange,
|
|
1360
1229
|
error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
|
|
1361
1230
|
...themeProps,
|
|
1362
1231
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
@@ -1406,7 +1275,7 @@
|
|
|
1406
1275
|
[onFocus, id]
|
|
1407
1276
|
);
|
|
1408
1277
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1409
|
-
core.PasswordInput,
|
|
1278
|
+
core$1.PasswordInput,
|
|
1410
1279
|
{
|
|
1411
1280
|
id,
|
|
1412
1281
|
name,
|
|
@@ -1470,7 +1339,7 @@
|
|
|
1470
1339
|
);
|
|
1471
1340
|
const selected = utils.enumOptionsIndexForValue(value, enumOptions);
|
|
1472
1341
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1473
|
-
core.Radio.Group,
|
|
1342
|
+
core$1.Radio.Group,
|
|
1474
1343
|
{
|
|
1475
1344
|
id,
|
|
1476
1345
|
name: htmlName || id,
|
|
@@ -1482,8 +1351,8 @@
|
|
|
1482
1351
|
error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
|
|
1483
1352
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1484
1353
|
...themeProps,
|
|
1485
|
-
children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1486
|
-
core.Radio,
|
|
1354
|
+
children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1355
|
+
core$1.Radio,
|
|
1487
1356
|
{
|
|
1488
1357
|
id: utils.optionId(id, i),
|
|
1489
1358
|
value: String(i),
|
|
@@ -1537,10 +1406,10 @@
|
|
|
1537
1406
|
}
|
|
1538
1407
|
}, [onFocus, id, value]);
|
|
1539
1408
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1540
|
-
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
1541
|
-
options?.description && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Description, { children: options.description }),
|
|
1409
|
+
!hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
|
|
1410
|
+
options?.description && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Description, { children: options.description }),
|
|
1542
1411
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1543
|
-
core.Slider,
|
|
1412
|
+
core$1.Slider,
|
|
1544
1413
|
{
|
|
1545
1414
|
id,
|
|
1546
1415
|
name,
|
|
@@ -1557,7 +1426,7 @@
|
|
|
1557
1426
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1558
1427
|
}
|
|
1559
1428
|
),
|
|
1560
|
-
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `range-widget-input-errors-${index}`))
|
|
1429
|
+
rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Error, { children: error }, `range-widget-input-errors-${index}`))
|
|
1561
1430
|
] });
|
|
1562
1431
|
}
|
|
1563
1432
|
function SelectWidget(props) {
|
|
@@ -1617,7 +1486,7 @@
|
|
|
1617
1486
|
}
|
|
1618
1487
|
return [];
|
|
1619
1488
|
}, [enumDisabled, enumOptions]);
|
|
1620
|
-
const Component = multiple ? core.MultiSelect : core.Select;
|
|
1489
|
+
const Component = multiple ? core$1.MultiSelect : core$1.Select;
|
|
1621
1490
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1622
1491
|
Component,
|
|
1623
1492
|
{
|
|
@@ -1685,7 +1554,7 @@
|
|
|
1685
1554
|
[onFocus, id]
|
|
1686
1555
|
);
|
|
1687
1556
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1688
|
-
core.Textarea,
|
|
1557
|
+
core$1.Textarea,
|
|
1689
1558
|
{
|
|
1690
1559
|
id,
|
|
1691
1560
|
name: htmlName || name,
|
|
@@ -1738,7 +1607,7 @@
|
|
|
1738
1607
|
|
|
1739
1608
|
// src/Form/index.ts
|
|
1740
1609
|
function generateForm() {
|
|
1741
|
-
return core
|
|
1610
|
+
return core.withTheme(generateTheme());
|
|
1742
1611
|
}
|
|
1743
1612
|
var Form_default = generateForm();
|
|
1744
1613
|
|
|
@@ -7,7 +7,10 @@ import { Text } from '@mantine/core';
|
|
|
7
7
|
*/
|
|
8
8
|
export default function FieldHelpTemplate(props) {
|
|
9
9
|
const { fieldPathId, help } = props;
|
|
10
|
+
if (!help) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
10
13
|
const id = helpId(fieldPathId);
|
|
11
|
-
return
|
|
14
|
+
return (_jsx(Text, { id: id, size: 'sm', my: 'xs', c: 'dimmed', children: help }));
|
|
12
15
|
}
|
|
13
16
|
//# sourceMappingURL=FieldHelpTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldHelpTemplate.js","sourceRoot":"","sources":["../../src/templates/FieldHelpTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAiE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,KAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEpC,
|
|
1
|
+
{"version":3,"file":"FieldHelpTemplate.js","sourceRoot":"","sources":["../../src/templates/FieldHelpTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAiE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,KAA8B;IAC9B,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEpC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAE/B,OAAO,CACL,KAAC,IAAI,IAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,CAAC,EAAC,QAAQ,YACvC,IAAI,GACA,CACR,CAAC;AACJ,CAAC"}
|