react-native-skia-box-shadow 0.1.0
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/LICENSE +21 -0
- package/README.md +147 -0
- package/lib/commonjs/Shadow.js +245 -0
- package/lib/commonjs/Shadow.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/Shadow.js +240 -0
- package/lib/module/Shadow.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/Shadow.d.ts +54 -0
- package/lib/typescript/Shadow.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +79 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +81 -0
- package/src/Shadow.tsx +260 -0
- package/src/index.ts +7 -0
- package/src/types.ts +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vasyl Stetsiuk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# react-native-skia-box-shadow
|
|
2
|
+
|
|
3
|
+
CSS-style box shadows for React Native — blur, spread, offset, colors, gradients, and arbitrary shapes.
|
|
4
|
+
|
|
5
|
+
Powered by [`@shopify/react-native-skia`](https://shopify.github.io/react-native-skia/).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Blur** — Gaussian blur with no sigma limit (uses Skia ImageFilter)
|
|
10
|
+
- **Spread** — expand or shrink shadow beyond element bounds
|
|
11
|
+
- **Offset** — horizontal and vertical translation
|
|
12
|
+
- **Colors & Gradients** — solid colors or Skia shader fills (linear, radial, sweep)
|
|
13
|
+
- **Shapes** — rect, roundedRect, circle, or arbitrary SVG path
|
|
14
|
+
- **Multi-layer** — stack multiple shadow layers, just like in Figma
|
|
15
|
+
- **Cross-platform** — iOS & Android
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install react-native-skia-box-shadow @shopify/react-native-skia
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
> **Peer dependency**: `@shopify/react-native-skia` >= 1.0.0
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Simple shadow
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Shadow } from 'react-native-skia-box-shadow';
|
|
31
|
+
|
|
32
|
+
<Shadow
|
|
33
|
+
shadows={{
|
|
34
|
+
fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.12)' },
|
|
35
|
+
blurRadius: 16,
|
|
36
|
+
offsetY: 4,
|
|
37
|
+
}}
|
|
38
|
+
shape={{ kind: 'roundedRect', radius: 16 }}
|
|
39
|
+
>
|
|
40
|
+
<View style={{ backgroundColor: '#fff', borderRadius: 16, padding: 20 }}>
|
|
41
|
+
<Text>Card with shadow</Text>
|
|
42
|
+
</View>
|
|
43
|
+
</Shadow>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Multiple shadow layers
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<Shadow
|
|
50
|
+
shadows={[
|
|
51
|
+
{ blurRadius: 2, offsetY: 1, fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.04)' } },
|
|
52
|
+
{ blurRadius: 6, offsetY: 3, fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.06)' } },
|
|
53
|
+
{ blurRadius: 24, offsetY: 12, fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.10)' } },
|
|
54
|
+
]}
|
|
55
|
+
shape={{ kind: 'roundedRect', radius: 12 }}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</Shadow>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Colored / gradient shadow
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Skia } from '@shopify/react-native-skia';
|
|
65
|
+
|
|
66
|
+
<Shadow
|
|
67
|
+
shadows={{
|
|
68
|
+
fillStyle: {
|
|
69
|
+
kind: 'shader',
|
|
70
|
+
factory: (w, h) =>
|
|
71
|
+
Skia.Shader.MakeLinearGradient(
|
|
72
|
+
{ x: 0, y: 0 },
|
|
73
|
+
{ x: w, y: h },
|
|
74
|
+
[Skia.Color('#6366F1'), Skia.Color('#EC4899')],
|
|
75
|
+
null,
|
|
76
|
+
0,
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
blurRadius: 24,
|
|
80
|
+
offsetY: 8,
|
|
81
|
+
}}
|
|
82
|
+
shape={{ kind: 'roundedRect', radius: 20 }}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</Shadow>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Circle shape
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
<Shadow
|
|
92
|
+
shadows={{ blurRadius: 20, spread: 4, fillStyle: { kind: 'color', color: 'rgba(236,72,153,0.35)' } }}
|
|
93
|
+
shape={{ kind: 'circle' }}
|
|
94
|
+
>
|
|
95
|
+
<View style={{ width: 64, height: 64, borderRadius: 32, backgroundColor: '#EC4899' }} />
|
|
96
|
+
</Shadow>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## API
|
|
100
|
+
|
|
101
|
+
### `<Shadow>` Props
|
|
102
|
+
|
|
103
|
+
| Prop | Type | Default | Description |
|
|
104
|
+
| ---------- | --------------------------------- | ------------------- | -------------------------------------- |
|
|
105
|
+
| `shadows` | `ShadowParams \| ShadowParams[]` | required | One or more shadow layer descriptors |
|
|
106
|
+
| `shape` | `ShadowShape` | `{ kind: 'rect' }` | Default shape for all shadow layers |
|
|
107
|
+
| `width` | `number` | auto (onLayout) | Explicit width |
|
|
108
|
+
| `height` | `number` | auto (onLayout) | Explicit height |
|
|
109
|
+
| `style` | `ViewStyle` | — | Style for the outer container |
|
|
110
|
+
| `children` | `ReactNode` | — | Content rendered above the shadow |
|
|
111
|
+
|
|
112
|
+
### `ShadowParams`
|
|
113
|
+
|
|
114
|
+
| Prop | Type | Default | Description |
|
|
115
|
+
| ------------ | ----------------- | -------------- | ------------------------------ |
|
|
116
|
+
| `fillStyle` | `ShadowFillStyle` | black @ 10% | Shadow color or shader |
|
|
117
|
+
| `blurRadius` | `number` | `24` | Gaussian blur radius |
|
|
118
|
+
| `spread` | `number` | `4` | Expand shadow beyond bounds |
|
|
119
|
+
| `offsetX` | `number` | `0` | Horizontal offset |
|
|
120
|
+
| `offsetY` | `number` | `0` | Vertical offset |
|
|
121
|
+
| `shape` | `ShadowShape` | inherits | Per-layer shape override |
|
|
122
|
+
|
|
123
|
+
### `ShadowShape`
|
|
124
|
+
|
|
125
|
+
| Kind | Props | Description |
|
|
126
|
+
| ------------- | ---------- | ---------------------- |
|
|
127
|
+
| `rect` | — | Rectangle |
|
|
128
|
+
| `roundedRect` | `radius` | Rounded rectangle |
|
|
129
|
+
| `circle` | — | Circle |
|
|
130
|
+
| `path` | `svgPath` | Arbitrary SVG path |
|
|
131
|
+
|
|
132
|
+
### `ShadowFillStyle`
|
|
133
|
+
|
|
134
|
+
| Kind | Props | Description |
|
|
135
|
+
| -------- | ------------------- | ---------------------------------- |
|
|
136
|
+
| `color` | `color: string` | Solid color (any CSS color string) |
|
|
137
|
+
| `shader` | `factory: Function` | `(width, height) => SkShader` |
|
|
138
|
+
|
|
139
|
+
## How it works
|
|
140
|
+
|
|
141
|
+
The component renders a Skia `<Canvas>` behind your children. Each shadow layer draws a shape (matching your content's shape) with a Gaussian blur applied as an ImageFilter. The canvas is automatically expanded to prevent clipping.
|
|
142
|
+
|
|
143
|
+
This is a React Native port of the Compose Multiplatform library [`vasyl-stetsiuk/shadow`](https://github.com/vasyl-stetsiuk/shadow).
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT © [Vasyl Stetsiuk](https://stetsiuk.dev)
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ShadowDefaults = exports.Shadow = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeSkia = require("@shopify/react-native-skia");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
// ── Defaults (mirrors ShadowDefaults.kt) ───────────────────────
|
|
13
|
+
const DEFAULTS = exports.ShadowDefaults = {
|
|
14
|
+
fillStyle: {
|
|
15
|
+
kind: 'color',
|
|
16
|
+
color: 'rgba(0,0,0,0.10)'
|
|
17
|
+
},
|
|
18
|
+
blurRadius: 24,
|
|
19
|
+
spread: 4,
|
|
20
|
+
offsetX: 0,
|
|
21
|
+
offsetY: 0
|
|
22
|
+
};
|
|
23
|
+
const pixelRatio = _reactNative.PixelRatio.get();
|
|
24
|
+
|
|
25
|
+
// ── Single shadow layer renderer ────────────────────────────────
|
|
26
|
+
const ShadowLayer = ({
|
|
27
|
+
params,
|
|
28
|
+
width,
|
|
29
|
+
height,
|
|
30
|
+
defaultShape
|
|
31
|
+
}) => {
|
|
32
|
+
const {
|
|
33
|
+
fillStyle = DEFAULTS.fillStyle,
|
|
34
|
+
blurRadius = DEFAULTS.blurRadius,
|
|
35
|
+
spread = DEFAULTS.spread,
|
|
36
|
+
offsetX = DEFAULTS.offsetX,
|
|
37
|
+
offsetY = DEFAULTS.offsetY,
|
|
38
|
+
shape: shapeOverride
|
|
39
|
+
} = params;
|
|
40
|
+
const shape = shapeOverride ?? defaultShape;
|
|
41
|
+
|
|
42
|
+
// ── Paint ─────────────────────────────────────────────────────
|
|
43
|
+
const paint = (0, _react.useMemo)(() => {
|
|
44
|
+
const p = _reactNativeSkia.Skia.Paint();
|
|
45
|
+
if (fillStyle.kind === 'color') {
|
|
46
|
+
p.setColor(_reactNativeSkia.Skia.Color(fillStyle.color));
|
|
47
|
+
} else {
|
|
48
|
+
p.setShader(fillStyle.factory(width, height));
|
|
49
|
+
}
|
|
50
|
+
return p;
|
|
51
|
+
}, [fillStyle, width, height]);
|
|
52
|
+
|
|
53
|
+
// ── Shadow sizing (spread) ────────────────────────────────────
|
|
54
|
+
const shadowWidth = width + spread * 2;
|
|
55
|
+
const shadowHeight = height + spread * 2;
|
|
56
|
+
const scaleX = width > 0 ? shadowWidth / width : 1;
|
|
57
|
+
const scaleY = height > 0 ? shadowHeight / height : 1;
|
|
58
|
+
|
|
59
|
+
// ── Blur (adjusted for pixel density) ─────────────────────────
|
|
60
|
+
const adjustedBlur = blurRadius / pixelRatio;
|
|
61
|
+
const blurChild = adjustedBlur > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Blur, {
|
|
62
|
+
blur: adjustedBlur
|
|
63
|
+
}) : null;
|
|
64
|
+
|
|
65
|
+
// ── Shape element (with Blur as child) ────────────────────────
|
|
66
|
+
const shapeElement = (0, _react.useMemo)(() => {
|
|
67
|
+
switch (shape.kind) {
|
|
68
|
+
case 'roundedRect':
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.RoundedRect, {
|
|
70
|
+
x: 0,
|
|
71
|
+
y: 0,
|
|
72
|
+
width: width,
|
|
73
|
+
height: height,
|
|
74
|
+
r: shape.radius,
|
|
75
|
+
paint: paint,
|
|
76
|
+
children: blurChild
|
|
77
|
+
});
|
|
78
|
+
case 'circle':
|
|
79
|
+
{
|
|
80
|
+
const r = Math.min(width, height) / 2;
|
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Circle, {
|
|
82
|
+
cx: width / 2,
|
|
83
|
+
cy: height / 2,
|
|
84
|
+
r: r,
|
|
85
|
+
paint: paint,
|
|
86
|
+
children: blurChild
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
case 'path':
|
|
90
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Path, {
|
|
91
|
+
path: shape.svgPath,
|
|
92
|
+
paint: paint,
|
|
93
|
+
children: blurChild
|
|
94
|
+
});
|
|
95
|
+
case 'rect':
|
|
96
|
+
default:
|
|
97
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Rect, {
|
|
98
|
+
x: 0,
|
|
99
|
+
y: 0,
|
|
100
|
+
width: width,
|
|
101
|
+
height: height,
|
|
102
|
+
paint: paint,
|
|
103
|
+
children: blurChild
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}, [shape, width, height, paint, blurChild]);
|
|
107
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Group, {
|
|
108
|
+
transform: [{
|
|
109
|
+
translateX: offsetX
|
|
110
|
+
}, {
|
|
111
|
+
translateY: offsetY
|
|
112
|
+
}],
|
|
113
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Group, {
|
|
114
|
+
transform: [{
|
|
115
|
+
scaleX
|
|
116
|
+
}, {
|
|
117
|
+
scaleY
|
|
118
|
+
}],
|
|
119
|
+
origin: {
|
|
120
|
+
x: width / 2,
|
|
121
|
+
y: height / 2
|
|
122
|
+
},
|
|
123
|
+
children: shapeElement
|
|
124
|
+
})
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `<Shadow>` — CSS-style box shadows for React Native.
|
|
130
|
+
*
|
|
131
|
+
* Renders one or more blurred, colored shadows behind `children`.
|
|
132
|
+
* Supports blur, spread, offset, custom colors/shaders, and
|
|
133
|
+
* arbitrary shapes (rect, roundedRect, circle, SVG path).
|
|
134
|
+
*
|
|
135
|
+
* Powered by `@shopify/react-native-skia`.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```tsx
|
|
139
|
+
* import { Shadow } from 'react-native-skia-box-shadow';
|
|
140
|
+
*
|
|
141
|
+
* <Shadow
|
|
142
|
+
* shadows={{
|
|
143
|
+
* fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.15)' },
|
|
144
|
+
* blurRadius: 20,
|
|
145
|
+
* offsetY: 4,
|
|
146
|
+
* }}
|
|
147
|
+
* shape={{ kind: 'roundedRect', radius: 16 }}
|
|
148
|
+
* >
|
|
149
|
+
* <View style={styles.card}>
|
|
150
|
+
* <Text>Card with shadow</Text>
|
|
151
|
+
* </View>
|
|
152
|
+
* </Shadow>
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* // Multiple shadow layers
|
|
158
|
+
* <Shadow
|
|
159
|
+
* shadows={[
|
|
160
|
+
* { blurRadius: 4, offsetY: 2, fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.08)' } },
|
|
161
|
+
* { blurRadius: 16, offsetY: 8, fillStyle: { kind: 'color', color: 'rgba(0,0,0,0.12)' } },
|
|
162
|
+
* ]}
|
|
163
|
+
* shape={{ kind: 'roundedRect', radius: 12 }}
|
|
164
|
+
* >
|
|
165
|
+
* {children}
|
|
166
|
+
* </Shadow>
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
const Shadow = ({
|
|
170
|
+
shadows,
|
|
171
|
+
shape = {
|
|
172
|
+
kind: 'rect'
|
|
173
|
+
},
|
|
174
|
+
width: _width,
|
|
175
|
+
height: _height,
|
|
176
|
+
style,
|
|
177
|
+
children
|
|
178
|
+
}) => {
|
|
179
|
+
const [layout, setLayout] = (0, _react.useState)(null);
|
|
180
|
+
const onLayout = e => {
|
|
181
|
+
const {
|
|
182
|
+
width,
|
|
183
|
+
height
|
|
184
|
+
} = e.nativeEvent.layout;
|
|
185
|
+
setLayout({
|
|
186
|
+
width,
|
|
187
|
+
height
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
const width = _width ?? layout?.width ?? 0;
|
|
191
|
+
const height = _height ?? layout?.height ?? 0;
|
|
192
|
+
const shadowList = Array.isArray(shadows) ? shadows : [shadows];
|
|
193
|
+
|
|
194
|
+
// ── Compute canvas padding ────────────────────────────────────
|
|
195
|
+
// The canvas must be large enough to contain blurred + spread +
|
|
196
|
+
// offset shadows without clipping.
|
|
197
|
+
const canvasPadding = (0, _react.useMemo)(() => {
|
|
198
|
+
let maxExtent = 0;
|
|
199
|
+
for (const s of shadowList) {
|
|
200
|
+
const blur = s.blurRadius ?? DEFAULTS.blurRadius;
|
|
201
|
+
const spread = s.spread ?? DEFAULTS.spread;
|
|
202
|
+
const ox = Math.abs(s.offsetX ?? DEFAULTS.offsetX);
|
|
203
|
+
const oy = Math.abs(s.offsetY ?? DEFAULTS.offsetY);
|
|
204
|
+
const extent = blur * 3 + spread + Math.max(ox, oy);
|
|
205
|
+
if (extent > maxExtent) maxExtent = extent;
|
|
206
|
+
}
|
|
207
|
+
return Math.ceil(maxExtent);
|
|
208
|
+
}, [shadowList]);
|
|
209
|
+
const hasSize = width > 0 && height > 0;
|
|
210
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
211
|
+
style: [styles.container, style],
|
|
212
|
+
onLayout: onLayout,
|
|
213
|
+
children: [hasSize && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Canvas, {
|
|
214
|
+
style: [styles.canvas, {
|
|
215
|
+
top: -canvasPadding,
|
|
216
|
+
left: -canvasPadding,
|
|
217
|
+
width: width + canvasPadding * 2,
|
|
218
|
+
height: height + canvasPadding * 2
|
|
219
|
+
}],
|
|
220
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSkia.Group, {
|
|
221
|
+
transform: [{
|
|
222
|
+
translateX: canvasPadding
|
|
223
|
+
}, {
|
|
224
|
+
translateY: canvasPadding
|
|
225
|
+
}],
|
|
226
|
+
children: shadowList.map((params, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ShadowLayer, {
|
|
227
|
+
params: params,
|
|
228
|
+
width: width,
|
|
229
|
+
height: height,
|
|
230
|
+
defaultShape: shape
|
|
231
|
+
}, idx))
|
|
232
|
+
})
|
|
233
|
+
}), children]
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
exports.Shadow = Shadow;
|
|
237
|
+
const styles = _reactNative.StyleSheet.create({
|
|
238
|
+
container: {},
|
|
239
|
+
canvas: {
|
|
240
|
+
position: 'absolute',
|
|
241
|
+
pointerEvents: 'none'
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
var _default = exports.default = Shadow;
|
|
245
|
+
//# sourceMappingURL=Shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeSkia","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DEFAULTS","exports","ShadowDefaults","fillStyle","kind","color","blurRadius","spread","offsetX","offsetY","pixelRatio","PixelRatio","ShadowLayer","params","width","height","defaultShape","shape","shapeOverride","paint","useMemo","p","Skia","Paint","setColor","Color","setShader","factory","shadowWidth","shadowHeight","scaleX","scaleY","adjustedBlur","blurChild","jsx","Blur","blur","shapeElement","RoundedRect","x","y","radius","children","Math","min","Circle","cx","cy","Path","path","svgPath","Rect","Group","transform","translateX","translateY","origin","Shadow","shadows","_width","_height","style","layout","setLayout","useState","onLayout","nativeEvent","shadowList","Array","isArray","canvasPadding","maxExtent","s","ox","abs","oy","extent","max","ceil","hasSize","jsxs","View","styles","container","Canvas","canvas","top","left","map","idx","StyleSheet","create","position","pointerEvents","_default"],"sourceRoot":"../../src","sources":["Shadow.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC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,CAACC,MAAM,CAAC;EAC/BR,SAAS,EAAE,CAAC,CAAC;EACbE,MAAM,EAAE;IACNO,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAAC,IAAAC,QAAA,GAAA7F,OAAA,CAAAV,OAAA,GAEYkE,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Shadow", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Shadow.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ShadowDefaults", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Shadow.ShadowDefaults;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ShadowView", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Shadow.Shadow;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _Shadow = _interopRequireWildcard(require("./Shadow"));
|
|
25
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Shadow","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAmF,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|