nuxt-ui-basekit 0.1.1 → 0.2.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.
@@ -1,16 +1,16 @@
1
1
  import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue'
2
2
 
3
3
  /**
4
- * Misst die Breite eines Containers, damit ein SVG in echten Pixeln zeichnen
5
- * kann statt über eine skalierte `viewBox`.
4
+ * Measures a container so an SVG can draw in real pixels instead of going
5
+ * through a scaled `viewBox`.
6
6
  *
7
- * Der Unterschied ist die Schrift: eine `viewBox`, die auf Containerbreite
8
- * hochgerechnet wird, zieht Achsenbeschriftung und Werte mit hoch auf einer
9
- * breiten Karte steht dann 15-px-Text, wo 11 gemeint waren. Mit gemessener
10
- * Breite bleibt Text Text und nur die Geometrie wächst.
7
+ * The difference is the type: a `viewBox` scaled up to container width drags
8
+ * axis labels and values up with ita wide card then shows 15px text where
9
+ * 11 was meant. With a measured width, text stays text and only the geometry
10
+ * grows.
11
11
  *
12
- * Vor dem Mounten (SSR, erster Frame) gilt `fallback`. Das Diagramm ist damit
13
- * sofort da und rückt einmal zurecht, statt zu flackern.
12
+ * Before mount (SSR, first frame) `fallback` applies. The chart is therefore
13
+ * there straight away and settles once, rather than flickering.
14
14
  */
