varsel 0.5.2 → 0.6.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/dist/internals.js CHANGED
@@ -4,10 +4,10 @@
4
4
  * This file is meant for internal package usage and shouldn't generally be imported directly by consumers.
5
5
  */
6
6
  export { ANIMATION_CONFIG } from "./core/animations";
7
- export { FOCUSABLE_SELECTORS } from "./core/accessibility";
7
+ export { FOCUSABLE_SELECTORS, focusManager, isFocusVisible, } from "./core/accessibility";
8
8
  export { POSITION_CONFIGS } from "./core/positions";
9
- export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, getDefaultSwipeDirections, } from "./core/swipe";
10
- export { toastContainerVariants, toastContentVariants, } from "./core/variants";
9
+ export { SWIPE_DISMISS_THRESHOLD, SWIPE_DISMISS_VELOCITY, SWIPE_EXIT_DISTANCE, SWIPE_REVERSE_CANCEL_THRESHOLD, getDefaultSwipeDirections, } from "./core/swipe";
10
+ export { toastContainerVariants, toastContentVariants } from "./core/variants";
11
11
  export { cn } from "./core/utils";
12
12
  export { toast } from "./core/toast-factory";
13
13
  export { toastState } from "./core/toast-state";
package/dist/styles.css CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Main stylesheet for Varsel.
3
3
  * Built with Tailwind CSS v4 using the @theme directive.
4
- *
4
+ *
5
5
  * Defines custom CSS variables for colors, shadows, and animations.
6
6
  * Supports light and dark modes via the .dark class (standard Tailwind approach).
7
7
  */
@@ -11,50 +11,47 @@
11
11
 
12
12
  :root {
13
13
  /* Base hue used for generating the color palette (oklch) */
14
- --base-hue: 265;
14
+ --base-hue: 285;
15
15
 
16
16
  /* Semantic color tokens */
17
- --color-vs-popover: oklch(1 0 0);
18
- --color-vs-popover-muted: oklch(0.96 0.002 var(--base-hue));
19
- --color-vs-foreground: oklch(0.1408 0.0044 var(--base-hue));
20
- --color-vs-border: oklch(0.8925 0.0014 var(--base-hue));
21
- --color-vs-ring: oklch(0.55 0.012 var(--base-hue));
22
- --color-vs-ring-offset: oklch(0.96 0.002 var(--base-hue));
23
- --color-vs-destructive: oklch(0.62 0.21 25);
24
- --color-vs-warning: oklch(0.8 0.2 75);
25
- --color-vs-success: oklch(0.7 0.18 155);
26
- --color-vs-info: oklch(0.7 0.18 240);
17
+ --vs-popover: oklch(0.9851 0 0);
18
+ --vs-popover-muted: oklch(0.9497 0.0027 var(--base-hue));
19
+ --vs-foreground: oklch(0.1408 0.0044 var(--base-hue));
20
+ --vs-border: oklch(0.9437 0.0027 var(--base-hue));
21
+ --vs-ring: oklch(0.55 0.012 var(--base-hue));
22
+ --vs-ring-offset: oklch(0.96 0.002 var(--base-hue));
23
+ --vs-destructive: oklch(0.62 0.21 25);
24
+ --vs-warning: oklch(0.8 0.2 75);
25
+ --vs-success: oklch(0.7 0.18 155);
26
+ --vs-info: oklch(0.7 0.18 240);
27
27
 
28
28
  /* Shadows */
29
29
  --shadow-vs-button:
30
- 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15), 0px 3px 3px -1.5px
31
- rgba(0, 0, 0, 0.05);
30
+ 0px 1px 1px -0.5px rgb(0 0 0 / 0.06), 0px 3px 3px -1.5px rgb(0 0 0 / 0.06),
31
+ 0px 6px 6px -3px rgb(0 0 0 / 0.06);
32
32
  --shadow-vs-toast:
33
- 0px 1px 1px -0.5px rgba(0, 0, 0, 0.15),
34
- 0px 3px 3px -1.5px rgba(0, 0, 0, 0.05),
35
- 0px 6px 6px -3px rgba(0, 0, 0, 0.05),
36
- 0px 12px 12px -6px rgba(0, 0, 0, 0.05),
37
- 0px 24px 24px -12px rgba(0, 0, 0, 0.05),
38
- 0px 48px 48px -24px rgba(0, 0, 0, 0.05);
33
+ 0px 1px 1px -0.5px rgb(0 0 0 / 0.06), 0px 3px 3px -1.5px rgb(0 0 0 / 0.06),
34
+ 0px 6px 6px -3px rgb(0 0 0 / 0.06), 0px 12px 12px -6px rgb(0 0 0 / 0.06),
35
+ 0px 24px 24px -12px rgb(0 0 0 / 0.06);
39
36
 
