@planningcenter/sweetest-alert 0.2.3 → 0.3.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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +108 -0
- package/dist/style.css +62 -0
- package/dist/sweetest_alert.d.ts +16 -0
- package/package.json +5 -6
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),v=require("react-dom"),h=require("@planningcenter/tapestry");var o={},_;function C(){if(_)return o;_=1;var c=v;if(process.env.NODE_ENV==="production")o.createRoot=c.createRoot,o.hydrateRoot=c.hydrateRoot;else{var r=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;o.createRoot=function(l,n){r.usingClientEntryPoint=!0;try{return c.createRoot(l,n)}finally{r.usingClientEntryPoint=!1}},o.hydrateRoot=function(l,n,s){r.usingClientEntryPoint=!0;try{return c.hydrateRoot(l,n,s)}finally{r.usingClientEntryPoint=!1}}}return o}var f=C();const p="M8,0c2.1217,0 4.1566,0.84286 5.6569,2.34315c1.5002,1.50029 2.3431,3.53512 2.3431,5.65685c0,1.58225 -0.4692,3.129 -1.3482,4.4446c-0.8791,1.3156 -2.1285,2.3409 -3.5903,2.9464c-1.46184,0.6055 -3.07037,0.764 -4.62222,0.4553c-1.55185,-0.3087 -2.97731,-1.0706 -4.09613,-2.1894c-1.11882,-1.1189 -1.88075,-2.5443 -2.18943,-4.09618c-0.30868,-1.55185 -0.15025,-3.16038 0.45525,-4.62219c0.6055,-1.46181 1.63088,-2.71124 2.94647,-3.59029c1.31559,-0.87905 2.86231,-1.34824 4.44456,-1.34824zM12.57,6.07l-1.14,-1.14l-4.43,4.44l-2.43,-2.44l-1.14,1.14l3.57,3.56z",w="M15.7713,14.0548c0.0002,0.133 -0.0347,0.2638 -0.1011,0.3791c-0.0664,0.1153 -0.162,0.211 -0.2772,0.2776c-0.1152,0.0665 -0.246,0.1015 -0.379,0.1015h-14.02801c-0.13305,0 -0.26377,-0.035 -0.37898,-0.1015c-0.11521,-0.0666 -0.21084,-0.1623 -0.27725,-0.2776c-0.06642,-0.1153 -0.10127,-0.2461 -0.10106,-0.3791c0.00022,-0.1331 0.0355,-0.2637 0.10229,-0.3788l7.014,-12.11501c0.06631,-0.11506 0.16176,-0.21062 0.27675,-0.27707c0.11498,-0.06644 0.24544,-0.10142 0.37825,-0.10142c0.1328,0 0.26326,0.03498 0.37824,0.10142c0.11499,0.06645 0.21044,0.16201 0.27676,0.27707l7.01401,12.11501c0.0668,0.1151 0.1021,0.2457 0.1023,0.3788zM8.75699,11.028h-1.514v1.514h1.514zM8.75699,6.48499h-1.514v3.029h1.514z",E="M8.8,4h-1.6v1.6h1.6zM8.8,7.2h-1.6v4.8h1.6zM8,0c2.1217,0 4.1566,0.84286 5.6569,2.34315c1.5002,1.50029 2.3431,3.53512 2.3431,5.65685c0,1.58225 -0.4692,3.129 -1.3482,4.4446c-0.8791,1.3156 -2.1285,2.3409 -3.5903,2.9464c-1.46184,0.6055 -3.07037,0.764 -4.62222,0.4553c-1.55185,-0.3087 -2.97731,-1.0706 -4.09613,-2.1894c-1.11882,-1.1189 -1.88075,-2.5443 -2.18943,-4.09618c-0.30868,-1.55185 -0.15025,-3.16038 0.45525,-4.62219c0.6055,-1.46181 1.63088,-2.71124 2.94647,-3.59029c1.31559,-0.87905 2.86231,-1.34824 4.44456,-1.34824z",R="M11.3951,10.2621l-2.26245,-2.2621l2.26245,-2.26215l-1.1317,-1.1316l-2.2625,2.26215l-2.26246,-2.26215l-1.13175,1.1316l2.26246,2.26215l-2.26246,2.2621l1.13175,1.1316l2.26246,-2.2621l2.2625,2.2621zM16,8c0,2.1214 -0.8421,4.156 -2.3414,5.6569c-1.119,1.1188 -2.5446,1.8807 -4.09668,2.1894c-1.55205,0.3087 -3.16079,0.1502 -4.62278,-0.4553c-1.46199,-0.6055 -2.71157,-1.6309 -3.59073,-2.9465c-0.87916,-1.3156 -1.34841,-2.86226 -1.34841,-4.4445c0,-1.58224 0.46925,-3.12895 1.34841,-4.44453c0.87916,-1.31559 2.12874,-2.34097 3.59073,-2.94648c1.46199,-0.60551 3.07073,-0.76395 4.62278,-0.45529c1.55208,0.30866 2.97768,1.07056 4.09668,2.18935c1.4993,1.50098 2.3414,3.5356 2.3414,5.65695z";function x({onCancel:c,onConfirm:r,confirmButton:l="Okay",content:n,hideCancel:s=!1,title:y,type:a="warning"}){const t=document.createElement("dialog");t.className="pco-sweetest-alert",document.body.appendChild(t);const d=f.createRoot(t),i=()=>{d.unmount(),document.body.removeChild(t)},g=()=>{i(),r?.()},u=()=>{i(),c?.()},m=()=>{switch(a){case"success":return p;case"error":return R;case"info":return E;case"danger":case"warning":return w}};return d.render(e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:`pco-sweetest-alert__icon pco-sweetest-alert--${a}`,width:"48",height:"48",viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:m()})}),e.jsx("h2",{className:"pco-sweetest-alert__title",children:y}),e.jsx("div",{className:"pco-sweetest-alert__body",children:typeof n=="string"?e.jsx("p",{children:n}):n}),e.jsxs("div",{className:"pco-sweetest-alert__actions",children:[!s&&e.jsx(h.Button,{label:"Cancel",kind:"ghost",onClick:u}),e.jsx(h.Button,{label:l,kind:a==="danger"?"delete":"primary",onClick:g})]})]})),t.showModal(),t.addEventListener("close",u),{show:()=>t.showModal(),close:()=>t.close(),cleanup:i}}exports.SweetestAlert=x;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SweetestAlert } from "./sweetest_alert.tsx";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsxs as u, Fragment as g, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import v from "react-dom";
|
|
3
|
+
import { Button as m } from "@planningcenter/tapestry";
|
|
4
|
+
var o = {}, _;
|
|
5
|
+
function y() {
|
|
6
|
+
if (_) return o;
|
|
7
|
+
_ = 1;
|
|
8
|
+
var c = v;
|
|
9
|
+
if (process.env.NODE_ENV === "production")
|
|
10
|
+
o.createRoot = c.createRoot, o.hydrateRoot = c.hydrateRoot;
|
|
11
|
+
else {
|
|
12
|
+
var n = c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
13
|
+
o.createRoot = function(l, t) {
|
|
14
|
+
n.usingClientEntryPoint = !0;
|
|
15
|
+
try {
|
|
16
|
+
return c.createRoot(l, t);
|
|
17
|
+
} finally {
|
|
18
|
+
n.usingClientEntryPoint = !1;
|
|
19
|
+
}
|
|
20
|
+
}, o.hydrateRoot = function(l, t, a) {
|
|
21
|
+
n.usingClientEntryPoint = !0;
|
|
22
|
+
try {
|
|
23
|
+
return c.hydrateRoot(l, t, a);
|
|
24
|
+
} finally {
|
|
25
|
+
n.usingClientEntryPoint = !1;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return o;
|
|
30
|
+
}
|
|
31
|
+
var w = y();
|
|
32
|
+
const E = "M8,0c2.1217,0 4.1566,0.84286 5.6569,2.34315c1.5002,1.50029 2.3431,3.53512 2.3431,5.65685c0,1.58225 -0.4692,3.129 -1.3482,4.4446c-0.8791,1.3156 -2.1285,2.3409 -3.5903,2.9464c-1.46184,0.6055 -3.07037,0.764 -4.62222,0.4553c-1.55185,-0.3087 -2.97731,-1.0706 -4.09613,-2.1894c-1.11882,-1.1189 -1.88075,-2.5443 -2.18943,-4.09618c-0.30868,-1.55185 -0.15025,-3.16038 0.45525,-4.62219c0.6055,-1.46181 1.63088,-2.71124 2.94647,-3.59029c1.31559,-0.87905 2.86231,-1.34824 4.44456,-1.34824zM12.57,6.07l-1.14,-1.14l-4.43,4.44l-2.43,-2.44l-1.14,1.14l3.57,3.56z", R = "M15.7713,14.0548c0.0002,0.133 -0.0347,0.2638 -0.1011,0.3791c-0.0664,0.1153 -0.162,0.211 -0.2772,0.2776c-0.1152,0.0665 -0.246,0.1015 -0.379,0.1015h-14.02801c-0.13305,0 -0.26377,-0.035 -0.37898,-0.1015c-0.11521,-0.0666 -0.21084,-0.1623 -0.27725,-0.2776c-0.06642,-0.1153 -0.10127,-0.2461 -0.10106,-0.3791c0.00022,-0.1331 0.0355,-0.2637 0.10229,-0.3788l7.014,-12.11501c0.06631,-0.11506 0.16176,-0.21062 0.27675,-0.27707c0.11498,-0.06644 0.24544,-0.10142 0.37825,-0.10142c0.1328,0 0.26326,0.03498 0.37824,0.10142c0.11499,0.06645 0.21044,0.16201 0.27676,0.27707l7.01401,12.11501c0.0668,0.1151 0.1021,0.2457 0.1023,0.3788zM8.75699,11.028h-1.514v1.514h1.514zM8.75699,6.48499h-1.514v3.029h1.514z", M = "M8.8,4h-1.6v1.6h1.6zM8.8,7.2h-1.6v4.8h1.6zM8,0c2.1217,0 4.1566,0.84286 5.6569,2.34315c1.5002,1.50029 2.3431,3.53512 2.3431,5.65685c0,1.58225 -0.4692,3.129 -1.3482,4.4446c-0.8791,1.3156 -2.1285,2.3409 -3.5903,2.9464c-1.46184,0.6055 -3.07037,0.764 -4.62222,0.4553c-1.55185,-0.3087 -2.97731,-1.0706 -4.09613,-2.1894c-1.11882,-1.1189 -1.88075,-2.5443 -2.18943,-4.09618c-0.30868,-1.55185 -0.15025,-3.16038 0.45525,-4.62219c0.6055,-1.46181 1.63088,-2.71124 2.94647,-3.59029c1.31559,-0.87905 2.86231,-1.34824 4.44456,-1.34824z", z = "M11.3951,10.2621l-2.26245,-2.2621l2.26245,-2.26215l-1.1317,-1.1316l-2.2625,2.26215l-2.26246,-2.26215l-1.13175,1.1316l2.26246,2.26215l-2.26246,2.2621l1.13175,1.1316l2.26246,-2.2621l2.2625,2.2621zM16,8c0,2.1214 -0.8421,4.156 -2.3414,5.6569c-1.119,1.1188 -2.5446,1.8807 -4.09668,2.1894c-1.55205,0.3087 -3.16079,0.1502 -4.62278,-0.4553c-1.46199,-0.6055 -2.71157,-1.6309 -3.59073,-2.9465c-0.87916,-1.3156 -1.34841,-2.86226 -1.34841,-4.4445c0,-1.58224 0.46925,-3.12895 1.34841,-4.44453c0.87916,-1.31559 2.12874,-2.34097 3.59073,-2.94648c1.46199,-0.60551 3.07073,-0.76395 4.62278,-0.45529c1.55208,0.30866 2.97768,1.07056 4.09668,2.18935c1.4993,1.50098 2.3414,3.5356 2.3414,5.65695z";
|
|
33
|
+
function O({
|
|
34
|
+
// Optional: Callback function executed when cancel button is clicked
|
|
35
|
+
onCancel: c,
|
|
36
|
+
// Optional: Callback function executed when confirm button is clicked
|
|
37
|
+
onConfirm: n,
|
|
38
|
+
// Optional: Text for the confirm button. Defaults to "Okay".
|
|
39
|
+
confirmButton: l = "Okay",
|
|
40
|
+
// Required: The body content explaining the alert.
|
|
41
|
+
// Accepts a React fragment or a string of text.
|
|
42
|
+
content: t,
|
|
43
|
+
// Optional: When true, hides the cancel button for simple notifications.
|
|
44
|
+
// Defaults to "false".
|
|
45
|
+
hideCancel: a = !1,
|
|
46
|
+
// Required: The main heading text displayed at the top of the modal
|
|
47
|
+
title: f,
|
|
48
|
+
// Optional: The visual type of alert, affects icon and styling.
|
|
49
|
+
// Values can be "info", "success", "error", "danger", or "warning" (default).
|
|
50
|
+
type: s = "warning"
|
|
51
|
+
}) {
|
|
52
|
+
const e = document.createElement("dialog");
|
|
53
|
+
e.className = "pco-sweetest-alert", document.body.appendChild(e);
|
|
54
|
+
const d = w.createRoot(e), i = () => {
|
|
55
|
+
d.unmount(), document.body.removeChild(e);
|
|
56
|
+
}, p = () => {
|
|
57
|
+
i(), n?.();
|
|
58
|
+
}, h = () => {
|
|
59
|
+
i(), c?.();
|
|
60
|
+
}, C = () => {
|
|
61
|
+
switch (s) {
|
|
62
|
+
case "success":
|
|
63
|
+
return E;
|
|
64
|
+
case "error":
|
|
65
|
+
return z;
|
|
66
|
+
case "info":
|
|
67
|
+
return M;
|
|
68
|
+
case "danger":
|
|
69
|
+
case "warning":
|
|
70
|
+
return R;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return d.render(
|
|
74
|
+
/* @__PURE__ */ u(g, { children: [
|
|
75
|
+
/* @__PURE__ */ r(
|
|
76
|
+
"svg",
|
|
77
|
+
{
|
|
78
|
+
className: `pco-sweetest-alert__icon pco-sweetest-alert--${s}`,
|
|
79
|
+
width: "48",
|
|
80
|
+
height: "48",
|
|
81
|
+
viewBox: "0 0 16 16",
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: /* @__PURE__ */ r("path", { d: C() })
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ r("h2", { className: "pco-sweetest-alert__title", children: f }),
|
|
87
|
+
/* @__PURE__ */ r("div", { className: "pco-sweetest-alert__body", children: typeof t == "string" ? /* @__PURE__ */ r("p", { children: t }) : t }),
|
|
88
|
+
/* @__PURE__ */ u("div", { className: "pco-sweetest-alert__actions", children: [
|
|
89
|
+
!a && /* @__PURE__ */ r(m, { label: "Cancel", kind: "ghost", onClick: h }),
|
|
90
|
+
/* @__PURE__ */ r(
|
|
91
|
+
m,
|
|
92
|
+
{
|
|
93
|
+
label: l,
|
|
94
|
+
kind: s === "danger" ? "delete" : "primary",
|
|
95
|
+
onClick: p
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] })
|
|
99
|
+
] })
|
|
100
|
+
), e.showModal(), e.addEventListener("close", h), {
|
|
101
|
+
show: () => e.showModal(),
|
|
102
|
+
close: () => e.close(),
|
|
103
|
+
cleanup: i
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
O as SweetestAlert
|
|
108
|
+
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.pco-sweetest-alert {
|
|
2
|
+
background: var(--t-surface-color-card);
|
|
3
|
+
border: 0;
|
|
4
|
+
border-radius: var(--t-border-radius-lg);
|
|
5
|
+
box-shadow: 0 0 var(--t-spacing-3) var(--t-fill-color-transparency-dark-020);
|
|
6
|
+
font-size: var(--t-font-size-md);
|
|
7
|
+
margin: auto;
|
|
8
|
+
max-width: 600px;
|
|
9
|
+
padding: var(--t-spacing-4) var(--t-spacing-4) 0;
|
|
10
|
+
text-align: center;
|
|
11
|
+
|
|
12
|
+
&::backdrop {
|
|
13
|
+
background: var(--t-fill-color-transparency-dark-040);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.pco-sweetest-alert__icon {
|
|
18
|
+
height: var(--t-element-size-3xl);
|
|
19
|
+
margin-block: var(--t-spacing-1);
|
|
20
|
+
width: var(--t-element-size-3xl);
|
|
21
|
+
|
|
22
|
+
&.pco-sweetest-alert--info {
|
|
23
|
+
fill: var(--t-icon-color-status-info-primary);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.pco-sweetest-alert--success {
|
|
27
|
+
fill: var(--t-icon-color-status-success-primary);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.pco-sweetest-alert--warning {
|
|
31
|
+
fill: var(--t-icon-color-status-warning-primary);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&:is(.pco-sweetest-alert--danger, .pco-sweetest-alert--error) {
|
|
35
|
+
fill: var(--t-icon-color-status-error-primary);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.pco-sweetest-alert__title {
|
|
40
|
+
color: var(--t-text-color-default-headline);
|
|
41
|
+
font-size: var(--t-font-size-2xl);
|
|
42
|
+
font-weight: var(--t-font-weight-semibold);
|
|
43
|
+
margin-block: var(--t-spacing-2);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.pco-sweetest-alert__body {
|
|
47
|
+
color: var(--t-text-color-default-primary);
|
|
48
|
+
font-weight: var(--t-font-weight-normal);
|
|
49
|
+
line-height: 1.4;
|
|
50
|
+
margin-bottom: var(--t-spacing-4);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.pco-sweetest-alert__actions {
|
|
54
|
+
align-items: center;
|
|
55
|
+
border-top: var(--t-border-width-default) solid var(--t-border-color-default-base);
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-wrap: wrap;
|
|
58
|
+
gap: var(--t-spacing-1);
|
|
59
|
+
justify-content: center;
|
|
60
|
+
margin-inline: calc(-1 * var(--t-spacing-4));
|
|
61
|
+
padding: var(--t-spacing-3) var(--t-spacing-4);
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type AlertTypes = "info" | "success" | "error" | "danger" | "warning";
|
|
3
|
+
export declare function SweetestAlert({ onCancel, onConfirm, confirmButton, content, hideCancel, title, type, }: {
|
|
4
|
+
onCancel?: () => void;
|
|
5
|
+
onConfirm?: () => void;
|
|
6
|
+
confirmButton?: string;
|
|
7
|
+
content: string | React.ReactNode;
|
|
8
|
+
hideCancel?: boolean;
|
|
9
|
+
title: string;
|
|
10
|
+
type?: AlertTypes;
|
|
11
|
+
}): {
|
|
12
|
+
show: () => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
cleanup: () => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/sweetest-alert",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "The sweetest alert ever",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@1.22.22",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"preview": "vite preview --config vite.config.docs.ts",
|
|
37
37
|
"test": "vitest",
|
|
38
38
|
"lint:js": "eslint .",
|
|
39
|
-
"lint:css": "stylelint \"**/*.css\""
|
|
39
|
+
"lint:css": "stylelint \"**/*.css\"",
|
|
40
|
+
"prepublishOnly": "yarn build:lib"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@planningcenter/icons": "^15.26.0",
|
|
@@ -60,8 +61,10 @@
|
|
|
60
61
|
"eslint-plugin-react": "^7.37.5",
|
|
61
62
|
"eslint-plugin-react-hooks": "^7.0.0",
|
|
62
63
|
"jsdom": "^27.0.0",
|
|
64
|
+
"prismjs": "^1.30.0",
|
|
63
65
|
"react": "^18.3.1",
|
|
64
66
|
"react-dom": "^18.3.1",
|
|
67
|
+
"react-simple-code-editor": "^0.14.1",
|
|
65
68
|
"stylelint": "^16.25.0",
|
|
66
69
|
"typescript": "^5.9.3",
|
|
67
70
|
"typescript-eslint": "^8.46.1",
|
|
@@ -71,9 +74,5 @@
|
|
|
71
74
|
"volta": {
|
|
72
75
|
"node": "22.20.0",
|
|
73
76
|
"yarn": "1.22.22"
|
|
74
|
-
},
|
|
75
|
-
"dependencies": {
|
|
76
|
-
"prismjs": "^1.30.0",
|
|
77
|
-
"react-simple-code-editor": "^0.14.1"
|
|
78
77
|
}
|
|
79
78
|
}
|