@billdog.io/react-native 1.0.0-beta.2
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/BillDogReactNative.podspec +30 -0
- package/LICENSE +21 -0
- package/README.md +330 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogABTestModule.kt +317 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogAnalyticsModule.kt +389 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogModule.kt +817 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogPaywallViewManager.kt +383 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogSurveyModule.kt +427 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogVirtualCurrencyModule.kt +407 -0
- package/android/src/main/kotlin/io/billdog/virtualcurrency/BillDogVirtualCurrencyPackage.kt +44 -0
- package/dist/AdvancedPaywallCache.d.ts +70 -0
- package/dist/AdvancedPaywallCache.js +344 -0
- package/dist/BillDog.d.ts +255 -0
- package/dist/BillDog.js +918 -0
- package/dist/BillDogConfiguration.d.ts +145 -0
- package/dist/BillDogConfiguration.js +229 -0
- package/dist/ComponentRenderer.d.ts +17 -0
- package/dist/ComponentRenderer.js +886 -0
- package/dist/LayoutEngine.d.ts +101 -0
- package/dist/LayoutEngine.js +394 -0
- package/dist/LocalizationResolver.d.ts +99 -0
- package/dist/LocalizationResolver.js +266 -0
- package/dist/NativePaywallView.d.ts +36 -0
- package/dist/NativePaywallView.js +59 -0
- package/dist/PaywallCache.d.ts +74 -0
- package/dist/PaywallCache.js +293 -0
- package/dist/PaywallStateManager.d.ts +62 -0
- package/dist/PaywallStateManager.js +147 -0
- package/dist/PaywallView.d.ts +42 -0
- package/dist/PaywallView.js +275 -0
- package/dist/ProductVariableProvider.d.ts +60 -0
- package/dist/ProductVariableProvider.js +239 -0
- package/dist/VariableResolver.d.ts +120 -0
- package/dist/VariableResolver.js +379 -0
- package/dist/WebViewPaywall.d.ts +75 -0
- package/dist/WebViewPaywall.js +360 -0
- package/dist/animations/presets.d.ts +49 -0
- package/dist/animations/presets.js +367 -0
- package/dist/components/AccoladeCpsComponent.d.ts +13 -0
- package/dist/components/AccoladeCpsComponent.js +248 -0
- package/dist/components/AccordionComponent.d.ts +10 -0
- package/dist/components/AccordionComponent.js +187 -0
- package/dist/components/AnimatedWrapper.d.ts +35 -0
- package/dist/components/AnimatedWrapper.js +277 -0
- package/dist/components/CarouselComponent.d.ts +23 -0
- package/dist/components/CarouselComponent.js +484 -0
- package/dist/components/ChartCurveComponent.d.ts +13 -0
- package/dist/components/ChartCurveComponent.js +333 -0
- package/dist/components/CheckboxComponent.d.ts +9 -0
- package/dist/components/CheckboxComponent.js +172 -0
- package/dist/components/ConfettiComponent.d.ts +9 -0
- package/dist/components/ConfettiComponent.js +172 -0
- package/dist/components/CountdownComponent.d.ts +16 -0
- package/dist/components/CountdownComponent.js +414 -0
- package/dist/components/DelayedXComponent.d.ts +12 -0
- package/dist/components/DelayedXComponent.js +240 -0
- package/dist/components/DrawerModalComponent.d.ts +20 -0
- package/dist/components/DrawerModalComponent.js +286 -0
- package/dist/components/GradientView.d.ts +38 -0
- package/dist/components/GradientView.js +126 -0
- package/dist/components/HapticFeedbackComponent.d.ts +16 -0
- package/dist/components/HapticFeedbackComponent.js +64 -0
- package/dist/components/HorizontalProductsComponent.d.ts +17 -0
- package/dist/components/HorizontalProductsComponent.js +284 -0
- package/dist/components/MultiChoiceGridComponent.d.ts +13 -0
- package/dist/components/MultiChoiceGridComponent.js +234 -0
- package/dist/components/NPSScaleComponent.d.ts +16 -0
- package/dist/components/NPSScaleComponent.js +260 -0
- package/dist/components/NavigationComponent.d.ts +26 -0
- package/dist/components/NavigationComponent.js +302 -0
- package/dist/components/OAuthButtonComponent.d.ts +20 -0
- package/dist/components/OAuthButtonComponent.js +237 -0
- package/dist/components/ProgressLoaderComponent.d.ts +13 -0
- package/dist/components/ProgressLoaderComponent.js +308 -0
- package/dist/components/ProgressStepperComponent.d.ts +18 -0
- package/dist/components/ProgressStepperComponent.js +228 -0
- package/dist/components/SegmentedPickerComponent.d.ts +10 -0
- package/dist/components/SegmentedPickerComponent.js +221 -0
- package/dist/components/ShareButtonsComponent.d.ts +21 -0
- package/dist/components/ShareButtonsComponent.js +265 -0
- package/dist/components/ShareCodeComponent.d.ts +16 -0
- package/dist/components/ShareCodeComponent.js +274 -0
- package/dist/components/SingleChoiceGridComponent.d.ts +13 -0
- package/dist/components/SingleChoiceGridComponent.js +210 -0
- package/dist/components/SliderComponent.d.ts +9 -0
- package/dist/components/SliderComponent.js +263 -0
- package/dist/components/StarRatingInputComponent.d.ts +20 -0
- package/dist/components/StarRatingInputComponent.js +198 -0
- package/dist/components/StickerCompositeComponent.d.ts +13 -0
- package/dist/components/StickerCompositeComponent.js +136 -0
- package/dist/components/TabsComponent.d.ts +19 -0
- package/dist/components/TabsComponent.js +431 -0
- package/dist/components/TextInputComponent.d.ts +18 -0
- package/dist/components/TextInputComponent.js +227 -0
- package/dist/components/TimelineComponent.d.ts +19 -0
- package/dist/components/TimelineComponent.js +104 -0
- package/dist/components/ToggleComponent.d.ts +14 -0
- package/dist/components/ToggleComponent.js +132 -0
- package/dist/components/VerticalProductsComponent.d.ts +17 -0
- package/dist/components/VerticalProductsComponent.js +311 -0
- package/dist/dynamicValues.d.ts +36 -0
- package/dist/dynamicValues.js +142 -0
- package/dist/filters/dateFilters.d.ts +50 -0
- package/dist/filters/dateFilters.js +390 -0
- package/dist/filters/index.d.ts +18 -0
- package/dist/filters/index.js +253 -0
- package/dist/hooks/useOfferings.d.ts +76 -0
- package/dist/hooks/useOfferings.js +99 -0
- package/dist/hooks/usePaywall.d.ts +27 -0
- package/dist/hooks/usePaywall.js +114 -0
- package/dist/hooks/usePlacement.d.ts +34 -0
- package/dist/hooks/usePlacement.js +89 -0
- package/dist/hooks/useSubscription.d.ts +40 -0
- package/dist/hooks/useSubscription.js +97 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +198 -0
- package/dist/models/BillDogError.d.ts +40 -0
- package/dist/models/BillDogError.js +11 -0
- package/dist/models/CacheFetchPolicy.d.ts +8 -0
- package/dist/models/CacheFetchPolicy.js +4 -0
- package/dist/models/CustomProduct.d.ts +32 -0
- package/dist/models/CustomProduct.js +15 -0
- package/dist/models/CustomerInfo.d.ts +17 -0
- package/dist/models/CustomerInfo.js +11 -0
- package/dist/models/Delegate.d.ts +20 -0
- package/dist/models/Delegate.js +11 -0
- package/dist/models/EntitlementInfo.d.ts +19 -0
- package/dist/models/EntitlementInfo.js +2 -0
- package/dist/models/Placement.d.ts +54 -0
- package/dist/models/Placement.js +15 -0
- package/dist/models/PurchaseParams.d.ts +39 -0
- package/dist/models/PurchaseParams.js +60 -0
- package/dist/models/PurchaseResult.d.ts +30 -0
- package/dist/models/PurchaseResult.js +15 -0
- package/dist/models/RestoreResult.d.ts +30 -0
- package/dist/models/RestoreResult.js +22 -0
- package/dist/models/RestoredItem.d.ts +26 -0
- package/dist/models/RestoredItem.js +13 -0
- package/dist/modules/ABTest.d.ts +65 -0
- package/dist/modules/ABTest.js +113 -0
- package/dist/modules/Analytics.d.ts +91 -0
- package/dist/modules/Analytics.js +182 -0
- package/dist/modules/Survey.d.ts +65 -0
- package/dist/modules/Survey.js +82 -0
- package/dist/modules/VirtualCurrency.d.ts +63 -0
- package/dist/modules/VirtualCurrency.js +147 -0
- package/dist/murmur.d.ts +23 -0
- package/dist/murmur.js +104 -0
- package/dist/notifications/LiveActivitiesManager.d.ts +47 -0
- package/dist/notifications/LiveActivitiesManager.js +106 -0
- package/dist/notifications/NotificationScheduler.d.ts +55 -0
- package/dist/notifications/NotificationScheduler.js +199 -0
- package/dist/notifications/PurchaseNotificationHandler.d.ts +24 -0
- package/dist/notifications/PurchaseNotificationHandler.js +55 -0
- package/dist/notifications/useDeviceToken.d.ts +36 -0
- package/dist/notifications/useDeviceToken.js +97 -0
- package/dist/notifications/useLiveActivity.d.ts +39 -0
- package/dist/notifications/useLiveActivity.js +104 -0
- package/dist/review/ReviewAnalytics.d.ts +34 -0
- package/dist/review/ReviewAnalytics.js +73 -0
- package/dist/review/ReviewManager.d.ts +83 -0
- package/dist/review/ReviewManager.js +339 -0
- package/dist/review/ReviewTimingManager.d.ts +82 -0
- package/dist/review/ReviewTimingManager.js +224 -0
- package/dist/survey-core/types.d.ts +215 -0
- package/dist/survey-core/types.js +8 -0
- package/dist/types.d.ts +438 -0
- package/dist/types.js +158 -0
- package/dist/utils/ApiClient.d.ts +65 -0
- package/dist/utils/ApiClient.js +132 -0
- package/dist/utils/CSSConverter.d.ts +49 -0
- package/dist/utils/CSSConverter.js +470 -0
- package/dist/utils/animations.d.ts +41 -0
- package/dist/utils/animations.js +194 -0
- package/dist/utils/calendarIntegration.d.ts +36 -0
- package/dist/utils/calendarIntegration.js +89 -0
- package/dist/utils/configurationResolver.d.ts +23 -0
- package/dist/utils/configurationResolver.js +78 -0
- package/dist/utils/deviceDetection.d.ts +38 -0
- package/dist/utils/deviceDetection.js +59 -0
- package/dist/utils/hapticFeedback.d.ts +17 -0
- package/dist/utils/hapticFeedback.js +53 -0
- package/dist/utils/iconMapper.d.ts +26 -0
- package/dist/utils/iconMapper.js +113 -0
- package/dist/utils/notificationPermissions.d.ts +13 -0
- package/dist/utils/notificationPermissions.js +51 -0
- package/dist/utils/priceFormatting.d.ts +19 -0
- package/dist/utils/priceFormatting.js +99 -0
- package/dist/utils/shareSheet.d.ts +17 -0
- package/dist/utils/shareSheet.js +42 -0
- package/dist/utils/subscriptionUpgrade.d.ts +84 -0
- package/dist/utils/subscriptionUpgrade.js +100 -0
- package/dist/valueUtils.d.ts +48 -0
- package/dist/valueUtils.js +129 -0
- package/dist/xFlowTags.d.ts +18 -0
- package/dist/xFlowTags.js +385 -0
- package/ios/BillDogABTest.m +50 -0
- package/ios/BillDogABTest.swift +188 -0
- package/ios/BillDogAnalytics.m +105 -0
- package/ios/BillDogAnalytics.swift +324 -0
- package/ios/BillDogBridge.m +222 -0
- package/ios/BillDogBridge.swift +715 -0
- package/ios/BillDogLiveActivities.m +41 -0
- package/ios/BillDogLiveActivities.swift +104 -0
- package/ios/BillDogPaywallViewManager.m +39 -0
- package/ios/BillDogPaywallViewManager.swift +361 -0
- package/ios/BillDogSurvey.m +34 -0
- package/ios/BillDogSurvey.swift +257 -0
- package/ios/BillDogVirtualCurrencyBridge.m +63 -0
- package/ios/BillDogVirtualCurrencyBridge.swift +511 -0
- package/junit.xml +25 -0
- package/package.json +61 -0
- package/react-native.config.js +13 -0
- package/src/AdvancedPaywallCache.ts +433 -0
- package/src/BillDog.ts +983 -0
- package/src/BillDogConfiguration.ts +318 -0
- package/src/ComponentRenderer.tsx +1325 -0
- package/src/LayoutEngine.ts +459 -0
- package/src/LocalizationResolver.ts +311 -0
- package/src/NativePaywallView.tsx +132 -0
- package/src/PaywallCache.ts +358 -0
- package/src/PaywallStateManager.ts +154 -0
- package/src/PaywallView.tsx +328 -0
- package/src/ProductVariableProvider.ts +282 -0
- package/src/VariableResolver.ts +516 -0
- package/src/WebViewPaywall.tsx +454 -0
- package/src/animations/presets.ts +421 -0
- package/src/components/AccoladeCpsComponent.tsx +259 -0
- package/src/components/AccordionComponent.tsx +213 -0
- package/src/components/AnimatedWrapper.tsx +316 -0
- package/src/components/CarouselComponent.tsx +615 -0
- package/src/components/ChartCurveComponent.tsx +452 -0
- package/src/components/CheckboxComponent.tsx +185 -0
- package/src/components/ConfettiComponent.tsx +178 -0
- package/src/components/CountdownComponent.tsx +454 -0
- package/src/components/DelayedXComponent.tsx +266 -0
- package/src/components/DrawerModalComponent.tsx +324 -0
- package/src/components/GradientView.tsx +129 -0
- package/src/components/HapticFeedbackComponent.tsx +39 -0
- package/src/components/HorizontalProductsComponent.tsx +329 -0
- package/src/components/MultiChoiceGridComponent.tsx +265 -0
- package/src/components/NPSScaleComponent.tsx +294 -0
- package/src/components/NavigationComponent.tsx +329 -0
- package/src/components/OAuthButtonComponent.tsx +266 -0
- package/src/components/ProgressLoaderComponent.tsx +366 -0
- package/src/components/ProgressStepperComponent.tsx +250 -0
- package/src/components/SegmentedPickerComponent.tsx +245 -0
- package/src/components/ShareButtonsComponent.tsx +299 -0
- package/src/components/ShareCodeComponent.tsx +303 -0
- package/src/components/SingleChoiceGridComponent.tsx +229 -0
- package/src/components/SliderComponent.tsx +280 -0
- package/src/components/StarRatingInputComponent.tsx +223 -0
- package/src/components/StickerCompositeComponent.tsx +168 -0
- package/src/components/TabsComponent.tsx +496 -0
- package/src/components/TextInputComponent.tsx +258 -0
- package/src/components/TimelineComponent.tsx +129 -0
- package/src/components/ToggleComponent.tsx +142 -0
- package/src/components/VerticalProductsComponent.tsx +357 -0
- package/src/dynamicValues.ts +180 -0
- package/src/filters/dateFilters.ts +411 -0
- package/src/filters/index.ts +281 -0
- package/src/hooks/useOfferings.ts +192 -0
- package/src/hooks/usePaywall.ts +154 -0
- package/src/hooks/usePlacement.ts +143 -0
- package/src/hooks/useSubscription.ts +154 -0
- package/src/index.ts +245 -0
- package/src/models/BillDogError.ts +24 -0
- package/src/models/CacheFetchPolicy.ts +13 -0
- package/src/models/CustomProduct.ts +33 -0
- package/src/models/CustomerInfo.ts +26 -0
- package/src/models/Delegate.ts +22 -0
- package/src/models/EntitlementInfo.ts +27 -0
- package/src/models/Placement.ts +50 -0
- package/src/models/PurchaseParams.ts +81 -0
- package/src/models/PurchaseResult.ts +32 -0
- package/src/models/RestoreResult.ts +27 -0
- package/src/models/RestoredItem.ts +25 -0
- package/src/modules/ABTest.ts +131 -0
- package/src/modules/Analytics.ts +227 -0
- package/src/modules/Survey.ts +126 -0
- package/src/modules/VirtualCurrency.ts +223 -0
- package/src/murmur.ts +102 -0
- package/src/notifications/LiveActivitiesManager.ts +140 -0
- package/src/notifications/NotificationScheduler.ts +292 -0
- package/src/notifications/PurchaseNotificationHandler.ts +67 -0
- package/src/notifications/useDeviceToken.ts +116 -0
- package/src/notifications/useLiveActivity.ts +125 -0
- package/src/review/ReviewAnalytics.ts +89 -0
- package/src/review/ReviewManager.ts +355 -0
- package/src/review/ReviewTimingManager.ts +265 -0
- package/src/survey-core/types.ts +244 -0
- package/src/types/ambient.d.ts +9 -0
- package/src/types.ts +680 -0
- package/src/utils/ApiClient.ts +163 -0
- package/src/utils/CSSConverter.ts +552 -0
- package/src/utils/animations.ts +232 -0
- package/src/utils/calendarIntegration.ts +113 -0
- package/src/utils/configurationResolver.ts +106 -0
- package/src/utils/deviceDetection.ts +83 -0
- package/src/utils/hapticFeedback.ts +55 -0
- package/src/utils/iconMapper.ts +102 -0
- package/src/utils/notificationPermissions.ts +48 -0
- package/src/utils/priceFormatting.ts +119 -0
- package/src/utils/shareSheet.ts +55 -0
- package/src/utils/subscriptionUpgrade.ts +183 -0
- package/src/valueUtils.ts +108 -0
- package/src/xFlowTags.ts +463 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SliderComponent = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const SliderComponent = ({ component, stateManager, isPreviewMode = false, }) => {
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
41
|
+
const props = component.properties;
|
|
42
|
+
const minValue = (_a = props.minValue) !== null && _a !== void 0 ? _a : 0;
|
|
43
|
+
const maxValue = (_b = props.maxValue) !== null && _b !== void 0 ? _b : 100;
|
|
44
|
+
const step = (_c = props.step) !== null && _c !== void 0 ? _c : 1;
|
|
45
|
+
const defaultValue = (_d = props.defaultValue) !== null && _d !== void 0 ? _d : minValue;
|
|
46
|
+
const disabled = (_e = props.disabled) !== null && _e !== void 0 ? _e : false;
|
|
47
|
+
const showValue = props.showValue !== false;
|
|
48
|
+
const label = props.sliderLabel || props.label;
|
|
49
|
+
const valuePrefix = (_f = props.valuePrefix) !== null && _f !== void 0 ? _f : '';
|
|
50
|
+
const valueSuffix = (_g = props.valueSuffix) !== null && _g !== void 0 ? _g : '';
|
|
51
|
+
// Colors
|
|
52
|
+
const activeColor = (_h = props.activeColor) !== null && _h !== void 0 ? _h : '#007AFF';
|
|
53
|
+
const trackColor = (_j = props.trackColor) !== null && _j !== void 0 ? _j : '#e0e0e0';
|
|
54
|
+
const thumbColor = (_k = props.thumbColor) !== null && _k !== void 0 ? _k : activeColor;
|
|
55
|
+
const [currentValue, setCurrentValue] = (0, react_1.useState)(defaultValue);
|
|
56
|
+
const [trackWidth, setTrackWidth] = (0, react_1.useState)(0);
|
|
57
|
+
const animatedValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
58
|
+
const isDragging = (0, react_1.useRef)(false);
|
|
59
|
+
// Calculate value from position
|
|
60
|
+
const positionToValue = (0, react_1.useCallback)((position) => {
|
|
61
|
+
if (trackWidth === 0)
|
|
62
|
+
return minValue;
|
|
63
|
+
const ratio = Math.max(0, Math.min(1, position / trackWidth));
|
|
64
|
+
const rawValue = minValue + ratio * (maxValue - minValue);
|
|
65
|
+
// Apply step
|
|
66
|
+
const steppedValue = Math.round(rawValue / step) * step;
|
|
67
|
+
return Math.max(minValue, Math.min(maxValue, steppedValue));
|
|
68
|
+
}, [trackWidth, minValue, maxValue, step]);
|
|
69
|
+
// Calculate position from value
|
|
70
|
+
const valueToPosition = (0, react_1.useCallback)((value) => {
|
|
71
|
+
if (maxValue === minValue)
|
|
72
|
+
return 0;
|
|
73
|
+
const ratio = (value - minValue) / (maxValue - minValue);
|
|
74
|
+
return ratio * trackWidth;
|
|
75
|
+
}, [trackWidth, minValue, maxValue]);
|
|
76
|
+
// Update animated value when currentValue or trackWidth changes
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
const position = valueToPosition(currentValue);
|
|
79
|
+
animatedValue.setValue(position);
|
|
80
|
+
}, [currentValue, trackWidth, valueToPosition, animatedValue]);
|
|
81
|
+
// Register initial state
|
|
82
|
+
(0, react_1.useEffect)(() => {
|
|
83
|
+
if (stateManager) {
|
|
84
|
+
stateManager.updateState(`element:${component.id}.currentValue`, currentValue);
|
|
85
|
+
}
|
|
86
|
+
}, []);
|
|
87
|
+
// Subscribe to external state changes
|
|
88
|
+
(0, react_1.useEffect)(() => {
|
|
89
|
+
if (stateManager) {
|
|
90
|
+
return stateManager.subscribeToState(`element:${component.id}.currentValue`, (value) => {
|
|
91
|
+
if (value !== currentValue && !isDragging.current) {
|
|
92
|
+
setCurrentValue(value);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}, [component.id, stateManager, currentValue]);
|
|
97
|
+
// Pan responder for drag handling
|
|
98
|
+
const panResponder = (0, react_1.useRef)(react_native_1.PanResponder.create({
|
|
99
|
+
onStartShouldSetPanResponder: () => !disabled,
|
|
100
|
+
onMoveShouldSetPanResponder: () => !disabled,
|
|
101
|
+
onPanResponderGrant: (_, gestureState) => {
|
|
102
|
+
isDragging.current = true;
|
|
103
|
+
// Calculate initial position from touch
|
|
104
|
+
const touchX = gestureState.x0;
|
|
105
|
+
// This needs adjustment based on actual component position
|
|
106
|
+
},
|
|
107
|
+
onPanResponderMove: (_, gestureState) => {
|
|
108
|
+
if (disabled || trackWidth === 0)
|
|
109
|
+
return;
|
|
110
|
+
// Calculate new position based on accumulated movement
|
|
111
|
+
const currentPosition = valueToPosition(currentValue);
|
|
112
|
+
const newPosition = Math.max(0, Math.min(trackWidth, currentPosition + gestureState.dx));
|
|
113
|
+
const newValue = positionToValue(newPosition);
|
|
114
|
+
if (newValue !== currentValue) {
|
|
115
|
+
setCurrentValue(newValue);
|
|
116
|
+
animatedValue.setValue(newPosition);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
onPanResponderRelease: () => {
|
|
120
|
+
isDragging.current = false;
|
|
121
|
+
// Update state manager on release
|
|
122
|
+
if (stateManager) {
|
|
123
|
+
stateManager.updateState(`element:${component.id}.currentValue`, currentValue);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
onPanResponderTerminate: () => {
|
|
127
|
+
isDragging.current = false;
|
|
128
|
+
},
|
|
129
|
+
})).current;
|
|
130
|
+
// Handle track layout
|
|
131
|
+
const onTrackLayout = (event) => {
|
|
132
|
+
const { width } = event.nativeEvent.layout;
|
|
133
|
+
setTrackWidth(width);
|
|
134
|
+
};
|
|
135
|
+
// Handle direct tap on track
|
|
136
|
+
const handleTrackPress = (event) => {
|
|
137
|
+
if (disabled || trackWidth === 0)
|
|
138
|
+
return;
|
|
139
|
+
const touchX = event.nativeEvent.locationX;
|
|
140
|
+
const newValue = positionToValue(touchX);
|
|
141
|
+
setCurrentValue(newValue);
|
|
142
|
+
if (stateManager) {
|
|
143
|
+
stateManager.updateState(`element:${component.id}.currentValue`, newValue);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const formatValue = (value) => {
|
|
147
|
+
if (step >= 1) {
|
|
148
|
+
return Math.round(value).toString();
|
|
149
|
+
}
|
|
150
|
+
else if (step >= 0.1) {
|
|
151
|
+
return value.toFixed(1);
|
|
152
|
+
}
|
|
153
|
+
return value.toFixed(2);
|
|
154
|
+
};
|
|
155
|
+
// Calculate progress percentage
|
|
156
|
+
const progress = trackWidth > 0 ? ((currentValue - minValue) / (maxValue - minValue)) * 100 : 0;
|
|
157
|
+
return (<react_native_1.View style={[styles.container, disabled && styles.disabled]}>
|
|
158
|
+
{(label || showValue) && (<react_native_1.View style={styles.header}>
|
|
159
|
+
{label && <react_native_1.Text style={styles.label}>{label}</react_native_1.Text>}
|
|
160
|
+
{showValue && (<react_native_1.Text style={styles.value}>
|
|
161
|
+
{valuePrefix}{formatValue(currentValue)}{valueSuffix}
|
|
162
|
+
</react_native_1.Text>)}
|
|
163
|
+
</react_native_1.View>)}
|
|
164
|
+
|
|
165
|
+
<react_native_1.View style={styles.sliderContainer} onStartShouldSetResponder={() => !disabled} onResponderGrant={handleTrackPress} {...panResponder.panHandlers}>
|
|
166
|
+
<react_native_1.View style={[styles.track, { backgroundColor: trackColor }]} onLayout={onTrackLayout}>
|
|
167
|
+
<react_native_1.Animated.View style={[
|
|
168
|
+
styles.fill,
|
|
169
|
+
{
|
|
170
|
+
backgroundColor: activeColor,
|
|
171
|
+
width: animatedValue.interpolate({
|
|
172
|
+
inputRange: [0, trackWidth || 1],
|
|
173
|
+
outputRange: ['0%', '100%'],
|
|
174
|
+
extrapolate: 'clamp',
|
|
175
|
+
}),
|
|
176
|
+
}
|
|
177
|
+
]}/>
|
|
178
|
+
</react_native_1.View>
|
|
179
|
+
<react_native_1.Animated.View style={[
|
|
180
|
+
styles.thumb,
|
|
181
|
+
{
|
|
182
|
+
backgroundColor: thumbColor,
|
|
183
|
+
transform: [{
|
|
184
|
+
translateX: animatedValue.interpolate({
|
|
185
|
+
inputRange: [0, trackWidth || 1],
|
|
186
|
+
outputRange: [0, trackWidth || 0],
|
|
187
|
+
extrapolate: 'clamp',
|
|
188
|
+
}),
|
|
189
|
+
}],
|
|
190
|
+
}
|
|
191
|
+
]}/>
|
|
192
|
+
</react_native_1.View>
|
|
193
|
+
|
|
194
|
+
<react_native_1.View style={styles.rangeLabels}>
|
|
195
|
+
<react_native_1.Text style={styles.rangeLabel}>{minValue}</react_native_1.Text>
|
|
196
|
+
<react_native_1.Text style={styles.rangeLabel}>{maxValue}</react_native_1.Text>
|
|
197
|
+
</react_native_1.View>
|
|
198
|
+
</react_native_1.View>);
|
|
199
|
+
};
|
|
200
|
+
exports.SliderComponent = SliderComponent;
|
|
201
|
+
const styles = react_native_1.StyleSheet.create({
|
|
202
|
+
container: {
|
|
203
|
+
width: '100%',
|
|
204
|
+
paddingVertical: 8,
|
|
205
|
+
},
|
|
206
|
+
disabled: {
|
|
207
|
+
opacity: 0.5,
|
|
208
|
+
},
|
|
209
|
+
header: {
|
|
210
|
+
flexDirection: 'row',
|
|
211
|
+
justifyContent: 'space-between',
|
|
212
|
+
alignItems: 'center',
|
|
213
|
+
marginBottom: 12,
|
|
214
|
+
},
|
|
215
|
+
label: {
|
|
216
|
+
fontSize: 16,
|
|
217
|
+
fontWeight: '500',
|
|
218
|
+
color: '#333',
|
|
219
|
+
},
|
|
220
|
+
value: {
|
|
221
|
+
fontSize: 16,
|
|
222
|
+
fontWeight: '600',
|
|
223
|
+
color: '#007AFF',
|
|
224
|
+
},
|
|
225
|
+
sliderContainer: {
|
|
226
|
+
height: 44,
|
|
227
|
+
justifyContent: 'center',
|
|
228
|
+
paddingHorizontal: 10, // Padding for thumb
|
|
229
|
+
},
|
|
230
|
+
track: {
|
|
231
|
+
height: 6,
|
|
232
|
+
borderRadius: 3,
|
|
233
|
+
overflow: 'hidden',
|
|
234
|
+
},
|
|
235
|
+
fill: {
|
|
236
|
+
height: '100%',
|
|
237
|
+
borderRadius: 3,
|
|
238
|
+
},
|
|
239
|
+
thumb: {
|
|
240
|
+
position: 'absolute',
|
|
241
|
+
width: 24,
|
|
242
|
+
height: 24,
|
|
243
|
+
borderRadius: 12,
|
|
244
|
+
marginLeft: -2, // Center thumb on track edge
|
|
245
|
+
shadowColor: '#000',
|
|
246
|
+
shadowOffset: { width: 0, height: 2 },
|
|
247
|
+
shadowOpacity: 0.25,
|
|
248
|
+
shadowRadius: 4,
|
|
249
|
+
elevation: 4,
|
|
250
|
+
borderWidth: 2,
|
|
251
|
+
borderColor: '#fff',
|
|
252
|
+
},
|
|
253
|
+
rangeLabels: {
|
|
254
|
+
flexDirection: 'row',
|
|
255
|
+
justifyContent: 'space-between',
|
|
256
|
+
marginTop: 8,
|
|
257
|
+
paddingHorizontal: 4,
|
|
258
|
+
},
|
|
259
|
+
rangeLabel: {
|
|
260
|
+
fontSize: 12,
|
|
261
|
+
color: '#999',
|
|
262
|
+
},
|
|
263
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StarRatingInputComponent - React Native
|
|
3
|
+
*
|
|
4
|
+
* Interactive star rating with customizable appearance.
|
|
5
|
+
* Features:
|
|
6
|
+
* - Configurable max stars
|
|
7
|
+
* - Half-star support
|
|
8
|
+
* - State manager integration
|
|
9
|
+
* - Animated feedback
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { PaywallComponent } from '../types';
|
|
13
|
+
interface StarRatingInputComponentProps {
|
|
14
|
+
component: PaywallComponent;
|
|
15
|
+
stateManager?: any;
|
|
16
|
+
isPreviewMode?: boolean;
|
|
17
|
+
renderComponent?: (component: PaywallComponent) => React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const StarRatingInputComponent: React.FC<StarRatingInputComponentProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* StarRatingInputComponent - React Native
|
|
4
|
+
*
|
|
5
|
+
* Interactive star rating with customizable appearance.
|
|
6
|
+
* Features:
|
|
7
|
+
* - Configurable max stars
|
|
8
|
+
* - Half-star support
|
|
9
|
+
* - State manager integration
|
|
10
|
+
* - Animated feedback
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.StarRatingInputComponent = void 0;
|
|
47
|
+
const react_1 = __importStar(require("react"));
|
|
48
|
+
const react_native_1 = require("react-native");
|
|
49
|
+
const StarRatingInputComponent = ({ component, stateManager, isPreviewMode = false, renderComponent, }) => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
51
|
+
const props = component.properties;
|
|
52
|
+
const componentId = component.id;
|
|
53
|
+
// Rating configuration
|
|
54
|
+
const maxStars = (_a = props.maxStars) !== null && _a !== void 0 ? _a : 5;
|
|
55
|
+
const defaultRating = Math.min(Math.max((_b = props.defaultRating) !== null && _b !== void 0 ? _b : 0, 0), maxStars);
|
|
56
|
+
const allowHalfStars = (_c = props.allowHalfStars) !== null && _c !== void 0 ? _c : false;
|
|
57
|
+
const allowZeroRating = (_d = props.allowZeroRating) !== null && _d !== void 0 ? _d : true;
|
|
58
|
+
const disabled = (_e = props.disabled) !== null && _e !== void 0 ? _e : false;
|
|
59
|
+
const tapSameToDeselect = (_f = props.tapSameToDeselect) !== null && _f !== void 0 ? _f : true;
|
|
60
|
+
// Label configuration
|
|
61
|
+
const showLabel = (_g = props.showLabel) !== null && _g !== void 0 ? _g : true;
|
|
62
|
+
const labelText = (_h = props.labelText) !== null && _h !== void 0 ? _h : 'Rate your experience';
|
|
63
|
+
const labelFontSize = (_k = (_j = props.labelFontSize) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : 16;
|
|
64
|
+
const labelFontWeight = (_l = props.labelFontWeight) !== null && _l !== void 0 ? _l : '600';
|
|
65
|
+
const labelTextColor = (_m = props.labelTextColor) !== null && _m !== void 0 ? _m : '#1F2937';
|
|
66
|
+
// Star appearance
|
|
67
|
+
const starSize = (_o = props.starSize) !== null && _o !== void 0 ? _o : 32;
|
|
68
|
+
const starSpacing = (_p = props.starSpacing) !== null && _p !== void 0 ? _p : 4;
|
|
69
|
+
const activeColor = (_q = props.activeColor) !== null && _q !== void 0 ? _q : '#FFD700';
|
|
70
|
+
const inactiveColor = (_r = props.inactiveColor) !== null && _r !== void 0 ? _r : '#D1D5DB';
|
|
71
|
+
// Display options
|
|
72
|
+
const showRatingText = (_s = props.showRatingText) !== null && _s !== void 0 ? _s : true;
|
|
73
|
+
const ratingTextFormat = (_t = props.ratingTextFormat) !== null && _t !== void 0 ? _t : 'fraction';
|
|
74
|
+
const ratingTextFontSize = (_v = (_u = props.ratingTextFontSize) === null || _u === void 0 ? void 0 : _u.value) !== null && _v !== void 0 ? _v : 14;
|
|
75
|
+
const ratingTextColor = (_w = props.ratingTextColor) !== null && _w !== void 0 ? _w : '#6B7280';
|
|
76
|
+
const [currentRating, setCurrentRating] = (0, react_1.useState)(defaultRating);
|
|
77
|
+
const [animatedScales] = (0, react_1.useState)(() => Array.from({ length: maxStars }, () => new react_native_1.Animated.Value(1)));
|
|
78
|
+
// Connect to state manager
|
|
79
|
+
(0, react_1.useEffect)(() => {
|
|
80
|
+
if (stateManager) {
|
|
81
|
+
// Subscribe to external changes
|
|
82
|
+
return stateManager.subscribeToState(`element:${componentId}.rating`, (value) => {
|
|
83
|
+
if (value !== currentRating) {
|
|
84
|
+
setCurrentRating(value);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [componentId, stateManager, currentRating]);
|
|
89
|
+
// Update state manager when rating changes
|
|
90
|
+
(0, react_1.useEffect)(() => {
|
|
91
|
+
if (stateManager) {
|
|
92
|
+
stateManager.updateState(`element:${componentId}.rating`, currentRating);
|
|
93
|
+
}
|
|
94
|
+
}, [componentId, currentRating, stateManager]);
|
|
95
|
+
// Handle star press
|
|
96
|
+
const handleStarPress = (0, react_1.useCallback)((starIndex) => {
|
|
97
|
+
if (disabled)
|
|
98
|
+
return;
|
|
99
|
+
let newRating = starIndex + 1;
|
|
100
|
+
// Tap same to deselect
|
|
101
|
+
if (tapSameToDeselect && newRating === currentRating) {
|
|
102
|
+
newRating = allowZeroRating ? 0 : 1;
|
|
103
|
+
}
|
|
104
|
+
// Clamp rating
|
|
105
|
+
newRating = Math.max(allowZeroRating ? 0 : 1, Math.min(maxStars, newRating));
|
|
106
|
+
// Animate the star
|
|
107
|
+
react_native_1.Animated.sequence([
|
|
108
|
+
react_native_1.Animated.timing(animatedScales[starIndex], {
|
|
109
|
+
toValue: 1.3,
|
|
110
|
+
duration: 100,
|
|
111
|
+
useNativeDriver: true,
|
|
112
|
+
}),
|
|
113
|
+
react_native_1.Animated.timing(animatedScales[starIndex], {
|
|
114
|
+
toValue: 1,
|
|
115
|
+
duration: 100,
|
|
116
|
+
useNativeDriver: true,
|
|
117
|
+
}),
|
|
118
|
+
]).start();
|
|
119
|
+
setCurrentRating(newRating);
|
|
120
|
+
}, [disabled, tapSameToDeselect, currentRating, allowZeroRating, maxStars, animatedScales]);
|
|
121
|
+
// Format rating text
|
|
122
|
+
const formatRatingText = (0, react_1.useCallback)(() => {
|
|
123
|
+
switch (ratingTextFormat) {
|
|
124
|
+
case 'written':
|
|
125
|
+
return `${currentRating} of ${maxStars}`;
|
|
126
|
+
case 'stars':
|
|
127
|
+
return `${currentRating} ${currentRating === 1 ? 'star' : 'stars'}`;
|
|
128
|
+
case 'percentage':
|
|
129
|
+
return `${Math.round((currentRating / maxStars) * 100)}%`;
|
|
130
|
+
case 'fraction':
|
|
131
|
+
default:
|
|
132
|
+
return `${currentRating}/${maxStars}`;
|
|
133
|
+
}
|
|
134
|
+
}, [currentRating, maxStars, ratingTextFormat]);
|
|
135
|
+
return (<react_native_1.View style={[styles.container, disabled && styles.disabled]}>
|
|
136
|
+
{/* Label */}
|
|
137
|
+
{showLabel && labelText && (<react_native_1.Text style={[
|
|
138
|
+
styles.label,
|
|
139
|
+
{
|
|
140
|
+
fontSize: labelFontSize,
|
|
141
|
+
fontWeight: labelFontWeight,
|
|
142
|
+
color: labelTextColor,
|
|
143
|
+
},
|
|
144
|
+
]}>
|
|
145
|
+
{labelText}
|
|
146
|
+
</react_native_1.Text>)}
|
|
147
|
+
|
|
148
|
+
{/* Stars Row */}
|
|
149
|
+
<react_native_1.View style={[styles.starsRow, { gap: starSpacing }]}>
|
|
150
|
+
{Array.from({ length: maxStars }, (_, index) => {
|
|
151
|
+
const isFilled = index < currentRating;
|
|
152
|
+
return (<react_native_1.TouchableOpacity key={index} onPress={() => handleStarPress(index)} disabled={disabled} activeOpacity={0.7}>
|
|
153
|
+
<react_native_1.Animated.View style={{
|
|
154
|
+
transform: [{ scale: animatedScales[index] }],
|
|
155
|
+
}}>
|
|
156
|
+
<react_native_1.Text style={{
|
|
157
|
+
fontSize: starSize,
|
|
158
|
+
color: isFilled ? activeColor : inactiveColor,
|
|
159
|
+
}}>
|
|
160
|
+
★
|
|
161
|
+
</react_native_1.Text>
|
|
162
|
+
</react_native_1.Animated.View>
|
|
163
|
+
</react_native_1.TouchableOpacity>);
|
|
164
|
+
})}
|
|
165
|
+
</react_native_1.View>
|
|
166
|
+
|
|
167
|
+
{/* Rating Text */}
|
|
168
|
+
{showRatingText && (<react_native_1.Text style={[
|
|
169
|
+
styles.ratingText,
|
|
170
|
+
{
|
|
171
|
+
fontSize: ratingTextFontSize,
|
|
172
|
+
color: ratingTextColor,
|
|
173
|
+
},
|
|
174
|
+
]}>
|
|
175
|
+
{formatRatingText()}
|
|
176
|
+
</react_native_1.Text>)}
|
|
177
|
+
</react_native_1.View>);
|
|
178
|
+
};
|
|
179
|
+
exports.StarRatingInputComponent = StarRatingInputComponent;
|
|
180
|
+
const styles = react_native_1.StyleSheet.create({
|
|
181
|
+
container: {
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
gap: 12,
|
|
184
|
+
},
|
|
185
|
+
disabled: {
|
|
186
|
+
opacity: 0.5,
|
|
187
|
+
},
|
|
188
|
+
label: {
|
|
189
|
+
textAlign: 'center',
|
|
190
|
+
},
|
|
191
|
+
starsRow: {
|
|
192
|
+
flexDirection: 'row',
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
},
|
|
195
|
+
ratingText: {
|
|
196
|
+
textAlign: 'center',
|
|
197
|
+
},
|
|
198
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StickerCompositeComponent - Native React Native implementation
|
|
3
|
+
* Positioned overlay sticker with rotation, icons, images, and text
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PaywallComponent } from '../types';
|
|
7
|
+
interface StickerCompositeComponentProps {
|
|
8
|
+
component: PaywallComponent;
|
|
9
|
+
stateManager?: any;
|
|
10
|
+
isPreviewMode?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const StickerCompositeComponent: React.FC<StickerCompositeComponentProps>;
|
|
13
|
+
export default StickerCompositeComponent;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* StickerCompositeComponent - Native React Native implementation
|
|
4
|
+
* Positioned overlay sticker with rotation, icons, images, and text
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StickerCompositeComponent = void 0;
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const react_native_1 = require("react-native");
|
|
13
|
+
// Icon mapping for common icon names
|
|
14
|
+
const ICON_MAP = {
|
|
15
|
+
star: '⭐',
|
|
16
|
+
heart: '❤️',
|
|
17
|
+
fire: '🔥',
|
|
18
|
+
check: '✅',
|
|
19
|
+
crown: '👑',
|
|
20
|
+
lightning: '⚡',
|
|
21
|
+
trophy: '🏆',
|
|
22
|
+
diamond: '💎',
|
|
23
|
+
rocket: '🚀',
|
|
24
|
+
gift: '🎁',
|
|
25
|
+
medal: '🏅',
|
|
26
|
+
sparkle: '✨',
|
|
27
|
+
thumbsup: '👍',
|
|
28
|
+
badge: '🏷️',
|
|
29
|
+
};
|
|
30
|
+
const getColorFromValue = (value, fallback) => {
|
|
31
|
+
if (!value)
|
|
32
|
+
return fallback;
|
|
33
|
+
if (typeof value === 'string')
|
|
34
|
+
return value;
|
|
35
|
+
if (typeof value === 'object' && value.color)
|
|
36
|
+
return value.color;
|
|
37
|
+
return fallback;
|
|
38
|
+
};
|
|
39
|
+
const StickerCompositeComponent = ({ component, stateManager, isPreviewMode = false, }) => {
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
|
+
const props = component.properties;
|
|
42
|
+
// Properties
|
|
43
|
+
const imageUrl = props.imageUrl;
|
|
44
|
+
const iconName = props.iconName;
|
|
45
|
+
const text = props.text;
|
|
46
|
+
const rotation = props.rotation || 0;
|
|
47
|
+
const backgroundColor = getColorFromValue(props.backgroundColor, '#FFEB3B');
|
|
48
|
+
const borderRadius = (_a = props.borderRadius) !== null && _a !== void 0 ? _a : 8;
|
|
49
|
+
const borderColor = props.borderColor ? getColorFromValue(props.borderColor, 'transparent') : undefined;
|
|
50
|
+
const borderWidth = (_b = props.borderWidth) !== null && _b !== void 0 ? _b : 0;
|
|
51
|
+
const shadowColor = props.shadowColor ? getColorFromValue(props.shadowColor, 'rgba(0,0,0,0.2)') : undefined;
|
|
52
|
+
const shadowBlur = (_c = props.shadowBlur) !== null && _c !== void 0 ? _c : 8;
|
|
53
|
+
const paddingHorizontal = (_d = props.paddingHorizontal) !== null && _d !== void 0 ? _d : 16;
|
|
54
|
+
const paddingVertical = (_e = props.paddingVertical) !== null && _e !== void 0 ? _e : 8;
|
|
55
|
+
const fontSize = (_f = props.fontSize) !== null && _f !== void 0 ? _f : 14;
|
|
56
|
+
const textColor = getColorFromValue(props.textColor, '#000000');
|
|
57
|
+
const fontWeight = (_g = props.fontWeight) !== null && _g !== void 0 ? _g : '600';
|
|
58
|
+
const iconSize = (_h = props.iconSize) !== null && _h !== void 0 ? _h : 24;
|
|
59
|
+
const iconColor = props.iconColor ? getColorFromValue(props.iconColor, textColor) : textColor;
|
|
60
|
+
// Get icon emoji
|
|
61
|
+
const iconEmoji = iconName ? ICON_MAP[iconName.toLowerCase()] || '🏷️' : null;
|
|
62
|
+
// Build content
|
|
63
|
+
const hasIcon = !!iconEmoji;
|
|
64
|
+
const hasImage = !!imageUrl;
|
|
65
|
+
const hasText = !!text;
|
|
66
|
+
if (!hasIcon && !hasImage && !hasText) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return (<react_native_1.View style={[
|
|
70
|
+
styles.container,
|
|
71
|
+
{
|
|
72
|
+
transform: [{ rotate: `${rotation}deg` }],
|
|
73
|
+
backgroundColor,
|
|
74
|
+
borderRadius,
|
|
75
|
+
paddingHorizontal,
|
|
76
|
+
paddingVertical,
|
|
77
|
+
...(borderColor && borderWidth > 0 && {
|
|
78
|
+
borderColor,
|
|
79
|
+
borderWidth,
|
|
80
|
+
}),
|
|
81
|
+
...(shadowColor && {
|
|
82
|
+
shadowColor,
|
|
83
|
+
shadowOffset: { width: 2, height: 2 },
|
|
84
|
+
shadowOpacity: 0.3,
|
|
85
|
+
shadowRadius: shadowBlur / 2,
|
|
86
|
+
elevation: 4,
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
]}>
|
|
90
|
+
{/* Icon */}
|
|
91
|
+
{hasIcon && (<react_native_1.Text style={[styles.icon, { fontSize: iconSize }]}>
|
|
92
|
+
{iconEmoji}
|
|
93
|
+
</react_native_1.Text>)}
|
|
94
|
+
|
|
95
|
+
{/* Image */}
|
|
96
|
+
{hasImage && (<react_native_1.Image source={{ uri: imageUrl }} style={[
|
|
97
|
+
styles.image,
|
|
98
|
+
{
|
|
99
|
+
width: iconSize,
|
|
100
|
+
height: iconSize,
|
|
101
|
+
borderRadius: borderRadius / 2,
|
|
102
|
+
},
|
|
103
|
+
]} resizeMode="cover"/>)}
|
|
104
|
+
|
|
105
|
+
{/* Text */}
|
|
106
|
+
{hasText && (<react_native_1.Text style={[
|
|
107
|
+
styles.text,
|
|
108
|
+
{
|
|
109
|
+
fontSize,
|
|
110
|
+
color: textColor,
|
|
111
|
+
fontWeight: fontWeight,
|
|
112
|
+
marginLeft: (hasIcon || hasImage) ? 8 : 0,
|
|
113
|
+
},
|
|
114
|
+
]}>
|
|
115
|
+
{text}
|
|
116
|
+
</react_native_1.Text>)}
|
|
117
|
+
</react_native_1.View>);
|
|
118
|
+
};
|
|
119
|
+
exports.StickerCompositeComponent = StickerCompositeComponent;
|
|
120
|
+
const styles = react_native_1.StyleSheet.create({
|
|
121
|
+
container: {
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
alignSelf: 'flex-start',
|
|
125
|
+
},
|
|
126
|
+
icon: {
|
|
127
|
+
textAlign: 'center',
|
|
128
|
+
},
|
|
129
|
+
image: {
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
},
|
|
132
|
+
text: {
|
|
133
|
+
textAlign: 'center',
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
exports.default = exports.StickerCompositeComponent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TabsComponent - Interactive tabs for React Native
|
|
3
|
+
* Uses element:{id}.currentIndex for state tracking (Superwall pattern)
|
|
4
|
+
* Full property support matching web schema for cross-platform consistency
|
|
5
|
+
* Phase 2 Enhanced: icon support, alignment, sizing, disabled state, animation duration, overflow
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { PaywallComponent } from '../types';
|
|
9
|
+
interface TabsComponentProps {
|
|
10
|
+
component: PaywallComponent;
|
|
11
|
+
/** Child components to render within the tabs (defaults to component.children) */
|
|
12
|
+
children?: PaywallComponent[];
|
|
13
|
+
renderChild: (child: PaywallComponent, index: number) => React.ReactNode;
|
|
14
|
+
stateManager?: any;
|
|
15
|
+
isPreviewMode?: boolean;
|
|
16
|
+
onTabChange?: (componentId: string, previousIndex: number, newIndex: number, tabLabel: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const TabsComponent: React.FC<TabsComponentProps>;
|
|
19
|
+
export {};
|