@gen-epix/ui-core-form 4.0.2 → 4.2.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/dist/_chunks/Autocomplete.js +86 -84
- package/dist/_chunks/Autocomplete.js.map +1 -1
- package/dist/_chunks/DatePicker.js +26 -26
- package/dist/_chunks/FileUpload.js +73 -0
- package/dist/_chunks/FileUpload.js.map +1 -0
- package/dist/_chunks/FormUtil.js +4 -1
- package/dist/_chunks/FormUtil.js.map +1 -1
- package/dist/_chunks/RichTextEditor.js +7658 -4335
- package/dist/_chunks/RichTextEditor.js.map +1 -1
- package/dist/_chunks/TransferList.js +59 -59
- package/dist/_chunks/TransferList.js.map +1 -1
- package/dist/components/fields/Autocomplete/Autocomplete.d.ts +6 -3
- package/dist/components/fields/CheckboxGroup/index.js +14 -14
- package/dist/components/fields/DateRangePicker/index.js +39 -39
- package/dist/components/fields/DateRangePicker/index.js.map +1 -1
- package/dist/components/fields/{UploadButton/UploadButton.d.ts → FileUpload/FileUpload.d.ts} +2 -2
- package/dist/components/fields/FileUpload/index.d.ts +1 -0
- package/dist/components/fields/FileUpload/index.js +2 -0
- package/dist/components/fields/NumberField/index.js +29 -29
- package/dist/components/fields/NumberField/index.js.map +1 -1
- package/dist/components/fields/NumberRangeInput/index.js +34 -34
- package/dist/components/fields/RadioGroup/index.js +7 -7
- package/dist/components/fields/Select/index.js +32 -19
- package/dist/components/fields/Select/index.js.map +1 -1
- package/dist/components/fields/Switch/Switch.d.ts +3 -2
- package/dist/components/fields/Switch/index.js +50 -40
- package/dist/components/fields/Switch/index.js.map +1 -1
- package/dist/components/fields/TextField/index.js +19 -19
- package/dist/components/fields/ToggleButtonGroup/index.js +7 -7
- package/dist/components/helpers/GenericForm/GenericForm.d.ts +1 -1
- package/dist/components/helpers/GenericForm/index.js +42 -32
- package/dist/components/helpers/GenericForm/index.js.map +1 -1
- package/dist/hooks/useIsFormFieldRequiredFromSchema/index.js +5 -4
- package/dist/hooks/useIsFormFieldRequiredFromSchema/index.js.map +1 -1
- package/dist/models/form.d.ts +31 -19
- package/dist/models/form.js.map +1 -1
- package/package.json +84 -81
- package/dist/_chunks/UploadButton.js +0 -91
- package/dist/_chunks/UploadButton.js.map +0 -1
- package/dist/_chunks/index.esm.js +0 -398
- package/dist/_chunks/index.esm.js.map +0 -1
- package/dist/components/fields/UploadButton/index.d.ts +0 -1
- package/dist/components/fields/UploadButton/index.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as e } from "../../../_chunks/rolldown-runtime.js";
|
|
2
2
|
import { a as t, n, o as r, r as i, s as a, t as o } from "../../../_chunks/isValid.js";
|
|
3
3
|
import { _ as s, a as c, c as l, g as u, h as d, i as f, l as p, n as m, o as h, r as g, s as _, t as v, u as y, v as b } from "../../../_chunks/FormUtil.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { FormFieldHelperText as x } from "../../helpers/FormFieldHelperText/index.js";
|
|
5
|
+
import { FormFieldLoadingIndicator as S } from "../../helpers/FormFieldLoadingIndicator/index.js";
|
|
6
|
+
import { t as C } from "../../../_chunks/classnames.js";
|
|
7
|
+
import { t as ee } from "../../../_chunks/sv.js";
|
|
8
|
+
import { t as w } from "../../../_chunks/isEqual.js";
|
|
9
|
+
import { DATE_FORMAT as T } from "@gen-epix/ui-core/constants/date";
|
|
10
|
+
import { useCallback as E, useId as D, useMemo as O, useRef as te } from "react";
|
|
11
|
+
import { Controller as ne, useFormContext as re, useWatch as ie } from "react-hook-form";
|
|
12
12
|
import { useTranslation as ae } from "react-i18next";
|
|
13
13
|
import { Box as oe, FormControl as se, FormHelperText as ce, FormLabel as le, IconButton as ue, useTheme as de } from "@mui/material";
|
|
14
14
|
import fe from "@mui/icons-material/Clear";
|
|
@@ -1416,19 +1416,19 @@ function pt(e, t, n) {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
//#endregion
|
|
1418
1418
|
//#region src/components/fields/DateRangePicker/DateRangePicker.tsx
|
|
1419
|
-
var $ = /* @__PURE__ */ e(
|
|
1420
|
-
let { control: f, formState: { errors: p } } =
|
|
1419
|
+
var $ = /* @__PURE__ */ e(C(), 1), mt = /* @__PURE__ */ e(w(), 1), ht = ({ dateFormat: e = T.DATE, disabled: t = !1, infoMessage: n, label: r, loading: i = !1, maxDate: a, minDate: s, name: c, onChange: l, required: u = !1, warningMessage: d }) => {
|
|
1420
|
+
let { control: f, formState: { errors: p } } = re(), h = v.getFieldErrorMessage(p, c), g = !!h, _ = !!d && !g, b = te(null), C = te(null), w = de(), M = D(), { t: N } = ae(), P = O(() => pt(/* @__PURE__ */ new Date(), 3), []), F = O(() => {
|
|
1421
1421
|
switch (e) {
|
|
1422
|
-
case
|
|
1423
|
-
case
|
|
1424
|
-
case
|
|
1425
|
-
case
|
|
1422
|
+
case T.DATE:
|
|
1423
|
+
case T.DATE_TIME: return;
|
|
1424
|
+
case T.YEAR: return ["year"];
|
|
1425
|
+
case T.YEAR_MONTH: return ["year", "month"];
|
|
1426
1426
|
default: throw Error(`Unsupported date format: ${e}`);
|
|
1427
1427
|
}
|
|
1428
|
-
}, [e]), I =
|
|
1428
|
+
}, [e]), I = E((t) => {
|
|
1429
1429
|
let n = [null, null];
|
|
1430
1430
|
switch (e) {
|
|
1431
|
-
case
|
|
1431
|
+
case T.DATE:
|
|
1432
1432
|
n[0] = t[0] ? Q(t[0], {
|
|
1433
1433
|
hours: 0,
|
|
1434
1434
|
milliseconds: 0,
|
|
@@ -1441,7 +1441,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1441
1441
|
seconds: 59
|
|
1442
1442
|
}) : null;
|
|
1443
1443
|
break;
|
|
1444
|
-
case
|
|
1444
|
+
case T.DATE_TIME:
|
|
1445
1445
|
n[0] = t[0] ? Q(t[0], {
|
|
1446
1446
|
milliseconds: 0,
|
|
1447
1447
|
seconds: 0
|
|
@@ -1450,7 +1450,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1450
1450
|
seconds: 59
|
|
1451
1451
|
}) : null;
|
|
1452
1452
|
break;
|
|
1453
|
-
case
|
|
1453
|
+
case T.YEAR:
|
|
1454
1454
|
n[0] = t[0] ? Q(t[0], {
|
|
1455
1455
|
date: 1,
|
|
1456
1456
|
hours: 0,
|
|
@@ -1467,7 +1467,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1467
1467
|
seconds: 59
|
|
1468
1468
|
}) : null;
|
|
1469
1469
|
break;
|
|
1470
|
-
case
|
|
1470
|
+
case T.YEAR_MONTH:
|
|
1471
1471
|
n[0] = t[0] ? Q(t[0], {
|
|
1472
1472
|
date: 1,
|
|
1473
1473
|
hours: 0,
|
|
@@ -1484,34 +1484,34 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1484
1484
|
default: throw Error(`Unsupported date format: ${e}`);
|
|
1485
1485
|
}
|
|
1486
1486
|
return n;
|
|
1487
|
-
}, [e]), L =
|
|
1487
|
+
}, [e]), L = E((t) => t ? e === T.YEAR_MONTH ? ut(t, "MMMM yyyy", /* @__PURE__ */ new Date()) : m(t) : null, [e]), R = O(() => ({
|
|
1488
1488
|
...y,
|
|
1489
|
-
formatLong:
|
|
1490
|
-
}), []), z =
|
|
1489
|
+
formatLong: ee.formatLong
|
|
1490
|
+
}), []), z = ie({
|
|
1491
1491
|
control: f,
|
|
1492
1492
|
name: c
|
|
1493
|
-
}), B =
|
|
1493
|
+
}), B = E((e, t) => {
|
|
1494
1494
|
let n = I(t);
|
|
1495
1495
|
(0, mt.default)(n, z) || (e(n), l && l(n));
|
|
1496
1496
|
}, [
|
|
1497
1497
|
l,
|
|
1498
1498
|
z,
|
|
1499
1499
|
I
|
|
1500
|
-
]), V =
|
|
1500
|
+
]), V = E(({ field: { onBlur: e, onChange: l, ref: f, value: p } }) => {
|
|
1501
1501
|
f({ focus: () => {
|
|
1502
1502
|
b?.current?.focus();
|
|
1503
1503
|
} });
|
|
1504
1504
|
let m = p[0], v = p[1], y = (e) => {
|
|
1505
1505
|
B(l, [e, v]);
|
|
1506
|
-
},
|
|
1506
|
+
}, ee = (e) => {
|
|
1507
1507
|
B(l, [m, e]);
|
|
1508
|
-
},
|
|
1508
|
+
}, T = () => {
|
|
1509
1509
|
let t = L(b.current.value);
|
|
1510
1510
|
o(t) ? t < s ? B(l, [s, v]) : t > a ? B(l, [a, a]) : v && t > v ? B(l, [v, t]) : B(l, [t, v]) : B(l, [null, v]), e();
|
|
1511
|
-
},
|
|
1512
|
-
let t = L(
|
|
1511
|
+
}, E = () => {
|
|
1512
|
+
let t = L(C.current.value);
|
|
1513
1513
|
o(t) ? t > a ? B(l, [m, a]) : t < s ? B(l, [s, s]) : m && t < m ? B(l, [t, m]) : B(l, [m, t]) : B(l, [m, null]), e();
|
|
1514
|
-
},
|
|
1514
|
+
}, D = () => {
|
|
1515
1515
|
l([null, null]);
|
|
1516
1516
|
};
|
|
1517
1517
|
return /* @__PURE__ */ A(se, {
|
|
@@ -1535,7 +1535,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1535
1535
|
children: [r, !t && /* @__PURE__ */ k(ue, {
|
|
1536
1536
|
...j.createAttributes("DateRangePicker-reset"),
|
|
1537
1537
|
"aria-label": N`Clear date range`,
|
|
1538
|
-
onClick:
|
|
1538
|
+
onClick: D,
|
|
1539
1539
|
sx: {
|
|
1540
1540
|
"& svg": { fontSize: "16px" },
|
|
1541
1541
|
position: "absolute",
|
|
@@ -1551,7 +1551,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1551
1551
|
children: /* @__PURE__ */ A(oe, {
|
|
1552
1552
|
sx: {
|
|
1553
1553
|
display: "grid",
|
|
1554
|
-
gap:
|
|
1554
|
+
gap: w.spacing(1),
|
|
1555
1555
|
gridTemplateColumns: "1fr 1fr"
|
|
1556
1556
|
},
|
|
1557
1557
|
children: [/* @__PURE__ */ k(pe, {
|
|
@@ -1567,7 +1567,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1567
1567
|
slotProps: { textField: {
|
|
1568
1568
|
className: (0, $.default)({ "Mui-warning": _ }),
|
|
1569
1569
|
error: g,
|
|
1570
|
-
onBlur:
|
|
1570
|
+
onBlur: T,
|
|
1571
1571
|
slotProps: { inputLabel: {
|
|
1572
1572
|
...j.createAttributes("DateRangePicker-from-input"),
|
|
1573
1573
|
required: u
|
|
@@ -1579,17 +1579,17 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1579
1579
|
}), /* @__PURE__ */ k(pe, {
|
|
1580
1580
|
disabled: t || i,
|
|
1581
1581
|
disableFuture: !0,
|
|
1582
|
-
inputRef:
|
|
1582
|
+
inputRef: C,
|
|
1583
1583
|
label: N`To`,
|
|
1584
1584
|
loading: i,
|
|
1585
1585
|
maxDate: a,
|
|
1586
1586
|
minDate: m ? new Date(Math.max.apply(null, [s, m])) : s,
|
|
1587
|
-
onChange:
|
|
1587
|
+
onChange: ee,
|
|
1588
1588
|
referenceDate: a,
|
|
1589
1589
|
slotProps: { textField: {
|
|
1590
1590
|
className: (0, $.default)({ "Mui-warning": _ }),
|
|
1591
1591
|
error: g,
|
|
1592
|
-
onBlur:
|
|
1592
|
+
onBlur: E,
|
|
1593
1593
|
slotProps: { inputLabel: {
|
|
1594
1594
|
...j.createAttributes("DateRangePicker-to-input"),
|
|
1595
1595
|
required: u
|
|
@@ -1601,10 +1601,10 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1601
1601
|
})]
|
|
1602
1602
|
})
|
|
1603
1603
|
}),
|
|
1604
|
-
!!i && /* @__PURE__ */ k(
|
|
1604
|
+
!!i && /* @__PURE__ */ k(S, {}),
|
|
1605
1605
|
/* @__PURE__ */ k(ce, {
|
|
1606
1606
|
sx: { ml: 0 },
|
|
1607
|
-
children: /* @__PURE__ */ k(
|
|
1607
|
+
children: /* @__PURE__ */ k(x, {
|
|
1608
1608
|
errorMessage: h,
|
|
1609
1609
|
infoMessage: n,
|
|
1610
1610
|
noIndent: !0,
|
|
@@ -1623,7 +1623,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1623
1623
|
M,
|
|
1624
1624
|
u,
|
|
1625
1625
|
R,
|
|
1626
|
-
|
|
1626
|
+
w,
|
|
1627
1627
|
N,
|
|
1628
1628
|
a,
|
|
1629
1629
|
s,
|
|
@@ -1635,7 +1635,7 @@ var $ = /* @__PURE__ */ e(w(), 1), mt = /* @__PURE__ */ e(T(), 1), ht = ({ dateF
|
|
|
1635
1635
|
B,
|
|
1636
1636
|
L
|
|
1637
1637
|
]);
|
|
1638
|
-
return /* @__PURE__ */ k(
|
|
1638
|
+
return /* @__PURE__ */ k(ne, {
|
|
1639
1639
|
control: f,
|
|
1640
1640
|
defaultValue: "",
|
|
1641
1641
|
name: c,
|