@tamagui/adapt 3.0.0-beta.924.1 → 3.0.1
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/dist/cjs/Adapt.cjs +90 -67
- package/dist/cjs/Adapt.native.cjs +113 -70
- package/dist/cjs/Adapt.native.js +113 -70
- package/dist/cjs/Adapt.native.js.map +1 -1
- package/dist/esm/Adapt.mjs +90 -68
- package/dist/esm/Adapt.mjs.map +1 -1
- package/dist/esm/Adapt.native.js +113 -71
- package/dist/esm/Adapt.native.js.map +1 -1
- package/package.json +10 -8
- package/src/Adapt.tsx +131 -90
- package/types/Adapt.d.ts +11 -17
- package/types/Adapt.d.ts.map +1 -1
package/src/Adapt.tsx
CHANGED
|
@@ -88,16 +88,13 @@ export type AdaptTarget<State = unknown> = {
|
|
|
88
88
|
state: State
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export type AdaptConfig = Pick<AdaptProps, 'when' | 'platform'>
|
|
92
|
+
|
|
91
93
|
export type AdaptParentContextI = {
|
|
92
94
|
Contents: Component
|
|
93
95
|
scopeName: string
|
|
94
|
-
platform: AdaptPlatform
|
|
95
|
-
setPlatform: (when: AdaptPlatform) => any
|
|
96
|
-
when: AdaptWhen
|
|
97
|
-
setWhen: (when: AdaptWhen) => any
|
|
98
96
|
active: boolean
|
|
99
|
-
|
|
100
|
-
setRawActive: (active: boolean) => void
|
|
97
|
+
setAdaptConfig: (config: AdaptConfig | null) => void
|
|
101
98
|
portalName?: string
|
|
102
99
|
lastScope?: string
|
|
103
100
|
slot: AdaptSlotStore | null
|
|
@@ -139,13 +136,8 @@ const adaptContextKeys = [
|
|
|
139
136
|
'Contents',
|
|
140
137
|
'scopeName',
|
|
141
138
|
'portalName',
|
|
142
|
-
'platform',
|
|
143
|
-
'setPlatform',
|
|
144
|
-
'when',
|
|
145
|
-
'setWhen',
|
|
146
139
|
'active',
|
|
147
|
-
'
|
|
148
|
-
'setRawActive',
|
|
140
|
+
'setAdaptConfig',
|
|
149
141
|
'slot',
|
|
150
142
|
'handoff',
|
|
151
143
|
'targetFullyHidden',
|
|
@@ -165,13 +157,8 @@ export const AdaptContext = createStyledContext<
|
|
|
165
157
|
Contents: null as any,
|
|
166
158
|
scopeName: '',
|
|
167
159
|
portalName: '',
|
|
168
|
-
platform: null as any,
|
|
169
|
-
setPlatform: (x: AdaptPlatform) => {},
|
|
170
|
-
when: null as any,
|
|
171
|
-
setWhen: () => {},
|
|
172
160
|
active: false,
|
|
173
|
-
|
|
174
|
-
setRawActive: () => {},
|
|
161
|
+
setAdaptConfig: () => {},
|
|
175
162
|
slot: null,
|
|
176
163
|
handoff: {
|
|
177
164
|
hidden: true,
|
|
@@ -193,6 +180,9 @@ export const AdaptContext = createStyledContext<
|
|
|
193
180
|
const AdaptCapabilitiesContext = createContext<AdaptCapabilitiesValue>({})
|
|
194
181
|
|
|
195
182
|
const LastAdaptContextScope = createContext('')
|
|
183
|
+
const AdaptTargetScope = createContext<string | null>(null)
|
|
184
|
+
|
|
185
|
+
export const useAdaptTargetScope = () => useContext(AdaptTargetScope)
|
|
196
186
|
|
|
197
187
|
export const ProvideAdaptContext = ({
|
|
198
188
|
children,
|
|
@@ -226,21 +216,53 @@ export const useAdaptContext = (scope?: string) => {
|
|
|
226
216
|
|
|
227
217
|
type AdaptParentProps = {
|
|
228
218
|
children?: React.ReactNode
|
|
219
|
+
// the children the user gave the adapting component, where their <Adapt /> lives.
|
|
220
|
+
// AdaptParent's own children are that component's internals, one wrapper deep.
|
|
221
|
+
adaptChildren?: React.ReactNode
|
|
229
222
|
Contents?: AdaptParentContextI['Contents']
|
|
230
223
|
scope: string
|
|
231
224
|
open?: boolean
|
|
232
225
|
onOpenChange?: (open: boolean) => void
|
|
233
226
|
state?: unknown
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// an <Adapt /> written into the adapting component's children is read off the
|
|
230
|
+
// element tree during render. learning it from the child's layout effect left
|
|
231
|
+
// every consumer seeing "inactive" on the first commit, so an adapted Select
|
|
232
|
+
// mounted SelectInlineImpl and swapped it for SelectSheetImpl one commit later,
|
|
233
|
+
// remounting the whole subtree. only direct children are scanned, descending
|
|
234
|
+
// into fragments: any deeper and a nested adapting component's own <Adapt />
|
|
235
|
+
// would adapt this one too. Children.toArray already flattens arrays and drops
|
|
236
|
+
// false, so `{cond && <Adapt />}` still reads. an <Adapt /> that a userland
|
|
237
|
+
// component renders is not in this tree, so it reports itself from its effect
|
|
238
|
+
// instead and still costs that extra commit.
|
|
239
|
+
function findAdaptConfig(children: React.ReactNode, scope: string): AdaptConfig | null {
|
|
240
|
+
for (const child of React.Children.toArray(children)) {
|
|
241
|
+
if (!React.isValidElement(child)) continue
|
|
242
|
+
|
|
243
|
+
if (child.type === React.Fragment) {
|
|
244
|
+
const found = findAdaptConfig(
|
|
245
|
+
(child.props as { children?: React.ReactNode }).children,
|
|
246
|
+
scope
|
|
247
|
+
)
|
|
248
|
+
if (found) return found
|
|
249
|
+
continue
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (child.type === Adapt) {
|
|
253
|
+
const childProps = child.props as AdaptProps
|
|
254
|
+
if (childProps.scope == null || childProps.scope === scope) {
|
|
255
|
+
return childProps
|
|
239
256
|
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return null
|
|
240
261
|
}
|
|
241
262
|
|
|
242
263
|
export const AdaptParent = ({
|
|
243
264
|
children,
|
|
265
|
+
adaptChildren,
|
|
244
266
|
Contents,
|
|
245
267
|
scope,
|
|
246
268
|
open,
|
|
@@ -255,9 +277,23 @@ export const AdaptParent = ({
|
|
|
255
277
|
slotRef.current = createAdaptSlotStore()
|
|
256
278
|
}
|
|
257
279
|
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
280
|
+
const staticConfig = React.useMemo(
|
|
281
|
+
() => findAdaptConfig(adaptChildren, scope) ?? findAdaptConfig(children, scope),
|
|
282
|
+
[adaptChildren, children, scope]
|
|
283
|
+
)
|
|
284
|
+
const [publishedConfig, setPublishedConfig] = React.useState<AdaptConfig | null>(null)
|
|
285
|
+
const rawActive = useAdaptIsActiveGiven(staticConfig ?? publishedConfig)
|
|
286
|
+
|
|
287
|
+
// written during render because a child's layout effect calls setAdaptConfig
|
|
288
|
+
// before this component's own effects run
|
|
289
|
+
const staticConfigRef = React.useRef(staticConfig)
|
|
290
|
+
staticConfigRef.current = staticConfig
|
|
291
|
+
|
|
292
|
+
const setAdaptConfig = React.useCallback((config: AdaptConfig | null) => {
|
|
293
|
+
if (staticConfigRef.current) return
|
|
294
|
+
setPublishedConfig(config)
|
|
295
|
+
}, [])
|
|
296
|
+
|
|
261
297
|
const [exiting, setExiting] = React.useState(false)
|
|
262
298
|
const [present, setPresent] = React.useState(false)
|
|
263
299
|
const [targetFullyHidden, setTargetFullyHidden] = React.useState(!open)
|
|
@@ -276,13 +312,6 @@ export const AdaptParent = ({
|
|
|
276
312
|
rawActive && wasTargetHiddenRef.current && hasHadActiveTargetRef.current && open
|
|
277
313
|
)
|
|
278
314
|
|
|
279
|
-
rawActiveRef.current = rawActive
|
|
280
|
-
openRef.current = open
|
|
281
|
-
if (rawActive) {
|
|
282
|
-
hasHadActiveTargetRef.current = true
|
|
283
|
-
}
|
|
284
|
-
wasTargetHiddenRef.current = targetHidden
|
|
285
|
-
|
|
286
315
|
const releasePresenceLatch = React.useCallback(() => {
|
|
287
316
|
setExiting(false)
|
|
288
317
|
if (!rawActiveRef.current) {
|
|
@@ -297,6 +326,15 @@ export const AdaptParent = ({
|
|
|
297
326
|
}, [shouldStartExit])
|
|
298
327
|
|
|
299
328
|
useIsomorphicLayoutEffect(() => {
|
|
329
|
+
// committed snapshot: skipNextAnimation compares the next render against
|
|
330
|
+
// these, and onTransition reads them non-reactively
|
|
331
|
+
rawActiveRef.current = rawActive
|
|
332
|
+
openRef.current = open
|
|
333
|
+
if (rawActive) {
|
|
334
|
+
hasHadActiveTargetRef.current = true
|
|
335
|
+
}
|
|
336
|
+
wasTargetHiddenRef.current = targetHidden
|
|
337
|
+
|
|
300
338
|
if (open && rawActive) {
|
|
301
339
|
setTargetFullyHidden(false)
|
|
302
340
|
return
|
|
@@ -308,7 +346,7 @@ export const AdaptParent = ({
|
|
|
308
346
|
if (!open && !active) {
|
|
309
347
|
setTargetFullyHidden(true)
|
|
310
348
|
}
|
|
311
|
-
}, [active, open, rawActive])
|
|
349
|
+
}, [active, open, rawActive, targetHidden])
|
|
312
350
|
|
|
313
351
|
useIsomorphicLayoutEffect(() => {
|
|
314
352
|
if (rawActive) {
|
|
@@ -404,13 +442,8 @@ export const AdaptParent = ({
|
|
|
404
442
|
<LastAdaptContextScope.Provider value={scope}>
|
|
405
443
|
<ProvideAdaptContext
|
|
406
444
|
Contents={FinalContents}
|
|
407
|
-
when={when}
|
|
408
|
-
platform={platform}
|
|
409
|
-
setPlatform={setPlatform}
|
|
410
|
-
setWhen={setWhen}
|
|
411
445
|
active={active}
|
|
412
|
-
|
|
413
|
-
setRawActive={setRawActive}
|
|
446
|
+
setAdaptConfig={setAdaptConfig}
|
|
414
447
|
portalName={portalName}
|
|
415
448
|
scopeName={scope}
|
|
416
449
|
slot={slotRef.current}
|
|
@@ -456,32 +489,29 @@ export const AdaptContents = ({ scope, ...rest }: { scope?: string }) => {
|
|
|
456
489
|
}
|
|
457
490
|
}, [context.active, context.registerContents, context.unregisterContents])
|
|
458
491
|
|
|
459
|
-
// forwards props
|
|
460
|
-
return
|
|
492
|
+
// forwards props
|
|
493
|
+
return (
|
|
494
|
+
<AdaptTargetScope.Provider value={null}>
|
|
495
|
+
{React.createElement(context.Contents, { ...rest, scope, key: `stable` })}
|
|
496
|
+
</AdaptTargetScope.Provider>
|
|
497
|
+
)
|
|
461
498
|
}
|
|
462
499
|
|
|
463
|
-
AdaptContents.shouldForwardSpace = true
|
|
464
|
-
|
|
465
500
|
export const Adapt = withStaticProperties(
|
|
466
501
|
function Adapt(props: AdaptProps) {
|
|
467
|
-
const {
|
|
502
|
+
const { children, platform, scope, when } = props
|
|
468
503
|
const context = useAdaptContext(scope)
|
|
469
|
-
const
|
|
470
|
-
const enabled = rawEnabled || context.active
|
|
504
|
+
const enabled = context.active
|
|
471
505
|
const isRenderCallback = typeof children === 'function'
|
|
472
506
|
|
|
507
|
+
// only reaches the parent when it could not read this element off its own
|
|
508
|
+
// children, i.e. a userland component renders the <Adapt />
|
|
473
509
|
useIsomorphicLayoutEffect(() => {
|
|
474
|
-
context
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
platform,
|
|
480
|
-
rawEnabled,
|
|
481
|
-
context.setWhen,
|
|
482
|
-
context.setPlatform,
|
|
483
|
-
context.setRawActive,
|
|
484
|
-
])
|
|
510
|
+
context.setAdaptConfig({ when, platform })
|
|
511
|
+
return () => {
|
|
512
|
+
context.setAdaptConfig(null)
|
|
513
|
+
}
|
|
514
|
+
}, [when, platform, context.setAdaptConfig])
|
|
485
515
|
|
|
486
516
|
useIsomorphicLayoutEffect(() => {
|
|
487
517
|
if (!enabled || !isRenderCallback) return
|
|
@@ -497,14 +527,6 @@ export const Adapt = withStaticProperties(
|
|
|
497
527
|
context.unregisterRenderCallback,
|
|
498
528
|
])
|
|
499
529
|
|
|
500
|
-
useIsomorphicLayoutEffect(() => {
|
|
501
|
-
return () => {
|
|
502
|
-
context?.setWhen?.(null)
|
|
503
|
-
context?.setPlatform?.(null)
|
|
504
|
-
context?.setRawActive?.(false)
|
|
505
|
-
}
|
|
506
|
-
}, [])
|
|
507
|
-
|
|
508
530
|
let output: React.ReactNode
|
|
509
531
|
|
|
510
532
|
if (isRenderCallback) {
|
|
@@ -514,7 +536,11 @@ export const Adapt = withStaticProperties(
|
|
|
514
536
|
output = children
|
|
515
537
|
}
|
|
516
538
|
|
|
517
|
-
return
|
|
539
|
+
return (
|
|
540
|
+
<AdaptTargetScope.Provider value={context.scopeName}>
|
|
541
|
+
<StackZIndexContext>{!enabled ? null : output}</StackZIndexContext>
|
|
542
|
+
</AdaptTargetScope.Provider>
|
|
543
|
+
)
|
|
518
544
|
},
|
|
519
545
|
{
|
|
520
546
|
Contents: AdaptContents,
|
|
@@ -524,7 +550,6 @@ export const Adapt = withStaticProperties(
|
|
|
524
550
|
export const AdaptPortalContents = (props: {
|
|
525
551
|
children: React.ReactNode
|
|
526
552
|
scope?: string
|
|
527
|
-
passThrough?: boolean
|
|
528
553
|
}) => {
|
|
529
554
|
const isActive = useAdaptIsActive(props.scope)
|
|
530
555
|
const { slot } = useAdaptContext(props.scope)
|
|
@@ -557,19 +582,29 @@ function AdaptSlotPublisher({
|
|
|
557
582
|
slot: AdaptSlotStore | null
|
|
558
583
|
children: React.ReactNode
|
|
559
584
|
}) {
|
|
560
|
-
const publishedRef = React.useRef
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
585
|
+
const publishedRef = React.useRef<{
|
|
586
|
+
isActive: boolean
|
|
587
|
+
element: React.ReactNode
|
|
588
|
+
} | null>(null)
|
|
589
|
+
|
|
590
|
+
// Publish the live element value after every commit. Do not memoize this handoff
|
|
591
|
+
// on a dep array: stale element deps caused the Sheet overlay-hoist regression
|
|
592
|
+
// this replaces. Comparing against what was actually published is safe, and
|
|
593
|
+
// keeps an unchanged element from re-rendering every slot consumer.
|
|
564
594
|
useIsomorphicLayoutEffect(() => {
|
|
565
595
|
if (!slot) return
|
|
566
596
|
|
|
597
|
+
const published = publishedRef.current
|
|
598
|
+
if (published && published.isActive === isActive && published.element === children) {
|
|
599
|
+
return
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
publishedRef.current = { isActive, element: children }
|
|
603
|
+
|
|
567
604
|
if (isActive) {
|
|
568
605
|
slot.publish(children)
|
|
569
|
-
publishedRef.current = true
|
|
570
606
|
} else {
|
|
571
607
|
slot.clear()
|
|
572
|
-
publishedRef.current = false
|
|
573
608
|
}
|
|
574
609
|
|
|
575
610
|
slot.notify()
|
|
@@ -577,11 +612,11 @@ function AdaptSlotPublisher({
|
|
|
577
612
|
|
|
578
613
|
useIsomorphicLayoutEffect(() => {
|
|
579
614
|
return () => {
|
|
580
|
-
if (publishedRef.current) {
|
|
615
|
+
if (publishedRef.current?.isActive) {
|
|
581
616
|
slot?.clear()
|
|
582
617
|
slot?.notify()
|
|
583
|
-
publishedRef.current = false
|
|
584
618
|
}
|
|
619
|
+
publishedRef.current = null
|
|
585
620
|
}
|
|
586
621
|
}, [slot])
|
|
587
622
|
|
|
@@ -591,20 +626,15 @@ function AdaptSlotPublisher({
|
|
|
591
626
|
const emptySubscribe = () => () => {}
|
|
592
627
|
const emptySnapshot = () => 0
|
|
593
628
|
|
|
594
|
-
const useAdaptIsActiveGiven = ({
|
|
595
|
-
when,
|
|
596
|
-
platform,
|
|
597
|
-
}: Pick<AdaptProps, 'when' | 'platform'>) => {
|
|
629
|
+
const useAdaptIsActiveGiven = (config: AdaptConfig | null) => {
|
|
598
630
|
const media = useMedia()
|
|
631
|
+
const when = config?.when
|
|
632
|
+
const platform = config?.platform
|
|
599
633
|
|
|
600
634
|
if (when == null && platform == null) {
|
|
601
635
|
return false
|
|
602
636
|
}
|
|
603
637
|
|
|
604
|
-
if (when === true) {
|
|
605
|
-
return true
|
|
606
|
-
}
|
|
607
|
-
|
|
608
638
|
let enabled = false
|
|
609
639
|
|
|
610
640
|
if (platform === 'touch') enabled = isTouchable
|
|
@@ -613,10 +643,15 @@ const useAdaptIsActiveGiven = ({
|
|
|
613
643
|
else if (platform === 'ios') enabled = isIos
|
|
614
644
|
else if (platform === 'android') enabled = isAndroid
|
|
615
645
|
|
|
646
|
+
// platform narrows every `when`, including `when={true}`
|
|
616
647
|
if (platform && enabled == false) {
|
|
617
648
|
return false
|
|
618
649
|
}
|
|
619
650
|
|
|
651
|
+
if (when === true) {
|
|
652
|
+
return true
|
|
653
|
+
}
|
|
654
|
+
|
|
620
655
|
if (when && typeof when === 'string') {
|
|
621
656
|
enabled = media[when]
|
|
622
657
|
}
|
|
@@ -625,26 +660,26 @@ const useAdaptIsActiveGiven = ({
|
|
|
625
660
|
}
|
|
626
661
|
|
|
627
662
|
export const useAdaptIsActive = (scope?: string) => {
|
|
628
|
-
|
|
629
|
-
const isActiveGiven = useAdaptIsActiveGiven(props)
|
|
630
|
-
return props.active || isActiveGiven
|
|
663
|
+
return useAdaptContext(scope).active
|
|
631
664
|
}
|
|
632
665
|
|
|
633
666
|
export function useAdaptTarget<State = unknown>(
|
|
634
667
|
scope?: string
|
|
635
668
|
): AdaptTarget<State> | null {
|
|
636
669
|
const context = useAdaptContext(scope)
|
|
670
|
+
const targetScope = useAdaptTargetScope()
|
|
671
|
+
const isTarget = scope !== undefined || targetScope === context.scopeName
|
|
637
672
|
|
|
638
673
|
useIsomorphicLayoutEffect(() => {
|
|
639
|
-
if (!context.active) return
|
|
674
|
+
if (!context.active || !isTarget) return
|
|
640
675
|
|
|
641
676
|
context.registerTarget()
|
|
642
677
|
return () => {
|
|
643
678
|
context.unregisterTarget()
|
|
644
679
|
}
|
|
645
|
-
}, [context.active, context.registerTarget, context.unregisterTarget])
|
|
680
|
+
}, [context.active, context.registerTarget, context.unregisterTarget, isTarget])
|
|
646
681
|
|
|
647
|
-
if (!context.active) {
|
|
682
|
+
if (!context.active || !isTarget) {
|
|
648
683
|
return null
|
|
649
684
|
}
|
|
650
685
|
|
|
@@ -656,6 +691,12 @@ export function useAdaptTarget<State = unknown>(
|
|
|
656
691
|
}
|
|
657
692
|
}
|
|
658
693
|
|
|
694
|
+
// lets an adapt target declare what its container already provides, so content
|
|
695
|
+
// need not double up on it. currently write-only: Sheet declares all three when
|
|
696
|
+
// it is the target, but nothing reads them back. Dialog.Overlay, Dialog.Close
|
|
697
|
+
// and Select instead check useAdaptIsActive() directly, which assumes the
|
|
698
|
+
// target is a Sheet. reading capabilities there is what would make a non-Sheet
|
|
699
|
+
// target (the render callback, or a custom useAdaptTarget container) correct.
|
|
659
700
|
export const AdaptCapabilities = ({
|
|
660
701
|
children,
|
|
661
702
|
scroll,
|
package/types/Adapt.d.ts
CHANGED
|
@@ -35,16 +35,12 @@ export type AdaptTarget<State = unknown> = {
|
|
|
35
35
|
handoff: AdaptTargetHandoff;
|
|
36
36
|
state: State;
|
|
37
37
|
};
|
|
38
|
+
export type AdaptConfig = Pick<AdaptProps, 'when' | 'platform'>;
|
|
38
39
|
export type AdaptParentContextI = {
|
|
39
40
|
Contents: Component;
|
|
40
41
|
scopeName: string;
|
|
41
|
-
platform: AdaptPlatform;
|
|
42
|
-
setPlatform: (when: AdaptPlatform) => any;
|
|
43
|
-
when: AdaptWhen;
|
|
44
|
-
setWhen: (when: AdaptWhen) => any;
|
|
45
42
|
active: boolean;
|
|
46
|
-
|
|
47
|
-
setRawActive: (active: boolean) => void;
|
|
43
|
+
setAdaptConfig: (config: AdaptConfig | null) => void;
|
|
48
44
|
portalName?: string;
|
|
49
45
|
lastScope?: string;
|
|
50
46
|
slot: AdaptSlotStore | null;
|
|
@@ -75,7 +71,8 @@ export type AdaptProps = {
|
|
|
75
71
|
children: React.JSX.Element | ((contents: React.ReactNode, adapt: AdaptRenderState) => React.ReactNode);
|
|
76
72
|
};
|
|
77
73
|
type Component = (props: any) => any;
|
|
78
|
-
export declare const AdaptContext: import("@tamagui/core").StyledContext<AdaptParentContextI, "Contents" | "active" | "handoff" | "
|
|
74
|
+
export declare const AdaptContext: import("@tamagui/core").StyledContext<AdaptParentContextI, "Contents" | "active" | "handoff" | "portalName" | "registerContents" | "registerRenderCallback" | "registerTarget" | "scopeName" | "setAdaptConfig" | "slot" | "targetFullyHidden" | "unregisterContents" | "unregisterRenderCallback" | "unregisterTarget">;
|
|
75
|
+
export declare const useAdaptTargetScope: () => string | null;
|
|
79
76
|
export declare const ProvideAdaptContext: ({ children, ...context }: AdaptParentContextI & {
|
|
80
77
|
children: any;
|
|
81
78
|
}) => React.JSX.Element;
|
|
@@ -85,29 +82,26 @@ export declare const useAdaptContext: (scope?: string) => AdaptParentContextI;
|
|
|
85
82
|
*/
|
|
86
83
|
type AdaptParentProps = {
|
|
87
84
|
children?: React.ReactNode;
|
|
85
|
+
adaptChildren?: React.ReactNode;
|
|
88
86
|
Contents?: AdaptParentContextI['Contents'];
|
|
89
87
|
scope: string;
|
|
90
88
|
open?: boolean;
|
|
91
89
|
onOpenChange?: (open: boolean) => void;
|
|
92
90
|
state?: unknown;
|
|
93
|
-
portal?: boolean | {
|
|
94
|
-
forwardProps?: any;
|
|
95
|
-
};
|
|
96
91
|
};
|
|
97
|
-
export declare const AdaptParent: ({ children, Contents, scope, open, onOpenChange, state, }: AdaptParentProps) => React.JSX.Element;
|
|
98
|
-
|
|
92
|
+
export declare const AdaptParent: ({ children, adaptChildren, Contents, scope, open, onOpenChange, state, }: AdaptParentProps) => React.JSX.Element;
|
|
93
|
+
/**
|
|
94
|
+
* Components
|
|
95
|
+
*/
|
|
96
|
+
export declare const AdaptContents: ({ scope, ...rest }: {
|
|
99
97
|
scope?: string;
|
|
100
|
-
})
|
|
101
|
-
export declare namespace AdaptContents {
|
|
102
|
-
var shouldForwardSpace: boolean;
|
|
103
|
-
}
|
|
98
|
+
}) => React.JSX.Element;
|
|
104
99
|
export declare const Adapt: ((props: AdaptProps) => React.JSX.Element) & {
|
|
105
100
|
Contents: typeof AdaptContents;
|
|
106
101
|
};
|
|
107
102
|
export declare const AdaptPortalContents: (props: {
|
|
108
103
|
children: React.ReactNode;
|
|
109
104
|
scope?: string;
|
|
110
|
-
passThrough?: boolean;
|
|
111
105
|
}) => React.JSX.Element;
|
|
112
106
|
export declare const useAdaptIsActive: (scope?: string) => boolean;
|
|
113
107
|
export declare function useAdaptTarget<State = unknown>(scope?: string): AdaptTarget<State> | null;
|
package/types/Adapt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapt.d.ts","sourceRoot":"","sources":["../src/Adapt.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,E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