@draftbit/core 48.5.3-2f0211.2 → 48.5.3-63926a.2

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.
@@ -1 +1 @@
1
- var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _utilities=require("../../utilities");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["reversed","children","style"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Layout/ZStack.tsx";var ZStack=function ZStack(_ref){var reversed=_ref.reversed,children=_ref.children,style=_ref.style,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var _React$useState=_react.default.useState(new Map()),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),childSizes=_React$useState2[0],setChildSizes=_React$useState2[1];var _React$useState3=_react.default.useState(),_React$useState4=(0,_slicedToArray2.default)(_React$useState3,2),maxChildWidth=_React$useState4[0],setMaxChildWidth=_React$useState4[1];var _React$useState5=_react.default.useState(),_React$useState6=(0,_slicedToArray2.default)(_React$useState5,2),maxChildHeight=_React$useState6[0],setMaxChildHeight=_React$useState6[1];var onChildLayout=_react.default.useCallback(function(index,width,height){var size={width:roundTo3DecimalPoints(width),height:roundTo3DecimalPoints(height)};setChildSizes(new Map(childSizes.set(index,size)));},[childSizes,setChildSizes]);var absoluteChildren=_react.default.useMemo(function(){var childrenArray=_react.default.Children.toArray(children);if(reversed){childrenArray=childrenArray.reverse();}return childrenArray.map(function(child,index){var props=child.props||{};return _react.default.cloneElement(child,Object.assign({},props,{onLayout:function onLayout(event){var layout=event.nativeEvent.layout;var fullWidth=layout.x+layout.width;var fullHeight=layout.y+layout.height;onChildLayout(index,fullWidth,fullHeight);props.onLayout==null?void 0:props.onLayout(event);},key:index,style:Object.assign({position:"absolute",zIndex:index+1},props.style)}),props.children);});},[children,reversed,onChildLayout]);_react.default.useEffect(function(){setChildSizes(new Map());},[absoluteChildren.length]);var childSizeValues=Array.from(childSizes.values());(0,_utilities.useDeepCompareEffect)(function(){var maxWidth=0;var maxHeight=0;childSizeValues.forEach(function(_ref2){var width=_ref2.width,height=_ref2.height;if(width>maxWidth){maxWidth=width;}if(height>maxHeight){maxHeight=height;}});setMaxChildWidth(maxWidth);setMaxChildHeight(maxHeight);},[childSizeValues,setMaxChildWidth,setMaxChildHeight]);return(0,_jsxRuntime.jsx)(_reactNative.View,Object.assign({style:[maxChildWidth&&maxChildHeight?{width:maxChildWidth,height:maxChildHeight}:{},style]},rest,{children:absoluteChildren}));};function roundTo3DecimalPoints(value){return Math.round(value*1000)/1000;}var _default=ZStack;exports.default=_default;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _slicedToArray2=_interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _jsxRuntime=require("react/jsx-runtime");var _excluded=["reversed","children","style"];var _this=this,_jsxFileName="/home/runner/work/react-native-jigsaw/react-native-jigsaw/packages/core/src/components/Layout/ZStack.tsx";var ZStack=function ZStack(_ref){var reversed=_ref.reversed,children=_ref.children,style=_ref.style,rest=(0,_objectWithoutProperties2.default)(_ref,_excluded);var childSizes=_react.default.useRef(new Map());var _React$useState=_react.default.useState(),_React$useState2=(0,_slicedToArray2.default)(_React$useState,2),maxChildWidth=_React$useState2[0],setMaxChildWidth=_React$useState2[1];var _React$useState3=_react.default.useState(),_React$useState4=(0,_slicedToArray2.default)(_React$useState3,2),maxChildHeight=_React$useState4[0],setMaxChildHeight=_React$useState4[1];var onChildLayout=_react.default.useCallback(function(index,width,height){childSizes.current.set(index,{width:width,height:height});var maxWidth=0;var maxHeight=0;for(var _ref2 of childSizes.current.values()){var _width=_ref2.width;var _height=_ref2.height;if(_width>maxWidth){maxWidth=_width;}if(_height>maxHeight){maxHeight=_height;}}setMaxChildWidth(maxWidth);setMaxChildHeight(maxHeight);},[setMaxChildWidth,setMaxChildHeight]);var absoluteChildren=_react.default.useMemo(function(){var childrenArray=_react.default.Children.toArray(children);if(reversed){childrenArray=childrenArray.reverse();}return childrenArray.map(function(child,index){var props=child.props||{};return _react.default.cloneElement(child,Object.assign({},props,{onLayout:function onLayout(event){var layout=event.nativeEvent.layout;var fullWidth=layout.x+layout.width;var fullHeight=layout.y+layout.height;onChildLayout(index,fullWidth,fullHeight);props.onLayout==null?void 0:props.onLayout(event);},key:index,style:Object.assign({position:"absolute",zIndex:index+1},props.style)}),props.children);});},[children,reversed,onChildLayout]);_react.default.useEffect(function(){childSizes.current.clear();},[absoluteChildren.length]);return(0,_jsxRuntime.jsx)(_reactNative.View,Object.assign({style:[maxChildWidth&&maxChildHeight?{width:maxChildWidth,height:maxChildHeight}:{},style]},rest,{children:absoluteChildren}));};var _default=ZStack;exports.default=_default;
@@ -1,17 +1,27 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
- import { useDeepCompareEffect } from "../../utilities";
4
3
  const ZStack = ({ reversed, children, style, ...rest }) => {
5
- const [childSizes, setChildSizes] = React.useState(new Map());
4
+ const childSizes = React.useRef(new Map());
6
5
  const [maxChildWidth, setMaxChildWidth] = React.useState();
7
6
  const [maxChildHeight, setMaxChildHeight] = React.useState();
8
7
  const onChildLayout = React.useCallback((index, width, height) => {
9
- const size = {
10
- width: roundTo3DecimalPoints(width),
11
- height: roundTo3DecimalPoints(height),
12
- };
13
- setChildSizes(new Map(childSizes.set(index, size)));
14
- }, [childSizes, setChildSizes]);
8
+ childSizes.current.set(index, {
9
+ width,
10
+ height,
11
+ });
12
+ let maxWidth = 0;
13
+ let maxHeight = 0;
14
+ for (const { width, height } of childSizes.current.values()) {
15
+ if (width > maxWidth) {
16
+ maxWidth = width;
17
+ }
18
+ if (height > maxHeight) {
19
+ maxHeight = height;
20
+ }
21
+ }
22
+ setMaxChildWidth(maxWidth);
23
+ setMaxChildHeight(maxHeight);
24
+ }, [setMaxChildWidth, setMaxChildHeight]);
15
25
  const absoluteChildren = React.useMemo(() => {
16
26
  let childrenArray = React.Children.toArray(children);
17
27
  if (reversed) {
@@ -35,23 +45,8 @@ const ZStack = ({ reversed, children, style, ...rest }) => {
35
45
  });
36
46
  }, [children, reversed, onChildLayout]);
