@rozie-ui/toast-solid 0.1.0 → 0.1.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/dist/index.cjs CHANGED
@@ -418,12 +418,11 @@ function Toaster(_props) {
418
418
  if (swipeGesture() && swipeGesture().id === t.id) setSwipeGesture(null);
419
419
  if (swipe() && swipe().id === t.id) setSwipe(null);
420
420
  }
421
- function depth(t) {
422
- const idx = toasts().findIndex((x) => x.id === t.id);
423
- return idx === -1 ? 0 : toasts().length - 1 - idx;
421
+ function depth(ti) {
422
+ return toasts().length - 1 - ti;
424
423
  }
425
- function toastStyle(t) {
426
- const depthDecl = "--rozie-toast-depth: " + depth(t) + ";";
424
+ function toastStyle(t, ti) {
425
+ const depthDecl = "--rozie-toast-depth: " + depth(ti) + ";";
427
426
  if (t.exiting) return t.swipeExitSign != null ? depthDecl + " --rozie-toast-swipe-exit: " + t.swipeExitSign + ";" : depthDecl;
428
427
  const dragState = swipe();
429
428
  if (!dragState || dragState.id !== t.id) return depthDecl;
@@ -456,7 +455,7 @@ function Toaster(_props) {
456
455
  }
457
456
  }, attrs)} data-rozie-s-12d4265c="">
458
457
 
