playbook_ui 16.3.0 → 16.4.0.pre.alpha.PLAY2718containerfalseborderradiusresponsiveonly15164
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/Components/CustomCell.tsx +17 -4
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableActions.ts +21 -9
- data/app/pb_kits/playbook/pb_advanced_table/Hooks/useTableState.ts +5 -2
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/ExpansionControlHelpers.tsx +25 -1
- data/app/pb_kits/playbook/pb_advanced_table/Utilities/RowModelUtils.ts +100 -0
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +65 -1
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +12 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +109 -2
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.jsx +50 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_cascade_collapse.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.html.erb +57 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_pinned_rows_rails.md +7 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_parent_only.jsx +175 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_parent_only.md +5 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +31 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.jsx +93 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/index.js +130 -29
- data/app/pb_kits/playbook/pb_advanced_table/scss_partials/advanced_table_sticky_mixin.scss +6 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +21 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +115 -9
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +12 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.rb +9 -1
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +6 -1
- data/app/pb_kits/playbook/pb_collapsible/index.js +15 -26
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +3 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.jsx +6 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.html.erb +3 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height.jsx +6 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height_placement.html.erb +3 -3
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_full_height_placement.jsx +6 -3
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +3 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.html.erb +16 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_closing_options_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.html.erb +224 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_custom_event_type.md +7 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +8 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +255 -46
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +19 -14
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.scss +4 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx +3 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin.html.erb +46 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin.jsx +42 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin_rails.md +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/_fixed_confirmation_toast_nav_margin_react.md +1 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_fixed_confirmation_toast/fixed_confirmation_toast.rb +7 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +7 -1
- data/app/pb_kits/playbook/pb_list/_list_mixin.scss +4 -4
- data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +1 -1
- data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +24 -15
- data/app/pb_kits/playbook/pb_popover/docs/_popover_placement.jsx +81 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_placement_react.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_position.html.erb +128 -0
- data/app/pb_kits/playbook/pb_popover/docs/_popover_position_rails.md +1 -0
- data/app/pb_kits/playbook/pb_popover/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_popover/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +35 -134
- data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_editor.tsx +51 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/_trix_editor.tsx +206 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +56 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.md +1 -0
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +13 -21
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +0 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/inlineFocus.ts +5 -4
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +19 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +24 -21
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.jsx +152 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props.md +17 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.html.erb +121 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_with_card_title_props_rails.md +17 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -11
- data/app/pb_kits/playbook/pb_table/table.rb +4 -0
- data/app/pb_kits/playbook/pb_table/table.test.js +33 -0
- data/app/pb_kits/playbook/pb_textarea/_textarea.scss +4 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +105 -3
- data/app/pb_kits/playbook/utilities/domHelpers.ts +50 -0
- data/dist/chunks/{_pb_line_graph-CKBPxTmM.js → _pb_line_graph-D6s5rymw.js} +1 -1
- data/dist/chunks/_typeahead-Bh0RF1X-.js +1 -0
- data/dist/chunks/componentRegistry-DRSp5D_e.js +1 -0
- data/dist/chunks/{globalProps-DLCfJwiU.js → globalProps-Ds_6HBhX.js} +1 -1
- data/dist/chunks/lib-BaO72ugL.js +29 -0
- data/dist/chunks/vendor.js +5 -5
- data/dist/menu.yml +3 -2
- 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/pb_forms_helper.rb +3 -0
- data/lib/playbook/version.rb +2 -2
- metadata +34 -31
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.html.erb +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.jsx +0 -15
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.html.erb +0 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_focus.jsx +0 -17
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.html.erb +0 -6
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.jsx +0 -16
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.jsx +0 -28
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_label.md +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.html.erb +0 -35
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_preview.jsx +0 -45
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.html.erb +0 -10
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.jsx +0 -22
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_required_indicator.md +0 -3
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_simple.jsx +0 -13
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.html.erb +0 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_sticky.jsx +0 -15
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.html.erb +0 -115
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_templates.jsx +0 -42
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.html.erb +0 -4
- data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.jsx +0 -14
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb +0 -5
- data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +0 -63
- data/dist/chunks/_typeahead-B7bktFm6.js +0 -1
- data/dist/chunks/componentRegistry-DzmmLR2x.js +0 -1
- data/dist/chunks/lib-QT_7rPYf.js +0 -29
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import inlineFocus from './inlineFocus'
|
|
4
|
+
import applyFocusState from './useFocus'
|
|
5
|
+
import './_dedupe_trix_toolbar'
|
|
6
|
+
|
|
7
|
+
type Editor = {
|
|
8
|
+
element?: HTMLElement,
|
|
9
|
+
insertHTML?: (html: string) => void,
|
|
10
|
+
loadHTML?: (html: string) => void,
|
|
11
|
+
setSelectedRange?: (range: Array<number>) => void,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type TrixConfig = {
|
|
15
|
+
textAttributes?: {
|
|
16
|
+
inlineCode?: {
|
|
17
|
+
tagName: string,
|
|
18
|
+
inheritable: boolean,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type TrixInstance = {
|
|
24
|
+
config: TrixConfig,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type TrixEditorComponentProps = {
|
|
28
|
+
className: string,
|
|
29
|
+
fileParamName?: string,
|
|
30
|
+
mergeTags: unknown[],
|
|
31
|
+
onChange: (html: string, text: string) => void,
|
|
32
|
+
onEditorReady: (editorInstance: Editor) => void,
|
|
33
|
+
placeholder?: string,
|
|
34
|
+
value?: string,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type TrixTextEditorProps = {
|
|
38
|
+
TrixEditor?: React.ComponentType<TrixEditorComponentProps>,
|
|
39
|
+
focus?: boolean,
|
|
40
|
+
id?: string,
|
|
41
|
+
inputOptions?: { [key: string]: string | number | boolean | (() => void) },
|
|
42
|
+
label?: string,
|
|
43
|
+
name?: string,
|
|
44
|
+
onChange: (html: string, text: string) => void,
|
|
45
|
+
placeholder?: string,
|
|
46
|
+
template: string,
|
|
47
|
+
toolbarBottom?: boolean,
|
|
48
|
+
trixInstance?: TrixInstance,
|
|
49
|
+
value?: string,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const TrixTextEditor = ({
|
|
53
|
+
TrixEditor,
|
|
54
|
+
focus = false,
|
|
55
|
+
id,
|
|
56
|
+
inputOptions = {},
|
|
57
|
+
label,
|
|
58
|
+
name,
|
|
59
|
+
onChange,
|
|
60
|
+
placeholder,
|
|
61
|
+
template,
|
|
62
|
+
toolbarBottom = false,
|
|
63
|
+
trixInstance = undefined,
|
|
64
|
+
value = '',
|
|
65
|
+
}: TrixTextEditorProps): React.ReactElement => {
|
|
66
|
+
const [editor, setEditor] = useState<Editor>()
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const textAttributes = trixInstance?.config?.textAttributes
|
|
70
|
+
if (!textAttributes) return
|
|
71
|
+
|
|
72
|
+
textAttributes.inlineCode = {
|
|
73
|
+
tagName: 'code',
|
|
74
|
+
inheritable: true,
|
|
75
|
+
}
|
|
76
|
+
}, [trixInstance])
|
|
77
|
+
|
|
78
|
+
const handleOnEditorReady = (editorInstance: Editor) => {
|
|
79
|
+
setEditor(editorInstance)
|
|
80
|
+
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
const oldId = editorInstance.element?.getAttribute('input')
|
|
83
|
+
if (!oldId) return
|
|
84
|
+
|
|
85
|
+
const hiddenInput = document.getElementById(oldId) as HTMLElement | null
|
|
86
|
+
if (!hiddenInput) return
|
|
87
|
+
|
|
88
|
+
const hiddenInputId = (inputOptions.id as string) || oldId
|
|
89
|
+
|
|
90
|
+
if (hiddenInputId !== oldId) {
|
|
91
|
+
hiddenInput.id = hiddenInputId
|
|
92
|
+
editorInstance.element?.setAttribute('input', hiddenInputId)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (inputOptions.name) {
|
|
96
|
+
hiddenInput.setAttribute('name', inputOptions.name as string)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const editorDomId = (id as string) || `${hiddenInputId}_trix`
|
|
100
|
+
const trixLabelId = ((id as string) || hiddenInputId) + '-label'
|
|
101
|
+
|
|
102
|
+
if (label) {
|
|
103
|
+
editorInstance.element?.setAttribute('aria-labelledby', trixLabelId)
|
|
104
|
+
}
|
|
105
|
+
if (editorInstance.element) {
|
|
106
|
+
editorInstance.element.id = editorDomId
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!editor || !editor.element) return
|
|
113
|
+
|
|
114
|
+
const toolbarElement = editor.element.parentElement?.querySelector('trix-toolbar') as HTMLElement | null
|
|
115
|
+
if (!toolbarElement) return
|
|
116
|
+
|
|
117
|
+
const blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement | null
|
|
118
|
+
if (!blockCodeButton) return
|
|
119
|
+
|
|
120
|
+
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]') as HTMLElement | null
|
|
121
|
+
if (!inlineCodeButton) {
|
|
122
|
+
inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
|
|
123
|
+
blockCodeButton.hidden = true
|
|
124
|
+
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
|
125
|
+
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (toolbarBottom) {
|
|
129
|
+
editor.element.after(toolbarElement)
|
|
130
|
+
}
|
|
131
|
+
}, [editor, toolbarBottom])
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!focus) return
|
|
135
|
+
|
|
136
|
+
document.addEventListener('trix-focus', applyFocusState)
|
|
137
|
+
document.addEventListener('trix-blur', applyFocusState)
|
|
138
|
+
applyFocusState()
|
|
139
|
+
|
|
140
|
+
return () => {
|
|
141
|
+
document.removeEventListener('trix-focus', applyFocusState)
|
|
142
|
+
document.removeEventListener('trix-blur', applyFocusState)
|
|
143
|
+
}
|
|
144
|
+
}, [focus])
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
document.addEventListener('trix-focus', inlineFocus)
|
|
148
|
+
document.addEventListener('trix-blur', inlineFocus)
|
|
149
|
+
|
|
150
|
+
return () => {
|
|
151
|
+
document.removeEventListener('trix-focus', inlineFocus)
|
|
152
|
+
document.removeEventListener('trix-blur', inlineFocus)
|
|
153
|
+
}
|
|
154
|
+
}, [])
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!editor || !template) return
|
|
158
|
+
editor.loadHTML && editor.loadHTML('')
|
|
159
|
+
editor.setSelectedRange && editor.setSelectedRange([0, 0])
|
|
160
|
+
editor.insertHTML && editor.insertHTML(template)
|
|
161
|
+
}, [editor, template])
|
|
162
|
+
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
if (!editor?.element) return
|
|
165
|
+
|
|
166
|
+
const clickHandler = ({ target }: Event) => {
|
|
167
|
+
const trixEditorContainer = (target as Element).closest('.pb_rich_text_editor_kit')
|
|
168
|
+
if (!trixEditorContainer) return
|
|
169
|
+
|
|
170
|
+
const anchorElement = (target as Element).closest('a') as HTMLAnchorElement | null
|
|
171
|
+
if (!anchorElement) return
|
|
172
|
+
|
|
173
|
+
if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
editor.element.addEventListener('click', clickHandler)
|
|
177
|
+
|
|
178
|
+
return () => {
|
|
179
|
+
editor.element?.removeEventListener('click', clickHandler)
|
|
180
|
+
}
|
|
181
|
+
}, [editor])
|
|
182
|
+
|
|
183
|
+
if (!TrixEditor) {
|
|
184
|
+
return (
|
|
185
|
+
<div style={{ color: 'red', padding: '1em', border: '1px solid #f00', background: '#fff0f0' }}>
|
|
186
|
+
<strong>Trix Editor is not available.</strong>
|
|
187
|
+
<br />
|
|
188
|
+
Please import <code>TrixEditor</code> from <code>react-trix</code> and pass it as a prop to <code>RichTextEditor</code>.
|
|
189
|
+
<br />
|
|
190
|
+
<pre>{`import { TrixEditor } from 'react-trix';\n<RichTextEditor TrixEditor={TrixEditor} ... />`}</pre>
|
|
191
|
+
</div>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return React.createElement(TrixEditor, {
|
|
196
|
+
className: '',
|
|
197
|
+
fileParamName: name,
|
|
198
|
+
mergeTags: [],
|
|
199
|
+
onChange,
|
|
200
|
+
onEditorReady: handleOnEditorReady,
|
|
201
|
+
placeholder,
|
|
202
|
+
value,
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export default TrixTextEditor
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import RichTextEditor from '../../pb_rich_text_editor/_rich_text_editor'
|
|
3
|
+
import Caption from '../../pb_caption/_caption'
|
|
4
|
+
// The TrixEditor and Trix imports are required for the Legacy RichTextEditor to work
|
|
5
|
+
// They are passed as props to the RichTextEditor kit
|
|
6
|
+
import { TrixEditor } from 'react-trix'
|
|
7
|
+
import Trix from 'trix'
|
|
3
8
|
|
|
4
9
|
const RichTextEditorDefault = (props) => {
|
|
5
10
|
const [value, setValue] = useState('Add your text here. You can format your text, add links, quotes, and bullets.'),
|
|
@@ -7,11 +12,62 @@ const RichTextEditorDefault = (props) => {
|
|
|
7
12
|
|
|
8
13
|
return (
|
|
9
14
|
<div>
|
|
15
|
+
<Caption marginBottom="xs"
|
|
16
|
+
text="Default"
|
|
17
|
+
/>
|
|
10
18
|
<RichTextEditor
|
|
19
|
+
TrixEditor={TrixEditor}
|
|
11
20
|
onChange={handleOnChange}
|
|
21
|
+
trixInstance={Trix}
|
|
12
22
|
value={value}
|
|
13
23
|
{...props}
|
|
14
24
|
/>
|
|
25
|
+
<br/>
|
|
26
|
+
<Caption marginBottom="xs"
|
|
27
|
+
text="Simple"
|
|
28
|
+
/>
|
|
29
|
+
<RichTextEditor
|
|
30
|
+
TrixEditor={TrixEditor}
|
|
31
|
+
simple
|
|
32
|
+
trixInstance={Trix}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
<br/>
|
|
36
|
+
<Caption marginBottom="xs"
|
|
37
|
+
text="Focus"
|
|
38
|
+
/>
|
|
39
|
+
<RichTextEditor
|
|
40
|
+
TrixEditor={TrixEditor}
|
|
41
|
+
focus
|
|
42
|
+
trixInstance={Trix}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
<br/>
|
|
46
|
+
<Caption marginBottom="xs"
|
|
47
|
+
text="Inline"
|
|
48
|
+
/>
|
|
49
|
+
<RichTextEditor
|
|
50
|
+
TrixEditor={TrixEditor}
|
|
51
|
+
id="inline"
|
|
52
|
+
inline
|
|
53
|
+
toolbarBottom
|
|
54
|
+
trixInstance={Trix}
|
|
55
|
+
value="Try hovering over this text. Then try modifying it or adding more of your own text."
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
<br/>
|
|
59
|
+
<Caption marginBottom="xs"
|
|
60
|
+
text="Sticky"
|
|
61
|
+
/>
|
|
62
|
+
<RichTextEditor
|
|
63
|
+
TrixEditor={TrixEditor}
|
|
64
|
+
id="sticky"
|
|
65
|
+
sticky
|
|
66
|
+
trixInstance={Trix}
|
|
67
|
+
value="In this example, when you scroll down, the rich text editor's toolbar will scroll along with the page and it will no longer be visible at the top of the page. Dummy text to enable scroll.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ornare lorem ut pellentesque tempor. Vivamus ut ex vestibulum velit rich text editor eleifend fringilla. Sed non metus dictum, elementum mauris wysiwyg html editor non, sagittis odio. Nullam pellentesque leo sit amet ante suscipit wysiwyg html editor sagittis. Donec tempus vulputate suscipit. Ut non felis rich text editor ac dolor pulvinar lacinia eu eget urna. Sed tincidunt sapien vulputate tellus fringilla sodales. Morbi accumsan dui wysiwyg html editor sed massa pellentesque, quis vestibulum lectus scelerisque. Nulla ultrices mi id felis luctus aliquet. Donec nec ligula wysiwyg html editor pretium sapien semper dictum eu id quam. Etiam ut sollicitudin nibh. Quisque eu ultrices dui. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus rich text editor mi eu consequat. Nullam tincidunt erat et placerat mattis. Nunc rich text editor congue, enim vitae dictum dignissim, libero nisl sagittis augue, non aliquet nibh tortor sit amet ex. Aliquam cursus maximus mi eu consequat. Nullam tincidunt erat et placerat mattis."
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
|
|
15
71
|
</div>
|
|
16
72
|
)
|
|
17
73
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
**IMPORTANT**: The Trix version of the RichTextEditor is a Legacy kit and no longer being actively maintained. Please use the advanced Editor above.
|
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
examples:
|
|
2
2
|
|
|
3
3
|
rails:
|
|
4
|
-
- rich_text_editor_default: Default
|
|
5
|
-
- rich_text_editor_simple: Simple
|
|
6
|
-
- rich_text_editor_attributes: Attributes
|
|
7
|
-
- rich_text_editor_focus: Focus
|
|
8
|
-
- rich_text_editor_sticky: Sticky
|
|
9
|
-
- rich_text_editor_templates: Templates
|
|
10
|
-
# - rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
11
|
-
- rich_text_editor_inline: Inline
|
|
12
|
-
- rich_text_editor_required_indicator: Required Indicator
|
|
13
|
-
- rich_text_editor_preview: Preview
|
|
14
4
|
|
|
15
5
|
react:
|
|
16
|
-
- rich_text_editor_default: Default
|
|
17
6
|
- rich_text_editor_advanced_default: Advanced Default
|
|
18
7
|
- rich_text_editor_more_extensions: Advanced (Extra Extensions)
|
|
19
8
|
- rich_text_editor_toolbar_disabled: Advanced (Toolbar disabled)
|
|
20
|
-
- rich_text_editor_simple: Simple
|
|
21
9
|
- rich_text_editor_advanced_simple: Advanced (Simple)
|
|
22
|
-
- rich_text_editor_attributes: Attributes
|
|
23
10
|
- rich_text_editor_advanced_attributes: Advanced (Attributes)
|
|
24
|
-
- rich_text_editor_focus: Focus
|
|
25
11
|
- rich_text_editor_advanced_focus: Advanced (Focus)
|
|
26
|
-
- rich_text_editor_sticky: Sticky
|
|
27
12
|
- rich_text_editor_advanced_sticky: Advanced (Sticky)
|
|
28
|
-
- rich_text_editor_templates: Templates
|
|
29
13
|
- rich_text_editor_advanced_templates: Advanced (Templates)
|
|
30
|
-
# - rich_text_editor_toolbar_bottom: Toolbar Bottom
|
|
31
|
-
- rich_text_editor_inline: Inline
|
|
32
14
|
- rich_text_editor_advanced_inline: Advanced (Inline)
|
|
33
15
|
- rich_text_editor_advanced_height: Advanced Height
|
|
34
16
|
- rich_text_editor_advanced_min_height: Advanced Min Height
|
|
35
|
-
- rich_text_editor_label: Label
|
|
36
17
|
- rich_text_editor_advanced_label: Advanced (Label)
|
|
37
|
-
- rich_text_editor_required_indicator: Required Indicator
|
|
38
18
|
- rich_text_editor_advanced_required_indicator: Advanced Required Indicator
|
|
39
|
-
- rich_text_editor_preview: Preview
|
|
40
19
|
- rich_text_editor_advanced_preview: Advanced Preview
|
|
20
|
+
- rich_text_editor_default: Legacy Default (Trix)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
export { default as RichTextEditorDefault } from './_rich_text_editor_default.jsx'
|
|
2
|
-
export { default as RichTextEditorSimple } from './_rich_text_editor_simple.jsx'
|
|
3
|
-
export { default as RichTextEditorAttributes } from './_rich_text_editor_attributes.jsx'
|
|
4
|
-
export { default as RichTextEditorFocus } from './_rich_text_editor_focus.jsx'
|
|
5
|
-
export { default as RichTextEditorSticky } from './_rich_text_editor_sticky.jsx'
|
|
6
|
-
export { default as RichTextEditorTemplates } from './_rich_text_editor_templates.jsx'
|
|
7
|
-
export { default as RichTextEditorToolbarBottom } from './_rich_text_editor_toolbar_bottom.jsx'
|
|
8
|
-
export { default as RichTextEditorInline } from './_rich_text_editor_inline.jsx'
|
|
9
|
-
export { default as RichTextEditorPreview } from './_rich_text_editor_preview.jsx'
|
|
10
2
|
export { default as RichTextEditorAdvancedDefault } from './_rich_text_editor_advanced_default.jsx'
|
|
11
3
|
export { default as RichTextEditorMoreExtensions } from './_rich_text_editor_more_extensions.jsx'
|
|
12
4
|
export { default as RichTextEditorToolbarDisabled } from './_rich_text_editor_toolbar_disabled.jsx'
|
|
@@ -19,7 +11,5 @@ export { default as RichTextEditorAdvancedSticky } from './_rich_text_editor_adv
|
|
|
19
11
|
export { default as RichTextEditorAdvancedInline } from './_rich_text_editor_advanced_inline.jsx'
|
|
20
12
|
export { default as RichTextEditorAdvancedHeight } from './_rich_text_editor_advanced_height.jsx'
|
|
21
13
|
export { default as RichTextEditorAdvancedMinHeight } from './_rich_text_editor_advanced_min_height.jsx'
|
|
22
|
-
export { default as RichTextEditorRequiredIndicator } from './_rich_text_editor_required_indicator.jsx'
|
|
23
14
|
export { default as RichTextEditorAdvancedRequiredIndicator } from './_rich_text_editor_advanced_required_indicator.jsx'
|
|
24
|
-
export { default as RichTextEditorLabel } from './_rich_text_editor_label.jsx'
|
|
25
15
|
export { default as RichTextEditorAdvancedLabel } from './_rich_text_editor_advanced_label.jsx'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const inlineFocus = () => {
|
|
2
|
-
const trixEditorElement = event.target
|
|
3
|
-
|
|
1
|
+
const inlineFocus = (event: Event) => {
|
|
2
|
+
const trixEditorElement = event.target
|
|
3
|
+
if (!(trixEditorElement instanceof Element)) return
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const trixEditorContainer = trixEditorElement.closest('.pb_rich_text_editor_kit')
|
|
6
|
+
if (!trixEditorContainer?.classList.contains('inline')) return
|
|
6
7
|
|
|
7
8
|
trixEditorContainer.classList.toggle('focused')
|
|
8
9
|
}
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
.pb_selectable_list_kit {
|
|
5
5
|
margin-bottom: 0px;
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
li {
|
|
8
|
+
border-bottom-color: $input_border_default;
|
|
9
|
+
|
|
10
|
+
&:before {
|
|
11
|
+
color: $text_lighter;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
.pb_item_kit,
|
|
8
16
|
.pb_item_kit_checked_item {
|
|
9
17
|
&:hover {
|
|
@@ -14,4 +22,14 @@
|
|
|
14
22
|
.checked_item {
|
|
15
23
|
background-color: $active_light;
|
|
16
24
|
}
|
|
25
|
+
|
|
26
|
+
.dark {
|
|
27
|
+
li {
|
|
28
|
+
border-bottom-color: $input_border_default_dark;
|
|
29
|
+
|
|
30
|
+
&:before {
|
|
31
|
+
color: $text_lighter_dark;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
17
35
|
}
|
|
@@ -20,6 +20,7 @@ type TableProps = {
|
|
|
20
20
|
aria?: { [key: string]: string },
|
|
21
21
|
children: React.ReactNode[] | React.ReactNode,
|
|
22
22
|
className: string,
|
|
23
|
+
cardProps?: { [key: string]: any },
|
|
23
24
|
collapse?: "sm" | "md" | "lg",
|
|
24
25
|
container?: boolean,
|
|
25
26
|
dark?: boolean,
|
|
@@ -42,6 +43,7 @@ type TableProps = {
|
|
|
42
43
|
striped?: boolean,
|
|
43
44
|
tag?: "table" | "div",
|
|
44
45
|
title?: string,
|
|
46
|
+
titleProps?: { [key: string]: any },
|
|
45
47
|
variant?: "default" | "withFilter",
|
|
46
48
|
verticalBorder?: boolean,
|
|
47
49
|
} & GlobalProps
|
|
@@ -52,6 +54,8 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
52
54
|
const {
|
|
53
55
|
aria = {},
|
|
54
56
|
variant = 'default',
|
|
57
|
+
cardProps = {},
|
|
58
|
+
titleProps = {},
|
|
55
59
|
children,
|
|
56
60
|
className,
|
|
57
61
|
collapse = variant === 'withFilter' ? 'md' : 'sm',
|
|
@@ -348,34 +352,33 @@ const Table = (props: TableProps): React.ReactElement => {
|
|
|
348
352
|
|
|
349
353
|
// Merge default props with user-provided props (user props override defaults)
|
|
350
354
|
const mergedFilterProps = { ...defaultFilterProps, ...filterProps }
|
|
355
|
+
|
|
356
|
+
// Default card props that CAN be overridden (All props from Card kit CAN be used, but these are the ones we set as defaults)
|
|
357
|
+
const defaultCardProps: { [key: string]: any } = {
|
|
358
|
+
padding: "none",
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Merge default props with user-provided props (user props override defaults)
|
|
362
|
+
const mergedCardProps = { ...defaultCardProps, ...cardProps }
|
|
363
|
+
|
|
364
|
+
// Default title props that CAN be overridden (All props from Title kit CAN be used, but these are the ones we set as defaults)
|
|
365
|
+
const defaultTitleProps: { [key: string]: any } = {
|
|
366
|
+
size: 3,
|
|
367
|
+
paddingY: "md",
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Merge default props with user-provided props (user props override defaults)
|
|
371
|
+
const mergedTitleProps = { ...defaultTitleProps, ...titleProps }
|
|
351
372
|
|
|
352
373
|
return (
|
|
353
374
|
<>
|
|
354
375
|
{title && (
|
|
355
|
-
<Title
|
|
356
|
-
paddingLeft={{
|
|
357
|
-
xs: "sm",
|
|
358
|
-
sm: "sm",
|
|
359
|
-
md: "xl",
|
|
360
|
-
lg: "xl",
|
|
361
|
-
xl: "xl",
|
|
362
|
-
default: "xl",
|
|
363
|
-
} as any}
|
|
364
|
-
paddingY="md"
|
|
365
|
-
size={3}
|
|
376
|
+
<Title {...mergedTitleProps}
|
|
366
377
|
text={title}
|
|
367
|
-
/>
|
|
378
|
+
/>
|
|
368
379
|
)}
|
|
369
380
|
<Card
|
|
370
|
-
|
|
371
|
-
xs: "sm",
|
|
372
|
-
sm: "sm",
|
|
373
|
-
md: "xl",
|
|
374
|
-
lg: "xl",
|
|
375
|
-
xl: "xl",
|
|
376
|
-
default: "xl",
|
|
377
|
-
} as any}
|
|
378
|
-
padding="none"
|
|
381
|
+
{...mergedCardProps}
|
|
379
382
|
>
|
|
380
383
|
<Flex
|
|
381
384
|
align="stretch"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import { Button, Date as DateKit, DatePicker, Dropdown, Select, Table, TextInput, Typeahead, Flex } from "playbook-ui"
|
|
3
|
+
|
|
4
|
+
// Mock Data for Table
|
|
5
|
+
const users = [
|
|
6
|
+
{ id: 1, name: "Jennifer", title: "Associate Scrum Master", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-01" },
|
|
7
|
+
{ id: 2, name: "Nick", title: "UX Engineer II", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-02" },
|
|
8
|
+
{ id: 3, name: "Nida", title: "Senior UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-03" },
|
|
9
|
+
{ id: 4, name: "Justin", title: "Director of User Experience Engineering", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-04" },
|
|
10
|
+
{ id: 5, name: "Edward", title: "UX Designer II", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-05" },
|
|
11
|
+
{ id: 6, name: "Elisa", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-06" },
|
|
12
|
+
{ id: 7, name: "Gary", title: "UX Engineer", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-07" },
|
|
13
|
+
{ id: 8, name: "Barkley", title: "Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-08" },
|
|
14
|
+
{ id: 9, name: "Aaron", title: "Associate Nitro Quality Ninja", department: "Business Technology", branch: "Philadelphia", startDate: "2025-01-09" },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
const TableWithFilterWithCardTitleProps = () => {
|
|
18
|
+
const [territory, setTerritory] = useState("")
|
|
19
|
+
|
|
20
|
+
// --------Filter content example ------
|
|
21
|
+
const filterContent = ({ closePopover }) => (
|
|
22
|
+
<>
|
|
23
|
+
<TextInput
|
|
24
|
+
label="Territory ID"
|
|
25
|
+
onChange={event => setTerritory(event.target.value)}
|
|
26
|
+
value={territory}
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<Typeahead
|
|
30
|
+
label="Title"
|
|
31
|
+
options={[
|
|
32
|
+
{ key: "senior-ux-engineer", label: "Senior UX Engineer", value: "senior-ux-engineer" },
|
|
33
|
+
{ key: "ux-engineer", label: "UX Engineer", value: "ux-engineer" },
|
|
34
|
+
{ key: "ux-designer", label: "UX Designer", value: "ux-designer" }
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<Select
|
|
39
|
+
blankSelection="All Departments"
|
|
40
|
+
label="Department"
|
|
41
|
+
options={[
|
|
42
|
+
{ value: "Business Technology", label: "Business Technology", key: "business-technology" },
|
|
43
|
+
{ value: "Customer Development", label: "Customer Development", key: "customer-development" },
|
|
44
|
+
{ value: "Talent Acquisition", label: "Talent Acquisition", key: "talent-acquisition" }
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<Dropdown
|
|
49
|
+
label="Branch"
|
|
50
|
+
options={[
|
|
51
|
+
{ key: "Philadelphia", label: "Philadelphia", value: "philadelphia" },
|
|
52
|
+
{ key: "New York", label: "New York", value: "new-york" },
|
|
53
|
+
{ key: "Austin", label: "Austin", value: "austin" }
|
|
54
|
+
]}
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
<DatePicker
|
|
58
|
+
label="Start Date"
|
|
59
|
+
paddingY="sm"
|
|
60
|
+
pickerId="startedOn"
|
|
61
|
+
/>
|
|
62
|
+
<Flex spacing="between">
|
|
63
|
+
<Button
|
|
64
|
+
onClick={() => {
|
|
65
|
+
alert("No filtering functionality - just a pattern demo!")
|
|
66
|
+
closePopover()
|
|
67
|
+
}}
|
|
68
|
+
text="Filter"
|
|
69
|
+
/>
|
|
70
|
+
<Button
|
|
71
|
+
text="Defaults"
|
|
72
|
+
variant="secondary"
|
|
73
|
+
/>
|
|
74
|
+
</Flex>
|
|
75
|
+
</>
|
|
76
|
+
)
|
|
77
|
+
// -------End Filter content example ------
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Table
|
|
81
|
+
cardProps={{marginX: {
|
|
82
|
+
xs: "sm",
|
|
83
|
+
sm: "sm",
|
|
84
|
+
md: "xl",
|
|
85
|
+
lg: "xl",
|
|
86
|
+
xl: "xl",
|
|
87
|
+
default: "xl",
|
|
88
|
+
}}}
|
|
89
|
+
filterContent={filterContent}
|
|
90
|
+
filterProps={{
|
|
91
|
+
results: 50,
|
|
92
|
+
sortOptions: {
|
|
93
|
+
territory_id: "Territory ID",
|
|
94
|
+
first_name: "Name",
|
|
95
|
+
started_on: "Start Date",
|
|
96
|
+
department_name: "Department",
|
|
97
|
+
title_name: "Title",
|
|
98
|
+
branch_branch_name: "Branch",
|
|
99
|
+
},
|
|
100
|
+
sortValue: [{ name: 'started_on', dir: 'asc' }],
|
|
101
|
+
}}
|
|
102
|
+
title="Table Title Here"
|
|
103
|
+
titleProps={{
|
|
104
|
+
paddingLeft:{
|
|
105
|
+
xs: "sm",
|
|
106
|
+
sm: "sm",
|
|
107
|
+
md: "xl",
|
|
108
|
+
lg: "xl",
|
|
109
|
+
xl: "xl",
|
|
110
|
+
default: "xl",
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
variant="withFilter"
|
|
114
|
+
>
|
|
115
|
+
<Table.Head>
|
|
116
|
+
<Table.Row>
|
|
117
|
+
<Table.Header>{'Territory ID'}</Table.Header>
|
|
118
|
+
<Table.Header>{'Name'}</Table.Header>
|
|
119
|
+
<Table.Header>{'Title'}</Table.Header>
|
|
120
|
+
<Table.Header>{'Department'}</Table.Header>
|
|
121
|
+
<Table.Header>{'Branch'}</Table.Header>
|
|
122
|
+
<Table.Header textAlign="right">{'Start Date'}</Table.Header>
|
|
123
|
+
</Table.Row>
|
|
124
|
+
</Table.Head>
|
|
125
|
+
<Table.Body>
|
|
126
|
+
{users.map((user) => (
|
|
127
|
+
<Table.Row key={user.id}>
|
|
128
|
+
<Table.Cell
|
|
129
|
+
marginX={{ xs: "sm" }}
|
|
130
|
+
numberSpacing="tabular"
|
|
131
|
+
>
|
|
132
|
+
{user.id}
|
|
133
|
+
</Table.Cell>
|
|
134
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.name}</Table.Cell>
|
|
135
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.title}</Table.Cell>
|
|
136
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.department}</Table.Cell>
|
|
137
|
+
<Table.Cell marginX={{ xs: "sm" }}>{user.branch}</Table.Cell>
|
|
138
|
+
<Table.Cell marginX={{ xs: "sm" }}>
|
|
139
|
+
<DateKit
|
|
140
|
+
alignment="right"
|
|
141
|
+
showCurrentYear
|
|
142
|
+
value={user.startDate}
|
|
143
|
+
/>
|
|
144
|
+
</Table.Cell>
|
|
145
|
+
</Table.Row>
|
|
146
|
+
))}
|
|
147
|
+
</Table.Body>
|
|
148
|
+
</Table>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default TableWithFilterWithCardTitleProps
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
The `withFilter` variant also offers 2 additional optional props:
|
|
2
|
+
|
|
3
|
+
`cardProps`: An object containing Card-specific props.
|
|
4
|
+
`titleProps`: An object containing Title-specific props.
|
|
5
|
+
|
|
6
|
+
#### Default Card Props
|
|
7
|
+
|
|
8
|
+
The Table kit automatically sets these Card defaults (which you can override via `cardProps`):
|
|
9
|
+
|
|
10
|
+
- `padding="none"`
|
|
11
|
+
|
|
12
|
+
#### Default Title Props
|
|
13
|
+
|
|
14
|
+
The Table kit automatically sets these Title defaults (which you can override via `titleProps`):
|
|
15
|
+
|
|
16
|
+
- `size={3}`
|
|
17
|
+
- `paddingY="md"`
|