@molecule/app-typing-indicator-svelte 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-15T07:10:28.283Z
6
+ Generated: 2026-11-21T12:47:41.646Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-typing-indicator-svelte
@@ -56,7 +56,10 @@ interface TypingIndicatorProps {
56
56
  dotSize?: number
57
57
  /** Animation duration in ms. Defaults to 1200. */
58
58
  durationMs?: number
59
- /** Accessible label. */
59
+ /**
60
+ * Accessible label. Overrides the translated / `defaultValue` `'Typing…'`
61
+ * (prop > `t()` > default).
62
+ */
60
63
  ariaLabel?: string
61
64
  /** Extra classes. */
62
65
  className?: string
@@ -91,9 +94,13 @@ Peer dependencies:
91
94
 
92
95
  Dots use `currentColor`, so the indicator inherits the surrounding text
93
96
  color — wrap it in a muted-text container to dim it. The default
94
- `ariaLabel` is hardcoded English 'Typing…' (React parity) and there is no
95
- companion locale bond: pass a translated `ariaLabel` in non-English apps.
96
- Each instance injects its own `<style>` tag for the keyframes (fine for a
97
- chat view; avoid hundreds at once). Props (documented on the exported
98
- `TypingIndicatorProps` interface): visible (default true), dotSize (px,
99
- default 6), durationMs (default 1200), ariaLabel, className.
97
+ `ariaLabel` is the translated `typingIndicator.aria.label` (English
98
+ `'Typing…'`, via `@molecule/app-locales-typing-indicator`); the `ariaLabel`
99
+ prop overrides it. Each instance injects its own `<style>` tag for the
100
+ keyframes (fine for a chat view; avoid hundreds at once). Props (documented
101
+ on the exported `TypingIndicatorProps` interface): visible (default true),
102
+ dotSize (px, default 6), durationMs (default 1200), ariaLabel, className.
103
+
104
+ ## Translations
105
+
106
+ Translation strings are provided by `@molecule/app-locales-typing-indicator`.
@@ -2,12 +2,14 @@
2
2
  TypingIndicator: the Svelte counterpart of `@molecule/app-typing-indicator-react`'s
3
3
  `TypingIndicator` — three-dot CSS-only pulse animation. Same props, same DOM
4
4
  for the same input; the dots use `currentColor` so the indicator inherits the
5
- surrounding text color. Each instance injects its own `<style>` tag with the
6
- shared keyframes: a `<style>` element in Svelte markup is raw text (no
7
- expressions), so the `injectKeyframes` action inserts it on mount — it runs
8
- again on every re-mount, and the element leaves the DOM with the span.
5
+ surrounding text color. Each instance renders its own `<style>` element with
6
+ the shared keyframes: it is written as `<svelte:element this={'style'}>` so
7
+ Svelte treats it as an ordinary element (a literal `<style>` in markup is
8
+ component CSS), and it is part of the template, so it mounts, updates and
9
+ unmounts with the span.
9
10
  -->
10
11
  <script lang="ts">
12
+ import { useTranslation } from '@molecule/app-svelte'
11
13
  import { getClassMap } from '@molecule/app-ui'
12
14
 
13
15
  import type { TypingIndicatorProps } from './types.js'
@@ -16,24 +18,29 @@
16
18
  visible = true,
17
19
  dotSize = 6,
18
20
  durationMs = 1200,
19
- ariaLabel = 'Typing…',
21
+ ariaLabel,
20
22
  className,
21
23
  }: TypingIndicatorProps = $props()
22
24
 
25
+ const { t } = useTranslation()
26
+
23
27
  const cm = $derived(getClassMap())
24
28
 
25
29
  const keyName = 'molecule-typing-pulse'
26
30
 
27
31
  /**
28
- * Inserts the keyframes `<style>` element as the span's first child.
29
- *
30
- * @param el - The indicator span.
32
+ * The label: the prop when given, else the translated default (read in the
33
+ * template, so a locale switch re-renders it).
34
+ * @returns The label text.
31
35
  */
32
- const injectKeyframes = (el: HTMLElement): void => {
33
- const style = document.createElement('style')
34
- style.textContent = `@keyframes ${keyName} { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }`
35
- el.insertBefore(style, el.firstChild)
36
- }
36
+ const label = (): string =>
37
+ ariaLabel ?? t('typingIndicator.aria.label', undefined, { defaultValue: 'Typing…' })
38
+
39
+ // The host stylesheet's global 0.01ms collapse still leaves the per-dot
40
+ // stagger delay, so the dots flash in sequence for a reduced-motion user and
41
+ // the rendered frame depends on when it is painted; the component's own rule
42
+ // turns the pulse off entirely instead.
43
+ const css = `@keyframes ${keyName} { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } } @media (prefers-reduced-motion: reduce) { [data-typing-dot] { animation: none !important; } }`
37
44
 
38
45
  const styleAttr = (i: number): string =>
39
46
  `display:inline-block;width:${dotSize}px;height:${dotSize}px;border-radius:50%;background:currentColor;animation:${keyName} ${durationMs}ms ease-in-out ${(i * durationMs) / 6}ms infinite`
@@ -41,13 +48,13 @@
41
48
 
