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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -2
  3. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +17 -61
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +1 -1
  6. data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +0 -3
  7. data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +0 -2
  8. data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +1 -3
  9. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +0 -15
  10. data/app/pb_kits/playbook/pb_background/_background.tsx +2 -8
  11. data/app/pb_kits/playbook/pb_button/_button.scss +0 -6
  12. data/app/pb_kits/playbook/pb_button/_button.tsx +3 -1
  13. data/app/pb_kits/playbook/pb_button/_button_mixins.scss +0 -15
  14. data/app/pb_kits/playbook/pb_button/button.rb +1 -1
  15. data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +0 -1
  16. data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +0 -8
  17. data/app/pb_kits/playbook/pb_button/docs/_button_default.md +1 -1
  18. data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +2 -2
  19. data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +4 -0
  20. data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_indeterminate.html.erb +7 -84
  21. data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +1 -3
  22. data/app/pb_kits/playbook/pb_currency/_currency.tsx +3 -7
  23. data/app/pb_kits/playbook/pb_currency/currency.html.erb +2 -2
  24. data/app/pb_kits/playbook/pb_currency/currency.rb +1 -17
  25. data/app/pb_kits/playbook/pb_currency/currency.test.js +3 -40
  26. data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -2
  27. data/app/pb_kits/playbook/pb_currency/docs/index.js +0 -1
  28. data/app/pb_kits/playbook/pb_drawer/_drawer.scss +0 -1
  29. data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +45 -159
  30. data/app/pb_kits/playbook/pb_drawer/docs/example.yml +1 -1
  31. data/app/pb_kits/playbook/pb_drawer/docs/index.js +0 -1
  32. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -1
  33. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +1 -0
  34. data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +4 -0
  35. data/app/pb_kits/playbook/pb_dropdown/utilities/subComponentHelper.tsx +2 -13
  36. data/app/pb_kits/playbook/pb_form/docs/_form_form_with.html.erb +2 -2
  37. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_loading.html.erb +1 -1
  38. data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +12 -63
  39. data/app/pb_kits/playbook/pb_image/_image.tsx +1 -3
  40. data/app/pb_kits/playbook/pb_layout/_layout.tsx +14 -36
  41. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -3
  42. data/app/pb_kits/playbook/pb_pagination/_pagination.tsx +2 -2
  43. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.tsx +3 -5
  44. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.html.erb +2 -3
  45. data/app/pb_kits/playbook/pb_progress_simple/progress_simple.rb +0 -5
  46. data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +1 -3
  47. data/app/pb_kits/playbook/pb_selectable_card/docs/_selectable_card_default.html.erb +1 -2
  48. data/app/pb_kits/playbook/pb_table/_table.tsx +25 -109
  49. data/app/pb_kits/playbook/pb_table/docs/index.js +0 -1
  50. data/app/pb_kits/playbook/pb_table/styles/_all.scss +0 -2
  51. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.html.erb +0 -47
  52. data/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_children.jsx +0 -59
  53. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +0 -3
  54. data/app/pb_kits/playbook/pb_typeahead/index.ts +3 -29
  55. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +2 -5
  56. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +0 -4
  57. data/app/pb_kits/playbook/utilities/_max_width.scss +9 -29
  58. data/app/pb_kits/playbook/utilities/_min_width.scss +2 -6
  59. data/app/pb_kits/playbook/utilities/globalPropNames.mjs +1 -1
  60. data/app/pb_kits/playbook/utilities/globalProps.ts +4 -37
  61. data/dist/chunks/_typeahead-D0PihN_3.js +22 -0
  62. data/dist/chunks/_weekday_stacked-uMIX8f-A.js +45 -0
  63. data/dist/chunks/{lib-SyD3buPZ.js → lib-BC6ESsxG.js} +1 -1
  64. data/dist/chunks/{pb_form_validation-Dt8UJgrJ.js → pb_form_validation-B_Z9rEbg.js} +1 -1
  65. data/dist/chunks/vendor.js +1 -1
  66. data/dist/menu.yml +0 -321
  67. data/dist/playbook-doc.js +1 -1
  68. data/dist/playbook-rails-react-bindings.js +1 -1
  69. data/dist/playbook-rails.js +1 -1
  70. data/dist/playbook.css +1 -1
  71. data/lib/playbook/classnames.rb +0 -4
  72. data/lib/playbook/forms/builder/typeahead_field.rb +0 -13
  73. data/lib/playbook/kit_base.rb +1 -16
  74. data/lib/playbook/spacing.rb +0 -21
  75. data/lib/playbook/version.rb +2 -2
  76. metadata +6 -28
  77. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.html.erb +0 -53
  78. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_custom_cell_rails.md +0 -5
  79. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.jsx +0 -50
  80. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination.md +0 -1
  81. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.jsx +0 -57
  82. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pagination_with_props.md +0 -5
  83. data/app/pb_kits/playbook/pb_advanced_table/docs/advanced_table_pagination_mock_data.json +0 -5600
  84. data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.html.erb +0 -4
  85. data/app/pb_kits/playbook/pb_currency/docs/_currency_negative.jsx +0 -16
  86. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +0 -31
  87. data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +0 -6
  88. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +0 -87
  89. data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +0 -2
  90. data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +0 -4
  91. data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +0 -18
  92. data/app/pb_kits/playbook/tokens/_height.scss +0 -19
  93. data/app/pb_kits/playbook/tokens/exports/_height.module.scss +0 -37
  94. data/app/pb_kits/playbook/utilities/_height.scss +0 -33
  95. data/app/pb_kits/playbook/utilities/_width.scss +0 -45
  96. data/dist/chunks/_typeahead-B8fkIeXA.js +0 -22
  97. data/dist/chunks/_weekday_stacked-DjRTXEi-.js +0 -45
  98. data/lib/playbook/height.rb +0 -29
  99. data/lib/playbook/max_height.rb +0 -29
  100. 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'
