@zeyolabs/ui 2026.11.32 → 2026.11.34

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.
@@ -19,6 +19,8 @@
19
19
  import Form from '../form/Form.svelte';
20
20
  import Select from '../form/primitives/Select.svelte';
21
21
  import SkeletonText from '../skeleton/SkeletonText.svelte';
22
+ import Span from '../text/Span.svelte';
23
+ import Title from '../text/Title.svelte';
22
24
 
23
25
  /**
24
26
  * Members of the request's account (`@zeyolabs/kit/auth`): who is in it, with which policy,
@@ -49,13 +51,13 @@
49
51
  {const policyName = (key: string) => data.policies.find((p) => p.key === key)?.name ?? key}
50
52
 
51
53
  <Card gap="sm" padding="md">
52
- <h2 class="account-title">{title}</h2>
54
+ <Title level={2} size="xs">{title}</Title>
53
55
  <ul class="account-list">
54
56
  {#each data.members as member (member.userId)}
55
57
  <li>
56
58
  <div class="who">
57
- <span class="name">{member.name}</span>
58
- <span class="sub">{member.email}</span>
59
+ <Span bold>{member.name}</Span>
60
+ <Span color="tertiary" size="sm">{member.email}</Span>
59
61
  </div>
60
62
  {#if data.can.manage && member.userId !== data.me.userId && (member.policy !== 'owner' || data.me.policy === 'owner')}
61
63
  <Select
@@ -91,15 +93,15 @@
91
93
  </ul>
92
94
 
93
95
  {#if data.invites.length}
94
- <h3 class="account-subtitle">Pending invitations</h3>
96
+ <Title level={3} size="xs">Pending invitations</Title>
95
97
  <ul class="account-list">
96
98
  {#each data.invites as invite (invite.email)}
97
99
  <li>
98
100
  <div class="who">
99
- <span class="name">{invite.email}</span>
100
- <span class="sub">
101
+ <Span bold>{invite.email}</Span>
102
+ <Span color="tertiary" size="sm">
101
103
  {policyName(invite.policy)}, expires {day.format(invite.expiresAt)}
102
- </span>
104
+ </Span>
103
105
  </div>
104
106
  {#if data.can.invite}
105
107
  <Button
@@ -142,17 +144,6 @@
142
144
  </Boundary>
143
145
 
144
146
  <style>
145
- .account-title {
146
- margin: 0;
147
- font-size: var(--text-base);
148
- font-weight: 600;
149
- }
150
- .account-subtitle {
151
- margin: 4px 0 0;
152
- font-size: 12px;
153
- font-weight: 600;
154
- color: var(--txs);
155
- }
156
147
  .account-list {
157
148
  display: flex;
158
149
  flex-direction: column;
@@ -173,13 +164,6 @@
173
164
  flex-direction: column;
174
165
  min-width: 0;
175
166
  }
176
- .name {
177
- font-weight: 500;
178
- }
179
- .sub {
180
- color: var(--txt);
181
- font-size: 12px;
182
- }
183
167
  .account-list :global(.policy) {
184
168
  width: 160px;
185
169
  }
@@ -14,6 +14,8 @@
14
14
  import Checkbox from '../form/primitives/Checkbox.svelte';
15
15
  import Input from '../form/primitives/Input.svelte';
16
16
  import SkeletonText from '../skeleton/SkeletonText.svelte';
17
+ import Span from '../text/Span.svelte';
18
+ import Title from '../text/Title.svelte';
17
19
 
18
20
  /**
19
21
  * The account's policies (`@zeyolabs/kit/auth`): the built-in ones, read-only, and the
@@ -69,7 +71,7 @@
69
71
 
70
72
  <Card gap="sm" padding="md">
71
73
  <div class="head">
72
- <h2 class="policies-title">{title}</h2>
74
+ <Title level={2} size="xs">{title}</Title>
73
75
  {#if data.can.managePolicies && !draft}
74
76
  <Button onclick={() => edit()} size="sm" variant="secondary">
75
77
  <Plus size={13} /> New policy
@@ -81,12 +83,12 @@
81
83
  {#each data.policies as policy (policy.key)}
82
84
  <li>
83
85
  <div class="what">
84
- <span class="name">{policy.name}</span>
85
- <span class="sub">
86
+ <Span bold>{policy.name}</Span>
87
+ <Span color="tertiary" size="sm">
86
88
  {policy.permissions.includes('*')
87
89
  ? 'Everything'
88
90
  : policy.permissions.join(', ') || 'Nothing'}
89
- </span>
91
+ </Span>
90
92
  </div>
91
93
  {#if policy.builtIn}
92
94
  <Badge dot={false}>Built in</Badge>
@@ -150,11 +152,6 @@
150
152
  align-items: center;
151
153
  justify-content: space-between;
152
154
  }
153
- .policies-title {
154
- margin: 0;
155
- font-size: var(--text-base);
156
- font-weight: 600;
157
- }
158
155
  .policies {
159
156
  display: flex;
160
157
  flex-direction: column;
@@ -175,13 +172,6 @@
175
172
  flex-direction: column;
176
173
  min-width: 0;
177
174
  }
178
- .name {
179
- font-weight: 500;
180
- }
181
- .sub {
182
- color: var(--txt);
183
- font-size: 12px;
184
- }
185
175
  .editor {
186
176
  display: flex;
187
177
  flex-direction: column;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeyolabs/ui",
3
- "version": "2026.11.32",
3
+ "version": "2026.11.34",
4
4
  "description": "Shared Svelte 5 components, form fields and design tokens for SvelteKit 3 apps.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -27,6 +27,7 @@
27
27
  "showcase:deploy": "pnpm --filter showcase cf-deploy"
28
28
  },
29
29
  "files": [
30
+ "!**/*.test.ts",
30
31
  "account",
