@zeyolabs/ui 2026.11.41 → 2026.11.42

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.
@@ -11,7 +11,7 @@
11
11
 
12
12
  <div class="faq-list">
13
13
  {#each items as item, i (item.question)}
14
- {@const open = openIdx === i}
14
+ {const open = $derived(openIdx === i)}
15
15
  <div class="faq-item" class:faq-open={open}>
16
16
  <button
17
17
  class="faq-q"
@@ -21,7 +21,7 @@
21
21
  {#if label}<div class="label">{label}</div>{/if}
22
22
  <div class="chips">
23
23
  {#each chips as chip (chip.value)}
24
- {@const on = selected.includes(chip.value)}
24
+ {const on = $derived(selected.includes(chip.value))}
25
25
  <button
26
26
  class="chip"
27
27
  class:on
@@ -88,7 +88,7 @@
88
88
  tabindex="0"
89
89
  >
90
90
  {#each visible as option, i (option.value)}
91
- {@const on = selected.includes(option.value)}
91
+ {const on = $derived(selected.includes(option.value))}
92
92
  {#if option.group && option.group !== visible[i - 1]?.group}
93
93
  <div class="group">{option.group}</div>
94
94
  {/if}
@@ -28,7 +28,7 @@
28
28
  </script>
29
29
 
30
30
  {#if icon}
31
- {@const Icon = icon}
31
+ {const Icon = $derived(icon)}
32
32
  <div class={wrapperClass}>
33
33
  <div class={iconClass}>
34
34
  <Icon class="size-5" />
@@ -25,7 +25,7 @@
25
25
  </script>
26
26
 
27
27
  {#if icon}
28
- {@const Icon = icon}
28
+ {const Icon = $derived(icon)}
29
29
  <div class="form-input-wrapper" class:sm={size === 'sm'}>
30
30
  <div class="form-input-icon" class:form-input-icon--top={iconPosition === 'top'}>
31
31
  <Icon />
@@ -21,7 +21,7 @@
21
21
  </script>
22
22
 
23
23
  {#if icon}
24
- {@const Icon = icon}
24
+ {const Icon = $derived(icon)}
25
25
  <div class="form-input-wrapper">
26
26
  <div class="form-input-icon form-input-icon--top">
27
27
  <Icon />
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import { page } from '$app/state';
3
+
4
+ import { headContext } from './context';
5
+
6
+ /**
7
+ * A page's `<head>` tags: title, description, canonical link and link-preview tags. The site's
8
+ * name, URL and share picture come from `setHeadContext` in the root layout. Renders nothing
9
+ * visible: the page's heading is its own `Title`.
10
+ */
11
+ let {
12
+ canonical,
13
+ description,
14
+ image,
15
+ title,
16
+ }: {
17
+ /** Path (or absolute URL) search engines should treat as this page. Default: the path, no query. */
18
+ canonical?: string;
19
+ description?: string;
20
+ /** This page's link-preview picture, instead of the site's. */
21
+ image?: string;
22
+ /** The page's own title; omitted, the tab shows the site name alone. */
23
+ title?: string;
24
+ } = $props();
25
+
26
+ const site = headContext();
27
+ const fullTitle = $derived(
28
+ title ? `${title}${site.separator ?? ' · '}${site.siteName}` : site.siteName
29
+ );
30
+ const url = $derived.by(() => {
31
+ if (!site.siteUrl) return null;
32
+ const path = canonical ?? page.url.pathname;
33
+ return /^https?:\/\//.test(path) ? path : `${site.siteUrl}${path}`;
34
+ });
35
+ const picture = $derived(image ?? site.shareImage);
36
+ </script>
37
+
38
+ <svelte:head>
39
+ <title>{fullTitle}</title>
40
+ {#if description}
41
+ <meta name="description" content={description} />
42
+ {/if}
43
+ {#if site.noindex}
44
+ <meta name="robots" content="noindex" />
45
+ {/if}
46
+ {#if url}
47
+ <link href={url} rel="canonical" />
48
+ <meta content={site.siteName} property="og:site_name" />
49
+ <meta content={title ?? site.siteName} property="og:title" />
50
+ {#if description}
51
+ <meta content={description} property="og:description" />
52
+ {/if}
53
+ <meta content={url} property="og:url" />
54
+ <meta content="website" property="og:type" />
55
+ {#if picture}
56
+ <meta content={picture} property="og:image" />
57
+ {/if}
58
+ {/if}
59
+ </svelte:head>
@@ -0,0 +1,27 @@
1
+ import { getContext, setContext } from 'svelte';
2
+
3
+ /** What every page's `<Head>` shares: set once in the app's root layout. */
4
+ export type HeadSite = {
5
+ /** True for apps that must stay out of search results (admins, private tools). */
6
+ noindex?: boolean;
7
+ /** Goes between the page title and the site name. Default `' · '`. */
8
+ separator?: string;
9
+ /** Absolute URL of the picture link previews show, unless a page passes its own. */
10
+ shareImage?: string;
11
+ siteName: string;
12
+ /** The public origin, e.g. `https://www.keycrox.co.uk`. Without it, no canonical or share tags. */
13
+ siteUrl?: string;
14
+ };
15
+
16
+ const KEY = Symbol.for('@zeyolabs/ui/head');
17
+
18
+ /** The site's `<Head>` settings, for every page below this layout. */
19
+ export function setHeadContext(site: HeadSite): void {
20
+ setContext(KEY, site);
21
+ }
22
+
23
+ export function headContext(): HeadSite {
24
+ const site = getContext<HeadSite | undefined>(KEY);
25
+ if (!site) throw new Error('@zeyolabs/ui/head: call setHeadContext() in the root layout');
26
+ return site;
27
+ }
@@ -60,7 +60,7 @@
60
60
  type="button"
61
61
  >
62
62
  {#if item.icon}
63
- {@const Icon = item.icon}
63
+ {const Icon = $derived(item.icon)}
64
64
  <Icon size={14} />
65
65
  {/if}
66
66
  <span>{item.label}</span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeyolabs/ui",
3
- "version": "2026.11.41",
3
+ "version": "2026.11.42",
4
4
  "description": "Shared Svelte 5 components, form fields and design tokens for SvelteKit 3 apps.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -46,6 +46,7 @@
46
46
  "form",
47
47
  "gallery",
48
48
  "grouped-grid",
49
+ "head",
49
50
  "layout",
50
51
  "list-row",
51
52
  "menu",
@@ -129,7 +130,8 @@
129
130
  "./gallery/*": "./gallery/*",
130
131
  "./theme/theme.svelte": "./theme/theme.svelte.ts",
131
132
  "./theme/*": "./theme/*",
132
- "./turnstile/*": "./turnstile/*"
133
+ "./turnstile/*": "./turnstile/*",
134
+ "./head/*": "./head/*"
133
135
  },
134
136
  "peerDependencies": {
135
137
  "@zeyolabs/kit": ">=2026.11.6",
@@ -121,11 +121,11 @@
121
121
  <div>
122
122
  <div class="flex {heightClass[height]} items-stretch gap-px">
123
123
  {#each range(maxSlots) as index (index)}
124
- {@const slot = paddedSlots[index]}
124
+ {const slot = $derived(paddedSlots[index])}
125
125
  {#if slot}
126
- {@const [key, value] = slot}
127
- {@const isDeselected = selected !== undefined && selected !== key}
128
- {@const slotColor = backgroundClass[value.color]}
126
+ {const [key, value] = $derived(slot)}
127
+ {const isDeselected = $derived(selected !== undefined && selected !== key)}
128
+ {const slotColor = $derived(backgroundClass[value.color])}
129
129
  {#if onSelect}
130
130
  <button
131
131
  class="{baseSlotClass} cursor-pointer {slotColor} transition-opacity hover:opacity-80"