@skeletonlabs/skeleton 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/actions/Clipboard/clipboard.d.ts +4 -0
- package/actions/Clipboard/clipboard.js +37 -0
- package/actions/Filters/filter.d.ts +3 -0
- package/actions/Filters/filter.js +23 -0
- package/actions/Filters/svg-filters/Apollo.svelte +13 -0
- package/actions/Filters/svg-filters/Apollo.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/BlueNight.svelte +12 -0
- package/actions/Filters/svg-filters/BlueNight.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/Emerald.svelte +23 -0
- package/actions/Filters/svg-filters/Emerald.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/GreenFall.svelte +18 -0
- package/actions/Filters/svg-filters/GreenFall.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/Noir.svelte +11 -0
- package/actions/Filters/svg-filters/Noir.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/NoirLight.svelte +10 -0
- package/actions/Filters/svg-filters/NoirLight.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/Rustic.svelte +14 -0
- package/actions/Filters/svg-filters/Rustic.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/Summer84.svelte +12 -0
- package/actions/Filters/svg-filters/Summer84.svelte.d.ts +19 -0
- package/actions/Filters/svg-filters/XPro.svelte +12 -0
- package/actions/Filters/svg-filters/XPro.svelte.d.ts +19 -0
- package/actions/FocusTrap/focusTrap.d.ts +4 -0
- package/actions/FocusTrap/focusTrap.js +42 -0
- package/components/Accordion/AccordionGroup.svelte +47 -0
- package/components/Accordion/AccordionGroup.svelte.d.ts +24 -0
- package/components/Accordion/AccordionItem.svelte +70 -0
- package/components/Accordion/AccordionItem.svelte.d.ts +35 -0
- package/components/Alert/Alert.svelte +65 -0
- package/components/Alert/Alert.svelte.d.ts +30 -0
- package/components/AppBar/AppBar.svelte +54 -0
- package/components/AppBar/AppBar.svelte.d.ts +30 -0
- package/components/AppRail/AppRail.svelte +48 -0
- package/components/AppRail/AppRail.svelte.d.ts +31 -0
- package/components/AppRail/AppRailTile.svelte +51 -0
- package/components/AppRail/AppRailTile.svelte.d.ts +33 -0
- package/components/AppShell/AppShell.svelte +80 -0
- package/components/AppShell/AppShell.svelte.d.ts +31 -0
- package/components/Avatar/Avatar.svelte +46 -0
- package/components/Avatar/Avatar.svelte.d.ts +32 -0
- package/components/Breadcrumb/Breadcrumb.svelte +24 -0
- package/components/Breadcrumb/Breadcrumb.svelte.d.ts +21 -0
- package/components/Breadcrumb/Crumb.svelte +29 -0
- package/components/Breadcrumb/Crumb.svelte.d.ts +21 -0
- package/components/ConicGradient/ConicGradient.svelte +80 -0
- package/components/ConicGradient/ConicGradient.svelte.d.ts +24 -0
- package/components/ConicGradient/types.d.ts +10 -0
- package/components/ConicGradient/types.js +2 -0
- package/components/Divider/Divider.svelte +21 -0
- package/components/Divider/Divider.svelte.d.ts +22 -0
- package/components/FileButton/FileButton.svelte +25 -0
- package/components/FileButton/FileButton.svelte.d.ts +22 -0
- package/components/FileDropzone/FileDropzone.svelte +83 -0
- package/components/FileDropzone/FileDropzone.svelte.d.ts +27 -0
- package/components/GradientHeading/GradientHeading.svelte +21 -0
- package/components/GradientHeading/GradientHeading.svelte.d.ts +22 -0
- package/components/ListBox/ListBox.svelte +54 -0
- package/components/ListBox/ListBox.svelte.d.ts +30 -0
- package/components/ListBox/ListBoxItem.svelte +87 -0
- package/components/ListBox/ListBoxItem.svelte.d.ts +30 -0
- package/components/Paginator/Paginator.svelte +62 -0
- package/components/Paginator/Paginator.svelte.d.ts +25 -0
- package/components/Paginator/types.d.ts +10 -0
- package/components/Paginator/types.js +2 -0
- package/components/ProgressBar/ProgressBar.svelte +57 -0
- package/components/ProgressBar/ProgressBar.svelte.d.ts +23 -0
- package/components/ProgressRadial/ProgressRadial.svelte +81 -0
- package/components/ProgressRadial/ProgressRadial.svelte.d.ts +25 -0
- package/components/Radio/RadioGroup.svelte +45 -0
- package/components/Radio/RadioGroup.svelte.d.ts +30 -0
- package/components/Radio/RadioItem.svelte +40 -0
- package/components/Radio/RadioItem.svelte.d.ts +29 -0
- package/components/RangeSlider/RangeSlider.svelte +95 -0
- package/components/RangeSlider/RangeSlider.svelte.d.ts +32 -0
- package/components/SlideToggle/SlideToggle.svelte +77 -0
- package/components/SlideToggle/SlideToggle.svelte.d.ts +31 -0
- package/components/Stepper/Step.svelte +94 -0
- package/components/Stepper/Step.svelte.d.ts +31 -0
- package/components/Stepper/Stepper.svelte +42 -0
- package/components/Stepper/Stepper.svelte.d.ts +27 -0
- package/components/SvgIcon/SvgIcon.svelte +45 -0
- package/components/SvgIcon/SvgIcon.svelte.d.ts +26 -0
- package/components/SvgIcon/icons.d.ts +1 -0
- package/components/SvgIcon/icons.js +171 -0
- package/components/Tab/Tab.svelte +54 -0
- package/components/Tab/Tab.svelte.d.ts +32 -0
- package/components/Tab/TabGroup.svelte +69 -0
- package/components/Tab/TabGroup.svelte.d.ts +30 -0
- package/components/Table/Table.svelte +102 -0
- package/components/Table/Table.svelte.d.ts +27 -0
- package/components/Table/types.d.ts +10 -0
- package/components/Table/types.js +1 -0
- package/components/Table/utils.d.ts +7 -0
- package/components/Table/utils.js +33 -0
- package/index.d.ts +59 -0
- package/index.js +68 -0
- package/package.json +147 -0
- package/styles/all.css +20 -0
- package/styles/core.css +53 -0
- package/styles/elements/badges.css +29 -0
- package/styles/elements/buttons.css +162 -0
- package/styles/elements/cards.css +34 -0
- package/styles/elements/lists.css +47 -0
- package/styles/elements/logo-clouds.css +31 -0
- package/styles/elements/menus.css +26 -0
- package/styles/elements/placeholders.css +17 -0
- package/styles/elements/tables.css +97 -0
- package/styles/elements/tooltips.css +83 -0
- package/styles/elements.css +15 -0
- package/styles/forms.css +154 -0
- package/styles/highlight-js.css +116 -0
- package/styles/tailwind.css +12 -0
- package/styles/tokens.css +171 -0
- package/styles/typography.css +115 -0
- package/tailwind/colors.d.ts +13 -0
- package/tailwind/colors.js +335 -0
- package/tailwind/theme.cjs +45 -0
- package/tailwind/theme.d.cts +5 -0
- package/themes/legacy/theme-skeleton.css +93 -0
- package/themes/theme-crimson.css +70 -0
- package/themes/theme-gold-nouveau.css +142 -0
- package/themes/theme-hamlindigo.css +82 -0
- package/themes/theme-modern.css +78 -0
- package/themes/theme-rocket.css +80 -0
- package/themes/theme-sahara.css +83 -0
- package/themes/theme-seafoam.css +81 -0
- package/themes/theme-seasonal.css +69 -0
- package/themes/theme-skeleton.css +99 -0
- package/themes/theme-vintage.css +80 -0
- package/utilities/CodeBlock/CodeBlock.svelte +63 -0
- package/utilities/CodeBlock/CodeBlock.svelte.d.ts +23 -0
- package/utilities/CodeBlock/stores.d.ts +2 -0
- package/utilities/CodeBlock/stores.js +3 -0
- package/utilities/DataTable/DataTable.d.ts +14 -0
- package/utilities/DataTable/DataTable.js +98 -0
- package/utilities/DataTable/actions.d.ts +8 -0
- package/utilities/DataTable/actions.js +114 -0
- package/utilities/DataTable/types.d.ts +15 -0
- package/utilities/DataTable/types.js +2 -0
- package/utilities/Drawer/Drawer.svelte +135 -0
- package/utilities/Drawer/Drawer.svelte.d.ts +36 -0
- package/utilities/LightSwitch/LightSwitch.svelte +70 -0
- package/utilities/LightSwitch/LightSwitch.svelte.d.ts +16 -0
- package/utilities/LightSwitch/stores.d.ts +3 -0
- package/utilities/LightSwitch/stores.js +5 -0
- package/utilities/LocalStorageStore/LocalStorageStore.d.ts +10 -0
- package/utilities/LocalStorageStore/LocalStorageStore.js +44 -0
- package/utilities/Menu/menu.d.ts +18 -0
- package/utilities/Menu/menu.js +100 -0
- package/utilities/Modal/Modal.d.ts +1 -0
- package/utilities/Modal/Modal.js +44 -0
- package/utilities/Modal/Modal.svelte +182 -0
- package/utilities/Modal/Modal.svelte.d.ts +33 -0
- package/utilities/Modal/examples/ModalExampleEmbed.svelte +20 -0
- package/utilities/Modal/examples/ModalExampleEmbed.svelte.d.ts +17 -0
- package/utilities/Modal/examples/ModalExampleForm.svelte +46 -0
- package/utilities/Modal/examples/ModalExampleForm.svelte.d.ts +17 -0
- package/utilities/Modal/examples/ModalExampleList.svelte +32 -0
- package/utilities/Modal/examples/ModalExampleList.svelte.d.ts +17 -0
- package/utilities/Modal/stores.d.ts +1 -0
- package/utilities/Modal/stores.js +22 -0
- package/utilities/Modal/types.d.ts +26 -0
- package/utilities/Modal/types.js +2 -0
- package/utilities/Toast/Toast.svelte +117 -0
- package/utilities/Toast/Toast.svelte.d.ts +28 -0
- package/utilities/Toast/stores.d.ts +10 -0
- package/utilities/Toast/stores.js +44 -0
- package/utilities/Toast/types.d.ts +21 -0
- package/utilities/Toast/types.js +2 -0
- package/utilities/Tooltip/tooltip.d.ts +35 -0
- package/utilities/Tooltip/tooltip.js +94 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* https://fonts.google.com/specimen/Lato?query=lato¬o.query=Abril */
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap');
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
/* =~= Theme Styles =~= */
|
|
6
|
+
--theme-border-base: 1px;
|
|
7
|
+
--theme-font-family-heading: 'Lato', system-ui, sans-serif;
|
|
8
|
+
--theme-font-family-body: system-ui, sans-serif;
|
|
9
|
+
--theme-font-color-base: var(--color-surface-900);
|
|
10
|
+
--theme-font-color-dark: var(--color-surface-50);
|
|
11
|
+
--theme-rounded-base: 9999px;
|
|
12
|
+
--theme-rounded-container: 8px;
|
|
13
|
+
/* =~= Theme Colors | Tailwind =~= */
|
|
14
|
+
/* primary | #0FBA81 */
|
|
15
|
+
--color-primary-50: 104 243 197;
|
|
16
|
+
--color-primary-100: 71 240 184;
|
|
17
|
+
--color-primary-200: 19 231 160;
|
|
18
|
+
--color-primary-300: 17 217 151;
|
|
19
|
+
--color-primary-400: 16 203 141;
|
|
20
|
+
--color-primary-500: 15 186 129;
|
|
21
|
+
--color-primary-600: 13 165 115;
|
|
22
|
+
--color-primary-700: 12 146 101;
|
|
23
|
+
--color-primary-800: 10 123 85;
|
|
24
|
+
--color-primary-900: 7 85 59;
|
|
25
|
+
/* accent | #4F46E5 */
|
|
26
|
+
--color-accent-50: 216 215 249;
|
|
27
|
+
--color-accent-100: 204 201 247;
|
|
28
|
+
--color-accent-200: 187 183 245;
|
|
29
|
+
--color-accent-300: 157 152 241;
|
|
30
|
+
--color-accent-400: 127 121 236;
|
|
31
|
+
--color-accent-500: 79 70 229;
|
|
32
|
+
--color-accent-600: 62 54 227;
|
|
33
|
+
--color-accent-700: 41 31 224;
|
|
34
|
+
--color-accent-800: 35 27 192;
|
|
35
|
+
--color-accent-900: 22 17 121;
|
|
36
|
+
/* tertiary | #EAB309 */
|
|
37
|
+
--color-tertiary-50: 250 218 122;
|
|
38
|
+
--color-tertiary-100: 250 215 113;
|
|
39
|
+
--color-tertiary-200: 248 207 83;
|
|
40
|
+
--color-tertiary-300: 247 197 49;
|
|
41
|
+
--color-tertiary-400: 246 187 9;
|
|
42
|
+
--color-tertiary-500: 234 179 9;
|
|
43
|
+
--color-tertiary-600: 211 160 8;
|
|
44
|
+
--color-tertiary-700: 187 142 7;
|
|
45
|
+
--color-tertiary-800: 157 119 6;
|
|
46
|
+
--color-tertiary-900: 113 86 4;
|
|
47
|
+
/* warning | #D41976 */
|
|
48
|
+
--color-warning-50: 249 205 227;
|
|
49
|
+
--color-warning-100: 247 191 219;
|
|
50
|
+
--color-warning-200: 244 164 204;
|
|
51
|
+
--color-warning-300: 241 136 189;
|
|
52
|
+
--color-warning-400: 236 91 163;
|
|
53
|
+
--color-warning-500: 212 25 118;
|
|
54
|
+
--color-warning-600: 192 23 107;
|
|
55
|
+
--color-warning-700: 173 20 97;
|
|
56
|
+
--color-warning-800: 137 16 77;
|
|
57
|
+
--color-warning-900: 96 11 54;
|
|
58
|
+
/* surface | #1C2237 */
|
|
59
|
+
--color-surface-50: 231 234 243;
|
|
60
|
+
--color-surface-100: 218 222 236;
|
|
61
|
+
--color-surface-200: 191 199 222;
|
|
62
|
+
--color-surface-300: 160 172 207;
|
|
63
|
+
--color-surface-400: 127 142 189;
|
|
64
|
+
--color-surface-500: 73 90 143;
|
|
65
|
+
--color-surface-600: 67 83 132;
|
|
66
|
+
--color-surface-700: 55 68 108;
|
|
67
|
+
--color-surface-800: 45 56 88;
|
|
68
|
+
--color-surface-900: 31 38 61;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Headings */
|
|
72
|
+
[data-theme='skeleton'] h1,
|
|
73
|
+
[data-theme='skeleton'] h2,
|
|
74
|
+
[data-theme='skeleton'] h3,
|
|
75
|
+
[data-theme='skeleton'] h4,
|
|
76
|
+
[data-theme='skeleton'] h5,
|
|
77
|
+
[data-theme='skeleton'] h6 {
|
|
78
|
+
font-weight: bold;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Applied to body with `<body data-theme="skeleton">` */
|
|
82
|
+
/* Created with: https://csshero.org/mesher/ */
|
|
83
|
+
[data-theme='skeleton'] {
|
|
84
|
+
/* prettier-ignore */
|
|
85
|
+
background-image:
|
|
86
|
+
radial-gradient(at 73% 84%, hsla(213,80%,69%,0.18) 0px, transparent 50%),
|
|
87
|
+
radial-gradient(at 16% 79%, hsla(268,79%,73%,0.18) 0px, transparent 50%),
|
|
88
|
+
radial-gradient(at 88% 64%, hsla(290,68%,62%,0.18) 0px, transparent 50%),
|
|
89
|
+
radial-gradient(at 67% 14%, hsla(167,87%,76%,0.18) 0px, transparent 50%),
|
|
90
|
+
radial-gradient(at 70% 75%, hsla(170,71%,68%,0.18) 0px, transparent 50%),
|
|
91
|
+
radial-gradient(at 98% 62%, hsla(244,77%,60%,0.18) 0px, transparent 50%),
|
|
92
|
+
radial-gradient(at 50% 19%, hsla(322,97%,63%,0.18) 0px, transparent 50%);
|
|
93
|
+
}
|
|
94
|
+
.dark [data-theme='skeleton'] {
|
|
95
|
+
/* prettier-ignore */
|
|
96
|
+
background-image:
|
|
97
|
+
radial-gradient(at 36% 0%, hsla(240,73%,56%,0.2) 0px, transparent 50%),
|
|
98
|
+
radial-gradient(at 71% 4%, hsla(330,78%,46%,0.18) 0px, transparent 50%);
|
|
99
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* https://fonts.google.com/specimen/Abril+Fatface?query=Abril+Fatface¬o.query=Abril */
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap');
|
|
3
|
+
/* https://fonts.google.com/noto/specimen/Noto+Sans?query=sans */
|
|
4
|
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100;0,200;0,300;0,400;1,100;1,200;1,300&display=swap');
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
/* =~= Theme Styles =~= */
|
|
8
|
+
--theme-border-base: 1px;
|
|
9
|
+
--theme-font-family-heading: 'Abril Fatface', cursive;
|
|
10
|
+
--theme-font-family-base: 'Noto Sans', sans-serif;
|
|
11
|
+
--theme-font-color-base: var(--color-primary-900);
|
|
12
|
+
--theme-font-color-dark: var(--color-primary-100);
|
|
13
|
+
--theme-rounded-base: 2px;
|
|
14
|
+
--theme-rounded-container: 4px;
|
|
15
|
+
/* =~= Theme Colors | Tailwind =~= */
|
|
16
|
+
/* amber | #f59e0b */
|
|
17
|
+
--color-primary-50: 255 251 235; /* ⬅ #fffbeb */
|
|
18
|
+
--color-primary-100: 254 243 199; /* ⬅ #fef3c7 */
|
|
19
|
+
--color-primary-200: 253 230 138; /* ⬅ #fde68a */
|
|
20
|
+
--color-primary-300: 252 211 77; /* ⬅ #fcd34d */
|
|
21
|
+
--color-primary-400: 251 191 36; /* ⬅ #fbbf24 */
|
|
22
|
+
--color-primary-500: 245 158 11; /* ⬅ #f59e0b */
|
|
23
|
+
--color-primary-600: 217 119 6; /* ⬅ #d97706 */
|
|
24
|
+
--color-primary-700: 180 83 9; /* ⬅ #b45309 */
|
|
25
|
+
--color-primary-800: 146 64 14; /* ⬅ #92400e */
|
|
26
|
+
--color-primary-900: 120 53 15; /* ⬅ #78350f */
|
|
27
|
+
/* green | #22c55e */
|
|
28
|
+
--color-accent-50: 240 253 244; /* ⬅ #f0fdf4 */
|
|
29
|
+
--color-accent-100: 220 252 231; /* ⬅ #dcfce7 */
|
|
30
|
+
--color-accent-200: 187 247 208; /* ⬅ #bbf7d0 */
|
|
31
|
+
--color-accent-300: 134 239 172; /* ⬅ #86efac */
|
|
32
|
+
--color-accent-400: 74 222 128; /* ⬅ #4ade80 */
|
|
33
|
+
--color-accent-500: 34 197 94; /* ⬅ #22c55e */
|
|
34
|
+
--color-accent-600: 22 163 74; /* ⬅ #16a34a */
|
|
35
|
+
--color-accent-700: 21 128 61; /* ⬅ #15803d */
|
|
36
|
+
--color-accent-800: 22 101 52; /* ⬅ #166534 */
|
|
37
|
+
--color-accent-900: 20 83 45; /* ⬅ #14532d */
|
|
38
|
+
/* cyan | #06b6d4 */
|
|
39
|
+
--color-tertiary-50: 236 254 255; /* ⬅ #ecfeff */
|
|
40
|
+
--color-tertiary-100: 207 250 254; /* ⬅ #cffafe */
|
|
41
|
+
--color-tertiary-200: 165 243 252; /* ⬅ #a5f3fc */
|
|
42
|
+
--color-tertiary-300: 103 232 249; /* ⬅ #67e8f9 */
|
|
43
|
+
--color-tertiary-400: 34 211 238; /* ⬅ #22d3ee */
|
|
44
|
+
--color-tertiary-500: 6 182 212; /* ⬅ #06b6d4 */
|
|
45
|
+
--color-tertiary-600: 8 145 178; /* ⬅ #0891b2 */
|
|
46
|
+
--color-tertiary-700: 14 116 144; /* ⬅ #0e7490 */
|
|
47
|
+
--color-tertiary-800: 21 94 117; /* ⬅ #155e75 */
|
|
48
|
+
--color-tertiary-900: 22 78 99; /* ⬅ #164e63 */
|
|
49
|
+
/* red | #ef4444 */
|
|
50
|
+
--color-warning-50: 254 242 242; /* ⬅ #fef2f2 */
|
|
51
|
+
--color-warning-100: 254 226 226; /* ⬅ #fee2e2 */
|
|
52
|
+
--color-warning-200: 254 202 202; /* ⬅ #fecaca */
|
|
53
|
+
--color-warning-300: 252 165 165; /* ⬅ #fca5a5 */
|
|
54
|
+
--color-warning-400: 248 113 113; /* ⬅ #f87171 */
|
|
55
|
+
--color-warning-500: 239 68 68; /* ⬅ #ef4444 */
|
|
56
|
+
--color-warning-600: 220 38 38; /* ⬅ #dc2626 */
|
|
57
|
+
--color-warning-700: 185 28 28; /* ⬅ #b91c1c */
|
|
58
|
+
--color-warning-800: 153 27 27; /* ⬅ #991b1b */
|
|
59
|
+
--color-warning-900: 127 29 29; /* ⬅ #7f1d1d */
|
|
60
|
+
/* stone | #78716c */
|
|
61
|
+
--color-surface-50: 250 250 249; /* ⬅ #fafaf9 */
|
|
62
|
+
--color-surface-100: 245 245 244; /* ⬅ #f5f5f4 */
|
|
63
|
+
--color-surface-200: 231 229 228; /* ⬅ #e7e5e4 */
|
|
64
|
+
--color-surface-300: 214 211 209; /* ⬅ #d6d3d1 */
|
|
65
|
+
--color-surface-400: 168 162 158; /* ⬅ #a8a29e */
|
|
66
|
+
--color-surface-500: 120 113 108; /* ⬅ #78716c */
|
|
67
|
+
--color-surface-600: 87 83 78; /* ⬅ #57534e */
|
|
68
|
+
--color-surface-700: 68 64 60; /* ⬅ #44403c */
|
|
69
|
+
--color-surface-800: 41 37 36; /* ⬅ #292524 */
|
|
70
|
+
--color-surface-900: 28 25 23; /* ⬅ #1c1917 */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[data-theme='vintage'] h1,
|
|
74
|
+
[data-theme='vintage'] h2,
|
|
75
|
+
[data-theme='vintage'] h3,
|
|
76
|
+
[data-theme='vintage'] h4,
|
|
77
|
+
[data-theme='vintage'] h5,
|
|
78
|
+
[data-theme='vintage'] h6 {
|
|
79
|
+
letter-spacing: 1px;
|
|
80
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script>import { storeHighlightJs } from './stores';
|
|
2
|
+
import { clipboard } from '../../actions/Clipboard/clipboard';
|
|
3
|
+
// Props
|
|
4
|
+
/** Sets a language alias for Highlight.js syntax highlighting. */
|
|
5
|
+
export let language = 'plaintext';
|
|
6
|
+
/** Provide the code to render. Be mindful to escape as needed! */
|
|
7
|
+
export let code = '';
|
|
8
|
+
// Props (styles)
|
|
9
|
+
/** Provided classes to set the background color. */
|
|
10
|
+
export let background = 'bg-[#141517]';
|
|
11
|
+
/** Provided classes to set the text size. */
|
|
12
|
+
export let text = 'text-sm';
|
|
13
|
+
/** Provided classes to set the text color. */
|
|
14
|
+
export let color = 'text-white';
|
|
15
|
+
/** Provided classes to set the border radius. */
|
|
16
|
+
export let rounded = 'rounded-container-token';
|
|
17
|
+
/** Provided classes to set the button styles. */
|
|
18
|
+
export let buttonCopy = 'bg-white/5 hover:bg-white/10';
|
|
19
|
+
// Base Classes
|
|
20
|
+
const cBase = 'overflow-hidden shadow';
|
|
21
|
+
const cHeader = 'text-xs uppercase flex justify-between items-center p-2 pl-4';
|
|
22
|
+
const cPre = 'whitespace-pre-wrap break-all p-4 pt-1';
|
|
23
|
+
// Local
|
|
24
|
+
let formatted = false;
|
|
25
|
+
let displayCode = code;
|
|
26
|
+
let copyState = false;
|
|
27
|
+
// Allow shorthand 'js' alias for Javascript
|
|
28
|
+
function languageFormatter(lang) {
|
|
29
|
+
if (lang === 'js')
|
|
30
|
+
return 'javascript';
|
|
31
|
+
return lang;
|
|
32
|
+
}
|
|
33
|
+
// Handle Copy Text
|
|
34
|
+
function onCopyClick() {
|
|
35
|
+
copyState = true;
|
|
36
|
+
// prettier-ignore
|
|
37
|
+
setTimeout(() => { copyState = false; }, 2000);
|
|
38
|
+
}
|
|
39
|
+
// Trigger syntax highlighting if highlight.js is available
|
|
40
|
+
$: if ($storeHighlightJs !== undefined) {
|
|
41
|
+
displayCode = $storeHighlightJs.highlight(code, { language }).value.trim();
|
|
42
|
+
formatted = true;
|
|
43
|
+
}
|
|
44
|
+
// Reactive
|
|
45
|
+
$: classesBase = `${cBase} ${background} ${text} ${color} ${rounded} ${$$props.class ?? ''}`;
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<!-- prettier-ignore -->
|
|
49
|
+
{#if language && code}
|
|
50
|
+
<div class="code-block {classesBase}" data-testid="code-block">
|
|
51
|
+
<!-- Header -->
|
|
52
|
+
<header class="code-block-header {cHeader} {background} sticky top-0">
|
|
53
|
+
<!-- Language -->
|
|
54
|
+
<span class="code-block-language text-white/60">{languageFormatter(language)}</span>
|
|
55
|
+
<!-- Copy Button -->
|
|
56
|
+
<button class="code-block-btn btn btn-sm {buttonCopy}" on:click={onCopyClick} use:clipboard={code}>
|
|
57
|
+
{!copyState ? 'Copy' : 'Copied ✓'}
|
|
58
|
+
</button>
|
|
59
|
+
</header>
|
|
60
|
+
<!-- Pre/Code -->
|
|
61
|
+
<pre class="code-block-pre {cPre}"><code class="code-block-code language-{language}">{#if formatted}{@html displayCode}{:else}{code.trim()}{/if}</code></pre>
|
|
62
|
+
</div>
|
|
63
|
+
{/if}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
language?: string | undefined;
|
|
6
|
+
code?: string | undefined;
|
|
7
|
+
background?: string | undefined;
|
|
8
|
+
text?: string | undefined;
|
|
9
|
+
color?: string | undefined;
|
|
10
|
+
rounded?: string | undefined;
|
|
11
|
+
buttonCopy?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
events: {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {};
|
|
17
|
+
};
|
|
18
|
+
export type CodeBlockProps = typeof __propDef.props;
|
|
19
|
+
export type CodeBlockEvents = typeof __propDef.events;
|
|
20
|
+
export type CodeBlockSlots = typeof __propDef.slots;
|
|
21
|
+
export default class CodeBlock extends SvelteComponentTyped<CodeBlockProps, CodeBlockEvents, CodeBlockSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
import type { DataTableModel } from './types';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './actions';
|
|
5
|
+
/** Listens for changes to `$dataTableModel` and triggers: search, selection, sort, and pagination. */
|
|
6
|
+
export declare function dataTableHandler(store: DataTableModel): void;
|
|
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;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Data Table Utilities
|
|
2
|
+
// A set of utility features for local template-driven data tables.
|
|
3
|
+
import { get } from 'svelte/store';
|
|
4
|
+
// Exports
|
|
5
|
+
export * from './types';
|
|
6
|
+
export * from './actions';
|
|
7
|
+
// Data Table Handler
|
|
8
|
+
/** Listens for changes to `$dataTableModel` and triggers: search, selection, sort, and pagination. */
|
|
9
|
+
export function dataTableHandler(store) {
|
|
10
|
+
// Reset
|
|
11
|
+
store.filtered = store.source;
|
|
12
|
+
// Then
|
|
13
|
+
searchHandler(store);
|
|
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);
|
|
24
|
+
}
|
|
25
|
+
// Search ---
|
|
26
|
+
function searchHandler(store) {
|
|
27
|
+
store.filtered = store.filtered.filter((rowObj) => {
|
|
28
|
+
const formattedSearchTerm = store.search?.toLowerCase() || '';
|
|
29
|
+
return Object.values(rowObj).join(' ').toLowerCase().includes(formattedSearchTerm);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Selection ---
|
|
33
|
+
function selectionHandler(store) {
|
|
34
|
+
store.selection = store.filtered.filter((row) => row.dataTableChecked === true);
|
|
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);
|
|
49
|
+
}
|
|
50
|
+
// 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
|
+
function sortHandler(store) {
|
|
67
|
+
if (!store.sort)
|
|
68
|
+
return;
|
|
69
|
+
// Sort order based on current sortState.asc value
|
|
70
|
+
sortState.asc ? sortOrder('asc', store) : sortOrder('dsc', store);
|
|
71
|
+
}
|
|
72
|
+
function sortOrder(order, store) {
|
|
73
|
+
const key = store.sort;
|
|
74
|
+
store.filtered.sort((x, y) => {
|
|
75
|
+
// If descending, swap x/y
|
|
76
|
+
if (order === 'dsc')
|
|
77
|
+
[x, y] = [y, x];
|
|
78
|
+
// Sort logic
|
|
79
|
+
if (typeof x[key] === 'string' && typeof y[key] === 'string') {
|
|
80
|
+
return String(x[key]).localeCompare(String(y[key]));
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return x[key] - y[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Pagination ---
|
|
88
|
+
function paginationHandler(store) {
|
|
89
|
+
// store.sort = ''; // reset
|
|
90
|
+
if (store.pagination) {
|
|
91
|
+
// Slice for Pagination
|
|
92
|
+
store.filtered = store.filtered.slice(store.pagination.offset * store.pagination.limit, // start
|
|
93
|
+
store.pagination.offset * store.pagination.limit + store.pagination.limit // end
|
|
94
|
+
);
|
|
95
|
+
// Set Current Size
|
|
96
|
+
store.pagination.size = store.source.length;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Svelte Action for applying sort asc/dsc classes. */
|
|
2
|
+
export declare function tableInteraction(node: HTMLElement): {
|
|
3
|
+
destroy(): void;
|
|
4
|
+
};
|
|
5
|
+
/** Svelte Action for handling table a11y keyboard interactions. */
|
|
6
|
+
export declare function tableA11y(node: HTMLElement): {
|
|
7
|
+
destroy(): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Shared Data/Table Actions
|
|
2
|
+
// Data Table (only) ---
|
|
3
|
+
/** Svelte Action for applying sort asc/dsc classes. */
|
|
4
|
+
export function tableInteraction(node) {
|
|
5
|
+
const classAsc = 'table-sort-asc';
|
|
6
|
+
const classDsc = 'table-sort-dsc';
|
|
7
|
+
// Click Handler
|
|
8
|
+
const onClick = (e) => {
|
|
9
|
+
if (!(e.target instanceof Element))
|
|
10
|
+
return;
|
|
11
|
+
const sortTarget = e.target;
|
|
12
|
+
// Get target state before modification
|
|
13
|
+
const targetAscSorted = sortTarget.classList.contains(classAsc);
|
|
14
|
+
const sortTargetKey = sortTarget.getAttribute('data-sort');
|
|
15
|
+
// Clear asc class
|
|
16
|
+
const elemAsc = node.querySelector(`.${classAsc}`);
|
|
17
|
+
if (elemAsc)
|
|
18
|
+
elemAsc.classList.remove(classAsc);
|
|
19
|
+
// Clear dsc class
|
|
20
|
+
const elemDsc = node.querySelector(`.${classDsc}`);
|
|
21
|
+
if (elemDsc)
|
|
22
|
+
elemDsc.classList.remove(classDsc);
|
|
23
|
+
// Set new sort class
|
|
24
|
+
if (sortTargetKey) {
|
|
25
|
+
const classToApply = targetAscSorted ? classDsc : classAsc;
|
|
26
|
+
e.target.classList.add(classToApply);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// Events
|
|
30
|
+
node.addEventListener('click', onClick);
|
|
31
|
+
// Lifecycle
|
|
32
|
+
return {
|
|
33
|
+
destroy() {
|
|
34
|
+
node.removeEventListener('click', onClick);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Shared ---
|
|
39
|
+
/** Svelte Action for handling table a11y keyboard interactions. */
|
|
40
|
+
export function tableA11y(node) {
|
|
41
|
+
const keyWhitelist = ['ArrowRight', 'ArrowUp', 'ArrowLeft', 'ArrowDown', 'Home', 'End'];
|
|
42
|
+
// on:keydown
|
|
43
|
+
const onKeyDown = (event) => {
|
|
44
|
+
// console.log('keydown triggered');
|
|
45
|
+
if (keyWhitelist.includes(event.code)) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
// prettier-ignore
|
|
48
|
+
switch (event.code) {
|
|
49
|
+
case 'ArrowUp':
|
|
50
|
+
a11ySetActiveCell(node, 0, -1);
|
|
51
|
+
break;
|
|
52
|
+
case 'ArrowDown':
|
|
53
|
+
a11ySetActiveCell(node, 0, 1);
|
|
54
|
+
break;
|
|
55
|
+
case 'ArrowLeft':
|
|
56
|
+
a11ySetActiveCell(node, -1, 0);
|
|
57
|
+
break;
|
|
58
|
+
case 'ArrowRight':
|
|
59
|
+
a11ySetActiveCell(node, 1, 0);
|
|
60
|
+
break;
|
|
61
|
+
case 'Home':
|
|
62
|
+
a11yJumpToOuterColumn(node, 'first');
|
|
63
|
+
break;
|
|
64
|
+
case 'End':
|
|
65
|
+
a11yJumpToOuterColumn(node, 'last');
|
|
66
|
+
break;
|
|
67
|
+
default: break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
// Event Listner
|
|
72
|
+
node.addEventListener('keydown', onKeyDown);
|
|
73
|
+
// Lifecycle
|
|
74
|
+
return {
|
|
75
|
+
destroy() {
|
|
76
|
+
node.removeEventListener('keydown', onKeyDown);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function a11ySetActiveCell(node, x, y) {
|
|
81
|
+
// Focused Element
|
|
82
|
+
const focusedElem = document.activeElement;
|
|
83
|
+
if (!focusedElem || !focusedElem.parentElement || !focusedElem.parentElement.ariaRowIndex || !focusedElem.ariaColIndex)
|
|
84
|
+
return;
|
|
85
|
+
const focusedElemRowIndex = parseInt(focusedElem.parentElement.ariaRowIndex);
|
|
86
|
+
const focusedElemColIndex = parseInt(focusedElem.ariaColIndex);
|
|
87
|
+
// Target Element
|
|
88
|
+
const targetRowElement = node.querySelector(`[aria-rowindex="${focusedElemRowIndex + y}"]`);
|
|
89
|
+
if (targetRowElement !== null) {
|
|
90
|
+
const targetColElement = targetRowElement.querySelector(`[aria-colindex="${focusedElemColIndex + x}"]`);
|
|
91
|
+
if (targetColElement !== null)
|
|
92
|
+
targetColElement.focus();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function a11yGetTargetElem(node) {
|
|
96
|
+
// Focused Element
|
|
97
|
+
const focusedElem = document.activeElement;
|
|
98
|
+
if (!focusedElem || !focusedElem.parentElement || !focusedElem.parentElement.ariaRowIndex)
|
|
99
|
+
return null;
|
|
100
|
+
const focusedElemRowIndex = parseInt(focusedElem.parentElement.ariaRowIndex);
|
|
101
|
+
// Return Target Element
|
|
102
|
+
return node.querySelector(`[aria-rowindex="${focusedElemRowIndex}"]`);
|
|
103
|
+
}
|
|
104
|
+
function a11yJumpToOuterColumn(node, type = 'first') {
|
|
105
|
+
const targetRowElement = a11yGetTargetElem(node);
|
|
106
|
+
if (targetRowElement === null)
|
|
107
|
+
return;
|
|
108
|
+
const lastIndex = targetRowElement.children.length;
|
|
109
|
+
const selected = type === 'first' ? 1 : lastIndex;
|
|
110
|
+
const targetColElement = targetRowElement.querySelector(`[aria-colindex="${selected}"]`);
|
|
111
|
+
if (targetColElement === null)
|
|
112
|
+
return;
|
|
113
|
+
targetColElement.focus();
|
|
114
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PaginationSettings } from '../../components/Paginator/types';
|
|
2
|
+
export interface DataTableModel {
|
|
3
|
+
/** The original unfiltered source data. */
|
|
4
|
+
source: any[];
|
|
5
|
+
/** The filtered source data, shown in UI. */
|
|
6
|
+
filtered: any[];
|
|
7
|
+
/** An array of selected row objects. */
|
|
8
|
+
selection?: any[];
|
|
9
|
+
/** The current search term. */
|
|
10
|
+
search?: string;
|
|
11
|
+
/** The current sort key. */
|
|
12
|
+
sort: string;
|
|
13
|
+
/** The Paginator component settings. */
|
|
14
|
+
pagination?: PaginationSettings;
|
|
15
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<script>import { fade, fly } from 'svelte/transition';
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
import { focusTrap } from '../../actions/FocusTrap/focusTrap';
|
|
4
|
+
// Props
|
|
5
|
+
/** Provide a store to manage visible state.
|
|
6
|
+
* @type {Writable(boolean)}
|
|
7
|
+
*/
|
|
8
|
+
export let open = writable(false);
|
|
9
|
+
/** Set the anchor position.
|
|
10
|
+
* @type {'left' | 'top' | 'right' | 'bottom'}
|
|
11
|
+
*/
|
|
12
|
+
export let position = 'left';
|
|
13
|
+
/** Define the Svelte transition animation duration.*/
|
|
14
|
+
export let duration = 150;
|
|
15
|
+
// Props (backdrop)
|
|
16
|
+
/** Backdrop - Provide classes to set the backdrop background color*/
|
|
17
|
+
export let bgBackdrop = 'bg-backdrop-token';
|
|
18
|
+
/** Backdrop - Provide classes to set the blur style.*/
|
|
19
|
+
export let blur = 'backdrop-blur-xs';
|
|
20
|
+
// Props (drawer)
|
|
21
|
+
/** Drawer - Provide classes to set the drawer background color.*/
|
|
22
|
+
export let bgDrawer = 'bg-surface-100-800-token';
|
|
23
|
+
/** Drawer - Provide classes to set border color.*/
|
|
24
|
+
export let border = '';
|
|
25
|
+
/** Drawer - Provide classes to set border radius.*/
|
|
26
|
+
export let rounded = '';
|
|
27
|
+
/** Drawer - Provide classes to override the width.*/
|
|
28
|
+
export let width = '';
|
|
29
|
+
/** Drawer - Provide classes to override the height.*/
|
|
30
|
+
export let height = '';
|
|
31
|
+
/** Drawer - Provide classes to set margins.*/
|
|
32
|
+
export let margin = '';
|
|
33
|
+
// Props (a11y)
|
|
34
|
+
/** Provide an ID of the element labeling the drawer.*/
|
|
35
|
+
export let labelledby = '';
|
|
36
|
+
/** Provide an ID of the element describing the drawer.*/
|
|
37
|
+
export let describedby = '';
|
|
38
|
+
// Base Classes
|
|
39
|
+
const cBaseBackdrop = 'fixed top-0 left-0 right-0 bottom-0 z-40 flex';
|
|
40
|
+
const cBaseDrawer = 'shadow-xl overflow-y-auto';
|
|
41
|
+
// Local
|
|
42
|
+
let elemBackdrop;
|
|
43
|
+
let elemDrawer;
|
|
44
|
+
function percentage(percent, amount) {
|
|
45
|
+
return (amount / 100) * percent;
|
|
46
|
+
}
|
|
47
|
+
// Set Animation Values
|
|
48
|
+
let animParams = { backdrop: '', width: '', height: '', x: 0, y: 0 };
|
|
49
|
+
function setAnimParams() {
|
|
50
|
+
switch (position) {
|
|
51
|
+
case 'top':
|
|
52
|
+
animParams = {
|
|
53
|
+
backdrop: 'flex-col justify-start',
|
|
54
|
+
width: 'w-full',
|
|
55
|
+
height: 'h-[40%]',
|
|
56
|
+
x: 0,
|
|
57
|
+
y: -percentage(40, window.innerHeight)
|
|
58
|
+
};
|
|
59
|
+
break;
|
|
60
|
+
case 'bottom':
|
|
61
|
+
animParams = { backdrop: 'flex-col justify-end', width: 'w-full', height: 'h-[40%]', x: 0, y: percentage(40, window.innerHeight) };
|
|
62
|
+
break;
|
|
63
|
+
case 'right':
|
|
64
|
+
animParams = { backdrop: 'justify-end', width: 'w-[90%]', height: 'h-full', x: percentage(80, window.innerWidth), y: 0 };
|
|
65
|
+
break;
|
|
66
|
+
// Default: Left
|
|
67
|
+
default:
|
|
68
|
+
animParams = { backdrop: 'justify-start', width: 'w-[90%]', height: 'h-full', x: -percentage(80, window.innerWidth), y: 0 };
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Input Handlers
|
|
73
|
+
function onClickBackdrop(e) {
|
|
74
|
+
// Limit to only backdrop element
|
|
75
|
+
if (e.target === elemBackdrop) {
|
|
76
|
+
close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function onKeydownWindow(e) {
|
|
80
|
+
if (!$open)
|
|
81
|
+
return;
|
|
82
|
+
if (e.code === 'Escape') {
|
|
83
|
+
close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Close
|
|
87
|
+
function close() {
|
|
88
|
+
open.set(false);
|
|
89
|
+
}
|
|
90
|
+
// Subscribe to $open prop
|
|
91
|
+
open.subscribe((o) => {
|
|
92
|
+
if (o === true) {
|
|
93
|
+
setAnimParams();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
// Reactive
|
|
97
|
+
$: classesWidth = width ? width : animParams.width;
|
|
98
|
+
$: classesHeight = height ? height : animParams.height;
|
|
99
|
+
$: classesBackdrop = `${cBaseBackdrop} ${animParams.backdrop} ${bgBackdrop} ${blur} ${$$props.class ?? ''}`;
|
|
100
|
+
$: classesDrawer = `${cBaseDrawer} ${classesWidth} ${classesHeight} ${bgDrawer} ${border} ${margin} ${rounded}`;
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<svelte:window on:keydown={onKeydownWindow} />
|
|
104
|
+
|
|
105
|
+
{#if $open}
|
|
106
|
+
<!-- Backdrop -->
|
|
107
|
+
<div
|
|
108
|
+
bind:this={elemBackdrop}
|
|
109
|
+
class="drawer-backdrop {classesBackdrop}"
|
|
110
|
+
data-testid="drawer-backdrop"
|
|
111
|
+
transition:fade|local={{ duration }}
|
|
112
|
+
on:click={(e) => {
|
|
113
|
+
onClickBackdrop(e);
|
|
114
|
+
}}
|
|
115
|
+
on:keydown
|
|
116
|
+
on:keyup
|
|
117
|
+
on:keypress
|
|
118
|
+
use:focusTrap={true}
|
|
119
|
+
>
|
|
120
|
+
<!-- Drawer -->
|
|
121
|
+
<div
|
|
122
|
+
bind:this={elemDrawer}
|
|
123
|
+
class="drawer {classesDrawer}"
|
|
124
|
+
data-testid="drawer"
|
|
125
|
+
transition:fly|local={{ x: animParams.x, y: animParams.y, duration }}
|
|
126
|
+
role="dialog"
|
|
127
|
+
aria-modal="true"
|
|
128
|
+
aria-labelledby={labelledby}
|
|
129
|
+
aria-describedby={describedby}
|
|
130
|
+
>
|
|
131
|
+
<!-- Slot: Default -->
|
|
132
|
+
<slot />
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|