42
49
  {#if visible}
43
50
  <span
44
- use:injectKeyframes
45
51
  role="status"
46
- aria-label={ariaLabel}
52
+ aria-label={label()}
47
53
  class={cm.cn(cm.flex({ align: 'center', gap: 'xs' }), className)}
48
54
  >
55
+ <svelte:element this={"style"}>{css}</svelte:element>
49
56
  {#each [0, 1, 2] as i (i)}
50
- <span aria-hidden="true" style={styleAttr(i)}></span>
57
+ <span aria-hidden="true" data-typing-dot style={styleAttr(i)}></span>
51
58
  {/each}
52
59
  </span>
53
60
  {/if}
@@ -1 +1 @@
1
- {"version":3,"file":"TypingIndicator.svelte.d.ts","sourceRoot":"","sources":["../src/TypingIndicator.svelte"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA6CvD,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"TypingIndicator.svelte.d.ts","sourceRoot":"","sources":["../src/TypingIndicator.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAoDvD,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
package/dist/index.d.ts CHANGED
@@ -19,12 +19,12 @@
19
19
  * @remarks
20
20
  * Dots use `currentColor`, so the indicator inherits the surrounding text
21
21
  * color — wrap it in a muted-text container to dim it. The default
22
- * `ariaLabel` is hardcoded English 'Typing…' (React parity) and there is no
23
- * companion locale bond: pass a translated `ariaLabel` in non-English apps.
24
- * Each instance injects its own `<style>` tag for the keyframes (fine for a
25
- * chat view; avoid hundreds at once). Props (documented on the exported
26
- * `TypingIndicatorProps` interface): visible (default true), dotSize (px,
27
- * default 6), durationMs (default 1200), ariaLabel, className.
22
+ * `ariaLabel` is the translated `typingIndicator.aria.label` (English
23
+ * `'Typing…'`, via `@molecule/app-locales-typing-indicator`); the `ariaLabel`
24
+ * prop overrides it. Each instance injects its own `<style>` tag for the
25
+ * keyframes (fine for a chat view; avoid hundreds at once). Props (documented
26
+ * on the exported `TypingIndicatorProps` interface): visible (default true),
27
+ * dotSize (px, default 6), durationMs (default 1200), ariaLabel, className.
28
28
  *
29
29
  * @module
30
30
  */
package/dist/index.js CHANGED
@@ -19,12 +19,12 @@
19
19
  * @remarks
20
20
  * Dots use `currentColor`, so the indicator inherits the surrounding text
21
21
  * color — wrap it in a muted-text container to dim it. The default
22
- * `ariaLabel` is hardcoded English 'Typing…' (React parity) and there is no
23
- * companion locale bond: pass a translated `ariaLabel` in non-English apps.
24
- * Each instance injects its own `<style>` tag for the keyframes (fine for a
25
- * chat view; avoid hundreds at once). Props (documented on the exported
26
- * `TypingIndicatorProps` interface): visible (default true), dotSize (px,
27
- * default 6), durationMs (default 1200), ariaLabel, className.
22
+ * `ariaLabel` is the translated `typingIndicator.aria.label` (English
23
+ * `'Typing…'`, via `@molecule/app-locales-typing-indicator`); the `ariaLabel`
24
+ * prop overrides it. Each instance injects its own `<style>` tag for the
25
+ * keyframes (fine for a chat view; avoid hundreds at once). Props (documented
26
+ * on the exported `TypingIndicatorProps` interface): visible (default true),
27
+ * dotSize (px, default 6), durationMs (default 1200), ariaLabel, className.
28
28
  *
29
29
  * @module
30
30
  */
package/dist/types.d.ts CHANGED
@@ -11,7 +11,10 @@ export interface TypingIndicatorProps {
11
11
  dotSize?: number;
12
12
  /** Animation duration in ms. Defaults to 1200. */
13
13
  durationMs?: number;
14
- /** Accessible label. */
14
+ /**
15
+ * Accessible label. Overrides the translated / `defaultValue` `'Typing…'`
16
+ * (prop > `t()` > default).
17
+ */
15
18
  ariaLabel?: string;
16
19
  /** Extra classes. */
17
20
  className?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,oBAAoB;IACnC,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-typing-indicator-svelte",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Three-dot animated typing indicator for chat UIs",
5
5
  "homepage": "https://www.molecule.dev/packages/app-typing-indicator-svelte",
6
6
  "type": "module",
@@ -57,13 +57,13 @@
57
57
  "@molecule/app-framework-conformance": "0.0.0",
58
58
  "@molecule/app-i18n": "1.2.2",
59
59
  "@molecule/app-icons": "1.0.4",
60
- "@molecule/app-svelte": "3.7.1",
61
- "@molecule/app-ui": "1.4.0",
62
- "@molecule/app-ui-svelte": "1.1.5",
60
+ "@molecule/app-svelte": "3.13.0",
61
+ "@molecule/app-ui": "1.5.0",
62
+ "@molecule/app-ui-svelte": "1.4.1",
63
63
  "@sveltejs/package": "3.0.2",
64
64
  "@sveltejs/vite-plugin-svelte": "7.1.2",
65
65
  "@types/node": "26.6.5",
66
- "jsdom": "30.1.3",
66
+ "jsdom": "31.0.1",
67
67
  "svelte": "5.57.2",
68
68
  "svelte-check": "4.7.7",
69
69
  "typescript": "6.0.3",