ynotsoft-dynamic-form 1.0.47 → 1.0.48
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/dynamic-form.js +33 -27
- package/dist/dynamic-form.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/dynamic-form.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as d, jsxs as I, Fragment as Ve } from "react/jsx-runtime";
|
|
2
2
|
import * as u from "react";
|
|
3
|
-
import Ke, { useLayoutEffect as Ra, useState as
|
|
3
|
+
import Ke, { useLayoutEffect as Ra, useState as be, forwardRef as ni, createElement as ao, useRef as oi, useEffect as lo, useMemo as Ta } from "react";
|
|
4
4
|
import { toast as fn } from "react-hot-toast";
|
|
5
5
|
import dr from "dayjs";
|
|
6
6
|
import Na from "react-select";
|
|
@@ -2390,7 +2390,7 @@ function Kn(e, t) {
|
|
|
2390
2390
|
return typeof e == "function" ? e(t) : e && (e.current = t), e;
|
|
2391
2391
|
}
|
|
2392
2392
|
function Gc(e, t) {
|
|
2393
|
-
var n =
|
|
2393
|
+
var n = be(function() {
|
|
2394
2394
|
return {
|
|
2395
2395
|
// value
|
|
2396
2396
|
value: e,
|
|
@@ -3857,14 +3857,14 @@ const {
|
|
|
3857
3857
|
getOwnPropertyDescriptor: Id
|
|
3858
3858
|
} = Object;
|
|
3859
3859
|
let {
|
|
3860
|
-
freeze:
|
|
3860
|
+
freeze: ve,
|
|
3861
3861
|
seal: Re,
|
|
3862
3862
|
create: wo
|
|
3863
3863
|
} = Object, {
|
|
3864
3864
|
apply: xo,
|
|
3865
3865
|
construct: So
|
|
3866
3866
|
} = typeof Reflect < "u" && Reflect;
|
|
3867
|
-
|
|
3867
|
+
ve || (ve = function(t) {
|
|
3868
3868
|
return t;
|
|
3869
3869
|
});
|
|
3870
3870
|
Re || (Re = function(t) {
|
|
@@ -3880,8 +3880,8 @@ So || (So = function(t) {
|
|
|
3880
3880
|
o[r - 1] = arguments[r];
|
|
3881
3881
|
return new t(...o);
|
|
3882
3882
|
});
|
|
3883
|
-
const nn =
|
|
3884
|
-
function
|
|
3883
|
+
const nn = ye(Array.prototype.forEach), Md = ye(Array.prototype.lastIndexOf), Ur = ye(Array.prototype.pop), _t = ye(Array.prototype.push), Dd = ye(Array.prototype.splice), dn = ye(String.prototype.toLowerCase), Zn = ye(String.prototype.toString), Qn = ye(String.prototype.match), Ot = ye(String.prototype.replace), Ld = ye(String.prototype.indexOf), Fd = ye(String.prototype.trim), Pe = ye(Object.prototype.hasOwnProperty), ge = ye(RegExp.prototype.test), It = $d(TypeError);
|
|
3884
|
+
function ye(e) {
|
|
3885
3885
|
return function(t) {
|
|
3886
3886
|
t instanceof RegExp && (t.lastIndex = 0);
|
|
3887
3887
|
for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), r = 1; r < n; r++)
|
|
@@ -3926,9 +3926,9 @@ function Mt(e, t) {
|
|
|
3926
3926
|
const o = Id(e, t);
|
|
3927
3927
|
if (o) {
|
|
3928
3928
|
if (o.get)
|
|
3929
|
-
return
|
|
3929
|
+
return ye(o.get);
|
|
3930
3930
|
if (typeof o.value == "function")
|
|
3931
|
-
return
|
|
3931
|
+
return ye(o.value);
|
|
3932
3932
|
}
|
|
3933
3933
|
e = Od(e);
|
|
3934
3934
|
}
|
|
@@ -3937,7 +3937,7 @@ function Mt(e, t) {
|
|
|
3937
3937
|
}
|
|
3938
3938
|
return n;
|
|
3939
3939
|
}
|
|
3940
|
-
const Wr =
|
|
3940
|
+
const Wr = ve(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Jn = ve(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), eo = ve(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Bd = ve(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), to = ve(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Ud = ve(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Hr = ve(["#text"]), Vr = ve(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), no = ve(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Gr = ve(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), on = ve(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Wd = Re(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Hd = Re(/<%[\w\W]*|[\w\W]*%>/gm), Vd = Re(/\$\{[\w\W]*/gm), Gd = Re(/^data-[\-\w.\u00B7-\uFFFF]+$/), jd = Re(/^aria-[\-\w]+$/), Es = Re(
|
|
3941
3941
|
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
3942
3942
|
// eslint-disable-line no-useless-escape
|
|
3943
3943
|
), Yd = Re(/^(?:\w+script|data):/i), Kd = Re(
|
|
@@ -4111,7 +4111,7 @@ function Rs() {
|
|
|
4111
4111
|
x = b.TRUSTED_TYPES_POLICY, E = x.createHTML("");
|
|
4112
4112
|
} else
|
|
4113
4113
|
x === void 0 && (x = Zd(h, r)), x !== null && typeof E == "string" && (E = x.createHTML(""));
|
|
4114
|
-
|
|
4114
|
+
ve && ve(b), mt = b;
|
|
4115
4115
|
}
|
|
4116
4116
|
}, er = J({}, [...Jn, ...eo, ...Bd]), tr = J({}, [...to, ...Ud]), Ea = function(b) {
|
|
4117
4117
|
let P = C(b);
|
|
@@ -4212,8 +4212,8 @@ function Rs() {
|
|
|
4212
4212
|
const ae = C(b) || b.parentNode, me = S(b) || b.childNodes;
|
|
4213
4213
|
if (me && ae) {
|
|
4214
4214
|
const ce = me.length;
|
|
4215
|
-
for (let
|
|
4216
|
-
const Ue = m(me[
|
|
4215
|
+
for (let we = ce - 1; we >= 0; --we) {
|
|
4216
|
+
const Ue = m(me[we], !0);
|
|
4217
4217
|
Ue.__removalCount = (b.__removalCount || 0) + 1, ae.insertBefore(Ue, w(b));
|
|
4218
4218
|
}
|
|
4219
4219
|
}
|
|
@@ -4274,7 +4274,7 @@ function Rs() {
|
|
|
4274
4274
|
for (; ae--; ) {
|
|
4275
4275
|
const me = P[ae], {
|
|
4276
4276
|
name: ce,
|
|
4277
|
-
namespaceURI:
|
|
4277
|
+
namespaceURI: we,
|
|
4278
4278
|
value: Ue
|
|
4279
4279
|
} = me, ht = fe(ce), Un = Ue;
|
|
4280
4280
|
let pe = ce === "value" ? Un : Fd(Un);
|
|
@@ -4304,7 +4304,7 @@ function Rs() {
|
|
|
4304
4304
|
rt(ce, b);
|
|
4305
4305
|
continue;
|
|
4306
4306
|
}
|
|
4307
|
-
if (x && typeof h == "object" && typeof h.getAttributeType == "function" && !
|
|
4307
|
+
if (x && typeof h == "object" && typeof h.getAttributeType == "function" && !we)
|
|
4308
4308
|
switch (h.getAttributeType(cr, ht)) {
|
|
4309
4309
|
case "TrustedHTML": {
|
|
4310
4310
|
pe = x.createHTML(pe);
|
|
@@ -4317,7 +4317,7 @@ function Rs() {
|
|
|
4317
4317
|
}
|
|
4318
4318
|
if (pe !== Un)
|
|
4319
4319
|
try {
|
|
4320
|
-
|
|
4320
|
+
we ? b.setAttributeNS(we, ce, pe) : b.setAttribute(ce, pe), Bn(b) ? Oe(b) : Ur(t.removed);
|
|
4321
4321
|
} catch {
|
|
4322
4322
|
rt(ce, b);
|
|
4323
4323
|
}
|
|
@@ -4369,11 +4369,11 @@ function Rs() {
|
|
|
4369
4369
|
me = P;
|
|
4370
4370
|
return (O.shadowroot || O.shadowrootmode) && (me = X.call(o, me, !0)), me;
|
|
4371
4371
|
}
|
|
4372
|
-
let
|
|
4373
|
-
return Te && k["!doctype"] && P.ownerDocument && P.ownerDocument.doctype && P.ownerDocument.doctype.name && ge(As, P.ownerDocument.doctype.name) && (
|
|
4374
|
-
` +
|
|
4375
|
-
|
|
4376
|
-
}), x && jt ? x.createHTML(
|
|
4372
|
+
let we = Te ? P.outerHTML : P.innerHTML;
|
|
4373
|
+
return Te && k["!doctype"] && P.ownerDocument && P.ownerDocument.doctype && P.ownerDocument.doctype.name && ge(As, P.ownerDocument.doctype.name) && (we = "<!DOCTYPE " + P.ownerDocument.doctype.name + `>
|
|
4374
|
+
` + we), ue && nn([q, T, F], (Ue) => {
|
|
4375
|
+
we = Ot(we, Ue, " ");
|
|
4376
|
+
}), x && jt ? x.createHTML(we) : we;
|
|
4377
4377
|
}, t.setConfig = function() {
|
|
4378
4378
|
let H = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
4379
4379
|
zn(H), nt = !0;
|
|
@@ -7598,7 +7598,7 @@ function up({
|
|
|
7598
7598
|
handleBlur: o,
|
|
7599
7599
|
error: r
|
|
7600
7600
|
}) {
|
|
7601
|
-
const [i, s] =
|
|
7601
|
+
const [i, s] = be(!1), a = t[e.name] ?? { from: null, to: null }, l = (f) => n(e.name, f), c = () => n(e.name, { from: null, to: null });
|
|
7602
7602
|
return /* @__PURE__ */ d("div", { children: /* @__PURE__ */ I(Ho, { open: i, onOpenChange: s, children: [
|
|
7603
7603
|
/* @__PURE__ */ d(Vo, { asChild: !0, children: /* @__PURE__ */ I(
|
|
7604
7604
|
"button",
|
|
@@ -7699,7 +7699,7 @@ function Jr({
|
|
|
7699
7699
|
api_URL: a,
|
|
7700
7700
|
disabled: l
|
|
7701
7701
|
}) {
|
|
7702
|
-
const c = l, f = e.type === "multifile", p = o?.[e.name] || {}, g = t[e.name], h = f ? g || [] : [g].filter(Boolean), [y, m] =
|
|
7702
|
+
const c = l, f = e.type === "multifile", p = o?.[e.name] || {}, g = t[e.name], h = f ? g || [] : [g].filter(Boolean), [y, m] = be(!1), v = a ? `${a}uploads` : null;
|
|
7703
7703
|
!v && e.uploadEndpoint && console.error(
|
|
7704
7704
|
`api_URL prop is required when using FileField with upload functionality for field "${e.name}"`
|
|
7705
7705
|
);
|
|
@@ -7927,8 +7927,14 @@ function dp({
|
|
|
7927
7927
|
r && /* @__PURE__ */ d("p", { className: "mt-1 text-sm text-red-500", children: r })
|
|
7928
7928
|
] });
|
|
7929
7929
|
}
|
|
7930
|
-
function fp({
|
|
7931
|
-
|
|
7930
|
+
function fp({
|
|
7931
|
+
field: e,
|
|
7932
|
+
formValues: t,
|
|
7933
|
+
handleChange: n,
|
|
7934
|
+
handleBlur: o,
|
|
7935
|
+
error: r
|
|
7936
|
+
}) {
|
|
7937
|
+
const [i, s] = be(!1), a = t[e.name] ?? null, l = (f) => n(e.name, f), c = () => n(e.name, null);
|
|
7932
7938
|
return /* @__PURE__ */ I("div", { children: [
|
|
7933
7939
|
/* @__PURE__ */ I(Popover, { open: i, onOpenChange: s, children: [
|
|
7934
7940
|
/* @__PURE__ */ d(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ I(
|
|
@@ -8738,7 +8744,7 @@ function om({
|
|
|
8738
8744
|
handleBlur: o,
|
|
8739
8745
|
error: r
|
|
8740
8746
|
}) {
|
|
8741
|
-
const [i, s] =
|
|
8747
|
+
const [i, s] = be(!1), a = t[e.name] ?? null, l = (f) => n(e.name, f), c = () => n(e.name, null);
|
|
8742
8748
|
return /* @__PURE__ */ d("div", { children: /* @__PURE__ */ I(Ho, { open: i, onOpenChange: s, children: [
|
|
8743
8749
|
/* @__PURE__ */ d(Vo, { asChild: !0, children: /* @__PURE__ */ I(
|
|
8744
8750
|
"button",
|
|
@@ -8822,7 +8828,7 @@ function om({
|
|
|
8822
8828
|
] }) });
|
|
8823
8829
|
}
|
|
8824
8830
|
function rm({ field: e, formValues: t, handleChange: n, handleBlur: o, error: r }) {
|
|
8825
|
-
const [i, s] =
|
|
8831
|
+
const [i, s] = be(!1), [a, l] = be("12"), [c, f] = be("00"), [p, g] = be("PM"), h = t[e.name] || "";
|
|
8826
8832
|
Ke.useEffect(() => {
|
|
8827
8833
|
if (h) {
|
|
8828
8834
|
const x = h.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);
|
|
@@ -9133,7 +9139,7 @@ const ym = ({
|
|
|
9133
9139
|
},
|
|
9134
9140
|
debugMode: l = !1
|
|
9135
9141
|
}) => {
|
|
9136
|
-
const [c, f] =
|
|
9142
|
+
const [c, f] = be({ ...s }), [p, g] = be({}), [h, y] = be({}), [m, v] = be({}), [w, S] = be({}), [C, x] = be({
|
|
9137
9143
|
isOpen: !1,
|
|
9138
9144
|
fieldName: null
|
|
9139
9145
|
}), E = oi({}), B = [
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
// Ensure focus styling is handled correctly for the button element
|
|
75
75
|
focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50
|
|
76
76
|
${d?"bg-gray-50 border-gray-300 text-gray-400 cursor-not-allowed opacity-70":y?"bg-blue-50 border-blue-500 text-blue-600":"bg-white border-gray-300 hover:border-blue-400 hover:bg-gray-50 cursor-pointer"}
|
|
77
|
-
`;return l.jsx("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("button",{type:"button",className:q,onClick:()=>{d||r?.current?.[e.name]?.click()},onDragOver:O,onDragEnter:O,onDragLeave:A,onDrop:G,disabled:d,children:[l.jsx("div",{className:"border-gray-400 border p-1 mb-3 rounded-md bg-gray-100 shadow-md ",children:l.jsx(eu,{size:24,className:"m-1"})}),l.jsxs("p",{className:"text-sm font-normal",children:[l.jsxs("span",{className:d?"text-gray-400":"text-blue-600 hover:text-blue-700 underline",children:["Upload ",f?"Files":"a file"]}),l.jsx("span",{className:"font-light",children:" or drag and drop"})]}),l.jsxs("p",{className:"text-xs mt-1 text-gray-500",children:[K,V,f&&e.maxFiles&&`, Max ${e.maxFiles} files`]})]}),l.jsx("input",{ref:T=>{T&&r&&r.current&&(r.current[e.name]=T)},id:e.name,type:"file",accept:e.accept,multiple:f,className:"sr-only",onChange:T=>E(e.name,T.target.files),disabled:d}),h.length>0&&l.jsx("div",{className:"space-y-2 pt-2 border-t border-gray-200",children:h.map((T,F)=>{const U=T.original_name||T.name||"File",L=T.size||null;return l.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[l.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[l.jsx("span",{className:"text-sm truncate",children:U}),L&&l.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["(",w(L),")"]})]}),l.jsx("button",{type:"button",onClick:()=>z(e.name,T),className:`text-red-500 hover:text-red-700 ml-3 flex-shrink-0 ${d?"cursor-not-allowed opacity-50":""}`,disabled:d,children:"Remove"})]},T.url||T.original_name||F)})}),Object.entries(p).map(([T,F])=>F.status==="uploading"?l.jsxs("div",{className:"relative pt-1",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",T]}),l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[F.progress,"%"]})]}),l.jsx("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:l.jsx("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${F.progress}%`}})})]},T):null)]})},e.name)}function Bf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r,charCount:s,setCharCounts:a}){const i=J.useRef(null),c=t[e.name]||"",d=typeof e.disabled=="function"?e.disabled(t):e.disabled||e.readOnly,f=()=>{const g=i.current;g&&(g.style.height="auto",g.style.height=`${g.scrollHeight+2}px`)};J.useEffect(()=>{f()},[c]);const p=g=>{n(e.name,g.target.value),f(),a&&a(h=>({...h,[e.name]:g.target.value.length}))};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{...e.props,ref:i,id:e.name,name:e.name,placeholder:e.placeholder||"",value:c,onChange:p,onBlur:()=>o(e.name),disabled:d,maxLength:e.maxLength,rows:e.rows||3,className:`flex w-full rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none overflow-y-auto ${r?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${d?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),l.jsx("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&l.jsxs("span",{className:"text-xs text-gray-500",children:[s||0,"/",e.maxLength," characters"]})}),r&&l.jsx("p",{className:"mt-1 text-sm text-red-500",children:r})]})}function Uf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r}){const[s,a]=useState(!1),i=t[e.name]??null,c=f=>n(e.name,f),d=()=>n(e.name,null);return l.jsxs("div",{children:[l.jsxs(Popover,{open:s,onOpenChange:a,children:[l.jsx(PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":s,onClick:()=>a(!0),onKeyDown:f=>f.key==="Enter"&&a(!0),className:`
|
|
77
|
+
`;return l.jsx("div",{className:`mb-4 ${e.fieldClass||"col-span-full"}`,children:l.jsxs("div",{className:"space-y-3",children:[l.jsxs("button",{type:"button",className:q,onClick:()=>{d||r?.current?.[e.name]?.click()},onDragOver:O,onDragEnter:O,onDragLeave:A,onDrop:G,disabled:d,children:[l.jsx("div",{className:"border-gray-400 border p-1 mb-3 rounded-md bg-gray-100 shadow-md ",children:l.jsx(eu,{size:24,className:"m-1"})}),l.jsxs("p",{className:"text-sm font-normal",children:[l.jsxs("span",{className:d?"text-gray-400":"text-blue-600 hover:text-blue-700 underline",children:["Upload ",f?"Files":"a file"]}),l.jsx("span",{className:"font-light",children:" or drag and drop"})]}),l.jsxs("p",{className:"text-xs mt-1 text-gray-500",children:[K,V,f&&e.maxFiles&&`, Max ${e.maxFiles} files`]})]}),l.jsx("input",{ref:T=>{T&&r&&r.current&&(r.current[e.name]=T)},id:e.name,type:"file",accept:e.accept,multiple:f,className:"sr-only",onChange:T=>E(e.name,T.target.files),disabled:d}),h.length>0&&l.jsx("div",{className:"space-y-2 pt-2 border-t border-gray-200",children:h.map((T,F)=>{const U=T.original_name||T.name||"File",L=T.size||null;return l.jsxs("div",{className:"flex items-center justify-between p-2 bg-gray-50 rounded",children:[l.jsxs("div",{className:"flex items-center space-x-2 min-w-0",children:[l.jsx("span",{className:"text-sm truncate",children:U}),L&&l.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:["(",w(L),")"]})]}),l.jsx("button",{type:"button",onClick:()=>z(e.name,T),className:`text-red-500 hover:text-red-700 ml-3 flex-shrink-0 ${d?"cursor-not-allowed opacity-50":""}`,disabled:d,children:"Remove"})]},T.url||T.original_name||F)})}),Object.entries(p).map(([T,F])=>F.status==="uploading"?l.jsxs("div",{className:"relative pt-1",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:["Uploading ",T]}),l.jsxs("span",{className:"text-xs font-semibold inline-block text-blue-600",children:[F.progress,"%"]})]}),l.jsx("div",{className:"overflow-hidden h-2 mt-1 text-xs flex rounded bg-blue-200",children:l.jsx("div",{className:"shadow-none flex flex-col text-center whitespace-nowrap text-white justify-center bg-blue-500",style:{width:`${F.progress}%`}})})]},T):null)]})},e.name)}function Bf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r,charCount:s,setCharCounts:a}){const i=J.useRef(null),c=t[e.name]||"",d=typeof e.disabled=="function"?e.disabled(t):e.disabled||e.readOnly,f=()=>{const g=i.current;g&&(g.style.height="auto",g.style.height=`${g.scrollHeight+2}px`)};J.useEffect(()=>{f()},[c]);const p=g=>{n(e.name,g.target.value),f(),a&&a(h=>({...h,[e.name]:g.target.value.length}))};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("textarea",{...e.props,ref:i,id:e.name,name:e.name,placeholder:e.placeholder||"",value:c,onChange:p,onBlur:()=>o(e.name),disabled:d,maxLength:e.maxLength,rows:e.rows||3,className:`flex w-full rounded-md border px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none overflow-y-auto ${r?"border-red-500 focus-visible:ring-red-500":"border-input focus-visible:ring-blue-500"} ${d?"bg-gray-50 text-gray-500":"bg-background"}`,style:{minHeight:"80px",maxHeight:"400px"}}),l.jsx("div",{className:"flex justify-between items-center",children:e.maxLength&&!e.readOnly&&l.jsxs("span",{className:"text-xs text-gray-500",children:[s||0,"/",e.maxLength," characters"]})}),r&&l.jsx("p",{className:"mt-1 text-sm text-red-500",children:r})]})}function Uf({field:e,formValues:t,handleChange:n,handleBlur:o,error:r}){const[s,a]=J.useState(!1),i=t[e.name]??null,c=f=>n(e.name,f),d=()=>n(e.name,null);return l.jsxs("div",{children:[l.jsxs(Popover,{open:s,onOpenChange:a,children:[l.jsx(PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",id:e.name,"aria-haspopup":"dialog","aria-expanded":s,onClick:()=>a(!0),onKeyDown:f=>f.key==="Enter"&&a(!0),className:`
|
|
78
78
|
inline-flex items-center justify-between gap-2
|
|
79
79
|
w-full h-9 rounded-md border bg-white
|
|
80
80
|
px-3 py-2 text-sm font-normal shadow-sm
|