@pequity/squirrel 6.0.12 → 6.0.14

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 (69) hide show
  1. package/dist/cjs/chunks/index.js +2645 -0
  2. package/dist/cjs/chunks/p-btn.types.js +3 -0
  3. package/dist/cjs/chunks/p-select.js +2 -2
  4. package/dist/cjs/index.js +49 -52
  5. package/dist/cjs/inputClasses.js +129 -0
  6. package/dist/cjs/inputClassesMixin.js +23 -19
  7. package/dist/cjs/p-btn.js +56 -57
  8. package/dist/cjs/p-input-search.js +3 -3
  9. package/dist/cjs/useInputClasses.js +19 -18
  10. package/dist/es/chunks/index.js +2646 -0
  11. package/dist/es/chunks/p-btn.types.js +4 -0
  12. package/dist/es/chunks/p-select.js +2 -2
  13. package/dist/es/index.js +75 -78
  14. package/dist/es/inputClasses.js +129 -0
  15. package/dist/es/inputClassesMixin.js +23 -19
  16. package/dist/es/p-btn.js +56 -57
  17. package/dist/es/p-input-search.js +3 -3
  18. package/dist/es/useInputClasses.js +23 -22
  19. package/dist/squirrel/components/p-btn/p-btn.types.d.ts +2 -1
  20. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +395 -17
  21. package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +30 -22
  22. package/dist/squirrel/components/p-input/p-input.vue.d.ts +11 -7
  23. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +11 -7
  24. package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +3 -3
  25. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +16 -12
  26. package/dist/squirrel/components/p-select/p-select.vue.d.ts +5 -5
  27. package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +30 -22
  28. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +1 -1
  29. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +11 -7
  30. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +11 -7
  31. package/dist/squirrel/composables/useInputClasses.d.ts +3 -3
  32. package/dist/squirrel/index.d.ts +1 -0
  33. package/dist/squirrel/utils/index.d.ts +2 -2
  34. package/dist/squirrel/utils/inputClasses.d.ts +988 -0
  35. package/dist/squirrel/utils/inputClassesMixin.d.ts +12 -8
  36. package/dist/squirrel.css +15 -22
  37. package/package.json +22 -19
  38. package/squirrel/assets/squirrel.css +1 -1
  39. package/squirrel/components/p-action-bar/p-action-bar.stories.js +1 -2
  40. package/squirrel/components/p-btn/p-btn.spec.js +1 -1
  41. package/squirrel/components/p-btn/p-btn.types.ts +3 -1
  42. package/squirrel/components/p-btn/p-btn.vue +60 -74
  43. package/squirrel/components/p-file-upload/p-file-upload.spec.js +3 -8
  44. package/squirrel/components/p-file-upload/p-file-upload.vue +6 -16
  45. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +3 -10
  46. package/squirrel/components/p-input/p-input.spec.js +3 -8
  47. package/squirrel/components/p-input-number/p-input-number.spec.js +15 -18
  48. package/squirrel/components/p-input-percent/p-input-percent.spec.js +3 -8
  49. package/squirrel/components/p-input-percent/p-input-percent.vue +3 -3
  50. package/squirrel/components/p-input-search/p-input-search.vue +4 -4
  51. package/squirrel/components/p-select/p-select.spec.js +28 -34
  52. package/squirrel/components/p-select/p-select.vue +4 -4
  53. package/squirrel/components/p-tabs/p-tabs.stories.js +2 -2
  54. package/squirrel/components/p-textarea/p-textarea.spec.js +3 -8
  55. package/squirrel/composables/useInputClasses.spec.js +138 -77
  56. package/squirrel/composables/useInputClasses.ts +25 -39
  57. package/squirrel/index.ts +1 -0
  58. package/squirrel/utils/index.ts +3 -36
  59. package/squirrel/utils/inputClasses.ts +130 -0
  60. package/squirrel/utils/inputClassesMixin.spec.js +153 -64
  61. package/squirrel/utils/inputClassesMixin.ts +26 -43
  62. package/dist/cjs/inputClassesShared.js +0 -76
  63. package/dist/es/inputClassesShared.js +0 -76
  64. package/dist/squirrel/utils/inputClassesShared.d.ts +0 -45
  65. package/squirrel/assets/file-upload-drag-over-icon.svg +0 -5
  66. package/squirrel/assets/file-upload-upload-icon.svg +0 -5
  67. package/squirrel/assets/file-upload-x-icon-hover.svg +0 -8
  68. package/squirrel/assets/file-upload-x-icon.svg +0 -8
  69. package/squirrel/utils/inputClassesShared.ts +0 -75
