@ciwergrp/nuxid 1.0.2-release
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/README.md +119 -0
- package/bin/kiban.mjs +41 -0
- package/console/request.mjs +337 -0
- package/dist/module.d.mts +188 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +439 -0
- package/dist/runtime/form.d.ts +21 -0
- package/dist/runtime/form.js +161 -0
- package/dist/runtime/helper/array/collapse.d.ts +1 -0
- package/dist/runtime/helper/array/collapse.js +9 -0
- package/dist/runtime/helper/array/crossJoin.d.ts +1 -0
- package/dist/runtime/helper/array/crossJoin.js +17 -0
- package/dist/runtime/helper/array/every.d.ts +1 -0
- package/dist/runtime/helper/array/every.js +3 -0
- package/dist/runtime/helper/array/first.d.ts +1 -0
- package/dist/runtime/helper/array/first.js +11 -0
- package/dist/runtime/helper/array/flatten.d.ts +1 -0
- package/dist/runtime/helper/array/flatten.js +14 -0
- package/dist/runtime/helper/array/index.d.ts +46 -0
- package/dist/runtime/helper/array/index.js +69 -0
- package/dist/runtime/helper/array/join.d.ts +1 -0
- package/dist/runtime/helper/array/join.js +11 -0
- package/dist/runtime/helper/array/last.d.ts +1 -0
- package/dist/runtime/helper/array/last.js +11 -0
- package/dist/runtime/helper/array/map.d.ts +1 -0
- package/dist/runtime/helper/array/map.js +3 -0
- package/dist/runtime/helper/array/mapSpread.d.ts +1 -0
- package/dist/runtime/helper/array/mapSpread.js +3 -0
- package/dist/runtime/helper/array/partition.d.ts +1 -0
- package/dist/runtime/helper/array/partition.js +12 -0
- package/dist/runtime/helper/array/random.d.ts +1 -0
- package/dist/runtime/helper/array/random.js +19 -0
- package/dist/runtime/helper/array/reject.d.ts +1 -0
- package/dist/runtime/helper/array/reject.js +3 -0
- package/dist/runtime/helper/array/shuffle.d.ts +1 -0
- package/dist/runtime/helper/array/shuffle.js +8 -0
- package/dist/runtime/helper/array/sole.d.ts +1 -0
- package/dist/runtime/helper/array/sole.js +7 -0
- package/dist/runtime/helper/array/some.d.ts +1 -0
- package/dist/runtime/helper/array/some.js +3 -0
- package/dist/runtime/helper/array/sort.d.ts +1 -0
- package/dist/runtime/helper/array/sort.js +4 -0
- package/dist/runtime/helper/array/sortDesc.d.ts +1 -0
- package/dist/runtime/helper/array/sortDesc.js +9 -0
- package/dist/runtime/helper/array/take.d.ts +1 -0
- package/dist/runtime/helper/array/take.js +9 -0
- package/dist/runtime/helper/array/where.d.ts +1 -0
- package/dist/runtime/helper/array/where.js +3 -0
- package/dist/runtime/helper/array/whereNotNull.d.ts +1 -0
- package/dist/runtime/helper/array/whereNotNull.js +3 -0
- package/dist/runtime/helper/array/wrap.d.ts +1 -0
- package/dist/runtime/helper/array/wrap.js +6 -0
- package/dist/runtime/helper/index.d.ts +4 -0
- package/dist/runtime/helper/index.js +4 -0
- package/dist/runtime/helper/number/clamp.d.ts +1 -0
- package/dist/runtime/helper/number/clamp.js +3 -0
- package/dist/runtime/helper/number/currency.d.ts +1 -0
- package/dist/runtime/helper/number/currency.js +14 -0
- package/dist/runtime/helper/number/fileSize.d.ts +1 -0
- package/dist/runtime/helper/number/fileSize.js +12 -0
- package/dist/runtime/helper/number/format.d.ts +1 -0
- package/dist/runtime/helper/number/format.js +12 -0
- package/dist/runtime/helper/number/humanize.d.ts +5 -0
- package/dist/runtime/helper/number/humanize.js +39 -0
- package/dist/runtime/helper/number/index.d.ts +37 -0
- package/dist/runtime/helper/number/index.js +60 -0
- package/dist/runtime/helper/number/intl.d.ts +5 -0
- package/dist/runtime/helper/number/intl.js +32 -0
- package/dist/runtime/helper/number/ordinal.d.ts +1 -0
- package/dist/runtime/helper/number/ordinal.js +26 -0
- package/dist/runtime/helper/number/pairs.d.ts +1 -0
- package/dist/runtime/helper/number/pairs.js +11 -0
- package/dist/runtime/helper/number/parse.d.ts +4 -0
- package/dist/runtime/helper/number/parse.js +19 -0
- package/dist/runtime/helper/number/percentage.d.ts +1 -0
- package/dist/runtime/helper/number/percentage.js +14 -0
- package/dist/runtime/helper/number/spell.d.ts +2 -0
- package/dist/runtime/helper/number/spell.js +145 -0
- package/dist/runtime/helper/number/state.d.ts +1 -0
- package/dist/runtime/helper/number/state.js +8 -0
- package/dist/runtime/helper/number/trim.d.ts +1 -0
- package/dist/runtime/helper/number/trim.js +3 -0
- package/dist/runtime/helper/object/add.d.ts +2 -0
- package/dist/runtime/helper/object/add.js +8 -0
- package/dist/runtime/helper/object/dot.d.ts +1 -0
- package/dist/runtime/helper/object/dot.js +19 -0
- package/dist/runtime/helper/object/except.d.ts +2 -0
- package/dist/runtime/helper/object/except.js +10 -0
- package/dist/runtime/helper/object/forget.d.ts +2 -0
- package/dist/runtime/helper/object/forget.js +24 -0
- package/dist/runtime/helper/object/get.d.ts +2 -0
- package/dist/runtime/helper/object/get.js +15 -0
- package/dist/runtime/helper/object/has.d.ts +2 -0
- package/dist/runtime/helper/object/has.js +5 -0
- package/dist/runtime/helper/object/index.d.ts +22 -0
- package/dist/runtime/helper/object/index.js +33 -0
- package/dist/runtime/helper/object/only.d.ts +2 -0
- package/dist/runtime/helper/object/only.js +12 -0
- package/dist/runtime/helper/object/set.d.ts +2 -0
- package/dist/runtime/helper/object/set.js +23 -0
- package/dist/runtime/helper/object/undot.d.ts +1 -0
- package/dist/runtime/helper/object/undot.js +8 -0
- package/dist/runtime/helper/object/utils.d.ts +3 -0
- package/dist/runtime/helper/object/utils.js +10 -0
- package/dist/runtime/helper/state.d.ts +6 -0
- package/dist/runtime/helper/state.js +50 -0
- package/dist/runtime/helper/string/basic.d.ts +7 -0
- package/dist/runtime/helper/string/basic.js +42 -0
- package/dist/runtime/helper/string/bounds.d.ts +6 -0
- package/dist/runtime/helper/string/bounds.js +42 -0
- package/dist/runtime/helper/string/case.d.ts +9 -0
- package/dist/runtime/helper/string/case.js +50 -0
- package/dist/runtime/helper/string/index.d.ts +57 -0
- package/dist/runtime/helper/string/index.js +100 -0
- package/dist/runtime/helper/string/locale.d.ts +1 -0
- package/dist/runtime/helper/string/locale.js +1 -0
- package/dist/runtime/helper/string/match.d.ts +4 -0
- package/dist/runtime/helper/string/match.js +15 -0
- package/dist/runtime/helper/string/pad.d.ts +3 -0
- package/dist/runtime/helper/string/pad.js +12 -0
- package/dist/runtime/helper/string/plural.d.ts +3 -0
- package/dist/runtime/helper/string/plural.js +16 -0
- package/dist/runtime/helper/string/replace.d.ts +4 -0
- package/dist/runtime/helper/string/replace.js +25 -0
- package/dist/runtime/helper/string/slug.d.ts +1 -0
- package/dist/runtime/helper/string/slug.js +8 -0
- package/dist/runtime/helper/string/transliterate.d.ts +2 -0
- package/dist/runtime/helper/string/transliterate.js +8 -0
- package/dist/runtime/helper/string/words.d.ts +2 -0
- package/dist/runtime/helper/string/words.js +13 -0
- package/dist/runtime/lodash.d.ts +1 -0
- package/dist/runtime/lodash.js +1 -0
- package/dist/runtime/pinia/composables.d.ts +2 -0
- package/dist/runtime/pinia/composables.js +3 -0
- package/dist/runtime/pinia/payload-plugin.d.ts +5 -0
- package/dist/runtime/pinia/payload-plugin.js +15 -0
- package/dist/runtime/pinia/plugin.d.ts +6 -0
- package/dist/runtime/pinia/plugin.js +22 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.js +4 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/validator.d.ts +13 -0
- package/dist/runtime/validator.js +445 -0
- package/dist/types.d.mts +11 -0
- package/package.json +90 -0
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { addImports, addPlugin, addImportsDir, defineNuxtModule, createResolver, installModule } from '@nuxt/kit';
|
|
2
|
+
import * as lodash from 'lodash-es';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export * from '../dist/runtime/form.js';
|
|
5
|
+
export { default as useForm } from '../dist/runtime/form.js';
|
|
6
|
+
export * from '../dist/runtime/validator.js';
|
|
7
|
+
export * from '../dist/runtime/helper/index.js';
|
|
8
|
+
|
|
9
|
+
const lodashExcludes = [
|
|
10
|
+
"wrapperValue",
|
|
11
|
+
"wrapperToIterator",
|
|
12
|
+
"wrapperReverse",
|
|
13
|
+
"wrapperPlant",
|
|
14
|
+
"wrapperNext",
|
|
15
|
+
"wrapperLodash",
|
|
16
|
+
"wrapperCommit",
|
|
17
|
+
"wrapperChain",
|
|
18
|
+
"wrapperAt",
|
|
19
|
+
"templateSettings",
|
|
20
|
+
"toIterator",
|
|
21
|
+
"VERSION",
|
|
22
|
+
"lodash",
|
|
23
|
+
"value",
|
|
24
|
+
"valueOf",
|
|
25
|
+
"toJSON",
|
|
26
|
+
"thru",
|
|
27
|
+
"plant",
|
|
28
|
+
"next",
|
|
29
|
+
"default",
|
|
30
|
+
"commit",
|
|
31
|
+
"head"
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const lodashDefaults = {
|
|
35
|
+
enabled: false,
|
|
36
|
+
// prefix: false,
|
|
37
|
+
prefix: "ki",
|
|
38
|
+
prefixSkip: "is",
|
|
39
|
+
upperAfterPrefix: true,
|
|
40
|
+
exclude: [],
|
|
41
|
+
alias: []
|
|
42
|
+
};
|
|
43
|
+
const toArray = (value) => value ? Array.isArray(value) ? value : [value] : [];
|
|
44
|
+
function resolveLodashOptions(input) {
|
|
45
|
+
if (input === false) {
|
|
46
|
+
return { ...lodashDefaults, enabled: false };
|
|
47
|
+
}
|
|
48
|
+
const overrides = typeof input === "boolean" || input === void 0 ? {} : input;
|
|
49
|
+
return {
|
|
50
|
+
...lodashDefaults,
|
|
51
|
+
...overrides,
|
|
52
|
+
enabled: overrides?.enabled ?? true,
|
|
53
|
+
exclude: [
|
|
54
|
+
...lodashExcludes,
|
|
55
|
+
...lodashDefaults.exclude,
|
|
56
|
+
...overrides?.exclude ?? []
|
|
57
|
+
],
|
|
58
|
+
alias: overrides?.alias ?? lodashDefaults.alias
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function registerLodashFeature(options, resolve) {
|
|
62
|
+
if (!options.enabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const aliasMap = new Map(options.alias);
|
|
66
|
+
const excludes = new Set(options.exclude);
|
|
67
|
+
const skipPrefixes = toArray(options.prefixSkip);
|
|
68
|
+
for (const name of Object.keys(lodash)) {
|
|
69
|
+
if (excludes.has(name)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const alias = aliasMap.get(name) ?? name;
|
|
73
|
+
const shouldPrefix = options.prefix && !skipPrefixes.some((key) => alias.startsWith(key));
|
|
74
|
+
const as = shouldPrefix ? `${options.prefix}${options.upperAfterPrefix ? lodash.upperFirst(alias) : alias}` : alias;
|
|
75
|
+
addImports({ name, as, from: resolve("./runtime/lodash") });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const validatorDefaults = {
|
|
80
|
+
enabled: false
|
|
81
|
+
};
|
|
82
|
+
function resolveValidatorOptions(input) {
|
|
83
|
+
if (input === false) {
|
|
84
|
+
return { ...validatorDefaults, enabled: false };
|
|
85
|
+
}
|
|
86
|
+
const overrides = typeof input === "boolean" || input === void 0 ? {} : input;
|
|
87
|
+
return {
|
|
88
|
+
...validatorDefaults,
|
|
89
|
+
...overrides,
|
|
90
|
+
enabled: overrides?.enabled ?? true
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function registerValidatorFeature(options, { from }) {
|
|
94
|
+
if (!options.enabled) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
addImports({ name: "createValidationRules", as: "createValidationRules", from });
|
|
98
|
+
addImports({ name: "ValidationRule", as: "ValidationRule", from, type: true });
|
|
99
|
+
addImports({ name: "ValidationOptions", as: "ValidationOptions", from, type: true });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const iconDefaults = {
|
|
103
|
+
enabled: false,
|
|
104
|
+
config: {
|
|
105
|
+
componentName: "KIcon",
|
|
106
|
+
size: "1.25em",
|
|
107
|
+
class: "align-middle inline-block text-current",
|
|
108
|
+
mode: "svg"
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
function resolveIconOptions(input) {
|
|
112
|
+
if (input === false) {
|
|
113
|
+
return { ...iconDefaults, enabled: false };
|
|
114
|
+
}
|
|
115
|
+
if (input === void 0) {
|
|
116
|
+
return iconDefaults;
|
|
117
|
+
}
|
|
118
|
+
const overrides = typeof input === "boolean" ? {} : input;
|
|
119
|
+
return {
|
|
120
|
+
...iconDefaults,
|
|
121
|
+
...overrides,
|
|
122
|
+
enabled: overrides.enabled ?? true,
|
|
123
|
+
config: overrides.config ?? iconDefaults.config
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const formDefaults = {
|
|
128
|
+
enabled: false
|
|
129
|
+
};
|
|
130
|
+
function resolveFormOptions(input) {
|
|
131
|
+
if (input === false) {
|
|
132
|
+
return { ...formDefaults, enabled: false };
|
|
133
|
+
}
|
|
134
|
+
const overrides = typeof input === "boolean" || input === void 0 ? {} : input;
|
|
135
|
+
return {
|
|
136
|
+
...formDefaults,
|
|
137
|
+
...overrides,
|
|
138
|
+
enabled: overrides?.enabled ?? true
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function registerFormFeature(options, { from }) {
|
|
142
|
+
if (!options.enabled) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
addImports({ name: "default", as: "useForm", from });
|
|
146
|
+
addImports({ name: "UseForm", as: "UseForm", from, type: true });
|
|
147
|
+
addImports({ name: "KibanFormOptions", as: "KibanFormOptions", from, type: true });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const elementPlusDefaults = {
|
|
151
|
+
enabled: false,
|
|
152
|
+
config: {}
|
|
153
|
+
};
|
|
154
|
+
function resolveElementPlusOptions(input) {
|
|
155
|
+
if (input === false) {
|
|
156
|
+
return { ...elementPlusDefaults, enabled: false };
|
|
157
|
+
}
|
|
158
|
+
if (input === void 0) {
|
|
159
|
+
return elementPlusDefaults;
|
|
160
|
+
}
|
|
161
|
+
const overrides = typeof input === "boolean" ? {} : input;
|
|
162
|
+
return {
|
|
163
|
+
...elementPlusDefaults,
|
|
164
|
+
...overrides,
|
|
165
|
+
enabled: overrides.enabled ?? true,
|
|
166
|
+
config: overrides.config ?? elementPlusDefaults.config
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const helperDefaults = {
|
|
171
|
+
enabled: false,
|
|
172
|
+
config: {
|
|
173
|
+
style: "factory",
|
|
174
|
+
localeSource: "cookie",
|
|
175
|
+
localeKey: "lang",
|
|
176
|
+
localeFallback: "en",
|
|
177
|
+
defaultCurrency: "USD"
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function resolveHelperOptions(input) {
|
|
181
|
+
if (input === false) {
|
|
182
|
+
return helperDefaults;
|
|
183
|
+
}
|
|
184
|
+
const overrides = typeof input === "boolean" || input === void 0 ? {} : input;
|
|
185
|
+
const config = overrides.config ?? {};
|
|
186
|
+
return {
|
|
187
|
+
enabled: overrides?.enabled ?? true,
|
|
188
|
+
config: {
|
|
189
|
+
style: config.style ?? helperDefaults.config.style,
|
|
190
|
+
localeSource: config.localeSource ?? helperDefaults.config.localeSource,
|
|
191
|
+
localeKey: config.localeKey ?? helperDefaults.config.localeKey,
|
|
192
|
+
localeFallback: config.localeFallback ?? helperDefaults.config.localeFallback,
|
|
193
|
+
defaultCurrency: config.defaultCurrency ?? helperDefaults.config.defaultCurrency
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function registerHelperFeature(options, { from }) {
|
|
198
|
+
if (!options.enabled) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const style = options.config.style;
|
|
202
|
+
if (style === "factory") {
|
|
203
|
+
addImports({ name: "array", as: "array", from });
|
|
204
|
+
addImports({ name: "object", as: "object", from });
|
|
205
|
+
addImports({ name: "number", as: "number", from });
|
|
206
|
+
addImports({ name: "string", as: "string", from });
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const numberExports = [
|
|
210
|
+
"abbreviate",
|
|
211
|
+
"forHumans",
|
|
212
|
+
"clamp",
|
|
213
|
+
"currency",
|
|
214
|
+
"defaultCurrency",
|
|
215
|
+
"defaultLocale",
|
|
216
|
+
"fileSize",
|
|
217
|
+
"format",
|
|
218
|
+
"ordinal",
|
|
219
|
+
"pairs",
|
|
220
|
+
"parse",
|
|
221
|
+
"parseFloatNumber",
|
|
222
|
+
"parseIntNumber",
|
|
223
|
+
"percentage",
|
|
224
|
+
"spell",
|
|
225
|
+
"spellOrdinal",
|
|
226
|
+
"trim",
|
|
227
|
+
"useLocale",
|
|
228
|
+
"withLocale",
|
|
229
|
+
"useCurrency",
|
|
230
|
+
"withCurrency"
|
|
231
|
+
];
|
|
232
|
+
const arrayExports = [
|
|
233
|
+
"collapse",
|
|
234
|
+
"crossJoin",
|
|
235
|
+
"every",
|
|
236
|
+
"first",
|
|
237
|
+
"flatten",
|
|
238
|
+
"join",
|
|
239
|
+
"last",
|
|
240
|
+
"map",
|
|
241
|
+
"mapSpread",
|
|
242
|
+
"partition",
|
|
243
|
+
"random",
|
|
244
|
+
"reject",
|
|
245
|
+
"shuffle",
|
|
246
|
+
"sole",
|
|
247
|
+
"some",
|
|
248
|
+
"sort",
|
|
249
|
+
"sortDesc",
|
|
250
|
+
"take",
|
|
251
|
+
"where",
|
|
252
|
+
"whereNotNull",
|
|
253
|
+
"wrap"
|
|
254
|
+
];
|
|
255
|
+
const objectExports = [
|
|
256
|
+
"add",
|
|
257
|
+
"dot",
|
|
258
|
+
"except",
|
|
259
|
+
"forget",
|
|
260
|
+
"get",
|
|
261
|
+
"has",
|
|
262
|
+
"only",
|
|
263
|
+
"set",
|
|
264
|
+
"undot"
|
|
265
|
+
];
|
|
266
|
+
const stringExports = [
|
|
267
|
+
"after",
|
|
268
|
+
"afterLast",
|
|
269
|
+
"ascii",
|
|
270
|
+
"defaultLocale",
|
|
271
|
+
"before",
|
|
272
|
+
"beforeLast",
|
|
273
|
+
"between",
|
|
274
|
+
"betweenFirst",
|
|
275
|
+
"camel",
|
|
276
|
+
"contains",
|
|
277
|
+
"containsAll",
|
|
278
|
+
"endsWith",
|
|
279
|
+
"finish",
|
|
280
|
+
"kebab",
|
|
281
|
+
"lcfirst",
|
|
282
|
+
"length",
|
|
283
|
+
"lower",
|
|
284
|
+
"padBoth",
|
|
285
|
+
"padLeft",
|
|
286
|
+
"padRight",
|
|
287
|
+
"plural",
|
|
288
|
+
"pluralStudly",
|
|
289
|
+
"remove",
|
|
290
|
+
"replace",
|
|
291
|
+
"replaceFirst",
|
|
292
|
+
"replaceLast",
|
|
293
|
+
"rtrim",
|
|
294
|
+
"singular",
|
|
295
|
+
"slug",
|
|
296
|
+
"snake",
|
|
297
|
+
"start",
|
|
298
|
+
"startsWith",
|
|
299
|
+
"studly",
|
|
300
|
+
"title",
|
|
301
|
+
"transliterate",
|
|
302
|
+
"ucfirst",
|
|
303
|
+
"upper",
|
|
304
|
+
"wordCount",
|
|
305
|
+
"words",
|
|
306
|
+
"wrap",
|
|
307
|
+
"useLocale",
|
|
308
|
+
"withLocale"
|
|
309
|
+
];
|
|
310
|
+
for (const name of numberExports) {
|
|
311
|
+
const as = `${capitalize(name)}`;
|
|
312
|
+
addImports({ name, as, from });
|
|
313
|
+
}
|
|
314
|
+
for (const name of arrayExports) {
|
|
315
|
+
const as = `${capitalize(name)}`;
|
|
316
|
+
addImports({ name, as, from });
|
|
317
|
+
}
|
|
318
|
+
for (const name of objectExports) {
|
|
319
|
+
const as = `${capitalize(name)}`;
|
|
320
|
+
addImports({ name, as, from });
|
|
321
|
+
}
|
|
322
|
+
for (const name of stringExports) {
|
|
323
|
+
const as = `${capitalize(name)}`;
|
|
324
|
+
addImports({ name, as, from });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function capitalize(value) {
|
|
328
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const piniaDefaults = {
|
|
332
|
+
enabled: false,
|
|
333
|
+
storesDirs: ["stores"]
|
|
334
|
+
};
|
|
335
|
+
function resolvePiniaOptions(input) {
|
|
336
|
+
if (input === false) {
|
|
337
|
+
return { ...piniaDefaults, enabled: false };
|
|
338
|
+
}
|
|
339
|
+
const overrides = typeof input === "boolean" || input === void 0 ? {} : input;
|
|
340
|
+
return {
|
|
341
|
+
...piniaDefaults,
|
|
342
|
+
...overrides,
|
|
343
|
+
enabled: overrides.enabled ?? true,
|
|
344
|
+
storesDirs: overrides.storesDirs ?? piniaDefaults.storesDirs
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function registerPiniaFeature(options, nuxt, { runtimeDir, payload, plugin, composables, resolver }) {
|
|
348
|
+
if (!options.enabled) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
nuxt.options.build.transpile.push(runtimeDir);
|
|
352
|
+
nuxt.options.vite.optimizeDeps ??= {};
|
|
353
|
+
nuxt.options.vite.optimizeDeps.exclude ??= [];
|
|
354
|
+
if (!nuxt.options.vite.optimizeDeps.exclude.includes("pinia")) {
|
|
355
|
+
nuxt.options.vite.optimizeDeps.exclude.push("pinia");
|
|
356
|
+
}
|
|
357
|
+
nuxt.hook("prepare:types", ({ references }) => {
|
|
358
|
+
references.push({ types: "@pinia/nuxt" });
|
|
359
|
+
});
|
|
360
|
+
nuxt.hook("modules:done", () => {
|
|
361
|
+
addPlugin(plugin);
|
|
362
|
+
addPlugin(payload);
|
|
363
|
+
});
|
|
364
|
+
addImports([
|
|
365
|
+
{ from: composables, name: "defineStore" },
|
|
366
|
+
{ from: composables, name: "acceptHMRUpdate" },
|
|
367
|
+
{ from: composables, name: "usePinia" },
|
|
368
|
+
{ from: composables, name: "storeToRefs" },
|
|
369
|
+
{ from: composables, name: "defineStore", as: "definePiniaStore" }
|
|
370
|
+
]);
|
|
371
|
+
for (const storeDir of options.storesDirs) {
|
|
372
|
+
addImportsDir(resolver.resolve(nuxt.options.srcDir, storeDir));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const module$1 = defineNuxtModule({
|
|
377
|
+
meta: {
|
|
378
|
+
name: "nuxid",
|
|
379
|
+
configKey: "kiban"
|
|
380
|
+
},
|
|
381
|
+
moduleDependencies() {
|
|
382
|
+
const dependencies = {
|
|
383
|
+
"@sentry/nuxt": {
|
|
384
|
+
version: "10.32.1"
|
|
385
|
+
},
|
|
386
|
+
"@vueuse/nuxt": {
|
|
387
|
+
version: "14.1.0"
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
return dependencies;
|
|
391
|
+
},
|
|
392
|
+
async setup(options, nuxt) {
|
|
393
|
+
const resolver = createResolver(import.meta.url);
|
|
394
|
+
const lodashOptions = resolveLodashOptions(options.lodash);
|
|
395
|
+
const validatorOptions = resolveValidatorOptions(options.validator);
|
|
396
|
+
const formOptions = resolveFormOptions(options.form);
|
|
397
|
+
const iconOptions = resolveIconOptions(options.icon);
|
|
398
|
+
const elementPlusOptions = resolveElementPlusOptions(options.elementPlus);
|
|
399
|
+
const helperOptions = resolveHelperOptions(options.helper);
|
|
400
|
+
const piniaOptions = resolvePiniaOptions(options.pinia);
|
|
401
|
+
if (iconOptions.enabled) {
|
|
402
|
+
await installModule("@nuxt/icon", iconOptions.config);
|
|
403
|
+
}
|
|
404
|
+
if (elementPlusOptions.enabled) {
|
|
405
|
+
await installModule("@element-plus/nuxt", elementPlusOptions.config);
|
|
406
|
+
}
|
|
407
|
+
if (lodashOptions.enabled) {
|
|
408
|
+
registerLodashFeature(lodashOptions, resolver.resolve);
|
|
409
|
+
}
|
|
410
|
+
if (validatorOptions.enabled) {
|
|
411
|
+
registerValidatorFeature(validatorOptions, {
|
|
412
|
+
from: resolver.resolve("./runtime/validator")
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
if (formOptions.enabled) {
|
|
416
|
+
registerFormFeature(formOptions, {
|
|
417
|
+
from: resolver.resolve("./runtime/form")
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
if (helperOptions.enabled) {
|
|
421
|
+
registerHelperFeature(helperOptions, {
|
|
422
|
+
from: resolver.resolve("./runtime/helper")
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (piniaOptions.enabled) {
|
|
426
|
+
const piniaRuntimeDir = fileURLToPath(new URL("./runtime/pinia", import.meta.url));
|
|
427
|
+
registerPiniaFeature(piniaOptions, nuxt, {
|
|
428
|
+
runtimeDir: resolver.resolve(piniaRuntimeDir),
|
|
429
|
+
payload: resolver.resolve(piniaRuntimeDir, "payload-plugin"),
|
|
430
|
+
plugin: resolver.resolve(piniaRuntimeDir, "plugin"),
|
|
431
|
+
composables: resolver.resolve(piniaRuntimeDir, "composables"),
|
|
432
|
+
resolver
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HTTPMethod } from 'h3';
|
|
2
|
+
import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
|
|
3
|
+
export type FormFetcher = <T = any>(request: NitroFetchRequest, opts?: NitroFetchOptions<NitroFetchRequest>) => Promise<T>;
|
|
4
|
+
export interface UseForm<DefaultResponseType = any> {
|
|
5
|
+
_method?: HTTPMethod;
|
|
6
|
+
submit: <APIResponseType = DefaultResponseType>(method: HTTPMethod, url: NitroFetchRequest, options?: NitroFetchOptions<NitroFetchRequest>) => Promise<APIResponseType>;
|
|
7
|
+
post: <APIResponseType = DefaultResponseType>(url: NitroFetchRequest, options?: NitroFetchOptions<NitroFetchRequest>) => Promise<APIResponseType>;
|
|
8
|
+
patch: <APIResponseType = DefaultResponseType>(url: NitroFetchRequest, options?: NitroFetchOptions<NitroFetchRequest>) => Promise<APIResponseType>;
|
|
9
|
+
put: <APIResponseType = DefaultResponseType>(url: NitroFetchRequest, options?: NitroFetchOptions<NitroFetchRequest>) => Promise<APIResponseType>;
|
|
10
|
+
delete: <APIResponseType = DefaultResponseType>(url: NitroFetchRequest, options?: NitroFetchOptions<NitroFetchRequest>) => Promise<APIResponseType>;
|
|
11
|
+
processing: boolean;
|
|
12
|
+
errors: any;
|
|
13
|
+
response: Record<string, any> | null;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export interface FormComposableOptions {
|
|
17
|
+
alwaysFormData?: boolean;
|
|
18
|
+
fetcher?: FormFetcher;
|
|
19
|
+
fetchOptions?: NitroFetchOptions<NitroFetchRequest>;
|
|
20
|
+
}
|
|
21
|
+
export default function useForm<TData extends object, DefaultResponseType = any>(initialData: TData, formOptions?: FormComposableOptions): TData & UseForm<DefaultResponseType>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { reactive, ref, toRaw } from "vue";
|
|
2
|
+
function normalizeStringWhitespace(value) {
|
|
3
|
+
return value.trim().replace(/\s{2,}/g, " ");
|
|
4
|
+
}
|
|
5
|
+
function normalizeValue(value) {
|
|
6
|
+
if (typeof value === "string") {
|
|
7
|
+
return normalizeStringWhitespace(value);
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return value.map((item) => normalizeValue(item));
|
|
11
|
+
}
|
|
12
|
+
if (value && typeof value === "object" && !(value instanceof File) && Object.prototype.toString.call(value) === "[object Object]") {
|
|
13
|
+
return Object.keys(value).reduce((normalized, key) => {
|
|
14
|
+
normalized[key] = normalizeValue(value[key]);
|
|
15
|
+
return normalized;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
export default function useForm(initialData, formOptions) {
|
|
21
|
+
const form = reactive({
|
|
22
|
+
...initialData,
|
|
23
|
+
response: null,
|
|
24
|
+
errors: {},
|
|
25
|
+
processing: false,
|
|
26
|
+
submit: async (method, url, options) => {
|
|
27
|
+
const isMultipart = ref(false);
|
|
28
|
+
const formDataBody = new FormData();
|
|
29
|
+
form.processing = true;
|
|
30
|
+
form.response = null;
|
|
31
|
+
form.errors = {};
|
|
32
|
+
const excludedKeys = [
|
|
33
|
+
"errors",
|
|
34
|
+
"processing",
|
|
35
|
+
"response",
|
|
36
|
+
"post",
|
|
37
|
+
"patch",
|
|
38
|
+
"put",
|
|
39
|
+
"delete",
|
|
40
|
+
"submit",
|
|
41
|
+
"rules"
|
|
42
|
+
];
|
|
43
|
+
const plainBodyObject = {};
|
|
44
|
+
const formData = { ...toRaw(form) };
|
|
45
|
+
for (const key in formData) {
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(formData, key) || excludedKeys.includes(key)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const value = normalizeValue(formData[key]);
|
|
50
|
+
form[key] = value;
|
|
51
|
+
if (value instanceof File || Array.isArray(value) && value.some((item) => item instanceof File)) {
|
|
52
|
+
isMultipart.value = true;
|
|
53
|
+
}
|
|
54
|
+
if (value instanceof File) {
|
|
55
|
+
formDataBody.append(key, value);
|
|
56
|
+
} else if (Array.isArray(value) && value.every((item) => item instanceof File)) {
|
|
57
|
+
value.forEach((file) => formDataBody.append(`${key}[]`, file));
|
|
58
|
+
} else if (Array.isArray(value)) {
|
|
59
|
+
value.forEach((item, index) => {
|
|
60
|
+
if (typeof item === "object" && item !== null && !(item instanceof File)) {
|
|
61
|
+
Object.keys(item).forEach((subKey) => {
|
|
62
|
+
const fieldName = `${key}[${index}][${subKey}]`;
|
|
63
|
+
formDataBody.append(fieldName, String(item[subKey] || ""));
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
const fieldName = `${key}[${index}]`;
|
|
67
|
+
formDataBody.append(fieldName, String(item));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
plainBodyObject[key] = value;
|
|
71
|
+
} else if (typeof value === "object" && value !== null && !(value instanceof File)) {
|
|
72
|
+
Object.keys(value).forEach((subKey) => {
|
|
73
|
+
const fieldName = `${key}[${subKey}]`;
|
|
74
|
+
if (Array.isArray(value[subKey])) {
|
|
75
|
+
value[subKey].forEach((arrayItem, arrayIndex) => {
|
|
76
|
+
const arrayFieldName = `${fieldName}[${arrayIndex}]`;
|
|
77
|
+
formDataBody.append(arrayFieldName, String(arrayItem));
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
formDataBody.append(fieldName, String(value[subKey] || ""));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
plainBodyObject[key] = value;
|
|
84
|
+
} else {
|
|
85
|
+
if (value !== null && value !== void 0) {
|
|
86
|
+
formDataBody.append(key, String(value));
|
|
87
|
+
} else if (value === null) {
|
|
88
|
+
formDataBody.append(key, "");
|
|
89
|
+
}
|
|
90
|
+
plainBodyObject[key] = value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const fetchOptions = {
|
|
94
|
+
...formOptions?.fetchOptions,
|
|
95
|
+
...options,
|
|
96
|
+
method,
|
|
97
|
+
body: formOptions?.alwaysFormData || isMultipart.value ? formDataBody : plainBodyObject,
|
|
98
|
+
onRequestError(context) {
|
|
99
|
+
form.processing = false;
|
|
100
|
+
if (typeof formOptions?.fetchOptions?.onRequestError === "function") {
|
|
101
|
+
formOptions.fetchOptions.onRequestError(context);
|
|
102
|
+
}
|
|
103
|
+
if (typeof options?.onRequestError === "function") {
|
|
104
|
+
options.onRequestError(context);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onResponse(context) {
|
|
108
|
+
if (context.response.ok) {
|
|
109
|
+
form.response = context.response._data;
|
|
110
|
+
}
|
|
111
|
+
form.errors = {};
|
|
112
|
+
form.processing = false;
|
|
113
|
+
if (typeof formOptions?.fetchOptions?.onResponse === "function") {
|
|
114
|
+
formOptions.fetchOptions.onResponse(context);
|
|
115
|
+
}
|
|
116
|
+
if (typeof options?.onResponse === "function") {
|
|
117
|
+
options.onResponse(context);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
async onResponseError(context) {
|
|
121
|
+
if (context.response._data && typeof context.response._data === "object") {
|
|
122
|
+
const responseData = context.response._data;
|
|
123
|
+
if (responseData.errors) {
|
|
124
|
+
form.errors = responseData.errors;
|
|
125
|
+
} else if (responseData.message || responseData.error) {
|
|
126
|
+
form.errors = responseData;
|
|
127
|
+
} else {
|
|
128
|
+
form.errors = responseData;
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
form.errors = {};
|
|
132
|
+
}
|
|
133
|
+
if (typeof formOptions?.fetchOptions?.onResponseError === "function") {
|
|
134
|
+
formOptions.fetchOptions.onResponseError(context);
|
|
135
|
+
}
|
|
136
|
+
if (typeof options?.onResponseError === "function") {
|
|
137
|
+
options.onResponseError(context);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const fetcher = formOptions?.fetcher ?? globalThis.$fetch;
|
|
142
|
+
if (!fetcher) {
|
|
143
|
+
throw new Error("Nuxt $fetch is not available in the current context");
|
|
144
|
+
}
|
|
145
|
+
return fetcher(url, fetchOptions);
|
|
146
|
+
},
|
|
147
|
+
post: (url, options) => {
|
|
148
|
+
return form.submit("POST", url, options);
|
|
149
|
+
},
|
|
150
|
+
patch: (url, options) => {
|
|
151
|
+
return form.submit("PATCH", url, options);
|
|
152
|
+
},
|
|
153
|
+
put: (url, options) => {
|
|
154
|
+
return form.submit("PUT", url, options);
|
|
155
|
+
},
|
|
156
|
+
delete: (url, options) => {
|
|
157
|
+
return form.submit("DELETE", url, options);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return form;
|
|
161
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function collapse<T>(arrays: Array<T[]>): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function crossJoin<T>(...arrays: T[][]): T[][];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function crossJoin(...arrays) {
|
|
2
|
+
if (arrays.length === 0) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
return arrays.reduce(
|
|
6
|
+
(acc, curr) => {
|
|
7
|
+
const next = [];
|
|
8
|
+
for (const prefix of acc) {
|
|
9
|
+
for (const value of curr) {
|
|
10
|
+
next.push([...prefix, value]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return next;
|
|
14
|
+
},
|
|
15
|
+
[[]]
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function every<T>(array: T[], predicate: (item: T, index: number) => boolean): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function first<T>(array: T[], callback?: (item: T, index: number) => boolean, defaultValue?: T | null): T | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function first(array, callback, defaultValue = null) {
|
|
2
|
+
if (!callback) {
|
|
3
|
+
return array.length ? array[0] : defaultValue;
|
|
4
|
+
}
|
|
5
|
+
for (let i = 0; i < array.length; i++) {
|
|
6
|
+
if (callback(array[i], i)) {
|
|
7
|
+
return array[i];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return defaultValue;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flatten<T>(input: T[], depth?: number): any[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function flatten(input, depth = Infinity) {
|
|
2
|
+
if (depth <= 0) {
|
|
3
|
+
return [...input];
|
|
4
|
+
}
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const item of input) {
|
|
7
|
+
if (Array.isArray(item) && depth > 0) {
|
|
8
|
+
result.push(...flatten(item, depth - 1));
|
|
9
|
+
} else {
|
|
10
|
+
result.push(item);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|