playbook_ui 14.20.0.pre.rc.0 → 14.20.0.pre.rc.1
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 +4 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.jsx +11 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +33 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.md +3 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +14 -1
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +1 -1
- data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +13 -7
- data/app/pb_kits/playbook/pb_person/_person.tsx +12 -2
- data/dist/chunks/_weekday_stacked-CaTzIguf.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +3 -3
- data/dist/chunks/_weekday_stacked-PfWrqC3z.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a8f9dbc6655bfe62d658f083e7e454993db3296e9fba0cad13f5cd4ead03ca
|
4
|
+
data.tar.gz: b711491996fcba25839cdab82233d5a5915d546607501f5d043de0a8ed926aa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498c6280b1a3ba30ea17603a860a7480a0e6b494514747efe7c3a42badbd9d3327921f67754a9a6b6b70a02866318d00cf5e9a7f346b40d1735f2439233caf04
|
7
|
+
data.tar.gz: dffbbd624f1627f9fba0411440719e07dbee51ca22b303973304224e944cadfd0d17c0bcc7d912b8a6142432f72c882d3e6c4ba13e833d2d2b25ac618b8752cd
|
@@ -6,6 +6,7 @@ import Flex from '../../pb_flex/_flex'
|
|
6
6
|
import FlexItem from '../../pb_flex/_flex_item'
|
7
7
|
import Avatar from '../../pb_avatar/_avatar'
|
8
8
|
import User from '../../pb_user/_user'
|
9
|
+
import Body from '../../pb_body/_body'
|
9
10
|
|
10
11
|
const DropdownWithCustomDisplay = (props) => {
|
11
12
|
const [selectedOption, setSelectedOption] = useState();
|
@@ -50,10 +51,20 @@ const DropdownWithCustomDisplay = (props) => {
|
|
50
51
|
<>
|
51
52
|
{
|
52
53
|
selectedOption && (
|
54
|
+
<Flex align="center">
|
53
55
|
<Avatar
|
54
56
|
name={selectedOption.label}
|
55
57
|
size="xs"
|
56
58
|
/>
|
59
|
+
<Body
|
60
|
+
marginX="xs"
|
61
|
+
text={selectedOption.label}
|
62
|
+
/>
|
63
|
+
<Badge
|
64
|
+
text={selectedOption.status}
|
65
|
+
variant={selectedOption.status == "Offline" ? "neutral" : selectedOption.status == "Online" ? "success" : "warning"}
|
66
|
+
/>
|
67
|
+
</Flex>
|
57
68
|
)
|
58
69
|
}
|
59
70
|
</>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected.
|
1
|
+
Optionally utilize `customDisplay` on the `Dropdown.Trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `customDisplay` will display as the selected option.
|
2
2
|
|
3
3
|
The `placeholder` prop can also be used to customize the placeholder text for the default `Dropdown.Trigger`.
|
4
4
|
|
@@ -38,7 +38,11 @@
|
|
38
38
|
|
39
39
|
<%
|
40
40
|
custom_display = capture do
|
41
|
-
pb_rails("
|
41
|
+
pb_rails("flex", props: { align: "center" }) do
|
42
|
+
concat(pb_rails("avatar", props: { name: "", size: "xs", id: "dropdown-avatar" }))
|
43
|
+
concat(pb_rails("body", props: { text: "", size: "xs", margin_x: "xs", id: "dropdown-avatar-name" }))
|
44
|
+
concat(pb_rails("badge", props: { text: "", id: "dropdown-avatar-status" }))
|
45
|
+
end
|
42
46
|
end
|
43
47
|
%>
|
44
48
|
|
@@ -62,4 +66,31 @@
|
|
62
66
|
<% end %>
|
63
67
|
<% end %>
|
64
68
|
<% end %>
|
65
|
-
<% end %>
|
69
|
+
<% end %>
|
70
|
+
|
71
|
+
|
72
|
+
<script>
|
73
|
+
document.addEventListener("pb:dropdown:selected", (e) => {
|
74
|
+
const option = e.detail;
|
75
|
+
const dropdown = e.target;
|
76
|
+
|
77
|
+
const display = dropdown.querySelector("#dropdown_trigger_custom_display");
|
78
|
+
if (!display) return;
|
79
|
+
|
80
|
+
const nameEl = display.querySelector("#dropdown-avatar-name");
|
81
|
+
if (nameEl) nameEl.textContent = option.label;
|
82
|
+
|
83
|
+
const avatarEl = display.querySelector("#dropdown-avatar").querySelector(".avatar_wrapper");
|
84
|
+
const initials = (option.label[0] + option.label.split(" ").pop()[0]).toUpperCase();
|
85
|
+
if (avatarEl) {
|
86
|
+
avatarEl.dataset.name = option.label;
|
87
|
+
avatarEl.setAttribute("data-initials", initials);
|
88
|
+
}
|
89
|
+
const badgeEl = display.querySelector("#dropdown-avatar-status");
|
90
|
+
const variant = option.status === "Online" ? "success" : option.status === "Offline" ? "neutral" : "warning";
|
91
|
+
if (badgeEl) {
|
92
|
+
badgeEl.querySelector("span").textContent = option.status;
|
93
|
+
badgeEl.className = 'pb_badge_kit_' + variant;
|
94
|
+
}
|
95
|
+
});
|
96
|
+
</script>
|
@@ -1,4 +1,6 @@
|
|
1
|
-
Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected.
|
1
|
+
Optionally utilize `custom_display` on the `dropdown/dropdown_trigger` subcomponent to customize its content after an option is selected. Pass in any combination of kits to create a custom display. When a user clicks on an option, the kits passed into `custom_display` will display as the selected option.
|
2
|
+
|
3
|
+
Make use of a script to help set the custom_display with the correct value. By using the pb:dropdown:selected event listener, you can target the kits with a querySelector and update them dynamically with the values needed to match the selected option. Make sure to add an ID to the kits being passed in.
|
2
4
|
|
3
5
|
The `placeholder` prop can also be used to customize the placeholder text for the default `dropdown/dropdown_trigger`.
|
4
6
|
|
@@ -142,9 +142,22 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
142
142
|
const customDisplayElement = this.element.querySelector(
|
143
143
|
"#dropdown_trigger_custom_display"
|
144
144
|
);
|
145
|
+
|
145
146
|
if (triggerElement) {
|
146
147
|
const selectedLabel = JSON.parse(value).label;
|
147
|
-
|
148
|
+
if (customDisplayElement) {
|
149
|
+
triggerElement.textContent = ""
|
150
|
+
this.element.setAttribute("data-option-selected", value);
|
151
|
+
const selectedObj = JSON.parse(value);
|
152
|
+
this.element.dispatchEvent(
|
153
|
+
new CustomEvent("pb:dropdown:selected", {
|
154
|
+
detail: selectedObj,
|
155
|
+
bubbles: true,
|
156
|
+
})
|
157
|
+
);
|
158
|
+
} else {
|
159
|
+
triggerElement.textContent = selectedLabel
|
160
|
+
}
|
148
161
|
if (customDisplayElement) {
|
149
162
|
customDisplayElement.style.display = "block";
|
150
163
|
customDisplayElement.style.paddingRight = "8px";
|
@@ -81,6 +81,11 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
|
|
81
81
|
|
82
82
|
const formatStreetAdr = (address: string): string => preserveCase ? address : titleize(address)
|
83
83
|
|
84
|
+
const uppercaseState = state?.toUpperCase() ?? ''
|
85
|
+
|
86
|
+
const fields = [address, addressCont, city, homeId, homeUrl, houseStyle, state, territory, zipcode]
|
87
|
+
const hasAllEmptyProps = fields.every(field => field === undefined || field === null || field === '')
|
88
|
+
|
84
89
|
return (
|
85
90
|
<div
|
86
91
|
className={classes(className, dark)}
|
@@ -88,7 +93,8 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
|
|
88
93
|
{...dataProps}
|
89
94
|
{...htmlProps}
|
90
95
|
>
|
91
|
-
{
|
96
|
+
{hasAllEmptyProps && '—'}
|
97
|
+
{emphasis == 'street' && !hasAllEmptyProps &&
|
92
98
|
<div>
|
93
99
|
<Title
|
94
100
|
className="pb_home_address_street_address"
|
@@ -105,11 +111,11 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
|
|
105
111
|
{titleize(addressCont)}
|
106
112
|
</Title>
|
107
113
|
<Body color="light">
|
108
|
-
{`${titleize(city)}, ${
|
114
|
+
{`${city ? `${titleize(city)}, ` : ''}${uppercaseState}${zipcode ? ` ${zipcode}` : ''}`}
|
109
115
|
</Body>
|
110
116
|
</div>
|
111
117
|
}
|
112
|
-
{emphasis == 'city' &&
|
118
|
+
{emphasis == 'city' && !hasAllEmptyProps &&
|
113
119
|
<div>
|
114
120
|
<Body color="light">
|
115
121
|
{joinPresent([formatStreetAdr(address), houseStyle], ' · ')}
|
@@ -122,18 +128,18 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
|
|
122
128
|
size={4}
|
123
129
|
tag="span"
|
124
130
|
>
|
125
|
-
{`${titleize(city)}, ${
|
131
|
+
{`${city ? `${titleize(city)}, ` : ''}${uppercaseState}`}
|
126
132
|
</Title>
|
127
133
|
<Body
|
128
134
|
color="light"
|
129
135
|
tag="span"
|
130
136
|
>
|
131
|
-
{` ${zipcode}`}
|
137
|
+
{` ${zipcode ?? ''}`}
|
132
138
|
</Body>
|
133
139
|
</div>
|
134
140
|
</div>
|
135
141
|
}
|
136
|
-
{emphasis == 'none' &&
|
142
|
+
{emphasis == 'none' && !hasAllEmptyProps &&
|
137
143
|
<div>
|
138
144
|
<Body dark={dark}>
|
139
145
|
{joinPresent([formatStreetAdr(address), houseStyle], ' · ')}
|
@@ -144,7 +150,7 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
|
|
144
150
|
color="light"
|
145
151
|
dark={dark}
|
146
152
|
>
|
147
|
-
{`${titleize(city)}, ${
|
153
|
+
{`${city ? `${titleize(city)}, ` : ''}${uppercaseState}${zipcode ? ` ${zipcode}` : ''}`}
|
148
154
|
</Body>
|
149
155
|
</div>
|
150
156
|
</div>
|
@@ -41,6 +41,16 @@ const Person = (props: PersonProps): React.ReactElement => {
|
|
41
41
|
className
|
42
42
|
)
|
43
43
|
|
44
|
+
const hasAllEmptyProps = [firstName, lastName].every(field => field === undefined || field === null || field === '')
|
45
|
+
|
46
|
+
if (hasAllEmptyProps) {
|
47
|
+
return (
|
48
|
+
<>
|
49
|
+
—
|
50
|
+
</>
|
51
|
+
)
|
52
|
+
}
|
53
|
+
|
44
54
|
return (
|
45
55
|
<div
|
46
56
|
{...ariaProps}
|
@@ -53,13 +63,13 @@ const Person = (props: PersonProps): React.ReactElement => {
|
|
53
63
|
className="pb_person_first"
|
54
64
|
tag="span"
|
55
65
|
>
|
56
|
-
{firstName}
|
66
|
+
{firstName ?? ''}
|
57
67
|
</Body>
|
58
68
|
{lastName &&
|
59
69
|
<Title
|
60
70
|
className="pb_person_first"
|
61
71
|
size={4}
|
62
|
-
text={` ${lastName}`}
|
72
|
+
text={lastName ? ` ${lastName}` : ''}
|
63
73
|
/>
|
64
74
|
}
|
65
75
|
</div>
|