@leaflink/stash 53.4.3 → 53.4.5
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/Copy.js +1 -1
- package/dist/MoreActions.js +1 -1
- package/dist/Table.js +180 -100
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js +1 -1
- package/dist/TableHeaderRow.js +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-WMPMxzO-.js → Tooltip.vue_vue_type_script_setup_true_lang-CFpM7Ldj.js} +2 -2
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-WMPMxzO-.js.map → Tooltip.vue_vue_type_script_setup_true_lang-CFpM7Ldj.js.map} +1 -1
- package/dist/components.css +1 -1
- package/dist/index-DA70nQCT.js +424 -0
- package/dist/{index-B1Gkwuxd.js.map → index-DA70nQCT.js.map} +1 -1
- package/dist/useSortable.js +1 -1
- package/dist/useValidation.d.ts +22 -0
- package/dist/useValidation.js +208 -167
- package/dist/useValidation.js.map +1 -1
- package/package.json +1 -1
- package/dist/index-B1Gkwuxd.js +0 -277
package/dist/useSortable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import v from "@leaflink/snitch";
|
|
2
|
-
import { a as I } from "./index-
|
|
2
|
+
import { a as I } from "./index-DA70nQCT.js";
|
|
3
3
|
import { isRef as w, toValue as D, nextTick as A, computed as i, ref as y, watch as S, onMounted as $, onBeforeUnmount as G } from "vue";
|
|
4
4
|
function O({ list: n, from: s, to: e }) {
|
|
5
5
|
if (s === e) return;
|
package/dist/useValidation.d.ts
CHANGED
|
@@ -57,6 +57,18 @@ export declare function email(config?: Config): ValidationRule;
|
|
|
57
57
|
*/
|
|
58
58
|
export declare function isDefined(value: unknown): boolean;
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Minimal shape for a JSON:API error object when setting validation errors from an HTTP response.
|
|
62
|
+
* @see https://jsonapi.org/format/#error-objects
|
|
63
|
+
*/
|
|
64
|
+
export declare interface JsonApiValidationError {
|
|
65
|
+
detail?: string;
|
|
66
|
+
source?: {
|
|
67
|
+
pointer?: string;
|
|
68
|
+
};
|
|
69
|
+
title?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
60
72
|
export declare function maxLength(config: Config_2): ValidationRule;
|
|
61
73
|
|
|
62
74
|
export declare function maxValue(config: Config_3): ValidationRule;
|
|
@@ -181,6 +193,16 @@ export declare interface ValidationGroup<Values extends object> {
|
|
|
181
193
|
* Indicates if one or more fields have had their value changed at least one time
|
|
182
194
|
*/
|
|
183
195
|
someTouched: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Sets field error messages from a JSON:API error response.
|
|
198
|
+
* Parses each error's `source.pointer` (e.g. `/data/attributes/email`) to a field name and uses `detail` as the message.
|
|
199
|
+
* Only applies errors for field names that exist in the validation rules; unknown fields are ignored.
|
|
200
|
+
*/
|
|
201
|
+
setApiErrors: (errors: JsonApiValidationError[]) => void;
|
|
202
|
+
/**
|
|
203
|
+
* Clears API-set error messages. If `fieldName` is provided, clears only that field; otherwise clears all.
|
|
204
|
+
*/
|
|
205
|
+
clearApiErrors: (fieldName?: string) => void;
|
|
184
206
|
}
|
|
185
207
|
|
|
186
208
|
/**
|
package/dist/useValidation.js
CHANGED
|
@@ -1,249 +1,290 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { toValue as
|
|
4
|
-
import { DECIMAL_PRECISION as
|
|
5
|
-
import { t as
|
|
6
|
-
import { i as
|
|
7
|
-
import
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
1
|
+
import F from "lodash-es/debounce";
|
|
2
|
+
import A from "lodash-es/get";
|
|
3
|
+
import { toValue as c, computed as v, ref as T, watch as R, reactive as L, nextTick as I, readonly as w } from "vue";
|
|
4
|
+
import { DECIMAL_PRECISION as j, DEBOUNCE as q } from "./constants.js";
|
|
5
|
+
import { t as h } from "./locale.js";
|
|
6
|
+
import { i as f } from "./isDefined-DzVx0B6k.js";
|
|
7
|
+
import B from "lodash-es/round";
|
|
8
|
+
function D(t) {
|
|
9
|
+
return t && t.constructor && typeof t.constructor.isBuffer == "function" && t.constructor.isBuffer(t);
|
|
10
|
+
}
|
|
11
|
+
function M(t) {
|
|
12
|
+
return t;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
return
|
|
22
|
-
|
|
14
|
+
function C(t, e) {
|
|
15
|
+
e = e || {};
|
|
16
|
+
const r = e.delimiter || ".", i = e.maxDepth, a = e.transformKey || M, u = {};
|
|
17
|
+
function m(E, S, d) {
|
|
18
|
+
d = d || 1, Object.keys(E).forEach(function(x) {
|
|
19
|
+
const l = E[x], o = e.safe && Array.isArray(l), g = Object.prototype.toString.call(l), N = D(l), p = g === "[object Object]" || g === "[object Array]", n = S ? S + r + a(x) : a(x);
|
|
20
|
+
if (!o && !N && p && Object.keys(l).length && (!e.maxDepth || d < i))
|
|
21
|
+
return m(l, n, d + 1);
|
|
22
|
+
u[n] = l;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return m(t), u;
|
|
26
|
+
}
|
|
27
|
+
function k(t) {
|
|
28
|
+
const e = t.replace(/^\//, ""), r = "data/attributes/";
|
|
29
|
+
if (e.startsWith(r))
|
|
30
|
+
return e.slice(r.length).split("/").filter(Boolean).join(".");
|
|
31
|
+
const i = e.split("/").filter(Boolean);
|
|
32
|
+
return i[i.length - 1] || t;
|
|
26
33
|
}
|
|
27
|
-
function
|
|
34
|
+
function U(t) {
|
|
35
|
+
var r;
|
|
36
|
+
const e = {};
|
|
37
|
+
for (const i of t) {
|
|
38
|
+
const a = (r = i.source) == null ? void 0 : r.pointer;
|
|
39
|
+
if (!a)
|
|
40
|
+
continue;
|
|
41
|
+
const u = i.detail || i.title || "";
|
|
42
|
+
if (!u)
|
|
43
|
+
continue;
|
|
44
|
+
const m = k(a);
|
|
45
|
+
e[m] = u;
|
|
46
|
+
}
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
function H(t = {}) {
|
|
28
50
|
return {
|
|
29
51
|
name: "email",
|
|
30
|
-
validator(
|
|
31
|
-
return !
|
|
52
|
+
validator(e) {
|
|
53
|
+
return !f(e) || typeof e == "string" && /^\S+@\S+\.\S+$/.test(e);
|
|
32
54
|
},
|
|
33
|
-
message:
|
|
55
|
+
message: t.message || h("ll.validation.email")
|
|
34
56
|
};
|
|
35
57
|
}
|
|
36
|
-
function
|
|
58
|
+
function Q(t) {
|
|
37
59
|
return {
|
|
38
60
|
name: "maxLength",
|
|
39
|
-
validator(
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
61
|
+
validator(e) {
|
|
62
|
+
const r = c(t.max), i = c(e);
|
|
63
|
+
if (!f(i))
|
|
42
64
|
return !0;
|
|
43
|
-
let
|
|
44
|
-
return
|
|
65
|
+
let a = String(i);
|
|
66
|
+
return t.trim && (a = a.trim()), a.length <= r;
|
|
45
67
|
},
|
|
46
|
-
message:
|
|
68
|
+
message: t.message || (() => h("ll.validation.maxLength", { max: String(c(t.max)) }))
|
|
47
69
|
};
|
|
48
70
|
}
|
|
49
|
-
function
|
|
71
|
+
function X(t) {
|
|
50
72
|
return {
|
|
51
73
|
name: "maxValue",
|
|
52
|
-
validator(
|
|
53
|
-
const
|
|
54
|
-
return !
|
|
74
|
+
validator(e) {
|
|
75
|
+
const r = c(t.max);
|
|
76
|
+
return !f(e) || Number(e) <= r;
|
|
55
77
|
},
|
|
56
|
-
message:
|
|
78
|
+
message: t.message || (() => h("ll.validation.maxValue", { max: String(c(t.max)) }))
|
|
57
79
|
};
|
|
58
80
|
}
|
|
59
|
-
function
|
|
81
|
+
function Z(t) {
|
|
60
82
|
return {
|
|
61
83
|
name: "minLength",
|
|
62
|
-
validator(
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
84
|
+
validator(e) {
|
|
85
|
+
const r = c(t.min), i = c(e);
|
|
86
|
+
if (!f(i))
|
|
65
87
|
return !0;
|
|
66
|
-
let
|
|
67
|
-
return
|
|
88
|
+
let a = String(i);
|
|
89
|
+
return t.trim && (a = a.trim()), a.length >= r;
|
|
68
90
|
},
|
|
69
|
-
message:
|
|
91
|
+
message: t.message || (() => h("ll.validation.minLength", { min: String(c(t.min)) }))
|
|
70
92
|
};
|
|
71
93
|
}
|
|
72
|
-
function
|
|
94
|
+
function ee(t) {
|
|
73
95
|
return {
|
|
74
96
|
name: "minValue",
|
|
75
|
-
validator(
|
|
76
|
-
const
|
|
77
|
-
return !
|
|
97
|
+
validator(e) {
|
|
98
|
+
const r = c(t.min);
|
|
99
|
+
return !f(e) || Number(e) >= r;
|
|
78
100
|
},
|
|
79
|
-
message:
|
|
101
|
+
message: t.message || (() => h("ll.validation.minValue", { min: String(c(t.min)) }))
|
|
80
102
|
};
|
|
81
103
|
}
|
|
82
|
-
function
|
|
104
|
+
function te(t) {
|
|
83
105
|
return {
|
|
84
106
|
name: "pattern",
|
|
85
|
-
validator(
|
|
86
|
-
const
|
|
87
|
-
return !
|
|
107
|
+
validator(e) {
|
|
108
|
+
const r = c(e);
|
|
109
|
+
return !f(r) || t.regex.test(String(r));
|
|
88
110
|
},
|
|
89
111
|
message: () => {
|
|
90
|
-
if (typeof
|
|
112
|
+
if (typeof t.message != "string" || !t.message.trim())
|
|
91
113
|
throw new Error(
|
|
92
114
|
'The "pattern" ruleFactory requires a custom message informing the user of the required pattern.'
|
|
93
115
|
);
|
|
94
|
-
return
|
|
116
|
+
return t.message;
|
|
95
117
|
}
|
|
96
118
|
};
|
|
97
119
|
}
|
|
98
|
-
function
|
|
120
|
+
function re(t = {}) {
|
|
99
121
|
return {
|
|
100
122
|
name: "positiveNumber",
|
|
101
|
-
validator(
|
|
102
|
-
return !
|
|
123
|
+
validator(e) {
|
|
124
|
+
return !f(e) || Number(e) > 0;
|
|
103
125
|
},
|
|
104
|
-
message:
|
|
126
|
+
message: t.message || h("ll.validation.positiveNumber")
|
|
105
127
|
};
|
|
106
128
|
}
|
|
107
|
-
function
|
|
129
|
+
function ne(t = {}) {
|
|
108
130
|
return {
|
|
109
131
|
name: "price",
|
|
110
|
-
validator(
|
|
111
|
-
const
|
|
112
|
-
return !
|
|
132
|
+
validator(e) {
|
|
133
|
+
const r = Number(e);
|
|
134
|
+
return !f(e) || r !== 1 / 0 && r >= 0 && r === B(r, j.CURRENCY);
|
|
113
135
|
},
|
|
114
|
-
message:
|
|
136
|
+
message: t.message || h("ll.validation.price")
|
|
115
137
|
};
|
|
116
138
|
}
|
|
117
|
-
function
|
|
139
|
+
function se(t = {}) {
|
|
118
140
|
return {
|
|
119
141
|
name: "required",
|
|
120
|
-
validator(
|
|
121
|
-
return
|
|
142
|
+
validator(e) {
|
|
143
|
+
return f(typeof e == "string" ? e.trim() : e);
|
|
122
144
|
},
|
|
123
|
-
message:
|
|
145
|
+
message: t.message || h("ll.validation.required")
|
|
124
146
|
};
|
|
125
147
|
}
|
|
126
|
-
function
|
|
148
|
+
function ae(t = {}) {
|
|
127
149
|
return {
|
|
128
150
|
name: "wholeNumber",
|
|
129
|
-
validator(
|
|
130
|
-
return !
|
|
151
|
+
validator(e) {
|
|
152
|
+
return !f(e) || Number.isInteger(Number(e)) && Number(e) >= 0;
|
|
131
153
|
},
|
|
132
|
-
message:
|
|
154
|
+
message: t.message || h("ll.validation.wholeNumber")
|
|
133
155
|
};
|
|
134
156
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
157
|
+
const _ = "api";
|
|
158
|
+
function ie({
|
|
159
|
+
rules: t,
|
|
160
|
+
values: e
|
|
138
161
|
}) {
|
|
139
|
-
const
|
|
140
|
-
(n,
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
},
|
|
144
|
-
|
|
162
|
+
const r = v(() => Object.keys(C(t, { safe: !0 }))), i = T({}), a = r.value.reduce(
|
|
163
|
+
(n, s) => {
|
|
164
|
+
const V = T(A(c(e), s)), y = (O) => {
|
|
165
|
+
V.value = A(c(e), O);
|
|
166
|
+
}, b = F(() => {
|
|
167
|
+
y(s);
|
|
145
168
|
}, q.FAST);
|
|
146
|
-
return
|
|
147
|
-
() =>
|
|
169
|
+
return R(
|
|
170
|
+
() => A(c(e), s),
|
|
148
171
|
() => {
|
|
149
|
-
|
|
172
|
+
b();
|
|
150
173
|
}
|
|
151
|
-
), n[
|
|
152
|
-
fieldName:
|
|
153
|
-
fieldValue:
|
|
174
|
+
), n[s] = K({
|
|
175
|
+
fieldName: s,
|
|
176
|
+
fieldValue: V,
|
|
154
177
|
flush: () => {
|
|
155
|
-
|
|
178
|
+
b.cancel(), y(s);
|
|
156
179
|
},
|
|
157
|
-
|
|
180
|
+
getApiError: () => i.value[s] || "",
|
|
181
|
+
rules: A(t, s)
|
|
158
182
|
}), n;
|
|
159
183
|
},
|
|
160
184
|
{}
|
|
161
|
-
),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
), u = v(() => Object.values(a)), m = v(() => u.value.some((n) => n.errors.length > 0)), E = v(() => u.value.some((n) => n.isTouched)), S = v(() => u.value.filter((n) => n.isDirty)), d = async function({ preventScroll: n } = {}) {
|
|
186
|
+
if (u.value.forEach((s) => {
|
|
187
|
+
s.setTouched(!1), s.setTouched(!0);
|
|
188
|
+
}), await I(), m.value && !n) {
|
|
189
|
+
const s = Object.entries(a).find(([, b]) => b.errorMessage), V = (s == null ? void 0 : s[0]) || "", y = document == null ? void 0 : document.querySelector(`[name=${V}]`);
|
|
190
|
+
y && y.scrollIntoView({ behavior: "smooth" });
|
|
191
|
+
}
|
|
192
|
+
return !m.value;
|
|
193
|
+
}, x = function(n) {
|
|
194
|
+
var s;
|
|
195
|
+
return ((s = a[n]) == null ? void 0 : s.errorMessage) || "";
|
|
196
|
+
}, l = function(n) {
|
|
197
|
+
if (!a[n])
|
|
198
|
+
throw new Error(`In touch: fieldName "${n}" does not exist in the validation fields.`);
|
|
199
|
+
a[n].setTouched();
|
|
200
|
+
}, o = async function() {
|
|
201
|
+
await I(), u.value.forEach((n) => {
|
|
202
|
+
n.setTouched(!1);
|
|
203
|
+
});
|
|
204
|
+
}, g = function(n) {
|
|
205
|
+
u.value.forEach((s) => {
|
|
206
|
+
s.setInitialValue(n[s.name]);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
function N(n) {
|
|
210
|
+
const s = U(n), V = r.value, y = {};
|
|
211
|
+
for (const b of V)
|
|
212
|
+
s[b] && (y[b] = s[b]);
|
|
213
|
+
i.value = y;
|
|
214
|
+
}
|
|
215
|
+
function p(n) {
|
|
216
|
+
if (n) {
|
|
217
|
+
const s = { ...i.value };
|
|
218
|
+
delete s[n], i.value = s;
|
|
219
|
+
} else
|
|
220
|
+
i.value = {};
|
|
221
|
+
}
|
|
222
|
+
return L({
|
|
223
|
+
validate: d,
|
|
224
|
+
getError: x,
|
|
225
|
+
touch: l,
|
|
226
|
+
setAllUntouched: o,
|
|
227
|
+
setInitialValues: g,
|
|
228
|
+
setApiErrors: N,
|
|
229
|
+
clearApiErrors: p,
|
|
230
|
+
fields: a,
|
|
231
|
+
dirtyFields: S,
|
|
193
232
|
hasErrors: m,
|
|
194
|
-
someTouched:
|
|
233
|
+
someTouched: E
|
|
195
234
|
});
|
|
196
235
|
}
|
|
197
|
-
function
|
|
198
|
-
fieldName:
|
|
199
|
-
fieldValue:
|
|
200
|
-
rules:
|
|
201
|
-
flush:
|
|
236
|
+
function K({
|
|
237
|
+
fieldName: t,
|
|
238
|
+
fieldValue: e,
|
|
239
|
+
rules: r,
|
|
240
|
+
flush: i,
|
|
241
|
+
getApiError: a
|
|
202
242
|
}) {
|
|
203
|
-
const
|
|
204
|
-
fieldName:
|
|
205
|
-
ruleName:
|
|
206
|
-
isValid:
|
|
207
|
-
message: typeof
|
|
208
|
-
})) : []),
|
|
209
|
-
()
|
|
210
|
-
ruleName:
|
|
211
|
-
message:
|
|
212
|
-
}))
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
243
|
+
const u = T(e.value), m = T(!1), E = v(() => (e.value ?? "") !== (u.value ?? "")), S = v(() => m.value ? r.map((o) => ({
|
|
244
|
+
fieldName: t,
|
|
245
|
+
ruleName: o.name,
|
|
246
|
+
isValid: o.validator(e.value),
|
|
247
|
+
message: typeof o.message == "function" ? o.message(e.value) : o.message
|
|
248
|
+
})) : []), d = v(() => {
|
|
249
|
+
const o = a(), g = o !== "" ? [{ ruleName: _, message: o }] : [], N = S.value.filter((p) => !p.isValid).map((p) => ({
|
|
250
|
+
ruleName: p.ruleName,
|
|
251
|
+
message: p.message
|
|
252
|
+
}));
|
|
253
|
+
return [...g, ...N];
|
|
254
|
+
});
|
|
255
|
+
function x(o = !0) {
|
|
256
|
+
i(), m.value = o;
|
|
216
257
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
258
|
+
function l(o) {
|
|
259
|
+
u.value = o;
|
|
219
260
|
}
|
|
220
|
-
return
|
|
221
|
-
name:
|
|
222
|
-
currentValue:
|
|
223
|
-
initialValue:
|
|
224
|
-
isTouched:
|
|
225
|
-
isDirty: E
|
|
226
|
-
errorMessage:
|
|
227
|
-
var
|
|
228
|
-
return ((
|
|
261
|
+
return L({
|
|
262
|
+
name: t,
|
|
263
|
+
currentValue: w(e),
|
|
264
|
+
initialValue: w(u),
|
|
265
|
+
isTouched: w(m),
|
|
266
|
+
isDirty: w(E),
|
|
267
|
+
errorMessage: v(() => {
|
|
268
|
+
var o, g;
|
|
269
|
+
return ((g = (o = d.value) == null ? void 0 : o[0]) == null ? void 0 : g.message) || "";
|
|
229
270
|
}),
|
|
230
|
-
errors:
|
|
231
|
-
setInitialValue:
|
|
232
|
-
setTouched:
|
|
271
|
+
errors: d,
|
|
272
|
+
setInitialValue: l,
|
|
273
|
+
setTouched: x
|
|
233
274
|
});
|
|
234
275
|
}
|
|
235
276
|
export {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
277
|
+
ie as default,
|
|
278
|
+
H as email,
|
|
279
|
+
f as isDefined,
|
|
280
|
+
Q as maxLength,
|
|
281
|
+
X as maxValue,
|
|
282
|
+
Z as minLength,
|
|
283
|
+
ee as minValue,
|
|
284
|
+
te as pattern,
|
|
285
|
+
re as positiveNumber,
|
|
286
|
+
ne as price,
|
|
287
|
+
se as required,
|
|
288
|
+
ae as wholeNumber
|
|
248
289
|
};
|
|
249
290
|
//# sourceMappingURL=useValidation.js.map
|