40
37
  /* Radius & Easing */
41
- --radius-base: 0.125rem;
38
+ --radius-base: 0.15rem;
42
39
  --ease-vs-button: cubic-bezier(0.25, 0.46, 0.45, 0.94);
43
40
  --ease-vs-toast: cubic-bezier(0.32, 0.72, 0, 1);
44
41
  --ease-vs-pop: cubic-bezier(0.18, 0.89, 0.32, 1.28);
45
42
  }
46
43
 
47
44
  .dark {
48
- --color-vs-popover: oklch(0.2139 0.0101 var(--base-hue));
49
- --color-vs-popover-muted: oklch(0.2502 0.016 var(--base-hue));
50
- --color-vs-foreground: oklch(0.9824 0.0013 var(--base-hue));
51
- --color-vs-border: oklch(0.278 0.015 var(--base-hue));
52
- --color-vs-ring: oklch(0.58 0.012 var(--base-hue));
53
- --color-vs-ring-offset: oklch(0.15 0.005 var(--base-hue));
54
- --color-vs-destructive: oklch(0.72 0.27 25);
55
- --color-vs-warning: oklch(0.82 0.24 85);
56
- --color-vs-success: oklch(0.78 0.25 155);
57
- --color-vs-info: oklch(0.78 0.18 240);
45
+ --vs-popover: oklch(0.2103 0.0059 var(--base-hue));
46
+ --vs-popover-muted: oklch(0.2367 0.0076 var(--base-hue));
47
+ --vs-foreground: oklch(0.9851 0 0);
48
+ --vs-border: oklch(0.2739 0.0055 var(--base-hue));
49
+ --vs-ring: oklch(0.58 0.012 var(--base-hue));
50
+ --vs-ring-offset: oklch(0.15 0.005 var(--base-hue));
51
+ --vs-destructive: oklch(0.72 0.27 25);
52
+ --vs-warning: oklch(0.82 0.24 85);
53
+ --vs-success: oklch(0.78 0.25 155);
54
+ --vs-info: oklch(0.78 0.18 240);
58
55
  }
59
56
 
60
57
  @theme {
@@ -124,7 +121,8 @@
124
121
 
125
122
  .vs-icon--waiting {
126
123
  opacity: 0;
127
- transform: scale(0.75) rotate(-6deg);
124
+ transform: scale(0.25);
125
+ filter: blur(4px);
128
126
  }
129
127
 
130
128
  .vs-icon--pop {
@@ -136,6 +134,18 @@
136
134
  height: 100%;
137
135
  }
138
136
 
137
+ .vs-sr-only {
138
+ position: absolute;
139
+ width: 1px;
140
+ height: 1px;
141
+ padding: 0;
142
+ margin: -1px;
143
+ overflow: hidden;
144
+ clip: rect(0, 0, 0, 0);
145
+ white-space: nowrap;
146
+ border: 0;
147
+ }
148
+
139
149
  @keyframes vs-spin {
140
150
  to {
141
151
  transform: rotate(360deg);
@@ -145,35 +155,25 @@
145
155
  @keyframes vs-spinner-finish {
146
156
  0% {
147
157
  opacity: 1;
148
- transform: scale(1) rotate(0deg);
158
+ transform: scale(1);
149
159
  filter: blur(0);
150
160
  }
151
- 60% {
152
- opacity: 0.65;
153
- transform: scale(0.55) rotate(140deg);
154
- filter: blur(0.3px);
155
- }
156
161
  100% {
157
162
  opacity: 0;
158
- transform: scale(0) rotate(220deg);
159
- filter: blur(0.8px);
163
+ transform: scale(0.25);
164
+ filter: blur(4px);
160
165
  }
161
166
  }
162
167
 
163
168
  @keyframes vs-icon-pop {
164
169
  0% {
165
170
  opacity: 0;
166
- transform: scale(0.5) rotate(-10deg);
167
- filter: blur(2px);
168
- }
169
- 60% {
170
- opacity: 1;
171
- transform: scale(1.18) rotate(2deg);
172
- filter: blur(0);
171
+ transform: scale(0.25);
172
+ filter: blur(4px);
173
173
  }
174
174
  100% {
175
175
  opacity: 1;
176
- transform: scale(1) rotate(0deg);
176
+ transform: scale(1);
177
177
  filter: blur(0);
178
178
  }
179
179
  }
@@ -192,4 +192,4 @@
192
192
  opacity: 1;
193
193
  transform: scale(1);
194
194
  }
195
- }
195
+ }
@@ -5,15 +5,20 @@
5
5
  import type { ToastData } from "./internals";
