@butternutbox/pawprint-native 1.2.0 → 1.3.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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +57 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +273 -236
- package/dist/index.d.ts +273 -236
- package/dist/index.js +57 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/Menu/Menu.stories.tsx +19 -55
- package/src/components/molecules/Menu/Menu.test.tsx +55 -1
- package/src/components/molecules/Menu/Menu.tsx +56 -31
- package/src/components/molecules/Menu/MenuItem.tsx +32 -39
- package/src/components/molecules/Menu/hooks/index.ts +1 -0
- package/src/components/molecules/Menu/hooks/useMenuTrigger.test.ts +48 -0
- package/src/components/molecules/Menu/hooks/useMenuTrigger.ts +40 -0
- package/src/components/molecules/Menu/index.ts +2 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
[34mCJS[39m Build start
|
|
8
8
|
[34mESM[39m Build start
|
|
9
9
|
[34mDTS[39m Build start
|
|
10
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
10
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m564.54 KB[39m
|
|
11
11
|
[32mCJS[39m [1mdist/index.cjs.map [22m[32m1.10 MB[39m
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 6535ms
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m533.47 KB[39m
|
|
14
14
|
[32mESM[39m [1mdist/index.js.map [22m[32m1.10 MB[39m
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 6536ms
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 17552ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m111.87 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m111.87 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -10658,46 +10658,37 @@ var Tooltip = React66__default.default.forwardRef(
|
|
|
10658
10658
|
);
|
|
10659
10659
|
Tooltip.displayName = "Tooltip";
|
|
10660
10660
|
var parseTokenValue53 = (value) => parseFloat(value);
|
|
10661
|
-
var Row = styled51__default.default(reactNative.Pressable)(({ theme: theme2
|
|
10661
|
+
var Row = styled51__default.default(reactNative.Pressable)(({ theme: theme2 }) => {
|
|
10662
10662
|
const { spacing } = theme2.tokens.semantics.dimensions;
|
|
10663
|
-
const { colour } = theme2.tokens.semantics;
|
|
10664
10663
|
return {
|
|
10665
10664
|
width: "100%",
|
|
10666
|
-
alignItems: "
|
|
10665
|
+
alignItems: "flex-start",
|
|
10667
10666
|
justifyContent: "center",
|
|
10668
10667
|
paddingVertical: parseTokenValue53(spacing.md),
|
|
10669
|
-
paddingHorizontal: parseTokenValue53(spacing.md)
|
|
10670
|
-
borderBottomWidth: divider ? 1 : 0,
|
|
10671
|
-
borderBottomColor: colour.border.divider
|
|
10668
|
+
paddingHorizontal: parseTokenValue53(spacing.md)
|
|
10672
10669
|
};
|
|
10673
10670
|
});
|
|
10674
10671
|
var MenuItem = React66__default.default.forwardRef((_a, ref) => {
|
|
10675
10672
|
var _b = _a, { variant = "action", onPress, children, divider = true } = _b, rest = __objRest(_b, ["variant", "onPress", "children", "divider"]);
|
|
10676
10673
|
const theme2 = react.useTheme();
|
|
10677
10674
|
const { colour, typography } = theme2.tokens.semantics;
|
|
10678
|
-
const labelColour = variant === "destructive" ? colour.text.error : colour.text.
|
|
10675
|
+
const labelColour = variant === "destructive" ? colour.text.error : colour.text.link.default;
|
|
10679
10676
|
const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
10680
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10694
|
-
|
|
10695
|
-
color: labelColour,
|
|
10696
|
-
children: label
|
|
10697
|
-
}
|
|
10698
|
-
) : children
|
|
10699
|
-
})
|
|
10700
|
-
);
|
|
10677
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
10678
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10679
|
+
Row,
|
|
10680
|
+
__spreadProps(__spreadValues({
|
|
10681
|
+
ref,
|
|
10682
|
+
onPress,
|
|
10683
|
+
accessible: true,
|
|
10684
|
+
accessibilityRole: "menuitem",
|
|
10685
|
+
accessibilityLabel: label
|
|
10686
|
+
}, rest), {
|
|
10687
|
+
children: label !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Typography, { token: typography.body.medium.md, color: labelColour, children: label }) : children
|
|
10688
|
+
})
|
|
10689
|
+
),
|
|
10690
|
+
divider && /* @__PURE__ */ jsxRuntime.jsx(Divider, {})
|
|
10691
|
+
] });
|
|
10701
10692
|
});
|
|
10702
10693
|
MenuItem.displayName = "Menu.Item";
|
|
10703
10694
|
var parseTokenValue54 = (value) => parseFloat(value);
|
|
@@ -10708,18 +10699,14 @@ var DismissLayer = styled51__default.default(reactNative.Pressable)({
|
|
|
10708
10699
|
right: 0,
|
|
10709
10700
|
bottom: 0
|
|
10710
10701
|
});
|
|
10711
|
-
var Anchor = styled51__default.default(reactNative.View)(
|
|
10712
|
-
|
|
10713
|
-
return __spreadValues({
|
|
10714
|
-
position: "absolute"
|
|
10715
|
-
}, align === "right" ? { right: inset } : { left: inset });
|
|
10702
|
+
var Anchor = styled51__default.default(reactNative.View)({
|
|
10703
|
+
position: "absolute"
|
|
10716
10704
|
});
|
|
10717
10705
|
var Card = styled51__default.default(reactNative.Pressable)(({ theme: theme2, width }) => {
|
|
10718
10706
|
const { borderRadius } = theme2.tokens.semantics.dimensions;
|
|
10719
10707
|
const { shadow, background } = theme2.tokens.semantics.colour;
|
|
10720
10708
|
return {
|
|
10721
10709
|
width,
|
|
10722
|
-
maxWidth: "90%",
|
|
10723
10710
|
borderRadius: parseTokenValue54(borderRadius.md),
|
|
10724
10711
|
overflow: "hidden",
|
|
10725
10712
|
backgroundColor: background.surface.default,
|
|
@@ -10737,12 +10724,25 @@ var Card = styled51__default.default(reactNative.Pressable)(({ theme: theme2, wi
|
|
|
10737
10724
|
var MenuRoot = ({
|
|
10738
10725
|
open,
|
|
10739
10726
|
onClose,
|
|
10727
|
+
anchor,
|
|
10740
10728
|
anchorOffset = 0,
|
|
10741
10729
|
align = "right",
|
|
10742
|
-
width =
|
|
10730
|
+
width = 280,
|
|
10743
10731
|
closeAccessibilityLabel = "Close menu",
|
|
10744
10732
|
children
|
|
10745
10733
|
}) => {
|
|
10734
|
+
const theme2 = react.useTheme();
|
|
10735
|
+
const { width: windowWidth } = reactNative.useWindowDimensions();
|
|
10736
|
+
const { spacing } = theme2.tokens.semantics.dimensions;
|
|
10737
|
+
const [lastAnchor, setLastAnchor] = React66.useState(anchor);
|
|
10738
|
+
if (anchor && anchor !== lastAnchor) setLastAnchor(anchor);
|
|
10739
|
+
const shownAnchor = anchor != null ? anchor : lastAnchor;
|
|
10740
|
+
const position = shownAnchor ? __spreadValues({
|
|
10741
|
+
top: shownAnchor.y + shownAnchor.height + parseTokenValue54(spacing.xs)
|
|
10742
|
+
}, align === "right" ? { right: windowWidth - (shownAnchor.x + shownAnchor.width) } : { left: shownAnchor.x }) : {
|
|
10743
|
+
top: anchorOffset,
|
|
10744
|
+
[align]: parseTokenValue54(spacing.md)
|
|
10745
|
+
};
|
|
10746
10746
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10747
10747
|
reactNative.Modal,
|
|
10748
10748
|
{
|
|
@@ -10760,10 +10760,10 @@ var MenuRoot = ({
|
|
|
10760
10760
|
accessibilityLabel: closeAccessibilityLabel
|
|
10761
10761
|
}
|
|
10762
10762
|
),
|
|
10763
|
-
/* @__PURE__ */ jsxRuntime.jsx(Anchor, {
|
|
10763
|
+
/* @__PURE__ */ jsxRuntime.jsx(Anchor, { style: position, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10764
10764
|
Card,
|
|
10765
10765
|
{
|
|
10766
|
-
width,
|
|
10766
|
+
width: Math.min(width, windowWidth * 0.9),
|
|
10767
10767
|
onPress: () => {
|
|
10768
10768
|
},
|
|
10769
10769
|
accessible: false,
|
|
@@ -10779,6 +10779,25 @@ MenuRoot.displayName = "Menu";
|
|
|
10779
10779
|
var Menu2 = Object.assign(MenuRoot, {
|
|
10780
10780
|
Item: MenuItem
|
|
10781
10781
|
});
|
|
10782
|
+
var useMenuTrigger = () => {
|
|
10783
|
+
const triggerRef = React66.useRef(null);
|
|
10784
|
+
const [anchor, setAnchor] = React66.useState();
|
|
10785
|
+
const open = React66.useCallback(() => {
|
|
10786
|
+
var _a;
|
|
10787
|
+
(_a = triggerRef.current) == null ? void 0 : _a.measureInWindow(
|
|
10788
|
+
(x, y, width, height) => setAnchor({ x, y, width, height })
|
|
10789
|
+
);
|
|
10790
|
+
}, []);
|
|
10791
|
+
const close = React66.useCallback(() => setAnchor(void 0), []);
|
|
10792
|
+
const isOpen = anchor !== void 0;
|
|
10793
|
+
return {
|
|
10794
|
+
triggerRef,
|
|
10795
|
+
isOpen,
|
|
10796
|
+
open,
|
|
10797
|
+
close,
|
|
10798
|
+
menuProps: { open: isOpen, onClose: close, anchor }
|
|
10799
|
+
};
|
|
10800
|
+
};
|
|
10782
10801
|
var parseTokenValue55 = (value) => parseFloat(value);
|
|
10783
10802
|
var StyledInsightRoot = styled51__default.default(reactNative.View)(
|
|
10784
10803
|
({
|
|
@@ -12926,6 +12945,7 @@ exports.slideOutAnimation = slideOutAnimation;
|
|
|
12926
12945
|
exports.theme = theme;
|
|
12927
12946
|
exports.useCopyField = useCopyField;
|
|
12928
12947
|
exports.useDrawerKeyboardAvoidance = useDrawerKeyboardAvoidance;
|
|
12948
|
+
exports.useMenuTrigger = useMenuTrigger;
|
|
12929
12949
|
exports.usePasswordField = usePasswordField;
|
|
12930
12950
|
exports.usePawprint = usePawprint;
|
|
12931
12951
|
exports.useSearchField = useSearchField;
|