@vergelijkdirect/comparison-forms 2.0.0-rc.13 → 2.0.0-rc.14

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.
Files changed (34) hide show
  1. package/dist/wc-forms/VdInput-PLH7DZsc.js +331 -0
  2. package/dist/wc-forms/VdPopover-CcRVedXS.js +285 -0
  3. package/dist/wc-forms/VdRadioGroup-BsMaGEuY.js +166 -0
  4. package/dist/wc-forms/VdSearchableSelect-CY7qBcIO.js +4516 -0
  5. package/dist/wc-forms/VdSelect-BPB3Jh_f.js +108 -0
  6. package/dist/wc-forms/bike.js +1647 -0
  7. package/dist/wc-forms/birthdate.schema-DGsq2GQR.js +89 -0
  8. package/dist/wc-forms/business-car.js +109 -0
  9. package/dist/wc-forms/business-liability.js +71 -0
  10. package/dist/wc-forms/car.js +112 -0
  11. package/dist/wc-forms/caravan.js +144 -0
  12. package/dist/wc-forms/company.schema-CUG4hnMP.js +239 -0
  13. package/dist/wc-forms/date.util-D9xNHiuY.js +474 -0
  14. package/dist/wc-forms/familyComposition.schema-fY4w6P1J.js +74 -0
  15. package/dist/wc-forms/floating-ui.dom-B6uyM6oK.js +856 -0
  16. package/dist/wc-forms/house.js +101 -0
  17. package/dist/wc-forms/houseOwnedBuilding.model-CPULUrWv.js +14 -0
  18. package/dist/wc-forms/legal.js +153 -0
  19. package/dist/wc-forms/liability.js +89 -0
  20. package/dist/wc-forms/loan.js +173 -0
  21. package/dist/wc-forms/messages-kbFdNTrA.js +40 -0
  22. package/dist/wc-forms/moped.js +115 -0
  23. package/dist/wc-forms/motor.js +112 -0
  24. package/dist/wc-forms/package.js +119 -0
  25. package/dist/wc-forms/pet.js +158 -0
  26. package/dist/wc-forms/rolldown-runtime-Dqa2HsxW.js +20 -0
  27. package/dist/wc-forms/rules-Cj1sWDmF.js +13 -0
  28. package/dist/wc-forms/services-CG6XsnRT.js +16 -0
  29. package/dist/wc-forms/travel.js +99 -0
  30. package/dist/wc-forms/useAddress-LSZ7sQk9.js +243 -0
  31. package/dist/wc-forms/useLicensePlate-KLwykzxF.js +187 -0
  32. package/dist/wc-forms/useValidator-DdXn8soU.js +7197 -0
  33. package/dist/wc-forms/yesNo-BvJlCm7Y.js +6 -0
  34. package/package.json +7 -4
