@solostylist/ui-kit 1.0.196 → 1.0.197

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,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  import { SelectProps } from '@mui/material';
2
3
  /** Base type constraint for select options - can be primitives or objects */
3
4
  type BaseOption = string | number | Record<string, unknown>;
@@ -29,6 +30,8 @@ export type SSelectProps<T extends BaseOption = string> = Omit<SelectProps, 'err
29
30
  searchable?: boolean;
30
31
  /** Placeholder text for the search input */
31
32
  searchPlaceholder?: string;
33
+ /** Custom render function for options */
34
+ renderOption?: (option: T) => ReactNode;
32
35
  };
33
36
  /**
34
37
  * A flexible select component that handles both primitive and object options with form integration.
@@ -1,40 +1,41 @@
1
1
  import { j as t } from "../jsx-runtime-tc70JA_2.js";
2
- import { forwardRef as A, useState as f } from "react";
3
- import { c as E } from "../createSvgIcon-DTNHY3_v.js";
4
- import { Select as F, ListSubheader as M, TextField as T, InputAdornment as B, MenuItem as c, Box as p } from "@mui/material";
5
- import { SForm as D } from "../s-form/s-form.js";
6
- const K = E(/* @__PURE__ */ t.jsx("path", {
2
+ import { forwardRef as F, useState as p } from "react";
3
+ import { c as M } from "../createSvgIcon-DTNHY3_v.js";
4
+ import { Select as T, ListSubheader as B, TextField as D, InputAdornment as K, MenuItem as f, Box as x } from "@mui/material";
5
+ import { SForm as N } from "../s-form/s-form.js";
6
+ const R = M(/* @__PURE__ */ t.jsx("path", {
7
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"), N = A(
8
+ }), "Search"), W = F(
9
9
  ({
10
- options: r = [],
11
- optionLabel: m = "name",
12
- optionValue: y = "id",
13
- placeholder: x,
14
- label: C = "",
15
- error: b,
16
- required: I = !1,
17
- simple: w = !1,
18
- htmlFor: g,
19
- searchable: l = !1,
20
- searchPlaceholder: P = "",
10
+ options: o = [],
11
+ optionLabel: y = "name",
12
+ optionValue: C = "id",
13
+ placeholder: g,
14
+ label: b = "",
15
+ error: I,
16
+ required: w = !1,
17
+ simple: P = !1,
18
+ htmlFor: v,
19
+ searchable: r = !1,
20
+ searchPlaceholder: V = "",
21
+ renderOption: u,
21
22
  ...s
22
- }, O) => {
23
- const v = s.value !== void 0, [V, $] = f(s.multiple ? [] : null), L = v ? s.value : V, [u, h] = f(""), [k, j] = f(!1), a = (e) => String(typeof e == "string" || typeof e == "number" ? e : e[m]), o = (e) => typeof e == "string" || typeof e == "number" ? e : e[y], S = l && u ? r.filter((e) => a(e).toLowerCase().includes(u.toLowerCase())) : r;
24
- return /* @__PURE__ */ t.jsx(D, { error: b, label: C, required: I, htmlFor: g, children: /* @__PURE__ */ t.jsxs(
25
- F,
23
+ }, $) => {
24
+ const h = s.value !== void 0, [L, k] = p(s.multiple ? [] : null), z = h ? s.value : L, [i, j] = p(""), [A, S] = p(!1), a = (e) => String(typeof e == "string" || typeof e == "number" ? e : e[y]), l = (e) => typeof e == "string" || typeof e == "number" ? e : e[C], m = r && i ? o.filter((e) => a(e).toLowerCase().includes(i.toLowerCase())) : o;
25
+ return /* @__PURE__ */ t.jsx(N, { error: I, label: b, required: w, htmlFor: v, children: /* @__PURE__ */ t.jsxs(
26
+ T,
26
27
  {
27
- id: g,
28
+ id: v,
28
29
  displayEmpty: !0,
29
30
  fullWidth: !0,
30
31
  defaultValue: "",
31
- ref: O,
32
- open: l ? k : void 0,
33
- onOpen: l ? () => j(!0) : void 0,
34
- onClose: l ? () => {
35
- j(!1), h("");
32
+ ref: $,
33
+ open: r ? A : void 0,
34
+ onOpen: r ? () => S(!0) : void 0,
35
+ onClose: r ? () => {
36
+ S(!1), j("");
36
37
  } : void 0,
37
- MenuProps: l ? {
38
+ MenuProps: r ? {
38
39
  autoFocus: !1,
39
40
  PaperProps: {
40
41
  onKeyDown: (e) => {
@@ -44,38 +45,38 @@ const K = E(/* @__PURE__ */ t.jsx("path", {
44
45
  } : void 0,
45
46
  renderValue: s.multiple ? (e) => {
46
47
  const n = e;
47
- return n.length === 0 ? /* @__PURE__ */ t.jsx(p, { component: "span", sx: { color: "divider" }, children: x }) : n?.map((i) => {
48
- const d = r.find((z) => o(z) === o(i));
49
- return d ? a(d) : "";
48
+ return n.length === 0 ? /* @__PURE__ */ t.jsx(x, { component: "span", sx: { color: "divider" }, children: g }) : n?.map((d) => {
49
+ const c = o.find((E) => l(E) === l(d));
50
+ return c ? a(c) : "";
50
51
  }).filter(Boolean).join(", ");
51
52
  } : (e) => {
52
53
  const n = e;
53
54
  if (n == null || n === "")
54
- return /* @__PURE__ */ t.jsx(p, { component: "span", sx: { color: "divider" }, children: x });
55
- if (w)
55
+ return /* @__PURE__ */ t.jsx(x, { component: "span", sx: { color: "divider" }, children: g });
56
+ if (P)
56
57
  return a(n);
57
- const i = r.find((d) => o(d) === o(n));
58
- return i ? a(i) : "";
58
+ const d = o.find((c) => l(c) === l(n));
59
+ return d ? a(d) : "";
59
60
  },
60
61
  ...s,
61
- value: r.length ? L ?? "" : "",
62
+ value: o.length ? z ?? "" : "",
62
63
  onChange: (e, n) => {
63
64
  if (s.onChange)
64
65
  s.onChange(e, n);
65
- else if (!v) {
66
- const i = e.target.value;
67
- $(i);
66
+ else if (!h) {
67
+ const d = e.target.value;
68
+ k(d);
68
69
  }
69
70
  },
70
71
  children: [
71
- l && /* @__PURE__ */ t.jsx(M, { sx: { px: 2, py: 1, position: "sticky", top: 0, bgcolor: "background.paper", zIndex: 1 }, children: /* @__PURE__ */ t.jsx(
72
- T,
72
+ r && /* @__PURE__ */ t.jsx(B, { sx: { px: 2, py: 1, position: "sticky", top: 0, bgcolor: "background.paper", zIndex: 1 }, children: /* @__PURE__ */ t.jsx(
73
+ D,
73
74
  {
74
75
  fullWidth: !0,
75
76
  autoFocus: !0,
76
- placeholder: P,
77
- value: u,
78
- onChange: (e) => h(e.target.value),
77
+ placeholder: V,
78
+ value: i,
79
+ onChange: (e) => j(e.target.value),
79
80
  onKeyDown: (e) => {
80
81
  e.key !== "Escape" && e.stopPropagation();
81
82
  },
@@ -83,42 +84,42 @@ const K = E(/* @__PURE__ */ t.jsx("path", {
83
84
  e.stopPropagation();
84
85
  },
85
86
  InputProps: {
86
- startAdornment: /* @__PURE__ */ t.jsx(B, { position: "start", children: /* @__PURE__ */ t.jsx(K, { fontSize: "small" }) })
87
+ startAdornment: /* @__PURE__ */ t.jsx(K, { position: "start", children: /* @__PURE__ */ t.jsx(R, { fontSize: "small" }) })
87
88
  }
88
89
  }
89
90
  ) }),
90
- l ? S?.length > 0 ? S.map((e, n) => /* @__PURE__ */ t.jsx(
91
- c,
91
+ r ? m?.length > 0 ? m.map((e, n) => /* @__PURE__ */ t.jsx(
92
+ f,
92
93
  {
93
94
  disabled: e?.disabled ?? !1,
94
- value: o(e),
95
- children: a(e)
95
+ value: l(e),
96
+ children: u ? u(e) : a(e)
96
97
  },
97
- `${o(e)}-${n}`
98
- )) : u ? /* @__PURE__ */ t.jsx(c, { disabled: !0, children: /* @__PURE__ */ t.jsx(p, { sx: { color: "text.secondary", textAlign: "center", width: "100%" }, children: "No results found" }) }) : r?.map((e, n) => /* @__PURE__ */ t.jsx(
99
- c,
98
+ `${l(e)}-${n}`
99
+ )) : i ? /* @__PURE__ */ t.jsx(f, { disabled: !0, children: /* @__PURE__ */ t.jsx(x, { sx: { color: "text.secondary", textAlign: "center", width: "100%" }, children: "No results found" }) }) : o?.map((e, n) => /* @__PURE__ */ t.jsx(
100
+ f,
100
101
  {
101
102
  disabled: e?.disabled ?? !1,
102
- value: o(e),
103
- children: a(e)
103
+ value: l(e),
104
+ children: u ? u(e) : a(e)
104
105
  },
105
- `${o(e)}-${n}`
106
- )) : r?.map((e, n) => /* @__PURE__ */ t.jsx(
107
- c,
106
+ `${l(e)}-${n}`
107
+ )) : o?.map((e, n) => /* @__PURE__ */ t.jsx(
108
+ f,
108
109
  {
109
110
  disabled: e?.disabled ?? !1,
110
- value: o(e),
111
- children: a(e)
111
+ value: l(e),
112
+ children: u ? u(e) : a(e)
112
113
  },
113
- `${o(e)}-${n}`
114
+ `${l(e)}-${n}`
114
115
  ))
115
116
  ]
116
117
  }
117
118
  ) });
118
119
  }
119
120
  );
120
- N.displayName = "SSelect";
121
+ W.displayName = "SSelect";
121
122
  export {
122
- N as SSelect,
123
- N as default
123
+ W as SSelect,
124
+ W as default
124
125
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org"
5
5
  },
6
- "version": "1.0.196",
6
+ "version": "1.0.197",
7
7
  "description": "advanced ui kit for solostylist",
8
8
  "type": "module",
9
9
  "main": "dist/main.js",