@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.
Files changed (151) hide show
  1. package/README.md +2 -1
  2. package/dist/cjs/chunks/p-alert.js +3 -0
  3. package/dist/cjs/chunks/p-avatar.js +16 -0
  4. package/dist/cjs/chunks/p-btn.js +3 -0
  5. package/dist/cjs/chunks/p-card.js +4 -0
  6. package/dist/cjs/chunks/p-dropdown-select.js +34 -0
  7. package/dist/cjs/chunks/p-input-number.js +32 -0
  8. package/dist/cjs/chunks/p-input-percent.js +13 -2
  9. package/dist/cjs/chunks/p-input.js +28 -0
  10. package/dist/cjs/chunks/p-pagination-info.js +9 -5
  11. package/dist/cjs/chunks/p-pagination.js +23 -13
  12. package/dist/cjs/chunks/p-select-btn.js +2 -1
  13. package/dist/cjs/chunks/p-select.js +33 -0
  14. package/dist/cjs/chunks/p-table-loader.js +20 -0
  15. package/dist/cjs/chunks/p-tabs.js +12 -0
  16. package/dist/cjs/chunks/p-textarea.js +20 -0
  17. package/dist/cjs/index.js +40 -3
  18. package/dist/cjs/p-checkbox.js +8 -1
  19. package/dist/cjs/p-chips.js +17 -1
  20. package/dist/cjs/p-close-btn.js +6 -1
  21. package/dist/cjs/p-drawer.js +90 -2
  22. package/dist/cjs/p-dropdown.js +2 -1
  23. package/dist/cjs/p-input-search.js +13 -1
  24. package/dist/cjs/p-loading.js +1 -1
  25. package/dist/cjs/p-modal.js +82 -2
  26. package/dist/cjs/p-select-pill.js +36 -2
  27. package/dist/cjs/p-skeleton-loader.js +17 -1
  28. package/dist/cjs/p-table-filter-icon.js +4 -1
  29. package/dist/cjs/p-table-header-cell.js +29 -0
  30. package/dist/cjs/p-table-td.js +1 -1
  31. package/dist/cjs/p-toggle.js +22 -1
  32. package/dist/es/chunks/p-alert.js +3 -0
  33. package/dist/es/chunks/p-avatar.js +16 -0
  34. package/dist/es/chunks/p-btn.js +3 -0
  35. package/dist/es/chunks/p-card.js +4 -0
  36. package/dist/es/chunks/p-dropdown-select.js +34 -0
  37. package/dist/es/chunks/p-input-number.js +32 -0
  38. package/dist/es/chunks/p-input-percent.js +13 -2
  39. package/dist/es/chunks/p-input.js +28 -0
  40. package/dist/es/chunks/p-pagination-info.js +9 -5
  41. package/dist/es/chunks/p-pagination.js +24 -14
  42. package/dist/es/chunks/p-select-btn.js +2 -1
  43. package/dist/es/chunks/p-select.js +33 -0
  44. package/dist/es/chunks/p-table-loader.js +20 -0
  45. package/dist/es/chunks/p-tabs.js +12 -0
  46. package/dist/es/chunks/p-textarea.js +20 -0
  47. package/dist/es/index.js +40 -3
  48. package/dist/es/p-checkbox.js +8 -1
  49. package/dist/es/p-chips.js +17 -1
  50. package/dist/es/p-close-btn.js +6 -1
  51. package/dist/es/p-drawer.js +90 -2
  52. package/dist/es/p-dropdown.js +2 -1
  53. package/dist/es/p-input-search.js +13 -1
  54. package/dist/es/p-loading.js +1 -1
  55. package/dist/es/p-modal.js +82 -2
  56. package/dist/es/p-select-pill.js +36 -2
  57. package/dist/es/p-skeleton-loader.js +17 -1
  58. package/dist/es/p-table-filter-icon.js +4 -1
  59. package/dist/es/p-table-header-cell.js +29 -0
  60. package/dist/es/p-table-td.js +1 -1
  61. package/dist/es/p-toggle.js +22 -1
  62. package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +14 -2
  63. package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +16 -3
  64. package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +35 -0
  65. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +18 -2
  66. package/dist/squirrel/components/p-card/p-card.vue.d.ts +20 -7
  67. package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +25 -7
  68. package/dist/squirrel/components/p-chips/p-chips.vue.d.ts +24 -0
  69. package/dist/squirrel/components/p-close-btn/p-close-btn.vue.d.ts +13 -0
  70. package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +16 -0
  71. package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +141 -3
  72. package/dist/squirrel/components/p-dropdown/p-dropdown.vue.d.ts +11 -2
  73. package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +69 -1
  74. package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +70 -6
  75. package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +4 -0
  76. package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +11 -4
  77. package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +27 -7
  78. package/dist/squirrel/components/p-input/p-input.vue.d.ts +73 -8
  79. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +83 -12
  80. package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +22 -2
  81. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +24 -0
  82. package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +185 -15
  83. package/dist/squirrel/components/p-pagination/p-pagination.vue.d.ts +22 -12
  84. package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +16 -8
  85. package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +20 -0
  86. package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +10 -0
  87. package/dist/squirrel/components/p-select/p-select.vue.d.ts +76 -6
  88. package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +67 -10
  89. package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +1 -1
  90. package/dist/squirrel/components/p-select-pill/p-select-pill.vue.d.ts +72 -2
  91. package/dist/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue.d.ts +40 -0
  92. package/dist/squirrel/components/p-steps/p-steps.vue.d.ts +12 -0
  93. package/dist/squirrel/components/p-table/p-table.vue.d.ts +32 -0
  94. package/dist/squirrel/components/p-table-header-cell/p-table-filter-icon.vue.d.ts +6 -0
  95. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +56 -1
  96. package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +40 -0
  97. package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +12 -2
  98. package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +12 -0
  99. package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +33 -2
  100. package/dist/squirrel/components/p-tabs-pills/p-tabs-pills.vue.d.ts +22 -0
  101. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +52 -8
  102. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +50 -3
  103. package/dist/squirrel.css +68 -68
  104. package/package.json +15 -15
  105. package/squirrel/components/p-action-bar/p-action-bar.stories.js +5 -5
  106. package/squirrel/components/p-action-bar/p-action-bar.vue +30 -3
  107. package/squirrel/components/p-alert/p-alert.vue +24 -0
  108. package/squirrel/components/p-avatar/p-avatar.vue +28 -0
  109. package/squirrel/components/p-btn/p-btn.vue +35 -0
  110. package/squirrel/components/p-card/p-card.vue +24 -1
  111. package/squirrel/components/p-checkbox/p-checkbox.vue +23 -1
  112. package/squirrel/components/p-chips/p-chips.vue +24 -0
  113. package/squirrel/components/p-close-btn/p-close-btn.vue +15 -0
  114. package/squirrel/components/p-date-picker/p-date-picker.vue +23 -1
  115. package/squirrel/components/p-drawer/p-drawer.vue +95 -0
  116. package/squirrel/components/p-dropdown/p-dropdown.vue +12 -1
  117. package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +41 -0
  118. package/squirrel/components/p-file-upload/p-file-upload.vue +58 -3
  119. package/squirrel/components/p-icon/p-icon.vue +16 -0
  120. package/squirrel/components/p-info-icon/p-info-icon.vue +19 -0
  121. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue +32 -0
  122. package/squirrel/components/p-input/p-input.vue +61 -1
  123. package/squirrel/components/p-input-number/p-input-number.vue +78 -1
  124. package/squirrel/components/p-input-percent/p-input-percent.vue +27 -3
  125. package/squirrel/components/p-input-search/p-input-search.vue +30 -2
  126. package/squirrel/components/p-link/p-link.vue +13 -0
  127. package/squirrel/components/p-loading/p-loading.vue +9 -2
  128. package/squirrel/components/p-modal/p-modal.vue +138 -2
  129. package/squirrel/components/p-pagination/p-pagination.vue +28 -8
  130. package/squirrel/components/p-pagination-info/p-pagination-info.vue +16 -4
  131. package/squirrel/components/p-progress-bar/p-progress-bar.vue +31 -4
  132. package/squirrel/components/p-ring-loader/p-ring-loader.vue +17 -0
  133. package/squirrel/components/p-select/p-select.vue +50 -1
  134. package/squirrel/components/p-select-btn/p-select-btn.vue +90 -2
  135. package/squirrel/components/p-select-list/p-select-list.vue +7 -0
  136. package/squirrel/components/p-select-pill/p-select-pill.vue +52 -2
  137. package/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue +24 -0
  138. package/squirrel/components/p-steps/p-steps.vue +25 -0
  139. package/squirrel/components/p-table/p-table.vue +39 -0
  140. package/squirrel/components/p-table-header-cell/p-table-filter-icon.vue +9 -0
  141. package/squirrel/components/p-table-header-cell/p-table-header-cell.vue +36 -0
  142. package/squirrel/components/p-table-loader/p-table-loader.vue +28 -0
  143. package/squirrel/components/p-table-sort/p-table-sort.vue +19 -1
  144. package/squirrel/components/p-table-td/p-table-td.vue +20 -0
  145. package/squirrel/components/p-tabs/p-tabs.stories.js +2 -2
  146. package/squirrel/components/p-tabs/p-tabs.vue +33 -1
  147. package/squirrel/components/p-tabs-pills/p-tabs-pills.vue +33 -0
  148. package/squirrel/components/p-textarea/p-textarea.vue +43 -1
  149. package/squirrel/components/p-toggle/p-toggle.vue +44 -1
  150. package/squirrel/assets/pagination-left-icon.svg +0 -5
  151. package/squirrel/assets/pagination-right-icon.svg +0 -5