31
32
  "back-button",
32
33
  "badge",
@@ -67,8 +68,8 @@
67
68
  "text",
68
69
  "theme",
69
70
  "tokens.css",
70
- "typography.css",
71
- "!**/*.test.ts"
71
+ "turnstile",
72
+ "typography.css"
72
73
  ],
73
74
  "exports": {
74
75
  "./template.css": "./template.css",
@@ -128,7 +129,8 @@
128
129
  "./layout/*": "./layout/*",
129
130
  "./gallery/*": "./gallery/*",
130
131
  "./theme/theme.svelte": "./theme/theme.svelte.ts",
131
- "./theme/*": "./theme/*"
132
+ "./theme/*": "./theme/*",
133
+ "./turnstile/*": "./turnstile/*"
132
134
  },
133
135
  "peerDependencies": {
134
136
  "@zeyolabs/kit": ">=2026.11.6",
package/text/Title.svelte CHANGED
@@ -4,7 +4,7 @@
4
4
  import { BG_CLASS, type Color, COLOR_CLASS } from './color';
5
5
 
6
6
  type Level = 1 | 2 | 3 | 4 | 5 | 6;
7
- type Size = 'lg' | 'md' | 'sm' | 'xl';
7
+ type Size = 'lg' | 'md' | 'sm' | 'xl' | 'xs';
8
8
 
9
9
  const DEFAULT_SIZE: Record<Level, Size> = {
10
10
  1: 'xl',
@@ -46,7 +46,7 @@
46
46
  * default `size` below. */
47
47
  level: Level;
48
48
  maxWidth?: string;
49
- /** The look: `xl` | `lg` | `md` | `sm`. Omit it and it follows `level` (1 xl, 2 lg, 3-4 md,
49
+ /** The look: `xl` | `lg` | `md` | `sm` | `xs` (body size, for card headings). Omit it and it follows `level` (1 xl, 2 lg, 3-4 md,
50
50
  * 5-6 sm), so pass it only when the look and the tag differ. */
51
51
  size?: Size;
52
52
  /** Single-line ellipsis. Needs a bounded width from context (a flex child needs its own
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+
4
+ import { loadTurnstile } from './load';
5
+
6
+ /**
7
+ * Cloudflare Turnstile, rendered explicitly once its script has loaded. `onToken` gets each
8
+ * solved token; an expired or timed-out challenge resets itself. Bind `reset` to start over
9
+ * after the token is spent. If the script never loads, nothing renders and the server-side
10
+ * check rejects the form.
11
+ */
12
+ let {
13
+ onToken,
14
+ reset = $bindable(),
15
+ siteKey,
16
+ theme = 'auto',
17
+ }: {
18
+ onToken: (token: string) => void;
19
+ reset?: () => void;
20
+ siteKey: string;
21
+ theme?: 'auto' | 'dark' | 'light';
22
+ } = $props();
23
+
24
+ let container: HTMLDivElement;
25
+
26
+ onMount(() => {
27
+ let removed = false;
28
+ let remove = () => {};
29
+ loadTurnstile().then((turnstile) => {
30
+ if (removed || !turnstile) return;
31
+ let widgetId: string | undefined;
32
+ const restart = () => {
33
+ if (widgetId) turnstile.reset(widgetId);
34
+ };
35
+ widgetId = turnstile.render(container, {
36
+ callback: (token) => onToken(token),
37
+ 'expired-callback': restart,
38
+ 'response-field': false,
39
+ sitekey: siteKey,
40
+ theme,
41
+ 'timeout-callback': restart,
42
+ });
43
+ reset = restart;
44
+ remove = () => {
45
+ if (widgetId) turnstile.remove(widgetId);
46
+ };
47
+ });
48
+ return () => {
49
+ removed = true;
50
+ remove();
51
+ };
52
+ });
53
+ </script>
54
+
55
+ <div bind:this={container}></div>
@@ -0,0 +1,49 @@
1
+ /** The part of Cloudflare's `window.turnstile` that `Turnstile.svelte` uses. */
2
+ export type TurnstileApi = {
3
+ remove(widgetId: string): void;
4
+ render(
5
+ container: HTMLElement,
6
+ options: {
7
+ callback: (token: string) => void;
8
+ 'expired-callback': () => void;
9
+ 'response-field': boolean;
10
+ sitekey: string;
11
+ theme: 'auto' | 'dark' | 'light';
12
+ 'timeout-callback': () => void;
13
+ }
14
+ ): string | undefined;
15
+ reset(widgetId: string): void;
16
+ };
17
+
18
+ const SCRIPT_URL = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
19
+
20
+ let loading: Promise<null | TurnstileApi> | undefined;
21
+
22
+ function api(): null | TurnstileApi {
23
+ return (window as { turnstile?: TurnstileApi }).turnstile ?? null;
24
+ }
25
+
26
+ /**
27
+ * Cloudflare's Turnstile API, loading its script once per page. Null when the script fails to
28
+ * load or loads without defining `window.turnstile` (blocked, rewritten by an extension or a bot).
29
+ */
30
+ export function loadTurnstile(): Promise<null | TurnstileApi> {
31
+ if (api()) return Promise.resolve(api());
32
+ loading ??= new Promise((resolve) => {
33
+ const script = document.createElement('script');
34
+ script.src = SCRIPT_URL;
35
+ script.async = true;
36
+ script.addEventListener('load', () => resolve(api()), { once: true });
37
+ script.addEventListener(
38
+ 'error',
39
+ () => {
40
+ loading = undefined;
41
+ script.remove();
42
+ resolve(null);
43
+ },
44
+ { once: true }
45
+ );
46
+ document.head.append(script);
47
+ });
48
+ return loading;
49
+ }
package/typography.css CHANGED
@@ -117,6 +117,14 @@
117
117
  letter-spacing: -0.01em;
118
118
  }
119
119
 
120
+ /* Body size, semibold: card and panel headings in dense pages. */
121
+ .title-xs {
122
+ font-size: var(--text-base, 13px);
123
+ font-weight: 600;
124
+ line-height: 1.5;
125
+ letter-spacing: 0;
126
+ }
127
+
120
128
  .xs {
121
129
  font-size: 11px;
122
130
  letter-spacing: 0.01em;