@butternutbox/pawprint-native 1.2.0 → 1.3.1

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/dist/index.js CHANGED
@@ -9128,6 +9128,16 @@ var SelectFieldRoot = React66.forwardRef(
9128
9128
  keyboardSub.remove();
9129
9129
  };
9130
9130
  }, [isOpen, searchable, isSearching, searchQuery]);
9131
+ const isOpenRef = React66.useRef(isOpen);
9132
+ React66.useEffect(() => {
9133
+ isOpenRef.current = isOpen;
9134
+ });
9135
+ const handleSearchBlur = () => {
9136
+ setTimeout(() => {
9137
+ var _a2;
9138
+ if (isOpenRef.current) (_a2 = searchInputRef.current) == null ? void 0 : _a2.focus();
9139
+ }, 50);
9140
+ };
9131
9141
  const isCompound = React66.Children.toArray(children).some(
9132
9142
  (child) => React66.isValidElement(child) && child.type === SelectFieldContent
9133
9143
  );
@@ -9218,6 +9228,7 @@ var SelectFieldRoot = React66.forwardRef(
9218
9228
  ref: searchInputRef,
9219
9229
  value: searchQuery,
9220
9230
  onChangeText: setSearchQuery,
9231
+ onBlur: handleSearchBlur,
9221
9232
  placeholder: searchPlaceholder != null ? searchPlaceholder : "Search...",
9222
9233
  returnKeyType: "search",
9223
9234
  clearButtonMode: "never",
@@ -10627,46 +10638,37 @@ var Tooltip = React66.forwardRef(
10627
10638
  );
10628
10639
  Tooltip.displayName = "Tooltip";
10629
10640
  var parseTokenValue53 = (value) => parseFloat(value);
10630
- var Row = styled51(Pressable)(({ theme: theme2, divider }) => {
10641
+ var Row = styled51(Pressable)(({ theme: theme2 }) => {
10631
10642
  const { spacing } = theme2.tokens.semantics.dimensions;
10632
- const { colour } = theme2.tokens.semantics;
10633
10643
  return {
10634
10644
  width: "100%",
10635
- alignItems: "center",
10645
+ alignItems: "flex-start",
10636
10646
  justifyContent: "center",
10637
10647
  paddingVertical: parseTokenValue53(spacing.md),
10638
- paddingHorizontal: parseTokenValue53(spacing.md),
10639
- borderBottomWidth: divider ? 1 : 0,
10640
- borderBottomColor: colour.border.divider
10648
+ paddingHorizontal: parseTokenValue53(spacing.md)
10641
10649
  };
10642
10650
  });
10643
10651
  var MenuItem = React66.forwardRef((_a, ref) => {
10644
10652
  var _b = _a, { variant = "action", onPress, children, divider = true } = _b, rest = __objRest(_b, ["variant", "onPress", "children", "divider"]);
10645
10653
  const theme2 = useTheme();
10646
10654
  const { colour, typography } = theme2.tokens.semantics;
10647
- const labelColour = variant === "destructive" ? colour.text.error : colour.text.action.default;
10655
+ const labelColour = variant === "destructive" ? colour.text.error : colour.text.link.default;
10648
10656
  const label = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
10649
- return /* @__PURE__ */ jsx(
10650
- Row,
10651
- __spreadProps(__spreadValues({
10652
- ref,
10653
- divider,
10654
- onPress,
10655
- accessible: true,
10656
- accessibilityRole: "menuitem",
10657
- accessibilityLabel: label
10658
- }, rest), {
10659
- children: label !== void 0 ? /* @__PURE__ */ jsx(
10660
- Typography,
10661
- {
10662
- token: typography.body.medium.md,
10663
- align: "center",
10664
- color: labelColour,
10665
- children: label
10666
- }
10667
- ) : children
10668
- })
10669
- );
10657
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
10658
+ /* @__PURE__ */ jsx(
10659
+ Row,
10660
+ __spreadProps(__spreadValues({
10661
+ ref,
10662
+ onPress,
10663
+ accessible: true,
10664
+ accessibilityRole: "menuitem",
10665
+ accessibilityLabel: label
10666
+ }, rest), {
10667
+ children: label !== void 0 ? /* @__PURE__ */ jsx(Typography, { token: typography.body.medium.md, color: labelColour, children: label }) : children
10668
+ })
10669
+ ),
10670
+ divider && /* @__PURE__ */ jsx(Divider, {})
10671
+ ] });
10670
10672
  });
10671
10673
  MenuItem.displayName = "Menu.Item";
10672
10674
  var parseTokenValue54 = (value) => parseFloat(value);
@@ -10677,18 +10679,14 @@ var DismissLayer = styled51(Pressable)({
10677
10679
  right: 0,
10678
10680
  bottom: 0
10679
10681
  });
