@bouko/react 2.3.0 → 2.3.2

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.
@@ -57,5 +57,5 @@ export default function FormBuilder({ fields, button, styles, submit, cancel = f
57
57
  return (_jsx(MultipleChoice, { id: id, label: label, options: options || [], value: data[id], update: x => setField(id, x), note: note, required: required }, id));
58
58
  else if (element === "attachment")
59
59
  return (_jsx(Attachment, { id: id, label: label, value: data[id], update: x => setField(id, x), note: note, required: required }, id));
60
- }) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("flex-1 text-sm", styles?.submit), onClick: handleSubmit, disabled: !isValid, children: [_jsx("div", { className: cn(isLoading ? "hidden" : ""), children: _jsx(CheckCircle, {}) }), _jsx("div", { className: cn(isLoading ? "animate-spin" : "hidden"), children: _jsx(Spinner, {}) }), button || "Submit"] }), cancel !== false && (_jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] }))] })] }));
60
+ }) }, i))), _jsxs(RowBox, { style: "items-center gap-2 mt-2 w-full", children: [_jsxs(Button, { style: cn("flex-1 text-sm", styles?.submit), onClick: handleSubmit, disabled: !isValid || isLoading, children: [_jsx("div", { className: cn(isLoading ? "hidden" : ""), children: _jsx(CheckCircle, {}) }), _jsx("div", { className: cn(isLoading ? "animate-spin" : "hidden"), children: _jsx(Spinner, {}) }), button || "Submit"] }), cancel !== false && (_jsxs(Button, { style: cn("text-sm text-error hover:text-error-light", styles?.cancel), variant: "ghost", onClick: clear, children: [_jsx(XCircle, {}), "Cancel"] }))] })] }));
61
61
  }
@@ -24,6 +24,24 @@ export const parseData = (data) => {
24
24
  copy[key] = new Date(value);
25
25
  else if (key === "timestamp")
26
26
  copy[key] = new Date(value.replaceAll("'", ""));
27
+ else if (parseAllowedDate(value))
28
+ copy[key] = new Date(value);
27
29
  }
28
30
  return copy;
29
31
  };
32
+ function parseAllowedDate(input) {
33
+ // ISO 8601 strict (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss+hh:mm)
34
+ const isoStrictRegex = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2}))?$/;
35
+ // MySQL/Postgres style with space + offset without colon (YYYY-MM-DD HH:mm:ss+hhmm)
36
+ const spaceOffsetRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{4}$/;
37
+ let normalized = input;
38
+ if (spaceOffsetRegex.test(input)) {
39
+ // Convert to ISO by replacing space with T and adding colon in offset
40
+ normalized = input.replace(" ", "T").replace(/([+-]\d{2})(\d{2})$/, "$1:$2");
41
+ }
42
+ else if (!isoStrictRegex.test(input)) {
43
+ return null; // Not allowed format
44
+ }
45
+ const date = new Date(normalized);
46
+ return !isNaN(date.getTime()) ? date : null;
47
+ }
@@ -1 +1 @@
1
- export default function useInterval(action: () => Promise<boolean | void>, delay: number): void;
1
+ export declare function useInterval(action: () => Promise<boolean | void>, delay: number, deps?: unknown[]): void;
@@ -1,11 +1,13 @@
1
1
  "use client";
2
2
  import { useEffect, useRef } from "react";
3
- export default function useInterval(action, delay) {
3
+ export function useInterval(action, delay, deps = []) {
4
4
  const ref = useRef(async () => false);
5
5
  useEffect(() => {
6
6
  ref.current = action;
7
7
  }, [action]);
8
8
  useEffect(() => {
9
+ if (deps.some(v => v === undefined || v === null))
10
+ return;
9
11
  const tick = async () => {
10
12
  const stop = await ref.current();
11
13
  if (stop && id)
@@ -14,5 +16,5 @@ export default function useInterval(action, delay) {
14
16
  const id = setInterval(tick, delay);
15
17
  tick();
16
18
  return () => clearInterval(id);
17
- }, [delay]);
19
+ }, [delay, ...deps]);
18
20
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.3.0",
4
+ "version": "2.3.2",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",