@@ -88,7 +88,6 @@ body.PBDrawer__Body--close {
88
88
  }
89
89
 
90
90
  .pb_drawer.pb_drawer_after_open {
91
- pointer-events: auto;
92
91
  transform: translate3d(0, 0, 0);
93
92
  }
94
93
 
@@ -7,7 +7,7 @@ import {
7
7
  buildDataProps,
8
8
  buildHtmlProps,
9
9
  } from "../utilities/props";
10
- import { globalProps, globalInlineProps } from "../utilities/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
- openBreakpoint?: "none" | "xs" | "sm" | "md" | "lg" | "xl";
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
- withinElement?: boolean;
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
- openBreakpoint = "none",
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 = true,
50
- menuButtonID,
46
+ fullHeight = false,
51
47
  opened,
52
48
  onClose,
53
49
  overlay = true,
54
50
  placement = "left",
55
- withinElement = false,
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
- const dynamicInlineProps = globalInlineProps(props)
109
- const [menuButtonOpened, setMenuButtonOpened] = useState(false);
103
+
110
104
  const [triggerOpened, setTriggerOpened] = useState(false);
111
105
 
112
- const breakpointWidths: Record<DrawerProps["openBreakpoint"], number> = {
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
- const breakpointValues = {
122
- none: 0,
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 (openBreakpoint === "none") return;
119
+ if (breakpoint === "none") return;
135
120
 
136
121
  const handleResize = () => {
137
122
  const width = window.innerWidth;
138
- const openBreakpointWidth = breakpointWidths[openBreakpoint];
123
+ const breakpointWidth = breakpointWidths[breakpoint];
139
124
 
140
- if (width <= openBreakpointWidth) {
141
- setIsOpenBreakpointOpen(true);
125
+ if (width <= breakpointWidth) {
126
+ setIsBreakpointOpen(true);
142
127
  } else {
143
- setIsOpenBreakpointOpen(false);
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
- }, [openBreakpoint]);
157
-
158
- useEffect(() => {
159
- if (closeBreakpoint === "none") return;
140
+ }, [breakpoint]);
160
141
 
161
- const handleResize = () => {
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, withinElement]);
184
+ }, [modalIsOpened, behavior, placement, size]);
246
185
 
