@r2digisolutions/components 0.21.14 → 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.
@@ -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
- <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
142
  {:else if label}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.21.14",
3
+ "version": "0.21.15",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",