yuyeon 0.3.1 → 0.3.2-rc.10
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/yuyeon.js +4861 -4714
- package/dist/yuyeon.umd.cjs +3 -3
- package/lib/components/dialog/YDialog.js +6 -1
- package/lib/components/dialog/YDialog.js.map +1 -1
- package/lib/components/divider/YDivider.scss +21 -0
- package/lib/components/field-input/YFieldInput.js +4 -1
- package/lib/components/field-input/YFieldInput.js.map +1 -1
- package/lib/components/input/YInput.js +2 -1
- package/lib/components/input/YInput.js.map +1 -1
- package/lib/components/select/YSelect.js.map +1 -1
- package/lib/components/slider/YSlider.js +1 -0
- package/lib/components/slider/YSlider.js.map +1 -1
- package/lib/components/slider/YSlider.scss +3 -0
- package/lib/components/slider/index.js +1 -1
- package/lib/components/slider/index.js.map +1 -1
- package/lib/components/slider/slider.js +2 -0
- package/lib/components/slider/slider.js.map +1 -0
- package/lib/components/table/YDataTable.js +32 -16
- package/lib/components/table/YDataTable.js.map +1 -1
- package/lib/components/table/YDataTableBody.js +26 -8
- 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.vue +146 -0
- package/lib/components/table/YDataTableRow.js +14 -6
- package/lib/components/table/YDataTableRow.js.map +1 -1
- package/lib/components/table/YDataTableServer.js +34 -19
- 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 +52 -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/types/index.js.map +1 -1
- package/lib/components/table/types/item.js.map +1 -1
- package/lib/components/tree-view/YTreeView.js +8 -4
- package/lib/components/tree-view/YTreeView.js.map +1 -1
- package/lib/components/tree-view/tree-view.js +34 -4
- package/lib/components/tree-view/tree-view.js.map +1 -1
- package/lib/components/tree-view/types.js.map +1 -1
- package/lib/composables/theme/setting.js +3 -2
- package/lib/composables/theme/setting.js.map +1 -1
- package/lib/util/color/index.js +1 -1
- package/lib/util/color/index.js.map +1 -1
- package/package.json +1 -1
- package/types/abstract/items.d.ts +4 -4
- package/types/components/badge/YBadge.d.ts +4 -4
- package/types/components/button/YButton.d.ts +8 -8
- package/types/components/chip/YChip.d.ts +1 -1
- package/types/components/date-picker/YDateCalendar.d.ts +1 -1
- package/types/components/date-picker/YDatePicker.d.ts +12 -12
- package/types/components/date-picker/YDatePickerControl.d.ts +10 -10
- package/types/components/dialog/YDialog.d.ts +72 -72
- package/types/components/dropdown/YDropdown.d.ts +55 -55
- package/types/components/field-input/YFieldInput.d.ts +13 -13
- package/types/components/hover/YHover.d.ts +3 -3
- package/types/components/icon/YIcon.d.ts +2 -2
- package/types/components/img/YImg.d.ts +5 -5
- package/types/components/input/YInput.d.ts +10 -9
- package/types/components/ip-field/YIpv4Field.d.ts +1 -1
- package/types/components/layer/YLayer.d.ts +26 -26
- package/types/components/layer/content.d.ts +1 -1
- package/types/components/layer/scroll-strategies.d.ts +1 -1
- package/types/components/list/YListItem.d.ts +1 -1
- package/types/components/menu/YMenu.d.ts +9 -9
- package/types/components/pagination/YPagination.d.ts +5 -5
- package/types/components/select/YSelect.d.ts +101 -101
- package/types/components/slider/index.d.ts +1 -0
- package/types/components/slider/slider.d.ts +0 -0
- package/types/components/snackbar/YSnackbar.d.ts +33 -33
- package/types/components/switch/YSwitch.d.ts +10 -10
- package/types/components/tab/YTab.d.ts +12 -12
- package/types/components/tab/YTabs.d.ts +4 -4
- package/types/components/table/YDataTable.d.ts +37 -15
- package/types/components/table/YDataTableBody.d.ts +5 -3
- package/types/components/table/YDataTableControl.d.ts +2 -2
- package/types/components/table/YDataTableHead.d.ts +2 -2
- package/types/components/table/YDataTableLayer.d.ts +4 -1
- package/types/components/table/YDataTableServer.d.ts +40 -18
- package/types/components/table/YTable.d.ts +4 -4
- 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/types/index.d.ts +2 -1
- package/types/components/table/types/item.d.ts +2 -1
- package/types/components/textarea/YTextarea.d.ts +18 -18
- package/types/components/tooltip/YTooltip.d.ts +46 -46
- package/types/components/tree-view/YTreeView.d.ts +21 -9
- package/types/components/tree-view/YTreeViewNode.d.ts +8 -8
- package/types/components/tree-view/tree-view.d.ts +2 -1
- package/types/components/tree-view/types.d.ts +8 -6
- package/types/composables/choice.d.ts +1 -1
- package/types/composables/coordinate/index.d.ts +8 -8
- package/types/composables/form.d.ts +2 -2
- package/types/composables/icon.d.ts +2 -2
- package/types/composables/list-items.d.ts +10 -10
- package/types/composables/theme/setting.d.ts +1 -0
- package/types/composables/transition.d.ts +1 -1
- package/types/composables/validation.d.ts +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sorting.js","names":["inject","provide","toRef","useModelDuplex","propsFactory","Y_DATA_TABLE_SORTING_KEY","Symbol","for","pressDataTableSortProps","sortBy","type","Array","default","multiSort","Boolean","createSorting","props","provideSorting","options","page","toggleSort","column","neo","value","map","v","target","find","key","sortOption","order","mustSort","filter","isSorted","option","data","useSorting","Error","description"],"sources":["../../../../src/components/table/composables/sorting.ts"],"sourcesContent":["import {\r\n type DeepReadonly,\r\n type InjectionKey,\r\n type PropType,\r\n type Ref,\r\n inject,\r\n provide,\r\n toRef,\r\n} from 'vue';\r\n\r\nimport { useModelDuplex } from '@/composables/communication';\r\nimport { propsFactory } from '@/util/component';\r\n\r\nimport type {\r\n DataTableProvideSortingData,\r\n InternalDataTableHeader,\r\n SortOption,\r\n} from '../types';\r\n\r\nconst Y_DATA_TABLE_SORTING_KEY: InjectionKey<{\r\n sortBy: Ref<readonly SortOption[]>;\r\n toggleSort: (col: InternalDataTableHeader) => void;\r\n isSorted: (col: InternalDataTableHeader) => boolean;\r\n}> = Symbol.for('yuyeon.data-table.sorting');\r\n\r\nexport const pressDataTableSortProps = propsFactory(\r\n {\r\n sortBy: {\r\n type: Array as PropType<DeepReadonly<SortOption[]>>,\r\n default: () => [],\r\n },\r\n multiSort: Boolean,\r\n },\r\n 'YDataTable--sorting',\r\n);\r\n\r\ntype SortProps = {\r\n sortBy: readonly SortOption[];\r\n 'onUpdate:sortBy': ((value: any) => void) | undefined;\r\n multiSort: boolean;\r\n};\r\n\r\nexport function createSorting(props: SortProps) {\r\n const sortBy = useModelDuplex(props, 'sortBy');\r\n const multiSort = toRef(props, 'multiSort');\r\n\r\n return { sortBy, multiSort };\r\n}\r\n\r\nexport function provideSorting(options: {\r\n sortBy: Ref<readonly SortOption[]>;\r\n page?: Ref<number>;\r\n multiSort?: Ref<boolean>;\r\n}) {\r\n const { sortBy, multiSort, page } = options;\r\n\r\n const toggleSort = (column: InternalDataTableHeader) => {\r\n let neo = sortBy.value?.map((v) => ({ ...v })) ?? [];\r\n const target = neo.find((v) => v.key === column.key);\r\n const sortOption: SortOption = { key: column.key, order: 'asc' };\r\n\r\n if (!target) {\r\n if (multiSort?.value) {\r\n neo = [...neo, sortOption];\r\n } else {\r\n neo = [sortOption];\r\n }\r\n } else if (target.order === 'desc') {\r\n if (column.mustSort) {\r\n target.order = 'asc';\r\n } else {\r\n neo = neo.filter((v) => v.key !== column.key);\r\n }\r\n } else {\r\n target.order = 'desc';\r\n }\r\n sortBy.value = neo;\r\n if (page) {\r\n page.value = 1;\r\n }\r\n };\r\n\r\n function isSorted(column: InternalDataTableHeader) {\r\n return !!sortBy.value.find((option) => option.key === column.key);\r\n }\r\n\r\n const data: DataTableProvideSortingData = { sortBy, toggleSort, isSorted };\r\n\r\n provide(Y_DATA_TABLE_SORTING_KEY, data);\r\n\r\n return data;\r\n}\r\n\r\nexport function useSorting() {\r\n const data = inject(Y_DATA_TABLE_SORTING_KEY);\r\n if (!data) {\r\n throw new Error(`Not provided: ${Y_DATA_TABLE_SORTING_KEY.description}`);\r\n }\r\n return data;\r\n}\r\n"],"mappings":"AAAA,SAKEA,MAAM,EACNC,OAAO,EACPC,KAAK,QACA,KAAK;AAAC,SAEJC,cAAc;AAAA,SACdC,YAAY;AAQrB,MAAMC,wBAIJ,GAAGC,MAAM,CAACC,GAAG,CAAC,2BAA2B,CAAC;AAE5C,OAAO,MAAMC,uBAAuB,GAAGJ,YAAY,CACjD;EACEK,MAAM,EAAE;IACNC,IAAI,EAAEC,KAA6C;IACnDC,OAAO,EAAEA,CAAA,KAA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C;IACF,CAAC,MAAM;MACLF,MAAM,CAACI,KAAK,GAAG,MAAM;IACvB;IACArB,MAAM,CAACc,KAAK,GAAGD,GAAG;IAClB,IAAIH,IAAI,EAAE;MACRA,IAAI,CAACI,KAAK,GAAG,CAAC;IAChB;EACF,CAAC;EAED,SAASU,QAAQA,CAACZ,MAA+B,EAAE;IACjD,OAAO,CAAC,CAACZ,MAAM,CAACc,KAAK,CAACI,IAAI,CAAEO,MAAM,IAAKA,MAAM,CAACN,GAAG,KAAKP,MAAM,CAACO,GAAG,CAAC;EACnE;EAEA,MAAMO,IAAiC,GAAG;IAAE1B,MAAM;IAAEW,UAAU;IAAEa;EAAS,CAAC;EAE1EhC,OAAO,CAACI,wBAAwB,EAAE8B,IAAI,CAAC;EAEvC,OAAOA,IAAI;AACb;AAEA,OAAO,SAASC,UAAUA,CAAA,EAAG;EAC3B,MAAMD,IAAI,GAAGnC,MAAM,CAACK,wBAAwB,CAAC;EAC7C,IAAI,CAAC8B,IAAI,EAAE;IACT,MAAM,IAAIE,KAAK,CAAE,iBAAgBhC,wBAAwB,CAACiC,WAAY,EAAC,CAAC;EAC1E;EACA,OAAOH,IAAI;AACb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, shallowRef } from 'vue';
|
|
1
|
+
import { ref, shallowRef, watch } from 'vue';
|
|
2
2
|
import { useResizeObserver } from "../../../composables/resize-observer.js";
|
|
3
3
|
import { debounce } from "../../../util/debounce.js";
|
|
4
4
|
export function useRectMeasure() {
|
|
@@ -15,10 +15,20 @@ export function useRectMeasure() {
|
|
|
15
15
|
});
|
|
16
16
|
function measure(entries) {
|
|
17
17
|
containerRect.value = entries?.[0]?.contentRect;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (wrapperRef.value) {
|
|
19
|
+
const rect = wrapperRef.value.getBoundingClientRect();
|
|
20
|
+
if (rect) {
|
|
21
|
+
const obj = {};
|
|
22
|
+
for (const key in rect) {
|
|
23
|
+
if (typeof rect[key] !== "function") {
|
|
24
|
+
obj[key] = rect[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
wrapperRect.value = {
|
|
28
|
+
...obj,
|
|
29
|
+
clientWidth: wrapperRef.value?.clientWidth ?? 0
|
|
30
|
+
};
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
if (tableRef.value) {
|
|
24
34
|
const rect = tableRef.value?.getBoundingClientRect();
|
|
@@ -27,6 +37,12 @@ export function useRectMeasure() {
|
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
}
|
|
40
|
+
watch(tableRef, neo => {
|
|
41
|
+
if (neo) {
|
|
42
|
+
const el = containerRef.value;
|
|
43
|
+
wrapperRef.value = el.querySelector('.y-table__wrapper');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
30
46
|
return {
|
|
31
47
|
containerRef,
|
|
32
48
|
wrapperRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measure.js","names":["ref","shallowRef","useResizeObserver","debounce","useRectMeasure","tableRef","wrapperRef","containerRect","wrapperRect","tableRect","debounceMeasure","measure","resizeObservedRef","containerRef","entries","value","contentRect","
|
|
1
|
+
{"version":3,"file":"measure.js","names":["ref","shallowRef","watch","useResizeObserver","debounce","useRectMeasure","tableRef","wrapperRef","containerRect","wrapperRect","tableRect","debounceMeasure","measure","resizeObservedRef","containerRef","entries","value","contentRect","rect","getBoundingClientRect","obj","key","clientWidth","neo","el","querySelector"],"sources":["../../../../src/components/table/composibles/measure.ts"],"sourcesContent":["import { ref, shallowRef, watch } from 'vue';\n\nimport { useResizeObserver } from '@/composables/resize-observer';\nimport { debounce } from '@/util/debounce';\n\nexport function useRectMeasure() {\n const tableRef = ref();\n const wrapperRef = ref();\n\n const containerRect = shallowRef<DOMRectReadOnly>();\n const wrapperRect = shallowRef<DOMRectReadOnly>();\n const tableRect = shallowRef<DOMRectReadOnly>();\n\n const debounceMeasure = debounce(measure, 100);\n\n const { resizeObservedRef: containerRef } = useResizeObserver((entries) => {\n debounceMeasure(entries);\n });\n\n function measure(entries: any) {\n containerRect.value = entries?.[0]?.contentRect;\n\n if (wrapperRef.value) {\n const rect = wrapperRef.value.getBoundingClientRect();\n\n if (rect) {\n const obj: any = {};\n for (const key in rect) {\n if (typeof rect[key] !== \"function\") {\n obj[key] = rect[key];\n }\n }\n wrapperRect.value = {\n ...obj,\n clientWidth: wrapperRef.value?.clientWidth ?? 0,\n };\n }\n\n }\n\n if (tableRef.value) {\n const rect = tableRef.value?.getBoundingClientRect();\n if (rect) {\n tableRect.value = rect;\n }\n }\n }\n\n watch(tableRef, (neo) => {\n if (neo) {\n const el = containerRef.value!;\n wrapperRef.value = el.querySelector('.y-table__wrapper');\n }\n })\n\n return {\n containerRef,\n wrapperRef,\n tableRef,\n containerRect,\n wrapperRect,\n tableRect,\n };\n}\n"],"mappings":"AAAA,SAASA,GAAG,EAAEC,UAAU,EAAEC,KAAK,QAAQ,KAAK;AAAC,SAEpCC,iBAAiB;AAAA,SACjBC,QAAQ;AAEjB,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/B,MAAMC,QAAQ,GAAGN,GAAG,CAAC,CAAC;EACtB,MAAMO,UAAU,GAAGP,GAAG,CAAC,CAAC;EAExB,MAAMQ,aAAa,GAAGP,UAAU,CAAkB,CAAC;EACnD,MAAMQ,WAAW,GAAGR,UAAU,CAAkB,CAAC;EACjD,MAAMS,SAAS,GAAGT,UAAU,CAAkB,CAAC;EAE/C,MAAMU,eAAe,GAAGP,QAAQ,CAACQ,OAAO,EAAE,GAAG,CAAC;EAE9C,MAAM;IAAEC,iBAAiB,EAAEC;EAAa,CAAC,GAAGX,iBAAiB,CAAEY,OAAO,IAAK;IACzEJ,eAAe,CAACI,OAAO,CAAC;EAC1B,CAAC,CAAC;EAEF,SAASH,OAAOA,CAACG,OAAY,EAAE;IAC7BP,aAAa,CAACQ,KAAK,GAAGD,OAAO,GAAG,CAAC,CAAC,EAAEE,WAAW;IAE/C,IAAIV,UAAU,CAACS,KAAK,EAAE;MACpB,MAAME,IAAI,GAAGX,UAAU,CAACS,KAAK,CAACG,qBAAqB,CAAC,CAAC;MAErD,IAAID,IAAI,EAAE;QACR,MAAME,GAAQ,GAAG,CAAC,CAAC;QACnB,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;UACtB,IAAI,OAAOA,IAAI,CAACG,GAAG,CAAC,KAAK,UAAU,EAAE;YACnCD,GAAG,CAACC,GAAG,CAAC,GAAGH,IAAI,CAACG,GAAG,CAAC;UACtB;QACF;QACAZ,WAAW,CAACO,KAAK,GAAG;UAClB,GAAGI,GAAG;UACNE,WAAW,EAAEf,UAAU,CAACS,KAAK,EAAEM,WAAW,IAAI;QAChD,CAAC;MACH;IAEF;IAEA,IAAIhB,QAAQ,CAACU,KAAK,EAAE;MAClB,MAAME,IAAI,GAAGZ,QAAQ,CAACU,KAAK,EAAEG,qBAAqB,CAAC,CAAC;MACpD,IAAID,IAAI,EAAE;QACRR,SAAS,CAACM,KAAK,GAAGE,IAAI;MACxB;IACF;EACF;EAEAhB,KAAK,CAACI,QAAQ,EAAGiB,GAAG,IAAK;IACvB,IAAIA,GAAG,EAAE;MACP,MAAMC,EAAE,GAAGV,YAAY,CAACE,KAAM;MAC9BT,UAAU,CAACS,KAAK,GAAGQ,EAAE,CAACC,aAAa,CAAC,mBAAmB,CAAC;IAC1D;EACF,CAAC,CAAC;EAEF,OAAO;IACLX,YAAY;IACZP,UAAU;IACVD,QAAQ;IACRE,aAAa;IACbC,WAAW;IACXC;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/table/types/index.ts"],"sourcesContent":["import { ComputedRef, Ref, UnwrapRef } from 'vue';\
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/table/types/index.ts"],"sourcesContent":["import { ComputedRef, Ref, UnwrapRef } from 'vue';\n\nimport { SelectableItem } from '@/components/table/composables/selection';\nimport type { DataTableCompareFn } from './common';\nimport type { DataTableHeader, InternalDataTableHeader } from './header';\nimport type { DataTableItem, ItemKeySlot } from './item';\nimport type { CellProps, RowProps } from './row';\n\nexport type {\n ItemKeySlot,\n RowProps,\n CellProps,\n DataTableHeader,\n InternalDataTableHeader,\n DataTableItem,\n DataTableCompareFn,\n};\n\nexport type SortOption = { key: string; order?: boolean | 'asc' | 'desc' };\n\nexport type DataTableProvideSortingData = {\n sortBy: Ref<readonly SortOption[]>;\n toggleSort: (column: InternalDataTableHeader) => void;\n isSorted: (column: InternalDataTableHeader) => boolean;\n};\n\nexport interface DataTableProvidePaginationData {\n page: Ref<number>;\n pageSize: Ref<number>;\n startIndex: ComputedRef<number>;\n endIndex: ComputedRef<number>;\n pageLength: ComputedRef<number>;\n total: Ref<number>;\n nextPage: () => void;\n prevPage: () => void;\n setPage: (value: number) => void;\n setPageSize: (value: number) => void;\n}\n\nexport interface DataTableProvideSelectionData {\n toggleSelect: (item: SelectableItem) => void;\n select: (items: SelectableItem[], value: boolean) => void;\n selectAll: (value: boolean) => void;\n isSelected: (items: SelectableItem | SelectableItem[]) => any;\n isSomeSelected: (items: SelectableItem | SelectableItem[]) => any;\n someSelected: ComputedRef<boolean>;\n allSelected: ComputedRef<any>;\n showSelectAll: boolean;\n selectables: ComputedRef<SelectableItem[]>;\n}\n\nexport type YDataTableSlotProps = {\n // pagination\n page: number;\n pageSize: number;\n pageLength: number;\n setPageSize: DataTableProvidePaginationData['setPageSize'];\n // sorting\n sortBy: UnwrapRef<DataTableProvideSortingData['sortBy']>;\n toggleSort: DataTableProvideSortingData['toggleSort'];\n // selection\n someSelected: boolean;\n allSelected: boolean;\n isSelected: DataTableProvideSelectionData['isSelected'];\n select: DataTableProvideSelectionData['select'];\n selectAll: DataTableProvideSelectionData['selectAll'];\n toggleSelect: DataTableProvideSelectionData['toggleSelect'];\n //\n items: readonly DataTableItem[];\n columns: InternalDataTableHeader[];\n headers: InternalDataTableHeader[][];\n //\n TableBodyRef: Ref<any>;\n};\n\nexport type FixedPropType = 'lead' | 'trail' | 'lead-last' | 'trail-last';\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","names":[],"sources":["../../../../src/components/table/types/item.ts"],"sourcesContent":["import { SelectableItem, provideSelection } from '
|
|
1
|
+
{"version":3,"file":"item.js","names":[],"sources":["../../../../src/components/table/types/item.ts"],"sourcesContent":["import { SelectableItem, provideSelection } from '@/components/table/composables/selection';\nimport { InternalDataTableHeader } from './header';\n\ntype ItemSlotBase<T> = {\n index: number;\n item: T;\n internalItem: DataTableItem<T>;\n selected: boolean;\n isSelected: ReturnType<typeof provideSelection>['isSelected'];\n toggleSelect: ReturnType<typeof provideSelection>['toggleSelect'];\n};\n\nexport type ItemKeySlot<T> = ItemSlotBase<T> & {\n value: any;\n column: InternalDataTableHeader;\n};\n\nexport interface DataTableItem<T = any> extends SelectableItem {\n index: number;\n columns: Record<string, any>;\n raw: T;\n rowRef?: any\n}\n"],"mappings":""}
|
|
@@ -25,17 +25,20 @@ export const YTreeView = defineComponent({
|
|
|
25
25
|
},
|
|
26
26
|
multipleActive: Boolean,
|
|
27
27
|
activeStrategy: {
|
|
28
|
+
/**
|
|
29
|
+
* cascade: only descendent leaves
|
|
30
|
+
* relative: cascade after check parent (ancestor)
|
|
31
|
+
*/
|
|
28
32
|
type: String,
|
|
29
|
-
// TODO: 'leaf'
|
|
30
33
|
default: 'independent'
|
|
31
34
|
},
|
|
35
|
+
onlyEventActiveStrategy: Boolean,
|
|
32
36
|
selected: {
|
|
33
37
|
type: [Array],
|
|
34
38
|
default: () => []
|
|
35
39
|
},
|
|
36
40
|
selectStrategy: {
|
|
37
41
|
type: String,
|
|
38
|
-
// TODO: 'leaf'
|
|
39
42
|
default: 'leaf'
|
|
40
43
|
},
|
|
41
44
|
returnItem: Boolean,
|
|
@@ -159,7 +162,7 @@ export const YTreeView = defineComponent({
|
|
|
159
162
|
let until = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
160
163
|
Object.entries(nodes.value).forEach(_ref2 => {
|
|
161
164
|
let [key, node] = _ref2;
|
|
162
|
-
if (until === true || until >= node.level) {
|
|
165
|
+
if (until === true || Number(until) >= node.level) {
|
|
163
166
|
updateExpanded(key, true);
|
|
164
167
|
}
|
|
165
168
|
});
|
|
@@ -282,7 +285,8 @@ export const YTreeView = defineComponent({
|
|
|
282
285
|
activeSet,
|
|
283
286
|
excludedSet,
|
|
284
287
|
searchLoading,
|
|
285
|
-
expandedCache
|
|
288
|
+
expandedCache,
|
|
289
|
+
renderLeaves
|
|
286
290
|
};
|
|
287
291
|
}
|
|
288
292
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YTreeView.js","names":["computed","defineComponent","onMounted","ref","shallowRef","watch","provideTreeView","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","chooseProps","debounce","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","filterItemsFn","excludeItem","expandedCache","nodes","expandedSet","selectedSet","activeSet","searchLoading","excludedSet","issueVnodeState","updateExpanded","updateActive","updateSelected","emitExpanded","emitActive","emitSelected","isExcluded","items","search","arguments","length","undefined","excluded","Set","value","diff","forEach","key","item","itemKey","itemText","itemChildren","expand","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","includes","indeterminate","node","childKeys","map","child","add","neo","deep","until","Object","entries","_ref2","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","keys","nodeKey","neoKeys","k","oldSelected","oldActive","clear","flush","renderLeaves","slice","leaf","classes","styles","color","activeColor","activeValue","selectedValue","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\n type PropType,\n type Ref,\n computed,\n defineComponent,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue';\n\nimport { provideTreeView } from '@/components/tree-view/tree-view';\nimport { useRender } from '@/composables/component';\nimport { CandidateKey } from '@/types';\nimport { differenceBetween } from '@/util/array';\nimport { isColorValue } from '@/util/color';\nimport { deepEqual, getObjectValueByPath, hasOwnProperty } from '@/util/common';\nimport { chooseProps } from '@/util/component';\nimport { debounce } from '@/util/debounce';\n\nimport { YProgressBar } from '../progress-bar';\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\nimport { NodeState, TreeviewFilterFn } from './types';\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\n\nimport './YTreeView.scss';\n\nconst treeViewNodeProps = pressYTreeViewNodeProps();\n\nexport const YTreeView = defineComponent({\n name: 'YTreeView',\n props: {\n expanded: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n active: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n multipleActive: Boolean,\n activeStrategy: {\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\n default: 'independent',\n },\n selected: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n selectStrategy: {\n type: String as PropType<'independent' | 'cascade'>, // TODO: 'leaf'\n default: 'leaf',\n },\n returnItem: Boolean,\n defaultExpand: [Boolean, String, Number],\n filter: Function as PropType<TreeviewFilterFn>,\n searchDebounceWait: {\n type: Number as PropType<number>,\n default: 700,\n },\n ...treeViewNodeProps,\n },\n emits: ['update:expanded', 'update:active', 'update:selected'],\n setup(props, { slots, emit, expose }) {\n const filterItemsFn = shallowRef(\n debounce(excludeItem, props.searchDebounceWait),\n );\n const expandedCache = ref<CandidateKey[]>([]);\n\n const {\n nodes,\n expanded,\n active,\n selected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n isExcluded,\n } = provideTreeView(props);\n\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\n const excluded = new Set<CandidateKey>();\n if (!search) {\n searchLoading.value = false;\n excludedSet.value = excluded;\n const diff = differenceBetween(expandedCache.value, [\n ...expandedSet.value,\n ]);\n diff.forEach((key) => {\n updateExpanded(key, false);\n });\n expandedCache.value.forEach((key) => {\n updateExpanded(key, true);\n });\n return;\n }\n for (const item of items) {\n filterTreeItems(\n filter,\n item,\n search ?? '',\n props.itemKey,\n props.itemText,\n props.itemChildren as string,\n excluded,\n );\n }\n excludedSet.value = excluded;\n searchLoading.value = false;\n expand();\n }\n\n watch(\n () => props.search,\n () => {\n searchLoading.value = true;\n filterItemsFn.value(props.items, props.search, props.filter);\n },\n );\n\n // Util Methods\n function getNodeKey(itemOrKey: any) {\n return props.returnItem\n ? getObjectValueByPath(itemOrKey, props.itemKey)\n : itemOrKey;\n }\n\n // State Methods\n function updateNodes(\n items: any[],\n parentKey: CandidateKey | null = null,\n level = 0,\n ) {\n for (const item of items) {\n const key = getObjectValueByPath(item, props.itemKey);\n const children =\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\n const exist = hasOwnProperty(nodes.value, key);\n const existNode = exist\n ? nodes.value[key]\n : {\n vnode: null,\n selected: selected.value?.includes(key) ?? false,\n indeterminate: false,\n active: active.value?.includes(key) ?? false,\n expanded: expanded.value?.includes(key) ?? false,\n };\n const node: NodeState = {\n vnode: existNode.vnode,\n item,\n level,\n parentKey,\n childKeys: children.map((child: any) =>\n getObjectValueByPath(child, props.itemKey),\n ),\n expanded: children.length > 0 && existNode.expanded,\n active: existNode.active,\n indeterminate: existNode.indeterminate,\n selected: existNode.selected,\n };\n\n updateNodes(children, key, level + 1);\n\n nodes.value[key] = node;\n if (nodes.value[key].expanded) {\n expandedSet.value.add(key);\n }\n if (nodes.value[key].selected) {\n selectedSet.value.add(key);\n }\n if (nodes.value[key].active) {\n activeSet.value.add(key);\n }\n issueVnodeState(key);\n }\n }\n\n watch(\n expandedSet,\n (neo) => {\n if (!props.search) {\n expandedCache.value = [...neo];\n }\n },\n { deep: true },\n );\n\n function expand(until: boolean | string | number = true) {\n Object.entries(nodes.value).forEach(([key, node]) => {\n if (until === true || until >= node.level) {\n updateExpanded(key, true);\n }\n });\n emitExpanded();\n return expandedSet.value;\n }\n\n function stateWatcher(\n value: any[],\n stateSet: Ref<Set<CandidateKey>>,\n updater: (key: CandidateKey, to: boolean) => void,\n emitter: () => void,\n ) {\n const valuesOfKey = props.returnItem\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\n : value;\n const old = [...stateSet.value];\n if (deepEqual(old, valuesOfKey)) {\n return;\n }\n old.forEach((key) => updater(key, false));\n valuesOfKey.forEach((key) => updater(key, true));\n emitter();\n }\n\n watch(expanded, (neo) => {\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\n });\n\n watch(active, (neo) => {\n stateWatcher(neo, activeSet, updateActive, emitActive);\n });\n\n watch(selected, (neo) => {\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\n });\n\n watch(\n () => props.items,\n (neo: any[]) => {\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\n );\n const neoKeys = getKeys(\n neo,\n props.itemKey,\n props.itemChildren as string,\n );\n const diff = differenceBetween(oldKeys, neoKeys);\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\n return;\n }\n diff.forEach((k) => delete nodes.value[k]);\n\n // init\n const oldSelected = [...selectedSet.value];\n const oldActive = [...activeSet.value];\n selectedSet.value.clear();\n expandedSet.value.clear();\n activeSet.value.clear();\n updateNodes(neo);\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\n emitSelected();\n }\n if (!deepEqual(oldActive, [...activeSet.value])) {\n emitActive();\n }\n filterItemsFn.value(neo, props.search, props.filter);\n },\n { deep: true, flush: 'sync' },\n );\n\n // Provide & Issue\n\n updateNodes(props.items);\n\n const renderLeaves = computed(() => {\n return props.items.slice().filter((leaf) => {\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\n });\n });\n\n const classes = computed(() => {\n return {\n 'y-tree-view': true,\n };\n });\n\n const styles = computed(() => {\n let color = props.activeColor;\n if (props.activeColor && !isColorValue(props.activeColor)) {\n color = `var(--y-theme-${props.activeColor})`;\n }\n return {\n [`--y-tree-view__active-color`]: color,\n };\n });\n\n onMounted(() => {\n if (props.search) {\n searchLoading.value = true;\n excludeItem(props.items, props.search, props.filter);\n }\n\n if (props.defaultExpand != null && props.defaultExpand !== false) {\n expandedCache.value = [...expand(props.defaultExpand)];\n } else {\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\n emitExpanded();\n }\n\n for (const activeValue of props.active.map(getNodeKey)) {\n updateActive(activeValue, true);\n }\n\n for (const selectedValue of props.selected.map(getNodeKey)) {\n updateSelected(selectedValue, true);\n }\n });\n\n expose({\n expand,\n });\n\n useRender(() => {\n return (\n <>\n <div class={classes.value} style={styles.value} role=\"tree\">\n {searchLoading.value && <YProgressBar indeterminate />}\n {renderLeaves.value.length > 0 ? (\n renderLeaves.value.slice().map((leaf) => {\n return (\n <YTreeViewNode\n v-slots={slots}\n key={getObjectValueByPath(leaf, props.itemKey)}\n {...{\n ...chooseProps(props, treeViewNodeProps),\n item: leaf,\n level: 0,\n }}\n ></YTreeViewNode>\n );\n })\n ) : (\n <div class=\"y-tree-view__no-data\">\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\n </div>\n )}\n </div>\n </>\n );\n });\n\n return {\n nodes,\n expandedSet,\n selectedSet,\n activeSet,\n excludedSet,\n searchLoading,\n expandedCache,\n };\n },\n});\n\nexport type YTreeView = InstanceType<typeof YTreeView>;\n"],"mappings":";AAAA,SAGEA,QAAQ,EACRC,eAAe,EACfC,SAAS,EACTC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAA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;MACjC;MAEA,KAAK,MAAMC,aAAa,IAAIvG,KAAK,CAACU,QAAQ,CAAC4D,GAAG,CAACb,UAAU,CAAC,EAAE;QAC1DrB,cAAc,CAACmE,aAAa,EAAE,IAAI,CAAC;MACrC;IACF,CAAC,CAAC;IAEFhF,MAAM,CAAC;MACLiC;IACF,CAAC,CAAC;IAEFzE,SAAS,CAAC,MAAM;MACd,OAAAyH,YAAA,CAAAC,SAAA,SAAAD,YAAA;QAAA,SAEgBN,OAAO,CAAClD,KAAK;QAAA,SAASmD,MAAM,CAACnD,KAAK;QAAA;MAAA,IAC3CjB,aAAa,CAACiB,KAAK,IAAAwD,YAAA,CAAAjH,YAAA;QAAA;MAAA,QAAkC,EACrDwG,YAAY,CAAC/C,KAAK,CAACJ,MAAM,GAAG,CAAC,GAC5BmD,YAAY,CAAC/C,KAAK,CAACgD,KAAK,CAAC,CAAC,CAAC1B,GAAG,CAAE2B,IAAI,IAAK;QACvC,OAAAO,YAAA,CAAAhH,aAAA,EAAAkH,WAAA;UAAA,OAGSvH,oBAAoB,CAAC8G,IAAI,EAAEjG,KAAK,CAACqD,OAAO;QAAC;UAE5C,GAAGhE,WAAW,CAACW,KAAK,EAAEH,iBAAiB,CAAC;UACxCuD,IAAI,EAAE6C,IAAI;UACVpC,KAAK,EAAE;QAAC,IALDxC,KAAK;MASpB,CAAC,CAAC,GAAAmF,YAAA;QAAA;MAAA,IAGCnF,KAAK,CAAC,SAAS,CAAC,GAAGA,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAAmF,YAAA,gBAAAG,gBAAA,aAAuB,EAEhE;IAIT,CAAC,CAAC;IAEF,OAAO;MACLhF,KAAK;MACLC,WAAW;MACXC,WAAW;MACXC,SAAS;MACTE,WAAW;MACXD,aAAa;MACbL;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"YTreeView.js","names":["computed","defineComponent","onMounted","ref","shallowRef","watch","provideTreeView","useRender","differenceBetween","isColorValue","deepEqual","getObjectValueByPath","hasOwnProperty","chooseProps","debounce","YProgressBar","YTreeViewNode","pressYTreeViewNodeProps","filterTreeItem","filterTreeItems","getKeys","treeViewNodeProps","YTreeView","name","props","expanded","type","Array","default","active","multipleActive","Boolean","activeStrategy","String","onlyEventActiveStrategy","selected","selectStrategy","returnItem","defaultExpand","Number","filter","Function","searchDebounceWait","emits","setup","_ref","slots","emit","expose","filterItemsFn","excludeItem","expandedCache","nodes","expandedSet","selectedSet","activeSet","searchLoading","excludedSet","issueVnodeState","updateExpanded","updateActive","updateSelected","emitExpanded","emitActive","emitSelected","isExcluded","items","search","arguments","length","undefined","excluded","Set","value","diff","forEach","key","item","itemKey","itemText","itemChildren","expand","getNodeKey","itemOrKey","updateNodes","parentKey","level","children","exist","existNode","vnode","includes","indeterminate","node","childKeys","map","child","add","neo","deep","until","Object","entries","_ref2","stateWatcher","stateSet","updater","emitter","valuesOfKey","v","old","oldKeys","keys","nodeKey","neoKeys","k","oldSelected","oldActive","clear","flush","renderLeaves","slice","leaf","classes","styles","color","activeColor","activeValue","selectedValue","_createVNode","_Fragment","_mergeProps","_createTextVNode"],"sources":["../../../src/components/tree-view/YTreeView.tsx"],"sourcesContent":["import {\n type PropType,\n type Ref,\n computed,\n defineComponent,\n onMounted,\n ref,\n shallowRef,\n watch,\n} from 'vue';\n\nimport { provideTreeView } from '@/components/tree-view/tree-view';\nimport { useRender } from '@/composables/component';\nimport { CandidateKey } from '@/types';\nimport { differenceBetween } from '@/util/array';\nimport { isColorValue } from '@/util/color';\nimport { deepEqual, getObjectValueByPath, hasOwnProperty } from '@/util/common';\nimport { chooseProps } from '@/util/component';\nimport { debounce } from '@/util/debounce';\n\nimport { YProgressBar } from '../progress-bar';\nimport { YTreeViewNode, pressYTreeViewNodeProps } from './YTreeViewNode';\nimport { NodeState, TreeviewFilterFn } from './types';\nimport { filterTreeItem, filterTreeItems, getKeys } from './util';\n\nimport './YTreeView.scss';\n\nconst treeViewNodeProps = pressYTreeViewNodeProps();\n\nexport const YTreeView = defineComponent({\n name: 'YTreeView',\n props: {\n expanded: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n active: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n multipleActive: Boolean,\n activeStrategy: {\n /**\n * cascade: only descendent leaves\n * relative: cascade after check parent (ancestor)\n */\n type: String as PropType<'independent' | 'cascade' | 'relative'>,\n default: 'independent',\n },\n onlyEventActiveStrategy: Boolean,\n selected: {\n type: [Array] as PropType<CandidateKey[]>,\n default: () => [],\n },\n selectStrategy: {\n type: String as PropType<'independent' | 'cascade'>,\n default: 'leaf',\n },\n returnItem: Boolean,\n defaultExpand: [Boolean, String, Number],\n filter: Function as PropType<TreeviewFilterFn>,\n searchDebounceWait: {\n type: Number as PropType<number>,\n default: 700,\n },\n ...treeViewNodeProps,\n },\n emits: ['update:expanded', 'update:active', 'update:selected'],\n setup(props, { slots, emit, expose }) {\n const filterItemsFn = shallowRef(\n debounce(excludeItem, props.searchDebounceWait),\n );\n const expandedCache = ref<CandidateKey[]>([]);\n\n const {\n nodes,\n expanded,\n active,\n selected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n isExcluded,\n } = provideTreeView(props);\n\n function excludeItem(items: any[], search = '', filter = filterTreeItem) {\n const excluded = new Set<CandidateKey>();\n if (!search) {\n searchLoading.value = false;\n excludedSet.value = excluded;\n const diff = differenceBetween(expandedCache.value, [\n ...expandedSet.value,\n ]);\n diff.forEach((key) => {\n updateExpanded(key, false);\n });\n expandedCache.value.forEach((key) => {\n updateExpanded(key, true);\n });\n return;\n }\n for (const item of items) {\n filterTreeItems(\n filter,\n item,\n search ?? '',\n props.itemKey,\n props.itemText,\n props.itemChildren as string,\n excluded,\n );\n }\n excludedSet.value = excluded;\n searchLoading.value = false;\n expand();\n }\n\n watch(\n () => props.search,\n () => {\n searchLoading.value = true;\n filterItemsFn.value(props.items, props.search, props.filter);\n },\n );\n\n // Util Methods\n function getNodeKey(itemOrKey: any) {\n return props.returnItem\n ? getObjectValueByPath(itemOrKey, props.itemKey)\n : itemOrKey;\n }\n\n // State Methods\n function updateNodes(\n items: any[],\n parentKey: CandidateKey | null = null,\n level = 0,\n ) {\n for (const item of items) {\n const key = getObjectValueByPath(item, props.itemKey);\n const children =\n getObjectValueByPath(item, props.itemChildren as string) ?? [];\n const exist = hasOwnProperty(nodes.value, key);\n const existNode = exist\n ? nodes.value[key]\n : {\n vnode: null,\n selected: selected.value?.includes(key) ?? false,\n indeterminate: false,\n active: active.value?.includes(key) ?? false,\n expanded: expanded.value?.includes(key) ?? false,\n };\n const node: NodeState = {\n vnode: existNode.vnode,\n item,\n level,\n parentKey,\n childKeys: children.map((child: any) =>\n getObjectValueByPath(child, props.itemKey),\n ),\n expanded: children.length > 0 && existNode.expanded,\n active: existNode.active,\n indeterminate: existNode.indeterminate,\n selected: existNode.selected,\n };\n\n updateNodes(children, key, level + 1);\n\n nodes.value[key] = node;\n if (nodes.value[key].expanded) {\n expandedSet.value.add(key);\n }\n if (nodes.value[key].selected) {\n selectedSet.value.add(key);\n }\n if (nodes.value[key].active) {\n activeSet.value.add(key);\n }\n issueVnodeState(key);\n }\n }\n\n watch(\n expandedSet,\n (neo) => {\n if (!props.search) {\n expandedCache.value = [...neo];\n }\n },\n { deep: true },\n );\n\n function expand(until: boolean | string | number = true) {\n Object.entries(nodes.value).forEach(([key, node]) => {\n if (until === true || Number(until) >= node.level) {\n updateExpanded(key, true);\n }\n });\n emitExpanded();\n return expandedSet.value;\n }\n\n function stateWatcher(\n value: any[],\n stateSet: Ref<Set<CandidateKey>>,\n updater: (key: CandidateKey, to: boolean) => void,\n emitter: () => void,\n ) {\n const valuesOfKey = props.returnItem\n ? value.map((v) => getObjectValueByPath(v, props.itemKey))\n : value;\n const old = [...stateSet.value];\n if (deepEqual(old, valuesOfKey)) {\n return;\n }\n old.forEach((key) => updater(key, false));\n valuesOfKey.forEach((key) => updater(key, true));\n emitter();\n }\n\n watch(expanded, (neo) => {\n stateWatcher(neo, expandedSet, updateExpanded, emitExpanded);\n });\n\n watch(active, (neo) => {\n stateWatcher(neo, activeSet, updateActive, emitActive);\n });\n\n watch(selected, (neo) => {\n stateWatcher(neo, selectedSet, updateSelected, emitSelected);\n });\n\n watch(\n () => props.items,\n (neo: any[]) => {\n const oldKeys = Object.keys(nodes.value).map((nodeKey) =>\n getObjectValueByPath(nodes.value[nodeKey].item, props.itemKey),\n );\n const neoKeys = getKeys(\n neo,\n props.itemKey,\n props.itemChildren as string,\n );\n const diff = differenceBetween(oldKeys, neoKeys);\n if (diff.length < 1 && neoKeys.length < oldKeys.length) {\n return;\n }\n diff.forEach((k) => delete nodes.value[k]);\n\n // init\n const oldSelected = [...selectedSet.value];\n const oldActive = [...activeSet.value];\n selectedSet.value.clear();\n expandedSet.value.clear();\n activeSet.value.clear();\n updateNodes(neo);\n if (!deepEqual(oldSelected, [...selectedSet.value])) {\n emitSelected();\n }\n if (!deepEqual(oldActive, [...activeSet.value])) {\n emitActive();\n }\n filterItemsFn.value(neo, props.search, props.filter);\n },\n { deep: true, flush: 'sync' },\n );\n\n // Provide & Issue\n\n updateNodes(props.items);\n\n const renderLeaves = computed(() => {\n return props.items.slice().filter((leaf) => {\n return !isExcluded(getObjectValueByPath(leaf, props.itemKey));\n });\n });\n\n const classes = computed(() => {\n return {\n 'y-tree-view': true,\n };\n });\n\n const styles = computed(() => {\n let color = props.activeColor;\n if (props.activeColor && !isColorValue(props.activeColor)) {\n color = `var(--y-theme-${props.activeColor})`;\n }\n return {\n [`--y-tree-view__active-color`]: color,\n };\n });\n\n onMounted(() => {\n if (props.search) {\n searchLoading.value = true;\n excludeItem(props.items, props.search, props.filter);\n }\n\n if (props.defaultExpand != null && props.defaultExpand !== false) {\n expandedCache.value = [...expand(props.defaultExpand)];\n } else {\n expanded.value.forEach((v: any) => updateExpanded(getNodeKey(v), true));\n emitExpanded();\n }\n\n for (const activeValue of props.active.map(getNodeKey)) {\n updateActive(activeValue, true);\n }\n\n for (const selectedValue of props.selected.map(getNodeKey)) {\n updateSelected(selectedValue, true);\n }\n });\n\n expose({\n expand,\n });\n\n useRender(() => {\n return (\n <>\n <div class={classes.value} style={styles.value} role=\"tree\">\n {searchLoading.value && <YProgressBar indeterminate />}\n {renderLeaves.value.length > 0 ? (\n renderLeaves.value.slice().map((leaf) => {\n return (\n <YTreeViewNode\n v-slots={slots}\n key={getObjectValueByPath(leaf, props.itemKey)}\n {...{\n ...chooseProps(props, treeViewNodeProps),\n item: leaf,\n level: 0,\n }}\n ></YTreeViewNode>\n );\n })\n ) : (\n <div class=\"y-tree-view__no-data\">\n {slots['no-data'] ? slots['no-data']() : <span>No Data</span>}\n </div>\n )}\n </div>\n </>\n );\n });\n\n return {\n nodes,\n expandedSet,\n selectedSet,\n activeSet,\n excludedSet,\n searchLoading,\n expandedCache,\n renderLeaves,\n };\n },\n});\n\nexport type YTreeView = InstanceType<typeof YTreeView>;\n"],"mappings":";AAAA,SAGEA,QAAQ,EACRC,eAAe,EACfC,SAAS,EACTC,GAAG,EACHC,UAAU,EACVC,KAAK,QACA,KAAK;AAAC,SAEJC,eAAe;AAAA,SACfC,SAAS;AAAA,SAETC,iBAAiB;AAAA,SACjBC,YAAY;AAAA,SACZC,SAAS,EAAEC,oBAAoB,EAAEC,cAAc;AAAA,SAC/CC,WAAW;AAAA,SACXC,QAAQ;AAAA,SAERC,YAAY;AAAA,SACZC,aAAa,EAAEC,uBAAuB;AAAA,SAEtCC,cAAc,EAAEC,eAAe,EAAEC,OAAO;AAEjD;AAEA,MAAMC,iBAAiB,GAAGJ,uBAAuB,CAAC,CAAC;AAEnD,OAAO,MAAMK,SAAS,GAAGrB,eAAe,CAAC;EACvCsB,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE;IACLC,QAAQ,EAAE;MACRC,IAAI,EAAE,CAACC,KAAK,CAA6B;M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AAlH,YAAA;QAAA;MAAA,QAAkC,EACrDyG,YAAY,CAAC/C,KAAK,CAACJ,MAAM,GAAG,CAAC,GAC5BmD,YAAY,CAAC/C,KAAK,CAACgD,KAAK,CAAC,CAAC,CAAC1B,GAAG,CAAE2B,IAAI,IAAK;QACvC,OAAAO,YAAA,CAAAjH,aAAA,EAAAmH,WAAA;UAAA,OAGSxH,oBAAoB,CAAC+G,IAAI,EAAElG,KAAK,CAACsD,OAAO;QAAC;UAE5C,GAAGjE,WAAW,CAACW,KAAK,EAAEH,iBAAiB,CAAC;UACxCwD,IAAI,EAAE6C,IAAI;UACVpC,KAAK,EAAE;QAAC,IALDxC,KAAK;MASpB,CAAC,CAAC,GAAAmF,YAAA;QAAA;MAAA,IAGCnF,KAAK,CAAC,SAAS,CAAC,GAAGA,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAAmF,YAAA,gBAAAG,gBAAA,aAAuB,EAEhE;IAIT,CAAC,CAAC;IAEF,OAAO;MACLhF,KAAK;MACLC,WAAW;MACXC,WAAW;MACXC,SAAS;MACTE,WAAW;MACXD,aAAa;MACbL,aAAa;MACbqE;IACF,CAAC;EACH;AACF,CAAC,CAAC"}
|
|
@@ -86,14 +86,29 @@ export function provideTreeView(props) {
|
|
|
86
86
|
if (props.activeSingleModifier && event?.getModifierState(props.activeSingleModifier)) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
if (props.multipleActive && props.activeStrategy === 'cascade') {
|
|
89
|
+
if (props.multipleActive && (!props.onlyEventActiveStrategy || props.onlyEventActiveStrategy && event) && (props.activeStrategy === 'cascade' || props.activeStrategy === 'relative')) {
|
|
90
90
|
for (const descendant of getDescendants(key)) {
|
|
91
91
|
if (descendant in nodes.value) {
|
|
92
|
-
|
|
93
|
-
nodes.value[descendant].active = to;
|
|
94
|
-
issueVnodeState(descendant);
|
|
92
|
+
setActive(descendant, to);
|
|
95
93
|
}
|
|
96
94
|
}
|
|
95
|
+
if (props.activeStrategy === 'relative') {
|
|
96
|
+
let grand = node.parentKey;
|
|
97
|
+
do {
|
|
98
|
+
const parentKey = grand;
|
|
99
|
+
grand = null;
|
|
100
|
+
if (!parentKey) continue;
|
|
101
|
+
const parent = nodes.value[parentKey];
|
|
102
|
+
if (!parent) continue;
|
|
103
|
+
const all = isChildrenAll(parentKey, 'active', to);
|
|
104
|
+
if (all || !to) {
|
|
105
|
+
setActive(parentKey, to);
|
|
106
|
+
if (parent.parentKey) {
|
|
107
|
+
grand = parent.parentKey;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} while (grand != null);
|
|
111
|
+
}
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
114
|
function updateSelected(key, to) {
|
|
@@ -118,6 +133,21 @@ export function provideTreeView(props) {
|
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
}
|
|
136
|
+
function isChildrenAll(key, stateKey, to) {
|
|
137
|
+
const node = nodes.value[key];
|
|
138
|
+
if (!node) return false;
|
|
139
|
+
const {
|
|
140
|
+
childKeys
|
|
141
|
+
} = node;
|
|
142
|
+
return childKeys.every(childKey => {
|
|
143
|
+
return nodes.value[childKey]?.[stateKey] === to;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function setActive(key, to) {
|
|
147
|
+
to ? activeSet.value.add(key) : activeSet.value.delete(key);
|
|
148
|
+
nodes.value[key].active = to;
|
|
149
|
+
issueVnodeState(key);
|
|
150
|
+
}
|
|
121
151
|
|
|
122
152
|
// Emit
|
|
123
153
|
function emitExpanded() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-view.js","names":["inject","provide","ref","shallowRef","useModelDuplex","getObjectValueByPath","Y_TREE_VIEW","Symbol","for","provideTreeView","props","nodes","expanded","active","selected","expandedSet","Set","selectedSet","activeSet","searchLoading","excludedSet","getDescendants","key","descendants","childKeys","value","push","remains","slice","length","childKey","splice","item","isExcluded","search","has","issueVnodeState","node","vnode","indeterminate","updateExpanded","to","children","itemChildren","Array","isArray","add","delete","updateActive","event","inactiveKey","multipleActive","requiredActive","size","activeSingleModifier","getModifierState","activeStrategy","descendant","updateSelected","selectStrategy","emitExpanded","arr","returnItem","map","emitActive","emitSelected","register","useTreeView","instance","Error"],"sources":["../../../src/components/tree-view/tree-view.ts"],"sourcesContent":["import {\n InjectionKey,\n Ref,\n inject,\n provide,\n ref,\n shallowRef,\n} from 'vue';\n\nimport { useModelDuplex } from '@/composables';\nimport { CandidateKey } from '@/types';\nimport { getObjectValueByPath } from '@/util';\n\nexport const Y_TREE_VIEW: InjectionKey<{\n register: (key: CandidateKey, vnode: any) => void;\n updateExpanded: (key: CandidateKey, to: boolean) => void;\n updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;\n updateSelected: (key: CandidateKey, to: boolean) => void;\n searchLoading: Ref<boolean>;\n isExcluded: (key: CandidateKey) => boolean;\n emitExpanded: () => void;\n emitActive: () => void;\n emitSelected: () => void;\n}> = Symbol.for('YTreeView');\n\n// TODO: props type\nexport function provideTreeView(props: any) {\n const nodes = ref<Record<CandidateKey, any>>({});\n const expanded = useModelDuplex(props, 'expanded');\n const active = useModelDuplex(props, 'active');\n const selected = useModelDuplex(props, 'selected');\n\n const expandedSet = ref(new Set<CandidateKey>());\n const selectedSet = ref(new Set<CandidateKey>());\n const activeSet = ref(new Set<CandidateKey>());\n const searchLoading = shallowRef(false);\n const excludedSet = ref(new Set<CandidateKey>());\n\n // Utils\n function getDescendants(key: CandidateKey) {\n const descendants: CandidateKey[] = [];\n const { childKeys } = nodes.value[key];\n descendants.push(...childKeys);\n const remains: CandidateKey[] = childKeys.slice();\n\n while (remains.length > 0) {\n const childKey: CandidateKey = remains.splice(0, 1)[0];\n const item = nodes.value[childKey];\n if (item) {\n descendants.push(...item.childKeys);\n remains.push(...item.childKeys);\n }\n }\n\n return descendants;\n }\n\n // Search\n function isExcluded(key: CandidateKey) {\n return !!props.search && excludedSet.value.has(key);\n }\n\n //\n function issueVnodeState(key: CandidateKey) {\n const node = nodes.value[key];\n if (node?.vnode) {\n node.vnode.active = node.active;\n node.vnode.selected = node.selected;\n node.vnode.indeterminate = node.indeterminate;\n node.vnode.expanded = node.expanded;\n }\n }\n\n // Update\n function updateExpanded(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n const children = getObjectValueByPath(\n node.item,\n props.itemChildren as string,\n );\n if (Array.isArray(children) && children.length > 0) {\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\n node.expanded = to;\n issueVnodeState(key);\n }\n }\n\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n let inactiveKey = !to ? key : '';\n if (!props.multipleActive && to && !activeSet.value.has(key)) {\n [inactiveKey] = [...activeSet.value];\n }\n if (to) {\n activeSet.value.add(key);\n node.active = true;\n issueVnodeState(key);\n } else {\n if (\n props.requiredActive &&\n activeSet.value.size === 1 &&\n key === inactiveKey\n ) {\n issueVnodeState(key);\n return;\n }\n }\n if (inactiveKey && inactiveKey in nodes.value) {\n activeSet.value.delete(inactiveKey);\n nodes.value[inactiveKey].active = false;\n issueVnodeState(inactiveKey);\n }\n\n if (\n props.activeSingleModifier &&\n event?.getModifierState(props.activeSingleModifier)\n ) {\n return;\n }\n\n if (props.multipleActive && props.activeStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? activeSet.value.add(descendant)\n : activeSet.value.delete(descendant);\n nodes.value[descendant].active = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n function updateSelected(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n\n if (to) {\n selectedSet.value.add(key);\n node.selected = true;\n }\n\n if (!to && key in nodes.value) {\n selectedSet.value.delete(key);\n nodes.value[key].selected = false;\n issueVnodeState(key);\n }\n\n if (props.selectStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? selectedSet.value.add(descendant)\n : selectedSet.value.delete(descendant);\n nodes.value[descendant].selected = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n // Emit\n function emitExpanded() {\n const arr = [...expandedSet.value];\n expanded.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitActive() {\n const arr = [...activeSet.value];\n active.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitSelected() {\n const arr = [...selectedSet.value];\n selected.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n // Inject\n function register(key: CandidateKey, vnode: any) {\n if (nodes.value[key]) {\n nodes.value[key].vnode = vnode;\n }\n\n issueVnodeState(key);\n }\n\n provide(Y_TREE_VIEW, {\n register,\n updateExpanded,\n updateActive,\n updateSelected,\n searchLoading,\n isExcluded,\n emitExpanded,\n emitActive,\n emitSelected,\n });\n\n return {\n nodes,\n expanded,\n active,\n selected,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n isExcluded,\n };\n}\n\nexport function useTreeView() {\n const instance = inject(Y_TREE_VIEW);\n if (!instance) throw new Error('Not found provided YTreeView');\n return instance;\n}\n"],"mappings":"AAAA,SAGEA,MAAM,EACNC,OAAO,EACPC,GAAG,EACHC,UAAU,QACL,KAAK;AAAC,SAEJC,cAAc;AAAA,SAEdC,oBAAoB;AAE7B,OAAO,MAAMC,WAUX,GAAGC,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;;AAE5B;AACA,OAAO,SAASC,eAAeA,CAACC,KAAU,EAAE;EAC1C,MAAMC,KAAK,GAAGT,GAAG,CAA4B,CAAC,CAAC,CAAC;EAChD,MAAMU,QAAQ,GAAGR,cAAc,CAACM,KAAK,EAAE,UAAU,CAAC;EAClD,MAAMG,MAAM,GAAGT,cAAc,CAACM,KAAK,EAAE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U,cAAc;IACdE,YAAY;IACZI,UAAU;IACVC,YAAY;IACZlD,WAAW;IACXE,WAAW;IACXC,SAAS;IACTC,aAAa;IACbC,WAAW;IACXa;EACF,CAAC;AACH;AAEA,OAAO,SAASkC,WAAWA,CAAA,EAAG;EAC5B,MAAMC,QAAQ,GAAGpE,MAAM,CAACM,WAAW,CAAC;EACpC,IAAI,CAAC8D,QAAQ,EAAE,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EAC9D,OAAOD,QAAQ;AACjB"}
|
|
1
|
+
{"version":3,"file":"tree-view.js","names":["inject","provide","ref","shallowRef","useModelDuplex","getObjectValueByPath","Y_TREE_VIEW","Symbol","for","provideTreeView","props","nodes","expanded","active","selected","expandedSet","Set","selectedSet","activeSet","searchLoading","excludedSet","getDescendants","key","descendants","childKeys","value","push","remains","slice","length","childKey","splice","item","isExcluded","search","has","issueVnodeState","node","vnode","indeterminate","updateExpanded","to","children","itemChildren","Array","isArray","add","delete","updateActive","event","inactiveKey","multipleActive","requiredActive","size","activeSingleModifier","getModifierState","onlyEventActiveStrategy","activeStrategy","descendant","setActive","grand","parentKey","parent","all","isChildrenAll","updateSelected","selectStrategy","stateKey","every","emitExpanded","arr","returnItem","map","emitActive","emitSelected","register","useTreeView","instance","Error"],"sources":["../../../src/components/tree-view/tree-view.ts"],"sourcesContent":["import { InjectionKey, Ref, inject, provide, ref, shallowRef } from 'vue';\n\n\n\nimport { NodeState } from '@/components/tree-view/types';\nimport { useModelDuplex } from '@/composables';\nimport { CandidateKey } from '@/types';\nimport { getObjectValueByPath } from '@/util';\n\n\nexport const Y_TREE_VIEW: InjectionKey<{\n register: (key: CandidateKey, vnode: any) => void;\n updateExpanded: (key: CandidateKey, to: boolean) => void;\n updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;\n updateSelected: (key: CandidateKey, to: boolean) => void;\n searchLoading: Ref<boolean>;\n isExcluded: (key: CandidateKey) => boolean;\n emitExpanded: () => void;\n emitActive: () => void;\n emitSelected: () => void;\n}> = Symbol.for('YTreeView');\n\n// TODO: props type\nexport function provideTreeView(props: any) {\n const nodes = ref<Record<CandidateKey, NodeState>>({});\n const expanded = useModelDuplex(props, 'expanded');\n const active = useModelDuplex(props, 'active');\n const selected = useModelDuplex(props, 'selected');\n\n const expandedSet = ref(new Set<CandidateKey>());\n const selectedSet = ref(new Set<CandidateKey>());\n const activeSet = ref(new Set<CandidateKey>());\n const searchLoading = shallowRef(false);\n const excludedSet = ref(new Set<CandidateKey>());\n\n // Utils\n function getDescendants(key: CandidateKey) {\n const descendants: CandidateKey[] = [];\n const { childKeys } = nodes.value[key];\n descendants.push(...childKeys);\n const remains: CandidateKey[] = childKeys.slice();\n\n while (remains.length > 0) {\n const childKey: CandidateKey = remains.splice(0, 1)[0];\n const item = nodes.value[childKey];\n if (item) {\n descendants.push(...item.childKeys);\n remains.push(...item.childKeys);\n }\n }\n\n return descendants;\n }\n\n // Search\n function isExcluded(key: CandidateKey) {\n return !!props.search && excludedSet.value.has(key);\n }\n\n //\n function issueVnodeState(key: CandidateKey) {\n const node = nodes.value[key];\n if (node?.vnode) {\n node.vnode.active = node.active;\n node.vnode.selected = node.selected;\n node.vnode.indeterminate = node.indeterminate;\n node.vnode.expanded = node.expanded;\n }\n }\n\n // Update\n function updateExpanded(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n const children = getObjectValueByPath(\n node.item,\n props.itemChildren as string,\n );\n if (Array.isArray(children) && children.length > 0) {\n to ? expandedSet.value.add(key) : expandedSet.value.delete(key);\n node.expanded = to;\n issueVnodeState(key);\n }\n }\n\n function updateActive(key: CandidateKey, to: boolean, event?: MouseEvent) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n let inactiveKey = !to ? key : '';\n if (!props.multipleActive && to && !activeSet.value.has(key)) {\n [inactiveKey] = [...activeSet.value];\n }\n if (to) {\n activeSet.value.add(key);\n node.active = true;\n issueVnodeState(key);\n } else {\n if (\n props.requiredActive &&\n activeSet.value.size === 1 &&\n key === inactiveKey\n ) {\n issueVnodeState(key);\n return;\n }\n }\n if (inactiveKey && inactiveKey in nodes.value) {\n activeSet.value.delete(inactiveKey);\n nodes.value[inactiveKey].active = false;\n issueVnodeState(inactiveKey);\n }\n\n if (\n props.activeSingleModifier &&\n event?.getModifierState(props.activeSingleModifier)\n ) {\n return;\n }\n\n if (\n props.multipleActive &&\n (!props.onlyEventActiveStrategy ||\n (props.onlyEventActiveStrategy && event)) &&\n (props.activeStrategy === 'cascade' ||\n props.activeStrategy === 'relative')\n ) {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n setActive(descendant, to);\n }\n }\n if (props.activeStrategy === 'relative') {\n let grand: CandidateKey | null = node.parentKey;\n do {\n const parentKey = grand;\n grand = null;\n if (!parentKey) continue;\n const parent = nodes.value[parentKey];\n if (!parent) continue;\n const all = isChildrenAll(parentKey, 'active', to);\n if (all || !to) {\n setActive(parentKey, to);\n if (parent.parentKey) {\n grand = parent.parentKey;\n }\n }\n } while (grand != null);\n }\n }\n }\n\n function updateSelected(key: CandidateKey, to: boolean) {\n if (!(key in nodes.value)) return;\n const node = nodes.value[key];\n\n if (to) {\n selectedSet.value.add(key);\n node.selected = true;\n }\n\n if (!to && key in nodes.value) {\n selectedSet.value.delete(key);\n nodes.value[key].selected = false;\n issueVnodeState(key);\n }\n\n if (props.selectStrategy === 'cascade') {\n for (const descendant of getDescendants(key)) {\n if (descendant in nodes.value) {\n to\n ? selectedSet.value.add(descendant)\n : selectedSet.value.delete(descendant);\n nodes.value[descendant].selected = to;\n issueVnodeState(descendant);\n }\n }\n }\n }\n\n function isChildrenAll(key: CandidateKey, stateKey: string, to: boolean) {\n const node = nodes.value[key];\n if (!node) return false;\n const { childKeys } = node;\n return childKeys.every((childKey) => {\n return (nodes.value[childKey] as any)?.[stateKey] === to;\n });\n }\n\n function setActive(key: CandidateKey, to: boolean) {\n to ? activeSet.value.add(key) : activeSet.value.delete(key);\n nodes.value[key].active = to;\n issueVnodeState(key);\n }\n\n // Emit\n function emitExpanded() {\n const arr = [...expandedSet.value];\n expanded.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitActive() {\n const arr = [...activeSet.value];\n active.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n function emitSelected() {\n const arr = [...selectedSet.value];\n selected.value = props.returnItem\n ? arr.map((key) => nodes.value[key].item)\n : arr;\n }\n\n // Inject\n function register(key: CandidateKey, vnode: any) {\n if (nodes.value[key]) {\n nodes.value[key].vnode = vnode;\n }\n\n issueVnodeState(key);\n }\n\n provide(Y_TREE_VIEW, {\n register,\n updateExpanded,\n updateActive,\n updateSelected,\n searchLoading,\n isExcluded,\n emitExpanded,\n emitActive,\n emitSelected,\n });\n\n return {\n nodes,\n expanded,\n active,\n selected,\n issueVnodeState,\n updateExpanded,\n updateActive,\n updateSelected,\n emitExpanded,\n emitActive,\n emitSelected,\n expandedSet,\n selectedSet,\n activeSet,\n searchLoading,\n excludedSet,\n isExcluded,\n };\n}\n\nexport function useTreeView() {\n const instance = inject(Y_TREE_VIEW);\n if (!instance) throw new Error('Not found provided YTreeView');\n return instance;\n}\n"],"mappings":"AAAA,SAA4BA,MAAM,EAAEC,OAAO,EAAEC,GAAG,EAAEC,UAAU,QAAQ,KAAK;AAAC,SAKjEC,cAAc;AAAA,SAEdC,oBAAoB;AAG7B,OAAO,MAAMC,WAUX,GAAGC,MAAM,CAACC,GAAG,CAAC,WAAW,CAAC;;AAE5B;AACA,OAAO,SAASC,eAAeA,CAACC,KAAU,EAAE;EAC1C,MAAMC,KAAK,GAAGT,GAAG,CAAkC,CAAC,CAAC,CAAC;EACtD,MAAMU,QAAQ,GAAGR,cAAc,CAACM,KAAK,EAAE,UAAU,CAAC;EAClD,MAAMG,MAAM,GAAGT,cAAc,CAACM,KAAK,EAAE,QAAQ,CAAC;EAC9C,MAAMI,QAAQ,GAAGV,cAAc,CAACM,KAAK,EAA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WAAW;IACXC,SAAS;IACTC,aAAa;IACbC,WAAW;IACXa;EACF,CAAC;AACH;AAEA,OAAO,SAAS2C,WAAWA,CAAA,EAAG;EAC5B,MAAMC,QAAQ,GAAG7E,MAAM,CAACM,WAAW,CAAC;EACpC,IAAI,CAACuE,QAAQ,EAAE,MAAM,IAAIC,KAAK,CAAC,8BAA8B,CAAC;EAC9D,OAAOD,QAAQ;AACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/tree-view/types.ts"],"sourcesContent":["import { type ComponentPublicInstance } from 'vue';\
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/components/tree-view/types.ts"],"sourcesContent":["import { type ComponentPublicInstance } from 'vue';\n\nimport type { CandidateKey } from '@/types';\n\nexport interface ItemState {\n selected: boolean;\n indeterminate: boolean;\n active: boolean;\n expanded: boolean;\n}\n\nexport interface NodeState extends ItemState {\n childKeys: CandidateKey[];\n item: any;\n parentKey: null | CandidateKey;\n vnode:\n | null\n | (ComponentPublicInstance & ItemState);\n level: number;\n}\n\nexport type TreeviewFilterFn = (\n item: any,\n search: string,\n itemText: string,\n) => boolean;\n"],"mappings":""}
|
|
@@ -3,6 +3,7 @@ export const ThemeScheme = {
|
|
|
3
3
|
light: 'light',
|
|
4
4
|
dark: 'dark'
|
|
5
5
|
};
|
|
6
|
+
export const schemes = ['light', 'dark', 'auto'];
|
|
6
7
|
export const defaultTonalLuminance = [0, 10, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 95, 98, 99, 100];
|
|
7
8
|
export const defaultPalette = {
|
|
8
9
|
scaleMethod: 'tonal',
|
|
@@ -98,8 +99,8 @@ export function configureOptions(options) {
|
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
return {
|
|
101
|
-
scheme: ThemeScheme.light,
|
|
102
|
-
theme: ['light', 'dark'],
|
|
102
|
+
scheme: schemes.includes(options.scheme) ? options.scheme : ThemeScheme.light,
|
|
103
|
+
theme: options.theme ?? ['light', 'dark'],
|
|
103
104
|
themes: {
|
|
104
105
|
...mergeDeep(defaultThemesValues, options.themes)
|
|
105
106
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting.js","names":["mergeDeep","ThemeScheme","light","dark","defaultTonalLuminance","defaultPalette","scaleMethod","colors","primary","secondary","tertiary","neutral","positive","negative","warning","info","defaultThemesValues","isDark","background","surface","outline","error","success","shadow","highlighter","variables","configureOptions","options","scheme","theme","themes","palette","separation"],"sources":["../../../src/composables/theme/setting.ts"],"sourcesContent":["import { mergeDeep } from '@/util/common';\
|
|
1
|
+
{"version":3,"file":"setting.js","names":["mergeDeep","ThemeScheme","light","dark","schemes","defaultTonalLuminance","defaultPalette","scaleMethod","colors","primary","secondary","tertiary","neutral","positive","negative","warning","info","defaultThemesValues","isDark","background","surface","outline","error","success","shadow","highlighter","variables","configureOptions","options","scheme","theme","themes","palette","includes","separation"],"sources":["../../../src/composables/theme/setting.ts"],"sourcesContent":["import { mergeDeep } from '@/util/common';\n\nimport type { PaletteOption, ThemeOptions } from './types';\n\nexport const ThemeScheme = {\n light: 'light',\n dark: 'dark',\n} as const;\n\nexport const schemes = ['light', 'dark', 'auto'] as const;\n\nexport const defaultTonalLuminance = [\n 0, 10, 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 95, 98, 99, 100,\n];\n\nexport const defaultPalette: PaletteOption = {\n scaleMethod: 'tonal',\n colors: {\n primary: '#0062a1',\n secondary: '#6251a6',\n tertiary: '#3c691b',\n neutral: '#5d5e61',\n positive: '#009d61',\n negative: '#ba1a1a',\n warning: '#f69400',\n info: '#0d62e6',\n },\n};\n\nexport const defaultThemesValues: any = {\n light: {\n isDark: false,\n colors: {\n primary: '#0062a1',\n secondary: '#6251a6',\n tertiary: '#3c691b',\n background: '#fdfbff',\n 'on-background': '#1a1c1e',\n surface: '#fdfbff',\n 'on-surface': '#1a1c1e',\n 'surface-variant': '#dfe3eb',\n 'on-surface-variant': '#42474e',\n outline: '#73777f',\n 'outline-variant': '#c2c7cf',\n error: '#ba1a1a',\n 'on-error': '#ffffff',\n warning: '#8a5100',\n 'on-warning': '#ffffff',\n info: '#0056d0',\n 'on-info': '#ffffff',\n success: '#006d42',\n 'on-success': '#ffffff',\n shadow: '#000000',\n highlighter: '#ffff00',\n },\n variables: {\n 'outline-opacity': 0.14,\n 'base-shadow-opacity': 0.14,\n 'base-font': '#141414',\n },\n },\n dark: {\n isDark: true,\n colors: {\n primary: '#9ccaff',\n 'on-primary': '#003257',\n secondary: '#cbbeff',\n 'on-secondary': '#332074',\n tertiary: '#a1d57a',\n 'on-tertiary': '#173800',\n background: '#1a1c1e',\n 'on-background': '#e2e2e6',\n surface: '#1a1c1e',\n 'on-surface': '#e2e2e6',\n 'surface-variant': '#42474e',\n 'on-surface-variant': '#c2c7cf',\n outline: '#8c9199',\n 'outline-variant': '#42474e',\n error: '#ffb4ab',\n 'on-error': '#690005',\n warning: '#ffb86e',\n 'on-warning': '#492900',\n info: '#b1c5ff',\n 'on-info': '#002c72',\n success: '#61dd9a',\n 'on-success': '#003920',\n shadow: '#000000',\n highlighter: '#51510d',\n },\n variables: {\n 'outline-opacity': 0.14,\n 'base-shadow-opacity': 0.14,\n 'base-font': '#f5f5f5',\n },\n },\n};\n\nexport function configureOptions(options?: ThemeOptions): any {\n if (!options) {\n return {\n scheme: ThemeScheme.light,\n theme: ['light', 'dark'],\n themes: { ...mergeDeep(defaultThemesValues) },\n palette: { ...mergeDeep(defaultPalette) },\n };\n }\n return {\n scheme: schemes.includes(options.scheme)\n ? options.scheme\n : ThemeScheme.light,\n theme: options.theme ?? ['light', 'dark'],\n themes: { ...mergeDeep(defaultThemesValues, options.themes) },\n palette: { ...mergeDeep(defaultPalette, options.palette) },\n separation: options?.separation,\n };\n}\n"],"mappings":"SAASA,SAAS;AAIlB,OAAO,MAAMC,WAAW,GAAG;EACzBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE;AACR,C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AM,EAAEzB,OAAO,CAAC6B,QAAQ,CAACL,OAAO,CAACC,MAAM,CAAC,GACpCD,OAAO,CAACC,MAAM,GACd5B,WAAW,CAACC,KAAK;IACrB4B,KAAK,EAAEF,OAAO,CAACE,KAAK,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;IACzCC,MAAM,EAAE;MAAE,GAAG/B,SAAS,CAACiB,mBAAmB,EAAEW,OAAO,CAACG,MAAM;IAAE,CAAC;IAC7DC,OAAO,EAAE;MAAE,GAAGhC,SAAS,CAACM,cAAc,EAAEsB,OAAO,CAACI,OAAO;IAAE,CAAC;IAC1DE,UAAU,EAAEN,OAAO,EAAEM;EACvB,CAAC;AACH"}
|
package/lib/util/color/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* https://github.com/vuetifyjs/vuetify
|
|
13
13
|
* */
|
|
14
14
|
import { HEX_COLOR_REGEX, RGBA_REGEX } from "./const.js";
|
|
15
|
-
import { rgbFromHex } from "
|
|
15
|
+
import { rgbFromHex } from "./conversion.js";
|
|
16
16
|
export function isColorValue(value) {
|
|
17
17
|
return RGBA_REGEX.test(value) || HEX_COLOR_REGEX.test(value);
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["HEX_COLOR_REGEX","RGBA_REGEX","rgbFromHex","isColorValue","value","test","colorRgb","color","startsWith","join","exec","valueArray","trim","split","splice","isTextColorIsLight","r","g","b","luminance"],"sources":["../../../src/util/color/index.ts"],"sourcesContent":["/*\r\n* yuyeon\r\n* Apache-2.0 license (Copyright 2023 yeonyew)\r\n*\r\n* Used Libs\r\n* - material-color-utilities\r\n* Apache-2.0 license (Copyright 2021 Google LLC)\r\n* https://github.com/material-foundation/material-color-utilities\r\n*\r\n* - Vuetify\r\n* MIT license (Copyright (c) 2016-2023 John Jeremy Leider)\r\n* https://github.com/vuetifyjs/vuetify\r\n* */\r\n\r\nimport { HEX_COLOR_REGEX, RGBA_REGEX } from \"./const\";\r\nimport { rgbFromHex } from '
|
|
1
|
+
{"version":3,"file":"index.js","names":["HEX_COLOR_REGEX","RGBA_REGEX","rgbFromHex","isColorValue","value","test","colorRgb","color","startsWith","join","exec","valueArray","trim","split","splice","isTextColorIsLight","r","g","b","luminance"],"sources":["../../../src/util/color/index.ts"],"sourcesContent":["/*\r\n* yuyeon\r\n* Apache-2.0 license (Copyright 2023 yeonyew)\r\n*\r\n* Used Libs\r\n* - material-color-utilities\r\n* Apache-2.0 license (Copyright 2021 Google LLC)\r\n* https://github.com/material-foundation/material-color-utilities\r\n*\r\n* - Vuetify\r\n* MIT license (Copyright (c) 2016-2023 John Jeremy Leider)\r\n* https://github.com/vuetifyjs/vuetify\r\n* */\r\n\r\nimport { HEX_COLOR_REGEX, RGBA_REGEX } from \"./const\";\r\nimport { rgbFromHex } from './conversion';\r\n\r\nexport function isColorValue(value: string): boolean {\r\n return RGBA_REGEX.test(value) || HEX_COLOR_REGEX.test(value);\r\n}\r\n\r\nexport function colorRgb(color: string): string {\r\n if (color?.startsWith('#')) {\r\n return rgbFromHex(color)?.join(',') || '';\r\n }\r\n const RGBA_REGEX = /rgb(a?)\\((?<v>.*)\\)/;\r\n if (RGBA_REGEX.test(color)) {\r\n const value = RGBA_REGEX.exec(color)?.[2] || '';\r\n if (value) {\r\n const valueArray = value.trim().split(',');\r\n valueArray.splice(3, 1);\r\n return valueArray.join(',');\r\n }\r\n }\r\n return '';\r\n}\r\n\r\nexport function isTextColorIsLight(r: number, g: number, b: number): boolean {\r\n const luminance = 1 - (0.299 * r + 0.587 * g + 0.114 * b) / 255;\r\n return luminance < 0.5;\r\n}\r\n\r\nexport * from './const';\r\nexport * from \"./conversion\";\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAZA,SAcSA,eAAe,EAAEC,UAAU;AAAA,SAC3BC,UAAU;AAEnB,OAAO,SAASC,YAAYA,CAACC,KAAa,EAAW;EACnD,OAAOH,UAAU,CAACI,IAAI,CAACD,KAAK,CAAC,IAAIJ,eAAe,CAACK,IAAI,CAACD,KAAK,CAAC;AAC9D;AAEA,OAAO,SAASE,QAAQA,CAACC,KAAa,EAAU;EAC9C,IAAIA,KAAK,EAAEC,UAAU,CAAC,GAAG,CAAC,EAAE;IAC1B,OAAON,UAAU,CAACK,KAAK,CAAC,EAAEE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;EAC3C;EACA,MAAMR,UAAU,GAAG,qBAAqB;EACxC,IAAIA,UAAU,CAACI,IAAI,CAACE,KAAK,CAAC,EAAE;IAC1B,MAAMH,KAAK,GAAGH,UAAU,CAACS,IAAI,CAACH,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC/C,IAAIH,KAAK,EAAE;MACT,MAAMO,UAAU,GAAGP,KAAK,CAACQ,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC;MAC1CF,UAAU,CAACG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;MACvB,OAAOH,UAAU,CAACF,IAAI,CAAC,GAAG,CAAC;IAC7B;EACF;EACA,OAAO,EAAE;AACX;AAEA,OAAO,SAASM,kBAAkBA,CAACC,CAAS,EAAEC,CAAS,EAAEC,CAAS,EAAW;EAC3E,MAAMC,SAAS,GAAG,CAAC,GAAG,CAAC,KAAK,GAAGH,CAAC,GAAG,KAAK,GAAGC,CAAC,GAAG,KAAK,GAAGC,CAAC,IAAI,GAAG;EAC/D,OAAOC,SAAS,GAAG,GAAG;AACxB;AAAC;AAAA"}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export declare const pressItemsPropsOptions: <Defaults extends {
|
|
|
12
12
|
} : Omit<{
|
|
13
13
|
type: PropType<any[]>;
|
|
14
14
|
default: () => never[];
|
|
15
|
-
}, "
|
|
15
|
+
}, "default" | "type"> & {
|
|
16
16
|
type: PropType<unknown extends Defaults["items"] ? any[] : any[] | Defaults["items"]>;
|
|
17
17
|
default: unknown extends Defaults["items"] ? any[] : any[] | Defaults["items"];
|
|
18
18
|
};
|
|
@@ -22,7 +22,7 @@ export declare const pressItemsPropsOptions: <Defaults extends {
|
|
|
22
22
|
} : Omit<{
|
|
23
23
|
type: PropType<string>;
|
|
24
24
|
default: string;
|
|
25
|
-
}, "
|
|
25
|
+
}, "default" | "type"> & {
|
|
26
26
|
type: PropType<unknown extends Defaults["itemKey"] ? string : string | Defaults["itemKey"]>;
|
|
27
27
|
default: unknown extends Defaults["itemKey"] ? string : string | Defaults["itemKey"];
|
|
28
28
|
};
|
|
@@ -32,7 +32,7 @@ export declare const pressItemsPropsOptions: <Defaults extends {
|
|
|
32
32
|
} : Omit<{
|
|
33
33
|
type: PropType<string>;
|
|
34
34
|
default: string;
|
|
35
|
-
}, "
|
|
35
|
+
}, "default" | "type"> & {
|
|
36
36
|
type: PropType<unknown extends Defaults["itemText"] ? string : string | Defaults["itemText"]>;
|
|
37
37
|
default: unknown extends Defaults["itemText"] ? string : string | Defaults["itemText"];
|
|
38
38
|
};
|
|
@@ -42,7 +42,7 @@ export declare const pressItemsPropsOptions: <Defaults extends {
|
|
|
42
42
|
} : Omit<{
|
|
43
43
|
type: PropType<string | boolean>;
|
|
44
44
|
default: string;
|
|
45
|
-
}, "
|
|
45
|
+
}, "default" | "type"> & {
|
|
46
46
|
type: PropType<unknown extends Defaults["itemChildren"] ? string | boolean : NonNullable<string | boolean> | Defaults["itemChildren"]>;
|
|
47
47
|
default: unknown extends Defaults["itemChildren"] ? string | boolean : NonNullable<string | boolean> | Defaults["itemChildren"];
|
|
48
48
|
};
|
|
@@ -31,7 +31,7 @@ export declare const pressYBadgePropsOptions: <Defaults extends {
|
|
|
31
31
|
} : Omit<{
|
|
32
32
|
type: NumberConstructor;
|
|
33
33
|
default: number;
|
|
34
|
-
}, "
|
|
34
|
+
}, "default" | "type"> & {
|
|
35
35
|
type: PropType<unknown extends Defaults["backgroundOpacity"] ? number : number | Defaults["backgroundOpacity"]>;
|
|
36
36
|
default: unknown extends Defaults["backgroundOpacity"] ? number : number | Defaults["backgroundOpacity"];
|
|
37
37
|
};
|
|
@@ -41,7 +41,7 @@ export declare const pressYBadgePropsOptions: <Defaults extends {
|
|
|
41
41
|
} : Omit<{
|
|
42
42
|
type: PropType<string>;
|
|
43
43
|
default: string;
|
|
44
|
-
}, "
|
|
44
|
+
}, "default" | "type"> & {
|
|
45
45
|
type: PropType<unknown extends Defaults["tag"] ? string : string | Defaults["tag"]>;
|
|
46
46
|
default: unknown extends Defaults["tag"] ? string : string | Defaults["tag"];
|
|
47
47
|
};
|
|
@@ -75,7 +75,7 @@ export declare const pressYBadgePropsOptions: <Defaults extends {
|
|
|
75
75
|
} : Omit<{
|
|
76
76
|
type: StringConstructor;
|
|
77
77
|
default: string;
|
|
78
|
-
}, "
|
|
78
|
+
}, "default" | "type"> & {
|
|
79
79
|
type: PropType<unknown extends Defaults["label"] ? string : string | Defaults["label"]>;
|
|
80
80
|
default: unknown extends Defaults["label"] ? string : string | Defaults["label"];
|
|
81
81
|
};
|
|
@@ -93,7 +93,7 @@ export declare const pressYBadgePropsOptions: <Defaults extends {
|
|
|
93
93
|
} : Omit<{
|
|
94
94
|
type: StringConstructor;
|
|
95
95
|
default: string;
|
|
96
|
-
}, "
|
|
96
|
+
}, "default" | "type"> & {
|
|
97
97
|
type: PropType<unknown extends Defaults["transition"] ? string : string | Defaults["transition"]>;
|
|
98
98
|
default: unknown extends Defaults["transition"] ? string : string | Defaults["transition"];
|
|
99
99
|
};
|