@lilydesignsystem/web-components-picker-bar 0.1.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { LinkItem, LinkPickerProps, LinkPicker } from '@lilydesignsystem/web-components-link-picker';
2
+ import { SearchPickerProps } from '@lilydesignsystem/web-components-search-picker';
1
3
  import { ThemePickerProps } from '@lilydesignsystem/web-components-theme-picker';
2
4
  import { LocalePickerProps } from '@lilydesignsystem/web-components-locale-picker';
3
5
  import { TextSizePickerProps } from '@lilydesignsystem/web-components-text-size-picker';
@@ -10,9 +12,10 @@ import { ShareTarget, SharePickerProps } from '@lilydesignsystem/web-components-
10
12
  * the custom-element class but does NOT register it. The `index.ts`
11
13
  * barrel registers it on import.
12
14
  *
13
- * A thin composition wrapper: it renders `<lily-theme-picker>`,
14
- * `<lily-locale-picker>`, `<lily-text-size-picker>`, and
15
- * `<lily-share-picker>` — each depended on as a real npm package, not
15
+ * A thin composition wrapper: it renders `<lily-search-picker>`,
16
+ * `<lily-theme-picker>`, `<lily-locale-picker>`,
17
+ * `<lily-text-size-picker>`, and `<lily-share-picker>` — search first,
18
+ * each depended on as a real npm package, not
16
19
  * vendored — in that fixed order, with two catalog-specific defaults
17
20
  * pre-wired (§5.1, §5.2 of the spec). It owns no interaction of its
18
21
  * own: no listbox, no keyboard handling, no applied/persisted state.
@@ -35,6 +38,17 @@ declare const DEFAULT_THEMES: string[];
35
38
  declare const DEFAULT_SIZES: string[];
36
39
  /** Accessible names for the four pickers. Required — no English default. */
