@weni/unnnic-system 3.0.4 → 3.0.5-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/components/DataTable/index.vue.d.ts +156 -0
  2. package/dist/components/DataTable/index.vue.d.ts.map +1 -0
  3. package/dist/components/DatePicker/DatePicker.vue.d.ts +2 -2
  4. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +3 -3
  5. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +1 -1
  6. package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
  7. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +18 -0
  8. package/dist/components/SelectSmart/SelectSmart.vue.d.ts.map +1 -1
  9. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +9 -0
  10. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
  11. package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts +9 -0
  12. package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -0
  13. package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts +15 -0
  14. package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts.map +1 -0
  15. package/dist/components/index.d.ts +263 -6
  16. package/dist/components/index.d.ts.map +1 -1
  17. package/dist/{es-91798705.mjs → es-e4780f92.mjs} +1 -1
  18. package/dist/{index-8110960e.mjs → index-c20c8a10.mjs} +9470 -9119
  19. package/dist/{pt-br-ca5eccc1.mjs → pt-br-9e604702.mjs} +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/unnnic.mjs +61 -58
  22. package/dist/unnnic.umd.js +44 -43
  23. package/package.json +2 -2
  24. package/src/assets/img/previews/doc-preview.png +0 -0
  25. package/src/assets/img/previews/image-preview.png +0 -0
  26. package/src/assets/img/previews/video-preview.png +0 -0
  27. package/src/components/DataTable/index.vue +493 -0
  28. package/src/components/ModalDialog/ModalDialog.vue +27 -29
  29. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -1
  30. package/src/components/SelectSmart/SelectSmart.vue +22 -1
  31. package/src/components/SelectSmart/SelectSmartMultipleHeader.vue +1 -1
  32. package/src/components/SelectSmart/SelectSmartOption.vue +5 -0
  33. package/src/components/TemplatePreview/TemplatePreview.vue +249 -0
  34. package/src/components/TemplatePreview/TemplatePreviewModal.vue +51 -0
  35. package/src/components/TemplatePreview/types.d.ts +16 -0
  36. package/src/components/index.ts +9 -0
  37. package/src/stories/DataTable.stories.js +332 -0
  38. package/src/stories/SelectSmart.stories.js +1 -1
  39. package/src/stories/TemplatePreview.stories.js +94 -0
  40. package/src/stories/TemplatePreviewModal.stories.js +110 -0
