@weni/unnnic-system 3.4.1-alpha.0 → 3.4.1-alpha.1

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 (27) hide show
  1. package/dist/components/CardImage/CardImage.vue.d.ts +17 -26
  2. package/dist/components/ChatsContact/ChatsContact.vue.d.ts +17 -26
  3. package/dist/components/Checkbox/Checkbox.vue.d.ts +17 -26
  4. package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
  5. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +28 -0
  6. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +1 -0
  7. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +17 -26
  8. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +17 -26
  9. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
  10. package/dist/components/Switch/Switch.vue.d.ts +1 -1
  11. package/dist/components/index.d.ts +182 -106
  12. package/dist/components/index.d.ts.map +1 -1
  13. package/dist/{es-479daf92.mjs → es-eca523be.mjs} +1 -1
  14. package/dist/{index-a8aa7094.mjs → index-c84d6c3d.mjs} +6300 -6259
  15. package/dist/{pt-br-32c84cc8.mjs → pt-br-dd7ba97f.mjs} +1 -1
  16. package/dist/style.css +1 -1
  17. package/dist/unnnic.mjs +160 -158
  18. package/dist/unnnic.umd.js +33 -33
  19. package/package.json +1 -1
  20. package/src/assets/icons/checkbox-checked-disabled.svg +3 -0
  21. package/src/assets/icons/checkbox-checked.svg +3 -0
  22. package/src/components/Checkbox/Checkbox.vue +88 -65
  23. package/src/components/Checkbox/__tests__/Checkbox.spec.js +6 -21
  24. package/src/components/CheckboxGroup/CheckboxGroup.vue +96 -0
  25. package/src/components/index.ts +4 -0
  26. package/src/stories/Checkbox.stories.js +9 -10
  27. package/src/stories/CheckboxGroup.stories.js +104 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.4.1-alpha.0",
3
+ "version": "3.4.1-alpha.1",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,3 @@
1
+ <svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3.60023 7.13135L9.96565 0.765935C10.0744 0.655796 10.2018 0.599407 10.3477 0.596768C10.4936 0.594129 10.6242 0.650518 10.7396 0.765935C10.855 0.881351 10.9127 1.00955 10.9127 1.15052C10.9127 1.29163 10.8577 1.41718 10.7477 1.52718L4.08586 8.19864C3.9503 8.33531 3.79224 8.40364 3.61169 8.40364C3.43099 8.40364 3.27224 8.33531 3.13544 8.19864L0.260439 5.32364C0.150439 5.2135 0.0928002 5.08711 0.0875224 4.94448C0.0821058 4.80198 0.137106 4.67302 0.252522 4.5576C0.367939 4.44218 0.496759 4.38448 0.638981 4.38448C0.781203 4.38448 0.907731 4.44218 1.01856 4.5576L3.60023 7.13135Z" fill="#B2B9C7"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="11" height="9" viewBox="0 0 11 9" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3.60023 7.13135L9.96565 0.765935C10.0744 0.655796 10.2018 0.599407 10.3477 0.596768C10.4936 0.594129 10.6242 0.650518 10.7396 0.765935C10.855 0.881351 10.9127 1.00955 10.9127 1.15052C10.9127 1.29163 10.8577 1.41718 10.7477 1.52718L4.08586 8.19864C3.9503 8.33531 3.79224 8.40364 3.61169 8.40364C3.43099 8.40364 3.27224 8.33531 3.13544 8.19864L0.260439 5.32364C0.150439 5.2135 0.0928002 5.08711 0.0875224 4.94448C0.0821058 4.80198 0.137106 4.67302 0.252522 4.5576C0.367939 4.44218 0.496759 4.38448 0.638981 4.38448C0.781203 4.38448 0.907731 4.44218 1.01856 4.5576L3.60023 7.13135Z" fill="white"/>
3
+ </svg>
@@ -1,37 +1,41 @@
1
1
  <!-- eslint-disable vue/multi-word-component-names -->
2
2
  <template>
