@weni/unnnic-system 3.2.9-alpha.2 → 3.2.9-alpha.4

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 (52) hide show
  1. package/dist/components/DateFilter/DateFilter.vue.d.ts +60 -93
  2. package/dist/components/Input/BaseInput.vue.d.ts +18 -0
  3. package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
  4. package/dist/components/Input/Input.vue.d.ts +60 -93
  5. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  6. package/dist/components/Input/TextInput.vue.d.ts +36 -0
  7. package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
  8. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +60 -93
  9. package/dist/components/InputNext/InputNext.vue.d.ts +1 -1
  10. package/dist/components/Label/Label.vue.d.ts +2 -2
  11. package/dist/components/Label/Label.vue.d.ts.map +1 -1
  12. package/dist/components/ModalNext/ModalNext.vue.d.ts +60 -93
  13. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +36 -0
  14. package/dist/components/SelectTime/index.vue.d.ts +36 -0
  15. package/dist/components/Tab/Tab.vue.d.ts +11 -0
  16. package/dist/components/index.d.ts +507 -749
  17. package/dist/components/index.d.ts.map +1 -1
  18. package/dist/{es-2735a8fb.js → es-0c19f636.js} +1 -1
  19. package/dist/{index-e012fa52.js → index-4b1fed3d.js} +2750 -2722
  20. package/dist/locales/en.json.d.ts +2 -1
  21. package/dist/locales/es.json.d.ts +2 -1
  22. package/dist/locales/pt_br.json.d.ts +2 -1
  23. package/dist/{pt-br-f38a8b9c.js → pt-br-688d3863.js} +1 -1
  24. package/dist/style.css +1 -1
  25. package/dist/unnnic.js +1 -1
  26. package/dist/unnnic.umd.cjs +32 -32
  27. package/package.json +1 -1
  28. package/src/components/Input/BaseInput.vue +12 -2
  29. package/src/components/Input/Input.scss +2 -1
  30. package/src/components/Input/Input.vue +17 -29
  31. package/src/components/Input/TextInput.vue +11 -1
  32. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +2 -2
  33. package/src/components/Label/Label.vue +2 -2
  34. package/src/components/Popover/__tests__/Popover.spec.js +147 -0
  35. package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
  36. package/src/components/Popover/index.vue +146 -0
  37. package/src/components/Select/SelectOption.vue +57 -0
  38. package/src/components/Select/__tests__/Select.spec.js +412 -0
  39. package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
  40. package/src/components/Select/__tests__/SelectOption.spec.js +174 -0
  41. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +93 -0
  42. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
  43. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
  44. package/src/components/Select/index.vue +187 -0
  45. package/src/components/Tab/Tab.vue +37 -23
  46. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
  47. package/src/locales/en.json +2 -1
  48. package/src/locales/es.json +2 -1
  49. package/src/locales/pt_br.json +2 -1
  50. package/src/stories/Popover.stories.js +39 -0
  51. package/src/stories/Select.stories.js +91 -0
  52. package/src/stories/Tab.stories.js +11 -4
