@pequity/squirrel 8.5.0 → 8.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,168 +1,21 @@
1
- /**
2
- * A table header cell component that displays text with optional tooltip and filter icon.
3
- * Provides consistent styling for table headers with support for custom text colors,
4
- * tooltips, and filter functionality.
5
- *
6
- * @displayName PTableHeaderCell
7
- */
8
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
- /**
10
- * The text content to display in the header cell.
11
- * Also used as the title attribute for accessibility.
12
- */
13
- text: {
14
- type: StringConstructor;
15
- default: string;
16
- };
17
- /**
18
- * CSS classes to apply to the text element.
19
- * Can be a string, object, or array for flexible styling.
20
- */
21
- textClass: {
22
- type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
23
- default: string;
24
- };
25
- /**
26
- * Whether the filter icon is in an active state.
27
- * Controls the visual appearance of the filter icon and text color.
28
- */
29
- filterActive: {
30
- type: BooleanConstructor;
31
- default: boolean;
32
- };
33
- /**
34
- * Whether to show the filter icon.
35
- * When false, the filter icon is hidden regardless of other states.
36
- */
37
- showFilterIcon: {
38
- type: BooleanConstructor;
39
- default: boolean;
40
- };
41
- /**
42
- * Tooltip text to display when hovering over the info icon.
43
- * When provided, shows an info icon with the tooltip content.
44
- */
45
- tooltipText: {
46
- type: StringConstructor;
47
- default: string;
48
- };
49
- /**
50
- * Custom text color to apply to the header text.
51
- * Overrides the default text color when provided.
52
- */
53
- textColor: {
54
- type: StringConstructor;
55
- default: string;
56
- };
57
- }>, {}, {
58
- DEFAULT_CLASSES: string;
59
- }, {
60
- textColorClass(): "" | "text-active-blue" | "text-p-gray-60";
61
- style(): {
62
- color?: undefined;
63
- } | {
64
- color: string;
65
- };
66
- }, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "click-filter-icon"[], "click-filter-icon", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
67
- /**
68
- * The text content to display in the header cell.
69
- * Also used as the title attribute for accessibility.
70
- */
71
- text: {
72
- type: StringConstructor;
73
- default: string;
74
- };
75
- /**
76
- * CSS classes to apply to the text element.
77
- * Can be a string, object, or array for flexible styling.
78
- */
79
- textClass: {
80
- type: (StringConstructor | ObjectConstructor | ArrayConstructor)[];
81
- default: string;
82
- };
83
- /**
84
- * Whether the filter icon is in an active state.
85
- * Controls the visual appearance of the filter icon and text color.
86
- */
87
- filterActive: {
88
- type: BooleanConstructor;
89
- default: boolean;
90
- };
91
- /**
92
- * Whether to show the filter icon.
93
- * When false, the filter icon is hidden regardless of other states.
94
- */
95
- showFilterIcon: {
96
- type: BooleanConstructor;
97
- default: boolean;
98
- };
99
- /**
100
- * Tooltip text to display when hovering over the info icon.
101
- * When provided, shows an info icon with the tooltip content.
102
- */
103
- tooltipText: {
104
- type: StringConstructor;
105
- default: string;
106
- };
107
- /**
108
- * Custom text color to apply to the header text.
109
- * Overrides the default text color when provided.
110
- */
111
- textColor: {
112
- type: StringConstructor;
113
- default: string;
114
- };
115
- }>> & Readonly<{
116
- "onClick-filter-icon"?: ((...args: any[]) => any) | undefined;
1
+ type Props = {
2
+ text?: string;
3
+ textClass?: string;
4
+ filterActive?: boolean;
5
+ showFilterIcon?: boolean;
6
+ tooltipText?: string;
7
+ textColor?: string;
8
+ };
9
+ declare const _default: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ "click-filter-icon": (event: Event, filterActive: boolean) => any;
11
+ }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
12
+ "onClick-filter-icon"?: ((event: Event, filterActive: boolean) => any) | undefined;
117
13
  }>, {
118
14
  text: string;
119
15
  tooltipText: string;
120
- textClass: string | Record<string, any> | unknown[];
16
+ textClass: string;
121
17
  filterActive: boolean;
122
18
  showFilterIcon: boolean;
123
19
  textColor: string;
124
- }, {}, {
125
- PTableFilterIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
126
- active: {
127
- type: BooleanConstructor;
128
- default: boolean;
129
- };
130
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
131
- active: {
132
- type: BooleanConstructor;
133
- default: boolean;
134
- };
135
- }>> & Readonly<{}>, {
136
- active: boolean;
137
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
138
- PInfoIcon: {
139
- new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<{
140
- text?: string | null;
141
- }> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
142
- text: string | null;
143
- }, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
144
- P: {};
145
- B: {};
146
- D: {};
147
- C: {};
148
- M: {};
149
- Defaults: {};
150
- }, Readonly<{
151
- text?: string | null;
152
- }> & Readonly<{}>, {}, {}, {}, {}, {
153
- text: string | null;
154
- }>;
155
- __isFragment?: never;
156
- __isTeleport?: never;
157
- __isSuspense?: never;
158
- } & import("vue").ComponentOptionsBase<Readonly<{
159
- text?: string | null;
160
- }> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
161
- text: string | null;
162
- }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
163
- $slots: {
164
- default?: () => unknown;
165
- };
166
- });
167
- }, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
20
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
168
21
  export default _default;
