@weni/unnnic-system 2.6.1-alpha.2 → 2.6.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.
@@ -1,229 +0,0 @@
1
- <template>
2
- <section
3
- ref="popover"
4
- :class="['unnnic-tour__popover', step.popoverPosition]"
5
- :style="style"
6
- >
7
- <header class="popover__header">
8
- <h1 class="header__title">{{ step.title }}</h1>
9
- <p
10
- class="header__close-tour"
11
- @click="$emit('end')"
12
- >
13
- {{ i18n('close_tour') }}
14
- </p>
15
- </header>
16
- <p class="popover__description">{{ step.description }}</p>
17
- <UnnnicButton
18
- type="primary"
19
- @click="$emit('nextStep')"
20
- >
21
- {{ i18n('understood') }} {{ currentStep }}/{{ stepsLength }}
22
- </UnnnicButton>
23
- </section>
24
- </template>
25
-
26
- <script>
27
- import UnnnicI18n from '@/mixins/i18n';
28
-
29
- import UnnnicButton from '@/components/Button/Button.vue';
30
-
31
- export default {
32
- name: 'UnnnicTourPopover',
33
-
34
- components: {
35
- UnnnicButton,
36
- },
37
-
38
- mixins: [UnnnicI18n],
39
-
40
- props: {
41
- step: {
42
- type: Object,
43
- required: true,
44
- },
45
- currentStep: {
46
- type: Number,
47
- required: true,
48
- },
49
- stepsLength: {
50
- type: Number,
51
- required: true,
52
- },
53
- attachedElement: {
54
- type: Element,
55
- required: true,
56
- },
57
- },
58
-
59
- emits: ['end', 'nextStep'],
60
-
61
- data() {
62
- return {
63
- style: {},
64
- defaultTranslations: {
65
- close_tour: {
66
- 'pt-br': 'Fechar tour',
67
- en: 'Close tour',
68
- es: 'Cerrar recorrido',
69
- },
70
- understood: {
71
- 'pt-br': 'Entendi',
72
- en: 'I understood',
73
- es: 'Entendí',
74
- },
75
- },
76
- };
77
- },
78
-
79
- watch: {
80
- attachedElement: {
81
- immediate: true,
82
- deep: true,
83
- handler() {
84
- this.$nextTick(() => {
85
- this.updatePopoverStyle();
86
- });
87
- },
88
- },
89
- },
90
-
91
- methods: {
92
- updatePopoverStyle() {
93
- const { attachedElement, step } = this;
94
-
95
- const popoverElement = this.$refs.popover;
96
-
97
- if (!attachedElement || !popoverElement) {
98
- return;
99
- }
100
-
101
- const {
102
- top: attachedTop,
103
- left: attachedLeft,
104
- width: attachedWidth,
105
- height: attachedHeight,
106
- } = attachedElement.getBoundingClientRect();
107
- const popoverArrowSize = 12;
108
- const popoverArrowMargin = 2;
109
- const popoverArrowSpacing = popoverArrowSize + popoverArrowMargin;
110
- const popoverWidth = popoverElement?.offsetWidth;
111
- const popoverHeight = popoverElement?.offsetHeight;
112
-
113
- const translateXMap = {
114
- top: attachedLeft - (popoverWidth - attachedWidth) / 2,
115
- bottom: attachedLeft - (popoverWidth - attachedWidth) / 2,
116
- right: attachedLeft + attachedWidth + popoverArrowSpacing,
117
- left: attachedLeft - popoverWidth - popoverArrowSpacing,
118
- };
119
- const translateYMap = {
120
- top: attachedTop - popoverHeight - popoverArrowSpacing,
121
- bottom: attachedTop + attachedHeight + popoverArrowSpacing,
122
- right: attachedTop - popoverHeight / 2 + attachedHeight / 2,
123
- left: attachedTop - popoverHeight / 2 + attachedHeight / 2,
124
- };
125
-
126
- let style = {
127
- transform: `translate(${translateXMap[step.popoverPosition]}px, ${translateYMap[step.popoverPosition]}px)`,
128
- transition: 'transform .3s ease',
129
- };
130
-
131
- this.style = style;
132
- },
133
- },
134
- };
135
- </script>
136
- <style lang="scss" scoped>
137
- @import '../../assets/scss/unnnic.scss';
138
-
139
- * {
140
- margin: 0;
141
- padding: 0;
142
- box-sizing: border-box;
143
- }
144
-
145
- .unnnic-tour__popover {
146
- display: flex;
147
- flex-direction: column;
148
- gap: $unnnic-spacing-ant;
149
- position: fixed;
150
- top: 0;
151
- left: 0;
152
-
153
- z-index: 1001;
154
-
155
- border-radius: $unnnic-border-radius-sm;
156
- box-shadow: $unnnic-shadow-level-near;
157
- background: $unnnic-color-background-white;
158
- padding: $unnnic-spacing-ant;
159
-
160
- width: max-content;
161
- max-width: 30vw;
162
-
163
- color: $unnnic-color-neutral-darkest;
164
- font-family: $unnnic-font-family-secondary;
165
- font-size: $unnnic-font-size-body-gt;
166
- font-weight: $unnnic-font-weight-regular;
167
-
168
- $arrowSize: $unnnic-icon-size-xs;
169
- $arrowHalfSize: calc($arrowSize / 2);
170
-
171
- &::before {
172
- content: '';
173
- position: absolute;
174
-
175
- width: $unnnic-icon-size-xs;
176
- height: $unnnic-icon-size-xs;
177
-
178
- border-radius: calc($unnnic-border-radius-sm / 2);
179
-
180
- background: linear-gradient(
181
- -45deg,
182
- $unnnic-color-background-white 50%,
183
- transparent 50%
184
- );
185
- }
186
-
187
- &.top::before {
188
- left: 50%;
189
- bottom: -$arrowHalfSize;
190
- transform: translateX(-50%) rotate(45deg);
191
- }
192
-
193
- &.bottom::before {
194
- top: -$arrowHalfSize;
195
- left: 50%;
196
- transform: translateX(-50%) rotate(225deg);
197
- }
198
-
199
- &.left::before {
200
- right: -$arrowHalfSize;
201
- top: 50%;
202
- transform: translateY(-50%) rotate(315deg);
203
- }
204
-
205
- &.right::before {
206
- left: -$arrowHalfSize;
207
- top: 50%;
208
- transform: translateY(-50%) rotate(135deg);
209
- }
210
-
211
- .popover__header {
212
- display: flex;
213
- justify-content: space-between;
214
- align-items: center;
215
- gap: $unnnic-spacing-nano;
216
-
217
- .header__title {
218
- font-weight: $unnnic-font-weight-bold;
219
- font-size: $unnnic-font-size-body-gt;
220
- }
221
- .header__close-tour {
222
- cursor: pointer;
223
-
224
- font-size: $unnnic-font-size-body-md;
225
- text-decoration-line: underline;
226
- }
227
- }
228
- }
229
- </style>
@@ -1,61 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
- import { mount } from '@vue/test-utils';
3
-
4
- import Icon from '../Icon.vue';
5
-
6
- const createWrapper = (props) => {
7
- return mount(Icon, { props });
8
- };
9
-
10
- describe('Icon', () => {
11
- it('should render old icons map and trigger click events', async () => {
12
- const wrapper = createWrapper({ icon: 'search-1', clickable: false });
13
-
14
- const hasOldIcon = wrapper.find('[data-testid="old-map-icons"]');
15
- expect(hasOldIcon.exists()).toBe(true);
16
-
17
- await wrapper.trigger('click');
18
- expect(wrapper.emitted('click')).toBe(undefined);
19
-
20
- await wrapper.setProps({ clickable: true });
21
- await wrapper.trigger('click');
22
- expect(wrapper.emitted('click')).toBeTruthy();
23
-
24
- await wrapper.trigger('mousedown');
25
- await wrapper.trigger('mouseup');
26
-
27
- expect(wrapper.emitted('mousedown')).toBeTruthy();
28
- expect(wrapper.emitted('mouseup')).toBeTruthy();
29
- });
30
-
31
- it('should render material icons and trigger click events', async () => {
32
- const wrapper = createWrapper({
33
- icon: 'done_all',
34
- clickable: false,
35
- });
36
-
37
- const hasMaterialIcon = wrapper.find('[data-testid="material-icon"]');
38
- expect(hasMaterialIcon.exists()).toBe(true);
39
-
40
- await wrapper.trigger('click');
41
- expect(wrapper.emitted('click')).toBe(undefined);
42
-
43
- await wrapper.setProps({ clickable: true });
44
- await wrapper.trigger('click');
45
- expect(wrapper.emitted('click')).toBeTruthy();
46
-
47
- await wrapper.trigger('mousedown');
48
- await wrapper.trigger('mouseup');
49
-
50
- expect(wrapper.emitted('mousedown')).toBeTruthy();
51
- expect(wrapper.emitted('mouseup')).toBeTruthy();
52
- });
53
-
54
- it('should log warning because invalid props', () => {
55
- const warningSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
56
-
57
- createWrapper({ lineHeight: 'invalid' });
58
-
59
- expect(warningSpy).toHaveBeenCalled();
60
- });
61
- });
@@ -1,66 +0,0 @@
1
- import { Meta, Source, Story } from '@storybook/blocks';
2
-
3
- import * as DropAreaStories from './DropArea.stories';
4
-
5
- <Meta of={DropAreaStories}/>
6
-
7
- # DropArea
8
-
9
- The `DropArea` component is designed to provide an area for uploading files, limiting them by file type and/or size.
10
-
11
- <Source
12
- language='html'
13
- dark
14
- code={`<UnnnicDropArea
15
- v-model:currentFiles="[]"
16
- subtitle=""
17
- supportedFormats="*"
18
- :maxFileSize="undefined"
19
- :maximumUploads="1"
20
- :acceptMultiple="true"
21
- :shouldReplace="false"
22
- @fileChange="() => {}"
23
- @unsupportedFormat="() => {}"
24
- @exceededTheMaximumFileSizeLimit="() => {}"
25
- >
26
- <template #title>Title Slot</template>
27
- <template #subtitle>Subtitle Slot</template>
28
- </UnnnicDropArea>`}
29
- />
30
-
31
-
32
- ---
33
-
34
- #### **Props Options:**
35
-
36
- | Key | Description | Values | Default |
37
- |----------------------------------|-------------------------------------------------------------------------------|-------------|--------------------------|
38
- | v-model:currentFiles | `Array` of the dropped or selected `File` object predefinition | `[File]` | `[]` |
39
- | subtitle | `String` of the subtitle to replace | `-` | `Formatos suportados: *` |
40
- | supportedFormats | `String` of the supported file formats for filtering files in System Explorer | `.pdf,.png` | `*` |
41
- | maxFileSize | `Number` of the file size limit in megabytes | `Number` | `undefined` |
42
- | maximumUploads | `Number` maximum of the files | `Number` | `1` |
43
- | acceptMultiple | `Boolean` whether or not the user can select more than one file at a time | `Boolean` | `true` |
44
- | shouldReplace | `Boolean` whether or not the new files will replace the `currentFiles` prop | `Boolean` | `false` |
45
- | @fileChange | When files are added or replaced | `Function` | `-` |
46
- | @unsupportedFormat | When a file has an incorrect extension and/or an unsupported format | `Function` | `-` |
47
- | @exceededTheMaximumFileSizeLimit | When a file exceeds the maximum file size limit set in `maxFileSize` | `Function` | `-` |
48
-
49
- #### **Slots:**
50
-
51
- | Name | Description | Default |
52
- |----------|-------------------------------------|------------------------------------------|
53
- | title | Template of the title to replace | `Arraste seu arquivo aqui, ou procure-o` |
54
- | subtitle | Template of the subtitle to replace | `Formatos suportados: *` |
55
-
56
- ## Example
57
- Some examples of uses of the `DropArea`
58
-
59
- ### Default
60
-
61
- <Story of={DropAreaStories.Default} />
62
-
63
-
64
- ### With Title and Subtitle slots
65
-
66
- <Story of={DropAreaStories.WithTitleAndSubtitleSlots} />
@@ -1,74 +0,0 @@
1
- import { action } from '@storybook/addon-actions';
2
- import UnnnicDropArea from '../components/DropArea/DropArea.vue';
3
-
4
- const events = {
5
- 'onUpdate:currentFiles': action('update:currentFiles'),
6
- onFileChange: action('fileChange'),
7
- onUnsupportedFormat: action('unsupportedFormat'),
8
- onExceededTheMaximumFileSizeLimit: action('exceededTheMaximumFileSizeLimit'),
9
- };
10
-
11
- export default {
12
- title: 'Example/DropArea',
13
- component: UnnnicDropArea,
14
- argTypes: {
15
- acceptMultiple: { control: 'boolean' },
16
- supportedFormats: { control: 'text' },
17
- maxFileSize: { control: 'number' },
18
- shouldReplace: { control: 'boolean' },
19
- currentFiles: { control: 'object' },
20
- maximumUploads: { control: 'number' },
21
- subtitle: { control: 'text' },
22
- onFileChange: { control: 'function' },
23
- },
24
- parameters: {
25
- controls: {
26
- exclude: Object.keys(events),
27
- },
28
- },
29
- args: {
30
- ...events,
31
- acceptMultiple: true,
32
- supportedFormats: '*',
33
- maxFileSize: undefined,
34
- shouldReplace: false,
35
- currentFiles: [],
36
- maximumUploads: 1,
37
- subtitle: '',
38
- },
39
- };
40
-
41
- const Template = (args) => ({
42
- components: { UnnnicDropArea },
43
-
44
- setup() {
45
- return { args };
46
- },
47
-
48
- template: `
49
- <UnnnicDropArea v-bind="args" />
50
- `,
51
- });
52
-
53
- const TemplateWithTitleAndSubtitleSlots = (args) => ({
54
- components: { UnnnicDropArea },
55
-
56
- setup() {
57
- return { args };
58
- },
59
-
60
- template: `
61
- <UnnnicDropArea v-bind="args">
62
- <template #title>Title Slot</template>
63
- <template #subtitle>Subtitle Slot</template>
64
- </UnnnicDropArea>
65
- `,
66
- });
67
-
68
- export const Default = Template.bind({});
69
- Default.args = {};
70
-
71
- export const WithTitleAndSubtitleSlots = TemplateWithTitleAndSubtitleSlots.bind(
72
- {},
73
- );
74
- WithTitleAndSubtitleSlots.args = {};
@@ -1,198 +0,0 @@
1
- import UnnnicTour from '../components/Tour/Tour.vue';
2
- import UnnnicCard from '../components/Card/Card.vue';
3
-
4
- export default {
5
- title: 'Example/Tour',
6
- component: UnnnicTour,
7
- argTypes: {},
8
- render: (args) => ({
9
- components: {
10
- UnnnicTour,
11
- UnnnicCard,
12
- },
13
- setup() {
14
- return { args };
15
- },
16
- methods: {
17
- startTour() {
18
- this.$refs.tour.start();
19
- },
20
- handleTourStep(step) {
21
- this.$refs.tour.start();
22
- this.$refs.tour.handleStep(step);
23
- },
24
- },
25
- mounted() {
26
- this.$nextTick(() => {
27
- args.steps[0].attachedElement = this.$refs.step1.$el;
28
- args.steps[1].attachedElement = this.$refs.step2.$el;
29
- args.steps[2].attachedElement = this.$refs.step3.$el;
30
- args.steps[3].attachedElement = this.$refs.step4.$el;
31
- });
32
- },
33
- template: `
34
- <div style="height: 50%; width: 30%; border: 1px solid #ccc; padding: 16px; margin: auto">
35
- <button @click="startTour">Start tour</button>
36
- <button @click="handleTourStep(3)">Go to step 3</button>
37
- <UnnnicCard
38
- type="default"
39
- title="This is the title"
40
- description="This is the description"
41
- ref="step1"
42
- />
43
- <UnnnicCard
44
- type="default"
45
- title="This is the title"
46
- description="This is the description"
47
- ref="step2"
48
- />
49
- <UnnnicCard
50
- type="default"
51
- title="This is the title"
52
- description="This is the description"
53
- ref="step3"
54
- />
55
- <UnnnicCard
56
- type="default"
57
- title="This is the title"
58
- description="This is the description"
59
- ref="step4"
60
- />
61
- <unnnic-tour v-bind="args" ref="tour" />
62
- </div>
63
- `,
64
- }),
65
- };
66
-
67
- export const Default = {
68
- args: {
69
- steps: [
70
- {
71
- title: 'Step 1',
72
- description:
73
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus euismod nibh vel elementum. Integer nisi lectus, hendrerit aliquet tellus nec, volutpat porttitor erat. Vivamus tincidunt sit amet ex non. ',
74
- attachedElement: null,
75
- popoverPosition: 'right',
76
- },
77
- {
78
- title: 'Step 2',
79
- description:
80
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec luctus dui orci. ',
81
- attachedElement: null,
82
- popoverPosition: 'bottom',
83
- },
84
- {
85
- title: 'Step 3',
86
- description:
87
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum accumsan erat, at bibendum nisi mollis et. Aliquam venenatis tristique.',
88
- attachedElement: null,
89
- popoverPosition: 'left',
90
- },
91
- {
92
- title: 'Step 4',
93
- description:
94
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ex purus, ullamcorper sed nunc eu. ',
95
- attachedElement: null,
96
- popoverPosition: 'top',
97
- },
98
- ],
99
- },
100
- };
101
-
102
- export const WithPadding = {
103
- args: {
104
- steps: [
105
- {
106
- title: 'Step 1',
107
- description:
108
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus euismod nibh vel elementum. Integer nisi lectus, hendrerit aliquet tellus nec, volutpat porttitor erat. Vivamus tincidunt sit amet ex non. ',
109
- attachedElement: null,
110
- popoverPosition: 'right',
111
- padding: {
112
- vertical: 20,
113
- horizontal: 20,
114
- },
115
- },
116
- ],
117
- },
118
- render: (args) => ({
119
- components: {
120
- UnnnicTour,
121
- UnnnicCard,
122
- },
123
- setup() {
124
- return { args };
125
- },
126
- methods: {
127
- startTour() {
128
- this.$refs.tour.start();
129
- },
130
- },
131
- mounted() {
132
- this.$nextTick(() => {
133
- args.steps[0].attachedElement = this.$refs.step1.$el;
134
- });
135
- },
136
- template: `
137
- <div style="height: 50%; width: 30%; border: 1px solid #ccc; padding: 16px; margin: auto">
138
- <button @click="startTour">Start tour</button>
139
- <UnnnicCard
140
- type="default"
141
- title="This is the title"
142
- description="This is the description"
143
- ref="step1"
144
- />
145
- <unnnic-tour v-bind="args" ref="tour" />
146
- </div>
147
- `,
148
- }),
149
- };
150
-
151
- export const WithNegativePadding = {
152
- args: {
153
- steps: [
154
- {
155
- title: 'Step 1',
156
- description:
157
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus euismod nibh vel elementum. Integer nisi lectus, hendrerit aliquet tellus nec, volutpat porttitor erat. Vivamus tincidunt sit amet ex non. ',
158
- attachedElement: null,
159
- popoverPosition: 'right',
160
- padding: {
161
- vertical: -30,
162
- horizontal: -10,
163
- },
164
- },
165
- ],
166
- },
167
- render: (args) => ({
168
- components: {
169
- UnnnicTour,
170
- UnnnicCard,
171
- },
172
- setup() {
173
- return { args };
174
- },
175
- methods: {
176
- startTour() {
177
- this.$refs.tour.start();
178
- },
179
- },
180
- mounted() {
181
- this.$nextTick(() => {
182
- args.steps[0].attachedElement = this.$refs.step1.$el;
183
- });
184
- },
185
- template: `
186
- <div style="height: 50%; width: 30%; border: 1px solid #ccc; padding: 16px; margin: auto">
187
- <button @click="startTour">Start tour</button>
188
- <UnnnicCard
189
- type="default"
190
- title="This is the title"
191
- description="This is the description"
192
- ref="step1"
193
- />
194
- <unnnic-tour v-bind="args" ref="tour" />
195
- </div>
196
- `,
197
- }),
198
- };