@lapis-notes/ui 0.1.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/CHANGELOG.md +9 -0
- package/LICENSE.md +4 -0
- package/README.md +46 -0
- package/dist/codemirror-autocomplete.css +223 -0
- package/dist/command-fuzzy-filter.d.ts +15 -0
- package/dist/command-fuzzy-filter.js +27 -0
- package/dist/components/ui/confirm-dialog/confirm-dialog.css +11 -0
- package/dist/components/ui/confirm-dialog/confirm-dialog.svelte +94 -0
- package/dist/components/ui/confirm-dialog/confirm-dialog.svelte.d.ts +18 -0
- package/dist/components/ui/confirm-dialog/index.d.ts +3 -0
- package/dist/components/ui/confirm-dialog/index.js +3 -0
- package/dist/components/ui/modal/index.d.ts +3 -0
- package/dist/components/ui/modal/index.js +3 -0
- package/dist/components/ui/modal/modal.css +16 -0
- package/dist/components/ui/modal/modal.svelte +74 -0
- package/dist/components/ui/modal/modal.svelte.d.ts +16 -0
- package/dist/components/ui/search/index.d.ts +3 -0
- package/dist/components/ui/search/index.js +3 -0
- package/dist/components/ui/search/search.css +55 -0
- package/dist/components/ui/search/search.svelte +54 -0
- package/dist/components/ui/search/search.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar-custom/constants.d.ts +6 -0
- package/dist/components/ui/sidebar-custom/constants.js +6 -0
- package/dist/components/ui/sidebar-custom/context.svelte.d.ts +49 -0
- package/dist/components/ui/sidebar-custom/context.svelte.js +68 -0
- package/dist/components/ui/sidebar-custom/index.d.ts +26 -0
- package/dist/components/ui/sidebar-custom/index.js +28 -0
- package/dist/components/ui/sidebar-custom/sidebar-content.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-content.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-custom.css +1357 -0
- package/dist/components/ui/sidebar-custom/sidebar-footer.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-footer.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-action.svelte +37 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-action.svelte.d.ts +11 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-content.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-content.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-label.svelte +37 -0
- package/dist/components/ui/sidebar-custom/sidebar-group-label.svelte.d.ts +11 -0
- package/dist/components/ui/sidebar-custom/sidebar-group.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-group.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-header.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-header.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-input.svelte +24 -0
- package/dist/components/ui/sidebar-custom/sidebar-input.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar-custom/sidebar-inset.svelte +22 -0
- package/dist/components/ui/sidebar-custom/sidebar-inset.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-action.svelte +40 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-action.svelte.d.ts +12 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-badge.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-badge.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-button.svelte +106 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-button.svelte.d.ts +27 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-item.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-item.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-skeleton.svelte +43 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-skeleton.svelte.d.ts +8 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub-button.svelte +43 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub-button.svelte.d.ts +13 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub-item.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub-item.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub.svelte +23 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu-sub.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu.svelte +26 -0
- package/dist/components/ui/sidebar-custom/sidebar-menu.svelte.d.ts +5 -0
- package/dist/components/ui/sidebar-custom/sidebar-nested-provider.svelte +69 -0
- package/dist/components/ui/sidebar-custom/sidebar-nested-provider.svelte.d.ts +16 -0
- package/dist/components/ui/sidebar-custom/sidebar-provider.svelte +72 -0
- package/dist/components/ui/sidebar-custom/sidebar-provider.svelte.d.ts +15 -0
- package/dist/components/ui/sidebar-custom/sidebar-rail.svelte +44 -0
- package/dist/components/ui/sidebar-custom/sidebar-rail.svelte.d.ts +9 -0
- package/dist/components/ui/sidebar-custom/sidebar-resize.svelte.d.ts +15 -0
- package/dist/components/ui/sidebar-custom/sidebar-resize.svelte.js +131 -0
- package/dist/components/ui/sidebar-custom/sidebar-separator.svelte +22 -0
- package/dist/components/ui/sidebar-custom/sidebar-separator.svelte.d.ts +4 -0
- package/dist/components/ui/sidebar-custom/sidebar-trigger.svelte +86 -0
- package/dist/components/ui/sidebar-custom/sidebar-trigger.svelte.d.ts +10 -0
- package/dist/components/ui/sidebar-custom/sidebar.svelte +102 -0
- package/dist/components/ui/sidebar-custom/sidebar.svelte.d.ts +11 -0
- package/dist/components/ui/table-dnd/index.d.ts +3 -0
- package/dist/components/ui/table-dnd/index.js +3 -0
- package/dist/components/ui/table-dnd/table-dnd-sensors.d.ts +2 -0
- package/dist/components/ui/table-dnd/table-dnd-sensors.js +11 -0
- package/dist/components/ui/table-dnd/table-dnd-utils.d.ts +29 -0
- package/dist/components/ui/table-dnd/table-dnd-utils.js +77 -0
- package/dist/components/ui/table-dnd/table-dnd.css +12 -0
- package/dist/components/ui/table-dnd/table-drag-grip.svelte +63 -0
- package/dist/components/ui/table-dnd/table-drag-grip.svelte.d.ts +17 -0
- package/dist/fuzzy-search.d.ts +12 -0
- package/dist/fuzzy-search.js +22 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/is-mobile.svelte.d.ts +4 -0
- package/dist/hooks/is-mobile.svelte.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/styles.css +11 -0
- package/dist/theme.css +89 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.js +5 -0
- package/package.json +109 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as Sheet from "@lapismd/design-core/shadcn/sheet";
|
|
3
|
+
import { type WithElementRef } from "../../../utils.js";
|
|
4
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
5
|
+
import { SIDEBAR_WIDTH_MOBILE } from "./constants.js";
|
|
6
|
+
import { useSidebar } from "./context.svelte.js";
|
|
7
|
+
import "./sidebar-custom.css";
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
ref = $bindable(null),
|
|
11
|
+
side = "left",
|
|
12
|
+
variant = "sidebar",
|
|
13
|
+
collapsible = "offcanvas",
|
|
14
|
+
class: className,
|
|
15
|
+
children,
|
|
16
|
+
...restProps
|
|
17
|
+
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
18
|
+
side?: "left" | "right";
|
|
19
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
20
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
21
|
+
} = $props();
|
|
22
|
+
|
|
23
|
+
const sidebar = useSidebar();
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
{#if collapsible === "none"}
|
|
27
|
+
<div
|
|
28
|
+
{...restProps}
|
|
29
|
+
data-ui-component="sidebar-custom"
|
|
30
|
+
data-ui-part="sidebar"
|
|
31
|
+
data-slot="sidebar"
|
|
32
|
+
class={className}
|
|
33
|
+
bind:this={ref}
|
|
34
|
+
>
|
|
35
|
+
{@render children?.()}
|
|
36
|
+
</div>
|
|
37
|
+
{:else if sidebar.isMobile}
|
|
38
|
+
<Sheet.Root
|
|
39
|
+
bind:open={() => sidebar.openMobile, (v) => sidebar.setOpenMobile(v)}
|
|
40
|
+
{...restProps}
|
|
41
|
+
>
|
|
42
|
+
<Sheet.Content
|
|
43
|
+
bind:ref
|
|
44
|
+
data-sidebar="sidebar"
|
|
45
|
+
data-ui-component="sidebar-custom"
|
|
46
|
+
data-ui-part="sidebar-content"
|
|
47
|
+
data-slot="sidebar"
|
|
48
|
+
data-mobile="true"
|
|
49
|
+
class={className}
|
|
50
|
+
style="--sidebar-width: {SIDEBAR_WIDTH_MOBILE};"
|
|
51
|
+
{side}
|
|
52
|
+
showCloseButton={false}
|
|
53
|
+
>
|
|
54
|
+
<Sheet.Header class="sr-only">
|
|
55
|
+
<Sheet.Title>Sidebar</Sheet.Title>
|
|
56
|
+
<Sheet.Description>Displays the mobile sidebar.</Sheet.Description>
|
|
57
|
+
</Sheet.Header>
|
|
58
|
+
<div
|
|
59
|
+
data-ui-component="sidebar-custom"
|
|
60
|
+
data-ui-part="sidebar-anon-1"
|
|
61
|
+
data-slot="sidebar-anon-1"
|
|
62
|
+
>
|
|
63
|
+
{@render children?.()}
|
|
64
|
+
</div>
|
|
65
|
+
</Sheet.Content>
|
|
66
|
+
</Sheet.Root>
|
|
67
|
+
{:else}
|
|
68
|
+
<div
|
|
69
|
+
bind:this={ref}
|
|
70
|
+
data-state={sidebar.state}
|
|
71
|
+
data-collapsible={sidebar.state === "collapsed" ? collapsible : ""}
|
|
72
|
+
data-variant={variant}
|
|
73
|
+
data-side={side}
|
|
74
|
+
data-dragging={sidebar.isDraggingRail}
|
|
75
|
+
data-ui-component="sidebar-custom"
|
|
76
|
+
data-ui-part="sidebar"
|
|
77
|
+
data-slot="sidebar"
|
|
78
|
+
>
|
|
79
|
+
<!-- This is what handles the sidebar gap on desktop -->
|
|
80
|
+
<div
|
|
81
|
+
data-ui-component="sidebar-custom"
|
|
82
|
+
data-ui-part="sidebar-gap"
|
|
83
|
+
data-slot="sidebar-gap"
|
|
84
|
+
></div>
|
|
85
|
+
<div
|
|
86
|
+
{...restProps}
|
|
87
|
+
data-ui-component="sidebar-custom"
|
|
88
|
+
data-ui-part="sidebar-container"
|
|
89
|
+
data-slot="sidebar-container"
|
|
90
|
+
class={className}
|
|
91
|
+
>
|
|
92
|
+
<div
|
|
93
|
+
data-sidebar="sidebar"
|
|
94
|
+
data-ui-component="sidebar-custom"
|
|
95
|
+
data-ui-part="sidebar-inner"
|
|
96
|
+
data-slot="sidebar-inner"
|
|
97
|
+
>
|
|
98
|
+
{@render children?.()}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type WithElementRef } from "../../../utils.js";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import "./sidebar-custom.css";
|
|
4
|
+
type $$ComponentProps = WithElementRef<HTMLAttributes<HTMLDivElement>> & {
|
|
5
|
+
side?: "left" | "right";
|
|
6
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
7
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
8
|
+
};
|
|
9
|
+
declare const Sidebar: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
10
|
+
type Sidebar = ReturnType<typeof Sidebar>;
|
|
11
|
+
export default Sidebar;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { tableReorderSensors } from "./table-dnd-sensors.js";
|
|
2
|
+
export { dropIndicatorClasses, isColumnDragSource, isRowDragSource, parseTableDragData, resolveTableDragTargetIndex, tableColDragType, tableRowDragType, type TableDragData, type TableDragSource, type TableReorderNamespace, } from "./table-dnd-utils.js";
|
|
3
|
+
export { default as TableDragGrip } from "./table-drag-grip.svelte";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { tableReorderSensors } from "./table-dnd-sensors.js";
|
|
2
|
+
export { dropIndicatorClasses, isColumnDragSource, isRowDragSource, parseTableDragData, resolveTableDragTargetIndex, tableColDragType, tableRowDragType, } from "./table-dnd-utils.js";
|
|
3
|
+
export { default as TableDragGrip } from "./table-drag-grip.svelte";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PointerActivationConstraints, PointerSensor, } from "@dnd-kit/dom";
|
|
2
|
+
// dnd-kit skips distance constraints for handle drags by default, which makes
|
|
3
|
+
// row/column grip clicks start a drag on mousedown. Require a small move so
|
|
4
|
+
// click-to-select and drag-to-reorder stay distinct.
|
|
5
|
+
export const tableReorderSensors = [
|
|
6
|
+
PointerSensor.configure({
|
|
7
|
+
activationConstraints() {
|
|
8
|
+
return [new PointerActivationConstraints.Distance({ value: 5 })];
|
|
9
|
+
},
|
|
10
|
+
}),
|
|
11
|
+
];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type TableReorderNamespace = "csv" | "markdown" | "settings";
|
|
2
|
+
export type TableDragSource = {
|
|
3
|
+
type: string;
|
|
4
|
+
index: number;
|
|
5
|
+
};
|
|
6
|
+
export type TableDragData = {
|
|
7
|
+
type: string;
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function tableRowDragType(namespace: TableReorderNamespace): string;
|
|
11
|
+
export declare function tableColDragType(namespace: TableReorderNamespace): string;
|
|
12
|
+
export declare function dropIndicatorClasses(dragSource: TableDragSource | null, dragOverIndex: number | null, rowIndex: number, colIndex: number, rowType: string, colType: string): string;
|
|
13
|
+
export declare function isRowDragSource(dragSource: TableDragSource | null, rowIndex: number, rowType: string): boolean;
|
|
14
|
+
export declare function isColumnDragSource(dragSource: TableDragSource | null, colIndex: number, colType: string): boolean;
|
|
15
|
+
export declare function parseTableDragData(operation: {
|
|
16
|
+
id?: string | number;
|
|
17
|
+
data?: unknown;
|
|
18
|
+
} | null | undefined, rowType: string, colType: string): TableDragData | undefined;
|
|
19
|
+
export declare function resolveTableDragTargetIndex(event: {
|
|
20
|
+
canceled?: boolean;
|
|
21
|
+
operation: {
|
|
22
|
+
source?: {
|
|
23
|
+
data?: unknown;
|
|
24
|
+
} | null;
|
|
25
|
+
target?: {
|
|
26
|
+
data?: unknown;
|
|
27
|
+
} | null;
|
|
28
|
+
};
|
|
29
|
+
}, dragOverIndex: number | null, rowType: string, colType: string): number | null;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function tableRowDragType(namespace) {
|
|
2
|
+
return `${namespace}-table-row`;
|
|
3
|
+
}
|
|
4
|
+
export function tableColDragType(namespace) {
|
|
5
|
+
return `${namespace}-table-col`;
|
|
6
|
+
}
|
|
7
|
+
export function dropIndicatorClasses(dragSource, dragOverIndex, rowIndex, colIndex, rowType, colType) {
|
|
8
|
+
if (!dragSource || dragOverIndex === null) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
const classes = [];
|
|
12
|
+
if (dragSource.type === colType && colIndex === dragOverIndex) {
|
|
13
|
+
if (dragOverIndex > dragSource.index) {
|
|
14
|
+
classes.push("is-dragging-right");
|
|
15
|
+
}
|
|
16
|
+
else if (dragOverIndex < dragSource.index) {
|
|
17
|
+
classes.push("is-dragging-left");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (dragSource.type === rowType && rowIndex === dragOverIndex) {
|
|
21
|
+
if (dragOverIndex > dragSource.index) {
|
|
22
|
+
classes.push("is-dragging-bottom");
|
|
23
|
+
}
|
|
24
|
+
else if (dragOverIndex < dragSource.index) {
|
|
25
|
+
classes.push("is-dragging-top");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return classes.join(" ");
|
|
29
|
+
}
|
|
30
|
+
export function isRowDragSource(dragSource, rowIndex, rowType) {
|
|
31
|
+
return dragSource?.type === rowType && dragSource.index === rowIndex;
|
|
32
|
+
}
|
|
33
|
+
export function isColumnDragSource(dragSource, colIndex, colType) {
|
|
34
|
+
return dragSource?.type === colType && dragSource.index === colIndex;
|
|
35
|
+
}
|
|
36
|
+
export function parseTableDragData(operation, rowType, colType) {
|
|
37
|
+
const data = operation?.data;
|
|
38
|
+
if (data &&
|
|
39
|
+
(data.type === rowType || data.type === colType) &&
|
|
40
|
+
typeof data.index === "number") {
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
if (typeof operation?.id !== "string") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const id = operation.id;
|
|
47
|
+
const indexMatches = [...id.matchAll(/:(\d+)(?=$|:)/g)];
|
|
48
|
+
const index = Number(indexMatches.at(-1)?.[1]);
|
|
49
|
+
if (Number.isNaN(index)) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (id.includes("row")) {
|
|
53
|
+
return { type: rowType, index };
|
|
54
|
+
}
|
|
55
|
+
if (id.includes("col")) {
|
|
56
|
+
return { type: colType, index };
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
export function resolveTableDragTargetIndex(event, dragOverIndex, rowType, colType) {
|
|
61
|
+
const source = parseTableDragData(event.operation.source, rowType, colType);
|
|
62
|
+
const target = parseTableDragData(event.operation.target, rowType, colType);
|
|
63
|
+
if (!event.canceled &&
|
|
64
|
+
source &&
|
|
65
|
+
target &&
|
|
66
|
+
target.type === source.type &&
|
|
67
|
+
target.index !== source.index) {
|
|
68
|
+
return target.index;
|
|
69
|
+
}
|
|
70
|
+
if (!event.canceled &&
|
|
71
|
+
source &&
|
|
72
|
+
dragOverIndex !== null &&
|
|
73
|
+
dragOverIndex !== source.index) {
|
|
74
|
+
return dragOverIndex;
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[data-ui-component="table-dnd"] {
|
|
2
|
+
--ui-table-dnd-grip-opacity: 0.7;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[data-ui-component="table-dnd"][data-ui-part="grip"] {
|
|
6
|
+
opacity: var(--ui-table-dnd-grip-opacity);
|
|
7
|
+
cursor: grab;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-ui-component="table-dnd"][data-ui-part="grip"]:active {
|
|
11
|
+
cursor: grabbing;
|
|
12
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createDraggable } from "@dnd-kit/svelte";
|
|
3
|
+
import { Button } from "@lapismd/design-core/shadcn/button";
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import "./table-dnd.css";
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
dragId,
|
|
9
|
+
dragType,
|
|
10
|
+
dragIndex,
|
|
11
|
+
axis,
|
|
12
|
+
class: className = "",
|
|
13
|
+
ariaLabel,
|
|
14
|
+
onclick,
|
|
15
|
+
children,
|
|
16
|
+
markdownHandleAttrs = false,
|
|
17
|
+
}: {
|
|
18
|
+
dragId: string;
|
|
19
|
+
dragType: string;
|
|
20
|
+
dragIndex: number;
|
|
21
|
+
axis: "row" | "col";
|
|
22
|
+
class?: string;
|
|
23
|
+
ariaLabel: string;
|
|
24
|
+
onclick?: (event: MouseEvent) => void;
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
/** When true, emit legacy markdown e2e attributes on the grip button. */
|
|
27
|
+
markdownHandleAttrs?: boolean;
|
|
28
|
+
} = $props();
|
|
29
|
+
|
|
30
|
+
const draggable = createDraggable({
|
|
31
|
+
get id() {
|
|
32
|
+
return dragId;
|
|
33
|
+
},
|
|
34
|
+
get type() {
|
|
35
|
+
return dragType;
|
|
36
|
+
},
|
|
37
|
+
get data() {
|
|
38
|
+
return {
|
|
39
|
+
type: dragType,
|
|
40
|
+
index: dragIndex,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<Button
|
|
47
|
+
variant="ghost"
|
|
48
|
+
size="xs"
|
|
49
|
+
data-grab-handle=""
|
|
50
|
+
data-ui-component="table-dnd"
|
|
51
|
+
data-ui-part="grip"
|
|
52
|
+
class={className}
|
|
53
|
+
aria-label={ariaLabel}
|
|
54
|
+
onclick={(event: MouseEvent) => {
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
onclick?.(event);
|
|
57
|
+
}}
|
|
58
|
+
data-markdown-table-drag-handle={markdownHandleAttrs ? axis : undefined}
|
|
59
|
+
data-markdown-table-drag-index={markdownHandleAttrs ? dragIndex : undefined}
|
|
60
|
+
{@attach draggable.attachHandle}
|
|
61
|
+
>
|
|
62
|
+
{@render children?.()}
|
|
63
|
+
</Button>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import "./table-dnd.css";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
dragId: string;
|
|
5
|
+
dragType: string;
|
|
6
|
+
dragIndex: number;
|
|
7
|
+
axis: "row" | "col";
|
|
8
|
+
class?: string;
|
|
9
|
+
ariaLabel: string;
|
|
10
|
+
onclick?: (event: MouseEvent) => void;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
/** When true, emit legacy markdown e2e attributes on the grip button. */
|
|
13
|
+
markdownHandleAttrs?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const TableDragGrip: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
16
|
+
type TableDragGrip = ReturnType<typeof TableDragGrip>;
|
|
17
|
+
export default TableDragGrip;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FuseOptionKey } from "fuse.js";
|
|
2
|
+
export interface FuzzySearchResult<T> {
|
|
3
|
+
item: T;
|
|
4
|
+
score: number;
|
|
5
|
+
}
|
|
6
|
+
export interface FuzzySearchOptions<T> {
|
|
7
|
+
keys: ReadonlyArray<FuseOptionKey<T>>;
|
|
8
|
+
threshold?: number;
|
|
9
|
+
distance?: number;
|
|
10
|
+
minMatchCharLength?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function fuzzySearch<T>(items: readonly T[], query: string, options: FuzzySearchOptions<T>): FuzzySearchResult<T>[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Fuse, {} from "fuse.js";
|
|
2
|
+
const DEFAULT_THRESHOLD = 0.4;
|
|
3
|
+
const DEFAULT_DISTANCE = 100;
|
|
4
|
+
const DEFAULT_MIN_MATCH_CHAR_LENGTH = 2;
|
|
5
|
+
export function fuzzySearch(items, query, options) {
|
|
6
|
+
const normalizedQuery = query.trim();
|
|
7
|
+
if (!normalizedQuery) {
|
|
8
|
+
return items.map((item) => ({ item, score: 1 }));
|
|
9
|
+
}
|
|
10
|
+
const fuse = new Fuse(items, {
|
|
11
|
+
keys: [...options.keys],
|
|
12
|
+
includeScore: true,
|
|
13
|
+
threshold: options.threshold ?? DEFAULT_THRESHOLD,
|
|
14
|
+
distance: options.distance ?? DEFAULT_DISTANCE,
|
|
15
|
+
ignoreLocation: true,
|
|
16
|
+
minMatchCharLength: options.minMatchCharLength ?? DEFAULT_MIN_MATCH_CHAR_LENGTH,
|
|
17
|
+
});
|
|
18
|
+
return fuse.search(normalizedQuery).map((result) => ({
|
|
19
|
+
item: result.item,
|
|
20
|
+
score: 1 - (result.score ?? 1),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./is-mobile.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./is-mobile.svelte";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/styles.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alias-only entry for hosts that import `@lapis-notes/ui/styles.css`.
|
|
3
|
+
*
|
|
4
|
+
* Brand palette and semantic tokens come from design-core:
|
|
5
|
+
* @import "@lapismd/design-core/styles.css";
|
|
6
|
+
* @import "@lapismd/design-core/themes/lapis.css";
|
|
7
|
+
*
|
|
8
|
+
* Do not re-import Tailwind or redefine --primary / --destructive here.
|
|
9
|
+
* Storybook host Tailwind is for demo layout only — not component paint.
|
|
10
|
+
*/
|
|
11
|
+
@import "./theme.css";
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin Obsidian/Lapis compatibility aliases → design-core semantic tokens.
|
|
3
|
+
*
|
|
4
|
+
* Brand palette lives in `@lapismd/design-core/themes/lapis.css`
|
|
5
|
+
* (`data-ui-theme="lapis"`). Do not redefine --primary / --destructive here.
|
|
6
|
+
*/
|
|
7
|
+
:root,
|
|
8
|
+
[data-ui-theme="lapis"] {
|
|
9
|
+
--ui-control-height: var(--ui-workspace-settings-control-height, 30px);
|
|
10
|
+
--ui-control-radius: var(--ui-workspace-settings-control-radius, 6px);
|
|
11
|
+
|
|
12
|
+
/* Text */
|
|
13
|
+
--text-normal: var(--foreground);
|
|
14
|
+
--text-muted: var(--muted-foreground);
|
|
15
|
+
--text-faint: var(--muted-foreground);
|
|
16
|
+
--text-on-accent: var(--primary-foreground);
|
|
17
|
+
--text-on-accent-inverted: var(--foreground);
|
|
18
|
+
--text-error: var(--destructive);
|
|
19
|
+
--text-warning: var(--warning, #ec7500);
|
|
20
|
+
--text-success: var(--success, #08b94e);
|
|
21
|
+
--text-accent: var(--ring, var(--primary));
|
|
22
|
+
--text-accent-hover: var(--primary);
|
|
23
|
+
--text-selection: var(--ui-workspace-selection, color-mix(in srgb, var(--ring) 20%, transparent));
|
|
24
|
+
|
|
25
|
+
/* Surfaces */
|
|
26
|
+
--background-primary: var(--background);
|
|
27
|
+
--background-primary-alt: var(--card);
|
|
28
|
+
--background-secondary: var(--muted);
|
|
29
|
+
--background-secondary-alt: var(--card);
|
|
30
|
+
--background-modifier-hover: color-mix(in srgb, var(--foreground) 6.7%, transparent);
|
|
31
|
+
--background-modifier-active-hover: color-mix(in srgb, var(--ring) 10%, transparent);
|
|
32
|
+
--background-modifier-border: var(--border);
|
|
33
|
+
--background-modifier-border-hover: var(--input);
|
|
34
|
+
--background-modifier-border-focus: var(--ring);
|
|
35
|
+
--background-modifier-error: var(--destructive);
|
|
36
|
+
--background-modifier-error-hover: var(--destructive);
|
|
37
|
+
--background-modifier-success: var(--success, #08b94e);
|
|
38
|
+
--background-modifier-form-field: var(--background);
|
|
39
|
+
--background-modifier-form-field-hover: var(--background);
|
|
40
|
+
--background-modifier-cover: color-mix(in srgb, var(--foreground) 12%, transparent);
|
|
41
|
+
--background-modifier-box-shadow: color-mix(in srgb, var(--foreground) 10%, transparent);
|
|
42
|
+
|
|
43
|
+
/* Interactive */
|
|
44
|
+
--interactive-accent-hsl: var(--lapis-accent-hsl, 258, 88%, 66%);
|
|
45
|
+
--interactive-accent: var(--ring, var(--primary));
|
|
46
|
+
--interactive-accent-hover: var(--lapis-accent-hover, var(--primary));
|
|
47
|
+
--interactive-accent-pressed: var(--primary);
|
|
48
|
+
--interactive-normal: var(--background);
|
|
49
|
+
--interactive-hover: var(--muted);
|
|
50
|
+
|
|
51
|
+
/* Controls */
|
|
52
|
+
--input-height: var(--ui-control-height);
|
|
53
|
+
--input-radius: var(--ui-control-radius);
|
|
54
|
+
--radius-s: var(--ui-workspace-radius-small, 4px);
|
|
55
|
+
--radius-m: var(--ui-workspace-radius-medium, 8px);
|
|
56
|
+
--radius-l: var(--ui-workspace-radius-large, 12px);
|
|
57
|
+
--divider-color: var(--border);
|
|
58
|
+
--divider-color-hover: var(--ring, var(--primary));
|
|
59
|
+
--divider-width: 1px;
|
|
60
|
+
--shadow-s: none;
|
|
61
|
+
--shadow-l: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Mira's Obsidian-compatible surfaces keep their portable palette when used
|
|
66
|
+
* alone. Inside Lapis, align interaction paint with design-core's semantic
|
|
67
|
+
* brand tokens so portaled and consumer-composed previews resolve identically.
|
|
68
|
+
*/
|
|
69
|
+
[data-ui-theme="lapis"] [data-mira-theme~="obsidian"],
|
|
70
|
+
[data-ui-theme="lapis"][data-mira-theme~="obsidian"] {
|
|
71
|
+
--mira-accent: var(--ui-workspace-focus-ring);
|
|
72
|
+
--mira-accent-foreground: var(--ui-workspace-accent-foreground);
|
|
73
|
+
--mira-accent-soft: var(--ui-workspace-selection);
|
|
74
|
+
--mira-focus-ring: var(--ui-workspace-focus-ring);
|
|
75
|
+
--mira-selection: var(--ui-workspace-selection);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.dark,
|
|
79
|
+
.theme-dark,
|
|
80
|
+
.dark [data-ui-theme="lapis"],
|
|
81
|
+
[data-ui-theme="lapis"].dark {
|
|
82
|
+
--interactive-normal: var(--muted);
|
|
83
|
+
--interactive-hover: var(--accent);
|
|
84
|
+
--text-accent: var(--lapis-accent-hover, var(--ring));
|
|
85
|
+
--interactive-accent: var(--lapis-accent, var(--ring));
|
|
86
|
+
--interactive-accent-hover: var(--lapis-accent-hover, var(--primary));
|
|
87
|
+
--background-modifier-form-field: var(--card);
|
|
88
|
+
--background-modifier-cover: color-mix(in srgb, var(--background) 60%, transparent);
|
|
89
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClassValue } from "clsx";
|
|
2
|
+
export declare function cn(...inputs: ClassValue[]): string;
|
|
3
|
+
export type WithoutChild<T> = T extends {
|
|
4
|
+
child?: any;
|
|
5
|
+
} ? Omit<T, "child"> : T;
|
|
6
|
+
export type WithoutChildren<T> = T extends {
|
|
7
|
+
children?: any;
|
|
8
|
+
} ? Omit<T, "children"> : T;
|
|
9
|
+
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
|
10
|
+
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & {
|
|
11
|
+
ref?: U | null;
|
|
12
|
+
};
|
package/dist/utils.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lapis-notes/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Public UI primitives required by Lapis Notes API consumers",
|
|
5
|
+
"license": "AGPL-3.0-or-later",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lapismd/lapis-notes.git",
|
|
9
|
+
"directory": "packages/ui"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/lapismd/lapis-notes/tree/main/packages/ui#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/lapismd/lapis-notes/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"files": [
|
|
20
|
+
"CHANGELOG.md",
|
|
21
|
+
"dist",
|
|
22
|
+
"LICENSE.md",
|
|
23
|
+
"README.md",
|
|
24
|
+
"src/lib/internal",
|
|
25
|
+
"!dist/**/*.test.*",
|
|
26
|
+
"!dist/**/*.spec.*"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"**/*.css"
|
|
30
|
+
],
|
|
31
|
+
"svelte": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"svelte": "./dist/index.js",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./theme.css": {
|
|
41
|
+
"default": "./dist/theme.css"
|
|
42
|
+
},
|
|
43
|
+
"./styles.css": {
|
|
44
|
+
"default": "./dist/styles.css"
|
|
45
|
+
},
|
|
46
|
+
"./codemirror-autocomplete.css": {
|
|
47
|
+
"default": "./dist/codemirror-autocomplete.css"
|
|
48
|
+
},
|
|
49
|
+
"./table-dnd/utils": {
|
|
50
|
+
"types": "./dist/components/ui/table-dnd/table-dnd-utils.d.ts",
|
|
51
|
+
"import": "./dist/components/ui/table-dnd/table-dnd-utils.js",
|
|
52
|
+
"default": "./dist/components/ui/table-dnd/table-dnd-utils.js"
|
|
53
|
+
},
|
|
54
|
+
"./table-dnd/sensors": {
|
|
55
|
+
"types": "./dist/components/ui/table-dnd/table-dnd-sensors.d.ts",
|
|
56
|
+
"import": "./dist/components/ui/table-dnd/table-dnd-sensors.js",
|
|
57
|
+
"default": "./dist/components/ui/table-dnd/table-dnd-sensors.js"
|
|
58
|
+
},
|
|
59
|
+
"./*": {
|
|
60
|
+
"types": "./dist/components/ui/*/index.d.ts",
|
|
61
|
+
"svelte": "./dist/components/ui/*/index.js",
|
|
62
|
+
"import": "./dist/components/ui/*/index.js",
|
|
63
|
+
"default": "./dist/components/ui/*/index.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"svelte": "^5.0.0",
|
|
68
|
+
"@lapismd/design-core": "^0.1.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@internationalized/date": "^3.8.2",
|
|
72
|
+
"@lucide/svelte": "^0.515.0",
|
|
73
|
+
"@sveltejs/package": "^2.5.0",
|
|
74
|
+
"@sveltejs/vite-plugin-svelte": "^5.1.1",
|
|
75
|
+
"@tailwindcss/vite": "^4.1.12",
|
|
76
|
+
"@tanstack/table-core": "^8.21.3",
|
|
77
|
+
"@tsconfig/svelte": "^5.0.5",
|
|
78
|
+
"bits-ui": "2.18.1",
|
|
79
|
+
"clsx": "^2.1.1",
|
|
80
|
+
"mode-watcher": "^1.1.0",
|
|
81
|
+
"paneforge": "^1.0.2",
|
|
82
|
+
"publint": "^0.3.12",
|
|
83
|
+
"svelte": "^5.38.2",
|
|
84
|
+
"svelte-check": "^4.3.1",
|
|
85
|
+
"svelte-sonner": "^1.0.5",
|
|
86
|
+
"tailwind-merge": "^3.3.1",
|
|
87
|
+
"tailwind-variants": "^1.0.0",
|
|
88
|
+
"tailwindcss": "^4.1.12",
|
|
89
|
+
"tw-animate-css": "^1.3.7",
|
|
90
|
+
"typescript": "~5.8.3",
|
|
91
|
+
"vite": "^6.4.2",
|
|
92
|
+
"vitest": "^4.1.8"
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"@dnd-kit/dom": "^0.4.0",
|
|
96
|
+
"@dnd-kit/svelte": "^0.4.0",
|
|
97
|
+
"@lapismd/design-core": "^0.1.0",
|
|
98
|
+
"fuse.js": "^7.3.0"
|
|
99
|
+
},
|
|
100
|
+
"scripts": {
|
|
101
|
+
"build": "pnpm run prepack",
|
|
102
|
+
"check": "pnpm --dir ../.. check:no-tailwind packages/ui/src/lib/components && pnpm check:svelte && pnpm check:types",
|
|
103
|
+
"check:svelte": "svelte-check --tsconfig ./tsconfig.app.json --fail-on-warnings --output human",
|
|
104
|
+
"check:types": "tsc -p tsconfig.node.json --noEmit",
|
|
105
|
+
"dev": "pnpm --dir ../.. storybook",
|
|
106
|
+
"storybook": "pnpm --dir ../.. storybook",
|
|
107
|
+
"test": "vitest run"
|
|
108
|
+
}
|
|
109
|
+
}
|