@skeletonlabs/skeleton 0.78.0 → 0.80.8
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 +5 -0
- package/actions/Filters/svg-filters/GreenFall.svelte +10 -1
- package/actions/Filters/svg-filters/Noir.svelte +21 -2
- package/actions/Filters/svg-filters/NoirLight.svelte +10 -1
- package/actions/FocusTrap/focusTrap.js +16 -5
- package/components/Accordion/AccordionGroup.svelte +1 -1
- package/components/Alert/Alert.svelte +4 -4
- package/components/AppRail/AppRail.svelte +6 -3
- package/components/AppRail/AppRail.svelte.d.ts +2 -1
- package/components/AppRail/AppRailTile.svelte +13 -6
- package/components/AppRail/AppRailTile.svelte.d.ts +2 -2
- package/components/AppShell/AppShell.svelte +1 -1
- package/components/Breadcrumb/Crumb.svelte +7 -1
- package/components/ConicGradient/ConicGradient.svelte +1 -1
- package/components/FileDropzone/FileDropzone.svelte +13 -2
- package/components/FileDropzone/FileDropzone.svelte.d.ts +1 -0
- package/components/GradientHeading/GradientHeading.svelte.d.ts +1 -1
- package/components/ListBox/ListBox.svelte +6 -3
- package/components/ProgressBar/ProgressBar.svelte +9 -1
- package/components/ProgressRadial/ProgressRadial.svelte +9 -1
- package/components/Radio/RadioGroup.svelte +3 -0
- package/components/Radio/RadioGroup.svelte.d.ts +1 -0
- package/components/Radio/RadioItem.svelte +23 -4
- package/components/Radio/RadioItem.svelte.d.ts +4 -2
- package/components/RangeSlider/RangeSlider.svelte +9 -3
- package/components/SlideToggle/SlideToggle.svelte +22 -2
- package/components/SvgIcon/SvgIcon.svelte +1 -1
- package/components/SvgIcon/icons.d.ts +1 -1
- package/components/SvgIcon/icons.js +1 -1
- package/components/Tab/Tab.svelte +5 -2
- package/components/Tab/TabGroup.svelte +1 -1
- package/components/Table/Table.svelte +2 -5
- package/index.d.ts +3 -1
- package/index.js +2 -1
- package/package.json +14 -6
- package/styles/all.css +7 -6
- package/styles/core.css +1 -1
- package/styles/elements/badges.css +22 -1
- package/styles/elements/buttons.css +5 -5
- package/styles/elements/cards.css +12 -6
- package/styles/elements/chips.css +18 -0
- package/styles/elements/lists.css +1 -1
- package/styles/elements/menus.css +3 -0
- package/styles/elements/tables.css +2 -2
- package/styles/elements.css +3 -2
- package/styles/forms.css +15 -8
- package/styles/tailwind.css +2 -2
- package/styles/tokens/backgrounds.css +239 -0
- package/styles/tokens/border-radius.css +41 -0
- package/styles/tokens/borders.css +185 -0
- package/styles/tokens/fills.css +29 -0
- package/styles/tokens/misc.css +22 -0
- package/styles/tokens/rings.css +185 -0
- package/styles/tokens/text.css +216 -0
- package/styles/tokens.css +9 -169
- package/styles/typography.css +2 -2
- package/tailwind/theme.cjs +10 -18
- package/themes/theme-crimson.css +6 -0
- package/themes/theme-gold-nouveau.css +12 -0
- package/themes/theme-hamlindigo.css +6 -0
- package/themes/theme-modern.css +6 -0
- package/themes/theme-rocket.css +6 -0
- package/themes/theme-sahara.css +6 -0
- package/themes/theme-seafoam.css +8 -2
- package/themes/theme-skeleton.css +7 -1
- package/themes/theme-vintage.css +6 -0
- package/utilities/DataTable/DataTable.d.ts +15 -11
- package/utilities/DataTable/DataTable.js +90 -53
- package/utilities/DataTable/types.d.ts +24 -6
- package/utilities/Drawer/Drawer.svelte +79 -58
- package/utilities/Drawer/Drawer.svelte.d.ts +1 -3
- package/utilities/Drawer/stores.d.ts +10 -0
- package/utilities/Drawer/stores.js +21 -0
- package/utilities/Drawer/types.d.ts +33 -0
- package/utilities/Drawer/types.js +2 -0
- package/utilities/Menu/menu.js +60 -13
- package/utilities/Modal/Modal.svelte +4 -4
- package/utilities/Modal/examples/ModalExampleForm.svelte +3 -2
- package/utilities/Modal/examples/ModalExampleList.svelte +3 -5
- package/utilities/Modal/stores.d.ts +12 -1
- package/utilities/Modal/stores.js +2 -0
- package/utilities/Modal/types.d.ts +1 -1
- package/utilities/Toast/Toast.svelte +1 -1
- package/themes/legacy/theme-skeleton.css +0 -93
- package/utilities/Modal/Modal.d.ts +0 -1
- package/utilities/Modal/Modal.js +0 -44
package/styles/tokens.css
CHANGED
|
@@ -1,171 +1,11 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* Design Tokens */
|
|
2
2
|
|
|
3
|
-
@
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
@import 'tokens/backgrounds.css';
|
|
4
|
+
@import 'tokens/borders.css';
|
|
5
|
+
@import 'tokens/border-radius.css';
|
|
6
|
+
@import 'tokens/fills.css';
|
|
7
|
+
@import 'tokens/rings.css';
|
|
8
|
+
@import 'tokens/text.css';
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/* === Background === */
|
|
12
|
-
|
|
13
|
-
/* Primary */
|
|
14
|
-
.bg-hover-token {
|
|
15
|
-
@apply hover:bg-primary-500/10;
|
|
16
|
-
}
|
|
17
|
-
.bg-active-token {
|
|
18
|
-
@apply bg-primary-500;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/* Accent */
|
|
22
|
-
.bg-accent-hover-token {
|
|
23
|
-
@apply hover:bg-accent-500/10;
|
|
24
|
-
}
|
|
25
|
-
.bg-accent-active-token {
|
|
26
|
-
@apply bg-accent-500 text-accent-50 dark:text-accent-50;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Backdrop Shim */
|
|
30
|
-
.bg-backdrop-token {
|
|
31
|
-
@apply bg-surface-400/70 dark:bg-surface-900/70;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* Background: Surface (darkest -> lightest) */
|
|
35
|
-
/* https://user-images.githubusercontent.com/1509726/195171203-423e5b84-8763-40f1-b3ea-4cb2b8e38108.png */
|
|
36
|
-
.bg-surface-50-900-token {
|
|
37
|
-
@apply bg-surface-50 dark:bg-surface-900;
|
|
38
|
-
}
|
|
39
|
-
.bg-surface-100-800-token {
|
|
40
|
-
@apply bg-surface-100 dark:bg-surface-800;
|
|
41
|
-
}
|
|
42
|
-
.bg-surface-200-700-token {
|
|
43
|
-
@apply bg-surface-200 dark:bg-surface-700;
|
|
44
|
-
}
|
|
45
|
-
.bg-surface-300-600-token {
|
|
46
|
-
@apply bg-surface-300 dark:bg-surface-600;
|
|
47
|
-
}
|
|
48
|
-
.bg-surface-400-500-token {
|
|
49
|
-
@apply bg-surface-400 dark:bg-surface-500;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* === Border Width === */
|
|
53
|
-
|
|
54
|
-
.border-token {
|
|
55
|
-
border-width: var(--theme-border-base);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* === Border Colors === */
|
|
59
|
-
|
|
60
|
-
/* Border: Surface (darkest -> lightest) */
|
|
61
|
-
/* https://user-images.githubusercontent.com/1509726/195171203-423e5b84-8763-40f1-b3ea-4cb2b8e38108.png */
|
|
62
|
-
.border-surface-50-900-token {
|
|
63
|
-
@apply border-surface-50 dark:border-surface-900;
|
|
64
|
-
}
|
|
65
|
-
.border-surface-100-800-token {
|
|
66
|
-
@apply border-surface-100 dark:border-surface-800;
|
|
67
|
-
}
|
|
68
|
-
.border-surface-200-700-token {
|
|
69
|
-
@apply border-surface-200 dark:border-surface-700;
|
|
70
|
-
}
|
|
71
|
-
.border-surface-300-600-token {
|
|
72
|
-
@apply border-surface-300 dark:border-surface-600;
|
|
73
|
-
}
|
|
74
|
-
.border-surface-400-500-token {
|
|
75
|
-
@apply border-surface-400 dark:border-surface-500;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/* === Border Radius === */
|
|
79
|
-
|
|
80
|
-
/* Base */
|
|
81
|
-
/* Small elements, such as buttons, badges, chips, etc. */
|
|
82
|
-
.rounded-token {
|
|
83
|
-
border-radius: var(--theme-rounded-base);
|
|
84
|
-
}
|
|
85
|
-
.rounded-tl-token {
|
|
86
|
-
border-top-left-radius: var(--theme-rounded-base);
|
|
87
|
-
}
|
|
88
|
-
.rounded-tr-token {
|
|
89
|
-
border-top-right-radius: var(--theme-rounded-base);
|
|
90
|
-
}
|
|
91
|
-
.rounded-bl-token {
|
|
92
|
-
border-bottom-left-radius: var(--theme-rounded-base);
|
|
93
|
-
}
|
|
94
|
-
.rounded-br-token {
|
|
95
|
-
border-bottom-right-radius: var(--theme-rounded-base);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/* Container */
|
|
99
|
-
/* Large elements, such as cards and textareas */
|
|
100
|
-
.rounded-container-token {
|
|
101
|
-
border-radius: var(--theme-rounded-container);
|
|
102
|
-
}
|
|
103
|
-
.rounded-tl-container-token {
|
|
104
|
-
border-top-left-radius: var(--theme-rounded-container);
|
|
105
|
-
}
|
|
106
|
-
.rounded-tr-container-token {
|
|
107
|
-
border-top-right-radius: var(--theme-rounded-container);
|
|
108
|
-
}
|
|
109
|
-
.rounded-bl-container-token {
|
|
110
|
-
border-bottom-left-radius: var(--theme-rounded-container);
|
|
111
|
-
}
|
|
112
|
-
.rounded-br-container-token {
|
|
113
|
-
border-bottom-right-radius: var(--theme-rounded-container);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/* === Font Family === */
|
|
117
|
-
|
|
118
|
-
.font-heading-token {
|
|
119
|
-
font-family: var(--theme-font-family-heading);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.font-token {
|
|
123
|
-
font-family: var(--theme-font-family-base);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* === Font Color === */
|
|
127
|
-
/* Light / Dark / Auto */
|
|
128
|
-
|
|
129
|
-
.text-base-token {
|
|
130
|
-
color: rgba(var(--theme-font-color-base));
|
|
131
|
-
}
|
|
132
|
-
.text-dark-token {
|
|
133
|
-
color: rgba(var(--theme-font-color-dark));
|
|
134
|
-
}
|
|
135
|
-
.text-token {
|
|
136
|
-
@apply text-base-token dark:text-dark-token;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/* === Ring Colors === */
|
|
140
|
-
|
|
141
|
-
/* Ring: Surface (darkest -> lightest) */
|
|
142
|
-
/* https://user-images.githubusercontent.com/1509726/195171203-423e5b84-8763-40f1-b3ea-4cb2b8e38108.png */
|
|
143
|
-
.ring-surface-50-900-token {
|
|
144
|
-
@apply ring-surface-50 dark:ring-surface-900;
|
|
145
|
-
}
|
|
146
|
-
.ring-surface-100-800-token {
|
|
147
|
-
@apply ring-surface-100 dark:ring-surface-800;
|
|
148
|
-
}
|
|
149
|
-
.ring-surface-200-700-token {
|
|
150
|
-
@apply ring-surface-200 dark:ring-surface-700;
|
|
151
|
-
}
|
|
152
|
-
.ring-surface-300-600-token {
|
|
153
|
-
@apply ring-surface-300 dark:ring-surface-600;
|
|
154
|
-
}
|
|
155
|
-
.ring-surface-400-500-token {
|
|
156
|
-
@apply ring-surface-400 dark:ring-surface-500;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/* === SVG Fill === */
|
|
160
|
-
/* Light / Dark / Auto */
|
|
161
|
-
|
|
162
|
-
.fill-base-token {
|
|
163
|
-
fill: rgba(var(--theme-font-color-base));
|
|
164
|
-
}
|
|
165
|
-
.fill-dark-token {
|
|
166
|
-
fill: rgba(var(--theme-font-color-dark));
|
|
167
|
-
}
|
|
168
|
-
.fill-token {
|
|
169
|
-
@apply fill-base-token dark:fill-dark-token;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
10
|
+
/* One-off tokens go here */
|
|
11
|
+
@import 'tokens/misc.css';
|
package/styles/typography.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Stylesheet
|
|
1
|
+
/* Stylesheet: typography.css */
|
|
2
2
|
|
|
3
3
|
body {
|
|
4
4
|
/* Theme: Font Family */
|
|
@@ -48,7 +48,7 @@ body {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
a:not(.unstyled):not(.btn):not(.btn-icon):not(.app-bar a):not(.logo-item):not(.card):not(.list-nav a) {
|
|
51
|
-
@apply text-primary-600
|
|
51
|
+
@apply text-primary-600-300-token underline underline-offset-4 decoration-dotted decoration-primary-500/20 hover:decoration-primary-500;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
blockquote:not(.unstyled) {
|
package/tailwind/theme.cjs
CHANGED
|
@@ -4,27 +4,19 @@
|
|
|
4
4
|
const plugin = require('tailwindcss/plugin');
|
|
5
5
|
|
|
6
6
|
// Source: https://tailwindcss.com/docs/customizing-colors#using-css-variables
|
|
7
|
-
function rgbAppendOpacity(variable) {
|
|
8
|
-
return ({ opacityValue }) => {
|
|
9
|
-
if (opacityValue === undefined) {
|
|
10
|
-
return `rgb(var(${variable}))`;
|
|
11
|
-
}
|
|
12
|
-
return `rgb(var(${variable}) / ${opacityValue})`;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
7
|
|
|
16
8
|
function createColorSet(colorName) {
|
|
17
9
|
return {
|
|
18
|
-
50:
|
|
19
|
-
100:
|
|
20
|
-
200:
|
|
21
|
-
300:
|
|
22
|
-
400:
|
|
23
|
-
500:
|
|
24
|
-
600:
|
|
25
|
-
700:
|
|
26
|
-
800:
|
|
27
|
-
900:
|
|
10
|
+
50: `rgb(var(--color-${colorName}-50) / <alpha-value>)`,
|
|
11
|
+
100: `rgb(var(--color-${colorName}-100) / <alpha-value>)`,
|
|
12
|
+
200: `rgb(var(--color-${colorName}-200) / <alpha-value>)`,
|
|
13
|
+
300: `rgb(var(--color-${colorName}-300) / <alpha-value>)`,
|
|
14
|
+
400: `rgb(var(--color-${colorName}-400) / <alpha-value>)`,
|
|
15
|
+
500: `rgb(var(--color-${colorName}-500) / <alpha-value>)`,
|
|
16
|
+
600: `rgb(var(--color-${colorName}-600) / <alpha-value>)`,
|
|
17
|
+
700: `rgb(var(--color-${colorName}-700) / <alpha-value>)`,
|
|
18
|
+
800: `rgb(var(--color-${colorName}-800) / <alpha-value>)`,
|
|
19
|
+
900: `rgb(var(--color-${colorName}-900) / <alpha-value>)`
|
|
28
20
|
};
|
|
29
21
|
}
|
|
30
22
|
|
package/themes/theme-crimson.css
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
--theme-font-color-dark: var(--color-surface-50);
|
|
12
12
|
--theme-rounded-base: 24px;
|
|
13
13
|
--theme-rounded-container: 24px;
|
|
14
|
+
/* On Colors */
|
|
15
|
+
--on-primary: #fff;
|
|
16
|
+
--on-accent: #fff;
|
|
17
|
+
--on-tertiary: #000;
|
|
18
|
+
--on-warning: #fff;
|
|
19
|
+
--on-surface: #fff;
|
|
14
20
|
/* =~= Theme Colors | Hex =~= */
|
|
15
21
|
/* primary | #d4161d */
|
|
16
22
|
--color-primary-50: 254 246 246; /* ⬅ #fef6f6 */
|
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
--theme-font-color-dark: var(--color-surface-50);
|
|
15
15
|
--theme-rounded-base: 4px;
|
|
16
16
|
--theme-rounded-container: 4px;
|
|
17
|
+
/* On Colors */
|
|
18
|
+
--on-primary: #fff;
|
|
19
|
+
--on-accent: #000;
|
|
20
|
+
--on-tertiary: #000;
|
|
21
|
+
--on-warning: #fff;
|
|
22
|
+
--on-surface: #fff;
|
|
17
23
|
/* =~= Theme Colors | Hex =~= */
|
|
18
24
|
/* primary | #744aa1 */
|
|
19
25
|
--color-primary-50: 250 248 252; /* ⬅ #faf8fc */
|
|
@@ -74,6 +80,12 @@
|
|
|
74
80
|
|
|
75
81
|
/* Dark Mode Overrides */
|
|
76
82
|
.dark body {
|
|
83
|
+
/* On Colors */
|
|
84
|
+
--on-primary: #000;
|
|
85
|
+
--on-accent: #fff;
|
|
86
|
+
--on-tertiary: #000;
|
|
87
|
+
--on-warning: #fff;
|
|
88
|
+
--on-surface: #fff;
|
|
77
89
|
/* primary | #e7c504 */
|
|
78
90
|
--color-primary-50: 255 253 245; /* ⬅ #fffdf5 */
|
|
79
91
|
--color-primary-100: 255 251 230; /* ⬅ #fffbe6 */
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
--theme-font-color-dark: 255 255 255;
|
|
14
14
|
--theme-rounded-base: 0px;
|
|
15
15
|
--theme-rounded-container: 0px;
|
|
16
|
+
/* On Colors */
|
|
17
|
+
--on-primary: #fff;
|
|
18
|
+
--on-accent: #fff;
|
|
19
|
+
--on-tertiary: #000;
|
|
20
|
+
--on-warning: #fff;
|
|
21
|
+
--on-surface: #fff;
|
|
16
22
|
/* =~= Theme Colors | Hex =~= */
|
|
17
23
|
/* primary | #6376A1 */
|
|
18
24
|
--color-primary-50: 245 247 249;
|
package/themes/theme-modern.css
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
--theme-font-color-dark: var(--color-tertiary-50);
|
|
11
11
|
--theme-rounded-base: 9999px;
|
|
12
12
|
--theme-rounded-container: 24px;
|
|
13
|
+
/* On Colors */
|
|
14
|
+
--on-primary: #fff;
|
|
15
|
+
--on-accent: #000;
|
|
16
|
+
--on-tertiary: #000;
|
|
17
|
+
--on-warning: #fff;
|
|
18
|
+
--on-surface: #fff;
|
|
13
19
|
/* =~= Theme Colors | Tailwind =~= */
|
|
14
20
|
/* pink | #ec4899 */
|
|
15
21
|
--color-primary-50: 253 242 248; /* ⬅ #fdf2f8 */
|
package/themes/theme-rocket.css
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
--theme-font-color-dark: var(--color-primary-100);
|
|
13
13
|
--theme-rounded-base: 0px;
|
|
14
14
|
--theme-rounded-container: 0px;
|
|
15
|
+
/* On Colors */
|
|
16
|
+
--on-primary: #000;
|
|
17
|
+
--on-accent: #fff;
|
|
18
|
+
--on-tertiary: #fff;
|
|
19
|
+
--on-warning: #fff;
|
|
20
|
+
--on-surface: #fff;
|
|
15
21
|
/* =~= Theme Colors | Tailwind =~= */
|
|
16
22
|
/* cyan | #06b6d4 */
|
|
17
23
|
--color-primary-50: 236 254 255; /* ⬅ #ecfeff */
|
package/themes/theme-sahara.css
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
--theme-font-color-dark: var(--color-primary-100);
|
|
13
13
|
--theme-rounded-base: 9999px;
|
|
14
14
|
--theme-rounded-container: 24px;
|
|
15
|
+
/* On Colors */
|
|
16
|
+
--on-primary: #000;
|
|
17
|
+
--on-accent: #000;
|
|
18
|
+
--on-tertiary: #000;
|
|
19
|
+
--on-warning: #000;
|
|
20
|
+
--on-surface: #fff;
|
|
15
21
|
/* =~= Theme Colors | Tailwind =~= */
|
|
16
22
|
/* yellow | #eab308 */
|
|
17
23
|
--color-primary-50: 254 252 232; /* ⬅ #fefce8 */
|
package/themes/theme-seafoam.css
CHANGED
|
@@ -5,12 +5,18 @@
|
|
|
5
5
|
/* =~= Theme Styles =~= */
|
|
6
6
|
--theme-border-base: 5px;
|
|
7
7
|
--theme-font-family-heading: 'Playfair Display', serif;
|
|
8
|
-
--theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
9
|
-
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
8
|
+
--theme-font-family-base: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
9
|
+
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
10
10
|
--theme-font-color-base: var(--color-surface-700);
|
|
11
11
|
--theme-font-color-dark: var(--color-accent-100);
|
|
12
12
|
--theme-rounded-base: 16px;
|
|
13
13
|
--theme-rounded-container: 16px;
|
|
14
|
+
/* On Colors */
|
|
15
|
+
--on-primary: #000;
|
|
16
|
+
--on-accent: #000;
|
|
17
|
+
--on-tertiary: #fff;
|
|
18
|
+
--on-warning: #fff;
|
|
19
|
+
--on-surface: #fff;
|
|
14
20
|
/* =~= Theme Colors | Tailwind =~= */
|
|
15
21
|
/* teal | #14b8a6 */
|
|
16
22
|
--color-primary-50: 240 253 250; /* ⬅ #f0fdfa */
|
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
/* =~= Theme Styles =~= */
|
|
6
6
|
--theme-border-base: 1px;
|
|
7
7
|
--theme-font-family-heading: 'Lato', system-ui, sans-serif;
|
|
8
|
-
--theme-font-family-
|
|
8
|
+
--theme-font-family-base: system-ui, sans-serif;
|
|
9
9
|
--theme-font-color-base: var(--color-surface-900);
|
|
10
10
|
--theme-font-color-dark: var(--color-surface-50);
|
|
11
11
|
--theme-rounded-base: 9999px;
|
|
12
12
|
--theme-rounded-container: 8px;
|
|
13
|
+
/* On Colors */
|
|
14
|
+
--on-primary: #000;
|
|
15
|
+
--on-accent: #fff;
|
|
16
|
+
--on-tertiary: #000;
|
|
17
|
+
--on-warning: #fff;
|
|
18
|
+
--on-surface: #fff;
|
|
13
19
|
/* =~= Theme Colors | Tailwind =~= */
|
|
14
20
|
/* primary | #0FBA81 */
|
|
15
21
|
--color-primary-50: 104 243 197;
|
package/themes/theme-vintage.css
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
--theme-font-color-dark: var(--color-primary-100);
|
|
13
13
|
--theme-rounded-base: 2px;
|
|
14
14
|
--theme-rounded-container: 4px;
|
|
15
|
+
/* On Colors */
|
|
16
|
+
--on-primary: #000;
|
|
17
|
+
--on-accent: #000;
|
|
18
|
+
--on-tertiary: #000;
|
|
19
|
+
--on-warning: #fff;
|
|
20
|
+
--on-surface: #fff;
|
|
15
21
|
/* =~= Theme Colors | Tailwind =~= */
|
|
16
22
|
/* amber | #f59e0b */
|
|
17
23
|
--color-primary-50: 255 251 235; /* ⬅ #fffbeb */
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { DataTableModel } from './types';
|
|
1
|
+
import type { DataTableModel, DataTableOptions } from './types';
|
|
3
2
|
export * from './types';
|
|
4
3
|
export * from './actions';
|
|
4
|
+
/** Creates the writeable store for the data table */
|
|
5
|
+
export declare function createDataTableStore<T extends Record<PropertyKey, any>>(source: T[], options?: DataTableOptions<T>): {
|
|
6
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<DataTableModel<T>>, invalidate?: ((value?: DataTableModel<T> | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
|
|
7
|
+
set: (this: void, value: DataTableModel<T>) => void;
|
|
8
|
+
/** Sets a new data source while maintaining the state of the original source */
|
|
9
|
+
updateSource: (data: T[]) => void;
|
|
10
|
+
/** Triggered by the "select all" checkbox to toggle all row selection. */
|
|
11
|
+
selectAll: (checked: boolean) => void;
|
|
12
|
+
/** Allows you to dynamically pre-select rows on-demand. */
|
|
13
|
+
select: (key: keyof T, valuesArr: unknown[]) => void;
|
|
14
|
+
/** Listens for clicks to a table heading with `data-sort` attribute. Updates `$dataTableModel.sort`. */
|
|
15
|
+
sort: (event: Event) => void;
|
|
16
|
+
};
|
|
5
17
|
/** Listens for changes to `$dataTableModel` and triggers: search, selection, sort, and pagination. */
|
|
6
|
-
export declare function dataTableHandler(
|
|
7
|
-
/** A utility method for updating a select store value. */
|
|
8
|
-
export declare function dataTableStorePut(store: Writable<DataTableModel>, key: string, value: unknown): void;
|
|
9
|
-
/** Allows you to dynamically pre-select rows on-demand. */
|
|
10
|
-
export declare function dataTableSelect(store: Writable<DataTableModel>, key: string, valuesArr: any): void;
|
|
11
|
-
/** Triggered by the "select all" checkbox to toggle all row selection. */
|
|
12
|
-
export declare function dataTableSelectAll(event: any, store: Writable<DataTableModel>): void;
|
|
13
|
-
/** Listens for clicks to a table heading with `data-sort` attribute. Updates `$dataTableModel.sort`. */
|
|
14
|
-
export declare function dataTableSort(event: any, store: Writable<DataTableModel>): void;
|
|
18
|
+
export declare function dataTableHandler<T extends Record<PropertyKey, any>>(model: DataTableModel<T>): void;
|
|
@@ -1,77 +1,104 @@
|
|
|
1
1
|
// Data Table Utilities
|
|
2
2
|
// A set of utility features for local template-driven data tables.
|
|
3
|
-
import {
|
|
3
|
+
import { writable } from 'svelte/store';
|
|
4
4
|
// Exports
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './actions';
|
|
7
|
+
/** Creates the writeable store for the data table */
|
|
8
|
+
export function createDataTableStore(source, options = {}) {
|
|
9
|
+
// Creates a new source that also adds the `dataTableChecked` property to each row object
|
|
10
|
+
const modifiedList = source.map((rowObj) => ({ ...rowObj, dataTableChecked: false }));
|
|
11
|
+
// Generate the writable
|
|
12
|
+
const { subscribe, set, update } = writable({
|
|
13
|
+
source,
|
|
14
|
+
base: modifiedList,
|
|
15
|
+
filtered: modifiedList,
|
|
16
|
+
sortState: { lastKey: '', asc: true },
|
|
17
|
+
selection: [],
|
|
18
|
+
search: options.search ?? '',
|
|
19
|
+
sort: options.sort ?? '',
|
|
20
|
+
pagination: options.pagination
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
subscribe,
|
|
24
|
+
set,
|
|
25
|
+
/** Sets a new data source while maintaining the state of the original source */
|
|
26
|
+
updateSource: (data) => update((model) => {
|
|
27
|
+
model.source = data;
|
|
28
|
+
model.base = data.map((row, i) => {
|
|
29
|
+
return { ...row, dataTableChecked: model.base[i]?.dataTableChecked ?? false };
|
|
30
|
+
});
|
|
31
|
+
return { ...model, filtered: model.base };
|
|
32
|
+
}),
|
|
33
|
+
/** Triggered by the "select all" checkbox to toggle all row selection. */
|
|
34
|
+
selectAll: (checked) => {
|
|
35
|
+
update((model) => {
|
|
36
|
+
// checks/unchecks all of the rows
|
|
37
|
+
model.base.forEach((row) => {
|
|
38
|
+
row.dataTableChecked = checked;
|
|
39
|
+
return row;
|
|
40
|
+
});
|
|
41
|
+
return model;
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
/** Allows you to dynamically pre-select rows on-demand. */
|
|
45
|
+
select: (key, valuesArr) => {
|
|
46
|
+
update((model) => {
|
|
47
|
+
model.filtered.map((row) => {
|
|
48
|
+
if (valuesArr.includes(row[key]))
|
|
49
|
+
row.dataTableChecked = true;
|
|
50
|
+
return row;
|
|
51
|
+
});
|
|
52
|
+
return model;
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
/** Listens for clicks to a table heading with `data-sort` attribute. Updates `$dataTableModel.sort`. */
|
|
56
|
+
sort: (event) => {
|
|
57
|
+
update((model) => {
|
|
58
|
+
if (!(event.target instanceof Element))
|
|
59
|
+
return model;
|
|
60
|
+
const newSortKey = event.target.getAttribute('data-sort');
|
|
61
|
+
// If same key used repeated, toggle asc/dsc order
|
|
62
|
+
if (newSortKey !== '' && newSortKey === model.sortState.lastKey)
|
|
63
|
+
model.sortState.asc = !model.sortState.asc;
|
|
64
|
+
// Cache the last key used
|
|
65
|
+
model.sortState.lastKey = newSortKey;
|
|
66
|
+
// Update sort key
|
|
67
|
+
model.sort = newSortKey ?? '';
|
|
68
|
+
return model;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
7
73
|
// Data Table Handler
|
|
8
74
|
/** Listens for changes to `$dataTableModel` and triggers: search, selection, sort, and pagination. */
|
|
9
|
-
export function dataTableHandler(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
selectionHandler(store);
|
|
15
|
-
sortHandler(store);
|
|
16
|
-
paginationHandler(store);
|
|
17
|
-
}
|
|
18
|
-
// Utilities ---
|
|
19
|
-
/** A utility method for updating a select store value. */
|
|
20
|
-
export function dataTableStorePut(store, key, value) {
|
|
21
|
-
let newStore = get(store);
|
|
22
|
-
newStore = { ...newStore, [key]: value };
|
|
23
|
-
store.set(newStore);
|
|
75
|
+
export function dataTableHandler(model) {
|
|
76
|
+
searchHandler(model);
|
|
77
|
+
selectionHandler(model);
|
|
78
|
+
sortHandler(model);
|
|
79
|
+
paginationHandler(model);
|
|
24
80
|
}
|
|
25
81
|
// Search ---
|
|
26
82
|
function searchHandler(store) {
|
|
27
|
-
store.filtered = store.
|
|
83
|
+
store.filtered = store.base.filter((rowObj) => {
|
|
28
84
|
const formattedSearchTerm = store.search?.toLowerCase() || '';
|
|
29
85
|
return Object.values(rowObj).join(' ').toLowerCase().includes(formattedSearchTerm);
|
|
30
86
|
});
|
|
31
87
|
}
|
|
32
88
|
// Selection ---
|
|
33
89
|
function selectionHandler(store) {
|
|
34
|
-
store.selection = store.
|
|
35
|
-
}
|
|
36
|
-
/** Allows you to dynamically pre-select rows on-demand. */
|
|
37
|
-
export function dataTableSelect(store, key, valuesArr) {
|
|
38
|
-
get(store).filtered.map((row) => {
|
|
39
|
-
if (valuesArr.includes(row[key]))
|
|
40
|
-
row.dataTableChecked = true;
|
|
41
|
-
return row;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/** Triggered by the "select all" checkbox to toggle all row selection. */
|
|
45
|
-
export function dataTableSelectAll(event, store) {
|
|
46
|
-
const isAllChecked = event.target.checked;
|
|
47
|
-
const storeFiltered = get(store).source.forEach((row) => (row.dataTableChecked = isAllChecked));
|
|
48
|
-
dataTableStorePut(store, 'filtered', storeFiltered);
|
|
90
|
+
store.selection = store.base.filter((row) => row.dataTableChecked === true); // ? should this be filtered by source or filter?
|
|
49
91
|
}
|
|
50
92
|
// Sort ---
|
|
51
|
-
const sortState = { lastKey: '', asc: true };
|
|
52
|
-
/** Listens for clicks to a table heading with `data-sort` attribute. Updates `$dataTableModel.sort`. */
|
|
53
|
-
export function dataTableSort(event, store) {
|
|
54
|
-
if (!(event.target instanceof Element))
|
|
55
|
-
return;
|
|
56
|
-
const newSortKey = event.target.getAttribute('data-sort');
|
|
57
|
-
// If same key used repeated, toggle asc/dsc order
|
|
58
|
-
if (newSortKey !== '' && newSortKey === sortState.lastKey)
|
|
59
|
-
sortState.asc = !sortState.asc;
|
|
60
|
-
// Cache the last key used
|
|
61
|
-
sortState.lastKey = newSortKey;
|
|
62
|
-
// Update store
|
|
63
|
-
if (newSortKey)
|
|
64
|
-
dataTableStorePut(store, 'sort', newSortKey);
|
|
65
|
-
}
|
|
66
93
|
function sortHandler(store) {
|
|
67
94
|
if (!store.sort)
|
|
68
95
|
return;
|
|
69
96
|
// Sort order based on current sortState.asc value
|
|
70
|
-
sortState.asc ? sortOrder('asc', store) : sortOrder('dsc', store);
|
|
97
|
+
store.sortState.asc ? sortOrder('asc', store) : sortOrder('dsc', store);
|
|
71
98
|
}
|
|
72
99
|
function sortOrder(order, store) {
|
|
73
100
|
const key = store.sort;
|
|
74
|
-
store.filtered.sort((x, y) => {
|
|
101
|
+
store.filtered = store.base.sort((x, y) => {
|
|
75
102
|
// If descending, swap x/y
|
|
76
103
|
if (order === 'dsc')
|
|
77
104
|
[x, y] = [y, x];
|
|
@@ -86,13 +113,23 @@ function sortOrder(order, store) {
|
|
|
86
113
|
}
|
|
87
114
|
// Pagination ---
|
|
88
115
|
function paginationHandler(store) {
|
|
89
|
-
// store.sort = ''; // reset
|
|
90
116
|
if (store.pagination) {
|
|
91
117
|
// Slice for Pagination
|
|
92
|
-
|
|
118
|
+
const filtered = store.base.slice(store.pagination.offset * store.pagination.limit, // start
|
|
93
119
|
store.pagination.offset * store.pagination.limit + store.pagination.limit // end
|
|
94
120
|
);
|
|
95
|
-
//
|
|
96
|
-
store.
|
|
121
|
+
// filter by search if currently searching
|
|
122
|
+
if (store.search !== '') {
|
|
123
|
+
store.filtered = store.filtered.slice(0, store.pagination.limit);
|
|
124
|
+
// Set Current Size
|
|
125
|
+
store.pagination.size = store.filtered.length;
|
|
126
|
+
// Set the current page to the first page
|
|
127
|
+
store.pagination.offset = 0;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
store.filtered = filtered;
|
|
131
|
+
// Set Current Size
|
|
132
|
+
store.pagination.size = store.base.length;
|
|
133
|
+
}
|
|
97
134
|
}
|
|
98
135
|
}
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import type { PaginationSettings } from '../../components/Paginator/types';
|
|
2
|
-
export interface DataTableModel {
|
|
3
|
-
/** The original
|
|
4
|
-
source:
|
|
2
|
+
export interface DataTableModel<T extends Record<PropertyKey, unknown>> {
|
|
3
|
+
/** The original source data. */
|
|
4
|
+
source: T[];
|
|
5
|
+
/** The unfiltered, modified source data */
|
|
6
|
+
base: Data<T>;
|
|
5
7
|
/** The filtered source data, shown in UI. */
|
|
6
|
-
filtered:
|
|
8
|
+
filtered: Data<T>;
|
|
7
9
|
/** An array of selected row objects. */
|
|
8
|
-
selection
|
|
10
|
+
selection: Data<T>;
|
|
11
|
+
/** The current search term. */
|
|
12
|
+
search: string;
|
|
13
|
+
/** The current sort key. */
|
|
14
|
+
sort: keyof T | '';
|
|
15
|
+
/** The current state of the sort key. */
|
|
16
|
+
sortState: {
|
|
17
|
+
lastKey: keyof T | '' | null;
|
|
18
|
+
asc: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** The Paginator component settings. */
|
|
21
|
+
pagination?: PaginationSettings;
|
|
22
|
+
}
|
|
23
|
+
export interface DataTableOptions<T> {
|
|
9
24
|
/** The current search term. */
|
|
10
25
|
search?: string;
|
|
11
26
|
/** The current sort key. */
|
|
12
|
-
sort
|
|
27
|
+
sort?: keyof T | '';
|
|
13
28
|
/** The Paginator component settings. */
|
|
14
29
|
pagination?: PaginationSettings;
|
|
15
30
|
}
|
|
31
|
+
export type Data<T> = (T & {
|
|
32
|
+
dataTableChecked: boolean;
|
|
33
|
+
})[];
|