@lilydesignsystem/nunjucks-picker-bar 0.2.0 → 0.4.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/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';
@@ -25,7 +27,7 @@ export { autoInit as autoInitSharePicker } from '@lilydesignsystem/nunjucks-shar
25
27
 
26
28
 
27
29
  /**
28
- * All 45 Lily reference theme slugs, in the same order as
30
+ * All 57 Lily reference theme slugs, in the same order as
29
31
  * `DEFAULT_THEMES` in picker-bar.njk. A Nunjucks macro cannot import a
30
32
  * JS constant, so the two copies are held in agreement by a test
31
33
  * rather than by delegation — the same pattern this catalog already
@@ -36,11 +38,14 @@ const DEFAULT_THEMES = [
36
38
  "abyss",
37
39
  "acid",
38
40
  "adobe-spectrum",
41
+ "ant-design",
39
42
  "aqua",
43
+ "atlassian",
40
44
  "autumn",
41
45
  "black",
42
46
  "bumblebee",
43
47
  "business",
48
+ "cappuccino",
44
49
  "caramellatte",
45
50
  "cmyk",
46
51
  "coffee",
@@ -51,23 +56,32 @@ const DEFAULT_THEMES = [
51
56
  "dim",
52
57
  "dracula",
53
58
  "emerald",
59
+ "excel",
54
60
  "fantasy",
61
+ "fluent",
55
62
  "forest",
56
63
  "garden",
64
+ "github-primer",
57
65
  "halloween",
66
+ "ibm-carbon",
58
67
  "lemonade",
59
68
  "light",
69
+ "linear",
60
70
  "lofi",
61
71
  "luxury",
62
72
  "mozilla-protocol",
63
73
  "night",
64
74
  "nord",
75
+ "notion",
65
76
  "pastel",
66
77
  "retro",
78
+ "salesforce",
79
+ "sap-fiori",
67
80
  "silk",
68
81
  "sunset",
69
82
  "synthwave",
70
83
  "valentine",
84
+ "vercel",
71
85
  "winter",
72
86
  "wireframe",
73
87
  "united-kingdom-government-digital-service",
@@ -101,11 +115,12 @@ const DEFAULT_SIZES = [
101
115
  * rendered one.
102
116
  *
103
117
  * @param {HTMLElement} root
104
- * @param {{searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
118
+ * @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
105
119
  */
