playbook_ui 12.30.0 → 12.30.1.pre.alpha.PLAY906multilevelselectedidsprop912
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_label_value/label_value.test.js +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +7 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +0 -18
- data/app/pb_kits/playbook/pb_title/_title.tsx +2 -21
- data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_title/title.rb +4 -17
- data/app/pb_kits/playbook/pb_title/title.test.js +2 -2
- data/dist/playbook-rails.js +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +7 -10
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.html.erb +0 -1
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.jsx +0 -16
- data/app/pb_kits/playbook/pb_title/docs/_title_responsive.md +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb99bff289e00a7d9a4304de6118e54be2349a7d705bd69f07307940b277db5
|
4
|
+
data.tar.gz: 34b932013c8f26a6c25afe95e725fc4bac6f62b323e49e134ab0020a312107f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 245aac90b727280ef79d58a04569cc93f559d09b5ad2bd1350260c1eea9c4b02030de75e6ec7ff9a7d6751006c0c32bb7be946bc1ad813032d00a5ced8e240e0
|
7
|
+
data.tar.gz: af04cb501838d28a314d6de419fd6a5ca7782ce2f0973f80ba24ca048d82fdbad61041c56d43783f38ec1f77a6b7a56fd5b09eff85528ddab775557d6a0f2a9f
|
@@ -103,7 +103,7 @@ describe("LabelValue Kit", () => {
|
|
103
103
|
/>
|
104
104
|
)
|
105
105
|
const kit = screen.getByTestId(testId)
|
106
|
-
const activeProp = kit.querySelector(".
|
106
|
+
const activeProp = kit.querySelector(".pb_title_kit_size_4_link")
|
107
107
|
expect(activeProp).toBeInTheDocument()
|
108
108
|
})
|
109
109
|
})
|
@@ -28,6 +28,7 @@ type MultiLevelSelectProps = {
|
|
28
28
|
returnAllSelected?: boolean
|
29
29
|
treeData?: { [key: string]: string }[]
|
30
30
|
onSelect?: (prop: { [key: string]: any }) => void
|
31
|
+
selectedIds?: string[]
|
31
32
|
} & GlobalProps
|
32
33
|
|
33
34
|
const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
@@ -41,6 +42,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
41
42
|
returnAllSelected = false,
|
42
43
|
treeData,
|
43
44
|
onSelect = () => {},
|
45
|
+
selectedIds
|
44
46
|
} = props
|
45
47
|
|
46
48
|
const ariaProps = buildAriaProps(aria)
|
@@ -70,8 +72,8 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
70
72
|
|
71
73
|
|
72
74
|
useEffect(() => {
|
73
|
-
setFormattedData(addCheckedAndParentProperty(treeData))
|
74
|
-
}, [treeData])
|
75
|
+
setFormattedData(addCheckedAndParentProperty(treeData, selectedIds))
|
76
|
+
}, [treeData, selectedIds])
|
75
77
|
|
76
78
|
useEffect(() => {
|
77
79
|
if (returnAllSelected) {
|
@@ -160,6 +162,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
160
162
|
//function to map over data and add parent_id + depth property to each item
|
161
163
|
const addCheckedAndParentProperty = (
|
162
164
|
treeData: { [key: string]: any }[],
|
165
|
+
selectedIds: string[],
|
163
166
|
parent_id: string = null,
|
164
167
|
depth: number = 0,
|
165
168
|
) => {
|
@@ -169,6 +172,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
169
172
|
return treeData.map((item: { [key: string]: any } | any) => {
|
170
173
|
const newItem = {
|
171
174
|
...item,
|
175
|
+
checked: selectedIds && selectedIds.length && selectedIds.includes(item.id),
|
172
176
|
parent_id,
|
173
177
|
depth,
|
174
178
|
}
|
@@ -179,6 +183,7 @@ const MultiLevelSelect = (props: MultiLevelSelectProps) => {
|
|
179
183
|
: item.children
|
180
184
|
newItem.children = addCheckedAndParentProperty(
|
181
185
|
children,
|
186
|
+
selectedIds,
|
182
187
|
newItem.id,
|
183
188
|
depth + 1
|
184
189
|
)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
@import "../tokens/titles";
|
2
2
|
@import "../tokens/colors";
|
3
|
-
@import "../tokens/screen_sizes";
|
4
3
|
@import './title_mixin';
|
5
4
|
|
6
5
|
[class^=pb_title_kit]{
|
@@ -34,21 +33,4 @@
|
|
34
33
|
&[class*=_thin] {
|
35
34
|
@include pb_title_thin;
|
36
35
|
}
|
37
|
-
|
38
|
-
@each $size, $size_value in $breakpoints_grid {
|
39
|
-
@each $title_size_value in [1, 2, 3, 4] {
|
40
|
-
$min_size: map-get($size_value, "min");
|
41
|
-
$max_size: map-get($size_value, "max");
|
42
|
-
&[class*=_#{$size}_#{$title_size_value}] {
|
43
|
-
@include break_on($min_size, $max_size) {
|
44
|
-
@if $title_size_value == 1 { @include pb_title_1; }
|
45
|
-
@else if $title_size_value == 2 { @include pb_title_2; }
|
46
|
-
@else if $title_size_value == 3 { @include pb_title_3; }
|
47
|
-
@else if $title_size_value == 4 { @include pb_title_4; }
|
48
|
-
@include title_colors;
|
49
|
-
@if $title_size_value != 4 { @include pb_title_bold; }
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
36
|
}
|
@@ -3,9 +3,6 @@ import classnames from 'classnames'
|
|
3
3
|
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
4
4
|
import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalProps'
|
5
5
|
|
6
|
-
type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4"
|
7
|
-
type SizeResponsiveType = {[key: string]: SizeType}
|
8
|
-
|
9
6
|
type TitleProps = {
|
10
7
|
aria?: {[key: string]: string},
|
11
8
|
bold?: boolean,
|
@@ -14,7 +11,7 @@ type TitleProps = {
|
|
14
11
|
color?: "default" | "light" | "lighter" | "success" | "error" | "link",
|
15
12
|
data?: {[key: string]: string},
|
16
13
|
id?: string,
|
17
|
-
size?:
|
14
|
+
size?: 1 | 2| 3| 4 | "1" | "2" | "3" | "4",
|
18
15
|
tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
|
19
16
|
text?: string,
|
20
17
|
variant?: null | "link",
|
@@ -39,25 +36,9 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
39
36
|
const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
|
40
37
|
const dataProps: {[key: string]: string | number} = buildDataProps(data)
|
41
38
|
const getBold = bold ? '' : 'thin'
|
42
|
-
|
43
|
-
const generateSizeClasses = () => {
|
44
|
-
let css = ''
|
45
|
-
|
46
|
-
if (typeof size == "number" || typeof size == "string") {
|
47
|
-
css += `pb_title_kit_size_${size} `
|
48
|
-
} else {
|
49
|
-
Object.entries(size).forEach((sizeObj) => {
|
50
|
-
css += `pb_title_kit_${sizeObj[0]}_${sizeObj[1]} `
|
51
|
-
})
|
52
|
-
}
|
53
|
-
|
54
|
-
return css.trim()
|
55
|
-
}
|
56
|
-
|
57
39
|
const classes = classnames(
|
58
|
-
buildCss('pb_title_kit', variant, color, getBold),
|
40
|
+
buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
|
59
41
|
globalProps(props),
|
60
|
-
generateSizeClasses(),
|
61
42
|
className
|
62
43
|
)
|
63
44
|
const Tag: React.ReactElement | any = `${tag}`
|
@@ -3,10 +3,8 @@ examples:
|
|
3
3
|
- title_default: Default UI
|
4
4
|
- title_light_weight: Light Weight UI
|
5
5
|
- title_colors: Colors
|
6
|
-
- title_responsive: Responsive
|
7
6
|
|
8
7
|
react:
|
9
8
|
- title_default: Default UI
|
10
9
|
- title_light_weight: Light Weight UI
|
11
10
|
- title_colors: Colors
|
12
|
-
- title_responsive: Responsive
|
@@ -6,7 +6,9 @@ module Playbook
|
|
6
6
|
prop :color, type: Playbook::Props::Enum,
|
7
7
|
values: [nil, "default", "light", "lighter", "success", "error", "link"],
|
8
8
|
default: nil
|
9
|
-
prop :size,
|
9
|
+
prop :size, type: Playbook::Props::Enum,
|
10
|
+
values: [1, 2, 3, 4],
|
11
|
+
default: 3
|
10
12
|
prop :tag, type: Playbook::Props::Enum,
|
11
13
|
values: %w[h1 h2 h3 h4 h5 h6 p div span],
|
12
14
|
default: "h3"
|
@@ -18,27 +20,12 @@ module Playbook
|
|
18
20
|
prop :bold, type: Playbook::Props::Boolean, default: true
|
19
21
|
|
20
22
|
def classname
|
21
|
-
|
22
|
-
title_class + generate_size_classname
|
23
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
23
24
|
end
|
24
25
|
|
25
26
|
def is_bold
|
26
27
|
bold ? nil : "thin"
|
27
28
|
end
|
28
|
-
|
29
|
-
def generate_size_classname
|
30
|
-
responsive = try(:size).is_a?(::Hash)
|
31
|
-
css = ""
|
32
|
-
if responsive
|
33
|
-
size.each do |key, value|
|
34
|
-
css += " pb_title_kit_#{key}_#{value}"
|
35
|
-
end
|
36
|
-
else
|
37
|
-
css += " pb_title_kit_size_#{size}"
|
38
|
-
end
|
39
|
-
|
40
|
-
css unless css.blank?
|
41
|
-
end
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|
@@ -25,7 +25,7 @@ test('with thin font weight', () => {
|
|
25
25
|
)
|
26
26
|
|
27
27
|
const kit = screen.getByTestId('primary-test')
|
28
|
-
expect(kit).toHaveClass('
|
28
|
+
expect(kit).toHaveClass('pb_title_kit_size_3_thin')
|
29
29
|
})
|
30
30
|
|
31
31
|
test('with colors', () => {
|
@@ -38,5 +38,5 @@ test('with colors', () => {
|
|
38
38
|
)
|
39
39
|
|
40
40
|
const kit = screen.getByTestId('primary-test')
|
41
|
-
expect(kit).toHaveClass('
|
41
|
+
expect(kit).toHaveClass('pb_title_kit_size_3_success')
|
42
42
|
})
|