@lilydesignsystem/html-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/html-link-picker';
2
+ import { SearchPickerProps, SearchPicker } from '@lilydesignsystem/html-search-picker';
1
3
  import { ThemePickerProps, ThemePicker } from '@lilydesignsystem/html-theme-picker';
2
4
  import { LocalePickerProps, LocalePicker } from '@lilydesignsystem/html-locale-picker';
3
5
  import { TextSizePickerProps, TextSizePicker } from '@lilydesignsystem/html-text-size-picker';
@@ -11,8 +13,9 @@ export { ShareTarget } from '@lilydesignsystem/html-share-picker';
11
13
  * the custom-element class but does NOT register it. The `index.ts`
12
14
  * barrel registers it on import.
13
15
  *
14
- * A thin composition: renders `<theme-picker>`, `<locale-picker>`,
15
- * `<text-size-picker>`, and `<share-picker>` — each imported from its
16
+ * A thin composition: renders `<search-picker>`, `<theme-picker>`,
17
+ * `<locale-picker>`, `<text-size-picker>`, and `<share-picker>` — in
18
+ * that order, search first — each imported from its
16
19
  * own published package, not vendored — inside one
17
20
  * `<div class="picker-bar {class}">` row. Owns no lifecycle of its
18
21
  * own beyond two catalog-specific defaults (§5.1, §5.2 of the spec).
@@ -33,8 +36,19 @@ declare const DEFAULT_THEMES: string[];
33
36
  * either.
34
37
  */
35
38
  declare const DEFAULT_SIZES: string[];
