playbook_ui 12.25.0.pre.alpha.PLAY818multilevelrebuild779 → 12.25.0.pre.alpha.play822bolddefaultfortitle3764
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 +1 -82
- data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +13 -14
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +2 -3
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +98 -58
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +86 -340
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx +31 -0
- 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 +0 -1
- data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +87 -0
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +1 -1
- data/app/pb_kits/playbook/pb_title/_title.scss +1 -1
- data/app/pb_kits/playbook/pb_title/_title.tsx +2 -3
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +6 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +1 -2
- data/app/pb_kits/playbook/pb_title/title.rb +3 -10
- data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/version.rb +1 -1
- metadata +4 -3
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +0 -212
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.play822bolddefaultfortitle3764
|
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-13 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
|
1411
1410
|
- app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss
|
1412
1411
|
- 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
|
@@ -1418,6 +1418,7 @@ files:
|
|
1418
1418
|
- app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.md
|
1419
1419
|
- app/pb_kits/playbook/pb_multi_level_select/docs/example.yml
|
1420
1420
|
- app/pb_kits/playbook/pb_multi_level_select/docs/index.js
|
1421
|
+
- app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts
|
1421
1422
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb
|
1422
1423
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb
|
1423
1424
|
- app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx
|
@@ -1,212 +0,0 @@
|
|
1
|
-
//function for unchecking items in formattedData
|
2
|
-
export const unCheckIt = (
|
3
|
-
formattedData: { [key: string]: any }[],
|
4
|
-
id: string
|
5
|
-
) => {
|
6
|
-
formattedData.map((item: { [key: string]: any }) => {
|
7
|
-
if (item.id === id && item.checked) {
|
8
|
-
item.checked = false;
|
9
|
-
}
|
10
|
-
if (item.children && item.children.length > 0) {
|
11
|
-
unCheckIt(item.children, id);
|
12
|
-
}
|
13
|
-
return item;
|
14
|
-
});
|
15
|
-
};
|
16
|
-
|
17
|
-
//function to retrieve all ancestors of unchecked item and set checked to false
|
18
|
-
export const getAncestorsOfUnchecked = (
|
19
|
-
formattedData: { [key: string]: any }[],
|
20
|
-
item: { [key: string]: any }
|
21
|
-
) => {
|
22
|
-
if (item.parent_id) {
|
23
|
-
const ancestors = filterFormattedDataById(formattedData, item.parent_id);
|
24
|
-
ancestors[0].checked = false;
|
25
|
-
|
26
|
-
if (ancestors[0].parent_id) {
|
27
|
-
getAncestorsOfUnchecked(formattedData, ancestors[0]);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
};
|
31
|
-
|
32
|
-
//recursively check all child and grandchild items if parent checked
|
33
|
-
export const checkedRecursive = (item: { [key: string]: any }) => {
|
34
|
-
if (!item.checked) {
|
35
|
-
item.checked = true;
|
36
|
-
}
|
37
|
-
if (item.children && item.children.length > 0) {
|
38
|
-
item.children.forEach((childItem: { [key: string]: any }) => {
|
39
|
-
checkedRecursive(childItem);
|
40
|
-
});
|
41
|
-
}
|
42
|
-
};
|
43
|
-
|
44
|
-
//recursively uncheck all child and grandchild items if parent unchecked
|
45
|
-
export const unCheckedRecursive = (item: { [key: string]: any }) => {
|
46
|
-
if (item.checked) {
|
47
|
-
item.checked = false;
|
48
|
-
}
|
49
|
-
if (item.children && item.children.length > 0) {
|
50
|
-
item.children.forEach((childItem: { [key: string]: any }) => {
|
51
|
-
unCheckedRecursive(childItem);
|
52
|
-
});
|
53
|
-
}
|
54
|
-
};
|
55
|
-
|
56
|
-
//function is going over formattedData and returning all objects that match the
|
57
|
-
//id of the clicked item from the dropdown
|
58
|
-
export const filterFormattedDataById = (
|
59
|
-
formattedData: { [key: string]: any }[],
|
60
|
-
id: string
|
61
|
-
) => {
|
62
|
-
const matched: { [key: string]: any }[] = [];
|
63
|
-
const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
|
64
|
-
for (const item of data) {
|
65
|
-
if (item.id.toLowerCase() === (term.toLowerCase())) {
|
66
|
-
matched.push(item);
|
67
|
-
}
|
68
|
-
|
69
|
-
if (item.children && item.children.length > 0) {
|
70
|
-
recursiveSearch(item.children, term);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
recursiveSearch(formattedData, id);
|
76
|
-
return matched;
|
77
|
-
};
|
78
|
-
|
79
|
-
export const findByFilter = (
|
80
|
-
formattedData: { [key: string]: any }[],
|
81
|
-
searchTerm: string
|
82
|
-
) => {
|
83
|
-
const matchedItems: { [key: string]: any }[] = [];
|
84
|
-
const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
|
85
|
-
for (const item of data) {
|
86
|
-
if (item.label.toLowerCase().includes(term.toLowerCase())) {
|
87
|
-
matchedItems.push(item);
|
88
|
-
}
|
89
|
-
|
90
|
-
if (item.children) {
|
91
|
-
recursiveSearch(item.children, term);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
};
|
95
|
-
|
96
|
-
recursiveSearch(formattedData, searchTerm);
|
97
|
-
return matchedItems;
|
98
|
-
};
|
99
|
-
|
100
|
-
//function to get all items with checked = true
|
101
|
-
export const getCheckedItems = (
|
102
|
-
data: { [key: string]: any }[]
|
103
|
-
): { [key: string]: any }[] => {
|
104
|
-
const checkedItems: { [key: string]: any }[] = [];
|
105
|
-
if (!Array.isArray(data)) {
|
106
|
-
return;
|
107
|
-
}
|
108
|
-
data.forEach((item: { [key: string]: any }) => {
|
109
|
-
if (item.checked) {
|
110
|
-
checkedItems.push(item);
|
111
|
-
}
|
112
|
-
if (item.children && item.children.length > 0) {
|
113
|
-
const childCheckedItems = getCheckedItems(item.children);
|
114
|
-
checkedItems.push(...childCheckedItems);
|
115
|
-
}
|
116
|
-
});
|
117
|
-
return checkedItems;
|
118
|
-
};
|
119
|
-
|
120
|
-
export const getChildIds = (
|
121
|
-
item: { [key: string]: any },
|
122
|
-
defaultArray: { [key: string]: any }[]
|
123
|
-
) => {
|
124
|
-
let childIds: string[] = [];
|
125
|
-
item.children.forEach((child: { [key: string]: any }) => {
|
126
|
-
childIds.push(child.id);
|
127
|
-
if (child.children && child.children.length > 0) {
|
128
|
-
const childChildIds = getChildIds(child, defaultArray);
|
129
|
-
childIds.push(...childChildIds);
|
130
|
-
}
|
131
|
-
});
|
132
|
-
return childIds;
|
133
|
-
};
|
134
|
-
|
135
|
-
export const updateReturnItems = (newChecked: { [key: string]: any }[]) => {
|
136
|
-
const updatedCheckedItems: { [key: string]: any }[] = [];
|
137
|
-
for (const item of newChecked) {
|
138
|
-
if (item.children && item.children.length > 0) {
|
139
|
-
const allChildrenChecked = item.children.every(
|
140
|
-
(child: { [key: string]: any }) => child.checked
|
141
|
-
);
|
142
|
-
if (allChildrenChecked) {
|
143
|
-
updatedCheckedItems.push(item);
|
144
|
-
}
|
145
|
-
}
|
146
|
-
const childItem = updatedCheckedItems.some((x) => x.id === item?.parent_id);
|
147
|
-
if (!childItem) {
|
148
|
-
updatedCheckedItems.push(item);
|
149
|
-
}
|
150
|
-
}
|
151
|
-
const filteredReturn = updatedCheckedItems.filter((item) => {
|
152
|
-
return !updatedCheckedItems.find(
|
153
|
-
(otherItem) => otherItem.id === item.parent_id
|
154
|
-
);
|
155
|
-
});
|
156
|
-
return filteredReturn;
|
157
|
-
};
|
158
|
-
|
159
|
-
export const recursiveReturnOnlyParent = (
|
160
|
-
items: { [key: string]: any },
|
161
|
-
formattedData: { [key: string]: any }[],
|
162
|
-
defaultReturn: { [key: string]: any }[],
|
163
|
-
setDefaultReturn: any
|
164
|
-
) => {
|
165
|
-
const parent = filterFormattedDataById(formattedData, items.parent_id);
|
166
|
-
const allChildrenChecked = parent[0].children.every(
|
167
|
-
(child: { [key: string]: any }) => child.checked
|
168
|
-
);
|
169
|
-
if (allChildrenChecked) {
|
170
|
-
// Only return the parent and remove its children from defaultReturn
|
171
|
-
parent[0].checked = true;
|
172
|
-
const filteredDefaultReturn = defaultReturn.filter((item) => {
|
173
|
-
// Remove children of the specific parent
|
174
|
-
if (
|
175
|
-
parent[0].children.find(
|
176
|
-
(child: { [key: string]: any }) => child.id === item.id
|
177
|
-
)
|
178
|
-
) {
|
179
|
-
return false;
|
180
|
-
}
|
181
|
-
});
|
182
|
-
setDefaultReturn([...filteredDefaultReturn, parent[0]]);
|
183
|
-
// Check if the parent has a parent and its children are all checked
|
184
|
-
const parentHasParent = parent[0].parent_id !== null;
|
185
|
-
if (parentHasParent) {
|
186
|
-
recursiveReturnOnlyParent(
|
187
|
-
parent[0],
|
188
|
-
formattedData,
|
189
|
-
filteredDefaultReturn,
|
190
|
-
setDefaultReturn
|
191
|
-
);
|
192
|
-
}
|
193
|
-
} else {
|
194
|
-
const checkedChildren = parent[0].children.filter(
|
195
|
-
(child: { [key: string]: any }) => child.checked
|
196
|
-
);
|
197
|
-
const updatedDefaultReturn = [...defaultReturn, ...checkedChildren];
|
198
|
-
setDefaultReturn(updatedDefaultReturn);
|
199
|
-
}
|
200
|
-
};
|
201
|
-
|
202
|
-
export const removeChildrenIfParentChecked = (
|
203
|
-
items: { [key: string]: any },
|
204
|
-
defaultReturn: { [key: string]: any }[],
|
205
|
-
setDefaultReturn: any
|
206
|
-
) => {
|
207
|
-
const childIds = getChildIds(items, defaultReturn);
|
208
|
-
const filteredDefaultArray = defaultReturn.filter(
|
209
|
-
(item: { [key: string]: any }) => childIds !== item.id
|
210
|
-
);
|
211
|
-
setDefaultReturn([...filteredDefaultArray, items]);
|
212
|
-
};
|