@vc-shell/framework 1.0.187 → 1.0.189

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 (147) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/core/plugins/moment/humanize.ts +6 -7
  3. package/dist/core/plugins/moment/humanize.d.ts.map +1 -1
  4. package/dist/framework.js +5907 -5885
  5. package/dist/index.css +1 -1
  6. package/dist/shared/modules/dynamic/components/fields/Button.d.ts.map +1 -1
  7. package/dist/shared/modules/dynamic/components/fields/ContentField.d.ts.map +1 -1
  8. package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts.map +1 -1
  9. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts +4 -1
  10. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts.map +1 -1
  11. package/dist/shared/modules/dynamic/components/fields/GalleryField.d.ts.map +1 -1
  12. package/dist/shared/modules/dynamic/components/fields/ImageField.d.ts.map +1 -1
  13. package/dist/shared/modules/dynamic/components/fields/MultivalueField.d.ts.map +1 -1
  14. package/dist/shared/modules/dynamic/components/fields/SelectField.d.ts.map +1 -1
  15. package/dist/shared/modules/dynamic/components/fields/StatusField.d.ts.map +1 -1
  16. package/dist/shared/modules/dynamic/components/fields/VideoField.d.ts.map +1 -1
  17. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts +417 -0
  18. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts.map +1 -0
  19. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts +357 -0
  20. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts.map +1 -0
  21. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts +398 -0
  22. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts.map +1 -0
  23. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts +392 -0
  24. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts.map +1 -0
  25. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts +398 -0
  26. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts.map +1 -0
  27. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts +372 -0
  28. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts.map +1 -0
  29. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts +391 -0
  30. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts.map +1 -0
  31. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts +372 -0
  32. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts.map +1 -0
  33. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts +439 -0
  34. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts.map +1 -0
  35. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts +448 -0
  36. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts.map +1 -0
  37. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts +459 -0
  38. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts.map +1 -0
  39. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts +359 -0
  40. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts.map +1 -0
  41. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts +507 -0
  42. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts.map +1 -0
  43. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts +392 -0
  44. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts.map +1 -0
  45. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts +14 -0
  46. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts.map +1 -0
  47. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts +395 -0
  48. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts.map +1 -0
  49. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts +322 -0
  50. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts.map +1 -0
  51. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts +113 -0
  52. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts.map +1 -0
  53. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts +3 -0
  54. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts.map +1 -0
  55. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +235 -0
  56. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts.map +1 -0
  57. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts +4 -0
  58. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts.map +1 -0
  59. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts +3 -0
  60. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts.map +1 -0
  61. package/dist/shared/modules/dynamic/factories/base/useDetailsFactory.d.ts.map +1 -1
  62. package/dist/shared/modules/dynamic/helpers/getters.d.ts.map +1 -1
  63. package/dist/shared/modules/dynamic/types/index.d.ts +73 -38
  64. package/dist/shared/modules/dynamic/types/index.d.ts.map +1 -1
  65. package/dist/shared/modules/dynamic/types/models.d.ts.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/dist/ui/components/atoms/vc-card/vc-card.vue.d.ts.map +1 -1
  68. package/dist/ui/components/atoms/vc-switch/index.d.ts +1 -39
  69. package/dist/ui/components/atoms/vc-switch/index.d.ts.map +1 -1
  70. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts +30 -11
  71. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts.map +1 -1
  72. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts +22 -3
  73. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts.map +1 -1
  74. package/dist/ui/components/atoms/vc-video/index.d.ts +1 -35
  75. package/dist/ui/components/atoms/vc-video/index.d.ts.map +1 -1
  76. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts +5 -27
  77. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts.map +1 -1
  78. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts +3 -18
  79. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts.map +1 -1
  80. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
  81. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts.map +1 -1
  82. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts +252 -42
  83. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts.map +1 -1
  84. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +36 -6
  85. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts.map +1 -1
  86. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts +96 -32
  87. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts.map +1 -1
  88. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts +3 -3
  89. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts.map +1 -1
  90. package/dist/ui/components/molecules/vc-textarea/vc-textarea.vue.d.ts.map +1 -1
  91. package/dist/ui/components/organisms/vc-table/vc-table.vue.d.ts.map +1 -1
  92. package/package.json +4 -4
  93. package/shared/modules/dynamic/components/fields/Button.ts +5 -2
  94. package/shared/modules/dynamic/components/fields/Card.ts +4 -4
  95. package/shared/modules/dynamic/components/fields/ContentField.ts +1 -0
  96. package/shared/modules/dynamic/components/fields/DynamicProperty.ts +5 -6
  97. package/shared/modules/dynamic/components/fields/EditorField.ts +4 -3
  98. package/shared/modules/dynamic/components/fields/Fieldset.ts +1 -1
  99. package/shared/modules/dynamic/components/fields/GalleryField.ts +6 -3
  100. package/shared/modules/dynamic/components/fields/ImageField.ts +0 -1
  101. package/shared/modules/dynamic/components/fields/InputCurrency.ts +1 -1
  102. package/shared/modules/dynamic/components/fields/MultivalueField.ts +3 -2
  103. package/shared/modules/dynamic/components/fields/SelectField.ts +1 -0
  104. package/shared/modules/dynamic/components/fields/StatusField.ts +20 -10
  105. package/shared/modules/dynamic/components/fields/VideoField.ts +0 -1
  106. package/shared/modules/dynamic/components/fields/storybook/Button.stories.ts +247 -0
  107. package/shared/modules/dynamic/components/fields/storybook/Card.stories.ts +167 -0
  108. package/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.ts +186 -0
  109. package/shared/modules/dynamic/components/fields/storybook/ContentField.stories.ts +246 -0
  110. package/shared/modules/dynamic/components/fields/storybook/EditorField.stories.ts +185 -0
  111. package/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.ts +409 -0
  112. package/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.ts +239 -0
  113. package/shared/modules/dynamic/components/fields/storybook/ImageField.stories.ts +186 -0
  114. package/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.ts +267 -0
  115. package/shared/modules/dynamic/components/fields/storybook/InputField.stories.ts +286 -0
  116. package/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.ts +347 -0
  117. package/shared/modules/dynamic/components/fields/storybook/RatingField.stories.ts +131 -0
  118. package/shared/modules/dynamic/components/fields/storybook/SelectField.stories.ts +653 -0
  119. package/shared/modules/dynamic/components/fields/storybook/StatusField.stories.ts +202 -0
  120. package/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.ts +178 -0
  121. package/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.ts +191 -0
  122. package/shared/modules/dynamic/components/fields/storybook/VideoField.stories.ts +92 -0
  123. package/shared/modules/dynamic/components/fields/storybook/common/args.ts +130 -0
  124. package/shared/modules/dynamic/components/fields/storybook/common/templates.ts +8 -0
  125. package/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.ts +54 -0
  126. package/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.ts +16 -0
  127. package/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.ts +41 -0
  128. package/shared/modules/dynamic/factories/base/useDetailsFactory.ts +4 -2
  129. package/shared/modules/dynamic/helpers/getters.ts +3 -0
  130. package/shared/modules/dynamic/helpers/nodeBuilder.ts +1 -1
  131. package/shared/modules/dynamic/helpers/setters.ts +1 -1
  132. package/shared/modules/dynamic/types/index.ts +78 -40
  133. package/shared/modules/dynamic/types/models.ts +8 -7
  134. package/ui/components/atoms/vc-card/vc-card.vue +12 -2
  135. package/ui/components/atoms/vc-switch/index.ts +1 -3
  136. package/ui/components/atoms/vc-switch/vc-switch.vue +10 -3
  137. package/ui/components/atoms/vc-video/index.ts +1 -3
  138. package/ui/components/atoms/vc-video/vc-video.stories.ts +1 -15
  139. package/ui/components/atoms/vc-video/vc-video.vue +4 -37
  140. package/ui/components/molecules/vc-editor/vc-editor.vue +28 -9
  141. package/ui/components/molecules/vc-field/_internal/vc-field-type/vc-field-type.vue +2 -2
  142. package/ui/components/molecules/vc-input-currency/vc-input-currency.vue +8 -0
  143. package/ui/components/molecules/vc-multivalue/vc-multivalue.vue +21 -9
  144. package/ui/components/molecules/vc-select/vc-select.stories.ts +74 -3
  145. package/ui/components/molecules/vc-select/vc-select.vue +35 -38
  146. package/ui/components/molecules/vc-textarea/vc-textarea.vue +1 -9
  147. package/ui/components/organisms/vc-table/vc-table.vue +1 -0
