playbook_ui 15.7.0.pre.alpha.PLAY2678emojimask13284 → 15.7.0.pre.alpha.PLAY2704multilevelselectsingledisabledoptions13404

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5671bd3842cbc616980cca133af25a4d32013d8bcf16c2472d5e5cda9d122943
4
- data.tar.gz: 0c2ce0cd5554eb290beb880f6ad0ce84207c40ceaa428b947c6b9566947388ba
3
+ metadata.gz: 10b9d0d0359b00ce5f07f4b0d3f0e1dc2501722d51210e29c76ade6dfc9eca0e
4
+ data.tar.gz: 3b3389d7f5545d88ac712ef7c0ac7526d448089ff6b1e541214f7577ffb689ad
5
5
  SHA512:
6
- metadata.gz: 769539b8947c986ca86ad41720be93617da036d335de3ffe9945afe26fcb05bc543d420124486ed2825b85e46ad83bb183ac922a9cbc3f70a1f318f987a5c53b
7
- data.tar.gz: af02627b473d11689bf92429bf6bfe6dd7a11bfc443f641c48749ef56faeb0358f12779049e6b72ccb8b6486cca3a211ed7572113cbf65751dc2b9e96a4a7a79
6
+ metadata.gz: c4a79a82d7c87252941b881c6396d5b3f6884021cd54dbde70e44d75797b3be6f20130fd87a23d76d4efbad2fed8f8633d018f6289c8e7b108a53524f3af8161
7
+ data.tar.gz: 79b3ce7929fffbafdbc098cacd0763f6b4f7d9c56bd9674598fe5602129cbe9871c7000c5e4178b171c125dd77ee00246412f322da6e063f379da29cfe167b2a
@@ -30,10 +30,6 @@ module Playbook
30
30
  closeable.present? ? " remove_toast" : ""
31
31
  end
32
32
 
33
- def auto_close_class
34
- auto_close.present? ? " auto_close_#{auto_close}" : ""
35
- end
36
-
37
33
  def position_class
38
34
  horizontal && vertical ? " positioned_toast #{vertical} #{horizontal}" : ""
39
35
  end
@@ -42,6 +38,14 @@ module Playbook
42
38
  multi_line.present? ? "multi_line" : nil
43
39
  end
44
40
 
41
+ def auto_close_attribute
42
+ auto_close.present? ? { "pb-auto-close": auto_close } : {}
43
+ end
44
+
45
+ def data
46
+ Hash(prop(:data)).merge(auto_close_attribute)
47
+ end
48
+
45
49
  def icon_value
46
50
  icon || case status
47
51
  when "success"
@@ -61,9 +65,7 @@ module Playbook
61
65
 
62
66
  def classname
63
67
  default_z_index = z_index.present? ? "" : " z_index_max"
64
- # IMPORTANT: the AutoClose class must be the last class in the string for JS to read it correctly
65
- # Changing the order will break the auto_close functionality
66
- generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index + auto_close_class
68
+ generate_classname("pb_fixed_confirmation_toast_kit", status, multi_line_class) + close_class + position_class + icon_class + default_z_index
67
69
  end
68
70
  end
69
71
  end
@@ -21,17 +21,12 @@ export default class PbFixedConfirmationToast extends PbEnhancedElement {
21
21
  }
22
22
 
23
23
  autoCloseToast(element) {
24
- const classListValues = element.classList.value
25
- const hasAutoCloseClass = classListValues.includes('auto_close')
26
-
27
- if (hasAutoCloseClass) {
28
- const classList = classListValues.split(' ')
29
- const autoCloseValue = classList[classList.length - 1].split('_')[2]
30
- const autoCloseIntValue = parseInt(autoCloseValue)
24
+ const autoCloseDataAttr = element.getAttribute('data-pb-auto-close')
31
25
 
26
+ if (autoCloseDataAttr) {
32
27
  setTimeout(() => {
33
28
  this.removeToast(element)
34
- }, autoCloseIntValue)
29
+ }, parseInt(autoCloseDataAttr))
35
30
  }
36
31
  }
37
32
  }
