@r2digisolutions/components 0.19.17 → 0.19.19

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.
@@ -403,6 +403,7 @@
403
403
  />
404
404
  {:else if prop.field === 'fill' || prop.field === 'color' || prop.field === 'stroke' || prop.field === 'textBackground'}
405
405
  <ColorPicker
406
+ size="xs"
406
407
  value={String(current ?? '#000000')}
407
408
  showSwatches={false}
408
409
  onchange={(v) => onoverride?.({ propId: prop.id, value: v })}
@@ -463,7 +464,7 @@
463
464
  {@const slots = listFillableSlotsForInstance(doc, parentWidget?.id ?? '')}
464
465
  <PropertyField label="Fill slot">
465
466
  <Select
466
- size="sm"
467
+ size="xs"
467
468
  options={[
468
469
  { value: '', label: 'Host (default)' },
469
470
  ...slots.map((s) => ({ value: s, label: s }))
@@ -475,7 +476,7 @@
475
476
  {/if}
476
477
  <PropertyField label="Anchors">
477
478
  <Select
478
- size="sm"
479
+ size="xs"
479
480
  options={anchorOptions}
480
481
  value={currentAnchorPreset()}
481
482
  onchange={(v) => setAnchorPreset(v)}
@@ -487,7 +488,7 @@
487
488
  </p>
488
489
  <PropertyField label="Size rule">
489
490
  <Select
490
- size="sm"
491
+ size="xs"
491
492
  options={sizeRuleOptions}
492
493
  value={layer.slot?.sizeRule === 'auto' ? 'fixed' : (layer.slot?.sizeRule ?? 'fixed')}
493
494
  onchange={(v) =>
@@ -506,7 +507,7 @@
506
507
  <div class="grid grid-cols-2 gap-2">
507
508
  <PropertyField label={parentKind === 'hBox' ? 'Align Y' : 'Align X'}>
508
509
  <Select
509
- size="sm"
510
+ size="xs"
510
511
  options={alignAxisOptions}
511
512
  value={String(
512
513
  parentKind === 'hBox'
@@ -826,6 +827,7 @@
826
827
  onreset={() => resetField('shadowColor')}
827
828
  >
828
829
  <ColorPicker
830
+ size="xs"
829
831
  value={layer.shadowColor ?? '#000000'}
830
832
  showSwatches={false}
831
833
  onchange={(v) => patch({ shadowColor: v })}
@@ -884,7 +886,7 @@
884
886
  onreset={() => resetField('objectFit')}
885
887
  >
886
888
  <Select
887
- size="sm"
889
+ size="xs"
888
890
  options={fitOptions}
889
891
  value={layer.objectFit ?? 'cover'}
890
892
  onchange={(v) => patch({ objectFit: v as CanvasLayer['objectFit'] })}
@@ -957,7 +959,7 @@
957
959
  </PropertyField>
958
960
  <PropertyField label="Weight">
959
961
  <Select
960
- size="sm"
962
+ size="xs"
961
963
  options={weightOptions}
962
964
  value={String(layer.fontWeight ?? 600)}
963
965
  onchange={(v) => patch({ fontWeight: v })}
@@ -965,7 +967,7 @@
965
967
  </PropertyField>
966
968
  <PropertyField label="Style">
967
969
  <Select
968
- size="sm"
970
+ size="xs"
969
971
  options={styleOptions}
970
972
  value={layer.fontStyle ?? 'normal'}
971
973
  onchange={(v) => patch({ fontStyle: v as CanvasLayer['fontStyle'] })}
@@ -973,7 +975,7 @@
973
975
  </PropertyField>
974
976
  <PropertyField label="Decoration">
975
977
  <Select
976
- size="sm"
978
+ size="xs"
977
979
  options={decoOptions}
978
980
  value={layer.textDecoration ?? 'none'}
979
981
  onchange={(v) => patch({ textDecoration: v as CanvasLayer['textDecoration'] })}
@@ -981,7 +983,7 @@
981
983
  </PropertyField>
982
984
  <PropertyField label="Align">
983
985
  <Select
984
- size="sm"
986
+ size="xs"
985
987
  options={alignOptions}
986
988
  value={layer.textAlign ?? 'left'}
987
989
  onchange={(v) => patch({ textAlign: v as CanvasLayer['textAlign'] })}
@@ -995,6 +997,7 @@
995
997
  onreset={() => resetField('color')}
996
998
  >
997
999
  <ColorPicker
1000
+ size="xs"
998
1001
  value={layer.color ?? '#0f172a'}
999
1002
  onchange={(v) => patch({ color: v })}
1000
1003
  />
@@ -1008,6 +1011,7 @@
1008
1011
  onreset={() => resetField('textBackground')}
1009
1012
  >
1010
1013
  <ColorPicker
1014
+ size="xs"
1011
1015
  value={layer.textBackground ?? '#ffffff'}
1012
1016
  alpha
1013
1017
  onchange={(v) => patch({ textBackground: v })}
@@ -1023,6 +1027,7 @@
1023
1027
  onreset={() => resetField('fill')}
1024
1028
  >
1025
1029
  <ColorPicker
1030
+ size="xs"
1026
1031
  value={layer.fill ?? '#fef08a'}
1027
1032
  onchange={(v) => patch({ fill: v })}
1028
1033
  />
@@ -1060,6 +1065,7 @@
1060
1065
  onreset={() => resetField('fill')}
1061
1066
  >
1062
1067
  <ColorPicker
1068
+ size="xs"
1063
1069
  value={layer.fill ?? '#3b82f6'}
1064
1070
  onchange={(v) => patch({ fill: v })}
1065
1071
  />
@@ -1094,6 +1100,7 @@
1094
1100
  onreset={() => resetField('stroke')}
1095
1101
  >
1096
1102
  <ColorPicker
1103
+ size="xs"
1097
1104
  value={layer.stroke ?? '#000000'}
1098
1105
  onchange={(v) => patch({ stroke: v })}
1099
1106
  />
@@ -1149,6 +1156,7 @@
1149
1156
  {/if}
1150
1157
  <PropertyField label="Background">
1151
1158
  <ColorPicker
1159
+ size="xs"
1152
1160
  value={doc.background || '#ffffff'}
1153
1161
  alpha
1154
1162
  onchange={(v) => patchDoc({ background: v })}
@@ -2,7 +2,7 @@
2
2
  import { createId } from '../../../utils/id.js';
3
3
 
4
4
  export type ColorFormat = 'hex' | 'rgb' | 'hsl';
5
- type ColorPickerSize = 'sm' | 'md' | 'lg';
5
+ type ColorPickerSize = 'xs' | 'sm' | 'md' | 'lg';
6
6
 
7
7
  interface ColorPickerProps {
8
8
  value?: string;
@@ -49,24 +49,28 @@
49
49
  }: ColorPickerProps = $props();
50
50
 
51
51
  const triggerSizeClasses: Record<ColorPickerSize, string> = {
52
+ xs: 'h-7 gap-1.5 rounded-lg px-1.5',
52
53
  sm: 'h-8 gap-2 rounded-lg px-2',
53
54
  md: 'h-10 gap-2.5 rounded-xl px-2.5',
54
55
  lg: 'h-12 gap-3 rounded-xl px-3'
55
56
  };
56
57
 
57
58
  const swatchSizeClasses: Record<ColorPickerSize, string> = {
59
+ xs: 'h-4 w-4 rounded',
58
60
  sm: 'h-5 w-5 rounded-md',
59
61
  md: 'h-7 w-7 rounded-lg',
60
62
  lg: 'h-8 w-8 rounded-lg'
61
63
  };
62
64
 
63
65
  const valueSizeClasses: Record<ColorPickerSize, string> = {
66
+ xs: 'text-xs',
64
67
  sm: 'text-sm',
65
68
  md: 'text-sm',
66
69
  lg: 'text-base'
67
70
  };
68
71
 
69
72
  const chevronSizeClasses: Record<ColorPickerSize, string> = {
73
+ xs: 'h-3 w-3',
70
74
  sm: 'h-3.5 w-3.5',
71
75
  md: 'h-4 w-4',
72
76
  lg: 'h-4 w-4'
@@ -1,5 +1,5 @@
1
1
  export type ColorFormat = 'hex' | 'rgb' | 'hsl';
2
- type ColorPickerSize = 'sm' | 'md' | 'lg';
2
+ type ColorPickerSize = 'xs' | 'sm' | 'md' | 'lg';
3
3
  interface ColorPickerProps {
4
4
  value?: string;
5
5
  swatches?: string[];
@@ -77,12 +77,20 @@
77
77
  </span>
78
78
  {/if}
79
79
 
80
- <span class="flex min-w-0 items-center gap-0.5 truncate" title={label}>
80
+ <span class="flex min-w-0 items-center justify-start gap-0.5 text-left" title={label}>
81
+ <Text
82
+ size="xs"
83
+ tone={canReset ? 'primary' : 'secondary'}
84
+ as="span"
85
+ class={['min-w-0 flex-1 truncate font-medium', canReset && 'text-amber-700 dark:text-amber-400']}
86
+ >
87
+ {label}
88
+ </Text>
81
89
  {#if exposed !== null}
82
90
  <IconButton
83
91
  label={exposed ? 'Hide from instances' : 'Expose on instances'}
84
92
  size="xs"
85
- class={exposed ? 'text-brand-600' : 'text-muted'}
93
+ class={['shrink-0', exposed ? 'text-brand-600' : 'text-muted']}
86
94
  onclick={() => onexpose?.(!exposed)}
87
95
  >
88
96
  {#if exposed}
@@ -92,14 +100,6 @@
92
100
  {/if}
93
101
  </IconButton>
94
102
  {/if}
95
- <Text
96
- size="xs"
97
- tone={canReset ? 'primary' : 'secondary'}
98
- as="span"
99
- class={['truncate font-medium', canReset && 'text-amber-700 dark:text-amber-400']}
100
- >
101
- {label}
102
- </Text>
103
103
  </span>
104
104
 
105
105
  <div
@@ -28,7 +28,7 @@
28
28
  * and highlight it. Defaults to true.
29
29
  */
30
30
  flyToSelected?: boolean;
31
- size?: 'sm' | 'md' | 'lg';
31
+ size?: 'xs' | 'sm' | 'md' | 'lg';
32
32
  class?: string;
33
33
  onchange?: (value: string) => void;
34
34
  }
@@ -160,6 +160,7 @@
160
160
  );
161
161
 
162
162
  const sizeClasses = {
163
+ xs: 'h-7 text-xs px-2 gap-1.5 rounded-lg',
163
164
  sm: 'h-8 text-sm px-3',
164
165
  md: 'h-10 text-sm px-3.5',
165
166
  lg: 'h-12 text-base px-4'
@@ -23,7 +23,7 @@ interface SelectProps {
23
23
  * and highlight it. Defaults to true.
24
24
  */
25
25
  flyToSelected?: boolean;
26
- size?: 'sm' | 'md' | 'lg';
26
+ size?: 'xs' | 'sm' | 'md' | 'lg';
27
27
  class?: string;
28
28
  onchange?: (value: string) => void;
29
29
  }
@@ -115,6 +115,7 @@
115
115
  interface CanvasEditorProps {
116
116
  value?: CanvasDocument;
117
117
  assets?: MediaAsset[];
118
+ zoom?: number;
118
119
  class?: string;
119
120
  onchange?: (doc: CanvasDocument) => void;
120
121
  onassetschange?: (assets: MediaAsset[]) => void;
@@ -128,6 +129,7 @@
128
129
  let {
129
130
  value = $bindable(emptyCanvasDocument()),
130
131
  assets = $bindable<MediaAsset[]>([]),
132
+ zoom = $bindable(1),
131
133
  class: className = '',
132
134
  onchange,
133
135
  onassetschange,
@@ -146,7 +148,6 @@
146
148
  let showInspector = $state(true);
147
149
  let assetsSize = $state(58);
148
150
  let sidebarTab = $state<'elements' | 'uploads' | 'widgets'>('elements');
149
- let zoom = $state(1);
150
151
  let showGrid = $state(false);
151
152
  let showGuides = $state(true);
152
153
  let snap = $state(true);
@@ -4,6 +4,7 @@ import type { MediaAsset } from '../../../utils/mediaTracks.js';
4
4
  interface CanvasEditorProps {
5
5
  value?: CanvasDocument;
6
6
  assets?: MediaAsset[];
7
+ zoom?: number;
7
8
  class?: string;
8
9
  onchange?: (doc: CanvasDocument) => void;
9
10
  onassetschange?: (assets: MediaAsset[]) => void;
@@ -13,6 +14,6 @@ interface CanvasEditorProps {
13
14
  blob?: Blob;
14
15
  }) => void;
15
16
  }
16
- declare const CanvasEditor: import("svelte").Component<CanvasEditorProps, {}, "value" | "assets">;
17
+ declare const CanvasEditor: import("svelte").Component<CanvasEditorProps, {}, "value" | "zoom" | "assets">;
17
18
  type CanvasEditor = ReturnType<typeof CanvasEditor>;
18
19
  export default CanvasEditor;
@@ -6,6 +6,10 @@
6
6
  separator?: boolean;
7
7
  shortcut?: string;
8
8
  destructive?: boolean;
9
+ /** Show a leading check column (macOS / Cursor style). */
10
+ checked?: boolean;
11
+ /** Nested flyout submenu. */
12
+ children?: MenubarSubItem[];
9
13
  }
10
14
 
11
15
  export interface MenubarItem {
@@ -27,9 +31,11 @@
27
31
  }: MenubarProps = $props();
28
32
 
29
33
  let openId = $state<string | null>(null);
34
+ let flyoutId = $state<string | null>(null);
30
35
  let menubarEl = $state<HTMLElement | null>(null);
31
36
  let menuEl = $state<HTMLDivElement | null>(null);
32
37
  let menuStyle = $state('');
38
+ let highlightedId = $state<string | null>(null);
33
39
 
34
40
  function menuDomId(id: string) {
35
41
  return `menubar-menu-${id}`;
@@ -44,6 +50,8 @@
44
50
  }
45
51
  }
46
52
  openId = null;
53
+ flyoutId = null;
54
+ highlightedId = null;
47
55
  menuStyle = '';
48
56
  }
49
57
 
@@ -58,20 +66,22 @@
58
66
  const spaceBelow = window.innerHeight - rect.bottom - pad;
59
67
  const openUp = spaceBelow < menuH && rect.top > spaceBelow;
60
68
  let left = rect.left;
61
- const menuW = Math.max(200, menuEl.offsetWidth || 200);
69
+ const menuW = Math.max(220, menuEl.offsetWidth || 220);
62
70
  if (left + menuW > window.innerWidth - pad) {
63
71
  left = Math.max(pad, window.innerWidth - menuW - pad);
64
72
  }
65
73
  // inset:auto must come BEFORE top/left — shorthand would clear them
66
74
  if (openUp) {
67
- menuStyle = `position:fixed;margin:0;inset:auto;bottom:${Math.round(window.innerHeight - rect.top + 6)}px;left:${Math.round(left)}px;`;
75
+ menuStyle = `position:fixed;margin:0;inset:auto;bottom:${Math.round(window.innerHeight - rect.top + 2)}px;left:${Math.round(left)}px;`;
68
76
  } else {
69
- menuStyle = `position:fixed;margin:0;inset:auto;top:${Math.round(rect.bottom + 6)}px;left:${Math.round(left)}px;`;
77
+ menuStyle = `position:fixed;margin:0;inset:auto;top:${Math.round(rect.bottom + 2)}px;left:${Math.round(left)}px;`;
70
78
  }
71
79
  }
72
80
 
73
81
  function open(id: string) {
74
82
  openId = id;
83
+ flyoutId = null;
84
+ highlightedId = null;
75
85
  queueMicrotask(() => {
76
86
  if (!menuEl) return;
77
87
  try {
@@ -91,6 +101,7 @@
91
101
 
92
102
  function select(subItem: MenubarSubItem, parentId: string) {
93
103
  if (subItem.disabled || subItem.separator) return;
104
+ if (subItem.children?.length) return;
94
105
  onselect?.(subItem.id, parentId);
95
106
  close();
96
107
  }
@@ -118,10 +129,16 @@
118
129
  function onToggle(e: ToggleEvent) {
119
130
  if (e.newState === 'closed') {
120
131
  openId = null;
132
+ flyoutId = null;
133
+ highlightedId = null;
121
134
  menuStyle = '';
122
135
  }
123
136
  }
124
137
 
138
+ function levelHasChecks(list: MenubarSubItem[]) {
139
+ return list.some((i) => !i.separator && i.checked !== undefined);
140
+ }
141
+
125
142
  $effect(() => {
126
143
  if (!openId) return;
127
144
  const onWin = () => {
@@ -138,7 +155,87 @@
138
155
  const openItem = $derived(items.find((i) => i.id === openId) ?? null);
139
156
  </script>
140
157
 
141
- <nav bind:this={menubarEl} class={['flex items-center gap-0.5', className]} role="menubar">
158
+ {#snippet menuRows(list: MenubarSubItem[], parentId: string)}
159
+ {@const checks = levelHasChecks(list)}
160
+ {#each list as sub (sub.id)}
161
+ {#if sub.separator}
162
+ <div class="menubar-sep" role="separator"></div>
163
+ {:else}
164
+ {@const hasChildren = Boolean(sub.children?.length)}
165
+ {@const isHot = highlightedId === sub.id || flyoutId === sub.id}
166
+ <div
167
+ class="relative"
168
+ role="presentation"
169
+ onmouseenter={() => {
170
+ if (sub.disabled) return;
171
+ highlightedId = sub.id;
172
+ flyoutId = hasChildren ? sub.id : null;
173
+ }}
174
+ >
175
+ <button
176
+ type="button"
177
+ role={sub.checked !== undefined ? 'menuitemcheckbox' : 'menuitem'}
178
+ disabled={sub.disabled}
179
+ aria-disabled={sub.disabled || undefined}
180
+ aria-checked={sub.checked !== undefined ? sub.checked : undefined}
181
+ aria-haspopup={hasChildren ? 'menu' : undefined}
182
+ aria-expanded={hasChildren ? flyoutId === sub.id : undefined}
183
+ onclick={() => select(sub, parentId)}
184
+ class={[
185
+ 'menubar-item',
186
+ isHot && !sub.disabled && 'menubar-item-hot',
187
+ sub.disabled && 'menubar-item-disabled',
188
+ !sub.disabled && sub.destructive && 'menubar-item-danger',
189
+ !sub.disabled && !sub.destructive && 'menubar-item-default'
190
+ ]}
191
+ >
192
+ {#if checks}
193
+ <span class="menubar-check" aria-hidden="true">
194
+ {#if sub.checked}
195
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.75">
196
+ <path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
197
+ </svg>
198
+ {/if}
199
+ </span>
200
+ {/if}
201
+ <span class="menubar-label">{sub.label}</span>
202
+ {#if sub.shortcut && !hasChildren}
203
+ <span class="menubar-shortcut">{sub.shortcut}</span>
204
+ {:else if hasChildren}
205
+ <svg
206
+ class="menubar-chevron"
207
+ width="12"
208
+ height="12"
209
+ viewBox="0 0 24 24"
210
+ fill="none"
211
+ stroke="currentColor"
212
+ stroke-width="2.25"
213
+ aria-hidden="true"
214
+ >
215
+ <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
216
+ </svg>
217
+ {/if}
218
+ </button>
219
+
220
+ {#if hasChildren && flyoutId === sub.id && sub.children?.length}
221
+ <div
222
+ class="menubar-panel menubar-flyout"
223
+ role="menu"
224
+ tabindex="-1"
225
+ onmouseenter={() => {
226
+ flyoutId = sub.id;
227
+ highlightedId = sub.id;
228
+ }}
229
+ >
230
+ {@render menuRows(sub.children, parentId)}
231
+ </div>
232
+ {/if}
233
+ </div>
234
+ {/if}
235
+ {/each}
236
+ {/snippet}
237
+
238
+ <div bind:this={menubarEl} class={['menubar-bar flex items-center gap-px', className]} role="menubar">
142
239
  {#each items as item (item.id)}
143
240
  {@const isOpen = openId === item.id}
144
241
  <button
@@ -154,29 +251,14 @@
154
251
  }}
155
252
  onkeydown={(e) => handleMenuKeydown(e, item)}
156
253
  class={[
157
- 'flex h-7 items-center gap-1 rounded-md px-2.5 text-xs font-medium transition-colors duration-100 outline-none sm:h-8 sm:px-3 sm:text-sm',
158
- 'focus-visible:ring-2 focus-visible:ring-brand-500/30',
159
- isOpen
160
- ? 'bg-surface-overlay text-primary'
161
- : 'text-secondary hover:bg-surface-overlay hover:text-primary'
254
+ 'menubar-trigger',
255
+ isOpen ? 'menubar-trigger-open' : 'menubar-trigger-idle'
162
256
  ]}
163
257
  >
164
258
  {item.label}
165
- {#if item.items?.length}
166
- <svg
167
- class={['h-3 w-3 opacity-60 transition-transform duration-150', isOpen && 'rotate-180']}
168
- viewBox="0 0 24 24"
169
- fill="none"
170
- stroke="currentColor"
171
- stroke-width="2.5"
172
- aria-hidden="true"
173
- >
174
- <path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" />
175
- </svg>
176
- {/if}
177
259
  </button>
178
260
  {/each}
179
- </nav>
261
+ </div>
180
262
 
181
263
  <!-- Single shared menu in the top layer (native Popover) -->
182
264
  <div
@@ -184,41 +266,13 @@
184
266
  id={openId ? menuDomId(openId) : 'menubar-menu'}
185
267
  popover="auto"
186
268
  role="menu"
269
+ tabindex="-1"
187
270
  ontoggle={onToggle}
188
271
  style={menuStyle}
189
- class="menubar-popover m-0 min-w-[200px] rounded-xl border border-border bg-surface-elevated p-1.5 shadow-xl outline-none"
272
+ class="menubar-popover menubar-panel m-0 outline-none"
190
273
  >
191
274
  {#if openItem?.items?.length}
192
- {#each openItem.items as sub (sub.id)}
193
- {#if sub.separator}
194
- <div class="my-1 h-px bg-border" role="separator"></div>
195
- {:else}
196
- <button
197
- type="button"
198
- role="menuitem"
199
- disabled={sub.disabled}
200
- onclick={() => select(sub, openItem.id)}
201
- class={[
202
- 'flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-left text-sm transition-colors duration-75 outline-none',
203
- sub.disabled && 'cursor-not-allowed opacity-40',
204
- !sub.disabled &&
205
- sub.destructive &&
206
- 'text-red-500 hover:bg-red-50 dark:hover:bg-red-950/40',
207
- !sub.disabled && !sub.destructive && 'text-primary hover:bg-surface-overlay',
208
- 'focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-brand-500/30'
209
- ]}
210
- >
211
- <span class="min-w-0 flex-1 truncate">{sub.label}</span>
212
- {#if sub.shortcut}
213
- <kbd
214
- class="ml-auto shrink-0 rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[10px] text-muted"
215
- >
216
- {sub.shortcut}
217
- </kbd>
218
- {/if}
219
- </button>
220
- {/if}
221
- {/each}
275
+ {@render menuRows(openItem.items, openItem.id)}
222
276
  {/if}
223
277
  </div>
224
278
 
@@ -227,4 +281,168 @@
227
281
  .menubar-popover:popover-open {
228
282
  inset: unset;
229
283
  }
284
+
285
+ .menubar-trigger {
286
+ display: flex;
287
+ align-items: center;
288
+ height: 1.5rem;
289
+ padding: 0 0.5rem;
290
+ border-radius: 0.25rem;
291
+ font-size: 0.8125rem;
292
+ line-height: 1;
293
+ font-weight: 400;
294
+ letter-spacing: -0.01em;
295
+ outline: none;
296
+ transition: background-color 80ms ease, color 80ms ease;
297
+ }
298
+
299
+ .menubar-trigger:focus-visible {
300
+ box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-brand-500, #3b82f6) 35%, transparent);
301
+ }
302
+
303
+ .menubar-trigger-idle {
304
+ color: var(--text-secondary, var(--color-text-secondary, #737373));
305
+ }
306
+
307
+ .menubar-trigger-idle:hover {
308
+ /* text-primary is light in dark mode → soft white wash (never surface-overlay #171717) */
309
+ background: color-mix(in oklab, var(--text-primary, var(--color-text-primary, CanvasText)) 14%, transparent);
310
+ color: var(--text-primary, var(--color-text-primary, CanvasText));
311
+ }
312
+
313
+ .menubar-trigger-open {
314
+ background: color-mix(in oklab, var(--color-brand-500, #3b82f6) 22%, transparent);
315
+ color: var(--text-primary, var(--color-text-primary, CanvasText));
316
+ }
317
+
318
+ :global(.dark) .menubar-trigger-idle:hover,
319
+ :global(html.dark) .menubar-trigger-idle:hover,
320
+ :global(:root.dark) .menubar-trigger-idle:hover {
321
+ background: color-mix(in oklab, #fff 14%, transparent);
322
+ color: #fff;
323
+ }
324
+
325
+ :global(.dark) .menubar-trigger-open,
326
+ :global(html.dark) .menubar-trigger-open,
327
+ :global(:root.dark) .menubar-trigger-open {
328
+ background: color-mix(in oklab, var(--color-brand-500, #3b82f6) 32%, transparent);
329
+ color: #fff;
330
+ }
331
+
332
+ :global(.menubar-panel) {
333
+ min-width: 13.75rem;
334
+ padding: 0.25rem;
335
+ border-radius: 0.5rem;
336
+ border: 1px solid color-mix(in oklab, var(--color-border, #e5e5e5) 90%, transparent);
337
+ background: color-mix(in oklab, var(--color-surface-elevated, #fff) 88%, transparent);
338
+ backdrop-filter: blur(20px) saturate(1.4);
339
+ -webkit-backdrop-filter: blur(20px) saturate(1.4);
340
+ box-shadow:
341
+ 0 0 0 0.5px color-mix(in oklab, #000 8%, transparent),
342
+ 0 10px 40px -8px color-mix(in oklab, #000 35%, transparent),
343
+ 0 4px 12px -4px color-mix(in oklab, #000 18%, transparent);
344
+ }
345
+
346
+ :global(.dark) :global(.menubar-panel),
347
+ :global([data-theme='dark']) :global(.menubar-panel) {
348
+ border-color: color-mix(in oklab, #fff 12%, transparent);
349
+ background: color-mix(in oklab, #1c1c1e 82%, transparent);
350
+ box-shadow:
351
+ 0 0 0 0.5px color-mix(in oklab, #fff 8%, transparent),
352
+ 0 16px 48px -12px color-mix(in oklab, #000 65%, transparent),
353
+ 0 4px 16px -4px color-mix(in oklab, #000 40%, transparent);
354
+ }
355
+
356
+ :global(.menubar-flyout) {
357
+ position: absolute;
358
+ left: calc(100% - 2px);
359
+ top: -0.25rem;
360
+ z-index: 2;
361
+ }
362
+
363
+ :global(.menubar-sep) {
364
+ height: 1px;
365
+ margin: 0.25rem 0.5rem;
366
+ background: color-mix(in oklab, var(--color-border, #e5e5e5) 85%, transparent);
367
+ }
368
+
369
+ :global(.dark) :global(.menubar-sep) {
370
+ background: color-mix(in oklab, #fff 12%, transparent);
371
+ }
372
+
373
+ :global(.menubar-item) {
374
+ display: flex;
375
+ width: 100%;
376
+ align-items: center;
377
+ gap: 0.5rem;
378
+ min-height: 1.375rem;
379
+ padding: 0.2rem 0.5rem;
380
+ border-radius: 0.25rem;
381
+ font-size: 0.8125rem;
382
+ line-height: 1.2;
383
+ letter-spacing: -0.01em;
384
+ text-align: left;
385
+ outline: none;
386
+ transition: background-color 60ms ease, color 60ms ease;
387
+ }
388
+
389
+ :global(.menubar-item-default) {
390
+ color: var(--text-primary, var(--color-text-primary, #171717));
391
+ }
392
+
393
+ :global(.dark) :global(.menubar-item-default) {
394
+ color: #f5f5f5;
395
+ }
396
+
397
+ :global(.menubar-item-hot) {
398
+ background: var(--color-brand-500, #007aff) !important;
399
+ color: #fff !important;
400
+ }
401
+
402
+ :global(.menubar-item-hot) :global(.menubar-shortcut),
403
+ :global(.menubar-item-hot) :global(.menubar-chevron),
404
+ :global(.menubar-item-hot) :global(.menubar-check) {
405
+ color: color-mix(in oklab, #fff 78%, transparent) !important;
406
+ }
407
+
408
+ :global(.menubar-item-danger):not(:global(.menubar-item-hot)) {
409
+ color: #ef4444;
410
+ }
411
+
412
+ :global(.menubar-item-disabled) {
413
+ cursor: not-allowed;
414
+ opacity: 0.38;
415
+ }
416
+
417
+ :global(.menubar-check) {
418
+ display: flex;
419
+ width: 0.875rem;
420
+ height: 0.875rem;
421
+ flex-shrink: 0;
422
+ align-items: center;
423
+ justify-content: center;
424
+ }
425
+
426
+ :global(.menubar-label) {
427
+ min-width: 0;
428
+ flex: 1;
429
+ overflow: hidden;
430
+ text-overflow: ellipsis;
431
+ white-space: nowrap;
432
+ }
433
+
434
+ :global(.menubar-shortcut) {
435
+ margin-left: 1.5rem;
436
+ flex-shrink: 0;
437
+ font-size: 0.75rem;
438
+ letter-spacing: 0.02em;
439
+ color: var(--color-muted, #a3a3a3);
440
+ font-variant-numeric: tabular-nums;
441
+ }
442
+
443
+ :global(.menubar-chevron) {
444
+ margin-left: 0.75rem;
445
+ flex-shrink: 0;
446
+ opacity: 0.7;
447
+ }
230
448
  </style>
@@ -5,6 +5,10 @@ export interface MenubarSubItem {
5
5
  separator?: boolean;
6
6
  shortcut?: string;
7
7
  destructive?: boolean;
8
+ /** Show a leading check column (macOS / Cursor style). */
9
+ checked?: boolean;
10
+ /** Nested flyout submenu. */
11
+ children?: MenubarSubItem[];
8
12
  }
9
13
  export interface MenubarItem {
10
14
  id: string;
@@ -6,13 +6,40 @@
6
6
  id: 'file',
7
7
  label: 'File',
8
8
  items: [
9
- { id: 'new', label: 'New File', shortcut: '⌘N' },
10
- { id: 'open', label: 'Open...', shortcut: '⌘O' },
11
- { id: 'save', label: 'Save', shortcut: '⌘S' },
12
- { id: 'saveas', label: 'Save As...', shortcut: '⌘⇧S' },
9
+ { id: 'new-file', label: 'New Text File', shortcut: '⌘N' },
10
+ { id: 'new-window', label: 'New Window', shortcut: '⇧⌘N' },
11
+ {
12
+ id: 'new-profile',
13
+ label: 'New Window with Profile',
14
+ children: [
15
+ { id: 'profile-default', label: 'Default' },
16
+ { id: 'profile-work', label: 'Work' },
17
+ { id: 'sep-profiles', label: '', separator: true },
18
+ { id: 'profile-manage', label: 'Manage Profiles…' }
19
+ ]
20
+ },
13
21
  { id: 'sep1', label: '', separator: true },
14
- { id: 'close', label: 'Close', shortcut: '⌘W' },
15
- { id: 'quit', label: 'Quit', shortcut: '⌘Q', destructive: true }
22
+ { id: 'open', label: 'Open…', shortcut: '⌘O' },
23
+ { id: 'open-folder', label: 'Open Folder…', shortcut: '⌘K ⌘O' },
24
+ {
25
+ id: 'open-recent',
26
+ label: 'Open Recent',
27
+ children: [
28
+ { id: 'recent-1', label: 'crm' },
29
+ { id: 'recent-2', label: 'components' },
30
+ { id: 'sep-recent', label: '', separator: true },
31
+ { id: 'recent-clear', label: 'Clear Recently Opened' }
32
+ ]
33
+ },
34
+ { id: 'sep2', label: '', separator: true },
35
+ { id: 'save', label: 'Save', shortcut: '⌘S' },
36
+ { id: 'save-as', label: 'Save As…', shortcut: '⇧⌘S' },
37
+ { id: 'save-all', label: 'Save All', shortcut: '⌥⌘S', disabled: true },
38
+ { id: 'sep3', label: '', separator: true },
39
+ { id: 'auto-save', label: 'Auto Save', checked: true },
40
+ { id: 'sep4', label: '', separator: true },
41
+ { id: 'close-editor', label: 'Close Editor', shortcut: '⌘W' },
42
+ { id: 'close-window', label: 'Close Window', shortcut: '⇧⌘W', destructive: true }
16
43
  ]
17
44
  },
18
45
  {
@@ -20,26 +47,25 @@
20
47
  label: 'Edit',
21
48
  items: [
22
49
  { id: 'undo', label: 'Undo', shortcut: '⌘Z' },
23
- { id: 'redo', label: 'Redo', shortcut: '⌘⇧Z' },
24
- { id: 'sep2', label: '', separator: true },
50
+ { id: 'redo', label: 'Redo', shortcut: '⇧⌘Z' },
51
+ { id: 'sep-e1', label: '', separator: true },
25
52
  { id: 'cut', label: 'Cut', shortcut: '⌘X' },
26
53
  { id: 'copy', label: 'Copy', shortcut: '⌘C' },
27
54
  { id: 'paste', label: 'Paste', shortcut: '⌘V' },
28
- { id: 'sep3', label: '', separator: true },
29
- { id: 'selectall', label: 'Select All', shortcut: '⌘A' }
55
+ { id: 'sep-e2', label: '', separator: true },
56
+ { id: 'select-all', label: 'Select All', shortcut: '⌘A' }
30
57
  ]
31
58
  },
32
59
  {
33
60
  id: 'view',
34
61
  label: 'View',
35
62
  items: [
36
- { id: 'sidebar', label: 'Toggle Sidebar', shortcut: '⌘B' },
37
- { id: 'terminal', label: 'Toggle Terminal', shortcut: '⌘`' },
38
- { id: 'zen', label: 'Zen Mode', shortcut: '⌘K Z', disabled: true },
39
- { id: 'sep4', label: '', separator: true },
40
- { id: 'zoomin', label: 'Zoom In', shortcut: '⌘+' },
41
- { id: 'zoomout', label: 'Zoom Out', shortcut: '⌘-' },
42
- { id: 'zoomreset', label: 'Reset Zoom', shortcut: '⌘0' }
63
+ { id: 'sidebar', label: 'Toggle Sidebar', shortcut: '⌘B', checked: true },
64
+ { id: 'inspector', label: 'Toggle Inspector', shortcut: '⌘I', checked: true },
65
+ { id: 'sep-v1', label: '', separator: true },
66
+ { id: 'zoom-in', label: 'Zoom In', shortcut: '⌘+' },
67
+ { id: 'zoom-out', label: 'Zoom Out', shortcut: '⌘-' },
68
+ { id: 'zoom-reset', label: 'Reset Zoom', shortcut: '⌘0' }
43
69
  ]
44
70
  },
45
71
  {
@@ -48,7 +74,7 @@
48
74
  items: [
49
75
  { id: 'docs', label: 'Documentation' },
50
76
  { id: 'shortcuts', label: 'Keyboard Shortcuts', shortcut: '⌘K ⌘S' },
51
- { id: 'sep5', label: '', separator: true },
77
+ { id: 'sep-h', label: '', separator: true },
52
78
  { id: 'about', label: 'About' }
53
79
  ]
54
80
  }
@@ -57,11 +83,17 @@
57
83
  let lastAction = $state('');
58
84
  </script>
59
85
 
60
- <div class="space-y-4">
61
- <Menubar {items} onselect={(id, parent) => (lastAction = `${parent} > ${id}`)} />
86
+ <div class="space-y-4 rounded-xl border border-border bg-surface p-4 dark:bg-neutral-950">
87
+ <div
88
+ class="flex items-center gap-2 rounded-lg border border-border bg-surface-elevated/90 px-2 py-1 backdrop-blur"
89
+ >
90
+ <span class="px-1 text-xs font-semibold tracking-tight text-primary">App</span>
91
+ <div class="h-3.5 w-px bg-border" aria-hidden="true"></div>
92
+ <Menubar {items} class="min-w-0 flex-1" onselect={(id, parent) => (lastAction = `${parent} › ${id}`)} />
93
+ </div>
62
94
  {#if lastAction}
63
95
  <p class="text-xs text-muted">
64
- Acción: <span class="text-primary font-medium">{lastAction}</span>
96
+ Acción: <span class="font-medium text-primary">{lastAction}</span>
65
97
  </p>
66
98
  {/if}
67
99
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.19.17",
3
+ "version": "0.19.19",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",