@lilydesignsystem/web-components-picker-bar 0.3.0 → 0.5.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/LICENSE.md ADDED
@@ -0,0 +1,64 @@
1
+ <!-- Synced from the canonical repository by bin/sync-special-files.
2
+ Do not edit here; edit the root copy and re-run the script.
3
+ Canonical: https://github.com/LilyDesignSystem/lily-design-system/blob/main/LICENSE.md -->
4
+
5
+ # License
6
+
7
+ Lily Design System™ is free open source software.
8
+
9
+ License is any of these, at your option, or contact us for custom license options.
10
+
11
+ * [MIT](https://opensource.org/license/mit) ([SPDX: MIT](https://spdx.org/licenses/MIT.html))
12
+
13
+ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([SPDX: Apache-2.0](https://spdx.org/licenses/Apache-2.0.html))
14
+
15
+ * [GNU General Public License v2.0](https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html) ([SPDX: GPL-2.0-only](https://spdx.org/licenses/GPL-2.0-only.html))
16
+
17
+ * [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) ([SPDX: GPL-3.0-only](https://spdx.org/licenses/GPL-3.0-only.html))
18
+
19
+ * [BSD 3-Clause License](https://opensource.org/license/bsd-3-clause) ([SPDX: BSD-3-Clause](https://spdx.org/licenses/BSD-3-Clause.html))
20
+
21
+ ## SPDX
22
+
23
+ The machine-readable expression for the choice above is:
24
+
25
+ ```
26
+ SPDX-License-Identifier: MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause
27
+ ```
28
+
29
+ Every package manifest in this repository should carry that expression, or a
30
+ single identifier from the list where the packaging format does not accept a
31
+ disjunction. You do not need permission to pick one: choose whichever member of
32
+ the list suits your project and comply with that one.
33
+
34
+ This applies to the whole repository — the component catalog, the seven headless
35
+ libraries, the seven example applications, the seven helper catalogs, the
36
+ `themes/` stylesheets, the `bin/` tooling, and the documentation.
37
+
38
+ ## Scope note
39
+
40
+ This file supersedes an earlier `CC BY-NC-SA` notice. That notice was a content
41
+ license with a non-commercial clause, it was not an open-source license, and it
42
+ contradicted both the specification and the published packages. It should not be
43
+ relied on. If you obtained Lily under it and that raises a question for you,
44
+ contact <joel@joelparkerhenderson.com>.
45
+
46
+ ## Trademarks
47
+
48
+ Lily™ and Lily Design System™ are trademarks. The trademarks are distinct from
49
+ the software license: a trademark claim (™) asserts use of the marks and is
50
+ independent of the licenses above. A license to the software is not a license to
51
+ the marks.
52
+
53
+ You may say your project uses Lily, is built with Lily, or is compatible with
54
+ Lily. Please do not use the marks as the name of your fork or product, or in a
55
+ way that suggests affiliation or endorsement. For any use beyond that, contact
56
+ <joel@joelparkerhenderson.com>.
57
+
58
+ ## Third-party references
59
+
60
+ Lily's example applications and `themes/` stylesheets take visual reference from
61
+ public-sector design systems including NHS UK, GOV.UK, and USWDS. Lily is not
62
+ affiliated with, endorsed by, or connected to any of those organisations. Their
63
+ names and marks belong to them, and this license grants nothing in respect of
64
+ them.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # Lily Design System™ — `<lily-picker-bar>`
2
+
3
+ > **Link picker (0.3.0).** Pass `links` (and `labels.link`) to add a `link-picker` — a home icon opening the page links your app defines — as the leftmost icon. It renders only when both are given.
4
+
5
+ > **Time zone picker (0.5.0).** Set `labels.timeZone` and `timeZoneProps = { locale: "fr" }` (plus any `<lily-time-zone-picker>` property, e.g. `names`) to add a `time-zone-picker` — time zones by UTC offset with their full names — right after the locale picker. It renders only when both the label and the locale are given. To name the text sizes in the reader's language pass `sizeLabels` through the text-size props (`textSizeLabels(pack)` / `LocaleTranslations.TextSizeLabels(locale)` from the locale-translations package).
6
+
7
+ A single page-header row that composes five of the Lily
8
+ [`*-picker` helpers](../index.md) — search, theme, locale, text size,
9
+ and share, in that order — with two catalog-wide defaults pre-wired,
10
+ so you can drop one custom element into a header instead of
11
+ assembling and configuring five.
12
+
13
+ `<lily-motion-picker>` and `<lily-date-time-picker>` are not part of
14
+ the bar: motion has no natural spot next to the other three header
15
+ preferences, and `<lily-date-time-picker>` is a form control, not a
16
+ header control.
17
+
18
+ ## Install
19
+
20
+ ```sh
21
+ npm install @lilydesignsystem/web-components-picker-bar
22
+ ```
23
+
24
+ `@lilydesignsystem/web-components-search-picker`, `-theme-picker`,
25
+ `-locale-picker`, `-text-size-picker`, and `-share-picker` install automatically as
26
+ regular dependencies — `<lily-picker-bar>` is a thin wrapper around
27
+ them, not a reimplementation.
28
+
29
+ ## Usage
30
+
31
+ ```html
32
+ <script type="module">
33
+ import "@lilydesignsystem/web-components-picker-bar";
34
+ </script>
35
+
36
+ <lily-picker-bar id="header-picker-bar" themes-url="/assets/themes/"></lily-picker-bar>
37
+
38
+ <script type="module">
39
+ const bar = document.getElementById("header-picker-bar");
40
+ bar.labels = {
41
+ search: "Search this site",
42
+ searchInput: "Search terms",
43
+ searchSubmit: "Search",
44
+ theme: "Theme",
45
+ locale: "Language",
46
+ textSize: "Text size",
47
+ share: "Share",
48
+ };
49
+ bar.locales = ["en", "cy", "gd", "ga"];
50
+ bar.shareTargets = [
51
+ {
52
+ id: "email",
53
+ label: "Email",
54
+ href: (url, title) => `mailto:?subject=${title}&body=${url}`,
55
+ },
56
+ ];
57
+ </script>
58
+ ```
59
+
60
+ `labels`, `locales`, and `shareTargets` are property-only (§4.3 of the
61
+ spec) — objects and functions cannot be expressed as HTML attributes
62
+ — so set them from script, before or after the element connects.
63
+ `themes-url` (required) and `class` are plain attributes and can be
64
+ written directly in HTML, as shown above.
65
+
66
+ That's a complete, working header row: site search (a search for
67
+ `foo` goes to `/?foo`), 45 themes, four locales, the
68
+ seven-step text-size scale, and one share destination plus
69
+ copy-to-URL if you add `bar.shareProps = { copyLabel: "Copy link" }`.
70
+
71
+ ## Defaults
72
+
73
+ - **`themes`** defaults to `DEFAULT_THEMES` — all 45 Lily reference
74
+ theme slugs, alphabetical, with the 8 United Kingdom / United States
75
+ government themes moved to their own alphabetical group at the
76
+ bottom. Set `bar.themes = [...]` (or the `themes="a,b,c"` attribute)
77
+ to override.
78
+ - **`sizes`** defaults to `DEFAULT_SIZES` — the seven-step scale
79
+ `largest`, `larger`, `large`, `normal`, `small`, `smaller`,
80
+ `smallest` — and the text-size picker starts on `normal`. Set
81
+ `bar.sizes = [...]` (and `bar.textSizeProps = { defaultValue: "…" }`
82
+ if you want a different starting point) to override.
83
+
84
+ Both are exported as named constants:
85
+
86
+ ```js
87
+ import { DEFAULT_THEMES, DEFAULT_SIZES } from "@lilydesignsystem/web-components-picker-bar";
88
+ ```
89
+
90
+ ## Passing extra properties to one picker
91
+
92
+ Each wrapped picker takes a `*Props` bag for anything beyond what
93
+ `<lily-picker-bar>` lifts to the top level — persistence, initial
94
+ value, detection, a `*Labels` override map, a custom glyph:
95
+
96
+ ```js
97
+ bar.searchProps = { action: "/search", placeholder: "Search…", navigate: (href) => router.push(href) };
98
+ bar.themeProps = { storageKey: "lily-theme", detectFromSystem: true };
99
+ bar.localeProps = { storageKey: "lily-locale", detectFromNavigator: true };
100
+ bar.textSizeProps = { storageKey: "lily-text-size" };
101
+ bar.shareProps = { copyLabel: "Copy link", copiedLabel: "Copied" };
102
+ ```
103
+
104
+ Anything in a `*Props` bag wins over `<lily-picker-bar>`'s own default
105
+ for that picker.
106
+
107
+ ## Styling
108
+
109
+ `<lily-picker-bar>` renders no CSS of its own class beyond the
110
+ `picker-bar` root wrapper — style each child through its own
111
+ package's class hooks (`search-picker`, `theme-picker`, `locale-picker`,
112
+ `text-size-picker`, `share-picker`; see each package's own `index.md`).
113
+ A typical header layout:
114
+
115
+ ```css
116
+ .picker-bar {
117
+ display: flex;
118
+ gap: var(--theme-space-sm, 0.5rem);
119
+ align-items: center;
120
+ }
121
+ ```
122
+
123
+ ## Accessibility
124
+
125
+ Every accessible name comes from `labels` — there is no English
126
+ default, because a set of names this catalog invented is exactly the
127
+ case the rest of Lily's i18n rule exists for. Each wrapped picker
128
+ keeps its own WAI-ARIA APG contract unchanged; see that picker's own
129
+ `index.md`.
130
+
131
+ ## Full contract
132
+
133
+ See [`spec/index.md`](./spec/index.md).
134
+
135
+ ---
136
+
137
+ Lily™ and Lily Design System™ are trademarks.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { SearchPickerProps } from '@lilydesignsystem/web-components-search-picke
3
3
  import { ThemePickerProps } from '@lilydesignsystem/web-components-theme-picker';
4
4
  import { LocalePickerProps } from '@lilydesignsystem/web-components-locale-picker';
5
5
  import { TextSizePickerProps } from '@lilydesignsystem/web-components-text-size-picker';
6
+ import { TimeZonePickerProps } from '@lilydesignsystem/web-components-time-zone-picker';
6
7
  import { ShareTarget, SharePickerProps } from '@lilydesignsystem/web-components-share-picker';
7
8
 
8
9
  /**
@@ -22,7 +23,7 @@ import { ShareTarget, SharePickerProps } from '@lilydesignsystem/web-components-
22
23
  */
23
24
 
24
25
  /**
25
- * All 45 Lily reference theme slugs (see `themes/` at the repo root),
26
+ * All 57 Lily reference theme slugs (see `themes/` at the repo root),
26
27
  * sorted alphabetically except the United Kingdom and United States
27
28
  * government/public-sector themes, which sort last as one alphabetical
28
29
  * group of their own. Mirrors `<lily-theme-picker>`'s own title-casing
@@ -55,6 +56,11 @@ type PickerBarLabels = {
55
56
  locale: string;
56
57
  /** Accessible name for the text-size picker's button and listbox. */
57
58
  textSize: string;
59
+ /**
60
+ * Accessible name for the time-zone picker's button and listbox. Needed only when
61
+ * `timeZoneProps.locale` is supplied; the time-zone picker renders only when both are present.
62
+ */
63
+ timeZone?: string;
58
64
  /** Accessible name for the share picker's button and list. */
59
65
  share: string;
60
66
  };
@@ -76,6 +82,8 @@ type PickerBarProps = {
76
82
  /** Property-only extra `<lily-locale-picker>` config, applied after the bar's own. */
77
83
  localeProps?: Partial<Omit<LocalePickerProps, "locales" | "label">>;
78
84
  sizes?: string[];
85
+ /** Property-only extra `<lily-time-zone-picker>` config; `locale` (names and sorts the zones) is required for it to render, after the locale picker. */
86
+ timeZoneProps?: Partial<Omit<TimeZonePickerProps, "label">>;
79
87
  /** Property-only extra `<lily-text-size-picker>` config, applied after the bar's own. */
80
88
  textSizeProps?: Partial<Omit<TextSizePickerProps, "sizes" | "label">>;
81
89
  /** Property-only — `ShareTarget.href` is a function. */
@@ -115,6 +123,8 @@ declare class PickerBar extends HTMLElement {
115
123
  set themeProps(v: Partial<ThemePickerProps>);
116
124
  get localeProps(): Partial<LocalePickerProps>;
117
125
  set localeProps(v: Partial<LocalePickerProps>);
126
+ get timeZoneProps(): Partial<TimeZonePickerProps>;
127
+ set timeZoneProps(v: Partial<TimeZonePickerProps>);
118
128
  get textSizeProps(): Partial<TextSizePickerProps>;
119
129
  set textSizeProps(v: Partial<TextSizePickerProps>);
120
130
  get shareProps(): Partial<SharePickerProps>;
@@ -123,4 +133,5 @@ declare class PickerBar extends HTMLElement {
123
133
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
124
134
  }
125
135
 
126
- export { DEFAULT_SIZES, DEFAULT_THEMES, PickerBar, type PickerBarLabels, type PickerBarProps };
136
+ export { DEFAULT_SIZES, DEFAULT_THEMES, PickerBar };
137
+ export type { PickerBarLabels, PickerBarProps };
package/dist/index.js CHANGED
@@ -1,19 +1,23 @@
1
- // lily-design-system-web-components-picker-bar/picker-bar.ts
1
+ // picker-bar.ts
2
2
  import "@lilydesignsystem/web-components-link-picker";
3
3
  import "@lilydesignsystem/web-components-search-picker";
4
4
  import "@lilydesignsystem/web-components-theme-picker";
5
5
  import "@lilydesignsystem/web-components-locale-picker";
6
6
  import "@lilydesignsystem/web-components-text-size-picker";
7
+ import "@lilydesignsystem/web-components-time-zone-picker";
7
8
  import "@lilydesignsystem/web-components-share-picker";
8
9
  var DEFAULT_THEMES = [
9
10
  "abyss",
10
11
  "acid",
11
12
  "adobe-spectrum",
13
+ "ant-design",
12
14
  "aqua",
15
+ "atlassian",
13
16
  "autumn",
14
17
  "black",
15
18
  "bumblebee",
16
19
  "business",
20
+ "cappuccino",
17
21
  "caramellatte",
18
22
  "cmyk",
19
23
  "coffee",
@@ -24,23 +28,32 @@ var DEFAULT_THEMES = [
24
28
  "dim",
25
29
  "dracula",
26
30
  "emerald",
31
+ "excel",
27
32
  "fantasy",
33
+ "fluent",
28
34
  "forest",
29
35
  "garden",
36
+ "github-primer",
30
37
  "halloween",
38
+ "ibm-carbon",
31
39
  "lemonade",
32
40
  "light",
41
+ "linear",
33
42
  "lofi",
34
43
  "luxury",
35
44
  "mozilla-protocol",
36
45
  "night",
37
46
  "nord",
47
+ "notion",
38
48
  "pastel",
39
49
  "retro",
50
+ "salesforce",
51
+ "sap-fiori",
40
52
  "silk",
41
53
  "sunset",
42
54
  "synthwave",
43
55
  "valentine",
56
+ "vercel",
44
57
  "winter",
45
58
  "wireframe",
46
59
  "united-kingdom-government-digital-service",
@@ -88,6 +101,7 @@ var PickerBar = class extends HTMLElement {
88
101
  #themeProps = {};
89
102
  #localeProps = {};
90
103
  #textSizeProps = {};
104
+ #timeZoneProps = {};
91
105
  #shareProps = {};
92
106
  #built = false;
93
107
  #rootEl = null;
@@ -96,6 +110,7 @@ var PickerBar = class extends HTMLElement {
96
110
  #themeEl = null;
97
111
  #localeEl = null;
98
112
  #textSizeEl = null;
113
+ #timeZoneEl = null;
99
114
  #shareEl = null;
100
115
  // ---- Property accessors ----
101
116
  get themesUrl() {
@@ -147,6 +162,7 @@ var PickerBar = class extends HTMLElement {
147
162
  set labels(v) {
148
163
  this.#labels = v ?? { ...DEFAULT_LABELS };
149
164
  this.#syncLink();
165
+ this.#syncTimeZone();
150
166
  if (this.#searchEl) {
151
167
  this.#searchEl.label = this.#labels.search;
152
168
  this.#searchEl.inputLabel = this.#labels.searchInput;
@@ -226,6 +242,31 @@ var PickerBar = class extends HTMLElement {
226
242
  this.#localeProps = v ?? {};
227
243
  if (this.#localeEl) Object.assign(this.#localeEl, this.#localeProps);
228
244
  }
245
+ get timeZoneProps() {
246
+ return { ...this.#timeZoneProps };
247
+ }
248
+ set timeZoneProps(v) {
249
+ this.#timeZoneProps = v ?? {};
250
+ this.#syncTimeZone();
251
+ }
252
+ /** The time-zone picker exists only with `labels.timeZone` and `timeZoneProps.locale`; it sits just after the locale picker. */
253
+ #syncTimeZone() {
254
+ if (!this.#rootEl) return;
255
+ const wanted = !!this.#labels.timeZone && !!this.#timeZoneProps.locale;
256
+ if (!wanted) {
257
+ this.#timeZoneEl?.remove();
258
+ this.#timeZoneEl = null;
259
+ return;
260
+ }
261
+ const el = this.#timeZoneEl ?? document.createElement("lily-time-zone-picker");
262
+ el.locale = this.#timeZoneProps.locale;
263
+ Object.assign(el, this.#timeZoneProps);
264
+ el.label = this.#labels.timeZone;
265
+ if (!this.#timeZoneEl) {
266
+ this.#timeZoneEl = el;
267
+ this.#rootEl.insertBefore(el, this.#textSizeEl);
268
+ }
269
+ }
229
270
  get textSizeProps() {
230
271
  return { ...this.#textSizeProps };
231
272
  }
@@ -321,11 +362,13 @@ var PickerBar = class extends HTMLElement {
321
362
  this.#textSizeEl = textSizeEl;
322
363
  this.#shareEl = shareEl;
323
364
  this.#linkEl = null;
365
+ this.#timeZoneEl = null;
324
366
  this.#syncLink();
367
+ this.#syncTimeZone();
325
368
  }
326
369
  };
327
370
 
328
- // lily-design-system-web-components-picker-bar/index.ts
371
+ // index.ts
329
372
  if (typeof customElements !== "undefined" && !customElements.get("lily-picker-bar")) {
330
373
  customElements.define("lily-picker-bar", PickerBar);
331
374
  }
package/index.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  > **Link picker (0.3.0).** Pass `links` (and `labels.link`) to add a `link-picker` — a home icon opening the page links your app defines — as the leftmost icon. It renders only when both are given.
4
4
 
5
+ > **Time zone picker (0.5.0).** Set `labels.timeZone` and `timeZoneProps = { locale: "fr" }` (plus any `<lily-time-zone-picker>` property, e.g. `names`) to add a `time-zone-picker` — time zones by UTC offset with their full names — right after the locale picker. It renders only when both the label and the locale are given. To name the text sizes in the reader's language pass `sizeLabels` through the text-size props (`textSizeLabels(pack)` / `LocaleTranslations.TextSizeLabels(locale)` from the locale-translations package).
6
+
5
7
  A single page-header row that composes five of the Lily
6
8
  [`*-picker` helpers](../index.md) — search, theme, locale, text size,
7
9
  and share, in that order — with two catalog-wide defaults pre-wired,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@lilydesignsystem/web-components-picker-bar",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "engines": {
5
- "node": "=26"
5
+ "node": ">=26"
6
6
  },
7
7
  "description": "Lily Design System Web Components picker bar: composes lily-link-picker (optional), lily-search-picker, lily-theme-picker, lily-locale-picker, lily-text-size-picker, and lily-share-picker into one page-header row.",
8
8
  "type": "module",
@@ -21,7 +21,10 @@
21
21
  "README.md"
22
22
  ],
23
23
  "scripts": {
24
- "prepublishOnly": "cd .. && npm run build"
24
+ "build": "node build.js",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "prepublishOnly": "npm run build"
25
28
  },
26
29
  "dependencies": {
27
30
  "@lilydesignsystem/web-components-link-picker": "^0.1.0",
@@ -29,8 +32,15 @@
29
32
  "@lilydesignsystem/web-components-theme-picker": "^0.2.0",
30
33
  "@lilydesignsystem/web-components-locale-picker": "^0.2.0",
31
34
  "@lilydesignsystem/web-components-text-size-picker": "^0.2.0",
35
+ "@lilydesignsystem/web-components-time-zone-picker": "^0.1.0",
32
36
  "@lilydesignsystem/web-components-share-picker": "^0.2.0"
33
37
  },
38
+ "devDependencies": {
39
+ "jsdom": "^30.1.1",
40
+ "tsup": "^9.0.0",
41
+ "typescript": "^5.9.3",
42
+ "vitest": "^4.1.11"
43
+ },
34
44
  "keywords": [
35
45
  "lily",
36
46
  "design",
@@ -48,7 +58,7 @@
48
58
  "license": "MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause",
49
59
  "repository": {
50
60
  "type": "git",
51
- "url": "git+https://github.com/LilyDesignSystem/lily-design-system-web-components-helpers.git",
61
+ "url": "git+https://github.com/LilyDesignSystem/lily-design-system.git",
52
62
  "directory": "lily-design-system-web-components-picker-bar"
53
63
  },
54
64
  "homepage": "https://lilydesignsystem.com/",