@pequity/squirrel 6.1.1 → 7.0.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.
- package/dist/cjs/chunks/index.js +748 -504
- package/dist/cjs/chunks/p-alert.js +52 -0
- package/dist/cjs/chunks/p-avatar.js +65 -0
- package/dist/cjs/chunks/p-btn.js +2 -2
- package/dist/cjs/chunks/p-date-picker.js +2 -2
- package/dist/cjs/chunks/p-input-number.js +161 -0
- package/dist/cjs/chunks/p-input-percent.js +2 -2
- package/dist/cjs/chunks/p-input.js +111 -0
- package/dist/cjs/chunks/p-progress-bar.js +38 -0
- package/dist/cjs/chunks/p-textarea.js +89 -0
- package/dist/cjs/index.js +69 -76
- package/dist/cjs/inputClasses.js +8 -2
- package/dist/cjs/p-alert.js +2 -64
- package/dist/cjs/p-avatar.js +2 -70
- package/dist/cjs/p-drawer.js +2 -2
- package/dist/cjs/p-input-number.js +2 -145
- package/dist/cjs/p-input-search.js +2 -2
- package/dist/cjs/p-input.js +2 -92
- package/dist/cjs/p-modal.js +2 -2
- package/dist/cjs/p-progress-bar.js +2 -40
- package/dist/cjs/p-table-filter-icon.js +14 -9
- package/dist/cjs/p-textarea.js +2 -72
- package/dist/cjs/p-toggle.js +76 -64
- package/dist/cjs/useInputClasses.js +13 -18
- package/dist/es/chunks/index.js +748 -504
- package/dist/es/chunks/p-alert.js +53 -0
- package/dist/es/chunks/p-avatar.js +66 -0
- package/dist/es/chunks/p-btn.js +2 -2
- package/dist/es/chunks/p-date-picker.js +2 -2
- package/dist/es/chunks/p-input-number.js +162 -0
- package/dist/es/chunks/p-input-percent.js +2 -2
- package/dist/es/chunks/p-input.js +112 -0
- package/dist/es/chunks/p-progress-bar.js +39 -0
- package/dist/es/chunks/p-textarea.js +90 -0
- package/dist/es/index.js +119 -126
- package/dist/es/inputClasses.js +8 -2
- package/dist/es/p-alert.js +2 -64
- package/dist/es/p-avatar.js +2 -70
- package/dist/es/p-drawer.js +2 -2
- package/dist/es/p-input-number.js +2 -145
- package/dist/es/p-input-search.js +2 -2
- package/dist/es/p-input.js +2 -92
- package/dist/es/p-modal.js +2 -2
- package/dist/es/p-progress-bar.js +2 -40
- package/dist/es/p-table-filter-icon.js +14 -9
- package/dist/es/p-textarea.js +2 -72
- package/dist/es/p-toggle.js +77 -65
- package/dist/es/useInputClasses.js +14 -19
- package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +27 -10
- package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +9 -10
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +8 -248
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +2 -2
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +37 -13
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +2 -2
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +30 -61
- package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +101 -65
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +113 -83
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +2 -2
- package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +5 -20
- package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +3 -7
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +79 -42
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +25 -62
- package/dist/squirrel/composables/useInputClasses.d.ts +2 -1
- package/dist/squirrel/utils/index.d.ts +1 -3
- package/dist/squirrel/utils/inputClasses.d.ts +9 -525
- package/dist/squirrel.css +5 -5
- package/package.json +28 -28
- package/squirrel/components/p-alert/p-alert.spec.js +9 -8
- package/squirrel/components/p-alert/p-alert.vue +19 -31
- package/squirrel/components/p-avatar/p-avatar.spec.ts +10 -3
- package/squirrel/components/p-avatar/p-avatar.vue +40 -42
- package/squirrel/components/p-btn/p-btn.spec.js +2 -3
- package/squirrel/components/p-btn/p-btn.vue +2 -2
- package/squirrel/components/p-input/p-input.vue +63 -40
- package/squirrel/components/p-input-number/p-input-number.vue +101 -86
- package/squirrel/components/p-progress-bar/p-progress-bar.vue +9 -14
- package/squirrel/components/p-table-header-cell/p-table-filter-icon.vue +8 -9
- package/squirrel/components/p-table-sort/p-table-sort.vue +13 -16
- package/squirrel/components/p-textarea/p-textarea.vue +55 -37
- package/squirrel/components/p-toggle/p-toggle.vue +59 -43
- package/squirrel/composables/useInputClasses.spec.js +50 -13
- package/squirrel/composables/useInputClasses.ts +18 -24
- package/squirrel/utils/index.ts +0 -7
- package/squirrel/utils/inputClasses.ts +8 -2
- package/dist/cjs/inputClassesMixin.js +0 -58
- package/dist/cjs/tailwind.js +0 -25
- package/dist/es/inputClassesMixin.js +0 -59
- package/dist/es/tailwind.js +0 -25
- package/dist/squirrel/utils/inputClassesMixin.d.ts +0 -56
- package/dist/squirrel/utils/tailwind.d.ts +0 -8
- package/squirrel/utils/inputClassesMixin.spec.js +0 -241
- package/squirrel/utils/inputClassesMixin.ts +0 -60
- package/squirrel/utils/tailwind.spec.js +0 -27
- package/squirrel/utils/tailwind.ts +0 -28
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pequity/squirrel",
|
|
3
3
|
"description": "Squirrel component library",
|
|
4
|
-
"version": "
|
|
5
|
-
"packageManager": "pnpm@9.15.
|
|
4
|
+
"version": "7.0.1",
|
|
5
|
+
"packageManager": "pnpm@9.15.9",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -48,37 +48,37 @@
|
|
|
48
48
|
"vue-toastification": "^2.0.0-rc.5"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@commitlint/cli": "^19.
|
|
52
|
-
"@commitlint/config-conventional": "^19.
|
|
51
|
+
"@commitlint/cli": "^19.8.0",
|
|
52
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
53
53
|
"@pequity/eslint-config": "^1.1.1",
|
|
54
|
-
"@playwright/test": "^1.
|
|
54
|
+
"@playwright/test": "^1.51.0",
|
|
55
55
|
"@semantic-release/changelog": "^6.0.3",
|
|
56
56
|
"@semantic-release/git": "^10.0.1",
|
|
57
|
-
"@storybook/addon-a11y": "^8.6.
|
|
58
|
-
"@storybook/addon-actions": "^8.6.
|
|
59
|
-
"@storybook/addon-essentials": "^8.6.
|
|
60
|
-
"@storybook/addon-interactions": "^8.6.
|
|
61
|
-
"@storybook/addon-links": "^8.6.
|
|
62
|
-
"@storybook/blocks": "^8.6.
|
|
63
|
-
"@storybook/manager-api": "^8.6.
|
|
64
|
-
"@storybook/test": "^8.6.
|
|
65
|
-
"@storybook/test-runner": "^0.
|
|
66
|
-
"@storybook/theming": "^8.6.
|
|
67
|
-
"@storybook/vue3": "^8.6.
|
|
68
|
-
"@storybook/vue3-vite": "^8.6.
|
|
57
|
+
"@storybook/addon-a11y": "^8.6.4",
|
|
58
|
+
"@storybook/addon-actions": "^8.6.4",
|
|
59
|
+
"@storybook/addon-essentials": "^8.6.4",
|
|
60
|
+
"@storybook/addon-interactions": "^8.6.4",
|
|
61
|
+
"@storybook/addon-links": "^8.6.4",
|
|
62
|
+
"@storybook/blocks": "^8.6.4",
|
|
63
|
+
"@storybook/manager-api": "^8.6.4",
|
|
64
|
+
"@storybook/test": "^8.6.4",
|
|
65
|
+
"@storybook/test-runner": "^0.22.0",
|
|
66
|
+
"@storybook/theming": "^8.6.4",
|
|
67
|
+
"@storybook/vue3": "^8.6.4",
|
|
68
|
+
"@storybook/vue3-vite": "^8.6.4",
|
|
69
69
|
"@tanstack/vue-virtual": "3.13.2",
|
|
70
70
|
"@types/jsdom": "^21.1.7",
|
|
71
71
|
"@types/lodash-es": "^4.17.12",
|
|
72
|
-
"@types/node": "^22.13.
|
|
72
|
+
"@types/node": "^22.13.10",
|
|
73
73
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
74
|
-
"@vitest/coverage-v8": "^3.0.
|
|
74
|
+
"@vitest/coverage-v8": "^3.0.8",
|
|
75
75
|
"@vue/compiler-sfc": "3.5.13",
|
|
76
76
|
"@vue/test-utils": "^2.4.6",
|
|
77
77
|
"@vuepic/vue-datepicker": "11.0.1",
|
|
78
|
-
"autoprefixer": "^10.4.
|
|
78
|
+
"autoprefixer": "^10.4.21",
|
|
79
79
|
"dayjs": "1.11.13",
|
|
80
|
-
"eslint": "^9.
|
|
81
|
-
"eslint-plugin-storybook": "^0.11.
|
|
80
|
+
"eslint": "^9.22.0",
|
|
81
|
+
"eslint-plugin-storybook": "^0.11.4",
|
|
82
82
|
"floating-vue": "5.2.2",
|
|
83
83
|
"glob": "^11.0.1",
|
|
84
84
|
"husky": "^9.1.7",
|
|
@@ -88,25 +88,25 @@
|
|
|
88
88
|
"lodash-es": "4.17.21",
|
|
89
89
|
"make-coverage-badge": "^1.2.0",
|
|
90
90
|
"postcss": "^8.5.3",
|
|
91
|
-
"prettier": "^3.5.
|
|
91
|
+
"prettier": "^3.5.3",
|
|
92
92
|
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
93
93
|
"resolve-tspaths": "^0.8.23",
|
|
94
94
|
"rimraf": "^6.0.1",
|
|
95
95
|
"sass": "^1.85.1",
|
|
96
96
|
"semantic-release": "^24.2.3",
|
|
97
|
-
"storybook": "^8.6.
|
|
97
|
+
"storybook": "^8.6.4",
|
|
98
98
|
"svgo": "^3.3.2",
|
|
99
99
|
"tailwindcss": "^3.4.17",
|
|
100
100
|
"typescript": "5.7.3",
|
|
101
|
-
"vite": "^6.2.
|
|
102
|
-
"vitest": "^3.0.
|
|
101
|
+
"vite": "^6.2.1",
|
|
102
|
+
"vitest": "^3.0.8",
|
|
103
103
|
"vue": "3.5.13",
|
|
104
104
|
"vue-currency-input": "3.2.1",
|
|
105
105
|
"vue-router": "4.5.0",
|
|
106
106
|
"vue-toastification": "2.0.0-rc.5",
|
|
107
|
-
"vue-tsc": "2.2.
|
|
107
|
+
"vue-tsc": "2.2.8"
|
|
108
108
|
},
|
|
109
109
|
"dependencies": {
|
|
110
|
-
"tailwind-variants": "^0.
|
|
110
|
+
"tailwind-variants": "^1.0.0"
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -3,18 +3,18 @@ import { createWrapperFor } from '@tests/vitest.helpers';
|
|
|
3
3
|
|
|
4
4
|
describe('PAlert.vue', () => {
|
|
5
5
|
it.each([
|
|
6
|
-
['info', ['bg-info', 'text-on-info']],
|
|
7
|
-
['warning', ['bg-warning', 'text-on-warning']],
|
|
8
|
-
['
|
|
9
|
-
['
|
|
10
|
-
])('renders an alert of type %s', async (type, classes) => {
|
|
11
|
-
const wrapper = createWrapperFor(PAlert, { props: { type } });
|
|
6
|
+
['info', ['bg-info', 'text-on-info'], 'streamline:information-circle-solid'],
|
|
7
|
+
['warning', ['bg-warning', 'text-on-warning'], 'streamline:warning-triangle-solid'],
|
|
8
|
+
['error', ['bg-error', 'text-on-error'], 'streamline:warning-octagon-solid'],
|
|
9
|
+
['success', ['bg-success', 'text-on-success'], 'streamline:check-square-solid'],
|
|
10
|
+
])('renders an alert of type %s', async (type, classes, iconName) => {
|
|
11
|
+
const wrapper = createWrapperFor(PAlert, { props: { type }, global: { stubs: { PIcon: true } } });
|
|
12
12
|
|
|
13
13
|
const alert = await wrapper.find('div[role="alert"]');
|
|
14
|
-
const
|
|
14
|
+
const icon = wrapper.findComponent({ name: 'PIcon' });
|
|
15
15
|
|
|
16
16
|
expect(classes.every((c) => alert.classes().includes(c))).toBe(true);
|
|
17
|
-
expect(
|
|
17
|
+
expect(icon.props().icon).toBe(iconName);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('renders slots for icon and content', async () => {
|
|
@@ -23,6 +23,7 @@ describe('PAlert.vue', () => {
|
|
|
23
23
|
default: `This is an alert`,
|
|
24
24
|
icon: `<i class="test-icon"></i>`,
|
|
25
25
|
},
|
|
26
|
+
global: { stubs: { PIcon: true } },
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
const alert = await wrapper.find('div[role="alert"]');
|
|
@@ -1,53 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="['rounded p-4 text-xs font-semibold', classes]" role="alert">
|
|
2
|
+
<div :class="['rounded p-4 text-xs font-semibold', ALERT_TYPES[props.type].classes]" role="alert">
|
|
3
3
|
<div class="flex">
|
|
4
4
|
<div class="pr-2">
|
|
5
5
|
<slot name="icon">
|
|
6
|
-
<
|
|
7
|
-
<path
|
|
8
|
-
d="M8 0C6.41775 0 4.87104 0.469192 3.55544 1.34824C2.23985 2.22729 1.21447 3.47672 0.608967 4.93853C0.00346629 6.40034 -0.15496 8.00887 0.153721 9.56072C0.462403 11.1126 1.22433 12.538 2.34315 13.6569C3.46197 14.7757 4.88743 15.5376 6.43928 15.8463C7.99113 16.155 9.59966 15.9965 11.0615 15.391C12.5233 14.7855 13.7727 13.7602 14.6518 12.4446C15.5308 11.129 16 9.58225 16 8C16 5.87827 15.1571 3.84344 13.6569 2.34315C12.1566 0.842855 10.1217 0 8 0V0ZM8.16667 3.33333C8.36445 3.33333 8.55779 3.39198 8.72224 3.50186C8.88669 3.61175 9.01486 3.76792 9.09055 3.95065C9.16624 4.13338 9.18604 4.33444 9.14746 4.52842C9.10887 4.72241 9.01363 4.90059 8.87378 5.04044C8.73392 5.18029 8.55574 5.27553 8.36176 5.31412C8.16778 5.3527 7.96671 5.3329 7.78399 5.25721C7.60126 5.18153 7.44508 5.05335 7.3352 4.8889C7.22532 4.72445 7.16667 4.53112 7.16667 4.33333C7.16667 4.06812 7.27203 3.81376 7.45956 3.62623C7.6471 3.43869 7.90145 3.33333 8.16667 3.33333ZM9.66667 12.3333H7C6.82319 12.3333 6.65362 12.2631 6.5286 12.1381C6.40358 12.013 6.33334 11.8435 6.33334 11.6667C6.33334 11.4899 6.40358 11.3203 6.5286 11.1953C6.65362 11.0702 6.82319 11 7 11H7.5C7.54421 11 7.5866 10.9824 7.61786 10.9512C7.64911 10.9199 7.66667 10.8775 7.66667 10.8333V7.83333C7.66667 7.78913 7.64911 7.74674 7.61786 7.71548C7.5866 7.68423 7.54421 7.66667 7.5 7.66667H7C6.82319 7.66667 6.65362 7.59643 6.5286 7.47141C6.40358 7.34638 6.33334 7.17681 6.33334 7C6.33334 6.82319 6.40358 6.65362 6.5286 6.5286C6.65362 6.40357 6.82319 6.33333 7 6.33333H7.66667C8.02029 6.33333 8.35943 6.47381 8.60948 6.72386C8.85953 6.97391 9 7.31305 9 7.66667V10.8333C9 10.8775 9.01756 10.9199 9.04882 10.9512C9.08008 10.9824 9.12247 11 9.16667 11H9.66667C9.84348 11 10.0131 11.0702 10.1381 11.1953C10.2631 11.3203 10.3333 11.4899 10.3333 11.6667C10.3333 11.8435 10.2631 12.013 10.1381 12.1381C10.0131 12.2631 9.84348 12.3333 9.66667 12.3333Z"
|
|
9
|
-
:fill="svgColor"
|
|
10
|
-
/>
|
|
11
|
-
</svg>
|
|
6
|
+
<PIcon :icon="ALERT_TYPES[props.type].icon" width="16" class="-mb-0.5" inline />
|
|
12
7
|
</slot>
|
|
13
8
|
</div>
|
|
14
9
|
<div>
|
|
15
|
-
<slot
|
|
10
|
+
<slot></slot>
|
|
16
11
|
</div>
|
|
17
12
|
</div>
|
|
18
13
|
</div>
|
|
19
14
|
</template>
|
|
20
15
|
|
|
21
16
|
<script lang="ts">
|
|
22
|
-
import
|
|
23
|
-
import {
|
|
17
|
+
import PIcon from '@squirrel/components/p-icon/p-icon.vue';
|
|
18
|
+
import { type PropType } from 'vue';
|
|
24
19
|
|
|
25
20
|
const ALERT_TYPES = {
|
|
26
|
-
info: `bg-info text-on-info`,
|
|
27
|
-
warning: `bg-warning text-on-warning`,
|
|
28
|
-
error: `bg-error text-on-error`,
|
|
29
|
-
success: `bg-success text-on-success`,
|
|
21
|
+
info: { classes: `bg-info text-on-info`, icon: 'streamline:information-circle-solid' },
|
|
22
|
+
warning: { classes: `bg-warning text-on-warning`, icon: 'streamline:warning-triangle-solid' },
|
|
23
|
+
error: { classes: `bg-error text-on-error`, icon: 'streamline:warning-octagon-solid' },
|
|
24
|
+
success: { classes: `bg-success text-on-success`, icon: 'streamline:check-square-solid' },
|
|
30
25
|
};
|
|
26
|
+
</script>
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
defineOptions({
|
|
33
30
|
name: 'PAlert',
|
|
34
|
-
|
|
35
|
-
type: {
|
|
36
|
-
type: String as PropType<keyof typeof ALERT_TYPES>,
|
|
37
|
-
default: 'info',
|
|
38
|
-
validator(value: keyof typeof ALERT_TYPES) {
|
|
39
|
-
return Object.keys(ALERT_TYPES).includes(value);
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
computed: {
|
|
44
|
-
classes() {
|
|
45
|
-
return `${ALERT_TYPES[this.type]}`;
|
|
46
|
-
},
|
|
47
|
-
svgColor() {
|
|
48
|
-
const type = `on-${this.type}` as Color;
|
|
31
|
+
});
|
|
49
32
|
|
|
50
|
-
|
|
33
|
+
const props = defineProps({
|
|
34
|
+
type: {
|
|
35
|
+
type: String as PropType<keyof typeof ALERT_TYPES>,
|
|
36
|
+
default: 'info',
|
|
37
|
+
validator(value: keyof typeof ALERT_TYPES) {
|
|
38
|
+
return Object.keys(ALERT_TYPES).includes(value);
|
|
51
39
|
},
|
|
52
40
|
},
|
|
53
41
|
});
|
|
@@ -76,10 +76,17 @@ describe('PAvatar.vue', () => {
|
|
|
76
76
|
},
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const img = () => wrapper.find('img');
|
|
80
|
+
const label = () => wrapper.find('div.items-center');
|
|
81
|
+
|
|
82
|
+
await img().trigger('error');
|
|
83
|
+
|
|
84
|
+
expect(img().exists()).toBe(false);
|
|
85
|
+
expect(label().exists()).toBe(true);
|
|
81
86
|
|
|
82
87
|
await wrapper.setProps({ imageSrc: 'new-src.jpg' });
|
|
83
|
-
|
|
88
|
+
|
|
89
|
+
expect(img().exists()).toBe(true);
|
|
90
|
+
expect(label().exists()).toBe(false);
|
|
84
91
|
});
|
|
85
92
|
});
|
|
@@ -15,57 +15,55 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script lang="ts">
|
|
18
|
-
import {
|
|
18
|
+
import { computed, type PropType, ref, watch } from 'vue';
|
|
19
19
|
|
|
20
|
-
const SHAPES =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
20
|
+
const SHAPES = ['rectangle', 'circle'] as const;
|
|
21
|
+
|
|
22
|
+
type Shape = (typeof SHAPES)[number];
|
|
24
23
|
|
|
25
24
|
const SHAPE_CLASSES = {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
rectangle: 'rounded-lg',
|
|
26
|
+
circle: 'rounded-full',
|
|
28
27
|
};
|
|
28
|
+
</script>
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
defineOptions({
|
|
31
32
|
name: 'PAvatar',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type: String,
|
|
40
|
-
default: '',
|
|
41
|
-
},
|
|
42
|
-
label: {
|
|
43
|
-
type: String,
|
|
44
|
-
required: true,
|
|
45
|
-
},
|
|
46
|
-
imageClass: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: '',
|
|
49
|
-
},
|
|
50
|
-
labelClass: {
|
|
51
|
-
type: String,
|
|
52
|
-
default: '',
|
|
53
|
-
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
shape: {
|
|
37
|
+
type: String as PropType<Shape>,
|
|
38
|
+
default: 'circle',
|
|
39
|
+
validator: (value: Shape) => SHAPES.includes(value),
|
|
54
40
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
41
|
+
imageSrc: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '',
|
|
59
44
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
45
|
+
label: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true,
|
|
64
48
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
imageClass: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: '',
|
|
52
|
+
},
|
|
53
|
+
labelClass: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: '',
|
|
69
56
|
},
|
|
70
57
|
});
|
|
58
|
+
|
|
59
|
+
const imageBroken = ref<boolean>(false);
|
|
60
|
+
|
|
61
|
+
const shapeClass = computed(() => SHAPE_CLASSES[props.shape]);
|
|
62
|
+
|
|
63
|
+
watch(
|
|
64
|
+
() => props.imageSrc,
|
|
65
|
+
() => {
|
|
66
|
+
imageBroken.value = false;
|
|
67
|
+
}
|
|
68
|
+
);
|
|
71
69
|
</script>
|
|
@@ -18,6 +18,7 @@ const ELEMENTS_MAP = {
|
|
|
18
18
|
const DEFAULT_CLASSES_ARRAY = [
|
|
19
19
|
'relative',
|
|
20
20
|
'inline-block',
|
|
21
|
+
'whitespace-nowrap',
|
|
21
22
|
'outline-none',
|
|
22
23
|
'disabled:opacity-50',
|
|
23
24
|
'disabled:cursor-default',
|
|
@@ -177,7 +178,7 @@ describe('PBtn.vue', () => {
|
|
|
177
178
|
it.each([
|
|
178
179
|
['sm', ['py-1.5', 'px-3', 'rounded', 'font-medium', 'text-sm', 'leading-5']],
|
|
179
180
|
['md', ['py-2', 'px-6', 'rounded', 'font-medium', 'text-base']],
|
|
180
|
-
['lg', ['py-3', 'px-6', 'rounded', 'font-medium', 'text-lg']],
|
|
181
|
+
['lg', ['py-3', 'px-6', 'rounded', 'font-medium', 'text-lg', 'leading-6']],
|
|
181
182
|
])('renders a button of size %s', async (size, classes) => {
|
|
182
183
|
const wrapper = createWrapperFor(PBtn, { props: { size }, slots: { default: `button` } });
|
|
183
184
|
|
|
@@ -268,8 +269,6 @@ describe('PBtn.vue', () => {
|
|
|
268
269
|
|
|
269
270
|
const icon = await wrapper.findComponent({ name: 'PIcon' });
|
|
270
271
|
|
|
271
|
-
console.log(icon.classes());
|
|
272
|
-
|
|
273
272
|
expect(classes.every((c) => icon.classes().includes(c))).toBe(true);
|
|
274
273
|
});
|
|
275
274
|
|
|
@@ -47,7 +47,7 @@ type Icon = InstanceType<typeof PIcon>['$props']['icon'];
|
|
|
47
47
|
const btnClasses = {
|
|
48
48
|
slots: {
|
|
49
49
|
button:
|
|
50
|
-
'relative inline-block rounded font-medium outline-none disabled:pointer-events-none disabled:cursor-default disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-default aria-disabled:opacity-50',
|
|
50
|
+
'relative inline-block whitespace-nowrap rounded font-medium outline-none disabled:pointer-events-none disabled:cursor-default disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-default aria-disabled:opacity-50',
|
|
51
51
|
content: 'flex items-center justify-center has-[.slot-wrapper:empty]:gap-0',
|
|
52
52
|
loader: 'absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center font-medium',
|
|
53
53
|
icon: 'shrink-0',
|
|
@@ -94,7 +94,7 @@ const btnClasses = {
|
|
|
94
94
|
icon: 'text-xl',
|
|
95
95
|
},
|
|
96
96
|
lg: {
|
|
97
|
-
button: 'px-6 has-[.slot-wrapper:empty]:px-3 py-3 text-lg leading-
|
|
97
|
+
button: 'px-6 has-[.slot-wrapper:empty]:px-3 py-3 text-lg leading-6',
|
|
98
98
|
content: 'gap-2.5',
|
|
99
99
|
icon: 'text-2xl',
|
|
100
100
|
},
|
|
@@ -25,57 +25,80 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script lang="ts">
|
|
28
|
-
import
|
|
29
|
-
import {
|
|
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, useSlots } from 'vue';
|
|
30
31
|
|
|
31
32
|
const INPUT_TYPES = { TEXT: 'text', PASSWORD: 'password' };
|
|
32
33
|
|
|
33
34
|
type InputTypeKeys = keyof typeof INPUT_TYPES;
|
|
34
35
|
type InputType = (typeof INPUT_TYPES)[InputTypeKeys];
|
|
36
|
+
</script>
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
defineOptions({
|
|
37
40
|
name: 'PInput',
|
|
38
|
-
mixins: [inputClassesMixin],
|
|
39
41
|
inheritAttrs: false,
|
|
40
|
-
|
|
41
|
-
modelValue: {
|
|
42
|
-
type: [String, Number],
|
|
43
|
-
default: '',
|
|
44
|
-
},
|
|
45
|
-
type: {
|
|
46
|
-
type: String as PropType<InputType>,
|
|
47
|
-
default: INPUT_TYPES.TEXT,
|
|
48
|
-
validator(value: InputType) {
|
|
49
|
-
return Object.values(INPUT_TYPES).includes(value);
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
label: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: '',
|
|
55
|
-
},
|
|
56
|
-
errorMsg: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: '',
|
|
59
|
-
},
|
|
60
|
-
required: {
|
|
61
|
-
type: Boolean,
|
|
62
|
-
default: false,
|
|
63
|
-
},
|
|
64
|
-
rounded: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: false,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
emits: ['update:modelValue'],
|
|
70
|
-
computed: {
|
|
71
|
-
attrs() {
|
|
72
|
-
const { class: classes, style, ...rest } = this.$attrs;
|
|
42
|
+
});
|
|
73
43
|
|
|
74
|
-
|
|
44
|
+
defineEmits(['update:modelValue']);
|
|
45
|
+
|
|
46
|
+
const props = defineProps({
|
|
47
|
+
modelValue: {
|
|
48
|
+
type: [String, Number, Boolean, null] as PropType<string | number | boolean | null>,
|
|
49
|
+
default: '',
|
|
50
|
+
},
|
|
51
|
+
type: {
|
|
52
|
+
type: String as PropType<InputType>,
|
|
53
|
+
default: INPUT_TYPES.TEXT,
|
|
54
|
+
validator(value: InputType) {
|
|
55
|
+
return Object.values(INPUT_TYPES).includes(value);
|
|
75
56
|
},
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
},
|
|
58
|
+
label: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: '',
|
|
61
|
+
},
|
|
62
|
+
errorMsg: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: '',
|
|
65
|
+
},
|
|
66
|
+
required: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: false,
|
|
69
|
+
},
|
|
70
|
+
size: {
|
|
71
|
+
type: String as PropType<Size>,
|
|
72
|
+
default: 'md',
|
|
73
|
+
validator(value: Size) {
|
|
74
|
+
return SIZES.includes(value);
|
|
78
75
|
},
|
|
79
76
|
},
|
|
77
|
+
rounded: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: false,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const slots = useSlots();
|
|
84
|
+
|
|
85
|
+
const { labelClasses, inputClasses, errorMsgClasses } = useInputClasses(
|
|
86
|
+
computed(() => ({
|
|
87
|
+
...props,
|
|
88
|
+
prefix: !!slots.prefix,
|
|
89
|
+
suffix: !!slots.suffix,
|
|
90
|
+
}))
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const allAttrs = useAttrs();
|
|
94
|
+
|
|
95
|
+
const attrs = computed(() => {
|
|
96
|
+
const { class: classes, style, ...rest } = allAttrs;
|
|
97
|
+
|
|
98
|
+
return rest;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const style = computed(() => {
|
|
102
|
+
return allAttrs.style as StyleValue;
|
|
80
103
|
});
|
|
81
104
|
</script>
|