@@ -1,26 +1,13 @@
1
+ import { type Size } from '@squirrel/components/p-btn/p-btn.types';
1
2
  import {
2
- ERROR_MSG,
3
- INPUT_BASE,
4
- INPUT_ERROR,
5
- INPUT_NORMAL,
6
- INPUT_SIZES,
7
- type InputSize,
8
- LABEL_BASE,
9
- LABEL_REQUIRED,
10
- LABEL_SIZES,
11
- SELECT_ARROW,
12
- SELECT_BASE,
13
- SELECT_SIZES,
14
- SPACING_LEFT,
15
- SPACING_PREFIX,
16
- SPACING_RIGHT,
17
- SPACING_SUFFIX,
18
- TEXTAREA_BASE,
19
- } from '@squirrel/utils/inputClassesShared';
3
+ inputClasses as tvInputClasses,
4
+ selectClasses as tvSelectClasses,
5
+ textareaClasses as tvTextareaClasses,
6
+ } from '@squirrel/utils/inputClasses';
20
7
  import { computed, ref, toRefs } from 'vue';
21
8
 
22
9
  const defaults = {
23
- size: ref<InputSize>('md'),
10
+ size: ref<Size>('md'),
24
11
  errorMsg: ref(''),
25
12
  required: ref(false),
26
13
  prefix: ref(false),
@@ -29,7 +16,7 @@ const defaults = {
29
16
  };
30
17
 
31
18
  type Props = {
32
- size: InputSize;
19
+ size: Size;
33
20
  errorMsg: string;
34
21
  required: boolean;
35
22
  prefix: boolean;
@@ -43,38 +30,37 @@ export function useInputClasses(props: Partial<Props>) {
43
30
  const opts = { ...defaults, ...toRefs(props) } as Defaults;
44
31
  const { size, errorMsg, required, rounded, prefix, suffix } = opts;
45
32
 
46
- const inputClasses = computed(() => {
47
- const base = `${INPUT_BASE} ${INPUT_SIZES[size.value]}`;
48
- const spacingLeft = prefix.value ? SPACING_PREFIX[size.value] : SPACING_LEFT[size.value];
49
- const spacingRight = suffix.value ? SPACING_SUFFIX[size.value] : SPACING_RIGHT[size.value];
50
- const res = `${base} ${spacingLeft} ${spacingRight} ${errorMsg.value ? INPUT_ERROR : INPUT_NORMAL}${rounded.value ? ' rounded-full' : ''}`;
33
+ const allClasses = computed(() => {
34
+ const { input, label, errorMessage } = tvInputClasses({
35
+ size: size.value,
36
+ prefix: prefix.value,
37
+ suffix: suffix.value,
38
+ required: required.value,
39
+ error: !!errorMsg.value,
40
+ rounded: rounded.value,
41
+ });
51
42
 
52
- return res;
43
+ return { input: input(), label: label(), errorMessage: errorMessage() };
53
44
  });
54
45
 
55
- const labelClasses = computed(() => {
56
- const base = `${LABEL_BASE} ${LABEL_SIZES[size.value]}`;
57
- const res = required.value ? `${base} ${LABEL_REQUIRED}` : base;
46
+ const inputClasses = computed(() => allClasses.value.input);
58
47
 
59
- return res;
60
- });
48
+ const labelClasses = computed(() => allClasses.value.label);
49
+
50
+ const errorMsgClasses = computed(() => allClasses.value.errorMessage);
61
51
 
62
52
  const selectClasses = computed(() => {
63
- const res = `${inputClasses.value.replace(` ${SPACING_RIGHT[size.value]}`, '')} ${SELECT_BASE} ${SELECT_ARROW} ${
64
- SELECT_SIZES[size.value]
65
- }`;
53
+ const { input } = tvSelectClasses({ size: size.value, required: required.value, error: !!errorMsg.value });
66
54
 
67
- return res;
55
+ return input();
68
56
  });
69
57
 
70
58
  const textareaClasses = computed(() => {
71
- const res = `${inputClasses.value} ${TEXTAREA_BASE}`;
59
+ const { input } = tvTextareaClasses({ required: required.value, error: !!errorMsg.value });
72
60
 
73
- return res;
61
+ return input();
74
62
  });
75
63
 
76
- const errorMsgClasses = ref(ERROR_MSG);
77
-
78
64
  return {
79
65
  inputClasses,
80
66
  labelClasses,
package/squirrel/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from '@squirrel/components';
4
4
  export * from '@squirrel/composables';
5
5
  export * from '@squirrel/tailwind/config';
6
6
  export * from '@squirrel/utils';
7
+ export * from 'tailwind-variants';
@@ -1,25 +1,7 @@
1
+ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
1
2
  import { CURRENCY_INPUT_DEFAULTS } from '@squirrel/utils/currency';
2
3
  import { getNextActiveElement, isElement, isVisible } from '@squirrel/utils/dom';
3
4
  import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
4
- import {
5
- ERROR_MSG,
6
- INPUT_BASE,
7
- INPUT_ERROR,
8
- INPUT_NORMAL,
9
- INPUT_SIZES,
10
- type InputSize,
11
- LABEL_BASE,
12
- LABEL_REQUIRED,
13
- LABEL_SIZES,
14
- SELECT_ARROW,
15
- SELECT_BASE,
16
- SELECT_SIZES,
17
- SPACING_LEFT,
18
- SPACING_PREFIX,
19
- SPACING_RIGHT,
20
- SPACING_SUFFIX,
21
- TEXTAREA_BASE,
22
- } from '@squirrel/utils/inputClassesShared';
23
5
  import { setupListKeyboardNavigation } from '@squirrel/utils/listKeyboardNavigation';
24
6
  import { toNumberOrNull } from '@squirrel/utils/number';
25
7
  import { isObject } from '@squirrel/utils/object';
@@ -33,34 +15,19 @@ export {
33
15
  Color,
34
16
  createPagingRange,
35
17
  CURRENCY_INPUT_DEFAULTS,
36
- ERROR_MSG,
37
18
  getColor,
38
19
  getColorDeep,
39
20
  getNextActiveElement,
40
21
  getScreen,
41
- INPUT_BASE,
42
- INPUT_ERROR,
43
- INPUT_NORMAL,
44
- INPUT_SIZES,
45
22
  inputClassesMixin,
46
- InputSize,
47
23
  isElement,
48
24
  isObject,
49
25
  isVisible,
50
- LABEL_BASE,
51
- LABEL_REQUIRED,
52
- LABEL_SIZES,
53
26
  sanitizeUrl,
54
- SELECT_ARROW,
55
- SELECT_BASE,
56
- SELECT_SIZES,
57
27
  setupListKeyboardNavigation,
58
- SPACING_LEFT,
59
- SPACING_PREFIX,
60
- SPACING_RIGHT,
61
- SPACING_SUFFIX,
28
+ Size,
29
+ SIZES,
62
30
  splitStringForHighlight,
63
- TEXTAREA_BASE,
64
31
  toNumberOrNull,
65
32
  toString,
66
33
  };
@@ -0,0 +1,130 @@
1
+ import { tv } from 'tailwind-variants';
2
+
3
+ const inputClasses = tv({
4
+ slots: {
5
+ input:
6
+ 'w-full rounded border-0 bg-surface text-night ring-1 ring-inset ring-p-gray-30 placeholder:text-p-gray-40 hover:ring-primary focus:outline-none focus:ring-2 focus:ring-primary disabled:cursor-default disabled:bg-p-blue-10 disabled:ring-p-gray-30 disabled:hover:ring-p-gray-30',
7
+ label: 'mb-1 block font-medium',
8
+ errorMessage: 'mt-1 text-xs text-on-error',
9
+ },
10
+ variants: {
11
+ size: {
12
+ sm: {
13
+ input: 'h-8 pl-3 pr-3 text-sm',
14
+ label: 'text-xs',
15
+ },
16
+ md: {
17
+ input: 'h-10 pl-4 pr-4 text-base',
18
+ label: 'text-sm',
19
+ },
20
+ lg: {
21
+ input: 'h-12 pl-5 pr-5 text-lg',
22
+ label: 'text-base',
23
+ },
24
+ },
25
+ prefix: {
26
+ true: 'pl-8',
27
+ },
28
+ suffix: {
29
+ true: 'pr-6',
30
+ },
31
+ required: {
32
+ true: {
33
+ label: `after:text-on-error after:content-["_*"]`,
34
+ },
35
+ },
36
+ error: {
37
+ true: {
38
+ input: 'ring-on-error hover:ring-on-error focus:ring-on-error',
39
+ },
40
+ },
41
+ rounded: {
42
+ true: {
43
+ input: 'rounded-full',
44
+ },
45
+ },
46
+ },
47
+ compoundVariants: [
48
+ {
49
+ size: 'sm',
50
+ prefix: true,
51
+ class: {
52
+ input: 'pl-6',
53
+ },
54
+ },
55
+ {
56
+ size: 'md',
57
+ prefix: true,
58
+ class: {
59
+ input: 'pl-8',
60
+ },
61
+ },
62
+ {
63
+ size: 'lg',
64
+ prefix: true,
65
+ class: {
66
+ input: 'pl-12',
67
+ },
68
+ },
69
+ {
70
+ size: 'sm',
71
+ suffix: true,
72
+ class: {
73
+ input: 'pr-6',
74
+ },
75
+ },
76
+ {
77
+ size: 'md',
78
+ suffix: true,
79
+ class: {
80
+ input: 'pr-8',
81
+ },
82
+ },
83
+ {
84
+ size: 'lg',
85
+ suffix: true,
86
+ class: {
87
+ input: 'pr-12',
88
+ },
89
+ },
90
+ ],
91
+ defaultVariants: {
92
+ size: 'md',
93
+ },
94
+ });
95
+
96
+ const textareaClasses = tv({
97
+ extend: inputClasses,
98
+ slots: {
99
+ input: 'resize-y overflow-auto px-3 py-3',
100
+ },
101
+ variants: {
102
+ size: {
103
+ md: {
104
+ input: 'h-auto',
105
+ },
106
+ },
107
+ },
108
+ });
109
+
110
+ const selectClasses = tv({
111
+ extend: inputClasses,
112
+ slots: {
113
+ input: 'squirrel-bg-chevron-down appearance-none truncate bg-no-repeat',
114
+ },
115
+ variants: {
116
+ size: {
117
+ sm: {
118
+ input: 'bg-[position:right_0.675rem_center] pr-8',
119
+ },
120
+ md: {
121
+ input: 'bg-[position:right_1rem_center] pr-10',
122
+ },
123
+ lg: {
124
+ input: 'bg-[position:right_1.25rem_center] pr-12',
125
+ },
126
+ },
127
+ },
128
+ });
129
+
130
+ export { inputClasses, selectClasses, textareaClasses };
@@ -1,49 +1,57 @@
1
1
  import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
2
2
  import { shallowMount } from '@vue/test-utils';
3
3
 
4
- const baseInputClasses = () =>
5
- [
6
- 'text-night',
7
- 'w-full',
8
- 'bg-surface',
9
- 'focus:outline-none',
10
- 'border-0',
11
- 'ring-1',
12
- 'ring-inset',
13
- 'focus:ring-2',
14
- 'disabled:ring-p-gray-30',
15
- 'disabled:hover:ring-p-gray-30',
16
- 'disabled:bg-p-blue-10',
17
- 'disabled:cursor-default',
18
- 'placeholder:text-p-gray-40',
19
- 'h-10',
20
- 'text-base',
21
- 'rounded',
22
- 'pl-4',
23
- 'pr-4',
24
- 'ring-p-gray-30',
25
- 'hover:ring-primary',
26
- 'focus:ring-primary',
27
- ].join(' ');
4
+ const baseInputClassesMd = () => [
5
+ 'text-night',
6
+ 'w-full',
7
+ 'bg-surface',
8
+ 'focus:outline-none',
9
+ 'border-0',
10
+ 'ring-1',
11
+ 'ring-inset',
12
+ 'focus:ring-2',
13
+ 'disabled:ring-p-gray-30',
14
+ 'disabled:hover:ring-p-gray-30',
15
+ 'disabled:bg-p-blue-10',
16
+ 'disabled:cursor-default',
17
+ 'placeholder:text-p-gray-40',
18
+ 'h-10',
19
+ 'text-base',
20
+ 'rounded',
21
+ 'pl-4',
22
+ 'pr-4',
23
+ 'ring-p-gray-30',
24
+ 'hover:ring-primary',
25
+ 'focus:ring-primary',
26
+ ];
28
27
 
29
28
  const baseInputClassesSm = () => {
30
- return baseInputClasses()
31
- .replace('h-10', 'h-8')
32
- .replace('text-base', 'text-sm')
33
- .replace('pl-4', 'pl-3')
34
- .replace('pr-4', 'pr-3')
35
- .replace('rounded', 'rounded');
29
+ return baseInputClassesMd().map((item) => {
30
+ return (
31
+ {
32
+ 'h-10': 'h-8',
33
+ 'text-base': 'text-sm',
34
+ 'pl-4': 'pl-3',
35
+ 'pr-4': 'pr-3',
36
+ }[item] || item
37
+ );
38
+ });
36
39
  };
37
40
 
38
41
  const baseInputClassesLg = () => {
39
- return baseInputClasses()
40
- .replace('h-10', 'h-12')
41
- .replace('text-base', 'text-lg')
42
- .replace('pl-4', 'pl-5')
43
- .replace('pr-4', 'pr-5');
42
+ return baseInputClassesMd().map((item) => {
43
+ return (
44
+ {
45
+ 'h-10': 'h-12',
46
+ 'text-base': 'text-lg',
47
+ 'pl-4': 'pl-5',
48
+ 'pr-4': 'pr-5',
49
+ }[item] || item
50
+ );
51
+ });
44
52
  };
45
53
 
46
- const baseLabelClasses = 'block mb-1 font-medium text-sm';
54
+ const baseLabelClassesMd = ['block', 'mb-1', 'font-medium', 'text-sm'];
47
55
 
48
56
  const createWrapper = (opts) => {
49
57
  const TestComponent = {
@@ -60,93 +68,174 @@ describe('inputClassesMixin', () => {
60
68
  it('generates input classes md', () => {
61
69
  const wrapper = createWrapper({ props: { size: 'md' } });
62
70
 
63
- expect(wrapper.vm.inputClasses).toBe(baseInputClasses());
71
+ const inputClasses = wrapper.vm.inputClasses.split(' ');
72
+
73
+ expect(inputClasses).toEqual(expect.arrayContaining(baseInputClassesMd()));
64
74
  });
65
75
 
66
76
  it('generates input classes sm', () => {
67
77
  const wrapper = createWrapper({ props: { size: 'sm' } });
68
78
 
69
- expect(wrapper.vm.inputClasses).toBe(baseInputClassesSm());
79
+ const inputClasses = wrapper.vm.inputClasses.split(' ');
80
+
81
+ expect(inputClasses).toEqual(expect.arrayContaining(baseInputClassesSm()));
70
82
  });
71
83
 
72
84
  it('generates input classes lg', () => {
73
85
  const wrapper = createWrapper({ props: { size: 'lg' } });
74
86
 
75
- expect(wrapper.vm.inputClasses).toBe(baseInputClassesLg());
87
+ const inputClasses = wrapper.vm.inputClasses.split(' ');
88
+
89
+ expect(inputClasses).toEqual(expect.arrayContaining(baseInputClassesLg()));
76
90
  });
77
91
 
78
92
  it('generates label classes md', () => {
79
93
  const wrapper = createWrapper({ props: { size: 'md' } });
80
94
 
81
- expect(wrapper.vm.labelClasses).toBe(baseLabelClasses);
95
+ const labelClasses = wrapper.vm.labelClasses.split(' ');
96
+
97
+ expect(labelClasses).toEqual(expect.arrayContaining(baseLabelClassesMd));
82
98
  });
83
99
 
84
100
  it('generates label classes sm', () => {
85
101
  const wrapper = createWrapper({ props: { size: 'sm' } });
86
102
 
87
- expect(wrapper.vm.labelClasses).toBe(baseLabelClasses.replace('text-sm', 'text-xs'));
103
+ const labelClasses = wrapper.vm.labelClasses.split(' ');
104
+ const baseLabelClasses = baseLabelClassesMd.map((item) => {
105
+ return (
106
+ {
107
+ 'text-sm': 'text-xs',
108
+ }[item] || item
109
+ );
110
+ });
111
+
112
+ expect(labelClasses).toEqual(expect.arrayContaining(baseLabelClasses));
88
113
  });
89
114
 
90
115
  it('generates label classes lg', () => {
91
116
  const wrapper = createWrapper({ props: { size: 'lg' } });
92
117
 
93
- expect(wrapper.vm.labelClasses).toBe(baseLabelClasses.replace('text-sm', 'text-base'));
118
+ const labelClasses = wrapper.vm.labelClasses.split(' ');
119
+ const baseLabelClassesLg = baseLabelClassesMd.map((item) => {
120
+ return (
121
+ {
122
+ 'text-sm': 'text-base',
123
+ }[item] || item
124
+ );
125
+ });
126
+
127
+ expect(labelClasses).toEqual(expect.arrayContaining(baseLabelClassesLg));
94
128
  });
95
129
 
96
130
  it('generates select classes md', () => {
97
131
  const wrapper = createWrapper({ props: { size: 'md' } });
98
132
 
99
- expect(wrapper.vm.selectClasses).toBe(
100
- baseInputClasses().replace('pr-4 ', '') +
101
- ` truncate squirrel-bg-chevron-down bg-no-repeat appearance-none bg-[right_1rem_center] pr-10`
102
- );
133
+ const selectClasses = wrapper.vm.selectClasses.split(' ');
134
+ const baseInputClasses = baseInputClassesMd().filter((item) => {
135
+ return !['pr-4', 'bg-surface'].includes(item);
136
+ });
137
+ const baseSelectClasses = [
138
+ 'appearance-none',
139
+ 'bg-[position:right_1rem_center]',
140
+ 'bg-no-repeat',
141
+ 'pr-10',
142
+ 'squirrel-bg-chevron-down',
143
+ 'truncate',
144
+ ];
145
+
146
+ const res = baseInputClasses.concat(baseSelectClasses);
147
+
148
+ expect(selectClasses).toEqual(expect.arrayContaining(res));
103
149
  });
104
150
 
105
151
  it('generates select classes sm', () => {
106
152
  const wrapper = createWrapper({ props: { size: 'sm' } });
107
153
 
108
- expect(wrapper.vm.selectClasses).toBe(
109
- baseInputClassesSm().replace('pr-3 ', '') +
110
- ` truncate squirrel-bg-chevron-down bg-no-repeat appearance-none bg-[right_0.675rem_center] pr-8`
111
- );
154
+ const selectClasses = wrapper.vm.selectClasses.split(' ');
155
+ const baseInputClasses = baseInputClassesSm().filter((item) => {
156
+ return !['pr-3', 'bg-surface'].includes(item);
157
+ });
158
+ const baseSelectClasses = [
159
+ 'appearance-none',
160
+ 'bg-[position:right_0.675rem_center]',
161
+ 'bg-no-repeat',
162
+ 'pr-8',
163
+ 'squirrel-bg-chevron-down',
164
+ 'truncate',
165
+ ];
166
+ const res = baseInputClasses.concat(baseSelectClasses);
167
+
168
+ expect(selectClasses).toEqual(expect.arrayContaining(res));
112
169
  });
113
170
 
114
171
  it('generates select classes lg', () => {
115
172
  const wrapper = createWrapper({ props: { size: 'lg' } });
116
173
 
117
- expect(wrapper.vm.selectClasses).toBe(
118
- baseInputClassesLg().replace('pr-5 ', '') +
119
- ` truncate squirrel-bg-chevron-down bg-no-repeat appearance-none bg-[right_1.25rem_center] pr-12`
120
- );
174
+ const selectClasses = wrapper.vm.selectClasses.split(' ');
175
+ const baseInputClasses = baseInputClassesLg().filter((item) => {
176
+ return !['pr-5', 'bg-surface'].includes(item);
177
+ });
178
+ const baseSelectClasses = [
179
+ 'appearance-none',
180
+ 'bg-[position:right_1.25rem_center]',
181
+ 'bg-no-repeat',
182
+ 'pr-12',
183
+ 'squirrel-bg-chevron-down',
184
+ 'truncate',
185
+ ];
186
+ const res = baseInputClasses.concat(baseSelectClasses);
187
+
188
+ expect(selectClasses).toEqual(expect.arrayContaining(res));
121
189
  });
122
190
 
123
191
  it('generates textarea classes md', () => {
124
192
  const wrapper = createWrapper({ props: { size: 'md' } });
125
193
 
126
- expect(wrapper.vm.textareaClasses).toBe(baseInputClasses() + ' resize-y px-3 py-3 overflow-auto h-auto');
194
+ const textareaClasses = wrapper.vm.textareaClasses.split(' ');
195
+ const baseInputClasses = baseInputClassesMd().filter((item) => {
196
+ return !['pl-3', 'pr-3', 'h-10'].includes(item);
197
+ });
198
+ const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto']);
199
+
200
+ expect(textareaClasses).toEqual(expect.arrayContaining(res));
127
201
  });
128
202
 
129
203
  it('generates textarea classes sm', () => {
130
204
  const wrapper = createWrapper({ props: { size: 'sm' } });
131
205
 
132
- expect(wrapper.vm.textareaClasses).toBe(baseInputClassesSm() + ' resize-y px-3 py-3 overflow-auto h-auto');
206
+ const textareaClasses = wrapper.vm.textareaClasses.split(' ');
207
+ const baseInputClasses = baseInputClassesSm().filter((item) => {
208
+ return !['pr-3', 'pl-3', 'h-8', 'text-sm'].includes(item);
209
+ });
210
+ const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto', 'pr-4', 'pl-4']);
211
+
212
+ expect(textareaClasses).toEqual(expect.arrayContaining(res));
133
213
  });
134
214
 
135
215
  it('generates textarea classes lg', () => {
136
216
  const wrapper = createWrapper({ props: { size: 'lg' } });
137
217
 
138
- expect(wrapper.vm.textareaClasses).toBe(baseInputClassesLg() + ' resize-y px-3 py-3 overflow-auto h-auto');
218
+ const textareaClasses = wrapper.vm.textareaClasses.split(' ');
219
+ const baseInputClasses = baseInputClassesLg().filter((item) => {
220
+ return !['pr-5', 'pl-5', 'h-12', 'text-lg'].includes(item);
221
+ });
222
+ const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto', 'pr-4', 'pl-4']);
223
+
224
+ expect(textareaClasses).toEqual(expect.arrayContaining(res));
139
225
  });
140
226
 
141
227
  it('generates error classes', () => {
142
228
  const wrapper = createWrapper({ props: { size: 'md', errorMsg: 'Test error' } });
143
229
 
144
- expect(wrapper.vm.inputClasses).toBe(
145
- baseInputClasses().replace(
146
- 'ring-p-gray-30 hover:ring-primary focus:ring-primary',
147
- 'ring-on-error hover:ring-on-error focus:ring-on-error'
148
- )
149
- );
150
- expect(wrapper.vm.errorMsgClasses).toBe('text-xs text-on-error mt-1');
230
+ const inputClasses = wrapper.vm.inputClasses.split(' ');
231
+ const resInputClasses = baseInputClassesMd()
232
+ .filter((item) => {
233
+ return !['ring-p-gray-30', 'hover:ring-primary', 'focus:ring-primary'].includes(item);
234
+ })
235
+ .concat(['ring-on-error', 'hover:ring-on-error', 'focus:ring-on-error']);
236
+ const errorMsgClasses = wrapper.vm.errorMsgClasses.split(' ');
237
+
238
+ expect(inputClasses).toEqual(expect.arrayContaining(resInputClasses));
239
+ expect(errorMsgClasses).toEqual(expect.arrayContaining(['text-xs', 'text-on-error', 'mt-1']));
151
240
  });
152
241
  });