react-tilt-button 0.0.6 → 0.0.8

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
@@ -164,12 +164,39 @@ These override the selected variant.
164
164
 
165
165
  | Prop |
166
166
  | ------------- |
167
- | `bordered` |
168
167
  | `borderColor` |
169
168
  | `borderWidth` |
170
169
 
171
170
  ---
172
171
 
172
+ ## Glare / Specular Highlight (Optional)
173
+
174
+ The button supports a **dynamic specular glare highlight** that simulates light reflecting off the surface.
175
+
176
+ It automatically shifts based on hover position (left / middle / right) and fades out on press.
177
+
178
+ ### Props
179
+
180
+ | Prop | Type | Default | Description |
181
+ | -------------- | ------ | --------- | ----------------------------------- |
182
+ | `glareColor` | string | `#ffffff` | Color of the glare highlight |
183
+ | `glareOpacity` | number | `0` | Intensity of the glare (0 → 1) |
184
+ | `glareWidth` | number | `0` | Width of glare band (0 → 100, in %) |
185
+
186
+ ### Example
187
+
188
+ ```jsx
189
+ <TiltButton
190
+ glareColor='#ffffff'
191
+ glareOpacity={0.12}
192
+ glareWidth={60}
193
+ >
194
+ Shiny Button
195
+ </TiltButton>
196
+ ```
197
+
198
+ ---
199
+
173
200
  ### Misc
174
201
 
175
202
  | Prop | Description |
@@ -201,24 +228,10 @@ All visuals are driven by CSS variables:
201
228
  - `--text-color`
202
229
  - `--border-color`
203
230
  - `--border-width`
231
+ - `--glare-rgb`
232
+ - `--glare-alpha`
233
+ - `--glare-width`
204
234
 
205
235
  So you can theme it externally if needed.
206
236
 
207
237
  ---
