@planningcenter/organization-avatars 1.3.0 → 1.4.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/index.cjs +1 -1
- package/dist/index.js +131 -127
- package/dist/style.css +9 -10
- package/dist/types.d.ts +3 -2
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),O=require("react-dom"),B=require("@planningcenter/url"),k=require("@planningcenter/tapestry"),A=require("@planningcenter/icons/paths/general"),P=require("@planningcenter/icons/paths/services"),T=require("react-dropzone");function z(a){var o,t,r="";if(typeof a=="string"||typeof a=="number")r+=a;else if(typeof a=="object")if(Array.isArray(a)){var d=a.length;for(o=0;o<d;o++)a[o]&&(t=z(a[o]))&&(r&&(r+=" "),r+=t)}else for(t in a)a[t]&&(r&&(r+=" "),r+=t);return r}function $(){for(var a,o,t=0,r="",d=arguments.length;t<d;t++)(a=arguments[t])&&(o=z(a))&&(r&&(r+=" "),r+=o);return r}function L(){const a=document.querySelector('meta[name="csrf-token"]');if(!a||!a.content)throw new Error('CSRF token not found. Ensure your Rails application includes <meta name="csrf-token" content="..."> in the document head.');return a.content}function E(a){const o=a.split("");return[o.shift()?.toUpperCase(),o.join("")].join("")}const I=a=>a==="dark_mode_avatar"?"dark":"light";function N({avatarUrl:a,organization:o,mode:t,pcoEnv:r,onAvatarUpdate:d}){const[s,p]=i.useState(null),[u,m]=i.useState(a),[l,f]=i.useState(!1),[c,v]=i.useState(!1),[U,j]=i.useState(""),x=i.useId(),C=i.useRef(null),_=I(t),F=g=>{const[n]=g;n&&p(Object.assign(n,{preview:URL.createObjectURL(n)}))};i.useEffect(()=>{m(a)},[a]),i.useEffect(()=>()=>{s?.preview&&(URL.revokeObjectURL(s.preview),j(""))},[s]);const S=async g=>{const n=await fetch(B.pcoApiUrl("accounts",{env:r}),{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF-Token":L(),Accept:"application/json"},body:JSON.stringify({data:{attributes:g}})}),h=await n.json();if(!n.ok)throw h;return h},R=async g=>{if(g.preventDefault(),!(!s||l||c)){f(!0);try{const n=new FileReader,h=await new Promise((y,w)=>{n.onloadend=()=>y(n.result),n.onerror=w,n.readAsDataURL(s)}),b=await S({[t]:h,[`${t}_cache`]:""});m(b.data.attributes[t].url),p(null),d(t,b.data.attributes[t].url),C.current?.close()}catch{j("We were unable to save your avatar.")}finally{f(!1)}}},q=async()=>{if(!(l||c)){v(!0);try{await S({[`remove_${t}`]:"1"}),m(""),d(t,""),C.current?.close()}catch{j("We were unable to delete your avatar.")}finally{v(!1)}}},D=()=>{p(null),j("")};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pco-org-avatar",children:[e.jsx("button",{type:"button",commandfor:x,command:"show-modal",className:`pco-org-avatar__button pco-org-avatar__button--${_}`,children:u?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:u,alt:`Church logo for ${o}`}),e.jsx("div",{className:"tds-btn tds-btn--interaction tds-btn--icononly",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:A.pencil})})})]}):e.jsx("svg",{width:"48",height:"48",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:P.image})})}),e.jsxs("div",{className:"pco-org-avatar__label",children:[E(_)," mode"]})]}),O.createPortal(e.jsx("dialog",{id:x,ref:C,className:"pco-org-avatar__dialog",onClose:D,children:e.jsxs("form",{onSubmit:R,children:[e.jsxs("div",{className:"pco-org-avatar__dialog-header",children:[e.jsxs("h1",{className:"pco-org-avatar__dialog-title",children:["Church logo — ",_," mode"]}),e.jsx("button",{type:"button",commandfor:x,command:"close",className:"pco-org-avatar__dialog-close","aria-label":"Close modal",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:A.smallX})})})]}),e.jsxs("div",{className:"pco-org-avatar__dialog-body",children:[U&&e.jsxs("div",{role:"alert",className:"pco-org-avatar__dialog-alert",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",className:"symbol","aria-hidden":"true",children:e.jsx("path",{d:A.exclamationTriangle})}),e.jsx("p",{children:U})]}),e.jsx(T,{accept:{"image/*":[".jpg",".jpeg",".png"]},multiple:!1,onDropAccepted:F,children:({getRootProps:g,getInputProps:n,isFocused:h,isDragAccept:b,isDragReject:y,isDragActive:w})=>{const M=$("pco-org-avatar__dialog-dropzone",`pco-org-avatar__dialog-dropzone--${_}`,{"pco-org-avatar__dialog-dropzone--image":s||u,"pco-org-avatar__dialog-dropzone--focused":h,"pco-org-avatar__dialog-dropzone--accepted":b,"pco-org-avatar__dialog-dropzone--rejected":w&&y});return e.jsxs("div",{...g({className:M}),children:[e.jsx("input",{...n()}),s?e.jsx("img",{src:s.preview,alt:`Church logo for ${o}`}):u?e.jsx("img",{src:u,alt:`Church logo for ${o}`}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"64",height:"64",viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:A.toCloudArrow})}),w&&y?e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Wrong file type"}),e.jsx("p",{children:"Please upload a PNG or JPG file."})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Add church logo"}),e.jsx("p",{children:"Use a high-quality image (up to 20mb) with a transparent background."})]})]})]})}})]}),e.jsxs("div",{className:"pco-org-avatar__dialog-actions",children:[u&&e.jsx(k.Button,{label:"Delete logo",kind:"delete",onClick:q,loading:c,disabled:c||l,className:"pco-org-avatar__dialog-delete"}),e.jsx(k.Button,{type:"button",label:"Cancel",commandfor:x,command:"close",disabled:l||c}),e.jsx(k.Button,{type:"submit",label:"Update logo",kind:"primary",loading:l,disabled:!s||l||c})]})]})}),document.body)]})}function W({avatarUrl:a,darkModeAvatarUrl:o,orgName:t,pcoEnv:r,showDarkModeAvatar:d=!1}){const[s,p]=i.useState(a),[u,m]=i.useState(o),l=(c,v)=>{c==="avatar"?p(v):c==="dark_mode_avatar"&&m(v)},f=u||s;return e.jsxs("div",{className:"pco-org-avatars",children:[e.jsx(N,{avatarUrl:s,organization:t,mode:"avatar",pcoEnv:r,onAvatarUpdate:l}),d&&e.jsx(N,{avatarUrl:f,organization:t,mode:"dark_mode_avatar",pcoEnv:r,onAvatarUpdate:l})]})}exports.OrganizationAvatars=W;
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { pcoApiUrl as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { pencil as
|
|
7
|
-
import { image as
|
|
8
|
-
import
|
|
9
|
-
function
|
|
10
|
-
var
|
|
11
|
-
if (typeof e == "string" || typeof e == "number")
|
|
1
|
+
import { jsxs as n, Fragment as _, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useId as P, useRef as T, useEffect as D } from "react";
|
|
3
|
+
import { createPortal as L } from "react-dom";
|
|
4
|
+
import { pcoApiUrl as I } from "@planningcenter/url";
|
|
5
|
+
import { Button as j } from "@planningcenter/tapestry";
|
|
6
|
+
import { pencil as E, smallX as W, exclamationTriangle as q, toCloudArrow as G } from "@planningcenter/icons/paths/general";
|
|
7
|
+
import { image as J } from "@planningcenter/icons/paths/services";
|
|
8
|
+
import X from "react-dropzone";
|
|
9
|
+
function M(e) {
|
|
10
|
+
var o, r, t = "";
|
|
11
|
+
if (typeof e == "string" || typeof e == "number") t += e;
|
|
12
12
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
13
|
-
var
|
|
14
|
-
for (
|
|
15
|
-
} else for (r in e) e[r] && (
|
|
16
|
-
return
|
|
13
|
+
var s = e.length;
|
|
14
|
+
for (o = 0; o < s; o++) e[o] && (r = M(e[o])) && (t && (t += " "), t += r);
|
|
15
|
+
} else for (r in e) e[r] && (t && (t += " "), t += r);
|
|
16
|
+
return t;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
for (var e,
|
|
20
|
-
return
|
|
18
|
+
function H() {
|
|
19
|
+
for (var e, o, r = 0, t = "", s = arguments.length; r < s; r++) (e = arguments[r]) && (o = M(e)) && (t && (t += " "), t += o);
|
|
20
|
+
return t;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function K() {
|
|
23
23
|
const e = document.querySelector('meta[name="csrf-token"]');
|
|
24
24
|
if (!e || !e.content)
|
|
25
25
|
throw new Error(
|
|
@@ -27,33 +27,37 @@ function X() {
|
|
|
27
27
|
);
|
|
28
28
|
return e.content;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
function Q(e) {
|
|
31
|
+
const o = e.split("");
|
|
32
|
+
return [o.shift()?.toUpperCase(), o.join("")].join("");
|
|
33
|
+
}
|
|
34
|
+
const V = (e) => e === "dark_mode_avatar" ? "dark" : "light";
|
|
35
|
+
function R({
|
|
32
36
|
avatarUrl: e,
|
|
33
|
-
organization:
|
|
37
|
+
organization: o,
|
|
34
38
|
mode: r,
|
|
35
|
-
pcoEnv:
|
|
36
|
-
onAvatarUpdate:
|
|
39
|
+
pcoEnv: t,
|
|
40
|
+
onAvatarUpdate: s
|
|
37
41
|
}) {
|
|
38
|
-
const [
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
Object.assign(
|
|
42
|
-
preview: URL.createObjectURL(
|
|
42
|
+
const [l, m] = u(null), [h, f] = u(e), [c, U] = u(!1), [d, v] = u(!1), [z, b] = u(""), y = P(), N = T(null), w = V(r), S = (p) => {
|
|
43
|
+
const [i] = p;
|
|
44
|
+
i && m(
|
|
45
|
+
Object.assign(i, {
|
|
46
|
+
preview: URL.createObjectURL(i)
|
|
43
47
|
})
|
|
44
48
|
);
|
|
45
49
|
};
|
|
46
|
-
|
|
50
|
+
D(() => {
|
|
47
51
|
f(e);
|
|
48
|
-
}, [e]),
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
const
|
|
52
|
-
const
|
|
52
|
+
}, [e]), D(() => () => {
|
|
53
|
+
l?.preview && (URL.revokeObjectURL(l.preview), b(""));
|
|
54
|
+
}, [l]);
|
|
55
|
+
const x = async (p) => {
|
|
56
|
+
const i = await fetch(I("accounts", { env: t }), {
|
|
53
57
|
method: "PATCH",
|
|
54
58
|
headers: {
|
|
55
59
|
"Content-Type": "application/json",
|
|
56
|
-
"X-CSRF-Token":
|
|
60
|
+
"X-CSRF-Token": K(),
|
|
57
61
|
Accept: "application/json"
|
|
58
62
|
},
|
|
59
63
|
body: JSON.stringify({
|
|
@@ -61,44 +65,44 @@ function x({
|
|
|
61
65
|
attributes: p
|
|
62
66
|
}
|
|
63
67
|
})
|
|
64
|
-
}),
|
|
65
|
-
if (!
|
|
66
|
-
return
|
|
67
|
-
},
|
|
68
|
-
if (p.preventDefault(), !(!
|
|
69
|
-
|
|
68
|
+
}), g = await i.json();
|
|
69
|
+
if (!i.ok) throw g;
|
|
70
|
+
return g;
|
|
71
|
+
}, F = async (p) => {
|
|
72
|
+
if (p.preventDefault(), !(!l || c || d)) {
|
|
73
|
+
U(!0);
|
|
70
74
|
try {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
}), k = await
|
|
74
|
-
[r]:
|
|
75
|
+
const i = new FileReader(), g = await new Promise((A, C) => {
|
|
76
|
+
i.onloadend = () => A(i.result), i.onerror = C, i.readAsDataURL(l);
|
|
77
|
+
}), k = await x({
|
|
78
|
+
[r]: g,
|
|
75
79
|
[`${r}_cache`]: ""
|
|
76
80
|
});
|
|
77
|
-
f(k.data.attributes[r].url), m(null),
|
|
81
|
+
f(k.data.attributes[r].url), m(null), s(r, k.data.attributes[r].url), N.current?.close();
|
|
78
82
|
} catch {
|
|
79
|
-
|
|
83
|
+
b("We were unable to save your avatar.");
|
|
80
84
|
} finally {
|
|
81
|
-
|
|
85
|
+
U(!1);
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
},
|
|
85
|
-
if (!c) {
|
|
88
|
+
}, O = async () => {
|
|
89
|
+
if (!(c || d)) {
|
|
86
90
|
v(!0);
|
|
87
91
|
try {
|
|
88
|
-
await
|
|
92
|
+
await x({
|
|
89
93
|
[`remove_${r}`]: "1"
|
|
90
|
-
}), f(""),
|
|
94
|
+
}), f(""), s(r, ""), N.current?.close();
|
|
91
95
|
} catch {
|
|
92
|
-
|
|
96
|
+
b("We were unable to delete your avatar.");
|
|
93
97
|
} finally {
|
|
94
98
|
v(!1);
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
|
-
},
|
|
98
|
-
m(null),
|
|
101
|
+
}, $ = () => {
|
|
102
|
+
m(null), b("");
|
|
99
103
|
};
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ n(_, { children: [
|
|
105
|
+
/* @__PURE__ */ n("div", { className: "pco-org-avatar", children: [
|
|
102
106
|
/* @__PURE__ */ a(
|
|
103
107
|
"button",
|
|
104
108
|
{
|
|
@@ -106,17 +110,17 @@ function x({
|
|
|
106
110
|
commandfor: y,
|
|
107
111
|
command: "show-modal",
|
|
108
112
|
className: `pco-org-avatar__button pco-org-avatar__button--${w}`,
|
|
109
|
-
children:
|
|
110
|
-
/* @__PURE__ */ a("img", { src:
|
|
111
|
-
/* @__PURE__ */ a("
|
|
113
|
+
children: h ? /* @__PURE__ */ n(_, { children: [
|
|
114
|
+
/* @__PURE__ */ a("img", { src: h, alt: `Church logo for ${o}` }),
|
|
115
|
+
/* @__PURE__ */ a("div", { className: "tds-btn tds-btn--interaction tds-btn--icononly", children: /* @__PURE__ */ a(
|
|
112
116
|
"svg",
|
|
113
117
|
{
|
|
114
|
-
width: "
|
|
115
|
-
height: "
|
|
118
|
+
width: "14",
|
|
119
|
+
height: "14",
|
|
116
120
|
viewBox: "0 0 16 16",
|
|
117
121
|
fill: "currentColor",
|
|
118
122
|
"aria-hidden": "true",
|
|
119
|
-
children: /* @__PURE__ */ a("path", { d:
|
|
123
|
+
children: /* @__PURE__ */ a("path", { d: E })
|
|
120
124
|
}
|
|
121
125
|
) })
|
|
122
126
|
] }) : /* @__PURE__ */ a(
|
|
@@ -127,27 +131,27 @@ function x({
|
|
|
127
131
|
viewBox: "0 0 16 16",
|
|
128
132
|
fill: "currentColor",
|
|
129
133
|
"aria-hidden": "true",
|
|
130
|
-
children: /* @__PURE__ */ a("path", { d:
|
|
134
|
+
children: /* @__PURE__ */ a("path", { d: J })
|
|
131
135
|
}
|
|
132
136
|
)
|
|
133
137
|
}
|
|
134
138
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
w,
|
|
139
|
+
/* @__PURE__ */ n("div", { className: "pco-org-avatar__label", children: [
|
|
140
|
+
Q(w),
|
|
137
141
|
" mode"
|
|
138
142
|
] })
|
|
139
143
|
] }),
|
|
140
|
-
|
|
144
|
+
L(
|
|
141
145
|
/* @__PURE__ */ a(
|
|
142
146
|
"dialog",
|
|
143
147
|
{
|
|
144
148
|
id: y,
|
|
145
|
-
ref:
|
|
149
|
+
ref: N,
|
|
146
150
|
className: "pco-org-avatar__dialog",
|
|
147
|
-
onClose:
|
|
148
|
-
children: /* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
+
onClose: $,
|
|
152
|
+
children: /* @__PURE__ */ n("form", { onSubmit: F, children: [
|
|
153
|
+
/* @__PURE__ */ n("div", { className: "pco-org-avatar__dialog-header", children: [
|
|
154
|
+
/* @__PURE__ */ n("h1", { className: "pco-org-avatar__dialog-title", children: [
|
|
151
155
|
"Church logo — ",
|
|
152
156
|
w,
|
|
153
157
|
" mode"
|
|
@@ -168,14 +172,14 @@ function x({
|
|
|
168
172
|
viewBox: "0 0 16 16",
|
|
169
173
|
fill: "currentColor",
|
|
170
174
|
"aria-hidden": "true",
|
|
171
|
-
children: /* @__PURE__ */ a("path", { d:
|
|
175
|
+
children: /* @__PURE__ */ a("path", { d: W })
|
|
172
176
|
}
|
|
173
177
|
)
|
|
174
178
|
}
|
|
175
179
|
)
|
|
176
180
|
] }),
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
|
|
181
|
+
/* @__PURE__ */ n("div", { className: "pco-org-avatar__dialog-body", children: [
|
|
182
|
+
z && /* @__PURE__ */ n("div", { role: "alert", className: "pco-org-avatar__dialog-alert", children: [
|
|
179
183
|
/* @__PURE__ */ a(
|
|
180
184
|
"svg",
|
|
181
185
|
{
|
|
@@ -184,50 +188,50 @@ function x({
|
|
|
184
188
|
viewBox: "0 0 16 16",
|
|
185
189
|
className: "symbol",
|
|
186
190
|
"aria-hidden": "true",
|
|
187
|
-
children: /* @__PURE__ */ a("path", { d:
|
|
191
|
+
children: /* @__PURE__ */ a("path", { d: q })
|
|
188
192
|
}
|
|
189
193
|
),
|
|
190
|
-
/* @__PURE__ */ a("p", { children:
|
|
194
|
+
/* @__PURE__ */ a("p", { children: z })
|
|
191
195
|
] }),
|
|
192
196
|
/* @__PURE__ */ a(
|
|
193
|
-
|
|
197
|
+
X,
|
|
194
198
|
{
|
|
195
199
|
accept: { "image/*": [".jpg", ".jpeg", ".png"] },
|
|
196
200
|
multiple: !1,
|
|
197
|
-
onDropAccepted:
|
|
201
|
+
onDropAccepted: S,
|
|
198
202
|
children: ({
|
|
199
203
|
getRootProps: p,
|
|
200
|
-
getInputProps:
|
|
201
|
-
isFocused:
|
|
204
|
+
getInputProps: i,
|
|
205
|
+
isFocused: g,
|
|
202
206
|
isDragAccept: k,
|
|
203
|
-
isDragReject:
|
|
204
|
-
isDragActive:
|
|
207
|
+
isDragReject: A,
|
|
208
|
+
isDragActive: C
|
|
205
209
|
}) => {
|
|
206
|
-
const
|
|
210
|
+
const B = H(
|
|
207
211
|
"pco-org-avatar__dialog-dropzone",
|
|
208
212
|
`pco-org-avatar__dialog-dropzone--${w}`,
|
|
209
213
|
{
|
|
210
|
-
"pco-org-avatar__dialog-dropzone--image":
|
|
211
|
-
"pco-org-avatar__dialog-dropzone--focused":
|
|
214
|
+
"pco-org-avatar__dialog-dropzone--image": l || h,
|
|
215
|
+
"pco-org-avatar__dialog-dropzone--focused": g,
|
|
212
216
|
"pco-org-avatar__dialog-dropzone--accepted": k,
|
|
213
|
-
"pco-org-avatar__dialog-dropzone--rejected":
|
|
217
|
+
"pco-org-avatar__dialog-dropzone--rejected": C && A
|
|
214
218
|
}
|
|
215
219
|
);
|
|
216
|
-
return /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */ a("input", { ...
|
|
218
|
-
|
|
220
|
+
return /* @__PURE__ */ n("div", { ...p({ className: B }), children: [
|
|
221
|
+
/* @__PURE__ */ a("input", { ...i() }),
|
|
222
|
+
l ? /* @__PURE__ */ a(
|
|
219
223
|
"img",
|
|
220
224
|
{
|
|
221
|
-
src:
|
|
222
|
-
alt: `Church logo for ${
|
|
225
|
+
src: l.preview,
|
|
226
|
+
alt: `Church logo for ${o}`
|
|
223
227
|
}
|
|
224
|
-
) :
|
|
228
|
+
) : h ? /* @__PURE__ */ a(
|
|
225
229
|
"img",
|
|
226
230
|
{
|
|
227
|
-
src:
|
|
228
|
-
alt: `Church logo for ${
|
|
231
|
+
src: h,
|
|
232
|
+
alt: `Church logo for ${o}`
|
|
229
233
|
}
|
|
230
|
-
) : /* @__PURE__ */
|
|
234
|
+
) : /* @__PURE__ */ n(_, { children: [
|
|
231
235
|
/* @__PURE__ */ a(
|
|
232
236
|
"svg",
|
|
233
237
|
{
|
|
@@ -235,13 +239,13 @@ function x({
|
|
|
235
239
|
height: "64",
|
|
236
240
|
viewBox: "0 0 16 16",
|
|
237
241
|
"aria-hidden": "true",
|
|
238
|
-
children: /* @__PURE__ */ a("path", { d:
|
|
242
|
+
children: /* @__PURE__ */ a("path", { d: G })
|
|
239
243
|
}
|
|
240
244
|
),
|
|
241
|
-
|
|
245
|
+
C && A ? /* @__PURE__ */ n(_, { children: [
|
|
242
246
|
/* @__PURE__ */ a("h2", { children: "Wrong file type" }),
|
|
243
247
|
/* @__PURE__ */ a("p", { children: "Please upload a PNG or JPG file." })
|
|
244
|
-
] }) : /* @__PURE__ */
|
|
248
|
+
] }) : /* @__PURE__ */ n(_, { children: [
|
|
245
249
|
/* @__PURE__ */ a("h2", { children: "Add church logo" }),
|
|
246
250
|
/* @__PURE__ */ a("p", { children: "Use a high-quality image (up to 20mb) with a transparent background." })
|
|
247
251
|
] })
|
|
@@ -251,36 +255,36 @@ function x({
|
|
|
251
255
|
}
|
|
252
256
|
)
|
|
253
257
|
] }),
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
/* @__PURE__ */ n("div", { className: "pco-org-avatar__dialog-actions", children: [
|
|
259
|
+
h && /* @__PURE__ */ a(
|
|
260
|
+
j,
|
|
257
261
|
{
|
|
258
262
|
label: "Delete logo",
|
|
259
263
|
kind: "delete",
|
|
260
|
-
onClick:
|
|
261
|
-
loading:
|
|
262
|
-
disabled: c,
|
|
264
|
+
onClick: O,
|
|
265
|
+
loading: d,
|
|
266
|
+
disabled: d || c,
|
|
263
267
|
className: "pco-org-avatar__dialog-delete"
|
|
264
268
|
}
|
|
265
269
|
),
|
|
266
270
|
/* @__PURE__ */ a(
|
|
267
|
-
|
|
271
|
+
j,
|
|
268
272
|
{
|
|
269
273
|
type: "button",
|
|
270
274
|
label: "Cancel",
|
|
271
275
|
commandfor: y,
|
|
272
276
|
command: "close",
|
|
273
|
-
disabled: c
|
|
277
|
+
disabled: c || d
|
|
274
278
|
}
|
|
275
279
|
),
|
|
276
280
|
/* @__PURE__ */ a(
|
|
277
|
-
|
|
281
|
+
j,
|
|
278
282
|
{
|
|
279
283
|
type: "submit",
|
|
280
284
|
label: "Update logo",
|
|
281
285
|
kind: "primary",
|
|
282
286
|
loading: c,
|
|
283
|
-
disabled: !
|
|
287
|
+
disabled: !l || c || d
|
|
284
288
|
}
|
|
285
289
|
)
|
|
286
290
|
] })
|
|
@@ -291,41 +295,41 @@ function x({
|
|
|
291
295
|
)
|
|
292
296
|
] });
|
|
293
297
|
}
|
|
294
|
-
function
|
|
298
|
+
function ia({
|
|
295
299
|
avatarUrl: e,
|
|
296
|
-
darkModeAvatarUrl:
|
|
300
|
+
darkModeAvatarUrl: o,
|
|
297
301
|
orgName: r,
|
|
298
|
-
pcoEnv:
|
|
299
|
-
showDarkModeAvatar:
|
|
302
|
+
pcoEnv: t,
|
|
303
|
+
showDarkModeAvatar: s = !1
|
|
300
304
|
}) {
|
|
301
|
-
const [
|
|
302
|
-
|
|
303
|
-
), c = (
|
|
304
|
-
|
|
305
|
+
const [l, m] = u(e), [h, f] = u(
|
|
306
|
+
o
|
|
307
|
+
), c = (d, v) => {
|
|
308
|
+
d === "avatar" ? m(v) : d === "dark_mode_avatar" && f(v);
|
|
305
309
|
};
|
|
306
|
-
return /* @__PURE__ */
|
|
310
|
+
return /* @__PURE__ */ n("div", { className: "pco-org-avatars", children: [
|
|
307
311
|
/* @__PURE__ */ a(
|
|
308
|
-
|
|
312
|
+
R,
|
|
309
313
|
{
|
|
310
|
-
avatarUrl:
|
|
314
|
+
avatarUrl: l,
|
|
311
315
|
organization: r,
|
|
312
316
|
mode: "avatar",
|
|
313
|
-
pcoEnv:
|
|
317
|
+
pcoEnv: t,
|
|
314
318
|
onAvatarUpdate: c
|
|
315
319
|
}
|
|
316
320
|
),
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
s && /* @__PURE__ */ a(
|
|
322
|
+
R,
|
|
319
323
|
{
|
|
320
|
-
avatarUrl:
|
|
324
|
+
avatarUrl: h || l,
|
|
321
325
|
organization: r,
|
|
322
326
|
mode: "dark_mode_avatar",
|
|
323
|
-
pcoEnv:
|
|
327
|
+
pcoEnv: t,
|
|
324
328
|
onAvatarUpdate: c
|
|
325
329
|
}
|
|
326
330
|
)
|
|
327
331
|
] });
|
|
328
332
|
}
|
|
329
333
|
export {
|
|
330
|
-
|
|
334
|
+
ia as OrganizationAvatars
|
|
331
335
|
};
|
package/dist/style.css
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.pco-org-avatar__button {
|
|
14
|
-
background:
|
|
14
|
+
background: var(--t-surface-color-canvas);
|
|
15
15
|
border: var(--t-border-width) dashed var(--t-border-color);
|
|
16
16
|
border-radius: var(--t-border-radius-lg);
|
|
17
17
|
color: var(--t-icon-color-dim);
|
|
@@ -29,23 +29,17 @@
|
|
|
29
29
|
vertical-align: middle;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.pco-org-avatar__button
|
|
33
|
-
background: var(--t-fill-color-interaction);
|
|
34
|
-
border-radius: var(--t-border-radius-md);
|
|
32
|
+
.pco-org-avatar__button div {
|
|
35
33
|
bottom: var(--t-spacing-1);
|
|
36
|
-
box-shadow: 0 var(--t-spacing-half) var(--t-spacing-1)
|
|
37
|
-
var(--t-fill-color-transparency-dark-static-020);
|
|
38
|
-
color: var(--t-icon-color-inverted);
|
|
39
34
|
opacity: 0;
|
|
40
|
-
padding: var(--t-spacing-1);
|
|
41
35
|
position: absolute;
|
|
42
36
|
right: var(--t-spacing-1);
|
|
43
37
|
transition: all 0.1s linear;
|
|
44
38
|
visibility: hidden;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
|
-
.pco-org-avatar__button:hover
|
|
48
|
-
.pco-org-avatar__button:focus-
|
|
41
|
+
.pco-org-avatar__button:hover div,
|
|
42
|
+
.pco-org-avatar__button:focus-visible div {
|
|
49
43
|
opacity: 1;
|
|
50
44
|
visibility: visible;
|
|
51
45
|
}
|
|
@@ -194,6 +188,11 @@
|
|
|
194
188
|
vertical-align: middle;
|
|
195
189
|
}
|
|
196
190
|
|
|
191
|
+
.pco-org-avatar__dialog-dropzone:not(
|
|
192
|
+
.pco-org-avatar__dialog-dropzone:has(img),
|
|
193
|
+
.pco-org-avatar__dialog-dropzone--accepted,
|
|
194
|
+
.pco-org-avatar__dialog-dropzone--rejected
|
|
195
|
+
):hover,
|
|
197
196
|
.pco-org-avatar__dialog-dropzone--focused {
|
|
198
197
|
outline: 2px solid var(--t-fill-color-interaction);
|
|
199
198
|
outline-offset: 1px;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import type { Environment } from "@planningcenter/url";
|
|
1
2
|
export type OrganizationAvatarsProps = {
|
|
2
3
|
avatarUrl?: string;
|
|
3
4
|
darkModeAvatarUrl?: string;
|
|
4
5
|
orgName: string;
|
|
5
|
-
pcoEnv?:
|
|
6
|
+
pcoEnv?: Environment;
|
|
6
7
|
showDarkModeAvatar?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export type OrganizationAvatarProps = {
|
|
9
10
|
avatarUrl?: string;
|
|
10
11
|
organization: string;
|
|
11
12
|
mode: "avatar" | "dark_mode_avatar";
|
|
12
|
-
pcoEnv?:
|
|
13
|
+
pcoEnv?: Environment;
|
|
13
14
|
onAvatarUpdate: (attrName: string, newUrl: string) => void;
|
|
14
15
|
};
|
|
15
16
|
export type FileWithPreview = File & {
|
package/dist/utils.d.ts
CHANGED