@knitify/vue 2.1.0 → 2.2.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/README.md +4 -1
- package/dist/index.es.js +5533 -4141
- package/dist/index.umd.js +1 -1
- package/dist/types/components/ArticleList/types.d.ts +9 -2
- package/dist/types/components/ButtonGroup/KButtonGroup.vue.d.ts +11 -0
- package/dist/types/components/ButtonGroup/types.d.ts +7 -0
- package/dist/types/components/Chat/KChatPrompt.vue.d.ts +2 -2
- package/dist/types/components/ChatDock/KChatDock.vue.d.ts +2 -2
- package/dist/types/components/DataTable/KDataTable.vue.d.ts +71 -0
- package/dist/types/components/DataTable/KDataTableLinkCell.vue.d.ts +21 -0
- package/dist/types/components/DataTable/KDataTableSettings.vue.d.ts +32 -0
- package/dist/types/components/DataTable/KDataTableSort.vue.d.ts +17 -0
- package/dist/types/components/DataTable/columnTypes.d.ts +19 -0
- package/dist/types/components/DataTable/keys.d.ts +9 -0
- package/dist/types/components/DataTable/types.d.ts +269 -0
- package/dist/types/components/Dialog/KDialogHost.vue.d.ts +3 -0
- package/dist/types/components/Dialog/KDialogItem.vue.d.ts +16 -0
- package/dist/types/components/Dialog/types.d.ts +61 -0
- package/dist/types/components/Dialog/useDialog.d.ts +41 -0
- package/dist/types/components/Dropzone/KDropzone.vue.d.ts +39 -0
- package/dist/types/components/Dropzone/types.d.ts +89 -0
- package/dist/types/components/FileTree/KFileTree.vue.d.ts +2 -2
- package/dist/types/components/Modal/types.d.ts +4 -0
- package/dist/types/components/Table/types.d.ts +4 -2
- package/dist/types/components/Tabs/KTabs.vue.d.ts +1 -1
- package/dist/types/components/Tabs/types.d.ts +17 -0
- package/dist/types/components/TagsInput/KTagsInput.vue.d.ts +2 -2
- package/dist/types/components/Toast/types.d.ts +22 -0
- package/dist/types/components/Toast/useToast.d.ts +14 -2
- package/dist/types/components/Workspace/KWorkspace.vue.d.ts +2 -2
- package/dist/types/components/index.d.ts +7 -0
- package/dist/types/components/types.d.ts +5 -0
- package/dist/types/index.d.ts +11 -2
- package/dist/types/utils/useTopmost.d.ts +3 -1
- package/dist/web-types.json +781 -40
- package/package.json +3 -3
|
@@ -15,10 +15,10 @@ export type KArticleListItemProps = {
|
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
/** Excerpt, clamped to three lines by core. The default slot overrides it. */
|
|
17
17
|
excerpt?: string;
|
|
18
|
-
/** Forces the hover fill, for previews. */
|
|
18
|
+
/** Forces the hover fill and the actions slot open, for previews. */
|
|
19
19
|
hovered?: boolean;
|
|
20
20
|
href?: string;
|
|
21
|
-
/** Sprite id of the trailing
|
|
21
|
+
/** Sprite id of the trailing chevron, shown when there is no actions slot. */
|
|
22
22
|
icon?: string;
|
|
23
23
|
/** Article title. The `title` slot overrides it. */
|
|
24
24
|
title?: string;
|
|
@@ -32,9 +32,16 @@ export type KArticleListSlots = {
|
|
|
32
32
|
default?(): any;
|
|
33
33
|
};
|
|
34
34
|
export type KArticleListItemSlots = {
|
|
35
|
+
/**
|
|
36
|
+
* The overflow trigger, typically a `KDropdown` around a meatball
|
|
37
|
+
* `KButton`. Replaces the chevron. Core fades it in on hover or focus, and
|
|
38
|
+
* keeps it shown while the dropdown is open. Not rendered on a disabled row.
|
|
39
|
+
*/
|
|
40
|
+
actions?(): any;
|
|
35
41
|
date?(): any;
|
|
36
42
|
/** The excerpt. */
|
|
37
43
|
default?(): any;
|
|
44
|
+
/** The trailing chevron. Ignored when the actions slot is filled. */
|
|
38
45
|
icon?(): any;
|
|
39
46
|
title?(): any;
|
|
40
47
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KButtonGroupSlots } from './types';
|
|
2
|
+
type __VLS_Slots = KButtonGroupSlots;
|
|
3
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
8
|
+
new (): {
|
|
9
|
+
$slots: S;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -6,12 +6,12 @@ type __VLS_ModelProps = {
|
|
|
6
6
|
};
|
|
7
7
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
8
8
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
-
stop: () => any;
|
|
10
9
|
submit: (value: string) => any;
|
|
10
|
+
stop: () => any;
|
|
11
11
|
"update:modelValue": (value: string) => any;
|
|
12
12
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
13
|
-
onStop?: (() => any) | undefined;
|
|
14
13
|
onSubmit?: ((value: string) => any) | undefined;
|
|
14
|
+
onStop?: (() => any) | undefined;
|
|
15
15
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
16
16
|
}>, {
|
|
17
17
|
disabled: boolean;
|
|
@@ -21,16 +21,16 @@ declare const __VLS_base: import("vue").DefineComponent<KChatDockProps, {
|
|
|
21
21
|
togglePanel: typeof togglePanel;
|
|
22
22
|
refilter: typeof refilter;
|
|
23
23
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
-
select: (id: string, opened: boolean) => any;
|
|
25
24
|
search: (query: string) => any;
|
|
25
|
+
select: (id: string, opened: boolean) => any;
|
|
26
26
|
reflow: () => any;
|
|
27
27
|
launcher: () => any;
|
|
28
28
|
compose: () => any;
|
|
29
29
|
panel: (open: boolean) => any;
|
|
30
30
|
activate: (id: string) => any;
|
|
31
31
|
}, string, import("vue").PublicProps, Readonly<KChatDockProps> & Readonly<{
|
|
32
|
-
onSelect?: ((id: string, opened: boolean) => any) | undefined;
|
|
33
32
|
onSearch?: ((query: string) => any) | undefined;
|
|
33
|
+
onSelect?: ((id: string, opened: boolean) => any) | undefined;
|
|
34
34
|
onReflow?: (() => any) | undefined;
|
|
35
35
|
onLauncher?: (() => any) | undefined;
|
|
36
36
|
onCompose?: (() => any) | undefined;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { KTableSize } from '../Table/types';
|
|
2
|
+
import type { KDataTableActionLabels, KDataTableColumn, KDataTableEmits, KDataTableRowKey, KDataTableSettingsLabels, KDataTableSlots, KDataTableSortLabels, KDataTableSortRule } from './types';
|
|
3
|
+
declare const __VLS_export: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(Omit<import("../types.js").KTableProps, "size" | "striped"> & {
|
|
5
|
+
actionLabels?: Partial<KDataTableActionLabels>;
|
|
6
|
+
columns?: KDataTableColumn<T>[] | undefined;
|
|
7
|
+
emptyLabel?: string;
|
|
8
|
+
filterLabel?: string;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
maxHeight?: string;
|
|
11
|
+
nextLabel?: string;
|
|
12
|
+
pageSize?: number;
|
|
13
|
+
pinStart?: number;
|
|
14
|
+
prevLabel?: string;
|
|
15
|
+
rowKey?: string | ((row: T) => KDataTableRowKey) | undefined;
|
|
16
|
+
rows?: T[] | undefined;
|
|
17
|
+
searchPlaceholder?: string;
|
|
18
|
+
selectable?: boolean;
|
|
19
|
+
settingsLabel?: string;
|
|
20
|
+
settingsLabels?: Partial<KDataTableSettingsLabels>;
|
|
21
|
+
sortLabel?: string;
|
|
22
|
+
sortLabels?: Partial<KDataTableSortLabels>;
|
|
23
|
+
sortOptions?: import("../types.js").KSelectOption[];
|
|
24
|
+
total: number;
|
|
25
|
+
} & {
|
|
26
|
+
page?: number;
|
|
27
|
+
search?: string;
|
|
28
|
+
selected?: KDataTableRowKey[];
|
|
29
|
+
sort?: KDataTableSortRule[];
|
|
30
|
+
hiddenColumns?: string[];
|
|
31
|
+
size?: KTableSize;
|
|
32
|
+
striped?: boolean;
|
|
33
|
+
}) & {
|
|
34
|
+
onResize?: ((widths: number[]) => any) | undefined;
|
|
35
|
+
onAction?: ((action: string, row: T, column: {
|
|
36
|
+
key: string;
|
|
37
|
+
label: string;
|
|
38
|
+
resizable?: boolean;
|
|
39
|
+
sortable?: boolean;
|
|
40
|
+
} & {
|
|
41
|
+
type: "link";
|
|
42
|
+
} & {
|
|
43
|
+
to: (row: T) => import("vue-router").RouteLocationRaw;
|
|
44
|
+
}, payload?: unknown) => any) | undefined;
|
|
45
|
+
"onUpdate:page"?: ((value: number) => any) | undefined;
|
|
46
|
+
"onUpdate:hiddenColumns"?: ((value: string[]) => any) | undefined;
|
|
47
|
+
"onUpdate:size"?: ((value: KTableSize) => any) | undefined;
|
|
48
|
+
"onUpdate:striped"?: ((value: boolean) => any) | undefined;
|
|
49
|
+
"onUpdate:search"?: ((value: string) => any) | undefined;
|
|
50
|
+
"onUpdate:selected"?: ((value: KDataTableRowKey[]) => any) | undefined;
|
|
51
|
+
"onUpdate:sort"?: ((value: KDataTableSortRule[]) => any) | undefined;
|
|
52
|
+
}> & (typeof globalThis extends {
|
|
53
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
54
|
+
} ? P : {});
|
|
55
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
56
|
+
/** Hands every column back to automatic layout. */
|
|
57
|
+
reset: () => void | undefined;
|
|
58
|
+
}>) => void;
|
|
59
|
+
attrs: any;
|
|
60
|
+
slots: KDataTableSlots<T>;
|
|
61
|
+
emit: KDataTableEmits<T> & (((event: "update:page", value: number) => void) & ((event: "update:hiddenColumns", value: string[]) => void) & ((event: "update:size", value: KTableSize) => void) & ((event: "update:striped", value: boolean) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selected", value: KDataTableRowKey[]) => void) & ((event: "update:sort", value: KDataTableSortRule[]) => void));
|
|
62
|
+
}>) => import("vue").VNode & {
|
|
63
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
64
|
+
};
|
|
65
|
+
declare const _default: typeof __VLS_export;
|
|
66
|
+
export default _default;
|
|
67
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
68
|
+
[K in keyof T]: T[K];
|
|
69
|
+
} : {
|
|
70
|
+
[K in keyof T as K]: T[K];
|
|
71
|
+
}) & {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { KDataTableCellComponentProps } from './types';
|
|
2
|
+
declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<KDataTableCellComponentProps<T, "link"> & {
|
|
4
|
+
onAction?: ((action: string, payload?: unknown) => any) | undefined;
|
|
5
|
+
}> & (typeof globalThis extends {
|
|
6
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
7
|
+
} ? P : {});
|
|
8
|
+
expose: (exposed: {}) => void;
|
|
9
|
+
attrs: any;
|
|
10
|
+
slots: {};
|
|
11
|
+
emit: (evt: "action", action: string, payload?: unknown) => void;
|
|
12
|
+
}>) => import("vue").VNode & {
|
|
13
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
14
|
+
};
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
18
|
+
[K in keyof T]: T[K];
|
|
19
|
+
} : {
|
|
20
|
+
[K in keyof T as K]: T[K];
|
|
21
|
+
}) & {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { KTableSize } from '../Table/types';
|
|
2
|
+
import type { KDataTableColumn, KDataTableSettingsLabels } from './types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
columns: KDataTableColumn[];
|
|
5
|
+
labels: KDataTableSettingsLabels;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
default?(): any;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_ModelProps = {
|
|
11
|
+
'hiddenColumns'?: string[];
|
|
12
|
+
'size'?: KTableSize;
|
|
13
|
+
'striped'?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
16
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
"update:hiddenColumns": (value: string[]) => any;
|
|
18
|
+
"update:size": (value: KTableSize) => any;
|
|
19
|
+
"update:striped": (value: boolean) => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
21
|
+
"onUpdate:hiddenColumns"?: ((value: string[]) => any) | undefined;
|
|
22
|
+
"onUpdate:size"?: ((value: KTableSize) => any) | undefined;
|
|
23
|
+
"onUpdate:striped"?: ((value: boolean) => any) | undefined;
|
|
24
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KSelectOption } from '../Select/types';
|
|
2
|
+
import type { KDataTableSortLabels, KDataTableSortRule } from './types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
labels: KDataTableSortLabels;
|
|
5
|
+
options: KSelectOption[];
|
|
6
|
+
};
|
|
7
|
+
type __VLS_ModelProps = {
|
|
8
|
+
modelValue?: KDataTableSortRule[];
|
|
9
|
+
};
|
|
10
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
+
"update:modelValue": (value: KDataTableSortRule[]) => any;
|
|
13
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
14
|
+
"onUpdate:modelValue"?: ((value: KDataTableSortRule[]) => any) | undefined;
|
|
15
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Component } from 'vue';
|
|
2
|
+
import type { KDataTableColumnType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Makes `component` render the cells of every column whose `type` is `type`,
|
|
5
|
+
* in every KDataTable. Register before the app mounts — tables already on
|
|
6
|
+
* screen don't pick up a type registered later. Registering a name again
|
|
7
|
+
* replaces its component, built-in `link` included.
|
|
8
|
+
*
|
|
9
|
+
* Declare the type in `KDataTableColumnTypes` first; `type` only accepts the
|
|
10
|
+
* names declared there.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerColumnType(type: KDataTableColumnType, component: Component): void;
|
|
13
|
+
/**
|
|
14
|
+
* The component registered for `type`. With none, its cells fall back to
|
|
15
|
+
* plain text, and the first lookup warns so a missing `registerColumnType`
|
|
16
|
+
* call is noticed. Not gated on a dev flag: the library is prebuilt, so its
|
|
17
|
+
* own build would decide that, not the consumer's.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveColumnType(type: string): Component | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
import type { KDataTableActionLabels } from './types';
|
|
3
|
+
/** The `link` column type's menu text when `actionLabels` leaves an entry out. */
|
|
4
|
+
export declare const DEFAULT_ACTION_LABELS: KDataTableActionLabels;
|
|
5
|
+
export interface DataTableContext {
|
|
6
|
+
/** The resolved menu text for `link` cells, defaults filled in. */
|
|
7
|
+
actionLabels: ComputedRef<KDataTableActionLabels>;
|
|
8
|
+
}
|
|
9
|
+
export declare const dataTableKey: InjectionKey<DataTableContext>;
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
2
|
+
import type { KSelectOption } from '../Select/types';
|
|
3
|
+
import type { KTableProps } from '../Table/types';
|
|
4
|
+
type KDataTableColumnBase = {
|
|
5
|
+
/** The row field shown in this column, and the `cell-{key}` slot's name. */
|
|
6
|
+
key: string;
|
|
7
|
+
/** Header text. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Gives the header a drag handle for resizing the column. */
|
|
10
|
+
resizable?: boolean;
|
|
11
|
+
/** Offered in the sort popover's "Sort by". Defaults to `true`. */
|
|
12
|
+
sortable?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Every column type, keyed by the name a column's `type` takes, mapped to the
|
|
16
|
+
* extra options a column of that type requires. Add your own by augmenting it
|
|
17
|
+
* — with the same `<T>` — and registering a component for each:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* declare module '@knitify/vue' {
|
|
21
|
+
* interface KDataTableColumnTypes<T> {
|
|
22
|
+
* rating: { max: number } // a column of this type requires `max`
|
|
23
|
+
* currency: {} // no options of its own
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* registerColumnType('rating', RatingCell)
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* `T` is the row type, for options that take the row, like `link`'s `to`.
|
|
30
|
+
*/
|
|
31
|
+
export interface KDataTableColumnTypes<T = any> {
|
|
32
|
+
/**
|
|
33
|
+
* The value links to a route. The cell also gets a meatball button, shown
|
|
34
|
+
* on hover (always, on touch screens), opening a menu with View (which
|
|
35
|
+
* follows the same route) and Delete. The link and View emit `view` through
|
|
36
|
+
* `action`; Delete emits `delete`.
|
|
37
|
+
*/
|
|
38
|
+
link: {
|
|
39
|
+
/** Where the cell links to, and where View goes. */
|
|
40
|
+
to: (row: T) => RouteLocationRaw;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Every value `type` takes — the built-in types and any you declare. */
|
|
44
|
+
export type KDataTableColumnType = keyof KDataTableColumnTypes;
|
|
45
|
+
/** A column that shows the value as plain text. */
|
|
46
|
+
export type KDataTableTextColumn = KDataTableColumnBase & {
|
|
47
|
+
type?: undefined;
|
|
48
|
+
};
|
|
49
|
+
/** A column of one type, carrying that type's options. */
|
|
50
|
+
export type KDataTableTypedColumn<T = any, K extends KDataTableColumnType = KDataTableColumnType> = {
|
|
51
|
+
[Type in K]: KDataTableColumnBase & {
|
|
52
|
+
type: Type;
|
|
53
|
+
} & KDataTableColumnTypes<T>[Type];
|
|
54
|
+
}[K];
|
|
55
|
+
export type KDataTableLinkColumn<T = any> = KDataTableTypedColumn<T, 'link'>;
|
|
56
|
+
/**
|
|
57
|
+
* One column. `type` picks the component its cells render with; leave it out
|
|
58
|
+
* for plain text. A `cell-{key}` slot still overrides any type.
|
|
59
|
+
*/
|
|
60
|
+
export type KDataTableColumn<T = any> = KDataTableTextColumn | KDataTableTypedColumn<T>;
|
|
61
|
+
/**
|
|
62
|
+
* What a column type's component receives as props. Type its own with the
|
|
63
|
+
* column type it renders, e.g. `KDataTableCellComponentProps<Task, 'rating'>`,
|
|
64
|
+
* and `column` carries that type's options.
|
|
65
|
+
*/
|
|
66
|
+
export type KDataTableCellComponentProps<T = any, K extends KDataTableColumnType = KDataTableColumnType> = {
|
|
67
|
+
row: T;
|
|
68
|
+
/** `row[column.key]`. */
|
|
69
|
+
value: any;
|
|
70
|
+
column: KDataTableTypedColumn<T, K>;
|
|
71
|
+
/** The row's position on the current page. */
|
|
72
|
+
index: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* What a column type's component may emit. An `action` comes out of the table
|
|
76
|
+
* as its own `action` event, with the row and column added.
|
|
77
|
+
*/
|
|
78
|
+
export type KDataTableCellComponentEmits = {
|
|
79
|
+
action: [action: string, payload?: unknown];
|
|
80
|
+
};
|
|
81
|
+
/** `link`'s actions are `view` and `delete`; your column types add their own. */
|
|
82
|
+
export type KDataTableRowAction = string;
|
|
83
|
+
export type KDataTableActionLabels = {
|
|
84
|
+
/** Accessible name of the meatball button. */
|
|
85
|
+
menu: string;
|
|
86
|
+
view: string;
|
|
87
|
+
delete: string;
|
|
88
|
+
};
|
|
89
|
+
export type KDataTableRowKey = string | number;
|
|
90
|
+
export type KDataTableSortOrder = 'asc' | 'desc';
|
|
91
|
+
/** One "Sort by … Order by …" line of the sort popover. */
|
|
92
|
+
export type KDataTableSortRule = {
|
|
93
|
+
key: string;
|
|
94
|
+
order: KDataTableSortOrder;
|
|
95
|
+
};
|
|
96
|
+
export type KDataTableSortLabels = {
|
|
97
|
+
sortBy: string;
|
|
98
|
+
orderBy: string;
|
|
99
|
+
ascending: string;
|
|
100
|
+
descending: string;
|
|
101
|
+
add: string;
|
|
102
|
+
remove: string;
|
|
103
|
+
};
|
|
104
|
+
export type KDataTableSettingsLabels = {
|
|
105
|
+
columns: string;
|
|
106
|
+
columnsTitle: string;
|
|
107
|
+
rowHeight: string;
|
|
108
|
+
single: string;
|
|
109
|
+
double: string;
|
|
110
|
+
triple: string;
|
|
111
|
+
rowStyle: string;
|
|
112
|
+
striped: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* A `KTable` framed by a toolbar (search; filter, sort and settings popovers;
|
|
116
|
+
* and a pager) and a footer (pagination). It renders controls, not data
|
|
117
|
+
* operations: the rows are shown as given, so slice, search and sort them —
|
|
118
|
+
* client- or server-side — from `page`, `pageSize`, `search` and `sort`.
|
|
119
|
+
*/
|
|
120
|
+
export type KDataTableProps<T = any> = Omit<KTableProps, 'size' | 'striped'> & {
|
|
121
|
+
/** Overrides any of a `link` column's menu text. */
|
|
122
|
+
actionLabels?: Partial<KDataTableActionLabels>;
|
|
123
|
+
/**
|
|
124
|
+
* Generates the header and a row per entry of `rows`. Leave it out and put
|
|
125
|
+
* your own `<thead>`/`<tbody>` in the default slot instead — that markup
|
|
126
|
+
* gets no checkbox column.
|
|
127
|
+
*/
|
|
128
|
+
columns?: KDataTableColumn<T>[];
|
|
129
|
+
/** Shown in place of the rows when `rows` is empty. */
|
|
130
|
+
emptyLabel?: string;
|
|
131
|
+
/** Text of the filter button. Defaults to `Filter`. */
|
|
132
|
+
filterLabel?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Shows a skeleton in every cell in place of the rows — as many rows as
|
|
135
|
+
* are currently shown, or a full page when there are none. Applies to
|
|
136
|
+
* `columns` and `rows`; custom markup in the default slot is left as is.
|
|
137
|
+
*/
|
|
138
|
+
loading?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Caps the table's height and scrolls it inside the frame — what a
|
|
141
|
+
* `stickyHeader` sticks to. Any CSS length, e.g. `480px`.
|
|
142
|
+
*/
|
|
143
|
+
maxHeight?: string;
|
|
144
|
+
/** Accessible name of the next-page buttons. */
|
|
145
|
+
nextLabel?: string;
|
|
146
|
+
/** Rows per page. Defaults to 10. */
|
|
147
|
+
pageSize?: number;
|
|
148
|
+
/**
|
|
149
|
+
* How many leading data columns stay put while the table scrolls sideways,
|
|
150
|
+
* up to 4. The checkbox column is pinned along with them and isn't counted.
|
|
151
|
+
*/
|
|
152
|
+
pinStart?: number;
|
|
153
|
+
/** Accessible name of the previous-page buttons. */
|
|
154
|
+
prevLabel?: string;
|
|
155
|
+
/** The field — or a function — giving each row a unique key. Defaults to `id`. */
|
|
156
|
+
rowKey?: string | ((row: T) => KDataTableRowKey);
|
|
157
|
+
/** The current page's rows, shown as given. */
|
|
158
|
+
rows?: T[];
|
|
159
|
+
/** Defaults to `Search`. */
|
|
160
|
+
searchPlaceholder?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Leads each generated row with a checkbox, plus a select-all in the
|
|
163
|
+
* header, bound to `v-model:selected`. Defaults to `true`.
|
|
164
|
+
*/
|
|
165
|
+
selectable?: boolean;
|
|
166
|
+
/** Text of the settings button. Defaults to `Settings`. */
|
|
167
|
+
settingsLabel?: string;
|
|
168
|
+
/** Overrides any of the settings menu's text. */
|
|
169
|
+
settingsLabels?: Partial<KDataTableSettingsLabels>;
|
|
170
|
+
/** Text of the sort button. Defaults to `Sort`. */
|
|
171
|
+
sortLabel?: string;
|
|
172
|
+
/** Overrides any of the sort popover's text. */
|
|
173
|
+
sortLabels?: Partial<KDataTableSortLabels>;
|
|
174
|
+
/**
|
|
175
|
+
* What "Sort by" offers. Defaults to the sortable `columns`; pass it to
|
|
176
|
+
* offer fields that aren't shown, e.g. "Updated at".
|
|
177
|
+
*/
|
|
178
|
+
sortOptions?: KSelectOption[];
|
|
179
|
+
/** Number of rows across every page. Drives the pager and pagination. */
|
|
180
|
+
total: number;
|
|
181
|
+
};
|
|
182
|
+
export type KDataTableEmits<T = any> = {
|
|
183
|
+
/** A column was resized. Carries every column's width in px. */
|
|
184
|
+
(event: 'resize', widths: number[]): void;
|
|
185
|
+
/**
|
|
186
|
+
* A column type's component reported an action on its row. For `link`,
|
|
187
|
+
* `view` fires once the router has moved — from the link itself or the
|
|
188
|
+
* menu's View — and not when a guard cancels it, nor for a click that
|
|
189
|
+
* opens a new tab or window instead; `delete` does nothing
|
|
190
|
+
* else, so confirm and remove the row here. `payload` is whatever the cell
|
|
191
|
+
* sent along, if anything.
|
|
192
|
+
*/
|
|
193
|
+
(event: 'action', action: KDataTableRowAction, row: T, column: KDataTableTypedColumn<T>, payload?: unknown): void;
|
|
194
|
+
};
|
|
195
|
+
/** What the pager and pagination slots get to build their own controls. */
|
|
196
|
+
export type KDataTablePageState = {
|
|
197
|
+
/** The current page, kept within range. */
|
|
198
|
+
page: number;
|
|
199
|
+
pageCount: number;
|
|
200
|
+
pageSize: number;
|
|
201
|
+
/** 1-based position of the page's first row, or 0 with no rows. */
|
|
202
|
+
from: number;
|
|
203
|
+
/** 1-based position of the page's last row. */
|
|
204
|
+
to: number;
|
|
205
|
+
total: number;
|
|
206
|
+
/** Moves to a page; out-of-range targets are ignored. */
|
|
207
|
+
go: (page: number) => void;
|
|
208
|
+
};
|
|
209
|
+
export type KDataTableCellProps<T = any> = {
|
|
210
|
+
row: T;
|
|
211
|
+
/** `row[column.key]`. */
|
|
212
|
+
value: any;
|
|
213
|
+
/** The row's position on the current page. */
|
|
214
|
+
index: number;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Every built-in control sits in its own slot, so any one can be replaced or
|
|
218
|
+
* — with an empty `<template #filter />` — removed. The `*-start` and
|
|
219
|
+
* `*-end` slots add components beside them without replacing anything.
|
|
220
|
+
*/
|
|
221
|
+
export type KDataTableSlots<T = any> = {
|
|
222
|
+
/**
|
|
223
|
+
* Your own `<thead>`/`<tbody>`, used instead of `columns` and `rows`.
|
|
224
|
+
*/
|
|
225
|
+
default?(): any;
|
|
226
|
+
/** A column's cells, e.g. `#cell-status` for a badge. Defaults to the value. */
|
|
227
|
+
[cell: `cell-${string}`]: ((props: KDataTableCellProps<T>) => any) | undefined;
|
|
228
|
+
/** A column's header content, e.g. `#header-title`. */
|
|
229
|
+
[header: `header-${string}`]: ((props: {
|
|
230
|
+
column: KDataTableColumn;
|
|
231
|
+
}) => any) | undefined;
|
|
232
|
+
/** Replaces the `emptyLabel` text. */
|
|
233
|
+
empty?(): any;
|
|
234
|
+
/** Leads the toolbar, e.g. an "Add Task" `KButtonGroup`. */
|
|
235
|
+
'toolbar-start'?(): any;
|
|
236
|
+
/** Replaces the search field. */
|
|
237
|
+
search?(props: {
|
|
238
|
+
search: string;
|
|
239
|
+
update: (value: string) => void;
|
|
240
|
+
}): any;
|
|
241
|
+
/** The filter button's popover panel. */
|
|
242
|
+
'filter-content'?(): any;
|
|
243
|
+
/** Replaces the filter button and its popover. */
|
|
244
|
+
filter?(): any;
|
|
245
|
+
/** Replaces the sort popover's panel. Defaults to the sort rules. */
|
|
246
|
+
'sort-content'?(): any;
|
|
247
|
+
/** Replaces the sort button and its popover. */
|
|
248
|
+
sort?(): any;
|
|
249
|
+
/**
|
|
250
|
+
* Replaces the settings menu — columns, row height and row style. Pass a
|
|
251
|
+
* `KDropdownMenu`.
|
|
252
|
+
*/
|
|
253
|
+
'settings-content'?(): any;
|
|
254
|
+
/** `KDropdownItem`s added below the settings menu's own. */
|
|
255
|
+
'settings-items'?(): any;
|
|
256
|
+
/** Replaces the settings button and its menu. */
|
|
257
|
+
settings?(): any;
|
|
258
|
+
/** Follows the settings button. */
|
|
259
|
+
'toolbar-end'?(): any;
|
|
260
|
+
/** Replaces the "1–10 of 325" pager on the toolbar's right. */
|
|
261
|
+
pager?(props: KDataTablePageState): any;
|
|
262
|
+
/** `<tr>`s placed in the `<tfoot>` above the pagination row. */
|
|
263
|
+
summary?(): any;
|
|
264
|
+
/** The footer's left side, e.g. an "Add Task" button. */
|
|
265
|
+
'footer-start'?(): any;
|
|
266
|
+
/** Replaces the pagination on the footer's right. */
|
|
267
|
+
pagination?(props: KDataTablePageState): any;
|
|
268
|
+
};
|
|
269
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { KDialogRequest } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* One dialog raised through `useDialog()`. Internal to KDialogHost, which
|
|
4
|
+
* mounts one per request it shows and unmounts it on `done` — once the request
|
|
5
|
+
* is answered and the exit transition has finished.
|
|
6
|
+
*/
|
|
7
|
+
type __VLS_Props = {
|
|
8
|
+
request: KDialogRequest;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
done: () => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
|
+
onDone?: (() => any) | undefined;
|
|
14
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { VNodeChild } from 'vue';
|
|
2
|
+
import type { Intent } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Body text. A render function rather than an HTML string, so markup such as a
|
|
5
|
+
* bold item name never passes user content through `innerHTML`.
|
|
6
|
+
*/
|
|
7
|
+
export type KDialogMessage = string | (() => VNodeChild);
|
|
8
|
+
export type KDialogBaseOptions = {
|
|
9
|
+
title: string;
|
|
10
|
+
message?: KDialogMessage;
|
|
11
|
+
/**
|
|
12
|
+
* Colours the primary button. Leave it unset for a positive action — the
|
|
13
|
+
* brand button — and use `critical` for a destructive one, which also moves
|
|
14
|
+
* the initial focus to Cancel.
|
|
15
|
+
*/
|
|
16
|
+
variant?: Intent;
|
|
17
|
+
/** Escape, a backdrop click and the × all cancel. Default `true`. */
|
|
18
|
+
dismissible?: boolean;
|
|
19
|
+
size?: 'xs' | 'sm';
|
|
20
|
+
};
|
|
21
|
+
export type KAlertDialogOptions = KDialogBaseOptions & {
|
|
22
|
+
/** Default `'OK'`. */
|
|
23
|
+
okText?: string;
|
|
24
|
+
};
|
|
25
|
+
export type KConfirmDialogOptions = KDialogBaseOptions & {
|
|
26
|
+
/** Default `'Confirm'`, or `'Delete'` for the `critical` variant. */
|
|
27
|
+
confirmText?: string;
|
|
28
|
+
/** Default `'Cancel'`. */
|
|
29
|
+
cancelText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Runs on confirm with the dialog held open and both buttons disabled. The
|
|
32
|
+
* dialog resolves once it settles; if it throws, the dialog stays open.
|
|
33
|
+
*/
|
|
34
|
+
onConfirm?: () => unknown;
|
|
35
|
+
};
|
|
36
|
+
export type KPromptDialogOptions = Omit<KConfirmDialogOptions, 'onConfirm'> & {
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
placeholder?: string;
|
|
39
|
+
inputType?: 'text' | 'email' | 'number' | 'password';
|
|
40
|
+
/** Return `true` to accept the value, or a string to show as the error. */
|
|
41
|
+
validate?: (value: string) => string | true;
|
|
42
|
+
/** As on confirm, but handed the entered value. */
|
|
43
|
+
onConfirm?: (value: string) => unknown;
|
|
44
|
+
};
|
|
45
|
+
export type KDialogKind = 'alert' | 'confirm' | 'prompt';
|
|
46
|
+
/** One queued call to `useDialog()`, as the host renders it. */
|
|
47
|
+
export type KDialogRequest = {
|
|
48
|
+
id: number;
|
|
49
|
+
} & ({
|
|
50
|
+
kind: 'alert';
|
|
51
|
+
options: KAlertDialogOptions;
|
|
52
|
+
resolve: (value: void) => void;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'confirm';
|
|
55
|
+
options: KConfirmDialogOptions;
|
|
56
|
+
resolve: (value: boolean) => void;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'prompt';
|
|
59
|
+
options: KPromptDialogOptions;
|
|
60
|
+
resolve: (value: string | null) => void;
|
|
61
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { KAlertDialogOptions, KConfirmDialogOptions, KDialogKind, KDialogRequest, KPromptDialogOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Every pending dialog, oldest first. Module-level so any caller — a setup
|
|
4
|
+
* function, a store, a plain module — feeds the one `<KDialogHost />`, which
|
|
5
|
+
* shows the head of the queue and takes it off once it has closed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const dialogQueue: import("vue").ShallowReactive<KDialogRequest[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Dialogs raised while another dialog's `onConfirm` is running. They open at
|
|
10
|
+
* once, over it, instead of joining the queue: the running dialog cannot
|
|
11
|
+
* finish until they are answered, so queueing them behind it would deadlock.
|
|
12
|
+
*/
|
|
13
|
+
export declare const nestedDialogs: import("vue").ShallowReactive<KDialogRequest[]>;
|
|
14
|
+
/** How many dialogs are running an `onConfirm` handler right now. */
|
|
15
|
+
export declare const busyDialogs: import("vue").Ref<number, number>;
|
|
16
|
+
/** What a dialog resolves with when it is cancelled or dismissed. */
|
|
17
|
+
export declare const cancelValue: (kind: KDialogKind) => false | null | undefined;
|
|
18
|
+
/** Settles every pending dialog as cancelled and empties both lists. */
|
|
19
|
+
export declare function cancelAllDialogs(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Promise-based alert, confirm and prompt, rendered by `<KDialogHost />` —
|
|
22
|
+
* mount it once, near the root of the app.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const dialog = useDialog()
|
|
26
|
+
*
|
|
27
|
+
* if (await dialog.confirm({ title: 'Delete file?', variant: 'critical' })) {
|
|
28
|
+
* // …
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Calls made while a dialog is open wait their turn rather than stacking — except
|
|
33
|
+
* from inside an `onConfirm` handler, where the new dialog opens over the busy one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useDialog(): {
|
|
36
|
+
alert(options: KAlertDialogOptions): Promise<void>;
|
|
37
|
+
/** Resolves `true` on confirm, `false` on cancel or dismissal. */
|
|
38
|
+
confirm(options: KConfirmDialogOptions): Promise<boolean>;
|
|
39
|
+
/** Resolves the entered value, or `null` on cancel or dismissal. */
|
|
40
|
+
prompt(options: KPromptDialogOptions): Promise<string | null>;
|
|
41
|
+
};
|