jfs-components 0.1.2 → 0.1.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/CHANGELOG.md +29 -0
- package/lib/commonjs/components/AmountInput/AmountInput.js +8 -5
- package/lib/commonjs/components/BenefitCard/BenefitCard.js +231 -0
- package/lib/commonjs/components/CcCard/CcCard.js +470 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +4 -3
- package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +4 -3
- package/lib/commonjs/components/CompareTable/CompareTable.js +372 -0
- package/lib/commonjs/components/ComparisonBar/ComparisonBar.js +266 -0
- package/lib/commonjs/components/DropdownInput/DropdownInput.js +35 -3
- package/lib/commonjs/components/FormField/FormField.js +4 -3
- package/lib/commonjs/components/InputSearch/InputSearch.js +6 -4
- package/lib/commonjs/components/NoteInput/NoteInput.js +6 -5
- package/lib/commonjs/components/PdpCcCard/PdpCcCard.js +273 -0
- package/lib/commonjs/components/ProductMerchandisingCard/GlassFill.js +263 -0
- package/lib/commonjs/components/ProductMerchandisingCard/GlassFill.web.js +116 -0
- package/lib/commonjs/components/ProductMerchandisingCard/ProductMerchandisingCard.js +353 -0
- package/lib/commonjs/components/ProjectionMarker/ProjectionMarker.js +161 -0
- package/lib/commonjs/components/Radio/Radio.js +5 -5
- package/lib/commonjs/components/Slider/Slider.js +473 -0
- package/lib/commonjs/components/TextInput/TextInput.js +13 -8
- package/lib/commonjs/components/TextSegment/TextSegment.js +118 -0
- package/lib/commonjs/components/index.js +63 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/design-tokens/figma-modes.generated.js +38 -9
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/react-utils.js +22 -0
- package/lib/module/components/AmountInput/AmountInput.js +6 -4
- package/lib/module/components/BenefitCard/BenefitCard.js +225 -0
- package/lib/module/components/CcCard/CcCard.js +464 -0
- package/lib/module/components/Checkbox/Checkbox.js +5 -4
- package/lib/module/components/CheckboxItem/CheckboxItem.js +5 -4
- package/lib/module/components/CompareTable/CompareTable.js +367 -0
- package/lib/module/components/ComparisonBar/ComparisonBar.js +260 -0
- package/lib/module/components/DropdownInput/DropdownInput.js +36 -4
- package/lib/module/components/FormField/FormField.js +5 -4
- package/lib/module/components/InputSearch/InputSearch.js +6 -4
- package/lib/module/components/NoteInput/NoteInput.js +7 -6
- package/lib/module/components/PdpCcCard/PdpCcCard.js +267 -0
- package/lib/module/components/ProductMerchandisingCard/GlassFill.js +257 -0
- package/lib/module/components/ProductMerchandisingCard/GlassFill.web.js +111 -0
- package/lib/module/components/ProductMerchandisingCard/ProductMerchandisingCard.js +347 -0
- package/lib/module/components/ProjectionMarker/ProjectionMarker.js +156 -0
- package/lib/module/components/Radio/Radio.js +5 -4
- package/lib/module/components/Slider/Slider.js +468 -0
- package/lib/module/components/TextInput/TextInput.js +15 -10
- package/lib/module/components/TextSegment/TextSegment.js +113 -0
- package/lib/module/components/index.js +9 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/design-tokens/figma-modes.generated.js +38 -9
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/react-utils.js +21 -0
- package/lib/typescript/src/components/AmountInput/AmountInput.d.ts +3 -2
- package/lib/typescript/src/components/BenefitCard/BenefitCard.d.ts +93 -0
- package/lib/typescript/src/components/CcCard/CcCard.d.ts +137 -0
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +2 -2
- package/lib/typescript/src/components/CompareTable/CompareTable.d.ts +88 -0
- package/lib/typescript/src/components/ComparisonBar/ComparisonBar.d.ts +118 -0
- package/lib/typescript/src/components/DropdownInput/DropdownInput.d.ts +20 -1
- package/lib/typescript/src/components/FormField/FormField.d.ts +2 -2
- package/lib/typescript/src/components/InputSearch/InputSearch.d.ts +23 -2
- package/lib/typescript/src/components/NoteInput/NoteInput.d.ts +19 -2
- package/lib/typescript/src/components/PdpCcCard/PdpCcCard.d.ts +84 -0
- package/lib/typescript/src/components/ProductMerchandisingCard/GlassFill.d.ts +56 -0
- package/lib/typescript/src/components/ProductMerchandisingCard/GlassFill.web.d.ts +27 -0
- package/lib/typescript/src/components/ProductMerchandisingCard/ProductMerchandisingCard.d.ts +81 -0
- package/lib/typescript/src/components/ProjectionMarker/ProjectionMarker.d.ts +82 -0
- package/lib/typescript/src/components/Radio/Radio.d.ts +3 -2
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/typescript/src/components/Slider/Slider.d.ts +99 -0
- package/lib/typescript/src/components/TextInput/TextInput.d.ts +9 -29
- package/lib/typescript/src/components/TextSegment/TextSegment.d.ts +100 -0
- package/lib/typescript/src/components/index.d.ts +10 -1
- package/lib/typescript/src/design-tokens/figma-modes.generated.d.ts +22 -2
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/lib/typescript/src/utils/react-utils.d.ts +10 -0
- package/package.json +2 -1
- package/src/components/AmountInput/AmountInput.tsx +7 -5
- package/src/components/BenefitCard/BenefitCard.tsx +309 -0
- package/src/components/CcCard/CcCard.tsx +598 -0
- package/src/components/Checkbox/Checkbox.tsx +5 -4
- package/src/components/CheckboxItem/CheckboxItem.tsx +5 -4
- package/src/components/CompareTable/CompareTable.tsx +477 -0
- package/src/components/ComparisonBar/ComparisonBar.tsx +356 -0
- package/src/components/DropdownInput/DropdownInput.tsx +55 -3
- package/src/components/FormField/FormField.tsx +5 -4
- package/src/components/InputSearch/InputSearch.tsx +8 -5
- package/src/components/NoteInput/NoteInput.tsx +8 -6
- package/src/components/PdpCcCard/PdpCcCard.tsx +356 -0
- package/src/components/ProductMerchandisingCard/GlassFill.tsx +276 -0
- package/src/components/ProductMerchandisingCard/GlassFill.web.tsx +127 -0
- package/src/components/ProductMerchandisingCard/ProductMerchandisingCard.tsx +423 -0
- package/src/components/ProjectionMarker/ProjectionMarker.tsx +277 -0
- package/src/components/Radio/Radio.tsx +5 -4
- package/src/components/Slider/Slider.tsx +628 -0
- package/src/components/TextInput/TextInput.tsx +15 -11
- package/src/components/TextSegment/TextSegment.tsx +166 -0
- package/src/components/index.ts +10 -1
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/design-tokens/figma-modes.generated.ts +38 -9
- package/src/icons/registry.ts +1 -1
- package/src/utils/react-utils.ts +23 -0
- package/lib/typescript/scripts/extract-component-tokens.d.ts +0 -9
- package/lib/typescript/scripts/generate-component-docs.d.ts +0 -9
- package/lib/typescript/scripts/generate-icon-registry.d.ts +0 -3
- package/lib/typescript/scripts/generate-mode-types.d.ts +0 -2
- package/lib/typescript/scripts/retype-modes.d.cts +0 -2
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _blur = require("@react-native-community/blur");
|
|
10
|
+
var _maskedView = _interopRequireDefault(require("@react-native-masked-view/masked-view"));
|
|
11
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
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); }
|
|
15
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a';
|
|
16
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66';
|
|
17
|
+
|
|
18
|
+
// The native view-manager name registered by `@react-native-community/blur`
|
|
19
|
+
// (`AndroidBlurView` on Android, `BlurView` on iOS).
|
|
20
|
+
const NATIVE_BLUR_NAME = _reactNative.Platform.OS === 'android' ? 'AndroidBlurView' : 'BlurView';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Alpha stop on a layer's vertical reveal mask. `offset` is the vertical
|
|
24
|
+
* position (0 = top of the surface, 1 = bottom); `opacity` is the mask alpha
|
|
25
|
+
* there (0 = layer hidden / fully clear, 1 = layer fully applied).
|
|
26
|
+
*
|
|
27
|
+
* Using several stops (rather than a single linear 0 → 1 ramp) lets each layer
|
|
28
|
+
* EASE in, so the blur swells smoothly toward the bottom instead of appearing
|
|
29
|
+
* along a hard horizontal seam. That soft S-curve is what gives the surface its
|
|
30
|
+
* "glass" feel rather than a flat translucent panel.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A single layer of the progressive ramp.
|
|
35
|
+
* - `stops` describe how this layer is revealed from top to bottom.
|
|
36
|
+
* - `amount` is this layer's share (0–1) of the max `blurAmount`.
|
|
37
|
+
*
|
|
38
|
+
* We stack just TWO layers on both platforms: a faint base blur that covers
|
|
39
|
+
* most of the footer and a slightly stronger accent concentrated near the
|
|
40
|
+
* bottom. Keeping the overlap shallow avoids compounding the dark tint of
|
|
41
|
+
* multiple `BlurView`s (which is what made the earlier 3-layer ramp read as a
|
|
42
|
+
* heavy block), while still giving a genuine variable-radius result — the blur
|
|
43
|
+
* radius grows toward the bottom where the two layers overlap.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// Base reveal: a faint trace of blur begins near the very top and grows
|
|
47
|
+
// steadily downward, so the upper half still carries visible glass rather than
|
|
48
|
+
// snapping clear. Also reused for the no-native-blur fallback scrim.
|
|
49
|
+
const BASE_MASK_STOPS = [{
|
|
50
|
+
offset: 0.0,
|
|
51
|
+
opacity: 0
|
|
52
|
+
}, {
|
|
53
|
+
offset: 0.08,
|
|
54
|
+
opacity: 0.12
|
|
55
|
+
}, {
|
|
56
|
+
offset: 0.35,
|
|
57
|
+
opacity: 0.4
|
|
58
|
+
}, {
|
|
59
|
+
offset: 0.65,
|
|
60
|
+
opacity: 0.8
|
|
61
|
+
}, {
|
|
62
|
+
offset: 1.0,
|
|
63
|
+
opacity: 1
|
|
64
|
+
}];
|
|
65
|
+
const PROGRESSIVE_LAYERS = [{
|
|
66
|
+
amount: 0.65,
|
|
67
|
+
stops: BASE_MASK_STOPS
|
|
68
|
+
},
|
|
69
|
+
// Accent: the strongest blur, gathering over the lower portion for depth.
|
|
70
|
+
{
|
|
71
|
+
amount: 1.0,
|
|
72
|
+
stops: [{
|
|
73
|
+
offset: 0.0,
|
|
74
|
+
opacity: 0
|
|
75
|
+
}, {
|
|
76
|
+
offset: 0.3,
|
|
77
|
+
opacity: 0.15
|
|
78
|
+
}, {
|
|
79
|
+
offset: 0.65,
|
|
80
|
+
opacity: 0.65
|
|
81
|
+
}, {
|
|
82
|
+
offset: 1.0,
|
|
83
|
+
opacity: 1
|
|
84
|
+
}]
|
|
85
|
+
}];
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Probe ONCE whether the native blur view is actually present in this binary.
|
|
89
|
+
*
|
|
90
|
+
* `@react-native-community/blur` is a peer dependency so its JS always imports,
|
|
91
|
+
* but on a build where the native module was never linked (e.g. `pod install`
|
|
92
|
+
* wasn't run on iOS) rendering `<BlurView>` shows React Native's red
|
|
93
|
+
* "Unimplemented component <BlurView>" placeholder. Detecting availability up
|
|
94
|
+
* front lets us fall back to a tinted scrim instead of crashing the surface.
|
|
95
|
+
*
|
|
96
|
+
* - New architecture (bridgeless): `getViewManagerConfig` raises a soft error,
|
|
97
|
+
* so we MUST use `hasViewManagerConfig` -> Fabric component registry.
|
|
98
|
+
* - Old architecture (Paper): `getViewManagerConfig` returns null when the
|
|
99
|
+
* view manager isn't registered.
|
|
100
|
+
*/
|
|
101
|
+
const NATIVE_BLUR_SUPPORTED = (() => {
|
|
102
|
+
try {
|
|
103
|
+
const um = _reactNative.UIManager;
|
|
104
|
+
if (typeof um.hasViewManagerConfig === 'function') {
|
|
105
|
+
return um.hasViewManagerConfig(NATIVE_BLUR_NAME) === true;
|
|
106
|
+
}
|
|
107
|
+
if (typeof um.getViewManagerConfig === 'function') {
|
|
108
|
+
return um.getViewManagerConfig(NATIVE_BLUR_NAME) != null;
|
|
109
|
+
}
|
|
110
|
+
} catch {
|
|
111
|
+
// Any probe failure -> treat blur as unavailable and use the fallback.
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
})();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Vertical alpha-gradient mask drawn with `react-native-svg`. `MaskedView`
|
|
118
|
+
* reveals its child in proportion to this mask's alpha, so feeding it an eased
|
|
119
|
+
* multi-stop gradient makes the layer's blur swell in smoothly from top to
|
|
120
|
+
* bottom instead of along a hard seam.
|
|
121
|
+
*/
|
|
122
|
+
function GradientMask({
|
|
123
|
+
id,
|
|
124
|
+
stops
|
|
125
|
+
}) {
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
|
|
127
|
+
width: "100%",
|
|
128
|
+
height: "100%",
|
|
129
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Defs, {
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.LinearGradient, {
|
|
131
|
+
id: id,
|
|
132
|
+
x1: "0",
|
|
133
|
+
y1: "0",
|
|
134
|
+
x2: "0",
|
|
135
|
+
y2: "1",
|
|
136
|
+
children: stops.map((s, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
137
|
+
offset: s.offset,
|
|
138
|
+
stopColor: "#000000",
|
|
139
|
+
stopOpacity: s.opacity
|
|
140
|
+
}, i))
|
|
141
|
+
})
|
|
142
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
|
|
143
|
+
x: "0",
|
|
144
|
+
y: "0",
|
|
145
|
+
width: "100%",
|
|
146
|
+
height: "100%",
|
|
147
|
+
fill: `url(#${id})`
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Glass / frosted surface for native (iOS + Android).
|
|
154
|
+
*
|
|
155
|
+
* Why this lives in its own platform-split file (mirrors `MediaCard/GlassFill`):
|
|
156
|
+
* - `@react-native-community/blur` is a native-only module; importing it on
|
|
157
|
+
* web throws because it references native components not registered there.
|
|
158
|
+
* Metro's platform-extension resolution picks `GlassFill.tsx` for native
|
|
159
|
+
* and `GlassFill.web.tsx` for web, keeping the web bundle native-free.
|
|
160
|
+
* - Centralizes the `intensity` (0–100) -> `blurAmount` (0–32) mapping so the
|
|
161
|
+
* Figma `blur/minimal` token semantics survive across platforms.
|
|
162
|
+
*
|
|
163
|
+
* On iOS (with the pod installed) this is a real `UIVisualEffectView` (true
|
|
164
|
+
* OS-level live blur). On Android it uses the community blur view. When the
|
|
165
|
+
* native module isn't linked in the running binary, the component degrades to
|
|
166
|
+
* a translucent tinted scrim (`reducedTransparencyFallbackColor` / fallback
|
|
167
|
+
* color) instead of rendering the "Unimplemented component" placeholder.
|
|
168
|
+
*/
|
|
169
|
+
function GlassFill({
|
|
170
|
+
tint = 'dark',
|
|
171
|
+
intensity = 50,
|
|
172
|
+
overlayColor,
|
|
173
|
+
progressive = false,
|
|
174
|
+
style
|
|
175
|
+
}) {
|
|
176
|
+
const rawId = (0, _react.useId)();
|
|
177
|
+
const maskId = `glass-mask-${rawId.replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
178
|
+
const blurType = tint === 'light' ? 'light' : 'dark';
|
|
179
|
+
const uniformBlurAmount = Math.max(0, Math.min(32, Math.round(intensity * 0.32)));
|
|
180
|
+
const fallbackColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK);
|
|
181
|
+
|
|
182
|
+
// ----- Progressive (variable) blur -------------------------------------
|
|
183
|
+
if (progressive) {
|
|
184
|
+
// Peak blur radius (at the bottom). Full strength so the frosted glass
|
|
185
|
+
// is clearly engaged where the layers overlap, while the eased masks
|
|
186
|
+
// keep the top of the surface fully clear.
|
|
187
|
+
const peakBlur = Math.max(1, Math.min(32, Math.round(intensity * 0.32)));
|
|
188
|
+
|
|
189
|
+
// Native blur not linked -> tint eases from transparent (top) to a soft
|
|
190
|
+
// fallback color (bottom) so the surface still reads as gentle glass.
|
|
191
|
+
if (!NATIVE_BLUR_SUPPORTED) {
|
|
192
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
193
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
194
|
+
pointerEvents: "none",
|
|
195
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_maskedView.default, {
|
|
196
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
197
|
+
maskElement: /*#__PURE__*/(0, _jsxRuntime.jsx)(GradientMask, {
|
|
198
|
+
id: `${maskId}-fb`,
|
|
199
|
+
stops: BASE_MASK_STOPS
|
|
200
|
+
}),
|
|
201
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
202
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
203
|
+
backgroundColor: fallbackColor
|
|
204
|
+
}]
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
210
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
211
|
+
pointerEvents: "none",
|
|
212
|
+
children: PROGRESSIVE_LAYERS.map((layer, i) => {
|
|
213
|
+
const amount = Math.max(1, Math.round(peakBlur * layer.amount));
|
|
214
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_maskedView.default, {
|
|
215
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
216
|
+
maskElement: /*#__PURE__*/(0, _jsxRuntime.jsx)(GradientMask, {
|
|
217
|
+
id: `${maskId}-${i}`,
|
|
218
|
+
stops: layer.stops
|
|
219
|
+
}),
|
|
220
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_blur.BlurView, {
|
|
221
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
222
|
+
blurType: blurType,
|
|
223
|
+
blurAmount: amount,
|
|
224
|
+
reducedTransparencyFallbackColor: fallbackColor
|
|
225
|
+
})
|
|
226
|
+
}, i);
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ----- Uniform blur (default) ------------------------------------------
|
|
232
|
+
// Native blur not linked in this build -> render a translucent tinted scrim
|
|
233
|
+
// so the surface still reads as frosted glass and never shows RN's
|
|
234
|
+
// "Unimplemented component <BlurView>" box.
|
|
235
|
+
if (!NATIVE_BLUR_SUPPORTED) {
|
|
236
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
237
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
238
|
+
backgroundColor: fallbackColor
|
|
239
|
+
}, style],
|
|
240
|
+
pointerEvents: "none"
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
244
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
245
|
+
pointerEvents: "none",
|
|
246
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blur.BlurView, {
|
|
247
|
+
style: _reactNative.StyleSheet.absoluteFill,
|
|
248
|
+
blurType: blurType,
|
|
249
|
+
blurAmount: uniformBlurAmount,
|
|
250
|
+
reducedTransparencyFallbackColor: fallbackColor
|
|
251
|
+
}), overlayColor != null ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
252
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
253
|
+
backgroundColor: overlayColor
|
|
254
|
+
}]
|
|
255
|
+
}) : null, _reactNative.Platform.OS === 'android' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
256
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
257
|
+
backgroundColor: 'rgba(255,255,255,0.03)',
|
|
258
|
+
opacity: 0.6
|
|
259
|
+
}]
|
|
260
|
+
}) : null]
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
var _default = exports.default = GlassFill;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const DEFAULT_FALLBACK_DARK = '#1414174a';
|
|
12
|
+
const DEFAULT_FALLBACK_LIGHT = '#ffffff66';
|
|
13
|
+
|
|
14
|
+
// Mirror of the native ramp (see GlassFill.tsx). Each layer is a `mask-image`
|
|
15
|
+
// gradient whose alpha stops (0 = top, 1 = bottom) ease the blur in; `amount`
|
|
16
|
+
// is the layer's share of the max blur. Two gently-overlapping layers (faint
|
|
17
|
+
// base + bottom accent) keep the surface subtle and glass-like rather than a
|
|
18
|
+
// heavy frosted block.
|
|
19
|
+
|
|
20
|
+
const PROGRESSIVE_LAYERS = [{
|
|
21
|
+
amount: 0.65,
|
|
22
|
+
stops: [{
|
|
23
|
+
offset: 0.0,
|
|
24
|
+
opacity: 0
|
|
25
|
+
}, {
|
|
26
|
+
offset: 0.08,
|
|
27
|
+
opacity: 0.12
|
|
28
|
+
}, {
|
|
29
|
+
offset: 0.35,
|
|
30
|
+
opacity: 0.4
|
|
31
|
+
}, {
|
|
32
|
+
offset: 0.65,
|
|
33
|
+
opacity: 0.8
|
|
34
|
+
}, {
|
|
35
|
+
offset: 1.0,
|
|
36
|
+
opacity: 1
|
|
37
|
+
}]
|
|
38
|
+
}, {
|
|
39
|
+
amount: 1.0,
|
|
40
|
+
stops: [{
|
|
41
|
+
offset: 0.0,
|
|
42
|
+
opacity: 0
|
|
43
|
+
}, {
|
|
44
|
+
offset: 0.3,
|
|
45
|
+
opacity: 0.15
|
|
46
|
+
}, {
|
|
47
|
+
offset: 0.65,
|
|
48
|
+
opacity: 0.65
|
|
49
|
+
}, {
|
|
50
|
+
offset: 1.0,
|
|
51
|
+
opacity: 1
|
|
52
|
+
}]
|
|
53
|
+
}];
|
|
54
|
+
function toGradient(stops) {
|
|
55
|
+
const parts = stops.map(s => `rgba(0,0,0,${s.opacity}) ${Math.round(s.offset * 100)}%`).join(', ');
|
|
56
|
+
return `linear-gradient(to bottom, ${parts})`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Web counterpart of `GlassFill`.
|
|
61
|
+
*
|
|
62
|
+
* `@react-native-community/blur` ships no web implementation, so on web we
|
|
63
|
+
* render a translucent `View` with `backdrop-filter: blur()`. Native bundles
|
|
64
|
+
* pick up `GlassFill.tsx` instead via Metro's platform resolver; the web
|
|
65
|
+
* bundle picks up this file, so the native-only module is never imported here.
|
|
66
|
+
*/
|
|
67
|
+
function GlassFill({
|
|
68
|
+
tint = 'dark',
|
|
69
|
+
intensity = 50,
|
|
70
|
+
overlayColor,
|
|
71
|
+
progressive = false,
|
|
72
|
+
style
|
|
73
|
+
}) {
|
|
74
|
+
// intensity 0-100 -> ~0-32px CSS blur, kept in parity with the native scale.
|
|
75
|
+
const blurPx = Math.max(0, Math.min(32, Math.round(intensity * 0.32)));
|
|
76
|
+
const tintColor = overlayColor ?? (tint === 'light' ? DEFAULT_FALLBACK_LIGHT : DEFAULT_FALLBACK_DARK);
|
|
77
|
+
if (progressive) {
|
|
78
|
+
// Full peak blur (parity with native) so the frosted glass is clearly
|
|
79
|
+
// engaged at the bottom; the eased masks keep the top fully clear.
|
|
80
|
+
const peakPx = Math.max(1, Math.min(32, Math.round(intensity * 0.32)));
|
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
82
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
83
|
+
pointerEvents: "none",
|
|
84
|
+
children: PROGRESSIVE_LAYERS.map((layer, i) => {
|
|
85
|
+
const px = Math.max(1, Math.round(peakPx * layer.amount));
|
|
86
|
+
const gradient = toGradient(layer.stops);
|
|
87
|
+
// web-only CSS (backdrop-filter / mask-image); cast because
|
|
88
|
+
// these keys aren't in RN's ViewStyle.
|
|
89
|
+
const webStyle = {
|
|
90
|
+
backdropFilter: `blur(${px}px)`,
|
|
91
|
+
WebkitBackdropFilter: `blur(${px}px)`,
|
|
92
|
+
maskImage: gradient,
|
|
93
|
+
WebkitMaskImage: gradient
|
|
94
|
+
};
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
96
|
+
style: [_reactNative.StyleSheet.absoluteFill, webStyle],
|
|
97
|
+
pointerEvents: "none"
|
|
98
|
+
}, i);
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
103
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
104
|
+
backgroundColor: tintColor
|
|
105
|
+
},
|
|
106
|
+
// backdrop-filter is web-only CSS; ignored by RN on native
|
|
107
|
+
// (we never bundle this file there anyway).
|
|
108
|
+
// @ts-ignore web-only style
|
|
109
|
+
{
|
|
110
|
+
backdropFilter: `blur(${blurPx}px)`,
|
|
111
|
+
WebkitBackdropFilter: `blur(${blurPx}px)`
|
|
112
|
+
}, style],
|
|
113
|
+
pointerEvents: "none"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
var _default = exports.default = GlassFill;
|