@nolwenture/formik-jsonschema-form 0.17.0 → 0.19.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.
- package/README.md +21 -0
- package/dist/fields/SearchableSelectField.d.ts +3 -0
- package/dist/fields/SearchableSelectField.js +57 -0
- package/dist/fields/index.d.ts +1 -0
- package/dist/fields/index.js +1 -0
- package/dist/sampleData/completeSchema.js +30 -0
- package/dist/styledComponents.d.ts +26 -0
- package/dist/styledComponents.js +66 -12
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -409,6 +409,8 @@ export function MyFormComponent() {
|
|
|
409
409
|
Enum fields are fields with multiple options to either choose `oneOf` or `anyOf` from.
|
|
410
410
|
There is an alternative field implementation for "anyOf" that when given `"ui:field": "SearchMultiTagSelectField"` results in a searchable multi tag select field.
|
|
411
411
|
|
|
412
|
+
A searchable single select field is also available for `oneOf` and `enum`. To use it, add the following to the field's uiSchema: `"ui:field": "SearchableSelectField"`
|
|
413
|
+
|
|
412
414
|
The type of the field holding the enum is defined by its return value. `oneOf` enums will only return a single value and therefore, the type of the returned value is used as the field type (in the following example, "number" is the correct field type).
|
|
413
415
|
|
|
414
416
|
`anyOf`enums will return the value(s) inside an array, even if only one option was selected. Therefore, the correct field type for the field holding the `anyOf`-enum is "array".
|
|
@@ -451,6 +453,16 @@ const schema = {
|
|
|
451
453
|
{ const: 4, title: "four" },
|
|
452
454
|
],
|
|
453
455
|
},
|
|
456
|
+
enumSearchableOneOf: {
|
|
457
|
+
type: "string",
|
|
458
|
+
title: "Enum searchable select oneOf",
|
|
459
|
+
oneOf: [
|
|
460
|
+
{ const: "one", title: "One" },
|
|
461
|
+
{ const: "two", title: "Two" },
|
|
462
|
+
{ const: "three", title: "Three" },
|
|
463
|
+
{ const: "four", title: "Four" },
|
|
464
|
+
],
|
|
465
|
+
},
|
|
454
466
|
},
|
|
455
467
|
};
|
|
456
468
|
|
|
@@ -462,6 +474,15 @@ const uiSchema = {
|
|
|
462
474
|
emptySearchMessage: "...no matching results found",
|
|
463
475
|
},
|
|
464
476
|
},
|
|
477
|
+
enumSearchableOneOf: {
|
|
478
|
+
"ui:field": "SearchableSelectField",
|
|
479
|
+
"ui:options": {
|
|
480
|
+
placeholder: "Search...",
|
|
481
|
+
clearButtonText: "Clear",
|
|
482
|
+
expandText: "More results",
|
|
483
|
+
emptySearchMessage: "...no matching results found",
|
|
484
|
+
},
|
|
485
|
+
},
|
|
465
486
|
};
|
|
466
487
|
```
|
|
467
488
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef, useContext, useMemo } from "react";
|
|
3
|
+
import { useExtractUiSchema, useSetDefault } from "../hooks";
|
|
4
|
+
import { FormRegistry } from "../Form";
|
|
5
|
+
import { useField } from "formik";
|
|
6
|
+
import { getEnums } from "../utils";
|
|
7
|
+
export const SearchableSelectField = (props) => {
|
|
8
|
+
const { templates: { FieldTemplate }, components: { SearchableSelectContainer, SearchDropdownContainer, SearchListOption, SearchListExpand, SearchNotFound, SearchInput, SearchClearButton, SearchInputContainer, }, } = useContext(FormRegistry);
|
|
9
|
+
useSetDefault(props);
|
|
10
|
+
const { name, uiSchema } = props;
|
|
11
|
+
const { props: inputProps, placeholder, clearButtonText, expandText, notFoundMessage, } = useExtractUiSchema(uiSchema);
|
|
12
|
+
const [{ value }, __, { setValue }] = useField(name);
|
|
13
|
+
const enums = useMemo(() => getEnums(props), [props]);
|
|
14
|
+
const options = (enums === null || enums === void 0 ? void 0 : enums.values) || [];
|
|
15
|
+
const [showOptions, setShowOptions] = useState(false);
|
|
16
|
+
const [searchTerm, setSearchTerm] = useState(() => { var _a, _b; return (_b = (_a = options.find((option) => option.const === value)) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : ""; });
|
|
17
|
+
const [displayedItems, setDisplayedItems] = useState([]);
|
|
18
|
+
const [itemsToShow, setItemsToShow] = useState(10);
|
|
19
|
+
const moreRef = useRef(null);
|
|
20
|
+
const containerRef = useRef(null);
|
|
21
|
+
const loadMoreItems = () => {
|
|
22
|
+
setItemsToShow((prev) => prev + 10);
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setDisplayedItems(options
|
|
26
|
+
.filter((option) => { var _a, _b; return ((_b = (_a = option.title) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "").includes(searchTerm.toLowerCase()); })
|
|
27
|
+
.slice(0, itemsToShow));
|
|
28
|
+
}, [itemsToShow, options, searchTerm]);
|
|
29
|
+
const handleSearchChange = (event) => {
|
|
30
|
+
setSearchTerm(event.target.value);
|
|
31
|
+
setItemsToShow(10);
|
|
32
|
+
setShowOptions(true);
|
|
33
|
+
};
|
|
34
|
+
const handleSelect = (item) => {
|
|
35
|
+
var _a;
|
|
36
|
+
setSearchTerm((_a = item.title) !== null && _a !== void 0 ? _a : "");
|
|
37
|
+
setValue(item.const);
|
|
38
|
+
setShowOptions(false);
|
|
39
|
+
};
|
|
40
|
+
const handleFocus = () => {
|
|
41
|
+
setShowOptions(true);
|
|
42
|
+
};
|
|
43
|
+
const handleBlur = (event) => {
|
|
44
|
+
if (containerRef.current &&
|
|
45
|
+
!containerRef.current.contains(event.relatedTarget)) {
|
|
46
|
+
setShowOptions(false);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const handleClear = () => {
|
|
50
|
+
setSearchTerm("");
|
|
51
|
+
setValue(undefined);
|
|
52
|
+
};
|
|
53
|
+
const filteredOptions = options.filter((option) => { var _a, _b; return ((_b = (_a = option.title) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "").includes(searchTerm.toLowerCase()); });
|
|
54
|
+
const showMoreOption = displayedItems.length < filteredOptions.length &&
|
|
55
|
+
displayedItems.length >= 10;
|
|
56
|
+
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(SearchableSelectContainer, { ref: containerRef, onBlur: handleBlur, children: [_jsxs(SearchInputContainer, { children: [_jsx(SearchInput, Object.assign({}, inputProps, { name: name, type: "text", placeholder: placeholder, value: searchTerm, onChange: handleSearchChange, onFocus: handleFocus })), searchTerm && (_jsx(SearchClearButton, { onClick: handleClear, children: clearButtonText !== null && clearButtonText !== void 0 ? clearButtonText : "x" }))] }), showOptions && (_jsxs(SearchDropdownContainer, { role: "dropdown-list", ref: moreRef, children: [displayedItems.length > 0 ? (displayedItems.map((item, index) => (_jsx(SearchListOption, { role: "filtered-list", onClick: () => handleSelect(item), onMouseDown: (e) => e.preventDefault(), children: item.title }, index)))) : (_jsx(SearchNotFound, { onMouseDown: (e) => e.preventDefault(), children: notFoundMessage !== null && notFoundMessage !== void 0 ? notFoundMessage : "No match found" })), showMoreOption && (_jsx(SearchListExpand, { ref: moreRef, onMouseDown: (e) => e.preventDefault(), onClick: loadMoreItems, children: expandText !== null && expandText !== void 0 ? expandText : "More..." }))] }))] }) })));
|
|
57
|
+
};
|
package/dist/fields/index.d.ts
CHANGED
package/dist/fields/index.js
CHANGED
|
@@ -68,6 +68,27 @@ export const completeSchema = {
|
|
|
68
68
|
{ const: "dragon", title: "dragon" },
|
|
69
69
|
],
|
|
70
70
|
},
|
|
71
|
+
searchableSelect: {
|
|
72
|
+
type: "string",
|
|
73
|
+
title: "Enum searchable select oneOf",
|
|
74
|
+
description: "Enum searchable select oneOf description",
|
|
75
|
+
oneOf: [
|
|
76
|
+
{ const: "cat", title: "cat" },
|
|
77
|
+
{ const: "dog", title: "dog" },
|
|
78
|
+
{ const: "bunny", title: "bunny" },
|
|
79
|
+
{ const: "canary", title: "canary" },
|
|
80
|
+
{ const: "hamster", title: "hamster" },
|
|
81
|
+
{ const: "goldfish", title: "goldfish" },
|
|
82
|
+
{ const: "dragon", title: "dragon" },
|
|
83
|
+
{ const: "lizard", title: "lizard" },
|
|
84
|
+
{ const: "frog", title: "frog" },
|
|
85
|
+
{ const: "parrot", title: "parrot" },
|
|
86
|
+
{ const: "turtle", title: "turtle" },
|
|
87
|
+
{ const: "raccoon", title: "raccoon" },
|
|
88
|
+
{ const: "tiger", title: "tiger" },
|
|
89
|
+
{ const: "lion", title: "lion" },
|
|
90
|
+
],
|
|
91
|
+
},
|
|
71
92
|
null: { type: "null", title: "Null", description: "Null description" },
|
|
72
93
|
nested: {
|
|
73
94
|
type: "object",
|
|
@@ -293,5 +314,14 @@ export const completeUiSchema = {
|
|
|
293
314
|
emptySearchMessage: "...no matching results found",
|
|
294
315
|
},
|
|
295
316
|
},
|
|
317
|
+
searchableSelect: {
|
|
318
|
+
"ui:field": "SearchableSelectField",
|
|
319
|
+
"ui:options": {
|
|
320
|
+
placeholder: "Search...",
|
|
321
|
+
clearButtonText: "X",
|
|
322
|
+
expandText: "More results",
|
|
323
|
+
emptySearchMessage: "...no matching results found",
|
|
324
|
+
},
|
|
325
|
+
},
|
|
296
326
|
textArea: { "ui:field": "TextAreaField" },
|
|
297
327
|
};
|
|
@@ -167,6 +167,7 @@ export declare const RadioButtonField: {
|
|
|
167
167
|
};
|
|
168
168
|
export declare const MultipleChoiceField: ({ inputProps, name, className, enums, style, }: MultipleChoiceFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
169
169
|
export declare const MultiSelectContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
170
|
+
export declare const MultiSelectSearchContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
170
171
|
export declare const MultiSelectInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<Omit<Omit<any, "as">, "ref"> & {
|
|
171
172
|
ref?: unknown;
|
|
172
173
|
}, never>, "ref"> & {
|
|
@@ -184,6 +185,7 @@ export declare const SearchableMultiTagSelectField: {
|
|
|
184
185
|
({ name, placeholder, enums, emptySearchMessage, closeElement, className, }: SelectFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
185
186
|
styles: {
|
|
186
187
|
MultiSelectContainerStyle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
188
|
+
MultiSelectSearchContainerStyle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
187
189
|
MultiSelectInputStyle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<Omit<Omit<any, "as">, "ref"> & {
|
|
188
190
|
ref?: unknown;
|
|
189
191
|
}, never>, "ref"> & {
|
|
@@ -214,4 +216,28 @@ export declare const Icon: import("styled-components").IStyledComponent<"web", i
|
|
|
214
216
|
export declare const CollapsibleChildWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
215
217
|
export declare const CollapsibleObjectFieldWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, never>>;
|
|
216
218
|
export declare const CollapsibleObjectFieldTitle: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, never>>;
|
|
219
|
+
export declare const SearchableSelectContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>, "ref"> & {
|
|
220
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
221
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>, keyof React.Component<any, {}, any>>;
|
|
222
|
+
export declare const SearchDropdownContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>, "ref"> & {
|
|
223
|
+
ref?: ((instance: HTMLUListElement | null) => void) | React.RefObject<HTMLUListElement> | null | undefined;
|
|
224
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, never>>, keyof React.Component<any, {}, any>>;
|
|
225
|
+
export declare const SearchListOption: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>, "ref"> & {
|
|
226
|
+
ref?: ((instance: HTMLLIElement | null) => void) | React.RefObject<HTMLLIElement> | null | undefined;
|
|
227
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>>, keyof React.Component<any, {}, any>>;
|
|
228
|
+
export declare const SearchListExpand: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>, "ref"> & {
|
|
229
|
+
ref?: ((instance: HTMLLIElement | null) => void) | React.RefObject<HTMLLIElement> | null | undefined;
|
|
230
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>>, keyof React.Component<any, {}, any>>;
|
|
231
|
+
export declare const SearchNotFound: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>, "ref"> & {
|
|
232
|
+
ref?: ((instance: HTMLLIElement | null) => void) | React.RefObject<HTMLLIElement> | null | undefined;
|
|
233
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>>, keyof React.Component<any, {}, any>>;
|
|
234
|
+
export declare const SearchInput: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("styled-components/dist/types").FastOmit<Omit<Omit<any, "as">, "ref"> & {
|
|
235
|
+
ref?: unknown;
|
|
236
|
+
}, never>, "ref"> & {
|
|
237
|
+
ref?: unknown;
|
|
238
|
+
}, never>> & Omit<import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<any, "as">, "ref"> & {
|
|
239
|
+
ref?: unknown;
|
|
240
|
+
}, never>> & Omit<({ formikAs, ...props }: Omit<formik.FieldAttributes<any>, "as">) => import("react/jsx-runtime").JSX.Element, keyof React.Component<any, {}, any>>, keyof React.Component<any, {}, any>>;
|
|
241
|
+
export declare const SearchClearButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>;
|
|
242
|
+
export declare const SearchInputContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
217
243
|
export {};
|
package/dist/styledComponents.js
CHANGED
|
@@ -293,7 +293,14 @@ export const MultiSelectContainer = styled.div `
|
|
|
293
293
|
display: flex;
|
|
294
294
|
flex-direction: column;
|
|
295
295
|
`;
|
|
296
|
-
export const
|
|
296
|
+
export const MultiSelectSearchContainer = styled.div `
|
|
297
|
+
display: inline-block;
|
|
298
|
+
position: relative;
|
|
299
|
+
width: fit-content;
|
|
300
|
+
`;
|
|
301
|
+
export const MultiSelectInput = styled(FieldInput) `
|
|
302
|
+
width: 100%;
|
|
303
|
+
`;
|
|
297
304
|
export const MultiSelectBadgeContainer = styled.div `
|
|
298
305
|
margin: 0.3em 0;
|
|
299
306
|
display: inline-flex;
|
|
@@ -313,13 +320,15 @@ export const MultiSelectBadgeCloseElement = styled.span `
|
|
|
313
320
|
font-family: sans-serif;
|
|
314
321
|
`;
|
|
315
322
|
export const MultiSelectOptionList = styled.ul `
|
|
323
|
+
width: 100%;
|
|
316
324
|
padding: unset;
|
|
317
325
|
margin: unset;
|
|
318
326
|
border: 1px solid gray;
|
|
319
327
|
border-radius: 0.2em;
|
|
320
328
|
position: absolute;
|
|
321
329
|
background: white;
|
|
322
|
-
|
|
330
|
+
top: 100%;
|
|
331
|
+
z-index: 1000;
|
|
323
332
|
`;
|
|
324
333
|
export const MultiSelectOptionListItem = styled.li `
|
|
325
334
|
cursor: pointer;
|
|
@@ -345,22 +354,23 @@ export const SearchableMultiTagSelectField = ({ name, placeholder, enums, emptyS
|
|
|
345
354
|
};
|
|
346
355
|
return (_jsx(formik.Field, { className: className, name: name, multiple: true, children: ({ field, form: { setFieldValue }, meta, }) => {
|
|
347
356
|
var _a;
|
|
348
|
-
return (_jsxs(MultiSelectContainer, { className: className, children: [_jsx(FieldInput, Object.assign({ id: className, type: "hidden" }, field)), _jsx(MultiSelectInput, { id: className + "_id", className: className, type: "text", onChange: (e) => {
|
|
349
|
-
|
|
350
|
-
|
|
357
|
+
return (_jsxs(MultiSelectContainer, { className: className, children: [_jsx(FieldInput, Object.assign({ id: className, type: "hidden" }, field)), _jsxs(MultiSelectSearchContainer, { children: [_jsx(MultiSelectInput, { id: className + "_id", className: className, type: "text", onChange: (e) => {
|
|
358
|
+
setSearch(e.currentTarget.value);
|
|
359
|
+
}, placeholder: placeholder, value: search }), search.length > 0 && (_jsx(MultiSelectOptionList, { children: searchIncludedInEnum() ? (enums === null || enums === void 0 ? void 0 : enums.values.filter((item) => { var _a; return !((_a = field.value) !== null && _a !== void 0 ? _a : []).includes(item.const); }).filter((value) => value.title.toLowerCase().includes(search.toLowerCase())).map((option, index) => (_jsx(MultiSelectOptionListItem, { value: option.const, onClick: () => {
|
|
360
|
+
var _a;
|
|
361
|
+
setFieldValue(name, [
|
|
362
|
+
...new Set([...((_a = field.value) !== null && _a !== void 0 ? _a : []), option.const]),
|
|
363
|
+
]);
|
|
364
|
+
setSearch("");
|
|
365
|
+
}, children: option.title }, index)))) : (_jsx(MultiSelectOptionListWithoutItem, { children: emptySearchMessage !== null && emptySearchMessage !== void 0 ? emptySearchMessage : "No match found" })) }))] }), _jsx(MultiSelectBadgeContainer, { children: ((_a = field.value) !== null && _a !== void 0 ? _a : []).map((value) => {
|
|
351
366
|
var _a;
|
|
352
367
|
return (_jsxs(MultiSelectBadge, { children: [(_a = enums === null || enums === void 0 ? void 0 : enums.values.find((option) => option.const === value)) === null || _a === void 0 ? void 0 : _a.title, _jsx(MultiSelectBadgeCloseElement, { onClick: () => setFieldValue(name, field.value.filter((v) => v !== value)), children: closeElement !== null && closeElement !== void 0 ? closeElement : "x" })] }, value));
|
|
353
|
-
}) }),
|
|
354
|
-
var _a;
|
|
355
|
-
setFieldValue(name, [
|
|
356
|
-
...new Set([...((_a = field.value) !== null && _a !== void 0 ? _a : []), option.const]),
|
|
357
|
-
]);
|
|
358
|
-
setSearch("");
|
|
359
|
-
}, children: option.title }, index)))) : (_jsx(MultiSelectOptionListWithoutItem, { children: emptySearchMessage !== null && emptySearchMessage !== void 0 ? emptySearchMessage : "No match found" })) })), meta.touched && meta.error && (_jsx("div", { className: "error", children: meta.error }))] }));
|
|
368
|
+
}) }), meta.touched && meta.error && (_jsx("div", { className: "error", children: meta.error }))] }));
|
|
360
369
|
} }));
|
|
361
370
|
};
|
|
362
371
|
SearchableMultiTagSelectField.styles = {
|
|
363
372
|
MultiSelectContainerStyle: MultiSelectContainer,
|
|
373
|
+
MultiSelectSearchContainerStyle: MultiSelectSearchContainer,
|
|
364
374
|
MultiSelectInputStyle: MultiSelectInput,
|
|
365
375
|
MultiSelectBadgeContainerStyle: MultiSelectBadgeContainer,
|
|
366
376
|
MultiSelectBadgeStyle: MultiSelectBadge,
|
|
@@ -402,3 +412,47 @@ export const Icon = styled.div `
|
|
|
402
412
|
export const CollapsibleChildWrapper = styled.div ``;
|
|
403
413
|
export const CollapsibleObjectFieldWrapper = ObjectFieldWrapper;
|
|
404
414
|
export const CollapsibleObjectFieldTitle = ObjectFieldTitle;
|
|
415
|
+
export const SearchableSelectContainer = styled(MultiSelectSearchContainer) ``;
|
|
416
|
+
export const SearchDropdownContainer = styled(MultiSelectOptionList) `
|
|
417
|
+
overflow-y: auto;
|
|
418
|
+
overflow-x: auto;
|
|
419
|
+
max-height: 6rem;
|
|
420
|
+
white-space: nowrap;
|
|
421
|
+
`;
|
|
422
|
+
export const SearchListOption = styled(MultiSelectOptionListItem) `
|
|
423
|
+
cursor: default;
|
|
424
|
+
`;
|
|
425
|
+
export const SearchListExpand = styled(MultiSelectOptionListItem) `
|
|
426
|
+
text-decoration: underline;
|
|
427
|
+
&:hover {
|
|
428
|
+
background: none;
|
|
429
|
+
}
|
|
430
|
+
`;
|
|
431
|
+
export const SearchNotFound = styled(MultiSelectOptionListItem) `
|
|
432
|
+
cursor: default;
|
|
433
|
+
&:hover {
|
|
434
|
+
background: none;
|
|
435
|
+
}
|
|
436
|
+
`;
|
|
437
|
+
export const SearchInput = styled(FieldInput) `
|
|
438
|
+
width: 100%;
|
|
439
|
+
padding-right: 1.5em;
|
|
440
|
+
text-overflow: ellipsis;
|
|
441
|
+
`;
|
|
442
|
+
export const SearchClearButton = styled.span `
|
|
443
|
+
cursor: pointer;
|
|
444
|
+
position: absolute;
|
|
445
|
+
right: 0.3em;
|
|
446
|
+
bottom: 0;
|
|
447
|
+
top: 0;
|
|
448
|
+
margin: auto;
|
|
449
|
+
background-color: #ccc;
|
|
450
|
+
border-radius: 50%;
|
|
451
|
+
line-height: 1em;
|
|
452
|
+
min-width: 1em;
|
|
453
|
+
height: 1em;
|
|
454
|
+
text-align: center;
|
|
455
|
+
`;
|
|
456
|
+
export const SearchInputContainer = styled.div `
|
|
457
|
+
display: flex;
|
|
458
|
+
`;
|
package/dist/types.d.ts
CHANGED
|
@@ -147,6 +147,14 @@ export type ComponentsType = {
|
|
|
147
147
|
BooleanFieldWrapper: React.FunctionComponent<any>;
|
|
148
148
|
CollapsibleObjectFieldWrapper: React.FunctionComponent<any>;
|
|
149
149
|
CollapsibleObjectFieldTitle: React.FunctionComponent<any>;
|
|
150
|
+
SearchableSelectContainer: React.FunctionComponent<any>;
|
|
151
|
+
SearchDropdownContainer: React.FunctionComponent<any>;
|
|
152
|
+
SearchListOption: React.FunctionComponent<any>;
|
|
153
|
+
SearchListExpand: React.FunctionComponent<any>;
|
|
154
|
+
SearchNotFound: React.FunctionComponent<any>;
|
|
155
|
+
SearchInput: React.FunctionComponent<any>;
|
|
156
|
+
SearchClearButton: React.FunctionComponent<any>;
|
|
157
|
+
SearchInputContainer: React.FunctionComponent<any>;
|
|
150
158
|
};
|
|
151
159
|
export declare enum ObjectFieldButtonPurpose {
|
|
152
160
|
ADD = 0,
|