yuyeon 0.3.0-rc.5 → 0.3.0-rc.6

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.
@@ -0,0 +1,179 @@
1
+ import { inject, provide, ref, shallowRef } from 'vue';
2
+ import { useModelDuplex } from "../../composables/index.mjs";
3
+ import { getObjectValueByPath } from "../../util/index.mjs";
4
+ export const Y_TREE_VIEW = Symbol.for('YTreeView');
5
+
6
+ // TODO: props type
7
+ export function provideTreeView(props) {
8
+ const nodes = ref({});
9
+ const expanded = useModelDuplex(props, 'expanded');
10
+ const active = useModelDuplex(props, 'active');
11
+ const selected = useModelDuplex(props, 'selected');
12
+ const expandedSet = ref(new Set());
13
+ const selectedSet = ref(new Set());
14
+ const activeSet = ref(new Set());
15
+ const searchLoading = shallowRef(false);
16
+ const excludedSet = ref(new Set());
17
+
18
+ // Utils
19
+ function getDescendants(key) {
20
+ const descendants = [];
21
+ const {
22
+ childKeys
23
+ } = nodes.value[key];
24
+ descendants.push(...childKeys);
25
+ const remains = childKeys.slice();
26
+ while (remains.length > 0) {
27
+ const childKey = remains.splice(0, 1)[0];
28
+ const item = nodes.value[childKey];
29
+ if (item) {
30
+ descendants.push(...item.childKeys);
31
+ remains.push(...item.childKeys);
32
+ }
33
+ }
34
+ return descendants;
35
+ }
36
+
37
+ // Search
38
+ function isExcluded(key) {
39
+ return !!props.search && excludedSet.value.has(key);
40
+ }
41
+
42
+ //
43
+ function issueVnodeState(key) {
44
+ const node = nodes.value[key];
45
+ if (node?.vnode) {
46
+ node.vnode.active = node.active;
47
+ node.vnode.selected = node.selected;
48
+ node.vnode.indeterminate = node.indeterminate;
49
+ node.vnode.expanded = node.expanded;
50
+ }
51
+ }
52
+
53
+ // Update
54
+ function updateExpanded(key, to) {
55
+ if (!(key in nodes.value)) return;
56
+ const node = nodes.value[key];
57
+ const children = getObjectValueByPath(node.item, props.itemChildren);
58
+ if (Array.isArray(children) && children.length > 0) {
59
+ to ? expandedSet.value.add(key) : expandedSet.value.delete(key);
60
+ node.expanded = to;
61
+ issueVnodeState(key);
62
+ }
63
+ }
64
+ function updateActive(key, to, event) {
65
+ if (!(key in nodes.value)) return;
66
+ const node = nodes.value[key];
67
+ let inactiveKey = !to ? key : '';
68
+ if (!props.multipleActive && to && !activeSet.value.has(key)) {
69
+ [inactiveKey] = [...activeSet.value];
70
+ }
71
+ if (to) {
72
+ activeSet.value.add(key);
73
+ node.active = true;
74
+ issueVnodeState(key);
75
+ } else {
76
+ if (props.requiredActive && activeSet.value.size === 1 && key === inactiveKey) {
77
+ issueVnodeState(key);
78
+ return;
79
+ }
80
+ }
81
+ if (inactiveKey && inactiveKey in nodes.value) {
82
+ activeSet.value.delete(inactiveKey);
83
+ nodes.value[inactiveKey].active = false;
84
+ issueVnodeState(inactiveKey);
85
+ }
86
+ if (props.activeSingleModifier && event?.getModifierState(props.activeSingleModifier)) {
87
+ return;
88
+ }
89
+ if (props.multipleActive && props.activeStrategy === 'cascade') {
90
+ for (const descendant of getDescendants(key)) {
91
+ if (descendant in nodes.value) {
92
+ to ? activeSet.value.add(descendant) : activeSet.value.delete(descendant);
93
+ nodes.value[descendant].active = to;
94
+ issueVnodeState(descendant);
95
+ }
96
+ }
97
+ }
98
+ }
99
+ function updateSelected(key, to) {
100
+ if (!(key in nodes.value)) return;
101
+ const node = nodes.value[key];
102
+ if (to) {
103
+ selectedSet.value.add(key);
104
+ node.selected = true;
105
+ }
106
+ if (!to && key in nodes.value) {
107
+ selectedSet.value.delete(key);
108
+ nodes.value[key].selected = false;
109
+ issueVnodeState(key);
110
+ }
111
+ if (props.selectStrategy === 'cascade') {
112
+ for (const descendant of getDescendants(key)) {
113
+ if (descendant in nodes.value) {
114
+ to ? selectedSet.value.add(descendant) : selectedSet.value.delete(descendant);
115
+ nodes.value[descendant].selected = to;
116
+ issueVnodeState(descendant);
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ // Emit
123
+ function emitExpanded() {
124
+ const arr = [...expandedSet.value];
125
+ expanded.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
126
+ }
127
+ function emitActive() {
128
+ const arr = [...activeSet.value];
129
+ active.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
130
+ }
131
+ function emitSelected() {
132
+ const arr = [...selectedSet.value];
133
+ selected.value = props.returnItem ? arr.map(key => nodes.value[key].item) : arr;
134
+ }
135
+
136
+ // Inject
137
+ function register(key, vnode) {
138
+ if (nodes.value[key]) {
139
+ nodes.value[key].vnode = vnode;
140
+ }
141
+ issueVnodeState(key);
142
+ }
143
+ provide(Y_TREE_VIEW, {
144
+ register,
145
+ updateExpanded,
146
+ updateActive,
147
+ updateSelected,
148
+ searchLoading,
149
+ isExcluded,
150
+ emitExpanded,
151
+ emitActive,
152
+ emitSelected
153
+ });
154
+ return {
155
+ nodes,
156
+ expanded,
157
+ active,
158
+ selected,
159
+ issueVnodeState,
160
+ updateExpanded,
161
+ updateActive,
162
+ updateSelected,
163
+ emitExpanded,
164
+ emitActive,
165
+ emitSelected,
166
+ expandedSet,
167
+ selectedSet,
168
+ activeSet,
169
+ searchLoading,
170
+ excludedSet,
171
+ isExcluded
172
+ };
173
+ }
174
+ export function useTreeView() {
175
+ const instance = inject(Y_TREE_VIEW);
176
+ if (!instance) throw new Error('Not found provided YTreeView');
177
+ return instance;
178
+ }
179
+ //# sourceMappingURL=tree-view.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-view.mjs","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,QAAQ,CAAC;EAC9C,MAAMI,QAAQ,GAAGV,cAAc,CAACM,KAAK,EAAE,UAAU,CAAC;EAElD,MAAMK,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;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuyeon",
3
- "version": "0.3.0-rc.5",
3
+ "version": "0.3.0-rc.6",
4
4
  "keywords": [
5
5
  "UI Library",
6
6
  "Vue"
@@ -4,5 +4,8 @@ export declare const YTextEllipsis: import('vue').DefineComponent<{
4
4
  type: StringConstructor;
5
5
  default: string;
6
6
  };
7
+ position: {
8
+ type: StringConstructor;
9
+ };
7
10
  }, void, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string>;
8
11
  export type YTextEllipsis = InstanceType<typeof YTextEllipsis>;
@@ -46,7 +46,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
46
46
  };
47
47
  multipleActive: BooleanConstructor;
48
48
  activeStrategy: {
49
- type: PropType<"independent" | "cascade">;
49
+ type: PropType<"cascade" | "independent">;
50
50
  default: string;
51
51
  };
52
52
  selected: {
@@ -54,7 +54,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
54
54
  default: () => never[];
55
55
  };
56
56
  selectStrategy: {
57
- type: PropType<"independent" | "cascade">;
57
+ type: PropType<"cascade" | "independent">;
58
58
  default: string;
59
59
  };
60
60
  returnItem: BooleanConstructor;
@@ -116,7 +116,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
116
116
  };
117
117
  multipleActive: BooleanConstructor;
118
118
  activeStrategy: {
119
- type: PropType<"independent" | "cascade">;
119
+ type: PropType<"cascade" | "independent">;
120
120
  default: string;
121
121
  };
122
122
  selected: {
@@ -124,7 +124,7 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
124
124
  default: () => never[];
125
125
  };
126
126
  selectStrategy: {
127
- type: PropType<"independent" | "cascade">;
127
+ type: PropType<"cascade" | "independent">;
128
128
  default: string;
129
129
  };
130
130
  returnItem: BooleanConstructor;
@@ -146,15 +146,15 @@ export declare const YTreeView: import('vue').DefineComponent<import('vue').Extr
146
146
  itemKey: string;
147
147
  itemText: string;
148
148
  itemChildren: string | boolean;
149
+ selected: CandidateKey[];
149
150
  disableTransition: boolean;
150
151
  enableActive: boolean;
151
152
  requiredActive: boolean;
152
153
  activeColor: string;
153
154
  enableSelect: boolean;
154
- selected: CandidateKey[];
155
155
  multipleActive: boolean;
156
- activeStrategy: "independent" | "cascade";
157
- selectStrategy: "independent" | "cascade";
156
+ activeStrategy: "cascade" | "independent";
157
+ selectStrategy: "cascade" | "independent";
158
158
  searchDebounceWait: number;
159
159
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
160
160
  export type YTreeView = InstanceType<typeof YTreeView>;
@@ -156,7 +156,17 @@ export declare const YTreeViewNode: import('vue').DefineComponent<{
156
156
  default: number;
157
157
  };
158
158
  }, {
159
- treeView: any;
159
+ treeView: {
160
+ register: (key: import('../../types').CandidateKey, vnode: any) => void;
161
+ updateExpanded: (key: import('../../types').CandidateKey, to: boolean) => void;
162
+ updateActive: (key: import('../../types').CandidateKey, to: boolean, event?: MouseEvent | undefined) => void;
163
+ updateSelected: (key: import('../../types').CandidateKey, to: boolean) => void;
164
+ searchLoading: import('vue').Ref<boolean, boolean>;
165
+ isExcluded: (key: import('../../types').CandidateKey) => boolean;
166
+ emitExpanded: () => void;
167
+ emitActive: () => void;
168
+ emitSelected: () => void;
169
+ };
160
170
  myKey: import('vue').ComputedRef<any>;
161
171
  expanded: import('vue').Ref<boolean, boolean>;
162
172
  active: import('vue').Ref<boolean, boolean>;
@@ -0,0 +1,50 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { CandidateKey } from '../../types';
3
+
4
+ export declare const Y_TREE_VIEW: InjectionKey<{
5
+ register: (key: CandidateKey, vnode: any) => void;
6
+ updateExpanded: (key: CandidateKey, to: boolean) => void;
7
+ updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;
8
+ updateSelected: (key: CandidateKey, to: boolean) => void;
9
+ searchLoading: Ref<boolean>;
10
+ isExcluded: (key: CandidateKey) => boolean;
11
+ emitExpanded: () => void;
12
+ emitActive: () => void;
13
+ emitSelected: () => void;
14
+ }>;
15
+ export declare function provideTreeView(props: any): {
16
+ nodes: Ref<Record<CandidateKey, any>, Record<CandidateKey, any>>;
17
+ expanded: Ref<any, any> & {
18
+ readonly rxValue: any;
19
+ };
20
+ active: Ref<any, any> & {
21
+ readonly rxValue: any;
22
+ };
23
+ selected: Ref<any, any> & {
24
+ readonly rxValue: any;
25
+ };
26
+ issueVnodeState: (key: CandidateKey) => void;
27
+ updateExpanded: (key: CandidateKey, to: boolean) => void;
28
+ updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent) => void;
29
+ updateSelected: (key: CandidateKey, to: boolean) => void;
30
+ emitExpanded: () => void;
31
+ emitActive: () => void;
32
+ emitSelected: () => void;
33
+ expandedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
34
+ selectedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
35
+ activeSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
36
+ searchLoading: import('vue').ShallowRef<boolean, boolean>;
37
+ excludedSet: Ref<Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>, Set<CandidateKey> | (Set<CandidateKey> & Omit<Set<CandidateKey>, keyof Set<any>>)>;
38
+ isExcluded: (key: CandidateKey) => boolean;
39
+ };
40
+ export declare function useTreeView(): {
41
+ register: (key: CandidateKey, vnode: any) => void;
42
+ updateExpanded: (key: CandidateKey, to: boolean) => void;
43
+ updateActive: (key: CandidateKey, to: boolean, event?: MouseEvent | undefined) => void;
44
+ updateSelected: (key: CandidateKey, to: boolean) => void;
45
+ searchLoading: Ref<boolean, boolean>;
46
+ isExcluded: (key: CandidateKey) => boolean;
47
+ emitExpanded: () => void;
48
+ emitActive: () => void;
49
+ emitSelected: () => void;
50
+ };