playbook_ui_docs 14.16.0.pre.rc.1 → 14.16.0.pre.rc.2
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/docs/_advanced_table_inline_editing.jsx +102 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_inline_editing.md +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.jsx +91 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_react_hook.md +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +1 -0
- data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -0
- data/dist/playbook-doc.js +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 772529d63fd7a2bab3d1cc810c1b20b5b94043a84833ff4e650bb4f459179f48
|
4
|
+
data.tar.gz: d2a43100853d291f5e5bf0b6e0b5af025176d0f992a9ef732853a4616e057f4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66749f23af5453b1547b98a941fa45688c213f972e26529aefda4832ee15b7bb1439ad8dc338b747ec5621a5806fb0b299cb5922fa119f406513346765791577
|
7
|
+
data.tar.gz: aea449b9e4e1b9b8fb24cf81d5ae31ce114c0e99b19bbb98aaf88bfd25d5a8609e97b18fb4bb92bd7019baabc90eeca8b94f12e8fdf9dc6e674c2c36748db70d
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { AdvancedTable, TextInput, Body } from "playbook-ui";
|
3
|
+
import MOCK_DATA from "./advanced_table_mock_data.json";
|
4
|
+
|
5
|
+
const AdvancedTableInlineEditing = (props) => {
|
6
|
+
const [editedValues, setEditedValues] = useState({});
|
7
|
+
|
8
|
+
const EditableCell = ({ rowId, originalValue, onSave }) => {
|
9
|
+
const [localValue, setLocalValue] = useState(originalValue);
|
10
|
+
|
11
|
+
const handleChange = (e) => setLocalValue(e.target.value);
|
12
|
+
|
13
|
+
const handleBlur = () => {
|
14
|
+
originalValue !== localValue && onSave(rowId, localValue);
|
15
|
+
};
|
16
|
+
|
17
|
+
return (
|
18
|
+
<TextInput inline
|
19
|
+
marginBottom="none"
|
20
|
+
{...props}
|
21
|
+
>
|
22
|
+
<input
|
23
|
+
onBlur={handleBlur}
|
24
|
+
onChange={handleChange}
|
25
|
+
onKeyDown={(e) => e.key === 'Enter' && handleBlur()}
|
26
|
+
value={localValue}
|
27
|
+
/>
|
28
|
+
</TextInput>
|
29
|
+
);
|
30
|
+
};
|
31
|
+
|
32
|
+
const columnDefinitions = [
|
33
|
+
{
|
34
|
+
accessor: "year",
|
35
|
+
label: "Year",
|
36
|
+
cellAccessors: ["quarter", "month", "day"],
|
37
|
+
},
|
38
|
+
{
|
39
|
+
accessor: "newEnrollments",
|
40
|
+
label: "New Enrollments",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
accessor: "scheduledMeetings",
|
44
|
+
label: "Scheduled Meetings",
|
45
|
+
editable: true,
|
46
|
+
customRenderer: (row) => {
|
47
|
+
return (
|
48
|
+
<EditableCell
|
49
|
+
onSave={(id, val) => {
|
50
|
+
setEditedValues((prev) => ({ ...prev, [id]: val }));
|
51
|
+
}}
|
52
|
+
originalValue={
|
53
|
+
editedValues[row.id] ?? row.original.scheduledMeetings
|
54
|
+
}
|
55
|
+
rowId={row.id}
|
56
|
+
/>
|
57
|
+
);
|
58
|
+
},
|
59
|
+
},
|
60
|
+
{
|
61
|
+
accessor: "attendanceRate",
|
62
|
+
label: "Attendance Rate",
|
63
|
+
},
|
64
|
+
{
|
65
|
+
accessor: "completedClasses",
|
66
|
+
label: "Completed Classes",
|
67
|
+
},
|
68
|
+
{
|
69
|
+
accessor: "classCompletionRate",
|
70
|
+
label: "Class Completion Rate",
|
71
|
+
},
|
72
|
+
{
|
73
|
+
accessor: "graduatedStudents",
|
74
|
+
label: "Graduated Students",
|
75
|
+
},
|
76
|
+
];
|
77
|
+
|
78
|
+
return (
|
79
|
+
<div className="App">
|
80
|
+
<AdvancedTable
|
81
|
+
columnDefinitions={columnDefinitions}
|
82
|
+
tableData={MOCK_DATA}
|
83
|
+
{...props}
|
84
|
+
/>
|
85
|
+
{
|
86
|
+
editedValues && Object.keys(editedValues).length > 0 && (
|
87
|
+
<>
|
88
|
+
<Body
|
89
|
+
marginTop="md"
|
90
|
+
{...props}
|
91
|
+
>
|
92
|
+
Edited Values by Row Id:
|
93
|
+
</Body>
|
94
|
+
<pre style={{color: 'white'}}>{JSON.stringify(editedValues, null, 2)}</pre>
|
95
|
+
</>
|
96
|
+
)
|
97
|
+
}
|
98
|
+
</div>
|
99
|
+
);
|
100
|
+
};
|
101
|
+
|
102
|
+
export default AdvancedTableInlineEditing;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
Inline Cell Editing can be achieved with a combination of our `TextInput` kit and the `customRenderer` method available through columnDefinitions.
|
2
|
+
|
3
|
+
Hover over any cell within the 'Scheduled Meetings' column to see the TextInput and type in to change values. Values can be saved by clicking away from the TextInput or by hitting 'Enter'.
|
4
|
+
See the code snippet below to see how this was achieved. Devs must manage state themselves as shown.
|
@@ -36,4 +36,5 @@ examples:
|
|
36
36
|
- advanced_table_selectable_rows: Selectable Rows
|
37
37
|
- advanced_table_selectable_rows_no_subrows: Selectable Rows (No Subrows)
|
38
38
|
- advanced_table_selectable_rows_actions: Selectable Rows (With Actions)
|
39
|
-
- advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
|
39
|
+
- advanced_table_selectable_rows_header: Selectable Rows (No Actions Bar)
|
40
|
+
- advanced_table_inline_editing: Inline Cell Editing
|
@@ -20,4 +20,5 @@ export { default as AdvancedTableNoSubrows } from './_advanced_table_no_subrows.
|
|
20
20
|
export { default as AdvancedTableSelectableRowsHeader } from './_advanced_table_selectable_rows_header.jsx'
|
21
21
|
export { default as AdvancedTableSelectableRowsActions } from './_advanced_table_selectable_rows_actions.jsx'
|
22
22
|
export { default as AdvancedTableTablePropsStickyHeader } from './_advanced_table_table_props_sticky_header.jsx'
|
23
|
-
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
23
|
+
export { default as AdvancedTableColumnHeadersCustomCell } from './_advanced_table_column_headers_custom_cell.jsx'
|
24
|
+
export { default as AdvancedTableInlineEditing } from './_advanced_table_inline_editing.jsx'
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import React from "react"
|
2
|
+
import MultiLevelSelect from "../_multi_level_select"
|
3
|
+
import { useForm } from "react-hook-form"
|
4
|
+
|
5
|
+
const treeData = [
|
6
|
+
{
|
7
|
+
label: "Power Home Remodeling",
|
8
|
+
value: "Power Home Remodeling",
|
9
|
+
id: "powerhome1",
|
10
|
+
expanded: true,
|
11
|
+
children: [
|
12
|
+
{
|
13
|
+
label: "People",
|
14
|
+
value: "People",
|
15
|
+
id: "people1",
|
16
|
+
expanded: true,
|
17
|
+
children: [
|
18
|
+
{
|
19
|
+
label: "Talent Acquisition",
|
20
|
+
value: "Talent Acquisition",
|
21
|
+
id: "talent1",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
label: "Business Affairs",
|
25
|
+
value: "Business Affairs",
|
26
|
+
id: "business1",
|
27
|
+
children: [
|
28
|
+
{
|
29
|
+
label: "Initiatives",
|
30
|
+
value: "Initiatives",
|
31
|
+
id: "initiative1",
|
32
|
+
},
|
33
|
+
{
|
34
|
+
label: "Learning & Development",
|
35
|
+
value: "Learning & Development",
|
36
|
+
id: "development1",
|
37
|
+
},
|
38
|
+
],
|
39
|
+
},
|
40
|
+
{
|
41
|
+
label: "People Experience",
|
42
|
+
value: "People Experience",
|
43
|
+
id: "experience1",
|
44
|
+
},
|
45
|
+
],
|
46
|
+
},
|
47
|
+
{
|
48
|
+
label: "Contact Center",
|
49
|
+
value: "Contact Center",
|
50
|
+
id: "contact1",
|
51
|
+
children: [
|
52
|
+
{
|
53
|
+
label: "Appointment Management",
|
54
|
+
value: "Appointment Management",
|
55
|
+
id: "appointment1",
|
56
|
+
},
|
57
|
+
{
|
58
|
+
label: "Customer Service",
|
59
|
+
value: "Customer Service",
|
60
|
+
id: "customer1",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
label: "Energy",
|
64
|
+
value: "Energy",
|
65
|
+
id: "energy1",
|
66
|
+
},
|
67
|
+
],
|
68
|
+
},
|
69
|
+
],
|
70
|
+
},
|
71
|
+
]
|
72
|
+
|
73
|
+
const MultiLevelSelectReactHook = (props) => {
|
74
|
+
const { register, watch } = useForm()
|
75
|
+
const selectedItems = watch("departments")
|
76
|
+
selectedItems && console.log("Selected Items", selectedItems)
|
77
|
+
|
78
|
+
return (
|
79
|
+
<div>
|
80
|
+
<MultiLevelSelect
|
81
|
+
id="multiselect-default"
|
82
|
+
marginBottom="md"
|
83
|
+
treeData={treeData}
|
84
|
+
{...register("departments")}
|
85
|
+
{...props}
|
86
|
+
/>
|
87
|
+
</div>
|
88
|
+
)
|
89
|
+
}
|
90
|
+
|
91
|
+
export default MultiLevelSelectReactHook
|
@@ -0,0 +1 @@
|
|
1
|
+
You can pass `react-hook-form` props to the MultiLevelSelect kit. Check your console to see the full data selected from this example.
|
@@ -12,6 +12,7 @@ examples:
|
|
12
12
|
|
13
13
|
react:
|
14
14
|
- multi_level_select_default: Default
|
15
|
+
- multi_level_select_react_hook: React Hook
|
15
16
|
- multi_level_select_single: Single Select
|
16
17
|
- multi_level_select_single_children_only: Single Select w/ Hidden Radios
|
17
18
|
- multi_level_select_return_all_selected: Return All Selected
|
@@ -7,3 +7,4 @@ 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'
|