@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/dist/index.js
CHANGED
|
@@ -10627,46 +10627,37 @@ var Tooltip = React66.forwardRef(
|
|
|
10627
10627
|
);
|
|
10628
10628
|
Tooltip.displayName = "Tooltip";
|
|
10629
10629
|
var parseTokenValue53 = (value) => parseFloat(value);
|
|
10630
|
-
var Row = styled51(Pressable)(({ theme: theme2
|
|
10630
|
+
var Row = styled51(Pressable)(({ theme: theme2 }) => {
|
|
10631
10631
|
const { spacing } = theme2.tokens.semantics.dimensions;
|
|
10632
|
-
const { colour } = theme2.tokens.semantics;
|
|
10633
10632
|
return {
|
|
10634
10633
|
width: "100%",
|
|
10635
|
-
alignItems: "
|
|
10634
|
+
alignItems: "flex-start",
|
|
10636
10635
|
justifyContent: "center",
|
|
10637
10636
|
paddingVertical: parseTokenValue53(spacing.md),
|
|
10638
|
-
paddingHorizontal: parseTokenValue53(spacing.md)
|
|
10639
|
-
borderBottomWidth: divider ? 1 : 0,
|
|
10640
|
-
borderBottomColor: colour.border.divider
|
|
10637
|
+
paddingHorizontal: parseTokenValue53(spacing.md)
|
|
10641
10638
|
};
|
|
10642
10639
|
});
|
|
10643
10640
|
var MenuItem = React66.forwardRef((_a, ref) => {
|
|
10644
10641
|
var _b = _a, { variant = "action", onPress, children, divider = true } = _b, rest = __objRest(_b, ["variant", "onPress", "children", "divider"]);
|
|
10645
10642
|
const theme2 = useTheme();
|
|
10646
10643
|
const { colour, typography } = theme2.tokens.semantics;
|
|
10647
|
-
const labelColour = variant === "destructive" ? colour.text.error : colour.text.
|
|
10644
|
+
const labelColour = variant === "destructive" ? colour.text.error : colour.text.link.default;
|
|
10648
10645
|
const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
10649
|
-
return /* @__PURE__ */
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10661
|
-
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
color: labelColour,
|
|
10665
|
-
children: label
|
|
10666
|
-
}
|
|
10667
|
-
) : children
|
|
10668
|
-
})
|
|
10669
|
-
);
|
|
10646
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10647
|
+
/* @__PURE__ */ jsx(
|
|
10648
|
+
Row,
|
|
10649
|
+
__spreadProps(__spreadValues({
|
|
10650
|
+
ref,
|
|
10651
|
+
onPress,
|
|
10652
|
+
accessible: true,
|
|
10653
|
+
accessibilityRole: "menuitem",
|
|
10654
|
+
accessibilityLabel: label
|
|
10655
|
+
}, rest), {
|
|
10656
|
+
children: label !== void 0 ? /* @__PURE__ */ jsx(Typography, { token: typography.body.medium.md, color: labelColour, children: label }) : children
|
|
10657
|
+
})
|
|
10658
|
+
),
|
|
10659
|
+
divider && /* @__PURE__ */ jsx(Divider, {})
|
|
10660
|
+
] });
|
|
10670
10661
|
});
|
|
10671
10662
|
MenuItem.displayName = "Menu.Item";
|
|
10672
10663
|
var parseTokenValue54 = (value) => parseFloat(value);
|
|
@@ -10677,18 +10668,14 @@ var DismissLayer = styled51(Pressable)({
|
|
|
10677
10668
|
right: 0,
|
|
10678
10669
|
bottom: 0
|
|
10679
10670
|
});
|
|
10680
|
-
var Anchor = styled51(View)(
|
|
10681
|
-
|
|
10682
|
-
return __spreadValues({
|
|
10683
|
-
position: "absolute"
|
|
10684
|
-
}, align === "right" ? { right: inset } : { left: inset });
|
|
10671
|
+
var Anchor = styled51(View)({
|
|
10672
|
+
position: "absolute"
|
|
10685
10673
|
});
|
|
10686
10674
|
var Card = styled51(Pressable)(({ theme: theme2, width }) => {
|
|
10687
10675
|
const { borderRadius } = theme2.tokens.semantics.dimensions;
|
|
10688
10676
|
const { shadow, background } = theme2.tokens.semantics.colour;
|
|
10689
10677
|
return {
|
|
10690
10678
|
width,
|
|
10691
|
-
maxWidth: "90%",
|
|
10692
10679
|
borderRadius: parseTokenValue54(borderRadius.md),
|
|
10693
10680
|
overflow: "hidden",
|
|
10694
10681
|
backgroundColor: background.surface.default,
|
|
@@ -10706,12 +10693,25 @@ var Card = styled51(Pressable)(({ theme: theme2, width }) => {
|
|
|
10706
10693
|
var MenuRoot = ({
|
|
10707
10694
|
open,
|
|
10708
10695
|
onClose,
|
|
10696
|
+
anchor,
|
|
10709
10697
|
anchorOffset = 0,
|
|
10710
10698
|
align = "right",
|
|
10711
|
-
width =
|
|
10699
|
+
width = 280,
|
|
10712
10700
|
closeAccessibilityLabel = "Close menu",
|
|
10713
10701
|
children
|
|
10714
10702
|
}) => {
|
|
10703
|
+
const theme2 = useTheme();
|
|
10704
|
+
const { width: windowWidth } = useWindowDimensions();
|
|
10705
|
+
const { spacing } = theme2.tokens.semantics.dimensions;
|
|
10706
|
+
const [lastAnchor, setLastAnchor] = useState(anchor);
|
|
10707
|
+
if (anchor && anchor !== lastAnchor) setLastAnchor(anchor);
|
|
10708
|
+
const shownAnchor = anchor != null ? anchor : lastAnchor;
|
|
10709
|
+
const position = shownAnchor ? __spreadValues({
|
|
10710
|
+
top: shownAnchor.y + shownAnchor.height + parseTokenValue54(spacing.xs)
|
|
10711
|
+
}, align === "right" ? { right: windowWidth - (shownAnchor.x + shownAnchor.width) } : { left: shownAnchor.x }) : {
|
|
10712
|
+
top: anchorOffset,
|
|
10713
|
+
[align]: parseTokenValue54(spacing.md)
|
|
10714
|
+
};
|
|
10715
10715
|
return /* @__PURE__ */ jsxs(
|
|
10716
10716
|
Modal,
|
|
10717
10717
|
{
|
|
@@ -10729,10 +10729,10 @@ var MenuRoot = ({
|
|
|
10729
10729
|
accessibilityLabel: closeAccessibilityLabel
|
|
10730
10730
|
}
|
|
10731
10731
|
),
|
|
10732
|
-
/* @__PURE__ */ jsx(Anchor, {
|
|
10732
|
+
/* @__PURE__ */ jsx(Anchor, { style: position, children: /* @__PURE__ */ jsx(
|
|
10733
10733
|
Card,
|
|
10734
10734
|
{
|
|
10735
|
-
width,
|
|
10735
|
+
width: Math.min(width, windowWidth * 0.9),
|
|
10736
10736
|
onPress: () => {
|
|
10737
10737
|
},
|
|
10738
10738
|
accessible: false,
|
|
@@ -10748,6 +10748,25 @@ MenuRoot.displayName = "Menu";
|
|
|
10748
10748
|
var Menu2 = Object.assign(MenuRoot, {
|
|
10749
10749
|
Item: MenuItem
|
|
10750
10750
|
});
|
|
10751
|
+
var useMenuTrigger = () => {
|
|
10752
|
+
const triggerRef = useRef(null);
|
|
10753
|
+
const [anchor, setAnchor] = useState();
|
|
10754
|
+
const open = useCallback(() => {
|
|
10755
|
+
var _a;
|
|
10756
|
+
(_a = triggerRef.current) == null ? void 0 : _a.measureInWindow(
|
|
10757
|
+
(x, y, width, height) => setAnchor({ x, y, width, height })
|
|
10758
|
+
);
|
|
10759
|
+
}, []);
|
|
10760
|
+
const close = useCallback(() => setAnchor(void 0), []);
|
|
10761
|
+
const isOpen = anchor !== void 0;
|
|
10762
|
+
return {
|
|
10763
|
+
triggerRef,
|
|
10764
|
+
isOpen,
|
|
10765
|
+
open,
|
|
10766
|
+
close,
|
|
10767
|
+
menuProps: { open: isOpen, onClose: close, anchor }
|
|
10768
|
+
};
|
|
10769
|
+
};
|
|
10751
10770
|
var parseTokenValue55 = (value) => parseFloat(value);
|
|
10752
10771
|
var StyledInsightRoot = styled51(View)(
|
|
10753
10772
|
({
|
|
@@ -12803,6 +12822,6 @@ var FloatingActionButton = React66.forwardRef(
|
|
|
12803
12822
|
);
|
|
12804
12823
|
FloatingActionButton.displayName = "FloatingActionButton";
|
|
12805
12824
|
|
|
12806
|
-
export { Accordion, Animated5 as Animated, Avatar, Badge, Button, ButtonDock, ButtonGroup, CarouselControls, Checkbox, CheckboxGroup, CopyField, CopyFieldInput, Countdown, DatePicker, Divider, Drawer, FilterTab, FloatingActionButton, Hint, Icon, IconButton, Illustration, Input, InputDescription, InputError, InputField, InputLabel, InputText, Link, Logo, Menu2 as Menu, MenuItem, MessageCard, MessageCardBanner, MessageCardInsight, NativeSelectPicker, Notification, NumberField, NumberInput, NumberInputField, PROGRESS_ANIMATION, PasswordField, PasswordFieldInput, PasswordFieldRequirements, PawprintProvider, PictureSelector, ProductDisplayCard, ProductListingCardWithBadgeAndGrid as ProductListingCard, Progress, Radio, RadioGroup, RadioTile, SearchField, SearchFieldInput, SegmentedControl, SelectField, SelectFieldContent, SelectFieldItem, SelectFieldTrigger, SelectFieldValue, Slider, Spinner, StackedNotifications, Switch, TabNavigation, Tag, TextArea, TextAreaField, TextAreaLabel, ThemeProvider, Tooltip, Typography, createPawprintTheme, fadeAnimation, fadeDownAnimation, fadeUpAnimation, registerLogo, resolveLogo, scaleAnimation, slideInAnimation, slideOutAnimation, theme, useCopyField, useDrawerKeyboardAvoidance, usePasswordField, usePawprint, useSearchField, useSelectField };
|
|
12825
|
+
export { Accordion, Animated5 as Animated, Avatar, Badge, Button, ButtonDock, ButtonGroup, CarouselControls, Checkbox, CheckboxGroup, CopyField, CopyFieldInput, Countdown, DatePicker, Divider, Drawer, FilterTab, FloatingActionButton, Hint, Icon, IconButton, Illustration, Input, InputDescription, InputError, InputField, InputLabel, InputText, Link, Logo, Menu2 as Menu, MenuItem, MessageCard, MessageCardBanner, MessageCardInsight, NativeSelectPicker, Notification, NumberField, NumberInput, NumberInputField, PROGRESS_ANIMATION, PasswordField, PasswordFieldInput, PasswordFieldRequirements, PawprintProvider, PictureSelector, ProductDisplayCard, ProductListingCardWithBadgeAndGrid as ProductListingCard, Progress, Radio, RadioGroup, RadioTile, SearchField, SearchFieldInput, SegmentedControl, SelectField, SelectFieldContent, SelectFieldItem, SelectFieldTrigger, SelectFieldValue, Slider, Spinner, StackedNotifications, Switch, TabNavigation, Tag, TextArea, TextAreaField, TextAreaLabel, ThemeProvider, Tooltip, Typography, createPawprintTheme, fadeAnimation, fadeDownAnimation, fadeUpAnimation, registerLogo, resolveLogo, scaleAnimation, slideInAnimation, slideOutAnimation, theme, useCopyField, useDrawerKeyboardAvoidance, useMenuTrigger, usePasswordField, usePawprint, useSearchField, useSelectField };
|
|
12807
12826
|
//# sourceMappingURL=index.js.map
|
|
12808
12827
|
//# sourceMappingURL=index.js.map
|