@@ -0,0 +1,187 @@
1
+ <template>
2
+ <div class="unnnic-select">
3
+ <UnnnicPopover
4
+ v-model="openPopover"
5
+ :popoverBalloonProps="{ maxHeight: calculatedMaxHeight }"
6
+ >
7
+ <template #trigger>
8
+ <UnnnicInput
9
+ :modelValue="inputValue"
10
+ class="unnnic-select__input"
11
+ readonly
12
+ :forceActiveStatus="openPopover"
13
+ :size="props.size"
14
+ :placeholder="props.placeholder"
15
+ :label="props.label"
16
+ :errors="props.errors"
17
+ :message="props.message"
18
+ :iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
19
+ :disabled="props.disabled"
20
+ />
21
+ </template>
22
+ <template #content>
23
+ <div class="unnnic-select__content">
24
+ <UnnnicInput
25
+ v-if="props.enableSearch"
26
+ class="unnnic-select__input-search"
27
+ :modelValue="props.search"
28
+ :placeholder="$t('search')"
29
+ iconLeft="search"
30
+ @update:modelValue="handleSearch"
31
+ />
32
+ <UnnnicSelectOption
33
+ v-for="option in filteredOptions"
34
+ :key="option[props.itemValue]"
35
+ :label="option[props.itemLabel]"
36
+ :active="
37
+ option[props.itemValue] === selectedItem?.[props.itemValue]
38
+ "
39
+ :disabled="option.disabled"
40
+ @click="handleSelectOption(option)"
41
+ />
42
+ </div>
43
+ </template>
44
+ </UnnnicPopover>
45
+ </div>
46
+ </template>
47
+
48
+ <script setup lang="ts">
49
+ import { computed, ref, watch } from 'vue';
50
+ import UnnnicInput from '../Input/Input.vue';
51
+ import UnnnicPopover from '../Popover/index.vue';
52
+ import UnnnicSelectOption from './SelectOption.vue';
53
+ import UnnnicI18n from '../../mixins/i18n';
54
+
55
+ defineOptions({
56
+ name: 'UnnnicSelect',
57
+ mixins: [UnnnicI18n],
58
+ });
59
+
60
+ interface SelectProps {
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ options: Array<{ [key: string]: any }>;
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ modelValue: any;
65
+ returnObject?: boolean;
66
+ itemLabel?: string;
67
+ itemValue?: string;
68
+ placeholder?: string;
69
+ label?: string;
70
+ type?: 'normal' | 'error';
71
+ errors?: string | Array<string>;
72
+ message?: string;
73
+ size?: 'sm' | 'md';
74
+ optionsLines?: number;
75
+ enableSearch?: boolean;
76
+ search?: string;
77
+ locale?: string;
78
+ disabled?: boolean;
79
+ }
80
+
81
+ const props = withDefaults(defineProps<SelectProps>(), {
82
+ size: 'md',
83
+ type: 'normal',
84
+ placeholder: '',
85
+ optionsLines: 5,
86
+ returnObject: false,
87
+ itemLabel: 'label',
88
+ itemValue: 'value',
89
+ locale: 'en',
90
+ enableSearch: false,
91
+ disabled: false,
92
+ });
93
+
94
+ const emit = defineEmits<{
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
+ 'update:modelValue': [value: any];
97
+ 'update:search': [value: string];
98
+ }>();
99
+
100
+ const openPopover = ref(false);
101
+
102
+ watch(openPopover, () => {
103
+ if (!openPopover.value) {
104
+ handleSearch('');
105
+ }
106
+ });
107
+
108
+ const calculatedMaxHeight = computed(() => {
109
+ if (!props.options || props.options.length === 0) return 'unset';
110
+ const fieldsHeight = 37 * props.optionsLines + 40;
111
+ return `${props.enableSearch ? fieldsHeight + 50 : fieldsHeight}px`;
112
+ });
113
+
114
+ const selectedItem = computed(() => {
115
+ if (props.returnObject) return props.modelValue;
116
+
117
+ return props.options.find(
118
+ (option) => option[props.itemValue] === props.modelValue,
119
+ );
120
+ });
121
+
122
+ const inputValue = computed(() => {
123
+ return selectedItem.value?.[props.itemLabel];
124
+ });
125
+
126
+ const handleSelectOption = (option) => {
127
+ if (
128
+ option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
129
+ option.disabled
130
+ )
131
+ return;
132
+
133
+ emit(
134
+ 'update:modelValue',
135
+ props.returnObject ? option : option[props.itemValue],
136
+ );
137
+ openPopover.value = false;
138
+ };
139
+
140
+ const handleSearch = (value: string) => {
141
+ emit('update:search', value);
142
+ };
143
+
144
+ const filteredOptions = computed(() => {
145
+ if (!props.enableSearch || !props.search) return props.options;
146
+
147
+ return props.options.filter(
148
+ (option) =>
149
+ option[props.itemLabel]
150
+ .toLowerCase()
151
+ .includes(props.search?.toLowerCase()) ||
152
+ option[props.itemValue]
153
+ .toLowerCase()
154
+ .includes(props.search?.toLowerCase()),
155
+ );
156
+ });
157
+ </script>
158
+
159
+ <style lang="scss" scoped>
160
+ @use '@/assets/scss/unnnic' as *;
161
+
162
+ :deep(.unnnic-select__input) {
163
+ cursor: pointer;
164
+ }
165
+
166
+ :deep(.unnnic-select__input-search) {
167
+ > .icon-left {
168
+ color: $unnnic-color-fg-base;
169
+ }
170
+ }
171
+
172
+ :deep(.unnnic-select__input) {
173
+ > .icon-right {
174
+ color: $unnnic-color-fg-base;
175
+ }
176
+ }
177
+
178
+ .unnnic-select {
179
+ &__content {
180
+ display: flex;
181
+ flex-direction: column;
182
+ padding: 0;
183
+ margin: 0;
184
+ gap: $unnnic-space-1;
185
+ }
186
+ }
187
+ </style>
@@ -9,6 +9,7 @@
9
9
  class="tab-head"
