react-tilt-button 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -135,15 +135,16 @@ So the button:
135
135
 
136
136
  ### Geometry
137
137
 
138
- | Prop | Type | Default | Notes |
139
- | ------------ | ---------------- | ------- | ------------------------------ |
140
- | `width` | number \| string | `260` | No max |
141
- | `height` | number \| string | `64` | No max |
142
- | `elevation` | number | `14` | Clamped to `height * 0.3` |
143
- | `pressInset` | number | `5` | Clamped to `<= elevation` |
144
- | `tilt` | number | `2` | Clamped to `<= elevation / 9` |
145
- | `radius` | number | `14` | Clamped to `<= faceHeight / 4` |
146
- | `motion` | number (ms) | `160` | Animation speed |
138
+ | Prop | Type | Default | Notes |
139
+ | ------------ | ---------------- | ------- | ----------------------------------------------------- |
140
+ | `width` | number \| string | `260` | No max |
141
+ | `height` | number \| string | `64` | No max |
142
+ | `elevation` | number | `14` | Clamped to `height * 0.3` |
143
+ | `pressInset` | number | `5` | Clamped to `<= elevation` |
144
+ | `tilt` | number | `2` | Clamped to `<= elevation / 9` |
145
+ | `pressTilt` | boolean | `true` | When `true`, the button keeps its skew while pressing |
146
+ | `radius` | number | `14` | Clamped to `<= faceHeight / 4` |
147
+ | `motion` | number (ms) | `160` | Animation speed |
147
148
 
148
149
  ---
149
150
 