10680
- var Anchor = styled51(View)(({ theme: theme2, align }) => {
10681
- const inset = parseTokenValue54(theme2.tokens.semantics.dimensions.spacing.md);
10682
- return __spreadValues({
10683
- position: "absolute"
10684
- }, align === "right" ? { right: inset } : { left: inset });
10682
+ var Anchor = styled51(View)({
10683
+ position: "absolute"
10685
10684
  });
10686
10685
  var Card = styled51(Pressable)(({ theme: theme2, width }) => {
10687
10686
  const { borderRadius } = theme2.tokens.semantics.dimensions;
10688
10687
  const { shadow, background } = theme2.tokens.semantics.colour;
10689
10688
  return {
10690
10689
  width,
10691
- maxWidth: "90%",
10692
10690
  borderRadius: parseTokenValue54(borderRadius.md),
10693
10691
  overflow: "hidden",
10694
10692
  backgroundColor: background.surface.default,
@@ -10706,12 +10704,25 @@ var Card = styled51(Pressable)(({ theme: theme2, width }) => {
10706
10704
  var MenuRoot = ({
10707
10705
  open,
10708
10706
  onClose,
10707
+ anchor,
10709
10708
  anchorOffset = 0,
10710
10709
  align = "right",
10711
- width = 360,
10710
+ width = 280,
10712
10711
  closeAccessibilityLabel = "Close menu",
10713
10712
  children
10714
10713
  }) => {
10714
+ const theme2 = useTheme();
10715
+ const { width: windowWidth } = useWindowDimensions();
10716
+ const { spacing } = theme2.tokens.semantics.dimensions;
10717
+ const [lastAnchor, setLastAnchor] = useState(anchor);
10718
+ if (anchor && anchor !== lastAnchor) setLastAnchor(anchor);
10719
+ const shownAnchor = anchor != null ? anchor : lastAnchor;
10720
+ const position = shownAnchor ? __spreadValues({
10721
+ top: shownAnchor.y + shownAnchor.height + parseTokenValue54(spacing.xs)
10722
+ }, align === "right" ? { right: windowWidth - (shownAnchor.x + shownAnchor.width) } : { left: shownAnchor.x }) : {
10723
+ top: anchorOffset,
10724
+ [align]: parseTokenValue54(spacing.md)
10725
+ };
10715
10726
  return /* @__PURE__ */ jsxs(
10716
10727
  Modal,
10717
10728
  {
@@ -10729,10 +10740,10 @@ var MenuRoot = ({
10729
10740
  accessibilityLabel: closeAccessibilityLabel
10730
10741
  }
10731
10742
  ),
10732
- /* @__PURE__ */ jsx(Anchor, { align, style: { top: anchorOffset }, children: /* @__PURE__ */ jsx(
10743
+ /* @__PURE__ */ jsx(Anchor, { style: position, children: /* @__PURE__ */ jsx(
10733
10744
  Card,
10734
10745
  {
10735
- width,
10746
+ width: Math.min(width, windowWidth * 0.9),
10736
10747
  onPress: () => {
10737
10748
  },
10738
10749
  accessible: false,
@@ -10748,6 +10759,25 @@ MenuRoot.displayName = "Menu";
10748
10759
  var Menu2 = Object.assign(MenuRoot, {
10749
10760
  Item: MenuItem
10750
10761
  });
10762
+ var useMenuTrigger = () => {
10763
+ const triggerRef = useRef(null);
10764
+ const [anchor, setAnchor] = useState();
10765
+ const open = useCallback(() => {
10766
+ var _a;
10767
+ (_a = triggerRef.current) == null ? void 0 : _a.measureInWindow(
10768
+ (x, y, width, height) => setAnchor({ x, y, width, height })
10769
+ );
10770
+ }, []);
10771
+ const close = useCallback(() => setAnchor(void 0), []);
10772
+ const isOpen = anchor !== void 0;
10773
+ return {
10774
+ triggerRef,
10775
+ isOpen,
10776
+ open,
10777
+ close,
10778
+ menuProps: { open: isOpen, onClose: close, anchor }
10779
+ };
10780
+ };
10751
10781
  var parseTokenValue55 = (value) => parseFloat(value);
10752
10782
  var StyledInsightRoot = styled51(View)(
10753
10783
  ({
@@ -12803,6 +12833,6 @@ var FloatingActionButton = React66.forwardRef(
12803
12833
  );
12804
12834
  FloatingActionButton.displayName = "FloatingActionButton";
12805
12835
 
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 };
12836
+ 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
12837
  //# sourceMappingURL=index.js.map
12808
12838
  //# sourceMappingURL=index.js.map