10
10
  :class="{
11
11
  'tab-head--active': localValue === tab,
12
+ 'tab-head--disabled': disabledTabs?.includes(tab),
12
13
  }"
13
14
  @click="change(tab)"
14
15
  >
@@ -20,10 +21,9 @@
20
21
  side="bottom"
21
22
  >
22
23
  <UnnnicIcon
23
- icon="info"
24
+ icon="help"
24
25
  :size="size === 'sm' ? 'xs' : 'sm'"
25
- filled
26
- scheme="neutral-cleanest"
26
+ scheme="fg-base"
27
27
  />
28
28
  </UnnnicToolTip>
29
29
  </li>
@@ -65,6 +65,13 @@ export default {
65
65
  tabs: {
66
66
  type: Array,
67
67
  default: null,
68
+ validator: (tabs) => {
69
+ return tabs.every((tab) => typeof tab === 'string') && tabs.length <= 5;
70
+ },
71
+ },
72
+ disabledTabs: {
73
+ type: Array,
74
+ default: null,
68
75
  },
69
76
  },
70
77
  emits: ['change'],
@@ -105,6 +112,10 @@ export default {
105
112
  return '';
106
113
  },
107
114
  change(value) {
115
+ if (this.disabledTabs?.includes(value)) {
116
+ return;
117
+ }
118
+
108
119
  this.localValue = value;
109
120
  this.$emit('change', this.localValue);
110
121
  },
@@ -119,18 +130,15 @@ export default {
119
130
  display: flex;
120
131
  align-items: flex-start;
121
132
  justify-content: space-between;
122
- color: $unnnic-color-neutral-cloudy;
123
- font-family: $unnnic-font-family-secondary;
124
- font-weight: $unnnic-font-weight-bold;
125
- font-size: $unnnic-font-size-body-lg;
126
- line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
127
- margin-bottom: $unnnic-inset-sm;
128
- border-bottom: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
133
+ color: $unnnic-color-fg-base;
134
+ font: $unnnic-font-action;
135
+ margin-bottom: $unnnic-space-4;
136
+ border-bottom: $unnnic-border-width-thinner solid $unnnic-color-border-base;
129
137
  }
130
138
 
