@vcita/design-system 0.0.12-prod.beta.27 → 0.1.2

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 (102) hide show
  1. package/README.md +30 -21
  2. package/dist/@vcita/design-system.esm.js +519 -676
  3. package/dist/@vcita/design-system.min.js +1 -1
  4. package/dist/@vcita/design-system.ssr.js +449 -608
  5. package/init/DesignSystem.js +77 -0
  6. package/init/VcSvg/VcSvg.stories.js +25 -0
  7. package/{src/components → init}/VcSvg/VcSvg.vue +0 -0
  8. package/init/vuetify.config.js +132 -0
  9. package/package.json +6 -5
  10. package/src/assets/logo.png +0 -0
  11. package/src/assets/logo.svg +1 -0
  12. package/src/components/VcActionList/VcActionList.spec.js +57 -0
  13. package/src/components/VcActionList/VcActionList.stories.js +56 -0
  14. package/src/components/VcActionList/VcActionList.vue +1 -1
  15. package/src/components/VcActions/VcActions.spec.js +153 -0
  16. package/src/components/VcActions/VcActions.stories.js +103 -0
  17. package/src/components/VcActions/VcActions.vue +14 -6
  18. package/src/components/VcAlert/VcAlert.spec.js +162 -0
  19. package/src/components/VcAlert/VcAlert.stories.js +105 -0
  20. package/src/components/VcAlert/VcAlert.vue +7 -8
  21. package/src/components/VcAutoComplete/VcAutoComplete.spec.js +67 -0
  22. package/src/components/VcAutoComplete/VcAutoComplete.stories.js +99 -0
  23. package/src/components/VcAvatar/VcAvatar.spec.js +110 -0
  24. package/src/components/VcAvatar/VcAvatar.stories.js +101 -0
  25. package/src/components/VcBottomActions/VcBottomActions.spec.js +64 -0
  26. package/src/components/VcBottomActions/VcBottomActions.stories.js +103 -0
  27. package/src/components/VcBottomActions/VcBottomActions.vue +4 -4
  28. package/src/components/VcButton/VcButton.spec.js +181 -0
  29. package/src/components/VcButton/VcButton.stories.js +123 -0
  30. package/src/components/VcButton/VcButton.stories.mdx.old +40 -0
  31. package/src/components/VcButtonGroup/VcButtonGroup.spec.js +209 -0
  32. package/src/components/VcButtonGroup/VcButtonGroup.stories.js +109 -0
  33. package/src/components/VcButtonGroup/VcButtonGroup.vue +5 -1
  34. package/src/components/VcCard/VcCard.spec.js +38 -0
  35. package/src/components/VcCard/VcCard.stories.js +28 -0
  36. package/src/components/VcCard/VcCard.vue +46 -0
  37. package/src/components/VcExpansionPanels/VcExpansionPanels.stories.js +36 -0
  38. package/src/components/VcForm/VcForm.spec.js +38 -0
  39. package/src/components/VcForm/VcForm.stories.js +44 -0
  40. package/src/components/VcHourInput/VcHourInput.stories.js +36 -0
  41. package/src/components/VcIcon/VcIcon.spec.js +38 -0
  42. package/src/components/VcIcon/VcIcon.stories.js +53 -0
  43. package/src/components/VcIconWithTooltip/VcIconWithTooltip.spec.js +156 -0
  44. package/src/components/VcIconWithTooltip/VcIconWithTooltip.stories.js +77 -0
  45. package/src/components/VcIconWithTooltip/VcIconWithTooltip.vue +7 -6
  46. package/src/components/VcLayout/VcLayout.spec.js +38 -0
  47. package/src/components/VcLayout/VcLayout.stories.js +26 -0
  48. package/src/components/VcLoader/VcLoader.spec.js +38 -0
  49. package/src/components/VcLoader/VcLoader.stories.js +30 -0
  50. package/src/components/VcLoader/VcLoader.vue +1 -1
  51. package/src/components/VcMenu/VcMenu.spec.js +38 -0
  52. package/src/components/VcMenu/VcMenu.stories.js +45 -0
  53. package/src/components/VcSwitch/VcSwitch.spec.js +38 -0
  54. package/src/components/VcSwitch/VcSwitch.stories.js +87 -0
  55. package/src/components/VcSwitch/VcSwitch.vue +14 -1
  56. package/src/components/VcTextArea/VcTextArea.spec.js +41 -0
  57. package/src/components/VcTextArea/VcTextArea.stories.js +144 -0
  58. package/src/components/VcTextArea/VcTextArea.vue +21 -10
  59. package/src/components/VcTextField/VcTextField.spec.js +170 -0
  60. package/src/components/VcTextField/VcTextField.stories.js +65 -0
  61. package/src/components/VcTextField/VcTextField.vue +4 -3
  62. package/src/components/VcToast/VcToast.spec.js +75 -0
  63. package/src/components/VcToast/VcToast.stories.js +80 -0
  64. package/src/components/VcToast/VcToast.vue +11 -15
  65. package/src/components/VcTooltip/VcTooltip.spec.js +58 -0
  66. package/src/components/VcTooltip/VcTooltip.stories.js +163 -0
  67. package/src/components/VcTooltip/VcTooltip.vue +4 -4
  68. package/src/components/index.js +26 -0
  69. package/src/components/modal/VcConfirmModal/VcConfirmModal.spec.js +48 -0
  70. package/src/components/modal/VcConfirmModal/VcConfirmModal.stories.js +142 -0
  71. package/src/components/modal/VcConfirmProminentModal/VcConfirmProminentModal.spec.js +49 -0
  72. package/src/components/modal/VcConfirmProminentModal/VcConfirmProminentModal.stories.js +53 -0
  73. package/src/components/modal/VcInputModal/VcInputModal.spec.js +79 -0
  74. package/src/components/modal/VcInputModal/VcInputModal.stories.js +188 -0
  75. package/src/components/modal/VcNoticeModal/VcNoticeModal.spec.js +54 -0
  76. package/src/components/modal/VcNoticeModal/VcNoticeModal.stories.js +136 -0
  77. package/src/components/modal/elements/VcModalContainer.spec.js +38 -0
  78. package/src/components/modal/elements/VcModalContainer.stories.js +49 -0
  79. package/src/components/modal/elements/VcModalFooter.spec.js +82 -0
  80. package/src/components/modal/elements/VcModalFooter.stories.js +47 -0
  81. package/src/components/modal/elements/VcModalHeader.spec.js +103 -0
  82. package/src/components/modal/elements/VcModalHeader.stories.js +91 -0
  83. package/src/components/modal/elements/VcModalWrapper.spec.js +38 -0
  84. package/src/components/modal/elements/VcModalWrapper.stories.js +34 -0
  85. package/src/entry.esm.js +16 -0
  86. package/src/entry.js +13 -0
  87. package/src/scss/_i18n-mixins.scss +174 -0
  88. package/src/scss/mixins.scss +7 -0
  89. package/src/stories/assets/HeaderImage.svg +9 -0
  90. package/src/stories/assets/code-brackets.svg +1 -0
  91. package/src/stories/assets/colors.svg +1 -0
  92. package/src/stories/assets/comments.svg +1 -0
  93. package/src/stories/assets/direction.svg +1 -0
  94. package/src/stories/assets/flow.svg +1 -0
  95. package/src/stories/assets/plugin.svg +1 -0
  96. package/src/stories/assets/rabbit.svg +17 -0
  97. package/src/stories/assets/repo.svg +1 -0
  98. package/src/stories/assets/stackalt.svg +1 -0
  99. package/src/stories/colors.stories.mdx +78 -0
  100. package/src/stories/welcome.stories.mdx +210 -0
  101. package/styles/variables.scss +65 -7
  102. package/utils/colorUtil.js +41 -0
