@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.
@@ -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 u } from "../jsx-runtime-OVHDjVDe.js";
2
- import { forwardRef as C, useState as w } from "react";
3
- import { Select as B, MenuItem as E, Box as i } from "@mui/material";
4
- import I from "../s-form/s-form.js";
5
- const W = C(
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: t = [],
8
- optionLabel: x = "name",
9
- optionValue: g = "id",
10
- placeholder: d,
11
- label: h = "",
12
- error: v,
13
- required: j = !1,
14
- variant: O = "outlined",
15
- simple: y = !1,
16
- htmlFor: s,
17
- ...r
18
- }, m) => {
19
- const c = r.value !== void 0, [S, V] = w(r.multiple ? [] : null), b = c ? r.value : S, o = (e) => String(typeof e == "string" || typeof e == "number" ? e : e[x]), l = (e) => typeof e == "string" || typeof e == "number" ? e : e[g];
20
- return /* @__PURE__ */ u.jsx(I, { error: v, label: h, required: j, htmlFor: s, children: /* @__PURE__ */ u.jsx(
21
- B,
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: s,
28
+ id: h,
24
29
  displayEmpty: !0,
25
30
  fullWidth: !0,
26
31
  defaultValue: "",
27
- ref: m,
28
- renderValue: r.multiple ? (e) => {
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__ */ u.jsx(i, { component: "span", sx: { color: "text.secondary" }, children: d }) : n == null ? void 0 : n.map((a) => {
31
- const f = t.find((p) => l(p) === l(a));
32
- return f ? o(f) : "";
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__ */ u.jsx(i, { component: "span", sx: { color: "text.secondary" }, children: d });
38
- if (y)
39
- return o(n);
40
- const a = t.find((f) => l(f) === l(n));
41
- return a ? o(a) : "";
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
- ...r,
44
- value: t.length ? b ?? "" : "",
61
+ ...a,
62
+ value: o.length ? z ?? "" : "",
45
63
  onChange: (e, n) => {
46
- if (r.onChange)
47
- r.onChange(e, n);
48
- else if (!c) {
49
- const a = e.target.value;
50
- V(a);
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: t == null ? void 0 : t.map((e, n) => /* @__PURE__ */ u.jsx(
54
- E,
55
- {
56
- disabled: (e == null ? void 0 : e.disabled) ?? !1,
57
- value: l(e),
58
- children: o(e)
59
- },
60
- `${l(e)}-${n}`
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
- W as default
116
+ J as default
68
117
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org"
5
5
  },
6
- "version": "1.0.131",
6
+ "version": "1.0.133",
7
7
  "description": "advanced ui kit for solostylist",
8
8
  "private": false,
9
9
  "type": "module",