@bagelink/vue 0.0.427 → 0.0.435
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/components/Alert.vue.d.ts +4 -1
- package/dist/components/Alert.vue.d.ts.map +1 -1
- package/dist/components/TableSchema.vue.d.ts +2 -5
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/BglForm.vue.d.ts +4 -1
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePicker.vue.d.ts +4 -0
- package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/FileUpload.vue.d.ts +6 -2
- package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts +0 -3
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/layout/Tabs.vue.d.ts +6 -2
- package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
- package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
- package/dist/index.cjs +239 -137
- package/dist/index.mjs +240 -138
- package/dist/plugins/bagel.d.ts +3 -0
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/style.css +109 -91
- package/dist/utils/BagelFormUtils.d.ts +1 -0
- package/dist/utils/BagelFormUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/lang.d.ts +7 -0
- package/dist/utils/lang.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/Alert.vue +4 -2
- package/src/components/TableSchema.vue +19 -9
- package/src/components/form/BglField.vue +5 -3
- package/src/components/form/BglForm.vue +13 -9
- package/src/components/form/inputs/DatePicker.vue +8 -2
- package/src/components/form/inputs/FileUpload.vue +54 -23
- package/src/components/form/inputs/RadioPillsInput.vue +9 -9
- package/src/components/form/inputs/SelectInput.vue +36 -31
- package/src/components/form/inputs/TextInput.vue +1 -1
- package/src/components/layout/Tabs.vue +14 -5
- package/src/components/layout/TabsNav.vue +34 -14
- package/src/plugins/bagel.ts +13 -4
- package/src/utils/BagelFormUtils.ts +44 -10
- package/src/utils/index.ts +2 -0
- package/src/utils/lang.ts +39 -0
package/src/plugins/bagel.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { inject } from 'vue';
|
|
|
4
4
|
import type { InjectionKey, Plugin } from 'vue';
|
|
5
5
|
import { Bagel } from '@bagelink/sdk';
|
|
6
6
|
import clickOutside from '../utils/clickOutside';
|
|
7
|
+
import { useLang } from '../utils';
|
|
7
8
|
|
|
8
9
|
export const bagelInjectionKey = Symbol('bagel') as InjectionKey<Bagel>;
|
|
9
10
|
export const i18nTInjectionKey = Symbol('bagel') as InjectionKey<
|
|
@@ -26,11 +27,14 @@ export function useI18nT() {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export interface BagelOptions {
|
|
29
|
-
|
|
30
|
+
availableLangs?: string[];
|
|
31
|
+
defaultLang?: string;
|
|
32
|
+
language?: string;
|
|
33
|
+
host: string;
|
|
30
34
|
// eslint-disable-next-line no-unused-vars
|
|
31
|
-
onError?: (err: Error) => void
|
|
35
|
+
onError?: (err: Error) => void;
|
|
32
36
|
// eslint-disable-next-line no-unused-vars
|
|
33
|
-
i18nT?: (key: string) => string
|
|
37
|
+
i18nT?: (key: string) => string;
|
|
34
38
|
}
|
|
35
39
|
export const BagelVue: Plugin = {
|
|
36
40
|
install: (app, options: BagelOptions) => {
|
|
@@ -46,9 +50,14 @@ export const BagelVue: Plugin = {
|
|
|
46
50
|
},
|
|
47
51
|
},
|
|
48
52
|
});
|
|
53
|
+
const { availableLangs, defaultLang, lang } = useLang();
|
|
54
|
+
if (options.availableLangs) availableLangs.value = options.availableLangs;
|
|
55
|
+
if (options.defaultLang) defaultLang.value = options.defaultLang;
|
|
56
|
+
if (options.language) lang.value = options.language;
|
|
49
57
|
app.config.globalProperties.$bagel = bagel;
|
|
50
58
|
app.provide(bagelInjectionKey, bagel);
|
|
51
|
-
app.config.globalProperties.$i18T =
|
|
59
|
+
app.config.globalProperties.$i18T =
|
|
60
|
+
options?.i18nT || ((key?: string) => key);
|
|
52
61
|
app.provide(i18nTInjectionKey, options?.i18nT || ((key: string) => key));
|
|
53
62
|
},
|
|
54
63
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Field } from '@bagelink/vue';
|
|
2
2
|
|
|
3
|
-
export type Option =
|
|
3
|
+
export type Option =
|
|
4
|
+
| string
|
|
5
|
+
| number
|
|
6
|
+
| Record<string, any>
|
|
7
|
+
| { label: string; value: string | number };
|
|
4
8
|
|
|
5
9
|
interface InputOptions {
|
|
6
10
|
required?: boolean;
|
|
@@ -8,6 +12,7 @@ interface InputOptions {
|
|
|
8
12
|
class?: string;
|
|
9
13
|
defaultValue?: string;
|
|
10
14
|
disabled?: boolean;
|
|
15
|
+
helptext?: string;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
interface TextInputOptions extends InputOptions {
|
|
@@ -27,9 +32,13 @@ interface NumFieldOptions extends InputOptions {
|
|
|
27
32
|
step?: number;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
type RichTextOptions = InputOptions
|
|
35
|
+
type RichTextOptions = InputOptions;
|
|
31
36
|
|
|
32
|
-
export function richText(
|
|
37
|
+
export function richText(
|
|
38
|
+
id: string,
|
|
39
|
+
label?: string,
|
|
40
|
+
options?: RichTextOptions,
|
|
41
|
+
) {
|
|
33
42
|
return {
|
|
34
43
|
$el: 'richtext',
|
|
35
44
|
class: options?.class,
|
|
@@ -41,7 +50,11 @@ export function richText(id: string, label?: string, options?: RichTextOptions)
|
|
|
41
50
|
};
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
export function txtField(
|
|
53
|
+
export function txtField(
|
|
54
|
+
id: string,
|
|
55
|
+
label?: string,
|
|
56
|
+
options?: TextInputOptions,
|
|
57
|
+
): Field {
|
|
45
58
|
return {
|
|
46
59
|
$el: 'text',
|
|
47
60
|
class: options?.class,
|
|
@@ -49,11 +62,20 @@ export function txtField(id: string, label?: string, options?: TextInputOptions)
|
|
|
49
62
|
id,
|
|
50
63
|
label,
|
|
51
64
|
placeholder: options?.placeholder,
|
|
52
|
-
attrs: {
|
|
65
|
+
attrs: {
|
|
66
|
+
type: options?.type,
|
|
67
|
+
pattern: options?.pattern,
|
|
68
|
+
multiline: options?.multiline,
|
|
69
|
+
},
|
|
53
70
|
};
|
|
54
71
|
}
|
|
55
72
|
|
|
56
|
-
export function slctField(
|
|
73
|
+
export function slctField(
|
|
74
|
+
id: string,
|
|
75
|
+
label?: string,
|
|
76
|
+
options?: Option[] | (() => Option[]),
|
|
77
|
+
config?: SlctInputOptions,
|
|
78
|
+
): Field {
|
|
57
79
|
return {
|
|
58
80
|
$el: 'select',
|
|
59
81
|
id,
|
|
@@ -63,11 +85,19 @@ export function slctField(id: string, label?: string, options?: Option[] | (() =
|
|
|
63
85
|
required: config?.required,
|
|
64
86
|
label,
|
|
65
87
|
defaultValue: config?.defaultValue,
|
|
66
|
-
attrs: {
|
|
88
|
+
attrs: {
|
|
89
|
+
disabled: config?.disabled,
|
|
90
|
+
searchable: config?.searchable,
|
|
91
|
+
multiselect: config?.multiselect,
|
|
92
|
+
},
|
|
67
93
|
};
|
|
68
94
|
}
|
|
69
95
|
|
|
70
|
-
export function checkField(
|
|
96
|
+
export function checkField(
|
|
97
|
+
id: string,
|
|
98
|
+
label?: string,
|
|
99
|
+
options?: NumFieldOptions,
|
|
100
|
+
): Field {
|
|
71
101
|
return {
|
|
72
102
|
$el: 'check',
|
|
73
103
|
class: options?.class,
|
|
@@ -77,7 +107,11 @@ export function checkField(id: string, label?: string, options?: NumFieldOptions
|
|
|
77
107
|
};
|
|
78
108
|
}
|
|
79
109
|
|
|
80
|
-
export function numField(
|
|
110
|
+
export function numField(
|
|
111
|
+
id: string,
|
|
112
|
+
label?: string,
|
|
113
|
+
options?: NumFieldOptions,
|
|
114
|
+
): Field {
|
|
81
115
|
return {
|
|
82
116
|
$el: 'text',
|
|
83
117
|
class: options?.class,
|
|
@@ -92,7 +126,7 @@ export function numField(id: string, label?: string, options?: NumFieldOptions):
|
|
|
92
126
|
export function frmRow(...children: Field[]) {
|
|
93
127
|
return {
|
|
94
128
|
$el: 'div',
|
|
95
|
-
class: 'flex gap-1 m_block
|
|
129
|
+
class: 'flex gap-1 m_block',
|
|
96
130
|
children,
|
|
97
131
|
};
|
|
98
132
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { reactive, computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
interface State {
|
|
4
|
+
defaultLang: string;
|
|
5
|
+
availableLangs: string[];
|
|
6
|
+
lang: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const state: State = reactive({
|
|
10
|
+
defaultLang: '',
|
|
11
|
+
availableLangs: [],
|
|
12
|
+
lang: 'en',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export function useLang() {
|
|
16
|
+
const lang = computed({
|
|
17
|
+
get: () => state.lang,
|
|
18
|
+
set: (val) => (state.lang = val),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const $tdb = (langEl: Record<string, any>) => langEl[state.lang] || langEl[state.defaultLang] || '';
|
|
22
|
+
|
|
23
|
+
const availableLangs = computed({
|
|
24
|
+
get: () => state.availableLangs,
|
|
25
|
+
set: (val) => (state.availableLangs = val),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const defaultLang = computed({
|
|
29
|
+
get: () => state.defaultLang,
|
|
30
|
+
set: (val) => (state.defaultLang = val),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
lang,
|
|
35
|
+
$tdb,
|
|
36
|
+
availableLangs,
|
|
37
|
+
defaultLang,
|
|
38
|
+
};
|
|
39
|
+
}
|