459
- <_solid_primitives_keyed.Key each={toasts()} by={(t) => t.id}>{(t) => <div role="status" aria-live={(0, _rozie_runtime_solid.rozieAttr)(liveFor(t().type))} class={"rozie-toast " + (0, _rozie_runtime_solid.rozieClass)("rozie-toast--" + t().type + (t().exiting ? " rozie-toast--exiting" : "") + (t().swipeExitSign != null ? " rozie-toast--swipe-exit" : ""))} style={(0, _rozie_runtime_solid.parseInlineStyle)(toastStyle(t()))} onAnimationEnd={($event) => {
458
+ <_solid_primitives_keyed.Key each={toasts()} by={(t) => t.id}>{(t, ti) => <div role="status" aria-live={(0, _rozie_runtime_solid.rozieAttr)(liveFor(t().type))} class={"rozie-toast " + (0, _rozie_runtime_solid.rozieClass)("rozie-toast--" + t().type + (t().exiting ? " rozie-toast--exiting" : "") + (t().swipeExitSign != null ? " rozie-toast--swipe-exit" : ""))} style={(0, _rozie_runtime_solid.parseInlineStyle)(toastStyle(t(), ti()))} onAnimationEnd={($event) => {
460
459
  t().exiting && removeToast(t().id);
461
460
  }} onPointerDown={($event) => {
462
461
  onToastPointerDown(t(), $event);
package/dist/index.mjs CHANGED
@@ -414,12 +414,11 @@ function Toaster(_props) {
414
414
  if (swipeGesture() && swipeGesture().id === t.id) setSwipeGesture(null);
415
415
  if (swipe() && swipe().id === t.id) setSwipe(null);
416
416
  }
417
- function depth(t) {
418
- const idx = toasts().findIndex((x) => x.id === t.id);
419
- return idx === -1 ? 0 : toasts().length - 1 - idx;
417
+ function depth(ti) {
418
+ return toasts().length - 1 - ti;
420
419
  }
421
- function toastStyle(t) {
422
- const depthDecl = "--rozie-toast-depth: " + depth(t) + ";";
420
+ function toastStyle(t, ti) {
421
+ const depthDecl = "--rozie-toast-depth: " + depth(ti) + ";";
423
422
  if (t.exiting) return t.swipeExitSign != null ? depthDecl + " --rozie-toast-swipe-exit: " + t.swipeExitSign + ";" : depthDecl;
424
423
  const dragState = swipe();
425
424
  if (!dragState || dragState.id !== t.id) return depthDecl;
@@ -452,7 +451,7 @@ function Toaster(_props) {
452
451
  }
453
452
  }, attrs)} data-rozie-s-12d4265c="">
454
453
 
455
- <Key each={toasts()} by={(t) => t.id}>{(t) => <div role="status" aria-live={rozieAttr(liveFor(t().type))} class={"rozie-toast " + rozieClass("rozie-toast--" + t().type + (t().exiting ? " rozie-toast--exiting" : "") + (t().swipeExitSign != null ? " rozie-toast--swipe-exit" : ""))} style={parseInlineStyle(toastStyle(t()))} onAnimationEnd={($event) => {
454
+ <Key each={toasts()} by={(t) => t.id}>{(t, ti) => <div role="status" aria-live={rozieAttr(liveFor(t().type))} class={"rozie-toast " + rozieClass("rozie-toast--" + t().type + (t().exiting ? " rozie-toast--exiting" : "") + (t().swipeExitSign != null ? " rozie-toast--swipe-exit" : ""))} style={parseInlineStyle(toastStyle(t(), ti()))} onAnimationEnd={($event) => {
456
455
  t().exiting && removeToast(t().id);
457
456
  }} onPointerDown={($event) => {
458
457
  onToastPointerDown(t(), $event);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rozie-ui/toast-solid",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@solid-primitives/keyed": "^1.5.3",
49
- "@rozie/runtime-solid": "0.2.0"
49
+ "@rozie/runtime-solid": "0.2.1"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "solid-js": "^1.8"
package/src/Toaster.tsx CHANGED
@@ -623,9 +623,18 @@ export default function Toaster(_props: ToasterProps): JSX.Element {
623
623
  // is depth 0; each older toast is one deeper. Corner-independent — the
624
624
  // collapsed grid overlay ignores flex-direction/column-reverse entirely, so
625
625
  // this needs no position-aware math.
626
- function depth(t: any) {
627
- const idx = toasts().findIndex((x: any) => x.id === t.id);
628
- return idx === -1 ? 0 : toasts().length - 1 - idx;
626
+ //
627
+ // quick 260716-npt Finding 3 (perf): depth USED to be a per-toast
628
+ // `$data.toasts.findIndex(...)` scan invoked from toastStyle() for every row
629
+ // — O(n) work × n toasts rendered = O(n^2) per render. The template's r-for
630
+ // already computes each row's array index for free (the r-for bare-comma
631
+ // index form, `t, ti in ...` — see TreeNode.rozie/Table.rozie precedent), so
632
+ // depth(ti) is now O(1) arithmetic off that index — no scan, and `t`'s id
633
+ // can never be "not found" via this call path (ti IS t's own index), so the
634
+ // old idx===-1→0 fallback collapses to unreachable-by-construction (same
635
+ // observable semantics: newest=depth 0, older=length-1-idx).
636
+ function depth(ti: any) {
637
+ return toasts().length - 1 - ti;
629
638
  }
630
639
 
631
640
  // String-form `:style` for the toast row. ALWAYS carries `--rozie-toast-depth`
@@ -633,8 +642,8 @@ export default function Toaster(_props: ToasterProps): JSX.Element {
633
642
  // `.rozie-toaster--stacked`), plus EITHER the active drag transform (while
634
643
  // $data.swipe tracks this id) OR the swipe-exit sign custom property (once
635
644
  // `dismissBegin('swipe')` flipped `t.swipeExitSign`). Drag/exit never overlap.
636
- function toastStyle(t: any) {
637
- const depthDecl = '--rozie-toast-depth: ' + depth(t) + ';';
645
+ function toastStyle(t: any, ti: any) {
646
+ const depthDecl = '--rozie-toast-depth: ' + depth(ti) + ';';
638
647
  if (t.exiting) {
639
648
  return t.swipeExitSign != null ? depthDecl + ' --rozie-toast-swipe-exit: ' + t.swipeExitSign + ';' : depthDecl;
640
649
  }
@@ -674,7 +683,7 @@ export default function Toaster(_props: ToasterProps): JSX.Element {
674
683
  <>
675
684
  <div role="region" aria-label={rozieAttr(regionLabel())} {...attrs} class={"rozie-toaster" + " " + rozieClass('rozie-toaster--' + local.position + (local.stacked ? ' rozie-toaster--stacked' : '')) + (((attrs as unknown as Record<string, unknown>).class as string | undefined) ? " " + ((attrs as unknown as Record<string, unknown>).class as string | undefined) : "")} {...mergeListeners({ onMouseEnter: ($event: MouseEvent & { currentTarget: HTMLDivElement; target: Element }) => { onMouseEnter(); }, onMouseLeave: ($event: MouseEvent & { currentTarget: HTMLDivElement; target: Element }) => { onMouseLeave(); } }, attrs)} data-rozie-s-12d4265c="">
676
685
 
677
- <Key each={toasts() as readonly any[]} by={(t) => t.id}>{(t) => <div role="status" aria-live={rozieAttr(liveFor(t().type))} class={"rozie-toast" + " " + rozieClass('rozie-toast--' + t().type + (t().exiting ? ' rozie-toast--exiting' : '') + (t().swipeExitSign != null ? ' rozie-toast--swipe-exit' : ''))} style={parseInlineStyle(toastStyle(t()))} onAnimationEnd={($event: AnimationEvent & { currentTarget: HTMLDivElement; target: Element }) => { t().exiting && removeToast(t().id); }} onPointerDown={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerDown(t(), $event); }} onPointerMove={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerMove(t(), $event); }} onPointerUp={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerUp(t(), $event); }} onPointerCancel={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerCancel(t()); }} data-rozie-s-12d4265c="">
686
+ <Key each={toasts() as readonly any[]} by={(t) => t.id}>{(t, ti) => <div role="status" aria-live={rozieAttr(liveFor(t().type))} class={"rozie-toast" + " " + rozieClass('rozie-toast--' + t().type + (t().exiting ? ' rozie-toast--exiting' : '') + (t().swipeExitSign != null ? ' rozie-toast--swipe-exit' : ''))} style={parseInlineStyle(toastStyle(t(), ti()))} onAnimationEnd={($event: AnimationEvent & { currentTarget: HTMLDivElement; target: Element }) => { t().exiting && removeToast(t().id); }} onPointerDown={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerDown(t(), $event); }} onPointerMove={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerMove(t(), $event); }} onPointerUp={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerUp(t(), $event); }} onPointerCancel={($event: PointerEvent & { currentTarget: HTMLDivElement; target: Element }) => { onToastPointerCancel(t()); }} data-rozie-s-12d4265c="">
678
687
  {(_props.toastSlot ?? _props.slots?.['toast'])?.({ toast: t(), dismiss }) ?? <>{<Show when={t().type === 'loading'}><span class={"rozie-toast-spinner"} aria-hidden="true" data-rozie-s-12d4265c="" /></Show>}<span class={"rozie-toast-message"} data-rozie-s-12d4265c="">{rozieDisplay(t().message)}</span><button type="button" aria-label="Dismiss" class={"rozie-toast-close"} onClick={($event: MouseEvent & { currentTarget: HTMLButtonElement; target: Element }) => { dismissBegin(t().id, 'close'); }} data-rozie-s-12d4265c="">×</button></>}
679
688
  </div>}</Key>
680
689
  </div>