@wistia/ui 0.10.2 → 0.10.3-beta.131d48d0.820ab0d

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.2
3
+ * @license @wistia/ui v0.10.3-beta.131d48d0.820ab0d
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -57,6 +57,7 @@ __export(index_exports, {
57
57
  CollapsibleContent: () => CollapsibleContent,
58
58
  CollapsibleTrigger: () => CollapsibleTrigger,
59
59
  ColorSchemeWrapper: () => ColorSchemeWrapper,
60
+ Combobox: () => Combobox2,
60
61
  DataCard: () => DataCard,
61
62
  DataCardTrend: () => DataCardTrend,
62
63
  DataCards: () => DataCards,
@@ -8760,9 +8761,17 @@ var Checkbox = (0, import_react34.forwardRef)(
8760
8761
  const generatedId = (0, import_react34.useId)();
8761
8762
  const computedId = (0, import_type_guards26.isNonEmptyString)(id) ? id : `wistia-ui-checkbox-${generatedId}`;
8762
8763
  const checkboxGroupContext = useCheckboxGroup();
8763
- const contextName = checkboxGroupContext?.name;
8764
+ const groupName = checkboxGroupContext?.name;
8764
8765
  const contextOnChange = checkboxGroupContext?.onChange;
8765
- const checkboxName = name ?? contextName;
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
+ }
8766
8775
  const handleOnChange = onChange ?? contextOnChange;
8767
8776
  return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)(StyledCheckboxWrapper, { disabled, children: [
8768
8777
  /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(
@@ -11732,9 +11741,9 @@ var Radio = (0, import_react57.forwardRef)(
11732
11741
  const generatedId = (0, import_react57.useId)();
11733
11742
  const computedId = (0, import_type_guards45.isNonEmptyString)(id) ? id : `wistia-ui-radio-${generatedId}`;
11734
11743
  const radioGroupContext = useRadioGroup();
11735
- const contextName = radioGroupContext?.name;
11744
+ const groupName = radioGroupContext?.name;
11736
11745
  const contextOnChange = radioGroupContext?.onChange;
11737
- const radioName = name ?? contextName;
11746
+ const radioName = name ?? groupName;
11738
11747
  const handleOnChange = onChange ?? contextOnChange;
11739
11748
  return /* @__PURE__ */ (0, import_jsx_runtime251.jsxs)(
11740
11749
  StyledRadioWrapper,
@@ -13699,6 +13708,245 @@ var List = ({
13699
13708
  return null;
13700
13709
  };
13701
13710
  List.displayName = "List";
13711
+
13712
+ // src/components/Combobox/Combobox.tsx
13713
+ var Ariakit = __toESM(require("@ariakit/react"));
13714
+ var import_react73 = require("react");
13715
+ var import_match_sorter = require("match-sorter");
13716
+ var import_styled_components96 = __toESM(require("styled-components"));
13717
+ var import_jsx_runtime279 = require("react/jsx-runtime");
13718
+ var ComboboxWapper = import_styled_components96.default.div`
13719
+ ${inputCss};
13720
+ width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
13721
+ padding: var(--wui-input-vertical-padding) var(--wui-input-horizontal-padding);
13722
+ background-color: var(--wui-input-color-bg);
13723
+ border: none;
13724
+ outline: 1px solid var(--wui-input-color-border);
13725
+ outline-offset: -1px;
13726
+ border-radius: var(--wui-input-border-radius);
13727
+ font-size: var(--wui-input-font-size);
13728
+ line-height: var(--wui-input-line-height);
13729
+ font-weight: var(--wui-input-font-weight);
13730
+ color: var(--wui-input-color-text);
13731
+ display: inline-flex;
13732
+ flex-wrap: wrap;
13733
+ gap: var(--wui-space-01);
13734
+
13735
+ > * {
13736
+ width: min-content !important;
13737
+ }
13738
+
13739
+ &:focus-within {
13740
+ outline: 2px solid var(--wui-input-color-border-focus);
13741
+ outline-offset: -2px;
13742
+ }
13743
+
13744
+ input {
13745
+ outline: 0 none;
13746
+ border: 0 none;
13747
+
13748
+ &::placeholder {
13749
+ color: var(--wui-input-placeholder);
13750
+ opacity: 1;
13751
+ }
13752
+
13753
+ &:focus {
13754
+ outline: 0;
13755
+ }
13756
+
13757
+ &[aria-invalid='true'] {
13758
+ outline-color: var(--wui-input-color-border-error);
13759
+ }
13760
+
13761
+ &:disabled {
13762
+ outline-color: var(--wui-color-border-disabled);
13763
+ background-color: var(--wui-color-bg-surface-disabled);
13764
+ }
13765
+ }
13766
+ `;
13767
+ var ComboboxInput = (0, import_styled_components96.default)(Ariakit.Combobox)`
13768
+ appearance: none;
13769
+ padding: 0;
13770
+ width: 100%;
13771
+ border: 0 none;
13772
+ flex: 1;
13773
+
13774
+ &[data-focus-visible] {
13775
+ outline-style: solid;
13776
+ }
13777
+
13778
+ &[data-active-item] {
13779
+ outline-width: 2px;
13780
+ }
13781
+ `;
13782
+ var ComboboxPopover = (0, import_styled_components96.default)(Ariakit.Popover)`
13783
+ --wui-combobox-content-border: var(--wui-color-border);
13784
+ --wui-combobox-content-bg: var(--wui-color-bg-surface);
13785
+ --wui-combobox-content-border-radius: var(--wui-border-radius-02);
13786
+ --wui-combobox-option-padding: var(--wui-space-02);
13787
+ --wui-combobox-option-inner-gap: var(--wui-space-03);
13788
+ --wui-combobox-option-bg-hover: var(--wui-color-bg-surface-hover);
13789
+
13790
+ border-radius: var(--wui-border-radius-02);
13791
+ padding: var(--wui-space-04);
13792
+ max-height: var(--wui-popover-max-height, 300px);
13793
+ background-color: var(--wui-color-bg-surface);
13794
+ box-shadow: var(--wui-elevation-01);
13795
+ border: 1px solid var(--wui-color-border);
13796
+ position: relative;
13797
+ z-index: 50;
13798
+ display: flex;
13799
+ flex-direction: column;
13800
+ overflow: auto;
13801
+ overscroll-behavior: contain;
13802
+
13803
+ &[aria-busy='true'] {
13804
+ --item-opacity: 0.5;
13805
+ }
13806
+ `;
13807
+ var ComboboxItem2 = (0, import_styled_components96.default)(Ariakit.ComboboxItem)`
13808
+ ${variantStyleMap2.body3};
13809
+ display: flex;
13810
+ padding: var(--wui-combobox-option-padding);
13811
+ gap: var(--wui-combobox-option-inner-gap);
13812
+ font-size: var(--font-size);
13813
+ font-weight: var(--font-weight);
13814
+ border-radius: var(--wui-border-radius-01);
13815
+ align-items: center;
13816
+ cursor: pointer;
13817
+
13818
+ &:hover,
13819
+ &:focus-visible {
13820
+ background-color: var(--wui-combobox-option-bg-hover);
13821
+ outline: none;
13822
+ }
13823
+
13824
+ &[aria-disabled='true'] {
13825
+ color: var(--wui-color-text-disabled);
13826
+ }
13827
+
13828
+ &[aria-disabled='true']:hover {
13829
+ background-color: transparent;
13830
+ }
13831
+ `;
13832
+ var NoResults = import_styled_components96.default.div`
13833
+ gap: var(--wui-space-02);
13834
+ `;
13835
+ var POPOVER_WIDTH_OFFSET = 20;
13836
+ var extractOptions = (children) => {
13837
+ const options = {};
13838
+ import_react73.Children.forEach(children, (child) => {
13839
+ if ((0, import_react73.isValidElement)(child) && "value" in child.props && "children" in child.props) {
13840
+ options[child.props.value] = child.props.children ?? child.props.value;
13841
+ }
13842
+ });
13843
+ return options;
13844
+ };
13845
+ var Combobox2 = ({
13846
+ placeholder,
13847
+ value = [],
13848
+ onChange,
13849
+ searchValue,
13850
+ onSearchValueChange,
13851
+ children,
13852
+ fullWidth = true
13853
+ }) => {
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)(() => {
13859
+ const comboboxWrapper = comboboxWrapperRef.current;
13860
+ if (comboboxWrapper) {
13861
+ const updateWidthVariable = () => {
13862
+ const { width } = comboboxWrapper.getBoundingClientRect();
13863
+ setWrapperWidth(`${width - POPOVER_WIDTH_OFFSET}px`);
13864
+ };
13865
+ updateWidthVariable();
13866
+ window.addEventListener("resize", updateWidthVariable);
13867
+ return () => {
13868
+ window.removeEventListener("resize", updateWidthVariable);
13869
+ };
13870
+ }
13871
+ return () => null;
13872
+ }, []);
13873
+ const handleRemoveValue = (valueToRemove) => {
13874
+ onChange(value.filter((val) => val !== valueToRemove));
13875
+ };
13876
+ const matches = (0, import_react73.useMemo)(() => {
13877
+ return (0, import_match_sorter.matchSorter)(Object.keys(options), searchValue);
13878
+ }, [options, searchValue]);
13879
+ return /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13880
+ Ariakit.ComboboxProvider,
13881
+ {
13882
+ selectedValue: value,
13883
+ setSelectedValue: onChange,
13884
+ setValue: (nextValue) => {
13885
+ startTransition(() => {
13886
+ onSearchValueChange(nextValue);
13887
+ });
13888
+ },
13889
+ children: [
13890
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13891
+ ComboboxWapper,
13892
+ {
13893
+ ref: comboboxWrapperRef,
13894
+ $fullWidth: fullWidth,
13895
+ children: [
13896
+ value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
13897
+ Tag,
13898
+ {
13899
+ href: "https://example.com",
13900
+ label: selectedValue,
13901
+ onClickRemove: () => handleRemoveValue(selectedValue),
13902
+ onClickRemoveLabel: `Remove ${selectedValue}`
13903
+ },
13904
+ selectedValue
13905
+ )),
13906
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(ComboboxInput, { placeholder })
13907
+ ]
13908
+ }
13909
+ ),
13910
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13911
+ ComboboxPopover,
13912
+ {
13913
+ "aria-busy": isPending,
13914
+ gutter: 8,
13915
+ sameWidth: false,
13916
+ style: {
13917
+ width: wrapperWidth
13918
+ },
13919
+ children: [
13920
+ matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime279.jsxs)(
13921
+ ComboboxItem2,
13922
+ {
13923
+ className: "combobox-item",
13924
+ focusOnHover: true,
13925
+ value: match,
13926
+ children: [
13927
+ /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(
13928
+ Icon,
13929
+ {
13930
+ size: "sm",
13931
+ style: {
13932
+ opacity: value.includes(match) ? 1 : 0
13933
+ },
13934
+ type: "checkmark"
13935
+ }
13936
+ ),
13937
+ options[match]
13938
+ ]
13939
+ },
13940
+ match
13941
+ )),
13942
+ !matches.length && /* @__PURE__ */ (0, import_jsx_runtime279.jsx)(NoResults, { children: "No results found" })
13943
+ ]
13944
+ }
13945
+ )
13946
+ ]
13947
+ }
13948
+ );
13949
+ };
13702
13950
  // Annotate the CommonJS export names for ESM import in node:
13703
13951
  0 && (module.exports = {
13704
13952
  ActionButton,
@@ -13719,6 +13967,7 @@ List.displayName = "List";
13719
13967
  CollapsibleContent,
13720
13968
  CollapsibleTrigger,
13721
13969
  ColorSchemeWrapper,
13970
+ Combobox,
13722
13971
  DataCard,
13723
13972
  DataCardTrend,
13724
13973
  DataCards,