next-recomponents 1.7.27 → 1.7.29

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 CHANGED
@@ -43669,7 +43669,7 @@ function TextArea(_a) {
43669
43669
  "onChange",
43670
43670
  "children"
43671
43671
  ]);
43672
- const [value, setValue] = (0, import_react27.useState)(children);
43672
+ const [value, setValue] = (0, import_react27.useState)((props == null ? void 0 : props.value) || "");
43673
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: [
43674
43674
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "font-bold ", children: [
43675
43675
  label,
@@ -43683,14 +43683,14 @@ function TextArea(_a) {
43683
43683
  className: ["p-1 w-full rounded border shadow", className].join(
43684
43684
  " "
43685
43685
  ),
43686
+ value,
43686
43687
  onChange: (e) => {
43687
43688
  if (maxLength) {
43688
43689
  e.target.value = e.target.value.slice(0, maxLength);
43689
43690
  }
43690
43691
  setValue(e.target.value);
43691
43692
  onChange == null ? void 0 : onChange(e);
43692
- },
43693
- children: value
43693
+ }
43694
43694
  })
43695
43695
  ),
43696
43696
  maxLength && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: " text-xs text-gray text-right", children: [
@@ -43856,7 +43856,7 @@ function useResources({
43856
43856
  }
43857
43857
  });
