@jobber/components 6.102.0 → 6.103.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.
@@ -1,7 +1,9 @@
1
1
  import type { IconColorNames, IconNames } from "@jobber/design";
2
2
  import type React from "react";
3
- import type { CSSProperties, ReactElement, ReactNode } from "react";
3
+ import type { CSSProperties, ComponentProps, ReactElement, ReactNode } from "react";
4
+ import type { Pressable as AriaPressable } from "react-aria-components";
4
5
  import type { IconProps } from "../Icon";
6
+ type PressableChild = ComponentProps<typeof AriaPressable>["children"];
5
7
  export interface MenuLegacyProps extends MenuBaseProps {
6
8
  /**
7
9
  * Custom menu activator. If this is not provided a default [… More] will be used.
@@ -128,11 +130,12 @@ export interface MenuSectionComposableProps extends UnsafeProps {
128
130
  export interface MenuHeaderComposableProps extends UnsafeProps {
129
131
  readonly children: ReactNode;
130
132
  }
133
+ type MenuItemVariants = "destructive";
131
134
  export interface MenuItemComposableProps extends UnsafeProps {
132
135
  /**
133
- * Apply destructive styling to the item label and icon.
136
+ * Visual style variations for the MenuItem default content.
134
137
  */
135
- readonly destructive?: boolean;
138
+ readonly variation?: MenuItemVariants;
136
139
  /**
137
140
  * Item content.
138
141
  */
@@ -172,7 +175,7 @@ export interface MenuTriggerComposableProps {
172
175
  * If you want to access the open event, use the onOpenChange on the Menu component.
173
176
  * If it does not have an interactive role, or a focus style it will have issues.
174
177
  */
175
- readonly children: ReactNode;
178
+ readonly children: PressableChild;
176
179
  }
177
180
  export interface MenuSeparatorComposableProps extends UnsafeProps {
178
181
  }
package/dist/Menu-cjs.js CHANGED
@@ -87,7 +87,7 @@ const composeOverlayVariation = {
87
87
  hidden: { opacity: 0 },
88
88
  visible: { opacity: 1 },
89
89
  };
90
- const variation = {
90
+ const animationVariation = {
91
91
  overlayStartStop: { opacity: 0 },
92
92
  startOrStop: (placement) => {
93
93
  let y = Y_TRANSLATION_DESKTOP;
@@ -206,14 +206,14 @@ function MenuLegacy({ activator, items, UNSAFE_className, UNSAFE_style, }) {
206
206
  })),
207
207
  React.createElement(MenuPortal, null,
208
208
  React.createElement(framerMotion.AnimatePresence, null, visible && (React.createElement(React.Fragment, null,
209
- React.createElement(framerMotion.motion.div, { className: styles.overlay, onClick: toggle(), variants: variation, initial: "overlayStartStop", animate: "done", exit: "overlayStartStop", transition: Object.assign({}, OVERLAY_ANIMATION_CONFIG) }),
209
+ React.createElement(framerMotion.motion.div, { className: styles.overlay, onClick: toggle(), variants: animationVariation, initial: "overlayStartStop", animate: "done", exit: "overlayStartStop", transition: Object.assign({}, OVERLAY_ANIMATION_CONFIG) }),
210
210
  React.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, getFloatingProps({
211
211
  onKeyDown: event => {
212
212
  if (event.key === "Tab") {
213
213
  event.preventDefault();
214
214
  }
215
215
  },
216
- }), positionAttributes, useFormFieldFocus.formFieldFocusAttribute), items.length > 0 && (React.createElement(framerMotion.motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, transition: Object.assign({}, MENU_ANIMATION_CONFIG), style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, renderedSections)))))))));
216
+ }), positionAttributes, useFormFieldFocus.formFieldFocusAttribute), items.length > 0 && (React.createElement(framerMotion.motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: animationVariation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, transition: Object.assign({}, MENU_ANIMATION_CONFIG), style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, renderedSections)))))))));
217
217
  function toggle(callbackPassthrough) {
218
218
  return (event) => {
219
219
  setVisible(!visible);
@@ -348,14 +348,14 @@ const MenuItemComposable = React.forwardRef(function MenuItemComposable(props, r
348
348
  if (props.href) {
349
349
  const { href, target, rel, onClick } = props;
350
350
  return (React.createElement(Tree.$3674c52c6b3c5bce$export$2ce376c2cc3355c8, { ref: ref, className: className, style: UNSAFE_style, textValue: props.textValue, href: href, target: target, rel: rel, onClick: onClick },
351
- React.createElement(MenuItemContext.Provider, { value: { destructive: props.destructive } }, props.children)));
351
+ React.createElement(MenuItemContext.Provider, { value: { variation: props.variation } }, props.children)));
352
352
  }
353
353
  return (React.createElement(Tree.$3674c52c6b3c5bce$export$2ce376c2cc3355c8, { ref: ref, className: className, style: UNSAFE_style, textValue: props.textValue, onAction: () => {
354
354
  var _a;
355
355
  // Zero-arg activation for non-link items
356
356
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
357
357
  } },
358
- React.createElement(MenuItemContext.Provider, { value: { destructive: props.destructive } }, props.children)));
358
+ React.createElement(MenuItemContext.Provider, { value: { variation: props.variation } }, props.children)));
359
359
  });