106
120
  function initPickerBar(root, opts = {}) {
107
121
  if (!root) {
108
122
  return {
123
+ link: null,
109
124
  search: null,
110
125
  theme: null,
111
126
  locale: null,
@@ -114,6 +129,7 @@ function initPickerBar(root, opts = {}) {
114
129
  };
115
130
  }
116
131
  const {
132
+ linkProps = {},
117
133
  searchProps = {},
118
134
  themeProps = {},
119
135
  localeProps = {},
@@ -121,6 +137,7 @@ function initPickerBar(root, opts = {}) {
121
137
  shareProps = {},
122
138
  } = opts;
123
139
 
140
+ const linkRoot = root.querySelector("[data-lily-link-picker-root]");
124
141
  const searchRoot = root.querySelector("[data-lily-search-picker-root]");
125
142
  const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
126
143
  const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
@@ -130,6 +147,7 @@ function initPickerBar(root, opts = {}) {
130
147
  const shareRoot = root.querySelector("[data-lily-share-picker-root]");
131
148
 
132
149
  return {
150
+ link: linkRoot ? initLinkPicker(linkRoot, linkProps) : null,
133
151
  search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
134
152
  theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
135
153
  locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
@@ -143,7 +161,7 @@ function initPickerBar(root, opts = {}) {
143
161
  /**
144
162
  * Find every `[data-lily-picker-bar-root]` and wire it.
145
163
  *
146
- * @param {{searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
164
+ * @param {{linkProps?: object, searchProps?: object, themeProps?: object, localeProps?: object, textSizeProps?: object, shareProps?: object}=} opts
147
165
  * @returns {Array<ReturnType<typeof initPickerBar>>}
148
166
  */
149
167
  function autoInit(opts = {}) {
package/dist/index.js CHANGED
@@ -1,4 +1,8 @@
1
- // lily-design-system-nunjucks-picker-bar/picker-bar.client.js
1
+ // 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
@@ -23,11 +27,14 @@ var DEFAULT_THEMES = [
23
27
  "abyss",
24
28
  "acid",
25
29
  "adobe-spectrum",
30
+ "ant-design",
26
31
  "aqua",
32
+ "atlassian",
27
33
  "autumn",
28
34
  "black",
29
35
  "bumblebee",
30
36
  "business",
37
+ "cappuccino",
31
38
  "caramellatte",
32
39
  "cmyk",
33
40
  "coffee",
@@ -38,23 +45,32 @@ var DEFAULT_THEMES = [
38
45
  "dim",
39
46
  "dracula",
40
47
  "emerald",
48
+ "excel",
41
49
  "fantasy",
50
+ "fluent",
42
51
  "forest",
43
52
  "garden",
53
+ "github-primer",
44
54
  "halloween",
55
+ "ibm-carbon",
45
56
  "lemonade",
46
57
  "light",
58
+ "linear",
47
59
  "lofi",
48
60
  "luxury",
49
61
  "mozilla-protocol",
50
62
  "night",
51
63
  "nord",
64
+ "notion",
52
65
  "pastel",
53
66
  "retro",
67
+ "salesforce",
68
+ "sap-fiori",
54
69
  "silk",
55
70
  "sunset",
56
71
  "synthwave",
57
72
  "valentine",
73
+ "vercel",
58
74
  "winter",
59
75
  "wireframe",
60
76
  "united-kingdom-government-digital-service",
@@ -78,6 +94,7 @@ var DEFAULT_SIZES = [
78
94
  function initPickerBar(root, opts = {}) {
79
95
  if (!root) {
80
96
  return {
97
+ link: null,
81
98
  search: null,
82
99
  theme: null,
83
100
  locale: null,
@@ -86,12 +103,14 @@ function initPickerBar(root, opts = {}) {
86
103
  };
87
104
  }
88
105
  const {
106
+ linkProps = {},
89
107
  searchProps = {},
90
108
  themeProps = {},
91
109
  localeProps = {},
92
110
  textSizeProps = {},
93
111
  shareProps = {}
94
112
  } = opts;
113
+ const linkRoot = root.querySelector("[data-lily-link-picker-root]");
95
114
  const searchRoot = root.querySelector("[data-lily-search-picker-root]");
96
115
  const themeRoot = root.querySelector("[data-lily-theme-picker-root]");
97
116
  const localeRoot = root.querySelector("[data-lily-locale-picker-root]");
@@ -100,6 +119,7 @@ function initPickerBar(root, opts = {}) {
100
119
  );
101
120
  const shareRoot = root.querySelector("[data-lily-share-picker-root]");
102
121
  return {
122
+ link: linkRoot ? initLinkPicker(linkRoot, linkProps) : null,
103
123
  search: searchRoot ? initSearchPicker(searchRoot, searchProps) : null,
104
124
  theme: themeRoot ? initThemePicker(themeRoot, themeProps) : null,
105
125
  locale: localeRoot ? initLocalePicker(localeRoot, localeProps) : null,
@@ -118,6 +138,7 @@ export {
118
138
  DEFAULT_SIZES,
119
139
  DEFAULT_THEMES,
120
140
  autoInit,
141
+ autoInitLinkPicker,
121
142
  autoInitLocalePicker,
122
143
  autoInitSearchPicker,
123
144
  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
 
@@ -22,16 +22,17 @@
22
22
  one-line Environment setup. In this monorepo's own dev/test tree the
23
23
  same relative shape already holds: each sibling package sits at
24
24
  `../lily-design-system-nunjucks-{name}-picker/dist/{name}-picker.njk`
25
- relative to the catalog root, exactly where `node_modules` would
25
+ relative to the repository 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 %}
31
32
  {% from "lily-design-system-nunjucks-text-size-picker/dist/text-size-picker.njk" import textSizePicker %}
32
33
  {% from "lily-design-system-nunjucks-share-picker/dist/share-picker.njk" import sharePicker %}
33
34
  {#
34
- All 45 Lily reference theme slugs (see `themes/` at the repo root),
35
+ All 57 Lily reference theme slugs (see `themes/` at the repo root),
35
36
  sorted alphabetically except the United Kingdom and United States
36
37
  government/public-sector themes, which sort last as one alphabetical
37
38
  group of their own. Mirrors `theme-picker`'s own title-casing of each
@@ -42,13 +43,16 @@
42
43
  held in sync by assertion rather than by delegation.
43
44
  #}
44
45
  {%- set DEFAULT_THEMES = [
45
- "abyss", "acid", "adobe-spectrum", "aqua", "autumn", "black",
46
- "bumblebee", "business", "caramellatte", "cmyk", "coffee",
47
- "corporate", "cupcake", "cyberpunk", "dark", "dim", "dracula",
48
- "emerald", "fantasy", "forest", "garden", "halloween", "lemonade",
49
- "light", "lofi", "luxury", "mozilla-protocol", "night", "nord",
50
- "pastel", "retro", "silk", "sunset", "synthwave", "valentine",
51
- "winter", "wireframe",
46
+ "abyss", "acid", "adobe-spectrum", "ant-design", "aqua",
47
+ "atlassian", "autumn", "black", "bumblebee", "business",
48
+ "cappuccino", "caramellatte", "cmyk", "coffee", "corporate",
49
+ "cupcake", "cyberpunk", "dark", "dim", "dracula", "emerald",
50
+ "excel", "fantasy", "fluent", "forest", "garden",
51
+ "github-primer", "halloween", "ibm-carbon", "lemonade", "light",
52
+ "linear", "lofi", "luxury", "mozilla-protocol", "night", "nord",
53
+ "notion", "pastel", "retro", "salesforce", "sap-fiori", "silk",
54
+ "sunset", "synthwave", "valentine", "vercel", "winter",
55
+ "wireframe",
52
56
  "united-kingdom-government-digital-service",
53
57
  "united-kingdom-national-health-service-england-for-patients",
54
58
  "united-kingdom-national-health-service-england-for-practitioners",
@@ -68,14 +72,24 @@
68
72
  ] -%}
69
73
  {#
70
74
  Params (single `opts` object):
71
- labels — object, required: { search, searchInput,
75
+ labels — object, required: { link?, search, searchInput,
72
76
  searchSubmit, theme, locale, textSize, share }.
77
+ `link` names the link picker's button and list and is
78
+ needed only when `links` is supplied.
73
79
  The seven accessible names: `search` names the
74
80
  search picker's button and search landmark,
75
81
  `searchInput` its field, `searchSubmit` its ⏎
76
82
  button. No English default — a
77
83
  nav row this catalog invented is exactly what the
78
84
  i18n rule exists to prevent hardcoding.
85
+ links — array<object>. Page links for the link picker (a home
86
+ icon), rendered FIRST — leftmost. Defined by the app,
87
+ each { label, href, id?, current?, newTab? }. Omitted or
88
+ empty (or no `labels.link`): no link picker.
89
+ linkProps — object. Extra link-picker opts (name, id, classes,
90
+ attributes). Its function-valued options (navigate,
91
+ onNavigate) cannot pass through a macro — hand them to
92
+ picker-bar.client.js's `linkProps` instead.
79
93
  themesUrl — string, required. Forwarded to theme-picker.
80
94
  locales — array<string>, required. Forwarded to locale-picker;
81
95
  no catalog default exists.
@@ -130,6 +144,7 @@
130
144
  {%- macro pickerBar(opts) -%}
131
145
  {%- set themes = opts.themes | default(DEFAULT_THEMES) -%}
132
146
  {%- set sizes = opts.sizes | default(DEFAULT_SIZES) -%}
147
+ {%- set linkProps = opts.linkProps | default({}) -%}
133
148
  {%- set searchProps = opts.searchProps | default({}) -%}
134
149
  {%- set themeProps = opts.themeProps | default({}) -%}
135
150
  {%- set localeProps = opts.localeProps | default({}) -%}
@@ -140,6 +155,16 @@
140
155
  data-lily-picker-bar-root
141
156
  {%- if opts.attributes %}{% for k, v in opts.attributes %} {{ k }}="{{ v }}"{% endfor %}{% endif %}
142
157
  >
158
+ {%- if opts.links and opts.links.length > 0 and opts.labels.link -%}
159
+ {{ linkPicker({
160
+ label: opts.labels.link,
161
+ links: opts.links,
162
+ name: linkProps.name,
163
+ id: linkProps.id,
164
+ classes: linkProps.classes,
165
+ attributes: linkProps.attributes
166
+ }) }}
167
+ {%- endif %}
143
168
  {{ searchPicker({
144
169
  label: opts.labels.search,
145
170
  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.4.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",
@@ -22,15 +22,26 @@
22
22
  "README.md"
23
23
  ],
24
24
  "scripts": {
25
- "prepublishOnly": "cd .. && npm run build"
25
+ "build": "bash build.sh",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "prepublishOnly": "npm run build"
26
29
  },
27
30
  "dependencies": {
31
+ "@lilydesignsystem/nunjucks-link-picker": "^0.1.0",
28
32
  "@lilydesignsystem/nunjucks-search-picker": "^0.1.0",
29
33
  "@lilydesignsystem/nunjucks-theme-picker": "^0.2.0",
30
34
  "@lilydesignsystem/nunjucks-locale-picker": "^0.2.0",
31
35
  "@lilydesignsystem/nunjucks-text-size-picker": "^0.2.0",
32
36
  "@lilydesignsystem/nunjucks-share-picker": "^0.2.0"
33
37
  },
38
+ "devDependencies": {
39
+ "jsdom": "^30.1.1",
40
+ "nunjucks": "^3.2.4",
41
+ "tsup": "^8.5.1",
42
+ "typescript": "^5.9.3",
43
+ "vitest": "^5.0.3"
44
+ },
34
45
  "keywords": [
35
46
  "lily",
36
47
  "design",
@@ -48,7 +59,7 @@
48
59
  "license": "MIT OR Apache-2.0 OR GPL-2.0-only OR GPL-3.0-only OR BSD-3-Clause",
49
60
  "repository": {
50
61
  "type": "git",
51
- "url": "git+https://github.com/LilyDesignSystem/lily-design-system-nunjucks-helpers.git",
62
+ "url": "git+https://github.com/LilyDesignSystem/lily-design-system.git",
52
63
  "directory": "lily-design-system-nunjucks-picker-bar"
53
64
  },
54
65
  "homepage": "https://lilydesignsystem.com/",