@molecule/app-typing-indicator-svelte 1.1.1 → 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.
@@ -2,10 +2,11 @@
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">
11
12
  import { useTranslation } from '@molecule/app-svelte'
@@ -35,22 +36,11 @@
35
36
  const label = (): string =>
36
37
  ariaLabel ?? t('typingIndicator.aria.label', undefined, { defaultValue: 'Typing…' })
37
38
 
38
- /**
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.
48
- */
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)
53
- }
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; } }`
54
44
 
55
45
  const styleAttr = (i: number): string =>
56
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`
@@ -58,11 +48,11 @@
58
48
 
59
49
  {#if visible}
60
50
  <span
61
- use:injectKeyframes
62
51
  role="status"
63
52
  aria-label={label()}
64
53
  class={cm.cn(cm.flex({ align: 'center', gap: 'xs' }), className)}
65
54
  >
55
+ <svelte:element this={"style"}>{css}</svelte:element>
66
56
  {#each [0, 1, 2] as i (i)}
67
57
  <span aria-hidden="true" data-typing-dot style={styleAttr(i)}></span>
68
58
  {/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;AAoDvD,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.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.9.0",
60
+ "@molecule/app-svelte": "3.13.0",
61
61
  "@molecule/app-ui": "1.5.0",
62
- "@molecule/app-ui-svelte": "1.2.1",
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",