@w5-ui/svelte 0.1.0 → 0.2.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.
- package/package.json +6 -6
- package/src/lib/components/Accordion.svelte +9 -1
- package/src/lib/components/AccordionItem.svelte +11 -5
- package/src/lib/components/ActionMenu.svelte +19 -14
- package/src/lib/components/ActivityFeed.svelte +24 -11
- package/src/lib/components/Alert.svelte +9 -4
- package/src/lib/components/AnnotatedTimeSeries.svelte +40 -26
- package/src/lib/components/ArcDiagram.svelte +20 -8
- package/src/lib/components/AreaChart.svelte +26 -14
- package/src/lib/components/Avatar.svelte +20 -8
- package/src/lib/components/AvatarGroup.svelte +16 -7
- package/src/lib/components/Badge.svelte +24 -11
- package/src/lib/components/Banner.svelte +20 -9
- package/src/lib/components/BarChart.svelte +29 -17
- package/src/lib/components/BeeswarmChart.svelte +32 -18
- package/src/lib/components/BoxPlot.svelte +27 -15
- package/src/lib/components/Breadcrumb.svelte +12 -7
- package/src/lib/components/BubbleChart.svelte +39 -25
- package/src/lib/components/BulletChart.svelte +16 -9
- package/src/lib/components/BumpChart.svelte +15 -8
- package/src/lib/components/Button.svelte +32 -11
- package/src/lib/components/CIDRInput.svelte +27 -19
- package/src/lib/components/CalendarHeatmap.svelte +12 -5
- package/src/lib/components/Callout.svelte +9 -4
- package/src/lib/components/CandlestickChart.svelte +31 -16
- package/src/lib/components/Card.svelte +16 -6
- package/src/lib/components/Carousel.svelte +14 -11
- package/src/lib/components/Checkbox.svelte +37 -16
- package/src/lib/components/ChordDiagram.svelte +12 -5
- package/src/lib/components/CirclePacking.svelte +13 -6
- package/src/lib/components/CodeBlock.svelte +16 -7
- package/src/lib/components/ColorPicker.svelte +22 -11
- package/src/lib/components/ColumnToggle.svelte +18 -11
- package/src/lib/components/Combobox.svelte +44 -33
- package/src/lib/components/CommandPalette.svelte +41 -31
- package/src/lib/components/ConfirmDialog.svelte +66 -35
- package/src/lib/components/ContextMenu.svelte +46 -33
- package/src/lib/components/ContextualHelp.svelte +13 -9
- package/src/lib/components/ContourPlot.svelte +43 -28
- package/src/lib/components/CopyButton.svelte +8 -4
- package/src/lib/components/CorrelationMatrix.svelte +16 -7
- package/src/lib/components/CountUp.svelte +30 -13
- package/src/lib/components/CumulativeDistribution.svelte +32 -19
- package/src/lib/components/DatePicker.svelte +28 -21
- package/src/lib/components/DateRangePicker.svelte +39 -32
- package/src/lib/components/Dendrogram.svelte +18 -6
- package/src/lib/components/Donut.svelte +28 -14
- package/src/lib/components/DotPlot.svelte +31 -16
- package/src/lib/components/Drawer.svelte +28 -21
- package/src/lib/components/DualAxisChart.svelte +39 -26
- package/src/lib/components/DumbbellChart.svelte +24 -12
- package/src/lib/components/DurationInput.svelte +26 -17
- package/src/lib/components/EmptyState.svelte +16 -6
- package/src/lib/components/ErrorBandChart.svelte +28 -14
- package/src/lib/components/ExpandableRow.svelte +19 -6
- package/src/lib/components/Field.svelte +26 -12
- package/src/lib/components/FileUpload.svelte +29 -20
- package/src/lib/components/FilterBuilder.svelte +27 -17
- package/src/lib/components/FlameGraph.svelte +14 -7
- package/src/lib/components/ForceGraph.svelte +19 -7
- package/src/lib/components/FunnelChart.svelte +20 -13
- package/src/lib/components/GanttChart.svelte +14 -7
- package/src/lib/components/Gauge.svelte +26 -16
- package/src/lib/components/GroupedList.svelte +13 -6
- package/src/lib/components/HealthBar.svelte +14 -5
- package/src/lib/components/HeatMap.svelte +28 -17
- package/src/lib/components/HexbinChart.svelte +36 -22
- package/src/lib/components/Histogram.svelte +27 -14
- package/src/lib/components/HorizonChart.svelte +28 -16
- package/src/lib/components/HoverCard.svelte +24 -12
- package/src/lib/components/IPInput.svelte +24 -16
- package/src/lib/components/IcicleChart.svelte +14 -7
- package/src/lib/components/IconButton.svelte +27 -9
- package/src/lib/components/InlineEdit.svelte +22 -12
- package/src/lib/components/Input.svelte +67 -10
- package/src/lib/components/InputGroup.svelte +8 -3
- package/src/lib/components/JsonViewer.svelte +17 -6
- package/src/lib/components/JsonViewerNode.svelte +36 -18
- package/src/lib/components/KVTable.svelte +6 -2
- package/src/lib/components/KanbanBoard.svelte +24 -17
- package/src/lib/components/Kbd.svelte +8 -4
- package/src/lib/components/LineChart.svelte +29 -17
- package/src/lib/components/LogViewer.svelte +27 -12
- package/src/lib/components/LollipopChart.svelte +20 -8
- package/src/lib/components/MACInput.svelte +24 -16
- package/src/lib/components/MarimekkoChart.svelte +14 -7
- package/src/lib/components/MatrixChart.svelte +19 -9
- package/src/lib/components/Menubar.svelte +26 -19
- package/src/lib/components/MirroredBarChart.svelte +25 -10
- package/src/lib/components/Modal.svelte +46 -33
- package/src/lib/components/MultiSelect.svelte +49 -38
- package/src/lib/components/NightingaleChart.svelte +17 -10
- package/src/lib/components/NotificationPanel.svelte +48 -33
- package/src/lib/components/NumberInput.svelte +37 -23
- package/src/lib/components/OTPInput.svelte +28 -16
- package/src/lib/components/Pagination.svelte +16 -13
- package/src/lib/components/ParallelCoordinates.svelte +28 -16
- package/src/lib/components/ParetoChart.svelte +38 -24
- package/src/lib/components/PasswordInput.svelte +24 -14
- package/src/lib/components/PieChart.svelte +21 -13
- package/src/lib/components/Pill.svelte +17 -6
- package/src/lib/components/PolarHeatmap.svelte +32 -18
- package/src/lib/components/Popover.svelte +22 -11
- package/src/lib/components/ProgressBar.svelte +17 -8
- package/src/lib/components/PunchCard.svelte +31 -20
- package/src/lib/components/QuadrantChart.svelte +50 -30
- package/src/lib/components/RadarChart.svelte +30 -18
- package/src/lib/components/RadialBarChart.svelte +14 -7
- package/src/lib/components/RadioGroup.svelte +20 -8
- package/src/lib/components/RangeSlider.svelte +30 -18
- package/src/lib/components/RankedList.svelte +18 -6
- package/src/lib/components/ResizablePanel.svelte +33 -17
- package/src/lib/components/RidgelinePlot.svelte +33 -21
- package/src/lib/components/RowToggle.svelte +15 -5
- package/src/lib/components/SankeyDiagram.svelte +18 -6
- package/src/lib/components/ScatterPlot.svelte +34 -21
- package/src/lib/components/SearchBox.svelte +27 -5
- package/src/lib/components/SegmentedControl.svelte +11 -7
- package/src/lib/components/Select.svelte +37 -26
- package/src/lib/components/SelectionToolbar.svelte +25 -11
- package/src/lib/components/Sidebar.svelte +15 -9
- package/src/lib/components/Signal.svelte +6 -2
- package/src/lib/components/Skeleton.svelte +20 -10
- package/src/lib/components/SkipLink.svelte +9 -4
- package/src/lib/components/Slider.svelte +28 -14
- package/src/lib/components/SlopeChart.svelte +35 -21
- package/src/lib/components/SortHeader.svelte +20 -9
- package/src/lib/components/SortableList.svelte +20 -13
- package/src/lib/components/Sparkline.svelte +15 -6
- package/src/lib/components/SparklineMatrix.svelte +17 -10
- package/src/lib/components/Spinner.svelte +7 -3
- package/src/lib/components/SplitButton.svelte +28 -17
- package/src/lib/components/Spoiler.svelte +22 -11
- package/src/lib/components/StackedBarChart.svelte +35 -22
- package/src/lib/components/StackedProgress.svelte +21 -9
- package/src/lib/components/StarRating.svelte +22 -11
- package/src/lib/components/Stat.svelte +32 -10
- package/src/lib/components/StatusIndicator.svelte +7 -3
- package/src/lib/components/StepChart.svelte +27 -15
- package/src/lib/components/Stepper.svelte +10 -6
- package/src/lib/components/StreamGraph.svelte +19 -12
- package/src/lib/components/StripeChart.svelte +22 -12
- package/src/lib/components/SunburstChart.svelte +11 -4
- package/src/lib/components/SwitchPortGrid.svelte +13 -7
- package/src/lib/components/TabPanel.svelte +9 -4
- package/src/lib/components/Tabs.svelte +18 -10
- package/src/lib/components/Tag.svelte +9 -5
- package/src/lib/components/TagInput.svelte +28 -18
- package/src/lib/components/Textarea.svelte +37 -15
- package/src/lib/components/ThresholdAreaChart.svelte +34 -21
- package/src/lib/components/TimePicker.svelte +25 -17
- package/src/lib/components/TimeRange.svelte +19 -14
- package/src/lib/components/Timeline.svelte +8 -4
- package/src/lib/components/Toast.svelte +2 -2
- package/src/lib/components/Toggle.svelte +13 -7
- package/src/lib/components/ToggleGroup.svelte +19 -11
- package/src/lib/components/Tooltip.svelte +16 -6
- package/src/lib/components/Topbar.svelte +24 -10
- package/src/lib/components/TransferList.svelte +34 -27
- package/src/lib/components/TreeItem.svelte +23 -10
- package/src/lib/components/TreeMap.svelte +13 -6
- package/src/lib/components/TreeView.svelte +24 -12
- package/src/lib/components/UptimeTimeline.svelte +22 -15
- package/src/lib/components/VennDiagram.svelte +25 -13
- package/src/lib/components/ViolinPlot.svelte +31 -19
- package/src/lib/components/VirtualList.svelte +25 -13
- package/src/lib/components/WaffleChart.svelte +32 -18
- package/src/lib/components/WaterfallChart.svelte +33 -26
- package/src/lib/components/WordCloud.svelte +21 -14
- package/src/lib/icons/AlarmIcon.svelte +4 -1
- package/src/lib/icons/BellIcon.svelte +2 -1
- package/src/lib/icons/CaretIcon.svelte +5 -3
- package/src/lib/icons/ClientsIcon.svelte +4 -1
- package/src/lib/icons/CloseIcon.svelte +2 -1
- package/src/lib/icons/DashboardIcon.svelte +4 -1
- package/src/lib/icons/DevicesIcon.svelte +4 -1
- package/src/lib/icons/DownloadIcon.svelte +2 -1
- package/src/lib/icons/HelpIcon.svelte +2 -1
- package/src/lib/icons/InfraIcon.svelte +4 -1
- package/src/lib/icons/IntegrationsIcon.svelte +4 -1
- package/src/lib/icons/LogsIcon.svelte +4 -1
- package/src/lib/icons/PlusIcon.svelte +2 -1
- package/src/lib/icons/PortsIcon.svelte +4 -1
- package/src/lib/icons/SearchIcon.svelte +6 -4
- package/src/lib/icons/SecurityIcon.svelte +4 -1
- package/src/lib/icons/SettingsIcon.svelte +4 -1
- package/src/lib/icons/TopologyIcon.svelte +4 -1
- package/src/lib/icons/UpdatesIcon.svelte +2 -1
- package/src/lib/icons/VpnIcon.svelte +4 -1
- package/src/lib/icons/WifiIcon.svelte +4 -1
- package/src/lib/icons/WirelessIcon.svelte +4 -1
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
let counter = 0;
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
interface Props {
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
value?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
class?: string;
|
|
13
|
+
onchange?: (payload: string) => void;
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
let {
|
|
17
|
+
label = undefined,
|
|
18
|
+
value = $bindable('0.0.0.0'),
|
|
19
|
+
disabled = false,
|
|
20
|
+
class: className = '',
|
|
21
|
+
onchange,
|
|
22
|
+
}: Props = $props();
|
|
15
23
|
const uid = `dash-ui-ip-${++counter}`;
|
|
16
24
|
|
|
17
25
|
function clampOctet(s: string): string {
|
|
@@ -26,8 +34,8 @@
|
|
|
26
34
|
return [parts[0] ?? '0', parts[1] ?? '0', parts[2] ?? '0', parts[3] ?? '0'];
|
|
27
35
|
}
|
|
28
36
|
|
|
29
|
-
let octets: [string, string, string, string] = parseIP(value);
|
|
30
|
-
let inputs: (HTMLInputElement | null)[] = [null, null, null, null];
|
|
37
|
+
let octets: [string, string, string, string] = $state(parseIP(value));
|
|
38
|
+
let inputs: (HTMLInputElement | null)[] = $state([null, null, null, null]);
|
|
31
39
|
|
|
32
40
|
function focusAt(i: number) {
|
|
33
41
|
const el = inputs[i];
|
|
@@ -39,7 +47,7 @@
|
|
|
39
47
|
octets[i] = clampOctet(raw);
|
|
40
48
|
octets = octets as [string, string, string, string];
|
|
41
49
|
value = octets.join('.');
|
|
42
|
-
|
|
50
|
+
onchange?.(value);
|
|
43
51
|
if (raw.length === 3 && i < 3) setTimeout(() => focusAt(i + 1), 0);
|
|
44
52
|
}
|
|
45
53
|
|
|
@@ -63,7 +71,7 @@
|
|
|
63
71
|
e.preventDefault();
|
|
64
72
|
octets = text.split('.').map(clampOctet) as [string, string, string, string];
|
|
65
73
|
value = octets.join('.');
|
|
66
|
-
|
|
74
|
+
onchange?.(value);
|
|
67
75
|
setTimeout(() => focusAt(3), 0);
|
|
68
76
|
}
|
|
69
77
|
}
|
|
@@ -90,10 +98,10 @@
|
|
|
90
98
|
{disabled}
|
|
91
99
|
maxlength={3}
|
|
92
100
|
class="ip-input__octet"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
101
|
+
oninput={(e) => commitOctet(i, e.currentTarget.value)}
|
|
102
|
+
onkeydown={(e) => handleKey(i, e)}
|
|
103
|
+
onpaste={handlePaste}
|
|
104
|
+
onfocus={(e) => e.currentTarget.select()}
|
|
97
105
|
/>
|
|
98
106
|
{#if i < 3}
|
|
99
107
|
<span class="ip-input__dot" aria-hidden="true">.</span>
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export interface IcicleNode {
|
|
3
3
|
label: string;
|
|
4
4
|
value?: number;
|
|
5
5
|
color?: string;
|
|
6
6
|
children?: IcicleNode[];
|
|
7
7
|
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
root: IcicleNode;
|
|
14
|
+
height?: number;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
}
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
export let height = 160;
|
|
11
|
-
export let ariaLabel = 'Icicle chart';
|
|
18
|
+
let { root, height = 160, ariaLabel = 'Icicle chart' }: Props = $props();
|
|
12
19
|
|
|
13
20
|
const PALETTE = ['#FF7B7B', '#F5A623', '#A78BFA', '#34D399', '#006FFF', '#00C875', '#FB923C'];
|
|
14
21
|
const VW = 340;
|
|
@@ -49,9 +56,9 @@
|
|
|
49
56
|
return cells;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
let depth = $derived(treeDepth(root));
|
|
60
|
+
let levelH = $derived(height / (depth + 1));
|
|
61
|
+
let cells = $derived(flatten(root, 0, 0, VW, levelH, 0, PALETTE[0], { n: 0 }));
|
|
55
62
|
</script>
|
|
56
63
|
|
|
57
64
|
{#if cells.length > 0}
|
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
type?: 'button' | 'submit' | 'reset';
|
|
7
|
+
class?: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
onclick?: (event: MouseEvent) => void;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// svelte-ignore state_referenced_locally
|
|
15
|
+
// svelte-ignore state_referenced_locally
|
|
16
|
+
let {
|
|
17
|
+
title = undefined,
|
|
18
|
+
type = 'button',
|
|
19
|
+
class: className = '',
|
|
20
|
+
style = '',
|
|
21
|
+
onclick,
|
|
22
|
+
children,
|
|
23
|
+
...rest
|
|
24
|
+
}: Props = $props();
|
|
7
25
|
</script>
|
|
8
26
|
|
|
9
27
|
<button
|
|
@@ -11,9 +29,9 @@
|
|
|
11
29
|
class="icon-btn {className}"
|
|
12
30
|
{title}
|
|
13
31
|
{style}
|
|
14
|
-
{
|
|
15
|
-
aria-label={
|
|
16
|
-
|
|
32
|
+
{...rest}
|
|
33
|
+
aria-label={(rest['aria-label'] as string | undefined) ?? title}
|
|
34
|
+
{onclick}
|
|
17
35
|
>
|
|
18
|
-
|
|
36
|
+
{@render children?.()}
|
|
19
37
|
</button>
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tick } from 'svelte';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
interface Props {
|
|
5
|
+
value: string;
|
|
6
|
+
onconfirm: (v: string) => void;
|
|
7
|
+
label: string;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
value,
|
|
13
|
+
onconfirm,
|
|
14
|
+
label,
|
|
15
|
+
placeholder = ''
|
|
16
|
+
}: Props = $props();
|
|
8
17
|
|
|
9
|
-
let editing = false;
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
let
|
|
18
|
+
let editing = $state(false);
|
|
19
|
+
// svelte-ignore state_referenced_locally
|
|
20
|
+
let draft = $state(value);
|
|
21
|
+
let inputEl = $state<HTMLInputElement | undefined>(undefined);
|
|
22
|
+
let editBtnEl = $state<HTMLButtonElement | undefined>(undefined);
|
|
13
23
|
|
|
14
24
|
async function startEdit() {
|
|
15
25
|
draft = value;
|
|
@@ -47,14 +57,14 @@
|
|
|
47
57
|
aria-label="Edit {label}"
|
|
48
58
|
bind:value={draft}
|
|
49
59
|
{placeholder}
|
|
50
|
-
|
|
60
|
+
onkeydown={handleKeydown}
|
|
51
61
|
/>
|
|
52
|
-
<button type="button" class="ie__btn ie__btn--save" aria-label="Save"
|
|
62
|
+
<button type="button" class="ie__btn ie__btn--save" aria-label="Save" onclick={confirm}>
|
|
53
63
|
<svg viewBox="0 0 14 14" width="12" height="12" fill="none" aria-hidden="true" focusable="false">
|
|
54
64
|
<path d="M2.5 7.5l3.5 3.5L12 3" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
55
65
|
</svg>
|
|
56
66
|
</button>
|
|
57
|
-
<button type="button" class="ie__btn ie__btn--cancel" aria-label="Cancel"
|
|
67
|
+
<button type="button" class="ie__btn ie__btn--cancel" aria-label="Cancel" onclick={cancel}>
|
|
58
68
|
<svg viewBox="0 0 14 14" width="12" height="12" fill="none" aria-hidden="true" focusable="false">
|
|
59
69
|
<path d="M3 3l8 8M11 3l-8 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
60
70
|
</svg>
|
|
@@ -63,7 +73,7 @@
|
|
|
63
73
|
{:else}
|
|
64
74
|
<span class="ie">
|
|
65
75
|
<span class="ie__text">{value}</span>
|
|
66
|
-
<button bind:this={editBtnEl} type="button" class="ie__edit" aria-label="Edit {label}"
|
|
76
|
+
<button bind:this={editBtnEl} type="button" class="ie__edit" aria-label="Edit {label}" onclick={startEdit}>
|
|
67
77
|
<svg viewBox="0 0 14 14" width="12" height="12" fill="none" aria-hidden="true" focusable="false">
|
|
68
78
|
<path d="M9.5 2l2.5 2.5-8 8H1.5v-2.5l8-8z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
69
79
|
</svg>
|
|
@@ -1,18 +1,75 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
value?: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
class?: string;
|
|
7
|
+
style?: string;
|
|
8
|
+
oninput?: (event: Event) => void;
|
|
9
|
+
onchange?: (event: Event) => void;
|
|
10
|
+
onfocus?: (event: FocusEvent) => void;
|
|
11
|
+
onblur?: (event: FocusEvent) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
value = $bindable(''),
|
|
16
|
+
placeholder = '',
|
|
17
|
+
type = 'text',
|
|
18
|
+
class: className = '',
|
|
19
|
+
style = '',
|
|
20
|
+
oninput,
|
|
21
|
+
onchange,
|
|
22
|
+
onfocus,
|
|
23
|
+
onblur,
|
|
24
|
+
}: Props = $props();
|
|
8
25
|
</script>
|
|
9
26
|
|
|
10
27
|
{#if type === 'text'}
|
|
11
|
-
<input
|
|
28
|
+
<input
|
|
29
|
+
class="input {className}"
|
|
30
|
+
type="text"
|
|
31
|
+
{placeholder}
|
|
32
|
+
bind:value
|
|
33
|
+
{style}
|
|
34
|
+
{oninput}
|
|
35
|
+
{onchange}
|
|
36
|
+
{onfocus}
|
|
37
|
+
{onblur}
|
|
38
|
+
/>
|
|
12
39
|
{:else if type === 'password'}
|
|
13
|
-
<input
|
|
40
|
+
<input
|
|
41
|
+
class="input {className}"
|
|
42
|
+
type="password"
|
|
43
|
+
{placeholder}
|
|
44
|
+
bind:value
|
|
45
|
+
{style}
|
|
46
|
+
{oninput}
|
|
47
|
+
{onchange}
|
|
48
|
+
{onfocus}
|
|
49
|
+
{onblur}
|
|
50
|
+
/>
|
|
14
51
|
{:else if type === 'number'}
|
|
15
|
-
<input
|
|
52
|
+
<input
|
|
53
|
+
class="input {className}"
|
|
54
|
+
type="number"
|
|
55
|
+
{placeholder}
|
|
56
|
+
bind:value
|
|
57
|
+
{style}
|
|
58
|
+
{oninput}
|
|
59
|
+
{onchange}
|
|
60
|
+
{onfocus}
|
|
61
|
+
{onblur}
|
|
62
|
+
/>
|
|
16
63
|
{:else}
|
|
17
|
-
<input
|
|
64
|
+
<input
|
|
65
|
+
class="input {className}"
|
|
66
|
+
{type}
|
|
67
|
+
{placeholder}
|
|
68
|
+
{value}
|
|
69
|
+
{style}
|
|
70
|
+
{oninput}
|
|
71
|
+
{onchange}
|
|
72
|
+
{onfocus}
|
|
73
|
+
{onblur}
|
|
74
|
+
/>
|
|
18
75
|
{/if}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
prefix?: string | undefined;
|
|
4
|
+
suffix?: string | undefined;
|
|
5
|
+
children?: import('svelte').Snippet;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let { prefix = undefined, suffix = undefined, children }: Props = $props();
|
|
4
9
|
</script>
|
|
5
10
|
|
|
6
11
|
<div class="input-group">
|
|
7
12
|
{#if prefix !== undefined}
|
|
8
13
|
<span class="input-group-addon input-group-addon--prefix">{prefix}</span>
|
|
9
14
|
{/if}
|
|
10
|
-
|
|
15
|
+
{@render children?.()}
|
|
11
16
|
{#if suffix !== undefined}
|
|
12
17
|
<span class="input-group-addon input-group-addon--suffix">{suffix}</span>
|
|
13
18
|
{/if}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export type { JsVal } from './JsonViewerNode.svelte';
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
6
|
import JsonViewerNode from './JsonViewerNode.svelte';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import type { JsVal } from './JsonViewerNode.svelte';
|
|
8
|
+
interface Props {
|
|
9
|
+
data: unknown;
|
|
10
|
+
label?: string;
|
|
11
|
+
defaultExpanded?: boolean;
|
|
12
|
+
maxDepth?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
data,
|
|
17
|
+
label = 'JSON viewer',
|
|
18
|
+
defaultExpanded = true,
|
|
19
|
+
maxDepth = 3
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
let root = $derived(data as JsVal);
|
|
11
22
|
</script>
|
|
12
23
|
|
|
13
24
|
<div class="json-viewer" role="tree" aria-label={label}>
|
|
14
|
-
<JsonViewerNode v={
|
|
25
|
+
<JsonViewerNode v={root} depth={0} {maxDepth} startOpen={defaultExpanded} />
|
|
15
26
|
</div>
|
|
@@ -1,26 +1,44 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export type JsVal = string | number | boolean | null | JsVal[] | { [k: string]: JsVal };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import JsonViewerNode from './JsonViewerNode.svelte';
|
|
7
|
+
interface Props {
|
|
8
|
+
v: JsVal;
|
|
9
|
+
k?: string | undefined;
|
|
10
|
+
depth?: number;
|
|
11
|
+
maxDepth?: number;
|
|
12
|
+
startOpen?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
v,
|
|
17
|
+
k = undefined,
|
|
18
|
+
depth = 0,
|
|
19
|
+
maxDepth = 3,
|
|
20
|
+
startOpen = true
|
|
21
|
+
}: Props = $props();
|
|
8
22
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
let isArr = $derived(Array.isArray(v));
|
|
24
|
+
let isObj = $derived(v !== null && typeof v === 'object');
|
|
25
|
+
let expandable = $derived(isArr || isObj);
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
// `open` is initialised from `startOpen`/`depth`/`maxDepth` props but is
|
|
28
|
+
// intentionally a one-shot snapshot at construction time — afterwards
|
|
29
|
+
// the user controls it via the toggle.
|
|
30
|
+
// svelte-ignore state_referenced_locally
|
|
31
|
+
let open = $state(startOpen && depth < maxDepth);
|
|
14
32
|
|
|
15
|
-
|
|
33
|
+
let entries = $derived(isArr
|
|
16
34
|
? (v as JsVal[]).map((item: JsVal, i: number) => ({ ek: String(i), ev: item, arrItem: true }))
|
|
17
35
|
: isObj
|
|
18
36
|
? Object.entries(v as { [key: string]: JsVal }).map(([ek, ev]) => ({ ek, ev, arrItem: false }))
|
|
19
|
-
: [];
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
: []);
|
|
38
|
+
let count = $derived(entries.length);
|
|
39
|
+
let ob = $derived(isArr ? '[' : '{');
|
|
40
|
+
let cb = $derived(isArr ? ']' : '}');
|
|
41
|
+
let indent = $derived(depth * 14);
|
|
24
42
|
</script>
|
|
25
43
|
|
|
26
44
|
{#if !expandable}
|
|
@@ -36,7 +54,7 @@
|
|
|
36
54
|
<button
|
|
37
55
|
type="button"
|
|
38
56
|
class="jv-toggle-row"
|
|
39
|
-
|
|
57
|
+
onclick={() => (open = !open)}
|
|
40
58
|
aria-label="{open ? 'Collapse' : 'Expand'} {k ?? (isArr ? 'array' : 'object')}"
|
|
41
59
|
style:padding-left="{indent}px"
|
|
42
60
|
>
|
|
@@ -48,7 +66,7 @@
|
|
|
48
66
|
{#if open}
|
|
49
67
|
<div role="group" class="jv-children">
|
|
50
68
|
{#each entries as { ek, ev, arrItem } (ek)}
|
|
51
|
-
<
|
|
69
|
+
<JsonViewerNode v={ev} k={arrItem ? undefined : ek} depth={depth + 1} {maxDepth} {startOpen} />
|
|
52
70
|
{/each}
|
|
53
71
|
<div class="jv-row jv-close" style:padding-left="{indent}px">
|
|
54
72
|
<span class="jv-bracket">{cb}</span>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
rows?: Array<{ label: string; value: string; valueColor?: string }>;
|
|
4
|
+
caption?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
let { rows = [], caption = undefined }: Props = $props();
|
|
4
8
|
</script>
|
|
5
9
|
|
|
6
10
|
<table class="kv-table">
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export interface KanbanCard {
|
|
3
3
|
id: string;
|
|
4
4
|
title: string;
|
|
5
5
|
subtitle?: string;
|
|
6
6
|
meta?: string;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
export interface KanbanColumn {
|
|
10
9
|
id: string;
|
|
11
10
|
title: string;
|
|
12
11
|
color?: string;
|
|
13
12
|
cards: KanbanCard[];
|
|
14
13
|
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
interface Props {
|
|
20
|
+
columns: KanbanColumn[];
|
|
21
|
+
onCardMove?: ((cardId: string, fromColId: string, toColId: string) => void) | undefined;
|
|
22
|
+
ariaLabel?: string;
|
|
23
|
+
}
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
export let onCardMove: ((cardId: string, fromColId: string, toColId: string) => void) | undefined = undefined;
|
|
18
|
-
export let ariaLabel: string = 'Kanban board';
|
|
25
|
+
let { columns, onCardMove = undefined, ariaLabel = 'Kanban board' }: Props = $props();
|
|
19
26
|
|
|
20
|
-
let announce = '';
|
|
21
|
-
let grabbed: { cardId: string; colId: string } | null = null;
|
|
22
|
-
let dragSrc: { cardId: string; colId: string } | null = null;
|
|
23
|
-
let dragOverCol: string | null = null;
|
|
24
|
-
let cardRefs: Record<string, HTMLButtonElement> = {};
|
|
27
|
+
let announce = $state('');
|
|
28
|
+
let grabbed: { cardId: string; colId: string } | null = $state(null);
|
|
29
|
+
let dragSrc: { cardId: string; colId: string } | null = $state(null);
|
|
30
|
+
let dragOverCol: string | null = $state(null);
|
|
31
|
+
let cardRefs: Record<string, HTMLButtonElement> = $state({});
|
|
25
32
|
|
|
26
33
|
const announceId = `kanban-announce-${Math.random().toString(36).slice(2, 9)}`;
|
|
27
34
|
|
|
@@ -96,13 +103,13 @@
|
|
|
96
103
|
class="kanban-col"
|
|
97
104
|
class:kanban-col--over={dragOverCol === col.id}
|
|
98
105
|
role="listitem"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
ondragover={e => handleDragOver(e, col.id)}
|
|
107
|
+
ondragleave={() => { dragOverCol = null; }}
|
|
108
|
+
ondrop={e => handleDrop(e, col.id)}
|
|
102
109
|
>
|
|
103
110
|
<div class="kanban-col-header">
|
|
104
111
|
{#if col.color}
|
|
105
|
-
<span class="kanban-col-dot" style="background:{col.color}" aria-hidden="true"
|
|
112
|
+
<span class="kanban-col-dot" style="background:{col.color}" aria-hidden="true"></span>
|
|
106
113
|
{/if}
|
|
107
114
|
<span class="kanban-col-title">{col.title}</span>
|
|
108
115
|
<span class="kanban-col-count" aria-label="{col.cards.length} card{col.cards.length !== 1 ? 's' : ''}">
|
|
@@ -121,9 +128,9 @@
|
|
|
121
128
|
draggable={true}
|
|
122
129
|
aria-pressed={isGrabbed}
|
|
123
130
|
aria-label="{card.title}{card.subtitle ? `, ${card.subtitle}` : ''}{card.meta ? `, ${card.meta}` : ''}. {isGrabbed ? 'Moving. Use arrow keys to change column, Space to drop, Escape to cancel.' : 'Press Space to move.'}"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
onkeydown={e => handleKeyDown(e, card, col)}
|
|
132
|
+
ondragstart={e => handleDragStart(e, card.id, col.id)}
|
|
133
|
+
ondragend={() => { dragSrc = null; dragOverCol = null; }}
|
|
127
134
|
>
|
|
128
135
|
<span class="kanban-card-title">{card.title}</span>
|
|
129
136
|
{#if card.subtitle}<span class="kanban-card-sub">{card.subtitle}</span>{/if}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
keys: string | string[];
|
|
4
|
+
class?: string;
|
|
5
|
+
}
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
let { keys, class: className = '' }: Props = $props();
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
let parts = $derived(typeof keys === 'string' ? keys.split('+') : keys);
|
|
7
11
|
</script>
|
|
8
12
|
|
|
9
13
|
<kbd class="kbd {className}">
|
|
@@ -1,25 +1,37 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export interface LineChartSeries {
|
|
3
3
|
label: string;
|
|
4
4
|
color: string;
|
|
5
5
|
values: number[];
|
|
6
6
|
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
series?: LineChartSeries[];
|
|
13
|
+
labels?: string[];
|
|
14
|
+
height?: number;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
}
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
let {
|
|
19
|
+
series = [],
|
|
20
|
+
labels = [],
|
|
21
|
+
height = 160,
|
|
22
|
+
ariaLabel = 'Line chart'
|
|
23
|
+
}: Props = $props();
|
|
12
24
|
|
|
13
25
|
const VW = 400;
|
|
14
26
|
const PAD = { t: 12, r: 8, b: 28, l: 8 };
|
|
15
27
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
let allValues = $derived(series.flatMap((s) => s.values));
|
|
29
|
+
let minV = $derived(allValues.length ? Math.min(...allValues) : 0);
|
|
30
|
+
let maxV = $derived(allValues.length ? Math.max(...allValues) : 1);
|
|
31
|
+
let range = $derived(maxV - minV || 1);
|
|
32
|
+
let chartW = $derived(VW - PAD.l - PAD.r);
|
|
33
|
+
let chartH = $derived(height - PAD.t - PAD.b);
|
|
34
|
+
let n = $derived(series[0]?.values.length ?? 0);
|
|
23
35
|
|
|
24
36
|
function toX(i: number): number {
|
|
25
37
|
return PAD.l + (n > 1 ? (i / (n - 1)) * chartW : chartW / 2);
|
|
@@ -28,14 +40,14 @@
|
|
|
28
40
|
return PAD.t + chartH - ((v - minV) / range) * chartH;
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
let gridLines = $derived([0, 0.25, 0.5, 0.75, 1].map((f) => PAD.t + (1 - f) * chartH));
|
|
32
44
|
|
|
33
|
-
|
|
45
|
+
let paths = $derived(series.map((s) => {
|
|
34
46
|
const pts = s.values.map((v, i) => `${toX(i).toFixed(1)},${toY(v).toFixed(1)}`);
|
|
35
47
|
return { color: s.color, label: s.label, d: `M ${pts.join(' L ')}` };
|
|
36
|
-
});
|
|
48
|
+
}));
|
|
37
49
|
|
|
38
|
-
|
|
50
|
+
let areas = $derived(series.map((s) => {
|
|
39
51
|
const pts = s.values.map((v, i) => `${toX(i).toFixed(1)},${toY(v).toFixed(1)}`);
|
|
40
52
|
const bot = (PAD.t + chartH).toFixed(1);
|
|
41
53
|
return {
|
|
@@ -43,7 +55,7 @@
|
|
|
43
55
|
label: s.label,
|
|
44
56
|
d: `M ${toX(0).toFixed(1)},${bot} L ${pts.join(' L ')} L ${toX(n - 1).toFixed(1)},${bot} Z`,
|
|
45
57
|
};
|
|
46
|
-
});
|
|
58
|
+
}));
|
|
47
59
|
</script>
|
|
48
60
|
|
|
49
61
|
<div role="img" aria-label={ariaLabel} style="width:100%;">
|