@lumx/react 4.29.1-alpha.0 → 4.29.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 CHANGED
@@ -4623,12 +4623,16 @@ interface BaseSelectTextFieldWrapperProps<O> extends Pick<BaseSelectProps<O>, 'o
4623
4623
  filter: 'auto' | 'manual' | 'off';
4624
4624
  /**
4625
4625
  * Controlled search input value.
4626
- * When provided, this value seeds (and resets) the visible search text in the input.
4627
- * Setting it to `''` (empty string) resets the input.
4626
+ * When provided, this value seeds the visible search text in the input. In multiple selection,
4627
+ * `''` resets it.
4628
+ * In single selection, `''` (empty string) keeps the input empty while the option stays selected:
4629
+ * the input shows only the text the user types. When you copy `onSearch` into this prop, pass
4630
+ * `search || undefined` so that the input shows the name of the selected option when idle.
4628
4631
  */
4629
4632
  searchInputValue?: string;
4630
4633
  /**
4631
- * Whether to show a clear button when a value is selected.
4634
+ * Whether the selection can be cleared (single selection): with a clear button, when the user
4635
+ * erases the input text, and with Escape. When `false`, the selection stays.
4632
4636
  * @default true
4633
4637
  */
4634
4638
  hasClearButton?: boolean;
@@ -6086,6 +6090,12 @@ interface TreeListItemProps extends GenericProps$1, ReactToJSX<TreeListItemProps
6086
6090
  * In a combobox, the open state resets on each popup open: cache the loaded sub-items.
6087
6091
  */
6088
6092
  hasSubItems?: boolean;
6093
+ /**
6094
+ * Open the item at mount. Uncontrolled: it applies at each mount (in a combobox, at each popup
6095
+ * open), it does not call `onOpenChange`, and a change after mount does nothing.
6096
+ * With `hasSubItems`, `onOpenChange` does not fire at mount: load the sub-items yourself.
6097
+ */
6098
+ defaultOpen?: boolean;
6089
6099
  /**
6090
6100
  * Called on every open and close by the user (expand toggle, Right, Left, Enter or a click on a
6091
6101
  * non-selectable parent item). Not called for the initial state or for the filter.
@@ -6109,8 +6119,8 @@ interface TreeListItemProps extends GenericProps$1, ReactToJSX<TreeListItemProps
6109
6119
  * tree `value` holds it. Without, it is not selectable: Enter or a click on a non-selectable parent item
6110
6120
  * opens or closes it, and on a non-selectable leaf item only calls `onClick` (e.g. an action such as
6111
6121
  * "Create a new list…").
6112
- * - The open state is internal: a parent item starts open when a sub-item at any depth is selected.
6113
- * In a combobox, it resets on each popup open.
6122
+ * - The open state is internal: a parent item starts open with `defaultOpen`, or when a sub-item at
6123
+ * any depth is selected. In a combobox, it resets on each popup open.
6114
6124
  * - Touch screen readers: TalkBack (Chrome) can open and close the parent items. On iOS, a user can
6115
6125
  * only reach the sub-items of a selectable parent item through the filter. To support it, use a
6116
6126
  * non-selectable parent item with an "All <name>" leaf item that carries the parent value.
package/index.js CHANGED
@@ -19979,7 +19979,9 @@ const SelectTextField$1 = props => {
19979
19979
  let displayValue;
19980
19980
  if (isMultiple || isSearching) {
19981
19981
  displayValue = searchText;
19982
- } else if (!isMultiple) {
19982
+ } else if (externalSearchValue === '') {
19983
+ displayValue = '';
19984
+ } else {
19983
19985
  displayValue = getOptionDisplayName(value, getOptionName, getOptionId);
19984
19986
  }
19985
19987
 
@@ -19988,13 +19990,15 @@ const SelectTextField$1 = props => {
19988
19990
  const next = toggleSelection(options, getOptionId, value, selectedOption.value, isMultiple);
19989
19991
  // In multi mode, `toggleSelection` skips when no option matches and returns the
19990
19992
  // unchanged current array — the onChange call is a no-op for the consumer.
19991
- onChange?.(next);
19993
+ // Escape on a closed combobox sends a clear request with an empty option id.
19994
+ const isBlockedClear = !isMultiple && !hasClearButton && selectedOption.value === '';
19995
+ if (!isBlockedClear) onChange?.(next);
19992
19996
 
19993
19997
  // Reset search state after selection.
19994
19998
  setIsSearching(false);
19995
19999
  setSearchText('');
19996
20000
  onSearch?.('');
19997
- }, [getOptionId, isMultiple, onChange, onSearch, options, value]);
20001
+ }, [getOptionId, hasClearButton, isMultiple, onChange, onSearch, options, value]);
19998
20002
 
19999
20003
  // Handle text input changes (search).
20000
20004
  const handleInputChange = useCallback(inputValue => {
@@ -20003,10 +20007,10 @@ const SelectTextField$1 = props => {
20003
20007
  onSearch?.(inputValue);
20004
20008
 
20005
20009
  // When the user clears the input (single mode only), clear the selection too.
20006
- if (!isMultiple && inputValue === '' && value !== undefined && value !== null) {
20010
+ if (!isMultiple && hasClearButton && inputValue === '' && value !== undefined && value !== null) {
20007
20011
  onChange?.(undefined);
20008
20012
  }
20009
- }, [isMultiple, onChange, onSearch, value]);
20013
+ }, [hasClearButton, isMultiple, onChange, onSearch, value]);
20010
20014
 
20011
20015
  // Handle clear button click (single mode only).
20012
20016
  const handleClear = useCallback(event => {
@@ -24352,6 +24356,7 @@ function setupTreeList(options = {}) {
24352
24356
  function registerTreeItem(element, itemOptions) {
24353
24357
  const {
24354
24358
  isParent,
24359
+ defaultOpen,
24355
24360
  onOpenChange,
24356
24361
  onChange
24357
24362
  } = itemOptions;
@@ -24361,7 +24366,7 @@ function setupTreeList(options = {}) {
24361
24366
  const hasSelectedBelow = () => hasSelectedSubItem(element);
24362
24367
  let filterState = NO_FILTER_STATE;
24363
24368
  /** Open state set by the user (or the initial state) without a filter. */
