@wistia/ui 0.4.6 → 0.4.7-beta.5aa0e9cf.7fbd46e

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.d.mts CHANGED
@@ -336,6 +336,11 @@ declare const ActionButton: react.ForwardRefExoticComponent<(Omit<{
336
336
  } & Omit<ButtonAsLinkProps, "size" | "isLoading" | "leftIcon" | "fullWidth" | "unstyled" | "rightIcon" | "variant">, "ref">) & react.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
337
337
 
338
338
  type AvatarInstanceType = 'image' | 'initials';
339
+ type AvatarImageLoadStateType = 'error' | 'loaded' | 'loading';
340
+ type AvatarStatus = {
341
+ type: AvatarInstanceType;
342
+ state: AvatarImageLoadStateType;
343
+ };
339
344
  type AvatarProps = ComponentPropsWithoutRef<'div'> & {
340
345
  /**
341
346
  * The height and width of the avatar (overrides size prop)
@@ -358,7 +363,7 @@ type AvatarProps = ComponentPropsWithoutRef<'div'> & {
358
363
  /**
359
364
  * A callback that is invoked after the image has loaded or failed to load
360
365
  */
361
- onImageLoad?: (avatarType: AvatarInstanceType) => void;
366
+ onImageLoad?: (avatarStatus: AvatarStatus) => void;
362
367
  };
363
368
  /**
364
369
  * An avatar uses a photo, initials or icon to represent an entity
@@ -2163,4 +2168,4 @@ declare const WistiaLogo: {
2163
2168
  displayName: string;
2164
2169
  };
2165
2170
 
2166
- export { ActionButton, type ActionButtonProps, Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
2171
+ export { ActionButton, type ActionButtonProps, Avatar, type AvatarProps, type AvatarStatus, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
package/dist/index.d.ts CHANGED
@@ -336,6 +336,11 @@ declare const ActionButton: react.ForwardRefExoticComponent<(Omit<{
336
336
  } & Omit<ButtonAsLinkProps, "size" | "isLoading" | "leftIcon" | "fullWidth" | "unstyled" | "rightIcon" | "variant">, "ref">) & react.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
337
337
 
338
338
  type AvatarInstanceType = 'image' | 'initials';
339
+ type AvatarImageLoadStateType = 'error' | 'loaded' | 'loading';
340
+ type AvatarStatus = {
341
+ type: AvatarInstanceType;
342
+ state: AvatarImageLoadStateType;
343
+ };
339
344
  type AvatarProps = ComponentPropsWithoutRef<'div'> & {
340
345
  /**
341
346
  * The height and width of the avatar (overrides size prop)
@@ -358,7 +363,7 @@ type AvatarProps = ComponentPropsWithoutRef<'div'> & {
358
363
  /**
359
364
  * A callback that is invoked after the image has loaded or failed to load
360
365
  */
361
- onImageLoad?: (avatarType: AvatarInstanceType) => void;
366
+ onImageLoad?: (avatarStatus: AvatarStatus) => void;
362
367
  };
