playbook_ui 13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21323 → 13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21358

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,145 @@
1
+ import React from "react";
2
+ import MultiLevelSelect from "../_multi_level_select";
3
+
4
+ const treeData = [
5
+ {
6
+ label: "Philadelphia",
7
+ value: "Philadelphia",
8
+ id: "phl",
9
+ children: [
10
+ {
11
+ label: "HQ",
12
+ value: "HQ",
13
+ id: "hq",
14
+ },
15
+ {
16
+ label: "Marketing & Sales PHL",
17
+ value: "Marketing & Sales PHL",
18
+ id: "marketing1",
19
+ },
20
+ {
21
+ label: "Installation Office PHL",
22
+ value: "Installation Office PHL",
23
+ id: "installation1",
24
+ },
25
+ {
26
+ label: "Warehouse PHL",
27
+ value: "Warehouse PHL",
28
+ id: "warehouse1",
29
+ },
30
+ ]
31
+ },
32
+ {
33
+ label: "New Jersey",
34
+ value: "New Jersey",
35
+ id: "nj",
36
+ children: [
37
+ {
38
+ label: "New Jersey",
39
+ value: "New Jersey",
40
+ id: "nj1",
41
+ children: [
42
+ {
43
+ label: "Marketing & Sales NJ",
44
+ value: "Marketing & Sales NJ",
45
+ id: "marketing2",
46
+ },
47
+ {
48
+ label: "Installation Office NJ",
49
+ value: "Installation Office NJ",
50
+ id: "installation2",
51
+ },
52
+ {
53
+ label: "Warehouse NJ",
54
+ value: "Warehouse NJ",
55
+ id: "warehouse2",
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ label: "Princeton",
61
+ value: "Princeton",
62
+ id: "princeton",
63
+ children: [
64
+ {
65
+ label: "Marketing & Sales Princeton",
66
+ value: "Marketing & Sales Princeton",
67
+ id: "marketing3",
68
+ },
69
+ {
70
+ label: "Installation Office Princeton",
71
+ value: "Installation Office Princeton",
72
+ id: "installation3",
73
+ },
74
+ {
75
+ label: "Warehouse Princeton",
76
+ value: "Warehouse Princeton",
77
+ id: "warehouse3",
78
+ },
79
+ ]
80
+ },
81
+ ]
82
+ },
83
+ {
84
+ label: "Maryland",
85
+ value: "Maryland",
86
+ id: "MD",
87
+ children: [
88
+ {
89
+ label: "Marketing & Sales MD",
90
+ value: "Marketing & Sales MD",
91
+ id: "marketing4",
92
+ },
93
+ {
94
+ label: "Installation Office MD",
95
+ value: "Installation Office MD",
96
+ id: "installation4",
97
+ },
98
+ {
99
+ label: "Warehouse MD",
100
+ value: "Warehouse MD",
101
+ id: "warehouse4",
102
+ },
103
+ ]
104
+ },
105
+ {
106
+ label: "Connecticut",
107
+ value: "Connecticut",
108
+ id: "CT",
109
+ children: [
110
+ {
111
+ label: "Marketing & Sales CT",
112
+ value: "Marketing & Sales CT",
113
+ id: "marketing5",
114
+ },
115
+ {
116
+ label: "Installation Office CT",
117
+ value: "Installation Office CT",
118
+ id: "installation5",
119
+ },
120
+ {
121
+ label: "Warehouse CT",
122
+ value: "Warehouse CT",
123
+ id: "warehouse5",
124
+ },
125
+ ]
126
+ },
127
+ ];
128
+
129
+ const MultiLevelSelectSingleChildrenOnly = (props) => {
130
+ return (
131
+ <div>
132
+ <MultiLevelSelect
133
+ id="multiselect-single-children-only"
134
+ inputName="PowerChildren"
135
+ onSelect={(selectedNode) => console.log("Selected Node", selectedNode)}
136
+ treeData={treeData}
137
+ ultimateChildrenOnly
138
+ variant="single"
139
+ {...props}
140
+ />
141
+ </div>
142
+ )
143
+ };
144
+
145
+ export default MultiLevelSelectSingleChildrenOnly;
@@ -2,6 +2,7 @@ examples:
2
2
  rails:
3
3
  - multi_level_select_default: Default
4
4
  - multi_level_select_single: Single Select
5
+ - multi_level_select_single_children_only: Single Select Ultimate Children Only
5
6
  - multi_level_select_return_all_selected: Return All Selected
6
7
  - multi_level_select_selected_ids: Selected Ids
7
8
  - multi_level_select_with_form: With Form
@@ -9,5 +10,6 @@ examples:
9
10
  react:
10
11
  - multi_level_select_default: Default
11
12
  - multi_level_select_single: Single Select
13
+ - multi_level_select_single_children_only: Single Select Ultimate Children Only
12
14
  - multi_level_select_return_all_selected: Return All Selected
13
15
  - multi_level_select_selected_ids: Selected Ids
@@ -1,4 +1,5 @@
1
1
  export { default as MultiLevelSelectDefault } from './_multi_level_select_default.jsx'
2
2
  export { default as MultiLevelSelectSingle } from './_multi_level_select_single.jsx'
3
+ export { default as MultiLevelSelectSingleChildrenOnly } from './_multi_level_select_single_children_only.jsx'
3
4
  export { default as MultiLevelSelectReturnAllSelected } from './_multi_level_select_return_all_selected.jsx'
4
5
  export { default as MultiLevelSelectSelectedIds } from "./_multi_level_select_selected_ids.jsx"
@@ -16,6 +16,8 @@ module Playbook
16
16
  default: "pills"
17
17
  prop :input_name, type: Playbook::Props::String,
18
18
  default: ""
19
+ prop :ultimate_children_only, type: Playbook::Props::Boolean,
20
+ default: false
19
21
  prop :variant, type: Playbook::Props::Enum,
20
22
  values: %w[multi single],
21
23
  default: "multi"
@@ -33,6 +35,7 @@ module Playbook
33
35
  returnAllSelected: return_all_selected,
34
36
  selectedIds: selected_ids,
35
37
  input_name: input_name,
38
+ ultimateChildrenOnly: ultimate_children_only,
36
39
  variant: variant,
37
40
  }
38
41
  end