131
139
  .tab-content {
132
140
  display: flex;
133
- gap: $unnnic-spacing-sm;
141
+ gap: $unnnic-space-6;
134
142
 
135
143
  margin: 0;
136
144
  padding: 0;
@@ -139,27 +147,24 @@ export default {
139
147
 
140
148
  .tab-head {
141
149
  display: flex;
142
- gap: $unnnic-spacing-xs;
150
+ gap: $unnnic-space-2;
143
151
  align-items: center;
144
152
 
145
153
  cursor: pointer;
146
- margin: $unnnic-spacing-xs $unnnic-spacing-sm;
154
+ padding: $unnnic-space-2 $unnnic-space-4;
147
155
 
148
156
  .unnnic-tooltip {
149
157
  display: flex;
150
158
  }
151
159
 
152
160
  &:hover {
153
- color: $unnnic-color-neutral-black;
161
+ color: $unnnic-color-fg-emphasized;
154
162
  }
155
163
  }
156
164
 
157
165
  .tab-head--active {
158
- font-family: $unnnic-font-family-secondary;
159
- font-weight: $unnnic-font-weight-bold;
160
- color: $unnnic-color-neutral-black;
161
- font-size: $unnnic-font-size-body-lg;
162
- line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
166
+ color: $unnnic-color-fg-emphasized;
167
+ font: $unnnic-font-action;
163
168
  transition: 0.4s;
164
169
 
165
170
  position: relative;
@@ -168,14 +173,23 @@ export default {
168
173
  content: '';
169
174
 
170
175
  position: absolute;
171
- bottom: -$unnnic-spacing-xs;
172
- left: -$unnnic-spacing-sm;
176
+ bottom: 0;
177
+ left: 0;
173
178
 
174
179
  display: block;
175
180
 
176
- width: calc(100% + (#{$unnnic-spacing-sm} * 2));
181
+ width: 100%;
177
182
 
178
- border-bottom: $unnnic-border-width-thin solid $unnnic-color-weni-600;
183
+ border-bottom: $unnnic-border-width-thin solid $unnnic-color-border-active;
184
+ }
185
+ }
186
+
187
+ .tab-head--disabled {
188
+ color: $unnnic-color-fg-muted;
189
+ cursor: default;
190
+
191
+ &:hover {
192
+ color: $unnnic-color-fg-muted;
179
193
  }
180
194
  }
181
195
 
@@ -4,7 +4,7 @@ exports[`Tab.vue > matches the snapshot 1`] = `
4
4
  "<div data-v-b4e39fac="" class="tab size-md">
5
5
  <header data-v-b4e39fac="" class="tab-header">
6
6
  <ul data-v-b4e39fac="" class="tab-content">
7
- <li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--neutral-cleanest unnnic-icon-size--sm material-symbols-rounded--filled" data-testid="material-icon" translate="no">info</span><span data-v-bf0cf546="" class="unnnic-tooltip-label unnnic-tooltip-label-bottom" data-testid="tooltip-label" style="left: 0px; top: 8px;">Tooltip text <br data-v-bf0cf546=""><!--v-if--></span></div>
7
+ <li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm" data-testid="material-icon" translate="no">help</span><span data-v-bf0cf546="" class="unnnic-tooltip-label unnnic-tooltip-label-bottom" data-testid="tooltip-label" style="left: 0px; top: 8px;">Tooltip text <br data-v-bf0cf546=""><!--v-if--></span></div>
8
8
  </li>
9
9
  <li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
10
10
  <!--v-if-->
@@ -41,5 +41,6 @@
41
41
  "flags": "Flags",
42
42
  "custom": "Custom"
43
43
  }
44
- }
44
+ },
45
+ "search": "Search"
45
46
  }
@@ -41,5 +41,6 @@
41
41
  "flags": "Banderas",
42
42
  "custom": "Personalizados"
43
43
  }
44
- }
44
+ },
45
+ "search": "Buscar"
45
46
  }
@@ -41,5 +41,6 @@
41
41
  "flags": "Bandeiras",
42
42
  "custom": "Personalizados"
43
43
  }
44
- }
44
+ },
45
+ "search": "Buscar"
45
46
  }
@@ -0,0 +1,39 @@
1
+ import UnnnicPopover from '../components/Popover/index.vue';
2
+
3
+ export default {
4
+ title: 'example/Popover',
5
+ component: UnnnicPopover,
6
+ render: (args) => ({
7
+ components: { UnnnicPopover },
8
+ setup() {
9
+ return {
10
+ args,
11
+ };
12
+ },
13
+ template: `
14
+ <div>
15
+ <unnnic-popover v-bind="args">
16
+ <template #trigger>
17
+ <button>Click me</button>
18
+ </template>
19
+ <template #content>
20
+ <p>Hello</p>
21
+ </template>
22
+ </unnnic-popover>
23
+ <p>label label</p>
24
+ </div>
25
+ `,
26
+ }),
27
+ };
28
+
29
+ export const Default = {
30
+ args: {
31
+ modelValue: false,
32
+ },
33
+ };
34
+
35
+ export const WithModelValue = {
36
+ args: {
37
+ modelValue: true,
38
+ },
39
+ };
@@ -0,0 +1,91 @@
1
+ import UnnnicSelect from '../components/Select/index.vue';
2
+
3
+ const options = [
4
+ { label: 'Option 1', value: 'option1', altValue: 'alt_value_option1' },
5
+ { label: 'Option 2', value: 'option2', altValue: 'alt_value_option2' },
6
+ { label: 'Option 3', value: 'option3', altValue: 'alt_value_option3' },
7
+ { label: 'Option 4', value: 'option4', altValue: 'alt_value_option4' },
8
+ { label: 'Option 5', value: 'option5', altValue: 'alt_value_option5' },
9
+ { label: 'Option 6', value: 'option6', altValue: 'alt_value_option6' },
10
+ { label: 'Option 7', value: 'option7', altValue: 'alt_value_option7' },
11
+ { label: 'Option 8', value: 'option8', altValue: 'alt_value_option8' },
12
+ { label: 'Option 9', value: 'option9', altValue: 'alt_value_option9' },
13
+ { label: 'Option 10', value: 'option10', disabled: true },
14
+ ];
15
+
16
+ export default {
17
+ title: 'Form/Select',
18
+ component: UnnnicSelect,
19
+ render: (args) => ({
20
+ components: { UnnnicSelect },
21
+ setup() {
22
+ const handleSearch = (value) => {
23
+ args.search = value;
24
+ };
25
+ return { args, handleSearch };
26
+ },
27
+ data() {
28
+ return {
29
+ exampleValue: null,
30
+ };
31
+ },
32
+ template: `
33
+ <p>modelValue: {{ exampleValue }}</p>
34
+ <unnnic-select v-model="exampleValue" v-bind="args" @update:search="handleSearch" />
35
+ `,
36
+ }),
37
+ };
38
+
39
+ export const Default = {
40
+ args: {
41
+ placeholder: 'Placeholder',
42
+ label: 'Label',
43
+ options,
44
+ },
45
+ };
46
+
47
+ export const ReturnObject = {
48
+ args: {
49
+ returnObject: true,
50
+ placeholder: 'Placeholder',
51
+ label: 'Label',
52
+ options,
53
+ },
54
+ };
55
+
56
+ export const AlternativeValueKey = {
57
+ args: {
58
+ itemValue: 'altValue',
59
+ placeholder: 'Placeholder',
60
+ label: 'Label',
61
+ options,
62
+ },
63
+ };
64
+
65
+ export const AlternativeValueLabel = {
66
+ args: {
67
+ itemLabel: 'altValue',
68
+ placeholder: 'Placeholder',
69
+ label: 'Label',
70
+ options,
71
+ },
72
+ };
73
+
74
+ export const Disabled = {
75
+ args: {
76
+ placeholder: 'Placeholder',
77
+ label: 'Label',
78
+ options,
79
+ disabled: true,
80
+ },
81
+ };
82
+
83
+ export const WithSearch = {
84
+ args: {
85
+ placeholder: 'Placeholder',
86
+ label: 'Label',
87
+ options,
88
+ enableSearch: true,
89
+ search: '',
90
+ },
91
+ };
@@ -3,9 +3,6 @@ import unnnicTab from '../components/Tab/Tab.vue';
3
3
  export default {
4
4
  title: 'tabs/Tab',
5
5
  component: unnnicTab,
6
- argTypes: {
7
- size: { control: { type: 'select', options: ['md', 'sm'] } },
8
- },
9
6
  render: (args) => ({
10
7
  components: {
11
8
  unnnicTab,
@@ -36,6 +33,15 @@ export default {
36
33
  Second description
37
34
  </p>
38
35
  </template>
36
+ <template #tab-head-third>
37
+ Third
38
+ </template>
39
+ <template #tab-panel-third>
40
+ <h2 class="title">Third Content</h2>
41
+ <p class="description">
42
+ Third description
43
+ </p>
44
+ </template>
39
45
  </unnnic-tab>
40
46
  `,
41
47
  }),
@@ -44,6 +50,7 @@ export default {
44
50
  export const Default = {
45
51
  args: {
46
52
  initialTab: 'first',
47
- tabs: ['first', 'second'],
53
+ tabs: ['first', 'second', 'third'],
54
+ disabledTabs: ['third'],
48
55
  },
49
56
  };