@juanlaria/lifted 0.1.2 → 0.1.4

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
@@ -70,8 +70,9 @@ instance.destroy(); // Cleanup
70
70
  | `background` | `string` | — | Background color (CSS). Used to auto-calculate shadow color. |
71
71
  | `shadowColor` | `string` | — | Manual shadow color override (CSS color). |
72
72
  | `shadowColorDark` | `string` | — | Shadow color for dark mode when using auto-detect. |
73
- | `intensity` | `number` | `1` | Shadow intensity multiplier. `0.5` = subtle, `1` = normal, `2` = dramatic. |
74
- | `animated` | `boolean` | `true` | Whether to animate shadow changes with transitions. |
73
+ | `intensity` | `number` | `1` | Shadow opacity multiplier. `0.5` = lighter, `1` = normal, `2` = darker. |
74
+ | `scale` | `number` | `1` | Shadow size multiplier. `0.5` = smaller/contained (~8px max), `1` = default (~16px max), `2` = larger/dramatic (~32px max). |
75
+ | `animated` | `boolean` | `true` | Whether to animate shadow changes with transitions. Automatically disabled when using `lightSource="mouse"` for smooth tracking. |
75
76
  | `transitionDuration` | `number` | `150` | Transition duration in milliseconds. |
76
77
  | `children` | `React.ReactNode` | — | Content to render inside the component. |
77
78
 
@@ -91,9 +92,7 @@ Plus all standard HTML div attributes (`className`, `style`, `onClick`, etc.).
91
92
  <LiftedBox
92
93
  lightSource={{
93
94
  type: 'mouse',
94
- smoothing: 0.1, // 0-1, lower = smoother movement
95
- maxAngle: 30, // Maximum angle deviation
96
- fallbackAngle: -45, // Angle when mouse unavailable
95
+ fallbackAngle: -45, // Angle when mouse unavailable (default: -45)
97
96
  }}
98
97
  />
99
98
 
