@mouseless/baked 1.0.2 → 1.1.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.
Files changed (172) hide show
  1. package/dist/module.d.mts +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +34 -23
  4. package/dist/runtime/components/AwaitLoading.d.ts +14 -0
  5. package/dist/runtime/components/AwaitLoading.js +27 -0
  6. package/dist/runtime/components/Bake.d.vue.ts +25 -11
  7. package/dist/runtime/components/Bake.vue +87 -16
  8. package/dist/runtime/components/Bake.vue.d.ts +25 -11
  9. package/dist/runtime/components/Button.d.vue.ts +27 -0
  10. package/dist/runtime/components/Button.vue +26 -0
  11. package/dist/runtime/components/Button.vue.d.ts +27 -0
  12. package/dist/runtime/components/CardLink.d.vue.ts +11 -9
  13. package/dist/runtime/components/CardLink.vue +1 -2
  14. package/dist/runtime/components/CardLink.vue.d.ts +11 -9
  15. package/dist/runtime/components/Composite.d.vue.ts +13 -0
  16. package/dist/runtime/components/Composite.vue +17 -0
  17. package/dist/runtime/components/Composite.vue.d.ts +13 -0
  18. package/dist/runtime/components/Conditional.d.vue.ts +23 -0
  19. package/dist/runtime/components/Conditional.vue +31 -0
  20. package/dist/runtime/components/Conditional.vue.d.ts +23 -0
  21. package/dist/runtime/components/Contents.d.vue.ts +40 -0
  22. package/dist/runtime/components/Contents.vue +25 -0
  23. package/dist/runtime/components/Contents.vue.d.ts +40 -0
  24. package/dist/runtime/components/DataPanel.d.vue.ts +13 -11
  25. package/dist/runtime/components/DataPanel.vue +35 -36
  26. package/dist/runtime/components/DataPanel.vue.d.ts +13 -11
  27. package/dist/runtime/components/DataTable.d.vue.ts +19 -9
  28. package/dist/runtime/components/DataTable.vue +69 -55
  29. package/dist/runtime/components/DataTable.vue.d.ts +19 -9
  30. package/dist/runtime/components/DefaultLayout.d.vue.ts +11 -9
  31. package/dist/runtime/components/DefaultLayout.vue +1 -2
  32. package/dist/runtime/components/DefaultLayout.vue.d.ts +11 -9
  33. package/dist/runtime/components/DeferredTabContent.d.vue.ts +26 -8
  34. package/dist/runtime/components/DeferredTabContent.vue +4 -3
  35. package/dist/runtime/components/DeferredTabContent.vue.d.ts +26 -8
  36. package/dist/runtime/components/Dialog.d.vue.ts +17 -0
  37. package/dist/runtime/components/Dialog.vue +57 -0
  38. package/dist/runtime/components/Dialog.vue.d.ts +17 -0
  39. package/dist/runtime/components/Error.vue +6 -0
  40. package/dist/runtime/components/ErrorPage.d.vue.ts +20 -8
  41. package/dist/runtime/components/ErrorPage.vue.d.ts +20 -8
  42. package/dist/runtime/components/Fieldset.d.vue.ts +21 -0
  43. package/dist/runtime/components/Fieldset.vue +38 -0
  44. package/dist/runtime/components/Fieldset.vue.d.ts +21 -0
  45. package/dist/runtime/components/Filter.d.vue.ts +23 -9
  46. package/dist/runtime/components/Filter.vue +5 -7
  47. package/dist/runtime/components/Filter.vue.d.ts +23 -9
  48. package/dist/runtime/components/FormPage.d.vue.ts +17 -0
  49. package/dist/runtime/components/FormPage.vue +48 -0
  50. package/dist/runtime/components/FormPage.vue.d.ts +17 -0
  51. package/dist/runtime/components/Header.d.vue.ts +19 -9
  52. package/dist/runtime/components/Header.vue +27 -29
  53. package/dist/runtime/components/Header.vue.d.ts +19 -9
  54. package/dist/runtime/components/Icon.d.vue.ts +11 -9
  55. package/dist/runtime/components/Icon.vue +1 -2
  56. package/dist/runtime/components/Icon.vue.d.ts +11 -9
  57. package/dist/runtime/components/Input.d.vue.ts +25 -0
  58. package/dist/runtime/components/Input.vue +78 -0
  59. package/dist/runtime/components/Input.vue.d.ts +25 -0
  60. package/dist/runtime/components/InputNumber.d.vue.ts +25 -0
  61. package/dist/runtime/components/InputNumber.vue +35 -0
  62. package/dist/runtime/components/InputNumber.vue.d.ts +25 -0
  63. package/dist/runtime/components/InputText.d.vue.ts +25 -0
  64. package/dist/runtime/components/InputText.vue +31 -0
  65. package/dist/runtime/components/InputText.vue.d.ts +25 -0
  66. package/dist/runtime/components/Inputs.d.vue.ts +29 -0
  67. package/dist/runtime/components/Inputs.vue +50 -0
  68. package/dist/runtime/components/Inputs.vue.d.ts +29 -0
  69. package/dist/runtime/components/LanguageSwitcher.d.vue.ts +1 -9
  70. package/dist/runtime/components/LanguageSwitcher.vue +0 -4
  71. package/dist/runtime/components/LanguageSwitcher.vue.d.ts +1 -9
  72. package/dist/runtime/components/Layout.vue +9 -5
  73. package/dist/runtime/components/Logo.d.vue.ts +11 -7
  74. package/dist/runtime/components/Logo.vue.d.ts +11 -7
  75. package/dist/runtime/components/MenuPage.d.vue.ts +11 -9
  76. package/dist/runtime/components/MenuPage.vue +28 -29
  77. package/dist/runtime/components/MenuPage.vue.d.ts +11 -9
  78. package/dist/runtime/components/Message.d.vue.ts +19 -9
  79. package/dist/runtime/components/Message.vue +10 -14
  80. package/dist/runtime/components/Message.vue.d.ts +19 -9
  81. package/dist/runtime/components/MissingComponent.d.vue.ts +21 -0
  82. package/dist/runtime/components/MissingComponent.vue +174 -0
  83. package/dist/runtime/components/MissingComponent.vue.d.ts +21 -0
  84. package/dist/runtime/components/ModalLayout.d.vue.ts +10 -15
  85. package/dist/runtime/components/ModalLayout.vue +0 -7
  86. package/dist/runtime/components/ModalLayout.vue.d.ts +10 -15
  87. package/dist/runtime/components/Money.d.vue.ts +11 -9
  88. package/dist/runtime/components/Money.vue +10 -15
  89. package/dist/runtime/components/Money.vue.d.ts +11 -9
  90. package/dist/runtime/components/NavLink.d.vue.ts +19 -9
  91. package/dist/runtime/components/NavLink.vue +34 -20
  92. package/dist/runtime/components/NavLink.vue.d.ts +19 -9
  93. package/dist/runtime/components/Number.d.vue.ts +11 -9
  94. package/dist/runtime/components/Number.vue +10 -15
  95. package/dist/runtime/components/Number.vue.d.ts +11 -9
  96. package/dist/runtime/components/Page.vue +7 -4
  97. package/dist/runtime/components/PageTitle.d.vue.ts +15 -9
  98. package/dist/runtime/components/PageTitle.vue +39 -8
  99. package/dist/runtime/components/PageTitle.vue.d.ts +15 -9
  100. package/dist/runtime/components/PersistentPopover.vue +1 -1
  101. package/dist/runtime/components/ProvideParentContext.d.vue.ts +28 -0
  102. package/dist/runtime/components/ProvideParentContext.vue +14 -0
  103. package/dist/runtime/components/ProvideParentContext.vue.d.ts +28 -0
  104. package/dist/runtime/components/Rate.d.vue.ts +11 -9
  105. package/dist/runtime/components/Rate.vue +6 -11
  106. package/dist/runtime/components/Rate.vue.d.ts +11 -9
  107. package/dist/runtime/components/Select.d.vue.ts +31 -9
  108. package/dist/runtime/components/Select.vue +30 -49
  109. package/dist/runtime/components/Select.vue.d.ts +31 -9
  110. package/dist/runtime/components/SelectButton.d.vue.ts +31 -9
  111. package/dist/runtime/components/SelectButton.vue +21 -36
  112. package/dist/runtime/components/SelectButton.vue.d.ts +31 -9
  113. package/dist/runtime/components/SideMenu.d.vue.ts +19 -9
  114. package/dist/runtime/components/SideMenu.vue.d.ts +19 -9
  115. package/dist/runtime/components/SideMenuItem.d.vue.ts +19 -9
  116. package/dist/runtime/components/SideMenuItem.vue.d.ts +19 -9
  117. package/dist/runtime/components/SimpleForm.d.vue.ts +17 -0
  118. package/dist/runtime/components/SimpleForm.vue +108 -0
  119. package/dist/runtime/components/SimpleForm.vue.d.ts +17 -0
  120. package/dist/runtime/components/SimplePage.d.vue.ts +13 -0
  121. package/dist/runtime/components/SimplePage.vue +19 -0
  122. package/dist/runtime/components/SimplePage.vue.d.ts +13 -0
  123. package/dist/runtime/components/TabbedPage.d.vue.ts +13 -0
  124. package/dist/runtime/components/{ReportPage.vue → TabbedPage.vue} +47 -65
  125. package/dist/runtime/components/TabbedPage.vue.d.ts +13 -0
  126. package/dist/runtime/components/Text.d.vue.ts +19 -9
  127. package/dist/runtime/components/Text.vue +9 -13
  128. package/dist/runtime/components/Text.vue.d.ts +19 -9
  129. package/dist/runtime/composables/useActionExecuter.d.ts +7 -0
  130. package/dist/runtime/composables/useActionExecuter.js +108 -0
  131. package/dist/runtime/composables/useConstraintEvaluator.d.ts +7 -0
  132. package/dist/runtime/composables/useConstraintEvaluator.js +58 -0
  133. package/dist/runtime/composables/useContext.d.ts +13 -8
  134. package/dist/runtime/composables/useContext.js +42 -18
  135. package/dist/runtime/composables/useDataFetcher.d.ts +6 -6
  136. package/dist/runtime/composables/useDataFetcher.js +66 -40
  137. package/dist/runtime/composables/useEvents.d.ts +7 -0
  138. package/dist/runtime/composables/useEvents.js +33 -0
  139. package/dist/runtime/composables/useFormat.d.ts +0 -1
  140. package/dist/runtime/composables/useFormat.js +0 -13
  141. package/dist/runtime/composables/useLoginRedirect.d.ts +1 -1
  142. package/dist/runtime/composables/useLoginRedirect.js +2 -2
  143. package/dist/runtime/composables/useNuxtError.d.ts +1 -1
  144. package/dist/runtime/composables/useNuxtError.js +2 -2
  145. package/dist/runtime/composables/useNuxtRoute.d.ts +1 -1
  146. package/dist/runtime/composables/useNuxtRoute.js +3 -3
  147. package/dist/runtime/composables/usePathBuilder.d.ts +3 -0
  148. package/dist/runtime/composables/usePathBuilder.js +18 -0
  149. package/dist/runtime/composables/useReactionHandler.d.ts +6 -0
  150. package/dist/runtime/composables/useReactionHandler.js +104 -0
  151. package/dist/runtime/composables/useRedirect.d.ts +3 -0
  152. package/dist/runtime/composables/useRedirect.js +17 -0
  153. package/dist/runtime/composables/useToken.js +2 -2
  154. package/dist/runtime/plugins/auth.js +16 -3
  155. package/dist/runtime/plugins/baked.js +23 -0
  156. package/dist/runtime/plugins/fetch.js +2 -2
  157. package/package.json +18 -18
  158. package/dist/runtime/components/None.d.vue.ts +0 -11
  159. package/dist/runtime/components/None.vue +0 -25
  160. package/dist/runtime/components/None.vue.d.ts +0 -11
  161. package/dist/runtime/components/Parameters.d.vue.ts +0 -11
  162. package/dist/runtime/components/Parameters.vue +0 -61
  163. package/dist/runtime/components/Parameters.vue.d.ts +0 -11
  164. package/dist/runtime/components/QueryParameters.d.vue.ts +0 -11
  165. package/dist/runtime/components/QueryParameters.vue +0 -109
  166. package/dist/runtime/components/QueryParameters.vue.d.ts +0 -11
  167. package/dist/runtime/components/ReportPage.d.vue.ts +0 -11
  168. package/dist/runtime/components/ReportPage.vue.d.ts +0 -11
  169. package/dist/runtime/composables/useConditional.d.ts +0 -3
  170. package/dist/runtime/composables/useConditional.js +0 -15
  171. package/dist/runtime/composables/useQuery.d.ts +0 -3
  172. package/dist/runtime/composables/useQuery.js +0 -13
