@vc-shell/framework 1.0.188 → 1.0.190

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 (181) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/core/plugins/moment/humanize.ts +6 -7
  3. package/core/types/index.ts +12 -1
  4. package/dist/core/plugins/moment/humanize.d.ts.map +1 -1
  5. package/dist/core/types/index.d.ts +1 -1
  6. package/dist/core/types/index.d.ts.map +1 -1
  7. package/dist/framework.js +30782 -20187
  8. package/dist/index.css +1 -1
  9. package/dist/shared/components/error-interceptor/interceptor.d.ts.map +1 -1
  10. package/dist/shared/modules/dynamic/components/fields/Button.d.ts.map +1 -1
  11. package/dist/shared/modules/dynamic/components/fields/ContentField.d.ts.map +1 -1
  12. package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts.map +1 -1
  13. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts +4 -1
  14. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts.map +1 -1
  15. package/dist/shared/modules/dynamic/components/fields/GalleryField.d.ts.map +1 -1
  16. package/dist/shared/modules/dynamic/components/fields/ImageField.d.ts.map +1 -1
  17. package/dist/shared/modules/dynamic/components/fields/InputField.d.ts.map +1 -1
  18. package/dist/shared/modules/dynamic/components/fields/MultivalueField.d.ts.map +1 -1
  19. package/dist/shared/modules/dynamic/components/fields/SelectField.d.ts.map +1 -1
  20. package/dist/shared/modules/dynamic/components/fields/StatusField.d.ts.map +1 -1
  21. package/dist/shared/modules/dynamic/components/fields/TextareaField.d.ts.map +1 -1
  22. package/dist/shared/modules/dynamic/components/fields/VideoField.d.ts.map +1 -1
  23. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts +417 -0
  24. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts.map +1 -0
  25. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts +357 -0
  26. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts.map +1 -0
  27. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts +398 -0
  28. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts.map +1 -0
  29. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts +392 -0
  30. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts.map +1 -0
  31. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts +407 -0
  32. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts.map +1 -0
  33. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts +372 -0
  34. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts.map +1 -0
  35. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts +391 -0
  36. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts.map +1 -0
  37. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts +372 -0
  38. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts.map +1 -0
  39. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts +439 -0
  40. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts.map +1 -0
  41. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts +460 -0
  42. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts.map +1 -0
  43. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts +459 -0
  44. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts.map +1 -0
  45. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts +359 -0
  46. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts.map +1 -0
  47. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts +507 -0
  48. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts.map +1 -0
  49. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts +392 -0
  50. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts.map +1 -0
  51. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts +14 -0
  52. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts.map +1 -0
  53. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts +407 -0
  54. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts.map +1 -0
  55. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts +322 -0
  56. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts.map +1 -0
  57. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts +113 -0
  58. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts.map +1 -0
  59. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts +3 -0
  60. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts.map +1 -0
  61. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +235 -0
  62. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts.map +1 -0
  63. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts +4 -0
  64. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts.map +1 -0
  65. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts +3 -0
  66. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts.map +1 -0
  67. package/dist/shared/modules/dynamic/factories/base/useDetailsFactory.d.ts.map +1 -1
  68. package/dist/shared/modules/dynamic/factories/types/index.d.ts +1 -0
  69. package/dist/shared/modules/dynamic/factories/types/index.d.ts.map +1 -1
  70. package/dist/shared/modules/dynamic/helpers/getters.d.ts.map +1 -1
  71. package/dist/shared/modules/dynamic/types/index.d.ts +88 -38
  72. package/dist/shared/modules/dynamic/types/index.d.ts.map +1 -1
  73. package/dist/shared/modules/dynamic/types/models.d.ts.map +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/dist/ui/components/atoms/vc-card/vc-card.stories.d.ts +16 -16
  76. package/dist/ui/components/atoms/vc-card/vc-card.vue.d.ts.map +1 -1
  77. package/dist/ui/components/atoms/vc-switch/index.d.ts +1 -39
  78. package/dist/ui/components/atoms/vc-switch/index.d.ts.map +1 -1
  79. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts +30 -11
  80. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts.map +1 -1
  81. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts +22 -3
  82. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts.map +1 -1
  83. package/dist/ui/components/atoms/vc-video/index.d.ts +1 -35
  84. package/dist/ui/components/atoms/vc-video/index.d.ts.map +1 -1
  85. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts +5 -27
  86. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts.map +1 -1
  87. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts +3 -18
  88. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts.map +1 -1
  89. package/dist/ui/components/molecules/vc-editor/vc-editor.stories.d.ts +16 -4
  90. package/dist/ui/components/molecules/vc-editor/vc-editor.stories.d.ts.map +1 -1
  91. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts +2 -1
  92. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
  93. package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts +30 -16
  94. package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts.map +1 -1
  95. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.stories.d.ts +12 -12
  96. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts.map +1 -1
  97. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts +252 -42
  98. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts.map +1 -1
  99. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +36 -6
  100. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts.map +1 -1
  101. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts +96 -32
  102. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts.map +1 -1
  103. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts +3 -3
  104. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts.map +1 -1
  105. package/dist/ui/components/molecules/vc-textarea/vc-textarea.stories.d.ts +63 -63
  106. package/dist/ui/components/molecules/vc-textarea/vc-textarea.vue.d.ts +6 -6
  107. package/dist/ui/components/molecules/vc-textarea/vc-textarea.vue.d.ts.map +1 -1
  108. package/dist/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue.d.ts +1 -0
  109. package/dist/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue.d.ts.map +1 -1
  110. package/dist/ui/components/organisms/vc-table/_internal/vc-table-column-switcher/vc-table-column-switcher.vue.d.ts.map +1 -1
  111. package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts +8 -2
  112. package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts.map +1 -1
  113. package/dist/ui/components/organisms/vc-table/vc-table.vue.d.ts +3 -1
  114. package/dist/ui/components/organisms/vc-table/vc-table.vue.d.ts.map +1 -1
  115. package/package.json +8 -4
  116. package/shared/components/error-interceptor/interceptor.ts +1 -1
  117. package/shared/modules/dynamic/components/fields/Button.ts +5 -2
  118. package/shared/modules/dynamic/components/fields/Card.ts +4 -4
  119. package/shared/modules/dynamic/components/fields/ContentField.ts +1 -0
  120. package/shared/modules/dynamic/components/fields/DynamicProperty.ts +5 -6
  121. package/shared/modules/dynamic/components/fields/EditorField.ts +5 -3
  122. package/shared/modules/dynamic/components/fields/Fieldset.ts +1 -1
  123. package/shared/modules/dynamic/components/fields/GalleryField.ts +6 -3
  124. package/shared/modules/dynamic/components/fields/ImageField.ts +0 -1
  125. package/shared/modules/dynamic/components/fields/InputCurrency.ts +1 -1
  126. package/shared/modules/dynamic/components/fields/InputField.ts +1 -0
  127. package/shared/modules/dynamic/components/fields/MultivalueField.ts +3 -2
  128. package/shared/modules/dynamic/components/fields/SelectField.ts +1 -0
  129. package/shared/modules/dynamic/components/fields/StatusField.ts +20 -10
  130. package/shared/modules/dynamic/components/fields/TextareaField.ts +1 -0
  131. package/shared/modules/dynamic/components/fields/VideoField.ts +0 -1
  132. package/shared/modules/dynamic/components/fields/storybook/Button.stories.ts +247 -0
  133. package/shared/modules/dynamic/components/fields/storybook/Card.stories.ts +166 -0
  134. package/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.ts +185 -0
  135. package/shared/modules/dynamic/components/fields/storybook/ContentField.stories.ts +245 -0
  136. package/shared/modules/dynamic/components/fields/storybook/EditorField.stories.ts +192 -0
  137. package/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.ts +409 -0
  138. package/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.ts +239 -0
  139. package/shared/modules/dynamic/components/fields/storybook/ImageField.stories.ts +186 -0
  140. package/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.ts +267 -0
  141. package/shared/modules/dynamic/components/fields/storybook/InputField.stories.ts +298 -0
  142. package/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.ts +347 -0
  143. package/shared/modules/dynamic/components/fields/storybook/RatingField.stories.ts +131 -0
  144. package/shared/modules/dynamic/components/fields/storybook/SelectField.stories.ts +653 -0
  145. package/shared/modules/dynamic/components/fields/storybook/StatusField.stories.ts +202 -0
  146. package/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.ts +178 -0
  147. package/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.ts +203 -0
  148. package/shared/modules/dynamic/components/fields/storybook/VideoField.stories.ts +92 -0
  149. package/shared/modules/dynamic/components/fields/storybook/common/args.ts +130 -0
  150. package/shared/modules/dynamic/components/fields/storybook/common/templates.ts +8 -0
  151. package/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.ts +54 -0
  152. package/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.ts +16 -0
  153. package/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.ts +41 -0
  154. package/shared/modules/dynamic/factories/base/useDetailsFactory.ts +1 -0
  155. package/shared/modules/dynamic/factories/types/index.ts +2 -0
  156. package/shared/modules/dynamic/helpers/getters.ts +3 -0
  157. package/shared/modules/dynamic/helpers/nodeBuilder.ts +1 -1
  158. package/shared/modules/dynamic/helpers/setters.ts +1 -1
  159. package/shared/modules/dynamic/types/index.ts +93 -40
  160. package/shared/modules/dynamic/types/models.ts +8 -7
  161. package/shared/pages/LoginPage/components/login/Login.vue +1 -1
  162. package/ui/components/atoms/vc-card/vc-card.vue +12 -2
  163. package/ui/components/atoms/vc-switch/index.ts +1 -3
  164. package/ui/components/atoms/vc-switch/vc-switch.vue +10 -3
  165. package/ui/components/atoms/vc-video/index.ts +1 -3
  166. package/ui/components/atoms/vc-video/vc-video.stories.ts +1 -15
  167. package/ui/components/atoms/vc-video/vc-video.vue +4 -37
  168. package/ui/components/molecules/vc-editor/vc-editor.vue +47 -33
  169. package/ui/components/molecules/vc-field/_internal/vc-field-type/vc-field-type.vue +2 -2
  170. package/ui/components/molecules/vc-input/vc-input.stories.ts +14 -0
  171. package/ui/components/molecules/vc-input-currency/vc-input-currency.vue +8 -0
  172. package/ui/components/molecules/vc-multivalue/vc-multivalue.vue +21 -9
  173. package/ui/components/molecules/vc-select/vc-select.stories.ts +74 -3
  174. package/ui/components/molecules/vc-select/vc-select.vue +35 -38
  175. package/ui/components/molecules/vc-textarea/vc-textarea.stories.ts +1 -1
  176. package/ui/components/molecules/vc-textarea/vc-textarea.vue +5 -15
  177. package/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +1 -1
  178. package/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue +140 -108
  179. package/ui/components/organisms/vc-table/_internal/vc-table-column-switcher/vc-table-column-switcher.vue +20 -6
  180. package/ui/components/organisms/vc-table/vc-table.stories.ts +6 -2
  181. package/ui/components/organisms/vc-table/vc-table.vue +176 -124
