@likable-hair/svelte 3.0.14 → 3.0.17
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/components/composed/common/MenuOrDrawer.svelte +32 -0
- package/dist/components/composed/common/MenuOrDrawer.svelte.d.ts +37 -0
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte +48 -0
- package/dist/components/composed/common/MenuOrDrawerOptions.svelte.d.ts +35 -0
- package/dist/components/composed/forms/AsyncAutocomplete.svelte +40 -0
- package/dist/components/composed/forms/AsyncAutocomplete.svelte.d.ts +28 -0
- package/dist/components/composed/forms/ConfirmOrCancelButtons.svelte +84 -0
- package/dist/components/composed/forms/ConfirmOrCancelButtons.svelte.d.ts +41 -0
- package/dist/components/composed/forms/Dropdown.svelte +79 -0
- package/dist/components/composed/forms/Dropdown.svelte.d.ts +29 -0
- package/dist/components/composed/list/PaginatedTable.svelte +152 -0
- package/dist/components/composed/list/PaginatedTable.svelte.d.ts +14 -0
- package/dist/components/composed/list/Paginator.css +4 -0
- package/dist/components/composed/list/Paginator.svelte +140 -0
- package/dist/components/composed/list/Paginator.svelte.d.ts +23 -0
- package/dist/components/composed/search/GlobalSearchTextField.svelte +4 -2
- package/dist/components/composed/search/SearchBar.svelte +2 -0
- package/dist/components/composed/search/SearchBar.svelte.d.ts +2 -0
- package/dist/components/layouts/StableDividedSideBarLayout.css +1 -0
- package/dist/components/layouts/StableDividedSideBarLayout.svelte +5 -0
- package/dist/components/layouts/UnstableDividedSideBarLayout.css +13 -0
- package/dist/components/layouts/UnstableDividedSideBarLayout.svelte +284 -0
- package/dist/components/layouts/UnstableDividedSideBarLayout.svelte.d.ts +38 -0
- package/dist/components/simple/buttons/Button.css +2 -0
- package/dist/components/simple/buttons/Button.svelte +22 -1
- package/dist/components/simple/buttons/Button.svelte.d.ts +5 -0
- package/dist/components/simple/common/Menu.svelte +36 -9
- package/dist/components/simple/common/Menu.svelte.d.ts +5 -1
- package/dist/components/simple/common/scroller.d.ts +1 -0
- package/dist/components/simple/common/scroller.js +9 -0
- package/dist/components/simple/dates/DatePickerTextField.svelte +21 -6
- package/dist/components/simple/dates/DatePickerTextField.svelte.d.ts +10 -1
- package/dist/components/simple/dialogs/Dialog.svelte.d.ts +1 -1
- package/dist/components/simple/forms/Autocomplete.svelte +60 -28
- package/dist/components/simple/forms/Autocomplete.svelte.d.ts +25 -4
- package/dist/components/simple/forms/SimpleTextField.svelte +5 -0
- package/dist/components/simple/forms/SimpleTextField.svelte.d.ts +1 -0
- package/dist/components/simple/lists/ColorInvertedSelector.css +6 -0
- package/dist/components/simple/lists/ColorInvertedSelector.svelte +99 -0
- package/dist/components/simple/lists/ColorInvertedSelector.svelte.d.ts +45 -0
- package/dist/components/simple/lists/SelectableVerticalList.css +13 -0
- package/dist/components/simple/lists/SelectableVerticalList.svelte +137 -49
- package/dist/components/simple/lists/SelectableVerticalList.svelte.d.ts +11 -8
- package/dist/components/simple/lists/SimpleTable.css +13 -0
- package/dist/components/simple/lists/SimpleTable.svelte +246 -0
- package/dist/components/simple/{common → lists}/SimpleTable.svelte.d.ts +22 -11
- package/dist/components/simple/media/Icon.svelte +28 -6
- package/dist/components/simple/navigation/Drawer.css +2 -1
- package/dist/components/simple/navigation/Drawer.svelte +2 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/stores/debounce.d.ts +4 -0
- package/dist/stores/debounce.js +10 -0
- package/dist/utils/clickOutside.d.ts +4 -0
- package/dist/utils/clickOutside.js +14 -0
- package/package.json +1 -143
- package/dist/components/simple/common/SimpleTable.svelte +0 -77
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>import "../../../css/main.css";
|
|
2
|
+
import Drawer from "../../simple/navigation/Drawer.svelte";
|
|
3
|
+
import Menu from "../../simple/common/Menu.svelte";
|
|
4
|
+
import MediaQuery from "../../simple/common/MediaQuery.svelte";
|
|
5
|
+
export let open = false, activator, drawerPosition = "bottom", menuAnchor = "bottom-center", _boxShadow = "rgb(var(--global-color-grey-900), .5) 0px 2px 4px", _height = "fit-content", _maxHeight = void 0, _minWidth = "100px", _bordeRadius = "5px";
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<MediaQuery let:mAndDown>
|
|
9
|
+
{#if mAndDown}
|
|
10
|
+
<Drawer
|
|
11
|
+
bind:open={open}
|
|
12
|
+
bind:position={drawerPosition}
|
|
13
|
+
on:item-click
|
|
14
|
+
>
|
|
15
|
+
<slot isDrawer={true} isMenu={false}></slot>
|
|
16
|
+
</Drawer>
|
|
17
|
+
{:else}
|
|
18
|
+
<Menu
|
|
19
|
+
bind:activator={activator}
|
|
20
|
+
bind:open={open}
|
|
21
|
+
closeOnClickOutside
|
|
22
|
+
_boxShadow={_boxShadow}
|
|
23
|
+
_height={_height}
|
|
24
|
+
_maxHeight={_maxHeight}
|
|
25
|
+
_minWidth={_minWidth}
|
|
26
|
+
_borderRadius={_bordeRadius}
|
|
27
|
+
anchor={menuAnchor}
|
|
28
|
+
>
|
|
29
|
+
<slot isDrawer={false} isMenu={true}></slot>
|
|
30
|
+
</Menu>
|
|
31
|
+
{/if}
|
|
32
|
+
</MediaQuery>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import '../../../css/main.css';
|
|
3
|
+
import Drawer from '../../simple/navigation/Drawer.svelte';
|
|
4
|
+
import Menu from '../../simple/common/Menu.svelte';
|
|
5
|
+
import type { ComponentProps } from 'svelte';
|
|
6
|
+
declare const __propDef: {
|
|
7
|
+
props: {
|
|
8
|
+
open?: boolean | undefined;
|
|
9
|
+
activator: HTMLElement;
|
|
10
|
+
drawerPosition?: ComponentProps<Drawer>['position'];
|
|
11
|
+
menuAnchor?: ComponentProps<Menu>['anchor'];
|
|
12
|
+
_boxShadow?: string | undefined;
|
|
13
|
+
_height?: string | undefined;
|
|
14
|
+
_maxHeight?: string | undefined;
|
|
15
|
+
_minWidth?: string | undefined;
|
|
16
|
+
_bordeRadius?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
'item-click': CustomEvent<{
|
|
20
|
+
item: import("../../simple/navigation/Navigator.svelte").Item;
|
|
21
|
+
}>;
|
|
22
|
+
} & {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
};
|
|
25
|
+
slots: {
|
|
26
|
+
default: {
|
|
27
|
+
isDrawer: boolean;
|
|
28
|
+
isMenu: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type MenuOrDrawerProps = typeof __propDef.props;
|
|
33
|
+
export type MenuOrDrawerEvents = typeof __propDef.events;
|
|
34
|
+
export type MenuOrDrawerSlots = typeof __propDef.slots;
|
|
35
|
+
export default class MenuOrDrawer extends SvelteComponentTyped<MenuOrDrawerProps, MenuOrDrawerEvents, MenuOrDrawerSlots> {
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import "../../../css/main.css";
|
|
4
|
+
import MenuOrDrawer from "./MenuOrDrawer.svelte";
|
|
5
|
+
import SelectableVerticalList from "../../simple/lists/SelectableVerticalList.svelte";
|
|
6
|
+
export let open = false, activator, drawerPosition = "bottom", menuAnchor = "bottom-center", elements = [], _boxShadow = "rgb(var(--global-color-grey-900), .5) 0px 2px 4px", _height = "fit-content", _maxHeight = void 0, _minWidth = "100px", _bordeRadius = "5px";
|
|
7
|
+
let selected;
|
|
8
|
+
let focused;
|
|
9
|
+
$:
|
|
10
|
+
if (!!selected)
|
|
11
|
+
selected = void 0;
|
|
12
|
+
$:
|
|
13
|
+
if (!!focused && !open)
|
|
14
|
+
focused = void 0;
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<MenuOrDrawer
|
|
18
|
+
bind:open
|
|
19
|
+
bind:activator
|
|
20
|
+
bind:drawerPosition
|
|
21
|
+
bind:menuAnchor
|
|
22
|
+
{_boxShadow}
|
|
23
|
+
{_height}
|
|
24
|
+
{_maxHeight}
|
|
25
|
+
{_minWidth}
|
|
26
|
+
{_bordeRadius}
|
|
27
|
+
let:isDrawer
|
|
28
|
+
--drawer-default-space={`${Math.min(elements?.length || 0, 5) * 56}px`}
|
|
29
|
+
>
|
|
30
|
+
<div class="selectable-list-wrapper">
|
|
31
|
+
<SelectableVerticalList
|
|
32
|
+
bind:selected
|
|
33
|
+
bind:focused
|
|
34
|
+
bind:elements
|
|
35
|
+
--selectable-vertical-list-default-width={isDrawer ? '100%' : 'auto'}
|
|
36
|
+
--selectable-vertical-list-default-element-height={isDrawer ? '56px' : 'auto'}
|
|
37
|
+
--selectable-vertical-list-default-title-font-size="null"
|
|
38
|
+
on:select={() => open = false}
|
|
39
|
+
on:select
|
|
40
|
+
></SelectableVerticalList>
|
|
41
|
+
</div>
|
|
42
|
+
</MenuOrDrawer>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.selectable-list-wrapper {
|
|
46
|
+
background-color: rgb(var(--global-color-background-100));
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
3
|
+
import '../../../css/main.css';
|
|
4
|
+
import type { ComponentProps } from 'svelte';
|
|
5
|
+
import type Drawer from '../../simple/navigation/Drawer.svelte';
|
|
6
|
+
import type Menu from '../../simple/common/Menu.svelte';
|
|
7
|
+
import SelectableVerticalList from '../../simple/lists/SelectableVerticalList.svelte';
|
|
8
|
+
declare const __propDef: {
|
|
9
|
+
props: {
|
|
10
|
+
open?: boolean | undefined;
|
|
11
|
+
activator: HTMLElement;
|
|
12
|
+
drawerPosition?: ComponentProps<Drawer>['position'];
|
|
13
|
+
menuAnchor?: ComponentProps<Menu>['anchor'];
|
|
14
|
+
elements?: ComponentProps<SelectableVerticalList>['elements'];
|
|
15
|
+
_boxShadow?: string | undefined;
|
|
16
|
+
_height?: string | undefined;
|
|
17
|
+
_maxHeight?: string | undefined;
|
|
18
|
+
_minWidth?: string | undefined;
|
|
19
|
+
_bordeRadius?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
events: {
|
|
22
|
+
select: CustomEvent<{
|
|
23
|
+
element: import("../../simple/lists/SelectableVerticalList.svelte").Element;
|
|
24
|
+
}>;
|
|
25
|
+
} & {
|
|
26
|
+
[evt: string]: CustomEvent<any>;
|
|
27
|
+
};
|
|
28
|
+
slots: {};
|
|
29
|
+
};
|
|
30
|
+
export type MenuOrDrawerOptionsProps = typeof __propDef.props;
|
|
31
|
+
export type MenuOrDrawerOptionsEvents = typeof __propDef.events;
|
|
32
|
+
export type MenuOrDrawerOptionsSlots = typeof __propDef.slots;
|
|
33
|
+
export default class MenuOrDrawerOptions extends SvelteComponentTyped<MenuOrDrawerOptionsProps, MenuOrDrawerOptionsEvents, MenuOrDrawerOptionsSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import Autocomplete from "../../../components/simple/forms/Autocomplete.svelte";
|
|
4
|
+
import debounceStore from "../../../stores/debounce";
|
|
5
|
+
import { writable } from "svelte/store";
|
|
6
|
+
export let items = [], values = [], multiple = false, searcher, searchThreshold = 2, debounceTimeout = 500, searching = false, search = false, searchText = void 0, maxVisibleChips = void 0;
|
|
7
|
+
const searchTextValue = writable(searchText);
|
|
8
|
+
$:
|
|
9
|
+
searchTextDebounce = debounceStore(searchTextValue, debounceTimeout);
|
|
10
|
+
$:
|
|
11
|
+
if (!!$searchTextDebounce && searchThreshold <= $searchTextDebounce.length) {
|
|
12
|
+
searching = true;
|
|
13
|
+
searcher({ searchText: $searchTextDebounce }).then((it) => {
|
|
14
|
+
items = it;
|
|
15
|
+
}).finally(() => {
|
|
16
|
+
searching = false;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
$:
|
|
20
|
+
if (search) {
|
|
21
|
+
search = false;
|
|
22
|
+
searching = true;
|
|
23
|
+
searcher({ searchText: $searchTextDebounce }).then((it) => {
|
|
24
|
+
items = it;
|
|
25
|
+
}).finally(() => {
|
|
26
|
+
searching = false;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
$:
|
|
30
|
+
$searchTextValue = searchText;
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<Autocomplete
|
|
34
|
+
bind:items
|
|
35
|
+
bind:values
|
|
36
|
+
bind:searchText
|
|
37
|
+
bind:multiple
|
|
38
|
+
bind:maxVisibleChips
|
|
39
|
+
searchFunction={() => true}
|
|
40
|
+
></Autocomplete>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Item } from "../../../components/simple/forms/Autocomplete.svelte";
|
|
3
|
+
export type { Item };
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
items?: Item[] | undefined;
|
|
7
|
+
values?: Item[] | undefined;
|
|
8
|
+
multiple?: boolean | undefined;
|
|
9
|
+
searcher: (params: {
|
|
10
|
+
searchText: string;
|
|
11
|
+
}) => Promise<Item[]>;
|
|
12
|
+
searchThreshold?: number | undefined;
|
|
13
|
+
debounceTimeout?: number | undefined;
|
|
14
|
+
searching?: boolean | undefined;
|
|
15
|
+
search?: boolean | undefined;
|
|
16
|
+
searchText?: string | undefined;
|
|
17
|
+
maxVisibleChips?: number | undefined;
|
|
18
|
+
};
|
|
19
|
+
events: {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {};
|
|
23
|
+
};
|
|
24
|
+
export type AsyncAutocompleteProps = typeof __propDef.props;
|
|
25
|
+
export type AsyncAutocompleteEvents = typeof __propDef.events;
|
|
26
|
+
export type AsyncAutocompleteSlots = typeof __propDef.slots;
|
|
27
|
+
export default class AsyncAutocomplete extends SvelteComponentTyped<AsyncAutocompleteProps, AsyncAutocompleteEvents, AsyncAutocompleteSlots> {
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<script>import "../../../css/main.css";
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
export let loading = false, marginTop = "20px", cancelText = "Annulla", confirmText = "Salva", confirmDisable = false, cancelDisable = false;
|
|
4
|
+
let dispatch = createEventDispatcher();
|
|
5
|
+
function handleConfirm(event) {
|
|
6
|
+
if (!confirmDisable) {
|
|
7
|
+
dispatch("confirm-click", {
|
|
8
|
+
nativeEvent: event.detail.nativeEvent
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function handleCancel(nativeEvent) {
|
|
13
|
+
if (!cancelDisable) {
|
|
14
|
+
dispatch("cancel-click", {
|
|
15
|
+
nativeEvent
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
import Button from "../../simple/buttons/Button.svelte";
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
style:margin-top={marginTop}
|
|
24
|
+
class="button-container"
|
|
25
|
+
>
|
|
26
|
+
<div
|
|
27
|
+
class="link-button-container"
|
|
28
|
+
>
|
|
29
|
+
<div></div>
|
|
30
|
+
<slot name="cancel-button" {loading} {handleCancel} {cancelText}>
|
|
31
|
+
<button
|
|
32
|
+
class="text-button"
|
|
33
|
+
on:click={handleCancel}
|
|
34
|
+
>{cancelText}</button>
|
|
35
|
+
</slot>
|
|
36
|
+
</div>
|
|
37
|
+
<slot name="confirm-button" {loading} {handleConfirm} {confirmDisable} {confirmText}>
|
|
38
|
+
<Button
|
|
39
|
+
loading={loading}
|
|
40
|
+
on:click={handleConfirm}
|
|
41
|
+
disabled={confirmDisable}
|
|
42
|
+
>{confirmText}</Button>
|
|
43
|
+
</slot>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<style>
|
|
48
|
+
@media (max-width: 768px){
|
|
49
|
+
.button-container {
|
|
50
|
+
flex-direction: column-reverse;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (min-width: 769px){
|
|
55
|
+
.button-container {
|
|
56
|
+
justify-content: end;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: 15px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.text-button {
|
|
63
|
+
font-family: inherit;
|
|
64
|
+
font-size: 100%;
|
|
65
|
+
font-weight: inherit;
|
|
66
|
+
line-height: inherit;
|
|
67
|
+
color: inherit;
|
|
68
|
+
margin: 0;
|
|
69
|
+
padding: 0;
|
|
70
|
+
background-color: transparent;
|
|
71
|
+
background-image: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.button-container {
|
|
75
|
+
display: flex;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.link-button-container {
|
|
79
|
+
height: 45px;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import '../../../css/main.css';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
loading?: boolean | undefined;
|
|
6
|
+
marginTop?: string | undefined;
|
|
7
|
+
cancelText?: string | undefined;
|
|
8
|
+
confirmText?: string | undefined;
|
|
9
|
+
confirmDisable?: boolean | undefined;
|
|
10
|
+
cancelDisable?: boolean | undefined;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
"confirm-click": CustomEvent<{
|
|
14
|
+
nativeEvent: MouseEvent;
|
|
15
|
+
}>;
|
|
16
|
+
"cancel-click": CustomEvent<{
|
|
17
|
+
nativeEvent: MouseEvent | KeyboardEvent;
|
|
18
|
+
}>;
|
|
19
|
+
} & {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
};
|
|
22
|
+
slots: {
|
|
23
|
+
'cancel-button': {
|
|
24
|
+
loading: boolean;
|
|
25
|
+
handleCancel: (nativeEvent: MouseEvent | KeyboardEvent) => void;
|
|
26
|
+
cancelText: string;
|
|
27
|
+
};
|
|
28
|
+
'confirm-button': {
|
|
29
|
+
loading: boolean;
|
|
30
|
+
handleConfirm: (event: any) => void;
|
|
31
|
+
confirmDisable: boolean;
|
|
32
|
+
confirmText: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type ConfirmOrCancelButtonsProps = typeof __propDef.props;
|
|
37
|
+
export type ConfirmOrCancelButtonsEvents = typeof __propDef.events;
|
|
38
|
+
export type ConfirmOrCancelButtonsSlots = typeof __propDef.slots;
|
|
39
|
+
export default class ConfirmOrCancelButtons extends SvelteComponentTyped<ConfirmOrCancelButtonsProps, ConfirmOrCancelButtonsEvents, ConfirmOrCancelButtonsSlots> {
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>import Autocomplete from "../../../components/simple/forms/Autocomplete.svelte";
|
|
4
|
+
import Button from "../../simple/buttons/Button.svelte";
|
|
5
|
+
import Icon from "../../simple/media/Icon.svelte";
|
|
6
|
+
export let items = [], values = [], multiple = false, searchText = void 0, maxVisibleChips = void 0, placeholder = "Seleziona", icon = void 0;
|
|
7
|
+
$:
|
|
8
|
+
generatedLabel = values.length == 1 ? values[0].label : `${values.length} Selezionati`;
|
|
9
|
+
function handleCloseClick(event) {
|
|
10
|
+
event.preventDefault();
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
values = [];
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Autocomplete
|
|
17
|
+
bind:items
|
|
18
|
+
bind:values
|
|
19
|
+
bind:searchText
|
|
20
|
+
bind:multiple
|
|
21
|
+
bind:maxVisibleChips
|
|
22
|
+
searchFunction={() => true}
|
|
23
|
+
>
|
|
24
|
+
<svelte:fragment slot="selection-container" let:openMenu let:handleKeyDown>
|
|
25
|
+
<Button
|
|
26
|
+
--button-default-background-color="transparent"
|
|
27
|
+
--button-default-border="2px solid rgb(var(--global-color-primary-400))"
|
|
28
|
+
--button-default-color="rgb(var(--global-color-contrast-800))"
|
|
29
|
+
on:click={openMenu}
|
|
30
|
+
on:keydown={(event) => {
|
|
31
|
+
handleKeyDown(event.detail.nativeEvent)
|
|
32
|
+
if(event.detail.nativeEvent.key == 'ArrowDown' || event.detail.nativeEvent.key == 'ArrowUp') {
|
|
33
|
+
event.detail.nativeEvent.stopPropagation()
|
|
34
|
+
event.detail.nativeEvent.preventDefault()
|
|
35
|
+
}
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<slot name="label" {values} {items} {searchText}>
|
|
39
|
+
<div class="label">
|
|
40
|
+
{#if !!icon}
|
|
41
|
+
<Icon name={icon}></Icon>
|
|
42
|
+
{/if}
|
|
43
|
+
{#if values.length == 0}
|
|
44
|
+
<div class="space-between">
|
|
45
|
+
<div>{placeholder}</div>
|
|
46
|
+
<Icon name="mdi-chevron-down"></Icon>
|
|
47
|
+
</div>
|
|
48
|
+
{:else}
|
|
49
|
+
<div class="space-between">
|
|
50
|
+
<div>{generatedLabel}</div>
|
|
51
|
+
<Icon
|
|
52
|
+
name="mdi-close"
|
|
53
|
+
click
|
|
54
|
+
on:click={handleCloseClick}
|
|
55
|
+
></Icon>
|
|
56
|
+
</div>
|
|
57
|
+
{/if}
|
|
58
|
+
</div>
|
|
59
|
+
</slot>
|
|
60
|
+
</Button>
|
|
61
|
+
</svelte:fragment>
|
|
62
|
+
</Autocomplete>
|
|
63
|
+
|
|
64
|
+
<style>
|
|
65
|
+
.label {
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: flex-start;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: 10px;
|
|
70
|
+
width: 130px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.space-between {
|
|
74
|
+
flex-grow: 1;
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
align-items: center;
|
|
78
|
+
}
|
|
79
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Item } from "../../../components/simple/forms/Autocomplete.svelte";
|
|
3
|
+
export type { Item };
|
|
4
|
+
declare const __propDef: {
|
|
5
|
+
props: {
|
|
6
|
+
items?: Item[] | undefined;
|
|
7
|
+
values?: Item[] | undefined;
|
|
8
|
+
multiple?: boolean | undefined;
|
|
9
|
+
searchText?: string | undefined;
|
|
10
|
+
maxVisibleChips?: number | undefined;
|
|
11
|
+
placeholder?: string | undefined;
|
|
12
|
+
icon?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {
|
|
18
|
+
label: {
|
|
19
|
+
values: Item[];
|
|
20
|
+
items: Item[];
|
|
21
|
+
searchText: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type DropdownProps = typeof __propDef.props;
|
|
26
|
+
export type DropdownEvents = typeof __propDef.events;
|
|
27
|
+
export type DropdownSlots = typeof __propDef.slots;
|
|
28
|
+
export default class Dropdown extends SvelteComponentTyped<DropdownProps, DropdownEvents, DropdownSlots> {
|
|
29
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
<!-- <script lang="ts" context="module">
|
|
2
|
+
export type Header = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: "boolean" | "string" | "number" | "date" | "custom";
|
|
6
|
+
width?: string;
|
|
7
|
+
minWidth?: string;
|
|
8
|
+
data?: { [key: string]: any };
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { onMount } from 'svelte';
|
|
14
|
+
import type { Filter } from '../../../types/filter';
|
|
15
|
+
import StandardPaginator from './StandardPaginator.svelte';
|
|
16
|
+
import StandardSelect from './StandardSelect.svelte';
|
|
17
|
+
import StandardTable from "./StandardTable.svelte";
|
|
18
|
+
|
|
19
|
+
export let headers: Header[] = [],
|
|
20
|
+
filters: Filter[] = [],
|
|
21
|
+
width: string = "auto",
|
|
22
|
+
page: number = 1,
|
|
23
|
+
perPage: number = 20,
|
|
24
|
+
perPageOptions: number[] = [20, 50, 100],
|
|
25
|
+
reload: boolean = false,
|
|
26
|
+
loading: boolean = false,
|
|
27
|
+
loadingText: string = "Caricamento ...",
|
|
28
|
+
noDataText: string = "Nessun elemento disponibile",
|
|
29
|
+
fetcher: (params: {
|
|
30
|
+
page: number,
|
|
31
|
+
perPage: number,
|
|
32
|
+
filters: Filter[]
|
|
33
|
+
}) => Promise<{
|
|
34
|
+
data: any[],
|
|
35
|
+
meta: PaginationData
|
|
36
|
+
}>
|
|
37
|
+
|
|
38
|
+
let items: { [key: string]: any }[] = [],
|
|
39
|
+
maxPage: number | undefined = undefined
|
|
40
|
+
|
|
41
|
+
onMount(() => {
|
|
42
|
+
loadRows()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
async function loadRows() {
|
|
46
|
+
if(!!fetcher) {
|
|
47
|
+
loading = true
|
|
48
|
+
let results = await fetcher({page, perPage, filters})
|
|
49
|
+
|
|
50
|
+
items = results.data
|
|
51
|
+
page = results.meta.currentPage
|
|
52
|
+
maxPage = results.meta.lastPage
|
|
53
|
+
loading = false
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handlePaginationChange() {
|
|
58
|
+
loadRows()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handlePerPageChange() {
|
|
62
|
+
page = 1
|
|
63
|
+
loadRows()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$: perPageOptionsFormatted = perPageOptions.map((el) => {
|
|
67
|
+
return {
|
|
68
|
+
value: el,
|
|
69
|
+
text: el.toString()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
$: if(reload) {
|
|
73
|
+
loadRows().then(() => {
|
|
74
|
+
reload = false
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$: filters && loadRows()
|
|
79
|
+
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<div class="top-actions">
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
<div class="table">
|
|
86
|
+
<StandardTable
|
|
87
|
+
headers={headers}
|
|
88
|
+
width={width}
|
|
89
|
+
items={items}
|
|
90
|
+
>
|
|
91
|
+
<svelte:fragment slot="appendLastColumn" let:item>
|
|
92
|
+
<slot name="appendLastColumn" item={item}></slot>
|
|
93
|
+
</svelte:fragment>
|
|
94
|
+
|
|
95
|
+
<svelte:fragment slot="customColumn" let:item let:header>
|
|
96
|
+
<slot name="customColumn" item={item} header={header}></slot>
|
|
97
|
+
</svelte:fragment>
|
|
98
|
+
</StandardTable>
|
|
99
|
+
{#if loading}
|
|
100
|
+
<div class="loading-text">
|
|
101
|
+
{loadingText}
|
|
102
|
+
</div>
|
|
103
|
+
{:else if items.length == 0}
|
|
104
|
+
<div class="no-data">
|
|
105
|
+
{noDataText}
|
|
106
|
+
</div>
|
|
107
|
+
{/if}
|
|
108
|
+
</div>
|
|
109
|
+
<div class="footer">
|
|
110
|
+
<div>
|
|
111
|
+
<StandardSelect
|
|
112
|
+
bind:value={perPage}
|
|
113
|
+
options={perPageOptionsFormatted}
|
|
114
|
+
on:change={handlePerPageChange}
|
|
115
|
+
></StandardSelect>
|
|
116
|
+
</div>
|
|
117
|
+
<div>
|
|
118
|
+
<StandardPaginator
|
|
119
|
+
bind:page={page}
|
|
120
|
+
bind:maxPage={maxPage}
|
|
121
|
+
on:change={handlePaginationChange}
|
|
122
|
+
></StandardPaginator>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<style>
|
|
127
|
+
.footer {
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
margin-top: 10px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.loading-text {
|
|
134
|
+
height: 200px;
|
|
135
|
+
max-height: 100vh;
|
|
136
|
+
display: flex;
|
|
137
|
+
justify-content: center;
|
|
138
|
+
align-items: center;
|
|
139
|
+
color: var(--global-light-contrast-color);
|
|
140
|
+
font-size: .9rem;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.no-data {
|
|
144
|
+
height: 200px;
|
|
145
|
+
max-height: 100vh;
|
|
146
|
+
display: flex;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
align-items: center;
|
|
149
|
+
color: var(--global-light-contrast-color);
|
|
150
|
+
font-size: .9rem;
|
|
151
|
+
}
|
|
152
|
+
</style> -->
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type PaginatedTableProps = typeof __propDef.props;
|
|
10
|
+
export type PaginatedTableEvents = typeof __propDef.events;
|
|
11
|
+
export type PaginatedTableSlots = typeof __propDef.slots;
|
|
12
|
+
export default class PaginatedTable extends SvelteComponentTyped<PaginatedTableProps, PaginatedTableEvents, PaginatedTableSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|