@r2digisolutions/components 0.21.19 → 0.21.21
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/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +40 -8
- package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte.d.ts +4 -0
- package/dist/components/molecules/SegmentedControl/SegmentedControl.svelte +18 -5
- package/dist/components/molecules/SegmentedControl/SegmentedControl.svelte.d.ts +7 -1
- package/dist/components/organisms/AppShell/AppShell.svelte +10 -7
- package/package.json +1 -1
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
label?: string;
|
|
29
29
|
showLabel?: boolean;
|
|
30
30
|
showFlags?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Compact header style: language name on top, code underneath (no code badge on the right).
|
|
33
|
+
*/
|
|
34
|
+
stacked?: boolean;
|
|
31
35
|
align?: 'start' | 'end';
|
|
32
36
|
class?: string;
|
|
33
37
|
onchange?: (code: string, locale: LocaleOption) => void;
|
|
@@ -55,6 +59,7 @@
|
|
|
55
59
|
label = 'Language',
|
|
56
60
|
showLabel = false,
|
|
57
61
|
showFlags = true,
|
|
62
|
+
stacked = false,
|
|
58
63
|
align = 'end',
|
|
59
64
|
class: className = '',
|
|
60
65
|
onchange
|
|
@@ -67,7 +72,17 @@
|
|
|
67
72
|
const shortCode = $derived((current?.code ?? value).split('-')[0]?.toUpperCase() ?? '—');
|
|
68
73
|
|
|
69
74
|
const triggerSize = $derived(
|
|
70
|
-
|
|
75
|
+
stacked
|
|
76
|
+
? size === 'sm'
|
|
77
|
+
? 'min-h-9 gap-1.5 px-2.5 py-1'
|
|
78
|
+
: size === 'lg'
|
|
79
|
+
? 'min-h-11 gap-2.5 px-3.5 py-1.5'
|
|
80
|
+
: 'min-h-10 gap-2 px-3 py-1'
|
|
81
|
+
: size === 'sm'
|
|
82
|
+
? 'h-8 gap-1.5 px-2.5 text-xs'
|
|
83
|
+
: size === 'lg'
|
|
84
|
+
? 'h-11 gap-2.5 px-3.5 text-sm'
|
|
85
|
+
: 'h-9 gap-2 px-3 text-sm'
|
|
71
86
|
);
|
|
72
87
|
|
|
73
88
|
const segmentSize = $derived(
|
|
@@ -194,15 +209,32 @@
|
|
|
194
209
|
onclick={() => (open = !open)}
|
|
195
210
|
>
|
|
196
211
|
{#if showFlags && current?.flag}
|
|
197
|
-
<span class=
|
|
212
|
+
<span class={['leading-none', stacked ? 'text-sm' : 'text-base']} aria-hidden="true"
|
|
213
|
+
>{current.flag}</span
|
|
214
|
+
>
|
|
198
215
|
{:else}
|
|
199
|
-
<Globe class="h-4 w-4 text-muted" />
|
|
216
|
+
<Globe class="h-4 w-4 shrink-0 text-muted" />
|
|
217
|
+
{/if}
|
|
218
|
+
{#if stacked}
|
|
219
|
+
<span class="min-w-0 max-w-28 flex-1 text-left leading-tight" dir={current?.dir ?? 'ltr'}>
|
|
220
|
+
<span class="text-primary block truncate text-xs font-medium"
|
|
221
|
+
>{current?.label ?? value}</span
|
|
222
|
+
>
|
|
223
|
+
<span class="text-secondary block truncate text-[10px] font-semibold tracking-wide"
|
|
224
|
+
>{shortCode}</span
|
|
225
|
+
>
|
|
226
|
+
</span>
|
|
227
|
+
{:else}
|
|
228
|
+
<span class="max-w-36 truncate text-xs" dir={current?.dir ?? 'ltr'}
|
|
229
|
+
>{current?.label ?? value}</span
|
|
230
|
+
>
|
|
231
|
+
<span
|
|
232
|
+
class="rounded-md bg-surface-overlay px-1.5 py-0.5 text-[10px] font-semibold tracking-wide text-muted"
|
|
233
|
+
>
|
|
234
|
+
{shortCode}
|
|
235
|
+
</span>
|
|
200
236
|
{/if}
|
|
201
|
-
<
|
|
202
|
-
<span class="rounded-md bg-surface-overlay px-1.5 py-0.5 text-[10px] font-semibold tracking-wide text-muted">
|
|
203
|
-
{shortCode}
|
|
204
|
-
</span>
|
|
205
|
-
<ChevronDown class={['h-3.5 w-3.5 text-muted transition', open && 'rotate-180']} />
|
|
237
|
+
<ChevronDown class={['h-3.5 w-3.5 shrink-0 text-muted transition', open && 'rotate-180']} />
|
|
206
238
|
</button>
|
|
207
239
|
|
|
208
240
|
{#if open}
|
|
@@ -20,6 +20,10 @@ interface LocaleSwitcherProps {
|
|
|
20
20
|
label?: string;
|
|
21
21
|
showLabel?: boolean;
|
|
22
22
|
showFlags?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Compact header style: language name on top, code underneath (no code badge on the right).
|
|
25
|
+
*/
|
|
26
|
+
stacked?: boolean;
|
|
23
27
|
align?: 'start' | 'end';
|
|
24
28
|
class?: string;
|
|
25
29
|
onchange?: (code: string, locale: LocaleOption) => void;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
2
4
|
export interface SegmentItem {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
5
7
|
disabled?: boolean;
|
|
8
|
+
icon?: Component<{ class?: string; size?: number | string; strokeWidth?: number | string }>;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
interface SegmentedControlProps {
|
|
@@ -30,9 +33,15 @@
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
const sizeClasses = {
|
|
33
|
-
sm: 'h-7 px-2.5 text-xs',
|
|
34
|
-
md: 'h-9 px-3 text-sm',
|
|
35
|
-
lg: 'h-10 px-4 text-sm'
|
|
36
|
+
sm: 'h-7 gap-1 px-2.5 text-xs',
|
|
37
|
+
md: 'h-9 gap-1.5 px-3 text-sm',
|
|
38
|
+
lg: 'h-10 gap-1.5 px-4 text-sm'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const iconSize = {
|
|
42
|
+
sm: 12,
|
|
43
|
+
md: 14,
|
|
44
|
+
lg: 16
|
|
36
45
|
};
|
|
37
46
|
|
|
38
47
|
function select(id: string, disabled?: boolean) {
|
|
@@ -52,6 +61,7 @@
|
|
|
52
61
|
>
|
|
53
62
|
{#each items as item (item.id)}
|
|
54
63
|
{@const isActive = getActive() === item.id}
|
|
64
|
+
{@const Icon = item.icon}
|
|
55
65
|
<button
|
|
56
66
|
type="button"
|
|
57
67
|
role="radio"
|
|
@@ -59,7 +69,7 @@
|
|
|
59
69
|
disabled={item.disabled}
|
|
60
70
|
onclick={() => select(item.id, item.disabled)}
|
|
61
71
|
class={[
|
|
62
|
-
'rounded-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
|
|
72
|
+
'inline-flex items-center justify-center rounded-lg font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
|
|
63
73
|
sizeClasses[size],
|
|
64
74
|
fullWidth && 'flex-1',
|
|
65
75
|
isActive
|
|
@@ -68,7 +78,10 @@
|
|
|
68
78
|
item.disabled && 'cursor-not-allowed opacity-40'
|
|
69
79
|
]}
|
|
70
80
|
>
|
|
71
|
-
{
|
|
81
|
+
{#if Icon}
|
|
82
|
+
<Icon class="shrink-0" size={iconSize[size]} strokeWidth={2.25} />
|
|
83
|
+
{/if}
|
|
84
|
+
<span>{item.label}</span>
|
|
72
85
|
</button>
|
|
73
86
|
{/each}
|
|
74
87
|
</div>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
1
2
|
export interface SegmentItem {
|
|
2
3
|
id: string;
|
|
3
4
|
label: string;
|
|
4
5
|
disabled?: boolean;
|
|
6
|
+
icon?: Component<{
|
|
7
|
+
class?: string;
|
|
8
|
+
size?: number | string;
|
|
9
|
+
strokeWidth?: number | string;
|
|
10
|
+
}>;
|
|
5
11
|
}
|
|
6
12
|
interface SegmentedControlProps {
|
|
7
13
|
items?: SegmentItem[];
|
|
@@ -11,6 +17,6 @@ interface SegmentedControlProps {
|
|
|
11
17
|
class?: string;
|
|
12
18
|
onchange?: (id: string) => void;
|
|
13
19
|
}
|
|
14
|
-
declare const SegmentedControl:
|
|
20
|
+
declare const SegmentedControl: Component<SegmentedControlProps, {}, "value">;
|
|
15
21
|
type SegmentedControl = ReturnType<typeof SegmentedControl>;
|
|
16
22
|
export default SegmentedControl;
|
|
@@ -78,6 +78,15 @@
|
|
|
78
78
|
children
|
|
79
79
|
}: AppShellProps = $props();
|
|
80
80
|
|
|
81
|
+
// Context must be set during component init — never inside $derived (async SSR
|
|
82
|
+
// re-entry / first read would call setContext outside init → 500).
|
|
83
|
+
const sharedChrome = getSharedAppChrome();
|
|
84
|
+
try {
|
|
85
|
+
getAppChrome();
|
|
86
|
+
} catch {
|
|
87
|
+
setAppChrome(sharedChrome);
|
|
88
|
+
}
|
|
89
|
+
|
|
81
90
|
// Resolve via singleton inside deriveds so HMR / duplicate graphs stay aligned.
|
|
82
91
|
const propContextual = $derived.by((): AppShellContextual | null => {
|
|
83
92
|
if (contextualGroups.length === 0) return null;
|
|
@@ -91,14 +100,8 @@
|
|
|
91
100
|
});
|
|
92
101
|
|
|
93
102
|
const resolvedContextual = $derived.by(() => {
|
|
94
|
-
const chrome = getSharedAppChrome();
|
|
95
|
-
try {
|
|
96
|
-
getAppChrome();
|
|
97
|
-
} catch {
|
|
98
|
-
setAppChrome(chrome);
|
|
99
|
-
}
|
|
100
103
|
void getAppChromeEpoch();
|
|
101
|
-
return
|
|
104
|
+
return getSharedAppChrome().source?.() ?? propContextual;
|
|
102
105
|
});
|
|
103
106
|
const contextualKey = $derived(
|
|
104
107
|
resolvedContextual
|