43858
43858
  const findFunc = (id3, query) => __async(null, null, function* () {
43859
- var _a, _b, _c2, _d2;
43859
+ var _a, _b, _c2;
43860
43860
  const options = {
43861
43861
  method: "GET",
43862
43862
  url: `${baseURI}/${key}/${id3}`,
@@ -43876,11 +43876,10 @@ function useResources({
43876
43876
  newInfo[key].errorMessage = "";
43877
43877
  newInfo[key].selectedItem = d;
43878
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);
43879
- console.log("index", index, (_c2 = newInfo[key]) == null ? void 0 : _c2.data);
43880
43879
  if (index >= 0) {
43881
43880
  newInfo[key].data[index] = d;
43882
43881
  } else {
43883
- if ((_d2 = newInfo[key]) == null ? void 0 : _d2.data) {
43882
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
43884
43883
  newInfo[key].data.unshift(d);
43885
43884
  } else {
43886
43885
  newInfo[key].data = [d];
@@ -44257,6 +44256,7 @@ function Select(_a) {
44257
44256
  const validOption = (value) => {
44258
44257
  return options.find((opt) => opt.label == value);
44259
44258
  };
44259
+ const normalize = (str) => str.toLowerCase().replace(/,/g, "").trim();
44260
44260
  (0, import_react30.useEffect)(() => {
44261
44261
  const parsedOptions = import_react30.default.Children.toArray(children).filter((child) => {
44262
44262
  return child.type === "option";
@@ -44274,8 +44274,8 @@ function Select(_a) {
44274
44274
  setFiltered(
44275
44275
  options.filter(
44276
44276
  (opt) => {
44277
- var _a2, _b2;
44278
- return (_b2 = (_a2 = opt == null ? void 0 : opt.label) == null ? void 0 : _a2.toLowerCase()) == null ? void 0 : _b2.includes(inputValue == null ? void 0 : inputValue.toLowerCase());
44277
+ var _a2;
44278
+ return (_a2 = normalize(`${opt == null ? void 0 : opt.label}`)) == null ? void 0 : _a2.includes(normalize(inputValue));
44279
44279
  }
44280
44280
  )
44281
44281
  );
@@ -44348,7 +44348,7 @@ function Select(_a) {
44348
44348
  e.target.classList.add("bg-green-200");
44349
44349
  (_i = (_h = (_g = e.target) == null ? void 0 : _g.classList) == null ? void 0 : _h.remove) == null ? void 0 : _i.call(_h, "bg-red-200");
44350
44350
  }
44351
- }, 100);
44351
+ }, 200);
44352
44352
  },
44353
44353
  onChange: (e) => {
44354
44354
  setInputValue(e.target.value);
@@ -44367,7 +44367,6 @@ function Select(_a) {
44367
44367
  setIsOpen(true);
44368
44368
  setInputValue("");
44369
44369
  if ((inputRef == null ? void 0 : inputRef.current) && strictMode) {
44370
- console.log(inputRef.current);
44371
44370
  (_c = (_b2 = (_a2 = inputRef.current) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
44372
44371
  (_f = (_e = (_d = inputRef.current) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
44373
44372
  inputRef.current.focus();
@@ -44388,9 +44387,12 @@ function Select(_a) {
44388
44387
  className: `p-2 cursor-pointer ${index === highlightedIndex ? "bg-blue-100" : "hover:bg-gray-100"}`,
44389
44388
  onClick: () => {
44390
44389
  var _a2;
44391
- (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
44392
- target: { value: (opt == null ? void 0 : opt.value) || opt.label }
44393
- });
44390
+ try {
44391
+ (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
44392
+ target: { value: (opt == null ? void 0 : opt.value) || opt.label }
44393
+ });
44394
+ } catch (error) {
44395
+ }
44394
44396
  const item = validOption(opt.label);
44395
44397
  if (inputRef == null ? void 0 : inputRef.current) {
44396
44398
  if (!item) {
@@ -44691,7 +44693,11 @@ function MyCalendar(_a) {
44691
44693
  }
44692
44694
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative", children: [
44693
44695
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("label", { className: "flex flex-col gap-1", children: [
44694
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "font-bold", children: label }),
44696
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "font-bold", children: [
44697
+ label,
44698
+ " ",
44699
+ (otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-red-500", children: "*" })
44700
+ ] }),
44695
44701
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
44696
44702
  "div",
44697
44703
  {
package/dist/index.mjs CHANGED
@@ -43653,7 +43653,7 @@ function TextArea(_a) {
43653
43653
  "onChange",
43654
43654
  "children"
43655
43655
  ]);
43656
- const [value, setValue] = useState8(children);
43656
+ const [value, setValue] = useState8((props == null ? void 0 : props.value) || "");
43657
43657
  return /* @__PURE__ */ jsx16("div", { className: "w-full", children: /* @__PURE__ */ jsxs13("label", { className: "flex flex-col gap-1", children: [
43658
43658
  /* @__PURE__ */ jsxs13("div", { className: "font-bold ", children: [
43659
43659
  label,
@@ -43667,14 +43667,14 @@ function TextArea(_a) {
43667
43667
  className: ["p-1 w-full rounded border shadow", className].join(
43668
43668
  " "
43669
43669
  ),
43670
+ value,
43670
43671
  onChange: (e) => {
43671
43672
  if (maxLength) {
43672
43673
  e.target.value = e.target.value.slice(0, maxLength);
43673
43674
  }
43674
43675
  setValue(e.target.value);
43675
43676
  onChange == null ? void 0 : onChange(e);
43676
- },
43677
- children: value
43677
+ }
43678
43678
  })
43679
43679
  ),
43680
43680
  maxLength && /* @__PURE__ */ jsxs13("div", { className: " text-xs text-gray text-right", children: [
@@ -43840,7 +43840,7 @@ function useResources({
43840
43840
  }
43841
43841
  });
43842
43842
  const findFunc = (id3, query) => __async(null, null, function* () {
43843
- var _a, _b, _c2, _d2;
43843
+ var _a, _b, _c2;
43844
43844
  const options = {
43845
43845
  method: "GET",
43846
43846
  url: `${baseURI}/${key}/${id3}`,
@@ -43860,11 +43860,10 @@ function useResources({
43860
43860
  newInfo[key].errorMessage = "";
43861
43861
  newInfo[key].selectedItem = d;
43862
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);
43863
- console.log("index", index, (_c2 = newInfo[key]) == null ? void 0 : _c2.data);
43864
43863
  if (index >= 0) {
43865
43864
  newInfo[key].data[index] = d;
43866
43865
  } else {
43867
- if ((_d2 = newInfo[key]) == null ? void 0 : _d2.data) {
43866
+ if ((_c2 = newInfo[key]) == null ? void 0 : _c2.data) {
43868
43867
  newInfo[key].data.unshift(d);
43869
43868
  } else {
43870
43869
  newInfo[key].data = [d];
@@ -44245,6 +44244,7 @@ function Select(_a) {
44245
44244
  const validOption = (value) => {
44246
44245
  return options.find((opt) => opt.label == value);
44247
44246
  };
44247
+ const normalize = (str) => str.toLowerCase().replace(/,/g, "").trim();
44248
44248
  useEffect8(() => {
44249
44249
  const parsedOptions = React7.Children.toArray(children).filter((child) => {
44250
44250
  return child.type === "option";
@@ -44262,8 +44262,8 @@ function Select(_a) {
44262
44262
  setFiltered(
44263
44263
  options.filter(
44264
44264
  (opt) => {
44265
- var _a2, _b2;
44266
- return (_b2 = (_a2 = opt == null ? void 0 : opt.label) == null ? void 0 : _a2.toLowerCase()) == null ? void 0 : _b2.includes(inputValue == null ? void 0 : inputValue.toLowerCase());
44265
+ var _a2;
44266
+ return (_a2 = normalize(`${opt == null ? void 0 : opt.label}`)) == null ? void 0 : _a2.includes(normalize(inputValue));
44267
44267
  }
44268
44268
  )
44269
44269
  );
@@ -44336,7 +44336,7 @@ function Select(_a) {
44336
44336
  e.target.classList.add("bg-green-200");
44337
44337
  (_i = (_h = (_g = e.target) == null ? void 0 : _g.classList) == null ? void 0 : _h.remove) == null ? void 0 : _i.call(_h, "bg-red-200");
44338
44338
  }
44339
- }, 100);
44339
+ }, 200);
44340
44340
  },
44341
44341
  onChange: (e) => {
44342
44342
  setInputValue(e.target.value);
@@ -44355,7 +44355,6 @@ function Select(_a) {
44355
44355
  setIsOpen(true);
44356
44356
  setInputValue("");
44357
44357
  if ((inputRef == null ? void 0 : inputRef.current) && strictMode) {
44358
- console.log(inputRef.current);
44359
44358
  (_c = (_b2 = (_a2 = inputRef.current) == null ? void 0 : _a2.classList) == null ? void 0 : _b2.remove) == null ? void 0 : _c.call(_b2, "bg-green-200");
44360
44359
  (_f = (_e = (_d = inputRef.current) == null ? void 0 : _d.classList) == null ? void 0 : _e.add) == null ? void 0 : _f.call(_e, "bg-red-200");
44361
44360
  inputRef.current.focus();
@@ -44376,9 +44375,12 @@ function Select(_a) {
44376
44375
  className: `p-2 cursor-pointer ${index === highlightedIndex ? "bg-blue-100" : "hover:bg-gray-100"}`,
44377
44376
  onClick: () => {
44378
44377
  var _a2;
44379
- (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
44380
- target: { value: (opt == null ? void 0 : opt.value) || opt.label }
44381
- });
44378
+ try {
44379
+ (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, {
44380
+ target: { value: (opt == null ? void 0 : opt.value) || opt.label }
44381
+ });
44382
+ } catch (error) {
44383
+ }
44382
44384
  const item = validOption(opt.label);
44383
44385
  if (inputRef == null ? void 0 : inputRef.current) {
44384
44386
  if (!item) {
@@ -44683,7 +44685,11 @@ function MyCalendar(_a) {
44683
44685
  }
44684
44686
  return /* @__PURE__ */ jsxs16("div", { className: "relative", children: [
44685
44687
  /* @__PURE__ */ jsxs16("label", { className: "flex flex-col gap-1", children: [
44686
- /* @__PURE__ */ jsx24("div", { className: "font-bold", children: label }),
44688
+ /* @__PURE__ */ jsxs16("div", { className: "font-bold", children: [
44689
+ label,
44690
+ " ",
44691
+ (otherProps == null ? void 0 : otherProps.required) && /* @__PURE__ */ jsx24("span", { className: "text-red-500", children: "*" })
44692
+ ] }),
44687
44693
  /* @__PURE__ */ jsx24("div", { children: /* @__PURE__ */ jsxs16(
44688
44694
  "div",
44689
44695
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "1.7.27",
3
+ "version": "1.7.29",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -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">{label}</div>
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?.()}
@@ -41,6 +41,8 @@ export default function Select({
41
41
  const validOption = (value: string) => {
42
42
  return options.find((opt) => opt.label == value);
43
43
  };
44
+ const normalize = (str: string) => str.toLowerCase().replace(/,/g, "").trim();
45
+
44
46
  useEffect(() => {
45
47
  const parsedOptions = React.Children.toArray(children)
46
48
  .filter((child): child is ReactElement => {
@@ -60,7 +62,7 @@ export default function Select({
60
62
  useEffect(() => {
61
63
  setFiltered(
62
64
  options.filter((opt) =>
63
- opt?.label?.toLowerCase()?.includes(inputValue?.toLowerCase())
65
+ normalize(`${opt?.label}`)?.includes(normalize(inputValue))
64
66
  )
65
67
  );
66
68
  setHighlightedIndex(-1);
@@ -136,7 +138,7 @@ export default function Select({
136
138
  e.target.classList.add("bg-green-200");
137
139
  e.target?.classList?.remove?.("bg-red-200");
138
140
  }
139
- }, 100);
141
+ }, 200);
140
142
 
141
143
  // props?.onChange?.(e);
142
144
  }}
@@ -159,7 +161,6 @@ export default function Select({
159
161
  setIsOpen(true);
160
162
  setInputValue("");
161
163
  if (inputRef?.current && strictMode) {
162
- console.log(inputRef.current);
163
164
  inputRef.current?.classList?.remove?.("bg-green-200");
164
165
  inputRef.current?.classList?.add?.("bg-red-200");
165
166
  inputRef.current.focus();
@@ -186,10 +187,11 @@ export default function Select({
186
187
  : "hover:bg-gray-100"
187
188
  }`}
188
189
  onClick={() => {
189
- props?.onChange?.({
190
- target: { value: opt?.value || opt.label },
191
- } as React.ChangeEvent<HTMLInputElement>);
192
-
190
+ try {
191
+ props?.onChange?.({
192
+ target: { value: opt?.value || opt.label },
193
+ } as React.ChangeEvent<HTMLInputElement>);
194
+ } catch (error) {}
193
195
  const item = validOption(opt.label);
194
196
  if (inputRef?.current) {
195
197
  if (!item) {
@@ -20,7 +20,7 @@ export default function TextArea({
20
20
  children = "",
21
21
  ...props
22
22
  }: Props) {
23
- const [value, setValue] = useState<string>(children as 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">
@@ -33,6 +33,7 @@ export default function TextArea({
33
33
  className={["p-1 w-full rounded border shadow", className].join(
34
34
  " "
35
35
  )}
36
+ value={value}
36
37
  onChange={(e) => {
37
38
  if (maxLength) {
38
39
  e.target.value = e.target.value.slice(0, maxLength);
@@ -40,9 +41,7 @@ export default function TextArea({
40
41
  setValue(e.target.value);
41
42
  onChange?.(e);
42
43
  }}
43
- >
44
- {value}
45
- </textarea>
44
+ ></textarea>
46
45
  {maxLength && (
47
46
  <div className=" text-xs text-gray text-right">
48
47
  {value.length} / {maxLength}
@@ -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
- console.log("index", index, newInfo[key]?.data);
107
+
108
108
  if (index >= 0) {
109
109
  newInfo[key].data[index] = d;
110
110
  } else {