@pequity/squirrel 8.4.5 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/cjs/chunks/index.js +530 -179
- package/dist/cjs/chunks/p-alert.js +11 -16
- package/dist/cjs/chunks/p-btn.js +1 -1
- package/dist/cjs/chunks/p-input-percent.js +2 -2
- package/dist/cjs/index.js +33 -27
- package/dist/cjs/inputClasses.js +3 -3
- package/dist/cjs/p-icon.js +2 -1
- package/dist/cjs/p-loading.js +2 -2
- package/dist/cjs/p-modal.js +45 -43
- package/dist/cjs/p-table-header-cell.js +3 -2
- package/dist/cjs/p-table.js +2 -0
- package/dist/cjs/usePTableHeaderWrap.js +38 -0
- package/dist/es/chunks/index.js +530 -179
- package/dist/es/chunks/p-alert.js +11 -16
- package/dist/es/chunks/p-btn.js +2 -2
- package/dist/es/chunks/p-input-percent.js +2 -2
- package/dist/es/index.js +39 -33
- package/dist/es/inputClasses.js +4 -4
- package/dist/es/p-icon.js +2 -1
- package/dist/es/p-loading.js +2 -2
- package/dist/es/p-modal.js +45 -43
- package/dist/es/p-table-header-cell.js +3 -2
- package/dist/es/p-table.js +2 -0
- package/dist/es/usePTableHeaderWrap.js +38 -0
- package/dist/squirrel/components/p-action-bar/p-action-bar.vue.d.ts +1 -1
- package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +2 -2
- package/dist/squirrel/components/p-avatar/p-avatar.vue.d.ts +1 -1
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +3 -3
- package/dist/squirrel/components/p-card/p-card.vue.d.ts +1 -1
- package/dist/squirrel/components/p-checkbox/p-checkbox.vue.d.ts +1 -1
- package/dist/squirrel/components/p-close-btn/p-close-btn.vue.d.ts +1 -1
- package/dist/squirrel/components/p-date-picker/p-date-picker.vue.d.ts +1 -1
- package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +12 -12
- package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +1 -1
- package/dist/squirrel/components/p-file-upload/p-file-upload.vue.d.ts +1 -1
- package/dist/squirrel/components/p-icon/p-icon.types.d.ts +1 -0
- package/dist/squirrel/components/p-icon/p-icon.vue.d.ts +1 -1
- package/dist/squirrel/components/p-info-icon/p-info-icon.vue.d.ts +1 -1
- package/dist/squirrel/components/p-inline-date-picker/p-inline-date-picker.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +1 -1
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +1 -1
- package/dist/squirrel/components/p-link/p-link.vue.d.ts +1 -1
- package/dist/squirrel/components/p-loading/p-loading.vue.d.ts +1 -1
- package/dist/squirrel/components/p-modal/p-modal.vue.d.ts +5 -1
- package/dist/squirrel/components/p-pagination/p-pagination.vue.d.ts +1 -1
- package/dist/squirrel/components/p-pagination-info/p-pagination-info.vue.d.ts +1 -1
- package/dist/squirrel/components/p-progress-bar/p-progress-bar.vue.d.ts +1 -1
- package/dist/squirrel/components/p-ring-loader/p-ring-loader.vue.d.ts +1 -1
- package/dist/squirrel/components/p-select/p-select.vue.d.ts +1 -1
- package/dist/squirrel/components/p-select-btn/p-select-btn.vue.d.ts +1 -1
- package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +1 -1
- package/dist/squirrel/components/p-steps/p-steps.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table/p-table.types.d.ts +1 -0
- package/dist/squirrel/components/p-table/p-table.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table/usePTableHeaderWrap.d.ts +4 -0
- package/dist/squirrel/components/p-table-header-cell/p-table-filter-icon.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +3 -3
- package/dist/squirrel/components/p-table-loader/p-table-loader.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-sort/p-table-sort.vue.d.ts +1 -1
- package/dist/squirrel/components/p-table-td/p-table-td.vue.d.ts +1 -1
- package/dist/squirrel/components/p-tabs/p-tabs.vue.d.ts +1 -1
- package/dist/squirrel/components/p-tabs-pills/p-tabs-pills.vue.d.ts +1 -1
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +1 -1
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +1 -1
- package/dist/squirrel.css +22 -22
- package/package.json +23 -21
- package/squirrel/components/p-alert/p-alert.spec.js +4 -4
- package/squirrel/components/p-alert/p-alert.stories.js +19 -13
- package/squirrel/components/p-alert/p-alert.vue +9 -11
- package/squirrel/components/p-icon/p-icon.types.ts +1 -0
- package/squirrel/components/p-modal/p-modal-basic.spec.js +29 -3
- package/squirrel/components/p-modal/p-modal.vue +44 -33
- package/squirrel/components/p-table/p-table.spec.js +51 -15
- package/squirrel/components/p-table/p-table.types.ts +2 -0
- package/squirrel/components/p-table/p-table.vue +7 -4
- package/squirrel/components/p-table/usePTableHeaderWrap.spec.js +118 -0
- package/squirrel/components/p-table/usePTableHeaderWrap.ts +45 -0
- package/squirrel/components/p-table-header-cell/p-table-header-cell.spec.js +5 -1
- package/squirrel/components/p-table-header-cell/p-table-header-cell.vue +2 -1
|
@@ -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
|
+
};
|
|
@@ -25,7 +25,11 @@ describe('PTableHeaderCell.vue', () => {
|
|
|
25
25
|
'text-xs',
|
|
26
26
|
'leading-5',
|
|
27
27
|
'font-semibold',
|
|
28
|
-
'
|
|
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,7 +24,7 @@ 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
|
|
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
|
|
|
28
29
|
/**
|
|
29
30
|
* A table header cell component that displays text with optional tooltip and filter icon.
|