@wistia/ui 0.8.26 → 0.8.27-beta.2b8575c3.f6789ae

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.8.26
3
+ * @license @wistia/ui v0.8.27-beta.2b8575c3.f6789ae
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,
@@ -8500,6 +8501,11 @@ Checkbox.displayName = "Checkbox";
8500
8501
 
8501
8502
  // src/components/ClickRegion/ClickRegion.tsx
8502
8503
  var import_react30 = require("react");
8504
+ var isClickableElement = (element) => {
8505
+ if (!element) return false;
8506
+ const el = element;
8507
+ return el.closest("button") !== null || el.closest("a") !== null || el.closest("input") !== null || el.closest("select") !== null || el.closest("textarea") !== null || el.closest("label") !== null || el.closest("[data-wui-faux-input]") !== null;
8508
+ };
8503
8509
  var ClickRegion = ({ children, targetRef }) => {
8504
8510
  (0, import_react30.useEffect)(() => {
8505
8511
  if (targetRef.current && targetRef.current.tagName === "A") {
@@ -8512,7 +8518,10 @@ var ClickRegion = ({ children, targetRef }) => {
8512
8518
  const handleClick = (0, import_react30.useCallback)(
8513
8519
  (event) => {
8514
8520
  const node = targetRef.current;
8515
- if (event.target instanceof HTMLAnchorElement && !event.target.hasAttribute("data-click-region-target-link") || event.target instanceof HTMLButtonElement && !event.target.hasAttribute("data-click-region-target-button")) {
8521
+ if (event.target === node) {
8522
+ return;
8523
+ }
8524
+ if (isClickableElement(event.target) && event.target !== node) {
8516
8525
  event.stopPropagation();
8517
8526
  return;
8518
8527
  }
@@ -10766,11 +10775,8 @@ MenuItem.displayName = "MenuItem";
10766
10775
  // src/components/Menu/MenuRadioGroup.tsx
10767
10776
  var import_react_dropdown_menu5 = require("@radix-ui/react-dropdown-menu");
10768
10777
  var import_jsx_runtime238 = require("react/jsx-runtime");
10769
- var MenuRadioGroup = ({ children, label, ...props }) => {
10770
- return /* @__PURE__ */ (0, import_jsx_runtime238.jsxs)(import_react_dropdown_menu5.DropdownMenuRadioGroup, { ...props, children: [
10771
- /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(MenuLabel, { children: label }),
10772
- children
10773
- ] });
10778
+ var MenuRadioGroup = ({ children, ...props }) => {
10779
+ return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(import_react_dropdown_menu5.DropdownMenuRadioGroup, { ...props, children });
10774
10780
  };
10775
10781
  MenuRadioGroup.displayName = "MenuRadioGroup";
10776
10782
 
@@ -13272,6 +13278,245 @@ var WistiaLogo = ({
13272
13278
  return href !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime274.jsx)("a", { href, children: Logo }) : Logo;
13273
13279
  };
13274
13280
  WistiaLogo.displayName = "WistiaLogo";
13281
+
13282
+ // src/components/Combobox/Combobox.tsx
13283
+ var Ariakit = __toESM(require("@ariakit/react"));
13284
+ var import_react73 = require("react");
13285
+ var import_match_sorter = require("match-sorter");
13286
+ var import_styled_components95 = __toESM(require("styled-components"));
13287
+ var import_jsx_runtime275 = require("react/jsx-runtime");
13288
+ var ComboboxWapper = import_styled_components95.default.div`
13289
+ ${inputCssVariables};
13290
+ width: ${({ $fullWidth }) => $fullWidth ? "100%" : "auto"};
13291
+ padding: var(--wui-input-vertical-padding) var(--wui-input-horizontal-padding);
13292
+ background-color: var(--wui-input-color-bg);
13293
+ border: none;
13294
+ outline: 1px solid var(--wui-input-color-border);
13295
+ outline-offset: -1px;
13296
+ border-radius: var(--wui-input-border-radius);
13297
+ font-size: var(--wui-input-font-size);
13298
+ line-height: var(--wui-input-line-height);
13299
+ font-weight: var(--wui-input-font-weight);
13300
+ color: var(--wui-input-color-text);
13301
+ display: inline-flex;
13302
+ flex-wrap: wrap;
13303
+ gap: var(--wui-space-01);
13304
+
13305
+ > * {
13306
+ width: min-content !important;
13307
+ }
13308
+
13309
+ &:focus-within {
13310
+ outline: 2px solid var(--wui-input-color-border-focus);
13311
+ outline-offset: -2px;
13312
+ }
13313
+
13314
+ input {
13315
+ outline: 0 none;
13316
+ border: 0 none;
13317
+
13318
+ &::placeholder {
13319
+ color: var(--wui-input-placeholder);
13320
+ opacity: 1;
13321
+ }
13322
+
13323
+ &:focus {
13324
+ outline: 0;
13325
+ }
13326
+
13327
+ &[aria-invalid='true'] {
13328
+ outline-color: var(--wui-input-color-border-error);
13329
+ }
13330
+
13331
+ &:disabled {
13332
+ outline-color: var(--wui-color-border-disabled);
13333
+ background-color: var(--wui-color-bg-surface-disabled);
13334
+ }
13335
+ }
13336
+ `;
13337
+ var ComboboxInput = (0, import_styled_components95.default)(Ariakit.Combobox)`
13338
+ appearance: none;
13339
+ padding: 0;
13340
+ width: 100%;
13341
+ border: 0 none;
13342
+ flex: 1;
13343
+
13344
+ &[data-focus-visible] {
13345
+ outline-style: solid;
13346
+ }
13347
+
13348
+ &[data-active-item] {
13349
+ outline-width: 2px;
13350
+ }
13351
+ `;
13352
+ var ComboboxPopover = (0, import_styled_components95.default)(Ariakit.Popover)`
13353
+ --wui-combobox-content-border: var(--wui-color-border);
13354
+ --wui-combobox-content-bg: var(--wui-color-bg-surface);
13355
+ --wui-combobox-content-border-radius: var(--wui-border-radius-02);
13356
+ --wui-combobox-option-padding: var(--wui-space-02);
13357
+ --wui-combobox-option-inner-gap: var(--wui-space-03);
13358
+ --wui-combobox-option-bg-hover: var(--wui-color-bg-surface-hover);
13359
+
13360
+ border-radius: var(--wui-border-radius-02);
13361
+ padding: var(--wui-space-04);
13362
+ max-height: var(--wui-popover-max-height, 300px);
13363
+ background-color: var(--wui-color-bg-surface);
13364
+ box-shadow: var(--wui-elevation-01);
13365
+ border: 1px solid var(--wui-color-border);
13366
+ position: relative;
13367
+ z-index: 50;
13368
+ display: flex;
13369
+ flex-direction: column;
13370
+ overflow: auto;
13371
+ overscroll-behavior: contain;
13372
+
13373
+ &[aria-busy='true'] {
13374
+ --item-opacity: 0.5;
13375
+ }
13376
+ `;
13377
+ var ComboboxItem2 = (0, import_styled_components95.default)(Ariakit.ComboboxItem)`
13378
+ ${variantStyleMap2.body3};
13379
+ display: flex;
13380
+ padding: var(--wui-combobox-option-padding);
13381
+ gap: var(--wui-combobox-option-inner-gap);
13382
+ font-size: var(--font-size);
13383
+ font-weight: var(--font-weight);
13384
+ border-radius: var(--wui-border-radius-01);
13385
+ align-items: center;
13386
+ cursor: pointer;
13387
+
13388
+ &:hover,
13389
+ &:focus-visible {
13390
+ background-color: var(--wui-combobox-option-bg-hover);
13391
+ outline: none;
13392
+ }
13393
+
13394
+ &[aria-disabled='true'] {
13395
+ color: var(--wui-color-text-disabled);
13396
+ }
13397
+
13398
+ &[aria-disabled='true']:hover {
13399
+ background-color: transparent;
13400
+ }
13401
+ `;
13402
+ var NoResults = import_styled_components95.default.div`
13403
+ gap: var(--wui-space-02);
13404
+ `;
13405
+ var POPOVER_WIDTH_OFFSET = 20;
13406
+ var extractOptions = (children) => {
13407
+ const options = {};
13408
+ import_react73.Children.forEach(children, (child) => {
13409
+ if ((0, import_react73.isValidElement)(child) && "value" in child.props && "children" in child.props) {
13410
+ options[child.props.value] = child.props.children ?? child.props.value;
13411
+ }
13412
+ });
13413
+ return options;
13414
+ };
13415
+ var Combobox2 = ({
13416
+ placeholder,
13417
+ value = [],
13418
+ onChange,
13419
+ searchValue,
13420
+ onSearchValueChange,
13421
+ children,
13422
+ fullWidth = true
13423
+ }) => {
13424
+ const [isPending, startTransition] = (0, import_react73.useTransition)();
13425
+ const [wrapperWidth, setWrapperWidth] = (0, import_react73.useState)("auto");
13426
+ const comboboxWrapperRef = (0, import_react73.useRef)(null);
13427
+ const options = (0, import_react73.useMemo)(() => extractOptions(children), [children]);
13428
+ (0, import_react73.useEffect)(() => {
13429
+ const comboboxWrapper = comboboxWrapperRef.current;
13430
+ if (comboboxWrapper) {
13431
+ const updateWidthVariable = () => {
13432
+ const { width } = comboboxWrapper.getBoundingClientRect();
13433
+ setWrapperWidth(`${width - POPOVER_WIDTH_OFFSET}px`);
13434
+ };
13435
+ updateWidthVariable();
13436
+ window.addEventListener("resize", updateWidthVariable);
13437
+ return () => {
13438
+ window.removeEventListener("resize", updateWidthVariable);
13439
+ };
13440
+ }
13441
+ return () => null;
13442
+ }, []);
13443
+ const handleRemoveValue = (valueToRemove) => {
13444
+ onChange(value.filter((val) => val !== valueToRemove));
13445
+ };
13446
+ const matches = (0, import_react73.useMemo)(() => {
13447
+ return (0, import_match_sorter.matchSorter)(Object.keys(options), searchValue);
13448
+ }, [options, searchValue]);
13449
+ return /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)(
13450
+ Ariakit.ComboboxProvider,
13451
+ {
13452
+ selectedValue: value,
13453
+ setSelectedValue: onChange,
13454
+ setValue: (nextValue) => {
13455
+ startTransition(() => {
13456
+ onSearchValueChange(nextValue);
13457
+ });
13458
+ },
13459
+ children: [
13460
+ /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)(
13461
+ ComboboxWapper,
13462
+ {
13463
+ ref: comboboxWrapperRef,
13464
+ $fullWidth: fullWidth,
13465
+ children: [
13466
+ value.map((selectedValue) => /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
13467
+ Tag,
13468
+ {
13469
+ href: "https://example.com",
13470
+ label: selectedValue,
13471
+ onClickRemove: () => handleRemoveValue(selectedValue),
13472
+ onClickRemoveLabel: `Remove ${selectedValue}`
13473
+ },
13474
+ selectedValue
13475
+ )),
13476
+ /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(ComboboxInput, { placeholder })
13477
+ ]
13478
+ }
13479
+ ),
13480
+ /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)(
13481
+ ComboboxPopover,
13482
+ {
13483
+ "aria-busy": isPending,
13484
+ gutter: 8,
13485
+ sameWidth: false,
13486
+ style: {
13487
+ width: wrapperWidth
13488
+ },
13489
+ children: [
13490
+ matches.map((match) => /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)(
13491
+ ComboboxItem2,
13492
+ {
13493
+ className: "combobox-item",
13494
+ focusOnHover: true,
13495
+ value: match,
13496
+ children: [
13497
+ /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(
13498
+ Icon,
13499
+ {
13500
+ size: "sm",
13501
+ style: {
13502
+ opacity: value.includes(match) ? 1 : 0
13503
+ },
13504
+ type: "checkmark"
13505
+ }
13506
+ ),
13507
+ options[match]
13508
+ ]
13509
+ },
13510
+ match
13511
+ )),
13512
+ !matches.length && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(NoResults, { children: "No results found" })
13513
+ ]
13514
+ }
13515
+ )
13516
+ ]
13517
+ }
13518
+ );
13519
+ };
13275
13520
  // Annotate the CommonJS export names for ESM import in node:
13276
13521
  0 && (module.exports = {
13277
13522
  ActionButton,
@@ -13292,6 +13537,7 @@ WistiaLogo.displayName = "WistiaLogo";
13292
13537
  CollapsibleContent,
13293
13538
  CollapsibleTrigger,
13294
13539
  ColorSchemeWrapper,
13540
+ Combobox,
13295
13541
  DataCard,
13296
13542
  DataCardTrend,
13297
13543
  DataCards,