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.
@@ -12990,12 +12990,31 @@ var require_getBoundingClientRect_native = __commonJS({
12990
12990
  __export2(getBoundingClientRect_exports, {
12991
12991
  getBoundingClientRect: function() {
12992
12992
  return getBoundingClientRect;
12993
+ },
12994
+ getBoundingClientRectAsync: function() {
12995
+ return getBoundingClientRectAsync;
12993
12996
  }
12994
12997
  });
12995
12998
  module2.exports = __toCommonJS2(getBoundingClientRect_exports);
12996
12999
  var getBoundingClientRect = function(node) {
12997
13000
  var _node_getBoundingClientRect;
12998
13001
  if (!(!node || node.nodeType !== 1)) return (_node_getBoundingClientRect = node.getBoundingClientRect) === null || _node_getBoundingClientRect === void 0 ? void 0 : _node_getBoundingClientRect.call(node);
13002
+ }, getBoundingClientRectAsync = function(element) {
13003
+ return new Promise(function(resolve) {
13004
+ var didFallback = !1;
13005
+ function fallbackToSync() {
13006
+ didFallback = !0, resolve(getBoundingClientRect(element));
13007
+ }
13008
+ var tm = setTimeout(fallbackToSync, 32), observer = new IntersectionObserver(function(entries, ob) {
13009
+ if (clearTimeout(tm), ob.disconnect(), !didFallback) {
13010
+ var _entries_;
13011
+ resolve((_entries_ = entries[0]) === null || _entries_ === void 0 ? void 0 : _entries_.boundingClientRect);
13012
+ }
13013
+ }, {
13014
+ threshold: 1e-4
13015
+ });
13016
+ observer.observe(element);
13017
+ });
12999
13018
  };
13000
13019
  }
13001
13020
  });
