@lumx/core 4.12.1 → 4.13.0-next.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/js/components/Combobox/ComboboxButton.d.ts +3 -1
- package/js/types/NamedProps.d.ts +8 -0
- package/js/types/index.d.ts +1 -0
- package/js/utils/select/findOptionById.d.ts +13 -0
- package/js/utils/select/toggleSelection.d.ts +23 -0
- package/js/utils/select/types.d.ts +47 -0
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CommonRef, HasClassName, LumxClassName } from '../../types';
|
|
1
|
+
import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
|
|
2
2
|
import type { ComboboxCallbacks } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Label display mode for the ComboboxButton.
|
|
@@ -23,6 +23,8 @@ export interface ComboboxButtonProps extends HasClassName, ComboboxCallbacks {
|
|
|
23
23
|
isOpen?: boolean;
|
|
24
24
|
/** ref to the root button element. */
|
|
25
25
|
ref?: CommonRef;
|
|
26
|
+
/** Custom render button */
|
|
27
|
+
renderButton?: (buttonProps: Record<string, any>) => JSXElement;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* Injected framework-specific components for ComboboxButton rendering.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips index signature from a type, keeping only explicitly named properties.
|
|
3
|
+
* Used to prevent `GenericProps`'s `[propName: string]: any` from contaminating
|
|
4
|
+
* TypeScript inference of the option type `O`.
|
|
5
|
+
*/
|
|
6
|
+
export type NamedProps<T> = {
|
|
7
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
8
|
+
};
|
package/js/types/index.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export type { AriaAttributes } from './AriaAttributes';
|
|
|
27
27
|
export type { Selector } from './Selector';
|
|
28
28
|
export type { PropsToOverride } from './jsx/PropsToOverride';
|
|
29
29
|
export type { PartialBy, PartialExcept } from './PartialBy';
|
|
30
|
+
export type { NamedProps } from './NamedProps';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Selector } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Find the option whose id matches the given value.
|
|
4
|
+
*
|
|
5
|
+
* Used by Select* wrappers to resolve a selection event (which carries the option id
|
|
6
|
+
* as `selectedOption.value`) back to the original option object.
|
|
7
|
+
*
|
|
8
|
+
* @param options The list of options.
|
|
9
|
+
* @param getOptionId Selector returning the option id (matches `<Combobox.Option value>`).
|
|
10
|
+
* @param id The id to match against.
|
|
11
|
+
* @return The matching option, or `undefined` if none is found / inputs are nullish.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findOptionById<O>(options: readonly O[] | undefined, getOptionId: Selector<O> | undefined, id: unknown): O | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Selector } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the next selection state after a user toggles an option.
|
|
4
|
+
*
|
|
5
|
+
* Single-mode behaviour (`isMultiple=false`):
|
|
6
|
+
* - Returns the option matched by id (or `undefined` if none matches the id —
|
|
7
|
+
* e.g. when the consumer triggers a custom action via `beforeOptions`).
|
|
8
|
+
*
|
|
9
|
+
* Multi-mode behaviour (`isMultiple=true`):
|
|
10
|
+
* - If the option is already in the current value array → returns a new array with it removed.
|
|
11
|
+
* - Otherwise → returns a new array with the option appended.
|
|
12
|
+
* - If the id matches no option in `options` (e.g. custom actions), the current array is returned unchanged.
|
|
13
|
+
*
|
|
14
|
+
* Pure function: never mutates `currentValue`.
|
|
15
|
+
*
|
|
16
|
+
* @param options The list of options.
|
|
17
|
+
* @param getOptionId Selector returning the option id (matches `<Combobox.Option value>`).
|
|
18
|
+
* @param currentValue Current selection (option, array of options, or undefined).
|
|
19
|
+
* @param selectedOptionId Id of the option the user just selected.
|
|
20
|
+
* @param isMultiple Whether to use multi-select semantics.
|
|
21
|
+
* @return The new selection — `O | undefined` in single mode, `O[]` in multi mode.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toggleSelection<O>(options: readonly O[] | undefined, getOptionId: Selector<O> | undefined, currentValue: O | O[] | undefined, selectedOptionId: unknown, isMultiple: boolean): O | O[] | undefined;
|
|
@@ -19,6 +19,8 @@ export interface RenderOptionContext {
|
|
|
19
19
|
index: number;
|
|
20
20
|
/** Resolved option id (from `getOptionId`). Should be passed as `value` to `<Combobox.Option>`. */
|
|
21
21
|
value: any;
|
|
22
|
+
/** Resolved option name (from `getOptionName`, falling back to `getOptionId`). */
|
|
23
|
+
name: string;
|
|
22
24
|
/** Whether this option is currently selected. Should be forwarded as `isSelected`. */
|
|
23
25
|
isSelected: boolean;
|
|
24
26
|
/** Resolved description string (from `getOptionDescription`), if any. Should be forwarded as `description`. */
|
|
@@ -116,6 +118,51 @@ export interface SelectTextFieldTranslations {
|
|
|
116
118
|
/** Secondary error message (e.g. "Please try again"). */
|
|
117
119
|
errorTryReloadMessage?: string;
|
|
118
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Shared translation labels for SelectButton wrappers (React and Vue).
|
|
123
|
+
*/
|
|
124
|
+
export interface SelectButtonTranslations {
|
|
125
|
+
/** Screen reader loading announcement (e.g. "Loading…"). */
|
|
126
|
+
loadingMessage?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Message to display when the list has no visible options.
|
|
129
|
+
* Can be a plain string or a function receiving the current input value (for dynamic messages).
|
|
130
|
+
* When omitted, the empty state is not shown.
|
|
131
|
+
*/
|
|
132
|
+
emptyMessage?: string | ((inputValue: string) => string);
|
|
133
|
+
/**
|
|
134
|
+
* Message callback to display the number of available options.
|
|
135
|
+
* Called with the current visible option count and should return a human-readable string.
|
|
136
|
+
* Displayed when the dropdown is open, not empty, not loading, and not in error.
|
|
137
|
+
* When omitted, no option count message is shown.
|
|
138
|
+
*/
|
|
139
|
+
nbOptionMessage?: (optionsLength: number) => string;
|
|
140
|
+
/** Error title displayed in the dropdown (e.g. "Failed to load"). */
|
|
141
|
+
errorMessage?: string;
|
|
142
|
+
/** Secondary error message (e.g. "Please try again"). */
|
|
143
|
+
errorTryReloadMessage?: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Wrapper-level props shared between React and Vue SelectButton implementations.
|
|
147
|
+
* These are framework-specific concerns (not part of the core template) that both
|
|
148
|
+
* wrappers need — extracted here to avoid duplication.
|
|
149
|
+
*/
|
|
150
|
+
export interface BaseSelectButtonWrapperProps<O> extends Pick<BaseSelectProps<O>, 'options' | 'getOptionId' | 'getOptionName' | 'getOptionDescription' | 'getSectionId'> {
|
|
151
|
+
/**
|
|
152
|
+
* Selection type. Discriminator that wrappers expand into a typed union:
|
|
153
|
+
* `'single'` (default) → `value?: O`, `'multiple'` → `value: O[]`.
|
|
154
|
+
*/
|
|
155
|
+
selectionType?: 'single' | 'multiple';
|
|
156
|
+
/** Button label (used for ARIA and when no selection). */
|
|
157
|
+
label: string;
|
|
158
|
+
/**
|
|
159
|
+
* Status of the dropdown list.
|
|
160
|
+
* @default 'idle'
|
|
161
|
+
*/
|
|
162
|
+
listStatus?: SelectTextFieldStatus;
|
|
163
|
+
/** Optional translations for screen-reader announcements (loading/empty/error/option count). */
|
|
164
|
+
translations?: SelectButtonTranslations;
|
|
165
|
+
}
|
|
119
166
|
/**
|
|
120
167
|
* Wrapper-level props shared between React and Vue SelectTextField implementations.
|
|
121
168
|
* These are framework-specific concerns (not part of the core template) that both
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@floating-ui/dom": "^1.7.5",
|
|
10
|
-
"@lumx/icons": "^4.
|
|
10
|
+
"@lumx/icons": "^4.13.0-next.1",
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"focus-visible": "^5.0.2",
|
|
13
13
|
"lodash": "4.18.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
70
70
|
},
|
|
71
71
|
"sideEffects": false,
|
|
72
|
-
"version": "4.
|
|
72
|
+
"version": "4.13.0-next.1",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
75
75
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -92,5 +92,6 @@
|
|
|
92
92
|
"vite": "^7.3.2",
|
|
93
93
|
"vite-tsconfig-paths": "^5.1.4",
|
|
94
94
|
"vitest": "^4.0.18"
|
|
95
|
-
}
|
|
95
|
+
},
|
|
96
|
+
"stableVersion": "4.12.1"
|
|
96
97
|
}
|