@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,409 @@
1
+ import { Meta, StoryFn } from "@storybook/vue3";
2
+ import page from "./pages/DynamicRender";
3
+ import { template, templateWithVisibilityToggle } from "./common/templates";
4
+ import { FieldsetSchema } from "../../../types";
5
+ import { SchemaBaseArgTypes } from "./common/args";
6
+ import * as _ from "lodash-es";
7
+ import { reactive, ref } from "vue";
8
+
9
+ export default {
10
+ title: "DynamicViews/special/Fieldset",
11
+ component: page,
12
+ args: {
13
+ id: "fieldsetId",
14
+ component: "vc-fieldset",
15
+ fields: [
16
+ {
17
+ id: "fieldId",
18
+ component: "vc-input",
19
+ label: "Input field",
20
+ placeholder: "Enter text here",
21
+ property: "mockedProperty",
22
+ },
23
+ {
24
+ id: "fieldId2",
25
+ component: "vc-input",
26
+ label: "Input field 2",
27
+ placeholder: "Enter text here",
28
+ property: "mockedProperty2",
29
+ },
30
+ ],
31
+ },
32
+ argTypes: {
33
+ ..._.pick(SchemaBaseArgTypes, ["id", "visibility", "horizontalSeparator"]),
34
+ property: {
35
+ description: `Property name to build \`fieldset\` from \`array of objects\`.
36
+ Data can be defined in either the \`item\` or the \`scope\`.
37
+ \nDot notation can also be used for nested properties, e.g. \`address.city\` or \`addresses[1].city\`.
38
+ `,
39
+ table: {
40
+ type: {
41
+ summary: "string",
42
+ },
43
+ },
44
+ },
45
+ component: {
46
+ description: "Component type for field.",
47
+ type: {
48
+ required: true,
49
+ name: "string",
50
+ },
51
+ table: {
52
+ type: {
53
+ summary: "vc-fieldset",
54
+ },
55
+ defaultValue: {
56
+ summary: "vc-fieldset",
57
+ },
58
+ },
59
+ },
60
+ columns: {
61
+ description: "Number of columns to display the fields in.",
62
+ control: "number",
63
+ table: {
64
+ type: {
65
+ summary: "number",
66
+ },
67
+ defaultValue: {
68
+ summary: 1,
69
+ },
70
+ },
71
+ },
72
+ aspectRatio: {
73
+ description: `Array of numbers that define the aspect ratio of each column.
74
+ Example - If you have two columns - set to [1, 1] to make all columns equal width.
75
+ Uses CSS flex-grow property to set the width of each column.`,
76
+ control: "text",
77
+ table: {
78
+ type: {
79
+ summary: "string",
80
+ },
81
+ defaultValue: {
82
+ summary: "1:1",
83
+ },
84
+ },
85
+ },
86
+ fields: {
87
+ description: "Array of control schemas for the fields in the fieldset.",
88
+ type: {
89
+ required: true,
90
+ name: "other",
91
+ value: "ControlSchema[]",
92
+ },
93
+ table: {
94
+ type: {
95
+ summary: "ControlSchema[]",
96
+ },
97
+ },
98
+ },
99
+ remove: {
100
+ description: `Method to call to remove field from the fieldset. When set - activates remove button.
101
+ \nUsed for \`property\`-based fieldsets.
102
+ Allows to remove selected fieldset.
103
+ Method should be defined in the blade \`scope\`.
104
+ \n Argument - \`id\` of the field to remove`,
105
+ table: {
106
+ type: {
107
+ summary: "{ method: string }",
108
+ },
109
+ defaultValue: {
110
+ summary: false,
111
+ },
112
+ },
113
+ },
114
+ },
115
+ parameters: {
116
+ componentSubtitle:
117
+ "Fieldset allows displaying sets of any available controls of any nested depth. It allows arranging elements in a grid with a customizable number of columns and aspect ratio that allows to control columns width, the ability to build a grid with multiple rows based on an array of data bound to the fieldset using the property option. It also has visibility state settings and ability to remove elements from the fieldset.",
118
+ docs: {
119
+ canvas: {
120
+ sourceState: "none",
121
+ },
122
+ },
123
+ },
124
+ } satisfies Meta<FieldsetSchema>;
125
+
126
+ export const SingleColumn: StoryFn<FieldsetSchema> = (args) => ({
127
+ components: { page },
128
+ setup() {
129
+ const context = reactive({
130
+ item: {
131
+ mockedProperty: "value",
132
+ mockedProperty2: "value2",
133
+ },
134
+ });
135
+ return { args, context };
136
+ },
137
+ template,
138
+ });
139
+
140
+ export const TwoColumns = SingleColumn.bind({});
141
+ TwoColumns.args = {
142
+ columns: 2,
143
+ };
144
+
145
+ export const ThreeColumns: StoryFn<FieldsetSchema> = (args) => ({
146
+ components: { page },
147
+ setup() {
148
+ const context = reactive({
149
+ item: {
150
+ mockedProperty: "value",
151
+ mockedProperty2: "value2",
152
+ mockedProperty3: "value3",
153
+ },
154
+ });
155
+ return { args, context };
156
+ },
157
+ template,
158
+ });
159
+ ThreeColumns.args = {
160
+ columns: 3,
161
+ fields: [
162
+ {
163
+ id: "fieldId",
164
+ component: "vc-input",
165
+ label: "Input field",
166
+ placeholder: "Enter text here",
167
+ property: "mockedProperty",
168
+ },
169
+ {
170
+ id: "fieldId2",
171
+ component: "vc-input",
172
+ label: "Input field 2",
173
+ placeholder: "Enter text here",
174
+ property: "mockedProperty2",
175
+ },
176
+ {
177
+ id: "fieldId3",
178
+ component: "vc-input",
179
+ label: "Input field 3",
180
+ placeholder: "Enter text here",
181
+ property: "mockedProperty3",
182
+ },
183
+ ],
184
+ };
185
+
186
+ export const ThreeColumnsWithAspectRatio = ThreeColumns.bind({});
187
+ ThreeColumnsWithAspectRatio.args = {
188
+ columns: 3,
189
+ aspectRatio: [1, 2, 1],
190
+ fields: [
191
+ {
192
+ id: "fieldId",
193
+ component: "vc-input",
194
+ label: "Input field",
195
+ placeholder: "Enter text here",
196
+ property: "mockedProperty",
197
+ },
198
+ {
199
+ id: "fieldId2",
200
+ component: "vc-input",
201
+ label: "Input field 2",
202
+ placeholder: "Enter text here",
203
+ property: "mockedProperty2",
204
+ },
205
+ {
206
+ id: "fieldId3",
207
+ component: "vc-input",
208
+ label: "Input field 3",
209
+ placeholder: "Enter text here",
210
+ property: "mockedProperty3",
211
+ },
212
+ ],
213
+ };
214
+
215
+ export const PropertyBasedFieldsetInTwoColumns: StoryFn<FieldsetSchema> = (args) => ({
216
+ components: { page },
217
+ setup() {
218
+ const context = reactive({
219
+ item: {
220
+ dataArray: [
221
+ {
222
+ id: 1,
223
+ value: "value1",
224
+ label: "Label 1",
225
+ description: "Description 1",
226
+ },
227
+ {
228
+ id: 2,
229
+ value: "value2",
230
+ label: "Label 2",
231
+ description: "Description 2",
232
+ },
233
+ {
234
+ id: 3,
235
+ value: "value3",
236
+ label: "Label 3",
237
+ description: "Description 2",
238
+ },
239
+ ],
240
+ },
241
+ });
242
+ return { args, context };
243
+ },
244
+ template,
245
+ });
246
+ PropertyBasedFieldsetInTwoColumns.args = {
247
+ property: "dataArray",
248
+ columns: 2,
249
+ fields: [
250
+ {
251
+ id: "fieldId",
252
+ component: "vc-input",
253
+ label: "{label}",
254
+ placeholder: "Enter text here",
255
+ property: "value",
256
+ },
257
+ {
258
+ id: "textareaId",
259
+ component: "vc-textarea",
260
+ label: "{label}",
261
+ property: "description",
262
+ },
263
+ ],
264
+ };
265
+
266
+ export const RemoveField: StoryFn<FieldsetSchema> = (args) => ({
267
+ components: { page },
268
+ setup() {
269
+ const context = reactive({
270
+ item: {
271
+ dataArray: [
272
+ {
273
+ id: 1,
274
+ value: "value1",
275
+ label: "Label 1",
276
+ },
277
+ {
278
+ id: 2,
279
+ value: "value2",
280
+ label: "Label 2",
281
+ },
282
+ {
283
+ id: 3,
284
+ value: "value3",
285
+ label: "Label 3",
286
+ },
287
+ ],
288
+ },
289
+ scope: {
290
+ removeField: (id: number) => {
291
+ context.item.dataArray.splice(id, 1);
292
+ },
293
+ },
294
+ });
295
+ return { args, context };
296
+ },
297
+ template,
298
+ });
299
+ RemoveField.args = {
300
+ property: "dataArray",
301
+ fields: [
302
+ {
303
+ id: "fieldId",
304
+ component: "vc-input",
305
+ label: "{label}",
306
+ placeholder: "Enter text here",
307
+ property: "value",
308
+ },
309
+ ],
310
+ remove: { method: "removeField" },
311
+ };
312
+
313
+ export const NestedFieldsetsWithHorizontalSeparator: StoryFn<FieldsetSchema> = (args) => ({
314
+ components: { page },
315
+ setup() {
316
+ const context = reactive({
317
+ item: {
318
+ mockedProperty: "value",
319
+ mockedProperty2: "value2",
320
+ mockedProperty3: "value3",
321
+ mockedProperty4: "value4",
322
+ },
323
+ });
324
+ return { args, context };
325
+ },
326
+ template,
327
+ });
328
+ NestedFieldsetsWithHorizontalSeparator.args = {
329
+ fields: [
330
+ {
331
+ id: "nestedFieldsetId",
332
+ component: "vc-fieldset",
333
+ fields: [
334
+ {
335
+ id: "fieldsetId",
336
+ component: "vc-fieldset",
337
+ columns: 2,
338
+ aspectRatio: [2, 1],
339
+ horizontalSeparator: true,
340
+ fields: [
341
+ {
342
+ id: "input1",
343
+ component: "vc-input",
344
+ label: "Input 1",
345
+ property: "mockedProperty",
346
+ },
347
+ {
348
+ id: "input2",
349
+ component: "vc-input",
350
+ label: "Input 2",
351
+ property: "mockedProperty2",
352
+ },
353
+ ],
354
+ },
355
+ {
356
+ id: "fieldsetId2",
357
+ component: "vc-fieldset",
358
+ columns: 2,
359
+ aspectRatio: [1, 2],
360
+ fields: [
361
+ {
362
+ id: "input1",
363
+ component: "vc-input",
364
+ label: "Input 1",
365
+ property: "mockedProperty3",
366
+ },
367
+ {
368
+ id: "input2",
369
+ component: "vc-input",
370
+ label: "Input 2",
371
+ property: "mockedProperty4",
372
+ },
373
+ ],
374
+ },
375
+ ],
376
+ },
377
+ ],
378
+ };
379
+
380
+ export const WithVisibilityMethod: StoryFn<FieldsetSchema> = (args) => ({
381
+ components: { page },
382
+ setup() {
383
+ const isVisible = ref(false);
384
+ const toggle = () => {
385
+ isVisible.value = !isVisible.value;
386
+ };
387
+
388
+ const context = reactive({
389
+ item: {
390
+ mockedProperty: "I am input field",
391
+ mockedProperty2: "I am input field 2",
392
+ },
393
+ scope: {
394
+ visibilityFn: isVisible,
395
+ },
396
+ });
397
+
398
+ return { args, context, toggle };
399
+ },
400
+ template: templateWithVisibilityToggle,
401
+ });
402
+ WithVisibilityMethod.args = {
403
+ visibility: { method: "visibilityFn" },
404
+ };
405
+
406
+ export const WithHorizontalSeparator = SingleColumn.bind({});
407
+ WithHorizontalSeparator.args = {
408
+ horizontalSeparator: true,
409
+ };
@@ -0,0 +1,239 @@
1
+ import { computed, reactive, ref } from "vue";
2
+ import { template, templateWithVisibilityToggle } from "./common/templates";
3
+ import page from "./pages/DynamicRender";
4
+ import { Meta, StoryFn } from "@storybook/vue3";
5
+ import { ICommonAsset } from "../../../../../..";
6
+ import * as _ from "lodash-es";
7
+ import { SchemaBaseArgTypes } from "./common/args";
8
+ import { GallerySchema } from "../../..";
9
+
10
+ export default {
11
+ title: "DynamicViews/molecules/VcGallery",
12
+ component: page,
13
+ args: {
14
+ id: "GalleryFieldId",
15
+ component: "vc-gallery",
16
+ property: "mockedImages",
17
+ },
18
+ argTypes: {
19
+ ..._.omit(SchemaBaseArgTypes, ["placeholder", "multilanguage", "update", "horizontalSeparator"]),
20
+ component: {
21
+ description: "Component type.",
22
+ type: {
23
+ required: true,
24
+ name: "string",
25
+ },
26
+ table: {
27
+ type: {
28
+ summary: "vc-gallery",
29
+ },
30
+ defaultValue: {
31
+ summary: "vc-gallery",
32
+ },
33
+ },
34
+ },
35
+ variant: {
36
+ description: "Gallery type.",
37
+ control: "radio",
38
+ options: ["gallery", "file-upload"],
39
+ table: {
40
+ type: {
41
+ summary: "gallery | file-upload",
42
+ },
43
+ defaultValue: {
44
+ summary: "gallery",
45
+ },
46
+ },
47
+ },
48
+ multiple: {
49
+ description: "Whether the gallery has multiple files upload or not.",
50
+ table: {
51
+ type: {
52
+ summary: "boolean",
53
+ },
54
+ defaultValue: {
55
+ summary: "false",
56
+ },
57
+ },
58
+ },
59
+ actions: {
60
+ description: "Gallery item button actions on hover.",
61
+ control: "object",
62
+ table: {
63
+ type: {
64
+ summary: `{
65
+ preview: boolean;
66
+ edit: boolean;
67
+ remove: boolean;
68
+ }`,
69
+ },
70
+ defaultValue: {
71
+ summary: `{ preview: true, edit: true, remove: true }`,
72
+ },
73
+ },
74
+ },
75
+ hideAfterUpload: {
76
+ description: "Whether the upload is hides after upload or not.",
77
+ table: {
78
+ type: {
79
+ summary: "boolean",
80
+ },
81
+ defaultValue: {
82
+ summary: "false",
83
+ },
84
+ },
85
+ },
86
+ },
87
+ parameters: {
88
+ docs: {
89
+ canvas: {
90
+ sourceState: "none",
91
+ },
92
+ },
93
+ },
94
+ } satisfies Meta<GallerySchema>;
95
+
96
+ const images = ref<ICommonAsset[]>([
97
+ {
98
+ id: "1",
99
+ url: "https://picsum.photos/200",
100
+ },
101
+ {
102
+ id: "2",
103
+ url: "https://picsum.photos/200",
104
+ },
105
+ {
106
+ id: "3",
107
+ url: "https://picsum.photos/200",
108
+ },
109
+ ]);
110
+
111
+ const assetsHandler = {
112
+ images: {
113
+ upload: (files: FileList) => {
114
+ const uploadedImages = ref<ICommonAsset[]>([]);
115
+ for (let i = 0; i < files.length; i++) {
116
+ uploadedImages.value.push({
117
+ id: Math.random().toString(36).substring(7),
118
+ url: URL.createObjectURL(files[i]),
119
+ });
120
+ }
121
+
122
+ return uploadedImages.value;
123
+ },
124
+ remove: (files: ICommonAsset[]) => images.value.filter((image) => !files.includes(image)),
125
+ edit: (files: ICommonAsset[]) => files,
126
+ },
127
+ };
128
+
129
+ export const Template: StoryFn<GallerySchema> = (args) => ({
130
+ components: { page },
131
+ setup: () => {
132
+ const context = reactive({
133
+ item: {
134
+ mockedImages: images,
135
+ },
136
+ scope: {
137
+ assetsHandler,
138
+ },
139
+ });
140
+
141
+ return { args, context };
142
+ },
143
+ template,
144
+ });
145
+
146
+ export const Label = Template.bind({});
147
+ Label.args = {
148
+ label: "Gallery label",
149
+ };
150
+
151
+ export const WithTooltip = Template.bind({});
152
+ WithTooltip.args = {
153
+ label: "Gallery label",
154
+ tooltip: "Gallery tooltip",
155
+ };
156
+
157
+ export const WithDisabled: StoryFn<GallerySchema> = (args) => ({
158
+ components: { page },
159
+ setup: () => {
160
+ const context = reactive({
161
+ item: {
162
+ mockedImages: images,
163
+ },
164
+ scope: {
165
+ assetsHandler: {
166
+ images: {},
167
+ },
168
+ disabledFn: computed(() => true),
169
+ },
170
+ });
171
+ return { args, context };
172
+ },
173
+ template,
174
+ });
175
+ WithDisabled.args = {
176
+ label: "Gallery label",
177
+ disabled: { method: "disabledFn" },
178
+ };
179
+
180
+ export const WithVisibilityMethod: StoryFn<GallerySchema> = (args) => ({
181
+ components: { page },
182
+ setup: () => {
183
+ const isVisible = ref(false);
184
+ const toggle = () => {
185
+ isVisible.value = !isVisible.value;
186
+ };
187
+
188
+ const context = reactive({
189
+ item: {
190
+ mockedImages: images,
191
+ },
192
+ scope: {
193
+ assetsHandler: {
194
+ images: {},
195
+ },
196
+ visibilityFn: isVisible,
197
+ },
198
+ });
199
+ return { args, context, toggle };
200
+ },
201
+ template: templateWithVisibilityToggle,
202
+ });
203
+ WithVisibilityMethod.args = {
204
+ label: "Gallery label",
205
+ visibility: { method: "visibilityFn" },
206
+ };
207
+
208
+ export const FileUpload: StoryFn<GallerySchema> = (args) => ({
209
+ components: { page },
210
+ setup: () => {
211
+ const image = ref([]);
212
+ const context = reactive({
213
+ item: {
214
+ mockedImages: image,
215
+ },
216
+ scope: {
217
+ assetsHandler,
218
+ },
219
+ });
220
+
221
+ return { args, context };
222
+ },
223
+ template,
224
+ });
225
+ FileUpload.storyName = "Single file upload with hide after upload";
226
+ FileUpload.args = {
227
+ variant: "file-upload",
228
+ hideAfterUpload: true,
229
+ };
230
+
231
+ export const WithoutItemActions = Template.bind({});
232
+ WithoutItemActions.args = {
233
+ label: "Gallery label",
234
+ actions: {
235
+ preview: false,
236
+ edit: false,
237
+ remove: false,
238
+ },
239
+ };