@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.
Files changed (175) hide show
  1. package/README.md +31 -1
  2. package/dist/cjs/chunks/index.js +530 -179
  3. package/dist/cjs/chunks/p-alert.js +14 -16
  4. package/dist/cjs/chunks/p-avatar.js +16 -0
  5. package/dist/cjs/chunks/p-btn.js +4 -1
  6. package/dist/cjs/chunks/p-card.js +4 -0
  7. package/dist/cjs/chunks/p-dropdown-select.js +34 -0
  8. package/dist/cjs/chunks/p-input-number.js +32 -0
  9. package/dist/cjs/chunks/p-input-percent.js +15 -4
  10. package/dist/cjs/chunks/p-input.js +28 -0
  11. package/dist/cjs/chunks/p-pagination-info.js +9 -5
  12. package/dist/cjs/chunks/p-pagination.js +23 -13
  13. package/dist/cjs/chunks/p-select-btn.js +2 -1
  14. package/dist/cjs/chunks/p-select.js +33 -0
  15. package/dist/cjs/chunks/p-table-loader.js +20 -0
  16. package/dist/cjs/chunks/p-tabs.js +12 -0
  17. package/dist/cjs/chunks/p-textarea.js +20 -0
  18. package/dist/cjs/index.js +72 -29
  19. package/dist/cjs/inputClasses.js +3 -3
  20. package/dist/cjs/p-checkbox.js +8 -1
  21. package/dist/cjs/p-chips.js +17 -1
  22. package/dist/cjs/p-close-btn.js +6 -1
  23. package/dist/cjs/p-drawer.js +90 -2
  24. package/dist/cjs/p-dropdown.js +2 -1
  25. package/dist/cjs/p-icon.js +2 -1
  26. package/dist/cjs/p-input-search.js +13 -1
  27. package/dist/cjs/p-loading.js +3 -3
  28. package/dist/cjs/p-modal.js +125 -43
  29. package/dist/cjs/p-select-pill.js +36 -2
  30. package/dist/cjs/p-skeleton-loader.js +17 -1
  31. package/dist/cjs/p-table-filter-icon.js +4 -1
  32. package/dist/cjs/p-table-header-cell.js +32 -2
  33. package/dist/cjs/p-table-td.js +1 -1
  34. package/dist/cjs/p-table.js +2 -0
  35. package/dist/cjs/p-toggle.js +22 -1
  36. package/dist/cjs/usePTableHeaderWrap.js +38 -0
  37. package/dist/es/chunks/index.js +530 -179
  38. package/dist/es/chunks/p-alert.js +14 -16
  39. package/dist/es/chunks/p-avatar.js +16 -0
  40. package/dist/es/chunks/p-btn.js +5 -2
  41. package/dist/es/chunks/p-card.js +4 -0
  42. package/dist/es/chunks/p-dropdown-select.js +34 -0
  43. package/dist/es/chunks/p-input-number.js +32 -0
  44. package/dist/es/chunks/p-input-percent.js +15 -4
  45. package/dist/es/chunks/p-input.js +28 -0
  46. package/dist/es/chunks/p-pagination-info.js +9 -5
  47. package/dist/es/chunks/p-pagination.js +24 -14
  48. package/dist/es/chunks/p-select-btn.js +2 -1
  49. package/dist/es/chunks/p-select.js +33 -0
  50. package/dist/es/chunks/p-table-loader.js +20 -0
  51. package/dist/es/chunks/p-tabs.js +12 -0
  52. package/dist/es/chunks/p-textarea.js +20 -0
  53. package/dist/es/index.js +77 -34
  54. package/dist/es/inputClasses.js +4 -4
  55. package/dist/es/p-checkbox.js +8 -1
  56. package/dist/es/p-chips.js +17 -1
  57. package/dist/es/p-close-btn.js +6 -1
  58. package/dist/es/p-drawer.js +90 -2
  59. package/dist/es/p-dropdown.js +2 -1
  60. package/dist/es/p-icon.js +2 -1
  61. package/dist/es/p-input-search.js +13 -1
  62. package/dist/es/p-loading.js +3 -3
  63. package/dist/es/p-modal.js +125 -43
  64. package/dist/es/p-select-pill.js +36 -2
  65. package/dist/es/p-skeleton-loader.js +17 -1
  66. package/dist/es/p-table-filter-icon.js +4 -1
  67. package/dist/es/p-table-header-cell.js +32 -2
  68. package/dist/es/p-table-td.js +1 -1
  69. package/dist/es/p-table.js +2 -0
  70. package/dist/es/p-toggle.js +22 -1
  71. package/dist/es/usePTableHeaderWrap.js +38 -0
  72. package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +15 -3
  73. package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +18 -5
  74. package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +36 -1
  75. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +21 -5
  76. package/dist/squirrel/components/p-card/p-card.vue.d.ts +21 -8
  77. package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +26 -8
  78. package/dist/squirrel/components/p-chips/p-chips.vue.d.ts +24 -0
  79. package/dist/squirrel/components/p-close-btn/p-close-btn.vue.d.ts +14 -1
  80. package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +17 -1
  81. package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +153 -15
  82. package/dist/squirrel/components/p-dropdown/p-dropdown.vue.d.ts +11 -2
  83. package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +70 -2
  84. package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +71 -7
  85. package/dist/squirrel/components/p-icon/p-icon.types.d.ts +1 -0
  86. package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +5 -1
  87. package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +12 -5
  88. package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +28 -8
  89. package/dist/squirrel/components/p-input/p-input.vue.d.ts +74 -9
  90. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +83 -12
  91. package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +23 -3
  92. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +25 -1
  93. package/dist/squirrel/components/p-link/p-link.vue.d.ts +1 -1
  94. package/dist/squirrel/components/p-loading/p-loading.vue.d.ts +1 -1
  95. package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +190 -16
  96. package/dist/squirrel/components/p-pagination/p-pagination.vue.d.ts +23 -13
  97. package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +17 -9
  98. package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +21 -1
  99. package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +11 -1
  100. package/dist/squirrel/components/p-select/p-select.vue.d.ts +77 -7
  101. package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +68 -11
  102. package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +2 -2
  103. package/dist/squirrel/components/p-select-pill/p-select-pill.vue.d.ts +72 -2
  104. package/dist/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue.d.ts +40 -0
  105. package/dist/squirrel/components/p-steps/p-steps.vue.d.ts +13 -1
  106. package/dist/squirrel/components/p-table/p-table.types.d.ts +1 -0
  107. package/dist/squirrel/components/p-table/p-table.vue.d.ts +33 -1
  108. package/dist/squirrel/components/p-table/usePTableHeaderWrap.d.ts +4 -0
  109. package/dist/squirrel/components/p-table-header-cell/p-table-filter-icon.vue.d.ts +7 -1
  110. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +59 -4
  111. package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +41 -1
  112. package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +13 -3
  113. package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +13 -1
  114. package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +34 -3
  115. package/dist/squirrel/components/p-tabs-pills/p-tabs-pills.vue.d.ts +23 -1
  116. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +53 -9
  117. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +51 -4
  118. package/dist/squirrel.css +68 -68
  119. package/package.json +24 -22
  120. package/squirrel/components/p-action-bar/p-action-bar.stories.js +5 -5
  121. package/squirrel/components/p-action-bar/p-action-bar.vue +30 -3
  122. package/squirrel/components/p-alert/p-alert.spec.js +4 -4
  123. package/squirrel/components/p-alert/p-alert.stories.js +19 -13
  124. package/squirrel/components/p-alert/p-alert.vue +33 -11
  125. package/squirrel/components/p-avatar/p-avatar.vue +28 -0
  126. package/squirrel/components/p-btn/p-btn.vue +35 -0
  127. package/squirrel/components/p-card/p-card.vue +24 -1
  128. package/squirrel/components/p-checkbox/p-checkbox.vue +23 -1
  129. package/squirrel/components/p-chips/p-chips.vue +24 -0
  130. package/squirrel/components/p-close-btn/p-close-btn.vue +15 -0
  131. package/squirrel/components/p-date-picker/p-date-picker.vue +23 -1
  132. package/squirrel/components/p-drawer/p-drawer.vue +95 -0
  133. package/squirrel/components/p-dropdown/p-dropdown.vue +12 -1
  134. package/squirrel/components/p-dropdown-select/p-dropdown-select.vue +41 -0
  135. package/squirrel/components/p-file-upload/p-file-upload.vue +58 -3
  136. package/squirrel/components/p-icon/p-icon.types.ts +1 -0
  137. package/squirrel/components/p-icon/p-icon.vue +16 -0
  138. package/squirrel/components/p-info-icon/p-info-icon.vue +19 -0
  139. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue +32 -0
  140. package/squirrel/components/p-input/p-input.vue +61 -1
  141. package/squirrel/components/p-input-number/p-input-number.vue +78 -1
  142. package/squirrel/components/p-input-percent/p-input-percent.vue +27 -3
  143. package/squirrel/components/p-input-search/p-input-search.vue +30 -2
  144. package/squirrel/components/p-link/p-link.vue +13 -0
  145. package/squirrel/components/p-loading/p-loading.vue +9 -2
  146. package/squirrel/components/p-modal/p-modal-basic.spec.js +29 -3
  147. package/squirrel/components/p-modal/p-modal.vue +182 -35
  148. package/squirrel/components/p-pagination/p-pagination.vue +28 -8
  149. package/squirrel/components/p-pagination-info/p-pagination-info.vue +16 -4
  150. package/squirrel/components/p-progress-bar/p-progress-bar.vue +31 -4
  151. package/squirrel/components/p-ring-loader/p-ring-loader.vue +17 -0
  152. package/squirrel/components/p-select/p-select.vue +50 -1
  153. package/squirrel/components/p-select-btn/p-select-btn.vue +90 -2
  154. package/squirrel/components/p-select-list/p-select-list.vue +7 -0
  155. package/squirrel/components/p-select-pill/p-select-pill.vue +52 -2
  156. package/squirrel/components/p-skeleton-loader/p-skeleton-loader.vue +24 -0
  157. package/squirrel/components/p-steps/p-steps.vue +25 -0
  158. package/squirrel/components/p-table/p-table.spec.js +51 -15
  159. package/squirrel/components/p-table/p-table.types.ts +2 -0
  160. package/squirrel/components/p-table/p-table.vue +46 -4
  161. package/squirrel/components/p-table/usePTableHeaderWrap.spec.js +118 -0
  162. package/squirrel/components/p-table/usePTableHeaderWrap.ts +45 -0
  163. package/squirrel/components/p-table-header-cell/p-table-filter-icon.vue +9 -0
  164. package/squirrel/components/p-table-header-cell/p-table-header-cell.spec.js +5 -1
  165. package/squirrel/components/p-table-header-cell/p-table-header-cell.vue +38 -1
  166. package/squirrel/components/p-table-loader/p-table-loader.vue +28 -0
  167. package/squirrel/components/p-table-sort/p-table-sort.vue +19 -1
  168. package/squirrel/components/p-table-td/p-table-td.vue +20 -0
  169. package/squirrel/components/p-tabs/p-tabs.stories.js +2 -2
  170. package/squirrel/components/p-tabs/p-tabs.vue +33 -1
  171. package/squirrel/components/p-tabs-pills/p-tabs-pills.vue +33 -0
  172. package/squirrel/components/p-textarea/p-textarea.vue +43 -1
  173. package/squirrel/components/p-toggle/p-toggle.vue +44 -1
  174. package/squirrel/assets/pagination-left-icon.svg +0 -5
  175. package/squirrel/assets/pagination-right-icon.svg +0 -5