36
- /** Accessible names for the four pickers. Required — no English default. */
39
+ /** Accessible names for the pickers. Required — no English default (`link` only when `links` is given). */
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. */
@@ -53,6 +67,8 @@ type PickerBarLabels = {
53
67
  * so anything here overrides them. Excludes the props `<picker-bar>`
54
68
  * already lifts to the top level.
55
69
  */
70
+ type LinkPickerExtra = Partial<Omit<LinkPickerProps, "label" | "links">>;
71
+ type SearchPickerExtra = Partial<Omit<SearchPickerProps, "label" | "inputLabel" | "submitLabel">>;
56
72
  type ThemePickerExtra = Partial<Omit<ThemePickerProps, "label" | "themesUrl" | "themes">>;
57
73
  type LocalePickerExtra = Partial<Omit<LocalePickerProps, "label" | "locales">>;
58
74
  type TextSizePickerExtra = Partial<Omit<TextSizePickerProps, "label" | "sizes">>;
@@ -60,6 +76,10 @@ type SharePickerExtra = Partial<Omit<SharePickerProps, "label" | "targets">>;
60
76
  /** Mirrors the observed attributes / properties for typing convenience. */
61
77
  type PickerBarProps = {
62
78
  labels: PickerBarLabels;
79
+ /** Page links for the link picker, which renders FIRST (leftmost). Omitted or empty: no link picker. */
80
+ links?: LinkItem[];
81
+ linkProps?: LinkPickerExtra;
82
+ searchProps?: SearchPickerExtra;
63
83
  themesUrl: string;
64
84
  themes?: string[];
65
85
  themeProps?: ThemePickerExtra;
@@ -87,6 +107,12 @@ declare class PickerBar extends HTMLElement {
87
107
  set sizes(v: string[]);
88
108
  get shareTargets(): ShareTarget[];
89
109
  set shareTargets(v: ShareTarget[]);
110
+ get links(): LinkItem[];
111
+ set links(v: LinkItem[]);
112
+ get linkProps(): LinkPickerExtra;
113
+ set linkProps(v: LinkPickerExtra);
114
+ get searchProps(): SearchPickerExtra;
115
+ set searchProps(v: SearchPickerExtra);
90
116
  get themeProps(): ThemePickerExtra;
91
117
  set themeProps(v: ThemePickerExtra);
92
118
  get localeProps(): LocalePickerExtra;
@@ -95,6 +121,10 @@ declare class PickerBar extends HTMLElement {
95
121
  set textSizeProps(v: TextSizePickerExtra);
96
122
  get shareProps(): SharePickerExtra;
97
123
  set shareProps(v: SharePickerExtra);
124
+ /** The rendered `<link-picker>` instance, once connected (null when no links). */
125
+ get linkPicker(): LinkPicker | null;
126
+ /** The rendered `<search-picker>` instance, once connected. */
127
+ get searchPicker(): SearchPicker | null;
98
128
  /** The rendered `<theme-picker>` instance, once connected. */
99
129
  get themePicker(): ThemePicker | null;
100
130
  /** The rendered `<locale-picker>` instance, once connected. */
@@ -107,4 +137,4 @@ declare class PickerBar extends HTMLElement {
107
137
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
108
138
  }
109
139
 
110
- export { DEFAULT_SIZES, DEFAULT_THEMES, type LocalePickerExtra, PickerBar, type PickerBarLabels, type PickerBarProps, type SharePickerExtra, type TextSizePickerExtra, type ThemePickerExtra };
140
+ export { DEFAULT_SIZES, DEFAULT_THEMES, type LocalePickerExtra, PickerBar, type PickerBarLabels, type PickerBarProps, type SearchPickerExtra, type SharePickerExtra, type TextSizePickerExtra, type ThemePickerExtra };
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // lily-design-system-html-picker-bar/picker-bar.ts
2
+ import "@lilydesignsystem/html-link-picker";
3
+ import "@lilydesignsystem/html-search-picker";
2
4
  import "@lilydesignsystem/html-theme-picker";
3
5
  import "@lilydesignsystem/html-locale-picker";
4
6
  import "@lilydesignsystem/html-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: "",
@@ -78,12 +83,17 @@ var PickerBar = class extends HTMLElement {
78
83
  #locales = [];
79
84
  #sizes = DEFAULT_SIZES;
80
85
  #shareTargets = [];
86
+ #links = [];
87
+ #linkProps = {};
88
+ #searchProps = {};
81
89
  #themeProps = {};
82
90
  #localeProps = {};
83
91
  #textSizeProps = {};
84
92
  #shareProps = {};
85
93
  // Rendered-DOM references. Null until #render() has run.
86
94
  #rootEl = null;
95
+ #linkPickerEl = null;
96
+ #searchPickerEl = null;
87
97
  #themePickerEl = null;
88
98
  #localePickerEl = null;
89
99
  #textSizePickerEl = null;
@@ -145,6 +155,27 @@ var PickerBar = class extends HTMLElement {
145
155
  this.#shareTargets = Array.isArray(v) ? v.slice() : [];
146
156
  this.#render();
147
157
  }
158
+ get links() {
159
+ return [...this.#links];
160
+ }
161
+ set links(v) {
162
+ this.#links = Array.isArray(v) ? v.slice() : [];
163
+ this.#render();
164
+ }
165
+ get linkProps() {
166
+ return this.#linkProps;
167
+ }
168
+ set linkProps(v) {
169
+ this.#linkProps = v ?? {};
170
+ this.#render();
171
+ }
172
+ get searchProps() {
173
+ return this.#searchProps;
174
+ }
175
+ set searchProps(v) {
176
+ this.#searchProps = v ?? {};
177
+ this.#render();
178
+ }
148
179
  get themeProps() {
149
180
  return this.#themeProps;
150
181
  }
@@ -173,6 +204,14 @@ var PickerBar = class extends HTMLElement {
173
204
  this.#shareProps = v ?? {};
174
205
  this.#render();
175
206
  }
207
+ /** The rendered `<link-picker>` instance, once connected (null when no links). */
208
+ get linkPicker() {
209
+ return this.#linkPickerEl;
210
+ }
211
+ /** The rendered `<search-picker>` instance, once connected. */
212
+ get searchPicker() {
213
+ return this.#searchPickerEl;
214
+ }
176
215
  /** The rendered `<theme-picker>` instance, once connected. */
177
216
  get themePicker() {
178
217
  return this.#themePickerEl;
@@ -227,6 +266,21 @@ var PickerBar = class extends HTMLElement {
227
266
  const extraClass = this.getAttribute("class") ?? "";
228
267
  const root = document.createElement("div");
229
268
  root.className = `picker-bar ${extraClass}`.trim();
269
+ this.#linkPickerEl = null;
270
+ if (this.#links.length > 0 && this.#labels.link) {
271
+ const linkEl = document.createElement("link-picker");
272
+ linkEl.label = this.#labels.link;
273
+ linkEl.links = this.#links;
274
+ Object.assign(linkEl, this.#linkProps);
275
+ root.appendChild(linkEl);
276
+ this.#linkPickerEl = linkEl;
277
+ }
278
+ const searchEl = document.createElement("search-picker");
279
+ searchEl.label = this.#labels.search;
280
+ searchEl.inputLabel = this.#labels.searchInput;
281
+ searchEl.submitLabel = this.#labels.searchSubmit;
282
+ Object.assign(searchEl, this.#searchProps);
283
+ root.appendChild(searchEl);
230
284
  const themeEl = document.createElement("theme-picker");
231
285
  themeEl.label = this.#labels.theme;
232
286
  themeEl.themesUrl = this.themesUrl;
@@ -253,6 +307,7 @@ var PickerBar = class extends HTMLElement {
253
307
  root.appendChild(shareEl);
254
308
  this.replaceChildren(root);
255
309
  this.#rootEl = root;
310
+ this.#searchPickerEl = searchEl;
256
311
  this.#themePickerEl = themeEl;
257
312
  this.#localePickerEl = localeEl;
258
313
  this.#textSizePickerEl = textSizeEl;
package/index.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Lily Design System™ — HTML PickerBar
2
2
 
3
- A single page-header custom element, `<picker-bar>`, that composes four
4
- of the Lily [`*-picker` helpers](../index.md) — theme, locale, text
5
- size, and share — with two catalog-wide defaults pre-wired, so you can
6
- drop one 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 custom element, `<picker-bar>`, that composes five
6
+ of the Lily [`*-picker` helpers](../index.md) — search, theme, locale,
7
+ text size, and share, in that order — with two catalog-wide defaults
8
+ pre-wired, so you can drop one element into a header instead of
9
+ assembling and configuring five.
8
10
 
9
11
  `motion-picker` and `date-time-picker` are not part of the bar: motion
10
12
  has no natural spot next to the other three header preferences, and
@@ -16,8 +18,8 @@ has no natural spot next to the other three header preferences, and
16
18
  npm install @lilydesignsystem/html-picker-bar
17
19
  ```
18
20
 
19
- `@lilydesignsystem/html-theme-picker`, `-locale-picker`,
20
- `-text-size-picker`, and `-share-picker` install automatically as
21
+ `@lilydesignsystem/html-search-picker`, `-theme-picker`,
22
+ `-locale-picker`, `-text-size-picker`, and `-share-picker` install automatically as
21
23
  regular dependencies — `<picker-bar>` is a thin wrapper around them,
22
24
  not a reimplementation.
23
25
 
@@ -28,6 +30,9 @@ import "@lilydesignsystem/html-picker-bar";
28
30
 
29
31
  const bar = document.createElement("picker-bar");
30
32
  bar.labels = {
33
+ search: "Search this site",
34
+ searchInput: "Search terms",
35
+ searchSubmit: "Search",
31
36
  theme: "Theme",
32
37
  locale: "Language",
33
38
  textSize: "Text size",
@@ -52,6 +57,9 @@ Or in markup, for the parts that fit plain attributes:
52
57
  <picker-bar themes-url="/assets/themes/" locales="en,cy,gd,ga"></picker-bar>
53
58
  <script type="module">
54
59
  document.querySelector("picker-bar").labels = {
60
+ search: "Search this site",
61
+ searchInput: "Search terms",
62
+ searchSubmit: "Search",
55
63
  theme: "Theme",
56
64
  locale: "Language",
57
65
  textSize: "Text size",
@@ -60,6 +68,11 @@ Or in markup, for the parts that fit plain attributes:
60
68
  </script>
61
69
  ```
62
70
 
71
+ Search sends a query for `foo` to `/?foo` by default. `labels` carries
72
+ seven names: three for search (`search` names its button and search
73
+ landmark, `searchInput` the field, `searchSubmit` the `⏎` button) and
74
+ one for each other picker.
75
+
63
76
  `labels` has to be set as a JS property (no honest attribute encoding
64
77
  exists for an object), same as `shareTargets` — see
65
78
  `<date-time-picker>`'s `labels` and `<share-picker>`'s `targets` for the
@@ -91,6 +104,7 @@ attribute — for anything beyond what `<picker-bar>` lifts to the top
91
104
  level: persistence, initial value, detection, a `*Labels` override map.
92
105
 
93
106
  ```js
107
+ bar.searchProps = { action: "/search", placeholder: "Search…", navigate: (href) => router.push(href) };
94
108
  bar.themeProps = { storageKey: "lily-theme", detectFromSystem: true };
95
109
  bar.localeProps = { storageKey: "lily-locale", detectFromNavigator: true };
96
110
  bar.textSizeProps = { storageKey: "lily-text-size" };
@@ -108,6 +122,7 @@ After `<picker-bar>` has rendered (i.e. once it's connected to the
108
122
  document), each wrapped element is available as a read-only property:
109
123
 
110
124
  ```js
125
+ bar.searchPicker; // the <search-picker> instance
111
126
  bar.themePicker; // the <theme-picker> instance
112
127
  bar.localePicker; // the <locale-picker> instance
113
128
  bar.textSizePicker; // the <text-size-picker> instance
@@ -122,7 +137,8 @@ instances of their own packages.
122
137
 
123
138
  `<picker-bar>` renders no CSS of its own beyond the `picker-bar` root
124
139
  wrapper class — style each child through its own package's class hooks
125
- (`theme-picker`, `locale-picker`, `text-size-picker`, `share-picker`;
140
+ (`search-picker`, `theme-picker`, `locale-picker`, `text-size-picker`,
141
+ `share-picker`;
126
142
  see each package's own `index.md`). A typical header layout:
127
143
 
128
144
  ```css
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@lilydesignsystem/html-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 picker bar: composes theme-picker, locale-picker, text-size-picker, and share-picker into one page-header row. Headless, SSR-safe, no CSS.",
7
+ "description": "Lily Design System HTML picker bar: composes link-picker (optional), search-picker, theme-picker, locale-picker, text-size-picker, and share-picker into one page-header row. Headless, SSR-safe, no CSS.",
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/html-theme-picker": "^0.1.0",
28
- "@lilydesignsystem/html-locale-picker": "^0.1.0",
29
- "@lilydesignsystem/html-text-size-picker": "^0.1.0",
30
- "@lilydesignsystem/html-share-picker": "^0.1.0"
27
+ "@lilydesignsystem/html-link-picker": "^0.1.0",
28
+ "@lilydesignsystem/html-search-picker": "^0.1.0",
29
+ "@lilydesignsystem/html-theme-picker": "^0.2.0",
30
+ "@lilydesignsystem/html-locale-picker": "^0.2.0",
31
+ "@lilydesignsystem/html-text-size-picker": "^0.2.0",
32
+ "@lilydesignsystem/html-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",