@momo-kits/calculator-keyboard 0.150.2-beta.15 → 0.150.2-beta.17
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.
- package/android/src/main/java/com/calculatorkeyboard/CustomKeyboardView.kt +20 -7
- package/android/src/main/java/com/calculatorkeyboard/KeyboardOverplayHost.kt +232 -0
- package/android/src/main/java/com/calculatorkeyboard/RCTInputCalculator.kt +78 -220
- package/ios/CalculatorKeyboardView.swift +5 -17
- package/ios/InputCalculator.m +1 -1
- package/ios/InputCalculator.swift +2 -2
- package/package.json +7 -131
- package/src/index.tsx +25 -41
- package/lib/commonjs/index.js +0 -94
- package/lib/commonjs/index.js.map +0 -1
- package/lib/module/index.js +0 -93
- package/lib/module/index.js.map +0 -1
- package/lib/typescript/commonjs/package.json +0 -1
- package/lib/typescript/commonjs/src/index.d.ts +0 -43
- package/lib/typescript/commonjs/src/index.d.ts.map +0 -1
- package/lib/typescript/module/package.json +0 -1
- package/lib/typescript/module/src/index.d.ts +0 -43
- package/lib/typescript/module/src/index.d.ts.map +0 -1
|
@@ -34,7 +34,7 @@ class CustomKeyboardView(
|
|
|
34
34
|
private var customKeyButton: Button? = null
|
|
35
35
|
private var customKeyButtonBackground: Int = "#D8D8D8".toColorInt()
|
|
36
36
|
private var customKeyButtonTextColor: Int = Color.BLACK
|
|
37
|
-
private var customKeyButtonState:
|
|
37
|
+
private var customKeyButtonState: String = "default"
|
|
38
38
|
|
|
39
39
|
init {
|
|
40
40
|
val activity = context.currentActivity as? AppCompatActivity
|
|
@@ -43,6 +43,12 @@ class CustomKeyboardView(
|
|
|
43
43
|
val widthButton = (displayMetrics.widthPixels - separatorWidth * 2 - 4 * separatorWidth) / 5f
|
|
44
44
|
val heightButton = (calculatorHeight - separatorWidth * 2 - 3 * separatorWidth) / 4
|
|
45
45
|
|
|
46
|
+
isClickable = false
|
|
47
|
+
isFocusable = false
|
|
48
|
+
isFocusableInTouchMode = false
|
|
49
|
+
clipToPadding = false
|
|
50
|
+
clipChildren = false
|
|
51
|
+
|
|
46
52
|
renderUI(widthButton, heightButton)
|
|
47
53
|
}
|
|
48
54
|
|
|
@@ -113,6 +119,9 @@ class CustomKeyboardView(
|
|
|
113
119
|
setTextColor(Color.BLACK)
|
|
114
120
|
}
|
|
115
121
|
|
|
122
|
+
isClickable = true
|
|
123
|
+
isFocusable = false
|
|
124
|
+
isFocusableInTouchMode = false
|
|
116
125
|
|
|
117
126
|
translationX = xOffset.toInt().toFloat()
|
|
118
127
|
translationY = yOffset.toInt().toFloat()
|
|
@@ -141,6 +150,11 @@ class CustomKeyboardView(
|
|
|
141
150
|
).apply {
|
|
142
151
|
constrainedWidth = false
|
|
143
152
|
}
|
|
153
|
+
|
|
154
|
+
isClickable = true
|
|
155
|
+
isFocusable = false
|
|
156
|
+
isFocusableInTouchMode = false
|
|
157
|
+
|
|
144
158
|
translationX = xOffset
|
|
145
159
|
translationY = yOffset
|
|
146
160
|
setImageResource(android.R.drawable.ic_input_delete)
|
|
@@ -267,22 +281,21 @@ class CustomKeyboardView(
|
|
|
267
281
|
}
|
|
268
282
|
|
|
269
283
|
|
|
270
|
-
fun setCustomKeyState(state:
|
|
284
|
+
fun setCustomKeyState(state: String) {
|
|
271
285
|
customKeyButtonState = state
|
|
272
|
-
customKeyButton?.isEnabled = state
|
|
286
|
+
customKeyButton?.isEnabled = state != "disable"
|
|
273
287
|
updateCustomKeyUI(customKeyButtonBackground, customKeyButtonTextColor, state)
|
|
274
288
|
}
|
|
275
289
|
|
|
276
|
-
private fun updateCustomKeyUI(background: Int, textColor: Int, state:
|
|
277
|
-
val backgroundColor = if(state == 1) "#EBEBF2".toColorInt() else background
|
|
278
|
-
val textColor = if (state == 1) Color.WHITE else textColor
|
|
290
|
+
private fun updateCustomKeyUI(background: Int, textColor: Int, state: String){
|
|
279
291
|
|
|
280
292
|
customKeyButton?.background = GradientDrawable().apply {
|
|
281
293
|
shape = GradientDrawable.RECTANGLE
|
|
282
294
|
cornerRadius = 24f
|
|
283
|
-
setColor(
|
|
295
|
+
setColor(background)
|
|
284
296
|
}
|
|
285
297
|
customKeyButton?.setTextColor(textColor)
|
|
286
298
|
}
|
|
287
299
|
|
|
300
|
+
|
|
288
301
|
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
package com.calculatorkeyboard
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.ContextWrapper
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.Gravity
|
|
9
|
+
import android.view.MotionEvent
|
|
10
|
+
import android.view.View
|
|
11
|
+
import android.view.ViewGroup
|
|
12
|
+
import android.widget.FrameLayout
|
|
13
|
+
import androidx.core.view.ViewCompat
|
|
14
|
+
import androidx.core.view.WindowInsetsCompat
|
|
15
|
+
import androidx.core.view.doOnLayout
|
|
16
|
+
import androidx.core.view.updatePadding
|
|
17
|
+
import java.lang.ref.WeakReference
|
|
18
|
+
import androidx.core.view.isNotEmpty
|
|
19
|
+
|
|
20
|
+
internal class KeyboardOverlayHost {
|
|
21
|
+
|
|
22
|
+
private val tag = "KeyboardOverlayHost"
|
|
23
|
+
|
|
24
|
+
private var localRootRef: WeakReference<ViewGroup>? = null
|
|
25
|
+
private var containerRef: WeakReference<FrameLayout>? = null
|
|
26
|
+
private var paddingTargetRef: WeakReference<View>? = null
|
|
27
|
+
|
|
28
|
+
private var originalBottomPadding: Int = 0
|
|
29
|
+
private var isShowing = false
|
|
30
|
+
|
|
31
|
+
private class OverlayContainer(ctx: Context) : FrameLayout(ctx) {
|
|
32
|
+
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean = false
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fun show(anchorView: View, keyboardView: View, heightPx: Int) {
|
|
36
|
+
val localRoot = findLocalRoot(anchorView) ?: run {
|
|
37
|
+
Log.w(tag, "show: cannot find local root from anchorView")
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
val container = ensureContainer(localRoot, anchorView.context) ?: return
|
|
41
|
+
|
|
42
|
+
val paddingTarget = findPaddingTargetWithin(anchorView, localRoot)
|
|
43
|
+
paddingTargetRef = WeakReference(paddingTarget)
|
|
44
|
+
localRootRef = WeakReference(localRoot)
|
|
45
|
+
|
|
46
|
+
val bottomInset = (ViewCompat.getRootWindowInsets(container)
|
|
47
|
+
?.getInsets(WindowInsetsCompat.Type.systemBars())?.bottom) ?: 0
|
|
48
|
+
|
|
49
|
+
val lp = FrameLayout.LayoutParams(
|
|
50
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
51
|
+
heightPx + bottomInset
|
|
52
|
+
).apply { gravity = Gravity.BOTTOM }
|
|
53
|
+
|
|
54
|
+
if (keyboardView.parent !== container) {
|
|
55
|
+
container.removeAllViews()
|
|
56
|
+
container.addView(keyboardView, lp)
|
|
57
|
+
} else {
|
|
58
|
+
keyboardView.layoutParams = lp
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
keyboardView.isClickable = true
|
|
62
|
+
keyboardView.isFocusable = false
|
|
63
|
+
keyboardView.isFocusableInTouchMode = false
|
|
64
|
+
keyboardView.visibility = View.VISIBLE
|
|
65
|
+
|
|
66
|
+
if (!isShowing) originalBottomPadding = paddingTarget.paddingBottom
|
|
67
|
+
paddingTarget.updatePadding(bottom = heightPx)
|
|
68
|
+
|
|
69
|
+
container.visibility = View.VISIBLE
|
|
70
|
+
container.bringToFront()
|
|
71
|
+
container.translationZ = 10000f
|
|
72
|
+
container.elevation = 10000f
|
|
73
|
+
localRoot.post { container.bringToFront() }
|
|
74
|
+
|
|
75
|
+
keyboardView.animate().cancel()
|
|
76
|
+
keyboardView.post {
|
|
77
|
+
container.bringToFront()
|
|
78
|
+
keyboardView.doOnLayout { child ->
|
|
79
|
+
val h = child.height.takeIf { it > 0 } ?: heightPx
|
|
80
|
+
child.translationY = h.toFloat()
|
|
81
|
+
child.animate()
|
|
82
|
+
.translationY(0f)
|
|
83
|
+
.setDuration(250L)
|
|
84
|
+
.withStartAction {
|
|
85
|
+
isShowing = true
|
|
86
|
+
child.setLayerType(View.LAYER_TYPE_HARDWARE, null)
|
|
87
|
+
container.bringToFront()
|
|
88
|
+
}
|
|
89
|
+
.withEndAction {
|
|
90
|
+
child.setLayerType(View.LAYER_TYPE_NONE, null)
|
|
91
|
+
}
|
|
92
|
+
.start()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fun hide() {
|
|
98
|
+
val container = containerRef?.get() ?: return
|
|
99
|
+
val localRoot = localRootRef?.get() ?: return
|
|
100
|
+
val paddingTarget = paddingTargetRef?.get() ?: localRoot
|
|
101
|
+
|
|
102
|
+
val child = if (container.isNotEmpty())
|
|
103
|
+
container.getChildAt(container.childCount - 1) else null
|
|
104
|
+
|
|
105
|
+
if (child == null) {
|
|
106
|
+
paddingTarget.updatePadding(bottom = originalBottomPadding)
|
|
107
|
+
isShowing = false
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
child.animate().cancel()
|
|
112
|
+
val h = child.height.takeIf { it > 0 } ?: (child.measuredHeight.takeIf { it > 0 } ?: 0)
|
|
113
|
+
if (h == 0) {
|
|
114
|
+
container.removeAllViews()
|
|
115
|
+
paddingTarget.updatePadding(bottom = originalBottomPadding)
|
|
116
|
+
isShowing = false
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
child.animate()
|
|
121
|
+
.translationY(h.toFloat())
|
|
122
|
+
.setDuration(250L)
|
|
123
|
+
.withEndAction {
|
|
124
|
+
container.removeAllViews()
|
|
125
|
+
paddingTarget.updatePadding(bottom = originalBottomPadding)
|
|
126
|
+
isShowing = false
|
|
127
|
+
}
|
|
128
|
+
.start()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
fun detach() {
|
|
132
|
+
containerRef?.get()?.let { (it.parent as? ViewGroup)?.removeView(it) }
|
|
133
|
+
containerRef = null
|
|
134
|
+
localRootRef = null
|
|
135
|
+
paddingTargetRef = null
|
|
136
|
+
isShowing = false
|
|
137
|
+
originalBottomPadding = 0
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private fun findLocalRoot(anchor: View): ViewGroup? {
|
|
141
|
+
var cur: View? = anchor
|
|
142
|
+
|
|
143
|
+
while (cur != null) {
|
|
144
|
+
if (cur is ViewGroup && isReactRoot(cur)) {
|
|
145
|
+
return cur
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
val parent = cur.parent
|
|
149
|
+
if (parent is ViewGroup) {
|
|
150
|
+
val parentName = parent::class.java.simpleName
|
|
151
|
+
if (parentName.contains("FragmentContainerView")) {
|
|
152
|
+
return (cur as? ViewGroup) ?: parent
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
cur = (cur.parent as? View)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return (anchor.rootView as? ViewGroup)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private fun isReactRoot(v: View): Boolean {
|
|
163
|
+
val n = v::class.java.simpleName
|
|
164
|
+
return n.contains("ReactRootView") ||
|
|
165
|
+
n.contains("RNGestureHandlerEnabledRootView") ||
|
|
166
|
+
(n.contains("React") && n.contains("Root"))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@SuppressLint("ClickableViewAccessibility")
|
|
170
|
+
private fun ensureContainer(localRoot: ViewGroup, ctx: Context): FrameLayout? {
|
|
171
|
+
var container = containerRef?.get()
|
|
172
|
+
|
|
173
|
+
if (container == null || container.parent !== localRoot) {
|
|
174
|
+
container?.let { (it.parent as? ViewGroup)?.removeView(it) }
|
|
175
|
+
|
|
176
|
+
container = OverlayContainer(ctx).apply {
|
|
177
|
+
layoutParams = ViewGroup.LayoutParams(
|
|
178
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
179
|
+
ViewGroup.LayoutParams.MATCH_PARENT
|
|
180
|
+
)
|
|
181
|
+
isClickable = false
|
|
182
|
+
isFocusable = false
|
|
183
|
+
elevation = 10000f
|
|
184
|
+
translationZ = 10000f
|
|
185
|
+
visibility = View.VISIBLE
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
localRoot.addView(container)
|
|
189
|
+
container.bringToFront()
|
|
190
|
+
localRoot.requestLayout()
|
|
191
|
+
containerRef = WeakReference(container)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return container
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private fun findPaddingTargetWithin(anchor: View, localRoot: ViewGroup): View {
|
|
198
|
+
fun dfs(g: ViewGroup): View? {
|
|
199
|
+
if (isReactRoot(g)) return g
|
|
200
|
+
for (i in 0 until g.childCount) {
|
|
201
|
+
val c = g.getChildAt(i)
|
|
202
|
+
if (c is ViewGroup) {
|
|
203
|
+
val hit = dfs(c)
|
|
204
|
+
if (hit != null) return hit
|
|
205
|
+
} else if (isReactRoot(c)) {
|
|
206
|
+
return c
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return null
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
dfs(localRoot)?.let { return it }
|
|
213
|
+
|
|
214
|
+
var cur: View? = anchor
|
|
215
|
+
var last: View = anchor
|
|
216
|
+
while (cur != null && cur !== localRoot) {
|
|
217
|
+
last = cur
|
|
218
|
+
cur = (cur.parent as? View)
|
|
219
|
+
}
|
|
220
|
+
return last as? ViewGroup ?: localRoot
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@Suppress("unused")
|
|
224
|
+
private fun findActivityFrom(view: View): Activity? {
|
|
225
|
+
var ctx: Context? = view.context
|
|
226
|
+
while (ctx is ContextWrapper) {
|
|
227
|
+
if (ctx is Activity) return ctx
|
|
228
|
+
ctx = ctx.baseContext
|
|
229
|
+
}
|
|
230
|
+
return null
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
package com.calculatorkeyboard
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
-
import android.app.Activity
|
|
5
4
|
import android.content.Context
|
|
6
|
-
import android.content.ContextWrapper
|
|
7
5
|
import android.graphics.Color
|
|
8
|
-
import android.view.Gravity
|
|
9
6
|
import android.view.KeyEvent
|
|
10
|
-
import android.view.View
|
|
11
|
-
import android.view.WindowManager
|
|
12
|
-
import android.view.animation.DecelerateInterpolator
|
|
13
7
|
import android.view.inputmethod.InputMethodManager
|
|
14
|
-
import android.widget.PopupWindow
|
|
15
|
-
import androidx.core.graphics.Insets
|
|
16
|
-
import androidx.core.graphics.drawable.toDrawable
|
|
17
8
|
import androidx.core.graphics.toColorInt
|
|
18
|
-
import androidx.core.view.OnApplyWindowInsetsListener
|
|
19
9
|
import androidx.core.view.ViewCompat
|
|
20
10
|
import androidx.core.view.WindowInsetsCompat
|
|
21
11
|
import com.facebook.react.bridge.ReadableArray
|
|
@@ -29,16 +19,13 @@ import com.facebook.react.views.textinput.ReactTextInputManager
|
|
|
29
19
|
class RCTInputCalculator : ReactTextInputManager() {
|
|
30
20
|
|
|
31
21
|
private var keyboardView: CustomKeyboardView? = null
|
|
32
|
-
private var popup: PopupWindow? = null
|
|
33
|
-
private val animationDuration = 250L
|
|
34
|
-
|
|
35
22
|
private lateinit var editText: CalculatorEditText
|
|
36
|
-
|
|
37
|
-
private var fakeImeListener: OnApplyWindowInsetsListener? = null
|
|
38
|
-
private var fakeImeAttachedTo: View? = null
|
|
39
|
-
|
|
40
23
|
private lateinit var imm: InputMethodManager
|
|
41
24
|
|
|
25
|
+
private val overlayHost = KeyboardOverlayHost()
|
|
26
|
+
|
|
27
|
+
private var backListenerAttached = false
|
|
28
|
+
private var overlayShowing = false
|
|
42
29
|
|
|
43
30
|
override fun getName() = REACT_CLASS
|
|
44
31
|
|
|
@@ -56,12 +43,8 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
56
43
|
|
|
57
44
|
val wasFocused = view.hasFocus()
|
|
58
45
|
val atEnd = wasFocused && view.selectionStart == e.length && view.selectionEnd == e.length
|
|
59
|
-
|
|
60
46
|
e.replace(0, e.length, newText)
|
|
61
|
-
|
|
62
|
-
if (!wasFocused || atEnd) {
|
|
63
|
-
view.setSelection(newText.length)
|
|
64
|
-
}
|
|
47
|
+
if (!wasFocused || atEnd) view.setSelection(newText.length)
|
|
65
48
|
}
|
|
66
49
|
}
|
|
67
50
|
|
|
@@ -72,7 +55,7 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
72
55
|
|
|
73
56
|
@ReactProp(name = "customKeyBackground")
|
|
74
57
|
fun setCustomKeyBackground(view: ReactEditText, background: String?) {
|
|
75
|
-
keyboardView?.setCustomKeyBackground((background?: "#d8d8d8").toColorInt())
|
|
58
|
+
keyboardView?.setCustomKeyBackground((background ?: "#d8d8d8").toColorInt())
|
|
76
59
|
}
|
|
77
60
|
|
|
78
61
|
@ReactProp(name = "customKeyTextColor")
|
|
@@ -80,10 +63,9 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
80
63
|
keyboardView?.setCustomKeyTextColor(textColor?.toColorInt() ?: Color.BLACK)
|
|
81
64
|
}
|
|
82
65
|
|
|
83
|
-
|
|
84
66
|
@ReactProp(name = "customKeyState")
|
|
85
|
-
fun setCustomKeyState(view: ReactEditText, state:
|
|
86
|
-
keyboardView?.setCustomKeyState(state ?:
|
|
67
|
+
fun setCustomKeyState(view: ReactEditText, state: String?) {
|
|
68
|
+
keyboardView?.setCustomKeyState(state ?: "default")
|
|
87
69
|
}
|
|
88
70
|
|
|
89
71
|
@ReactProp(name = "keyboardColor")
|
|
@@ -96,7 +78,29 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
96
78
|
imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
97
79
|
|
|
98
80
|
editText = CalculatorEditText(context).apply {
|
|
99
|
-
showSoftInputOnFocus =
|
|
81
|
+
showSoftInputOnFocus = false
|
|
82
|
+
isFocusableInTouchMode = true
|
|
83
|
+
setOnTouchListener { v, event ->
|
|
84
|
+
if (event.action == android.view.MotionEvent.ACTION_DOWN) {
|
|
85
|
+
showSoftInputOnFocus = false
|
|
86
|
+
ViewCompat.getWindowInsetsController(this)?.hide(WindowInsetsCompat.Type.ime())
|
|
87
|
+
imm.hideSoftInputFromWindow(windowToken, 0)
|
|
88
|
+
|
|
89
|
+
if (!isFocused) requestFocus()
|
|
90
|
+
|
|
91
|
+
val kb = keyboardView
|
|
92
|
+
if (kb != null && !overlayShowing) {
|
|
93
|
+
overlayHost.show(
|
|
94
|
+
anchorView = this,
|
|
95
|
+
keyboardView = kb,
|
|
96
|
+
heightPx = calculatorHeight
|
|
97
|
+
)
|
|
98
|
+
overlayShowing = true
|
|
99
|
+
}
|
|
100
|
+
return@setOnTouchListener true
|
|
101
|
+
}
|
|
102
|
+
false
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
keyboardView = CustomKeyboardView(context, editText).apply {
|
|
@@ -104,19 +108,34 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
104
108
|
elevation = 24f
|
|
105
109
|
}
|
|
106
110
|
|
|
111
|
+
if (!backListenerAttached) {
|
|
112
|
+
editText.setOnKeyListener { v, keyCode, event ->
|
|
113
|
+
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_UP && v.hasFocus()) {
|
|
114
|
+
v.clearFocus()
|
|
115
|
+
true
|
|
116
|
+
} else false
|
|
117
|
+
}
|
|
118
|
+
backListenerAttached = true
|
|
119
|
+
}
|
|
120
|
+
|
|
107
121
|
editText.onFocusListener = object : CalculatorEditText.OnFocusChangeListener {
|
|
108
122
|
override fun onFocusChange(view: CalculatorEditText, hasFocus: Boolean) {
|
|
109
123
|
UiThreadUtil.runOnUiThread {
|
|
110
124
|
if (hasFocus) {
|
|
111
|
-
|
|
125
|
+
disableSystemImeFor(view)
|
|
126
|
+
if (!overlayShowing) {
|
|
127
|
+
val kb = keyboardView ?: return@runOnUiThread
|
|
128
|
+
overlayHost.show(
|
|
129
|
+
anchorView = view,
|
|
130
|
+
keyboardView = kb,
|
|
131
|
+
heightPx = calculatorHeight
|
|
132
|
+
)
|
|
133
|
+
overlayShowing = true
|
|
134
|
+
}
|
|
112
135
|
} else {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (keyCode == KeyEvent.KEYCODE_BACK && hasFocus) {
|
|
117
|
-
v.clearFocus()
|
|
118
|
-
true
|
|
119
|
-
} else false
|
|
136
|
+
overlayHost.hide()
|
|
137
|
+
overlayShowing = false
|
|
138
|
+
enableSystemImeFor(view)
|
|
120
139
|
}
|
|
121
140
|
}
|
|
122
141
|
}
|
|
@@ -125,128 +144,13 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
125
144
|
return editText
|
|
126
145
|
}
|
|
127
146
|
|
|
128
|
-
override fun getCommandsMap(): Map<String, Int> {
|
|
129
|
-
return mapOf(
|
|
130
|
-
"blur" to 1,
|
|
131
|
-
"focus" to 2
|
|
132
|
-
)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
override fun receiveCommand(reactEditText: ReactEditText, commandId: Int, args: ReadableArray?) {
|
|
136
|
-
when (commandId) {
|
|
137
|
-
1 -> blur()
|
|
138
|
-
2 -> focus()
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
|
|
143
|
-
val base = super.getExportedCustomBubblingEventTypeConstants().toMutableMap()
|
|
144
|
-
|
|
145
|
-
base["onKeyPress"] = mapOf(
|
|
146
|
-
"phasedRegistrationNames" to mapOf(
|
|
147
|
-
"bubbled" to "onKeyPress"
|
|
148
|
-
)
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
return base
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
|
|
155
|
-
val base = super.getExportedCustomDirectEventTypeConstants().toMutableMap()
|
|
156
|
-
base["onCustomKeyEvent"] = mapOf("registrationName" to "onCustomKeyEvent")
|
|
157
|
-
return base
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private fun ensurePopup() {
|
|
161
|
-
if (popup != null) return
|
|
162
|
-
val content = keyboardView ?: return
|
|
163
|
-
|
|
164
|
-
popup = PopupWindow(
|
|
165
|
-
content,
|
|
166
|
-
WindowManager.LayoutParams.MATCH_PARENT,
|
|
167
|
-
calculatorHeight + bottomInsetFrom(editText.rootView),
|
|
168
|
-
false
|
|
169
|
-
).apply {
|
|
170
|
-
setBackgroundDrawable(android.graphics.Color.TRANSPARENT.toDrawable())
|
|
171
|
-
isOutsideTouchable = false
|
|
172
|
-
isClippingEnabled = false
|
|
173
|
-
softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING
|
|
174
|
-
inputMethodMode = PopupWindow.INPUT_METHOD_NOT_NEEDED
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private fun bottomInsetFrom(view: View): Int {
|
|
179
|
-
val insets = ViewCompat.getRootWindowInsets(view) ?: return 0
|
|
180
|
-
val mask = WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.displayCutout()
|
|
181
|
-
return insets.getInsets(mask).bottom
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
private fun showKeyboardPopup(anchor: View) {
|
|
185
|
-
ensurePopup()
|
|
186
|
-
val p = popup ?: return
|
|
187
|
-
if (p.isShowing) return
|
|
188
|
-
|
|
189
|
-
disableSystemImeFor(editText)
|
|
190
|
-
|
|
191
|
-
p.animationStyle = 0
|
|
192
|
-
p.height = calculatorHeight + bottomInsetFrom(anchor.rootView)
|
|
193
|
-
p.showAtLocation(anchor.rootView, Gravity.BOTTOM or Gravity.START, 0, 0)
|
|
194
|
-
|
|
195
|
-
val content = p.contentView
|
|
196
|
-
|
|
197
|
-
val h = content.height.takeIf { it > 0 } ?: p.height
|
|
198
|
-
content.translationY = h.toFloat()
|
|
199
|
-
|
|
200
|
-
content.post {
|
|
201
|
-
content.animate()
|
|
202
|
-
.translationY(0f)
|
|
203
|
-
.setDuration(animationDuration)
|
|
204
|
-
.setInterpolator(DecelerateInterpolator())
|
|
205
|
-
.withStartAction { content.setLayerType(View.LAYER_TYPE_HARDWARE, null) }
|
|
206
|
-
.withEndAction { content.setLayerType(View.LAYER_TYPE_NONE, null) }
|
|
207
|
-
.start()
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
content.post {
|
|
211
|
-
findActivityFrom(content)?.let { act ->
|
|
212
|
-
setFakeIme(act.window.decorView, true, calculatorHeight)
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private fun hideKeyboardPopup() {
|
|
218
|
-
val p = popup ?: run {
|
|
219
|
-
enableSystemImeFor(editText, requestShow = false)
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
if (!p.isShowing) {
|
|
223
|
-
enableSystemImeFor(editText, requestShow = false)
|
|
224
|
-
popup = null
|
|
225
|
-
return
|
|
226
|
-
}
|
|
227
|
-
val content = p.contentView
|
|
228
|
-
|
|
229
|
-
content.animate().cancel()
|
|
230
|
-
|
|
231
|
-
val distance = (content.height.takeIf { it > 0 } ?: p.height).toFloat()
|
|
232
147
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
try { if (p.isShowing) p.dismiss() } catch (_: Throwable) {}
|
|
239
|
-
popup = null
|
|
240
|
-
content.translationY = 0f
|
|
241
|
-
content.setLayerType(View.LAYER_TYPE_NONE, null)
|
|
148
|
+
override fun onDropViewInstance(view: ReactEditText) {
|
|
149
|
+
super.onDropViewInstance(view)
|
|
150
|
+
overlayHost.hide()
|
|
151
|
+
overlayHost.detach()
|
|
152
|
+
overlayShowing = false
|
|
242
153
|
|
|
243
|
-
findActivityFrom(content)?.let { act ->
|
|
244
|
-
setFakeIme(act.window.decorView, false, 0)
|
|
245
|
-
}
|
|
246
|
-
enableSystemImeFor(editText, requestShow = false)
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
.start()
|
|
250
154
|
}
|
|
251
155
|
|
|
252
156
|
private fun disableSystemImeFor(v: ReactEditText) {
|
|
@@ -257,83 +161,37 @@ class RCTInputCalculator : ReactTextInputManager() {
|
|
|
257
161
|
imm.hideSoftInputFromWindow(v.windowToken, 0)
|
|
258
162
|
}
|
|
259
163
|
|
|
260
|
-
|
|
261
|
-
private fun enableSystemImeFor(v: ReactEditText, requestShow: Boolean) {
|
|
164
|
+
private fun enableSystemImeFor(v: ReactEditText) {
|
|
262
165
|
v.showSoftInputOnFocus = true
|
|
263
|
-
if (requestShow && v.isFocused) {
|
|
264
|
-
v.post {
|
|
265
|
-
if (android.os.Build.VERSION.SDK_INT >= 30) {
|
|
266
|
-
ViewCompat.getWindowInsetsController(v)?.show(WindowInsetsCompat.Type.ime())
|
|
267
|
-
} else {
|
|
268
|
-
imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
166
|
}
|
|
273
167
|
|
|
274
|
-
|
|
275
|
-
if (show) {
|
|
276
|
-
if (fakeImeListener != null && fakeImeAttachedTo === rootView) {
|
|
277
|
-
ViewCompat.requestApplyInsets(rootView)
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
fakeImeAttachedTo?.let { ViewCompat.setOnApplyWindowInsetsListener(it, null) }
|
|
281
|
-
fakeImeAttachedTo = rootView
|
|
282
|
-
|
|
283
|
-
val listener = OnApplyWindowInsetsListener { _, insets ->
|
|
284
|
-
val curBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
|
285
|
-
val newBarsBottom = maxOf(curBars.bottom, heightPx)
|
|
286
|
-
|
|
287
|
-
WindowInsetsCompat.Builder(insets)
|
|
288
|
-
.setInsets(WindowInsetsCompat.Type.ime(), Insets.of(0, 0, 0, heightPx))
|
|
289
|
-
.setVisible(WindowInsetsCompat.Type.ime(), true)
|
|
290
|
-
.setInsets(
|
|
291
|
-
WindowInsetsCompat.Type.systemBars(),
|
|
292
|
-
Insets.of(curBars.left, curBars.top, curBars.right, newBarsBottom)
|
|
293
|
-
)
|
|
294
|
-
.build()
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
fakeImeListener = listener
|
|
298
|
-
ViewCompat.setOnApplyWindowInsetsListener(rootView, listener)
|
|
299
|
-
ViewCompat.requestApplyInsets(rootView)
|
|
300
|
-
} else {
|
|
301
|
-
fakeImeAttachedTo?.let { ViewCompat.setOnApplyWindowInsetsListener(it, null) }
|
|
302
|
-
fakeImeListener = null
|
|
303
|
-
fakeImeAttachedTo = null
|
|
304
|
-
|
|
305
|
-
ViewCompat.requestApplyInsets(rootView)
|
|
168
|
+
override fun getCommandsMap(): Map<String, Int> = mapOf("blur" to 1, "focus" to 2)
|
|
306
169
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
170
|
+
override fun receiveCommand(reactEditText: ReactEditText, commandId: Int, args: ReadableArray?) {
|
|
171
|
+
when (commandId) {
|
|
172
|
+
1 -> blur()
|
|
173
|
+
2 -> focus()
|
|
312
174
|
}
|
|
313
175
|
}
|
|
314
176
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return null
|
|
177
|
+
override fun getExportedCustomBubblingEventTypeConstants(): MutableMap<String, Any> {
|
|
178
|
+
val base = super.getExportedCustomBubblingEventTypeConstants().toMutableMap()
|
|
179
|
+
base["onKeyPress"] = mapOf("phasedRegistrationNames" to mapOf("bubbled" to "onKeyPress"))
|
|
180
|
+
return base
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> {
|
|
184
|
+
val base = super.getExportedCustomDirectEventTypeConstants().toMutableMap()
|
|
185
|
+
base["onCustomKeyEvent"] = mapOf("registrationName" to "onCustomKeyEvent")
|
|
186
|
+
return base
|
|
326
187
|
}
|
|
327
188
|
|
|
328
189
|
private fun focus() {
|
|
329
|
-
UiThreadUtil.runOnUiThread {
|
|
330
|
-
if (!editText.isFocused) editText.requestFocus()
|
|
331
|
-
}
|
|
190
|
+
UiThreadUtil.runOnUiThread { if (!editText.isFocused) editText.requestFocus() }
|
|
332
191
|
}
|
|
333
192
|
|
|
334
193
|
private fun blur() {
|
|
335
|
-
UiThreadUtil.runOnUiThread {
|
|
336
|
-
if (editText.isFocused) editText.clearFocus()
|
|
337
|
-
}
|
|
194
|
+
UiThreadUtil.runOnUiThread { if (editText.isFocused) editText.clearFocus() }
|
|
338
195
|
}
|
|
339
196
|
}
|
|
197
|
+
|
|
@@ -19,7 +19,7 @@ class CalculatorKeyboardView: UIView {
|
|
|
19
19
|
var customKeyText: String? { didSet { updateCustomKeyTitle() } }
|
|
20
20
|
var customKeyBackground: String? { didSet { updateCustomKeyBackground() } }
|
|
21
21
|
var customKeyTextColor: String? { didSet { updateCustomKeyBackground() } }
|
|
22
|
-
var customKeyState:
|
|
22
|
+
var customKeyState: String? { didSet { updateCustomKeyBackground() } }
|
|
23
23
|
private weak var customKeyButton: UIButton?
|
|
24
24
|
|
|
25
25
|
|
|
@@ -121,23 +121,11 @@ class CalculatorKeyboardView: UIView {
|
|
|
121
121
|
let textColor = customKeyTextColor,
|
|
122
122
|
let state = customKeyState else { return }
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
if state == 1 {
|
|
126
|
-
bgColor = "#EBEBF2"
|
|
127
|
-
} else {
|
|
128
|
-
bgColor = background
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
let txtColor: UIColor
|
|
132
|
-
if state == 1 {
|
|
133
|
-
txtColor = .white
|
|
134
|
-
} else {
|
|
135
|
-
txtColor = UIColor(hex: textColor)
|
|
136
|
-
}
|
|
124
|
+
|
|
137
125
|
|
|
138
|
-
btn.isEnabled = state
|
|
139
|
-
btn.backgroundColor = UIColor(hex:
|
|
140
|
-
btn.setTitleColor(
|
|
126
|
+
btn.isEnabled = state != "disable"
|
|
127
|
+
btn.backgroundColor = UIColor(hex: background)
|
|
128
|
+
btn.setTitleColor(UIColor(hex: textColor), for: .normal)
|
|
141
129
|
|
|
142
130
|
}
|
|
143
131
|
|
package/ios/InputCalculator.m
CHANGED
|
@@ -79,7 +79,7 @@ RCT_EXPORT_VIEW_PROPERTY(keyboardColor, UIColor)
|
|
|
79
79
|
RCT_EXPORT_VIEW_PROPERTY(customKeyText, NSString)
|
|
80
80
|
RCT_EXPORT_VIEW_PROPERTY(customKeyBackground, NSString)
|
|
81
81
|
RCT_EXPORT_VIEW_PROPERTY(customKeyTextColor, NSString)
|
|
82
|
-
RCT_EXPORT_VIEW_PROPERTY(customKeyState,
|
|
82
|
+
RCT_EXPORT_VIEW_PROPERTY(customKeyState, NSString)
|
|
83
83
|
|
|
84
84
|
@end
|
|
85
85
|
|
|
@@ -34,8 +34,8 @@ class InputCalculator: RCTSinglelineTextInputView {
|
|
|
34
34
|
didSet { keyboardView?.customKeyTextColor = customKeyTextColor }
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
@objc var customKeyState:
|
|
38
|
-
didSet { keyboardView?.customKeyState = customKeyState
|
|
37
|
+
@objc var customKeyState: String? {
|
|
38
|
+
didSet { keyboardView?.customKeyState = customKeyState }
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
@objc func beginEditingInput(_ note: Notification) { onFocus?([:]) }
|
package/package.json
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/calculator-keyboard",
|
|
3
|
-
"version": "0.150.2-beta.
|
|
3
|
+
"version": "0.150.2-beta.17",
|
|
4
4
|
"description": "react native calculator keyboard",
|
|
5
|
-
"
|
|
6
|
-
"main": "./lib/commonjs/index.js",
|
|
7
|
-
"module": "./lib/module/index.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": {
|
|
11
|
-
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
-
"default": "./lib/module/index.js"
|
|
13
|
-
},
|
|
14
|
-
"require": {
|
|
15
|
-
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
-
"default": "./lib/commonjs/index.js"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
},
|
|
5
|
+
"main": "./src/index.tsx",
|
|
20
6
|
"files": [
|
|
21
7
|
"src",
|
|
22
8
|
"lib",
|
|
@@ -41,7 +27,7 @@
|
|
|
41
27
|
"typecheck": "tsc",
|
|
42
28
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
29
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
44
|
-
"build": "
|
|
30
|
+
"build": "echo 'build step'",
|
|
45
31
|
"release": "release-it"
|
|
46
32
|
},
|
|
47
33
|
"keywords": [
|
|
@@ -63,123 +49,13 @@
|
|
|
63
49
|
"registry": "https://registry.npmjs.org/"
|
|
64
50
|
},
|
|
65
51
|
"devDependencies": {
|
|
66
|
-
"@commitlint/config-conventional": "^17.0.2",
|
|
67
|
-
"@evilmartians/lefthook": "^1.5.0",
|
|
68
|
-
"@react-native-community/cli": "15.0.1",
|
|
69
|
-
"@react-native/eslint-config": "^0.73.1",
|
|
70
|
-
"@release-it/conventional-changelog": "^9.0.2",
|
|
71
|
-
"@types/jest": "^29.5.5",
|
|
72
|
-
"@types/react": "^18.2.44",
|
|
73
|
-
"commitlint": "^17.0.2",
|
|
74
|
-
"del-cli": "^5.1.0",
|
|
75
|
-
"eslint": "^8.51.0",
|
|
76
|
-
"eslint-config-prettier": "^9.0.0",
|
|
77
|
-
"eslint-plugin-prettier": "^5.0.1",
|
|
78
|
-
"jest": "^29.7.0",
|
|
79
|
-
"prettier": "^3.0.3",
|
|
80
|
-
"react": "18.3.1",
|
|
81
|
-
"react-native": "0.76.5",
|
|
82
|
-
"react-native-builder-bob": "^0.32.0",
|
|
83
|
-
"release-it": "^17.10.0",
|
|
84
|
-
"turbo": "^1.10.7",
|
|
85
|
-
"typescript": "^5.2.2"
|
|
86
|
-
},
|
|
87
|
-
"resolutions": {
|
|
88
|
-
"@types/react": "^18.2.44"
|
|
89
|
-
},
|
|
90
|
-
"peerDependencies": {
|
|
91
52
|
"react": "*",
|
|
92
53
|
"react-native": "*"
|
|
93
54
|
},
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
"<rootDir>/lib/"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"commitlint": {
|
|
102
|
-
"extends": [
|
|
103
|
-
"@commitlint/config-conventional"
|
|
104
|
-
]
|
|
105
|
-
},
|
|
106
|
-
"release-it": {
|
|
107
|
-
"git": {
|
|
108
|
-
"commitMessage": "chore: release ${version}",
|
|
109
|
-
"tagName": "v${version}"
|
|
110
|
-
},
|
|
111
|
-
"npm": {
|
|
112
|
-
"publish": true
|
|
113
|
-
},
|
|
114
|
-
"github": {
|
|
115
|
-
"release": true
|
|
116
|
-
},
|
|
117
|
-
"plugins": {
|
|
118
|
-
"@release-it/conventional-changelog": {
|
|
119
|
-
"preset": "angular"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"eslintConfig": {
|
|
124
|
-
"root": true,
|
|
125
|
-
"extends": [
|
|
126
|
-
"@react-native",
|
|
127
|
-
"prettier"
|
|
128
|
-
],
|
|
129
|
-
"rules": {
|
|
130
|
-
"react/react-in-jsx-scope": "off",
|
|
131
|
-
"prettier/prettier": [
|
|
132
|
-
"error",
|
|
133
|
-
{
|
|
134
|
-
"quoteProps": "consistent",
|
|
135
|
-
"singleQuote": true,
|
|
136
|
-
"tabWidth": 2,
|
|
137
|
-
"trailingComma": "es5",
|
|
138
|
-
"useTabs": false
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"eslintIgnore": [
|
|
144
|
-
"node_modules/",
|
|
145
|
-
"lib/"
|
|
146
|
-
],
|
|
147
|
-
"prettier": {
|
|
148
|
-
"quoteProps": "consistent",
|
|
149
|
-
"singleQuote": true,
|
|
150
|
-
"tabWidth": 2,
|
|
151
|
-
"trailingComma": "es5",
|
|
152
|
-
"useTabs": false
|
|
153
|
-
},
|
|
154
|
-
"react-native-builder-bob": {
|
|
155
|
-
"source": "src",
|
|
156
|
-
"output": "lib",
|
|
157
|
-
"targets": [
|
|
158
|
-
[
|
|
159
|
-
"commonjs",
|
|
160
|
-
{
|
|
161
|
-
"esm": true
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
"module",
|
|
166
|
-
{
|
|
167
|
-
"esm": true
|
|
168
|
-
}
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
"typescript",
|
|
172
|
-
{
|
|
173
|
-
"project": "tsconfig.build.json",
|
|
174
|
-
"esm": true
|
|
175
|
-
}
|
|
176
|
-
]
|
|
177
|
-
]
|
|
178
|
-
},
|
|
179
|
-
"create-react-native-library": {
|
|
180
|
-
"type": "legacy-view",
|
|
181
|
-
"languages": "kotlin-swift",
|
|
182
|
-
"version": "0.45.5"
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "*",
|
|
57
|
+
"react-native": "*",
|
|
58
|
+
"@momo-kits/foundation": "latest"
|
|
183
59
|
},
|
|
184
60
|
"dependencies": {}
|
|
185
61
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { ApplicationContext, Colors } from '@momo-kits/foundation';
|
|
2
3
|
import {
|
|
3
4
|
type ColorValue,
|
|
4
5
|
findNodeHandle,
|
|
5
6
|
type NativeSyntheticEvent,
|
|
6
7
|
processColor,
|
|
7
8
|
requireNativeComponent,
|
|
8
|
-
type TextInputChangeEventData,
|
|
9
9
|
type TextInputProps,
|
|
10
10
|
UIManager,
|
|
11
11
|
} from 'react-native';
|
|
@@ -15,30 +15,6 @@ const NativeInput = requireNativeComponent<any>(NAME);
|
|
|
15
15
|
|
|
16
16
|
type KeyPressEvent = { nativeEvent: { key: string } };
|
|
17
17
|
|
|
18
|
-
export enum CustomKeyBackground {
|
|
19
|
-
Default = 0,
|
|
20
|
-
Primary = 1,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* export enum CustomKeyBackground {
|
|
25
|
-
* Default = 'default',
|
|
26
|
-
* Primary = 'primary',
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
export enum CustomKeyState {
|
|
31
|
-
Default = 0,
|
|
32
|
-
Disabled = 1,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* export enum CustomKeyState {
|
|
37
|
-
* Default = 'default',
|
|
38
|
-
* Disable = 'disable',
|
|
39
|
-
* }
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
18
|
interface InputCalculatorProps extends TextInputProps {
|
|
43
19
|
text?: string | undefined;
|
|
44
20
|
keyboardColor?: ColorValue;
|
|
@@ -49,6 +25,13 @@ interface InputCalculatorProps extends TextInputProps {
|
|
|
49
25
|
onCustomKeyEvent?: () => void;
|
|
50
26
|
}
|
|
51
27
|
|
|
28
|
+
export type CustomKeyBackground = 'primary' | 'default' | string;
|
|
29
|
+
|
|
30
|
+
export enum CustomKeyState {
|
|
31
|
+
Default = 'default',
|
|
32
|
+
Disable = 'disable',
|
|
33
|
+
}
|
|
34
|
+
|
|
52
35
|
export type InputCalculatorRef = {
|
|
53
36
|
focus: () => void;
|
|
54
37
|
blur: () => void;
|
|
@@ -68,30 +51,31 @@ const InputCalculator = React.forwardRef<
|
|
|
68
51
|
onCustomKeyEvent,
|
|
69
52
|
...props
|
|
70
53
|
},
|
|
71
|
-
ref
|
|
54
|
+
ref,
|
|
72
55
|
) => {
|
|
56
|
+
const { theme } = useContext(ApplicationContext);
|
|
73
57
|
const nativeRef = React.useRef<any>(null);
|
|
74
58
|
|
|
75
|
-
const _onChange = (
|
|
76
|
-
event: NativeSyntheticEvent<TextInputChangeEventData>
|
|
77
|
-
) => {
|
|
59
|
+
const _onChange = (event: NativeSyntheticEvent<any>) => {
|
|
78
60
|
const currentText = event.nativeEvent.text;
|
|
79
|
-
props.onChange
|
|
80
|
-
props.onChangeText
|
|
61
|
+
props.onChange?.(event);
|
|
62
|
+
props.onChangeText?.(currentText);
|
|
81
63
|
};
|
|
82
64
|
|
|
83
65
|
const text = props.text ?? props.defaultValue ?? '';
|
|
84
|
-
let keyBackground =
|
|
85
|
-
let textKeyColor =
|
|
66
|
+
let keyBackground = Colors.black_06;
|
|
67
|
+
let textKeyColor = Colors.black_20;
|
|
68
|
+
|
|
69
|
+
if (customKeyBackground === 'primary') {
|
|
70
|
+
keyBackground = theme.colors.primary;
|
|
71
|
+
textKeyColor = Colors.black_01;
|
|
72
|
+
}
|
|
86
73
|
|
|
87
|
-
if (
|
|
88
|
-
keyBackground =
|
|
89
|
-
textKeyColor =
|
|
74
|
+
if (customKeyState === CustomKeyState.Disable) {
|
|
75
|
+
keyBackground = theme.colors.background.disable;
|
|
76
|
+
textKeyColor = Colors.black_01;
|
|
90
77
|
}
|
|
91
78
|
|
|
92
|
-
/**
|
|
93
|
-
* expose methods to parent component
|
|
94
|
-
*/
|
|
95
79
|
React.useImperativeHandle(ref, () => ({
|
|
96
80
|
focus() {
|
|
97
81
|
const node = findNodeHandle(nativeRef.current);
|
|
@@ -126,7 +110,7 @@ const InputCalculator = React.forwardRef<
|
|
|
126
110
|
onCustomKeyEvent={onCustomKeyEvent}
|
|
127
111
|
/>
|
|
128
112
|
);
|
|
129
|
-
}
|
|
113
|
+
},
|
|
130
114
|
);
|
|
131
115
|
|
|
132
116
|
export default InputCalculator;
|
package/lib/commonjs/index.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.CustomKeyState = exports.CustomKeyBackground = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const NAME = 'RCTInputCalculator';
|
|
12
|
-
const NativeInput = (0, _reactNative.requireNativeComponent)(NAME);
|
|
13
|
-
let CustomKeyBackground = exports.CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
|
|
14
|
-
CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
|
|
15
|
-
CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
|
|
16
|
-
return CustomKeyBackground;
|
|
17
|
-
}({});
|
|
18
|
-
/**
|
|
19
|
-
* export enum CustomKeyBackground {
|
|
20
|
-
* Default = 'default',
|
|
21
|
-
* Primary = 'primary',
|
|
22
|
-
* }
|
|
23
|
-
*/
|
|
24
|
-
let CustomKeyState = exports.CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
|
|
25
|
-
CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
|
|
26
|
-
CustomKeyState[CustomKeyState["Disabled"] = 1] = "Disabled";
|
|
27
|
-
return CustomKeyState;
|
|
28
|
-
}({});
|
|
29
|
-
/**
|
|
30
|
-
* export enum CustomKeyState {
|
|
31
|
-
* Default = 'default',
|
|
32
|
-
* Disable = 'disable',
|
|
33
|
-
* }
|
|
34
|
-
*/
|
|
35
|
-
const InputCalculator = /*#__PURE__*/_react.default.forwardRef(({
|
|
36
|
-
customKeyBackground = 'default',
|
|
37
|
-
keyboardColor = '',
|
|
38
|
-
customKeyText,
|
|
39
|
-
onKeyPress,
|
|
40
|
-
customKeyState = CustomKeyState.Default,
|
|
41
|
-
onCustomKeyEvent,
|
|
42
|
-
...props
|
|
43
|
-
}, ref) => {
|
|
44
|
-
const nativeRef = _react.default.useRef(null);
|
|
45
|
-
const _onChange = event => {
|
|
46
|
-
const currentText = event.nativeEvent.text;
|
|
47
|
-
props.onChange && props.onChange(event);
|
|
48
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
49
|
-
};
|
|
50
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
51
|
-
let keyBackground = '#D8D8D8';
|
|
52
|
-
let textKeyColor = '#000000';
|
|
53
|
-
if (customKeyBackground === CustomKeyBackground.Primary) {
|
|
54
|
-
keyBackground = '#EB2F96';
|
|
55
|
-
textKeyColor = '#FFFFFF';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* expose methods to parent component
|
|
60
|
-
*/
|
|
61
|
-
_react.default.useImperativeHandle(ref, () => ({
|
|
62
|
-
focus() {
|
|
63
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
64
|
-
if (!node) return;
|
|
65
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
66
|
-
if (config?.Commands?.focus != null) {
|
|
67
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
blur() {
|
|
71
|
-
const node = (0, _reactNative.findNodeHandle)(nativeRef.current);
|
|
72
|
-
if (!node) return;
|
|
73
|
-
const config = _reactNative.UIManager.getViewManagerConfig(NAME);
|
|
74
|
-
if (config?.Commands?.blur != null) {
|
|
75
|
-
_reactNative.UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeInput, {
|
|
80
|
-
...props,
|
|
81
|
-
ref: nativeRef,
|
|
82
|
-
onChange: _onChange,
|
|
83
|
-
onKeyPress: onKeyPress,
|
|
84
|
-
value: text,
|
|
85
|
-
keybardColor: (0, _reactNative.processColor)(keyboardColor),
|
|
86
|
-
customKeyText: customKeyText,
|
|
87
|
-
customKeyBackground: keyBackground,
|
|
88
|
-
customKeyTextColor: textKeyColor,
|
|
89
|
-
customKeyState: customKeyState,
|
|
90
|
-
onCustomKeyEvent: onCustomKeyEvent
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
var _default = exports.default = InputCalculator;
|
|
94
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","NAME","NativeInput","requireNativeComponent","CustomKeyBackground","exports","CustomKeyState","InputCalculator","React","forwardRef","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","Default","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","Primary","useImperativeHandle","focus","node","findNodeHandle","current","config","UIManager","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","jsx","value","keybardColor","processColor","customKeyTextColor","_default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
|
package/lib/module/index.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { findNodeHandle, processColor, requireNativeComponent, UIManager } from 'react-native';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
const NAME = 'RCTInputCalculator';
|
|
7
|
-
const NativeInput = requireNativeComponent(NAME);
|
|
8
|
-
export let CustomKeyBackground = /*#__PURE__*/function (CustomKeyBackground) {
|
|
9
|
-
CustomKeyBackground[CustomKeyBackground["Default"] = 0] = "Default";
|
|
10
|
-
CustomKeyBackground[CustomKeyBackground["Primary"] = 1] = "Primary";
|
|
11
|
-
return CustomKeyBackground;
|
|
12
|
-
}({});
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* export enum CustomKeyBackground {
|
|
16
|
-
* Default = 'default',
|
|
17
|
-
* Primary = 'primary',
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export let CustomKeyState = /*#__PURE__*/function (CustomKeyState) {
|
|
22
|
-
CustomKeyState[CustomKeyState["Default"] = 0] = "Default";
|
|
23
|
-
CustomKeyState[CustomKeyState["Disabled"] = 1] = "Disabled";
|
|
24
|
-
return CustomKeyState;
|
|
25
|
-
}({});
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* export enum CustomKeyState {
|
|
29
|
-
* Default = 'default',
|
|
30
|
-
* Disable = 'disable',
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
const InputCalculator = /*#__PURE__*/React.forwardRef(({
|
|
35
|
-
customKeyBackground = 'default',
|
|
36
|
-
keyboardColor = '',
|
|
37
|
-
customKeyText,
|
|
38
|
-
onKeyPress,
|
|
39
|
-
customKeyState = CustomKeyState.Default,
|
|
40
|
-
onCustomKeyEvent,
|
|
41
|
-
...props
|
|
42
|
-
}, ref) => {
|
|
43
|
-
const nativeRef = React.useRef(null);
|
|
44
|
-
const _onChange = event => {
|
|
45
|
-
const currentText = event.nativeEvent.text;
|
|
46
|
-
props.onChange && props.onChange(event);
|
|
47
|
-
props.onChangeText && props.onChangeText(currentText);
|
|
48
|
-
};
|
|
49
|
-
const text = props.text ?? props.defaultValue ?? '';
|
|
50
|
-
let keyBackground = '#D8D8D8';
|
|
51
|
-
let textKeyColor = '#000000';
|
|
52
|
-
if (customKeyBackground === CustomKeyBackground.Primary) {
|
|
53
|
-
keyBackground = '#EB2F96';
|
|
54
|
-
textKeyColor = '#FFFFFF';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* expose methods to parent component
|
|
59
|
-
*/
|
|
60
|
-
React.useImperativeHandle(ref, () => ({
|
|
61
|
-
focus() {
|
|
62
|
-
const node = findNodeHandle(nativeRef.current);
|
|
63
|
-
if (!node) return;
|
|
64
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
65
|
-
if (config?.Commands?.focus != null) {
|
|
66
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.focus, []);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
blur() {
|
|
70
|
-
const node = findNodeHandle(nativeRef.current);
|
|
71
|
-
if (!node) return;
|
|
72
|
-
const config = UIManager.getViewManagerConfig(NAME);
|
|
73
|
-
if (config?.Commands?.blur != null) {
|
|
74
|
-
UIManager.dispatchViewManagerCommand(node, config.Commands.blur, []);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}));
|
|
78
|
-
return /*#__PURE__*/_jsx(NativeInput, {
|
|
79
|
-
...props,
|
|
80
|
-
ref: nativeRef,
|
|
81
|
-
onChange: _onChange,
|
|
82
|
-
onKeyPress: onKeyPress,
|
|
83
|
-
value: text,
|
|
84
|
-
keybardColor: processColor(keyboardColor),
|
|
85
|
-
customKeyText: customKeyText,
|
|
86
|
-
customKeyBackground: keyBackground,
|
|
87
|
-
customKeyTextColor: textKeyColor,
|
|
88
|
-
customKeyState: customKeyState,
|
|
89
|
-
onCustomKeyEvent: onCustomKeyEvent
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
export default InputCalculator;
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","findNodeHandle","processColor","requireNativeComponent","UIManager","jsx","_jsx","NAME","NativeInput","CustomKeyBackground","CustomKeyState","InputCalculator","forwardRef","customKeyBackground","keyboardColor","customKeyText","onKeyPress","customKeyState","Default","onCustomKeyEvent","props","ref","nativeRef","useRef","_onChange","event","currentText","nativeEvent","text","onChange","onChangeText","defaultValue","keyBackground","textKeyColor","Primary","useImperativeHandle","focus","node","current","config","getViewManagerConfig","Commands","dispatchViewManagerCommand","blur","value","keybardColor","customKeyTextColor"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ColorValue, type TextInputProps } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare enum CustomKeyBackground {
|
|
9
|
-
Default = 0,
|
|
10
|
-
Primary = 1
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* export enum CustomKeyBackground {
|
|
14
|
-
* Default = 'default',
|
|
15
|
-
* Primary = 'primary',
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export declare enum CustomKeyState {
|
|
19
|
-
Default = 0,
|
|
20
|
-
Disabled = 1
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* export enum CustomKeyState {
|
|
24
|
-
* Default = 'default',
|
|
25
|
-
* Disable = 'disable',
|
|
26
|
-
* }
|
|
27
|
-
*/
|
|
28
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
29
|
-
text?: string | undefined;
|
|
30
|
-
keyboardColor?: ColorValue;
|
|
31
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
32
|
-
customKeyText?: string | undefined;
|
|
33
|
-
customKeyBackground?: CustomKeyBackground;
|
|
34
|
-
customKeyState?: CustomKeyState;
|
|
35
|
-
onCustomKeyEvent?: () => void;
|
|
36
|
-
}
|
|
37
|
-
export type InputCalculatorRef = {
|
|
38
|
-
focus: () => void;
|
|
39
|
-
blur: () => void;
|
|
40
|
-
};
|
|
41
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
42
|
-
export default InputCalculator;
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC7B,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED;;;;;GAKG;AAEH,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED;;;;;GAKG;AAEH,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGAyEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type ColorValue, type TextInputProps } from 'react-native';
|
|
3
|
-
type KeyPressEvent = {
|
|
4
|
-
nativeEvent: {
|
|
5
|
-
key: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare enum CustomKeyBackground {
|
|
9
|
-
Default = 0,
|
|
10
|
-
Primary = 1
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* export enum CustomKeyBackground {
|
|
14
|
-
* Default = 'default',
|
|
15
|
-
* Primary = 'primary',
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export declare enum CustomKeyState {
|
|
19
|
-
Default = 0,
|
|
20
|
-
Disabled = 1
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* export enum CustomKeyState {
|
|
24
|
-
* Default = 'default',
|
|
25
|
-
* Disable = 'disable',
|
|
26
|
-
* }
|
|
27
|
-
*/
|
|
28
|
-
interface InputCalculatorProps extends TextInputProps {
|
|
29
|
-
text?: string | undefined;
|
|
30
|
-
keyboardColor?: ColorValue;
|
|
31
|
-
onKeyPress?: (e: KeyPressEvent) => void;
|
|
32
|
-
customKeyText?: string | undefined;
|
|
33
|
-
customKeyBackground?: CustomKeyBackground;
|
|
34
|
-
customKeyState?: CustomKeyState;
|
|
35
|
-
onCustomKeyEvent?: () => void;
|
|
36
|
-
}
|
|
37
|
-
export type InputCalculatorRef = {
|
|
38
|
-
focus: () => void;
|
|
39
|
-
blur: () => void;
|
|
40
|
-
};
|
|
41
|
-
declare const InputCalculator: React.ForwardRefExoticComponent<InputCalculatorProps & React.RefAttributes<InputCalculatorRef>>;
|
|
42
|
-
export default InputCalculator;
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,UAAU,EAMf,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AAKtB,KAAK,aAAa,GAAG;IAAE,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEtD,oBAAY,mBAAmB;IAC7B,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED;;;;;GAKG;AAEH,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED;;;;;GAKG;AAEH,UAAU,oBAAqB,SAAQ,cAAc;IACnD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,eAAe,iGAyEpB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|