@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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),M=require("react-dom"),O=require("@planningcenter/url"),C=require("@planningcenter/tapestry"),w=require("@planningcenter/icons/paths/general"),B=require("@planningcenter/icons/paths/services"),D=require("react-dropzone");function N(a){var o,r,t="";if(typeof a=="string"||typeof a=="number")t+=a;else if(typeof a=="object")if(Array.isArray(a)){var c=a.length;for(o=0;o<c;o++)a[o]&&(r=N(a[o]))&&(t&&(t+=" "),t+=r)}else for(r in a)a[r]&&(t&&(t+=" "),t+=r);return t}function L(){for(var a,o,r=0,t="",c=arguments.length;r<c;r++)(a=arguments[r])&&(o=N(a))&&(t&&(t+=" "),t+=o);return t}function P(){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}const T=a=>a==="dark_mode_avatar"?"dark":"light";function U({avatarUrl:a,organization:o,mode:r,pcoEnv:t,onAvatarUpdate:c}){const[s,m]=i.useState(null),[d,v]=i.useState(a),[l,h]=i.useState(!1),[f,u]=i.useState(""),j=i.useId(),k=i.useRef(null),x=T(r),S=g=>{const[n]=g;n&&m(Object.assign(n,{preview:URL.createObjectURL(n)}))};i.useEffect(()=>{v(a)},[a]),i.useEffect(()=>()=>{s?.preview&&(URL.revokeObjectURL(s.preview),u(""))},[s]);const A=async g=>{const n=await fetch(O.pcoApiUrl("accounts",{env:t}),{method:"PATCH",headers:{"Content-Type":"application/json","X-CSRF-Token":P(),Accept:"application/json"},body:JSON.stringify({data:{attributes:g}})}),p=await n.json();if(!n.ok)throw p;return p},z=async g=>{if(g.preventDefault(),!(!s||l)){h(!0);try{const n=new FileReader,p=await new Promise((b,y)=>{n.onloadend=()=>b(n.result),n.onerror=y,n.readAsDataURL(s)}),_=await A({[r]:p,[`${r}_cache`]:""});v(_.data.attributes[r].url),m(null),c(r,_.data.attributes[r].url),k.current?.close()}catch{u("We were unable to save your avatar.")}finally{h(!1)}}},F=async()=>{if(!l){h(!0);try{await A({[`remove_${r}`]:"1"}),v(""),c(r,""),k.current?.close()}catch{u("We were unable to delete your avatar.")}finally{h(!1)}}},R=()=>{m(null),u("")};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pco-org-avatar",children:[e.jsx("button",{type:"button",commandfor:j,command:"show-modal",className:`pco-org-avatar__button pco-org-avatar__button--${x}`,children:d?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:d,alt:`Church logo for ${o}`}),e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:w.pencil})})})]}):e.jsx("svg",{width:"48",height:"48",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:B.image})})}),e.jsxs("div",{className:"pco-org-avatar__label",children:[x," mode"]})]}),M.createPortal(e.jsx("dialog",{id:j,ref:k,className:"pco-org-avatar__dialog",onClose:R,children:e.jsxs("form",{onSubmit:z,children:[e.jsxs("div",{className:"pco-org-avatar__dialog-header",children:[e.jsxs("h1",{className:"pco-org-avatar__dialog-title",children:["Church logo — ",x," mode"]}),e.jsx("button",{type:"button",commandfor:j,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:w.smallX})})})]}),e.jsxs("div",{className:"pco-org-avatar__dialog-body",children:[f&&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:w.exclamationTriangle})}),e.jsx("p",{children:f})]}),e.jsx(D,{accept:{"image/*":[".jpg",".jpeg",".png"]},multiple:!1,onDropAccepted:S,children:({getRootProps:g,getInputProps:n,isFocused:p,isDragAccept:_,isDragReject:b,isDragActive:y})=>{const q=L("pco-org-avatar__dialog-dropzone",`pco-org-avatar__dialog-dropzone--${x}`,{"pco-org-avatar__dialog-dropzone--image":s||d,"pco-org-avatar__dialog-dropzone--focused":p,"pco-org-avatar__dialog-dropzone--accepted":_,"pco-org-avatar__dialog-dropzone--rejected":y&&b});return e.jsxs("div",{...g({className:q}),children:[e.jsx("input",{...n()}),s?e.jsx("img",{src:s.preview,alt:`Church logo for ${o}`}):d?e.jsx("img",{src:d,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:w.toCloudArrow})}),y&&b?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:[d&&e.jsx(C.Button,{label:"Delete logo",kind:"delete",onClick:F,loading:l,disabled:l,className:"pco-org-avatar__dialog-delete"}),e.jsx(C.Button,{type:"button",label:"Cancel",commandfor:j,command:"close",disabled:l}),e.jsx(C.Button,{type:"submit",label:"Update logo",kind:"primary",loading:l,disabled:!s||l})]})]})}),document.body)]})}function $({avatarUrl:a,darkModeAvatarUrl:o,orgName:r,pcoEnv:t,showDarkModeAvatar:c=!1}){const[s,m]=i.useState(a),[d,v]=i.useState(o),l=(f,u)=>{f==="avatar"?m(u):f==="dark_mode_avatar"&&v(u)},h=d||s;return e.jsxs("div",{className:"pco-org-avatars",children:[e.jsx(U,{avatarUrl:s,organization:r,mode:"avatar",pcoEnv:t,onAvatarUpdate:l}),c&&e.jsx(U,{avatarUrl:h,organization:r,mode:"dark_mode_avatar",pcoEnv:t,onAvatarUpdate:l})]})}exports.OrganizationAvatars=$;
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 t, Fragment as b, jsx as a } from "react/jsx-runtime";
2
- import { useState as g, useId as S, useRef as $, useEffect as j } from "react";
3
- import { createPortal as B } from "react-dom";
4
- import { pcoApiUrl as P } from "@planningcenter/url";
5
- import { Button as N } from "@planningcenter/tapestry";
6
- import { pencil as T, smallX as E, exclamationTriangle as I, toCloudArrow as W } from "@planningcenter/icons/paths/general";
7
- import { image as q } from "@planningcenter/icons/paths/services";
8
- import G from "react-dropzone";
9
- function R(e) {
10
- var n, r, o = "";
11
- if (typeof e == "string" || typeof e == "number") o += e;
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 d = e.length;
14
- for (n = 0; n < d; n++) e[n] && (r = R(e[n])) && (o && (o += " "), o += r);
15
- } else for (r in e) e[r] && (o && (o += " "), o += r);
16
- return o;
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 J() {
19
- for (var e, n, r = 0, o = "", d = arguments.length; r < d; r++) (e = arguments[r]) && (n = R(e)) && (o && (o += " "), o += n);
20
- return o;
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 X() {
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
- const H = (e) => e === "dark_mode_avatar" ? "dark" : "light";
31
- function x({
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: n,
37
+ organization: o,
34
38
  mode: r,
35
- pcoEnv: o,
36
- onAvatarUpdate: d
39
+ pcoEnv: t,
40
+ onAvatarUpdate: s
37
41
  }) {
38
- const [i, m] = g(null), [s, f] = g(e), [c, v] = g(!1), [_, h] = g(""), y = S(), A = $(null), w = H(r), M = (p) => {
39
- const [l] = p;
40
- l && m(
41
- Object.assign(l, {
42
- preview: URL.createObjectURL(l)
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
- j(() => {
50
+ D(() => {
47
51
  f(e);
48
- }, [e]), j(() => () => {
49
- i?.preview && (URL.revokeObjectURL(i.preview), h(""));
50
- }, [i]);
51
- const z = async (p) => {
52
- const l = await fetch(P("accounts", { env: o }), {
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": X(),
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
- }), u = await l.json();
65
- if (!l.ok) throw u;
66
- return u;
67
- }, D = async (p) => {
68
- if (p.preventDefault(), !(!i || c)) {
69
- v(!0);
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 l = new FileReader(), u = await new Promise((C, U) => {
72
- l.onloadend = () => C(l.result), l.onerror = U, l.readAsDataURL(i);
73
- }), k = await z({
74
- [r]: u,
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), d(r, k.data.attributes[r].url), A.current?.close();
81
+ f(k.data.attributes[r].url), m(null), s(r, k.data.attributes[r].url), N.current?.close();
78
82
  } catch {
79
- h("We were unable to save your avatar.");
83
+ b("We were unable to save your avatar.");
80
84
  } finally {
81
- v(!1);
85
+ U(!1);
82
86
  }
83
87
  }
84
- }, F = async () => {
85
- if (!c) {
88
+ }, O = async () => {
89
+ if (!(c || d)) {
86
90
  v(!0);
87
91
  try {
88
- await z({
92
+ await x({
89
93
  [`remove_${r}`]: "1"
90
- }), f(""), d(r, ""), A.current?.close();
94
+ }), f(""), s(r, ""), N.current?.close();
91
95
  } catch {
92
- h("We were unable to delete your avatar.");
96
+ b("We were unable to delete your avatar.");
93
97
  } finally {
94
98
  v(!1);
95
99
  }
96
100
  }
97
- }, L = () => {
98
- m(null), h("");
101
+ }, $ = () => {
102
+ m(null), b("");
99
103
  };
100
- return /* @__PURE__ */ t(b, { children: [
101
- /* @__PURE__ */ t("div", { className: "pco-org-avatar", children: [
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: s ? /* @__PURE__ */ t(b, { children: [
110
- /* @__PURE__ */ a("img", { src: s, alt: `Church logo for ${n}` }),
111
- /* @__PURE__ */ a("span", { children: /* @__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: "16",
115
- height: "16",
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: T })
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: q })
134
+ children: /* @__PURE__ */ a("path", { d: J })
131
135
  }
132
136
  )
133
137
  }
134
138
  ),
135
- /* @__PURE__ */ t("div", { className: "pco-org-avatar__label", children: [
136
- w,
139
+ /* @__PURE__ */ n("div", { className: "pco-org-avatar__label", children: [
140
+ Q(w),
137
141
  " mode"
138
142
  ] })
139
143
  ] }),
140
- B(
144
+ L(
141
145
  /* @__PURE__ */ a(
142
146
  "dialog",
143
147
  {
144
148
  id: y,
145
- ref: A,
149
+ ref: N,
146
150
  className: "pco-org-avatar__dialog",
147
- onClose: L,
148
- children: /* @__PURE__ */ t("form", { onSubmit: D, children: [
149
- /* @__PURE__ */ t("div", { className: "pco-org-avatar__dialog-header", children: [
150
- /* @__PURE__ */ t("h1", { className: "pco-org-avatar__dialog-title", children: [
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: E })
175
+ children: /* @__PURE__ */ a("path", { d: W })
172
176
  }
173
177
  )
174
178
  }
175
179
  )
176
180
  ] }),
177
- /* @__PURE__ */ t("div", { className: "pco-org-avatar__dialog-body", children: [
178
- _ && /* @__PURE__ */ t("div", { role: "alert", className: "pco-org-avatar__dialog-alert", children: [
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: I })
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
- G,
197
+ X,
194
198
  {
195
199
  accept: { "image/*": [".jpg", ".jpeg", ".png"] },
196
200
  multiple: !1,
197
- onDropAccepted: M,
201
+ onDropAccepted: S,
198
202
  children: ({
199
203
  getRootProps: p,
200
- getInputProps: l,
201
- isFocused: u,
204
+ getInputProps: i,
205
+ isFocused: g,
202
206
  isDragAccept: k,
203
- isDragReject: C,
204
- isDragActive: U
207
+ isDragReject: A,
208
+ isDragActive: C
205
209
  }) => {
206
- const O = J(
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": i || s,
211
- "pco-org-avatar__dialog-dropzone--focused": u,
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": U && C
217
+ "pco-org-avatar__dialog-dropzone--rejected": C && A
214
218
  }
215
219
  );
216
- return /* @__PURE__ */ t("div", { ...p({ className: O }), children: [
217
- /* @__PURE__ */ a("input", { ...l() }),
218
- i ? /* @__PURE__ */ a(
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: i.preview,
222
- alt: `Church logo for ${n}`
225
+ src: l.preview,
226
+ alt: `Church logo for ${o}`
223
227
  }
224
- ) : s ? /* @__PURE__ */ a(
228
+ ) : h ? /* @__PURE__ */ a(
225
229
  "img",
226
230
  {
227
- src: s,
228
- alt: `Church logo for ${n}`
231
+ src: h,
232
+ alt: `Church logo for ${o}`
229
233
  }
230
- ) : /* @__PURE__ */ t(b, { children: [
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: W })
242
+ children: /* @__PURE__ */ a("path", { d: G })
239
243
  }
240
244
  ),
241
- U && C ? /* @__PURE__ */ t(b, { children: [
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__ */ t(b, { children: [
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__ */ t("div", { className: "pco-org-avatar__dialog-actions", children: [
255
- s && /* @__PURE__ */ a(
256
- N,
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: F,
261
- loading: c,
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
- N,
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
- N,
281
+ j,
278
282
  {
279
283
  type: "submit",
280
284
  label: "Update logo",
281
285
  kind: "primary",
282
286
  loading: c,
283
- disabled: !i || c
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 oa({
298
+ function ia({
295
299
  avatarUrl: e,
296
- darkModeAvatarUrl: n,
300
+ darkModeAvatarUrl: o,
297
301
  orgName: r,
298
- pcoEnv: o,
299
- showDarkModeAvatar: d = !1
302
+ pcoEnv: t,
303
+ showDarkModeAvatar: s = !1
300
304
  }) {
301
- const [i, m] = g(e), [s, f] = g(
302
- n
303
- ), c = (_, h) => {
304
- _ === "avatar" ? m(h) : _ === "dark_mode_avatar" && f(h);
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__ */ t("div", { className: "pco-org-avatars", children: [
310
+ return /* @__PURE__ */ n("div", { className: "pco-org-avatars", children: [
307
311
  /* @__PURE__ */ a(
308
- x,
312
+ R,
309
313
  {
310
- avatarUrl: i,
314
+ avatarUrl: l,
311
315
  organization: r,
312
316
  mode: "avatar",
313
- pcoEnv: o,
317
+ pcoEnv: t,
314
318
  onAvatarUpdate: c
315
319
  }
316
320
  ),
317
- d && /* @__PURE__ */ a(
318
- x,
321
+ s && /* @__PURE__ */ a(
322
+ R,
319
323
  {
320
- avatarUrl: s || i,
324
+ avatarUrl: h || l,
321
325
  organization: r,
322
326
  mode: "dark_mode_avatar",
323
- pcoEnv: o,
327
+ pcoEnv: t,
324
328
  onAvatarUpdate: c
325
329
  }
326
330
  )
327
331
  ] });
328
332
  }
329
333
  export {
330
- oa as OrganizationAvatars
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: transparent;
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 span {
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 span,
48
- .pco-org-avatar__button:focus-within span {
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?: string;
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?: string;
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
@@ -1 +1,2 @@
1
1
  export declare function getCsrfToken(): string;
2
+ export declare function capitalize(content: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/organization-avatars",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Organization avatar upload components for Planning Center apps",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@1.22.22",