@planningcenter/organization-avatars 1.7.0 → 1.8.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 -1
- package/dist/index.js +176 -160
- package/dist/style.css +33 -20
- 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"),c=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),P=require("react-dom"),$=require("@planningcenter/url"),y=require("@planningcenter/tapestry"),I=require("@planningcenter/sweetest-alert"),x=require("@planningcenter/icons/paths/general"),L=require("@planningcenter/icons/paths/services"),E=require("react-dropzone");function B(a){var r,t,o="";if(typeof a=="string"||typeof a=="number")o+=a;else if(typeof a=="object")if(Array.isArray(a)){var d=a.length;for(r=0;r<d;r++)a[r]&&(t=B(a[r]))&&(o&&(o+=" "),o+=t)}else for(t in a)a[t]&&(o&&(o+=" "),o+=t);return o}function W(){for(var a,r,t=0,o="",d=arguments.length;t<d;t++)(a=arguments[t])&&(r=B(a))&&(o&&(o+=" "),o+=r);return o}function G(){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 J(a){const r=a.split("");return[r.shift()?.toUpperCase(),r.join("")].join("")}const X=a=>a==="dark_mode_avatar"?"dark":"light",U=({open:a})=>e.jsxs("h2",{className:"pco-org-avatar__instructions",children:["Drag & drop your logo file to upload, or"," ",e.jsx(y.Button,{label:"browse",kind:"inline-text",onClick:r=>{r.stopPropagation(),a()}})]});function z({avatarUrl:a,organization:r,mode:t,pcoEnv:o,readOnly:d,onAvatarUpdate:f,fallbackAvatarUrl:b}){const[n,_]=c.useState(null),[l,w]=c.useState(!1),[i,p]=c.useState(!1),[g,k]=c.useState(""),q=c.useId(),m=c.useRef(null),u=X(t),v=a||b,T=h=>{const[s]=h;s&&_(Object.assign(s,{preview:URL.createObjectURL(s)}))};c.useEffect(()=>()=>{n?.preview&&(URL.revokeObjectURL(n.preview),k(""))},[n]);const R=async h=>{const s=await fetch($.pcoApiUrl("accounts",{env:o}),{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF-Token":G(),Accept:"application/json"},body:JSON.stringify({data:{attributes:h}})}),j=await s.json();if(!s.ok)throw j;return j},D=async h=>{if(h.preventDefault(),!(!n||l||i)){w(!0);try{const s=new FileReader,j=await new Promise((C,N)=>{s.onloadend=()=>C(s.result),s.onerror=N,s.readAsDataURL(n)}),A=await R({[t]:j,[`${t}_cache`]:""});_(null),f(t,A.data.attributes[t].url),m.current?.close()}catch{k("We were unable to save your avatar.")}finally{w(!1)}}},S=async()=>{l||i||(p(!0),I.SweetestAlert({type:"danger",title:"Remove this logo?",content:u==="light"?"Removing this logo means no logo will appear in light mode. This cannot be undone.":b?"Removing this logo means your light mode logo will appear in dark mode. This cannot be undone.":"Removing this logo means no logo will appear in dark mode. This cannot be undone.",confirmButton:"Remove logo",onConfirm:async()=>{try{await R({[`remove_${t}`]:"1"}),f(t,""),m.current?.close()}catch{k("We were unable to delete your avatar.")}finally{p(!1)}},onCancel:()=>{p(!1)}}))},M=()=>{_(null),k("")};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pco-org-avatar",children:[e.jsx("button",{type:"button",onClick:()=>m.current?.showModal(),disabled:d,className:`pco-org-avatar__button pco-org-avatar__button--${u}`,children:v?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:v,alt:`Church logo for ${r}`}),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:x.pencil})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{width:"48",height:"48",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:L.image})}),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:x.pencil})})})]})}),e.jsxs("div",{className:"pco-org-avatar__label",children:[J(u)," mode"]})]}),P.createPortal(e.jsx("dialog",{id:q,ref:m,className:"pco-org-avatar__dialog",onClose:M,children:e.jsxs("form",{onSubmit:D,children:[e.jsxs("div",{className:"pco-org-avatar__dialog-header",children:[e.jsxs("h1",{className:"pco-org-avatar__dialog-title",children:["Church logo — ",u," mode"]}),e.jsx("button",{type:"button",onClick:()=>m.current?.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:x.smallX})})})]}),e.jsxs("div",{className:"pco-org-avatar__dialog-body",children:[g&&e.jsxs("div",{role:"alert",className:"pco-org-avatar-alert 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:x.exclamationTriangle})}),e.jsx("p",{children:g})]}),e.jsx(E,{accept:{"image/*":[".jpg",".jpeg",".png"]},multiple:!1,onDropAccepted:T,children:({getRootProps:h,getInputProps:s,isFocused:j,isDragAccept:A,isDragReject:C,isDragActive:N,open:F})=>{const O=W("pco-org-avatar__dialog-dropzone",`pco-org-avatar__dialog-dropzone--${u}`,{"pco-org-avatar__dialog-dropzone--image":n||v,"pco-org-avatar__dialog-dropzone--focused":j,"pco-org-avatar__dialog-dropzone--accepted":A,"pco-org-avatar__dialog-dropzone--rejected":N&&C});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{...h({className:O}),children:[e.jsx("input",{...s()}),n?e.jsx("img",{src:n.preview,alt:`Church logo for ${r}`}):v?e.jsx("img",{src:v,alt:`Church logo for ${r}`}):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:x.toCloudArrow})}),N&&C?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(U,{open:F}),e.jsx("p",{className:"pco-org-avatar__instructions-sub",children:"Use a high-quality image (up to 20mb) with a transparent background."})]})]})]}),(n||v)&&e.jsx(U,{open:F})]})}})]}),e.jsxs("div",{className:"pco-org-avatar__dialog-actions",children:[a&&u==="light"&&e.jsx(y.Button,{label:"Remove logo",kind:"secondary-delete",onClick:S,loading:i,disabled:i||l,className:"pco-org-avatar__dialog-delete"}),a&&u==="dark"&&e.jsx(y.Button,{label:"Use light mode logo",kind:"secondary",onClick:S,loading:i,disabled:i||l,className:"pco-org-avatar__dialog-delete"}),e.jsx(y.Button,{type:"button",label:"Cancel",onClick:()=>m.current?.close(),disabled:l||i}),e.jsx(y.Button,{type:"submit",label:"Update logo",kind:"primary",loading:l,disabled:!n||l||i})]})]})}),document.body)]})}function H({avatarUrl:a,darkModeAvatarUrl:r,orgName:t,onAvatarUpdate:o,pcoEnv:d,readOnly:f,showDarkModeAvatar:b=!1}){const[n,_]=c.useState(a),[l,w]=c.useState(r),i=(p,g)=>{p==="avatar"?(_(g),o?.("avatar",g)):p==="dark_mode_avatar"&&(w(g),o?.("dark_mode_avatar",g))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pco-org-avatars",children:[e.jsx(z,{avatarUrl:n,organization:t,mode:"avatar",pcoEnv:d,readOnly:f,onAvatarUpdate:i}),b&&e.jsx(z,{avatarUrl:l,organization:t,mode:"dark_mode_avatar",pcoEnv:d,readOnly:f,onAvatarUpdate:i,fallbackAvatarUrl:n})]}),b&&n&&!l&&e.jsxs("div",{className:"pco-org-avatar-alert",children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",className:"symbol","aria-hidden":"true",children:e.jsx("path",{d:x.infoCircle})}),e.jsx("p",{children:"The same logo is being used for both light and dark modes."})]})]})}exports.OrganizationAvatars=H;
|
package/dist/index.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as r, Fragment as h, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as _, useId as L, useRef as E, useEffect as W } from "react";
|
|
3
3
|
import { createPortal as q } from "react-dom";
|
|
4
4
|
import { pcoApiUrl as G } from "@planningcenter/url";
|
|
5
|
-
import { Button as
|
|
5
|
+
import { Button as C } from "@planningcenter/tapestry";
|
|
6
6
|
import { SweetestAlert as J } from "@planningcenter/sweetest-alert";
|
|
7
|
-
import { pencil as
|
|
8
|
-
import { image as
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
var
|
|
12
|
-
if (typeof
|
|
13
|
-
else if (typeof
|
|
14
|
-
var s =
|
|
15
|
-
for (
|
|
16
|
-
} else for (
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
function Y() {
|
|
20
|
-
for (var e, o, r = 0, t = "", s = arguments.length; r < s; r++) (e = arguments[r]) && (o = M(e)) && (t && (t += " "), t += o);
|
|
21
|
-
return t;
|
|
7
|
+
import { pencil as T, smallX as X, exclamationTriangle as H, toCloudArrow as K, infoCircle as Q } from "@planningcenter/icons/paths/general";
|
|
8
|
+
import { image as V } from "@planningcenter/icons/paths/services";
|
|
9
|
+
import Y from "react-dropzone";
|
|
10
|
+
function D(a) {
|
|
11
|
+
var t, o, n = "";
|
|
12
|
+
if (typeof a == "string" || typeof a == "number") n += a;
|
|
13
|
+
else if (typeof a == "object") if (Array.isArray(a)) {
|
|
14
|
+
var s = a.length;
|
|
15
|
+
for (t = 0; t < s; t++) a[t] && (o = D(a[t])) && (n && (n += " "), n += o);
|
|
16
|
+
} else for (o in a) a[o] && (n && (n += " "), n += o);
|
|
17
|
+
return n;
|
|
22
18
|
}
|
|
23
19
|
function Z() {
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
for (var a, t, o = 0, n = "", s = arguments.length; o < s; o++) (a = arguments[o]) && (t = D(a)) && (n && (n += " "), n += t);
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
function ee() {
|
|
24
|
+
const a = document.querySelector('meta[name="csrf-token"]');
|
|
25
|
+
if (!a || !a.content)
|
|
26
26
|
throw new Error(
|
|
27
27
|
'CSRF token not found. Ensure your Rails application includes <meta name="csrf-token" content="..."> in the document head.'
|
|
28
28
|
);
|
|
29
|
-
return
|
|
29
|
+
return a.content;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
return [
|
|
31
|
+
function ae(a) {
|
|
32
|
+
const t = a.split("");
|
|
33
|
+
return [t.shift()?.toUpperCase(), t.join("")].join("");
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const oe = (a) => a === "dark_mode_avatar" ? "dark" : "light", B = ({ open: a }) => /* @__PURE__ */ r("h2", { className: "pco-org-avatar__instructions", children: [
|
|
36
36
|
"Drag & drop your logo file to upload, or",
|
|
37
37
|
" ",
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
38
|
+
/* @__PURE__ */ e(
|
|
39
|
+
C,
|
|
40
40
|
{
|
|
41
41
|
label: "browse",
|
|
42
42
|
kind: "inline-text",
|
|
43
|
-
onClick: (
|
|
44
|
-
|
|
43
|
+
onClick: (t) => {
|
|
44
|
+
t.stopPropagation(), a();
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
)
|
|
48
48
|
] });
|
|
49
49
|
function F({
|
|
50
|
-
avatarUrl:
|
|
51
|
-
organization:
|
|
52
|
-
mode:
|
|
53
|
-
pcoEnv:
|
|
50
|
+
avatarUrl: a,
|
|
51
|
+
organization: t,
|
|
52
|
+
mode: o,
|
|
53
|
+
pcoEnv: n,
|
|
54
54
|
readOnly: s,
|
|
55
55
|
onAvatarUpdate: y,
|
|
56
|
-
fallbackAvatarUrl:
|
|
56
|
+
fallbackAvatarUrl: w
|
|
57
57
|
}) {
|
|
58
|
-
const [i,
|
|
59
|
-
const [l] =
|
|
60
|
-
l &&
|
|
58
|
+
const [i, k] = _(null), [d, N] = _(!1), [c, m] = _(!1), [g, A] = _(""), M = L(), v = E(null), p = oe(o), f = a || w, P = (u) => {
|
|
59
|
+
const [l] = u;
|
|
60
|
+
l && k(
|
|
61
61
|
Object.assign(l, {
|
|
62
62
|
preview: URL.createObjectURL(l)
|
|
63
63
|
})
|
|
@@ -66,50 +66,50 @@ function F({
|
|
|
66
66
|
W(() => () => {
|
|
67
67
|
i?.preview && (URL.revokeObjectURL(i.preview), A(""));
|
|
68
68
|
}, [i]);
|
|
69
|
-
const
|
|
70
|
-
const l = await fetch(G("accounts", { env:
|
|
69
|
+
const x = async (u) => {
|
|
70
|
+
const l = await fetch(G("accounts", { env: n }), {
|
|
71
71
|
method: "PATCH",
|
|
72
72
|
headers: {
|
|
73
73
|
"Content-Type": "application/json",
|
|
74
|
-
"X-CSRF-Token":
|
|
74
|
+
"X-CSRF-Token": ee(),
|
|
75
75
|
Accept: "application/json"
|
|
76
76
|
},
|
|
77
77
|
body: JSON.stringify({
|
|
78
78
|
data: {
|
|
79
|
-
attributes:
|
|
79
|
+
attributes: u
|
|
80
80
|
}
|
|
81
81
|
})
|
|
82
|
-
}),
|
|
83
|
-
if (!l.ok) throw
|
|
84
|
-
return
|
|
85
|
-
},
|
|
86
|
-
if (
|
|
87
|
-
|
|
82
|
+
}), b = await l.json();
|
|
83
|
+
if (!l.ok) throw b;
|
|
84
|
+
return b;
|
|
85
|
+
}, $ = async (u) => {
|
|
86
|
+
if (u.preventDefault(), !(!i || d || c)) {
|
|
87
|
+
N(!0);
|
|
88
88
|
try {
|
|
89
|
-
const l = new FileReader(),
|
|
90
|
-
l.onloadend = () =>
|
|
91
|
-
}), j = await
|
|
92
|
-
[
|
|
93
|
-
[`${
|
|
89
|
+
const l = new FileReader(), b = await new Promise((R, U) => {
|
|
90
|
+
l.onloadend = () => R(l.result), l.onerror = U, l.readAsDataURL(i);
|
|
91
|
+
}), j = await x({
|
|
92
|
+
[o]: b,
|
|
93
|
+
[`${o}_cache`]: ""
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
k(null), y(o, j.data.attributes[o].url), v.current?.close();
|
|
96
96
|
} catch {
|
|
97
97
|
A("We were unable to save your avatar.");
|
|
98
98
|
} finally {
|
|
99
|
-
|
|
99
|
+
N(!1);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
},
|
|
102
|
+
}, z = async () => {
|
|
103
103
|
d || c || (m(!0), J({
|
|
104
104
|
type: "danger",
|
|
105
105
|
title: "Remove this logo?",
|
|
106
|
-
content:
|
|
106
|
+
content: p === "light" ? "Removing this logo means no logo will appear in light mode. This cannot be undone." : w ? "Removing this logo means your light mode logo will appear in dark mode. This cannot be undone." : "Removing this logo means no logo will appear in dark mode. This cannot be undone.",
|
|
107
107
|
confirmButton: "Remove logo",
|
|
108
108
|
onConfirm: async () => {
|
|
109
109
|
try {
|
|
110
|
-
await
|
|
111
|
-
[`remove_${
|
|
112
|
-
}), y(
|
|
110
|
+
await x({
|
|
111
|
+
[`remove_${o}`]: "1"
|
|
112
|
+
}), y(o, ""), v.current?.close();
|
|
113
113
|
} catch {
|
|
114
114
|
A("We were unable to delete your avatar.");
|
|
115
115
|
} finally {
|
|
@@ -121,20 +121,20 @@ function F({
|
|
|
121
121
|
}
|
|
122
122
|
}));
|
|
123
123
|
}, O = () => {
|
|
124
|
-
|
|
124
|
+
k(null), A("");
|
|
125
125
|
};
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */
|
|
126
|
+
return /* @__PURE__ */ r(h, { children: [
|
|
127
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatar", children: [
|
|
128
|
+
/* @__PURE__ */ e(
|
|
129
129
|
"button",
|
|
130
130
|
{
|
|
131
131
|
type: "button",
|
|
132
132
|
onClick: () => v.current?.showModal(),
|
|
133
133
|
disabled: s,
|
|
134
|
-
className: `pco-org-avatar__button pco-org-avatar__button--${
|
|
135
|
-
children: f ? /* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
134
|
+
className: `pco-org-avatar__button pco-org-avatar__button--${p}`,
|
|
135
|
+
children: f ? /* @__PURE__ */ r(h, { children: [
|
|
136
|
+
/* @__PURE__ */ e("img", { src: f, alt: `Church logo for ${t}` }),
|
|
137
|
+
/* @__PURE__ */ e("div", { className: "tds-btn tds-btn--interaction tds-btn--icononly", children: /* @__PURE__ */ e(
|
|
138
138
|
"svg",
|
|
139
139
|
{
|
|
140
140
|
width: "14",
|
|
@@ -142,11 +142,11 @@ function F({
|
|
|
142
142
|
viewBox: "0 0 16 16",
|
|
143
143
|
fill: "currentColor",
|
|
144
144
|
"aria-hidden": "true",
|
|
145
|
-
children: /* @__PURE__ */
|
|
145
|
+
children: /* @__PURE__ */ e("path", { d: T })
|
|
146
146
|
}
|
|
147
147
|
) })
|
|
148
|
-
] }) : /* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
148
|
+
] }) : /* @__PURE__ */ r(h, { children: [
|
|
149
|
+
/* @__PURE__ */ e(
|
|
150
150
|
"svg",
|
|
151
151
|
{
|
|
152
152
|
width: "48",
|
|
@@ -154,10 +154,10 @@ function F({
|
|
|
154
154
|
viewBox: "0 0 16 16",
|
|
155
155
|
fill: "currentColor",
|
|
156
156
|
"aria-hidden": "true",
|
|
157
|
-
children: /* @__PURE__ */
|
|
157
|
+
children: /* @__PURE__ */ e("path", { d: V })
|
|
158
158
|
}
|
|
159
159
|
),
|
|
160
|
-
/* @__PURE__ */
|
|
160
|
+
/* @__PURE__ */ e("div", { className: "tds-btn tds-btn--interaction tds-btn--icononly", children: /* @__PURE__ */ e(
|
|
161
161
|
"svg",
|
|
162
162
|
{
|
|
163
163
|
width: "14",
|
|
@@ -165,40 +165,40 @@ function F({
|
|
|
165
165
|
viewBox: "0 0 16 16",
|
|
166
166
|
fill: "currentColor",
|
|
167
167
|
"aria-hidden": "true",
|
|
168
|
-
children: /* @__PURE__ */
|
|
168
|
+
children: /* @__PURE__ */ e("path", { d: T })
|
|
169
169
|
}
|
|
170
170
|
) })
|
|
171
171
|
] })
|
|
172
172
|
}
|
|
173
173
|
),
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
174
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatar__label", children: [
|
|
175
|
+
ae(p),
|
|
176
176
|
" mode"
|
|
177
177
|
] })
|
|
178
178
|
] }),
|
|
179
179
|
q(
|
|
180
|
-
/* @__PURE__ */
|
|
180
|
+
/* @__PURE__ */ e(
|
|
181
181
|
"dialog",
|
|
182
182
|
{
|
|
183
|
-
id:
|
|
183
|
+
id: M,
|
|
184
184
|
ref: v,
|
|
185
185
|
className: "pco-org-avatar__dialog",
|
|
186
186
|
onClose: O,
|
|
187
|
-
children: /* @__PURE__ */
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
187
|
+
children: /* @__PURE__ */ r("form", { onSubmit: $, children: [
|
|
188
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatar__dialog-header", children: [
|
|
189
|
+
/* @__PURE__ */ r("h1", { className: "pco-org-avatar__dialog-title", children: [
|
|
190
190
|
"Church logo — ",
|
|
191
|
-
|
|
191
|
+
p,
|
|
192
192
|
" mode"
|
|
193
193
|
] }),
|
|
194
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ e(
|
|
195
195
|
"button",
|
|
196
196
|
{
|
|
197
197
|
type: "button",
|
|
198
198
|
onClick: () => v.current?.close(),
|
|
199
199
|
className: "pco-org-avatar__dialog-close",
|
|
200
200
|
"aria-label": "Close modal",
|
|
201
|
-
children: /* @__PURE__ */
|
|
201
|
+
children: /* @__PURE__ */ e(
|
|
202
202
|
"svg",
|
|
203
203
|
{
|
|
204
204
|
width: "16",
|
|
@@ -206,15 +206,15 @@ function F({
|
|
|
206
206
|
viewBox: "0 0 16 16",
|
|
207
207
|
fill: "currentColor",
|
|
208
208
|
"aria-hidden": "true",
|
|
209
|
-
children: /* @__PURE__ */
|
|
209
|
+
children: /* @__PURE__ */ e("path", { d: X })
|
|
210
210
|
}
|
|
211
211
|
)
|
|
212
212
|
}
|
|
213
213
|
)
|
|
214
214
|
] }),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
g && /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
215
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatar__dialog-body", children: [
|
|
216
|
+
g && /* @__PURE__ */ r("div", { role: "alert", className: "pco-org-avatar-alert pco-org-avatar__dialog-alert", children: [
|
|
217
|
+
/* @__PURE__ */ e(
|
|
218
218
|
"svg",
|
|
219
219
|
{
|
|
220
220
|
width: "16",
|
|
@@ -222,102 +222,102 @@ function F({
|
|
|
222
222
|
viewBox: "0 0 16 16",
|
|
223
223
|
className: "symbol",
|
|
224
224
|
"aria-hidden": "true",
|
|
225
|
-
children: /* @__PURE__ */
|
|
225
|
+
children: /* @__PURE__ */ e("path", { d: H })
|
|
226
226
|
}
|
|
227
227
|
),
|
|
228
|
-
/* @__PURE__ */
|
|
228
|
+
/* @__PURE__ */ e("p", { children: g })
|
|
229
229
|
] }),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
|
|
230
|
+
/* @__PURE__ */ e(
|
|
231
|
+
Y,
|
|
232
232
|
{
|
|
233
233
|
accept: { "image/*": [".jpg", ".jpeg", ".png"] },
|
|
234
234
|
multiple: !1,
|
|
235
235
|
onDropAccepted: P,
|
|
236
236
|
children: ({
|
|
237
|
-
getRootProps:
|
|
237
|
+
getRootProps: u,
|
|
238
238
|
getInputProps: l,
|
|
239
|
-
isFocused:
|
|
239
|
+
isFocused: b,
|
|
240
240
|
isDragAccept: j,
|
|
241
|
-
isDragReject:
|
|
241
|
+
isDragReject: R,
|
|
242
242
|
isDragActive: U,
|
|
243
243
|
open: S
|
|
244
244
|
}) => {
|
|
245
|
-
const I =
|
|
245
|
+
const I = Z(
|
|
246
246
|
"pco-org-avatar__dialog-dropzone",
|
|
247
|
-
`pco-org-avatar__dialog-dropzone--${
|
|
247
|
+
`pco-org-avatar__dialog-dropzone--${p}`,
|
|
248
248
|
{
|
|
249
249
|
"pco-org-avatar__dialog-dropzone--image": i || f,
|
|
250
|
-
"pco-org-avatar__dialog-dropzone--focused":
|
|
250
|
+
"pco-org-avatar__dialog-dropzone--focused": b,
|
|
251
251
|
"pco-org-avatar__dialog-dropzone--accepted": j,
|
|
252
|
-
"pco-org-avatar__dialog-dropzone--rejected": U &&
|
|
252
|
+
"pco-org-avatar__dialog-dropzone--rejected": U && R
|
|
253
253
|
}
|
|
254
254
|
);
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
i ? /* @__PURE__ */
|
|
255
|
+
return /* @__PURE__ */ r(h, { children: [
|
|
256
|
+
/* @__PURE__ */ r("div", { ...u({ className: I }), children: [
|
|
257
|
+
/* @__PURE__ */ e("input", { ...l() }),
|
|
258
|
+
i ? /* @__PURE__ */ e(
|
|
259
259
|
"img",
|
|
260
260
|
{
|
|
261
261
|
src: i.preview,
|
|
262
|
-
alt: `Church logo for ${
|
|
262
|
+
alt: `Church logo for ${t}`
|
|
263
263
|
}
|
|
264
|
-
) : f ? /* @__PURE__ */
|
|
264
|
+
) : f ? /* @__PURE__ */ e(
|
|
265
265
|
"img",
|
|
266
266
|
{
|
|
267
267
|
src: f,
|
|
268
|
-
alt: `Church logo for ${
|
|
268
|
+
alt: `Church logo for ${t}`
|
|
269
269
|
}
|
|
270
|
-
) : /* @__PURE__ */
|
|
271
|
-
/* @__PURE__ */
|
|
270
|
+
) : /* @__PURE__ */ r(h, { children: [
|
|
271
|
+
/* @__PURE__ */ e(
|
|
272
272
|
"svg",
|
|
273
273
|
{
|
|
274
274
|
width: "64",
|
|
275
275
|
height: "64",
|
|
276
276
|
viewBox: "0 0 16 16",
|
|
277
277
|
"aria-hidden": "true",
|
|
278
|
-
children: /* @__PURE__ */
|
|
278
|
+
children: /* @__PURE__ */ e("path", { d: K })
|
|
279
279
|
}
|
|
280
280
|
),
|
|
281
|
-
U &&
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
] }) : /* @__PURE__ */
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
281
|
+
U && R ? /* @__PURE__ */ r(h, { children: [
|
|
282
|
+
/* @__PURE__ */ e("h2", { children: "Wrong file type" }),
|
|
283
|
+
/* @__PURE__ */ e("p", { children: "Please upload a PNG or JPG file." })
|
|
284
|
+
] }) : /* @__PURE__ */ r(h, { children: [
|
|
285
|
+
/* @__PURE__ */ e(B, { open: S }),
|
|
286
|
+
/* @__PURE__ */ e("p", { className: "pco-org-avatar__instructions-sub", children: "Use a high-quality image (up to 20mb) with a transparent background." })
|
|
287
287
|
] })
|
|
288
288
|
] })
|
|
289
289
|
] }),
|
|
290
|
-
(i || f) && /* @__PURE__ */
|
|
290
|
+
(i || f) && /* @__PURE__ */ e(B, { open: S })
|
|
291
291
|
] });
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
)
|
|
295
295
|
] }),
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatar__dialog-actions", children: [
|
|
297
|
+
a && p === "light" && /* @__PURE__ */ e(
|
|
298
|
+
C,
|
|
299
299
|
{
|
|
300
300
|
label: "Remove logo",
|
|
301
301
|
kind: "secondary-delete",
|
|
302
|
-
onClick:
|
|
302
|
+
onClick: z,
|
|
303
303
|
loading: c,
|
|
304
304
|
disabled: c || d,
|
|
305
305
|
className: "pco-org-avatar__dialog-delete"
|
|
306
306
|
}
|
|
307
307
|
),
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
a && p === "dark" && /* @__PURE__ */ e(
|
|
309
|
+
C,
|
|
310
310
|
{
|
|
311
311
|
label: "Use light mode logo",
|
|
312
312
|
kind: "secondary",
|
|
313
|
-
onClick:
|
|
313
|
+
onClick: z,
|
|
314
314
|
loading: c,
|
|
315
315
|
disabled: c || d,
|
|
316
316
|
className: "pco-org-avatar__dialog-delete"
|
|
317
317
|
}
|
|
318
318
|
),
|
|
319
|
-
/* @__PURE__ */
|
|
320
|
-
|
|
319
|
+
/* @__PURE__ */ e(
|
|
320
|
+
C,
|
|
321
321
|
{
|
|
322
322
|
type: "button",
|
|
323
323
|
label: "Cancel",
|
|
@@ -325,8 +325,8 @@ function F({
|
|
|
325
325
|
disabled: d || c
|
|
326
326
|
}
|
|
327
327
|
),
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
|
|
328
|
+
/* @__PURE__ */ e(
|
|
329
|
+
C,
|
|
330
330
|
{
|
|
331
331
|
type: "submit",
|
|
332
332
|
label: "Update logo",
|
|
@@ -343,46 +343,62 @@ function F({
|
|
|
343
343
|
)
|
|
344
344
|
] });
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
avatarUrl:
|
|
348
|
-
darkModeAvatarUrl:
|
|
349
|
-
orgName:
|
|
350
|
-
onAvatarUpdate:
|
|
346
|
+
function ge({
|
|
347
|
+
avatarUrl: a,
|
|
348
|
+
darkModeAvatarUrl: t,
|
|
349
|
+
orgName: o,
|
|
350
|
+
onAvatarUpdate: n,
|
|
351
351
|
pcoEnv: s,
|
|
352
352
|
readOnly: y,
|
|
353
|
-
showDarkModeAvatar:
|
|
353
|
+
showDarkModeAvatar: w = !1
|
|
354
354
|
}) {
|
|
355
|
-
const [i,
|
|
356
|
-
|
|
355
|
+
const [i, k] = _(a), [d, N] = _(
|
|
356
|
+
t
|
|
357
357
|
), c = (m, g) => {
|
|
358
|
-
m === "avatar" ? (
|
|
358
|
+
m === "avatar" ? (k(g), n?.("avatar", g)) : m === "dark_mode_avatar" && (N(g), n?.("dark_mode_avatar", g));
|
|
359
359
|
};
|
|
360
|
-
return /* @__PURE__ */
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
360
|
+
return /* @__PURE__ */ r(h, { children: [
|
|
361
|
+
/* @__PURE__ */ r("div", { className: "pco-org-avatars", children: [
|
|
362
|
+
/* @__PURE__ */ e(
|
|
363
|
+
F,
|
|
364
|
+
{
|
|
365
|
+
avatarUrl: i,
|
|
366
|
+
organization: o,
|
|
367
|
+
mode: "avatar",
|
|
368
|
+
pcoEnv: s,
|
|
369
|
+
readOnly: y,
|
|
370
|
+
onAvatarUpdate: c
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
w && /* @__PURE__ */ e(
|
|
374
|
+
F,
|
|
375
|
+
{
|
|
376
|
+
avatarUrl: d,
|
|
377
|
+
organization: o,
|
|
378
|
+
mode: "dark_mode_avatar",
|
|
379
|
+
pcoEnv: s,
|
|
380
|
+
readOnly: y,
|
|
381
|
+
onAvatarUpdate: c,
|
|
382
|
+
fallbackAvatarUrl: i
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
] }),
|
|
386
|
+
w && i && !d && /* @__PURE__ */ r("div", { className: "pco-org-avatar-alert", children: [
|
|
387
|
+
/* @__PURE__ */ e(
|
|
388
|
+
"svg",
|
|
389
|
+
{
|
|
390
|
+
width: "16",
|
|
391
|
+
height: "16",
|
|
392
|
+
viewBox: "0 0 16 16",
|
|
393
|
+
className: "symbol",
|
|
394
|
+
"aria-hidden": "true",
|
|
395
|
+
children: /* @__PURE__ */ e("path", { d: Q })
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
/* @__PURE__ */ e("p", { children: "The same logo is being used for both light and dark modes." })
|
|
399
|
+
] })
|
|
384
400
|
] });
|
|
385
401
|
}
|
|
386
402
|
export {
|
|
387
|
-
|
|
403
|
+
ge as OrganizationAvatars
|
|
388
404
|
};
|
package/dist/style.css
CHANGED
|
@@ -3,23 +3,52 @@
|
|
|
3
3
|
gap: var(--t-spacing-1);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
.pco-org-avatar-alert {
|
|
7
|
+
align-items: center;
|
|
8
|
+
background: var(--t-fill-color-status-info-ghost);
|
|
9
|
+
border-radius: var(--t-border-radius-lg);
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: var(--t-spacing-2);
|
|
12
|
+
margin-top: var(--t-spacing-2);
|
|
13
|
+
padding: var(--t-spacing-2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pco-org-avatar-alert svg {
|
|
17
|
+
fill: var(--t-icon-color-status-info);
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
height: var(--t-element-size-md);
|
|
20
|
+
width: var(--t-element-size-md);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pco-org-avatar-alert p {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: var(--t-spacing-half);
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
.pco-org-avatar {
|
|
7
31
|
align-items: center;
|
|
8
|
-
display:
|
|
32
|
+
display: flex;
|
|
9
33
|
flex-direction: column;
|
|
10
34
|
gap: var(--t-spacing-1);
|
|
35
|
+
flex: 1;
|
|
36
|
+
max-width: 175px;
|
|
37
|
+
min-width: 0;
|
|
11
38
|
}
|
|
12
39
|
|
|
13
40
|
.pco-org-avatar__button {
|
|
41
|
+
aspect-ratio: 175 / 100;
|
|
14
42
|
background: var(--t-surface-color-canvas);
|
|
15
43
|
border: var(--t-border-width) dashed var(--t-border-color);
|
|
16
44
|
border-radius: var(--t-border-radius-lg);
|
|
17
45
|
color: var(--t-icon-color-dim);
|
|
18
46
|
cursor: pointer;
|
|
19
|
-
height: 100px;
|
|
47
|
+
max-height: 100px;
|
|
48
|
+
max-width: 100%;
|
|
20
49
|
padding: var(--t-spacing-1);
|
|
21
50
|
position: relative;
|
|
22
|
-
width:
|
|
51
|
+
width: 100%;
|
|
23
52
|
}
|
|
24
53
|
|
|
25
54
|
.pco-org-avatar__button img {
|
|
@@ -136,27 +165,11 @@
|
|
|
136
165
|
|
|
137
166
|
.pco-org-avatar__dialog-alert {
|
|
138
167
|
background: var(--t-fill-color-status-error-ghost);
|
|
139
|
-
|
|
140
|
-
display: flex;
|
|
141
|
-
gap: var(--t-spacing-2);
|
|
142
|
-
margin-bottom: var(--t-spacing-2);
|
|
143
|
-
padding: var(--t-spacing-2);
|
|
168
|
+
margin-block: 0 var(--t-spacing-2);
|
|
144
169
|
}
|
|
145
170
|
|
|
146
171
|
.pco-org-avatar__dialog-alert svg {
|
|
147
172
|
fill: var(--t-icon-color-status-error);
|
|
148
|
-
flex-shrink: 0;
|
|
149
|
-
height: var(--t-element-size-md);
|
|
150
|
-
position: relative;
|
|
151
|
-
top: 1px;
|
|
152
|
-
width: var(--t-element-size-md);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.pco-org-avatar__dialog-alert p {
|
|
156
|
-
display: flex;
|
|
157
|
-
flex-direction: column;
|
|
158
|
-
gap: var(--t-spacing-half);
|
|
159
|
-
margin: 0;
|
|
160
173
|
}
|
|
161
174
|
|
|
162
175
|
.pco-org-avatar__dialog-dropzone {
|