@@ -13101,9 +13120,15 @@ var require_useElementLayout_native = __commonJS({
13101
13120
  getElementLayoutEvent: function() {
13102
13121
  return getElementLayoutEvent2;
13103
13122
  },
13123
+ getElementLayoutEventAsync: function() {
13124
+ return getElementLayoutEventAsync;
13125
+ },
13104
13126
  measureLayout: function() {
13105
13127
  return measureLayout;
13106
13128
  },
13129
+ measureLayoutAsync: function() {
13130
+ return measureLayoutAsync;
13131
+ },
13107
13132
  setOnLayoutStrategy: function() {
13108
13133
  return setOnLayoutStrategy3;
13109
13134
  },
@@ -13112,37 +13137,62 @@ var require_useElementLayout_native = __commonJS({
13112
13137
  }
13113
13138
  });
13114
13139
  module2.exports = __toCommonJS2(useElementLayout_exports);
13115
- var import_constants4 = require_index_native6(), import_web = require_index_native14(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), status = "active";
13140
+ var import_constants4 = require_index_native6(), import_web = require_index_native14(), LayoutHandlers = /* @__PURE__ */ new WeakMap(), Nodes = /* @__PURE__ */ new Set(), strategy = "async";
13116
13141
  function setOnLayoutStrategy3(state) {
13117
- status = state;
13118
- }
13119
- var NodeRectCache = /* @__PURE__ */ new WeakMap(), ParentRectCache = /* @__PURE__ */ new WeakMap(), rAF = typeof window < "u" ? window.requestAnimationFrame : void 0;
13120
- import_constants4.isClient && rAF && (updateLayoutIfChanged = function(node) {
13121
- var nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode == null ? void 0 : parentNode.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
13122
- if (typeof onLayout == "function") {
13123
- var cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
13124
- if (!cachedRect || // has changed one rect
13125
- !(0, import_web.isEqualShallow)(cachedRect, nodeRect) && (!cachedParentRect || !(0, import_web.isEqualShallow)(cachedParentRect, parentRect))) {
13126
- NodeRectCache.set(node, nodeRect), parentRect && parentNode && ParentRectCache.set(parentNode, parentRect);
13127
- var event = getElementLayoutEvent2(node);
13128
- avoidUpdates ? queuedUpdates.set(node, function() {
13129
- return onLayout(event);
13130
- }) : onLayout(event);
13131
- }
13132
- }
13133
- }, layoutOnAnimationFrame = function() {
13134
- var now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
13135
- if (lastFrameAt = now, status !== "inactive") {
13136
- var expectedFrameTime = 16.67, hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
13137
- hasRecentSyncWork || Nodes.forEach(updateLayoutIfChanged);
13142
+ strategy = state;
13143
+ }
13144
+ 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;
13145
+ if (import_constants4.isClient && rAF) {
13146
+ layoutOnAnimationFrame = function() {
13147
+ var now = Date.now(), timeSinceLastFrame = now - lastFrameAt;
13148
+ if (lastFrameAt = now, strategy !== "off") {
13149
+ var expectedFrameTime = 16.67, hasRecentSyncWork = timeSinceLastFrame > expectedFrameTime * numDroppedFramesUntilPause;
13150
+ hasRecentSyncWork || Nodes.forEach(updateLayoutIfChanged);
13151
+ }
13152
+ rAF(layoutOnAnimationFrame);
13153
+ }, layoutOnAnimationFrame2 = layoutOnAnimationFrame, avoidUpdates = !0, queuedUpdates = /* @__PURE__ */ new Map(), lastFrameAt = Date.now(), numDroppedFramesUntilPause = 2, (0, import_web.___onDidFinishClientRender)(function() {
13154
+ avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function(cb) {
13155
+ return cb();
13156
+ }), queuedUpdates.clear());
13157
+ });
13158
+ async function updateLayoutIfChanged(node) {
13159
+ var nodeRect = node.getBoundingClientRect(), parentNode = node.parentElement, parentRect = parentNode == null ? void 0 : parentNode.getBoundingClientRect(), onLayout = LayoutHandlers.get(node);
13160
+ if (typeof onLayout == "function") {
13161
+ var cachedRect = NodeRectCache.get(node), cachedParentRect = parentNode ? NodeRectCache.get(parentNode) : null;
13162
+ if (!cachedRect || // has changed one rect
13163
+ !(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) {
13164
+ var event = getElementLayoutEvent2(node);
13165
+ queuedUpdates.set(node, function() {
13166
+ return onLayout(event);
13167
+ });
13168
+ } else if (strategy === "async") {
13169
+ var now = Date.now();
13170
+ LastChangeTime.set(node, now);
13171
+ var existingTimer = DebounceTimers.get(node);
13172
+ existingTimer && clearTimeout(existingTimer);
13173
+ var timer = setTimeout(async function() {
13174
+ var lastChange = LastChangeTime.get(node) || 0, timeSinceChange = Date.now() - lastChange;
13175
+ if (timeSinceChange >= DEBOUNCE_DELAY) {
13176
+ var event2 = await getElementLayoutEventAsync(node);
13177
+ onLayout(event2), DebounceTimers.delete(node);
13178
+ } else {
13179
+ var remainingDelay = DEBOUNCE_DELAY - timeSinceChange, newTimer = setTimeout(async function() {
13180
+ var event3 = await getElementLayoutEventAsync(node);
13181
+ onLayout(event3), DebounceTimers.delete(node);
13182
+ }, remainingDelay);
13183
+ DebounceTimers.set(node, newTimer);
13184
+ }
13185
+ }, DEBOUNCE_DELAY);
13186
+ DebounceTimers.set(node, timer);
13187
+ } else {
13188
+ var event1 = getElementLayoutEvent2(node);
13189
+ onLayout(event1);
13190
+ }
13191
+ }
13138
13192
  }
13139
13193
  rAF(layoutOnAnimationFrame);
13140
- }, updateLayoutIfChanged2 = updateLayoutIfChanged, layoutOnAnimationFrame2 = layoutOnAnimationFrame, avoidUpdates = !0, queuedUpdates = /* @__PURE__ */ new Map(), lastFrameAt = Date.now(), numDroppedFramesUntilPause = 2, (0, import_web.___onDidFinishClientRender)(function() {
13141
- avoidUpdates = !1, queuedUpdates && (queuedUpdates.forEach(function(cb) {
13142
- return cb();
13143
- }), queuedUpdates.clear());
13144
- }), rAF(layoutOnAnimationFrame));
13145
- var updateLayoutIfChanged, layoutOnAnimationFrame, updateLayoutIfChanged2, layoutOnAnimationFrame2, avoidUpdates, queuedUpdates, lastFrameAt, numDroppedFramesUntilPause, getElementLayoutEvent2 = function(target) {
13194
+ }
13195
+ var layoutOnAnimationFrame, layoutOnAnimationFrame2, avoidUpdates, queuedUpdates, lastFrameAt, numDroppedFramesUntilPause, getElementLayoutEvent2 = function(target) {
13146
13196
  var res = null;
13147
13197
  if (measureLayout(target, null, function(x, y, width, height, left, top) {
13148
13198
  res = {
@@ -13170,6 +13220,37 @@ var require_useElementLayout_native = __commonJS({
13170
13220
  callback(x, y, width, height, left, top);
13171
13221
  }
13172
13222
  }
13223
+ }, getElementLayoutEventAsync = async function(target) {
13224
+ var res = null;
13225
+ if (await measureLayoutAsync(target, null, function(x, y, width, height, left, top) {
13226
+ res = {
13227
+ nativeEvent: {
13228
+ layout: {
13229
+ x,
13230
+ y,
13231
+ width,
13232
+ height,
13233
+ left,
13234
+ top
13235
+ },
13236
+ target
13237
+ },
13238
+ timeStamp: Date.now()
13239
+ };
13240
+ }), !res) throw new Error("\u203C\uFE0F");
13241
+ return res;
13242
+ }, measureLayoutAsync = async function(node, relativeTo, callback) {
13243
+ var relativeNode = relativeTo || (node == null ? void 0 : node.parentElement);
13244
+ if (relativeNode instanceof HTMLElement) {
13245
+ var [nodeDim, relativeNodeDim] = await Promise.all([
13246
+ node.getBoundingClientRect(),
13247
+ relativeNode.getBoundingClientRect()
13248
+ ]);
13249
+ if (relativeNodeDim && nodeDim) {
13250
+ var { x, y, width, height, left, top } = getRelativeDimensions(nodeDim, relativeNodeDim);
13251
+ callback(x, y, width, height, left, top);
13252
+ }
13253
+ }
13173
13254
  }, getRelativeDimensions = function(a, b) {
13174
13255
  var { height, left, top, width } = a, x = left - b.left, y = top - b.top;
13175
13256
  return {
@@ -13189,6 +13270,8 @@ var require_useElementLayout_native = __commonJS({
13189
13270
  var node2 = (_ref_current2 = ref.current) === null || _ref_current2 === void 0 ? void 0 : _ref_current2.host;
13190
13271
  if (node2) return LayoutHandlers.set(node2, onLayout), Nodes.add(node2), onLayout(getElementLayoutEvent2(node2)), function() {
13191
13272
  Nodes.delete(node2), LayoutHandlers.delete(node2), NodeRectCache.delete(node2);
13273
+ var timer = DebounceTimers.get(node2);
13274
+ timer && (clearTimeout(timer), DebounceTimers.delete(node2)), LastChangeTime.delete(node2);
13192
13275
  };
13193
13276
  }
13194
13277
  }, [
@@ -15047,7 +15130,7 @@ var require_Accordion_native = __commonJS({
15047
15130
  }
15048
15131
  });
15049
15132
  module2.exports = __toCommonJS2(Accordion_exports);
15050
- 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 = [
15133
+ 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 = [
15051
15134
  "Home",
15052
15135
  "End",
15053
15136
  "ArrowDown",
@@ -15077,7 +15160,7 @@ var require_Accordion_native = __commonJS({
15077
15160
  ].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;
15078
15161
  }
15079
15162
  };
15080
- var { Provider: AccordionValueProvider, useStyledContext: useAccordionValueContext } = (0, import_web.createStyledContext)(), { Provider: AccordionCollapsibleProvider, useStyledContext: useAccordionCollapsibleContext } = (0, import_web.createStyledContext)(), AccordionImplSingle = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15163
+ var { Provider: AccordionValueProvider, useStyledContext: useAccordionValueContext } = (0, import_core12.createStyledContext)(), { Provider: AccordionCollapsibleProvider, useStyledContext: useAccordionCollapsibleContext } = (0, import_core12.createStyledContext)(), AccordionImplSingle = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15081
15164
  var { value: valueProp, defaultValue, control, onValueChange = function() {
15082
15165
  }, collapsible = !1, ...accordionSingleProps } = props, [value, setValue] = (0, import_use_controllable_state.useControllableState)({
15083
15166
  prop: valueProp,
@@ -15145,7 +15228,7 @@ var require_Accordion_native = __commonJS({
15145
15228
  })
15146
15229
  })
15147
15230
  });
15148
- }), { Provider: AccordionImplProvider, useStyledContext: useAccordionContext } = (0, import_web.createStyledContext)(), AccordionImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15231
+ }), { Provider: AccordionImplProvider, useStyledContext: useAccordionContext } = (0, import_core12.createStyledContext)(), AccordionImpl = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15149
15232
  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) {
15150
15233
  var _triggerCollection_clampedIndex_ref_current;
15151
15234
  if (ACCORDION_KEYS.includes(event.key)) {
@@ -15204,7 +15287,7 @@ var require_Accordion_native = __commonJS({
15204
15287
  })
15205
15288
  })
15206
15289
  });
