@r2digisolutions/components 0.23.0 → 0.24.0

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.
Files changed (50) hide show
  1. package/dist/components/atoms/Avatar/Avatar.stories.js +1 -1
  2. package/dist/components/atoms/BrandMark/BrandMark.svelte +47 -7
  3. package/dist/components/atoms/BrandMark/BrandMark.svelte.d.ts +4 -0
  4. package/dist/components/atoms/Input/Input.svelte +5 -4
  5. package/dist/components/atoms/Slider/Slider.svelte +19 -15
  6. package/dist/components/atoms/Slider/Slider.svelte.d.ts +2 -0
  7. package/dist/components/molecules/AuthCard/AuthCard.svelte +19 -4
  8. package/dist/components/molecules/AuthCard/AuthCard.svelte.d.ts +4 -0
  9. package/dist/components/molecules/CanvasElementsPanel/CanvasElementsPanel.svelte +90 -26
  10. package/dist/components/molecules/CanvasInspector/CanvasInspector.svelte +176 -5
  11. package/dist/components/molecules/ChipBar/ChipBar.svelte +18 -5
  12. package/dist/components/molecules/ChipBar/ChipBar.svelte.d.ts +1 -1
  13. package/dist/components/molecules/Combobox/Combobox.svelte +2 -2
  14. package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +121 -33
  15. package/dist/components/molecules/FormSection/FormSection.svelte +25 -28
  16. package/dist/components/molecules/ImageEditor/ImageEditor.svelte +183 -0
  17. package/dist/components/molecules/ImageEditor/ImageEditor.svelte.d.ts +19 -0
  18. package/dist/components/molecules/KnowledgeCard/KnowledgeCard.svelte +5 -5
  19. package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +58 -35
  20. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte +293 -39
  21. package/dist/components/molecules/MediaLayerItem/MediaLayerItem.svelte.d.ts +6 -1
  22. package/dist/components/molecules/MediaStage/MediaStage.svelte +302 -245
  23. package/dist/components/molecules/MentionInput/MentionInput.svelte +332 -120
  24. package/dist/components/molecules/MentionInput/MentionInput.svelte.d.ts +13 -2
  25. package/dist/components/molecules/SearchBar/SearchBar.svelte +7 -1
  26. package/dist/components/molecules/SearchInput/SearchInput.svelte +77 -18
  27. package/dist/components/molecules/SearchInput/SearchInput.svelte.d.ts +4 -0
  28. package/dist/components/molecules/SearchInput/SearchInputStory.svelte +1 -0
  29. package/dist/components/molecules/Select/Select.svelte +14 -1
  30. package/dist/components/molecules/Select/Select.svelte.d.ts +3 -0
  31. package/dist/components/molecules/UserMenu/UserMenu.svelte +30 -27
  32. package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte +200 -17
  33. package/dist/components/molecules/WidgetFrame/WidgetFrame.svelte.d.ts +14 -0
  34. package/dist/components/organisms/AppShell/AppShell.svelte +7 -1
  35. package/dist/components/organisms/AppShell/AppShell.svelte.d.ts +2 -0
  36. package/dist/components/organisms/AuthShell/AuthShell.svelte +61 -29
  37. package/dist/components/organisms/AuthShell/AuthShell.svelte.d.ts +4 -0
  38. package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte +156 -7
  39. package/dist/components/organisms/CanvasEditor/CanvasEditor.svelte.d.ts +5 -0
  40. package/dist/components/organisms/Navbar/Navbar.svelte +2 -2
  41. package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte +314 -141
  42. package/dist/components/organisms/ProfileHeaderUploader/ProfileHeaderUploader.svelte.d.ts +20 -1
  43. package/dist/index.d.ts +3 -1
  44. package/dist/index.js +2 -1
  45. package/dist/styles.css +17 -0
  46. package/dist/utils/canvasDocument.d.ts +56 -4
  47. package/dist/utils/canvasDocument.js +91 -2
  48. package/dist/utils/canvasExport.d.ts +1 -1
  49. package/dist/utils/canvasExport.js +15 -25
  50. package/package.json +1 -1
