@ceed/cds 1.15.0-next.9 → 1.15.0

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.
@@ -21,7 +21,6 @@ interface PaginationProps extends React.ComponentProps<typeof PaginationRoot> {
21
21
  rowCount: number;
22
22
  onPageChange: (newPage: number) => void;
23
23
  size?: 'sm' | 'md' | 'lg';
24
- variant?: 'standard' | 'compact';
25
24
  }
26
25
  declare function Pagination(props: PaginationProps): React.JSX.Element;
27
26
  declare namespace Pagination {
@@ -161,6 +161,18 @@ function MyComponent() {
161
161
 
162
162
  ```tsx
163
163
  <Stack spacing={2}>
164
+ <Stack direction="row" spacing={1}>
165
+ <button type="button" onClick={() => {
166
+ setOptions([...options, {
167
+ value: `new-${Date.now()}`,
168
+ label: `New Item ${options.length - 11}`
169
+ }]);
170
+ }} style={{
171
+ padding: '4px 12px',
172
+ cursor: 'pointer'
173
+ }}>
174
+ Add New Option
175
+ </button>
164
176
  <button type="button" onClick={() => {
165
177
  setKey(prev => prev + 1);
166
178
  }} style={{
@@ -169,11 +181,12 @@ function MyComponent() {
169
181
  }}>
170
182
  Force Re-render
171
183
  </button>
172
- <FilterableCheckboxGroup key={key} label="Sorting Demo" placeholder="Search..." helperText="Initial sort: Selected (C,B,A,3,2,1) first, then unselected (X,Y,Z,7,8,9)" options={sortingOptions} value={value} onChange={setValue} />
184
+ </Stack>
185
+ <FilterableCheckboxGroup key={key} label="Sorting Demo" placeholder="Search..." helperText="Click 'Add New Option' to test sorting when options change" options={options} value={value} onChange={setValue} />
173
186
  <Typography level="body-sm" sx={{
174
187
  whiteSpace: 'pre-line'
175
188
  }}>
176
- {`Selected: ${value.length > 0 ? value.join(', ') : 'None'}\n\nClick "Force Re-render" button to remount the component.\nOrder should remain the same (sorted only on initial mount).`}
189
+ {`Selected: ${value.length > 0 ? value.join(', ') : 'None'}\n\nOptions count: ${options.length}\n\n- Add New Option: Add new item to test sorting when options change\n- Force Re-render: Remount component to test initial sorting\n\nAlphabet items (A-Z) appear first, then numbers (1-9).`}
177
190
  </Typography>
178
191
  </Stack>
179
192
  ```
@@ -2,8 +2,8 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- ```
6
- <Canvas of={Pagination.Default} />
5
+ ```text
6
+ // Unable to derive source for Default
7
7
  ```
8
8
 
9
9
  | Field | Description | Default |
package/dist/index.cjs CHANGED
@@ -3528,10 +3528,8 @@ TableBody.displayName = "TableBody";
3528
3528
 
3529
3529
  // src/components/Pagination/Pagination.tsx
3530
3530
  var import_react27 = __toESM(require("react"));
3531
- var import_ChevronLeftRounded = __toESM(require("@mui/icons-material/ChevronLeftRounded"));
3532
- var import_ChevronRightRounded = __toESM(require("@mui/icons-material/ChevronRightRounded"));
3533
- var import_FirstPageRounded = __toESM(require("@mui/icons-material/FirstPageRounded"));
3534
- var import_LastPageRounded = __toESM(require("@mui/icons-material/LastPageRounded"));
3531
+ var import_ChevronLeft2 = __toESM(require("@mui/icons-material/ChevronLeft"));
3532
+ var import_ChevronRight2 = __toESM(require("@mui/icons-material/ChevronRight"));
3535
3533
  var import_joy35 = require("@mui/joy");
3536
3534
  var PaginationButton = (0, import_joy35.styled)(Button_default, {
3537
3535
  name: "Pagination",
@@ -3590,7 +3588,6 @@ function Pagination(props) {
3590
3588
  onPageChange,
3591
3589
  rowCount,
3592
3590
  size = "md",
3593
- variant = "standard",
3594
3591
  ...innerProps
3595
3592
  } = props;
3596
3593
  const [paginationModel, setPaginationModel] = useControlledState(
@@ -3617,87 +3614,6 @@ function Pagination(props) {
3617
3614
  setPaginationModel({ ...paginationModel, page: lastPage });
3618
3615
  }
3619
3616
  }, [rowCount, paginationModel, lastPage, setPaginationModel]);
3620
- const pageOptions = Array.from({ length: lastPage }, (_, i) => ({
3621
- label: `${i + 1}`,
3622
- value: `${i + 1}`
3623
- }));
3624
- if (variant === "compact") {
3625
- return /* @__PURE__ */ import_react27.default.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ import_react27.default.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ import_react27.default.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ import_react27.default.createElement(
3626
- PaginationIconButton,
3627
- {
3628
- size,
3629
- variant: "plain",
3630
- color: "neutral",
3631
- onClick: () => handlePageChange(firstPage),
3632
- disabled: paginationModel.page === firstPage,
3633
- "aria-label": "First page"
3634
- },
3635
- /* @__PURE__ */ import_react27.default.createElement(import_FirstPageRounded.default, null)
3636
- ), /* @__PURE__ */ import_react27.default.createElement(
3637
- PaginationIconButton,
3638
- {
3639
- size,
3640
- variant: "plain",
3641
- color: "neutral",
3642
- onClick: () => handlePageChange(paginationModel.page - 1),
3643
- disabled: paginationModel.page === firstPage,
3644
- "aria-label": "Previous page"
3645
- },
3646
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeftRounded.default, null)
3647
- )), /* @__PURE__ */ import_react27.default.createElement(
3648
- Autocomplete_default,
3649
- {
3650
- size,
3651
- value: `${paginationModel.page}`,
3652
- onChange: (event) => {
3653
- if (event.target.value) {
3654
- handlePageChange(parseInt(event.target.value, 10));
3655
- }
3656
- },
3657
- options: pageOptions,
3658
- sx: {
3659
- width: {
3660
- sm: "80px",
3661
- md: "100px",
3662
- lg: "120px"
3663
- }[size]
3664
- }
3665
- }
3666
- ), /* @__PURE__ */ import_react27.default.createElement(
3667
- Typography_default,
3668
- {
3669
- level: `body-${size}`,
3670
- sx: (theme) => ({
3671
- color: theme.palette.text.secondary,
3672
- fontWeight: 500
3673
- })
3674
- },
3675
- "/ ",
3676
- lastPage
3677
- ), /* @__PURE__ */ import_react27.default.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ import_react27.default.createElement(
3678
- PaginationIconButton,
3679
- {
3680
- size,
3681
- variant: "plain",
3682
- color: "neutral",
3683
- onClick: () => handlePageChange(paginationModel.page + 1),
3684
- disabled: paginationModel.page === lastPage,
3685
- "aria-label": "Next page"
3686
- },
3687
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronRightRounded.default, null)
3688
- ), /* @__PURE__ */ import_react27.default.createElement(
3689
- PaginationIconButton,
3690
- {
3691
- size,
3692
- variant: "plain",
3693
- color: "neutral",
3694
- onClick: () => handlePageChange(lastPage),
3695
- disabled: paginationModel.page === lastPage,
3696
- "aria-label": "Last page"
3697
- },
3698
- /* @__PURE__ */ import_react27.default.createElement(import_LastPageRounded.default, null)
3699
- ))));
3700
- }
3701
3617
  return /* @__PURE__ */ import_react27.default.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ import_react27.default.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ import_react27.default.createElement(
3702
3618
  PaginationIconButton,
3703
3619
  {
@@ -3708,7 +3624,7 @@ function Pagination(props) {
3708
3624
  disabled: paginationModel.page === firstPage,
3709
3625
  "aria-label": "Previous page"
3710
3626
  },
3711
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeftRounded.default, null)
3627
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronLeft2.default, null)
3712
3628
  ), paginationModel.page !== firstPage && /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { size, variant: "plain", color: "neutral", onClick: () => handlePageChange(firstPage) }, firstPage), isMoreBeforePages && /* @__PURE__ */ import_react27.default.createElement(
3713
3629
  PaginationButton,
3714
3630
  {
@@ -3719,7 +3635,7 @@ function Pagination(props) {
3719
3635
  "aria-label": "More previous pages"
3720
3636
  },
3721
3637
  "..."
3722
- ), beforePages.map((p) => /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { active: "true", size, "aria-current": "page" }, paginationModel.page), afterPages.map((p) => /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), isMoreAfterPages && /* @__PURE__ */ import_react27.default.createElement(
3638
+ ), beforePages.map((p) => /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { active: "active", size, "aria-current": "page" }, paginationModel.page), afterPages.map((p) => /* @__PURE__ */ import_react27.default.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), isMoreAfterPages && /* @__PURE__ */ import_react27.default.createElement(
3723
3639
  PaginationButton,
3724
3640
  {
3725
3641
  size,
@@ -3739,7 +3655,7 @@ function Pagination(props) {
3739
3655
  disabled: paginationModel.page === lastPage,
3740
3656
  "aria-label": "Next page"
3741
3657
  },
3742
- /* @__PURE__ */ import_react27.default.createElement(import_ChevronRightRounded.default, null)
3658
+ /* @__PURE__ */ import_react27.default.createElement(import_ChevronRight2.default, null)
3743
3659
  )));
3744
3660
  }
3745
3661
  Pagination.displayName = "Pagination";
@@ -4639,6 +4555,7 @@ function FilterableCheckboxGroup(props) {
4639
4555
  );
4640
4556
  const parentRef = (0, import_react34.useRef)(null);
4641
4557
  const isInitialSortRef = (0, import_react34.useRef)(false);
4558
+ const prevOptionsRef = (0, import_react34.useRef)([...options]);
4642
4559
  const filteredOptions = (0, import_react34.useMemo)(() => {
4643
4560
  if (!searchTerm) return sortedOptions;
4644
4561
  return sortedOptions.filter((option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()));
@@ -4653,16 +4570,6 @@ function FilterableCheckboxGroup(props) {
4653
4570
  return 36;
4654
4571
  }
4655
4572
  }, [size]);
4656
- const noOptionsFontSize = (0, import_react34.useMemo)(() => {
4657
- switch (size) {
4658
- case "sm":
4659
- return "14px";
4660
- case "md":
4661
- return "16px";
4662
- case "lg":
4663
- return "18px";
4664
- }
4665
- }, [size]);
4666
4573
  const virtualizer = (0, import_react_virtual3.useVirtualizer)({
4667
4574
  count: filteredOptions.length,
4668
4575
  estimateSize: () => itemSize,
@@ -4672,27 +4579,34 @@ function FilterableCheckboxGroup(props) {
4672
4579
  });
4673
4580
  const items = virtualizer.getVirtualItems();
4674
4581
  (0, import_react34.useEffect)(() => {
4675
- if (isInitialSortRef.current) return;
4676
- const initialValue = value ?? [];
4677
- const sorted = [...options].sort((a, b) => {
4678
- const aSelected = initialValue.includes(a.value);
4679
- const bSelected = initialValue.includes(b.value);
4680
- if (aSelected !== bSelected) {
4681
- return aSelected ? -1 : 1;
4682
- }
4683
- const aIsAlpha = /^[a-zA-Z]/.test(a.label);
4684
- const bIsAlpha = /^[a-zA-Z]/.test(b.label);
4685
- if (aIsAlpha !== bIsAlpha) {
4686
- return aIsAlpha ? -1 : 1;
4582
+ const optionsChanged = prevOptionsRef.current.length !== options.length || prevOptionsRef.current.some(
4583
+ (prevOption, index) => prevOption.value !== options[index]?.value || prevOption.label !== options[index]?.label || prevOption.disabled !== options[index]?.disabled
4584
+ );
4585
+ if (!isInitialSortRef.current || optionsChanged) {
4586
+ const initialValue = value ?? [];
4587
+ const sorted = [...options].sort((a, b) => {
4588
+ const aSelected = initialValue.includes(a.value);
4589
+ const bSelected = initialValue.includes(b.value);
4590
+ if (aSelected !== bSelected) {
4591
+ return aSelected ? -1 : 1;
4592
+ }
4593
+ const aIsAlpha = /^[a-zA-Z]/.test(a.label);
4594
+ const bIsAlpha = /^[a-zA-Z]/.test(b.label);
4595
+ if (aIsAlpha !== bIsAlpha) {
4596
+ return aIsAlpha ? -1 : 1;
4597
+ }
4598
+ return a.label.localeCompare(b.label);
4599
+ });
4600
+ setSortedOptions(sorted);
4601
+ prevOptionsRef.current = [...options];
4602
+ if (!isInitialSortRef.current) {
4603
+ isInitialSortRef.current = true;
4687
4604
  }
4688
- return a.label.localeCompare(b.label);
4689
- });
4690
- setSortedOptions(sorted);
4691
- isInitialSortRef.current = true;
4605
+ }
4692
4606
  }, [options, value]);
4693
4607
  (0, import_react34.useEffect)(() => {
4694
4608
  virtualizer.measure();
4695
- }, [virtualizer, filteredOptions]);
4609
+ }, [virtualizer, filteredOptions, size]);
4696
4610
  const handleSearchChange = (0, import_react34.useCallback)((event) => {
4697
4611
  setSearchTerm(event.target.value);
4698
4612
  }, []);
@@ -4738,19 +4652,7 @@ function FilterableCheckboxGroup(props) {
4738
4652
  disabled,
4739
4653
  endDecorator: /* @__PURE__ */ import_react34.default.createElement(import_Search.default, null)
4740
4654
  }
4741
- ), filteredOptions.length === 0 ? /* @__PURE__ */ import_react34.default.createElement(
4742
- Stack_default,
4743
- {
4744
- sx: (theme) => ({
4745
- padding: "20px 12px",
4746
- justifyContent: "center",
4747
- alignItems: "center",
4748
- fontSize: noOptionsFontSize,
4749
- color: theme.palette.neutral.softDisabledColor
4750
- })
4751
- },
4752
- "No options found."
4753
- ) : /* @__PURE__ */ import_react34.default.createElement(
4655
+ ), filteredOptions.length === 0 ? /* @__PURE__ */ import_react34.default.createElement(Typography_default, { level: `body-${size}`, textColor: "neutral.softDisabledColor", padding: "20px 12px", textAlign: "center" }, "No options found.") : /* @__PURE__ */ import_react34.default.createElement(
4754
4656
  "div",
4755
4657
  {
4756
4658
  ref: parentRef,
package/dist/index.js CHANGED
@@ -3466,10 +3466,8 @@ TableBody.displayName = "TableBody";
3466
3466
 
3467
3467
  // src/components/Pagination/Pagination.tsx
3468
3468
  import React24, { useCallback as useCallback10, useEffect as useEffect6 } from "react";
3469
- import PreviousIcon from "@mui/icons-material/ChevronLeftRounded";
3470
- import NextIcon from "@mui/icons-material/ChevronRightRounded";
3471
- import FirstPageIcon from "@mui/icons-material/FirstPageRounded";
3472
- import LastPageIcon from "@mui/icons-material/LastPageRounded";
3469
+ import PreviousIcon from "@mui/icons-material/ChevronLeft";
3470
+ import NextIcon from "@mui/icons-material/ChevronRight";
3473
3471
  import { styled as styled13 } from "@mui/joy";
3474
3472
  var PaginationButton = styled13(Button_default, {
3475
3473
  name: "Pagination",
@@ -3528,7 +3526,6 @@ function Pagination(props) {
3528
3526
  onPageChange,
3529
3527
  rowCount,
3530
3528
  size = "md",
3531
- variant = "standard",
3532
3529
  ...innerProps
3533
3530
  } = props;
3534
3531
  const [paginationModel, setPaginationModel] = useControlledState(
@@ -3555,87 +3552,6 @@ function Pagination(props) {
3555
3552
  setPaginationModel({ ...paginationModel, page: lastPage });
3556
3553
  }
3557
3554
  }, [rowCount, paginationModel, lastPage, setPaginationModel]);
3558
- const pageOptions = Array.from({ length: lastPage }, (_, i) => ({
3559
- label: `${i + 1}`,
3560
- value: `${i + 1}`
3561
- }));
3562
- if (variant === "compact") {
3563
- return /* @__PURE__ */ React24.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ React24.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ React24.createElement(
3564
- PaginationIconButton,
3565
- {
3566
- size,
3567
- variant: "plain",
3568
- color: "neutral",
3569
- onClick: () => handlePageChange(firstPage),
3570
- disabled: paginationModel.page === firstPage,
3571
- "aria-label": "First page"
3572
- },
3573
- /* @__PURE__ */ React24.createElement(FirstPageIcon, null)
3574
- ), /* @__PURE__ */ React24.createElement(
3575
- PaginationIconButton,
3576
- {
3577
- size,
3578
- variant: "plain",
3579
- color: "neutral",
3580
- onClick: () => handlePageChange(paginationModel.page - 1),
3581
- disabled: paginationModel.page === firstPage,
3582
- "aria-label": "Previous page"
3583
- },
3584
- /* @__PURE__ */ React24.createElement(PreviousIcon, null)
3585
- )), /* @__PURE__ */ React24.createElement(
3586
- Autocomplete_default,
3587
- {
3588
- size,
3589
- value: `${paginationModel.page}`,
3590
- onChange: (event) => {
3591
- if (event.target.value) {
3592
- handlePageChange(parseInt(event.target.value, 10));
3593
- }
3594
- },
3595
- options: pageOptions,
3596
- sx: {
3597
- width: {
3598
- sm: "80px",
3599
- md: "100px",
3600
- lg: "120px"
3601
- }[size]
3602
- }
3603
- }
3604
- ), /* @__PURE__ */ React24.createElement(
3605
- Typography_default,
3606
- {
3607
- level: `body-${size}`,
3608
- sx: (theme) => ({
3609
- color: theme.palette.text.secondary,
3610
- fontWeight: 500
3611
- })
3612
- },
3613
- "/ ",
3614
- lastPage
3615
- ), /* @__PURE__ */ React24.createElement(Stack_default, { direction: "row" }, /* @__PURE__ */ React24.createElement(
3616
- PaginationIconButton,
3617
- {
3618
- size,
3619
- variant: "plain",
3620
- color: "neutral",
3621
- onClick: () => handlePageChange(paginationModel.page + 1),
3622
- disabled: paginationModel.page === lastPage,
3623
- "aria-label": "Next page"
3624
- },
3625
- /* @__PURE__ */ React24.createElement(NextIcon, null)
3626
- ), /* @__PURE__ */ React24.createElement(
3627
- PaginationIconButton,
3628
- {
3629
- size,
3630
- variant: "plain",
3631
- color: "neutral",
3632
- onClick: () => handlePageChange(lastPage),
3633
- disabled: paginationModel.page === lastPage,
3634
- "aria-label": "Last page"
3635
- },
3636
- /* @__PURE__ */ React24.createElement(LastPageIcon, null)
3637
- ))));
3638
- }
3639
3555
  return /* @__PURE__ */ React24.createElement(PaginationRoot, { ...innerProps }, /* @__PURE__ */ React24.createElement(PaginationContainer, { direction: "row", size, alignItems: "center" }, /* @__PURE__ */ React24.createElement(
3640
3556
  PaginationIconButton,
3641
3557
  {
@@ -3657,7 +3573,7 @@ function Pagination(props) {
3657
3573
  "aria-label": "More previous pages"
3658
3574
  },
3659
3575
  "..."
3660
- ), beforePages.map((p) => /* @__PURE__ */ React24.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), /* @__PURE__ */ React24.createElement(PaginationButton, { active: "true", size, "aria-current": "page" }, paginationModel.page), afterPages.map((p) => /* @__PURE__ */ React24.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), isMoreAfterPages && /* @__PURE__ */ React24.createElement(
3576
+ ), beforePages.map((p) => /* @__PURE__ */ React24.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), /* @__PURE__ */ React24.createElement(PaginationButton, { active: "active", size, "aria-current": "page" }, paginationModel.page), afterPages.map((p) => /* @__PURE__ */ React24.createElement(PaginationButton, { key: p, size, variant: "plain", color: "neutral", onClick: () => handlePageChange(p) }, p)), isMoreAfterPages && /* @__PURE__ */ React24.createElement(
3661
3577
  PaginationButton,
3662
3578
  {
3663
3579
  size,
@@ -4583,6 +4499,7 @@ function FilterableCheckboxGroup(props) {
4583
4499
  );
4584
4500
  const parentRef = useRef8(null);
4585
4501
  const isInitialSortRef = useRef8(false);
4502
+ const prevOptionsRef = useRef8([...options]);
4586
4503
  const filteredOptions = useMemo12(() => {
4587
4504
  if (!searchTerm) return sortedOptions;
4588
4505
  return sortedOptions.filter((option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()));
@@ -4597,16 +4514,6 @@ function FilterableCheckboxGroup(props) {
4597
4514
  return 36;
4598
4515
  }
4599
4516
  }, [size]);
4600
- const noOptionsFontSize = useMemo12(() => {
4601
- switch (size) {
4602
- case "sm":
4603
- return "14px";
4604
- case "md":
4605
- return "16px";
4606
- case "lg":
4607
- return "18px";
4608
- }
4609
- }, [size]);
4610
4517
  const virtualizer = useVirtualizer3({
4611
4518
  count: filteredOptions.length,
4612
4519
  estimateSize: () => itemSize,
@@ -4616,27 +4523,34 @@ function FilterableCheckboxGroup(props) {
4616
4523
  });
4617
4524
  const items = virtualizer.getVirtualItems();
4618
4525
  useEffect8(() => {
4619
- if (isInitialSortRef.current) return;
4620
- const initialValue = value ?? [];
4621
- const sorted = [...options].sort((a, b) => {
4622
- const aSelected = initialValue.includes(a.value);
4623
- const bSelected = initialValue.includes(b.value);
4624
- if (aSelected !== bSelected) {
4625
- return aSelected ? -1 : 1;
4626
- }
4627
- const aIsAlpha = /^[a-zA-Z]/.test(a.label);
4628
- const bIsAlpha = /^[a-zA-Z]/.test(b.label);
4629
- if (aIsAlpha !== bIsAlpha) {
4630
- return aIsAlpha ? -1 : 1;
4526
+ const optionsChanged = prevOptionsRef.current.length !== options.length || prevOptionsRef.current.some(
4527
+ (prevOption, index) => prevOption.value !== options[index]?.value || prevOption.label !== options[index]?.label || prevOption.disabled !== options[index]?.disabled
4528
+ );
4529
+ if (!isInitialSortRef.current || optionsChanged) {
4530
+ const initialValue = value ?? [];
4531
+ const sorted = [...options].sort((a, b) => {
4532
+ const aSelected = initialValue.includes(a.value);
4533
+ const bSelected = initialValue.includes(b.value);
4534
+ if (aSelected !== bSelected) {
4535
+ return aSelected ? -1 : 1;
4536
+ }
4537
+ const aIsAlpha = /^[a-zA-Z]/.test(a.label);
4538
+ const bIsAlpha = /^[a-zA-Z]/.test(b.label);
4539
+ if (aIsAlpha !== bIsAlpha) {
4540
+ return aIsAlpha ? -1 : 1;
4541
+ }
4542
+ return a.label.localeCompare(b.label);
4543
+ });
4544
+ setSortedOptions(sorted);
4545
+ prevOptionsRef.current = [...options];
4546
+ if (!isInitialSortRef.current) {
4547
+ isInitialSortRef.current = true;
4631
4548
  }
4632
- return a.label.localeCompare(b.label);
4633
- });
4634
- setSortedOptions(sorted);
4635
- isInitialSortRef.current = true;
4549
+ }
4636
4550
  }, [options, value]);
4637
4551
  useEffect8(() => {
4638
4552
  virtualizer.measure();
4639
- }, [virtualizer, filteredOptions]);
4553
+ }, [virtualizer, filteredOptions, size]);
4640
4554
  const handleSearchChange = useCallback13((event) => {
4641
4555
  setSearchTerm(event.target.value);
4642
4556
  }, []);
@@ -4682,19 +4596,7 @@ function FilterableCheckboxGroup(props) {
4682
4596
  disabled,
4683
4597
  endDecorator: /* @__PURE__ */ React31.createElement(SearchIcon, null)
4684
4598
  }
4685
- ), filteredOptions.length === 0 ? /* @__PURE__ */ React31.createElement(
4686
- Stack_default,
4687
- {
4688
- sx: (theme) => ({
4689
- padding: "20px 12px",
4690
- justifyContent: "center",
4691
- alignItems: "center",
4692
- fontSize: noOptionsFontSize,
4693
- color: theme.palette.neutral.softDisabledColor
4694
- })
4695
- },
4696
- "No options found."
4697
- ) : /* @__PURE__ */ React31.createElement(
4599
+ ), filteredOptions.length === 0 ? /* @__PURE__ */ React31.createElement(Typography_default, { level: `body-${size}`, textColor: "neutral.softDisabledColor", padding: "20px 12px", textAlign: "center" }, "No options found.") : /* @__PURE__ */ React31.createElement(
4698
4600
  "div",
4699
4601
  {
4700
4602
  ref: parentRef,