@@ -90,7 +90,7 @@
90
90
 
91
91
  <%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
92
92
  <%= form.typeahead :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
93
- <%= form.text_field :example_text_field, props: { label: "emoji mask demo text input", emoji_mask: true } %>
93
+ <%= form.text_field :example_text_field, props: { label: true } %>
94
94
  <%= form.text_field :example_text_field_2, props: { label: "Text Field Custom Label" } %>
95
95
  <%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field", hidden_inputs: true } %>
96
96
  <%= form.email_field :example_email_field, props: { label: true } %>
@@ -98,7 +98,7 @@
98
98
  <%= form.search_field :example_search_field, props: { label: true } %>
99
99
  <%= form.password_field :example_password_field, props: { label: true } %>
100
100
  <%= form.url_field :example_url_field, props: { label: true } %>
101
- <%= form.text_area :example_text_area, props: { label: "emoji mask demo textarea", emoji_mask: true } %>
101
+ <%= form.text_area :example_text_area, props: { label: true } %>
102
102
  <%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options } %>
103
103
  <%= form.dropdown_field :example_dropdown_multi, props: { label: true, options: example_dropdown_options, multi_select: true } %>
104
104
  <%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true } %>
@@ -358,6 +358,13 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
358
358
  const { id, value: inputText } = e.target;
359
359
  // The radio button needs a unique ID, this grabs the ID before the hyphen
360
360
  const selectedItemID = id.match(/^[^-]*/)[0];
361
+
362
+ // Check if the item is disabled - if so, don't allow selection (safety check in addition to native disabled attribute)
363
+ const clickedItem = filterFormattedDataById(formattedData, selectedItemID);
364
+ if (clickedItem.length > 0 && clickedItem[0].disabled) {
365
+ return;
366
+ }
367
+
361
368
  // Reset tree checked state, triggering useEffect
362
369
  const treeWithNoSelections = modifyRecursive(formattedData, false);
363
370
  // Update tree with single selection
