@bagelink/vue 0.0.423 → 0.0.431

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 (48) hide show
  1. package/dist/components/AccordionItem.vue.d.ts +3 -2
  2. package/dist/components/AccordionItem.vue.d.ts.map +1 -1
  3. package/dist/components/Alert.vue.d.ts +4 -1
  4. package/dist/components/Alert.vue.d.ts.map +1 -1
  5. package/dist/components/Avatar.vue.d.ts.map +1 -1
  6. package/dist/components/Carousel.vue.d.ts +8 -2
  7. package/dist/components/Carousel.vue.d.ts.map +1 -1
  8. package/dist/components/Modal.vue.d.ts.map +1 -1
  9. package/dist/components/TableSchema.vue.d.ts +2 -5
  10. package/dist/components/TableSchema.vue.d.ts.map +1 -1
  11. package/dist/components/form/inputs/DatePicker.vue.d.ts +4 -0
  12. package/dist/components/form/inputs/DatePicker.vue.d.ts.map +1 -1
  13. package/dist/components/form/inputs/FileUpload.vue.d.ts +6 -2
  14. package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
  15. package/dist/components/form/inputs/RadioPillsInput.vue.d.ts.map +1 -1
  16. package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
  17. package/dist/components/form/inputs/TextInput.vue.d.ts +0 -3
  18. package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
  19. package/dist/components/layout/Tabs.vue.d.ts +6 -2
  20. package/dist/components/layout/Tabs.vue.d.ts.map +1 -1
  21. package/dist/components/layout/TabsNav.vue.d.ts +6 -2
  22. package/dist/components/layout/TabsNav.vue.d.ts.map +1 -1
  23. package/dist/index.cjs +256 -155
  24. package/dist/index.mjs +257 -156
  25. package/dist/plugins/bagel.d.ts +3 -0
  26. package/dist/plugins/bagel.d.ts.map +1 -1
  27. package/dist/style.css +194 -172
  28. package/dist/utils/index.d.ts +1 -0
  29. package/dist/utils/index.d.ts.map +1 -1
  30. package/dist/utils/lang.d.ts +7 -0
  31. package/dist/utils/lang.d.ts.map +1 -0
  32. package/package.json +1 -1
  33. package/src/components/AccordionItem.vue +57 -43
  34. package/src/components/Alert.vue +4 -2
  35. package/src/components/Avatar.vue +1 -1
  36. package/src/components/Carousel.vue +2 -2
  37. package/src/components/Modal.vue +4 -2
  38. package/src/components/TableSchema.vue +19 -9
  39. package/src/components/form/inputs/DatePicker.vue +8 -2
  40. package/src/components/form/inputs/FileUpload.vue +54 -23
  41. package/src/components/form/inputs/RadioPillsInput.vue +5 -4
  42. package/src/components/form/inputs/SelectInput.vue +212 -204
  43. package/src/components/form/inputs/TextInput.vue +1 -1
  44. package/src/components/layout/Tabs.vue +14 -5
  45. package/src/components/layout/TabsNav.vue +40 -15
  46. package/src/plugins/bagel.ts +13 -4
  47. package/src/utils/index.ts +2 -0
  48. 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
  };
@@ -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
+ }