react-custom-gradient-button
Version:
A fully flexible React-powered gradient button component
837 lines (830 loc) • 27.6 kB
JavaScript
import Te from 'react';
import './style.css';
var Oe = { exports: {} },
A = {};
var _e;
function ir() {
if (_e) return A;
_e = 1;
var y = Te,
m = Symbol.for('react.element'),
k = Symbol.for('react.fragment'),
_ = Object.prototype.hasOwnProperty,
w = y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,
P = { key: !0, ref: !0, __self: !0, __source: !0 };
function T(g, l, R) {
var c,
b = {},
O = null,
$ = null;
R !== void 0 && (O = '' + R),
l.key !== void 0 && (O = '' + l.key),
l.ref !== void 0 && ($ = l.ref);
for (c in l) _.call(l, c) && !P.hasOwnProperty(c) && (b[c] = l[c]);
if (g && g.defaultProps) for (c in ((l = g.defaultProps), l)) b[c] === void 0 && (b[c] = l[c]);
return { $$typeof: m, type: g, key: O, ref: $, props: b, _owner: w.current };
}
return (A.Fragment = k), (A.jsx = T), (A.jsxs = T), A;
}
var I = {};
var Re;
function ur() {
return (
Re ||
((Re = 1),
process.env.NODE_ENV !== 'production' &&
(function () {
var y = Te,
m = Symbol.for('react.element'),
k = Symbol.for('react.portal'),
_ = Symbol.for('react.fragment'),
w = Symbol.for('react.strict_mode'),
P = Symbol.for('react.profiler'),
T = Symbol.for('react.provider'),
g = Symbol.for('react.context'),
l = Symbol.for('react.forward_ref'),
R = Symbol.for('react.suspense'),
c = Symbol.for('react.suspense_list'),
b = Symbol.for('react.memo'),
O = Symbol.for('react.lazy'),
$ = Symbol.for('react.offscreen'),
H = Symbol.iterator,
Ce = '@@iterator';
function we(e) {
if (e === null || typeof e != 'object') return null;
var r = (H && e[H]) || e[Ce];
return typeof r == 'function' ? r : null;
}
var S = y.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function d(e) {
{
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
t[n - 1] = arguments[n];
Pe('error', e, t);
}
}
function Pe(e, r, t) {
{
var n = S.ReactDebugCurrentFrame,
i = n.getStackAddendum();
i !== '' && ((r += '%s'), (t = t.concat([i])));
var u = t.map(function (o) {
return String(o);
});
u.unshift('Warning: ' + r), Function.prototype.apply.call(console[e], console, u);
}
}
var Se = !1,
xe = !1,
je = !1,
ke = !1,
De = !1,
X;
X = Symbol.for('react.module.reference');
function Fe(e) {
return !!(
typeof e == 'string' ||
typeof e == 'function' ||
e === _ ||
e === P ||
De ||
e === w ||
e === R ||
e === c ||
ke ||
e === $ ||
Se ||
xe ||
je ||
(typeof e == 'object' &&
e !== null &&
(e.$$typeof === O ||
e.$$typeof === b ||
e.$$typeof === T ||
e.$$typeof === g ||
e.$$typeof === l ||
e.$$typeof === X ||
e.getModuleId !== void 0))
);
}
function Ae(e, r, t) {
var n = e.displayName;
if (n) return n;
var i = r.displayName || r.name || '';
return i !== '' ? t + '(' + i + ')' : t;
}
function Z(e) {
return e.displayName || 'Context';
}
function h(e) {
if (e == null) return null;
if (
(typeof e.tag == 'number' &&
d(
'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 _:
return 'Fragment';
case k:
return 'Portal';
case P:
return 'Profiler';
case w:
return 'StrictMode';
case R:
return 'Suspense';
case c:
return 'SuspenseList';
}
if (typeof e == 'object')
switch (e.$$typeof) {
case g:
var r = e;
return Z(r) + '.Consumer';
case T:
var t = e;
return Z(t._context) + '.Provider';
case l:
return Ae(e, e.render, 'ForwardRef');
case b:
var n = e.displayName || null;
return n !== null ? n : h(e.type) || 'Memo';
case O: {
var i = e,
u = i._payload,
o = i._init;
try {
return h(o(u));
} catch {
return null;
}
}
}
return null;
}
var C = Object.assign,
D = 0,
Q,
ee,
re,
te,
ne,
ae,
oe;
function ie() {}
ie.__reactDisabledLog = !0;
function Ie() {
{
if (D === 0) {
(Q = console.log),
(ee = console.info),
(re = console.warn),
(te = console.error),
(ne = console.group),
(ae = console.groupCollapsed),
(oe = console.groupEnd);
var e = {
configurable: !0,
enumerable: !0,
value: ie,
writable: !0,
};
Object.defineProperties(console, {
info: e,
log: e,
warn: e,
error: e,
group: e,
groupCollapsed: e,
groupEnd: e,
});
}
D++;
}
}
function $e() {
{
if ((D--, D === 0)) {
var e = {
configurable: !0,
enumerable: !0,
writable: !0,
};
Object.defineProperties(console, {
log: C({}, e, {
value: Q,
}),
info: C({}, e, {
value: ee,
}),
warn: C({}, e, {
value: re,
}),
error: C({}, e, {
value: te,
}),
group: C({}, e, {
value: ne,
}),
groupCollapsed: C({}, e, {
value: ae,
}),
groupEnd: C({}, e, {
value: oe,
}),
});
}
D < 0 &&
d('disabledDepth fell below zero. This is a bug in React. Please file an issue.');
}
}
var M = S.ReactCurrentDispatcher,
U;
function W(e, r, t) {
{
if (U === void 0)
try {
throw Error();
} catch (i) {
var n = i.stack.trim().match(/\n( *(at )?)/);
U = (n && n[1]) || '';
}
return (
`
` +
U +
e
);
}
}
var B = !1,
Y;
{
var We = typeof WeakMap == 'function' ? WeakMap : Map;
Y = new We();
}
function ue(e, r) {
if (!e || B) return '';
{
var t = Y.get(e);
if (t !== void 0) return t;
}
var n;
B = !0;
var i = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var u;
(u = M.current), (M.current = null), Ie();
try {
if (r) {
var o = function () {
throw Error();
};
if (
(Object.defineProperty(o.prototype, 'props', {
set: function () {
throw Error();
},
}),
typeof Reflect == 'object' && Reflect.construct)
) {
try {
Reflect.construct(o, []);
} catch (E) {
n = E;
}
Reflect.construct(e, [], o);
} else {
try {
o.call();
} catch (E) {
n = E;
}
e.call(o.prototype);
}
} else {
try {
throw Error();
} catch (E) {
n = E;
}
e();
}
} catch (E) {
if (E && n && typeof E.stack == 'string') {
for (
var a = E.stack.split(`
`),
v = n.stack.split(`
`),
s = a.length - 1,
f = v.length - 1;
s >= 1 && f >= 0 && a[s] !== v[f];
)
f--;
for (; s >= 1 && f >= 0; s--, f--)
if (a[s] !== v[f]) {
if (s !== 1 || f !== 1)
do
if ((s--, f--, f < 0 || a[s] !== v[f])) {
var p =
`
` + a[s].replace(' at new ', ' at ');
return (
e.displayName &&
p.includes('<anonymous>') &&
(p = p.replace('<anonymous>', e.displayName)),
typeof e == 'function' && Y.set(e, p),
p
);
}
while (s >= 1 && f >= 0);
break;
}
}
} finally {
(B = !1), (M.current = u), $e(), (Error.prepareStackTrace = i);
}
var j = e ? e.displayName || e.name : '',
me = j ? W(j) : '';
return typeof e == 'function' && Y.set(e, me), me;
}
function Ye(e, r, t) {
return ue(e, !1);
}
function Le(e) {
var r = e.prototype;
return !!(r && r.isReactComponent);
}
function L(e, r, t) {
if (e == null) return '';
if (typeof e == 'function') return ue(e, Le(e));
if (typeof e == 'string') return W(e);
switch (e) {
case R:
return W('Suspense');
case c:
return W('SuspenseList');
}
if (typeof e == 'object')
switch (e.$$typeof) {
case l:
return Ye(e.render);
case b:
return L(e.type, r, t);
case O: {
var n = e,
i = n._payload,
u = n._init;
try {
return L(u(i), r, t);
} catch {}
}
}
return '';
}
var N = Object.prototype.hasOwnProperty,
se = {},
fe = S.ReactDebugCurrentFrame;
function V(e) {
if (e) {
var r = e._owner,
t = L(e.type, e._source, r ? r.type : null);
fe.setExtraStackFrame(t);
} else fe.setExtraStackFrame(null);
}
function Ne(e, r, t, n, i) {
{
var u = Function.call.bind(N);
for (var o in e)
if (u(e, o)) {
var a = void 0;
try {
if (typeof e[o] != 'function') {
var v = Error(
(n || 'React class') +
': ' +
t +
' type `' +
o +
'` is invalid; it must be a function, usually from the `prop-types` package, but received `' +
typeof e[o] +
'`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
);
throw ((v.name = 'Invariant Violation'), v);
}
a = e[o](r, o, n, t, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
} catch (s) {
a = s;
}
a &&
!(a instanceof Error) &&
(V(i),
d(
'%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).',
n || 'React class',
t,
o,
typeof a
),
V(null)),
a instanceof Error &&
!(a.message in se) &&
((se[a.message] = !0), V(i), d('Failed %s type: %s', t, a.message), V(null));
}
}
}
var Ve = Array.isArray;
function q(e) {
return Ve(e);
}
function Me(e) {
{
var r = typeof Symbol == 'function' && Symbol.toStringTag,
t = (r && e[Symbol.toStringTag]) || e.constructor.name || 'Object';
return t;
}
}
function Ue(e) {
try {
return le(e), !1;
} catch {
return !0;
}
}
function le(e) {
return '' + e;
}
function ce(e) {
if (Ue(e))
return (
d(
'The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.',
Me(e)
),
le(e)
);
}
var F = S.ReactCurrentOwner,
Be = {
key: !0,
ref: !0,
__self: !0,
__source: !0,
},
de,
ve,
G;
G = {};
function qe(e) {
if (N.call(e, 'ref')) {
var r = Object.getOwnPropertyDescriptor(e, 'ref').get;
if (r && r.isReactWarning) return !1;
}
return e.ref !== void 0;
}
function Ge(e) {
if (N.call(e, 'key')) {
var r = Object.getOwnPropertyDescriptor(e, 'key').get;
if (r && r.isReactWarning) return !1;
}
return e.key !== void 0;
}
function Je(e, r) {
if (typeof e.ref == 'string' && F.current && r && F.current.stateNode !== r) {
var t = h(F.current.type);
G[t] ||
(d(
'Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',
h(F.current.type),
e.ref
),
(G[t] = !0));
}
}
function ze(e, r) {
{
var t = function () {
de ||
((de = !0),
d(
'%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 Ke(e, r) {
{
var t = function () {
ve ||
((ve = !0),
d(
'%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 He = function (e, r, t, n, i, u, o) {
var a = {
$$typeof: m,
type: e,
key: r,
ref: t,
props: o,
_owner: u,
};
return (
(a._store = {}),
Object.defineProperty(a._store, 'validated', {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1,
}),
Object.defineProperty(a, '_self', {
configurable: !1,
enumerable: !1,
writable: !1,
value: n,
}),
Object.defineProperty(a, '_source', {
configurable: !1,
enumerable: !1,
writable: !1,
value: i,
}),
Object.freeze && (Object.freeze(a.props), Object.freeze(a)),
a
);
};
function Xe(e, r, t, n, i) {
{
var u,
o = {},
a = null,
v = null;
t !== void 0 && (ce(t), (a = '' + t)),
Ge(r) && (ce(r.key), (a = '' + r.key)),
qe(r) && ((v = r.ref), Je(r, i));
for (u in r) N.call(r, u) && !Be.hasOwnProperty(u) && (o[u] = r[u]);
if (e && e.defaultProps) {
var s = e.defaultProps;
for (u in s) o[u] === void 0 && (o[u] = s[u]);
}
if (a || v) {
var f = typeof e == 'function' ? e.displayName || e.name || 'Unknown' : e;
a && ze(o, f), v && Ke(o, f);
}
return He(e, a, v, i, n, F.current, o);
}
}
var J = S.ReactCurrentOwner,
pe = S.ReactDebugCurrentFrame;
function x(e) {
if (e) {
var r = e._owner,
t = L(e.type, e._source, r ? r.type : null);
pe.setExtraStackFrame(t);
} else pe.setExtraStackFrame(null);
}
var z;
z = !1;
function K(e) {
return typeof e == 'object' && e !== null && e.$$typeof === m;
}
function ge() {
{
if (J.current) {
var e = h(J.current.type);
if (e)
return (
`
Check the render method of \`` +
e +
'`.'
);
}
return '';
}
}
function Ze(e) {
{
if (e !== void 0) {
var r = e.fileName.replace(/^.*[\\\/]/, ''),
t = e.lineNumber;
return (
`
Check your code at ` +
r +
':' +
t +
'.'
);
}
return '';
}
}
var be = {};
function Qe(e) {
{
var r = ge();
if (!r) {
var t = typeof e == 'string' ? e : e.displayName || e.name;
t &&
(r =
`
Check the top-level render call using <` +
t +
'>.');
}
return r;
}
}
function he(e, r) {
{
if (!e._store || e._store.validated || e.key != null) return;
e._store.validated = !0;
var t = Qe(r);
if (be[t]) return;
be[t] = !0;
var n = '';
e &&
e._owner &&
e._owner !== J.current &&
(n = ' It was passed a child from ' + h(e._owner.type) + '.'),
x(e),
d(
'Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',
t,
n
),
x(null);
}
}
function Ee(e, r) {
{
if (typeof e != 'object') return;
if (q(e))
for (var t = 0; t < e.length; t++) {
var n = e[t];
K(n) && he(n, r);
}
else if (K(e)) e._store && (e._store.validated = !0);
else if (e) {
var i = we(e);
if (typeof i == 'function' && i !== e.entries)
for (var u = i.call(e), o; !(o = u.next()).done; ) K(o.value) && he(o.value, r);
}
}
}
function er(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 === l || r.$$typeof === b))
t = r.propTypes;
else return;
if (t) {
var n = h(r);
Ne(t, e.props, 'prop', n, e);
} else if (r.PropTypes !== void 0 && !z) {
z = !0;
var i = h(r);
d(
'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?',
i || 'Unknown'
);
}
typeof r.getDefaultProps == 'function' &&
!r.getDefaultProps.isReactClassApproved &&
d(
'getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.'
);
}
}
function rr(e) {
{
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
var n = r[t];
if (n !== 'children' && n !== 'key') {
x(e),
d(
'Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.',
n
),
x(null);
break;
}
}
e.ref !== null &&
(x(e), d('Invalid attribute `ref` supplied to `React.Fragment`.'), x(null));
}
}
function ye(e, r, t, n, i, u) {
{
var o = Fe(e);
if (!o) {
var a = '';
(e === void 0 ||
(typeof e == 'object' && e !== null && Object.keys(e).length === 0)) &&
(a +=
" 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 v = Ze(i);
v ? (a += v) : (a += ge());
var s;
e === null
? (s = 'null')
: q(e)
? (s = 'array')
: e !== void 0 && e.$$typeof === m
? ((s = '<' + (h(e.type) || 'Unknown') + ' />'),
(a = ' Did you accidentally export a JSX literal instead of a component?'))
: (s = typeof e),
d(
'React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s',
s,
a
);
}
var f = Xe(e, r, t, i, u);
if (f == null) return f;
if (o) {
var p = r.children;
if (p !== void 0)
if (n)
if (q(p)) {
for (var j = 0; j < p.length; j++) Ee(p[j], e);
Object.freeze && Object.freeze(p);
} else
d(
'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 Ee(p, e);
}
return e === _ ? rr(f) : er(f), f;
}
}
function tr(e, r, t) {
return ye(e, r, t, !0);
}
function nr(e, r, t) {
return ye(e, r, t, !1);
}
var ar = nr,
or = tr;
(I.Fragment = _), (I.jsx = ar), (I.jsxs = or);
})()),
I
);
}
(function (y) {
process.env.NODE_ENV === 'production' ? (y.exports = ir()) : (y.exports = ur());
})(Oe);
const sr = Oe.exports.jsx,
lr = ({
children: y,
className: m,
color: k = 'white',
start: _ = '#aa076b',
middle: w = '#61045f',
end: P = '#aa076b',
borderRadius: T = '0.5rem',
width: g = '',
height: l = '',
style: R = {},
...c
}) =>
/* @__PURE__ */ sr('button', {
style: {
color: k,
backgroundImage: `linear-gradient(to right, ${_} 0%, ${w} 51%, ${P} 100%)`,
borderRadius: T,
width: g,
height: l,
...R,
},
tabIndex: 0,
className: `cstm-button-grd ${m || ''}`,
...c,
children: y,
});
export { lr as default };