next-recomponents 1.7.26 → 1.7.28
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/index.js +45 -30
- package/dist/index.mjs +45 -30
- package/package.json +1 -1
- package/src/calendar/index.tsx +4 -1
- package/src/input/index.tsx +3 -1
- package/src/select/index.tsx +23 -21
- package/src/text-area/index.tsx +5 -3
- package/src/use-resources/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -11127,7 +11127,11 @@ function Input(_a) {
|
|
|
11127
11127
|
const isValid = !regex ? true : regex.test(value);
|
|
11128
11128
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "w-full", children: [
|
|
11129
11129
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
11130
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.
|
|
11130
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "font-bold ", children: [
|
|
11131
|
+
label,
|
|
11132
|
+
" ",
|
|
11133
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-red-500", children: "*" })
|
|
11134
|
+
] }),
|
|
11131
11135
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
11132
11136
|
"input",
|
|
11133
11137
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -43665,9 +43669,13 @@ function TextArea(_a) {
|
|
|
43665
43669
|
"onChange",
|
|
43666
43670
|
"children"
|
|
43667
43671
|
]);
|
|
43668
|
-
const [value, setValue] = (0, import_react27.useState)(
|
|
43672
|
+
const [value, setValue] = (0, import_react27.useState)((props == null ? void 0 : props.value) || "");
|
|
43669
43673
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
43670
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.
|
|
43674
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "font-bold ", children: [
|
|
43675
|
+
label,
|
|
43676
|
+
" ",
|
|
43677
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-red-500", children: "*" })
|
|
43678
|
+
] }),
|
|
43671
43679
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
43672
43680
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43673
43681
|
"textarea",
|
|
@@ -43675,14 +43683,14 @@ function TextArea(_a) {
|
|
|
43675
43683
|
className: ["p-1 w-full rounded border shadow", className].join(
|
|
43676
43684
|
" "
|
|
43677
43685
|
),
|
|
43686
|
+
value,
|
|
43678
43687
|
onChange: (e) => {
|
|
43679
43688
|
if (maxLength) {
|
|
43680
43689
|
e.target.value = e.target.value.slice(0, maxLength);
|
|
43681
43690
|
}
|
|
43682
43691
|
setValue(e.target.value);
|
|
43683
43692
|
onChange == null ? void 0 : onChange(e);
|
|
43684
|
-
}
|
|
43685
|
-
value
|
|
43693
|
+
}
|
|
43686
43694
|
})
|
|
43687
43695
|
),
|
|
43688
43696
|
maxLength && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: " text-xs text-gray text-right", children: [
|
|
@@ -43848,7 +43856,7 @@ function useResources({
|
|
|
43848
43856
|
}
|
|
43849
43857
|
});
|
|
43850
43858
|
const findFunc = (id3, query) => __async(null, null, function* () {
|
|
43851
|
-
var _a, _b, _c2
|
|
43859
|
+
var _a, _b, _c2;
|
|
43852
43860
|
const options = {
|
|
43853
43861
|
method: "GET",
|
|
43854
43862
|
url: `${baseURI}/${key}/${id3}`,
|
|
@@ -43868,11 +43876,10 @@ function useResources({
|
|
|
43868
43876
|
newInfo[key].errorMessage = "";
|
|
43869
43877
|
newInfo[key].selectedItem = d;
|
|
43870
43878
|
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex((d2) => (d2 == null ? void 0 : d2.id) == id3);
|
|
43871
|
-
console.log("index", index, (_c2 = newInfo[key]) == null ? void 0 : _c2.data);
|
|
43872
43879
|
if (index >= 0) {
|
|
43873
43880
|
newInfo[key].data[index] = d;
|
|
43874
43881
|
} else {
|
|
43875
|
-
if ((
|
|
43882
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
43876
43883
|
newInfo[key].data.unshift(d);
|
|
43877
43884
|
} else {
|
|
43878
43885
|
newInfo[key].data = [d];
|
|
@@ -44306,7 +44313,11 @@ function Select(_a) {
|
|
|
44306
44313
|
}
|
|
44307
44314
|
}, [isOpen]);
|
|
44308
44315
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: containerRef, className: "w-full", children: [
|
|
44309
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime20.
|
|
44316
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: "font-bold mb-1 block", children: [
|
|
44317
|
+
label,
|
|
44318
|
+
" ",
|
|
44319
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-red-500", children: "*" })
|
|
44320
|
+
] }),
|
|
44310
44321
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative", children: [
|
|
44311
44322
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
44312
44323
|
"input",
|
|
@@ -44321,24 +44332,22 @@ function Select(_a) {
|
|
|
44321
44332
|
value: inputValue,
|
|
44322
44333
|
onBlur: (e) => {
|
|
44323
44334
|
setTimeout(() => {
|
|
44324
|
-
var _a2;
|
|
44325
|
-
|
|
44326
|
-
|
|
44327
|
-
if (
|
|
44328
|
-
|
|
44329
|
-
|
|
44330
|
-
|
|
44331
|
-
|
|
44332
|
-
|
|
44333
|
-
return;
|
|
44334
|
-
}
|
|
44335
|
-
} else {
|
|
44336
|
-
e.target.value = (item == null ? void 0 : item.value) || item.label;
|
|
44337
|
-
e.currentTarget.classList.add("bg-green-200");
|
|
44338
|
-
e.currentTarget.classList.remove("bg-red-200");
|
|
44335
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
44336
|
+
const item = validOption(e.target.value);
|
|
44337
|
+
if (!item) {
|
|
44338
|
+
if (strictMode) {
|
|
44339
|
+
e.target.value = "";
|
|
44340
|
+
setInputValue("");
|
|
44341
|
+
(_c = (_b2 = (_a2 = e.target) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
|
|
44342
|
+
(_f = (_e = (_d = e.target) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
44343
|
+
return;
|
|
44339
44344
|
}
|
|
44345
|
+
} else {
|
|
44346
|
+
e.target.value = (item == null ? void 0 : item.value) || item.label;
|
|
44347
|
+
e.target.classList.add("bg-green-200");
|
|
44348
|
+
(_i = (_h = (_g = e.target) == null ? void 0 : _g.classList) == null ? void 0 : _h.remove) == null ? void 0 : _i.call(_h, "bg-red-200");
|
|
44340
44349
|
}
|
|
44341
|
-
},
|
|
44350
|
+
}, 200);
|
|
44342
44351
|
},
|
|
44343
44352
|
onChange: (e) => {
|
|
44344
44353
|
setInputValue(e.target.value);
|
|
@@ -44357,7 +44366,6 @@ function Select(_a) {
|
|
|
44357
44366
|
setIsOpen(true);
|
|
44358
44367
|
setInputValue("");
|
|
44359
44368
|
if ((inputRef == null ? void 0 : inputRef.current) && strictMode) {
|
|
44360
|
-
console.log(inputRef.current);
|
|
44361
44369
|
(_c = (_b2 = (_a2 = inputRef.current) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
|
|
44362
44370
|
(_f = (_e = (_d = inputRef.current) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
44363
44371
|
inputRef.current.focus();
|
|
@@ -44378,9 +44386,12 @@ function Select(_a) {
|
|
|
44378
44386
|
className: `p-2 cursor-pointer ${index === highlightedIndex ? "bg-blue-100" : "hover:bg-gray-100"}`,
|
|
44379
44387
|
onClick: () => {
|
|
44380
44388
|
var _a2;
|
|
44381
|
-
|
|
44382
|
-
|
|
44383
|
-
|
|
44389
|
+
try {
|
|
44390
|
+
(_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
|
|
44391
|
+
target: { value: (opt == null ? void 0 : opt.value) || opt.label }
|
|
44392
|
+
});
|
|
44393
|
+
} catch (error) {
|
|
44394
|
+
}
|
|
44384
44395
|
const item = validOption(opt.label);
|
|
44385
44396
|
if (inputRef == null ? void 0 : inputRef.current) {
|
|
44386
44397
|
if (!item) {
|
|
@@ -44681,7 +44692,11 @@ function MyCalendar(_a) {
|
|
|
44681
44692
|
}
|
|
44682
44693
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative", children: [
|
|
44683
44694
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
|
|
44684
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.
|
|
44695
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "font-bold", children: [
|
|
44696
|
+
label,
|
|
44697
|
+
" ",
|
|
44698
|
+
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-red-500", children: "*" })
|
|
44699
|
+
] }),
|
|
44685
44700
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
44686
44701
|
"div",
|
|
44687
44702
|
{
|
package/dist/index.mjs
CHANGED
|
@@ -11109,7 +11109,11 @@ function Input(_a) {
|
|
|
11109
11109
|
const isValid = !regex ? true : regex.test(value);
|
|
11110
11110
|
return /* @__PURE__ */ jsxs5("div", { className: "w-full", children: [
|
|
11111
11111
|
/* @__PURE__ */ jsxs5("label", { className: "flex flex-col gap-1", children: [
|
|
11112
|
-
/* @__PURE__ */
|
|
11112
|
+
/* @__PURE__ */ jsxs5("div", { className: "font-bold ", children: [
|
|
11113
|
+
label,
|
|
11114
|
+
" ",
|
|
11115
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx7("span", { className: "text-red-500", children: "*" })
|
|
11116
|
+
] }),
|
|
11113
11117
|
/* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(
|
|
11114
11118
|
"input",
|
|
11115
11119
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -43649,9 +43653,13 @@ function TextArea(_a) {
|
|
|
43649
43653
|
"onChange",
|
|
43650
43654
|
"children"
|
|
43651
43655
|
]);
|
|
43652
|
-
const [value, setValue] = useState8(
|
|
43656
|
+
const [value, setValue] = useState8((props == null ? void 0 : props.value) || "");
|
|
43653
43657
|
return /* @__PURE__ */ jsx16("div", { className: "w-full", children: /* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
|
|
43654
|
-
/* @__PURE__ */
|
|
43658
|
+
/* @__PURE__ */ jsxs13("div", { className: "font-bold ", children: [
|
|
43659
|
+
label,
|
|
43660
|
+
" ",
|
|
43661
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx16("span", { className: "text-red-500", children: "*" })
|
|
43662
|
+
] }),
|
|
43655
43663
|
/* @__PURE__ */ jsxs13("div", { children: [
|
|
43656
43664
|
/* @__PURE__ */ jsx16(
|
|
43657
43665
|
"textarea",
|
|
@@ -43659,14 +43667,14 @@ function TextArea(_a) {
|
|
|
43659
43667
|
className: ["p-1 w-full rounded border shadow", className].join(
|
|
43660
43668
|
" "
|
|
43661
43669
|
),
|
|
43670
|
+
value,
|
|
43662
43671
|
onChange: (e) => {
|
|
43663
43672
|
if (maxLength) {
|
|
43664
43673
|
e.target.value = e.target.value.slice(0, maxLength);
|
|
43665
43674
|
}
|
|
43666
43675
|
setValue(e.target.value);
|
|
43667
43676
|
onChange == null ? void 0 : onChange(e);
|
|
43668
|
-
}
|
|
43669
|
-
value
|
|
43677
|
+
}
|
|
43670
43678
|
})
|
|
43671
43679
|
),
|
|
43672
43680
|
maxLength && /* @__PURE__ */ jsxs13("div", { className: " text-xs text-gray text-right", children: [
|
|
@@ -43832,7 +43840,7 @@ function useResources({
|
|
|
43832
43840
|
}
|
|
43833
43841
|
});
|
|
43834
43842
|
const findFunc = (id3, query) => __async(null, null, function* () {
|
|
43835
|
-
var _a, _b, _c2
|
|
43843
|
+
var _a, _b, _c2;
|
|
43836
43844
|
const options = {
|
|
43837
43845
|
method: "GET",
|
|
43838
43846
|
url: `${baseURI}/${key}/${id3}`,
|
|
@@ -43852,11 +43860,10 @@ function useResources({
|
|
|
43852
43860
|
newInfo[key].errorMessage = "";
|
|
43853
43861
|
newInfo[key].selectedItem = d;
|
|
43854
43862
|
const index = (_b = (_a = newInfo[key]) == null ? void 0 : _a.data) == null ? void 0 : _b.findIndex((d2) => (d2 == null ? void 0 : d2.id) == id3);
|
|
43855
|
-
console.log("index", index, (_c2 = newInfo[key]) == null ? void 0 : _c2.data);
|
|
43856
43863
|
if (index >= 0) {
|
|
43857
43864
|
newInfo[key].data[index] = d;
|
|
43858
43865
|
} else {
|
|
43859
|
-
if ((
|
|
43866
|
+
if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
|
|
43860
43867
|
newInfo[key].data.unshift(d);
|
|
43861
43868
|
} else {
|
|
43862
43869
|
newInfo[key].data = [d];
|
|
@@ -44294,7 +44301,11 @@ function Select(_a) {
|
|
|
44294
44301
|
}
|
|
44295
44302
|
}, [isOpen]);
|
|
44296
44303
|
return /* @__PURE__ */ jsxs14("div", { ref: containerRef, className: "w-full", children: [
|
|
44297
|
-
label && /* @__PURE__ */
|
|
44304
|
+
label && /* @__PURE__ */ jsxs14("label", { className: "font-bold mb-1 block", children: [
|
|
44305
|
+
label,
|
|
44306
|
+
" ",
|
|
44307
|
+
(props == null ? void 0 : props.required) && /* @__PURE__ */ jsx19("span", { className: "text-red-500", children: "*" })
|
|
44308
|
+
] }),
|
|
44298
44309
|
/* @__PURE__ */ jsxs14("div", { className: "relative", children: [
|
|
44299
44310
|
/* @__PURE__ */ jsx19(
|
|
44300
44311
|
"input",
|
|
@@ -44309,24 +44320,22 @@ function Select(_a) {
|
|
|
44309
44320
|
value: inputValue,
|
|
44310
44321
|
onBlur: (e) => {
|
|
44311
44322
|
setTimeout(() => {
|
|
44312
|
-
var _a2;
|
|
44313
|
-
|
|
44314
|
-
|
|
44315
|
-
if (
|
|
44316
|
-
|
|
44317
|
-
|
|
44318
|
-
|
|
44319
|
-
|
|
44320
|
-
|
|
44321
|
-
return;
|
|
44322
|
-
}
|
|
44323
|
-
} else {
|
|
44324
|
-
e.target.value = (item == null ? void 0 : item.value) || item.label;
|
|
44325
|
-
e.currentTarget.classList.add("bg-green-200");
|
|
44326
|
-
e.currentTarget.classList.remove("bg-red-200");
|
|
44323
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
44324
|
+
const item = validOption(e.target.value);
|
|
44325
|
+
if (!item) {
|
|
44326
|
+
if (strictMode) {
|
|
44327
|
+
e.target.value = "";
|
|
44328
|
+
setInputValue("");
|
|
44329
|
+
(_c = (_b2 = (_a2 = e.target) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
|
|
44330
|
+
(_f = (_e = (_d = e.target) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
44331
|
+
return;
|
|
44327
44332
|
}
|
|
44333
|
+
} else {
|
|
44334
|
+
e.target.value = (item == null ? void 0 : item.value) || item.label;
|
|
44335
|
+
e.target.classList.add("bg-green-200");
|
|
44336
|
+
(_i = (_h = (_g = e.target) == null ? void 0 : _g.classList) == null ? void 0 : _h.remove) == null ? void 0 : _i.call(_h, "bg-red-200");
|
|
44328
44337
|
}
|
|
44329
|
-
},
|
|
44338
|
+
}, 200);
|
|
44330
44339
|
},
|
|
44331
44340
|
onChange: (e) => {
|
|
44332
44341
|
setInputValue(e.target.value);
|
|
@@ -44345,7 +44354,6 @@ function Select(_a) {
|
|
|
44345
44354
|
setIsOpen(true);
|
|
44346
44355
|
setInputValue("");
|
|
44347
44356
|
if ((inputRef == null ? void 0 : inputRef.current) && strictMode) {
|
|
44348
|
-
console.log(inputRef.current);
|
|
44349
44357
|
(_c = (_b2 = (_a2 = inputRef.current) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
|
|
44350
44358
|
(_f = (_e = (_d = inputRef.current) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
|
|
44351
44359
|
inputRef.current.focus();
|
|
@@ -44366,9 +44374,12 @@ function Select(_a) {
|
|
|
44366
44374
|
className: `p-2 cursor-pointer ${index === highlightedIndex ? "bg-blue-100" : "hover:bg-gray-100"}`,
|
|
44367
44375
|
onClick: () => {
|
|
44368
44376
|
var _a2;
|
|
44369
|
-
|
|
44370
|
-
|
|
44371
|
-
|
|
44377
|
+
try {
|
|
44378
|
+
(_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
|
|
44379
|
+
target: { value: (opt == null ? void 0 : opt.value) || opt.label }
|
|
44380
|
+
});
|
|
44381
|
+
} catch (error) {
|
|
44382
|
+
}
|
|
44372
44383
|
const item = validOption(opt.label);
|
|
44373
44384
|
if (inputRef == null ? void 0 : inputRef.current) {
|
|
44374
44385
|
if (!item) {
|
|
@@ -44673,7 +44684,11 @@ function MyCalendar(_a) {
|
|
|
44673
44684
|
}
|
|
44674
44685
|
return /* @__PURE__ */ jsxs16("div", { className: "relative", children: [
|
|
44675
44686
|
/* @__PURE__ */ jsxs16("label", { className: "flex flex-col gap-1", children: [
|
|
44676
|
-
/* @__PURE__ */
|
|
44687
|
+
/* @__PURE__ */ jsxs16("div", { className: "font-bold", children: [
|
|
44688
|
+
label,
|
|
44689
|
+
" ",
|
|
44690
|
+
(otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ jsx24("span", { className: "text-red-500", children: "*" })
|
|
44691
|
+
] }),
|
|
44677
44692
|
/* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsxs16(
|
|
44678
44693
|
"div",
|
|
44679
44694
|
{
|
package/package.json
CHANGED
package/src/calendar/index.tsx
CHANGED
|
@@ -64,7 +64,10 @@ export default function MyCalendar({
|
|
|
64
64
|
return (
|
|
65
65
|
<div className="relative">
|
|
66
66
|
<label className="flex flex-col gap-1">
|
|
67
|
-
<div className="font-bold">
|
|
67
|
+
<div className="font-bold">
|
|
68
|
+
{label}{" "}
|
|
69
|
+
{otherProps?.required && <span className="text-red-500">*</span>}
|
|
70
|
+
</div>
|
|
68
71
|
<div>
|
|
69
72
|
<div
|
|
70
73
|
onClick={() => modalRef?.current?.showModal?.()}
|
package/src/input/index.tsx
CHANGED
|
@@ -22,7 +22,9 @@ export default function Input({
|
|
|
22
22
|
return (
|
|
23
23
|
<div className="w-full">
|
|
24
24
|
<label className="flex flex-col gap-1">
|
|
25
|
-
<div className="font-bold ">
|
|
25
|
+
<div className="font-bold ">
|
|
26
|
+
{label} {props?.required && <span className="text-red-500">*</span>}
|
|
27
|
+
</div>
|
|
26
28
|
<div>
|
|
27
29
|
<input
|
|
28
30
|
{...props}
|
package/src/select/index.tsx
CHANGED
|
@@ -104,7 +104,11 @@ export default function Select({
|
|
|
104
104
|
}, [isOpen]);
|
|
105
105
|
return (
|
|
106
106
|
<div ref={containerRef} className="w-full">
|
|
107
|
-
{label &&
|
|
107
|
+
{label && (
|
|
108
|
+
<label className="font-bold mb-1 block">
|
|
109
|
+
{label} {props?.required && <span className="text-red-500">*</span>}
|
|
110
|
+
</label>
|
|
111
|
+
)}
|
|
108
112
|
<div className="relative">
|
|
109
113
|
<input
|
|
110
114
|
autoComplete="off"
|
|
@@ -117,24 +121,22 @@ export default function Select({
|
|
|
117
121
|
value={inputValue}
|
|
118
122
|
onBlur={(e) => {
|
|
119
123
|
setTimeout(() => {
|
|
120
|
-
|
|
121
|
-
const item = validOption(e.target.value);
|
|
124
|
+
const item = validOption(e.target.value);
|
|
122
125
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
e.target.value = item?.value || item.label;
|
|
133
|
-
e.currentTarget.classList.add("bg-green-200");
|
|
134
|
-
e.currentTarget.classList.remove("bg-red-200");
|
|
126
|
+
if (!item) {
|
|
127
|
+
if (strictMode) {
|
|
128
|
+
e.target.value = "";
|
|
129
|
+
setInputValue("");
|
|
130
|
+
e.target?.classList?.remove?.("bg-green-200");
|
|
131
|
+
e.target?.classList?.add?.("bg-red-200");
|
|
132
|
+
return;
|
|
135
133
|
}
|
|
134
|
+
} else {
|
|
135
|
+
e.target.value = item?.value || item.label;
|
|
136
|
+
e.target.classList.add("bg-green-200");
|
|
137
|
+
e.target?.classList?.remove?.("bg-red-200");
|
|
136
138
|
}
|
|
137
|
-
},
|
|
139
|
+
}, 200);
|
|
138
140
|
|
|
139
141
|
// props?.onChange?.(e);
|
|
140
142
|
}}
|
|
@@ -157,7 +159,6 @@ export default function Select({
|
|
|
157
159
|
setIsOpen(true);
|
|
158
160
|
setInputValue("");
|
|
159
161
|
if (inputRef?.current && strictMode) {
|
|
160
|
-
console.log(inputRef.current);
|
|
161
162
|
inputRef.current?.classList?.remove?.("bg-green-200");
|
|
162
163
|
inputRef.current?.classList?.add?.("bg-red-200");
|
|
163
164
|
inputRef.current.focus();
|
|
@@ -184,10 +185,11 @@ export default function Select({
|
|
|
184
185
|
: "hover:bg-gray-100"
|
|
185
186
|
}`}
|
|
186
187
|
onClick={() => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
try {
|
|
189
|
+
props?.onChange?.({
|
|
190
|
+
target: { value: opt?.value || opt.label },
|
|
191
|
+
} as React.ChangeEvent<HTMLInputElement>);
|
|
192
|
+
} catch (error) {}
|
|
191
193
|
const item = validOption(opt.label);
|
|
192
194
|
if (inputRef?.current) {
|
|
193
195
|
if (!item) {
|
package/src/text-area/index.tsx
CHANGED
|
@@ -20,17 +20,20 @@ export default function TextArea({
|
|
|
20
20
|
children = "",
|
|
21
21
|
...props
|
|
22
22
|
}: Props) {
|
|
23
|
-
const [value, setValue] = useState<string>(
|
|
23
|
+
const [value, setValue] = useState<string>((props?.value as string) || "");
|
|
24
24
|
return (
|
|
25
25
|
<div className="w-full">
|
|
26
26
|
<label className="flex flex-col gap-1">
|
|
27
|
-
<div className="font-bold ">
|
|
27
|
+
<div className="font-bold ">
|
|
28
|
+
{label} {props?.required && <span className="text-red-500">*</span>}
|
|
29
|
+
</div>
|
|
28
30
|
<div>
|
|
29
31
|
<textarea
|
|
30
32
|
{...props}
|
|
31
33
|
className={["p-1 w-full rounded border shadow", className].join(
|
|
32
34
|
" "
|
|
33
35
|
)}
|
|
36
|
+
value={value}
|
|
34
37
|
onChange={(e) => {
|
|
35
38
|
if (maxLength) {
|
|
36
39
|
e.target.value = e.target.value.slice(0, maxLength);
|
|
@@ -38,7 +41,6 @@ export default function TextArea({
|
|
|
38
41
|
setValue(e.target.value);
|
|
39
42
|
onChange?.(e);
|
|
40
43
|
}}
|
|
41
|
-
value={value}
|
|
42
44
|
></textarea>
|
|
43
45
|
{maxLength && (
|
|
44
46
|
<div className=" text-xs text-gray text-right">
|
|
@@ -104,7 +104,7 @@ export default function useResources<T extends Record<string, ItemsRecord>>({
|
|
|
104
104
|
|
|
105
105
|
newInfo[key].selectedItem = d;
|
|
106
106
|
const index = newInfo[key]?.data?.findIndex((d: any) => d?.id == id);
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
if (index >= 0) {
|
|
109
109
|
newInfo[key].data[index] = d;
|
|
110
110
|
} else {
|