37
40
  type PickerBarLabels = {
41
+ /**
42
+ * Accessible name for the link picker's button and list. Needed only when `links` is
43
+ * supplied; the link picker renders only when both are present.
44
+ */
45
+ link?: string;
46
+ /** Accessible name for the search picker's button and search landmark. */
47
+ search: string;
48
+ /** Accessible name for the search picker's text field. */
49
+ searchInput: string;
50
+ /** Accessible name for the search picker's ⏎ submit button. */
51
+ searchSubmit: string;
38
52
  /** Accessible name for the theme picker's button and listbox. */
39
53
  theme: string;
40
54
  /** Accessible name for the locale picker's button and listbox. */
@@ -48,6 +62,12 @@ type PickerBarLabels = {
48
62
  type PickerBarProps = {
49
63
  /** Property-only — see `spec/index.md` §4.3. Required, no default. */
50
64
  labels: PickerBarLabels;
65
+ /** Property-only extra `<lily-search-picker>` config (`action`, `navigate`, `placeholder`, `onSearch`, …), applied after the bar's own. */
66
+ searchProps?: Partial<Omit<SearchPickerProps, "label" | "inputLabel" | "submitLabel">>;
67
+ /** Page links for the link picker, which renders FIRST (leftmost). Omitted or empty: no link picker. */
68
+ links?: LinkItem[];
69
+ /** Property-only extra `<lily-link-picker>` config (`onNavigate`, …), applied after this bar's own. */
70
+ linkProps?: Partial<Omit<LinkPickerProps, "label" | "links">>;
51
71
  themesUrl: string;
52
72
  themes?: string[];
53
73
  /** Property-only extra `<lily-theme-picker>` config, applied after the bar's own. */
@@ -82,6 +102,15 @@ declare class PickerBar extends HTMLElement {
82
102
  /** Property-only — `ShareTarget.href` is a function. */
83
103
  get shareTargets(): ShareTarget[];
84
104
  set shareTargets(v: ShareTarget[]);
105
+ /** Page links for the link picker (leftmost). Property-only. */
106
+ get links(): LinkItem[];
107
+ set links(v: LinkItem[]);
108
+ get linkProps(): Partial<LinkPickerProps>;
109
+ set linkProps(v: Partial<LinkPickerProps>);
110
+ /** The rendered `<lily-link-picker>` instance (null when no links). */
111
+ get linkPicker(): LinkPicker | null;
112
+ get searchProps(): Partial<SearchPickerProps>;
113
+ set searchProps(v: Partial<SearchPickerProps>);
85
114
  get themeProps(): Partial<ThemePickerProps>;
86
115
  set themeProps(v: Partial<ThemePickerProps>);
87
116
  get localeProps(): Partial<LocalePickerProps>;
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // lily-design-system-web-components-picker-bar/picker-bar.ts
2
+ import "@lilydesignsystem/web-components-link-picker";
3
+ import "@lilydesignsystem/web-components-search-picker";
2
4
  import "@lilydesignsystem/web-components-theme-picker";
3
5
  import "@lilydesignsystem/web-components-locale-picker";
4
6
  import "@lilydesignsystem/web-components-text-size-picker";
@@ -60,6 +62,9 @@ var DEFAULT_SIZES = [
60
62
  "smallest"
61
63
  ];
62
64
  var DEFAULT_LABELS = {
65
+ search: "",
66
+ searchInput: "",
67
+ searchSubmit: "",
63
68
  theme: "",
64
69
  locale: "",
65
70
  textSize: "",
@@ -77,12 +82,17 @@ var PickerBar = class extends HTMLElement {
77
82
  #sizes = [...DEFAULT_SIZES];
78
83
  #labels = { ...DEFAULT_LABELS };
79
84
  #shareTargets = [];
85
+ #links = [];
86
+ #linkProps = {};
87
+ #searchProps = {};
80
88
  #themeProps = {};
81
89
  #localeProps = {};
82
90
  #textSizeProps = {};
83
91
  #shareProps = {};
84
92
  #built = false;
85
93
  #rootEl = null;
94
+ #linkEl = null;
95
+ #searchEl = null;
86
96
  #themeEl = null;
87
97
  #localeEl = null;
88
98
  #textSizeEl = null;
@@ -136,6 +146,12 @@ var PickerBar = class extends HTMLElement {
136
146
  }
137
147
  set labels(v) {
138
148
  this.#labels = v ?? { ...DEFAULT_LABELS };
149
+ this.#syncLink();
150
+ if (this.#searchEl) {
151
+ this.#searchEl.label = this.#labels.search;
152
+ this.#searchEl.inputLabel = this.#labels.searchInput;
153
+ this.#searchEl.submitLabel = this.#labels.searchSubmit;
154
+ }
139
155
  if (this.#themeEl) this.#themeEl.label = this.#labels.theme;
140
156
  if (this.#localeEl) this.#localeEl.label = this.#labels.locale;
141
157
  if (this.#textSizeEl) this.#textSizeEl.label = this.#labels.textSize;
@@ -149,6 +165,53 @@ var PickerBar = class extends HTMLElement {
149
165
  this.#shareTargets = Array.isArray(v) ? v.slice() : [];
150
166
  if (this.#shareEl) this.#shareEl.targets = this.#shareTargets;
151
167
  }
168
+ /** Page links for the link picker (leftmost). Property-only. */
169
+ get links() {
170
+ return [...this.#links];
171
+ }
172
+ set links(v) {
173
+ this.#links = Array.isArray(v) ? v.slice() : [];
174
+ this.#syncLink();
175
+ }
176
+ get linkProps() {
177
+ return { ...this.#linkProps };
178
+ }
179
+ set linkProps(v) {
180
+ this.#linkProps = v ?? {};
181
+ if (this.#linkEl) Object.assign(this.#linkEl, this.#linkProps);
182
+ }
183
+ /** The rendered `<lily-link-picker>` instance (null when no links). */
184
+ get linkPicker() {
185
+ return this.#linkEl;
186
+ }
187
+ /**
188
+ * Create, update or remove the link picker so it is the root's first child exactly when
189
+ * `links` is non-empty and `labels.link` is set. The picker is optional, so unlike the
190
+ * other five it can appear and disappear after the bar is rendered.
191
+ */
192
+ #syncLink() {
193
+ if (!this.#rootEl) return;
194
+ const wanted = this.#links.length > 0 && !!this.#labels.link;
195
+ if (!wanted) {
196
+ this.#linkEl?.remove();
197
+ this.#linkEl = null;
198
+ return;
199
+ }
200
+ if (!this.#linkEl) {
201
+ this.#linkEl = document.createElement("lily-link-picker");
202
+ this.#rootEl.insertBefore(this.#linkEl, this.#rootEl.firstChild);
203
+ }
204
+ this.#linkEl.label = this.#labels.link;
205
+ this.#linkEl.links = this.#links;
206
+ Object.assign(this.#linkEl, this.#linkProps);
207
+ }
208
+ get searchProps() {
209
+ return { ...this.#searchProps };
210
+ }
211
+ set searchProps(v) {
212
+ this.#searchProps = v ?? {};
213
+ if (this.#searchEl) Object.assign(this.#searchEl, this.#searchProps);
214
+ }
152
215
  get themeProps() {
153
216
  return { ...this.#themeProps };
154
217
  }
@@ -221,6 +284,12 @@ var PickerBar = class extends HTMLElement {
221
284
  const root = document.createElement("div");
222
285
  root.className = `picker-bar ${extraClass}`.trim();
223
286
  this.replaceChildren(root);
287
+ const searchEl = document.createElement("lily-search-picker");
288
+ searchEl.label = this.#labels.search;
289
+ searchEl.inputLabel = this.#labels.searchInput;
290
+ searchEl.submitLabel = this.#labels.searchSubmit;
291
+ Object.assign(searchEl, this.#searchProps);
292
+ root.appendChild(searchEl);
224
293
  const themeEl = document.createElement("lily-theme-picker");
225
294
  themeEl.label = this.#labels.theme;
226
295
  themeEl.themesUrl = this.themesUrl;
@@ -246,10 +315,13 @@ var PickerBar = class extends HTMLElement {
246
315
  Object.assign(shareEl, this.#shareProps);
247
316
  root.appendChild(shareEl);
248
317
  this.#rootEl = root;
318
+ this.#searchEl = searchEl;
249
319
  this.#themeEl = themeEl;
250
320
  this.#localeEl = localeEl;
251
321
  this.#textSizeEl = textSizeEl;
252
322
  this.#shareEl = shareEl;
323
+ this.#linkEl = null;
324
+ this.#syncLink();
253
325
  }
254
326
  };
255
327
 
package/index.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Lily Design System™ — `<lily-picker-bar>`
2
2
 
3
- A single page-header row that composes four of the Lily
4
- [`*-picker` helpers](../index.md) — theme, locale, text size, and
5
- share — with two catalog-wide defaults pre-wired, so you can drop one
6
- custom element into a header instead of assembling and configuring
7
- four.
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
+ A single page-header row that composes five of the Lily
6
+ [`*-picker` helpers](../index.md) — search, theme, locale, text size,
7
+ and share, in that order — with two catalog-wide defaults pre-wired,
8
+ so you can drop one custom element into a header instead of
9
+ assembling and configuring five.
8
10
 
9
11
  `<lily-motion-picker>` and `<lily-date-time-picker>` are not part of
10
12
  the bar: motion has no natural spot next to the other three header
@@ -17,8 +19,8 @@ header control.
17
19
  npm install @lilydesignsystem/web-components-picker-bar
18
20
  ```
19
21
 
20
- `@lilydesignsystem/web-components-theme-picker`, `-locale-picker`,
21
- `-text-size-picker`, and `-share-picker` install automatically as
22
+ `@lilydesignsystem/web-components-search-picker`, `-theme-picker`,
23
+ `-locale-picker`, `-text-size-picker`, and `-share-picker` install automatically as
22
24
  regular dependencies — `<lily-picker-bar>` is a thin wrapper around
23
25
  them, not a reimplementation.
24
26
 
@@ -34,6 +36,9 @@ them, not a reimplementation.
34
36
  <script type="module">
35
37
  const bar = document.getElementById("header-picker-bar");
36
38
  bar.labels = {
39
+ search: "Search this site",
40
+ searchInput: "Search terms",
41
+ searchSubmit: "Search",
37
42
  theme: "Theme",
38
43
  locale: "Language",
39
44
  textSize: "Text size",
@@ -56,7 +61,8 @@ spec) — objects and functions cannot be expressed as HTML attributes
56
61
  `themes-url` (required) and `class` are plain attributes and can be
57
62
  written directly in HTML, as shown above.
58
63
 
59
- That's a complete, working header row: 45 themes, four locales, the
64
+ That's a complete, working header row: site search (a search for
65
+ `foo` goes to `/?foo`), 45 themes, four locales, the
60
66
  seven-step text-size scale, and one share destination plus
61
67
  copy-to-URL if you add `bar.shareProps = { copyLabel: "Copy link" }`.
62
68
 
@@ -86,6 +92,7 @@ Each wrapped picker takes a `*Props` bag for anything beyond what
86
92
  value, detection, a `*Labels` override map, a custom glyph:
87
93
 
88
94
  ```js
95
+ bar.searchProps = { action: "/search", placeholder: "Search…", navigate: (href) => router.push(href) };
89
96
  bar.themeProps = { storageKey: "lily-theme", detectFromSystem: true };
90
97
  bar.localeProps = { storageKey: "lily-locale", detectFromNavigator: true };
91
98
  bar.textSizeProps = { storageKey: "lily-text-size" };
@@ -99,7 +106,7 @@ for that picker.
99
106
 
100
107
  `<lily-picker-bar>` renders no CSS of its own class beyond the
101
108
  `picker-bar` root wrapper — style each child through its own
102
- package's class hooks (`theme-picker`, `locale-picker`,
109
+ package's class hooks (`search-picker`, `theme-picker`, `locale-picker`,
103
110
  `text-size-picker`, `share-picker`; see each package's own `index.md`).
104
111
  A typical header layout:
105
112
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@lilydesignsystem/web-components-picker-bar",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "engines": {
5
5
  "node": "=26"
6
6
  },
7
- "description": "Lily Design System - HTML custom element picker bar: composes lily-theme-picker, lily-locale-picker, lily-text-size-picker, and lily-share-picker into one page-header row.",
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",
9
9
  "main": "./dist/index.js",
10
10
  "module": "./dist/index.js",
@@ -24,10 +24,12 @@
24
24
  "prepublishOnly": "cd .. && npm run build"
25
25
  },
26
26
  "dependencies": {
27
- "@lilydesignsystem/web-components-theme-picker": "^0.1.0",
28
- "@lilydesignsystem/web-components-locale-picker": "^0.1.0",
29
- "@lilydesignsystem/web-components-text-size-picker": "^0.1.0",
30
- "@lilydesignsystem/web-components-share-picker": "^0.1.0"
27
+ "@lilydesignsystem/web-components-link-picker": "^0.1.0",
28
+ "@lilydesignsystem/web-components-search-picker": "^0.1.0",
29
+ "@lilydesignsystem/web-components-theme-picker": "^0.2.0",
30
+ "@lilydesignsystem/web-components-locale-picker": "^0.2.0",
31
+ "@lilydesignsystem/web-components-text-size-picker": "^0.2.0",
32
+ "@lilydesignsystem/web-components-share-picker": "^0.2.0"
31
33
  },
32
34
  "keywords": [
33
35
  "lily",
@@ -36,6 +38,7 @@
36
38
  "html",
37
39
  "picker",
38
40
  "picker-bar",
41
+ "search",
39
42
  "theme",
40
43
  "locale",
41
44
  "text-size",