@solid2-aria/sonner 0.0.1 → 0.1.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
@@ -1,14 +1,15 @@
1
- # Solid 2 Sonner
1
+ # @solid2-aria/sonner
2
2
 
3
3
  Toast notifications for Solid 2, adapted from solid-sonner and Sonner. Requires `solid-js` and `@solidjs/web` 2.0.0-rc.17 or later in the Solid 2 release line.
4
4
 
5
- In a workspace app, add the dependency and build the package from the repository root:
5
+ ## Installation
6
6
 
7
7
  ```sh
8
- bun add --cwd apps/your-app @solid2-aria/sonner@^0.0.1
9
- bun run --filter @solid2-aria/sonner build
8
+ bun add @solid2-aria/sonner solid-js@next @solidjs/web@next
10
9
  ```
11
10
 
11
+ ## Usage
12
+
12
13
  Import the stylesheet once in your app entry point, and mount a `Toaster`:
13
14
 
14
15
  ```tsx
@@ -61,7 +62,7 @@ function NotificationCount() {
61
62
 
62
63
  The export selects compiled browser code for browser bundles and SSR code for server bundles. SSR and hydration are checked with Solid's rendering APIs. Toast state is module scoped, so call `toast()` from client interactions rather than request-scoped server code.
63
64
 
64
- Run verification from `packages/sonner`:
65
+ Run verification from `packages/solid2-sonner`:
65
66
 
66
67
  ```sh
67
68
  bun run build
@@ -391,10 +391,10 @@ function isAction(action) {
391
391
  }
392
392
  // src/index.tsx
393
393
  var _tmpl$ = /* @__PURE__ */ template(`<button data-button>`);
394
- var _tmpl$2 = /* @__PURE__ */ template(`<button data-close-button>`);
395
- var _tmpl$3 = /* @__PURE__ */ template(`<div data-icon><!$><!/><!$><!/>`);
396
- var _tmpl$4 = /* @__PURE__ */ template(`<div data-description>`);
397
- var _tmpl$5 = /* @__PURE__ */ template(`<div data-content><div data-title></div><!$><!/>`);
394
+ var _tmpl$2 = /* @__PURE__ */ template(`<div data-content><div data-title></div><!$><!/>`);
395
+ var _tmpl$3 = /* @__PURE__ */ template(`<button data-close-button>`);
396
+ var _tmpl$4 = /* @__PURE__ */ template(`<div data-icon><!$><!/><!$><!/>`);
397
+ var _tmpl$5 = /* @__PURE__ */ template(`<div data-description>`);
398
398
  var _tmpl$6 = /* @__PURE__ */ template(`<div>`);
399
399
  var _tmpl$7 = /* @__PURE__ */ template(`<li tabindex=0 data-sonner-toast>`);
400
400
  var _tmpl$8 = /* @__PURE__ */ template(`<section tabindex=-1 aria-live=polite aria-relevant="additions text"aria-atomic=false data-react-aria-top-layer>`);
@@ -610,26 +610,23 @@ function ToastBody(props) {
610
610
  return null;
611
611
  };
