@katlux/toolkit 0.1.1-alpha.92 → 0.1.1-alpha.95

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 (60) hide show
  1. package/dist/compiled/composables/locales.mjs +554 -0
  2. package/dist/compiled/composables/useKatluxI18n.mjs +56 -0
  3. package/dist/compiled/composables/useKatluxI18n.spec.mjs +10 -0
  4. package/dist/compiled/composables/usePresetComponent.mjs +6 -12
  5. package/dist/module.cjs +2 -1
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +2 -1
  8. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
  9. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
  10. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  11. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  12. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  13. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -2
  14. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -2
  15. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -1
  16. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +8 -8
  17. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +8 -8
  18. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  19. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -2
  20. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -2
  21. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
  22. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
  23. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +9 -9
  24. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +9 -9
  25. package/dist/runtime/components/KGantt/KGantt.logic.d.ts +4 -4
  26. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
  27. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
  28. package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +6 -6
  29. package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +6 -6
  30. package/dist/runtime/components/KIcon/KIcon.logic.d.ts +3 -3
  31. package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +1 -1
  32. package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +1 -1
  33. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  34. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  35. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
  36. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
  37. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +1 -1
  38. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
  39. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
  40. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
  41. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  42. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  43. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
  44. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
  45. package/dist/runtime/composables/locales.d.ts +28 -0
  46. package/dist/runtime/composables/locales.js +554 -0
  47. package/dist/runtime/composables/useKatluxI18n.d.ts +15 -0
  48. package/dist/runtime/composables/useKatluxI18n.js +56 -0
  49. package/dist/runtime/composables/usePresetComponent.d.ts +3 -9
  50. package/dist/runtime/composables/usePresetComponent.js +6 -12
  51. package/dist/runtime/plugins/PresetPlugin.js +11 -12
  52. package/dist/runtime/presets/default/components/KAlert/KAlert.vue +2 -3
  53. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +2 -2
  54. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +2 -2
  55. package/dist/runtime/presets/default/components/KModal/KModal.vue +2 -2
  56. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +2 -2
  57. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -2
  58. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +2 -2
  59. package/dist/runtime/presets/default/components/KTree/KTree.vue +2 -2
  60. package/package.json +2 -1
@@ -1,15 +1,11 @@
1
- import { computed, defineAsyncComponent } from "vue";
2
- import { useAppConfig, useState } from "#app";
3
- export function usePresetLoadersRegistry() {
4
- return useState("katlux-preset-loaders-registry", () => ({}));
5
- }
1
+ import { computed, defineAsyncComponent, shallowReactive } from "vue";
2
+ import { useAppConfig } from "#app";
3
+ const _loadersRegistry = shallowReactive({});
6
4
  export function registerPresetComponents(presetName, loaders) {
7
- const registry = usePresetLoadersRegistry();
8
- registry.value[presetName] = loaders;
5
+ _loadersRegistry[presetName] = loaders;
9
6
  }
