@lumx/react 4.25.1-alpha.1 → 4.25.1-alpha.3

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/index.d.ts CHANGED
@@ -1857,6 +1857,11 @@ interface ComboboxListProps$1 extends HasClassName {
1857
1857
  * Omit (or set to `undefined`) when not loading — the attribute is not rendered as `"false"`.
1858
1858
  */
1859
1859
  'aria-busy'?: boolean;
1860
+ /**
1861
+ * Allow selecting several options (`aria-multiselectable`).
1862
+ * Also read by `Combobox.SelectionIcon` to pick the checkbox icons.
1863
+ */
1864
+ 'aria-multiselectable'?: boolean | 'true' | 'false';
1860
1865
  /** Content (should be ComboboxOption elements). */
1861
1866
  children?: JSXElement;
1862
1867
  /** The ID of the listbox element. */
@@ -2307,6 +2312,11 @@ declare const Combobox: {
2307
2312
  displayName: string;
2308
2313
  className: "lumx-combobox-option-skeleton";
2309
2314
  };
2315
+ /** Selection state icon (check circle / radio, or checkbox in multiple lists) for the `after` slot of an option. Reads the option `isSelected` and the list `aria-multiselectable`. */
2316
+ SelectionIcon: {
2317
+ (): react_jsx_runtime.JSX.Element;
2318
+ displayName: string;
2319
+ };
2310
2320
  /** Floating popover container that auto-binds to the combobox anchor and open/close state. */
2311
2321
  Popover: {
2312
2322
  (props: ComboboxPopoverComponentProps): react_jsx_runtime.JSX.Element;
package/index.js CHANGED
@@ -20,15 +20,15 @@ import { mdiCheckCircle } from '@lumx/icons/esm/check-circle.js';
20
20
  import { mdiCloseCircle } from '@lumx/icons/esm/close-circle.js';
21
21
  import { mdiInformationOutline } from '@lumx/icons/esm/information-outline.js';
22
22
  import castArray from 'lodash/castArray.js';
23
+ import { mdiCheckboxBlankOutline } from '@lumx/icons/esm/checkbox-blank-outline.js';
24
+ import { mdiCheckboxMarked } from '@lumx/icons/esm/checkbox-marked.js';
25
+ import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank.js';
23
26
  import noop$1 from 'lodash/noop.js';
24
27
  import concat from 'lodash/concat.js';
25
28
  import dropRight from 'lodash/dropRight.js';
26
29
  import partition from 'lodash/partition.js';
27
30
  import reduce from 'lodash/reduce.js';
28
31
  import { mdiMenuDown } from '@lumx/icons/esm/menu-down.js';
29
- import { mdiCheckboxBlankOutline } from '@lumx/icons/esm/checkbox-blank-outline.js';
30
- import { mdiCheckboxMarked } from '@lumx/icons/esm/checkbox-marked.js';
31
- import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank.js';
32
32
  import { mdiClose } from '@lumx/icons/esm/close.js';
33
33
  import isFunction from 'lodash/isFunction.js';
34
34
  import { mdiAlert } from '@lumx/icons/esm/alert.js';
@@ -8734,9 +8734,11 @@ const ComboboxList = forwardRef((props, ref) => {
8734
8734
  } = props;
8735
8735
  const internalRef = useRef(null);
8736
8736
  const mergedRef = useMergeRefs(ref, internalRef);
8737
+ const selectionType = String(forwardedProps['aria-multiselectable']) === 'true' ? 'multiple' : 'single';
8737
8738
  const listContextValue = useMemo(() => ({
8738
- type
8739
- }), [type]);
8739
+ type,
8740
+ selectionType
8741
+ }), [type, selectionType]);
8740
8742
  const [isOpen] = useComboboxOpen();
8741
8743
  const options = useComboboxEvent('optionsChange', undefined);
8742
8744
  const visibleCount = options?.optionsLength ?? 0;
