@metricshift/react 1.0.1 → 1.0.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/dist/index.esm.js +34 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +9 -9
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(T,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],S):(T=typeof globalThis<"u"?globalThis:T||self,S(T.MetricShiftReact={},T.React))})(this,function(T,S){"use strict";var te={exports:{}},
|
|
1
|
+
(function(T,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],S):(T=typeof globalThis<"u"?globalThis:T||self,S(T.MetricShiftReact={},T.React))})(this,function(T,S){"use strict";var te={exports:{}},H={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var ge;function Ne(){if(ge)return
|
|
9
|
+
*/var ge;function Ne(){if(ge)return H;ge=1;var d=S,j=Symbol.for("react.element"),I=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,p=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function M(E,b,P){var h,R={},v=null,W=null;P!==void 0&&(v=""+P),b.key!==void 0&&(v=""+b.key),b.ref!==void 0&&(W=b.ref);for(h in b)f.call(b,h)&&!o.hasOwnProperty(h)&&(R[h]=b[h]);if(E&&E.defaultProps)for(h in b=E.defaultProps,b)R[h]===void 0&&(R[h]=b[h]);return{$$typeof:j,type:E,key:v,ref:W,props:R,_owner:p.current}}return H.Fragment=I,H.jsx=M,H.jsxs=M,H}var K={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ye;function Ue(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&function(){var d=S,j=Symbol.for("react.element"),I=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),E=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),
|
|
18
|
-
`+ue+e}}var ce=!1
|
|
17
|
+
*/var ye;function Ue(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&function(){var d=S,j=Symbol.for("react.element"),I=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),E=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),z=Symbol.iterator,O="@@iterator";function N(e){if(e===null||typeof e!="object")return null;var r=z&&e[z]||e[O];return typeof r=="function"?r:null}var F=d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];U("error",e,t)}}function U(e,r,t){{var a=F.ReactDebugCurrentFrame,u=a.getStackAddendum();u!==""&&(r+="%s",t=t.concat([u]));var c=t.map(function(l){return String(l)});c.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,c)}}var i=!1,w=!1,Q=!1,ae=!1,oe=!1,Z;Z=Symbol.for("react.module.reference");function ie(e){return!!(typeof e=="string"||typeof e=="function"||e===f||e===o||oe||e===p||e===P||e===h||ae||e===W||i||w||Q||typeof e=="object"&&e!==null&&(e.$$typeof===v||e.$$typeof===R||e.$$typeof===M||e.$$typeof===E||e.$$typeof===b||e.$$typeof===Z||e.getModuleId!==void 0))}function G(e,r,t){var a=e.displayName;if(a)return a;var u=r.displayName||r.name||"";return u!==""?t+"("+u+")":t}function se(e){return e.displayName||"Context"}function D(e){if(e==null)return null;if(typeof e.tag=="number"&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case I:return"Portal";case o:return"Profiler";case p:return"StrictMode";case P:return"Suspense";case h:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case E:var r=e;return se(r)+".Consumer";case M:var t=e;return se(t._context)+".Provider";case b:return G(e,e.render,"ForwardRef");case R:var a=e.displayName||null;return a!==null?a:D(e.type)||"Memo";case v:{var u=e,c=u._payload,l=u._init;try{return D(l(c))}catch{return null}}}return null}var A=Object.assign,g=0,Y,B,Se,Ee,Re,ke,_e;function je(){}je.__reactDisabledLog=!0;function Ge(){{if(g===0){Y=console.log,B=console.info,Se=console.warn,Ee=console.error,Re=console.group,ke=console.groupCollapsed,_e=console.groupEnd;var e={configurable:!0,enumerable:!0,value:je,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}g++}}function Xe(){{if(g--,g===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:Y}),info:A({},e,{value:B}),warn:A({},e,{value:Se}),error:A({},e,{value:Ee}),group:A({},e,{value:Re}),groupCollapsed:A({},e,{value:ke}),groupEnd:A({},e,{value:_e})})}g<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var le=F.ReactCurrentDispatcher,ue;function $(e,r,t){{if(ue===void 0)try{throw Error()}catch(u){var a=u.stack.trim().match(/\n( *(at )?)/);ue=a&&a[1]||""}return`
|
|
18
|
+
`+ue+e}}var ce=!1,q;{var Qe=typeof WeakMap=="function"?WeakMap:Map;q=new Qe}function we(e,r){if(!e||ce)return"";{var t=q.get(e);if(t!==void 0)return t}var a;ce=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var c;c=le.current,le.current=null,Ge();try{if(r){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(_){a=_}Reflect.construct(e,[],l)}else{try{l.call()}catch(_){a=_}e.call(l.prototype)}}else{try{throw Error()}catch(_){a=_}e()}}catch(_){if(_&&a&&typeof _.stack=="string"){for(var s=_.stack.split(`
|
|
19
19
|
`),k=a.stack.split(`
|
|
20
20
|
`),y=s.length-1,m=k.length-1;y>=1&&m>=0&&s[y]!==k[m];)m--;for(;y>=1&&m>=0;y--,m--)if(s[y]!==k[m]){if(y!==1||m!==1)do if(y--,m--,m<0||s[y]!==k[m]){var C=`
|
|
21
|
-
`+s[y].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"
|
|
21
|
+
`+s[y].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,C),C}while(y>=1&&m>=0);break}}}finally{ce=!1,le.current=c,Xe(),Error.prepareStackTrace=u}var J=e?e.displayName||e.name:"",L=J?$(J):"";return typeof e=="function"&&q.set(e,L),L}function Ze(e,r,t){return we(e,!1)}function $e(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function ee(e,r,t){if(e==null)return"";if(typeof e=="function")return we(e,$e(e));if(typeof e=="string")return $(e);switch(e){case P:return $("Suspense");case h:return $("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case b:return Ze(e.render);case R:return ee(e.type,r,t);case v:{var a=e,u=a._payload,c=a._init;try{return ee(c(u),r,t)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,Te={},Ce=F.ReactDebugCurrentFrame;function re(e){if(e){var r=e._owner,t=ee(e.type,e._source,r?r.type:null);Ce.setExtraStackFrame(t)}else Ce.setExtraStackFrame(null)}function qe(e,r,t,a,u){{var c=Function.call.bind(X);for(var l in e)if(c(e,l)){var s=void 0;try{if(typeof e[l]!="function"){var k=Error((a||"React class")+": "+t+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw k.name="Invariant Violation",k}s=e[l](r,l,a,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){s=y}s&&!(s instanceof Error)&&(re(u),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",a||"React class",t,l,typeof s),re(null)),s instanceof Error&&!(s.message in Te)&&(Te[s.message]=!0,re(u),x("Failed %s type: %s",t,s.message),re(null))}}}var er=Array.isArray;function fe(e){return er(e)}function rr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function tr(e){try{return Pe(e),!1}catch{return!0}}function Pe(e){return""+e}function Oe(e){if(tr(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rr(e)),Pe(e)}var Fe=F.ReactCurrentOwner,nr={key:!0,ref:!0,__self:!0,__source:!0},Ie,Me;function ar(e){if(X.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function or(e){if(X.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ir(e,r){typeof e.ref=="string"&&Fe.current}function sr(e,r){{var t=function(){Ie||(Ie=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function lr(e,r){{var t=function(){Me||(Me=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ur=function(e,r,t,a,u,c,l){var s={$$typeof:j,type:e,key:r,ref:t,props:l,_owner:c};return s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s};function cr(e,r,t,a,u){{var c,l={},s=null,k=null;t!==void 0&&(Oe(t),s=""+t),or(r)&&(Oe(r.key),s=""+r.key),ar(r)&&(k=r.ref,ir(r,u));for(c in r)X.call(r,c)&&!nr.hasOwnProperty(c)&&(l[c]=r[c]);if(e&&e.defaultProps){var y=e.defaultProps;for(c in y)l[c]===void 0&&(l[c]=y[c])}if(s||k){var m=typeof e=="function"?e.displayName||e.name||"Unknown":e;s&&sr(l,m),k&&lr(l,m)}return ur(e,s,k,u,a,Fe.current,l)}}var de=F.ReactCurrentOwner,De=F.ReactDebugCurrentFrame;function V(e){if(e){var r=e._owner,t=ee(e.type,e._source,r?r.type:null);De.setExtraStackFrame(t)}else De.setExtraStackFrame(null)}var pe;pe=!1;function ve(e){return typeof e=="object"&&e!==null&&e.$$typeof===j}function ze(){{if(de.current){var e=D(de.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function fr(e){return""}var
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function fr(e){return""}var Ae={};function dr(e){{var r=ze();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+t+">.")}return r}}function We(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=dr(r);if(
|
|
25
|
+
Check the top-level render call using <`+t+">.")}return r}}function We(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=dr(r);if(Ae[t])return;Ae[t]=!0;var a="";e&&e._owner&&e._owner!==de.current&&(a=" It was passed a child from "+D(e._owner.type)+"."),V(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,a),V(null)}}function Ye(e,r){{if(typeof e!="object")return;if(fe(e))for(var t=0;t<e.length;t++){var a=e[t];ve(a)&&We(a,r)}else if(ve(e))e._store&&(e._store.validated=!0);else if(e){var u=N(e);if(typeof u=="function"&&u!==e.entries)for(var c=u.call(e),l;!(l=c.next()).done;)ve(l.value)&&We(l.value,r)}}}function pr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===b||r.$$typeof===R))t=r.propTypes;else return;if(t){var a=D(r);qe(t,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!pe){pe=!0;var u=D(r);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function vr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var a=r[t];if(a!=="children"&&a!=="key"){V(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),V(null);break}}e.ref!==null&&(V(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}var Be={};function Le(e,r,t,a,u,c){{var l=ie(e);if(!l){var s="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(s+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var k=fr();k?s+=k:s+=ze();var y;e===null?y="null":fe(e)?y="array":e!==void 0&&e.$$typeof===j?(y="<"+(D(e.type)||"Unknown")+" />",s=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,s)}var m=cr(e,r,t,u,c);if(m==null)return m;if(l){var C=r.children;if(C!==void 0)if(a)if(fe(C)){for(var J=0;J<C.length;J++)Ye(C[J],e);Object.freeze&&Object.freeze(C)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ye(C,e)}if(X.call(r,"key")){var L=D(e),_=Object.keys(r).filter(function(mr){return mr!=="key"}),be=_.length>0?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}";if(!Be[L+be]){var xr=_.length>0?"{"+_.join(": ..., ")+": ...}":"{}";x(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,be,L,xr,L),Be[L+be]=!0}}return e===f?vr(m):pr(m),m}}function br(e,r,t){return Le(e,r,t,!0)}function gr(e,r,t){return Le(e,r,t,!1)}var yr=gr,hr=br;
|
|
30
|
+
<%s key={someKey} {...props} />`,be,L,xr,L),Be[L+be]=!0}}return e===f?vr(m):pr(m),m}}function br(e,r,t){return Le(e,r,t,!0)}function gr(e,r,t){return Le(e,r,t,!1)}var yr=gr,hr=br;K.Fragment=f,K.jsx=yr,K.jsxs=hr}()),K}process.env.NODE_ENV==="production"?te.exports=Ne():te.exports=Ue();var n=te.exports;const he=({isOpen:d,onClose:j,onSubmit:I})=>{const[f,p]=S.useState({text:"",rating:void 0,feedbackType:"general",userEmail:"",userName:""}),[o,M]=S.useState(!1),[E,b]=S.useState("idle"),[P,h]=S.useState(""),[R,v]=S.useState(!1),W=S.useRef(null),z=S.useRef(null);S.useEffect(()=>(d?(v(!0),document.body.style.overflow="hidden",setTimeout(()=>{var i;(i=z.current)==null||i.focus()},150)):document.body.style.overflow="unset",()=>{document.body.style.overflow="unset"}),[d]),S.useEffect(()=>{const i=w=>{w.key==="Escape"&&d&&!o&&O()};return d&&document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[d,o]);const O=()=>{v(!1),setTimeout(()=>{j(),setTimeout(()=>{p({text:"",rating:void 0,feedbackType:"general",userEmail:"",userName:""}),b("idle"),h("")},100)},200)},N=async i=>{if(i.preventDefault(),!f.text.trim()){h("Please enter your feedback");return}M(!0),h("");try{await I(f),b("success"),setTimeout(()=>{O()},2e3)}catch(w){b("error"),h(w instanceof Error?w.message:"Failed to submit feedback")}finally{M(!1)}};if(!d)return null;const F=i=>{i.target===i.currentTarget&&!o&&O()},x={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4,padding:"16px",opacity:R?1:0,transition:"opacity 0.2s ease-in-out"},U={backgroundColor:"white",borderRadius:"12px",padding:"24px",maxWidth:"500px",width:"100%",maxHeight:"90vh",overflowY:"auto",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",transform:R?"scale(1)":"scale(0.95)",opacity:R?1:0,transition:"all 0.2s ease-in-out"};return n.jsx("div",{onClick:F,style:x,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-modal-title",children:n.jsxs("div",{ref:W,style:U,onClick:i=>i.stopPropagation(),children:[n.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("h2",{id:"feedback-modal-title",style:{fontSize:"20px",fontWeight:"600",margin:0,color:"#111827"},children:"Send Feedback"}),n.jsx("button",{onClick:O,disabled:o,"aria-label":"Close feedback form",style:{background:"none",border:"none",fontSize:"24px",cursor:o?"not-allowed":"pointer",color:"#6b7280",padding:"0",lineHeight:"1",opacity:o?.5:1,transition:"color 0.2s"},onMouseEnter:i=>!o&&(i.currentTarget.style.color="#111827"),onMouseLeave:i=>!o&&(i.currentTarget.style.color="#6b7280"),children:"×"})]}),E==="success"&&n.jsxs("div",{style:{backgroundColor:"#d1fae5",border:"1px solid #6ee7b7",borderRadius:"8px",padding:"12px",marginBottom:"16px",color:"#065f46",display:"flex",alignItems:"center",gap:"8px",animation:"slideIn 0.3s ease-out"},role:"status","aria-live":"polite",children:[n.jsx("span",{style:{fontSize:"18px"},children:"✓"}),n.jsx("span",{children:"Thank you! Your feedback has been submitted."})]}),P&&n.jsxs("div",{style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5",borderRadius:"8px",padding:"12px",marginBottom:"16px",color:"#991b1b",display:"flex",alignItems:"center",gap:"8px"},role:"alert","aria-live":"assertive",children:[n.jsx("span",{style:{fontSize:"18px"},children:"⚠"}),n.jsx("span",{children:P})]}),n.jsxs("form",{onSubmit:N,children:[n.jsxs("div",{style:{marginBottom:"16px"},children:[n.jsx("label",{htmlFor:"feedback-type",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500",color:"#374151"},children:"Type"}),n.jsxs("select",{id:"feedback-type",value:f.feedbackType,onChange:i=>p({...f,feedbackType:i.target.value}),disabled:o,style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",fontSize:"14px",backgroundColor:"white",cursor:o?"not-allowed":"pointer",opacity:o?.6:1},children:[n.jsx("option",{value:"general",children:"General Feedback"}),n.jsx("option",{value:"bug",children:"Bug Report"}),n.jsx("option",{value:"feature_request",children:"Feature Request"}),n.jsx("option",{value:"question",children:"Question"}),n.jsx("option",{value:"praise",children:"Praise"})]})]}),n.jsxs("div",{style:{marginBottom:"16px"},children:[n.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500",color:"#374151"},children:"Rating (optional)"}),n.jsx("div",{style:{display:"flex",gap:"8px"},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(i=>n.jsx("button",{type:"button",onClick:()=>p({...f,rating:i}),disabled:o,"aria-label":`Rate ${i} stars`,"aria-pressed":f.rating===i,style:{background:"none",border:"none",fontSize:"28px",cursor:o?"not-allowed":"pointer",padding:"0",color:f.rating&&f.rating>=i?"#fbbf24":"#d1d5db",transition:"all 0.2s",opacity:o?.6:1,transform:"scale(1)"},onMouseEnter:w=>!o&&(w.currentTarget.style.transform="scale(1.2)"),onMouseLeave:w=>!o&&(w.currentTarget.style.transform="scale(1)"),children:"★"},i))})]}),n.jsxs("div",{style:{marginBottom:"16px"},children:[n.jsxs("label",{htmlFor:"feedback-text",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500",color:"#374151"},children:["Your Feedback ",n.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),n.jsx("textarea",{id:"feedback-text",ref:z,value:f.text,onChange:i=>p({...f,text:i.target.value}),placeholder:"Tell us what you think...",required:!0,disabled:o,rows:4,"aria-required":"true",style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",fontSize:"14px",resize:"vertical",fontFamily:"inherit",opacity:o?.6:1,cursor:o?"not-allowed":"text"}})]}),n.jsxs("div",{style:{marginBottom:"16px"},children:[n.jsx("label",{htmlFor:"feedback-name",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500",color:"#374151"},children:"Name (optional)"}),n.jsx("input",{id:"feedback-name",type:"text",value:f.userName,onChange:i=>p({...f,userName:i.target.value}),placeholder:"Your name",disabled:o,style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",fontSize:"14px",opacity:o?.6:1}})]}),n.jsxs("div",{style:{marginBottom:"24px"},children:[n.jsx("label",{htmlFor:"feedback-email",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500",color:"#374151"},children:"Email (optional)"}),n.jsx("input",{id:"feedback-email",type:"email",value:f.userEmail,onChange:i=>p({...f,userEmail:i.target.value}),placeholder:"your@email.com",disabled:o,style:{width:"100%",padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",fontSize:"14px",opacity:o?.6:1}})]}),n.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[n.jsx("button",{type:"button",onClick:O,disabled:o,style:{padding:"10px 20px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",fontSize:"14px",fontWeight:"500",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,transition:"all 0.2s"},onMouseEnter:i=>!o&&(i.currentTarget.style.backgroundColor="#f9fafb"),onMouseLeave:i=>!o&&(i.currentTarget.style.backgroundColor="white"),children:"Cancel"}),n.jsxs("button",{type:"submit",disabled:o||E==="success",style:{padding:"10px 20px",border:"none",borderRadius:"6px",backgroundColor:E==="success"?"#10b981":"#3b82f6",color:"white",fontSize:"14px",fontWeight:"500",cursor:o||E==="success"?"not-allowed":"pointer",opacity:o?.7:1,transition:"all 0.2s",display:"flex",alignItems:"center",gap:"8px"},children:[o&&n.jsx("span",{style:{display:"inline-block",width:"14px",height:"14px",border:"2px solid #ffffff",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.6s linear infinite"}}),n.jsx("span",{children:o?"Sending...":E==="success"?"✓ Sent!":"Send Feedback"})]})]})]}),n.jsx("style",{children:`
|
|
31
31
|
@keyframes spin {
|
|
32
32
|
to { transform: rotate(360deg); }
|
|
33
33
|
}
|
|
@@ -41,5 +41,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
41
41
|
transform: translateY(0);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
`})]})})};async function xe(d,j,I){const f={"Content-Type":"application/json"};I&&(f
|
|
44
|
+
`})]})})};async function xe(d,j,I){const f={"Content-Type":"application/json"};I&&(f.Authorization=`Bearer ${I}`);try{const p=await fetch(`${d}/api/feedback`,{method:"POST",headers:f,body:JSON.stringify(j)});if(!p.ok){const o=await p.json().catch(()=>({}));throw new Error(o.message||`HTTP ${p.status}: ${p.statusText}`)}return await p.json()}catch(p){throw p instanceof Error?p:new Error("Failed to submit feedback")}}const Ve=({projectId:d,apiKey:j,apiUrl:I="http://localhost:3000",buttonText:f="Feedback",showIcon:p=!0,position:o="bottom-right",size:M="medium",buttonColor:E="#3b82f6",buttonHoverColor:b="#2563eb",buttonTextColor:P="#ffffff",customStyles:h,customClassName:R="",disabled:v=!1,autoOpen:W=!1,onOpen:z,onClose:O,onSuccess:N,onError:F})=>{const[x,U]=S.useState(W),[i,w]=S.useState(!1),Q=()=>{v||(U(!0),z==null||z())},ae=()=>{U(!1),O==null||O()},oe=async g=>{try{const Y={...g,project_id:d,page_url:window.location.href,page_title:document.title,user_agent:navigator.userAgent,user_identifier:g.userEmail||"anonymous",user_email:g.userEmail,user_name:g.userName,feedback_type:g.feedbackType},B=await xe(I,Y,j);N&&(B!=null&&B.id)&&N(B.id)}catch(Y){throw F&&Y instanceof Error&&F(Y),Y}},Z={small:{padding:"8px 16px",fontSize:"14px",iconSize:"16px"},medium:{padding:"12px 20px",fontSize:"16px",iconSize:"20px"},large:{padding:"16px 28px",fontSize:"18px",iconSize:"24px"}},ie=()=>{if(o==="inline")return{display:"inline-flex",position:"relative"};const g={position:"fixed",zIndex:9999};return o.includes("bottom")?g.bottom="20px":g.top="20px",o.includes("right")?g.right="20px":g.left="20px",g},G=Z[M],D={...ie(),padding:G.padding,backgroundColor:i&&!v?b:E,color:P,border:"none",borderRadius:"8px",fontSize:G.fontSize,fontWeight:"600",cursor:v?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",boxShadow:o!=="inline"?"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)":"none",transition:"all 0.2s ease",opacity:v?.6:1,transform:i&&!v?"translateY(-2px)":"translateY(0)",outline:"none",...h},A={fontSize:G.iconSize,lineHeight:1,display:"flex",alignItems:"center"};return n.jsxs(n.Fragment,{children:[n.jsxs("button",{onClick:Q,onMouseEnter:()=>!v&&w(!0),onMouseLeave:()=>!v&&w(!1),disabled:v,className:R,style:D,"aria-label":"Open feedback form","aria-pressed":x,"aria-disabled":v,role:"button",tabIndex:v?-1:0,onKeyDown:g=>{!v&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),Q())},children:[p&&n.jsx("span",{style:A,"aria-hidden":"true",children:"💬"}),n.jsx("span",{children:f})]}),n.jsx(he,{isOpen:x,onClose:ae,onSubmit:oe})]})},me=S.createContext(null),Je=()=>{const d=S.useContext(me);if(!d)throw new Error("useMetricShift must be used within MetricShiftProvider");return d},He=({config:d,children:j})=>n.jsx(me.Provider,{value:d,children:j});let ne=null;const Ke={init:d=>{ne={apiUrl:"http://localhost:3000",...d},console.log("✅ MetricShift SDK initialized",{projectId:d.projectId,apiUrl:ne.apiUrl})},getConfig:()=>ne};T.FeedbackButton=Ve,T.FeedbackModal=he,T.MetricShift=Ke,T.MetricShiftProvider=He,T.submitFeedback=xe,T.useMetricShift=Je,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
|
|
45
45
|
//# sourceMappingURL=index.umd.js.map
|