@@ -90,99 +90,235 @@ const FOCUSABLE_ELEMENTS =
90
90
  'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';
91
91
  let animatingZIndex = 0;
92
92
 
93
+ /**
94
+ * A modal dialog component with advanced features like animations, focus management, and accessibility.
95
+ * Provides a teleported modal interface with backdrop, customizable styling, and lifecycle events.
96
+ * Supports both controlled and uncontrolled modes with proper keyboard navigation.
97
+ *
98
+ * @displayName PModal
99
+ */
93
100
  defineOptions({
94
101
  name: 'PModal',
95
102
  });
96
103
 
104
+ defineSlots<{
105
+ /**
106
+ * Default content slot for the modal body.
107
+ */
108
+ default?: () => unknown;
109
+ /**
110
+ * Custom title wrapper content.
111
+ */
112
+ 'title-wrapper'?: () => unknown;
113
+ /**
114
+ * Custom content wrapper.
115
+ */
116
+ 'content-wrapper'?: () => unknown;
117
+ /**
118
+ * Custom footer content.
119
+ */
120
+ footer?: () => unknown;
121
+ /**
122
+ * Custom footer wrapper.
123
+ */
124
+ 'footer-wrapper'?: () => unknown;
125
+ }>();
126
+
97
127
  const emit = defineEmits<{
128
+ /**
129
+ * Emitted before the modal starts opening.
130
+ */
98
131
  'before-open': [];
132
+ /**
133
+ * Emitted when the modal is opening (animation in progress).
134
+ */
99
135
  opening: [];
136
+ /**
137
+ * Emitted when the modal has finished opening.
138
+ */
100
139
  opened: [];
140
+ /**
141
+ * Emitted before the modal starts closing.
142
+ */
101
143
  'before-close': [];
144
+ /**
145
+ * Emitted when the modal is closing (animation in progress).
146
+ */
102
147
  closing: [];
148
+ /**
149
+ * Emitted when the modal has finished closing.
150
+ */
103
151
  closed: [];
104
- 'update:modelValue': [boolean];
105
- 'click:overlay': [MouseEvent];
152
+ /**
153
+ * Emitted when the modal visibility changes (v-model).
154
+ * @param {boolean} value - The new visibility state
155
+ */
156
+ 'update:modelValue': [value: boolean];
157
+ /**
158
+ * Emitted when the backdrop is clicked.
159
+ * @param {MouseEvent} event - The click event
160
+ */
161
+ 'click:overlay': [event: MouseEvent];
106
162
  }>();
