@asteby/metacore-runtime-react 46.2.2 → 46.2.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 46.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ab15b46: El campo de fecha de un diálogo de acción marca aria-invalid cuando el servidor rechaza ese campo.
8
+
3
9
  ## 46.2.2
4
10
 
5
11
  ### Patch Changes
@@ -996,7 +996,7 @@ formValues, record, fieldErrors) {
996
996
  case 'date':
997
997
  // Modern shadcn Calendar in a Popover (portaled, never clipped by the
998
998
  // modal) instead of the native, dated, easily-cut <input type=date>.
999
- return _jsx(DynamicDateField, { field: field, value: value, onChange: onChange });
999
+ return _jsx(DynamicDateField, { field: field, value: value, onChange: onChange, invalid: invalid });
1000
1000
  default:
1001
1001
  return _jsx(Input, { id: field.key, type: field.type === 'email' ? 'email' : field.type === 'url' ? 'url' : 'text', value: value || '', onChange: (e) => onChange(e.target.value), placeholder: field.placeholder, "aria-invalid": invalid || undefined, className: invalidCls || undefined });
1002
1002
  }
@@ -3,7 +3,9 @@ export interface DynamicDateFieldProps {
3
3
  field: ActionFieldDef;
4
4
  value: any;
5
5
  onChange: (v: any) => void;
6
+ /** Server or client validation failed for this field (PIT-046). */
7
+ invalid?: boolean;
6
8
  }
7
- export declare function DynamicDateField({ field, value, onChange }: DynamicDateFieldProps): import("react").JSX.Element;
9
+ export declare function DynamicDateField({ field, value, onChange, invalid }: DynamicDateFieldProps): import("react").JSX.Element;
8
10
  export default DynamicDateField;
9
11
  //# sourceMappingURL=dynamic-date-field.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-date-field.d.ts","sourceRoot":"","sources":["../src/dynamic-date-field.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,GAAG,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAC7B;AAsBD,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BAkCjF;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"dynamic-date-field.d.ts","sourceRoot":"","sources":["../src/dynamic-date-field.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C,MAAM,WAAW,qBAAqB;IAClC,KAAK,EAAE,cAAc,CAAA;IACrB,KAAK,EAAE,GAAG,CAAA;IACV,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;IAC1B,mEAAmE;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CACpB;AAsBD,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,qBAAqB,+BAsC1F;AAED,eAAe,gBAAgB,CAAA"}
@@ -35,10 +35,11 @@ function label(d) {
35
35
  return toISO(d);
36
36
  }
37
37
  }
38
- export function DynamicDateField({ field, value, onChange }) {
38
+ export function DynamicDateField({ field, value, onChange, invalid }) {
39
39
  const [open, setOpen] = useState(false);
40
40
  const selected = toDate(value);
41
- return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", id: field.key, "data-empty": !selected, className: "w-full justify-start text-start font-normal data-[empty=true]:text-muted-foreground", children: [_jsx(CalendarIcon, { className: "mr-2 size-4 shrink-0 opacity-50" }), _jsx("span", { className: "truncate", children: selected ? label(selected) : (field.placeholder || 'Elegí una fecha') })] }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", captionLayout: "dropdown", selected: selected, defaultMonth: selected, onSelect: (d) => {
41
+ return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", id: field.key, "data-empty": !selected, "aria-invalid": invalid || undefined, className: 'w-full justify-start text-start font-normal data-[empty=true]:text-muted-foreground' +
42
+ (invalid ? ' border-destructive ring-1 ring-destructive/30' : ''), children: [_jsx(CalendarIcon, { className: "mr-2 size-4 shrink-0 opacity-50" }), _jsx("span", { className: "truncate", children: selected ? label(selected) : (field.placeholder || 'Elegí una fecha') })] }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", captionLayout: "dropdown", selected: selected, defaultMonth: selected, onSelect: (d) => {
42
43
  onChange(d ? toISO(d) : '');
43
44
  setOpen(false);
44
45
  } }) })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "46.2.2",
3
+ "version": "46.2.3",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1501,7 +1501,7 @@ function renderField(
1501
1501
  case 'date':
1502
1502
  // Modern shadcn Calendar in a Popover (portaled, never clipped by the
1503
1503
  // modal) instead of the native, dated, easily-cut <input type=date>.
1504
- return <DynamicDateField field={field} value={value} onChange={onChange} />
1504
+ return <DynamicDateField field={field} value={value} onChange={onChange} invalid={invalid} />
1505
1505
  default:
1506
1506
  return <Input id={field.key} type={field.type === 'email' ? 'email' : field.type === 'url' ? 'url' : 'text'} value={value || ''} onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange(e.target.value)} placeholder={field.placeholder} aria-invalid={invalid || undefined} className={invalidCls || undefined} />
1507
1507
  }
@@ -27,6 +27,8 @@ export interface DynamicDateFieldProps {
27
27
  field: ActionFieldDef
28
28
  value: any
29
29
  onChange: (v: any) => void
30
+ /** Server or client validation failed for this field (PIT-046). */
31
+ invalid?: boolean
30
32
  }
31
33
 
32
34
  const toDate = parseCalendarDate
@@ -49,7 +51,7 @@ function label(d: Date | undefined): string {
49
51
  }
50
52
  }
51
53
 
52
- export function DynamicDateField({ field, value, onChange }: DynamicDateFieldProps) {
54
+ export function DynamicDateField({ field, value, onChange, invalid }: DynamicDateFieldProps) {
53
55
  const [open, setOpen] = useState(false)
54
56
  const selected = toDate(value)
55
57
 
@@ -61,7 +63,11 @@ export function DynamicDateField({ field, value, onChange }: DynamicDateFieldPro
61
63
  variant="outline"
62
64
  id={field.key}
63
65
  data-empty={!selected}
64
- className="w-full justify-start text-start font-normal data-[empty=true]:text-muted-foreground"
66
+ aria-invalid={invalid || undefined}
67
+ className={
68
+ 'w-full justify-start text-start font-normal data-[empty=true]:text-muted-foreground' +
69
+ (invalid ? ' border-destructive ring-1 ring-destructive/30' : '')
70
+ }
65
71
  >
66
72
  <CalendarIcon className="mr-2 size-4 shrink-0 opacity-50" />
67
73
  <span className="truncate">