@cayuse-test/react 1.0.7 → 1.0.8

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.
@@ -3338,6 +3338,31 @@ var Combobox = React28.forwardRef(
3338
3338
  return { options: [] };
3339
3339
  });
3340
3340
  };
3341
+ const openMenu = (focusOption2) => {
3342
+ const select = selectRef.current;
3343
+ const { selectValue, isFocused } = select.state;
3344
+ const focusableOptions = select.buildFocusableOptions();
3345
+ let openAtIndex = focusOption2 === "first" ? 0 : focusableOptions.length - 1;
3346
+ if (!select.props.isMulti) {
3347
+ const selectedIndex = focusableOptions.indexOf(selectValue[0]);
3348
+ if (selectedIndex > -1) {
3349
+ openAtIndex = selectedIndex;
3350
+ }
3351
+ }
3352
+ while (isNonEmptyString(focusableOptions[openAtIndex]?.subType)) {
3353
+ openAtIndex++;
3354
+ }
3355
+ select.scrollToFocusedOptionOnUpdate = !(isFocused && select.menuListRef);
3356
+ select.setState(
3357
+ {
3358
+ inputIsHiddenAfterUpdate: false,
3359
+ focusedValue: null,
3360
+ focusedOption: focusableOptions[openAtIndex],
3361
+ focusedOptionId: select.getFocusedOptionId(focusableOptions[openAtIndex])
3362
+ },
3363
+ () => select.onMenuOpen()
3364
+ );
3365
+ };
3341
3366
  const selectedValueFocusOption = () => {
3342
3367
  const select = selectRef.current;
3343
3368
  if (!select) return;
@@ -3414,9 +3439,9 @@ var Combobox = React28.forwardRef(
3414
3439
  });
3415
3440
  };
3416
3441
  const asyncProps = isAsync ? {
3417
- cacheOptions: rest.cacheOptions ?? false,
3418
- defaultOptions: rest.defaultOptions ?? false,
3419
- loadOptions: loadOptions ? loadOptionsWithHiddenOptionsCount : void 0
3442
+ cacheOptions: typeof rest.cacheOptions === "boolean" ? rest.cacheOptions : false,
3443
+ defaultOptions: typeof rest.defaultOptions === "boolean" ? rest.defaultOptions : false,
3444
+ loadOptions: typeof loadOptions === "function" ? loadOptionsWithHiddenOptionsCount : void 0
3420
3445
  } : {};
3421
3446
  const selectProps = {
3422
3447
  "aria-label": label,
@@ -3426,13 +3451,14 @@ var Combobox = React28.forwardRef(
3426
3451
  if (instance) {
3427
3452
  selectRef.current = instance;
3428
3453
  selectRef.current.focusOption = focusOption;
3454
+ selectRef.current.openMenu = openMenu;
3429
3455
  }
3430
3456
  },
3431
3457
  selectedValueFocusOption,
3432
3458
  allExpanded,
3433
3459
  onExpandAllToggle,
3434
3460
  updateFocusedOption,
3435
- describedById: errorMessage || description ? describedById : void 0,
3461
+ describedById: Boolean(errorMessage) || Boolean(description) ? describedById : void 0,
3436
3462
  inputId: id ?? internalId,
3437
3463
  isInvalid: invalid,
3438
3464
  isDisabled: disabled,
@@ -3710,25 +3736,25 @@ function normalizeUserToOption(userOrPersonObject) {
3710
3736
  };
3711
3737
  }
