@symply.io/basic-components 1.2.13 → 1.2.14-beta.2
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/Autocomplete/index.js
CHANGED
@@ -33,7 +33,23 @@ function CustomAutocomplete(props) {
|
|
33
33
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Autocomplete, { size: size, fullWidth: true, loading: loading, disabled: disabled, limitTags: limitTags !== null && limitTags !== void 0 ? limitTags : -1, options: options, multiple: multiple, onChange: function (event, val) {
|
34
34
|
event.preventDefault();
|
35
35
|
onChange(val);
|
36
|
-
},
|
36
|
+
}, getOptionLabel: function (option) {
|
37
|
+
if (typeof option === "string") {
|
38
|
+
return option;
|
39
|
+
}
|
40
|
+
if (option.value) {
|
41
|
+
return String(option.value);
|
42
|
+
}
|
43
|
+
return option.label;
|
44
|
+
}, renderOption: function (props, option) { return (_jsx("li", __assign({}, props, { children: option.label || "" }))); }, isOptionEqualToValue: function (opt, val) {
|
45
|
+
if (typeof opt === "string") {
|
46
|
+
return opt === val;
|
47
|
+
}
|
48
|
+
if (opt.value) {
|
49
|
+
return String(opt.value) === String(val.value);
|
50
|
+
}
|
51
|
+
return opt.label === val.label;
|
52
|
+
}, value: value, inputValue: inputValue, onInputChange: function (event, val) {
|
37
53
|
onInputChange(val);
|
38
54
|
}, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { required: required, size: size, inputProps: __assign(__assign({}, params.inputProps), { required: required && (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
|
39
55
|
}
|
package/Autocomplete/types.d.ts
CHANGED
@@ -4,6 +4,7 @@ export declare type AutocompleteOptionType<T = {
|
|
4
4
|
[name: string]: unknown;
|
5
5
|
}> = T & {
|
6
6
|
label: string;
|
7
|
+
value?: string | number;
|
7
8
|
};
|
8
9
|
export declare type AutocompleteValueType<T, multiple extends boolean | undefined> = multiple extends false | undefined ? AutocompleteOptionType<T> | null : Array<AutocompleteOptionType<T>>;
|
9
10
|
export interface AutocompleteProps<T, multiple extends boolean | undefined> extends Omit<TextFieldProps, "onChange" | "value" | "disabled"> {
|
@@ -43,7 +43,21 @@ function AutocompleteWithFilter(props) {
|
|
43
43
|
event.preventDefault();
|
44
44
|
onChange(val);
|
45
45
|
}, value: value, disableCloseOnSelect: disableCloseOnSelect || multiple, getOptionLabel: function (option) {
|
46
|
-
|
46
|
+
if (typeof option === "string") {
|
47
|
+
return option;
|
48
|
+
}
|
49
|
+
if (option.value) {
|
50
|
+
return String(option.value);
|
51
|
+
}
|
52
|
+
return option.label;
|
53
|
+
}, isOptionEqualToValue: function (opt, val) {
|
54
|
+
if (typeof opt === "string") {
|
55
|
+
return opt === val;
|
56
|
+
}
|
57
|
+
if (opt.value) {
|
58
|
+
return String(opt.value) === String(val.value);
|
59
|
+
}
|
60
|
+
return opt.label === val.label;
|
47
61
|
}, renderOption: function (props, option, _a) {
|
48
62
|
var selected = _a.selected;
|
49
63
|
return (_jsxs("li", __assign({}, props, { children: [_jsx(Checkbox, { icon: icon, color: "primary", checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected }), option.label || ""] })));
|
@@ -2,6 +2,7 @@ import { CSSProperties } from "react";
|
|
2
2
|
import { TextFieldProps } from "@mui/material/TextField";
|
3
3
|
export declare type AutocompleteWithFilterOptionType<T> = T & {
|
4
4
|
label: string;
|
5
|
+
value?: string | number;
|
5
6
|
};
|
6
7
|
export declare type AutocompleteWithFilterlValueType<T, multiple extends boolean | undefined> = multiple extends false | undefined ? AutocompleteWithFilterOptionType<T> | null : Array<AutocompleteWithFilterOptionType<T>>;
|
7
8
|
export interface AutocompleteWithFilterProps<T, multiple extends boolean | undefined> extends Omit<TextFieldProps, "onChange" | "value" | "disabled"> {
|
package/README.md
CHANGED
@@ -122,7 +122,8 @@ import Autocomplete from '@symply.io/basic-components/Autocomplete';
|
|
122
122
|
| Name | Type | Default | Required | Description |
|
123
123
|
| ------ | ------- | ------- | -------- | -------------------------- |
|
124
124
|
| label | string | | true | Option label. |
|
125
|
-
|
|
125
|
+
| value | unknown | | true | Option valie. |
|
126
|
+
| [name] | unknown | | false | Customized option property |
|
126
127
|
|
127
128
|
<h5>Props</h5>
|
128
129
|
|
@@ -155,7 +156,8 @@ import AutocompleteWithFilter from '@symply.io/basic-components/AutocompleteWith
|
|
155
156
|
| Name | Type | Default | Required | Description |
|
156
157
|
| ------ | ------- | ------- | -------- | -------------------------- |
|
157
158
|
| label | string | | true | Option label. |
|
158
|
-
|
|
159
|
+
| value | unknown | | true | Option valie. |
|
160
|
+
| [name] | unknown | | false | Customized option property |
|
159
161
|
|
160
162
|
<h5>Props</h5>
|
161
163
|
|