playbook_ui 12.10.0.pre.alpha.PLAY677richtexteditorts370 → 12.10.0.pre.alpha.PLAY705phonenumberreturn372
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_phone_number_input/_phone_number_input.tsx +12 -2
- data/app/pb_kits/playbook/pb_rich_text_editor/{_rich_text_editor.tsx → _rich_text_editor.jsx} +32 -40
- data/app/pb_kits/playbook/pb_rich_text_editor/{inlineFocus.ts → inlineFocus.js} +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/{useFocus.ts → useFocus.js} +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 203044cb15b22597397b39bf38a531a0c158c55ec72ae4e3cdebe8ad8ec6a64a
|
4
|
+
data.tar.gz: e8fa151f4da651ffbf4789f3b160fbef3f5e70a0762512c0b1350b2c457f8459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7498a9c8f75ce5a49924ca0df255b9a62c71197b850c443ee2f7216298583018fb43d106d217b3afd230356c1e1d2f642fa0d0f4e85fc12a70c8e4a3ceadff5e
|
7
|
+
data.tar.gz: 235cbf4d84f40cf6c557fb986acc5c8665a0d837895740609957445c9a810fab8c2d306dc10bd9518d94a4a3d8c27f548ef00484c4f5210cc5f18527837b885f
|
@@ -121,10 +121,15 @@ const PhoneNumberInput = (props: PhoneNumberInputProps) => {
|
|
121
121
|
validateOnlyNumbers()
|
122
122
|
}
|
123
123
|
|
124
|
+
const getCurrentSelectedData = (itiInit: any, inputValue: string) => {
|
125
|
+
return {...itiInit.getSelectedCountryData(), number: inputValue}
|
126
|
+
}
|
127
|
+
|
124
128
|
const handleOnChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
125
129
|
setInputValue(evt.target.value)
|
126
130
|
validateTooLongNumber(itiInit)
|
127
|
-
|
131
|
+
const selectedData = getCurrentSelectedData(itiInit, evt.target.value)
|
132
|
+
onChange(selectedData)
|
128
133
|
isValid(itiInit.isValidNumber())
|
129
134
|
}
|
130
135
|
|
@@ -144,7 +149,12 @@ const PhoneNumberInput = (props: PhoneNumberInputProps) => {
|
|
144
149
|
}
|
145
150
|
)
|
146
151
|
|
147
|
-
inputRef.current.addEventListener("countrychange", () =>
|
152
|
+
inputRef.current.addEventListener("countrychange", (evt: Event) => {
|
153
|
+
validateTooLongNumber(telInputInit)
|
154
|
+
const selectedData = getCurrentSelectedData(telInputInit, (evt.target as HTMLInputElement).value)
|
155
|
+
onChange(selectedData)
|
156
|
+
})
|
157
|
+
|
148
158
|
inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
|
149
159
|
inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
|
150
160
|
|
data/app/pb_kits/playbook/pb_rich_text_editor/{_rich_text_editor.tsx → _rich_text_editor.jsx}
RENAMED
@@ -1,3 +1,6 @@
|
|
1
|
+
/* @flow */
|
2
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
3
|
+
|
1
4
|
import React, { useEffect, useState } from 'react'
|
2
5
|
import classnames from 'classnames'
|
3
6
|
import inlineFocus from './inlineFocus'
|
@@ -15,21 +18,11 @@ try {
|
|
15
18
|
|
16
19
|
import { TrixEditor } from "react-trix"
|
17
20
|
|
18
|
-
type Editor = {
|
19
|
-
attributeIsActive?: Function,
|
20
|
-
element?: HTMLElement,
|
21
|
-
getSelectedDocument?: Function,
|
22
|
-
getSelectedRange?: () => Array<number>,
|
23
|
-
insertHTML?: Function,
|
24
|
-
loadHTML?: Function,
|
25
|
-
setSelectedRange?: (range: Array<number>) => void,
|
26
|
-
}
|
27
|
-
|
28
21
|
type RichTextEditorProps = {
|
29
|
-
aria?:
|
22
|
+
aria?: object,
|
30
23
|
toolbarBottom?: Boolean,
|
31
24
|
className?: string,
|
32
|
-
data?:
|
25
|
+
data?: object,
|
33
26
|
focus?: boolean,
|
34
27
|
id?: string,
|
35
28
|
inline?: boolean,
|
@@ -60,19 +53,19 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
60
53
|
} = props
|
61
54
|
|
62
55
|
const ariaProps = buildAriaProps(aria),
|
63
|
-
|
64
|
-
|
56
|
+
dataProps = buildDataProps(data),
|
57
|
+
[editor, setEditor] = useState()
|
65
58
|
|
66
|
-
const handleOnEditorReady = (editorInstance
|
67
|
-
|
59
|
+
const handleOnEditorReady = (editorInstance) => setEditor(editorInstance),
|
60
|
+
element = editor?.element
|
68
61
|
|
69
62
|
// DOM manipulation must wait for editor to be ready
|
70
63
|
if (editor) {
|
71
|
-
const toolbarElement = element.parentElement.querySelector('trix-toolbar')
|
72
|
-
|
64
|
+
const toolbarElement = element.parentElement.querySelector('trix-toolbar'),
|
65
|
+
blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]')
|
73
66
|
|
74
|
-
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]')
|
75
|
-
if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true)
|
67
|
+
let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]')
|
68
|
+
if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true)
|
76
69
|
|
77
70
|
// set button attributes
|
78
71
|
inlineCodeButton.dataset.trixAttribute = 'inlineCode'
|
@@ -100,8 +93,8 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
100
93
|
|
101
94
|
focus
|
102
95
|
? (document.addEventListener('trix-focus', useFocus),
|
103
|
-
|
104
|
-
|
96
|
+
document.addEventListener('trix-blur', useFocus),
|
97
|
+
useFocus())
|
105
98
|
: null
|
106
99
|
|
107
100
|
document.addEventListener('trix-focus', inlineFocus)
|
@@ -117,11 +110,11 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
117
110
|
|
118
111
|
useEffect(() => {
|
119
112
|
if (!element) return
|
120
|
-
element.addEventListener('click', ({
|
121
|
-
const trixEditorContainer =
|
113
|
+
element.addEventListener('click', ({target}) => {
|
114
|
+
const trixEditorContainer = target.closest('.pb_rich_text_editor_kit')
|
122
115
|
if (!trixEditorContainer) return
|
123
116
|
|
124
|
-
const anchorElement =
|
117
|
+
const anchorElement = target.closest('a')
|
125
118
|
if (!anchorElement) return
|
126
119
|
|
127
120
|
if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
|
@@ -129,11 +122,11 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
129
122
|
}, [element])
|
130
123
|
|
131
124
|
const richTextEditorClass = 'pb_rich_text_editor_kit',
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
simpleClass = simple ? 'simple' : '',
|
126
|
+
focusClass = focus ? 'focus-editor-targets' : '',
|
127
|
+
stickyClass = sticky ? 'sticky' : '',
|
128
|
+
inlineClass = inline ? 'inline' : '',
|
129
|
+
toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
|
137
130
|
|
138
131
|
let css = classnames(globalProps(props), className)
|
139
132
|
css = classnames(
|
@@ -148,18 +141,17 @@ const RichTextEditor = (props: RichTextEditorProps) => {
|
|
148
141
|
|
149
142
|
return (
|
150
143
|
<div
|
151
|
-
|
152
|
-
|
153
|
-
|
144
|
+
{...ariaProps}
|
145
|
+
{...dataProps}
|
146
|
+
className={css}
|
154
147
|
>
|
155
148
|
<TrixEditor
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
value={value}
|
149
|
+
className=""
|
150
|
+
fileParamName={name}
|
151
|
+
onChange={onChange}
|
152
|
+
onEditorReady={handleOnEditorReady}
|
153
|
+
placeholder={placeholder}
|
154
|
+
value={value}
|
163
155
|
/>
|
164
156
|
</div>
|
165
157
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
const inlineFocus = () => {
|
2
|
-
const trixEditorElement = event.target
|
2
|
+
const trixEditorElement = event.target
|
3
3
|
const trixEditorContainer = trixEditorElement.closest('.pb_rich_text_editor_kit')
|
4
4
|
|
5
5
|
if (!trixEditorContainer.classList.contains('inline')) return
|
@@ -2,7 +2,7 @@ const useFocus = () => {
|
|
2
2
|
const allTrixEditors = document.querySelectorAll(
|
3
3
|
'.focus-editor-targets trix-editor'
|
4
4
|
)
|
5
|
-
allTrixEditors.forEach((editorElement
|
5
|
+
allTrixEditors.forEach((editorElement) => {
|
6
6
|
const toolbarElement = editorElement.toolbarElement
|
7
7
|
if (editorElement == document.activeElement) {
|
8
8
|
editorElement.classList.add('focused-editor')
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.10.0.pre.alpha.
|
4
|
+
version: 12.10.0.pre.alpha.PLAY705phonenumberreturn372
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
@@ -1710,8 +1710,8 @@ files:
|
|
1710
1710
|
- app/pb_kits/playbook/pb_radio/radio.html.erb
|
1711
1711
|
- app/pb_kits/playbook/pb_radio/radio.rb
|
1712
1712
|
- app/pb_kits/playbook/pb_radio/radio.test.js
|
1713
|
+
- app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx
|
1713
1714
|
- app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss
|
1714
|
-
- app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx
|
1715
1715
|
- app/pb_kits/playbook/pb_rich_text_editor/_trix_styles.scss
|
1716
1716
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.html.erb
|
1717
1717
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_attributes.jsx
|
@@ -1734,11 +1734,11 @@ files:
|
|
1734
1734
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml
|
1735
1735
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/index.js
|
1736
1736
|
- app/pb_kits/playbook/pb_rich_text_editor/docs/templates.js
|
1737
|
-
- app/pb_kits/playbook/pb_rich_text_editor/inlineFocus.
|
1737
|
+
- app/pb_kits/playbook/pb_rich_text_editor/inlineFocus.js
|
1738
1738
|
- app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.html.erb
|
1739
1739
|
- app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb
|
1740
1740
|
- app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.test.js
|
1741
|
-
- app/pb_kits/playbook/pb_rich_text_editor/useFocus.
|
1741
|
+
- app/pb_kits/playbook/pb_rich_text_editor/useFocus.js
|
1742
1742
|
- app/pb_kits/playbook/pb_section_separator/_section_separator.scss
|
1743
1743
|
- app/pb_kits/playbook/pb_section_separator/_section_separator.tsx
|
1744
1744
|
- app/pb_kits/playbook/pb_section_separator/_section_separator_mixin.scss
|