@@ -0,0 +1,103 @@
1
+ import VcActionsCmp from "./VcActions";
2
+
3
+ const GeneralTemplate = (args, {argTypes}) => ({
4
+ components: {VcActions: VcActionsCmp},
5
+ props: Object.keys(argTypes),
6
+ template: `
7
+ <div>
8
+ <vcActions :items="items"
9
+ :header="header"
10
+ v-model="showSheet"
11
+ :title="title"
12
+ :client="client"
13
+ :data-qa="dataQa"
14
+ @close="onClose"
15
+ @action="onAction">
16
+ <template v-slot="{attrs, on}">
17
+ <v-icon v-bind="attrs" v-on="on"
18
+ @click="showSheet = !showSheet">
19
+ $three_dots
20
+ </v-icon>
21
+ </template>
22
+ </vcActions>
23
+ </div>`,
24
+ })
25
+
26
+ export const Playground = GeneralTemplate.bind({});
27
+
28
+ // Set default values
29
+ Playground.args = {
30
+ showSheet: false,
31
+ items: [
32
+ {
33
+ title: 'Move to guest list',
34
+ event: 'moveToGustList',
35
+ icon: 'information'
36
+ }, {
37
+ title: 'Remove from waitlist',
38
+ event: 'remove',
39
+ icon: 'example'
40
+ }, {
41
+ title: 'Go to client page',
42
+ event: 'goToClientPage',
43
+ icon: 'vip'
44
+ }
45
+ ],
46
+ header: true,
47
+ title: `Ronald's actions`,
48
+ client: {
49
+ imagePath: 'https://i.picsum.photos/id/1025/4951/3301.jpg?hmac=_aGh5AtoOChip_iaMo8ZvvytfEojcgqbCH7dzaz-H8Y',
50
+ name: 'Victor Chohen',
51
+ firstName: 'Ronald',
52
+ colorId: 1
53
+ },
54
+ dataQa: 'playground-qa'
55
+ }
56
+
57
+ export const No_icons = GeneralTemplate.bind({});
58
+
59
+ // Set default values
60
+ No_icons.args = {
61
+ showSheet: false,
62
+ items: [
63
+ {
64
+ title: 'Move to guest list',
65
+ event: 'moveToGustList',
66
+ }, {
67
+ title: 'Remove from waitlist',
68
+ event: 'remove',
69
+ }, {
70
+ title: 'Go to client page',
71
+ event: 'goToClientPage',
72
+ }
73
+ ],
74
+ header: true,
75
+ title: `Ronald's actions`,
76
+ client: {
77
+ imagePath: 'https://i.picsum.photos/id/1025/4951/3301.jpg?hmac=_aGh5AtoOChip_iaMo8ZvvytfEojcgqbCH7dzaz-H8Y',
78
+ name: 'Victor Chohen',
79
+ firstName: 'Ronald',
80
+ colorId: 1
81
+ },
82
+ dataQa: 'playground-qa'
83
+ }
84
+
85
+ export default {
86
+ title: 'Controls / VcActions',
87
+ id: 'VcActions',
88
+ component: VcActionsCmp,
89
+ argTypes: {
90
+ onAction: { action: 'onAction'},
91
+ onClose: { action: 'onClose'},
92
+ },
93
+ parameters: {
94
+ design: {
95
+ type: 'figma',
96
+ url: 'https://www.figma.com/file/lF4Iiyl1UcTQqWpszonNsx/Event\'s-Waitlist?node-id=617%3A83022',
97
+ },
98
+ status: {
99
+ type: 'beta', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
100
+ url: 'https://vuetifyjs.com/en/components/bottom-sheets/',
101
+ }
102
+ },
103
+ };
@@ -1,10 +1,14 @@
1
1
  <template>
