@r2digisolutions/components 0.23.0 → 0.23.1

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.
@@ -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: {
@@ -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"
@@ -12,7 +12,7 @@
12
12
  }
13
13
 
14
14
  export type ChipBarSize = 'sm' | 'md';
15
- export type ChipBarVariant = 'soft' | 'solid' | 'outline';
15
+ export type ChipBarVariant = 'soft' | 'solid' | 'outline' | 'underline';
16
16
 
17
17
  interface ChipBarProps {
18
18
  items?: ChipBarItem[];
@@ -94,12 +94,22 @@
94
94
  md: 'gap-1.5 px-3 py-1.5 text-sm'
95
95
  };
96
96
 
97
+ const underlineSizes: Record<ChipBarSize, string> = {
98
+ sm: 'gap-1.5 px-1 pb-2.5 text-xs',
99
+ md: 'gap-1.5 px-1.5 pb-3 text-sm'
100
+ };
101
+
97
102
  const iconSizes: Record<ChipBarSize, string> = {
98
103
  sm: 'h-3.5 w-3.5',
99
104
  md: 'h-4 w-4'
100
105
  };
101
106
 
102
107
  function chipClass(isActive: boolean) {
108
+ if (variant === 'underline') {
109
+ return isActive
110
+ ? 'rounded-none border-0 border-b-2 border-brand-500 bg-transparent text-primary'
111
+ : 'rounded-none border-0 border-b-2 border-transparent bg-transparent text-secondary hover:text-primary';
112
+ }
103
113
  if (variant === 'solid') {
104
114
  return isActive
105
115
  ? 'border-brand-500 bg-brand-500 text-white shadow-sm'
@@ -132,7 +142,10 @@
132
142
 
133
143
  <div
134
144
  bind:this={scroller}
135
- class="flex gap-2 overflow-x-auto py-0.5 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
145
+ class={[
146
+ 'flex overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
147
+ variant === 'underline' ? 'gap-5 border-b border-border' : 'gap-2 py-0.5'
148
+ ]}
136
149
  role="listbox"
137
150
  aria-label={ariaLabel}
138
151
  aria-multiselectable={multi}
@@ -146,8 +159,8 @@
146
159
  aria-selected={isActive}
147
160
  disabled={item.disabled}
148
161
  class={[
149
- 'inline-flex shrink-0 items-center rounded-full border font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40',
150
- sizes[size],
162
+ 'inline-flex shrink-0 items-center font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40',
163
+ variant === 'underline' ? underlineSizes[size] : ['rounded-full border', sizes[size]],
151
164
  chipClass(isActive)
152
165
  ]}
153
166
  onclick={() => select(item.id, item.disabled)}
@@ -157,7 +170,7 @@
157
170
  <Icon class={iconSizes[size]} aria-hidden="true" />
158
171
  {/if}
159
172
  <span>{item.label}</span>
160
- {#if item.count !== undefined}
173
+ {#if item.count !== undefined && variant !== 'underline'}
161
174
  <span
162
175
  class={[
163
176
  'rounded-full px-1.5 py-px text-[10px] font-semibold tabular-nums',
@@ -8,7 +8,7 @@ export interface ChipBarItem {
8
8
  icon?: Component;
9
9
  }
10
10
  export type ChipBarSize = 'sm' | 'md';
11
- export type ChipBarVariant = 'soft' | 'solid' | 'outline';
11
+ export type ChipBarVariant = 'soft' | 'solid' | 'outline' | 'underline';
12
12
  interface ChipBarProps {
13
13
  items?: ChipBarItem[];
14
14
  value?: string;
@@ -80,15 +80,15 @@
80
80
  <p class="mt-0.5 text-sm text-muted">{subtitle}</p>
81
81
  {/if}
82
82
 
83
- {#if actions}
84
- <div class="mt-3">
85
- {@render actions()}
83
+ {#if children}
84
+ <div class="mt-3 border-t border-border/70 pt-3">
85
+ {@render children()}
86
86
  </div>
87
87
  {/if}
88
88
 
89
- {#if children}
89
+ {#if actions}
90
90
  <div class="mt-3">
91
- {@render children()}
91
+ {@render actions()}
92
92
  </div>
93
93
  {/if}
94
94
  </div>
@@ -59,7 +59,13 @@
59
59
 
60
60
  function submit() {
61
61
  if (busy) return;
62
- onsubmit?.(value);
62
+ const el =
63
+ typeof document !== 'undefined'
64
+ ? (document.getElementById(inputId) as HTMLInputElement | null)
65
+ : null;
66
+ const live = el?.value ?? value;
67
+ value = live;
68
+ onsubmit?.(live);
63
69
  }
64
70
 
65
71
  function clear() {
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import IconButton from '../../atoms/IconButton/IconButton.svelte';
2
3
  import Input from '../../atoms/Input/Input.svelte';
3
4
 
4
5
  interface SearchInputProps {
@@ -8,6 +9,10 @@
8
9
  disabled?: boolean;
9
10
  size?: 'sm' | 'md' | 'lg';
10
11
  class?: string;
12
+ /** Accessible label for the submit control. */
13
+ submitLabel?: string;
14
+ /** Show the trailing submit button. Default true. */
15
+ showSubmit?: boolean;
11
16
  oninput?: (e: Event) => void;
12
17
  onsubmit?: (value: string) => void;
13
18
  onchange?: (e: Event) => void;
@@ -20,32 +25,86 @@
20
25
  disabled = false,
21
26
  size = 'md',
22
27
  class: className = '',
28
+ submitLabel = 'Search',
29
+ showSubmit = true,
23
30
  oninput,
24
31
  onsubmit,
25
32
  onchange
26
33
  }: SearchInputProps = $props();
27
34
 
35
+ const submitButtonSize = $derived(size === 'sm' ? 'xs' : 'sm');
36
+
37
+ function submit() {
38
+ onsubmit?.(value);
39
+ }
40
+
28
41
  function handleKeydown(e: KeyboardEvent) {
29
- if (e.key === 'Enter') onsubmit?.(value);
42
+ if (e.key !== 'Enter') return;
43
+ e.preventDefault();
44
+ submit();
30
45
  }
31
46
  </script>
32
47
 
33
- <div class={className} onkeydown={handleKeydown}>
34
- <Input
35
- {label}
36
- {placeholder}
48
+ {#snippet leadIcon()}
49
+ <svg
50
+ class="h-4 w-4"
51
+ viewBox="0 0 24 24"
52
+ fill="none"
53
+ stroke="currentColor"
54
+ stroke-width="2"
55
+ aria-hidden="true"
56
+ >
57
+ <path
58
+ stroke-linecap="round"
59
+ stroke-linejoin="round"
60
+ d="M21 21l-4.35-4.35M11 18a7 7 0 100-14 7 7 0 000 14z"
61
+ />
62
+ </svg>
63
+ {/snippet}
64
+
65
+ {#snippet trailIcon()}
66
+ <IconButton
67
+ type="button"
68
+ variant="ghost"
69
+ size={submitButtonSize}
70
+ label={submitLabel}
37
71
  {disabled}
38
- {size}
39
- type="search"
40
- clearable
41
- bind:value
42
- {oninput}
43
- {onchange}
72
+ class="-me-1.5"
73
+ onclick={(e) => {
74
+ e.preventDefault();
75
+ e.stopPropagation();
76
+ submit();
77
+ }}
44
78
  >
45
- {#snippet leadIcon()}
46
- <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
47
- <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-4.35-4.35M11 18a7 7 0 100-14 7 7 0 000 14z" />
48
- </svg>
49
- {/snippet}
50
- </Input>
51
- </div>
79
+ <svg
80
+ class="h-full w-full"
81
+ viewBox="0 0 24 24"
82
+ fill="none"
83
+ stroke="currentColor"
84
+ stroke-width="2"
85
+ aria-hidden="true"
86
+ >
87
+ <path
88
+ stroke-linecap="round"
89
+ stroke-linejoin="round"
90
+ d="M21 21l-4.35-4.35M11 18a7 7 0 100-14 7 7 0 000 14z"
91
+ />
92
+ </svg>
93
+ </IconButton>
94
+ {/snippet}
95
+
96
+ <Input
97
+ {label}
98
+ {placeholder}
99
+ {disabled}
100
+ {size}
101
+ type="search"
102
+ clearable
103
+ class={className}
104
+ bind:value
105
+ {oninput}
106
+ {onchange}
107
+ onkeydown={handleKeydown}
108
+ {leadIcon}
109
+ trailIcon={showSubmit ? trailIcon : undefined}
110
+ />
@@ -5,6 +5,10 @@ interface SearchInputProps {
5
5
  disabled?: boolean;
6
6
  size?: 'sm' | 'md' | 'lg';
7
7
  class?: string;
8
+ /** Accessible label for the submit control. */
9
+ submitLabel?: string;
10
+ /** Show the trailing submit button. Default true. */
11
+ showSubmit?: boolean;
8
12
  oninput?: (e: Event) => void;
9
13
  onsubmit?: (value: string) => void;
10
14
  onchange?: (e: Event) => void;
@@ -17,6 +17,7 @@
17
17
  placeholder={props.placeholder ?? 'Search projects…'}
18
18
  size={props.size ?? 'md'}
19
19
  disabled={props.disabled ?? false}
20
+ submitLabel="Search"
20
21
  onsubmit={(v) => (lastSubmit = v)}
21
22
  />
22
23
  {#if lastSubmit}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",