@r2digisolutions/components 0.21.12 → 0.21.15
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/atoms/SelectionBox/SelectionBox.svelte +51 -29
- package/dist/components/organisms/AppShell/AppShell.svelte +15 -14
- package/dist/components/organisms/AppShell/app-chrome.svelte.d.ts +12 -2
- package/dist/components/organisms/AppShell/app-chrome.svelte.js +58 -3
- package/dist/components/organisms/Sidebar/Sidebar.svelte +9 -29
- package/dist/components/organisms/Sidebar/Sidebar.svelte.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Check from '@lucide/svelte/icons/check';
|
|
3
|
+
import Minus from '@lucide/svelte/icons/minus';
|
|
4
|
+
|
|
2
5
|
export type SelectionBoxSize = 'sm' | 'md' | 'lg';
|
|
3
6
|
export type SelectionBoxTone = 'brand' | 'primary' | 'success' | 'neutral';
|
|
4
7
|
export type SelectionBoxRadius = 'sm' | 'md' | 'none';
|
|
@@ -44,6 +47,12 @@
|
|
|
44
47
|
lg: 'h-5 w-5'
|
|
45
48
|
};
|
|
46
49
|
|
|
50
|
+
const iconSizeClasses: Record<SelectionBoxSize, string> = {
|
|
51
|
+
sm: 'h-2.5 w-2.5',
|
|
52
|
+
md: 'h-3 w-3',
|
|
53
|
+
lg: 'h-3.5 w-3.5'
|
|
54
|
+
};
|
|
55
|
+
|
|
47
56
|
const radiusClasses: Record<SelectionBoxRadius, string> = {
|
|
48
57
|
none: 'rounded-none',
|
|
49
58
|
sm: 'rounded',
|
|
@@ -66,6 +75,13 @@
|
|
|
66
75
|
'checked:bg-neutral-800 checked:border-neutral-800 indeterminate:bg-neutral-800 indeterminate:border-neutral-800 hover:border-neutral-500 focus-visible:ring-neutral-500 dark:checked:bg-neutral-200 dark:checked:border-neutral-200 dark:indeterminate:bg-neutral-200 dark:indeterminate:border-neutral-200 dark:hover:border-neutral-400 dark:focus-visible:ring-neutral-400'
|
|
67
76
|
};
|
|
68
77
|
|
|
78
|
+
const toneIconColors: Record<SelectionBoxTone, string> = {
|
|
79
|
+
brand: 'text-white',
|
|
80
|
+
success: 'text-white',
|
|
81
|
+
primary: 'text-white dark:text-neutral-900',
|
|
82
|
+
neutral: 'text-white dark:text-neutral-900'
|
|
83
|
+
};
|
|
84
|
+
|
|
69
85
|
function handleChange(e: Event) {
|
|
70
86
|
const target = e.target as HTMLInputElement;
|
|
71
87
|
checked = target.checked;
|
|
@@ -86,35 +102,41 @@
|
|
|
86
102
|
className
|
|
87
103
|
]}
|
|
88
104
|
>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
<span class={['relative inline-flex shrink-0', sizeClasses[size]]}>
|
|
106
|
+
<input
|
|
107
|
+
id={inputId}
|
|
108
|
+
type="checkbox"
|
|
109
|
+
{name}
|
|
110
|
+
{value}
|
|
111
|
+
{disabled}
|
|
112
|
+
bind:checked
|
|
113
|
+
{@attach setIndeterminate}
|
|
114
|
+
class={[
|
|
115
|
+
'absolute inset-0 cursor-pointer border-2 border-border bg-surface-elevated appearance-none transition-all duration-150',
|
|
116
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
117
|
+
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
118
|
+
radiusClasses[radius],
|
|
119
|
+
toneChecked[tone]
|
|
120
|
+
]}
|
|
121
|
+
onchange={handleChange}
|
|
122
|
+
aria-label={showLabel ? undefined : label}
|
|
123
|
+
/>
|
|
124
|
+
{#if indeterminate || checked}
|
|
125
|
+
<span
|
|
126
|
+
class={[
|
|
127
|
+
'pointer-events-none absolute inset-0 z-10 flex items-center justify-center',
|
|
128
|
+
toneIconColors[tone]
|
|
129
|
+
]}
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
>
|
|
132
|
+
{#if indeterminate}
|
|
133
|
+
<Minus class={iconSizeClasses[size]} strokeWidth={3} />
|
|
134
|
+
{:else}
|
|
135
|
+
<Check class={iconSizeClasses[size]} strokeWidth={3} />
|
|
136
|
+
{/if}
|
|
137
|
+
</span>
|
|
138
|
+
{/if}
|
|
139
|
+
</span>
|
|
118
140
|
{#if label && showLabel}
|
|
119
141
|
<span class={['font-medium text-primary', labelSizeClasses[size]]}>{label}</span>
|
|
120
142
|
{:else if label}
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
import IconButton from '../../atoms/IconButton/IconButton.svelte';
|
|
7
7
|
import Badge from '../../atoms/Badge/Badge.svelte';
|
|
8
8
|
import {
|
|
9
|
-
AppChrome,
|
|
10
9
|
getAppChrome,
|
|
10
|
+
getAppChromeEpoch,
|
|
11
|
+
getSharedAppChrome,
|
|
11
12
|
setAppChrome,
|
|
12
13
|
type AppShellContextual
|
|
13
14
|
} from './app-chrome.svelte.js';
|
|
@@ -77,16 +78,7 @@
|
|
|
77
78
|
children
|
|
78
79
|
}: AppShellProps = $props();
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
return getAppChrome();
|
|
83
|
-
} catch {
|
|
84
|
-
const created = new AppChrome();
|
|
85
|
-
setAppChrome(created);
|
|
86
|
-
return created;
|
|
87
|
-
}
|
|
88
|
-
})();
|
|
89
|
-
|
|
81
|
+
// Resolve via singleton inside deriveds so HMR / duplicate graphs stay aligned.
|
|
90
82
|
const propContextual = $derived.by((): AppShellContextual | null => {
|
|
91
83
|
if (contextualGroups.length === 0) return null;
|
|
92
84
|
return {
|
|
@@ -98,11 +90,20 @@
|
|
|
98
90
|
};
|
|
99
91
|
});
|
|
100
92
|
|
|
101
|
-
const resolvedContextual = $derived
|
|
93
|
+
const resolvedContextual = $derived.by(() => {
|
|
94
|
+
const chrome = getSharedAppChrome();
|
|
95
|
+
try {
|
|
96
|
+
getAppChrome();
|
|
97
|
+
} catch {
|
|
98
|
+
setAppChrome(chrome);
|
|
99
|
+
}
|
|
100
|
+
void getAppChromeEpoch();
|
|
101
|
+
return chrome.source?.() ?? propContextual;
|
|
102
|
+
});
|
|
102
103
|
const contextualKey = $derived(
|
|
103
104
|
resolvedContextual
|
|
104
|
-
? `${resolvedContextual.parentHref ?? ''}:${resolvedContextual.brand ?? ''}:${resolvedContextual.
|
|
105
|
-
:
|
|
105
|
+
? `${getAppChromeEpoch()}:${resolvedContextual.parentHref ?? ''}:${resolvedContextual.brand ?? ''}:${resolvedContextual.groups?.map((g) => g.id).join(',') ?? ''}`
|
|
106
|
+
: `none:${getAppChromeEpoch()}`
|
|
106
107
|
);
|
|
107
108
|
const showRail = $derived(rail.length > 0 || railFooter.length > 0);
|
|
108
109
|
let mobileOpen = $state(false);
|
|
@@ -11,10 +11,20 @@ export interface AppShellContextual {
|
|
|
11
11
|
header?: Snippet;
|
|
12
12
|
onchange?: (id: string) => void;
|
|
13
13
|
}
|
|
14
|
+
export type AppChromeClear = () => void;
|
|
15
|
+
export declare function getAppChromeEpoch(): number;
|
|
14
16
|
export declare class AppChrome {
|
|
17
|
+
#private;
|
|
15
18
|
/** Live reader so nested layouts stay reactive when `[id]` is reused. */
|
|
16
19
|
source: (() => AppShellContextual | null) | null;
|
|
17
20
|
get contextual(): AppShellContextual | null;
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Register contextual sidebar. Returns a disposer that only clears if this
|
|
23
|
+
* registration is still active (safe across layout navigation races).
|
|
24
|
+
*/
|
|
25
|
+
setContextual(nav: AppShellContextual | (() => AppShellContextual | null) | null): AppChromeClear;
|
|
19
26
|
}
|
|
20
|
-
export declare
|
|
27
|
+
export declare function getSharedAppChrome(): AppChrome;
|
|
28
|
+
export declare function getAppChrome(): AppChrome;
|
|
29
|
+
/** Sets Svelte context and keeps `globalThis` in sync for duplicate module graphs. */
|
|
30
|
+
export declare function setAppChrome(chrome: AppChrome): void;
|
|
@@ -1,16 +1,71 @@
|
|
|
1
1
|
import { createContext } from 'svelte';
|
|
2
|
+
const GLOBAL_KEY = '__r2_app_chrome__';
|
|
3
|
+
const EPOCH_KEY = '__r2_app_chrome_epoch__';
|
|
4
|
+
function epochBox() {
|
|
5
|
+
const g = globalThis;
|
|
6
|
+
if (!g[EPOCH_KEY])
|
|
7
|
+
g[EPOCH_KEY] = { value: 0 };
|
|
8
|
+
return g[EPOCH_KEY];
|
|
9
|
+
}
|
|
10
|
+
/** Reactive epoch — always read via this so AppShell tracks updates across module copies. */
|
|
11
|
+
let chromeEpoch = $state(0);
|
|
12
|
+
export function getAppChromeEpoch() {
|
|
13
|
+
// Prefer module signal; sync from global so duplicate graphs still move.
|
|
14
|
+
const box = epochBox();
|
|
15
|
+
if (box.value !== chromeEpoch)
|
|
16
|
+
chromeEpoch = box.value;
|
|
17
|
+
return chromeEpoch;
|
|
18
|
+
}
|
|
19
|
+
function bumpEpoch() {
|
|
20
|
+
const box = epochBox();
|
|
21
|
+
box.value += 1;
|
|
22
|
+
chromeEpoch = box.value;
|
|
23
|
+
}
|
|
2
24
|
export class AppChrome {
|
|
3
25
|
/** Live reader so nested layouts stay reactive when `[id]` is reused. */
|
|
4
26
|
source = $state.raw(null);
|
|
27
|
+
/** Identity of the active source — cleanup no-ops if another layout already replaced it. */
|
|
28
|
+
#owner = null;
|
|
5
29
|
get contextual() {
|
|
6
30
|
return this.source?.() ?? null;
|
|
7
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Register contextual sidebar. Returns a disposer that only clears if this
|
|
34
|
+
* registration is still active (safe across layout navigation races).
|
|
35
|
+
*/
|
|
8
36
|
setContextual(nav) {
|
|
9
37
|
if (nav === null) {
|
|
10
38
|
this.source = null;
|
|
11
|
-
|
|
39
|
+
this.#owner = null;
|
|
40
|
+
bumpEpoch();
|
|
41
|
+
return () => { };
|
|
12
42
|
}
|
|
13
|
-
|
|
43
|
+
const reader = typeof nav === 'function' ? nav : () => nav;
|
|
44
|
+
this.source = reader;
|
|
45
|
+
this.#owner = reader;
|
|
46
|
+
bumpEpoch();
|
|
47
|
+
return () => {
|
|
48
|
+
if (this.#owner !== reader)
|
|
49
|
+
return;
|
|
50
|
+
this.source = null;
|
|
51
|
+
this.#owner = null;
|
|
52
|
+
bumpEpoch();
|
|
53
|
+
};
|
|
14
54
|
}
|
|
15
55
|
}
|
|
16
|
-
export
|
|
56
|
+
export function getSharedAppChrome() {
|
|
57
|
+
const g = globalThis;
|
|
58
|
+
if (!g[GLOBAL_KEY])
|
|
59
|
+
g[GLOBAL_KEY] = new AppChrome();
|
|
60
|
+
return g[GLOBAL_KEY];
|
|
61
|
+
}
|
|
62
|
+
const [getAppChromeContext, setAppChromeContext] = createContext();
|
|
63
|
+
export function getAppChrome() {
|
|
64
|
+
return getAppChromeContext();
|
|
65
|
+
}
|
|
66
|
+
/** Sets Svelte context and keeps `globalThis` in sync for duplicate module graphs. */
|
|
67
|
+
export function setAppChrome(chrome) {
|
|
68
|
+
const g = globalThis;
|
|
69
|
+
g[GLOBAL_KEY] = chrome;
|
|
70
|
+
setAppChromeContext(chrome);
|
|
71
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
href?: string;
|
|
16
16
|
icon?: SidebarIcon;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
-
/** Completed step (wizard
|
|
18
|
+
/** Completed step (wizard). Kept for a11y; no check glyph in the UI. */
|
|
19
19
|
done?: boolean;
|
|
20
20
|
/** Optional short hint (e.g. warning). */
|
|
21
21
|
hint?: string;
|
|
@@ -61,45 +61,25 @@
|
|
|
61
61
|
function itemClass(item: SidebarItem) {
|
|
62
62
|
const active = value === item.id;
|
|
63
63
|
return [
|
|
64
|
-
'relative flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm transition-colors',
|
|
64
|
+
'relative flex w-full items-center justify-start gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors',
|
|
65
65
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
|
|
66
66
|
active
|
|
67
67
|
? 'bg-surface-overlay font-medium text-primary'
|
|
68
|
-
:
|
|
69
|
-
? 'text-secondary hover:bg-surface-overlay hover:text-primary'
|
|
70
|
-
: 'text-secondary hover:bg-surface-overlay hover:text-primary',
|
|
68
|
+
: 'text-secondary hover:bg-surface-overlay hover:text-primary',
|
|
71
69
|
item.disabled && 'pointer-events-none cursor-not-allowed opacity-40',
|
|
72
70
|
collapsed && 'justify-center'
|
|
73
71
|
];
|
|
74
72
|
}
|
|
75
73
|
</script>
|
|
76
74
|
|
|
77
|
-
{#snippet checkIcon()}
|
|
78
|
-
<svg
|
|
79
|
-
class="text-brand-600 dark:text-brand-400 h-4 w-4 shrink-0"
|
|
80
|
-
viewBox="0 0 24 24"
|
|
81
|
-
fill="none"
|
|
82
|
-
stroke="currentColor"
|
|
83
|
-
stroke-width="2.25"
|
|
84
|
-
aria-hidden="true"
|
|
85
|
-
>
|
|
86
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
|
|
87
|
-
</svg>
|
|
88
|
-
{/snippet}
|
|
89
|
-
|
|
90
75
|
{#snippet itemGlyph(item: SidebarItem)}
|
|
91
|
-
{#if item.
|
|
92
|
-
{@render checkIcon()}
|
|
93
|
-
{:else if item.icon}
|
|
76
|
+
{#if item.icon}
|
|
94
77
|
<item.icon class="h-4 w-4 shrink-0" strokeWidth={1.75} />
|
|
78
|
+
{:else if !collapsed}
|
|
79
|
+
<!-- No letter tile / check — labels stay flush left like the primary nav -->
|
|
95
80
|
{:else}
|
|
96
81
|
<span
|
|
97
|
-
class=
|
|
98
|
-
'h-6 w-6 rounded-md font-semibold flex shrink-0 items-center justify-center text-[11px]',
|
|
99
|
-
item.done
|
|
100
|
-
? 'bg-brand-500/15 text-brand-700 dark:text-brand-300'
|
|
101
|
-
: 'bg-surface-overlay'
|
|
102
|
-
]}
|
|
82
|
+
class="bg-surface-overlay h-6 w-6 rounded-md font-semibold flex shrink-0 items-center justify-center text-[11px]"
|
|
103
83
|
>
|
|
104
84
|
{item.label.slice(0, 1)}
|
|
105
85
|
</span>
|
|
@@ -118,7 +98,7 @@
|
|
|
118
98
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
119
99
|
{@render itemGlyph(item)}
|
|
120
100
|
{#if !collapsed}
|
|
121
|
-
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
101
|
+
<span class="min-w-0 flex-1 truncate text-left">{item.label}</span>
|
|
122
102
|
{#if item.hint}
|
|
123
103
|
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
124
104
|
{/if}
|
|
@@ -137,7 +117,7 @@
|
|
|
137
117
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
138
118
|
{@render itemGlyph(item)}
|
|
139
119
|
{#if !collapsed}
|
|
140
|
-
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
120
|
+
<span class="min-w-0 flex-1 truncate text-left">{item.label}</span>
|
|
141
121
|
{#if item.hint}
|
|
142
122
|
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
143
123
|
{/if}
|
|
@@ -10,7 +10,7 @@ export interface SidebarItem {
|
|
|
10
10
|
href?: string;
|
|
11
11
|
icon?: SidebarIcon;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
-
/** Completed step (wizard
|
|
13
|
+
/** Completed step (wizard). Kept for a11y; no check glyph in the UI. */
|
|
14
14
|
done?: boolean;
|
|
15
15
|
/** Optional short hint (e.g. warning). */
|
|
16
16
|
hint?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -671,7 +671,7 @@ export type { BottomNavItem, BottomNavIcon } from './components/organisms/Bottom
|
|
|
671
671
|
export { default as CommandPalette } from './components/organisms/CommandPalette/CommandPalette.svelte';
|
|
672
672
|
export type { CommandItem, CommandIcon } from './components/organisms/CommandPalette/CommandPalette.svelte';
|
|
673
673
|
export { default as AppShell } from './components/organisms/AppShell/AppShell.svelte';
|
|
674
|
-
export { getAppChrome, setAppChrome, AppChrome } from './components/organisms/AppShell/app-chrome.svelte.js';
|
|
674
|
+
export { getAppChrome, getSharedAppChrome, setAppChrome, AppChrome } from './components/organisms/AppShell/app-chrome.svelte.js';
|
|
675
675
|
export type { AppShellContextual } from './components/organisms/AppShell/app-chrome.svelte.js';
|
|
676
676
|
export { default as EditorShell } from './components/organisms/EditorShell/EditorShell.svelte';
|
|
677
677
|
export { default as BlueprintEditor } from './components/organisms/BlueprintEditor/BlueprintEditor.svelte';
|
package/dist/index.js
CHANGED
|
@@ -463,7 +463,7 @@ export { default as Navbar } from './components/organisms/Navbar/Navbar.svelte';
|
|
|
463
463
|
export { default as BottomNav } from './components/organisms/BottomNav/BottomNav.svelte';
|
|
464
464
|
export { default as CommandPalette } from './components/organisms/CommandPalette/CommandPalette.svelte';
|
|
465
465
|
export { default as AppShell } from './components/organisms/AppShell/AppShell.svelte';
|
|
466
|
-
export { getAppChrome, setAppChrome, AppChrome } from './components/organisms/AppShell/app-chrome.svelte.js';
|
|
466
|
+
export { getAppChrome, getSharedAppChrome, setAppChrome, AppChrome } from './components/organisms/AppShell/app-chrome.svelte.js';
|
|
467
467
|
export { default as EditorShell } from './components/organisms/EditorShell/EditorShell.svelte';
|
|
468
468
|
export { default as BlueprintEditor } from './components/organisms/BlueprintEditor/BlueprintEditor.svelte';
|
|
469
469
|
export { default as CanvasEditor } from './components/organisms/CanvasEditor/CanvasEditor.svelte';
|