@@ -0,0 +1,332 @@
1
+ import UnnnicDataTable from '../components/DataTable/index.vue';
2
+ import { action } from '@storybook/addon-actions';
3
+
4
+ export default {
5
+ title: 'Data Display/DataTable',
6
+ component: UnnnicDataTable,
7
+ tags: ['autodocs'],
8
+ args: {
9
+ page: 1,
10
+ },
11
+ argTypes: {
12
+ headers: {
13
+ description:
14
+ 'Array of header items defining the structure of the table header.',
15
+ control: 'object',
16
+ },
17
+ items: {
18
+ description: 'Array of row items defining the content of the table rows.',
19
+ control: 'object',
20
+ },
21
+ size: {
22
+ description:
23
+ 'The size of the table. Options are `sm` for small and `md` for medium.',
24
+ control: { type: 'select' },
25
+ options: ['sm', 'md'],
26
+ },
27
+ page: {
28
+ description: 'The current page number for pagination.',
29
+ control: 'number',
30
+ },
31
+ pageTotal: {
32
+ description: 'The total number of pages available for pagination.',
33
+ control: 'number',
34
+ },
35
+ pageInterval: {
36
+ description: 'The number of items displayed per page.',
37
+ control: 'number',
38
+ },
39
+ isLoading: {
40
+ description: 'Indicates whether the table data is loading.',
41
+ control: 'boolean',
42
+ },
43
+ hideHeaders: {
44
+ description: 'Determines if the table headers should be hidden.',
45
+ control: 'boolean',
46
+ },
47
+ height: {
48
+ description: 'The height of the table.',
49
+ control: 'text',
50
+ },
51
+ maxHeight: {
52
+ description: 'The maximum height of the table.',
53
+ control: 'text',
54
+ },
55
+ clickable: {
56
+ description: 'Indicates whether the table rows should be clickable.',
57
+ control: 'boolean',
58
+ },
59
+ fixedHeaders: {
60
+ description:
61
+ 'Indicates whether the table headers should be fixed in scroll.',
62
+ control: 'boolean',
63
+ },
64
+ hidePagination: {
65
+ description: 'Indicates whether the pagination should be hidden.',
66
+ control: 'boolean',
67
+ },
68
+ locale: {
69
+ description: 'The locale for the table translations.',
70
+ control: { type: 'select' },
71
+ options: ['en', 'pt-br', 'es'],
72
+ },
73
+ },
74
+ render: (args) => ({
75
+ components: {
76
+ UnnnicDataTable,
77
+ },
78
+ setup() {
79
+ const sort = ({ order, header }) => {
80
+ action('update:sort')({ order, header });
81
+ if (order === 'asc')
82
+ args.items = args.items.sort((a, b) => a.id - b.id);
83
+ if (order === 'desc')
84
+ args.items = args.items.sort((a, b) => b.id - a.id);
85
+ };
86
+ const updatePage = (page) => {
87
+ action('update:page')(page);
88
+ args.page = page;
89
+ };
90
+ const itemClick = (item) => {
91
+ action('itemClick')(item);
92
+ };
93
+
94
+ return { args, sort, updatePage, itemClick };
95
+ },
96
+ template: `
97
+ <UnnnicDataTable
98
+ v-bind="args"
99
+ :headers="args.headers"
100
+ :items="args.items"
101
+ :pageTotal="125"
102
+ :pageInterval="5"
103
+ @update:sort="sort"
104
+ @update:page="updatePage"
105
+ @itemClick="itemClick"
106
+ >
107
+ </UnnnicDataTable>
108
+ `,
109
+ }),
110
+ };
111
+
112
+ const headers = [
113
+ {
114
+ title: 'ID',
115
+ itemKey: 'id',
116
+ isSortable: true,
117
+ },
118
+ {
119
+ title: 'Name',
120
+ itemKey: 'name',
121
+ },
122
+ {
123
+ title: 'Age',
124
+ itemKey: 'age',
125
+ },
126
+ {
127
+ title: 'Country',
128
+ itemKey: 'country',
129
+ },
130
+ ];
131
+
132
+ const items = [
133
+ {
134
+ id: '1',
135
+ name: 'Eduardo',
136
+ age: 27,
137
+ country: 'Brazil',
138
+ },
139
+ {
140
+ id: '2',
141
+ name: 'Marcus',
142
+ age: 27,
143
+ country: 'Brazil',
144
+ },
145
+ {
146
+ id: '3',
147
+ name: 'Paulo',
148
+ age: 29,
149
+ country: 'Brazil',
150
+ },
151
+ {
152
+ id: '4',
153
+ name: 'Cristian',
154
+ age: 27,
155
+ country: 'Brazil',
156
+ },
157
+ {
158
+ id: '5',
159
+ name: 'Aldemylla',
160
+ age: 27,
161
+ country: 'Brazil',
162
+ },
163
+ ];
164
+
165
+ export const Default = {
166
+ args: {
167
+ headers,
168
+ items,
169
+ },
170
+ };
171
+
172
+ export const Clickable = {
173
+ args: {
174
+ headers,
175
+ items,
176
+ clickable: true,
177
+ },
178
+ };
179
+
180
+ export const WithHeightLimit = {
181
+ args: {
182
+ headers,
183
+ items,
184
+ height: '165px',
185
+ },
186
+ };
187
+
188
+ export const FixedHeaders = {
189
+ args: {
190
+ headers,
191
+ items,
192
+ fixedHeaders: true,
193
+ height: '165px',
194
+ },
195
+ };
196
+
197
+ export const Medium = {
198
+ args: {
199
+ headers,
200
+ items,
201
+ size: 'md',
202
+ },
203
+ };
204
+
205
+ export const Small = {
206
+ args: {
207
+ headers,
208
+ items,
209
+ size: 'sm',
210
+ },
211
+ };
212
+
213
+ export const HideHeaders = {
214
+ args: {
215
+ headers,
216
+ items,
217
+ hideHeaders: true,
218
+ },
219
+ };
220
+
221
+ export const SlotHeader = {
222
+ args: { headers, items },
223
+ render: (args) => ({
224
+ components: {
225
+ UnnnicDataTable,
226
+ },
227
+ setup() {
228
+ const sort = ({ order, header }) => {
229
+ action('update:sort')({ order, header });
230
+ if (order === 'asc')
231
+ args.items = args.items.sort((a, b) => a.id - b.id);
232
+ if (order === 'desc')
233
+ args.items = args.items.sort((a, b) => b.id - a.id);
234
+ };
235
+ const updatePage = (page) => {
236
+ action('update:page')(page);
237
+ args.page = page;
238
+ };
239
+ const itemClick = (item) => {
240
+ action('itemClick')(item);
241
+ };
242
+
243
+ return { args, sort, updatePage, itemClick };
244
+ },
245
+ template: `
246
+ <UnnnicDataTable
247
+ v-bind="args"
248
+ :headers="args.headers"
249
+ :items="args.items"
250
+ :pageTotal="125"
251
+ :pageInterval="5"
252
+ @update:sort="sort"
253
+ @update:page="updatePage"
254
+ @itemClick="itemClick"
255
+ >
256
+ <template #header-name="{ header }">
257
+ <button>
258
+ {{ header.title }}
259
+ </button>
260
+ </template>
261
+ </UnnnicDataTable>
262
+ `,
263
+ }),
264
+ };
265
+
266
+ export const SlotItem = {
267
+ args: { headers, items },
268
+ render: (args) => ({
269
+ components: {
270
+ UnnnicDataTable,
271
+ },
272
+ setup() {
273
+ const sort = ({ order, header }) => {
274
+ action('update:sort')({ order, header });
275
+ if (order === 'asc')
276
+ args.items = args.items.sort((a, b) => a.id - b.id);
277
+ if (order === 'desc')
278
+ args.items = args.items.sort((a, b) => b.id - a.id);
279
+ };
280
+ const updatePage = (page) => {
281
+ action('update:page')(page);
282
+ args.page = page;
283
+ };
284
+ const itemClick = (item) => {
285
+ action('itemClick')(item);
286
+ };
287
+
288
+ return { args, sort, updatePage, itemClick };
289
+ },
290
+ template: `
291
+ <UnnnicDataTable
292
+ v-bind="args"
293
+ :headers="args.headers"
294
+ :items="args.items"
295
+ :pageTotal="125"
296
+ :pageInterval="5"
297
+ @update:sort="sort"
298
+ @update:page="updatePage"
299
+ @itemClick="itemClick"
300
+ >
301
+ <template #body-id="{ item }">
302
+ <button>
303
+ {{ item.id }}
304
+ </button>
305
+ </template>
306
+ </UnnnicDataTable>
307
+ `,
308
+ }),
309
+ };
310
+
311
+ export const HidePagination = {
312
+ args: {
313
+ headers,
314
+ items,
315
+ hidePagination: true,
316
+ },
317
+ };
318
+
319
+ export const WithoutResults = {
320
+ args: {
321
+ headers,
322
+ items: [],
323
+ },
324
+ };
325
+
326
+ export const Loading = {
327
+ args: {
328
+ headers,
329
+ items,
330
+ isLoading: true,
331
+ },
332
+ };
@@ -284,7 +284,7 @@ export const Multiple = {
284
284
  { value: 'spain', label: 'Espanha' },
285
285
  { value: 'saudi_arabia', label: 'Arábia Saudita' },
286
286
  ],
