@lumx/react 4.25.0 → 4.25.1-alpha.1
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 +12 -0
- package/index.js +91 -11
- package/index.js.map +1 -1
- package/package.json +4 -3
package/index.d.ts
CHANGED
|
@@ -1898,6 +1898,12 @@ interface ComboboxEventMap {
|
|
|
1898
1898
|
* Used to control the loading message text in the live region (ComboboxState).
|
|
1899
1899
|
*/
|
|
1900
1900
|
loadingAnnouncement: boolean;
|
|
1901
|
+
/**
|
|
1902
|
+
* Fired only when this option becomes the active descendant (true)
|
|
1903
|
+
* or stops being the active descendant (false).
|
|
1904
|
+
* Build the key with optionActiveEvent(optionId).
|
|
1905
|
+
*/
|
|
1906
|
+
[event: OptionActiveEvent]: boolean;
|
|
1901
1907
|
}
|
|
1902
1908
|
/** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
|
|
1903
1909
|
interface ComboboxCallbacks {
|
|
@@ -4308,6 +4314,12 @@ interface RenderOptionContext {
|
|
|
4308
4314
|
isSelected: boolean;
|
|
4309
4315
|
/** Resolved description string (from `getOptionDescription`), if any. Should be forwarded as `description`. */
|
|
4310
4316
|
description?: string | null;
|
|
4317
|
+
/**
|
|
4318
|
+
* Selection state icon to render after the option label
|
|
4319
|
+
* (single selection: check circle when selected, blank radio otherwise; multiple selection: checkbox).
|
|
4320
|
+
* Should be forwarded as `after` (appended after any custom `after` content).
|
|
4321
|
+
*/
|
|
4322
|
+
after?: JSXElement;
|
|
4311
4323
|
}
|
|
4312
4324
|
interface BaseSelectProps<O> {
|
|
4313
4325
|
/** List of option objects. */
|
package/index.js
CHANGED
|
@@ -26,6 +26,9 @@ import dropRight from 'lodash/dropRight.js';
|
|
|
26
26
|
import partition from 'lodash/partition.js';
|
|
27
27
|
import reduce from 'lodash/reduce.js';
|
|
28
28
|
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';
|
|
29
32
|
import { mdiClose } from '@lumx/icons/esm/close.js';
|
|
30
33
|
import isFunction from 'lodash/isFunction.js';
|
|
31
34
|
import { mdiAlert } from '@lumx/icons/esm/alert.js';
|
|
@@ -48,7 +51,6 @@ import { mdiPauseCircleOutline } from '@lumx/icons/esm/pause-circle-outline.js';
|
|
|
48
51
|
import chunk from 'lodash/chunk.js';
|
|
49
52
|
import { mdiDotsVertical } from '@lumx/icons/esm/dots-vertical.js';
|
|
50
53
|
import take from 'lodash/take.js';
|
|
51
|
-
import { mdiRadioboxBlank } from '@lumx/icons/esm/radiobox-blank.js';
|
|
52
54
|
import { mdiRadioboxMarked } from '@lumx/icons/esm/radiobox-marked.js';
|
|
53
55
|
import { mdiArrowDown } from '@lumx/icons/esm/arrow-down.js';
|
|
54
56
|
import { mdiArrowUp } from '@lumx/icons/esm/arrow-up.js';
|
|
@@ -6514,6 +6516,11 @@ function setupListbox(handle, signal, notify, options) {
|
|
|
6514
6516
|
return focusNav;
|
|
6515
6517
|
}
|
|
6516
6518
|
|
|
6519
|
+
const DEFAULT_COMBOBOX_POPOVER_MAX_HEIGHT = '80vh';
|
|
6520
|
+
const OPTION_ACTIVE_EVENT_PREFIX = 'optionActive:';
|
|
6521
|
+
const optionActiveEvent = optionId => `${OPTION_ACTIVE_EVENT_PREFIX}${optionId}`;
|
|
6522
|
+
const isOptionActiveEvent = event => event.startsWith(OPTION_ACTIVE_EVENT_PREFIX);
|
|
6523
|
+
|
|
6517
6524
|
/** Options for configuring the shared combobox behavior. */
|
|
6518
6525
|
|
|
6519
6526
|
/**
|
|
@@ -6574,6 +6581,9 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6574
6581
|
loadingAnnouncement: new Set()
|
|
6575
6582
|
};
|
|
6576
6583
|
|
|
6584
|
+
/** Per-option subscribers, keyed by optionActive:<id>. Sets are created on demand. */
|
|
6585
|
+
const optionActiveSubscribers = new Map();
|
|
6586
|
+
|
|
6577
6587
|
/**
|
|
6578
6588
|
* Last value dispatched for each event. Kept in sync so pull-based subscribers — React's
|
|
6579
6589
|
* `useSyncExternalStore` via {@link ComboboxHandle.getSnapshot} — can read the current value
|
|
@@ -6585,8 +6595,15 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6585
6595
|
|
|
6586
6596
|
/** Notify all subscribers for a given event. */
|
|
6587
6597
|
function notify(event, value) {
|
|
6598
|
+
const previous = latestValues.activeDescendantChange ?? null;
|
|
6588
6599
|
latestValues[event] = value;
|
|
6589
6600
|
subscribers[event].forEach(cb => cb(value));
|
|
6601
|
+
|
|
6602
|
+
// Fan out to the 2 affected options only: first the previous one, then the new one.
|
|
6603
|
+
if (event === 'activeDescendantChange' && previous !== value) {
|
|
6604
|
+
if (previous) optionActiveSubscribers.get(optionActiveEvent(previous))?.forEach(cb => cb(false));
|
|
6605
|
+
if (value) optionActiveSubscribers.get(optionActiveEvent(value))?.forEach(cb => cb(true));
|
|
6606
|
+
}
|
|
6590
6607
|
}
|
|
6591
6608
|
|
|
6592
6609
|
/** Count visible (non-filtered) options. */
|
|
@@ -7003,7 +7020,20 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
7003
7020
|
};
|
|
7004
7021
|
},
|
|
7005
7022
|
subscribe(event, callback) {
|
|
7006
|
-
|
|
7023
|
+
if (isOptionActiveEvent(event)) {
|
|
7024
|
+
const optionCallback = callback;
|
|
7025
|
+
const set = optionActiveSubscribers.get(event) ?? new Set();
|
|
7026
|
+
optionActiveSubscribers.set(event, set);
|
|
7027
|
+
set.add(optionCallback);
|
|
7028
|
+
// Replay (same as open): Vue subscribes after mount and can miss the activation.
|
|
7029
|
+
if (latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length)) optionCallback(true);
|
|
7030
|
+
return () => {
|
|
7031
|
+
set.delete(optionCallback);
|
|
7032
|
+
if (!set.size) optionActiveSubscribers.delete(event);
|
|
7033
|
+
};
|
|
7034
|
+
}
|
|
7035
|
+
const subs = subscribers[event];
|
|
7036
|
+
subs.add(callback);
|
|
7007
7037
|
// Replay current loading state to late subscribers so that framework wrappers
|
|
7008
7038
|
// that subscribe after initial mount (e.g. async Vue watchers) don't miss the
|
|
7009
7039
|
// initial events fired during mount.
|
|
@@ -7016,10 +7046,14 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
7016
7046
|
|
|
7017
7047
|
// Cleanup function
|
|
7018
7048
|
return () => {
|
|
7019
|
-
|
|
7049
|
+
subs.delete(callback);
|
|
7020
7050
|
};
|
|
7021
7051
|
},
|
|
7022
7052
|
getSnapshot(event) {
|
|
7053
|
+
if (isOptionActiveEvent(event)) {
|
|
7054
|
+
// Derived value. No per-id value is stored.
|
|
7055
|
+
return latestValues.activeDescendantChange === event.slice(OPTION_ACTIVE_EVENT_PREFIX.length);
|
|
7056
|
+
}
|
|
7023
7057
|
return latestValues[event];
|
|
7024
7058
|
},
|
|
7025
7059
|
destroy() {
|
|
@@ -7039,6 +7073,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
7039
7073
|
skeletonCount = 0;
|
|
7040
7074
|
clearTimeout(loadingTimer);
|
|
7041
7075
|
announcementSent = false;
|
|
7076
|
+
optionActiveSubscribers.clear();
|
|
7042
7077
|
// Clear all subscribers
|
|
7043
7078
|
for (const set of Object.values(subscribers)) {
|
|
7044
7079
|
set.clear();
|
|
@@ -9022,6 +9057,9 @@ const ComboboxOption = forwardRef((props, ref) => {
|
|
|
9022
9057
|
const internalRef = useRef(null);
|
|
9023
9058
|
const mergedRef = useMergeRefs(ref, internalRef);
|
|
9024
9059
|
const [isFiltered, setIsFiltered] = useState(false);
|
|
9060
|
+
|
|
9061
|
+
// Force the tooltip open while the option is the active descendant (keyboard highlight).
|
|
9062
|
+
const isActive = useComboboxEvent(optionActiveEvent(optionId), false);
|
|
9025
9063
|
useEffect(() => {
|
|
9026
9064
|
const element = internalRef.current;
|
|
9027
9065
|
if (!element || !handle) return undefined;
|
|
@@ -9060,7 +9098,10 @@ const ComboboxOption = forwardRef((props, ref) => {
|
|
|
9060
9098
|
handleClick: onClick,
|
|
9061
9099
|
id: optionId,
|
|
9062
9100
|
descriptionId,
|
|
9063
|
-
tooltipProps
|
|
9101
|
+
tooltipProps: tooltipProps && {
|
|
9102
|
+
...tooltipProps,
|
|
9103
|
+
forceOpen: tooltipProps.forceOpen || isActive
|
|
9104
|
+
}
|
|
9064
9105
|
}, {
|
|
9065
9106
|
Tooltip
|
|
9066
9107
|
});
|
|
@@ -10251,8 +10292,6 @@ const ComboboxOptionSkeleton = props => {
|
|
|
10251
10292
|
ComboboxOptionSkeleton.displayName = COMPONENT_NAME$1c;
|
|
10252
10293
|
ComboboxOptionSkeleton.className = CLASSNAME$19;
|
|
10253
10294
|
|
|
10254
|
-
const DEFAULT_COMBOBOX_POPOVER_MAX_HEIGHT = '80vh';
|
|
10255
|
-
|
|
10256
10295
|
const COMPONENT_NAME$1b = 'ComboboxPopover';
|
|
10257
10296
|
|
|
10258
10297
|
/**
|
|
@@ -18563,6 +18602,31 @@ function getOptionDisplayName(value, getOptionName, getOptionId) {
|
|
|
18563
18602
|
return '';
|
|
18564
18603
|
}
|
|
18565
18604
|
|
|
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
|
+
|
|
18566
18630
|
/**
|
|
18567
18631
|
* Render options as ComboboxOption elements.
|
|
18568
18632
|
* Framework-specific components are passed as a second argument.
|
|
@@ -18575,6 +18639,7 @@ function renderSelectOptions(props, components) {
|
|
|
18575
18639
|
getOptionDescription,
|
|
18576
18640
|
renderOption,
|
|
18577
18641
|
selected,
|
|
18642
|
+
selectionType,
|
|
18578
18643
|
getSectionId,
|
|
18579
18644
|
renderSectionTitle
|
|
18580
18645
|
} = props;
|
|
@@ -18596,7 +18661,8 @@ function renderSelectOptions(props, components) {
|
|
|
18596
18661
|
getOptionName,
|
|
18597
18662
|
getOptionDescription,
|
|
18598
18663
|
renderOption,
|
|
18599
|
-
selected
|
|
18664
|
+
selected,
|
|
18665
|
+
selectionType
|
|
18600
18666
|
// getSectionId intentionally omitted to render flat options inside.
|
|
18601
18667
|
}, components)
|
|
18602
18668
|
}, sectionId);
|
|
@@ -18610,6 +18676,10 @@ function renderSelectOptions(props, components) {
|
|
|
18610
18676
|
const name = getWithSelector(getOptionName || getOptionId, item) || id;
|
|
18611
18677
|
const description = getOptionDescription && getWithSelector(getOptionDescription, item);
|
|
18612
18678
|
const isSelected = selectedIds?.has(id) ?? false;
|
|
18679
|
+
const after = /*#__PURE__*/jsx(SelectionIcon, {
|
|
18680
|
+
selectionType: selectionType,
|
|
18681
|
+
isSelected: isSelected
|
|
18682
|
+
});
|
|
18613
18683
|
|
|
18614
18684
|
// Delegate to the consumer's render function when provided.
|
|
18615
18685
|
// The consumer receives core-computed context and is responsible for rendering
|
|
@@ -18620,13 +18690,15 @@ function renderSelectOptions(props, components) {
|
|
|
18620
18690
|
value: id,
|
|
18621
18691
|
name,
|
|
18622
18692
|
isSelected,
|
|
18623
|
-
description
|
|
18693
|
+
description,
|
|
18694
|
+
after
|
|
18624
18695
|
});
|
|
18625
18696
|
}
|
|
18626
18697
|
return /*#__PURE__*/jsx(Combobox.Option, {
|
|
18627
18698
|
value: id,
|
|
18628
18699
|
description: description,
|
|
18629
18700
|
isSelected: isSelected,
|
|
18701
|
+
after: after,
|
|
18630
18702
|
children: name
|
|
18631
18703
|
}, id);
|
|
18632
18704
|
});
|
|
@@ -18725,7 +18797,8 @@ const SelectButton$2 = (props, {
|
|
|
18725
18797
|
renderOption,
|
|
18726
18798
|
getSectionId,
|
|
18727
18799
|
renderSectionTitle,
|
|
18728
|
-
selected: value
|
|
18800
|
+
selected: value,
|
|
18801
|
+
selectionType
|
|
18729
18802
|
}, {
|
|
18730
18803
|
Combobox
|
|
18731
18804
|
}), onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {
|
|
@@ -18758,6 +18831,7 @@ SelectButton$2.className = CLASSNAME$n;
|
|
|
18758
18831
|
* - If the consumer returns a `<Combobox.Option>`, its props/children are merged with the
|
|
18759
18832
|
* core-computed `value` / `isSelected` / `description` / `key`.
|
|
18760
18833
|
* When the consumer's `<Combobox.Option>` has no children, falls back to the option `name`.
|
|
18834
|
+
* The core-computed selection icons are kept: `after` is appended to the custom `after`.
|
|
18761
18835
|
* - If the consumer returns anything else, returns `null` (skips the option).
|
|
18762
18836
|
*
|
|
18763
18837
|
* @param renderOption Consumer-provided render function.
|
|
@@ -18770,7 +18844,8 @@ function wrapRenderOption(renderOption) {
|
|
|
18770
18844
|
value: optionValue,
|
|
18771
18845
|
isSelected,
|
|
18772
18846
|
description,
|
|
18773
|
-
name
|
|
18847
|
+
name,
|
|
18848
|
+
after
|
|
18774
18849
|
}) => {
|
|
18775
18850
|
const node = renderOption(option, index);
|
|
18776
18851
|
if (!isComponentType(ComboboxOption)(node)) {
|
|
@@ -18778,6 +18853,7 @@ function wrapRenderOption(renderOption) {
|
|
|
18778
18853
|
}
|
|
18779
18854
|
const {
|
|
18780
18855
|
children = name,
|
|
18856
|
+
after: customAfter,
|
|
18781
18857
|
...customProps
|
|
18782
18858
|
} = node.props;
|
|
18783
18859
|
return /*#__PURE__*/jsx(ComboboxOption, {
|
|
@@ -18785,6 +18861,9 @@ function wrapRenderOption(renderOption) {
|
|
|
18785
18861
|
value: optionValue,
|
|
18786
18862
|
isSelected: isSelected,
|
|
18787
18863
|
description: description,
|
|
18864
|
+
after: /*#__PURE__*/jsxs(Fragment, {
|
|
18865
|
+
children: [customAfter, after]
|
|
18866
|
+
}),
|
|
18788
18867
|
children: children
|
|
18789
18868
|
}, optionValue);
|
|
18790
18869
|
};
|
|
@@ -19021,7 +19100,8 @@ const SelectTextField$2 = (props, {
|
|
|
19021
19100
|
renderOption,
|
|
19022
19101
|
getSectionId,
|
|
19023
19102
|
renderSectionTitle,
|
|
19024
|
-
selected
|
|
19103
|
+
selected,
|
|
19104
|
+
selectionType: isMultiselectable ? 'multiple' : 'single'
|
|
19025
19105
|
}, {
|
|
19026
19106
|
Combobox
|
|
19027
19107
|
}), afterOptions, onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {
|