3712
3738
  function UserComboboxOption(props) {
3713
- const { data, selectProps } = props;
3739
+ const { value, data, selectProps } = props;
3714
3740
  const { isSearchable, allExpanded, onExpandAllToggle } = selectProps;
3741
+ const isExpandAllOption = value === "expand-all";
3715
3742
  const [isExpanded, setIsExpanded] = useState5(allExpanded);
3716
- const { isExpandAll } = data;
3717
3743
  const innerProps = {
3718
3744
  ...props.innerProps,
3719
3745
  "data-searchable": Boolean(isSearchable)
3720
3746
  };
3721
- if (isExpandAll) {
3747
+ if (isExpandAllOption) {
3722
3748
  innerProps.onClick = (e) => {
3723
3749
  e.stopPropagation();
3724
- onExpandAllToggle(!allExpanded);
3750
+ onExpandAllToggle();
3725
3751
  };
3726
3752
  }
3727
3753
  useEffect10(() => {
3728
- if (!isExpandAll) {
3754
+ if (!isExpandAllOption) {
3729
3755
  setIsExpanded(allExpanded);
3730
3756
  }
3731
- }, [allExpanded, isExpandAll]);
3757
+ }, [allExpanded, isExpandAllOption]);
3732
3758
  if (data.subType === "narrow-criteria-hint") {
3733
3759
  innerProps["data-group"] = true;
3734
3760
  innerProps.onClick = void 0;
@@ -3737,44 +3763,43 @@ function UserComboboxOption(props) {
3737
3763
  }
3738
3764
  const handleExpandClick = (e) => {
3739
3765
  e.stopPropagation();
3740
- if (isExpandAll) {
3741
- onExpandAllToggle(!allExpanded);
3766
+ if (isExpandAllOption) {
3767
+ onExpandAllToggle();
3742
3768
  } else {
3743
3769
  setIsExpanded(!isExpanded);
3744
3770
  }
3745
3771
  };
3746
- const optionLabelText = isExpandAll ? allExpanded ? "Collapse All" : "Expand All" : data.label;
3747
- const optionLabel = /* @__PURE__ */ jsxs31("span", { className: !isExpandAll ? "combobox__option-container--indented" : "", children: [
3748
- /* @__PURE__ */ jsx48("span", { onClick: handleExpandClick, children: /* @__PURE__ */ jsx48(
3749
- Icon,
3750
- {
3751
- color: "grey",
3752
- name: `chevron-${isExpandAll ? allExpanded ? "down" : "right" : isExpanded ? "down" : "right"}`
3753
- }
3754
- ) }),
3755
- /* @__PURE__ */ jsx48(
3756
- "span",
3757
- {
3758
- className: isExpandAll ? "combobox__option--expand-all-label" : "combobox__option--text",
3759
- children: optionLabelText
3760
- }
3761
- )
3762
- ] });
3763
- return /* @__PURE__ */ jsx48(components2.Option, { ...props, innerProps, children: /* @__PURE__ */ jsxs31(
3764
- "div",
3772
+ const optionLabelText = isExpandAllOption ? allExpanded ? "Collapse All" : "Expand All" : data.label;
3773
+ const optionLabel = /* @__PURE__ */ jsxs31(
3774
+ "span",
3765
3775
  {
3766
- className: "combobox__option-container",
3776
+ className: !isExpandAllOption ? "combobox__option-container--indented" : "",
3767
3777
  children: [
3768
- optionLabel,
3769
- !isExpandAll && isExpanded && /* @__PURE__ */ jsxs31("div", { className: "combobox__option--expanded", children: [
3770
- /* @__PURE__ */ jsx48("div", { children: data.user.email }),
3771
- /* @__PURE__ */ jsx48("div", { children: data.user.unitName }),
3772
- /* @__PURE__ */ jsx48("div", { children: data.user.profileTypes })
3773
- ] })
3778
+ /* @__PURE__ */ jsx48("span", { onClick: handleExpandClick, children: /* @__PURE__ */ jsx48(
3779
+ Icon,
3780
+ {
3781
+ color: "grey",
3782
+ name: `chevron-${isExpandAllOption ? allExpanded ? "down" : "right" : isExpanded ? "down" : "right"}`
3783
+ }
3784
+ ) }),
3785
+ /* @__PURE__ */ jsx48(
3786
+ "span",
3787
+ {
3788
+ className: isExpandAllOption ? "combobox__option--expand-all-label" : "combobox__option--text",
3789
+ children: optionLabelText
3790
+ }
3791
+ )
3774
3792
  ]
3775
- },
3776
- isExpandAll ? "expand-all" : data.value
3777
- ) });
3793
+ }
3794
+ );
3795
+ return /* @__PURE__ */ jsx48(components2.Option, { ...props, innerProps, children: /* @__PURE__ */ jsxs31("div", { className: "combobox__option-container", children: [
3796
+ optionLabel,
3797
+ !isExpandAllOption && isExpanded ? /* @__PURE__ */ jsxs31("div", { className: "combobox__option--expanded", children: [
3798
+ /* @__PURE__ */ jsx48("div", { children: data.user.email }),
3799
+ /* @__PURE__ */ jsx48("div", { children: data.user.unitName }),
3800
+ /* @__PURE__ */ jsx48("div", { children: data.user.profileTypes })
3801
+ ] }) : null
3802
+ ] }, data.value) });
3778
3803
  }
3779
3804
 
3780
3805
  // packages/components/form/user-select/user-select.tsx
@@ -10382,4 +10407,4 @@ export {
10382
10407
  MilestoneProgress2 as MilestoneProgress,
10383
10408
  TaskFormHeader
10384
10409
  };
10385
- //# sourceMappingURL=chunk-MLVINKXL.js.map
10410
+ //# sourceMappingURL=chunk-SYDHZCBD.js.map