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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { Block } from "@gradio/atoms";
|
| 3 |
+
import type { SvelteComponent, ComponentType } from "svelte";
|
| 4 |
+
import type { Gradio, SelectData } from "@gradio/utils";
|
| 5 |
+
import { BaseExample } from "@gradio/textbox";
|
| 6 |
+
import type { load_component as load_component_type } from "@gradio/utils";
|
| 7 |
+
|
| 8 |
+
export let components: string[];
|
| 9 |
+
export let component_props: Record<string, any>[];
|
| 10 |
+
let component_map: Map<
|
| 11 |
+
string,
|
| 12 |
+
Promise<{
|
| 13 |
+
default: ComponentType<SvelteComponent>;
|
| 14 |
+
}>
|
| 15 |
+
> = new Map();
|
| 16 |
+
export let load_component: load_component_type;
|
| 17 |
+
export let headers: string[];
|
| 18 |
+
export let samples: any[][] | null = null;
|
| 19 |
+
let old_samples: any[][] | null = null;
|
| 20 |
+
export let sample_labels: string[] | null = null;
|
| 21 |
+
export let value: number | null = null;
|
| 22 |
+
export let root: string;
|
| 23 |
+
export let proxy_url: null | string;
|
| 24 |
+
export let samples_per_page = 10;
|
| 25 |
+
export let onclick: (data: SelectData) => void;
|
| 26 |
+
export let onselect: (data: SelectData) => void;
|
| 27 |
+
|
| 28 |
+
export let layout: "gallery" | "table" | null = null;
|
| 29 |
+
|
| 30 |
+
// Although the `samples_dir` prop is not used in any of the core Gradio component, it is kept for backward compatibility
|
| 31 |
+
// with any custom components created with gradio<=4.20.0
|
| 32 |
+
let samples_dir: string = proxy_url
|
| 33 |
+
? `/proxy=${proxy_url}file=`
|
| 34 |
+
: `${root}/file=`;
|
| 35 |
+
let page = 0;
|
| 36 |
+
|
| 37 |
+
$: gallery =
|
| 38 |
+
(components.length < 2 || sample_labels !== null) && layout !== "table";
|
| 39 |
+
let paginate = samples ? samples.length > samples_per_page : false;
|
| 40 |
+
|
| 41 |
+
let selected_samples: any[][];
|
| 42 |
+
let page_count: number;
|
| 43 |
+
let visible_pages: number[] = [];
|
| 44 |
+
|
| 45 |
+
let current_hover = -1;
|
| 46 |
+
|
| 47 |
+
function handle_mouseenter(i: number): void {
|
| 48 |
+
current_hover = i;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function handle_mouseleave(): void {
|
| 52 |
+
current_hover = -1;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
$: {
|
| 56 |
+
if (sample_labels) {
|
| 57 |
+
samples = sample_labels.map((e) => [e]);
|
| 58 |
+
} else if (!samples) {
|
| 59 |
+
samples = [];
|
| 60 |
+
}
|
| 61 |
+
if (JSON.stringify(samples) !== JSON.stringify(old_samples)) {
|
| 62 |
+
page = 0;
|
| 63 |
+
old_samples = samples;
|
| 64 |
+
}
|
| 65 |
+
paginate = samples.length > samples_per_page;
|
| 66 |
+
if (paginate) {
|
| 67 |
+
visible_pages = [];
|
| 68 |
+
selected_samples = samples.slice(
|
| 69 |
+
page * samples_per_page,
|
| 70 |
+
(page + 1) * samples_per_page
|
| 71 |
+
);
|
| 72 |
+
page_count = Math.ceil(samples.length / samples_per_page);
|
| 73 |
+
[0, page, page_count - 1].forEach((anchor) => {
|
| 74 |
+
for (let i = anchor - 2; i <= anchor + 2; i++) {
|
| 75 |
+
if (i >= 0 && i < page_count && !visible_pages.includes(i)) {
|
| 76 |
+
if (
|
| 77 |
+
visible_pages.length > 0 &&
|
| 78 |
+
i - visible_pages[visible_pages.length - 1] > 1
|
| 79 |
+
) {
|
| 80 |
+
visible_pages.push(-1);
|
| 81 |
+
}
|
| 82 |
+
visible_pages.push(i);
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
});
|
| 86 |
+
} else {
|
| 87 |
+
selected_samples = samples.slice();
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
let component_meta: {
|
| 92 |
+
value: any;
|
| 93 |
+
component: ComponentType<SvelteComponent>;
|
| 94 |
+
}[][] = [];
|
| 95 |
+
|
| 96 |
+
async function get_component_meta(
|
| 97 |
+
selected_samples_json: string
|
| 98 |
+
): Promise<void> {
|
| 99 |
+
const _selected_samples: any[][] = JSON.parse(selected_samples_json);
|
| 100 |
+
|
| 101 |
+
// @ts-ignore
|
| 102 |
+
component_meta = await Promise.all(
|
| 103 |
+
_selected_samples &&
|
| 104 |
+
_selected_samples.map(
|
| 105 |
+
async (sample_row) =>
|
| 106 |
+
await Promise.all(
|
| 107 |
+
sample_row.map(async (sample_cell, j) => {
|
| 108 |
+
return {
|
| 109 |
+
value: sample_cell,
|
| 110 |
+
component: load_component(components[j], "example")
|
| 111 |
+
};
|
| 112 |
+
})
|
| 113 |
+
)
|
| 114 |
+
)
|
| 115 |
+
);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Need to striginfiy the samples otherwise get_component_meta will trigger infinitely
|
| 119 |
+
// Saw this when rendering examples in a gr.render block
|
| 120 |
+
$: selected_samples_json = JSON.stringify(selected_samples || []);
|
| 121 |
+
|
| 122 |
+
// $: get_component_meta(selected_samples_json);
|
| 123 |
+
</script>
|
| 124 |
+
|
| 125 |
+
{#await get_component_meta(selected_samples_json) then _}
|
| 126 |
+
{#if gallery}
|
| 127 |
+
<div class="gallery">
|
| 128 |
+
{#each selected_samples as sample_row, i}
|
| 129 |
+
{#if sample_row[0] != null}
|
| 130 |
+
<button
|
| 131 |
+
class="gallery-item"
|
| 132 |
+
on:click={() => {
|
| 133 |
+
value = i + page * samples_per_page;
|
| 134 |
+
onclick({ index: value, value: sample_row });
|
| 135 |
+
onselect({ index: value, value: sample_row });
|
| 136 |
+
}}
|
| 137 |
+
on:mouseenter={() => handle_mouseenter(i)}
|
| 138 |
+
on:mouseleave={() => handle_mouseleave()}
|
| 139 |
+
>
|
| 140 |
+
{#if sample_labels}
|
| 141 |
+
<BaseExample
|
| 142 |
+
value={sample_row[0]}
|
| 143 |
+
selected={current_hover === i}
|
| 144 |
+
type="gallery"
|
| 145 |
+
/>
|
| 146 |
+
{:else if component_meta.length}
|
| 147 |
+
{#await component_meta[0][0].component then component}
|
| 148 |
+
{#key sample_row[0]}
|
| 149 |
+
<svelte:component
|
| 150 |
+
this={component.default}
|
| 151 |
+
{...component_props[0]}
|
| 152 |
+
value={sample_row[0]}
|
| 153 |
+
{samples_dir}
|
| 154 |
+
type="gallery"
|
| 155 |
+
selected={current_hover === i}
|
| 156 |
+
index={i}
|
| 157 |
+
{root}
|
| 158 |
+
/>
|
| 159 |
+
{/key}
|
| 160 |
+
{/await}
|
| 161 |
+
{/if}
|
| 162 |
+
</button>
|
| 163 |
+
{/if}
|
| 164 |
+
{/each}
|
| 165 |
+
</div>
|
| 166 |
+
{:else if selected_samples.length > 0}
|
| 167 |
+
<div class="table-wrap">
|
| 168 |
+
<table tabindex="0" role="grid">
|
| 169 |
+
<thead>
|
| 170 |
+
<tr class="tr-head">
|
| 171 |
+
{#each headers as header}
|
| 172 |
+
<th>
|
| 173 |
+
{header}
|
| 174 |
+
</th>
|
| 175 |
+
{/each}
|
| 176 |
+
</tr>
|
| 177 |
+
</thead>
|
| 178 |
+
<tbody>
|
| 179 |
+
{#each component_meta as sample_row, i}
|
| 180 |
+
<tr
|
| 181 |
+
class="tr-body"
|
| 182 |
+
on:click={() => {
|
| 183 |
+
value = i + page * samples_per_page;
|
| 184 |
+
onclick({ index: value, value: sample_row });
|
| 185 |
+
onselect({
|
| 186 |
+
index: value,
|
| 187 |
+
value: selected_samples[i]
|
| 188 |
+
});
|
| 189 |
+
}}
|
| 190 |
+
on:mouseenter={() => handle_mouseenter(i)}
|
| 191 |
+
on:mouseleave={() => handle_mouseleave()}
|
| 192 |
+
>
|
| 193 |
+
{#each sample_row as { value, component }, j}
|
| 194 |
+
{@const component_name = components[j]}
|
| 195 |
+
|
| 196 |
+
{#if component_name !== undefined}
|
| 197 |
+
<td
|
| 198 |
+
style="max-width: {component_name === 'textbox'
|
| 199 |
+
? '35ch'
|
| 200 |
+
: 'auto'}"
|
| 201 |
+
class={component_name}
|
| 202 |
+
>
|
| 203 |
+
{#await component then component}
|
| 204 |
+
<svelte:component
|
| 205 |
+
this={component.default}
|
| 206 |
+
{...component_props[j]}
|
| 207 |
+
{value}
|
| 208 |
+
{samples_dir}
|
| 209 |
+
type="table"
|
| 210 |
+
selected={current_hover === i}
|
| 211 |
+
index={i}
|
| 212 |
+
{root}
|
| 213 |
+
/>
|
| 214 |
+
{/await}
|
| 215 |
+
</td>
|
| 216 |
+
{/if}
|
| 217 |
+
{/each}
|
| 218 |
+
</tr>
|
| 219 |
+
{/each}
|
| 220 |
+
</tbody>
|
| 221 |
+
</table>
|
| 222 |
+
</div>
|
| 223 |
+
{/if}
|
| 224 |
+
{#if paginate}
|
| 225 |
+
<div class="paginate">
|
| 226 |
+
Pages:
|
| 227 |
+
{#each visible_pages as visible_page}
|
| 228 |
+
{#if visible_page === -1}
|
| 229 |
+
<div>...</div>
|
| 230 |
+
{:else}
|
| 231 |
+
<button
|
| 232 |
+
class:current-page={page === visible_page}
|
| 233 |
+
on:click={() => (page = visible_page)}
|
| 234 |
+
>
|
| 235 |
+
{visible_page + 1}
|
| 236 |
+
</button>
|
| 237 |
+
{/if}
|
| 238 |
+
{/each}
|
| 239 |
+
</div>
|
| 240 |
+
{/if}
|
| 241 |
+
{/await}
|
| 242 |
+
|
| 243 |
+
<style>
|
| 244 |
+
.wrap {
|
| 245 |
+
display: inline-block;
|
| 246 |
+
width: var(--size-full);
|
| 247 |
+
max-width: var(--size-full);
|
| 248 |
+
color: var(--body-text-color);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.hide {
|
| 252 |
+
display: none;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.gallery {
|
| 256 |
+
display: flex;
|
| 257 |
+
flex-wrap: wrap;
|
| 258 |
+
gap: var(--spacing-lg);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
.gallery-item {
|
| 262 |
+
border: 1px solid var(--border-color-primary);
|
| 263 |
+
border-radius: var(--button-large-radius);
|
| 264 |
+
overflow: hidden;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
.gallery-item:hover {
|
| 268 |
+
border-color: var(--border-color-accent);
|
| 269 |
+
background: var(--table-row-focus);
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
.table-wrap {
|
| 273 |
+
border: 1px solid var(--border-color-primary);
|
| 274 |
+
border-radius: var(--table-radius);
|
| 275 |
+
width: var(--size-full);
|
| 276 |
+
table-layout: auto;
|
| 277 |
+
overflow-x: auto;
|
| 278 |
+
line-height: var(--line-sm);
|
| 279 |
+
color: var(--table-text-color);
|
| 280 |
+
}
|
| 281 |
+
table {
|
| 282 |
+
width: var(--size-full);
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.tr-head {
|
| 286 |
+
box-shadow: var(--shadow-drop-lg);
|
| 287 |
+
border-bottom: 1px solid var(--border-color-primary);
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
.tr-head > * + * {
|
| 291 |
+
border-right-width: 0px;
|
| 292 |
+
border-left-width: 1px;
|
| 293 |
+
border-color: var(--border-color-primary);
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
th {
|
| 297 |
+
padding: var(--size-2);
|
| 298 |
+
white-space: nowrap;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.tr-body {
|
| 302 |
+
cursor: pointer;
|
| 303 |
+
border-bottom: 1px solid var(--border-color-primary);
|
| 304 |
+
background: var(--table-even-background-fill);
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
.tr-body:last-child {
|
| 308 |
+
border: none;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
.tr-body:nth-child(odd) {
|
| 312 |
+
background: var(--table-odd-background-fill);
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
.tr-body:hover {
|
| 316 |
+
background: var(--table-row-focus);
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
.tr-body > * + * {
|
| 320 |
+
border-right-width: 0px;
|
| 321 |
+
border-left-width: 1px;
|
| 322 |
+
border-color: var(--border-color-primary);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
.tr-body:hover > * + * {
|
| 326 |
+
border-color: var(--border-color-accent);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
td {
|
| 330 |
+
padding: var(--size-2);
|
| 331 |
+
text-align: center;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.paginate {
|
| 335 |
+
display: flex;
|
| 336 |
+
justify-content: center;
|
| 337 |
+
align-items: center;
|
| 338 |
+
gap: var(--spacing-sm);
|
| 339 |
+
margin-top: var(--size-2);
|
| 340 |
+
color: var(--block-label-text-color);
|
| 341 |
+
font-size: var(--text-sm);
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
button.current-page {
|
| 345 |
+
font-weight: var(--weight-bold);
|
| 346 |
+
}
|
| 347 |
+
</style>
|
6.0.2/dataset/Index.svelte
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { Block } from "@gradio/atoms";
|
| 3 |
+
import type { SvelteComponent, ComponentType } from "svelte";
|
| 4 |
+
import { Gradio } from "@gradio/utils";
|
| 5 |
+
import type { DatasetProps, DatasetEvents } from "./types";
|
| 6 |
+
|
| 7 |
+
import Dataset from "./Dataset.svelte";
|
| 8 |
+
|
| 9 |
+
let props = $props();
|
| 10 |
+
|
| 11 |
+
const gradio = new Gradio<DatasetEvents, DatasetProps>(props);
|
| 12 |
+
|
| 13 |
+
// Need to mark samples as state, otherwise get_component_meta constantly triggers
|
| 14 |
+
let samples = $derived(gradio.props.samples ?? []);
|
| 15 |
+
</script>
|
| 16 |
+
|
| 17 |
+
<Block
|
| 18 |
+
visible={gradio.shared.visible}
|
| 19 |
+
padding={false}
|
| 20 |
+
elem_id={gradio.shared.elem_id}
|
| 21 |
+
elem_classes={gradio.shared.elem_classes}
|
| 22 |
+
scale={gradio.shared.scale}
|
| 23 |
+
min_width={gradio.shared.min_width}
|
| 24 |
+
allow_overflow={false}
|
| 25 |
+
container={false}
|
| 26 |
+
>
|
| 27 |
+
{#if gradio.shared.show_label}
|
| 28 |
+
<div class="label">
|
| 29 |
+
<svg
|
| 30 |
+
xmlns="http://www.w3.org/2000/svg"
|
| 31 |
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
| 32 |
+
aria-hidden="true"
|
| 33 |
+
role="img"
|
| 34 |
+
width="1em"
|
| 35 |
+
height="1em"
|
| 36 |
+
preserveAspectRatio="xMidYMid meet"
|
| 37 |
+
viewBox="0 0 32 32"
|
| 38 |
+
>
|
| 39 |
+
<path
|
| 40 |
+
fill="currentColor"
|
| 41 |
+
d="M10 6h18v2H10zm0 18h18v2H10zm0-9h18v2H10zm-6 0h2v2H4zm0-9h2v2H4zm0 18h2v2H4z"
|
| 42 |
+
/>
|
| 43 |
+
</svg>
|
| 44 |
+
{gradio.shared.label || "Examples"}
|
| 45 |
+
</div>
|
| 46 |
+
{/if}
|
| 47 |
+
|
| 48 |
+
<Dataset
|
| 49 |
+
onclick={(d) => (
|
| 50 |
+
(gradio.props.value = d.index),
|
| 51 |
+
gradio.dispatch("click", gradio.props.value)
|
| 52 |
+
)}
|
| 53 |
+
onselect={(data) => gradio.dispatch("select", data)}
|
| 54 |
+
load_component={gradio.shared.load_component}
|
| 55 |
+
{samples}
|
| 56 |
+
{...gradio.props}
|
| 57 |
+
/>
|
| 58 |
+
</Block>
|
| 59 |
+
|
| 60 |
+
<style>
|
| 61 |
+
.label {
|
| 62 |
+
display: flex;
|
| 63 |
+
align-items: center;
|
| 64 |
+
margin-bottom: var(--size-2);
|
| 65 |
+
color: var(--block-label-text-color);
|
| 66 |
+
font-weight: var(--block-label-text-weight);
|
| 67 |
+
font-size: var(--block-label-text-size);
|
| 68 |
+
line-height: var(--line-sm);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
svg {
|
| 72 |
+
margin-right: var(--size-1);
|
| 73 |
+
}
|
| 74 |
+
</style>
|
6.0.2/dataset/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/dataset",
|
| 3 |
+
"version": "0.5.0",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"exports": {
|
| 11 |
+
".": {
|
| 12 |
+
"gradio": "./Index.svelte",
|
| 13 |
+
"svelte": "./dist/Index.svelte",
|
| 14 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 15 |
+
},
|
| 16 |
+
"./package.json": "./package.json"
|
| 17 |
+
},
|
| 18 |
+
"dependencies": {
|
| 19 |
+
"@gradio/atoms": "workspace:^",
|
| 20 |
+
"@gradio/client": "workspace:^",
|
| 21 |
+
"@gradio/utils": "workspace:^",
|
| 22 |
+
"@gradio/upload": "workspace:^",
|
| 23 |
+
"@gradio/textbox": "workspace:^"
|
| 24 |
+
},
|
| 25 |
+
"devDependencies": {
|
| 26 |
+
"@gradio/preview": "workspace:^"
|
| 27 |
+
},
|
| 28 |
+
"peerDependencies": {
|
| 29 |
+
"svelte": "^5.43.4"
|
| 30 |
+
},
|
| 31 |
+
"repository": {
|
| 32 |
+
"type": "git",
|
| 33 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 34 |
+
"directory": "js/dataset"
|
| 35 |
+
}
|
| 36 |
+
}
|
6.0.2/dataset/types.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { SelectData } from "@gradio/utils";
|
| 2 |
+
|
| 3 |
+
export interface DatasetProps {
|
| 4 |
+
components: string[];
|
| 5 |
+
component_props: Record<string, any>[];
|
| 6 |
+
headers: string[];
|
| 7 |
+
samples: any[][] | null;
|
| 8 |
+
sample_labels: string[] | null;
|
| 9 |
+
value: number | null;
|
| 10 |
+
root: string;
|
| 11 |
+
proxy_url: null | string;
|
| 12 |
+
samples_per_page: number;
|
| 13 |
+
|
| 14 |
+
layout: "gallery" | "table" | null;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
export interface DatasetEvents {
|
| 18 |
+
click: never;
|
| 19 |
+
select: SelectData;
|
| 20 |
+
}
|