playbook_ui 14.14.0.pre.alpha.play1852reacthookformsupportradio6318 → 14.14.0.pre.alpha.play1868dependencyremovallodash6286
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_card/_card.tsx +2 -1
- data/app/pb_kits/playbook/pb_filter/Filter/CurrentFilters.tsx +4 -4
- data/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +2 -2
- data/app/pb_kits/playbook/pb_radio/_radio.tsx +74 -85
- data/app/pb_kits/playbook/pb_radio/docs/example.yml +1 -2
- data/app/pb_kits/playbook/pb_radio/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_radio/radio.test.js +0 -16
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +5 -4
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -1
- data/app/pb_kits/playbook/utilities/object.ts +82 -1
- data/dist/chunks/_typeahead-CHxdYnAw.js +36 -0
- data/dist/chunks/_weekday_stacked-D2tZHCNS.js +45 -0
- data/dist/chunks/{lib-D3us1bGD.js → lib-CrrD678a.js} +2 -2
- data/dist/chunks/{pb_form_validation-BpihMSOQ.js → pb_form_validation-BbWhQeoO.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -8
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.jsx +0 -60
- data/app/pb_kits/playbook/pb_radio/docs/_radio_react_hook.md +0 -1
- data/dist/chunks/_typeahead-8okiJBmN.js +0 -36
- data/dist/chunks/_weekday_stacked-DrKLZrfR.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27a1fb0e1b7ff46b56d6009a0eb62cd2d8fee0a67bcbe52756710ef9aaf5581
|
4
|
+
data.tar.gz: c46d01bb2e6d6b386297b040c132f438da09b14b5582319a07ec6358f758917f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c87e5ec2242eaf97737497152d0494d166282ad0da5dc17e0efd1008e1c698bbeb1389fd96cff40e8b1607caaa92dfdf3a90b9461e9876cf4c79030bd079b2d
|
7
|
+
data.tar.gz: f41cc750d14f6ec823711b0f85c3af3f60ff08f7149de6242969353b0fb2bac27576e03d75e587370d1286f46c2b60b64554cc19aa663a432274ee91c0dd03b3
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/* eslint-disable react/no-multi-comp */
|
2
2
|
|
3
3
|
import React from 'react'
|
4
|
-
import { get } from '
|
4
|
+
import { get } from '../utilities/object'
|
5
|
+
|
5
6
|
import classnames from 'classnames'
|
6
7
|
|
7
8
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { isEmpty, map, omitBy } from '
|
2
|
+
import { isEmpty, map, omitBy } from '../../utilities/object'
|
3
3
|
|
4
4
|
import Body from '../../pb_body/_body'
|
5
5
|
import Caption from '../../pb_caption/_caption'
|
@@ -40,13 +40,13 @@ const CurrentFilters = ({ dark, filters }: CurrentFiltersProps): React.ReactElem
|
|
40
40
|
className="filter"
|
41
41
|
key={`filter-${name}`}
|
42
42
|
>
|
43
|
-
{ value === true ?
|
43
|
+
{ value === true ?
|
44
44
|
<Title
|
45
45
|
dark={dark}
|
46
46
|
size={4}
|
47
47
|
tag="h4"
|
48
48
|
text={name}
|
49
|
-
/> :
|
49
|
+
/> :
|
50
50
|
<div>
|
51
51
|
<Caption
|
52
52
|
dark={dark}
|
@@ -58,7 +58,7 @@ const CurrentFilters = ({ dark, filters }: CurrentFiltersProps): React.ReactElem
|
|
58
58
|
tag="h4"
|
59
59
|
text={value}
|
60
60
|
/>
|
61
|
-
</div>
|
61
|
+
</div>
|
62
62
|
}
|
63
63
|
</div>
|
64
64
|
))}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import { isEmpty } from '
|
2
|
+
import { isEmpty } from '../../utilities/object'
|
3
3
|
|
4
4
|
import Flex from '../../pb_flex/_flex'
|
5
5
|
|
@@ -46,7 +46,7 @@ const FilterSingle = ({
|
|
46
46
|
paddingRight="lg"
|
47
47
|
vertical="center"
|
48
48
|
>
|
49
|
-
{ children &&
|
49
|
+
{ children &&
|
50
50
|
<>
|
51
51
|
<FiltersPopover
|
52
52
|
dark={dark}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
/*eslint-disable react/no-multi-comp */
|
2
|
+
|
3
|
+
import React, { forwardRef, useRef } from 'react'
|
2
4
|
import Body from '../pb_body/_body'
|
3
5
|
import Flex from '../pb_flex/_flex'
|
4
6
|
import classnames from 'classnames'
|
@@ -8,7 +10,7 @@ import { globalProps, GlobalProps } from '../utilities/globalProps'
|
|
8
10
|
type RadioProps = {
|
9
11
|
aria?: { [key: string]: string },
|
10
12
|
alignment?: string,
|
11
|
-
checked?: boolean,
|
13
|
+
checked?: boolean,
|
12
14
|
children?: React.ReactChild[] | React.ReactChild,
|
13
15
|
customChildren?: boolean,
|
14
16
|
className?: string,
|
@@ -22,10 +24,10 @@ type RadioProps = {
|
|
22
24
|
name?: string,
|
23
25
|
value?: string,
|
24
26
|
text?: string,
|
25
|
-
onChange
|
27
|
+
onChange: (event: React.FormEvent<HTMLInputElement> | null) => void,
|
26
28
|
} & GlobalProps
|
27
29
|
|
28
|
-
const Radio =
|
30
|
+
const Radio = ({
|
29
31
|
aria = {},
|
30
32
|
alignment,
|
31
33
|
children,
|
@@ -41,123 +43,110 @@ const Radio = forwardRef<HTMLInputElement, RadioProps>(({
|
|
41
43
|
name = 'radio_name',
|
42
44
|
text = 'Radio Text',
|
43
45
|
value = 'radio_text',
|
44
|
-
checked,
|
45
46
|
onChange = () => { void 0 },
|
46
47
|
...props
|
47
|
-
}, ref) => {
|
48
|
-
const
|
49
|
-
const setRefs = (el: HTMLInputElement) => {
|
50
|
-
internalRef.current = el
|
51
|
-
if (typeof ref === 'function') {
|
52
|
-
ref(el)
|
53
|
-
} else if (ref) {
|
54
|
-
(ref as React.MutableRefObject<HTMLInputElement | null>).current = el
|
55
|
-
}
|
56
|
-
}
|
57
|
-
|
58
|
-
const ariaProps = buildAriaProps(aria)
|
59
|
-
const dataProps = buildDataProps(data)
|
60
|
-
const htmlProps = buildHtmlProps(htmlOptions)
|
48
|
+
}: RadioProps, ref: any) => {
|
49
|
+
const radioRef = useRef(null);
|
61
50
|
|
51
|
+
const ariaProps = buildAriaProps(aria);
|
52
|
+
const dataProps = buildDataProps(data);
|
53
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
62
54
|
const classes = classnames(
|
63
55
|
buildCss('pb_radio_kit', alignment),
|
64
56
|
dark ? 'dark' : null,
|
65
57
|
error ? 'error' : null,
|
66
58
|
globalProps(props),
|
67
59
|
className
|
68
|
-
)
|
60
|
+
);
|
69
61
|
|
70
62
|
const classesCustom = classnames(
|
71
63
|
dark ? 'dark' : null,
|
72
64
|
error ? 'error' : null,
|
73
65
|
globalProps(props),
|
74
66
|
className
|
75
|
-
)
|
76
|
-
|
77
|
-
const checkedProps = checked !== undefined ? { checked } : {}
|
67
|
+
);
|
78
68
|
|
79
|
-
const displayRadio = (
|
80
|
-
if (children && customChildren
|
81
|
-
return children
|
69
|
+
const displayRadio = (props: RadioProps & any) => {
|
70
|
+
if (children && customChildren == false)
|
71
|
+
return (children)
|
82
72
|
else
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
73
|
+
return (
|
74
|
+
<input
|
75
|
+
disabled={disabled}
|
76
|
+
id={id}
|
77
|
+
name={name}
|
78
|
+
onChange={onChange}
|
79
|
+
ref={ref}
|
80
|
+
text={text}
|
81
|
+
type="radio"
|
82
|
+
value={value}
|
83
|
+
{...props}
|
84
|
+
/>
|
85
|
+
)}
|
97
86
|
|
98
87
|
const handleContainerClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | undefined) => {
|
99
88
|
if (event) {
|
100
|
-
const target = event.target as HTMLElement
|
89
|
+
const target = event.target as HTMLElement;
|
101
90
|
if (
|
102
91
|
target.id === 'pb-radio-children-wrapper' ||
|
103
92
|
target.closest('#pb-radio-children-wrapper')
|
104
93
|
) {
|
105
|
-
|
94
|
+
radioRef.current?.click();
|
106
95
|
}
|
107
96
|
}
|
108
|
-
}
|
97
|
+
};
|
109
98
|
|
110
|
-
return
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
99
|
+
return (
|
100
|
+
customChildren ? (
|
101
|
+
<Flex
|
102
|
+
{...ariaProps}
|
103
|
+
{...dataProps}
|
104
|
+
{...htmlProps}
|
105
|
+
align='center'
|
106
|
+
className={classesCustom}
|
107
|
+
cursor='pointer'
|
108
|
+
htmlFor={id}
|
109
|
+
htmlOptions={{
|
110
|
+
onClick: ((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
111
|
+
handleContainerClick(event);
|
112
|
+
}) as unknown as () => void
|
113
|
+
}}
|
114
|
+
id="radio-container"
|
115
|
+
>
|
116
|
+
<label className={buildCss('pb_radio_kit', alignment)}>
|
127
117
|
<input
|
128
|
-
{...checkedProps}
|
129
118
|
disabled={disabled}
|
130
119
|
id={id}
|
131
120
|
name={name}
|
132
121
|
onChange={onChange}
|
133
|
-
ref={
|
122
|
+
ref={radioRef}
|
134
123
|
type="radio"
|
135
124
|
value={value}
|
136
125
|
{...props}
|
137
126
|
/>
|
127
|
+
<span className="pb_radio_button" />
|
128
|
+
</label>
|
129
|
+
<div id="pb-radio-children-wrapper"> {children} </div>
|
130
|
+
</Flex>
|
131
|
+
) : (
|
132
|
+
<label
|
133
|
+
{...ariaProps}
|
134
|
+
{...dataProps}
|
135
|
+
{...htmlProps}
|
136
|
+
className={classes}
|
137
|
+
htmlFor={id}
|
138
|
+
>
|
139
|
+
<>{displayRadio(props)}</>
|
138
140
|
<span className="pb_radio_button" />
|
141
|
+
<Body
|
142
|
+
dark={dark}
|
143
|
+
status={error ? 'negative' : null}
|
144
|
+
text={label}
|
145
|
+
variant={null}
|
146
|
+
/>
|
139
147
|
</label>
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<label
|
144
|
-
{...ariaProps}
|
145
|
-
{...dataProps}
|
146
|
-
{...htmlProps}
|
147
|
-
className={classes}
|
148
|
-
htmlFor={id}
|
149
|
-
>
|
150
|
-
{displayRadio(props)}
|
151
|
-
<span className="pb_radio_button" />
|
152
|
-
<Body
|
153
|
-
dark={dark}
|
154
|
-
status={error ? 'negative' : null}
|
155
|
-
text={label}
|
156
|
-
variant={null}
|
157
|
-
/>
|
158
|
-
</label>
|
159
|
-
)
|
160
|
-
})
|
148
|
+
)
|
149
|
+
);
|
150
|
+
};
|
161
151
|
|
162
|
-
|
163
|
-
export default Radio
|
152
|
+
export default forwardRef(Radio);
|
@@ -16,7 +16,6 @@ examples:
|
|
16
16
|
- radio_alignment: Alignment
|
17
17
|
- radio_disabled: Disabled
|
18
18
|
- radio_custom_children: Custom Children
|
19
|
-
- radio_react_hook: React Hook Form
|
20
19
|
|
21
20
|
swift:
|
22
21
|
- radio_default_swift: Default
|
@@ -27,4 +26,4 @@ examples:
|
|
27
26
|
- radio_spacing_swift: Spacing
|
28
27
|
- radio_padding_swift: Padding
|
29
28
|
- radio_subtitle_swift: Subtitle
|
30
|
-
- radio_props_swift: ""
|
29
|
+
- radio_props_swift: ""
|
@@ -4,4 +4,3 @@ export { default as RadioError } from './_radio_error.jsx'
|
|
4
4
|
export { default as RadioAlignment } from './_radio_alignment.jsx'
|
5
5
|
export { default as RadioDisabled } from './_radio_disabled.jsx'
|
6
6
|
export { default as RadioCustomChildren } from './_radio_custom_children.jsx'
|
7
|
-
export { default as RadioReactHook } from './_radio_react_hook.jsx'
|
@@ -86,19 +86,3 @@ test('has disabled attribute', () => {
|
|
86
86
|
expect(input).toHaveAttribute('disabled')
|
87
87
|
})
|
88
88
|
|
89
|
-
|
90
|
-
test('has ref in the input element', () => {
|
91
|
-
const ref = React.createRef()
|
92
|
-
render(
|
93
|
-
<Radio
|
94
|
-
data={{ testid: testId }}
|
95
|
-
name="Radio-name"
|
96
|
-
ref={ref}
|
97
|
-
text="Radio"
|
98
|
-
value="radio value"
|
99
|
-
/>
|
100
|
-
)
|
101
|
-
|
102
|
-
expect(ref.current).not.toBeNull()
|
103
|
-
expect(ref.current?.tagName).toBe('INPUT')
|
104
|
-
})
|
@@ -10,7 +10,8 @@ import { highchartsTheme } from "../pb_dashboard/pbChartsLightTheme";
|
|
10
10
|
import { highchartsDarkTheme } from "../pb_dashboard/pbChartsDarkTheme";
|
11
11
|
import mapColors from "../pb_dashboard/pbChartsColorsHelper";
|
12
12
|
import treemap from 'highcharts/modules/treemap'
|
13
|
-
import { merge
|
13
|
+
import { merge} from '../utilities/object'
|
14
|
+
|
14
15
|
|
15
16
|
type TreemapChartProps = {
|
16
17
|
chartData: {
|
@@ -53,7 +54,7 @@ const TreemapChart = ({
|
|
53
54
|
type = "treemap",
|
54
55
|
...props
|
55
56
|
}: TreemapChartProps): React.ReactElement => {
|
56
|
-
|
57
|
+
|
57
58
|
const ariaProps = buildAriaProps(aria)
|
58
59
|
const dataProps = buildDataProps(data)
|
59
60
|
const htmlProps = buildHtmlProps(htmlOptions)
|
@@ -62,9 +63,9 @@ const TreemapChart = ({
|
|
62
63
|
dark
|
63
64
|
? Highcharts.setOptions(highchartsDarkTheme)
|
64
65
|
: Highcharts.setOptions(highchartsTheme);
|
65
|
-
};
|
66
|
+
};
|
66
67
|
treemap(Highcharts)
|
67
|
-
setupTheme();
|
68
|
+
setupTheme();
|
68
69
|
|
69
70
|
const staticOptions = {
|
70
71
|
title: {
|
@@ -3,7 +3,8 @@ import Select from 'react-select'
|
|
3
3
|
import AsyncSelect from 'react-select/async'
|
4
4
|
import CreateableSelect from 'react-select/creatable'
|
5
5
|
import AsyncCreateableSelect from 'react-select/async-creatable'
|
6
|
-
import { get, isString, uniqueId } from '
|
6
|
+
import { get, isString, uniqueId } from '../utilities/object'
|
7
|
+
|
7
8
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
8
9
|
import classnames from 'classnames'
|
9
10
|
|
@@ -1,3 +1,84 @@
|
|
1
1
|
/* 🛠️ Any commonly used lodash functions can be added here. 🤙 */
|
2
2
|
|
3
|
-
export const isEmpty = (obj:
|
3
|
+
export const isEmpty = (obj: any) => [Object, Array].includes((obj || {}).constructor) && !Object.entries((obj || {})).length;
|
4
|
+
|
5
|
+
export const get = <T, R = any>(obj: T, path: string, defaultValue?: R): R | any => {
|
6
|
+
const travel = (regexp: RegExp): any =>
|
7
|
+
String.prototype.split
|
8
|
+
.call(path, regexp)
|
9
|
+
.filter(Boolean)
|
10
|
+
.reduce((res: any, key: string) => (res !== null && res !== undefined ? res[key] : res), obj)
|
11
|
+
const result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/)
|
12
|
+
return result === undefined || result === obj ? defaultValue : result
|
13
|
+
}
|
14
|
+
|
15
|
+
export const map = <T, U>(
|
16
|
+
collection: T[] | Record<string, T> | null | undefined,
|
17
|
+
iteratee: (value: any, key: string, collection: T[] | Record<string, T>) => U
|
18
|
+
): U[] => {
|
19
|
+
if (!collection) return []
|
20
|
+
const coerce = (val: any) => {
|
21
|
+
if (val === true) return val
|
22
|
+
if (
|
23
|
+
typeof val === "number" ||
|
24
|
+
typeof val === "string" ||
|
25
|
+
typeof val === "boolean" ||
|
26
|
+
val === null
|
27
|
+
)
|
28
|
+
return String(val)
|
29
|
+
return val
|
30
|
+
}
|
31
|
+
return Array.isArray(collection)
|
32
|
+
? collection.map((v, i) => iteratee(coerce(v), String(i), collection))
|
33
|
+
: Object.keys(collection).map(key => iteratee(coerce(collection[key]), key, collection))
|
34
|
+
}
|
35
|
+
|
36
|
+
export const isString = (str: unknown): str is string =>
|
37
|
+
str != null && typeof (str as any).valueOf() === "string"
|
38
|
+
|
39
|
+
export const omitBy = <T extends Record<string, any>>(
|
40
|
+
obj: T,
|
41
|
+
predicate: (value: T[keyof T], key: string) => boolean
|
42
|
+
): Partial<T> => {
|
43
|
+
if (obj === null || typeof obj !== 'object') return {} as Partial<T>
|
44
|
+
return Object.keys(obj).reduce((result, key) => {
|
45
|
+
const typedKey = key as keyof T
|
46
|
+
if (!predicate(obj[typedKey], key)) {
|
47
|
+
result[typedKey] = obj[typedKey]
|
48
|
+
}
|
49
|
+
return result
|
50
|
+
}, {} as Partial<T>)
|
51
|
+
}
|
52
|
+
|
53
|
+
export const uniqueId: (prefix?: string) => string = (() => {
|
54
|
+
let counter = 0
|
55
|
+
return (prefix = '') => `${prefix}${++counter}`
|
56
|
+
})()
|
57
|
+
|
58
|
+
type PlainObject = { [key: string]: any }
|
59
|
+
|
60
|
+
const isObject = (item: any): item is PlainObject =>
|
61
|
+
item !== null && typeof item === 'object'
|
62
|
+
|
63
|
+
export const merge = <T extends PlainObject>(
|
64
|
+
target: T,
|
65
|
+
...sources: PlainObject[]
|
66
|
+
): T => {
|
67
|
+
if (!sources.length) return target
|
68
|
+
const source = sources.shift()!
|
69
|
+
if (isObject(target) && isObject(source)) {
|
70
|
+
Object.keys(source).forEach((key: string) => {
|
71
|
+
const typedKey = key as keyof T
|
72
|
+
const srcValue = source[key]
|
73
|
+
if (isObject(srcValue)) {
|
74
|
+
if (!target[typedKey]) {
|
75
|
+
target[typedKey] = (Array.isArray(srcValue) ? [] : {}) as unknown as T[typeof typedKey]
|
76
|
+
}
|
77
|
+
merge(target[typedKey], srcValue)
|
78
|
+
} else {
|
79
|
+
target[typedKey] = srcValue
|
80
|
+
}
|
81
|
+
})
|
82
|
+
}
|
83
|
+
return merge(target, ...sources)
|
84
|
+
}
|