@@ -0,0 +1,130 @@
1
+ export const SchemaBaseArgTypes = {
2
+ id: {
3
+ description: "Unique identifier for component.",
4
+ control: "text",
5
+ type: {
6
+ required: true,
7
+ name: "string",
8
+ },
9
+ table: {
10
+ type: {
11
+ summary: "string",
12
+ },
13
+ },
14
+ },
15
+ label: {
16
+ description: `Control label.
17
+ To show label based on some bound property - use interpolation \`{}\` syntax.
18
+ \n\`@example\` {someProperty}
19
+ Supports i18n keys.`,
20
+ control: "text",
21
+ table: {
22
+ type: {
23
+ summary: "string",
24
+ },
25
+ },
26
+ },
27
+ property: {
28
+ description: `Property name to populate the component with data.
29
+ Data can be defined in either the \`item\` or the \`scope\`.
30
+ \nDot notation can also be used for nested properties, e.g. \`address.city\` or \`addresses[1].city\`.
31
+ \nYou can also use a \`function\` or \`writable computed\` to set the property in the \`scope\`, which receives the modified data as an argument.
32
+ `,
33
+ type: {
34
+ required: true,
35
+ name: "string",
36
+ },
37
+ table: {
38
+ type: {
39
+ summary: "string",
40
+ },
41
+ },
42
+ },
43
+ rules: {
44
+ description: `Vee-validate and custom validation rules for the schema.`,
45
+ control: "object",
46
+ table: {
47
+ type: {
48
+ summary: "IValidationRules",
49
+ detail:
50
+ "https://github.com/VirtoCommerce/vc-shell/blob/67ac3849b35660680123efaf59775d4a64a210f6/framework/core/types/index.ts#L10",
51
+ },
52
+ },
53
+ },
54
+ placeholder: {
55
+ description: `Placeholder text for the component.
56
+ Supports i18n keys.`,
57
+ control: "text",
58
+ table: {
59
+ type: {
60
+ summary: "string",
61
+ },
62
+ },
63
+ },
64
+ disabled: {
65
+ description: `Disabled state for component.
66
+ Method should be defined in the blade \`scope\`.
67
+ Method should return boolean value.
68
+ `,
69
+ table: {
70
+ type: {
71
+ summary: "{ method: string }",
72
+ },
73
+ },
74
+ },
75
+ tooltip: {
76
+ description: `Tooltip text for the component.
77
+ Supports i18n keys.`,
78
+ control: "text",
79
+ table: {
80
+ type: {
81
+ summary: "string",
82
+ },
83
+ },
84
+ },
85
+ visibility: {
86
+ description: `Visibility options for component.
87
+ Method should be defined in the blade \`scope\`.
88
+ Method should return boolean value.
89
+ `,
90
+ table: {
91
+ type: {
92
+ summary: "{ method: string }",
93
+ },
94
+ },
95
+ },
96
+ multilanguage: {
97
+ description: "Flag to indicate if the component supports multilanguage.",
98
+ control: "boolean",
99
+ table: {
100
+ type: {
101
+ summary: "boolean",
102
+ },
103
+ defaultValue: {
104
+ summary: "false",
105
+ },
106
+ },
107
+ },
108
+ update: {
109
+ description: `Additional method that is called when the modelValue of the component changes.
110
+ Method should be defined in the blade \`scope\`.
111
+ `,
112
+ table: {
113
+ type: {
114
+ summary: "{ method: string }",
115
+ },
116
+ },
117
+ },
118
+ horizontalSeparator: {
119
+ description: `Adds horizontal separator after component.`,
120
+ control: "boolean",
121
+ table: {
122
+ type: {
123
+ summary: "boolean",
124
+ },
125
+ defaultValue: {
126
+ summary: "false",
127
+ },
128
+ },
129
+ },
130
+ } as const;
@@ -0,0 +1,8 @@
1
+ export const template = `
2
+ <page :args="args" :context="context" :additionalSource="additionalSource" @update:modelValue="(val) => Object.assign(context.item, val)" />
3
+ `;
4
+
5
+ export const templateWithVisibilityToggle = `
6
+ <VcButton @click="toggle" class="tw-mb-4" outline small variant="danger">Toggle visibility</VcButton>
7
+ ${template}
8
+ `;
@@ -0,0 +1,54 @@
1
+ import { DefineComponent, PropType, UnwrapNestedRefs, defineComponent, h, reactive, ref, watchEffect } from "vue";
2
+ import SchemaRender from "../../../SchemaRender";
3
+ import { sourceHighlighter } from "../utils/sourceHighlighter";
4
+ import { ControlSchema, DetailsBladeContext } from "../../../..";
5
+ import { VcPopupContainer } from "../../../../../../components/popup-handler";
6
+ import { useForm } from "vee-validate";
7
+
8
+ export default defineComponent({
9
+ title: "DynamicPage",
10
+ props: {
11
+ context: {
12
+ type: Object as PropType<UnwrapNestedRefs<DetailsBladeContext>>,
13
+ required: true,
14
+ default: () => ({}) as DetailsBladeContext,
15
+ },
16
+ args: {
17
+ type: Object as PropType<ControlSchema>,
18
+ required: true,
19
+ default: (): ControlSchema => ({}) as ControlSchema,
20
+ },
21
+ additionalSource: {
22
+ type: Object as PropType<DefineComponent>,
23
+ },
24
+ },
25
+ emits: ["update:modelValue"],
26
+ setup(props, ctx) {
27
+ props = reactive(props);
28
+ useForm({ validateOnMount: true });
29
+
30
+ const highlightedCode = ref("");
31
+
32
+ watchEffect(async () => {
33
+ highlightedCode.value = await sourceHighlighter(props.args, props.context, props.additionalSource);
34
+ });
35
+
36
+ return () => [
37
+ h(SchemaRender, {
38
+ modelValue: props.context?.item,
39
+ "onUpdate:modelValue": (value) => {
40
+ ctx.emit("update:modelValue", value);
41
+ },
42
+ context: props.context,
43
+ uiSchema: [props.args],
44
+ }),
45
+
46
+ h("pre", {
47
+ ref: "pre",
48
+ class: "tw-mt-4 tw-p-2 tw-bg-[#F7FAFC]",
49
+ innerHTML: highlightedCode.value,
50
+ }),
51
+ h(VcPopupContainer),
52
+ ];
53
+ },
54
+ });
@@ -0,0 +1,16 @@
1
+ import { sourceTransform } from "./sourceTransform";
2
+ import { highlight, languages } from "prismjs";
3
+ import "prismjs/themes/prism.css";
4
+ import { ControlSchema } from "../../../../types";
5
+
6
+ export const sourceHighlighter = async (
7
+ args: ControlSchema,
8
+ context: Record<string, unknown>,
9
+ additionalSource: unknown,
10
+ ) => {
11
+ return createPrismEl(await sourceTransform(args, context, additionalSource));
12
+ };
13
+
14
+ function createPrismEl(state: string) {
15
+ return highlight(state, languages.javascript, "javascript");
16
+ }
@@ -0,0 +1,41 @@
1
+ import * as parserTypeScript from "prettier/parser-typescript";
2
+ import * as prettier from "prettier/standalone";
3
+ // eslint-disable-next-line import/namespace
4
+ import * as prettierPluginEstree from "prettier/plugins/estree";
5
+ import serialize from "serialize-javascript";
6
+ import { ControlSchema } from "../../../../types";
7
+
8
+ export const sourceTransform = async (
9
+ args: ControlSchema,
10
+ context: Record<string, unknown>,
11
+ additionalSource: unknown,
12
+ ) => {
13
+ let source: string = "";
14
+
15
+ if (args) {
16
+ source += `
17
+ \nconst ComponentSchema = ${serialize(args, { space: 2 })}`;
18
+ }
19
+
20
+ if (context && Object.keys(context).length > 0) {
21
+ source += `
22
+ \nconst ComposableScope = ${serialize(context, { unsafe: true, space: 2 })}`;
23
+ }
24
+
25
+ if (additionalSource) {
26
+ source += `
27
+ \nconst Context = ${serialize(additionalSource, { unsafe: true, space: 2 })}`;
28
+ }
29
+
30
+ return await formatCode(source);
31
+ };
32
+
33
+ const formatCode = async (src: string) => {
34
+ const options = {
35
+ parser: "typescript",
36
+ singleQuote: true,
37
+ plugins: [parserTypeScript, prettierPluginEstree],
38
+ tabWidth: 2,
39
+ };
40
+ return await prettier.format(src, options);
41
+ };
@@ -33,6 +33,7 @@ export const useDetailsFactory = <Item>(factoryParams: UseDetailsFactoryParams<I
33
33
  await factoryParams.saveChanges?.(item as Item);
34
34
  isModified.value = false;
35
35
  isDirty = ref(false);
36
+ isDirty = ref(false);
36
37
  } else throw new Error("Form is not valid");