363
368
  /**
364
369
  * An avatar uses a photo, initials or icon to represent an entity
@@ -2163,4 +2168,4 @@ declare const WistiaLogo: {
2163
2168
  displayName: string;
2164
2169
  };
2165
2170
 
2166
- export { ActionButton, type ActionButtonProps, Avatar, type AvatarInstanceType, type AvatarProps, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
2171
+ export { ActionButton, type ActionButtonProps, Avatar, type AvatarProps, type AvatarStatus, Badge, type BadgeProps, Box, type BoxProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonGroup, type ButtonProps, Card, type CardProps, Checkbox, CheckboxGroup, CheckboxMenuItem, type ColorSchemeTypes, ColorSchemeWrapper, type ColorSchemeWrapperProps, Divider, Ellipsis, Form, FormErrorSummary, FormField, type FormFieldProps, FormGroup, type FormGroupProps, type FormProps, Heading, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconNameType, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuLabel, MenuRadioGroup, Modal, type ModalProps, Radio, RadioGroup, RadioMenuItem, type RadioProps, ScreenReaderOnly, Stack, SubMenu, Tag, type TagProps, Text, type TextProps, Tooltip, type TooltipProps, UIProvider, WistiaLogo, colorSchemeOptions, copyToClipboard, ellipsisFlexParentStyle, ellipsisStyle, iconSizeMap, mq, useActiveMq, useAriaLive, useBoolean, useFormState, useKey, useMq, useToast, useWindowSize };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.4.6
3
+ * @license @wistia/ui v0.4.7-beta.5aa0e9cf.7fbd46e
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -5868,17 +5868,17 @@ var Avatar = ({
5868
5868
  onImageLoad,
5869
5869
  ...otherProps
5870
5870
  }) => {
5871
- const [imageLoadState, setImageLoadState] = useState4(null);
5871
+ const [imageLoadState, setImageLoadState] = useState4("loading");
5872
5872
  useEffect3(() => {
5873
- setImageLoadState(null);
5873
+ setImageLoadState("loading");
5874
5874
  }, [imageUrl]);
5875
5875
  const handleImageLoad = () => {
5876
5876
  setImageLoadState("loaded");
5877
- onImageLoad?.("image");
5877
+ onImageLoad?.({ state: "loaded", type: "image" });
5878
5878
  };
5879
5879
  const handleImageLoadError = () => {
5880
5880
  setImageLoadState("error");
5881
- onImageLoad?.("initials");
5881
+ onImageLoad?.({ state: "error", type: "initials" });
5882
5882
  };
5883
5883
  const avatarSize = heightAndWidth ?? avatarSizeMap[size];
5884
5884
  const avatarColor = useMemo3(() => chooseColorScheme(name), [name]);
@@ -7397,6 +7397,14 @@ import {
7397
7397
  DropdownMenuContent
7398
7398
  } from "@radix-ui/react-dropdown-menu";
7399
7399
  import { isNotNil as isNotNil10, isNotUndefined as isNotUndefined7 } from "@wistia/type-guards";
7400
+ import { useMemo as useMemo7 } from "react";
7401
+
7402
+ // src/components/Menu/MenuContext.tsx
7403
+ import { createContext as createContext5, useContext as useContext4 } from "react";
7404
+ var MenuContext = createContext5({ compact: false });
7405
+ var useMenuContext = () => useContext4(MenuContext);
7406
+
7407
+ // src/components/Menu/Menu.tsx
7400
7408
  import { jsx as jsx187, jsxs as jsxs14 } from "react/jsx-runtime";
7401
7409
  var open = keyframes`
7402
7410
  from {
@@ -7418,6 +7426,28 @@ var close = keyframes`
7418
7426
  transform: scale(.97) translateY(-8px);
7419
7427
  }
7420
7428
  `;
7429
+ var menuItemCss = css20`
7430
+ --menu-label-description-gap: var(--wui-space-01);
7431
+ --menu-item-inner-gap: var(--wui-space-03);
7432
+ --menu-item-left-icon-size: 24px;
7433
+ --menu-item-right-icon-size: 16px;
7434
+ --menu-item-padding: var(--wui-space-02);
7435
+ --menu-label-font-size: var(--wui-typography-label-3-size);
7436
+ --menu-label-font-weight: var(--wui-typography-label-3-weight);
7437
+ --menu-label-line-height: var(--wui-typography-label-3-line-height);
7438
+ --menu-divider-margin: var(--wui-space-02);
7439
+ `;
7440
+ var compactMenuItemCss = css20`
7441
+ --menu-label-description-gap: 0;
7442
+ --menu-item-inner-gap: var(--wui-space-02);
7443
+ --menu-item-left-icon-size: 16px;
7444
+ --menu-item-right-icon-size: 12px;
7445
+ --menu-item-padding: 6px;
7446
+ --menu-label-font-size: var(--wui-typography-label-4-size);
7447
+ --menu-label-font-weight: var(--wui-typography-label-4-weight);
7448
+ --menu-label-line-height: var(--wui-typography-label-4-line-height);
7449
+ --menu-divider-margin: var(--wui-space-01);
7450
+ `;
7421
7451
  var menuContentCss = css20`
7422
7452
  --menu-font-family: var(--wui-typography-family-default);
7423
7453
  --menu-bg: var(--wui-color-bg-surface);
@@ -7427,6 +7457,8 @@ var menuContentCss = css20`
7427
7457
  --menu-min-width: 120px;
7428
7458
  --menu-max-width: 284px;
7429
7459
 
7460
+ ${({ $compact }) => $compact ? compactMenuItemCss : menuItemCss};
7461
+
7430
7462
  animation: ${open}; /* TODO - need easing tokens */
7431
7463
  font-family: var(--menu-font-family);
7432
7464
  background: var(--menu-bg);
@@ -7457,31 +7489,8 @@ var menuContentCss = css20`
7457
7489
  margin: var(--menu-divider-margin) 0;
7458
7490
  }
7459
7491
  `;
