@cayuse-test/react 1.0.7 → 1.0.9

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MAX_FILE_SIZE_75_MB,
3
3
  useClickOutside
4
- } from "./chunk-BVB7EXJY.js";
4
+ } from "./chunk-XVA4YFXM.js";
5
5
  import {
6
6
  capitalizeAndJoin,
7
7
  flushStorage,
@@ -2326,15 +2326,16 @@ function SelectableCell({
2326
2326
  row,
2327
2327
  isMultiSelect,
2328
2328
  onRowSelectionChange,
2329
- rowAriaLabel
2329
+ rowAriaLabel,
2330
+ tableId
2330
2331
  }) {
2331
2332
  if (!row._isSelectable) {
2332
2333
  return /* @__PURE__ */ jsx34("td", {});
2333
2334
  }
2334
2335
  const rowLabel = isFunction(rowAriaLabel) ? rowAriaLabel({ row }) : "";
2335
2336
  function onSelect(event) {
2336
- event.preventDefault();
2337
- event.stopPropagation();
2337
+ event?.preventDefault();
2338
+ event?.stopPropagation();
2338
2339
  if (!row._isDisabledForSelection) {
2339
2340
  onRowSelectionChange({
2340
2341
  rows: [row],
@@ -2357,7 +2358,7 @@ function SelectableCell({
2357
2358
  return /* @__PURE__ */ jsx34("td", { className: "dynamic-table__selectable-cell", onClick: onSelect, children: /* @__PURE__ */ jsx34(
2358
2359
  Radio,
2359
2360
  {
2360
- name: "table-single-select",
2361
+ name: `table-single-select-${tableId}`,
2361
2362
  className: "dynamic-table__single-select",
2362
2363
  checked: row._isSelected,
2363
2364
  onChange: onSelect,
@@ -2377,6 +2378,7 @@ function SelectableCell({
2377
2378
  import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
2378
2379
  function RowContent(props) {
2379
2380
  const {
2381
+ tableId,
2380
2382
  row,
2381
2383
  rowIndex,
2382
2384
  subRowIndex,
@@ -2426,6 +2428,7 @@ function RowContent(props) {
2426
2428
  SelectableCell,
2427
2429
  {
2428
2430
  row,
2431
+ tableId,
2429
2432
  isMultiSelect,
2430
2433
  onRowSelectionChange,
2431
2434
  rowAriaLabel
@@ -2456,6 +2459,7 @@ function RowContent(props) {
2456
2459
  import { Fragment as Fragment4, jsx as jsx36, jsxs as jsxs22 } from "react/jsx-runtime";
2457
2460
  function TableBodyContent(props) {
2458
2461
  const {
2462
+ tableId,
2459
2463
  isLoading,
2460
2464
  isRefresh,
2461
2465
  headers,
@@ -2488,6 +2492,7 @@ function TableBodyContent(props) {
2488
2492
  /* @__PURE__ */ jsx36(
2489
2493
  RowContent,
2490
2494
  {
2495
+ tableId,
2491
2496
  headers,
2492
2497
  row,
2493
2498
  rowIndex,
@@ -2510,6 +2515,7 @@ function TableBodyContent(props) {
2510
2515
  /* @__PURE__ */ jsx36(
2511
2516
  RowContent,
2512
2517
  {
2518
+ tableId,
2513
2519
  headers,
2514
2520
  row: subRow,
2515
2521
  rowIndex,
@@ -2619,8 +2625,10 @@ var DynamicTable = forwardRef4(
2619
2625
  children
2620
2626
  } = props;
2621
2627
  const tableHeaders = headers.filter((h) => isNonEmptyObject(h));
2622
- const rootRef = useRef4(null);
2623
2628
  const captionId = useId3();
2629
+ const tId = useId3();
2630
+ const tableId = id || tId;
2631
+ const rootRef = useRef4(null);
2624
2632
  const [expandedRows, setExpandedRows] = useState4([]);
2625
2633
  function toggleExpandableRow(event) {
2626
2634
  const rowIndex = Number(event.currentTarget.dataset.rowIndex);
@@ -2715,7 +2723,7 @@ var DynamicTable = forwardRef4(
2715
2723
  /* @__PURE__ */ jsx38("div", { className: "dynamic-table__wrapper", children: /* @__PURE__ */ jsxs24(
2716
2724
  "table",
2717
2725
  {
2718
- id,
2726
+ id: tableId,
2719
2727
  className: "dynamic-table",
2720
2728
  "data-exapandable": isExpandable,
2721
2729
  "data-selectable": isSelectable,
@@ -2773,6 +2781,7 @@ var DynamicTable = forwardRef4(
2773
2781
  children: /* @__PURE__ */ jsx38(
2774
2782
  TableBodyContent,
2775
2783
  {
2784
+ tableId,
2776
2785
  rows: tableRows,
2777
2786
  headers: tableHeaders,
2778
2787
  isLoading,
@@ -3338,6 +3347,31 @@ var Combobox = React28.forwardRef(
3338
3347
  return { options: [] };
3339
3348
  });
3340
3349
  };
3350
+ const openMenu = (focusOption2) => {
3351
+ const select = selectRef.current;
3352
+ const { selectValue, isFocused } = select.state;
3353
+ const focusableOptions = select.buildFocusableOptions();
3354
+ let openAtIndex = focusOption2 === "first" ? 0 : focusableOptions.length - 1;
3355
+ if (!select.props.isMulti) {
3356
+ const selectedIndex = focusableOptions.indexOf(selectValue[0]);
3357
+ if (selectedIndex > -1) {
3358
+ openAtIndex = selectedIndex;
3359
+ }
3360
+ }
3361
+ while (isNonEmptyString(focusableOptions[openAtIndex]?.subType)) {
3362
+ openAtIndex++;
3363
+ }
3364
+ select.scrollToFocusedOptionOnUpdate = !(isFocused && select.menuListRef);
3365
+ select.setState(
3366
+ {
3367
+ inputIsHiddenAfterUpdate: false,
3368
+ focusedValue: null,
3369
+ focusedOption: focusableOptions[openAtIndex],
3370
+ focusedOptionId: select.getFocusedOptionId(focusableOptions[openAtIndex])
3371
+ },
3372
+ () => select.onMenuOpen()
3373
+ );
3374
+ };
3341
3375
  const selectedValueFocusOption = () => {
3342
3376
  const select = selectRef.current;
3343
3377
  if (!select) return;
@@ -3414,9 +3448,9 @@ var Combobox = React28.forwardRef(
3414
3448
  });
3415
3449
  };
3416
3450
  const asyncProps = isAsync ? {
3417
- cacheOptions: rest.cacheOptions ?? false,
3418
- defaultOptions: rest.defaultOptions ?? false,
3419
- loadOptions: loadOptions ? loadOptionsWithHiddenOptionsCount : void 0
3451
+ cacheOptions: typeof rest.cacheOptions === "boolean" ? rest.cacheOptions : false,
3452
+ defaultOptions: typeof rest.defaultOptions === "boolean" ? rest.defaultOptions : false,
3453
+ loadOptions: typeof loadOptions === "function" ? loadOptionsWithHiddenOptionsCount : void 0
3420
3454
  } : {};
3421
3455
  const selectProps = {
3422
3456
  "aria-label": label,
@@ -3426,13 +3460,14 @@ var Combobox = React28.forwardRef(
3426
3460
  if (instance) {
3427
3461
  selectRef.current = instance;
3428
3462
  selectRef.current.focusOption = focusOption;
3463
+ selectRef.current.openMenu = openMenu;
3429
3464
  }
3430
3465
  },
3431
3466
  selectedValueFocusOption,
3432
3467
  allExpanded,
3433
3468
  onExpandAllToggle,
3434
3469
  updateFocusedOption,
3435
- describedById: errorMessage || description ? describedById : void 0,
3470
+ describedById: Boolean(errorMessage) || Boolean(description) ? describedById : void 0,
3436
3471
  inputId: id ?? internalId,
3437
3472
  isInvalid: invalid,
3438
3473
  isDisabled: disabled,
@@ -3710,25 +3745,25 @@ function normalizeUserToOption(userOrPersonObject) {
3710
3745
  };
3711
3746
  }
3712
3747
  function UserComboboxOption(props) {
3713
- const { data, selectProps } = props;
3748
+ const { value, data, selectProps } = props;
3714
3749
  const { isSearchable, allExpanded, onExpandAllToggle } = selectProps;
3750
+ const isExpandAllOption = value === "expand-all";
3715
3751
  const [isExpanded, setIsExpanded] = useState5(allExpanded);
3716
- const { isExpandAll } = data;
3717
3752
  const innerProps = {
3718
3753
  ...props.innerProps,
3719
3754
  "data-searchable": Boolean(isSearchable)
3720
3755
  };
3721
- if (isExpandAll) {
3756
+ if (isExpandAllOption) {
3722
3757
  innerProps.onClick = (e) => {
3723
3758
  e.stopPropagation();
3724
- onExpandAllToggle(!allExpanded);
3759
+ onExpandAllToggle();
3725
3760
  };
3726
3761
  }
3727
3762
  useEffect10(() => {
3728
- if (!isExpandAll) {
3763
+ if (!isExpandAllOption) {
3729
3764
  setIsExpanded(allExpanded);
3730
3765
  }
3731
- }, [allExpanded, isExpandAll]);
3766
+ }, [allExpanded, isExpandAllOption]);
3732
3767
  if (data.subType === "narrow-criteria-hint") {
3733
3768
  innerProps["data-group"] = true;
3734
3769
  innerProps.onClick = void 0;
@@ -3737,44 +3772,43 @@ function UserComboboxOption(props) {
3737
3772
  }
3738
3773
  const handleExpandClick = (e) => {
3739
3774
  e.stopPropagation();
3740
- if (isExpandAll) {
3741
- onExpandAllToggle(!allExpanded);
3775
+ if (isExpandAllOption) {
3776
+ onExpandAllToggle();
3742
3777
  } else {
3743
3778
  setIsExpanded(!isExpanded);
3744
3779
  }
3745
3780
  };
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",
3781
+ const optionLabelText = isExpandAllOption ? allExpanded ? "Collapse All" : "Expand All" : data.label;
3782
+ const optionLabel = /* @__PURE__ */ jsxs31(
3783
+ "span",
3765
3784
  {
3766
- className: "combobox__option-container",
3785
+ className: !isExpandAllOption ? "combobox__option-container--indented" : "",
3767
3786
  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
- ] })
3787
+ /* @__PURE__ */ jsx48("span", { onClick: handleExpandClick, children: /* @__PURE__ */ jsx48(
3788
+ Icon,
3789
+ {
3790
+ color: "grey",
3791
+ name: `chevron-${isExpandAllOption ? allExpanded ? "down" : "right" : isExpanded ? "down" : "right"}`
3792
+ }
3793
+ ) }),
3794
+ /* @__PURE__ */ jsx48(
3795
+ "span",
3796
+ {
3797
+ className: isExpandAllOption ? "combobox__option--expand-all-label" : "combobox__option--text",
3798
+ children: optionLabelText
3799
+ }
3800
+ )
3774
3801
  ]
3775
- },
3776
- isExpandAll ? "expand-all" : data.value
3777
- ) });
3802
+ }
3803
+ );
3804
+ return /* @__PURE__ */ jsx48(components2.Option, { ...props, innerProps, children: /* @__PURE__ */ jsxs31("div", { className: "combobox__option-container", children: [
3805
+ optionLabel,
3806
+ !isExpandAllOption && isExpanded ? /* @__PURE__ */ jsxs31("div", { className: "combobox__option--expanded", children: [
3807
+ /* @__PURE__ */ jsx48("div", { children: data.user.email }),
3808
+ /* @__PURE__ */ jsx48("div", { children: data.user.unitName }),
3809
+ /* @__PURE__ */ jsx48("div", { children: data.user.profileTypes })
3810
+ ] }) : null
3811
+ ] }, data.value) });
3778
3812
  }
3779
3813
 
3780
3814
  // packages/components/form/user-select/user-select.tsx
@@ -10382,4 +10416,4 @@ export {
10382
10416
  MilestoneProgress2 as MilestoneProgress,
10383
10417
  TaskFormHeader
10384
10418
  };
10385
- //# sourceMappingURL=chunk-MLVINKXL.js.map
10419
+ //# sourceMappingURL=chunk-XU6XYQR5.js.map