208
-
209
- ## Philosophy
210
-
211
- This is not a flat UI button.
212
-
213
- It is a **physical, tactile UI primitive** that behaves like an object:
214
-
215
- - It has depth
216
- - It deforms
217
- - It squishes
218
- - It reacts to pressure
219
-
220
- ---
221
-
222
- ## License
223
-
224
- Use it. Ship it. Modify it.
@@ -1 +1 @@
1
- .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;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-bottom-left-radius:var(--radius);border-bottom-right-radius:var(--radius);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}.soft-btn__inner{display:inline-flex;align-items:center;gap:10px}.soft-btn--bordered .soft-btn__content{box-shadow:inset 0 0 0 var(--border-width) var(--border-color)}.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--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}
1
+ .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__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;gap:10px;z-index:4}.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__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{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--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}}
@@ -1,80 +1,80 @@
1
- import me, { useRef as _e, useState as oe } from "react";
2
- var U = { exports: {} }, S = {};
3
- var ne;
4
- function pe() {
5
- if (ne) return S;
6
- ne = 1;
7
- var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), f = /* @__PURE__ */ Symbol.for("react.fragment");
8
- function a(i, s, c) {
9
- var d = null;
10
- if (c !== void 0 && (d = "" + c), s.key !== void 0 && (d = "" + s.key), "key" in s) {
11
- c = {};
12
- for (var b in s)
13
- b !== "key" && (c[b] = s[b]);
14
- } else c = s;
15
- return s = c.ref, {
16
- $$typeof: u,
17
- type: i,
18
- key: d,
19
- ref: s !== void 0 ? s : null,
20
- props: c
1
+ import ve, { useRef as Re, useState as ne } from "react";
2
+ var J = { exports: {} }, N = {};
3
+ var ae;
4
+ function Ce() {
5
+ if (ae) return N;
6
+ ae = 1;
7
+ var c = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function l(d, i, u) {
9
+ var v = null;
10
+ if (u !== void 0 && (v = "" + u), i.key !== void 0 && (v = "" + i.key), "key" in i) {
11
+ u = {};
12
+ for (var R in i)
13
+ R !== "key" && (u[R] = i[R]);
14
+ } else u = i;
15
+ return i = u.ref, {
16
+ $$typeof: c,
17
+ type: d,
18
+ key: v,
19
+ ref: i !== void 0 ? i : null,
20
+ props: u
21
21
  };
22
22
  }
23
- return S.Fragment = f, S.jsx = a, S.jsxs = a, S;
23
+ return N.Fragment = s, N.jsx = l, N.jsxs = l, N;
24
24
  }
25
- var N = {};
26
- var ae;
27
- function Ee() {
28
- return ae || (ae = 1, process.env.NODE_ENV !== "production" && (function() {
29
- function u(e) {
25
+ var j = {};
26
+ var se;
27
+ function xe() {
28
+ return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function c(e) {
30
30
  if (e == null) return null;
31
31
  if (typeof e == "function")
32
- return e.$$typeof === Q ? null : e.displayName || e.name || null;
32
+ return e.$$typeof === F ? null : e.displayName || e.name || null;
33
33
  if (typeof e == "string") return e;
34
34
  switch (e) {
35
- case C:
35
+ case y:
36
36
  return "Fragment";
37
- case T:
37
+ case Z:
38
38
  return "Profiler";
39
- case J:
39
+ case H:
40
40
  return "StrictMode";
41
- case h:
41
+ case T:
42
42
  return "Suspense";
43
- case W:
43
+ case Y:
44
44
  return "SuspenseList";
45
- case G:
45
+ case k:
46
46
  return "Activity";
47
47
  }
48
48
  if (typeof e == "object")
49
49
  switch (typeof e.tag == "number" && console.error(
50
50
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
51
  ), e.$$typeof) {
52
- case q:
52
+ case G:
53
53
  return "Portal";
54
- case $:
54
+ case w:
55
55
  return e.displayName || "Context";
56
- case X:
56
+ case Q:
57
57
  return (e._context.displayName || "Context") + ".Consumer";
58
- case z:
58
+ case K:
59
59
  var r = e.render;
60
60
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
- case E:
62
- return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
63
- case v:
61
+ case D:
62
+ return r = e.displayName || null, r !== null ? r : c(e.type) || "Memo";
63
+ case h:
64
64
  r = e._payload, e = e._init;
65
65
  try {
66
- return u(e(r));
66
+ return c(e(r));
67
67
  } catch {
68
68
  }
69
69
  }
70
70
  return null;
71
71
  }
72
- function f(e) {
72
+ function s(e) {
73
73
  return "" + e;
74
74
  }
75
- function a(e) {
75
+ function l(e) {
76
76
  try {
77
- f(e);
77
+ s(e);
78
78
  var r = !1;
79
79
  } catch {
80
80
  r = !0;
@@ -86,37 +86,37 @@ function Ee() {
86
86
  r,
87
87
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
88
  o
89
- ), f(e);
89
+ ), s(e);
90
90
  }
91
91
  }
92
- function i(e) {
93
- if (e === C) return "<>";
94
- if (typeof e == "object" && e !== null && e.$$typeof === v)
92
+ function d(e) {
93
+ if (e === y) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === h)
95
95
  return "<...>";
96
96
  try {
97
- var r = u(e);
97
+ var r = c(e);
98
98
  return r ? "<" + r + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
101
101
  }
102
102
  }
103
- function s() {
104
- var e = A.A;
103
+ function i() {
104
+ var e = O.A;
105
105
  return e === null ? null : e.getOwner();
106
106
  }
107
- function c() {
107
+ function u() {
108
108
  return Error("react-stack-top-frame");
109
109
  }
110
- function d(e) {
111
- if (m.call(e, "key")) {
110
+ function v(e) {
111
+ if (ee.call(e, "key")) {
112
112
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
113
113
  if (r && r.isReactWarning) return !1;
114
114
  }
115
115
  return e.key !== void 0;
116
116
  }
117
- function b(e, r) {
117
+ function R(e, r) {
118
118
  function t() {
119
- I || (I = !0, console.error(
119
+ L || (L = !0, console.error(
120
120
  "%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)",
121
121
  r
122
122
  ));
@@ -126,23 +126,23 @@ function Ee() {
126
126
  configurable: !0
127
127
  });
128
128
  }
129
- function x() {
130
- var e = u(this.type);
131
- return Y[e] || (Y[e] = !0, console.error(
129
+ function A() {
130
+ var e = c(this.type);
131
+ return U[e] || (U[e] = !0, console.error(
132
132
  "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."
133
133
  )), e = this.props.ref, e !== void 0 ? e : null;
134
134
  }
135
- function _(e, r, t, o, R, w) {
135
+ function C(e, r, t, o, P, g) {
136
136
  var n = t.ref;
137
137
  return e = {
138
- $$typeof: M,
138
+ $$typeof: W,
139
139
  type: e,
140
140
  key: r,
141
141
  props: t,
142
142
  _owner: o
143
143
  }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
144
144
  enumerable: !1,
145
- get: x
145
+ get: A
146
146
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
147
  configurable: !1,
148
148
  enumerable: !1,
@@ -157,33 +157,33 @@ function Ee() {
157
157
  configurable: !1,
158
158
  enumerable: !1,
159
159
  writable: !0,
160
- value: R
160
+ value: P
161
161
  }), Object.defineProperty(e, "_debugTask", {
162
162
  configurable: !1,
163
163
  enumerable: !1,
164
164
  writable: !0,
165
- value: w
165
+ value: g
166
166
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
167
  }
168
- function P(e, r, t, o, R, w) {
168
+ function I(e, r, t, o, P, g) {
169
169
  var n = r.children;
170
170
  if (n !== void 0)
171
171
  if (o)
172
- if (H(n)) {
172
+ if (re(n)) {
173
173
  for (o = 0; o < n.length; o++)
174
- j(n[o]);
174
+ $(n[o]);
175
175
  Object.freeze && Object.freeze(n);
176
176
  } else
177
177
  console.error(
178
178
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
179
  );
180
- else j(n);
181
- if (m.call(r, "key")) {
182
- n = u(e);
183
- var l = Object.keys(r).filter(function(Z) {
184
- return Z !== "key";
180
+ else $(n);
181
+ if (ee.call(r, "key")) {
182
+ n = c(e);
183
+ var m = Object.keys(r).filter(function(te) {
184
+ return te !== "key";
185
185
  });
186
- o = 0 < l.length ? "{key: someKey, " + l.join(": ..., ") + ": ...}" : "{key: someKey}", L[n + o] || (l = 0 < l.length ? "{" + l.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", B[n + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error(
187
187
  `A props object containing a "key" prop is being spread into JSX:
188
188
  let props = %s;
189
189
  <%s {...props} />
@@ -192,79 +192,78 @@ React keys must be passed directly to JSX without using spread:
192
192
  <%s key={someKey} {...props} />`,
193
193
  o,
194
194
  n,
195
- l,
195
+ m,
196
196
  n
197
- ), L[n + o] = !0);
197
+ ), B[n + o] = !0);
198
198
  }
199
- if (n = null, t !== void 0 && (a(t), n = "" + t), d(r) && (a(r.key), n = "" + r.key), "key" in r) {
199
+ if (n = null, t !== void 0 && (l(t), n = "" + t), v(r) && (l(r.key), n = "" + r.key), "key" in r) {
200
200
  t = {};
201
- for (var O in r)
202
- O !== "key" && (t[O] = r[O]);
201
+ for (var p in r)
202
+ p !== "key" && (t[p] = r[p]);
203
203
  } else t = r;
204
- return n && b(
204
+ return n && R(
205
205
  t,
206
206
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
- ), _(
207
+ ), C(
208
208
  e,
209
209
  n,
210
210
  t,
211
- s(),
212
- R,
213
- w
211
+ i(),
212
+ P,
213
+ g
214
214
  );
215
215
  }
216
- function j(e) {
217
- g(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === v && (e._payload.status === "fulfilled" ? g(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
216
+ function $(e) {
217
+ M(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === h && (e._payload.status === "fulfilled" ? M(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
218
  }
219
- function g(e) {
220
- return typeof e == "object" && e !== null && e.$$typeof === M;
219
+ function M(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === W;
221
221
  }
222
- var p = me, M = /* @__PURE__ */ Symbol.for("react.transitional.element"), q = /* @__PURE__ */ Symbol.for("react.portal"), C = /* @__PURE__ */ Symbol.for("react.fragment"), J = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), X = /* @__PURE__ */ Symbol.for("react.consumer"), $ = /* @__PURE__ */ Symbol.for("react.context"), z = /* @__PURE__ */ Symbol.for("react.forward_ref"), h = /* @__PURE__ */ Symbol.for("react.suspense"), W = /* @__PURE__ */ Symbol.for("react.suspense_list"), E = /* @__PURE__ */ Symbol.for("react.memo"), v = /* @__PURE__ */ Symbol.for("react.lazy"), G = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), A = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, m = Object.prototype.hasOwnProperty, H = Array.isArray, k = console.createTask ? console.createTask : function() {
222
+ var x = ve, W = /* @__PURE__ */ Symbol.for("react.transitional.element"), G = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__PURE__ */ Symbol.for("react.fragment"), H = /* @__PURE__ */ Symbol.for("react.strict_mode"), Z = /* @__PURE__ */ Symbol.for("react.profiler"), Q = /* @__PURE__ */ Symbol.for("react.consumer"), w = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), T = /* @__PURE__ */ Symbol.for("react.suspense"), Y = /* @__PURE__ */ Symbol.for("react.suspense_list"), D = /* @__PURE__ */ Symbol.for("react.memo"), h = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.activity"), F = /* @__PURE__ */ Symbol.for("react.client.reference"), O = 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
223
  return null;
224
224
  };
225
- p = {
225
+ x = {
226
226
  react_stack_bottom_frame: function(e) {
227
227
  return e();
228
228
  }
229
229
  };
230
- var I, Y = {}, D = p.react_stack_bottom_frame.bind(
231
- p,
232
- c
233
- )(), F = k(i(c)), L = {};
234
- N.Fragment = C, N.jsx = function(e, r, t) {
235
- var o = 1e4 > A.recentlyCreatedOwnerStacks++;
236
- return P(
230
+ var L, U = {}, V = x.react_stack_bottom_frame.bind(
231
+ x,
232
+ u
233
+ )(), q = b(d(u)), B = {};
234
+ j.Fragment = y, j.jsx = function(e, r, t) {
235
+ var o = 1e4 > O.recentlyCreatedOwnerStacks++;
236
+ return I(
237
237
  e,
238
238
  r,
239
239
  t,
240
240
  !1,
241
- o ? Error("react-stack-top-frame") : D,
242
- o ? k(i(e)) : F
241
+ o ? Error("react-stack-top-frame") : V,
242
+ o ? b(d(e)) : q
243
243
  );
244
- }, N.jsxs = function(e, r, t) {
245
- var o = 1e4 > A.recentlyCreatedOwnerStacks++;
246
- return P(
244
+ }, j.jsxs = function(e, r, t) {
245
+ var o = 1e4 > O.recentlyCreatedOwnerStacks++;
246
+ return I(
247
247
  e,
248
248
  r,
249
249
  t,
250
250
  !0,
251
- o ? Error("react-stack-top-frame") : D,
252
- o ? k(i(e)) : F
251
+ o ? Error("react-stack-top-frame") : V,
252
+ o ? b(d(e)) : q
253
253
  );
254
254
  };
255
- })()), N;
255
+ })()), j;
256
256
  }
257
- var se;
258
- function ve() {
259
- return se || (se = 1, process.env.NODE_ENV === "production" ? U.exports = pe() : U.exports = Ee()), U.exports;
257
+ var le;
258
+ function Te() {
259
+ return le || (le = 1, process.env.NODE_ENV === "production" ? J.exports = Ce() : J.exports = xe()), J.exports;
260
260
  }
261
- var V = ve();
262
- const le = {
261
+ var X = Te();
262
+ const ce = {
263
263
  solid: {
264
264
  surfaceColor: "#3b82f6",
265
265
  sideColor: "#1d4ed8",
266
266
  textColor: "#ffffff",
267
- bordered: !1,
268
267
  borderColor: "transparent",
269
268
  borderWidth: 0
270
269
  },
@@ -272,7 +271,6 @@ const le = {
272
271
  surfaceColor: "#ffffff",
273
272
  sideColor: "#2563eb",
274
273
  textColor: "#2563eb",
275
- bordered: !0,
276
274
  borderColor: "#2563eb",
277
275
  borderWidth: 3
278
276
  },
@@ -280,7 +278,6 @@ const le = {
280
278
  surfaceColor: "#181818",
281
279
  sideColor: "#494949",
282
280
  textColor: "#e5e7eb",
283
- bordered: !0,
284
281
  borderColor: "#5e5e5e",
285
282
  borderWidth: 3
286
283
  },
@@ -288,7 +285,6 @@ const le = {
288
285
  surfaceColor: "#22b8c7",
289
286
  sideColor: "#e5dd4a",
290
287
  textColor: "#fef08a",
291
- bordered: !0,
292
288
  borderColor: "#fef08a",
293
289
  borderWidth: 3
294
290
  },
@@ -296,7 +292,6 @@ const le = {
296
292
  surfaceColor: "#f472b6",
297
293
  sideColor: "#db2777",
298
294
  textColor: "#ffffff",
299
- bordered: !1,
300
295
  borderColor: "transparent",
301
296
  borderWidth: 0
302
297
  },
@@ -304,7 +299,6 @@ const le = {
304
299
  surfaceColor: "#2a2a37",
305
300
  sideColor: "#8b5e3c",
306
301
  textColor: "#c4a484",
307
- bordered: !0,
308
302
  borderColor: "#8b5f39",
309
303
  borderWidth: 4
310
304
  },
@@ -312,7 +306,6 @@ const le = {
312
306
  surfaceColor: "#2c2c39",
313
307
  sideColor: "#b22b3b",
314
308
  textColor: "#fff7ed",
315
- bordered: !0,
316
309
  borderColor: "#d9445b",
317
310
  borderWidth: 4
318
311
  },
@@ -320,7 +313,6 @@ const le = {
320
313
  surfaceColor: "#cbd5e1",
321
314
  sideColor: "#64748b",
322
315
  textColor: "#020617",
323
- bordered: !0,
324
316
  borderColor: "#475569",
325
317
  borderWidth: 2
326
318
  },
@@ -328,7 +320,6 @@ const le = {
328
320
  surfaceColor: "#ffcf10",
329
321
  sideColor: "#d29000",
330
322
  textColor: "#422006",
331
- bordered: !0,
332
323
  borderColor: "#fff0a8",
333
324
  borderWidth: 2
334
325
  },
@@ -336,89 +327,115 @@ const le = {
336
327
  surfaceColor: "#cec3fd",
337
328
  sideColor: "#b489ff",
338
329
  textColor: "#2e1065",
339
- bordered: !1,
340
330
  borderColor: "#a36eff",
341
331
  borderWidth: 4
342
332
  }
343
333
  };
344
- function B(u, f, a) {
345
- return Math.max(f, Math.min(a, u));
334
+ function z(c, s, l) {
335
+ return Math.max(s, Math.min(l, c));
346
336
  }
347
- function Te({
348
- children: u,
349
- onClick: f,
350
- disabled: a = !1,
351
- variant: i = "solid",
352
- elevation: s = 14,
353
- pressInset: c = 5,
354
- tilt: d = 2,
355
- motion: b = 160,
356
- width: x = 260,
357
- height: _ = 64,
358
- radius: P = 14,
359
- surfaceColor: j,
360
- sideColor: g,
361
- textColor: p,
362
- bordered: M,
363
- borderColor: q,
364
- borderWidth: C,
365
- className: J = "",
366
- style: T,
367
- ...X
337
+ function ye({
338
+ children: c,
339
+ onClick: s,
340
+ disabled: l = !1,
341
+ variant: d = "solid",
342
+ elevation: i = 14,
343
+ pressInset: u = 5,
344
+ tilt: v = 2,
345
+ motion: R = 160,
346
+ width: A = 260,
347
+ height: C = 64,
348
+ radius: I = 14,
349
+ surfaceColor: $,
350
+ sideColor: M,
351
+ textColor: x,
352
+ borderColor: W,
353
+ borderWidth: G,
354
+ glareColor: y = "#ffffff",
355
+ glareOpacity: H = 0,
356
+ glareWidth: Z = 0,
357
+ className: Q = "",
358
+ style: w,
359
+ ...K
368
360
  }) {
369
- const $ = _e(null), [z, h] = oe(!1), [W, E] = oe(null), v = Math.max(0, Number(_) || 0), G = Math.max(0, Number(s) || 0), A = v * 0.3, m = B(G, 0, A), H = Math.max(0, Number(c) || 0), k = B(H, 0, m), I = Math.max(0, Number(d) || 0), Y = Number((m / 9).toFixed(2)), D = B(I, 0, Y), F = v - m, L = Math.max(0, Math.floor(F / 4)), e = Math.max(0, Number(P) || 0), r = B(e, 0, L), t = Math.max(0, Number(b) || 0), o = (y) => {
370
- if (a) return;
371
- const K = $.current;
372
- if (!K) return;
373
- const ee = K.getBoundingClientRect(), re = y.clientX - ee.left, te = ee.width || 1;
374
- re < te * 0.33 ? E("left") : re > te * 0.66 ? E("right") : E("middle");
375
- }, R = () => {
376
- E(null), h(!1);
377
- }, w = (y) => {
378
- a || y.button === 0 && h(!0);
379
- }, n = (y) => {
380
- a || (h(!1), f && f(y));
381
- }, l = le[i] || le.solid, O = j ?? l.surfaceColor, Z = g ?? l.sideColor, ce = p ?? l.textColor, ue = M ?? l.bordered, fe = q ?? l.borderColor, ie = C ?? l.borderWidth, de = {
361
+ const T = Re(null), [Y, D] = ne(!1), [h, k] = ne(null), F = Math.max(0, Number(C) || 0), O = Math.max(0, Number(i) || 0), re = F * 0.3, b = z(O, 0, re), L = Math.max(0, Number(u) || 0), U = z(L, 0, b), V = Math.max(0, Number(v) || 0), q = Number((b / 9).toFixed(2)), B = z(V, 0, q), e = F - b, r = Math.max(0, Math.floor(e / 4)), t = Math.max(0, Number(I) || 0), o = z(t, 0, r), P = Math.max(0, Number(R) || 0);
362
+ function g(a, f) {
363
+ const _ = f.getBoundingClientRect(), E = a.clientX - _.left, oe = _.width || 1;
364
+ return E < oe * 0.33 ? "left" : E > oe * 0.66 ? "right" : "middle";
365
+ }
366
+ const n = (a) => {
367
+ if (l || a.button !== 0 && a.pointerType === "mouse") return;
368
+ const f = T.current;
369
+ if (!f) return;
370
+ f.setPointerCapture(a.pointerId);
371
+ const _ = g(a, f);
372
+ k((E) => E === _ ? E : _), D(!0);
373
+ }, m = (a) => {
374
+ if (l || a.pointerType !== "mouse") return;
375
+ const f = T.current;
376
+ if (!f) return;
377
+ const _ = g(a, f);
378
+ k((E) => E === _ ? E : _);
379
+ }, p = (a) => {
380
+ const f = T.current;
381
+ try {
382
+ f?.hasPointerCapture(a.pointerId) && f.releasePointerCapture(a.pointerId);
383
+ } catch {
384
+ }
385
+ D(!1), k(null), l && Y && p(a);
386
+ }, te = (a) => {
387
+ l || (p(a), s && s(a));
388
+ }, ie = (a) => {
389
+ l || p(a);
390
+ }, ue = (a) => {
391
+ p(a);
392
+ }, S = ce[d] || ce.solid, fe = $ ?? S.surfaceColor, de = M ?? S.sideColor, be = x ?? S.textColor, me = W ?? S.borderColor, pe = G ?? S.borderWidth ?? 0, _e = {
382
393
  ...{
383
- "--button-raise-level": `${m}px`,
384
- "--press-inset": `${k}px`,
385
- "--button-hover-pressure": D,
386
- "--transform-speed": `${t}ms`,
387
- "--radius": `${r}px`,
388
- "--surface-color": O,
389
- "--side-color": Z,
390
- "--text-color": ce,
391
- "--border-color": fe,
392
- "--border-width": `${ie}px`,
393
- width: typeof x == "number" ? `${x}px` : x,
394
- height: typeof _ == "number" ? `${_}px` : _
394
+ "--button-raise-level": `${b}px`,
395
+ "--press-inset": `${U}px`,
396
+ "--button-hover-pressure": B,
397
+ "--transform-speed": `${P}ms`,
398
+ "--radius": `${o}px`,
399
+ "--surface-color": fe,
400
+ "--side-color": de,
401
+ "--text-color": be,
402
+ "--border-color": me,
403
+ "--border-width": `${pe}px`,
404
+ "--glare-rgb": he(y),
405
+ "--glare-alpha": H,
406
+ "--glare-width": Z,
407
+ width: typeof A == "number" ? `${A}px` : A,
408
+ height: typeof C == "number" ? `${C}px` : C
395
409
  },
396
- ...T && typeof T == "object" ? T : {}
397
- }, be = [
398
- "soft-btn",
399
- z && "soft-btn--active",
400
- W && `soft-btn--${W}`,
401
- a && "soft-btn--disabled",
402
- ue && "soft-btn--bordered",
403
- J
404
- ].filter(Boolean).join(" ");
405
- return /* @__PURE__ */ V.jsx(
410
+ ...w && typeof w == "object" ? w : {}
411
+ }, Ee = ["soft-btn", Y && "soft-btn--active", h && `soft-btn--${h}`, l && "soft-btn--disabled", Q].filter(Boolean).join(" ");
412
+ return /* @__PURE__ */ X.jsx(
406
413
  "button",
407
414
  {
408
- ...X,
409
- ref: $,
410
- className: be,
411
- style: de,
412
- onMouseMove: o,
413
- onMouseLeave: R,
414
- onMouseDown: w,
415
- onMouseUp: n,
416
- disabled: a,
417
- children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ V.jsx("span", { className: "soft-btn__inner", children: u }) }) })
415
+ ...K,
416
+ ref: T,
417
+ className: Ee,
418
+ style: _e,
419
+ onPointerDown: n,
420
+ onPointerMove: m,
421
+ onPointerUp: te,
422
+ onPointerLeave: ie,
423
+ onPointerCancel: ue,
424
+ disabled: l,
425
+ children: /* @__PURE__ */ X.jsx("span", { className: "soft-btn__wrapper", children: /* @__PURE__ */ X.jsx("span", { className: "soft-btn__content", children: /* @__PURE__ */ X.jsx("span", { className: "soft-btn__inner", children: c }) }) })
418
426
  }
419
427
  );
420
428
  }
429
+ function he(c) {
430
+ if (!c || typeof c != "string")
431
+ return "255,255,255";
432
+ let s = c.replace("#", "");
433
+ if (s.length === 3 && (s = s.split("").map((u) => u + u).join("")), s.length !== 6)
434
+ return "255,255,255";
435
+ const l = parseInt(s.slice(0, 2), 16), d = parseInt(s.slice(2, 4), 16), i = parseInt(s.slice(4, 6), 16);
436
+ return `${l},${d},${i}`;
437
+ }
421
438
  export {
422
- Te as TiltButton,
423
- le as TiltButtonVariants
439
+ ye as TiltButton,
440
+ ce as TiltButtonVariants
424
441
  };
@@ -1,6 +1,6 @@
1
- (function(i,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(i=typeof globalThis<"u"?globalThis:i||self,d(i["react-tilt-button"]={},i.React))})(this,(function(i,d){"use strict";var g={exports:{}},C={};var re;function ue(){if(re)return C;re=1;var u=Symbol.for("react.transitional.element"),f=Symbol.for("react.fragment");function a(b,s,c){var m=null;if(c!==void 0&&(m=""+c),s.key!==void 0&&(m=""+s.key),"key"in s){c={};for(var p in s)p!=="key"&&(c[p]=s[p])}else c=s;return s=c.ref,{$$typeof:u,type:b,key:m,ref:s!==void 0?s:null,props:c}}return C.Fragment=f,C.jsx=a,C.jsxs=a,C}var h={};var te;function fe(){return te||(te=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case O:return"Profiler";case q:return"StrictMode";case S:return"Suspense";case L:return"SuspenseList";case Q: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 G:return"Portal";case F:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case Z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case R:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case T:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function f(e){return""+e}function a(e){try{f(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),f(e)}}function b(e){if(e===y)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===T)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=k.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function m(e){if(_.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function p(e,r){function t(){U||(U=!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 A(){var e=u(this.type);return V[e]||(V[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 v(e,r,t,o,x,N){var n=t.ref;return e={$$typeof:D,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:A}):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:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function I(e,r,t,o,x,N){var n=r.children;if(n!==void 0)if(o)if(K(n)){for(o=0;o<n.length;o++)Y(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 Y(n);if(_.call(r,"key")){n=u(e);var l=Object.keys(r).filter(function(ee){return ee!=="key"});o=0<l.length?"{key: someKey, "+l.join(": ..., ")+": ...}":"{key: someKey}",X[n+o]||(l=0<l.length?"{"+l.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (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 W={exports:{}},S={};var se;function fe(){if(se)return S;se=1;var c=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function l(d,i,f){var C=null;if(f!==void 0&&(C=""+f),i.key!==void 0&&(C=""+i.key),"key"in i){f={};for(var T in i)T!=="key"&&(f[T]=i[T])}else f=i;return i=f.ref,{$$typeof:c,type:d,key:C,ref:i!==void 0?i:null,props:f}}return S.Fragment=s,S.jsx=l,S.jsxs=l,S}var w={};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===J?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case ee:return"Profiler";case K:return"StrictMode";case P:return"Suspense";case V:return"SuspenseList";case N: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 Q:return"Portal";case j: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 B: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===k)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=I.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function C(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 T(e,r){function t(){X||(X=!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 O(){var e=c(this.type);return z[e]||(z[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,g,A){var n=t.ref;return e={$$typeof:U,type:e,key:r,props:t,_owner:o},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:O}):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:g}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function D(e,r,t,o,g,A){var n=r.children;if(n!==void 0)if(o)if(ne(n)){for(o=0;o<n.length;o++)F(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 F(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}",H[n+o]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,o,n,l,n),X[n+o]=!0)}if(n=null,t!==void 0&&(a(t),n=""+t),m(r)&&(a(r.key),n=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return n&&p(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,n,t,s(),x,N)}function Y(e){$(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===T&&(e._payload.status==="fulfilled"?$(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function $(e){return typeof e=="object"&&e!==null&&e.$$typeof===D}var E=d,D=Symbol.for("react.transitional.element"),G=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),F=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),k=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=Object.prototype.hasOwnProperty,K=Array.isArray,w=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var U,V={},B=E.react_stack_bottom_frame.bind(E,c)(),J=w(b(c)),X={};h.Fragment=y,h.jsx=function(e,r,t){var o=1e4>k.recentlyCreatedOwnerStacks++;return I(e,r,t,!1,o?Error("react-stack-top-frame"):B,o?w(b(e)):J)},h.jsxs=function(e,r,t){var o=1e4>k.recentlyCreatedOwnerStacks++;return I(e,r,t,!0,o?Error("react-stack-top-frame"):B,o?w(b(e)):J)}})()),h}var oe;function ie(){return oe||(oe=1,process.env.NODE_ENV==="production"?g.exports=ue():g.exports=fe()),g.exports}var M=ie();const z={solid:{surfaceColor:"#3b82f6",sideColor:"#1d4ed8",textColor:"#ffffff",bordered:!1,borderColor:"transparent",borderWidth:0},outline:{surfaceColor:"#ffffff",sideColor:"#2563eb",textColor:"#2563eb",bordered:!0,borderColor:"#2563eb",borderWidth:3},dark:{surfaceColor:"#181818",sideColor:"#494949",textColor:"#e5e7eb",bordered:!0,borderColor:"#5e5e5e",borderWidth:3},arcade:{surfaceColor:"#22b8c7",sideColor:"#e5dd4a",textColor:"#fef08a",bordered:!0,borderColor:"#fef08a",borderWidth:3},gum:{surfaceColor:"#f472b6",sideColor:"#db2777",textColor:"#ffffff",bordered:!1,borderColor:"transparent",borderWidth:0},carbon:{surfaceColor:"#2a2a37",sideColor:"#8b5e3c",textColor:"#c4a484",bordered:!0,borderColor:"#8b5f39",borderWidth:4},warning:{surfaceColor:"#2c2c39",sideColor:"#b22b3b",textColor:"#fff7ed",bordered:!0,borderColor:"#d9445b",borderWidth:4},steel:{surfaceColor:"#cbd5e1",sideColor:"#64748b",textColor:"#020617",bordered:!0,borderColor:"#475569",borderWidth:2},gold:{surfaceColor:"#ffcf10",sideColor:"#d29000",textColor:"#422006",bordered:!0,borderColor:"#fff0a8",borderWidth:2},lavender:{surfaceColor:"#cec3fd",sideColor:"#b489ff",textColor:"#2e1065",bordered:!1,borderColor:"#a36eff",borderWidth:4}};function W(u,f,a){return Math.max(f,Math.min(a,u))}function de({children:u,onClick:f,disabled:a=!1,variant:b="solid",elevation:s=14,pressInset:c=5,tilt:m=2,motion:p=160,width:A=260,height:v=64,radius:I=14,surfaceColor:Y,sideColor:$,textColor:E,bordered:D,borderColor:G,borderWidth:y,className:q="",style:O,...H}){const F=d.useRef(null),[Z,S]=d.useState(!1),[L,R]=d.useState(null),T=Math.max(0,Number(v)||0),Q=Math.max(0,Number(s)||0),k=T*.3,_=W(Q,0,k),K=Math.max(0,Number(c)||0),w=W(K,0,_),U=Math.max(0,Number(m)||0),V=Number((_/9).toFixed(2)),B=W(U,0,V),J=T-_,X=Math.max(0,Math.floor(J/4)),e=Math.max(0,Number(I)||0),r=W(e,0,X),t=Math.max(0,Number(p)||0),o=j=>{if(a)return;const ae=F.current;if(!ae)return;const se=ae.getBoundingClientRect(),le=j.clientX-se.left,ce=se.width||1;le<ce*.33?R("left"):le>ce*.66?R("right"):R("middle")},x=()=>{R(null),S(!1)},N=j=>{a||j.button===0&&S(!0)},n=j=>{a||(S(!1),f&&f(j))},l=z[b]||z.solid,P=Y??l.surfaceColor,ee=$??l.sideColor,be=E??l.textColor,me=D??l.bordered,pe=G??l.borderColor,_e=y??l.borderWidth,ve={...{"--button-raise-level":`${_}px`,"--press-inset":`${w}px`,"--button-hover-pressure":B,"--transform-speed":`${t}ms`,"--radius":`${r}px`,"--surface-color":P,"--side-color":ee,"--text-color":be,"--border-color":pe,"--border-width":`${_e}px`,width:typeof A=="number"?`${A}px`:A,height:typeof v=="number"?`${v}px`:v},...O&&typeof O=="object"?O:{}},Ee=["soft-btn",Z&&"soft-btn--active",L&&`soft-btn--${L}`,a&&"soft-btn--disabled",me&&"soft-btn--bordered",q].filter(Boolean).join(" ");return M.jsx("button",{...H,ref:F,className:Ee,style:ve,onMouseMove:o,onMouseLeave:x,onMouseDown:N,onMouseUp:n,disabled:a,children:M.jsx("span",{className:"soft-btn__wrapper",children:M.jsx("span",{className:"soft-btn__content",children:M.jsx("span",{className:"soft-btn__inner",children:u})})})})}i.TiltButton=de,i.TiltButtonVariants=z,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
6
+ <%s key={someKey} {...props} />`,o,n,_,n),H[n+o]=!0)}if(n=null,t!==void 0&&(l(t),n=""+t),C(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&&T(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),x(e,n,t,i(),g,A)}function F(e){L(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?L(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function L(e){return typeof e=="object"&&e!==null&&e.$$typeof===U}var h=m,U=Symbol.for("react.transitional.element"),Q=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),j=Symbol.for("react.context"),te=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),J=Symbol.for("react.client.reference"),I=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 X,z={},G=h.react_stack_bottom_frame.bind(h,f)(),q=p(d(f)),H={};w.Fragment=k,w.jsx=function(e,r,t){var o=1e4>I.recentlyCreatedOwnerStacks++;return D(e,r,t,!1,o?Error("react-stack-top-frame"):G,o?p(d(e)):q)},w.jsxs=function(e,r,t){var o=1e4>I.recentlyCreatedOwnerStacks++;return D(e,r,t,!0,o?Error("react-stack-top-frame"):G,o?p(d(e)):q)}})()),w}var ce;function de(){return ce||(ce=1,process.env.NODE_ENV==="production"?W.exports=fe():W.exports=ue()),W.exports}var Y=de();const Z={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 $(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:C=2,motion:T=160,width:O=260,height:x=64,radius:D=14,surfaceColor:F,sideColor:L,textColor:h,borderColor:U,borderWidth:Q,glareColor:k="#ffffff",glareOpacity:K=0,glareWidth:ee=0,className:re="",style:j,...te}){const P=m.useRef(null),[V,B]=m.useState(!1),[y,N]=m.useState(null),J=Math.max(0,Number(x)||0),I=Math.max(0,Number(i)||0),ne=J*.3,p=$(I,0,ne),X=Math.max(0,Number(f)||0),z=$(X,0,p),G=Math.max(0,Number(C)||0),q=Number((p/9).toFixed(2)),H=$(G,0,q),e=J-p,r=Math.max(0,Math.floor(e/4)),t=Math.max(0,Number(D)||0),o=$(t,0,r),g=Math.max(0,Number(T)||0);function A(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=P.current;if(!u)return;u.setPointerCapture(a.pointerId);const E=A(a,u);N(R=>R===E?R:E),B(!0)},_=a=>{if(l||a.pointerType!=="mouse")return;const u=P.current;if(!u)return;const E=A(a,u);N(R=>R===E?R:E)},v=a=>{const u=P.current;try{u?.hasPointerCapture(a.pointerId)&&u.releasePointerCapture(a.pointerId)}catch{}B(!1),N(null),l&&V&&v(a)},ae=a=>{l||(v(a),s&&s(a))},pe=a=>{l||v(a)},_e=a=>{v(a)},M=Z[d]||Z.solid,ve=F??M.surfaceColor,Ee=L??M.sideColor,Re=h??M.textColor,Ce=U??M.borderColor,Te=Q??M.borderWidth??0,xe={...{"--button-raise-level":`${p}px`,"--press-inset":`${z}px`,"--button-hover-pressure":H,"--transform-speed":`${g}ms`,"--radius":`${o}px`,"--surface-color":ve,"--side-color":Ee,"--text-color":Re,"--border-color":Ce,"--border-width":`${Te}px`,"--glare-rgb":me(k),"--glare-alpha":K,"--glare-width":ee,width:typeof O=="number"?`${O}px`:O,height:typeof x=="number"?`${x}px`:x},...j&&typeof j=="object"?j:{}},he=["soft-btn",V&&"soft-btn--active",y&&`soft-btn--${y}`,l&&"soft-btn--disabled",re].filter(Boolean).join(" ");return Y.jsx("button",{...te,ref:P,className:he,style:xe,onPointerDown:n,onPointerMove:_,onPointerUp:ae,onPointerLeave:pe,onPointerCancel:_e,disabled:l,children:Y.jsx("span",{className:"soft-btn__wrapper",children:Y.jsx("span",{className:"soft-btn__content",children:Y.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=Z,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.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "archisvaze",