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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fa79ee278fc38b79bf8ba0d013868027d1b9b26029ccb1cf2f173b2a7797c83
4
- data.tar.gz: 9e914077f1ad480c8f7ffa9bb65a6828a7b9a887d7b8b3e536bacfa5ab7c5a6e
3
+ metadata.gz: 66a8f9dbc6655bfe62d658f083e7e454993db3296e9fba0cad13f5cd4ead03ca
4
+ data.tar.gz: b711491996fcba25839cdab82233d5a5915d546607501f5d043de0a8ed926aa3
5
5
  SHA512:
6
- metadata.gz: 4ef970a5758c8caf8a18b1d242eaf93c406318aaa676c2515200ed8e35fb8391de2acb7c2bc22f9350d6dd8555e26707fcdae48d0b779ee50372d35606364f86
7
- data.tar.gz: 1b0da522bd01978c4087c086cc6ec8d0066296696a7c8ff82d26e74d6d126694c83f2b3fa7d39b2cafb97678a9f66a4a175864a8c534d273590a763c03b18171
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. The component passed to customDisplay will be rendered to the left of the default text-based display. In this example the Avatar kit is being used.
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("avatar", props: { name: "Courtney Long", size: "xs" })
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. The component passed to custom_display will be rendered to the left of the default text-based display. In this example the Avatar kit is being used.
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
- triggerElement.textContent = selectedLabel;
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";
@@ -73,7 +73,7 @@ const DropdownTrigger = (props: DropdownTriggerProps) => {
73
73
  );
74
74
 
75
75
  const customDisplayPlaceholder = selected?.label ? (
76
- <b>{selected.label}</b>
76
+ ""
77
77
  ) : autocomplete ? (
78
78
  ""
79
79
  ) : placeholder ? (
@@ -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
- {emphasis == 'street' &&
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)}, ${state.toUpperCase()} ${zipcode}`}
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)}, ${state.toUpperCase()}`}
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)}, ${state.toUpperCase()} ${zipcode}`}
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>