@pequity/squirrel 6.1.1 → 7.0.0

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 (94) hide show
  1. package/dist/cjs/chunks/p-alert.js +52 -0
  2. package/dist/cjs/chunks/p-avatar.js +65 -0
  3. package/dist/cjs/chunks/p-btn.js +1 -1
  4. package/dist/cjs/chunks/p-date-picker.js +2 -2
  5. package/dist/cjs/chunks/p-input-number.js +161 -0
  6. package/dist/cjs/chunks/p-input-percent.js +2 -2
  7. package/dist/cjs/chunks/p-input.js +111 -0
  8. package/dist/cjs/chunks/p-progress-bar.js +38 -0
  9. package/dist/cjs/chunks/p-textarea.js +89 -0
  10. package/dist/cjs/index.js +69 -76
  11. package/dist/cjs/inputClasses.js +8 -2
  12. package/dist/cjs/p-alert.js +2 -64
  13. package/dist/cjs/p-avatar.js +2 -70
  14. package/dist/cjs/p-drawer.js +2 -2
  15. package/dist/cjs/p-input-number.js +2 -145
  16. package/dist/cjs/p-input-search.js +2 -2
  17. package/dist/cjs/p-input.js +2 -92
  18. package/dist/cjs/p-modal.js +2 -2
  19. package/dist/cjs/p-progress-bar.js +2 -40
  20. package/dist/cjs/p-table-filter-icon.js +14 -9
  21. package/dist/cjs/p-textarea.js +2 -72
  22. package/dist/cjs/p-toggle.js +76 -64
  23. package/dist/cjs/useInputClasses.js +13 -18
  24. package/dist/es/chunks/p-alert.js +53 -0
  25. package/dist/es/chunks/p-avatar.js +66 -0
  26. package/dist/es/chunks/p-btn.js +1 -1
  27. package/dist/es/chunks/p-date-picker.js +2 -2
  28. package/dist/es/chunks/p-input-number.js +162 -0
  29. package/dist/es/chunks/p-input-percent.js +2 -2
  30. package/dist/es/chunks/p-input.js +112 -0
  31. package/dist/es/chunks/p-progress-bar.js +39 -0
  32. package/dist/es/chunks/p-textarea.js +90 -0
  33. package/dist/es/index.js +119 -126
  34. package/dist/es/inputClasses.js +8 -2
  35. package/dist/es/p-alert.js +2 -64
  36. package/dist/es/p-avatar.js +2 -70
  37. package/dist/es/p-drawer.js +2 -2
  38. package/dist/es/p-input-number.js +2 -145
  39. package/dist/es/p-input-search.js +2 -2
  40. package/dist/es/p-input.js +2 -92
  41. package/dist/es/p-modal.js +2 -2
  42. package/dist/es/p-progress-bar.js +2 -40
  43. package/dist/es/p-table-filter-icon.js +14 -9
  44. package/dist/es/p-textarea.js +2 -72
  45. package/dist/es/p-toggle.js +77 -65
  46. package/dist/es/useInputClasses.js +14 -19
  47. package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +27 -10
  48. package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +9 -10
  49. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +7 -7
  50. package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +2 -2
  51. package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +37 -13
  52. package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +2 -2
  53. package/dist/squirrel/components/p-input/p-input.vue.d.ts +30 -61
  54. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +101 -65
  55. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +113 -83
  56. package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +2 -2
  57. package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +5 -20
  58. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +1 -1
  59. package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +1 -1
  60. package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +3 -7
  61. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +79 -42
  62. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +25 -62
  63. package/dist/squirrel/composables/useInputClasses.d.ts +2 -1
  64. package/dist/squirrel/utils/index.d.ts +1 -3
  65. package/dist/squirrel/utils/inputClasses.d.ts +12 -0
  66. package/dist/squirrel.css +5 -5
  67. package/package.json +18 -18
  68. package/squirrel/components/p-alert/p-alert.spec.js +9 -8
  69. package/squirrel/components/p-alert/p-alert.vue +19 -31
  70. package/squirrel/components/p-avatar/p-avatar.spec.ts +10 -3
  71. package/squirrel/components/p-avatar/p-avatar.vue +40 -42
  72. package/squirrel/components/p-btn/p-btn.spec.js +1 -3
  73. package/squirrel/components/p-btn/p-btn.vue +1 -1
  74. package/squirrel/components/p-input/p-input.vue +63 -40
  75. package/squirrel/components/p-input-number/p-input-number.vue +101 -86
  76. package/squirrel/components/p-progress-bar/p-progress-bar.vue +9 -14
  77. package/squirrel/components/p-table-header-cell/p-table-filter-icon.vue +8 -9
  78. package/squirrel/components/p-table-sort/p-table-sort.vue +13 -16
  79. package/squirrel/components/p-textarea/p-textarea.vue +55 -37
  80. package/squirrel/components/p-toggle/p-toggle.vue +59 -43
  81. package/squirrel/composables/useInputClasses.spec.js +50 -13
  82. package/squirrel/composables/useInputClasses.ts +18 -24
  83. package/squirrel/utils/index.ts +0 -7
  84. package/squirrel/utils/inputClasses.ts +8 -2
  85. package/dist/cjs/inputClassesMixin.js +0 -58
  86. package/dist/cjs/tailwind.js +0 -25
  87. package/dist/es/inputClassesMixin.js +0 -59
  88. package/dist/es/tailwind.js +0 -25
  89. package/dist/squirrel/utils/inputClassesMixin.d.ts +0 -56
  90. package/dist/squirrel/utils/tailwind.d.ts +0 -8
  91. package/squirrel/utils/inputClassesMixin.spec.js +0 -241
  92. package/squirrel/utils/inputClassesMixin.ts +0 -60
  93. package/squirrel/utils/tailwind.spec.js +0 -27
  94. package/squirrel/utils/tailwind.ts +0 -28
