@jameskabz/nextcraft-ui 0.8.2 → 0.8.4
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/components/craft-data-table-header.cjs +1 -1
- package/dist/components/craft-data-table-header.cjs.map +1 -1
- package/dist/components/craft-data-table-header.js +1 -1
- package/dist/components/craft-data-table-header.js.map +1 -1
- package/dist/components/craft-data-table.cjs +2 -2
- package/dist/components/craft-data-table.cjs.map +1 -1
- package/dist/components/craft-data-table.js +2 -2
- package/dist/components/craft-data-table.js.map +1 -1
- package/dist/components/craft-loader.cjs +20 -4
- package/dist/components/craft-loader.cjs.map +1 -1
- package/dist/components/craft-loader.js +20 -4
- package/dist/components/craft-loader.js.map +1 -1
- package/dist/components/craft-toast.d.cts +11 -3
- package/dist/components/craft-toast.d.ts +11 -3
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/lib/toast.cjs +235 -0
- package/dist/lib/toast.cjs.map +1 -0
- package/dist/{craft-toast-BcscwgO3.d.ts → lib/toast.d.cts} +3 -9
- package/dist/{craft-toast-C7rMmROV.d.cts → lib/toast.d.ts} +3 -9
- package/dist/lib/toast.js +197 -0
- package/dist/lib/toast.js.map +1 -0
- package/dist/styles.css +35 -0
- package/package.json +1 -1
|
@@ -150,7 +150,7 @@ function CraftLoader({
|
|
|
150
150
|
overlay = false,
|
|
151
151
|
text,
|
|
152
152
|
textPosition = "bottom",
|
|
153
|
-
backgroundColor = "
|
|
153
|
+
backgroundColor = "rgba(0, 0, 0, 0.75)",
|
|
154
154
|
tone,
|
|
155
155
|
className
|
|
156
156
|
}) {
|
|
@@ -178,13 +178,29 @@ function CraftLoader({
|
|
|
178
178
|
}
|
|
179
179
|
);
|
|
180
180
|
if (!overlay) return content;
|
|
181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
182
182
|
"div",
|
|
183
183
|
{
|
|
184
|
-
className: "absolute inset-0 z-10 flex items-center justify-center",
|
|
184
|
+
className: "absolute inset-0 z-10 flex items-center justify-center overflow-hidden backdrop-blur-md",
|
|
185
185
|
style: { backgroundColor },
|
|
186
186
|
"data-nc-theme": tone,
|
|
187
|
-
children:
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
189
|
+
"span",
|
|
190
|
+
{
|
|
191
|
+
className: "pointer-events-none absolute inset-0 bg-linear-to-br from-[rgb(var(--nc-accent-1)/0.12)] via-transparent to-[rgb(var(--nc-accent-3)/0.12)]",
|
|
192
|
+
"aria-hidden": "true"
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
196
|
+
"span",
|
|
197
|
+
{
|
|
198
|
+
className: "pointer-events-none absolute -left-1/4 -top-1/3 h-full w-[120%] rotate-6 bg-white/10 blur-2xl opacity-40",
|
|
199
|
+
"aria-hidden": "true"
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative z-10", children: content })
|
|
203
|
+
]
|
|
188
204
|
}
|
|
189
205
|
);
|
|
190
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/craft-loader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftLoaderType =\n | \"spin\"\n | \"pulse\"\n | \"bounce\"\n | \"ripple\"\n | \"bars\"\n | \"dots\"\n | \"ring\";\n\nexport type CraftLoaderSize = \"small\" | \"medium\" | \"large\" | \"xl\";\n\nexport type CraftLoaderProps = {\n loading?: boolean;\n type?: CraftLoaderType;\n size?: CraftLoaderSize;\n color?: string;\n overlay?: boolean;\n text?: React.ReactNode;\n textPosition?: \"top\" | \"bottom\";\n backgroundColor?: string;\n tone?: ThemeName;\n className?: string;\n};\n\nconst sizeMap: Record<CraftLoaderSize, number> = {\n small: 16,\n medium: 24,\n large: 32,\n xl: 40,\n};\n\nfunction Spinner({ size, color }: { size: number; color: string }) {\n return (\n <svg\n className=\"animate-spin\"\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke={color}\n strokeWidth=\"4\"\n className=\"opacity-25\"\n />\n <path\n d=\"M4 12a8 8 0 018-8\"\n stroke={color}\n strokeWidth=\"4\"\n strokeLinecap=\"round\"\n className=\"opacity-75\"\n />\n </svg>\n );\n}\n\nfunction Dots({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 6));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1, 2].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 120}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Bars({ size, color }: { size: number; color: string }) {\n const barHeight = size;\n const barWidth = Math.max(3, Math.floor(size / 6));\n return (\n <div className=\"flex items-end gap-1\">\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-pulse rounded-sm\"\n style={{\n width: barWidth,\n height: barHeight - index * 4,\n backgroundColor: color,\n animationDelay: `${index * 100}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Pulse({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-pulse rounded-full\"\n style={{ width: size, height: size, backgroundColor: color }}\n />\n );\n}\n\nfunction Ripple({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex rounded-full border-2 animate-ping\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Ring({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-spin rounded-full border-2 border-t-transparent\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Bounce({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 5));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 140}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nexport function CraftLoader({\n loading = false,\n type = \"dots\",\n size = \"medium\",\n color = \"rgb(var(--nc-accent-1))\",\n overlay = false,\n text,\n textPosition = \"bottom\",\n backgroundColor = \"
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-loader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftLoaderType =\n | \"spin\"\n | \"pulse\"\n | \"bounce\"\n | \"ripple\"\n | \"bars\"\n | \"dots\"\n | \"ring\";\n\nexport type CraftLoaderSize = \"small\" | \"medium\" | \"large\" | \"xl\";\n\nexport type CraftLoaderProps = {\n loading?: boolean;\n type?: CraftLoaderType;\n size?: CraftLoaderSize;\n color?: string;\n overlay?: boolean;\n text?: React.ReactNode;\n textPosition?: \"top\" | \"bottom\";\n backgroundColor?: string;\n tone?: ThemeName;\n className?: string;\n};\n\nconst sizeMap: Record<CraftLoaderSize, number> = {\n small: 16,\n medium: 24,\n large: 32,\n xl: 40,\n};\n\nfunction Spinner({ size, color }: { size: number; color: string }) {\n return (\n <svg\n className=\"animate-spin\"\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke={color}\n strokeWidth=\"4\"\n className=\"opacity-25\"\n />\n <path\n d=\"M4 12a8 8 0 018-8\"\n stroke={color}\n strokeWidth=\"4\"\n strokeLinecap=\"round\"\n className=\"opacity-75\"\n />\n </svg>\n );\n}\n\nfunction Dots({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 6));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1, 2].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 120}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Bars({ size, color }: { size: number; color: string }) {\n const barHeight = size;\n const barWidth = Math.max(3, Math.floor(size / 6));\n return (\n <div className=\"flex items-end gap-1\">\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-pulse rounded-sm\"\n style={{\n width: barWidth,\n height: barHeight - index * 4,\n backgroundColor: color,\n animationDelay: `${index * 100}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Pulse({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-pulse rounded-full\"\n style={{ width: size, height: size, backgroundColor: color }}\n />\n );\n}\n\nfunction Ripple({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex rounded-full border-2 animate-ping\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Ring({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-spin rounded-full border-2 border-t-transparent\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Bounce({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 5));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 140}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nexport function CraftLoader({\n loading = false,\n type = \"dots\",\n size = \"medium\",\n color = \"rgb(var(--nc-accent-1))\",\n overlay = false,\n text,\n textPosition = \"bottom\",\n backgroundColor = \"rgba(0, 0, 0, 0.75)\",\n tone,\n className,\n}: CraftLoaderProps) {\n if (!loading) return null;\n\n const px = sizeMap[size];\n\n const content = (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-3\",\n textPosition === \"top\" && \"flex-col-reverse\",\n className\n )}\n data-nc-theme={tone}\n >\n {type === \"spin\" && <Spinner size={px} color={color} />}\n {type === \"dots\" && <Dots size={px} color={color} />}\n {type === \"bars\" && <Bars size={px} color={color} />}\n {type === \"pulse\" && <Pulse size={px} color={color} />}\n {type === \"ripple\" && <Ripple size={px} color={color} />}\n {type === \"ring\" && <Ring size={px} color={color} />}\n {type === \"bounce\" && <Bounce size={px} color={color} />}\n {text ? <span className=\"text-xs text-[rgb(var(--nc-fg-muted))]\">{text}</span> : null}\n </div>\n );\n\n if (!overlay) return content;\n\n return (\n <div\n className=\"absolute inset-0 z-10 flex items-center justify-center overflow-hidden backdrop-blur-md\"\n style={{ backgroundColor }}\n data-nc-theme={tone}\n >\n <span\n className=\"pointer-events-none absolute inset-0 bg-linear-to-br from-[rgb(var(--nc-accent-1)/0.12)] via-transparent to-[rgb(var(--nc-accent-3)/0.12)]\"\n aria-hidden=\"true\"\n />\n <span\n className=\"pointer-events-none absolute -left-1/4 -top-1/3 h-full w-[120%] rotate-6 bg-white/10 blur-2xl opacity-40\"\n aria-hidden=\"true\"\n />\n <div className=\"relative z-10\">{content}</div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCI;AApCJ,gBAAmB;AA2BnB,MAAM,UAA2C;AAAA,EAC/C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,IAAI;AACN;AAEA,SAAS,QAAQ,EAAE,MAAM,MAAM,GAAoC;AACjE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO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AA,QACT;AAAA,QACA,iBAAiB,SAAS;AAAA,QAC1B;AAAA,MACF;AAAA,MACA,iBAAe;AAAA,MAEd;AAAA,iBAAS,UAAU,4CAAC,WAAQ,MAAM,IAAI,OAAc;AAAA,QACpD,SAAS,UAAU,4CAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,UAAU,4CAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,WAAW,4CAAC,SAAM,MAAM,IAAI,OAAc;AAAA,QACnD,SAAS,YAAY,4CAAC,UAAO,MAAM,IAAI,OAAc;AAAA,QACrD,SAAS,UAAU,4CAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,YAAY,4CAAC,UAAO,MAAM,IAAI,OAAc;AAAA,QACrD,OAAO,4CAAC,UAAK,WAAU,0CAA0C,gBAAK,IAAU;AAAA;AAAA;AAAA,EACnF;AAGF,MAAI,CAAC,QAAS,QAAO;AAErB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,gBAAgB;AAAA,MACzB,iBAAe;AAAA,MAEf;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA;AAAA,QACd;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA;AAAA,QACd;AAAA,QACA,4CAAC,SAAI,WAAU,iBAAiB,mBAAQ;AAAA;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
|
|
@@ -127,7 +127,7 @@ function CraftLoader({
|
|
|
127
127
|
overlay = false,
|
|
128
128
|
text,
|
|
129
129
|
textPosition = "bottom",
|
|
130
|
-
backgroundColor = "
|
|
130
|
+
backgroundColor = "rgba(0, 0, 0, 0.75)",
|
|
131
131
|
tone,
|
|
132
132
|
className
|
|
133
133
|
}) {
|
|
@@ -155,13 +155,29 @@ function CraftLoader({
|
|
|
155
155
|
}
|
|
156
156
|
);
|
|
157
157
|
if (!overlay) return content;
|
|
158
|
-
return /* @__PURE__ */
|
|
158
|
+
return /* @__PURE__ */ jsxs(
|
|
159
159
|
"div",
|
|
160
160
|
{
|
|
161
|
-
className: "absolute inset-0 z-10 flex items-center justify-center",
|
|
161
|
+
className: "absolute inset-0 z-10 flex items-center justify-center overflow-hidden backdrop-blur-md",
|
|
162
162
|
style: { backgroundColor },
|
|
163
163
|
"data-nc-theme": tone,
|
|
164
|
-
children:
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
"span",
|
|
167
|
+
{
|
|
168
|
+
className: "pointer-events-none absolute inset-0 bg-linear-to-br from-[rgb(var(--nc-accent-1)/0.12)] via-transparent to-[rgb(var(--nc-accent-3)/0.12)]",
|
|
169
|
+
"aria-hidden": "true"
|
|
170
|
+
}
|
|
171
|
+
),
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
"span",
|
|
174
|
+
{
|
|
175
|
+
className: "pointer-events-none absolute -left-1/4 -top-1/3 h-full w-[120%] rotate-6 bg-white/10 blur-2xl opacity-40",
|
|
176
|
+
"aria-hidden": "true"
|
|
177
|
+
}
|
|
178
|
+
),
|
|
179
|
+
/* @__PURE__ */ jsx("div", { className: "relative z-10", children: content })
|
|
180
|
+
]
|
|
165
181
|
}
|
|
166
182
|
);
|
|
167
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/craft-loader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftLoaderType =\n | \"spin\"\n | \"pulse\"\n | \"bounce\"\n | \"ripple\"\n | \"bars\"\n | \"dots\"\n | \"ring\";\n\nexport type CraftLoaderSize = \"small\" | \"medium\" | \"large\" | \"xl\";\n\nexport type CraftLoaderProps = {\n loading?: boolean;\n type?: CraftLoaderType;\n size?: CraftLoaderSize;\n color?: string;\n overlay?: boolean;\n text?: React.ReactNode;\n textPosition?: \"top\" | \"bottom\";\n backgroundColor?: string;\n tone?: ThemeName;\n className?: string;\n};\n\nconst sizeMap: Record<CraftLoaderSize, number> = {\n small: 16,\n medium: 24,\n large: 32,\n xl: 40,\n};\n\nfunction Spinner({ size, color }: { size: number; color: string }) {\n return (\n <svg\n className=\"animate-spin\"\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke={color}\n strokeWidth=\"4\"\n className=\"opacity-25\"\n />\n <path\n d=\"M4 12a8 8 0 018-8\"\n stroke={color}\n strokeWidth=\"4\"\n strokeLinecap=\"round\"\n className=\"opacity-75\"\n />\n </svg>\n );\n}\n\nfunction Dots({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 6));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1, 2].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 120}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Bars({ size, color }: { size: number; color: string }) {\n const barHeight = size;\n const barWidth = Math.max(3, Math.floor(size / 6));\n return (\n <div className=\"flex items-end gap-1\">\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-pulse rounded-sm\"\n style={{\n width: barWidth,\n height: barHeight - index * 4,\n backgroundColor: color,\n animationDelay: `${index * 100}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Pulse({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-pulse rounded-full\"\n style={{ width: size, height: size, backgroundColor: color }}\n />\n );\n}\n\nfunction Ripple({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex rounded-full border-2 animate-ping\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Ring({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-spin rounded-full border-2 border-t-transparent\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Bounce({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 5));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 140}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nexport function CraftLoader({\n loading = false,\n type = \"dots\",\n size = \"medium\",\n color = \"rgb(var(--nc-accent-1))\",\n overlay = false,\n text,\n textPosition = \"bottom\",\n backgroundColor = \"
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-loader.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftLoaderType =\n | \"spin\"\n | \"pulse\"\n | \"bounce\"\n | \"ripple\"\n | \"bars\"\n | \"dots\"\n | \"ring\";\n\nexport type CraftLoaderSize = \"small\" | \"medium\" | \"large\" | \"xl\";\n\nexport type CraftLoaderProps = {\n loading?: boolean;\n type?: CraftLoaderType;\n size?: CraftLoaderSize;\n color?: string;\n overlay?: boolean;\n text?: React.ReactNode;\n textPosition?: \"top\" | \"bottom\";\n backgroundColor?: string;\n tone?: ThemeName;\n className?: string;\n};\n\nconst sizeMap: Record<CraftLoaderSize, number> = {\n small: 16,\n medium: 24,\n large: 32,\n xl: 40,\n};\n\nfunction Spinner({ size, color }: { size: number; color: string }) {\n return (\n <svg\n className=\"animate-spin\"\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke={color}\n strokeWidth=\"4\"\n className=\"opacity-25\"\n />\n <path\n d=\"M4 12a8 8 0 018-8\"\n stroke={color}\n strokeWidth=\"4\"\n strokeLinecap=\"round\"\n className=\"opacity-75\"\n />\n </svg>\n );\n}\n\nfunction Dots({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 6));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1, 2].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 120}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Bars({ size, color }: { size: number; color: string }) {\n const barHeight = size;\n const barWidth = Math.max(3, Math.floor(size / 6));\n return (\n <div className=\"flex items-end gap-1\">\n {[0, 1, 2, 3].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-pulse rounded-sm\"\n style={{\n width: barWidth,\n height: barHeight - index * 4,\n backgroundColor: color,\n animationDelay: `${index * 100}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nfunction Pulse({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-pulse rounded-full\"\n style={{ width: size, height: size, backgroundColor: color }}\n />\n );\n}\n\nfunction Ripple({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex rounded-full border-2 animate-ping\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Ring({ size, color }: { size: number; color: string }) {\n return (\n <span\n className=\"inline-flex animate-spin rounded-full border-2 border-t-transparent\"\n style={{ width: size, height: size, borderColor: color }}\n />\n );\n}\n\nfunction Bounce({ size, color }: { size: number; color: string }) {\n const dotSize = Math.max(4, Math.floor(size / 5));\n return (\n <div className=\"flex items-center gap-2\">\n {[0, 1].map((index) => (\n <span\n key={index}\n className=\"inline-flex animate-bounce rounded-full\"\n style={{\n width: dotSize,\n height: dotSize,\n backgroundColor: color,\n animationDelay: `${index * 140}ms`,\n }}\n />\n ))}\n </div>\n );\n}\n\nexport function CraftLoader({\n loading = false,\n type = \"dots\",\n size = \"medium\",\n color = \"rgb(var(--nc-accent-1))\",\n overlay = false,\n text,\n textPosition = \"bottom\",\n backgroundColor = \"rgba(0, 0, 0, 0.75)\",\n tone,\n className,\n}: CraftLoaderProps) {\n if (!loading) return null;\n\n const px = sizeMap[size];\n\n const content = (\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-3\",\n textPosition === \"top\" && \"flex-col-reverse\",\n className\n )}\n data-nc-theme={tone}\n >\n {type === \"spin\" && <Spinner size={px} color={color} />}\n {type === \"dots\" && <Dots size={px} color={color} />}\n {type === \"bars\" && <Bars size={px} color={color} />}\n {type === \"pulse\" && <Pulse size={px} color={color} />}\n {type === \"ripple\" && <Ripple size={px} color={color} />}\n {type === \"ring\" && <Ring size={px} color={color} />}\n {type === \"bounce\" && <Bounce size={px} color={color} />}\n {text ? <span className=\"text-xs text-[rgb(var(--nc-fg-muted))]\">{text}</span> : null}\n </div>\n );\n\n if (!overlay) return content;\n\n return (\n <div\n className=\"absolute inset-0 z-10 flex items-center justify-center overflow-hidden backdrop-blur-md\"\n style={{ backgroundColor }}\n data-nc-theme={tone}\n >\n <span\n className=\"pointer-events-none absolute inset-0 bg-linear-to-br from-[rgb(var(--nc-accent-1)/0.12)] via-transparent to-[rgb(var(--nc-accent-3)/0.12)]\"\n aria-hidden=\"true\"\n />\n <span\n className=\"pointer-events-none absolute -left-1/4 -top-1/3 h-full w-[120%] rotate-6 bg-white/10 blur-2xl opacity-40\"\n aria-hidden=\"true\"\n />\n <div className=\"relative z-10\">{content}</div>\n </div>\n );\n}\n"],"mappings":";AAwCI,SAQE,KARF;AApCJ,SAAS,UAAU;AA2BnB,MAAM,UAA2C;AAAA,EAC/C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,IAAI;AACN;AAEA,SAAS,QAAQ,EAAE,MAAM,MAAM,GAAoC;AACjE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV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AW;AAAA,QACT;AAAA,QACA,iBAAiB,SAAS;AAAA,QAC1B;AAAA,MACF;AAAA,MACA,iBAAe;AAAA,MAEd;AAAA,iBAAS,UAAU,oBAAC,WAAQ,MAAM,IAAI,OAAc;AAAA,QACpD,SAAS,UAAU,oBAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,UAAU,oBAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,WAAW,oBAAC,SAAM,MAAM,IAAI,OAAc;AAAA,QACnD,SAAS,YAAY,oBAAC,UAAO,MAAM,IAAI,OAAc;AAAA,QACrD,SAAS,UAAU,oBAAC,QAAK,MAAM,IAAI,OAAc;AAAA,QACjD,SAAS,YAAY,oBAAC,UAAO,MAAM,IAAI,OAAc;AAAA,QACrD,OAAO,oBAAC,UAAK,WAAU,0CAA0C,gBAAK,IAAU;AAAA;AAAA;AAAA,EACnF;AAGF,MAAI,CAAC,QAAS,QAAO;AAErB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,gBAAgB;AAAA,MACzB,iBAAe;AAAA,MAEf;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA;AAAA,QACd;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,eAAY;AAAA;AAAA,QACd;AAAA,QACA,oBAAC,SAAI,WAAU,iBAAiB,mBAAQ;AAAA;AAAA;AAAA,EAC1C;AAEJ;","names":[]}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import 'react/jsx-runtime';
|
|
2
|
-
import '../theme/theme-context.cjs';
|
|
3
|
-
export {
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ThemeName } from '../theme/theme-context.cjs';
|
|
3
|
+
export { CraftToastCustomOptions, CraftToastOptions, CraftToastVariant, toast, useCraftToast, useToaster } from '../lib/toast.cjs';
|
|
4
4
|
import 'react';
|
|
5
|
+
|
|
6
|
+
type CraftToasterProps = {
|
|
7
|
+
tone?: ThemeName;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
declare function CraftToaster({ tone, className }: CraftToasterProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { CraftToaster, type CraftToasterProps };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import 'react/jsx-runtime';
|
|
2
|
-
import '../theme/theme-context.js';
|
|
3
|
-
export {
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ThemeName } from '../theme/theme-context.js';
|
|
3
|
+
export { CraftToastCustomOptions, CraftToastOptions, CraftToastVariant, toast, useCraftToast, useToaster } from '../lib/toast.js';
|
|
4
4
|
import 'react';
|
|
5
|
+
|
|
6
|
+
type CraftToasterProps = {
|
|
7
|
+
tone?: ThemeName;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
declare function CraftToaster({ tone, className }: CraftToasterProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { CraftToaster, type CraftToasterProps };
|
package/dist/index.d.cts
CHANGED
|
@@ -14,7 +14,8 @@ export { CraftModal, CraftModalProps } from './components/craft-modal.cjs';
|
|
|
14
14
|
export { CraftDrawer, CraftDrawerProps } from './components/craft-drawer.cjs';
|
|
15
15
|
export { CraftTabs, CraftTabsProps } from './components/craft-tabs.cjs';
|
|
16
16
|
export { CraftTooltip, CraftTooltipProps } from './components/craft-tooltip.cjs';
|
|
17
|
-
export {
|
|
17
|
+
export { CraftToaster, CraftToasterProps } from './components/craft-toast.cjs';
|
|
18
|
+
export { CraftToast, CraftToastCustomOptions, CraftToastOptions, CraftToastVariant, toast, useCraftToast, useToaster } from './lib/toast.cjs';
|
|
18
19
|
export { CraftSkeleton, CraftSkeletonProps } from './components/craft-skeleton.cjs';
|
|
19
20
|
export { CraftEmptyState, CraftEmptyStateProps } from './components/craft-empty-state.cjs';
|
|
20
21
|
export { CraftPopover, CraftPopoverProps } from './components/craft-popover.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export { CraftModal, CraftModalProps } from './components/craft-modal.js';
|
|
|
14
14
|
export { CraftDrawer, CraftDrawerProps } from './components/craft-drawer.js';
|
|
15
15
|
export { CraftTabs, CraftTabsProps } from './components/craft-tabs.js';
|
|
16
16
|
export { CraftTooltip, CraftTooltipProps } from './components/craft-tooltip.js';
|
|
17
|
-
export {
|
|
17
|
+
export { CraftToaster, CraftToasterProps } from './components/craft-toast.js';
|
|
18
|
+
export { CraftToast, CraftToastCustomOptions, CraftToastOptions, CraftToastVariant, toast, useCraftToast, useToaster } from './lib/toast.js';
|
|
18
19
|
export { CraftSkeleton, CraftSkeletonProps } from './components/craft-skeleton.js';
|
|
19
20
|
export { CraftEmptyState, CraftEmptyStateProps } from './components/craft-empty-state.js';
|
|
20
21
|
export { CraftPopover, CraftPopoverProps } from './components/craft-popover.js';
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var toast_exports = {};
|
|
31
|
+
__export(toast_exports, {
|
|
32
|
+
normalizeVariant: () => normalizeVariant,
|
|
33
|
+
removeToast: () => removeToast,
|
|
34
|
+
toast: () => toast,
|
|
35
|
+
useCraftToast: () => useCraftToast,
|
|
36
|
+
useToaster: () => useToaster
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(toast_exports);
|
|
39
|
+
var React = __toESM(require("react"), 1);
|
|
40
|
+
const toastState = { toasts: [] };
|
|
41
|
+
const toastListeners = /* @__PURE__ */ new Set();
|
|
42
|
+
const toastTimeouts = /* @__PURE__ */ new Map();
|
|
43
|
+
function emitToastState() {
|
|
44
|
+
toastListeners.forEach((listener) => listener());
|
|
45
|
+
}
|
|
46
|
+
function normalizeVariant(variant) {
|
|
47
|
+
if (variant === "danger") return "error";
|
|
48
|
+
return variant != null ? variant : "info";
|
|
49
|
+
}
|
|
50
|
+
function scheduleToastRemoval(id, duration) {
|
|
51
|
+
const timeoutMs = typeof duration === "number" ? duration : 4e3;
|
|
52
|
+
if (timeoutMs <= 0) return;
|
|
53
|
+
const existing = toastTimeouts.get(id);
|
|
54
|
+
if (existing) clearTimeout(existing);
|
|
55
|
+
toastTimeouts.set(
|
|
56
|
+
id,
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
toastState.toasts = toastState.toasts.filter((toast2) => toast2.id !== id);
|
|
59
|
+
toastTimeouts.delete(id);
|
|
60
|
+
emitToastState();
|
|
61
|
+
}, timeoutMs)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
function addToast(toast2) {
|
|
65
|
+
const id = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
66
|
+
const next = {
|
|
67
|
+
...toast2,
|
|
68
|
+
id,
|
|
69
|
+
variant: normalizeVariant(toast2.variant)
|
|
70
|
+
};
|
|
71
|
+
toastState.toasts = [...toastState.toasts, next];
|
|
72
|
+
emitToastState();
|
|
73
|
+
scheduleToastRemoval(id, toast2.duration);
|
|
74
|
+
return id;
|
|
75
|
+
}
|
|
76
|
+
function removeToast(id) {
|
|
77
|
+
toastState.toasts = toastState.toasts.filter((toast2) => toast2.id !== id);
|
|
78
|
+
const existing = toastTimeouts.get(id);
|
|
79
|
+
if (existing) {
|
|
80
|
+
clearTimeout(existing);
|
|
81
|
+
toastTimeouts.delete(id);
|
|
82
|
+
}
|
|
83
|
+
emitToastState();
|
|
84
|
+
}
|
|
85
|
+
function clearToasts() {
|
|
86
|
+
toastState.toasts = [];
|
|
87
|
+
toastTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
88
|
+
toastTimeouts.clear();
|
|
89
|
+
emitToastState();
|
|
90
|
+
}
|
|
91
|
+
function useToaster() {
|
|
92
|
+
const subscribe = React.useCallback((listener) => {
|
|
93
|
+
toastListeners.add(listener);
|
|
94
|
+
return () => toastListeners.delete(listener);
|
|
95
|
+
}, []);
|
|
96
|
+
const getSnapshot = React.useCallback(() => toastState.toasts, []);
|
|
97
|
+
return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
98
|
+
}
|
|
99
|
+
function useCraftToast() {
|
|
100
|
+
return React.useMemo(
|
|
101
|
+
() => ({
|
|
102
|
+
toast: (message, options) => addToast({
|
|
103
|
+
title: typeof message === "string" ? message : void 0,
|
|
104
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
105
|
+
description: options == null ? void 0 : options.description,
|
|
106
|
+
variant: options == null ? void 0 : options.variant,
|
|
107
|
+
duration: options == null ? void 0 : options.duration
|
|
108
|
+
}),
|
|
109
|
+
success: (message, options) => addToast({
|
|
110
|
+
title: typeof message === "string" ? message : void 0,
|
|
111
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
112
|
+
description: options == null ? void 0 : options.description,
|
|
113
|
+
variant: "success",
|
|
114
|
+
duration: options == null ? void 0 : options.duration
|
|
115
|
+
}),
|
|
116
|
+
warning: (message, options) => addToast({
|
|
117
|
+
title: typeof message === "string" ? message : void 0,
|
|
118
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
119
|
+
description: options == null ? void 0 : options.description,
|
|
120
|
+
variant: "warning",
|
|
121
|
+
duration: options == null ? void 0 : options.duration
|
|
122
|
+
}),
|
|
123
|
+
info: (message, options) => addToast({
|
|
124
|
+
title: typeof message === "string" ? message : void 0,
|
|
125
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
126
|
+
description: options == null ? void 0 : options.description,
|
|
127
|
+
variant: "info",
|
|
128
|
+
duration: options == null ? void 0 : options.duration
|
|
129
|
+
}),
|
|
130
|
+
error: (message, options) => addToast({
|
|
131
|
+
title: typeof message === "string" ? message : void 0,
|
|
132
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
133
|
+
description: options == null ? void 0 : options.description,
|
|
134
|
+
variant: "error",
|
|
135
|
+
duration: options == null ? void 0 : options.duration
|
|
136
|
+
}),
|
|
137
|
+
danger: (message, options) => addToast({
|
|
138
|
+
title: typeof message === "string" ? message : void 0,
|
|
139
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
140
|
+
description: options == null ? void 0 : options.description,
|
|
141
|
+
variant: "danger",
|
|
142
|
+
duration: options == null ? void 0 : options.duration
|
|
143
|
+
}),
|
|
144
|
+
dismiss: (id) => removeToast(id),
|
|
145
|
+
dismissAll: () => clearToasts()
|
|
146
|
+
}),
|
|
147
|
+
[]
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const toast = Object.assign(
|
|
151
|
+
(message, options) => addToast({
|
|
152
|
+
title: typeof message === "string" ? message : void 0,
|
|
153
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
154
|
+
description: options == null ? void 0 : options.description,
|
|
155
|
+
variant: options == null ? void 0 : options.variant,
|
|
156
|
+
duration: options == null ? void 0 : options.duration
|
|
157
|
+
}),
|
|
158
|
+
{
|
|
159
|
+
success: (message, options) => addToast({
|
|
160
|
+
title: typeof message === "string" ? message : void 0,
|
|
161
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
162
|
+
description: options == null ? void 0 : options.description,
|
|
163
|
+
variant: "success",
|
|
164
|
+
duration: options == null ? void 0 : options.duration
|
|
165
|
+
}),
|
|
166
|
+
error: (message, options) => addToast({
|
|
167
|
+
title: typeof message === "string" ? message : void 0,
|
|
168
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
169
|
+
description: options == null ? void 0 : options.description,
|
|
170
|
+
variant: "error",
|
|
171
|
+
duration: options == null ? void 0 : options.duration
|
|
172
|
+
}),
|
|
173
|
+
warning: (message, options) => addToast({
|
|
174
|
+
title: typeof message === "string" ? message : void 0,
|
|
175
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
176
|
+
description: options == null ? void 0 : options.description,
|
|
177
|
+
variant: "warning",
|
|
178
|
+
duration: options == null ? void 0 : options.duration
|
|
179
|
+
}),
|
|
180
|
+
info: (message, options) => addToast({
|
|
181
|
+
title: typeof message === "string" ? message : void 0,
|
|
182
|
+
custom: typeof message === "string" ? void 0 : message,
|
|
183
|
+
description: options == null ? void 0 : options.description,
|
|
184
|
+
variant: "info",
|
|
185
|
+
duration: options == null ? void 0 : options.duration
|
|
186
|
+
}),
|
|
187
|
+
custom: (component, options) => addToast({
|
|
188
|
+
custom: component,
|
|
189
|
+
duration: options == null ? void 0 : options.duration
|
|
190
|
+
}),
|
|
191
|
+
dismiss: (id) => removeToast(id),
|
|
192
|
+
dismissAll: () => clearToasts(),
|
|
193
|
+
promise: async (promise, options) => {
|
|
194
|
+
var _a, _b, _c;
|
|
195
|
+
const loadingId = addToast({
|
|
196
|
+
title: typeof (options == null ? void 0 : options.loading) === "string" ? options.loading : void 0,
|
|
197
|
+
custom: typeof (options == null ? void 0 : options.loading) === "string" ? void 0 : options == null ? void 0 : options.loading,
|
|
198
|
+
description: options == null ? void 0 : options.description,
|
|
199
|
+
variant: "info",
|
|
200
|
+
duration: (_a = options == null ? void 0 : options.duration) != null ? _a : 0
|
|
201
|
+
});
|
|
202
|
+
try {
|
|
203
|
+
const result = await promise;
|
|
204
|
+
removeToast(loadingId);
|
|
205
|
+
const successContent = typeof (options == null ? void 0 : options.success) === "function" ? options.success(result) : (_b = options == null ? void 0 : options.success) != null ? _b : "Success";
|
|
206
|
+
addToast({
|
|
207
|
+
title: typeof successContent === "string" ? successContent : void 0,
|
|
208
|
+
custom: typeof successContent === "string" ? void 0 : successContent,
|
|
209
|
+
variant: "success",
|
|
210
|
+
duration: options == null ? void 0 : options.duration
|
|
211
|
+
});
|
|
212
|
+
return result;
|
|
213
|
+
} catch (error) {
|
|
214
|
+
removeToast(loadingId);
|
|
215
|
+
const errorContent = typeof (options == null ? void 0 : options.error) === "function" ? options.error(error) : (_c = options == null ? void 0 : options.error) != null ? _c : "Something went wrong";
|
|
216
|
+
addToast({
|
|
217
|
+
title: typeof errorContent === "string" ? errorContent : void 0,
|
|
218
|
+
custom: typeof errorContent === "string" ? void 0 : errorContent,
|
|
219
|
+
variant: "error",
|
|
220
|
+
duration: options == null ? void 0 : options.duration
|
|
221
|
+
});
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
228
|
+
0 && (module.exports = {
|
|
229
|
+
normalizeVariant,
|
|
230
|
+
removeToast,
|
|
231
|
+
toast,
|
|
232
|
+
useCraftToast,
|
|
233
|
+
useToaster
|
|
234
|
+
});
|
|
235
|
+
//# sourceMappingURL=toast.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/toast.ts"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nexport type CraftToastVariant = \"info\" | \"success\" | \"warning\" | \"error\" | \"danger\";\n\nexport type CraftToast = {\n id: string;\n title?: string;\n description?: string;\n variant?: CraftToastVariant;\n duration?: number;\n custom?: React.ReactNode;\n};\n\nexport type CraftToastOptions = {\n description?: string;\n variant?: CraftToastVariant;\n duration?: number;\n};\n\nexport type CraftToastCustomOptions = {\n duration?: number;\n};\n\nconst toastState: { toasts: CraftToast[] } = { toasts: [] };\nconst toastListeners = new Set<() => void>();\nconst toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();\n\nfunction emitToastState() {\n toastListeners.forEach((listener) => listener());\n}\n\nexport function normalizeVariant(\n variant?: CraftToastVariant\n): Exclude<CraftToastVariant, \"danger\"> {\n if (variant === \"danger\") return \"error\";\n return variant ?? \"info\";\n}\n\nfunction scheduleToastRemoval(id: string, duration?: number) {\n const timeoutMs = typeof duration === \"number\" ? duration : 4000;\n if (timeoutMs <= 0) return;\n const existing = toastTimeouts.get(id);\n if (existing) clearTimeout(existing);\n toastTimeouts.set(\n id,\n setTimeout(() => {\n toastState.toasts = toastState.toasts.filter((toast) => toast.id !== id);\n toastTimeouts.delete(id);\n emitToastState();\n }, timeoutMs)\n );\n}\n\nfunction addToast(toast: Omit<CraftToast, \"id\">) {\n const id = `${Date.now()}-${Math.random().toString(16).slice(2)}`;\n const next: CraftToast = {\n ...toast,\n id,\n variant: normalizeVariant(toast.variant),\n };\n toastState.toasts = [...toastState.toasts, next];\n emitToastState();\n scheduleToastRemoval(id, toast.duration);\n return id;\n}\n\nexport function removeToast(id: string) {\n toastState.toasts = toastState.toasts.filter((toast) => toast.id !== id);\n const existing = toastTimeouts.get(id);\n if (existing) {\n clearTimeout(existing);\n toastTimeouts.delete(id);\n }\n emitToastState();\n}\n\nfunction clearToasts() {\n toastState.toasts = [];\n toastTimeouts.forEach((timeout) => clearTimeout(timeout));\n toastTimeouts.clear();\n emitToastState();\n}\n\nexport function useToaster() {\n const subscribe = React.useCallback((listener: () => void) => {\n toastListeners.add(listener);\n return () => toastListeners.delete(listener);\n }, []);\n\n const getSnapshot = React.useCallback(() => toastState.toasts, []);\n\n return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\nexport function useCraftToast() {\n return React.useMemo(\n () => ({\n toast: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: options?.variant,\n duration: options?.duration,\n }),\n success: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"success\",\n duration: options?.duration,\n }),\n warning: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"warning\",\n duration: options?.duration,\n }),\n info: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"info\",\n duration: options?.duration,\n }),\n error: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"error\",\n duration: options?.duration,\n }),\n danger: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"danger\",\n duration: options?.duration,\n }),\n dismiss: (id: string) => removeToast(id),\n dismissAll: () => clearToasts(),\n }),\n []\n );\n}\n\nexport const toast = Object.assign(\n (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: options?.variant,\n duration: options?.duration,\n }),\n {\n success: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"success\",\n duration: options?.duration,\n }),\n error: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"error\",\n duration: options?.duration,\n }),\n warning: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"warning\",\n duration: options?.duration,\n }),\n info: (message: React.ReactNode, options?: CraftToastOptions) =>\n addToast({\n title: typeof message === \"string\" ? message : undefined,\n custom: typeof message === \"string\" ? undefined : message,\n description: options?.description,\n variant: \"info\",\n duration: options?.duration,\n }),\n custom: (component: React.ReactNode, options?: CraftToastCustomOptions) =>\n addToast({\n custom: component,\n duration: options?.duration,\n }),\n dismiss: (id: string) => removeToast(id),\n dismissAll: () => clearToasts(),\n promise: async <T,>(\n promise: Promise<T>,\n options?: {\n loading?: React.ReactNode;\n success?: ((value: T) => React.ReactNode) | React.ReactNode;\n error?: ((error: unknown) => React.ReactNode) | React.ReactNode;\n description?: string;\n duration?: number;\n }\n ) => {\n const loadingId = addToast({\n title: typeof options?.loading === \"string\" ? options.loading : undefined,\n custom: typeof options?.loading === \"string\" ? undefined : options?.loading,\n description: options?.description,\n variant: \"info\",\n duration: options?.duration ?? 0,\n });\n\n try {\n const result = await promise;\n removeToast(loadingId);\n const successContent =\n typeof options?.success === \"function\"\n ? options.success(result)\n : options?.success ?? \"Success\";\n addToast({\n title: typeof successContent === \"string\" ? successContent : undefined,\n custom: typeof successContent === \"string\" ? undefined : successContent,\n variant: \"success\",\n duration: options?.duration,\n });\n return result;\n } catch (error) {\n removeToast(loadingId);\n const errorContent =\n typeof options?.error === \"function\"\n ? options.error(error)\n : options?.error ?? \"Something went wrong\";\n addToast({\n title: typeof errorContent === \"string\" ? errorContent : undefined,\n custom: typeof errorContent === \"string\" ? undefined : errorContent,\n variant: \"error\",\n duration: options?.duration,\n });\n throw error;\n }\n },\n }\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AAuBvB,MAAM,aAAuC,EAAE,QAAQ,CAAC,EAAE;AAC1D,MAAM,iBAAiB,oBAAI,IAAgB;AAC3C,MAAM,gBAAgB,oBAAI,IAA2C;AAErE,SAAS,iBAAiB;AACxB,iBAAe,QAAQ,CAAC,aAAa,SAAS,CAAC;AACjD;AAEO,SAAS,iBACd,SACsC;AACtC,MAAI,YAAY,SAAU,QAAO;AACjC,SAAO,4BAAW;AACpB;AAEA,SAAS,qBAAqB,IAAY,UAAmB;AAC3D,QAAM,YAAY,OAAO,aAAa,WAAW,WAAW;AAC5D,MAAI,aAAa,EAAG;AACpB,QAAM,WAAW,cAAc,IAAI,EAAE;AACrC,MAAI,SAAU,cAAa,QAAQ;AACnC,gBAAc;AAAA,IACZ;AAAA,IACA,WAAW,MAAM;AACf,iBAAW,SAAS,WAAW,OAAO,OAAO,CAACA,WAAUA,OAAM,OAAO,EAAE;AACvE,oBAAc,OAAO,EAAE;AACvB,qBAAe;AAAA,IACjB,GAAG,SAAS;AAAA,EACd;AACF;AAEA,SAAS,SAASA,QAA+B;AAC/C,QAAM,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/D,QAAM,OAAmB;AAAA,IAC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AAO,mCAAS,aAAY,WAAW,SAAY,mCAAS;AAAA,QACpE,aAAa,mCAAS;AAAA,QACtB,SAAS;AAAA,QACT,WAAU,wCAAS,aAAT,YAAqB;AAAA,MACjC,CAAC;AAED,UAAI;AACF,cAAM,SAAS,MAAM;AACrB,oBAAY,SAAS;AACrB,cAAM,iBACJ,QAAO,mCAAS,aAAY,aACxB,QAAQ,QAAQ,MAAM,KACtB,wCAAS,YAAT,YAAoB;AAC1B,iBAAS;AAAA,UACP,OAAO,OAAO,mBAAmB,WAAW,iBAAiB;AAAA,UAC7D,QAAQ,OAAO,mBAAmB,WAAW,SAAY;AAAA,UACzD,SAAS;AAAA,UACT,UAAU,mCAAS;AAAA,QACrB,CAAC;AACD,eAAO;AAAA,MACT,SAAS,OAAO;AACd,oBAAY,SAAS;AACrB,cAAM,eACJ,QAAO,mCAAS,WAAU,aACtB,QAAQ,MAAM,KAAK,KACnB,wCAAS,UAAT,YAAkB;AACxB,iBAAS;AAAA,UACP,OAAO,OAAO,iBAAiB,WAAW,eAAe;AAAA,UACzD,QAAQ,OAAO,iBAAiB,WAAW,SAAY;AAAA,UACvD,SAAS;AAAA,UACT,UAAU,mCAAS;AAAA,QACrB,CAAC;AACD,cAAM;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":["toast"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ThemeName } from './theme/theme-context.js';
|
|
3
1
|
import * as React from 'react';
|
|
4
2
|
|
|
5
3
|
type CraftToastVariant = "info" | "success" | "warning" | "error" | "danger";
|
|
@@ -19,6 +17,8 @@ type CraftToastOptions = {
|
|
|
19
17
|
type CraftToastCustomOptions = {
|
|
20
18
|
duration?: number;
|
|
21
19
|
};
|
|
20
|
+
declare function normalizeVariant(variant?: CraftToastVariant): Exclude<CraftToastVariant, "danger">;
|
|
21
|
+
declare function removeToast(id: string): void;
|
|
22
22
|
declare function useToaster(): CraftToast[];
|
|
23
23
|
declare function useCraftToast(): {
|
|
24
24
|
toast: (message: React.ReactNode, options?: CraftToastOptions) => string;
|
|
@@ -47,10 +47,4 @@ declare const toast: ((message: React.ReactNode, options?: CraftToastOptions) =>
|
|
|
47
47
|
}) => Promise<T>;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
type
|
|
51
|
-
tone?: ThemeName;
|
|
52
|
-
className?: string;
|
|
53
|
-
};
|
|
54
|
-
declare function CraftToaster({ tone, className }: CraftToasterProps): react_jsx_runtime.JSX.Element;
|
|
55
|
-
|
|
56
|
-
export { type CraftToast as C, type CraftToastCustomOptions as a, type CraftToastOptions as b, type CraftToastVariant as c, CraftToaster as d, type CraftToasterProps as e, useToaster as f, toast as t, useCraftToast as u };
|
|
50
|
+
export { type CraftToast, type CraftToastCustomOptions, type CraftToastOptions, type CraftToastVariant, normalizeVariant, removeToast, toast, useCraftToast, useToaster };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ThemeName } from './theme/theme-context.cjs';
|
|
3
1
|
import * as React from 'react';
|
|
4
2
|
|
|
5
3
|
type CraftToastVariant = "info" | "success" | "warning" | "error" | "danger";
|
|
@@ -19,6 +17,8 @@ type CraftToastOptions = {
|
|
|
19
17
|
type CraftToastCustomOptions = {
|
|
20
18
|
duration?: number;
|
|
21
19
|
};
|
|
20
|
+
declare function normalizeVariant(variant?: CraftToastVariant): Exclude<CraftToastVariant, "danger">;
|
|
21
|
+
declare function removeToast(id: string): void;
|
|
22
22
|
declare function useToaster(): CraftToast[];
|
|
23
23
|
declare function useCraftToast(): {
|
|
24
24
|
toast: (message: React.ReactNode, options?: CraftToastOptions) => string;
|
|
@@ -47,10 +47,4 @@ declare const toast: ((message: React.ReactNode, options?: CraftToastOptions) =>
|
|
|
47
47
|
}) => Promise<T>;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
type
|
|
51
|
-
tone?: ThemeName;
|
|
52
|
-
className?: string;
|
|
53
|
-
};
|
|
54
|
-
declare function CraftToaster({ tone, className }: CraftToasterProps): react_jsx_runtime.JSX.Element;
|
|
55
|
-
|
|
56
|
-
export { type CraftToast as C, type CraftToastCustomOptions as a, type CraftToastOptions as b, type CraftToastVariant as c, CraftToaster as d, type CraftToasterProps as e, useToaster as f, toast as t, useCraftToast as u };
|
|
50
|
+
export { type CraftToast, type CraftToastCustomOptions, type CraftToastOptions, type CraftToastVariant, normalizeVariant, removeToast, toast, useCraftToast, useToaster };
|