playbook_ui 14.15.0.pre.alpha.play1854reacthookmultilvlselect6572 → 14.15.0.pre.alpha.play1910emptystatekitreactbeta6579

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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +4 -2
  3. data/app/pb_kits/playbook/pb_empty_state/_empty_state.scss +38 -0
  4. data/app/pb_kits/playbook/pb_empty_state/_empty_state.tsx +199 -0
  5. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_alignment.jsx +38 -0
  6. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_orientation.jsx +19 -0
  7. data/app/pb_kits/playbook/pb_empty_state/docs/_empty_state_size.jsx +35 -0
  8. data/app/pb_kits/playbook/pb_empty_state/docs/example.yml +7 -0
  9. data/app/pb_kits/playbook/pb_empty_state/docs/index.js +3 -0
  10. data/app/pb_kits/playbook/pb_empty_state/empty_state.test.jsx +17 -0
  11. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +5 -20
  12. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +0 -1
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +0 -1
  14. data/dist/chunks/{_typeahead-DKSD8vAY.js → _typeahead-D2Wtk1Vx.js} +1 -1
  15. data/dist/chunks/_weekday_stacked-toeDpRDd.js +45 -0
  16. data/dist/chunks/vendor.js +1 -1
  17. data/dist/menu.yml +8 -0
  18. data/dist/playbook-doc.js +1 -1
  19. data/dist/playbook-rails-react-bindings.js +1 -1
  20. data/dist/playbook-rails.js +1 -1
  21. data/dist/playbook.css +1 -1
  22. data/lib/playbook/version.rb +1 -1
  23. metadata +11 -5
  24. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +0 -91
  25. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +0 -1
  26. data/dist/chunks/_weekday_stacked-C-GXG8yh.js +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 490e06dd4cafd132cf385ecbb9c648ba507870bc063cbcd04f3c079be70dad6e
4
- data.tar.gz: 5bdf49498aca37b53ca14af0895ad20676e22bebdb97d988c8f2e9f9ed8e300a
3
+ metadata.gz: a4b6fab9ece5fae4518e897b8210410b09d0e556020f43189ba301003be177e1
4
+ data.tar.gz: e0edb633f206fa6120fc1ffec4abf63481818afef913b8cf1cbfb9200e8ed4ff
5
5
  SHA512:
6
- metadata.gz: 8b7ba9cdef8ac50cb46523b4f9f12273639fcfc389641803959b5a231633346336ca90bea21e72601528b80a3122fffb22865f5542b5c41a23c3b8ddc01a3e23
7
- data.tar.gz: 3d2a14ba0096a4cf98b164ffa456168834219f9d087b22d3067939237d021e7f9726238c4e51319f63c9a63645cff456a54aa12a4b0da703117b9c9da20e7e8b
6
+ metadata.gz: 8c868d18999ce1bdff2d2bad36eebf0fe83debdd6527e0fbe8dccfb0cc2d2d2d8573c78f47a8cf3bf3f2c216f20f3e7bfaa2e4ffd4ef1a931b2a28392b216843
7
+ data.tar.gz: a4bf1483d2e93163ca1e6b30088a6783696dee5d39f0f05075c4db4f48ca2ccaa5d53cd6a8afb7da3941b2c50dc64806e13e167839ee2065d70ea9053076d9db
@@ -1,4 +1,5 @@
1
1
 
2
+
2
3
  @import 'pb_advanced_table/advanced_table';
3
4
  @import 'pb_avatar/avatar';
4
5
  @import 'pb_background/background';
@@ -14,8 +15,8 @@
14
15
  @import 'pb_circle_chart/circle_chart';
15
16
  @import 'pb_circle_icon_button/circle_icon_button';
16
17
  @import 'pb_collapsible/collapsible';
17
- @import 'pb_copy_button/copy_button';
18
18
  @import 'pb_contact/contact';
19
+ @import 'pb_copy_button/copy_button';
19
20
  @import 'pb_currency/currency';
20
21
  @import 'pb_dashboard_value/dashboard_value';
21
22
  @import 'pb_date/date';
@@ -45,6 +46,7 @@
45
46
  @import 'pb_highlight/highlight';
46
47
  @import 'pb_home_address_street/home_address_street';
47
48
  @import 'pb_icon/icon';
49
+ @import 'pb_icon_button/icon_button';
48
50
  @import 'pb_icon_circle/icon_circle';
49
51
  @import 'pb_icon_stat_value/icon_stat_value';
