@cayuse-test/react 1.0.6 → 1.0.7

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.
@@ -20,7 +20,6 @@ import {
20
20
  isNonEmptyString,
21
21
  isNumber,
22
22
  isObject,
23
- isObjectWithKey,
24
23
  isUrl,
25
24
  loginWithRedirect,
26
25
  request
@@ -3325,7 +3324,7 @@ var Combobox = React28.forwardRef(
3325
3324
  const isAsync = isAsyncComponent(props);
3326
3325
  const loadOptionsWithHiddenOptionsCount = (inputValue, ...args) => {
3327
3326
  return loadOptions(inputValue, ...args).then((result) => {
3328
- if (isObjectWithKey(result, "options")) {
3327
+ if ("options" in result) {
3329
3328
  return buildOptions(result.options, {
3330
3329
  inputValue,
3331
3330
  showNarrowCriteriaHint,
@@ -3334,6 +3333,9 @@ var Combobox = React28.forwardRef(
3334
3333
  });
3335
3334
  }
3336
3335
  return buildOptions(result, { inputValue });
3336
+ }).catch((error) => {
3337
+ console.error("Error loading options:", error);
3338
+ return { options: [] };
3337
3339
  });
3338
3340
  };
3339
3341
  const selectedValueFocusOption = () => {
@@ -3373,17 +3375,57 @@ var Combobox = React28.forwardRef(
3373
3375
  });
3374
3376
  }
3375
3377
  };
3378
+ const focusOption = (direction) => {
3379
+ const pageSize = selectRef.current.props.pageSize;
3380
+ const focusedOption = selectRef.current.state.focusedOption;
3381
+ const options = selectRef.current.getFocusableOptions();
3382
+ if (!options.length) return;
3383
+ let nextFocus = 0;
3384
+ let focusedIndex = options.indexOf(focusedOption);
3385
+ if (!focusedOption) {
3386
+ focusedIndex = -1;
3387
+ }
3388
+ while (true) {
3389
+ if (direction === "up") {
3390
+ nextFocus = focusedIndex > 0 ? focusedIndex - 1 : options.length - 1;
3391
+ focusedIndex--;
3392
+ } else if (direction === "down") {
3393
+ nextFocus = (focusedIndex + 1) % options.length;
3394
+ focusedIndex++;
3395
+ } else if (direction === "pageup") {
3396
+ nextFocus = focusedIndex - pageSize;
3397
+ if (nextFocus < 0) nextFocus = 0;
3398
+ } else if (direction === "pagedown") {
3399
+ nextFocus = focusedIndex + pageSize;
3400
+ if (nextFocus > options.length - 1) nextFocus = options.length - 1;
3401
+ } else if (direction === "last") {
3402
+ nextFocus = options.length - 1;
3403
+ focusedIndex--;
3404
+ }
3405
+ if (!options[nextFocus]?.subType) {
3406
+ break;
3407
+ }
3408
+ }
3409
+ selectRef.current.scrollToFocusedOptionOnUpdate = true;
3410
+ selectRef.current.setState({
3411
+ focusedOption: options[nextFocus],
3412
+ focusedValue: null,
3413
+ focusedOptionId: selectRef.current.getFocusedOptionId(options[nextFocus])
3414
+ });
3415
+ };
3376
3416
  const asyncProps = isAsync ? {
3377
3417
  cacheOptions: rest.cacheOptions ?? false,
3378
3418
  defaultOptions: rest.defaultOptions ?? false,
3379
3419
  loadOptions: loadOptions ? loadOptionsWithHiddenOptionsCount : void 0
3380
3420
  } : {};
3381
3421
  const selectProps = {
3422
+ "aria-label": label,
3382
3423
  ...rest,
3383
3424
  ...asyncProps,
3384
3425
  ref: (instance) => {
3385
3426
  if (instance) {
3386
3427
  selectRef.current = instance;
3428
+ selectRef.current.focusOption = focusOption;
3387
3429
  }
3388
3430
  },
3389
3431
  selectedValueFocusOption,
@@ -3413,8 +3455,7 @@ var Combobox = React28.forwardRef(
3413
3455
  },
3414
3456
  noOptionsMessage: noOptionsMessage ? typeof noOptionsMessage === "function" ? noOptionsMessage : () => noOptionsMessage : void 0,
3415
3457
  loadingMessage: loadingMessage ? typeof loadingMessage === "function" ? loadingMessage : () => loadingMessage : void 0,
3416
- unstyled: true,
3417
- "aria-label": label
3458
+ unstyled: true
3418
3459
  };
3419
3460
  return /* @__PURE__ */ jsxs29(
3420
3461
  "fieldset",
@@ -3719,14 +3760,21 @@ function UserComboboxOption(props) {
3719
3760
  }
3720
3761
  )
3721
3762
  ] });
3722
- return /* @__PURE__ */ jsx48(components2.Option, { ...props, innerProps, children: /* @__PURE__ */ jsxs31("div", { className: "combobox__option-container", children: [
3723
- optionLabel,
3724
- !isExpandAll && isExpanded && /* @__PURE__ */ jsxs31("div", { className: "combobox__option--expanded", children: [
3725
- /* @__PURE__ */ jsx48("div", { children: data.user.email }),
3726
- /* @__PURE__ */ jsx48("div", { children: data.user.unitName }),
3727
- /* @__PURE__ */ jsx48("div", { children: data.user.profileTypes })
3728
- ] })
3729
- ] }) });
3763
+ return /* @__PURE__ */ jsx48(components2.Option, { ...props, innerProps, children: /* @__PURE__ */ jsxs31(
3764
+ "div",
3765
+ {
3766
+ className: "combobox__option-container",
3767
+ 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
+ ] })
3774
+ ]
3775
+ },
3776
+ isExpandAll ? "expand-all" : data.value
3777
+ ) });
3730
3778
  }
3731
3779
 
3732
3780
  // packages/components/form/user-select/user-select.tsx
@@ -6424,7 +6472,7 @@ function UserComboboxOption2(props) {
6424
6472
  Icon,
6425
6473
  {
6426
6474
  color: "grey",
6427
- name: `chevron ${isExpandAll ? allExpanded ? "down" : "right" : isExpanded ? "down" : "right"}`
6475
+ name: `chevron-${isExpandAll ? allExpanded ? "down" : "right" : isExpanded ? "down" : "right"}`
6428
6476
  }
6429
6477
  ) }),
6430
6478
  /* @__PURE__ */ jsx67(
@@ -10334,4 +10382,4 @@ export {
10334
10382
  MilestoneProgress2 as MilestoneProgress,
10335
10383
  TaskFormHeader
10336
10384
  };
10337
- //# sourceMappingURL=chunk-QRWUG2FO.js.map
10385
+ //# sourceMappingURL=chunk-MLVINKXL.js.map