playbook_ui 12.25.0.pre.alpha.railsmultilevelimprovements758 → 12.25.0.pre.alpha.railsmultilevelimprovements780
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +82 -1
- data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +14 -13
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +3 -2
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +212 -0
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +58 -98
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +347 -98
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb +4 -4
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +594 -26
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +1 -1
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +1 -1
- metadata +3 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx +0 -31
- data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +0 -87
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.25.0.pre.alpha.
|
4
|
+
version: 12.25.0.pre.alpha.railsmultilevelimprovements780
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-06-
|
12
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -1407,9 +1407,9 @@ files:
|
|
1407
1407
|
- app/pb_kits/playbook/pb_message/message.html.erb
|
1408
1408
|
- app/pb_kits/playbook/pb_message/message.rb
|
1409
1409
|
- app/pb_kits/playbook/pb_message/message.test.js
|
1410
|
+
- app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx
|
1410
1411
|
- app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss
|
1411
1412
|
- app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx
|
1412
|
-
- app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx
|
1413
1413
|
- app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb
|
1414
1414
|
- app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.jsx
|
1415
1415
|
- app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md
|
@@ -1419,7 +1419,6 @@ files:
|
|
1419
1419
|
- app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb
|
1420
1420
|
- app/pb_kits/playbook/pb_multi_level_select/docs/example.yml
|
1421
1421
|
- app/pb_kits/playbook/pb_multi_level_select/docs/index.js
|
1422
|
-
- app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts
|
1423
1422
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb
|
1424
1423
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb
|
1425
1424
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import React from "react"
|
2
|
-
import DropdownTreeSelect from "react-dropdown-tree-select"
|
3
|
-
import "react-dropdown-tree-select/dist/styles.css"
|
4
|
-
|
5
|
-
type HelperProps = {
|
6
|
-
id?: string
|
7
|
-
treeData?: { [key: string]: string }[]
|
8
|
-
treeMode?: boolean
|
9
|
-
onChange?: any
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
const MultiSelectHelper = (props: HelperProps) => {
|
14
|
-
const { id, treeData, onChange, treeMode } = props
|
15
|
-
|
16
|
-
|
17
|
-
return (
|
18
|
-
<DropdownTreeSelect
|
19
|
-
data={treeData}
|
20
|
-
id={id}
|
21
|
-
keepOpenOnSelect
|
22
|
-
keepTreeOnSearch
|
23
|
-
keepChildrenOnSearch
|
24
|
-
onChange={onChange}
|
25
|
-
texts={{ placeholder: "Select..." }}
|
26
|
-
mode={treeMode ? 'hierarchical' : 'multiSelect'}
|
27
|
-
/>
|
28
|
-
)
|
29
|
-
}
|
30
|
-
|
31
|
-
export default MultiSelectHelper
|
@@ -1,87 +0,0 @@
|
|
1
|
-
export const findItemById = (
|
2
|
-
items: { [key: string]: any }[],
|
3
|
-
id: string
|
4
|
-
): any => {
|
5
|
-
for (const item of items) {
|
6
|
-
if (item.id === id) {
|
7
|
-
return item;
|
8
|
-
}
|
9
|
-
if (item.children) {
|
10
|
-
const found = findItemById(item.children, id);
|
11
|
-
if (found) {
|
12
|
-
return found;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
}
|
16
|
-
return null;
|
17
|
-
};
|
18
|
-
|
19
|
-
export const checkIt = (
|
20
|
-
foundItem: { [key: string]: any },
|
21
|
-
selectedItems: any[],
|
22
|
-
setSelectedItems: Function,
|
23
|
-
expand: boolean
|
24
|
-
) => {
|
25
|
-
if (!foundItem) {
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
|
29
|
-
foundItem.checked = true;
|
30
|
-
foundItem.expanded = expand;
|
31
|
-
selectedItems.push(foundItem);
|
32
|
-
|
33
|
-
if (foundItem.children) {
|
34
|
-
foundItem.children.map((x: any) => {
|
35
|
-
checkIt(x, selectedItems, setSelectedItems, expand);
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
setSelectedItems([...selectedItems]);
|
40
|
-
};
|
41
|
-
|
42
|
-
export const unCheckIt = (
|
43
|
-
foundItem: { [key: string]: any },
|
44
|
-
selectedItems: any,
|
45
|
-
setSelectedItems: any,
|
46
|
-
expand: boolean
|
47
|
-
) => {
|
48
|
-
if (!foundItem) {
|
49
|
-
return;
|
50
|
-
}
|
51
|
-
|
52
|
-
foundItem.checked = false;
|
53
|
-
foundItem.expanded = false;
|
54
|
-
const newSelectedItems = selectedItems.filter(
|
55
|
-
(item: any) => item.id !== foundItem.id
|
56
|
-
);
|
57
|
-
if (foundItem.children) {
|
58
|
-
foundItem.children.map((x: any) => {
|
59
|
-
unCheckIt(x, selectedItems, setSelectedItems, expand);
|
60
|
-
});
|
61
|
-
}
|
62
|
-
setSelectedItems([...newSelectedItems]);
|
63
|
-
};
|
64
|
-
|
65
|
-
|
66
|
-
export const getParentAndAncestorsIds = (itemId:string, items:{ [key: string]: string; }[], ancestors:string[] = []):any => {
|
67
|
-
for (let i = 0; i < items.length; i++) {
|
68
|
-
const item:any = items[i];
|
69
|
-
if (item.id === itemId) {
|
70
|
-
// item found in current level of items array
|
71
|
-
return [...ancestors, item.id];
|
72
|
-
}
|
73
|
-
if (item.children && item.children.length > 0) {
|
74
|
-
// recursively search through children
|
75
|
-
const foundAncestors = getParentAndAncestorsIds(
|
76
|
-
itemId,
|
77
|
-
item.children,
|
78
|
-
[...ancestors, item.id]
|
79
|
-
);
|
80
|
-
if (foundAncestors) {
|
81
|
-
return foundAncestors;
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|
85
|
-
// item not found in this level of items array or its children
|
86
|
-
return null;
|
87
|
-
}
|