@svadmin/ui 0.25.2 → 0.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svadmin/ui",
3
- "version": "0.25.2",
3
+ "version": "0.26.0",
4
4
  "description": "Pre-built admin UI components — AdminApp, AutoTable, AutoForm, Sidebar, Layout",
5
5
  "type": "module",
6
6
  "sideEffects": [
package/src/app.css CHANGED
@@ -34,8 +34,8 @@
34
34
  --accent-foreground: oklch(0.2 0.04 265);
35
35
  --destructive: oklch(0.577 0.245 27.325);
36
36
  --destructive-foreground: oklch(0.985 0 0);
37
- --border: oklch(0.912 0.008 264);
38
- --input: oklch(0.912 0.008 264);
37
+ --border: oklch(0.935 0.005 264);
38
+ --input: oklch(0.935 0.005 264);
39
39
  --ring: oklch(0.488 0.243 264.376);
40
40
  --chart-1: oklch(0.488 0.243 264.376);
41
41
  --chart-2: oklch(0.6 0.118 184.704);
@@ -54,7 +54,7 @@
54
54
  --sidebar-primary-foreground: oklch(0.985 0 0);
55
55
  --sidebar-accent: oklch(0.94 0.025 264);
56
56
  --sidebar-accent-foreground: oklch(0.33 0.17 264);
57
- --sidebar-border: oklch(0.912 0.008 264);
57
+ --sidebar-border: oklch(0.935 0.005 264);
58
58
  --sidebar-ring: oklch(0.488 0.243 264.376);
59
59
  }
60
60
 
@@ -75,8 +75,8 @@
75
75
  --accent-foreground: oklch(0.985 0 0);
76
76
  --destructive: oklch(0.704 0.191 22.216);
77
77
  --destructive-foreground: oklch(0.985 0 0);
78
- --border: oklch(0.23 0.025 265);
79
- --input: oklch(0.23 0.025 265);
78
+ --border: oklch(0.27 0.02 265);
79
+ --input: oklch(0.27 0.02 265);
80
80
  --ring: oklch(0.55 0.18 264);
81
81
  --chart-1: oklch(0.585 0.233 264);
82
82
  --chart-2: oklch(0.696 0.17 162.48);
@@ -95,7 +95,7 @@
95
95
  --sidebar-primary-foreground: oklch(0.985 0 0);
96
96
  --sidebar-accent: oklch(0.488 0.243 264.376 / 10%);
97
97
  --sidebar-accent-foreground: oklch(0.7 0.15 264);
98
- --sidebar-border: oklch(0.23 0.025 265);
98
+ --sidebar-border: oklch(0.27 0.02 265);
99
99
  --sidebar-ring: oklch(0.55 0.18 264);
100
100
  }
101
101
 
@@ -108,6 +108,13 @@
108
108
  /* Subtle interaction shadow */
109
109
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04), 0 0 0 1px rgb(0 0 0 / 0.02);
110
110
  }
111
+
112
+ /* Stripe-style: form inputs use card background instead of transparent */
113
+ [data-slot="input"],
114
+ [data-slot="textarea"],
115
+ [data-slot="select"] {
116
+ background-color: var(--card);
117
+ }
111
118
 
