@cbutep_n/pico-ui 0.0.6 → 0.0.7

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.
@@ -1,1262 +0,0 @@
1
- import { defineComponent as M, openBlock as V, createElementBlock as O, normalizeClass as F, renderSlot as ee, createElementVNode as T, createBlock as Ie, resolveDynamicComponent as Pe, unref as f, useModel as te, withDirectives as de, vModelCheckbox as rt, createVNode as it, mergeModels as fe, computed as C, toValue as b, onMounted as ot, getCurrentInstance as H, provide as lt, isRef as ve, watch as L, onBeforeUnmount as at, inject as ut, onUnmounted as st, ref as ae, reactive as ct, nextTick as dt, toDisplayString as Ee, createCommentVNode as ft, mergeProps as vt, Fragment as pt, renderList as mt, vModelRadio as ht, vModelText as gt } from "vue";
2
- const Nn = /* @__PURE__ */ M({
3
- __name: "PButton",
4
- props: {
5
- variant: { default: "primary" },
6
- size: { default: "medium" }
7
- },
8
- setup(e) {
9
- const t = {
10
- primary: ["bg-pico-primary", "text-white", "shadow-primary"],
11
- secondary: ["bg-pico-secondary", "text-white", "shadow-secondary"],
12
- outline: ["outline-2", "outline-pico-primary", "text-pico-primary"],
13
- ghost: ["text-pico-gray", "border-dashed border-2 border-pico-gray/50"],
14
- soft: ["bg-pico-primary/20", "text-pico-primary"]
15
- }, n = {
16
- large: ["text-lg", "py-3.5", "px-8.5"],
17
- medium: ["text-md", "py-2.5", "px-6"],
18
- small: ["text-sm", "py-1.5", "px-4"]
19
- };
20
- return (r, i) => (V(), O("button", {
21
- class: F(["w-max h-max rounded-lg font-semibold hover:brightness-80 duration-300", [t[e.variant], n[e.size]]])
22
- }, [
23
- ee(r.$slots, "default")
24
- ], 2));
25
- }
26
- }), yt = {
27
- xmlns: "http://www.w3.org/2000/svg",
28
- width: "12",
29
- height: "9",
30
- fill: "none"
31
- };
32
- function bt(e, t) {
33
- return V(), O("svg", yt, [...t[0] || (t[0] = [
34
- T("path", {
35
- fill: "#fff",
36
- d: "M10.868.366a1.25 1.25 0 0 1 0 1.767l-6.25 6.25a1.25 1.25 0 0 1-1.767 0l-2.5-2.5a1.25 1.25 0 0 1 1.767-1.767l1.617 1.616L9.1.366a1.25 1.25 0 0 1 1.767 0"
37
- }, null, -1)
38
- ])]);
39
- }
40
- const _t = { render: bt }, Vt = {
41
- checkmark: _t
42
- }, wt = /* @__PURE__ */ M({
43
- __name: "PIcon",
44
- props: {
45
- name: {}
46
- },
47
- setup(e) {
48
- return (t, n) => (V(), Ie(Pe(f(Vt)[e.name])));
49
- }
50
- }), Ot = ["disabled"], Fn = /* @__PURE__ */ M({
51
- __name: "PCheckboxInput",
52
- props: /* @__PURE__ */ fe({
53
- disabled: { type: Boolean, default: !1 }
54
- }, {
55
- modelValue: { type: Boolean },
56
- modelModifiers: {}
57
- }),
58
- emits: ["update:modelValue"],
59
- setup(e) {
60
- const t = /* @__PURE__ */ new Map([
61
- [!1, ["outline-2"]],
62
- [!0, ["bg-pico-primary"]]
63
- ]), n = te(e, "modelValue");
64
- return (r, i) => (V(), O("div", {
65
- class: F([f(t).get(!!n.value), "outline-pico-stroke-neutral min-w-5.5 duration-300 h-5.5 flex relative justify-center items-center rounded-sm"])
66
- }, [
67
- de(T("input", {
68
- class: "opacity-0 inset-0 absolute",
69
- disabled: e.disabled,
70
- type: "checkbox",
71
- "onUpdate:modelValue": i[0] || (i[0] = (o) => n.value = o)
72
- }, null, 8, Ot), [
73
- [rt, n.value]
74
- ]),
75
- it(wt, { name: "checkmark" })
76
- ], 2));
77
- }
78
- }), Mn = /* @__PURE__ */ M({
79
- __name: "PDivider",
80
- props: {
81
- orientation: { default: "horizontal" }
82
- },
83
- setup(e) {
84
- const t = {
85
- vertical: ["w-2px", "h-full"],
86
- horizontal: ["h-2px", "w-full"]
87
- };
88
- return (n, r) => (V(), O("div", {
89
- class: F(["bg-pico-stroke-neutral", t[e.orientation]])
90
- }, null, 2));
91
- }
92
- });
93
- function N(e) {
94
- return typeof e == "function";
95
- }
96
- function kt(e) {
97
- return e == null;
98
- }
99
- const q = (e) => e !== null && !!e && typeof e == "object" && !Array.isArray(e);
100
- function Ne(e) {
101
- return Number(e) >= 0;
102
- }
103
- function St(e) {
104
- const t = parseFloat(e);
105
- return isNaN(t) ? e : t;
106
- }
107
- function xt(e) {
108
- const t = e.split(".");
109
- if (!t.length)
110
- return "";
111
- let n = String(t[0]);
112
- for (let r = 1; r < t.length; r++) {
113
- if (Ne(t[r])) {
114
- n += `[${t[r]}]`;
115
- continue;
116
- }
117
- n += `.${t[r]}`;
118
- }
119
- return n;
120
- }
121
- const Ct = {};
122
- function jt(e) {
123
- return Ct[e];
124
- }
125
- function Ve(e, t, n) {
126
- typeof n.value == "object" && (n.value = D(n.value)), !n.enumerable || n.get || n.set || !n.configurable || !n.writable || t === "__proto__" ? Object.defineProperty(e, t, n) : e[t] = n.value;
127
- }
128
- function D(e) {
129
- if (typeof e != "object") return e;
130
- var t = 0, n, r, i, o = Object.prototype.toString.call(e);
131
- if (o === "[object Object]" ? i = Object.create(e.__proto__ || null) : o === "[object Array]" ? i = Array(e.length) : o === "[object Set]" ? (i = /* @__PURE__ */ new Set(), e.forEach(function(l) {
132
- i.add(D(l));
133
- })) : o === "[object Map]" ? (i = /* @__PURE__ */ new Map(), e.forEach(function(l, u) {
134
- i.set(D(u), D(l));
135
- })) : o === "[object Date]" ? i = /* @__PURE__ */ new Date(+e) : o === "[object RegExp]" ? i = new RegExp(e.source, e.flags) : o === "[object DataView]" ? i = new e.constructor(D(e.buffer)) : o === "[object ArrayBuffer]" ? i = e.slice(0) : o.slice(-6) === "Array]" && (i = new e.constructor(e)), i) {
136
- for (r = Object.getOwnPropertySymbols(e); t < r.length; t++)
137
- Ve(i, r[t], Object.getOwnPropertyDescriptor(e, r[t]));
138
- for (t = 0, r = Object.getOwnPropertyNames(e); t < r.length; t++)
139
- Object.hasOwnProperty.call(i, n = r[t]) && i[n] === e[n] || Ve(i, n, Object.getOwnPropertyDescriptor(e, n));
140
- }
141
- return i || e;
142
- }
143
- const Fe = /* @__PURE__ */ Symbol("vee-validate-form"), At = /* @__PURE__ */ Symbol("vee-validate-field-instance"), we = /* @__PURE__ */ Symbol("Default empty value"), Me = typeof window < "u";
144
- function ue(e) {
145
- return N(e) && !!e.__locatorRef;
146
- }
147
- function J(e) {
148
- return !!e && N(e.parse) && e.__type === "VVTypedSchema";
149
- }
150
- function se(e) {
151
- return !!e && N(e.validate);
152
- }
153
- function $e(e) {
154
- return e === "checkbox" || e === "radio";
155
- }
156
- function It(e) {
157
- return q(e) || Array.isArray(e);
158
- }
159
- function pe(e) {
160
- return /^\[.+\]$/i.test(e);
161
- }
162
- function Pt(e) {
163
- return Te(e) && e.multiple;
164
- }
165
- function Te(e) {
166
- return e.tagName === "SELECT";
167
- }
168
- function Et(e) {
169
- return e ? !!(typeof Event < "u" && N(Event) && e instanceof Event || e && e.srcElement) : !1;
170
- }
171
- function x(e, t) {
172
- if (e === t)
173
- return !0;
174
- if (e && t && typeof e == "object" && typeof t == "object") {
175
- if (e.constructor !== t.constructor)
176
- return !1;
177
- var n, r, i;
178
- if (Array.isArray(e)) {
179
- if (n = e.length, n != t.length)
180
- return !1;
181
- for (r = n; r-- !== 0; )
182
- if (!x(e[r], t[r]))
183
- return !1;
184
- return !0;
185
- }
186
- if (e instanceof Map && t instanceof Map) {
187
- if (e.size !== t.size)
188
- return !1;
189
- for (r of e.entries())
190
- if (!t.has(r[0]))
191
- return !1;
192
- for (r of e.entries())
193
- if (!x(r[1], t.get(r[0])))
194
- return !1;
195
- return !0;
196
- }
197
- if (ke(e) && ke(t))
198
- return !(e.size !== t.size || e.name !== t.name || e.lastModified !== t.lastModified || e.type !== t.type);
199
- if (e instanceof Set && t instanceof Set) {
200
- if (e.size !== t.size)
201
- return !1;
202
- for (r of e.entries())
203
- if (!t.has(r[0]))
204
- return !1;
205
- return !0;
206
- }
207
- if (ArrayBuffer.isView(e) && ArrayBuffer.isView(t)) {
208
- if (n = e.length, n != t.length)
209
- return !1;
210
- for (r = n; r-- !== 0; )
211
- if (e[r] !== t[r])
212
- return !1;
213
- return !0;
214
- }
215
- if (e.constructor === RegExp)
216
- return e.source === t.source && e.flags === t.flags;
217
- if (e.valueOf !== Object.prototype.valueOf)
218
- return e.valueOf() === t.valueOf();
219
- if (e.toString !== Object.prototype.toString)
220
- return e.toString() === t.toString();
221
- if (e = Oe(e), t = Oe(t), i = Object.keys(e), n = i.length, n !== Object.keys(t).length)
222
- return !1;
223
- for (r = n; r-- !== 0; )
224
- if (!Object.prototype.hasOwnProperty.call(t, i[r]))
225
- return !1;
226
- for (r = n; r-- !== 0; ) {
227
- var o = i[r];
228
- if (!x(e[o], t[o]))
229
- return !1;
230
- }
231
- return !0;
232
- }
233
- return e !== e && t !== t;
234
- }
235
- function Oe(e) {
236
- return Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
237
- }
238
- function ke(e) {
239
- return Me ? e instanceof File : !1;
240
- }
241
- function De(e) {
242
- return pe(e) ? e.replace(/\[|\]/gi, "") : e;
243
- }
244
- function W(e, t, n) {
245
- return e ? pe(t) ? e[De(t)] : (t || "").split(/\.|\[(\d+)\]/).filter(Boolean).reduce((i, o) => It(i) && o in i ? i[o] : n, e) : n;
246
- }
247
- function Nt(e, t, n) {
248
- if (pe(t)) {
249
- e[De(t)] = n;
250
- return;
251
- }
252
- const r = t.split(/\.|\[(\d+)\]/).filter(Boolean);
253
- let i = e;
254
- for (let o = 0; o < r.length; o++) {
255
- if (o === r.length - 1) {
256
- i[r[o]] = n;
257
- return;
258
- }
259
- (!(r[o] in i) || kt(i[r[o]])) && (i[r[o]] = Ne(r[o + 1]) ? [] : {}), i = i[r[o]];
260
- }
261
- }
262
- function Re(e) {
263
- return Object.keys(e);
264
- }
265
- function Be(e, t = void 0) {
266
- const n = H();
267
- return n?.provides[e] || ut(e, t);
268
- }
269
- function Ft(e, t, n) {
270
- if (Array.isArray(e)) {
271
- const r = [...e], i = r.findIndex((o) => x(o, t));
272
- return i >= 0 ? r.splice(i, 1) : r.push(t), r;
273
- }
274
- return x(e, t) ? n : t;
275
- }
276
- function Mt(e, t) {
277
- let n, r;
278
- return function(...i) {
279
- const o = this;
280
- return n || (n = !0, setTimeout(() => n = !1, t), r = e.apply(o, i)), r;
281
- };
282
- }
283
- function $t(e, t) {
284
- return q(t) && t.number ? St(e) : e;
285
- }
286
- function Se(e, t) {
287
- let n;
288
- return async function(...i) {
289
- const o = e(...i);
290
- n = o;
291
- const l = await o;
292
- return o !== n ? l : (n = void 0, t(l, i));
293
- };
294
- }
295
- function Tt(e) {
296
- return Array.isArray(e) ? e : e ? [e] : [];
297
- }
298
- function le(e) {
299
- if (ze(e))
300
- return e._value;
301
- }
302
- function ze(e) {
303
- return "_value" in e;
304
- }
305
- function Dt(e) {
306
- return e.type === "number" || e.type === "range" ? Number.isNaN(e.valueAsNumber) ? e.value : e.valueAsNumber : e.value;
307
- }
308
- function Ue(e) {
309
- if (!Et(e))
310
- return e;
311
- const t = e.target;
312
- if ($e(t.type) && ze(t))
313
- return le(t);
314
- if (t.type === "file" && t.files) {
315
- const n = Array.from(t.files);
316
- return t.multiple ? n : n[0];
317
- }
318
- if (Pt(t))
319
- return Array.from(t.options).filter((n) => n.selected && !n.disabled).map(le);
320
- if (Te(t)) {
321
- const n = Array.from(t.options).find((r) => r.selected);
322
- return n ? le(n) : t.value;
323
- }
324
- return Dt(t);
325
- }
326
- function Le(e) {
327
- const t = {};
328
- return Object.defineProperty(t, "_$$isNormalized", {
329
- value: !0,
330
- writable: !1,
331
- enumerable: !1,
332
- configurable: !1
333
- }), e ? q(e) && e._$$isNormalized ? e : q(e) ? Object.keys(e).reduce((n, r) => {
334
- const i = Rt(e[r]);
335
- return e[r] !== !1 && (n[r] = xe(i)), n;
336
- }, t) : typeof e != "string" ? t : e.split("|").reduce((n, r) => {
337
- const i = Bt(r);
338
- return i.name && (n[i.name] = xe(i.params)), n;
339
- }, t) : t;
340
- }
341
- function Rt(e) {
342
- return e === !0 ? [] : Array.isArray(e) || q(e) ? e : [e];
343
- }
344
- function xe(e) {
345
- const t = (n) => typeof n == "string" && n[0] === "@" ? zt(n.slice(1)) : n;
346
- return Array.isArray(e) ? e.map(t) : e instanceof RegExp ? [e] : Object.keys(e).reduce((n, r) => (n[r] = t(e[r]), n), {});
347
- }
348
- const Bt = (e) => {
349
- let t = [];
350
- const n = e.split(":")[0];
351
- return e.includes(":") && (t = e.split(":").slice(1).join(":").split(",")), { name: n, params: t };
352
- };
353
- function zt(e) {
354
- const t = (n) => {
355
- var r;
356
- return (r = W(n, e)) !== null && r !== void 0 ? r : n[e];
357
- };
358
- return t.__locatorRef = e, t;
359
- }
360
- function Ut(e) {
361
- return Array.isArray(e) ? e.filter(ue) : Re(e).filter((t) => ue(e[t])).map((t) => e[t]);
362
- }
363
- const Lt = {
364
- generateMessage: ({ field: e }) => `${e} is not valid.`,
365
- bails: !0,
366
- validateOnBlur: !0,
367
- validateOnChange: !0,
368
- validateOnInput: !1,
369
- validateOnModelUpdate: !0
370
- };
371
- let qt = Object.assign({}, Lt);
372
- const Wt = () => qt;
373
- async function Kt(e, t, n = {}) {
374
- const r = n?.bails, i = {
375
- name: n?.name || "{field}",
376
- rules: t,
377
- label: n?.label,
378
- bails: r ?? !0,
379
- formData: n?.values || {}
380
- }, o = await Gt(i, e);
381
- return Object.assign(Object.assign({}, o), { valid: !o.errors.length });
382
- }
383
- async function Gt(e, t) {
384
- const n = e.rules;
385
- if (J(n) || se(n))
386
- return Xt(t, Object.assign(Object.assign({}, e), { rules: n }));
387
- if (N(n) || Array.isArray(n)) {
388
- const u = {
389
- field: e.label || e.name,
390
- name: e.name,
391
- label: e.label,
392
- form: e.formData,
393
- value: t
394
- }, s = Array.isArray(n) ? n : [n], c = s.length, g = [];
395
- for (let h = 0; h < c; h++) {
396
- const j = s[h], p = await j(t, u);
397
- if (!(typeof p != "string" && !Array.isArray(p) && p)) {
398
- if (Array.isArray(p))
399
- g.push(...p);
400
- else {
401
- const R = typeof p == "string" ? p : qe(u);
402
- g.push(R);
403
- }
404
- if (e.bails)
405
- return {
406
- errors: g
407
- };
408
- }
409
- }
410
- return {
411
- errors: g
412
- };
413
- }
414
- const r = Object.assign(Object.assign({}, e), { rules: Le(n) }), i = [], o = Object.keys(r.rules), l = o.length;
415
- for (let u = 0; u < l; u++) {
416
- const s = o[u], c = await Ht(r, t, {
417
- name: s,
418
- params: r.rules[s]
419
- });
420
- if (c.error && (i.push(c.error), e.bails))
421
- return {
422
- errors: i
423
- };
424
- }
425
- return {
426
- errors: i
427
- };
428
- }
429
- function Jt(e) {
430
- return !!e && e.name === "ValidationError";
431
- }
432
- function Yt(e) {
433
- return {
434
- __type: "VVTypedSchema",
435
- async parse(n, r) {
436
- var i;
437
- try {
438
- return {
439
- output: await e.validate(n, { abortEarly: !1, context: r?.formData || {} }),
440
- errors: []
441
- };
442
- } catch (o) {
443
- if (!Jt(o))
444
- throw o;
445
- if (!(!((i = o.inner) === null || i === void 0) && i.length) && o.errors.length)
446
- return { errors: [{ path: o.path, errors: o.errors }] };
447
- const l = o.inner.reduce((u, s) => {
448
- const c = s.path || "";
449
- return u[c] || (u[c] = { errors: [], path: c }), u[c].errors.push(...s.errors), u;
450
- }, {});
451
- return { errors: Object.values(l) };
452
- }
453
- }
454
- };
455
- }
456
- async function Xt(e, t) {
457
- const r = await (J(t.rules) ? t.rules : Yt(t.rules)).parse(e, { formData: t.formData }), i = [];
458
- for (const o of r.errors)
459
- o.errors.length && i.push(...o.errors);
460
- return {
461
- value: r.value,
462
- errors: i
463
- };
464
- }
465
- async function Ht(e, t, n) {
466
- const r = jt(n.name);
467
- if (!r)
468
- throw new Error(`No such validator '${n.name}' exists.`);
469
- const i = Qt(n.params, e.formData), o = {
470
- field: e.label || e.name,
471
- name: e.name,
472
- label: e.label,
473
- value: t,
474
- form: e.formData,
475
- rule: Object.assign(Object.assign({}, n), { params: i })
476
- }, l = await r(t, i, o);
477
- return typeof l == "string" ? {
478
- error: l
479
- } : {
480
- error: l ? void 0 : qe(o)
481
- };
482
- }
483
- function qe(e) {
484
- const t = Wt().generateMessage;
485
- return t ? t(e) : "Field is invalid";
486
- }
487
- function Qt(e, t) {
488
- const n = (r) => ue(r) ? r(t) : r;
489
- return Array.isArray(e) ? e.map(n) : Object.keys(e).reduce((r, i) => (r[i] = n(e[i]), r), {});
490
- }
491
- let Ce = 0;
492
- function Zt(e, t) {
493
- const { value: n, initialValue: r, setInitialValue: i } = en(e, t.modelValue, t.form);
494
- if (!t.form) {
495
- let j = function(p) {
496
- var A;
497
- "value" in p && (n.value = p.value), "errors" in p && c(p.errors), "touched" in p && (h.touched = (A = p.touched) !== null && A !== void 0 ? A : h.touched), "initialValue" in p && i(p.initialValue);
498
- };
499
- const { errors: s, setErrors: c } = rn(), g = Ce >= Number.MAX_SAFE_INTEGER ? 0 : ++Ce, h = nn(n, r, s, t.schema);
500
- return {
501
- id: g,
502
- path: e,
503
- value: n,
504
- initialValue: r,
505
- meta: h,
506
- flags: { pendingUnmount: { [g]: !1 }, pendingReset: !1 },
507
- errors: s,
508
- setState: j
509
- };
510
- }
511
- const o = t.form.createPathState(e, {
512
- bails: t.bails,
513
- label: t.label,
514
- type: t.type,
515
- validate: t.validate,
516
- schema: t.schema
517
- }), l = C(() => o.errors);
518
- function u(s) {
519
- var c, g, h;
520
- "value" in s && (n.value = s.value), "errors" in s && ((c = t.form) === null || c === void 0 || c.setFieldError(f(e), s.errors)), "touched" in s && ((g = t.form) === null || g === void 0 || g.setFieldTouched(f(e), (h = s.touched) !== null && h !== void 0 ? h : !1)), "initialValue" in s && i(s.initialValue);
521
- }
522
- return {
523
- id: Array.isArray(o.id) ? o.id[o.id.length - 1] : o.id,
524
- path: e,
525
- value: n,
526
- errors: l,
527
- meta: o,
528
- initialValue: r,
529
- flags: o.__flags,
530
- setState: u
531
- };
532
- }
533
- function en(e, t, n) {
534
- const r = ae(f(t));
535
- function i() {
536
- return n ? W(n.initialValues.value, f(e), f(r)) : f(r);
537
- }
538
- function o(c) {
539
- if (!n) {
540
- r.value = c;
541
- return;
542
- }
543
- n.setFieldInitialValue(f(e), c, !0);
544
- }
545
- const l = C(i);
546
- if (!n)
547
- return {
548
- value: ae(i()),
549
- initialValue: l,
550
- setInitialValue: o
551
- };
552
- const u = tn(t, n, l, e);
553
- return n.stageInitialValue(f(e), u, !0), {
554
- value: C({
555
- get() {
556
- return W(n.values, f(e));
557
- },
558
- set(c) {
559
- n.setFieldValue(f(e), c, !1);
560
- }
561
- }),
562
- initialValue: l,
563
- setInitialValue: o
564
- };
565
- }
566
- function tn(e, t, n, r) {
567
- return ve(e) ? f(e) : e !== void 0 ? e : W(t.values, f(r), f(n));
568
- }
569
- function nn(e, t, n, r) {
570
- const i = C(() => {
571
- var l, u, s;
572
- return (s = (u = (l = b(r)) === null || l === void 0 ? void 0 : l.describe) === null || u === void 0 ? void 0 : u.call(l).required) !== null && s !== void 0 ? s : !1;
573
- }), o = ct({
574
- touched: !1,
575
- pending: !1,
576
- valid: !0,
577
- required: i,
578
- validated: !!f(n).length,
579
- initialValue: C(() => f(t)),
580
- dirty: C(() => !x(f(e), f(t)))
581
- });
582
- return L(n, (l) => {
583
- o.valid = !l.length;
584
- }, {
585
- immediate: !0,
586
- flush: "sync"
587
- }), o;
588
- }
589
- function rn() {
590
- const e = ae([]);
591
- return {
592
- errors: e,
593
- setErrors: (t) => {
594
- e.value = Tt(t);
595
- }
596
- };
597
- }
598
- const We = {}, Y = {}, X = "vee-validate-inspector", w = {
599
- error: 12405579,
600
- success: 448379,
601
- unknown: 5522283,
602
- white: 16777215,
603
- black: 0,
604
- blue: 218007,
605
- purple: 12157168,
606
- orange: 16099682,
607
- gray: 12304330
608
- };
609
- let y = null, E;
610
- async function on(e) {
611
- if (process.env.NODE_ENV !== "production") {
612
- if (!Me)
613
- return;
614
- (await import("./index-DRqJOqUR.js")).setupDevtoolsPlugin({
615
- id: "vee-validate-devtools-plugin",
616
- label: "VeeValidate Plugin",
617
- packageName: "vee-validate",
618
- homepage: "https://vee-validate.logaretm.com/v4",
619
- app: e,
620
- logo: "https://vee-validate.logaretm.com/v4/logo.png"
621
- }, (n) => {
622
- E = n, n.addInspector({
623
- id: X,
624
- icon: "rule",
625
- label: "vee-validate",
626
- noSelectionText: "Select a vee-validate node to inspect",
627
- actions: [
628
- {
629
- icon: "done_outline",
630
- tooltip: "Validate selected item",
631
- action: async () => {
632
- if (!y) {
633
- console.error("There is not a valid selected vee-validate node or component");
634
- return;
635
- }
636
- if (y.type === "field") {
637
- await y.field.validate();
638
- return;
639
- }
640
- if (y.type === "form") {
641
- await y.form.validate();
642
- return;
643
- }
644
- y.type === "pathState" && await y.form.validateField(y.state.path);
645
- }
646
- },
647
- {
648
- icon: "delete_sweep",
649
- tooltip: "Clear validation state of the selected item",
650
- action: () => {
651
- if (!y) {
652
- console.error("There is not a valid selected vee-validate node or component");
653
- return;
654
- }
655
- if (y.type === "field") {
656
- y.field.resetField();
657
- return;
658
- }
659
- y.type === "form" && y.form.resetForm(), y.type === "pathState" && y.form.resetField(y.state.path);
660
- }
661
- }
662
- ]
663
- }), n.on.getInspectorTree((r) => {
664
- if (r.inspectorId !== X)
665
- return;
666
- const i = Object.values(We), o = Object.values(Y);
667
- r.rootNodes = [
668
- ...i.map(an),
669
- ...o.map((l) => sn(l))
670
- ];
671
- }), n.on.getInspectorState((r) => {
672
- if (r.inspectorId !== X)
673
- return;
674
- const { form: i, field: o, state: l, type: u } = cn(r.nodeId);
675
- if (n.unhighlightElement(), i && u === "form") {
676
- r.state = dn(i), y = { type: "form", form: i }, n.highlightElement(i._vm);
677
- return;
678
- }
679
- if (l && u === "pathState" && i) {
680
- r.state = je(l), y = { type: "pathState", state: l, form: i };
681
- return;
682
- }
683
- if (o && u === "field") {
684
- r.state = je({
685
- errors: o.errors.value,
686
- dirty: o.meta.dirty,
687
- valid: o.meta.valid,
688
- touched: o.meta.touched,
689
- value: o.value.value,
690
- initialValue: o.meta.initialValue
691
- }), y = { field: o, type: "field" }, n.highlightElement(o._vm);
692
- return;
693
- }
694
- y = null, n.unhighlightElement();
695
- });
696
- });
697
- }
698
- }
699
- const ce = Mt(() => {
700
- setTimeout(async () => {
701
- await dt(), E?.sendInspectorState(X), E?.sendInspectorTree(X);
702
- }, 100);
703
- }, 100);
704
- function ln(e) {
705
- const t = H();
706
- if (!E) {
707
- const n = t?.appContext.app;
708
- if (!n)
709
- return;
710
- on(n);
711
- }
712
- Y[e.id] = Object.assign({}, e), Y[e.id]._vm = t, st(() => {
713
- delete Y[e.id], ce();
714
- }), ce();
715
- }
716
- function an(e) {
717
- const { textColor: t, bgColor: n } = Ge(e.meta.value.valid), r = {};
718
- Object.values(e.getAllPathStates()).forEach((l) => {
719
- Nt(r, b(l.path), un(l, e));
720
- });
721
- function i(l, u = []) {
722
- const s = [...u].pop();
723
- return "id" in l ? Object.assign(Object.assign({}, l), { label: s || l.label }) : q(l) ? {
724
- id: `${u.join(".")}`,
725
- label: s || "",
726
- children: Object.keys(l).map((c) => i(l[c], [...u, c]))
727
- } : Array.isArray(l) ? {
728
- id: `${u.join(".")}`,
729
- label: `${s}[]`,
730
- children: l.map((c, g) => i(c, [...u, String(g)]))
731
- } : { id: "", label: "", children: [] };
732
- }
733
- const { children: o } = i(r);
734
- return {
735
- id: me(e),
736
- label: e.name,
737
- children: o,
738
- tags: [
739
- {
740
- label: "Form",
741
- textColor: t,
742
- backgroundColor: n
743
- },
744
- {
745
- label: `${e.getAllPathStates().length} fields`,
746
- textColor: w.white,
747
- backgroundColor: w.unknown
748
- }
749
- ]
750
- };
751
- }
752
- function un(e, t) {
753
- return {
754
- id: me(t, e),
755
- label: b(e.path),
756
- tags: Ke(e.multiple, e.fieldsCount, e.type, e.valid, t)
757
- };
758
- }
759
- function sn(e, t) {
760
- return {
761
- id: me(t, e),
762
- label: f(e.name),
763
- tags: Ke(!1, 1, e.type, e.meta.valid, t)
764
- };
765
- }
766
- function Ke(e, t, n, r, i) {
767
- const { textColor: o, bgColor: l } = Ge(r);
768
- return [
769
- e ? void 0 : {
770
- label: "Field",
771
- textColor: o,
772
- backgroundColor: l
773
- },
774
- i ? void 0 : {
775
- label: "Standalone",
776
- textColor: w.black,
777
- backgroundColor: w.gray
778
- },
779
- n === "checkbox" ? {
780
- label: "Checkbox",
781
- textColor: w.white,
782
- backgroundColor: w.blue
783
- } : void 0,
784
- n === "radio" ? {
785
- label: "Radio",
786
- textColor: w.white,
787
- backgroundColor: w.purple
788
- } : void 0,
789
- e ? {
790
- label: "Multiple",
791
- textColor: w.black,
792
- backgroundColor: w.orange
793
- } : void 0
794
- ].filter(Boolean);
795
- }
796
- function me(e, t) {
797
- const n = t ? "path" in t ? "pathState" : "field" : "form", r = t ? "path" in t ? t?.path : b(t?.name) : "", i = { f: e?.formId, ff: t?.id || r, type: n };
798
- return btoa(encodeURIComponent(JSON.stringify(i)));
799
- }
800
- function cn(e) {
801
- try {
802
- const t = JSON.parse(decodeURIComponent(atob(e))), n = We[t.f];
803
- if (!n && t.ff) {
804
- const i = Y[t.ff];
805
- return i ? {
806
- type: t.type,
807
- field: i
808
- } : {};
809
- }
810
- if (!n)
811
- return {};
812
- const r = n.getPathState(t.ff);
813
- return {
814
- type: t.type,
815
- form: n,
816
- state: r
817
- };
818
- } catch {
819
- }
820
- return {};
821
- }
822
- function je(e) {
823
- return {
824
- "Field state": [
825
- { key: "errors", value: e.errors },
826
- {
827
- key: "initialValue",
828
- value: e.initialValue
829
- },
830
- {
831
- key: "currentValue",
832
- value: e.value
833
- },
834
- {
835
- key: "touched",
836
- value: e.touched
837
- },
838
- {
839
- key: "dirty",
840
- value: e.dirty
841
- },
842
- {
843
- key: "valid",
844
- value: e.valid
845
- }
846
- ]
847
- };
848
- }
849
- function dn(e) {
850
- const { errorBag: t, meta: n, values: r, isSubmitting: i, isValidating: o, submitCount: l } = e;
851
- return {
852
- "Form state": [
853
- {
854
- key: "submitCount",
855
- value: l.value
856
- },
857
- {
858
- key: "isSubmitting",
859
- value: i.value
860
- },
861
- {
862
- key: "isValidating",
863
- value: o.value
864
- },
865
- {
866
- key: "touched",
867
- value: n.value.touched
868
- },
869
- {
870
- key: "dirty",
871
- value: n.value.dirty
872
- },
873
- {
874
- key: "valid",
875
- value: n.value.valid
876
- },
877
- {
878
- key: "initialValues",
879
- value: n.value.initialValues
880
- },
881
- {
882
- key: "currentValues",
883
- value: r
884
- },
885
- {
886
- key: "errors",
887
- value: Re(t.value).reduce((u, s) => {
888
- var c;
889
- const g = (c = t.value[s]) === null || c === void 0 ? void 0 : c[0];
890
- return g && (u[s] = g), u;
891
- }, {})
892
- }
893
- ]
894
- };
895
- }
896
- function Ge(e) {
897
- return {
898
- bgColor: e ? w.success : w.error,
899
- textColor: e ? w.black : w.white
900
- };
901
- }
902
- function fn(e, t, n) {
903
- return $e(void 0) ? pn(e, t) : Je(e, t);
904
- }
905
- function Je(e, t, n) {
906
- const { initialValue: r, validateOnMount: i, bails: o, type: l, checkedValue: u, label: s, validateOnValueUpdate: c, uncheckedValue: g, controlled: h, keepValueOnUnmount: j, syncVModel: p, form: A } = vn(), R = h ? Be(Fe) : void 0, d = A || R, P = C(() => xt(b(e))), I = C(() => {
907
- if (b(d?.schema))
908
- return;
909
- const v = f(t);
910
- return se(v) || J(v) || N(v) || Array.isArray(v) ? v : Le(v);
911
- }), Ye = !N(I.value) && J(b(t)), { id: re, value: K, initialValue: Xe, meta: k, setState: Q, errors: ie, flags: Z } = Zt(P, {
912
- modelValue: r,
913
- form: d,
914
- bails: o,
915
- label: s,
916
- type: l,
917
- validate: I.value ? ge : void 0,
918
- schema: Ye ? t : void 0
919
- }), He = C(() => ie.value[0]);
920
- p && mn({
921
- value: K,
922
- prop: p,
923
- handleChange: ye,
924
- shouldValidate: () => c && !Z.pendingReset
925
- });
926
- const Qe = (a, v = !1) => {
927
- k.touched = !0, v && B();
928
- };
929
- async function he(a) {
930
- var v, _;
931
- if (d?.validateSchema) {
932
- const { results: m } = await d.validateSchema(a);
933
- return (v = m[b(P)]) !== null && v !== void 0 ? v : { valid: !0, errors: [] };
934
- }
935
- return I.value ? Kt(K.value, I.value, {
936
- name: b(P),
937
- label: b(s),
938
- values: (_ = d?.values) !== null && _ !== void 0 ? _ : {},
939
- bails: o
940
- }) : { valid: !0, errors: [] };
941
- }
942
- const B = Se(async () => (k.pending = !0, k.validated = !0, he("validated-only")), (a) => (Z.pendingUnmount[S.id] || (Q({ errors: a.errors }), k.pending = !1, k.valid = a.valid), a)), z = Se(async () => he("silent"), (a) => (k.valid = a.valid, a));
943
- function ge(a) {
944
- return a?.mode === "silent" ? z() : B();
945
- }
946
- function ye(a, v = !0) {
947
- const _ = Ue(a);
948
- oe(_, v);
949
- }
950
- ot(() => {
951
- if (i)
952
- return B();
953
- (!d || !d.validateSchema) && z();
954
- });
955
- function Ze(a) {
956
- k.touched = a;
957
- }
958
- function be(a) {
959
- var v;
960
- const _ = a && "value" in a ? a.value : Xe.value;
961
- Q({
962
- value: D(_),
963
- initialValue: D(_),
964
- touched: (v = a?.touched) !== null && v !== void 0 ? v : !1,
965
- errors: a?.errors || []
966
- }), k.pending = !1, k.validated = !1, z();
967
- }
968
- const _e = H();
969
- function oe(a, v = !0) {
970
- K.value = _e && p ? $t(a, _e.props.modelModifiers) : a, (v ? B : z)();
971
- }
972
- function et(a) {
973
- Q({ errors: Array.isArray(a) ? a : [a] });
974
- }
975
- const tt = C({
976
- get() {
977
- return K.value;
978
- },
979
- set(a) {
980
- oe(a, c);
981
- }
982
- }), S = {
983
- id: re,
984
- name: P,
985
- label: s,
986
- value: tt,
987
- meta: k,
988
- errors: ie,
989
- errorMessage: He,
990
- type: l,
991
- checkedValue: u,
992
- uncheckedValue: g,
993
- bails: o,
994
- keepValueOnUnmount: j,
995
- resetField: be,
996
- handleReset: () => be(),
997
- validate: ge,
998
- handleChange: ye,
999
- handleBlur: Qe,
1000
- setState: Q,
1001
- setTouched: Ze,
1002
- setErrors: et,
1003
- setValue: oe
1004
- };
1005
- if (lt(At, S), ve(t) && typeof f(t) != "function" && L(t, (a, v) => {
1006
- x(a, v) || (k.validated ? B() : z());
1007
- }, {
1008
- deep: !0
1009
- }), process.env.NODE_ENV !== "production" && (S._vm = H(), L(() => Object.assign(Object.assign({ errors: ie.value }, k), { value: K.value }), ce, {
1010
- deep: !0
1011
- }), d || ln(S)), !d)
1012
- return S;
1013
- const nt = C(() => {
1014
- const a = I.value;
1015
- return !a || N(a) || se(a) || J(a) || Array.isArray(a) ? {} : Object.keys(a).reduce((v, _) => {
1016
- const m = Ut(a[_]).map((G) => G.__locatorRef).reduce((G, U) => {
1017
- const $ = W(d.values, U) || d.values[U];
1018
- return $ !== void 0 && (G[U] = $), G;
1019
- }, {});
1020
- return Object.assign(v, m), v;
1021
- }, {});
1022
- });
1023
- return L(nt, (a, v) => {
1024
- if (!Object.keys(a).length)
1025
- return;
1026
- !x(a, v) && (k.validated ? B() : z());
1027
- }), at(() => {
1028
- var a;
1029
- const v = (a = b(S.keepValueOnUnmount)) !== null && a !== void 0 ? a : b(d.keepValuesOnUnmount), _ = b(P);
1030
- if (v || !d || Z.pendingUnmount[S.id]) {
1031
- d?.removePathState(_, re);
1032
- return;
1033
- }
1034
- Z.pendingUnmount[S.id] = !0;
1035
- const m = d.getPathState(_);
1036
- if (Array.isArray(m?.id) && m?.multiple ? m?.id.includes(S.id) : m?.id === S.id) {
1037
- if (m?.multiple && Array.isArray(m.value)) {
1038
- const U = m.value.findIndex(($) => x($, b(S.checkedValue)));
1039
- if (U > -1) {
1040
- const $ = [...m.value];
1041
- $.splice(U, 1), d.setFieldValue(_, $);
1042
- }
1043
- Array.isArray(m.id) && m.id.splice(m.id.indexOf(S.id), 1);
1044
- } else
1045
- d.unsetPathValue(b(P));
1046
- d.removePathState(_, re);
1047
- }
1048
- }), S;
1049
- }
1050
- function vn(e) {
1051
- return Object.assign(Object.assign({}, {
1052
- initialValue: void 0,
1053
- validateOnMount: !1,
1054
- bails: !0,
1055
- label: void 0,
1056
- validateOnValueUpdate: !0,
1057
- keepValueOnUnmount: void 0,
1058
- syncVModel: !1,
1059
- controlled: !0
1060
- }), { initialValue: void 0 });
1061
- }
1062
- function pn(e, t, n) {
1063
- const r = Be(Fe), i = void 0, o = void 0;
1064
- function l(u) {
1065
- const s = u.handleChange, c = C(() => {
1066
- const h = b(u.value), j = b(i);
1067
- return Array.isArray(h) ? h.findIndex((p) => x(p, j)) >= 0 : x(j, h);
1068
- });
1069
- function g(h, j = !0) {
1070
- var p, A;
1071
- if (c.value === ((p = h?.target) === null || p === void 0 ? void 0 : p.checked)) {
1072
- j && u.validate();
1073
- return;
1074
- }
1075
- const R = b(e), d = r?.getPathState(R), P = Ue(h);
1076
- let I = (A = b(i)) !== null && A !== void 0 ? A : P;
1077
- r && d?.multiple && d.type === "checkbox" && (I = Ft(W(r.values, R) || [], I, void 0)), s(I, j);
1078
- }
1079
- return Object.assign(Object.assign({}, u), {
1080
- checked: c,
1081
- checkedValue: i,
1082
- uncheckedValue: o,
1083
- handleChange: g
1084
- });
1085
- }
1086
- return l(Je(e, t));
1087
- }
1088
- function mn({ prop: e, value: t, handleChange: n, shouldValidate: r }) {
1089
- const i = H();
1090
- if (!i || !e) {
1091
- process.env.NODE_ENV !== "production" && console.warn("Failed to setup model events because `useField` was not called in setup.");
1092
- return;
1093
- }
1094
- const o = typeof e == "string" ? e : "modelValue", l = `update:${o}`;
1095
- o in i.props && (L(t, (u) => {
1096
- x(u, Ae(i, o)) || i.emit(l, u);
1097
- }), L(() => Ae(i, o), (u) => {
1098
- if (u === we && t.value === void 0)
1099
- return;
1100
- const s = u === we ? void 0 : u;
1101
- x(s, t.value) || n(s, r());
1102
- }));
1103
- }
1104
- function Ae(e, t) {
1105
- if (e)
1106
- return e.props[t];
1107
- }
1108
- const hn = { class: "flex flex-col items-start" }, $n = /* @__PURE__ */ M({
1109
- __name: "PFormItem",
1110
- props: {
1111
- component: {},
1112
- props: {},
1113
- name: {},
1114
- inputClass: {},
1115
- errorClass: {}
1116
- },
1117
- setup(e) {
1118
- const { value: t, errorMessage: n } = fn(e.name, {});
1119
- return (r, i) => (V(), O("div", hn, [
1120
- f(n) ? (V(), O("span", {
1121
- key: 0,
1122
- class: F([e.errorClass, "text-pico-red text-xs max-w-full mb-1"])
1123
- }, Ee(f(n)), 3)) : ft("", !0),
1124
- (V(), Ie(Pe(e.component), vt({
1125
- class: [e.inputClass, "max-w-max"],
1126
- "is-invalid": !!f(n),
1127
- modelValue: f(t),
1128
- "onUpdate:modelValue": i[0] || (i[0] = (o) => ve(t) ? t.value = o : null),
1129
- name: e.name
1130
- }, e.props), null, 16, ["class", "is-invalid", "modelValue", "name"]))
1131
- ]));
1132
- }
1133
- }), ne = (e, t) => {
1134
- const n = e.__vccOpts || e;
1135
- for (const [r, i] of t)
1136
- n[r] = i;
1137
- return n;
1138
- }, gn = {}, yn = { class: "rounded-lg p-8 bg-white outline-pico-stroke-neutral outline-2" };
1139
- function bn(e, t) {
1140
- return V(), O("div", yn, [
1141
- ee(e.$slots, "default")
1142
- ]);
1143
- }
1144
- const Tn = /* @__PURE__ */ ne(gn, [["render", bn]]), _n = { class: "flex gap-2" }, Vn = ["value", "disabled"], Dn = /* @__PURE__ */ M({
1145
- __name: "PRadioInput",
1146
- props: /* @__PURE__ */ fe({
1147
- disabled: { type: Boolean, default: !1 },
1148
- name: {},
1149
- options: {}
1150
- }, {
1151
- modelValue: {},
1152
- modelModifiers: {}
1153
- }),
1154
- emits: ["update:modelValue"],
1155
- setup(e) {
1156
- const t = /* @__PURE__ */ new Map([
1157
- [!1, ["outline-2 -outline-offset-2"]],
1158
- [!0, ["bg-pico-primary"]]
1159
- ]), n = te(e, "modelValue");
1160
- return (r, i) => (V(!0), O(pt, null, mt(e.options, (o) => (V(), O("div", _n, [
1161
- T("div", {
1162
- class: F([f(t).get(n.value === o.value), "outline-pico-stroke-neutral min-w-5.5 duration-300 h-5.5 flex relative justify-center items-center rounded-full"])
1163
- }, [
1164
- de(T("input", {
1165
- type: "radio",
1166
- value: o.value,
1167
- class: "opacity-0 inset-0 absolute",
1168
- disabled: e.disabled,
1169
- "onUpdate:modelValue": i[0] || (i[0] = (l) => n.value = l)
1170
- }, null, 8, Vn), [
1171
- [ht, n.value]
1172
- ]),
1173
- i[1] || (i[1] = T("div", { class: "w-2 h-2 bg-white rounded-full" }, null, -1))
1174
- ], 2),
1175
- T("p", null, Ee(o.label), 1)
1176
- ]))), 256));
1177
- }
1178
- }), wn = {}, On = { class: "w-full h-full rounded-sm pico-skeleton" };
1179
- function kn(e, t) {
1180
- return V(), O("div", On);
1181
- }
1182
- const Rn = /* @__PURE__ */ ne(wn, [["render", kn], ["__scopeId", "data-v-7ff1dee9"]]), Bn = /* @__PURE__ */ M({
1183
- __name: "PSwitchInput",
1184
- props: {
1185
- modelValue: { type: Boolean },
1186
- modelModifiers: {}
1187
- },
1188
- emits: ["update:modelValue"],
1189
- setup(e) {
1190
- const t = /* @__PURE__ */ new Map([
1191
- [!1, [""]],
1192
- [!0, ["translate-x-[calc(100%-2px)]"]]
1193
- ]), n = /* @__PURE__ */ new Map([
1194
- [!1, ["bg-pico-stroke-neutral "]],
1195
- [!0, ["bg-pico-primary"]]
1196
- ]), r = te(e, "modelValue"), i = () => {
1197
- r.value = !r.value;
1198
- };
1199
- return (o, l) => (V(), O("div", {
1200
- onClick: i,
1201
- class: F([f(n).get(!!r.value), "p-0.5 duration-300 min-w-10.5 rounded-full"])
1202
- }, [
1203
- T("div", {
1204
- class: F([f(t).get(!!r.value), "w-5 duration-300 will-change-transform aspect-square rounded-full bg-white"])
1205
- }, null, 2)
1206
- ], 2));
1207
- }
1208
- }), Sn = ["disabled", "placeholder"], zn = /* @__PURE__ */ M({
1209
- __name: "PTextInput",
1210
- props: /* @__PURE__ */ fe({
1211
- placeholder: {},
1212
- isInvalid: { type: Boolean, default: !1 },
1213
- disabled: { type: Boolean, default: !1 }
1214
- }, {
1215
- modelValue: {},
1216
- modelModifiers: {}
1217
- }),
1218
- emits: ["update:modelValue"],
1219
- setup(e) {
1220
- const t = /* @__PURE__ */ new Map([
1221
- [!0, ["outline-pico-red! text-pico-red! bg-pico-light-red!"]],
1222
- [!1, []]
1223
- ]), n = te(e, "modelValue");
1224
- return (r, i) => de((V(), O("input", {
1225
- disabled: e.disabled,
1226
- type: "text",
1227
- "onUpdate:modelValue": i[0] || (i[0] = (o) => n.value = o),
1228
- placeholder: e.placeholder,
1229
- class: F([f(t).get(e.isInvalid), "outline-pico-stroke-neutral outline-1 disabled:text-pico-caption/70 disabled:cursor-not-allowed text-pico-caption focus:text-pico-text bg-pico-light focus:bg-pico-white duration-300 focus:outline-pico-primary px-3 py-2 rounded-lg"])
1230
- }, null, 10, Sn)), [
1231
- [gt, n.value]
1232
- ]);
1233
- }
1234
- }), xn = {}, Cn = { class: "bg-pico-light w-full h-full" };
1235
- function jn(e, t) {
1236
- return V(), O("div", Cn, [
1237
- ee(e.$slots, "default")
1238
- ]);
1239
- }
1240
- const Un = /* @__PURE__ */ ne(xn, [["render", jn]]), An = {}, In = { class: "shadow-dark rounded-lg p-4 bg-white" };
1241
- function Pn(e, t) {
1242
- return V(), O("div", In, [
1243
- ee(e.$slots, "default")
1244
- ]);
1245
- }
1246
- const Ln = /* @__PURE__ */ ne(An, [["render", Pn]]);
1247
- export {
1248
- Un as PBackgroud,
1249
- Nn as PButton,
1250
- Ln as PCard,
1251
- Fn as PCheckboxInput,
1252
- Mn as PDivider,
1253
- $n as PFormItem,
1254
- wt as PIcon,
1255
- Tn as PPlane,
1256
- Dn as PRadioInput,
1257
- Rn as PSkeleton,
1258
- Bn as PSwitchInput,
1259
- zn as PTextInput,
1260
- Vt as PicoIcons
1261
- };
1262
- //# sourceMappingURL=pico-ui.es.js.map