@planningcenter/chat-react-native 3.15.0-rc.7 → 3.15.0-rc.9
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/build/components/display/icon.d.ts +26 -13
- package/build/components/display/icon.d.ts.map +1 -1
- package/build/components/display/icon.js +0 -12
- package/build/components/display/icon.js.map +1 -1
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/polyfills/events/CustomEvent.d.ts +21 -0
- package/build/polyfills/events/CustomEvent.d.ts.map +1 -0
- package/build/polyfills/events/CustomEvent.js +22 -0
- package/build/polyfills/events/CustomEvent.js.map +1 -0
- package/build/polyfills/events/Event.d.ts +49 -0
- package/build/polyfills/events/Event.d.ts.map +1 -0
- package/build/polyfills/events/Event.js +125 -0
- package/build/polyfills/events/Event.js.map +1 -0
- package/build/polyfills/events/EventHandlerAttributes.d.ts +8 -0
- package/build/polyfills/events/EventHandlerAttributes.d.ts.map +1 -0
- package/build/polyfills/events/EventHandlerAttributes.js +46 -0
- package/build/polyfills/events/EventHandlerAttributes.js.map +1 -0
- package/build/polyfills/events/EventTarget.d.ts +33 -0
- package/build/polyfills/events/EventTarget.d.ts.map +1 -0
- package/build/polyfills/events/EventTarget.js +238 -0
- package/build/polyfills/events/EventTarget.js.map +1 -0
- package/build/polyfills/events/internals/EventInternals.d.ts +30 -0
- package/build/polyfills/events/internals/EventInternals.d.ts.map +1 -0
- package/build/polyfills/events/internals/EventInternals.js +76 -0
- package/build/polyfills/events/internals/EventInternals.js.map +1 -0
- package/build/polyfills/events/internals/EventTargetInternals.d.ts +9 -0
- package/build/polyfills/events/internals/EventTargetInternals.d.ts.map +1 -0
- package/build/polyfills/events/internals/EventTargetInternals.js +11 -0
- package/build/polyfills/events/internals/EventTargetInternals.js.map +1 -0
- package/build/polyfills/webidl/PlatformObjects.d.ts +31 -0
- package/build/polyfills/webidl/PlatformObjects.d.ts.map +1 -0
- package/build/polyfills/webidl/PlatformObjects.js +39 -0
- package/build/polyfills/webidl/PlatformObjects.js.map +1 -0
- package/build/screens/design_system_screen.js +1 -1
- package/build/screens/design_system_screen.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/event-polyfill.test.ts +314 -0
- package/src/components/display/icon.tsx +17 -14
- package/src/index.tsx +2 -0
- package/src/polyfills/events/CustomEvent.ts +32 -0
- package/src/polyfills/events/Event.ts +186 -0
- package/src/polyfills/events/EventHandlerAttributes.ts +67 -0
- package/src/polyfills/events/EventTarget.ts +360 -0
- package/src/polyfills/events/README.md +1 -0
- package/src/polyfills/events/internals/EventInternals.ts +95 -0
- package/src/polyfills/events/internals/EventTargetInternals.ts +16 -0
- package/src/polyfills/webidl/PlatformObjects.ts +50 -0
- package/src/screens/design_system_screen.tsx +1 -1
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Implements the `EventTarget` interface from the DOM.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import Event from './Event'
|
|
13
|
+
import {
|
|
14
|
+
getStopImmediatePropagationFlag,
|
|
15
|
+
getStopPropagationFlag,
|
|
16
|
+
setComposedPath,
|
|
17
|
+
setCurrentTarget,
|
|
18
|
+
setEventPhase,
|
|
19
|
+
setInPassiveListenerFlag,
|
|
20
|
+
setIsTrusted,
|
|
21
|
+
setStopImmediatePropagationFlag,
|
|
22
|
+
setStopPropagationFlag,
|
|
23
|
+
setTarget,
|
|
24
|
+
} from './internals/EventInternals'
|
|
25
|
+
import {
|
|
26
|
+
EVENT_TARGET_GET_THE_PARENT_KEY,
|
|
27
|
+
INTERNAL_DISPATCH_METHOD_KEY,
|
|
28
|
+
} from './internals/EventTargetInternals'
|
|
29
|
+
import { setPlatformObject } from '../webidl/PlatformObjects'
|
|
30
|
+
|
|
31
|
+
export type EventCallback = (event: Event) => void
|
|
32
|
+
export type EventHandler = { handleEvent(event: Event): void }
|
|
33
|
+
export type EventListener = EventCallback | EventHandler
|
|
34
|
+
|
|
35
|
+
export type EventListenerOptions = Readonly<{
|
|
36
|
+
capture?: boolean
|
|
37
|
+
}>
|
|
38
|
+
|
|
39
|
+
export type AddEventListenerOptions = Readonly<{
|
|
40
|
+
capture?: boolean
|
|
41
|
+
passive?: boolean
|
|
42
|
+
once?: boolean
|
|
43
|
+
signal?: AbortSignal
|
|
44
|
+
}>
|
|
45
|
+
|
|
46
|
+
type EventListenerRegistration = {
|
|
47
|
+
readonly callback: EventListener
|
|
48
|
+
readonly passive: boolean
|
|
49
|
+
readonly once: boolean
|
|
50
|
+
removed: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type ListenersMap = Map<string, Map<EventListener, EventListenerRegistration>>
|
|
54
|
+
|
|
55
|
+
export default class EventTarget {
|
|
56
|
+
addEventListener(
|
|
57
|
+
type: string,
|
|
58
|
+
callback: EventListener | null,
|
|
59
|
+
optionsOrUseCapture: AddEventListenerOptions | boolean = {}
|
|
60
|
+
): void {
|
|
61
|
+
if (arguments.length < 2) {
|
|
62
|
+
throw new TypeError(
|
|
63
|
+
`Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (callback == null) {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
validateCallback(callback, 'addEventListener')
|
|
72
|
+
|
|
73
|
+
const processedType = String(type)
|
|
74
|
+
|
|
75
|
+
let capture: boolean
|
|
76
|
+
let passive: boolean
|
|
77
|
+
let once: boolean
|
|
78
|
+
let signal: AbortSignal | null | undefined
|
|
79
|
+
|
|
80
|
+
if (
|
|
81
|
+
optionsOrUseCapture != null &&
|
|
82
|
+
(typeof optionsOrUseCapture === 'object' || typeof optionsOrUseCapture === 'function')
|
|
83
|
+
) {
|
|
84
|
+
const opts = optionsOrUseCapture as AddEventListenerOptions
|
|
85
|
+
capture = Boolean(opts.capture)
|
|
86
|
+
passive =
|
|
87
|
+
opts.passive == null ? getDefaultPassiveValue(processedType, this) : Boolean(opts.passive)
|
|
88
|
+
once = Boolean(opts.once)
|
|
89
|
+
signal = opts.signal
|
|
90
|
+
if (signal !== undefined && !(signal instanceof AbortSignal)) {
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
"Failed to execute 'addEventListener' on 'EventTarget': Failed to read the 'signal' property from 'AddEventListenerOptions': Failed to convert value to 'AbortSignal'."
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
capture = Boolean(optionsOrUseCapture)
|
|
97
|
+
passive = false
|
|
98
|
+
once = false
|
|
99
|
+
signal = null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (signal?.aborted) {
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let listenersByType = getListenersForPhase(this, capture)
|
|
107
|
+
let listeners = listenersByType?.get(processedType)
|
|
108
|
+
if (listeners == null) {
|
|
109
|
+
if (listenersByType == null) {
|
|
110
|
+
listenersByType = new Map()
|
|
111
|
+
setListenersMap(this, capture, listenersByType)
|
|
112
|
+
}
|
|
113
|
+
listeners = new Map()
|
|
114
|
+
listenersByType.set(processedType, listeners)
|
|
115
|
+
} else if (listeners.has(callback)) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const listener: EventListenerRegistration = {
|
|
120
|
+
callback,
|
|
121
|
+
passive,
|
|
122
|
+
once,
|
|
123
|
+
removed: false,
|
|
124
|
+
}
|
|
125
|
+
listeners.set(callback, listener)
|
|
126
|
+
|
|
127
|
+
const nonNullListeners = listeners
|
|
128
|
+
|
|
129
|
+
if (signal != null) {
|
|
130
|
+
signal.addEventListener(
|
|
131
|
+
'abort',
|
|
132
|
+
() => {
|
|
133
|
+
listener.removed = true
|
|
134
|
+
if (nonNullListeners.get(callback) === listener) {
|
|
135
|
+
nonNullListeners.delete(callback)
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{ once: true }
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
removeEventListener(
|
|
144
|
+
type: string,
|
|
145
|
+
callback: EventListener,
|
|
146
|
+
optionsOrUseCapture: EventListenerOptions | boolean = {}
|
|
147
|
+
): void {
|
|
148
|
+
if (arguments.length < 2) {
|
|
149
|
+
throw new TypeError(
|
|
150
|
+
`Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (callback == null) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
validateCallback(callback, 'removeEventListener')
|
|
159
|
+
|
|
160
|
+
const processedType = String(type)
|
|
161
|
+
|
|
162
|
+
const capture =
|
|
163
|
+
typeof optionsOrUseCapture === 'boolean'
|
|
164
|
+
? optionsOrUseCapture
|
|
165
|
+
: Boolean((optionsOrUseCapture as EventListenerOptions).capture)
|
|
166
|
+
|
|
167
|
+
const listenersByType = getListenersForPhase(this, capture)
|
|
168
|
+
const listeners = listenersByType?.get(processedType)
|
|
169
|
+
if (listeners == null) {
|
|
170
|
+
return
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const listener = listeners.get(callback)
|
|
174
|
+
if (listener != null) {
|
|
175
|
+
listener.removed = true
|
|
176
|
+
listeners.delete(callback)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
dispatchEvent(event: Event): boolean {
|
|
181
|
+
if (!(event instanceof Event)) {
|
|
182
|
+
throw new TypeError(
|
|
183
|
+
"Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'."
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (getEventDispatchFlag(event)) {
|
|
188
|
+
throw new Error(
|
|
189
|
+
"Failed to execute 'dispatchEvent' on 'EventTarget': The event is already being dispatched."
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
setIsTrusted(event, false)
|
|
194
|
+
dispatch(this, event)
|
|
195
|
+
return !event.defaultPrevented
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// "protected" for subclasses: get the parent (see spec)
|
|
199
|
+
[EVENT_TARGET_GET_THE_PARENT_KEY](): EventTarget | null {
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// "protected" to dispatch trusted events
|
|
204
|
+
[INTERNAL_DISPATCH_METHOD_KEY](event: Event): void {
|
|
205
|
+
dispatch(this, event)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
setPlatformObject(EventTarget)
|
|
210
|
+
|
|
211
|
+
function validateCallback(callback: EventListener, methodName: string): void {
|
|
212
|
+
if (typeof callback !== 'function' && typeof callback !== 'object') {
|
|
213
|
+
throw new TypeError(
|
|
214
|
+
`Failed to execute '${methodName}' on 'EventTarget': parameter 2 is not of type 'Object'.`
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function getDefaultPassiveValue(_type: string, _eventTarget: EventTarget): boolean {
|
|
220
|
+
return false
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function dispatch(eventTarget: EventTarget, event: Event): void {
|
|
224
|
+
setEventDispatchFlag(event, true)
|
|
225
|
+
|
|
226
|
+
const eventPath = getEventPath(eventTarget, event)
|
|
227
|
+
setComposedPath(event, eventPath)
|
|
228
|
+
setTarget(event, eventTarget)
|
|
229
|
+
|
|
230
|
+
for (let i = eventPath.length - 1; i >= 0; i--) {
|
|
231
|
+
if (getStopPropagationFlag(event)) {
|
|
232
|
+
break
|
|
233
|
+
}
|
|
234
|
+
const target = eventPath[i]
|
|
235
|
+
setEventPhase(event, target === eventTarget ? Event.AT_TARGET : Event.CAPTURING_PHASE)
|
|
236
|
+
invoke(target, event, Event.CAPTURING_PHASE)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const target of eventPath) {
|
|
240
|
+
if (getStopPropagationFlag(event)) {
|
|
241
|
+
break
|
|
242
|
+
}
|
|
243
|
+
if (!event.bubbles && target !== eventTarget) {
|
|
244
|
+
break
|
|
245
|
+
}
|
|
246
|
+
setEventPhase(event, target === eventTarget ? Event.AT_TARGET : Event.BUBBLING_PHASE)
|
|
247
|
+
invoke(target, event, Event.BUBBLING_PHASE)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
setEventPhase(event, Event.NONE)
|
|
251
|
+
setCurrentTarget(event, null)
|
|
252
|
+
setComposedPath(event, [])
|
|
253
|
+
|
|
254
|
+
setEventDispatchFlag(event, false)
|
|
255
|
+
setStopImmediatePropagationFlag(event, false)
|
|
256
|
+
setStopPropagationFlag(event, false)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getEventPath(eventTarget: EventTarget, _event: Event): ReadonlyArray<EventTarget> {
|
|
260
|
+
const path: EventTarget[] = []
|
|
261
|
+
let target: EventTarget | null = eventTarget
|
|
262
|
+
|
|
263
|
+
while (target != null) {
|
|
264
|
+
path.push(target)
|
|
265
|
+
target = target[EVENT_TARGET_GET_THE_PARENT_KEY]()
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return path
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function invoke(eventTarget: EventTarget, event: Event, eventPhase: import('./Event').EventPhase) {
|
|
272
|
+
const listenersByType = getListenersForPhase(eventTarget, eventPhase === Event.CAPTURING_PHASE)
|
|
273
|
+
|
|
274
|
+
setCurrentTarget(event, eventTarget)
|
|
275
|
+
|
|
276
|
+
const maybeListeners = listenersByType?.get(event.type)
|
|
277
|
+
if (maybeListeners == null) {
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const listeners = Array.from(maybeListeners.values())
|
|
282
|
+
setCurrentTarget(event, eventTarget)
|
|
283
|
+
|
|
284
|
+
for (const listener of listeners) {
|
|
285
|
+
if (listener.removed) {
|
|
286
|
+
continue
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (listener.once) {
|
|
290
|
+
eventTarget.removeEventListener(
|
|
291
|
+
event.type,
|
|
292
|
+
listener.callback,
|
|
293
|
+
eventPhase === Event.CAPTURING_PHASE
|
|
294
|
+
)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (listener.passive) {
|
|
298
|
+
setInPassiveListenerFlag(event, true)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const currentEvent = (global as any).event
|
|
302
|
+
;(global as any).event = event
|
|
303
|
+
|
|
304
|
+
const callback = listener.callback as any
|
|
305
|
+
try {
|
|
306
|
+
if (typeof callback === 'function') {
|
|
307
|
+
callback.call(eventTarget, event)
|
|
308
|
+
} else if (typeof callback.handleEvent === 'function') {
|
|
309
|
+
callback.handleEvent(event)
|
|
310
|
+
}
|
|
311
|
+
} catch (error) {
|
|
312
|
+
// TODO: replace with `reportError` when it's available.
|
|
313
|
+
|
|
314
|
+
console.error(error)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (listener.passive) {
|
|
318
|
+
setInPassiveListenerFlag(event, false)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
;(global as any).event = currentEvent
|
|
322
|
+
|
|
323
|
+
if (getStopImmediatePropagationFlag(event)) {
|
|
324
|
+
break
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const CAPTURING_LISTENERS_KEY = Symbol('capturingListeners')
|
|
330
|
+
const BUBBLING_LISTENERS_KEY = Symbol('bubblingListeners')
|
|
331
|
+
|
|
332
|
+
function getListenersForPhase(
|
|
333
|
+
eventTarget: EventTarget,
|
|
334
|
+
isCapture: boolean
|
|
335
|
+
): ListenersMap | null | undefined {
|
|
336
|
+
// @ts-expect-error index on symbol
|
|
337
|
+
return isCapture ? eventTarget[CAPTURING_LISTENERS_KEY] : eventTarget[BUBBLING_LISTENERS_KEY]
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function setListenersMap(
|
|
341
|
+
eventTarget: EventTarget,
|
|
342
|
+
isCapture: boolean,
|
|
343
|
+
listenersMap: ListenersMap
|
|
344
|
+
): void {
|
|
345
|
+
if (isCapture) {
|
|
346
|
+
;(eventTarget as any)[CAPTURING_LISTENERS_KEY] = listenersMap
|
|
347
|
+
} else {
|
|
348
|
+
;(eventTarget as any)[BUBBLING_LISTENERS_KEY] = listenersMap
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const EVENT_DISPATCH_FLAG = Symbol('Event.dispatch')
|
|
353
|
+
|
|
354
|
+
function getEventDispatchFlag(event: Event): boolean {
|
|
355
|
+
return (event as any)[EVENT_DISPATCH_FLAG]
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function setEventDispatchFlag(event: Event, value: boolean): void {
|
|
359
|
+
;(event as any)[EVENT_DISPATCH_FLAG] = value
|
|
360
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This code is taken from react-native core.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal implementation details for the `Event` module.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type Event from '../Event'
|
|
6
|
+
import type EventTarget from '../EventTarget'
|
|
7
|
+
|
|
8
|
+
export const COMPOSED_PATH_KEY: unique symbol = Symbol('composedPath')
|
|
9
|
+
export const CURRENT_TARGET_KEY: unique symbol = Symbol('currentTarget')
|
|
10
|
+
export const EVENT_PHASE_KEY: unique symbol = Symbol('eventPhase')
|
|
11
|
+
export const IN_PASSIVE_LISTENER_FLAG_KEY: unique symbol = Symbol('inPassiveListenerFlag')
|
|
12
|
+
export const IS_TRUSTED_KEY: unique symbol = Symbol('isTrusted')
|
|
13
|
+
export const STOP_IMMEDIATE_PROPAGATION_FLAG_KEY: unique symbol = Symbol('stopPropagationFlag')
|
|
14
|
+
export const STOP_PROPAGATION_FLAG_KEY: unique symbol = Symbol('stopPropagationFlag')
|
|
15
|
+
export const TARGET_KEY: unique symbol = Symbol('target')
|
|
16
|
+
|
|
17
|
+
export function getCurrentTarget(event: Event): EventTarget | null {
|
|
18
|
+
// @ts-expect-error index on symbol
|
|
19
|
+
return event[CURRENT_TARGET_KEY]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setCurrentTarget(event: Event, currentTarget: EventTarget | null): void {
|
|
23
|
+
// @ts-expect-error index on symbol
|
|
24
|
+
event[CURRENT_TARGET_KEY] = currentTarget
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getComposedPath(event: Event): ReadonlyArray<EventTarget> {
|
|
28
|
+
// @ts-expect-error index on symbol
|
|
29
|
+
return event[COMPOSED_PATH_KEY]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function setComposedPath(event: Event, composedPath: ReadonlyArray<EventTarget>): void {
|
|
33
|
+
// @ts-expect-error index on symbol
|
|
34
|
+
event[COMPOSED_PATH_KEY] = composedPath
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getEventPhase(event: Event): import('../Event').EventPhase {
|
|
38
|
+
// @ts-expect-error index on symbol
|
|
39
|
+
return event[EVENT_PHASE_KEY]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function setEventPhase(event: Event, eventPhase: import('../Event').EventPhase): void {
|
|
43
|
+
// @ts-expect-error index on symbol
|
|
44
|
+
event[EVENT_PHASE_KEY] = eventPhase
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function getInPassiveListenerFlag(event: Event): boolean {
|
|
48
|
+
// @ts-expect-error index on symbol
|
|
49
|
+
return event[IN_PASSIVE_LISTENER_FLAG_KEY]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function setInPassiveListenerFlag(event: Event, value: boolean): void {
|
|
53
|
+
// @ts-expect-error index on symbol
|
|
54
|
+
event[IN_PASSIVE_LISTENER_FLAG_KEY] = value
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function getIsTrusted(event: Event): boolean {
|
|
58
|
+
// @ts-expect-error index on symbol
|
|
59
|
+
return event[IS_TRUSTED_KEY]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function setIsTrusted(event: Event, isTrusted: boolean): void {
|
|
63
|
+
// @ts-expect-error index on symbol
|
|
64
|
+
event[IS_TRUSTED_KEY] = isTrusted
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function getStopImmediatePropagationFlag(event: Event): boolean {
|
|
68
|
+
// @ts-expect-error index on symbol
|
|
69
|
+
return event[STOP_IMMEDIATE_PROPAGATION_FLAG_KEY]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function setStopImmediatePropagationFlag(event: Event, value: boolean): void {
|
|
73
|
+
// @ts-expect-error index on symbol
|
|
74
|
+
event[STOP_IMMEDIATE_PROPAGATION_FLAG_KEY] = value
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function getStopPropagationFlag(event: Event): boolean {
|
|
78
|
+
// @ts-expect-error index on symbol
|
|
79
|
+
return event[STOP_PROPAGATION_FLAG_KEY]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function setStopPropagationFlag(event: Event, value: boolean): void {
|
|
83
|
+
// @ts-expect-error index on symbol
|
|
84
|
+
event[STOP_PROPAGATION_FLAG_KEY] = value
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function getTarget(event: Event): EventTarget | null {
|
|
88
|
+
// @ts-expect-error index on symbol
|
|
89
|
+
return event[TARGET_KEY]
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function setTarget(event: Event, target: EventTarget | null): void {
|
|
93
|
+
// @ts-expect-error index on symbol
|
|
94
|
+
event[TARGET_KEY] = target
|
|
95
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal implementation details for the `EventTarget` module.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type Event from '../Event'
|
|
6
|
+
import type EventTarget from '../EventTarget'
|
|
7
|
+
import { setIsTrusted } from './EventInternals'
|
|
8
|
+
|
|
9
|
+
export const EVENT_TARGET_GET_THE_PARENT_KEY: unique symbol = Symbol('EventTarget[get the parent]')
|
|
10
|
+
|
|
11
|
+
export const INTERNAL_DISPATCH_METHOD_KEY: unique symbol = Symbol('EventTarget[dispatch]')
|
|
12
|
+
|
|
13
|
+
export function dispatchTrustedEvent(eventTarget: EventTarget, event: Event): void {
|
|
14
|
+
setIsTrusted(event, true)
|
|
15
|
+
return eventTarget[INTERNAL_DISPATCH_METHOD_KEY](event)
|
|
16
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const IS_PLATFORM_OBJECT_KEY = Symbol('isPlatformObject')
|
|
9
|
+
const CLONE_PLATFORM_OBJECT_KEY = Symbol('clonePlatformObject')
|
|
10
|
+
|
|
11
|
+
type CloneFn<T extends object> = (value: T) => T
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Marks the given object or instances of the given class as platform objects.
|
|
15
|
+
*
|
|
16
|
+
* Optionally, it sets the clone function for that platform object, which is a
|
|
17
|
+
* simplification of the serializable attribute of the Web interface.
|
|
18
|
+
*/
|
|
19
|
+
export function setPlatformObject<T extends object>(
|
|
20
|
+
obj: { prototype: unknown },
|
|
21
|
+
options?: { clone: CloneFn<T> }
|
|
22
|
+
): void
|
|
23
|
+
export function setPlatformObject<T extends object>(obj: T, options?: { clone: CloneFn<T> }): void
|
|
24
|
+
export function setPlatformObject(obj: any, options?: { clone: (value: any) => any }): void {
|
|
25
|
+
if (typeof obj === 'function') {
|
|
26
|
+
;(obj.prototype as any)[IS_PLATFORM_OBJECT_KEY] = true
|
|
27
|
+
if (options) {
|
|
28
|
+
;(obj.prototype as any)[CLONE_PLATFORM_OBJECT_KEY] = options.clone
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
;(obj as any)[IS_PLATFORM_OBJECT_KEY] = true
|
|
32
|
+
if (options) {
|
|
33
|
+
;(obj as any)[CLONE_PLATFORM_OBJECT_KEY] = options.clone
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Indicates if the given object is a platform object.
|
|
40
|
+
*/
|
|
41
|
+
export function isPlatformObject<T extends object>(obj: T): boolean {
|
|
42
|
+
return IS_PLATFORM_OBJECT_KEY in (obj as any)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns the clone function for the given platform object, if it was set.
|
|
47
|
+
*/
|
|
48
|
+
export function getPlatformObjectClone<T extends object>(obj: T): ((value: T) => T) | undefined {
|
|
49
|
+
return (obj as any)[CLONE_PLATFORM_OBJECT_KEY]
|
|
50
|
+
}
|
|
@@ -863,7 +863,7 @@ function ImageIconsSection({ isLast }: SectionProps) {
|
|
|
863
863
|
description="Displays any icon from @planningcenter/icons. Missing icons will fallback to a grey circle. Styling with `fontSize` will allow it to scale with the device's text a11y size."
|
|
864
864
|
>
|
|
865
865
|
<Row>
|
|
866
|
-
{/* @ts-expect-error -
|
|
866
|
+
{/* @ts-expect-error - Testing missing icon fallback */}
|
|
867
867
|
<Icon name="missingIcon" size={20} />
|
|
868
868
|
<Icon name="general.textMessage" size={20} />
|
|
869
869
|
<Icon name="general.bell" size={20} color={colors.needsDesignPass} />
|