@bouko/react 2.2.9 → 2.3.1

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
+ }
@@ -3,5 +3,5 @@ type Props<T> = FieldProps<T> & {
3
3
  rows?: number;
4
4
  placeholder?: string;
5
5
  };
6
- export default function TextArea<T>({ id, style, label, required, note, update, ...props }: Props<T>): import("react/jsx-runtime").JSX.Element;
6
+ export default function TextArea({ id, style, label, required, note, value, update, ...props }: Props<string>): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -1,8 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Field from "./field";
3
- import { setField } from "./form";
4
- export default function TextArea({ id, style, label, required = true, note, update, ...props }) {
5
- return (_jsx(Field, { style: style, label: label, required: required, note: note, children: _jsx("textarea", { className: styles.textarea, onChange: ({ target: { value } }) => setField(update, id, value), ...props }) }));
3
+ export default function TextArea({ id, style, label, required = true, note, value, update, ...props }) {
4
+ return (_jsx(Field, { style: style, label: label, required: required, note: note, children: _jsx("textarea", { className: styles.textarea, onChange: ({ target: { value } }) => update(value), value: value ?? "", ...props }) }));
6
5
  }
7
6
  const styles = {
8
7
  container: "flex flex-col gap-1 overflow-hidden",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.2.9",
4
+ "version": "2.3.1",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",