playbook_ui 14.9.0.pre.alpha.play1742globalheightfixes4766 → 14.9.0.pre.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +17 -61
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -3
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -15
- data/app/pb_kits/playbook/pb_background/_background.tsx +2 -8
- data/app/pb_kits/playbook/pb_button/_button.scss +0 -6
- data/app/pb_kits/playbook/pb_button/_button.tsx +3 -1
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +0 -15
- data/app/pb_kits/playbook/pb_button/button.rb +1 -1
- data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +0 -8
- data/app/pb_kits/playbook/pb_button/docs/_button_default.md +1 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +2 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +4 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +7 -84
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +1 -3
- data/app/pb_kits/playbook/pb_currency/_currency.tsx +3 -7
- data/app/pb_kits/playbook/pb_currency/currency.html.erb +2 -2
- data/app/pb_kits/playbook/pb_currency/currency.rb +1 -17
- data/app/pb_kits/playbook/pb_currency/currency.test.js +3 -40
- data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_currency/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +0 -1
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +45 -159
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_drawer/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +1 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +4 -0
- data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +2 -13
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +12 -63
- data/app/pb_kits/playbook/pb_image/_image.tsx +1 -3
- data/app/pb_kits/playbook/pb_layout/_layout.tsx +14 -36
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -3
- data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +2 -2
- data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.tsx +3 -5
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +2 -3
- data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +0 -5
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +1 -3
- data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +1 -2
- data/app/pb_kits/playbook/pb_table/_table.tsx +25 -109
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +0 -2
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +0 -47
- data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +0 -59
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -3
- data/app/pb_kits/playbook/pb_typeahead/index.ts +3 -29
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +0 -4
- data/app/pb_kits/playbook/utilities/_max_width.scss +9 -29
- data/app/pb_kits/playbook/utilities/_min_width.scss +2 -6
- data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -1
- data/app/pb_kits/playbook/utilities/globalProps.ts +4 -37
- data/dist/chunks/_typeahead-D0PihN_3.js +22 -0
- data/dist/chunks/_weekday_stacked-uMIX8f-A.js +45 -0
- data/dist/chunks/{lib-SyD3buPZ.js → lib-BC6ESsxG.js} +1 -1
- data/dist/chunks/{pb_form_validation-Dt8UJgrJ.js → pb_form_validation-B_Z9rEbg.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +0 -321
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/classnames.rb +0 -4
- data/lib/playbook/forms/builder/typeahead_field.rb +0 -13
- data/lib/playbook/kit_base.rb +1 -16
- data/lib/playbook/spacing.rb +0 -21
- data/lib/playbook/version.rb +2 -2
- metadata +6 -28
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.html.erb +0 -53
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.md +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -50
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md +0 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +0 -57
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +0 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_pagination_mock_data.json +0 -5600
- data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.html.erb +0 -4
- data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.jsx +0 -16
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +0 -31
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +0 -6
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +0 -87
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +0 -2
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +0 -4
- data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +0 -18
- data/app/pb_kits/playbook/tokens/_height.scss +0 -19
- data/app/pb_kits/playbook/tokens/exports/_height.module.scss +0 -37
- data/app/pb_kits/playbook/utilities/_height.scss +0 -33
- data/app/pb_kits/playbook/utilities/_width.scss +0 -45
- data/dist/chunks/_typeahead-B8fkIeXA.js +0 -22
- data/dist/chunks/_weekday_stacked-DjRTXEi-.js +0 -45
- data/lib/playbook/height.rb +0 -29
- data/lib/playbook/max_height.rb +0 -29
- data/lib/playbook/min_height.rb +0 -29
@@ -9,7 +9,6 @@ examples:
|
|
9
9
|
- currency_matching_decimals: Matching Decimals
|
10
10
|
- currency_unstyled: Unstyled
|
11
11
|
- currency_comma_separator: Comma Separator
|
12
|
-
- currency_negative: Negative
|
13
12
|
|
14
13
|
react:
|
15
14
|
- currency_variants: Variants
|
@@ -20,7 +19,6 @@ examples:
|
|
20
19
|
- currency_matching_decimals: Matching Decimals
|
21
20
|
- currency_unstyled: Unstyled
|
22
21
|
- currency_comma_separator: Comma Separator
|
23
|
-
- currency_negative: Negative
|
24
22
|
|
25
23
|
swift:
|
26
24
|
- currency_size_swift: Size
|
@@ -6,4 +6,3 @@ export { default as CurrencyAbbreviated } from './_currency_abbreviated.jsx'
|
|
6
6
|
export { default as CurrencyMatchingDecimals } from './_currency_matching_decimals.jsx'
|
7
7
|
export { default as CurrencyUnstyled } from './_currency_unstyled.jsx'
|
8
8
|
export { default as CurrencyCommaSeparator } from './_currency_comma_separator.jsx'
|
9
|
-
export { default as CurrencyNegative } from './_currency_negative.jsx'
|
@@ -7,7 +7,7 @@ import {
|
|
7
7
|
buildDataProps,
|
8
8
|
buildHtmlProps,
|
9
9
|
} from "../utilities/props";
|
10
|
-
import { globalProps
|
10
|
+
import { globalProps } from "../utilities/globalProps";
|
11
11
|
|
12
12
|
import { DialogContext } from "../pb_dialog/_dialog_context";
|
13
13
|
|
@@ -15,22 +15,20 @@ type DrawerProps = {
|
|
15
15
|
aria?: { [key: string]: string };
|
16
16
|
behavior?: "floating" | "push";
|
17
17
|
border?: "full" | "none" | "right" | "left";
|
18
|
-
|
19
|
-
closeBreakpoint?: "none" | "xs" | "sm" | "md" | "lg" | "xl";
|
18
|
+
breakpoint?: "none" | "xs" | "sm" | "md" | "lg" | "xl";
|
20
19
|
children: React.ReactNode | React.ReactNode[] | string;
|
21
20
|
className?: string;
|
22
21
|
data?: { [key: string]: string };
|
23
22
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) };
|
24
23
|
id?: string;
|
25
24
|
fullHeight?: boolean;
|
26
|
-
menuButtonID?: string;
|
27
25
|
onClose?: () => void;
|
28
26
|
opened: boolean;
|
29
27
|
overlay: boolean;
|
30
28
|
placement?: "left" | "right";
|
31
29
|
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
32
30
|
text?: string;
|
33
|
-
|
31
|
+
trigger?: string;
|
34
32
|
};
|
35
33
|
|
36
34
|
const Drawer = (props: DrawerProps): React.ReactElement => {
|
@@ -38,21 +36,19 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
38
36
|
aria = {},
|
39
37
|
behavior = "floating",
|
40
38
|
border = "none",
|
41
|
-
|
42
|
-
closeBreakpoint = "none",
|
39
|
+
breakpoint = "none",
|
43
40
|
className,
|
44
41
|
data = {},
|
45
42
|
htmlOptions = {},
|
46
43
|
id,
|
47
44
|
size = "md",
|
48
45
|
children,
|
49
|
-
fullHeight =
|
50
|
-
menuButtonID,
|
46
|
+
fullHeight = false,
|
51
47
|
opened,
|
52
48
|
onClose,
|
53
49
|
overlay = true,
|
54
50
|
placement = "left",
|
55
|
-
|
51
|
+
trigger,
|
56
52
|
} = props;
|
57
53
|
const ariaProps = buildAriaProps(aria);
|
58
54
|
const dataProps = buildDataProps(data);
|
@@ -84,7 +80,6 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
84
80
|
drawer_border_full: border === "full",
|
85
81
|
drawer_border_right: border === "right",
|
86
82
|
drawer_border_left: border === "left",
|
87
|
-
pb_drawer_within_element: withinElement,
|
88
83
|
}
|
89
84
|
)} ${globalPropsString}`,
|
90
85
|
afterOpen: "pb_drawer_after_open",
|
@@ -105,11 +100,10 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
105
100
|
};
|
106
101
|
|
107
102
|
const classes = classnames(buildCss("pb_drawer_wrapper"), className);
|
108
|
-
|
109
|
-
const [menuButtonOpened, setMenuButtonOpened] = useState(false);
|
103
|
+
|
110
104
|
const [triggerOpened, setTriggerOpened] = useState(false);
|
111
105
|
|
112
|
-
const breakpointWidths: Record<DrawerProps["
|
106
|
+
const breakpointWidths: Record<DrawerProps["breakpoint"], number> = {
|
113
107
|
none: 0,
|
114
108
|
xs: 575,
|
115
109
|
sm: 768,
|
@@ -118,30 +112,20 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
118
112
|
xl: 1400,
|
119
113
|
};
|
120
114
|
|
121
|
-
|
122
|
-
|
123
|
-
xs: 575,
|
124
|
-
sm: 768,
|
125
|
-
md: 992,
|
126
|
-
lg: 1200,
|
127
|
-
xl: 1400,
|
128
|
-
}
|
129
|
-
|
130
|
-
const [isOpenBreakpointOpen, setIsOpenBreakpointOpen] = useState(false);
|
131
|
-
const [isUserClosed, setIsUserClosed] = useState(false);
|
115
|
+
// State to manage opening the drawer based on breakpoint
|
116
|
+
const [isBreakpointOpen, setIsBreakpointOpen] = useState(false);
|
132
117
|
|
133
118
|
useEffect(() => {
|
134
|
-
if (
|
119
|
+
if (breakpoint === "none") return;
|
135
120
|
|
136
121
|
const handleResize = () => {
|
137
122
|
const width = window.innerWidth;
|
138
|
-
const
|
123
|
+
const breakpointWidth = breakpointWidths[breakpoint];
|
139
124
|
|
140
|
-
if (width <=
|
141
|
-
|
125
|
+
if (width <= breakpointWidth) {
|
126
|
+
setIsBreakpointOpen(true);
|
142
127
|
} else {
|
143
|
-
|
144
|
-
setIsUserClosed(false); // Reset when the breakpoint condition changes
|
128
|
+
setIsBreakpointOpen(false);
|
145
129
|
}
|
146
130
|
};
|
147
131
|
|
@@ -153,53 +137,9 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
153
137
|
return () => {
|
154
138
|
window.removeEventListener("resize", handleResize);
|
155
139
|
};
|
156
|
-
}, [
|
157
|
-
|
158
|
-
useEffect(() => {
|
159
|
-
if (closeBreakpoint === "none") return;
|
140
|
+
}, [breakpoint]);
|
160
141
|
|
161
|
-
|
162
|
-
const width = window.innerWidth;
|
163
|
-
if (width >= breakpointValues[closeBreakpoint]) {
|
164
|
-
setIsOpenBreakpointOpen(true);
|
165
|
-
} else {
|
166
|
-
setIsOpenBreakpointOpen(false);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
window.addEventListener("resize", handleResize);
|
171
|
-
|
172
|
-
handleResize();
|
173
|
-
|
174
|
-
return () => {
|
175
|
-
window.removeEventListener("resize", handleResize);
|
176
|
-
};
|
177
|
-
|
178
|
-
}, [closeBreakpoint]);
|
179
|
-
|
180
|
-
//hide menu button if breakpoint opens the drawer
|
181
|
-
useEffect(() => {
|
182
|
-
if (menuButtonID) {
|
183
|
-
const menuButton = document.getElementById(menuButtonID);
|
184
|
-
if (menuButton) {
|
185
|
-
if (isOpenBreakpointOpen) {
|
186
|
-
menuButton.style.display = 'none';
|
187
|
-
} else {
|
188
|
-
menuButton.style.display = '';
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}, [menuButtonID, isOpenBreakpointOpen]);
|
193
|
-
|
194
|
-
// Reset isUserClosed when isBreakpointOpen changes
|
195
|
-
useEffect(() => {
|
196
|
-
if (isOpenBreakpointOpen) {
|
197
|
-
setIsUserClosed(false);
|
198
|
-
}
|
199
|
-
}, [isOpenBreakpointOpen]);
|
200
|
-
|
201
|
-
const modalIsOpened =
|
202
|
-
(isOpenBreakpointOpen && !isUserClosed) || menuButtonOpened || opened;
|
142
|
+
const modalIsOpened = trigger ? triggerOpened : opened || isBreakpointOpen;
|
203
143
|
|
204
144
|
const [animationState, setAnimationState] = useState("");
|
205
145
|
|
@@ -210,15 +150,13 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
210
150
|
setAnimationState("beforeClose");
|
211
151
|
setTimeout(() => {
|
212
152
|
setAnimationState("");
|
213
|
-
}, 200);
|
153
|
+
}, 200); // closeTimeoutMS
|
214
154
|
}
|
215
155
|
}, [modalIsOpened]);
|
216
156
|
|
217
157
|
const isModalVisible = modalIsOpened || animationState === "beforeClose";
|
218
158
|
|
219
159
|
useEffect(() => {
|
220
|
-
if (withinElement) return;
|
221
|
-
|
222
160
|
const sizeMap: Record<DrawerProps["size"], string> = {
|
223
161
|
xl: "365px",
|
224
162
|
lg: "300px",
|
@@ -227,6 +165,7 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
227
165
|
xs: "64px",
|
228
166
|
};
|
229
167
|
const body = document.querySelector("body");
|
168
|
+
|
230
169
|
if (modalIsOpened && behavior === "push" && body) {
|
231
170
|
if (placement === "left") {
|
232
171
|
body.style.cssText = `margin-left: ${sizeMap[size]} !important; margin-right: '' !important;`;
|
@@ -242,98 +181,45 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
242
181
|
body.style.cssText = ""; // Clear the styles when modal is closed or behavior is not 'push'
|
243
182
|
body.classList.remove("PBDrawer__Body--open");
|
244
183
|
}
|
245
|
-
}, [modalIsOpened, behavior, placement, size
|
184
|
+
}, [modalIsOpened, behavior, placement, size]);
|
246
185
|
|
247
186
|
const api = {
|
248
|
-
onClose:
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
if (onClose) {
|
254
|
-
onClose();
|
255
|
-
}
|
256
|
-
},
|
187
|
+
onClose: trigger
|
188
|
+
? function () {
|
189
|
+
setTriggerOpened(false);
|
190
|
+
}
|
191
|
+
: onClose,
|
257
192
|
};
|
258
193
|
|
259
|
-
useEffect(() => {
|
260
|
-
if (menuButtonID) {
|
261
|
-
const menuButton = document.getElementById(menuButtonID);
|
262
|
-
if (menuButton) {
|
263
|
-
const handleMenuButtonClick = () => {
|
264
|
-
if (modalIsOpened) {
|
265
|
-
// Drawer is open, close it
|
266
|
-
setMenuButtonOpened(false);
|
267
|
-
setIsUserClosed(true);
|
268
|
-
} else {
|
269
|
-
// Drawer is closed, open it
|
270
|
-
setMenuButtonOpened(true);
|
271
|
-
setIsUserClosed(false);
|
272
|
-
}
|
273
|
-
};
|
274
|
-
menuButton.addEventListener("click", handleMenuButtonClick);
|
275
|
-
return () => {
|
276
|
-
menuButton.removeEventListener("click", handleMenuButtonClick);
|
277
|
-
};
|
278
|
-
}
|
279
|
-
}
|
280
|
-
}, [menuButtonID, modalIsOpened]);
|
281
|
-
|
282
194
|
return (
|
283
195
|
<DialogContext.Provider value={api}>
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
className={classnames(drawerClassNames.base, {
|
291
|
-
[drawerClassNames.afterOpen]:
|
292
|
-
animationState === "afterOpen",
|
293
|
-
[drawerClassNames.beforeClose]:
|
294
|
-
animationState === "beforeClose",
|
295
|
-
})}
|
296
|
-
id={id}
|
297
|
-
onClick={(e) => e.stopPropagation()}
|
298
|
-
style={dynamicInlineProps}
|
299
|
-
>
|
300
|
-
{children}
|
301
|
-
</div>
|
302
|
-
)
|
303
|
-
) : (
|
304
|
-
<div
|
305
|
-
{...ariaProps}
|
306
|
-
{...dataProps}
|
307
|
-
{...htmlProps}
|
308
|
-
className={classes}
|
309
|
-
>
|
196
|
+
<div
|
197
|
+
{...ariaProps}
|
198
|
+
{...dataProps}
|
199
|
+
{...htmlProps}
|
200
|
+
className={classes}
|
201
|
+
>
|
310
202
|
{isModalVisible && (
|
311
203
|
<div
|
312
204
|
className={classnames(overlayClassNames.base, {
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
animationState === "beforeClose",
|
317
|
-
})}
|
205
|
+
[overlayClassNames.afterOpen]: animationState === "afterOpen",
|
206
|
+
[overlayClassNames.beforeClose]: animationState === "beforeClose",
|
207
|
+
})}
|
318
208
|
id={id}
|
319
|
-
onClick={overlay ?
|
209
|
+
onClick={overlay ? onClose : undefined}
|
320
210
|
>
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
>
|
331
|
-
{children}
|
332
|
-
</div>
|
211
|
+
<div
|
212
|
+
className={classnames(drawerClassNames.base, {
|
213
|
+
[drawerClassNames.afterOpen]: animationState === "afterOpen",
|
214
|
+
[drawerClassNames.beforeClose]: animationState === "beforeClose",
|
215
|
+
})}
|
216
|
+
onClick={(e) => e.stopPropagation()}
|
217
|
+
>
|
218
|
+
{children}
|
219
|
+
</div>
|
333
220
|
</div>
|
334
221
|
)}
|
335
|
-
|
336
|
-
)}
|
222
|
+
</div>
|
337
223
|
</DialogContext.Provider>
|
338
224
|
);
|
339
225
|
};
|
@@ -3,4 +3,3 @@ export { default as DrawerSizes } from './_drawer_sizes.jsx'
|
|
3
3
|
export { default as DrawerOverlay } from './_drawer_overlay.jsx'
|
4
4
|
export { default as DrawerBorders } from './_drawer_borders.jsx'
|
5
5
|
export { default as DrawerBreakpoints } from './_drawer_breakpoints.jsx'
|
6
|
-
export { default as DrawerMenu } from './_drawer_menu.jsx'
|
@@ -18,19 +18,9 @@ export const separateChildComponents = (children: React.ReactChild[] | React.Rea
|
|
18
18
|
const otherChildren: React.ReactChild[] = [];
|
19
19
|
|
20
20
|
React.Children.forEach(children, (child) => {
|
21
|
-
|
22
|
-
const childType = element?.type;
|
23
|
-
const childDisplayName = (childType as any)?.displayName || (childType as any)?.name;
|
24
|
-
|
25
|
-
if (
|
26
|
-
childType === DropdownTrigger ||
|
27
|
-
childDisplayName === "DropdownTrigger"
|
28
|
-
) {
|
21
|
+
if (child && (child as ReactElement).type === DropdownTrigger) {
|
29
22
|
trigger = child;
|
30
|
-
} else if (
|
31
|
-
childType === DropdownContainer ||
|
32
|
-
childDisplayName === "DropdownContainer"
|
33
|
-
) {
|
23
|
+
} else if (child && (child as ReactElement).type === DropdownContainer) {
|
34
24
|
container = child;
|
35
25
|
} else {
|
36
26
|
otherChildren.push(child);
|
@@ -40,7 +30,6 @@ export const separateChildComponents = (children: React.ReactChild[] | React.Rea
|
|
40
30
|
return { trigger, container, otherChildren };
|
41
31
|
};
|
42
32
|
|
43
|
-
|
44
33
|
export const prepareSubcomponents = ({
|
45
34
|
children,
|
46
35
|
hasTriggerSubcomponent,
|
@@ -23,7 +23,7 @@
|
|
23
23
|
%>
|
24
24
|
|
25
25
|
<%= pb_form_with(scope: :example, url: "", method: :get) do |form| %>
|
26
|
-
<%= form.typeahead :
|
26
|
+
<%= form.typeahead :example_user, props: { data: { typeahead_example1: true, user: {} }, placeholder: "Search for a user" } %>
|
27
27
|
<%= form.text_field :example_text_field, props: { label: true } %>
|
28
28
|
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
|
29
29
|
<%= form.email_field :example_email_field, props: { label: true } %>
|
@@ -92,7 +92,7 @@
|
|
92
92
|
const selectedUserData = JSON.parse(selectedUserJSON)
|
93
93
|
|
94
94
|
// set the input field's value
|
95
|
-
event.target.querySelector('input[name=
|
95
|
+
event.target.querySelector('input[name=example_user]').value = selectedUserData.login
|
96
96
|
|
97
97
|
// log the selected option's dataset
|
98
98
|
console.log('The selected user data:')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= pb_form_with(scope: :example, url: "", method: :get, loading: true) do |form| %>
|
2
|
-
<%= form.text_field :
|
2
|
+
<%= form.text_field :example_text_field, props: { label: true } %>
|
3
3
|
|
4
4
|
<%= form.actions do |action| %>
|
5
5
|
<%= action.submit %>
|
@@ -22,74 +22,23 @@
|
|
22
22
|
%>
|
23
23
|
|
24
24
|
<%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
|
25
|
-
<%= form.
|
26
|
-
<%= form.
|
27
|
-
<%= form.
|
28
|
-
<%= form.
|
29
|
-
<%= form.
|
30
|
-
<%= form.
|
31
|
-
<%= form.
|
32
|
-
<%= form.
|
33
|
-
<%= form.
|
34
|
-
<%= form.
|
35
|
-
<%= form.
|
36
|
-
<%= form.collection_select :example_collection_select_validation, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
25
|
+
<%= form.text_field :example_text_field, props: { label: true, required: true } %>
|
26
|
+
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
|
27
|
+
<%= form.email_field :example_email_field, props: { label: true, required: true } %>
|
28
|
+
<%= form.number_field :example_number_field, props: { label: true, required: true } %>
|
29
|
+
<%= form.search_field :example_project_number, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
|
30
|
+
<%= form.password_field :example_password_field, props: { label: true, required: true } %>
|
31
|
+
<%= form.url_field :example_url_field, props: { label: true, required: true } %>
|
32
|
+
<%= form.text_area :example_text_area, props: { label: true, required: true } %>
|
33
|
+
<%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options, required: true } %>
|
34
|
+
<%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
|
35
|
+
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
37
36
|
<%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
|
38
37
|
<%= form.date_picker :example_date_picker_2, props: { label: true, required: true } %>
|
39
|
-
<%= form.star_rating_field :
|
38
|
+
<%= form.star_rating_field :example_star_rating, props: { variant: "interactive", label: true, required: true } %>
|
40
39
|
|
41
40
|
<%= form.actions do |action| %>
|
42
41
|
<%= action.submit %>
|
43
42
|
<%= action.button props: { type: "reset", text: "Cancel", variant: "secondary" } %>
|
44
43
|
<% end %>
|
45
44
|
<% end %>
|
46
|
-
|
47
|
-
<!-- form.typeahead user results example template -->
|
48
|
-
<template data-typeahead-example-result-option>
|
49
|
-
<%= pb_rails("user", props: {
|
50
|
-
name: tag(:slot, name: "name"),
|
51
|
-
orientation: "horizontal",
|
52
|
-
align: "left",
|
53
|
-
avatar_url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGP6zwAAAgcBApocMXEAAAAASUVORK5CYII=",
|
54
|
-
avatar: true
|
55
|
-
}) %>
|
56
|
-
</template>
|
57
|
-
|
58
|
-
<!-- form.typeahead JS example implementation -->
|
59
|
-
<%= javascript_tag defer: "defer" do %>
|
60
|
-
document.addEventListener("pb-typeahead-kit-search", function(event) {
|
61
|
-
if (!event.target.dataset || !event.target.dataset.typeaheadExample2) return
|
62
|
-
|
63
|
-
fetch(`https://api.github.com/search/users?q=${encodeURIComponent(event.detail.searchingFor)}`)
|
64
|
-
.then(response => response.json())
|
65
|
-
.then((result) => {
|
66
|
-
const resultOptionTemplate = document.querySelector("[data-typeahead-example-result-option]")
|
67
|
-
|
68
|
-
event.detail.setResults((result.items || []).map((user) => {
|
69
|
-
const wrapper = resultOptionTemplate.content.cloneNode(true)
|
70
|
-
wrapper.children[0].dataset.user = JSON.stringify(user)
|
71
|
-
wrapper.querySelector('slot[name="name"]').replaceWith(user.login)
|
72
|
-
wrapper.querySelector('img').dataset.src = user.avatar_url
|
73
|
-
return wrapper
|
74
|
-
}))
|
75
|
-
})
|
76
|
-
})
|
77
|
-
|
78
|
-
|
79
|
-
document.addEventListener("pb-typeahead-kit-result-option-selected", function(event) {
|
80
|
-
if (!event.target.dataset.typeaheadExample2) return
|
81
|
-
|
82
|
-
const selectedUserJSON = event.detail.selected.firstElementChild.dataset.user
|
83
|
-
const selectedUserData = JSON.parse(selectedUserJSON)
|
84
|
-
|
85
|
-
// set the input field's value
|
86
|
-
event.target.querySelector('input[name=example_typeahead_validation]').value = selectedUserData.login
|
87
|
-
|
88
|
-
// log the selected option's dataset
|
89
|
-
console.log('The selected user data:')
|
90
|
-
console.dir(selectedUserData)
|
91
|
-
|
92
|
-
// do even more with the data later - TBD
|
93
|
-
event.target.dataset.user = selectedUserJSON
|
94
|
-
})
|
95
|
-
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import classnames from 'classnames'
|
3
|
-
import { GlobalProps, globalProps
|
3
|
+
import { GlobalProps, globalProps } from '../utilities/globalProps'
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
5
5
|
|
6
6
|
type ImageType = {
|
@@ -41,7 +41,6 @@ const Image = (props: ImageType): React.ReactElement => {
|
|
41
41
|
globalProps(props),
|
42
42
|
className
|
43
43
|
)
|
44
|
-
const dynamicInlineProps = globalInlineProps(props)
|
45
44
|
const dataProps = buildDataProps(data)
|
46
45
|
const htmlProps = buildHtmlProps(htmlOptions)
|
47
46
|
|
@@ -57,7 +56,6 @@ const Image = (props: ImageType): React.ReactElement => {
|
|
57
56
|
id={id}
|
58
57
|
onError={onError}
|
59
58
|
src={url}
|
60
|
-
style={dynamicInlineProps}
|
61
59
|
/>
|
62
60
|
)
|
63
61
|
}
|