@wistia/ui 0.10.3-beta.f9f033db.a9ffeb4 → 0.10.4-beta.1ec201d3.a525932

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.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.10.3-beta.f9f033db.a9ffeb4
3
+ * @license @wistia/ui v0.10.4-beta.1ec201d3.a525932
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  ActionButton: () => ActionButton,
43
43
  Avatar: () => Avatar,
44
44
  Badge: () => Badge,
45
+ Banner: () => Banner,
45
46
  Box: () => Box,
46
47
  Breadcrumb: () => Breadcrumb,
47
48
  Breadcrumbs: () => Breadcrumbs,
@@ -58,6 +59,7 @@ __export(index_exports, {
58
59
  CollapsibleTrigger: () => CollapsibleTrigger,
59
60
  ColorSchemeWrapper: () => ColorSchemeWrapper,
60
61
  Combobox: () => Combobox2,
62
+ ComboboxOption: () => ComboboxOption,
61
63
  DataCard: () => DataCard,
62
64
  DataCardTrend: () => DataCardTrend,
63
65
  DataCards: () => DataCards,
@@ -8761,17 +8763,9 @@ var Checkbox = (0, import_react34.forwardRef)(
8761
8763
  const generatedId = (0, import_react34.useId)();
8762
8764
  const computedId = (0, import_type_guards26.isNonEmptyString)(id) ? id : `wistia-ui-checkbox-${generatedId}`;
8763
8765
  const checkboxGroupContext = useCheckboxGroup();
8764
- const groupName = checkboxGroupContext?.name;
8766
+ const contextName = checkboxGroupContext?.name;
8765
8767
  const contextOnChange = checkboxGroupContext?.onChange;
8766
- let checkboxName = name;
8767
- if (groupName) {
8768
- if ((0, import_type_guards26.isUndefined)(value)) {
8769
- console.error("Checkbox in CheckboxGroup is missing a value prop.");
8770
- checkboxName = groupName;
8771
- } else {
8772
- checkboxName = `${groupName}[${value}]`;
8773
- }
8774
- }
8768
+ const checkboxName = name ?? contextName;
8775
8769
  const handleOnChange = onChange ?? contextOnChange;
8776
8770
  return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(StyledCheckboxWrapper, { disabled, children: [
8777
8771
  /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
@@ -11741,9 +11735,9 @@ var Radio = (0, import_react57.forwardRef)(
11741
11735
  const generatedId = (0, import_react57.useId)();
11742
11736
  const computedId = (0, import_type_guards45.isNonEmptyString)(id) ? id : `wistia-ui-radio-${generatedId}`;
11743
11737
  const radioGroupContext = useRadioGroup();
11744
- const groupName = radioGroupContext?.name;
11738
+ const contextName = radioGroupContext?.name;
11745
11739
  const contextOnChange = radioGroupContext?.onChange;
11746
- const radioName = name ?? groupName;
11740
+ const radioName = name ?? contextName;
11747
11741
  const handleOnChange = onChange ?? contextOnChange;
11748
11742
  return /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
11749
11743
  StyledRadioWrapper,
@@ -13709,13 +13703,192 @@ var List = ({
13709
13703
  };
13710
13704
  List.displayName = "List";
13711
13705
 
13712
- // src/components/Combobox/Combobox.tsx
13713
- var Ariakit = __toESM(require("@ariakit/react"));
13706
+ // src/components/Banner/Banner.tsx
13714
13707
  var import_react73 = require("react");
13715
- var import_match_sorter = require("match-sorter");
13716
13708
  var import_styled_components96 = __toESM(require("styled-components"));
13709
+ var import_type_guards61 = require("@wistia/type-guards");
13717
13710
  var import_jsx_runtime279 = require("react/jsx-runtime");
13718
- var ComboboxWapper = import_styled_components96.default.div`
13711
+ var BREAKPOINT_WIDTH = 600;
13712
+ var VERTICAL_BREAKPOINT_WIDTH = 360;
13713
+ var MIN_IMAGE_WIDTH = 400;
13714
+ var StyledBanner = import_styled_components96.default.div`
13715
+ --wui-banner-padding: var(--wui-space-04);
13716
+ --wui-banner-content-height: ${({ $contentHeight }) => $contentHeight}px;
13717
+
13718
+ display: flex;
13719
+ flex-direction: row;
13720
+ background: var(--wui-color-bg-surface-secondary);
13721
+ border-radius: var(--wui-border-radius-03);
13722
+ position: relative;
13723
+ overflow: hidden;
13724
+ align-items: center;
13725
+
13726
+ &[data-wui-banner-content-prominence='secondary'] {
13727
+ --wui-banner-padding: var(--wui-space-05);
13728
+
13729
+ box-shadow: inset 0 0 0 2px var(--wui-color-border);
13730
+ }
13731
+
13732
+ &:has([data-wui-banner-image]) {
13733
+ --wui-banner-padding: var(--wui-space-05);
13734
+ }
13735
+
13736
+ &[data-wui-banner-content-prominence='small'] {
13737
+ --wui-banner-padding: var(--wui-space-04);
13738
+ }
13739
+
13740
+ &[data-wui-banner-orientation='vertical'] {
13741
+ flex-direction: column;
13742
+ align-items: stretch;
13743
+ }
13744
+
13745
+ ${({ $colorScheme }) => getColorScheme($colorScheme)};
13746
+ `;
13747
+ var IconWrapper = (0, import_styled_components96.default)(Box)`
13748
+ --wui-banner-icon-size: var(--font-size, 24px);
13749
+
13750
+ ${({ $iconPosition }) => $iconPosition === "inline" && import_styled_components96.css`
13751
+ display: inline-block;
13752
+ vertical-align: text-bottom;
13753
+ margin-right: calc(var(--wui-banner-icon-size) / 3);
13754
+ `}
13755
+
13756
+ svg {
13757
+ color: var(--wui-color-icon);
13758
+ width: var(--wui-banner-icon-size);
13759
+ height: var(--wui-banner-icon-size);
13760
+ }
13761
+ `;
13762
+ var Banner = ({
13763
+ bodyText,
13764
+ colorScheme = "inherit",
13765
+ headingText,
13766
+ icon,
13767
+ image,
13768
+ onClose,
13769
+ orientation = "horizontal",
13770
+ primaryAction,
13771
+ prominence = "default",
13772
+ secondaryAction,
13773
+ ...props
13774
+ }) => {
13775
+ const [containerRef, { width }] = useElementObserver();
13776
+ const [contentRef, { height: contentHeight }] = useElementObserver();
13777
+ const [isSmallContainer, setIsSmallContainer] = (0, import_react73.useState)(false);
13778
+ const [isVerticalLayout, setIsVerticalLayout] = (0, import_react73.useState)(orientation === "vertical");
13779
+ (0, import_react73.useEffect)(() => {
13780
+ const breakpoint = orientation === "vertical" ? VERTICAL_BREAKPOINT_WIDTH : BREAKPOINT_WIDTH;
13781
+ setIsSmallContainer(width <= breakpoint);
13782
+ if (orientation === "auto") {
13783
+ setIsVerticalLayout(width <= BREAKPOINT_WIDTH);
13784
+ }
13785
+ }, [width, orientation]);
13786
+ const hasImage = (0, import_type_guards61.isNotNil)(image);
13787
+ const shouldShowImage = hasImage && (isVerticalLayout || width >= MIN_IMAGE_WIDTH);
13788
+ const iconPosition = (0, import_react73.useMemo)(() => {
13789
+ if ((0, import_type_guards61.isNil)(icon)) return "none";
13790
+ if (isSmallContainer) return shouldShowImage ? "inline" : "above";
13791
+ return prominence === "secondary" ? "inline" : "above";
13792
+ }, [icon, isSmallContainer, shouldShowImage, prominence]);
13793
+ const contentDirection = (0, import_react73.useMemo)(
13794
+ () => !shouldShowImage && prominence === "default" && !isSmallContainer && !isVerticalLayout ? "row" : "column",
13795
+ [shouldShowImage, prominence, isSmallContainer, isVerticalLayout]
13796
+ );
13797
+ const headingVariant = isSmallContainer || prominence === "default" ? "heading5" : "heading3";
13798
+ const textVariant = prominence === "default" || isSmallContainer ? "body3" : "body2";
13799
+ const buttonSize = isSmallContainer ? "sm" : "md";
13800
+ const hasActions = (0, import_type_guards61.isNotNil)(primaryAction) || (0, import_type_guards61.isNotNil)(secondaryAction);
13801
+ return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13802
+ StyledBanner,
13803
+ {
13804
+ ...props,
13805
+ ref: containerRef,
13806
+ $colorScheme: colorScheme,
13807
+ $contentHeight: contentHeight,
13808
+ $width: !isSmallContainer && !isVerticalLayout ? width : void 0,
13809
+ "data-wui-banner-content-prominence": isSmallContainer ? "small" : prominence,
13810
+ "data-wui-banner-orientation": isVerticalLayout ? "vertical" : "horizontal",
13811
+ children: [
13812
+ shouldShowImage ? image : null,
13813
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13814
+ Box,
13815
+ {
13816
+ ref: contentRef,
13817
+ alignItems: "stretch",
13818
+ direction: contentDirection,
13819
+ flexMode: "grow",
13820
+ gap: "space-04",
13821
+ style: { padding: "var(--wui-banner-padding)" },
13822
+ children: [
13823
+ iconPosition === "above" && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
13824
+ IconWrapper,
13825
+ {
13826
+ $iconPosition: "above",
13827
+ alignSelf: "stretch",
13828
+ direction: "column",
13829
+ justifyContent: "center",
13830
+ children: icon
13831
+ }
13832
+ ),
13833
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13834
+ Box,
13835
+ {
13836
+ direction: "column",
13837
+ flexMode: contentDirection === "row" ? "grow" : "initial",
13838
+ gap: iconPosition === "inline" ? "space-01" : "space-00",
13839
+ justifyContent: "center",
13840
+ children: [
13841
+ (0, import_type_guards61.isNotNil)(headingText) ? /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(Heading, { variant: headingVariant, children: [
13842
+ iconPosition === "inline" && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(IconWrapper, { $iconPosition: "inline", children: icon }),
13843
+ headingText
13844
+ ] }) : null,
13845
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(Text, { variant: textVariant, children: bodyText })
13846
+ ]
13847
+ }
13848
+ ),
13849
+ hasActions ? /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13850
+ ButtonGroup,
13851
+ {
13852
+ buttonSize,
13853
+ collapseOnSmallScreens: false,
13854
+ style: { paddingRight: "var(--wui-space-02)" },
13855
+ children: [
13856
+ (0, import_type_guards61.isNotNil)(primaryAction) && primaryAction,
13857
+ (0, import_type_guards61.isNotNil)(secondaryAction) && secondaryAction
13858
+ ]
13859
+ }
13860
+ ) : null
13861
+ ]
13862
+ }
13863
+ ),
13864
+ (0, import_type_guards61.isNotNil)(onClose) && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
13865
+ IconButton,
13866
+ {
13867
+ label: "Close",
13868
+ onClick: onClose,
13869
+ size: "sm",
13870
+ style: {
13871
+ position: "absolute",
13872
+ top: "var(--wui-space-01)",
13873
+ right: "var(--wui-space-01)"
13874
+ },
13875
+ variant: "soft",
13876
+ children: /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(Icon, { type: "close" })
13877
+ }
13878
+ )
13879
+ ]
13880
+ }
13881
+ );
13882
+ };
13883
+ Banner.displayName = "Banner";
13884
+
13885
+ // src/components/Combobox/Combobox.tsx
13886
+ var Ariakit = __toESM(require("@ariakit/react"));
13887
+ var import_react74 = require("react");
13888
+ var import_match_sorter = require("match-sorter");
13889
+ var import_styled_components97 = __toESM(require("styled-components"));
13890
+ var import_jsx_runtime280 = require("react/jsx-runtime");
13891
+ var ComboboxWapper = import_styled_components97.default.div`
13719
13892
  ${inputCss};
13720
13893
  width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
13721
13894
  padding: var(--wui-input-vertical-padding) var(--wui-input-horizontal-padding);
@@ -13764,7 +13937,7 @@ var ComboboxWapper = import_styled_components96.default.div`
13764
13937
  }
13765
13938
  }
13766
13939
  `;
13767
- var ComboboxInput = (0, import_styled_components96.default)(Ariakit.Combobox)`
13940
+ var ComboboxInput = (0, import_styled_components97.default)(Ariakit.Combobox)`
13768
13941
  appearance: none;
13769
13942
  padding: 0;
13770
13943
  width: 100%;
@@ -13779,7 +13952,7 @@ var ComboboxInput = (0, import_styled_components96.default)(Ariakit.Combobox)`
13779
13952
  outline-width: 2px;
13780
13953
  }
13781
13954
  `;
13782
- var ComboboxPopover = (0, import_styled_components96.default)(Ariakit.Popover)`
13955
+ var ComboboxPopover = (0, import_styled_components97.default)(Ariakit.Popover)`
13783
13956
  --wui-combobox-content-border: var(--wui-color-border);
13784
13957
  --wui-combobox-content-bg: var(--wui-color-bg-surface);
13785
13958
  --wui-combobox-content-border-radius: var(--wui-border-radius-02);
@@ -13804,7 +13977,7 @@ var ComboboxPopover = (0, import_styled_components96.default)(Ariakit.Popover)`
13804
13977
  --item-opacity: 0.5;
13805
13978
  }
13806
13979
  `;
13807
- var ComboboxItem2 = (0, import_styled_components96.default)(Ariakit.ComboboxItem)`
13980
+ var ComboboxItem2 = (0, import_styled_components97.default)(Ariakit.ComboboxItem)`
13808
13981
  ${variantStyleMap2.body3};
13809
13982
  display: flex;
13810
13983
  padding: var(--wui-combobox-option-padding);
@@ -13829,14 +14002,25 @@ var ComboboxItem2 = (0, import_styled_components96.default)(Ariakit.ComboboxItem
13829
14002
  background-color: transparent;
13830
14003
  }
13831
14004
  `;
13832
- var NoResults = import_styled_components96.default.div`
14005
+ var NoResults = import_styled_components97.default.div`
13833
14006
  gap: var(--wui-space-02);
13834
14007
  `;
13835
14008
  var POPOVER_WIDTH_OFFSET = 20;
14009
+ var ComboboxOption = ({ value, children }) => {
14010
+ return /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
14011
+ ComboboxItem2,
14012
+ {
14013
+ className: "combobox-item",
14014
+ focusOnHover: true,
14015
+ value,
14016
+ children
14017
+ }
14018
+ );
14019
+ };
13836
14020
  var extractOptions = (children) => {
13837
14021
  const options = {};
13838
- import_react73.Children.forEach(children, (child) => {
13839
- if ((0, import_react73.isValidElement)(child) && "value" in child.props && "children" in child.props) {
14022
+ import_react74.Children.forEach(children, (child) => {
14023
+ if ((0, import_react74.isValidElement)(child) && "value" in child.props && "children" in child.props) {
13840
14024
  options[child.props.value] = child.props.children ?? child.props.value;
13841
14025
  }
13842
14026
  });
@@ -13851,11 +14035,11 @@ var Combobox2 = ({
13851
14035
  children,
13852
14036
  fullWidth = true
13853
14037
  }) => {
13854
- const [isPending, startTransition] = (0, import_react73.useTransition)();
13855
- const [wrapperWidth, setWrapperWidth] = (0, import_react73.useState)("auto");
13856
- const comboboxWrapperRef = (0, import_react73.useRef)(null);
13857
- const options = (0, import_react73.useMemo)(() => extractOptions(children), [children]);
13858
- (0, import_react73.useEffect)(() => {
14038
+ const [isPending, startTransition] = (0, import_react74.useTransition)();
14039
+ const [wrapperWidth, setWrapperWidth] = (0, import_react74.useState)("auto");
14040
+ const comboboxWrapperRef = (0, import_react74.useRef)(null);
14041
+ const options = (0, import_react74.useMemo)(() => extractOptions(children), [children]);
14042
+ (0, import_react74.useEffect)(() => {
13859
14043
  const comboboxWrapper = comboboxWrapperRef.current;
13860
14044
  if (comboboxWrapper) {
13861
14045
  const updateWidthVariable = () => {
@@ -13873,10 +14057,10 @@ var Combobox2 = ({
13873
14057
  const handleRemoveValue = (valueToRemove) => {
13874
14058
  onChange(value.filter((val) => val !== valueToRemove));
13875
14059
  };
13876
- const matches = (0, import_react73.useMemo)(() => {
14060
+ const matches = (0, import_react74.useMemo)(() => {
13877
14061
  return (0, import_match_sorter.matchSorter)(Object.keys(options), searchValue);
13878
14062
  }, [options, searchValue]);
13879
- return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14063
+ return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13880
14064
  Ariakit.ComboboxProvider,
13881
14065
  {
13882
14066
  selectedValue: value,
@@ -13887,13 +14071,13 @@ var Combobox2 = ({
13887
14071
  });
13888
14072
  },
13889
14073
  children: [
13890
- /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14074
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13891
14075
  ComboboxWapper,
13892
14076
  {
13893
14077
  ref: comboboxWrapperRef,
13894
14078
  $fullWidth: fullWidth,
13895
14079
  children: [
13896
- value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
14080
+ value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
13897
14081
  Tag,
13898
14082
  {
13899
14083
  href: "https://example.com",
@@ -13903,11 +14087,11 @@ var Combobox2 = ({
13903
14087
  },
13904
14088
  selectedValue
13905
14089
  )),
13906
- /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(ComboboxInput, { placeholder })
14090
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(ComboboxInput, { placeholder })
13907
14091
  ]
13908
14092
  }
13909
14093
  ),
13910
- /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14094
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13911
14095
  ComboboxPopover,
13912
14096
  {
13913
14097
  "aria-busy": isPending,
@@ -13917,14 +14101,14 @@ var Combobox2 = ({
13917
14101
  width: wrapperWidth
13918
14102
  },
13919
14103
  children: [
13920
- matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14104
+ matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13921
14105
  ComboboxItem2,
13922
14106
  {
13923
14107
  className: "combobox-item",
13924
14108
  focusOnHover: true,
13925
14109
  value: match,
13926
14110
  children: [
13927
- /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
14111
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
13928
14112
  Icon,
13929
14113
  {
13930
14114
  size: "sm",
@@ -13939,7 +14123,7 @@ var Combobox2 = ({
13939
14123
  },
13940
14124
  match
13941
14125
  )),
13942
- !matches.length && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(NoResults, { children: "No results found" })
14126
+ !matches.length && /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(NoResults, { children: "No results found" })
13943
14127
  ]
13944
14128
  }
13945
14129
  )
@@ -13952,6 +14136,7 @@ var Combobox2 = ({
13952
14136
  ActionButton,
13953
14137
  Avatar,
13954
14138
  Badge,
14139
+ Banner,
13955
14140
  Box,
13956
14141
  Breadcrumb,
13957
14142
  Breadcrumbs,
@@ -13968,6 +14153,7 @@ var Combobox2 = ({
13968
14153
  CollapsibleTrigger,
13969
14154
  ColorSchemeWrapper,
13970
14155
  Combobox,
14156
+ ComboboxOption,
13971
14157
  DataCard,
13972
14158
  DataCardTrend,
13973
14159
  DataCards,