@@ -0,0 +1,118 @@
1
+ import { HEADER_CELL_ONE_LINE_HEIGHT } from '@squirrel/components/p-table/p-table.types';
2
+ import { usePTableHeaderWrap } from '@squirrel/components/p-table/usePTableHeaderWrap';
3
+ import { waitNT } from '@tests/vitest.helpers';
4
+ import { mount } from '@vue/test-utils';
5
+ import { defineComponent, useTemplateRef } from 'vue';
6
+
7
+ // Mock ResizeObserver to capture the composable's callback
8
+ let composableResizeCallback;
9
+ const mockResizeObserver = vi.fn((callback) => {
10
+ composableResizeCallback = callback;
11
+ return {
12
+ observe: vi.fn(),
13
+ unobserve: vi.fn(),
14
+ disconnect: vi.fn(),
15
+ };
16
+ });
17
+
18
+ const createWrapper = (refName = 'theadRef') => {
19
+ const TestComponent = defineComponent({
20
+ setup() {
21
+ const theadRef = useTemplateRef('theadRef');
22
+ const { hasWrap } = usePTableHeaderWrap(theadRef);
23
+
24
+ return {
25
+ theadRef,
26
+ hasWrap,
27
+ };
28
+ },
29
+ template: `
30
+ <table>
31
+ <thead ref="${refName}" :data-has-wrap="hasWrap">
32
+ <tr>
33
+ <th>
34
+ <div data-p-table-header-text class="div-to-resize">Short</div>
35
+ </th>
36
+ <th>
37
+ <span data-p-table-header-text>Very Long Header That Could Potentially Wrap To Multiple Lines</span>
38
+ </th>
39
+ </tr>
40
+ </thead>
41
+ </table>
42
+ `,
43
+ });
44
+
45
+ return mount(TestComponent, {
46
+ attachTo: document.body,
47
+ });
48
+ };
49
+
50
+ describe('usePTableHeaderWrap', () => {
51
+ const originalOffsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetHeight');
52
+ const originalGlobalResizeObserver = globalThis.ResizeObserver;
53
+
54
+ beforeAll(() => {
55
+ Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
56
+ configurable: true,
57
+ value: HEADER_CELL_ONE_LINE_HEIGHT,
58
+ });
59
+ globalThis.ResizeObserver = mockResizeObserver;
60
+ });
61
+
62
+ afterAll(() => {
63
+ Object.defineProperty(HTMLElement.prototype, 'offsetHeight', originalOffsetHeight);
64
+ globalThis.ResizeObserver = originalGlobalResizeObserver;
65
+ });
66
+
67
+ beforeEach(() => {
68
+ mockResizeObserver.mockClear();
69
+ composableResizeCallback = null;
70
+ });
71
+
72
+ it('should have hasWrap false when all divs are single line height', async () => {
73
+ const wrapper = createWrapper();
74
+
75
+ // Trigger the composable's ResizeObserver callback
76
+ if (composableResizeCallback) {
77
+ composableResizeCallback();
78
+ await waitNT(wrapper.vm);
79
+ }
80
+
81
+ expect(wrapper.find('thead').attributes()['data-has-wrap']).toBe('false');
82
+
83
+ wrapper.unmount();
84
+ });
85
+
86
+ it('should have hasWrap true when one div is double line height', async () => {
87
+ // Override offsetHeight for the "div-to-resize" element
88
+ Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
89
+ configurable: true,
90
+ get() {
91
+ if (this.classList.contains('div-to-resize')) {
92
+ return HEADER_CELL_ONE_LINE_HEIGHT * 2;
93
+ }
94
+ return HEADER_CELL_ONE_LINE_HEIGHT;
95
+ },
96
+ });
97
+
98
+ const wrapper = createWrapper();
99
+
100
+ // Trigger the composable's ResizeObserver callback
101
+ if (composableResizeCallback) {
102
+ composableResizeCallback();
103
+ await waitNT(wrapper.vm);
104
+ }
105
+
106
+ expect(wrapper.find('thead').attributes()['data-has-wrap']).toBe('true');
107
+
108
+ wrapper.unmount();
109
+ });
110
+
111
+ it('should handle null theadRef gracefully', () => {
112
+ const wrapper = createWrapper('nullRef');
113
+
114
+ expect(wrapper.find('thead').attributes()['data-has-wrap']).toBe('false');
115
+
116
+ wrapper.unmount();
117
+ });
118
+ });
@@ -0,0 +1,45 @@
1
+ import { HEADER_CELL_ONE_LINE_HEIGHT } from '@squirrel/components/p-table/p-table.types';
2
+ import { onBeforeUnmount, onMounted, type Ref, ref } from 'vue';
3
+
4
+ export const usePTableHeaderWrap = (theadRef: Ref<HTMLElement | null>) => {
5
+ let headerObserver: ResizeObserver | null = null;
6
+ const hasWrap = ref(false);
7
+
8
+ const setupObserver = () => {
9
+ if (!theadRef.value) return;
10
+
11
+ headerObserver = new ResizeObserver(() => {
12
+ if (theadRef.value) {
13
+ const textDivs = theadRef.value.querySelectorAll('[data-p-table-header-text]') as NodeListOf<HTMLElement>;
14
+
15
+ for (const div of textDivs) {
16
+ if (div.offsetHeight > HEADER_CELL_ONE_LINE_HEIGHT) {
17
+ hasWrap.value = true;
18
+ return;
19
+ }
20
+ }
21
+
22
+ hasWrap.value = false;
23
+ }
24
+ });
25
+
26
+ headerObserver.observe(theadRef.value);
27
+ };
28
+
29
+ const cleanupObserver = () => {
30
+ if (headerObserver) {
31
+ headerObserver.disconnect();
32
+ headerObserver = null;
33
+ }
34
+ };
35
+
36
+ onMounted(() => {
37
+ setupObserver();
38
+ });
39
+
40
+ onBeforeUnmount(() => {
41
+ cleanupObserver();
42
+ });
43
+
44
+ return { hasWrap };
45
+ };
@@ -3,12 +3,21 @@
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
+ /**
7
+ * A filter icon component for table headers, used to indicate and toggle filter state.
8
+ * Changes its appearance based on the active state and supports hover effects.
9
+ *
10
+ * @displayName PTableFilterIcon
11
+ */
6
12
  defineOptions({
7
13
  name: 'PTableFilterIcon',
8
14
  inheritAttrs: false,
9
15
  });