@@ -9076,8 +9078,9 @@ const ComboboxOption = forwardRef((props, ref) => {
9076
9078
  // Wrap `after` content in an option context so sub-components (e.g. OptionMoreInfo)
9077
9079
  // can access the parent option's ID for keyboard highlight detection.
9078
9080
  const optionContextValue = useMemo(() => ({
9079
- optionId
9080
- }), [optionId]);
9081
+ optionId,
9082
+ isSelected: Boolean(isSelected)
9083
+ }), [optionId, isSelected]);
9081
9084
  const wrappedAfter = after ? /*#__PURE__*/jsx(ComboboxOptionContext.Provider, {
9082
9085
  value: optionContextValue,
9083
9086
  children: after
@@ -10692,6 +10695,45 @@ const ComboboxSection = forwardRef((props, ref) => {
10692
10695
  ComboboxSection.displayName = COMPONENT_NAME$19;
10693
10696
  ComboboxSection.className = CLASSNAME$16;
10694
10697
 
10698
+ /**
10699
+ * Selection state icon of an option. The icon is always rendered after the label.
10700
+ *
10701
+ * - `single`: a check circle icon when selected, a blank radio icon otherwise.
10702
+ * - `multiple`: a checkbox icon, marked or blank.
10703
+ */
10704
+ const ComboboxSelectionIcon$1 = ({
10705
+ selectionType,
10706
+ isSelected
10707
+ }) => {
10708
+ let icon;
10709
+ if (selectionType === 'multiple') {
10710
+ icon = isSelected ? mdiCheckboxMarked : mdiCheckboxBlankOutline;
10711
+ } else if (selectionType === 'single') {
10712
+ icon = isSelected ? mdiCheckCircle : mdiRadioboxBlank;
10713
+ } else {
10714
+ return null;
10715
+ }
10716
+ return /*#__PURE__*/jsx(Icon$1, {
10717
+ icon: icon,
10718
+ color: isSelected ? 'primary' : undefined,
10719
+ className: "lumx-combobox-option__selection-icon"
10720
+ });
10721
+ };
10722
+
10723
+ const ComboboxSelectionIcon = () => {
10724
+ const {
10725
+ isSelected
10726
+ } = useComboboxOptionContext();
10727
+ const {
10728
+ selectionType
10729
+ } = useComboboxListContext();
10730
+ return /*#__PURE__*/jsx(ComboboxSelectionIcon$1, {
10731
+ selectionType: selectionType,
10732
+ isSelected: isSelected
10733
+ });
10734
+ };
10735
+ ComboboxSelectionIcon.displayName = 'ComboboxSelectionIcon';
10736
+
10695
10737
  /**
10696
10738
  * Component display name.
10697
10739
  */
@@ -11191,6 +11233,8 @@ const Combobox = {
11191
11233
  OptionMoreInfo: ComboboxOptionMoreInfo,
11192
11234
  /** Loading placeholder skeleton(s) that auto-register loading state with the combobox handle. */
11193
11235
  OptionSkeleton: ComboboxOptionSkeleton,
11236
+ /** Selection state icon (check circle / radio, or checkbox in multiple lists) for the `after` slot of an option. Reads the option `isSelected` and the list `aria-multiselectable`. */
11237
+ SelectionIcon: ComboboxSelectionIcon,
11194
11238
  /** Floating popover container that auto-binds to the combobox anchor and open/close state. */
11195
11239
  Popover: ComboboxPopover,
11196
11240
  /** Labelled group of options that auto-hides when all its child options are filtered out. */
@@ -18602,31 +18646,6 @@ function getOptionDisplayName(value, getOptionName, getOptionId) {
18602
18646
  return '';
18603
18647
  }
18604
18648
 
18605
- /**
18606
- * Selection state icon of an option. The icon is always rendered after the label.
18607
- *
18608
- * - `single`: a check circle icon when selected, a blank radio icon otherwise.
18609
- * - `multiple`: a checkbox icon, marked or blank.
18610
- */
18611
- const SelectionIcon = ({
18612
- selectionType,
18613
- isSelected
18614
- }) => {
18615
- let icon;
18616
- if (selectionType === 'multiple') {
18617
- icon = isSelected ? mdiCheckboxMarked : mdiCheckboxBlankOutline;
18618
- } else if (selectionType === 'single') {
18619
- icon = isSelected ? mdiCheckCircle : mdiRadioboxBlank;
18620
- } else {
18621
- return null;
18622
- }
18623
- return /*#__PURE__*/jsx(Icon$1, {
18624
- icon: icon,
18625
- color: isSelected ? 'primary' : undefined,
18626
- className: "lumx-combobox-option__selection-icon"
18627
- });
18628
- };
18629
-
18630
18649
  /**
18631
18650
  * Render options as ComboboxOption elements.
18632
18651
  * Framework-specific components are passed as a second argument.
@@ -18639,7 +18658,6 @@ function renderSelectOptions(props, components) {
18639
18658
  getOptionDescription,
18640
18659
  renderOption,
18641
18660
  selected,
18642
- selectionType,
18643
18661
  getSectionId,
18644
18662
  renderSectionTitle
18645
18663
  } = props;
@@ -18661,8 +18679,7 @@ function renderSelectOptions(props, components) {
18661
18679
  getOptionName,
18662
18680
  getOptionDescription,
18663
18681
  renderOption,
18664
- selected,
18665
- selectionType
18682
+ selected
18666
18683
  // getSectionId intentionally omitted to render flat options inside.
18667
18684
  }, components)
18668
18685
  }, sectionId);
@@ -18676,10 +18693,7 @@ function renderSelectOptions(props, components) {
18676
18693
  const name = getWithSelector(getOptionName || getOptionId, item) || id;
18677
18694
  const description = getOptionDescription && getWithSelector(getOptionDescription, item);
18678
18695
  const isSelected = selectedIds?.has(id) ?? false;
18679
- const after = /*#__PURE__*/jsx(SelectionIcon, {
18680
- selectionType: selectionType,
18681
- isSelected: isSelected
18682
- });
18696
+ const after = /*#__PURE__*/jsx(Combobox.SelectionIcon, {});
18683
18697
 
18684
18698
  // Delegate to the consumer's render function when provided.
18685
18699
  // The consumer receives core-computed context and is responsible for rendering
@@ -18797,8 +18811,7 @@ const SelectButton$2 = (props, {
18797
18811
  renderOption,
18798
18812
  getSectionId,
18799
18813
  renderSectionTitle,
18800
- selected: value,
18801
- selectionType
18814
+ selected: value
18802
18815
  }, {
18803
18816
  Combobox
18804
18817
  }), onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {
@@ -19100,8 +19113,7 @@ const SelectTextField$2 = (props, {
19100
19113
  renderOption,
19101
19114
  getSectionId,
19102
19115
  renderSectionTitle,
19103
- selected,
19104
- selectionType: isMultiselectable ? 'multiple' : 'single'
19116
+ selected
19105
19117
  }, {
19106
19118
  Combobox
19107
19119
  }), afterOptions, onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {