@pequity/squirrel 8.4.4 → 8.4.5
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/README.md +2 -1
- package/dist/cjs/chunks/p-alert.js +3 -0
- package/dist/cjs/chunks/p-avatar.js +16 -0
- package/dist/cjs/chunks/p-btn.js +3 -0
- package/dist/cjs/chunks/p-card.js +4 -0
- package/dist/cjs/chunks/p-dropdown-select.js +34 -0
- package/dist/cjs/chunks/p-input-number.js +32 -0
- package/dist/cjs/chunks/p-input-percent.js +13 -2
- package/dist/cjs/chunks/p-input.js +28 -0
- package/dist/cjs/chunks/p-pagination-info.js +9 -5
- package/dist/cjs/chunks/p-pagination.js +23 -13
- package/dist/cjs/chunks/p-select-btn.js +2 -1
- package/dist/cjs/chunks/p-select.js +33 -0
- package/dist/cjs/chunks/p-table-loader.js +20 -0
- package/dist/cjs/chunks/p-tabs.js +12 -0
- package/dist/cjs/chunks/p-textarea.js +20 -0
- package/dist/cjs/index.js +40 -3
- package/dist/cjs/p-checkbox.js +8 -1
- package/dist/cjs/p-chips.js +17 -1
- package/dist/cjs/p-close-btn.js +6 -1
- package/dist/cjs/p-drawer.js +90 -2
- package/dist/cjs/p-dropdown.js +2 -1
- package/dist/cjs/p-input-search.js +13 -1
- package/dist/cjs/p-loading.js +1 -1
- package/dist/cjs/p-modal.js +82 -2
- package/dist/cjs/p-select-pill.js +36 -2
- package/dist/cjs/p-skeleton-loader.js +17 -1
- package/dist/cjs/p-table-filter-icon.js +4 -1
- package/dist/cjs/p-table-header-cell.js +29 -0
- package/dist/cjs/p-table-td.js +1 -1
- package/dist/cjs/p-toggle.js +22 -1
- package/dist/es/chunks/p-alert.js +3 -0
- package/dist/es/chunks/p-avatar.js +16 -0
- package/dist/es/chunks/p-btn.js +3 -0
- package/dist/es/chunks/p-card.js +4 -0
- package/dist/es/chunks/p-dropdown-select.js +34 -0
- package/dist/es/chunks/p-input-number.js +32 -0
- package/dist/es/chunks/p-input-percent.js +13 -2
- package/dist/es/chunks/p-input.js +28 -0
- package/dist/es/chunks/p-pagination-info.js +9 -5
- package/dist/es/chunks/p-pagination.js +24 -14
- package/dist/es/chunks/p-select-btn.js +2 -1
- package/dist/es/chunks/p-select.js +33 -0
- package/dist/es/chunks/p-table-loader.js +20 -0
- package/dist/es/chunks/p-tabs.js +12 -0
- package/dist/es/chunks/p-textarea.js +20 -0
- package/dist/es/index.js +40 -3
- package/dist/es/p-checkbox.js +8 -1
- package/dist/es/p-chips.js +17 -1
- package/dist/es/p-close-btn.js +6 -1
- package/dist/es/p-drawer.js +90 -2
- package/dist/es/p-dropdown.js +2 -1
- package/dist/es/p-input-search.js +13 -1
- package/dist/es/p-loading.js +1 -1
- package/dist/es/p-modal.js +82 -2
- package/dist/es/p-select-pill.js +36 -2
- package/dist/es/p-skeleton-loader.js +17 -1
- package/dist/es/p-table-filter-icon.js +4 -1
- package/dist/es/p-table-header-cell.js +29 -0
- package/dist/es/p-table-td.js +1 -1
- package/dist/es/p-toggle.js +22 -1
- package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +14 -2
- package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +16 -3
- package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +35 -0
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +18 -2
- package/dist/squirrel/components/p-card/p-card.vue.d.ts +20 -7
- package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +25 -7
- package/dist/squirrel/components/p-chips/p-chips.vue.d.ts +24 -0
- package/dist/squirrel/components/p-close-btn/p-close-btn.vue.d.ts +13 -0
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +16 -0
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +141 -3
- package/dist/squirrel/components/p-dropdown/p-dropdown.vue.d.ts +11 -2
- package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +69 -1
- package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +70 -6
- package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +4 -0
- package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +11 -4
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +27 -7
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +73 -8
- package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +83 -12
- package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +22 -2
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +24 -0
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +185 -15
- package/dist/squirrel/components/p-pagination/p-pagination.vue.d.ts +22 -12
- package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +16 -8
- package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +20 -0
- package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +10 -0
- package/dist/squirrel/components/p-select/p-select.vue.d.ts +76 -6
- package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +67 -10
- package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +1 -1
- package/dist/squirrel/components/p-select-pill/p-select-pill.vue.d.ts +72 -2
- package/dist/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue.d.ts +40 -0
- package/dist/squirrel/components/p-steps/p-steps.vue.d.ts +12 -0
- package/dist/squirrel/components/p-table/p-table.vue.d.ts +32 -0
- package/dist/squirrel/components/p-table-header-cell/p-table-filter-icon.vue.d.ts +6 -0
- package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +56 -1
- package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +40 -0
- package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +12 -2
- package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +12 -0
- package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +33 -2
- package/dist/squirrel/components/p-tabs-pills/p-tabs-pills.vue.d.ts +22 -0
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +52 -8
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +50 -3
- package/dist/squirrel.css +68 -68
- package/package.json +15 -15
- package/squirrel/components/p-action-bar/p-action-bar.stories.js +5 -5
- package/squirrel/components/p-action-bar/p-action-bar.vue +30 -3
- package/squirrel/components/p-alert/p-alert.vue +24 -0
- package/squirrel/components/p-avatar/p-avatar.vue +28 -0
- package/squirrel/components/p-btn/p-btn.vue +35 -0
- package/squirrel/components/p-card/p-card.vue +24 -1
- package/squirrel/components/p-checkbox/p-checkbox.vue +23 -1
- package/squirrel/components/p-chips/p-chips.vue +24 -0
- package/squirrel/components/p-close-btn/p-close-btn.vue +15 -0
- package/squirrel/components/p-date-picker/p-date-picker.vue +23 -1
- package/squirrel/components/p-drawer/p-drawer.vue +95 -0
- package/squirrel/components/p-dropdown/p-dropdown.vue +12 -1
- package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +41 -0
- package/squirrel/components/p-file-upload/p-file-upload.vue +58 -3
- package/squirrel/components/p-icon/p-icon.vue +16 -0
- package/squirrel/components/p-info-icon/p-info-icon.vue +19 -0
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue +32 -0
- package/squirrel/components/p-input/p-input.vue +61 -1
- package/squirrel/components/p-input-number/p-input-number.vue +78 -1
- package/squirrel/components/p-input-percent/p-input-percent.vue +27 -3
- package/squirrel/components/p-input-search/p-input-search.vue +30 -2
- package/squirrel/components/p-link/p-link.vue +13 -0
- package/squirrel/components/p-loading/p-loading.vue +9 -2
- package/squirrel/components/p-modal/p-modal.vue +138 -2
- package/squirrel/components/p-pagination/p-pagination.vue +28 -8
- package/squirrel/components/p-pagination-info/p-pagination-info.vue +16 -4
- package/squirrel/components/p-progress-bar/p-progress-bar.vue +31 -4
- package/squirrel/components/p-ring-loader/p-ring-loader.vue +17 -0
- package/squirrel/components/p-select/p-select.vue +50 -1
- package/squirrel/components/p-select-btn/p-select-btn.vue +90 -2
- package/squirrel/components/p-select-list/p-select-list.vue +7 -0
- package/squirrel/components/p-select-pill/p-select-pill.vue +52 -2
- package/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue +24 -0
- package/squirrel/components/p-steps/p-steps.vue +25 -0
- package/squirrel/components/p-table/p-table.vue +39 -0
- package/squirrel/components/p-table-header-cell/p-table-filter-icon.vue +9 -0
- package/squirrel/components/p-table-header-cell/p-table-header-cell.vue +36 -0
- package/squirrel/components/p-table-loader/p-table-loader.vue +28 -0
- package/squirrel/components/p-table-sort/p-table-sort.vue +19 -1
- package/squirrel/components/p-table-td/p-table-td.vue +20 -0
- package/squirrel/components/p-tabs/p-tabs.stories.js +2 -2
- package/squirrel/components/p-tabs/p-tabs.vue +33 -1
- package/squirrel/components/p-tabs-pills/p-tabs-pills.vue +33 -0
- package/squirrel/components/p-textarea/p-textarea.vue +43 -1
- package/squirrel/components/p-toggle/p-toggle.vue +44 -1
- package/squirrel/assets/pagination-left-icon.svg +0 -5
- package/squirrel/assets/pagination-right-icon.svg +0 -5
|
@@ -76,16 +76,31 @@ import { uniq } from 'lodash-es';
|
|
|
76
76
|
import { computed, onMounted, type PropType, ref, shallowRef } from 'vue';
|
|
77
77
|
import { useToast } from 'vue-toastification';
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* A file upload component with drag-and-drop support and comprehensive validation.
|
|
81
|
+
* Provides a user-friendly interface for file selection with visual feedback,
|
|
82
|
+
* file type validation, size limits, and multiple file support.
|
|
83
|
+
*
|
|
84
|
+
* @displayName PFileUpload
|
|
85
|
+
*/
|
|
79
86
|
defineOptions({
|
|
80
87
|
name: 'PFileUpload',
|
|
81
88
|
});
|
|
82
89
|
|
|
83
90
|
// Props
|
|
84
91
|
const props = defineProps({
|
|
92
|
+
/**
|
|
93
|
+
* The current file(s) value (v-model).
|
|
94
|
+
* Supports both single file and multiple files based on the multiple prop.
|
|
95
|
+
*/
|
|
85
96
|
modelValue: {
|
|
86
97
|
type: [Object, Array] as PropType<FileUploadFile | FileUploadFile[]>,
|
|
87
98
|
default: () => [],
|
|
88
99
|
},
|
|
100
|
+
/**
|
|
101
|
+
* Whether multiple files can be selected.
|
|
102
|
+
* When true, allows selecting multiple files at once.
|
|
103
|
+
*/
|
|
89
104
|
multiple: {
|
|
90
105
|
type: Boolean,
|
|
91
106
|
default: false,
|
|
@@ -98,33 +113,73 @@ const props = defineProps({
|
|
|
98
113
|
type: Array as PropType<string[] | readonly string[]>,
|
|
99
114
|
default: () => [],
|
|
100
115
|
},
|
|
116
|
+
/**
|
|
117
|
+
* Whether the file upload is disabled.
|
|
118
|
+
* Prevents user interaction when true.
|
|
119
|
+
*/
|
|
101
120
|
disabled: {
|
|
102
121
|
type: Boolean,
|
|
103
122
|
default: false,
|
|
104
123
|
},
|
|
124
|
+
/**
|
|
125
|
+
* Whether the file upload is required.
|
|
126
|
+
* Adds required attribute and visual indicator.
|
|
127
|
+
*/
|
|
105
128
|
required: {
|
|
106
129
|
type: Boolean,
|
|
107
130
|
default: false,
|
|
108
131
|
},
|
|
132
|
+
/**
|
|
133
|
+
* Error message to display below the file upload.
|
|
134
|
+
* When provided, the upload area will show error styling.
|
|
135
|
+
*/
|
|
109
136
|
errorMsg: {
|
|
110
137
|
type: String,
|
|
111
138
|
default: '',
|
|
112
139
|
},
|
|
140
|
+
/**
|
|
141
|
+
* Text label for the file upload field.
|
|
142
|
+
* Displayed above the upload area.
|
|
143
|
+
*/
|
|
113
144
|
label: {
|
|
114
145
|
type: String,
|
|
115
146
|
default: '',
|
|
116
147
|
},
|
|
148
|
+
/**
|
|
149
|
+
* Maximum file size in bytes.
|
|
150
|
+
* Files exceeding this size will be rejected with an error message.
|
|
151
|
+
*/
|
|
117
152
|
maxSizeInBytes: {
|
|
118
153
|
type: Number,
|
|
119
154
|
default: 256 * 1000, // 256 KB
|
|
120
155
|
},
|
|
156
|
+
/**
|
|
157
|
+
* Maximum number of files that can be uploaded.
|
|
158
|
+
* Only applies when multiple is true.
|
|
159
|
+
*/
|
|
121
160
|
maxNumberOfFiles: {
|
|
122
161
|
type: Number,
|
|
123
162
|
default: 10,
|
|
124
163
|
},
|
|
125
164
|
});
|
|
126
165
|
|
|
127
|
-
const emit = defineEmits
|
|
166
|
+
const emit = defineEmits<{
|
|
167
|
+
/**
|
|
168
|
+
* Emitted when the file selection changes.
|
|
169
|
+
* @param {FileUploadFile | FileUploadFile[]} value - The new file selection
|
|
170
|
+
*/
|
|
171
|
+
'update:modelValue': [value: FileUploadFile | FileUploadFile[]];
|
|
172
|
+
/**
|
|
173
|
+
* Emitted when a file is removed from the selection.
|
|
174
|
+
* @param {FileUploadFile} file - The removed file
|
|
175
|
+
*/
|
|
176
|
+
'file-removed': [file: FileUploadFile];
|
|
177
|
+
/**
|
|
178
|
+
* Emitted when new files are added to the selection.
|
|
179
|
+
* @param {FileUploadFile[]} files - The newly added files
|
|
180
|
+
*/
|
|
181
|
+
'file-added': [files: FileUploadFile[]];
|
|
182
|
+
}>();
|
|
128
183
|
|
|
129
184
|
// Data
|
|
130
185
|
const fileInputRef = shallowRef<HTMLInputElement>();
|
|
@@ -217,9 +272,9 @@ const uploadFile = (e: Event | DragEvent) => {
|
|
|
217
272
|
return;
|
|
218
273
|
}
|
|
219
274
|
|
|
220
|
-
const validatedFiles = props.fileTypes ? validateFiles(Array.from(f)) : f;
|
|
275
|
+
const validatedFiles = props.fileTypes ? validateFiles(Array.from(f)) : Array.from(f);
|
|
221
276
|
|
|
222
|
-
files.value = props.multiple ? [...files.value, ...validatedFiles] :
|
|
277
|
+
files.value = props.multiple ? [...files.value, ...validatedFiles] : validatedFiles;
|
|
223
278
|
|
|
224
279
|
emit('file-added', validatedFiles);
|
|
225
280
|
};
|
|
@@ -7,15 +7,31 @@ import 'iconify-icon';
|
|
|
7
7
|
import { P_ICON_ALIASES, type PIconAlias } from '@squirrel/components/p-icon/p-icon.types';
|
|
8
8
|
import { type IconifyIconProperties } from 'iconify-icon';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* An icon component that renders icons using Iconify.
|
|
12
|
+
* Supports both custom icon aliases and standard Iconify icon names.
|
|
13
|
+
* Inherits all IconifyIconProperties for full icon customization.
|
|
14
|
+
*
|
|
15
|
+
* @displayName PIcon
|
|
16
|
+
*/
|
|
10
17
|
defineOptions({
|
|
11
18
|
name: 'PIcon',
|
|
12
19
|
});
|
|
13
20
|
|
|
14
21
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
15
22
|
interface Props extends /* @vue-ignore */ IconifyIconProperties {
|
|
23
|
+
/**
|
|
24
|
+
* The icon to display. Can be an icon alias or any valid Iconify icon name.
|
|
25
|
+
* Icon aliases provide consistent icon naming across the application.
|
|
26
|
+
*/
|
|
16
27
|
icon: PIconAlias | (string & {});
|
|
17
28
|
}
|
|
18
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the provided icon is an icon alias.
|
|
32
|
+
* @param {string} icon - The icon name to check
|
|
33
|
+
* @returns {boolean} True if the icon is an icon alias
|
|
34
|
+
*/
|
|
19
35
|
const isPIcon = (icon: string): icon is PIconAlias => !!P_ICON_ALIASES[icon as PIconAlias];
|
|
20
36
|
|
|
21
37
|
defineProps<Props>();
|
|
@@ -10,11 +10,30 @@
|
|
|
10
10
|
<script setup lang="ts">
|
|
11
11
|
import PIcon from '@squirrel/components/p-icon/p-icon.vue';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* An info icon component that displays a tooltip on hover.
|
|
15
|
+
* Shows an info icon with customizable tooltip content.
|
|
16
|
+
* Tooltip appears after 750ms delay and disappears immediately on mouse leave.
|
|
17
|
+
*
|
|
18
|
+
* @displayName PInfoIcon
|
|
19
|
+
*/
|
|
13
20
|
defineOptions({
|
|
14
21
|
name: 'PInfoIcon',
|
|
15
22
|
});
|
|
16
23
|
|
|
24
|
+
defineSlots<{
|
|
25
|
+
/**
|
|
26
|
+
* Custom tooltip content - overrides the text prop.
|
|
27
|
+
* Use this slot for custom tooltip content instead of the text prop.
|
|
28
|
+
*/
|
|
29
|
+
default?: () => unknown;
|
|
30
|
+
}>();
|
|
31
|
+
|
|
17
32
|
type Props = {
|
|
33
|
+
/**
|
|
34
|
+
* Text content for the tooltip.
|
|
35
|
+
* If not provided, you can use the default slot instead.
|
|
36
|
+
*/
|
|
18
37
|
text?: string | null;
|
|
19
38
|
};
|
|
20
39
|
|
|
@@ -15,14 +15,42 @@ import { useInputClasses } from '@squirrel/composables/useInputClasses';
|
|
|
15
15
|
import VueDatePicker, { type VueDatePickerProps } from '@vuepic/vue-datepicker';
|
|
16
16
|
import { computed, type StyleValue, useAttrs } from 'vue';
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* An inline date picker component that displays a calendar for date selection.
|
|
20
|
+
* Wraps VueDatePicker with consistent styling and form integration.
|
|
21
|
+
* Supports custom labels, error states, and inherits all VueDatePicker props.
|
|
22
|
+
*
|
|
23
|
+
* @displayName PInlineDatePicker
|
|
24
|
+
*/
|
|
18
25
|
defineOptions({
|
|
19
26
|
name: 'PInlineDatePicker',
|
|
20
27
|
inheritAttrs: false,
|
|
21
28
|
});
|
|
22
29
|
|
|
30
|
+
defineSlots<{
|
|
31
|
+
/**
|
|
32
|
+
* Custom label content - overrides the label prop.
|
|
33
|
+
* @param {string} label - The label text
|
|
34
|
+
* @param {string} label-classes - CSS classes for the label
|
|
35
|
+
*/
|
|
36
|
+
label?: (props: { label: string; labelClasses: string }) => unknown;
|
|
37
|
+
}>();
|
|
38
|
+
|
|
23
39
|
type Props = {
|
|
40
|
+
/**
|
|
41
|
+
* Text label for the date picker field.
|
|
42
|
+
* If not provided, you can use the label slot instead.
|
|
43
|
+
*/
|
|
24
44
|
label?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Error message to display below the date picker.
|
|
47
|
+
* When provided, the date picker will show error styling.
|
|
48
|
+
*/
|
|
25
49
|
errorMsg?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the date picker is required.
|
|
52
|
+
* Adds required attribute and visual indicator.
|
|
53
|
+
*/
|
|
26
54
|
required?: boolean;
|
|
27
55
|
} & VueDatePickerProps;
|
|
28
56
|
|
|
@@ -38,6 +66,10 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
38
66
|
weekStart: 0,
|
|
39
67
|
});
|
|
40
68
|
|
|
69
|
+
/**
|
|
70
|
+
* The selected date value (v-model).
|
|
71
|
+
* Supports two-way binding for form inputs.
|
|
72
|
+
*/
|
|
41
73
|
const model = defineModel<Date | string | null>({ default: '' });
|
|
42
74
|
|
|
43
75
|
// Data
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
</slot>
|
|
8
8
|
<div class="relative w-full">
|
|
9
9
|
<div v-if="!!$slots.prefix">
|
|
10
|
+
<!-- Slot for content displayed before the input field -->
|
|
10
11
|
<slot name="prefix"></slot>
|
|
11
12
|
</div>
|
|
12
13
|
<input
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
@input="(event: Event) => $emit('update:modelValue', (event.target as HTMLInputElement).value)"
|
|
18
19
|
/>
|
|
19
20
|
<div v-if="!!$slots.suffix">
|
|
21
|
+
<!-- Slot for content displayed after the input field -->
|
|
20
22
|
<slot name="suffix"></slot>
|
|
21
23
|
</div>
|
|
22
24
|
</div>
|
|
@@ -36,18 +38,56 @@ type InputType = (typeof INPUT_TYPES)[InputTypeKeys];
|
|
|
36
38
|
</script>
|
|
37
39
|
|
|
38
40
|
<script setup lang="ts">
|
|
41
|
+
/**
|
|
42
|
+
* A versatile input component that supports various types, sizes, and states.
|
|
43
|
+
* Provides consistent styling and behavior across different input types.
|
|
44
|
+
* Supports custom labels, error states, and prefix/suffix content.
|
|
45
|
+
*/
|
|
39
46
|
defineOptions({
|
|
40
47
|
name: 'PInput',
|
|
41
48
|
inheritAttrs: false,
|
|
42
49
|
});
|
|
43
50
|
|
|
44
|
-
defineEmits
|
|
51
|
+
defineEmits<{
|
|
52
|
+
/**
|
|
53
|
+
* Emitted when the input value changes.
|
|
54
|
+
* @param {string} value - The new input value
|
|
55
|
+
*/
|
|
56
|
+
'update:modelValue': [value: string];
|
|
57
|
+
}>();
|
|
58
|
+
|
|
59
|
+
defineSlots<{
|
|
60
|
+
/**
|
|
61
|
+
* Custom label content - overrides the label prop.
|
|
62
|
+
* @param {string} label - The label text
|
|
63
|
+
* @param {string} label-classes - CSS classes for the label
|
|
64
|
+
*/
|
|
65
|
+
label?: (props: { label: string; labelClasses: string }) => unknown;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Content displayed before the input field.
|
|
69
|
+
*/
|
|
70
|
+
prefix?: () => unknown;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Content displayed after the input field.
|
|
74
|
+
*/
|
|
75
|
+
suffix?: () => unknown;
|
|
76
|
+
}>();
|
|
45
77
|
|
|
46
78
|
const props = defineProps({
|
|
79
|
+
/**
|
|
80
|
+
* The current value of the input (v-model).
|
|
81
|
+
* Supports two-way binding for form inputs.
|
|
82
|
+
*/
|
|
47
83
|
modelValue: {
|
|
48
84
|
type: [String, Number, Boolean, null] as PropType<string | number | boolean | null>,
|
|
49
85
|
default: '',
|
|
50
86
|
},
|
|
87
|
+
/**
|
|
88
|
+
* The type of the input field.
|
|
89
|
+
* Valid values: 'text', 'password'
|
|
90
|
+
*/
|
|
51
91
|
type: {
|
|
52
92
|
type: String as PropType<InputType>,
|
|
53
93
|
default: INPUT_TYPES.TEXT,
|
|
@@ -55,18 +95,34 @@ const props = defineProps({
|
|
|
55
95
|
return Object.values(INPUT_TYPES).includes(value);
|
|
56
96
|
},
|
|
57
97
|
},
|
|
98
|
+
/**
|
|
99
|
+
* Text label for the input field.
|
|
100
|
+
* If not provided, you can use the label slot instead.
|
|
101
|
+
*/
|
|
58
102
|
label: {
|
|
59
103
|
type: String,
|
|
60
104
|
default: '',
|
|
61
105
|
},
|
|
106
|
+
/**
|
|
107
|
+
* Error message to display below the input.
|
|
108
|
+
* When provided, the input will show error styling.
|
|
109
|
+
*/
|
|
62
110
|
errorMsg: {
|
|
63
111
|
type: String,
|
|
64
112
|
default: '',
|
|
65
113
|
},
|
|
114
|
+
/**
|
|
115
|
+
* Whether the input is required.
|
|
116
|
+
* Adds required attribute and visual indicator.
|
|
117
|
+
*/
|
|
66
118
|
required: {
|
|
67
119
|
type: Boolean,
|
|
68
120
|
default: false,
|
|
69
121
|
},
|
|
122
|
+
/**
|
|
123
|
+
* The size of the input - affects padding, font size, and spacing.
|
|
124
|
+
* Valid values: 'sm', 'md', 'lg'
|
|
125
|
+
*/
|
|
70
126
|
size: {
|
|
71
127
|
type: String as PropType<Size>,
|
|
72
128
|
default: 'md',
|
|
@@ -74,6 +130,10 @@ const props = defineProps({
|
|
|
74
130
|
return SIZES.includes(value);
|
|
75
131
|
},
|
|
76
132
|
},
|
|
133
|
+
/**
|
|
134
|
+
* Whether the input has rounded corners.
|
|
135
|
+
* Applies rounded styling to the input field.
|
|
136
|
+
*/
|
|
77
137
|
rounded: {
|
|
78
138
|
type: Boolean,
|
|
79
139
|
default: false,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
<div class="relative w-full">
|
|
12
12
|
<div v-if="!!$slots.prefix || prefixString">
|
|
13
|
+
<!-- Slot for custom prefix content - overrides the prefixString prop -->
|
|
13
14
|
<slot name="prefix">
|
|
14
15
|
<div
|
|
15
16
|
:class="[{ 'absolute left-3 flex items-center': prefixString }, prefixString ? prefixClasses[size] : '']"
|
|
@@ -53,30 +54,82 @@ const prefixClasses: Record<Size, string> = {
|
|
|
53
54
|
lg: 'text-lg h-12 left-5',
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
/**
|
|
58
|
+
* A specialized input component for numeric values with currency formatting.
|
|
59
|
+
* Provides number-only input with configurable currency display, precision, and formatting options.
|
|
60
|
+
* Supports custom labels, error states, tooltips, and prefix content.
|
|
61
|
+
* Uses vue-currency-input for robust number handling and formatting.
|
|
62
|
+
*/
|
|
56
63
|
defineOptions({
|
|
57
64
|
name: 'PInputNumber',
|
|
58
65
|
inheritAttrs: false,
|
|
59
66
|
});
|
|
60
67
|
|
|
61
|
-
const emit = defineEmits
|
|
68
|
+
const emit = defineEmits<{
|
|
69
|
+
/**
|
|
70
|
+
* Emitted when the numeric value changes.
|
|
71
|
+
* @param {number | null} value - The new numeric value
|
|
72
|
+
*/
|
|
73
|
+
'update:modelValue': [value: number | null];
|
|
74
|
+
/**
|
|
75
|
+
* Emitted when the value changes (includes the new value).
|
|
76
|
+
* @param {number | null} value - The new numeric value
|
|
77
|
+
*/
|
|
78
|
+
change: [value: number | null];
|
|
79
|
+
}>();
|
|
80
|
+
|
|
81
|
+
defineSlots<{
|
|
82
|
+
/**
|
|
83
|
+
* Custom label content - overrides the label prop.
|
|
84
|
+
* @param {string} label - The label text
|
|
85
|
+
* @param {string} label-classes - CSS classes for the label
|
|
86
|
+
*/
|
|
87
|
+
label?: (props: { label: string; labelClasses: string }) => unknown;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Custom prefix content - overrides the prefixString prop.
|
|
91
|
+
* Use this slot for custom prefix content instead of the prefixString prop.
|
|
92
|
+
*/
|
|
93
|
+
prefix?: () => unknown;
|
|
94
|
+
}>();
|
|
62
95
|
|
|
63
96
|
const props = defineProps({
|
|
97
|
+
/**
|
|
98
|
+
* The current numeric value of the input (v-model).
|
|
99
|
+
* Supports two-way binding for form inputs.
|
|
100
|
+
*/
|
|
64
101
|
modelValue: {
|
|
65
102
|
type: [Number, String] as PropType<number | string | null | undefined>,
|
|
66
103
|
default: null,
|
|
67
104
|
},
|
|
105
|
+
/**
|
|
106
|
+
* Text label for the input field.
|
|
107
|
+
* If not provided, you can use the label slot instead.
|
|
108
|
+
*/
|
|
68
109
|
label: {
|
|
69
110
|
type: String,
|
|
70
111
|
default: '',
|
|
71
112
|
},
|
|
113
|
+
/**
|
|
114
|
+
* Error message to display below the input.
|
|
115
|
+
* When provided, the input will show error styling.
|
|
116
|
+
*/
|
|
72
117
|
errorMsg: {
|
|
73
118
|
type: String,
|
|
74
119
|
default: '',
|
|
75
120
|
},
|
|
121
|
+
/**
|
|
122
|
+
* Whether the input is required.
|
|
123
|
+
* Adds required attribute and visual indicator.
|
|
124
|
+
*/
|
|
76
125
|
required: {
|
|
77
126
|
type: Boolean,
|
|
78
127
|
default: false,
|
|
79
128
|
},
|
|
129
|
+
/**
|
|
130
|
+
* The size of the input - affects padding, font size, and spacing.
|
|
131
|
+
* Valid values: 'sm', 'md', 'lg'
|
|
132
|
+
*/
|
|
80
133
|
size: {
|
|
81
134
|
type: String as PropType<Size>,
|
|
82
135
|
default: 'md',
|
|
@@ -84,14 +137,26 @@ const props = defineProps({
|
|
|
84
137
|
return SIZES.includes(value);
|
|
85
138
|
},
|
|
86
139
|
},
|
|
140
|
+
/**
|
|
141
|
+
* Whether to select all text when the input receives focus.
|
|
142
|
+
* Provides better UX for number input fields.
|
|
143
|
+
*/
|
|
87
144
|
selectOnClick: {
|
|
88
145
|
type: Boolean,
|
|
89
146
|
default: true,
|
|
90
147
|
},
|
|
148
|
+
/**
|
|
149
|
+
* Text for the info tooltip displayed next to the label.
|
|
150
|
+
* Uses PInfoIcon component for consistent tooltip styling.
|
|
151
|
+
*/
|
|
91
152
|
tooltipText: {
|
|
92
153
|
type: String,
|
|
93
154
|
default: '',
|
|
94
155
|
},
|
|
156
|
+
/**
|
|
157
|
+
* String to display as prefix in the input field.
|
|
158
|
+
* Can be overridden by the prefix slot for custom content.
|
|
159
|
+
*/
|
|
95
160
|
prefixString: {
|
|
96
161
|
type: String,
|
|
97
162
|
default: '',
|
|
@@ -155,9 +220,21 @@ const style = computed(() => {
|
|
|
155
220
|
return attrs.style as StyleValue;
|
|
156
221
|
});
|
|
157
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Handles focus event on the input field.
|
|
225
|
+
* Selects all text if selectOnClick is enabled.
|
|
226
|
+
* @param {void} - No parameters
|
|
227
|
+
* @returns {void}
|
|
228
|
+
*/
|
|
158
229
|
const focus = () => {
|
|
159
230
|
props.selectOnClick && inputRef.value.select();
|
|
160
231
|
};
|
|
161
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Programmatically sets the numeric value of the input.
|
|
235
|
+
* Useful for external control of the input value.
|
|
236
|
+
* @param {number | null} value - The numeric value to set
|
|
237
|
+
* @returns {void}
|
|
238
|
+
*/
|
|
162
239
|
defineExpose({ setValue });
|
|
163
240
|
</script>
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
12
|
import { type Size } from '@squirrel/components/p-btn/p-btn.types';
|
|
13
13
|
import PInputNumber from '@squirrel/components/p-input-number/p-input-number.vue';
|
|
14
|
+
import { toNumberOrNull } from '@squirrel/utils/number';
|
|
14
15
|
import { isNumber } from 'lodash-es';
|
|
15
16
|
import { computed, type PropType } from 'vue';
|
|
16
17
|
|
|
@@ -20,25 +21,48 @@ const prefixClasses: Record<Size, string> = {
|
|
|
20
21
|
lg: 'text-lg h-12 left-5',
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* A percentage input component that wraps PInputNumber with automatic decimal conversion.
|
|
26
|
+
* Displays values as percentages (multiplied by 100) while storing the actual decimal value.
|
|
27
|
+
* Provides a consistent interface for percentage inputs with proper formatting and validation.
|
|
28
|
+
*
|
|
29
|
+
* @displayName PInputPercent
|
|
30
|
+
*/
|
|
23
31
|
defineOptions({
|
|
24
32
|
name: 'PInputPercent',
|
|
25
33
|
});
|
|
26
34
|
|
|
27
35
|
const props = defineProps({
|
|
36
|
+
/**
|
|
37
|
+
* The current value (v-model).
|
|
38
|
+
* Stored as a decimal (0.5 = 50%) but displayed as a percentage.
|
|
39
|
+
* Supports two-way binding for form inputs.
|
|
40
|
+
*/
|
|
28
41
|
modelValue: {
|
|
29
42
|
type: [Number, String] as PropType<number | string | null | undefined>,
|
|
30
43
|
default: null,
|
|
31
44
|
},
|
|
45
|
+
/**
|
|
46
|
+
* The size of the input field.
|
|
47
|
+
* Valid values: 'sm', 'md', 'lg'
|
|
48
|
+
* @values sm, md, lg
|
|
49
|
+
*/
|
|
32
50
|
size: {
|
|
33
51
|
type: String as PropType<Size>,
|
|
34
52
|
default: 'md',
|
|
35
53
|
},
|
|
36
54
|
});
|
|
37
55
|
|
|
38
|
-
const emit = defineEmits
|
|
56
|
+
const emit = defineEmits<{
|
|
57
|
+
/**
|
|
58
|
+
* Emitted when the percentage value changes.
|
|
59
|
+
* @param {number | null} value - The new decimal value
|
|
60
|
+
*/
|
|
61
|
+
'update:modelValue': [value: number | null];
|
|
62
|
+
}>();
|
|
39
63
|
|
|
40
64
|
const convertedValue = computed({
|
|
41
|
-
get: () => (isNumber(props.modelValue) ? props.modelValue * 100 : props.modelValue),
|
|
42
|
-
set: (nV) => emit('update:modelValue', isNumber(nV) ? nV / 100 : nV),
|
|
65
|
+
get: () => (isNumber(props.modelValue) ? props.modelValue * 100 : toNumberOrNull(props.modelValue)),
|
|
66
|
+
set: (nV) => emit('update:modelValue', isNumber(nV) ? nV / 100 : toNumberOrNull(nV)),
|
|
43
67
|
});
|
|
44
68
|
</script>
|
|
@@ -40,23 +40,47 @@ import PIcon from '@squirrel/components/p-icon/p-icon.vue';
|
|
|
40
40
|
import PInput from '@squirrel/components/p-input/p-input.vue';
|
|
41
41
|
import { type PropType, ref, useTemplateRef, watch } from 'vue';
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
/**
|
|
44
|
+
* A search input component that provides a specialized input field for search functionality.
|
|
45
|
+
* Features include a search icon prefix, optional enter key icon, clear button,
|
|
46
|
+
* and automatic focus management. Built on top of PInput with search-specific styling
|
|
47
|
+
* and behavior.
|
|
48
|
+
*
|
|
49
|
+
* @displayName PInputSearch
|
|
50
|
+
*/
|
|
45
51
|
defineOptions({
|
|
46
52
|
name: 'PInputSearch',
|
|
47
53
|
inheritAttrs: false,
|
|
48
54
|
});
|
|
49
55
|
|
|
56
|
+
type PInputInstance = InstanceType<typeof PInput>;
|
|
57
|
+
|
|
50
58
|
const emit = defineEmits<{
|
|
59
|
+
/**
|
|
60
|
+
* Emitted when the search query value changes.
|
|
61
|
+
* @param {string} value - The new search query
|
|
62
|
+
*/
|
|
51
63
|
'update:modelValue': [value: string];
|
|
64
|
+
/**
|
|
65
|
+
* Emitted when the enter key is pressed.
|
|
66
|
+
* @param {string} value - The current search query
|
|
67
|
+
*/
|
|
52
68
|
enter: [value: string];
|
|
53
69
|
}>();
|
|
54
70
|
|
|
55
71
|
const props = defineProps({
|
|
72
|
+
/**
|
|
73
|
+
* The search query value (v-model).
|
|
74
|
+
* Controls the input field content and visibility of the clear button.
|
|
75
|
+
*/
|
|
56
76
|
modelValue: {
|
|
57
77
|
type: String,
|
|
58
78
|
default: '',
|
|
59
79
|
},
|
|
80
|
+
/**
|
|
81
|
+
* The size of the search input.
|
|
82
|
+
* Affects the overall dimensions and icon positioning.
|
|
83
|
+
*/
|
|
60
84
|
size: {
|
|
61
85
|
type: String as PropType<Size>,
|
|
62
86
|
default: 'md',
|
|
@@ -64,6 +88,10 @@ const props = defineProps({
|
|
|
64
88
|
return SIZES.includes(value);
|
|
65
89
|
},
|
|
66
90
|
},
|
|
91
|
+
/**
|
|
92
|
+
* Whether to show the enter key icon when the input is focused.
|
|
93
|
+
* Provides visual feedback that pressing enter will trigger a search.
|
|
94
|
+
*/
|
|
67
95
|
showEnterIcon: {
|
|
68
96
|
type: Boolean,
|
|
69
97
|
default: false,
|
|
@@ -12,9 +12,22 @@ import { isExternalLink } from '@squirrel/utils/link';
|
|
|
12
12
|
import { sanitizeUrl } from '@squirrel/utils/sanitization';
|
|
13
13
|
import { RouterLink, type RouterLinkProps } from 'vue-router';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* A link component that intelligently handles both internal and external links.
|
|
17
|
+
* Automatically detects external URLs and renders them as anchor tags with
|
|
18
|
+
* proper security attributes, while internal links use Vue Router's RouterLink.
|
|
19
|
+
* Supports all RouterLink props for internal navigation.
|
|
20
|
+
*
|
|
21
|
+
* @displayName PLink
|
|
22
|
+
*/
|
|
15
23
|
defineOptions({
|
|
16
24
|
name: 'PLink',
|
|
17
25
|
});
|
|
18
26
|
|
|
27
|
+
/**
|
|
28
|
+
* All props from Vue Router's RouterLink component are supported.
|
|
29
|
+
* The component automatically handles external vs internal link detection
|
|
30
|
+
* and applies appropriate rendering and security measures.
|
|
31
|
+
*/
|
|
19
32
|
defineProps<RouterLinkProps>();
|
|
20
33
|
</script>
|
|
@@ -33,12 +33,19 @@ import { usePLoading } from '@squirrel/components/p-loading/usePLoading';
|
|
|
33
33
|
import { isComponent } from '@squirrel/utils/component';
|
|
34
34
|
import { onBeforeUnmount, ref, toValue, watch } from 'vue';
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* A loading component that displays a loading rectangle at the top center of the screen.
|
|
38
|
+
* Shows a customizable content area with smooth animations and dynamic sizing.
|
|
39
|
+
* Supports both text content and component content with automatic dimension calculation.
|
|
40
|
+
*
|
|
41
|
+
* @displayName PLoading
|
|
42
|
+
*/
|
|
38
43
|
defineOptions({
|
|
39
44
|
name: 'PLoading',
|
|
40
45
|
});
|
|
41
46
|
|
|
47
|
+
const textDivClass = `flex h-8 justify-center gap-x-1.5 overflow-hidden whitespace-nowrap px-6 pt-1 text-sm font-semibold text-p-purple-60`;
|
|
48
|
+
|
|
42
49
|
const { show, content, props: componentProps, loadingHide } = usePLoading();
|
|
43
50
|
const dimsReference = ref<HTMLElement | null>(null);
|
|
44
51
|
const width = ref(0);
|