package/dist/module.d.mts CHANGED
@@ -2,6 +2,7 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { NuxtI18nOptions } from '@nuxtjs/i18n';
3
3
 
4
4
  interface ModuleOptions {
5
+ apiBaseURL: String;
5
6
  components?: Components;
6
7
  composables: Composables;
7
8
  primevue: PrimeVueOptions;
@@ -23,7 +24,6 @@ interface Composables {
23
24
  useFormat?: UseFormatOptions;
24
25
  }
25
26
  interface UseDataFetcherOptions {
26
- baseURL: String;
27
27
  retry?: RetryOptions | Boolean;
28
28
  }
29
29
  interface RetryOptions {
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mouseless/baked",
3
3
  "configKey": "baked",
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { createResolver, defineNuxtModule, addComponentsDir, addImportsDir, addPlugin } from '@nuxt/kit';
2
2
  import { pathToFileURL } from 'url';
3
+ import { join } from 'path';
3
4
 
4
- const resolver = createResolver(import.meta.url);
5
- const module = defineNuxtModule({
5
+ const metaUrlResolver = createResolver(import.meta.url);
6
+ const module$1 = defineNuxtModule({
6
7
  meta: {
7
8
  name: "@mouseless/baked",
8
9
  configKey: "baked"
@@ -10,7 +11,7 @@ const module = defineNuxtModule({
10
11
  defaults: {},
11
12
  moduleDependencies: {
12
13
  "@nuxtjs/i18n": {
13
- version: "10.1.1",
14
+ version: "10.2.1",
14
15
  defaults: {
15
16
  strategy: "no_prefix",
16
17
  detectBrowserLanguage: {
@@ -23,12 +24,12 @@ const module = defineNuxtModule({
23
24
  version: "6.14.0",
24
25
  defaults: {
25
26
  exposeConfig: true,
26
- cssPath: resolver.resolve("./runtime/assets/tailwind.css"),
27
+ cssPath: metaUrlResolver.resolve("./runtime/assets/tailwind.css"),
27
28
  config: {
28
29
  content: {
29
30
  files: [
30
- resolver.resolve("./runtime/components/**/*.{vue,mjs,ts}"),
31
- resolver.resolve("./runtime/*.{mjs,js,ts}")
31
+ metaUrlResolver.resolve("./runtime/components/**/*.{vue,mjs,ts}"),
32
+ metaUrlResolver.resolve("./runtime/*.{mjs,js,ts}")
32
33
  ]
33
34
  }
34
35
  }
@@ -45,8 +46,11 @@ const module = defineNuxtModule({
45
46
  if (process.env.npm_lifecycle_script?.includes("nuxt-module-build")) {
46
47
  return;
47
48
  }
48
- const entryProjectResolver = createResolver(_nuxt.options.rootDir);
49
- const appJsonPath = pathToFileURL(entryProjectResolver.resolve("./.baked/app.json"));
49
+ const resolver = {
50
+ metaUrl: metaUrlResolver,
51
+ rootDir: createResolver(_nuxt.options.rootDir)
52
+ };
53
+ const appJsonPath = pathToFileURL(resolver.rootDir.resolve("./.baked/app.json"));
50
54
  const app = (await import(appJsonPath.href, { with: { type: 'json' } })).default;
51
55
  _options.composables.useBreakpoints ||= {};
52
56
  _options.composables.useBreakpoints.screens ||= {
@@ -63,33 +67,34 @@ const module = defineNuxtModule({
63
67
  _nuxt.options.runtimeConfig.public.primevue = _options.primevue;
64
68
  _nuxt.options.runtimeConfig.public.components = _options.components;
65
69
  _nuxt.options.runtimeConfig.public.composables = _options.composables;
70
+ _nuxt.options.runtimeConfig.public.apiBaseURL = _options.apiBaseURL;
66
71
  _nuxt.options.css.push("primeicons/primeicons.css");
67
- _nuxt.options.css.push(resolver.resolve("./runtime/assets/overrides.css"));
72
+ _nuxt.options.css.push(resolver.metaUrl.resolve("./runtime/assets/overrides.css"));
68
73
  _nuxt.options.devtools = { enabled: false };
69
74
  _nuxt.options.experimental.payloadExtraction = false;
70
75
  _nuxt.options.features.inlineStyles = false;
71
76
  _nuxt.options.ssr = false;
72
- addComponentsDir({ path: resolver.resolve("./runtime/components") });
73
- addImportsDir(resolver.resolve("./runtime/composables"));
77
+ addComponentsDir({ path: resolver.metaUrl.resolve("./runtime/components") });
78
+ addImportsDir(resolver.metaUrl.resolve("./runtime/composables"));
74
79
  for (const plugin of app?.plugins ?? []) {
75
80
  _nuxt.options.runtimeConfig.public[plugin.name] = plugin;
76
- addPlugin(resolver.resolve(`./runtime/plugins/${plugin.name}`));
81
+ addPlugin(resolver[camelize(plugin.resolver ?? "MetaUrl")].resolve(join(plugin.basePath, plugin.name)));
77
82
  }
78
- addPlugin(resolver.resolve("./runtime/plugins/mutex"));
79
- addPlugin(resolver.resolve("./runtime/plugins/toast"));
80
- addPlugin(resolver.resolve("./runtime/plugins/trailingSlash"));
81
- addPlugin(resolver.resolve("./runtime/plugins/baked"));
82
- addPlugin(resolver.resolve("./runtime/plugins/primeVue"));
83
- addPlugin(resolver.resolve("./runtime/plugins/fetch"), {});
83
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/mutex"));
84
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/toast"));
85
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/trailingSlash"));
86
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/baked"));
87
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/primeVue"));
88
+ addPlugin(resolver.metaUrl.resolve("./runtime/plugins/fetch"), {});
84
89
  _nuxt.options.vite.optimizeDeps ||= {};
85
90
  _nuxt.options.vite.optimizeDeps.noDiscovery = true;
86
91
  _nuxt.options.i18n = {
87
- vueI18n: entryProjectResolver.resolve("./i18n.config.ts"),
88
- langDir: entryProjectResolver.resolve("./"),
92
+ vueI18n: resolver.rootDir.resolve("./i18n.config.ts"),
93
+ langDir: resolver.rootDir.resolve("./"),
89
94
  locales: app?.i18n?.supportedLanguages?.map((i) => {
90
95
  const files = [
91
- entryProjectResolver.resolve(`./.baked/locale.${i.code}.json`),
92
- entryProjectResolver.resolve(`./locales/locale.${i.code}.json`)
96
+ resolver.rootDir.resolve(`./.baked/locale.${i.code}.json`),
97
+ resolver.rootDir.resolve(`./locales/locale.${i.code}.json`)
93
98
  ];
94
99
  return {
95
100
  code: i.code,
@@ -115,5 +120,11 @@ const module = defineNuxtModule({
115
120
  };
116
121
  }
117
122
  });
123
+ function camelize(str) {
124
+ if (!str) {
125
+ return str;
126
+ }
127
+ return `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
128
+ }
118
129
 
119
- export { module as default };
130
+ export { module$1 as default };
@@ -0,0 +1,14 @@
1
+ declare namespace _default {
2
+ namespace props {
3
+ namespace skeleton {
4
+ export let type: ObjectConstructor;
5
+ export let required: boolean;
6
+ function _default(): void;
7
+ export { _default as default };
8
+ }
9
+ }
10
+ function setup(): (props: any) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
11
+ [key: string]: any;
12
+ }> | undefined;
13
+ }
14
+ export default _default;
@@ -0,0 +1,27 @@
1
+ import { h, useSlots } from "vue";
2
+ import { Skeleton } from "primevue";
3
+ import { useContext } from "#imports";
4
+
5
+ export default {
6
+ props: {
7
+ skeleton: { type: Object, required: false, default: () => { } }
8
+ },
9
+ setup() {
10
+ const context = useContext();
11
+ const slots = useSlots();
12
+
13
+ const loading = context.injectLoading();
14
+
15
+ return props => {
16
+ if(loading.value) {
17
+ if(slots.loading) {
18
+ return slots.loading()[0];
19
+ }
20
+
21
+ return h(Skeleton, props.skeleton);
22
+ }
23
+
24
+ return slots.default()[0];
25
+ };
26
+ }
27
+ };
@@ -4,17 +4,31 @@ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
4
  type __VLS_WithSlots<T, S> = T & (new () => {
5
5
  $slots: S;
6
6
  });
7
- declare const __VLS_base: import("vue").DefineComponent<{}, {
8
- $emit: typeof emit;
9
- $props: Partial<typeof __VLS_props>;
10
- name: string;
11
- descriptor: any;
12
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ name: {
9
+ type: StringConstructor;
10
+ required: true;
11
+ };
12
+ descriptor: {
13
+ type: null;
14
+ required: true;
15
+ };
16
+ modelValue: {
17
+ type: import("vue").PropType<any>;
18
+ };
19
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ name: {
21
+ type: StringConstructor;
22
+ required: true;
23
+ };
24
+ descriptor: {
25
+ type: null;
26
+ required: true;
27
+ };
28
+ modelValue: {
29
+ type: import("vue").PropType<any>;
30
+ };
31
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
32
  type __VLS_Slots = {
14
33
  default?: ((props: {}) => any) | undefined;
15
34
  };
16
- declare const emit: (event: "loaded", ...args: any[]) => void;
17
- declare const __VLS_props: {
18
- readonly name: string;
19
- readonly descriptor: any;
20
- };
@@ -1,10 +1,8 @@
1
1
  <template>
2
2
  <component
3
- :is="is"
3
+ :is="render()"
4
+ v-if="visible"
4
5
  :key="loading"
5
- v-model="model"
6
- :schema="descriptor.schema"
7
- :data
8
6
  :class="classes"
9
7
  >
10
8
  <slot v-if="$slots.default" />
@@ -12,39 +10,112 @@
12
10
  </template>
13
11
 
14
12
  <script setup>
15
- import { onMounted, ref } from "vue";
16
- import { useComponentResolver, useContext, useDataFetcher, useFormat } from "#imports";
13
+ import { h, nextTick, onBeforeUnmount, onMounted, ref } from "vue";
14
+ import { useActionExecuter, useComponentResolver, useContext, useDataFetcher, useFormat, useReactionHandler } from "#imports";
15
+ const actionExecuter = useActionExecuter();
17
16
  const componentResolver = useComponentResolver();
18
17
  const context = useContext();
19
18
  const dataFetcher = useDataFetcher();
20
19
  const { asClasses } = useFormat();
20
+ const reactionHandler = useReactionHandler();
21
21
  const { name, descriptor } = defineProps({
22
22
  name: { type: String, required: true },
23
23
  descriptor: { type: null, required: true }
24
24
  });
25
25
  const model = defineModel({ type: null });
26
26
  const emit = defineEmits(["loaded"]);
27
- context.providePath(name);
28
- context.provideDataDescriptor(descriptor.data);
29
- const is = componentResolver.resolve(descriptor.type, "None");
30
- const injectedData = context.injectData();
31
- const data = ref(dataFetcher.get({ data: descriptor.data, injectedData }));
27
+ const parentPath = context.injectPath();
28
+ const path = parentPath && parentPath !== "" ? `${parentPath}/${name}` : name;
29
+ const events = context.injectEvents();
30
+ const contextData = context.injectContextData();
31
+ const component = componentResolver.resolve(descriptor.type, "MissingComponent");
32
+ const componentProps = buildComponentProps();
33
+ const data = ref(dataFetcher.get({ data: descriptor.data, contextData }));
32
34
  const shouldLoad = dataFetcher.shouldLoad(descriptor.data?.type);
33
35
  const loading = ref(shouldLoad);
36
+ const executing = ref(false);
37
+ const visible = ref(true);
34
38
  const classes = [`b-component--${descriptor.type}`, ...asClasses(name)];
35
- context.provideData(data, "ParentData");
39
+ let reactions = null;
40
+ context.providePath(path);
41
+ context.provideDataDescriptor(descriptor.data);
42
+ context.provideParentContext({ ...contextData.parent, data });
43
+ context.provideExecuting(executing);
36
44
  if (shouldLoad) {
37
45
  context.provideLoading(loading);
38
46
  }
47
+ if (descriptor.reactions) {
48
+ reactions = reactionHandler.create(`${path}:bake`, {
49
+ reload(success) {
50
+ if (!success) {
51
+ return;
52
+ }
53
+ load();
54
+ },
55
+ show(success) {
56
+ visible.value = success;
57
+ }
58
+ });
59
+ reactions.bind(descriptor.reactions);
60
+ }
39
61
  onMounted(async () => {
40
- if (!shouldLoad) {
41
- return;
62
+ if (shouldLoad) {
63
+ await load();
42
64
  }
65
+ });
66
+ onBeforeUnmount(() => {
67
+ if (descriptor.reactions) {
68
+ reactions.unbind();
69
+ }
70
+ });
71
+ async function load() {
72
+ loading.value = true;
43
73
  data.value = await dataFetcher.fetch({
44
74
  data: descriptor.data,
45
- injectedData
75
+ contextData
46
76
  });
47
77
  loading.value = false;
48
78
  emit("loaded");
49
- });
79
+ }
80
+ function buildComponentProps() {
81
+ const result = {};
82
+ if (descriptor.schema) {
83
+ result.schema = descriptor.schema;
84
+ }
85
+ if (component.emits?.includes("submit")) {
86
+ result.onSubmit = onModelUpdate;
87
+ }
88
+ if (component.props?.modelValue) {
89
+ result["onUpdate:modelValue"] = onModelUpdate;
90
+ nextTick(() => onModelUpdate(model.value));
91
+ }
92
+ return result;
93
+ }
94
+ function render() {
95
+ if (descriptor.data) {
96
+ componentProps.data = data.value;
97
+ }
98
+ if (component.props?.modelValue) {
99
+ componentProps.modelValue = model.value;
100
+ }
101
+ return h(component, componentProps);
102
+ }
103
+ async function onModelUpdate(newModel) {
104
+ if (component.props?.modelValue) {
105
+ model.value = newModel;
106
+ }
107
+ if (!descriptor.action) {
108
+ return;
109
+ }
110
+ try {
111
+ executing.value = true;
112
+ await actionExecuter.execute({
113
+ action: descriptor.action,
114
+ contextData: { ...contextData, model: newModel },
115
+ events
116
+ });
117
+ } finally {
118
+ executing.value = false;
119
+ }
120
+ }
50
121
  </script>
@@ -4,17 +4,31 @@ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
4
  type __VLS_WithSlots<T, S> = T & (new () => {
5
5
  $slots: S;
6
6
  });
7
- declare const __VLS_base: import("vue").DefineComponent<{}, {
8
- $emit: typeof emit;
9
- $props: Partial<typeof __VLS_props>;
10
- name: string;
11
- descriptor: any;
12
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ name: {
9
+ type: StringConstructor;
10
+ required: true;
11
+ };
12
+ descriptor: {
13
+ type: null;
14
+ required: true;
15
+ };
16
+ modelValue: {
17
+ type: import("vue").PropType<any>;
18
+ };
19
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
+ name: {
21
+ type: StringConstructor;
22
+ required: true;
23
+ };
24
+ descriptor: {
25
+ type: null;
26
+ required: true;
27
+ };
28
+ modelValue: {
29
+ type: import("vue").PropType<any>;
30
+ };
31
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
32
  type __VLS_Slots = {
14
33
  default?: ((props: {}) => any) | undefined;
15
34
  };
16
- declare const emit: (event: "loaded", ...args: any[]) => void;
17
- declare const __VLS_props: {
18
- readonly name: string;
19
- readonly descriptor: any;
20
- };
@@ -0,0 +1,27 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: null;
6
+ required: true;
7
+ };
8
+ ready: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ submit: (...args: any[]) => void;
14
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
15
+ schema: {
16
+ type: null;
17
+ required: true;
18
+ };
19
+ ready: {
20
+ type: BooleanConstructor;
21
+ default: boolean;
22
+ };
23
+ }>> & Readonly<{
24
+ onSubmit?: ((...args: any[]) => any) | undefined;
25
+ }>, {
26
+ ready: boolean;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <Button
3
+ :disabled="!ready || executing"
4
+ :loading="executing"
5
+ :icon
6
+ :label="l(label)"
7
+ :rounded
8
+ :severity
9
+ :variant
10
+ @click="$emit('submit')"
11
+ />
12
+ </template>
13
+
14
+ <script setup>
15
+ import { useContext, useLocalization } from "#imports";
16
+ import { Button } from "primevue";
17
+ const context = useContext();
18
+ const { localize: l } = useLocalization();
19
+ const { schema } = defineProps({
20
+ schema: { type: null, required: true },
21
+ ready: { type: Boolean, default: true }
22
+ });
23
+ defineEmits(["submit"]);
24
+ const { icon, label, rounded, severity = "secondary", variant } = schema;
25
+ const executing = context.injectExecuting();
26
+ </script>
@@ -0,0 +1,27 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: null;
6
+ required: true;
7
+ };
8
+ ready: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
+ submit: (...args: any[]) => void;
14
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
15
+ schema: {
16
+ type: null;
17
+ required: true;
18
+ };
19
+ ready: {
20
+ type: BooleanConstructor;
21
+ default: boolean;
22
+ };
23
+ }>> & Readonly<{
24
+ onSubmit?: ((...args: any[]) => any) | undefined;
25
+ }>, {
26
+ ready: boolean;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -1,11 +1,13 @@
1
1
  declare const _default: typeof __VLS_export;
2
2
  export default _default;
3
- declare const __VLS_export: import("vue").DefineComponent<{}, {
4
- $props: Partial<typeof __VLS_props>;
5
- schema: any;
6
- data: any;
7
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
- declare const __VLS_props: {
9
- readonly schema: any;
10
- readonly data: any;
11
- };
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: null;
6
+ required: true;
7
+ };
8
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
+ schema: {
10
+ type: null;
11
+ required: true;
12
+ };
13
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -43,8 +43,7 @@ import { Button, Tag } from "primevue";
43
43
  import { useLocalization } from "#imports";
44
44
  const { localize: l } = useLocalization();
45
45
  const { schema } = defineProps({
46
- schema: { type: null, required: true },
47
- data: { type: null, default: null }
46
+ schema: { type: null, required: true }
48
47
  });
49
48
  const {
50
49
  route,
@@ -1,11 +1,13 @@
1
1
  declare const _default: typeof __VLS_export;
2
2
  export default _default;
3
- declare const __VLS_export: import("vue").DefineComponent<{}, {
4
- $props: Partial<typeof __VLS_props>;
5
- schema: any;
6
- data: any;
7
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
- declare const __VLS_props: {
9
- readonly schema: any;
10
- readonly data: any;
11
- };
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: null;
6
+ required: true;
7
+ };
8
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
+ schema: {
10
+ type: null;
11
+ required: true;
12
+ };
13
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,13 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: ObjectConstructor;
6
+ required: true;
7
+ };
8
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
+ schema: {
10
+ type: ObjectConstructor;
11
+ required: true;
12
+ };
13
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <Bake
3
+ v-for="(part, i) in parts"
4
+ v-bind="$attrs"
5
+ :key="`part-${i}`"
6
+ :name="`parts/${i}`"
7
+ :descriptor="part"
8
+ />
9
+ </template>
10
+
11
+ <script setup>
12
+ import { Bake } from "#components";
13
+ const { schema } = defineProps({
14
+ schema: { type: Object, required: true }
15
+ });
16
+ const { parts } = schema;
17
+ </script>
@@ -0,0 +1,13 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: ObjectConstructor;
6
+ required: true;
7
+ };
8
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
9
+ schema: {
10
+ type: ObjectConstructor;
11
+ required: true;
12
+ };
13
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,23 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ schema: {
5
+ type: null;
6
+ required: true;
7
+ };
8
+ data: {
9
+ type: null;
10
+ default: null;
11
+ };
12
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ schema: {
14
+ type: null;
15
+ required: true;
16
+ };
17
+ data: {
18
+ type: null;
19
+ default: null;
20
+ };
21
+ }>> & Readonly<{}>, {
22
+ data: any;
23
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <AwaitLoading>
3
+ <Bake
4
+ v-if="data"
5
+ :name="`${path}/${component.type}`"
6
+ :descriptor="component"
7
+ />
8
+ </AwaitLoading>
9
+ </template>
10
+
11
+ <script setup>
12
+ import { computed, useContext } from "#imports";
13
+ import { AwaitLoading, Bake } from "#components";
14
+ const context = useContext();
15
+ const { data, schema } = defineProps({
16
+ schema: { type: null, required: true },
17
+ data: { type: null, default: null }
18
+ });
19
+ const path = context.injectPath();
20
+ const { conditions, fallback } = schema;
21
+ const component = computed(() => {
22
+ if (!conditions) {
23
+ return fallback;
24
+ }
25
+ const successConditions = conditions.filter((condition) => condition.prop && data[condition.prop] === condition.value);
26
+ if (successConditions.length <= 0) {
27
+ return fallback;
28
+ }
29
+ return successConditions[0].component;
30
+ });
31
+ </script>