@wistia/ui 0.10.3 → 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
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,
@@ -13701,13 +13703,192 @@ var List = ({
13701
13703
  };
13702
13704
  List.displayName = "List";
13703
13705
 
13704
- // src/components/Combobox/Combobox.tsx
13705
- var Ariakit = __toESM(require("@ariakit/react"));
13706
+ // src/components/Banner/Banner.tsx
13706
13707
  var import_react73 = require("react");
13707
- var import_match_sorter = require("match-sorter");
13708
13708
  var import_styled_components96 = __toESM(require("styled-components"));
13709
+ var import_type_guards61 = require("@wistia/type-guards");
13709
13710
  var import_jsx_runtime279 = require("react/jsx-runtime");
13710
- 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`
13711
13892
  ${inputCss};
13712
13893
  width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
13713
13894
  padding: var(--wui-input-vertical-padding) var(--wui-input-horizontal-padding);
@@ -13756,7 +13937,7 @@ var ComboboxWapper = import_styled_components96.default.div`
13756
13937
  }
13757
13938
  }
13758
13939
  `;
13759
- var ComboboxInput = (0, import_styled_components96.default)(Ariakit.Combobox)`
13940
+ var ComboboxInput = (0, import_styled_components97.default)(Ariakit.Combobox)`
13760
13941
  appearance: none;
13761
13942
  padding: 0;
13762
13943
  width: 100%;
@@ -13771,7 +13952,7 @@ var ComboboxInput = (0, import_styled_components96.default)(Ariakit.Combobox)`
13771
13952
  outline-width: 2px;
13772
13953
  }
13773
13954
  `;
13774
- var ComboboxPopover = (0, import_styled_components96.default)(Ariakit.Popover)`
13955
+ var ComboboxPopover = (0, import_styled_components97.default)(Ariakit.Popover)`
13775
13956
  --wui-combobox-content-border: var(--wui-color-border);
13776
13957
  --wui-combobox-content-bg: var(--wui-color-bg-surface);
13777
13958
  --wui-combobox-content-border-radius: var(--wui-border-radius-02);
@@ -13796,7 +13977,7 @@ var ComboboxPopover = (0, import_styled_components96.default)(Ariakit.Popover)`
13796
13977
  --item-opacity: 0.5;
13797
13978
  }
13798
13979
  `;
13799
- var ComboboxItem2 = (0, import_styled_components96.default)(Ariakit.ComboboxItem)`
13980
+ var ComboboxItem2 = (0, import_styled_components97.default)(Ariakit.ComboboxItem)`
13800
13981
  ${variantStyleMap2.body3};
13801
13982
  display: flex;
13802
13983
  padding: var(--wui-combobox-option-padding);
@@ -13821,14 +14002,25 @@ var ComboboxItem2 = (0, import_styled_components96.default)(Ariakit.ComboboxItem
13821
14002
  background-color: transparent;
13822
14003
  }
13823
14004
  `;
13824
- var NoResults = import_styled_components96.default.div`
14005
+ var NoResults = import_styled_components97.default.div`
13825
14006
  gap: var(--wui-space-02);
13826
14007
  `;
13827
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
+ };
13828
14020
  var extractOptions = (children) => {
13829
14021
  const options = {};
13830
- import_react73.Children.forEach(children, (child) => {
13831
- 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) {
13832
14024
  options[child.props.value] = child.props.children ?? child.props.value;
13833
14025
  }
13834
14026
  });
@@ -13843,11 +14035,11 @@ var Combobox2 = ({
13843
14035
  children,
13844
14036
  fullWidth = true
13845
14037
  }) => {
13846
- const [isPending, startTransition] = (0, import_react73.useTransition)();
13847
- const [wrapperWidth, setWrapperWidth] = (0, import_react73.useState)("auto");
13848
- const comboboxWrapperRef = (0, import_react73.useRef)(null);
13849
- const options = (0, import_react73.useMemo)(() => extractOptions(children), [children]);
13850
- (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)(() => {
13851
14043
  const comboboxWrapper = comboboxWrapperRef.current;
13852
14044
  if (comboboxWrapper) {
13853
14045
  const updateWidthVariable = () => {
@@ -13865,10 +14057,10 @@ var Combobox2 = ({
13865
14057
  const handleRemoveValue = (valueToRemove) => {
13866
14058
  onChange(value.filter((val) => val !== valueToRemove));
13867
14059
  };
13868
- const matches = (0, import_react73.useMemo)(() => {
14060
+ const matches = (0, import_react74.useMemo)(() => {
13869
14061
  return (0, import_match_sorter.matchSorter)(Object.keys(options), searchValue);
13870
14062
  }, [options, searchValue]);
13871
- return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14063
+ return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13872
14064
  Ariakit.ComboboxProvider,
13873
14065
  {
13874
14066
  selectedValue: value,
@@ -13879,13 +14071,13 @@ var Combobox2 = ({
13879
14071
  });
13880
14072
  },
13881
14073
  children: [
13882
- /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14074
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13883
14075
  ComboboxWapper,
13884
14076
  {
13885
14077
  ref: comboboxWrapperRef,
13886
14078
  $fullWidth: fullWidth,
13887
14079
  children: [
13888
- value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
14080
+ value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
13889
14081
  Tag,
13890
14082
  {
13891
14083
  href: "https://example.com",
@@ -13895,11 +14087,11 @@ var Combobox2 = ({
13895
14087
  },
13896
14088
  selectedValue
13897
14089
  )),
13898
- /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(ComboboxInput, { placeholder })
14090
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(ComboboxInput, { placeholder })
13899
14091
  ]
13900
14092
  }
13901
14093
  ),
13902
- /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14094
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13903
14095
  ComboboxPopover,
13904
14096
  {
13905
14097
  "aria-busy": isPending,
@@ -13909,14 +14101,14 @@ var Combobox2 = ({
13909
14101
  width: wrapperWidth
13910
14102
  },
13911
14103
  children: [
13912
- matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
14104
+ matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(
13913
14105
  ComboboxItem2,
13914
14106
  {
13915
14107
  className: "combobox-item",
13916
14108
  focusOnHover: true,
13917
14109
  value: match,
13918
14110
  children: [
13919
- /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
14111
+ /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(
13920
14112
  Icon,
13921
14113
  {
13922
14114
  size: "sm",
@@ -13931,7 +14123,7 @@ var Combobox2 = ({
13931
14123
  },
13932
14124
  match
13933
14125
  )),
13934
- !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" })
13935
14127
  ]
13936
14128
  }
13937
14129
  )
@@ -13944,6 +14136,7 @@ var Combobox2 = ({
13944
14136
  ActionButton,
13945
14137
  Avatar,
13946
14138
  Badge,
14139
+ Banner,
13947
14140
  Box,
13948
14141
  Breadcrumb,
13949
14142
  Breadcrumbs,
@@ -13960,6 +14153,7 @@ var Combobox2 = ({
13960
14153
  CollapsibleTrigger,
13961
14154
  ColorSchemeWrapper,
13962
14155
  Combobox,
14156
+ ComboboxOption,
13963
14157
  DataCard,
13964
14158
  DataCardTrend,
13965
14159
  DataCards,