360
360
  const MenuItemContext = React.createContext(null);
361
361
  function useMenuItemContext() {
@@ -363,14 +363,14 @@ function useMenuItemContext() {
363
363
  return ctx !== null && ctx !== void 0 ? ctx : {};
364
364
  }
365
365
  function MenuItemIconComposable(props) {
366
- const { destructive } = useMenuItemContext();
366
+ const { variation } = useMenuItemContext();
367
367
  return (React.createElement("div", { "data-menu-slot": "icon" },
368
- React.createElement(Icon.Icon, Object.assign({}, props, { color: destructive ? "destructive" : props.color }))));
368
+ React.createElement(Icon.Icon, Object.assign({}, props, { color: variation === "destructive" ? "destructive" : props.color }))));
369
369
  }
370
370
  function MenuItemLabelComposable(props) {
371
- const { destructive } = useMenuItemContext();
371
+ const { variation } = useMenuItemContext();
372
372
  return (React.createElement("div", { "data-menu-slot": "label" },
373
- React.createElement(Typography.Typography, { element: "span", fontWeight: "semiBold", textColor: destructive ? "destructive" : "text" }, props.children)));
373
+ React.createElement(Typography.Typography, { element: "span", fontWeight: "semiBold", textColor: variation === "destructive" ? "destructive" : "text" }, props.children)));
374
374
  }
