playbook_ui 12.25.0.pre.alpha.play822bolddefaultfortitle3764 → 12.25.0.pre.alpha.railsmultilevelimprovements776

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +82 -1
  3. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +14 -13
  4. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +3 -2
  5. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +212 -0
  6. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +58 -98
  7. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +354 -86
  8. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md +1 -1
  9. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +1 -0
  10. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb +72 -0
  11. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
  12. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +3 -0
  13. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +1 -1
  14. data/app/pb_kits/playbook/pb_title/_title.scss +1 -1
  15. data/app/pb_kits/playbook/pb_title/_title.tsx +3 -2
  16. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +0 -1
  17. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +0 -6
  18. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +2 -1
  19. data/app/pb_kits/playbook/pb_title/title.rb +10 -3
  20. data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
  21. data/dist/playbook-rails.js +7 -7
  22. data/lib/playbook/forms/builder/multi_level_select_field.rb +12 -0
  23. data/lib/playbook/forms/builder.rb +1 -0
  24. data/lib/playbook/version.rb +1 -1
  25. metadata +5 -4
  26. data/app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx +0 -31
  27. data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +0 -87
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module Forms
5
+ class Builder
6
+ def multi_level_select(name, props: {})
7
+ props[:name] = name
8
+ @template.pb_rails("multi_level_select", props: props)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -10,6 +10,7 @@ module Playbook
10
10
  require_relative "builder/form_field_builder"
11
11
  require_relative "builder/select_field"
12
12
  require_relative "builder/typeahead_field"
13
+ require_relative "builder/multi_level_select_field"
13
14
 
14
15
  prepend(FormFieldBuilder.new(:email_field, kit_name: "text_input"))
15
16
  prepend(FormFieldBuilder.new(:number_field, kit_name: "text_input"))
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "12.25.0"
5
- VERSION = "12.25.0.pre.alpha.play822bolddefaultfortitle3764"
5
+ VERSION = "12.25.0.pre.alpha.railsmultilevelimprovements776"
6
6
  end
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.play822bolddefaultfortitle3764
4
+ version: 12.25.0.pre.alpha.railsmultilevelimprovements776
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-13 00:00:00.000000000 Z
12
+ date: 2023-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -1407,18 +1407,18 @@ 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
1416
1416
  - app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb
1417
1417
  - app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.jsx
1418
1418
  - app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.md
1419
+ - app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_with_form.html.erb
1419
1420
  - app/pb_kits/playbook/pb_multi_level_select/docs/example.yml
1420
1421
  - app/pb_kits/playbook/pb_multi_level_select/docs/index.js
1421
- - app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts
1422
1422
  - app/pb_kits/playbook/pb_multi_level_select/multi_level_select.html.erb
1423
1423
  - app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb
1424
1424
  - app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx
@@ -2431,6 +2431,7 @@ files:
2431
2431
  - lib/playbook/forms/builder/collection_select_field.rb
2432
2432
  - lib/playbook/forms/builder/date_picker_field.rb
2433
2433
  - lib/playbook/forms/builder/form_field_builder.rb
2434
+ - lib/playbook/forms/builder/multi_level_select_field.rb
2434
2435
  - lib/playbook/forms/builder/select_field.rb
2435
2436
  - lib/playbook/forms/builder/typeahead_field.rb
2436
2437
  - lib/playbook/justify_content.rb
@@ -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
- }