@krantho/ui-svelte 0.0.0-stage → 1.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Descoped
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@krantho/ui-svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "Svelte 5 components that render krantho content.",
5
+ "license": "MIT",
6
+ "homepage": "https://krantho.com",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/descoped/krantho.git",
10
+ "directory": "packages/ui-svelte"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/descoped/krantho/issues"
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./src/index.ts",
19
+ "svelte": "./src/index.ts",
20
+ "default": "./src/index.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "src"
25
+ ],
26
+ "svelte": "./src/index.ts",
27
+ "dependencies": {
28
+ "@krantho/core": "1.0.1",
29
+ "@krantho/seo-shared": "1.0.1"
30
+ },
31
+ "peerDependencies": {
32
+ "svelte": ">=5.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "svelte-check": "^4.7.8"
36
+ },
37
+ "scripts": {
38
+ "build": "echo 'Svelte package uses svelte-package (not yet configured)'",
39
+ "typecheck": "svelte-check --tsconfig ./tsconfig.json",
40
+ "clean": "rm -rf dist"
41
+ }
6
42
  }
@@ -0,0 +1,38 @@
1
+ <script lang="ts">
2
+ import { kranthoField, type MarkedDocument } from '@krantho/core/marks'
3
+
4
+ let {
5
+ src,
6
+ alt = '',
7
+ width,
8
+ height,
9
+ lazy = true,
10
+ class: className = '',
11
+ doc,
12
+ field,
13
+ }: {
14
+ src: string
15
+ alt?: string
16
+ width?: number | undefined
17
+ height?: number | undefined
18
+ lazy?: boolean
19
+ class?: string
20
+ /** The document the image belongs to; in a preview, `field` is marked for Live mode */
21
+ doc?: MarkedDocument | undefined
22
+ field?: string | undefined
23
+ } = $props()
24
+
25
+ const marks = $derived(field ? kranthoField(doc, field) : {})
26
+
27
+ const cssClass = $derived(`cms-image ${className}`.trim())
28
+ </script>
29
+
30
+ <img
31
+ {src}
32
+ {alt}
33
+ {width}
34
+ {height}
35
+ loading={lazy ? 'lazy' : undefined}
36
+ class={cssClass}
37
+ {...marks}
38
+ />
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import { kranthoSection, type MarkedDocument, markBodySections } from '@krantho/core/marks'
3
+
4
+ let {
5
+ html,
6
+ class: className = '',
7
+ doc,
8
+ section,
9
+ body,
10
+ }: {
11
+ html: string
12
+ class?: string
13
+ /** The document the markdown belongs to; in a preview, what it renders is marked for Live mode */
14
+ doc?: MarkedDocument | undefined
15
+ /** The `##` section `html` renders, by its heading */
16
+ section?: string | undefined
17
+ /** The markdown of a whole body `html` renders, so its lead and sections are marked */
18
+ body?: string | undefined
19
+ } = $props()
20
+
21
+ const cssClass = $derived(`cms-markdown ${className}`.trim())
22
+ const marks = $derived(section ? kranthoSection(doc, section) : {})
23
+ const rendered = $derived(!section && body !== undefined ? markBodySections(html, body, doc) : html)
24
+ </script>
25
+
26
+ <div class={cssClass} {...marks}>
27
+ {@html rendered}
28
+ </div>
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import { variantToTag } from '@krantho/core'
3
+ import { kranthoField, type MarkedDocument } from '@krantho/core/marks'
4
+
5
+ let {
6
+ text,
7
+ variant = 'body1',
8
+ color,
9
+ align,
10
+ weight,
11
+ size,
12
+ component,
13
+ class: className = '',
14
+ doc,
15
+ field,
16
+ }: {
17
+ text: string
18
+ variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'body1' | 'body2' | 'caption'
19
+ color?: 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success' | 'inherit' | undefined
20
+ align?: 'left' | 'center' | 'right' | 'justify' | undefined
21
+ weight?: 'light' | 'regular' | 'medium' | 'bold' | undefined
22
+ size?: 'small' | 'medium' | 'large' | undefined
23
+ component?: string | undefined
24
+ class?: string
25
+ /** The document the text belongs to; in a preview, `field` is marked for Live mode */
26
+ doc?: MarkedDocument | undefined
27
+ field?: string | undefined
28
+ } = $props()
29
+
30
+ const marks = $derived(field ? kranthoField(doc, field) : {})
31
+
32
+ const tag = $derived(component ?? variantToTag(variant))
33
+ const cssClass = $derived(
34
+ [
35
+ 'cms-text',
36
+ `cms-variant-${variant}`,
37
+ color && `cms-color-${color}`,
38
+ align && `cms-align-${align}`,
39
+ weight && `cms-weight-${weight}`,
40
+ size && `cms-size-${size}`,
41
+ className,
42
+ ]
43
+ .filter(Boolean)
44
+ .join(' '),
45
+ )
46
+ </script>
47
+
48
+ <svelte:element this={tag} class={cssClass} {...marks}>{text}</svelte:element>
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { default as CMSImage } from './CMSImage.svelte'
2
+ export { default as CMSMarkdown } from './CMSMarkdown.svelte'
3
+ export { default as CMSText } from './CMSText.svelte'
4
+ export { default as BreadcrumbJsonLd } from './seo/BreadcrumbJsonLd.svelte'
5
+ export { default as FAQSchema } from './seo/FAQSchema.svelte'
6
+ // SEO components
7
+ export { default as JsonLd } from './seo/JsonLd.svelte'
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ import JsonLd from './JsonLd.svelte'
3
+
4
+ let { pathname, siteUrl = '' }: { pathname: string; siteUrl?: string } = $props()
5
+
6
+ const breadcrumbs = $derived.by(() => {
7
+ const segments = pathname.split('/').filter(Boolean)
8
+ return segments.map((segment, index) => ({
9
+ '@type': 'ListItem' as const,
10
+ position: index + 1,
11
+ name: segment.charAt(0).toUpperCase() + segment.slice(1).replace(/-/g, ' '),
12
+ item: `${siteUrl}/${segments.slice(0, index + 1).join('/')}`,
13
+ }))
14
+ })
15
+
16
+ const jsonLd = $derived(
17
+ breadcrumbs.length > 0
18
+ ? {
19
+ '@context': 'https://schema.org',
20
+ '@type': 'BreadcrumbList',
21
+ itemListElement: breadcrumbs,
22
+ }
23
+ : null,
24
+ )
25
+ </script>
26
+
27
+ {#if jsonLd}
28
+ <JsonLd data={jsonLd} />
29
+ {/if}
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import JsonLd from './JsonLd.svelte'
3
+
4
+ let {
5
+ items,
6
+ }: {
7
+ items: Array<{ '@type': string; name: string; acceptedAnswer: { '@type': string; text: string } }>
8
+ } = $props()
9
+
10
+ const jsonLd = $derived(
11
+ items.length > 0
12
+ ? {
13
+ '@context': 'https://schema.org',
14
+ '@type': 'FAQPage',
15
+ mainEntity: items,
16
+ }
17
+ : null,
18
+ )
19
+ </script>
20
+
21
+ {#if jsonLd}
22
+ <JsonLd data={jsonLd} />
23
+ {/if}
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ import { serializeJsonLd } from '@krantho/seo-shared'
3
+
4
+ let { data }: { data: Record<string, unknown> } = $props()
5
+ const json = $derived(serializeJsonLd(data))
6
+ </script>
7
+
8
+ <svelte:head>
9
+ {@html `<script type="application/ld+json">${json}</script>`}
10
+ </svelte:head>
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.