6
6
  declare const ICON_VARIANTS: readonly ["success", "warning", "destructive", "info"];
7
7
  export type IconVariant = (typeof ICON_VARIANTS)[number];
8
- type IconElement = {
8
+ export type IconElement = {
9
9
  tag: "path";
10
10
  d: string;
11
+ fill?: boolean;
11
12
  } | {
12
13
  tag: "line";
13
14
  x1: number;
14
15
  y1: number;
15
16
  x2: number;
16
17
  y2: number;
18
+ opacity?: number;
19
+ } | {
20
+ tag: "polyline";
21
+ points: string;
17
22
  } | {
18
23
  tag: "circle";
19
24
  cx: number;
@@ -27,74 +32,43 @@ export interface VariantIconDefinition {
27
32
  export declare const variantIconMap: {
28
33
  success: {
29
34
  viewBox: string;
30
- elements: ({
31
- tag: "circle";
32
- cx: number;
33
- cy: number;
34
- r: number;
35
- d?: undefined;
36
- } | {
37
- tag: "path";
38
- d: string;
39
- cx?: undefined;
40
- cy?: undefined;
41
- r?: undefined;
42
- })[];
35
+ elements: {
36
+ tag: "polyline";
37
+ points: string;
38
+ }[];
43
39
  };
44
40
  warning: {
45
41
  viewBox: string;
46
42
  elements: ({
47
43
  tag: "path";
48
44
  d: string;
49
- x1?: undefined;
50
- y1?: undefined;
51
- x2?: undefined;
52
- y2?: undefined;
45
+ fill?: undefined;
53
46
  } | {
47
+ tag: "path";
48
+ d: string;
49
+ fill: true;
50
+ })[];
51
+ };
52
+ destructive: {
53
+ viewBox: string;
54
+ elements: {
54
55
  tag: "line";
55
56
  x1: number;
56
57
  y1: number;
57
58
  x2: number;
58
59
  y2: number;
59
- d?: undefined;
60
- })[];
60
+ }[];
61
61
  };
62
- destructive: {
62
+ info: {
63
63
  viewBox: string;
64
64
  elements: ({
65
- tag: "circle";
66
- cx: number;
67
- cy: number;
68
- r: number;
69
- d?: undefined;
70
- } | {
71
65
  tag: "path";
72
66
  d: string;
73
- cx?: undefined;
74
- cy?: undefined;
75
- r?: undefined;
76
- })[];
77
- };
78
- info: {
79
- viewBox: string;
80
- elements: ({
81
- tag: "circle";
82
- cx: number;
83
- cy: number;
84
- r: number;
85
- x1?: undefined;
86
- y1?: undefined;
87
- x2?: undefined;
88
- y2?: undefined;
67
+ fill?: undefined;
89
68
  } | {
90
- tag: "line";
91
- x1: number;
92
- y1: number;
93
- x2: number;
94
- y2: number;
95
- cx?: undefined;
96
- cy?: undefined;
97
- r?: undefined;
69
+ tag: "path";
70
+ d: string;
71
+ fill: true;
98
72
  })[];
99
73
  };
100
74
  };
@@ -1 +1 @@
1
- {"version":3,"file":"variant-icons.d.ts","sourceRoot":"","sources":["../src/lib/variant-icons.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,QAAA,MAAM,aAAa,wDAAyD,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,KAAK,WAAW,GACb;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC/D;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC2B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAC1B,UAAU,SAAS,CAAC,SAAS,CAAC,KAC5B,OAAO,IAAI,WAEb,CAAC"}
1
+ {"version":3,"file":"variant-icons.d.ts","sourceRoot":"","sources":["../src/lib/variant-icons.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,QAAA,MAAM,aAAa,wDAAyD,CAAC;AAE7E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,WAAW,GACpB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1C;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF;IAAE,GAAG,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C2B,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAC1B,UAAU,SAAS,CAAC,SAAS,CAAC,KAC5B,OAAO,IAAI,WAEb,CAAC"}
@@ -1,37 +1,47 @@
1
1
  const ICON_VARIANTS = ["success", "warning", "destructive", "info"];
2
2
  export const variantIconMap = {
3
3
  success: {
4
- viewBox: "0 0 24 24",
5
- elements: [
6
- { tag: "circle", cx: 12, cy: 12, r: 10 },
7
- { tag: "path", d: "m9 12 2 2 4-4" },
8
- ],
4
+ viewBox: "0 0 18 18",
5
+ elements: [{ tag: "polyline", points: "2.75 9.25 6.75 14.25 15.25 3.75" }],
9
6
  },
10
7
  warning: {
11
- viewBox: "0 0 24 24",
8
+ viewBox: "0 0 18 18",
12
9
  elements: [
13
10
  {
14
11
  tag: "path",
15
- d: "M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z",
12
+ d: "M7.63796 3.48996L2.21295 12.89C1.60795 13.9399 2.36395 15.25 3.57495 15.25H14.425C15.636 15.25 16.392 13.9399 15.787 12.89L10.362 3.48996C9.75696 2.44996 8.24296 2.44996 7.63796 3.48996Z",
13
+ },
14
+ { tag: "path", d: "M9 6.75V9.75" },
15
+ {
16
+ tag: "path",
17
+ d: "M9 13.5C8.448 13.5 8 13.05 8 12.5C8 11.95 8.448 11.5 9 11.5C9.552 11.5 10 11.9501 10 12.5C10 13.0499 9.552 13.5 9 13.5Z",
18
+ fill: true,
16
19
  },
17
- { tag: "line", x1: 12, y1: 9, x2: 12, y2: 13 },
18
- { tag: "line", x1: 12, y1: 17, x2: 12.01, y2: 17 },
19
20
  ],
20
21
  },
21
22
  destructive: {
22
- viewBox: "0 0 24 24",
23
+ viewBox: "0 0 18 18",
23
24
  elements: [
24
- { tag: "circle", cx: 12, cy: 12, r: 10 },
25
- { tag: "path", d: "m15 9-6 6" },
26
- { tag: "path", d: "m9 9 6 6" },
25
+ { tag: "line", x1: 14, y1: 4, x2: 4, y2: 14 },
26
+ { tag: "line", x1: 4, y1: 4, x2: 14, y2: 14 },
27
27
  ],
28
28
  },
29
29
  info: {
30
- viewBox: "0 0 24 24",
30
+ viewBox: "0 0 18 18",
31
31
  elements: [
32
- { tag: "circle", cx: 12, cy: 12, r: 10 },
33
- { tag: "line", x1: 12, y1: 16, x2: 12, y2: 12 },
34
- { tag: "line", x1: 12, y1: 8, x2: 12.01, y2: 8 },
32
+ {
33
+ tag: "path",
34
+ d: "M9 16.25C13.004 16.25 16.25 13.004 16.25 9C16.25 4.996 13.004 1.75 9 1.75C4.996 1.75 1.75 4.996 1.75 9C1.75 13.004 4.996 16.25 9 16.25Z",
35
+ },
36
+ {
37
+ tag: "path",
38
+ d: "M9 12.75V9.25C9 8.9739 8.7761 8.75 8.5 8.75H7.75",
39
+ },
40
+ {
41
+ tag: "path",
42
+ d: "M9 6.75C8.448 6.75 8 6.301 8 5.75C8 5.199 8.448 4.75 9 4.75C9.552 4.75 10 5.199 10 5.75C10 6.301 9.552 6.75 9 6.75Z",
43
+ fill: true,
44
+ },
35
45
  ],
36
46
  },
37
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "varsel",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Headless yet opinionated toast notifications for Svelte apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,6 +41,7 @@
41
41
  "build": "bun run build:css && svelte-package",
42
42
  "check": "svelte-check --tsconfig ./tsconfig.json",
43
43
  "dev": "bun run build:css:watch & svelte-package --watch",
44
+ "test": "vitest run",
44
45
  "lint": "tsc -p tsconfig.json --noEmit",
45
46
  "prepublishOnly": "bun run build"
46
47
  },
@@ -52,7 +53,6 @@
52
53
  "tailwindcss": "^4.1.18"
53
54
  },
54
55
  "devDependencies": {
55
- "@biomejs/biome": "2.3.8",
56
56
  "@sveltejs/package": "^2.5.7",
57
57
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
58
58
  "@tailwindcss/cli": "^4",