playbook_ui 14.9.0.pre.alpha.PLAY16264818 → 14.9.0.pre.alpha.PLAY16264952
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_advanced_table/table_header.html.erb +5 -3
- data/app/pb_kits/playbook/pb_avatar/_avatar.scss +0 -2
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.jsx +53 -49
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom_rails.html.erb +29 -36
- data/app/pb_kits/playbook/pb_body/_body.scss +14 -13
- data/app/pb_kits/playbook/pb_body/_body_mixins.scss +22 -16
- data/app/pb_kits/playbook/pb_bread_crumbs/docs/_bread_crumbs_default.jsx +6 -0
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -1
- data/app/pb_kits/playbook/pb_card/_card_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +33 -26
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_form.jsx +138 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +7 -6
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +9 -4
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.tsx +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleMain.tsx +2 -2
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.scss +5 -0
- data/app/pb_kits/playbook/pb_file_upload/_file_upload.tsx +7 -2
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +8 -2
- data/app/pb_kits/playbook/pb_link/_link.scss +3 -3
- data/app/pb_kits/playbook/pb_nav/_bold_mixin.scss +11 -1
- data/app/pb_kits/playbook/pb_nav/_collapsible_nav.scss +16 -2
- data/app/pb_kits/playbook/pb_nav/_vertical_nav.scss +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +18 -17
- data/app/pb_kits/playbook/pb_select/docs/_select_form.jsx +1 -0
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +4 -4
- data/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb +1 -1
- data/app/pb_kits/playbook/pb_stat_change/_stat_change.tsx +44 -36
- data/app/pb_kits/playbook/pb_stat_change/stat_change.html.erb +4 -4
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.html.erb +95 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.jsx +75 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.jsx +108 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_click.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.jsx +94 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_custom_content.md +0 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.jsx +83 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_rows.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.jsx +120 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_collapsible_with_nested_table.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +5 -0
- data/app/pb_kits/playbook/pb_table/index.ts +100 -26
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +2 -1
- data/app/pb_kits/playbook/pb_table/styles/_collapsible.scss +35 -0
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +106 -1
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +17 -2
- data/app/pb_kits/playbook/pb_title/_title.scss +6 -5
- data/app/pb_kits/playbook/pb_title/_title_mixin.scss +13 -0
- data/app/pb_kits/playbook/tokens/_titles.scss +0 -8
- data/app/pb_kits/playbook/utilities/_hover.scss +11 -2
- data/app/pb_kits/playbook/utilities/globalProps.ts +2 -0
- data/app/pb_kits/playbook/utilities/hookFormProps.ts +9 -3
- data/app/pb_kits/playbook/utilities/test/globalProps/hover.test.js +15 -0
- data/app/pb_kits/playbook/utilities/withReactHookForm.tsx +64 -0
- data/dist/chunks/_typeahead-BqHgiHoJ.js +22 -0
- data/dist/chunks/_weekday_stacked-BAk0aNPW.js +45 -0
- data/dist/chunks/{lib-SyD3buPZ.js → lib-CuCy3_xO.js} +3 -3
- data/dist/chunks/{pb_form_validation-Dt8UJgrJ.js → pb_form_validation-D37k10a0.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +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/dist/playbook.css +1 -1
- data/lib/playbook/hover.rb +7 -1
- data/lib/playbook/version.rb +1 -1
- metadata +20 -6
- data/dist/chunks/_typeahead-B8fkIeXA.js +0 -22
- data/dist/chunks/_weekday_stacked-DxlPBh55.js +0 -45
@@ -0,0 +1,64 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import {
|
3
|
+
FieldValues,
|
4
|
+
Path,
|
5
|
+
UseFormRegister,
|
6
|
+
RegisterOptions,
|
7
|
+
} from "react-hook-form"
|
8
|
+
|
9
|
+
export type WithReactHookFormProps<T extends FieldValues> = {
|
10
|
+
name: Path<T>
|
11
|
+
register?: UseFormRegister<T>
|
12
|
+
rules?: Omit<
|
13
|
+
RegisterOptions<T>,
|
14
|
+
"valueAsNumber" | "valueAsDate" | "setValueAs"
|
15
|
+
>
|
16
|
+
disabled?: boolean
|
17
|
+
}
|
18
|
+
|
19
|
+
function getDisplayName(WrappedComponent: React.ComponentType<any>): string {
|
20
|
+
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
|
21
|
+
}
|
22
|
+
|
23
|
+
export function withReactHookForm<
|
24
|
+
P extends {
|
25
|
+
onChange?: (...args: any[]) => void
|
26
|
+
onBlur?: (...args: any[]) => void
|
27
|
+
ref?: any
|
28
|
+
},
|
29
|
+
T extends FieldValues = FieldValues
|
30
|
+
>(WrappedComponent: React.ComponentType<P>) {
|
31
|
+
const WithReactHookFormComponent = React.forwardRef<HTMLElement, P & WithReactHookFormProps<T>>(
|
32
|
+
(props, ref) => {
|
33
|
+
const { register, name, rules, disabled, ...rest } = props
|
34
|
+
|
35
|
+
if (!register) {
|
36
|
+
return (<WrappedComponent {...(rest as P)}
|
37
|
+
ref={ref}
|
38
|
+
/>)
|
39
|
+
}
|
40
|
+
|
41
|
+
const fieldRegistration = register(name, rules)
|
42
|
+
|
43
|
+
const fieldProps = {
|
44
|
+
...rest,
|
45
|
+
...fieldRegistration,
|
46
|
+
disabled: disabled || (rest as any).disabled,
|
47
|
+
ref: ref || fieldRegistration.ref,
|
48
|
+
onChange: (...args: any[]) => {
|
49
|
+
fieldRegistration.onChange?.(...args)
|
50
|
+
;(rest as P).onChange?.(...args)
|
51
|
+
},
|
52
|
+
onBlur: (...args: any[]) => {
|
53
|
+
fieldRegistration.onBlur?.(...args)
|
54
|
+
;(rest as P).onBlur?.(...args)
|
55
|
+
},
|
56
|
+
}
|
57
|
+
|
58
|
+
return <WrappedComponent {...(fieldProps as P)} />
|
59
|
+
}
|
60
|
+
)
|
61
|
+
|
62
|
+
WithReactHookFormComponent.displayName = `WithReactHookForm(${getDisplayName(WrappedComponent)})`
|
63
|
+
return WithReactHookFormComponent
|
64
|
+
}
|