@homebound/beam 2.356.1 → 2.357.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.
|
@@ -14,7 +14,10 @@ exports.multiFilter = multiFilter;
|
|
|
14
14
|
class MultiFilter extends BaseFilter_1.BaseFilter {
|
|
15
15
|
render(value, setValue, tid, inModal, vertical) {
|
|
16
16
|
var _a;
|
|
17
|
-
if (inModal &&
|
|
17
|
+
if (inModal &&
|
|
18
|
+
Array.isArray(this.props.options) &&
|
|
19
|
+
this.props.options.length > 0 &&
|
|
20
|
+
this.props.options.length <= 8) {
|
|
18
21
|
const { disabledOptions } = this.props;
|
|
19
22
|
const disabledOptionsWithReasons = Object.fromEntries((_a = disabledOptions === null || disabledOptions === void 0 ? void 0 : disabledOptions.map(ComboBoxBase_1.disabledOptionToKeyedTuple)) !== null && _a !== void 0 ? _a : []);
|
|
20
23
|
const disabledKeys = Object.keys(disabledOptionsWithReasons);
|
|
@@ -9,7 +9,6 @@ export interface MultiSelectFieldProps<O, V extends Value> extends Exclude<Combo
|
|
|
9
9
|
getOptionLabel: (opt: O) => string;
|
|
10
10
|
values: V[];
|
|
11
11
|
onSelect: (values: V[], opts: O[]) => void;
|
|
12
|
-
options: O[];
|
|
13
12
|
}
|
|
14
13
|
/**
|
|
15
14
|
* Provides a non-native multiselect/dropdown widget.
|
|
@@ -66,8 +66,8 @@ export interface ComboBoxBaseProps<O, V extends Value> extends BeamFocusableProp
|
|
|
66
66
|
export declare function ComboBoxBase<O, V extends Value>(props: ComboBoxBaseProps<O, V>): JSX.Element;
|
|
67
67
|
/** Allows lazy-loading select fields, which is useful for pages w/lots of fields the user may not actually use. */
|
|
68
68
|
export type OptionsOrLoad<O> = O[] | {
|
|
69
|
-
/** The initial option to show before the user interacts with the dropdown. */
|
|
70
|
-
current: O | undefined;
|
|
69
|
+
/** The initial option(s) to show before the user interacts with the dropdown. */
|
|
70
|
+
current: O | O[] | undefined;
|
|
71
71
|
/** Fired when the user interacts with the dropdown, to load the real options. */
|
|
72
72
|
load: () => Promise<unknown>;
|
|
73
73
|
/** The full list of options, after load() has been fired. */
|
|
@@ -256,13 +256,16 @@ function initializeOptions(optionsOrLoad, getOptionValue, unsetLabel) {
|
|
|
256
256
|
if (options) {
|
|
257
257
|
opts.push(...options);
|
|
258
258
|
}
|
|
259
|
-
//
|
|
259
|
+
// Add the `current` to the list of options in the event it is not already there.
|
|
260
260
|
if (current) {
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
261
|
+
const toCheck = Array.isArray(current) ? current : [current];
|
|
262
|
+
toCheck.forEach((current) => {
|
|
263
|
+
const value = getOptionValue(current);
|
|
264
|
+
const found = options && options.find((o) => getOptionValue(o) === value);
|
|
265
|
+
if (!found) {
|
|
266
|
+
opts.push(current);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
266
269
|
}
|
|
267
270
|
}
|
|
268
271
|
return opts;
|