287
- multiple: true,
287
+ multiple:true,
288
288
  multipleWithoutSelectsMessage: 'No country selected yet :(',
289
289
  },
290
290
  };
@@ -0,0 +1,94 @@
1
+ import UnnnicTemplatePreview from "../components/TemplatePreview/TemplatePreview.vue";
2
+
3
+ export default {
4
+ title: "example/TemplatePreview",
5
+ tags: ["autodocs"],
6
+ component: UnnnicTemplatePreview,
7
+ };
8
+
9
+ const Template = (args) => ({
10
+ components: { UnnnicTemplatePreview },
11
+ setup() {
12
+ return { args };
13
+ },
14
+ template: `
15
+ <unnnic-template-preview v-bind="args" />
16
+ `,
17
+ });
18
+
19
+ const bodyText =
20
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sem orci, ultrices id lectus non, vehicula suscipit libero. Ut vehicula libero a tempus fringilla. Nam tincidunt vestibulum maximus. Morbi vel pretium risus. Curabitur id quam lectus. Quisque dolor elit, auctor a lacus non, rutrum ullamcorper mi. Nulla et turpis sed eros pharetra ullamcorper fermentum ac nisl. Donec lacinia hendrerit tellus, sit amet suscipit velit vestibulum sed. Praesent gravida posuere metus, ut fringilla dolor euismod vel. Aenean vel ipsum magna. Integer metus mi, fermentum ut nulla at, facilisis lobortis metus. Ut vitae tortor posuere, dapibus leo quis, finibus neque.";
21
+
22
+ export const Default = Template.bind({});
23
+ Default.args = {
24
+ template: {
25
+ header: {
26
+ type: "TEXT",
27
+ text: "Hello, world!",
28
+ },
29
+ footer: "Weni by VTEX",
30
+ buttons: [
31
+ {
32
+ text: "Button 1",
33
+ type: "PHONE_NUMBER",
34
+ },
35
+ {
36
+ text: "Button 2",
37
+ type: "URL",
38
+ },
39
+ {
40
+ text: "Button 3",
41
+ type: "QUICK_REPLY",
42
+ },
43
+ ],
44
+ body: bodyText,
45
+ },
46
+ };
47
+
48
+ export const Image = Template.bind({});
49
+ Image.args = {
50
+ template: {
51
+ header: {
52
+ type: "MEDIA",
53
+ mediaType: "IMAGE",
54
+ },
55
+ footer: "Weni by VTEX",
56
+ body: bodyText,
57
+ },
58
+ };
59
+
60
+ export const Video = Template.bind({});
61
+ Video.args = {
62
+ template: {
63
+ header: {
64
+ type: "MEDIA",
65
+ mediaType: "VIDEO",
66
+ },
67
+ buttons: [
68
+ {
69
+ text: "Button 1",
70
+ type: "PHONE_NUMBER",
71
+ },
72
+ {
73
+ text: "Button 2",
74
+ type: "URL",
75
+ },
76
+ {
77
+ text: "Button 3",
78
+ type: "QUICK_REPLY",
79
+ },
80
+ ],
81
+ },
82
+ };
83
+
84
+ export const Document = Template.bind({});
85
+ Document.args = {
86
+ template: {
87
+ header: {
88
+ type: "MEDIA",
89
+ mediaType: "DOCUMENT",
90
+ },
91
+ footer: "Weni by VTEX",
92
+ body: bodyText,
93
+ },
94
+ };
@@ -0,0 +1,110 @@
1
+ import UnnnicTemplatePreviewModal from "../components/TemplatePreview/TemplatePreviewModal.vue";
2
+
3
+ import { action } from "@storybook/addon-actions";
4
+
5
+ export default {
6
+ title: "example/TemplatePreviewModal",
7
+ tags: ["autodocs"],
8
+ component: UnnnicTemplatePreviewModal,
9
+ argTypes: {
10
+ locale: {
11
+ control: { type: "select" },
12
+ options: ["pt-br", "en", "es"],
13
+ },
14
+ },
15
+ };
16
+
17
+ const Template = (args) => ({
18
+ components: { UnnnicTemplatePreviewModal },
19
+ setup() {
20
+ const close = () => {
21
+ action("close")();
22
+ args.modelValue = false;
23
+ };
24
+ return { args, close };
25
+ },
26
+ template: `
27
+ <div>
28
+ <button @click="args.modelValue = true">Open Modal</button>
29
+ <unnnic-template-preview-modal v-bind="args" @close="close" />
30
+ </div>
31
+ `,
32
+ });
33
+
34
+ const bodyText =
35
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sem orci, ultrices id lectus non, vehicula suscipit libero. Ut vehicula libero a tempus fringilla. Nam tincidunt vestibulum maximus. Morbi vel pretium risus. Curabitur id quam lectus. Quisque dolor elit, auctor a lacus non, rutrum ullamcorper mi. Nulla et turpis sed eros pharetra ullamcorper fermentum ac nisl. Donec lacinia hendrerit tellus, sit amet suscipit velit vestibulum sed. Praesent gravida posuere metus, ut fringilla dolor euismod vel. Aenean vel ipsum magna. Integer metus mi, fermentum ut nulla at, facilisis lobortis metus. Ut vitae tortor posuere, dapibus leo quis, finibus neque.";
36
+
37
+ export const Default = Template.bind({});
38
+ Default.args = {
39
+ modelValue: false,
40
+ template: {
41
+ header: {
42
+ type: "TEXT",
43
+ text: "Hello, world!",
44
+ },
45
+ footer: "Weni by VTEX",
46
+ buttons: [
47
+ {
48
+ text: "Button 1",
49
+ type: "PHONE_NUMBER",
50
+ },
51
+ {
52
+ text: "Button 2",
53
+ type: "URL",
54
+ },
55
+ {
56
+ text: "Button 3",
57
+ type: "QUICK_REPLY",
58
+ },
59
+ ],
60
+ body: bodyText,
61
+ },
62
+ };
63
+
64
+ export const Image = Template.bind({});
65
+ Image.args = {
66
+ template: {
67
+ header: {
68
+ type: "MEDIA",
69
+ mediaType: "IMAGE",
70
+ },
71
+ footer: "Weni by VTEX",
72
+ body: bodyText,
73
+ },
74
+ };
75
+
76
+ export const Video = Template.bind({});
77
+ Video.args = {
78
+ template: {
79
+ header: {
80
+ type: "MEDIA",
81
+ mediaType: "VIDEO",
82
+ },
83
+ buttons: [
84
+ {
85
+ text: "Button 1",
86
+ type: "PHONE_NUMBER",
87
+ },
88
+ {
89
+ text: "Button 2",
90
+ type: "URL",
91
+ },
92
+ {
93
+ text: "Button 3",
94
+ type: "QUICK_REPLY",
95
+ },
96
+ ],
97
+ },
98
+ };
99
+
100
+ export const Document = Template.bind({});
101
+ Document.args = {
102
+ template: {
103
+ header: {
104
+ type: "MEDIA",
105
+ mediaType: "DOCUMENT",
106
+ },
107
+ footer: "Weni by VTEX",
108
+ body: bodyText,
109
+ },
110
+ };