@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 | any, Multiple, DisableClearable, FreeSolo>, 'renderInput'> {
4
- renderInput?: AutocompleteProps<T | string, Multiple, DisableClearable, FreeSolo>['renderInput'];
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 SSelectProps = Omit<SelectProps, 'error' | 'variant'> & {
3
- options?: any[];
4
- optionLabel?: string;
5
- optionValue?: any;
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, "ref"> & import('react').RefAttributes<unknown>>;
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 n } from "../jsx-runtime-C5mzlN2N.js";
2
- import { forwardRef as E, useState as R, useEffect as g } from "react";
3
- import { Select as w, MenuItem as I } from "@mui/material";
4
- import M from "../s-form/s-form.js";
5
- const z = E(
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: e = [],
8
- optionLabel: t = "name",
9
- optionValue: f = "id",
10
- placeholder: s,
11
- label: x = "",
12
- error: j,
13
- required: h = !1,
14
- variant: W = "outlined",
15
- simple: a = !1,
16
- htmlFor: c,
17
- ...u
18
- }, y) => {
19
- const [S, m] = R(u.value ?? null);
20
- return g(() => {
21
- m(u.value ?? null);
22
- }, [u.value]), /* @__PURE__ */ n.jsx(M, { error: j, label: x, required: h, htmlFor: c, children: /* @__PURE__ */ n.jsx(
23
- w,
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: c,
27
+ id: s,
26
28
  displayEmpty: !0,
27
29
  fullWidth: !0,
28
30
  defaultValue: "",
29
- ref: y,
30
- renderValue: u.multiple ? (r) => {
31
- var d;
32
- return (d = e.filter((l) => r == null ? void 0 : r.includes(l[f]))) == null ? void 0 : d.map((l) => l[t]).join(", ");
33
- } : (r) => {
34
- var d;
35
- return r !== null && typeof r < "u" && r !== "" ? a ? e.find((l) => l == r) : (d = e.find((l) => l[f] == r)) == null ? void 0 : d[t] : /* @__PURE__ */ n.jsx("span", { style: { color: "var(--mui-palette-text-secondary)" }, children: s });
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
- ...u,
38
- value: e.length ? S ?? "" : "",
39
- children: e == null ? void 0 : e.map((r, d) => /* @__PURE__ */ n.jsx(
40
- I,
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: (r == null ? void 0 : r.disabled) ?? !1,
43
- value: a ? r : r[f],
44
- children: a ? r : r[t]
49
+ disabled: (e == null ? void 0 : e.disabled) ?? !1,
50
+ value: n(e),
51
+ children: u(e)
45
52
  },
46
- (a ? r : r[f]) + d
53
+ `${n(e)}-${r}`
47
54
  ))
48
55
  }
49
56
  ) });
50
57
  }
51
58
  );
52
59
  export {
53
- z as default
60
+ M as default
54
61
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://registry.npmjs.org"
5
5
  },
6
- "version": "1.0.13",
6
+ "version": "1.0.14",
7
7
  "description": "advanced ui kit for solostylist",
8
8
  "private": false,
9
9
  "type": "module",