@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.
Files changed (45) hide show
  1. package/dist/components/Alert.vue.d.ts +4 -1
  2. package/dist/components/Alert.vue.d.ts.map +1 -1
  3. package/dist/components/TableSchema.vue.d.ts +2 -5
  4. package/dist/components/TableSchema.vue.d.ts.map +1 -1
  5. package/dist/components/form/BglField.vue.d.ts.map +1 -1
  6. package/dist/components/form/BglForm.vue.d.ts +4 -1
  7. package/dist/components/form/BglForm.vue.d.ts.map +1 -1
  8. package/dist/components/form/inputs/DatePicker.vue.d.ts +4 -0
  9. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  10. package/dist/components/form/inputs/FileUpload.vue.d.ts +6 -2
  11. package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
  12. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
  13. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  14. package/dist/components/form/inputs/TextInput.vue.d.ts +0 -3
  15. package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
  16. package/dist/components/layout/Tabs.vue.d.ts +6 -2
  17. package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
  18. package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
  19. package/dist/index.cjs +239 -137
  20. package/dist/index.mjs +240 -138
  21. package/dist/plugins/bagel.d.ts +3 -0
  22. package/dist/plugins/bagel.d.ts.map +1 -1
  23. package/dist/style.css +109 -91
  24. package/dist/utils/BagelFormUtils.d.ts +1 -0
  25. package/dist/utils/BagelFormUtils.d.ts.map +1 -1
  26. package/dist/utils/index.d.ts +1 -0
  27. package/dist/utils/index.d.ts.map +1 -1
  28. package/dist/utils/lang.d.ts +7 -0
  29. package/dist/utils/lang.d.ts.map +1 -0
  30. package/package.json +1 -1
  31. package/src/components/Alert.vue +4 -2
  32. package/src/components/TableSchema.vue +19 -9
  33. package/src/components/form/BglField.vue +5 -3
  34. package/src/components/form/BglForm.vue +13 -9
  35. package/src/components/form/inputs/DatePicker.vue +8 -2
  36. package/src/components/form/inputs/FileUpload.vue +54 -23
  37. package/src/components/form/inputs/RadioPillsInput.vue +9 -9
  38. package/src/components/form/inputs/SelectInput.vue +36 -31
  39. package/src/components/form/inputs/TextInput.vue +1 -1
  40. package/src/components/layout/Tabs.vue +14 -5
  41. package/src/components/layout/TabsNav.vue +34 -14
  42. package/src/plugins/bagel.ts +13 -4
  43. package/src/utils/BagelFormUtils.ts +44 -10
  44. package/src/utils/index.ts +2 -0
  45. package/src/utils/lang.ts +39 -0
@@ -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
- host: string
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 = options?.i18nT || ((key?: string) => key);
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 = string | number | Record<string, any> | { label: string, value: string | number };
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(id: string, label?: string, options?: RichTextOptions) {
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(id: string, label?: string, options?: TextInputOptions): Field {
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: { type: options?.type, pattern: options?.pattern, multiline: options?.multiline },
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(id: string, label?: string, options?: Option[] | (() => Option[]), config?: SlctInputOptions): Field {
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: { disabled: config?.disabled, searchable: config?.searchable, multiselect: config?.multiselect },
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(id: string, label?: string, options?: NumFieldOptions): Field {
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(id: string, label?: string, options?: NumFieldOptions): Field {
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 mt-1',
129
+ class: 'flex gap-1 m_block',
96
130
  children,
97
131
  };
98
132
  }
@@ -61,3 +61,5 @@ export const denullify = (itemData?: Record<string, any>, fieldID?: string) => (
61
61
  export { formatString } from './strings';
62
62
 
63
63
  export * as bagelFormUtils from './BagelFormUtils';
64
+
65
+ export { useLang } from './lang';
@@ -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
+ }