10
16
 
11
17
  defineProps({
18
+ /**
19
+ * Whether the filter icon is active (filtered state).
20
+ */
12
21
  active: {
13
22
  type: Boolean,
14
23
  default: false,
@@ -25,7 +25,11 @@ describe('PTableHeaderCell.vue', () => {
25
25
  'text-xs',
26
26
  'leading-5',
27
27
  'font-semibold',
28
- 'truncate',
28
+ 'line-clamp-2',
29
+ 'break-words',
30
+ 'hyphens-auto',
31
+ 'whitespace-normal',
32
+ 'max-h-10',
29
33
  'shrink',
30
34
  'test-class',
31
35
  'text-p-gray-60',
@@ -4,6 +4,7 @@
4
4
  :class="[DEFAULT_CLASSES, textClass, textColorClass, { 'mr-auto': !tooltipText }]"
5
5
  :style="style"
6
6
  :title="text"
7
+ data-p-table-header-text
7
8
  >
8
9
  {{ text }}
9
10
  </div>
@@ -23,8 +24,15 @@ import PInfoIcon from '@squirrel/components/p-info-icon/p-info-icon.vue';
23
24
  import PTableFilterIcon from '@squirrel/components/p-table-header-cell/p-table-filter-icon.vue';
24
25
  import { defineComponent } from 'vue';
25
26
 
26
- const DEFAULT_CLASSES = `text-xs leading-5 font-semibold truncate shrink`;
27
+ const DEFAULT_CLASSES = `text-xs leading-5 font-semibold line-clamp-2 break-words hyphens-auto whitespace-normal max-h-10 shrink`;
27
28
 
29
+ /**
30
+ * A table header cell component that displays text with optional tooltip and filter icon.
31
+ * Provides consistent styling for table headers with support for custom text colors,
32
+ * tooltips, and filter functionality.
33
+ *
34
+ * @displayName PTableHeaderCell
35
+ */
28
36
  export default defineComponent({
29
37
  name: 'PTableHeaderCell',
30
38
  components: {
@@ -32,31 +40,60 @@ export default defineComponent({
32
40
  PInfoIcon,
33
41
  },
34
42
  props: {
43
+ /**
44
+ * The text content to display in the header cell.
45
+ * Also used as the title attribute for accessibility.
46
+ */
35
47
  text: {
36
48
  type: String,
37
49
  default: '',
38
50
  },
51
+ /**
52
+ * CSS classes to apply to the text element.
53
+ * Can be a string, object, or array for flexible styling.
54
+ */
39
55
  textClass: {
40
56
  type: [String, Object, Array],
41
57
  default: 'text-left',
42
58
  },
59
+ /**
60
+ * Whether the filter icon is in an active state.
61
+ * Controls the visual appearance of the filter icon and text color.
62
+ */
43
63
  filterActive: {
44
64
  type: Boolean,
45
65
  default: false,
46
66
  },
67
+ /**
68
+ * Whether to show the filter icon.
69
+ * When false, the filter icon is hidden regardless of other states.
70
+ */
47
71
  showFilterIcon: {
48
72
  type: Boolean,
49
73
  default: false,
50
74
  },
75
+ /**
76
+ * Tooltip text to display when hovering over the info icon.
77
+ * When provided, shows an info icon with the tooltip content.
78
+ */
51
79
  tooltipText: {
52
80
  type: String,
53
81
  default: '',
54
82
  },
83
+ /**
84
+ * Custom text color to apply to the header text.
85
+ * Overrides the default text color when provided.
86
+ */
55
87
  textColor: {
56
88
  type: String,
57
89
  default: '',
58
90
  },
59
91
  },
92
+ /**
93
+ * Emitted when the filter icon is clicked.
94
+ * @param {Event} event - The click event
95
+ * @param {boolean} filterActive - The current filter active state
96
+ */
60
97
  emits: ['click-filter-icon'],
61
98
  data() {
62
99
  return {
@@ -25,27 +25,55 @@
25
25
  <script setup lang="ts">
26
26
  import PSkeletonLoader from '@squirrel/components/p-skeleton-loader/p-skeleton-loader.vue';
27
27
 
28
+ /**
29
+ * A table skeleton loader component that displays a loading placeholder for table data.
30
+ * Renders a complete table structure with skeleton loaders for headers and data cells.
31
+ * Supports customizable dimensions, styling, and optional subheaders to match
32
+ * the expected table layout during loading states.
33
+ *
34
+ * @displayName PTableLoader
35
+ */
28
36
  defineOptions({
29
37
  name: 'PTableLoader',
30
38
  });
31
39
 
32
40
  defineProps({
41
+ /**
42
+ * The number of rows to display in the skeleton table.
43
+ * Controls the vertical size of the loading placeholder.
44
+ */
33
45
  rows: {
34
46
  type: [Number, String],
35
47
  default: 4,
36
48
  },
49
+ /**
50
+ * The number of columns to display in the skeleton table.
51
+ * Controls the horizontal size of the loading placeholder.
52
+ */
37
53
  columns: {
38
54
  type: [Number, String],
39
55
  default: 6,
40
56
  },
57
+ /**
58
+ * CSS classes to apply to each table cell.
59
+ * Allows customization of cell padding and styling.
60
+ */
41
61
  tdClasses: {
42
62
  type: String,
43
63
  default: 'px-4 py-5',
44
64
  },
65
+ /**
66
+ * CSS classes to apply to the skeleton loader within each cell.
67
+ * Controls the height and appearance of individual skeleton elements.
68
+ */
45
69
  tdSkeletonClasses: {
46
70
  type: String,
47
71
  default: 'h-5',
48
72
  },
73
+ /**
74
+ * Whether to display subheaders in the table header.
75
+ * Adds an additional row below the main header for more complex table structures.
76
+ */
49
77
  withSubheader: {
50
78
  type: Boolean,
51
79
  default: false,
@@ -59,13 +59,31 @@
59
59
  import { SORTING_TYPES, type SortingType } from '@squirrel/components/p-table-sort/p-table-sort.config';
60
60
  import { type PropType } from 'vue';
61
61
 
62
+ /**
63
+ * A table sorting component that provides ascending, descending, and no-sorting options.
64
+ * Displays sort options with visual indicators and allows clearing the sort state.
65
+ * Used for table column sorting functionality.
66
+ *
67
+ * @displayName PTableSort
68
+ */
62
69
  defineOptions({
63
70
  name: 'PTableSort',
64
71
  });
65
72
 
66
- defineEmits(['update:modelValue']);
73
+ defineEmits<{
74
+ /**
75
+ * Emitted when the sorting state changes.
76
+ * @param {SortingType} value - The new sorting state
77
+ */
78
+ 'update:modelValue': [value: SortingType];
79
+ }>();
67
80
 
68
81
  defineProps({
82
+ /**
83
+ * The current sorting state (v-model).
84
+ * Valid values: 'asc', 'desc', 'no-sorting'
85
+ * Controls which sort option is visually active.
86
+ */
69
87
  modelValue: {
70
88
  type: String as PropType<SortingType>,
71
89
  default: SORTING_TYPES.NO_SORTING,
@@ -22,11 +22,31 @@ import {
22
22
  } from '@squirrel/components/p-table/p-table.types';
23
23
  import { computed, inject, type Ref, ref } from 'vue';
24
24
 
25
+ /**
26
+ * A table cell component that provides advanced styling and behavior for table data.
27
+ * Supports fixed columns, editable cells, selection states, and responsive design.
28
+ * Integrates with the table system through dependency injection for coordinated
29
+ * styling and behavior across the entire table structure.
30
+ *
31
+ * @displayName PTableTd
32
+ */
25
33
  defineOptions({ name: 'PTableTd', inheritAttrs: false });
26
34
 
27
35
  type Props = {
36
+ /**
37
+ * The index of the column this cell belongs to.
38
+ * Used for determining positioning and styling based on column position.
39
+ */
28
40
  colIndex: number;
41
+ /**
42
+ * Whether the cell is editable.
43
+ * Adds cursor pointer styling and enables edit functionality.
44
+ */
29
45
  isEditable?: boolean;
46
+ /**
47
+ * Whether the cell is part of a selected row.
48
+ * Applies selection styling and hover effects.
49
+ */
30
50
  isSelected?: boolean;
31
51
  };
32
52
 
@@ -1,4 +1,4 @@
1
- import PaginateRightIcon from '@squirrel/assets/pagination-right-icon.svg?inline';
1
+ import KeyboardPressEnterIcon from '@squirrel/assets/keyboard-press-enter.svg?inline';
2
2
  import PTabs from '@squirrel/components/p-tabs/p-tabs.vue';
3
3
  import { action } from 'storybook/actions';
4
4
  import { markRaw } from 'vue';
@@ -35,7 +35,7 @@ export const Default = {
35
35
  {
36
36
  title: 'Tab 2',
37
37
  name: 'tab2',
38
- icon: markRaw(PaginateRightIcon),
38
+ icon: markRaw(KeyboardPressEnterIcon),
39
39
  },
40
40
  {
41
41
  title: 'Tab 3',
@@ -30,31 +30,63 @@
30
30
  import { type ShallowRef } from 'vue';
31
31
  import { type RouteLocationRaw } from 'vue-router';
32
32
 
33
+ /**
34
+ * A tabs component for navigation between different sections.
35
+ * Displays tabs with optional icons and supports router navigation.
36
+ * Provides hover effects and active state styling.
37
+ *
38
+ * @displayName PTabs
39
+ */
33
40
  defineOptions({
34
41
  name: 'PTabs',
35
42
  });
36
43
 
44
+ /**
45
+ * Represents a single tab in the tabs component.
46
+ */
37
47
  type Tab = {
48
+ /** Unique identifier for the tab */
38
49
  name: string;
50
+ /** Display text for the tab */
39
51
  title: string;
52
+ /** Optional icon component or icon name */
40
53
  icon?: string | ShallowRef<string>;
54
+ /** Optional router link destination */
41
55
  to?: RouteLocationRaw;
42
56
  };
43
57
 
44
58
  defineProps({
59
+ /**
60
+ * Array of tab objects to display.
61
+ * Each tab should have a name, title, and optional icon and route.
62
+ */
45
63
  tabs: {
46
64
  type: Array as () => Tab[],
47
65
  required: true,
48
66
  },
67
+ /**
68
+ * The currently active tab name.
69
+ * Controls which tab is visually highlighted.
70
+ */
49
71
  activeTab: {
50
72
  type: String,
51
73
  required: true,
52
74
  },
75
+ /**
76
+ * Left padding for the tabs container in pixels.
77
+ * Useful for aligning tabs with other content.
78
+ */
53
79
  tabsLeftPadding: {
54
80
  type: Number,
55
81
  default: 0,
56
82
  },
57
83
  });
58
84
 
59
- defineEmits(['click:tab']);
85
+ defineEmits<{
86
+ /**
87
+ * Emitted when a tab is clicked.
88
+ * @param {string} tabName - The name of the clicked tab
89
+ */
90
+ 'click:tab': [tabName: string];
91
+ }>();
60
92
  </script>
@@ -30,20 +30,49 @@
30
30
  </template>
31
31
 
32
32
  <script setup lang="ts">
33
+ /**
34
+ * A tabs pills component that displays navigation tabs in a pill-style interface.
35
+ * Provides a compact tab navigation with smooth transitions and accessibility features.
36
+ * Supports disabled states and custom item text/value properties.
37
+ *
38
+ * @displayName PTabsPills
39
+ */
33
40
  defineOptions({
34
41
  name: 'PTabsPills',
35
42
  });
36
43
 
44
+ /**
45
+ * Valid value types for tab items.
46
+ */
37
47
  type Value = string | number | boolean;
38
48
 
49
+ /**
50
+ * Represents a single tab option in the pills component.
51
+ */
39
52
  type Option = {
40
53
  [key: string]: Value;
41
54
  };
42
55
 
43
56
  type Props = {
57
+ /**
58
+ * The currently selected tab value (v-model).
59
+ * Should match one of the item values in the items array.
60
+ */
44
61
  modelValue?: Value;
62
+ /**
63
+ * Array of tab items to display as pills.
64
+ * Each item should have properties matching itemValue and itemText.
65
+ */
45
66
  items?: readonly Option[];
67
+ /**
68
+ * Property name to use as the item display text.
69
+ * Used for button label content.
70
+ */
46
71
  itemText?: string;
72
+ /**
73
+ * Property name to use as the item value.
74
+ * Used for selection comparison and v-model binding.
75
+ */
47
76
  itemValue?: string;
48
77
  };
49
78
 
@@ -55,6 +84,10 @@ withDefaults(defineProps<Props>(), {
55
84
  });
56
85
 
57
86
  defineEmits<{
87
+ /**
88
+ * Emitted when the selected tab value changes.
89
+ * @param {Value} val - The new selected tab value
90
+ */
58
91
  'update:modelValue': [val: Value];
59
92
  }>();
60
93
  </script>
@@ -15,30 +15,72 @@ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
15
15
  import { useInputClasses } from '@squirrel/composables/useInputClasses';
16
16
  import { computed, type PropType, type StyleValue, useAttrs } from 'vue';
17
17
 
18
+ /**
19
+ * A textarea component for multi-line text input.
20
+ * Provides consistent styling and behavior with other form components.
21
+ * Supports custom labels, error states, and various sizes.
22
+ *
23
+ * @displayName PTextarea
24
+ */
18
25
  defineOptions({
19
26
  name: 'PTextarea',
20
27
  inheritAttrs: false,
21
28
  });
22
29
 
23
- const emit = defineEmits(['update:modelValue']);
30
+ const emit = defineEmits<{
31
+ /**
32
+ * Emitted when the textarea value changes.
33
+ * @param {string} value - The new textarea value
34
+ */
35
+ 'update:modelValue': [value: string];
36
+ }>();
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
+ }>();
24
46
 
25
47
  const props = defineProps({
48
+ /**
49
+ * The current value of the textarea (v-model).
50
+ * Supports two-way binding for form inputs.
51
+ */
26
52
  modelValue: {
27
53
  type: [String, Number, null] as PropType<string | number | null>,
28
54
  default: '',
29
55
  },
56
+ /**
57
+ * Text label for the textarea field.
58
+ * If not provided, you can use the label slot instead.
59
+ */
30
60
  label: {
31
61
  type: String,
32
62
  default: '',
33
63
  },
64
+ /**
65
+ * Error message to display below the textarea.
66
+ * When provided, the textarea will show error styling.
67
+ */
34
68
  errorMsg: {
35
69
  type: String,
36
70
  default: '',
37
71
  },
72
+ /**
73
+ * Whether the textarea is required.
74
+ * Adds required attribute and visual indicator.
75
+ */
38
76
  required: {
39
77
  type: Boolean,
40
78
  default: false,
41
79
  },
80
+ /**
81
+ * The size of the textarea - affects padding, font size, and spacing.
82
+ * Valid values: 'sm', 'md', 'lg'
83
+ */
42
84
  size: {
43
85
  type: String as PropType<Size>,
44
86
  default: 'md',
@@ -56,30 +56,73 @@ const TOGGLE_CLASSES = [
56
56
  </script>
57
57
 
58
58
  <script setup lang="ts">
59
+ /**
60
+ * A toggle switch component that provides a modern switch interface.
61
+ * Supports different sizes, labels, error states, and accessibility features.
62
+ * Uses a checkbox input with custom styling for the toggle appearance.
63
+ *
64
+ * @displayName PToggle
65
+ */
59
66
  defineOptions({
60
67
  name: 'PToggle',
61
68
  inheritAttrs: false,
62
69
  });
63
70
 
64
- const emit = defineEmits(['update:modelValue']);
71
+ defineSlots<{
72
+ /**
73
+ * Custom label content - overrides the label prop.
74
+ * @param {string} label - The label text
75
+ * @param {string} label-classes - CSS classes for the label
76
+ */
77
+ label?: (props: { label: string; labelClasses: string }) => unknown;
78
+ }>();
79
+
80
+ const emit = defineEmits<{
81
+ /**
82
+ * Emitted when the toggle state changes.
83
+ * @param {boolean} value - The new toggle state
84
+ */
85
+ 'update:modelValue': [value: boolean];
86
+ }>();
65
87
 
66
88
  const props = defineProps({
89
+ /**
90
+ * The current toggle state (v-model).
91
+ * Supports two-way binding for form inputs.
92
+ */
67
93
  modelValue: {
68
94
  type: Boolean,
69
95
  default: false,
70
96
  },
97
+ /**
98
+ * Text label for the toggle switch.
99
+ * If not provided, you can use the label slot instead.
100
+ */
71
101
  label: {
72
102
  type: String,
73
103
  default: '',
74
104
  },
105
+ /**
106
+ * Error message to display below the toggle.
107
+ * When provided, the toggle will show error styling.
108
+ */
75
109
  errorMsg: {
76
110
  type: String,
77
111
  default: '',
78
112
  },
113
+ /**
114
+ * Whether the toggle is required.
115
+ * Adds required attribute and visual indicator.
116
+ */
79
117
  required: {
80
118
  type: Boolean,
81
119
  default: false,
82
120
  },
121
+ /**
122
+ * The size of the toggle switch.
123
+ * Valid values: 'sm', 'md', 'lg'
124
+ * @values sm, md, lg
125
+ */
83
126
  size: {
84
127
  type: String as PropType<Size>,
85
128
  default: 'md',