@sps-woodland/buttons 8.21.0 → 8.21.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.es.js → index.js} +1 -1
- package/lib/index.umd.cjs +426 -0
- package/lib/style.css +1 -1
- package/package.json +10 -10
- package/vite.config.mjs +2 -2
- package/lib/index.cjs.js +0 -426
@@ -829,7 +829,7 @@ var Et = (e, t, r) => {
|
|
829
829
|
for (var [v, g] of e.compoundVariants)
|
830
830
|
Et(v, o, e.defaultVariants) && (r += " " + g);
|
831
831
|
return r;
|
832
|
-
}, $t = ne({ defaultClassName: "pkg_sps-
|
832
|
+
}, $t = ne({ defaultClassName: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy0", variantClassNames: { disabled: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy1", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy2" }, kind: { default: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy3", link: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy4", confirm: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy5", delete: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy6", key: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy7", icon: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy8" }, spinning: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy9", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxya" } }, defaultVariants: { disabled: !1, kind: "default", spinning: !1 }, compoundVariants: [[{ kind: "icon", spinning: !0 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyb"], [{ kind: "default", spinning: !0 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyc"], [{ kind: "confirm", spinning: !0 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyd"], [{ kind: "delete", spinning: !0 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxye"], [{ kind: "key", spinning: !0 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyf"], [{ disabled: !0, spinning: !1 }, "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyg"]] }), Pt = ne({ defaultClassName: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyh", variantClassNames: { disabled: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyi", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyj" }, kind: { icon: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyk", default: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyl", delete: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxym", key: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyn", confirm: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyo", link: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyp" }, spinning: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyq", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyr" } }, defaultVariants: { disabled: !1, kind: "default", spinning: !1 }, compoundVariants: [] }), xt = "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy11", St = ne({ defaultClassName: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy12", variantClassNames: { spinning: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy13", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy14" } }, defaultVariants: { spinning: !1 }, compoundVariants: [] }), Nt = ne({ defaultClassName: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxys", variantClassNames: { spinning: { true: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyt", false: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyu" }, kind: { icon: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyv", default: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyw", delete: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyx", key: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyy", confirm: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyz", link: "pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy10" } }, defaultVariants: { spinning: !1 }, compoundVariants: [] });
|
833
833
|
function Dt({
|
834
834
|
as: e,
|
835
835
|
onClick: t,
|
@@ -0,0 +1,426 @@
|
|
1
|
+
(function(N,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("react"),require("@sps-woodland/core"),require("@react-aria/focus"),require("@spscommerce/utils")):typeof define=="function"&&define.amd?define(["exports","react","@sps-woodland/core","@react-aria/focus","@spscommerce/utils"],v):(N=typeof globalThis<"u"?globalThis:N||self,v(N.Buttons={},N.React,N.core,N.focus,N.utils))})(this,function(N,v,V,me,y){"use strict";function Ae(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=Ae(v),_e=typeof document<"u"?v.useLayoutEffect:()=>{};function W(e){const t=v.useRef(null);return _e(()=>{t.current=e},[e]),v.useCallback((...r)=>{const o=t.current;return o==null?void 0:o(...r)},[])}let be=new Map;function Le(e,t){if(e===t)return e;let r=be.get(e);if(r)return r.forEach(a=>a(t)),t;let o=be.get(t);return o?(o.forEach(a=>a(e)),e):t}function ge(...e){return(...t)=>{for(let r of e)typeof r=="function"&&r(...t)}}const A=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},oe=e=>e&&"window"in e&&e.window===e?e:A(e).defaultView||window;function ve(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=ve(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Me(){for(var e,t,r=0,o="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=ve(e))&&(o&&(o+=" "),o+=t);return o}function j(...e){let t={...e[0]};for(let r=1;r<e.length;r++){let o=e[r];for(let a in o){let d=t[a],u=o[a];typeof d=="function"&&typeof u=="function"&&a[0]==="o"&&a[1]==="n"&&a.charCodeAt(2)>=65&&a.charCodeAt(2)<=90?t[a]=ge(d,u):(a==="className"||a==="UNSAFE_className")&&typeof d=="string"&&typeof u=="string"?t[a]=Me(d,u):a==="id"&&d&&u?t.id=Le(d,u):t[a]=u!==void 0?u:d}}return t}const Fe=new Set(["id"]),Ue=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),He=new Set(["href","hrefLang","target","rel","download","ping","referrerPolicy"]),Ge=/^(data-.*)$/;function Ve(e,t={}){let{labelable:r,isLink:o,propNames:a}=t,d={};for(const u in e)Object.prototype.hasOwnProperty.call(e,u)&&(Fe.has(u)||r&&Ue.has(u)||o&&He.has(u)||a!=null&&a.has(u)||Ge.test(u))&&(d[u]=e[u]);return d}function Y(e){if(We())e.focus({preventScroll:!0});else{let t=je(e);e.focus(),Ye(t)}}let X=null;function We(){if(X==null){X=!1;try{document.createElement("div").focus({get preventScroll(){return X=!0,!0}})}catch{}}return X}function je(e){let t=e.parentNode,r=[],o=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&r.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return o instanceof HTMLElement&&r.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),r}function Ye(e){for(let{element:t,scrollTop:r,scrollLeft:o}of e)t.scrollTop=r,t.scrollLeft=o}function q(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(r=>e.test(r.brand)))||e.test(window.navigator.userAgent)}function re(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function L(e){let t=null;return()=>(t==null&&(t=e()),t)}const z=L(function(){return re(/^Mac/i)}),Re=L(function(){return re(/^iPhone/i)}),he=L(function(){return re(/^iPad/i)||z()&&navigator.maxTouchPoints>1}),ye=L(function(){return Re()||he()}),Xe=L(function(){return q(/AppleWebKit/i)&&!qe()}),qe=L(function(){return q(/Chrome/i)}),ke=L(function(){return q(/Android/i)}),ze=L(function(){return q(/Firefox/i)});function R(e,t,r=!0){var o,a;let{metaKey:d,ctrlKey:u,altKey:p,shiftKey:m}=t;ze()&&(!((a=window.event)===null||a===void 0||(o=a.type)===null||o===void 0)&&o.startsWith("key"))&&e.target==="_blank"&&(z()?d=!0:u=!0);let h=Xe()&&z()&&!he()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:d,ctrlKey:u,altKey:p,shiftKey:m}):new MouseEvent("click",{metaKey:d,ctrlKey:u,altKey:p,shiftKey:m,bubbles:!0,cancelable:!0});R.isOpening=r,Y(e),e.dispatchEvent(h),R.isOpening=!1}R.isOpening=!1;let F=new Map,se=new Set;function we(){if(typeof window>"u")return;function e(o){return"propertyName"in o}let t=o=>{if(!e(o)||!o.target)return;let a=F.get(o.target);a||(a=new Set,F.set(o.target,a),o.target.addEventListener("transitioncancel",r,{once:!0})),a.add(o.propertyName)},r=o=>{if(!e(o)||!o.target)return;let a=F.get(o.target);if(a&&(a.delete(o.propertyName),a.size===0&&(o.target.removeEventListener("transitioncancel",r),F.delete(o.target)),F.size===0)){for(let d of se)d();se.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",r)}typeof document<"u"&&(document.readyState!=="loading"?we():document.addEventListener("DOMContentLoaded",we));function Je(e){requestAnimationFrame(()=>{F.size===0?e():se.add(e)})}function Qe(){let e=v.useRef(new Map),t=v.useCallback((a,d,u,p)=>{let m=p!=null&&p.once?(...h)=>{e.current.delete(u),u(...h)}:u;e.current.set(u,{type:d,eventTarget:a,fn:m,options:p}),a.addEventListener(d,u,p)},[]),r=v.useCallback((a,d,u,p)=>{var m;let h=((m=e.current.get(u))===null||m===void 0?void 0:m.fn)||u;a.removeEventListener(d,h,p),e.current.delete(u)},[]),o=v.useCallback(()=>{e.current.forEach((a,d)=>{r(a.eventTarget,a.type,d,a.options)})},[r]);return v.useEffect(()=>o,[o]),{addGlobalListener:t,removeGlobalListener:r,removeAllGlobalListeners:o}}function Ze(e,t){_e(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function Te(e){return e.mozInputSource===0&&e.isTrusted?!0:ke()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function et(e){return!ke()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}let U="default",ae="",J=new WeakMap;function Ee(e){if(ye()){if(U==="default"){const t=A(e);ae=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}U="disabled"}else(e instanceof HTMLElement||e instanceof SVGElement)&&(J.set(e,e.style.userSelect),e.style.userSelect="none")}function Q(e){if(ye()){if(U!=="disabled")return;U="restoring",setTimeout(()=>{Je(()=>{if(U==="restoring"){const t=A(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=ae||""),ae="",U="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&J.has(e)){let t=J.get(e);e.style.userSelect==="none"&&(e.style.userSelect=t),e.getAttribute("style")===""&&e.removeAttribute("style"),J.delete(e)}}const Be=v.createContext({register:()=>{}});Be.displayName="PressResponderContext";function tt(e,t){return t.get?t.get.call(e):t.value}function $e(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function nt(e,t){var r=$e(e,t,"get");return tt(e,r)}function ot(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function rt(e,t,r){ot(e,t),t.set(e,r)}function st(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function Pe(e,t,r){var o=$e(e,t,"set");return st(e,o,r),r}function at(e){let t=v.useContext(Be);if(t){let{register:r,...o}=t;e=j(o,e),r()}return Ze(t,e.ref),e}var Z=new WeakMap;class ee{continuePropagation(){Pe(this,Z,!1)}get shouldStopPropagation(){return nt(this,Z)}constructor(t,r,o,a){rt(this,Z,{writable:!0,value:void 0}),Pe(this,Z,!0);var d;let u=(d=a==null?void 0:a.target)!==null&&d!==void 0?d:o.currentTarget;const p=u==null?void 0:u.getBoundingClientRect();let m,h=0,b,P=null;o.clientX!=null&&o.clientY!=null&&(b=o.clientX,P=o.clientY),p&&(b!=null&&P!=null?(m=b-p.left,h=P-p.top):(m=p.width/2,h=p.height/2)),this.type=t,this.pointerType=r,this.target=o.currentTarget,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.x=m,this.y=h}}const xe=Symbol("linkClicked");function it(e){let{onPress:t,onPressChange:r,onPressStart:o,onPressEnd:a,onPressUp:d,isDisabled:u,isPressed:p,preventFocusOnPress:m,shouldCancelOnPointerExit:h,allowTextSelectionOnPress:b,ref:P,...S}=at(e),[_,x]=v.useState(!1),T=v.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,ignoreClickAfterPress:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null}),{addGlobalListener:E,removeAllGlobalListeners:O}=Qe(),$=W((n,f)=>{let B=T.current;if(u||B.didFirePressStart)return!1;let l=!0;if(B.isTriggeringEvent=!0,o){let k=new ee("pressstart",f,n);o(k),l=k.shouldStopPropagation}return r&&r(!0),B.isTriggeringEvent=!1,B.didFirePressStart=!0,x(!0),l}),w=W((n,f,B=!0)=>{let l=T.current;if(!l.didFirePressStart)return!1;l.ignoreClickAfterPress=!0,l.didFirePressStart=!1,l.isTriggeringEvent=!0;let k=!0;if(a){let s=new ee("pressend",f,n);a(s),k=s.shouldStopPropagation}if(r&&r(!1),x(!1),t&&B&&!u){let s=new ee("press",f,n);t(s),k&&(k=s.shouldStopPropagation)}return l.isTriggeringEvent=!1,k}),C=W((n,f)=>{let B=T.current;if(u)return!1;if(d){B.isTriggeringEvent=!0;let l=new ee("pressup",f,n);return d(l),B.isTriggeringEvent=!1,l.shouldStopPropagation}return!0}),D=W(n=>{let f=T.current;f.isPressed&&f.target&&(f.isOverTarget&&f.pointerType!=null&&w(K(f.target,n),f.pointerType,!1),f.isPressed=!1,f.isOverTarget=!1,f.activePointerId=null,f.pointerType=null,O(),b||Q(f.target))}),G=W(n=>{h&&D(n)}),fe=v.useMemo(()=>{let n=T.current,f={onKeyDown(l){if(le(l.nativeEvent,l.currentTarget)&&l.currentTarget.contains(l.target)){var k;Oe(l.target,l.key)&&l.preventDefault();let s=!0;if(!n.isPressed&&!l.repeat){n.target=l.currentTarget,n.isPressed=!0,s=$(l,"keyboard");let g=l.currentTarget,i=I=>{le(I,g)&&!I.repeat&&g.contains(I.target)&&n.target&&C(K(n.target,I),"keyboard")};E(A(l.currentTarget),"keyup",ge(i,B),!0)}s&&l.stopPropagation(),l.metaKey&&z()&&((k=n.metaKeyEvents)===null||k===void 0||k.set(l.key,l.nativeEvent))}else l.key==="Meta"&&(n.metaKeyEvents=new Map)},onClick(l){if(!(l&&!l.currentTarget.contains(l.target))&&l&&l.button===0&&!n.isTriggeringEvent&&!R.isOpening){let k=!0;if(u&&l.preventDefault(),!n.ignoreClickAfterPress&&!n.ignoreEmulatedMouseEvents&&!n.isPressed&&(n.pointerType==="virtual"||Te(l.nativeEvent))){!u&&!m&&Y(l.currentTarget);let s=$(l,"virtual"),g=C(l,"virtual"),i=w(l,"virtual");k=s&&g&&i}n.ignoreEmulatedMouseEvents=!1,n.ignoreClickAfterPress=!1,k&&l.stopPropagation()}}},B=l=>{var k;if(n.isPressed&&n.target&&le(l,n.target)){var s;Oe(l.target,l.key)&&l.preventDefault();let i=l.target;w(K(n.target,l),"keyboard",n.target.contains(i)),O(),l.key!=="Enter"&&ie(n.target)&&n.target.contains(i)&&!l[xe]&&(l[xe]=!0,R(n.target,l,!1)),n.isPressed=!1,(s=n.metaKeyEvents)===null||s===void 0||s.delete(l.key)}else if(l.key==="Meta"&&(!((k=n.metaKeyEvents)===null||k===void 0)&&k.size)){var g;let i=n.metaKeyEvents;n.metaKeyEvents=void 0;for(let I of i.values())(g=n.target)===null||g===void 0||g.dispatchEvent(new KeyboardEvent("keyup",I))}};if(typeof PointerEvent<"u"){f.onPointerDown=i=>{if(i.button!==0||!i.currentTarget.contains(i.target))return;if(et(i.nativeEvent)){n.pointerType="virtual";return}ue(i.currentTarget)&&i.preventDefault(),n.pointerType=i.pointerType;let I=!0;n.isPressed||(n.isPressed=!0,n.isOverTarget=!0,n.activePointerId=i.pointerId,n.target=i.currentTarget,!u&&!m&&Y(i.currentTarget),b||Ee(n.target),I=$(i,n.pointerType),E(A(i.currentTarget),"pointermove",l,!1),E(A(i.currentTarget),"pointerup",k,!1),E(A(i.currentTarget),"pointercancel",g,!1)),I&&i.stopPropagation()},f.onMouseDown=i=>{i.currentTarget.contains(i.target)&&i.button===0&&(ue(i.currentTarget)&&i.preventDefault(),i.stopPropagation())},f.onPointerUp=i=>{!i.currentTarget.contains(i.target)||n.pointerType==="virtual"||i.button===0&&H(i,i.currentTarget)&&C(i,n.pointerType||i.pointerType)};let l=i=>{i.pointerId===n.activePointerId&&(n.target&&H(i,n.target)?!n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!0,$(K(n.target,i),n.pointerType)):n.target&&n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!1,w(K(n.target,i),n.pointerType,!1),G(i)))},k=i=>{i.pointerId===n.activePointerId&&n.isPressed&&i.button===0&&n.target&&(H(i,n.target)&&n.pointerType!=null?w(K(n.target,i),n.pointerType):n.isOverTarget&&n.pointerType!=null&&w(K(n.target,i),n.pointerType,!1),n.isPressed=!1,n.isOverTarget=!1,n.activePointerId=null,n.pointerType=null,O(),b||Q(n.target),"ontouchend"in n.target&&i.pointerType!=="mouse"&&E(n.target,"touchend",s,{once:!0}))},s=i=>{Ne(i.target)&&i.preventDefault()},g=i=>{D(i)};f.onDragStart=i=>{i.currentTarget.contains(i.target)&&D(i)}}else{f.onMouseDown=s=>{if(s.button!==0||!s.currentTarget.contains(s.target))return;if(ue(s.currentTarget)&&s.preventDefault(),n.ignoreEmulatedMouseEvents){s.stopPropagation();return}n.isPressed=!0,n.isOverTarget=!0,n.target=s.currentTarget,n.pointerType=Te(s.nativeEvent)?"virtual":"mouse",!u&&!m&&Y(s.currentTarget),$(s,n.pointerType)&&s.stopPropagation(),E(A(s.currentTarget),"mouseup",l,!1)},f.onMouseEnter=s=>{if(!s.currentTarget.contains(s.target))return;let g=!0;n.isPressed&&!n.ignoreEmulatedMouseEvents&&n.pointerType!=null&&(n.isOverTarget=!0,g=$(s,n.pointerType)),g&&s.stopPropagation()},f.onMouseLeave=s=>{if(!s.currentTarget.contains(s.target))return;let g=!0;n.isPressed&&!n.ignoreEmulatedMouseEvents&&n.pointerType!=null&&(n.isOverTarget=!1,g=w(s,n.pointerType,!1),G(s)),g&&s.stopPropagation()},f.onMouseUp=s=>{s.currentTarget.contains(s.target)&&!n.ignoreEmulatedMouseEvents&&s.button===0&&C(s,n.pointerType||"mouse")};let l=s=>{if(s.button===0){if(n.isPressed=!1,O(),n.ignoreEmulatedMouseEvents){n.ignoreEmulatedMouseEvents=!1;return}n.target&&H(s,n.target)&&n.pointerType!=null?w(K(n.target,s),n.pointerType):n.target&&n.isOverTarget&&n.pointerType!=null&&w(K(n.target,s),n.pointerType,!1),n.isOverTarget=!1}};f.onTouchStart=s=>{if(!s.currentTarget.contains(s.target))return;let g=lt(s.nativeEvent);if(!g)return;n.activePointerId=g.identifier,n.ignoreEmulatedMouseEvents=!0,n.isOverTarget=!0,n.isPressed=!0,n.target=s.currentTarget,n.pointerType="touch",!u&&!m&&Y(s.currentTarget),b||Ee(n.target),$(M(n.target,s),n.pointerType)&&s.stopPropagation(),E(oe(s.currentTarget),"scroll",k,!0)},f.onTouchMove=s=>{if(!s.currentTarget.contains(s.target))return;if(!n.isPressed){s.stopPropagation();return}let g=Se(s.nativeEvent,n.activePointerId),i=!0;g&&H(g,s.currentTarget)?!n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!0,i=$(M(n.target,s),n.pointerType)):n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!1,i=w(M(n.target,s),n.pointerType,!1),G(M(n.target,s))),i&&s.stopPropagation()},f.onTouchEnd=s=>{if(!s.currentTarget.contains(s.target))return;if(!n.isPressed){s.stopPropagation();return}let g=Se(s.nativeEvent,n.activePointerId),i=!0;g&&H(g,s.currentTarget)&&n.pointerType!=null?(C(M(n.target,s),n.pointerType),i=w(M(n.target,s),n.pointerType)):n.isOverTarget&&n.pointerType!=null&&(i=w(M(n.target,s),n.pointerType,!1)),i&&s.stopPropagation(),n.isPressed=!1,n.activePointerId=null,n.isOverTarget=!1,n.ignoreEmulatedMouseEvents=!0,n.target&&!b&&Q(n.target),O()},f.onTouchCancel=s=>{s.currentTarget.contains(s.target)&&(s.stopPropagation(),n.isPressed&&D(M(n.target,s)))};let k=s=>{n.isPressed&&s.target.contains(n.target)&&D({currentTarget:n.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})};f.onDragStart=s=>{s.currentTarget.contains(s.target)&&D(s)}}return f},[E,u,m,O,b,D,G,w,$,C]);return v.useEffect(()=>()=>{var n;b||Q((n=T.current.target)!==null&&n!==void 0?n:void 0)},[b]),{isPressed:p||_,pressProps:j(S,fe)}}function ie(e){return e.tagName==="A"&&e.hasAttribute("href")}function le(e,t){const{key:r,code:o}=e,a=t,d=a.getAttribute("role");return(r==="Enter"||r===" "||r==="Spacebar"||o==="Space")&&!(a instanceof oe(a).HTMLInputElement&&!De(a,r)||a instanceof oe(a).HTMLTextAreaElement||a.isContentEditable)&&!((d==="link"||!d&&ie(a))&&r!=="Enter")}function lt(e){const{targetTouches:t}=e;return t.length>0?t[0]:null}function Se(e,t){const r=e.changedTouches;for(let o=0;o<r.length;o++){const a=r[o];if(a.identifier===t)return a}return null}function M(e,t){let r=0,o=0;return t.targetTouches&&t.targetTouches.length===1&&(r=t.targetTouches[0].clientX,o=t.targetTouches[0].clientY),{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:r,clientY:o}}function K(e,t){let r=t.clientX,o=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:r,clientY:o}}function ut(e){let t=0,r=0;return e.width!==void 0?t=e.width/2:e.radiusX!==void 0&&(t=e.radiusX),e.height!==void 0?r=e.height/2:e.radiusY!==void 0&&(r=e.radiusY),{top:e.clientY-r,right:e.clientX+t,bottom:e.clientY+r,left:e.clientX-t}}function ct(e,t){return!(e.left>t.right||t.left>e.right||e.top>t.bottom||t.top>e.bottom)}function H(e,t){let r=t.getBoundingClientRect(),o=ut(e);return ct(r,o)}function ue(e){return!(e instanceof HTMLElement)||!e.hasAttribute("draggable")}function Ne(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!ie(e)}function Oe(e,t){return e instanceof HTMLInputElement?!De(e,t):Ne(e)}const dt=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function De(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":dt.has(e.type)}let te=!1,ce=0;function de(){te=!0,setTimeout(()=>{te=!1},50)}function Ce(e){e.pointerType==="touch"&&de()}function pt(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Ce):document.addEventListener("touchend",de),ce++,()=>{ce--,!(ce>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Ce):document.removeEventListener("touchend",de))}}function ft(e){let{onHoverStart:t,onHoverChange:r,onHoverEnd:o,isDisabled:a}=e,[d,u]=v.useState(!1),p=v.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;v.useEffect(pt,[]);let{hoverProps:m,triggerHoverEnd:h}=v.useMemo(()=>{let b=(_,x)=>{if(p.pointerType=x,a||x==="touch"||p.isHovered||!_.currentTarget.contains(_.target))return;p.isHovered=!0;let T=_.currentTarget;p.target=T,t&&t({type:"hoverstart",target:T,pointerType:x}),r&&r(!0),u(!0)},P=(_,x)=>{if(p.pointerType="",p.target=null,x==="touch"||!p.isHovered)return;p.isHovered=!1;let T=_.currentTarget;o&&o({type:"hoverend",target:T,pointerType:x}),r&&r(!1),u(!1)},S={};return typeof PointerEvent<"u"?(S.onPointerEnter=_=>{te&&_.pointerType==="mouse"||b(_,_.pointerType)},S.onPointerLeave=_=>{!a&&_.currentTarget.contains(_.target)&&P(_,_.pointerType)}):(S.onTouchStart=()=>{p.ignoreEmulatedMouseEvents=!0},S.onMouseEnter=_=>{!p.ignoreEmulatedMouseEvents&&!te&&b(_,"mouse"),p.ignoreEmulatedMouseEvents=!1},S.onMouseLeave=_=>{!a&&_.currentTarget.contains(_.target)&&P(_,"mouse")}),{hoverProps:S,triggerHoverEnd:P}},[t,r,o,a,p]);return v.useEffect(()=>{a&&h({currentTarget:p.target},p.pointerType)},[a]),{hoverProps:m,isHovered:d}}function mt(e,t){let{elementType:r="button",isDisabled:o,onPress:a,onPressStart:d,onPressEnd:u,onPressUp:p,onPressChange:m,preventFocusOnPress:h,allowFocusWhenDisabled:b,onClick:P,href:S,target:_,rel:x,type:T="button"}=e,E;r==="button"?E={type:T,disabled:o}:E={role:"button",tabIndex:o?void 0:0,href:r==="a"&&o?void 0:S,target:r==="a"?_:void 0,type:r==="input"?T:void 0,disabled:r==="input"?o:void 0,"aria-disabled":!o||r==="input"?void 0:o,rel:r==="a"?x:void 0};let{pressProps:O,isPressed:$}=it({onPressStart:d,onPressEnd:u,onPressChange:m,onPress:a,onPressUp:p,isDisabled:o,preventFocusOnPress:h,ref:t}),{focusableProps:w}=me.useFocusable(e,t);b&&(w.tabIndex=o?-1:w.tabIndex);let C=j(w,O,Ve(e,{labelable:!0}));return{isPressed:$,buttonProps:j(E,C,{"aria-haspopup":e["aria-haspopup"],"aria-expanded":e["aria-expanded"],"aria-controls":e["aria-controls"],"aria-pressed":e["aria-pressed"],onClick:D=>{P&&(P(D),console.warn("onClick is deprecated, please use onPress"))}})}}function _t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ke(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,o)}return r}function Ie(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ke(Object(r),!0).forEach(function(o){_t(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ke(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}var bt=(e,t,r)=>{for(var o of Object.keys(e)){var a;if(e[o]!==((a=t[o])!==null&&a!==void 0?a:r[o]))return!1}return!0},ne=e=>t=>{var r=e.defaultClassName,o=Ie(Ie({},e.defaultVariants),t);for(var a in o){var d,u=(d=o[a])!==null&&d!==void 0?d:e.defaultVariants[a];if(u!=null){var p=u;typeof p=="boolean"&&(p=p===!0?"true":"false");var m=e.variantClassNames[a][p];m&&(r+=" "+m)}}for(var[h,b]of e.compoundVariants)bt(h,o,e.defaultVariants)&&(r+=" "+b);return r},gt=ne({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy0",variantClassNames:{disabled:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy1",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy2"},kind:{default:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy3",link:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy4",confirm:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy5",delete:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy6",key:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy7",icon:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy8"},spinning:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy9",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxya"}},defaultVariants:{disabled:!1,kind:"default",spinning:!1},compoundVariants:[[{kind:"icon",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyb"],[{kind:"default",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyc"],[{kind:"confirm",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyd"],[{kind:"delete",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxye"],[{kind:"key",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyf"],[{disabled:!0,spinning:!1},"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyg"]]}),vt=ne({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyh",variantClassNames:{disabled:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyi",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyj"},kind:{icon:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyk",default:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyl",delete:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxym",key:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyn",confirm:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyo",link:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyp"},spinning:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyq",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyr"}},defaultVariants:{disabled:!1,kind:"default",spinning:!1},compoundVariants:[]}),ht="pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy11",yt=ne({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy12",variantClassNames:{spinning:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy13",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy14"}},defaultVariants:{spinning:!1},compoundVariants:[]}),kt=ne({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxys",variantClassNames:{spinning:{true:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyt",false:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyu"},kind:{icon:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyv",default:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyw",delete:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyx",key:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyy",confirm:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyz",link:"pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy10"}},defaultVariants:{spinning:!1},compoundVariants:[]});function wt({as:e,onClick:t,onPress:r,children:o,className:a,isDisabled:d,disabled:u,href:p,icon:m,kind:h="default",spinning:b,spinningTitle:P,title:S,..._},x){const T=e??(p?"a":"button"),E={onPress:r??t,isDisabled:u??d??b,..._},{"data-testid":O}=_,$=x||c.useRef(null),{buttonProps:w}=mt(E,$),{hoverProps:C}=ft({isDisabled:E.isDisabled}),{type:D,...G}=w,fe={...j(G,C),ref:$,title:S,className:p?kt({spinning:b,kind:h}):vt({disabled:d||u,kind:h,spinning:b}),...p?{href:p}:{type:D},..._},{t:n}=c.useContext(V.I18nContext),f=m&&c.createElement(V.Icon,{className:ht,icon:m,"aria-hidden":"true","data-testid":`${O}__${m}-icon`});let B;h==="default"||h==="icon"||h==="link"?B="dark":B="light";const l=b&&c.createElement(V.Spinner,{color:B,className:yt({spinning:b}),title:P||n("design-system:button.spinningTitle"),"data-testid":`${O}__spinner`});return c.createElement(me.FocusRing,null,c.createElement("div",{className:V.cl(gt({disabled:d||u,kind:h,spinning:b}),a)},c.createElement(T,{...fe},f,o?c.createElement("span",null,o):"",l)))}const pe=c.forwardRef(wt);V.Metadata.set(pe,{name:"Button",props:{disabled:"boolean",href:"string",icon:"IconName",kind:{type:'"default" | "link" | "icon" | "confirm" | "delete" | "key"',default:'"default"'},spinning:"boolean",spinningTitle:"string",type:{type:'"button" | "submit"',default:'"button"'}},panellable:!0});const Tt={Buttons:{components:[pe],description:()=>c.createElement(c.Fragment,null,c.createElement("div",{className:"sps-body-14"},"Buttons are used to initiate events or actions. The labels and/or icons describe what the button will do."),c.createElement("br",null),c.createElement("h5",null,"Variants"),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Default: "),"For tertiary actions or actions of lower importance on a page."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Key: "),"For primary or important actions on a page."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Confirm: "),"For the main call to action on a page. There should only be one Confirm button per screen."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Delete: "),"For deleting information or another destructive action. These should always be paired with a Delete Confirmation Modal."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Disabled: "),"For actions that are not permitted in a particular state. These can be accompanied by a Tooltip on hover describing why it’s disabled."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"With an Icon: "),"For further illustrating the action. Example: Pencil icon in an Edit button. There can also be Icon Buttons without text.")),examples:{basic:{label:"Basic Buttons",description:({NavigateTo:e})=>c.createElement(c.Fragment,null,c.createElement("p",null,"The most common type of button that can be used in most cases. Example: Basic Buttons in a ",c.createElement(e,{to:"modals"},"Modal"),".")),examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
2
|
+
import { Button } from "@sps-woodland/buttons";
|
3
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
4
|
+
|
5
|
+
function Component() {
|
6
|
+
return (
|
7
|
+
<>
|
8
|
+
<Button className={sprinkles({ mr: "xs" })}>Default</Button>
|
9
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Key</Button>
|
10
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Confirm</Button>
|
11
|
+
<Button className={sprinkles({ mr: "xs" })} kind="delete">Delete</Button>
|
12
|
+
<Button disabled>Disabled</Button>
|
13
|
+
</>
|
14
|
+
)
|
15
|
+
}
|
16
|
+
`},withIcons:{description:"With Icons",react:y.code`
|
17
|
+
import { Button } from "@sps-woodland/buttons";
|
18
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
19
|
+
|
20
|
+
function Component() {
|
21
|
+
return (
|
22
|
+
<>
|
23
|
+
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud">Default</Button>
|
24
|
+
<Button className={sprinkles({ mr: "xs" })} icon="key" kind="key">Key</Button>
|
25
|
+
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud" kind="confirm">Confirm</Button>
|
26
|
+
<Button className={sprinkles({ mr: "xs" })} icon="trash" kind="delete">Delete</Button>
|
27
|
+
<Button icon="download-cloud" disabled>Disabled</Button>
|
28
|
+
</>
|
29
|
+
)
|
30
|
+
}
|
31
|
+
`},spinning:{description:"Spinning",react:y.code`
|
32
|
+
import { Button } from "@sps-woodland/buttons";
|
33
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
34
|
+
|
35
|
+
function Component() {
|
36
|
+
return (
|
37
|
+
<>
|
38
|
+
<Button className={sprinkles({ mr: "xs" })} spinning>Default</Button>
|
39
|
+
<Button className={sprinkles({ mr: "xs" })} spinning kind="key">Key</Button>
|
40
|
+
<Button className={sprinkles({ mr: "xs" })} spinning kind="confirm">Confirm</Button>
|
41
|
+
<Button spinning kind="delete">Delete</Button>
|
42
|
+
</>
|
43
|
+
)
|
44
|
+
}
|
45
|
+
`}}},dropdown:{label:"Dropdown Buttons",description:"Use these for actions that need to select an option to proceed. Example: Download button with optiosn related to the file format (PDF, PPT, etc.).",examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
46
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
47
|
+
|
48
|
+
function Component() {
|
49
|
+
return (
|
50
|
+
<>
|
51
|
+
<SpsDropdown
|
52
|
+
className="mr-1 mb-1"
|
53
|
+
label="Default"
|
54
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
55
|
+
/>
|
56
|
+
<SpsDropdown
|
57
|
+
className="mr-1 mb-1"
|
58
|
+
kind={ButtonKind.KEY}
|
59
|
+
label="Key"
|
60
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
61
|
+
/>
|
62
|
+
<SpsDropdown
|
63
|
+
className="mr-1 mb-1"
|
64
|
+
kind={ButtonKind.CONFIRM}
|
65
|
+
label="Confirm"
|
66
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
67
|
+
/>
|
68
|
+
<SpsDropdown
|
69
|
+
className="mr-1 mb-1"
|
70
|
+
kind={ButtonKind.DELETE}
|
71
|
+
label="Delete"
|
72
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
73
|
+
/>
|
74
|
+
<SpsDropdown
|
75
|
+
className="mr-1 mb-1"
|
76
|
+
disabled
|
77
|
+
label="Disabled"
|
78
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
79
|
+
/>
|
80
|
+
</>
|
81
|
+
)
|
82
|
+
}
|
83
|
+
`},withIcons:{description:"With Icons",react:y.code`
|
84
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
85
|
+
|
86
|
+
function Component() {
|
87
|
+
return (
|
88
|
+
<>
|
89
|
+
<SpsDropdown
|
90
|
+
className="mr-1 mb-1"
|
91
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
92
|
+
label="Default"
|
93
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
94
|
+
/>
|
95
|
+
<SpsDropdown
|
96
|
+
className="mr-1 mb-1"
|
97
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
98
|
+
kind={ButtonKind.KEY}
|
99
|
+
label="Key"
|
100
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
101
|
+
/>
|
102
|
+
<SpsDropdown
|
103
|
+
className="mr-1 mb-1"
|
104
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
105
|
+
kind={ButtonKind.CONFIRM}
|
106
|
+
label="Confirm"
|
107
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
108
|
+
/>
|
109
|
+
<SpsDropdown
|
110
|
+
className="mr-1 mb-1"
|
111
|
+
icon={SpsIcon.TRASH}
|
112
|
+
kind={ButtonKind.DELETE}
|
113
|
+
label="Delete"
|
114
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
115
|
+
/>
|
116
|
+
<SpsDropdown
|
117
|
+
className="mr-1 mb-1"
|
118
|
+
icon={SpsIcon.DOWNLOAD_CLOUD}
|
119
|
+
disabled
|
120
|
+
label="Disabled"
|
121
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
122
|
+
/>
|
123
|
+
</>
|
124
|
+
)
|
125
|
+
}
|
126
|
+
`},spinning:{description:"Spinning",react:y.code`
|
127
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
128
|
+
|
129
|
+
function Component() {
|
130
|
+
return (
|
131
|
+
<>
|
132
|
+
<SpsDropdown
|
133
|
+
spinning
|
134
|
+
className="mr-1 mb-1"
|
135
|
+
label="Default"
|
136
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
137
|
+
/>
|
138
|
+
<SpsDropdown
|
139
|
+
spinning
|
140
|
+
className="mr-1 mb-1"
|
141
|
+
kind={ButtonKind.KEY}
|
142
|
+
label="Key"
|
143
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
144
|
+
/>
|
145
|
+
<SpsDropdown
|
146
|
+
spinning
|
147
|
+
className="mr-1 mb-1"
|
148
|
+
kind={ButtonKind.CONFIRM}
|
149
|
+
label="Confirm"
|
150
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
151
|
+
/>
|
152
|
+
<SpsDropdown
|
153
|
+
spinning
|
154
|
+
className="mr-1 mb-1"
|
155
|
+
kind={ButtonKind.DELETE}
|
156
|
+
label="Delete"
|
157
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
158
|
+
/>
|
159
|
+
</>
|
160
|
+
)
|
161
|
+
}
|
162
|
+
`}}},splitButtons:{label:"Split Buttons",description:"Use when there is 1 primary action and other related actions can be taken.",examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
163
|
+
import { SpsSplitButton } from "@spscommerce/ds-react";
|
164
|
+
|
165
|
+
function Component() {
|
166
|
+
return (
|
167
|
+
<>
|
168
|
+
<SpsSplitButton className="mr-1 mb-1" label="Default" />
|
169
|
+
<SpsSplitButton
|
170
|
+
className="mr-1 mb-1"
|
171
|
+
kind={ButtonKind.KEY}
|
172
|
+
label="Key"
|
173
|
+
/>
|
174
|
+
<SpsSplitButton
|
175
|
+
className="mr-1 mb-1"
|
176
|
+
kind={ButtonKind.CONFIRM}
|
177
|
+
label="Confirm"
|
178
|
+
/>
|
179
|
+
<SpsSplitButton
|
180
|
+
className="mr-1 mb-1"
|
181
|
+
kind={ButtonKind.DELETE}
|
182
|
+
label="Delete"
|
183
|
+
/>
|
184
|
+
<SpsSplitButton className="mr-1 mb-1" disabled label="Disabled" />
|
185
|
+
</>
|
186
|
+
)
|
187
|
+
}
|
188
|
+
`},withIcons:{description:"With Icons",react:y.code`
|
189
|
+
import { SpsSplitButton } from "@spscommerce/ds-react";
|
190
|
+
|
191
|
+
function Component() {
|
192
|
+
return (
|
193
|
+
<>
|
194
|
+
<SpsSplitButton
|
195
|
+
className="mr-1 mb-1"
|
196
|
+
icon={SpsIcon.PLUS_SIGN}
|
197
|
+
label="Default"
|
198
|
+
/>
|
199
|
+
<SpsSplitButton
|
200
|
+
className="mr-1 mb-1"
|
201
|
+
icon={SpsIcon.PLUS_SIGN}
|
202
|
+
kind={ButtonKind.KEY}
|
203
|
+
label="Key"
|
204
|
+
/>
|
205
|
+
<SpsSplitButton
|
206
|
+
className="mr-1 mb-1"
|
207
|
+
icon={SpsIcon.PLUS_SIGN}
|
208
|
+
kind={ButtonKind.CONFIRM}
|
209
|
+
label="Confirm"
|
210
|
+
/>
|
211
|
+
<SpsSplitButton
|
212
|
+
className="mr-1 mb-1"
|
213
|
+
icon={SpsIcon.PLUS_SIGN}
|
214
|
+
kind={ButtonKind.DELETE}
|
215
|
+
label="Delete"
|
216
|
+
/>
|
217
|
+
<SpsSplitButton
|
218
|
+
className="mr-1 mb-1"
|
219
|
+
icon={SpsIcon.PLUS_SIGN}
|
220
|
+
disabled
|
221
|
+
label="Disabled"
|
222
|
+
/>
|
223
|
+
</>
|
224
|
+
)
|
225
|
+
}
|
226
|
+
`}}},iconButtons:{label:"Icon Buttons",description:({NavigateTo:e,Link:t})=>c.createElement(c.Fragment,null,c.createElement("p",null,"Use these for quick actions that can clearly be articulated by the use of an icon. Example: A Print button in the"," ",c.createElement(e,{to:"list-action-bar"},"List Action Bar"),". Do not use an icon that doesn't have a universally understood meaning; instead use a Basic Button or a Basic Button with an icon. ",c.createElement(t,{to:"/style-and-layout/icons/"},"View All Icons"))),examples:{standard:{description:"Standard Icon Buttons",react:y.code`
|
227
|
+
import { Button } from "@sps-woodland/buttons";
|
228
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
229
|
+
|
230
|
+
function Component() {
|
231
|
+
return (
|
232
|
+
<>
|
233
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="printer" />
|
234
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="pencil" />
|
235
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="x" />
|
236
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="trash" />
|
237
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="gear" />
|
238
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="download-cloud" />
|
239
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="search" />
|
240
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="plus-sign" />
|
241
|
+
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="minus" />
|
242
|
+
</>
|
243
|
+
)
|
244
|
+
}
|
245
|
+
`},dropdown:{description:({NavigateTo:e})=>c.createElement(c.Fragment,null,c.createElement("h5",null,"Dropdown Icon Buttons"),c.createElement("p",null,"Use these when there are several options available for action. Example: Dropdown Icon Button in a ",c.createElement(e,{to:"content-rows"},"Content Row"),".")),react:y.code`
|
246
|
+
import { SpsDropdown } from "@spscommerce/ds-react";
|
247
|
+
|
248
|
+
function Component() {
|
249
|
+
return (
|
250
|
+
<>
|
251
|
+
<SpsDropdown
|
252
|
+
className="mr-1 mb-1"
|
253
|
+
kind={ButtonKind.ICON}
|
254
|
+
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
255
|
+
/>
|
256
|
+
</>
|
257
|
+
)
|
258
|
+
}
|
259
|
+
`},spinner:{description:"Spinner",react:y.code`
|
260
|
+
import { Button } from "@sps-woodland/buttons";
|
261
|
+
|
262
|
+
function Component() {
|
263
|
+
return (
|
264
|
+
<>
|
265
|
+
<Button kind="icon" icon="download-cloud" spinning />
|
266
|
+
</>
|
267
|
+
)
|
268
|
+
}
|
269
|
+
`}}},textButtons:{label:"Text Buttons",description:({NavigateTo:e})=>c.createElement("p",null,"Use for less important actions, or ones that aren't taken as frequently. They should not appear inline with other copy. Example: Advanced Search button in the"," ",c.createElement(e,{to:"list-toolbar"},"List Toolbar")),examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
270
|
+
import { Button } from "@sps-woodland/buttons";
|
271
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
272
|
+
|
273
|
+
function Component() {
|
274
|
+
return (
|
275
|
+
<>
|
276
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link">Default</Button>
|
277
|
+
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link">Delete</Button>
|
278
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" disabled>Disabled</Button>
|
279
|
+
</>
|
280
|
+
)
|
281
|
+
}
|
282
|
+
`},withIcons:{description:"With Icons",react:y.code`
|
283
|
+
import { Button } from "@sps-woodland/buttons";
|
284
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
285
|
+
|
286
|
+
function Component() {
|
287
|
+
return (
|
288
|
+
<>
|
289
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="download-cloud">Default</Button>
|
290
|
+
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link" icon="trash">Delete</Button>
|
291
|
+
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="gear" disabled>Disabled</Button>
|
292
|
+
</>
|
293
|
+
)
|
294
|
+
}
|
295
|
+
`},spinner:{description:"Spinner",react:y.code`
|
296
|
+
import { Button } from "@sps-woodland/buttons";
|
297
|
+
|
298
|
+
function Component() {
|
299
|
+
return (
|
300
|
+
<>
|
301
|
+
<Button kind="link" spinning>Default</Button>
|
302
|
+
</>
|
303
|
+
)
|
304
|
+
}
|
305
|
+
`}}},submitButtons:{label:"Submit Buttons",description:({NavigateTo:e})=>c.createElement("p",null,"Use to submit a form. There can be a number of visual variations, for example a"," ",c.createElement(e,{to:"modals"},"Modal")," uses Basic Button (Key) as its Submit Button."),examples:{basic:{react:y.code`
|
306
|
+
import { Button } from "@sps-woodland/buttons";
|
307
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
308
|
+
|
309
|
+
function Component() {
|
310
|
+
const { formMeta, formValue, updateForm } = useSpsForm({});
|
311
|
+
|
312
|
+
function alertOnSubmit() {
|
313
|
+
window.alert("Form submitted");
|
314
|
+
}
|
315
|
+
|
316
|
+
return (
|
317
|
+
<SpsForm formMeta={formMeta} onSubmit={alertOnSubmit}>
|
318
|
+
{/* Use only one Submit button in your form */}
|
319
|
+
<Button className={sprinkles({ mr: "xs" })} type="submit" kind="key">Key</Button>
|
320
|
+
<Button type="submit" kind="confirm">Confirm</Button>
|
321
|
+
</SpsForm>
|
322
|
+
)
|
323
|
+
}
|
324
|
+
`}}},link:{label:"Button as a Link",description:"Used to link to another page, such as an external website. They may open in the same window or in a new one. It should only be used when a Text Button doesn't provide enough visual emphasis.",examples:{basic:{react:y.code`
|
325
|
+
import { Button } from "@sps-woodland/buttons";
|
326
|
+
|
327
|
+
function Component() {
|
328
|
+
return (
|
329
|
+
<>
|
330
|
+
<Button kind="default" href="https://google.com">
|
331
|
+
Button Text
|
332
|
+
</Button>
|
333
|
+
</>
|
334
|
+
)
|
335
|
+
}
|
336
|
+
`}}},buttonGroups:{label:"Button Groups",description:({NavigateTo:e})=>c.createElement("p",null,"Use button groups when there are a number of actions that can be taken in a view. When there are multiple button types in a group, they are separated using dividers. Example: Button groups in ",c.createElement(e,{to:"List Action Bar"},"List Action Bar"),"."),examples:{basic:{description:"Basic Button Groups",react:y.code`
|
337
|
+
import { Button } from "@sps-woodland/buttons";
|
338
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
339
|
+
|
340
|
+
function Component() {
|
341
|
+
return (
|
342
|
+
<>
|
343
|
+
<Button className={sprinkles({ mr: "xs" })}>Cancel</Button>
|
344
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Save</Button>
|
345
|
+
</>
|
346
|
+
)
|
347
|
+
}
|
348
|
+
`},icon:{description:"Icon Button Groups",react:y.code`
|
349
|
+
import { Button } from "@sps-woodland/buttons";
|
350
|
+
|
351
|
+
function Component() {
|
352
|
+
return (
|
353
|
+
<>
|
354
|
+
<Button kind="icon" icon="pencil" />
|
355
|
+
<Button kind="icon" icon="trash" />
|
356
|
+
</>
|
357
|
+
)
|
358
|
+
}
|
359
|
+
`},textAndIcons:{description:"Text Buttons + Icon Buttons Group",react:y.code`
|
360
|
+
import { Button } from "@sps-woodland/buttons";
|
361
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
362
|
+
import { VericalRule } from "@sps-woodland/core";
|
363
|
+
|
364
|
+
function Component() {
|
365
|
+
return (
|
366
|
+
<>
|
367
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
368
|
+
<VerticalRule />
|
369
|
+
<Button kind="icon" icon="download-cloud" />
|
370
|
+
<Button kind="icon" icon="printer" />
|
371
|
+
</>
|
372
|
+
)
|
373
|
+
}
|
374
|
+
`},textAndBasic:{description:"Text Buttons + Basic Buttons Group",react:y.code`
|
375
|
+
import { Button } from "@sps-woodland/buttons";
|
376
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
377
|
+
import { VericalRule } from "@sps-woodland/core";
|
378
|
+
|
379
|
+
function Component() {
|
380
|
+
return (
|
381
|
+
<>
|
382
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
383
|
+
<VerticalRule />
|
384
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
385
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
386
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
387
|
+
</>
|
388
|
+
)
|
389
|
+
}
|
390
|
+
`},iconsAndBasic:{description:"Icon Buttons + Basic Buttons Group",react:y.code`
|
391
|
+
import { Button } from "@sps-woodland/buttons";
|
392
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
393
|
+
import { VericalRule } from "@sps-woodland/core";
|
394
|
+
|
395
|
+
function Component() {
|
396
|
+
return (
|
397
|
+
<>
|
398
|
+
<Button kind="icon" icon="download-cloud" />
|
399
|
+
<Button kind="icon" icon="printer" />
|
400
|
+
<VerticalRule />
|
401
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
402
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
403
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
404
|
+
</>
|
405
|
+
)
|
406
|
+
}
|
407
|
+
`},textIconsAndBasic:{description:"Text Buttons + Icon Buttons + Basic Buttons Group",react:y.code`
|
408
|
+
import { Button } from "@sps-woodland/buttons";
|
409
|
+
import { sprinkles } from "@sps-woodland/tokens";
|
410
|
+
import { VericalRule } from "@sps-woodland/core";
|
411
|
+
|
412
|
+
function Component() {
|
413
|
+
return (
|
414
|
+
<>
|
415
|
+
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
416
|
+
<VerticalRule />
|
417
|
+
<Button kind="icon" icon="download-cloud" />
|
418
|
+
<Button kind="icon" icon="printer" />
|
419
|
+
<VerticalRule />
|
420
|
+
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
421
|
+
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
422
|
+
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
423
|
+
</>
|
424
|
+
)
|
425
|
+
}
|
426
|
+
`}}}}}};N.Button=pe,N.MANIFEST=Tt,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
package/lib/style.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
.pkg_sps-
|
1
|
+
.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy0{border-width:.0625rem;border-style:solid;border-radius:.25rem;cursor:pointer;display:inline-block;font-size:.75rem;font-weight:600;line-height:.875rem;padding:0;position:relative}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy3{background:#e9e9ea;border-color:#d2d4d4;color:#4b5356}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy3:hover{background:#d2d4d4}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy4{background:none transparent;border:0;color:#027db8}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy4:hover{background:none transparent;color:#08638d;text-decoration:none}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy5{background:#027db8;border-color:#08638d;color:#fff}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy5:hover{background:#08638d}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy6{background:#de012e;border-color:#a30d2d;color:#fff}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy6:hover{background:#a30d2d}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy7{background:#4b5356;border-color:#1f282c;color:#fff}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy7:hover{background:#1f282c}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy8{background:transparent;border-color:transparent;color:#4b5356}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy8:hover{background-color:#d2d4d4;border-color:#d2d4d4}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy9{color:transparent!important;cursor:not-allowed}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyb{background:#e9e9ea;border-color:#d2d4d4}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyb:hover,.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyc:hover{background:#e9e9ea}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyd:hover{background:#027db8}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxye:hover{background:#de012e}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyf:hover{background:#4b5356}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyg{background:#fff!important;border-color:#d2d4d4!important;color:#717779!important;cursor:not-allowed}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyg:hover{background:#fff}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyh{background:none transparent;border:0 none;color:inherit;display:block;font-size:inherit;font-weight:inherit;margin:0;text-decoration:none;padding:.5rem 1rem}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyh:hover{text-decoration:none}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyi{cursor:not-allowed!important}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyk{padding:.25rem .5rem}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyp{padding-top:.5rem;padding-bottom:.5rem;padding-right:0;padding-left:0}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyq{cursor:not-allowed!important}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxys{background:none transparent;border:0 none;color:inherit;cursor:inherit;display:block;font-size:inherit;font-weight:inherit;margin:0;padding:.5rem 1rem;text-decoration:none}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxys:hover{text-decoration:none;color:inherit}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyt{cursor:not-allowed}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxyv{padding:.25rem .5rem}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy11{line-height:0!important;position:relative}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy11:before{font-size:.875rem;line-height:0;position:relative;top:.125rem}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy11:not(:last-child){margin-right:.5rem}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy12{left:50%;margin:-.875rem -.4375rem;position:absolute}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy13{cursor:not-allowed;display:inline}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy14{display:none}.pkg_sps-woodland_buttons__version_8_21_2__hash_125pcxy12>i{border-width:.125rem;height:.875rem;width:.875rem}
|
package/package.json
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sps-woodland/buttons",
|
3
3
|
"description": "SPS Woodland Design System button components",
|
4
|
-
"version": "8.21.
|
4
|
+
"version": "8.21.2",
|
5
5
|
"author": "SPS Commerce",
|
6
6
|
"license": "UNLICENSED",
|
7
7
|
"repository": "https://github.com/SPSCommerce/woodland/tree/main/packages/@sps-woodland/buttons",
|
8
8
|
"homepage": "https://github.com/SPSCommerce/woodland/tree/master/packages/@sps-woodland/buttons#readme",
|
9
9
|
"type": "module",
|
10
|
-
"module": "./lib/index.
|
11
|
-
"main": "./lib/index.cjs
|
10
|
+
"module": "./lib/index.js",
|
11
|
+
"main": "./lib/index.umd.cjs",
|
12
12
|
"types": "./lib/index.d.ts",
|
13
13
|
"exports": {
|
14
14
|
".": {
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"default": "./lib/index.
|
15
|
+
"require": "./lib/index.umd.cjs",
|
16
|
+
"import": "./lib/index.js",
|
17
|
+
"default": "./lib/index.js",
|
18
18
|
"types": "./lib/index.d.ts"
|
19
19
|
},
|
20
20
|
"./lib/style.css": {
|
@@ -30,8 +30,8 @@
|
|
30
30
|
"@spscommerce/utils": "^7.0.0",
|
31
31
|
"react": "^16.9.0",
|
32
32
|
"react-dom": "^16.9.0",
|
33
|
-
"@sps-woodland/core": "8.21.
|
34
|
-
"@sps-woodland/tokens": "8.21.
|
33
|
+
"@sps-woodland/core": "8.21.2",
|
34
|
+
"@sps-woodland/tokens": "8.21.2"
|
35
35
|
},
|
36
36
|
"devDependencies": {
|
37
37
|
"@react-aria/button": "^3.3.5",
|
@@ -42,8 +42,8 @@
|
|
42
42
|
"@vanilla-extract/recipes": "^0.2.5",
|
43
43
|
"react": "^16.9.0",
|
44
44
|
"react-dom": "^16.9.0",
|
45
|
-
"@sps-woodland/core": "8.21.
|
46
|
-
"@sps-woodland/tokens": "8.21.
|
45
|
+
"@sps-woodland/core": "8.21.2",
|
46
|
+
"@sps-woodland/tokens": "8.21.2"
|
47
47
|
},
|
48
48
|
"dependencies": {
|
49
49
|
"@react-aria/button": "^3.7.0",
|
package/vite.config.mjs
CHANGED
@@ -18,8 +18,8 @@ export default defineConfig({
|
|
18
18
|
build: {
|
19
19
|
lib: {
|
20
20
|
entry: path.resolve(__dirname, "src/index.ts"),
|
21
|
-
|
22
|
-
fileName:
|
21
|
+
name: "Buttons",
|
22
|
+
fileName: "index"
|
23
23
|
},
|
24
24
|
outDir: path.resolve(__dirname, "./lib"),
|
25
25
|
emptyOutDir: false,
|
package/lib/index.cjs.js
DELETED
@@ -1,426 +0,0 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),G=require("@sps-woodland/core"),Ee=require("@react-aria/focus"),y=require("@spscommerce/utils");function Ie(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const c=Ie(k),Be=typeof document<"u"?k.useLayoutEffect:()=>{};function H(e){const t=k.useRef(null);return Be(()=>{t.current=e},[e]),k.useCallback((...r)=>{const o=t.current;return o==null?void 0:o(...r)},[])}let fe=new Map;function Ae(e,t){if(e===t)return e;let r=fe.get(e);if(r)return r.forEach(a=>a(t)),t;let o=fe.get(t);return o?(o.forEach(a=>a(e)),e):t}function $e(...e){return(...t)=>{for(let r of e)typeof r=="function"&&r(...t)}}const A=e=>{var t;return(t=e==null?void 0:e.ownerDocument)!==null&&t!==void 0?t:document},ae=e=>e&&"window"in e&&e.window===e?e:A(e).defaultView||window;function Pe(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=Pe(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Le(){for(var e,t,r=0,o="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=Pe(e))&&(o&&(o+=" "),o+=t);return o}function W(...e){let t={...e[0]};for(let r=1;r<e.length;r++){let o=e[r];for(let a in o){let d=t[a],u=o[a];typeof d=="function"&&typeof u=="function"&&a[0]==="o"&&a[1]==="n"&&a.charCodeAt(2)>=65&&a.charCodeAt(2)<=90?t[a]=$e(d,u):(a==="className"||a==="UNSAFE_className")&&typeof d=="string"&&typeof u=="string"?t[a]=Le(d,u):a==="id"&&d&&u?t.id=Ae(d,u):t[a]=u!==void 0?u:d}}return t}const Me=new Set(["id"]),Fe=new Set(["aria-label","aria-labelledby","aria-describedby","aria-details"]),Ue=new Set(["href","hrefLang","target","rel","download","ping","referrerPolicy"]),Re=/^(data-.*)$/;function He(e,t={}){let{labelable:r,isLink:o,propNames:a}=t,d={};for(const u in e)Object.prototype.hasOwnProperty.call(e,u)&&(Me.has(u)||r&&Fe.has(u)||o&&Ue.has(u)||a!=null&&a.has(u)||Re.test(u))&&(d[u]=e[u]);return d}function V(e){if(Ge())e.focus({preventScroll:!0});else{let t=Ve(e);e.focus(),We(t)}}let Y=null;function Ge(){if(Y==null){Y=!1;try{document.createElement("div").focus({get preventScroll(){return Y=!0,!0}})}catch{}}return Y}function Ve(e){let t=e.parentNode,r=[],o=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==o;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&r.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return o instanceof HTMLElement&&r.push({element:o,scrollTop:o.scrollTop,scrollLeft:o.scrollLeft}),r}function We(e){for(let{element:t,scrollTop:r,scrollLeft:o}of e)t.scrollTop=r,t.scrollLeft=o}function ee(e){var t;return typeof window>"u"||window.navigator==null?!1:((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.brands.some(r=>e.test(r.brand)))||e.test(window.navigator.userAgent)}function ce(e){var t;return typeof window<"u"&&window.navigator!=null?e.test(((t=window.navigator.userAgentData)===null||t===void 0?void 0:t.platform)||window.navigator.platform):!1}function L(e){let t=null;return()=>(t==null&&(t=e()),t)}const Q=L(function(){return ce(/^Mac/i)}),je=L(function(){return ce(/^iPhone/i)}),xe=L(function(){return ce(/^iPad/i)||Q()&&navigator.maxTouchPoints>1}),Se=L(function(){return je()||xe()}),Ye=L(function(){return ee(/AppleWebKit/i)&&!Xe()}),Xe=L(function(){return ee(/Chrome/i)}),Ne=L(function(){return ee(/Android/i)}),qe=L(function(){return ee(/Firefox/i)});function j(e,t,r=!0){var o,a;let{metaKey:d,ctrlKey:u,altKey:p,shiftKey:m}=t;qe()&&(!((a=window.event)===null||a===void 0||(o=a.type)===null||o===void 0)&&o.startsWith("key"))&&e.target==="_blank"&&(Q()?d=!0:u=!0);let v=Ye()&&Q()&&!xe()?new KeyboardEvent("keydown",{keyIdentifier:"Enter",metaKey:d,ctrlKey:u,altKey:p,shiftKey:m}):new MouseEvent("click",{metaKey:d,ctrlKey:u,altKey:p,shiftKey:m,bubbles:!0,cancelable:!0});j.isOpening=r,V(e),e.dispatchEvent(v),j.isOpening=!1}j.isOpening=!1;let U=new Map,ie=new Set;function me(){if(typeof window>"u")return;function e(o){return"propertyName"in o}let t=o=>{if(!e(o)||!o.target)return;let a=U.get(o.target);a||(a=new Set,U.set(o.target,a),o.target.addEventListener("transitioncancel",r,{once:!0})),a.add(o.propertyName)},r=o=>{if(!e(o)||!o.target)return;let a=U.get(o.target);if(a&&(a.delete(o.propertyName),a.size===0&&(o.target.removeEventListener("transitioncancel",r),U.delete(o.target)),U.size===0)){for(let d of ie)d();ie.clear()}};document.body.addEventListener("transitionrun",t),document.body.addEventListener("transitionend",r)}typeof document<"u"&&(document.readyState!=="loading"?me():document.addEventListener("DOMContentLoaded",me));function ze(e){requestAnimationFrame(()=>{U.size===0?e():ie.add(e)})}function Je(){let e=k.useRef(new Map),t=k.useCallback((a,d,u,p)=>{let m=p!=null&&p.once?(...v)=>{e.current.delete(u),u(...v)}:u;e.current.set(u,{type:d,eventTarget:a,fn:m,options:p}),a.addEventListener(d,u,p)},[]),r=k.useCallback((a,d,u,p)=>{var m;let v=((m=e.current.get(u))===null||m===void 0?void 0:m.fn)||u;a.removeEventListener(d,v,p),e.current.delete(u)},[]),o=k.useCallback(()=>{e.current.forEach((a,d)=>{r(a.eventTarget,a.type,d,a.options)})},[r]);return k.useEffect(()=>o,[o]),{addGlobalListener:t,removeGlobalListener:r,removeAllGlobalListeners:o}}function Qe(e,t){Be(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function _e(e){return e.mozInputSource===0&&e.isTrusted?!0:Ne()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function Ze(e){return!Ne()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}let R="default",le="",J=new WeakMap;function be(e){if(Se()){if(R==="default"){const t=A(e);le=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect="none"}R="disabled"}else(e instanceof HTMLElement||e instanceof SVGElement)&&(J.set(e,e.style.userSelect),e.style.userSelect="none")}function X(e){if(Se()){if(R!=="disabled")return;R="restoring",setTimeout(()=>{ze(()=>{if(R==="restoring"){const t=A(e);t.documentElement.style.webkitUserSelect==="none"&&(t.documentElement.style.webkitUserSelect=le||""),le="",R="default"}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&J.has(e)){let t=J.get(e);e.style.userSelect==="none"&&(e.style.userSelect=t),e.getAttribute("style")===""&&e.removeAttribute("style"),J.delete(e)}}const Oe=k.createContext({register:()=>{}});Oe.displayName="PressResponderContext";function et(e,t){return t.get?t.get.call(e):t.value}function De(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function tt(e,t){var r=De(e,t,"get");return et(e,r)}function nt(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ot(e,t,r){nt(e,t),t.set(e,r)}function rt(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function ge(e,t,r){var o=De(e,t,"set");return rt(e,o,r),r}function st(e){let t=k.useContext(Oe);if(t){let{register:r,...o}=t;e=W(o,e),r()}return Qe(t,e.ref),e}var q=new WeakMap;class z{continuePropagation(){ge(this,q,!1)}get shouldStopPropagation(){return tt(this,q)}constructor(t,r,o,a){ot(this,q,{writable:!0,value:void 0}),ge(this,q,!0);var d;let u=(d=a==null?void 0:a.target)!==null&&d!==void 0?d:o.currentTarget;const p=u==null?void 0:u.getBoundingClientRect();let m,v=0,b,P=null;o.clientX!=null&&o.clientY!=null&&(b=o.clientX,P=o.clientY),p&&(b!=null&&P!=null?(m=b-p.left,v=P-p.top):(m=p.width/2,v=p.height/2)),this.type=t,this.pointerType=r,this.target=o.currentTarget,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.x=m,this.y=v}}const ve=Symbol("linkClicked");function at(e){let{onPress:t,onPressChange:r,onPressStart:o,onPressEnd:a,onPressUp:d,isDisabled:u,isPressed:p,preventFocusOnPress:m,shouldCancelOnPointerExit:v,allowTextSelectionOnPress:b,ref:P,...S}=st(e),[_,x]=k.useState(!1),T=k.useRef({isPressed:!1,ignoreEmulatedMouseEvents:!1,ignoreClickAfterPress:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null}),{addGlobalListener:E,removeAllGlobalListeners:N}=Je(),$=H((n,f)=>{let B=T.current;if(u||B.didFirePressStart)return!1;let l=!0;if(B.isTriggeringEvent=!0,o){let h=new z("pressstart",f,n);o(h),l=h.shouldStopPropagation}return r&&r(!0),B.isTriggeringEvent=!1,B.didFirePressStart=!0,x(!0),l}),w=H((n,f,B=!0)=>{let l=T.current;if(!l.didFirePressStart)return!1;l.ignoreClickAfterPress=!0,l.didFirePressStart=!1,l.isTriggeringEvent=!0;let h=!0;if(a){let s=new z("pressend",f,n);a(s),h=s.shouldStopPropagation}if(r&&r(!1),x(!1),t&&B&&!u){let s=new z("press",f,n);t(s),h&&(h=s.shouldStopPropagation)}return l.isTriggeringEvent=!1,h}),D=H((n,f)=>{let B=T.current;if(u)return!1;if(d){B.isTriggeringEvent=!0;let l=new z("pressup",f,n);return d(l),B.isTriggeringEvent=!1,l.shouldStopPropagation}return!0}),O=H(n=>{let f=T.current;f.isPressed&&f.target&&(f.isOverTarget&&f.pointerType!=null&&w(K(f.target,n),f.pointerType,!1),f.isPressed=!1,f.isOverTarget=!1,f.activePointerId=null,f.pointerType=null,N(),b||X(f.target))}),M=H(n=>{v&&O(n)}),ne=k.useMemo(()=>{let n=T.current,f={onKeyDown(l){if(oe(l.nativeEvent,l.currentTarget)&&l.currentTarget.contains(l.target)){var h;ye(l.target,l.key)&&l.preventDefault();let s=!0;if(!n.isPressed&&!l.repeat){n.target=l.currentTarget,n.isPressed=!0,s=$(l,"keyboard");let g=l.currentTarget,i=C=>{oe(C,g)&&!C.repeat&&g.contains(C.target)&&n.target&&D(K(n.target,C),"keyboard")};E(A(l.currentTarget),"keyup",$e(i,B),!0)}s&&l.stopPropagation(),l.metaKey&&Q()&&((h=n.metaKeyEvents)===null||h===void 0||h.set(l.key,l.nativeEvent))}else l.key==="Meta"&&(n.metaKeyEvents=new Map)},onClick(l){if(!(l&&!l.currentTarget.contains(l.target))&&l&&l.button===0&&!n.isTriggeringEvent&&!j.isOpening){let h=!0;if(u&&l.preventDefault(),!n.ignoreClickAfterPress&&!n.ignoreEmulatedMouseEvents&&!n.isPressed&&(n.pointerType==="virtual"||_e(l.nativeEvent))){!u&&!m&&V(l.currentTarget);let s=$(l,"virtual"),g=D(l,"virtual"),i=w(l,"virtual");h=s&&g&&i}n.ignoreEmulatedMouseEvents=!1,n.ignoreClickAfterPress=!1,h&&l.stopPropagation()}}},B=l=>{var h;if(n.isPressed&&n.target&&oe(l,n.target)){var s;ye(l.target,l.key)&&l.preventDefault();let i=l.target;w(K(n.target,l),"keyboard",n.target.contains(i)),N(),l.key!=="Enter"&&de(n.target)&&n.target.contains(i)&&!l[ve]&&(l[ve]=!0,j(n.target,l,!1)),n.isPressed=!1,(s=n.metaKeyEvents)===null||s===void 0||s.delete(l.key)}else if(l.key==="Meta"&&(!((h=n.metaKeyEvents)===null||h===void 0)&&h.size)){var g;let i=n.metaKeyEvents;n.metaKeyEvents=void 0;for(let C of i.values())(g=n.target)===null||g===void 0||g.dispatchEvent(new KeyboardEvent("keyup",C))}};if(typeof PointerEvent<"u"){f.onPointerDown=i=>{if(i.button!==0||!i.currentTarget.contains(i.target))return;if(Ze(i.nativeEvent)){n.pointerType="virtual";return}re(i.currentTarget)&&i.preventDefault(),n.pointerType=i.pointerType;let C=!0;n.isPressed||(n.isPressed=!0,n.isOverTarget=!0,n.activePointerId=i.pointerId,n.target=i.currentTarget,!u&&!m&&V(i.currentTarget),b||be(n.target),C=$(i,n.pointerType),E(A(i.currentTarget),"pointermove",l,!1),E(A(i.currentTarget),"pointerup",h,!1),E(A(i.currentTarget),"pointercancel",g,!1)),C&&i.stopPropagation()},f.onMouseDown=i=>{i.currentTarget.contains(i.target)&&i.button===0&&(re(i.currentTarget)&&i.preventDefault(),i.stopPropagation())},f.onPointerUp=i=>{!i.currentTarget.contains(i.target)||n.pointerType==="virtual"||i.button===0&&F(i,i.currentTarget)&&D(i,n.pointerType||i.pointerType)};let l=i=>{i.pointerId===n.activePointerId&&(n.target&&F(i,n.target)?!n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!0,$(K(n.target,i),n.pointerType)):n.target&&n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!1,w(K(n.target,i),n.pointerType,!1),M(i)))},h=i=>{i.pointerId===n.activePointerId&&n.isPressed&&i.button===0&&n.target&&(F(i,n.target)&&n.pointerType!=null?w(K(n.target,i),n.pointerType):n.isOverTarget&&n.pointerType!=null&&w(K(n.target,i),n.pointerType,!1),n.isPressed=!1,n.isOverTarget=!1,n.activePointerId=null,n.pointerType=null,N(),b||X(n.target),"ontouchend"in n.target&&i.pointerType!=="mouse"&&E(n.target,"touchend",s,{once:!0}))},s=i=>{Ce(i.target)&&i.preventDefault()},g=i=>{O(i)};f.onDragStart=i=>{i.currentTarget.contains(i.target)&&O(i)}}else{f.onMouseDown=s=>{if(s.button!==0||!s.currentTarget.contains(s.target))return;if(re(s.currentTarget)&&s.preventDefault(),n.ignoreEmulatedMouseEvents){s.stopPropagation();return}n.isPressed=!0,n.isOverTarget=!0,n.target=s.currentTarget,n.pointerType=_e(s.nativeEvent)?"virtual":"mouse",!u&&!m&&V(s.currentTarget),$(s,n.pointerType)&&s.stopPropagation(),E(A(s.currentTarget),"mouseup",l,!1)},f.onMouseEnter=s=>{if(!s.currentTarget.contains(s.target))return;let g=!0;n.isPressed&&!n.ignoreEmulatedMouseEvents&&n.pointerType!=null&&(n.isOverTarget=!0,g=$(s,n.pointerType)),g&&s.stopPropagation()},f.onMouseLeave=s=>{if(!s.currentTarget.contains(s.target))return;let g=!0;n.isPressed&&!n.ignoreEmulatedMouseEvents&&n.pointerType!=null&&(n.isOverTarget=!1,g=w(s,n.pointerType,!1),M(s)),g&&s.stopPropagation()},f.onMouseUp=s=>{s.currentTarget.contains(s.target)&&!n.ignoreEmulatedMouseEvents&&s.button===0&&D(s,n.pointerType||"mouse")};let l=s=>{if(s.button===0){if(n.isPressed=!1,N(),n.ignoreEmulatedMouseEvents){n.ignoreEmulatedMouseEvents=!1;return}n.target&&F(s,n.target)&&n.pointerType!=null?w(K(n.target,s),n.pointerType):n.target&&n.isOverTarget&&n.pointerType!=null&&w(K(n.target,s),n.pointerType,!1),n.isOverTarget=!1}};f.onTouchStart=s=>{if(!s.currentTarget.contains(s.target))return;let g=it(s.nativeEvent);if(!g)return;n.activePointerId=g.identifier,n.ignoreEmulatedMouseEvents=!0,n.isOverTarget=!0,n.isPressed=!0,n.target=s.currentTarget,n.pointerType="touch",!u&&!m&&V(s.currentTarget),b||be(n.target),$(I(n.target,s),n.pointerType)&&s.stopPropagation(),E(ae(s.currentTarget),"scroll",h,!0)},f.onTouchMove=s=>{if(!s.currentTarget.contains(s.target))return;if(!n.isPressed){s.stopPropagation();return}let g=he(s.nativeEvent,n.activePointerId),i=!0;g&&F(g,s.currentTarget)?!n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!0,i=$(I(n.target,s),n.pointerType)):n.isOverTarget&&n.pointerType!=null&&(n.isOverTarget=!1,i=w(I(n.target,s),n.pointerType,!1),M(I(n.target,s))),i&&s.stopPropagation()},f.onTouchEnd=s=>{if(!s.currentTarget.contains(s.target))return;if(!n.isPressed){s.stopPropagation();return}let g=he(s.nativeEvent,n.activePointerId),i=!0;g&&F(g,s.currentTarget)&&n.pointerType!=null?(D(I(n.target,s),n.pointerType),i=w(I(n.target,s),n.pointerType)):n.isOverTarget&&n.pointerType!=null&&(i=w(I(n.target,s),n.pointerType,!1)),i&&s.stopPropagation(),n.isPressed=!1,n.activePointerId=null,n.isOverTarget=!1,n.ignoreEmulatedMouseEvents=!0,n.target&&!b&&X(n.target),N()},f.onTouchCancel=s=>{s.currentTarget.contains(s.target)&&(s.stopPropagation(),n.isPressed&&O(I(n.target,s)))};let h=s=>{n.isPressed&&s.target.contains(n.target)&&O({currentTarget:n.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})};f.onDragStart=s=>{s.currentTarget.contains(s.target)&&O(s)}}return f},[E,u,m,N,b,O,M,w,$,D]);return k.useEffect(()=>()=>{var n;b||X((n=T.current.target)!==null&&n!==void 0?n:void 0)},[b]),{isPressed:p||_,pressProps:W(S,ne)}}function de(e){return e.tagName==="A"&&e.hasAttribute("href")}function oe(e,t){const{key:r,code:o}=e,a=t,d=a.getAttribute("role");return(r==="Enter"||r===" "||r==="Spacebar"||o==="Space")&&!(a instanceof ae(a).HTMLInputElement&&!Ke(a,r)||a instanceof ae(a).HTMLTextAreaElement||a.isContentEditable)&&!((d==="link"||!d&&de(a))&&r!=="Enter")}function it(e){const{targetTouches:t}=e;return t.length>0?t[0]:null}function he(e,t){const r=e.changedTouches;for(let o=0;o<r.length;o++){const a=r[o];if(a.identifier===t)return a}return null}function I(e,t){let r=0,o=0;return t.targetTouches&&t.targetTouches.length===1&&(r=t.targetTouches[0].clientX,o=t.targetTouches[0].clientY),{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:r,clientY:o}}function K(e,t){let r=t.clientX,o=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:r,clientY:o}}function lt(e){let t=0,r=0;return e.width!==void 0?t=e.width/2:e.radiusX!==void 0&&(t=e.radiusX),e.height!==void 0?r=e.height/2:e.radiusY!==void 0&&(r=e.radiusY),{top:e.clientY-r,right:e.clientX+t,bottom:e.clientY+r,left:e.clientX-t}}function ut(e,t){return!(e.left>t.right||t.left>e.right||e.top>t.bottom||t.top>e.bottom)}function F(e,t){let r=t.getBoundingClientRect(),o=lt(e);return ut(r,o)}function re(e){return!(e instanceof HTMLElement)||!e.hasAttribute("draggable")}function Ce(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!=="submit"&&e.type!=="reset":!de(e)}function ye(e,t){return e instanceof HTMLInputElement?!Ke(e,t):Ce(e)}const ct=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function Ke(e,t){return e.type==="checkbox"||e.type==="radio"?t===" ":ct.has(e.type)}let Z=!1,se=0;function ue(){Z=!0,setTimeout(()=>{Z=!1},50)}function ke(e){e.pointerType==="touch"&&ue()}function dt(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",ke):document.addEventListener("touchend",ue),se++,()=>{se--,!(se>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",ke):document.removeEventListener("touchend",ue))}}function pt(e){let{onHoverStart:t,onHoverChange:r,onHoverEnd:o,isDisabled:a}=e,[d,u]=k.useState(!1),p=k.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;k.useEffect(dt,[]);let{hoverProps:m,triggerHoverEnd:v}=k.useMemo(()=>{let b=(_,x)=>{if(p.pointerType=x,a||x==="touch"||p.isHovered||!_.currentTarget.contains(_.target))return;p.isHovered=!0;let T=_.currentTarget;p.target=T,t&&t({type:"hoverstart",target:T,pointerType:x}),r&&r(!0),u(!0)},P=(_,x)=>{if(p.pointerType="",p.target=null,x==="touch"||!p.isHovered)return;p.isHovered=!1;let T=_.currentTarget;o&&o({type:"hoverend",target:T,pointerType:x}),r&&r(!1),u(!1)},S={};return typeof PointerEvent<"u"?(S.onPointerEnter=_=>{Z&&_.pointerType==="mouse"||b(_,_.pointerType)},S.onPointerLeave=_=>{!a&&_.currentTarget.contains(_.target)&&P(_,_.pointerType)}):(S.onTouchStart=()=>{p.ignoreEmulatedMouseEvents=!0},S.onMouseEnter=_=>{!p.ignoreEmulatedMouseEvents&&!Z&&b(_,"mouse"),p.ignoreEmulatedMouseEvents=!1},S.onMouseLeave=_=>{!a&&_.currentTarget.contains(_.target)&&P(_,"mouse")}),{hoverProps:S,triggerHoverEnd:P}},[t,r,o,a,p]);return k.useEffect(()=>{a&&v({currentTarget:p.target},p.pointerType)},[a]),{hoverProps:m,isHovered:d}}function ft(e,t){let{elementType:r="button",isDisabled:o,onPress:a,onPressStart:d,onPressEnd:u,onPressUp:p,onPressChange:m,preventFocusOnPress:v,allowFocusWhenDisabled:b,onClick:P,href:S,target:_,rel:x,type:T="button"}=e,E;r==="button"?E={type:T,disabled:o}:E={role:"button",tabIndex:o?void 0:0,href:r==="a"&&o?void 0:S,target:r==="a"?_:void 0,type:r==="input"?T:void 0,disabled:r==="input"?o:void 0,"aria-disabled":!o||r==="input"?void 0:o,rel:r==="a"?x:void 0};let{pressProps:N,isPressed:$}=at({onPressStart:d,onPressEnd:u,onPressChange:m,onPress:a,onPressUp:p,isDisabled:o,preventFocusOnPress:v,ref:t}),{focusableProps:w}=Ee.useFocusable(e,t);b&&(w.tabIndex=o?-1:w.tabIndex);let D=W(w,N,He(e,{labelable:!0}));return{isPressed:$,buttonProps:W(E,D,{"aria-haspopup":e["aria-haspopup"],"aria-expanded":e["aria-expanded"],"aria-controls":e["aria-controls"],"aria-pressed":e["aria-pressed"],onClick:O=>{P&&(P(O),console.warn("onClick is deprecated, please use onPress"))}})}}function mt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function we(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,o)}return r}function Te(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?we(Object(r),!0).forEach(function(o){mt(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):we(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}var _t=(e,t,r)=>{for(var o of Object.keys(e)){var a;if(e[o]!==((a=t[o])!==null&&a!==void 0?a:r[o]))return!1}return!0},te=e=>t=>{var r=e.defaultClassName,o=Te(Te({},e.defaultVariants),t);for(var a in o){var d,u=(d=o[a])!==null&&d!==void 0?d:e.defaultVariants[a];if(u!=null){var p=u;typeof p=="boolean"&&(p=p===!0?"true":"false");var m=e.variantClassNames[a][p];m&&(r+=" "+m)}}for(var[v,b]of e.compoundVariants)_t(v,o,e.defaultVariants)&&(r+=" "+b);return r},bt=te({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy0",variantClassNames:{disabled:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy1",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy2"},kind:{default:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy3",link:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy4",confirm:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy5",delete:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy6",key:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy7",icon:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy8"},spinning:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy9",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxya"}},defaultVariants:{disabled:!1,kind:"default",spinning:!1},compoundVariants:[[{kind:"icon",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyb"],[{kind:"default",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyc"],[{kind:"confirm",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyd"],[{kind:"delete",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxye"],[{kind:"key",spinning:!0},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyf"],[{disabled:!0,spinning:!1},"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyg"]]}),gt=te({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyh",variantClassNames:{disabled:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyi",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyj"},kind:{icon:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyk",default:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyl",delete:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxym",key:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyn",confirm:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyo",link:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyp"},spinning:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyq",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyr"}},defaultVariants:{disabled:!1,kind:"default",spinning:!1},compoundVariants:[]}),vt="pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy11",ht=te({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy12",variantClassNames:{spinning:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy13",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy14"}},defaultVariants:{spinning:!1},compoundVariants:[]}),yt=te({defaultClassName:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxys",variantClassNames:{spinning:{true:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyt",false:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyu"},kind:{icon:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyv",default:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyw",delete:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyx",key:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyy",confirm:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxyz",link:"pkg_sps-woodland_buttons__version_8_21_0__hash_125pcxy10"}},defaultVariants:{spinning:!1},compoundVariants:[]});function kt({as:e,onClick:t,onPress:r,children:o,className:a,isDisabled:d,disabled:u,href:p,icon:m,kind:v="default",spinning:b,spinningTitle:P,title:S,..._},x){const T=e??(p?"a":"button"),E={onPress:r??t,isDisabled:u??d??b,..._},{"data-testid":N}=_,$=x||c.useRef(null),{buttonProps:w}=ft(E,$),{hoverProps:D}=pt({isDisabled:E.isDisabled}),{type:O,...M}=w,ne={...W(M,D),ref:$,title:S,className:p?yt({spinning:b,kind:v}):gt({disabled:d||u,kind:v,spinning:b}),...p?{href:p}:{type:O},..._},{t:n}=c.useContext(G.I18nContext),f=m&&c.createElement(G.Icon,{className:vt,icon:m,"aria-hidden":"true","data-testid":`${N}__${m}-icon`});let B;v==="default"||v==="icon"||v==="link"?B="dark":B="light";const l=b&&c.createElement(G.Spinner,{color:B,className:ht({spinning:b}),title:P||n("design-system:button.spinningTitle"),"data-testid":`${N}__spinner`});return c.createElement(Ee.FocusRing,null,c.createElement("div",{className:G.cl(bt({disabled:d||u,kind:v,spinning:b}),a)},c.createElement(T,{...ne},f,o?c.createElement("span",null,o):"",l)))}const pe=c.forwardRef(kt);G.Metadata.set(pe,{name:"Button",props:{disabled:"boolean",href:"string",icon:"IconName",kind:{type:'"default" | "link" | "icon" | "confirm" | "delete" | "key"',default:'"default"'},spinning:"boolean",spinningTitle:"string",type:{type:'"button" | "submit"',default:'"button"'}},panellable:!0});const wt={components:[pe],description:()=>c.createElement(c.Fragment,null,c.createElement("div",{className:"sps-body-14"},"Buttons are used to initiate events or actions. The labels and/or icons describe what the button will do."),c.createElement("br",null),c.createElement("h5",null,"Variants"),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Default: "),"For tertiary actions or actions of lower importance on a page."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Key: "),"For primary or important actions on a page."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Confirm: "),"For the main call to action on a page. There should only be one Confirm button per screen."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Delete: "),"For deleting information or another destructive action. These should always be paired with a Delete Confirmation Modal."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"Disabled: "),"For actions that are not permitted in a particular state. These can be accompanied by a Tooltip on hover describing why it’s disabled."),c.createElement("div",{className:"sps-body-14"},c.createElement("span",{className:"sps-text-semibold"},"With an Icon: "),"For further illustrating the action. Example: Pencil icon in an Edit button. There can also be Icon Buttons without text.")),examples:{basic:{label:"Basic Buttons",description:({NavigateTo:e})=>c.createElement(c.Fragment,null,c.createElement("p",null,"The most common type of button that can be used in most cases. Example: Basic Buttons in a ",c.createElement(e,{to:"modals"},"Modal"),".")),examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
2
|
-
import { Button } from "@sps-woodland/buttons";
|
3
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
4
|
-
|
5
|
-
function Component() {
|
6
|
-
return (
|
7
|
-
<>
|
8
|
-
<Button className={sprinkles({ mr: "xs" })}>Default</Button>
|
9
|
-
<Button className={sprinkles({ mr: "xs" })} kind="key">Key</Button>
|
10
|
-
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Confirm</Button>
|
11
|
-
<Button className={sprinkles({ mr: "xs" })} kind="delete">Delete</Button>
|
12
|
-
<Button disabled>Disabled</Button>
|
13
|
-
</>
|
14
|
-
)
|
15
|
-
}
|
16
|
-
`},withIcons:{description:"With Icons",react:y.code`
|
17
|
-
import { Button } from "@sps-woodland/buttons";
|
18
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
19
|
-
|
20
|
-
function Component() {
|
21
|
-
return (
|
22
|
-
<>
|
23
|
-
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud">Default</Button>
|
24
|
-
<Button className={sprinkles({ mr: "xs" })} icon="key" kind="key">Key</Button>
|
25
|
-
<Button className={sprinkles({ mr: "xs" })} icon="download-cloud" kind="confirm">Confirm</Button>
|
26
|
-
<Button className={sprinkles({ mr: "xs" })} icon="trash" kind="delete">Delete</Button>
|
27
|
-
<Button icon="download-cloud" disabled>Disabled</Button>
|
28
|
-
</>
|
29
|
-
)
|
30
|
-
}
|
31
|
-
`},spinning:{description:"Spinning",react:y.code`
|
32
|
-
import { Button } from "@sps-woodland/buttons";
|
33
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
34
|
-
|
35
|
-
function Component() {
|
36
|
-
return (
|
37
|
-
<>
|
38
|
-
<Button className={sprinkles({ mr: "xs" })} spinning>Default</Button>
|
39
|
-
<Button className={sprinkles({ mr: "xs" })} spinning kind="key">Key</Button>
|
40
|
-
<Button className={sprinkles({ mr: "xs" })} spinning kind="confirm">Confirm</Button>
|
41
|
-
<Button spinning kind="delete">Delete</Button>
|
42
|
-
</>
|
43
|
-
)
|
44
|
-
}
|
45
|
-
`}}},dropdown:{label:"Dropdown Buttons",description:"Use these for actions that need to select an option to proceed. Example: Download button with optiosn related to the file format (PDF, PPT, etc.).",examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
46
|
-
import { SpsDropdown } from "@spscommerce/ds-react";
|
47
|
-
|
48
|
-
function Component() {
|
49
|
-
return (
|
50
|
-
<>
|
51
|
-
<SpsDropdown
|
52
|
-
className="mr-1 mb-1"
|
53
|
-
label="Default"
|
54
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
55
|
-
/>
|
56
|
-
<SpsDropdown
|
57
|
-
className="mr-1 mb-1"
|
58
|
-
kind={ButtonKind.KEY}
|
59
|
-
label="Key"
|
60
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
61
|
-
/>
|
62
|
-
<SpsDropdown
|
63
|
-
className="mr-1 mb-1"
|
64
|
-
kind={ButtonKind.CONFIRM}
|
65
|
-
label="Confirm"
|
66
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
67
|
-
/>
|
68
|
-
<SpsDropdown
|
69
|
-
className="mr-1 mb-1"
|
70
|
-
kind={ButtonKind.DELETE}
|
71
|
-
label="Delete"
|
72
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
73
|
-
/>
|
74
|
-
<SpsDropdown
|
75
|
-
className="mr-1 mb-1"
|
76
|
-
disabled
|
77
|
-
label="Disabled"
|
78
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
79
|
-
/>
|
80
|
-
</>
|
81
|
-
)
|
82
|
-
}
|
83
|
-
`},withIcons:{description:"With Icons",react:y.code`
|
84
|
-
import { SpsDropdown } from "@spscommerce/ds-react";
|
85
|
-
|
86
|
-
function Component() {
|
87
|
-
return (
|
88
|
-
<>
|
89
|
-
<SpsDropdown
|
90
|
-
className="mr-1 mb-1"
|
91
|
-
icon={SpsIcon.DOWNLOAD_CLOUD}
|
92
|
-
label="Default"
|
93
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
94
|
-
/>
|
95
|
-
<SpsDropdown
|
96
|
-
className="mr-1 mb-1"
|
97
|
-
icon={SpsIcon.DOWNLOAD_CLOUD}
|
98
|
-
kind={ButtonKind.KEY}
|
99
|
-
label="Key"
|
100
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
101
|
-
/>
|
102
|
-
<SpsDropdown
|
103
|
-
className="mr-1 mb-1"
|
104
|
-
icon={SpsIcon.DOWNLOAD_CLOUD}
|
105
|
-
kind={ButtonKind.CONFIRM}
|
106
|
-
label="Confirm"
|
107
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
108
|
-
/>
|
109
|
-
<SpsDropdown
|
110
|
-
className="mr-1 mb-1"
|
111
|
-
icon={SpsIcon.TRASH}
|
112
|
-
kind={ButtonKind.DELETE}
|
113
|
-
label="Delete"
|
114
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
115
|
-
/>
|
116
|
-
<SpsDropdown
|
117
|
-
className="mr-1 mb-1"
|
118
|
-
icon={SpsIcon.DOWNLOAD_CLOUD}
|
119
|
-
disabled
|
120
|
-
label="Disabled"
|
121
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
122
|
-
/>
|
123
|
-
</>
|
124
|
-
)
|
125
|
-
}
|
126
|
-
`},spinning:{description:"Spinning",react:y.code`
|
127
|
-
import { SpsDropdown } from "@spscommerce/ds-react";
|
128
|
-
|
129
|
-
function Component() {
|
130
|
-
return (
|
131
|
-
<>
|
132
|
-
<SpsDropdown
|
133
|
-
spinning
|
134
|
-
className="mr-1 mb-1"
|
135
|
-
label="Default"
|
136
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
137
|
-
/>
|
138
|
-
<SpsDropdown
|
139
|
-
spinning
|
140
|
-
className="mr-1 mb-1"
|
141
|
-
kind={ButtonKind.KEY}
|
142
|
-
label="Key"
|
143
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
144
|
-
/>
|
145
|
-
<SpsDropdown
|
146
|
-
spinning
|
147
|
-
className="mr-1 mb-1"
|
148
|
-
kind={ButtonKind.CONFIRM}
|
149
|
-
label="Confirm"
|
150
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
151
|
-
/>
|
152
|
-
<SpsDropdown
|
153
|
-
spinning
|
154
|
-
className="mr-1 mb-1"
|
155
|
-
kind={ButtonKind.DELETE}
|
156
|
-
label="Delete"
|
157
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
158
|
-
/>
|
159
|
-
</>
|
160
|
-
)
|
161
|
-
}
|
162
|
-
`}}},splitButtons:{label:"Split Buttons",description:"Use when there is 1 primary action and other related actions can be taken.",examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
163
|
-
import { SpsSplitButton } from "@spscommerce/ds-react";
|
164
|
-
|
165
|
-
function Component() {
|
166
|
-
return (
|
167
|
-
<>
|
168
|
-
<SpsSplitButton className="mr-1 mb-1" label="Default" />
|
169
|
-
<SpsSplitButton
|
170
|
-
className="mr-1 mb-1"
|
171
|
-
kind={ButtonKind.KEY}
|
172
|
-
label="Key"
|
173
|
-
/>
|
174
|
-
<SpsSplitButton
|
175
|
-
className="mr-1 mb-1"
|
176
|
-
kind={ButtonKind.CONFIRM}
|
177
|
-
label="Confirm"
|
178
|
-
/>
|
179
|
-
<SpsSplitButton
|
180
|
-
className="mr-1 mb-1"
|
181
|
-
kind={ButtonKind.DELETE}
|
182
|
-
label="Delete"
|
183
|
-
/>
|
184
|
-
<SpsSplitButton className="mr-1 mb-1" disabled label="Disabled" />
|
185
|
-
</>
|
186
|
-
)
|
187
|
-
}
|
188
|
-
`},withIcons:{description:"With Icons",react:y.code`
|
189
|
-
import { SpsSplitButton } from "@spscommerce/ds-react";
|
190
|
-
|
191
|
-
function Component() {
|
192
|
-
return (
|
193
|
-
<>
|
194
|
-
<SpsSplitButton
|
195
|
-
className="mr-1 mb-1"
|
196
|
-
icon={SpsIcon.PLUS_SIGN}
|
197
|
-
label="Default"
|
198
|
-
/>
|
199
|
-
<SpsSplitButton
|
200
|
-
className="mr-1 mb-1"
|
201
|
-
icon={SpsIcon.PLUS_SIGN}
|
202
|
-
kind={ButtonKind.KEY}
|
203
|
-
label="Key"
|
204
|
-
/>
|
205
|
-
<SpsSplitButton
|
206
|
-
className="mr-1 mb-1"
|
207
|
-
icon={SpsIcon.PLUS_SIGN}
|
208
|
-
kind={ButtonKind.CONFIRM}
|
209
|
-
label="Confirm"
|
210
|
-
/>
|
211
|
-
<SpsSplitButton
|
212
|
-
className="mr-1 mb-1"
|
213
|
-
icon={SpsIcon.PLUS_SIGN}
|
214
|
-
kind={ButtonKind.DELETE}
|
215
|
-
label="Delete"
|
216
|
-
/>
|
217
|
-
<SpsSplitButton
|
218
|
-
className="mr-1 mb-1"
|
219
|
-
icon={SpsIcon.PLUS_SIGN}
|
220
|
-
disabled
|
221
|
-
label="Disabled"
|
222
|
-
/>
|
223
|
-
</>
|
224
|
-
)
|
225
|
-
}
|
226
|
-
`}}},iconButtons:{label:"Icon Buttons",description:({NavigateTo:e,Link:t})=>c.createElement(c.Fragment,null,c.createElement("p",null,"Use these for quick actions that can clearly be articulated by the use of an icon. Example: A Print button in the"," ",c.createElement(e,{to:"list-action-bar"},"List Action Bar"),". Do not use an icon that doesn't have a universally understood meaning; instead use a Basic Button or a Basic Button with an icon. ",c.createElement(t,{to:"/style-and-layout/icons/"},"View All Icons"))),examples:{standard:{description:"Standard Icon Buttons",react:y.code`
|
227
|
-
import { Button } from "@sps-woodland/buttons";
|
228
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
229
|
-
|
230
|
-
function Component() {
|
231
|
-
return (
|
232
|
-
<>
|
233
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="printer" />
|
234
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="pencil" />
|
235
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="x" />
|
236
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="trash" />
|
237
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="gear" />
|
238
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="download-cloud" />
|
239
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="search" />
|
240
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="plus-sign" />
|
241
|
-
<Button className={sprinkles({ mr: "xs" })} kind="icon" icon="minus" />
|
242
|
-
</>
|
243
|
-
)
|
244
|
-
}
|
245
|
-
`},dropdown:{description:({NavigateTo:e})=>c.createElement(c.Fragment,null,c.createElement("h5",null,"Dropdown Icon Buttons"),c.createElement("p",null,"Use these when there are several options available for action. Example: Dropdown Icon Button in a ",c.createElement(e,{to:"content-rows"},"Content Row"),".")),react:y.code`
|
246
|
-
import { SpsDropdown } from "@spscommerce/ds-react";
|
247
|
-
|
248
|
-
function Component() {
|
249
|
-
return (
|
250
|
-
<>
|
251
|
-
<SpsDropdown
|
252
|
-
className="mr-1 mb-1"
|
253
|
-
kind={ButtonKind.ICON}
|
254
|
-
options={[[{ label: "Option A" }, () => console.log("Option A")]]}
|
255
|
-
/>
|
256
|
-
</>
|
257
|
-
)
|
258
|
-
}
|
259
|
-
`},spinner:{description:"Spinner",react:y.code`
|
260
|
-
import { Button } from "@sps-woodland/buttons";
|
261
|
-
|
262
|
-
function Component() {
|
263
|
-
return (
|
264
|
-
<>
|
265
|
-
<Button kind="icon" icon="download-cloud" spinning />
|
266
|
-
</>
|
267
|
-
)
|
268
|
-
}
|
269
|
-
`}}},textButtons:{label:"Text Buttons",description:({NavigateTo:e})=>c.createElement("p",null,"Use for less important actions, or ones that aren't taken as frequently. They should not appear inline with other copy. Example: Advanced Search button in the"," ",c.createElement(e,{to:"list-toolbar"},"List Toolbar")),examples:{withoutIcons:{description:"Without Icons",react:y.code`
|
270
|
-
import { Button } from "@sps-woodland/buttons";
|
271
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
272
|
-
|
273
|
-
function Component() {
|
274
|
-
return (
|
275
|
-
<>
|
276
|
-
<Button className={sprinkles({ mr: "sm" })} kind="link">Default</Button>
|
277
|
-
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link">Delete</Button>
|
278
|
-
<Button className={sprinkles({ mr: "sm" })} kind="link" disabled>Disabled</Button>
|
279
|
-
</>
|
280
|
-
)
|
281
|
-
}
|
282
|
-
`},withIcons:{description:"With Icons",react:y.code`
|
283
|
-
import { Button } from "@sps-woodland/buttons";
|
284
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
285
|
-
|
286
|
-
function Component() {
|
287
|
-
return (
|
288
|
-
<>
|
289
|
-
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="download-cloud">Default</Button>
|
290
|
-
<Button className={sprinkles({ mr: "sm", color: "red-medium" })} kind="link" icon="trash">Delete</Button>
|
291
|
-
<Button className={sprinkles({ mr: "sm" })} kind="link" icon="gear" disabled>Disabled</Button>
|
292
|
-
</>
|
293
|
-
)
|
294
|
-
}
|
295
|
-
`},spinner:{description:"Spinner",react:y.code`
|
296
|
-
import { Button } from "@sps-woodland/buttons";
|
297
|
-
|
298
|
-
function Component() {
|
299
|
-
return (
|
300
|
-
<>
|
301
|
-
<Button kind="link" spinning>Default</Button>
|
302
|
-
</>
|
303
|
-
)
|
304
|
-
}
|
305
|
-
`}}},submitButtons:{label:"Submit Buttons",description:({NavigateTo:e})=>c.createElement("p",null,"Use to submit a form. There can be a number of visual variations, for example a"," ",c.createElement(e,{to:"modals"},"Modal")," uses Basic Button (Key) as its Submit Button."),examples:{basic:{react:y.code`
|
306
|
-
import { Button } from "@sps-woodland/buttons";
|
307
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
308
|
-
|
309
|
-
function Component() {
|
310
|
-
const { formMeta, formValue, updateForm } = useSpsForm({});
|
311
|
-
|
312
|
-
function alertOnSubmit() {
|
313
|
-
window.alert("Form submitted");
|
314
|
-
}
|
315
|
-
|
316
|
-
return (
|
317
|
-
<SpsForm formMeta={formMeta} onSubmit={alertOnSubmit}>
|
318
|
-
{/* Use only one Submit button in your form */}
|
319
|
-
<Button className={sprinkles({ mr: "xs" })} type="submit" kind="key">Key</Button>
|
320
|
-
<Button type="submit" kind="confirm">Confirm</Button>
|
321
|
-
</SpsForm>
|
322
|
-
)
|
323
|
-
}
|
324
|
-
`}}},link:{label:"Button as a Link",description:"Used to link to another page, such as an external website. They may open in the same window or in a new one. It should only be used when a Text Button doesn't provide enough visual emphasis.",examples:{basic:{react:y.code`
|
325
|
-
import { Button } from "@sps-woodland/buttons";
|
326
|
-
|
327
|
-
function Component() {
|
328
|
-
return (
|
329
|
-
<>
|
330
|
-
<Button kind="default" href="https://google.com">
|
331
|
-
Button Text
|
332
|
-
</Button>
|
333
|
-
</>
|
334
|
-
)
|
335
|
-
}
|
336
|
-
`}}},buttonGroups:{label:"Button Groups",description:({NavigateTo:e})=>c.createElement("p",null,"Use button groups when there are a number of actions that can be taken in a view. When there are multiple button types in a group, they are separated using dividers. Example: Button groups in ",c.createElement(e,{to:"List Action Bar"},"List Action Bar"),"."),examples:{basic:{description:"Basic Button Groups",react:y.code`
|
337
|
-
import { Button } from "@sps-woodland/buttons";
|
338
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
339
|
-
|
340
|
-
function Component() {
|
341
|
-
return (
|
342
|
-
<>
|
343
|
-
<Button className={sprinkles({ mr: "xs" })}>Cancel</Button>
|
344
|
-
<Button className={sprinkles({ mr: "xs" })} kind="key">Save</Button>
|
345
|
-
</>
|
346
|
-
)
|
347
|
-
}
|
348
|
-
`},icon:{description:"Icon Button Groups",react:y.code`
|
349
|
-
import { Button } from "@sps-woodland/buttons";
|
350
|
-
|
351
|
-
function Component() {
|
352
|
-
return (
|
353
|
-
<>
|
354
|
-
<Button kind="icon" icon="pencil" />
|
355
|
-
<Button kind="icon" icon="trash" />
|
356
|
-
</>
|
357
|
-
)
|
358
|
-
}
|
359
|
-
`},textAndIcons:{description:"Text Buttons + Icon Buttons Group",react:y.code`
|
360
|
-
import { Button } from "@sps-woodland/buttons";
|
361
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
362
|
-
import { VericalRule } from "@sps-woodland/core";
|
363
|
-
|
364
|
-
function Component() {
|
365
|
-
return (
|
366
|
-
<>
|
367
|
-
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
368
|
-
<VerticalRule />
|
369
|
-
<Button kind="icon" icon="download-cloud" />
|
370
|
-
<Button kind="icon" icon="printer" />
|
371
|
-
</>
|
372
|
-
)
|
373
|
-
}
|
374
|
-
`},textAndBasic:{description:"Text Buttons + Basic Buttons Group",react:y.code`
|
375
|
-
import { Button } from "@sps-woodland/buttons";
|
376
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
377
|
-
import { VericalRule } from "@sps-woodland/core";
|
378
|
-
|
379
|
-
function Component() {
|
380
|
-
return (
|
381
|
-
<>
|
382
|
-
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
383
|
-
<VerticalRule />
|
384
|
-
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
385
|
-
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
386
|
-
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
387
|
-
</>
|
388
|
-
)
|
389
|
-
}
|
390
|
-
`},iconsAndBasic:{description:"Icon Buttons + Basic Buttons Group",react:y.code`
|
391
|
-
import { Button } from "@sps-woodland/buttons";
|
392
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
393
|
-
import { VericalRule } from "@sps-woodland/core";
|
394
|
-
|
395
|
-
function Component() {
|
396
|
-
return (
|
397
|
-
<>
|
398
|
-
<Button kind="icon" icon="download-cloud" />
|
399
|
-
<Button kind="icon" icon="printer" />
|
400
|
-
<VerticalRule />
|
401
|
-
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
402
|
-
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
403
|
-
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
404
|
-
</>
|
405
|
-
)
|
406
|
-
}
|
407
|
-
`},textIconsAndBasic:{description:"Text Buttons + Icon Buttons + Basic Buttons Group",react:y.code`
|
408
|
-
import { Button } from "@sps-woodland/buttons";
|
409
|
-
import { sprinkles } from "@sps-woodland/tokens";
|
410
|
-
import { VericalRule } from "@sps-woodland/core";
|
411
|
-
|
412
|
-
function Component() {
|
413
|
-
return (
|
414
|
-
<>
|
415
|
-
<Button className={sprinkles({ mr: "xs" })} kind="link">Text Button</Button>
|
416
|
-
<VerticalRule />
|
417
|
-
<Button kind="icon" icon="download-cloud" />
|
418
|
-
<Button kind="icon" icon="printer" />
|
419
|
-
<VerticalRule />
|
420
|
-
<Button className={sprinkles({ ml: "xs", mr: "xs" })} kind="default">Button</Button>
|
421
|
-
<Button className={sprinkles({ mr: "xs" })} kind="key">Button</Button>
|
422
|
-
<Button className={sprinkles({ mr: "xs" })} kind="confirm">Button</Button>
|
423
|
-
</>
|
424
|
-
)
|
425
|
-
}
|
426
|
-
`}}}}},Tt={Buttons:wt};exports.Button=pe;exports.MANIFEST=Tt;
|