funda-ui 4.7.175 → 4.7.181
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/LiveSearch/index.d.ts +1 -0
- package/LiveSearch/index.js +7 -5
- package/README.md +1 -1
- package/Select/index.d.ts +1 -0
- package/Select/index.js +8 -6
- package/Tree/index.css +5 -0
- package/Tree/index.d.ts +15 -3
- package/Tree/index.js +449 -208
- package/lib/cjs/LiveSearch/index.d.ts +1 -0
- package/lib/cjs/LiveSearch/index.js +7 -5
- package/lib/cjs/Select/index.d.ts +1 -0
- package/lib/cjs/Select/index.js +8 -6
- package/lib/cjs/Tree/index.d.ts +15 -3
- package/lib/cjs/Tree/index.js +449 -208
- package/lib/css/Tree/index.css +5 -0
- package/lib/esm/LiveSearch/index.tsx +14 -6
- package/lib/esm/Select/index.tsx +23 -7
- package/lib/esm/Tree/TreeList.tsx +114 -130
- package/lib/esm/Tree/index.scss +10 -12
- package/lib/esm/Tree/index.tsx +253 -68
- package/lib/esm/Tree/init-height.tsx +14 -1
- package/package.json +1 -1
package/lib/css/Tree/index.css
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
.tree-diagram-default .tree-diagram-default-nav .nav-link {
|
|
42
42
|
position: relative;
|
|
43
43
|
display: block;
|
|
44
|
+
cursor: pointer;
|
|
44
45
|
min-width: var(--tree-link-min-width);
|
|
45
46
|
padding: var(--tree-padding-y) var(--tree-padding-x);
|
|
46
47
|
font-size: var(--tree-font-size);
|
|
@@ -51,6 +52,10 @@
|
|
|
51
52
|
padding-left: calc(var(--tree-padding-x) * 2);
|
|
52
53
|
z-index: 1;
|
|
53
54
|
}
|
|
55
|
+
.tree-diagram-default .tree-diagram-default-nav .nav-link.disabled {
|
|
56
|
+
opacity: 0.5;
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
}
|
|
54
59
|
.tree-diagram-default .tree-diagram-default-nav .nav-link > span {
|
|
55
60
|
transition: 0.1s ease-in-out;
|
|
56
61
|
border-radius: 2px;
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
export interface OptionConfig {
|
|
22
21
|
disabled?: boolean;
|
|
23
22
|
label: any;
|
|
@@ -60,6 +59,7 @@ export type LiveSearchProps = {
|
|
|
60
59
|
btnId?: string;
|
|
61
60
|
fetchTrigger?: boolean;
|
|
62
61
|
hideIcon?: boolean;
|
|
62
|
+
renderOption?: (optionData: OptionConfig, index: number) => React.ReactNode;
|
|
63
63
|
/** Set the depth value of the control to control the display of the pop-up layer appear above.
|
|
64
64
|
* Please set it when multiple controls are used at the same time. */
|
|
65
65
|
depth?: number;
|
|
@@ -125,6 +125,7 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
125
125
|
btnId,
|
|
126
126
|
fetchTrigger,
|
|
127
127
|
hideIcon,
|
|
128
|
+
renderOption,
|
|
128
129
|
depth,
|
|
129
130
|
style,
|
|
130
131
|
winWidth,
|
|
@@ -610,7 +611,7 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
610
611
|
setChangedVal(_data.label);
|
|
611
612
|
|
|
612
613
|
} else {
|
|
613
|
-
const _curData = typeof el.
|
|
614
|
+
const _curData = typeof el.currentTarget !== 'undefined' ? el.currentTarget.dataset.itemdata : el.dataset.itemdata;
|
|
614
615
|
if (typeof _curData === 'undefined') return;
|
|
615
616
|
|
|
616
617
|
const _data = JSON.parse(_curData);
|
|
@@ -969,11 +970,18 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
|
|
|
969
970
|
data-itemdata={JSON.stringify(item)}
|
|
970
971
|
data-list-item-label={`${typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel}`}
|
|
971
972
|
role="tab"
|
|
972
|
-
dangerouslySetInnerHTML={{
|
|
973
|
-
__html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
|
|
974
|
-
}}
|
|
975
973
|
onClick={handleSelect}
|
|
976
|
-
|
|
974
|
+
>
|
|
975
|
+
|
|
976
|
+
{typeof renderOption === 'function' ? <>
|
|
977
|
+
{renderOption(item, index)}
|
|
978
|
+
</> : <>
|
|
979
|
+
<span dangerouslySetInnerHTML={{
|
|
980
|
+
__html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
|
|
981
|
+
}}></span>
|
|
982
|
+
</>}
|
|
983
|
+
|
|
984
|
+
</button>
|
|
977
985
|
}) : null}
|
|
978
986
|
|
|
979
987
|
</div>
|
package/lib/esm/Select/index.tsx
CHANGED
|
@@ -52,6 +52,8 @@ import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
|
|
56
|
+
|
|
55
57
|
export type SelectOptionChangeFnType = (arg1: any, arg2: any, arg3: any) => void;
|
|
56
58
|
|
|
57
59
|
|
|
@@ -102,6 +104,7 @@ export type SelectProps = {
|
|
|
102
104
|
optionsExClassName?: string;
|
|
103
105
|
exceededSidePosOffset?: number;
|
|
104
106
|
clearIcon?: boolean;
|
|
107
|
+
renderOption?: (optionData: OptionConfig, index: number) => React.ReactNode;
|
|
105
108
|
multiSelect?: MultiSelectConfig;
|
|
106
109
|
multiSelectEntireAreaTrigger?: boolean;
|
|
107
110
|
multiSelectSelectedItemOnlyStatus?: multiSelectSelectedItemOnlyStatusConfig;
|
|
@@ -166,6 +169,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
166
169
|
optionsExClassName,
|
|
167
170
|
exceededSidePosOffset,
|
|
168
171
|
clearIcon,
|
|
172
|
+
renderOption,
|
|
169
173
|
multiSelect,
|
|
170
174
|
multiSelectEntireAreaTrigger,
|
|
171
175
|
multiSelectSelectedItemOnlyStatus,
|
|
@@ -2832,11 +2836,16 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2832
2836
|
data-itemdata={JSON.stringify(item)}
|
|
2833
2837
|
data-list-item-label={`${typeof item.listItemLabel === 'undefined' ? '' : item.listItemLabel}`}
|
|
2834
2838
|
role="tab"
|
|
2835
|
-
dangerouslySetInnerHTML={{
|
|
2836
|
-
__html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
|
|
2837
|
-
}}
|
|
2838
2839
|
onClick={handleSelect}
|
|
2839
|
-
|
|
2840
|
+
>
|
|
2841
|
+
{typeof renderOption === 'function' ? <>
|
|
2842
|
+
{renderOption(item, index)}
|
|
2843
|
+
</> : <>
|
|
2844
|
+
<span dangerouslySetInnerHTML={{
|
|
2845
|
+
__html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
|
|
2846
|
+
}}></span>
|
|
2847
|
+
</>}
|
|
2848
|
+
</button>
|
|
2840
2849
|
|
|
2841
2850
|
} else {
|
|
2842
2851
|
|
|
@@ -2889,9 +2898,16 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
|
|
|
2889
2898
|
)}>
|
|
2890
2899
|
<svg width="1.2em" height="1.2em" fill="#000000" viewBox="0 0 24 24"><path d="M4 7.2002V16.8002C4 17.9203 4 18.4801 4.21799 18.9079C4.40973 19.2842 4.71547 19.5905 5.0918 19.7822C5.5192 20 6.07899 20 7.19691 20H16.8031C17.921 20 18.48 20 18.9074 19.7822C19.2837 19.5905 19.5905 19.2842 19.7822 18.9079C20 18.4805 20 17.9215 20 16.8036V7.19691C20 6.07899 20 5.5192 19.7822 5.0918C19.5905 4.71547 19.2837 4.40973 18.9074 4.21799C18.4796 4 17.9203 4 16.8002 4H7.2002C6.08009 4 5.51962 4 5.0918 4.21799C4.71547 4.40973 4.40973 4.71547 4.21799 5.0918C4 5.51962 4 6.08009 4 7.2002Z" /></svg>
|
|
2891
2900
|
</var>
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2901
|
+
|
|
2902
|
+
{typeof renderOption === 'function' ? <>
|
|
2903
|
+
{renderOption(item, index)}
|
|
2904
|
+
</> : <>
|
|
2905
|
+
<span dangerouslySetInnerHTML={{
|
|
2906
|
+
__html: typeof item.listItemLabel === 'undefined' ? item.label : item.listItemLabel
|
|
2907
|
+
}}></span>
|
|
2908
|
+
</>}
|
|
2909
|
+
|
|
2910
|
+
|
|
2895
2911
|
</button>
|
|
2896
2912
|
|
|
2897
2913
|
}
|
|
@@ -7,18 +7,14 @@ import {
|
|
|
7
7
|
getNextSiblings,
|
|
8
8
|
getChildren
|
|
9
9
|
} from 'funda-utils/dist/cjs/dom';
|
|
10
|
-
import {
|
|
10
|
+
import { combinedCls } from 'funda-utils/dist/cjs/cls';
|
|
11
|
+
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
import { initUlHeight } from './init-height';
|
|
14
15
|
import { removeItemOnce, activeClass } from './utils/func';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
fetchFuncAsync?: any | undefined;
|
|
18
|
-
fetchFuncMethod?: string | undefined;
|
|
19
|
-
fetchFuncMethodParams?: any[] | undefined;
|
|
20
|
-
fetchCallback?: (data: any) => void;
|
|
21
|
-
}
|
|
17
|
+
import type {ItemConfig, UpdateDataFunction, DataNode} from './index';
|
|
22
18
|
|
|
23
19
|
|
|
24
20
|
/* Recursively nested components to traverse nodes
|
|
@@ -30,20 +26,30 @@ export type TreeListProps = {
|
|
|
30
26
|
first?: boolean;
|
|
31
27
|
disableArrow?: boolean;
|
|
32
28
|
disableCollapse?: boolean;
|
|
29
|
+
renderOption?: (optionData: DataNode, key: React.Key) => React.ReactNode;
|
|
33
30
|
arrow?: React.ReactNode;
|
|
34
31
|
arrowIcons?: React.ReactNode[];
|
|
35
32
|
childClassName?: string;
|
|
36
33
|
orginalData: any[any];
|
|
37
34
|
data: any[any];
|
|
38
|
-
getCheckedPrint
|
|
39
|
-
updateCheckedPrint
|
|
40
|
-
getCheckedData
|
|
41
|
-
updategetCheckedData
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
getCheckedPrint: any[];
|
|
36
|
+
updateCheckedPrint: React.Dispatch<React.SetStateAction<any[]>>;
|
|
37
|
+
getCheckedData: any[];
|
|
38
|
+
updategetCheckedData: React.Dispatch<React.SetStateAction<any[]>>;
|
|
39
|
+
expandedMap: Record<string, boolean>;
|
|
40
|
+
onSelect?: (
|
|
41
|
+
e: React.MouseEvent<HTMLElement>,
|
|
42
|
+
val: ItemConfig,
|
|
43
|
+
updateData: UpdateDataFunction
|
|
44
|
+
) => void;
|
|
45
|
+
onDoubleSelect?: (
|
|
46
|
+
e: React.MouseEvent<HTMLElement>,
|
|
47
|
+
val: ItemConfig,
|
|
48
|
+
updateData: UpdateDataFunction
|
|
49
|
+
) => void;
|
|
50
|
+
onCollapse?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
45
51
|
onCheck?: (val: any) => void;
|
|
46
|
-
evInitValue?:
|
|
52
|
+
evInitValue?: UpdateDataFunction;
|
|
47
53
|
};
|
|
48
54
|
|
|
49
55
|
export default function TreeList(props: TreeListProps) {
|
|
@@ -52,6 +58,7 @@ export default function TreeList(props: TreeListProps) {
|
|
|
52
58
|
rootNode,
|
|
53
59
|
checkboxNamePrefix,
|
|
54
60
|
alternateCollapse,
|
|
61
|
+
renderOption,
|
|
55
62
|
first,
|
|
56
63
|
disableArrow,
|
|
57
64
|
disableCollapse,
|
|
@@ -64,6 +71,7 @@ export default function TreeList(props: TreeListProps) {
|
|
|
64
71
|
updateCheckedPrint,
|
|
65
72
|
getCheckedData,
|
|
66
73
|
updategetCheckedData,
|
|
74
|
+
expandedMap,
|
|
67
75
|
onSelect,
|
|
68
76
|
onDoubleSelect,
|
|
69
77
|
onCollapse,
|
|
@@ -73,6 +81,16 @@ export default function TreeList(props: TreeListProps) {
|
|
|
73
81
|
} = props;
|
|
74
82
|
|
|
75
83
|
const rootRef = useRef<any>(null);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const mergedData = data === null ? [] : data.map((item: ItemConfig) => {
|
|
87
|
+
const itemData = typeof item === 'string' ? JSON.parse(item) : item;
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
...itemData,
|
|
91
|
+
isExpanded: expandedMap?.[itemData.key] ?? false
|
|
92
|
+
};
|
|
93
|
+
});
|
|
76
94
|
|
|
77
95
|
const customIcon: React.ReactNode = <var className="default-icon"><svg width="0.75em" height="0.75em" viewBox="0 0 20 20" fill="none"><path d="M15.795 11.272L7.795 16.272C6.79593 16.8964 5.5 16.1782 5.5 15L5.5 5.00002C5.5 3.82186 6.79593 3.1036 7.795 3.72802L15.795 8.72802C16.735 9.31552 16.735 10.6845 15.795 11.272Z" fill="currentColor"/></svg></var>;
|
|
78
96
|
|
|
@@ -168,122 +186,41 @@ export default function TreeList(props: TreeListProps) {
|
|
|
168
186
|
};
|
|
169
187
|
|
|
170
188
|
|
|
171
|
-
|
|
172
|
-
if ( ul.length === 0 ) return;
|
|
173
|
-
|
|
174
|
-
activeClass(hyperlink, 'remove');
|
|
175
|
-
hyperlink.setAttribute('aria-expanded', 'false');
|
|
176
|
-
activeClass(hyperlink.parentNode, 'remove');
|
|
177
|
-
|
|
178
|
-
//to close
|
|
179
|
-
[].slice.call(ul).forEach(function(element: any){
|
|
180
|
-
element.style.maxHeight = 0;
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const openChild = (hyperlink: HTMLElement, ul: HTMLAllCollection) => {
|
|
185
|
-
if ( ul.length === 0 ) return;
|
|
186
|
-
|
|
187
|
-
activeClass(hyperlink, 'add');
|
|
188
|
-
hyperlink.setAttribute('aria-expanded', 'true');
|
|
189
|
-
activeClass(hyperlink.parentNode, 'add');
|
|
190
|
-
|
|
191
|
-
// init <ul> height
|
|
192
|
-
initUlHeight(ul);
|
|
193
|
-
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
function handleCollapse(e: any) {
|
|
197
|
-
if ( disableCollapse ) return;
|
|
198
|
-
|
|
189
|
+
function handleSelect(e: React.MouseEvent<HTMLDivElement>) {
|
|
199
190
|
e.preventDefault();
|
|
200
191
|
e.stopPropagation();
|
|
201
192
|
|
|
202
193
|
const hyperlink = e.currentTarget;
|
|
203
|
-
const url = hyperlink.getAttribute('href');
|
|
204
|
-
const subElement = getNextSiblings(hyperlink, 'ul');
|
|
205
|
-
|
|
206
|
-
// loading
|
|
207
|
-
//=====================
|
|
208
|
-
if ( hyperlink.classList.contains('async-ready') ) {
|
|
209
|
-
activeClass(hyperlink, 'add', 'loading');
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// calback
|
|
213
|
-
//=====================
|
|
214
|
-
const fetchFunc: Function = hyperlink.classList.contains('async-ready') ? (typeof evInitValue !== 'function' ? ()=>void(0) : evInitValue) : ()=>void(0);
|
|
215
|
-
onCollapse?.(e, {
|
|
216
|
-
key: hyperlink.dataset.key,
|
|
217
|
-
slug: hyperlink.dataset.slug,
|
|
218
|
-
link: hyperlink.dataset.link,
|
|
219
|
-
optiondata: hyperlink.dataset.optiondata
|
|
220
|
-
}, fetchFunc);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// hide child if expandedLink doesn't exist, on the contrary
|
|
225
|
-
//=====================
|
|
226
|
-
if ( hyperlink.classList.contains('loading') ) return;
|
|
227
|
-
|
|
228
|
-
if ( hyperlink.getAttribute('aria-expanded') === 'false' || hyperlink.getAttribute('aria-expanded') === null ) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
//Hide all other siblings of the selected <ul>
|
|
232
|
-
if ( alternateCollapse ) {
|
|
233
|
-
[].slice.call(rootRef.current.children).forEach(function(li: any){
|
|
234
|
-
|
|
235
|
-
activeClass(li, 'remove');
|
|
236
194
|
|
|
237
|
-
const _li = li.firstChild;
|
|
238
|
-
activeClass(_li, 'remove');
|
|
239
|
-
_li.setAttribute('aria-expanded', false);
|
|
240
|
-
|
|
241
|
-
[].slice.call(getNextSiblings(_li, 'ul')).forEach(function(element: any){
|
|
242
|
-
element.style.maxHeight = 0;
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
//open current
|
|
248
|
-
openChild(hyperlink, subElement as never);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
} else {
|
|
253
|
-
|
|
254
|
-
//close current
|
|
255
|
-
closeChild(hyperlink, subElement as never);
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function handleSelect(e: any) {
|
|
263
|
-
e.preventDefault();
|
|
264
|
-
e.stopPropagation();
|
|
265
|
-
|
|
266
|
-
const hyperlink = e.currentTarget;
|
|
267
195
|
|
|
268
196
|
if ( hyperlink.classList.contains('selected') ) {
|
|
269
197
|
activeClass(hyperlink, 'remove', 'selected');
|
|
270
198
|
} else {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
199
|
+
const wrapper = hyperlink.closest('.tree-diagram__wrapper');
|
|
200
|
+
if (wrapper) {
|
|
201
|
+
[].slice.call(wrapper.querySelectorAll('li > div.nav-link')).forEach((node: any) => {
|
|
202
|
+
activeClass(node, 'remove', 'selected');
|
|
203
|
+
});
|
|
204
|
+
}
|
|
274
205
|
activeClass(hyperlink, 'add', 'selected');
|
|
275
206
|
}
|
|
276
207
|
|
|
277
208
|
|
|
209
|
+
|
|
278
210
|
onSelect?.(e, {
|
|
279
|
-
key: hyperlink.dataset.key,
|
|
280
|
-
slug: hyperlink.dataset.slug,
|
|
281
|
-
link: hyperlink.dataset.link,
|
|
282
|
-
optiondata: hyperlink.dataset.optiondata
|
|
283
|
-
},
|
|
211
|
+
key: hyperlink.dataset.key as string,
|
|
212
|
+
slug: hyperlink.dataset.slug as string,
|
|
213
|
+
link: hyperlink.dataset.link as string,
|
|
214
|
+
optiondata: hyperlink.dataset.optiondata as string
|
|
215
|
+
}, async () => {
|
|
216
|
+
if (typeof evInitValue === 'function') {
|
|
217
|
+
await evInitValue(hyperlink.dataset.key as string, null);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
284
220
|
|
|
285
221
|
if ( disableArrow ) {
|
|
286
|
-
|
|
222
|
+
onCollapse?.(e);
|
|
223
|
+
|
|
287
224
|
}
|
|
288
225
|
}
|
|
289
226
|
|
|
@@ -296,7 +233,7 @@ export default function TreeList(props: TreeListProps) {
|
|
|
296
233
|
if ( hyperlink.classList.contains('selected') ) {
|
|
297
234
|
activeClass(hyperlink, 'remove', 'selected');
|
|
298
235
|
} else {
|
|
299
|
-
[].slice.call(hyperlink.closest('.tree-diagram__wrapper').querySelectorAll('li >
|
|
236
|
+
[].slice.call(hyperlink.closest('.tree-diagram__wrapper').querySelectorAll('li > div.nav-link')).forEach((node: any) => {
|
|
300
237
|
activeClass(node, 'remove', 'selected');
|
|
301
238
|
});
|
|
302
239
|
activeClass(hyperlink, 'add', 'selected');
|
|
@@ -308,10 +245,14 @@ export default function TreeList(props: TreeListProps) {
|
|
|
308
245
|
slug: hyperlink.dataset.slug,
|
|
309
246
|
link: hyperlink.dataset.link,
|
|
310
247
|
optiondata: hyperlink.dataset.optiondata
|
|
311
|
-
},
|
|
248
|
+
}, async () => {
|
|
249
|
+
if (typeof evInitValue === 'function') {
|
|
250
|
+
await evInitValue(hyperlink.dataset.key as string, null);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
312
253
|
|
|
313
|
-
if (
|
|
314
|
-
|
|
254
|
+
if (disableArrow) {
|
|
255
|
+
onCollapse?.(e);
|
|
315
256
|
}
|
|
316
257
|
}
|
|
317
258
|
|
|
@@ -411,9 +352,9 @@ export default function TreeList(props: TreeListProps) {
|
|
|
411
352
|
|
|
412
353
|
// Activate current item
|
|
413
354
|
//=====================
|
|
414
|
-
const allItems = rootRef.current ? [].slice.call(document.querySelectorAll(`.${childClassName}
|
|
355
|
+
const allItems = rootRef.current ? [].slice.call(document.querySelectorAll(`.${childClassName} div.nav-link`)).map( (item: any) => {
|
|
415
356
|
return {
|
|
416
|
-
href: item.
|
|
357
|
+
href: item.dataset.href,
|
|
417
358
|
el: item,
|
|
418
359
|
actived: item.parentNode.classList?.contains('active') ? true : false,
|
|
419
360
|
expandedLink: document.body.contains(item.parentNode.parentNode.previousSibling) ? item.parentNode.parentNode.previousSibling : false
|
|
@@ -463,11 +404,12 @@ export default function TreeList(props: TreeListProps) {
|
|
|
463
404
|
}
|
|
464
405
|
)} ref={rootRef} style={!first ? {maxHeight: '0px'} : {}}>
|
|
465
406
|
|
|
466
|
-
{
|
|
407
|
+
{mergedData.map((item: any, i: number) => {
|
|
467
408
|
|
|
468
409
|
const _async = item.childrenAsync ? 'async-ready' : '';
|
|
469
410
|
const _cusIcons = arrowIcons ? 'custom-icons' : '';
|
|
470
411
|
|
|
412
|
+
const optiondata = typeof item.optiondata !== 'undefined' ? item.optiondata : '{}';
|
|
471
413
|
|
|
472
414
|
if ( item.heading ) return (
|
|
473
415
|
<li
|
|
@@ -489,7 +431,19 @@ export default function TreeList(props: TreeListProps) {
|
|
|
489
431
|
data-key={item.key}
|
|
490
432
|
data-optiondata={JSON.stringify(item)}
|
|
491
433
|
>
|
|
492
|
-
<span>
|
|
434
|
+
<span>
|
|
435
|
+
{/* ICON */}
|
|
436
|
+
{item.icon ? item.icon.indexOf('</svg>') < 0 ? <><i className={item.icon}></i> </> : <var dangerouslySetInnerHTML={{ __html: `${item.icon}` }} /> : null}
|
|
437
|
+
|
|
438
|
+
{/* TITLE */}
|
|
439
|
+
{typeof renderOption === 'function' ? <>
|
|
440
|
+
{renderOption(item, item.key)}
|
|
441
|
+
</> : <>
|
|
442
|
+
<i dangerouslySetInnerHTML={{
|
|
443
|
+
__html: `${item.title}`
|
|
444
|
+
}}></i>
|
|
445
|
+
</>}
|
|
446
|
+
</span>
|
|
493
447
|
</a>
|
|
494
448
|
</li>
|
|
495
449
|
);
|
|
@@ -507,7 +461,15 @@ export default function TreeList(props: TreeListProps) {
|
|
|
507
461
|
onMouseLeave={typeof item.itemMouseLeaveCallback !== 'undefined' ? item.itemMouseLeaveCallback : () => void(0)}
|
|
508
462
|
>
|
|
509
463
|
|
|
510
|
-
{(item.children && item.children.length) || item.childrenAsync ? <span
|
|
464
|
+
{(item.children && item.children.length) || item.childrenAsync ? <span
|
|
465
|
+
aria-expanded={JSON.parse(optiondata as string).isExpanded || item.active ? 'true' : 'false'}
|
|
466
|
+
className={item.active ? `arrow active ${_async} ${_cusIcons}` : `arrow ${_async} ${_cusIcons}`}
|
|
467
|
+
onClick={onCollapse}
|
|
468
|
+
data-link={item.link}
|
|
469
|
+
data-slug={item.slug}
|
|
470
|
+
data-key={item.key}
|
|
471
|
+
data-optiondata={JSON.stringify(item)}
|
|
472
|
+
>{arrowGenerator()}</span> : ''}
|
|
511
473
|
|
|
512
474
|
<span className="checkbox-trigger">
|
|
513
475
|
|
|
@@ -539,17 +501,18 @@ export default function TreeList(props: TreeListProps) {
|
|
|
539
501
|
|
|
540
502
|
</span>
|
|
541
503
|
|
|
542
|
-
<
|
|
504
|
+
<div
|
|
543
505
|
tabIndex={-1}
|
|
544
506
|
className={combinedCls(
|
|
545
507
|
'nav-link',
|
|
546
508
|
_async,
|
|
547
509
|
{
|
|
548
510
|
'selected': item.selected,
|
|
549
|
-
'active': item.active
|
|
511
|
+
'active': item.active,
|
|
512
|
+
'disabled': item.disabled
|
|
550
513
|
}
|
|
551
514
|
)}
|
|
552
|
-
href={item.link === '#' ? `${item.link}-${i}` : item.link}
|
|
515
|
+
data-href={item.link === '#' ? `${item.link}-${i}` : item.link}
|
|
553
516
|
aria-expanded="false"
|
|
554
517
|
onClick={handleSelect}
|
|
555
518
|
onDoubleClick={handleDoubleSelect}
|
|
@@ -560,7 +523,23 @@ export default function TreeList(props: TreeListProps) {
|
|
|
560
523
|
onMouseEnter={typeof item.itemLinkMouseEnterCallback !== 'undefined' ? item.itemLinkMouseEnterCallback : () => void(0)}
|
|
561
524
|
onMouseLeave={typeof item.itemLinkMouseLeaveCallback !== 'undefined' ? item.itemLinkMouseLeaveCallback : () => void(0)}
|
|
562
525
|
>
|
|
563
|
-
<span>
|
|
526
|
+
<span>
|
|
527
|
+
|
|
528
|
+
{/* ICON */}
|
|
529
|
+
{item.icon ? item.icon.indexOf('</svg>') < 0 ? <><i className={item.icon}></i> </> : <var dangerouslySetInnerHTML={{ __html: `${item.icon}` }} /> : null}
|
|
530
|
+
|
|
531
|
+
{/* TITLE */}
|
|
532
|
+
{typeof renderOption === 'function' ? <>
|
|
533
|
+
{renderOption(item, item.key)}
|
|
534
|
+
</> : <>
|
|
535
|
+
<i dangerouslySetInnerHTML={{
|
|
536
|
+
__html: `${item.title}`
|
|
537
|
+
}}></i>
|
|
538
|
+
</>}
|
|
539
|
+
|
|
540
|
+
{/* ARROW */}
|
|
541
|
+
{titleArrowGenerator()}
|
|
542
|
+
</span>
|
|
564
543
|
|
|
565
544
|
|
|
566
545
|
{/*<!-- CUSTOM CONTENT -->*/}
|
|
@@ -568,7 +547,7 @@ export default function TreeList(props: TreeListProps) {
|
|
|
568
547
|
{item.customContentToHyperlink}
|
|
569
548
|
{/*<!-- /CUSTOM CONTENT -->*/}
|
|
570
549
|
|
|
571
|
-
</
|
|
550
|
+
</div>
|
|
572
551
|
|
|
573
552
|
|
|
574
553
|
{/*<!-- CUSTOM CONTENT -->*/}
|
|
@@ -578,6 +557,7 @@ export default function TreeList(props: TreeListProps) {
|
|
|
578
557
|
|
|
579
558
|
{item.children && item.children.length > 0 && <TreeList
|
|
580
559
|
rootNode={rootNode}
|
|
560
|
+
renderOption={renderOption}
|
|
581
561
|
checkboxNamePrefix={checkboxNamePrefix}
|
|
582
562
|
orginalData={orginalData}
|
|
583
563
|
data={item.children}
|
|
@@ -585,7 +565,6 @@ export default function TreeList(props: TreeListProps) {
|
|
|
585
565
|
arrow={arrow}
|
|
586
566
|
onSelect={onSelect}
|
|
587
567
|
onDoubleSelect={onDoubleSelect}
|
|
588
|
-
onCollapse={onCollapse}
|
|
589
568
|
onCheck={onCheck}
|
|
590
569
|
disableArrow={disableArrow}
|
|
591
570
|
disableCollapse={disableCollapse}
|
|
@@ -596,6 +575,11 @@ export default function TreeList(props: TreeListProps) {
|
|
|
596
575
|
getCheckedData={getCheckedData}
|
|
597
576
|
updategetCheckedData={updategetCheckedData}
|
|
598
577
|
|
|
578
|
+
// Collapse
|
|
579
|
+
expandedMap={expandedMap}
|
|
580
|
+
onCollapse={onCollapse}
|
|
581
|
+
|
|
582
|
+
|
|
599
583
|
/>}
|
|
600
584
|
</li>
|
|
601
585
|
);
|
package/lib/esm/Tree/index.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
/* ======================================================
|
|
2
4
|
<!-- Tree -->
|
|
3
5
|
/* ====================================================== */
|
|
@@ -42,6 +44,7 @@
|
|
|
42
44
|
.nav-link {
|
|
43
45
|
position: relative;
|
|
44
46
|
display: block;
|
|
47
|
+
cursor: pointer;
|
|
45
48
|
min-width: var(--tree-link-min-width);
|
|
46
49
|
padding: var(--tree-padding-y) var(--tree-padding-x);
|
|
47
50
|
font-size: var(--tree-font-size);
|
|
@@ -52,6 +55,11 @@
|
|
|
52
55
|
padding-left: calc(var(--tree-padding-x)*2);
|
|
53
56
|
z-index: 1;
|
|
54
57
|
|
|
58
|
+
&.disabled {
|
|
59
|
+
opacity: .5;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
> span {
|
|
56
64
|
transition: .1s ease-in-out;
|
|
57
65
|
border-radius: 2px;
|
|
@@ -184,14 +192,7 @@
|
|
|
184
192
|
i {
|
|
185
193
|
font-style: normal;
|
|
186
194
|
}
|
|
187
|
-
|
|
188
|
-
> a {
|
|
189
|
-
|
|
190
|
-
&:hover {
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
+
|
|
195
196
|
|
|
196
197
|
&.active {
|
|
197
198
|
|
|
@@ -212,10 +213,7 @@
|
|
|
212
213
|
}
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
216
|
+
|
|
219
217
|
}
|
|
220
218
|
|
|
221
219
|
> li {
|