@addsign/moje-agenda-shared-lib 0.0.9 → 0.0.11
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/components/Button.js +1 -1
- package/dist/components/form/AutocompleteSearchBar.d.ts +21 -0
- package/dist/components/form/AutocompleteSearchBar.js +306 -0
- package/dist/components/form/FormField.d.ts +25 -0
- package/dist/components/form/FormField.js +248 -0
- package/dist/index-CvL09ndn.js +128 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +8 -4
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IOptionItem } from '../../main';
|
|
2
|
+
|
|
3
|
+
declare const AutocompleteSearchBar: React.FC<{
|
|
4
|
+
label: string;
|
|
5
|
+
name: string;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
fetchUrl?: string;
|
|
10
|
+
valueKey: string;
|
|
11
|
+
labelKey: string;
|
|
12
|
+
onChange: (value: any) => void;
|
|
13
|
+
onFocus: () => void;
|
|
14
|
+
onBlur: () => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
serverSearch?: boolean;
|
|
17
|
+
value?: string;
|
|
18
|
+
initOptions?: IOptionItem[];
|
|
19
|
+
showId?: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export default AutocompleteSearchBar;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { jsxs as C, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as B, useEffect as p, useState as m } from "react";
|
|
3
|
+
import { useFederationContext as K } from "../../contexts/FederationContext.js";
|
|
4
|
+
import { a as _, b as ee, M as te } from "../../index-CvL09ndn.js";
|
|
5
|
+
function re(e) {
|
|
6
|
+
for (var t = [], r = 1; r < arguments.length; r++)
|
|
7
|
+
t[r - 1] = arguments[r];
|
|
8
|
+
e && e.addEventListener && e.addEventListener.apply(e, t);
|
|
9
|
+
}
|
|
10
|
+
function ae(e) {
|
|
11
|
+
for (var t = [], r = 1; r < arguments.length; r++)
|
|
12
|
+
t[r - 1] = arguments[r];
|
|
13
|
+
e && e.removeEventListener && e.removeEventListener.apply(e, t);
|
|
14
|
+
}
|
|
15
|
+
var le = ["mousedown", "touchstart"], se = function(e, t, r) {
|
|
16
|
+
r === void 0 && (r = le);
|
|
17
|
+
var d = B(t);
|
|
18
|
+
p(function() {
|
|
19
|
+
d.current = t;
|
|
20
|
+
}, [t]), p(function() {
|
|
21
|
+
for (var o = function(u) {
|
|
22
|
+
var c = e.current;
|
|
23
|
+
c && !c.contains(u.target) && d.current(u);
|
|
24
|
+
}, a = 0, f = r; a < f.length; a++) {
|
|
25
|
+
var h = f[a];
|
|
26
|
+
re(document, h, o);
|
|
27
|
+
}
|
|
28
|
+
return function() {
|
|
29
|
+
for (var u = 0, c = r; u < c.length; u++) {
|
|
30
|
+
var N = c[u];
|
|
31
|
+
ae(document, N, o);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}, [r, e]);
|
|
35
|
+
};
|
|
36
|
+
const de = ({
|
|
37
|
+
label: e,
|
|
38
|
+
name: t,
|
|
39
|
+
required: r,
|
|
40
|
+
disabled: d,
|
|
41
|
+
description: o,
|
|
42
|
+
fetchUrl: a,
|
|
43
|
+
valueKey: f,
|
|
44
|
+
labelKey: h,
|
|
45
|
+
onChange: u,
|
|
46
|
+
onFocus: c,
|
|
47
|
+
onBlur: N,
|
|
48
|
+
placeholder: A,
|
|
49
|
+
serverSearch: v = !1,
|
|
50
|
+
value: $,
|
|
51
|
+
initOptions: F,
|
|
52
|
+
showId: L
|
|
53
|
+
}) => {
|
|
54
|
+
var j, V;
|
|
55
|
+
const [k, w] = m(""), [J, E] = m(!1), [x, R] = m([]), [M, b] = m(-1), [P, O] = m(
|
|
56
|
+
null
|
|
57
|
+
), [g, y] = m([]), X = B(null), D = B(null), q = K(), [Q, z] = m(!1), [H] = m({});
|
|
58
|
+
p(() => {
|
|
59
|
+
a && (async () => {
|
|
60
|
+
E(!0), console.log(
|
|
61
|
+
"%csrcsharedAutocompleteSearchBar.tsx:77 fetchUrl, value",
|
|
62
|
+
"color: #007acc;",
|
|
63
|
+
a
|
|
64
|
+
);
|
|
65
|
+
const { data: s } = await q.apiClient.get(a || "");
|
|
66
|
+
R(
|
|
67
|
+
s.map((i) => ({
|
|
68
|
+
value: i[f],
|
|
69
|
+
label: i[h] + (L ? " (" + i[f] + ")" : "")
|
|
70
|
+
}))
|
|
71
|
+
), E(!1);
|
|
72
|
+
})();
|
|
73
|
+
}, [a]), p(() => {
|
|
74
|
+
F && R(F);
|
|
75
|
+
}, [F]), p(() => {
|
|
76
|
+
if ($ && x) {
|
|
77
|
+
const l = x.find((s) => s.value == $);
|
|
78
|
+
l && (w(l.label), O(l));
|
|
79
|
+
}
|
|
80
|
+
}, [$, x]), p(() => {
|
|
81
|
+
v && (async () => {
|
|
82
|
+
E(!0);
|
|
83
|
+
const { data: s } = await q.apiClient.get(a + k);
|
|
84
|
+
R(
|
|
85
|
+
s.map((i) => ({
|
|
86
|
+
value: i[f],
|
|
87
|
+
label: i[h] + (L ? " (" + i[f] + ")" : "")
|
|
88
|
+
}))
|
|
89
|
+
), y(
|
|
90
|
+
s.map((i) => ({
|
|
91
|
+
value: i[f],
|
|
92
|
+
label: i[h] + (L ? " (" + i[f] + ")" : "")
|
|
93
|
+
}))
|
|
94
|
+
), E(!1);
|
|
95
|
+
})();
|
|
96
|
+
}, [k, v, f, h, a]), se(D, () => {
|
|
97
|
+
y([]), P || (w(""), u(null)), S();
|
|
98
|
+
});
|
|
99
|
+
const Y = (l) => {
|
|
100
|
+
w(l.target.value), O(null), b(-1), y(
|
|
101
|
+
x.filter(
|
|
102
|
+
(s) => {
|
|
103
|
+
var i, W, G;
|
|
104
|
+
return (G = s == null ? void 0 : s.label) == null ? void 0 : G.toLowerCase().includes((W = (i = l.target) == null ? void 0 : i.value) == null ? void 0 : W.toLowerCase());
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
}, Z = () => {
|
|
109
|
+
console.log("handleFocus query", k), z(!0), c(), y(
|
|
110
|
+
x
|
|
111
|
+
/*.filter((option) =>
|
|
112
|
+
option.label.toLowerCase().includes(query.toLowerCase()),
|
|
113
|
+
),*/
|
|
114
|
+
);
|
|
115
|
+
}, I = () => {
|
|
116
|
+
console.log(
|
|
117
|
+
"%csrcsharedAutocompleteSearchBar.tsx:95 handleClearQuery",
|
|
118
|
+
"color: #007acc;"
|
|
119
|
+
), w(""), u(null), O(null), setTimeout(() => {
|
|
120
|
+
b(-1), y(x);
|
|
121
|
+
}, 1e3);
|
|
122
|
+
}, U = (l) => {
|
|
123
|
+
l.key === "ArrowUp" && g.length > 0 ? b(
|
|
124
|
+
(s) => s > 0 ? s - 1 : g.length - 1
|
|
125
|
+
) : l.key === "ArrowDown" && g.length > 0 ? b(
|
|
126
|
+
(s) => s < g.length - 1 ? s + 1 : 0
|
|
127
|
+
) : l.key === "Enter" && M !== -1 ? T(g[M]) : l.key === "Escape" && M !== -1 && S();
|
|
128
|
+
}, T = (l) => {
|
|
129
|
+
w(l.label), O(l), b(-1), u(l.value), S();
|
|
130
|
+
}, S = () => {
|
|
131
|
+
y([]), N(), z(!1);
|
|
132
|
+
};
|
|
133
|
+
return /* @__PURE__ */ C("div", { className: "w-full min-h-20 flex-col justify-start items-start gap-1.5 inline-flex", children: [
|
|
134
|
+
/* @__PURE__ */ C(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
className: "self-stretch min-h-14 flex-col justify-start items-start gap-1.5 flex relative",
|
|
138
|
+
ref: D,
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ C(
|
|
141
|
+
"label",
|
|
142
|
+
{
|
|
143
|
+
className: "text-slate-700 text-sm leading-tight font-medium",
|
|
144
|
+
htmlFor: t,
|
|
145
|
+
children: [
|
|
146
|
+
e,
|
|
147
|
+
" ",
|
|
148
|
+
r ? "*" : ""
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ n(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
className: `self-stretch px-3 py-1.5 rounded-lg justify-start items-center gap-2 inline-flex outline-none border
|
|
156
|
+
${Q ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""}
|
|
157
|
+
${Q && ((j = H[t]) != null && j.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""}
|
|
158
|
+
${!Q && ((V = H[t]) != null && V.message) ? "border-red-200" : ""}
|
|
159
|
+
${d ? "bg-gray-100" : "bg-transparent"}`,
|
|
160
|
+
children: /* @__PURE__ */ n("div", { className: "Content grow shrink basis-0 min-h-5 xl:min-h-8 justify-start items-start gap-2 flex relative flex-col w-full mx-auto", children: /* @__PURE__ */ n(
|
|
161
|
+
oe,
|
|
162
|
+
{
|
|
163
|
+
value: k,
|
|
164
|
+
onChange: Y,
|
|
165
|
+
onKeyDown: U,
|
|
166
|
+
onFocus: Z,
|
|
167
|
+
clearQuery: I,
|
|
168
|
+
inputRef: X,
|
|
169
|
+
placeholder: A,
|
|
170
|
+
isFocused: Q,
|
|
171
|
+
onBlur: S,
|
|
172
|
+
isLoading: J
|
|
173
|
+
}
|
|
174
|
+
) })
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
g.length > 0 && /* @__PURE__ */ n(
|
|
178
|
+
ne,
|
|
179
|
+
{
|
|
180
|
+
options: g,
|
|
181
|
+
selectedOptionIndex: M,
|
|
182
|
+
handleOptionClick: T
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
o && /* @__PURE__ */ n("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: o })
|
|
189
|
+
] });
|
|
190
|
+
}, ne = ({
|
|
191
|
+
options: e,
|
|
192
|
+
selectedOptionIndex: t,
|
|
193
|
+
handleOptionClick: r
|
|
194
|
+
}) => {
|
|
195
|
+
const d = B(null);
|
|
196
|
+
return p(() => {
|
|
197
|
+
var o;
|
|
198
|
+
if (t >= 0 && t < e.length) {
|
|
199
|
+
const a = (o = d.current) == null ? void 0 : o.children[t];
|
|
200
|
+
a == null || a.scrollIntoView({
|
|
201
|
+
behavior: "instant",
|
|
202
|
+
block: "nearest"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}, [t, e.length]), /* @__PURE__ */ n(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
ref: d,
|
|
209
|
+
className: "overflow-y-auto resultOptionContainer w-full max-h-96 absolute outline-4 bg-white border border-gray-200 drop-shadow-xl rounded-xl z-50 top-[73px]",
|
|
210
|
+
children: e.map((o, a) => /* @__PURE__ */ n(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
className: `py-2 px-4 flex items-center justify-between gap-8 hover:bg-gray-200 cursor-pointer ${t === a ? "bg-gray-200" : ""}`,
|
|
214
|
+
onClick: () => r(o),
|
|
215
|
+
children: /* @__PURE__ */ n("p", { className: "font-normal", children: o.label })
|
|
216
|
+
},
|
|
217
|
+
o.value
|
|
218
|
+
))
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
}, oe = ({
|
|
222
|
+
value: e,
|
|
223
|
+
onChange: t,
|
|
224
|
+
onKeyDown: r,
|
|
225
|
+
onFocus: d,
|
|
226
|
+
onBlur: o,
|
|
227
|
+
inputRef: a,
|
|
228
|
+
placeholder: f,
|
|
229
|
+
clearQuery: h,
|
|
230
|
+
isFocused: u,
|
|
231
|
+
isLoading: c
|
|
232
|
+
}) => /* @__PURE__ */ C("div", { className: "relative flex items-center w-full sharedResource", children: [
|
|
233
|
+
/* @__PURE__ */ n(
|
|
234
|
+
"input",
|
|
235
|
+
{
|
|
236
|
+
type: "text",
|
|
237
|
+
className: `pl-1 py-1 border-gray-800 w-full ${c ? "pr-10" : "pr-20"}`,
|
|
238
|
+
value: e,
|
|
239
|
+
onChange: t,
|
|
240
|
+
onKeyDown: r,
|
|
241
|
+
onFocus: d,
|
|
242
|
+
ref: a,
|
|
243
|
+
placeholder: f,
|
|
244
|
+
disabled: c
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
c && /* @__PURE__ */ n("div", { className: "loader absolute right-0 text-gray-500", children: /* @__PURE__ */ C(
|
|
248
|
+
"svg",
|
|
249
|
+
{
|
|
250
|
+
className: "animate-spin h-5 w-5",
|
|
251
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
252
|
+
fill: "none",
|
|
253
|
+
viewBox: "0 0 24 24",
|
|
254
|
+
children: [
|
|
255
|
+
/* @__PURE__ */ n(
|
|
256
|
+
"circle",
|
|
257
|
+
{
|
|
258
|
+
className: "opacity-25",
|
|
259
|
+
cx: "12",
|
|
260
|
+
cy: "12",
|
|
261
|
+
r: "10",
|
|
262
|
+
stroke: "currentColor",
|
|
263
|
+
strokeWidth: "4"
|
|
264
|
+
}
|
|
265
|
+
),
|
|
266
|
+
/* @__PURE__ */ n(
|
|
267
|
+
"path",
|
|
268
|
+
{
|
|
269
|
+
className: "opacity-75",
|
|
270
|
+
fill: "currentColor",
|
|
271
|
+
d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
) }),
|
|
277
|
+
u && !c && /* @__PURE__ */ n(
|
|
278
|
+
_,
|
|
279
|
+
{
|
|
280
|
+
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
281
|
+
onClick: o
|
|
282
|
+
}
|
|
283
|
+
),
|
|
284
|
+
!u && !c && /* @__PURE__ */ n(
|
|
285
|
+
ee,
|
|
286
|
+
{
|
|
287
|
+
className: "material-icons absolute right-0 cursor-pointer text-gray-500",
|
|
288
|
+
onClick: () => {
|
|
289
|
+
var v;
|
|
290
|
+
(v = a.current) == null || v.focus(), d();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
),
|
|
294
|
+
e && !c && /* @__PURE__ */ n(
|
|
295
|
+
te,
|
|
296
|
+
{
|
|
297
|
+
className: "material-icons absolute right-10 cursor-pointer text-gray-500",
|
|
298
|
+
onClick: () => {
|
|
299
|
+
h();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] });
|
|
304
|
+
export {
|
|
305
|
+
de as default
|
|
306
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { IOptionItem } from '../../main';
|
|
3
|
+
|
|
4
|
+
export interface FormFieldProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
value?: any;
|
|
10
|
+
register?: any;
|
|
11
|
+
errors?: any;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
clearable?: boolean;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
options?: IOptionItem[];
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
fetchUrl?: string;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
valueKey?: string;
|
|
21
|
+
labelKey?: string;
|
|
22
|
+
onInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | any>) => void;
|
|
23
|
+
}
|
|
24
|
+
declare const FormField: React.FC<FormFieldProps>;
|
|
25
|
+
export default FormField;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { jsxs as o, jsx as t, Fragment as x } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useRef as X, useEffect as Y } from "react";
|
|
3
|
+
import { M as Z } from "../../index-CvL09ndn.js";
|
|
4
|
+
import { useFederationContext as _ } from "../../contexts/FederationContext.js";
|
|
5
|
+
const re = ({
|
|
6
|
+
label: b,
|
|
7
|
+
name: r,
|
|
8
|
+
type: p,
|
|
9
|
+
register: y,
|
|
10
|
+
disabled: n,
|
|
11
|
+
errors: u = {},
|
|
12
|
+
required: H,
|
|
13
|
+
clearable: L,
|
|
14
|
+
value: l,
|
|
15
|
+
description: w,
|
|
16
|
+
onInputChange: i,
|
|
17
|
+
options: s,
|
|
18
|
+
placeholder: v,
|
|
19
|
+
children: C,
|
|
20
|
+
fetchUrl: N,
|
|
21
|
+
valueKey: T,
|
|
22
|
+
labelKey: E,
|
|
23
|
+
maxLength: G
|
|
24
|
+
}) => {
|
|
25
|
+
var j, A, S, $, M;
|
|
26
|
+
const [k, a] = R(!1), [F, B] = R(s), O = X(null), {
|
|
27
|
+
ref: q = O,
|
|
28
|
+
onBlur: f = () => {
|
|
29
|
+
},
|
|
30
|
+
...d
|
|
31
|
+
} = y ? y(r) : {}, z = (j = _()) == null ? void 0 : j.apiClient, c = q || O, D = () => {
|
|
32
|
+
c.current && c.current.focus();
|
|
33
|
+
}, J = (e) => {
|
|
34
|
+
const g = Array.from(
|
|
35
|
+
e.target.selectedOptions,
|
|
36
|
+
(m) => m.value
|
|
37
|
+
);
|
|
38
|
+
i({
|
|
39
|
+
...e,
|
|
40
|
+
target: {
|
|
41
|
+
value: g,
|
|
42
|
+
name: e.target.name
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, K = (e) => {
|
|
46
|
+
i({
|
|
47
|
+
...e,
|
|
48
|
+
target: {
|
|
49
|
+
value: e.target.value == "on",
|
|
50
|
+
name: e.target.name
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}, P = (e) => {
|
|
54
|
+
i({
|
|
55
|
+
...e,
|
|
56
|
+
target: {
|
|
57
|
+
value: "",
|
|
58
|
+
name: r
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
Y(() => {
|
|
63
|
+
N && (async (g) => {
|
|
64
|
+
const { data: m } = await z.get(g), V = typeof m[0] == "number", W = m.map((h) => V ? { value: h, label: h.toString() } : {
|
|
65
|
+
value: h[T || "id"],
|
|
66
|
+
label: h[E || "name"]
|
|
67
|
+
});
|
|
68
|
+
B([
|
|
69
|
+
{ value: null, label: " " },
|
|
70
|
+
// Add an empty option as the first item
|
|
71
|
+
...W
|
|
72
|
+
]);
|
|
73
|
+
})(N), s && B(s);
|
|
74
|
+
}, [N, s]);
|
|
75
|
+
const Q = () => {
|
|
76
|
+
switch (p) {
|
|
77
|
+
case "select":
|
|
78
|
+
return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ o(
|
|
79
|
+
"select",
|
|
80
|
+
{
|
|
81
|
+
id: r,
|
|
82
|
+
className: "grow shrink basis-0 text-gray-900 text-sm font-normal leading-tight focus:border-none bg-transparent",
|
|
83
|
+
disabled: n,
|
|
84
|
+
value: l,
|
|
85
|
+
...d,
|
|
86
|
+
ref: c,
|
|
87
|
+
onChange: i,
|
|
88
|
+
onFocus: () => a(!0),
|
|
89
|
+
onBlur: (e) => {
|
|
90
|
+
f(e), a(!1);
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
v && /* @__PURE__ */ t("option", { label: v }),
|
|
94
|
+
F == null ? void 0 : F.map((e) => /* @__PURE__ */ t(
|
|
95
|
+
"option",
|
|
96
|
+
{
|
|
97
|
+
value: e.value ? e.value : void 0,
|
|
98
|
+
children: e.label
|
|
99
|
+
},
|
|
100
|
+
e.value
|
|
101
|
+
))
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
) });
|
|
105
|
+
case "multiSelect":
|
|
106
|
+
return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(
|
|
107
|
+
"select",
|
|
108
|
+
{
|
|
109
|
+
id: r,
|
|
110
|
+
multiple: !0,
|
|
111
|
+
className: "grow shrink basis-0 text-gray-900 text-sm font-normal leading-tight focus:border-none bg-transparent",
|
|
112
|
+
disabled: n,
|
|
113
|
+
value: Array.isArray(l) ? l : [],
|
|
114
|
+
...d,
|
|
115
|
+
ref: c,
|
|
116
|
+
onChange: J,
|
|
117
|
+
onFocus: () => a(!0),
|
|
118
|
+
onBlur: (e) => {
|
|
119
|
+
f(e), a(!1);
|
|
120
|
+
},
|
|
121
|
+
children: s == null ? void 0 : s.map((e) => /* @__PURE__ */ t(
|
|
122
|
+
"option",
|
|
123
|
+
{
|
|
124
|
+
value: e.value ? e.value : void 0,
|
|
125
|
+
children: e.label
|
|
126
|
+
},
|
|
127
|
+
e.value
|
|
128
|
+
))
|
|
129
|
+
}
|
|
130
|
+
) });
|
|
131
|
+
case "radioGroup":
|
|
132
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-col", children: s == null ? void 0 : s.map((e, g) => /* @__PURE__ */ o(
|
|
133
|
+
"label",
|
|
134
|
+
{
|
|
135
|
+
className: "inline-flex items-center space-x-2 my-2",
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ t(
|
|
138
|
+
"input",
|
|
139
|
+
{
|
|
140
|
+
type: "radio",
|
|
141
|
+
name: r,
|
|
142
|
+
value: e.value,
|
|
143
|
+
checked: l === e.value,
|
|
144
|
+
disabled: n,
|
|
145
|
+
...y(r),
|
|
146
|
+
onChange: i,
|
|
147
|
+
className: "text-indigo-600 border-gray-300 focus:ring-indigo-500 mr-2"
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ t("span", { className: "text-gray-900 text-sm font-normal leading-tight", children: e.label })
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
g
|
|
154
|
+
)) });
|
|
155
|
+
case "textarea":
|
|
156
|
+
return /* @__PURE__ */ t(
|
|
157
|
+
"textarea",
|
|
158
|
+
{
|
|
159
|
+
id: r,
|
|
160
|
+
className: "grow shrink basis-0 text-gray-900 text-sm font-normal leading-tight focus:border-none ",
|
|
161
|
+
disabled: n,
|
|
162
|
+
value: l,
|
|
163
|
+
rows: 3,
|
|
164
|
+
...d,
|
|
165
|
+
ref: c,
|
|
166
|
+
onChange: i,
|
|
167
|
+
onFocus: () => a(!0),
|
|
168
|
+
maxLength: G || 4e3,
|
|
169
|
+
onBlur: (e) => {
|
|
170
|
+
f(e), a(!1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
case "checkbox":
|
|
175
|
+
return /* @__PURE__ */ o(x, { children: [
|
|
176
|
+
/* @__PURE__ */ t(
|
|
177
|
+
"input",
|
|
178
|
+
{
|
|
179
|
+
type: "checkbox",
|
|
180
|
+
id: r,
|
|
181
|
+
className: "shrink basis-0 text-gray-900 text-sm font-normal leading-tight focus:border-none",
|
|
182
|
+
checked: l,
|
|
183
|
+
disabled: n,
|
|
184
|
+
...d,
|
|
185
|
+
ref: c,
|
|
186
|
+
onChange: K,
|
|
187
|
+
onFocus: () => a(!0),
|
|
188
|
+
onBlur: (e) => {
|
|
189
|
+
f(e), a(!1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
/* @__PURE__ */ t("label", { htmlFor: r, children: b })
|
|
194
|
+
] });
|
|
195
|
+
default:
|
|
196
|
+
return /* @__PURE__ */ t(x, { children: /* @__PURE__ */ t(
|
|
197
|
+
"input",
|
|
198
|
+
{
|
|
199
|
+
className: "grow shrink basis-0 text-gray-900 text-sm font-normal leading-tight focus:border-none bg-transparent",
|
|
200
|
+
id: r,
|
|
201
|
+
readOnly: n,
|
|
202
|
+
value: l,
|
|
203
|
+
type: p,
|
|
204
|
+
...d,
|
|
205
|
+
ref: c,
|
|
206
|
+
placeholder: v,
|
|
207
|
+
onChange: i,
|
|
208
|
+
onFocus: () => a(!0),
|
|
209
|
+
onBlur: (e) => {
|
|
210
|
+
f(e), a(!1);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
) });
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
return /* @__PURE__ */ o("div", { className: "w-full min-h-30 flex-col justify-start items-start gap-1.5 inline-flex", children: [
|
|
217
|
+
/* @__PURE__ */ o("div", { className: "self-stretch flex-col justify-start items-start gap-1.5 flex", children: [
|
|
218
|
+
b && /* @__PURE__ */ o(
|
|
219
|
+
"label",
|
|
220
|
+
{
|
|
221
|
+
className: "text-slate-700 text-sm leading-tight font-medium",
|
|
222
|
+
htmlFor: r,
|
|
223
|
+
children: [
|
|
224
|
+
b,
|
|
225
|
+
" ",
|
|
226
|
+
H ? "*" : ""
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ t(
|
|
231
|
+
"div",
|
|
232
|
+
{
|
|
233
|
+
className: `self-stretch px-3 py-2 rounded-lg justify-start items-center gap-2 inline-flex outline-none border ${k && !((A = u[r]) != null && A.message) ? "outline-4 outline-indigo-200 outline-offset-0 border-indigo-300" : ""} ${k && ((S = u[r]) != null && S.message) ? "outline-4 outline-red-200 outline-offset-0 border-none" : ""} ${!k && (($ = u[r]) != null && $.message) ? "border-red-200" : ""} ${n ? "bg-gray-100" : "bg-transparent"}`,
|
|
234
|
+
children: /* @__PURE__ */ o("div", { className: "flex relative grow shrink basis-0 min-h-5 xl:min-h-[32px] justify-start items-stretch gap-2 max-w-full", children: [
|
|
235
|
+
Q(),
|
|
236
|
+
C && /* @__PURE__ */ t("div", { onClick: D, children: C }),
|
|
237
|
+
L && l && /* @__PURE__ */ t(Z, { onClick: P })
|
|
238
|
+
] })
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] }),
|
|
242
|
+
w && /* @__PURE__ */ t("div", { className: "HintText self-stretch text-slate-600 text-sm font-normal leading-tight", children: w }),
|
|
243
|
+
u[r] && /* @__PURE__ */ t("div", { className: "HintText self-stretch text-red-600 text-sm font-normal leading-tight", children: (M = u[r]) == null ? void 0 : M.message })
|
|
244
|
+
] });
|
|
245
|
+
};
|
|
246
|
+
export {
|
|
247
|
+
re as default
|
|
248
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import a from "react";
|
|
2
|
+
var m = {
|
|
3
|
+
color: void 0,
|
|
4
|
+
size: void 0,
|
|
5
|
+
className: void 0,
|
|
6
|
+
style: void 0,
|
|
7
|
+
attr: void 0
|
|
8
|
+
}, d = a.createContext && /* @__PURE__ */ a.createContext(m), h = ["attr", "size", "title"];
|
|
9
|
+
function b(t, e) {
|
|
10
|
+
if (t == null)
|
|
11
|
+
return {};
|
|
12
|
+
var r = O(t, e), n, i;
|
|
13
|
+
if (Object.getOwnPropertySymbols) {
|
|
14
|
+
var o = Object.getOwnPropertySymbols(t);
|
|
15
|
+
for (i = 0; i < o.length; i++)
|
|
16
|
+
n = o[i], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(t, n) && (r[n] = t[n]);
|
|
17
|
+
}
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
function O(t, e) {
|
|
21
|
+
if (t == null)
|
|
22
|
+
return {};
|
|
23
|
+
var r = {};
|
|
24
|
+
for (var n in t)
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
|
26
|
+
if (e.indexOf(n) >= 0)
|
|
27
|
+
continue;
|
|
28
|
+
r[n] = t[n];
|
|
29
|
+
}
|
|
30
|
+
return r;
|
|
31
|
+
}
|
|
32
|
+
function c() {
|
|
33
|
+
return c = Object.assign ? Object.assign.bind() : function(t) {
|
|
34
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
35
|
+
var r = arguments[e];
|
|
36
|
+
for (var n in r)
|
|
37
|
+
Object.prototype.hasOwnProperty.call(r, n) && (t[n] = r[n]);
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}, c.apply(this, arguments);
|
|
41
|
+
}
|
|
42
|
+
function g(t, e) {
|
|
43
|
+
var r = Object.keys(t);
|
|
44
|
+
if (Object.getOwnPropertySymbols) {
|
|
45
|
+
var n = Object.getOwnPropertySymbols(t);
|
|
46
|
+
e && (n = n.filter(function(i) {
|
|
47
|
+
return Object.getOwnPropertyDescriptor(t, i).enumerable;
|
|
48
|
+
})), r.push.apply(r, n);
|
|
49
|
+
}
|
|
50
|
+
return r;
|
|
51
|
+
}
|
|
52
|
+
function u(t) {
|
|
53
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
54
|
+
var r = arguments[e] != null ? arguments[e] : {};
|
|
55
|
+
e % 2 ? g(Object(r), !0).forEach(function(n) {
|
|
56
|
+
y(t, n, r[n]);
|
|
57
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : g(Object(r)).forEach(function(n) {
|
|
58
|
+
Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
function y(t, e, r) {
|
|
64
|
+
return e = w(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
|
|
65
|
+
}
|
|
66
|
+
function w(t) {
|
|
67
|
+
var e = j(t, "string");
|
|
68
|
+
return typeof e == "symbol" ? e : e + "";
|
|
69
|
+
}
|
|
70
|
+
function j(t, e) {
|
|
71
|
+
if (typeof t != "object" || !t)
|
|
72
|
+
return t;
|
|
73
|
+
var r = t[Symbol.toPrimitive];
|
|
74
|
+
if (r !== void 0) {
|
|
75
|
+
var n = r.call(t, e || "default");
|
|
76
|
+
if (typeof n != "object")
|
|
77
|
+
return n;
|
|
78
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
79
|
+
}
|
|
80
|
+
return (e === "string" ? String : Number)(t);
|
|
81
|
+
}
|
|
82
|
+
function p(t) {
|
|
83
|
+
return t && t.map((e, r) => /* @__PURE__ */ a.createElement(e.tag, u({
|
|
84
|
+
key: r
|
|
85
|
+
}, e.attr), p(e.child)));
|
|
86
|
+
}
|
|
87
|
+
function s(t) {
|
|
88
|
+
return (e) => /* @__PURE__ */ a.createElement(P, c({
|
|
89
|
+
attr: u({}, t.attr)
|
|
90
|
+
}, e), p(t.child));
|
|
91
|
+
}
|
|
92
|
+
function P(t) {
|
|
93
|
+
var e = (r) => {
|
|
94
|
+
var {
|
|
95
|
+
attr: n,
|
|
96
|
+
size: i,
|
|
97
|
+
title: o
|
|
98
|
+
} = t, v = b(t, h), f = i || r.size || "1em", l;
|
|
99
|
+
return r.className && (l = r.className), t.className && (l = (l ? l + " " : "") + t.className), /* @__PURE__ */ a.createElement("svg", c({
|
|
100
|
+
stroke: "currentColor",
|
|
101
|
+
fill: "currentColor",
|
|
102
|
+
strokeWidth: "0"
|
|
103
|
+
}, r.attr, n, v, {
|
|
104
|
+
className: l,
|
|
105
|
+
style: u(u({
|
|
106
|
+
color: t.color || r.color
|
|
107
|
+
}, r.style), t.style),
|
|
108
|
+
height: f,
|
|
109
|
+
width: f,
|
|
110
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
111
|
+
}), o && /* @__PURE__ */ a.createElement("title", null, o), t.children);
|
|
112
|
+
};
|
|
113
|
+
return d !== void 0 ? /* @__PURE__ */ a.createElement(d.Consumer, null, (r) => e(r)) : e(m);
|
|
114
|
+
}
|
|
115
|
+
function E(t) {
|
|
116
|
+
return s({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }, child: [] }] })(t);
|
|
117
|
+
}
|
|
118
|
+
function z(t) {
|
|
119
|
+
return s({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z" }, child: [] }] })(t);
|
|
120
|
+
}
|
|
121
|
+
function M(t) {
|
|
122
|
+
return s({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z" }, child: [] }] })(t);
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
E as M,
|
|
126
|
+
z as a,
|
|
127
|
+
M as b
|
|
128
|
+
};
|
package/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default as Button } from './components/Button.tsx';
|
|
2
|
+
export { default as AutocompleteSearchBar } from './components/form/AutocompleteSearchBar.tsx';
|
|
3
|
+
export { default as FormField } from './components/form/FormField.tsx';
|
|
2
4
|
export * from './contexts/FederationContext.tsx';
|
|
3
5
|
export * from './types.ts';
|
package/dist/main.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { default as o } from "./components/Button.js";
|
|
2
|
-
import {
|
|
2
|
+
import { default as a } from "./components/form/AutocompleteSearchBar.js";
|
|
3
|
+
import { default as f } from "./components/form/FormField.js";
|
|
4
|
+
import { FederationContext as x, FederationContextProvider as m, useFederationContext as u } from "./contexts/FederationContext.js";
|
|
3
5
|
export {
|
|
6
|
+
a as AutocompleteSearchBar,
|
|
4
7
|
o as Button,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
x as FederationContext,
|
|
9
|
+
m as FederationContextProvider,
|
|
10
|
+
f as FormField,
|
|
11
|
+
u as useFederationContext
|
|
8
12
|
};
|
package/dist/types.d.ts
CHANGED