@invopop/popui 0.1.3 → 0.1.4-beta.2
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/AlertDialog.svelte +10 -11
- package/dist/BaseButton.svelte +29 -104
- package/dist/BaseCard.svelte +35 -30
- package/dist/BaseCounter.svelte +11 -8
- package/dist/BaseDropdown.svelte +5 -5
- package/dist/BaseFlag.svelte +5 -3
- package/dist/BaseFlag.svelte.d.ts +1 -0
- package/dist/BaseTable.svelte +16 -16
- package/dist/BaseTable.svelte.d.ts +1 -1
- package/dist/BaseTableActions.svelte +4 -6
- package/dist/BaseTableCellContent.svelte +9 -21
- package/dist/BaseTableCheckbox.svelte +9 -11
- package/dist/BaseTableHeaderContent.svelte +4 -4
- package/dist/BaseTableHeaderOrderBy.svelte +23 -12
- package/dist/BaseTableRow.svelte +12 -10
- package/dist/Breadcrumb.svelte +40 -0
- package/dist/Breadcrumb.svelte.d.ts +4 -0
- package/dist/Breadcrumbs.svelte +5 -30
- package/dist/ButtonFile.svelte +40 -30
- package/dist/ButtonUuidCopy.svelte +6 -3
- package/dist/CardCheckbox.svelte +45 -32
- package/dist/CardCheckbox.svelte.d.ts +1 -1
- package/dist/CardRelation.svelte +12 -13
- package/dist/CompanySelector.svelte +35 -7
- package/dist/CounterWidget.svelte +52 -0
- package/dist/CounterWidget.svelte.d.ts +4 -0
- package/dist/DataListItem.svelte +14 -10
- package/dist/DatePicker.svelte +20 -17
- package/dist/DrawerContext.svelte +207 -15
- package/dist/DrawerContextItem.svelte +50 -50
- package/dist/DrawerContextSeparator.svelte +1 -1
- package/dist/DropdownSelect.svelte +81 -22
- package/dist/DropdownSelectGroup.svelte +15 -0
- package/dist/DropdownSelectGroup.svelte.d.ts +7 -0
- package/dist/EmptyState.svelte +42 -0
- package/dist/EmptyState.svelte.d.ts +4 -0
- package/dist/FeedEvents.svelte +9 -5
- package/dist/FeedIconEvent.svelte +2 -2
- package/dist/FeedIconStatus.svelte +4 -4
- package/dist/FeedItem.svelte +10 -11
- package/dist/FeedItemDetail.svelte +32 -6
- package/dist/FeedViewer.svelte +1 -1
- package/dist/GlobalSearch.svelte +13 -12
- package/dist/InputCheckbox.svelte +2 -5
- package/dist/InputError.svelte +4 -9
- package/dist/InputLabel.svelte +3 -1
- package/dist/InputRadio.svelte +29 -13
- package/dist/InputRadio.svelte.d.ts +1 -1
- package/dist/InputSearch.svelte +8 -8
- package/dist/InputSelect.svelte +32 -31
- package/dist/InputText.svelte +32 -24
- package/dist/InputTextarea.svelte +25 -19
- package/dist/InputToggle.svelte +24 -18
- package/dist/MenuItem.svelte +16 -11
- package/dist/MenuItemCollapsible.svelte +7 -7
- package/dist/Notification.svelte +60 -25
- package/dist/ProfileAvatar.svelte +43 -14
- package/dist/ProgressBar.svelte +42 -0
- package/dist/ProgressBar.svelte.d.ts +4 -0
- package/dist/ProgressBarCircle.svelte +46 -0
- package/dist/ProgressBarCircle.svelte.d.ts +4 -0
- package/dist/SeparatorHorizontal.svelte +2 -2
- package/dist/ShortcutWrapper.svelte +14 -5
- package/dist/StatusLabel.svelte +4 -5
- package/dist/StepIconList.svelte +11 -9
- package/dist/TagBeta.svelte +26 -14
- package/dist/TagProgress.svelte +28 -0
- package/dist/TagProgress.svelte.d.ts +4 -0
- package/dist/TagSearch.svelte +4 -4
- package/dist/TagStatus.svelte +32 -34
- package/dist/TitleMain.svelte +1 -1
- package/dist/TitleSection.svelte +1 -1
- package/dist/UuidCopy.svelte +4 -4
- package/dist/alert-dialog/alert-dialog-action.svelte +8 -4
- package/dist/alert-dialog/alert-dialog-cancel.svelte +7 -3
- package/dist/alert-dialog/alert-dialog-content.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-description.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-footer.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-header.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-overlay.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-title.svelte +1 -1
- package/dist/alert-dialog/alert-dialog-trigger.svelte +4 -2
- package/dist/button/button.svelte +224 -24
- package/dist/button/button.svelte.d.ts +77 -26
- package/dist/clickOutside.d.ts +5 -2
- package/dist/clickOutside.js +9 -3
- package/dist/data-table/cells/boolean-cell.svelte +16 -0
- package/dist/data-table/cells/boolean-cell.svelte.d.ts +8 -0
- package/dist/data-table/cells/currency-cell.svelte +10 -0
- package/dist/data-table/cells/currency-cell.svelte.d.ts +8 -0
- package/dist/data-table/cells/date-cell.svelte +10 -0
- package/dist/data-table/cells/date-cell.svelte.d.ts +8 -0
- package/dist/data-table/cells/tag-cell.svelte +12 -0
- package/dist/data-table/cells/tag-cell.svelte.d.ts +8 -0
- package/dist/data-table/cells/text-cell.svelte +10 -0
- package/dist/data-table/cells/text-cell.svelte.d.ts +8 -0
- package/dist/data-table/column-definitions.d.ts +12 -0
- package/dist/data-table/column-definitions.js +42 -0
- package/dist/data-table/column-sizing-helpers.d.ts +6 -0
- package/dist/data-table/column-sizing-helpers.js +24 -0
- package/dist/data-table/create-columns.d.ts +3 -0
- package/dist/data-table/create-columns.js +50 -0
- package/dist/data-table/data-table-pagination.svelte +173 -0
- package/dist/data-table/data-table-pagination.svelte.d.ts +4 -0
- package/dist/data-table/data-table-svelte.svelte.d.ts +40 -0
- package/dist/data-table/data-table-svelte.svelte.js +111 -0
- package/dist/data-table/data-table-toolbar.svelte +16 -0
- package/dist/data-table/data-table-toolbar.svelte.d.ts +29 -0
- package/dist/data-table/data-table-types.d.ts +75 -0
- package/dist/data-table/data-table-types.js +1 -0
- package/dist/data-table/data-table-view-options.svelte +88 -0
- package/dist/data-table/data-table-view-options.svelte.d.ts +27 -0
- package/dist/data-table/data-table.svelte +323 -0
- package/dist/data-table/data-table.svelte.d.ts +25 -0
- package/dist/data-table/flex-render.svelte +40 -0
- package/dist/data-table/flex-render.svelte.d.ts +33 -0
- package/dist/data-table/index.d.ts +13 -0
- package/dist/data-table/index.js +13 -0
- package/dist/data-table/render-helpers.d.ts +90 -0
- package/dist/data-table/render-helpers.js +99 -0
- package/dist/data-table/table-setup.d.ts +36 -0
- package/dist/data-table/table-setup.js +130 -0
- package/dist/data-table/table-styles.d.ts +17 -0
- package/dist/data-table/table-styles.js +49 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +3 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.js +33 -14
- package/dist/range-calendar/range-calendar-cell.svelte +1 -1
- package/dist/range-calendar/range-calendar-day.svelte +11 -12
- package/dist/range-calendar/range-calendar-head-cell.svelte +1 -1
- package/dist/range-calendar/range-calendar-header.svelte +1 -1
- package/dist/range-calendar/range-calendar-month-select.svelte +1 -1
- package/dist/range-calendar/range-calendar-next-button.svelte +3 -3
- package/dist/range-calendar/range-calendar-prev-button.svelte +3 -3
- package/dist/range-calendar/range-calendar.svelte +1 -1
- package/dist/sonner/index.d.ts +1 -0
- package/dist/sonner/index.js +1 -0
- package/dist/sonner/sonner.svelte +44 -0
- package/dist/sonner/sonner.svelte.d.ts +4 -0
- package/dist/svg/CheckBadge.svelte +18 -0
- package/dist/svg/CheckBadge.svelte.d.ts +26 -0
- package/dist/svg/IconDelivery.svelte +86 -0
- package/dist/svg/IconDelivery.svelte.d.ts +20 -0
- package/dist/svg/IconEmpty.svelte +113 -121
- package/dist/svg/IconOrder.svelte +81 -0
- package/dist/svg/IconOrder.svelte.d.ts +20 -0
- package/dist/svg/IconPayment.svelte +86 -0
- package/dist/svg/IconPayment.svelte.d.ts +20 -0
- package/dist/table/table-body.svelte +5 -1
- package/dist/table/table-cell.svelte +4 -2
- package/dist/table/table-footer.svelte +1 -1
- package/dist/table/table-head.svelte +4 -2
- package/dist/table/table-header.svelte +1 -1
- package/dist/table/table-row.svelte +4 -2
- package/dist/table/table.svelte +2 -2
- package/dist/tabs/tabs-list.svelte +8 -2
- package/dist/tabs/tabs-list.svelte.d.ts +4 -1
- package/dist/tabs/tabs-trigger.svelte +5 -3
- package/dist/tabs/tabs-trigger.svelte.d.ts +4 -1
- package/dist/tailwind.theme.css +998 -0
- package/dist/tooltip/tooltip-content.svelte +2 -2
- package/dist/types.d.ts +76 -50
- package/package.json +20 -10
- package/dist/CounterWorkflow.svelte +0 -19
- package/dist/CounterWorkflow.svelte.d.ts +0 -4
- package/dist/DrawerContextWorkspace.svelte +0 -126
- package/dist/DrawerContextWorkspace.svelte.d.ts +0 -4
- package/dist/EmptyStateIcon.svelte +0 -52
- package/dist/EmptyStateIcon.svelte.d.ts +0 -4
- package/dist/EmptyStateIllustration.svelte +0 -66
- package/dist/EmptyStateIllustration.svelte.d.ts +0 -4
- package/dist/FormLayoutModal.svelte +0 -14
- package/dist/FormLayoutModal.svelte.d.ts +0 -4
- package/dist/ProfileSelector.svelte +0 -41
- package/dist/ProfileSelector.svelte.d.ts +0 -4
- package/dist/SectionLayout.svelte +0 -13
- package/dist/SectionLayout.svelte.d.ts +0 -4
- package/dist/tw.theme.d.ts +0 -171
- package/dist/tw.theme.js +0 -188
|
@@ -1,63 +1,114 @@
|
|
|
1
1
|
import { type WithElementRef } from '../utils.js';
|
|
2
2
|
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
import { type VariantProps } from 'tailwind-variants';
|
|
4
|
+
import type { IconSource } from '@steeze-ui/svelte-icon';
|
|
4
5
|
export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
5
6
|
variant: {
|
|
6
|
-
default: string;
|
|
7
|
-
destructive: string;
|
|
8
|
-
outline: string;
|
|
9
7
|
primary: string;
|
|
10
|
-
|
|
8
|
+
warning: string;
|
|
9
|
+
danger: string;
|
|
10
|
+
outline: string;
|
|
11
11
|
ghost: string;
|
|
12
|
-
|
|
12
|
+
secondary: string;
|
|
13
|
+
dark: string;
|
|
14
|
+
'dark-ghost': string;
|
|
13
15
|
};
|
|
14
16
|
size: {
|
|
15
|
-
default: string;
|
|
16
17
|
sm: string;
|
|
18
|
+
md: string;
|
|
17
19
|
lg: string;
|
|
18
|
-
icon: string;
|
|
19
|
-
'icon-sm': string;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
iconOnly: {
|
|
22
|
+
true: string;
|
|
23
|
+
false: string;
|
|
24
|
+
};
|
|
25
|
+
hasIcon: {
|
|
26
|
+
true: string;
|
|
27
|
+
false: string;
|
|
28
|
+
};
|
|
29
|
+
stackedLeft: {
|
|
30
|
+
true: string;
|
|
31
|
+
false: string;
|
|
32
|
+
};
|
|
33
|
+
stackedRight: {
|
|
34
|
+
true: string;
|
|
35
|
+
false: string;
|
|
36
|
+
};
|
|
37
|
+
}, undefined, "inline-flex items-center justify-center font-medium text-base whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-selected focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-30 relative overflow-hidden box-border cursor-pointer", {
|
|
22
38
|
variant: {
|
|
23
|
-
default: string;
|
|
24
|
-
destructive: string;
|
|
25
|
-
outline: string;
|
|
26
39
|
primary: string;
|
|
27
|
-
|
|
40
|
+
warning: string;
|
|
41
|
+
danger: string;
|
|
42
|
+
outline: string;
|
|
28
43
|
ghost: string;
|
|
29
|
-
|
|
44
|
+
secondary: string;
|
|
45
|
+
dark: string;
|
|
46
|
+
'dark-ghost': string;
|
|
30
47
|
};
|
|
31
48
|
size: {
|
|
32
|
-
default: string;
|
|
33
49
|
sm: string;
|
|
50
|
+
md: string;
|
|
34
51
|
lg: string;
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
};
|
|
53
|
+
iconOnly: {
|
|
54
|
+
true: string;
|
|
55
|
+
false: string;
|
|
56
|
+
};
|
|
57
|
+
hasIcon: {
|
|
58
|
+
true: string;
|
|
59
|
+
false: string;
|
|
60
|
+
};
|
|
61
|
+
stackedLeft: {
|
|
62
|
+
true: string;
|
|
63
|
+
false: string;
|
|
64
|
+
};
|
|
65
|
+
stackedRight: {
|
|
66
|
+
true: string;
|
|
67
|
+
false: string;
|
|
37
68
|
};
|
|
38
69
|
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
39
70
|
variant: {
|
|
40
|
-
default: string;
|
|
41
|
-
destructive: string;
|
|
42
|
-
outline: string;
|
|
43
71
|
primary: string;
|
|
44
|
-
|
|
72
|
+
warning: string;
|
|
73
|
+
danger: string;
|
|
74
|
+
outline: string;
|
|
45
75
|
ghost: string;
|
|
46
|
-
|
|
76
|
+
secondary: string;
|
|
77
|
+
dark: string;
|
|
78
|
+
'dark-ghost': string;
|
|
47
79
|
};
|
|
48
80
|
size: {
|
|
49
|
-
default: string;
|
|
50
81
|
sm: string;
|
|
82
|
+
md: string;
|
|
51
83
|
lg: string;
|
|
52
|
-
icon: string;
|
|
53
|
-
'icon-sm': string;
|
|
54
84
|
};
|
|
55
|
-
|
|
85
|
+
iconOnly: {
|
|
86
|
+
true: string;
|
|
87
|
+
false: string;
|
|
88
|
+
};
|
|
89
|
+
hasIcon: {
|
|
90
|
+
true: string;
|
|
91
|
+
false: string;
|
|
92
|
+
};
|
|
93
|
+
stackedLeft: {
|
|
94
|
+
true: string;
|
|
95
|
+
false: string;
|
|
96
|
+
};
|
|
97
|
+
stackedRight: {
|
|
98
|
+
true: string;
|
|
99
|
+
false: string;
|
|
100
|
+
};
|
|
101
|
+
}, undefined, "inline-flex items-center justify-center font-medium text-base whitespace-nowrap focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-selected focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-30 relative overflow-hidden box-border cursor-pointer", unknown, unknown, undefined>>;
|
|
56
102
|
export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
|
|
57
103
|
export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
|
|
58
104
|
export type ButtonProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
|
|
59
105
|
variant?: ButtonVariant;
|
|
60
106
|
size?: ButtonSize;
|
|
107
|
+
icon?: IconSource;
|
|
108
|
+
iconPosition?: 'left' | 'right';
|
|
109
|
+
iconClass?: string;
|
|
110
|
+
stackedLeft?: boolean;
|
|
111
|
+
stackedRight?: boolean;
|
|
61
112
|
};
|
|
62
113
|
declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
|
|
63
114
|
type Button = ReturnType<typeof Button>;
|
package/dist/clickOutside.d.ts
CHANGED
package/dist/clickOutside.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Dispatch event on click outside of node
|
|
3
|
+
* @param {HTMLElement} node
|
|
4
|
+
*/
|
|
2
5
|
export function clickOutside(node) {
|
|
6
|
+
/**
|
|
7
|
+
* @param {MouseEvent} event
|
|
8
|
+
*/
|
|
3
9
|
const handleClick = (event) => {
|
|
4
|
-
if (node && !node.contains(event.target) && !event.defaultPrevented) {
|
|
5
|
-
node.dispatchEvent(new CustomEvent('click_outside'
|
|
10
|
+
if (node && !node.contains(/** @type {Node} */ (event.target)) && !event.defaultPrevented) {
|
|
11
|
+
node.dispatchEvent(new CustomEvent('click_outside'))
|
|
6
12
|
}
|
|
7
13
|
}
|
|
8
14
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '@steeze-ui/svelte-icon'
|
|
3
|
+
import type { BooleanCellConfig } from '../data-table-types.js'
|
|
4
|
+
|
|
5
|
+
let { value, config }: { value: boolean; config?: BooleanCellConfig } = $props()
|
|
6
|
+
|
|
7
|
+
const showWhenTrue = config?.showWhenTrue ?? true
|
|
8
|
+
const showWhenFalse = config?.showWhenFalse ?? false
|
|
9
|
+
const shouldShow = value ? showWhenTrue : showWhenFalse
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if shouldShow && config?.icon}
|
|
13
|
+
<div class="flex justify-center">
|
|
14
|
+
<Icon src={config.icon} class={config.iconClass ?? 'size-4'} />
|
|
15
|
+
</div>
|
|
16
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BooleanCellConfig } from '../data-table-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
value: boolean;
|
|
4
|
+
config?: BooleanCellConfig;
|
|
5
|
+
};
|
|
6
|
+
declare const BooleanCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type BooleanCell = ReturnType<typeof BooleanCell>;
|
|
8
|
+
export default BooleanCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils.js'
|
|
3
|
+
import type { CurrencyCellConfig } from '../data-table-types.js'
|
|
4
|
+
|
|
5
|
+
let { value, config }: { value: any; config?: CurrencyCellConfig } = $props()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<span class={cn('font-mono text-base text-foreground', config?.className)}>
|
|
9
|
+
{value}
|
|
10
|
+
</span>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CurrencyCellConfig } from '../data-table-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
value: any;
|
|
4
|
+
config?: CurrencyCellConfig;
|
|
5
|
+
};
|
|
6
|
+
declare const CurrencyCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type CurrencyCell = ReturnType<typeof CurrencyCell>;
|
|
8
|
+
export default CurrencyCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils.js'
|
|
3
|
+
import type { DateCellConfig } from '../data-table-types.js'
|
|
4
|
+
|
|
5
|
+
let { value, config }: { value: any; config?: DateCellConfig } = $props()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<span class={cn('font-mono text-base text-foreground', config?.className)}>
|
|
9
|
+
{value}
|
|
10
|
+
</span>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DateCellConfig } from '../data-table-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
value: any;
|
|
4
|
+
config?: DateCellConfig;
|
|
5
|
+
};
|
|
6
|
+
declare const DateCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type DateCell = ReturnType<typeof DateCell>;
|
|
8
|
+
export default DateCell;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TagStatus from '../../TagStatus.svelte'
|
|
3
|
+
import type { TagCellConfig } from '../data-table-types.js'
|
|
4
|
+
|
|
5
|
+
let { value, config }: { value: string; config: TagCellConfig } = $props()
|
|
6
|
+
|
|
7
|
+
const option = $derived(config.options.find((opt) => opt.value === value))
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if option}
|
|
11
|
+
<TagStatus label={option.label} status={option.color} dot={config.showDot ?? false} />
|
|
12
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TagCellConfig } from '../data-table-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
value: string;
|
|
4
|
+
config: TagCellConfig;
|
|
5
|
+
};
|
|
6
|
+
declare const TagCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type TagCell = ReturnType<typeof TagCell>;
|
|
8
|
+
export default TagCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils.js'
|
|
3
|
+
import type { TextCellConfig } from '../data-table-types.js'
|
|
4
|
+
|
|
5
|
+
let { value, config }: { value: any; config?: TextCellConfig } = $props()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<div class={cn('truncate', config?.className)}>
|
|
9
|
+
{value}
|
|
10
|
+
</div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TextCellConfig } from '../data-table-types.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
value: any;
|
|
4
|
+
config?: TextCellConfig;
|
|
5
|
+
};
|
|
6
|
+
declare const TextCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type TextCell = ReturnType<typeof TextCell>;
|
|
8
|
+
export default TextCell;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ColumnDef, Row } from '@tanstack/table-core';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Create the selection column definition for row selection
|
|
5
|
+
*/
|
|
6
|
+
export declare function createSelectionColumn<TData>(): ColumnDef<TData>;
|
|
7
|
+
/**
|
|
8
|
+
* Create the actions column definition for row actions
|
|
9
|
+
*/
|
|
10
|
+
export declare function createActionsColumn<TData>(rowActionsSnippet: Snippet<[{
|
|
11
|
+
row: Row<TData>;
|
|
12
|
+
}]>): ColumnDef<TData>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { renderComponent, renderSnippet } from './render-helpers.js';
|
|
2
|
+
import InputCheckbox from '../InputCheckbox.svelte';
|
|
3
|
+
/**
|
|
4
|
+
* Create the selection column definition for row selection
|
|
5
|
+
*/
|
|
6
|
+
export function createSelectionColumn() {
|
|
7
|
+
return {
|
|
8
|
+
id: 'select',
|
|
9
|
+
header: ({ table }) => renderComponent(InputCheckbox, {
|
|
10
|
+
checked: table.getIsAllPageRowsSelected(),
|
|
11
|
+
onchange: (value) => table.toggleAllPageRowsSelected(value),
|
|
12
|
+
indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
|
|
13
|
+
'aria-label': 'Select all',
|
|
14
|
+
onclick: (e) => e.stopPropagation()
|
|
15
|
+
}),
|
|
16
|
+
cell: ({ row }) => renderComponent(InputCheckbox, {
|
|
17
|
+
checked: row.getIsSelected(),
|
|
18
|
+
onchange: (value) => row.toggleSelected(value),
|
|
19
|
+
'aria-label': 'Select row',
|
|
20
|
+
onclick: (e) => e.stopPropagation()
|
|
21
|
+
}),
|
|
22
|
+
enableSorting: false,
|
|
23
|
+
enableHiding: false,
|
|
24
|
+
enableResizing: false,
|
|
25
|
+
size: 52,
|
|
26
|
+
minSize: 52,
|
|
27
|
+
maxSize: 52
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create the actions column definition for row actions
|
|
32
|
+
*/
|
|
33
|
+
export function createActionsColumn(rowActionsSnippet) {
|
|
34
|
+
return {
|
|
35
|
+
id: 'actions',
|
|
36
|
+
cell: ({ row }) => renderSnippet(rowActionsSnippet, { row }),
|
|
37
|
+
enableResizing: false,
|
|
38
|
+
size: 56,
|
|
39
|
+
minSize: 56,
|
|
40
|
+
maxSize: 56
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColumnSizingState } from '@tanstack/table-core';
|
|
2
|
+
/**
|
|
3
|
+
* Calculate initial column sizes based on available container width
|
|
4
|
+
* Scales column sizes proportionally if container is wider than default sizes
|
|
5
|
+
*/
|
|
6
|
+
export declare function calculateColumnSizing(columns: any[], containerWidth: number): ColumnSizingState | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate initial column sizes based on available container width
|
|
3
|
+
* Scales column sizes proportionally if container is wider than default sizes
|
|
4
|
+
*/
|
|
5
|
+
export function calculateColumnSizing(columns, containerWidth) {
|
|
6
|
+
// Collect all column sizes
|
|
7
|
+
const defaultSizes = {};
|
|
8
|
+
columns.forEach((col) => {
|
|
9
|
+
if (col.size) {
|
|
10
|
+
defaultSizes[col.id] = col.size;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const totalDefaultSize = Object.values(defaultSizes).reduce((sum, size) => sum + size, 0);
|
|
14
|
+
// If container is wider than default, scale columns proportionally
|
|
15
|
+
if (containerWidth > totalDefaultSize && totalDefaultSize > 0) {
|
|
16
|
+
const scale = containerWidth / totalDefaultSize;
|
|
17
|
+
const newSizing = {};
|
|
18
|
+
Object.entries(defaultSizes).forEach(([key, value]) => {
|
|
19
|
+
newSizing[key] = Math.floor(value * scale);
|
|
20
|
+
});
|
|
21
|
+
return newSizing;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { renderComponent } from './render-helpers.js';
|
|
2
|
+
import TextCell from './cells/text-cell.svelte';
|
|
3
|
+
import BooleanCell from './cells/boolean-cell.svelte';
|
|
4
|
+
import TagCell from './cells/tag-cell.svelte';
|
|
5
|
+
import DateCell from './cells/date-cell.svelte';
|
|
6
|
+
import CurrencyCell from './cells/currency-cell.svelte';
|
|
7
|
+
export function createColumns(columns) {
|
|
8
|
+
return columns.map((col) => {
|
|
9
|
+
const tanstackCol = {
|
|
10
|
+
id: col.id,
|
|
11
|
+
accessorKey: col.accessorKey,
|
|
12
|
+
header: col.header,
|
|
13
|
+
enableSorting: col.enableSorting ?? true,
|
|
14
|
+
enableHiding: col.enableHiding ?? true,
|
|
15
|
+
enableResizing: col.enableResizing ?? true,
|
|
16
|
+
size: col.size,
|
|
17
|
+
minSize: col.minSize,
|
|
18
|
+
maxSize: col.maxSize
|
|
19
|
+
};
|
|
20
|
+
// Cell renderer
|
|
21
|
+
if (col.cell) {
|
|
22
|
+
// Custom cell renderer
|
|
23
|
+
tanstackCol.cell = ({ row }) => {
|
|
24
|
+
const value = col.accessorKey ? row.original[col.accessorKey] : undefined;
|
|
25
|
+
return col.cell(value, row.original);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else if (col.cellType) {
|
|
29
|
+
// Built-in cell renderer based on type
|
|
30
|
+
tanstackCol.cell = ({ row }) => {
|
|
31
|
+
const value = col.accessorKey ? row.original[col.accessorKey] : undefined;
|
|
32
|
+
switch (col.cellType) {
|
|
33
|
+
case 'text':
|
|
34
|
+
return renderComponent(TextCell, { value: value, config: col.cellConfig });
|
|
35
|
+
case 'boolean':
|
|
36
|
+
return renderComponent(BooleanCell, { value: value, config: col.cellConfig });
|
|
37
|
+
case 'tag':
|
|
38
|
+
return renderComponent(TagCell, { value: value, config: col.cellConfig });
|
|
39
|
+
case 'date':
|
|
40
|
+
return renderComponent(DateCell, { value: value, config: col.cellConfig });
|
|
41
|
+
case 'currency':
|
|
42
|
+
return renderComponent(CurrencyCell, { value: value, config: col.cellConfig });
|
|
43
|
+
default:
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return tanstackCol;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from '../button/button.svelte'
|
|
3
|
+
import InputSelect from '../InputSelect.svelte'
|
|
4
|
+
import { ArrowLeft, ArrowRight, ScrollLeft, ScrollRight } from '@invopop/ui-icons'
|
|
5
|
+
import { cn } from '../utils.js'
|
|
6
|
+
import type { DataTablePaginationProps } from './data-table-types.js'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
table,
|
|
10
|
+
id,
|
|
11
|
+
class: className,
|
|
12
|
+
showRowsPerPage = true,
|
|
13
|
+
rowsPerPageOptions = [10, 25, 50, 100],
|
|
14
|
+
itemsLabel = 'items',
|
|
15
|
+
children,
|
|
16
|
+
selectedSlot,
|
|
17
|
+
unselectedSlot,
|
|
18
|
+
onPageChange,
|
|
19
|
+
onPageSizeChange
|
|
20
|
+
}: DataTablePaginationProps<any> = $props()
|
|
21
|
+
|
|
22
|
+
let currentPage = $derived(table.getState().pagination.pageIndex + 1)
|
|
23
|
+
let totalPages = $derived(table.getPageCount())
|
|
24
|
+
let totalItems = $derived(table.getFilteredRowModel().rows.length)
|
|
25
|
+
let rowsPerPage = $derived(table.getState().pagination.pageSize)
|
|
26
|
+
let hasSelection = $derived(Object.keys(table.getState().rowSelection).length > 0)
|
|
27
|
+
|
|
28
|
+
let pageInputValue = $derived(`${currentPage}`)
|
|
29
|
+
|
|
30
|
+
function handlePageInput(event: Event) {
|
|
31
|
+
const target = event.target as HTMLInputElement
|
|
32
|
+
const value = parseInt(target.value)
|
|
33
|
+
if (value >= 1 && value <= totalPages) {
|
|
34
|
+
table.setPageIndex(value - 1)
|
|
35
|
+
onPageChange?.(value)
|
|
36
|
+
} else if (target.value === '') {
|
|
37
|
+
// Allow empty input temporarily
|
|
38
|
+
pageInputValue = ''
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handlePageBlur(event: Event) {
|
|
43
|
+
const target = event.target as HTMLInputElement
|
|
44
|
+
const value = parseInt(target.value)
|
|
45
|
+
if (isNaN(value) || value < 1) {
|
|
46
|
+
pageInputValue = `${currentPage}`
|
|
47
|
+
} else if (value > totalPages) {
|
|
48
|
+
table.setPageIndex(totalPages - 1)
|
|
49
|
+
onPageChange?.(totalPages)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function formatNumber(num: number): string {
|
|
54
|
+
return new Intl.NumberFormat('en-US').format(num)
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
{id}
|
|
60
|
+
class={cn(
|
|
61
|
+
'flex items-center justify-between h-11 px-4 py-[5px] bg-background backdrop-blur-[10px]',
|
|
62
|
+
className
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
<div class="flex items-center gap-3">
|
|
66
|
+
<div class="flex items-center gap-2">
|
|
67
|
+
<div class="flex items-center gap-1.5">
|
|
68
|
+
<div class="flex items-center">
|
|
69
|
+
<Button
|
|
70
|
+
variant="ghost"
|
|
71
|
+
size="md"
|
|
72
|
+
icon={ScrollLeft}
|
|
73
|
+
onclick={() => {
|
|
74
|
+
table.setPageIndex(0)
|
|
75
|
+
onPageChange?.(1)
|
|
76
|
+
}}
|
|
77
|
+
disabled={currentPage === 1}
|
|
78
|
+
class={cn(currentPage === 1 && 'pointer-events-none opacity-30')}
|
|
79
|
+
aria-label="First page"
|
|
80
|
+
/>
|
|
81
|
+
<Button
|
|
82
|
+
variant="ghost"
|
|
83
|
+
size="md"
|
|
84
|
+
icon={ArrowLeft}
|
|
85
|
+
onclick={() => {
|
|
86
|
+
const newPage = currentPage - 1
|
|
87
|
+
table.previousPage()
|
|
88
|
+
onPageChange?.(newPage)
|
|
89
|
+
}}
|
|
90
|
+
disabled={currentPage === 1}
|
|
91
|
+
class={cn(currentPage === 1 && 'pointer-events-none opacity-30')}
|
|
92
|
+
aria-label="Previous page"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="flex items-center gap-1.5">
|
|
96
|
+
<input
|
|
97
|
+
type="number"
|
|
98
|
+
bind:value={pageInputValue}
|
|
99
|
+
min="1"
|
|
100
|
+
max={totalPages}
|
|
101
|
+
oninput={handlePageInput}
|
|
102
|
+
onblur={handlePageBlur}
|
|
103
|
+
class="w-12 h-8 px-2 py-1 text-base tracking-tight rounded-lg border border-border-default-secondary bg-background-default-default backdrop-blur-[2px] caret-foreground-accent text-foreground outline-none focus:ring-0 hover:border-border-default-secondary-hover focus:border-border-selected-bold focus:shadow-active [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
|
|
104
|
+
/>
|
|
105
|
+
<span class="text-sm text-foreground-default-secondary whitespace-nowrap">
|
|
106
|
+
/ {totalPages}
|
|
107
|
+
</span>
|
|
108
|
+
</div>
|
|
109
|
+
<div class="flex items-center">
|
|
110
|
+
<Button
|
|
111
|
+
variant="ghost"
|
|
112
|
+
size="md"
|
|
113
|
+
icon={ArrowRight}
|
|
114
|
+
onclick={() => {
|
|
115
|
+
const newPage = currentPage + 1
|
|
116
|
+
table.nextPage()
|
|
117
|
+
onPageChange?.(newPage)
|
|
118
|
+
}}
|
|
119
|
+
disabled={currentPage === totalPages}
|
|
120
|
+
class={cn(currentPage === totalPages && 'pointer-events-none opacity-30')}
|
|
121
|
+
aria-label="Next page"
|
|
122
|
+
/>
|
|
123
|
+
<Button
|
|
124
|
+
variant="ghost"
|
|
125
|
+
size="md"
|
|
126
|
+
icon={ScrollRight}
|
|
127
|
+
onclick={() => {
|
|
128
|
+
table.setPageIndex(totalPages - 1)
|
|
129
|
+
onPageChange?.(totalPages)
|
|
130
|
+
}}
|
|
131
|
+
disabled={currentPage === totalPages}
|
|
132
|
+
class={cn(currentPage === totalPages && 'pointer-events-none opacity-30')}
|
|
133
|
+
aria-label="Last page"
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
{#if showRowsPerPage}
|
|
138
|
+
<div class="w-[105px]">
|
|
139
|
+
<InputSelect
|
|
140
|
+
value={`${rowsPerPage}`}
|
|
141
|
+
options={rowsPerPageOptions.map((size) => ({
|
|
142
|
+
value: `${size}`,
|
|
143
|
+
label: `${size} rows`
|
|
144
|
+
}))}
|
|
145
|
+
onchange={(value) => {
|
|
146
|
+
const size = Number(value)
|
|
147
|
+
table.setPageSize(size)
|
|
148
|
+
onPageSizeChange?.(size)
|
|
149
|
+
}}
|
|
150
|
+
placeholder="Rows per page"
|
|
151
|
+
disablePlaceholder={true}
|
|
152
|
+
aria-label="Rows per page"
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
{/if}
|
|
156
|
+
</div>
|
|
157
|
+
{#if totalItems > 0}
|
|
158
|
+
<span class="text-sm text-foreground-default-secondary">
|
|
159
|
+
{formatNumber(totalItems)}
|
|
160
|
+
{itemsLabel}
|
|
161
|
+
</span>
|
|
162
|
+
{/if}
|
|
163
|
+
</div>
|
|
164
|
+
<div class="flex items-center gap-2">
|
|
165
|
+
{#if hasSelection && selectedSlot}
|
|
166
|
+
{@render selectedSlot()}
|
|
167
|
+
{:else if !hasSelection && unselectedSlot}
|
|
168
|
+
{@render unselectedSlot()}
|
|
169
|
+
{:else if children}
|
|
170
|
+
{@render children()}
|
|
171
|
+
{/if}
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DataTablePaginationProps } from './data-table-types.js';
|
|
2
|
+
declare const DataTablePagination: import("svelte").Component<DataTablePaginationProps<any>, {}, "">;
|
|
3
|
+
type DataTablePagination = ReturnType<typeof DataTablePagination>;
|
|
4
|
+
export default DataTablePagination;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type RowData, type TableOptions } from "@tanstack/table-core";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a reactive TanStack table object for Svelte.
|
|
4
|
+
* @param options Table options to create the table with.
|
|
5
|
+
* @returns A reactive table object.
|
|
6
|
+
* @example
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <script>
|
|
9
|
+
* const table = createSvelteTable({ ... })
|
|
10
|
+
* </script>
|
|
11
|
+
*
|
|
12
|
+
* <table>
|
|
13
|
+
* <thead>
|
|
14
|
+
* {#each table.getHeaderGroups() as headerGroup}
|
|
15
|
+
* <tr>
|
|
16
|
+
* {#each headerGroup.headers as header}
|
|
17
|
+
* <th colspan={header.colSpan}>
|
|
18
|
+
* <FlexRender content={header.column.columnDef.header} context={header.getContext()} />
|
|
19
|
+
* </th>
|
|
20
|
+
* {/each}
|
|
21
|
+
* </tr>
|
|
22
|
+
* {/each}
|
|
23
|
+
* </thead>
|
|
24
|
+
* <!-- ... -->
|
|
25
|
+
* </table>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createSvelteTable<TData extends RowData>(options: TableOptions<TData>): import("@tanstack/table-core").Table<TData>;
|
|
29
|
+
type MaybeThunk<T extends object> = T | (() => T | null | undefined);
|
|
30
|
+
type Intersection<T extends readonly unknown[]> = (T extends [infer H, ...infer R] ? H & Intersection<R> : unknown) & {};
|
|
31
|
+
/**
|
|
32
|
+
* Lazily merges several objects (or thunks) while preserving
|
|
33
|
+
* getter semantics from every source.
|
|
34
|
+
*
|
|
35
|
+
* Proxy-based to avoid known WebKit recursion issue.
|
|
36
|
+
*/
|
|
37
|
+
export declare function mergeObjects<Sources extends readonly MaybeThunk<any>[]>(...sources: Sources): Intersection<{
|
|
38
|
+
[K in keyof Sources]: Sources[K];
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|