@solostylist/ui-kit 1.0.131 → 1.0.133
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/s-select/s-select.d.ts +5 -0
- package/dist/s-select/s-select.js +97 -48
- package/package.json +1 -1
|
@@ -28,6 +28,10 @@ export type SSelectProps<T extends BaseOption = string> = Omit<SelectProps, 'err
|
|
|
28
28
|
simple?: boolean;
|
|
29
29
|
/** HTML id attribute for the select element */
|
|
30
30
|
htmlFor?: string;
|
|
31
|
+
/** Enable search/filter functionality in the dropdown */
|
|
32
|
+
searchable?: boolean;
|
|
33
|
+
/** Placeholder text for the search input */
|
|
34
|
+
searchPlaceholder?: string;
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* SSelect - A flexible select component that handles both primitive and object options
|
|
@@ -37,6 +41,7 @@ export type SSelectProps<T extends BaseOption = string> = Omit<SelectProps, 'err
|
|
|
37
41
|
* - Generic typing for type-safe option handling
|
|
38
42
|
* - Support for both primitive (string/number) and object options
|
|
39
43
|
* - Configurable option label and value extraction for objects
|
|
44
|
+
* - Optional search/filter functionality for large option lists
|
|
40
45
|
* - Placeholder support with proper styling
|
|
41
46
|
* - Single and multiple selection modes
|
|
42
47
|
* - Simple mode for primitive value rendering
|
|
@@ -1,68 +1,117 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { j as t } from "../jsx-runtime-OVHDjVDe.js";
|
|
2
|
+
import { forwardRef as E, useState as f } from "react";
|
|
3
|
+
import { c as F } from "../createSvgIcon-By5UWB4_.js";
|
|
4
|
+
import { Select as M, ListSubheader as T, TextField as A, InputAdornment as B, MenuItem as p, Box as x } from "@mui/material";
|
|
5
|
+
import D from "../s-form/s-form.js";
|
|
6
|
+
const K = F(/* @__PURE__ */ t.jsx("path", {
|
|
7
|
+
d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"
|
|
8
|
+
}), "Search"), J = E(
|
|
6
9
|
({
|
|
7
|
-
options:
|
|
8
|
-
optionLabel:
|
|
9
|
-
optionValue:
|
|
10
|
-
placeholder:
|
|
11
|
-
label:
|
|
12
|
-
error:
|
|
13
|
-
required:
|
|
14
|
-
variant:
|
|
15
|
-
simple:
|
|
16
|
-
htmlFor:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
options: o = [],
|
|
11
|
+
optionLabel: y = "name",
|
|
12
|
+
optionValue: C = "id",
|
|
13
|
+
placeholder: g,
|
|
14
|
+
label: m = "",
|
|
15
|
+
error: I,
|
|
16
|
+
required: P = !1,
|
|
17
|
+
variant: R = "outlined",
|
|
18
|
+
simple: b = !1,
|
|
19
|
+
htmlFor: h,
|
|
20
|
+
searchable: r = !1,
|
|
21
|
+
searchPlaceholder: w = "",
|
|
22
|
+
...a
|
|
23
|
+
}, V) => {
|
|
24
|
+
const v = a.value !== void 0, [L, k] = f(a.multiple ? [] : null), z = v ? a.value : L, [d, j] = f(""), [O, S] = f(!1), s = (e) => String(typeof e == "string" || typeof e == "number" ? e : e[y]), l = (e) => typeof e == "string" || typeof e == "number" ? e : e[C], c = r && d ? o.filter((e) => s(e).toLowerCase().includes(d.toLowerCase())) : o;
|
|
25
|
+
return /* @__PURE__ */ t.jsx(D, { error: I, label: m, required: P, htmlFor: h, children: /* @__PURE__ */ t.jsxs(
|
|
26
|
+
M,
|
|
22
27
|
{
|
|
23
|
-
id:
|
|
28
|
+
id: h,
|
|
24
29
|
displayEmpty: !0,
|
|
25
30
|
fullWidth: !0,
|
|
26
31
|
defaultValue: "",
|
|
27
|
-
ref:
|
|
28
|
-
|
|
32
|
+
ref: V,
|
|
33
|
+
open: r ? O : void 0,
|
|
34
|
+
onOpen: r ? () => S(!0) : void 0,
|
|
35
|
+
onClose: r ? () => {
|
|
36
|
+
S(!1), j("");
|
|
37
|
+
} : void 0,
|
|
38
|
+
MenuProps: r ? {
|
|
39
|
+
autoFocus: !1,
|
|
40
|
+
PaperProps: {
|
|
41
|
+
onKeyDown: (e) => {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} : void 0,
|
|
46
|
+
renderValue: a.multiple ? (e) => {
|
|
29
47
|
const n = e;
|
|
30
|
-
return n.length === 0 ? /* @__PURE__ */
|
|
31
|
-
const
|
|
32
|
-
return
|
|
48
|
+
return n.length === 0 ? /* @__PURE__ */ t.jsx(x, { component: "span", sx: { color: "text.secondary" }, children: g }) : n == null ? void 0 : n.map((u) => {
|
|
49
|
+
const i = o.find(($) => l($) === l(u));
|
|
50
|
+
return i ? s(i) : "";
|
|
33
51
|
}).filter(Boolean).join(", ");
|
|
34
52
|
} : (e) => {
|
|
35
53
|
const n = e;
|
|
36
54
|
if (n == null || n === "")
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
if (
|
|
39
|
-
return
|
|
40
|
-
const
|
|
41
|
-
return
|
|
55
|
+
return /* @__PURE__ */ t.jsx(x, { component: "span", sx: { color: "text.secondary" }, children: g });
|
|
56
|
+
if (b)
|
|
57
|
+
return s(n);
|
|
58
|
+
const u = o.find((i) => l(i) === l(n));
|
|
59
|
+
return u ? s(u) : "";
|
|
42
60
|
},
|
|
43
|
-
...
|
|
44
|
-
value:
|
|
61
|
+
...a,
|
|
62
|
+
value: o.length ? z ?? "" : "",
|
|
45
63
|
onChange: (e, n) => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
else if (!
|
|
49
|
-
const
|
|
50
|
-
|
|
64
|
+
if (a.onChange)
|
|
65
|
+
a.onChange(e, n);
|
|
66
|
+
else if (!v) {
|
|
67
|
+
const u = e.target.value;
|
|
68
|
+
k(u);
|
|
51
69
|
}
|
|
52
70
|
},
|
|
53
|
-
children:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
children: [
|
|
72
|
+
r && /* @__PURE__ */ t.jsx(T, { sx: { px: 2, py: 1, position: "sticky", top: 0, bgcolor: "background.paper", zIndex: 1 }, children: /* @__PURE__ */ t.jsx(
|
|
73
|
+
A,
|
|
74
|
+
{
|
|
75
|
+
size: "small",
|
|
76
|
+
fullWidth: !0,
|
|
77
|
+
autoFocus: !0,
|
|
78
|
+
placeholder: w,
|
|
79
|
+
value: d,
|
|
80
|
+
onChange: (e) => j(e.target.value),
|
|
81
|
+
onKeyDown: (e) => {
|
|
82
|
+
e.key !== "Escape" && e.stopPropagation();
|
|
83
|
+
},
|
|
84
|
+
onClick: (e) => {
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
},
|
|
87
|
+
InputProps: {
|
|
88
|
+
startAdornment: /* @__PURE__ */ t.jsx(B, { position: "start", children: /* @__PURE__ */ t.jsx(K, { fontSize: "small" }) })
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
) }),
|
|
92
|
+
(c == null ? void 0 : c.length) > 0 ? c.map((e, n) => /* @__PURE__ */ t.jsx(
|
|
93
|
+
p,
|
|
94
|
+
{
|
|
95
|
+
disabled: (e == null ? void 0 : e.disabled) ?? !1,
|
|
96
|
+
value: l(e),
|
|
97
|
+
children: s(e)
|
|
98
|
+
},
|
|
99
|
+
`${l(e)}-${n}`
|
|
100
|
+
)) : r && d && /* @__PURE__ */ t.jsx(p, { disabled: !0, children: /* @__PURE__ */ t.jsx(x, { sx: { color: "text.secondary", fontStyle: "italic" }, children: "No results found" }) }),
|
|
101
|
+
!r && (o == null ? void 0 : o.map((e, n) => /* @__PURE__ */ t.jsx(
|
|
102
|
+
p,
|
|
103
|
+
{
|
|
104
|
+
disabled: (e == null ? void 0 : e.disabled) ?? !1,
|
|
105
|
+
value: l(e),
|
|
106
|
+
children: s(e)
|
|
107
|
+
},
|
|
108
|
+
`${l(e)}-${n}`
|
|
109
|
+
)))
|
|
110
|
+
]
|
|
62
111
|
}
|
|
63
112
|
) });
|
|
64
113
|
}
|
|
65
114
|
);
|
|
66
115
|
export {
|
|
67
|
-
|
|
116
|
+
J as default
|
|
68
117
|
};
|