@lilydesignsystem/html-picker-bar 0.1.0 → 0.2.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 +18 -4
- package/dist/index.js +24 -0
- package/index.md +22 -8
- package/package.json +8 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SearchPickerProps, SearchPicker } from '@lilydesignsystem/html-search-picker';
|
|
1
2
|
import { ThemePickerProps, ThemePicker } from '@lilydesignsystem/html-theme-picker';
|
|
2
3
|
import { LocalePickerProps, LocalePicker } from '@lilydesignsystem/html-locale-picker';
|
|
3
4
|
import { TextSizePickerProps, TextSizePicker } from '@lilydesignsystem/html-text-size-picker';
|
|
@@ -11,8 +12,9 @@ export { ShareTarget } from '@lilydesignsystem/html-share-picker';
|
|
|
11
12
|
* the custom-element class but does NOT register it. The `index.ts`
|
|
12
13
|
* barrel registers it on import.
|
|
13
14
|
*
|
|
14
|
-
* A thin composition: renders `<
|
|
15
|
-
* `<text-size-picker>`, and `<share-picker>` —
|
|
15
|
+
* A thin composition: renders `<search-picker>`, `<theme-picker>`,
|
|
16
|
+
* `<locale-picker>`, `<text-size-picker>`, and `<share-picker>` — in
|
|
17
|
+
* that order, search first — each imported from its
|
|
16
18
|
* own published package, not vendored — inside one
|
|
17
19
|
* `<div class="picker-bar {class}">` row. Owns no lifecycle of its
|
|
18
20
|
* own beyond two catalog-specific defaults (§5.1, §5.2 of the spec).
|
|
@@ -33,8 +35,14 @@ declare const DEFAULT_THEMES: string[];
|
|
|
33
35
|
* either.
|
|
34
36
|
*/
|
|
35
37
|
declare const DEFAULT_SIZES: string[];
|
|
36
|
-
/** Accessible names for the
|
|
38
|
+
/** Accessible names for the five pickers. Required — no English default. */
|
|
37
39
|
type PickerBarLabels = {
|
|
40
|
+
/** Accessible name for the search picker's button and search landmark. */
|
|
41
|
+
search: string;
|
|
42
|
+
/** Accessible name for the search picker's text field. */
|
|
43
|
+
searchInput: string;
|
|
44
|
+
/** Accessible name for the search picker's ⏎ submit button. */
|
|
45
|
+
searchSubmit: string;
|
|
38
46
|
/** Accessible name for the theme picker's button and listbox. */
|
|
39
47
|
theme: string;
|
|
40
48
|
/** Accessible name for the locale picker's button and listbox. */
|
|
@@ -53,6 +61,7 @@ type PickerBarLabels = {
|
|
|
53
61
|
* so anything here overrides them. Excludes the props `<picker-bar>`
|
|
54
62
|
* already lifts to the top level.
|
|
55
63
|
*/
|
|
64
|
+
type SearchPickerExtra = Partial<Omit<SearchPickerProps, "label" | "inputLabel" | "submitLabel">>;
|
|
56
65
|
type ThemePickerExtra = Partial<Omit<ThemePickerProps, "label" | "themesUrl" | "themes">>;
|
|
57
66
|
type LocalePickerExtra = Partial<Omit<LocalePickerProps, "label" | "locales">>;
|
|
58
67
|
type TextSizePickerExtra = Partial<Omit<TextSizePickerProps, "label" | "sizes">>;
|
|
@@ -60,6 +69,7 @@ type SharePickerExtra = Partial<Omit<SharePickerProps, "label" | "targets">>;
|
|
|
60
69
|
/** Mirrors the observed attributes / properties for typing convenience. */
|
|
61
70
|
type PickerBarProps = {
|
|
62
71
|
labels: PickerBarLabels;
|
|
72
|
+
searchProps?: SearchPickerExtra;
|
|
63
73
|
themesUrl: string;
|
|
64
74
|
themes?: string[];
|
|
65
75
|
themeProps?: ThemePickerExtra;
|
|
@@ -87,6 +97,8 @@ declare class PickerBar extends HTMLElement {
|
|
|
87
97
|
set sizes(v: string[]);
|
|
88
98
|
get shareTargets(): ShareTarget[];
|
|
89
99
|
set shareTargets(v: ShareTarget[]);
|
|
100
|
+
get searchProps(): SearchPickerExtra;
|
|
101
|
+
set searchProps(v: SearchPickerExtra);
|
|
90
102
|
get themeProps(): ThemePickerExtra;
|
|
91
103
|
set themeProps(v: ThemePickerExtra);
|
|
92
104
|
get localeProps(): LocalePickerExtra;
|
|
@@ -95,6 +107,8 @@ declare class PickerBar extends HTMLElement {
|
|
|
95
107
|
set textSizeProps(v: TextSizePickerExtra);
|
|
96
108
|
get shareProps(): SharePickerExtra;
|
|
97
109
|
set shareProps(v: SharePickerExtra);
|
|
110
|
+
/** The rendered `<search-picker>` instance, once connected. */
|
|
111
|
+
get searchPicker(): SearchPicker | null;
|
|
98
112
|
/** The rendered `<theme-picker>` instance, once connected. */
|
|
99
113
|
get themePicker(): ThemePicker | null;
|
|
100
114
|
/** The rendered `<locale-picker>` instance, once connected. */
|
|
@@ -107,4 +121,4 @@ declare class PickerBar extends HTMLElement {
|
|
|
107
121
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
export { DEFAULT_SIZES, DEFAULT_THEMES, type LocalePickerExtra, PickerBar, type PickerBarLabels, type PickerBarProps, type SharePickerExtra, type TextSizePickerExtra, type ThemePickerExtra };
|
|
124
|
+
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,5 @@
|
|
|
1
1
|
// lily-design-system-html-picker-bar/picker-bar.ts
|
|
2
|
+
import "@lilydesignsystem/html-search-picker";
|
|
2
3
|
import "@lilydesignsystem/html-theme-picker";
|
|
3
4
|
import "@lilydesignsystem/html-locale-picker";
|
|
4
5
|
import "@lilydesignsystem/html-text-size-picker";
|
|
@@ -60,6 +61,9 @@ var DEFAULT_SIZES = [
|
|
|
60
61
|
"smallest"
|
|
61
62
|
];
|
|
62
63
|
var DEFAULT_LABELS = {
|
|
64
|
+
search: "",
|
|
65
|
+
searchInput: "",
|
|
66
|
+
searchSubmit: "",
|
|
63
67
|
theme: "",
|
|
64
68
|
locale: "",
|
|
65
69
|
textSize: "",
|
|
@@ -78,12 +82,14 @@ var PickerBar = class extends HTMLElement {
|
|
|
78
82
|
#locales = [];
|
|
79
83
|
#sizes = DEFAULT_SIZES;
|
|
80
84
|
#shareTargets = [];
|
|
85
|
+
#searchProps = {};
|
|
81
86
|
#themeProps = {};
|
|
82
87
|
#localeProps = {};
|
|
83
88
|
#textSizeProps = {};
|
|
84
89
|
#shareProps = {};
|
|
85
90
|
// Rendered-DOM references. Null until #render() has run.
|
|
86
91
|
#rootEl = null;
|
|
92
|
+
#searchPickerEl = null;
|
|
87
93
|
#themePickerEl = null;
|
|
88
94
|
#localePickerEl = null;
|
|
89
95
|
#textSizePickerEl = null;
|
|
@@ -145,6 +151,13 @@ var PickerBar = class extends HTMLElement {
|
|
|
145
151
|
this.#shareTargets = Array.isArray(v) ? v.slice() : [];
|
|
146
152
|
this.#render();
|
|
147
153
|
}
|
|
154
|
+
get searchProps() {
|
|
155
|
+
return this.#searchProps;
|
|
156
|
+
}
|
|
157
|
+
set searchProps(v) {
|
|
158
|
+
this.#searchProps = v ?? {};
|
|
159
|
+
this.#render();
|
|
160
|
+
}
|
|
148
161
|
get themeProps() {
|
|
149
162
|
return this.#themeProps;
|
|
150
163
|
}
|
|
@@ -173,6 +186,10 @@ var PickerBar = class extends HTMLElement {
|
|
|
173
186
|
this.#shareProps = v ?? {};
|
|
174
187
|
this.#render();
|
|
175
188
|
}
|
|
189
|
+
/** The rendered `<search-picker>` instance, once connected. */
|
|
190
|
+
get searchPicker() {
|
|
191
|
+
return this.#searchPickerEl;
|
|
192
|
+
}
|
|
176
193
|
/** The rendered `<theme-picker>` instance, once connected. */
|
|
177
194
|
get themePicker() {
|
|
178
195
|
return this.#themePickerEl;
|
|
@@ -227,6 +244,12 @@ var PickerBar = class extends HTMLElement {
|
|
|
227
244
|
const extraClass = this.getAttribute("class") ?? "";
|
|
228
245
|
const root = document.createElement("div");
|
|
229
246
|
root.className = `picker-bar ${extraClass}`.trim();
|
|
247
|
+
const searchEl = document.createElement("search-picker");
|
|
248
|
+
searchEl.label = this.#labels.search;
|
|
249
|
+
searchEl.inputLabel = this.#labels.searchInput;
|
|
250
|
+
searchEl.submitLabel = this.#labels.searchSubmit;
|
|
251
|
+
Object.assign(searchEl, this.#searchProps);
|
|
252
|
+
root.appendChild(searchEl);
|
|
230
253
|
const themeEl = document.createElement("theme-picker");
|
|
231
254
|
themeEl.label = this.#labels.theme;
|
|
232
255
|
themeEl.themesUrl = this.themesUrl;
|
|
@@ -253,6 +276,7 @@ var PickerBar = class extends HTMLElement {
|
|
|
253
276
|
root.appendChild(shareEl);
|
|
254
277
|
this.replaceChildren(root);
|
|
255
278
|
this.#rootEl = root;
|
|
279
|
+
this.#searchPickerEl = searchEl;
|
|
256
280
|
this.#themePickerEl = themeEl;
|
|
257
281
|
this.#localePickerEl = localeEl;
|
|
258
282
|
this.#textSizePickerEl = textSizeEl;
|
package/index.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Lily Design System™ — HTML PickerBar
|
|
2
2
|
|
|
3
|
-
A single page-header custom element, `<picker-bar>`, that composes
|
|
4
|
-
of the Lily [`*-picker` helpers](../index.md) — theme, locale,
|
|
5
|
-
size, and share — with two catalog-wide defaults
|
|
6
|
-
drop one element into a header instead of
|
|
7
|
-
|
|
3
|
+
A single page-header custom element, `<picker-bar>`, that composes five
|
|
4
|
+
of the Lily [`*-picker` helpers](../index.md) — search, theme, locale,
|
|
5
|
+
text size, and share, in that order — with two catalog-wide defaults
|
|
6
|
+
pre-wired, so you can drop one element into a header instead of
|
|
7
|
+
assembling and configuring five.
|
|
8
8
|
|
|
9
9
|
`motion-picker` and `date-time-picker` are not part of the bar: motion
|
|
10
10
|
has no natural spot next to the other three header preferences, and
|
|
@@ -16,8 +16,8 @@ has no natural spot next to the other three header preferences, and
|
|
|
16
16
|
npm install @lilydesignsystem/html-picker-bar
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
`@lilydesignsystem/html-
|
|
20
|
-
`-text-size-picker`, and `-share-picker` install automatically as
|
|
19
|
+
`@lilydesignsystem/html-search-picker`, `-theme-picker`,
|
|
20
|
+
`-locale-picker`, `-text-size-picker`, and `-share-picker` install automatically as
|
|
21
21
|
regular dependencies — `<picker-bar>` is a thin wrapper around them,
|
|
22
22
|
not a reimplementation.
|
|
23
23
|
|
|
@@ -28,6 +28,9 @@ import "@lilydesignsystem/html-picker-bar";
|
|
|
28
28
|
|
|
29
29
|
const bar = document.createElement("picker-bar");
|
|
30
30
|
bar.labels = {
|
|
31
|
+
search: "Search this site",
|
|
32
|
+
searchInput: "Search terms",
|
|
33
|
+
searchSubmit: "Search",
|
|
31
34
|
theme: "Theme",
|
|
32
35
|
locale: "Language",
|
|
33
36
|
textSize: "Text size",
|
|
@@ -52,6 +55,9 @@ Or in markup, for the parts that fit plain attributes:
|
|
|
52
55
|
<picker-bar themes-url="/assets/themes/" locales="en,cy,gd,ga"></picker-bar>
|
|
53
56
|
<script type="module">
|
|
54
57
|
document.querySelector("picker-bar").labels = {
|
|
58
|
+
search: "Search this site",
|
|
59
|
+
searchInput: "Search terms",
|
|
60
|
+
searchSubmit: "Search",
|
|
55
61
|
theme: "Theme",
|
|
56
62
|
locale: "Language",
|
|
57
63
|
textSize: "Text size",
|
|
@@ -60,6 +66,11 @@ Or in markup, for the parts that fit plain attributes:
|
|
|
60
66
|
</script>
|
|
61
67
|
```
|
|
62
68
|
|
|
69
|
+
Search sends a query for `foo` to `/?foo` by default. `labels` carries
|
|
70
|
+
seven names: three for search (`search` names its button and search
|
|
71
|
+
landmark, `searchInput` the field, `searchSubmit` the `⏎` button) and
|
|
72
|
+
one for each other picker.
|
|
73
|
+
|
|
63
74
|
`labels` has to be set as a JS property (no honest attribute encoding
|
|
64
75
|
exists for an object), same as `shareTargets` — see
|
|
65
76
|
`<date-time-picker>`'s `labels` and `<share-picker>`'s `targets` for the
|
|
@@ -91,6 +102,7 @@ attribute — for anything beyond what `<picker-bar>` lifts to the top
|
|
|
91
102
|
level: persistence, initial value, detection, a `*Labels` override map.
|
|
92
103
|
|
|
93
104
|
```js
|
|
105
|
+
bar.searchProps = { action: "/search", placeholder: "Search…", navigate: (href) => router.push(href) };
|
|
94
106
|
bar.themeProps = { storageKey: "lily-theme", detectFromSystem: true };
|
|
95
107
|
bar.localeProps = { storageKey: "lily-locale", detectFromNavigator: true };
|
|
96
108
|
bar.textSizeProps = { storageKey: "lily-text-size" };
|
|
@@ -108,6 +120,7 @@ After `<picker-bar>` has rendered (i.e. once it's connected to the
|
|
|
108
120
|
document), each wrapped element is available as a read-only property:
|
|
109
121
|
|
|
110
122
|
```js
|
|
123
|
+
bar.searchPicker; // the <search-picker> instance
|
|
111
124
|
bar.themePicker; // the <theme-picker> instance
|
|
112
125
|
bar.localePicker; // the <locale-picker> instance
|
|
113
126
|
bar.textSizePicker; // the <text-size-picker> instance
|
|
@@ -122,7 +135,8 @@ instances of their own packages.
|
|
|
122
135
|
|
|
123
136
|
`<picker-bar>` renders no CSS of its own beyond the `picker-bar` root
|
|
124
137
|
wrapper class — style each child through its own package's class hooks
|
|
125
|
-
(`theme-picker`, `locale-picker`, `text-size-picker`,
|
|
138
|
+
(`search-picker`, `theme-picker`, `locale-picker`, `text-size-picker`,
|
|
139
|
+
`share-picker`;
|
|
126
140
|
see each package's own `index.md`). A typical header layout:
|
|
127
141
|
|
|
128
142
|
```css
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lilydesignsystem/html-picker-bar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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 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,11 @@
|
|
|
24
24
|
"prepublishOnly": "cd .. && npm run build"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@lilydesignsystem/html-
|
|
28
|
-
"@lilydesignsystem/html-
|
|
29
|
-
"@lilydesignsystem/html-
|
|
30
|
-
"@lilydesignsystem/html-
|
|
27
|
+
"@lilydesignsystem/html-search-picker": "^0.1.0",
|
|
28
|
+
"@lilydesignsystem/html-theme-picker": "^0.2.0",
|
|
29
|
+
"@lilydesignsystem/html-locale-picker": "^0.2.0",
|
|
30
|
+
"@lilydesignsystem/html-text-size-picker": "^0.2.0",
|
|
31
|
+
"@lilydesignsystem/html-share-picker": "^0.2.0"
|
|
31
32
|
},
|
|
32
33
|
"keywords": [
|
|
33
34
|
"lily",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"html",
|
|
37
38
|
"picker",
|
|
38
39
|
"picker-bar",
|
|
40
|
+
"search",
|
|
39
41
|
"theme",
|
|
40
42
|
"locale",
|
|
41
43
|
"text-size",
|