612
612
  return [
613
- createComponent(Show, {
614
- get when() {
615
- return memo(() => {
616
- return !!(props.closeButton && !hasCustomContent());
617
- })() ? toastType() !== "loading" : props.closeButton && !hasCustomContent();
618
- },
619
- get children() {
620
- var _el$2 = getNextElement(_tmpl$2);
621
- _el$2._$$click = () => {
613
+ memo(() => {
614
+ return memo(() => {
615
+ return !!(props.closeButton && !hasCustomContent() && toastType() !== "loading");
616
+ })() ? (() => {
617
+ var _el$7 = getNextElement(_tmpl$3);
618
+ _el$7._$$click = () => {
622
619
  if (props.disabled || !props.dismissible) return;
623
620
  props.onDelete();
624
621
  props.onDismiss();
625
622
  };
626
- _el$2._$$pointerup = (event) => {
623
+ _el$7._$$pointerup = (event) => {
627
624
  event.stopPropagation();
628
625
  };
629
- _el$2._$$pointerdown = (event) => {
626
+ _el$7._$$pointerdown = (event) => {
630
627
  event.stopPropagation();
631
628
  };
632
- insert(_el$2, scope(() => {
629
+ insert(_el$7, scope(() => {
633
630
  return props.icons?.close ?? createComponent(CloseIcon, {});
634
631
  }));
635
632
  effect(() => {
@@ -639,74 +636,75 @@ function ToastBody(props) {
639
636
  a: readShallow(cn(classNames()?.closeButton, toastClassNames()?.closeButton))
640
637
  };
641
638
  }, ({ e, t, a }, _p$) => {
642
- e !== _p$?.e && setAttribute(_el$2, "aria-label", e);
643
- t !== _p$?.t && setAttribute(_el$2, "data-disabled", t);
644
- className(_el$2, a, _p$?.a);
639
+ e !== _p$?.e && setAttribute(_el$7, "aria-label", e);
640
+ t !== _p$?.t && setAttribute(_el$7, "data-disabled", t);
641
+ className(_el$7, a, _p$?.a);
645
642
  });
646
643
  runHydrationEvents();
647
- return _el$2;
648
- }
644
+ return _el$7;
645
+ })() : void 0;
649
646
  }),
650
- createComponent(Show, {
651
- get when() {
652
- return hasIcon();
653
- },
654
- get children() {
655
- var _el$3 = getNextElement(_tmpl$3);
656
- var _el$4 = _el$3.firstChild;
657
- var [_el$5, _el$6] = getNextMarker(_el$4.nextSibling);
658
- var _el$7 = _el$5.nextSibling;
659
- var [_el$8, _el$9] = getNextMarker(_el$7.nextSibling);
660
- insert(_el$3, scope(() => {
647
+ memo(() => {
648
+ return memo(() => {
649
+ return !!hasIcon();
650
+ })() ? (() => {
651
+ var _el$8 = getNextElement(_tmpl$4);
652
+ var _el$9 = _el$8.firstChild;
653
+ var [_el$10, _el$11] = getNextMarker(_el$9.nextSibling);
654
+ var _el$12 = _el$10.nextSibling;
655
+ var [_el$13, _el$14] = getNextMarker(_el$12.nextSibling);
656
+ insert(_el$8, scope(() => {
661
657
  return loadingIconContent();
662
- }), _el$5, _el$6);
663
- insert(_el$3, scope((() => {
664
- var _c$ = memo(() => {
658
+ }), _el$10, _el$11);
659
+ insert(_el$8, scope((() => {
660
+ var _c$2 = memo(() => {
665
661
  return toastType() === "loading";
666
662
  });
667
663
  return () => {
668
- return _c$() ? null : props.getIcon();
664
+ return _c$2() ? null : props.getIcon();
669
665
  };
670
- })()), _el$8, _el$9);
666
+ })()), _el$13, _el$14);
671
667
  effect(() => readShallow(cn(classNames()?.icon, toastClassNames()?.icon)), (_v$, _$p) => {
672
- className(_el$3, _v$, _$p);
668
+ className(_el$8, _v$, _$p);
673
669
  });
674
- return _el$3;
675
- }
670
+ return _el$8;
671
+ })() : void 0;
676
672
  }),
677
673
  (() => {
678
- var _el$10 = getNextElement(_tmpl$5);
679
- var _el$11 = _el$10.firstChild;
680
- var _el$13 = _el$11.nextSibling;
681
- var [_el$14, _el$15] = getNextMarker(_el$13.nextSibling);
682
- insert(_el$11, scope(() => {
674
+ var _el$2 = getNextElement(_tmpl$2);
675
+ var _el$3 = _el$2.firstChild;
676
+ var _el$4 = _el$3.nextSibling;
677
+ var [_el$5, _el$6] = getNextMarker(_el$4.nextSibling);
678
+ insert(_el$3, scope(() => {
683
679
  return props.toast.jsx ?? resolveContent(props.toast.title);
684
680
  }));
685
- insert(_el$10, createComponent(Show, {
686
- get when() {
687
- return props.toast.description;
688
- },
689
- get children() {
690
- var _el$12 = getNextElement(_tmpl$4);
691
- insert(_el$12, scope(() => {
692
- return resolveContent(props.toast.description);
693
- }));
694
- effect(() => readShallow(cn(props.descriptionClassName, props.toastDescriptionClassName, classNames()?.description, toastClassNames()?.description)), (_v$, _$p) => {
695
- className(_el$12, _v$, _$p);
696
- });
697
- return _el$12;
698
- }
699
- }), _el$14, _el$15);
681
+ insert(_el$2, scope((() => {
682
+ var _c$ = memo(() => {
683
+ return !!props.toast.description;
684
+ });
685
+ return () => {
686
+ return _c$() ? (() => {
687
+ var _el$15 = getNextElement(_tmpl$5);
688
+ insert(_el$15, scope(() => {
689
+ return resolveContent(props.toast.description);
690
+ }));
691
+ effect(() => readShallow(cn(props.descriptionClassName, props.toastDescriptionClassName, classNames()?.description, toastClassNames()?.description)), (_v$, _$p) => {
692
+ className(_el$15, _v$, _$p);
693
+ });
694
+ return _el$15;
695
+ })() : void 0;
696
+ };
697
+ })()), _el$5, _el$6);
700
698
  effect(() => {
701
699
  return {
702
700
  e: readShallow(cn(classNames()?.content, toastClassNames()?.content)),
703
701
  t: readShallow(cn(classNames()?.title, toastClassNames()?.title))
704
702
  };
705
703
  }, ({ e, t }, _p$) => {
706
- className(_el$10, e, _p$?.e);
707
- className(_el$11, t, _p$?.t);
704
+ className(_el$2, e, _p$?.e);
705
+ className(_el$3, t, _p$?.t);
708
706
  });
709
- return _el$10;
707
+ return _el$2;
710
708
  })(),
711
709
  createComponent(Show, {
712
710
  get when() {
@@ -1206,11 +1204,10 @@ function Toaster(props) {
1206
1204
  const [y, x] = position.split("-");
1207
1205
  const toastsByPosition = createMemo(() => filteredToasts().filter((toast) => !toast.position && index() === 0 || toast.position === position));
1208
1206
  const heightsByPosition = createMemo(() => heights().filter((height) => index() === 0 && !height.position || height.position === position));
1209
- return createComponent(Show, {
1210
- get when() {
1207
+ return memo(() => {
1208
+ return memo(() => {
1211
1209
  return filteredToasts().length > 0;
1212
- },
1213
- get children() {
1210
+ })() ? (() => {
1214
1211
  var _el$19 = getNextElement(_tmpl$9);
1215
1212
  _el$19._$$pointerup = () => {
1216
1213
  setInteracting(false);
@@ -1354,7 +1351,7 @@ function Toaster(props) {
1354
1351
  });
1355
1352
  runHydrationEvents();
1356
1353
  return _el$19;
1357
- }
1354
+ })() : void 0;
1358
1355
  });
1359
1356
  }
1360
1357
  }));