@molecule/app-typing-indicator-svelte 1.1.1 → 1.2.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/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-21T12:47:41.646Z
6
+ Generated: 2026-11-25T10:06:46.697Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-typing-indicator-svelte
@@ -81,7 +81,7 @@ const TypingIndicator: LegacyComponentType
81
81
  Peer dependencies:
82
82
 
83
83
  - `@molecule/app-svelte` ^3.5.0
84
- - `@molecule/app-ui` ^1.0.1
84
+ - `@molecule/app-ui` ^1.9.0
85
85
  - `@molecule/app-ui-svelte` ^1.1.0
86
86
  - `svelte` ^5.0.0
87
87
 
@@ -2,14 +2,16 @@
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 keyframes of its motion recipe (the ClassMap's `typingPulse`, else the
7
+ standard curve): it is written as `<svelte:element this={'style'}>` so
8
+ Svelte treats it as an ordinary element (a literal `<style>` in markup is
9
+ component CSS), and it is part of the template, so it mounts, updates and
10
+ unmounts with the span.
9
11
  -->
10
12
  <script lang="ts">
11
13
  import { useTranslation } from '@molecule/app-svelte'
12
- import { getClassMap } from '@molecule/app-ui'
14
+ import { DEFAULT_TYPING_PULSE, getClassMap } from '@molecule/app-ui'
13
15
 
14
16
  import type { TypingIndicatorProps } from './types.js'
15
17
 
@@ -25,7 +27,19 @@
25
27
 
26
28
  const cm = $derived(getClassMap())
27
29
 
28
- const keyName = 'molecule-typing-pulse'
30
+ // React's `PulseDots` reads the recipe on each render; a Svelte component's
31
+ // script runs once per instance, so this is the recipe the instance mounts with.
32
+ const { peakAt, restAt, stagger, dimOpacity, dimScale } =
33
+ getClassMap().typingPulse ?? DEFAULT_TYPING_PULSE
34
+
35
+ // Keyframes are document-wide. A custom curve must coexist with a mounted standard pulse.
36
+ const keyName =
37
+ peakAt === DEFAULT_TYPING_PULSE.peakAt &&
38
+ restAt === DEFAULT_TYPING_PULSE.restAt &&
39
+ dimOpacity === DEFAULT_TYPING_PULSE.dimOpacity &&
40
+ dimScale === DEFAULT_TYPING_PULSE.dimScale
41
+ ? 'molecule-typing-pulse'
42
+ : `molecule-typing-pulse-${[peakAt, restAt, dimOpacity, dimScale].join('-').replaceAll('.', '_')}`
29
43
 
30
44
  /**
31
45
  * The label: the prop when given, else the translated default (read in the
@@ -35,34 +49,31 @@
35
49
  const label = (): string =>
36
50
  ariaLabel ?? t('typingIndicator.aria.label', undefined, { defaultValue: 'Typing…' })
37
51
 
52
+ // The host stylesheet's global 0.01ms collapse still leaves the per-dot
53
+ // stagger delay, so the dots flash in sequence for a reduced-motion user and
54
+ // the rendered frame depends on when it is painted; the component's own rule
55
+ // turns the pulse off entirely instead.
56
+ const css = `@keyframes ${keyName} { 0%, ${restAt * 100}%, 100% { opacity: ${dimOpacity}; transform: scale(${dimScale}); } ${peakAt * 100}% { opacity: 1; transform: scale(1); } } @media (prefers-reduced-motion: reduce) { [data-typing-dot] { animation: none !important; } }`
57
+
38
58
  /**
39
- * Inserts the `<style>` element with the keyframes and the reduced-motion
40
- * opt-out as the span's first child.
41
- *
42
- * The host stylesheet's global 0.01ms collapse still leaves the per-dot
43
- * stagger delay, so the dots flash in sequence for a reduced-motion user and
44
- * the rendered frame depends on when it is painted; the component's own rule
45
- * turns the pulse off entirely instead.
46
- *
47
- * @param el - The indicator span.
59
+ * One dot's inline styles. The original division preserves the exact serialized delay for fractional values.
60
+ * @param i - The dot's position (0–2); each dot's delay staggers it.
61
+ * @returns The style attribute text.
48
62
  */
49
- const injectKeyframes = (el: HTMLElement): void => {
50
- const style = document.createElement('style')
51
- style.textContent = `@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; } }`
52
- el.insertBefore(style, el.firstChild)
63
+ const styleAttr = (i: number): string => {
64
+ const elapsed = i * durationMs
65
+ const delay = stagger === DEFAULT_TYPING_PULSE.stagger ? elapsed / 6 : elapsed * stagger
66
+ return `display:inline-block;width:${dotSize}px;height:${dotSize}px;border-radius:50%;background:currentColor;animation:${keyName} ${durationMs}ms ease-in-out ${delay}ms infinite`
53
67
  }
54
-
55
- const styleAttr = (i: number): string =>
56
- `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`
57
68
  </script>
58
69
 
59
70
  {#if visible}
60
71
  <span
61
- use:injectKeyframes
62
72
  role="status"
63
73
  aria-label={label()}
64
74
  class={cm.cn(cm.flex({ align: 'center', gap: 'xs' }), className)}
65
75
  >
76
+ <svelte:element this={"style"}>{css}</svelte:element>
66
77
  {#each [0, 1, 2] as i (i)}
67
78
  <span aria-hidden="true" data-typing-dot style={styleAttr(i)}></span>
68
79
  {/each}
@@ -1 +1 @@
1
- {"version":3,"file":"TypingIndicator.svelte.d.ts","sourceRoot":"","sources":["../src/TypingIndicator.svelte"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA8DvD,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;AAwEvD,QAAA,MAAM,eAAe,0DAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-typing-indicator-svelte",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
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",
@@ -49,21 +49,21 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@molecule/app-svelte": "^3.5.0",
52
- "@molecule/app-ui": "^1.0.1",
52
+ "@molecule/app-ui": "^1.9.0",
53
53
  "@molecule/app-ui-svelte": "^1.1.0",
54
54
  "svelte": "^5.0.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@molecule/app-framework-conformance": "0.0.0",
58
- "@molecule/app-i18n": "1.2.2",
58
+ "@molecule/app-i18n": "1.3.0",
59
59
  "@molecule/app-icons": "1.0.4",
60
- "@molecule/app-svelte": "3.9.0",
61
- "@molecule/app-ui": "1.5.0",
62
- "@molecule/app-ui-svelte": "1.2.1",
60
+ "@molecule/app-svelte": "3.16.0",
61
+ "@molecule/app-ui": "1.13.0",
62
+ "@molecule/app-ui-svelte": "1.9.0",
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",