24364
- let userOpen = hasSelectedBelow();
24369
+ let userOpen = defaultOpen || hasSelectedBelow();
24365
24370
  /** Open state set by the user during a filter (lasts until the next change of the filter text). */
24366
24371
  let filterOverride = null;
24367
24372
  /**
@@ -24820,8 +24825,8 @@ function isTreeListHandle(handle) {
24820
24825
  * tree `value` holds it. Without, it is not selectable: Enter or a click on a non-selectable parent item
24821
24826
  * opens or closes it, and on a non-selectable leaf item only calls `onClick` (e.g. an action such as
24822
24827
  * "Create a new list…").
24823
- * - The open state is internal: a parent item starts open when a sub-item at any depth is selected.
24824
- * In a combobox, it resets on each popup open.
24828
+ * - The open state is internal: a parent item starts open with `defaultOpen`, or when a sub-item at
24829
+ * any depth is selected. In a combobox, it resets on each popup open.
24825
24830
  * - Touch screen readers: TalkBack (Chrome) can open and close the parent items. On iOS, a user can
24826
24831
  * only reach the sub-items of a selectable parent item through the filter. To support it, use a
24827
24832
  * non-selectable parent item with an "All <name>" leaf item that carries the parent value.
@@ -24836,6 +24841,7 @@ const TreeListItem = forwardRef((props, ref) => {
24836
24841
  children,
24837
24842
  value,
24838
24843
  hasSubItems,
24844
+ defaultOpen,
24839
24845
  onOpenChange,
24840
24846
  onClick,
24841
24847
  before,
@@ -24875,10 +24881,12 @@ const TreeListItem = forwardRef((props, ref) => {
24875
24881
  // Latest props read by the controller.
24876
24882
  const latestProps = useRef({
24877
24883
  isParent,
24884
+ defaultOpen,
24878
24885
  onOpenChange
24879
24886
  });
24880
24887
  latestProps.current = {
24881
24888
  isParent,
24889
+ defaultOpen,
24882
24890
  onOpenChange
24883
24891
  };
24884
24892
  const [state, setState] = useState({
@@ -24892,6 +24900,7 @@ const TreeListItem = forwardRef((props, ref) => {
24892
24900
  if (!element || !tree) return undefined;
24893
24901
  const controller = tree.registerTreeItem(element, {
24894
24902
  isParent: () => latestProps.current.isParent,
24903
+ defaultOpen: latestProps.current.defaultOpen,
24895
24904
  onOpenChange: isOpen => latestProps.current.onOpenChange?.(isOpen),
24896
24905
  onChange: setState
24897
24906
  });