@@ -1 +1 @@
1
- individual items can also be disabled by including the `disabled:true` within the object on the treeData for the `returnAllSelected`/`return_all_selected` variant. As noted above, this variant will return data on all checked nodes from the dropdown, irrespective of whether it is a parent or child node.
1
+ Individual items can also be disabled by including the `disabled:true` within the object on the treeData for the `returnAllSelected`/`return_all_selected` variant. As noted above, this variant will return data on all checked nodes from the dropdown, irrespective of whether it is a parent or child node.
@@ -0,0 +1,135 @@
1
+ <% treeData = [
2
+ {
3
+ label: "HQ",
4
+ value: "hQ",
5
+ id: "hq2",
6
+ },
7
+ {
8
+ label: "Philadelphia",
9
+ value: "philadelphia",
10
+ id: "phl2",
11
+ disabled: true,
12
+ children: [
13
+ {
14
+ label: "Marketing & Sales PHL",
15
+ value: "marketingAndSalesPhl",
16
+ id: "marketingPHL2",
17
+ },
18
+ {
19
+ label: "Installation Office PHL",
20
+ value: "installationOfficePhl",
21
+ id: "installationPHL2",
22
+ },
23
+ {
24
+ label: "Warehouse PHL",
25
+ value: "warehousePhl",
26
+ id: "warehousePHL2",
27
+ },
28
+ ]
29
+ },
30
+ {
31
+ label: "New Jersey",
32
+ value: "newJersey",
33
+ id: "nj2",
34
+ children: [
35
+ {
36
+ label: "New Jersey",
37
+ value: "newJersey",
38
+ id: "nj12",
39
+ children: [
40
+ {
41
+ label: "Marketing & Sales NJ",
42
+ value: "marketingAndSalesNj",
43
+ id: "marketingNJ2",
44
+ disabled: true,
45
+ },
46
+ {
47
+ label: "Installation Office NJ",
48
+ value: "installationOfficeNj",
49
+ id: "installationNJ2",
50
+ },
51
+ {
52
+ label: "Warehouse NJ",
53
+ value: "warehouseNj",
54
+ id: "warehouseNJ2",
55
+ },
56
+ ],
57
+ },
58
+ {
59
+ label: "Princeton",
60
+ value: "princeton",
61
+ id: "princeton2",
62
+ children: [
63
+ {
64
+ label: "Marketing & Sales Princeton",
65
+ value: "marketingAndSalesPrinceton",
66
+ id: "marketingPR2",
67
+ },
68
+ {
69
+ label: "Installation Office Princeton",
70
+ value: "installationOfficePrinceton",
71
+ id: "installationPR2",
72
+ disabled: true,
73
+ },
74
+ {
75
+ label: "Warehouse Princeton",
76
+ value: "warehousePrinceton",
77
+ id: "warehousePR2",
78
+ },
79
+ ]
80
+ },
81
+ ]
82
+ },
83
+ {
84
+ label: "Maryland",
85
+ value: "maryland",
86
+ id: "MD2",
87
+ children: [
88
+ {
89
+ label: "Marketing & Sales MD",
90
+ value: "marketingAndSalesMd",
91
+ id: "marketingMD2",
92
+ },
93
+ {
94
+ label: "Installation Office MD",
95
+ value: "installationOfficeMd",
96
+ id: "installationMD2",
97
+ },
98
+ {
99
+ label: "Warehouse MD",
100
+ value: "warehouseMd",
101
+ id: "warehouseMD2",
102
+ },
103
+ ]
104
+ },
105
+ {
106
+ label: "Connecticut",
107
+ value: "connecticut",
108
+ id: "CT2",
109
+ children: [
110
+ {
111
+ label: "Marketing & Sales CT",
112
+ value: "marketingAndSalesCt",
113
+ id: "marketingCT2",
114
+ },
115
+ {
116
+ label: "Installation Office CT",
117
+ value: "installationOfficeCt",
118
+ id: "installationCT2",
119
+ },
120
+ {
121
+ label: "Warehouse CT",
122
+ value: "warehouseCt",
123
+ id: "warehouseCT2",
124
+ },
125
+ ]
126
+ },
127
+ ] %>
128
+
129
+ <%= pb_rails("multi_level_select", props: {
130
+ id: "multi-level-select-single-disabled-rails",
131
+ name: "single_disabled",
132
+ tree_data: treeData,
133
+ input_name: "Power",
134
+ variant: "single"
135
+ }) %>
@@ -0,0 +1,147 @@
1
+ import React from "react";
2
+ import MultiLevelSelect from "../_multi_level_select";
3
+
4
+ const treeData = [
5
+ {
6
+ label: "HQ",
7
+ value: "hQ",
8
+ id: "hq2",
9
+ },
10
+ {
11
+ label: "Philadelphia",
12
+ value: "philadelphia",
13
+ id: "phl2",
14
+ disabled: true,
15
+ children: [
16
+ {
17
+ label: "Marketing & Sales PHL",
18
+ value: "marketingAndSalesPhl",
19
+ id: "marketingPHL2",
20
+ },
21
+ {
22
+ label: "Installation Office PHL",
23
+ value: "installationOfficePhl",
24
+ id: "installationPHL2",
25
+ },
26
+ {
27
+ label: "Warehouse PHL",
28
+ value: "warehousePhl",
29
+ id: "warehousePHL2",
30
+ },
31
+ ]
32
+ },
33
+ {
34
+ label: "New Jersey",
35
+ value: "newJersey",
36
+ id: "nj2",
37
+ children: [
38
+ {
39
+ label: "New Jersey",
40
+ value: "newJersey",
41
+ id: "nj12",
42
+ children: [
43
+ {
44
+ label: "Marketing & Sales NJ",
45
+ value: "marketingAndSalesNj",
46
+ id: "marketingNJ2",
47
+ disabled: true,
48
+ },
49
+ {
50
+ label: "Installation Office NJ",
51
+ value: "installationOfficeNj",
52
+ id: "installationNJ2",
53
+ },
54
+ {
55
+ label: "Warehouse NJ",
56
+ value: "warehouseNj",
57
+ id: "warehouseNJ2",
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ label: "Princeton",
63
+ value: "princeton",
64
+ id: "princeton2",
65
+ children: [
66
+ {
67
+ label: "Marketing & Sales Princeton",
68
+ value: "marketingAndSalesPrinceton",
69
+ id: "marketingPR2",
70
+ },
71
+ {
72
+ label: "Installation Office Princeton",
73
+ value: "installationOfficePrinceton",
74
+ id: "installationPR2",
75
+ disabled: true,
76
+ },
77
+ {
78
+ label: "Warehouse Princeton",
79
+ value: "warehousePrinceton",
80
+ id: "warehousePR2",
81
+ },
82
+ ]
83
+ },
84
+ ]
85
+ },
86
+ {
87
+ label: "Maryland",
88
+ value: "maryland",
89
+ id: "MD2",
90
+ children: [
91
+ {
92
+ label: "Marketing & Sales MD",
93
+ value: "marketingAndSalesMd",
94
+ id: "marketingMD2",
95
+ },
96
+ {
97
+ label: "Installation Office MD",
98
+ value: "installationOfficeMd",
99
+ id: "installationMD2",
100
+ },
101
+ {
102
+ label: "Warehouse MD",
103
+ value: "warehouseMd",
104
+ id: "warehouseMD2",
105
+ },
106
+ ]
107
+ },
108
+ {
109
+ label: "Connecticut",
110
+ value: "connecticut",
111
+ id: "CT2",
112
+ children: [
113
+ {
114
+ label: "Marketing & Sales CT",
115
+ value: "marketingAndSalesCt",
116
+ id: "marketingCT2",
117
+ },
118
+ {
119
+ label: "Installation Office CT",
120
+ value: "installationOfficeCt",
121
+ id: "installationCT2",
122
+ },
123
+ {
124
+ label: "Warehouse CT",
125
+ value: "warehouseCt",
126
+ id: "warehouseCT2",
127
+ },
128
+ ]
129
+ },
130
+ ];
131
+
132
+ const MultiLevelSelectSingleDisabled = (props) => {
133
+ return (
134
+ <div>
135
+ <MultiLevelSelect
136
+ id="multiselect-single-disabled"
137
+ inputName="Power"
138
+ onSelect={(selectedNode) => console.log("Selected Node", selectedNode)}
139
+ treeData={treeData}
140
+ variant="single"
141
+ {...props}
142
+ />
143
+ </div>
144
+ )
145
+ };
146
+
147
+ export default MultiLevelSelectSingleDisabled;
@@ -0,0 +1 @@
1
+ Individual items can be disabled by including `disabled: true` within the object on the treeData for the `single` variant. Disabled options are visibly disabled in the dropdown UI and cannot be selected via mouse click or keyboard navigation. When a parent node is disabled, all of its children are automatically disabled as well.
@@ -15,6 +15,7 @@ examples:
15
15
  - multi_level_select_disabled_options: Disabled Options (Return All Selected)
16
16
  - multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
17
17
  - multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
18
+ - multi_level_select_single_disabled: Disabled Options (Single Select)
18
19
 
19
20
  react:
20
21
  - multi_level_select_default: Default
@@ -33,3 +34,4 @@ examples:
33
34
  - multi_level_select_disabled_options: Disabled Options (Return All Selected)
34
35
  - multi_level_select_disabled_options_parent_default: Disabled Parent Option (Default)
35
36
  - multi_level_select_disabled_options_parent: Disabled Parent Option (Return All Selected)
37
+ - multi_level_select_single_disabled: Disabled Options (Single Select)
@@ -14,3 +14,4 @@ export { default as MultiLevelSelectDisabledOptionsParent } from './_multi_level
14
14
  export { default as MultiLevelSelectDisabledOptionsParentDefault } from './_multi_level_select_disabled_options_parent_default.jsx'
15
15
  export { default as MultiLevelSelectDisabledOptionsDefault } from './_multi_level_select_disabled_options_default.jsx'
16
16
  export { default as MultiLevelSelectLabel } from './_multi_level_select_label.jsx'
17
+ export { default as MultiLevelSelectSingleDisabled } from './_multi_level_select_single_disabled.jsx'