37
47
  React.useEffect(() => {
38
- setChildSizes(new Map());
48
+ childSizes.current.clear();
39
49
  }, [absoluteChildren.length]);
40
- const childSizeValues = Array.from(childSizes.values());
41
- useDeepCompareEffect(() => {
42
- let maxWidth = 0;
43
- let maxHeight = 0;
44
- childSizeValues.forEach(({ width, height }) => {
45
- if (width > maxWidth) {
46
- maxWidth = width;
47
- }
48
- if (height > maxHeight) {
49
- maxHeight = height;
50
- }
51
- });
52
- setMaxChildWidth(maxWidth);
53
- setMaxChildHeight(maxHeight);
54
- }, [childSizeValues, setMaxChildWidth, setMaxChildHeight]);
55
50
  return (React.createElement(View, { style: [
56
51
  maxChildWidth && maxChildHeight
57
52
  ? { width: maxChildWidth, height: maxChildHeight }
@@ -59,8 +54,5 @@ const ZStack = ({ reversed, children, style, ...rest }) => {
59
54
  style,
60
55
  ], ...rest }, absoluteChildren));
61
56
  };
62
- function roundTo3DecimalPoints(value) {
63
- return Math.round(value * 1000) / 1000;
64
- }
65
57
  export default ZStack;
66
58
  //# sourceMappingURL=ZStack.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ZStack.js","sourceRoot":"","sources":["../../../../../src/components/Layout/ZStack.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAgC,MAAM,cAAc,CAAC;AACl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