@lilydesignsystem/nunjucks-picker-bar 0.2.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 { initLinkPicker } from '@lilydesignsystem/nunjucks-link-picker';
2
+ export { autoInit as autoInitLinkPicker } from '@lilydesignsystem/nunjucks-link-picker';
1
3
  import { initSearchPicker } from '@lilydesignsystem/nunjucks-search-picker';
2
4
  export { autoInit as autoInitSearchPicker } from '@lilydesignsystem/nunjucks-search-picker';
3
5
  import { initThemePicker } from '@lilydesignsystem/nunjucks-theme-picker';
@@ -101,11 +103,12 @@ const DEFAULT_SIZES = [
101
103
  * rendered one.
102
104
  *
103
105
  * @param {HTMLElement} root
104
- * @param {{searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
106
+ * @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
105
107
  */
106
108
  function initPickerBar(root, opts = {}) {
107
109
  if (!root) {
108
110
  return {
111
+ link: null,
109
112
  search: null,
110
113
  theme: null,
111
114
  locale: null,
@@ -114,6 +117,7 @@ function initPickerBar(root, opts = {}) {
114
117
  };
115
118
  }
116
119
  const {
120
+ linkProps = {},
117
121
  searchProps = {},
118
122
  themeProps = {},
119
123
  localeProps = {},
@@ -121,6 +125,7 @@ function initPickerBar(root, opts = {}) {
121
125
  shareProps = {},
122
126
  } = opts;
123
127
 
128
+ const linkRoot = root.querySelector("[data-lily-link-picker-root]");
124
129
  const searchRoot = root.querySelector("[data-lily-search-picker-root]");
125
130
  const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
126
131
  const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
@@ -130,6 +135,7 @@ function initPickerBar(root, opts = {}) {
130
135
  const shareRoot = root.querySelector("[data-lily-share-picker-root]");
131
136
 
132
137
  return {
138
+ link: linkRoot ? initLinkPicker(linkRoot, linkProps) : null,
133
139
  search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
134
140
  theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
135
141
  locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
@@ -143,7 +149,7 @@ function initPickerBar(root, opts = {}) {
143
149
  /**
144
150
  * Find every `[data-lily-picker-bar-root]` and wire it.
145
151
  *
146
- * @param {{searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
152
+ * @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
147
153
  * @returns {Array<ReturnType<typeof initPickerBar>>}
148
154
  */
149
155
  function autoInit(opts = {}) {
package/dist/index.js CHANGED
@@ -1,4 +1,8 @@
1
1
  // lily-design-system-nunjucks-picker-bar/picker-bar.client.js
2
+ import {
3
+ initLinkPicker,
4
+ autoInit as autoInitLinkPicker
5
+ } from "@lilydesignsystem/nunjucks-link-picker";
2
6
  import {
3
7
  initSearchPicker,
4
8
  autoInit as autoInitSearchPicker
@@ -78,6 +82,7 @@ var DEFAULT_SIZES = [
78
82
  function initPickerBar(root, opts = {}) {
79
83
  if (!root) {
80
84
  return {
85
+ link: null,
81
86
  search: null,
82
87
  theme: null,
83
88
  locale: null,
@@ -86,12 +91,14 @@ function initPickerBar(root, opts = {}) {
86
91
  };
87
92
  }
88
93
  const {
94
+ linkProps = {},
89
95
  searchProps = {},
90
96
  themeProps = {},
91
97
  localeProps = {},
92
98
  textSizeProps = {},
93
99
  shareProps = {}
94
100
  } = opts;
101
+ const linkRoot = root.querySelector("[data-lily-link-picker-root]");
95
102
  const searchRoot = root.querySelector("[data-lily-search-picker-root]");
96
103
  const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
97
104
  const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
@@ -100,6 +107,7 @@ function initPickerBar(root, opts = {}) {
100
107
  );
101
108
  const shareRoot = root.querySelector("[data-lily-share-picker-root]");
102
109
  return {
110
+ link: linkRoot ? initLinkPicker(linkRoot, linkProps) : null,
103
111
  search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
104
112
  theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
105
113
  locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
@@ -118,6 +126,7 @@ export {
118
126
  DEFAULT_SIZES,
119
127
  DEFAULT_THEMES,
120
128
  autoInit,
129
+ autoInitLinkPicker,
121
130
  autoInitLocalePicker,
122
131
  autoInitSearchPicker,
123
132
  autoInitSharePicker,
@@ -1,5 +1,5 @@
1
1
  {#
2
- PickerBar macro — composes search-picker, theme-picker,
2
+ PickerBar macro — composes link-picker (optional, leftmost), search-picker, theme-picker,
3
3
  locale-picker, text-size-picker, and share-picker (in that order)
4
4
  into one page-header row.
5
5
 
@@ -25,6 +25,7 @@
25
25
  relative to the catalog root, exactly where `node_modules` would
26
26
  place it after a real install.
27
27
  #}
28
+ {% from "lily-design-system-nunjucks-link-picker/dist/link-picker.njk" import linkPicker %}
28
29
  {% from "lily-design-system-nunjucks-search-picker/dist/search-picker.njk" import searchPicker %}
29
30
  {% from "lily-design-system-nunjucks-theme-picker/dist/theme-picker.njk" import themePicker %}
30
31
  {% from "lily-design-system-nunjucks-locale-picker/dist/locale-picker.njk" import localePicker %}
@@ -68,14 +69,24 @@
68
69
  ] -%}
69
70
  {#
70
71
  Params (single `opts` object):
71
- labels — object, required: { search, searchInput,
72
+ labels — object, required: { link?, search, searchInput,
72
73
  searchSubmit, theme, locale, textSize, share }.
74
+ `link` names the link picker's button and list and is
75
+ needed only when `links` is supplied.
73
76
  The seven accessible names: `search` names the
74
77
  search picker's button and search landmark,
75
78
  `searchInput` its field, `searchSubmit` its ⏎
76
79
  button. No English default — a
77
80
  nav row this catalog invented is exactly what the
78
81
  i18n rule exists to prevent hardcoding.
82
+ links — array<object>. Page links for the link picker (a home
83
+ icon), rendered FIRST — leftmost. Defined by the app,
84
+ each { label, href, id?, current?, newTab? }. Omitted or
85
+ empty (or no `labels.link`): no link picker.
86
+ linkProps — object. Extra link-picker opts (name, id, classes,
87
+ attributes). Its function-valued options (navigate,
88
+ onNavigate) cannot pass through a macro — hand them to
89
+ picker-bar.client.js's `linkProps` instead.
79
90
  themesUrl — string, required. Forwarded to theme-picker.
80
91
  locales — array<string>, required. Forwarded to locale-picker;
81
92
  no catalog default exists.
@@ -130,6 +141,7 @@
130
141
  {%- macro pickerBar(opts) -%}
131
142
  {%- set themes = opts.themes | default(DEFAULT_THEMES) -%}
132
143
  {%- set sizes = opts.sizes | default(DEFAULT_SIZES) -%}
144
+ {%- set linkProps = opts.linkProps | default({}) -%}
133
145
  {%- set searchProps = opts.searchProps | default({}) -%}
134
146
  {%- set themeProps = opts.themeProps | default({}) -%}
135
147
  {%- set localeProps = opts.localeProps | default({}) -%}
@@ -140,6 +152,16 @@
140
152
  data-lily-picker-bar-root
141
153
  {%- if opts.attributes %}{% for k, v in opts.attributes %} {{ k }}="{{ v }}"{% endfor %}{% endif %}
142
154
  >
155
+ {%- if opts.links and opts.links.length > 0 and opts.labels.link -%}
156
+ {{ linkPicker({
157
+ label: opts.labels.link,
158
+ links: opts.links,
159
+ name: linkProps.name,
160
+ id: linkProps.id,
161
+ classes: linkProps.classes,
162
+ attributes: linkProps.attributes
163
+ }) }}
164
+ {%- endif %}
143
165
  {{ searchPicker({
144
166
  label: opts.labels.search,
145
167
  inputLabel: opts.labels.searchInput,
package/index.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Lily Design System™ — Nunjucks PickerBar
2
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
+
3
5
  A single page-header macro that composes five of the Lily
4
6
  [`*-picker` helpers](../index.md) in this catalog — search, theme,
5
7
  locale, text size, and share, in that order — with two catalog-wide
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@lilydesignsystem/nunjucks-picker-bar",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "engines": {
5
5
  "node": "=26"
6
6
  },
7
- "description": "Lily Design System Nunjucks 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.",
7
+ "description": "Lily Design System Nunjucks 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",
@@ -25,6 +25,7 @@
25
25
  "prepublishOnly": "cd .. && npm run build"
26
26
  },
27
27
  "dependencies": {
28
+ "@lilydesignsystem/nunjucks-link-picker": "^0.1.0",
28
29
  "@lilydesignsystem/nunjucks-search-picker": "^0.1.0",
29
30
  "@lilydesignsystem/nunjucks-theme-picker": "^0.2.0",
30
31
  "@lilydesignsystem/nunjucks-locale-picker": "^0.2.0",