package/dist/squirrel.css CHANGED
@@ -364,17 +364,6 @@ to {
364
364
  100% {
365
365
  transform: translateX(100%);
366
366
  }
367
- }.filter[data-v-5c047926] {
368
- background: url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15.5%206.73H4.5C4.36739%206.73%204.24021%206.67732%204.14645%206.58355C4.05268%206.48978%204%206.3626%204%206.23C4%206.09739%204.05268%205.97021%204.14645%205.87644C4.24021%205.78267%204.36739%205.73%204.5%205.73H15.5C15.6326%205.73%2015.7598%205.78267%2015.8536%205.87644C15.9473%205.97021%2016%206.09739%2016%206.23C16%206.3626%2015.9473%206.48978%2015.8536%206.58355C15.7598%206.67732%2015.6326%206.73%2015.5%206.73Z'%20fill='%23424E6E'/%3e%3cpath%20d='M14.33%209.245H5.67C5.53739%209.245%205.41021%209.19232%205.31644%209.09855C5.22268%209.00478%205.17%208.8776%205.17%208.745C5.17%208.61239%205.22268%208.48521%205.31644%208.39144C5.41021%208.29767%205.53739%208.245%205.67%208.245H14.33C14.4626%208.245%2014.5898%208.29767%2014.6836%208.39144C14.7773%208.48521%2014.83%208.61239%2014.83%208.745C14.83%208.8776%2014.7773%209.00478%2014.6836%209.09855C14.5898%209.19232%2014.4626%209.245%2014.33%209.245Z'%20fill='%23424E6E'/%3e%3cpath%20d='M11.605%2014.27H8.395C8.2624%2014.27%208.13522%2014.2173%208.04145%2014.1235C7.94768%2014.0298%207.895%2013.9026%207.895%2013.77C7.895%2013.6374%207.94768%2013.5102%208.04145%2013.4164C8.13522%2013.3227%208.2624%2013.27%208.395%2013.27H11.605C11.7376%2013.27%2011.8648%2013.3227%2011.9586%2013.4164C12.0523%2013.5102%2012.105%2013.6374%2012.105%2013.77C12.105%2013.9026%2012.0523%2014.0298%2011.9586%2014.1235C11.8648%2014.2173%2011.7376%2014.27%2011.605%2014.27Z'%20fill='%23424E6E'/%3e%3cpath%20d='M13.155%2011.755H6.845C6.71239%2011.755%206.58522%2011.7023%206.49145%2011.6085C6.39768%2011.5148%206.345%2011.3876%206.345%2011.255C6.345%2011.1224%206.39768%2010.9952%206.49145%2010.9014C6.58522%2010.8077%206.71239%2010.755%206.845%2010.755H13.155C13.2876%2010.755%2013.4148%2010.8077%2013.5086%2010.9014C13.6023%2010.9952%2013.655%2011.1224%2013.655%2011.255C13.655%2011.3876%2013.6023%2011.5148%2013.5086%2011.6085C13.4148%2011.7023%2013.2876%2011.755%2013.155%2011.755Z'%20fill='%23424E6E'/%3e%3c/svg%3e") no-repeat;
369
- }
370
- .filter[data-v-5c047926]:hover {
371
- background: url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='20'%20height='20'%20rx='4'%20fill='black'%20fill-opacity='0.05'/%3e%3cpath%20d='M15.5%206.73001H4.5C4.36739%206.73001%204.24021%206.67733%204.14645%206.58356C4.05268%206.4898%204%206.36262%204%206.23001C4%206.0974%204.05268%205.97023%204.14645%205.87646C4.24021%205.78269%204.36739%205.73001%204.5%205.73001H15.5C15.6326%205.73001%2015.7598%205.78269%2015.8536%205.87646C15.9473%205.97023%2016%206.0974%2016%206.23001C16%206.36262%2015.9473%206.4898%2015.8536%206.58356C15.7598%206.67733%2015.6326%206.73001%2015.5%206.73001Z'%20fill='%23424E6E'/%3e%3cpath%20d='M14.33%209.24503H5.67C5.53739%209.24503%205.41021%209.19235%205.31644%209.09858C5.22268%209.00481%205.17%208.87763%205.17%208.74503C5.17%208.61242%205.22268%208.48524%205.31644%208.39147C5.41021%208.2977%205.53739%208.24503%205.67%208.24503H14.33C14.4626%208.24503%2014.5898%208.2977%2014.6836%208.39147C14.7773%208.48524%2014.83%208.61242%2014.83%208.74503C14.83%208.87763%2014.7773%209.00481%2014.6836%209.09858C14.5898%209.19235%2014.4626%209.24503%2014.33%209.24503Z'%20fill='%23424E6E'/%3e%3cpath%20d='M11.605%2014.27H8.395C8.2624%2014.27%208.13522%2014.2173%208.04145%2014.1236C7.94768%2014.0298%207.895%2013.9026%207.895%2013.77C7.895%2013.6374%207.94768%2013.5102%208.04145%2013.4165C8.13522%2013.3227%208.2624%2013.27%208.395%2013.27H11.605C11.7376%2013.27%2011.8648%2013.3227%2011.9586%2013.4165C12.0523%2013.5102%2012.105%2013.6374%2012.105%2013.77C12.105%2013.9026%2012.0523%2014.0298%2011.9586%2014.1236C11.8648%2014.2173%2011.7376%2014.27%2011.605%2014.27Z'%20fill='%23424E6E'/%3e%3cpath%20d='M13.155%2011.755H6.845C6.71239%2011.755%206.58522%2011.7023%206.49145%2011.6086C6.39768%2011.5148%206.345%2011.3876%206.345%2011.255C6.345%2011.1224%206.39768%2010.9952%206.49145%2010.9015C6.58522%2010.8077%206.71239%2010.755%206.845%2010.755H13.155C13.2876%2010.755%2013.4148%2010.8077%2013.5086%2010.9015C13.6023%2010.9952%2013.655%2011.1224%2013.655%2011.255C13.655%2011.3876%2013.6023%2011.5148%2013.5086%2011.6086C13.4148%2011.7023%2013.2876%2011.755%2013.155%2011.755Z'%20fill='%23424E6E'/%3e%3c/svg%3e") no-repeat;
372
- }
373
- .filter.active[data-v-5c047926] {
374
- background: url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10%2014L4%205V3h16v2l-6%209v6l-4%202z'%20fill='%230F45AF'%20/%3e%3c/svg%3e") no-repeat;
375
- }
376
- .filter.active[data-v-5c047926]:hover {
377
- background: url("data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='24'%20height='24'%20rx='4'%20fill='black'%20fill-opacity='0.05'/%3e%3cpath%20d='M10%2014L4%205V3h16v2l-6%209v6l-4%202z'%20fill='%230F45AF'%20/%3e%3c/svg%3e") no-repeat;
378
367
  }.td-shadow-right[data-v-9a0c95c7] {
379
368
  box-shadow: -1px 1px 5px 4px rgba(0, 0, 0, 0.15);
380
369
  clip-path: inset(0px -12px 0px 0px);
@@ -1128,35 +1117,35 @@ to {
1128
1117
  background-image: url("data:image/svg+xml,%3csvg%20width='33'%20height='30'%20viewBox='0%200%2033%2030'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M31.0143%2029.9524C31.1862%2029.9516%2031.3551%2029.9066%2031.5045%2029.8215C31.6539%2029.7365%2031.7789%2029.6144%2031.8674%2029.4669C31.9558%2029.3195%2032.0048%2029.1517%2032.0095%2028.9799C32.0142%2028.808%2031.9745%2028.6378%2031.8943%2028.4857L16.8943%200.485744C16.8006%200.337008%2016.6708%200.214443%2016.5169%200.129498C16.363%200.0445534%2016.1901%200%2016.0143%200C15.8385%200%2015.6656%200.0445534%2015.5117%200.129498C15.3578%200.214443%2015.228%200.337008%2015.1343%200.485744L0.134286%2028.4857C0.0463617%2028.6353%200%2028.8056%200%2028.9791C0%2029.1526%200.0463617%2029.3229%200.134286%2029.4724C0.221436%2029.6207%200.346313%2029.7432%200.496207%2029.8275C0.6461%2029.9118%200.815658%2029.9549%200.98762%2029.9524H31.0143ZM16.0143%2026.2857C15.6176%2026.2857%2015.2299%2026.1677%2014.9004%2025.9467C14.571%2025.7258%2014.3147%2025.4118%2014.1641%2025.0448C14.0136%2024.6778%2013.9755%2024.2743%2014.0549%2023.8857C14.1342%2023.497%2014.3274%2023.1407%2014.6098%2022.8621C14.8922%2022.5835%2015.251%2022.3951%2015.6407%2022.321C16.0304%2022.2468%2016.4334%2022.2903%2016.7983%2022.4458C17.1633%2022.6012%2017.4737%2022.8617%2017.6903%2023.1941C17.9068%2023.5265%2018.0196%2023.9158%2018.0143%2024.3124C18.0073%2024.8382%2017.7935%2025.3401%2017.4192%2025.7094C17.0448%2026.0787%2016.5401%2026.2858%2016.0143%2026.2857ZM16.0143%209.95241C16.3679%209.95241%2016.707%2010.0929%2016.9571%2010.3429C17.2071%2010.593%2017.3476%2010.9321%2017.3476%2011.2857V18.5791C17.3476%2018.9327%2017.2071%2019.2718%2016.9571%2019.5219C16.707%2019.7719%2016.3679%2019.9124%2016.0143%2019.9124C15.6607%2019.9124%2015.3215%2019.7719%2015.0715%2019.5219C14.8214%2019.2718%2014.681%2018.9327%2014.681%2018.5791V11.2857C14.681%2010.9321%2014.8214%2010.593%2015.0715%2010.3429C15.3215%2010.0929%2015.6607%209.95241%2016.0143%209.95241Z'%20fill='%23F2C94C'%20/%3e%3c/svg%3e");
1129
1118
  }
1130
1119
 
1131
- /*# sourceMappingURL=squirrel.css.map */.p-table[data-v-8af637b9] {
1120
+ /*# sourceMappingURL=squirrel.css.map */.p-table[data-v-58c21732] {
1132
1121
  color: rgb(var(--color-night));
1133
1122
  height: 1px;
1134
1123
  }
1135
- .p-table th[data-v-8af637b9] {
1124
+ .p-table th[data-v-58c21732] {
1136
1125
  position: sticky;
1137
1126
  top: 0px;
1138
1127
  z-index: 20;
1139
1128
  padding: 0px;
1140
1129
  }
1141
- .p-table.first-col-fixed th[data-v-8af637b9]:first-child {
1130
+ .p-table.first-col-fixed th[data-v-58c21732]:first-child {
1142
1131
  left: 0px;
1143
1132
  z-index: 30;
1144
1133
  }
1145
- .p-table.first-col-fixed th:first-child .th-shadow[data-v-8af637b9] {
1134
+ .p-table.first-col-fixed th:first-child .th-shadow[data-v-58c21732] {
1146
1135
  box-shadow: -1px 1px 5px 4px rgba(0, 0, 0, 0.15);
1147
1136
  clip-path: inset(0px -12px 0px 0px);
1148
1137
  }
1149
- .p-table.last-col-fixed th[data-v-8af637b9]:last-child {
1138
+ .p-table.last-col-fixed th[data-v-58c21732]:last-child {
1150
1139
  right: 0px;
1151
1140
  z-index: 30;
1152
1141
  }
1153
- .p-table.last-col-fixed th:last-child .th-shadow[data-v-8af637b9] {
1142
+ .p-table.last-col-fixed th:last-child .th-shadow[data-v-58c21732] {
1154
1143
  box-shadow: -2px 1px 8px rgba(0, 0, 0, 0.15);
1155
1144
  clip-path: inset(0px 0px 0px -12px);
1156
1145
  }
1157
- [data-v-8af637b9] .p-table tr:last-child td {
1146
+ [data-v-58c21732] .p-table tr:last-child td {
1158
1147
  border-bottom-width: 0px;
1159
1148
  }
1160
- [data-v-8af637b9] .p-table tr:last-child td.td-col-fixed-border-b::after {
1149
+ [data-v-58c21732] .p-table tr:last-child td.td-col-fixed-border-b::after {
1161
1150
  height: 0px;
1162
1151
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pequity/squirrel",
3
3
  "description": "Squirrel component library",
4
- "version": "8.5.0",
4
+ "version": "8.5.1",
5
5
  "packageManager": "pnpm@10.15.1",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -52,7 +52,6 @@ import {
52
52
  import PTable from '@squirrel/components/p-table/p-table.vue';
53
53
  import { usePTableColResize } from '@squirrel/components/p-table/usePTableColResize';
54
54
  import { usePTableRowVirtualizer } from '@squirrel/components/p-table/usePTableRowVirtualizer';
55
- import PFilterIcon from '@squirrel/components/p-table-header-cell/p-table-filter-icon.vue';
56
55
  import PTableHeaderCell from '@squirrel/components/p-table-header-cell/p-table-header-cell.vue';
57
56
  import PTableLoader from '@squirrel/components/p-table-loader/p-table-loader.vue';
58
57
  import {
@@ -90,7 +89,6 @@ export {
90
89
  PDropdown,
91
90
  PDropdownSelect,
92
91
  PFileUpload,
93
- PFilterIcon,
94
92
  PIcon,
95
93
  PIconAlias,
96
94
  PInfoIcon,
@@ -302,7 +302,7 @@ describe('PTable.vue', () => {
302
302
  props: { cols },
303
303
  });
304
304
 
305
- const filterIcon = wrapper.find('div.cursor-pointer.filter.active');
305
+ const filterIcon = wrapper.findComponent({ name: 'PIcon' });
306
306
  await filterIcon.trigger('click');
307
307
 
308
308
  expect(wrapper.emitted()['click-filter-icon']).toBeTruthy();
@@ -425,4 +425,37 @@ describe('PTable.vue', () => {
425
425
  expect(wrapper.find('table tbody tr:last-child > td').attributes().style).toEqual('height: 100px;');
426
426
  expect(wrapper.find('table tbody tr:last-child').classes()).toEqual([]);
427
427
  });
428
+
429
+ it('emits col-resize event when column resizing stops', async () => {
430
+ const cols = cloneDeep(columns);
431
+ const wrapper = createWrapperFor(PTable, {
432
+ props: {
433
+ cols,
434
+ colsResizable: true,
435
+ data,
436
+ },
437
+ });
438
+
439
+ const resizeHandle = wrapper.find('[data-resize-handle]');
440
+
441
+ // Find the parent th element and mock its dimensions
442
+ const th = resizeHandle.element.closest('th');
443
+ if (th) {
444
+ const mockTds = [{ getBoundingClientRect: () => ({ width: 120 }) }];
445
+ const mockTable = {
446
+ querySelectorAll: vi.fn(() => mockTds),
447
+ };
448
+ Object.defineProperty(th, 'closest', {
449
+ value: vi.fn(() => mockTable),
450
+ configurable: true,
451
+ });
452
+ }
453
+
454
+ await resizeHandle.trigger('dblclick');
455
+
456
+ expect(wrapper.emitted()['col-resize']).toBeTruthy();
457
+ expect(wrapper.emitted()['col-resize'][0]).toHaveLength(2);
458
+ expect(typeof wrapper.emitted()['col-resize'][0][0]).toBe('number');
459
+ expect(typeof wrapper.emitted()['col-resize'][0][1]).toBe('number');
460
+ });
428
461
  });
@@ -33,14 +33,18 @@
33
33
  class="bg-surface"
34
34
  >
35
35
  <div :class="thDivClasses(i)" :style="bgColorStyle(col)">
36
- <div :class="['flex', { 'h-10': hasWrap }]">
36
+ <div :class="['flex', { 'h-8': hasWrap }]">
37
37
  <slot :name="`prepend-header-cell-${kebabCase(col.name)}`" :col="col" />
38
38
  <PTableHeaderCell
39
39
  :text="col.title"
40
40
  :filter-active="col.filterActive"
41
41
  :show-filter-icon="col.filterable || col.sortable"
42
42
  :tooltip-text="col.tooltip"
43
- :class="[{ 'pl-2': i === 1 && isFirstColFixed, 'pr-2': i === cols.length && isLastColFixed }, 'grow']"
43
+ :class="[
44
+ hasWrap ? 'leading-4' : 'leading-5',
45
+ { 'pl-2': i === 1 && isFirstColFixed, 'pr-2': i === cols.length && isLastColFixed },
46
+ 'grow',
47
+ ]"
44
48
  :text-color="headerCellTextColor(col)"
45
49
  v-bind="col.headerCellAttrs"
46
50
  @click-filter-icon="$emit('click-filter-icon', $event, col)"
@@ -1,4 +1,3 @@
1
- import PFilterIcon from '@squirrel/components/p-table-header-cell/p-table-filter-icon.vue';
2
1
  import PTableHeaderCell from '@squirrel/components/p-table-header-cell/p-table-header-cell.vue';
3
2
  import { createWrapperFor } from '@tests/vitest.helpers';
4
3
 
@@ -9,11 +8,16 @@ describe('PTableHeaderCell.vue', () => {
9
8
  text: 'Test text',
10
9
  textClass: 'test-class',
11
10
  },
12
- global: { stubs: { PInfoIcon: true } },
11
+ global: {
12
+ stubs: {
13
+ PInfoIcon: true,
14
+ PIcon: true,
15
+ },
16
+ },
13
17
  });
14
18
 
15
19
  const div = await wrapper.find('div.test-class');
16
- const icon = wrapper.findComponent(PFilterIcon);
20
+ const icon = wrapper.findComponent({ name: 'PIcon' });
17
21
  const tooltipIcon = await wrapper.findComponent({ name: 'PInfoIcon' });
18
22
 
19
23
  expect(wrapper.classes()).toEqual(['flex', 'items-center', 'overflow-hidden']);
@@ -23,7 +27,6 @@ describe('PTableHeaderCell.vue', () => {
23
27
  expect(div.attributes('title')).toBe('Test text');
24
28
  expect(div.classes()).toEqual([
25
29
  'text-xs',
26
- 'leading-5',
27
30
  'font-semibold',
28
31
  'line-clamp-2',
29
32
  'break-words',
@@ -49,11 +52,10 @@ describe('PTableHeaderCell.vue', () => {
49
52
  });
50
53
 
51
54
  const div = wrapper.find('div.test-class');
52
- const icon = wrapper.findComponent(PFilterIcon);
55
+ const icon = wrapper.findComponent({ name: 'PIcon' });
53
56
 
54
- expect(icon.exists()).toBe(true);
55
57
  expect(icon.classes()).not.toContain('hidden');
56
- expect(icon.vm.active).toBe(true);
58
+ expect(icon.classes()).toContain('text-active-blue');
57
59
  expect(div.classes()).toContain('text-active-blue');
58
60
  });
59
61
 
@@ -83,7 +85,9 @@ describe('PTableHeaderCell.vue', () => {
83
85
  },
84
86
  });
85
87
 
86
- await wrapper.find('.filter').trigger('click');
88
+ const icon = wrapper.findComponent({ name: 'PIcon' });
89
+
90
+ await icon.trigger('click');
87
91
 
88
92
  const emittedEvent = wrapper.emitted()['click-filter-icon'][0];
89
93
  const mouseEvent = emittedEvent[0];
@@ -9,22 +9,29 @@
9
9
  {{ text }}
10
10
  </div>
11
11
  <div v-if="tooltipText" class="relative ml-1 mr-auto h-3 w-3 shrink-0">
12
- <PInfoIcon v-if="tooltipText" :text="tooltipText" />
12
+ <PInfoIcon :text="tooltipText" />
13
13
  </div>
14
- <PTableFilterIcon
15
- :class="['ml-2', { hidden: !showFilterIcon }]"
16
- :active="filterActive"
14
+ <PIcon
15
+ :icon="filterActive ? 'ph:funnel-fill' : 'si:filter-list-alt-duotone'"
16
+ :class="[
17
+ 'ml-2 mr-px cursor-pointer rounded-sm',
18
+ { hidden: !showFilterIcon },
19
+ filterActive
20
+ ? 'text-active-blue hover:bg-p-blue-10 hover:text-p-blue-60 hover:ring-1 hover:ring-p-blue-10'
21
+ : 'text-p-gray-60 hover:bg-p-gray-10 hover:text-night hover:ring-1 hover:ring-p-gray-10',
22
+ ]"
23
+ height="16"
17
24
  @click="$emit('click-filter-icon', $event, filterActive)"
18
25
  />
19
26
  </div>
20
27
  </template>
21
28
 
22
- <script lang="ts">
29
+ <script setup lang="ts">
30
+ import PIcon from '@squirrel/components/p-icon/p-icon.vue';
23
31
  import PInfoIcon from '@squirrel/components/p-info-icon/p-info-icon.vue';
24
- import PTableFilterIcon from '@squirrel/components/p-table-header-cell/p-table-filter-icon.vue';
25
- import { defineComponent } from 'vue';
32
+ import { computed } from 'vue';
26
33
 
27
- const DEFAULT_CLASSES = `text-xs leading-5 font-semibold line-clamp-2 break-words hyphens-auto whitespace-normal max-h-10 shrink`;
34
+ const DEFAULT_CLASSES = `text-xs font-semibold line-clamp-2 break-words hyphens-auto whitespace-normal max-h-10 shrink`;
28
35
 
29
36
  /**
30
37
  * A table header cell component that displays text with optional tooltip and filter icon.
@@ -33,85 +40,63 @@ const DEFAULT_CLASSES = `text-xs leading-5 font-semibold line-clamp-2 break-word
33
40
  *
34
41
  * @displayName PTableHeaderCell
35
42
  */
36
- export default defineComponent({
43
+ defineOptions({
37
44
  name: 'PTableHeaderCell',
38
- components: {
39
- PTableFilterIcon,
40
- PInfoIcon,
41
- },
42
- props: {
43
- /**
44
- * The text content to display in the header cell.
45
- * Also used as the title attribute for accessibility.
46
- */
47
- text: {
48
- type: String,
49
- default: '',
50
- },
51
- /**
52
- * CSS classes to apply to the text element.
53
- * Can be a string, object, or array for flexible styling.
54
- */
55
- textClass: {
56
- type: [String, Object, Array],
57
- default: 'text-left',
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
- */
63
- filterActive: {
64
- type: Boolean,
65
- default: false,
66
- },
67
- /**
68
- * Whether to show the filter icon.
69
- * When false, the filter icon is hidden regardless of other states.
70
- */
71
- showFilterIcon: {
72
- type: Boolean,
73
- default: false,
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
- */
79
- tooltipText: {
80
- type: String,
81
- default: '',
82
- },
83
- /**
84
- * Custom text color to apply to the header text.
85
- * Overrides the default text color when provided.
86
- */
87
- textColor: {
88
- type: String,
89
- default: '',
90
- },
91
- },
45
+ });
46
+
47
+ type Props = {
48
+ text?: string;
49
+ textClass?: string;
50
+ filterActive?: boolean;
51
+ showFilterIcon?: boolean;
52
+ tooltipText?: string;
53
+ textColor?: string;
54
+ };
55
+
56
+ const props = withDefaults(defineProps<Props>(), {
57
+ /**
58
+ * The text content to display in the header cell.
59
+ * Also used as the title attribute for accessibility.
60
+ */
61
+ text: '',
62
+ /**
63
+ * CSS classes to apply to the text element.
64
+ * Can be a string, object, or array for flexible styling.
65
+ */
66
+ textClass: 'text-left',
67
+ /**
68
+ * Whether the filter icon is in an active state.
69
+ * Controls the visual appearance of the filter icon and text color.
70
+ */
71
+ filterActive: false,
72
+ /**
73
+ * Whether to show the filter icon.
74
+ */
75
+ showFilterIcon: false,
76
+ /**
77
+ * Tooltip text to display when hovering over the info icon.
78
+ * When provided, shows an info icon with the tooltip content.
79
+ */
80
+ tooltipText: '',
81
+ /**
82
+ * Custom text color to apply to the header text.
83
+ * Overrides the default text color when provided.
84
+ */
85
+ textColor: '',
86
+ });
87
+
88
+ defineEmits<{
92
89
  /**
93
90
  * Emitted when the filter icon is clicked.
94
91
  * @param {Event} event - The click event
95
92
  * @param {boolean} filterActive - The current filter active state
96
93
  */
97
- emits: ['click-filter-icon'],
98
- data() {
99
- return {
100
- DEFAULT_CLASSES,
101
- };
102
- },
103
- computed: {
104
- textColorClass() {
105
- return this.filterActive ? 'text-active-blue' : this.textColor ? '' : 'text-p-gray-60';
106
- },
107
- style() {
108
- if (this.filterActive) {
109
- return {};
110
- }
111
- return {
112
- color: this.textColor,
113
- };
114
- },
115
- },
116
- });
94
+ 'click-filter-icon': [event: Event, filterActive: boolean];
95
+ }>();
96
+
97
+ const textColorClass = computed(() =>
98
+ props.filterActive ? 'text-active-blue' : props.textColor ? '' : 'text-p-gray-60'
99
+ );
100
+
101
+ const style = computed(() => (props.filterActive ? {} : { color: props.textColor }));
117
102
  </script>
@@ -1,28 +0,0 @@
1
- "use strict";
2
- const vue = require("vue");
3
- const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
4
- const _sfc_main = /* @__PURE__ */ vue.defineComponent({
5
- ...{
6
- name: "PTableFilterIcon",
7
- inheritAttrs: false
8
- },
9
- __name: "p-table-filter-icon",
10
- props: {
11
- /**
12
- * Whether the filter icon is active (filtered state).
13
- */
14
- active: {
15
- type: Boolean,
16
- default: false
17
- }
18
- },
19
- setup(__props) {
20
- return (_ctx, _cache) => {
21
- return vue.openBlock(), vue.createElementBlock("div", vue.mergeProps({
22
- class: ["h-5 w-5 shrink-0 cursor-pointer filter", { active: __props.active }]
23
- }, _ctx.$attrs), null, 16);
24
- };
25
- }
26
- });
27
- const PTableFilterIcon = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__scopeId", "data-v-5c047926"]]);
28
- module.exports = PTableFilterIcon;
@@ -1,29 +0,0 @@
1
- import { defineComponent, createElementBlock, openBlock, mergeProps } from "vue";
2
- import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
3
- const _sfc_main = /* @__PURE__ */ defineComponent({
4
- ...{
5
- name: "PTableFilterIcon",
6
- inheritAttrs: false
7
- },
8
- __name: "p-table-filter-icon",
9
- props: {
10
- /**
11
- * Whether the filter icon is active (filtered state).
12
- */
13
- active: {
14
- type: Boolean,
15
- default: false
16
- }
17
- },
18
- setup(__props) {
19
- return (_ctx, _cache) => {
20
- return openBlock(), createElementBlock("div", mergeProps({
21
- class: ["h-5 w-5 shrink-0 cursor-pointer filter", { active: __props.active }]
22
- }, _ctx.$attrs), null, 16);
23
- };
24
- }
25
- });
26
- const PTableFilterIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5c047926"]]);
27
- export {
28
- PTableFilterIcon as default
29
- };
@@ -1,20 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
- /**
3
- * Whether the filter icon is active (filtered state).
4
- */
5
- active: {
6
- type: BooleanConstructor;
7
- default: boolean;
8
- };
9
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
10
- /**
11
- * Whether the filter icon is active (filtered state).
12
- */
13
- active: {
14
- type: BooleanConstructor;
15
- default: boolean;
16
- };
17
- }>> & Readonly<{}>, {
18
- active: boolean;
19
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
20
- export default _default;