3
- <div class="unnnic-checkbox-wrapper">
4
- <UnnnicIcon
5
- class="unnnic-checkbox"
6
- :class="{ disabled }"
7
- :icon="icon"
8
- :scheme="color"
9
- :clickable="!disabled"
10
- :size="size"
11
- @click="click"
12
- />
13
-
14
- <div
15
- v-if="textRight"
16
- :class="[
17
- 'unnnic-checkbox__label',
18
- 'unnnic-checkbox__label__right',
19
- `unnnic-checkbox__label__${size}`,
20
- ]"
21
- data-testid="checkbox-text-right"
3
+ <section class="unnnic-checkbox-wrapper">
4
+ <label>
5
+ <input
6
+ class="unnnic-checkbox"
7
+ type="checkbox"
8
+ :disabled="disabled"
9
+ :checked="modelValue"
10
+ @change="click"
11
+ v-bind="pick($attrs, ['id', 'name'])"
12
+ />
13
+
14
+ <p
15
+ v-if="label || textRight"
16
+ :class="[
17
+ 'unnnic-checkbox__label',
18
+ { 'unnnic-checkbox__label--disabled': disabled },
19
+ ]"
20
+ data-testid="checkbox-text-right"
21
+ >
22
+ {{ label || textRight }}
23
+ </p>
24
+ </label>
25
+
26
+ <p
27
+ v-if="helper"
28
+ class="unnnic-checkbox__helper"
22
29
  >
23
- {{ textRight }}
24
- </div>
25
- </div>
30
+ {{ helper }}
31
+ </p>
32
+ </section>
26
33
  </template>
27
34
 
28
35
  <script>
29
- import UnnnicIcon from '../Icon.vue';
36
+ import { pick } from 'lodash';
30
37
 