247
186
  const api = {
248
- onClose: () => {
249
- if (menuButtonID) {
250
- setMenuButtonOpened(false);
251
- }
252
- setIsUserClosed(true);
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
- {withinElement ? (
285
- isModalVisible && (
286
- <div
287
- {...ariaProps}
288
- {...dataProps}
289
- {...htmlProps}
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
- [overlayClassNames.afterOpen]:
314
- animationState === "afterOpen",
315
- [overlayClassNames.beforeClose]:
316
- animationState === "beforeClose",
317
- })}
205
+ [overlayClassNames.afterOpen]: animationState === "afterOpen",
206
+ [overlayClassNames.beforeClose]: animationState === "beforeClose",
207
+ })}
318
208
  id={id}
319
- onClick={overlay ? api.onClose : undefined}
209
+ onClick={overlay ? onClose : undefined}
320
210
  >
321
- <div
322
- className={classnames(drawerClassNames.base, {
323
- [drawerClassNames.afterOpen]:
324
- animationState === "afterOpen",
325
- [drawerClassNames.beforeClose]:
326
- animationState === "beforeClose",
327
- })}
328
- onClick={(e) => e.stopPropagation()}
329
- style={dynamicInlineProps}
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
- </div>
336
- )}
222
+ </div>
337
223
  </DialogContext.Provider>
338
224
  );
339
225
  };
@@ -6,7 +6,7 @@ examples:
6
6
 
7
7
  react:
8
8
  - drawer_default: Default
9
- - drawer_menu: Menu Behavior
10
9
  - drawer_sizes: Sizes
11
10
  - drawer_overlay: Overlay
12
11
  - drawer_borders: Borders
12
+ - drawer_breakpoints: Open on Breakpoints
@@ -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'
@@ -53,7 +53,6 @@
53
53
  }
54
54
 
55
55
  .pb_dropdown_container {
56
- position: absolute;
57
56
  background-color: $white;
58
57
  overflow: hidden;
59
58
  box-shadow: $shadow_deep;
@@ -3,6 +3,7 @@
3
3
  class: object.classname,
4
4
  data: object.data,
5
5
  id: object.id,
6
+ style: object.container_style,
6
7
  **combined_html_options) do %>
7
8
  <%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
8
9
  <% if content.present? %>
@@ -7,6 +7,10 @@ module Playbook
7
7
  generate_classname("pb_dropdown_container", "close", separator: " ")
8
8
  end
9
9
 
10
+ def container_style
11
+ "position: absolute"
12
+ end
13
+
10
14
  def data
11
15
  Hash(prop(:data)).merge(dropdown_container: true)
12
16
  end
@@ -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
- const element = child as ReactElement;
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 :example_typeahead, props: { data: { typeahead_example1: true, user: {} }, label: true, placeholder: "Search for a user" } %>
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=example_typeahead]').value = selectedUserData.login
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 :example_text_field_loading, props: { label: true } %>
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.typeahead :example_typeahead_validation, props: { data: { typeahead_example2: true, user: {} }, label: true, placeholder: "Search for a user", required: true, validation: { message: "Please select a user." } } %>
26
- <%= form.text_field :example_text_field_validation, props: { label: true, required: true } %>
27
- <%= form.phone_number_field :example_phone_number_field_validation, props: { label: "Example phone field" } %>
28
- <%= form.email_field :example_email_field_validation, props: { label: true, required: true } %>
29
- <%= form.number_field :example_number_field_validation, props: { label: true, required: true } %>
30
- <%= form.search_field :example_project_number_validation, props: { label: true, required: true, validation: { pattern: "[0-9]{2}-[0-9]{5}", message: "Please enter a valid project number (example: 33-12345)." } } %>
31
- <%= form.password_field :example_password_field_validation, props: { label: true, required: true } %>
32
- <%= form.url_field :example_url_field_validation, props: { label: true, required: true } %>
33
- <%= form.text_area :example_text_area_validation, props: { label: true, required: true } %>
34
- <%= form.dropdown_field :example_dropdown_validation, props: { label: true, options: example_dropdown_options, required: true } %>
35
- <%= form.select :example_select_validation, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
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 :example_star_rating_validation, props: { variant: "interactive", label: true, required: true } %>
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, globalInlineProps } from '../utilities/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
  }