@solostylist/ui-kit 1.0.13 → 1.0.14
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { AutocompleteProps } from '@mui/material';
|
|
3
|
-
export interface SAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined = undefined> extends Omit<AutocompleteProps<T
|
|
4
|
-
renderInput?: AutocompleteProps<T
|
|
3
|
+
export interface SAutocompleteProps<T, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined = undefined> extends Omit<AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>, 'renderInput'> {
|
|
4
|
+
renderInput?: AutocompleteProps<T, Multiple, DisableClearable, FreeSolo>['renderInput'];
|
|
5
5
|
label?: string | React.ReactNode;
|
|
6
6
|
required?: boolean;
|
|
7
7
|
error?: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SelectProps } from '@mui/material';
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
type BaseOption = string | number | {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
type SSelectProps<T extends BaseOption = string> = Omit<SelectProps, 'error' | 'variant'> & {
|
|
6
|
+
options?: T[];
|
|
7
|
+
optionLabel?: T extends object ? keyof T : never;
|
|
8
|
+
optionValue?: T extends object ? keyof T : never;
|
|
6
9
|
placeholder?: string;
|
|
7
10
|
variant?: 'outlined' | 'filled' | 'standard';
|
|
8
11
|
label?: string;
|
|
@@ -11,5 +14,5 @@ type SSelectProps = Omit<SelectProps, 'error' | 'variant'> & {
|
|
|
11
14
|
simple?: boolean;
|
|
12
15
|
htmlFor?: string;
|
|
13
16
|
};
|
|
14
|
-
declare const SSelect: import('react').ForwardRefExoticComponent<Omit<SSelectProps
|
|
17
|
+
declare const SSelect: import('react').ForwardRefExoticComponent<Omit<SSelectProps<BaseOption>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
|
|
15
18
|
export default SSelect;
|
|
@@ -1,54 +1,61 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Select as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { j as d } from "../jsx-runtime-C5mzlN2N.js";
|
|
2
|
+
import { forwardRef as h, useState as m, useEffect as V } from "react";
|
|
3
|
+
import { Select as E, MenuItem as O } from "@mui/material";
|
|
4
|
+
import R from "../s-form/s-form.js";
|
|
5
|
+
const M = h(
|
|
6
6
|
({
|
|
7
|
-
options:
|
|
8
|
-
optionLabel:
|
|
9
|
-
optionValue:
|
|
10
|
-
placeholder:
|
|
11
|
-
label:
|
|
12
|
-
error:
|
|
13
|
-
required:
|
|
14
|
-
variant:
|
|
15
|
-
simple:
|
|
16
|
-
htmlFor:
|
|
17
|
-
...
|
|
18
|
-
},
|
|
19
|
-
const [S,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
7
|
+
options: l = [],
|
|
8
|
+
optionLabel: o = "name",
|
|
9
|
+
optionValue: c = "id",
|
|
10
|
+
placeholder: i,
|
|
11
|
+
label: v = "",
|
|
12
|
+
error: x,
|
|
13
|
+
required: y = !1,
|
|
14
|
+
variant: $ = "outlined",
|
|
15
|
+
simple: g = !1,
|
|
16
|
+
htmlFor: s,
|
|
17
|
+
...t
|
|
18
|
+
}, j) => {
|
|
19
|
+
const [S, p] = m(t.value ?? null);
|
|
20
|
+
V(() => {
|
|
21
|
+
p(t.value ?? null);
|
|
22
|
+
}, [t.value]);
|
|
23
|
+
const u = (e) => String(typeof e == "string" || typeof e == "number" ? e : e[o]), n = (e) => typeof e == "string" || typeof e == "number" ? e : e[c];
|
|
24
|
+
return /* @__PURE__ */ d.jsx(R, { error: x, label: v, required: y, htmlFor: s, children: /* @__PURE__ */ d.jsx(
|
|
25
|
+
E,
|
|
24
26
|
{
|
|
25
|
-
id:
|
|
27
|
+
id: s,
|
|
26
28
|
displayEmpty: !0,
|
|
27
29
|
fullWidth: !0,
|
|
28
30
|
defaultValue: "",
|
|
29
|
-
ref:
|
|
30
|
-
renderValue:
|
|
31
|
-
|
|
32
|
-
return
|
|
33
|
-
} : (
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
ref: j,
|
|
32
|
+
renderValue: t.multiple ? (e) => e.map((a) => {
|
|
33
|
+
const f = l.find((b) => n(b) === n(a));
|
|
34
|
+
return f ? u(f) : "";
|
|
35
|
+
}).filter(Boolean).join(", ") : (e) => {
|
|
36
|
+
const r = e;
|
|
37
|
+
if (r == null || r === "")
|
|
38
|
+
return /* @__PURE__ */ d.jsx("span", { style: { color: "var(--mui-palette-text-secondary)" }, children: i });
|
|
39
|
+
if (g)
|
|
40
|
+
return u(r);
|
|
41
|
+
const a = l.find((f) => n(f) === n(r));
|
|
42
|
+
return a ? u(a) : "";
|
|
36
43
|
},
|
|
37
|
-
...
|
|
38
|
-
value:
|
|
39
|
-
children:
|
|
40
|
-
|
|
44
|
+
...t,
|
|
45
|
+
value: l.length ? S ?? "" : "",
|
|
46
|
+
children: l == null ? void 0 : l.map((e, r) => /* @__PURE__ */ d.jsx(
|
|
47
|
+
O,
|
|
41
48
|
{
|
|
42
|
-
disabled: (
|
|
43
|
-
value:
|
|
44
|
-
children:
|
|
49
|
+
disabled: (e == null ? void 0 : e.disabled) ?? !1,
|
|
50
|
+
value: n(e),
|
|
51
|
+
children: u(e)
|
|
45
52
|
},
|
|
46
|
-
(
|
|
53
|
+
`${n(e)}-${r}`
|
|
47
54
|
))
|
|
48
55
|
}
|
|
49
56
|
) });
|
|
50
57
|
}
|
|
51
58
|
);
|
|
52
59
|
export {
|
|
53
|
-
|
|
60
|
+
M as default
|
|
54
61
|
};
|