@lilydesignsystem/angular-time-zone-picker 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,105 @@
1
- # Temporary Holding Version
1
+ # TimeZonePicker (Angular helper)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A reusable Angular headless **time zone picker**: an icon button that opens a WAI-ARIA APG listbox of time
4
+ zones, each shown as its UTC offset and its full name (`UTC+05:30 – India Standard Time`), **ordered by offset**
5
+ from west to east. On every change it sets `data-time-zone="{IANA id}"` on a target element (default
6
+ `document.documentElement`), optionally persisting the choice to `localStorage`. Ships no CSS.
7
+
8
+ The value is an IANA zone id (`Asia/Kolkata`), which is what `Intl.DateTimeFormat({ timeZone })` and every
9
+ date library take. The offsets and names are not a table in this package: they are computed with `Intl` for the
10
+ `locale` you pass, on the `date` you pass (default now), so the same zone reads `UTC-05:00 – Eastern Standard
11
+ Time` in January and `UTC-04:00 – Eastern Daylight Time` in July, and `Central European Standard Time` becomes
12
+ `heure normale d’Europe centrale` for `fr`.
13
+
14
+ ```js
15
+ // What the app does with the choice:
16
+ new Intl.DateTimeFormat(locale, { timeZone: document.documentElement.dataset.timeZone }).format(date);
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import { Component } from "@angular/core";
23
+ import { TimeZonePicker } from "@lilydesignsystem/angular-time-zone-picker";
24
+
25
+ @Component({
26
+ selector: "app-example",
27
+ standalone: true,
28
+ imports: [TimeZonePicker],
29
+ template: `<lily-time-zone-picker label="Time zone" locale="en-GB" [(value)]="zone" storageKey="lily-time-zone" />`,
30
+ })
31
+ export class Example {
32
+ zone = "";
33
+ }
34
+ ```
35
+
36
+ Angular idioms: the selector is `lily-time-zone-picker`; inputs are signal inputs (`[(value)]` and `[(open)]` are two-way models), the extra class is `className`, `zoneChange` is the output fired once per applied change, and a projected `<ng-template lilyTimeZonePickerIcon let-args>` replaces the icon (`args.infoFor(args.value)?.offset`).
37
+
38
+ ## Props
39
+
40
+ | Prop | Type | Required | Description |
41
+ | -------------- | --------------------------- | -------- | ------------------------------------------------------------------------------------------------ |
42
+ | `label` | `string` | yes | Accessible name for the button and the listbox; also the tooltip text. |
43
+ | `locale` | `string` | yes | BCP 47 tag the zone names are written in. No default: the picker never picks a language for you. |
44
+ | `zones` | `readonly string[]` | no | IANA ids to offer. Default `DEFAULT_ZONES` (55 representative zones). Shown by offset, not in the order given. |
45
+ | `date` | `Date` | no | The moment offsets and names are worked out for. Default: now, read once. |
46
+ | `value` | `string` | no | Selected IANA id. Two-way bindable. |
47
+ | `defaultValue` | `string` | no | Initial zone when nothing else is supplied. |
48
+ | `storageKey` | `string` | no | If set, persist the zone to `localStorage`. |
49
+ | `name` | `string` | no | `name` of the hidden input (default `"time-zone"`). |
50
+ | `target` | `HTMLElement \| null` | no | Element to receive `data-time-zone`. Default `<html>`. |
51
+ | `labelFor` | `(zone: ZoneInfo) => string`| no | Builds an option's text. Default `UTC+01:00 – Central European Standard Time`. |
52
+ | `names` | `ZoneNames` | no | Zone names by IANA id (a name, or `[standard, daylight]`) that win over `Intl`: the CLDR packs, below. |
53
+ | `children` | `Snippet<[ChildArgs]>` | no | Replaces the clock icon. |
54
+ | `onChange` | `(zone: string) => void` | no | Called once after a new zone is applied. |
55
+ | `open` | `boolean` | no | Is the popup open? Bindable. |
56
+ | `onOpenChange` | `(open: boolean) => void` | no | Fires whenever the open state changes. |
57
+ | `disabled` | `boolean` | no | Disables the button. |
58
+ | `className` | `string` | no | Extra CSS class on the root. |
59
+
60
+ The pure functions are exported too: `orderedZones`, `zoneInfo`, `offsetMinutes`, `formatOffset`, `zoneName`,
61
+ `matchZone`, `systemZone`, `defaultLabel`.
62
+
63
+ ## Zone names from Unicode CLDR
64
+
65
+ By default the full names come from `Intl`, so they are whatever ICU data the browser or server carries. For the same
66
+ name in every runtime, pass the Unicode CLDR names that `@lilydesignsystem/angular-locale-translations` ships, one pack
67
+ per label-pack locale (all 64), with the pack's own locale tag as the picker's `locale`:
68
+
69
+ ```ts
70
+ import { zoneNamesFrom } from "@lilydesignsystem/angular-locale-translations";
71
+ import fr from "@lilydesignsystem/angular-locale-translations/zone-names/fr-001";
72
+
73
+ // in the component class: names = zoneNamesFrom(fr);
74
+ // in its template:
75
+ // <lily-time-zone-picker label="Fuseau horaire" locale="fr" [names]="names" />
76
+ ```
77
+
78
+ A pack names about 425 zones, with the daylight name where a zone has one. A zone CLDR has no name for in that language
79
+ is not in the pack and falls back to `Intl`, never to another language. Cornish, Scots and Wu have no CLDR zone names, so
80
+ their packs are empty. See [spec/zone-names](../spec/zone-names/index.md).
81
+
82
+ ## Behaviour
83
+
84
+ - **Order**: by UTC offset ascending (`UTC-11:00` first, `UTC+14:00` last); ties by name (compared in `locale`),
85
+ then by id. An id the runtime does not know is left out; a repeated id appears once.
86
+ - **Initial value**: `value` > stored zone (only if still offered) > `defaultValue` > the reader's own zone when
87
+ listed, or its listed twin (same offset and name: `Europe/Berlin` → `Europe/Paris`) > `UTC` > the first zone.
88
+ - **Date**: offsets are fixed for the picker's `date` (read once when none is given) so an open list never
89
+ re-sorts under the pointer. Pass a `date` to show the offsets for a specific day.
90
+ - SSR-safe: all DOM writes happen inside an effect; the zone list is computed without the DOM.
91
+
92
+ ## Accessibility
93
+
94
+ - WCAG 2.2 AAA target.
95
+ - APG listbox keyboard contract: ArrowDown / ArrowUp / Enter / Space open; arrows clamp; `Home` / `End`;
96
+ `PageUp` / `PageDown` by ten; typeahead over the option text (type `UTC+05` to reach it); `Escape` closes
97
+ without changing the value; `Tab` closes and moves on.
98
+ - The offset is written in ASCII (`UTC+05:30`, hyphen-minus), so typeahead and screen readers read it the same
99
+ everywhere; the zone name comes from `Intl` in the reader's language.
100
+ - A tooltip repeats the label on hover and focus, dismissable with `Escape`, and is not linked with
101
+ `aria-describedby`.
102
+
103
+ ---
104
+
105
+ Lily™ and Lily Design System™ are trademarks.