@@ -1,62 +1,62 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;--glare-rgb: 255, 255, 255;--glare-alpha: 0;--glare-width: 0;--edge-aa: 0px;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{border-radius:var(--radius)}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.soft-btn__content:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,rgba(var(--glare-rgb),0) calc(50% - var(--glare-width) * 1%),rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% - var(--glare-width) * .5%),rgba(var(--glare-rgb),var(--glare-alpha)) 50%,rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% + var(--glare-width) * .5%),rgba(var(--glare-rgb),0) calc(50% + var(--glare-width) * 1%));background-size:200% 100%;background-position:50% 50%;opacity:0;transition:opacity .16s ease,background-position var(--transform-speed) ease;z-index:3}.soft-btn--right .soft-btn__content:after{opacity:1;background-position:0% 50%}.soft-btn--middle .soft-btn__content:after{opacity:1;background-position:50% 50%}.soft-btn--left .soft-btn__content:after{opacity:1;background-position:100% 50%}.soft-btn--active .soft-btn__content:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- import ve, { useRef as Re, useState as ne } from "react";
3
- var X = { exports: {} }, I = {};
4
- var ae;
5
- function Ce() {
6
- if (ae) return I;
7
- ae = 1;
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--press-compensated: 0px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;--glare-rgb: 255, 255, 255;--glare-alpha: 0;--glare-width: 0;--edge-aa: 0px;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{border-radius:var(--radius)}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--press-tilt.soft-btn--active.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--press-tilt.soft-btn--active.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.soft-btn__content:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,rgba(var(--glare-rgb),0) calc(50% - var(--glare-width) * 1%),rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% - var(--glare-width) * .5%),rgba(var(--glare-rgb),var(--glare-alpha)) 50%,rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% + var(--glare-width) * .5%),rgba(var(--glare-rgb),0) calc(50% + var(--glare-width) * 1%));background-size:200% 100%;background-position:50% 50%;opacity:0;transition:opacity .16s ease,background-position var(--transform-speed) ease;z-index:3}.soft-btn--right .soft-btn__content:after{opacity:1;background-position:0% 50%}.soft-btn--middle .soft-btn__content:after{opacity:1;background-position:50% 50%}.soft-btn--left .soft-btn__content:after{opacity:1;background-position:100% 50%}.soft-btn--active .soft-btn__content:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import Pe, { useRef as ge, useState as se } from "react";
3
+ var X = { exports: {} }, M = {};
4
+ var le;
5
+ function ye() {
6
+ if (le) return M;
7
+ le = 1;
8
8
  var c = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
9
9
  function l(d, i, u) {
10
- var v = null;
11
- if (u !== void 0 && (v = "" + u), i.key !== void 0 && (v = "" + i.key), "key" in i) {
10
+ var _ = null;
11
+ if (u !== void 0 && (_ = "" + u), i.key !== void 0 && (_ = "" + i.key), "key" in i) {
12
12
  u = {};
13
- for (var R in i)
14
- R !== "key" && (u[R] = i[R]);
13
+ for (var E in i)
14
+ E !== "key" && (u[E] = i[E]);
15
15
  } else u = i;
16
16
  return i = u.ref, {
17
17
  $$typeof: c,
18
18
  type: d,
19
- key: v,
19
+ key: _,
20
20
  ref: i !== void 0 ? i : null,
21
21
  props: u
22
22
  };
23
23
  }
24
- return I.Fragment = s, I.jsx = l, I.jsxs = l, I;
24
+ return M.Fragment = s, M.jsx = l, M.jsxs = l, M;
25
25
  }
26
26
  var $ = {};
27
- var se;
28
- function xe() {
29
- return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
27
+ var ce;
28
+ function Ae() {
29
+ return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
30
30
  function c(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
- return e.$$typeof === L ? null : e.displayName || e.name || null;
33
+ return e.$$typeof === k ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case k:
36
+ case R:
37
37
  return "Fragment";
38
- case Z:
38
+ case Q:
39
39
  return "Profiler";
40
- case H:
40
+ case Z:
41
41
  return "StrictMode";
42
- case h:
42
+ case re:
43
43
  return "Suspense";
44
- case D:
44
+ case C:
45
45
  return "SuspenseList";
46
- case S:
46
+ case L:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof e == "object")
50
50
  switch (typeof e.tag == "number" && console.error(
51
51
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
52
  ), e.$$typeof) {
53
- case w:
53
+ case A:
54
54
  return "Portal";
55
- case O:
55
+ case ee:
56
56
  return e.displayName || "Context";
57
- case Q:
58
- return (e._context.displayName || "Context") + ".Consumer";
59
57
  case K:
58
+ return (e._context.displayName || "Context") + ".Consumer";
59
+ case w:
60
60
  var r = e.render;
61
61
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
62
  case F:
@@ -91,7 +91,7 @@ function xe() {
91
91
  }
92
92
  }
93
93
  function d(e) {
94
- if (e === k) return "<>";
94
+ if (e === R) return "<>";
95
95
  if (typeof e == "object" && e !== null && e.$$typeof === P)
96
96
  return "<...>";
97
97
  try {
@@ -102,22 +102,22 @@ function xe() {
102
102
  }
103
103
  }
104
104
  function i() {
105
- var e = N.A;
105
+ var e = g.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
108
  function u() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function v(e) {
112
- if (ee.call(e, "key")) {
111
+ function _(e) {
112
+ if (U.call(e, "key")) {
113
113
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
114
  if (r && r.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function R(e, r) {
118
+ function E(e, r) {
119
119
  function t() {
120
- U || (U = !0, console.error(
120
+ x || (x = !0, console.error(
121
121
  "%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://react.dev/link/special-props)",
122
122
  r
123
123
  ));
@@ -127,23 +127,23 @@ function xe() {
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function A() {
130
+ function H() {
131
131
  var e = c(this.type);
132
132
  return V[e] || (V[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function C(e, r, t, o, g, y) {
136
+ function T(e, r, t, o, y, N) {
137
137
  var n = t.ref;
138
138
  return e = {
139
- $$typeof: T,
139
+ $$typeof: D,
140
140
  type: e,
141
141
  key: r,
142
142
  props: t,
143
143
  _owner: o
144
144
  }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
- get: A
146
+ get: H
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -158,19 +158,19 @@ function xe() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: g
161
+ value: y
162
162
  }), Object.defineProperty(e, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: y
166
+ value: N
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function M(e, r, t, o, g, y) {
169
+ function v(e, r, t, o, y, N) {
170
170
  var n = r.children;
171
171
  if (n !== void 0)
172
172
  if (o)
173
- if (re(n)) {
173
+ if (oe(n)) {
174
174
  for (o = 0; o < n.length; o++)
175
175
  W(n[o]);
176
176
  Object.freeze && Object.freeze(n);
@@ -179,12 +179,12 @@ function xe() {
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
181
  else W(n);
182
- if (ee.call(r, "key")) {
182
+ if (U.call(r, "key")) {
183
183
  n = c(e);
184
- var m = Object.keys(r).filter(function(te) {
184
+ var b = Object.keys(r).filter(function(te) {
185
185
  return te !== "key";
186
186
  });
187
- o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", J[n + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ o = 0 < b.length ? "{key: someKey, " + b.join(": ..., ") + ": ...}" : "{key: someKey}", q[n + o] || (b = 0 < b.length ? "{" + b.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
@@ -193,74 +193,74 @@ React keys must be passed directly to JSX without using spread:
193
193
  <%s key={someKey} {...props} />`,
194
194
  o,
195
195
  n,
196
- m,
196
+ b,
197
197
  n
198
- ), J[n + o] = !0);
198
+ ), q[n + o] = !0);
199
199
  }
200
- if (n = null, t !== void 0 && (l(t), n = "" + t), v(r) && (l(r.key), n = "" + r.key), "key" in r) {
200
+ if (n = null, t !== void 0 && (l(t), n = "" + t), _(r) && (l(r.key), n = "" + r.key), "key" in r) {
201
201
  t = {};
202
- for (var p in r)
203
- p !== "key" && (t[p] = r[p]);
202
+ for (var j in r)
203
+ j !== "key" && (t[j] = r[j]);
204
204
  } else t = r;
205
- return n && R(
205
+ return n && E(
206
206
  t,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), C(
208
+ ), T(
209
209
  e,
210
210
  n,
211
211
  t,
212
212
  i(),
213
- g,
214
- y
213
+ y,
214
+ N
215
215
  );
216
216
  }
217
217
  function W(e) {
218
218
  Y(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? Y(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
219
  }
220
220
  function Y(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === T;
221
+ return typeof e == "object" && e !== null && e.$$typeof === D;
222
222
  }
223
- var x = ve, T = /* @__PURE__ */ Symbol.for("react.transitional.element"), w = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), H = /* @__PURE__ */ Symbol.for("react.strict_mode"), Z = /* @__PURE__ */ Symbol.for("react.profiler"), Q = /* @__PURE__ */ Symbol.for("react.consumer"), O = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), h = /* @__PURE__ */ Symbol.for("react.suspense"), D = /* @__PURE__ */ Symbol.for("react.suspense_list"), F = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), S = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), N = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ee = Object.prototype.hasOwnProperty, re = Array.isArray, b = console.createTask ? console.createTask : function() {
223
+ var h = Pe, D = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), Z = /* @__PURE__ */ Symbol.for("react.strict_mode"), Q = /* @__PURE__ */ Symbol.for("react.profiler"), K = /* @__PURE__ */ Symbol.for("react.consumer"), ee = /* @__PURE__ */ Symbol.for("react.context"), w = /* @__PURE__ */ Symbol.for("react.forward_ref"), re = /* @__PURE__ */ Symbol.for("react.suspense"), C = /* @__PURE__ */ Symbol.for("react.suspense_list"), F = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), L = /* @__PURE__ */ Symbol.for("react.activity"), k = /* @__PURE__ */ Symbol.for("react.client.reference"), g = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, oe = Array.isArray, O = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
- x = {
226
+ h = {
227
227
  react_stack_bottom_frame: function(e) {
228
228
  return e();
229
229
  }
230
230
  };
231
- var U, V = {}, q = x.react_stack_bottom_frame.bind(
232
- x,
231
+ var x, V = {}, S = h.react_stack_bottom_frame.bind(
232
+ h,
233
233
  u
234
- )(), B = b(d(u)), J = {};
235
- $.Fragment = k, $.jsx = function(e, r, t) {
236
- var o = 1e4 > N.recentlyCreatedOwnerStacks++;
237
- return M(
234
+ )(), B = O(d(u)), q = {};
235
+ $.Fragment = R, $.jsx = function(e, r, t) {
236
+ var o = 1e4 > g.recentlyCreatedOwnerStacks++;
237
+ return v(
238
238
  e,
239
239
  r,
240
240
  t,
241
241
  !1,
242
- o ? Error("react-stack-top-frame") : q,
243
- o ? b(d(e)) : B
242
+ o ? Error("react-stack-top-frame") : S,
243
+ o ? O(d(e)) : B
244
244
  );
245
245
  }, $.jsxs = function(e, r, t) {
246
- var o = 1e4 > N.recentlyCreatedOwnerStacks++;
247
- return M(
246
+ var o = 1e4 > g.recentlyCreatedOwnerStacks++;
247
+ return v(
248
248
  e,
249
249
  r,
250
250
  t,
251
251
  !0,
252
- o ? Error("react-stack-top-frame") : q,
253
- o ? b(d(e)) : B
252
+ o ? Error("react-stack-top-frame") : S,
253
+ o ? O(d(e)) : B
254
254
  );
255
255
  };
256
256
  })()), $;
257
257
  }
258
- var le;
259
- function Te() {
260
- return le || (le = 1, process.env.NODE_ENV === "production" ? X.exports = Ce() : X.exports = xe()), X.exports;
258
+ var ie;
259
+ function we() {
260
+ return ie || (ie = 1, process.env.NODE_ENV === "production" ? X.exports = ye() : X.exports = Ae()), X.exports;
261
261
  }
262
- var z = Te();
263
- const ce = {
262
+ var z = we();
263
+ const ue = {
264
264
  solid: {
265
265
  surfaceColor: "#3b82f6",
266
266
  sideColor: "#1d4ed8",
@@ -335,99 +335,108 @@ const ce = {
335
335
  function G(c, s, l) {
336
336
  return Math.max(s, Math.min(l, c));
337
337
  }
338
- function Ae({
338
+ function je({
339
339
  children: c,
340
340
  onClick: s,
341
341
  disabled: l = !1,
342
342
  variant: d = "solid",
343
343
  elevation: i = 14,
344
344
  pressInset: u = 5,
345
- tilt: v = 2,
346
- motion: R = 160,
347
- width: A = 260,
348
- height: C = 64,
349
- radius: M = 14,
350
- surfaceColor: W,
351
- sideColor: Y,
352
- textColor: x,
353
- borderColor: T,
354
- borderWidth: w,
355
- glareColor: k = "#ffffff",
356
- glareOpacity: H = 0,
357
- glareWidth: Z = 0,
358
- className: Q = "",
359
- style: O,
360
- ...K
345
+ tilt: _ = 2,
346
+ pressTilt: E = !0,
347
+ motion: H = 160,
348
+ width: T = 260,
349
+ height: v = 64,
350
+ radius: W = 14,
351
+ surfaceColor: Y,
352
+ sideColor: h,
353
+ textColor: D,
354
+ borderColor: A,
355
+ borderWidth: R,
356
+ glareColor: Z = "#ffffff",
357
+ glareOpacity: Q = 0,
358
+ glareWidth: K = 0,
359
+ className: ee = "",
360
+ style: w,
361
+ ...re
361
362
  }) {
362
- const h = Re(null), [D, F] = ne(!1), [P, S] = ne(null), L = Math.max(0, Number(C) || 0), N = Math.max(0, Number(i) || 0), re = L * 0.3, b = G(N, 0, re), U = Math.max(0, Number(u) || 0), V = G(U, 0, b), q = Math.max(0, Number(v) || 0), B = Number((b / 9).toFixed(2)), J = G(q, 0, B), e = L - b, r = Math.max(0, Math.floor(e / 4)), t = Math.max(0, Number(M) || 0), o = G(t, 0, r), g = Math.max(0, Number(R) || 0);
363
- function y(a, f) {
364
- const _ = f.getBoundingClientRect(), E = a.clientX - _.left, oe = _.width || 1;
365
- return E < oe * 0.33 ? "left" : E > oe * 0.66 ? "right" : "middle";
363
+ const C = ge(null), [F, P] = se(!1), [L, k] = se(null), g = Math.max(0, Number(v) || 0), U = Math.max(0, Number(i) || 0), O = g * 0.3, x = G(U, 0, O), V = Math.max(0, Number(u) || 0), S = G(V, 0, x), B = Math.max(0, Number(_) || 0), q = Number((x / 9).toFixed(2)), e = G(B, 0, q), t = C.current?.getBoundingClientRect()?.width || Number(T) || 0, o = e * Math.PI / 180, y = t / 2 * Math.tan(o), N = Math.max(0, S - y), n = g - x, b = Math.max(0, Math.floor(n / 4)), j = Math.max(0, Number(W) || 0), te = G(j, 0, b), fe = Math.max(0, Number(H) || 0);
364
+ function ne(a, f) {
365
+ const m = f.getBoundingClientRect(), p = a.clientX - m.left, ae = m.width || 1;
366
+ return p < ae * 0.33 ? "left" : p > ae * 0.66 ? "right" : "middle";
366
367
  }
367
- const n = (a) => {
368
+ const de = (a) => {
368
369
  if (l || a.button !== 0 && a.pointerType === "mouse") return;
369
- const f = h.current;
370
+ const f = C.current;
370
371
  if (!f) return;
371
372
  f.setPointerCapture(a.pointerId);
372
- const _ = y(a, f);
373
- S((E) => E === _ ? E : _), F(!0);
374
- }, m = (a) => {
373
+ const m = ne(a, f);
374
+ k((p) => p === m ? p : m), P(!0);
375
+ }, be = (a) => {
375
376
  if (l || a.pointerType !== "mouse") return;
376
- const f = h.current;
377
+ const f = C.current;
377
378
  if (!f) return;
378
- const _ = y(a, f);
379
- S((E) => E === _ ? E : _);
380
- }, p = (a) => {
381
- const f = h.current;
379
+ const m = ne(a, f);
380
+ k((p) => p === m ? p : m);
381
+ }, J = (a) => {
382
+ const f = C.current;
382
383
  try {
383
384
  f?.hasPointerCapture(a.pointerId) && f.releasePointerCapture(a.pointerId);
384
385
  } catch {
385
386
  }
386
- F(!1), S(null), l && D && p(a);
387
- }, te = (a) => {
388
- l || (p(a), s && s(a));
389
- }, ie = (a) => {
390
- l || p(a);
391
- }, ue = (a) => {
392
- p(a);
393
- }, j = ce[d] || ce.solid, fe = W ?? j.surfaceColor, de = Y ?? j.sideColor, be = x ?? j.textColor, me = typeof T == "string" && T.trim() !== "" ? T : j.borderColor || "transparent", pe = typeof w == "number" && w >= 0 ? w : j.borderWidth ?? 0, _e = {
387
+ P(!1), k(null), l && F && J(a);
388
+ }, me = (a) => {
389
+ l || (J(a), s && s(a));
390
+ }, pe = (a) => {
391
+ l || J(a);
392
+ }, _e = (a) => {
393
+ J(a);
394
+ }, I = ue[d] || ue.solid, Ee = Y ?? I.surfaceColor, ve = h ?? I.sideColor, Re = D ?? I.textColor, Ce = typeof A == "string" && A.trim() !== "" ? A : I.borderColor || "transparent", xe = typeof R == "number" && R >= 0 ? R : I.borderWidth ?? 0, Te = {
394
395
  ...{
395
- "--button-raise-level": `${b}px`,
396
- "--press-inset": `${V}px`,
397
- "--button-hover-pressure": J,
398
- "--transform-speed": `${g}ms`,
399
- "--radius": `${o}px`,
400
- "--surface-color": fe,
401
- "--side-color": de,
402
- "--text-color": be,
403
- "--border-color": me,
404
- "--border-width": `${pe}px`,
405
- "--glare-rgb": he(k),
406
- "--glare-alpha": H,
407
- "--glare-width": Z,
408
- width: typeof A == "number" ? `${A}px` : A,
409
- height: typeof C == "number" ? `${C}px` : C
396
+ "--button-raise-level": `${x}px`,
397
+ "--press-inset": `${S}px`,
398
+ "--press-compensated": `${N}px`,
399
+ "--button-hover-pressure": e,
400
+ "--transform-speed": `${fe}ms`,
401
+ "--radius": `${te}px`,
402
+ "--surface-color": Ee,
403
+ "--side-color": ve,
404
+ "--text-color": Re,
405
+ "--border-color": Ce,
406
+ "--border-width": `${xe}px`,
407
+ "--glare-rgb": ke(Z),
408
+ "--glare-alpha": Q,
409
+ "--glare-width": K,
410
+ width: typeof T == "number" ? `${T}px` : T,
411
+ height: typeof v == "number" ? `${v}px` : v
410
412
  },
411
- ...O && typeof O == "object" ? O : {}
412
- }, Ee = ["soft-btn", D && "soft-btn--active", P && `soft-btn--${P}`, l && "soft-btn--disabled", Q].filter(Boolean).join(" ");
413
+ ...w && typeof w == "object" ? w : {}
414
+ }, he = [
415
+ "soft-btn",
416
+ F && "soft-btn--active",
417
+ L && `soft-btn--${L}`,
418
+ l && "soft-btn--disabled",
419
+ E && "soft-btn--press-tilt",
420
+ ee
421
+ ].filter(Boolean).join(" ");
413
422
  return /* @__PURE__ */ z.jsx(
414
423
  "button",
415
424
  {
416
- ...K,
417
- ref: h,
418
- className: Ee,
419
- style: _e,
420
- onPointerDown: n,
421
- onPointerMove: m,
422
- onPointerUp: te,
423
- onPointerLeave: ie,
424
- onPointerCancel: ue,
425
+ ...re,
426
+ ref: C,
427
+ className: he,
428
+ style: Te,
429
+ onPointerDown: de,
430
+ onPointerMove: be,
431
+ onPointerUp: me,
432
+ onPointerLeave: pe,
433
+ onPointerCancel: _e,
425
434
  disabled: l,
426
435
  children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ z.jsx("span", { className: "soft-btn__inner", children: c }) }) })
427
436
  }
428
437
  );
429
438
  }
430
- function he(c) {
439
+ function ke(c) {
431
440
  if (!c || typeof c != "string")
432
441
  return "255,255,255";
433
442
  let s = c.replace("#", "");
@@ -437,6 +446,6 @@ function he(c) {
437
446
  return `${l},${d},${i}`;
438
447
  }
439
448
  export {
440
- Ae as TiltButton,
441
- ce as TiltButtonVariants
449
+ je as TiltButton,
450
+ ue as TiltButtonVariants
442
451
  };
@@ -1,7 +1,7 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;--glare-rgb: 255, 255, 255;--glare-alpha: 0;--glare-width: 0;--edge-aa: 0px;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{border-radius:var(--radius)}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.soft-btn__content:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,rgba(var(--glare-rgb),0) calc(50% - var(--glare-width) * 1%),rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% - var(--glare-width) * .5%),rgba(var(--glare-rgb),var(--glare-alpha)) 50%,rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% + var(--glare-width) * .5%),rgba(var(--glare-rgb),0) calc(50% + var(--glare-width) * 1%));background-size:200% 100%;background-position:50% 50%;opacity:0;transition:opacity .16s ease,background-position var(--transform-speed) ease;z-index:3}.soft-btn--right .soft-btn__content:after{opacity:1;background-position:0% 50%}.soft-btn--middle .soft-btn__content:after{opacity:1;background-position:50% 50%}.soft-btn--left .soft-btn__content:after{opacity:1;background-position:100% 50%}.soft-btn--active .soft-btn__content:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- (function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b["react-tilt-button"]={},b.React))})(this,(function(b,m){"use strict";var $={exports:{}},w={};var se;function fe(){if(se)return w;se=1;var c=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(d,i,f){var T=null;if(f!==void 0&&(T=""+f),i.key!==void 0&&(T=""+i.key),"key"in i){f={};for(var C in i)C!=="key"&&(f[C]=i[C])}else f=i;return i=f.ref,{$$typeof:c,type:d,key:T,ref:i!==void 0?i:null,props:f}}return w.Fragment=s,w.jsx=l,w.jsxs=l,w}var O={};var le;function ue(){return le||(le=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case N:return"Fragment";case ee:return"Profiler";case K:return"StrictMode";case y:return"Suspense";case B:return"SuspenseList";case M:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case j:return"Portal";case I:return e.displayName||"Context";case re:return(e._context.displayName||"Context")+".Consumer";case te:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return r=e.displayName||null,r!==null?r:c(e.type)||"Memo";case g:r=e._payload,e=e._init;try{return c(e(r))}catch{}}return null}function s(e){return""+e}function l(e){try{s(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),s(e)}}function d(e){if(e===N)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var r=c(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function i(){var e=W.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function T(e){if(oe.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function C(e,r){function t(){z||(z=!0,console.error("%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://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function k(){var e=c(this.type);return G[e]||(G[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function x(e,r,t,o,A,S){var n=t.ref;return e={$$typeof:P,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:k}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function L(e,r,t,o,A,S){var n=r.children;if(n!==void 0)if(o)if(ne(n)){for(o=0;o<n.length;o++)U(n[o]);Object.freeze&&Object.freeze(n)}else console.error("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 U(n);if(oe.call(r,"key")){n=c(e);var _=Object.keys(r).filter(function(ae){return ae!=="key"});o=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",Z[n+o]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.soft-btn{--button-raise-level: 14px;--press-inset: 5px;--press-compensated: 0px;--button-hover-pressure: 2;--transform-speed: .16s;--radius: 14px;--surface-color: #f3f4f6;--side-color: #d1d5db;--text-color: #111827;--border-color: rgba(0, 0, 0, .35);--border-width: 2px;--glare-rgb: 255, 255, 255;--glare-alpha: 0;--glare-width: 0;--edge-aa: 0px;position:relative;border:none;background:transparent;padding:0;cursor:pointer;-webkit-user-select:none;user-select:none}.soft-btn__wrapper{position:relative;display:block;width:100%;height:100%;transform-style:preserve-3d}.soft-btn__wrapper:before{content:"";position:absolute;left:0;right:0;bottom:0;height:calc(100% - var(--button-raise-level));background:var(--side-color);border-radius:var(--radius);z-index:1}.soft-btn--active .soft-btn__wrapper:before{border-radius:var(--radius)}.soft-btn__content{position:relative;width:100%;height:calc(100% - var(--button-raise-level));background:var(--surface-color);color:var(--text-color);border-radius:var(--radius);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:600;transform:translateY(0);transition:transform var(--transform-speed) ease-out;will-change:transform;backface-visibility:hidden;transform-origin:center;z-index:2;box-shadow:inset 0 0 0 var(--border-width) var(--border-color),0 0 var(--edge-aa) #00000073}.soft-btn__inner{display:inline-flex;align-items:center;justify-content:center;gap:10px;z-index:4;width:100%;height:100%}.soft-btn--middle .soft-btn__content{transform:translateY(calc(1px * var(--button-hover-pressure)))}.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure)))}.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure)))}.soft-btn--left,.soft-btn--right{--edge-aa: 1px}.soft-btn--active .soft-btn__content{transform:translateY(var(--press-inset));transition:transform calc(var(--transform-speed) * .8) ease-out}.soft-btn--press-tilt.soft-btn--active.soft-btn--left .soft-btn__content{transform:skewY(calc(-1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--press-tilt.soft-btn--active.soft-btn--right .soft-btn__content{transform:skewY(calc(1deg * var(--button-hover-pressure))) translateY(var(--press-compensated))}.soft-btn--disabled{opacity:.6;pointer-events:none}.soft-btn--disabled .soft-btn__content:after{opacity:0}.soft-btn__content:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(90deg,rgba(var(--glare-rgb),0) calc(50% - var(--glare-width) * 1%),rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% - var(--glare-width) * .5%),rgba(var(--glare-rgb),var(--glare-alpha)) 50%,rgba(var(--glare-rgb),calc(var(--glare-alpha) * .5)) calc(50% + var(--glare-width) * .5%),rgba(var(--glare-rgb),0) calc(50% + var(--glare-width) * 1%));background-size:200% 100%;background-position:50% 50%;opacity:0;transition:opacity .16s ease,background-position var(--transform-speed) ease;z-index:3}.soft-btn--right .soft-btn__content:after{opacity:1;background-position:0% 50%}.soft-btn--middle .soft-btn__content:after{opacity:1;background-position:50% 50%}.soft-btn--left .soft-btn__content:after{opacity:1;background-position:100% 50%}.soft-btn--active .soft-btn__content:after{opacity:1;background:rgba(var(--glare-rgb),var(--glare-alpha));background-position:50% 50%}@supports (-moz-appearance: none){.soft-btn--left,.soft-btn--right{--edge-aa: 1.25px}}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ (function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b["react-tilt-button"]={},b.React))})(this,(function(b,m){"use strict";var D={exports:{}},w={};var se;function de(){if(se)return w;se=1;var c=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(d,i,u){var E=null;if(u!==void 0&&(E=""+u),i.key!==void 0&&(E=""+i.key),"key"in i){u={};for(var R in i)R!=="key"&&(u[R]=i[R])}else u=i;return i=u.ref,{$$typeof:c,type:d,key:E,ref:i!==void 0?i:null,props:u}}return w.Fragment=s,w.jsx=l,w.jsxs=l,w}var O={};var le;function be(){return le||(le=1,process.env.NODE_ENV!=="production"&&(function(){function c(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case re:return"Profiler";case ee:return"StrictMode";case ne:return"Suspense";case x:return"SuspenseList";case X:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case k:return"Portal";case oe:return e.displayName||"Context";case te:return(e._context.displayName||"Context")+".Consumer";case N:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return r=e.displayName||null,r!==null?r:c(e.type)||"Memo";case y:r=e._payload,e=e._init;try{return c(e(r))}catch{}}return null}function s(e){return""+e}function l(e){try{s(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),s(e)}}function d(e){if(e===C)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var r=c(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function i(){var e=A.A;return e===null?null:e.getOwner()}function u(){return Error("react-stack-top-frame")}function E(e){if(z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function R(e,r){function t(){h||(h=!0,console.error("%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://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function K(){var e=c(this.type);return G[e]||(G[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function P(e,r,t,o,S,W){var n=t.ref;return e={$$typeof:B,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:K}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,t,o,S,W){var n=r.children;if(n!==void 0)if(o)if(ie(n)){for(o=0;o<n.length;o++)U(n[o]);Object.freeze&&Object.freeze(n)}else console.error("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 U(n);if(z.call(r,"key")){n=c(e);var p=Object.keys(r).filter(function(ae){return ae!=="key"});o=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",H[n+o]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
3
3
  let props = %s;
4
4
  <%s {...props} />
5
5
  React keys must be passed directly to JSX without using spread:
6
6
  let props = %s;
7
- <%s key={someKey} {...props} />`,o,n,_,n),Z[n+o]=!0)}if(n=null,t!==void 0&&(l(t),n=""+t),T(r)&&(l(r.key),n=""+r.key),"key"in r){t={};for(var v in r)v!=="key"&&(t[v]=r[v])}else t=r;return n&&C(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),x(e,n,t,i(),A,S)}function U(e){V(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?V(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function V(e){return typeof e=="object"&&e!==null&&e.$$typeof===P}var h=m,P=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),I=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),M=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),W=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=Object.prototype.hasOwnProperty,ne=Array.isArray,p=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(e){return e()}};var z,G={},q=h.react_stack_bottom_frame.bind(h,f)(),H=p(d(f)),Z={};O.Fragment=N,O.jsx=function(e,r,t){var o=1e4>W.recentlyCreatedOwnerStacks++;return L(e,r,t,!1,o?Error("react-stack-top-frame"):q,o?p(d(e)):H)},O.jsxs=function(e,r,t){var o=1e4>W.recentlyCreatedOwnerStacks++;return L(e,r,t,!0,o?Error("react-stack-top-frame"):q,o?p(d(e)):H)}})()),O}var ce;function de(){return ce||(ce=1,process.env.NODE_ENV==="production"?$.exports=fe():$.exports=ue()),$.exports}var D=de();const Q={solid:{surfaceColor:"#3b82f6",sideColor:"#1d4ed8",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},outline:{surfaceColor:"#ffffff",sideColor:"#2563eb",textColor:"#2563eb",borderColor:"#2563eb",borderWidth:3},dark:{surfaceColor:"#181818",sideColor:"#494949",textColor:"#e5e7eb",borderColor:"#5e5e5e",borderWidth:3},arcade:{surfaceColor:"#22b8c7",sideColor:"#e5dd4a",textColor:"#fef08a",borderColor:"#fef08a",borderWidth:3},gum:{surfaceColor:"#f472b6",sideColor:"#db2777",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},carbon:{surfaceColor:"#2a2a37",sideColor:"#8b5e3c",textColor:"#c4a484",borderColor:"#8b5f39",borderWidth:4},warning:{surfaceColor:"#2c2c39",sideColor:"#b22b3b",textColor:"#fff7ed",borderColor:"#d9445b",borderWidth:4},steel:{surfaceColor:"#cbd5e1",sideColor:"#64748b",textColor:"#020617",borderColor:"#475569",borderWidth:2},gold:{surfaceColor:"#ffcf10",sideColor:"#d29000",textColor:"#422006",borderColor:"#fff0a8",borderWidth:2},lavender:{surfaceColor:"#cec3fd",sideColor:"#b489ff",textColor:"#2e1065",borderColor:"#a36eff",borderWidth:4}};function F(c,s,l){return Math.max(s,Math.min(l,c))}function be({children:c,onClick:s,disabled:l=!1,variant:d="solid",elevation:i=14,pressInset:f=5,tilt:T=2,motion:C=160,width:k=260,height:x=64,radius:L=14,surfaceColor:U,sideColor:V,textColor:h,borderColor:P,borderWidth:j,glareColor:N="#ffffff",glareOpacity:K=0,glareWidth:ee=0,className:re="",style:I,...te}){const y=m.useRef(null),[B,J]=m.useState(!1),[g,M]=m.useState(null),X=Math.max(0,Number(x)||0),W=Math.max(0,Number(i)||0),ne=X*.3,p=F(W,0,ne),z=Math.max(0,Number(f)||0),G=F(z,0,p),q=Math.max(0,Number(T)||0),H=Number((p/9).toFixed(2)),Z=F(q,0,H),e=X-p,r=Math.max(0,Math.floor(e/4)),t=Math.max(0,Number(L)||0),o=F(t,0,r),A=Math.max(0,Number(C)||0);function S(a,u){const E=u.getBoundingClientRect(),R=a.clientX-E.left,ie=E.width||1;return R<ie*.33?"left":R>ie*.66?"right":"middle"}const n=a=>{if(l||a.button!==0&&a.pointerType==="mouse")return;const u=y.current;if(!u)return;u.setPointerCapture(a.pointerId);const E=S(a,u);M(R=>R===E?R:E),J(!0)},_=a=>{if(l||a.pointerType!=="mouse")return;const u=y.current;if(!u)return;const E=S(a,u);M(R=>R===E?R:E)},v=a=>{const u=y.current;try{u?.hasPointerCapture(a.pointerId)&&u.releasePointerCapture(a.pointerId)}catch{}J(!1),M(null),l&&B&&v(a)},ae=a=>{l||(v(a),s&&s(a))},pe=a=>{l||v(a)},_e=a=>{v(a)},Y=Q[d]||Q.solid,ve=U??Y.surfaceColor,Ee=V??Y.sideColor,Re=h??Y.textColor,Te=typeof P=="string"&&P.trim()!==""?P:Y.borderColor||"transparent",Ce=typeof j=="number"&&j>=0?j:Y.borderWidth??0,xe={...{"--button-raise-level":`${p}px`,"--press-inset":`${G}px`,"--button-hover-pressure":Z,"--transform-speed":`${A}ms`,"--radius":`${o}px`,"--surface-color":ve,"--side-color":Ee,"--text-color":Re,"--border-color":Te,"--border-width":`${Ce}px`,"--glare-rgb":me(N),"--glare-alpha":K,"--glare-width":ee,width:typeof k=="number"?`${k}px`:k,height:typeof x=="number"?`${x}px`:x},...I&&typeof I=="object"?I:{}},he=["soft-btn",B&&"soft-btn--active",g&&`soft-btn--${g}`,l&&"soft-btn--disabled",re].filter(Boolean).join(" ");return D.jsx("button",{...te,ref:y,className:he,style:xe,onPointerDown:n,onPointerMove:_,onPointerUp:ae,onPointerLeave:pe,onPointerCancel:_e,disabled:l,children:D.jsx("span",{className:"soft-btn__wrapper",children:D.jsx("span",{className:"soft-btn__content",children:D.jsx("span",{className:"soft-btn__inner",children:c})})})})}function me(c){if(!c||typeof c!="string")return"255,255,255";let s=c.replace("#","");if(s.length===3&&(s=s.split("").map(f=>f+f).join("")),s.length!==6)return"255,255,255";const l=parseInt(s.slice(0,2),16),d=parseInt(s.slice(2,4),16),i=parseInt(s.slice(4,6),16);return`${l},${d},${i}`}b.TiltButton=be,b.TiltButtonVariants=Q,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
7
+ <%s key={someKey} {...props} />`,o,n,p,n),H[n+o]=!0)}if(n=null,t!==void 0&&(l(t),n=""+t),E(r)&&(l(r.key),n=""+r.key),"key"in r){t={};for(var $ in r)$!=="key"&&(t[$]=r[$])}else t=r;return n&&R(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),P(e,n,t,i(),S,W)}function U(e){V(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?V(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function V(e){return typeof e=="object"&&e!==null&&e.$$typeof===B}var g=m,B=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),ee=Symbol.for("react.strict_mode"),re=Symbol.for("react.profiler"),te=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),ne=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),A=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=Object.prototype.hasOwnProperty,ie=Array.isArray,M=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(e){return e()}};var h,G={},I=g.react_stack_bottom_frame.bind(g,u)(),q=M(d(u)),H={};O.Fragment=C,O.jsx=function(e,r,t){var o=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,t,!1,o?Error("react-stack-top-frame"):I,o?M(d(e)):q)},O.jsxs=function(e,r,t){var o=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,t,!0,o?Error("react-stack-top-frame"):I,o?M(d(e)):q)}})()),O}var ce;function me(){return ce||(ce=1,process.env.NODE_ENV==="production"?D.exports=de():D.exports=be()),D.exports}var F=me();const Q={solid:{surfaceColor:"#3b82f6",sideColor:"#1d4ed8",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},outline:{surfaceColor:"#ffffff",sideColor:"#2563eb",textColor:"#2563eb",borderColor:"#2563eb",borderWidth:3},dark:{surfaceColor:"#181818",sideColor:"#494949",textColor:"#e5e7eb",borderColor:"#5e5e5e",borderWidth:3},arcade:{surfaceColor:"#22b8c7",sideColor:"#e5dd4a",textColor:"#fef08a",borderColor:"#fef08a",borderWidth:3},gum:{surfaceColor:"#f472b6",sideColor:"#db2777",textColor:"#ffffff",borderColor:"transparent",borderWidth:0},carbon:{surfaceColor:"#2a2a37",sideColor:"#8b5e3c",textColor:"#c4a484",borderColor:"#8b5f39",borderWidth:4},warning:{surfaceColor:"#2c2c39",sideColor:"#b22b3b",textColor:"#fff7ed",borderColor:"#d9445b",borderWidth:4},steel:{surfaceColor:"#cbd5e1",sideColor:"#64748b",textColor:"#020617",borderColor:"#475569",borderWidth:2},gold:{surfaceColor:"#ffcf10",sideColor:"#d29000",textColor:"#422006",borderColor:"#fff0a8",borderWidth:2},lavender:{surfaceColor:"#cec3fd",sideColor:"#b489ff",textColor:"#2e1065",borderColor:"#a36eff",borderWidth:4}};function L(c,s,l){return Math.max(s,Math.min(l,c))}function pe({children:c,onClick:s,disabled:l=!1,variant:d="solid",elevation:i=14,pressInset:u=5,tilt:E=2,pressTilt:R=!0,motion:K=160,width:P=260,height:T=64,radius:U=14,surfaceColor:V,sideColor:g,textColor:B,borderColor:k,borderWidth:C,glareColor:ee="#ffffff",glareOpacity:re=0,glareWidth:te=0,className:oe="",style:N,...ne}){const x=m.useRef(null),[J,y]=m.useState(!1),[X,j]=m.useState(null),A=Math.max(0,Number(T)||0),z=Math.max(0,Number(i)||0),M=A*.3,h=L(z,0,M),G=Math.max(0,Number(u)||0),I=L(G,0,h),q=Math.max(0,Number(E)||0),H=Number((h/9).toFixed(2)),e=L(q,0,H),t=x.current?.getBoundingClientRect()?.width||Number(P)||0,o=e*Math.PI/180,S=t/2*Math.tan(o),W=Math.max(0,I-S),n=A-h,p=Math.max(0,Math.floor(n/4)),$=Math.max(0,Number(U)||0),ae=L($,0,p),ve=Math.max(0,Number(K)||0);function ue(a,f){const _=f.getBoundingClientRect(),v=a.clientX-_.left,fe=_.width||1;return v<fe*.33?"left":v>fe*.66?"right":"middle"}const Ee=a=>{if(l||a.button!==0&&a.pointerType==="mouse")return;const f=x.current;if(!f)return;f.setPointerCapture(a.pointerId);const _=ue(a,f);j(v=>v===_?v:_),y(!0)},Re=a=>{if(l||a.pointerType!=="mouse")return;const f=x.current;if(!f)return;const _=ue(a,f);j(v=>v===_?v:_)},Z=a=>{const f=x.current;try{f?.hasPointerCapture(a.pointerId)&&f.releasePointerCapture(a.pointerId)}catch{}y(!1),j(null),l&&J&&Z(a)},Te=a=>{l||(Z(a),s&&s(a))},Ce=a=>{l||Z(a)},xe=a=>{Z(a)},Y=Q[d]||Q.solid,he=V??Y.surfaceColor,Pe=g??Y.sideColor,ge=B??Y.textColor,ye=typeof k=="string"&&k.trim()!==""?k:Y.borderColor||"transparent",Ae=typeof C=="number"&&C>=0?C:Y.borderWidth??0,Se={...{"--button-raise-level":`${h}px`,"--press-inset":`${I}px`,"--press-compensated":`${W}px`,"--button-hover-pressure":e,"--transform-speed":`${ve}ms`,"--radius":`${ae}px`,"--surface-color":he,"--side-color":Pe,"--text-color":ge,"--border-color":ye,"--border-width":`${Ae}px`,"--glare-rgb":_e(ee),"--glare-alpha":re,"--glare-width":te,width:typeof P=="number"?`${P}px`:P,height:typeof T=="number"?`${T}px`:T},...N&&typeof N=="object"?N:{}},we=["soft-btn",J&&"soft-btn--active",X&&`soft-btn--${X}`,l&&"soft-btn--disabled",R&&"soft-btn--press-tilt",oe].filter(Boolean).join(" ");return F.jsx("button",{...ne,ref:x,className:we,style:Se,onPointerDown:Ee,onPointerMove:Re,onPointerUp:Te,onPointerLeave:Ce,onPointerCancel:xe,disabled:l,children:F.jsx("span",{className:"soft-btn__wrapper",children:F.jsx("span",{className:"soft-btn__content",children:F.jsx("span",{className:"soft-btn__inner",children:c})})})})}function _e(c){if(!c||typeof c!="string")return"255,255,255";let s=c.replace("#","");if(s.length===3&&(s=s.split("").map(u=>u+u).join("")),s.length!==6)return"255,255,255";const l=parseInt(s.slice(0,2),16),d=parseInt(s.slice(2,4),16),i=parseInt(s.slice(4,6),16);return`${l},${d},${i}`}b.TiltButton=pe,b.TiltButtonVariants=Q,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-tilt-button",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "archisvaze",
@@ -11,7 +11,6 @@
11
11
  ],
12
12
  "main": "./dist/react-tilt-button.umd.js",
13
13
  "module": "./dist/react-tilt-button.es.js",
14
- "style": "./dist/react-tilt-button.css",
15
14
  "exports": {
16
15
  ".": {
17
16
  "import": "./dist/react-tilt-button.es.js",