tamagui 1.126.17 → 1.127.0

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/native.js CHANGED
@@ -13570,12 +13570,31 @@ var require_getBoundingClientRect_native = __commonJS({
13570
13570
  __export2(getBoundingClientRect_exports, {
13571
13571
  getBoundingClientRect: function() {
13572
13572
  return getBoundingClientRect;
13573
+ },
13574
+ getBoundingClientRectAsync: function() {
13575
+ return getBoundingClientRectAsync;
13573
13576
  }
13574
13577
  });
13575
13578
  module2.exports = __toCommonJS2(getBoundingClientRect_exports);
13576
13579
  var getBoundingClientRect = function(node) {
13577
13580
  var _node_getBoundingClientRect;
13578
13581
  if (!(!node || node.nodeType !== 1)) return (_node_getBoundingClientRect = node.getBoundingClientRect) === null || _node_getBoundingClientRect === void 0 ? void 0 : _node_getBoundingClientRect.call(node);
13582
+ }, getBoundingClientRectAsync = function(element) {
13583
+ return new Promise(function(resolve) {
13584
+ var didFallback = !1;
13585
+ function fallbackToSync() {
13586
+ didFallback = !0, resolve(getBoundingClientRect(element));
13587
+ }
13588
+ var tm = setTimeout(fallbackToSync, 32), observer = new IntersectionObserver(function(entries, ob) {
13589
+ if (clearTimeout(tm), ob.disconnect(), !didFallback) {
13590
+ var _entries_;
13591
+ resolve((_entries_ = entries[0]) === null || _entries_ === void 0 ? void 0 : _entries_.boundingClientRect);
13592
+ }
13593
+ }, {
13594
+ threshold: 1e-4
13595
+ });
13596
+ observer.observe(element);
13597
+ });
13579
13598
  };
13580
13599
  }
13581
13600
  });