@@ -18,12 +18,13 @@
18
18
  </div>
19
19
  </template>
20
20
 
21
- <script lang="ts">
21
+ <script setup lang="ts">
22
+ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
22
23
  import PInfoIcon from '@squirrel/components/p-info-icon/p-info-icon.vue';
23
- import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
24
+ import { useInputClasses } from '@squirrel/composables/useInputClasses';
24
25
  import { toNumberOrNull } from '@squirrel/utils/number';
25
26
  import { kebabCase } from 'lodash-es';
26
- import { computed, defineComponent, type PropType, type StyleValue, watch } from 'vue';
27
+ import { computed, type PropType, type StyleValue, useAttrs, useSlots, watch } from 'vue';
27
28
  import { type CurrencyDisplay, type CurrencyInputOptions, useCurrencyInput } from 'vue-currency-input';
28
29
 
29
30
  const ALL_OPTIONS = [
@@ -40,93 +41,107 @@ const ALL_OPTIONS = [
40
41
  'valueScaling',
41
42
  ];
42
43
 
43
- export default defineComponent({
44
+ defineOptions({
44
45
  name: 'PInputNumber',
45
- components: {
46
- PInfoIcon,
47
- },
48
- mixins: [inputClassesMixin],
49
46
  inheritAttrs: false,
50
- props: {
51
- modelValue: {
52
- type: [Number, String] as PropType<number | string | null | undefined>,
53
- default: null,
54
- },
55
- label: {
56
- type: String,
57
- default: '',
58
- },
59
- errorMsg: {
60
- type: String,
61
- default: '',
62
- },
63
- required: {
64
- type: Boolean,
65
- default: false,
66
- },
67
- selectOnClick: {
68
- type: Boolean,
69
- default: true,
70
- },
71
- tooltipText: {
72
- type: String,
73
- default: '',
47
+ });
48
+
49
+ const emit = defineEmits(['update:modelValue', 'change']);
50
+
51
+ const props = defineProps({
52
+ modelValue: {
53
+ type: [Number, String] as PropType<number | string | null | undefined>,
54
+ default: null,
55
+ },
56
+ label: {
57
+ type: String,
58
+ default: '',
59
+ },
60
+ errorMsg: {
61
+ type: String,
62
+ default: '',
63
+ },
64
+ required: {
65
+ type: Boolean,
66
+ default: false,
67
+ },
68
+ size: {
69
+ type: String as PropType<Size>,
70
+ default: 'md',
71
+ validator(value: Size) {
72
+ return SIZES.includes(value);
74
73
  },
75
74
  },
76
- emits: ['update:modelValue', 'change'],
77
- setup(props, { attrs, emit, expose }) {
78
- const DEFAULTS: CurrencyInputOptions & Record<string, unknown> = {
79
- locale: 'en-US',
80
- currency: 'USD',
81
- precision: 0,
82
- currencyDisplay: 'hidden' as CurrencyDisplay,
83
- };
84
-
85
- const inputCurrencyOptions = computed(() => {
86
- ALL_OPTIONS.forEach((key) => {
87
- const attr = attrs[kebabCase(key)];
88
-
89
- if (attr && typeof attr !== 'undefined') {
90
- DEFAULTS[key] = attr;
91
- }
92
- });
93
-
94
- return DEFAULTS;
95
- });
96
-
97
- const { inputRef, numberValue, setValue } = useCurrencyInput(
98
- inputCurrencyOptions.value as unknown as CurrencyInputOptions,
99
- false
100
- );
101
-
102
- watch(numberValue, (value) => {
103
- emit('update:modelValue', toNumberOrNull(value));
104
- });
105
-
106
- watch(
107
- () => props.modelValue,
108
- (value) => {
109
- setValue(toNumberOrNull(value));
110
- }
111
- );
112
-
113
- const computedAttrs = computed(() => {
114
- const { class: classes, style, ...rest } = attrs;
115
-
116
- return rest;
117
- });
118
-
119
- const style = computed(() => {
120
- return attrs.style as StyleValue;
121
- });
122
-
123
- const focus = () => {
124
- props.selectOnClick && inputRef.value.select();
125
- };
126
-
127
- expose({ setValue });
128
-
129
- return { inputRef, computedAttrs, style, focus };
75
+ selectOnClick: {
76
+ type: Boolean,
77
+ default: true,
78
+ },
79
+ tooltipText: {
80
+ type: String,
81
+ default: '',
130
82
  },
131
83
  });
84
+
85
+ const slots = useSlots();
86
+
87
+ const { labelClasses, inputClasses, errorMsgClasses } = useInputClasses(
88
+ computed(() => ({
89
+ ...props,
90
+ prefix: !!slots.prefix,
91
+ suffix: !!slots.suffix,
92
+ }))
93
+ );
94
+
95
+ const attrs = useAttrs();
96
+
97
+ const DEFAULTS: CurrencyInputOptions & Record<string, unknown> = {
98
+ locale: 'en-US',
99
+ currency: 'USD',
100
+ precision: 0,
101
+ currencyDisplay: 'hidden' as CurrencyDisplay,
102
+ };
103
+
104
+ const inputCurrencyOptions = computed(() => {
105
+ ALL_OPTIONS.forEach((key) => {
106
+ const attr = attrs[kebabCase(key)];
107
+
108
+ if (attr && typeof attr !== 'undefined') {
109
+ DEFAULTS[key] = attr;
110
+ }
111
+ });
112
+
113
+ return DEFAULTS;
114
+ });
115
+
116
+ const { inputRef, numberValue, setValue } = useCurrencyInput(
117
+ inputCurrencyOptions.value as unknown as CurrencyInputOptions,
118
+ false
119
+ );
120
+
121
+ watch(numberValue, (value) => {
122
+ emit('update:modelValue', toNumberOrNull(value));
123
+ });
124
+
125
+ watch(
126
+ () => props.modelValue,
127
+ (value) => {
128
+ setValue(toNumberOrNull(value));
129
+ }
130
+ );
131
+
132
+ const computedAttrs = computed(() => {
133
+ const { class: classes, style, ...rest } = attrs;
134
+
135
+ return rest;
136
+ });
137
+
138
+ const style = computed(() => {
139
+ return attrs.style as StyleValue;
140
+ });
141
+
142
+ const focus = () => {
143
+ props.selectOnClick && inputRef.value.select();
144
+ };
145
+
146
+ defineExpose({ setValue });
132
147
  </script>
@@ -10,26 +10,21 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script lang="ts">
14
- import { defineComponent, type PropType } from 'vue';
15
-
13
+ <script setup lang="ts">
16
14
  export type ProgressItem = {
17
15
  value: number;
18
16
  color: string;
19
17
  label?: string;
20
18
  };
21
19
 
22
- export default defineComponent({
20
+ type Props = {
21
+ total: number;
22
+ items: ProgressItem[];
23
+ };
24
+
25
+ defineOptions({
23
26
  name: 'PProgressBar',
24
- props: {
25
- total: {
26
- type: Number as PropType<number>,
27
- required: true,
28
- },
29
- items: {
30
- type: Array as PropType<ProgressItem[]>,
31
- required: true,
32
- },
33
- },
34
27
  });
28
+
29
+ defineProps<Props>();
35
30
  </script>
@@ -2,17 +2,16 @@
2
2
  <div :class="['h-5 w-5 shrink-0 cursor-pointer filter', { active: active }]" v-bind="$attrs"></div>
3
3
  </template>
4
4
 
5
- <script lang="ts">
6
- import { defineComponent } from 'vue';
7
-
8
- export default defineComponent({
5
+ <script setup lang="ts">
6
+ defineOptions({
9
7
  name: 'PTableFilterIcon',
10
8
  inheritAttrs: false,
11
- props: {
12
- active: {
13
- type: Boolean,
14
- default: false,
15
- },
9
+ });
10
+
11
+ defineProps({
12
+ active: {
13
+ type: Boolean,
14
+ default: false,
16
15
  },
17
16
  });
18
17
  </script>
@@ -55,26 +55,23 @@
55
55
  </div>
56
56
  </template>
57
57
 
58
- <script lang="ts">
58
+ <script setup lang="ts">
59
59
  import { SORTING_TYPES, type SortingType } from '@squirrel/components/p-table-sort/p-table-sort.config';
60
- import { defineComponent, type PropType } from 'vue';
60
+ import { type PropType } from 'vue';
61
61
 
62
- export default defineComponent({
62
+ defineOptions({
63
63
  name: 'PTableSort',
64
- props: {
65
- modelValue: {
66
- type: String as PropType<SortingType>,
67
- default: SORTING_TYPES.NO_SORTING,
68
- validator(value: SortingType) {
69
- return Object.values(SORTING_TYPES).includes(value);
70
- },
64
+ });
65
+
66
+ defineEmits(['update:modelValue']);
67
+
68
+ defineProps({
69
+ modelValue: {
70
+ type: String as PropType<SortingType>,
71
+ default: SORTING_TYPES.NO_SORTING,
72
+ validator(value: SortingType) {
73
+ return Object.values(SORTING_TYPES).includes(value);
71
74
  },
72
75
  },
73
- emits: ['update:modelValue'],
74
- data() {
75
- return {
76
- SORTING_TYPES,
77
- };
78
- },
79
76
  });
80
77
  </script>
@@ -10,49 +10,67 @@
10
10
  </div>
11
11
  </template>
12
12
 
13
- <script lang="ts">
14
- import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
15
- import { defineComponent, type StyleValue } from 'vue';
13
+ <script setup lang="ts">
14
+ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
15
+ import { useInputClasses } from '@squirrel/composables/useInputClasses';
16
+ import { computed, type PropType, type StyleValue, useAttrs } from 'vue';
16
17
 
17
- export default defineComponent({
18
+ defineOptions({
18
19
  name: 'PTextarea',
19
- mixins: [inputClassesMixin],
20
20
  inheritAttrs: false,
21
- props: {
22
- modelValue: {
23
- type: [String, Number],
24
- default: '',
25
- },
26
- label: {
27
- type: String,
28
- default: '',
29
- },
30
- errorMsg: {
31
- type: String,
32
- default: '',
33
- },
34
- required: {
35
- type: Boolean,
36
- default: false,
37
- },
38
- },
39
- emits: ['update:modelValue'],
40
- computed: {
41
- attrs() {
42
- const { class: classes, style, ...rest } = this.$attrs;
21
+ });
43
22
 
44
- return rest;
45
- },
46
- style() {
47
- return this.$attrs.style as StyleValue;
48
- },
49
- },
50
- methods: {
51
- updateValue(e: Event): void {
52
- const target = e.target as HTMLInputElement;
23
+ const emit = defineEmits(['update:modelValue']);
53
24
 
54
- this.$emit('update:modelValue', target.value);
25
+ const props = defineProps({
26
+ modelValue: {
27
+ type: [String, Number, null] as PropType<string | number | null>,
28
+ default: '',
29
+ },
30
+ label: {
31
+ type: String,
32
+ default: '',
33
+ },
34
+ errorMsg: {
35
+ type: String,
36
+ default: '',
37
+ },
38
+ required: {
39
+ type: Boolean,
40
+ default: false,
41
+ },
42
+ size: {
43
+ type: String as PropType<Size>,
44
+ default: 'md',
45
+ validator(value: Size) {
46
+ return SIZES.includes(value);
55
47
  },
56
48
  },
57
49
  });
50
+
51
+ const { labelClasses, textareaClasses, errorMsgClasses } = useInputClasses(
52
+ computed(() => ({
53
+ required: props.required,
54
+ errorMsg: props.errorMsg,
55
+ size: props.size,
56
+ }))
57
+ );
58
+
59
+ const allAttrs = useAttrs();
60
+
61
+ const attrs = computed(() => {
62
+ const { class: classes, style, ...rest } = allAttrs;
63
+
64
+ return rest;
65
+ });
66
+
67
+ const style = computed(() => {
68
+ return allAttrs.style as StyleValue;
69
+ });
70
+
71
+ const updateValue = (e: Event) => {
72
+ const target = e.target as HTMLInputElement;
73
+
74
+ emit('update:modelValue', target.value);
75
+ };
58
76
  </script>
@@ -25,8 +25,9 @@
25
25
  </template>
26
26
 
27
27
  <script lang="ts">
28
- import inputClassesMixin from '@squirrel/utils/inputClassesMixin';
29
- import { defineComponent, type StyleValue } from 'vue';
28
+ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
29
+ import { useInputClasses } from '@squirrel/composables/useInputClasses';
30
+ import { computed, type PropType, type StyleValue, useAttrs } from 'vue';
30
31
 
31
32
  const TOGGLE_SIZES = {
32
33
  sm: `w-7 h-4 after:top-[2px] after:left-[2px] after:h-3 after:w-3`,
@@ -52,56 +53,71 @@ const TOGGLE_CLASSES = [
52
53
  'peer-disabled:bg-p-blue-10',
53
54
  'peer-disabled:after:border-p-blue-10',
54
55
  ].join(' ');
56
+ </script>
55
57
 
56
- export default defineComponent({
58
+ <script setup lang="ts">
59
+ defineOptions({
57
60
  name: 'PToggle',
58
- mixins: [inputClassesMixin],
59
61
  inheritAttrs: false,
60
- props: {
61
- modelValue: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- label: {
66
- type: String,
67
- default: '',
68
- },
69
- errorMsg: {
70
- type: String,
71
- default: '',
72
- },
73
- required: {
74
- type: Boolean,
75
- default: false,
76
- },
77
- },
78
- emits: ['update:modelValue'],
79
- computed: {
80
- toggleClasses() {
81
- const base = `${TOGGLE_CLASSES} ${TOGGLE_SIZES[this.size]}`;
82
- const res = this.errorMsg ? `${base} border border-on-error` : base;
62
+ });
83
63
 
84
- return res;
85
- },
86
- toggleLabelClasses() {
87
- return `${this.labelClasses.replace('mb-1', '')} ml-2`;
88
- },
89
- attrs() {
90
- const { style, class: classes, 'data-testid': dataTestId, ...rest } = this.$attrs;
64
+ const emit = defineEmits(['update:modelValue']);
91
65
 
92
- return rest;
93
- },
94
- style() {
95
- return this.$attrs.style as StyleValue;
96
- },
66
+ const props = defineProps({
67
+ modelValue: {
68
+ type: Boolean,
69
+ default: false,
70
+ },
71
+ label: {
72
+ type: String,
73
+ default: '',
74
+ },
75
+ errorMsg: {
76
+ type: String,
77
+ default: '',
78
+ },
79
+ required: {
80
+ type: Boolean,
81
+ default: false,
97
82
  },
98
- methods: {
99
- change(e: Event) {
100
- const target = e.target as HTMLInputElement;
101
- this.$emit('update:modelValue', target.checked);
83
+ size: {
84
+ type: String as PropType<Size>,
85
+ default: 'md',
86
+ validator(value: Size) {
87
+ return SIZES.includes(value);
102
88
  },
103
89
  },
104
90
  });
91
+
92
+ const allAttrs = useAttrs();
93
+ const { labelClasses, errorMsgClasses } = useInputClasses(props);
94
+
95
+ const toggleClasses = computed(() => {
96
+ const base = `${TOGGLE_CLASSES} ${TOGGLE_SIZES[props.size]}`;
97
+ const res = props.errorMsg ? `${base} border border-on-error` : base;
98
+
99
+ return res;
100
+ });
101
+
102
+ const toggleLabelClasses = computed(() => {
103
+ return `${labelClasses.value.replace('mb-1', '')} ml-2`;
104
+ });
105
+
106
+ const attrs = computed(() => {
107
+ const { style, class: classes, 'data-testid': dataTestId, ...rest } = allAttrs;
108
+
109
+ return rest;
110
+ });
111
+
112
+ const style = computed(() => {
113
+ return allAttrs.style as StyleValue;
114
+ });
115
+
116
+ const change = (e: Event) => {
117
+ const target = e.target as HTMLInputElement;
118
+
119
+ emit('update:modelValue', target.checked);
120
+ };
105
121
  </script>
106
122
 
107
123
  <style scoped>
@@ -1,5 +1,6 @@
1
1
  import { useInputClasses } from '@squirrel/composables/useInputClasses';
2
- import { reactive } from 'vue';
2
+ import { expect } from '@storybook/test';
3
+ import { reactive, ref } from 'vue';
3
4
 
4
5
  const baseInputClassesMd = () => [
5
6
  'text-night',
@@ -54,6 +55,42 @@ const baseInputClassesLg = () => {
54
55
  const baseLabelClassesMd = ['block', 'mb-1', 'font-medium', 'text-sm'];
55
56
 
56
57
  describe('useInputClasses', () => {
58
+ it('accepts a non-reactive object', () => {
59
+ const props = { size: 'lg' };
60
+
61
+ const { inputClasses, labelClasses, selectClasses, textareaClasses, errorMsgClasses } = useInputClasses(props);
62
+
63
+ expect(inputClasses.value).toContain('text-lg');
64
+ expect(labelClasses.value).toContain('text-base');
65
+ expect(selectClasses.value).toContain('text-lg');
66
+ expect(textareaClasses.value).toContain('text-lg');
67
+ expect(errorMsgClasses.value).toContain('text-on-error');
68
+ });
69
+
70
+ it('reacts to changes when props is a reactive object', () => {
71
+ const props = reactive({ size: 'md' });
72
+
73
+ const { inputClasses } = useInputClasses(props);
74
+
75
+ expect(inputClasses.value).toContain('text-base');
76
+
77
+ props.size = 'lg';
78
+
79
+ expect(inputClasses.value).toContain('text-lg');
80
+ });
81
+
82
+ it('reacts to changes when props is a ref', () => {
83
+ const props = ref({ size: 'md' });
84
+
85
+ const { inputClasses } = useInputClasses(props);
86
+
87
+ expect(inputClasses.value).toContain('text-base');
88
+
89
+ props.value.size = 'lg';
90
+
91
+ expect(inputClasses.value).toContain('text-lg');
92
+ });
93
+
57
94
  it('generates input classes md', () => {
58
95
  const props = reactive({ size: 'md' });
59
96
 
@@ -177,26 +214,26 @@ describe('useInputClasses', () => {
177
214
  expect(selectClasses.value.split(' ')).toEqual(expect.arrayContaining(res));
178
215
  });
179
216
 
180
- it('generates textarea classes md', () => {
181
- const props = reactive({ size: 'md' });
217
+ it('generates textarea classes sm', () => {
218
+ const props = reactive({ size: 'sm' });
182
219
 
183
220
  const { textareaClasses } = useInputClasses(props);
184
- const baseInputClasses = baseInputClassesMd().filter((item) => {
185
- return !['pl-3', 'pr-3', 'h-10'].includes(item);
221
+ const baseInputClasses = baseInputClassesSm().filter((item) => {
222
+ return !['pl-3', 'pr-3', 'h-8'].includes(item);
186
223
  });
187
- const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto']);
224
+ const res = baseInputClasses.concat(['resize-y', 'py-2', 'overflow-auto', 'h-auto']);
188
225
 
189
226
  expect(textareaClasses.value.split(' ')).toEqual(expect.arrayContaining(res));
190
227
  });
191
228
 
192
- it('generates textarea classes sm', () => {
193
- const props = reactive({ size: 'sm' });
229
+ it('generates textarea classes md', () => {
230
+ const props = reactive({ size: 'md' });
194
231
 
195
232
  const { textareaClasses } = useInputClasses(props);
196
- const baseInputClasses = baseInputClassesSm().filter((item) => {
197
- return !['pr-3', 'pl-3', 'h-8', 'text-sm'].includes(item);
233
+ const baseInputClasses = baseInputClassesMd().filter((item) => {
234
+ return !['pl-4', 'pr-4', 'h-10'].includes(item);
198
235
  });
199
- const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto', 'pr-4', 'pl-4']);
236
+ const res = baseInputClasses.concat(['resize-y', 'py-3', 'overflow-auto', 'h-auto']);
200
237
 
201
238
  expect(textareaClasses.value.split(' ')).toEqual(expect.arrayContaining(res));
202
239
  });
@@ -206,9 +243,9 @@ describe('useInputClasses', () => {
206
243
 
207
244
  const { textareaClasses } = useInputClasses(props);
208
245
  const baseInputClasses = baseInputClassesLg().filter((item) => {
209
- return !['pr-5', 'pl-5', 'h-12', 'text-lg'].includes(item);
246
+ return !['pr-5', 'pl-5', 'h-12'].includes(item);
210
247
  });
211
- const res = baseInputClasses.concat(['resize-y', 'px-3', 'py-3', 'overflow-auto', 'h-auto', 'pr-4', 'pl-4']);
248
+ const res = baseInputClasses.concat(['resize-y', 'py-4', 'overflow-auto', 'h-auto']);
212
249
 
213
250
  expect(textareaClasses.value.split(' ')).toEqual(expect.arrayContaining(res));
214
251
  });