@r2digisolutions/components 0.21.14 → 0.21.16

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.
@@ -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,38 +102,42 @@
86
102
  className
87
103
  ]}
88
104
  >
89
- <input
90
- id={inputId}
91
- type="checkbox"
92
- {name}
93
- {value}
94
- {disabled}
95
- bind:checked
96
- {@attach setIndeterminate}
97
- class={[
98
- 'shrink-0 cursor-pointer border-2 border-border bg-surface-elevated appearance-none transition-all duration-150',
99
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
100
- 'disabled:cursor-not-allowed disabled:opacity-50',
101
- sizeClasses[size],
102
- radiusClasses[radius],
103
- toneChecked[tone]
104
- ]}
105
- style="
106
- background-image: {checked
107
- ? `url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e\")`
108
- : indeterminate
109
- ? `url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M3 8a1 1 0 011-1h8a1 1 0 110 2H4a1 1 0 01-1-1z'/%3e%3c/svg%3e\")`
110
- : 'none'};
111
- background-size: 100% 100%;
112
- background-position: center;
113
- background-repeat: no-repeat;
114
- "
115
- onchange={handleChange}
116
- aria-label={showLabel ? undefined : label}
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
- {:else if label}
121
- <span class="sr-only">{label}</span>
122
142
  {/if}
123
143
  </label>
@@ -205,7 +205,7 @@
205
205
  {:else}
206
206
  {#if check === 'box'}
207
207
  <!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
208
- <div class="shrink-0" onclick={(e) => e.stopPropagation()}>
208
+ <div class="flex shrink-0 items-center" onclick={(e) => e.stopPropagation()}>
209
209
  <SelectionBox
210
210
  checked={selected}
211
211
  size="md"
@@ -228,7 +228,7 @@
228
228
  {/if}
229
229
 
230
230
  {#if image || leading}
231
- <div class="shrink-0">
231
+ <div class="flex shrink-0 items-center">
232
232
  {#if image}
233
233
  <img src={image} alt={imageAlt} class="h-11 w-11 rounded-lg object-cover" />
234
234
  {:else if leading}
@@ -237,15 +237,22 @@
237
237
  </div>
238
238
  {/if}
239
239
 
240
- <div class="min-w-0 flex-1">
240
+ <div class="flex min-w-0 flex-1 flex-col justify-center">
241
241
  {#if children}
242
242
  {@render children()}
243
243
  {:else}
244
244
  {#if title}
245
- <p class="truncate text-sm font-medium text-primary">{title}</p>
245
+ <p
246
+ class={[
247
+ 'truncate text-sm font-medium text-primary',
248
+ !description && 'leading-none'
249
+ ]}
250
+ >
251
+ {title}
252
+ </p>
246
253
  {/if}
247
254
  {#if description}
248
- <p class="mt-0.5 truncate text-xs text-muted">{description}</p>
255
+ <p class="mt-0.5 truncate text-xs leading-snug text-muted">{description}</p>
249
256
  {/if}
250
257
  {/if}
251
258
  </div>
@@ -25,14 +25,16 @@
25
25
 
26
26
  function addMany(raw: string) {
27
27
  if (disabled) return;
28
+ // Comma / semicolon / newline — keep spaces so multi-word tags work (e.g. keywords).
28
29
  const parts = raw
29
- .split(/[\s,;]+/)
30
+ .split(/[,;\n]+/)
30
31
  .map((p) => p.trim())
31
32
  .filter(Boolean);
32
33
  if (!parts.length) return;
33
34
  let next = [...value];
34
35
  for (const part of parts) {
35
- if (next.includes(part)) continue;
36
+ const exists = next.some((t) => t.toLowerCase() === part.toLowerCase());
37
+ if (exists) continue;
36
38
  if (max !== undefined && next.length >= max) break;
37
39
  next.push(part);
38
40
  }
@@ -61,9 +63,10 @@
61
63
 
62
64
  function onPaste(e: ClipboardEvent) {
63
65
  const text = e.clipboardData?.getData('text') ?? '';
64
- if (!/[,;\s]/.test(text)) return;
66
+ if (!/[,;\n]/.test(text)) return;
65
67
  e.preventDefault();
66
- addMany(`${draft} ${text}`);
68
+ const prefix = draft.trim() ? `${draft.trim()}, ` : '';
69
+ addMany(`${prefix}${text}`);
67
70
  }
68
71
  </script>
69
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.14",
3
+ "version": "0.21.16",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",