@symply.io/basic-components 1.2.14-beta.1 → 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.
@@ -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
- }, getOptionLabel: function (opt) { return opt.label || ""; }, isOptionEqualToValue: function (opt, val) { return opt.value === val.value; }, value: value, inputValue: inputValue, onInputChange: function (event, val) {
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
  }
@@ -4,7 +4,7 @@ export declare type AutocompleteOptionType<T = {
4
4
  [name: string]: unknown;
5
5
  }> = T & {
6
6
  label: string;
7
- value: unknown;
7
+ value?: string | number;
8
8
  };
9
9
  export declare type AutocompleteValueType<T, multiple extends boolean | undefined> = multiple extends false | undefined ? AutocompleteOptionType<T> | null : Array<AutocompleteOptionType<T>>;
10
10
  export interface AutocompleteProps<T, multiple extends boolean | undefined> extends Omit<TextFieldProps, "onChange" | "value" | "disabled"> {
@@ -43,8 +43,22 @@ function AutocompleteWithFilter(props) {
43
43
  event.preventDefault();
44
44
  onChange(val);
45
45
  }, value: value, disableCloseOnSelect: disableCloseOnSelect || multiple, getOptionLabel: function (option) {
46
- return option.label || "";
47
- }, isOptionEqualToValue: function (opt, val) { return opt.value === val.value; }, renderOption: function (props, option, _a) {
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;
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 || ""] })));
50
64
  }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { variant: "outlined", required: required, inputProps: __assign(__assign({}, params.inputProps), { required: required && (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
@@ -2,7 +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: unknown;
5
+ value?: string | number;
6
6
  };
7
7
  export declare type AutocompleteWithFilterlValueType<T, multiple extends boolean | undefined> = multiple extends false | undefined ? AutocompleteWithFilterOptionType<T> | null : Array<AutocompleteWithFilterOptionType<T>>;
8
8
  export interface AutocompleteWithFilterProps<T, multiple extends boolean | undefined> extends Omit<TextFieldProps, "onChange" | "value" | "disabled"> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.2.14-beta.1",
3
+ "version": "1.2.14-beta.2",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",