31
38
  export default {
32
- components: {
33
- UnnnicIcon,
34
- },
35
39
  model: {
36
40
  event: 'change',
37
41
  },
@@ -50,13 +54,16 @@ export default {
50
54
  default: false,
51
55
  },
52
56
 
53
- size: {
57
+ label: {
54
58
  type: String,
55
- default: 'md',
56
- validator(value) {
57
- return ['md', 'sm'].includes(value);
58
- },
59
+ default: '',
60
+ },
61
+
62
+ helper: {
63
+ type: String,
64
+ default: '',
59
65
  },
66
+
60
67
  textRight: {
61
68
  type: String,
62
69
  default: '',
@@ -75,25 +82,11 @@ export default {
75
82
 
76
83
  return 'less';
77
84
  },
78
-
79
- icon() {
80
- return {
81
- checked: 'checkbox-select',
82
- default: this.disabled ? 'checkbox-disable' : 'checkbox-default',
83
- less: 'checkbox-less',
84
- }[this.valueName];
85
- },
86
-
87
- color() {
88
- if (this.valueName === 'default') {
89
- return 'neutral-clean';
90
- }
91
-
92
- return 'brand-weni';
93
- },
94
85
  },
95
86
 
96
87
  methods: {
88
+ pick,
89
+
97
90
  click() {
98
91
  const isChecked = ['checked', 'less'].includes(this.valueName);
99
92
  this.$emit('change', !isChecked);
@@ -106,35 +99,65 @@ export default {
106
99
  <style lang="scss" scoped>
107
100
  @use '@/assets/scss/unnnic' as *;
108
101
 
102
+ $checkbox-size: 21px;
103
+
109
104
  .unnnic-checkbox-wrapper {
110
105
  display: flex;
106
+ flex-direction: column;
111
107
  align-items: flex-start;
112
- cursor: pointer;
108
+ }
109
+
110
+ label {
111
+ display: flex;
112
+ align-items: center;
113
+ column-gap: $unnnic-space-2;
113
114
  }
114
115
 
115
116
  .unnnic-checkbox {
116
- &.disabled {
117
- :deep(.primary) {
118
- fill: $unnnic-color-neutral-cleanest;
119
- }
117
+ appearance: none;
118
+ width: $checkbox-size;
119
+ height: $checkbox-size;
120
+ margin: 0;
121
+ background-color: $unnnic-color-bg-base;
122
+ border: 1px solid $unnnic-color-border-base;
123
+ border-radius: $unnnic-radius-1;
124
+ box-sizing: border-box;
125
+
126
+ outline: none;
127
+
128
+ &:checked {
129
+ border-width: 0;
130
+ background-color: $unnnic-color-bg-active;
131
+ background-image: url('../../assets/icons/checkbox-checked.svg');
132
+ background-repeat: no-repeat;
133
+ background-position: center;
134
+ }
135
+
136
+ &:disabled,
137
+ &:disabled:checked {
138
+ background-color: $unnnic-color-bg-muted;
139
+ border: 1px solid $unnnic-color-border-muted;
140
+ }
141
+
142
+ &:disabled:checked {
143
+ background-image: url('../../assets/icons/checkbox-checked-disabled.svg');
120
144
  }
121
145
  }
122
146
 
123
147
  .unnnic-checkbox__label {
124
- font-family: $unnnic-font-family-secondary;
125
- font-weight: $unnnic-font-weight-regular;
126
- color: $unnnic-color-neutral-darkest;
127
-
128
- &__sm {
129
- margin-left: $unnnic-inline-nano;
130
- font-size: $unnnic-font-size-body-md;
131
- line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
132
- }
148
+ margin: 0;
149
+ font: $unnnic-font-body;
150
+ color: $unnnic-color-fg-emphasized;
133
151
 
134
- &__md {
135
- margin-left: $unnnic-inline-xs;
136
- font-size: $unnnic-font-size-body-gt;
137
- line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
152
+ &--disabled {
153
+ color: $unnnic-color-fg-muted;
138
154
  }
139
155
  }
156
+
157
+ .unnnic-checkbox__helper {
158
+ margin: 0;
159
+ margin-left: $checkbox-size + $unnnic-space-2;
160
+ font: $unnnic-font-caption-2;
161
+ color: $unnnic-color-fg-base;
162
+ }
140
163
  </style>
@@ -24,43 +24,28 @@ describe('Checkbox', () => {
24
24
 
25
25
  it('should checkbox emit change events', async () => {
26
26
  wrapper = createWrapper();
27
- const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
27
+ const checkbox = wrapper.find('input[type="checkbox"]');
28
28
 
29
29
  // click false to true
30
- await checkbox.trigger('click');
30
+ await checkbox.trigger('change');
31
31
  expect(wrapper.emitted('change')[0][0]).eq(true);
32
32
 
33
33
  // click true to false
34
34
  await wrapper.setProps({ modelValue: true });
35
- await checkbox.trigger('click');
35
+ await checkbox.trigger('change');
36
36
  expect(wrapper.emitted('change')[1][0]).eq(false);
37
37
 
38
38
  // click less to false
39
39
  await wrapper.setProps({ modelValue: 'less' });
40
- expect(wrapper.vm.icon).eq('checkbox-less');
41
- await checkbox.trigger('click');
40
+ expect(wrapper.vm.valueName).eq('less');
41
+ await checkbox.trigger('change');
42
42
  expect(wrapper.emitted('change')[2][0]).eq(false);
43
43
  });
44
44
 
45
45
  it('should checkbox disabled', async () => {
46
46
  wrapper = createWrapper({ disabled: true });
47
- const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
47
+ const checkbox = wrapper.find('input[type="checkbox"]');
48
48
  await checkbox.trigger('click');
49
49
  expect(wrapper.emitted('change')).eq(undefined);
50
50
  });
51
-
52
- it('should define sizes', async () => {
53
- wrapper = createWrapper({ size: 'sm', textRight: 'Label' });
54
- const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
55
- const label = wrapper.find('.unnnic-checkbox__label');
56
-
57
- // sm
58
- expect(checkbox.classes()).include('unnnic-icon__size--sm');
59
- expect(label.classes()).include('unnnic-checkbox__label__sm');
60
-
61
- // md
62
- await wrapper.setProps({ size: 'md' });
63
- expect(checkbox.classes()).include('unnnic-icon__size--md');
64
- expect(label.classes()).include('unnnic-checkbox__label__md');
65
- });
66
51
  });
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <section
3
+ :class="[
4
+ 'unnnic-checkbox-group__container',
5
+ `unnnic-checkbox-group--state-${state}`,
6
+ ]"
7
+ >
8
+ <UnnnicLabel
9
+ v-if="label"
10
+ :label="label"
11
+ :tooltip="labelTooltip"
12
+ :useHtmlTooltip="labelUseHtmlTooltip"
13
+ />
14
+
15
+ <section class="unnnic-checkbox-group__checkboxes">
16
+ <slot />
17
+ </section>
18
+
19
+ <footer
20
+ v-if="helper"
21
+ class="unnnic-checkbox-group__helper"
22
+ >
23
+ {{ helper }}
24
+ </footer>
25
+ </section>
26
+ </template>
27
+
28
+ <script setup>
29
+ import UnnnicLabel from '../Label/Label.vue';
30
+
31
+ const props = defineProps({
32
+ state: {
33
+ type: String,
34
+ default: 'horizontal',
35
+ validator(value) {
36
+ return ['horizontal', 'vertical'].includes(value);
37
+ },
38
+ },
39
+
40
+ label: {
41
+ type: String,
42
+ },
43
+
44
+ labelTooltip: {
45
+ type: String,
46
+ },
47
+
48
+ labelUseHtmlTooltip: {
49
+ type: Boolean,
50
+ },
51
+
52
+ helper: {
53
+ type: String,
54
+ },
55
+ });
56
+ </script>
57
+
58
+ <style lang="scss" scoped>
59
+ @use '@/assets/scss/unnnic' as *;
60
+
61
+ .unnnic-checkbox-group {
62
+ &__container {
63
+ display: flex;
64
+ flex-direction: column;
65
+ }
66
+
67
+ &__checkboxes {
68
+ margin-top: $unnnic-space-3;
69
+
70
+ display: flex;
71
+ gap: $unnnic-space-4 $unnnic-space-6;
72
+ }
73
+
74
+ &__helper {
75
+ margin-top: $unnnic-space-2;
76
+ font: $unnnic-font-caption-2;
77
+ color: $unnnic-color-fg-base;
78
+ }
79
+
80
+ &--state-horizontal {
81
+ .unnnic-checkbox-group__checkboxes {
82
+ flex-direction: row;
83
+ }
84
+ }
85
+
86
+ &--state-vertical {
87
+ .unnnic-checkbox-group__checkboxes {
88
+ flex-direction: column;
89
+ }
90
+
91
+ .unnnic-checkbox-group__helper {
92
+ margin-top: $unnnic-space-3;
93
+ }
94
+ }
95
+ }
96
+ </style>
@@ -25,6 +25,7 @@ import cardImage from './CardImage/CardImage.vue';
25
25
  import cardProject from './CardProject/CardProject.vue';
26
26
  import cardInformation from './CardInformation/CardInformation.vue';
27
27
  import checkbox from './Checkbox/Checkbox.vue';
28
+ import checkboxGroup from './CheckboxGroup/CheckboxGroup.vue';
28
29
  import collapse from './Collapse/Collapse.vue';
29
30
  import radio from './Radio/Radio.vue';
30
31
  import languageSelect from './Dropdown/LanguageSelect.vue';
@@ -131,6 +132,7 @@ export const components: ComponentsMap = {
131
132
  unnnicCardProject: cardProject,
132
133
  unnnicCardInformation: cardInformation,
133
134
  unnnicCheckbox: checkbox,
135
+ unnnicCheckboxGroup: checkboxGroup,
134
136
  unnnicCollapse: collapse,
135
137
  unnnicRadio: radio,
136
138
  unnnicLanguageSelect: languageSelect,
@@ -233,6 +235,7 @@ export const unnnicCardImage = cardImage as VueComponent;
233
235
  export const unnnicCardProject = cardProject as VueComponent;
234
236
  export const unnnicCardInformation = cardInformation;
235
237
  export const unnnicCheckbox = checkbox;
238
+ export const unnnicCheckboxGroup = checkboxGroup;
236
239
  export const unnnicCollapse = collapse;
237
240
  export const unnnicRadio = radio;
238
241
  export const unnniclanguageSelect = languageSelect as VueComponent;
@@ -332,6 +335,7 @@ export const UnnnicCardImage = cardImage as VueComponent;
332
335
  export const UnnnicCardProject = cardProject as VueComponent;
333
336
  export const UnnnicCardInformation = cardInformation;
334
337
  export const UnnnicCheckbox = checkbox;
338
+ export const UnnnicCheckboxGroup = checkboxGroup;
335
339
  export const UnnnicCollapse = collapse;
336
340
  export const UnnnicRadio = radio;
337
341
  export const UnnniclanguageSelect = languageSelect as VueComponent;
@@ -15,12 +15,12 @@ export default {
15
15
  },
16
16
  },
17
17
  },
18
- args: { disabled: false, size: 'md' },
18
+ args: { disabled: false },
19
19
  argTypes: {
20
- modelValue: { control: 'inline-radio', options: [true, false, 'less'] },
20
+ modelValue: { control: 'inline-radio', options: [true, false] },
21
21
  disabled: { control: 'boolean' },
22
- size: { control: 'select', options: ['md', 'sm'] },
23
- textRight: { control: 'text' },
22
+ label: { control: 'text' },
23
+ helper: { control: 'text' },
24
24
  },
25
25
  render: (args) => ({
26
26
  components: {
@@ -42,18 +42,15 @@ export default {
42
42
  export const Default = {
43
43
  args: {
44
44
  modelValue: false,
45
+ label: 'Label',
46
+ helper: 'Helper',
45
47
  },
46
48
  };
47
49
 
48
50
  export const Selected = {
49
51
  args: {
50
52
  modelValue: true,
51
- },
52
- };
53
-
54
- export const LessSelected = {
55
- args: {
56
- modelValue: 'less',
53
+ label: 'Label',
57
54
  },
58
55
  };
59
56
 
@@ -61,6 +58,7 @@ export const Disabled = {
61
58
  args: {
62
59
  modelValue: false,
63
60
  disabled: true,
61
+ label: 'Label',
64
62
  },
65
63
  };
66
64
 
@@ -68,5 +66,6 @@ export const DisabledSelected = {
68
66
  args: {
69
67
  modelValue: true,
70
68
  disabled: true,
69
+ label: 'Label',
71
70
  },
72
71
  };
@@ -0,0 +1,104 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import UnnnicCheckboxGroup from '../components/CheckboxGroup/CheckboxGroup.vue';
3
+ import UnnnicCheckbox from '../components/Checkbox/Checkbox.vue';
4
+ import { ref } from 'vue';
5
+
6
+ export default {
7
+ title: 'Form/CheckboxGroup',
8
+ component: UnnnicCheckboxGroup,
9
+ tags: ['autodocs'],
10
+ parameters: {
11
+ docs: {
12
+ description: {
13
+ component: `Allows the user to select multiple options from a category. It can also be
14
+ used to display a single option that may require additional acceptance or confirmation
15
+ before submission.`,
16
+ },
17
+ },
18
+ },
19
+ argTypes: {
20
+ label: { control: { type: 'text' } },
21
+ labelTooltip: { control: { type: 'text' } },
22
+ labelUseHtmlTooltip: { control: 'boolean' },
23
+ helper: { control: { type: 'text' } },
24
+ state: { control: 'select', options: ['horizontal', 'vertical'] },
25
+ },
26
+ };
27
+
28
+ export const Default = {
29
+ args: {
30
+ label: 'Checkbox Group 1',
31
+ helper: 'Helper text',
32
+ },
33
+
34
+ render: (args) => ({
35
+ components: {
36
+ UnnnicCheckboxGroup,
37
+ UnnnicCheckbox,
38
+ },
39
+
40
+ setup() {
41
+ return { args };
42
+ },
43
+
44
+ template: `
45
+ <section>
46
+ <UnnnicCheckboxGroup v-bind="args">
47
+ <UnnnicCheckbox :modelValue="true" label="Option 1" />
48
+ <UnnnicCheckbox :modelValue="false" label="Option 2" />
49
+ <UnnnicCheckbox :modelValue="false" label="Option 3" />
50
+ </UnnnicCheckboxGroup>
51
+ </section>
52
+ `,
53
+ }),
54
+ };
55
+
56
+ export const Horizontal = {
57
+ args: {
58
+ state: 'horizontal',
59
+ label: 'Label',
60
+ helper: 'Helper text',
61
+ },
62
+
63
+ render: (args) => ({
64
+ components: {
65
+ UnnnicCheckboxGroup,
66
+ UnnnicCheckbox,
67
+ },
68
+ setup() {
69
+ return { args };
70
+ },
71
+ template: `
72
+ <UnnnicCheckboxGroup v-bind="args">
73
+ <UnnnicCheckbox :modelValue="true" label="Option 1" />
74
+ <UnnnicCheckbox :modelValue="false" label="Option 2" />
75
+ <UnnnicCheckbox :modelValue="false" label="Option 3" />
76
+ </UnnnicCheckboxGroup>
77
+ `,
78
+ }),
79
+ };
80
+
81
+ export const Vertical = {
82
+ args: {
83
+ state: 'vertical',
84
+ label: 'Label',
85
+ helper: 'Helper text',
86
+ },
87
+
88
+ render: (args) => ({
89
+ components: {
90
+ UnnnicCheckboxGroup,
91
+ UnnnicCheckbox,
92
+ },
93
+ setup() {
94
+ return { args };
95
+ },
96
+ template: `
97
+ <UnnnicCheckboxGroup v-bind="args">
98
+ <UnnnicCheckbox :modelValue="true" label="Option 1" />
99
+ <UnnnicCheckbox :modelValue="false" label="Option 2" />
100
+ <UnnnicCheckbox :modelValue="false" label="Option 3" />
101
+ </UnnnicCheckboxGroup>
102
+ `,
103
+ }),
104
+ };