37
38
  });
38
39
 
@@ -80,6 +80,8 @@ export interface ListBaseBladeScope<Item = Record<string, any>, Query = Record<s
80
80
  breadcrumbs?: ComputedRef<Breadcrumbs[]>;
81
81
  }
82
82
 
83
+ export type TOpenBladeArgs = Omit<Parameters<ReturnType<typeof useBladeNavigation>["openBlade"]>["0"], "blade">;
84
+
83
85
  export interface DetailsBaseBladeScope extends BaseBladeScope {
84
86
  disabled?: ComputedRef<boolean | undefined>;
85
87
  multilanguage?: {
@@ -3,6 +3,9 @@ import * as _ from "lodash-es";
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
4
  export const getModel = (property: string, context: Record<string, any>) => {
5
5
  if (property && context) {
6
+ if (typeof context[property] === "function") {
7
+ return context[property]();
8
+ }
6
9
  return _.get(context, property);
7
10
  }
8
11
  return null;
@@ -62,7 +62,7 @@ function nodeBuilder<
62
62
  safeIn("property", controlSchema) &&
63
63
  controlSchema.property &&
64
64
  bladeContext.scope &&
65
- bladeContext.scope[controlSchema.property];
65
+ getModel(controlSchema.property, bladeContext.scope);
66
66
 
67
67
  const modelValue = scopedProperty ?? contextProperty ?? undefined;
68
68
 
@@ -17,7 +17,7 @@ function setModel(args: {
17
17
  if (typeof scope[property] === "function") {
18
18
  scope[property](value);
19
19
  } else {
20
- scope[property] = value;
20
+ _.set(scope, property, value);
21
21
  }
22
22
  }
23
23
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ VcButton,
2
3
  VcField,
3
4
  VcGallery,
4
5
  VcIcon,
@@ -209,6 +210,9 @@ export interface SchemaBase {
209
210
  */
210
211
  label?: string;
211
212
  /** Property name to populate the component with data.
213
+ * Data can be defined in either the `item` or the `scope`.
214
+ * Dot notation can also be used for nested properties, e.g. `address.city` or `addresses[1].city`.
215
+ * You can also use a `function` or `writable computed` to set the property in the `scope`, which receives the modified data as an argument.
212
216
  * @type {string}
213
217
  */
214
218
  property: string;
@@ -218,7 +222,7 @@ export interface SchemaBase {
218
222
  * @type {IValidationRules}
219
223
  */
220
224
  rules?: IValidationRules;
221
- /** Placeholder text for component.
225
+ /** Placeholder text for the component.
222
226
  * @type {string}
223
227
  */
224
228
  placeholder?: string;
@@ -228,7 +232,7 @@ export interface SchemaBase {
228
232
  * @type {{ method: string }}
229
233
  */
230
234
  disabled?: { method: string };
231
- /** Tooltip text for component.
235
+ /** Tooltip text for the component.
232
236
  * @type {string}
233
237
  */
234
238
  tooltip?: string;
@@ -277,9 +281,11 @@ export interface SelectSchema extends SchemaBase {
277
281
  * @type {string}
278
282
  */
279
283
  optionLabel: string;
280
- /**
281
- * Method that is used to get select options.
282
- * @description Method should be defined in the blade `scope`.
284
+ /** Method that is used to get select options.
285
+ * @description Method should be defined in the blade \`scope\` and could be:
286
+ * 1) async method with the following arguments: (\`keyword: string\`, \`skip\`, \`ids?: string[]\`).
287
+ * 2) any array
288
+ * 3) composable returning array
283
289
  * @type {string}
284
290
  */
285
291
  optionsMethod: string;
@@ -309,6 +315,11 @@ export interface SelectSchema extends SchemaBase {
309
315
  * }
310
316
  */
311
317
  emitValue?: boolean;
318
+ /**
319
+ * @type {boolean}
320
+ * @default true
321
+ */
322
+ mapOptions?: boolean;
312
323
  /**
313
324
  * Whether the select is searchable or not.
314
325
  * @type {boolean}
@@ -376,6 +387,11 @@ export interface TextareaSchema extends SchemaBase {
376
387
  * @type {boolean}
377
388
  */
378
389
  clearable?: boolean;
390
+ /**
391
+ * Maximum number of characters that can be entered.
392
+ * @type {number}
393
+ */
394
+ maxlength?: number;
379
395
  }
380
396
 
381
397
  /**
@@ -418,24 +434,23 @@ export interface InputSchema extends SchemaBase {
418
434
  * @type {ControlSchema}
419
435
  */
420
436
  prependInner?: ControlSchema;
437
+ /**
438
+ * Maximum number of characters that can be entered.
439
+ * @type {number}
440
+ */
441
+ maxlength?: number;
421
442
  }
422
443
 
423
444
  /**
424
445
  * Video schema interface.
425
446
  * @interface
426
447
  */
427
- export interface VideoSchema
428
- extends Pick<SchemaBase, "id" | "property" | "label" | "visibility" | "tooltip" | "update"> {
448
+ export interface VideoSchema extends Pick<SchemaBase, "id" | "property" | "label" | "visibility" | "tooltip"> {
429
449
  /**
430
450
  * Component type for video.
431
451
  * @type {"vc-video"}
432
452
  */
433
453
  component: "vc-video";
434
- /**
435
- * Video size.
436
- * @type {"auto" | "xs" | "s" | "m" | "l" | "xl" | "xxl"}
437
- */
438
- size?: ComponentProps<typeof VcVideo>["size"];
439
454
  }
440
455
 
441
456
  /**
@@ -478,8 +493,7 @@ export interface FieldSchema
478
493
  * Image schema interface.
479
494
  * @interface
480
495
  */
481
- export interface ImageSchema
482
- extends Pick<SchemaBase, "id" | "property" | "visibility" | "update" | "horizontalSeparator"> {
496
+ export interface ImageSchema extends Pick<SchemaBase, "id" | "property" | "visibility"> {
483
497
  /**
484
498
  * Component type for image.
485
499
  * @type {"vc-image"}
@@ -510,11 +524,6 @@ export interface ImageSchema
510
524
  * @type {boolean}
511
525
  */
512
526
  bordered?: boolean;
513
- /**
514
- * Whether the image has preview on click or not.
515
- * @type {boolean}
516
- */
517
- clickable?: boolean;
518
527
  }
519
528
 
520
529
  /**
@@ -563,13 +572,16 @@ export interface StatusSchema extends Pick<SchemaBase, "id" | "visibility" | "ho
563
572
  */
564
573
  title?: string;
565
574
  /**
566
- * Method to call to get status content.
575
+ * Used to display the content of the status. It can be a `string\` or an `object with a method property`.
576
+ * Method property could be a function, `computed property` or `ref`, returning a `string` value.
567
577
  * @description Method should be defined in the blade `scope`.
568
- * @type {{ method: string }}
578
+ * @type {{ method: string } | string}
569
579
  */
570
- content: {
571
- method: string;
572
- };
580
+ content:
581
+ | {
582
+ method: string;
583
+ }
584
+ | string;
573
585
  }
574
586
 
575
587
  /**
@@ -583,7 +595,12 @@ export interface InputCurrencySchema extends Omit<SchemaBase, "multilanguage"> {
583
595
  */
584
596
  component: "vc-input-currency";
585
597
  /**
586
- * Property that holds available currency options.
598
+ * List of currency options to be displayed in the dropdown.
599
+ * @description Array should be defined in the blade `scope`.
600
+ */
601
+ options: string;
602
+ /**
603
+ * Name of property that holds currency value.
587
604
  * @type {string}
588
605
  */
589
606
  optionProperty: string;
@@ -616,6 +633,16 @@ export interface EditorSchema extends SchemaBase {
616
633
  * @type {"vc-editor"}
617
634
  */
618
635
  component: "vc-editor";
636
+ /**
637
+ * Assets folder for the editor image uploads.
638
+ * @type {string}
639
+ */
640
+ assetsFolder: string;
641
+ /**
642
+ * Maximum length of the editor content.
643
+ * @type {number}
644
+ */
645
+ maxlength?: number;
619
646
  }
620
647
 
621
648
  /**
@@ -645,7 +672,8 @@ export interface DynamicPropertiesSchema
645
672
  * Gallery schema interface.
646
673
  * @interface
647
674
  */
648
- export interface GallerySchema extends Omit<SchemaBase, "placeholder" | "multilanguage"> {
675
+ export interface GallerySchema
676
+ extends Omit<SchemaBase, "placeholder" | "multilanguage" | "update" | "horizontalSeparator"> {
649
677
  /**
650
678
  * Component type for the gallery.
651
679
  * @type {"vc-gallery"}
@@ -681,8 +709,7 @@ export interface GallerySchema extends Omit<SchemaBase, "placeholder" | "multila
681
709
  * Interface for a card schema.
682
710
  * @interface
683
711
  */
684
- export interface CardSchema
685
- extends RequiredBy<Pick<SchemaBase, "id" | "label" | "visibility" | "horizontalSeparator">, "label"> {
712
+ export interface CardSchema extends RequiredBy<Pick<SchemaBase, "id" | "label" | "visibility">, "label"> {
686
713
  /**
687
714
  * Component type for the card.
688
715
  * @type {"vc-card"}
@@ -695,14 +722,19 @@ export interface CardSchema
695
722
  fields: ControlSchema[];
696
723
  /**
697
724
  * Button schema for the action button in the card, along with the action method to use.
698
- * @type {ButtonSchema & { method: string }}
725
+ * @type {ButtonSchema}
699
726
  */
700
- action?: ButtonSchema & { method: string };
727
+ action?: ButtonSchema;
701
728
  /**
702
729
  * Whether the card is collapsible or not.
703
730
  * @type {boolean}
704
731
  */
705
732
  collapsible?: boolean;
733
+ /**
734
+ * Whether the card is collapsed or not.
735
+ * @type {boolean}
736
+ */
737
+ collapsed?: boolean;
706
738
  /**
707
739
  * Removes internal padding from the card.
708
740
  * @type {boolean}
@@ -727,12 +759,12 @@ export interface CheckboxSchema extends Omit<SchemaBase, "multilanguage" | "plac
727
759
  */
728
760
  content: string;
729
761
  /**
730
- * True value for the switch.
762
+ * Value when checkbox is checked.
731
763
  * @type {boolean}
732
764
  */
733
765
  trueValue?: boolean;
734
766
  /**
735
- * False value for the switch.
767
+ * Value when checkbox is unchecked.
736
768
  * @type {boolean}
737
769
  */
738
770
  falseValue?: boolean;
@@ -742,13 +774,18 @@ export interface CheckboxSchema extends Omit<SchemaBase, "multilanguage" | "plac
742
774
  * Fieldset schema interface.
743
775
  * @interface
744
776
  */
745
- export interface FieldsetSchema
746
- extends PartialBy<Pick<SchemaBase, "id" | "property" | "visibility" | "horizontalSeparator">, "property"> {
777
+ export interface FieldsetSchema extends Pick<SchemaBase, "id" | "visibility" | "horizontalSeparator"> {
747
778
  /**
748
779
  * Component type for the fieldset.
749
780
  * @type {"vc-fieldset"}
750
781
  */
751
782
  component: "vc-fieldset";
783
+ /** Property name to build `fieldset` from `array of objects`.
784
+ * Data can be defined in either the `item` or the `scope`.
785
+ * Dot notation can also be used for nested properties, e.g. `address.city` or `addresses[1].city`
786
+ * @type {string}
787
+ */
788
+ property?: string;
752
789
  /**
753
790
  * Number of columns to display the fields in.
754
791
  * @type {number}
@@ -756,13 +793,13 @@ export interface FieldsetSchema
756
793
  columns?: number;
757
794
  /**
758
795
  * Array of numbers that define the aspect ratio of each column.
759
- * @example Set to [1, 1] to make all columns equal width.
760
- * @description Uses CSS flex-grow property.
796
+ * @example If you have two columns - set to [1, 1] to make all columns equal width.
797
+ * @description Uses CSS flex-grow property to set the width of each column.
761
798
  * @type {number[]}
762
799
  */
763
800
  aspectRatio?: number[];
764
801
  /**
765
- * Array of control schemas to be displayed in the fieldset.
802
+ * Array of control schemas for the fields in the fieldset.
766
803
  * @type {ControlSchema[]}
767
804
  */
768
805
  fields: ControlSchema[];
@@ -773,6 +810,7 @@ export interface FieldsetSchema
773
810
  *
774
811
  * Allows to remove selected fieldset.
775
812
  * @description Method should be defined in the blade `scope`.
813
+ * @argument {number} id - id of the field to remove
776
814
  * @type {{ method: string }}
777
815
  */
778
816
  remove?: {
@@ -791,12 +829,12 @@ export interface SwitchSchema extends Omit<SchemaBase, "placeholder" | "multilan
791
829
  */
792
830
  component: "vc-switch";
793
831
  /**
794
- * True value for the switch.
832
+ * Value when switch is on.
795
833
  * @type {boolean}
796
834
  */
797
835
  trueValue?: boolean;
798
836
  /**
799
- * False value for the switch.
837
+ * Value when switch is off.
800
838
  * @type {boolean}
801
839
  */
802
840
  falseValue?: boolean;
@@ -808,7 +846,7 @@ export type TableSchema = Omit<ListContentSchema, "filter"> & Pick<SchemaBase, "
808
846
  * Button schema interface.
809
847
  * @interface
810
848
  */
811
- export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visibility" | "horizontalSeparator"> {
849
+ export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visibility"> {
812
850
  /**
813
851
  * Component type.
814
852
  * @type {"vc-button"}
@@ -845,6 +883,21 @@ export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visi
845
883
  * @type {string}
846
884
  */
847
885
  method: string;
886
+ /**
887
+ * Button variant.
888
+ * @type {primary | warning | danger}
889
+ */
890
+ variant?: ComponentProps<typeof VcButton>["variant"];
891
+ /**
892
+ * Raised button.
893
+ * @type {boolean}
894
+ */
895
+ raised?: boolean;
896
+ /**
897
+ * Outlined button.
898
+ * @type {boolean}
899
+ */
900
+ outline?: boolean;
848
901
  }
849
902
 
850
903
  /**
@@ -22,13 +22,14 @@ import {
22
22
  } from "../../../../ui/components";
23
23
  import type { ComponentProps, ComponentEmit, ComponentSlots } from "vue-component-type-helpers";
24
24
 
25
- type FromGenericEventsToProps<T extends Record<string, any>> = T extends Record<string, any>
26
- ? {
27
- [K in string & `on${Capitalize<string & keyof T>}`]?: K extends `on${infer C}`
28
- ? (...args: T[Uncapitalize<C>]) => any
29
- : never;
30
- }
31
- : never;
25
+ type FromGenericEventsToProps<T extends Record<string, any>> =
26
+ T extends Record<string, any>
27
+ ? {
28
+ [K in string & `on${Capitalize<string & keyof T>}`]?: K extends `on${infer C}`
29
+ ? (...args: T[Uncapitalize<C>]) => any
30
+ : never;
31
+ }
32
+ : never;
32
33
 
33
34
  interface FieldOpts<T> {
34
35
  component?: ComponentType<T>;
@@ -197,7 +197,7 @@ const props = defineProps<Props>();
197
197
 
198
198
  const router = useRouter();
199
199
 
200
- const { setFieldError, resetForm, setErrors, validateField } = useForm({ validateOnMount: false });
200
+ const { validateField } = useForm({ validateOnMount: false });
201
201
  const { uiSettings, loading: customizationLoading } = useSettings();
202
202
  const { t } = useI18n({ useScope: "global" });
203
203
  let useLogin;