10
7
  export function usePresetComponent(componentBaseName, defaultComponent) {
11
8
  const appConfig = useAppConfig();
12
- const registry = usePresetLoadersRegistry();
13
9
  const presetStack = computed(() => {
14
10
  const raw = appConfig.katluxToolkit?.activePreset;
15
11
  const list = Array.isArray(raw) ? raw : raw ? [raw] : [];
@@ -19,7 +15,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
19
15
  let loader;
20
16
  for (const presetName of presetStack.value) {
21
17
  if (presetName === "default") break;
22
- const externalLoaders = registry.value[presetName];
18
+ const externalLoaders = _loadersRegistry[presetName];
23
19
  if (externalLoaders) {
24
20
  const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
25
21
  loader = externalLoaders[key];
@@ -47,9 +43,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
47
43
  if (loader) break;
48
44
  }
49
45
  }
50
- if (loader) {
51
- break;
52
- }
46
+ if (loader) break;
53
47
  }
54
48
  if (!loader) {
55
49
  return defaultComponent;
@@ -1,22 +1,21 @@
1
- import { defineNuxtPlugin, useHead, useState } from "#app";
2
- import { watch } from "vue";
1
+ import { defineNuxtPlugin, useHead, useAppConfig, useState } from "#app";
2
+ import { ref, watch } from "vue";
3
3
  import { PresetResolver } from "../utils/PresetResolver.js";
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
5
  const resolver = new PresetResolver();
6
+ const appConfig = useAppConfig();
6
7
  const activePresetState = useState("katlux-active-preset-state", () => resolver.getActivePreset());
7
- const activePreset = activePresetState.value;
8
- const updateRootAttribute = (preset) => {
9
- useHead({
10
- htmlAttrs: {
11
- "data-template": preset
12
- }
13
- });
14
- };
15
- updateRootAttribute(activePreset);
8
+ const resolvePresetString = (val) => Array.isArray(val) ? val[0] ?? "default" : val;
9
+ const currentPreset = ref(resolvePresetString(activePresetState.value));
10
+ useHead({
11
+ htmlAttrs: {
12
+ "data-template": currentPreset
13
+ }
14
+ });
16
15
  if (appConfig.katluxToolkit) {
17
16
  watch(() => appConfig.katluxToolkit?.activePreset, (newPreset) => {
18
17
  if (newPreset) {
19
- updateRootAttribute(newPreset);
18
+ currentPreset.value = resolvePresetString(newPreset);
20
19
  resolver.setActivePreset(newPreset);
21
20
  }
22
21
  });
@@ -12,14 +12,13 @@ Transition(name="k-alert-fade")
12
12
 
13
13
  <script lang="ts" setup>
14
14
  import type { KAlertProps } from '../../../../components/KAlert/KAlert.logic'
15
- import { useKAlertLogic } from '../../../../components/KAlert/KAlert.logic'
15
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
16
16
 
17
17
  const props = defineProps<KAlertProps>()
18
18
  const emit = defineEmits<{ dismiss: [] }>()
19
19
  const { visible, dismiss, icon } = useKAlertLogic(props, () => emit('dismiss'))
20
20
 
21
- const nuxtApp = useNuxtApp?.()
22
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
21
+ const { t } = useKatluxI18n()
23
22
  </script>
24
23
 
25
24
  <style lang="scss" scoped>
@@ -25,9 +25,9 @@
25
25
  import { computed } from 'vue'
26
26
  import { CFlatClientDataProvider } from '@katlux/providers'
27
27
  import type { IKDatatableAction } from '@katlux/providers'
28
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
28
29
 
29
- const nuxtApp = useNuxtApp?.()
30
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
30
+ const { t } = useKatluxI18n()
31
31
 
32
32
  const props = defineProps<{
33
33
  bulkActions: IKDatatableAction[]
@@ -59,9 +59,9 @@
59
59
  import { computed } from 'vue'
60
60
  import { ADataProvider } from '@katlux/providers'
61
61
  import type { IKDatatableAction } from '@katlux/providers'
62
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
62
63
 
63
- const nuxtApp = useNuxtApp?.()
64
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
64
+ const { t } = useKatluxI18n()
65
65
 
66
66
  const props = defineProps<{
67
67
  dataProvider: ADataProvider
@@ -11,9 +11,9 @@ dialog.k-modal(ref="dialogRef" @close="closeModal" @click="handleBackdropClick"
11
11
 
12
12
  <script lang="ts" setup>
13
13
  import { ref, watch, onMounted } from 'vue'
14
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
14
15
 
15
- const nuxtApp = useNuxtApp?.()
16
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
16
+ const { t } = useKatluxI18n()
17
17
 
18
18
  const props = defineProps<{
19
19
  modalId: string
@@ -32,9 +32,9 @@ nav.k-pagination(v-if="totalPages > 1" :aria-label="t('Pagination Navigation')")
32
32
 
33
33
  <script setup lang="ts">
34
34
  import { computed } from 'vue'
35
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
35
36
 
36
- const nuxtApp = useNuxtApp?.()
37
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
37
+ const { t } = useKatluxI18n()
38
38
 
39
39
  const props = defineProps<{
40
40
  dp: any
@@ -22,9 +22,9 @@
22
22
 
23
23
  <script lang="ts" setup>
24
24
  import { ref, onMounted, onUnmounted, watch, nextTick } from 'vue'
25
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
25
26
 
26
- const nuxtApp = useNuxtApp?.()
27
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
27
+ const { t } = useKatluxI18n()
28
28
 
29
29
  const props = defineProps<{
30
30
  items: any[]
@@ -9,9 +9,9 @@
9
9
 
10
10
  <script lang="ts" setup>
11
11
  import { computed, useAttrs } from 'vue'
12
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
12
13
 
13
- const nuxtApp = useNuxtApp?.()
14
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
14
+ const { t } = useKatluxI18n()
15
15
 
16
16
  defineOptions({
17
17
  inheritAttrs: false
@@ -50,9 +50,9 @@
50
50
 
51
51
  <script lang="ts" setup>
52
52
  import { computed, type Ref } from 'vue'
53
+ import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
53
54
 
54
- const nuxtApp = useNuxtApp?.()
55
- const t = (key: string) => nuxtApp?.$t ? nuxtApp.$t(key) : key
55
+ const { t } = useKatluxI18n()
56
56
 
57
57
  const props = defineProps<{
58
58
  visibleRows: any[] // Rows with __treeNode attached
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.92",
3
+ "version": "0.1.1-alpha.95",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -40,6 +40,7 @@
40
40
  "dependencies": {
41
41
  "@katlux/providers": "*",
42
42
  "@nuxt/kit": "^3.12.0",
43
+ "@nuxtjs/i18n": "^10.4.0",
43
44
  "pug": "^3.0.0",
44
45
  "sass": "^1.80.0"
45
46
  },