@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.
Files changed (100) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE.md +4 -0
  3. package/README.md +46 -0
  4. package/dist/codemirror-autocomplete.css +223 -0
  5. package/dist/command-fuzzy-filter.d.ts +15 -0
  6. package/dist/command-fuzzy-filter.js +27 -0
  7. package/dist/components/ui/confirm-dialog/confirm-dialog.css +11 -0
  8. package/dist/components/ui/confirm-dialog/confirm-dialog.svelte +94 -0
  9. package/dist/components/ui/confirm-dialog/confirm-dialog.svelte.d.ts +18 -0
  10. package/dist/components/ui/confirm-dialog/index.d.ts +3 -0
  11. package/dist/components/ui/confirm-dialog/index.js +3 -0
  12. package/dist/components/ui/modal/index.d.ts +3 -0
  13. package/dist/components/ui/modal/index.js +3 -0
  14. package/dist/components/ui/modal/modal.css +16 -0
  15. package/dist/components/ui/modal/modal.svelte +74 -0
  16. package/dist/components/ui/modal/modal.svelte.d.ts +16 -0
  17. package/dist/components/ui/search/index.d.ts +3 -0
  18. package/dist/components/ui/search/index.js +3 -0
  19. package/dist/components/ui/search/search.css +55 -0
  20. package/dist/components/ui/search/search.svelte +54 -0
  21. package/dist/components/ui/search/search.svelte.d.ts +10 -0
  22. package/dist/components/ui/sidebar-custom/constants.d.ts +6 -0
  23. package/dist/components/ui/sidebar-custom/constants.js +6 -0
  24. package/dist/components/ui/sidebar-custom/context.svelte.d.ts +49 -0
  25. package/dist/components/ui/sidebar-custom/context.svelte.js +68 -0
  26. package/dist/components/ui/sidebar-custom/index.d.ts +26 -0
  27. package/dist/components/ui/sidebar-custom/index.js +28 -0
  28. package/dist/components/ui/sidebar-custom/sidebar-content.svelte +23 -0
  29. package/dist/components/ui/sidebar-custom/sidebar-content.svelte.d.ts +5 -0
  30. package/dist/components/ui/sidebar-custom/sidebar-custom.css +1357 -0
  31. package/dist/components/ui/sidebar-custom/sidebar-footer.svelte +23 -0
  32. package/dist/components/ui/sidebar-custom/sidebar-footer.svelte.d.ts +5 -0
  33. package/dist/components/ui/sidebar-custom/sidebar-group-action.svelte +37 -0
  34. package/dist/components/ui/sidebar-custom/sidebar-group-action.svelte.d.ts +11 -0
  35. package/dist/components/ui/sidebar-custom/sidebar-group-content.svelte +23 -0
  36. package/dist/components/ui/sidebar-custom/sidebar-group-content.svelte.d.ts +5 -0
  37. package/dist/components/ui/sidebar-custom/sidebar-group-label.svelte +37 -0
  38. package/dist/components/ui/sidebar-custom/sidebar-group-label.svelte.d.ts +11 -0
  39. package/dist/components/ui/sidebar-custom/sidebar-group.svelte +23 -0
  40. package/dist/components/ui/sidebar-custom/sidebar-group.svelte.d.ts +5 -0
  41. package/dist/components/ui/sidebar-custom/sidebar-header.svelte +23 -0
  42. package/dist/components/ui/sidebar-custom/sidebar-header.svelte.d.ts +5 -0
  43. package/dist/components/ui/sidebar-custom/sidebar-input.svelte +24 -0
  44. package/dist/components/ui/sidebar-custom/sidebar-input.svelte.d.ts +4 -0
  45. package/dist/components/ui/sidebar-custom/sidebar-inset.svelte +22 -0
  46. package/dist/components/ui/sidebar-custom/sidebar-inset.svelte.d.ts +5 -0
  47. package/dist/components/ui/sidebar-custom/sidebar-menu-action.svelte +40 -0
  48. package/dist/components/ui/sidebar-custom/sidebar-menu-action.svelte.d.ts +12 -0
  49. package/dist/components/ui/sidebar-custom/sidebar-menu-badge.svelte +23 -0
  50. package/dist/components/ui/sidebar-custom/sidebar-menu-badge.svelte.d.ts +5 -0
  51. package/dist/components/ui/sidebar-custom/sidebar-menu-button.svelte +106 -0
  52. package/dist/components/ui/sidebar-custom/sidebar-menu-button.svelte.d.ts +27 -0
  53. package/dist/components/ui/sidebar-custom/sidebar-menu-item.svelte +23 -0
  54. package/dist/components/ui/sidebar-custom/sidebar-menu-item.svelte.d.ts +5 -0
  55. package/dist/components/ui/sidebar-custom/sidebar-menu-skeleton.svelte +43 -0
  56. package/dist/components/ui/sidebar-custom/sidebar-menu-skeleton.svelte.d.ts +8 -0
  57. package/dist/components/ui/sidebar-custom/sidebar-menu-sub-button.svelte +43 -0
  58. package/dist/components/ui/sidebar-custom/sidebar-menu-sub-button.svelte.d.ts +13 -0
  59. package/dist/components/ui/sidebar-custom/sidebar-menu-sub-item.svelte +23 -0
  60. package/dist/components/ui/sidebar-custom/sidebar-menu-sub-item.svelte.d.ts +5 -0
  61. package/dist/components/ui/sidebar-custom/sidebar-menu-sub.svelte +23 -0
  62. package/dist/components/ui/sidebar-custom/sidebar-menu-sub.svelte.d.ts +5 -0
  63. package/dist/components/ui/sidebar-custom/sidebar-menu.svelte +26 -0
  64. package/dist/components/ui/sidebar-custom/sidebar-menu.svelte.d.ts +5 -0
  65. package/dist/components/ui/sidebar-custom/sidebar-nested-provider.svelte +69 -0
  66. package/dist/components/ui/sidebar-custom/sidebar-nested-provider.svelte.d.ts +16 -0
  67. package/dist/components/ui/sidebar-custom/sidebar-provider.svelte +72 -0
  68. package/dist/components/ui/sidebar-custom/sidebar-provider.svelte.d.ts +15 -0
  69. package/dist/components/ui/sidebar-custom/sidebar-rail.svelte +44 -0
  70. package/dist/components/ui/sidebar-custom/sidebar-rail.svelte.d.ts +9 -0
  71. package/dist/components/ui/sidebar-custom/sidebar-resize.svelte.d.ts +15 -0
  72. package/dist/components/ui/sidebar-custom/sidebar-resize.svelte.js +131 -0
  73. package/dist/components/ui/sidebar-custom/sidebar-separator.svelte +22 -0
  74. package/dist/components/ui/sidebar-custom/sidebar-separator.svelte.d.ts +4 -0
  75. package/dist/components/ui/sidebar-custom/sidebar-trigger.svelte +86 -0
  76. package/dist/components/ui/sidebar-custom/sidebar-trigger.svelte.d.ts +10 -0
  77. package/dist/components/ui/sidebar-custom/sidebar.svelte +102 -0
  78. package/dist/components/ui/sidebar-custom/sidebar.svelte.d.ts +11 -0
  79. package/dist/components/ui/table-dnd/index.d.ts +3 -0
  80. package/dist/components/ui/table-dnd/index.js +3 -0
  81. package/dist/components/ui/table-dnd/table-dnd-sensors.d.ts +2 -0
  82. package/dist/components/ui/table-dnd/table-dnd-sensors.js +11 -0
  83. package/dist/components/ui/table-dnd/table-dnd-utils.d.ts +29 -0
  84. package/dist/components/ui/table-dnd/table-dnd-utils.js +77 -0
  85. package/dist/components/ui/table-dnd/table-dnd.css +12 -0
  86. package/dist/components/ui/table-dnd/table-drag-grip.svelte +63 -0
  87. package/dist/components/ui/table-dnd/table-drag-grip.svelte.d.ts +17 -0
  88. package/dist/fuzzy-search.d.ts +12 -0
  89. package/dist/fuzzy-search.js +22 -0
  90. package/dist/hooks/index.d.ts +1 -0
  91. package/dist/hooks/index.js +1 -0
  92. package/dist/hooks/is-mobile.svelte.d.ts +4 -0
  93. package/dist/hooks/is-mobile.svelte.js +7 -0
  94. package/dist/index.d.ts +4 -0
  95. package/dist/index.js +4 -0
  96. package/dist/styles.css +11 -0
  97. package/dist/theme.css +89 -0
  98. package/dist/utils.d.ts +12 -0
  99. package/dist/utils.js +5 -0
  100. package/package.json +109 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @lapis-notes/ui
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - First public npm release of the Lapis Notes Svelte UI primitives, including
8
+ shared search, modal, confirmation dialog, sidebar customisation, table drag
9
+ and drop helpers, and package CSS entrypoints.
package/LICENSE.md ADDED
@@ -0,0 +1,4 @@
1
+ AGPL-3.0-or-later
2
+
3
+ This package is licensed under the GNU Affero General Public License v3.0 or later.
4
+ See <https://www.gnu.org/licenses/agpl-3.0.en.html>.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @lapis-notes/ui
2
+
3
+ Shared Svelte UI primitives for Lapis Notes package consumers.
4
+
5
+ This package contains the small public UI surface required by
6
+ `@lapis-notes/api`, the workspace shell, and separately versioned plugins. It
7
+ owns reusable presentation primitives only; vault state, routing, plugin
8
+ lifecycle, persistence, and application policy stay in API or host packages.
9
+
10
+ ## Public surface
11
+
12
+ - Root helpers for class merging, fuzzy search, command filtering, and Svelte
13
+ hooks.
14
+ - CSS entrypoints: `theme.css`, `styles.css`, and
15
+ `codemirror-autocomplete.css`.
16
+ - Component subpaths for search, modal, confirm-dialog, sidebar-custom, and
17
+ table-dnd.
18
+ - Table drag-and-drop utility and sensor subpaths for consumers that need only
19
+ the non-component helpers.
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import "@lapis-notes/ui/theme.css";
25
+ import "@lapis-notes/ui/styles.css";
26
+
27
+ import { cn } from "@lapis-notes/ui";
28
+ import Search from "@lapis-notes/ui/search";
29
+ import { TableDragGrip } from "@lapis-notes/ui/table-dnd";
30
+ ```
31
+
32
+ `@lapismd/design-core` and Svelte are peers for the public UI contract. Install
33
+ matching published npm versions in standalone consumers.
34
+
35
+ ## Common Scripts
36
+
37
+ ```sh
38
+ pnpm --filter @lapis-notes/ui dev
39
+ pnpm --filter @lapis-notes/ui build
40
+ pnpm --filter @lapis-notes/ui check
41
+ ```
42
+
43
+ ## References
44
+
45
+ - [Package spec](spec.md)
46
+ - [Canonical spec](../../spec/src/20-packages/ui/index.md)
@@ -0,0 +1,223 @@
1
+ /**
2
+ * CodeMirror 6 autocomplete tooltips (`.cm-tooltip-autocomplete`, completion
3
+ * info). Native CSS keeps this public stylesheet usable by every Lapis host
4
+ * after Design Core styles and mirrors its Popover / Command surface language.
5
+ */
6
+
7
+ .cm-tooltip.cm-tooltip-autocomplete {
8
+ box-sizing: border-box;
9
+ max-width: 28rem;
10
+ border: 0;
11
+ border-radius: var(
12
+ --ui-popover-radius,
13
+ var(--radius-md, var(--radius, 0.5rem))
14
+ );
15
+ background-color: var(
16
+ --ui-popover-background,
17
+ var(--popover, var(--background))
18
+ );
19
+ color: var(
20
+ --ui-popover-foreground,
21
+ var(--popover-foreground, var(--foreground))
22
+ );
23
+ padding: 0.25rem;
24
+ box-shadow:
25
+ 0 0 0 1px var(--ui-popover-border-color, var(--border)),
26
+ var(
27
+ --shadow-md,
28
+ 0 4px 6px -1px rgb(0 0 0 / 0.1),
29
+ 0 2px 4px -2px rgb(0 0 0 / 0.1)
30
+ );
31
+ }
32
+
33
+ .cm-tooltip.cm-tooltip-autocomplete > ul {
34
+ max-height: 250px;
35
+ margin: 0;
36
+ font-family: var(--font-sans, inherit);
37
+ font-size: inherit;
38
+ }
39
+
40
+ .cm-tooltip.cm-completionInfo {
41
+ box-sizing: border-box;
42
+ aspect-ratio: 5 / 3;
43
+ width: 24rem;
44
+ max-width: none;
45
+ overflow: hidden;
46
+ border: 0;
47
+ border-radius: var(
48
+ --ui-popover-radius,
49
+ var(--radius-md, var(--radius, 0.5rem))
50
+ );
51
+ background-color: var(
52
+ --ui-popover-background,
53
+ var(--popover, var(--background))
54
+ );
55
+ color: var(
56
+ --ui-popover-foreground,
57
+ var(--popover-foreground, var(--foreground))
58
+ );
59
+ padding: 0.5rem 0.75rem;
60
+ font-family: var(--font-mono, ui-monospace, monospace);
61
+ font-size: inherit;
62
+ white-space: pre-wrap;
63
+ word-break: break-word;
64
+ box-shadow:
65
+ 0 0 0 1px var(--ui-popover-border-color, var(--border)),
66
+ var(
67
+ --shadow-md,
68
+ 0 4px 6px -1px rgb(0 0 0 / 0.1),
69
+ 0 2px 4px -2px rgb(0 0 0 / 0.1)
70
+ );
71
+ }
72
+
73
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li {
74
+ display: flex;
75
+ flex-direction: column;
76
+ margin-block-end: 0.25rem;
77
+ border-radius: calc(var(--radius, 0.5rem) * 0.6);
78
+ background-color: var(
79
+ --ui-popover-background,
80
+ var(--popover, var(--background))
81
+ );
82
+ padding: 0.25rem 0.5rem;
83
+ }
84
+
85
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li:hover,
86
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected="true"] {
87
+ background-color: var(--accent);
88
+ color: var(--foreground);
89
+ }
90
+
91
+ .cm-editor
92
+ .cm-tooltip.cm-tooltip-autocomplete
93
+ > ul
94
+ > li.cm-autocomplete-heading {
95
+ flex-direction: row;
96
+ justify-content: space-between;
97
+ }
98
+
99
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li.cm-autocomplete-display {
100
+ display: grid;
101
+ grid-template-columns: 1fr 1fr;
102
+ grid-template-rows: 1fr 1fr;
103
+ }
104
+
105
+ .cm-tooltip.cm-tooltip-autocomplete
106
+ > ul
107
+ > li.cm-autocomplete-display
108
+ > span.cm-completionLabel {
109
+ grid-column: 1;
110
+ grid-row: 1;
111
+ font-weight: 600;
112
+ }
113
+
114
+ .cm-tooltip.cm-tooltip-autocomplete
115
+ > ul
116
+ > li.cm-autocomplete-display
117
+ > span.cm-completionDetail {
118
+ grid-column: 1;
119
+ grid-row: 2;
120
+ }
121
+
122
+ .cm-tooltip.cm-tooltip-autocomplete
123
+ > ul
124
+ > li.cm-autocomplete-display
125
+ > span.suggestion-flair {
126
+ display: flex;
127
+ grid-column: 2;
128
+ grid-row: 1 / 3;
129
+ align-items: center;
130
+ justify-content: end;
131
+ color: var(--muted-foreground);
132
+ }
133
+
134
+ .cm-tooltip.cm-tooltip-autocomplete
135
+ > ul
136
+ > li.cm-autocomplete-display
137
+ > span.suggestion-flair
138
+ svg {
139
+ width: 1rem;
140
+ height: 1rem;
141
+ }
142
+
143
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li .cm-completionDetail {
144
+ margin-left: 0;
145
+ color: var(--muted-foreground);
146
+ font-style: normal;
147
+ }
148
+
149
+ .cm-completionMatchedText {
150
+ text-decoration: none;
151
+ }
152
+
153
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li[role="option"] {
154
+ flex-direction: row;
155
+ align-items: center;
156
+ gap: 0.25rem;
157
+ padding: 0.375rem 0.75rem 0.375rem 0.5rem;
158
+ }
159
+
160
+ .cm-tooltip.cm-tooltip-autocomplete
161
+ > ul
162
+ > li[role="option"]
163
+ > span.cm-completionLabel
164
+ > span.cm-completionMatchedText {
165
+ font-weight: 700;
166
+ text-decoration: none;
167
+ }
168
+
169
+ .cm-tooltip.cm-tooltip-autocomplete > ul > li:last-child {
170
+ margin-block-end: 0;
171
+ }
172
+
173
+ .cm-tooltip.cm-tooltip-autocomplete::after {
174
+ position: absolute;
175
+ right: 0;
176
+ bottom: 0;
177
+ left: 0;
178
+ display: none;
179
+ border-radius: 0 0
180
+ var(--ui-popover-radius, var(--radius-md, var(--radius, 0.5rem)))
181
+ var(--ui-popover-radius, var(--radius-md, var(--radius, 0.5rem)));
182
+ background-color: var(
183
+ --ui-popover-background,
184
+ var(--popover, var(--background))
185
+ );
186
+ padding: 0.5rem 0.75rem;
187
+ box-shadow: 0 0 0 1px var(--ui-popover-border-color, var(--border));
188
+ font-size: 0.75rem;
189
+ text-align: center;
190
+ pointer-events: none;
191
+ }
192
+
193
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.cm-autocomplete-heading)::after,
194
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.cm-autocomplete-display)::after {
195
+ display: block;
196
+ content: "↵ to accept";
197
+ }
198
+
199
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.cm-autocomplete-heading)
200
+ > ul
201
+ > li:last-child,
202
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.cm-autocomplete-display)
203
+ > ul
204
+ > li:last-child {
205
+ margin-block-end: 35px;
206
+ }
207
+
208
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.suggestion-item)::after {
209
+ display: none;
210
+ }
211
+
212
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.suggestion-item)
213
+ > ul
214
+ > li:last-child {
215
+ margin-block-end: 0;
216
+ }
217
+
218
+ .cm-tooltip.cm-tooltip-autocomplete:has(li.suggestion-item)
219
+ > ul
220
+ > li
221
+ > span.cm-completionLabel:empty {
222
+ display: none;
223
+ }
@@ -0,0 +1,15 @@
1
+ import { type FuzzySearchOptions } from "./fuzzy-search.js";
2
+ type CommandFuzzyFilterOptions = Pick<FuzzySearchOptions<{
3
+ text: string;
4
+ }>, "threshold" | "distance" | "minMatchCharLength">;
5
+ /**
6
+ * Returns a per-item Fuse.js scorer for filtering ranked lists and Command
7
+ * items.
8
+ */
9
+ export declare function createFuzzyMatchScore(options?: CommandFuzzyFilterOptions): (value: string, search: string, keywords?: string[]) => number;
10
+ export declare const fuzzyMatchScore: (value: string, search: string, keywords?: string[]) => number;
11
+ /** @alias fuzzyMatchScore */
12
+ export declare const createCommandFuzzyFilter: typeof createFuzzyMatchScore;
13
+ /** @alias fuzzyMatchScore */
14
+ export declare const commandFuzzyFilter: (value: string, search: string, keywords?: string[]) => number;
15
+ export {};
@@ -0,0 +1,27 @@
1
+ import { fuzzySearch } from "./fuzzy-search.js";
2
+ /**
3
+ * Returns a per-item Fuse.js scorer for filtering ranked lists and Command
4
+ * items.
5
+ */
6
+ export function createFuzzyMatchScore(options) {
7
+ return (value, search, keywords = []) => {
8
+ const normalizedQuery = search.trim();
9
+ if (!normalizedQuery) {
10
+ return 1;
11
+ }
12
+ const texts = [value, ...keywords].filter(Boolean);
13
+ if (texts.length === 0) {
14
+ return 0;
15
+ }
16
+ const results = fuzzySearch(texts.map((text) => ({ text })), normalizedQuery, {
17
+ keys: ["text"],
18
+ ...options,
19
+ });
20
+ return results.reduce((best, result) => Math.max(best, result.score), 0);
21
+ };
22
+ }
23
+ export const fuzzyMatchScore = createFuzzyMatchScore();
24
+ /** @alias fuzzyMatchScore */
25
+ export const createCommandFuzzyFilter = createFuzzyMatchScore;
26
+ /** @alias fuzzyMatchScore */
27
+ export const commandFuzzyFilter = fuzzyMatchScore;
@@ -0,0 +1,11 @@
1
+ [data-ui-component="dialog"][data-ui-part="dialog-content"][data-ui-confirm-dialog] {
2
+ --ui-confirm-dialog-max-width: 28rem;
3
+ --ui-confirm-dialog-footer-gap: 0.5rem;
4
+ max-width: var(--ui-confirm-dialog-max-width);
5
+ }
6
+
7
+ [data-ui-component="dialog"][data-ui-part="dialog-content"][data-ui-confirm-dialog]
8
+ [data-ui-part="dialog-footer"] {
9
+ gap: var(--ui-confirm-dialog-footer-gap);
10
+ justify-content: flex-end;
11
+ }
@@ -0,0 +1,94 @@
1
+ <script lang="ts">
2
+ import {
3
+ Button,
4
+ type ButtonVariant,
5
+ } from "@lapismd/design-core/shadcn/button";
6
+ import * as Dialog from "@lapismd/design-core/shadcn/dialog";
7
+ import { Dialog as DialogPrimitive } from "bits-ui";
8
+ import { cn } from "../../../utils";
9
+ import "./confirm-dialog.css";
10
+
11
+ let {
12
+ open = $bindable(false),
13
+ title = "Confirm",
14
+ description = "",
15
+ confirmLabel = "Continue",
16
+ cancelLabel = "Cancel",
17
+ confirmVariant = "default" as ButtonVariant,
18
+ class: className,
19
+ portalProps,
20
+ onConfirm,
21
+ onCancel,
22
+ }: {
23
+ open?: boolean;
24
+ title?: string;
25
+ description?: string;
26
+ confirmLabel?: string;
27
+ cancelLabel?: string;
28
+ confirmVariant?: ButtonVariant;
29
+ class?: string;
30
+ portalProps?: DialogPrimitive.PortalProps;
31
+ onConfirm?: () => void;
32
+ onCancel?: () => void;
33
+ } = $props();
34
+
35
+ let confirming = $state(false);
36
+ let opened = $state(false);
37
+
38
+ function handleOpenChange(nextOpen: boolean): void {
39
+ if (nextOpen) {
40
+ opened = true;
41
+ open = true;
42
+ return;
43
+ }
44
+
45
+ if (!opened) {
46
+ open = false;
47
+ return;
48
+ }
49
+
50
+ if (confirming) {
51
+ confirming = false;
52
+ open = false;
53
+ return;
54
+ }
55
+
56
+ open = false;
57
+ onCancel?.();
58
+ }
59
+
60
+ function handleCancel(): void {
61
+ open = false;
62
+ onCancel?.();
63
+ }
64
+
65
+ function handleConfirm(): void {
66
+ confirming = true;
67
+ onConfirm?.();
68
+ open = false;
69
+ }
70
+ </script>
71
+
72
+ <Dialog.Root {open} onOpenChange={handleOpenChange}>
73
+ <Dialog.Content
74
+ class={cn(className)}
75
+ {portalProps}
76
+ data-ui-confirm-dialog=""
77
+ >
78
+ <Dialog.Header>
79
+ <Dialog.Title>{title}</Dialog.Title>
80
+ {#if description}
81
+ <Dialog.Description>{description}</Dialog.Description>
82
+ {/if}
83
+ </Dialog.Header>
84
+
85
+ <Dialog.Footer>
86
+ <Button onclick={handleCancel} type="button" variant="outline">
87
+ {cancelLabel}
88
+ </Button>
89
+ <Button onclick={handleConfirm} type="button" variant={confirmVariant}>
90
+ {confirmLabel}
91
+ </Button>
92
+ </Dialog.Footer>
93
+ </Dialog.Content>
94
+ </Dialog.Root>
@@ -0,0 +1,18 @@
1
+ import { type ButtonVariant } from "@lapismd/design-core/shadcn/button";
2
+ import { Dialog as DialogPrimitive } from "bits-ui";
3
+ import "./confirm-dialog.css";
4
+ type $$ComponentProps = {
5
+ open?: boolean;
6
+ title?: string;
7
+ description?: string;
8
+ confirmLabel?: string;
9
+ cancelLabel?: string;
10
+ confirmVariant?: ButtonVariant;
11
+ class?: string;
12
+ portalProps?: DialogPrimitive.PortalProps;
13
+ onConfirm?: () => void;
14
+ onCancel?: () => void;
15
+ };
16
+ declare const ConfirmDialog: import("svelte").Component<$$ComponentProps, {}, "open">;
17
+ type ConfirmDialog = ReturnType<typeof ConfirmDialog>;
18
+ export default ConfirmDialog;
@@ -0,0 +1,3 @@
1
+ import Root from "./confirm-dialog.svelte";
2
+ export { Root, Root as ConfirmDialog };
3
+ export default Root;
@@ -0,0 +1,3 @@
1
+ import Root from "./confirm-dialog.svelte";
2
+ export { Root, Root as ConfirmDialog };
3
+ export default Root;
@@ -0,0 +1,3 @@
1
+ import Modal from "./modal.svelte";
2
+ export { Modal, Modal as Root };
3
+ export default Modal;
@@ -0,0 +1,3 @@
1
+ import Modal from "./modal.svelte";
2
+ export { Modal, Modal as Root };
3
+ export default Modal;
@@ -0,0 +1,16 @@
1
+ [data-ui-component="modal"] {
2
+ --ui-modal-width: var(--dialog-width, 560px);
3
+ --ui-modal-max-width: var(--dialog-max-width, 80vw);
4
+ --ui-modal-max-height: var(--dialog-max-height, 85vh);
5
+ }
6
+
7
+ [data-ui-component="modal"][data-ui-part="content"] {
8
+ width: var(--ui-modal-width);
9
+ max-width: var(--ui-modal-max-width);
10
+ max-height: var(--ui-modal-max-height);
11
+ overflow: auto;
12
+ }
13
+
14
+ [data-ui-component="modal"][data-ui-part="body"] {
15
+ min-width: 0;
16
+ }
@@ -0,0 +1,74 @@
1
+ <script lang="ts">
2
+ import { Dialog as DialogPrimitive } from "bits-ui";
3
+ import * as Dialog from "@lapismd/design-core/shadcn/dialog";
4
+ import { cn } from "../../../utils";
5
+ import "./modal.css";
6
+
7
+ let {
8
+ open = $bindable(false),
9
+ modalEl = $bindable(null),
10
+ titleEl = $bindable(null),
11
+ title = "",
12
+ content = "",
13
+ contentEl = $bindable(null),
14
+ class: className,
15
+ onOpenChange,
16
+ portalProps,
17
+ }: {
18
+ open?: boolean;
19
+ class?: string;
20
+ titleEl?: HTMLElement | null;
21
+ title?: string | DocumentFragment;
22
+ content?: string | DocumentFragment;
23
+ contentEl?: HTMLElement | null;
24
+ modalEl?: HTMLElement | null;
25
+ onOpenChange?: (open: boolean) => void;
26
+ portalProps?: DialogPrimitive.PortalProps;
27
+ } = $props();
28
+
29
+ function renderContent(
30
+ el: HTMLDivElement,
31
+ content: string | DocumentFragment,
32
+ ) {
33
+ syncContent(el, content);
34
+ return {
35
+ update(content: string | DocumentFragment) {
36
+ syncContent(el, content);
37
+ },
38
+ };
39
+ }
40
+
41
+ function syncContent(
42
+ el: HTMLDivElement,
43
+ content: string | DocumentFragment,
44
+ ): void {
45
+ el.replaceChildren();
46
+ if (typeof content === "string") {
47
+ el.textContent = content;
48
+ return;
49
+ }
50
+ el.append(content.cloneNode(true));
51
+ }
52
+ </script>
53
+
54
+ <Dialog.Root bind:open {onOpenChange}>
55
+ <Dialog.Content
56
+ bind:ref={modalEl}
57
+ {portalProps}
58
+ dataUiComponent="modal"
59
+ dataUiPart="content"
60
+ class={cn(className)}
61
+ >
62
+ <Dialog.Header>
63
+ <Dialog.Title>
64
+ <div bind:this={titleEl} use:renderContent={title}></div>
65
+ </Dialog.Title>
66
+ </Dialog.Header>
67
+ <div
68
+ data-ui-component="modal"
69
+ data-ui-part="body"
70
+ bind:this={contentEl}
71
+ use:renderContent={content}
72
+ ></div>
73
+ </Dialog.Content>
74
+ </Dialog.Root>
@@ -0,0 +1,16 @@
1
+ import { Dialog as DialogPrimitive } from "bits-ui";
2
+ import "./modal.css";
3
+ type $$ComponentProps = {
4
+ open?: boolean;
5
+ class?: string;
6
+ titleEl?: HTMLElement | null;
7
+ title?: string | DocumentFragment;
8
+ content?: string | DocumentFragment;
9
+ contentEl?: HTMLElement | null;
10
+ modalEl?: HTMLElement | null;
11
+ onOpenChange?: (open: boolean) => void;
12
+ portalProps?: DialogPrimitive.PortalProps;
13
+ };
14
+ declare const Modal: import("svelte").Component<$$ComponentProps, {}, "open" | "modalEl" | "titleEl" | "contentEl">;
15
+ type Modal = ReturnType<typeof Modal>;
16
+ export default Modal;
@@ -0,0 +1,3 @@
1
+ import Root from "./search.svelte";
2
+ export { Root, Root as Search };
3
+ export default Root;
@@ -0,0 +1,3 @@
1
+ import Root from "./search.svelte";
2
+ export { Root, Root as Search };
3
+ export default Root;
@@ -0,0 +1,55 @@
1
+ [data-ui-component="search"] {
2
+ --ui-search-height: var(--input-height, var(--ui-control-height, 30px));
3
+ --ui-search-radius: var(--input-radius, var(--ui-control-radius, 6px));
4
+ --ui-search-border: var(--input, var(--border));
5
+ --ui-search-ring: var(--ring, var(--background-modifier-border-focus, var(--primary)));
6
+ --ui-search-icon-opacity: 0.5;
7
+ --ui-search-icon-size: 1rem;
8
+ --ui-search-icon-gap: 0.5rem;
9
+ --ui-search-padding-inline: 0.75rem;
10
+ }
11
+
12
+ [data-ui-component="search"][data-ui-part="root"] {
13
+ display: flex;
14
+ align-items: center;
15
+ width: 100%;
16
+ height: var(--ui-search-height);
17
+ padding-inline: var(--ui-search-padding-inline);
18
+ border: 1px solid var(--ui-search-border);
19
+ border-radius: var(--ui-search-radius);
20
+ transition: box-shadow 150ms ease;
21
+ }
22
+
23
+ [data-ui-component="search"][data-ui-part="root"]:focus-within {
24
+ box-shadow: 0 0 0 2px var(--ui-search-ring);
25
+ }
26
+
27
+ [data-ui-component="search"][data-ui-part="icon"] {
28
+ flex-shrink: 0;
29
+ width: var(--ui-search-icon-size);
30
+ height: var(--ui-search-icon-size);
31
+ margin-inline-end: var(--ui-search-icon-gap);
32
+ opacity: var(--ui-search-icon-opacity);
33
+ }
34
+
35
+ [data-ui-component="search"][data-ui-part="field"] {
36
+ display: flex;
37
+ align-items: center;
38
+ flex: 1 1 0%;
39
+ min-width: 0;
40
+ height: 100%;
41
+ }
42
+
43
+ [data-ui-component="search"][data-ui-part="field"] [data-ui-component="input"] {
44
+ height: 100%;
45
+ border: none;
46
+ background: transparent;
47
+ padding-block: 0;
48
+ padding-inline-start: 0;
49
+ box-shadow: none;
50
+ }
51
+
52
+ [data-ui-component="search"][data-ui-part="field"] [data-ui-component="input"]:focus-visible {
53
+ outline: none;
54
+ box-shadow: none;
55
+ }