375
375
  function MenuHeaderLabel(props) {
376
376
  return React.createElement(DefaultHeaderContent, null, props.children);
package/dist/Menu-es.js CHANGED
@@ -85,7 +85,7 @@ const composeOverlayVariation = {
85
85
  hidden: { opacity: 0 },
86
86
  visible: { opacity: 1 },
87
87
  };
88
- const variation = {
88
+ const animationVariation = {
89
89
  overlayStartStop: { opacity: 0 },
90
90
  startOrStop: (placement) => {
91
91
  let y = Y_TRANSLATION_DESKTOP;
@@ -204,14 +204,14 @@ function MenuLegacy({ activator, items, UNSAFE_className, UNSAFE_style, }) {
204
204
  })),
205
205
  React__default.createElement(MenuPortal, null,
206
206
  React__default.createElement(AnimatePresence, null, visible && (React__default.createElement(React__default.Fragment, null,
207
- React__default.createElement(motion.div, { className: styles.overlay, onClick: toggle(), variants: variation, initial: "overlayStartStop", animate: "done", exit: "overlayStartStop", transition: Object.assign({}, OVERLAY_ANIMATION_CONFIG) }),
207
+ React__default.createElement(motion.div, { className: styles.overlay, onClick: toggle(), variants: animationVariation, initial: "overlayStartStop", animate: "done", exit: "overlayStartStop", transition: Object.assign({}, OVERLAY_ANIMATION_CONFIG) }),
208
208
  React__default.createElement("div", Object.assign({ ref: refs.setFloating, className: styles.floatingContainer }, getFloatingProps({
209
209
  onKeyDown: event => {
210
210
  if (event.key === "Tab") {
211
211
  event.preventDefault();
212
212
  }
213
213
  },
214
- }), positionAttributes, formFieldFocusAttribute), items.length > 0 && (React__default.createElement(motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: variation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, transition: Object.assign({}, MENU_ANIMATION_CONFIG), style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, renderedSections)))))))));
214
+ }), positionAttributes, formFieldFocusAttribute), items.length > 0 && (React__default.createElement(motion.div, { className: classnames(styles.menu, UNSAFE_className === null || UNSAFE_className === void 0 ? void 0 : UNSAFE_className.menu), role: "menu", "data-elevation": "elevated", "aria-labelledby": buttonID, id: menuID, onClick: hide, variants: animationVariation, initial: "startOrStop", animate: "done", exit: "startOrStop", custom: context === null || context === void 0 ? void 0 : context.placement, transition: Object.assign({}, MENU_ANIMATION_CONFIG), style: UNSAFE_style === null || UNSAFE_style === void 0 ? void 0 : UNSAFE_style.menu }, renderedSections)))))))));
215
215
  function toggle(callbackPassthrough) {
216
216
  return (event) => {
217
217
  setVisible(!visible);
@@ -346,14 +346,14 @@ const MenuItemComposable = React__default.forwardRef(function MenuItemComposable
346
346
  if (props.href) {
347
347
  const { href, target, rel, onClick } = props;
348
348
  return (React__default.createElement($3674c52c6b3c5bce$export$2ce376c2cc3355c8, { ref: ref, className: className, style: UNSAFE_style, textValue: props.textValue, href: href, target: target, rel: rel, onClick: onClick },
349
- React__default.createElement(MenuItemContext.Provider, { value: { destructive: props.destructive } }, props.children)));
349
+ React__default.createElement(MenuItemContext.Provider, { value: { variation: props.variation } }, props.children)));
350
350
  }
351
351
  return (React__default.createElement($3674c52c6b3c5bce$export$2ce376c2cc3355c8, { ref: ref, className: className, style: UNSAFE_style, textValue: props.textValue, onAction: () => {
352
352
  var _a;
353
353
  // Zero-arg activation for non-link items
354
354
  (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
355
355
  } },
356
- React__default.createElement(MenuItemContext.Provider, { value: { destructive: props.destructive } }, props.children)));
356
+ React__default.createElement(MenuItemContext.Provider, { value: { variation: props.variation } }, props.children)));
357
357
  });
358
358
  const MenuItemContext = createContext(null);
359
359
  function useMenuItemContext() {
@@ -361,14 +361,14 @@ function useMenuItemContext() {
361
361
  return ctx !== null && ctx !== void 0 ? ctx : {};
362
362
  }
363
363
  function MenuItemIconComposable(props) {
364
- const { destructive } = useMenuItemContext();
364
+ const { variation } = useMenuItemContext();
365
365
  return (React__default.createElement("div", { "data-menu-slot": "icon" },
366
- React__default.createElement(Icon, Object.assign({}, props, { color: destructive ? "destructive" : props.color }))));
366
+ React__default.createElement(Icon, Object.assign({}, props, { color: variation === "destructive" ? "destructive" : props.color }))));
367
367
  }
368
368
  function MenuItemLabelComposable(props) {
369
- const { destructive } = useMenuItemContext();
369
+ const { variation } = useMenuItemContext();
370
370
  return (React__default.createElement("div", { "data-menu-slot": "label" },
371
- React__default.createElement(Typography, { element: "span", fontWeight: "semiBold", textColor: destructive ? "destructive" : "text" }, props.children)));
371
+ React__default.createElement(Typography, { element: "span", fontWeight: "semiBold", textColor: variation === "destructive" ? "destructive" : "text" }, props.children)));
372
372
  }
373
373
  function MenuHeaderLabel(props) {
374
374
  return React__default.createElement(DefaultHeaderContent, null, props.children);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "6.102.0",
3
+ "version": "6.103.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -538,5 +538,5 @@
538
538
  "> 1%",
539
539
  "IE 10"
540
540
  ],
541
- "gitHead": "1bab53a257b1c96c41a1d8b437f432fad4d138c1"
541
+ "gitHead": "97455b7bb50ed051e449077dc78c47a676446fee"
542
542
  }