@@ -13681,9 +13700,15 @@ var require_useElementLayout_native = __commonJS({
13681
13700
  getElementLayoutEvent: function() {
13682
13701
  return getElementLayoutEvent2;
13683
13702
  },
13703
+ getElementLayoutEventAsync: function() {
13704
+ return getElementLayoutEventAsync;
13705
+ },
13684
13706
  measureLayout: function() {
13685
13707
  return measureLayout;
13686
13708
  },
13709
+ measureLayoutAsync: function() {
13710
+ return measureLayoutAsync;
13711
+ },
13687
13712
  setOnLayoutStrategy: function() {
13688
13713
  return setOnLayoutStrategy3;
13689
13714
  },
@@ -13692,37 +13717,62 @@ var require_useElementLayout_native = __commonJS({
13692
13717
  }
13693
13718
  });
13694
13719
  module2.exports = __toCommonJS2(useElementLayout_exports);
13695
- var import_constants4 = require_index_native6(), import_web = require_index_native14(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), status = "active";
13720
+ var import_constants4 = require_index_native6(), import_web = require_index_native14(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), strategy = "async";
13696
13721
  function setOnLayoutStrategy3(state) {
13697
- status = state;
13698
- }
13699
- var NodeRectCache = /* @__PURE__ */ new WeakMap(), ParentRectCache = /* @__PURE__ */ new WeakMap(), rAF = typeof window < "u" ? window.requestAnimationFrame : void 0;
13700
- import_constants4.isClient && (rAF ? (updateLayoutIfChanged = function(node) {
13701
- var nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode == null ? void 0 : parentNode.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
13702
- if (typeof onLayout == "function") {
13703
- var cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
13704
- if (!cachedRect || // has changed one rect
13705
- !(0, import_web.isEqualShallow)(cachedRect, nodeRect) && (!cachedParentRect || !(0, import_web.isEqualShallow)(cachedParentRect, parentRect))) {
13706
- NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect);
13707
- var event = getElementLayoutEvent2(node);
13708
- avoidUpdates ? queuedUpdates.set(node, function() {
13709
- return onLayout(event);
13710
- }) : onLayout(event);
13711
- }
13712
- }
13713
- }, layoutOnAnimationFrame = function() {
13714
- var now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
13715
- if (lastFrameAt = now, status !== "inactive") {
13716
- var expectedFrameTime = 16.67, hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
13717
- hasRecentSyncWork || Nodes.forEach(updateLayoutIfChanged);
13722
+ strategy = state;
13723
+ }
13724
+ var NodeRectCache = /* @__PURE__ */ new WeakMap(), ParentRectCache = /* @__PURE__ */ new WeakMap(), DebounceTimers = /* @__PURE__ */ new WeakMap(), LastChangeTime = /* @__PURE__ */ new WeakMap(), rAF = typeof window < "u" ? window.requestAnimationFrame : void 0, DEBOUNCE_DELAY = 32;
13725
+ if (import_constants4.isClient) if (rAF) {
13726
+ layoutOnAnimationFrame = function() {
13727
+ var now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
13728
+ if (lastFrameAt = now, strategy !== "off") {
13729
+ var expectedFrameTime = 16.67, hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
13730
+ hasRecentSyncWork || Nodes.forEach(updateLayoutIfChanged);
13731
+ }
13732
+ rAF(layoutOnAnimationFrame);
13733
+ }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, avoidUpdates = !0, queuedUpdates = /* @__PURE__ */ new Map(), lastFrameAt = Date.now(), numDroppedFramesUntilPause = 2, (0, import_web.___onDidFinishClientRender)(function() {
13734
+ avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function(cb) {
13735
+ return cb();
13736
+ }), queuedUpdates.clear());
13737
+ });
13738
+ async function updateLayoutIfChanged(node) {
13739
+ var nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode == null ? void 0 : parentNode.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
13740
+ if (typeof onLayout == "function") {
13741
+ var cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
13742
+ if (!cachedRect || // has changed one rect
13743
+ !(0, import_web.isEqualShallow)(cachedRect, nodeRect) && (!cachedParentRect || !(0, import_web.isEqualShallow)(cachedParentRect, parentRect))) if (NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect), avoidUpdates) {
13744
+ var event = getElementLayoutEvent2(node);
13745
+ queuedUpdates.set(node, function() {
13746
+ return onLayout(event);
13747
+ });
13748
+ } else if (strategy === "async") {
13749
+ var now = Date.now();
13750
+ LastChangeTime.set(node, now);
13751
+ var existingTimer = DebounceTimers.get(node);
13752
+ existingTimer && clearTimeout(existingTimer);
13753
+ var timer = setTimeout(async function() {
13754
+ var lastChange = LastChangeTime.get(node) || 0, timeSinceChange = Date.now() - lastChange;
13755
+ if (timeSinceChange >= DEBOUNCE_DELAY) {
13756
+ var event2 = await getElementLayoutEventAsync(node);
13757
+ onLayout(event2), DebounceTimers.delete(node);
13758
+ } else {
13759
+ var remainingDelay = DEBOUNCE_DELAY - timeSinceChange, newTimer = setTimeout(async function() {
13760
+ var event3 = await getElementLayoutEventAsync(node);
13761
+ onLayout(event3), DebounceTimers.delete(node);
13762
+ }, remainingDelay);
13763
+ DebounceTimers.set(node, newTimer);
13764
+ }
13765
+ }, DEBOUNCE_DELAY);
13766
+ DebounceTimers.set(node, timer);
13767
+ } else {
13768
+ var event1 = getElementLayoutEvent2(node);
13769
+ onLayout(event1);
13770
+ }
13771
+ }
13718
13772
  }
13719
13773
  rAF(layoutOnAnimationFrame);
13720
- }, updateLayoutIfChanged2 = updateLayoutIfChanged, layoutOnAnimationFrame2 = layoutOnAnimationFrame, avoidUpdates = !0, queuedUpdates = /* @__PURE__ */ new Map(), lastFrameAt = Date.now(), numDroppedFramesUntilPause = 2, (0, import_web.___onDidFinishClientRender)(function() {
13721
- avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function(cb) {
13722
- return cb();
13723
- }), queuedUpdates.clear());
13724
- }), rAF(layoutOnAnimationFrame)) : process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly"));
13725
- var updateLayoutIfChanged, layoutOnAnimationFrame, updateLayoutIfChanged2, layoutOnAnimationFrame2, avoidUpdates, queuedUpdates, lastFrameAt, numDroppedFramesUntilPause, getElementLayoutEvent2 = function(target) {
13774
+ } else process.env.NODE_ENV === "development" && console.warn("No requestAnimationFrame - please polyfill for onLayout to work correctly");
13775
+ var layoutOnAnimationFrame, layoutOnAnimationFrame2, avoidUpdates, queuedUpdates, lastFrameAt, numDroppedFramesUntilPause, getElementLayoutEvent2 = function(target) {
13726
13776
  var res = null;
13727
13777
  if (measureLayout(target, null, function(x, y, width, height, left, top) {
13728
13778
  res = {
@@ -13750,6 +13800,37 @@ var require_useElementLayout_native = __commonJS({
13750
13800
  callback(x, y, width, height, left, top);
13751
13801
  }
13752
13802
  }
13803
+ }, getElementLayoutEventAsync = async function(target) {
13804
+ var res = null;
13805
+ if (await measureLayoutAsync(target, null, function(x, y, width, height, left, top) {
13806
+ res = {
13807
+ nativeEvent: {
13808
+ layout: {
13809
+ x,
13810
+ y,
13811
+ width,
13812
+ height,
13813
+ left,
13814
+ top
13815
+ },
13816
+ target
13817
+ },
13818
+ timeStamp: Date.now()
13819
+ };
13820
+ }), !res) throw new Error("\u203C\uFE0F");
13821
+ return res;
13822
+ }, measureLayoutAsync = async function(node, relativeTo, callback) {
13823
+ var relativeNode = relativeTo || (node == null ? void 0 : node.parentElement);
13824
+ if (relativeNode instanceof HTMLElement) {
13825
+ var [nodeDim, relativeNodeDim] = await Promise.all([
13826
+ node.getBoundingClientRect(),
13827
+ relativeNode.getBoundingClientRect()
13828
+ ]);
13829
+ if (relativeNodeDim && nodeDim) {
13830
+ var { x, y, width, height, left, top } = getRelativeDimensions(nodeDim, relativeNodeDim);
13831
+ callback(x, y, width, height, left, top);
13832
+ }
13833
+ }
13753
13834
  }, getRelativeDimensions = function(a, b) {
13754
13835
  var { height, left, top, width } = a, x = left - b.left, y = top - b.top;
13755
13836
  return {
@@ -13769,6 +13850,8 @@ var require_useElementLayout_native = __commonJS({
13769
13850
  var node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;
13770
13851
  if (node2) return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent2(node2)), function() {
13771
13852
  Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
13853
+ var timer = DebounceTimers.get(node2);
13854
+ timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
13772
13855
  };
13773
13856
  }
13774
13857
  }, [
@@ -15638,7 +15721,7 @@ var require_Accordion_native = __commonJS({
15638
15721
  }
15639
15722
  });
15640
15723
  module2.exports = __toCommonJS2(Accordion_exports);
15641
- var import_jsx_runtime6 = require("react/jsx-runtime"), import_collapsible = require_index_native15(), import_collection = require_index_native19(), import_compose_refs = require_index_native11(), import_constants4 = require_index_native6(), import_helpers = require_index_native7(), import_stacks3 = require_index_native22(), import_text2 = require_index_native24(), import_use_controllable_state = require_index_native10(), import_use_direction = require_index_native25(), import_web = require_index_native14(), React4 = __toESM2(require("react")), ACCORDION_NAME = "Accordion", ACCORDION_KEYS = [
15724
+ var import_jsx_runtime6 = require("react/jsx-runtime"), import_collapsible = require_index_native15(), import_collection = require_index_native19(), import_compose_refs = require_index_native11(), import_constants4 = require_index_native6(), import_core12 = require_index_native18(), import_helpers = require_index_native7(), import_stacks3 = require_index_native22(), import_text2 = require_index_native24(), import_use_controllable_state = require_index_native10(), import_use_direction = require_index_native25(), React4 = __toESM2(require("react")), ACCORDION_NAME = "Accordion", ACCORDION_KEYS = [
15642
15725
  "Home",
15643
15726
  "End",
15644
15727
  "ArrowDown",
@@ -15668,7 +15751,7 @@ var require_Accordion_native = __commonJS({
15668
15751
  ].includes(props.type) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`.") : props.type === "multiple" && typeof value == "string" ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`.") : props.type === "single" && Array.isArray(value) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`.") : null;
15669
15752
  }
15670
15753
  };
15671
- var { Provider: AccordionValueProvider, useStyledContext: useAccordionValueContext } = (0, import_web.createStyledContext)(), { Provider: AccordionCollapsibleProvider, useStyledContext: useAccordionCollapsibleContext } = (0, import_web.createStyledContext)(), AccordionImplSingle = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15754
+ var { Provider: AccordionValueProvider, useStyledContext: useAccordionValueContext } = (0, import_core12.createStyledContext)(), { Provider: AccordionCollapsibleProvider, useStyledContext: useAccordionCollapsibleContext } = (0, import_core12.createStyledContext)(), AccordionImplSingle = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15672
15755
  var { value: valueProp, defaultValue, control, onValueChange = function() {
15673
15756
  }, collapsible = !1, ...accordionSingleProps } = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
15674
15757
  prop: valueProp,
@@ -15736,7 +15819,7 @@ var require_Accordion_native = __commonJS({
15736
15819
  })
15737
15820
  })
15738
15821
  });
15739
- }), { Provider: AccordionImplProvider, useStyledContext: useAccordionContext } = (0, import_web.createStyledContext)(), AccordionImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15822
+ }), { Provider: AccordionImplProvider, useStyledContext: useAccordionContext } = (0, import_core12.createStyledContext)(), AccordionImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15740
15823
  var { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props, accordionRef = React4.useRef(null), composedRef = (0, import_compose_refs.useComposedRefs)(accordionRef, forwardedRef), getItems = useCollection(__scopeAccordion || ACCORDION_CONTEXT), direction = (0, import_use_direction.useDirection)(dir), isDirectionLTR = direction === "ltr", handleKeyDown = (0, import_helpers.composeEventHandlers)(props.onKeyDown, function(event) {
15741
15824
  var _triggerCollection_clampedIndex_ref_current;
15742
15825
  if (ACCORDION_KEYS.includes(event.key)) {
@@ -15795,7 +15878,7 @@ var require_Accordion_native = __commonJS({
15795
15878
  })
15796
15879
  })
15797
15880
  });
