@sps-woodland/growler 8.17.0 → 8.17.2

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/lib/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react"),d=require("@sps-woodland/core"),L=require("@sps-woodland/buttons"),C=require("@sps-woodland/tokens"),I=require("react-dom"),i=require("@spscommerce/utils");function x(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return o.default=r,Object.freeze(o)}const e=x(N);function _(r,o,t){return o in r?Object.defineProperty(r,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[o]=t,r}function b(r,o){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);o&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function E(r){for(var o=1;o<arguments.length;o++){var t=arguments[o]!=null?arguments[o]:{};o%2?b(Object(t),!0).forEach(function(n){_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var T=(r,o,t)=>{for(var n of Object.keys(r)){var s;if(r[n]!==((s=o[n])!==null&&s!==void 0?s:t[n]))return!1}return!0},j=r=>o=>{var t=r.defaultClassName,n=E(E({},r.defaultVariants),o);for(var s in n){var c,a=(c=n[s])!==null&&c!==void 0?c:r.defaultVariants[s];if(a!=null){var l=a;typeof l=="boolean"&&(l=l===!0?"true":"false");var u=r.variantClassNames[s][l];u&&(t+=" "+u)}}for(var[p,m]of r.compoundVariants)T(p,n,r.defaultVariants)&&(t+=" "+m);return t},D=j({defaultClassName:"_1c5fbnk1",variantClassNames:{kind:{activity:"_1c5fbnk2",info:"_1c5fbnk3",progress:"_1c5fbnk4",error:"_1c5fbnk5",success:"_1c5fbnk6",warning:"_1c5fbnk7"},fade:{true:"_1c5fbnk8",false:"_1c5fbnk9"}},defaultVariants:{},compoundVariants:[]}),U="_1c5fbnka",F="_1c5fbnkh",W="_1c5fbnkc",V="_1c5fbnkb",q="_1c5fbnkd",z="_1c5fbnke",H="_1c5fbnkf";const B=Object.freeze({warning:"status-warning",error:"status-error",success:"status-ok",info:"info-circle"});function g({children:r,className:o,imgSrc:t,kind:n="info",onClose:s,removeFromList:c,persist:a,title:l,id:u,...p}){const m=e.useRef(s);e.useEffect(()=>{m.current=s},[s]);const G=C.Tokens.component.growler.duration.visible,M=C.Tokens.component.growler.duration.fadeout,[O,w]=e.useState(!1),{t:P}=e.useContext(d.I18nContext);function K(){return[window.setTimeout(()=>{w(!0)},G),window.setTimeout(()=>{m.current&&m.current(),c&&u&&c(u)},G+M)]}const f=e.useRef([]);function y(){a||(f.current=K())}function S(){for(const A of f.current)window.clearTimeout(A);f.current=[]}function h(){S(),w(!1)}function R(){h(),w(!1),s&&s(),c&&u&&c(u)}return e.useEffect(()=>(y(),()=>{S()}),[]),e.createElement("div",{role:"alert","aria-live":"polite",className:d.cl(D({kind:n,fade:O}),o),onMouseEnter:h,onMouseLeave:y,...p},e.createElement("div",{className:V},t&&e.createElement("img",{src:t,alt:""}),n==="progress"?e.createElement(d.Spinner,null):e.createElement(d.Icon,{icon:B[n],className:W})),e.createElement("div",{className:q},e.createElement("div",{className:z},l&&e.createElement("span",{className:H},l),e.createElement("div",null,r)),e.createElement(L.Button,{kind:"icon",icon:"x",title:P("design-system:growler.dismiss"),className:F,onClick:R})))}d.Metadata.set(g,{name:"Growler",props:{imgSrc:{type:"string"},kind:{type:"GrowlerKind",default:"info"},onClose:{type:"() => void"},persist:{type:"boolean"},title:{type:"string"}}});let J=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((o,t)=>(t&=63,t<36?o+=t.toString(36):t<62?o+=(t-26).toString(36).toUpperCase():t>62?o+="-":o+="_",o),"");const k=e.createContext({growlerList:[],setGrowlerList:()=>{}});function v(r){const[o,t]=e.useState([]),n=a=>{if(!a){console.error("growlers should have an id");return}t(l=>l.filter(u=>a!==u.id))},s=o.map(({G:a,id:l})=>e.cloneElement(a(),{key:l,id:l,removeFromList:n})).filter(a=>d.Metadata.get(a.type).name==="Growler"?!0:(console.error("addGrowler only accepts a function that returns a Growler"),!1)),c=e.createElement("div",{"data-testid":r["data-testid"],"data-portalid":"growler-portal",className:U},s);return e.createElement(k.Provider,{value:{growlerList:o,setGrowlerList:t}},I.createPortal(c,document.body),r.children)}const Q=()=>{const r=e.useContext(k);if(r===void 0)throw new Error("addGrowler must be used within a GrowlerListProvider");return{addGrowler:e.useCallback(t=>{const n=J(),s={G:t,id:n};r.setGrowlerList([s,...r.growlerList])},[r])}},X={description:()=>e.createElement("p",null,"Use Growlers for dynamic messages in response to a user's action. All Growlers have a Primary Message, and may optionally have a Secondary Message as needed. Growlers may also contain Hyperlinks in the Secondary Message."),components:[g,v],examples:{general:{label:"General Usage",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Use the following guidelines to write an effective Growler message."),e.createElement("ul",null,e.createElement("li",null,"Write all messages in sentence case.",e.createElement("ul",null,e.createElement("li",null,"Capitalize the first word of the message."),e.createElement("li",null,"Add punctuation, such as a period, at the end of the message."))),e.createElement("li",null,"Keep messages as succinct as possible while also providing sufficient information to the customer."),e.createElement("li",null,"If you can clearly convey your message in a single statement, use only the Primary Message."),e.createElement("li",null,"If the message requires additional details, such as further information or instructions, use both the Primary and Secondary Messages.")),e.createElement("p",null,"For more examples of effective feedback message writing, refer to ",e.createElement("a",{href:"https://atlassian.design/content/messaging-guidelines",target:"_blank"},"Atlassian's Messaging Guidelines"),"."))},provider:{label:"Growler List Provider",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Applications that use growlers should be wrapped in the",e.createElement("code",null,"GrowlerListProvider")," component. All growlers should be triggered by the addGrowler function from the ",e.createElement("code",null,"useGrowler")," hook"),e.createElement("p",null,"Wrapping your application in the ",e.createElement("code",null,"GrowlerListProvider"),"will allow you to call the ",e.createElement("code",null,"useGrowler")," hook from anywhere within your application. There is no longer a need to pass anything through to the children components."))},error:{label:"Error",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Acceptable message: Document ABC123 has not been sent. Check the form and try sending it again."),e.createElement("p",null,`Unacceptable message: "Can't send your document."`)),examples:{primary:{description:"Primary Message Only",react:i.code`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react"),u=require("@sps-woodland/core"),N=require("@sps-woodland/buttons"),S=require("@sps-woodland/tokens"),L=require("react-dom"),i=require("@spscommerce/utils");function I(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return o.default=r,Object.freeze(o)}const e=I(A);function x(r,o,t){return o in r?Object.defineProperty(r,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[o]=t,r}function C(r,o){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);o&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function b(r){for(var o=1;o<arguments.length;o++){var t=arguments[o]!=null?arguments[o]:{};o%2?C(Object(t),!0).forEach(function(n){x(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):C(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}var T=(r,o,t)=>{for(var n of Object.keys(r)){var s;if(r[n]!==((s=o[n])!==null&&s!==void 0?s:t[n]))return!1}return!0},j=r=>o=>{var t=r.defaultClassName,n=b(b({},r.defaultVariants),o);for(var s in n){var c,a=(c=n[s])!==null&&c!==void 0?c:r.defaultVariants[s];if(a!=null){var l=a;typeof l=="boolean"&&(l=l===!0?"true":"false");var d=r.variantClassNames[s][l];d&&(t+=" "+d)}}for(var[p,m]of r.compoundVariants)T(p,n,r.defaultVariants)&&(t+=" "+m);return t},D=j({defaultClassName:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk1",variantClassNames:{kind:{activity:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk2",info:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk3",progress:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk4",error:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk5",success:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk6",warning:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk7"},fade:{true:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk8",false:"pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk9"}},defaultVariants:{},compoundVariants:[]}),U="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnka",F="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkh",W="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkc",V="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkb",q="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkd",z="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnke",H="pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkf";const k=Object.freeze({warning:"status-warning",error:"status-error",success:"status-ok",info:"info-circle"});function f({children:r,className:o,imgSrc:t,kind:n="info",onClose:s,removeFromList:c,persist:a,title:l,id:d,...p}){const m=e.useRef(s);e.useEffect(()=>{m.current=s},[s]);const _=S.Tokens.component.growler.duration.visible,B=S.Tokens.component.growler.duration.fadeout,[M,w]=e.useState(!1),{t:O}=e.useContext(u.I18nContext);function P(){return[window.setTimeout(()=>{w(!0)},_),window.setTimeout(()=>{m.current&&m.current(),c&&d&&c(d)},_+B)]}const g=e.useRef([]);function G(){a||(g.current=P())}function h(){for(const R of g.current)window.clearTimeout(R);g.current=[]}function y(){h(),w(!1)}function K(){y(),w(!1),s&&s(),c&&d&&c(d)}return e.useEffect(()=>(G(),()=>{h()}),[]),e.createElement("div",{role:"alert","aria-live":"polite",className:u.cl(D({kind:n,fade:M}),o),onMouseEnter:y,onMouseLeave:G,...p},e.createElement("div",{className:V},t&&e.createElement("img",{src:t,alt:""}),n==="progress"?e.createElement(u.Spinner,null):e.createElement(u.Icon,{icon:k[n],className:W})),e.createElement("div",{className:q},e.createElement("div",{className:z},l&&e.createElement("span",{className:H},l),e.createElement("div",null,r)),e.createElement(N.Button,{kind:"icon",icon:"x",title:O("design-system:growler.dismiss"),className:F,onClick:K})))}u.Metadata.set(f,{name:"Growler",props:{imgSrc:{type:"string"},kind:{type:"GrowlerKind",default:"info"},onClose:{type:"() => void"},persist:{type:"boolean"},title:{type:"string"}}});let J=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((o,t)=>(t&=63,t<36?o+=t.toString(36):t<62?o+=(t-26).toString(36).toUpperCase():t>62?o+="-":o+="_",o),"");const v=e.createContext({growlerList:[],setGrowlerList:()=>{}});function E(r){const[o,t]=e.useState([]),n=a=>{if(!a){console.error("growlers should have an id");return}t(l=>l.filter(d=>a!==d.id))},s=o.map(({G:a,id:l})=>e.cloneElement(a(),{key:l,id:l,removeFromList:n})).filter(a=>u.Metadata.get(a.type).name==="Growler"?!0:(console.error("addGrowler only accepts a function that returns a Growler"),!1)),c=e.createElement("div",{"data-testid":r["data-testid"],"data-portalid":"growler-portal",className:U},s);return e.createElement(v.Provider,{value:{growlerList:o,setGrowlerList:t}},L.createPortal(c,document.body),r.children)}const Q=()=>{const r=e.useContext(v);if(r===void 0)throw new Error("addGrowler must be used within a GrowlerListProvider");return{addGrowler:e.useCallback(t=>{const n=J(),s={G:t,id:n};r.setGrowlerList([s,...r.growlerList])},[r])}},X={description:()=>e.createElement("p",null,"Use Growlers for dynamic messages in response to a user's action. All Growlers have a Primary Message, and may optionally have a Secondary Message as needed. Growlers may also contain Hyperlinks in the Secondary Message."),components:[f,E],examples:{general:{label:"General Usage",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Use the following guidelines to write an effective Growler message."),e.createElement("ul",null,e.createElement("li",null,"Write all messages in sentence case.",e.createElement("ul",null,e.createElement("li",null,"Capitalize the first word of the message."),e.createElement("li",null,"Add punctuation, such as a period, at the end of the message."))),e.createElement("li",null,"Keep messages as succinct as possible while also providing sufficient information to the customer."),e.createElement("li",null,"If you can clearly convey your message in a single statement, use only the Primary Message."),e.createElement("li",null,"If the message requires additional details, such as further information or instructions, use both the Primary and Secondary Messages.")),e.createElement("p",null,"For more examples of effective feedback message writing, refer to ",e.createElement("a",{href:"https://atlassian.design/content/messaging-guidelines",target:"_blank"},"Atlassian's Messaging Guidelines"),"."))},provider:{label:"Growler List Provider",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Applications that use growlers should be wrapped in the",e.createElement("code",null,"GrowlerListProvider")," component. All growlers should be triggered by the addGrowler function from the ",e.createElement("code",null,"useGrowler")," hook"),e.createElement("p",null,"Wrapping your application in the ",e.createElement("code",null,"GrowlerListProvider"),"will allow you to call the ",e.createElement("code",null,"useGrowler")," hook from anywhere within your application. There is no longer a need to pass anything through to the children components."))},error:{label:"Error",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Acceptable message: Document ABC123 has not been sent. Check the form and try sending it again."),e.createElement("p",null,`Unacceptable message: "Can't send your document."`)),examples:{primary:{description:"Primary Message Only",react:i.code`
2
2
  import { Growler, useGrowler } from "@sps-woodland/growler";
3
3
  import { SpsButton } from "@spscommerce/ds-react";
4
4
  import { ButtonKind } from "@spscommerce/ds-shared";
@@ -329,4 +329,4 @@
329
329
  </>
330
330
  );
331
331
  }
332
- `}}}}},Y={Growlers:X};exports.Growler=g;exports.GrowlerIcons=B;exports.GrowlerListProvider=v;exports.MANIFEST=Y;exports.useGrowler=Q;
332
+ `}}}}},Y={Growlers:X};exports.Growler=f;exports.GrowlerIcons=k;exports.GrowlerListProvider=E;exports.MANIFEST=Y;exports.useGrowler=Q;
package/lib/index.es.js CHANGED
@@ -1,137 +1,137 @@
1
1
  import * as e from "react";
2
- import { Metadata as b, I18nContext as R, cl as A, Spinner as L, Icon as N } from "@sps-woodland/core";
3
- import { Button as x } from "@sps-woodland/buttons";
4
- import { Tokens as S } from "@sps-woodland/tokens";
5
- import I from "react-dom";
2
+ import { Metadata as C, I18nContext as P, cl as R, Spinner as A, Icon as L } from "@sps-woodland/core";
3
+ import { Button as N } from "@sps-woodland/buttons";
4
+ import { Tokens as h } from "@sps-woodland/tokens";
5
+ import x from "react-dom";
6
6
  import { code as i } from "@spscommerce/utils";
7
- function _(r, o, t) {
8
- return o in r ? Object.defineProperty(r, o, {
9
- value: t,
7
+ function I(r, t, o) {
8
+ return t in r ? Object.defineProperty(r, t, {
9
+ value: o,
10
10
  enumerable: !0,
11
11
  configurable: !0,
12
12
  writable: !0
13
- }) : r[o] = t, r;
13
+ }) : r[t] = o, r;
14
14
  }
15
- function h(r, o) {
16
- var t = Object.keys(r);
15
+ function y(r, t) {
16
+ var o = Object.keys(r);
17
17
  if (Object.getOwnPropertySymbols) {
18
18
  var n = Object.getOwnPropertySymbols(r);
19
- o && (n = n.filter(function(s) {
19
+ t && (n = n.filter(function(s) {
20
20
  return Object.getOwnPropertyDescriptor(r, s).enumerable;
21
- })), t.push.apply(t, n);
21
+ })), o.push.apply(o, n);
22
22
  }
23
- return t;
23
+ return o;
24
24
  }
25
- function C(r) {
26
- for (var o = 1; o < arguments.length; o++) {
27
- var t = arguments[o] != null ? arguments[o] : {};
28
- o % 2 ? h(Object(t), !0).forEach(function(n) {
29
- _(r, n, t[n]);
30
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : h(Object(t)).forEach(function(n) {
31
- Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
25
+ function S(r) {
26
+ for (var t = 1; t < arguments.length; t++) {
27
+ var o = arguments[t] != null ? arguments[t] : {};
28
+ t % 2 ? y(Object(o), !0).forEach(function(n) {
29
+ I(r, n, o[n]);
30
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(o)) : y(Object(o)).forEach(function(n) {
31
+ Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(o, n));
32
32
  });
33
33
  }
34
34
  return r;
35
35
  }
36
- var T = (r, o, t) => {
36
+ var T = (r, t, o) => {
37
37
  for (var n of Object.keys(r)) {
38
38
  var s;
39
- if (r[n] !== ((s = o[n]) !== null && s !== void 0 ? s : t[n]))
39
+ if (r[n] !== ((s = t[n]) !== null && s !== void 0 ? s : o[n]))
40
40
  return !1;
41
41
  }
42
42
  return !0;
43
- }, U = (r) => (o) => {
44
- var t = r.defaultClassName, n = C(C({}, r.defaultVariants), o);
43
+ }, U = (r) => (t) => {
44
+ var o = r.defaultClassName, n = S(S({}, r.defaultVariants), t);
45
45
  for (var s in n) {
46
46
  var c, a = (c = n[s]) !== null && c !== void 0 ? c : r.defaultVariants[s];
47
47
  if (a != null) {
48
48
  var l = a;
49
49
  typeof l == "boolean" && (l = l === !0 ? "true" : "false");
50
- var u = (
50
+ var d = (
51
51
  // @ts-expect-error
52
52
  r.variantClassNames[s][l]
53
53
  );
54
- u && (t += " " + u);
54
+ d && (o += " " + d);
55
55
  }
56
56
  }
57
- for (var [d, m] of r.compoundVariants)
58
- T(d, n, r.defaultVariants) && (t += " " + m);
59
- return t;
60
- }, D = U({ defaultClassName: "_1c5fbnk1", variantClassNames: { kind: { activity: "_1c5fbnk2", info: "_1c5fbnk3", progress: "_1c5fbnk4", error: "_1c5fbnk5", success: "_1c5fbnk6", warning: "_1c5fbnk7" }, fade: { true: "_1c5fbnk8", false: "_1c5fbnk9" } }, defaultVariants: {}, compoundVariants: [] }), j = "_1c5fbnka", F = "_1c5fbnkh", W = "_1c5fbnkc", V = "_1c5fbnkb", z = "_1c5fbnkd", q = "_1c5fbnke", H = "_1c5fbnkf";
57
+ for (var [m, u] of r.compoundVariants)
58
+ T(m, n, r.defaultVariants) && (o += " " + u);
59
+ return o;
60
+ }, D = U({ defaultClassName: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk1", variantClassNames: { kind: { activity: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk2", info: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk3", progress: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk4", error: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk5", success: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk6", warning: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk7" }, fade: { true: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk8", false: "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk9" } }, defaultVariants: {}, compoundVariants: [] }), j = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnka", F = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkh", W = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkc", V = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkb", z = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkd", q = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnke", H = "pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkf";
61
61
  const J = Object.freeze({
62
62
  warning: "status-warning",
63
63
  error: "status-error",
64
64
  success: "status-ok",
65
65
  info: "info-circle"
66
66
  });
67
- function E({
67
+ function k({
68
68
  children: r,
69
- className: o,
70
- imgSrc: t,
69
+ className: t,
70
+ imgSrc: o,
71
71
  kind: n = "info",
72
72
  onClose: s,
73
73
  removeFromList: c,
74
74
  persist: a,
75
75
  title: l,
76
- id: u,
77
- ...d
76
+ id: d,
77
+ ...m
78
78
  }) {
79
- const m = e.useRef(s);
79
+ const u = e.useRef(s);
80
80
  e.useEffect(() => {
81
- m.current = s;
81
+ u.current = s;
82
82
  }, [s]);
83
- const f = S.component.growler.duration.visible, k = S.component.growler.duration.fadeout, [v, p] = e.useState(!1), { t: M } = e.useContext(R);
84
- function K() {
83
+ const g = h.component.growler.duration.visible, v = h.component.growler.duration.fadeout, [E, p] = e.useState(!1), { t: B } = e.useContext(P);
84
+ function M() {
85
85
  return [
86
86
  window.setTimeout(() => {
87
87
  p(!0);
88
- }, f),
88
+ }, g),
89
89
  window.setTimeout(() => {
90
- m.current && m.current(), c && u && c(u);
91
- }, f + k)
90
+ u.current && u.current(), c && d && c(d);
91
+ }, g + v)
92
92
  ];
93
93
  }
94
94
  const w = e.useRef([]);
95
- function g() {
96
- a || (w.current = K());
95
+ function f() {
96
+ a || (w.current = M());
97
97
  }
98
- function G() {
99
- for (const P of w.current)
100
- window.clearTimeout(P);
98
+ function _() {
99
+ for (const O of w.current)
100
+ window.clearTimeout(O);
101
101
  w.current = [];
102
102
  }
103
- function y() {
104
- G(), p(!1);
103
+ function G() {
104
+ _(), p(!1);
105
105
  }
106
- function O() {
107
- y(), p(!1), s && s(), c && u && c(u);
106
+ function K() {
107
+ G(), p(!1), s && s(), c && d && c(d);
108
108
  }
109
- return e.useEffect(() => (g(), () => {
110
- G();
109
+ return e.useEffect(() => (f(), () => {
110
+ _();
111
111
  }), []), /* @__PURE__ */ e.createElement(
112
112
  "div",
113
113
  {
114
114
  role: "alert",
115
115
  "aria-live": "polite",
116
- className: A(D({ kind: n, fade: v }), o),
117
- onMouseEnter: y,
118
- onMouseLeave: g,
119
- ...d
116
+ className: R(D({ kind: n, fade: E }), t),
117
+ onMouseEnter: G,
118
+ onMouseLeave: f,
119
+ ...m
120
120
  },
121
- /* @__PURE__ */ e.createElement("div", { className: V }, t && /* @__PURE__ */ e.createElement("img", { src: t, alt: "" }), n === "progress" ? /* @__PURE__ */ e.createElement(L, null) : /* @__PURE__ */ e.createElement(N, { icon: J[n], className: W })),
121
+ /* @__PURE__ */ e.createElement("div", { className: V }, o && /* @__PURE__ */ e.createElement("img", { src: o, alt: "" }), n === "progress" ? /* @__PURE__ */ e.createElement(A, null) : /* @__PURE__ */ e.createElement(L, { icon: J[n], className: W })),
122
122
  /* @__PURE__ */ e.createElement("div", { className: z }, /* @__PURE__ */ e.createElement("div", { className: q }, l && /* @__PURE__ */ e.createElement("span", { className: H }, l), /* @__PURE__ */ e.createElement("div", null, r)), /* @__PURE__ */ e.createElement(
123
- x,
123
+ N,
124
124
  {
125
125
  kind: "icon",
126
126
  icon: "x",
127
- title: M("design-system:growler.dismiss"),
127
+ title: B("design-system:growler.dismiss"),
128
128
  className: F,
129
- onClick: O
129
+ onClick: K
130
130
  }
131
131
  ))
132
132
  );
133
133
  }
134
- b.set(E, {
134
+ C.set(k, {
135
135
  name: "Growler",
136
136
  props: {
137
137
  imgSrc: { type: "string" },
@@ -141,21 +141,21 @@ b.set(E, {
141
141
  title: { type: "string" }
142
142
  }
143
143
  });
144
- let Q = (r = 21) => crypto.getRandomValues(new Uint8Array(r)).reduce((o, t) => (t &= 63, t < 36 ? o += t.toString(36) : t < 62 ? o += (t - 26).toString(36).toUpperCase() : t > 62 ? o += "-" : o += "_", o), "");
145
- const B = e.createContext({
144
+ let Q = (r = 21) => crypto.getRandomValues(new Uint8Array(r)).reduce((t, o) => (o &= 63, o < 36 ? t += o.toString(36) : o < 62 ? t += (o - 26).toString(36).toUpperCase() : o > 62 ? t += "-" : t += "_", t), "");
145
+ const b = e.createContext({
146
146
  growlerList: [],
147
147
  // setGrowlerList noop until defined
148
148
  setGrowlerList: () => {
149
149
  }
150
150
  });
151
151
  function X(r) {
152
- const [o, t] = e.useState([]), n = (a) => {
152
+ const [t, o] = e.useState([]), n = (a) => {
153
153
  if (!a) {
154
154
  console.error("growlers should have an id");
155
155
  return;
156
156
  }
157
- t((l) => l.filter((u) => a !== u.id));
158
- }, s = o.map(({ G: a, id: l }) => e.cloneElement(a(), { key: l, id: l, removeFromList: n })).filter((a) => b.get(a.type).name === "Growler" ? !0 : (console.error(
157
+ o((l) => l.filter((d) => a !== d.id));
158
+ }, s = t.map(({ G: a, id: l }) => e.cloneElement(a(), { key: l, id: l, removeFromList: n })).filter((a) => C.get(a.type).name === "Growler" ? !0 : (console.error(
159
159
  "addGrowler only accepts a function that returns a Growler"
160
160
  ), !1)), c = /* @__PURE__ */ e.createElement(
161
161
  "div",
@@ -166,16 +166,16 @@ function X(r) {
166
166
  },
167
167
  s
168
168
  );
169
- return /* @__PURE__ */ e.createElement(B.Provider, { value: { growlerList: o, setGrowlerList: t } }, I.createPortal(c, document.body), r.children);
169
+ return /* @__PURE__ */ e.createElement(b.Provider, { value: { growlerList: t, setGrowlerList: o } }, x.createPortal(c, document.body), r.children);
170
170
  }
171
- const oe = () => {
172
- const r = e.useContext(B);
171
+ const te = () => {
172
+ const r = e.useContext(b);
173
173
  if (r === void 0)
174
174
  throw new Error("addGrowler must be used within a GrowlerListProvider");
175
175
  return { addGrowler: e.useCallback(
176
- (t) => {
176
+ (o) => {
177
177
  const n = Q(), s = {
178
- G: t,
178
+ G: o,
179
179
  id: n
180
180
  };
181
181
  r.setGrowlerList([s, ...r.growlerList]);
@@ -184,7 +184,7 @@ const oe = () => {
184
184
  ) };
185
185
  }, Y = {
186
186
  description: () => /* @__PURE__ */ e.createElement("p", null, "Use Growlers for dynamic messages in response to a user's action. All Growlers have a Primary Message, and may optionally have a Secondary Message as needed. Growlers may also contain Hyperlinks in the Secondary Message."),
187
- components: [E, X],
187
+ components: [k, X],
188
188
  examples: {
189
189
  general: {
190
190
  label: "General Usage",
@@ -600,9 +600,9 @@ const oe = () => {
600
600
  Growlers: Y
601
601
  };
602
602
  export {
603
- E as Growler,
603
+ k as Growler,
604
604
  J as GrowlerIcons,
605
605
  X as GrowlerListProvider,
606
606
  ne as MANIFEST,
607
- oe as useGrowler
607
+ te as useGrowler
608
608
  };
package/lib/style.css CHANGED
@@ -1 +1 @@
1
- @keyframes _1c5fbnk0{0%{opacity:1}to{opacity:0}}._1c5fbnk1{border-radius:.25rem;box-shadow:0 0 .3125rem #00000040;display:flex;margin-bottom:1rem;overflow:hidden;width:25rem}._1c5fbnk2{background:#e9e9ea;border:.0625rem oklch(56.48% .008 219.62) solid}._1c5fbnk3{background:#027db8;border:.0625rem oklch(56.21% .128 239.83) solid}._1c5fbnk4{background:#91467f;border:.0625rem oklch(50.83% .125 337.21) solid}._1c5fbnk5{background:#de012e;border:.0625rem oklch(56.83% .229 22.94) solid}._1c5fbnk6{background:#0b8940;border:.0625rem oklch(55.21% .148 150.27) solid}._1c5fbnk7{background:#e77609;border:.0625rem oklch(68.35% .17 53.59) solid}._1c5fbnk8{animation-name:_1c5fbnk0;animation-duration:2s}._1c5fbnk9{opacity:1}._1c5fbnka{display:flex;flex-direction:column;position:fixed;right:1.875rem;top:5.625rem;width:25rem}._1c5fbnkb{align-items:center;display:flex;flex-grow:0;flex-shrink:0;flex-basis:4.375rem;justify-content:center}._1c5fbnkc{color:#fff;font-size:1.875rem}._1c5fbnkd{background-color:#fff;padding:1rem 2.625rem 1rem 1rem;position:relative;display:flex;flex-grow:1}._1c5fbnke{flex-grow:1;font-size:.75rem;line-height:1.25rem}._1c5fbnkf{font-weight:600}._1c5fbnkg{color:#4b5356;overflow-wrap:break-word;width:16.5rem}._1c5fbnkh{position:absolute;right:.5rem;top:.5rem}
1
+ @keyframes pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk0{0%{opacity:1}to{opacity:0}}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk1{border-radius:.25rem;box-shadow:0 0 .3125rem #00000040;display:flex;margin-bottom:1rem;overflow:hidden;width:25rem}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk2{background:#e9e9ea;border:.0625rem oklch(56.48% .008 219.62) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk3{background:#027db8;border:.0625rem oklch(56.21% .128 239.83) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk4{background:#91467f;border:.0625rem oklch(50.83% .125 337.21) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk5{background:#de012e;border:.0625rem oklch(56.83% .229 22.94) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk6{background:#0b8940;border:.0625rem oklch(55.21% .148 150.27) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk7{background:#e77609;border:.0625rem oklch(68.35% .17 53.59) solid}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk8{animation-name:pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk0;animation-duration:2s}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnk9{opacity:1}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnka{display:flex;flex-direction:column;position:fixed;right:1.875rem;top:5.625rem;width:25rem}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkb{align-items:center;display:flex;flex-grow:0;flex-shrink:0;flex-basis:4.375rem;justify-content:center}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkc{color:#fff;font-size:1.875rem}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkd{background-color:#fff;padding:1rem 2.625rem 1rem 1rem;position:relative;display:flex;flex-grow:1}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnke{flex-grow:1;font-size:.75rem;line-height:1.25rem}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkf{font-weight:600}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkg{color:#4b5356;overflow-wrap:break-word;width:16.5rem}.pkg_sps-woodland_growler__version_8_17_2__hash_1c5fbnkh{position:absolute;right:.5rem;top:.5rem}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sps-woodland/growler",
3
3
  "description": "SPS Woodland Design System growler component and hook",
4
- "version": "8.17.0",
4
+ "version": "8.17.2",
5
5
  "author": "SPS Commerce",
6
6
  "license": "UNLICENSED",
7
7
  "repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/growler",
@@ -33,9 +33,9 @@
33
33
  "@spscommerce/utils": "^7.0.0",
34
34
  "react": "^16.9.0",
35
35
  "react-dom": "^16.9.0",
36
- "@sps-woodland/buttons": "8.17.0",
37
- "@sps-woodland/core": "8.17.0",
38
- "@sps-woodland/tokens": "8.17.0"
36
+ "@sps-woodland/buttons": "8.17.2",
37
+ "@sps-woodland/core": "8.17.2",
38
+ "@sps-woodland/tokens": "8.17.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@spscommerce/utils": "^7.0.0",
@@ -43,9 +43,9 @@
43
43
  "@vanilla-extract/recipes": "^0.2.5",
44
44
  "react": "^16.9.0",
45
45
  "react-dom": "^16.9.0",
46
- "@sps-woodland/buttons": "8.17.0",
47
- "@sps-woodland/core": "8.17.0",
48
- "@sps-woodland/tokens": "8.17.0"
46
+ "@sps-woodland/buttons": "8.17.2",
47
+ "@sps-woodland/core": "8.17.2",
48
+ "@sps-woodland/tokens": "8.17.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "pnpm run build:js && pnpm run build:types",
package/vite.config.mjs CHANGED
@@ -1,11 +1,20 @@
1
1
  import path from "path";
2
2
  import { vanillaExtractPlugin } from "@vanilla-extract/vite-plugin";
3
3
  import { defineConfig } from "vite";
4
-
4
+ import { getVanillaExtractPluginProps } from "../../../scripts/vanilla-extract-plugin-props.mjs";
5
5
  import pkg from "./package.json";
6
6
 
7
+ const packageVersion = process.env.PREDICTED_VERSION || pkg.version;
8
+
7
9
  export default defineConfig({
8
- plugins: [vanillaExtractPlugin()],
10
+ plugins: [
11
+ vanillaExtractPlugin(
12
+ getVanillaExtractPluginProps({
13
+ packageName: pkg.name,
14
+ packageVersion,
15
+ })
16
+ ),
17
+ ],
9
18
  build: {
10
19
  lib: {
11
20
  entry: path.resolve(__dirname, "src/index.ts"),