2
2
  <component :is="isMobile ? 'VcBottomActions' : 'VcActionList'"
3
- @input="handleSheet('input', $event)"
4
- :value="showSheet"
3
+ @action="handleSheet($event)"
4
+ @close="handleCloseSheet()"
5
+ v-model="showSheet"
5
6
  v-bind="$props">
6
7
  <template v-slot="{attrs, on}">
7
- <v-icon v-bind="attrs" v-on="on">$three_dots</v-icon>
8
+ <v-icon v-bind="attrs" v-on="on"
9
+ @click="showSheet = !showSheet">
10
+ $three_dots
11
+ </v-icon>
8
12
  </template>
9
13
  </component>
10
14
  </template>
@@ -51,9 +55,13 @@ export default {
51
55
  },
52
56
  },
53
57
  methods: {
54
- handleSheet(action, sheet) {
55
- this.showSheet = sheet.isOpen
56
- this.$emit('input', {action, sheet})
58
+ handleSheet(action) {
59
+ this.showSheet = false
60
+ this.$emit('action', action)
61
+ },
62
+ handleCloseSheet() {
63
+ this.showSheet = false
64
+ this.$emit('close')
57
65
  }
58
66
  }
59
67
  };
@@ -0,0 +1,162 @@
1
+ import '@testing-library/jest-dom'
2
+ import VcAlert from "./VcAlert.vue";
3
+ import Vuetify from 'vuetify'
4
+ import {render} from "@testing-library/vue";
5
+ import init from "../../../testing-library.config";
6
+ import userEvent from "@testing-library/user-event";
7
+
8
+ init();
9
+
10
+ describe("VcAlert.vue", () => {
11
+
12
+ const renderWithVuetify = (component, options, callback) => {
13
+ const root = document.createElement('div')
14
+ root.setAttribute('data-app', 'true')
15
+
16
+ return render(
17
+ component,
18
+ {
19
+ container: document.body.appendChild(root),
20
+ // for Vuetify components that use the vuetify instance property
21
+ vuetify: new Vuetify(),
22
+ ...options,
23
+ mocks: {},
24
+ },
25
+ callback,
26
+ )
27
+ }
28
+
29
+ it("shows info alert", async () => {
30
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
31
+ const {container, getByTestId, getByText, emitted} = renderWithVuetify(VcAlert, {
32
+ props: {
33
+ type: 'info',
34
+ headerText: 'header text',
35
+ bodyText: 'body text',
36
+ buttonText: 'button text',
37
+ dataQa: 'infoAlert'
38
+ }
39
+ })
40
+
41
+ // Expect options: https://github.com/testing-library/jest-dom
42
+ expect(container).toHaveAttribute('data-app', 'true');
43
+
44
+ const alert = getByTestId('infoAlert');
45
+ expect(alert).toBeInTheDocument();
46
+ expect(alert).toHaveClass('vcita-alert-info');
47
+
48
+ const header = getByText('header text');
49
+ expect(header).toBeInTheDocument();
50
+
51
+ const body = getByText('body text');
52
+ expect(body).toBeInTheDocument();
53
+
54
+ const actionButton = getByText('button text');
55
+ expect(actionButton).toBeInTheDocument();
56
+ await userEvent.click(actionButton);
57
+ expect(emitted().onAction.length).toBe(1);
58
+ });
59
+
60
+ it("shows warning alert with close button", async () => {
61
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
62
+ const {container, getByTestId, emitted} = renderWithVuetify(VcAlert, {
63
+ props: {
64
+ type: 'warning',
65
+ closeButton: true,
66
+ dataQa: 'warningAlert'
67
+ }
68
+ })
69
+
70
+ // Expect options: https://github.com/testing-library/jest-dom
71
+ expect(container).toHaveAttribute('data-app', 'true');
72
+
73
+ const alert = getByTestId('warningAlert');
74
+ expect(alert).toBeInTheDocument();
75
+ expect(alert).toHaveClass('vcita-alert-warning');
76
+
77
+ const closeButton = getByTestId('alert-close-btn');
78
+ expect(closeButton).toBeInTheDocument();
79
+
80
+ await userEvent.click(closeButton);
81
+ expect(emitted().closeAlert.length).toBe(1);
82
+ });
83
+
84
+ it("shows attention alert", () => {
85
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
86
+ const {container, getByTestId} = renderWithVuetify(VcAlert, {
87
+ props: {
88
+ type: 'attention',
89
+ dataQa: 'attentionAlert'
90
+ }
91
+ })
92
+
93
+ // Expect options: https://github.com/testing-library/jest-dom
94
+ expect(container).toHaveAttribute('data-app', 'true');
95
+
96
+ const alert = getByTestId('attentionAlert');
97
+ expect(alert).toBeInTheDocument();
98
+ expect(alert).toHaveClass('vcita-alert-attention');
99
+ });
100
+
101
+ it("shows success alert", () => {
102
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
103
+ const {container, getByTestId} = renderWithVuetify(VcAlert, {
104
+ props: {
105
+ type: 'success',
106
+ dataQa: 'successAlert'
107
+ }
108
+ })
109
+
110
+ // Expect options: https://github.com/testing-library/jest-dom
111
+ expect(container).toHaveAttribute('data-app', 'true');
112
+
113
+ const alert = getByTestId('successAlert');
114
+ expect(alert).toBeInTheDocument();
115
+ expect(alert).toHaveClass('vcita-alert-success');
116
+ });
117
+
118
+ it("shows success alert with stripe", () => {
119
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
120
+ const {container, getByTestId} = renderWithVuetify(VcAlert, {
121
+ props: {
122
+ type: 'success',
123
+ isStripe: true,
124
+ dataQa: 'successAlert'
125
+ }
126
+ })
127
+
128
+ // Expect options: https://github.com/testing-library/jest-dom
129
+ expect(container).toHaveAttribute('data-app', 'true');
130
+
131
+ const alert = getByTestId('successAlert');
132
+ expect(alert).toBeInTheDocument();
133
+ expect(alert).toHaveClass('vcita-alert-success');
134
+ expect(alert).toHaveClass('stripe');
135
+ });
136
+
137
+ it("shows success alert with inline header", () => {
138
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
139
+ const {container, getByTestId, getByText} = renderWithVuetify(VcAlert, {
140
+ props: {
141
+ type: 'success',
142
+ headerText: 'header text',
143
+ bodyText: 'body text',
144
+ dataQa: 'successAlert',
145
+ isInlineHeader: true
146
+ }
147
+ })
148
+
149
+ // Expect options: https://github.com/testing-library/jest-dom
150
+ expect(container).toHaveAttribute('data-app', 'true');
151
+
152
+ const alert = getByTestId('successAlert');
153
+ expect(alert).toBeInTheDocument();
154
+ expect(alert).toHaveClass('vcita-alert-success');
155
+
156
+ const header = getByText('header text');
157
+ expect(header).toBeInTheDocument();
158
+
159
+ const body = getByText('body text');
160
+ expect(body).toBeInTheDocument();
161
+ });
162
+ });
@@ -0,0 +1,105 @@
1
+ import {action} from '@storybook/addon-actions'
2
+ import VcAlertCmp from './VcAlert';
3
+
4
+ const GeneralTemplate = (args, {argTypes}) => ({
5
+ components: {VcAlert: VcAlertCmp},
6
+ props: Object.keys(argTypes),
7
+ template: `
8
+ <VcAlert :type="type"
9
+ :header-text="headerText"
10
+ :body-text="bodyText"
11
+ :button-text="buttonText"
12
+ :closeButton="closeButton"
13
+ :is-stripe="isStripe"
14
+ :isInlineHeader="isInlineHeader"
15
+ :data-qa="dataQa"
16
+ @onAction="onAction"
17
+ @closeAlert="closeAlertAction"
18
+ />`,
19
+ methods: {
20
+ closeAlertAction: action('closeAlert')
21
+ }
22
+ })
23
+
24
+ export const Playground = GeneralTemplate.bind({});
25
+
26
+ // Set default values
27
+ Playground.args = {
28
+ type: 'attention',
29
+ headerText: 'Header:',
30
+ bodyText: `I learned long ago, never to wrestle with a pig.
31
+ You get dirty, and besides, the pig likes it. <a href="https://images.squarespace-cdn.com/content/v1/5b71e83f1aef1d3e4bbd03f2/1534201222036-JHLKSIPN8AOXD4XNLRAN/Esther_main_image_1.jpg?format=2500w"
32
+ target="_blank">Link</a>`,
33
+ closeButton: true,
34
+ isStripe: false,
35
+ isInlineHeader: false,
36
+ dataQa: 'vcita-alert',
37
+ }
38
+
39
+ export const WithButton = GeneralTemplate.bind({});
40
+
41
+ // Set default values
42
+ WithButton.args = {
43
+ type: 'attention',
44
+ headerText: 'Header:',
45
+ bodyText: `I learned long ago, never to wrestle with a pig.
46
+ You get dirty, and besides, the pig likes it. <a href="https://images.squarespace-cdn.com/content/v1/5b71e83f1aef1d3e4bbd03f2/1534201222036-JHLKSIPN8AOXD4XNLRAN/Esther_main_image_1.jpg?format=2500w"
47
+ target="_blank">Link</a>`,
48
+ buttonText: 'Action',
49
+ closeButton: true,
50
+ isStripe: false,
51
+ isInlineHeader: false,
52
+ dataQa: 'vcita-alert',
53
+ }
54
+
55
+ const Template = (args, {argTypes}) => ({
56
+ components: {VcAlert: VcAlertCmp},
57
+ props: Object.keys(argTypes),
58
+ template: `
59
+ <VcAlert :type="type"
60
+ :header-text="headerText"
61
+ :body-text="bodyText"
62
+ :button-text="buttonText"
63
+ :is-stripe="isStripe"
64
+ :closeButton="closeButton"
65
+ @onAction="onAction"
66
+ @closeAlert="closeAlertAction"
67
+ />`,
68
+ methods: {
69
+ closeAlertAction: action('closeAlert')
70
+ }
71
+ })
72
+
73
+ export const Info_Stripe = Template.bind({});
74
+
75
+ // default values for controls
76
+ Info_Stripe.args = {
77
+ type: 'info',
78
+ headerText: '',
79
+ bodyText: 'Toto, I\'ve a feeling we\'re not in Kansas anymore',
80
+ buttonText: '',
81
+ closeButton: true,
82
+ isStripe: true,
83
+ }
84
+
85
+ export default {
86
+ title: 'Feedback / VcAlert',
87
+ id: 'VcAlert',
88
+ component: VcAlertCmp,
89
+ argTypes: {
90
+ type: {
91
+ options: ['attention', 'warning', 'info', 'success'],
92
+ control: {type: 'radio'}
93
+ },
94
+ },
95
+ parameters: {
96
+ design: {
97
+ type: 'figma',
98
+ url: 'https://www.figma.com/file/xIOY6fBoA1wpy1tHv3i5js/vcita---ui-library?node-id=1863%3A1405',
99
+ },
100
+ status: {
101
+ type: 'stable', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
102
+ url: 'http://www.url.com/status', // will make the tag a link
103
+ },
104
+ },
105
+ };
@@ -5,15 +5,14 @@
5
5
  :data-qa="dataQa"