15798
- }), ITEM_NAME = "AccordionItem", { Provider: AccordionItemProvider, useStyledContext: useAccordionItemContext } = (0, import_web.createStyledContext)(), AccordionItem = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15881
+ }), ITEM_NAME = "AccordionItem", { Provider: AccordionItemProvider, useStyledContext: useAccordionItemContext } = (0, import_core12.createStyledContext)(), AccordionItem = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15799
15882
  var { __scopeAccordion, value, ...accordionItemProps } = props, accordionContext = useAccordionContext(__scopeAccordion), valueContext = useAccordionValueContext(__scopeAccordion), triggerId = React4.useId(), open = value && valueContext.value.includes(value) || !1, disabled = accordionContext.disabled || props.disabled;
15800
15883
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AccordionItemProvider, {
15801
15884
  scope: __scopeAccordion,
@@ -15828,7 +15911,7 @@ var require_Accordion_native = __commonJS({
15828
15911
  });
15829
15912
  });
15830
15913
  AccordionHeader.displayName = HEADER_NAME;
15831
- var AccordionTriggerFrame = (0, import_web.styled)(import_collapsible.Collapsible.Trigger, {
15914
+ var AccordionTriggerFrame = (0, import_core12.styled)(import_collapsible.Collapsible.Trigger, {
15832
15915
  variants: {
15833
15916
  unstyled: {
15834
15917
  false: {
@@ -15866,7 +15949,7 @@ var require_Accordion_native = __commonJS({
15866
15949
  ref: forwardedRef
15867
15950
  })
15868
15951
  });
15869
- }), AccordionContentFrame = (0, import_web.styled)(import_collapsible.Collapsible.Content, {
15952
+ }), AccordionContentFrame = (0, import_core12.styled)(import_collapsible.Collapsible.Content, {
15870
15953
  variants: {
15871
15954
  unstyled: {
15872
15955
  false: {
@@ -15889,20 +15972,19 @@ var require_Accordion_native = __commonJS({
15889
15972
  ...contentProps,
15890
15973
  ref: forwardedRef
15891
15974
  });
15892
- }), HeightAnimator = import_web.View.styleable(function(props, ref) {
15893
- var itemContext = useAccordionItemContext(), { children, ...rest } = props, [height, setHeight] = React4.useState(0), onLayout = (0, import_web.useEvent)(function(param) {
15894
- var { nativeEvent } = param;
15895
- nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
15896
- });
15897
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_web.View, {
15975
+ }), HeightAnimator = import_core12.View.styleable(function(props, ref) {
15976
+ var itemContext = useAccordionItemContext(), { children, ...rest } = props, [height, setHeight] = React4.useState(0);
15977
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core12.View, {
15898
15978
  ref,
15899
15979
  height: itemContext.open ? height : 0,
15900
15980
  ...rest,
15901
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_web.View, {
15981
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core12.View, {
15902
15982
  position: "absolute",
15903
15983
  width: "100%",
15904
- //@ts-ignore
15905
- onLayout,
15984
+ onLayout: function(param) {
15985
+ var { nativeEvent } = param;
15986
+ nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
15987
+ },
15906
15988
  children
15907
15989
  })
15908
15990
  });