50
52
  @import 'pb_icon_value/icon_value';
@@ -109,7 +111,7 @@
109
111
  @import 'pb_user_badge/user_badge';
110
112
  @import 'pb_walkthrough/walkthrough';
111
113
  @import 'pb_weekday_stacked/weekday_stacked';
112
- @import 'pb_icon_button/icon_button';
114
+ @import 'pb_empty_state/empty_state';
113
115
  @import 'utilities/mixins';
114
116
  @import 'utilities/spacing';
115
117
  @import 'utilities/cursor';
@@ -0,0 +1,38 @@
1
+ .pb_empty_state_kit {
2
+
3
+ .sm-state-vertical {
4
+ width: 150px;
5
+ }
6
+
7
+ .md-state-vertical {
8
+ width: 300px;
9
+ }
10
+
11
+ .lg-state-vertical {
12
+ width: 450px;
13
+ }
14
+
15
+ .sm-state-horizontal {
16
+ width: max-content;
17
+ max-width: 400px;
18
+ .pb_flex_item_kit {
19
+ align-self: end;
20
+ }
21
+ }
22
+
23
+ .md-state-horizontal {
24
+ width: max-content;
25
+ max-width: 600px;
26
+ .pb_flex_item_kit {
27
+ align-self: end;
28
+ }
29
+ }
30
+
31
+ .lg-state-horizontal {
32
+ width: max-content;
33
+ .pb_flex_item_kit {
34
+ align-self: end;
35
+ }
36
+ }
37
+
38
+ }
@@ -0,0 +1,199 @@
1
+
2
+ import React from "react"
3
+ import classnames from "classnames"
4
+ import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props"
5
+ import { globalProps } from "../utilities/globalProps"
6
+ import Title from "../pb_title/_title"
7
+ import Body from "../pb_body/_body"
8
+ import Button from "../pb_button/_button"
9
+ import Detail from "../pb_detail/_detail"
10
+ import Flex from "../pb_flex/_flex"
11
+ import FlexItem from "../pb_flex/_flex_item"
12
+ import Image from "../pb_image/_image"
13
+
14
+ type EventHandler = (React.MouseEventHandler<HTMLElement>)
15
+
16
+ type EmptyStateProps = {
17
+ aria?: { [key: string]: string },
18
+ alignment?: "center" | "left" | "right",
19
+ className?: string,
20
+ data?: { [key: string]: string },
21
+ description?: string,
22
+ header?: string,
23
+ id?: string,
24
+ image?: string,
25
+ linkButton?: string,
26
+ onLinkButtonClick?: EventHandler,
27
+ onPrimaryButtonClick?: EventHandler,
28
+ orientation?: "horizontal" | "vertical",
29
+ primaryButton?: string,
30
+ size?: "sm" | "md" | "lg",
31
+ }
32
+
33
+ const EmptyState = (props: EmptyStateProps) => {
34
+ const {
35
+ aria = {},
36
+ alignment = "center",
37
+ className,
38
+ data = {},
39
+ description,
40
+ header = "",
41
+ id,
42
+ image,
43
+ linkButton,
44
+ onLinkButtonClick,
45
+ onPrimaryButtonClick,
46
+ orientation = "vertical",
47
+ primaryButton,
48
+ size = "md",
49
+ } = props
50
+
51
+ const ariaProps = buildAriaProps(aria)
52
+ const dataProps = buildDataProps(data)
53
+ const classes = classnames(buildCss("pb_empty_state_kit"), globalProps(props), className)
54
+
55
+ const renderContent = () => {
56
+ const sizeConfigs = {
57
+ sm: {
58
+ vertical: {
59
+ imageWidth: "100px",
60
+ titleSize: 4,
61
+ titlePadding: "xxs",
62
+ descriptionPadding: "sm",
63
+ buttonSize: "sm",
64
+ buttonMargin: "xs",
65
+ scssClassName: "sm-state-vertical",
66
+ column: "column",
67
+ },
68
+ horizontal: {
69
+ imageWidth: "100px",
70
+ titleSize: 4,
71
+ titlePadding: "xxs",
72
+ descriptionPadding: "sm",
73
+ buttonSize: "sm",
74
+ buttonMargin: "xs",
75
+ scssClassName: "sm-state-horizontal",
76
+ column: "",
77
+ },
78
+ },
79
+ md: {
80
+ vertical: {
81
+ imageWidth: "140px",
82
+ titleSize: 3,
83
+ titlePadding: "xs",
84
+ descriptionPadding: "md",
85
+ buttonSize: "md",
86
+ buttonMargin: "sm",
87
+ scssClassName: "md-state-vertical",
88
+ column: "column",
89
+ },
90
+ horizontal: {
91
+ imageWidth: "140px",
92
+ titleSize: 3,
93
+ titlePadding: "xs",
94
+ descriptionPadding: "md",
95
+ buttonSize: "md",
96
+ buttonMargin: "sm",
97
+ scssClassName: "md-state-horizontal",
98
+ column: "",
99
+ },
100
+ },
101
+ lg: {
102
+ vertical: {
103
+ imageWidth: "100%",
104
+ titleSize: 2,
105
+ titlePadding: "sm",
106
+ descriptionPadding: "lg",
107
+ buttonSize: "md",
108
+ buttonMargin: "md",
109
+ scssClassName: "lg-state-vertical",
110
+ column: "column",
111
+ },
112
+ horizontal: {
113
+ imageWidth: "100%",
114
+ titleSize: 2,
115
+ titlePadding: "sm",
116
+ descriptionPadding: "lg",
117
+ buttonSize: "md",
118
+ buttonMargin: "md",
119
+ scssClassName: "lg-state-horizontal",
120
+ column: "",
121
+ },
122
+ },
123
+ };
124
+
125
+ const configs = sizeConfigs[size]?.[orientation]
126
+ const alignFlex = alignment === "center" ? "center" : alignment === "right" ? "end" : "start"
127
+ const alignText = alignment === "center" ? "center" : alignment === "right" ? "right" : undefined
128
+
129
+
130
+ const layout = (
131
+ <div {...ariaProps}
132
+ {...dataProps}
133
+ className={classes}
134
+ id={id}
135
+ >
136
+ <Flex align={alignFlex}
137
+ className={configs.scssClassName}
138
+ orientation={configs.column as "column" | "row" | undefined}
139
+ paddingLeft="xl"
140
+ paddingRight="xl"
141
+ vertical="center"
142
+ >
143
+ { image ? (
144
+ <Image
145
+ alt="test"
146
+ htmlOptions={{ width: configs.imageWidth, height: "auto", alignment: "start" }}
147
+ url={image}
148
+ />
149
+ ) : null }
150
+
151
+ <FlexItem >
152
+ <Title paddingBottom={configs.titlePadding as "xxs" | "xs" | "sm" | undefined}
153
+ size={configs.titleSize as 1 | 2 | 3 | 4 | undefined}
154
+ text={header}
155
+ textAlign={alignText}
156
+ />
157
+
158
+ {size !== "sm" ? (
159
+ <Body paddingBottom={configs.descriptionPadding as "sm" | "md" | "lg" | undefined}
160
+ text={description}
161
+ textAlign={alignText}
162
+ />
163
+ ) : (
164
+ <Detail paddingBottom={configs.descriptionPadding as "sm" | "md" | "lg" | undefined}
165
+ text={description}
166
+ textAlign={alignText}
167
+ />
168
+ )}
169
+
170
+ { primaryButton ? (
171
+ <Button
172
+ marginBottom={configs.buttonMargin as "xs" | "sm" | "md" | undefined}
173
+ onClick={onPrimaryButtonClick}
174
+ size={configs.buttonSize as "sm" | "md" | undefined}
175
+ text={primaryButton}
176
+ variant="primary"
177
+ width="100%"
178
+ />
179
+ ) : null }
180
+
181
+ { linkButton ? (
182
+ <Button onClick={onLinkButtonClick}
183
+ size={configs.buttonSize as "sm" | "md" | undefined}
184
+ text={linkButton}
185
+ variant="link"
186
+ width="100%"
187
+ />
188
+ ) : null }
189
+
190
+ </FlexItem>
191
+ </Flex>
192
+ </div>
193
+ )
194
+ return layout
195
+ }
196
+ return renderContent()
197
+ }
198
+
199
+ export default EmptyState
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ import { EmptyState, Flex } from 'playbook-ui'
3
+
4
+ const EmptyStateAlignment = (props) => (
5
+ <Flex align="center"
6
+ spacing="evenly"
7
+ >
8
+ <EmptyState
9
+ {...props}
10
+ alignment="left"
11
+ description="Body text goes into detail with possible steps for user to take"
12
+ header="Title Explains"
13
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
14
+ primaryButton="Next Action"
15
+ size="md"
16
+ />
17
+ <EmptyState
18
+ {...props}
19
+ alignment="center"
20
+ description="Body text goes into detail with possible steps for user to take"
21
+ header="Title Explains"
22
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
23
+ primaryButton="Next Action"
24
+ size="md"
25
+ />
26
+ <EmptyState
27
+ {...props}
28
+ alignment="right"
29
+ description="Body text goes into detail with possible steps for user to take"
30
+ header="Title Explains"
31
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
32
+ primaryButton="Next Action"
33
+ size="md"
34
+ />
35
+ </Flex>
36
+ )
37
+
38
+ export default EmptyStateAlignment
@@ -0,0 +1,19 @@
1
+ import React from 'react'
2
+ import { EmptyState, Flex } from 'playbook-ui'
3
+
4
+ const EmptyStateOrientation = (props) => (
5
+ <Flex align="center">
6
+ <EmptyState
7
+ {...props}
8
+ alignment="left"
9
+ description="Body text goes into detail with possible steps for user to take"
10
+ header="Title Explains"
11
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
12
+ orientation="horizontal"
13
+ primaryButton="Next Action"
14
+ size="lg"
15
+ />
16
+ </Flex>
17
+ )
18
+
19
+ export default EmptyStateOrientation
@@ -0,0 +1,35 @@
1
+ import React from 'react'
2
+ import { EmptyState, Flex } from 'playbook-ui'
3
+
4
+ const EmptyStateSize = (props) => (
5
+ <Flex align="center"
6
+ spacing="evenly"
7
+ >
8
+ <EmptyState
9
+ {...props}
10
+ alignment="center"
11
+ description="Body text goes into detail with possible steps for user to take"
12
+ header="Title Explains"
13
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
14
+ linkButton="Alt Action"
15
+ onLinkButtonClick={() => alert("link button clicked!")}
16
+ onPrimaryButtonClick={() => alert("primary button clicked!")}
17
+ primaryButton="Next Action"
18
+ size="sm"
19
+ />
20
+ <EmptyState
21
+ {...props}
22
+ alignment="center"
23
+ description="Body text goes into detail with possible steps for user to take"
24
+ header="Title Explains"
25
+ image="https://component.gallery/static/8d36eaa25b6dcb026685101ebc379022/Empty%20state%20icon..svg"
26
+ linkButton="Alt Action"
27
+ onLinkButtonClick={() => alert("link button clicked!")}
28
+ onPrimaryButtonClick={() => alert("primary button clicked!")}
29
+ primaryButton="Next Action"
30
+ size="lg"
31
+ />
32
+ </Flex>
33
+ )
34
+
35
+ export default EmptyStateSize
@@ -0,0 +1,7 @@
1
+ examples:
2
+
3
+
4
+ react:
5
+ - empty_state_size: Size
6
+ - empty_state_orientation: Orientation
7
+ - empty_state_alignment: Alignment
@@ -0,0 +1,3 @@
1
+ export { default as EmptyStateOrientation } from './_empty_state_orientation.jsx'
2
+ export { default as EmptyStateSize } from './_empty_state_size.jsx'
3
+ export { default as EmptyStateAlignment } from './_empty_state_alignment.jsx'
@@ -0,0 +1,17 @@
1
+ import React from 'react'
2
+ import { render, screen } from '../utilities/test-utils'
3
+
4
+ import { EmptyState } from 'playbook-ui'
5
+
6
+
7
+ test('returns namespaced class name', () => {
8
+ render(
9
+ <EmptyState
10
+ data={{ testid: 'primary-test' }}
11
+ text="some text"
12
+ />
13
+ )
14
+
15
+ const kit = screen.getByTestId('primary-test')
16
+ expect(kit).toHaveClass('pb_empty_state_kit')
17
+ })
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, forwardRef } from "react";
1
+ import React, { useState, useEffect, useRef } from "react";
2
2
  import classnames from "classnames";
