@butternutbox/pawprint-native 0.10.9 → 0.10.11
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +36 -0
- package/dist/index.cjs +85 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +85 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/Drawer/DrawerBody.tsx +15 -2
- package/src/components/molecules/Drawer/DrawerContent.tsx +132 -42
- package/src/components/molecules/Drawer/DrawerMeasureContext.ts +18 -0
- package/src/components/molecules/NumberField/NumberField.tsx +5 -1
package/dist/index.js
CHANGED
|
@@ -8838,6 +8838,8 @@ var DrawerOverlay = React65.forwardRef(({ accessible = false }, _ref) => {
|
|
|
8838
8838
|
DrawerOverlay.displayName = "Drawer.Overlay";
|
|
8839
8839
|
var DrawerDragContext = React65.createContext(null);
|
|
8840
8840
|
var useDrawerDragContext = () => React65.useContext(DrawerDragContext);
|
|
8841
|
+
var DrawerMeasureContext = createContext(null);
|
|
8842
|
+
var useDrawerMeasureContext = () => useContext(DrawerMeasureContext);
|
|
8841
8843
|
var DrawerFooterContext = React65.createContext(false);
|
|
8842
8844
|
var useDrawerFooterContext = () => React65.useContext(DrawerFooterContext);
|
|
8843
8845
|
var DrawerHeaderContext = React65.createContext(null);
|
|
@@ -8856,17 +8858,12 @@ var StyledPanel2 = styled50(View)(
|
|
|
8856
8858
|
panelShadowColor,
|
|
8857
8859
|
panelShadowOffsetY,
|
|
8858
8860
|
panelShadowBlur,
|
|
8859
|
-
|
|
8860
|
-
}) => ({
|
|
8861
|
+
panelFlex
|
|
8862
|
+
}) => __spreadProps(__spreadValues({
|
|
8861
8863
|
width: "100%",
|
|
8862
8864
|
maxWidth: panelMaxWidth,
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
// automatically whenever the body grows or shrinks (async load, expanding
|
|
8866
|
-
// sections). The body's own maxHeight (see DrawerBody) bounds scrolling and
|
|
8867
|
-
// keeps the ScrollView from collapsing, so no fixed panel height is needed.
|
|
8868
|
-
maxHeight: panelMaxHeight,
|
|
8869
|
-
alignSelf: "center",
|
|
8865
|
+
alignSelf: "center"
|
|
8866
|
+
}, panelFlex != null ? { flex: panelFlex } : void 0), {
|
|
8870
8867
|
borderTopLeftRadius: panelBorderRadius,
|
|
8871
8868
|
borderTopRightRadius: panelBorderRadius,
|
|
8872
8869
|
borderTopWidth: panelBorderWidth,
|
|
@@ -8892,6 +8889,7 @@ var DrawerContent = React65.forwardRef(
|
|
|
8892
8889
|
const { isOpen, closeDrawer, onExitComplete } = useDrawerContext();
|
|
8893
8890
|
const { height: windowHeight } = useWindowDimensions();
|
|
8894
8891
|
const maxHeight = windowHeight * 0.9;
|
|
8892
|
+
const bodyMaxHeight = windowHeight - 300;
|
|
8895
8893
|
const closeDrawerRef = useRef(closeDrawer);
|
|
8896
8894
|
useEffect(() => {
|
|
8897
8895
|
closeDrawerRef.current = closeDrawer;
|
|
@@ -8902,12 +8900,22 @@ var DrawerContent = React65.forwardRef(
|
|
|
8902
8900
|
const entryRanRef = useRef(false);
|
|
8903
8901
|
const isOpenRef = useRef(isOpen);
|
|
8904
8902
|
const activeAnim = useRef(null);
|
|
8903
|
+
const [panelHeight, setPanelHeight] = useState(0);
|
|
8904
|
+
const chromeRef = useRef(0);
|
|
8905
|
+
const bodyContentRef = useRef(0);
|
|
8906
|
+
const firstNaturalRef = useRef(0);
|
|
8905
8907
|
useEffect(() => {
|
|
8906
8908
|
const id = translateY.addListener(({ value }) => {
|
|
8907
8909
|
translateYValue.current = value;
|
|
8908
8910
|
});
|
|
8909
8911
|
return () => translateY.removeListener(id);
|
|
8910
8912
|
}, [translateY]);
|
|
8913
|
+
useEffect(() => {
|
|
8914
|
+
if (panelHeightRef.current > 0 && panelHeightRef.current > maxHeight) {
|
|
8915
|
+
setPanelHeight(maxHeight);
|
|
8916
|
+
panelHeightRef.current = maxHeight;
|
|
8917
|
+
}
|
|
8918
|
+
}, [maxHeight]);
|
|
8911
8919
|
const runEntry = useCallback(() => {
|
|
8912
8920
|
var _a3;
|
|
8913
8921
|
if (panelHeightRef.current === 0) return;
|
|
@@ -8954,17 +8962,59 @@ var DrawerContent = React65.forwardRef(
|
|
|
8954
8962
|
runExit();
|
|
8955
8963
|
}
|
|
8956
8964
|
}, [isOpen, runEntry, runExit]);
|
|
8965
|
+
const applyRefit = useCallback(() => {
|
|
8966
|
+
const chrome = chromeRef.current;
|
|
8967
|
+
const content = bodyContentRef.current;
|
|
8968
|
+
if (chrome <= 0 || content <= 0) return;
|
|
8969
|
+
const desired = Math.min(
|
|
8970
|
+
chrome + Math.min(content, bodyMaxHeight),
|
|
8971
|
+
maxHeight
|
|
8972
|
+
);
|
|
8973
|
+
if (Math.abs(desired - panelHeightRef.current) > 1) {
|
|
8974
|
+
panelHeightRef.current = desired;
|
|
8975
|
+
setPanelHeight(desired);
|
|
8976
|
+
}
|
|
8977
|
+
}, [bodyMaxHeight, maxHeight]);
|
|
8978
|
+
const lockChrome = useCallback(() => {
|
|
8979
|
+
if (chromeRef.current > 0) return;
|
|
8980
|
+
const natural = firstNaturalRef.current;
|
|
8981
|
+
const content = bodyContentRef.current;
|
|
8982
|
+
if (natural <= 0 || content <= 0) return;
|
|
8983
|
+
chromeRef.current = natural - Math.min(content, bodyMaxHeight);
|
|
8984
|
+
}, [bodyMaxHeight]);
|
|
8985
|
+
const setBodyContentHeight = useCallback(
|
|
8986
|
+
(height) => {
|
|
8987
|
+
if (height <= 0) return;
|
|
8988
|
+
bodyContentRef.current = height;
|
|
8989
|
+
lockChrome();
|
|
8990
|
+
applyRefit();
|
|
8991
|
+
},
|
|
8992
|
+
[lockChrome, applyRefit]
|
|
8993
|
+
);
|
|
8994
|
+
const measureContextValue = useMemo(
|
|
8995
|
+
() => ({ setBodyContentHeight }),
|
|
8996
|
+
[setBodyContentHeight]
|
|
8997
|
+
);
|
|
8957
8998
|
const onLayout = useCallback(
|
|
8958
8999
|
({ nativeEvent }) => {
|
|
8959
9000
|
const h = nativeEvent.layout.height;
|
|
8960
9001
|
const capped = Math.min(h, maxHeight);
|
|
8961
9002
|
if (capped <= 0) return;
|
|
8962
|
-
|
|
8963
|
-
if (
|
|
9003
|
+
if (entryRanRef.current) return;
|
|
9004
|
+
if (chromeRef.current <= 0) {
|
|
9005
|
+
firstNaturalRef.current = h;
|
|
9006
|
+
lockChrome();
|
|
9007
|
+
}
|
|
9008
|
+
if (capped !== panelHeightRef.current) {
|
|
9009
|
+
panelHeightRef.current = capped;
|
|
9010
|
+
setPanelHeight(capped);
|
|
9011
|
+
}
|
|
9012
|
+
if (isOpenRef.current) {
|
|
8964
9013
|
runEntry();
|
|
8965
9014
|
}
|
|
9015
|
+
applyRefit();
|
|
8966
9016
|
},
|
|
8967
|
-
[runEntry, maxHeight]
|
|
9017
|
+
[runEntry, maxHeight, lockChrome, applyRefit]
|
|
8968
9018
|
);
|
|
8969
9019
|
const panResponder = useRef(
|
|
8970
9020
|
PanResponder.create({
|
|
@@ -9033,10 +9083,14 @@ var DrawerContent = React65.forwardRef(
|
|
|
9033
9083
|
const headerContextValue = headerChild != null ? {
|
|
9034
9084
|
variant: (_a2 = headerChild.props.variant) != null ? _a2 : "titleAndText"
|
|
9035
9085
|
} : null;
|
|
9036
|
-
return /* @__PURE__ */ jsx(DrawerHeaderContext.Provider, { value: headerContextValue, children: /* @__PURE__ */ jsx(DrawerFooterContext.Provider, { value: hasFooter, children: /* @__PURE__ */ jsx(DrawerDragContext.Provider, { value: dragContextValue, children: /* @__PURE__ */ jsx(
|
|
9086
|
+
return /* @__PURE__ */ jsx(DrawerHeaderContext.Provider, { value: headerContextValue, children: /* @__PURE__ */ jsx(DrawerFooterContext.Provider, { value: hasFooter, children: /* @__PURE__ */ jsx(DrawerMeasureContext.Provider, { value: measureContextValue, children: /* @__PURE__ */ jsx(DrawerDragContext.Provider, { value: dragContextValue, children: /* @__PURE__ */ jsx(
|
|
9037
9087
|
Animated.View,
|
|
9038
9088
|
{
|
|
9039
|
-
style: [
|
|
9089
|
+
style: [
|
|
9090
|
+
styles.animatedWrapper,
|
|
9091
|
+
panelHeight > 0 ? { height: panelHeight } : void 0,
|
|
9092
|
+
{ transform: [{ translateY }] }
|
|
9093
|
+
],
|
|
9040
9094
|
children: /* @__PURE__ */ jsx(
|
|
9041
9095
|
StyledPanel2,
|
|
9042
9096
|
__spreadProps(__spreadValues({
|
|
@@ -9045,7 +9099,7 @@ var DrawerContent = React65.forwardRef(
|
|
|
9045
9099
|
panelBorderRadius: parseTokenValue22(drawer.borderRadius.top),
|
|
9046
9100
|
panelBgColor: colour.background.container.default,
|
|
9047
9101
|
panelMaxWidth: parseTokenValue22(drawer.size.maxWidth),
|
|
9048
|
-
|
|
9102
|
+
panelFlex: panelHeight > 0 ? 1 : void 0,
|
|
9049
9103
|
panelBorderWidth: parseTokenValue22(dimensions3.borderWidth.sm),
|
|
9050
9104
|
panelBorderColor: colour.border.default,
|
|
9051
9105
|
panelShadowColor: modal.shadow.color,
|
|
@@ -9059,7 +9113,7 @@ var DrawerContent = React65.forwardRef(
|
|
|
9059
9113
|
})
|
|
9060
9114
|
)
|
|
9061
9115
|
}
|
|
9062
|
-
) }) }) });
|
|
9116
|
+
) }) }) }) });
|
|
9063
9117
|
}
|
|
9064
9118
|
);
|
|
9065
9119
|
DrawerContent.displayName = "Drawer.Content";
|
|
@@ -9375,14 +9429,22 @@ var StyledScrollView = styled50(ScrollView)(
|
|
|
9375
9429
|
);
|
|
9376
9430
|
var DrawerBody = React65.forwardRef(
|
|
9377
9431
|
(_a, ref) => {
|
|
9378
|
-
var _b = _a, { children, contentContainerStyle } = _b, props = __objRest(_b, ["children", "contentContainerStyle"]);
|
|
9432
|
+
var _b = _a, { children, contentContainerStyle, onContentSizeChange } = _b, props = __objRest(_b, ["children", "contentContainerStyle", "onContentSizeChange"]);
|
|
9379
9433
|
const theme2 = useTheme();
|
|
9380
9434
|
const { spacing } = theme2.tokens.components.drawer;
|
|
9381
9435
|
const { buttons } = theme2.tokens.components;
|
|
9382
9436
|
const { content } = spacing;
|
|
9383
9437
|
const headerContext = useDrawerHeaderContext();
|
|
9384
9438
|
const footerContext = useDrawerFooterContext();
|
|
9439
|
+
const measureContext = useDrawerMeasureContext();
|
|
9385
9440
|
const { height: windowHeight } = useWindowDimensions();
|
|
9441
|
+
const handleContentSizeChange = useCallback(
|
|
9442
|
+
(width, height) => {
|
|
9443
|
+
measureContext == null ? void 0 : measureContext.setBodyContentHeight(height);
|
|
9444
|
+
onContentSizeChange == null ? void 0 : onContentSizeChange(width, height);
|
|
9445
|
+
},
|
|
9446
|
+
[measureContext, onContentSizeChange]
|
|
9447
|
+
);
|
|
9386
9448
|
const gap = parseTokenValue26(content.slot.gap);
|
|
9387
9449
|
const horizontalPadding = parseTokenValue26(content.slot.horizontalPadding);
|
|
9388
9450
|
const topPadding = parseTokenValue26(content.slot.verticalPadding);
|
|
@@ -9398,6 +9460,7 @@ var DrawerBody = React65.forwardRef(
|
|
|
9398
9460
|
bodyGap: gap,
|
|
9399
9461
|
bodyMaxHeight,
|
|
9400
9462
|
bodyPaddingBottom,
|
|
9463
|
+
onContentSizeChange: handleContentSizeChange,
|
|
9401
9464
|
contentContainerStyle: [
|
|
9402
9465
|
{
|
|
9403
9466
|
gap,
|
|
@@ -10472,7 +10535,7 @@ NumberFieldInput.displayName = "NumberField.Input";
|
|
|
10472
10535
|
var parseTokenValue35 = (value) => parseFloat(value);
|
|
10473
10536
|
var StyledRoot10 = styled50(View)(({ rootGap, fullWidth }) => __spreadValues({
|
|
10474
10537
|
gap: rootGap
|
|
10475
|
-
}, fullWidth
|
|
10538
|
+
}, fullWidth ? { width: "100%" } : { alignItems: "center" }));
|
|
10476
10539
|
var StyledLabelGroup = styled50(View)(({ labelGap }) => ({
|
|
10477
10540
|
gap: labelGap
|
|
10478
10541
|
}));
|
|
@@ -10536,6 +10599,7 @@ var NumberField = React65.forwardRef(
|
|
|
10536
10599
|
{
|
|
10537
10600
|
token: typoTokens.label,
|
|
10538
10601
|
color: tokens3.colour.text.label,
|
|
10602
|
+
align: "center",
|
|
10539
10603
|
children: label
|
|
10540
10604
|
}
|
|
10541
10605
|
),
|
|
@@ -10544,6 +10608,7 @@ var NumberField = React65.forwardRef(
|
|
|
10544
10608
|
{
|
|
10545
10609
|
token: typoTokens.smallLabel,
|
|
10546
10610
|
color: tokens3.colour.text.description,
|
|
10611
|
+
align: "center",
|
|
10547
10612
|
children: smallLabel
|
|
10548
10613
|
}
|
|
10549
10614
|
)
|
|
@@ -10573,6 +10638,7 @@ var NumberField = React65.forwardRef(
|
|
|
10573
10638
|
{
|
|
10574
10639
|
token: size === "lg" ? tokens3.typography.large.secondaryContent : tokens3.typography.small.smallLabel,
|
|
10575
10640
|
color: tokens3.colour.text.description,
|
|
10641
|
+
align: "center",
|
|
10576
10642
|
children: description
|
|
10577
10643
|
}
|
|
10578
10644
|
),
|
|
@@ -10581,6 +10647,7 @@ var NumberField = React65.forwardRef(
|
|
|
10581
10647
|
{
|
|
10582
10648
|
token: size === "lg" ? tokens3.typography.large.secondaryContent : tokens3.typography.small.smallLabel,
|
|
10583
10649
|
color: theme2.tokens.components.inputs.colour.description.error,
|
|
10650
|
+
align: "center",
|
|
10584
10651
|
children: error
|
|
10585
10652
|
}
|
|
10586
10653
|
)
|