15
15
  export function useChartWidth(fallback = 640): {
16
16
  el: Ref<HTMLElement | null>
@@ -25,8 +25,8 @@ export function useChartWidth(fallback = 640): {
25
25
 
26
26
  observer = new ResizeObserver((entries) => {
27
27
  const measured = entries[0]?.contentRect.width ?? 0
28
- // Unter 240 px wird die Geometrie unbrauchbar; dann lieber schmal
29
- // zeichnen und den Container scrollen lassen.
28
+ // Below 240px the geometry becomes useless; draw narrow and let the
29
+ // container scroll instead.
30
30
  if (measured > 0) width.value = Math.max(240, Math.round(measured))
31
31
  })
32
32
  observer.observe(el.value)
@@ -2,10 +2,10 @@ import { useConfirmStore } from '../stores/confirm'
2
2
  import type { BaseKitConfirmOptions } from '../stores/confirm'
3
3
 
4
4
  /**
5
- * Bestätigungsabfrage als Ersatz für natives `window.confirm`.
5
+ * A confirmation prompt in place of the native `window.confirm`.
6
6
  *
7
- * Öffnet das global gemountete `BaseKitConfirmModal` und liefert ein Promise,
8
- * das mit `true`/`false` auflöst.
7
+ * Opens the globally mounted `BaseKitConfirmModal` and returns a promise that
8
+ * resolves to `true` or `false`.
9
9
  *
10
10
  * const confirm = useConfirm()
11
11
  * if (!(await confirm({ description: t('…'), color: 'error', confirmLabel: t('common.delete') }))) return
@@ -1,32 +1,32 @@
1
1
  import { defineStore } from 'pinia'
2
2
  import { ref } from 'vue'
3
3
 
4
- /** Optionen für eine Bestätigungsabfrage. */
4
+ /** Options for one confirmation prompt. */
5
5
  export interface BaseKitConfirmOptions {
6
- /** Titel des Dialogs (Default: `common.confirm.title`). */
6
+ /** Dialog title. Falls back to the `confirmTitle` label. */
7
7
  title?: string
8
- /** Erklärtext / Konsequenzbei Destruktivem ausformulieren. */
8
+ /** Explanation or consequencespell it out for anything destructive. */
9
9
  description?: string
10
- /** Beschriftung des Bestätigen-Buttons (Default: `common.confirm.confirm`). */
10
+ /** Label of the confirm button. Falls back to the `confirm` label. */
11
11
  confirmLabel?: string
12
- /** Beschriftung des Abbrechen-Buttons (Default: `common.cancel`). */
12
+ /** Label of the cancel button. Falls back to the `cancel` label. */
13
13
  cancelLabel?: string
14
- /** Farbe des Bestätigen-Buttons — `error` für destruktive Aktionen. */
14
+ /** Colour of the confirm button — `error` for destructive actions. */
15
15
  color?: 'error' | 'primary'
16
- /** Optionales Icon am Bestätigen-Button. */
16
+ /** Optional icon on the confirm button. */
17
17
  icon?: string
18
18
  }
19
19
 
20
20
  /**
21
- * Zentraler Bestätigungs-Storeersetzt native `window.confirm`-Dialoge durch
22
- * eine gethemte, dark-mode-fähige Abfrage.
21
+ * The confirmation store replaces native `window.confirm` dialogs with a
22
+ * themed, dark-mode-capable prompt.
23
23
  *
24
- * `ask()` öffnet das global gemountete `BaseKitConfirmModal` und liefert ein
25
- * Promise, das mit `true` (bestätigt) oder `false` (abgebrochen/geschlossen)
26
- * auflöst. Der Resolver lebt außerhalb der Reaktivität, damit genau eine
27
- * Antwort pro Abfrage zurückgeht.
24
+ * `ask()` opens the globally mounted `BaseKitConfirmModal` and returns a
25
+ * promise resolving to `true` (confirmed) or `false` (cancelled or closed).
26
+ * The resolver lives outside reactivity so exactly one answer goes back per
27
+ * prompt.
28
28
  *
29
- * Genutzt über das Composable `useConfirm()`:
29
+ * Used through the `useConfirm()` composable:
30
30
  * const confirm = useConfirm()
31
31
  * if (!(await confirm({ description: t('…'), color: 'error' }))) return
32
32
  */
@@ -36,7 +36,7 @@ export const useConfirmStore = defineStore('basekit:confirm', () => {
36
36
  let resolver: ((value: boolean) => void) | null = null
37
37
 
38
38
  function ask(opts: BaseKitConfirmOptions = {}): Promise<boolean> {
39
- // Läuft noch eine Abfrage, wird sie als abgebrochen aufgelöst.
39
+ // A prompt still running is resolved as cancelled.
40
40
  resolver?.(false)
41
41
  options.value = opts
42
42
  open.value = true
@@ -45,7 +45,7 @@ export const useConfirmStore = defineStore('basekit:confirm', () => {
45
45
  })
46
46
  }
47
47
 
48
- /** Abfrage beantworten und Dialog schließen. */
48
+ /** Answer the prompt and close the dialog. */
49
49
  function settle(value: boolean): void {
50
50
  open.value = false
51
51
  resolver?.(value)
@@ -1,14 +1,12 @@
1
1
  /**
2
- * HTML Markdown (turndown). Zwei Einsätze, beide nur im Admin/Editor — daher
3
- * bewusst getrennt von `markdown.ts` (das im öffentlichen Widget-Bundle steckt
4
- * und turndown nicht mitziehen soll):
5
- * - Tiptap speichert HTML → hier nach Markdown serialisieren.
6
- * - Legacy-Text-Blöcke mit rohem `config.html` einmalig nach Markdown wandeln.
2
+ * HTML to Markdown, through turndown. Kept apart from `markdown.ts` on
3
+ * purpose: that one may end up in a public bundle and should not drag turndown
4
+ * along, while this one is only ever needed where something is edited.
7
5
  *
8
- * **turndown wird bewusst erst beim ersten Aufruf geladen.** Das Paket ist
9
- * CommonJS; ein Import auf Modulebene landet im Server-Bundle und wirft dort
10
- * beim Rendern „require is not defined in ES module scope". Der Editor läuft
11
- * ohnehin nur im Browserauf dem Server wird die Funktion nie aufgerufen.
6
+ * **turndown is loaded lazily, and that is deliberate.** The package is
7
+ * CommonJS; an import at module level lands in the server bundle and throws
8
+ * "require is not defined in ES module scope" while rendering. The editor runs
9
+ * in the browser anywayon the server this function is never called.
12
10
  */
13
11
  type Turndown = { turndown: (html: string) => string }
14
12
 
@@ -18,14 +16,14 @@ function service(): Turndown | null {
18
16
  if (instance) return instance
19
17
  if (import.meta.server) return null
20
18
 
21
- // Synchroner Zugriff auf ein bereits geladenes Modul: der Editor ruft
22
- // `prepare()` beim Einhängen auf, bevor gespeichert werden kann.
19
+ // Synchronous access to an already loaded module: the editor calls
20
+ // `prepare()` on mount, well before anything can be saved.
23
21
  return instance
24
22
  }
25
23
 
26
24
  /**
27
- * Lädt turndown im Browser vor. Die Editor-Komponenten rufen das beim
28
- * Einhängen auf, damit {@link htmlToMarkdown} danach synchron bleiben kann.
25
+ * Preloads turndown in the browser. The editor components call this on mount
26
+ * so {@link htmlToMarkdown} can stay synchronous afterwards.
29
27
  */
30
28
  export async function prepareHtmlToMarkdown(): Promise<void> {
31
29
  if (instance || import.meta.server) return
@@ -40,8 +38,8 @@ export async function prepareHtmlToMarkdown(): Promise<void> {
40
38
  export function htmlToMarkdown(html?: string | null): string {
41
39
  if (!html) return ''
42
40
  const td = service()
43
- // Ohne geladenes turndown (Server, oder prepare() vergessen) lieber das
44
- // Original zurückgeben als eine Ausnahme zu werfen der Text ginge sonst
45
- // beim Speichern verloren.
41
+ // Without turndown loaded — on the server, or when prepare() was forgotten
42
+ // return the original rather than throwing: the text would otherwise be
43
+ // lost on save.
46
44
  return td ? td.turndown(String(html)).trim() : String(html)
47
45
  }
@@ -1,15 +1,16 @@
1
1
  import MarkdownIt from 'markdown-it'
2
2
 
3
3
  /**
4
- * Markdown HTML für den Text-Block (`richtext`-Widget, jetzt Markdown).
4
+ * Markdown to HTML.
5
5
  *
6
- * Bewusst `html: false`: roher HTML im Markdown wird NICHT durchgereicht — das
7
- * schließt die wichtigste XSS-Lücke ohne separaten Sanitizer (markdown-it
8
- * blockt zudem `javascript:`-Links per Default-`validateLink`). `linkify` macht
9
- * nackte URLs klickbar, `typographer` glättet Anführungszeichen/Bindestriche.
6
+ * `html: false` on purpose: raw HTML inside the Markdown is NOT passed
7
+ * through. That closes the biggest XSS hole without a separate sanitizer —
8
+ * markdown-it also blocks `javascript:` links through its default
9
+ * `validateLink`. `linkify` makes bare URLs clickable, `typographer` smooths
10
+ * quotes and dashes.
10
11
  *
11
- * Geteilt zwischen Anzeige und Editor-Vorschau, damit
12
- * Bearbeiten und Ausgabe identisch aussehen.
12
+ * Shared between display and editor preview, so that editing and output look
13
+ * the same.
13
14
  */
14
15
  const md: MarkdownIt = new MarkdownIt({
15
16
  html: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-basekit",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "Markenfreie Basis-Komponenten für Nuxt 4 auf Nuxt UI — Tabellen, Reiter, Diagramme, Auswahl und Leerzustände als Nuxt-Layer.",
5
5
  "keywords": [
6
6
  "nuxt",