@makolabs/ripple 2.1.0 → 2.3.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.
- package/dist/charts/Chart.svelte +307 -53
- package/dist/charts/chart-types.d.ts +12 -0
- package/dist/elements/accordion/Accordion.svelte +27 -10
- package/dist/elements/accordion/accordion-types.d.ts +6 -0
- package/dist/elements/dropdown/Select.svelte +191 -63
- package/dist/elements/dropdown/dropdown-types.d.ts +13 -1
- package/dist/elements/dropdown/select.d.ts +15 -0
- package/dist/elements/dropdown/select.js +14 -8
- package/dist/forms/DateRange.svelte +16 -3
- package/dist/forms/Input.svelte +6 -4
- package/dist/forms/MarketSelector.svelte +7 -27
- package/dist/forms/NumberInput.svelte +9 -6
- package/dist/forms/SegmentedControl.svelte +5 -18
- package/dist/forms/Tags.svelte +1 -1
- package/dist/forms/form-types.d.ts +2 -31
- package/dist/forms/market/market-selector-types.d.ts +1 -21
- package/dist/forms/segmented-control.d.ts +4 -34
- package/dist/forms/segmented-control.js +19 -59
- package/dist/index.d.ts +3 -11
- package/dist/index.js +0 -8
- package/dist/layout/activity-list/ActivityList.svelte +55 -1
- package/dist/variants.js +6 -6
- package/package.json +1 -1
- package/dist/elements/collapsible/Collapsible.svelte +0 -79
- package/dist/elements/collapsible/Collapsible.svelte.d.ts +0 -4
- package/dist/elements/collapsible/CollapsibleTestWrapper.svelte +0 -23
- package/dist/elements/collapsible/CollapsibleTestWrapper.svelte.d.ts +0 -8
- package/dist/elements/collapsible/collapsible-types.d.ts +0 -16
- package/dist/elements/collapsible/collapsible-types.js +0 -1
- package/dist/elements/combobox/Combobox.svelte +0 -274
- package/dist/elements/combobox/Combobox.svelte.d.ts +0 -25
- package/dist/elements/combobox/ComboboxTestWrapper.svelte +0 -38
- package/dist/elements/combobox/ComboboxTestWrapper.svelte.d.ts +0 -4
- package/dist/elements/combobox/combobox-types.d.ts +0 -39
- package/dist/elements/combobox/combobox-types.js +0 -1
- package/dist/elements/timeline/Timeline.svelte +0 -95
- package/dist/elements/timeline/Timeline.svelte.d.ts +0 -7
- package/dist/elements/timeline/timeline-types.d.ts +0 -11
- package/dist/elements/timeline/timeline-types.js +0 -1
- package/dist/forms/RadioInputs.svelte +0 -73
- package/dist/forms/RadioInputs.svelte.d.ts +0 -4
- package/dist/forms/RadioPill.svelte +0 -66
- package/dist/forms/RadioPill.svelte.d.ts +0 -4
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Collapsible from './Collapsible.svelte';
|
|
3
|
-
import type { CollapsibleProps } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
type Props = Omit<CollapsibleProps, 'children' | 'header'> & {
|
|
6
|
-
bodyText?: string;
|
|
7
|
-
headerText?: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
let { bodyText = '', headerText, ...rest }: Props = $props();
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
{#snippet body()}
|
|
14
|
-
<span data-testid="wrapper-body">{bodyText}</span>
|
|
15
|
-
{/snippet}
|
|
16
|
-
|
|
17
|
-
{#snippet customHeader({ open }: { open: boolean })}
|
|
18
|
-
<span data-testid="wrapper-header">{headerText} [{open ? 'open' : 'closed'}]</span>
|
|
19
|
-
{/snippet}
|
|
20
|
-
|
|
21
|
-
<Collapsible {...rest} header={headerText ? customHeader : undefined}>
|
|
22
|
-
{@render body()}
|
|
23
|
-
</Collapsible>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CollapsibleProps } from '../../index.js';
|
|
2
|
-
type Props = Omit<CollapsibleProps, 'children' | 'header'> & {
|
|
3
|
-
bodyText?: string;
|
|
4
|
-
headerText?: string;
|
|
5
|
-
};
|
|
6
|
-
declare const CollapsibleTestWrapper: import("svelte").Component<Props, {}, "">;
|
|
7
|
-
type CollapsibleTestWrapper = ReturnType<typeof CollapsibleTestWrapper>;
|
|
8
|
-
export default CollapsibleTestWrapper;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
export type CollapsibleProps = {
|
|
4
|
-
open?: boolean;
|
|
5
|
-
title?: string;
|
|
6
|
-
header?: Snippet<[{
|
|
7
|
-
open: boolean;
|
|
8
|
-
}]>;
|
|
9
|
-
children: Snippet;
|
|
10
|
-
class?: ClassValue;
|
|
11
|
-
headerClass?: ClassValue;
|
|
12
|
-
contentClass?: ClassValue;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
ontoggle?: (open: boolean) => void;
|
|
15
|
-
testId?: string;
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends ComboboxItem">
|
|
2
|
-
import { cn } from '../../helper/cls.js';
|
|
3
|
-
import { buildTestId } from '../../helper/testid.js';
|
|
4
|
-
import type { ComboboxItem, ComboboxProps } from '../../index.js';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
items,
|
|
8
|
-
onsearch,
|
|
9
|
-
value = null,
|
|
10
|
-
onselect,
|
|
11
|
-
placeholder = 'Search...',
|
|
12
|
-
emptyText = 'No results',
|
|
13
|
-
loadingText = 'Loading...',
|
|
14
|
-
debounceMs = 200,
|
|
15
|
-
minSearchLength = 0,
|
|
16
|
-
disabled = false,
|
|
17
|
-
class: className = '',
|
|
18
|
-
inputClass = '',
|
|
19
|
-
listClass = '',
|
|
20
|
-
itemSnippet,
|
|
21
|
-
testId
|
|
22
|
-
}: ComboboxProps<T> = $props();
|
|
23
|
-
|
|
24
|
-
let inputValue = $state(value?.label ?? '');
|
|
25
|
-
let isOpen = $state(false);
|
|
26
|
-
let highlightedIndex = $state(0);
|
|
27
|
-
let asyncResults = $state<T[]>([]);
|
|
28
|
-
let loading = $state(false);
|
|
29
|
-
let hasSearched = $state(false);
|
|
30
|
-
let rootEl: HTMLDivElement | undefined = $state();
|
|
31
|
-
let debounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
32
|
-
let searchSeq = 0;
|
|
33
|
-
|
|
34
|
-
function normalizeFilter(q: string): string {
|
|
35
|
-
return q.trim().toLowerCase();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function filterStatic(query: string, list: T[]): T[] {
|
|
39
|
-
const q = normalizeFilter(query);
|
|
40
|
-
if (!q) return list;
|
|
41
|
-
return list.filter(
|
|
42
|
-
(item) =>
|
|
43
|
-
item.label.toLowerCase().includes(q) || (item.description ?? '').toLowerCase().includes(q)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Static filtering is pure and runs every render — no side effects needed.
|
|
48
|
-
const results = $derived.by<T[]>(() => {
|
|
49
|
-
if (items !== undefined) return filterStatic(inputValue, items);
|
|
50
|
-
return asyncResults;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Async search: only triggered after user has interacted (hasSearched flag).
|
|
54
|
-
// Mount alone never fires onsearch, so static-mode tests and first-render
|
|
55
|
-
// async-mode tests don't see a spurious onsearch('') call.
|
|
56
|
-
$effect(() => {
|
|
57
|
-
if (items !== undefined) return;
|
|
58
|
-
if (!onsearch) return;
|
|
59
|
-
if (!hasSearched) return;
|
|
60
|
-
|
|
61
|
-
const query = inputValue;
|
|
62
|
-
clearTimeout(debounceTimer);
|
|
63
|
-
|
|
64
|
-
if (query.length < minSearchLength) {
|
|
65
|
-
asyncResults = [] as T[];
|
|
66
|
-
loading = false;
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
debounceTimer = setTimeout(async () => {
|
|
71
|
-
const currentSeq = ++searchSeq;
|
|
72
|
-
loading = true;
|
|
73
|
-
try {
|
|
74
|
-
const fetched = await onsearch(query);
|
|
75
|
-
if (currentSeq !== searchSeq) return;
|
|
76
|
-
asyncResults = fetched as T[];
|
|
77
|
-
} finally {
|
|
78
|
-
if (currentSeq === searchSeq) loading = false;
|
|
79
|
-
}
|
|
80
|
-
}, debounceMs);
|
|
81
|
-
|
|
82
|
-
return () => {
|
|
83
|
-
clearTimeout(debounceTimer);
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Group results, preserving order of first appearance.
|
|
88
|
-
// Uses a plain object as the lookup (local to derivation, no reactivity needed).
|
|
89
|
-
const groupedResults = $derived.by(() => {
|
|
90
|
-
const groups: Array<{ label: string | null; items: T[] }> = [];
|
|
91
|
-
const indexByGroup: Record<string, number> = {};
|
|
92
|
-
let nullGroupIdx = -1;
|
|
93
|
-
for (const item of results) {
|
|
94
|
-
const key = item.group;
|
|
95
|
-
let idx: number;
|
|
96
|
-
if (key === undefined || key === null) {
|
|
97
|
-
if (nullGroupIdx === -1) {
|
|
98
|
-
nullGroupIdx = groups.length;
|
|
99
|
-
groups.push({ label: null, items: [] });
|
|
100
|
-
}
|
|
101
|
-
idx = nullGroupIdx;
|
|
102
|
-
} else {
|
|
103
|
-
idx = indexByGroup[key] ?? -1;
|
|
104
|
-
if (idx === -1) {
|
|
105
|
-
idx = groups.length;
|
|
106
|
-
indexByGroup[key] = idx;
|
|
107
|
-
groups.push({ label: key, items: [] });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
groups[idx].items.push(item);
|
|
111
|
-
}
|
|
112
|
-
return groups;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// Flat enabled index for keyboard nav
|
|
116
|
-
const flatEnabled = $derived(results.filter((i) => !i.disabled));
|
|
117
|
-
|
|
118
|
-
function open() {
|
|
119
|
-
if (disabled) return;
|
|
120
|
-
isOpen = true;
|
|
121
|
-
highlightedIndex = 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function close() {
|
|
125
|
-
isOpen = false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function selectItem(item: T) {
|
|
129
|
-
if (item.disabled) return;
|
|
130
|
-
onselect?.(item);
|
|
131
|
-
inputValue = item.label;
|
|
132
|
-
close();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function handleInput(event: Event) {
|
|
136
|
-
const target = event.target as HTMLInputElement;
|
|
137
|
-
inputValue = target.value;
|
|
138
|
-
hasSearched = true;
|
|
139
|
-
if (!isOpen) open();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function handleKeydown(event: KeyboardEvent) {
|
|
143
|
-
if (disabled) return;
|
|
144
|
-
if (event.key === 'ArrowDown') {
|
|
145
|
-
event.preventDefault();
|
|
146
|
-
if (!isOpen) open();
|
|
147
|
-
highlightedIndex = Math.min(highlightedIndex + 1, Math.max(flatEnabled.length - 1, 0));
|
|
148
|
-
} else if (event.key === 'ArrowUp') {
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
highlightedIndex = Math.max(highlightedIndex - 1, 0);
|
|
151
|
-
} else if (event.key === 'Enter') {
|
|
152
|
-
if (isOpen && flatEnabled.length > 0) {
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
selectItem(flatEnabled[highlightedIndex]);
|
|
155
|
-
}
|
|
156
|
-
} else if (event.key === 'Escape') {
|
|
157
|
-
close();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Click-outside handling
|
|
162
|
-
$effect(() => {
|
|
163
|
-
if (!isOpen) return;
|
|
164
|
-
function onDocClick(e: MouseEvent) {
|
|
165
|
-
if (rootEl && !rootEl.contains(e.target as Node)) {
|
|
166
|
-
close();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
document.addEventListener('mousedown', onDocClick);
|
|
170
|
-
return () => document.removeEventListener('mousedown', onDocClick);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
function isHighlighted(item: T): boolean {
|
|
174
|
-
const idx = flatEnabled.indexOf(item);
|
|
175
|
-
return idx !== -1 && idx === highlightedIndex;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function isSelected(item: T): boolean {
|
|
179
|
-
return value != null && value.id === item.id;
|
|
180
|
-
}
|
|
181
|
-
</script>
|
|
182
|
-
|
|
183
|
-
<div
|
|
184
|
-
bind:this={rootEl}
|
|
185
|
-
class={cn('relative inline-flex w-full flex-col', className)}
|
|
186
|
-
data-testid={buildTestId('combobox', undefined, testId)}
|
|
187
|
-
>
|
|
188
|
-
<input
|
|
189
|
-
type="text"
|
|
190
|
-
role="combobox"
|
|
191
|
-
aria-expanded={isOpen}
|
|
192
|
-
aria-controls="combobox-listbox"
|
|
193
|
-
aria-autocomplete="list"
|
|
194
|
-
aria-disabled={disabled ? 'true' : undefined}
|
|
195
|
-
{disabled}
|
|
196
|
-
value={inputValue}
|
|
197
|
-
{placeholder}
|
|
198
|
-
class={cn(
|
|
199
|
-
'border-default-300 w-full rounded-md border bg-white px-3 py-2 text-sm',
|
|
200
|
-
'focus:border-primary-500 focus:ring-primary-500 focus:ring-1 focus:outline-none',
|
|
201
|
-
disabled && 'cursor-not-allowed opacity-50',
|
|
202
|
-
inputClass
|
|
203
|
-
)}
|
|
204
|
-
oninput={handleInput}
|
|
205
|
-
onfocus={open}
|
|
206
|
-
onkeydown={handleKeydown}
|
|
207
|
-
/>
|
|
208
|
-
|
|
209
|
-
{#if isOpen}
|
|
210
|
-
<ul
|
|
211
|
-
id="combobox-listbox"
|
|
212
|
-
role="listbox"
|
|
213
|
-
data-combobox-listbox=""
|
|
214
|
-
class={cn(
|
|
215
|
-
'border-default-200 absolute top-full left-0 z-50 mt-1 max-h-64 w-full overflow-y-auto rounded-md border bg-white shadow-lg',
|
|
216
|
-
listClass
|
|
217
|
-
)}
|
|
218
|
-
>
|
|
219
|
-
{#if loading}
|
|
220
|
-
<li class="text-default-500 px-3 py-2 text-sm" data-combobox-loading="">
|
|
221
|
-
{loadingText}
|
|
222
|
-
</li>
|
|
223
|
-
{:else if results.length === 0}
|
|
224
|
-
<li class="text-default-500 px-3 py-2 text-sm" data-combobox-empty="">
|
|
225
|
-
{emptyText}
|
|
226
|
-
</li>
|
|
227
|
-
{:else}
|
|
228
|
-
{#each groupedResults as group, groupIdx (group.label ?? `__null__${groupIdx}`)}
|
|
229
|
-
{#if group.label !== null}
|
|
230
|
-
<li
|
|
231
|
-
class="text-default-500 bg-default-50 px-3 py-1.5 text-xs font-semibold tracking-wide uppercase"
|
|
232
|
-
data-combobox-group={group.label}
|
|
233
|
-
role="presentation"
|
|
234
|
-
>
|
|
235
|
-
{group.label}
|
|
236
|
-
</li>
|
|
237
|
-
{/if}
|
|
238
|
-
{#each group.items as item (item.id)}
|
|
239
|
-
{@const highlighted = isHighlighted(item)}
|
|
240
|
-
{@const selected = isSelected(item)}
|
|
241
|
-
<li
|
|
242
|
-
role="option"
|
|
243
|
-
aria-selected={selected}
|
|
244
|
-
aria-disabled={item.disabled ? 'true' : undefined}
|
|
245
|
-
data-combobox-item=""
|
|
246
|
-
data-combobox-item-id={item.id}
|
|
247
|
-
class={cn(
|
|
248
|
-
'cursor-pointer px-3 py-2 text-sm',
|
|
249
|
-
highlighted && 'bg-primary-50',
|
|
250
|
-
selected && 'font-semibold',
|
|
251
|
-
item.disabled && 'cursor-not-allowed opacity-50'
|
|
252
|
-
)}
|
|
253
|
-
onclick={() => selectItem(item)}
|
|
254
|
-
onkeydown={() => {}}
|
|
255
|
-
onmouseenter={() => {
|
|
256
|
-
const idx = flatEnabled.indexOf(item);
|
|
257
|
-
if (idx !== -1) highlightedIndex = idx;
|
|
258
|
-
}}
|
|
259
|
-
>
|
|
260
|
-
{#if itemSnippet}
|
|
261
|
-
{@render itemSnippet(item, { highlighted, selected })}
|
|
262
|
-
{:else}
|
|
263
|
-
<div class="text-default-800 font-medium">{item.label}</div>
|
|
264
|
-
{#if item.description}
|
|
265
|
-
<div class="text-default-500 text-xs">{item.description}</div>
|
|
266
|
-
{/if}
|
|
267
|
-
{/if}
|
|
268
|
-
</li>
|
|
269
|
-
{/each}
|
|
270
|
-
{/each}
|
|
271
|
-
{/if}
|
|
272
|
-
</ul>
|
|
273
|
-
{/if}
|
|
274
|
-
</div>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ComboboxItem, ComboboxProps } from '../../index.js';
|
|
2
|
-
declare function $$render<T extends ComboboxItem>(): {
|
|
3
|
-
props: ComboboxProps<T>;
|
|
4
|
-
exports: {};
|
|
5
|
-
bindings: "";
|
|
6
|
-
slots: {};
|
|
7
|
-
events: {};
|
|
8
|
-
};
|
|
9
|
-
declare class __sveltets_Render<T extends ComboboxItem> {
|
|
10
|
-
props(): ReturnType<typeof $$render<T>>['props'];
|
|
11
|
-
events(): ReturnType<typeof $$render<T>>['events'];
|
|
12
|
-
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
13
|
-
bindings(): "";
|
|
14
|
-
exports(): {};
|
|
15
|
-
}
|
|
16
|
-
interface $$IsomorphicComponent {
|
|
17
|
-
new <T extends ComboboxItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
18
|
-
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
19
|
-
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
20
|
-
<T extends ComboboxItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
21
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
22
|
-
}
|
|
23
|
-
declare const Combobox: $$IsomorphicComponent;
|
|
24
|
-
type Combobox<T extends ComboboxItem> = InstanceType<typeof Combobox<T>>;
|
|
25
|
-
export default Combobox;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import Combobox from './Combobox.svelte';
|
|
3
|
-
import type { ComboboxItem, ComboboxProps } from '../../index.js';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
items,
|
|
7
|
-
onsearch,
|
|
8
|
-
value,
|
|
9
|
-
onselect,
|
|
10
|
-
placeholder,
|
|
11
|
-
emptyText,
|
|
12
|
-
loadingText,
|
|
13
|
-
debounceMs,
|
|
14
|
-
minSearchLength,
|
|
15
|
-
disabled,
|
|
16
|
-
class: className,
|
|
17
|
-
inputClass,
|
|
18
|
-
listClass,
|
|
19
|
-
testId
|
|
20
|
-
}: ComboboxProps<ComboboxItem> = $props();
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Combobox
|
|
24
|
-
{items}
|
|
25
|
-
{onsearch}
|
|
26
|
-
{value}
|
|
27
|
-
{onselect}
|
|
28
|
-
{placeholder}
|
|
29
|
-
{emptyText}
|
|
30
|
-
{loadingText}
|
|
31
|
-
{debounceMs}
|
|
32
|
-
{minSearchLength}
|
|
33
|
-
{disabled}
|
|
34
|
-
class={className}
|
|
35
|
-
{inputClass}
|
|
36
|
-
{listClass}
|
|
37
|
-
{testId}
|
|
38
|
-
/>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ComboboxItem, ComboboxProps } from '../../index.js';
|
|
2
|
-
declare const ComboboxTestWrapper: import("svelte").Component<ComboboxProps<ComboboxItem>, {}, "">;
|
|
3
|
-
type ComboboxTestWrapper = ReturnType<typeof ComboboxTestWrapper>;
|
|
4
|
-
export default ComboboxTestWrapper;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
export type ComboboxItem = {
|
|
4
|
-
id: string | number;
|
|
5
|
-
label: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
group?: string;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type ComboboxProps<T extends ComboboxItem = ComboboxItem> = {
|
|
11
|
-
/** Static items for client-side filtering. Provide this OR `onsearch`. */
|
|
12
|
-
items?: T[];
|
|
13
|
-
/**
|
|
14
|
-
* Async/sync search callback. Called with the debounced query string.
|
|
15
|
-
* Returns the list of items to display.
|
|
16
|
-
*/
|
|
17
|
-
onsearch?: (query: string) => T[] | Promise<T[]>;
|
|
18
|
-
/** Currently selected item (controlled). */
|
|
19
|
-
value?: T | null;
|
|
20
|
-
/** Fires when the user selects an item (click or Enter on highlighted). */
|
|
21
|
-
onselect?: (item: T) => void;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
emptyText?: string;
|
|
24
|
-
loadingText?: string;
|
|
25
|
-
/** Milliseconds to debounce onsearch calls (default 200). */
|
|
26
|
-
debounceMs?: number;
|
|
27
|
-
/** Minimum query length before onsearch fires (default 0). */
|
|
28
|
-
minSearchLength?: number;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
class?: ClassValue;
|
|
31
|
-
inputClass?: ClassValue;
|
|
32
|
-
listClass?: ClassValue;
|
|
33
|
-
/** Optional snippet to override the default item rendering. */
|
|
34
|
-
itemSnippet?: Snippet<[T, {
|
|
35
|
-
highlighted: boolean;
|
|
36
|
-
selected: boolean;
|
|
37
|
-
}]>;
|
|
38
|
-
testId?: string;
|
|
39
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn } from '../../helper/cls.js';
|
|
3
|
-
import type { TimelineItem } from '../../index.js';
|
|
4
|
-
import { formatDateTime, getRelativeTime } from '../../helper/date.js';
|
|
5
|
-
import { resolve } from '$app/paths';
|
|
6
|
-
|
|
7
|
-
let { items = [] as TimelineItem[], class: className = '' } = $props();
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<div class={cn('flow-root', className)}>
|
|
11
|
-
<ul role="list" class="-mb-8">
|
|
12
|
-
{#each items as item, index (item.title + index)}
|
|
13
|
-
<li>
|
|
14
|
-
<div class="relative pb-8">
|
|
15
|
-
{#if index !== items.length - 1}
|
|
16
|
-
<span class="bg-default-200 absolute top-4 left-4 -ml-px h-full w-1" aria-hidden="true"
|
|
17
|
-
></span>
|
|
18
|
-
{/if}
|
|
19
|
-
|
|
20
|
-
{@render ItemWrap({ item })}
|
|
21
|
-
</div>
|
|
22
|
-
</li>
|
|
23
|
-
{/each}
|
|
24
|
-
</ul>
|
|
25
|
-
</div>
|
|
26
|
-
|
|
27
|
-
{#snippet ItemWrap({ item }: { item: TimelineItem })}
|
|
28
|
-
<div class="relative flex gap-x-3" class:items-center={!item.details}>
|
|
29
|
-
<div class="relative ml-0.5 flex-shrink-0">
|
|
30
|
-
{@render TimelineIcon(item)}
|
|
31
|
-
</div>
|
|
32
|
-
{#if item.details}
|
|
33
|
-
{@render CommentItem({ item })}
|
|
34
|
-
{:else}
|
|
35
|
-
{@render StandardItem({ item })}
|
|
36
|
-
{/if}
|
|
37
|
-
</div>
|
|
38
|
-
{/snippet}
|
|
39
|
-
|
|
40
|
-
{#snippet StandardItem({ item }: { item: TimelineItem })}
|
|
41
|
-
<div class="min-w-0 flex-1">
|
|
42
|
-
<div class="flex items-center justify-between">
|
|
43
|
-
<p class="text-default-500 text-sm">
|
|
44
|
-
{item.title}
|
|
45
|
-
{#if item.link}
|
|
46
|
-
<a href={resolve(item.link.url as `/`)} class="text-default-900 font-medium"
|
|
47
|
-
>{item.link.text}</a
|
|
48
|
-
>
|
|
49
|
-
{/if}
|
|
50
|
-
</p>
|
|
51
|
-
{@render TimeStamp(item.time)}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
{/snippet}
|
|
55
|
-
|
|
56
|
-
{#snippet CommentItem({ item }: { item: TimelineItem })}
|
|
57
|
-
<div class="ring-default-200 w-full flex-grow rounded-md bg-white p-3 ring-1">
|
|
58
|
-
<div class="mb-1 flex justify-between gap-x-4">
|
|
59
|
-
<div class="text-default-900 text-sm font-medium">{item.title}</div>
|
|
60
|
-
{@render TimeStamp(item.time)}
|
|
61
|
-
</div>
|
|
62
|
-
<p class="text-default-500 text-sm">{item.details}</p>
|
|
63
|
-
</div>
|
|
64
|
-
{/snippet}
|
|
65
|
-
|
|
66
|
-
{#snippet TimeStamp(time: Date | string)}
|
|
67
|
-
<time
|
|
68
|
-
datetime={time instanceof Date ? time.toISOString() : time}
|
|
69
|
-
class="text-default-500 text-right text-sm whitespace-nowrap"
|
|
70
|
-
title={formatDateTime(time)}
|
|
71
|
-
>
|
|
72
|
-
{getRelativeTime(time)}
|
|
73
|
-
</time>
|
|
74
|
-
{/snippet}
|
|
75
|
-
|
|
76
|
-
{#snippet TimelineIcon(item: TimelineItem, classes = 'size-7 shrink-0')}
|
|
77
|
-
{#if item.Icon}
|
|
78
|
-
{@const Icon = item.Icon}
|
|
79
|
-
<Icon class={classes} />
|
|
80
|
-
{:else}
|
|
81
|
-
<svg
|
|
82
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
-
width="16"
|
|
84
|
-
height="16"
|
|
85
|
-
viewBox="0 0 16 16"
|
|
86
|
-
class={classes}
|
|
87
|
-
>
|
|
88
|
-
<circle cx="8" cy="8" r="7" fill="white" />
|
|
89
|
-
<path
|
|
90
|
-
fill="currentColor"
|
|
91
|
-
d="M1 8a7 7 0 1 1 14 0A7 7 0 0 1 1 8m9.854-1.146a.5.5 0 0 0-.708-.708L7.25 9.043L5.854 7.646a.5.5 0 1 0-.708.708l1.75 1.75a.5.5 0 0 0 .708 0z"
|
|
92
|
-
/>
|
|
93
|
-
</svg>
|
|
94
|
-
{/if}
|
|
95
|
-
{/snippet}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn } from '../helper/cls.js';
|
|
3
|
-
import { buildTestId } from '../helper/testid.js';
|
|
4
|
-
import type { RadioInputsProps } from '../index.js';
|
|
5
|
-
|
|
6
|
-
let {
|
|
7
|
-
name,
|
|
8
|
-
label,
|
|
9
|
-
options,
|
|
10
|
-
value = $bindable(),
|
|
11
|
-
disabled = false,
|
|
12
|
-
class: className = '',
|
|
13
|
-
errors = [],
|
|
14
|
-
required = false,
|
|
15
|
-
testId
|
|
16
|
-
}: RadioInputsProps = $props();
|
|
17
|
-
|
|
18
|
-
const containerClass = $derived(cn('space-y-2', className));
|
|
19
|
-
|
|
20
|
-
const radioClass = $derived(
|
|
21
|
-
cn('w-4 h-4 text-primary-600 border-default-300 focus:ring-primary-500', {
|
|
22
|
-
'opacity-50 cursor-not-allowed': disabled,
|
|
23
|
-
'border-danger-300 focus:ring-danger-500': errors.length
|
|
24
|
-
})
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const labelClass = $derived(
|
|
28
|
-
cn('block text-sm font-medium', {
|
|
29
|
-
'text-default-700': !errors.length,
|
|
30
|
-
'text-danger-600': errors.length
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<div class={containerClass}>
|
|
36
|
-
{#if label}
|
|
37
|
-
<label class={labelClass} for={`${name}-${value || options[0].value}`}>{label}</label>
|
|
38
|
-
{/if}
|
|
39
|
-
<div class="space-y-2">
|
|
40
|
-
{#each options as option, index (option.value)}
|
|
41
|
-
<div class="flex items-center gap-2">
|
|
42
|
-
<input
|
|
43
|
-
type="radio"
|
|
44
|
-
{name}
|
|
45
|
-
id={`${name}-${option.value}`}
|
|
46
|
-
value={option.value}
|
|
47
|
-
bind:group={value}
|
|
48
|
-
class={radioClass}
|
|
49
|
-
{disabled}
|
|
50
|
-
{required}
|
|
51
|
-
aria-describedby={errors.length
|
|
52
|
-
? errors.map((_, i) => `${name}-error-${i}`).join(' ')
|
|
53
|
-
: undefined}
|
|
54
|
-
data-testid={buildTestId('radio', 'option', testId, index)}
|
|
55
|
-
/>
|
|
56
|
-
<label
|
|
57
|
-
for={`${name}-${option.value}`}
|
|
58
|
-
class="text-default-700 text-sm"
|
|
59
|
-
data-testid={buildTestId('radio', 'label', testId, index)}
|
|
60
|
-
>
|
|
61
|
-
{option.label}
|
|
62
|
-
</label>
|
|
63
|
-
</div>
|
|
64
|
-
{/each}
|
|
65
|
-
</div>
|
|
66
|
-
{#if errors.length}
|
|
67
|
-
{#each errors as error, i (i)}
|
|
68
|
-
<p id={`${name}-error-${i}`} class="text-danger-600 mt-1 text-sm" role="alert">
|
|
69
|
-
{error}
|
|
70
|
-
</p>
|
|
71
|
-
{/each}
|
|
72
|
-
{/if}
|
|
73
|
-
</div>
|