@@ -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
+ };
@@ -1,4 +1,4 @@
1
- import { ComputedRef, MaybeRef, computed, ref, watch } from "vue";
1
+ import { ComputedRef, MaybeRef, Ref, computed, ref, watch } from "vue";
2
2
  import * as _ from "lodash-es";
3
3
  import { useForm, useIsFormDirty, useIsFormValid } from "vee-validate";
4
4
  import { useAsync, useLoading } from "../../../../../core/composables";
@@ -20,7 +20,7 @@ export const useDetailsFactory = <Item>(factoryParams: UseDetailsFactoryParams<I
20
20
  const itemTemp = ref<Item>();
21
21
  const isModified = ref(false);
22
22
  const isFormValid = useIsFormValid();
23
- const isDirty = useIsFormDirty();
23
+ let isDirty: Ref<boolean> = useIsFormDirty();
24
24
  const isDisabled = computed(() => !isDirty.value || !isFormValid.value);
25
25
 
26
26
  const { loading: itemLoading, action: load } = useAsync<ItemId>(async (args?: ItemId) => {
@@ -32,6 +32,8 @@ export const useDetailsFactory = <Item>(factoryParams: UseDetailsFactoryParams<I
32
32
  if (validationState.value.valid) {
33
33
  await factoryParams.saveChanges?.(item as Item);
34
34
  isModified.value = false;
35
+ isDirty = ref(false);
36
+ isDirty = ref(false);
35
37
  } else throw new Error("Form is not valid");
36
38
  });
37
39
 
@@ -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}
@@ -424,18 +435,12 @@ export interface InputSchema extends SchemaBase {
424
435
  * Video schema interface.
425
436
  * @interface
426
437
  */
427
- export interface VideoSchema
428
- extends Pick<SchemaBase, "id" | "property" | "label" | "visibility" | "tooltip" | "update"> {
438
+ export interface VideoSchema extends Pick<SchemaBase, "id" | "property" | "label" | "visibility" | "tooltip"> {
429
439
  /**
430
440
  * Component type for video.
431
441
  * @type {"vc-video"}
432
442
  */
433
443
  component: "vc-video";
434
- /**
435
- * Video size.
436
- * @type {"auto" | "xs" | "s" | "m" | "l" | "xl" | "xxl"}
437
- */
438
- size?: ComponentProps<typeof VcVideo>["size"];
439
444
  }
440
445
 
441
446
  /**
@@ -478,8 +483,7 @@ export interface FieldSchema
478
483
  * Image schema interface.
479
484
  * @interface
480
485
  */
481
- export interface ImageSchema
482
- extends Pick<SchemaBase, "id" | "property" | "visibility" | "update" | "horizontalSeparator"> {
486
+ export interface ImageSchema extends Pick<SchemaBase, "id" | "property" | "visibility"> {
483
487
  /**
484
488
  * Component type for image.
485
489
  * @type {"vc-image"}
@@ -510,11 +514,6 @@ export interface ImageSchema
510
514
  * @type {boolean}
511
515
  */
512
516
  bordered?: boolean;
513
- /**
514
- * Whether the image has preview on click or not.
515
- * @type {boolean}
516
- */
517
- clickable?: boolean;
518
517
  }
519
518
 
520
519
  /**
@@ -563,13 +562,16 @@ export interface StatusSchema extends Pick<SchemaBase, "id" | "visibility" | "ho
563
562
  */
564
563
  title?: string;
565
564
  /**
566
- * Method to call to get status content.
565
+ * Used to display the content of the status. It can be a `string\` or an `object with a method property`.
566
+ * Method property could be a function, `computed property` or `ref`, returning a `string` value.
567
567
  * @description Method should be defined in the blade `scope`.
568
- * @type {{ method: string }}
568
+ * @type {{ method: string } | string}
569
569
  */
570
- content: {
571
- method: string;
572
- };
570
+ content:
571
+ | {
572
+ method: string;
573
+ }
574
+ | string;
573
575
  }
574
576
 
575
577
  /**
@@ -583,7 +585,12 @@ export interface InputCurrencySchema extends Omit<SchemaBase, "multilanguage"> {
583
585
  */
584
586
  component: "vc-input-currency";
585
587
  /**
586
- * Property that holds available currency options.
588
+ * List of currency options to be displayed in the dropdown.
589
+ * @description Array should be defined in the blade `scope`.
590
+ */
591
+ options: string;
592
+ /**
593
+ * Name of property that holds currency value.
587
594
  * @type {string}
588
595
  */
589
596
  optionProperty: string;
@@ -616,6 +623,11 @@ export interface EditorSchema extends SchemaBase {
616
623
  * @type {"vc-editor"}
617
624
  */
618
625
  component: "vc-editor";
626
+ /**
627
+ * Assets folder for the editor image uploads.
628
+ * @type {string}
629
+ */
630
+ assetsFolder: string;
619
631
  }
620
632
 
621
633
  /**
@@ -645,7 +657,8 @@ export interface DynamicPropertiesSchema
645
657
  * Gallery schema interface.
646
658
  * @interface
647
659
  */
648
- export interface GallerySchema extends Omit<SchemaBase, "placeholder" | "multilanguage"> {
660
+ export interface GallerySchema
661
+ extends Omit<SchemaBase, "placeholder" | "multilanguage" | "update" | "horizontalSeparator"> {
649
662
  /**
650
663
  * Component type for the gallery.
651
664
  * @type {"vc-gallery"}
@@ -681,8 +694,7 @@ export interface GallerySchema extends Omit<SchemaBase, "placeholder" | "multila
681
694
  * Interface for a card schema.
682
695
  * @interface
683
696
  */
684
- export interface CardSchema
685
- extends RequiredBy<Pick<SchemaBase, "id" | "label" | "visibility" | "horizontalSeparator">, "label"> {
697
+ export interface CardSchema extends RequiredBy<Pick<SchemaBase, "id" | "label" | "visibility">, "label"> {
686
698
  /**
687
699
  * Component type for the card.
688
700
  * @type {"vc-card"}
@@ -695,14 +707,19 @@ export interface CardSchema
695
707
  fields: ControlSchema[];
696
708
  /**
697
709
  * Button schema for the action button in the card, along with the action method to use.
698
- * @type {ButtonSchema & { method: string }}
710
+ * @type {ButtonSchema}
699
711
  */
700
- action?: ButtonSchema & { method: string };
712
+ action?: ButtonSchema;
701
713
  /**
702
714
  * Whether the card is collapsible or not.
703
715
  * @type {boolean}
704
716
  */
705
717
  collapsible?: boolean;
718
+ /**
719
+ * Whether the card is collapsed or not.
720
+ * @type {boolean}
721
+ */
722
+ collapsed?: boolean;
706
723
  /**
707
724
  * Removes internal padding from the card.
708
725
  * @type {boolean}
@@ -727,12 +744,12 @@ export interface CheckboxSchema extends Omit<SchemaBase, "multilanguage" | "plac
727
744
  */
728
745
  content: string;
729
746
  /**
730
- * True value for the switch.
747
+ * Value when checkbox is checked.
731
748
  * @type {boolean}
732
749
  */
733
750
  trueValue?: boolean;
734
751
  /**
735
- * False value for the switch.
752
+ * Value when checkbox is unchecked.
736
753
  * @type {boolean}
737
754
  */
738
755
  falseValue?: boolean;
@@ -742,13 +759,18 @@ export interface CheckboxSchema extends Omit<SchemaBase, "multilanguage" | "plac
742
759
  * Fieldset schema interface.
743
760
  * @interface
744
761
  */
745
- export interface FieldsetSchema
746
- extends PartialBy<Pick<SchemaBase, "id" | "property" | "visibility" | "horizontalSeparator">, "property"> {
762
+ export interface FieldsetSchema extends Pick<SchemaBase, "id" | "visibility" | "horizontalSeparator"> {
747
763
  /**
748
764
  * Component type for the fieldset.
749
765
  * @type {"vc-fieldset"}
750
766
  */
751
767
  component: "vc-fieldset";
768
+ /** Property name to build `fieldset` from `array of objects`.
769
+ * Data can be defined in either the `item` or the `scope`.
770
+ * Dot notation can also be used for nested properties, e.g. `address.city` or `addresses[1].city`
771
+ * @type {string}
772
+ */
773
+ property?: string;
752
774
  /**
753
775
  * Number of columns to display the fields in.
754
776
  * @type {number}
@@ -756,13 +778,13 @@ export interface FieldsetSchema
756
778
  columns?: number;
757
779
  /**
758
780
  * 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.
781
+ * @example If you have two columns - set to [1, 1] to make all columns equal width.
782
+ * @description Uses CSS flex-grow property to set the width of each column.
761
783
  * @type {number[]}
762
784
  */
763
785
  aspectRatio?: number[];
764
786
  /**
765
- * Array of control schemas to be displayed in the fieldset.
787
+ * Array of control schemas for the fields in the fieldset.
766
788
  * @type {ControlSchema[]}
767
789
  */
768
790
  fields: ControlSchema[];
@@ -773,6 +795,7 @@ export interface FieldsetSchema
773
795
  *
774
796
  * Allows to remove selected fieldset.
775
797
  * @description Method should be defined in the blade `scope`.
798
+ * @argument {number} id - id of the field to remove
776
799
  * @type {{ method: string }}
777
800
  */
778
801
  remove?: {
@@ -791,12 +814,12 @@ export interface SwitchSchema extends Omit<SchemaBase, "placeholder" | "multilan
791
814
  */
792
815
  component: "vc-switch";
793
816
  /**
794
- * True value for the switch.
817
+ * Value when switch is on.
795
818
  * @type {boolean}
796
819
  */
797
820
  trueValue?: boolean;
798
821
  /**
799
- * False value for the switch.
822
+ * Value when switch is off.
800
823
  * @type {boolean}
801
824
  */
802
825
  falseValue?: boolean;
@@ -808,7 +831,7 @@ export type TableSchema = Omit<ListContentSchema, "filter"> & Pick<SchemaBase, "
808
831
  * Button schema interface.
809
832
  * @interface
810
833
  */
811
- export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visibility" | "horizontalSeparator"> {
834
+ export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visibility"> {
812
835
  /**
813
836
  * Component type.
814
837
  * @type {"vc-button"}
@@ -845,6 +868,21 @@ export interface ButtonSchema extends Pick<SchemaBase, "id" | "disabled" | "visi
845
868
  * @type {string}
846
869
  */
847
870
  method: string;
871
+ /**
872
+ * Button variant.
873
+ * @type {primary | warning | danger}
874
+ */
875
+ variant?: ComponentProps<typeof VcButton>["variant"];
876
+ /**
877
+ * Raised button.
878
+ * @type {boolean}
879
+ */
880
+ raised?: boolean;
881
+ /**
882
+ * Outlined button.
883
+ * @type {boolean}
884
+ */
885
+ outline?: boolean;
848
886
  }
849
887
 
850
888
  /**
@@ -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>;
@@ -41,7 +41,7 @@
41
41
  <!-- eslint-disable @typescript-eslint/no-explicit-any -->
42
42
  <script lang="ts" setup>
43
43
  import { VcIcon } from "./../vc-icon";
44
- import { ref } from "vue";
44
+ import { ref, watch } from "vue";
45
45
 
46
46
  export interface Props {
47
47
  header?: string;
@@ -71,7 +71,7 @@ defineSlots<{
71
71
  actions: (props?: any) => any;
72
72
  }>();
73
73
 
74
- const isCollapsedInternal = ref(props.isCollapsed);
74
+ const isCollapsedInternal = ref();
75
75
 
76
76
  function onHeaderClick() {
77
77
  if (props.isCollapsable) {
@@ -80,6 +80,16 @@ function onHeaderClick() {
80
80
  }
81
81
  emit("header:click");
82
82
  }
83
+
84
+ watch(
85
+ () => props.isCollapsed,
86
+ (value) => {
87
+ isCollapsedInternal.value = value;
88
+ },
89
+ {
90
+ immediate: true,
91
+ },
92
+ );
83
93
  </script>
84
94
 
85
95
  <style lang="scss">
@@ -1,3 +1 @@
1
- import _Switch from "./vc-switch.vue";
2
-
3
- export const VcSwitch = _Switch as typeof _Switch;
1
+ export { default as VcSwitch } from "./vc-switch.vue";