@djangocfg/ui-core 2.1.513 → 2.1.515

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/README.md CHANGED
@@ -61,7 +61,9 @@ import { UiProviders, Button, Card } from '@djangocfg/ui-core';
61
61
  | `components/specialized/` | Accordion · Collapsible · Toggle · Calendar · DatePicker (legacy — prefer forms/DateField) |
62
62
  | `components/boundary/` | ErrorBoundary |
63
63
 
64
- Imports stay flat — group folders are organisational.
64
+ Imports stay flat — group folders are organisational. Native-engine date/time
65
+ fields (`DateField` / `TimeField` / `DateTimeField`) have their own reference in
66
+ [`forms/datetime-field/README.md`](src/components/forms/datetime-field/README.md).
65
67
 
66
68
  ## Hooks (`/hooks`)
67
69
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/ui-core",
3
- "version": "2.1.513",
3
+ "version": "2.1.515",
4
4
  "description": "Pure React UI component library without Next.js dependencies - for Electron, Vite, CRA apps",
5
5
  "keywords": [
6
6
  "ui-components",
@@ -128,7 +128,7 @@
128
128
  "check:contrast": "node scripts/check-preset-contrast.mjs"
129
129
  },
130
130
  "peerDependencies": {
131
- "@djangocfg/i18n": "^2.1.513",
131
+ "@djangocfg/i18n": "^2.1.515",
132
132
  "consola": "^3.4.2",
133
133
  "lucide-react": "^0.545.0",
134
134
  "moment": "^2.30.1",
@@ -206,8 +206,8 @@
206
206
  "@chenglou/pretext": "^0.0.8"
207
207
  },
208
208
  "devDependencies": {
209
- "@djangocfg/i18n": "^2.1.513",
210
- "@djangocfg/typescript-config": "^2.1.513",
209
+ "@djangocfg/i18n": "^2.1.515",
210
+ "@djangocfg/typescript-config": "^2.1.515",
211
211
  "@types/node": "^24.13.3",
212
212
  "@types/react": "19.2.15",
213
213
  "@types/react-dom": "19.2.3",
@@ -0,0 +1,80 @@
1
+ # Date/time fields
2
+
3
+ `DateField` · `TimeField` · `DateTimeField` — native-engine, token-skinned
4
+ date/time inputs.
5
+
6
+ The browser's `<input type="date|time|datetime-local">` **is** the input engine:
7
+ segmented keyboard entry, locale-aware order, 12/24-hour by locale, arrow
8
+ increment, and the OS wheel on touch — all for free. This layer adds the
9
+ token-styled box, a leading icon, and (for date fields) a calendar popover for
10
+ mouse users. Values are ISO strings, so there's no timezone ambiguity at the
11
+ boundary.
12
+
13
+ | Component | `value` / `onChange` | Popover |
14
+ |---|---|---|
15
+ | `TimeField` | `"HH:mm"` (24h; `"HH:mm:ss"` when `step` < 60) | none — pure native segments |
16
+ | `DateField` | `"YYYY-MM-DD"` | `Calendar` (mouse; touch → OS wheel) |
17
+ | `DateTimeField` | `"YYYY-MM-DDTHH:mm"` | `Calendar` + a native `<input type="time">` |
18
+
19
+ ## Props
20
+
21
+ **Shared:**
22
+
23
+ | Prop | Type | Notes |
24
+ |---|---|---|
25
+ | `value` / `defaultValue` | `string` | Controlled / uncontrolled (ISO, see table). |
26
+ | `onChange` | `(value: string) => void` | Emits the ISO string. |
27
+ | `disabled` | `boolean` | |
28
+ | `invalid` | `boolean` | Wires `aria-invalid` + destructive border. Usually driven by the `Field` / `Form` layer. |
29
+ | `min` / `max` | `string` | Native bounds, same ISO shape as the value. |
30
+ | `name` / `id` | `string` | The native input **is** the form control — no hidden-input shim. `id` lets an external `<label htmlFor>` bind to the real control. |
31
+ | `className` | `string` | Applied to the field shell. |
32
+ | `aria-label` | `string` | |
33
+
34
+ **`TimeField` only:** `step?: number` — native `step` in seconds (`60` → HH:mm;
35
+ smaller exposes a seconds segment; controls arrow increment).
36
+
37
+ **`DateField` / `DateTimeField` only:**
38
+
39
+ - `align?: 'start' | 'center' | 'end'` — popover alignment (default `'start'`,
40
+ which keeps it under the field's left edge; Radix auto-flips on collision).
41
+ - `showPopover?: boolean` — default **AUTO**: shown on fine-pointer (mouse)
42
+ devices, hidden on coarse-pointer (touch) ones, where tapping the field opens
43
+ the OS date/time wheel — a better target than a mouse-first grid. Pass an
44
+ explicit `true` / `false` to force it. (`DateField`'s popover is the calendar;
45
+ `DateTimeField`'s is the calendar + a native time input.)
46
+
47
+ ## Behaviour notes
48
+
49
+ - **AM/PM vs 24-hour is the browser's call**, from the user's OS locale. We never
50
+ render our own time picker, so there's nothing to force or to desync. The wire
51
+ value is always 24h `HH:mm`.
52
+ - **Calendar localization**: month/weekday names come from the app locale via
53
+ `useLocaleOptional()` (`@djangocfg/i18n`) → date-fns locale. A bare calendar
54
+ with no `I18nProvider` falls back to English.
55
+ - **Local-safe dates**: `date-time-utils.ts` parses/formats `YYYY-MM-DD`
56
+ manually (not via `new Date(str)` / `toISOString()`), so the calendar day never
57
+ shifts by timezone.
58
+ - **Popover fit**: `collisionPadding` keeps it off the viewport/modal edge; there
59
+ is deliberately **no** `maxHeight` cap (that used the trigger-to-viewport gap
60
+ and clipped the calendar when the field sat low) — Radix's default
61
+ `avoidCollisions` flips the short popover above the field instead. A Popover
62
+ inside a Dialog can additionally be handed a `collisionBoundary` by the caller.
63
+ - **Native chrome**: the browser's own clock/calendar glyph and spin buttons are
64
+ suppressed via `.native-datetime-input` in
65
+ `styles/css/utilities/datetime-field.css`; `.native-datetime-input--center`
66
+ centers a value's segments cross-engine.
67
+
68
+ ## Migration
69
+
70
+ The old click-only `TimePicker` / `DatePicker` stay exported as back-compat
71
+ aliases (zero consumer churn). Prefer these `*Field` components. `DateRangePicker`
72
+ is unchanged (still the react-day-picker range grid).
73
+
74
+ ## Files
75
+
76
+ - `native-field-shell.tsx` — the shared token-styled box (surface, focus ring,
77
+ icon slot, invalid/disabled).
78
+ - `date-field.tsx` / `time-field.tsx` / `date-time-field.tsx` — the three fields.
79
+ - `popover-chevron.tsx` — the leading `IconTrigger` + trailing `PopoverChevron`.
80
+ - `date-time-utils.ts` — local-safe ISO ↔ `Date` helpers.