@@ -9,7 +9,7 @@ const meta = {
9
9
  alt: { control: 'text', description: 'Alt text for the image' },
10
10
  size: {
11
11
  control: 'select',
12
- options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl'],
12
+ options: ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'],
13
13
  description: 'Avatar size'
14
14
  },
15
15
  status: {
@@ -9,6 +9,10 @@
9
9
  name?: string;
10
10
  /** Official logo image URL (SVG/PNG). Replaces initials / children. */
11
11
  logoSrc?: string;
12
+ /** Glyph is a single color. Painted with currentColor so it follows light/dark. */
13
+ monochrome?: boolean;
14
+ /** When set, the mark (and name) link here — e.g. `/` on auth pages. */
15
+ href?: string;
12
16
  size?: BrandMarkSize;
13
17
  showName?: boolean;
14
18
  class?: string;
@@ -19,6 +23,8 @@
19
23
  mark,
20
24
  name = 'Brand',
21
25
  logoSrc,
26
+ monochrome = false,
27
+ href,
22
28
  size = 'md',
23
29
  showName = false,
24
30
  class: className = '',
@@ -47,22 +53,35 @@
47
53
  lg: 'text-lg',
48
54
  xl: 'text-xl'
49
55
  };
56
+
57
+ const rootClass = $derived([
58
+ 'inline-flex items-center gap-2.5',
59
+ href && 'no-underline text-inherit',
60
+ className
61
+ ]);
62
+
63
+ const paintMono = $derived(Boolean(logoSrc && monochrome));
64
+ const monoMask = $derived(paintMono && logoSrc ? `url("${logoSrc}")` : undefined);
50
65
  </script>
51
66
 
52
- <span class={['inline-flex items-center gap-2.5', className]}>
67
+ {#snippet markBody()}
53
68
  <span
54
69
  class={[
55
- 'inline-flex shrink-0 items-center justify-center shadow-sm',
56
- logoSrc ? 'overflow-hidden bg-white' : 'bg-brand-500 font-bold tracking-tight text-white',
70
+ 'inline-flex shrink-0 items-center justify-center',
71
+ paintMono && 'brand-mark-mono bg-current',
72
+ logoSrc && !paintMono && 'bg-white shadow-sm overflow-hidden',
73
+ !logoSrc && 'bg-brand-500 font-bold tracking-tight text-white shadow-sm',
57
74
  box[size]
58
75
  ]}
76
+ style:mask-image={monoMask}
77
+ style:-webkit-mask-image={monoMask}
59
78
  aria-hidden={showName || !!name}
60
79
  >
61
- {#if logoSrc}
80
+ {#if logoSrc && !paintMono}
62
81
  <img src={logoSrc} alt="" class="h-[78%] w-[78%] object-contain" />
63
- {:else if children}
82
+ {:else if !paintMono && children}
64
83
  {@render children()}
65
- {:else}
84
+ {:else if !paintMono}
66
85
  {initials}
67
86
  {/if}
68
87
  </span>
@@ -72,4 +91,25 @@
72
91
  {#if !showName}
73
92
  <span class="sr-only">{name}</span>
74
93
  {/if}
75
- </span>
94
+ {/snippet}
95
+
96
+ {#if href}
97
+ <a {href} class={rootClass} aria-label={name}>
98
+ {@render markBody()}
99
+ </a>
100
+ {:else}
101
+ <span class={rootClass}>
102
+ {@render markBody()}
103
+ </span>
104
+ {/if}
105
+
106
+ <style>
107
+ .brand-mark-mono {
108
+ -webkit-mask-repeat: no-repeat;
109
+ mask-repeat: no-repeat;
110
+ -webkit-mask-position: center;
111
+ mask-position: center;
112
+ -webkit-mask-size: contain;
113
+ mask-size: contain;
114
+ }
115
+ </style>
@@ -6,6 +6,10 @@ interface BrandMarkProps {
6
6
  name?: string;
7
7
  /** Official logo image URL (SVG/PNG). Replaces initials / children. */
8
8
  logoSrc?: string;
9
+ /** Glyph is a single color. Painted with currentColor so it follows light/dark. */
10
+ monochrome?: boolean;
11
+ /** When set, the mark (and name) link here — e.g. `/` on auth pages. */
12
+ href?: string;
9
13
  size?: BrandMarkSize;
10
14
  showName?: boolean;
11
15
  class?: string;
@@ -220,11 +220,12 @@
220
220
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
221
221
  </svg>
222
222
  </button>
223
- {:else if trailIcon}
224
- <span class={['text-muted shrink-0', statusIconClasses[status]]}>
223
+ {/if}
224
+ {#if trailIcon}
225
+ <span class={['shrink-0', statusIconClasses[status]]}>
225
226
  {@render trailIcon()}
226
227
  </span>
227
- {:else if status === 'error'}
228
+ {:else if !hasClear && status === 'error'}
228
229
  <svg
229
230
  class="h-4 w-4 text-red-500 shrink-0"
230
231
  viewBox="0 0 24 24"
@@ -237,7 +238,7 @@
237
238
  clip-rule="evenodd"
238
239
  />
239
240
  </svg>
240
- {:else if status === 'success'}
241
+ {:else if !hasClear && status === 'success'}
241
242
  <svg
242
243
  class="h-4 w-4 text-green-500 shrink-0"
243
244
  viewBox="0 0 24 24"
@@ -15,6 +15,8 @@
15
15
  showMarks?: boolean;
16
16
  unit?: string;
17
17
  size?: 'sm' | 'md' | 'lg';
18
+ /** Associates the range with another form, or `""` to keep it out of the parent form. */
19
+ form?: string;
18
20
  class?: string;
19
21
  onchange?: (value: number) => void;
20
22
  oninput?: (value: number) => void;
@@ -35,6 +37,7 @@
35
37
  showMarks = false,
36
38
  unit = '',
37
39
  size = 'md',
40
+ form,
38
41
  class: className = '',
39
42
  onchange,
40
43
  oninput
@@ -62,7 +65,7 @@
62
65
 
63
66
  function formatValue(v: number): string {
64
67
  if (Number.isInteger(step) && Number.isInteger(v)) return String(v);
65
- const decimals = String(step).includes('.') ? String(step).split('.')[1]?.length ?? 2 : 2;
68
+ const decimals = String(step).includes('.') ? (String(step).split('.')[1]?.length ?? 2) : 2;
66
69
  return v.toFixed(Math.min(decimals, 2));
67
70
  }
68
71
 
@@ -79,9 +82,9 @@
79
82
  }
80
83
  </script>
81
84
 
82
- <div class={['flex w-full select-none flex-col gap-1.5', className]}>
85
+ <div class={['gap-1.5 flex w-full flex-col select-none', className]}>
83
86
  {#if label || (showValue && valuePosition === 'header' && !inset)}
84
- <div class="flex items-center justify-between text-sm font-medium">
87
+ <div class="text-sm font-medium flex items-center justify-between">
85
88
  {#if label}
86
89
  <label for={sliderId} class="text-primary">{label}</label>
87
90
  {:else}
@@ -98,15 +101,15 @@
98
101
  <!-- svelte-ignore a11y_no_static_element_interactions -->
99
102
  <div
100
103
  class={[
101
- 'relative flex w-full items-center gap-2',
104
+ 'gap-2 relative flex w-full items-center',
102
105
  inset &&
103
- 'h-7 rounded-md border border-border bg-surface-overlay/80 px-2 shadow-sm dark:bg-surface-overlay/50',
106
+ 'h-7 rounded-md border-border bg-surface-overlay/80 px-2 shadow-sm dark:bg-surface-overlay/50 border',
104
107
  !inset && 'py-1.5'
105
108
  ]}
106
109
  onmouseenter={() => (isHovered = true)}
107
110
  onmouseleave={() => (isHovered = false)}
108
111
  >
109
- <div class="relative flex min-w-0 flex-1 cursor-pointer touch-none items-center py-1">
112
+ <div class="min-w-0 py-1 relative flex flex-1 cursor-pointer touch-none items-center">
110
113
  <!-- Track background -->
111
114
  <div
112
115
  class={[
@@ -116,29 +119,29 @@
116
119
  ]}
117
120
  >
118
121
  <!-- Fill bar -->
119
- <div class="h-full rounded-full bg-brand-500" style="width: {percentage}%"></div>
122
+ <div class="bg-brand-500 h-full rounded-full" style="width: {percentage}%"></div>
120
123
  </div>
121
124
 
122
125
  <!-- Custom Floating Thumb / Handle -->
123
126
  <div
124
127
  class={[
125
- 'pointer-events-none absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-full border-2 border-brand-500 bg-white shadow-md dark:bg-slate-900',
128
+ 'border-brand-500 bg-white shadow-md dark:bg-slate-900 pointer-events-none absolute top-1/2 flex -translate-y-1/2 items-center justify-center rounded-full border-2',
126
129
  'transition-[transform,box-shadow] duration-100',
127
130
  thumbSizeClasses[size],
128
- (isFocused || isHovered) && 'scale-110 ring-2 ring-brand-500/25',
131
+ (isFocused || isHovered) && 'ring-brand-500/25 scale-110 ring-2',
129
132
  disabled && 'border-gray-400 opacity-50'
130
133
  ]}
131
134
  style="left: {percentage}%"
132
135
  >
133
- <span class="h-1 w-1 rounded-full bg-brand-500"></span>
136
+ <span class="h-1 w-1 bg-brand-500 rounded-full"></span>
134
137
 
135
138
  {#if showValue && valuePosition === 'tooltip' && !inset && (isHovered || isFocused)}
136
139
  <div
137
- class="pointer-events-none absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-slate-900 px-1.5 py-0.5 font-mono text-[10px] font-bold text-white shadow-lg animate-in fade-in zoom-in-95 duration-150 dark:bg-slate-100 dark:text-slate-900"
140
+ class="-top-8 rounded-md bg-slate-900 px-1.5 py-0.5 font-mono font-bold text-white shadow-lg animate-in fade-in zoom-in-95 dark:bg-slate-100 dark:text-slate-900 pointer-events-none absolute left-1/2 -translate-x-1/2 text-[10px] whitespace-nowrap duration-150"
138
141
  >
139
142
  {formatValue(value)}{unit}
140
143
  <div
141
- class="absolute -bottom-1 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rotate-45 bg-slate-900 dark:bg-slate-100"
144
+ class="-bottom-1 h-1.5 w-1.5 bg-slate-900 dark:bg-slate-100 absolute left-1/2 -translate-x-1/2 rotate-45"
142
145
  ></div>
143
146
  </div>
144
147
  {/if}
@@ -149,12 +152,13 @@
149
152
  id={sliderId}
150
153
  type="range"
151
154
  {name}
155
+ {form}
152
156
  {min}
153
157
  {max}
154
158
  {step}
155
159
  {disabled}
156
160
  bind:value
157
- class="absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed"
161
+ class="inset-0 absolute z-10 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed"
158
162
  oninput={handleInput}
159
163
  onchange={handleChange}
160
164
  onfocus={() => (isFocused = true)}
@@ -164,7 +168,7 @@
164
168
 
165
169
  {#if inlineValue}
166
170
  <span
167
- class="w-9 shrink-0 text-right font-mono text-[10px] font-semibold tabular-nums text-secondary"
171
+ class="w-9 font-mono font-semibold text-secondary shrink-0 text-right text-[10px] tabular-nums"
168
172
  aria-hidden="true"
169
173
  >
170
174
  {formatValue(value)}{unit}
@@ -173,7 +177,7 @@
173
177
  </div>
174
178
 
175
179
  {#if showMarks}
176
- <div class="-mt-0.5 flex items-center justify-between px-0.5 font-mono text-[10px] text-muted">
180
+ <div class="-mt-0.5 px-0.5 font-mono text-muted flex items-center justify-between text-[10px]">
177
181
  <span>{min}{unit}</span>
178
182
  <span>{max}{unit}</span>
179
183
  </div>
@@ -14,6 +14,8 @@ interface SliderProps {
14
14
  showMarks?: boolean;
15
15
  unit?: string;
16
16
  size?: 'sm' | 'md' | 'lg';
17
+ /** Associates the range with another form, or `""` to keep it out of the parent form. */
18
+ form?: string;
17
19
  class?: string;
18
20
  onchange?: (value: number) => void;
19
21
  oninput?: (value: number) => void;
@@ -10,6 +10,10 @@
10
10
  mark?: string;
11
11
  /** Official brand logo URL (SVG/PNG) for BrandMark */
12
12
  logoSrc?: string;
13
+ /** Single-color logo, painted with currentColor */
14
+ monochrome?: boolean;
15
+ /** Brand / logo link target (e.g. `/`) */
16
+ brandHref?: string;
13
17
  class?: string;
14
18
  footer?: Snippet;
15
19
  children?: Snippet;
@@ -21,6 +25,8 @@
21
25
  brand = 'R2 Digi',
22
26
  mark,
23
27
  logoSrc,
28
+ monochrome = false,
29
+ brandHref,
24
30
  class: className = '',
25
31
  footer,
26
32
  children
@@ -31,10 +37,19 @@
31
37
  variant="elevated"
32
38
  padding="lg"
33
39
  radius="xl"
34
- class={`mx-auto w-full max-w-md border border-border shadow-sm ${className}`}
40
+ class={`max-w-md border-border shadow-sm mx-auto w-full border ${className}`}
35
41
  >
36
- <div class="mb-6 flex flex-col items-center gap-3 text-center">
37
- <BrandMark name={brand} {mark} {logoSrc} size="lg" showName />
42
+ <div class="mb-6 gap-3 flex flex-col items-center text-center">
43
+ <BrandMark
44
+ name={brand}
45
+ {mark}
46
+ {logoSrc}
47
+ {monochrome}
48
+ href={brandHref}
49
+ size="lg"
50
+ showName
51
+ class="text-primary"
52
+ />
38
53
  <div>
39
54
  <h1 class="text-xl font-semibold tracking-tight text-primary">{title}</h1>
40
55
  {#if description}
@@ -44,7 +59,7 @@
44
59
  </div>
45
60
  {@render children?.()}
46
61
  {#if footer}
47
- <div class="mt-6 border-t border-border pt-4 text-center text-sm text-secondary">
62
+ <div class="mt-6 border-border pt-4 text-sm text-secondary border-t text-center">
48
63
  {@render footer()}
49
64
  </div>
50
65
  {/if}
@@ -6,6 +6,10 @@ interface AuthCardProps {
6
6
  mark?: string;
7
7
  /** Official brand logo URL (SVG/PNG) for BrandMark */
8
8
  logoSrc?: string;
9
+ /** Single-color logo, painted with currentColor */
10
+ monochrome?: boolean;
11
+ /** Brand / logo link target (e.g. `/`) */
12
+ brandHref?: string;
9
13
  class?: string;
10
14
  footer?: Snippet;
11
15
  children?: Snippet;
@@ -37,6 +37,8 @@
37
37
  </script>
38
38
 
39
39
  <script lang="ts">
40
+ import Input from '../../atoms/Input/Input.svelte';
41
+
40
42
  interface CanvasElementsPanelProps {
41
43
  class?: string;
42
44
  onadd?: (def: CanvasElementDef) => void;
@@ -56,7 +58,7 @@
56
58
  text: 'Add a heading',
57
59
  fontSize: 56,
58
60
  fontWeight: 700,
59
- rect: { w: 440, h: 80 }
61
+ rect: { w: 440, h: 96 }
60
62
  }
61
63
  },
62
64
  {
@@ -642,7 +644,13 @@
642
644
  kind: 'text',
643
645
  group: 'Icons',
644
646
  glyph: '⭐',
645
- partial: { name: 'Star icon', text: '⭐', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
647
+ partial: {
648
+ name: 'Star icon',
649
+ text: '⭐',
650
+ fontSize: 64,
651
+ textAlign: 'center',
652
+ rect: { w: 80, h: 80 }
653
+ }
646
654
  },
647
655
  {
648
656
  id: 'icon-heart',
@@ -650,7 +658,13 @@
650
658
  kind: 'text',
651
659
  group: 'Icons',
652
660
  glyph: '❤️',
653
- partial: { name: 'Heart icon', text: '❤️', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
661
+ partial: {
662
+ name: 'Heart icon',
663
+ text: '❤️',
664
+ fontSize: 64,
665
+ textAlign: 'center',
666
+ rect: { w: 80, h: 80 }
667
+ }
654
668
  },
655
669
  {
656
670
  id: 'icon-check',
@@ -658,7 +672,13 @@
658
672
  kind: 'text',
659
673
  group: 'Icons',
660
674
  glyph: '✅',
661
- partial: { name: 'Check', text: '✅', fontSize: 56, textAlign: 'center', rect: { w: 72, h: 72 } }
675
+ partial: {
676
+ name: 'Check',
677
+ text: '✅',
678
+ fontSize: 56,
679
+ textAlign: 'center',
680
+ rect: { w: 72, h: 72 }
681
+ }
662
682
  },
663
683
  {
664
684
  id: 'icon-fire',
@@ -666,7 +686,13 @@
666
686
  kind: 'text',
667
687
  group: 'Icons',
668
688
  glyph: '🔥',
669
- partial: { name: 'Fire', text: '🔥', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
689
+ partial: {
690
+ name: 'Fire',
691
+ text: '🔥',
692
+ fontSize: 64,
693
+ textAlign: 'center',
694
+ rect: { w: 80, h: 80 }
695
+ }
670
696
  },
671
697
  {
672
698
  id: 'icon-spark',
@@ -674,7 +700,13 @@
674
700
  kind: 'text',
675
701
  group: 'Icons',
676
702
  glyph: '✨',
677
- partial: { name: 'Sparkles', text: '✨', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
703
+ partial: {
704
+ name: 'Sparkles',
705
+ text: '✨',
706
+ fontSize: 64,
707
+ textAlign: 'center',
708
+ rect: { w: 80, h: 80 }
709
+ }
678
710
  },
679
711
  {
680
712
  id: 'icon-rocket',
@@ -682,7 +714,13 @@
682
714
  kind: 'text',
683
715
  group: 'Icons',
684
716
  glyph: '🚀',
685
- partial: { name: 'Rocket', text: '🚀', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
717
+ partial: {
718
+ name: 'Rocket',
719
+ text: '🚀',
720
+ fontSize: 64,
721
+ textAlign: 'center',
722
+ rect: { w: 80, h: 80 }
723
+ }
686
724
  },
687
725
  {
688
726
  id: 'icon-idea',
@@ -690,7 +728,13 @@
690
728
  kind: 'text',
691
729
  group: 'Icons',
692
730
  glyph: '💡',
693
- partial: { name: 'Idea', text: '💡', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
731
+ partial: {
732
+ name: 'Idea',
733
+ text: '💡',
734
+ fontSize: 64,
735
+ textAlign: 'center',
736
+ rect: { w: 80, h: 80 }
737
+ }
694
738
  },
695
739
  {
696
740
  id: 'icon-target',
@@ -698,7 +742,13 @@
698
742
  kind: 'text',
699
743
  group: 'Icons',
700
744
  glyph: '🎯',
701
- partial: { name: 'Target', text: '🎯', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
745
+ partial: {
746
+ name: 'Target',
747
+ text: '🎯',
748
+ fontSize: 64,
749
+ textAlign: 'center',
750
+ rect: { w: 80, h: 80 }
751
+ }
702
752
  },
703
753
  {
704
754
  id: 'icon-party',
@@ -706,18 +756,28 @@
706
756
  kind: 'text',
707
757
  group: 'Icons',
708
758
  glyph: '🎉',
709
- partial: { name: 'Party', text: '🎉', fontSize: 64, textAlign: 'center', rect: { w: 80, h: 80 } }
759
+ partial: {
760
+ name: 'Party',
761
+ text: '🎉',
762
+ fontSize: 64,
763
+ textAlign: 'center',
764
+ rect: { w: 80, h: 80 }
765
+ }
710
766
  }
711
767
  ];
712
768
 
713
769
  const groupOrder = ['Text', 'Stickies', 'Shapes', 'Lines', 'Frames', 'Panels', 'Icons'];
770
+ let query = $state('');
714
771
 
715
- const groups = $derived(
716
- groupOrder.map((name) => ({
717
- name,
718
- items: elements.filter((e) => e.group === name)
719
- }))
720
- );
772
+ const groups = $derived.by(() => {
773
+ const q = query.trim().toLowerCase();
774
+ return groupOrder
775
+ .map((name) => ({
776
+ name,
777
+ items: elements.filter((e) => e.group === name && (!q || e.label.toLowerCase().includes(q)))
778
+ }))
779
+ .filter((group) => group.items.length > 0);
780
+ });
721
781
 
722
782
  function beginDrag(e: DragEvent, el: CanvasElementDef) {
723
783
  if (!e.dataTransfer) return;
@@ -727,22 +787,26 @@
727
787
  }
728
788
  </script>
729
789
 
730
- <div class={['flex h-full min-h-0 flex-col gap-4 overflow-auto p-3', className]}>
731
- <p class="text-[11px] text-muted">Click or drag onto the canvas</p>
790
+ <div class={['min-h-0 gap-4 p-3 flex h-full flex-col overflow-auto', className]}>
791
+ <Input size="sm" type="search" placeholder="Buscar" bind:value={query} autocomplete="off" />
792
+ <p class="text-muted text-[11px]">Click or drag onto the canvas</p>
793
+ {#if groups.length === 0}
794
+ <p class="text-xs text-muted">Ningún componente coincide.</p>
795
+ {/if}
732
796
  {#each groups as group (group.name)}
733
- <section class="flex flex-col gap-2">
734
- <h3 class="text-[11px] font-semibold uppercase tracking-wide text-muted">{group.name}</h3>
735
- <div class="grid grid-cols-3 gap-2">
797
+ <section class="gap-2 flex flex-col">
798
+ <h3 class="font-semibold tracking-wide text-muted text-[11px] uppercase">{group.name}</h3>
799
+ <div class="gap-2 grid grid-cols-3">
736
800
  {#each group.items as el (el.id)}
737
801
  <button
738
802
  type="button"
739
803
  draggable="true"
740
- class="flex cursor-grab flex-col items-center gap-1.5 rounded-lg border border-transparent bg-surface px-1.5 py-2.5 text-center transition-colors hover:border-border hover:bg-surface-overlay active:cursor-grabbing"
804
+ class="gap-1.5 rounded-lg bg-surface px-1.5 py-2.5 hover:border-border hover:bg-surface-overlay flex cursor-grab flex-col items-center border border-transparent text-center transition-colors active:cursor-grabbing"
741
805
  ondragstart={(e) => beginDrag(e, el)}
742
806
  onclick={() => onadd?.(el)}
743
807
  >
744
808
  <span
745
- class="flex h-11 w-full items-center justify-center rounded-md bg-[#eef1f5] dark:bg-surface-overlay"
809
+ class="h-11 rounded-md dark:bg-surface-overlay flex w-full items-center justify-center bg-[#eef1f5]"
746
810
  >
747
811
  {#if el.glyph}
748
812
  <span class="text-xl leading-none">{el.glyph}</span>
@@ -761,7 +825,7 @@
761
825
  </span>
762
826
  {:else if el.kind === 'sticky'}
763
827
  <span
764
- class="flex h-8 w-8 items-center justify-center rounded-sm text-[9px] font-semibold"
828
+ class="h-8 w-8 rounded-sm font-semibold flex items-center justify-center text-[9px]"
765
829
  style:background={el.swatch}
766
830
  style:color={el.partial?.color ?? '#713f12'}
767
831
  >
@@ -841,7 +905,7 @@
841
905
  </svg>
842
906
  {:else}
843
907
  <span
844
- class="h-7 w-9 border border-black/5"
908
+ class="h-7 w-9 border-black/5 border"
845
909
  style:background={el.swatch}
846
910
  style:border-radius="{el.partial?.borderRadius
847
911
  ? Math.min(12, el.partial.borderRadius / 2)
@@ -849,7 +913,7 @@
849
913
  ></span>
850
914
  {/if}
851
915
  </span>
852
- <span class="text-[10px] font-medium text-secondary">{el.label}</span>
916
+ <span class="font-medium text-secondary text-[10px]">{el.label}</span>
853
917
  </button>
854
918
  {/each}
855
919
  </div>