15207
- }), ITEM_NAME = "AccordionItem", { Provider: AccordionItemProvider, useStyledContext: useAccordionItemContext } = (0, import_web.createStyledContext)(), AccordionItem = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15290
+ }), ITEM_NAME = "AccordionItem", { Provider: AccordionItemProvider, useStyledContext: useAccordionItemContext } = (0, import_core12.createStyledContext)(), AccordionItem = /* @__PURE__ */ React4.forwardRef(function(props, forwardedRef) {
15208
15291
  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;
15209
15292
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AccordionItemProvider, {
15210
15293
  scope: __scopeAccordion,
@@ -15237,7 +15320,7 @@ var require_Accordion_native = __commonJS({
15237
15320
  });
15238
15321
  });
15239
15322
  AccordionHeader.displayName = HEADER_NAME;
15240
- var AccordionTriggerFrame = (0, import_web.styled)(import_collapsible.Collapsible.Trigger, {
15323
+ var AccordionTriggerFrame = (0, import_core12.styled)(import_collapsible.Collapsible.Trigger, {
15241
15324
  variants: {
15242
15325
  unstyled: {
15243
15326
  false: {
@@ -15275,7 +15358,7 @@ var require_Accordion_native = __commonJS({
15275
15358
  ref: forwardedRef
15276
15359
  })
15277
15360
  });
15278
- }), AccordionContentFrame = (0, import_web.styled)(import_collapsible.Collapsible.Content, {
15361
+ }), AccordionContentFrame = (0, import_core12.styled)(import_collapsible.Collapsible.Content, {
15279
15362
  variants: {
15280
15363
  unstyled: {
15281
15364
  false: {
@@ -15298,20 +15381,19 @@ var require_Accordion_native = __commonJS({
15298
15381
  ...contentProps,
15299
15382
  ref: forwardedRef
15300
15383
  });
15301
- }), HeightAnimator = import_web.View.styleable(function(props, ref) {
15302
- var itemContext = useAccordionItemContext(), { children, ...rest } = props, [height, setHeight] = React4.useState(0), onLayout = (0, import_web.useEvent)(function(param) {
15303
- var { nativeEvent } = param;
15304
- nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
15305
- });
15306
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_web.View, {
15384
+ }), HeightAnimator = import_core12.View.styleable(function(props, ref) {
15385
+ var itemContext = useAccordionItemContext(), { children, ...rest } = props, [height, setHeight] = React4.useState(0);
15386
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core12.View, {
15307
15387
  ref,
15308
15388
  height: itemContext.open ? height : 0,
15309
15389
  ...rest,
15310
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_web.View, {
15390
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core12.View, {
15311
15391
  position: "absolute",
15312
15392
  width: "100%",
15313
- //@ts-ignore
15314
- onLayout,
15393
+ onLayout: function(param) {
15394
+ var { nativeEvent } = param;
15395
+ nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
15396
+ },
15315
15397
  children
15316
15398
  })
15317
15399
  });