@pequity/squirrel 8.4.4 → 8.5.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.
- package/README.md +31 -1
- package/dist/cjs/chunks/index.js +530 -179
- package/dist/cjs/chunks/p-alert.js +14 -16
- package/dist/cjs/chunks/p-avatar.js +16 -0
- package/dist/cjs/chunks/p-btn.js +4 -1
- 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 +15 -4
- 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 +72 -29
- package/dist/cjs/inputClasses.js +3 -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-icon.js +2 -1
- package/dist/cjs/p-input-search.js +13 -1
- package/dist/cjs/p-loading.js +3 -3
- package/dist/cjs/p-modal.js +125 -43
- 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 +32 -2
- package/dist/cjs/p-table-td.js +1 -1
- package/dist/cjs/p-table.js +2 -0
- package/dist/cjs/p-toggle.js +22 -1
- package/dist/cjs/usePTableHeaderWrap.js +38 -0
- package/dist/es/chunks/index.js +530 -179
- package/dist/es/chunks/p-alert.js +14 -16
- package/dist/es/chunks/p-avatar.js +16 -0
- package/dist/es/chunks/p-btn.js +5 -2
- 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 +15 -4
- 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 +77 -34
- package/dist/es/inputClasses.js +4 -4
- 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-icon.js +2 -1
- package/dist/es/p-input-search.js +13 -1
- package/dist/es/p-loading.js +3 -3
- package/dist/es/p-modal.js +125 -43
- 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 +32 -2
- package/dist/es/p-table-td.js +1 -1
- package/dist/es/p-table.js +2 -0
- package/dist/es/p-toggle.js +22 -1
- package/dist/es/usePTableHeaderWrap.js +38 -0
- package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +15 -3
- package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +18 -5
- package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +36 -1
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +21 -5
- package/dist/squirrel/components/p-card/p-card.vue.d.ts +21 -8
- package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +26 -8
- 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 +14 -1
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +17 -1
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +153 -15
- 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 +70 -2
- package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +71 -7
- package/dist/squirrel/components/p-icon/p-icon.types.d.ts +1 -0
- package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +5 -1
- package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +12 -5
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +28 -8
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +74 -9
- 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 +23 -3
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +25 -1
- package/dist/squirrel/components/p-link/p-link.vue.d.ts +1 -1
- package/dist/squirrel/components/p-loading/p-loading.vue.d.ts +1 -1
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +190 -16
- package/dist/squirrel/components/p-pagination/p-pagination.vue.d.ts +23 -13
- package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +17 -9
- package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +21 -1
- package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +11 -1
- package/dist/squirrel/components/p-select/p-select.vue.d.ts +77 -7
- package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +68 -11
- package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +2 -2
- 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 +13 -1
- package/dist/squirrel/components/p-table/p-table.types.d.ts +1 -0
- package/dist/squirrel/components/p-table/p-table.vue.d.ts +33 -1
- package/dist/squirrel/components/p-table/usePTableHeaderWrap.d.ts +4 -0
- package/dist/squirrel/components/p-table-header-cell/p-table-filter-icon.vue.d.ts +7 -1
- package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +59 -4
- package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +41 -1
- package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +13 -3
- package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +13 -1
- package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +34 -3
- package/dist/squirrel/components/p-tabs-pills/p-tabs-pills.vue.d.ts +23 -1
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +53 -9
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +51 -4
- package/dist/squirrel.css +68 -68
- package/package.json +24 -22
- 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.spec.js +4 -4
- package/squirrel/components/p-alert/p-alert.stories.js +19 -13
- package/squirrel/components/p-alert/p-alert.vue +33 -11
- 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.types.ts +1 -0
- 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-basic.spec.js +29 -3
- package/squirrel/components/p-modal/p-modal.vue +182 -35
- 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.spec.js +51 -15
- package/squirrel/components/p-table/p-table.types.ts +2 -0
- package/squirrel/components/p-table/p-table.vue +46 -4
- package/squirrel/components/p-table/usePTableHeaderWrap.spec.js +118 -0
- package/squirrel/components/p-table/usePTableHeaderWrap.ts +45 -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.spec.js +5 -1
- package/squirrel/components/p-table-header-cell/p-table-header-cell.vue +38 -1
- 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
|
@@ -224,6 +224,13 @@ import {
|
|
|
224
224
|
type AnyValue = string | number | boolean | null | undefined | Record<string, unknown>;
|
|
225
225
|
type AnyObject = Record<string, AnyValue>;
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* A dropdown select component with advanced features like search, multiple selection, and virtual scrolling.
|
|
229
|
+
* Provides a customizable dropdown interface with support for single/multiple selection, search filtering,
|
|
230
|
+
* pill display for multiple selections, and virtual scrolling for large datasets.
|
|
231
|
+
*
|
|
232
|
+
* @displayName PDropdownSelect
|
|
233
|
+
*/
|
|
227
234
|
defineOptions({
|
|
228
235
|
name: 'PDropdownSelect',
|
|
229
236
|
inheritAttrs: false,
|
|
@@ -241,6 +248,10 @@ defineSlots<{
|
|
|
241
248
|
const emit = defineEmits(['update:modelValue', 'select', 'create']);
|
|
242
249
|
|
|
243
250
|
const props = defineProps({
|
|
251
|
+
/**
|
|
252
|
+
* The selected value(s) for the dropdown (v-model).
|
|
253
|
+
* Can be a single value or array of values depending on multiple prop.
|
|
254
|
+
*/
|
|
244
255
|
modelValue: {
|
|
245
256
|
type: [String, Number, Boolean, Array, Object] as PropType<ModelValue>,
|
|
246
257
|
default: null,
|
|
@@ -262,18 +273,30 @@ const props = defineProps({
|
|
|
262
273
|
type: Array as PropType<AnyValue[] | AnyObject[]>,
|
|
263
274
|
default: () => [],
|
|
264
275
|
},
|
|
276
|
+
/**
|
|
277
|
+
* Label text displayed above the dropdown.
|
|
278
|
+
*/
|
|
265
279
|
label: {
|
|
266
280
|
type: String,
|
|
267
281
|
default: '',
|
|
268
282
|
},
|
|
283
|
+
/**
|
|
284
|
+
* Error message to display below the dropdown.
|
|
285
|
+
*/
|
|
269
286
|
errorMsg: {
|
|
270
287
|
type: String,
|
|
271
288
|
default: '',
|
|
272
289
|
},
|
|
290
|
+
/**
|
|
291
|
+
* Whether the field is required.
|
|
292
|
+
*/
|
|
273
293
|
required: {
|
|
274
294
|
type: Boolean,
|
|
275
295
|
default: false,
|
|
276
296
|
},
|
|
297
|
+
/**
|
|
298
|
+
* The size of the dropdown component.
|
|
299
|
+
*/
|
|
277
300
|
size: {
|
|
278
301
|
type: String as PropType<Size>,
|
|
279
302
|
default: 'md',
|
|
@@ -310,26 +333,44 @@ const props = defineProps({
|
|
|
310
333
|
type: Number,
|
|
311
334
|
default: 7,
|
|
312
335
|
},
|
|
336
|
+
/**
|
|
337
|
+
* Additional attributes to apply to the dropdown menu.
|
|
338
|
+
*/
|
|
313
339
|
dropdownMenuAttrs: {
|
|
314
340
|
type: Object,
|
|
315
341
|
default: () => ({}),
|
|
316
342
|
},
|
|
343
|
+
/**
|
|
344
|
+
* CSS classes to apply to the dropdown menu.
|
|
345
|
+
*/
|
|
317
346
|
dropdownMenuClass: {
|
|
318
347
|
type: String,
|
|
319
348
|
default: 'overflow-x-hidden',
|
|
320
349
|
},
|
|
350
|
+
/**
|
|
351
|
+
* Inline styles to apply to the dropdown menu.
|
|
352
|
+
*/
|
|
321
353
|
dropdownMenuStyle: {
|
|
322
354
|
type: Object,
|
|
323
355
|
default: () => ({}),
|
|
324
356
|
},
|
|
357
|
+
/**
|
|
358
|
+
* Props to pass to the underlying PDropdown component.
|
|
359
|
+
*/
|
|
325
360
|
pDropdownProps: {
|
|
326
361
|
type: Object,
|
|
327
362
|
default: () => ({}),
|
|
328
363
|
},
|
|
364
|
+
/**
|
|
365
|
+
* Whether to enable search functionality within the dropdown.
|
|
366
|
+
*/
|
|
329
367
|
searchable: {
|
|
330
368
|
type: Boolean,
|
|
331
369
|
default: false,
|
|
332
370
|
},
|
|
371
|
+
/**
|
|
372
|
+
* Whether to show a clear button when items are selected.
|
|
373
|
+
*/
|
|
333
374
|
clearable: {
|
|
334
375
|
type: Boolean,
|
|
335
376
|
default: false,
|
|
@@ -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>
|