6
6
  :icon="getIcon">
7
7
  <VcLayout align-start column class="alert-content" :class="{'dialog-alert__close-btn': closeButton}">
8
- <template>
9
- <span v-if="headerText && !isInlineHeader" class="alert-header">
10
- {{ headerText }}
8
+ <div>Reut</div>
9
+ <span v-if="headerText && !isInlineHeader" class="alert-header">
10
+ {{ headerText }}
11
+ </span>
12
+ <span class="alert-body"
13
+ v-if="bodyText"
14
+ v-html="getBodyText">
11
15
  </span>
12
- <span class="alert-body"
13
- v-if="bodyText"
14
- v-html="getBodyText">
15
- </span>
16
- </template>
17
16
  </VcLayout>
18
17
  <VcButton v-if="buttonText"
19
18
  class="action-button"
@@ -0,0 +1,67 @@
1
+ import '@testing-library/jest-dom'
2
+ import VcAutoComplete from "./VcAutoComplete.vue";
3
+ import Vuetify from 'vuetify'
4
+ import init from "../../../testing-library.config"
5
+ import {render} from "@testing-library/vue";
6
+ import userEvent from '@testing-library/user-event'
7
+
8
+ init();
9
+
10
+ describe("VcAutoComplete.vue", () => {
11
+
12
+ const renderWithVuetify = (component, options, callback) => {
13
+ const root = document.createElement('div')
14
+ root.setAttribute('data-app', 'true')
15
+ root.setAttribute('data-qa', 'testContainer')
16
+
17
+ return render(
18
+ component,
19
+ {
20
+ container: document.body.appendChild(root),
21
+ // for Vuetify components that use the vuetify instance property
22
+ vuetify: new Vuetify(),
23
+ ...options,
24
+ mocks: {},
25
+ },
26
+ callback,
27
+ )
28
+ }
29
+
30
+ it("mounts", () => {
31
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
32
+ const {container} = renderWithVuetify(VcAutoComplete, {
33
+ props: {
34
+ items: ['foo', 'bar', 'fizz', 'buzz'],
35
+ }
36
+ })
37
+
38
+ // Expect options: https://github.com/testing-library/jest-dom
39
+ expect(container).toHaveAttribute('data-app', 'true')
40
+ });
41
+
42
+ it("interacts with the menu", async () => {
43
+ // Queries: https://testing-library.com/docs/queries/about#types-of-queries
44
+ const {getByTestId, emitted, baseElement} = renderWithVuetify(VcAutoComplete, {
45
+ props: {
46
+ items: ['foo', 'bar', 'fizz', 'buzz'],
47
+ }
48
+ })
49
+
50
+ const item = getByTestId("VcAutoComplete");
51
+ expect(item).toBeInTheDocument();
52
+
53
+ // Open menu
54
+ await userEvent.click(item);
55
+ expect(emitted().onMenuToggled.length).toBe(1);
56
+ const newValue = emitted().onMenuToggled[0][0];
57
+ expect(newValue).toBeTruthy();
58
+
59
+ // Close menu by click-outside
60
+ await userEvent.click(baseElement);
61
+ expect(emitted().onMenuToggled.length).toBe(2);
62
+ const updatedValue = emitted().onMenuToggled[1][0];
63
+ expect(updatedValue).toBeFalsy();
64
+
65
+ });
66
+
67
+ });
@@ -0,0 +1,99 @@
1
+ import VcAutoCompleteCmp from './VcAutoComplete';
2
+
3
+ const Template = (args, {argTypes}) => ({
4
+ components: {VcAutoComplete: VcAutoCompleteCmp},
5
+ props: Object.keys(argTypes),
6
+ template: '<div><VcAutoComplete v-model="value" :items="items" :color="color"' +
7
+ '@onMenuToggled="onMenuToggled"/></div>',
8
+ })
9
+
10
+ export const Playground = Template.bind({});
11
+
12
+ // Set default values
13
+ Playground.args = {
14
+ items: ['foo', 'bar', 'fizz', 'buzz'],
15
+ color: 'primary',
16
+ }
17
+
18
+ export const ObjectItems = Template.bind({});
19
+
20
+ // Set default values
21
+ ObjectItems.args = {
22
+ items: [
23
+ {
24
+ text: "regular item",
25
+ value: 1,
26
+ disabled: false,
27
+ divider: false,
28
+ header: false
29
+ },
30
+ {
31
+ text: "disabled item",
32
+ value: 2,
33
+ disabled: true,
34
+ divider: false,
35
+ header: false
36
+ },
37
+ {
38
+ text: "header item",
39
+ value: 3,
40
+ disabled: true,
41
+ divider: false,
42
+ header: "header item - cannot be selected"
43
+ },
44
+ {
45
+ text: "next will come a divider item",
46
+ value: 4,
47
+ disabled: false,
48
+ divider: false,
49
+ header: false
50
+ },
51
+ {
52
+ text: "some text",
53
+ value: 5,
54
+ disabled: false,
55
+ divider: true,
56
+ header: false
57
+ },
58
+ {
59
+ text: "and another regular item",
60
+ value: 6,
61
+ disabled: false,
62
+ divider: false,
63
+ header: false
64
+ },
65
+ ],
66
+ }
67
+
68
+ export const Color = Template.bind({});
69
+
70
+ // Set default values
71
+ Color.args = {
72
+ items: ['foo', 'bar', 'fizz', 'buzz'],
73
+ color: 'secondary',
74
+ }
75
+
76
+ export default {
77
+ title: 'Form / VcAutoComplete',
78
+ id: 'VcAutoComplete',
79
+ component: VcAutoCompleteCmp,
80
+ argTypes: {
81
+ items: {
82
+ control: "object"
83
+ },
84
+ color: {
85
+ options: ['primary', 'secondary','default','neutral','success','warning','danger','info'],
86
+ control: {type: 'radio'}
87
+ },
88
+ },
89
+ parameters: {
90
+ design: {
91
+ type: 'figma',
92
+ url: 'https://www.figma.com',
93
+ },
94
+ status: {
95
+ type: 'beta', // 'beta' | 'stable' | 'deprecated' | 'releaseCandidate'
96
+ url: 'http://www.url.com/status', // will make the tag a link
97
+ },
98
+ },
99
+ };