@@ -0,0 +1,243 @@
1
+ import { An as e, Gt as t, Jt as n, Kt as r, Ln as i, On as a, Sr as o, Un as s, Xn as c, Yt as l, _r as u, a as d, c as f, in as p, l as m, li as h, n as g, nn as _, oi as v, qr as y, r as b, ri as x, tn as S, ur as C, zr as w } from "./useValidator-DdXn8soU.js";
2
+ import { t as T } from "./VdInput-PLH7DZsc.js";
3
+ import { t as E } from "./VdSelect-BPB3Jh_f.js";
4
+ import { t as D } from "./services-CG6XsnRT.js";
5
+ //#endregion
6
+ //#region src/components/ui/form/VdFormGroup.vue
7
+ var O = /* @__PURE__ */ p({
8
+ __name: "VdFormGroup",
9
+ props: {
10
+ span: { default: null },
11
+ md: { default: null }
12
+ },
13
+ setup(e) {
14
+ let n = e, r = t(() => [
15
+ "vd-form__group",
16
+ n.span == null ? null : `vd-form__col-${n.span}`,
17
+ n.md == null ? null : `vd-form__col-md-${n.md}`
18
+ ]);
19
+ return (e, t) => (s(), l("div", { class: v(r.value) }, [c(e.$slots, "default")], 2));
20
+ }
21
+ }), k = { class: "vd-field" }, A = {
22
+ key: 0,
23
+ class: "vd-field__message vd-field__message--error"
24
+ }, j = {
25
+ key: 1,
26
+ class: "vd-field__message vd-field__message--information"
27
+ }, M = /* @__PURE__ */ p({
28
+ __name: "VdAddress",
29
+ props: /*@__PURE__*/ a({
30
+ path: { default: "address" },
31
+ additionOptions: {}
32
+ }, {
33
+ resolvedAddress: { required: !0 },
34
+ resolvedAddressModifiers: {}
35
+ }),
36
+ emits: ["update:resolvedAddress"],
37
+ setup(a) {
38
+ let c = a, d = C(a, "resolvedAddress"), { path: p } = c, { defineField: v, validateField: y, getFieldMeta: b, getError: D, removeError: M } = g(), [N, , P] = v(`${p}.zipCode`), [F, , I] = v(`${p}.houseNumber`), [L, , R] = v(`${p}.houseNumberAddition`), z = async () => {
39
+ await y(p), L.value || M(`${p}.houseNumberAddition`);
40
+ }, B = (e) => {
41
+ N.value && F.value ? z() : y(e);
42
+ }, V = () => B(`${p}.zipCode`), H = () => B(`${p}.houseNumber`), U = () => e(() => y(p)), W = b(p), G = t(() => D(p) ?? ""), K = t(() => d.value !== null), q = t(() => c.additionOptions.length === 0 ? "-" : "Kies een toevoeging");
43
+ return u([N, F], () => {
44
+ L.value &&= "", d.value = null, M(p), M(`${p}.houseNumberAddition`);
45
+ }), u(L, () => {
46
+ d.value = null;
47
+ }), i(() => {
48
+ N.value && F.value && z();
49
+ }), (e, t) => (s(), l("div", k, [_(m, null, {
50
+ default: o(() => [_(f, {
51
+ span: "5",
52
+ md: "3"
53
+ }, {
54
+ default: o(() => [_(T, {
55
+ modelValue: x(N),
56
+ "onUpdate:modelValue": t[0] ||= (e) => w(N) ? N.value = e : null,
57
+ modelModifiers: { trim: !0 },
58
+ name: "zipCode",
59
+ label: "Postcode",
60
+ placeholder: "bv. 1234 AZ",
61
+ "error-message": x(P),
62
+ mask: "####@@",
63
+ capitalize: "",
64
+ autocomplete: "",
65
+ required: !1,
66
+ verified: K.value,
67
+ loading: x(W).isValidating,
68
+ onBlur: V
69
+ }, null, 8, [
70
+ "modelValue",
71
+ "error-message",
72
+ "verified",
73
+ "loading"
74
+ ])]),
75
+ _: 1
76
+ }), _(O, {
77
+ span: "7",
78
+ md: "3"
79
+ }, {
80
+ default: o(() => [_(T, {
81
+ modelValue: x(F),
82
+ "onUpdate:modelValue": t[1] ||= (e) => w(F) ? F.value = e : null,
83
+ modelModifiers: { trim: !0 },
84
+ name: "houseNumber",
85
+ label: "Huisnummer",
86
+ placeholder: "bv. 1",
87
+ inputmode: "numeric",
88
+ "error-message": x(I),
89
+ autocomplete: "",
90
+ required: !1,
91
+ verified: K.value,
92
+ loading: x(W).isValidating,
93
+ onBlur: H
94
+ }, null, 8, [
95
+ "modelValue",
96
+ "error-message",
97
+ "verified",
98
+ "loading"
99
+ ]), _(E, {
100
+ modelValue: x(L),
101
+ "onUpdate:modelValue": t[2] ||= (e) => w(L) ? L.value = e : null,
102
+ name: "houseNumberAddition",
103
+ label: "Toevoeging",
104
+ placeholder: q.value,
105
+ options: a.additionOptions,
106
+ "error-message": x(R),
107
+ disabled: a.additionOptions.length === 0 || x(W).isValidating,
108
+ verified: K.value,
109
+ required: !1,
110
+ onSelect: U
111
+ }, null, 8, [
112
+ "modelValue",
113
+ "placeholder",
114
+ "options",
115
+ "error-message",
116
+ "disabled",
117
+ "verified"
118
+ ])]),
119
+ _: 1
120
+ })]),
121
+ _: 1
122
+ }), G.value ? (s(), l("div", A, [t[3] ||= r("i", { class: "fas fa-exclamation-circle vd-field__message-icon" }, null, -1), S(" " + h(G.value), 1)])) : d.value ? (s(), l("div", j, [t[4] ||= r("i", { class: "fas fa-info-circle vd-field__message-icon" }, null, -1), S(" " + h(d.value.street) + ", " + h(d.value.city), 1)])) : n("", !0)]));
123
+ }
124
+ }), N = (e) => ({
125
+ zipCode: e.ZipCode,
126
+ houseNumber: String(e.HouseNumber),
127
+ houseNumberAddition: e.HouseNumberAddition,
128
+ city: e.Place,
129
+ street: e.Street
130
+ }), P = /^\d{4}\s?[a-zA-Z]{2}$/, F = /^\d+$/, I = {
131
+ "needs-addition": "Een toevoeging is verplicht",
132
+ "not-found": "Postcode en huisnummer combinatie onbekend.",
133
+ error: "Adres ophalen is mislukt. Probeer het opnieuw."
134
+ };
135
+ function L(e) {
136
+ return e.replace(/\s/g, "").toUpperCase();
137
+ }
138
+ var R = "NO_ADDITION";
139
+ function z(e) {
140
+ return e === R ? "" : e.replace("-", "");
141
+ }
142
+ var B = (e) => e instanceof Error, V = (e) => {
143
+ if (B(e)) throw e;
144
+ return null;
145
+ }, H = (e, t, n) => D().dataValidationService.validateZipCode(e, t, n).then((e) => e).catch(V), U = (e, t) => D().homeService.getAddition({
146
+ zipcode: e,
147
+ houseNumber: t
148
+ }).then((e) => e ?? []).catch(V), W = async (e, t) => {
149
+ let [n, r] = await Promise.all([H(e, t), U(e, t)]);
150
+ return !n && !r?.length ? null : {
151
+ validWithoutAddition: !!n,
152
+ template: n,
153
+ additions: r ?? []
154
+ };
155
+ }, G = (e) => {
156
+ let t = e.additions.map((e) => ({
157
+ title: e,
158
+ value: z(e)
159
+ }));
160
+ return e.validWithoutAddition && t.length ? [{
161
+ title: "Geen toevoeging",
162
+ value: R
163
+ }, ...t] : t;
164
+ }, K = (e) => ({
165
+ zipCode: e?.zipCode ?? "",
166
+ houseNumber: e?.houseNumber ?? "",
167
+ houseNumberAddition: e ? e.houseNumberAddition || R : ""
168
+ }), q = (e) => {
169
+ let t = e?.path ?? "address", n = K(e?.initial), r = y(null), i = y([]), a = 0, o = null, s = async (e) => {
170
+ let t = L(e.zipCode), n = e.houseNumber.trim(), r = z(e.houseNumberAddition), i = `${t}:${n}`;
171
+ try {
172
+ let a = o?.key === i ? o : null;
173
+ if (!a) {
174
+ let e = await W(t, n);
175
+ if (!e) return {
176
+ status: "not-found",
177
+ options: [],
178
+ address: null
179
+ };
180
+ a = o = {
181
+ key: i,
182
+ verdict: e
183
+ };
184
+ }
185
+ let s = G(a.verdict);
186
+ if (a.verdict.additions.length && !e.houseNumberAddition) return {
187
+ status: "needs-addition",
188
+ options: s,
189
+ address: null
190
+ };
191
+ if (!a.verdict.template) {
192
+ let e = await H(t, n, r);
193
+ if (!e) return {
194
+ status: "not-found",
195
+ options: [],
196
+ address: null
197
+ };
198
+ a.verdict.template = e;
199
+ }
200
+ return {
201
+ status: "resolved",
202
+ options: s,
203
+ address: r ? {
204
+ ...a.verdict.template,
205
+ HouseNumberAddition: r
206
+ } : a.verdict.template
207
+ };
208
+ } catch (e) {
209
+ return console.error("Error on ITC address lookup", e), {
210
+ status: "error",
211
+ options: [],
212
+ address: null
213
+ };
214
+ }
215
+ }, c = async (e) => {
216
+ let t = ++a, n = await s(e), o = t !== a;
217
+ return o || (i.value = n.options, r.value = n.address ? N(n.address) : null), {
218
+ ...n,
219
+ stale: o
220
+ };
221
+ };
222
+ return {
223
+ path: t,
224
+ addressSchema: b({
225
+ zipCode: d().required("Vul je postcode in").matches(P, "Postcode is incorrect"),
226
+ houseNumber: d().required("Huisnummer is verplicht").matches(F, "Huisnummer is incorrect"),
227
+ houseNumberAddition: d().defined()
228
+ }).test("address-lookup", async (e, t) => {
229
+ let n = L(e.zipCode ?? ""), r = String(e.houseNumber ?? "").trim();
230
+ if (!P.test(n) || !F.test(r)) return !0;
231
+ let { status: i, stale: a } = await c(e);
232
+ return a || i === "resolved" ? !0 : i === "needs-addition" ? t.createError({
233
+ path: `${t.path}.houseNumberAddition`,
234
+ message: I[i]
235
+ }) : t.createError({ message: I[i] });
236
+ }),
237
+ draft: n,
238
+ resolvedAddress: r,
239
+ additionOptions: i
240
+ };
241
+ };
242
+ //#endregion
243
+ export { M as n, q as t };
@@ -0,0 +1,187 @@
1
+ import { $t as e, Ft as t, Gt as n, Jt as r, Kt as i, On as a, Sr as o, Un as s, Xn as c, Yt as l, _r as u, a as d, cr as f, fr as p, in as m, kn as h, li as g, qr as _, qt as v, ri as y, tn as b, ur as x } from "./useValidator-DdXn8soU.js";
2
+ import { t as S } from "./VdInput-PLH7DZsc.js";
3
+ import { t as C } from "./services-CG6XsnRT.js";
4
+ //#region src/enums/comparisonName.enum.ts
5
+ var w = /* @__PURE__ */ function(e) {
6
+ return e.Bike = "bike", e.Car = "car", e.Caravan = "caravan", e.CarBusiness = "car-business", e.BusinessLiability = "business-liability", e.Housing = "housing", e.LegalAssistance = "legal-assistance", e.Liability = "liability", e.Loan = "loan", e.Moped = "moped", e.Motor = "motor", e.Package = "package", e.Pet = "pet", e.Travel = "travel", e;
7
+ }({}), T = {
8
+ [w.Car]: {
9
+ apiTypes: ["Car", "Van"],
10
+ dutch: "auto",
11
+ icon: "fa-car"
12
+ },
13
+ [w.Motor]: {
14
+ apiTypes: ["Motor", "MP3Motor"],
15
+ dutch: "motor",
16
+ icon: "fa-motorcycle"
17
+ },
18
+ [w.Moped]: {
19
+ apiTypes: ["Moped"],
20
+ dutch: "brommer",
21
+ icon: "moped-solid"
22
+ },
23
+ [w.Caravan]: {
24
+ apiTypes: ["Caravan"],
25
+ dutch: "caravan",
26
+ icon: "fa-caravan-alt"
27
+ }
28
+ }, E = Object.fromEntries(Object.values(T).flatMap(({ apiTypes: e, icon: t }) => e.map((e) => [e.toLowerCase(), t]))), D = {
29
+ brommobiel: "fa-car-side",
30
+ "speed pedelec": "fa-bicycle"
31
+ }, O = (e) => !!e?.Brand && !!e.Model && !!e.ManufacturingYear, k = (e) => {
32
+ if (!e) return "";
33
+ let t = String(e.Model ?? "").toLowerCase().trim(), n = String(e.VehicleType ?? "").toLowerCase();
34
+ return D[t] ?? E[n] ?? "";
35
+ }, A = (e) => e ? `${e.Brand} ${e.Model} (${e.ManufacturingYear})` : "", j = [
36
+ "@@-##-@@",
37
+ "##-##-@@",
38
+ "##-@@-@@",
39
+ "@@-@@-##",
40
+ "##-@@-##",
41
+ "@@-##-##",
42
+ "##-@@@-#",
43
+ "@@-###-@",
44
+ "@-###-@@",
45
+ "#-@@@-##",
46
+ "@@@-##-@",
47
+ "@-##-@@@",
48
+ "#-@@-###",
49
+ "###-@@-#"
50
+ ];
51
+ //#endregion
52
+ //#region src/components/fields/licensePlate/licensePlate.util.ts
53
+ function M(e) {
54
+ return e.replace(/[\s\\-]/g, "");
55
+ }
56
+ var N = "*".repeat(6), P = j.map((e) => e.replace(/-/g, ""));
57
+ function F(e) {
58
+ let t = M(e).slice(0, 6);
59
+ if (t.length < 6) return N;
60
+ let n = [...t].map((e) => /[0-9]/.test(e) ? "#" : "@").join(""), r = P.indexOf(n);
61
+ return r === -1 ? N : j[r];
62
+ }
63
+ //#endregion
64
+ //#region src/components/fields/licensePlate/VdLicensePlate.vue?vue&type=script&setup=true&lang.ts
65
+ var I = {
66
+ key: 0,
67
+ class: "vd-input-license-plate__loading-information"
68
+ }, L = ["src"], R = /* @__PURE__ */ m({
69
+ inheritAttrs: !1,
70
+ __name: "VdLicensePlate",
71
+ props: /*@__PURE__*/ a({
72
+ name: {},
73
+ label: { default: "Kenteken" },
74
+ errorMessage: { default: null },
75
+ loading: {
76
+ type: Boolean,
77
+ default: !1
78
+ },
79
+ required: {
80
+ type: Boolean,
81
+ default: !1
82
+ }
83
+ }, {
84
+ modelValue: { default: "" },
85
+ modelModifiers: {},
86
+ vehicleData: { default: null },
87
+ vehicleDataModifiers: {}
88
+ }),
89
+ emits: /*@__PURE__*/ a(["input"], ["update:modelValue", "update:vehicleData"]),
90
+ setup(a, { emit: d }) {
91
+ let m = { mask: F }, _ = a, C = x(a, "modelValue"), w = x(a, "vehicleData"), T = d, E = f(), D = p(), j = n({
92
+ get: () => C.value ?? "",
93
+ set: (e) => {
94
+ C.value = e, T("input", e);
95
+ }
96
+ }), N = (e, t) => M(e).toUpperCase() === M(t).toUpperCase();
97
+ u(C, (e) => {
98
+ w.value && !N(e, w.value.LicensePlate) && (w.value = null);
99
+ });
100
+ let P = n(() => O(w.value) ? w.value : null), R = n(() => _.loading || !!P.value && !_.errorMessage), z = n(() => k(P.value)), B = n(() => A(P.value));
101
+ return (n, u) => (s(), v(S, h(y(E), {
102
+ modelValue: j.value,
103
+ "onUpdate:modelValue": u[0] ||= (e) => j.value = e,
104
+ capitalize: "",
105
+ autocomplete: "",
106
+ name: a.name,
107
+ label: a.label,
108
+ required: a.required,
109
+ "error-message": a.errorMessage || null,
110
+ loading: a.loading,
111
+ mask: m,
112
+ class: "vd-input-license-plate"
113
+ }), e({ _: 2 }, [
114
+ y(D).label ? {
115
+ name: "label",
116
+ fn: o(() => [c(n.$slots, "label")]),
117
+ key: "0"
118
+ } : void 0,
119
+ y(D).popover ? {
120
+ name: "popover",
121
+ fn: o(() => [c(n.$slots, "popover")]),
122
+ key: "1"
123
+ } : void 0,
124
+ R.value ? {
125
+ name: "information",
126
+ fn: o(() => [a.loading ? (s(), l("div", I, [...u[1] ||= [i("i", { class: "fas fa-circle-notch vd-input-license-plate__loading-icon" }, null, -1), b(" Voertuig gegevens ophalen... ", -1)]])) : P.value ? (s(), l(t, { key: 1 }, [z.value ? (s(), l("img", {
127
+ key: 0,
128
+ src: `https://d12bmfj3oyxu0t.cloudfront.net/vergelijkdirect/icons/${z.value}.svg`,
129
+ class: "vd-field__svg-message-icon",
130
+ alt: "vehicle-icon"
131
+ }, null, 8, L)) : r("", !0), b(" " + g(B.value), 1)], 64)) : r("", !0)]),
132
+ key: "2"
133
+ } : void 0
134
+ ]), 1040, [
135
+ "modelValue",
136
+ "name",
137
+ "label",
138
+ "required",
139
+ "error-message",
140
+ "loading"
141
+ ]));
142
+ }
143
+ }), z = /* @__PURE__ */ new Map(), B = (e, t) => `${t}:${e}`, V = {
144
+ "wrong-type": (e) => `Het ingevoerde kenteken is geen ${T[e].dutch}`,
145
+ unknown: () => "Voertuig onbekend - Voer ander kenteken in of neem contact op",
146
+ "not-found": () => "Kenteken onbekend",
147
+ error: () => "Kenteken is incorrect"
148
+ }, H = async (e, t) => {
149
+ try {
150
+ let n = await C().dataService.findVehicle(e, t);
151
+ if (Array.isArray(n) || !n || !Object.keys(n).length) return { status: "not-found" };
152
+ let r = n;
153
+ return r.VehicleType ? T[t].apiTypes.includes(r.VehicleType) ? {
154
+ status: "found",
155
+ data: r
156
+ } : { status: "wrong-type" } : { status: "unknown" };
157
+ } catch (e) {
158
+ return console.error("Error on ITC findVehicle", e), { status: "error" };
159
+ }
160
+ }, U = (e, t) => {
161
+ let n = B(e, t), r = z.get(n);
162
+ return r || (r = H(e, t), z.set(n, r), r.then(({ status: e }) => {
163
+ e === "error" && z.delete(n);
164
+ }, () => z.delete(n))), r;
165
+ }, W = (e, t = {}) => {
166
+ let n = _(t.initialData ?? null), r = 0;
167
+ t.initialData?.LicensePlate && z.set(B(M(t.initialData.LicensePlate), e), Promise.resolve({
168
+ status: "found",
169
+ data: t.initialData
170
+ }));
171
+ let i = async (t) => {
172
+ let i = M(t), a = ++r, o = await U(i, e);
173
+ return a === r && (n.value = o.status === "found" ? o.data : null), o;
174
+ };
175
+ return {
176
+ vehicleData: n,
177
+ licensePlateSchema: d().required("Dit veld is verplicht").test("license-plate-lookup", async (t, n) => {
178
+ if (!t) return !0;
179
+ let r = M(t);
180
+ if (r.length < 6) return n.createError({ message: "Kenteken is incorrect" });
181
+ let { status: a } = await i(r);
182
+ return a === "found" || n.createError({ message: V[a](e) });
183
+ })
184
+ };
185
+ };
186
+ //#endregion
187
+ export { R as n, w as r, W as t };