7460
- var menuItemCss = css20`
7461
- --menu-label-description-gap: var(--wui-space-01);
7462
- --menu-item-inner-gap: var(--wui-space-03);
7463
- --menu-item-left-icon-size: 24px;
7464
- --menu-item-right-icon-size: 16px;
7465
- --menu-item-padding: var(--wui-space-02);
7466
- --menu-label-font-size: var(--wui-typography-label-3-size);
7467
- --menu-label-font-weight: var(--wui-typography-label-3-weight);
7468
- --menu-label-line-height: var(--wui-typography-label-3-line-height);
7469
- --menu-divider-margin: var(--wui-space-02);
7470
- `;
7471
- var compactMenuItemCss = css20`
7472
- --menu-label-description-gap: 0;
7473
- --menu-item-inner-gap: var(--wui-space-02);
7474
- --menu-item-left-icon-size: 16px;
7475
- --menu-item-right-icon-size: 12px;
7476
- --menu-item-padding: 6px;
7477
- --menu-label-font-size: var(--wui-typography-label-4-size);
7478
- --menu-label-font-weight: var(--wui-typography-label-4-weight);
7479
- --menu-label-line-height: var(--wui-typography-label-4-line-height);
7480
- --menu-divider-margin: var(--wui-space-01);
7481
- `;
7482
7492
  var MenuContent = styled26(DropdownMenuContent)`
7483
7493
  ${menuContentCss}
7484
- ${({ $compact }) => $compact ? compactMenuItemCss : menuItemCss}
7485
7494
  `;
7486
7495
  var Menu = ({
7487
7496
  align = "start",
@@ -7496,6 +7505,7 @@ var Menu = ({
7496
7505
  onInteractOutside,
7497
7506
  ...props
7498
7507
  }) => {
7508
+ const contextValue = useMemo7(() => ({ compact }), [compact]);
7499
7509
  let controlProps = {
7500
7510
  ...isNotNil10(onOpenChange) && isNotNil10(isOpen) ? { open: isOpen, onOpenChange } : {}
7501
7511
  };
@@ -7505,7 +7515,7 @@ var Menu = ({
7505
7515
  onOpenChange: () => null
7506
7516
  };
7507
7517
  }
7508
- return /* @__PURE__ */ jsxs14(
7518
+ return /* @__PURE__ */ jsx187(MenuContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs14(
7509
7519
  DropdownMenu,
7510
7520
  {
7511
7521
  modal: false,
@@ -7537,7 +7547,7 @@ var Menu = ({
7537
7547
  ) })
7538
7548
  ]
7539
7549
  }
7540
- );
7550
+ ) });
7541
7551
  };
7542
7552
  Menu.displayName = "Menu";
7543
7553
 
@@ -7714,7 +7724,6 @@ var MenuItemDescription = ({ children }) => {
7714
7724
  import { jsx as jsx191, jsxs as jsxs16 } from "react/jsx-runtime";
7715
7725
  var SubMenuContent = styled30(DropdownMenuSubContent)`
7716
7726
  ${menuContentCss}
7717
- width: 298px;
7718
7727
 
7719
7728
  ${mq.smAndDown} {
7720
7729
  transform: translateX(-100%) !important;
@@ -7751,12 +7760,13 @@ var SubMenu = ({
7751
7760
  }) => {
7752
7761
  const { isSmAndUp } = useMq();
7753
7762
  const [isExpanded, setIsExpanded] = useState7(false);
7763
+ const { compact } = useMenuContext();
7754
7764
  return isSmAndUp ? /* @__PURE__ */ jsxs16(DropdownMenuSub, { onOpenChange, children: [
7755
7765
  /* @__PURE__ */ jsxs16(SubMenuTrigger, { ...props, children: [
7756
7766
  /* @__PURE__ */ jsx191(MenuItemLabel, { children: label }),
7757
7767
  isNotNil12(description) ? /* @__PURE__ */ jsx191(MenuItemDescription, { children: description }) : null
7758
7768
  ] }),
7759
- /* @__PURE__ */ jsx191(DropdownMenuPortal2, { children: /* @__PURE__ */ jsx191(SubMenuContent, { children }) })
7769
+ /* @__PURE__ */ jsx191(DropdownMenuPortal2, { children: /* @__PURE__ */ jsx191(SubMenuContent, { $compact: compact, children }) })
7760
7770
  ] }) : /* @__PURE__ */ jsxs16(DropdownMenuGroup, { children: [
7761
7771
  /* @__PURE__ */ jsxs16(
7762
7772
  SubMenuTrigger,