@ciwergrp/nuxid 1.6.6 → 1.7.0
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/module.json +1 -1
- package/dist/runtime/form.js +42 -3
- package/docs/.docs/dependencies.md +52 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/runtime/form.js
CHANGED
|
@@ -2,6 +2,45 @@ import { reactive, ref, toRaw } from "vue";
|
|
|
2
2
|
function normalizeStringWhitespace(value) {
|
|
3
3
|
return value.trim().replace(/\s{2,}/g, " ");
|
|
4
4
|
}
|
|
5
|
+
function isPlainObject(value) {
|
|
6
|
+
return value !== null && Object.prototype.toString.call(value) === "[object Object]";
|
|
7
|
+
}
|
|
8
|
+
function flattenErrorPaths(value, currentPath = "", target = {}) {
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
const hasObjectItems = value.some((item) => item !== null && typeof item === "object");
|
|
11
|
+
if (!hasObjectItems) {
|
|
12
|
+
if (currentPath) {
|
|
13
|
+
target[currentPath] = value;
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
}
|
|
17
|
+
value.forEach((item, index) => {
|
|
18
|
+
const nextPath = currentPath ? `${currentPath}.${index}` : `${index}`;
|
|
19
|
+
flattenErrorPaths(item, nextPath, target);
|
|
20
|
+
});
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
if (isPlainObject(value)) {
|
|
24
|
+
Object.keys(value).forEach((key) => {
|
|
25
|
+
const nextPath = currentPath ? `${currentPath}.${key}` : key;
|
|
26
|
+
flattenErrorPaths(value[key], nextPath, target);
|
|
27
|
+
});
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
if (currentPath) {
|
|
31
|
+
target[currentPath] = value;
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function withDotPathErrors(errors) {
|
|
36
|
+
if (!isPlainObject(errors) && !Array.isArray(errors)) {
|
|
37
|
+
return errors;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...errors,
|
|
41
|
+
...flattenErrorPaths(errors)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
5
44
|
function normalizeValue(value) {
|
|
6
45
|
if (typeof value === "string") {
|
|
7
46
|
return normalizeStringWhitespace(value);
|
|
@@ -121,11 +160,11 @@ export default function useHttp(initialData, formOptions) {
|
|
|
121
160
|
if (context.response._data && typeof context.response._data === "object") {
|
|
122
161
|
const responseData = context.response._data;
|
|
123
162
|
if (responseData.errors) {
|
|
124
|
-
form.errors = responseData.errors;
|
|
163
|
+
form.errors = withDotPathErrors(responseData.errors);
|
|
125
164
|
} else if (responseData.message || responseData.error) {
|
|
126
|
-
form.errors = responseData;
|
|
165
|
+
form.errors = withDotPathErrors(responseData);
|
|
127
166
|
} else {
|
|
128
|
-
form.errors = responseData;
|
|
167
|
+
form.errors = withDotPathErrors(responseData);
|
|
129
168
|
}
|
|
130
169
|
} else {
|
|
131
170
|
form.errors = {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Dependencies
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Dependencies
|
|
6
|
+
|
|
7
|
+
This page documents dependencies introduced by `@ciwergrp/nuxid`.
|
|
8
|
+
|
|
9
|
+
## Does this already exist?
|
|
10
|
+
|
|
11
|
+
Not as a dedicated page/menu.
|
|
12
|
+
|
|
13
|
+
- Existing docs under [Third-Party](/built-in-modules/) explain some integrations.
|
|
14
|
+
- This page is the complete dependency inventory.
|
|
15
|
+
|
|
16
|
+
## Package Dependencies (installed with `@ciwergrp/nuxid`)
|
|
17
|
+
|
|
18
|
+
When you install `@ciwergrp/nuxid`, these direct package dependencies are installed:
|
|
19
|
+
|
|
20
|
+
- `@element-plus/nuxt`
|
|
21
|
+
- `@formatjs/intl`
|
|
22
|
+
- `@inquirer/prompts`
|
|
23
|
+
- `@nuxt/icon`
|
|
24
|
+
- `@nuxt/kit`
|
|
25
|
+
- `@sentry/nuxt`
|
|
26
|
+
- `@sindresorhus/slugify`
|
|
27
|
+
- `@sindresorhus/transliterate`
|
|
28
|
+
- `@tailwindcss/vite`
|
|
29
|
+
- `@vueuse/nuxt`
|
|
30
|
+
- `date-fns`
|
|
31
|
+
- `element-plus`
|
|
32
|
+
- `hls.js`
|
|
33
|
+
- `lodash-es`
|
|
34
|
+
- `pinia`
|
|
35
|
+
- `socket.io-client`
|
|
36
|
+
- `tailwindcss`
|
|
37
|
+
- `vite`
|
|
38
|
+
|
|
39
|
+
## Nuxt Module Dependencies Added to Your App
|
|
40
|
+
|
|
41
|
+
Nuxid adds/integrates Nuxt modules as follows:
|
|
42
|
+
|
|
43
|
+
- Always declared module dependency: `@sentry/nuxt` (via `moduleDependencies`)
|
|
44
|
+
- Conditionally installed when enabled in `nuxid` options:
|
|
45
|
+
- `@nuxt/icon` (`nuxid.icon`)
|
|
46
|
+
- `@element-plus/nuxt` (`nuxid.elementPlus`)
|
|
47
|
+
- `@vueuse/nuxt` (`nuxid.vueuse`)
|
|
48
|
+
|
|
49
|
+
## Notes
|
|
50
|
+
|
|
51
|
+
- Enabling `nuxid.pinia` integrates Pinia runtime/composables but does not call `installModule('@pinia/nuxt')`.
|
|
52
|
+
- Versions follow this repository's `package.json`.
|