@emamid/svelte-data-table 0.0.12 → 0.0.14
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/DataTable.doc.d.ts +79 -0
- package/dist/DataTable.doc.js +79 -0
- package/dist/DataTable.svelte +244 -0
- package/dist/DataTable.svelte.d.ts +55 -0
- package/dist/DataTableDataCell.svelte +46 -0
- package/dist/DataTableDataCell.svelte.d.ts +26 -0
- package/dist/DataTableHeaderCell.svelte +25 -0
- package/dist/DataTableHeaderCell.svelte.d.ts +24 -0
- package/dist/cells/Actions.d.ts +71 -0
- package/dist/cells/Actions.js +101 -0
- package/dist/cells/ActionsCell.doc.d.ts +28 -0
- package/dist/cells/ActionsCell.doc.js +28 -0
- package/dist/cells/ActionsCell.svelte +31 -0
- package/dist/cells/ActionsCell.svelte.d.ts +35 -0
- package/dist/cells/ButtonCell.doc.d.ts +6 -0
- package/dist/cells/ButtonCell.doc.js +6 -0
- package/dist/cells/ButtonCell.svelte +17 -0
- package/dist/cells/ButtonCell.svelte.d.ts +22 -0
- package/dist/cells/CheckboxCell.doc.d.ts +6 -0
- package/dist/cells/CheckboxCell.doc.js +6 -0
- package/dist/cells/CheckboxCell.svelte +21 -0
- package/dist/cells/CheckboxCell.svelte.d.ts +23 -0
- package/dist/cells/InputCell.doc.d.ts +6 -0
- package/dist/cells/InputCell.doc.js +6 -0
- package/dist/cells/InputCell.svelte +55 -0
- package/dist/cells/InputCell.svelte.d.ts +26 -0
- package/dist/cells/NumberInputCell.doc.d.ts +6 -0
- package/dist/cells/NumberInputCell.doc.js +6 -0
- package/dist/cells/NumberInputCell.svelte +48 -0
- package/dist/cells/NumberInputCell.svelte.d.ts +25 -0
- package/dist/cells/RangeCell.doc.d.ts +7 -0
- package/dist/cells/RangeCell.doc.js +7 -0
- package/dist/cells/RangeCell.svelte +19 -0
- package/dist/cells/RangeCell.svelte.d.ts +23 -0
- package/dist/cells/SelectCell.doc.d.ts +8 -0
- package/dist/cells/SelectCell.doc.js +8 -0
- package/dist/cells/SelectCell.svelte +30 -0
- package/dist/cells/SelectCell.svelte.d.ts +27 -0
- package/dist/cells/SpinCell.doc.d.ts +13 -0
- package/dist/cells/SpinCell.doc.js +13 -0
- package/dist/cells/SpinCell.svelte +59 -0
- package/dist/cells/SpinCell.svelte.d.ts +29 -0
- package/dist/cells/TabWrapper.doc.d.ts +5 -0
- package/dist/cells/TabWrapper.doc.js +5 -0
- package/dist/cells/TabWrapper.svelte +23 -0
- package/dist/cells/TabWrapper.svelte.d.ts +23 -0
- package/dist/cells/ToggleCell.doc.d.ts +6 -0
- package/dist/cells/ToggleCell.doc.js +6 -0
- package/dist/cells/ToggleCell.svelte +21 -0
- package/dist/cells/ToggleCell.svelte.d.ts +23 -0
- package/dist/cells/index.d.ts +21 -0
- package/dist/cells/index.js +21 -0
- package/dist/common.d.ts +136 -0
- package/dist/common.js +14 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ArrowDownSolid, ArrowUpSolid, BellActiveOutline, BookmarkOutline, CogOutline, EditOutline, HeartSolid, InfoCircleOutline, ShareNodesOutline, TrashBinOutline, } from 'flowbite-svelte-icons';
|
|
2
|
+
/**
|
|
3
|
+
* @constant bookmarkAction
|
|
4
|
+
* @type {Action}
|
|
5
|
+
* @property {string} name - bookmark
|
|
6
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - BookmarkOutline
|
|
7
|
+
*/
|
|
8
|
+
export const bookmarkAction = {
|
|
9
|
+
icon: BookmarkOutline,
|
|
10
|
+
name: 'bookmark',
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @constant deleteAction
|
|
14
|
+
* @type {Action}
|
|
15
|
+
* @property {string} name - delete
|
|
16
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - TrashBinOutline
|
|
17
|
+
*/
|
|
18
|
+
export const deleteAction = {
|
|
19
|
+
icon: TrashBinOutline,
|
|
20
|
+
name: 'delete',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @constant downAction
|
|
24
|
+
* @type {Action}
|
|
25
|
+
* @property {string} name - down
|
|
26
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - ArrowDownSolid
|
|
27
|
+
*/
|
|
28
|
+
export const downAction = {
|
|
29
|
+
icon: ArrowDownSolid,
|
|
30
|
+
name: 'down',
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @constant editAction
|
|
34
|
+
* @type {Action}
|
|
35
|
+
* @property {string} name - edit
|
|
36
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - EditOutline
|
|
37
|
+
*/
|
|
38
|
+
export const editAction = {
|
|
39
|
+
icon: EditOutline,
|
|
40
|
+
name: 'edit',
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* @constant favoriteAction
|
|
44
|
+
* @type {Action}
|
|
45
|
+
* @property {string} name - favorite
|
|
46
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - HeartSolid
|
|
47
|
+
*/
|
|
48
|
+
export const favoriteAction = {
|
|
49
|
+
icon: HeartSolid,
|
|
50
|
+
name: 'favorite',
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @constant infoAction
|
|
54
|
+
* @type {Action}
|
|
55
|
+
* @property {string} name - info
|
|
56
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - InfoCircleOutline
|
|
57
|
+
*/
|
|
58
|
+
export const infoAction = {
|
|
59
|
+
icon: InfoCircleOutline,
|
|
60
|
+
name: 'info',
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @constant notificationAction
|
|
64
|
+
* @type {Action}
|
|
65
|
+
* @property {string} name - notification
|
|
66
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - BellActiveOutline
|
|
67
|
+
*/
|
|
68
|
+
export const notificationAction = {
|
|
69
|
+
icon: BellActiveOutline,
|
|
70
|
+
name: 'notification',
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @constant settingsAction
|
|
74
|
+
* @type {Action}
|
|
75
|
+
* @property {string} name - settings
|
|
76
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - CogOutline
|
|
77
|
+
*/
|
|
78
|
+
export const settingsAction = {
|
|
79
|
+
icon: CogOutline,
|
|
80
|
+
name: 'settings',
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* @constant shareAction
|
|
84
|
+
* @type {Action}
|
|
85
|
+
* @property {string} name - share
|
|
86
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - ShareNodesOutline
|
|
87
|
+
*/
|
|
88
|
+
export const shareAction = {
|
|
89
|
+
icon: ShareNodesOutline,
|
|
90
|
+
name: 'share',
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* @constant upAction
|
|
94
|
+
* @type {Action}
|
|
95
|
+
* @property {string} name - up
|
|
96
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - UpArrowSolid
|
|
97
|
+
*/
|
|
98
|
+
export const upAction = {
|
|
99
|
+
icon: ArrowUpSolid,
|
|
100
|
+
name: 'up',
|
|
101
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the action should be disabled for the row.
|
|
3
|
+
* @callback ActionDisablementFunction
|
|
4
|
+
* @param {any} item - The row of data
|
|
5
|
+
* @param {ColumnConfig} column - The configuration for the ActionCell's column
|
|
6
|
+
* @param {Action} action - The action to disable or enable
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
/**
|
|
11
|
+
* An action to be displayed inside an ActionCell
|
|
12
|
+
* @interface Action
|
|
13
|
+
* @property {string} [buttonClass] - Class for the button. If not populated, the cell's buttonClass will be used.
|
|
14
|
+
* @property {ButtonColor} [buttonColor] - See {@link https://flowbite-svelte.com/docs/pages/typescript}. If not populated, the cell's buttonColor will be used.
|
|
15
|
+
* @property {string} [caption] - Text displayed with the icon.
|
|
16
|
+
* @property {string} name - Name of the action. Returned as part of the action event on DataGrid when the button is clicked.
|
|
17
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - Icon to be displayed in the button.
|
|
18
|
+
* @property {string} [iconClass] - Class for the icon to be displayed in the button. If not populated, the cell's iconClass will be used.
|
|
19
|
+
* @property {ActionDisablementFunction} [isDisabled] - If populated, will be called to check whether the button should be enabled or disabled for each row.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Cell containing an array of Button ({@link https://flowbite-svelte.com/docs/components/buttons}) components which fire the action event on the grid when clicked.
|
|
23
|
+
* @typedef {object} ActionsCell
|
|
24
|
+
* @property [Action[]] actions - The actions to be displayed inside the cell.
|
|
25
|
+
* @property {string} [buttonClass] - Class for the cell's buttons. Defaults to 'border-0 p-1'.
|
|
26
|
+
* @property {ButtonColor} [buttonColor] - See {@link https://flowbite-svelte.com/docs/pages/typescript}. Defaults to 'light'.
|
|
27
|
+
* @property {string} [iconClass] - Class for the icon to be displayed in the button. Defaults to 'w-4 h-4'.
|
|
28
|
+
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the action should be disabled for the row.
|
|
4
|
+
* @callback ActionDisablementFunction
|
|
5
|
+
* @param {any} item - The row of data
|
|
6
|
+
* @param {ColumnConfig} column - The configuration for the ActionCell's column
|
|
7
|
+
* @param {Action} action - The action to disable or enable
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* An action to be displayed inside an ActionCell
|
|
12
|
+
* @interface Action
|
|
13
|
+
* @property {string} [buttonClass] - Class for the button. If not populated, the cell's buttonClass will be used.
|
|
14
|
+
* @property {ButtonColor} [buttonColor] - See {@link https://flowbite-svelte.com/docs/pages/typescript}. If not populated, the cell's buttonColor will be used.
|
|
15
|
+
* @property {string} [caption] - Text displayed with the icon.
|
|
16
|
+
* @property {string} name - Name of the action. Returned as part of the action event on DataGrid when the button is clicked.
|
|
17
|
+
* @property {ConstructorOfATypedSvelteComponent} icon - Icon to be displayed in the button.
|
|
18
|
+
* @property {string} [iconClass] - Class for the icon to be displayed in the button. If not populated, the cell's iconClass will be used.
|
|
19
|
+
* @property {ActionDisablementFunction} [isDisabled] - If populated, will be called to check whether the button should be enabled or disabled for each row.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Cell containing an array of Button ({@link https://flowbite-svelte.com/docs/components/buttons}) components which fire the action event on the grid when clicked.
|
|
23
|
+
* @typedef {object} ActionsCell
|
|
24
|
+
* @property [Action[]] actions - The actions to be displayed inside the cell.
|
|
25
|
+
* @property {string} [buttonClass] - Class for the cell's buttons. Defaults to 'border-0 p-1'.
|
|
26
|
+
* @property {ButtonColor} [buttonColor] - See {@link https://flowbite-svelte.com/docs/pages/typescript}. Defaults to 'light'.
|
|
27
|
+
* @property {string} [iconClass] - Class for the icon to be displayed in the button. Defaults to 'w-4 h-4'.
|
|
28
|
+
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
4
|
+
import { Button } from "flowbite-svelte";
|
|
5
|
+
export let buttonClass = "border-0 p-1";
|
|
6
|
+
export let buttonColor = "light";
|
|
7
|
+
export let iconClass = "w-4 h-4";
|
|
8
|
+
export let column;
|
|
9
|
+
export let item;
|
|
10
|
+
export let actions = [];
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
const actionClicked = (action) => {
|
|
13
|
+
dispatch("action", {
|
|
14
|
+
action: action.name,
|
|
15
|
+
column,
|
|
16
|
+
item
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
{#each actions as action}
|
|
22
|
+
<Button
|
|
23
|
+
class={action.buttonClass || buttonClass}
|
|
24
|
+
color={action.buttonColor || buttonColor}
|
|
25
|
+
disabled={action.isDisabled?.(item, column, action)}
|
|
26
|
+
on:click={() => actionClicked(action)}
|
|
27
|
+
>
|
|
28
|
+
<svelte:component this={action.icon} class={action.iconClass || iconClass} />
|
|
29
|
+
{#if action.caption}{action.caption}{/if}
|
|
30
|
+
</Button>
|
|
31
|
+
{/each}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.js';
|
|
3
|
+
type ButtonColor = 'red' | 'yellow' | 'green' | 'purple' | 'blue' | 'light' | 'dark' | 'primary' | 'none' | 'alternative' | undefined;
|
|
4
|
+
export type ActionDisablementFunction = (item: any, column: ColumnConfig, action: Action) => boolean;
|
|
5
|
+
export interface Action {
|
|
6
|
+
buttonClass?: string;
|
|
7
|
+
buttonColor?: ButtonColor;
|
|
8
|
+
caption?: string;
|
|
9
|
+
name: string;
|
|
10
|
+
icon: ConstructorOfATypedSvelteComponent;
|
|
11
|
+
iconClass?: string;
|
|
12
|
+
isDisabled?: ActionDisablementFunction;
|
|
13
|
+
}
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
buttonClass?: string | undefined;
|
|
17
|
+
buttonColor?: ButtonColor;
|
|
18
|
+
iconClass?: string | undefined;
|
|
19
|
+
column: ColumnConfig;
|
|
20
|
+
item: any;
|
|
21
|
+
actions?: Action[] | undefined;
|
|
22
|
+
};
|
|
23
|
+
events: {
|
|
24
|
+
action: CustomEvent<any>;
|
|
25
|
+
} & {
|
|
26
|
+
[evt: string]: CustomEvent<any>;
|
|
27
|
+
};
|
|
28
|
+
slots: {};
|
|
29
|
+
};
|
|
30
|
+
export type ActionsCellProps = typeof __propDef.props;
|
|
31
|
+
export type ActionsCellEvents = typeof __propDef.events;
|
|
32
|
+
export type ActionsCellSlots = typeof __propDef.slots;
|
|
33
|
+
export default class ActionsCell extends SvelteComponent<ActionsCellProps, ActionsCellEvents, ActionsCellSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { Button } from "flowbite-svelte";
|
|
3
|
+
export let caption = "";
|
|
4
|
+
export let column;
|
|
5
|
+
export let item;
|
|
6
|
+
const dispatch = createEventDispatcher();
|
|
7
|
+
const buttonClicked = () => {
|
|
8
|
+
dispatch("click", {
|
|
9
|
+
column,
|
|
10
|
+
item
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Button {...$$props} on:click={buttonClicked}
|
|
16
|
+
>{#if caption}{caption}{/if}</Button
|
|
17
|
+
>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
caption?: string | undefined;
|
|
7
|
+
column: ColumnConfig;
|
|
8
|
+
item: any;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
click: CustomEvent<any>;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
};
|
|
17
|
+
export type ButtonCellProps = typeof __propDef.props;
|
|
18
|
+
export type ButtonCellEvents = typeof __propDef.events;
|
|
19
|
+
export type ButtonCellSlots = typeof __propDef.slots;
|
|
20
|
+
export default class ButtonCell extends SvelteComponent<ButtonCellProps, ButtonCellEvents, ButtonCellSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { Checkbox } from "flowbite-svelte";
|
|
3
|
+
export let caption = "";
|
|
4
|
+
export let column;
|
|
5
|
+
export let item;
|
|
6
|
+
export let value;
|
|
7
|
+
let localValue = value;
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
const toggleChanged = () => {
|
|
10
|
+
dispatch("cellChanged", {
|
|
11
|
+
column,
|
|
12
|
+
item,
|
|
13
|
+
oldValue: value,
|
|
14
|
+
newValue: localValue
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Checkbox {...$$props} bind:checked={localValue} on:change={toggleChanged}
|
|
20
|
+
>{#if caption}{caption}{/if}</Checkbox
|
|
21
|
+
>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
caption?: string | undefined;
|
|
7
|
+
column: ColumnConfig;
|
|
8
|
+
item: any;
|
|
9
|
+
value: any;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
cellChanged: CustomEvent<any>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export type CheckboxCellProps = typeof __propDef.props;
|
|
19
|
+
export type CheckboxCellEvents = typeof __propDef.events;
|
|
20
|
+
export type CheckboxCellSlots = typeof __propDef.slots;
|
|
21
|
+
export default class CheckboxCell extends SvelteComponent<CheckboxCellProps, CheckboxCellEvents, CheckboxCellSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing an Input {@link (https://flowbite-svelte.com/docs/forms/input-field}) component.
|
|
4
|
+
* @typedef {object} InputCell
|
|
5
|
+
* @property {string} [inputType] - See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types}
|
|
6
|
+
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing an Input {@link (https://flowbite-svelte.com/docs/forms/input-field}) component.
|
|
4
|
+
* @typedef {object} InputCell
|
|
5
|
+
* @property {string} [inputType] - See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types}
|
|
6
|
+
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { Input } from "flowbite-svelte";
|
|
3
|
+
import TabWrapper from "./TabWrapper.svelte";
|
|
4
|
+
export let inputType = "text";
|
|
5
|
+
export let item;
|
|
6
|
+
export let column;
|
|
7
|
+
export let value;
|
|
8
|
+
let internalValue;
|
|
9
|
+
$:
|
|
10
|
+
internalValue = value;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
const dispatchCellChanged = () => {
|
|
13
|
+
if (value !== internalValue) {
|
|
14
|
+
dispatch("cellChanged", {
|
|
15
|
+
column,
|
|
16
|
+
item,
|
|
17
|
+
oldValue: value,
|
|
18
|
+
newValue: internalValue
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const keypress = (event) => {
|
|
23
|
+
if (event.key === "Enter") {
|
|
24
|
+
dispatch("enterPressed", {
|
|
25
|
+
column,
|
|
26
|
+
item
|
|
27
|
+
});
|
|
28
|
+
dispatchCellChanged();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const prevTab = (_event) => {
|
|
32
|
+
dispatch("prevTab", {
|
|
33
|
+
column,
|
|
34
|
+
item
|
|
35
|
+
});
|
|
36
|
+
dispatchCellChanged();
|
|
37
|
+
};
|
|
38
|
+
const nextTab = (_event) => {
|
|
39
|
+
dispatch("nextTab", {
|
|
40
|
+
column,
|
|
41
|
+
item
|
|
42
|
+
});
|
|
43
|
+
dispatchCellChanged();
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<TabWrapper on:prevTab={prevTab} on:nextTab={nextTab}>
|
|
48
|
+
<Input
|
|
49
|
+
type={inputType}
|
|
50
|
+
bind:value={internalValue}
|
|
51
|
+
{...$$props}
|
|
52
|
+
on:keypress={keypress}
|
|
53
|
+
autofocus
|
|
54
|
+
/>
|
|
55
|
+
</TabWrapper>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
inputType?: string | undefined;
|
|
7
|
+
item: any;
|
|
8
|
+
column: ColumnConfig;
|
|
9
|
+
value: string;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
cellChanged: CustomEvent<any>;
|
|
13
|
+
enterPressed: CustomEvent<any>;
|
|
14
|
+
prevTab: CustomEvent<any>;
|
|
15
|
+
nextTab: CustomEvent<any>;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
};
|
|
21
|
+
export type InputCellProps = typeof __propDef.props;
|
|
22
|
+
export type InputCellEvents = typeof __propDef.events;
|
|
23
|
+
export type InputCellSlots = typeof __propDef.slots;
|
|
24
|
+
export default class InputCell extends SvelteComponent<InputCellProps, InputCellEvents, InputCellSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing a NumberInput ({@link https://flowbite-svelte.com/docs/forms/input-field#Number_input}) component.
|
|
4
|
+
* @typedef {object} NumberInputCell
|
|
5
|
+
* @property {string} [inputType] - See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
|
|
6
|
+
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing a NumberInput ({@link https://flowbite-svelte.com/docs/forms/input-field#Number_input}) component.
|
|
4
|
+
* @typedef {object} NumberInputCell
|
|
5
|
+
* @property {string} [inputType] - See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
|
|
6
|
+
*/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { NumberInput } from "flowbite-svelte";
|
|
3
|
+
import TabWrapper from "./TabWrapper.svelte";
|
|
4
|
+
export let item;
|
|
5
|
+
export let column;
|
|
6
|
+
export let value;
|
|
7
|
+
let internalValue;
|
|
8
|
+
$:
|
|
9
|
+
internalValue = value;
|
|
10
|
+
const dispatch = createEventDispatcher();
|
|
11
|
+
const dispatchCellChanged = () => {
|
|
12
|
+
if (value !== internalValue) {
|
|
13
|
+
dispatch("cellChanged", {
|
|
14
|
+
column,
|
|
15
|
+
item,
|
|
16
|
+
oldValue: value,
|
|
17
|
+
newValue: internalValue
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const keypress = async (event) => {
|
|
22
|
+
if (event.key === "Enter") {
|
|
23
|
+
dispatch("enterPressed", {
|
|
24
|
+
column,
|
|
25
|
+
item
|
|
26
|
+
});
|
|
27
|
+
dispatchCellChanged();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const prevTab = (_event) => {
|
|
31
|
+
dispatch("prevTab", {
|
|
32
|
+
column,
|
|
33
|
+
item
|
|
34
|
+
});
|
|
35
|
+
dispatchCellChanged();
|
|
36
|
+
};
|
|
37
|
+
const nextTab = (_event) => {
|
|
38
|
+
dispatch("nextTab", {
|
|
39
|
+
column,
|
|
40
|
+
item
|
|
41
|
+
});
|
|
42
|
+
dispatchCellChanged();
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<TabWrapper on:prevTab={prevTab} on:nextTab={nextTab}>
|
|
47
|
+
<NumberInput bind:value={internalValue} {...$$props} on:keypress={keypress} autofocus />
|
|
48
|
+
</TabWrapper>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.js';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
item: any;
|
|
7
|
+
column: ColumnConfig;
|
|
8
|
+
value: number;
|
|
9
|
+
};
|
|
10
|
+
events: {
|
|
11
|
+
cellChanged: CustomEvent<any>;
|
|
12
|
+
enterPressed: CustomEvent<any>;
|
|
13
|
+
prevTab: CustomEvent<any>;
|
|
14
|
+
nextTab: CustomEvent<any>;
|
|
15
|
+
} & {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
};
|
|
18
|
+
slots: {};
|
|
19
|
+
};
|
|
20
|
+
export type NumberInputCellProps = typeof __propDef.props;
|
|
21
|
+
export type NumberInputCellEvents = typeof __propDef.events;
|
|
22
|
+
export type NumberInputCellSlots = typeof __propDef.slots;
|
|
23
|
+
export default class NumberInputCell extends SvelteComponent<NumberInputCellProps, NumberInputCellEvents, NumberInputCellSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { Range } from "flowbite-svelte";
|
|
3
|
+
export let caption = "";
|
|
4
|
+
export let column;
|
|
5
|
+
export let item;
|
|
6
|
+
export let value;
|
|
7
|
+
let localValue = value;
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
const toggleChanged = () => {
|
|
10
|
+
dispatch("cellChanged", {
|
|
11
|
+
column,
|
|
12
|
+
item,
|
|
13
|
+
oldValue: value,
|
|
14
|
+
newValue: localValue
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Range {...$$props} bind:value={localValue} on:change={toggleChanged}>{#if caption}{caption}{/if}</Range>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ColumnConfig } from '../common.ts';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
caption?: string | undefined;
|
|
7
|
+
column: ColumnConfig;
|
|
8
|
+
item: any;
|
|
9
|
+
value: any;
|
|
10
|
+
};
|
|
11
|
+
events: {
|
|
12
|
+
cellChanged: CustomEvent<any>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export type RangeCellProps = typeof __propDef.props;
|
|
19
|
+
export type RangeCellEvents = typeof __propDef.events;
|
|
20
|
+
export type RangeCellSlots = typeof __propDef.slots;
|
|
21
|
+
export default class RangeCell extends SvelteComponent<RangeCellProps, RangeCellEvents, RangeCellSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing a Select ({@link https://flowbite-svelte.com/docs/forms/select}) component.
|
|
4
|
+
* @typedef {object} SelectCell
|
|
5
|
+
* @property {string} [displayProp] - Property within items which displays in the list. Defaults to 'name'.
|
|
6
|
+
* @property {string} [valueProp] - Property within tems used to populate the cell's value when picked. Defaults to 'id'.
|
|
7
|
+
* @property {any[]} items - Array of objects the user can select from.
|
|
8
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cell containing a Select ({@link https://flowbite-svelte.com/docs/forms/select}) component.
|
|
4
|
+
* @typedef {object} SelectCell
|
|
5
|
+
* @property {string} [displayProp] - Property within items which displays in the list. Defaults to 'name'.
|
|
6
|
+
* @property {string} [valueProp] - Property within tems used to populate the cell's value when picked. Defaults to 'id'.
|
|
7
|
+
* @property {any[]} items - Array of objects the user can select from.
|
|
8
|
+
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import { Select } from "flowbite-svelte";
|
|
3
|
+
import TabWrapper from "./TabWrapper.svelte";
|
|
4
|
+
export let item;
|
|
5
|
+
export let column;
|
|
6
|
+
export let displayProp = "name";
|
|
7
|
+
export let valueProp = "id";
|
|
8
|
+
export let items = [];
|
|
9
|
+
export let value;
|
|
10
|
+
let newValue = value;
|
|
11
|
+
const dispatch = createEventDispatcher();
|
|
12
|
+
$:
|
|
13
|
+
if (value !== newValue) {
|
|
14
|
+
dispatch("cellChanged", {
|
|
15
|
+
column,
|
|
16
|
+
item,
|
|
17
|
+
oldValue: value,
|
|
18
|
+
newValue
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<TabWrapper {column} {item} on:prevTab on:nextTab>
|
|
24
|
+
<Select
|
|
25
|
+
{...$$props}
|
|
26
|
+
items={items.map((item) => ({ value: item[valueProp], name: item[displayProp] }))}
|
|
27
|
+
bind:value={newValue}
|
|
28
|
+
autofocus
|
|
29
|
+
/>
|
|
30
|
+
</TabWrapper>
|