3
3
  import { globalProps, GlobalProps } from "../utilities/globalProps";
4
4
  import {
@@ -23,13 +23,6 @@ import {
23
23
  getExpandedItems,
24
24
  } from "./_helper_functions";
25
25
 
26
- interface MultiLevelSelectComponent
27
- extends React.ForwardRefExoticComponent<
28
- MultiLevelSelectProps & React.RefAttributes<HTMLInputElement>
29
- > {
30
- Options: typeof MultiLevelSelectOptions;
31
- }
32
-
33
26
  type MultiLevelSelectProps = {
34
27
  aria?: { [key: string]: string }
35
28
  className?: string
@@ -42,7 +35,6 @@ type MultiLevelSelectProps = {
42
35
  name?: string
43
36
  returnAllSelected?: boolean
44
37
  treeData?: { [key: string]: string; }[] | any
45
- onChange?: (event: { target: { name?: string; value: any } }) => void
46
38
  onSelect?: (prop: { [key: string]: any }) => void
47
39
  selectedIds?: string[] | any
48
40
  variant?: "multi" | "single"
@@ -50,7 +42,7 @@ type MultiLevelSelectProps = {
50
42
  pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
51
43
  } & GlobalProps
52
44
 
53
- const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((props) => {
45
+ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
54
46
  const {
55
47
  aria = {},
56
48
  className,
@@ -63,7 +55,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
63
55
  name,
64
56
  returnAllSelected = false,
65
57
  treeData,
66
- onChange = () => null,
67
58
  onSelect = () => null,
68
59
  selectedIds,
69
60
  variant = "multi",
@@ -296,10 +287,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
296
287
  // Logic for removing items from returnArray or defaultReturn when pills clicked
297
288
  if (returnAllSelected) {
298
289
  onSelect(getCheckedItems(updatedTree));
299
- onChange({ target: { name, value: getCheckedItems(updatedTree) } });
300
290
  } else {
301
291
  onSelect(getDefaultCheckedItems(updatedTree));
302
- onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
303
292
  }
304
293
  };
305
294
 
@@ -325,10 +314,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
325
314
  const updatedTree = changeItem(filtered[0], check);
326
315
  if (returnAllSelected) {
327
316
  onSelect(getCheckedItems(updatedTree));
328
- onChange({ target: { name, value: getCheckedItems(updatedTree) } });
329
317
  } else {
330
318
  onSelect(getDefaultCheckedItems(updatedTree));
331
- onChange({ target: { name, value: getDefaultCheckedItems(updatedTree) } });
332
319
  }
333
320
  };
334
321
 
@@ -361,7 +348,6 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
361
348
  setIsDropdownClosed(true);
362
349
 
363
350
  onSelect(selectedItem);
364
- onChange({ target: { name, value: selectedItem } });
365
351
  };
366
352
 
367
353
  // Single select: reset the tree state upon typing
@@ -403,12 +389,12 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
403
389
  // Rendering formattedData to UI based on typeahead
404
390
  const renderNestedOptions = (items: { [key: string]: string; }[] | any ) => {
405
391
  const hasOptionsChild = React.Children.toArray(props.children).some(
406
- (child) => React.isValidElement(child) && child.type === MultiLevelSelect.Options
392
+ (child: any) => child.type === MultiLevelSelect.Options
407
393
  );
408
394
 
409
395
  if (hasOptionsChild) {
410
396
  return React.Children.map(props.children, (child) => {
411
- if (React.isValidElement(child) && child.type === MultiLevelSelect.Options) {
397
+ if (child.type === MultiLevelSelect.Options) {
412
398
  return React.cloneElement(child, { items });
413
399
  }
414
400
  return null;
@@ -561,9 +547,8 @@ const MultiLevelSelect = forwardRef<HTMLInputElement, MultiLevelSelectProps>((pr
561
547
  </MultiLevelSelectContext.Provider>
562
548
  </div>
563
549
  );
564
- }) as MultiLevelSelectComponent;
550
+ };
565
551
 
566
- MultiLevelSelect.displayName = "MultiLevelSelect";
567
552
  MultiLevelSelect.Options = MultiLevelSelectOptions;
568
553
 
569
554
  export default MultiLevelSelect;
@@ -12,7 +12,6 @@ examples:
12
12
 
13
13
  react:
14
14
  - multi_level_select_default: Default
15
- - multi_level_select_react_hook: React Hook
16
15
  - multi_level_select_single: Single Select
17
16
  - multi_level_select_single_children_only: Single Select w/ Hidden Radios
18
17
  - multi_level_select_return_all_selected: Return All Selected
@@ -7,4 +7,3 @@ export { default as MultiLevelSelectColor } from './_multi_level_select_color.js
7
7
  export { default as MultiLevelSelectWithChildren } from './_multi_level_select_with_children.jsx'
8
8
  export { default as MultiLevelSelectWithChildrenWithRadios } from './_multi_level_select_with_children_with_radios.jsx'
9
9
  export { default as MultiLevelSelectDisabled } from './_multi_level_select_disabled.jsx'
10
- export { default as MultiLevelSelectReactHook } from './_multi_level_select_react_hook.jsx'