@asteby/metacore-runtime-react 18.5.0 → 18.6.0

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,15 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 18.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ed63683: Record dialog date fields use the real shadcn Calendar (react-day-picker) from
8
+ `@asteby/metacore-ui` instead of the dependency-free native `<input type="date">`
9
+ shim, and match datetime/timestamp(tz) types too. Empty/Go-zero dates
10
+ (0001-01-01) now show the "Seleccionar fecha" placeholder instead of
11
+ "31 de diciembre de 1".
12
+
3
13
  ## 18.5.0
4
14
 
5
15
  ### Minor Changes
@@ -12,9 +12,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
12
  // SDK stays transport- and host-agnostic.
13
13
  import { createContext, useContext, useEffect, useRef, useState } from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
- import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, Button, Input, Textarea, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Skeleton, Badge, Popover, PopoverContent, PopoverTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from '@asteby/metacore-ui/primitives';
15
+ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, Button, Input, Textarea, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Skeleton, Badge, Popover, PopoverContent, PopoverTrigger, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, Calendar, } from '@asteby/metacore-ui/primitives';
16
16
  import { cn } from '@asteby/metacore-ui/lib';
17
- import { Calendar } from './_primitives';
18
17
  import { toast } from 'sonner';
19
18
  import { format, parseISO } from 'date-fns';
20
19
  import { es } from 'date-fns/locale';
@@ -580,9 +579,13 @@ function EditField({ field, value, onChange }) {
580
579
  if (field.type === 'color') {
581
580
  return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { type: "color", value: value || '#6366f1', onChange: (e) => onChange(e.target.value), className: "h-9 w-14 cursor-pointer rounded-md border p-1" }), _jsx(Input, { value: value || '', onChange: (e) => onChange(e.target.value), placeholder: "#6366f1", className: "flex-1 h-9" })] }));
582
581
  }
583
- if (field.type === 'date') {
582
+ if (field.type === 'date' || field.type === 'datetime' || field.type === 'timestamp' || field.type === 'timestamptz') {
584
583
  const dateValue = value ? (typeof value === 'string' ? parseISO(value) : new Date(value)) : undefined;
585
- const validDate = dateValue && !isNaN(dateValue.getTime()) ? dateValue : undefined;
584
+ // Treat the Go zero-time (0001-01-01) as empty so an unset date shows the
585
+ // placeholder instead of "31 de diciembre de 1".
586
+ const validDate = dateValue && !isNaN(dateValue.getTime()) && dateValue.getFullYear() > 1
587
+ ? dateValue
588
+ : undefined;
586
589
  return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", className: cn("w-full justify-start text-left font-normal h-9", !validDate && "text-muted-foreground"), children: [_jsx(CalendarIcon, { className: "mr-2 h-4 w-4" }), validDate
587
590
  ? format(validDate, 'PPP', { locale: es })
588
591
  : "Seleccionar fecha"] }) }), _jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: _jsx(Calendar, { mode: "single", selected: validDate, onSelect: (date) => onChange(date ? format(date, 'yyyy-MM-dd') : ''), locale: es }) })] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "18.5.0",
3
+ "version": "18.6.0",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,9 +40,9 @@ import {
40
40
  CommandInput,
41
41
  CommandItem,
42
42
  CommandList,
43
+ Calendar,
43
44
  } from '@asteby/metacore-ui/primitives'
44
45
  import { cn } from '@asteby/metacore-ui/lib'
45
- import { Calendar } from './_primitives'
46
46
  import { toast } from 'sonner'
47
47
  import { format, parseISO } from 'date-fns'
48
48
  import { es } from 'date-fns/locale'
@@ -1108,9 +1108,14 @@ function EditField({ field, value, onChange }: {
1108
1108
  )
1109
1109
  }
1110
1110
 
1111
- if (field.type === 'date') {
1111
+ if (field.type === 'date' || field.type === 'datetime' || field.type === 'timestamp' || field.type === 'timestamptz') {
1112
1112
  const dateValue = value ? (typeof value === 'string' ? parseISO(value) : new Date(value)) : undefined
1113
- const validDate = dateValue && !isNaN(dateValue.getTime()) ? dateValue : undefined
1113
+ // Treat the Go zero-time (0001-01-01) as empty so an unset date shows the
1114
+ // placeholder instead of "31 de diciembre de 1".
1115
+ const validDate =
1116
+ dateValue && !isNaN(dateValue.getTime()) && dateValue.getFullYear() > 1
1117
+ ? dateValue
1118
+ : undefined
1114
1119
 
1115
1120
  return (
1116
1121
  <Popover>