playbook_ui 13.9.0 → 13.10.0.pre.alpha.PLAY1046multilevelsingleselectphase21323
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/pb_avatar/docs/_avatar_default_swift.md +12 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_monogram_swift.md +12 -0
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_props_swift.md +8 -0
- data/app/pb_kits/playbook/pb_avatar/docs/example.yml +3 -1
- data/app/pb_kits/playbook/pb_background/_background.tsx +103 -52
- data/app/pb_kits/playbook/pb_badge/docs/_badge_colors_swift.md +1 -1
- data/app/pb_kits/playbook/pb_button/_button.scss +2 -2
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +27 -22
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +6 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +270 -111
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.html.erb +6 -7
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_selected_ids.jsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.html.erb +76 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_single.jsx +90 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +7 -0
- data/dist/playbook-rails.js +5 -5
- data/lib/playbook/version.rb +2 -2
- metadata +12 -8
- data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8120f74ec160cee373cdd8848e6e614b47ab8f2c92f2dd87a53c533a735fbe9
|
4
|
+
data.tar.gz: db41eb2d926684394701fbb886da7382e84ece42a1e213faf89ef3f48a31d2dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc7da2bb3c53cba46fc93a186daaaf1fb7cdcaa6798196d1ec151e27c512dcda54536e0e52cd4c40a8b72ad1dde57738febd0825dd036c9f9a5ce9d619c7a0f
|
7
|
+
data.tar.gz: 023e6ef6b4f7464466f3c05f27a25ace1e26702a7bc02cc48d3218d53ebd60c766d6b6f4063621cafb89e009a44d8059c2d754b86d3b06938af539d31f943006
|
@@ -0,0 +1,12 @@
|
|
1
|
+
![avatar-default](https://github.com/powerhome/playbook/assets/92755007/b1bed6d5-56b4-40e2-96c3-6090642fc89f)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading, spacing: Spacing.small) {
|
5
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .xxSmall, status: .online)
|
6
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .xSmall, status: .away)
|
7
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .small, status: .online)
|
8
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .away)
|
9
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .large, status: .online)
|
10
|
+
PBAvatar(image: Image("andrew", bundle: .module), size: .xLarge, status: .offline)
|
11
|
+
}
|
12
|
+
```
|
@@ -0,0 +1,12 @@
|
|
1
|
+
![avatar-monogram](https://github.com/powerhome/playbook/assets/92755007/c7fd747d-46a9-4da0-8d89-dfa3647ea572)
|
2
|
+
|
3
|
+
```swift
|
4
|
+
VStack(alignment: .leading, spacing: Spacing.small) {
|
5
|
+
PBAvatar(name: "Tim Wenhold", size: .xxSmall, status: .online)
|
6
|
+
PBAvatar(name: "Tim Wenhold", size: .xSmall, status: .away)
|
7
|
+
PBAvatar(name: "Tim Wenhold", size: .small, status: .online)
|
8
|
+
PBAvatar(name: "Tim Wenhold", size: .medium, status: .away)
|
9
|
+
PBAvatar(name: "Tim Wenhold", size: .large, status: .online)
|
10
|
+
PBAvatar(name: "Tim", size: .xLarge, status: .offline)
|
11
|
+
}
|
12
|
+
```
|
@@ -0,0 +1,8 @@
|
|
1
|
+
### Props
|
2
|
+
| Name | Type | Description | Default | Values |
|
3
|
+
| --- | ----------- | --------- | --------- | --------- |
|
4
|
+
| **Image** | `Image` | Sets the Avatar image | | |
|
5
|
+
| **Name** | `String` | Used to display user's initails when image is blank | | |
|
6
|
+
| **Size** | `Size` | Adjusts the Avatar image size | `.medium` | `.xxSmall` `.xSmall` `.small` `.medium` `.large` `.xLarge` |
|
7
|
+
| **Status** | `PresenceStatus` | Sets user's activity status | | `away` `offline` `online` |
|
8
|
+
| **Wrapped** | `Bool` | Displays the wrapped variant | `false` | `true` `false` |
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from 'react'
|
1
|
+
import React, { useEffect, useState } from 'react'
|
2
2
|
import classnames from 'classnames'
|
3
3
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
4
4
|
import { GlobalProps, globalProps } from '../utilities/globalProps'
|
@@ -6,7 +6,7 @@ import { GlobalProps, globalProps } from '../utilities/globalProps'
|
|
6
6
|
type BackgroundProps = {
|
7
7
|
alt?: string,
|
8
8
|
aria?: {[key: string]: string},
|
9
|
-
backgroundColor?: 'gradient' |
|
9
|
+
backgroundColor?: ResponsiveProp<string> | 'gradient' |
|
10
10
|
'dark' |'light' | 'white' | 'success' | 'warning' | 'error' | 'info' | 'neutral' | 'primary' | 'shadow' |
|
11
11
|
'category_1' | 'category_2' | 'category_3' | 'category_4' | 'category_5' | 'category_6' | 'category_7' |
|
12
12
|
'category_8' | 'category_9' | 'category_10' | 'category_11' | 'category_12' | 'category_13' | 'category_14' |
|
@@ -15,20 +15,53 @@ type BackgroundProps = {
|
|
15
15
|
'card_light' | 'card_dark' | 'data_1' | 'data_2' | 'data_3' | 'data_4' | 'data_5' | 'data_6' | 'data_7' | 'data_8' |
|
16
16
|
'border_light' | 'border_dark' | 'success_secondary' | 'error_secondary' | 'info_secondary' | 'warning_secondary' |
|
17
17
|
'neutral_secondary' | 'primary_secondary' | 'success_subtle' | 'warning_subtle' | 'error_subtle' | 'info_subtle' | 'neutral_subtle',
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
backgroundSize?: ResponsiveProp<string> | 'auto' | 'cover' | 'contain',
|
19
|
+
backgroundPosition?: ResponsiveProp<string> | string,
|
20
|
+
backgroundRepeat?: ResponsiveProp<string> | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | 'space' | 'round' | 'initial' | 'inherit',
|
21
|
+
imageUrl?: ResponsiveProp<string> | string,
|
21
22
|
children?: React.ReactChild[] | React.ReactNode,
|
22
23
|
className?: string,
|
23
24
|
customColor?: string,
|
24
25
|
data?: {[key: string]: string},
|
25
26
|
id?: string,
|
26
|
-
imageUrl?: string,
|
27
27
|
padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
|
28
28
|
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div' | 'tr' | 'th' | 'td' | 'thead' | 'col',
|
29
29
|
transition?: 'fade' | 'blur' | 'scale',
|
30
30
|
} & GlobalProps
|
31
31
|
|
32
|
+
type ResponsiveProp<T> = T | {
|
33
|
+
xs?: T,
|
34
|
+
sm?: T,
|
35
|
+
md?: T,
|
36
|
+
lg?: T,
|
37
|
+
xl?: T,
|
38
|
+
default?: T
|
39
|
+
};
|
40
|
+
|
41
|
+
const breakpoints: {[key: string]: string} = {
|
42
|
+
xs: '(max-width: 575px)',
|
43
|
+
sm: '(min-width: 576px) and (max-width: 767px)',
|
44
|
+
md: '(min-width: 768px) and (max-width: 991px)',
|
45
|
+
lg: '(min-width: 992px) and (max-width: 1199px)',
|
46
|
+
xl: '(min-width: 1200px)',
|
47
|
+
};
|
48
|
+
|
49
|
+
const getResponsiveValue = <T extends string | undefined>(prop: ResponsiveProp<T> | undefined): T => {
|
50
|
+
if (typeof prop === 'string') {
|
51
|
+
return prop;
|
52
|
+
}
|
53
|
+
|
54
|
+
// Check for breakpoints
|
55
|
+
for (const [bp, value] of Object.entries(prop || {})) {
|
56
|
+
if (bp !== 'default' && window.matchMedia(breakpoints[bp]).matches) {
|
57
|
+
return value as T;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
// Return the default value if provided, otherwise undefined
|
62
|
+
return prop?.default || undefined;
|
63
|
+
};
|
64
|
+
|
32
65
|
const Background = (props: BackgroundProps) => {
|
33
66
|
const {
|
34
67
|
alt = '',
|
@@ -46,60 +79,78 @@ const Background = (props: BackgroundProps) => {
|
|
46
79
|
tag = 'div',
|
47
80
|
transition = '',
|
48
81
|
} = props
|
82
|
+
|
83
|
+
const [responsiveProps, setResponsiveProps] = useState({
|
84
|
+
backgroundSize: getResponsiveValue(backgroundSize),
|
85
|
+
backgroundPosition: getResponsiveValue(backgroundPosition),
|
86
|
+
backgroundRepeat: getResponsiveValue(backgroundRepeat),
|
87
|
+
backgroundColor: getResponsiveValue(backgroundColor),
|
88
|
+
imageUrl: getResponsiveValue(imageUrl),
|
89
|
+
});
|
49
90
|
|
50
|
-
|
51
|
-
|
91
|
+
// Update responsive values on window resize.
|
92
|
+
useEffect(() => {
|
93
|
+
const updateResponsiveProps = () => {
|
94
|
+
setResponsiveProps({
|
95
|
+
backgroundSize: getResponsiveValue(props.backgroundSize),
|
96
|
+
backgroundPosition: getResponsiveValue(props.backgroundPosition),
|
97
|
+
backgroundRepeat: getResponsiveValue(props.backgroundRepeat),
|
98
|
+
backgroundColor: getResponsiveValue(props.backgroundColor),
|
99
|
+
imageUrl: getResponsiveValue(props.imageUrl),
|
100
|
+
});
|
101
|
+
};
|
102
|
+
window.addEventListener('resize', updateResponsiveProps);
|
103
|
+
return () => window.removeEventListener('resize', updateResponsiveProps);
|
104
|
+
}, [props]);
|
52
105
|
|
53
|
-
const backgroundStyle = {
|
54
|
-
backgroundImage: `url(${imageUrl})`,
|
55
|
-
backgroundRepeat: `${backgroundRepeat}`,
|
56
|
-
backgroundSize: `${backgroundSize}`,
|
57
|
-
backgroundPosition: backgroundPosition
|
58
|
-
}
|
59
|
-
|
60
|
-
const backgroundPositionStyle = {
|
61
|
-
backgroundColor: customColor? customColor: null,
|
62
|
-
backgroundPosition: `${backgroundPosition}`
|
63
|
-
}
|
64
106
|
|
65
|
-
|
66
|
-
const
|
107
|
+
// Extract currently applicable responsive values.
|
108
|
+
const {
|
109
|
+
backgroundColor: resBackgroundColor,
|
110
|
+
backgroundPosition: resBackgroundPosition,
|
111
|
+
backgroundRepeat: resBackgroundRepeat,
|
112
|
+
backgroundSize: resBackgroundSize,
|
113
|
+
imageUrl: resImageUrl,
|
114
|
+
} = responsiveProps;
|
67
115
|
|
116
|
+
// Build CSS classes and styles using responsive values.
|
117
|
+
const classes = classnames(
|
118
|
+
buildCss('pb_background_kit'),
|
119
|
+
'lazyload',
|
120
|
+
globalProps(props),
|
121
|
+
transition,
|
122
|
+
{
|
123
|
+
[`pb_background_color_${resBackgroundColor}`]: resBackgroundColor && !customColor,
|
124
|
+
[`pb_background_custom_color`]: !!customColor,
|
125
|
+
},
|
126
|
+
className
|
127
|
+
);
|
68
128
|
|
69
|
-
const
|
129
|
+
const backgroundStyle = {
|
130
|
+
backgroundImage: resImageUrl ? `url(${resImageUrl})` : undefined,
|
131
|
+
backgroundRepeat: resBackgroundRepeat || undefined,
|
132
|
+
backgroundSize: resBackgroundSize || undefined,
|
133
|
+
backgroundPosition: resBackgroundPosition || undefined,
|
134
|
+
backgroundColor: customColor || undefined,
|
135
|
+
};
|
70
136
|
|
71
|
-
const
|
72
|
-
|
73
|
-
|
74
|
-
<Tag
|
75
|
-
alt={alt}
|
76
|
-
style={backgroundStyle}
|
77
|
-
{...ariaProps}
|
78
|
-
{...dataProps}
|
79
|
-
className={classes}
|
80
|
-
id={id}
|
81
|
-
>
|
82
|
-
{ children }
|
83
|
-
</Tag>
|
84
|
-
)
|
85
|
-
else
|
86
|
-
return (
|
87
|
-
<Tag
|
88
|
-
{...ariaProps}
|
89
|
-
{...dataProps}
|
90
|
-
className={classes}
|
91
|
-
id={id}
|
92
|
-
style={backgroundPositionStyle}
|
93
|
-
>
|
94
|
-
{ children }
|
95
|
-
</Tag>
|
96
|
-
)
|
97
|
-
}
|
137
|
+
const Tag: React.ReactElement | any = `${tag}`;
|
138
|
+
const ariaProps = buildAriaProps(aria);
|
139
|
+
const dataProps = buildDataProps(data);
|
98
140
|
|
141
|
+
|
99
142
|
return (
|
100
|
-
|
101
|
-
{
|
102
|
-
|
143
|
+
<Tag
|
144
|
+
alt={alt}
|
145
|
+
style={backgroundStyle}
|
146
|
+
{...ariaProps}
|
147
|
+
{...dataProps}
|
148
|
+
className={classes}
|
149
|
+
id={id}
|
150
|
+
>
|
151
|
+
{children}
|
152
|
+
</Tag>
|
153
|
+
|
103
154
|
)
|
104
155
|
}
|
105
156
|
|
@@ -40,11 +40,11 @@ $pb_button_sizes: (
|
|
40
40
|
border-radius: $border_radius_rounded;
|
41
41
|
border: 1px solid $border_light;
|
42
42
|
color: $text_lt_light;
|
43
|
-
padding: ($space_xxs -
|
43
|
+
padding: ($space_xxs - 3) $space_xs;
|
44
44
|
min-height: $space_md + 4;
|
45
45
|
|
46
46
|
.pb_icon_kit_emoji, .pb_icon_kit {
|
47
|
-
font-size: $
|
47
|
+
font-size: $font_small;
|
48
48
|
}
|
49
49
|
&:hover {
|
50
50
|
background-color: $bg_light;
|
@@ -1,22 +1,9 @@
|
|
1
|
-
//
|
2
|
-
|
3
|
-
data: { [key: string]: any }[],
|
4
|
-
item: { [key: string]: any }
|
5
|
-
) => {
|
6
|
-
if (item.parent_id) {
|
7
|
-
const ancestor = filterFormattedDataById(data, item.parent_id);
|
8
|
-
ancestor[0].checked = false;
|
9
|
-
ancestor[0].parent_id && getAncestorsOfUnchecked(data, ancestor[0]);
|
10
|
-
}
|
11
|
-
return data;
|
12
|
-
};
|
13
|
-
|
14
|
-
//function is going over formattedData and returning all objects that match the
|
15
|
-
//id of the clicked item from the dropdown
|
1
|
+
// Function is going over formattedData and returning all objects that match the
|
2
|
+
// ID of the clicked item from the dropdown
|
16
3
|
export const filterFormattedDataById = (
|
17
4
|
formattedData: { [key: string]: any }[],
|
18
5
|
id: string
|
19
|
-
) => {
|
6
|
+
): { [key: string]: any }[] => {
|
20
7
|
const matched: { [key: string]: any }[] = [];
|
21
8
|
const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
|
22
9
|
for (const item of data) {
|
@@ -38,7 +25,7 @@ export const filterFormattedDataById = (
|
|
38
25
|
export const findByFilter = (
|
39
26
|
formattedData: { [key: string]: any }[],
|
40
27
|
searchTerm: string
|
41
|
-
) => {
|
28
|
+
): { [key: string]: any }[] => {
|
42
29
|
const matchedItems: { [key: string]: any }[] = [];
|
43
30
|
const recursiveSearch = (data: { [key: string]: any }[], term: string) => {
|
44
31
|
for (const item of data) {
|
@@ -56,7 +43,20 @@ export const findByFilter = (
|
|
56
43
|
return matchedItems;
|
57
44
|
};
|
58
45
|
|
59
|
-
//
|
46
|
+
// Function to retrieve all ancestors of unchecked item and set checked to false
|
47
|
+
export const getAncestorsOfUnchecked = (
|
48
|
+
data: { [key: string]: any }[],
|
49
|
+
item: { [key: string]: any }
|
50
|
+
): { [key: string]: any }[] => {
|
51
|
+
if (item.parent_id) {
|
52
|
+
const ancestor = filterFormattedDataById(data, item.parent_id);
|
53
|
+
ancestor[0].checked = false;
|
54
|
+
ancestor[0].parent_id && getAncestorsOfUnchecked(data, ancestor[0]);
|
55
|
+
}
|
56
|
+
return data;
|
57
|
+
};
|
58
|
+
|
59
|
+
// Function to get all items with checked = true
|
60
60
|
export const getCheckedItems = (
|
61
61
|
data: { [key: string]: any }[]
|
62
62
|
): { [key: string]: any }[] => {
|
@@ -76,7 +76,9 @@ export const getCheckedItems = (
|
|
76
76
|
return checkedItems;
|
77
77
|
};
|
78
78
|
|
79
|
-
export const getDefaultCheckedItems = (
|
79
|
+
export const getDefaultCheckedItems = (
|
80
|
+
treeData: { [key: string]: any }[]
|
81
|
+
): { [key: string]: any }[] => {
|
80
82
|
const checkedDefault: { [key: string]: any }[] = [];
|
81
83
|
|
82
84
|
const traverseTree = (items: { [key: string]: any }[]) => {
|
@@ -118,7 +120,7 @@ export const getDefaultCheckedItems = (treeData: { [key: string]: any }[]) => {
|
|
118
120
|
export const recursiveCheckParent = (
|
119
121
|
item: { [key: string]: any },
|
120
122
|
data: any
|
121
|
-
) => {
|
123
|
+
): any => {
|
122
124
|
if (item.parent_id !== null) {
|
123
125
|
const parent = filterFormattedDataById(data, item.parent_id);
|
124
126
|
const allChildrenChecked = parent[0].children.every(
|
@@ -135,8 +137,11 @@ export const recursiveCheckParent = (
|
|
135
137
|
return data;
|
136
138
|
};
|
137
139
|
|
138
|
-
export const getExpandedItems = (
|
139
|
-
|
140
|
+
export const getExpandedItems = (
|
141
|
+
treeData: { [key: string]: string }[],
|
142
|
+
selectedIds: string[]
|
143
|
+
): any[] => {
|
144
|
+
const expandedItems: any[] = [];
|
140
145
|
|
141
146
|
const traverse = (items: string | any[], ancestors: any[] = []) => {
|
142
147
|
for (let i = 0; i < items.length; i++) {
|
@@ -30,10 +30,11 @@
|
|
30
30
|
align-items: center;
|
31
31
|
justify-content: space-between;
|
32
32
|
.input_inner_container {
|
33
|
-
|
33
|
+
width: 100%;
|
34
34
|
}
|
35
35
|
|
36
36
|
input {
|
37
|
+
width: 100%;
|
37
38
|
border: none;
|
38
39
|
font-family: $font_family_base;
|
39
40
|
font-size: $font_base;
|
@@ -84,4 +85,8 @@
|
|
84
85
|
.open {
|
85
86
|
display: block;
|
86
87
|
}
|
88
|
+
|
89
|
+
.singleHidden {
|
90
|
+
display: none
|
91
|
+
}
|
87
92
|
}
|