@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.
@@ -38,13 +38,8 @@ const adaptContextKeys = [
38
38
  "Contents",
39
39
  "scopeName",
40
40
  "portalName",
41
- "platform",
42
- "setPlatform",
43
- "when",
44
- "setWhen",
45
41
  "active",
46
- "rawActive",
47
- "setRawActive",
42
+ "setAdaptConfig",
48
43
  "slot",
49
44
  "handoff",
50
45
  "targetFullyHidden",
@@ -59,13 +54,8 @@ const AdaptContext = createStyledContext({
59
54
  Contents: null,
60
55
  scopeName: "",
61
56
  portalName: "",
62
- platform: null,
63
- setPlatform: (x) => {},
64
- when: null,
65
- setWhen: () => {},
66
57
  active: false,
67
- rawActive: false,
68
- setRawActive: () => {},
58
+ setAdaptConfig: () => {},
69
59
  slot: null,
70
60
  handoff: {
71
61
  hidden: true,
@@ -81,6 +71,8 @@ const AdaptContext = createStyledContext({
81
71
  }, { keys: adaptContextKeys });
82
72
  const AdaptCapabilitiesContext = createContext({});
83
73
  const LastAdaptContextScope = createContext("");
74
+ const AdaptTargetScope = createContext(null);
75
+ const useAdaptTargetScope = () => useContext(AdaptTargetScope);
84
76
  const ProvideAdaptContext = ({ children, ...context }) => {
85
77
  const scope = context.scopeName || "";
86
78
  const lastScope = useContext(LastAdaptContextScope);
@@ -99,16 +91,43 @@ const useAdaptContext = (scope) => {
99
91
  const adaptScope = scope ?? lastScope;
100
92
  return AdaptContext.useStyledContext(adaptScope);
101
93
  };
102
- const AdaptParent = ({ children, Contents, scope, open, onOpenChange, state }) => {
94
+ function findAdaptConfig(children, scope) {
95
+ for (const child of React.Children.toArray(children)) {
96
+ if (!React.isValidElement(child)) continue;
97
+ if (child.type === React.Fragment) {
98
+ const found = findAdaptConfig(child.props.children, scope);
99
+ if (found) return found;
100
+ continue;
101
+ }
102
+ if (child.type === Adapt) {
103
+ const childProps = child.props;
104
+ if (childProps.scope == null || childProps.scope === scope) {
105
+ return childProps;
106
+ }
107
+ }
108
+ }
109
+ return null;
110
+ }
111
+ const AdaptParent = ({ children, adaptChildren, Contents, scope, open, onOpenChange, state }) => {
103
112
  const id = useId();
104
113
  const portalName = `AdaptPortal${scope}${id}`;
105
114
  const slotRef = React.useRef(null);
106
115
  if (!slotRef.current) {
107
116
  slotRef.current = createAdaptSlotStore();
108
117
  }
109
- const [when, setWhen] = React.useState(null);
110
- const [platform, setPlatform] = React.useState(null);
111
- const [rawActive, setRawActive] = React.useState(false);
118
+ const staticConfig = React.useMemo(() => findAdaptConfig(adaptChildren, scope) ?? findAdaptConfig(children, scope), [
119
+ adaptChildren,
120
+ children,
121
+ scope
122
+ ]);
123
+ const [publishedConfig, setPublishedConfig] = React.useState(null);
124
+ const rawActive = useAdaptIsActiveGiven(staticConfig ?? publishedConfig);
125
+ const staticConfigRef = React.useRef(staticConfig);
126
+ staticConfigRef.current = staticConfig;
127
+ const setAdaptConfig = React.useCallback((config) => {
128
+ if (staticConfigRef.current) return;
129
+ setPublishedConfig(config);
130
+ }, []);
112
131
  const [exiting, setExiting] = React.useState(false);
113
132
  const [present, setPresent] = React.useState(false);
114
133
  const [targetFullyHidden, setTargetFullyHidden] = React.useState(!open);
@@ -123,12 +142,6 @@ const AdaptParent = ({ children, Contents, scope, open, onOpenChange, state }) =
123
142
  const active = rawActive || exiting || shouldStartExit;
124
143
  const targetHidden = !rawActive;
125
144
  const skipNextAnimation = Boolean(rawActive && wasTargetHiddenRef.current && hasHadActiveTargetRef.current && open);
126
- rawActiveRef.current = rawActive;
127
- openRef.current = open;
128
- if (rawActive) {
129
- hasHadActiveTargetRef.current = true;
130
- }
131
- wasTargetHiddenRef.current = targetHidden;
132
145
  const releasePresenceLatch = React.useCallback(() => {
133
146
  setExiting(false);
134
147
  if (!rawActiveRef.current) {
@@ -141,6 +154,12 @@ const AdaptParent = ({ children, Contents, scope, open, onOpenChange, state }) =
141
154
  }
142
155
  }, [shouldStartExit]);
143
156
  useIsomorphicLayoutEffect(() => {
157
+ rawActiveRef.current = rawActive;
158
+ openRef.current = open;
159
+ if (rawActive) {
160
+ hasHadActiveTargetRef.current = true;
161
+ }
162
+ wasTargetHiddenRef.current = targetHidden;
144
163
  if (open && rawActive) {
145
164
  setTargetFullyHidden(false);
146
165
  return;
@@ -151,7 +170,8 @@ const AdaptParent = ({ children, Contents, scope, open, onOpenChange, state }) =
151
170
  }, [
152
171
  active,
153
172
  open,
154
- rawActive
173
+ rawActive,
174
+ targetHidden
155
175
  ]);
156
176
  useIsomorphicLayoutEffect(() => {
157
177
  if (rawActive) {
@@ -224,13 +244,8 @@ const AdaptParent = ({ children, Contents, scope, open, onOpenChange, state }) =
224
244
  value: scope,
225
245
  children: /* @__PURE__ */ jsx(ProvideAdaptContext, {
226
246
  Contents: FinalContents,
227
- when,
228
- platform,
229
- setPlatform,
230
- setWhen,
231
247
  active,
232
- rawActive,
233
- setRawActive,
248
+ setAdaptConfig,
234
249
  portalName,
235
250
  scopeName: scope,
236
251
  slot: slotRef.current,
@@ -265,30 +280,32 @@ const AdaptContents = ({ scope, ...rest }) => {
265
280
  context.registerContents,
266
281
  context.unregisterContents
267
282
  ]);
268
- return React.createElement(context.Contents, {
269
- ...rest,
270
- scope,
271
- key: `stable`
283
+ return /* @__PURE__ */ jsx(AdaptTargetScope.Provider, {
284
+ value: null,
285
+ children: React.createElement(context.Contents, {
286
+ ...rest,
287
+ scope,
288
+ key: `stable`
289
+ })
272
290
  });
273
291
  };
274
- AdaptContents.shouldForwardSpace = true;
275
292
  const Adapt = withStaticProperties(function Adapt2(props) {
276
- const { platform, when, children, scope } = props;
293
+ const { children, platform, scope, when } = props;
277
294
  const context = useAdaptContext(scope);
278
- const rawEnabled = useAdaptIsActiveGiven(props);
279
- const enabled = rawEnabled || context.active;
295
+ const enabled = context.active;
280
296
  const isRenderCallback = typeof children === "function";
281
297
  useIsomorphicLayoutEffect(() => {
282
- context?.setWhen?.(when || rawEnabled);
283
- context?.setPlatform?.(platform || null);
284
- context?.setRawActive?.(rawEnabled);
298
+ context.setAdaptConfig({
299
+ when,
300
+ platform
301
+ });
302
+ return () => {
303
+ context.setAdaptConfig(null);
304
+ };
285
305
  }, [
286
306
  when,
287
307
  platform,
288
- rawEnabled,
289
- context.setWhen,
290
- context.setPlatform,
291
- context.setRawActive
308
+ context.setAdaptConfig
292
309
  ]);
293
310
  useIsomorphicLayoutEffect(() => {
294
311
  if (!enabled || !isRenderCallback) return;
@@ -302,13 +319,6 @@ const Adapt = withStaticProperties(function Adapt2(props) {
302
319
  context.registerRenderCallback,
303
320
  context.unregisterRenderCallback
304
321
  ]);
305
- useIsomorphicLayoutEffect(() => {
306
- return () => {
307
- context?.setWhen?.(null);
308
- context?.setPlatform?.(null);
309
- context?.setRawActive?.(false);
310
- };
311
- }, []);
312
322
  let output;
313
323
  if (isRenderCallback) {
314
324
  const Component = context?.Contents;
@@ -316,7 +326,10 @@ const Adapt = withStaticProperties(function Adapt2(props) {
316
326
  } else {
317
327
  output = children;
318
328
  }
319
- return /* @__PURE__ */ jsx(StackZIndexContext, { children: !enabled ? null : output });
329
+ return /* @__PURE__ */ jsx(AdaptTargetScope.Provider, {
330
+ value: context.scopeName,
331
+ children: /* @__PURE__ */ jsx(StackZIndexContext, { children: !enabled ? null : output })
332
+ });
320
333
  }, { Contents: AdaptContents });
321
334
  const AdaptPortalContents = (props) => {
322
335
  const isActive = useAdaptIsActive(props.scope);
@@ -333,39 +346,44 @@ function AdaptSlotContents({ scope }) {
333
346
  return /* @__PURE__ */ jsx(Fragment, { children: slot?.element ?? null });
334
347
  }
335
348
  function AdaptSlotPublisher({ isActive, slot, children }) {
336
- const publishedRef = React.useRef(false);
349
+ const publishedRef = React.useRef(null);
337
350
  useIsomorphicLayoutEffect(() => {
338
351
  if (!slot) return;
352
+ const published = publishedRef.current;
353
+ if (published && published.isActive === isActive && published.element === children) {
354
+ return;
355
+ }
356
+ publishedRef.current = {
357
+ isActive,
358
+ element: children
359
+ };
339
360
  if (isActive) {
340
361
  slot.publish(children);
341
- publishedRef.current = true;
342
362
  } else {
343
363
  slot.clear();
344
- publishedRef.current = false;
345
364
  }
346
365
  slot.notify();
347
366
  });
348
367
  useIsomorphicLayoutEffect(() => {
349
368
  return () => {
350
- if (publishedRef.current) {
369
+ if (publishedRef.current?.isActive) {
351
370
  slot?.clear();
352
371
  slot?.notify();
353
- publishedRef.current = false;
354
372
  }
373
+ publishedRef.current = null;
355
374
  };
356
375
  }, [slot]);
357
376
  return isActive ? null : /* @__PURE__ */ jsx(Fragment, { children });
358
377
  }
359
378
  const emptySubscribe = () => () => {};
360
379
  const emptySnapshot = () => 0;
361
- const useAdaptIsActiveGiven = ({ when, platform }) => {
380
+ const useAdaptIsActiveGiven = (config) => {
362
381
  const media = useMedia();
382
+ const when = config?.when;
383
+ const platform = config?.platform;
363
384
  if (when == null && platform == null) {
364
385
  return false;
365
386
  }
366
- if (when === true) {
367
- return true;
368
- }
369
387
  let enabled = false;
370
388
  if (platform === "touch") enabled = isTouchable;
371
389
  else if (platform === "native") enabled = !isWeb;
@@ -375,20 +393,23 @@ const useAdaptIsActiveGiven = ({ when, platform }) => {
375
393
  if (platform && enabled == false) {
376
394
  return false;
377
395
  }
396
+ if (when === true) {
397
+ return true;
398
+ }
378
399
  if (when && typeof when === "string") {
379
400
  enabled = media[when];
380
401
  }
381
402
  return enabled;
382
403
  };
383
404
  const useAdaptIsActive = (scope) => {
384
- const props = useAdaptContext(scope);
385
- const isActiveGiven = useAdaptIsActiveGiven(props);
386
- return props.active || isActiveGiven;
405
+ return useAdaptContext(scope).active;
387
406
  };
388
407
  function useAdaptTarget(scope) {
389
408
  const context = useAdaptContext(scope);
409
+ const targetScope = useAdaptTargetScope();
410
+ const isTarget = scope !== void 0 || targetScope === context.scopeName;
390
411
  useIsomorphicLayoutEffect(() => {
391
- if (!context.active) return;
412
+ if (!context.active || !isTarget) return;
392
413
  context.registerTarget();
393
414
  return () => {
394
415
  context.unregisterTarget();
@@ -396,9 +417,10 @@ function useAdaptTarget(scope) {
396
417
  }, [
397
418
  context.active,
398
419
  context.registerTarget,
399
- context.unregisterTarget
420
+ context.unregisterTarget,
421
+ isTarget
400
422
  ]);
401
- if (!context.active) {
423
+ if (!context.active || !isTarget) {
402
424
  return null;
403
425
  }
404
426
  return {
@@ -440,5 +462,5 @@ function getAdaptRenderState(context) {
440
462
  };
441
463
  }
442
464
 
443
- export { Adapt, AdaptCapabilities, AdaptContents, AdaptContext, AdaptParent, AdaptPortalContents, ProvideAdaptContext, useAdaptContext, useAdaptIsActive, useAdaptTarget, useAdaptedCapabilities };
465
+ export { Adapt, AdaptCapabilities, AdaptContents, AdaptContext, AdaptParent, AdaptPortalContents, ProvideAdaptContext, useAdaptContext, useAdaptIsActive, useAdaptTarget, useAdaptTargetScope, useAdaptedCapabilities };
444
466
  //# sourceMappingURL=Adapt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Adapt.js","names":[],"sources":["esm/Adapt.js"],"sourcesContent":["import {\n isAndroid,\n isIos,\n isTouchable,\n isWeb,\n useIsomorphicLayoutEffect\n} from \"@tamagui/constants\";\nimport { createStyledContext, useMedia } from \"@tamagui/core\";\nimport { withStaticProperties } from \"@tamagui/helpers\";\nimport { StackZIndexContext } from \"@tamagui/z-index-stack\";\nimport React, { createContext, useContext, useId } from \"react\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nfunction createAdaptSlotStore() {\n const listeners = /* @__PURE__ */ new Set();\n const store = {\n element: null,\n version: 0,\n publish(element) {\n store.element = element;\n },\n clear() {\n store.element = null;\n },\n notify() {\n store.version += 1;\n for (const listener of listeners) {\n listener();\n }\n },\n getSnapshot() {\n return store.version;\n },\n subscribe(callback) {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }\n };\n return store;\n}\nconst adaptContextKeys = [\n \"Contents\",\n \"scopeName\",\n \"portalName\",\n \"platform\",\n \"setPlatform\",\n \"when\",\n \"setWhen\",\n \"active\",\n \"rawActive\",\n \"setRawActive\",\n \"slot\",\n \"handoff\",\n \"targetFullyHidden\",\n \"registerTarget\",\n \"unregisterTarget\",\n \"registerContents\",\n \"unregisterContents\",\n \"registerRenderCallback\",\n \"unregisterRenderCallback\"\n];\nconst AdaptContext = createStyledContext(\n {\n Contents: null,\n scopeName: \"\",\n portalName: \"\",\n platform: null,\n setPlatform: (x) => {\n },\n when: null,\n setWhen: () => {\n },\n active: false,\n rawActive: false,\n setRawActive: () => {\n },\n slot: null,\n handoff: {\n hidden: true,\n onTransition: () => {\n }\n },\n targetFullyHidden: true,\n registerTarget: () => {\n },\n unregisterTarget: () => {\n },\n registerContents: () => {\n },\n unregisterContents: () => {\n },\n registerRenderCallback: () => {\n },\n unregisterRenderCallback: () => {\n }\n },\n {\n keys: adaptContextKeys\n }\n);\nconst AdaptCapabilitiesContext = createContext({});\nconst LastAdaptContextScope = createContext(\"\");\nconst ProvideAdaptContext = ({\n children,\n ...context\n}) => {\n const scope = context.scopeName || \"\";\n const lastScope = useContext(LastAdaptContextScope);\n return /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: lastScope || context.lastScope || \"\", children: /* @__PURE__ */ jsx(\n AdaptContext.Provider,\n {\n scope,\n lastScope: lastScope || context.lastScope,\n ...context,\n children\n }\n ) });\n};\nconst useAdaptContext = (scope) => {\n const lastScope = useContext(LastAdaptContextScope);\n const adaptScope = scope ?? lastScope;\n return AdaptContext.useStyledContext(adaptScope);\n};\nconst AdaptParent = ({\n children,\n Contents,\n scope,\n open,\n onOpenChange,\n state\n}) => {\n const id = useId();\n const portalName = `AdaptPortal${scope}${id}`;\n const slotRef = React.useRef(null);\n if (!slotRef.current) {\n slotRef.current = createAdaptSlotStore();\n }\n const [when, setWhen] = React.useState(null);\n const [platform, setPlatform] = React.useState(null);\n const [rawActive, setRawActive] = React.useState(false);\n const [exiting, setExiting] = React.useState(false);\n const [present, setPresent] = React.useState(false);\n const [targetFullyHidden, setTargetFullyHidden] = React.useState(!open);\n const targetCountRef = React.useRef(0);\n const contentsCountRef = React.useRef(0);\n const renderCallbackCountRef = React.useRef(0);\n const rawActiveRef = React.useRef(false);\n const openRef = React.useRef(open);\n const wasTargetHiddenRef = React.useRef(!rawActive);\n const hasHadActiveTargetRef = React.useRef(false);\n const shouldStartExit = !rawActive && present && Boolean(open);\n const active = rawActive || exiting || shouldStartExit;\n const targetHidden = !rawActive;\n const skipNextAnimation = Boolean(\n rawActive && wasTargetHiddenRef.current && hasHadActiveTargetRef.current && open\n );\n rawActiveRef.current = rawActive;\n openRef.current = open;\n if (rawActive) {\n hasHadActiveTargetRef.current = true;\n }\n wasTargetHiddenRef.current = targetHidden;\n const releasePresenceLatch = React.useCallback(() => {\n setExiting(false);\n if (!rawActiveRef.current) {\n setPresent(false);\n }\n }, []);\n useIsomorphicLayoutEffect(() => {\n if (shouldStartExit) {\n setExiting(true);\n }\n }, [shouldStartExit]);\n useIsomorphicLayoutEffect(() => {\n if (open && rawActive) {\n setTargetFullyHidden(false);\n return;\n }\n if (!open && !active) {\n setTargetFullyHidden(true);\n }\n }, [active, open, rawActive]);\n useIsomorphicLayoutEffect(() => {\n if (rawActive) {\n setPresent(true);\n } else if (!active) {\n setPresent(false);\n }\n if (rawActive && exiting) {\n setExiting(false);\n }\n }, [active, exiting, rawActive]);\n const handoff = React.useMemo(\n () => ({\n hidden: targetHidden,\n skipNextAnimation,\n onTransition(e) {\n if (e.phase !== \"end\" || e.finished === false) return;\n if (e.cause !== \"close\") {\n setTargetFullyHidden(false);\n return;\n }\n if (openRef.current && rawActiveRef.current) {\n setTargetFullyHidden(false);\n return;\n }\n setTargetFullyHidden(true);\n releasePresenceLatch();\n }\n }),\n [releasePresenceLatch, skipNextAnimation, targetHidden]\n );\n const registerTarget = React.useCallback(() => {\n targetCountRef.current += 1;\n if (process.env.NODE_ENV === \"development\" && targetCountRef.current > 1) {\n console.error(\n `Adapt expected exactly one target in scope \"${scope}\", but ${targetCountRef.current} targets registered.`\n );\n }\n }, [scope]);\n const unregisterTarget = React.useCallback(() => {\n targetCountRef.current = Math.max(0, targetCountRef.current - 1);\n }, []);\n const registerContents = React.useCallback(() => {\n contentsCountRef.current += 1;\n }, []);\n const unregisterContents = React.useCallback(() => {\n contentsCountRef.current = Math.max(0, contentsCountRef.current - 1);\n }, []);\n const registerRenderCallback = React.useCallback(() => {\n renderCallbackCountRef.current += 1;\n }, []);\n const unregisterRenderCallback = React.useCallback(() => {\n renderCallbackCountRef.current = Math.max(0, renderCallbackCountRef.current - 1);\n }, []);\n React.useEffect(() => {\n if (process.env.NODE_ENV !== \"development\") return;\n if (!active) return;\n const timer = setTimeout(() => {\n if (rawActiveRef.current && targetCountRef.current === 0 && contentsCountRef.current === 0 && renderCallbackCountRef.current === 0) {\n console.error(\n `Adapt is active in scope \"${scope}\" but no target registered with useAdaptTarget(), Adapt.Contents marker, or render callback consumed it.`\n );\n }\n });\n return () => clearTimeout(timer);\n }, [active, scope]);\n const FinalContents = Contents || AdaptSlotContents;\n return /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: scope, children: /* @__PURE__ */ jsx(\n ProvideAdaptContext,\n {\n Contents: FinalContents,\n when,\n platform,\n setPlatform,\n setWhen,\n active,\n rawActive,\n setRawActive,\n portalName,\n scopeName: scope,\n slot: slotRef.current,\n open,\n onOpenChange,\n state,\n handoff,\n targetFullyHidden,\n registerTarget,\n unregisterTarget,\n registerContents,\n unregisterContents,\n registerRenderCallback,\n unregisterRenderCallback,\n children\n }\n ) });\n};\nconst AdaptContents = ({ scope, ...rest }) => {\n const context = useAdaptContext(scope);\n if (!context?.Contents) {\n throw new Error(\n process.env.NODE_ENV === \"production\" ? `tamagui.dev/docs/intro/errors#warning-002` : `You're rendering a Tamagui <Adapt /> component without nesting it inside a parent that is able to adapt.`\n );\n }\n useIsomorphicLayoutEffect(() => {\n if (!context.active) return;\n context.registerContents();\n return () => {\n context.unregisterContents();\n };\n }, [context.active, context.registerContents, context.unregisterContents]);\n return React.createElement(context.Contents, { ...rest, scope, key: `stable` });\n};\nAdaptContents.shouldForwardSpace = true;\nconst Adapt = withStaticProperties(\n function Adapt2(props) {\n const { platform, when, children, scope } = props;\n const context = useAdaptContext(scope);\n const rawEnabled = useAdaptIsActiveGiven(props);\n const enabled = rawEnabled || context.active;\n const isRenderCallback = typeof children === \"function\";\n useIsomorphicLayoutEffect(() => {\n context?.setWhen?.(when || rawEnabled);\n context?.setPlatform?.(platform || null);\n context?.setRawActive?.(rawEnabled);\n }, [\n when,\n platform,\n rawEnabled,\n context.setWhen,\n context.setPlatform,\n context.setRawActive\n ]);\n useIsomorphicLayoutEffect(() => {\n if (!enabled || !isRenderCallback) return;\n context.registerRenderCallback();\n return () => {\n context.unregisterRenderCallback();\n };\n }, [\n enabled,\n isRenderCallback,\n context.registerRenderCallback,\n context.unregisterRenderCallback\n ]);\n useIsomorphicLayoutEffect(() => {\n return () => {\n context?.setWhen?.(null);\n context?.setPlatform?.(null);\n context?.setRawActive?.(false);\n };\n }, []);\n let output;\n if (isRenderCallback) {\n const Component = context?.Contents;\n output = children(Component ? /* @__PURE__ */ jsx(Component, {}) : null, getAdaptRenderState(context));\n } else {\n output = children;\n }\n return /* @__PURE__ */ jsx(StackZIndexContext, { children: !enabled ? null : output });\n },\n {\n Contents: AdaptContents\n }\n);\nconst AdaptPortalContents = (props) => {\n const isActive = useAdaptIsActive(props.scope);\n const { slot } = useAdaptContext(props.scope);\n return /* @__PURE__ */ jsx(AdaptSlotPublisher, { isActive, slot, children: props.children });\n};\nfunction AdaptSlotContents({ scope }) {\n const { slot } = useAdaptContext(scope);\n React.useSyncExternalStore(\n slot?.subscribe ?? emptySubscribe,\n slot?.getSnapshot ?? emptySnapshot,\n slot?.getSnapshot ?? emptySnapshot\n );\n return /* @__PURE__ */ jsx(Fragment, { children: slot?.element ?? null });\n}\nfunction AdaptSlotPublisher({\n isActive,\n slot,\n children\n}) {\n const publishedRef = React.useRef(false);\n useIsomorphicLayoutEffect(() => {\n if (!slot) return;\n if (isActive) {\n slot.publish(children);\n publishedRef.current = true;\n } else {\n slot.clear();\n publishedRef.current = false;\n }\n slot.notify();\n });\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (publishedRef.current) {\n slot?.clear();\n slot?.notify();\n publishedRef.current = false;\n }\n };\n }, [slot]);\n return isActive ? null : /* @__PURE__ */ jsx(Fragment, { children });\n}\nconst emptySubscribe = () => () => {\n};\nconst emptySnapshot = () => 0;\nconst useAdaptIsActiveGiven = ({\n when,\n platform\n}) => {\n const media = useMedia();\n if (when == null && platform == null) {\n return false;\n }\n if (when === true) {\n return true;\n }\n let enabled = false;\n if (platform === \"touch\") enabled = isTouchable;\n else if (platform === \"native\") enabled = !isWeb;\n else if (platform === \"web\") enabled = isWeb;\n else if (platform === \"ios\") enabled = isIos;\n else if (platform === \"android\") enabled = isAndroid;\n if (platform && enabled == false) {\n return false;\n }\n if (when && typeof when === \"string\") {\n enabled = media[when];\n }\n return enabled;\n};\nconst useAdaptIsActive = (scope) => {\n const props = useAdaptContext(scope);\n const isActiveGiven = useAdaptIsActiveGiven(props);\n return props.active || isActiveGiven;\n};\nfunction useAdaptTarget(scope) {\n const context = useAdaptContext(scope);\n useIsomorphicLayoutEffect(() => {\n if (!context.active) return;\n context.registerTarget();\n return () => {\n context.unregisterTarget();\n };\n }, [context.active, context.registerTarget, context.unregisterTarget]);\n if (!context.active) {\n return null;\n }\n return {\n open: context.open,\n onOpenChange: context.onOpenChange,\n handoff: context.handoff,\n state: context.state\n };\n}\nconst AdaptCapabilities = ({\n children,\n scroll,\n overlay,\n dismiss\n}) => {\n const parent = useContext(AdaptCapabilitiesContext);\n const value = React.useMemo(\n () => ({\n scroll: scroll ?? parent.scroll,\n overlay: overlay ?? parent.overlay,\n dismiss: dismiss ?? parent.dismiss\n }),\n [dismiss, overlay, parent.dismiss, parent.overlay, parent.scroll, scroll]\n );\n return /* @__PURE__ */ jsx(AdaptCapabilitiesContext.Provider, { value, children });\n};\nconst useAdaptedCapabilities = () => {\n return useContext(AdaptCapabilitiesContext);\n};\nfunction getAdaptRenderState(context) {\n return {\n active: context.active,\n open: context.open,\n onOpenChange: context.onOpenChange,\n state: context.state,\n handoff: context.handoff\n };\n}\nexport {\n Adapt,\n AdaptCapabilities,\n AdaptContents,\n AdaptContext,\n AdaptParent,\n AdaptPortalContents,\n ProvideAdaptContext,\n useAdaptContext,\n useAdaptIsActive,\n useAdaptTarget,\n useAdaptedCapabilities\n};\n//# sourceMappingURL=Adapt.js.map\n"],"mappings":";;;;;;;;AAYA,SAAS,uBAAuB;CAC9B,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,QAAQ;EACZ,SAAS;EACT,SAAS;EACT,QAAQ,SAAS;GACf,MAAM,UAAU;EAClB;EACA,QAAQ;GACN,MAAM,UAAU;EAClB;EACA,SAAS;GACP,MAAM,WAAW;GACjB,KAAK,MAAM,YAAY,WAAW;IAChC,SAAS;GACX;EACF;EACA,cAAc;GACZ,OAAO,MAAM;EACf;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;CACF;CACA,OAAO;AACT;AACA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,eAAe,oBACnB;CACE,UAAU;CACV,WAAW;CACX,YAAY;CACZ,UAAU;CACV,cAAc,MAAM,CACpB;CACA,MAAM;CACN,eAAe,CACf;CACA,QAAQ;CACR,WAAW;CACX,oBAAoB,CACpB;CACA,MAAM;CACN,SAAS;EACP,QAAQ;EACR,oBAAoB,CACpB;CACF;CACA,mBAAmB;CACnB,sBAAsB,CACtB;CACA,wBAAwB,CACxB;CACA,wBAAwB,CACxB;CACA,0BAA0B,CAC1B;CACA,8BAA8B,CAC9B;CACA,gCAAgC,CAChC;AACF,GACA,EACE,MAAM,iBACR,CACF;AACA,MAAM,2BAA2B,cAAc,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AAO;EACL,QAAQ,QAAQ;EAChB,MAAM,QAAQ;EACd,cAAc,QAAQ;EACtB,OAAO,QAAQ;EACf,SAAS,QAAQ;CACnB;AACF"}
1
+ {"version":3,"file":"Adapt.js","names":[],"sources":["esm/Adapt.js"],"sourcesContent":["import {\n isAndroid,\n isIos,\n isTouchable,\n isWeb,\n useIsomorphicLayoutEffect\n} from \"@tamagui/constants\";\nimport { createStyledContext, useMedia } from \"@tamagui/core\";\nimport { withStaticProperties } from \"@tamagui/helpers\";\nimport { StackZIndexContext } from \"@tamagui/z-index-stack\";\nimport React, { createContext, useContext, useId } from \"react\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\nfunction createAdaptSlotStore() {\n const listeners = /* @__PURE__ */ new Set();\n const store = {\n element: null,\n version: 0,\n publish(element) {\n store.element = element;\n },\n clear() {\n store.element = null;\n },\n notify() {\n store.version += 1;\n for (const listener of listeners) {\n listener();\n }\n },\n getSnapshot() {\n return store.version;\n },\n subscribe(callback) {\n listeners.add(callback);\n return () => {\n listeners.delete(callback);\n };\n }\n };\n return store;\n}\nconst adaptContextKeys = [\n \"Contents\",\n \"scopeName\",\n \"portalName\",\n \"active\",\n \"setAdaptConfig\",\n \"slot\",\n \"handoff\",\n \"targetFullyHidden\",\n \"registerTarget\",\n \"unregisterTarget\",\n \"registerContents\",\n \"unregisterContents\",\n \"registerRenderCallback\",\n \"unregisterRenderCallback\"\n];\nconst AdaptContext = createStyledContext(\n {\n Contents: null,\n scopeName: \"\",\n portalName: \"\",\n active: false,\n setAdaptConfig: () => {\n },\n slot: null,\n handoff: {\n hidden: true,\n onTransition: () => {\n }\n },\n targetFullyHidden: true,\n registerTarget: () => {\n },\n unregisterTarget: () => {\n },\n registerContents: () => {\n },\n unregisterContents: () => {\n },\n registerRenderCallback: () => {\n },\n unregisterRenderCallback: () => {\n }\n },\n {\n keys: adaptContextKeys\n }\n);\nconst AdaptCapabilitiesContext = createContext({});\nconst LastAdaptContextScope = createContext(\"\");\nconst AdaptTargetScope = createContext(null);\nconst useAdaptTargetScope = () => useContext(AdaptTargetScope);\nconst ProvideAdaptContext = ({\n children,\n ...context\n}) => {\n const scope = context.scopeName || \"\";\n const lastScope = useContext(LastAdaptContextScope);\n return /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: lastScope || context.lastScope || \"\", children: /* @__PURE__ */ jsx(\n AdaptContext.Provider,\n {\n scope,\n lastScope: lastScope || context.lastScope,\n ...context,\n children\n }\n ) });\n};\nconst useAdaptContext = (scope) => {\n const lastScope = useContext(LastAdaptContextScope);\n const adaptScope = scope ?? lastScope;\n return AdaptContext.useStyledContext(adaptScope);\n};\nfunction findAdaptConfig(children, scope) {\n for (const child of React.Children.toArray(children)) {\n if (!React.isValidElement(child)) continue;\n if (child.type === React.Fragment) {\n const found = findAdaptConfig(\n child.props.children,\n scope\n );\n if (found) return found;\n continue;\n }\n if (child.type === Adapt) {\n const childProps = child.props;\n if (childProps.scope == null || childProps.scope === scope) {\n return childProps;\n }\n }\n }\n return null;\n}\nconst AdaptParent = ({\n children,\n adaptChildren,\n Contents,\n scope,\n open,\n onOpenChange,\n state\n}) => {\n const id = useId();\n const portalName = `AdaptPortal${scope}${id}`;\n const slotRef = React.useRef(null);\n if (!slotRef.current) {\n slotRef.current = createAdaptSlotStore();\n }\n const staticConfig = React.useMemo(\n () => findAdaptConfig(adaptChildren, scope) ?? findAdaptConfig(children, scope),\n [adaptChildren, children, scope]\n );\n const [publishedConfig, setPublishedConfig] = React.useState(null);\n const rawActive = useAdaptIsActiveGiven(staticConfig ?? publishedConfig);\n const staticConfigRef = React.useRef(staticConfig);\n staticConfigRef.current = staticConfig;\n const setAdaptConfig = React.useCallback((config) => {\n if (staticConfigRef.current) return;\n setPublishedConfig(config);\n }, []);\n const [exiting, setExiting] = React.useState(false);\n const [present, setPresent] = React.useState(false);\n const [targetFullyHidden, setTargetFullyHidden] = React.useState(!open);\n const targetCountRef = React.useRef(0);\n const contentsCountRef = React.useRef(0);\n const renderCallbackCountRef = React.useRef(0);\n const rawActiveRef = React.useRef(false);\n const openRef = React.useRef(open);\n const wasTargetHiddenRef = React.useRef(!rawActive);\n const hasHadActiveTargetRef = React.useRef(false);\n const shouldStartExit = !rawActive && present && Boolean(open);\n const active = rawActive || exiting || shouldStartExit;\n const targetHidden = !rawActive;\n const skipNextAnimation = Boolean(\n rawActive && wasTargetHiddenRef.current && hasHadActiveTargetRef.current && open\n );\n const releasePresenceLatch = React.useCallback(() => {\n setExiting(false);\n if (!rawActiveRef.current) {\n setPresent(false);\n }\n }, []);\n useIsomorphicLayoutEffect(() => {\n if (shouldStartExit) {\n setExiting(true);\n }\n }, [shouldStartExit]);\n useIsomorphicLayoutEffect(() => {\n rawActiveRef.current = rawActive;\n openRef.current = open;\n if (rawActive) {\n hasHadActiveTargetRef.current = true;\n }\n wasTargetHiddenRef.current = targetHidden;\n if (open && rawActive) {\n setTargetFullyHidden(false);\n return;\n }\n if (!open && !active) {\n setTargetFullyHidden(true);\n }\n }, [active, open, rawActive, targetHidden]);\n useIsomorphicLayoutEffect(() => {\n if (rawActive) {\n setPresent(true);\n } else if (!active) {\n setPresent(false);\n }\n if (rawActive && exiting) {\n setExiting(false);\n }\n }, [active, exiting, rawActive]);\n const handoff = React.useMemo(\n () => ({\n hidden: targetHidden,\n skipNextAnimation,\n onTransition(e) {\n if (e.phase !== \"end\" || e.finished === false) return;\n if (e.cause !== \"close\") {\n setTargetFullyHidden(false);\n return;\n }\n if (openRef.current && rawActiveRef.current) {\n setTargetFullyHidden(false);\n return;\n }\n setTargetFullyHidden(true);\n releasePresenceLatch();\n }\n }),\n [releasePresenceLatch, skipNextAnimation, targetHidden]\n );\n const registerTarget = React.useCallback(() => {\n targetCountRef.current += 1;\n if (process.env.NODE_ENV === \"development\" && targetCountRef.current > 1) {\n console.error(\n `Adapt expected exactly one target in scope \"${scope}\", but ${targetCountRef.current} targets registered.`\n );\n }\n }, [scope]);\n const unregisterTarget = React.useCallback(() => {\n targetCountRef.current = Math.max(0, targetCountRef.current - 1);\n }, []);\n const registerContents = React.useCallback(() => {\n contentsCountRef.current += 1;\n }, []);\n const unregisterContents = React.useCallback(() => {\n contentsCountRef.current = Math.max(0, contentsCountRef.current - 1);\n }, []);\n const registerRenderCallback = React.useCallback(() => {\n renderCallbackCountRef.current += 1;\n }, []);\n const unregisterRenderCallback = React.useCallback(() => {\n renderCallbackCountRef.current = Math.max(0, renderCallbackCountRef.current - 1);\n }, []);\n React.useEffect(() => {\n if (process.env.NODE_ENV !== \"development\") return;\n if (!active) return;\n const timer = setTimeout(() => {\n if (rawActiveRef.current && targetCountRef.current === 0 && contentsCountRef.current === 0 && renderCallbackCountRef.current === 0) {\n console.error(\n `Adapt is active in scope \"${scope}\" but no target registered with useAdaptTarget(), Adapt.Contents marker, or render callback consumed it.`\n );\n }\n });\n return () => clearTimeout(timer);\n }, [active, scope]);\n const FinalContents = Contents || AdaptSlotContents;\n return /* @__PURE__ */ jsx(LastAdaptContextScope.Provider, { value: scope, children: /* @__PURE__ */ jsx(\n ProvideAdaptContext,\n {\n Contents: FinalContents,\n active,\n setAdaptConfig,\n portalName,\n scopeName: scope,\n slot: slotRef.current,\n open,\n onOpenChange,\n state,\n handoff,\n targetFullyHidden,\n registerTarget,\n unregisterTarget,\n registerContents,\n unregisterContents,\n registerRenderCallback,\n unregisterRenderCallback,\n children\n }\n ) });\n};\nconst AdaptContents = ({ scope, ...rest }) => {\n const context = useAdaptContext(scope);\n if (!context?.Contents) {\n throw new Error(\n process.env.NODE_ENV === \"production\" ? `tamagui.dev/docs/intro/errors#warning-002` : `You're rendering a Tamagui <Adapt /> component without nesting it inside a parent that is able to adapt.`\n );\n }\n useIsomorphicLayoutEffect(() => {\n if (!context.active) return;\n context.registerContents();\n return () => {\n context.unregisterContents();\n };\n }, [context.active, context.registerContents, context.unregisterContents]);\n return /* @__PURE__ */ jsx(AdaptTargetScope.Provider, { value: null, children: React.createElement(context.Contents, { ...rest, scope, key: `stable` }) });\n};\nconst Adapt = withStaticProperties(\n function Adapt2(props) {\n const { children, platform, scope, when } = props;\n const context = useAdaptContext(scope);\n const enabled = context.active;\n const isRenderCallback = typeof children === \"function\";\n useIsomorphicLayoutEffect(() => {\n context.setAdaptConfig({ when, platform });\n return () => {\n context.setAdaptConfig(null);\n };\n }, [when, platform, context.setAdaptConfig]);\n useIsomorphicLayoutEffect(() => {\n if (!enabled || !isRenderCallback) return;\n context.registerRenderCallback();\n return () => {\n context.unregisterRenderCallback();\n };\n }, [\n enabled,\n isRenderCallback,\n context.registerRenderCallback,\n context.unregisterRenderCallback\n ]);\n let output;\n if (isRenderCallback) {\n const Component = context?.Contents;\n output = children(Component ? /* @__PURE__ */ jsx(Component, {}) : null, getAdaptRenderState(context));\n } else {\n output = children;\n }\n return /* @__PURE__ */ jsx(AdaptTargetScope.Provider, { value: context.scopeName, children: /* @__PURE__ */ jsx(StackZIndexContext, { children: !enabled ? null : output }) });\n },\n {\n Contents: AdaptContents\n }\n);\nconst AdaptPortalContents = (props) => {\n const isActive = useAdaptIsActive(props.scope);\n const { slot } = useAdaptContext(props.scope);\n return /* @__PURE__ */ jsx(AdaptSlotPublisher, { isActive, slot, children: props.children });\n};\nfunction AdaptSlotContents({ scope }) {\n const { slot } = useAdaptContext(scope);\n React.useSyncExternalStore(\n slot?.subscribe ?? emptySubscribe,\n slot?.getSnapshot ?? emptySnapshot,\n slot?.getSnapshot ?? emptySnapshot\n );\n return /* @__PURE__ */ jsx(Fragment, { children: slot?.element ?? null });\n}\nfunction AdaptSlotPublisher({\n isActive,\n slot,\n children\n}) {\n const publishedRef = React.useRef(null);\n useIsomorphicLayoutEffect(() => {\n if (!slot) return;\n const published = publishedRef.current;\n if (published && published.isActive === isActive && published.element === children) {\n return;\n }\n publishedRef.current = { isActive, element: children };\n if (isActive) {\n slot.publish(children);\n } else {\n slot.clear();\n }\n slot.notify();\n });\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (publishedRef.current?.isActive) {\n slot?.clear();\n slot?.notify();\n }\n publishedRef.current = null;\n };\n }, [slot]);\n return isActive ? null : /* @__PURE__ */ jsx(Fragment, { children });\n}\nconst emptySubscribe = () => () => {\n};\nconst emptySnapshot = () => 0;\nconst useAdaptIsActiveGiven = (config) => {\n const media = useMedia();\n const when = config?.when;\n const platform = config?.platform;\n if (when == null && platform == null) {\n return false;\n }\n let enabled = false;\n if (platform === \"touch\") enabled = isTouchable;\n else if (platform === \"native\") enabled = !isWeb;\n else if (platform === \"web\") enabled = isWeb;\n else if (platform === \"ios\") enabled = isIos;\n else if (platform === \"android\") enabled = isAndroid;\n if (platform && enabled == false) {\n return false;\n }\n if (when === true) {\n return true;\n }\n if (when && typeof when === \"string\") {\n enabled = media[when];\n }\n return enabled;\n};\nconst useAdaptIsActive = (scope) => {\n return useAdaptContext(scope).active;\n};\nfunction useAdaptTarget(scope) {\n const context = useAdaptContext(scope);\n const targetScope = useAdaptTargetScope();\n const isTarget = scope !== void 0 || targetScope === context.scopeName;\n useIsomorphicLayoutEffect(() => {\n if (!context.active || !isTarget) return;\n context.registerTarget();\n return () => {\n context.unregisterTarget();\n };\n }, [context.active, context.registerTarget, context.unregisterTarget, isTarget]);\n if (!context.active || !isTarget) {\n return null;\n }\n return {\n open: context.open,\n onOpenChange: context.onOpenChange,\n handoff: context.handoff,\n state: context.state\n };\n}\nconst AdaptCapabilities = ({\n children,\n scroll,\n overlay,\n dismiss\n}) => {\n const parent = useContext(AdaptCapabilitiesContext);\n const value = React.useMemo(\n () => ({\n scroll: scroll ?? parent.scroll,\n overlay: overlay ?? parent.overlay,\n dismiss: dismiss ?? parent.dismiss\n }),\n [dismiss, overlay, parent.dismiss, parent.overlay, parent.scroll, scroll]\n );\n return /* @__PURE__ */ jsx(AdaptCapabilitiesContext.Provider, { value, children });\n};\nconst useAdaptedCapabilities = () => {\n return useContext(AdaptCapabilitiesContext);\n};\nfunction getAdaptRenderState(context) {\n return {\n active: context.active,\n open: context.open,\n onOpenChange: context.onOpenChange,\n state: context.state,\n handoff: context.handoff\n };\n}\nexport {\n Adapt,\n AdaptCapabilities,\n AdaptContents,\n AdaptContext,\n AdaptParent,\n AdaptPortalContents,\n ProvideAdaptContext,\n useAdaptContext,\n useAdaptIsActive,\n useAdaptTarget,\n useAdaptTargetScope,\n useAdaptedCapabilities\n};\n//# sourceMappingURL=Adapt.js.map\n"],"mappings":";;;;;;;;AAYA,SAAS,uBAAuB;CAC9B,MAAM,4BAA4B,IAAI,IAAI;CAC1C,MAAM,QAAQ;EACZ,SAAS;EACT,SAAS;EACT,QAAQ,SAAS;GACf,MAAM,UAAU;EAClB;EACA,QAAQ;GACN,MAAM,UAAU;EAClB;EACA,SAAS;GACP,MAAM,WAAW;GACjB,KAAK,MAAM,YAAY,WAAW;IAChC,SAAS;GACX;EACF;EACA,cAAc;GACZ,OAAO,MAAM;EACf;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa;IACX,UAAU,OAAO,QAAQ;GAC3B;EACF;CACF;CACA,OAAO;AACT;AACA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AACA,MAAM,eAAe,oBACnB;CACE,UAAU;CACV,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,sBAAsB,CACtB;CACA,MAAM;CACN,SAAS;EACP,QAAQ;EACR,oBAAoB,CACpB;CACF;CACA,mBAAmB;CACnB,sBAAsB,CACtB;CACA,wBAAwB,CACxB;CACA,wBAAwB,CACxB;CACA,0BAA0B,CAC1B;CACA,8BAA8B,CAC9B;CACA,gCAAgC,CAChC;AACF,GACA,EACE,MAAM,iBACR,CACF;AACA,MAAM,2BAA2B,cAAc,CAAC,CAAC;AACjD,MAAM,wBAAwB,cAAc,EAAE;AAC9C,MAAM,mBAAmB,cAAc,IAAI;AAC3C,MAAM,4BAA4B,WAAW,gBAAgB;AAC7D,MAAM,uBAAuB,EAC3B,UACA,GAAG,cACC;CACJ,MAAM,QAAQ,QAA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