@ftdata/ui 0.0.10 → 0.0.12
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/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/index.d.ts +1 -1
- package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/index.d.ts +1 -1
- package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/index.js +1 -1
- package/dist/components/MultiSelect/helpers/addOption.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/addOption.js +1 -1
- package/dist/components/MultiSelect/helpers/arraysEqual.d.ts +2 -0
- package/dist/components/MultiSelect/helpers/arraysEqual.js +5 -0
- package/dist/components/MultiSelect/helpers/computeSelected.d.ts +2 -0
- package/dist/components/MultiSelect/helpers/computeSelected.js +2 -0
- package/dist/components/MultiSelect/helpers/computeUnselected.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/computeUnselected.js +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/feedbackText.js +8 -8
- package/dist/components/MultiSelect/helpers/filterOptions.d.ts +1 -1
- package/dist/components/MultiSelect/helpers/filterOptions.js +2 -2
- package/dist/components/MultiSelect/helpers/getChangedFieds.d.ts +2 -0
- package/dist/components/MultiSelect/helpers/getChangedFieds.js +17 -0
- package/dist/components/MultiSelect/helpers/removeOptions.d.ts +1 -1
- package/dist/components/MultiSelect/hooks/useMultiSelect.d.ts +10 -0
- package/dist/components/MultiSelect/hooks/useMultiSelect.js +44 -0
- package/dist/components/MultiSelect/index.d.ts +6 -18
- package/dist/components/MultiSelect/index.js +18 -5
- package/dist/components/MultiSelect/interfaces/actions.d.ts +4 -0
- package/dist/components/MultiSelect/interfaces/actions.js +0 -0
- package/dist/components/MultiSelect/interfaces/config.d.ts +17 -0
- package/dist/components/MultiSelect/interfaces/config.js +0 -0
- package/dist/components/MultiSelect/interfaces/state.d.ts +10 -0
- package/dist/components/MultiSelect/interfaces/state.js +0 -0
- package/dist/components/MultiSelect/reducers/stateReducer.d.ts +21 -0
- package/dist/components/MultiSelect/reducers/stateReducer.js +44 -0
- package/dist/components/MultiSelect/styles.d.ts +1 -1
- package/dist/components/MultiSelect/styles.js +9 -3
- package/dist/components/fields/components/RotateButton/index.d.ts +1 -1
- package/dist/components/fields/components/RotateButton/index.js +2 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
- /package/dist/components/MultiSelect/{Badge → components/Badge}/index.d.ts +0 -0
- /package/dist/components/MultiSelect/{Badge → components/Badge}/index.js +0 -0
- /package/dist/components/MultiSelect/{Badge → components/Badge}/styles.d.ts +0 -0
- /package/dist/components/MultiSelect/{Badge → components/Badge}/styles.js +0 -0
- /package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/index.js +0 -0
- /package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/style.d.ts +0 -0
- /package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/style.js +0 -0
- /package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/style.d.ts +0 -0
- /package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/style.js +0 -0
package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/index.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RowComponentProps } from "react-window";
|
|
2
|
-
import { IMultiSelectOption } from "
|
|
2
|
+
import { IMultiSelectOption } from "../../../interfaces/state";
|
|
3
3
|
export default function Row({ index, style, options, onClickOption, addAll, }: RowComponentProps<{
|
|
4
4
|
options: IMultiSelectOption[];
|
|
5
5
|
onClickOption?: (event: React.MouseEvent<HTMLDivElement>, option: IMultiSelectOption) => void;
|
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { List } from "react-window";
|
|
3
3
|
import Row from "./Row/index.js";
|
|
4
4
|
import { LoadingContainer, SelectDropdown } from "./style.js";
|
|
5
|
-
import Loading from "
|
|
5
|
+
import Loading from "../../../Loading/index.js";
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
function MultiSelectList({ options, onClickOption, loading, addAll, translation, onLoadMore }) {
|
|
8
8
|
const [lastIndex, setLastIndex] = useState(0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMultiSelectOption } from
|
|
1
|
+
import { IMultiSelectOption } from "../interfaces/state";
|
|
2
2
|
export declare const addOption: (selected: IMultiSelectOption[], options: IMultiSelectOption[], option: IMultiSelectOption, max?: number) => {
|
|
3
3
|
selected: IMultiSelectOption[];
|
|
4
4
|
unselected: IMultiSelectOption[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computeUnselected } from "./computeUnselected.js";
|
|
2
2
|
const addOption = (selected, options, option, max)=>{
|
|
3
|
-
if (
|
|
3
|
+
if ("feedback__" === option.value) return;
|
|
4
4
|
if (max && selected.length >= max) return;
|
|
5
5
|
const newSelected = [
|
|
6
6
|
...selected,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IMultiSelectOption } from
|
|
1
|
+
import { IMultiSelectOption } from "../interfaces/state";
|
|
2
2
|
export declare const computeUnselected: (options: IMultiSelectOption[], selected: IMultiSelectOption[]) => IMultiSelectOption[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const computeUnselected = (options, selected)=>options.filter((opt)=>!selected.some((
|
|
1
|
+
const computeUnselected = (options, selected)=>options.filter((opt)=>!selected.some((s)=>s.value === opt.value));
|
|
2
2
|
export { computeUnselected };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMultiSelectOption } from
|
|
1
|
+
import { IMultiSelectOption } from "../interfaces/state";
|
|
2
2
|
export declare function feedbackText(translation: (key: string) => string, options: IMultiSelectOption[], filtered: IMultiSelectOption[], selected: IMultiSelectOption[], query: string, max?: number): {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
@@ -2,27 +2,27 @@ import { computeUnselected } from "./computeUnselected.js";
|
|
|
2
2
|
function feedbackText(translation, options, filtered, selected, query, max) {
|
|
3
3
|
if (!options.length) return [
|
|
4
4
|
{
|
|
5
|
-
value:
|
|
6
|
-
label: translation(
|
|
5
|
+
value: "feedback__",
|
|
6
|
+
label: translation("no_data_is_available")
|
|
7
7
|
}
|
|
8
8
|
];
|
|
9
9
|
if (max && selected.length >= max) return [
|
|
10
10
|
{
|
|
11
|
-
value:
|
|
12
|
-
label: translation(
|
|
11
|
+
value: "feedback__",
|
|
12
|
+
label: translation("the_selection_limit_has_been_reached")
|
|
13
13
|
}
|
|
14
14
|
];
|
|
15
15
|
if (query && !filtered.length) return [
|
|
16
16
|
{
|
|
17
|
-
value:
|
|
18
|
-
label: translation(
|
|
17
|
+
value: "feedback__",
|
|
18
|
+
label: translation("no_data_was_found")
|
|
19
19
|
}
|
|
20
20
|
];
|
|
21
21
|
const unselected = computeUnselected(options, selected);
|
|
22
22
|
if (!query && !unselected.length) return [
|
|
23
23
|
{
|
|
24
|
-
value:
|
|
25
|
-
label: translation(
|
|
24
|
+
value: "feedback__",
|
|
25
|
+
label: translation("all_were_selected")
|
|
26
26
|
}
|
|
27
27
|
];
|
|
28
28
|
return [];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IMultiSelectOption } from
|
|
1
|
+
import { IMultiSelectOption } from "../interfaces/state";
|
|
2
2
|
export declare const filterOptions: (options: IMultiSelectOption[], query: string) => IMultiSelectOption[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const filterOptions = (options, query)=>{
|
|
2
|
-
const normalizedQuery = query.toLowerCase().normalize(
|
|
3
|
-
return options.filter((o)=>o.label.toLowerCase().normalize(
|
|
2
|
+
const normalizedQuery = query.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
3
|
+
return options.filter((o)=>o.label.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").includes(normalizedQuery));
|
|
4
4
|
};
|
|
5
5
|
export { filterOptions };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { arraysEqual } from "./arraysEqual.js";
|
|
2
|
+
const FIELDS = [
|
|
3
|
+
"selected",
|
|
4
|
+
"options",
|
|
5
|
+
"filtered",
|
|
6
|
+
"unselected"
|
|
7
|
+
];
|
|
8
|
+
function getChangedFields(base, compare) {
|
|
9
|
+
const changed = [];
|
|
10
|
+
FIELDS.forEach((key)=>{
|
|
11
|
+
const last = base[key] || [];
|
|
12
|
+
const next = compare[key] || [];
|
|
13
|
+
if (arraysEqual(last, next)) changed.push(key);
|
|
14
|
+
});
|
|
15
|
+
return changed;
|
|
16
|
+
}
|
|
17
|
+
export { getChangedFields };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMultiSelectOption } from
|
|
1
|
+
import { IMultiSelectOption } from "../interfaces/state";
|
|
2
2
|
export declare const removeOption: (selected: IMultiSelectOption[], options: IMultiSelectOption[], option: IMultiSelectOption) => {
|
|
3
3
|
selected: IMultiSelectOption[];
|
|
4
4
|
unselected: IMultiSelectOption[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IMultiSelectState } from "../interfaces/state";
|
|
2
|
+
import { IMultiSelectConfig } from "../interfaces/config";
|
|
3
|
+
interface UseIMultiSelectConfig {
|
|
4
|
+
config?: IMultiSelectConfig;
|
|
5
|
+
}
|
|
6
|
+
export declare function useMultiSelect({ config }: UseIMultiSelectConfig): {
|
|
7
|
+
state: IMultiSelectState;
|
|
8
|
+
updateState: (newPartial: Partial<IMultiSelectState>) => void;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect, useReducer } from "react";
|
|
2
|
+
import { computeUnselected } from "../helpers/computeUnselected.js";
|
|
3
|
+
import { stateReducer } from "../reducers/stateReducer.js";
|
|
4
|
+
import { arraysEqual } from "../helpers/arraysEqual.js";
|
|
5
|
+
function useMultiSelect({ config }) {
|
|
6
|
+
const initial = {
|
|
7
|
+
selected: config?.fields?.externalSelected ?? [],
|
|
8
|
+
options: config?.fields?.externalOptions ?? [],
|
|
9
|
+
filtered: config?.fields?.externalFiltered ?? [],
|
|
10
|
+
unselected: computeUnselected(config?.fields?.externalOptions ?? [], config?.fields?.externalSelected ?? [])
|
|
11
|
+
};
|
|
12
|
+
const [state, dispatch] = useReducer(stateReducer, initial);
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
if (!config) return;
|
|
15
|
+
const { fields, actions } = config;
|
|
16
|
+
const payload = {};
|
|
17
|
+
if (fields?.externalSelected && !arraysEqual(fields.externalSelected, state.selected)) payload.selected = fields.externalSelected;
|
|
18
|
+
if (fields?.externalOptions && !arraysEqual(fields.externalOptions, state.options)) payload.options = fields.externalOptions;
|
|
19
|
+
if (fields?.externalFiltered && !arraysEqual(fields.externalFiltered, state.filtered)) payload.filtered = fields.externalFiltered;
|
|
20
|
+
if (fields?.externalUnselected && !arraysEqual(fields.externalUnselected, state.unselected)) payload.unselected = fields.externalUnselected;
|
|
21
|
+
if (Object.keys(payload).length) dispatch({
|
|
22
|
+
type: "SET_STATE",
|
|
23
|
+
payload
|
|
24
|
+
});
|
|
25
|
+
if (actions?.onSelectedChange) actions.onSelectedChange(state.selected);
|
|
26
|
+
if (actions?.onOptionsChange) actions.onOptionsChange(state.options);
|
|
27
|
+
if (actions?.onFilteredChange) actions.onFilteredChange(state.filtered);
|
|
28
|
+
if (actions?.onUnselectedChange) actions.onUnselectedChange(state.unselected);
|
|
29
|
+
}, [
|
|
30
|
+
state,
|
|
31
|
+
config
|
|
32
|
+
]);
|
|
33
|
+
const updateState = (newPartial)=>{
|
|
34
|
+
dispatch({
|
|
35
|
+
type: "SET_STATE",
|
|
36
|
+
payload: newPartial
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
state,
|
|
41
|
+
updateState
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { useMultiSelect };
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { InputHTMLAttributes, JSX } from "react";
|
|
2
2
|
import { FieldFeedbackType } from "../../types/feedback";
|
|
3
3
|
import { IconsNames } from "@ftdata/f-icons";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export interface IMultiSelectState {
|
|
9
|
-
selected: IMultiSelectOption[];
|
|
10
|
-
options: IMultiSelectOption[];
|
|
11
|
-
filtered: IMultiSelectOption[];
|
|
12
|
-
unselected: IMultiSelectOption[];
|
|
13
|
-
}
|
|
14
|
-
export interface IMultiSelectActions {
|
|
15
|
-
clear: () => void;
|
|
16
|
-
search?: (query: string) => void;
|
|
17
|
-
}
|
|
18
|
-
interface MultiSelectProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "value"> {
|
|
4
|
+
import { IMultiSelectActions } from "./interfaces/actions";
|
|
5
|
+
import { IMultiSelectState } from "./interfaces/state";
|
|
6
|
+
export interface MultiSelectProps extends InputHTMLAttributes<HTMLDivElement> {
|
|
19
7
|
disabled?: boolean;
|
|
20
8
|
helpText?: string;
|
|
21
9
|
helpIcon?: IconsNames;
|
|
@@ -27,13 +15,13 @@ interface MultiSelectProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
|
27
15
|
clear?: () => void;
|
|
28
16
|
loading?: boolean;
|
|
29
17
|
state: IMultiSelectState;
|
|
30
|
-
actions
|
|
18
|
+
actions?: IMultiSelectActions;
|
|
31
19
|
updateState: (newPartial: Partial<IMultiSelectState>) => void;
|
|
32
20
|
translation: (key: string) => string;
|
|
33
21
|
max?: number;
|
|
34
22
|
selectAll?: boolean;
|
|
35
23
|
total?: number;
|
|
36
24
|
onLoadMore?: () => Promise<void>;
|
|
25
|
+
toggle?: (open: boolean) => void;
|
|
37
26
|
}
|
|
38
|
-
export default function MultiSelect({ helpText, label, sublabel, required, disabled, feedback, helpIcon, name, translation, state, updateState, placeholder, max, loading, actions, selectAll, total, icon, onLoadMore, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
-
export {};
|
|
27
|
+
export default function MultiSelect({ helpText, label, sublabel, required, disabled, feedback, helpIcon, name, translation, state, updateState, placeholder, max, loading, actions, selectAll, total, icon, onLoadMore, toggle, ...rest }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,8 +5,8 @@ import Label from "../fields/components/Label/index.js";
|
|
|
5
5
|
import { getHelpTextFeedbackType } from "../fields/helpers/getFeedbackType.js";
|
|
6
6
|
import { Icon } from "@ftdata/f-icons";
|
|
7
7
|
import HelpText from "../fields/components/HelpText/index.js";
|
|
8
|
-
import MultiSelectList from "./MultiSelectList/index.js";
|
|
9
|
-
import Badge from "./Badge/index.js";
|
|
8
|
+
import MultiSelectList from "./components/MultiSelectList/index.js";
|
|
9
|
+
import Badge from "./components/Badge/index.js";
|
|
10
10
|
import { addOption } from "./helpers/addOption.js";
|
|
11
11
|
import { removeOption } from "./helpers/removeOptions.js";
|
|
12
12
|
import { computeUnselected } from "./helpers/computeUnselected.js";
|
|
@@ -15,7 +15,7 @@ import { feedbackText } from "./helpers/feedbackText.js";
|
|
|
15
15
|
import { COLOR_NEUTRAL_DARK } from "@ftdata/f-tokens";
|
|
16
16
|
import RotateButton from "../fields/components/RotateButton/index.js";
|
|
17
17
|
import calcTextSize from "./helpers/calcTextSize.js";
|
|
18
|
-
function MultiSelect({ helpText, label, sublabel, required, disabled, feedback, helpIcon, name, translation, state, updateState, placeholder, max, loading, actions, selectAll, total, icon, onLoadMore }) {
|
|
18
|
+
function MultiSelect({ helpText, label, sublabel, required, disabled, feedback, helpIcon, name, translation, state, updateState, placeholder, max, loading, actions, selectAll, total, icon, onLoadMore, toggle, ...rest }) {
|
|
19
19
|
const [showList, setShowList] = useState(false);
|
|
20
20
|
const [query, setQuery] = useState("");
|
|
21
21
|
const [inputSize, setInputSize] = useState(0);
|
|
@@ -53,7 +53,7 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
53
53
|
if (!value) return updateState({
|
|
54
54
|
filtered: []
|
|
55
55
|
});
|
|
56
|
-
if (actions
|
|
56
|
+
if (actions?.search) return void actions.search(value);
|
|
57
57
|
updateState({
|
|
58
58
|
filtered: filterOptions(computeUnselected(options, selected), value)
|
|
59
59
|
});
|
|
@@ -131,14 +131,22 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
131
131
|
const feedBackHelpText = getHelpTextFeedbackType(feedback, disabled);
|
|
132
132
|
const toggleList = (event)=>{
|
|
133
133
|
event.stopPropagation();
|
|
134
|
+
if (disabled) return;
|
|
134
135
|
setShowList((prev)=>!prev);
|
|
135
136
|
};
|
|
136
137
|
const handleClickContainer = (event)=>{
|
|
137
138
|
event.stopPropagation();
|
|
139
|
+
if (disabled) return;
|
|
138
140
|
if (!showList) setShowList(true);
|
|
139
141
|
inputRef.current?.focus();
|
|
140
142
|
};
|
|
143
|
+
useEffect(()=>{
|
|
144
|
+
if (toggle) toggle(showList);
|
|
145
|
+
}, [
|
|
146
|
+
showList
|
|
147
|
+
]);
|
|
141
148
|
return /*#__PURE__*/ jsxs(MultiSelectWrapper, {
|
|
149
|
+
...rest,
|
|
142
150
|
children: [
|
|
143
151
|
/*#__PURE__*/ jsxs(LabelContainer, {
|
|
144
152
|
children: [
|
|
@@ -179,6 +187,7 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
179
187
|
value: query,
|
|
180
188
|
onKeyDown: handleKeyDown,
|
|
181
189
|
onChange: handleChange,
|
|
190
|
+
disabled: disabled,
|
|
182
191
|
size: inputSize,
|
|
183
192
|
wide: 0 === selected.length
|
|
184
193
|
})
|
|
@@ -186,7 +195,11 @@ function MultiSelect({ helpText, label, sublabel, required, disabled, feedback,
|
|
|
186
195
|
}),
|
|
187
196
|
/*#__PURE__*/ jsx(RotateButton, {
|
|
188
197
|
rotate: showList,
|
|
189
|
-
onClick: toggleList
|
|
198
|
+
onClick: toggleList,
|
|
199
|
+
disabled: disabled,
|
|
200
|
+
style: {
|
|
201
|
+
cursor: disabled ? "not-allowed" : "pointer"
|
|
202
|
+
}
|
|
190
203
|
}),
|
|
191
204
|
!!max && /*#__PURE__*/ jsx(MaxItemsIndicator, {
|
|
192
205
|
children: /*#__PURE__*/ jsxs("span", {
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IMultiSelectState, IMultiSelectOption } from "./state";
|
|
2
|
+
export interface IMultiSelectConfigFields {
|
|
3
|
+
externalSelected?: IMultiSelectOption[];
|
|
4
|
+
externalOptions?: IMultiSelectOption[];
|
|
5
|
+
externalFiltered?: IMultiSelectOption[];
|
|
6
|
+
externalUnselected?: IMultiSelectOption[];
|
|
7
|
+
}
|
|
8
|
+
export interface IMultiSelectConfigActions {
|
|
9
|
+
onSelectedChange?: (selected: IMultiSelectState["selected"]) => void;
|
|
10
|
+
onOptionsChange?: (options: IMultiSelectState["options"]) => void;
|
|
11
|
+
onFilteredChange?: (filtered: IMultiSelectState["filtered"]) => void;
|
|
12
|
+
onUnselectedChange?: (unselected: IMultiSelectState["unselected"]) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface IMultiSelectConfig {
|
|
15
|
+
fields?: IMultiSelectConfigFields;
|
|
16
|
+
actions?: IMultiSelectConfigActions;
|
|
17
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IMultiSelectOption, IMultiSelectState } from "../interfaces/state";
|
|
2
|
+
type MultiSelectAction = {
|
|
3
|
+
type: "SET_STATE";
|
|
4
|
+
payload: Partial<IMultiSelectState>;
|
|
5
|
+
} | {
|
|
6
|
+
type: "SET_OPTIONS";
|
|
7
|
+
payload: IMultiSelectOption[];
|
|
8
|
+
} | {
|
|
9
|
+
type: "SET_SELECTED";
|
|
10
|
+
payload: IMultiSelectOption[];
|
|
11
|
+
} | {
|
|
12
|
+
type: "SET_UNSELECTED";
|
|
13
|
+
payload: IMultiSelectOption[];
|
|
14
|
+
} | {
|
|
15
|
+
type: "SET_FILTERED";
|
|
16
|
+
payload: IMultiSelectOption[];
|
|
17
|
+
} | {
|
|
18
|
+
type: "CLEAR";
|
|
19
|
+
};
|
|
20
|
+
export declare function stateReducer(state: IMultiSelectState, action: MultiSelectAction): IMultiSelectState;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { computeUnselected } from "../helpers/computeUnselected.js";
|
|
2
|
+
import { computeSelected } from "../helpers/computeSelected.js";
|
|
3
|
+
function stateReducer(state, action) {
|
|
4
|
+
switch(action.type){
|
|
5
|
+
case "SET_STATE":
|
|
6
|
+
return {
|
|
7
|
+
...state,
|
|
8
|
+
...action.payload,
|
|
9
|
+
unselected: computeUnselected(action.payload.options ?? state.options, action.payload.selected ?? state.selected)
|
|
10
|
+
};
|
|
11
|
+
case "SET_OPTIONS":
|
|
12
|
+
return {
|
|
13
|
+
...state,
|
|
14
|
+
options: action.payload,
|
|
15
|
+
unselected: computeUnselected(action.payload, state.selected)
|
|
16
|
+
};
|
|
17
|
+
case "SET_SELECTED":
|
|
18
|
+
return {
|
|
19
|
+
...state,
|
|
20
|
+
selected: action.payload,
|
|
21
|
+
unselected: computeUnselected(state.options, action.payload)
|
|
22
|
+
};
|
|
23
|
+
case "SET_UNSELECTED":
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
selected: computeSelected(state.options, action.payload),
|
|
27
|
+
unselected: action.payload
|
|
28
|
+
};
|
|
29
|
+
case "SET_FILTERED":
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
filtered: action.payload
|
|
33
|
+
};
|
|
34
|
+
case "CLEAR":
|
|
35
|
+
return {
|
|
36
|
+
...state,
|
|
37
|
+
selected: [],
|
|
38
|
+
unselected: state.options
|
|
39
|
+
};
|
|
40
|
+
default:
|
|
41
|
+
return state;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export { stateReducer };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldFeedbackType } from
|
|
1
|
+
import { FieldFeedbackType } from "../../types/feedback";
|
|
2
2
|
export declare const MultiSelectWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
3
|
interface labelProps {
|
|
4
4
|
required?: boolean;
|
|
@@ -19,7 +19,7 @@ const showButton = keyframes`
|
|
|
19
19
|
`;
|
|
20
20
|
const LabelContainer = styled_components.div`
|
|
21
21
|
display: flex;
|
|
22
|
-
gap: ${({ required })=>required ?
|
|
22
|
+
gap: ${({ required })=>required ? "0" : "0.5rem"};
|
|
23
23
|
position: relative;
|
|
24
24
|
justify-content: space-between;
|
|
25
25
|
align-items: flex-end;
|
|
@@ -47,7 +47,7 @@ const MultiSelectContainer = styled_components.div`
|
|
|
47
47
|
padding: 0.5rem 0.5rem 0.5rem 1rem;
|
|
48
48
|
width: 100%;
|
|
49
49
|
box-shadow: 0 0 0
|
|
50
|
-
${({ $active })=>$active ?
|
|
50
|
+
${({ $active })=>$active ? "2px" : "1px"}${COLOR_NEUTRAL_MEDIUM};
|
|
51
51
|
position: relative;
|
|
52
52
|
|
|
53
53
|
&:focus-within {
|
|
@@ -88,12 +88,13 @@ const BadgesContainer = styled_components.div`
|
|
|
88
88
|
const ResizableInput = styled_components.input`
|
|
89
89
|
outline: none;
|
|
90
90
|
border: none;
|
|
91
|
+
background-color: transparent;
|
|
91
92
|
color: ${COLOR_NEUTRAL_DUSK};
|
|
92
93
|
font-size: 0.875rem;
|
|
93
94
|
line-height: 1rem;
|
|
94
95
|
font-weight: ${FONT_WEIGHT_MEDIUM};
|
|
95
96
|
padding: 0.25rem 0;
|
|
96
|
-
width: ${({ size, wide })=>wide ?
|
|
97
|
+
width: ${({ size, wide })=>wide ? "100%" : size ? `${size}rem` : "1rem"};
|
|
97
98
|
|
|
98
99
|
&::placeholder {
|
|
99
100
|
color: ${COLOR_NEUTRAL_DARK};
|
|
@@ -102,6 +103,11 @@ const ResizableInput = styled_components.input`
|
|
|
102
103
|
font-weight: ${FONT_WEIGHT_MEDIUM};
|
|
103
104
|
line-height: 1.5rem;
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
&:disabled {
|
|
108
|
+
background-color: ${COLOR_NEUTRAL_LIGHTER};
|
|
109
|
+
cursor: not-allowed;
|
|
110
|
+
}
|
|
105
111
|
`;
|
|
106
112
|
const MaxItemsIndicator = styled_components.div`
|
|
107
113
|
display: flex;
|
|
@@ -2,5 +2,5 @@ import { ButtonHTMLAttributes } from "react";
|
|
|
2
2
|
interface RotateButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
3
|
rotate?: boolean;
|
|
4
4
|
}
|
|
5
|
-
export default function RotateButton({ rotate }: RotateButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export default function RotateButton({ rotate, ...rest }: RotateButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Icon } from "@ftdata/f-icons";
|
|
3
3
|
import { Rotate } from "./styles.js";
|
|
4
|
-
function RotateButton({ rotate }) {
|
|
4
|
+
function RotateButton({ rotate, ...rest }) {
|
|
5
5
|
return /*#__PURE__*/ jsx(Rotate, {
|
|
6
6
|
rotate: rotate,
|
|
7
|
+
...rest,
|
|
7
8
|
children: /*#__PURE__*/ jsx(Icon, {
|
|
8
9
|
name: "arw caret-down",
|
|
9
10
|
color: "currentColor"
|
package/dist/index.d.ts
CHANGED
|
@@ -14,9 +14,14 @@ export { default as Collapse } from "./components/Collapse";
|
|
|
14
14
|
export { default as UserMenu } from "./components/UserMenu";
|
|
15
15
|
export { default as Select } from "./components/Select";
|
|
16
16
|
export type { ISelectOption } from "./components/Select";
|
|
17
|
+
export type { SelectProps } from "./components/Select";
|
|
17
18
|
export { default as StateAlert } from "./components/StateAlert";
|
|
18
19
|
export { default as MultiSelect } from "./components/MultiSelect";
|
|
19
|
-
export
|
|
20
|
+
export { useMultiSelect } from "./components/MultiSelect/hooks/useMultiSelect";
|
|
21
|
+
export type { MultiSelectProps } from "./components/MultiSelect";
|
|
22
|
+
export type { IMultiSelectActions } from "./components/MultiSelect/interfaces/actions";
|
|
23
|
+
export type { IMultiSelectOption, IMultiSelectState, } from "./components/MultiSelect/interfaces/state";
|
|
24
|
+
export type { IMultiSelectConfig, IMultiSelectConfigActions, IMultiSelectConfigFields, } from "./components/MultiSelect/interfaces/config";
|
|
20
25
|
export { default as DoubleList } from "./components/DoubleList";
|
|
21
26
|
export { default as Menu } from "./components/Menu";
|
|
22
27
|
export type { MenuItem, MenuItemData, SubMenu, SubMenuData, } from "./components/Menu/types/MenuItem";
|
package/dist/index.js
CHANGED
|
@@ -13,9 +13,10 @@ import UserMenu from "./components/UserMenu/index.js";
|
|
|
13
13
|
import Select from "./components/Select/index.js";
|
|
14
14
|
import StateAlert from "./components/StateAlert/index.js";
|
|
15
15
|
import MultiSelect from "./components/MultiSelect/index.js";
|
|
16
|
+
import { useMultiSelect } from "./components/MultiSelect/hooks/useMultiSelect.js";
|
|
16
17
|
import DoubleList from "./components/DoubleList/index.js";
|
|
17
18
|
import Menu from "./components/Menu/index.js";
|
|
18
19
|
import { Input } from "./components/Input/index.js";
|
|
19
20
|
export * from "./components/Grid/index.js";
|
|
20
21
|
export * from "./components/Text/index.js";
|
|
21
|
-
export { Avatar, Breadcrumb, Button, Checkbox, Collapse, DoubleList, EmptyState, Input, Loading, Menu, MultiSelect, Radio, Select, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading };
|
|
22
|
+
export { Avatar, Breadcrumb, Button, Checkbox, Collapse, DoubleList, EmptyState, Input, Loading, Menu, MultiSelect, Radio, Select, StateAlert, Switch, TextArea, Tooltips, UserMenu, useLoading, useMultiSelect };
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/index.js
RENAMED
|
File without changes
|
/package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/style.d.ts
RENAMED
|
File without changes
|
/package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/Row/style.js
RENAMED
|
File without changes
|
/package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/style.d.ts
RENAMED
|
File without changes
|
/package/dist/components/MultiSelect/{MultiSelectList → components/MultiSelectList}/style.js
RENAMED
|
File without changes
|