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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6065952cf0606995f373c8718e0a1895be1177aee77691a23ebc0626a3d8245e
4
- data.tar.gz: 275df6169d763462916e7a01ebdfd12518689c3e2d826e5da6cfb2cf774aba7a
3
+ metadata.gz: 203044cb15b22597397b39bf38a531a0c158c55ec72ae4e3cdebe8ad8ec6a64a
4
+ data.tar.gz: e8fa151f4da651ffbf4789f3b160fbef3f5e70a0762512c0b1350b2c457f8459
5
5
  SHA512:
6
- metadata.gz: 492c73dd0792f7a0e52db3c0052d430dcb030f8dfdd5bba0a227c43888d8dfb8e761702ceb2a0d662462b3dc0d2fd1a988b7b39effaad14298b2cbb72c528d49
7
- data.tar.gz: 150a33c6b0d6b4f1246d8e7125944cb645cae7faa5f41bed277e8911a20f1b8a16d5925f774b48e9d0dbb9140beedb5b6caa9069e83c11ec9abc1ccd89e7de6b
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
- onChange(evt)
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", () => validateTooLongNumber(telInputInit))
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
 
@@ -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?: { [key: string]: string },
22
+ aria?: object,
30
23
  toolbarBottom?: Boolean,
31
24
  className?: string,
32
- data?: { [key: string]: string },
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
- dataProps = buildDataProps(data),
64
- [editor, setEditor] = useState<Editor>()
56
+ dataProps = buildDataProps(data),
57
+ [editor, setEditor] = useState()
65
58
 
66
- const handleOnEditorReady = (editorInstance: Editor) => setEditor(editorInstance),
67
- element = editor?.element
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') as HTMLElement,
72
- blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]') as HTMLElement
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]') as HTMLElement
75
- if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true) as HTMLElement
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
- document.addEventListener('trix-blur', useFocus),
104
- useFocus())
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', ({ target }: Event) => {
121
- const trixEditorContainer = (target as Element).closest('.pb_rich_text_editor_kit')
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 = (target as Element).closest('a')
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
- simpleClass = simple ? 'simple' : '',
133
- focusClass = focus ? 'focus-editor-targets' : '',
134
- stickyClass = sticky ? 'sticky' : '',
135
- inlineClass = inline ? 'inline' : '',
136
- toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
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
- {...ariaProps}
152
- {...dataProps}
153
- className={css}
144
+ {...ariaProps}
145
+ {...dataProps}
146
+ className={css}
154
147
  >
155
148
  <TrixEditor
156
- className=""
157
- fileParamName={name}
158
- mergeTags={[]}
159
- onChange={onChange}
160
- onEditorReady={handleOnEditorReady}
161
- placeholder={placeholder}
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 as Element
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: any) => {
5
+ allTrixEditors.forEach((editorElement) => {
6
6
  const toolbarElement = editorElement.toolbarElement
7
7
  if (editorElement == document.activeElement) {
8
8
  editorElement.classList.add('focused-editor')
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "12.10.0"
5
- VERSION = "12.10.0.pre.alpha.PLAY677richtexteditorts370"
5
+ VERSION = "12.10.0.pre.alpha.PLAY705phonenumberreturn372"
6
6
  end
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.PLAY677richtexteditorts370
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.ts
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.ts
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