@quazardous/qdadm 2.12.0 → 2.13.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quazardous/qdadm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.0",
|
|
4
4
|
"description": "Vue 3 framework for admin dashboards with PrimeVue",
|
|
5
5
|
"author": "quazardous",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
"vite": {
|
|
73
73
|
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"primevue": {
|
|
76
|
+
"optional": true
|
|
74
77
|
}
|
|
75
78
|
},
|
|
76
79
|
"optionalDependencies": {
|
|
@@ -59,6 +59,10 @@ export function useDirtyState<T extends FormState = FormState>(
|
|
|
59
59
|
// initial side each time doubled the per-key work, and the old
|
|
60
60
|
// JSON.parse(JSON.stringify(state)) deep clone tripled the snapshot cost.
|
|
61
61
|
let initialFieldSnapshots: Map<string, string> | null = null
|
|
62
|
+
// Parsed deep copy of the initial form, kept for path-aware isFieldDirty
|
|
63
|
+
// (#1396). Built once per snapshot; the per-keystroke checkDirty path
|
|
64
|
+
// (#1194) never touches it.
|
|
65
|
+
let initialForm: Record<string, unknown> | null = null
|
|
62
66
|
const ready = ref(false)
|
|
63
67
|
|
|
64
68
|
/** Resolve the form object inside the state (common 'form'/'formData' patterns). */
|
|
@@ -76,6 +80,16 @@ export function useDirtyState<T extends FormState = FormState>(
|
|
|
76
80
|
return s === undefined ? 'undefined' : s
|
|
77
81
|
}
|
|
78
82
|
|
|
83
|
+
/** Resolve a dot path ('config.login') in an object, undefined-safe. */
|
|
84
|
+
function getByPath(obj: unknown, path: string): unknown {
|
|
85
|
+
let cur: unknown = obj
|
|
86
|
+
for (const seg of path.split('.')) {
|
|
87
|
+
if (cur === null || cur === undefined || typeof cur !== 'object') return undefined
|
|
88
|
+
cur = (cur as Record<string, unknown>)[seg]
|
|
89
|
+
}
|
|
90
|
+
return cur
|
|
91
|
+
}
|
|
92
|
+
|
|
79
93
|
function getFormSnapshot(): string {
|
|
80
94
|
return JSON.stringify(getState())
|
|
81
95
|
}
|
|
@@ -96,6 +110,7 @@ export function useDirtyState<T extends FormState = FormState>(
|
|
|
96
110
|
fieldSnapshots.set(key, stringifyField(form[key]))
|
|
97
111
|
}
|
|
98
112
|
initialFieldSnapshots = fieldSnapshots
|
|
113
|
+
initialForm = JSON.parse(JSON.stringify(form)) as Record<string, unknown>
|
|
99
114
|
ready.value = true
|
|
100
115
|
})
|
|
101
116
|
}
|
|
@@ -126,7 +141,21 @@ export function useDirtyState<T extends FormState = FormState>(
|
|
|
126
141
|
}
|
|
127
142
|
|
|
128
143
|
function isFieldDirty(fieldName: string): boolean {
|
|
129
|
-
|
|
144
|
+
// Dot-free names: exact historical behavior.
|
|
145
|
+
if (!fieldName.includes('.')) {
|
|
146
|
+
return dirtyFields.value.includes(fieldName)
|
|
147
|
+
}
|
|
148
|
+
// Path-aware (#1396): a sub-field can only be dirty if its ROOT key is —
|
|
149
|
+
// the pre-filter reuses the per-key work checkDirty already did, and
|
|
150
|
+
// reading dirtyFields keeps the same reactive trigger as flat names.
|
|
151
|
+
const root = fieldName.slice(0, fieldName.indexOf('.'))
|
|
152
|
+
if (!dirtyFields.value.includes(root)) return false
|
|
153
|
+
if (!initialForm) return false
|
|
154
|
+
const currentForm = resolveForm(getState())
|
|
155
|
+
return (
|
|
156
|
+
stringifyField(getByPath(currentForm, fieldName)) !==
|
|
157
|
+
stringifyField(getByPath(initialForm, fieldName))
|
|
158
|
+
)
|
|
130
159
|
}
|
|
131
160
|
|
|
132
161
|
function reset(): void {
|
|
@@ -134,6 +163,7 @@ export function useDirtyState<T extends FormState = FormState>(
|
|
|
134
163
|
dirtyFields.value = []
|
|
135
164
|
initialSnapshot.value = null
|
|
136
165
|
initialFieldSnapshots = null
|
|
166
|
+
initialForm = null
|
|
137
167
|
ready.value = false
|
|
138
168
|
}
|
|
139
169
|
|
package/src/vite/qdadmPlugin.ts
CHANGED
|
@@ -53,6 +53,26 @@ export interface QdadmVitePluginOptions {
|
|
|
53
53
|
* (vue, vue-router, primevue, pinia).
|
|
54
54
|
*/
|
|
55
55
|
dedupe?: string[]
|
|
56
|
+
/**
|
|
57
|
+
* PrimeVue "flavor" (#1393): alias every `primevue/*` import to a
|
|
58
|
+
* compatible fork (e.g. OpenVue). qdadm officially maintains and tests
|
|
59
|
+
* `primevue@4` (MIT) only — a flavor keeping the v4 module layout/API is
|
|
60
|
+
* drop-in; divergences are the consumer's to absorb.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* qdadmVitePlugin({ primevue: { package: 'openvue' } })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
primevue?: {
|
|
67
|
+
/** Package that replaces `primevue` (e.g. 'openvue'). */
|
|
68
|
+
package: string
|
|
69
|
+
/**
|
|
70
|
+
* Optional package replacing `@primeuix/themes` — only needed if the
|
|
71
|
+
* flavor ships its own themes fork (none does today; OpenVue keeps the
|
|
72
|
+
* MIT @primeuix/* versions).
|
|
73
|
+
*/
|
|
74
|
+
themes?: string
|
|
75
|
+
}
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
export function qdadmVitePlugin(options: QdadmVitePluginOptions = {}): Plugin {
|
|
@@ -76,12 +96,33 @@ export function qdadmVitePlugin(options: QdadmVitePluginOptions = {}): Plugin {
|
|
|
76
96
|
// not installed under root node_modules (aliased/hoisted) — nothing to allow
|
|
77
97
|
}
|
|
78
98
|
|
|
99
|
+
// Flavor aliasing (#1393): after the alias, no `primevue`/themes ids
|
|
100
|
+
// remain in the graph — dedupe/exclude lists must name the flavor.
|
|
101
|
+
const flavor = options.primevue ?? null
|
|
102
|
+
const widgetPkg = flavor?.package ?? 'primevue'
|
|
103
|
+
const themesPkg = flavor?.themes ?? '@primeuix/themes'
|
|
104
|
+
const alias = []
|
|
105
|
+
if (flavor) {
|
|
106
|
+
alias.push({ find: /^primevue(\/|$)/, replacement: `${flavor.package}$1` })
|
|
107
|
+
if (flavor.themes) {
|
|
108
|
+
alias.push({ find: /^@primeuix\/themes(\/|$)/, replacement: `${flavor.themes}$1` })
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// With a flavor, the original packages may still be installed — keep
|
|
113
|
+
// them excluded too, or the optimizer pre-bundles a stray
|
|
114
|
+
// `primevue/*` id that bypassed the alias (split-instance again).
|
|
115
|
+
const widgetExcludes = flavor ? [widgetPkg, 'primevue'] : [widgetPkg]
|
|
116
|
+
const themesExcludes =
|
|
117
|
+
flavor?.themes ? [themesPkg, '@primeuix/themes'] : [themesPkg]
|
|
118
|
+
|
|
79
119
|
return {
|
|
80
120
|
resolve: {
|
|
81
|
-
|
|
121
|
+
...(alias.length > 0 ? { alias } : {}),
|
|
122
|
+
dedupe: ['vue', 'vue-router', widgetPkg, 'pinia', ...(options.dedupe ?? [])],
|
|
82
123
|
},
|
|
83
124
|
optimizeDeps: {
|
|
84
|
-
exclude: [
|
|
125
|
+
exclude: [...widgetExcludes, ...themesExcludes, '@quazardous/qdadm'],
|
|
85
126
|
// One form per install mode: the nested path resolves through a
|
|
86
127
|
// real node_modules chain (npm installs), the plain form through a
|
|
87
128
|
// symlink realpath — declaring the unused one logs a "Failed to
|