107
163
 
108
164
  const props = defineProps({
165
+ /**
166
+ * Unique name for the modal when using the modal service.
167
+ * Used for programmatic control of the modal.
168
+ */
109
169
  name: {
110
170
  type: String,
111
171
  default: '',
112
172
  },
173
+ /**
174
+ * Title displayed in the modal header.
175
+ * Used for accessibility and visual identification.
176
+ */
113
177
  title: {
114
178
  type: String,
115
179
  default: '',
116
180
  },
181
+ /**
182
+ * Base z-index for the modal.
183
+ * Higher values ensure the modal appears above other content.
184
+ */
117
185
  baseZindex: {
118
186
  type: Number,
119
187
  default: 1051,
120
188
  },
189
+ /**
190
+ * CSS classes for the backdrop element.
191
+ * Controls the appearance of the modal overlay.
192
+ */
121
193
  bgClass: {
122
194
  type: [String, Object, Array] as PropType<StyleValue>,
123
195
  default: 'fixed bottom-0 left-0 right-0 top-0 bg-black/20',
124
196
  },
197
+ /**
198
+ * CSS classes for the modal wrapper element.
199
+ * Controls the positioning and layout of the modal container.
200
+ */
125
201
  wrapperClass: {
126
202
  type: [String, Object, Array] as PropType<StyleValue>,
127
203
  default:
128
204
  'fixed bottom-0 left-0 right-0 top-0 flex flex-col items-center justify-center overflow-y-auto overflow-x-hidden outline-none',
129
205
  },
206
+ /**
207
+ * Base CSS classes for the modal content.
208
+ * Controls the appearance of the modal dialog itself.
209
+ */
130
210
  modalBaseClass: {
131
211
  type: [String, Object, Array] as PropType<StyleValue>,
132
212
  default: 'pm relative flex flex-col rounded-2xl pb-6 cursor-default bg-surface shadow-xl',
133
213
  },
214
+ /**
215
+ * Additional CSS classes for the modal content.
216
+ * Merged with modalBaseClass for custom styling.
217
+ */
134
218
  modalClass: {
135
219
  type: [String, Object, Array] as PropType<StyleValue>,
136
220
  default: '',
137
221
  },
222
+ /**
223
+ * Inline styles for the modal content.
224
+ * Applied directly to the modal element.
225
+ */
138
226
  modalStyle: {
139
227
  type: [String, Object, Array] as PropType<StyleValue>,
140
228
  default: '',
141
229
  },
230
+ /**
231
+ * CSS class for the modal entrance animation.
232
+ * Controls how the modal appears.
233
+ */
142
234
  inClass: {
143
235
  type: String,
144
236
  default: 'slideInTop',
145
237
  },
238
+ /**
239
+ * CSS class for the modal exit animation.
240
+ * Controls how the modal disappears.
241
+ */
146
242
  outClass: {
147
243
  type: String,
148
244
  default: 'slideOutTop',
149
245
  },
246
+ /**
247
+ * CSS class for the backdrop entrance animation.
248
+ * Controls how the backdrop appears.
249
+ */
150
250
  bgInClass: {
151
251
  type: String,
152
252
  default: 'fadeIn',
153
253
  },
254
+ /**
255
+ * CSS class for the backdrop exit animation.
256
+ * Controls how the backdrop disappears.
257
+ */
154
258
  bgOutClass: {
155
259
  type: String,
156
260
  default: 'fadeOut',
157
261
  },
262
+ /**
263
+ * Target element to append the modal to.
264
+ * Usually 'body' for proper z-index stacking.
265
+ */
158
266
  appendTo: {
159
267
  type: String,
160
268
  default: 'body',
161
269
  },
270
+ /**
271
+ * Whether the modal should be mounted immediately.
272
+ * Useful for modals that are always present in the DOM.
273
+ */
162
274
  live: {
163
275
  type: Boolean,
164
276
  default: false,
165
277
  },
278
+ /**
279
+ * Whether the modal can be closed by user interaction.
280
+ * Controls close button visibility and backdrop click behavior.
281
+ */
166
282
  enableClose: {
167
283
  type: Boolean,
168
284
  default: true,
169
285
  },
286
+ /**
287
+ * Controls the visibility of the modal (v-model).
288
+ * Supports two-way binding for modal state.
289
+ */
170
290
  modelValue: {
171
291
  type: Boolean,
172
292
  default: false,
173
293
  },
294
+ /**
295
+ * Accessibility label for the close button.
296
+ * Used by screen readers for better accessibility.
297
+ */
174
298
  closeLabel: {
175
299
  type: String,
176
300
  default: 'Close',
177
301
  },
302
+ /**
303
+ * Whether the modal content is disabled.
304
+ * Prevents user interaction with modal content.
305
+ */
178
306
  disabled: {
179
307
  type: Boolean,
180
308
  default: false,
181
309
  },
310
+ /**
311
+ * Error message to display in the modal.
312
+ * Shows an error alert above the modal content.
313
+ */
182
314
  errorMsg: {
183
315
  type: String,
184
316
  default: '',
185
317
  },
318
+ /**
319
+ * Maximum width of the modal.
320
+ * Controls the responsive behavior of the modal.
321
+ */
186
322
  maxWidth: {
187
323
  type: String,
188
324
  default: '500px',
@@ -6,7 +6,7 @@
6
6
  aria-label="go to the previous page"
7
7
  @click="setPage(Number(modelValue) - 1)"
8
8
  >
9
- <img src="@squirrel/assets/pagination-left-icon.svg" />
9
+ <PIcon icon="chevron-left" width="24px" />
10
10
  </div>
11
11
  <div v-for="(page, index) in pages" :key="index" @click="setPage(Number(page))">
12
12
  <div class="flex">
@@ -25,51 +25,71 @@
25
25
  aria-label="go to the next page"
26
26
  @click="setPage(Number(modelValue) + 1)"
27
27
  >
28
- <img src="@squirrel/assets/pagination-right-icon.svg" />
28
+ <PIcon icon="chevron-right" width="24px" />
29
29
  </div>
30
30
  </div>
31
31
  </template>
32
32
 
33
33
  <script setup lang="ts">
34
+ import PIcon from '@squirrel/components/p-icon/p-icon.vue';
34
35
  import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
35
36
  import { createPagingRange } from '@squirrel/utils/pagination';
36
37
  import { computed, type PropType } from 'vue';
37
38
 
39
+ /**
40
+ * A pagination component that displays page numbers with navigation controls.
41
+ * Provides a complete pagination interface with previous/next buttons, page numbers,
42
+ * loading states, and ellipsis for large page ranges.
43
+ * Supports customizable page sizes and offset ranges for optimal display.
44
+ *
45
+ * @displayName PPagination
46
+ */
38
47
  defineOptions({ name: 'PPagination' });
39
48
 
40
- const emit = defineEmits(['update:modelValue']);
49
+ const emit = defineEmits<{
50
+ /**
51
+ * Emitted when the current page changes.
52
+ * @param {number} value - The new page number
53
+ */
54
+ 'update:modelValue': [value: number];
55
+ }>();
41
56
 
42
57
  const props = defineProps({
43
58
  /**
44
- * The current page.
59
+ * The current page number (v-model).
60
+ * Controls which page is visually active and navigable.
45
61
  */
46
62
  modelValue: {
47
63
  type: Number as PropType<number | null>,
48
64
  default: null,
49
65
  },
50
66
  /**
51
- * The amount of data pagination should iterate through.
67
+ * The total amount of items to paginate through.
68
+ * Used to calculate the total number of pages.
52
69
  */
53
70
  count: {
54
71
  type: Number,
55
72
  default: 0,
56
73
  },
57
74
  /**
58
- * The amount of data to be displayed at 1 page. Used to calculate the length of pagination.
75
+ * The number of items to display per page.
76
+ * Used to calculate the total number of pages.
59
77
  */
60
78
  pageSize: {
61
79
  type: Number,
62
80
  default: 10,
63
81
  },
64
82
  /**
65
- * The amount of pages to be displayed before and after the current page.
83
+ * The number of pages to show before and after the current page.
84
+ * Controls the range of page numbers displayed around the current page.
66
85
  */
67
86
  pageOffset: {
68
87
  type: Number,
69
88
  default: 2,
70
89
  },
71
90
  /**
72
- * Whether the pagination is loading.
91
+ * Whether the pagination is in a loading state.
92
+ * When true, shows a skeleton loader instead of the pagination controls.
73
93
  */
74
94
  loading: {
75
95
  type: Boolean,
@@ -10,32 +10,44 @@
10
10
  import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
11
11
  import { computed } from 'vue';
12
12
 
13
+ /**
14
+ * A pagination info component that displays current page information and result counts.
15
+ * Shows the range of items being displayed (e.g., "Showing 1 to 10 of 100 results")
16
+ * and provides a customizable slot for when no results are found.
17
+ * Includes loading state with skeleton loader.
18
+ *
19
+ * @displayName PPaginationInfo
20
+ */
13
21
  defineOptions({ name: 'PPaginationInfo' });
14
22
 
15
23
  const props = defineProps({
16
24
  /**
17
- * The current page.
25
+ * The current page number (1-based).
26
+ * Used to calculate the starting item number in the display range.
18
27
  */
19
28
  currentPage: {
20
29
  type: Number,
21
30
  default: 0,
22
31
  },
23
32
  /**
24
- * The amount of data pagination iterates through.
33
+ * The total number of items across all pages.
34
+ * Used to calculate the total count and ending item number.
25
35
  */
26
36
  count: {
27
37
  type: Number,
28
38
  default: 0,
29
39
  },
30
40
  /**
31
- * The amount of data to be displayed at 1 page. Used to calculate the `from` and `to` limits.
41
+ * The number of items displayed per page.
42
+ * Used to calculate the `from` and `to` limits for the current page.
32
43
  */
33
44
  pageSize: {
34
45
  type: Number,
35
46
  default: 0,
36
47
  },
37
48
  /**
38
- * Whether the pagination is loading.
49
+ * Whether the pagination data is loading.
50
+ * When true, shows a skeleton loader instead of the info text.
39
51
  */
40
52
  loading: {
41
53
  type: Boolean,
@@ -11,20 +11,47 @@
11
11
  </template>
12
12
 
13
13
  <script setup lang="ts">
14
+ /**
15
+ * A progress bar component that displays multiple progress segments with different colors.
16
+ * Each segment represents a portion of the total progress and can have its own color
17
+ * and optional label. Useful for showing complex progress states or multi-part progress.
18
+ *
19
+ * @displayName PProgressBar
20
+ */
21
+ defineOptions({
22
+ name: 'PProgressBar',
23
+ });
24
+
25
+ /**
26
+ * Represents a single progress segment with its value, color, and optional label.
27
+ */
14
28
  export type ProgressItem = {
29
+ /**
30
+ * The numeric value of this progress segment.
31
+ */
15
32
  value: number;
33
+ /**
34
+ * The background color for this progress segment.
35
+ */
16
36
  color: string;
37
+ /**
38
+ * Optional label to display on hover tooltip.
39
+ */
17
40
  label?: string;
18
41
  };
19
42
 
20
43
  type Props = {
44
+ /**
45
+ * The total value used to calculate percentage widths.
46
+ * All segment values should sum to this total for accurate representation.
47
+ */
21
48
  total: number;
49
+ /**
50
+ * Array of progress segments to display.
51
+ * Each item represents a portion of the total progress.
52
+ */
22
53
  items: ProgressItem[];
23
54
  };
24
55
 
25
- defineOptions({
26
- name: 'PProgressBar',
27
- });
28
-
29
56
  defineProps<Props>();
30
57
  </script>
@@ -6,12 +6,29 @@
6
6
  import PIcon from '@squirrel/components/p-icon/p-icon.vue';
7
7
  import { computed } from 'vue';
8
8
 
9
+ /**
10
+ * A ring loader component that displays a spinning ring animation.
11
+ * Provides a consistent loading indicator with customizable size and color.
12
+ * Uses an SVG spinner icon with smooth animation.
13
+ *
14
+ * @displayName PRingLoader
15
+ */
9
16
  defineOptions({
10
17
  name: 'PRingLoader',
11
18
  });
12
19
 
13
20
  type Props = {
21
+ /**
22
+ * The size of the ring loader in pixels.
23
+ * Controls the overall dimensions of the spinner.
24
+ * Default: 80px
25
+ */
14
26
  size?: number;
27
+ /**
28
+ * Custom color for the ring loader.
29
+ * Overrides the default blue color when provided.
30
+ * Can be any valid CSS color value.
31
+ */
15
32
  color?: string;
16
33
  };
17
34
 
@@ -20,6 +20,14 @@ import { useInputClasses } from '@squirrel/composables/useInputClasses';
20
20
  import { type PropType, type StyleValue } from 'vue';
21
21
  import { computed, useAttrs } from 'vue';
22
22
 
23
+ /**
24
+ * A select dropdown component for choosing from a list of options.
25
+ * Provides consistent styling and behavior with other form components.
26
+ * Supports custom labels, error states, and flexible item structure.
27
+ * Automatically handles null values and boolean conversions.
28
+ *
29
+ * @displayName PSelect
30
+ */
23
31
  defineOptions({
24
32
  name: 'PSelect',
25
33
  inheritAttrs: false,
@@ -27,27 +35,61 @@ defineOptions({
27
35
 
28
36
  const emit = defineEmits(['update:modelValue']);
29
37
 
38
+ defineSlots<{
39
+ /**
40
+ * Custom label content - overrides the label prop.
41
+ * @param {string} label - The label text
42
+ * @param {string} label-classes - CSS classes for the label
43
+ */
44
+ label?: (props: { label: string; labelClasses: string }) => unknown;
45
+ }>();
46
+
30
47
  const props = defineProps({
48
+ /**
49
+ * The current selected value (v-model).
50
+ * Supports two-way binding for form inputs.
51
+ */
31
52
  modelValue: {
32
53
  type: [String, Number, Boolean, null] as PropType<string | number | boolean | null>,
33
54
  default: '',
34
55
  },
56
+ /**
57
+ * Array of objects representing the select options.
58
+ * Each object should have properties specified by itemText and itemValue.
59
+ * @example [{ text: 'Option 1', value: 1 }, { text: 'Option 2', value: 2 }]
60
+ */
35
61
  items: {
36
62
  type: Array as PropType<Record<string, unknown>[]>,
37
63
  default: () => [],
38
64
  },
65
+ /**
66
+ * Text label for the select field.
67
+ * If not provided, you can use the label slot instead.
68
+ */
39
69
  label: {
40
70
  type: String,
41
71
  default: '',
42
72
  },
73
+ /**
74
+ * Error message to display below the select.
75
+ * When provided, the select will show error styling.
76
+ */
43
77
  errorMsg: {
44
78
  type: String,
45
79
  default: '',
46
80
  },
81
+ /**
82
+ * Whether the select is required.
83
+ * Adds required attribute and visual indicator.
84
+ */
47
85
  required: {
48
86
  type: Boolean,
49
87
  default: false,
50
88
  },
89
+ /**
90
+ * The size of the select - affects padding, font size, and spacing.
91
+ * Valid values: 'sm', 'md', 'lg'
92
+ */
51
93
  size: {
52
94
  type: String as PropType<Size>,
53
95
  default: 'md',
@@ -55,10 +97,18 @@ const props = defineProps({
55
97
  return SIZES.includes(value);
56
98
  },
57
99
  },
100
+ /**
101
+ * Property name to use as the display text for each option.
102
+ * Defaults to 'text' - each item should have this property.
103
+ */
58
104
  itemText: {
59
105
  type: String,
60
106
  default: 'text',
61
107
  },
108
+ /**
109
+ * Property name to use as the value for each option.
110
+ * Defaults to 'value' - each item should have this property.
111
+ */
62
112
  itemValue: {
63
113
  type: [String, Number, Boolean, null] as PropType<string | number | boolean | null>,
64
114
  default: 'value',
@@ -98,7 +148,6 @@ const innerOptions = computed(() => {
98
148
  });
99
149
  });
100
150
 
101
- // Methods
102
151
  const onChange = (e: Event) => {
103
152
  const value = (e.target as HTMLSelectElement).value;
104
153
 
@@ -31,19 +31,71 @@
31
31
  import { type Size } from '@squirrel/components/p-btn/p-btn.types';
32
32
  import PBtn from '@squirrel/components/p-btn/p-btn.vue';
33
33
 
34
+ /**
35
+ * A select button group component that displays multiple buttons as a connected group.
36
+ * Provides a button-based selection interface with support for single/multiple selection,
37
+ * custom styling, tooltips, and flexible item structure.
38
+ *
39
+ * @displayName PSelectBtn
40
+ */
34
41
  type BtnGroupItem = Record<string, string | number | boolean>;
35
42
 
36
43
  type Props = {
37
- modelValue?: string | number | null | BtnGroupItem[];
44
+ /**
45
+ * The current selected value(s) (v-model).
46
+ * For single selection: string, number, boolean, or null
47
+ * For multiple selection: array of BtnGroupItem objects
48
+ */
49
+ modelValue?: string | number | boolean | null | BtnGroupItem[];
50
+ /**
51
+ * Array of items to display as buttons.
52
+ * Each item should have properties matching itemValue, itemText, and itemTooltipText.
53
+ */
38
54
  items?: BtnGroupItem[] | readonly BtnGroupItem[];
55
+ /**
56
+ * Property name to use as the item value.
57
+ * Used for selection comparison and v-model binding.
58
+ */
39
59
  itemValue?: string | number;
60
+ /**
61
+ * Property name to use as the item display text.
62
+ * Used for button label content.
63
+ */
40
64
  itemText?: string;
65
+ /**
66
+ * Property name to use as the item tooltip text.
67
+ * Used when showTooltip is enabled.
68
+ */
41
69
  itemTooltipText?: string;
70
+ /**
71
+ * The size of the buttons in the group.
72
+ * Valid values: 'sm', 'md', 'lg'
73
+ */
42
74
  size?: Size;
75
+ /**
76
+ * Whether to show tooltips on button hover.
77
+ * Uses the itemTooltipText property for tooltip content.
78
+ */
43
79
  showTooltip?: boolean;
80
+ /**
81
+ * Whether to highlight selected buttons visually.
82
+ * Applies selected styling to chosen buttons.
83
+ */
44
84
  highlightSelected?: boolean;
85
+ /**
86
+ * Whether buttons should grow to fill available space.
87
+ * Makes all buttons equal width within the container.
88
+ */
45
89
  grow?: boolean;
90
+ /**
91
+ * Whether multiple items can be selected simultaneously.
92
+ * When true, modelValue becomes an array of selected items.
93
+ */
46
94
  multiple?: boolean;
95
+ /**
96
+ * Whether to remove padding from button containers.
97
+ * Useful for custom spacing control.
98
+ */
47
99
  noPadding?: boolean;
48
100
  };
49
101
 
@@ -51,7 +103,23 @@ defineOptions({
51
103
  name: 'PSelectBtn',
52
104
  });
53
105
 
54
- const emit = defineEmits(['update:modelValue']);
106
+ defineSlots<{
107
+ /**
108
+ * Custom content for each button in the group.
109
+ * Overrides the default item text display.
110
+ * @param {BtnGroupItem} item - The current item data
111
+ * @param {boolean} isSelected - Whether the current item is selected
112
+ */
113
+ [key: `btn-${number}`]: (props: { item: BtnGroupItem; isSelected: boolean }) => unknown;
114
+ }>();
115
+
116
+ const emit = defineEmits<{
117
+ /**
118
+ * Emitted when the selection changes.
119
+ * @param {string | number | boolean | null | BtnGroupItem[]} value - The new selected value(s)
120
+ */
121
+ 'update:modelValue': [value: string | number | boolean | null | BtnGroupItem[]];
122
+ }>();
55
123
 
56
124
  // Props
57
125
  const props = withDefaults(defineProps<Props>(), {
@@ -69,10 +137,22 @@ const props = withDefaults(defineProps<Props>(), {
69
137
  });
70
138
 
71
139
  // Methods
140
+ /**
141
+ * Gets the tooltip text for a given item.
142
+ * Returns the item's tooltip text if showTooltip is enabled, otherwise empty string.
143
+ * @param {BtnGroupItem} item - The item to get tooltip text for
144
+ * @returns {string} The tooltip text or empty string
145
+ */
72
146
  const tooltipText = (item: BtnGroupItem) => {
73
147
  return props.showTooltip ? item[props.itemTooltipText] : '';
74
148
  };
75
149
 
150
+ /**
151
+ * Handles item selection based on single/multiple mode.
152
+ * For single selection: emits the item value directly.
153
+ * For multiple selection: toggles the item in the selection array.
154
+ * @param {BtnGroupItem} item - The item being selected
155
+ */
76
156
  const select = (item: BtnGroupItem) => {
77
157
  if (!props.multiple) {
78
158
  emit('update:modelValue', item[props.itemValue]);
@@ -95,6 +175,13 @@ const select = (item: BtnGroupItem) => {
95
175
  }
96
176
  };
97
177
 
178
+ /**
179
+ * Checks if a given item is currently selected.
180
+ * For single selection: compares with modelValue directly.
181
+ * For multiple selection: checks if item exists in modelValue array.
182
+ * @param {BtnGroupItem} item - The item to check
183
+ * @returns {boolean} True if the item is selected
184
+ */
98
185
  const isSelected = (item: BtnGroupItem) => {
99
186
  if (!props.multiple) {
100
187
  return props.modelValue === item[props.itemValue];
@@ -105,5 +192,6 @@ const isSelected = (item: BtnGroupItem) => {
105
192
  return index !== -1;
106
193
  }
107
194
  }
195
+ return false;
108
196
  };
109
197
  </script>