@globalbrain/sefirot 3.25.1 → 3.27.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.
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import SAvatar from './SAvatar.vue'
|
|
3
|
+
import SDescEmpty from './SDescEmpty.vue'
|
|
4
|
+
|
|
5
|
+
export interface Avatar {
|
|
6
|
+
avatar?: string | null
|
|
7
|
+
name?: string | null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
defineProps<{
|
|
11
|
+
avatar?: Avatar | null
|
|
12
|
+
}>()
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<div v-if="avatar" class="SDescAvatar">
|
|
17
|
+
<div class="value">
|
|
18
|
+
<SAvatar
|
|
19
|
+
v-if="avatar.avatar"
|
|
20
|
+
size="nano"
|
|
21
|
+
:avatar="avatar.avatar"
|
|
22
|
+
:name="avatar.name"
|
|
23
|
+
/>
|
|
24
|
+
<span v-if="avatar.name" class="name">
|
|
25
|
+
{{ avatar.name }}
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<SDescEmpty v-else />
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<style scoped lang="postcss">
|
|
33
|
+
.value {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 8px;
|
|
37
|
+
height: 24px;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
setup
|
|
3
3
|
lang="ts"
|
|
4
4
|
generic="
|
|
5
|
-
|
|
5
|
+
ValueType extends string | number | boolean = string | number | boolean,
|
|
6
6
|
Nullable extends boolean = false
|
|
7
7
|
"
|
|
8
8
|
>
|
|
@@ -16,16 +16,13 @@ export type Size = 'mini' | 'small' | 'medium'
|
|
|
16
16
|
export type Color = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
|
|
17
17
|
|
|
18
18
|
export interface Option<
|
|
19
|
-
|
|
20
|
-
Nullable extends boolean = false
|
|
19
|
+
ValueType extends string | number | boolean = string | number | boolean
|
|
21
20
|
> {
|
|
22
21
|
label: string
|
|
23
|
-
value:
|
|
22
|
+
value: ValueType
|
|
24
23
|
disabled?: boolean
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
type ValueType = Nullable extends true ? T : T
|
|
28
|
-
type ValueOrNull = Nullable extends true ? T | null : T
|
|
29
26
|
type NullValue = Nullable extends true ? null : never
|
|
30
27
|
|
|
31
28
|
const props = withDefaults(defineProps<{
|
|
@@ -38,7 +35,7 @@ const props = withDefaults(defineProps<{
|
|
|
38
35
|
checkIcon?: IconifyIcon | DefineComponent
|
|
39
36
|
checkText?: string
|
|
40
37
|
checkColor?: Color
|
|
41
|
-
options: Option<
|
|
38
|
+
options: Option<ValueType>[]
|
|
42
39
|
nullable?: Nullable
|
|
43
40
|
disabled?: boolean
|
|
44
41
|
value?: ValueType | null
|
|
@@ -51,8 +48,8 @@ const props = withDefaults(defineProps<{
|
|
|
51
48
|
})
|
|
52
49
|
|
|
53
50
|
const emit = defineEmits<{
|
|
54
|
-
(e: 'update:model-value', value:
|
|
55
|
-
(e: 'change', value:
|
|
51
|
+
(e: 'update:model-value', value: ValueType | NullValue): void
|
|
52
|
+
(e: 'change', value: ValueType | NullValue): void
|
|
56
53
|
}>()
|
|
57
54
|
|
|
58
55
|
const _value = computed(() => {
|
package/lib/http/Http.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { parse as parseCookie } from '@tinyhttp/cookie'
|
|
|
3
3
|
import FileSaver from 'file-saver'
|
|
4
4
|
import { type FetchOptions, type FetchRequest, type FetchResponse, ofetch } from 'ofetch'
|
|
5
5
|
import { stringify } from 'qs'
|
|
6
|
+
import { type Lang } from '../composables/Lang'
|
|
6
7
|
|
|
7
8
|
export interface HttpClient {
|
|
8
9
|
<T = any>(request: FetchRequest, options?: Omit<FetchOptions, 'method'>): Promise<T>
|
|
@@ -13,12 +14,14 @@ export interface HttpOptions {
|
|
|
13
14
|
baseUrl?: string
|
|
14
15
|
xsrfUrl?: string | false
|
|
15
16
|
client?: HttpClient
|
|
17
|
+
lang?: Lang
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export class Http {
|
|
19
21
|
private static baseUrl: string | undefined = undefined
|
|
20
22
|
private static xsrfUrl: string | false = '/api/csrf-cookie'
|
|
21
23
|
private static client: HttpClient = ofetch
|
|
24
|
+
private static lang: Lang | undefined = undefined
|
|
22
25
|
|
|
23
26
|
static config(options: HttpOptions) {
|
|
24
27
|
if (options.baseUrl) {
|
|
@@ -30,6 +33,9 @@ export class Http {
|
|
|
30
33
|
if (options.client) {
|
|
31
34
|
Http.client = options.client
|
|
32
35
|
}
|
|
36
|
+
if (options.lang) {
|
|
37
|
+
Http.lang = options.lang
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
private async ensureXsrfToken(): Promise<string | undefined> {
|
|
@@ -70,7 +76,8 @@ export class Http {
|
|
|
70
76
|
...options,
|
|
71
77
|
headers: {
|
|
72
78
|
Accept: 'application/json',
|
|
73
|
-
...(xsrfToken && { 'X-
|
|
79
|
+
...(xsrfToken && { 'X-Xsrf-Token': xsrfToken }),
|
|
80
|
+
...(Http.lang && { 'Accept-Language': Http.lang }),
|
|
74
81
|
...options.headers
|
|
75
82
|
}
|
|
76
83
|
}
|