lutra 0.0.13 → 0.0.16
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/data/Stat.svelte +1 -1
- package/dist/display/Avatar.svelte +1 -1
- package/dist/display/Badge.svelte +1 -1
- package/dist/display/Callout.svelte +3 -3
- package/dist/display/Code.svelte +1 -1
- package/dist/display/ContextTip.svelte +1 -1
- package/dist/display/Details.svelte +1 -1
- package/dist/display/Hero.svelte +1 -1
- package/dist/display/Icon.svelte +9 -3
- package/dist/display/IconButton.svelte +9 -9
- package/dist/display/IconButton.svelte.d.ts +0 -2
- package/dist/display/Image.svelte +41 -0
- package/dist/display/Image.svelte.d.ts +24 -0
- package/dist/display/Indicator.svelte +1 -1
- package/dist/display/Inset.svelte +18 -0
- package/dist/display/Inset.svelte.d.ts +17 -0
- package/dist/display/Popup.svelte +1 -1
- package/dist/display/Popup.svelte.d.ts +1 -3
- package/dist/display/Table.svelte +21 -0
- package/dist/display/Table.svelte.d.ts +23 -0
- package/dist/display/Tag.svelte +2 -2
- package/dist/display/Tooltip.svelte +1 -1
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.js +1 -0
- package/dist/form/Button.svelte +1 -1
- package/dist/form/FieldActions.svelte +26 -6
- package/dist/form/FieldActions.svelte.d.ts +1 -0
- package/dist/form/FieldContainer.svelte +4 -3
- package/dist/form/FieldContent.svelte +54 -16
- package/dist/form/FieldError.svelte +1 -1
- package/dist/form/FieldSection.svelte +20 -47
- package/dist/form/Fieldset.svelte +10 -5
- package/dist/form/Fieldset.svelte.d.ts +2 -0
- package/dist/form/Form.svelte +1 -1
- package/dist/form/Input.svelte +19 -40
- package/dist/form/Input.svelte.d.ts +2 -0
- package/dist/form/InputLength.svelte +1 -1
- package/dist/form/Label.svelte +2 -1
- package/dist/form/Select.svelte +1 -1
- package/dist/grid/Column.svelte +1 -1
- package/dist/grid/Grid.svelte +1 -1
- package/dist/grid/Row.svelte +1 -1
- package/dist/icons/Alert.svelte +2 -2
- package/dist/icons/Copy.svelte +2 -2
- package/dist/icons/Done.svelte +2 -2
- package/dist/icons/Error.svelte +2 -2
- package/dist/icons/Help.svelte +2 -2
- package/dist/icons/Hide.svelte +2 -2
- package/dist/icons/Info.svelte +2 -2
- package/dist/icons/Link.svelte +2 -2
- package/dist/icons/MenuBurger.svelte +3 -0
- package/dist/icons/MenuBurger.svelte.d.ts +23 -0
- package/dist/icons/MenuDots.svelte +3 -0
- package/dist/icons/MenuDots.svelte.d.ts +23 -0
- package/dist/icons/Show.svelte +2 -2
- package/dist/icons/Success.svelte +2 -2
- package/dist/icons/Warning.svelte +2 -2
- package/dist/layout/Layout.svelte +1 -1
- package/dist/layout/LayoutFooter.svelte +1 -1
- package/dist/layout/LayoutGrid.svelte +1 -1
- package/dist/layout/LayoutHeader.svelte +1 -1
- package/dist/layout/PageContent.svelte +1 -1
- package/dist/layout/Theme.svelte +7 -7
- package/dist/layout/UIContent.svelte +1 -1
- package/dist/nav/Breadcrumb.svelte +1 -1
- package/dist/nav/Menu.svelte +177 -161
- package/dist/nav/Menu.svelte.d.ts +11 -3
- package/dist/nav/MenuItem.svelte +122 -0
- package/dist/nav/MenuItem.svelte.d.ts +17 -0
- package/dist/nav/MenuTypes.d.ts +24 -3
- package/dist/nav/NavMenu.svelte +183 -0
- package/dist/nav/NavMenu.svelte.d.ts +18 -0
- package/dist/nav/TabbedContent.svelte +1 -1
- package/dist/nav/Tabs.svelte +8 -8
- package/dist/nav/index.d.ts +2 -0
- package/dist/nav/index.js +1 -0
- package/dist/style.css +36 -24
- package/dist/typo/Clamp.svelte +1 -1
- package/dist/typo/H.svelte +3 -2
- package/dist/typo/H.svelte.d.ts +2 -0
- package/dist/typo/H1.svelte +3 -3
- package/dist/typo/H1.svelte.d.ts +2 -0
- package/dist/typo/H2.svelte +3 -2
- package/dist/typo/H2.svelte.d.ts +2 -0
- package/dist/typo/H3.svelte +3 -2
- package/dist/typo/H3.svelte.d.ts +2 -0
- package/dist/typo/H4.svelte +3 -2
- package/dist/typo/H4.svelte.d.ts +2 -0
- package/dist/typo/H5.svelte +3 -2
- package/dist/typo/H5.svelte.d.ts +2 -0
- package/dist/typo/H6.svelte +3 -2
- package/dist/typo/H6.svelte.d.ts +2 -0
- package/dist/typo/P.svelte +3 -1
- package/dist/typo/P.svelte.d.ts +2 -0
- package/dist/utils/StringOrComponentOrSnippet.svelte +13 -0
- package/dist/utils/StringOrComponentOrSnippet.svelte.d.ts +17 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/keyboard.svelte.d.ts +3 -0
- package/dist/utils/keyboard.svelte.js +142 -0
- package/dist/utils/transitions.js +14 -7
- package/package.json +10 -14
- package/dist/datatable/DataTable.svelte +0 -31
- package/dist/datatable/DataTable.svelte.d.ts +0 -20
- package/dist/datatable/DataTableColumn.svelte +0 -20
- package/dist/datatable/DataTableColumn.svelte.d.ts +0 -18
- package/dist/datatable/DataTableRow.svelte +0 -59
- package/dist/datatable/DataTableRow.svelte.d.ts +0 -21
- package/dist/datatable/index.d.ts +0 -3
- package/dist/datatable/index.js +0 -3
- package/dist/form/server.d.ts +0 -21
- package/dist/form/server.js +0 -48
@@ -0,0 +1,8 @@
|
|
1
|
+
export { attr } from './attr.js';
|
2
|
+
export { stringToColor, hexToRgb, hexRelativeLuminance, relativeLuminanceW3C, StatusColors, isStatusColor, getStatusColorVar } from './color.js';
|
3
|
+
export type { Defaults } from './defaults.js';
|
4
|
+
export { createId } from './id.js';
|
5
|
+
export { isSnippet, isComponent } from './isSnippet.js';
|
6
|
+
export type { StatusColor, StatusColorOrString } from './color.js';
|
7
|
+
export { popBezier, popBezierInverse, slidefade, solve_spring, cubicBezier } from './transitions.js';
|
8
|
+
export type { SpringParams } from './transitions.js';
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { attr } from './attr.js';
|
2
|
+
export { stringToColor, hexToRgb, hexRelativeLuminance, relativeLuminanceW3C, StatusColors, isStatusColor, getStatusColorVar } from './color.js';
|
3
|
+
export { createId } from './id.js';
|
4
|
+
export { isSnippet, isComponent } from './isSnippet.js';
|
5
|
+
export { popBezier, popBezierInverse, slidefade, solve_spring, cubicBezier } from './transitions.js';
|
@@ -0,0 +1,3 @@
|
|
1
|
+
export declare function getNextFocusableElement(startingElement: HTMLElement | null, triggerElement: HTMLElement | null, direction: "next" | "previous"): HTMLElement | null;
|
2
|
+
export declare function arrowNavigation(el: HTMLElement | null, direction: "up" | "down"): void;
|
3
|
+
export declare function matchOnType(el: HTMLElement | null, e: KeyboardEvent): void;
|
@@ -0,0 +1,142 @@
|
|
1
|
+
export function getNextFocusableElement(startingElement, triggerElement, direction) {
|
2
|
+
if (!startingElement)
|
3
|
+
return null;
|
4
|
+
// Define selectors for focusable elements
|
5
|
+
const focusableSelectors = 'a, button, textarea, input, select';
|
6
|
+
// Get all focusable elements
|
7
|
+
const allFocusableElements = Array.from(document.querySelectorAll(focusableSelectors)).filter(el => !el.disabled && el.tabIndex >= 0);
|
8
|
+
console.log('allFocusableElements', allFocusableElements);
|
9
|
+
// Filter out elements inside the startingElement
|
10
|
+
const focusableElements = allFocusableElements.filter(el => !triggerElement.contains(el) && el !== startingElement);
|
11
|
+
console.log('focusableElements', focusableElements);
|
12
|
+
// Find the index of the starting element among all focusable elements
|
13
|
+
let startingIndex = allFocusableElements.indexOf(triggerElement);
|
14
|
+
console.log('startingIndex', startingIndex);
|
15
|
+
if (startingIndex === -1) {
|
16
|
+
// If the starting element is not focusable or not found, consider the document's active element if it's focusable.
|
17
|
+
const activeElement = document.activeElement;
|
18
|
+
if (activeElement && allFocusableElements.includes(activeElement)) {
|
19
|
+
startingIndex = allFocusableElements.indexOf(activeElement);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
// No valid starting point found
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
// Determine the next index based on the direction, skipping children of startingElement
|
27
|
+
let nextIndex = -1;
|
28
|
+
if (direction === 'next') {
|
29
|
+
for (let i = startingIndex + 1; i < allFocusableElements.length; i++) {
|
30
|
+
if (focusableElements.includes(allFocusableElements[i])) {
|
31
|
+
nextIndex = focusableElements.indexOf(allFocusableElements[i]);
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
for (let i = startingIndex - 1; i >= 0; i--) {
|
38
|
+
if (focusableElements.includes(allFocusableElements[i])) {
|
39
|
+
nextIndex = focusableElements.indexOf(allFocusableElements[i]);
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
// If no next element is found in the direction, wrap around.
|
45
|
+
if (nextIndex === -1) {
|
46
|
+
if (direction === 'next') {
|
47
|
+
// Wrap to the first element in the list
|
48
|
+
nextIndex = 0;
|
49
|
+
}
|
50
|
+
else {
|
51
|
+
// Wrap to the last element in the list
|
52
|
+
nextIndex = focusableElements.length - 1;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
// Return the next focusable element, or null if none are found
|
56
|
+
return focusableElements[nextIndex] || null;
|
57
|
+
}
|
58
|
+
export function arrowNavigation(el, direction) {
|
59
|
+
const items = el?.querySelectorAll("a, button, input, textarea, select");
|
60
|
+
if (!items)
|
61
|
+
return;
|
62
|
+
const index = Array.from(items).findIndex((el) => el === document.activeElement);
|
63
|
+
if (index === -1) {
|
64
|
+
items[0].focus();
|
65
|
+
}
|
66
|
+
else if (direction === "down" && index < items.length - 1) {
|
67
|
+
items[index + 1].focus();
|
68
|
+
}
|
69
|
+
else if (direction === "up" && index > 0) {
|
70
|
+
items[index - 1].focus();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
const ignoreKeys = ['backspace', 'tab', 'shift', 'control', 'alt', 'meta', 'arrowup', 'arrowdown', 'arrowleft', 'arrowright', 'home', 'end', 'pageup', 'pagedown', 'escape', 'capslock', 'numlock', 'scrolllock', 'pause', 'contextmenu', 'printscreen', 'help', 'clear', 'os', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10', 'f12', 'insert', 'delete', 'enter', 'space', 'escape'];
|
74
|
+
let keyMemory = $state("");
|
75
|
+
let timeout;
|
76
|
+
export function matchOnType(el, e) {
|
77
|
+
const items = el?.querySelectorAll("a, button, label");
|
78
|
+
if (!items)
|
79
|
+
return;
|
80
|
+
const index = Array.from(items).findIndex((el) => el === document.activeElement);
|
81
|
+
const search = e.key.toLowerCase();
|
82
|
+
if (timeout)
|
83
|
+
clearTimeout(timeout);
|
84
|
+
function removeUls() {
|
85
|
+
items.forEach((el) => {
|
86
|
+
const contentEl = el.querySelector("span.Content") ?? el.querySelector("label");
|
87
|
+
if (contentEl) {
|
88
|
+
contentEl.innerHTML = contentEl.textContent;
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
const currentlyFocusedElement = document.activeElement;
|
93
|
+
// return if the key is not a letter or number
|
94
|
+
if (ignoreKeys.includes(search) || currentlyFocusedElement.tagName === "INPUT" || currentlyFocusedElement.tagName === "TEXTAREA") {
|
95
|
+
keyMemory = '';
|
96
|
+
removeUls();
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
// clear the memory after 1 second
|
100
|
+
timeout = setTimeout(() => {
|
101
|
+
keyMemory = '';
|
102
|
+
removeUls();
|
103
|
+
}, 1000);
|
104
|
+
// only add if the last key is not the same
|
105
|
+
if (keyMemory[keyMemory.length - 1] !== search) {
|
106
|
+
keyMemory += search;
|
107
|
+
}
|
108
|
+
const matches = Array.from(items).filter((el) => {
|
109
|
+
const text = el.textContent?.trim().toLowerCase();
|
110
|
+
return text?.startsWith(keyMemory);
|
111
|
+
});
|
112
|
+
if (matches.length) {
|
113
|
+
// add underline to the matched text
|
114
|
+
matches.forEach((el) => {
|
115
|
+
const contentEl = el.querySelector("span.Content, label");
|
116
|
+
const text = contentEl?.textContent?.trim();
|
117
|
+
if (text) {
|
118
|
+
const index = text.toLowerCase().indexOf(keyMemory);
|
119
|
+
const first = text.slice(0, index);
|
120
|
+
const last = text.slice(index + keyMemory.length);
|
121
|
+
const middle = text.slice(index, index + keyMemory.length);
|
122
|
+
contentEl.innerHTML = `${first}<u>${middle}</u>${last}`;
|
123
|
+
}
|
124
|
+
});
|
125
|
+
if (keyMemory.length === 1) {
|
126
|
+
// if this element is already focused, move to the next one if memory is at one character
|
127
|
+
const nextMatches = Array.from(items).filter((el) => el.textContent?.trim().toLowerCase().startsWith(keyMemory));
|
128
|
+
if (nextMatches) {
|
129
|
+
const nextIndex = nextMatches.findIndex((el) => el === document.activeElement);
|
130
|
+
if (nextIndex < nextMatches.length - 1) {
|
131
|
+
nextMatches[nextIndex + 1].focus();
|
132
|
+
}
|
133
|
+
else {
|
134
|
+
nextMatches[0].focus();
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
else {
|
139
|
+
matches[0].focus();
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
@@ -1,20 +1,27 @@
|
|
1
|
-
import { cubicOut } from 'svelte/easing';
|
2
|
-
let visibleDoubleElements = false;
|
3
1
|
/**
|
4
2
|
* A bezier curve that starts fast and slows down.
|
5
3
|
*/
|
6
4
|
export const popBezier = cubicBezier(0.25, 0.25, 0.75, 1);
|
7
5
|
export const popBezierInverse = cubicBezier(0.75, 0.75, 0.25, 0);
|
8
6
|
export function slidefade(node, params = {}) {
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
7
|
+
const origin = params.origin || "top left";
|
8
|
+
const transform = getComputedStyle(node).transform.replace('none', '');
|
9
|
+
const existingTranslateX = transform.match(/translateX\(([^)]+)\)/);
|
10
|
+
const existingTranslateY = transform.match(/translateY\(([^)]+)\)/);
|
11
|
+
const _x = params.x || 0;
|
12
|
+
const _y = params.y || 0;
|
13
|
+
// If the origin is top left, we want to move the element to the right and down, so we need to invert the x and y values.
|
14
|
+
// If the origin is top right, we want to move the element to the left and down, so we need to invert the y value.
|
15
|
+
// etc.
|
16
|
+
const x = origin.indexOf('left') > -1 ? -1 * _x : _x;
|
17
|
+
const y = origin.indexOf('top') > -1 ? -1 * _y : _y;
|
18
|
+
const translateX = `${existingTranslateX ? existingTranslateX[1] : '0px'} + ${x}px`;
|
19
|
+
const translateY = `${existingTranslateY ? existingTranslateY[1] : '0px'} + ${y}px`;
|
13
20
|
return {
|
14
21
|
delay: params.delay || 0,
|
15
22
|
duration: params.duration || 400,
|
16
23
|
easing: params.easing || popBezier,
|
17
|
-
css: (t, u) => `transform-origin: ${
|
24
|
+
css: (t, u) => `transform-origin: ${origin}; transform: ${transform} translateX(calc(${translateX} * ${u})) translateY(calc(${translateY} * ${u})); scale: ${t / 10 + 0.9}; opacity: ${t};`,
|
18
25
|
};
|
19
26
|
}
|
20
27
|
export function solve_spring(from, velocity, to, _params) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "lutra",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.16",
|
4
4
|
"scripts": {
|
5
5
|
"dev": "vite dev --host 0.0.0.0",
|
6
6
|
"props": "node read_props.js",
|
@@ -25,10 +25,6 @@
|
|
25
25
|
"types": "./dist/data/index.d.ts",
|
26
26
|
"svelte": "./dist/data/index.js"
|
27
27
|
},
|
28
|
-
"./datatable": {
|
29
|
-
"types": "./dist/datatable/index.d.ts",
|
30
|
-
"svelte": "./dist/datatable/index.js"
|
31
|
-
},
|
32
28
|
"./display": {
|
33
29
|
"types": "./dist/display/index.d.ts",
|
34
30
|
"svelte": "./dist/display/index.js"
|
@@ -66,13 +62,13 @@
|
|
66
62
|
"svelte": "^4.0.0"
|
67
63
|
},
|
68
64
|
"devDependencies": {
|
69
|
-
"@playwright/test": "^1.
|
70
|
-
"@rollup/browser": "^4.
|
71
|
-
"@sveltejs/adapter-auto": "^3.
|
72
|
-
"@sveltejs/package": "^2.3.
|
73
|
-
"@sveltejs/vite-plugin-svelte": "^3.0
|
65
|
+
"@playwright/test": "^1.43.0",
|
66
|
+
"@rollup/browser": "^4.14.1",
|
67
|
+
"@sveltejs/adapter-auto": "^3.2.0",
|
68
|
+
"@sveltejs/package": "^2.3.1",
|
69
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.0",
|
74
70
|
"@types/glob": "8.1.0",
|
75
|
-
"glob": "^10.3.
|
71
|
+
"glob": "^10.3.12",
|
76
72
|
"highlight.js": "^11.9.0",
|
77
73
|
"mdsvex": "^0.11.0",
|
78
74
|
"monaco-editor": "^0.47.0",
|
@@ -80,10 +76,10 @@
|
|
80
76
|
"prettier-plugin-svelte": "^3.2.2",
|
81
77
|
"publint": "^0.2.7",
|
82
78
|
"svelte": "next",
|
83
|
-
"svelte-check": "^3.6.
|
79
|
+
"svelte-check": "^3.6.9",
|
84
80
|
"tslib": "^2.6.2",
|
85
|
-
"typescript": "^5.4.
|
86
|
-
"vite": "5.2.
|
81
|
+
"typescript": "^5.4.5",
|
82
|
+
"vite": "5.2.8",
|
87
83
|
"vitest": "1.4.0"
|
88
84
|
},
|
89
85
|
"svelte": "./dist/index.js",
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<script>import UiContent from "../layout/UIContent.svelte";
|
2
|
-
import { setContext } from "svelte";
|
3
|
-
let {
|
4
|
-
columns,
|
5
|
-
contained,
|
6
|
-
children
|
7
|
-
} = $props();
|
8
|
-
</script>
|
9
|
-
|
10
|
-
<UiContent>
|
11
|
-
<section class="DataTable" class:contained style="--dtc: {contained ? 1 : 0}; --dtcols: {columns};">
|
12
|
-
{@render children()}
|
13
|
-
</section>
|
14
|
-
</UiContent>
|
15
|
-
|
16
|
-
<style>
|
17
|
-
section {
|
18
|
-
container-type: inline-size;
|
19
|
-
display: grid;
|
20
|
-
grid-template-columns: repeat(var(--dtcols), minmax(min-content, 1fr));
|
21
|
-
border-radius: var(--border-radius);
|
22
|
-
font-size: var(--font-size, 1em);
|
23
|
-
margin-inline: calc((var(--dtc) - 1) * 1em);
|
24
|
-
width: calc(100% + (var(--dtc) - 1 * 2em));
|
25
|
-
overflow-x: auto;
|
26
|
-
}
|
27
|
-
section.contained {
|
28
|
-
border: var(--border);
|
29
|
-
border-radius: var(--border-radius);
|
30
|
-
}
|
31
|
-
</style>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
import { type Snippet } from "svelte";
|
3
|
-
declare const __propDef: {
|
4
|
-
props: {
|
5
|
-
columns: number;
|
6
|
-
/** The number of columns to display the data in. */
|
7
|
-
contained?: boolean | undefined;
|
8
|
-
children: Snippet;
|
9
|
-
};
|
10
|
-
events: {
|
11
|
-
[evt: string]: CustomEvent<any>;
|
12
|
-
};
|
13
|
-
slots: {};
|
14
|
-
};
|
15
|
-
export type DataTableProps = typeof __propDef.props;
|
16
|
-
export type DataTableEvents = typeof __propDef.events;
|
17
|
-
export type DataTableSlots = typeof __propDef.slots;
|
18
|
-
export default class DataTable extends SvelteComponent<DataTableProps, DataTableEvents, DataTableSlots> {
|
19
|
-
}
|
20
|
-
export {};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
<script>import { getContext } from "svelte";
|
2
|
-
let {
|
3
|
-
children
|
4
|
-
} = $props();
|
5
|
-
const { header } = getContext("DataTableRow");
|
6
|
-
if (header) {
|
7
|
-
getContext("DataTableColumns").addColumn();
|
8
|
-
}
|
9
|
-
</script>
|
10
|
-
|
11
|
-
<div class="DataTableColumn">
|
12
|
-
{#if children}
|
13
|
-
{@render children()}
|
14
|
-
{/if}
|
15
|
-
</div>
|
16
|
-
|
17
|
-
<style>
|
18
|
-
.DataTableColumn {
|
19
|
-
}
|
20
|
-
</style>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
declare const __propDef: {
|
3
|
-
props: {
|
4
|
-
children?: ((this: void) => typeof import("svelte").SnippetReturn & {
|
5
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
6
|
-
}) | undefined;
|
7
|
-
};
|
8
|
-
events: {
|
9
|
-
[evt: string]: CustomEvent<any>;
|
10
|
-
};
|
11
|
-
slots: {};
|
12
|
-
};
|
13
|
-
export type DataTableColumnProps = typeof __propDef.props;
|
14
|
-
export type DataTableColumnEvents = typeof __propDef.events;
|
15
|
-
export type DataTableColumnSlots = typeof __propDef.slots;
|
16
|
-
export default class DataTableColumn extends SvelteComponent<DataTableColumnProps, DataTableColumnEvents, DataTableColumnSlots> {
|
17
|
-
}
|
18
|
-
export {};
|
@@ -1,59 +0,0 @@
|
|
1
|
-
<script>import { setContext } from "svelte";
|
2
|
-
let {
|
3
|
-
children,
|
4
|
-
actions,
|
5
|
-
header = false
|
6
|
-
} = $props();
|
7
|
-
setContext("DataTableRow", { header });
|
8
|
-
</script>
|
9
|
-
|
10
|
-
<svelte:element this={header ? "header" : "section"} class="DataTableRow" class:header>
|
11
|
-
{@render children()}
|
12
|
-
{#if actions}
|
13
|
-
<div class="Actions">
|
14
|
-
{@render actions()}
|
15
|
-
</div>
|
16
|
-
{/if}
|
17
|
-
</svelte:element>
|
18
|
-
|
19
|
-
<style>
|
20
|
-
.DataTableRow {
|
21
|
-
display: grid;
|
22
|
-
grid-template-columns: subgrid;
|
23
|
-
grid-column: 1 / -1;
|
24
|
-
gap: 1.5em;
|
25
|
-
align-items: center;
|
26
|
-
width: 100%;
|
27
|
-
padding: 0.75em 1em;
|
28
|
-
position: relative;
|
29
|
-
}
|
30
|
-
.DataTableRow:hover {
|
31
|
-
background: var(--bg-subtle);
|
32
|
-
}
|
33
|
-
.DataTableRow:has(.Actions) {
|
34
|
-
padding-right: 0;
|
35
|
-
}
|
36
|
-
.DataTableRow :global(> *) {
|
37
|
-
white-space: nowrap;
|
38
|
-
}
|
39
|
-
.DataTableRow.header {
|
40
|
-
background: color-mix(in srgb, var(--bg-subtle) calc(var(--dtc) * 100%), transparent);
|
41
|
-
}
|
42
|
-
section:not(:first-child) {
|
43
|
-
border-top: var(--border);
|
44
|
-
}
|
45
|
-
.Actions {
|
46
|
-
display: flex;
|
47
|
-
gap: 0.75em;
|
48
|
-
justify-self: end;
|
49
|
-
position: sticky;
|
50
|
-
top: 0;
|
51
|
-
right: 0;
|
52
|
-
padding-left: 0.75em;
|
53
|
-
padding-right: calc(1em * var(--dtc));
|
54
|
-
background: var(--bg-app);
|
55
|
-
}
|
56
|
-
.DataTableRow:hover .Actions {
|
57
|
-
background: color-mix(in srgb, var(--bg-subtle) calc(var(--dtc) * 100%), transparent);
|
58
|
-
}
|
59
|
-
</style>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
import { type Snippet } from "svelte";
|
3
|
-
declare const __propDef: {
|
4
|
-
props: {
|
5
|
-
header?: boolean | undefined;
|
6
|
-
actions?: ((this: void) => typeof import("svelte").SnippetReturn & {
|
7
|
-
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
8
|
-
}) | undefined;
|
9
|
-
children: Snippet;
|
10
|
-
};
|
11
|
-
events: {
|
12
|
-
[evt: string]: CustomEvent<any>;
|
13
|
-
};
|
14
|
-
slots: {};
|
15
|
-
};
|
16
|
-
export type DataTableRowProps = typeof __propDef.props;
|
17
|
-
export type DataTableRowEvents = typeof __propDef.events;
|
18
|
-
export type DataTableRowSlots = typeof __propDef.slots;
|
19
|
-
export default class DataTableRow extends SvelteComponent<DataTableRowProps, DataTableRowEvents, DataTableRowSlots> {
|
20
|
-
}
|
21
|
-
export {};
|
package/dist/datatable/index.js
DELETED
package/dist/form/server.d.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import { Bodyguard } from "@auth70/bodyguard";
|
2
|
-
import type { ActionFailure, RequestEvent } from "@sveltejs/kit";
|
3
|
-
import type { z, ZodType } from "zod";
|
4
|
-
export declare const bodyguard: Bodyguard;
|
5
|
-
export type Issue = {
|
6
|
-
message: string;
|
7
|
-
path: string[];
|
8
|
-
field: string;
|
9
|
-
};
|
10
|
-
export declare class FormError extends Error {
|
11
|
-
issues: Issue[];
|
12
|
-
constructor(issues: Issue[], message?: string);
|
13
|
-
}
|
14
|
-
export declare function formHandler<T, Z extends ZodType<any, any>>(event: RequestEvent, schema: Z, onSuccess: (data: z.infer<Z>) => Promise<T>, { castNumbers, castBooleans, }?: {
|
15
|
-
castNumbers?: boolean;
|
16
|
-
castBooleans?: boolean;
|
17
|
-
}): Promise<T | ActionFailure<{
|
18
|
-
issues: any;
|
19
|
-
}> | ActionFailure<{
|
20
|
-
message: any;
|
21
|
-
}>>;
|
package/dist/form/server.js
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
import { Bodyguard } from "@auth70/bodyguard";
|
2
|
-
import { fail } from "@sveltejs/kit";
|
3
|
-
export const bodyguard = new Bodyguard();
|
4
|
-
export class FormError extends Error {
|
5
|
-
issues;
|
6
|
-
constructor(issues, message = 'Form error') {
|
7
|
-
super(message);
|
8
|
-
this.issues = issues;
|
9
|
-
}
|
10
|
-
}
|
11
|
-
export async function formHandler(event, schema, onSuccess, { castNumbers, castBooleans, } = {
|
12
|
-
castNumbers: false,
|
13
|
-
castBooleans: false,
|
14
|
-
}) {
|
15
|
-
const data = await bodyguard.softForm(event.request, schema.parse, {
|
16
|
-
castNumbers: castNumbers || false,
|
17
|
-
castBooleans: castBooleans || false,
|
18
|
-
});
|
19
|
-
if (!data.success) {
|
20
|
-
try {
|
21
|
-
const issues = JSON.parse(data.error);
|
22
|
-
console.error('[lutra] Bodyguard failed:', data);
|
23
|
-
return fail(400, {
|
24
|
-
issues,
|
25
|
-
});
|
26
|
-
}
|
27
|
-
catch (err) {
|
28
|
-
console.error('[lutra] Bodyguard failed:', data);
|
29
|
-
return fail(400, {
|
30
|
-
issues: data.error
|
31
|
-
});
|
32
|
-
}
|
33
|
-
}
|
34
|
-
try {
|
35
|
-
return Promise.resolve(onSuccess(data.value));
|
36
|
-
}
|
37
|
-
catch (err) {
|
38
|
-
console.error('[lutra] Error in form handler:', err);
|
39
|
-
if (err?.issues) {
|
40
|
-
return fail(400, {
|
41
|
-
issues: err?.issues ?? [],
|
42
|
-
});
|
43
|
-
}
|
44
|
-
return fail(500, {
|
45
|
-
message: err.message
|
46
|
-
});
|
47
|
-
}
|
48
|
-
}
|