playbook_ui 13.31.0.pre.alpha.powercentrainplaybookpt23212 → 13.31.0
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_background/background.html.erb +11 -2
- data/app/pb_kits/playbook/pb_body/body.html.erb +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumb_item.html.erb +6 -1
- data/app/pb_kits/playbook/pb_bread_crumbs/bread_crumbs.html.erb +6 -1
- data/app/pb_kits/playbook/pb_button/_button.scss +3 -3
- data/app/pb_kits/playbook/pb_button/_button_mixins.scss +2 -3
- data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +1 -1
- data/app/pb_kits/playbook/pb_caption/caption.html.erb +6 -1
- data/app/pb_kits/playbook/pb_card/card.html.erb +7 -1
- data/app/pb_kits/playbook/pb_dashboard/commonSettings.js +1 -1
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +1 -1
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +1 -1
- data/app/pb_kits/playbook/pb_date_year_stacked/docs/_date_year_stacked_default.jsx +1 -4
- data/app/pb_kits/playbook/pb_detail/detail.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +6 -1
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +5 -2
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +6 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +1 -15
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +0 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +19 -14
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +3 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +3 -7
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +5 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +5 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +1 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -2
- data/app/pb_kits/playbook/pb_dropdown/index.js +4 -33
- data/app/pb_kits/playbook/pb_flex/flex.html.erb +5 -1
- data/app/pb_kits/playbook/pb_form/docs/_form_form_with_validate.html.erb +0 -9
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +1 -1
- data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +6 -1
- data/app/pb_kits/playbook/pb_highlight/highlight.html.erb +5 -1
- data/app/pb_kits/playbook/pb_home_address_street/home_address_street.html.erb +5 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +23 -8
- data/app/pb_kits/playbook/tokens/_titles.scss +4 -4
- data/app/pb_kits/playbook/tokens/_typography.scss +10 -10
- data/dist/menu.yml +472 -566
- data/dist/playbook-rails.js +6 -6
- data/dist/reset.css +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c02852f26be30f0f9abff5ba3089c03c4d9f6878880b2e3f59827e7b556f8c3d
|
4
|
+
data.tar.gz: a5c30e259ea3d6a77135c2f6172d607ddb105732e20caf60f68d1d1f014bf468
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14c183e1ef95272881479defd28dec0aa49a6ee8539af55aa630cdd493aa48918830906465d6a46c0caf405a1c2a8b2b7dd5fc894f0031feb62bbd21341ae22
|
7
|
+
data.tar.gz: 26cd7b2d68304e1c80c4bf3e1bc9ce5cc07cf5c378c82e52bac4541abd61ca0a5a817ded5c6abde4282cb7c785b484778902afa96c3e83e0e7f3fcd84e68872b
|
@@ -1,14 +1,23 @@
|
|
1
1
|
<% if object.image_url.present? %>
|
2
|
-
<%=
|
2
|
+
<%= content_tag(object.tag,
|
3
|
+
aria: object.aria,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
class: object.classname,
|
3
7
|
style: "background-image: url('#{object.image_url}');
|
4
8
|
background-repeat: #{object.background_repeat};
|
5
9
|
background-size: #{object.background_size};
|
6
10
|
background-position: #{object.background_position};",
|
11
|
+
**combined_html_options
|
7
12
|
) do %>
|
8
13
|
<%= content.presence %>
|
9
14
|
<% end %>
|
10
15
|
<% else %>
|
11
|
-
<%=
|
16
|
+
<%= content_tag(object.tag,
|
17
|
+
aria: object.aria,
|
18
|
+
data: object.data,
|
19
|
+
id: object.id,
|
20
|
+
class: object.classname,
|
12
21
|
style: object.custom_background_color
|
13
22
|
) do %>
|
14
23
|
<%= content.presence %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
aria: object.aria,
|
6
|
+
**combined_html_options) do%>
|
2
7
|
<%= content_tag(object.link ? 'a' : 'span', class: 'bread_crumb_item', href: object.link) do %>
|
3
8
|
<%= content.presence %>
|
4
9
|
<% end %>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
|
10
10
|
$pb_button_size: 40px;
|
11
11
|
$pb_button_v_padding: 7px;
|
12
|
-
$pb_button_h_padding:
|
12
|
+
$pb_button_h_padding: 34px;
|
13
13
|
$pb_button_hover_darken: 4%;
|
14
14
|
$pb_button_border_width: 0px;
|
15
15
|
|
@@ -27,14 +27,13 @@ $pb_button_border_width: 0px;
|
|
27
27
|
text-rendering: optimizeLegibility;
|
28
28
|
font-size: $font_small;
|
29
29
|
font-weight: $bold;
|
30
|
-
letter-spacing: $lspace_loose;
|
31
30
|
text-align: center;
|
32
31
|
text-decoration: none;
|
33
32
|
vertical-align: middle;
|
34
33
|
text-transform: none;
|
35
34
|
border-width: $pb_button_border_width;
|
36
35
|
border-style: solid;
|
37
|
-
border-radius: $
|
36
|
+
border-radius: $border_rad_light;
|
38
37
|
min-height: $pb_button_size;
|
39
38
|
line-height: 1.5;
|
40
39
|
padding: $pb_button_v_padding $pb_button_h_padding;
|
@@ -53,7 +53,7 @@ const adjustAxisStyle = (axis) => {
|
|
53
53
|
/* Change axis label styles */
|
54
54
|
axis.labels.style.fontFamily = typography.font_family_base
|
55
55
|
axis.labels.style.color = colors.charcoal
|
56
|
-
axis.labels.style.fontWeight = typography.
|
56
|
+
axis.labels.style.fontWeight = typography.light
|
57
57
|
axis.labels.style.fontSize = typography.font_small
|
58
58
|
}
|
59
59
|
|
@@ -4,10 +4,7 @@ import { DateYearStacked } from '../../'
|
|
4
4
|
const DateYearStackedDefault = (props) => {
|
5
5
|
return (
|
6
6
|
<div>
|
7
|
-
<DateYearStacked
|
8
|
-
date={new Date()}
|
9
|
-
{...props}
|
10
|
-
/>
|
7
|
+
<DateYearStacked date={new Date()} />
|
11
8
|
<DateYearStacked
|
12
9
|
align="center"
|
13
10
|
date={new Date()}
|
@@ -1,5 +1,10 @@
|
|
1
1
|
<div class="pb_dialog_wrapper_rails <%= object.full_height_style %>" data-overlay-click= <%= object.overlay_close %> >
|
2
|
-
<%=
|
2
|
+
<%= content_tag(:dialog,
|
3
|
+
aria: object.aria,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
class: object.classname,
|
7
|
+
**combined_html_options) do %>
|
3
8
|
<% if object.status === "" && object.title %>
|
4
9
|
<%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
|
5
10
|
<% end %>
|
@@ -1,5 +1,8 @@
|
|
1
|
-
<%=
|
2
|
-
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
aria: object.aria,
|
5
|
+
**combined_html_options) do %>
|
3
6
|
<% if object.confirm_button && object.cancel_button %>
|
4
7
|
<div class="dialog-pseudo-footer"></div>
|
5
8
|
<%= pb_rails("flex", props: { classname:object.classname, spacing:"between", padding_x:"sm", padding:"sm", padding_bottom:"sm" }) do %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.sticky_header,
|
5
|
+
aria: object.aria,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("flex", props: {classname:object.classname, spacing:"between", padding:"sm", align:"center"}) do %>
|
3
8
|
<%= content.presence || object.title %>
|
4
9
|
|
@@ -51,16 +51,7 @@ export const DraggableContext = () => {
|
|
51
51
|
return useContext(DragContext);
|
52
52
|
};
|
53
53
|
|
54
|
-
export const DraggableProvider = ({
|
55
|
-
children,
|
56
|
-
initialItems,
|
57
|
-
onReorder,
|
58
|
-
onDragStart,
|
59
|
-
onDragEnter,
|
60
|
-
onDragEnd,
|
61
|
-
onDrop,
|
62
|
-
onDragOver
|
63
|
-
}: DraggableProviderType) => {
|
54
|
+
export const DraggableProvider = ({ children, initialItems, onReorder }: DraggableProviderType) => {
|
64
55
|
const [state, dispatch] = useReducer(reducer, initialState);
|
65
56
|
|
66
57
|
useEffect(() => {
|
@@ -74,7 +65,6 @@ export const DraggableProvider = ({
|
|
74
65
|
const handleDragStart = (id: string, container: string) => {
|
75
66
|
dispatch({ type: 'SET_DRAG_DATA', payload: { id: id, initialGroup: container } });
|
76
67
|
dispatch({ type: 'SET_IS_DRAGGING', payload: id });
|
77
|
-
if (onDragStart) onDragStart(id, container);
|
78
68
|
};
|
79
69
|
|
80
70
|
const handleDragEnter = (id: string, container: string) => {
|
@@ -82,13 +72,11 @@ export const DraggableProvider = ({
|
|
82
72
|
dispatch({ type: 'REORDER_ITEMS', payload: { dragId: state.dragData.id, targetId: id } });
|
83
73
|
dispatch({ type: 'SET_DRAG_DATA', payload: { id: state.dragData.id, initialGroup: container } });
|
84
74
|
}
|
85
|
-
if (onDragEnter) onDragEnter(id, container);
|
86
75
|
};
|
87
76
|
|
88
77
|
const handleDragEnd = () => {
|
89
78
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
90
79
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
91
|
-
if (onDragEnd) onDragEnd();
|
92
80
|
};
|
93
81
|
|
94
82
|
const changeCategory = (itemId: string, container: string) => {
|
@@ -99,13 +87,11 @@ export const DraggableProvider = ({
|
|
99
87
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
100
88
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
101
89
|
changeCategory(state.dragData.id, container);
|
102
|
-
if (onDrop) onDrop(container);
|
103
90
|
};
|
104
91
|
|
105
92
|
const handleDragOver = (e: Event, container: string) => {
|
106
93
|
e.preventDefault();
|
107
94
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
|
108
|
-
if (onDragOver) onDragOver(e, container);
|
109
95
|
};
|
110
96
|
|
111
97
|
const contextValue = useMemo(() => ({
|
@@ -23,9 +23,4 @@ export interface ItemType {
|
|
23
23
|
children: React.ReactNode;
|
24
24
|
initialItems: ItemType[];
|
25
25
|
onReorder: (items: ItemType[]) => void;
|
26
|
-
onDragStart?: (id: string, container: string) => void;
|
27
|
-
onDragEnter?: (id: string, container: string) => void;
|
28
|
-
onDragEnd?: () => void;
|
29
|
-
onDrop?: (container: string) => void;
|
30
|
-
onDragOver?: (e: Event, container: string) => void;
|
31
26
|
}
|
@@ -1,19 +1,23 @@
|
|
1
1
|
import React, { useState } from "react";
|
2
|
-
import {
|
2
|
+
import { SelectableList, Draggable, DraggableProvider } from "../../";
|
3
3
|
|
4
4
|
// Initial items to be dragged
|
5
5
|
const data = [
|
6
6
|
{
|
7
|
-
id: "
|
8
|
-
|
7
|
+
id: "1",
|
8
|
+
text: "Task 1",
|
9
9
|
},
|
10
10
|
{
|
11
|
-
id: "
|
12
|
-
|
11
|
+
id: "2",
|
12
|
+
text: "Task 2",
|
13
13
|
},
|
14
14
|
{
|
15
|
-
id: "
|
16
|
-
|
15
|
+
id: "3",
|
16
|
+
text: "Task 3",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: "4",
|
20
|
+
text: "Task 4",
|
17
21
|
},
|
18
22
|
];
|
19
23
|
|
@@ -26,19 +30,20 @@ const DraggableDefault = (props) => {
|
|
26
30
|
onReorder={(items) => setInitialState(items)}
|
27
31
|
>
|
28
32
|
<Draggable.Container {...props}>
|
29
|
-
|
30
|
-
{initialState.map(({ id,
|
33
|
+
<SelectableList variant="checkbox">
|
34
|
+
{initialState.map(({ id, text }) => (
|
31
35
|
<Draggable.Item dragId={id}
|
32
36
|
key={id}
|
33
37
|
>
|
34
|
-
<
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
+
<SelectableList.Item
|
39
|
+
label={text}
|
40
|
+
name={id}
|
41
|
+
value={id}
|
42
|
+
{...props}
|
38
43
|
/>
|
39
44
|
</Draggable.Item>
|
40
45
|
))}
|
41
|
-
|
46
|
+
</SelectableList>
|
42
47
|
</Draggable.Container>
|
43
48
|
</DraggableProvider>
|
44
49
|
</>
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
1
|
+
To use the Draggable kit, you must use the DraggableProvider and pass in `initialItems`. The `onReorder` is a function that returns the data as it changes as items are reordered. Use this to manage state as shown.
|
2
2
|
|
3
|
-
`
|
4
|
-
|
5
|
-
`Draggable.Container` = This specifies the container within which items can be dropped.
|
6
|
-
`Draggable.Item` = This specifies the items that can be dragged and dropped. `dragId` is a REQUIRED prop for Draggable.Item.
|
3
|
+
The `Draggable.Container` specifies the container within which items can be dropped.
|
4
|
+
The `Draggable.Item` specifies the items that can be dragged and dropped. `dragId` is a REQUIRED prop for Draggable.Item.
|
@@ -1,9 +1,5 @@
|
|
1
|
-
For a simplified version of the Draggable API for the Card kit,
|
2
|
-
|
3
|
-
Use `DraggableProvider` and manage state as shown.
|
4
|
-
|
5
|
-
`Draggable.Container` creates the container within which the cards can be dragged and dropped.
|
6
|
-
|
7
|
-
The Card kit is optimized to work with the draggable kit. To enable drag, use the `draggableItem` and `dragId` props on the Card kit as shown. An additional optional boolean prop (set to true by default) of `dragHandle` is also available to show the drag handle icon.
|
1
|
+
For a simplified version of the Draggable API for the Card kit, You can use the the Card kit as the Draggable Item by using the `draggableItem` prop. The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the Card kit.
|
8
2
|
|
3
|
+
In addition to the above `dragId` is a REQUIRED prop to be passedd to the Card kit when implementing dragging.
|
9
4
|
|
5
|
+
The dev must manage state as shown.
|
@@ -1,5 +1,7 @@
|
|
1
|
-
For a simplified version of the Draggable API for the List kit,
|
1
|
+
For a simplified version of the Draggable API for the List kit, use the DraggableProvider to wrap the List kit and use the `enableDrag` prop.
|
2
2
|
|
3
|
-
|
3
|
+
In addition to the above `dragId` is a REQUIRED prop to be passed to the List kit when implementing dragging.
|
4
4
|
|
5
|
-
The
|
5
|
+
The dev must manage state as shown.
|
6
|
+
|
7
|
+
The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the List kit.
|
@@ -1,5 +1,7 @@
|
|
1
|
-
For a simplified version of the Draggable API for the SelectableList kit,
|
1
|
+
For a simplified version of the Draggable API for the SelectableList kit, use the DraggableProvider to wrap the SelectableList kit and use the `enableDrag` prop.
|
2
2
|
|
3
|
-
|
3
|
+
In addition to the above `dragId` is a REQUIRED prop to be passed to the SelectableList kit when implementing dragging.
|
4
4
|
|
5
|
-
The
|
5
|
+
The dev must manage state as shown.
|
6
|
+
|
7
|
+
The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the SelectableList kit.
|
@@ -8,9 +8,7 @@
|
|
8
8
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
9
9
|
<% end %>
|
10
10
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
11
|
-
<input type="hidden" name="<%= object.name %>" id="dropdown-selected-option" value=""
|
12
|
-
<input id="dropdown-form-validation" name="<%= object.name %>_form_validation" value="" style="display: none" <%= object.required ? "required" : ""%> />
|
13
|
-
|
11
|
+
<input type="hidden" name="<%= object.name %>" id="dropdown-selected-option" value=""/>
|
14
12
|
<% if content.present? %>
|
15
13
|
<%= content.presence %>
|
16
14
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
@@ -8,8 +8,6 @@ module Playbook
|
|
8
8
|
prop :label, type: Playbook::Props::String
|
9
9
|
prop :name, type: Playbook::Props::String
|
10
10
|
prop :error, type: Playbook::Props::String
|
11
|
-
prop :required, type: Playbook::Props::Boolean,
|
12
|
-
default: false
|
13
11
|
|
14
12
|
def data
|
15
13
|
Hash(prop(:data)).merge(pb_dropdown: true)
|
@@ -8,22 +8,16 @@ const DOWN_ARROW_SELECTOR = "#dropdown_open_icon";
|
|
8
8
|
const UP_ARROW_SELECTOR = "#dropdown_close_icon";
|
9
9
|
const OPTION_SELECTOR = "[data-dropdown-option-label]";
|
10
10
|
const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
|
11
|
-
const INPUT_FORM_VALIDATION = "#dropdown-form-validation";
|
12
11
|
|
13
12
|
export default class PbDropdown extends PbEnhancedElement {
|
14
13
|
static get selector() {
|
15
14
|
return DROPDOWN_SELECTOR;
|
16
15
|
}
|
17
16
|
|
18
|
-
get target() {
|
19
|
-
return this.element.parentNode.querySelector(CONTAINER_SELECTOR);
|
20
|
-
}
|
21
|
-
|
22
17
|
connect() {
|
23
18
|
this.keyboardHandler = new PbDropdownKeyboard(this);
|
24
19
|
this.bindEventListeners();
|
25
20
|
this.updateArrowDisplay(false);
|
26
|
-
this.handleFormValidation();
|
27
21
|
}
|
28
22
|
|
29
23
|
bindEventListeners() {
|
@@ -44,13 +38,9 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
44
38
|
handleOptionClick(event) {
|
45
39
|
const option = event.target.closest(OPTION_SELECTOR);
|
46
40
|
const hiddenInput = this.element.querySelector("#dropdown-selected-option");
|
47
|
-
const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
|
48
|
-
|
49
41
|
if (option) {
|
50
42
|
const value = option.dataset.dropdownOptionLabel;
|
51
43
|
hiddenInput.value = JSON.parse(value).id;
|
52
|
-
inputFormValidation.value = JSON.parse(value).id;
|
53
|
-
this.clearFormValidation(inputFormValidation);
|
54
44
|
this.onOptionSelected(value, option);
|
55
45
|
}
|
56
46
|
}
|
@@ -113,6 +103,10 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
113
103
|
selectedOption.classList.add("pb_dropdown_option_selected");
|
114
104
|
}
|
115
105
|
|
106
|
+
get target() {
|
107
|
+
return this.element.parentNode.querySelector(CONTAINER_SELECTOR);
|
108
|
+
}
|
109
|
+
|
116
110
|
showElement(elem) {
|
117
111
|
elem.classList.remove("close");
|
118
112
|
elem.classList.add("open");
|
@@ -156,27 +150,4 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
156
150
|
upArrow.style.display = isOpen ? "inline-block" : "none";
|
157
151
|
}
|
158
152
|
}
|
159
|
-
|
160
|
-
handleFormValidation() {
|
161
|
-
const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
|
162
|
-
|
163
|
-
inputFormValidation.addEventListener("invalid", function (event) {
|
164
|
-
if (inputFormValidation.hasAttribute("required") && inputFormValidation.value === "") {
|
165
|
-
event.preventDefault();
|
166
|
-
inputFormValidation.closest(".dropdown_wrapper").classList.add("error");
|
167
|
-
}
|
168
|
-
}, true);
|
169
|
-
}
|
170
|
-
|
171
|
-
clearFormValidation(input) {
|
172
|
-
if (input.checkValidity()) {
|
173
|
-
const dropdownWrapperElement = input.closest(".dropdown_wrapper");
|
174
|
-
dropdownWrapperElement.classList.remove("error");
|
175
|
-
|
176
|
-
const errorLabelElement = dropdownWrapperElement.querySelector(".pb_body_kit_negative");
|
177
|
-
if (errorLabelElement) {
|
178
|
-
errorLabelElement.remove();
|
179
|
-
}
|
180
|
-
}
|
181
|
-
}
|
182
153
|
}
|
@@ -13,14 +13,6 @@
|
|
13
13
|
]
|
14
14
|
%>
|
15
15
|
|
16
|
-
<%
|
17
|
-
example_dropdown_options = [
|
18
|
-
{ label: 'United States', value: 'United States', id: 'us' },
|
19
|
-
{ label: 'Canada', value: 'Canada', id: 'ca' },
|
20
|
-
{ label: 'Pakistan', value: 'Pakistan', id: 'pk' },
|
21
|
-
]
|
22
|
-
%>
|
23
|
-
|
24
16
|
<%= pb_form_with(scope: :example, method: :get, url: "", validate: true) do |form| %>
|
25
17
|
<%= form.text_field :example_text_field, props: { label: true, required: true } %>
|
26
18
|
<%= form.phone_number_field :example_phone_number_field, props: { label: "Example phone field" } %>
|
@@ -30,7 +22,6 @@
|
|
30
22
|
<%= form.password_field :example_password_field, props: { label: true, required: true } %>
|
31
23
|
<%= form.url_field :example_url_field, props: { label: true, required: true } %>
|
32
24
|
<%= form.text_area :example_text_area, props: { label: true, required: true } %>
|
33
|
-
<%= form.dropdown_field :example_dropdown, props: { label: true, options: example_dropdown_options, required: true } %>
|
34
25
|
<%= form.select :example_select, [ ["Yes", 1], ["No", 2] ], props: { label: true, blank_selection: "Select One...", required: true } %>
|
35
26
|
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: { label: true, blank_selection: "Select One...", required: true } %>
|
36
27
|
<%= form.check_box :example_checkbox, props: { text: "Example Checkbox", label: true, required: true } %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:span,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= link_to object.url, target: object.link_option do %>
|
3
8
|
<%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
|
4
9
|
<% end %>
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
**combined_html_options) do %>
|
2
6
|
<%= pb_rails("home_address_street/#{emphasis}_emphasis", props: object.send("#{emphasis}_emphasis_props")) %>
|
3
7
|
<% end %>
|
4
8
|
|
@@ -86,18 +86,33 @@ const RichTextEditor = (props: RichTextEditorProps): React.ReactElement => {
|
|
86
86
|
const toolbarElement = element.parentElement.querySelector('trix-toolbar') as HTMLElement,
|
87
87
|
blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
|
88
88
|
|
89
|
-
// replace default trix "block code" button with "inline code" button
|
90
89
|
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]') as HTMLElement
|
91
|
-
if (!inlineCodeButton)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
97
|
-
}
|
90
|
+
if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
|
91
|
+
|
92
|
+
// set button attributes
|
93
|
+
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
94
|
+
blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
|
98
95
|
|
99
96
|
if (toolbarBottom) editor.element.after(toolbarElement)
|
100
97
|
|
98
|
+
const getCodeFormattingType = (): string => {
|
99
|
+
if (editor.attributeIsActive('code')) return 'block'
|
100
|
+
if (editor.attributeIsActive('inlineCode')) return 'inline'
|
101
|
+
|
102
|
+
const range = editor.getSelectedRange()
|
103
|
+
if (range[0] == range[1]) return 'block'
|
104
|
+
|
105
|
+
const text = editor.getSelectedDocument().toString().trim()
|
106
|
+
return /\n/.test(text) ? 'block' : 'inline'
|
107
|
+
}
|
108
|
+
|
109
|
+
// DOM event listeners
|
110
|
+
element.addEventListener('trix-selection-change', () => {
|
111
|
+
const type = getCodeFormattingType()
|
112
|
+
blockCodeButton.hidden = type == 'inline'
|
113
|
+
inlineCodeButton.hidden = type == 'block'
|
114
|
+
})
|
115
|
+
|
101
116
|
focus
|
102
117
|
? (document.addEventListener('trix-focus', useFocus),
|
103
118
|
document.addEventListener('trix-blur', useFocus),
|