@globalbrain/sefirot 3.19.1 → 3.21.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/lib/composables/D.ts +2 -2
- package/lib/composables/Lang.ts +6 -0
- package/lib/composables/Url.ts +17 -8
- package/lib/http/Http.ts +29 -27
- package/package.json +14 -14
package/lib/composables/D.ts
CHANGED
|
@@ -6,12 +6,12 @@ export interface D<T extends Record<string, any>> {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function useD<T extends Record<string, any>>(data: T): D<T> {
|
|
9
|
-
const initialData = JSON.
|
|
9
|
+
const initialData = JSON.stringify(data)
|
|
10
10
|
|
|
11
11
|
const refData = ref(data) as Ref<T>
|
|
12
12
|
|
|
13
13
|
function init(): void {
|
|
14
|
-
refData.value = initialData
|
|
14
|
+
refData.value = JSON.parse(initialData)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return {
|
package/lib/composables/Lang.ts
CHANGED
package/lib/composables/Url.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import isEqual from 'lodash-es/isEqual'
|
|
2
2
|
import isPlainObject from 'lodash-es/isPlainObject'
|
|
3
|
-
import { watch } from 'vue'
|
|
3
|
+
import { type MaybeRef, unref, watch } from 'vue'
|
|
4
4
|
import { useRoute, useRouter } from 'vue-router'
|
|
5
5
|
|
|
6
6
|
export interface UseUrlQuerySyncOptions {
|
|
@@ -9,20 +9,25 @@ export interface UseUrlQuerySyncOptions {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function useUrlQuerySync(
|
|
12
|
-
state: Record<string, any
|
|
12
|
+
state: MaybeRef<Record<string, any>>,
|
|
13
13
|
{ casts = {}, exclude }: UseUrlQuerySyncOptions = {}
|
|
14
14
|
): void {
|
|
15
15
|
const router = useRouter()
|
|
16
16
|
const route = useRoute()
|
|
17
17
|
|
|
18
|
-
const flattenInitialState = flattenObject(
|
|
18
|
+
const flattenInitialState = flattenObject(
|
|
19
|
+
JSON.parse(JSON.stringify(unref(state)))
|
|
20
|
+
)
|
|
19
21
|
|
|
20
22
|
setStateFromQuery()
|
|
21
23
|
|
|
22
|
-
watch(() => state, setQueryFromState, {
|
|
24
|
+
watch(() => unref(state), setQueryFromState, {
|
|
25
|
+
deep: true,
|
|
26
|
+
immediate: true
|
|
27
|
+
})
|
|
23
28
|
|
|
24
29
|
function setStateFromQuery() {
|
|
25
|
-
const flattenState = flattenObject(state)
|
|
30
|
+
const flattenState = flattenObject(unref(state))
|
|
26
31
|
const flattenQuery = flattenObject(route.query)
|
|
27
32
|
|
|
28
33
|
Object.keys(flattenQuery).forEach((key) => {
|
|
@@ -39,11 +44,11 @@ export function useUrlQuerySync(
|
|
|
39
44
|
flattenState[key] = cast ? cast(value) : value
|
|
40
45
|
})
|
|
41
46
|
|
|
42
|
-
deepAssign(state, unflattenObject(flattenState))
|
|
47
|
+
deepAssign(unref(state), unflattenObject(flattenState))
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
async function setQueryFromState() {
|
|
46
|
-
const flattenState = flattenObject(state)
|
|
51
|
+
const flattenState = flattenObject(unref(state))
|
|
47
52
|
const flattenQuery = flattenObject(route.query)
|
|
48
53
|
|
|
49
54
|
Object.keys(flattenState).forEach((key) => {
|
|
@@ -110,7 +115,11 @@ function deepAssign(target: Record<string, any>, source: Record<string, any>) {
|
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
function deepAssignBase(
|
|
118
|
+
function deepAssignBase(
|
|
119
|
+
dest: Record<string, any>,
|
|
120
|
+
src: Record<string, any>,
|
|
121
|
+
key: string | number
|
|
122
|
+
) {
|
|
114
123
|
if (typeof src[key] === 'object' && src[key] !== null) {
|
|
115
124
|
deepAssign(dest[key], src[key])
|
|
116
125
|
} else {
|
package/lib/http/Http.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { $fetch, type FetchOptions } from 'ofetch'
|
|
|
5
5
|
import { stringify } from 'qs'
|
|
6
6
|
|
|
7
7
|
export class Http {
|
|
8
|
+
static base: string | undefined = undefined
|
|
8
9
|
static xsrfUrl = '/api/csrf-cookie'
|
|
9
10
|
|
|
10
11
|
private async ensureXsrfToken(): Promise<string | undefined> {
|
|
@@ -35,6 +36,7 @@ export class Http {
|
|
|
35
36
|
return [
|
|
36
37
|
`${url}${queryString ? `?${queryString}` : ''}`,
|
|
37
38
|
{
|
|
39
|
+
baseURL: Http.base,
|
|
38
40
|
method,
|
|
39
41
|
credentials: 'include',
|
|
40
42
|
...options,
|
|
@@ -55,33 +57,6 @@ export class Http {
|
|
|
55
57
|
return $fetch.raw<T, any>(...(await this.buildRequest(url, options)))
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
private objectToFormData(obj: any, form?: FormData, namespace?: string) {
|
|
59
|
-
const fd = form || new FormData()
|
|
60
|
-
let formKey: string
|
|
61
|
-
|
|
62
|
-
for (const property in obj) {
|
|
63
|
-
if (Reflect.has(obj, property)) {
|
|
64
|
-
if (namespace) {
|
|
65
|
-
formKey = `${namespace}[${property}]`
|
|
66
|
-
} else {
|
|
67
|
-
formKey = property
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (obj[property] === undefined) {
|
|
71
|
-
continue
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof obj[property] === 'object' && !(obj[property] instanceof Blob)) {
|
|
75
|
-
this.objectToFormData(obj[property], fd, property)
|
|
76
|
-
} else {
|
|
77
|
-
fd.append(formKey, obj[property])
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return fd
|
|
83
|
-
}
|
|
84
|
-
|
|
85
60
|
async get<T = any>(url: string, options?: FetchOptions): Promise<T> {
|
|
86
61
|
return this.performRequest<T>(url, { method: 'GET', ...options })
|
|
87
62
|
}
|
|
@@ -132,6 +107,33 @@ export class Http {
|
|
|
132
107
|
|
|
133
108
|
FileSaver.saveAs(blob, filename as string)
|
|
134
109
|
}
|
|
110
|
+
|
|
111
|
+
private objectToFormData(obj: any, form?: FormData, namespace?: string) {
|
|
112
|
+
const fd = form || new FormData()
|
|
113
|
+
let formKey: string
|
|
114
|
+
|
|
115
|
+
for (const property in obj) {
|
|
116
|
+
if (Reflect.has(obj, property)) {
|
|
117
|
+
if (namespace) {
|
|
118
|
+
formKey = `${namespace}[${property}]`
|
|
119
|
+
} else {
|
|
120
|
+
formKey = property
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (obj[property] === undefined) {
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof obj[property] === 'object' && !(obj[property] instanceof Blob)) {
|
|
128
|
+
this.objectToFormData(obj[property], fd, property)
|
|
129
|
+
} else {
|
|
130
|
+
fd.append(formKey, obj[property])
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return fd
|
|
136
|
+
}
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
export type { FetchOptions }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@globalbrain/sefirot",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"packageManager": "pnpm@8.
|
|
3
|
+
"version": "3.21.0",
|
|
4
|
+
"packageManager": "pnpm@8.14.0",
|
|
5
5
|
"description": "Vue Components for Global Brain Design System.",
|
|
6
6
|
"author": "Kia Ishii <ka.ishii@globalbrains.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"@types/markdown-it": "^13.0.7",
|
|
47
47
|
"@vuelidate/core": "^2.0.3",
|
|
48
48
|
"@vuelidate/validators": "^2.0.4",
|
|
49
|
-
"@vueuse/core": "^10.7.
|
|
49
|
+
"@vueuse/core": "^10.7.1",
|
|
50
50
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
51
51
|
"fuse.js": "^7.0.0",
|
|
52
52
|
"lodash-es": "^4.17.21",
|
|
53
53
|
"markdown-it": "^14.0.0",
|
|
54
54
|
"normalize.css": "^8.0.1",
|
|
55
55
|
"pinia": "^2.1.7",
|
|
56
|
-
"postcss": "^8.4.
|
|
56
|
+
"postcss": "^8.4.33",
|
|
57
57
|
"postcss-nested": "^6.0.1",
|
|
58
58
|
"v-calendar": "^3.1.2",
|
|
59
|
-
"vue": "^3.
|
|
59
|
+
"vue": "^3.4.5",
|
|
60
60
|
"vue-router": "^4.2.5"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
"@types/body-scroll-lock": "^3.1.2",
|
|
81
81
|
"@types/lodash-es": "^4.17.12",
|
|
82
82
|
"@types/markdown-it": "^13.0.7",
|
|
83
|
-
"@types/node": "^20.10.
|
|
84
|
-
"@vitejs/plugin-vue": "^5.0.
|
|
85
|
-
"@vitest/coverage-v8": "^1.1.
|
|
83
|
+
"@types/node": "^20.10.6",
|
|
84
|
+
"@vitejs/plugin-vue": "^5.0.2",
|
|
85
|
+
"@vitest/coverage-v8": "^1.1.2",
|
|
86
86
|
"@vue/test-utils": "^2.4.3",
|
|
87
87
|
"@vuelidate/core": "^2.0.3",
|
|
88
88
|
"@vuelidate/validators": "^2.0.4",
|
|
89
|
-
"@vueuse/core": "^10.7.
|
|
89
|
+
"@vueuse/core": "^10.7.1",
|
|
90
90
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
91
91
|
"eslint": "^8.56.0",
|
|
92
92
|
"fuse.js": "^7.0.0",
|
|
@@ -96,17 +96,17 @@
|
|
|
96
96
|
"markdown-it": "^14.0.0",
|
|
97
97
|
"normalize.css": "^8.0.1",
|
|
98
98
|
"pinia": "^2.1.7",
|
|
99
|
-
"postcss": "^8.4.
|
|
99
|
+
"postcss": "^8.4.33",
|
|
100
100
|
"postcss-nested": "^6.0.1",
|
|
101
101
|
"punycode": "^2.3.1",
|
|
102
102
|
"release-it": "^17.0.1",
|
|
103
103
|
"typescript": "~5.3.3",
|
|
104
104
|
"v-calendar": "^3.1.2",
|
|
105
105
|
"vite": "^5.0.10",
|
|
106
|
-
"vitepress": "1.0.0-rc.
|
|
107
|
-
"vitest": "^1.1.
|
|
108
|
-
"vue": "^3.
|
|
106
|
+
"vitepress": "1.0.0-rc.35",
|
|
107
|
+
"vitest": "^1.1.2",
|
|
108
|
+
"vue": "^3.4.5",
|
|
109
109
|
"vue-router": "^4.2.5",
|
|
110
|
-
"vue-tsc": "^1.8.
|
|
110
|
+
"vue-tsc": "^1.8.27"
|
|
111
111
|
}
|
|
112
112
|
}
|