@weni/unnnic-system 3.12.3-alpha-teleports.1 → 3.12.3-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 (97) hide show
  1. package/dist/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue.d.ts.map +1 -1
  2. package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
  3. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +1 -1
  4. package/dist/components/DateFilter/DateFilter.vue.d.ts +81 -2
  5. package/dist/components/Drawer/Drawer.vue.d.ts.map +1 -1
  6. package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
  7. package/dist/components/Input/BaseInput.vue.d.ts +22 -0
  8. package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
  9. package/dist/components/Input/Input.vue.d.ts +81 -2
  10. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  11. package/dist/components/Input/TextInput.vue.d.ts +52 -1
  12. package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
  13. package/dist/components/InputNext/InputNext.vue.d.ts +1 -1
  14. package/dist/components/ModalNext/ModalNext.vue.d.ts +81 -2
  15. package/dist/components/MultiSelect/MultSelectOption.vue.d.ts +17 -0
  16. package/dist/components/MultiSelect/MultSelectOption.vue.d.ts.map +1 -0
  17. package/dist/components/MultiSelect/index.vue.d.ts +44 -0
  18. package/dist/components/MultiSelect/index.vue.d.ts.map +1 -0
  19. package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
  20. package/dist/components/Select/index.vue.d.ts +44 -0
  21. package/dist/components/Select/index.vue.d.ts.map +1 -0
  22. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +52 -1
  23. package/dist/components/SelectTime/index.vue.d.ts +52 -1
  24. package/dist/components/Switch/Switch.vue.d.ts.map +1 -1
  25. package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -1
  26. package/dist/components/Toast/Toast.vue.d.ts.map +1 -1
  27. package/dist/components/index.d.ts +23720 -0
  28. package/dist/components/index.d.ts.map +1 -0
  29. package/dist/components/ui/popover/PopoverOption.vue.d.ts +18 -0
  30. package/dist/components/ui/popover/PopoverOption.vue.d.ts.map +1 -0
  31. package/dist/components/ui/popover/index.d.ts +1 -0
  32. package/dist/components/ui/popover/index.d.ts.map +1 -1
  33. package/dist/{es-4aa88754.mjs → es-239c29c2.mjs} +1 -1
  34. package/dist/{index-ec96f88a.mjs → index-40e176e4.mjs} +9498 -9233
  35. package/dist/lib/layer-manager.d.ts.map +1 -1
  36. package/dist/locales/en.json.d.ts +2 -1
  37. package/dist/locales/es.json.d.ts +2 -1
  38. package/dist/locales/pt_br.json.d.ts +2 -1
  39. package/dist/{pt-br-ec1ec185.mjs → pt-br-5004a35e.mjs} +1 -1
  40. package/dist/style.css +1 -1
  41. package/dist/unnnic.mjs +176 -172
  42. package/dist/unnnic.umd.js +33 -33
  43. package/package.json +1 -1
  44. package/src/assets/scss/scheme-colors.scss +223 -223
  45. package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +1 -2
  46. package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +60 -61
  47. package/src/components/Checkbox/Checkbox.vue +9 -3
  48. package/src/components/CheckboxGroup/CheckboxGroup.vue +7 -5
  49. package/src/components/Chip/Chip.vue +1 -1
  50. package/src/components/Drawer/Drawer.vue +20 -9
  51. package/src/components/Drawer/__tests__/Drawer.spec.js +11 -9
  52. package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +9 -9
  53. package/src/components/FormElement/FormElement.vue +96 -87
  54. package/src/components/Input/BaseInput.vue +21 -2
  55. package/src/components/Input/Input.scss +2 -3
  56. package/src/components/Input/Input.vue +21 -3
  57. package/src/components/Input/TextInput.vue +58 -22
  58. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +5 -1
  59. package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
  60. package/src/components/ModalDialog/ModalDialog.vue +2 -2
  61. package/src/components/MultiSelect/MultSelectOption.vue +49 -0
  62. package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +556 -0
  63. package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +229 -0
  64. package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +81 -0
  65. package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +51 -0
  66. package/src/components/MultiSelect/index.vue +224 -0
  67. package/src/components/Radio/Radio.vue +12 -6
  68. package/src/components/Radio/__test__/Radio.spec.js +3 -1
  69. package/src/components/RadioGroup/RadioGroup.vue +18 -10
  70. package/src/components/Select/__tests__/Select.spec.js +422 -0
  71. package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
  72. package/src/components/Select/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
  73. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +65 -0
  74. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
  75. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
  76. package/src/components/Select/__tests__/__snapshots__/SelectPopover.spec.js.snap +8 -0
  77. package/src/components/Select/index.vue +261 -0
  78. package/src/components/Switch/Switch.vue +10 -3
  79. package/src/components/TemplatePreview/TemplatePreview.vue +28 -25
  80. package/src/components/TemplatePreview/TemplatePreviewModal.vue +10 -10
  81. package/src/components/TemplatePreview/types.d.ts +3 -3
  82. package/src/components/Toast/Toast.vue +12 -8
  83. package/src/components/index.ts +7 -7
  84. package/src/components/ui/dialog/DialogClose.vue +3 -3
  85. package/src/components/ui/drawer/DrawerClose.vue +9 -3
  86. package/src/components/ui/popover/PopoverOption.vue +4 -0
  87. package/src/lib/layer-manager.ts +12 -20
  88. package/src/locales/en.json +2 -1
  89. package/src/locales/es.json +2 -1
  90. package/src/locales/pt_br.json +2 -1
  91. package/src/stories/MultiSelect.stories.js +142 -46
  92. package/src/stories/Select.stories.js +158 -0
  93. package/src/stories/TemplatePreview.stories.js +27 -27
  94. package/src/stories/TemplatePreviewModal.stories.js +31 -31
  95. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +0 -163
  96. package/dist/components/MultiSelect/MultiSelect.vue.d.ts.map +0 -1
  97. package/src/components/MultiSelect/MultiSelect.vue +0 -297
