@planningcenter/organization-avatars 1.6.1 → 1.6.3

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