yuyeon 0.3.2-rc.8 → 0.3.3
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/dist/style.css +1 -1
- package/dist/yuyeon.js +3483 -3270
- package/dist/yuyeon.umd.cjs +3 -3
- package/lib/components/table/YDataTable.js +25 -14
- package/lib/components/table/YDataTable.js.map +1 -1
- package/lib/components/table/YDataTableBody.js +14 -18
- package/lib/components/table/YDataTableBody.js.map +1 -1
- package/lib/components/table/YDataTableControl.js +1 -1
- package/lib/components/table/YDataTableControl.js.map +1 -1
- package/lib/components/table/YDataTableHead.js +3 -3
- package/lib/components/table/YDataTableHead.js.map +1 -1
- package/lib/components/table/YDataTableLayer.js +11 -4
- package/lib/components/table/YDataTableLayer.js.map +1 -1
- package/lib/components/table/YDataTableLayerRow.js +87 -0
- package/lib/components/table/YDataTableLayerRow.js.map +1 -0
- package/lib/components/table/YDataTableLayerRow.vue +146 -0
- package/lib/components/table/YDataTableLayerRows.js +60 -0
- package/lib/components/table/YDataTableLayerRows.js.map +1 -0
- package/lib/components/table/YDataTableLayerRows.scss +14 -0
- package/lib/components/table/YDataTableRow.js +13 -5
- package/lib/components/table/YDataTableRow.js.map +1 -1
- package/lib/components/table/YDataTableRows.scss +14 -0
- package/lib/components/table/YDataTableServer.js +27 -17
- package/lib/components/table/YDataTableServer.js.map +1 -1
- package/lib/components/table/YTable.js +8 -3
- package/lib/components/table/YTable.js.map +1 -1
- package/lib/components/table/composables/expand.js +49 -0
- package/lib/components/table/composables/expand.js.map +1 -0
- package/lib/components/table/composables/header.js +127 -0
- package/lib/components/table/composables/header.js.map +1 -0
- package/lib/components/table/composables/items.js +58 -0
- package/lib/components/table/composables/items.js.map +1 -0
- package/lib/components/table/composables/measure.js +55 -0
- package/lib/components/table/composables/measure.js.map +1 -0
- package/lib/components/table/composables/options.js +33 -0
- package/lib/components/table/composables/options.js.map +1 -0
- package/lib/components/table/composables/pagination.js +99 -0
- package/lib/components/table/composables/pagination.js.map +1 -0
- package/lib/components/table/composables/provides.js +3 -0
- package/lib/components/table/composables/provides.js.map +1 -0
- package/lib/components/table/composables/selection.js +196 -0
- package/lib/components/table/composables/selection.js.map +1 -0
- package/lib/components/table/composables/sorted-items.js +50 -0
- package/lib/components/table/composables/sorted-items.js.map +1 -0
- package/lib/components/table/composables/sorting.js +73 -0
- package/lib/components/table/composables/sorting.js.map +1 -0
- package/lib/components/table/composibles/measure.js +21 -5
- package/lib/components/table/composibles/measure.js.map +1 -1
- package/lib/components/table/index.js +2 -0
- package/lib/components/table/index.js.map +1 -1
- package/lib/components/table/types/index.js.map +1 -1
- package/lib/components/table/types/item.js.map +1 -1
- package/package.json +5 -2
- package/types/components/table/YDataTable.d.ts +22 -0
- package/types/components/table/YDataTableBody.d.ts +1 -3
- package/types/components/table/YDataTableLayer.d.ts +4 -1
- package/types/components/table/YDataTableLayerRow.d.ts +22 -0
- package/types/components/table/YDataTableLayerRows.d.ts +9 -0
- package/types/components/table/YDataTableServer.d.ts +22 -0
- package/types/components/table/composables/expand.d.ts +42 -0
- package/types/components/table/composables/header.d.ts +207 -0
- package/types/components/table/composables/items.d.ts +55 -0
- package/types/components/table/composables/measure.d.ts +8 -0
- package/types/components/table/composables/options.d.ts +11 -0
- package/types/components/table/composables/pagination.d.ts +81 -0
- package/types/components/table/composables/provides.d.ts +15 -0
- package/types/components/table/composables/selection.d.ts +82 -0
- package/types/components/table/composables/sorted-items.d.ts +7 -0
- package/types/components/table/composables/sorting.d.ts +62 -0
- package/types/components/table/index.d.ts +2 -0
- package/types/components/table/types/index.d.ts +1 -1
- package/types/components/table/types/item.d.ts +2 -1
- package/types/shims.d.ts +58 -56
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { mergeProps as _mergeProps, createVNode as _createVNode, resolveDirective as _resolveDirective, Fragment as _Fragment } from "vue";
|
|
2
|
-
import { computed, provide, ref, toRef } from 'vue';
|
|
2
|
+
import { Fragment, computed, provide, ref, toRef } from 'vue';
|
|
3
|
+
import { pressDataTableExpandProps, provideExpand } from "./composables/expand.js";
|
|
4
|
+
import { createHeader, pressDataTableHeader } from "./composables/header.js";
|
|
5
|
+
import { pressDataTableItemsProps, useItems } from "./composables/items.js";
|
|
6
|
+
import { useOptions } from "./composables/options.js";
|
|
7
|
+
import { createPagination, pressDataTablePaginationProps, providePagination, usePaginatedItems } from "./composables/pagination.js";
|
|
8
|
+
import { YDataTableInjectionKey } from "./composables/provides.js";
|
|
9
|
+
import { pressDataTableSelectionProps, provideSelection } from "./composables/selection.js";
|
|
10
|
+
import { useSortedItems } from "./composables/sorted-items.js";
|
|
11
|
+
import { createSorting, pressDataTableSortProps, provideSorting } from "./composables/sorting.js";
|
|
3
12
|
import { useRender } from "../../composables/component.js";
|
|
4
13
|
import { useResizeObserver } from "../../composables/resize-observer.js";
|
|
5
14
|
import { chooseProps, defineComponent, propsFactory } from "../../util/component/index.js";
|
|
@@ -9,13 +18,6 @@ import { YDataTableControl } from "./YDataTableControl.js";
|
|
|
9
18
|
import { YDataTableHead, pressYDataTableHeadProps } from "./YDataTableHead.js";
|
|
10
19
|
import { YDataTableLayer } from "./YDataTableLayer.js";
|
|
11
20
|
import { YTable, pressYTableProps } from "./YTable.js";
|
|
12
|
-
import { createHeader, pressDataTableHeader } from "./composibles/header.js";
|
|
13
|
-
import { pressDataTableItemsProps, useItems } from "./composibles/items.js";
|
|
14
|
-
import { useOptions } from "./composibles/options.js";
|
|
15
|
-
import { createPagination, pressDataTablePaginationProps, providePagination, usePaginatedItems } from "./composibles/pagination.js";
|
|
16
|
-
import { pressDataTableSelectionProps, provideSelection } from "./composibles/selection.js";
|
|
17
|
-
import { useSortedItems } from "./composibles/sorted-items.js";
|
|
18
|
-
import { createSorting, pressDataTableSortProps, provideSorting } from "./composibles/sorting.js";
|
|
19
21
|
export const pressDataTableProps = propsFactory({
|
|
20
22
|
...pressYDataTableBodyProps(),
|
|
21
23
|
width: [String, Number],
|
|
@@ -25,6 +27,7 @@ export const pressDataTableProps = propsFactory({
|
|
|
25
27
|
...pressDataTableItemsProps(),
|
|
26
28
|
...pressDataTableSortProps(),
|
|
27
29
|
...pressDataTableSelectionProps(),
|
|
30
|
+
...pressDataTableExpandProps(),
|
|
28
31
|
...pressYDataTableHeadProps(),
|
|
29
32
|
...pressYTableProps()
|
|
30
33
|
}, 'DataTable');
|
|
@@ -40,6 +43,7 @@ export const YDataTable = defineComponent({
|
|
|
40
43
|
'update:pageSize': pageSize => true,
|
|
41
44
|
'update:sortBy': sortBy => true,
|
|
42
45
|
'update:options': options => true,
|
|
46
|
+
'update:expanded': expanded => true,
|
|
43
47
|
'click:row': (e, value) => true,
|
|
44
48
|
scroll: e => true
|
|
45
49
|
},
|
|
@@ -107,6 +111,10 @@ export const YDataTable = defineComponent({
|
|
|
107
111
|
allItems: items,
|
|
108
112
|
pageItems: items
|
|
109
113
|
});
|
|
114
|
+
const {
|
|
115
|
+
isExpanded,
|
|
116
|
+
toggleExpand
|
|
117
|
+
} = provideExpand(props);
|
|
110
118
|
const {
|
|
111
119
|
resizeObservedRef: headObserveRef,
|
|
112
120
|
contentRect: headRect
|
|
@@ -117,11 +125,6 @@ export const YDataTable = defineComponent({
|
|
|
117
125
|
search: toRef(props, 'search'),
|
|
118
126
|
sortBy
|
|
119
127
|
}, emit);
|
|
120
|
-
provide('y-data-table', {
|
|
121
|
-
toggleSort,
|
|
122
|
-
sortBy,
|
|
123
|
-
headRect
|
|
124
|
-
});
|
|
125
128
|
const slotProps = computed(() => {
|
|
126
129
|
return {
|
|
127
130
|
// pagination
|
|
@@ -133,6 +136,9 @@ export const YDataTable = defineComponent({
|
|
|
133
136
|
// sorting
|
|
134
137
|
sortBy: sortBy.value,
|
|
135
138
|
toggleSort,
|
|
139
|
+
// expand
|
|
140
|
+
isExpanded,
|
|
141
|
+
toggleExpand,
|
|
136
142
|
// selection
|
|
137
143
|
someSelected: someSelected.value,
|
|
138
144
|
allSelected: allSelected.value,
|
|
@@ -140,7 +146,7 @@ export const YDataTable = defineComponent({
|
|
|
140
146
|
select,
|
|
141
147
|
selectAll,
|
|
142
148
|
toggleSelect,
|
|
143
|
-
//
|
|
149
|
+
// matrix
|
|
144
150
|
items: paginatedItems.value,
|
|
145
151
|
columns: columns.value,
|
|
146
152
|
headers: headers.value,
|
|
@@ -148,6 +154,11 @@ export const YDataTable = defineComponent({
|
|
|
148
154
|
TableBodyRef
|
|
149
155
|
};
|
|
150
156
|
});
|
|
157
|
+
provide(YDataTableInjectionKey, {
|
|
158
|
+
toggleSort,
|
|
159
|
+
sortBy,
|
|
160
|
+
headRect
|
|
161
|
+
});
|
|
151
162
|
useRender(() => {
|
|
152
163
|
const yDataTableHeadProps = chooseProps(props, YDataTableHead.props);
|
|
153
164
|
const yDataTableBodyProps = chooseProps(props, YDataTableBody.props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDataTable.js","names":["computed","provide","ref","toRef","useRender","useResizeObserver","chooseProps","defineComponent","propsFactory","toStyleSizeValue","YDataTableBody","pressYDataTableBodyProps","YDataTableControl","YDataTableHead","pressYDataTableHeadProps","YDataTableLayer","YTable","pressYTableProps","createHeader","pressDataTableHeader","pressDataTableItemsProps","useItems","useOptions","createPagination","pressDataTablePaginationProps","providePagination","usePaginatedItems","pressDataTableSelectionProps","provideSelection","useSortedItems","createSorting","pressDataTableSortProps","provideSorting","pressDataTableProps","width","String","Number","search","hideDefaultTbody","Boolean","YDataTable","name","props","emits","value","page","pageSize","sortBy","options","click:row","e","scroll","setup","_ref","slots","emit","TableBodyRef","multiSort","columns","headers","enableSelect","items","toggleSort","total","length","startIndex","endIndex","pageLength","setPageSize","setPage","sortedItems","paginatedItems","isSelected","select","selectAll","toggleSelect","someSelected","allSelected","allItems","pageItems","resizeObservedRef","headObserveRef","contentRect","headRect","slotProps","yDataTableHeadProps","yDataTableBodyProps","yTableProps","_createVNode","_mergeProps","loading","hideNoData","height","top","leading","_Fragment","default","thead","tbody","tfoot","trailing","bottom","prepend","append"],"sources":["../../../src/components/table/YDataTable.tsx"],"sourcesContent":["import { type PropType, computed, provide, ref, toRef } from 'vue';\n\nimport { useRender } from '@/composables/component';\nimport { useResizeObserver } from '@/composables/resize-observer';\nimport { chooseProps, defineComponent, propsFactory } from '@/util/component';\nimport { toStyleSizeValue } from '@/util/ui';\n\nimport { YDataTableBody, pressYDataTableBodyProps } from './YDataTableBody';\nimport { YDataTableControl } from './YDataTableControl';\nimport { YDataTableHead, pressYDataTableHeadProps } from './YDataTableHead';\nimport { YDataTableLayer } from './YDataTableLayer';\nimport { YTable, pressYTableProps } from './YTable';\nimport { createHeader, pressDataTableHeader } from './composibles/header';\nimport { pressDataTableItemsProps, useItems } from './composibles/items';\nimport { useOptions } from './composibles/options';\nimport {\n createPagination,\n pressDataTablePaginationProps,\n providePagination,\n usePaginatedItems,\n} from './composibles/pagination';\nimport {\n pressDataTableSelectionProps,\n provideSelection,\n} from './composibles/selection';\nimport { useSortedItems } from './composibles/sorted-items';\nimport {\n createSorting,\n pressDataTableSortProps,\n provideSorting,\n} from './composibles/sorting';\nimport { YDataTableSlotProps } from './types';\n\nexport const pressDataTableProps = propsFactory(\n {\n ...pressYDataTableBodyProps(),\n width: [String, Number] as PropType<string | number>,\n search: String as PropType<string>,\n hideDefaultTbody: Boolean,\n ...pressDataTableHeader(),\n ...pressDataTableItemsProps(),\n ...pressDataTableSortProps(),\n ...pressDataTableSelectionProps(),\n ...pressYDataTableHeadProps(),\n ...pressYTableProps(),\n },\n 'DataTable',\n);\n\nexport const YDataTable = defineComponent({\n name: 'YDataTable',\n props: {\n ...pressDataTablePaginationProps(),\n ...pressDataTableProps(),\n },\n emits: {\n 'update:modelValue': (value: any[]) => true,\n 'update:page': (page: number) => true,\n 'update:pageSize': (pageSize: number) => true,\n 'update:sortBy': (sortBy: any) => true,\n 'update:options': (options: any) => true,\n 'click:row': (e: Event, value: { row: any }) => true,\n scroll: (e: Event) => true,\n },\n setup(props, { slots, emit }) {\n const TableBodyRef = ref();\n const { page, pageSize } = createPagination(props);\n const { sortBy, multiSort } = createSorting(props);\n const { columns, headers } = createHeader(props, {\n enableSelect: toRef(props, 'enableSelect'),\n });\n const { items } = useItems(props, columns);\n const { toggleSort } = provideSorting({ sortBy, multiSort, page });\n const total = computed(() => items.value.length);\n const { startIndex, endIndex, pageLength, setPageSize, setPage } =\n providePagination({\n page,\n pageSize,\n total,\n });\n const { sortedItems } = useSortedItems(props, items, sortBy);\n const { paginatedItems } = usePaginatedItems({\n items: sortedItems,\n startIndex,\n endIndex,\n pageSize,\n });\n const {\n isSelected,\n select,\n selectAll,\n toggleSelect,\n someSelected,\n allSelected,\n } = provideSelection(props, { allItems: items, pageItems: items });\n\n const { resizeObservedRef: headObserveRef, contentRect: headRect } =\n useResizeObserver();\n\n useOptions(\n {\n page,\n pageSize,\n search: toRef(props, 'search'),\n sortBy,\n },\n emit,\n );\n\n provide('y-data-table', {\n toggleSort,\n sortBy,\n headRect,\n });\n\n const slotProps = computed<YDataTableSlotProps>(() => {\n return {\n // pagination\n page: page.value,\n pageSize: pageSize.value,\n pageLength: pageLength.value,\n setPageSize,\n setPage,\n // sorting\n sortBy: sortBy.value,\n toggleSort,\n // selection\n someSelected: someSelected.value,\n allSelected: allSelected.value,\n isSelected,\n select,\n selectAll,\n toggleSelect,\n //\n items: paginatedItems.value,\n columns: columns.value,\n headers: headers.value,\n //\n TableBodyRef,\n };\n });\n\n useRender(() => {\n const yDataTableHeadProps = chooseProps(props, YDataTableHead.props);\n const yDataTableBodyProps = chooseProps(props, YDataTableBody.props);\n const yTableProps = chooseProps(props, YTable.props);\n return (\n <YTable\n class={[\n 'y-data-table',\n {\n 'y-data-table--no-data':\n !props.loading && props.items.length < 1 && !props.hideNoData,\n },\n ]}\n {...yTableProps}\n style={{\n '--y-table-head-height': toStyleSizeValue(headRect.value?.height),\n }}\n >\n {{\n top: () => slots.top?.(slotProps.value),\n leading: () =>\n slots.leading ? (\n slots.leading(slotProps.value)\n ) : (\n <>\n <YDataTableLayer\n v-slots={slots}\n slot-props={slotProps.value}\n ></YDataTableLayer>\n </>\n ),\n default: () =>\n slots.default ? (\n slots.default(slotProps.value)\n ) : (\n <>\n <thead ref={headObserveRef}>\n <YDataTableHead\n v-slots={slots}\n {...yDataTableHeadProps}\n ></YDataTableHead>\n </thead>\n {slots.thead?.(slotProps.value)}\n {!props.hideDefaultTbody && (\n <tbody>\n <YDataTableBody\n ref={TableBodyRef}\n v-slots={slots}\n {...yDataTableBodyProps}\n items={slotProps.value.items}\n ></YDataTableBody>\n </tbody>\n )}\n {slots.tbody?.(slotProps.value)}\n {slots.tfoot?.(slotProps.value)}\n </>\n ),\n trailing: () => slots.trailing?.(slotProps.value),\n bottom: () =>\n slots.bottom ? (\n slots.bottom(slotProps.value)\n ) : (\n <YDataTableControl\n v-slots={{\n prepend: slots['control.prepend'],\n append: slots['control.append'],\n }}\n ></YDataTableControl>\n ),\n }}\n </YTable>\n );\n });\n return { paginatedItems };\n },\n});\n\nexport type YDataTable = InstanceType<typeof YDataTable>;\n"],"mappings":";AAAA,SAAwBA,QAAQ,EAAEC,OAAO,EAAEC,GAAG,EAAEC,KAAK,QAAQ,KAAK;AAAC,SAE1DC,SAAS;AAAA,SACTC,iBAAiB;AAAA,SACjBC,WAAW,EAAEC,eAAe,EAAEC,YAAY;AAAA,SAC1CC,gBAAgB;AAAA,SAEhBC,cAAc,EAAEC,wBAAwB;AAAA,SACxCC,iBAAiB;AAAA,SACjBC,cAAc,EAAEC,wBAAwB;AAAA,SACxCC,eAAe;AAAA,SACfC,MAAM,EAAEC,gBAAgB;AAAA,SACxBC,YAAY,EAAEC,oBAAoB;AAAA,SAClCC,wBAAwB,EAAEC,QAAQ;AAAA,SAClCC,UAAU;AAAA,SAEjBC,gBAAgB,EAChBC,6BAA6B,EAC7BC,iBAAiB,EACjBC,iBAAiB;AAAA,SAGjBC,4BAA4B,EAC5BC,gBAAgB;AAAA,SAETC,cAAc;AAAA,SAErBC,aAAa,EACbC,uBAAu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0F,OAAO,EAAEhD,KAAK,CAAC,iBAAiB,CAAC;UACjCiD,MAAM,EAAEjD,KAAK,CAAC,gBAAgB;QAChC,CAAC;MAEJ;IAIX,CAAC,CAAC;IACF,OAAO;MAAEiB;IAAe,CAAC;EAC3B;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YDataTable.js","names":["Fragment","computed","provide","ref","toRef","pressDataTableExpandProps","provideExpand","createHeader","pressDataTableHeader","pressDataTableItemsProps","useItems","useOptions","createPagination","pressDataTablePaginationProps","providePagination","usePaginatedItems","YDataTableInjectionKey","pressDataTableSelectionProps","provideSelection","useSortedItems","createSorting","pressDataTableSortProps","provideSorting","useRender","useResizeObserver","chooseProps","defineComponent","propsFactory","toStyleSizeValue","YDataTableBody","pressYDataTableBodyProps","YDataTableControl","YDataTableHead","pressYDataTableHeadProps","YDataTableLayer","YTable","pressYTableProps","pressDataTableProps","width","String","Number","search","hideDefaultTbody","Boolean","YDataTable","name","props","emits","value","page","pageSize","sortBy","options","expanded","click:row","e","scroll","setup","_ref","slots","emit","TableBodyRef","multiSort","columns","headers","enableSelect","items","toggleSort","total","length","startIndex","endIndex","pageLength","setPageSize","setPage","sortedItems","paginatedItems","isSelected","select","selectAll","toggleSelect","someSelected","allSelected","allItems","pageItems","isExpanded","toggleExpand","resizeObservedRef","headObserveRef","contentRect","headRect","slotProps","yDataTableHeadProps","yDataTableBodyProps","yTableProps","_createVNode","_mergeProps","loading","hideNoData","height","top","leading","_Fragment","default","thead","tbody","tfoot","trailing","bottom","prepend","append"],"sources":["../../../src/components/table/YDataTable.tsx"],"sourcesContent":["import { Fragment, type PropType, computed, provide, ref, toRef } from 'vue';\n\nimport {\n pressDataTableExpandProps,\n provideExpand,\n} from '@/components/table/composables/expand';\nimport {\n createHeader,\n pressDataTableHeader,\n} from '@/components/table/composables/header';\nimport {\n pressDataTableItemsProps,\n useItems,\n} from '@/components/table/composables/items';\nimport { useOptions } from '@/components/table/composables/options';\nimport {\n createPagination,\n pressDataTablePaginationProps,\n providePagination,\n usePaginatedItems,\n} from '@/components/table/composables/pagination';\nimport { YDataTableInjectionKey } from '@/components/table/composables/provides';\nimport {\n pressDataTableSelectionProps,\n provideSelection,\n} from '@/components/table/composables/selection';\nimport { useSortedItems } from '@/components/table/composables/sorted-items';\nimport {\n createSorting,\n pressDataTableSortProps,\n provideSorting,\n} from '@/components/table/composables/sorting';\nimport { useRender } from '@/composables/component';\nimport { useResizeObserver } from '@/composables/resize-observer';\nimport { chooseProps, defineComponent, propsFactory } from '@/util/component';\nimport { toStyleSizeValue } from '@/util/ui';\n\nimport { YDataTableBody, pressYDataTableBodyProps } from './YDataTableBody';\nimport { YDataTableControl } from './YDataTableControl';\nimport { YDataTableHead, pressYDataTableHeadProps } from './YDataTableHead';\nimport { YDataTableLayer } from './YDataTableLayer';\nimport { YTable, pressYTableProps } from './YTable';\nimport { YDataTableSlotProps } from './types';\n\nexport const pressDataTableProps = propsFactory(\n {\n ...pressYDataTableBodyProps(),\n width: [String, Number] as PropType<string | number>,\n search: String as PropType<string>,\n hideDefaultTbody: Boolean,\n ...pressDataTableHeader(),\n ...pressDataTableItemsProps(),\n ...pressDataTableSortProps(),\n ...pressDataTableSelectionProps(),\n ...pressDataTableExpandProps(),\n ...pressYDataTableHeadProps(),\n ...pressYTableProps(),\n },\n 'DataTable',\n);\n\nexport const YDataTable = defineComponent({\n name: 'YDataTable',\n props: {\n ...pressDataTablePaginationProps(),\n ...pressDataTableProps(),\n },\n emits: {\n 'update:modelValue': (value: any[]) => true,\n 'update:page': (page: number) => true,\n 'update:pageSize': (pageSize: number) => true,\n 'update:sortBy': (sortBy: any) => true,\n 'update:options': (options: any) => true,\n 'update:expanded': (expanded: any[]) => true,\n 'click:row': (e: Event, value: { row: any }) => true,\n scroll: (e: Event) => true,\n },\n setup(props, { slots, emit }) {\n const TableBodyRef = ref();\n const { page, pageSize } = createPagination(props);\n const { sortBy, multiSort } = createSorting(props);\n const { columns, headers } = createHeader(props, {\n enableSelect: toRef(props, 'enableSelect'),\n });\n const { items } = useItems(props, columns);\n const { toggleSort } = provideSorting({ sortBy, multiSort, page });\n const total = computed(() => items.value.length);\n const { startIndex, endIndex, pageLength, setPageSize, setPage } =\n providePagination({\n page,\n pageSize,\n total,\n });\n const { sortedItems } = useSortedItems(props, items, sortBy);\n const { paginatedItems } = usePaginatedItems({\n items: sortedItems,\n startIndex,\n endIndex,\n pageSize,\n });\n const {\n isSelected,\n select,\n selectAll,\n toggleSelect,\n someSelected,\n allSelected,\n } = provideSelection(props, { allItems: items, pageItems: items });\n const { isExpanded, toggleExpand } = provideExpand(props);\n\n const { resizeObservedRef: headObserveRef, contentRect: headRect } =\n useResizeObserver();\n\n useOptions(\n {\n page,\n pageSize,\n search: toRef(props, 'search'),\n sortBy,\n },\n emit,\n );\n\n const slotProps = computed<YDataTableSlotProps>(() => {\n return {\n // pagination\n page: page.value,\n pageSize: pageSize.value,\n pageLength: pageLength.value,\n setPageSize,\n setPage,\n // sorting\n sortBy: sortBy.value,\n toggleSort,\n // expand\n isExpanded,\n toggleExpand,\n // selection\n someSelected: someSelected.value,\n allSelected: allSelected.value,\n isSelected,\n select,\n selectAll,\n toggleSelect,\n // matrix\n items: paginatedItems.value,\n columns: columns.value,\n headers: headers.value,\n //\n TableBodyRef,\n };\n });\n\n provide(YDataTableInjectionKey, {\n toggleSort,\n sortBy,\n headRect,\n });\n\n useRender(() => {\n const yDataTableHeadProps = chooseProps(props, YDataTableHead.props);\n const yDataTableBodyProps = chooseProps(props, YDataTableBody.props);\n const yTableProps = chooseProps(props, YTable.props);\n return (\n <YTable\n class={[\n 'y-data-table',\n {\n 'y-data-table--no-data':\n !props.loading && props.items.length < 1 && !props.hideNoData,\n },\n ]}\n {...yTableProps}\n style={{\n '--y-table-head-height': toStyleSizeValue(headRect.value?.height),\n }}\n >\n {{\n top: () => slots.top?.(slotProps.value),\n leading: () =>\n slots.leading ? (\n slots.leading(slotProps.value)\n ) : (\n <>\n <YDataTableLayer\n v-slots={slots}\n slot-props={slotProps.value}\n ></YDataTableLayer>\n </>\n ),\n default: () =>\n slots.default ? (\n slots.default(slotProps.value)\n ) : (\n <Fragment>\n <thead ref={headObserveRef}>\n <YDataTableHead\n v-slots={slots}\n {...yDataTableHeadProps}\n ></YDataTableHead>\n </thead>\n {slots.thead?.(slotProps.value)}\n {!props.hideDefaultTbody && (\n <tbody>\n <YDataTableBody\n ref={TableBodyRef}\n v-slots={slots}\n {...yDataTableBodyProps}\n items={slotProps.value.items}\n ></YDataTableBody>\n </tbody>\n )}\n {slots.tbody?.(slotProps.value)}\n {slots.tfoot?.(slotProps.value)}\n </Fragment>\n ),\n trailing: () => slots.trailing?.(slotProps.value),\n bottom: () =>\n slots.bottom ? (\n slots.bottom(slotProps.value)\n ) : (\n <YDataTableControl\n v-slots={{\n prepend: slots['control.prepend'],\n append: slots['control.append'],\n }}\n ></YDataTableControl>\n ),\n }}\n </YTable>\n );\n });\n\n return { paginatedItems };\n },\n});\n\nexport type YDataTable = InstanceType<typeof YDataTable>;\n"],"mappings":";AAAA,SAASA,QAAQ,EAAiBC,QAAQ,EAAEC,OAAO,EAAEC,GAAG,EAAEC,KAAK,QAAQ,KAAK;AAAC,SAG3EC,yBAAyB,EACzBC,aAAa;AAAA,SAGbC,YAAY,EACZC,oBAAoB;AAAA,SAGpBC,wBAAwB,EACxBC,QAAQ;AAAA,SAEDC,UAAU;AAAA,SAEjBC,gBAAgB,EAChBC,6BAA6B,EAC7BC,iBAAiB,EACjBC,iBAAiB;AAAA,SAEVC,sBAAsB;AAAA,SAE7BC,4BAA4B,EAC5BC,gBAAgB;AAAA,SAETC,cAAc;AAAA,SAErBC,aAAa,EACbC,uBAAuB,EACvBC,cAAc;AAAA,SAEPC,SAAS;AAAA,SACTC,iBAAiB;AAAA,SACjBC,WAAW,EAAEC,eAAe,EAAEC,YAAY;AAAA,SAC1CC,gBAAgB;AAAA,SAEhBC,cAAc,EAAEC,wBAAwB;AAAA,SACxCC,iBAAiB;A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S,CAAC3C,KAAK,CAAC,EAElC;QACH2D,QAAQ,EAAEA,CAAA,KAAMhD,KAAK,CAACgD,QAAQ,GAAGhB,SAAS,CAAC3C,KAAK,CAAC;QACjD4D,MAAM,EAAEA,CAAA,KACNjD,KAAK,CAACiD,MAAM,GACVjD,KAAK,CAACiD,MAAM,CAACjB,SAAS,CAAC3C,KAAK,CAAC,GAAA+C,YAAA,CAAAhE,iBAAA,QAGlB;UACP8E,OAAO,EAAElD,KAAK,CAAC,iBAAiB,CAAC;UACjCmD,MAAM,EAAEnD,KAAK,CAAC,gBAAgB;QAChC,CAAC;MAEJ;IAIX,CAAC,CAAC;IAEF,OAAO;MAAEiB;IAAe,CAAC;EAC3B;AACF,CAAC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { mergeProps as _mergeProps, resolveDirective as _resolveDirective, Fragment as _Fragment, createVNode as _createVNode } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment, mergeProps } from 'vue';
|
|
3
|
+
import { useExpand } from "./composables/expand.js";
|
|
4
|
+
import { useHeader } from "./composables/header.js";
|
|
5
|
+
import { useSelection } from "./composables/selection.js";
|
|
3
6
|
import { useRender } from "../../composables/component.js";
|
|
4
7
|
import { defineComponent, propsFactory } from "../../util/component/index.js";
|
|
5
8
|
import { YDataTableRow } from "./YDataTableRow.js";
|
|
6
|
-
import { useHeader } from "./composibles/header.js";
|
|
7
|
-
import { useSelection } from "./composibles/selection.js";
|
|
8
9
|
export const pressYDataTableBodyProps = propsFactory({
|
|
9
10
|
items: {
|
|
10
11
|
type: Array,
|
|
@@ -33,10 +34,8 @@ export const YDataTableBody = defineComponent({
|
|
|
33
34
|
emits: ['click:row', 'dblclick:row', 'contextmenu:row', 'mousedown:row'],
|
|
34
35
|
setup(props, _ref) {
|
|
35
36
|
let {
|
|
36
|
-
slots
|
|
37
|
-
expose
|
|
37
|
+
slots
|
|
38
38
|
} = _ref;
|
|
39
|
-
const rowRefs = ref([]);
|
|
40
39
|
const {
|
|
41
40
|
columns
|
|
42
41
|
} = useHeader();
|
|
@@ -44,6 +43,10 @@ export const YDataTableBody = defineComponent({
|
|
|
44
43
|
isSelected,
|
|
45
44
|
toggleSelect
|
|
46
45
|
} = useSelection();
|
|
46
|
+
const {
|
|
47
|
+
isExpanded,
|
|
48
|
+
toggleExpand
|
|
49
|
+
} = useExpand();
|
|
47
50
|
useRender(() => {
|
|
48
51
|
if (props.loading) {
|
|
49
52
|
return _createVNode("tr", null, [_createVNode("td", {
|
|
@@ -66,7 +69,9 @@ export const YDataTableBody = defineComponent({
|
|
|
66
69
|
internalItem: item,
|
|
67
70
|
columns: columns.value,
|
|
68
71
|
isSelected,
|
|
69
|
-
toggleSelect
|
|
72
|
+
toggleSelect,
|
|
73
|
+
isExpanded,
|
|
74
|
+
toggleExpand
|
|
70
75
|
};
|
|
71
76
|
function onClick(event, el) {
|
|
72
77
|
props['onClick:row']?.(event, {
|
|
@@ -117,8 +122,7 @@ export const YDataTableBody = defineComponent({
|
|
|
117
122
|
};
|
|
118
123
|
return _createVNode(_Fragment, null, [slots.item ? slots.item(slotProps) : _createVNode(YDataTableRow, _mergeProps({
|
|
119
124
|
"ref": el => {
|
|
120
|
-
|
|
121
|
-
item.rowRef = el;
|
|
125
|
+
item._bindRowRef(el);
|
|
122
126
|
}
|
|
123
127
|
}, slotProps.props, {
|
|
124
128
|
"onClick": props['onClick:row'] && onClick,
|
|
@@ -126,17 +130,9 @@ export const YDataTableBody = defineComponent({
|
|
|
126
130
|
"onDblclick": props['onDblclick:row'] && onDblclick,
|
|
127
131
|
"onMousedown": props['onMousedown:row'] && onMousedown,
|
|
128
132
|
"onKeydown": props['onKeydown:row'] && onKeydown
|
|
129
|
-
}), slots)]);
|
|
133
|
+
}), slots), isExpanded(item) && slots['expanded-row']?.(slotProps)]);
|
|
130
134
|
})]);
|
|
131
135
|
});
|
|
132
|
-
expose({
|
|
133
|
-
rowRefs
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// end
|
|
137
|
-
return {
|
|
138
|
-
rowRefs
|
|
139
|
-
};
|
|
140
136
|
}
|
|
141
137
|
});
|
|
142
138
|
//# sourceMappingURL=YDataTableBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDataTableBody.js","names":["mergeProps","ref","useRender","defineComponent","propsFactory","YDataTableRow","useHeader","useSelection","pressYDataTableBodyProps","items","type","Array","default","loading","Boolean","String","loadingText","hideNoData","noDataText","rowProps","Function","Object","rowHeight","Number","YDataTableBody","name","props","emits","setup","_ref","slots","expose","rowRefs","columns","isSelected","toggleSelect","_createVNode","value","length","_Fragment","body","map","item","index","stateProps","raw","internalItem","onClick","event","el","onDblclick","onContextmenu","onMousedown","onKeydown","slotProps","key","_mergeProps","push","rowRef"],"sources":["../../../src/components/table/YDataTableBody.tsx"],"sourcesContent":["import { type PropType, mergeProps, ref } from 'vue';\n\nimport { useRender } from '@/composables/component';\nimport { defineComponent, propsFactory } from '@/util/component';\n\nimport { YDataTableRow } from './YDataTableRow';\nimport { useHeader } from './composibles/header';\nimport { useSelection } from './composibles/selection';\nimport { DataTableItem, RowProps } from './types';\n\nexport const pressYDataTableBodyProps = propsFactory(\n {\n items: {\n type: Array as PropType<readonly DataTableItem[]>,\n default: () => [],\n },\n loading: [Boolean, String],\n loadingText: String,\n hideNoData: Boolean,\n noDataText: {\n type: String,\n default: '',\n },\n rowProps: [Function, Object] as PropType<RowProps<any>>,\n rowHeight: Number,\n 'onClick:row': Function as PropType<(e: Event, value: any) => void>,\n 'onDblclick:row': Function as PropType<(e: Event, value: any) => void>,\n 'onContextmenu:row': Function as PropType<(e: Event, value: any) => void>,\n 'onMousedown:row': Function as PropType<(e: Event, value: any) => void>,\n 'onKeydown:row': Function as PropType<(e: Event, value: any) => void>,\n },\n 'YDataTableBody',\n);\n\nexport const YDataTableBody = defineComponent({\n name: 'YDataTableBody',\n props: {\n ...pressYDataTableBodyProps(),\n },\n emits: ['click:row', 'dblclick:row', 'contextmenu:row', 'mousedown:row'],\n setup(props, { slots, expose }) {\n const rowRefs = ref<any[]>([]);\n const { columns } = useHeader();\n const { isSelected, toggleSelect } = useSelection();\n\n useRender(() => {\n if (props.loading) {\n return (\n <tr>\n <td colspan={columns.value.length} class={'y-data-table__loading'}>\n {slots.loading ? slots.loading() : <div>{props.loadingText}</div>}\n </td>\n </tr>\n );\n }\n if (!props.loading && props.items.length < 1 && !props.hideNoData) {\n return (\n <tr key=\"no-data\" class=\"y-data-table__no-data\">\n <td colspan={columns.value.length}>\n {slots['no-data']?.() ?? props.noDataText}\n </td>\n </tr>\n );\n }\n return (\n <>\n {slots.body\n ? slots.body?.(props)\n : props.items.map((item, index) => {\n const stateProps = {\n index,\n item: item.raw,\n internalItem: item,\n columns: columns.value,\n isSelected,\n toggleSelect,\n };\n\n function onClick(event: Event, el: null | Element) {\n props['onClick:row']?.(event, { ...stateProps, el });\n }\n\n function onDblclick(event: Event, el: null | Element) {\n props['onDblclick:row']?.(event, { ...stateProps, el });\n }\n\n function onContextmenu(event: Event, el: null | Element) {\n props['onContextmenu:row']?.(event, {\n ...stateProps,\n el,\n });\n }\n\n function onMousedown(event: Event, el: null | Element) {\n props['onMousedown:row']?.(event, { ...stateProps, el });\n }\n\n function onKeydown(event: Event, el: null | Element) {\n props['onKeydown:row']?.(event, { ...stateProps, el });\n }\n\n const slotProps = {\n ...stateProps,\n props: mergeProps(\n {\n key: `item__${item.key ?? item.index}`,\n item,\n index,\n },\n typeof props.rowProps === 'function'\n ? props.rowProps({\n item: stateProps.item,\n index: stateProps.index,\n internalItem: stateProps.internalItem,\n })\n : props.rowProps,\n ),\n onClick,\n onContextmenu,\n onDblclick,\n onMousedown,\n onKeydown,\n };\n\n return (\n <>\n {slots.item ? (\n slots.item(slotProps)\n ) : (\n <YDataTableRow\n ref={(el) => {\n rowRefs.value.push(el);\n item.rowRef = el;\n }}\n v-slots={slots}\n {...slotProps.props}\n onClick={props['onClick:row'] && onClick}\n onContextmenu={\n props['onContextmenu:row'] && onContextmenu\n }\n onDblclick={props['onDblclick:row'] && onDblclick}\n onMousedown={props['onMousedown:row'] && onMousedown}\n onKeydown={props['onKeydown:row'] && onKeydown}\n ></YDataTableRow>\n )}\n </>\n );\n })}\n </>\n );\n });\n\n expose({\n rowRefs,\n });\n\n // end\n return {\n rowRefs,\n };\n },\n});\n\nexport type YDataTableBody = InstanceType<typeof YDataTableBody>;\n"],"mappings":";AAAA,SAAwBA,UAAU,EAAEC,GAAG,QAAQ,KAAK;AAAC,SAE5CC,SAAS;AAAA,SACTC,eAAe,EAAEC,YAAY;AAAA,SAE7BC,aAAa;AAAA,SACbC,SAAS;AAAA,SACTC,YAAY;AAGrB,OAAO,MAAMC,wBAAwB,GAAGJ,YAAY,CAClD;EACEK,KAAK,EAAE;IACLC,IAAI,EAAEC,KAA2C;IACjDC,OAAO,EAAEA,CAAA,KAAM;EACjB,CAAC;EACDC,OAAO,EAAE,CAACC,OAAO,EAAEC,MAAM,CAAC;EAC1BC,WAAW,EAAED,MAAM;EACnBE,UAAU,EAAEH,OAAO;EACnBI,UAAU,EAAE;IACVR,IAAI,EAAEK,MAAM;IACZH,OAAO,EAAE;EACX,CAAC;EACDO,QAAQ,EAAE,CAACC,QAAQ,EAAEC,MAAM,CAA4B;EACvDC,SAAS,EAAEC,MAAM;EACjB,aAAa,EAAEH,QAAoD;EACnE,gBAAgB,EAAEA,QAAoD;EACtE,mBAAmB,EAAEA,QAAoD;EACzE,iBAAiB,EAAEA,QAAoD;EACvE,eAAe,EAAEA;AACnB,CAAC,EACD,gBACF,CAAC;AAED,OAAO,MAAMI,cAAc,GAAGrB,eAAe,CAAC;EAC5CsB,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE;IACL,GAAGlB,wBAAwB,CAAC;EAC9B,CAAC;EACDmB,KAAK,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,CAAC;EACxEC,KAAKA,CAACF,KAAK,EAAAG,IAAA,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AAjB,YAAA,CAAAG,SAAA,SAEKT,KAAK,CAACY,IAAI,GACTZ,KAAK,CAACY,IAAI,CAACY,SAAS,CAAC,GAAAlB,YAAA,CAAA/B,aAAA,EAAAmD,WAAA;UAAA,OAGbP,EAAE,IAAK;YACXjB,OAAO,CAACK,KAAK,CAACoB,IAAI,CAACR,EAAE,CAAC;YACtBP,IAAI,CAACgB,MAAM,GAAGT,EAAE;UAClB;QAAC,GAEGK,SAAS,CAAC5B,KAAK;UAAA,WACVA,KAAK,CAAC,aAAa,CAAC,IAAIqB,OAAO;UAAA,iBAEtCrB,KAAK,CAAC,mBAAmB,CAAC,IAAIyB,aAAa;UAAA,cAEjCzB,KAAK,CAAC,gBAAgB,CAAC,IAAIwB,UAAU;UAAA,eACpCxB,KAAK,CAAC,iBAAiB,CAAC,IAAI0B,WAAW;UAAA,aACzC1B,KAAK,CAAC,eAAe,CAAC,IAAI2B;QAAS,IARrCvB,KAAK,CAUjB;MAGP,CAAC,CAAC;IAGZ,CAAC,CAAC;IAEFC,MAAM,CAAC;MACLC;IACF,CAAC,CAAC;;IAEF;IACA,OAAO;MACLA;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YDataTableBody.js","names":["Fragment","mergeProps","useExpand","useHeader","useSelection","useRender","defineComponent","propsFactory","YDataTableRow","pressYDataTableBodyProps","items","type","Array","default","loading","Boolean","String","loadingText","hideNoData","noDataText","rowProps","Function","Object","rowHeight","Number","YDataTableBody","name","props","emits","setup","_ref","slots","columns","isSelected","toggleSelect","isExpanded","toggleExpand","_createVNode","value","length","_Fragment","body","map","item","index","stateProps","raw","internalItem","onClick","event","el","onDblclick","onContextmenu","onMousedown","onKeydown","slotProps","key","_mergeProps","_bindRowRef"],"sources":["../../../src/components/table/YDataTableBody.tsx"],"sourcesContent":["import { Fragment, type PropType, mergeProps, ref } from 'vue';\n\nimport { useExpand } from '@/components/table/composables/expand';\nimport { useHeader } from '@/components/table/composables/header';\nimport { useSelection } from '@/components/table/composables/selection';\nimport { useRender } from '@/composables/component';\nimport { defineComponent, propsFactory } from '@/util/component';\n\nimport { YDataTableRow } from './YDataTableRow';\nimport { DataTableItem, RowProps } from './types';\n\nexport const pressYDataTableBodyProps = propsFactory(\n {\n items: {\n type: Array as PropType<readonly DataTableItem[]>,\n default: () => [],\n },\n loading: [Boolean, String],\n loadingText: String,\n hideNoData: Boolean,\n noDataText: {\n type: String,\n default: '',\n },\n rowProps: [Function, Object] as PropType<RowProps<any>>,\n rowHeight: Number,\n 'onClick:row': Function as PropType<(e: Event, value: any) => void>,\n 'onDblclick:row': Function as PropType<(e: Event, value: any) => void>,\n 'onContextmenu:row': Function as PropType<(e: Event, value: any) => void>,\n 'onMousedown:row': Function as PropType<(e: Event, value: any) => void>,\n 'onKeydown:row': Function as PropType<(e: Event, value: any) => void>,\n },\n 'YDataTableBody',\n);\n\nexport const YDataTableBody = defineComponent({\n name: 'YDataTableBody',\n props: {\n ...pressYDataTableBodyProps(),\n },\n emits: ['click:row', 'dblclick:row', 'contextmenu:row', 'mousedown:row'],\n setup(props, { slots }) {\n const { columns } = useHeader();\n const { isSelected, toggleSelect } = useSelection();\n const { isExpanded, toggleExpand } = useExpand();\n\n useRender(() => {\n if (props.loading) {\n return (\n <tr>\n <td colspan={columns.value.length} class={'y-data-table__loading'}>\n {slots.loading ? slots.loading() : <div>{props.loadingText}</div>}\n </td>\n </tr>\n );\n }\n if (!props.loading && props.items.length < 1 && !props.hideNoData) {\n return (\n <tr key=\"no-data\" class=\"y-data-table__no-data\">\n <td colspan={columns.value.length}>\n {slots['no-data']?.() ?? props.noDataText}\n </td>\n </tr>\n );\n }\n return (\n <>\n {slots.body\n ? slots.body?.(props)\n : props.items.map((item, index) => {\n const stateProps = {\n index,\n item: item.raw,\n internalItem: item,\n columns: columns.value,\n isSelected,\n toggleSelect,\n isExpanded,\n toggleExpand,\n };\n\n function onClick(event: Event, el: null | Element) {\n props['onClick:row']?.(event, { ...stateProps, el });\n }\n\n function onDblclick(event: Event, el: null | Element) {\n props['onDblclick:row']?.(event, { ...stateProps, el });\n }\n\n function onContextmenu(event: Event, el: null | Element) {\n props['onContextmenu:row']?.(event, {\n ...stateProps,\n el,\n });\n }\n\n function onMousedown(event: Event, el: null | Element) {\n props['onMousedown:row']?.(event, { ...stateProps, el });\n }\n\n function onKeydown(event: Event, el: null | Element) {\n props['onKeydown:row']?.(event, { ...stateProps, el });\n }\n\n const slotProps = {\n ...stateProps,\n props: mergeProps(\n {\n key: `item__${item.key ?? item.index}`,\n item,\n index,\n },\n typeof props.rowProps === 'function'\n ? props.rowProps({\n item: stateProps.item,\n index: stateProps.index,\n internalItem: stateProps.internalItem,\n })\n : props.rowProps,\n ),\n onClick,\n onContextmenu,\n onDblclick,\n onMousedown,\n onKeydown,\n };\n\n return (\n <Fragment>\n {slots.item ? (\n slots.item(slotProps)\n ) : (\n <YDataTableRow\n ref={(el) => {\n item._bindRowRef(el);\n }}\n v-slots={slots}\n {...slotProps.props}\n onClick={props['onClick:row'] && onClick}\n onContextmenu={\n props['onContextmenu:row'] && onContextmenu\n }\n onDblclick={props['onDblclick:row'] && onDblclick}\n onMousedown={props['onMousedown:row'] && onMousedown}\n onKeydown={props['onKeydown:row'] && onKeydown}\n ></YDataTableRow>\n )}\n {isExpanded(item) && slots['expanded-row']?.(slotProps)}\n </Fragment>\n );\n })}\n </>\n );\n });\n },\n});\n\nexport type YDataTableBody = InstanceType<typeof YDataTableBody>;\n"],"mappings":";AAAA,SAASA,QAAQ,EAAiBC,UAAU,QAAa,KAAK;AAAC,SAEtDC,SAAS;AAAA,SACTC,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,SAAS;AAAA,SACTC,eAAe,EAAEC,YAAY;AAAA,SAE7BC,aAAa;AAGtB,OAAO,MAAMC,wBAAwB,GAAGF,YAAY,CAClD;EACEG,KAAK,EAAE;IACLC,IAAI,EAAEC,KAA2C;IACjDC,OAAO,EAAEA,CAAA,KAAM;EACjB,CAAC;EAC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,UAAU,CAACQ,IAAI,CAAC,IAAIZ,KAAK,CAAC,cAAc,CAAC,GAAGwB,SAAS,CAAC;MAG7D,CAAC,CAAC;IAGZ,CAAC,CAAC;EACJ;AACF,CAAC,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { YButton } from "../button/index.js";
|
|
|
6
6
|
import { YFieldInput } from "../field-input/index.js";
|
|
7
7
|
import { YIconExpand, YIconPageControl } from "../icons/index.js";
|
|
8
8
|
import { YPagination } from "../pagination/index.js";
|
|
9
|
-
import { pressDataTablePaginationProps } from "./
|
|
9
|
+
import { pressDataTablePaginationProps } from "./composables/pagination.js";
|
|
10
10
|
import "./YDataTableControl.scss";
|
|
11
11
|
export const pressYDataTableControlPropsOptions = propsFactory({
|
|
12
12
|
pageLength: Number,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDataTableControl.js","names":["useRender","propsFactory","defineComponent","YButton","YFieldInput","YIconExpand","YIconPageControl","YPagination","pressDataTablePaginationProps","pressYDataTableControlPropsOptions","pageLength","Number","setPageSize","Function","setPage","YDataTableControl","name","components","props","setup","_ref","slots","_createVNode","prepend","default","_Fragment","page","append"],"sources":["../../../src/components/table/YDataTableControl.tsx"],"sourcesContent":["import { type PropType } from 'vue';\n\nimport { useRender } from '@/composables/component';\nimport { propsFactory } from '@/util';\nimport { defineComponent } from '@/util/component';\n\nimport { YButton } from '../button';\nimport { YFieldInput } from '../field-input';\nimport { YIconExpand, YIconPageControl } from '../icons';\nimport { YPagination } from '../pagination';\nimport { pressDataTablePaginationProps } from '
|
|
1
|
+
{"version":3,"file":"YDataTableControl.js","names":["useRender","propsFactory","defineComponent","YButton","YFieldInput","YIconExpand","YIconPageControl","YPagination","pressDataTablePaginationProps","pressYDataTableControlPropsOptions","pageLength","Number","setPageSize","Function","setPage","YDataTableControl","name","components","props","setup","_ref","slots","_createVNode","prepend","default","_Fragment","page","append"],"sources":["../../../src/components/table/YDataTableControl.tsx"],"sourcesContent":["import { type PropType } from 'vue';\n\nimport { useRender } from '@/composables/component';\nimport { propsFactory } from '@/util';\nimport { defineComponent } from '@/util/component';\n\nimport { YButton } from '../button';\nimport { YFieldInput } from '../field-input';\nimport { YIconExpand, YIconPageControl } from '../icons';\nimport { YPagination } from '../pagination';\nimport { pressDataTablePaginationProps } from '@/components/table/composables/pagination';\n\nimport './YDataTableControl.scss';\n\nexport const pressYDataTableControlPropsOptions = propsFactory(\n {\n pageLength: Number as PropType<number>,\n setPageSize: Function as PropType<(pageSize: number) => void>,\n setPage: Function as PropType<(page: number) => void>,\n ...pressDataTablePaginationProps(),\n },\n 'YDataTableControl',\n);\n\nexport const YDataTableControl = defineComponent({\n name: 'YDataTableControl',\n components: {\n YButton,\n YIconExpand,\n YFieldInput,\n YIconPageControl,\n },\n props: pressYDataTableControlPropsOptions(),\n setup(props, { slots }) {\n useRender(() => {\n return (\n <footer class={['y-data-table-control']}>\n {slots.prepend?.(props)}\n {slots.default ? (\n slots.default()\n ) : (\n <>\n <div class=\"y-data-table-control__start\"></div>\n <div class=\"y-data-table-control__end\">\n <YPagination\n model-value={props.page}\n onUpdate:modelValue={props.setPage}\n length={props.pageLength}\n totalVisible={0}\n ></YPagination>\n </div>\n </>\n )}\n {slots.append?.(props)}\n </footer>\n );\n });\n },\n});\n\nexport type YDataTableControl = InstanceType<typeof YDataTableControl>;\n"],"mappings":";SAESA,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,eAAe;AAAA,SAEfC,OAAO;AAAA,SACPC,WAAW;AAAA,SACXC,WAAW,EAAEC,gBAAgB;AAAA,SAC7BC,WAAW;AAAA,SACXC,6BAA6B;AAEtC;AAEA,OAAO,MAAMC,kCAAkC,GAAGR,YAAY,CAC5D;EACES,UAAU,EAAEC,MAA0B;EACtCC,WAAW,EAAEC,QAAgD;EAC7DC,OAAO,EAAED,QAA4C;EACrD,GAAGL,6BAA6B,CAAC;AACnC,CAAC,EACD,mBACF,CAAC;AAED,OAAO,MAAMO,iBAAiB,GAAGb,eAAe,CAAC;EAC/Cc,IAAI,EAAE,mBAAmB;EACzBC,UAAU,EAAE;IACVd,OAAO;IACPE,WAAW;IACXD,WAAW;IACXE;EACF,CAAC;EACDY,KAAK,EAAET,kCAAkC,CAAC,CAAC;EAC3CU,KAAKA,CAACD,KAAK,EAAAE,IAAA,EAAa;IAAA,IAAX;MAAEC;IAAM,CAAC,GAAAD,IAAA;IACpBpB,SAAS,CAAC,MAAM;MACd,OAAAsB,YAAA;QAAA,SACiB,CAAC,sBAAsB;MAAC,IACpCD,KAAK,CAACE,OAAO,GAAGL,KAAK,CAAC,EACtBG,KAAK,CAACG,OAAO,GACZH,KAAK,CAACG,OAAO,CAAC,CAAC,GAAAF,YAAA,CAAAG,SAAA,SAAAH,YAAA;QAAA;MAAA,UAAAA,YAAA;QAAA;MAAA,IAAAA,YAAA,CAAAf,WAAA;QAAA,eAMIW,KAAK,CAACQ,IAAI;QAAA,uBACFR,KAAK,CAACJ,OAAO;QAAA,UAC1BI,KAAK,CAACR,UAAU;QAAA,gBACV;MAAC,YAItB,EACAW,KAAK,CAACM,MAAM,GAAGT,KAAK,CAAC;IAG5B,CAAC,CAAC;EACJ;AACF,CAAC,CAAC"}
|
|
@@ -7,9 +7,9 @@ import { YButton } from "../button/YButton.js";
|
|
|
7
7
|
import { YIconCheckbox } from "../icons/YIconCheckbox.js";
|
|
8
8
|
import { YIconSort } from "../icons/YIconSort.js";
|
|
9
9
|
import { YDataTableCell } from "./YDataTableCell.js";
|
|
10
|
-
import { useHeader } from "./
|
|
11
|
-
import { useSelection } from "./
|
|
12
|
-
import { useSorting } from "./
|
|
10
|
+
import { useHeader } from "./composables/header.js";
|
|
11
|
+
import { useSelection } from "./composables/selection.js";
|
|
12
|
+
import { useSorting } from "./composables/sorting.js";
|
|
13
13
|
export const pressYDataTableHeadProps = propsFactory({
|
|
14
14
|
multiSort: Boolean,
|
|
15
15
|
sortAscIcon: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDataTableHead.js","names":["useRender","wrapInArray","defineComponent","propsFactory","toStyleSizeValue","YButton","YIconCheckbox","YIconSort","YDataTableCell","useHeader","useSelection","useSorting","pressYDataTableHeadProps","multiSort","Boolean","sortAscIcon","type","String","default","sortDescIcon","dualSortIcon","sticky","YDataTableHead","name","components","props","setup","_ref","slots","toggleSort","sortBy","isSorted","someSelected","allSelected","selectAll","showSelectAll","selectables","columns","headers","getFixedStyles","column","y","fixed","undefined","fixedOffset","left","right","rightOffset","position","zIndex","top","onClick","e","getSortDirection","found","value","find","by","key","order","YDataTableTh","_ref2","x","_createVNode","_mergeProps","align","lastFixed","sortable","headerClasses","width","minWidth","maxWidth","rowspan","colspan","headerSlotName","headerSlotProps","length","stopPropagation","text","_Fragment","head","map","row"],"sources":["../../../src/components/table/YDataTableHead.tsx"],"sourcesContent":["import { type CSSProperties } from 'vue';\r\n\r\nimport { useRender } from '@/composables/component';\r\nimport { wrapInArray } from '@/util';\r\nimport { defineComponent, propsFactory } from '@/util/component';\r\nimport { toStyleSizeValue } from '@/util/ui';\r\n\r\nimport { YButton } from '../button/YButton';\r\nimport { YIconCheckbox } from '../icons/YIconCheckbox';\r\nimport { YIconSort } from '../icons/YIconSort';\r\nimport { YDataTableCell } from './YDataTableCell';\r\nimport { useHeader } from './composibles/header';\r\nimport { useSelection } from './composibles/selection';\r\nimport { useSorting } from './composibles/sorting';\r\nimport { type FixedPropType, InternalDataTableHeader } from './types';\r\n\r\nexport const pressYDataTableHeadProps = propsFactory(\r\n {\r\n multiSort: Boolean,\r\n sortAscIcon: {\r\n type: String,\r\n default: '@sortAsc',\r\n },\r\n sortDescIcon: {\r\n type: String,\r\n default: '@sortDesc',\r\n },\r\n dualSortIcon: Boolean,\r\n sticky: Boolean,\r\n },\r\n 'YDataTableHead',\r\n);\r\n\r\nexport const YDataTableHead = defineComponent({\r\n name: 'YDataTableHead',\r\n components: {\r\n YDataTableCell,\r\n },\r\n props: {\r\n ...pressYDataTableHeadProps(),\r\n },\r\n setup(props, { slots }) {\r\n const { toggleSort, sortBy, isSorted } = useSorting();\r\n const { someSelected, allSelected, selectAll, showSelectAll, selectables } =\r\n useSelection();\r\n const { columns, headers } = useHeader();\r\n\r\n const getFixedStyles = (\r\n column: InternalDataTableHeader,\r\n y: number,\r\n ): CSSProperties | undefined => {\r\n if (!props.sticky && !column.fixed) return undefined;\r\n let fixedOffset: any = {};\r\n if (column.fixed === true || column.fixed === 'left') {\r\n fixedOffset.left = toStyleSizeValue(column.fixedOffset);\r\n }\r\n if (column.fixed === 'right') {\r\n fixedOffset.right = toStyleSizeValue(column.rightOffset);\r\n }\r\n\r\n return {\r\n position: 'sticky',\r\n zIndex: column.fixed ? 4 : props.sticky ? 3 : undefined,\r\n top: props.sticky\r\n ? `calc(var(--v-table-header-height) * ${y})`\r\n : undefined,\r\n ...fixedOffset,\r\n };\r\n };\r\n\r\n function onClick(e: Event) {\r\n //\r\n }\r\n\r\n function getSortDirection(column: InternalDataTableHeader) {\r\n const found = sortBy.value.find((by) => by.key === column.key);\r\n if (!found) {\r\n return undefined;\r\n }\r\n if (found.order === 'asc') {\r\n return 'asc';\r\n }\r\n if (found.order === 'desc') {\r\n return 'desc';\r\n }\r\n }\r\n\r\n const YDataTableTh = ({\r\n column,\r\n x,\r\n y,\r\n }: {\r\n column: InternalDataTableHeader;\r\n x: number;\r\n y: number;\r\n }) => {\r\n return (\r\n <YDataTableCell\r\n type=\"head\"\r\n align={column.align}\r\n fixed={\r\n column.fixed\r\n ? (((column.fixed === 'right' ? 'trail' : 'lead') +\r\n (column.lastFixed ? '-last' : '')) as FixedPropType)\r\n : undefined\r\n }\r\n class={[\r\n 'y-data-table-header',\r\n {\r\n 'y-data-table-header--sortable': column.sortable,\r\n 'y-data-table-header--sorted': isSorted(column),\r\n 'y-data-table-header--select': column.key === 'data-table-select',\r\n },\r\n ...wrapInArray(column.headerClasses ?? []),\r\n ]}\r\n style={{\r\n width: toStyleSizeValue(column.width),\r\n minWidth: toStyleSizeValue(column.width),\r\n maxWidth: toStyleSizeValue(column.maxWidth),\r\n ...getFixedStyles(column, y),\r\n }}\r\n {...{ rowspan: column.rowspan, colspan: column.colspan }}\r\n onClick={onClick}\r\n >\r\n {{\r\n default: () => {\r\n const headerSlotName = `header.${column.key}` as const;\r\n const headerSlotProps = {\r\n column,\r\n selectAll,\r\n isSorted,\r\n toggleSort,\r\n sortBy: sortBy.value,\r\n someSelected: someSelected.value,\r\n allSelected: allSelected.value,\r\n selectables: selectables.value,\r\n getSortDirection,\r\n };\r\n\r\n if (slots[headerSlotName]) {\r\n return slots[headerSlotName]?.(headerSlotProps);\r\n }\r\n\r\n if (column.key === 'data-table-select') {\r\n return (\r\n slots['header.data-table-select']?.(headerSlotProps) ??\r\n (showSelectAll && (\r\n <YButton\r\n variation={'text,small'}\r\n disabled={selectables.value.length < 1}\r\n onClick={(e: MouseEvent) => {\r\n e.stopPropagation();\r\n selectAll(!allSelected.value);\r\n }}\r\n >\r\n <YIconCheckbox\r\n checked={allSelected.value}\r\n indeterminate={!allSelected.value && someSelected.value}\r\n disabled={selectables.value.length < 1}\r\n ></YIconCheckbox>\r\n </YButton>\r\n ))\r\n );\r\n }\r\n\r\n return (\r\n <div class=\"y-data-table-header__content\">\r\n <span class=\"y-data-table-header__text\">\r\n {slots?.[`header-text.${column.key}`]?.(headerSlotProps) ??\r\n column.text}\r\n </span>\r\n <span\r\n class={[\r\n 'y-data-table-header__sorting-icon',\r\n {\r\n 'y-data-table-header__sorting-icon--disabled':\r\n !column.sortable,\r\n },\r\n ]}\r\n onClick={\r\n column.sortable\r\n ? (e) => {\r\n e.stopPropagation();\r\n toggleSort(column);\r\n }\r\n : undefined\r\n }\r\n >\r\n <YIconSort\r\n disabled={!column.sortable}\r\n direction={getSortDirection(column)}\r\n ></YIconSort>\r\n </span>\r\n </div>\r\n );\r\n },\r\n }}\r\n </YDataTableCell>\r\n );\r\n };\r\n\r\n useRender(() => {\r\n return (\r\n <>\r\n {slots.head\r\n ? slots.head?.(props)\r\n : headers.value.map((row, y) => (\r\n <tr>\r\n {row.map((column, x) => (\r\n <YDataTableTh column={column} x={x} y={y} />\r\n ))}\r\n </tr>\r\n ))}\r\n </>\r\n );\r\n });\r\n },\r\n});\r\n\r\nexport type YDataTableHead = InstanceType<typeof YDataTableHead>;\r\n"],"mappings":";SAESA,SAAS;AAAA,SACTC,WAAW;AAAA,SACXC,eAAe,EAAEC,YAAY;AAAA,SAC7BC,gBAAgB;AAAA,SAEhBC,OAAO;AAAA,SACPC,aAAa;AAAA,SACbC,SAAS;AAAA,SACTC,cAAc;AAAA,SACdC,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,UAAU;AAGnB,OAAO,MAAMC,wBAAwB,GAAGT,YAAY,CAClD;EACEU,SAAS,EAAEC,OAAO;EAClBC,WAAW,EAAE;IACXC,IAAI,EAAEC,MAAM;IACZC,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAE;IACZH,IAAI,EAAEC,MAAM;IACZC,OAAO,EAAE;EACX,CAAC;EACDE,YAAY,EAAEN,OAAO;EACrBO,MAAM,EAAEP;AACV,CAAC,EACD,gBACF,CAAC;AAED,OAAO,MAAMQ,cAAc,GAAGpB,eAAe,CAAC;EAC5CqB,IAAI,EAAE,gBAAgB;EACtBC,UAAU,EAAE;IACVhB;EACF,CAAC;EACDiB,KAAK,EAAE;IACL,GAAGb,wBAAwB,CAAC;EAC9B,CAAC;EACDc,KAAKA,CAACD,KAAK,EAAAE,IAAA,EAAa;IAAA,IAAX;MAAEC;IAAM,CAAC,GAAAD,IAAA;IACpB,MAAM;MAAEE,UAAU;MAAEC,MAAM;MAAEC;IAAS,CAAC,GAAGpB,UAAU,CAAC,CAAC;IACrD,MAAM;MAAEqB,YAAY;MAAEC,WAAW;MAAEC,SAAS;MAAEC,aAAa;MAAEC;IAAY,CAAC,GACxE1B,YAAY,CAAC,CAAC;IAChB,MAAM;MAAE2B,OAAO;MAAEC;IAAQ,CAAC,GAAG7B,SAAS,CAAC,CAAC;IA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ACiC,MAAM,CAAC2B,QAAQ;YAAA,aACfd,gBAAgB,CAACb,MAAM;UAAC;QAK7C;MAAC;IAIT,CAAC;IAEDxC,SAAS,CAAC,MAAM;MACd,OAAA+D,YAAA,CAAAgB,SAAA,SAEKnD,KAAK,CAACoD,IAAI,GACPpD,KAAK,CAACoD,IAAI,GAAGvD,KAAK,CAAC,GACnBa,OAAO,CAACiB,KAAK,CAAC0B,GAAG,CAAC,CAACC,GAAG,EAAEzC,CAAC,KAAAsB,YAAA,cAEpBmB,GAAG,CAACD,GAAG,CAAC,CAACzC,MAAM,EAAEsB,CAAC,KAAAC,YAAA,CAAAH,YAAA;QAAA,UACKpB,MAAM;QAAA,KAAKsB,CAAC;QAAA,KAAKrB;MAAC,QACzC,CAAC,EAEL,CAAC;IAGZ,CAAC,CAAC;EACJ;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YDataTableHead.js","names":["useRender","wrapInArray","defineComponent","propsFactory","toStyleSizeValue","YButton","YIconCheckbox","YIconSort","YDataTableCell","useHeader","useSelection","useSorting","pressYDataTableHeadProps","multiSort","Boolean","sortAscIcon","type","String","default","sortDescIcon","dualSortIcon","sticky","YDataTableHead","name","components","props","setup","_ref","slots","toggleSort","sortBy","isSorted","someSelected","allSelected","selectAll","showSelectAll","selectables","columns","headers","getFixedStyles","column","y","fixed","undefined","fixedOffset","left","right","rightOffset","position","zIndex","top","onClick","e","getSortDirection","found","value","find","by","key","order","YDataTableTh","_ref2","x","_createVNode","_mergeProps","align","lastFixed","sortable","headerClasses","width","minWidth","maxWidth","rowspan","colspan","headerSlotName","headerSlotProps","length","stopPropagation","text","_Fragment","head","map","row"],"sources":["../../../src/components/table/YDataTableHead.tsx"],"sourcesContent":["import { type CSSProperties } from 'vue';\r\n\r\nimport { useRender } from '@/composables/component';\r\nimport { wrapInArray } from '@/util';\r\nimport { defineComponent, propsFactory } from '@/util/component';\r\nimport { toStyleSizeValue } from '@/util/ui';\r\n\r\nimport { YButton } from '../button/YButton';\r\nimport { YIconCheckbox } from '../icons/YIconCheckbox';\r\nimport { YIconSort } from '../icons/YIconSort';\r\nimport { YDataTableCell } from './YDataTableCell';\r\nimport { useHeader } from '@/components/table/composables/header';\r\nimport { useSelection } from '@/components/table/composables/selection';\r\nimport { useSorting } from '@/components/table/composables/sorting';\r\nimport { type FixedPropType, InternalDataTableHeader } from './types';\r\n\r\nexport const pressYDataTableHeadProps = propsFactory(\r\n {\r\n multiSort: Boolean,\r\n sortAscIcon: {\r\n type: String,\r\n default: '@sortAsc',\r\n },\r\n sortDescIcon: {\r\n type: String,\r\n default: '@sortDesc',\r\n },\r\n dualSortIcon: Boolean,\r\n sticky: Boolean,\r\n },\r\n 'YDataTableHead',\r\n);\r\n\r\nexport const YDataTableHead = defineComponent({\r\n name: 'YDataTableHead',\r\n components: {\r\n YDataTableCell,\r\n },\r\n props: {\r\n ...pressYDataTableHeadProps(),\r\n },\r\n setup(props, { slots }) {\r\n const { toggleSort, sortBy, isSorted } = useSorting();\r\n const { someSelected, allSelected, selectAll, showSelectAll, selectables } =\r\n useSelection();\r\n const { columns, headers } = useHeader();\r\n\r\n const getFixedStyles = (\r\n column: InternalDataTableHeader,\r\n y: number,\r\n ): CSSProperties | undefined => {\r\n if (!props.sticky && !column.fixed) return undefined;\r\n let fixedOffset: any = {};\r\n if (column.fixed === true || column.fixed === 'left') {\r\n fixedOffset.left = toStyleSizeValue(column.fixedOffset);\r\n }\r\n if (column.fixed === 'right') {\r\n fixedOffset.right = toStyleSizeValue(column.rightOffset);\r\n }\r\n\r\n return {\r\n position: 'sticky',\r\n zIndex: column.fixed ? 4 : props.sticky ? 3 : undefined,\r\n top: props.sticky\r\n ? `calc(var(--v-table-header-height) * ${y})`\r\n : undefined,\r\n ...fixedOffset,\r\n };\r\n };\r\n\r\n function onClick(e: Event) {\r\n //\r\n }\r\n\r\n function getSortDirection(column: InternalDataTableHeader) {\r\n const found = sortBy.value.find((by) => by.key === column.key);\r\n if (!found) {\r\n return undefined;\r\n }\r\n if (found.order === 'asc') {\r\n return 'asc';\r\n }\r\n if (found.order === 'desc') {\r\n return 'desc';\r\n }\r\n }\r\n\r\n const YDataTableTh = ({\r\n column,\r\n x,\r\n y,\r\n }: {\r\n column: InternalDataTableHeader;\r\n x: number;\r\n y: number;\r\n }) => {\r\n return (\r\n <YDataTableCell\r\n type=\"head\"\r\n align={column.align}\r\n fixed={\r\n column.fixed\r\n ? (((column.fixed === 'right' ? 'trail' : 'lead') +\r\n (column.lastFixed ? '-last' : '')) as FixedPropType)\r\n : undefined\r\n }\r\n class={[\r\n 'y-data-table-header',\r\n {\r\n 'y-data-table-header--sortable': column.sortable,\r\n 'y-data-table-header--sorted': isSorted(column),\r\n 'y-data-table-header--select': column.key === 'data-table-select',\r\n },\r\n ...wrapInArray(column.headerClasses ?? []),\r\n ]}\r\n style={{\r\n width: toStyleSizeValue(column.width),\r\n minWidth: toStyleSizeValue(column.width),\r\n maxWidth: toStyleSizeValue(column.maxWidth),\r\n ...getFixedStyles(column, y),\r\n }}\r\n {...{ rowspan: column.rowspan, colspan: column.colspan }}\r\n onClick={onClick}\r\n >\r\n {{\r\n default: () => {\r\n const headerSlotName = `header.${column.key}` as const;\r\n const headerSlotProps = {\r\n column,\r\n selectAll,\r\n isSorted,\r\n toggleSort,\r\n sortBy: sortBy.value,\r\n someSelected: someSelected.value,\r\n allSelected: allSelected.value,\r\n selectables: selectables.value,\r\n getSortDirection,\r\n };\r\n\r\n if (slots[headerSlotName]) {\r\n return slots[headerSlotName]?.(headerSlotProps);\r\n }\r\n\r\n if (column.key === 'data-table-select') {\r\n return (\r\n slots['header.data-table-select']?.(headerSlotProps) ??\r\n (showSelectAll && (\r\n <YButton\r\n variation={'text,small'}\r\n disabled={selectables.value.length < 1}\r\n onClick={(e: MouseEvent) => {\r\n e.stopPropagation();\r\n selectAll(!allSelected.value);\r\n }}\r\n >\r\n <YIconCheckbox\r\n checked={allSelected.value}\r\n indeterminate={!allSelected.value && someSelected.value}\r\n disabled={selectables.value.length < 1}\r\n ></YIconCheckbox>\r\n </YButton>\r\n ))\r\n );\r\n }\r\n\r\n return (\r\n <div class=\"y-data-table-header__content\">\r\n <span class=\"y-data-table-header__text\">\r\n {slots?.[`header-text.${column.key}`]?.(headerSlotProps) ??\r\n column.text}\r\n </span>\r\n <span\r\n class={[\r\n 'y-data-table-header__sorting-icon',\r\n {\r\n 'y-data-table-header__sorting-icon--disabled':\r\n !column.sortable,\r\n },\r\n ]}\r\n onClick={\r\n column.sortable\r\n ? (e) => {\r\n e.stopPropagation();\r\n toggleSort(column);\r\n }\r\n : undefined\r\n }\r\n >\r\n <YIconSort\r\n disabled={!column.sortable}\r\n direction={getSortDirection(column)}\r\n ></YIconSort>\r\n </span>\r\n </div>\r\n );\r\n },\r\n }}\r\n </YDataTableCell>\r\n );\r\n };\r\n\r\n useRender(() => {\r\n return (\r\n <>\r\n {slots.head\r\n ? slots.head?.(props)\r\n : headers.value.map((row, y) => (\r\n <tr>\r\n {row.map((column, x) => (\r\n <YDataTableTh column={column} x={x} y={y} />\r\n ))}\r\n </tr>\r\n ))}\r\n </>\r\n );\r\n });\r\n },\r\n});\r\n\r\nexport type YDataTableHead = InstanceType<typeof YDataTableHead>;\r\n"],"mappings":";SAESA,SAAS;AAAA,SACTC,WAAW;AAAA,SACXC,eAAe,EAAEC,YAAY;AAAA,SAC7BC,gBAAgB;AAAA,SAEhBC,OAAO;AAAA,SACPC,aAAa;AAAA,SACbC,SAAS;AAAA,SACTC,cAAc;AAAA,SACdC,SAAS;AAAA,SACTC,YAAY;AAAA,SACZC,UAAU;AAGnB,OAAO,MAAMC,wBAAwB,GAAGT,YAAY,CAClD;EACEU,SAAS,EAAEC,OAAO;EAClBC,WAAW,EAAE;IACXC,IAAI,EAAEC,MAAM;IACZC,OAAO,EAAE;EACX,CAAC;EACDC,YAAY,EAAE;IACZH,IAAI,EAAEC,MAAM;IACZC,OAAO,EAAE;EACX,CAAC;EACDE,YAAY,EAAEN,OAAO;EACr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AAK,IAAIvB,YAAY,CAACuB,KAAK;gBAAA,YAC7CnB,WAAW,CAACmB,KAAK,CAACqB,MAAM,GAAG;cAAC;YAAA,EAG3C,CAAC;UAEN;UAEA,OAAAb,YAAA;YAAA;UAAA,IAAAA,YAAA;YAAA;UAAA,IAGOnC,KAAK,GAAI,eAAcY,MAAM,CAACkB,GAAI,EAAC,CAAC,GAAGiB,eAAe,CAAC,IACtDnC,MAAM,CAACsC,IAAI,IAAAf,YAAA;YAAA,SAGN,CACL,mCAAmC,EACnC;cACE,6CAA6C,EAC3C,CAACvB,MAAM,CAAC2B;YACZ,CAAC,CACF;YAAA,WAEC3B,MAAM,CAAC2B,QAAQ,GACVf,CAAC,IAAK;cACLA,CAAC,CAACyB,eAAe,CAAC,CAAC;cACnBhD,UAAU,CAACW,MAAM,CAAC;YACpB,CAAC,GACDG;UAAS,IAAAoB,YAAA,CAAAxD,SAAA;YAAA,YAIH,CAACiC,MAAM,CAAC2B,QAAQ;YAAA,aACfd,gBAAgB,CAACb,MAAM;UAAC;QAK7C;MAAC;IAIT,CAAC;IAEDxC,SAAS,CAAC,MAAM;MACd,OAAA+D,YAAA,CAAAgB,SAAA,SAEKnD,KAAK,CAACoD,IAAI,GACPpD,KAAK,CAACoD,IAAI,GAAGvD,KAAK,CAAC,GACnBa,OAAO,CAACiB,KAAK,CAAC0B,GAAG,CAAC,CAACC,GAAG,EAAEzC,CAAC,KAAAsB,YAAA,cAEpBmB,GAAG,CAACD,GAAG,CAAC,CAACzC,MAAM,EAAEsB,CAAC,KAAAC,YAAA,CAAAH,YAAA;QAAA,UACKpB,MAAM;QAAA,KAAKsB,CAAC;QAAA,KAAKrB;MAAC,QACzC,CAAC,EAEL,CAAC;IAGZ,CAAC,CAAC;EACJ;AACF,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createVNode as _createVNode, Fragment as _Fragment } from "vue";
|
|
2
2
|
import { inject } from 'vue';
|
|
3
|
+
import { YDataTableInjectionKey, YTableInjectionKey } from "./composables/provides.js";
|
|
3
4
|
import { useRender } from "../../composables/component.js";
|
|
4
5
|
import { defineComponent } from "../../util/component/index.js";
|
|
5
6
|
export const YDataTableLayer = defineComponent({
|
|
@@ -11,15 +12,21 @@ export const YDataTableLayer = defineComponent({
|
|
|
11
12
|
let {
|
|
12
13
|
slots
|
|
13
14
|
} = _ref;
|
|
14
|
-
const YTableWire = inject(
|
|
15
|
+
const YTableWire = inject(YTableInjectionKey);
|
|
16
|
+
const YDataTableWire = inject(YDataTableInjectionKey);
|
|
15
17
|
useRender(() => {
|
|
18
|
+
const scopedSlotProps = {
|
|
19
|
+
...props.slotProps,
|
|
20
|
+
YTable: YTableWire,
|
|
21
|
+
YDataTable: YDataTableWire
|
|
22
|
+
};
|
|
16
23
|
return _createVNode("div", {
|
|
17
24
|
"class": ['y-data-table-layer']
|
|
18
|
-
}, [slots.layer ? slots.layer?.(
|
|
25
|
+
}, [slots.layer ? slots.layer?.(scopedSlotProps) : _createVNode(_Fragment, null, [_createVNode("div", {
|
|
19
26
|
"class": ['y-data-table-layer__head']
|
|
20
|
-
}, [slots['layer-head']?.(
|
|
27
|
+
}, [slots['layer-head']?.(scopedSlotProps)]), _createVNode("div", {
|
|
21
28
|
"class": ['y-data-table-layer__body']
|
|
22
|
-
}, [slots['layer-body']?.(
|
|
29
|
+
}, [slots['layer-body']?.(scopedSlotProps)])])]);
|
|
23
30
|
});
|
|
24
31
|
return {
|
|
25
32
|
YTableWire
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YDataTableLayer.js","names":["inject","useRender","defineComponent","YDataTableLayer","name","props","slotProps","Object","setup","_ref","slots","YTableWire","_createVNode","layer","_Fragment"],"sources":["../../../src/components/table/YDataTableLayer.tsx"],"sourcesContent":["import { type PropType, type Ref, inject } from 'vue';\
|
|
1
|
+
{"version":3,"file":"YDataTableLayer.js","names":["inject","YDataTableInjectionKey","YTableInjectionKey","useRender","defineComponent","YDataTableLayer","name","props","slotProps","Object","setup","_ref","slots","YTableWire","YDataTableWire","scopedSlotProps","YTable","YDataTable","_createVNode","layer","_Fragment"],"sources":["../../../src/components/table/YDataTableLayer.tsx"],"sourcesContent":["import { type PropType, type Ref, inject } from 'vue';\n\nimport {\n YDataTableInjectionKey,\n YTableInjectionKey,\n} from '@/components/table/composables/provides';\nimport { useRender } from '@/composables/component';\nimport { defineComponent } from '@/util/component';\n\nexport const YDataTableLayer = defineComponent({\n name: 'YDataTableLayer',\n props: {\n slotProps: Object as PropType<any>,\n },\n setup(props, { slots }) {\n const YTableWire = inject(YTableInjectionKey);\n const YDataTableWire = inject(YDataTableInjectionKey);\n\n useRender(() => {\n const scopedSlotProps = {\n ...props.slotProps,\n YTable: YTableWire,\n YDataTable: YDataTableWire,\n };\n\n return (\n <div class={['y-data-table-layer']}>\n {slots.layer ? (\n slots.layer?.(scopedSlotProps)\n ) : (\n <>\n <div class={['y-data-table-layer__head']}>\n {slots['layer-head']?.(scopedSlotProps)}\n </div>\n <div class={['y-data-table-layer__body']}>\n {slots['layer-body']?.(scopedSlotProps)}\n </div>\n </>\n )}\n </div>\n );\n });\n\n return {\n YTableWire,\n };\n },\n});\n\nexport type YDataTableLayer = InstanceType<typeof YDataTableLayer>;\n"],"mappings":";AAAA,SAAkCA,MAAM,QAAQ,KAAK;AAAC,SAGpDC,sBAAsB,EACtBC,kBAAkB;AAAA,SAEXC,SAAS;AAAA,SACTC,eAAe;AAExB,OAAO,MAAMC,eAAe,GAAGD,eAAe,CAAC;EAC7CE,IAAI,EAAE,iBAAiB;EACvBC,KAAK,EAAE;IACLC,SAAS,EAAEC;EACb,CAAC;EACDC,KAAKA,CAACH,KAAK,EAAAI,IAAA,EAAa;IAAA,IAAX;MAAEC;IAAM,CAAC,GAAAD,IAAA;IACpB,MAAME,UAAU,GAAGb,MAAM,CAACE,kBAAkB,CAAC;IAC7C,MAAMY,cAAc,GAAGd,MAAM,CAACC,sBAAsB,CAAC;IAErDE,SAAS,CAAC,MAAM;MACd,MAAMY,eAAe,GAAG;QACtB,GAAGR,KAAK,CAACC,SAAS;QAClBQ,MAAM,EAAEH,UAAU;QAClBI,UAAU,EAAEH;MACd,CAAC;MAED,OAAAI,YAAA;QAAA,SACc,CAAC,oBAAoB;MAAC,IAC/BN,KAAK,CAACO,KAAK,GACVP,KAAK,CAACO,KAAK,GAAGJ,eAAe,CAAC,GAAAG,YAAA,CAAAE,SAAA,SAAAF,YAAA;QAAA,SAGhB,CAAC,0BAA0B;MAAC,IACrCN,KAAK,CAAC,YAAY,CAAC,GAAGG,eAAe,CAAC,IAAAG,YAAA;QAAA,SAE7B,CAAC,0BAA0B;MAAC,IACrCN,KAAK,CAAC,YAAY,CAAC,GAAGG,eAAe,CAAC,IAG5C;IAGP,CAAC,CAAC;IAEF,OAAO;MACLF;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { withDirectives as _withDirectives, createVNode as _createVNode, vShow as _vShow } from "vue";
|
|
2
|
+
import { computed, onBeforeUnmount, ref, shallowRef, useTemplateRef, watch } from 'vue';
|
|
3
|
+
import { useRender } from "../../composables/component.js";
|
|
4
|
+
import { defineComponent } from "../../util/component/index.js";
|
|
5
|
+
import { toStyleSizeValue } from "../../util/ui.js";
|
|
6
|
+
export const YDataTableLayerRow = defineComponent({
|
|
7
|
+
name: 'YDataTableLayerRow',
|
|
8
|
+
props: {
|
|
9
|
+
layerProps: Object,
|
|
10
|
+
item: Object,
|
|
11
|
+
width: {
|
|
12
|
+
type: Number
|
|
13
|
+
},
|
|
14
|
+
scrollTop: {
|
|
15
|
+
type: Number,
|
|
16
|
+
default: 0
|
|
17
|
+
},
|
|
18
|
+
headRect: Object,
|
|
19
|
+
classes: Function,
|
|
20
|
+
styles: Object
|
|
21
|
+
},
|
|
22
|
+
slots: Object,
|
|
23
|
+
setup(props, _ref) {
|
|
24
|
+
let {
|
|
25
|
+
slots
|
|
26
|
+
} = _ref;
|
|
27
|
+
const observer = shallowRef(null);
|
|
28
|
+
const layerRowRef = useTemplateRef('layerRowRef');
|
|
29
|
+
const rect = shallowRef(null);
|
|
30
|
+
const show = shallowRef(false);
|
|
31
|
+
const rowEl = ref();
|
|
32
|
+
const computedStyles = computed(() => {
|
|
33
|
+
const propStyles = props.styles?.(props.item, {
|
|
34
|
+
width: props.width,
|
|
35
|
+
height: rect.value?.[0]?.height
|
|
36
|
+
}) ?? {};
|
|
37
|
+
return {
|
|
38
|
+
transform: `translateY(${props.scrollTop * -1 + (rowEl.value?.offsetTop ?? 0) - (props.headRect?.height ?? 40)}px)`,
|
|
39
|
+
width: toStyleSizeValue(propStyles?.width ?? props.width),
|
|
40
|
+
height: toStyleSizeValue(propStyles?.height ?? rect.value?.[0]?.height)
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
const computedClasses = computed(() => {
|
|
44
|
+
const propClassResult = props.classes?.(props.item);
|
|
45
|
+
return Array.isArray(propClassResult) ? propClassResult : [propClassResult];
|
|
46
|
+
});
|
|
47
|
+
watch(() => props.item?.rowRef.value, () => {
|
|
48
|
+
rowEl.value = props.item?.rowRef.value?.$el;
|
|
49
|
+
}, {
|
|
50
|
+
immediate: true
|
|
51
|
+
});
|
|
52
|
+
watch(rowEl, (neo, old) => {
|
|
53
|
+
if (neo) {
|
|
54
|
+
observer.value?.unobserve(neo);
|
|
55
|
+
observer.value = new ResizeObserver(() => {
|
|
56
|
+
rect.value = neo.getClientRects();
|
|
57
|
+
});
|
|
58
|
+
observer.value.observe(neo);
|
|
59
|
+
show.value = true;
|
|
60
|
+
} else {
|
|
61
|
+
show.value = false;
|
|
62
|
+
if (old && neo !== old) {
|
|
63
|
+
observer.value?.unobserve(old);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
immediate: true
|
|
68
|
+
});
|
|
69
|
+
onBeforeUnmount(() => {
|
|
70
|
+
if (observer.value) {
|
|
71
|
+
observer.value.disconnect();
|
|
72
|
+
observer.value = null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
useRender(() => _withDirectives(_createVNode("div", {
|
|
76
|
+
"ref": layerRowRef,
|
|
77
|
+
"class": ['y-data-table-layer-row', ...computedClasses.value],
|
|
78
|
+
"style": computedStyles.value
|
|
79
|
+
}, [slots.default && slots.default({
|
|
80
|
+
item: props.item,
|
|
81
|
+
width: props.width,
|
|
82
|
+
height: rect.value?.[0]?.height,
|
|
83
|
+
scrollTop: props.scrollTop
|
|
84
|
+
})]), [[_vShow, show.value]]));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=YDataTableLayerRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YDataTableLayerRow.js","names":["computed","onBeforeUnmount","ref","shallowRef","useTemplateRef","watch","useRender","defineComponent","toStyleSizeValue","YDataTableLayerRow","name","props","layerProps","Object","item","width","type","Number","scrollTop","default","headRect","classes","Function","styles","slots","setup","_ref","observer","layerRowRef","rect","show","rowEl","computedStyles","propStyles","height","value","transform","offsetTop","computedClasses","propClassResult","Array","isArray","rowRef","$el","immediate","neo","old","unobserve","ResizeObserver","getClientRects","observe","disconnect","_withDirectives","_createVNode","_vShow"],"sources":["../../../src/components/table/YDataTableLayerRow.tsx"],"sourcesContent":["import {\n type PropType,\n SlotsType,\n computed,\n onBeforeUnmount,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue';\n\nimport { useRender } from '@/composables/component';\nimport { defineComponent } from '@/util/component';\nimport { toStyleSizeValue } from '@/util/ui';\n\nexport type YDataTableLayerRowDefaultSlotProps = {\n item: any;\n width: number | undefined;\n height: number | undefined;\n scrollTop: number;\n};\n\nexport const YDataTableLayerRow = defineComponent({\n name: 'YDataTableLayerRow',\n props: {\n layerProps: Object as PropType<any>,\n item: Object as PropType<any>,\n width: {\n type: Number as PropType<number>,\n },\n scrollTop: {\n type: Number as PropType<number>,\n default: 0,\n },\n headRect: Object as PropType<DOMRect>,\n classes: Function as PropType<(item: any) => string[] | string>,\n styles: Object as PropType<(item: any, originStyle: any) => any>,\n },\n slots: Object as SlotsType<{\n default: (slotProps: YDataTableLayerRowDefaultSlotProps) => any;\n }>,\n setup(props, { slots }) {\n const observer = shallowRef<ResizeObserver | null>(null);\n\n const layerRowRef = useTemplateRef<HTMLElement>('layerRowRef');\n const rect = shallowRef<DOMRectList | null>(null);\n const show = shallowRef(false);\n\n const rowEl = ref();\n\n const computedStyles = computed(() => {\n const propStyles =\n props.styles?.(props.item, {\n width: props.width,\n height: rect.value?.[0]?.height,\n }) ?? {};\n\n return {\n transform: `translateY(${props.scrollTop * -1 + (rowEl.value?.offsetTop ?? 0) - (props.headRect?.height ?? 40)}px)`,\n width: toStyleSizeValue(propStyles?.width ?? props.width),\n height: toStyleSizeValue(propStyles?.height ?? rect.value?.[0]?.height),\n };\n });\n\n const computedClasses = computed(() => {\n const propClassResult = props.classes?.(props.item);\n return Array.isArray(propClassResult)\n ? propClassResult\n : [propClassResult];\n });\n\n watch(\n () => props.item?.rowRef.value,\n () => {\n rowEl.value = props.item?.rowRef.value?.$el;\n },\n {\n immediate: true,\n },\n );\n\n watch(\n rowEl,\n (neo, old) => {\n if (neo) {\n observer.value?.unobserve(neo);\n observer.value = new ResizeObserver(() => {\n rect.value = neo.getClientRects();\n });\n observer.value.observe(neo);\n show.value = true;\n } else {\n show.value = false;\n if (old && neo !== old) {\n observer.value?.unobserve(old);\n }\n }\n },\n { immediate: true },\n );\n\n onBeforeUnmount(() => {\n if (observer.value) {\n observer.value.disconnect();\n observer.value = null;\n }\n });\n\n useRender(() => (\n <div\n ref={layerRowRef}\n v-show={show.value}\n class={['y-data-table-layer-row', ...computedClasses.value]}\n style={computedStyles.value}\n >\n {slots.default &&\n slots.default({\n item: props.item,\n width: props.width,\n height: rect.value?.[0]?.height,\n scrollTop: props.scrollTop,\n })}\n </div>\n ));\n },\n});\n"],"mappings":";AAAA,SAGEA,QAAQ,EACRC,eAAe,EACf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