@@ -1,8 +1,10 @@
1
1
  <template>
2
- <section :class="[
3
- 'unnnic-checkbox-group__container',
4
- `unnnic-checkbox-group--state-${state}`,
5
- ]">
2
+ <section
3
+ :class="[
4
+ 'unnnic-checkbox-group__container',
5
+ `unnnic-checkbox-group--state-${state}`,
6
+ ]"
7
+ >
6
8
  <UnnnicLabel
7
9
  v-if="label"
8
10
  :label="label"
@@ -52,7 +54,7 @@ const props = defineProps({
52
54
  },
53
55
  });
54
56
  </script>
55
-
57
+
56
58
  <style lang="scss" scoped>
57
59
  @use '@/assets/scss/unnnic' as *;
58
60
 
@@ -80,7 +80,7 @@ const chipClass = computed(() => {
80
80
  border-radius: 600px;
81
81
  background-color: $unnnic-color-bg-base;
82
82
  border: 1px solid transparent;
83
-
83
+
84
84
  &:hover {
85
85
  background-color: $unnnic-color-bg-soft;
86
86
  }
@@ -10,11 +10,15 @@
10
10
  :showOverlay="!withoutOverlay"
11
11
  data-testid="drawer-container"
12
12
  :size="mappedSize"
13
- :class="[
14
- 'unnnic-drawer__container',
15
- `unnnic-drawer__container--${size}`,
16
- props.class,
17
- ].filter(Boolean).join(' ')"
13
+ :class="
14
+ [
15
+ 'unnnic-drawer__container',
16
+ `unnnic-drawer__container--${size}`,
17
+ props.class,
18
+ ]
19
+ .filter(Boolean)
20
+ .join(' ')
21
+ "
18
22
  >
19
23
  <DrawerHeader class="unnnic-drawer__header">
20
24
  <section class="unnnic-drawer__title-container">
@@ -91,7 +95,7 @@
91
95
  import { computed } from 'vue';
92
96
 
93
97
  import UnnnicButton from '../Button/Button.vue';
94
- import {
98
+ import {
95
99
  Drawer,
96
100
  DrawerContent,
97
101
  DrawerHeader,
@@ -172,15 +176,22 @@ const props = defineProps({
172
176
  },
173
177
  });
174
178
 
175
- const emit = defineEmits(['primaryButtonClick', 'secondaryButtonClick', 'close', 'back']);
176
- const showFooter = computed(() => !!(props.primaryButtonText || props.secondaryButtonText));
179
+ const emit = defineEmits([
180
+ 'primaryButtonClick',
181
+ 'secondaryButtonClick',
182
+ 'close',
183
+ 'back',
184
+ ]);
185
+ const showFooter = computed(
186
+ () => !!(props.primaryButtonText || props.secondaryButtonText),
187
+ );
177
188
  const mappedSize = computed(() => {
178
189
  const sizes = {
179
190
  md: 'medium',
180
191
  lg: 'large',
181
192
  xl: 'extra-large',
182
193
  gt: 'giant',
183
- }
194
+ };
184
195
  return sizes[props.size] || 'medium';
185
196
  });
186
197
 
@@ -35,7 +35,7 @@ describe('Drawer.vue', () => {
35
35
 
36
36
  const element = (id) => wrapper.find(`[data-testid="${id}"]`);
37
37
  const component = (id) => wrapper.findComponent(`[data-testid="${id}"]`);
38
- const drawer = () => element('drawer');
38
+ const drawerRoot = () => wrapper.findComponent({ name: 'UnnnicDrawerNext' });
39
39
  const title = () => element('drawer-title');
40
40
  const description = () => element('drawer-description');
41
41
  const primaryButton = () => component('primary-button');
@@ -43,6 +43,8 @@ describe('Drawer.vue', () => {
43
43
  const footer = () => element('footer');
44
44
  const closeIcon = () => component('close-icon');
45
45
  const drawerContainer = () => element('drawer-container');
46
+ const drawerContentComponent = () =>
47
+ wrapper.findComponent({ name: 'UnnnicDrawerContent' });
46
48
 
47
49
  describe('Component Rendering', () => {
48
50
  describe('Component Rendering', () => {
@@ -51,23 +53,21 @@ describe('Drawer.vue', () => {
51
53
  });
52
54
 
53
55
  it('should render the drawer when modelValue is true', () => {
54
- expect(drawer().attributes('open')).toBe('true');
56
+ expect(drawerRoot().props('open')).toBe(true);
55
57
  });
56
58
 
57
59
  it('should not render the drawer when modelValue is false', async () => {
58
60
  await wrapper.setProps({ modelValue: false });
59
- expect(drawer().attributes('open')).toBe('false');
61
+ expect(drawerRoot().props('open')).toBe(false);
60
62
  });
61
63
 
62
64
  it('should render the overlay when withoutOverlay is false', () => {
63
- console.log('wrapper.html()', wrapper.html());
64
-
65
- expect(drawerContainer().attributes('showoverlay')).toBe('true');
65
+ expect(drawerContentComponent().props('showOverlay')).toBe(true);
66
66
  });
67
67
 
68
68
  it('should not render the overlay when withoutOverlay is true', async () => {
69
69
  await wrapper.setProps({ withoutOverlay: true });
70
- expect(drawerContainer().attributes('showoverlay')).toBe('false');
70
+ expect(drawerContentComponent().props('showOverlay')).toBe(false);
71
71
  });
72
72
 
73
73
  it('should display the title and description correctly', () => {
@@ -217,14 +217,16 @@ describe('Drawer.vue', () => {
217
217
  describe('Props and Computed Properties', () => {
218
218
  it('should render the correct size class based on size prop', async () => {
219
219
  await wrapper.setProps({ size: 'lg' });
220
- expect(drawerContainer().classes()).toContain(
220
+ expect(drawerContentComponent().props('class')).toContain(
221
221
  'unnnic-drawer__container--lg',
222
222
  );
223
+ expect(drawerContentComponent().props('size')).toBe('large');
223
224
 
224
225
  await wrapper.setProps({ size: 'xl' });
225
- expect(drawerContainer().classes()).toContain(
226
+ expect(drawerContentComponent().props('class')).toContain(
226
227
  'unnnic-drawer__container--xl',
227
228
  );
229
+ expect(drawerContentComponent().props('size')).toBe('extra-large');
228
230
  });
229
231
 
230
232
  it('should display footer if either primaryButtonText or secondaryButtonText is provided', async () => {
@@ -1,22 +1,22 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`Drawer.vue > Component Rendering > Component Rendering > matches the snapshot 1`] = `
4
- "<div data-v-196de012="" class="unnnic-drawer" data-testid="drawer" open="true">
5
- <div data-v-196de012="" showoverlay="true" data-testid="drawer-container" size="medium" class="unnnic-drawer__container unnnic-drawer__container--md">
4
+ "<div data-v-e761d31f="" data-v-196de012="" disabled="false" defer="false" forcemount="false" data-testid="drawer-container">
5
+ <div data-v-7f241b30="" data-v-e761d31f="" data-state="open" style="pointer-events: auto;" data-vaul-overlay="" data-vaul-snap-points="false" data-vaul-snap-points-overlay="true" class="unnnic-drawer__overlay"></div>
6
+ <div data-v-e761d31f="" data-dismissable-layer="" style="--snap-point-height: 0; --initial-transform: calc(100% + 8px); pointer-events: auto;" tabindex="-1" data-vaul-drawer="" data-vaul-drawer-direction="right" data-vaul-delayed-snap-points="false" data-vaul-snap-points="false" size="medium" showoverlay="true" class="unnnic-drawer__content unnnic-drawer__content--medium unnnic-drawer__container unnnic-drawer__container--md" id="" role="dialog" aria-describedby="reka-dialog-description-v-1" aria-labelledby="reka-dialog-title-v-0" data-state="open">
6
7
  <header data-v-39d0dfb8="" data-v-196de012="" class="unnnic-drawer__header unnnic-drawer__header">
7
8
  <section data-v-196de012="" class="unnnic-drawer__title-container">
8
- <div data-v-196de012="" class="unnnic-drawer__title" data-testid="drawer-title">Test Title</div>
9
- <div data-v-196de012="" class="unnnic-drawer__description" data-testid="drawer-description">Test Description</div>
10
- </section>
11
- <div data-v-196de012="">
9
+ <h2 data-v-97709962="" data-v-196de012="" id="reka-dialog-title-v-0" class="unnnic-drawer__title unnnic-drawer__title" data-testid="drawer-title">Test Title</h2>
10
+ <p data-v-750ea255="" data-v-196de012="" id="reka-dialog-description-v-1" class="unnnic-drawer__description unnnic-drawer__description" data-testid="drawer-description">Test Description</p>
11
+ </section><button data-v-4a771f40="" data-v-196de012="" type="button" class="unnnic-drawer__close">
12
12
  <unnnic-button-stub data-v-196de012="" size="small" text="" type="tertiary" float="false" iconleft="" iconright="" iconcenter="arrow_forward" iconsfilled="false" disabled="false" loading="false" class="unnnic-drawer__close-icon" data-testid="close-icon"></unnnic-button-stub>
13
- </div>
13
+ </button>
14
14
  </header>
15
15
  <section data-v-196de012="" class="unnnic-drawer__content"></section>
16
- <div data-v-196de012="" class="unnnic-drawer__footer" data-testid="footer">
16
+ <footer data-v-02ebc5b4="" data-v-196de012="" class="unnnic-drawer__footer unnnic-drawer__footer" data-testid="footer">
17
17
  <unnnic-button-stub data-v-196de012="" size="large" text="Secondary Action" type="tertiary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="secondary-button"></unnnic-button-stub>
18
18
  <unnnic-button-stub data-v-196de012="" size="large" text="Primary Action" type="primary" float="false" iconleft="" iconright="" iconcenter="" iconsfilled="false" disabled="false" loading="false" data-testid="primary-button"></unnnic-button-stub>
19
- </div>
19
+ </footer>
20
20
  </div>
21
21
  </div>"
22
22
  `;
@@ -1,28 +1,37 @@
1
1
  <template>
2
- <section class="unnnic-form-element" :class="{ 'unnnic-form-element--disabled': disabled }">
3
- <UnnnicLabel
4
- v-if="label"
5
- :label="label"
2
+ <section
3
+ class="unnnic-form-element"
4
+ :class="{ 'unnnic-form-element--disabled': disabled }"
5
+ >
6
+ <UnnnicLabel
7
+ v-if="label"
8
+ :label="label"
6
9
  :tooltip="tooltip"
7
10
  :class="[
8
11
  'unnnic-form-element__label',
9
12
  {
10
13
  'unnnic-form-element__label--fixed': fixedLabel,
11
14
  },
12
- ]"
15
+ ]"
13
16
  />
14
17
 
15
18
  <slot></slot>
16
19
 
17
- <section
20
+ <section
18
21
  class="unnnic-form-element__hints-container"
19
22
  v-if="message || error || !!$slots.rightMessage"
20
23
  >
21
24
  <section class="unnnic-form-element__message-container">
22
- <p v-if="message" class="unnnic-form-element__message">
25
+ <p
26
+ v-if="message"
27
+ class="unnnic-form-element__message"
28
+ >
23
29
  {{ fullySanitize(message) }}
24
30
  </p>
25
- <p v-if="!!error?.length" class="unnnic-form-element__message error">
31
+ <p
32
+ v-if="!!error?.length"
33
+ class="unnnic-form-element__message error"
34
+ >
26
35
  {{ Array.isArray(error) ? error.join(', ') : error }}
27
36
  </p>
28
37
  </section>
@@ -34,104 +43,104 @@
34
43
  </template>
35
44
 
36
45
  <script lang="js">
37
- import { fullySanitize } from '../../utils/sanitize';
38
- import UnnnicLabel from '../Label/Label.vue';
39
-
40
- export default {
41
- components: {
42
- UnnnicLabel,
46
+ import { fullySanitize } from '../../utils/sanitize';
47
+ import UnnnicLabel from '../Label/Label.vue';
48
+
49
+ export default {
50
+ components: {
51
+ UnnnicLabel,
52
+ },
53
+ props: {
54
+ size: {
55
+ type: String,
56
+ default: 'md',
57
+ validator: (size) => ['md', 'sm'].includes(size),
43
58
  },
44
- props: {
45
- size: {
46
- type: String,
47
- default: 'md',
48
- validator: (size) => ['md', 'sm'].includes(size),
49
- },
50
59
 
51
- label: { type: String, default: '' },
60
+ label: { type: String, default: '' },
52
61
 
53
- fixedLabel: { type: Boolean, default: false },
62
+ fixedLabel: { type: Boolean, default: false },
54
63
 
55
- error: {
56
- type: [Boolean, String],
57
- default: false,
58
- },
64
+ error: {
65
+ type: [Boolean, String],
66
+ default: false,
67
+ },
59
68
 
60
- message: { type: String, default: '' },
69
+ message: { type: String, default: '' },
61
70
 
62
- disabled: { type: Boolean, default: false },
71
+ disabled: { type: Boolean, default: false },
63
72
 
64
- tooltip: { type: String, default: '' },
65
- },
66
- methods: {
67
- fullySanitize,
68
- },
69
- };
73
+ tooltip: { type: String, default: '' },
74
+ },
75
+ methods: {
76
+ fullySanitize,
77
+ },
78
+ };
70
79
  </script>
71
80
 
72
81
  <style lang="scss" scoped>
73
- @use '@/assets/scss/unnnic' as *;
74
-
75
- * {
76
- margin: $unnnic-space-0;
77
- padding: $unnnic-space-0;
78
- box-sizing: border-box;
79
- }
82
+ @use '@/assets/scss/unnnic' as *;
83
+
84
+ * {
85
+ margin: $unnnic-space-0;
86
+ padding: $unnnic-space-0;
87
+ box-sizing: border-box;
88
+ }
89
+
90
+ .unnnic-form-element {
91
+ &__label {
92
+ font: $unnnic-font-body;
93
+ color: $unnnic-color-neutral-cloudy;
94
+ margin-bottom: $unnnic-space-1;
95
+ display: flex;
96
+ align-items: center;
97
+ gap: $unnnic-space-2;
98
+
99
+ &--fixed {
100
+ margin-top: -$unnnic-font-size-body-gt - $unnnic-space-2 + $unnnic-space-1;
101
+ }
80
102
 
81
- .unnnic-form-element {
82
- &__label {
83
- font: $unnnic-font-body;
84
- color: $unnnic-color-neutral-cloudy;
85
- margin-bottom: $unnnic-space-1;
86
- display: flex;
87
- align-items: center;
88
- gap: $unnnic-space-2;
89
-
90
- &--fixed {
91
- margin-top: -$unnnic-font-size-body-gt - $unnnic-space-2 + $unnnic-space-1;
92
- }
103
+ &--fixed {
104
+ margin-bottom: $unnnic-space-0;
105
+ position: absolute;
106
+ padding: $unnnic-space-0 $unnnic-space-1;
107
+ margin-left: $unnnic-space-2;
93
108
 
94
- &--fixed {
95
- margin-bottom: $unnnic-space-0;
109
+ &:after {
110
+ content: ' ';
96
111
  position: absolute;
97
- padding: $unnnic-space-0 $unnnic-space-1;
98
- margin-left: $unnnic-space-2;
99
-
100
- &:after {
101
- content: ' ';
102
- position: absolute;
103
- left: $unnnic-space-0;
104
- bottom: $unnnic-space-1 - $unnnic-border-width-thinner;
105
- width: 100%;
106
- height: $unnnic-border-width-thinner;
107
- background-color: $unnnic-color-white;
108
- }
112
+ left: $unnnic-space-0;
113
+ bottom: $unnnic-space-1 - $unnnic-border-width-thinner;
114
+ width: 100%;
115
+ height: $unnnic-border-width-thinner;
116
+ background-color: $unnnic-color-white;
109
117
  }
110
118
  }
119
+ }
111
120
 
112
- &__message {
113
- &.error {
114
- color: $unnnic-color-fg-critical;
115
- }
121
+ &__message {
122
+ &.error {
123
+ color: $unnnic-color-fg-critical;
116
124
  }
125
+ }
117
126
 
118
- &__hints-container {
119
- display: flex;
120
- justify-content: space-between;
121
- margin-top: $unnnic-space-1;
122
- font: $unnnic-font-caption-2;
123
- color: $unnnic-color-fg-base;
124
- }
127
+ &__hints-container {
128
+ display: flex;
129
+ justify-content: space-between;
130
+ margin-top: $unnnic-space-1;
131
+ font: $unnnic-font-caption-2;
132
+ color: $unnnic-color-fg-base;
133
+ }
125
134
 
126
- &__message-container {
127
- display: flex;
128
- flex-direction: column;
129
- gap: $unnnic-space-1;
130
- }
135
+ &__message-container {
136
+ display: flex;
137
+ flex-direction: column;
138
+ gap: $unnnic-space-1;
139
+ }
131
140
 
132
- &--disabled .unnnic-form-element__label,
133
- &--disabled .unnnic-form-element__message {
134
- user-select: none;
135
- }
141
+ &--disabled .unnnic-form-element__label,
142
+ &--disabled .unnnic-form-element__message {
143
+ user-select: none;
136
144
  }
145
+ }
137
146
  </style>
@@ -4,16 +4,18 @@
4
4
  v-mask="mask"
5
5
  v-bind="attributes"
6
6
  :value="fullySanitize(modelValue)"
7
- :class="classes"
7
+ :class="[classes, { focus: forceActiveStatus }]"
8
8
  :type="nativeType"
9
+ :readonly="readonly"
9
10
  />
10
11
  <input
11
12
  v-else
12
13
  v-bind="attributes"
13
14
  :value="fullySanitize(modelValue)"
14
- :class="classes"
15
+ :class="[classes, { focus: forceActiveStatus }]"
15
16
  :type="nativeType"
16
17
  :maxlength="maxlength"
18
+ :readonly="readonly"
17
19
  />
18
20
  </template>
19
21
 
@@ -49,10 +51,19 @@ export default {
49
51
  },
50
52
  hasIconLeft: Boolean,
51
53
  hasIconRight: Boolean,
54
+ hasClearIcon: Boolean,
52
55
  maxlength: {
53
56
  type: Number,
54
57
  default: null,
55
58
  },
59
+ readonly: {
60
+ type: Boolean,
61
+ default: false,
62
+ },
63
+ forceActiveStatus: {
64
+ type: Boolean,
65
+ default: false,
66
+ },
56
67
  },
57
68
  emits: ['update:modelValue'],
58
69
  data() {
@@ -77,6 +88,7 @@ export default {
77
88
  {
78
89
  'input--has-icon-left': this.hasIconLeft,
79
90
  'input--has-icon-right': this.hasIconRight,
91
+ 'input--has-clear-icon': this.hasClearIcon,
80
92
  },
81
93
  ];
82
94
  },
@@ -117,6 +129,13 @@ export default {
117
129
 
118
130
  &.input--has-icon-right {
119
131
  padding-right: $unnnic-space-10;
132
+ &.input--has-clear-icon {
133
+ padding-right: $unnnic-space-10 + $unnnic-space-6;
134
+ }
135
+ }
136
+
137
+ &.input--has-clear-icon {
138
+ padding-right: $unnnic-space-10;
120
139
  }
121
140
 
122
141
  &.error {
@@ -9,9 +9,8 @@
9
9
  caret-color: $unnnic-color-fg-muted;
10
10
  font: $unnnic-font-body;
11
11
 
12
- transition: border-color 0.1s ease-in-out;
13
-
14
- &:focus {
12
+ &:focus,
13
+ &.focus {
15
14
  border-color: $unnnic-color-border-active;
16
15
  }
17
16
 
@@ -13,6 +13,7 @@
13
13
  v-bind="$attrs"
14
14
  v-model="val"
15
15
  class="unnnic-form-input"
16
+ :forceActiveStatus="forceActiveStatus"
16
17
  :placeholder="placeholder"
17
18
  :iconLeft="iconLeft"
18
19
  :iconRight="iconRight"
@@ -25,6 +26,9 @@
25
26
  :nativeType="nativeType"
26
27
  :maxlength="maxlength"
27
28
  :disabled="disabled"
29
+ :readonly="readonly"
30
+ :showClear="showClear"
31
+ @clear="$emit('clear')"
28
32
  />
29
33
 
30
34
  <template
@@ -43,8 +47,8 @@ import UnnnicFormElement from '../FormElement/FormElement.vue';
43
47
 
44
48
  export default {
45
49
  name: 'UnnnicInput',
46
- components: {
47
- TextInput,
50
+ components: {
51
+ TextInput,
48
52
  UnnnicFormElement,
49
53
  },
50
54
  props: {
@@ -127,8 +131,22 @@ export default {
127
131
  type: Boolean,
128
132
  default: false,
129
133
  },
134
+ readonly: {
135
+ type: Boolean,
136
+ default: false,
137
+ },
138
+ forceActiveStatus: {
139
+ type: Boolean,
140
+ default: false,
141
+ },
142
+ showClear: {
143
+ type: Boolean,
144
+ default: false,
145
+ },
130
146
  },
131
- emits: ['update:modelValue'],
147
+
148
+ emits: ['update:modelValue', 'clear'],
149
+
132
150
  data() {
133
151
  return {
134
152
  val: this.modelValue,
@@ -12,7 +12,10 @@
12
12
  class="input-itself"
13
13
  :hasIconLeft="!!iconLeft"
14
14
  :hasIconRight="!!iconRight || allowTogglePassword"
15
+ :hasClearIcon="showClear"
15
16
  :maxlength="maxlength"
17
+ :readonly="readonly"
18
+ :forceActiveStatus="forceActiveStatus"
16
19
  @focus="onFocus"
17
20
  @blur="onBlur"
18
21
  />
@@ -27,18 +30,28 @@
27
30
  @click="onIconLeftClick"
28
31
  />
29
32
 
30
- <UnnnicIcon
31
- v-if="iconRightSvg"
32
- :scheme="iconScheme"
33
- :icon="iconRightSvg"
34
- size="ant"
35
- :clickable="iconRightClickable || allowTogglePassword"
36
- :class="[
37
- 'icon-right',
38
- { clickable: iconRightClickable || allowTogglePassword },
39
- ]"
40
- @click="onIconRightClick"
41
- />
33
+ <section class="icon-right-container">
34
+ <UnnnicIcon
35
+ v-if="showClear"
36
+ class="icon-clear"
37
+ :scheme="iconScheme"
38
+ icon="close"
39
+ size="ant"
40
+ clickable
41
+ @click.stop="onClearClick"
42
+ />
43
+
44
+ <UnnnicIcon
45
+ v-if="iconRightSvg"
46
+ :scheme="iconScheme"
47
+ :icon="iconRightSvg"
48
+ size="ant"
49
+ :clickable="iconRightClickable || allowTogglePassword"
50
+ class="icon-right"
51
+ :class="{ clickable: iconRightClickable || allowTogglePassword }"
52
+ @click="onIconRightClick"
53
+ />
54
+ </section>
42
55
  </div>
43
56
  </template>
44
57
 
@@ -103,8 +116,20 @@ export default {
103
116
  type: Boolean,
104
117
  default: false,
105
118
  },
119
+ readonly: {
120
+ type: Boolean,
121
+ default: false,
122
+ },
123
+ forceActiveStatus: {
124
+ type: Boolean,
125
+ default: false,
126
+ },
127
+ showClear: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
106
131
  },
107
- emits: ['icon-left-click', 'icon-right-click'],
132
+ emits: ['icon-left-click', 'icon-right-click', 'clear'],
108
133
  data() {
109
134
  return {
110
135
  isFocused: false,
@@ -128,7 +153,6 @@ export default {
128
153
  if (this.isDisabled) {
129
154
  return 'fg-muted';
130
155
  }
131
-
132
156
  return 'fg-base';
133
157
  },
134
158
 
@@ -154,6 +178,10 @@ export default {
154
178
  if (this.iconLeftClickable) this.$emit('icon-left-click');
155
179
  },
156
180
 
181
+ onClearClick() {
182
+ this.$emit('clear');
183
+ },
184
+
157
185
  onIconRightClick() {
158
186
  if (this.attributes.disabled) return;
159
187
  if (this.allowTogglePassword) this.showPassword = !this.showPassword;
@@ -171,25 +199,33 @@ export default {
171
199
  }
172
200
 
173
201
  .icon {
174
- &-left,
175
- &-right {
176
- &:not(.clickable) {
177
- pointer-events: none;
178
- }
179
- }
180
-
181
202
  &-left {
182
203
  position: absolute;
183
204
  top: 50%;
184
205
  transform: translateY(-50%);
185
206
  left: $unnnic-space-4;
207
+
208
+ &:not(.clickable) {
209
+ pointer-events: none;
210
+ }
186
211
  }
187
212
 
188
- &-right {
213
+ &-right-container {
189
214
  position: absolute;
190
215
  top: 50%;
191
216
  transform: translateY(-50%);
192
217
  right: $unnnic-space-4;
218
+
219
+ display: flex;
220
+ align-items: center;
221
+ gap: $unnnic-space-2;
222
+
223
+ .icon-clear {
224
+ cursor: pointer;
225
+ }
226
+ .icon-right:not(.clickable) {
227
+ pointer-events: none;
228
+ }
193
229
  }
194
230
  }
195
231
  </style>