anysystem-design 0.0.26 → 0.0.27

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.
@@ -14,6 +14,7 @@ export type AutoCompleteBaseProps<ListOption extends SelectOption> = {
14
14
  className?: string;
15
15
  placeholder?: string;
16
16
  onChange?: (value: string | number) => void;
17
+ onSearch?: (query: string) => void;
17
18
  valueField?: ValueField<ListOption>;
18
19
  };
19
20
  declare const _default: <ListOption extends SelectOption>(props: AutoCompleteBaseProps<ListOption> & {
@@ -1,68 +1,71 @@
1
- import { jsx as a, jsxs as f } from "react/jsx-runtime";
2
- import c, { Fragment as p } from "react";
3
- import { t as y } from "../../bundle-mjs-SHnj3fHy.js";
4
- import { H as b } from "../../index-BVp57yIc.js";
5
- import { c as x } from "../../index-CBEJ8A3p.js";
6
- import { getValue as u } from "../Selectbox/helper.js";
7
- import { N as w, G as C, H as E, z as N, K as L } from "../../combobox-DcjIgW1K.js";
1
+ import { jsx as a, jsxs as p } from "react/jsx-runtime";
2
+ import c, { Fragment as y } from "react";
3
+ import { t as h } from "../../bundle-mjs-SHnj3fHy.js";
4
+ import { H as x } from "../../index-BVp57yIc.js";
5
+ import { c as w } from "../../index-CBEJ8A3p.js";
6
+ import { getValue as n } from "../Selectbox/helper.js";
7
+ import { N as C, G as E, H as N, z as L, K as H } from "../../combobox-DcjIgW1K.js";
8
8
  import { X as S } from "../../transition-6o20faRl.js";
9
- const H = (t, r) => r.type === "SEARCH" ? {
9
+ const A = (t, r) => r.type === "SEARCH" ? {
10
10
  ...t,
11
11
  query: r.query,
12
12
  filterList: t.list.filter((l) => l.label.toLowerCase().includes(r.query.toLowerCase()))
13
13
  } : r.type === "SETVALUE" ? {
14
14
  ...t,
15
15
  value: r.value,
16
- selected: t.list.find((l) => u(l, t.valueField) === r.value) || null
16
+ selected: t.list.find((l) => n(l, t.valueField) === r.value) || null
17
17
  } : r.type === "SETSELECT" ? {
18
18
  ...t,
19
19
  selected: r.selected,
20
- value: u(r.selected, t.valueField) + ""
21
- } : t, A = ({
20
+ value: n(r.selected, t.valueField) + ""
21
+ } : t, T = ({
22
22
  id: t,
23
23
  name: r,
24
24
  options: l,
25
25
  value: i = "",
26
26
  valueField: o = "value",
27
27
  onChange: d,
28
- placeholder: h
29
- }, v) => {
30
- const [m, s] = c.useReducer(H, {
28
+ onSearch: f,
29
+ placeholder: v
30
+ }, g) => {
31
+ const [m, s] = c.useReducer(A, {
31
32
  list: l,
32
33
  query: "",
33
34
  filterList: l,
34
35
  value: i,
35
36
  valueField: o,
36
37
  selected: l.find((e) => {
37
- const n = u(e, o);
38
- return i ? n === i : !1;
38
+ const u = n(e, o);
39
+ return i ? u === i : !1;
39
40
  }) || null
40
41
  });
41
- return c.useImperativeHandle(v, () => ({
42
+ return c.useImperativeHandle(g, () => ({
42
43
  search: (e) => s({ type: "SEARCH", query: e }),
43
44
  setValue: (e) => s({ type: "SETVALUE", value: e })
44
45
  })), /* @__PURE__ */ a(
45
- w,
46
+ C,
46
47
  {
47
48
  value: m.selected,
48
49
  onChange: (e) => {
49
50
  s({
50
51
  type: "SETSELECT",
51
52
  selected: e
52
- }), d && d(e ? u(e, o) : "");
53
+ }), d && d(e ? n(e, o) : "");
53
54
  },
54
- children: /* @__PURE__ */ f("div", { className: "relative", children: [
55
+ children: /* @__PURE__ */ p("div", { className: "relative", children: [
55
56
  /* @__PURE__ */ a(
56
- C,
57
+ E,
57
58
  {
58
- placeholder: h,
59
- onChange: (e) => s({ type: "SEARCH", query: e.target.value }),
59
+ placeholder: v,
60
+ onChange: (e) => {
61
+ s({ type: "SEARCH", query: e.target.value }), f && f(e.target.value);
62
+ },
60
63
  autoComplete: "off",
61
64
  displayValue: (e) => (e == null ? void 0 : e.label) || ""
62
65
  }
63
66
  ),
64
- /* @__PURE__ */ a(E, { className: "absolute inset-y-0 right-0 flex items-center pr-2", children: /* @__PURE__ */ a(
65
- b,
67
+ /* @__PURE__ */ a(N, { className: "absolute inset-y-0 right-0 flex items-center pr-2", children: /* @__PURE__ */ a(
68
+ x,
66
69
  {
67
70
  className: "h-5 w-5 text-gray-400",
68
71
  "aria-hidden": "true"
@@ -82,7 +85,7 @@ const H = (t, r) => r.type === "SEARCH" ? {
82
85
  /* @__PURE__ */ a(
83
86
  S,
84
87
  {
85
- as: p,
88
+ as: y,
86
89
  enter: "transition duration-100 ease-out",
87
90
  enterFrom: "scale-95 transform opacity-0",
88
91
  enterTo: "scale-100 transform opacity-100",
@@ -90,23 +93,23 @@ const H = (t, r) => r.type === "SEARCH" ? {
90
93
  leaveFrom: "scale-100 transform opacity-100",
91
94
  leaveTo: "scale-95 transform opacity-0",
92
95
  afterLeave: () => s({ type: "SEARCH", query: "" }),
93
- children: /* @__PURE__ */ a(N, { className: "absolute z-50 mt-5 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none dark:bg-gray-900 sm:text-sm", children: m.filterList.map((e) => /* @__PURE__ */ a(L, { as: p, value: e, children: ({ selected: n, focus: g }) => /* @__PURE__ */ f(
96
+ children: /* @__PURE__ */ a(L, { className: "absolute z-50 mt-5 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none dark:bg-gray-900 sm:text-sm", children: m.filterList.map((e) => /* @__PURE__ */ a(H, { as: y, value: e, children: ({ selected: u, focus: b }) => /* @__PURE__ */ p(
94
97
  "li",
95
98
  {
96
- className: y(
99
+ className: h(
97
100
  "relative flex cursor-pointer justify-between px-5 py-4 text-black hover:bg-primary-100 dark:text-white",
98
- (n || g) && "bg-primary-100 dark:bg-gray-700",
101
+ (u || b) && "bg-primary-100 dark:bg-gray-700",
99
102
  e.enable === !1 && "cursor-not-allowed opacity-50"
100
103
  ),
101
104
  children: [
102
105
  /* @__PURE__ */ a("span", { className: "pl-5", children: e.label }),
103
- n ? /* @__PURE__ */ a(
106
+ u ? /* @__PURE__ */ a(
104
107
  "span",
105
108
  {
106
- className: y(
109
+ className: h(
107
110
  "absolute inset-y-0 left-0 flex items-center pl-3 text-primary-600"
108
111
  ),
109
- children: /* @__PURE__ */ a(x, { className: "h-5 w-5", "aria-hidden": "true" })
112
+ children: /* @__PURE__ */ a(w, { className: "h-5 w-5", "aria-hidden": "true" })
110
113
  }
111
114
  ) : null
112
115
  ]
@@ -117,7 +120,7 @@ const H = (t, r) => r.type === "SEARCH" ? {
117
120
  ] })
118
121
  }
119
122
  );
120
- }, U = c.forwardRef(A);
123
+ }, B = c.forwardRef(T);
121
124
  export {
122
- U as default
125
+ B as default
123
126
  };
@@ -14,6 +14,7 @@ export type AutoCompleteMultipleProps<ListOption extends SelectOption> = {
14
14
  className?: string;
15
15
  placeholder?: string;
16
16
  onChange?: (value: string[] | number[]) => void;
17
+ onSearch?: (query: string) => void;
17
18
  valueField?: ValueField<ListOption>;
18
19
  };
19
20
  declare const _default: <ListOption extends SelectOption>(props: AutoCompleteMultipleProps<ListOption> & {
@@ -1,14 +1,14 @@
1
1
  import { jsx as l, jsxs as m } from "react/jsx-runtime";
2
- import p, { Fragment as h } from "react";
3
- import { _ as x } from "../../lodash-XYp3qmxI.js";
4
- import { t as v } from "../../bundle-mjs-SHnj3fHy.js";
5
- import { H as b } from "../../index-BVp57yIc.js";
6
- import { c as C } from "../../index-CBEJ8A3p.js";
7
- import { d as w } from "../../index-DUypCuzD.js";
2
+ import p, { Fragment as v } from "react";
3
+ import { _ as b } from "../../lodash-XYp3qmxI.js";
4
+ import { t as E } from "../../bundle-mjs-SHnj3fHy.js";
5
+ import { H as C } from "../../index-BVp57yIc.js";
6
+ import { c as w } from "../../index-CBEJ8A3p.js";
7
+ import { d as N } from "../../index-DUypCuzD.js";
8
8
  import { getValue as o } from "../Selectbox/helper.js";
9
- import { N, G as S, H as L, z as T, K as q } from "../../combobox-DcjIgW1K.js";
10
- import { X as A } from "../../transition-6o20faRl.js";
11
- const R = (r, t) => {
9
+ import { N as L, G as S, H as T, z as q, K as A } from "../../combobox-DcjIgW1K.js";
10
+ import { X as R } from "../../transition-6o20faRl.js";
11
+ const k = (r, t) => {
12
12
  if (t.type === "SEARCH")
13
13
  return {
14
14
  ...r,
@@ -41,17 +41,18 @@ const R = (r, t) => {
41
41
  };
42
42
  }
43
43
  return r;
44
- }, k = ({
44
+ }, H = ({
45
45
  id: r,
46
46
  name: t,
47
47
  value: a = [],
48
48
  options: u,
49
49
  valueField: n = "value",
50
50
  onChange: f,
51
- placeholder: E
52
- }, g) => {
53
- var y;
54
- const [s, c] = p.useReducer(R, {
51
+ onSearch: y,
52
+ placeholder: g
53
+ }, x) => {
54
+ var h;
55
+ const [s, c] = p.useReducer(k, {
55
56
  query: "",
56
57
  list: u,
57
58
  filterList: u,
@@ -59,10 +60,10 @@ const R = (r, t) => {
59
60
  valueField: n,
60
61
  selected: u.filter((e) => {
61
62
  const i = o(e, n);
62
- return x.some(a, (d) => d + "" == i + "");
63
+ return b.some(a, (d) => d + "" == i + "");
63
64
  }) || []
64
65
  });
65
- return p.useImperativeHandle(g, () => ({
66
+ return p.useImperativeHandle(x, () => ({
66
67
  search: (e) => {
67
68
  c({ type: "SEARCH", query: e });
68
69
  },
@@ -70,7 +71,7 @@ const R = (r, t) => {
70
71
  c({ type: "SETVALUE", value: e });
71
72
  }
72
73
  })), /* @__PURE__ */ l(
73
- N,
74
+ L,
74
75
  {
75
76
  value: s.selected,
76
77
  onChange: (e) => {
@@ -83,22 +84,24 @@ const R = (r, t) => {
83
84
  },
84
85
  multiple: !0,
85
86
  children: /* @__PURE__ */ m("div", { className: "relative flex gap-1", children: [
86
- s.selected.length > 0 && /* @__PURE__ */ l("ul", { className: "form-control flex gap-1", children: (y = s.selected) == null ? void 0 : y.map((e, i) => /* @__PURE__ */ l("li", { children: /* @__PURE__ */ m("div", { className: "flex rounded bg-indigo-50 p-1", children: [
87
+ s.selected.length > 0 && /* @__PURE__ */ l("ul", { className: "form-control flex gap-1", children: (h = s.selected) == null ? void 0 : h.map((e, i) => /* @__PURE__ */ l("li", { children: /* @__PURE__ */ m("div", { className: "flex rounded bg-indigo-50 p-1", children: [
87
88
  /* @__PURE__ */ l("span", { className: "whitespace-nowrap text-xs", children: e.label }),
88
89
  /* @__PURE__ */ l(
89
90
  "button",
90
91
  {
91
92
  onClick: () => c({ type: "REMOVESELECT", selected: e }),
92
- children: /* @__PURE__ */ l(w, { fontSize: 12, className: "font-bold" })
93
+ children: /* @__PURE__ */ l(N, { fontSize: 12, className: "font-bold" })
93
94
  }
94
95
  )
95
96
  ] }) }, i)) }),
96
97
  /* @__PURE__ */ l(
97
98
  S,
98
99
  {
99
- placeholder: E,
100
+ placeholder: g,
100
101
  value: s.query,
101
- onChange: (e) => c({ type: "SEARCH", query: e.target.value }),
102
+ onChange: (e) => {
103
+ c({ type: "SEARCH", query: e.target.value }), y && y(e.target.value);
104
+ },
102
105
  onKeyDown: (e) => {
103
106
  e.key === "Backspace" && s.query === "" && s.selected.length > 0 && c({
104
107
  type: "REMOVESELECT",
@@ -108,8 +111,8 @@ const R = (r, t) => {
108
111
  autoComplete: "off"
109
112
  }
110
113
  ),
111
- /* @__PURE__ */ l(L, { className: "absolute inset-y-0 right-0 flex items-center pr-2", children: /* @__PURE__ */ l(
112
- b,
114
+ /* @__PURE__ */ l(T, { className: "absolute inset-y-0 right-0 flex items-center pr-2", children: /* @__PURE__ */ l(
115
+ C,
113
116
  {
114
117
  className: "h-5 w-5 text-gray-400",
115
118
  "aria-hidden": "true"
@@ -127,9 +130,9 @@ const R = (r, t) => {
127
130
  }
128
131
  ),
129
132
  /* @__PURE__ */ l(
130
- A,
133
+ R,
131
134
  {
132
- as: h,
135
+ as: v,
133
136
  enter: "transition duration-100 ease-out",
134
137
  enterFrom: "scale-95 transform opacity-0",
135
138
  enterTo: "scale-100 transform opacity-100",
@@ -137,10 +140,10 @@ const R = (r, t) => {
137
140
  leaveFrom: "scale-100 transform opacity-100",
138
141
  leaveTo: "scale-95 transform opacity-0",
139
142
  afterLeave: () => c({ type: "SEARCH", query: "" }),
140
- children: /* @__PURE__ */ l(T, { className: "absolute mt-10 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none dark:bg-gray-900 sm:text-sm", children: s.filterList.map((e) => /* @__PURE__ */ l(q, { as: h, value: e, children: ({ selected: i, focus: d }) => /* @__PURE__ */ m(
143
+ children: /* @__PURE__ */ l(q, { className: "absolute mt-10 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black/5 focus:outline-none dark:bg-gray-900 sm:text-sm", children: s.filterList.map((e) => /* @__PURE__ */ l(A, { as: v, value: e, children: ({ selected: i, focus: d }) => /* @__PURE__ */ m(
141
144
  "li",
142
145
  {
143
- className: v(
146
+ className: E(
144
147
  "relative flex cursor-pointer justify-between px-5 py-4 text-black hover:bg-primary-100 dark:text-white",
145
148
  (i || d) && "bg-primary-100 dark:bg-gray-700",
146
149
  e.enable === !1 && "cursor-not-allowed opacity-50"
@@ -150,10 +153,10 @@ const R = (r, t) => {
150
153
  i ? /* @__PURE__ */ l(
151
154
  "span",
152
155
  {
153
- className: v(
156
+ className: E(
154
157
  "absolute inset-y-0 left-0 flex items-center pl-3 text-primary-600"
155
158
  ),
156
- children: /* @__PURE__ */ l(C, { className: "h-5 w-5", "aria-hidden": "true" })
159
+ children: /* @__PURE__ */ l(w, { className: "h-5 w-5", "aria-hidden": "true" })
157
160
  }
158
161
  ) : null
159
162
  ]
@@ -164,7 +167,7 @@ const R = (r, t) => {
164
167
  ] })
165
168
  }
166
169
  );
167
- }, D = p.forwardRef(k);
170
+ }, G = p.forwardRef(H);
168
171
  export {
169
- D as default
172
+ G as default
170
173
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anysystem-design",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",