112
119
  [data-slot="card"] {
113
120
  /* Classic Stripe soft shadow: faint ambient + directional drop */
@@ -8,7 +8,7 @@
8
8
  import { navigate } from '@svadmin/core/router';
9
9
  import { currentPath } from '@svadmin/core/router';
10
10
  import { QueryClient, QueryClientProvider } from '@tanstack/svelte-query';
11
- import { setComponentRegistry, type ComponentRegistry } from '../component-registry.svelte.js';
11
+ import { setComponentRegistry, getComponentRegistry, type ComponentRegistry } from '../component-registry.svelte.js';
12
12
  import Layout from './Layout.svelte';
13
13
  import AutoTable from './AutoTable.svelte';
14
14
  import AutoForm from './AutoForm.svelte';
@@ -164,19 +164,23 @@
164
164
  {/if}
165
165
  {:else if route === '/:resource'}
166
166
  {#key params.resource}
167
- <AutoTable resourceName={params.resource} />
167
+ {@const Comp = getComponentRegistry().AutoTable}
168
+ <Comp resourceName={params.resource} />
168
169
  {/key}
169
170
  {:else if route === '/:resource/create'}
170
171
  {#key params.resource}
171
- <AutoForm resourceName={params.resource} mode="create" />
172
+ {@const Comp = getComponentRegistry().AutoForm}
173
+ <Comp resourceName={params.resource} mode="create" />
172
174
  {/key}
173
175
  {:else if route === '/:resource/edit/:id'}
174
176
  {#key `${params.resource}-${params.id}`}
175
- <AutoForm resourceName={params.resource} mode="edit" id={params.id} />
177
+ {@const Comp = getComponentRegistry().AutoForm}
178
+ <Comp resourceName={params.resource} mode="edit" id={params.id} />
176
179
  {/key}
177
180
  {:else if route === '/:resource/show/:id'}
178
181
  {#key `${params.resource}-${params.id}`}
179
- <ShowPage resourceName={params.resource} id={params.id} />
182
+ {@const Comp = getComponentRegistry().ShowPage}
183
+ <Comp resourceName={params.resource} id={params.id} />
180
184
  {/key}
181
185
  {/if}
182
186
  </div>
@@ -1,13 +1,21 @@
1
1
  <script lang="ts">
2
- import { Marked } from "marked";
3
- import { markedHighlight } from "marked-highlight";
4
- import * as hljsModule from "highlight.js";
5
- const hljs = "default" in hljsModule ? hljsModule.default : hljsModule;
6
- import "highlight.js/styles/github-dark.css"; // or your preferred theme
7
- import DOMPurify from "isomorphic-dompurify";
2
+ import * as markedPkg from "marked";
3
+ import * as markedHighlightPkg from "marked-highlight";
4
+ import * as hljsPkg from "highlight.js";
5
+ import * as DOMPurifyPkg from "isomorphic-dompurify";
8
6
  import { Check, Copy } from "lucide-svelte";
9
7
  import { Button } from "./ui/button/index.js";
10
8
 
9
+ const Marked = markedPkg.Marked;
10
+ const markedHighlight = markedHighlightPkg.markedHighlight;
11
+ const hljsModule = hljsPkg.default || hljsPkg;
12
+ const DOMPurify = 'default' in DOMPurifyPkg ? DOMPurifyPkg.default : DOMPurifyPkg;
13
+
14
+ // Only safely import css if hljs exists
15
+ if (hljsModule && Object.keys(hljsModule).length > 0) {
16
+ import("highlight.js/styles/github-dark.css").catch(() => {});
17
+ }
18
+
11
19
  interface Props {
12
20
  /** The raw markdown string to render */
13
21
  content: string;
@@ -19,20 +27,24 @@
19
27
 
20
28
  let { content, streaming = false, class: className = "" }: Props = $props();
21
29
 
22
- // Configure marked with syntax highlighting
23
- const marked = new Marked(
30
+ const hasMarkdownDeps = !!(Marked && markedHighlight && DOMPurify && Object.keys(DOMPurify).length > 0);
31
+
32
+ // Configure marked with syntax highlighting if available
33
+ const markedObj = hasMarkdownDeps ? new Marked(
24
34
  markedHighlight({
25
35
  langPrefix: "hljs language-",
26
36
  highlight(code: string, lang: string) {
27
- const language = hljs.getLanguage(lang) ? lang : "plaintext";
28
- return hljs.highlight(code, { language }).value;
37
+ const language = hljsModule.getLanguage && hljsModule.getLanguage(lang) ? lang : "plaintext";
38
+ return hljsModule.highlight ? hljsModule.highlight(code, { language }).value : code;
29
39
  },
30
40
  }),
31
- );
41
+ ) : null;
32
42
 
33
43
  // Render HTML safely
34
44
  const html = $derived(
35
- DOMPurify.sanitize(marked.parse(content || "") as string),
45
+ hasMarkdownDeps
46
+ ? DOMPurify.sanitize(markedObj.parse(content || "") as string)
47
+ : `<div style="white-space: pre-wrap">${String(content || "").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</div>`
36
48
  );
37
49
 
38
50
  // Handle copy code blocks
@@ -1,8 +1,11 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from "svelte";
2
3
  import type { HTMLAttributes } from "svelte/elements";
3
4
  import { cn } from "../../../utils.js";
4
5
 
5
- let { class: className, ...restProps }: HTMLAttributes<HTMLDivElement> = $props();
6
+ let { class: className, children, ...restProps }: HTMLAttributes<HTMLDivElement> & { children?: Snippet } = $props();
6
7
  </script>
7
8
 
8
- <div class={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...restProps}></div>
9
+ <div class={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...restProps}>
10
+ {@render children?.()}
11
+ </div>
@@ -1,8 +1,11 @@
1
1
  <script lang="ts">
2
+ import type { Snippet } from "svelte";
2
3
  import type { HTMLAttributes } from "svelte/elements";
3
4
  import { cn } from "../../../utils.js";
4
5
 
5
- let { class: className, ...restProps }: HTMLAttributes<HTMLDivElement> = $props();
6
+ let { class: className, children, ...restProps }: HTMLAttributes<HTMLDivElement> & { children?: Snippet } = $props();
6
7
  </script>
7
8
 
8
- <div class={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...restProps}></div>
9
+ <div class={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...restProps}>
10
+ {@render children?.()}
11
+ </div>