@@ -16,9 +16,10 @@ export declare function angleToOffsetRatios(angleDeg: number): {
16
16
  *
17
17
  * @param elevation - Value from -1 (inner shadow) to 1 (drop shadow)
18
18
  * @param lightAngle - Angle of light source in degrees
19
- * @param intensity - Overall intensity multiplier
19
+ * @param intensity - Opacity multiplier (default 1)
20
+ * @param scale - Size multiplier for offset and blur (default 1)
20
21
  */
21
- export declare function calculateShadowLayers(elevation: number, lightAngle?: number, intensity?: number): ShadowLayer[];
22
+ export declare function calculateShadowLayers(elevation: number, lightAngle?: number, intensity?: number, scale?: number): ShadowLayer[];
22
23
  export declare function lerp(start: number, end: number, t: number): number;
23
24
  export declare function clamp(value: number, min: number, max: number): number;
24
25
  export declare function smoothPosition(current: Position, target: Position, smoothing: number): Position;
@@ -1 +1 @@
1
- {"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/core/calculations.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,MAAM,EACP,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAM1C,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,GAAG,WAAW,CAgBrF;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,MAAM,CAiCR;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAMxF;AAMD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAA4B,EACxC,SAAS,GAAE,MAAU,GACpB,WAAW,EAAE,CA0Cf;AAMD,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,KAAK,CAAC,KA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AE,GAAG,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,CAK/F"}
@@ -1 +1 @@
1
- {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../src/core/css-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,EACT,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,YAAY,CAgCd;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAM,GACtD,MAAM,CAGR;AAaD,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAoBlE;AA+BD,eAAO,MAAM,iBAAiB;;;;;;;;;CASpB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE7D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAKxE;AAMD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,KAAK,CAAC,aAAa,CAYrB;AAED,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,MAAY,EAAE,gBAAgB,GAAE,OAAe,GAAG,MAAM,CAStG"}
1
+ {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../src/core/css-generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,EACT,MAAM,SAAS,CAAC;AAiBjB,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,YAAY,CAiCd;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAM,GACtD,MAAM,CAGR;AAaD,wBAAgB,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,CAoBlE;AA+BD,eAAO,MAAM,iBAAiB;;;;;;;;;CASpB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE7D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,CAKxE;AAMD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,aAAa,EACtB,aAAa,CAAC,EAAE,MAAM,EACtB,aAAa,CAAC,EAAE,QAAQ,GAAG,IAAI,GAC9B,KAAK,CAAC,aAAa,CAYrB;AAED,eAAO,MAAM,yBAAyB,oDAAoD,CAAC;AAE3F,wBAAgB,kBAAkB,CAAC,UAAU,GAAE,MAAY,EAAE,gBAAgB,GAAE,OAAe,GAAG,MAAM,CAStG"}
@@ -97,10 +97,18 @@ export interface LiftedBoxProps extends Omit<React.HTMLAttributes<HTMLElement>,
97
97
  */
98
98
  shadowColorDark?: string;
99
99
  /**
100
- * Shadow intensity multiplier.
100
+ * Shadow intensity multiplier (affects opacity).
101
101
  * @default 1
102
102
  */
103
103
  intensity?: number;
104
+ /**
105
+ * Shadow size multiplier. Controls how large shadows can get.
106
+ * - 0.5 = smaller, more contained shadows (max ~8px)
107
+ * - 1 = default size (max ~16px)
108
+ * - 2 = larger, more dramatic shadows (max ~32px)
109
+ * @default 1
110
+ */
111
+ scale?: number;
104
112
  /**
105
113
  * Whether to animate shadow changes.
106
114
  * @default true
@@ -152,6 +160,7 @@ export interface VanillaLiftedBoxOptions {
152
160
  shadowColor?: string;
153
161
  shadowColorDark?: string;
154
162
  intensity?: number;
163
+ scale?: number;
155
164
  animated?: boolean;
156
165
  transitionDuration?: number;
157
166
  isDarkMode?: boolean;
@@ -201,6 +210,7 @@ export interface ShadowOptions {
201
210
  shadowColor?: string;
202
211
  shadowColorDark?: string;
203
212
  intensity?: number;
213
+ scale?: number;
204
214
  isDarkMode?: boolean;
205
215
  }
206
216
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,CAAC;IACf,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ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1C,8BAA8B;IAC9B,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAClD,8BAA8B;IAC9B,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;IAC5D,6BAA6B;IAC7B,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAMD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,+BAA+B;IAC/B,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC"}
@@ -0,0 +1,2 @@
1
+ "use strict";function b(t){return t===void 0?{type:"static",angle:-45}:typeof t=="number"?{type:"static",angle:t}:t==="mouse"?{type:"mouse",smoothing:.1,maxAngle:60,fallbackAngle:-45}:t}function m(t,n,e){switch(t.type){case"static":case"custom":return t.angle;case"mouse":{if(!e||!n)return t.fallbackAngle??-45;const o=n.x+n.width/2,s=n.y+n.height/2,a=e.x-o,c=e.y-s;return Math.atan2(c,a)*(180/Math.PI)+180}default:return-45}}function I(t){const n=t*(Math.PI/180);return{ratioX:Math.cos(n),ratioY:Math.sin(n)}}function $(t,n=-45,e=1,o=1){const s=Math.max(-1,Math.min(1,t));if(s===0)return[];const a=s<0,l=Math.abs(s)*5,{ratioX:r,ratioY:d}=I(n),u=a?-1:1,A=[];for(let h=0;h<5;h++){const L=h+1,i=Math.pow(2,h)*o;if(L<=l)A.push({offsetX:i*r*u,offsetY:i*d*u,blur:i,spread:0,opacity:.075*e,inset:a});else if(L-1<l){const f=l-(L-1);A.push({offsetX:i*r*f*u,offsetY:i*d*f*u,blur:i*f,spread:0,opacity:.075*f*e,inset:a})}}return A}function _(t,n,e){return t+(n-t)*e}function F(t,n,e){return{x:_(t.x,n.x,e),y:_(t.y,n.y,e)}}function S(t){if(t.match(/^#([0-9a-f]{3,8})$/i))return y(t);const e=t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);if(e)return{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])};const o=t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);return o?E({r:parseFloat(o[1]),g:parseFloat(o[2]),b:parseFloat(o[3])}):null}function y(t){let n=0,e=0,o=0;return t.length===4?(n=parseInt(t[1]+t[1],16),e=parseInt(t[2]+t[2],16),o=parseInt(t[3]+t[3],16)):t.length>=7&&(n=parseInt(t.slice(1,3),16),e=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16)),E({r:n,g:e,b:o})}function E({r:t,g:n,b:e}){t/=255,n/=255,e/=255;const o=Math.max(t,n,e),s=Math.min(t,n,e);let a=0,c=0;const l=(o+s)/2;if(o!==s){const r=o-s;switch(c=l>.5?r/(2-o-s):r/(o+s),o){case t:a=((n-e)/r+(n<e?6:0))/6;break;case n:a=((e-t)/r+2)/6;break;case e:a=((t-n)/r+4)/6;break}}return{h:Math.round(a*360),s:Math.round(c*100),l:Math.round(l*100)}}function M(t,n=!1){const e=S(t);if(!e)return n?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";if(n){const o=Math.max(0,e.s-20),s=Math.min(100,e.l+30);return`hsl(${e.h} ${o}% ${s}%)`}else{const o=Math.max(0,e.s*.6),s=Math.max(10,e.l*.5);return`hsl(${e.h} ${o}% ${s}%)`}}function w(t,n){const e=S(t);return e?`hsl(${e.h} ${e.s}% ${e.l}% / ${n})`:`hsl(220 3% 15% / ${n})`}function G(t){const n=S(t);return n?n.l>50:!0}function T(t,n,e){const{elevation:o=.3,lightSource:s,background:a,shadowColor:c,shadowColorDark:l,intensity:r=1,scale:d=1,isDarkMode:u=!1}=t,A=b(s),h=m(A,n,e),L=$(o,h,r,d);let i;c?i=c:u&&l?i=l:a?i=M(a,u):i=u?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";const f=Y(L,i),x=p(f),O=N(f,o,h);return{layers:f,boxShadow:x,cssVariables:O}}function D(t,n={}){return T({elevation:t,...n}).boxShadow}function Y(t,n){return t.map(e=>({...e,color:w(n,e.opacity)}))}function p(t){return t.length===0?"none":t.map(n=>{const{offsetX:e,offsetY:o,blur:s,spread:a,color:c,inset:l}=n,r=g(e),d=g(o),u=g(s),A=g(a),h=l?"inset ":"";return a===0?`${h}${r} ${d} ${u} ${c}`:`${h}${r} ${d} ${u} ${A} ${c}`}).join(`,
2
+ `)}function g(t){return t===0?"0":`${Math.round(t*100)/100}px`}function N(t,n,e){return{"--lifted-elevation":n.toString(),"--lifted-light-angle":`${e}deg`,"--lifted-layers":t.length.toString(),"--lifted-shadow":p(t)}}const C={deepInset:-.75,inset:-.3,none:0,subtle:.15,small:.25,medium:.5,large:.75,xlarge:1};function H(t){return typeof t=="number"?t:C[t]}function R(t,n,e){const s={boxShadow:T(t,n,e).boxShadow};return t.background&&(s.backgroundColor=t.background),s}const U="box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";function X(t=150,n=!1){const e="cubic-bezier(0.2, 0.6, 0.3, 1)",o=[`box-shadow ${t}ms ${e}`];return n&&o.push(`transform ${t}ms ${e}`),o.join(", ")}exports.BASE_OPACITY=.075;exports.DEFAULT_LIGHT_ANGLE=-45;exports.DEFAULT_SHADOW_TRANSITION=U;exports.ELEVATION_PRESETS=C;exports.MAX_LAYERS=5;exports.angleToOffsetRatios=I;exports.calculateLightAngle=m;exports.calculateShadowColor=M;exports.calculateShadowLayers=$;exports.generateBoxShadow=D;exports.generateLayerColor=w;exports.generateShadow=T;exports.generateStyleObject=R;exports.generateTransition=X;exports.hexToHSL=y;exports.isLightColor=G;exports.layersToCSS=p;exports.normalizeLightSource=b;exports.parseColor=S;exports.resolveElevation=H;exports.rgbToHSL=E;exports.smoothPosition=F;
@@ -0,0 +1,227 @@
1
+ const Y = 5, O = 0.075, X = -45;
2
+ function M(t) {
3
+ return t === void 0 ? { type: "static", angle: -45 } : typeof t == "number" ? { type: "static", angle: t } : t === "mouse" ? {
4
+ type: "mouse",
5
+ smoothing: 0.1,
6
+ maxAngle: 60,
7
+ fallbackAngle: -45
8
+ } : t;
9
+ }
10
+ function _(t, s, n) {
11
+ switch (t.type) {
12
+ case "static":
13
+ case "custom":
14
+ return t.angle;
15
+ case "mouse": {
16
+ if (!n || !s)
17
+ return t.fallbackAngle ?? -45;
18
+ const e = s.x + s.width / 2, a = s.y + s.height / 2, o = n.x - e, c = n.y - a;
19
+ return Math.atan2(c, o) * (180 / Math.PI) + 180;
20
+ }
21
+ default:
22
+ return -45;
23
+ }
24
+ }
25
+ function y(t) {
26
+ const s = t * (Math.PI / 180);
27
+ return {
28
+ ratioX: Math.cos(s),
29
+ ratioY: Math.sin(s)
30
+ };
31
+ }
32
+ function w(t, s = -45, n = 1, e = 1) {
33
+ const a = Math.max(-1, Math.min(1, t));
34
+ if (a === 0)
35
+ return [];
36
+ const o = a < 0, l = Math.abs(a) * 5, { ratioX: r, ratioY: d } = y(s), u = o ? -1 : 1, g = [];
37
+ for (let f = 0; f < 5; f++) {
38
+ const p = f + 1, i = Math.pow(2, f) * e;
39
+ if (p <= l)
40
+ g.push({
41
+ offsetX: i * r * u,
42
+ offsetY: i * d * u,
43
+ blur: i,
44
+ spread: 0,
45
+ opacity: 0.075 * n,
46
+ inset: o
47
+ });
48
+ else if (p - 1 < l) {
49
+ const h = l - (p - 1);
50
+ g.push({
51
+ offsetX: i * r * h * u,
52
+ offsetY: i * d * h * u,
53
+ blur: i * h,
54
+ spread: 0,
55
+ opacity: 0.075 * h * n,
56
+ inset: o
57
+ });
58
+ }
59
+ }
60
+ return g;
61
+ }
62
+ function b(t, s, n) {
63
+ return t + (s - t) * n;
64
+ }
65
+ function k(t, s, n) {
66
+ return {
67
+ x: b(t.x, s.x, n),
68
+ y: b(t.y, s.y, n)
69
+ };
70
+ }
71
+ function L(t) {
72
+ if (t.match(/^#([0-9a-f]{3,8})$/i))
73
+ return I(t);
74
+ const n = t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);
75
+ if (n)
76
+ return {
77
+ h: parseFloat(n[1]),
78
+ s: parseFloat(n[2]),
79
+ l: parseFloat(n[3])
80
+ };
81
+ const e = t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);
82
+ return e ? E({
83
+ r: parseFloat(e[1]),
84
+ g: parseFloat(e[2]),
85
+ b: parseFloat(e[3])
86
+ }) : null;
87
+ }
88
+ function I(t) {
89
+ let s = 0, n = 0, e = 0;
90
+ return t.length === 4 ? (s = parseInt(t[1] + t[1], 16), n = parseInt(t[2] + t[2], 16), e = parseInt(t[3] + t[3], 16)) : t.length >= 7 && (s = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), e = parseInt(t.slice(5, 7), 16)), E({ r: s, g: n, b: e });
91
+ }
92
+ function E({ r: t, g: s, b: n }) {
93
+ t /= 255, s /= 255, n /= 255;
94
+ const e = Math.max(t, s, n), a = Math.min(t, s, n);
95
+ let o = 0, c = 0;
96
+ const l = (e + a) / 2;
97
+ if (e !== a) {
98
+ const r = e - a;
99
+ switch (c = l > 0.5 ? r / (2 - e - a) : r / (e + a), e) {
100
+ case t:
101
+ o = ((s - n) / r + (s < n ? 6 : 0)) / 6;
102
+ break;
103
+ case s:
104
+ o = ((n - t) / r + 2) / 6;
105
+ break;
106
+ case n:
107
+ o = ((t - s) / r + 4) / 6;
108
+ break;
109
+ }
110
+ }
111
+ return {
112
+ h: Math.round(o * 360),
113
+ s: Math.round(c * 100),
114
+ l: Math.round(l * 100)
115
+ };
116
+ }
117
+ function x(t, s = !1) {
118
+ const n = L(t);
119
+ if (!n)
120
+ return s ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
121
+ if (s) {
122
+ const e = Math.max(0, n.s - 20), a = Math.min(100, n.l + 30);
123
+ return `hsl(${n.h} ${e}% ${a}%)`;
124
+ } else {
125
+ const e = Math.max(0, n.s * 0.6), a = Math.max(10, n.l * 0.5);
126
+ return `hsl(${n.h} ${e}% ${a}%)`;
127
+ }
128
+ }
129
+ function C(t, s) {
130
+ const n = L(t);
131
+ return n ? `hsl(${n.h} ${n.s}% ${n.l}% / ${s})` : `hsl(220 3% 15% / ${s})`;
132
+ }
133
+ function N(t) {
134
+ const s = L(t);
135
+ return s ? s.l > 50 : !0;
136
+ }
137
+ function S(t, s, n) {
138
+ const {
139
+ elevation: e = 0.3,
140
+ lightSource: a,
141
+ background: o,
142
+ shadowColor: c,
143
+ shadowColorDark: l,
144
+ intensity: r = 1,
145
+ scale: d = 1,
146
+ isDarkMode: u = !1
147
+ } = t, g = M(a), f = _(g, s, n), p = w(e, f, r, d);
148
+ let i;
149
+ c ? i = c : u && l ? i = l : o ? i = x(o, u) : i = u ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
150
+ const h = F(p, i), $ = m(h), T = D(h, e, f);
151
+ return { layers: h, boxShadow: $, cssVariables: T };
152
+ }
153
+ function U(t, s = {}) {
154
+ return S({ elevation: t, ...s }).boxShadow;
155
+ }
156
+ function F(t, s) {
157
+ return t.map((n) => ({
158
+ ...n,
159
+ color: C(s, n.opacity)
160
+ }));
161
+ }
162
+ function m(t) {
163
+ return t.length === 0 ? "none" : t.map((s) => {
164
+ const { offsetX: n, offsetY: e, blur: a, spread: o, color: c, inset: l } = s, r = A(n), d = A(e), u = A(a), g = A(o), f = l ? "inset " : "";
165
+ return o === 0 ? `${f}${r} ${d} ${u} ${c}` : `${f}${r} ${d} ${u} ${g} ${c}`;
166
+ }).join(`,
167
+ `);
168
+ }
169
+ function A(t) {
170
+ return t === 0 ? "0" : `${Math.round(t * 100) / 100}px`;
171
+ }
172
+ function D(t, s, n) {
173
+ return {
174
+ "--lifted-elevation": s.toString(),
175
+ "--lifted-light-angle": `${n}deg`,
176
+ "--lifted-layers": t.length.toString(),
177
+ "--lifted-shadow": m(t)
178
+ };
179
+ }
180
+ const G = {
181
+ deepInset: -0.75,
182
+ inset: -0.3,
183
+ none: 0,
184
+ subtle: 0.15,
185
+ small: 0.25,
186
+ medium: 0.5,
187
+ large: 0.75,
188
+ xlarge: 1
189
+ };
190
+ function v(t) {
191
+ return typeof t == "number" ? t : G[t];
192
+ }
193
+ function H(t, s, n) {
194
+ const a = {
195
+ boxShadow: S(t, s, n).boxShadow
196
+ };
197
+ return t.background && (a.backgroundColor = t.background), a;
198
+ }
199
+ const R = "box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";
200
+ function P(t = 150, s = !1) {
201
+ const n = "cubic-bezier(0.2, 0.6, 0.3, 1)", e = [`box-shadow ${t}ms ${n}`];
202
+ return s && e.push(`transform ${t}ms ${n}`), e.join(", ");
203
+ }
204
+ export {
205
+ O as B,
206
+ X as D,
207
+ G as E,
208
+ Y as M,
209
+ P as a,
210
+ x as b,
211
+ _ as c,
212
+ w as d,
213
+ U as e,
214
+ R as f,
215
+ S as g,
216
+ y as h,
217
+ N as i,
218
+ C as j,
219
+ H as k,
220
+ m as l,
221
+ I as m,
222
+ M as n,
223
+ E as o,
224
+ L as p,
225
+ v as r,
226
+ k as s
227
+ };
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B as s, D as o, f as r, E as l, M as t, h as S, c as L, b as T, d as g, e as n, j as A, g as E, k as i, a as c, m as h, i as _, l as C, n as O, p as d, r as I, o as f } from "./index-C0sp-tDk.js";
1
+ import { B as s, D as o, f as r, E as l, M as t, h as S, c as L, b as T, d as g, e as n, j as A, g as E, k as i, a as c, m as h, i as _, l as C, n as O, p as d, r as I, o as f } from "./index-yqTtrmSg.js";
2
2
  export {
3
3
  s as BASE_OPACITY,
4
4
  o as DEFAULT_LIGHT_ANGLE,
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D6JJAZ46.cjs");exports.BASE_OPACITY=e.BASE_OPACITY;exports.DEFAULT_LIGHT_ANGLE=e.DEFAULT_LIGHT_ANGLE;exports.DEFAULT_SHADOW_TRANSITION=e.DEFAULT_SHADOW_TRANSITION;exports.ELEVATION_PRESETS=e.ELEVATION_PRESETS;exports.MAX_LAYERS=e.MAX_LAYERS;exports.angleToOffsetRatios=e.angleToOffsetRatios;exports.calculateLightAngle=e.calculateLightAngle;exports.calculateShadowColor=e.calculateShadowColor;exports.calculateShadowLayers=e.calculateShadowLayers;exports.generateBoxShadow=e.generateBoxShadow;exports.generateLayerColor=e.generateLayerColor;exports.generateShadow=e.generateShadow;exports.generateStyleObject=e.generateStyleObject;exports.generateTransition=e.generateTransition;exports.hexToHSL=e.hexToHSL;exports.isLightColor=e.isLightColor;exports.layersToCSS=e.layersToCSS;exports.normalizeLightSource=e.normalizeLightSource;exports.parseColor=e.parseColor;exports.resolveElevation=e.resolveElevation;exports.rgbToHSL=e.rgbToHSL;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CWmwGPME.cjs");exports.BASE_OPACITY=e.BASE_OPACITY;exports.DEFAULT_LIGHT_ANGLE=e.DEFAULT_LIGHT_ANGLE;exports.DEFAULT_SHADOW_TRANSITION=e.DEFAULT_SHADOW_TRANSITION;exports.ELEVATION_PRESETS=e.ELEVATION_PRESETS;exports.MAX_LAYERS=e.MAX_LAYERS;exports.angleToOffsetRatios=e.angleToOffsetRatios;exports.calculateLightAngle=e.calculateLightAngle;exports.calculateShadowColor=e.calculateShadowColor;exports.calculateShadowLayers=e.calculateShadowLayers;exports.generateBoxShadow=e.generateBoxShadow;exports.generateLayerColor=e.generateLayerColor;exports.generateShadow=e.generateShadow;exports.generateStyleObject=e.generateStyleObject;exports.generateTransition=e.generateTransition;exports.hexToHSL=e.hexToHSL;exports.isLightColor=e.isLightColor;exports.layersToCSS=e.layersToCSS;exports.normalizeLightSource=e.normalizeLightSource;exports.parseColor=e.parseColor;exports.resolveElevation=e.resolveElevation;exports.rgbToHSL=e.rgbToHSL;
@@ -1 +1 @@
1
- {"version":3,"file":"LiftedBox.d.ts","sourceRoot":"","sources":["../../src/react/LiftedBox.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAA2D,MAAM,OAAO,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAC;AAStE,eAAO,MAAM,SAAS,oFA0HrB,CAAC;AAQF,eAAO,MAAM,UAAU,uGAEtB,CAAC;AAGF,eAAO,MAAM,YAAY,gGAIxB,CAAC;AAGF,eAAO,MAAM,WAAW,uGAEvB,CAAC;AAGF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"LiftedBox.d.ts","sourceRoot":"","sources":["../../src/react/LiftedBox.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAA2D,MAAM,OAAO,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,eAAe,CAAC;AAStE,eAAO,MAAM,SAAS,oFA6HrB,CAAC;AAQF,eAAO,MAAM,UAAU,uGAEtB,CAAC;AAGF,eAAO,MAAM,YAAY,gGAIxB,CAAC;AAGF,eAAO,MAAM,WAAW,uGAEvB,CAAC;AAGF,eAAe,SAAS,CAAC"}
package/dist/react.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as x } from "react/jsx-runtime";
2
- import V, { useState as w, useEffect as M, forwardRef as E, useRef as H, useMemo as h, createContext as X, useContext as A, useCallback as y } from "react";
3
- import { g as Y, a as j, n as Q } from "./index-C0sp-tDk.js";
2
+ import H, { useState as L, useEffect as M, forwardRef as E, useRef as X, useMemo as h, createContext as Y, useContext as A, useCallback as y } from "react";
3
+ import { g as j, a as Q, n as U } from "./index-yqTtrmSg.js";
4
4
  function N(e = {}) {
5
- const { defaultValue: t = !1 } = e, [o, s] = w(t);
5
+ const { defaultValue: t = !1 } = e, [o, s] = L(t);
6
6
  return M(() => {
7
7
  if (typeof window > "u") return;
8
8
  const n = window.matchMedia("(prefers-color-scheme: dark)");
@@ -22,19 +22,20 @@ const g = E(
22
22
  shadowColor: n,
23
23
  shadowColorDark: i,
24
24
  intensity: u = 1,
25
- animated: d = !0,
26
- transitionDuration: c = 150,
25
+ scale: d = 1,
26
+ animated: c = !0,
27
+ transitionDuration: f = 150,
27
28
  children: l,
28
- style: f,
29
- ...L
30
- }, v) => {
31
- const p = H(null), B = v || p, [R, S] = w(null), [C, z] = w(null), b = N(), m = Q(o);
29
+ style: v,
30
+ ...m
31
+ }, p) => {
32
+ const S = X(null), B = p || S, [R, z] = L(null), [C, I] = L(null), b = N(), w = U(o);
32
33
  M(() => {
33
- if (m.type !== "mouse") return;
34
+ if (w.type !== "mouse") return;
34
35
  const r = () => {
35
36
  if (B.current) {
36
37
  const a = B.current.getBoundingClientRect();
37
- z({
38
+ I({
38
39
  x: a.left,
39
40
  y: a.top,
40
41
  width: a.width,
@@ -45,14 +46,14 @@ const g = E(
45
46
  return r(), window.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", r, { passive: !0 }), () => {
46
47
  window.removeEventListener("scroll", r), window.removeEventListener("resize", r);
47
48
  };
48
- }, [m.type]), M(() => {
49
- if (m.type !== "mouse") return;
49
+ }, [w.type]), M(() => {
50
+ if (w.type !== "mouse") return;
50
51
  const r = (a) => {
51
- S({ x: a.clientX, y: a.clientY });
52
+ z({ x: a.clientX, y: a.clientY });
52
53
  };
53
54
  return window.addEventListener("mousemove", r, { passive: !0 }), () => window.removeEventListener("mousemove", r);
54
- }, [m.type]);
55
- const k = h(() => Y(
55
+ }, [w.type]);
56
+ const k = h(() => j(
56
57
  {
57
58
  elevation: e,
58
59
  lightSource: o,
@@ -60,6 +61,7 @@ const g = E(
60
61
  shadowColor: n,
61
62
  shadowColorDark: i,
62
63
  intensity: u,
64
+ scale: d,
63
65
  isDarkMode: b
64
66
  },
65
67
  C ?? void 0,
@@ -71,45 +73,46 @@ const g = E(
71
73
  n,
72
74
  i,
73
75
  u,
76
+ d,
74
77
  b,
75
78
  C,
76
79
  R
77
- ]), I = h(() => {
80
+ ]), V = h(() => {
78
81
  const r = {
79
82
  boxShadow: k.boxShadow,
80
- ...f
83
+ ...v
81
84
  };
82
- return s && (r.backgroundColor = s), d && m.type !== "mouse" && (r.transition = j(c)), r;
83
- }, [k.boxShadow, s, d, c, f, m.type]);
84
- return V.createElement(
85
+ return s && (r.backgroundColor = s), c && w.type !== "mouse" && (r.transition = Q(f)), r;
86
+ }, [k.boxShadow, s, c, f, v, w.type]);
87
+ return H.createElement(
85
88
  t,
86
89
  {
87
90
  ref: B,
88
- style: I,
89
- ...L
91
+ style: V,
92
+ ...m
90
93
  },
91
94
  l
92
95
  );
93
96
  }
94
97
  );
95
98
  g.displayName = "LiftedBox";
96
- const U = E(
99
+ const W = E(
97
100
  (e, t) => /* @__PURE__ */ x(g, { ref: t, elevation: 0.3, ...e })
98
101
  );
99
- U.displayName = "LiftedCard";
100
- const W = E(
102
+ W.displayName = "LiftedCard";
103
+ const q = E(
101
104
  ({ elevation: e = 0.25, ...t }, o) => /* @__PURE__ */ x(g, { ref: o, as: "button", elevation: e, ...t })
102
105
  );
103
- W.displayName = "LiftedButton";
104
- const q = E(
106
+ q.displayName = "LiftedButton";
107
+ const D = E(
105
108
  (e, t) => /* @__PURE__ */ x(g, { ref: t, elevation: 0.8, ...e })
106
109
  );
107
- q.displayName = "LiftedModal";
108
- const P = X(null);
109
- function J() {
110
+ D.displayName = "LiftedModal";
111
+ const P = Y(null);
112
+ function K() {
110
113
  return A(P);
111
114
  }
112
- function K() {
115
+ function O() {
113
116
  const e = A(P);
114
117
  if (!e)
115
118
  throw new Error(
@@ -117,7 +120,7 @@ function K() {
117
120
  );
118
121
  return e;
119
122
  }
120
- function O({
123
+ function T({
121
124
  children: e,
122
125
  autoDetectDarkMode: t = !0,
123
126
  defaultElevation: o = 0.3,
@@ -126,21 +129,21 @@ function O({
126
129
  disableTransitions: i = !1,
127
130
  customColorMapping: u
128
131
  }) {
129
- const [d, c] = w(null), l = N({ defaultValue: !1 }), f = h(() => n === "light" ? !1 : n === "dark" ? !0 : t ? l : !1, [n, t, l]);
132
+ const [d, c] = L(null), f = N({ defaultValue: !1 }), l = h(() => n === "light" ? !1 : n === "dark" ? !0 : t ? f : !1, [n, t, f]);
130
133
  M(() => {
131
- const v = (p) => {
134
+ const m = (p) => {
132
135
  c({ x: p.clientX, y: p.clientY });
133
136
  };
134
- return window.addEventListener("mousemove", v, { passive: !0 }), () => window.removeEventListener("mousemove", v);
137
+ return window.addEventListener("mousemove", m, { passive: !0 }), () => window.removeEventListener("mousemove", m);
135
138
  }, []);
136
- const L = h(
139
+ const v = h(
137
140
  () => ({
138
141
  autoDetectDarkMode: t,
139
142
  defaultElevation: o,
140
143
  defaultLightSource: s,
141
144
  colorScheme: n,
142
145
  disableTransitions: i,
143
- isDarkMode: f,
146
+ isDarkMode: l,
144
147
  mousePosition: d,
145
148
  customColorMapping: u
146
149
  }),
@@ -150,37 +153,37 @@ function O({
150
153
  s,
151
154
  n,
152
155
  i,
153
- f,
156
+ l,
154
157
  d,
155
158
  u
156
159
  ]
157
160
  );
158
- return /* @__PURE__ */ x(P.Provider, { value: L, children: e });
161
+ return /* @__PURE__ */ x(P.Provider, { value: v, children: e });
159
162
  }
160
- function T(e = {}) {
161
- const { base: t = 0.3, hover: o = 0.5, active: s = 0.15 } = e, [n, i] = w(!1), [u, d] = w(!1), c = h(() => u ? s : n ? o : t, [n, u, t, o, s]), l = y(() => i(!0), []), f = y(() => {
163
+ function Z(e = {}) {
164
+ const { base: t = 0.3, hover: o = 0.5, active: s = 0.15 } = e, [n, i] = L(!1), [u, d] = L(!1), c = h(() => u ? s : n ? o : t, [n, u, t, o, s]), f = y(() => i(!0), []), l = y(() => {
162
165
  i(!1), d(!1);
163
- }, []), L = y(() => d(!0), []), v = y(() => d(!1), []);
166
+ }, []), v = y(() => d(!0), []), m = y(() => d(!1), []);
164
167
  return {
165
168
  elevation: c,
166
169
  isHovered: n,
167
170
  isActive: u,
168
171
  elevationProps: {
169
- onMouseEnter: l,
170
- onMouseLeave: f,
171
- onMouseDown: L,
172
- onMouseUp: v
172
+ onMouseEnter: f,
173
+ onMouseLeave: l,
174
+ onMouseDown: v,
175
+ onMouseUp: m
173
176
  }
174
177
  };
175
178
  }
176
179
  export {
177
180
  g as LiftedBox,
178
- W as LiftedButton,
179
- U as LiftedCard,
180
- q as LiftedModal,
181
- O as LiftedProvider,
181
+ q as LiftedButton,
182
+ W as LiftedCard,
183
+ D as LiftedModal,
184
+ T as LiftedProvider,
182
185
  N as useDarkMode,
183
- T as useElevation,
184
- K as useLifted,
185
- J as useLiftedContext
186
+ Z as useElevation,
187
+ O as useLifted,
188
+ K as useLiftedContext
186
189
  };
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),e=require("react"),y=require("./index-D6JJAZ46.cjs");function E(t={}){const{defaultValue:s=!1}=t,[r,o]=e.useState(s);return e.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");o(n.matches);const u=d=>{o(d.matches)};return n.addEventListener("change",u),()=>n.removeEventListener("change",u)},[]),r}const h=e.forwardRef(({elevation:t=.3,as:s="div",lightSource:r=-45,background:o,shadowColor:n,shadowColorDark:u,intensity:d=1,animated:a=!0,transitionDuration:l=150,children:v,style:c,...L},m)=>{const M=e.useRef(null),p=m||M,[R,j]=e.useState(null),[S,A]=e.useState(null),b=E(),w=y.normalizeLightSource(r);e.useEffect(()=>{if(w.type!=="mouse")return;const i=()=>{if(p.current){const f=p.current.getBoundingClientRect();A({x:f.left,y:f.top,width:f.width,height:f.height})}};return i(),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i)}},[w.type]),e.useEffect(()=>{if(w.type!=="mouse")return;const i=f=>{j({x:f.clientX,y:f.clientY})};return window.addEventListener("mousemove",i,{passive:!0}),()=>window.removeEventListener("mousemove",i)},[w.type]);const B=e.useMemo(()=>y.generateShadow({elevation:t,lightSource:r,background:o,shadowColor:n,shadowColorDark:u,intensity:d,isDarkMode:b},S??void 0,R),[t,r,o,n,u,d,b,S,R]),N=e.useMemo(()=>{const i={boxShadow:B.boxShadow,...c};return o&&(i.backgroundColor=o),a&&w.type!=="mouse"&&(i.transition=y.generateTransition(l)),i},[B.boxShadow,o,a,l,c,w.type]);return e.createElement(s,{ref:p,style:N,...L},v)});h.displayName="LiftedBox";const P=e.forwardRef((t,s)=>x.jsx(h,{ref:s,elevation:.3,...t}));P.displayName="LiftedCard";const g=e.forwardRef(({elevation:t=.25,...s},r)=>x.jsx(h,{ref:r,as:"button",elevation:t,...s}));g.displayName="LiftedButton";const k=e.forwardRef((t,s)=>x.jsx(h,{ref:s,elevation:.8,...t}));k.displayName="LiftedModal";const C=e.createContext(null);function q(){return e.useContext(C)}function z(){const t=e.useContext(C);if(!t)throw new Error("useLifted must be used within a LiftedProvider. Wrap your app with <LiftedProvider> to use this hook.");return t}function I({children:t,autoDetectDarkMode:s=!0,defaultElevation:r=.3,defaultLightSource:o=-45,colorScheme:n="auto",disableTransitions:u=!1,customColorMapping:d}){const[a,l]=e.useState(null),v=E({defaultValue:!1}),c=e.useMemo(()=>n==="light"?!1:n==="dark"?!0:s?v:!1,[n,s,v]);e.useEffect(()=>{const m=M=>{l({x:M.clientX,y:M.clientY})};return window.addEventListener("mousemove",m,{passive:!0}),()=>window.removeEventListener("mousemove",m)},[]);const L=e.useMemo(()=>({autoDetectDarkMode:s,defaultElevation:r,defaultLightSource:o,colorScheme:n,disableTransitions:u,isDarkMode:c,mousePosition:a,customColorMapping:d}),[s,r,o,n,u,c,a,d]);return x.jsx(C.Provider,{value:L,children:t})}function V(t={}){const{base:s=.3,hover:r=.5,active:o=.15}=t,[n,u]=e.useState(!1),[d,a]=e.useState(!1),l=e.useMemo(()=>d?o:n?r:s,[n,d,s,r,o]),v=e.useCallback(()=>u(!0),[]),c=e.useCallback(()=>{u(!1),a(!1)},[]),L=e.useCallback(()=>a(!0),[]),m=e.useCallback(()=>a(!1),[]);return{elevation:l,isHovered:n,isActive:d,elevationProps:{onMouseEnter:v,onMouseLeave:c,onMouseDown:L,onMouseUp:m}}}exports.LiftedBox=h;exports.LiftedButton=g;exports.LiftedCard=P;exports.LiftedModal=k;exports.LiftedProvider=I;exports.useDarkMode=E;exports.useElevation=V;exports.useLifted=z;exports.useLiftedContext=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),e=require("react"),y=require("./index-CWmwGPME.cjs");function E(t={}){const{defaultValue:s=!1}=t,[r,o]=e.useState(s);return e.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(prefers-color-scheme: dark)");o(n.matches);const u=d=>{o(d.matches)};return n.addEventListener("change",u),()=>n.removeEventListener("change",u)},[]),r}const h=e.forwardRef(({elevation:t=.3,as:s="div",lightSource:r=-45,background:o,shadowColor:n,shadowColorDark:u,intensity:d=1,scale:a=1,animated:l=!0,transitionDuration:c=150,children:v,style:m,...w},M)=>{const j=e.useRef(null),p=M||j,[R,A]=e.useState(null),[S,N]=e.useState(null),b=E(),L=y.normalizeLightSource(r);e.useEffect(()=>{if(L.type!=="mouse")return;const i=()=>{if(p.current){const f=p.current.getBoundingClientRect();N({x:f.left,y:f.top,width:f.width,height:f.height})}};return i(),window.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("scroll",i),window.removeEventListener("resize",i)}},[L.type]),e.useEffect(()=>{if(L.type!=="mouse")return;const i=f=>{A({x:f.clientX,y:f.clientY})};return window.addEventListener("mousemove",i,{passive:!0}),()=>window.removeEventListener("mousemove",i)},[L.type]);const B=e.useMemo(()=>y.generateShadow({elevation:t,lightSource:r,background:o,shadowColor:n,shadowColorDark:u,intensity:d,scale:a,isDarkMode:b},S??void 0,R),[t,r,o,n,u,d,a,b,S,R]),q=e.useMemo(()=>{const i={boxShadow:B.boxShadow,...m};return o&&(i.backgroundColor=o),l&&L.type!=="mouse"&&(i.transition=y.generateTransition(c)),i},[B.boxShadow,o,l,c,m,L.type]);return e.createElement(s,{ref:p,style:q,...w},v)});h.displayName="LiftedBox";const P=e.forwardRef((t,s)=>x.jsx(h,{ref:s,elevation:.3,...t}));P.displayName="LiftedCard";const g=e.forwardRef(({elevation:t=.25,...s},r)=>x.jsx(h,{ref:r,as:"button",elevation:t,...s}));g.displayName="LiftedButton";const k=e.forwardRef((t,s)=>x.jsx(h,{ref:s,elevation:.8,...t}));k.displayName="LiftedModal";const C=e.createContext(null);function z(){return e.useContext(C)}function I(){const t=e.useContext(C);if(!t)throw new Error("useLifted must be used within a LiftedProvider. Wrap your app with <LiftedProvider> to use this hook.");return t}function V({children:t,autoDetectDarkMode:s=!0,defaultElevation:r=.3,defaultLightSource:o=-45,colorScheme:n="auto",disableTransitions:u=!1,customColorMapping:d}){const[a,l]=e.useState(null),c=E({defaultValue:!1}),v=e.useMemo(()=>n==="light"?!1:n==="dark"?!0:s?c:!1,[n,s,c]);e.useEffect(()=>{const w=M=>{l({x:M.clientX,y:M.clientY})};return window.addEventListener("mousemove",w,{passive:!0}),()=>window.removeEventListener("mousemove",w)},[]);const m=e.useMemo(()=>({autoDetectDarkMode:s,defaultElevation:r,defaultLightSource:o,colorScheme:n,disableTransitions:u,isDarkMode:v,mousePosition:a,customColorMapping:d}),[s,r,o,n,u,v,a,d]);return x.jsx(C.Provider,{value:m,children:t})}function H(t={}){const{base:s=.3,hover:r=.5,active:o=.15}=t,[n,u]=e.useState(!1),[d,a]=e.useState(!1),l=e.useMemo(()=>d?o:n?r:s,[n,d,s,r,o]),c=e.useCallback(()=>u(!0),[]),v=e.useCallback(()=>{u(!1),a(!1)},[]),m=e.useCallback(()=>a(!0),[]),w=e.useCallback(()=>a(!1),[]);return{elevation:l,isHovered:n,isActive:d,elevationProps:{onMouseEnter:c,onMouseLeave:v,onMouseDown:m,onMouseUp:w}}}exports.LiftedBox=h;exports.LiftedButton=g;exports.LiftedCard=P;exports.LiftedModal=k;exports.LiftedProvider=V;exports.useDarkMode=E;exports.useElevation=H;exports.useLifted=I;exports.useLiftedContext=z;
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/vanilla/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAGzB,MAAM,eAAe,CAAC;AASvB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAwG1B;AAMD,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE,MAAwB,EAClC,cAAc,GAAE,uBAA4B,GAC3C,wBAAwB,EAAE,CAU5B;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,IAAI,CAGvH;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAErD;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,MAAM,CAGpG"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/vanilla/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAGzB,MAAM,eAAe,CAAC;AASvB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAyG1B;AAMD,wBAAgB,kBAAkB,CAChC,QAAQ,GAAE,MAAwB,EAClC,cAAc,GAAE,uBAA4B,GAC3C,wBAAwB,EAAE,CAU5B;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,IAAI,CAGvH;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAErD;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,uBAAuB,CAAM,GAAG,MAAM,CAGpG"}
@@ -1,7 +1,7 @@
1
- import { g as u, a as f, n as S, s as m } from "./index-C0sp-tDk.js";
2
- import { E as k, c as E, b as A, d as D, e as B, i as F, l as M, p as P, r as T } from "./index-C0sp-tDk.js";
1
+ import { g as u, a as f, n as S, s as m } from "./index-yqTtrmSg.js";
2
+ import { E as k, c as E, b as A, d as D, e as B, i as F, l as M, p as P, r as T } from "./index-yqTtrmSg.js";
3
3
  function w(e, a = {}) {
4
- let o = { ...a }, i = null, n = null, r = null, d = !1;
4
+ let o = { ...a }, i = null, n = null, r = null, c = !1;
5
5
  const l = S(o.lightSource);
6
6
  function h() {
7
7
  const t = e.getBoundingClientRect();
@@ -13,7 +13,7 @@ function w(e, a = {}) {
13
13
  };
14
14
  }
15
15
  function s() {
16
- if (d) return;
16
+ if (c) return;
17
17
  const t = u(
18
18
  {
19
19
  elevation: o.elevation ?? 0.3,
@@ -22,6 +22,7 @@ function w(e, a = {}) {
22
22
  shadowColor: o.shadowColor,
23
23
  shadowColorDark: o.shadowColorDark,
24
24
  intensity: o.intensity ?? 1,
25
+ scale: o.scale ?? 1,
25
26
  isDarkMode: o.isDarkMode ?? !1
26
27
  },
27
28
  h(),
@@ -29,13 +30,13 @@ function w(e, a = {}) {
29
30
  );
30
31
  e.style.boxShadow = t.boxShadow;
31
32
  }
32
- function c(t) {
33
+ function d(t) {
33
34
  if (i = { x: t.clientX, y: t.clientY }, l.type === "mouse") {
34
35
  const g = l.smoothing ?? 0.1;
35
36
  n ? n = m(n, i, g) : n = i, r && cancelAnimationFrame(r), r = requestAnimationFrame(s);
36
37
  }
37
38
  }
38
- return o.background && (e.style.backgroundColor = o.background), o.animated !== !1 && (e.style.transition = f(o.transitionDuration ?? 150)), s(), l.type === "mouse" && window.addEventListener("mousemove", c, { passive: !0 }), {
39
+ return o.background && (e.style.backgroundColor = o.background), o.animated !== !1 && (e.style.transition = f(o.transitionDuration ?? 150)), s(), l.type === "mouse" && window.addEventListener("mousemove", d, { passive: !0 }), {
39
40
  setElevation(t) {
40
41
  o.elevation = t, s();
41
42
  },
@@ -49,7 +50,7 @@ function w(e, a = {}) {
49
50
  return e.style.boxShadow;
50
51
  },
51
52
  destroy() {
52
- d = !0, r && cancelAnimationFrame(r), window.removeEventListener("mousemove", c), e.style.boxShadow = "", e.style.transition = "";
53
+ c = !0, r && cancelAnimationFrame(r), window.removeEventListener("mousemove", d), e.style.boxShadow = "", e.style.transition = "";
53
54
  }
54
55
  };
55
56
  }
package/dist/vanilla.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-D6JJAZ46.cjs");function h(a,i={}){let o={...i},n=null,r=null,l=null,d=!1;const u=t.normalizeLightSource(o.lightSource);function S(){const e=a.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}function s(){if(d)return;const e=t.generateShadow({elevation:o.elevation??.3,lightSource:o.lightSource,background:o.background,shadowColor:o.shadowColor,shadowColorDark:o.shadowColorDark,intensity:o.intensity??1,isDarkMode:o.isDarkMode??!1},S(),r);a.style.boxShadow=e.boxShadow}function c(e){if(n={x:e.clientX,y:e.clientY},u.type==="mouse"){const g=u.smoothing??.1;r?r=t.smoothPosition(r,n,g):r=n,l&&cancelAnimationFrame(l),l=requestAnimationFrame(s)}}return o.background&&(a.style.backgroundColor=o.background),o.animated!==!1&&(a.style.transition=t.generateTransition(o.transitionDuration??150)),s(),u.type==="mouse"&&window.addEventListener("mousemove",c,{passive:!0}),{setElevation(e){o.elevation=e,s()},setLightSource(e){o.lightSource=e,s()},update(e){o={...o,...e},e.background&&(a.style.backgroundColor=e.background),s()},getShadowCSS(){return a.style.boxShadow},destroy(){d=!0,l&&cancelAnimationFrame(l),window.removeEventListener("mousemove",c),a.style.boxShadow="",a.style.transition=""}}}function f(a="[data-lifted]",i={}){const o=document.querySelectorAll(a);return Array.from(o).map(n=>{const r=n.dataset.liftedElevation,l={...i,elevation:r?parseFloat(r):i.elevation};return h(n,l)})}function w(a,i,o={}){const n=t.generateShadow({elevation:i,...o});a.style.boxShadow=n.boxShadow}function y(a){a.style.boxShadow=""}function m(a,i={}){return t.generateShadow({elevation:a,...i}).boxShadow}exports.ELEVATION_PRESETS=t.ELEVATION_PRESETS;exports.calculateLightAngle=t.calculateLightAngle;exports.calculateShadowColor=t.calculateShadowColor;exports.calculateShadowLayers=t.calculateShadowLayers;exports.generateBoxShadow=t.generateBoxShadow;exports.generateShadow=t.generateShadow;exports.isLightColor=t.isLightColor;exports.layersToCSS=t.layersToCSS;exports.normalizeLightSource=t.normalizeLightSource;exports.parseColor=t.parseColor;exports.resolveElevation=t.resolveElevation;exports.applyLift=w;exports.getLiftCSS=m;exports.initAllLiftedBoxes=f;exports.initLiftedBox=h;exports.removeLift=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CWmwGPME.cjs");function h(a,i={}){let o={...i},n=null,r=null,l=null,c=!1;const u=t.normalizeLightSource(o.lightSource);function S(){const e=a.getBoundingClientRect();return{x:e.left,y:e.top,width:e.width,height:e.height}}function s(){if(c)return;const e=t.generateShadow({elevation:o.elevation??.3,lightSource:o.lightSource,background:o.background,shadowColor:o.shadowColor,shadowColorDark:o.shadowColorDark,intensity:o.intensity??1,scale:o.scale??1,isDarkMode:o.isDarkMode??!1},S(),r);a.style.boxShadow=e.boxShadow}function d(e){if(n={x:e.clientX,y:e.clientY},u.type==="mouse"){const g=u.smoothing??.1;r?r=t.smoothPosition(r,n,g):r=n,l&&cancelAnimationFrame(l),l=requestAnimationFrame(s)}}return o.background&&(a.style.backgroundColor=o.background),o.animated!==!1&&(a.style.transition=t.generateTransition(o.transitionDuration??150)),s(),u.type==="mouse"&&window.addEventListener("mousemove",d,{passive:!0}),{setElevation(e){o.elevation=e,s()},setLightSource(e){o.lightSource=e,s()},update(e){o={...o,...e},e.background&&(a.style.backgroundColor=e.background),s()},getShadowCSS(){return a.style.boxShadow},destroy(){c=!0,l&&cancelAnimationFrame(l),window.removeEventListener("mousemove",d),a.style.boxShadow="",a.style.transition=""}}}function f(a="[data-lifted]",i={}){const o=document.querySelectorAll(a);return Array.from(o).map(n=>{const r=n.dataset.liftedElevation,l={...i,elevation:r?parseFloat(r):i.elevation};return h(n,l)})}function w(a,i,o={}){const n=t.generateShadow({elevation:i,...o});a.style.boxShadow=n.boxShadow}function y(a){a.style.boxShadow=""}function m(a,i={}){return t.generateShadow({elevation:a,...i}).boxShadow}exports.ELEVATION_PRESETS=t.ELEVATION_PRESETS;exports.calculateLightAngle=t.calculateLightAngle;exports.calculateShadowColor=t.calculateShadowColor;exports.calculateShadowLayers=t.calculateShadowLayers;exports.generateBoxShadow=t.generateBoxShadow;exports.generateShadow=t.generateShadow;exports.isLightColor=t.isLightColor;exports.layersToCSS=t.layersToCSS;exports.normalizeLightSource=t.normalizeLightSource;exports.parseColor=t.parseColor;exports.resolveElevation=t.resolveElevation;exports.applyLift=w;exports.getLiftCSS=m;exports.initAllLiftedBoxes=f;exports.initLiftedBox=h;exports.removeLift=y;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juanlaria/lifted",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Beautiful, realistic CSS shadows with layered depth - inspired by Josh Comeau & Tobias Ahlin",
5
5
  "keywords": [
6
6
  "css",
@@ -1,231 +0,0 @@
1
- const D = 5, U = 0.075, k = -45;
2
- function M(t) {
3
- return t === void 0 ? { type: "static", angle: -45 } : typeof t == "number" ? { type: "static", angle: t } : t === "mouse" ? {
4
- type: "mouse",
5
- smoothing: 0.1,
6
- maxAngle: 60,
7
- fallbackAngle: -45
8
- } : t;
9
- }
10
- function T(t, e, n) {
11
- switch (t.type) {
12
- case "static":
13
- case "custom":
14
- return t.angle;
15
- case "mouse": {
16
- if (!n || !e)
17
- return t.fallbackAngle ?? -45;
18
- const s = e.x + e.width / 2, a = e.y + e.height / 2, i = n.x - s, l = n.y - a;
19
- let r = Math.atan2(l, i) * (180 / Math.PI) + 180;
20
- const c = t.maxAngle ?? 60, h = t.fallbackAngle ?? -45;
21
- let o = r - h;
22
- for (; o > 180; ) o -= 360;
23
- for (; o < -180; ) o += 360;
24
- return o = Math.max(-c, Math.min(c, o)), h + o;
25
- }
26
- default:
27
- return -45;
28
- }
29
- }
30
- function $(t) {
31
- const e = t * (Math.PI / 180);
32
- return {
33
- ratioX: Math.cos(e),
34
- ratioY: Math.sin(e)
35
- };
36
- }
37
- function w(t, e = -45, n = 1) {
38
- const s = Math.max(-1, Math.min(1, t));
39
- if (s === 0)
40
- return [];
41
- const a = s < 0, l = Math.abs(s) * 5, { ratioX: u, ratioY: r } = $(e), c = a ? -1 : 1, h = [];
42
- for (let o = 0; o < 5; o++) {
43
- const d = o + 1, f = Math.pow(2, o);
44
- if (d <= l)
45
- h.push({
46
- offsetX: f * u * n * c,
47
- offsetY: f * r * n * c,
48
- blur: f * n,
49
- spread: 0,
50
- opacity: 0.075 * n,
51
- inset: a
52
- });
53
- else if (d - 1 < l) {
54
- const A = l - (d - 1);
55
- h.push({
56
- offsetX: f * u * A * n * c,
57
- offsetY: f * r * A * n * c,
58
- blur: f * A * n,
59
- spread: 0,
60
- opacity: 0.075 * A * n,
61
- inset: a
62
- });
63
- }
64
- }
65
- return h;
66
- }
67
- function p(t, e, n) {
68
- return t + (e - t) * n;
69
- }
70
- function N(t, e, n) {
71
- return {
72
- x: p(t.x, e.x, n),
73
- y: p(t.y, e.y, n)
74
- };
75
- }
76
- function L(t) {
77
- if (t.match(/^#([0-9a-f]{3,8})$/i))
78
- return I(t);
79
- const n = t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);
80
- if (n)
81
- return {
82
- h: parseFloat(n[1]),
83
- s: parseFloat(n[2]),
84
- l: parseFloat(n[3])
85
- };
86
- const s = t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);
87
- return s ? E({
88
- r: parseFloat(s[1]),
89
- g: parseFloat(s[2]),
90
- b: parseFloat(s[3])
91
- }) : null;
92
- }
93
- function I(t) {
94
- let e = 0, n = 0, s = 0;
95
- return t.length === 4 ? (e = parseInt(t[1] + t[1], 16), n = parseInt(t[2] + t[2], 16), s = parseInt(t[3] + t[3], 16)) : t.length >= 7 && (e = parseInt(t.slice(1, 3), 16), n = parseInt(t.slice(3, 5), 16), s = parseInt(t.slice(5, 7), 16)), E({ r: e, g: n, b: s });
96
- }
97
- function E({ r: t, g: e, b: n }) {
98
- t /= 255, e /= 255, n /= 255;
99
- const s = Math.max(t, e, n), a = Math.min(t, e, n);
100
- let i = 0, l = 0;
101
- const u = (s + a) / 2;
102
- if (s !== a) {
103
- const r = s - a;
104
- switch (l = u > 0.5 ? r / (2 - s - a) : r / (s + a), s) {
105
- case t:
106
- i = ((e - n) / r + (e < n ? 6 : 0)) / 6;
107
- break;
108
- case e:
109
- i = ((n - t) / r + 2) / 6;
110
- break;
111
- case n:
112
- i = ((t - e) / r + 4) / 6;
113
- break;
114
- }
115
- }
116
- return {
117
- h: Math.round(i * 360),
118
- s: Math.round(l * 100),
119
- l: Math.round(u * 100)
120
- };
121
- }
122
- function x(t, e = !1) {
123
- const n = L(t);
124
- if (!n)
125
- return e ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
126
- if (e) {
127
- const s = Math.max(0, n.s - 20), a = Math.min(100, n.l + 30);
128
- return `hsl(${n.h} ${s}% ${a}%)`;
129
- } else {
130
- const s = Math.max(0, n.s * 0.6), a = Math.max(10, n.l * 0.5);
131
- return `hsl(${n.h} ${s}% ${a}%)`;
132
- }
133
- }
134
- function y(t, e) {
135
- const n = L(t);
136
- return n ? `hsl(${n.h} ${n.s}% ${n.l}% / ${e})` : `hsl(220 3% 15% / ${e})`;
137
- }
138
- function O(t) {
139
- const e = L(t);
140
- return e ? e.l > 50 : !0;
141
- }
142
- function b(t, e, n) {
143
- const {
144
- elevation: s = 0.3,
145
- lightSource: a,
146
- background: i,
147
- shadowColor: l,
148
- shadowColorDark: u,
149
- intensity: r = 1,
150
- isDarkMode: c = !1
151
- } = t, h = M(a), o = T(h, e, n), d = w(s, o, r);
152
- let f;
153
- l ? f = l : c && u ? f = u : i ? f = x(i, c) : f = c ? "hsl(0 0% 100% / 0.1)" : "hsl(220 3% 15%)";
154
- const A = C(d, f), S = m(A), _ = F(A, s, o);
155
- return { layers: A, boxShadow: S, cssVariables: _ };
156
- }
157
- function X(t, e = {}) {
158
- return b({ elevation: t, ...e }).boxShadow;
159
- }
160
- function C(t, e) {
161
- return t.map((n) => ({
162
- ...n,
163
- color: y(e, n.opacity)
164
- }));
165
- }
166
- function m(t) {
167
- return t.length === 0 ? "none" : t.map((e) => {
168
- const { offsetX: n, offsetY: s, blur: a, spread: i, color: l, inset: u } = e, r = g(n), c = g(s), h = g(a), o = g(i), d = u ? "inset " : "";
169
- return i === 0 ? `${d}${r} ${c} ${h} ${l}` : `${d}${r} ${c} ${h} ${o} ${l}`;
170
- }).join(`,
171
- `);
172
- }
173
- function g(t) {
174
- return t === 0 ? "0" : `${Math.round(t * 100) / 100}px`;
175
- }
176
- function F(t, e, n) {
177
- return {
178
- "--lifted-elevation": e.toString(),
179
- "--lifted-light-angle": `${n}deg`,
180
- "--lifted-layers": t.length.toString(),
181
- "--lifted-shadow": m(t)
182
- };
183
- }
184
- const G = {
185
- deepInset: -0.75,
186
- inset: -0.3,
187
- none: 0,
188
- subtle: 0.15,
189
- small: 0.25,
190
- medium: 0.5,
191
- large: 0.75,
192
- xlarge: 1
193
- };
194
- function Y(t) {
195
- return typeof t == "number" ? t : G[t];
196
- }
197
- function H(t, e, n) {
198
- const a = {
199
- boxShadow: b(t, e, n).boxShadow
200
- };
201
- return t.background && (a.backgroundColor = t.background), a;
202
- }
203
- const v = "box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";
204
- function R(t = 150, e = !1) {
205
- const n = "cubic-bezier(0.2, 0.6, 0.3, 1)", s = [`box-shadow ${t}ms ${n}`];
206
- return e && s.push(`transform ${t}ms ${n}`), s.join(", ");
207
- }
208
- export {
209
- U as B,
210
- k as D,
211
- G as E,
212
- D as M,
213
- R as a,
214
- x as b,
215
- T as c,
216
- w as d,
217
- X as e,
218
- v as f,
219
- b as g,
220
- $ as h,
221
- O as i,
222
- y as j,
223
- H as k,
224
- m as l,
225
- I as m,
226
- M as n,
227
- E as o,
228
- L as p,
229
- Y as r,
230
- N as s
231
- };
@@ -1,2 +0,0 @@
1
- "use strict";function b(t){return t===void 0?{type:"static",angle:-45}:typeof t=="number"?{type:"static",angle:t}:t==="mouse"?{type:"mouse",smoothing:.1,maxAngle:60,fallbackAngle:-45}:t}function p(t,n,e){switch(t.type){case"static":case"custom":return t.angle;case"mouse":{if(!e||!n)return t.fallbackAngle??-45;const a=n.x+n.width/2,o=n.y+n.height/2,i=e.x-a,l=e.y-o;let r=Math.atan2(l,i)*(180/Math.PI)+180;const c=t.maxAngle??60,h=t.fallbackAngle??-45;let s=r-h;for(;s>180;)s-=360;for(;s<-180;)s+=360;return s=Math.max(-c,Math.min(c,s)),h+s}default:return-45}}function m(t){const n=t*(Math.PI/180);return{ratioX:Math.cos(n),ratioY:Math.sin(n)}}function M(t,n=-45,e=1){const a=Math.max(-1,Math.min(1,t));if(a===0)return[];const o=a<0,l=Math.abs(a)*5,{ratioX:f,ratioY:r}=m(n),c=o?-1:1,h=[];for(let s=0;s<5;s++){const A=s+1,u=Math.pow(2,s);if(A<=l)h.push({offsetX:u*f*e*c,offsetY:u*r*e*c,blur:u*e,spread:0,opacity:.075*e,inset:o});else if(A-1<l){const L=l-(A-1);h.push({offsetX:u*f*L*e*c,offsetY:u*r*L*e*c,blur:u*L*e,spread:0,opacity:.075*L*e,inset:o})}}return h}function _(t,n,e){return t+(n-t)*e}function G(t,n,e){return{x:_(t.x,n.x,e),y:_(t.y,n.y,e)}}function g(t){if(t.match(/^#([0-9a-f]{3,8})$/i))return I(t);const e=t.match(/^hsl\(\s*([\d.]+)\s*,?\s*([\d.]+)%?\s*,?\s*([\d.]+)%?\s*\)/i);if(e)return{h:parseFloat(e[1]),s:parseFloat(e[2]),l:parseFloat(e[3])};const a=t.match(/^rgb\(\s*([\d.]+)\s*,?\s*([\d.]+)\s*,?\s*([\d.]+)\s*\)/i);return a?E({r:parseFloat(a[1]),g:parseFloat(a[2]),b:parseFloat(a[3])}):null}function I(t){let n=0,e=0,a=0;return t.length===4?(n=parseInt(t[1]+t[1],16),e=parseInt(t[2]+t[2],16),a=parseInt(t[3]+t[3],16)):t.length>=7&&(n=parseInt(t.slice(1,3),16),e=parseInt(t.slice(3,5),16),a=parseInt(t.slice(5,7),16)),E({r:n,g:e,b:a})}function E({r:t,g:n,b:e}){t/=255,n/=255,e/=255;const a=Math.max(t,n,e),o=Math.min(t,n,e);let i=0,l=0;const f=(a+o)/2;if(a!==o){const r=a-o;switch(l=f>.5?r/(2-a-o):r/(a+o),a){case t:i=((n-e)/r+(n<e?6:0))/6;break;case n:i=((e-t)/r+2)/6;break;case e:i=((t-n)/r+4)/6;break}}return{h:Math.round(i*360),s:Math.round(l*100),l:Math.round(f*100)}}function w(t,n=!1){const e=g(t);if(!e)return n?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";if(n){const a=Math.max(0,e.s-20),o=Math.min(100,e.l+30);return`hsl(${e.h} ${a}% ${o}%)`}else{const a=Math.max(0,e.s*.6),o=Math.max(10,e.l*.5);return`hsl(${e.h} ${a}% ${o}%)`}}function $(t,n){const e=g(t);return e?`hsl(${e.h} ${e.s}% ${e.l}% / ${n})`:`hsl(220 3% 15% / ${n})`}function F(t){const n=g(t);return n?n.l>50:!0}function S(t,n,e){const{elevation:a=.3,lightSource:o,background:i,shadowColor:l,shadowColorDark:f,intensity:r=1,isDarkMode:c=!1}=t,h=b(o),s=p(h,n,e),A=M(a,s,r);let u;l?u=l:c&&f?u=f:i?u=w(i,c):u=c?"hsl(0 0% 100% / 0.1)":"hsl(220 3% 15%)";const L=D(A,u),x=T(L),y=N(L,a,s);return{layers:L,boxShadow:x,cssVariables:y}}function O(t,n={}){return S({elevation:t,...n}).boxShadow}function D(t,n){return t.map(e=>({...e,color:$(n,e.opacity)}))}function T(t){return t.length===0?"none":t.map(n=>{const{offsetX:e,offsetY:a,blur:o,spread:i,color:l,inset:f}=n,r=d(e),c=d(a),h=d(o),s=d(i),A=f?"inset ":"";return i===0?`${A}${r} ${c} ${h} ${l}`:`${A}${r} ${c} ${h} ${s} ${l}`}).join(`,
2
- `)}function d(t){return t===0?"0":`${Math.round(t*100)/100}px`}function N(t,n,e){return{"--lifted-elevation":n.toString(),"--lifted-light-angle":`${e}deg`,"--lifted-layers":t.length.toString(),"--lifted-shadow":T(t)}}const C={deepInset:-.75,inset:-.3,none:0,subtle:.15,small:.25,medium:.5,large:.75,xlarge:1};function U(t){return typeof t=="number"?t:C[t]}function Y(t,n,e){const o={boxShadow:S(t,n,e).boxShadow};return t.background&&(o.backgroundColor=t.background),o}const H="box-shadow 150ms cubic-bezier(0.2, 0.6, 0.3, 1)";function X(t=150,n=!1){const e="cubic-bezier(0.2, 0.6, 0.3, 1)",a=[`box-shadow ${t}ms ${e}`];return n&&a.push(`transform ${t}ms ${e}`),a.join(", ")}exports.BASE_OPACITY=.075;exports.DEFAULT_LIGHT_ANGLE=-45;exports.DEFAULT_SHADOW_TRANSITION=H;exports.ELEVATION_PRESETS=C;exports.MAX_LAYERS=5;exports.angleToOffsetRatios=m;exports.calculateLightAngle=p;exports.calculateShadowColor=w;exports.calculateShadowLayers=M;exports.generateBoxShadow=O;exports.generateLayerColor=$;exports.generateShadow=S;exports.generateStyleObject=Y;exports.generateTransition=X;exports.hexToHSL=I;exports.isLightColor=F;exports.layersToCSS=T;exports.normalizeLightSource=b;exports.parseColor=g;exports.resolveElevation=U;exports.rgbToHSL=E;exports.smoothPosition=G;