zkit-ui 1.0.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/README.md +267 -0
- package/dist/ComponentLibProvider.d.ts +15 -0
- package/dist/ComponentLibProvider.d.ts.map +1 -0
- package/dist/ComponentLibProvider.js +18 -0
- package/dist/assets/animations/spinner.json +1 -0
- package/dist/assets/icons/check.svg +4 -0
- package/dist/assets/icons/toast/error.webp +0 -0
- package/dist/assets/icons/toast/success.webp +0 -0
- package/dist/assets/icons/toast/warning.webp +0 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +42 -0
- package/dist/i18n/I18nProvider.d.ts +11 -0
- package/dist/i18n/I18nProvider.d.ts.map +1 -0
- package/dist/i18n/I18nProvider.js +84 -0
- package/dist/i18n/locale.d.ts +7 -0
- package/dist/i18n/locale.d.ts.map +1 -0
- package/dist/i18n/locale.js +87 -0
- package/dist/i18n/locales/de.d.ts +51 -0
- package/dist/i18n/locales/de.d.ts.map +1 -0
- package/dist/i18n/locales/de.js +62 -0
- package/dist/i18n/locales/en-US.d.ts +51 -0
- package/dist/i18n/locales/en-US.d.ts.map +1 -0
- package/dist/i18n/locales/en-US.js +62 -0
- package/dist/i18n/locales/index.d.ts +9 -0
- package/dist/i18n/locales/index.d.ts.map +1 -0
- package/dist/i18n/locales/index.js +23 -0
- package/dist/i18n/locales/ja.d.ts +51 -0
- package/dist/i18n/locales/ja.d.ts.map +1 -0
- package/dist/i18n/locales/ja.js +62 -0
- package/dist/i18n/locales/zh-CN.d.ts +51 -0
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -0
- package/dist/i18n/locales/zh-CN.js +62 -0
- package/dist/i18n/locales/zh-TW.d.ts +51 -0
- package/dist/i18n/locales/zh-TW.d.ts.map +1 -0
- package/dist/i18n/locales/zh-TW.js +62 -0
- package/dist/i18n/types.d.ts +11 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/useI18n.d.ts +2 -0
- package/dist/i18n/useI18n.d.ts.map +1 -0
- package/dist/i18n/useI18n.js +41 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +90 -0
- package/dist/services/ActionDialogService/ActionDialog.d.ts +4 -0
- package/dist/services/ActionDialogService/ActionDialog.d.ts.map +1 -0
- package/dist/services/ActionDialogService/ActionDialog.js +531 -0
- package/dist/services/ActionDialogService/index.d.ts +4 -0
- package/dist/services/ActionDialogService/index.d.ts.map +1 -0
- package/dist/services/ActionDialogService/index.js +8 -0
- package/dist/services/ActionDialogService/service.d.ts +7 -0
- package/dist/services/ActionDialogService/service.d.ts.map +1 -0
- package/dist/services/ActionDialogService/service.js +309 -0
- package/dist/services/ActionDialogService/shared.d.ts +17 -0
- package/dist/services/ActionDialogService/shared.d.ts.map +1 -0
- package/dist/services/ActionDialogService/shared.js +167 -0
- package/dist/services/ActionDialogService/types.d.ts +160 -0
- package/dist/services/ActionDialogService/types.d.ts.map +1 -0
- package/dist/services/ActionDialogService/types.js +2 -0
- package/dist/services/CardToastService/index.d.ts +115 -0
- package/dist/services/CardToastService/index.d.ts.map +1 -0
- package/dist/services/CardToastService/index.js +899 -0
- package/dist/services/ImagePreviewService/index.d.ts +179 -0
- package/dist/services/ImagePreviewService/index.d.ts.map +1 -0
- package/dist/services/ImagePreviewService/index.js +1383 -0
- package/dist/services/LoadingService/index.d.ts +146 -0
- package/dist/services/LoadingService/index.d.ts.map +1 -0
- package/dist/services/LoadingService/index.js +827 -0
- package/dist/services/PermissionPurposeDialogService/index.d.ts +99 -0
- package/dist/services/PermissionPurposeDialogService/index.d.ts.map +1 -0
- package/dist/services/PermissionPurposeDialogService/index.js +360 -0
- package/dist/services/PickerService/index.d.ts +128 -0
- package/dist/services/PickerService/index.d.ts.map +1 -0
- package/dist/services/PickerService/index.js +250 -0
- package/dist/theme/ThemeProvider.d.ts +15 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +61 -0
- package/dist/theme/defaultTheme.d.ts +3 -0
- package/dist/theme/defaultTheme.d.ts.map +1 -0
- package/dist/theme/defaultTheme.js +28 -0
- package/dist/theme/mergeTheme.d.ts +3 -0
- package/dist/theme/mergeTheme.d.ts.map +1 -0
- package/dist/theme/mergeTheme.js +19 -0
- package/dist/theme/types.d.ts +17 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +2 -0
- package/dist/theme/useTheme.d.ts +2 -0
- package/dist/theme/useTheme.d.ts.map +1 -0
- package/dist/theme/useTheme.js +46 -0
- package/dist/ui/Accordion/index.d.ts +99 -0
- package/dist/ui/Accordion/index.d.ts.map +1 -0
- package/dist/ui/Accordion/index.js +777 -0
- package/dist/ui/AddressCascader/index.d.ts +58 -0
- package/dist/ui/AddressCascader/index.d.ts.map +1 -0
- package/dist/ui/AddressCascader/index.js +710 -0
- package/dist/ui/BetweenTime/index.d.ts +82 -0
- package/dist/ui/BetweenTime/index.d.ts.map +1 -0
- package/dist/ui/BetweenTime/index.js +702 -0
- package/dist/ui/Button/index.d.ts +93 -0
- package/dist/ui/Button/index.d.ts.map +1 -0
- package/dist/ui/Button/index.js +832 -0
- package/dist/ui/Checkbox/index.d.ts +103 -0
- package/dist/ui/Checkbox/index.d.ts.map +1 -0
- package/dist/ui/Checkbox/index.js +694 -0
- package/dist/ui/DatePicker/index.d.ts +5 -0
- package/dist/ui/DatePicker/index.d.ts.map +1 -0
- package/dist/ui/DatePicker/index.js +157 -0
- package/dist/ui/DatePicker/types.d.ts +99 -0
- package/dist/ui/DatePicker/types.d.ts.map +1 -0
- package/dist/ui/DatePicker/types.js +2 -0
- package/dist/ui/DatePicker/utils.d.ts +32 -0
- package/dist/ui/DatePicker/utils.d.ts.map +1 -0
- package/dist/ui/DatePicker/utils.js +316 -0
- package/dist/ui/LinkedScroll/index.d.ts +78 -0
- package/dist/ui/LinkedScroll/index.d.ts.map +1 -0
- package/dist/ui/LinkedScroll/index.js +470 -0
- package/dist/ui/LoadingSpinner/index.d.ts +8 -0
- package/dist/ui/LoadingSpinner/index.d.ts.map +1 -0
- package/dist/ui/LoadingSpinner/index.js +122 -0
- package/dist/ui/Picker/actionBar.d.ts +14 -0
- package/dist/ui/Picker/actionBar.d.ts.map +1 -0
- package/dist/ui/Picker/actionBar.js +28 -0
- package/dist/ui/Picker/index.d.ts +5 -0
- package/dist/ui/Picker/index.d.ts.map +1 -0
- package/dist/ui/Picker/index.js +412 -0
- package/dist/ui/Picker/types.d.ts +80 -0
- package/dist/ui/Picker/types.d.ts.map +1 -0
- package/dist/ui/Picker/types.js +2 -0
- package/dist/ui/Picker/utils.d.ts +27 -0
- package/dist/ui/Picker/utils.d.ts.map +1 -0
- package/dist/ui/Picker/utils.js +182 -0
- package/dist/ui/Radio/index.d.ts +95 -0
- package/dist/ui/Radio/index.d.ts.map +1 -0
- package/dist/ui/Radio/index.js +633 -0
- package/dist/ui/Sheet/index.d.ts +12 -0
- package/dist/ui/Sheet/index.d.ts.map +1 -0
- package/dist/ui/Sheet/index.js +832 -0
- package/dist/ui/Sheet/nativeBottom.d.ts +52 -0
- package/dist/ui/Sheet/nativeBottom.d.ts.map +1 -0
- package/dist/ui/Sheet/nativeBottom.js +442 -0
- package/dist/ui/Sheet/nativeBottom.web.d.ts +18 -0
- package/dist/ui/Sheet/nativeBottom.web.d.ts.map +1 -0
- package/dist/ui/Sheet/nativeBottom.web.js +46 -0
- package/dist/ui/Sheet/slots.d.ts +5 -0
- package/dist/ui/Sheet/slots.d.ts.map +1 -0
- package/dist/ui/Sheet/slots.js +40 -0
- package/dist/ui/Sheet/types.d.ts +131 -0
- package/dist/ui/Sheet/types.d.ts.map +1 -0
- package/dist/ui/Sheet/types.js +2 -0
- package/dist/ui/SliderCaptcha/index.d.ts +57 -0
- package/dist/ui/SliderCaptcha/index.d.ts.map +1 -0
- package/dist/ui/SliderCaptcha/index.js +586 -0
- package/dist/ui/Switch/index.d.ts +72 -0
- package/dist/ui/Switch/index.d.ts.map +1 -0
- package/dist/ui/Switch/index.js +671 -0
- package/dist/ui/Text/index.d.ts +41 -0
- package/dist/ui/Text/index.d.ts.map +1 -0
- package/dist/ui/Text/index.js +325 -0
- package/dist/ui/TextInput/TextInputPrimitive.d.ts +8 -0
- package/dist/ui/TextInput/TextInputPrimitive.d.ts.map +1 -0
- package/dist/ui/TextInput/TextInputPrimitive.js +54 -0
- package/dist/ui/TextInput/index.d.ts +89 -0
- package/dist/ui/TextInput/index.d.ts.map +1 -0
- package/dist/ui/TextInput/index.js +545 -0
- package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts +39 -0
- package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.d.ts.map +1 -0
- package/dist/ui/WheelColumn/ZKitWheelPickerNativeComponent.js +60 -0
- package/dist/ui/WheelColumn/constants.d.ts +2 -0
- package/dist/ui/WheelColumn/constants.d.ts.map +1 -0
- package/dist/ui/WheelColumn/constants.js +4 -0
- package/dist/ui/WheelColumn/index.d.ts +59 -0
- package/dist/ui/WheelColumn/index.d.ts.map +1 -0
- package/dist/ui/WheelColumn/index.js +547 -0
- package/ios/ZKitWheelPicker.h +18 -0
- package/ios/ZKitWheelPicker.mm +230 -0
- package/ios/ZKitWheelPickerLabel.h +10 -0
- package/ios/ZKitWheelPickerLabel.mm +31 -0
- package/ios/ZKitWheelPickerManager.h +5 -0
- package/ios/ZKitWheelPickerManager.mm +53 -0
- package/package.json +75 -0
- package/react-native.config.js +10 -0
- package/src/ComponentLibProvider.tsx +56 -0
- package/src/assets/animations/spinner.json +1 -0
- package/src/assets/icons/check.svg +4 -0
- package/src/assets/icons/toast/error.webp +0 -0
- package/src/assets/icons/toast/success.webp +0 -0
- package/src/assets/icons/toast/warning.webp +0 -0
- package/src/config.ts +65 -0
- package/src/i18n/I18nProvider.tsx +69 -0
- package/src/i18n/locale.ts +108 -0
- package/src/i18n/locales/de.ts +67 -0
- package/src/i18n/locales/en-US.ts +67 -0
- package/src/i18n/locales/index.ts +19 -0
- package/src/i18n/locales/ja.ts +67 -0
- package/src/i18n/locales/zh-CN.ts +67 -0
- package/src/i18n/locales/zh-TW.ts +67 -0
- package/src/i18n/types.ts +21 -0
- package/src/i18n/useI18n.ts +7 -0
- package/src/index.ts +395 -0
- package/src/services/ActionDialogService/ActionDialog.tsx +756 -0
- package/src/services/ActionDialogService/README.md +146 -0
- package/src/services/ActionDialogService/index.tsx +39 -0
- package/src/services/ActionDialogService/service.tsx +355 -0
- package/src/services/ActionDialogService/shared.ts +204 -0
- package/src/services/ActionDialogService/types.ts +197 -0
- package/src/services/CardToastService/README.md +128 -0
- package/src/services/CardToastService/index.tsx +1284 -0
- package/src/services/ImagePreviewService/README.md +67 -0
- package/src/services/ImagePreviewService/index.tsx +2148 -0
- package/src/services/LoadingService/README.md +128 -0
- package/src/services/LoadingService/index.tsx +1113 -0
- package/src/services/PermissionPurposeDialogService/README.md +80 -0
- package/src/services/PermissionPurposeDialogService/index.tsx +449 -0
- package/src/services/PickerService/README.md +154 -0
- package/src/services/PickerService/index.tsx +410 -0
- package/src/theme/ThemeProvider.tsx +40 -0
- package/src/theme/defaultTheme.ts +30 -0
- package/src/theme/mergeTheme.ts +16 -0
- package/src/theme/types.ts +36 -0
- package/src/theme/useTheme.ts +10 -0
- package/src/types/svg.d.ts +9 -0
- package/src/types/vant-area-data.d.ts +19 -0
- package/src/ui/Accordion/README.md +67 -0
- package/src/ui/Accordion/index.tsx +1221 -0
- package/src/ui/AddressCascader/README.md +144 -0
- package/src/ui/AddressCascader/index.tsx +1084 -0
- package/src/ui/BetweenTime/README.md +490 -0
- package/src/ui/BetweenTime/index.tsx +1001 -0
- package/src/ui/Button/README.md +186 -0
- package/src/ui/Button/index.tsx +1356 -0
- package/src/ui/Checkbox/README.md +211 -0
- package/src/ui/Checkbox/index.tsx +1231 -0
- package/src/ui/DatePicker/README.md +117 -0
- package/src/ui/DatePicker/index.tsx +295 -0
- package/src/ui/DatePicker/types.ts +115 -0
- package/src/ui/DatePicker/utils.ts +405 -0
- package/src/ui/LinkedScroll/README.md +55 -0
- package/src/ui/LinkedScroll/index.tsx +809 -0
- package/src/ui/LoadingSpinner/index.tsx +104 -0
- package/src/ui/Picker/README.md +190 -0
- package/src/ui/Picker/actionBar.tsx +70 -0
- package/src/ui/Picker/index.tsx +694 -0
- package/src/ui/Picker/types.ts +94 -0
- package/src/ui/Picker/utils.ts +239 -0
- package/src/ui/Radio/README.md +207 -0
- package/src/ui/Radio/index.tsx +1117 -0
- package/src/ui/Sheet/README.md +82 -0
- package/src/ui/Sheet/index.tsx +1163 -0
- package/src/ui/Sheet/nativeBottom.tsx +683 -0
- package/src/ui/Sheet/nativeBottom.web.tsx +40 -0
- package/src/ui/Sheet/slots.tsx +75 -0
- package/src/ui/Sheet/types.ts +195 -0
- package/src/ui/SliderCaptcha/README.md +61 -0
- package/src/ui/SliderCaptcha/index.tsx +816 -0
- package/src/ui/Switch/README.md +143 -0
- package/src/ui/Switch/index.tsx +1092 -0
- package/src/ui/Text/README.md +157 -0
- package/src/ui/Text/index.tsx +450 -0
- package/src/ui/TextInput/README.md +197 -0
- package/src/ui/TextInput/TextInputPrimitive.tsx +44 -0
- package/src/ui/TextInput/index.tsx +942 -0
- package/src/ui/WheelColumn/README.md +104 -0
- package/src/ui/WheelColumn/ZKitWheelPickerNativeComponent.tsx +68 -0
- package/src/ui/WheelColumn/constants.ts +1 -0
- package/src/ui/WheelColumn/index.tsx +826 -0
- package/zkit-ui.podspec +19 -0
|
@@ -0,0 +1,832 @@
|
|
|
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.Button = void 0;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const React = __importStar(require("react"));
|
|
39
|
+
const react_native_1 = require("react-native");
|
|
40
|
+
const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
|
|
41
|
+
const zkit_tools_1 = require("zkit-tools");
|
|
42
|
+
const useTheme_1 = require("../../theme/useTheme");
|
|
43
|
+
const LoadingSpinner_1 = require("../LoadingSpinner");
|
|
44
|
+
const Text_1 = require("../Text");
|
|
45
|
+
const AnimatedPressable = react_native_reanimated_1.default.createAnimatedComponent(react_native_1.Pressable);
|
|
46
|
+
const PRESS_TIMING = {
|
|
47
|
+
duration: 120,
|
|
48
|
+
easing: react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic),
|
|
49
|
+
reduceMotion: react_native_reanimated_1.ReduceMotion.System,
|
|
50
|
+
};
|
|
51
|
+
const LOADING_TIMING = {
|
|
52
|
+
duration: 180,
|
|
53
|
+
easing: react_native_reanimated_1.Easing.out(react_native_reanimated_1.Easing.cubic),
|
|
54
|
+
reduceMotion: react_native_reanimated_1.ReduceMotion.System,
|
|
55
|
+
};
|
|
56
|
+
const DISABLED_OPACITY = 0.52;
|
|
57
|
+
const PRESSED_OPACITY = 0.82;
|
|
58
|
+
const PRESSED_SCALE = 0.985;
|
|
59
|
+
const LOADING_SIZE_VISUAL_SCALE = 1.2;
|
|
60
|
+
const SEMANTIC_COLORS = {
|
|
61
|
+
danger: '#DC2626',
|
|
62
|
+
error: '#DC2626',
|
|
63
|
+
info: '#2563EB',
|
|
64
|
+
success: '#16A34A',
|
|
65
|
+
warn: '#D97706',
|
|
66
|
+
warning: '#D97706',
|
|
67
|
+
};
|
|
68
|
+
const SIZE_TOKENS = {
|
|
69
|
+
xs: {
|
|
70
|
+
minHeight: 32,
|
|
71
|
+
paddingHorizontal: 10,
|
|
72
|
+
paddingVertical: 5,
|
|
73
|
+
gap: 5,
|
|
74
|
+
radius: 10,
|
|
75
|
+
iconOnlySide: 32,
|
|
76
|
+
iconSize: 15,
|
|
77
|
+
textSize: 13,
|
|
78
|
+
textLineHeight: 18,
|
|
79
|
+
},
|
|
80
|
+
sm: {
|
|
81
|
+
minHeight: 36,
|
|
82
|
+
paddingHorizontal: 12,
|
|
83
|
+
paddingVertical: 7,
|
|
84
|
+
gap: 6,
|
|
85
|
+
radius: 12,
|
|
86
|
+
iconOnlySide: 36,
|
|
87
|
+
iconSize: 16,
|
|
88
|
+
textSize: 14,
|
|
89
|
+
textLineHeight: 19,
|
|
90
|
+
},
|
|
91
|
+
md: {
|
|
92
|
+
minHeight: 44,
|
|
93
|
+
paddingHorizontal: 16,
|
|
94
|
+
paddingVertical: 10,
|
|
95
|
+
gap: 8,
|
|
96
|
+
radius: 14,
|
|
97
|
+
iconOnlySide: 44,
|
|
98
|
+
iconSize: 18,
|
|
99
|
+
textSize: 15,
|
|
100
|
+
textLineHeight: 21,
|
|
101
|
+
},
|
|
102
|
+
lg: {
|
|
103
|
+
minHeight: 48,
|
|
104
|
+
paddingHorizontal: 20,
|
|
105
|
+
paddingVertical: 12,
|
|
106
|
+
gap: 9,
|
|
107
|
+
radius: 16,
|
|
108
|
+
iconOnlySide: 48,
|
|
109
|
+
iconSize: 20,
|
|
110
|
+
textSize: 16,
|
|
111
|
+
textLineHeight: 22,
|
|
112
|
+
},
|
|
113
|
+
xl: {
|
|
114
|
+
minHeight: 56,
|
|
115
|
+
paddingHorizontal: 24,
|
|
116
|
+
paddingVertical: 14,
|
|
117
|
+
gap: 10,
|
|
118
|
+
radius: 18,
|
|
119
|
+
iconOnlySide: 56,
|
|
120
|
+
iconSize: 22,
|
|
121
|
+
textSize: 17,
|
|
122
|
+
textLineHeight: 24,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const GRADIENT_DIRECTIONS = {
|
|
126
|
+
'to bottom': { start: { x: 0.5, y: 0 }, end: { x: 0.5, y: 1 } },
|
|
127
|
+
'to bottom left': { start: { x: 1, y: 0 }, end: { x: 0, y: 1 } },
|
|
128
|
+
'to bottom right': { start: { x: 0, y: 0 }, end: { x: 1, y: 1 } },
|
|
129
|
+
'to left': { start: { x: 1, y: 0.5 }, end: { x: 0, y: 0.5 } },
|
|
130
|
+
'to right': { start: { x: 0, y: 0.5 }, end: { x: 1, y: 0.5 } },
|
|
131
|
+
'to top': { start: { x: 0.5, y: 1 }, end: { x: 0.5, y: 0 } },
|
|
132
|
+
'to top left': { start: { x: 1, y: 1 }, end: { x: 0, y: 0 } },
|
|
133
|
+
'to top right': { start: { x: 0, y: 1 }, end: { x: 1, y: 0 } },
|
|
134
|
+
};
|
|
135
|
+
let cachedLinearGradientComponent;
|
|
136
|
+
function resolveDefaultLoadingSize(iconSize, availableHeight) {
|
|
137
|
+
const scaled = iconSize * LOADING_SIZE_VISUAL_SCALE;
|
|
138
|
+
if (availableHeight == null || !Number.isFinite(availableHeight) || availableHeight <= 0) {
|
|
139
|
+
return scaled;
|
|
140
|
+
}
|
|
141
|
+
return Math.min(scaled, Math.max(0, availableHeight));
|
|
142
|
+
}
|
|
143
|
+
function resolveMetrics(size) {
|
|
144
|
+
var _a;
|
|
145
|
+
const token = (_a = SIZE_TOKENS[size]) !== null && _a !== void 0 ? _a : SIZE_TOKENS.md;
|
|
146
|
+
const loadingContentHeight = token.minHeight - token.paddingVertical * 2;
|
|
147
|
+
return {
|
|
148
|
+
minHeight: (0, zkit_tools_1.wp)(token.minHeight),
|
|
149
|
+
paddingHorizontal: (0, zkit_tools_1.wp)(token.paddingHorizontal),
|
|
150
|
+
paddingVertical: (0, zkit_tools_1.wp)(token.paddingVertical),
|
|
151
|
+
gap: (0, zkit_tools_1.wp)(token.gap),
|
|
152
|
+
radius: (0, zkit_tools_1.wp)(token.radius),
|
|
153
|
+
iconOnlySide: (0, zkit_tools_1.wp)(token.iconOnlySide),
|
|
154
|
+
iconSize: (0, zkit_tools_1.wp)(token.iconSize),
|
|
155
|
+
loadingSize: (0, zkit_tools_1.wp)(resolveDefaultLoadingSize(token.iconSize, loadingContentHeight)),
|
|
156
|
+
textSize: (0, zkit_tools_1.wp)(token.textSize),
|
|
157
|
+
textLineHeight: (0, zkit_tools_1.wp)(token.textLineHeight),
|
|
158
|
+
borderWidth: (0, zkit_tools_1.wp)(1),
|
|
159
|
+
linkPaddingVertical: (0, zkit_tools_1.wp)(2),
|
|
160
|
+
minTouchTarget: (0, zkit_tools_1.wp)(44),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function isPrimitiveTextChild(children) {
|
|
164
|
+
return typeof children === 'string' || typeof children === 'number';
|
|
165
|
+
}
|
|
166
|
+
function normalizeNumber(input) {
|
|
167
|
+
if (typeof input === 'number')
|
|
168
|
+
return Number.isFinite(input) ? input : undefined;
|
|
169
|
+
if (typeof input !== 'string')
|
|
170
|
+
return undefined;
|
|
171
|
+
const value = input.trim();
|
|
172
|
+
if (!value || value === 'auto' || value.endsWith('%'))
|
|
173
|
+
return undefined;
|
|
174
|
+
const parsed = Number.parseFloat(value);
|
|
175
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
176
|
+
}
|
|
177
|
+
function isProcessableColor(color) {
|
|
178
|
+
return (0, react_native_1.processColor)(color) != null;
|
|
179
|
+
}
|
|
180
|
+
function colorToRgba(color, alpha) {
|
|
181
|
+
const processed = (0, react_native_1.processColor)(color);
|
|
182
|
+
if (typeof processed !== 'number')
|
|
183
|
+
return undefined;
|
|
184
|
+
const normalized = processed >>> 0;
|
|
185
|
+
const r = (normalized >> 16) & 255;
|
|
186
|
+
const g = (normalized >> 8) & 255;
|
|
187
|
+
const b = normalized & 255;
|
|
188
|
+
const a = Math.max(0, Math.min(1, alpha));
|
|
189
|
+
return `rgba(${r},${g},${b},${a})`;
|
|
190
|
+
}
|
|
191
|
+
function resolveColorToken(input, fallback, theme) {
|
|
192
|
+
var _a;
|
|
193
|
+
if (input == null)
|
|
194
|
+
return fallback;
|
|
195
|
+
const key = input.trim();
|
|
196
|
+
if (!key)
|
|
197
|
+
return fallback;
|
|
198
|
+
const resolved = key === 'primary'
|
|
199
|
+
? theme.colors.primary
|
|
200
|
+
: key === 'onPrimary'
|
|
201
|
+
? theme.colors.onPrimary
|
|
202
|
+
: key === 'secondary' || key === 'neutral'
|
|
203
|
+
? theme.colors.secondary
|
|
204
|
+
: key === 'onSecondary'
|
|
205
|
+
? theme.colors.onSecondary
|
|
206
|
+
: key === 'surface'
|
|
207
|
+
? theme.colors.surface
|
|
208
|
+
: key === 'onSurface'
|
|
209
|
+
? theme.colors.onSurface
|
|
210
|
+
: key === 'border'
|
|
211
|
+
? theme.colors.border
|
|
212
|
+
: key === 'muted'
|
|
213
|
+
? theme.colors.muted
|
|
214
|
+
: key === 'disabled'
|
|
215
|
+
? theme.colors.disabled
|
|
216
|
+
: (_a = SEMANTIC_COLORS[key]) !== null && _a !== void 0 ? _a : key;
|
|
217
|
+
return isProcessableColor(resolved) ? resolved : fallback;
|
|
218
|
+
}
|
|
219
|
+
function resolveTonePalette(tone, theme) {
|
|
220
|
+
if (tone === 'neutral') {
|
|
221
|
+
return {
|
|
222
|
+
color: theme.colors.onSurface,
|
|
223
|
+
onColor: theme.colors.surface,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (tone === 'success') {
|
|
227
|
+
return {
|
|
228
|
+
color: SEMANTIC_COLORS.success,
|
|
229
|
+
onColor: '#FFFFFF',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
if (tone === 'warning') {
|
|
233
|
+
return {
|
|
234
|
+
color: SEMANTIC_COLORS.warning,
|
|
235
|
+
onColor: '#111827',
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (tone === 'danger') {
|
|
239
|
+
return {
|
|
240
|
+
color: SEMANTIC_COLORS.danger,
|
|
241
|
+
onColor: '#FFFFFF',
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (tone === 'info') {
|
|
245
|
+
return {
|
|
246
|
+
color: SEMANTIC_COLORS.info,
|
|
247
|
+
onColor: '#FFFFFF',
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
color: theme.colors.primary,
|
|
252
|
+
onColor: theme.colors.onPrimary,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function degToVector(deg) {
|
|
256
|
+
const rad = (deg * Math.PI) / 180;
|
|
257
|
+
const x = Math.cos(rad);
|
|
258
|
+
const y = Math.sin(rad);
|
|
259
|
+
const len = Math.sqrt(x * x + y * y) || 1;
|
|
260
|
+
return { x: x / len, y: y / len };
|
|
261
|
+
}
|
|
262
|
+
function parseGradient(gradient) {
|
|
263
|
+
var _a;
|
|
264
|
+
if (!gradient || gradient.colors.length < 2)
|
|
265
|
+
return undefined;
|
|
266
|
+
const colors = gradient.colors.map((x) => String(x).trim()).filter(Boolean);
|
|
267
|
+
if (colors.length < 2)
|
|
268
|
+
return undefined;
|
|
269
|
+
if (gradient.start || gradient.end) {
|
|
270
|
+
return { colors, start: gradient.start, end: gradient.end };
|
|
271
|
+
}
|
|
272
|
+
const direction = (_a = gradient.direction) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
273
|
+
if (!direction)
|
|
274
|
+
return { colors };
|
|
275
|
+
if (direction.startsWith('to ')) {
|
|
276
|
+
return { colors, ...GRADIENT_DIRECTIONS[direction] };
|
|
277
|
+
}
|
|
278
|
+
const deg = Number.parseFloat(direction.replace('deg', '').trim());
|
|
279
|
+
if (!Number.isFinite(deg))
|
|
280
|
+
return { colors };
|
|
281
|
+
const v = degToVector(deg);
|
|
282
|
+
return {
|
|
283
|
+
colors,
|
|
284
|
+
start: { x: 0.5 - v.x * 0.5, y: 0.5 - v.y * 0.5 },
|
|
285
|
+
end: { x: 0.5 + v.x * 0.5, y: 0.5 + v.y * 0.5 },
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function pickLinearGradientComponent() {
|
|
289
|
+
var _a;
|
|
290
|
+
if (cachedLinearGradientComponent !== undefined)
|
|
291
|
+
return cachedLinearGradientComponent;
|
|
292
|
+
try {
|
|
293
|
+
const mod = require('expo-linear-gradient');
|
|
294
|
+
cachedLinearGradientComponent = (_a = mod.LinearGradient) !== null && _a !== void 0 ? _a : null;
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
cachedLinearGradientComponent = null;
|
|
298
|
+
}
|
|
299
|
+
return cachedLinearGradientComponent;
|
|
300
|
+
}
|
|
301
|
+
function resolveShadowStyle(shadow, scheme, variant) {
|
|
302
|
+
var _a, _b, _c, _d, _e, _f;
|
|
303
|
+
if (!shadow || shadow === 'none' || variant === 'ghost' || variant === 'link')
|
|
304
|
+
return undefined;
|
|
305
|
+
if (typeof shadow === 'object') {
|
|
306
|
+
const radius = Math.max(0, (_a = shadow.radius) !== null && _a !== void 0 ? _a : (0, zkit_tools_1.wp)(10));
|
|
307
|
+
return {
|
|
308
|
+
shadowColor: (_b = shadow.color) !== null && _b !== void 0 ? _b : '#000000',
|
|
309
|
+
shadowOffset: {
|
|
310
|
+
width: (_c = shadow.offsetX) !== null && _c !== void 0 ? _c : 0,
|
|
311
|
+
height: (_d = shadow.offsetY) !== null && _d !== void 0 ? _d : (0, zkit_tools_1.wp)(3),
|
|
312
|
+
},
|
|
313
|
+
shadowOpacity: (_e = shadow.opacity) !== null && _e !== void 0 ? _e : (scheme === 'dark' ? 0.28 : 0.14),
|
|
314
|
+
shadowRadius: radius,
|
|
315
|
+
elevation: (_f = shadow.elevation) !== null && _f !== void 0 ? _f : Math.max(0, Math.round(radius * 0.55)),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const level = shadow === 'sm' ? 1 : shadow === 'md' ? 2 : shadow === 'lg' ? 3 : 0;
|
|
319
|
+
if (level <= 0)
|
|
320
|
+
return undefined;
|
|
321
|
+
const radius = (0, zkit_tools_1.wp)(level * 5 + 3);
|
|
322
|
+
return {
|
|
323
|
+
shadowColor: '#000000',
|
|
324
|
+
shadowOffset: { width: 0, height: (0, zkit_tools_1.wp)(level + 1) },
|
|
325
|
+
shadowOpacity: scheme === 'dark' ? 0.26 : 0.14,
|
|
326
|
+
shadowRadius: radius,
|
|
327
|
+
elevation: Math.max(0, Math.round(radius * 0.55)),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function resolveVisualColors({ accentColor, colors, gradientCfg, hasGradientBackground, palette, theme, variant, visualDisabled, }) {
|
|
331
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
332
|
+
const fallbackGradientColor = resolveColorToken(gradientCfg === null || gradientCfg === void 0 ? void 0 : gradientCfg.colors[0], accentColor, theme);
|
|
333
|
+
const solidBackground = gradientCfg ? fallbackGradientColor : accentColor;
|
|
334
|
+
const softBackground = (_a = colorToRgba(accentColor, 0.12)) !== null && _a !== void 0 ? _a : theme.colors.secondary;
|
|
335
|
+
const softBorder = (_b = colorToRgba(accentColor, 0.2)) !== null && _b !== void 0 ? _b : theme.colors.border;
|
|
336
|
+
let backgroundColor = 'transparent';
|
|
337
|
+
let borderColor = 'transparent';
|
|
338
|
+
let textColor = accentColor;
|
|
339
|
+
if (variant === 'solid') {
|
|
340
|
+
backgroundColor = solidBackground;
|
|
341
|
+
textColor = palette.onColor;
|
|
342
|
+
}
|
|
343
|
+
else if (variant === 'soft') {
|
|
344
|
+
backgroundColor = softBackground;
|
|
345
|
+
borderColor = softBorder;
|
|
346
|
+
}
|
|
347
|
+
else if (variant === 'outline') {
|
|
348
|
+
borderColor = accentColor;
|
|
349
|
+
}
|
|
350
|
+
backgroundColor = (_c = colors === null || colors === void 0 ? void 0 : colors.background) !== null && _c !== void 0 ? _c : backgroundColor;
|
|
351
|
+
borderColor = (_d = colors === null || colors === void 0 ? void 0 : colors.border) !== null && _d !== void 0 ? _d : borderColor;
|
|
352
|
+
textColor = (_e = colors === null || colors === void 0 ? void 0 : colors.text) !== null && _e !== void 0 ? _e : textColor;
|
|
353
|
+
if (hasGradientBackground) {
|
|
354
|
+
backgroundColor = 'transparent';
|
|
355
|
+
borderColor = (_f = colors === null || colors === void 0 ? void 0 : colors.border) !== null && _f !== void 0 ? _f : 'transparent';
|
|
356
|
+
textColor = (_g = colors === null || colors === void 0 ? void 0 : colors.text) !== null && _g !== void 0 ? _g : palette.onColor;
|
|
357
|
+
}
|
|
358
|
+
if (visualDisabled) {
|
|
359
|
+
const disabledBackground = variant === 'solid' || variant === 'soft' ? theme.colors.secondary : 'transparent';
|
|
360
|
+
backgroundColor = (_h = colors === null || colors === void 0 ? void 0 : colors.disabledBackground) !== null && _h !== void 0 ? _h : disabledBackground;
|
|
361
|
+
borderColor = (_j = colors === null || colors === void 0 ? void 0 : colors.disabledBorder) !== null && _j !== void 0 ? _j : (variant === 'outline' ? theme.colors.border : borderColor);
|
|
362
|
+
textColor = (_k = colors === null || colors === void 0 ? void 0 : colors.disabledText) !== null && _k !== void 0 ? _k : theme.colors.disabled;
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
backgroundColor,
|
|
366
|
+
borderColor,
|
|
367
|
+
textColor,
|
|
368
|
+
loadingColor: (_l = colors === null || colors === void 0 ? void 0 : colors.loading) !== null && _l !== void 0 ? _l : textColor,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function resolvePressEffect(effect, interactionDisabled) {
|
|
372
|
+
if (interactionDisabled)
|
|
373
|
+
return 'none';
|
|
374
|
+
if (effect !== 'auto')
|
|
375
|
+
return effect;
|
|
376
|
+
return 'scale-opacity';
|
|
377
|
+
}
|
|
378
|
+
function resolvePressEffectFlags(effect) {
|
|
379
|
+
return {
|
|
380
|
+
highlight: effect === 'highlight' || effect === 'scale-highlight',
|
|
381
|
+
opacity: effect === 'opacity' || effect === 'scale-opacity',
|
|
382
|
+
scale: effect === 'scale' || effect === 'scale-highlight' || effect === 'scale-opacity',
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function resolveOverlay({ accentColor, colors, hasGradientBackground, variant, }) {
|
|
386
|
+
if (colors === null || colors === void 0 ? void 0 : colors.pressedOverlay) {
|
|
387
|
+
return { color: colors.pressedOverlay, strength: 0.12 };
|
|
388
|
+
}
|
|
389
|
+
if (variant === 'solid' || hasGradientBackground) {
|
|
390
|
+
return { color: '#000000', strength: 0.1 };
|
|
391
|
+
}
|
|
392
|
+
if (variant === 'soft') {
|
|
393
|
+
return { color: '#000000', strength: 0.06 };
|
|
394
|
+
}
|
|
395
|
+
return { color: accentColor, strength: 0.1 };
|
|
396
|
+
}
|
|
397
|
+
function resolveRootSizeStyle({ block, iconOnly, layout, metrics, variant, }) {
|
|
398
|
+
var _a, _b, _c;
|
|
399
|
+
const width = (_a = layout === null || layout === void 0 ? void 0 : layout.width) !== null && _a !== void 0 ? _a : (block ? '100%' : undefined);
|
|
400
|
+
const height = layout === null || layout === void 0 ? void 0 : layout.height;
|
|
401
|
+
const iconSide = (_c = (_b = normalizeNumber(width)) !== null && _b !== void 0 ? _b : normalizeNumber(height)) !== null && _c !== void 0 ? _c : metrics.iconOnlySide;
|
|
402
|
+
if (iconOnly) {
|
|
403
|
+
return {
|
|
404
|
+
...(width !== undefined ? { width } : { width: iconSide }),
|
|
405
|
+
...(height !== undefined ? { height } : { height: iconSide }),
|
|
406
|
+
...((layout === null || layout === void 0 ? void 0 : layout.minWidth) !== undefined ? { minWidth: layout.minWidth } : undefined),
|
|
407
|
+
...((layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== undefined ? { maxWidth: layout.maxWidth } : undefined),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
...(width !== undefined ? { width } : undefined),
|
|
412
|
+
...(height !== undefined ? { height } : undefined),
|
|
413
|
+
...((layout === null || layout === void 0 ? void 0 : layout.minWidth) !== undefined ? { minWidth: layout.minWidth } : undefined),
|
|
414
|
+
...((layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== undefined ? { maxWidth: layout.maxWidth } : undefined),
|
|
415
|
+
...((layout === null || layout === void 0 ? void 0 : layout.minHeight) !== undefined
|
|
416
|
+
? { minHeight: layout.minHeight }
|
|
417
|
+
: variant === 'link'
|
|
418
|
+
? undefined
|
|
419
|
+
: { minHeight: metrics.minHeight }),
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function resolveContentSizeStyle(rootSizeStyle, iconOnly) {
|
|
423
|
+
const nextStyle = {};
|
|
424
|
+
if (iconOnly || rootSizeStyle.width !== undefined)
|
|
425
|
+
nextStyle.width = '100%';
|
|
426
|
+
if (iconOnly || rootSizeStyle.height !== undefined)
|
|
427
|
+
nextStyle.height = '100%';
|
|
428
|
+
else if (rootSizeStyle.minHeight !== undefined)
|
|
429
|
+
nextStyle.minHeight = rootSizeStyle.minHeight;
|
|
430
|
+
return nextStyle;
|
|
431
|
+
}
|
|
432
|
+
function resolveSideLength(rootSizeStyle, iconOnly, layout, metrics) {
|
|
433
|
+
var _a, _b;
|
|
434
|
+
const height = normalizeNumber(rootSizeStyle.height);
|
|
435
|
+
if (height != null)
|
|
436
|
+
return height;
|
|
437
|
+
if (iconOnly)
|
|
438
|
+
return (_a = normalizeNumber(rootSizeStyle.width)) !== null && _a !== void 0 ? _a : metrics.iconOnlySide;
|
|
439
|
+
return (_b = layout === null || layout === void 0 ? void 0 : layout.minHeight) !== null && _b !== void 0 ? _b : metrics.minHeight;
|
|
440
|
+
}
|
|
441
|
+
function resolveRadiusStyle({ iconOnly, layout, metrics, rootSizeStyle, shape, }) {
|
|
442
|
+
var _a;
|
|
443
|
+
if (shape === 'square')
|
|
444
|
+
return { borderRadius: 0 };
|
|
445
|
+
if (shape === 'pill') {
|
|
446
|
+
const radius = resolveSideLength(rootSizeStyle, iconOnly, layout, metrics) / 2;
|
|
447
|
+
return {
|
|
448
|
+
borderBottomLeftRadius: radius,
|
|
449
|
+
borderBottomRightRadius: radius,
|
|
450
|
+
borderRadius: radius,
|
|
451
|
+
borderTopLeftRadius: radius,
|
|
452
|
+
borderTopRightRadius: radius,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return { borderRadius: (_a = layout === null || layout === void 0 ? void 0 : layout.radius) !== null && _a !== void 0 ? _a : metrics.radius };
|
|
456
|
+
}
|
|
457
|
+
function resolvePaddingStyle({ iconOnly, layout, metrics, variant, }) {
|
|
458
|
+
var _a, _b, _c;
|
|
459
|
+
if (iconOnly)
|
|
460
|
+
return {};
|
|
461
|
+
if (variant === 'link') {
|
|
462
|
+
return {
|
|
463
|
+
paddingHorizontal: 0,
|
|
464
|
+
paddingVertical: (_a = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _a !== void 0 ? _a : metrics.linkPaddingVertical,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
return {
|
|
468
|
+
paddingHorizontal: (_b = layout === null || layout === void 0 ? void 0 : layout.paddingHorizontal) !== null && _b !== void 0 ? _b : metrics.paddingHorizontal,
|
|
469
|
+
paddingVertical: (_c = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _c !== void 0 ? _c : metrics.paddingVertical,
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function resolveBorderStyle({ border, metrics, theme, visualColors, variant, }) {
|
|
473
|
+
var _a, _b, _c;
|
|
474
|
+
const defaultBorderWidth = variant === 'outline' ? metrics.borderWidth : undefined;
|
|
475
|
+
const width = (_a = border === null || border === void 0 ? void 0 : border.width) !== null && _a !== void 0 ? _a : defaultBorderWidth;
|
|
476
|
+
if (width == null)
|
|
477
|
+
return {};
|
|
478
|
+
return {
|
|
479
|
+
borderColor: (_b = border === null || border === void 0 ? void 0 : border.color) !== null && _b !== void 0 ? _b : (visualColors.borderColor === 'transparent' ? theme.colors.border : visualColors.borderColor),
|
|
480
|
+
borderStyle: (_c = border === null || border === void 0 ? void 0 : border.style) !== null && _c !== void 0 ? _c : 'solid',
|
|
481
|
+
borderWidth: width,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function resolveDefaultHitSlop({ iconOnly, layout, metrics, rootSizeStyle, variant, }) {
|
|
485
|
+
var _a, _b;
|
|
486
|
+
if (variant === 'link') {
|
|
487
|
+
const visualHeight = ((_a = layout === null || layout === void 0 ? void 0 : layout.textLineHeight) !== null && _a !== void 0 ? _a : metrics.textLineHeight) +
|
|
488
|
+
((_b = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _b !== void 0 ? _b : metrics.linkPaddingVertical) * 2;
|
|
489
|
+
const vertical = Math.max((0, zkit_tools_1.wp)(6), (metrics.minTouchTarget - visualHeight) / 2);
|
|
490
|
+
return {
|
|
491
|
+
bottom: vertical,
|
|
492
|
+
left: (0, zkit_tools_1.wp)(8),
|
|
493
|
+
right: (0, zkit_tools_1.wp)(8),
|
|
494
|
+
top: vertical,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
const side = resolveSideLength(rootSizeStyle, iconOnly, layout, metrics);
|
|
498
|
+
const slop = Math.max(0, (metrics.minTouchTarget - side) / 2);
|
|
499
|
+
if (slop <= 0)
|
|
500
|
+
return undefined;
|
|
501
|
+
return {
|
|
502
|
+
bottom: slop,
|
|
503
|
+
left: iconOnly ? slop : 0,
|
|
504
|
+
right: iconOnly ? slop : 0,
|
|
505
|
+
top: slop,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function resolveLoadingSize({ iconOnly, layout, metrics, variant, }) {
|
|
509
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
510
|
+
if ((layout === null || layout === void 0 ? void 0 : layout.loadingSize) !== undefined)
|
|
511
|
+
return layout.loadingSize;
|
|
512
|
+
const iconSize = (_a = layout === null || layout === void 0 ? void 0 : layout.iconSize) !== null && _a !== void 0 ? _a : metrics.iconSize;
|
|
513
|
+
if (iconOnly) {
|
|
514
|
+
const availableHeight = (_c = (_b = normalizeNumber(layout === null || layout === void 0 ? void 0 : layout.height)) !== null && _b !== void 0 ? _b : normalizeNumber(layout === null || layout === void 0 ? void 0 : layout.width)) !== null && _c !== void 0 ? _c : metrics.iconOnlySide;
|
|
515
|
+
return resolveDefaultLoadingSize(iconSize, availableHeight);
|
|
516
|
+
}
|
|
517
|
+
if (variant === 'link') {
|
|
518
|
+
const availableHeight = ((_d = layout === null || layout === void 0 ? void 0 : layout.textLineHeight) !== null && _d !== void 0 ? _d : metrics.textLineHeight) +
|
|
519
|
+
((_e = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _e !== void 0 ? _e : metrics.linkPaddingVertical) * 2;
|
|
520
|
+
return resolveDefaultLoadingSize(iconSize, availableHeight);
|
|
521
|
+
}
|
|
522
|
+
const availableHeight = ((_g = (_f = normalizeNumber(layout === null || layout === void 0 ? void 0 : layout.height)) !== null && _f !== void 0 ? _f : layout === null || layout === void 0 ? void 0 : layout.minHeight) !== null && _g !== void 0 ? _g : metrics.minHeight) -
|
|
523
|
+
((_h = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _h !== void 0 ? _h : metrics.paddingVertical) * 2;
|
|
524
|
+
return resolveDefaultLoadingSize(iconSize, availableHeight);
|
|
525
|
+
}
|
|
526
|
+
function resolveIconBoxStyle(visible, iconSize) {
|
|
527
|
+
if (!visible)
|
|
528
|
+
return {};
|
|
529
|
+
return {
|
|
530
|
+
alignItems: 'center',
|
|
531
|
+
height: iconSize,
|
|
532
|
+
justifyContent: 'center',
|
|
533
|
+
overflow: 'hidden',
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function resolveWebCursorStyle(disabled) {
|
|
537
|
+
if (react_native_1.Platform.OS !== 'web')
|
|
538
|
+
return undefined;
|
|
539
|
+
return { cursor: disabled ? 'not-allowed' : 'pointer' };
|
|
540
|
+
}
|
|
541
|
+
function ButtonImpl({ variant = 'solid', tone = 'primary', size = 'md', shape = 'rounded', block = false, disabled = false, loading = false, loadingMode = 'inline', pressEffect = 'auto', icon, iconPlacement = 'start', iconOnly = false, color, colors, border, layout, gradient, shadow = 'none', children, style, contentStyle, textStyle, accessibilityLabel, accessibilityState, hitSlop, onPress, onPressIn, onPressOut, testID, ...pressableProps }, ref) {
|
|
542
|
+
var _a, _b;
|
|
543
|
+
const theme = (0, useTheme_1.useTheme)();
|
|
544
|
+
const scheme = (0, react_native_1.useColorScheme)();
|
|
545
|
+
const { width: viewportWidth } = (0, react_native_1.useWindowDimensions)();
|
|
546
|
+
const metrics = React.useMemo(() => resolveMetrics(size), [size, viewportWidth]);
|
|
547
|
+
const palette = React.useMemo(() => resolveTonePalette(tone, theme), [theme, tone]);
|
|
548
|
+
const accentColor = React.useMemo(() => resolveColorToken(color !== null && color !== void 0 ? color : colors === null || colors === void 0 ? void 0 : colors.color, palette.color, theme), [color, colors === null || colors === void 0 ? void 0 : colors.color, palette.color, theme]);
|
|
549
|
+
const gradientCfg = React.useMemo(() => parseGradient(gradient), [gradient]);
|
|
550
|
+
const LinearGradientComponent = React.useMemo(() => { var _a; return (variant === 'solid' && gradientCfg ? ((_a = pickLinearGradientComponent()) !== null && _a !== void 0 ? _a : undefined) : undefined); }, [gradientCfg, variant]);
|
|
551
|
+
const hasGradientBackground = Boolean(variant === 'solid' && gradientCfg && LinearGradientComponent);
|
|
552
|
+
const interactionDisabled = disabled || loading;
|
|
553
|
+
const visualDisabled = disabled;
|
|
554
|
+
const resolvedLoadingMode = iconOnly ? 'overlay' : loadingMode;
|
|
555
|
+
const centeredLoading = resolvedLoadingMode !== 'inline';
|
|
556
|
+
const visualColors = React.useMemo(() => resolveVisualColors({
|
|
557
|
+
accentColor,
|
|
558
|
+
colors,
|
|
559
|
+
gradientCfg,
|
|
560
|
+
hasGradientBackground,
|
|
561
|
+
palette,
|
|
562
|
+
theme,
|
|
563
|
+
variant,
|
|
564
|
+
visualDisabled,
|
|
565
|
+
}), [accentColor, colors, gradientCfg, hasGradientBackground, palette, theme, variant, visualDisabled]);
|
|
566
|
+
const rootSizeStyle = React.useMemo(() => resolveRootSizeStyle({
|
|
567
|
+
block,
|
|
568
|
+
iconOnly,
|
|
569
|
+
layout,
|
|
570
|
+
metrics,
|
|
571
|
+
variant,
|
|
572
|
+
}), [block, iconOnly, layout, metrics, variant]);
|
|
573
|
+
const contentSizeStyle = React.useMemo(() => resolveContentSizeStyle(rootSizeStyle, iconOnly), [iconOnly, rootSizeStyle]);
|
|
574
|
+
const radiusStyle = React.useMemo(() => resolveRadiusStyle({
|
|
575
|
+
iconOnly,
|
|
576
|
+
layout,
|
|
577
|
+
metrics,
|
|
578
|
+
rootSizeStyle,
|
|
579
|
+
shape,
|
|
580
|
+
}), [iconOnly, layout, metrics, rootSizeStyle, shape]);
|
|
581
|
+
const paddingStyle = React.useMemo(() => resolvePaddingStyle({
|
|
582
|
+
iconOnly,
|
|
583
|
+
layout,
|
|
584
|
+
metrics,
|
|
585
|
+
variant,
|
|
586
|
+
}), [iconOnly, layout, metrics, variant]);
|
|
587
|
+
const borderStyle = React.useMemo(() => resolveBorderStyle({
|
|
588
|
+
border,
|
|
589
|
+
metrics,
|
|
590
|
+
theme,
|
|
591
|
+
visualColors,
|
|
592
|
+
variant,
|
|
593
|
+
}), [border, metrics, theme, variant, visualColors]);
|
|
594
|
+
const shadowStyle = React.useMemo(() => resolveShadowStyle(shadow, scheme, variant), [scheme, shadow, variant]);
|
|
595
|
+
const webCursorStyle = React.useMemo(() => resolveWebCursorStyle(interactionDisabled), [interactionDisabled]);
|
|
596
|
+
const defaultHitSlop = React.useMemo(() => resolveDefaultHitSlop({
|
|
597
|
+
iconOnly,
|
|
598
|
+
layout,
|
|
599
|
+
metrics,
|
|
600
|
+
rootSizeStyle,
|
|
601
|
+
variant,
|
|
602
|
+
}), [iconOnly, layout, metrics, rootSizeStyle, variant]);
|
|
603
|
+
const resolvedText = React.useMemo(() => {
|
|
604
|
+
var _a, _b;
|
|
605
|
+
if (children == null)
|
|
606
|
+
return null;
|
|
607
|
+
if (!isPrimitiveTextChild(children))
|
|
608
|
+
return children;
|
|
609
|
+
return ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: 1, style: [
|
|
610
|
+
styles.text,
|
|
611
|
+
{
|
|
612
|
+
color: visualColors.textColor,
|
|
613
|
+
fontSize: (_a = layout === null || layout === void 0 ? void 0 : layout.textSize) !== null && _a !== void 0 ? _a : metrics.textSize,
|
|
614
|
+
lineHeight: (_b = layout === null || layout === void 0 ? void 0 : layout.textLineHeight) !== null && _b !== void 0 ? _b : metrics.textLineHeight,
|
|
615
|
+
},
|
|
616
|
+
variant === 'link' ? styles.linkText : null,
|
|
617
|
+
textStyle,
|
|
618
|
+
], children: children }));
|
|
619
|
+
}, [
|
|
620
|
+
children,
|
|
621
|
+
layout === null || layout === void 0 ? void 0 : layout.textLineHeight,
|
|
622
|
+
layout === null || layout === void 0 ? void 0 : layout.textSize,
|
|
623
|
+
metrics.textLineHeight,
|
|
624
|
+
metrics.textSize,
|
|
625
|
+
textStyle,
|
|
626
|
+
variant,
|
|
627
|
+
visualColors.textColor,
|
|
628
|
+
]);
|
|
629
|
+
const hasText = resolvedText != null;
|
|
630
|
+
const hasIcon = icon != null;
|
|
631
|
+
const iconSize = (_a = layout === null || layout === void 0 ? void 0 : layout.iconSize) !== null && _a !== void 0 ? _a : metrics.iconSize;
|
|
632
|
+
const loadingSize = React.useMemo(() => resolveLoadingSize({
|
|
633
|
+
iconOnly,
|
|
634
|
+
layout,
|
|
635
|
+
metrics,
|
|
636
|
+
variant,
|
|
637
|
+
}), [iconOnly, layout, metrics, variant]);
|
|
638
|
+
const contentGap = (_b = layout === null || layout === void 0 ? void 0 : layout.gap) !== null && _b !== void 0 ? _b : metrics.gap;
|
|
639
|
+
const iconBaseBoxStyle = React.useMemo(() => resolveIconBoxStyle(hasIcon, iconSize), [hasIcon, iconSize]);
|
|
640
|
+
const iconPlacedBoxStyle = React.useMemo(() => {
|
|
641
|
+
if (!hasIcon)
|
|
642
|
+
return {};
|
|
643
|
+
const gap = hasText ? contentGap : 0;
|
|
644
|
+
return {
|
|
645
|
+
width: iconSize,
|
|
646
|
+
...(iconPlacement === 'end' ? { marginLeft: gap } : { marginRight: gap }),
|
|
647
|
+
};
|
|
648
|
+
}, [contentGap, hasIcon, hasText, iconPlacement, iconSize]);
|
|
649
|
+
const inferredAccessibilityLabel = iconOnly && isPrimitiveTextChild(children) ? String(children) : undefined;
|
|
650
|
+
const resolvedAccessibilityLabel = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : inferredAccessibilityLabel;
|
|
651
|
+
const pressSv = (0, react_native_reanimated_1.useSharedValue)(0);
|
|
652
|
+
const loadingSv = (0, react_native_reanimated_1.useSharedValue)(loading ? 1 : 0);
|
|
653
|
+
const [spinnerMounted, setSpinnerMounted] = React.useState(loading);
|
|
654
|
+
const hideSpinnerTimerRef = React.useRef(null);
|
|
655
|
+
const resolvedPressEffect = React.useMemo(() => resolvePressEffect(pressEffect, interactionDisabled), [interactionDisabled, pressEffect]);
|
|
656
|
+
const pressEffectFlags = React.useMemo(() => resolvePressEffectFlags(resolvedPressEffect), [resolvedPressEffect]);
|
|
657
|
+
const pressHighlightEnabled = pressEffectFlags.highlight;
|
|
658
|
+
const pressOpacityEnabled = pressEffectFlags.opacity;
|
|
659
|
+
const pressScaleEnabled = pressEffectFlags.scale;
|
|
660
|
+
const pressOverlay = React.useMemo(() => resolveOverlay({
|
|
661
|
+
accentColor,
|
|
662
|
+
colors,
|
|
663
|
+
hasGradientBackground,
|
|
664
|
+
variant,
|
|
665
|
+
}), [accentColor, colors, hasGradientBackground, variant]);
|
|
666
|
+
React.useEffect(() => {
|
|
667
|
+
if (interactionDisabled || resolvedPressEffect === 'none') {
|
|
668
|
+
pressSv.value = 0;
|
|
669
|
+
}
|
|
670
|
+
}, [interactionDisabled, pressSv, resolvedPressEffect]);
|
|
671
|
+
React.useEffect(() => {
|
|
672
|
+
if (hideSpinnerTimerRef.current) {
|
|
673
|
+
clearTimeout(hideSpinnerTimerRef.current);
|
|
674
|
+
hideSpinnerTimerRef.current = null;
|
|
675
|
+
}
|
|
676
|
+
if (loading) {
|
|
677
|
+
setSpinnerMounted(true);
|
|
678
|
+
}
|
|
679
|
+
loadingSv.value = (0, react_native_reanimated_1.withTiming)(loading ? 1 : 0, LOADING_TIMING);
|
|
680
|
+
if (!loading) {
|
|
681
|
+
hideSpinnerTimerRef.current = setTimeout(() => {
|
|
682
|
+
setSpinnerMounted(false);
|
|
683
|
+
}, LOADING_TIMING.duration);
|
|
684
|
+
}
|
|
685
|
+
return () => {
|
|
686
|
+
if (hideSpinnerTimerRef.current) {
|
|
687
|
+
clearTimeout(hideSpinnerTimerRef.current);
|
|
688
|
+
hideSpinnerTimerRef.current = null;
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
}, [loading, loadingSv]);
|
|
692
|
+
const rootAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
693
|
+
const baseOpacity = visualDisabled ? DISABLED_OPACITY : 1;
|
|
694
|
+
const scale = pressScaleEnabled
|
|
695
|
+
? (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [1, PRESSED_SCALE])
|
|
696
|
+
: 1;
|
|
697
|
+
const opacity = pressOpacityEnabled
|
|
698
|
+
? (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [baseOpacity, PRESSED_OPACITY])
|
|
699
|
+
: baseOpacity;
|
|
700
|
+
return {
|
|
701
|
+
opacity,
|
|
702
|
+
transform: [{ scale }],
|
|
703
|
+
};
|
|
704
|
+
}, [pressOpacityEnabled, pressScaleEnabled, visualDisabled]);
|
|
705
|
+
const overlayAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
706
|
+
const opacity = pressHighlightEnabled
|
|
707
|
+
? (0, react_native_reanimated_1.interpolate)(pressSv.value, [0, 1], [0, pressOverlay.strength])
|
|
708
|
+
: 0;
|
|
709
|
+
return { opacity };
|
|
710
|
+
}, [pressHighlightEnabled, pressOverlay.strength]);
|
|
711
|
+
const inlineSpinnerAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
712
|
+
const width = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0, loadingSize]);
|
|
713
|
+
const marginRight = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0, hasText ? contentGap : 0]);
|
|
714
|
+
const opacity = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0, 1]);
|
|
715
|
+
const scale = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0.92, 1]);
|
|
716
|
+
return {
|
|
717
|
+
marginRight,
|
|
718
|
+
opacity,
|
|
719
|
+
transform: [{ scale }],
|
|
720
|
+
width,
|
|
721
|
+
};
|
|
722
|
+
}, [contentGap, hasText, loadingSize, loadingSv]);
|
|
723
|
+
const centeredSpinnerAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
724
|
+
const opacity = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0, 1]);
|
|
725
|
+
const scale = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0.92, 1]);
|
|
726
|
+
return {
|
|
727
|
+
opacity,
|
|
728
|
+
transform: [{ scale }],
|
|
729
|
+
};
|
|
730
|
+
}, [loadingSv]);
|
|
731
|
+
const iconAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
732
|
+
if (!hasIcon || iconOnly)
|
|
733
|
+
return { opacity: 0, width: 0 };
|
|
734
|
+
const margin = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [hasText ? contentGap : 0, 0]);
|
|
735
|
+
const opacity = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [1, 0]);
|
|
736
|
+
const scale = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [1, 0.92]);
|
|
737
|
+
const width = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [iconSize, 0]);
|
|
738
|
+
return {
|
|
739
|
+
opacity,
|
|
740
|
+
transform: [{ scale }],
|
|
741
|
+
width,
|
|
742
|
+
...(iconPlacement === 'end' ? { marginLeft: margin } : { marginRight: margin }),
|
|
743
|
+
};
|
|
744
|
+
}, [contentGap, hasIcon, hasText, iconOnly, iconPlacement, iconSize, loadingSv]);
|
|
745
|
+
const contentAnimatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
|
|
746
|
+
if (centeredLoading || iconOnly) {
|
|
747
|
+
const opacity = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [1, 0]);
|
|
748
|
+
const scale = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [1, 0.98]);
|
|
749
|
+
return { opacity, transform: [{ scale }] };
|
|
750
|
+
}
|
|
751
|
+
const translateX = (0, react_native_reanimated_1.interpolate)(loadingSv.value, [0, 1], [0, metrics.linkPaddingVertical]);
|
|
752
|
+
return { transform: [{ translateX }] };
|
|
753
|
+
}, [centeredLoading, iconOnly, loadingSv, metrics.linkPaddingVertical]);
|
|
754
|
+
const spinnerVisible = loading || spinnerMounted;
|
|
755
|
+
const showContent = !iconOnly;
|
|
756
|
+
const handlePress = React.useCallback((event) => {
|
|
757
|
+
if (interactionDisabled)
|
|
758
|
+
return;
|
|
759
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(event);
|
|
760
|
+
}, [interactionDisabled, onPress]);
|
|
761
|
+
const handlePressIn = React.useCallback((event) => {
|
|
762
|
+
if (!interactionDisabled && resolvedPressEffect !== 'none') {
|
|
763
|
+
pressSv.value = (0, react_native_reanimated_1.withTiming)(1, PRESS_TIMING);
|
|
764
|
+
}
|
|
765
|
+
onPressIn === null || onPressIn === void 0 ? void 0 : onPressIn(event);
|
|
766
|
+
}, [interactionDisabled, onPressIn, pressSv, resolvedPressEffect]);
|
|
767
|
+
const handlePressOut = React.useCallback((event) => {
|
|
768
|
+
if (!interactionDisabled && resolvedPressEffect !== 'none') {
|
|
769
|
+
pressSv.value = (0, react_native_reanimated_1.withTiming)(0, PRESS_TIMING);
|
|
770
|
+
}
|
|
771
|
+
onPressOut === null || onPressOut === void 0 ? void 0 : onPressOut(event);
|
|
772
|
+
}, [interactionDisabled, onPressOut, pressSv, resolvedPressEffect]);
|
|
773
|
+
return ((0, jsx_runtime_1.jsx)(AnimatedPressable, { ...pressableProps, ref: ref, accessibilityLabel: resolvedAccessibilityLabel, accessibilityRole: "button", accessibilityState: {
|
|
774
|
+
...accessibilityState,
|
|
775
|
+
busy: Boolean(loading || (accessibilityState === null || accessibilityState === void 0 ? void 0 : accessibilityState.busy)),
|
|
776
|
+
disabled: Boolean(interactionDisabled || (accessibilityState === null || accessibilityState === void 0 ? void 0 : accessibilityState.disabled)),
|
|
777
|
+
}, disabled: interactionDisabled, hitSlop: hitSlop !== null && hitSlop !== void 0 ? hitSlop : defaultHitSlop, onPress: handlePress, onPressIn: handlePressIn, onPressOut: handlePressOut, style: [styles.root, rootSizeStyle, radiusStyle, shadowStyle, rootAnimatedStyle, webCursorStyle, style], testID: testID, children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { pointerEvents: "none", style: [
|
|
778
|
+
styles.content,
|
|
779
|
+
contentSizeStyle,
|
|
780
|
+
paddingStyle,
|
|
781
|
+
radiusStyle,
|
|
782
|
+
borderStyle,
|
|
783
|
+
{ backgroundColor: visualColors.backgroundColor },
|
|
784
|
+
contentStyle,
|
|
785
|
+
], children: [LinearGradientComponent && gradientCfg ? ((0, jsx_runtime_1.jsx)(LinearGradientComponent, { pointerEvents: "none", colors: gradientCfg.colors, start: gradientCfg.start, end: gradientCfg.end, style: [react_native_1.StyleSheet.absoluteFillObject, radiusStyle] })) : null, (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { pointerEvents: "none", style: [
|
|
786
|
+
react_native_1.StyleSheet.absoluteFillObject,
|
|
787
|
+
radiusStyle,
|
|
788
|
+
{ backgroundColor: pressOverlay.color },
|
|
789
|
+
overlayAnimatedStyle,
|
|
790
|
+
] }), iconOnly ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.centerOverlay, centeredSpinnerAnimatedStyle], children: spinnerVisible ? ((0, jsx_runtime_1.jsx)(LoadingSpinner_1.LoadingSpinner, { animating: spinnerVisible, color: visualColors.loadingColor, size: loadingSize })) : null }), (icon !== null && icon !== void 0 ? icon : resolvedText) ? ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: contentAnimatedStyle, children: icon !== null && icon !== void 0 ? icon : resolvedText })) : null] })) : centeredLoading ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_native_reanimated_1.default.View, { style: [styles.centerContent, contentAnimatedStyle], children: [icon && iconPlacement === 'start' ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [iconBaseBoxStyle, iconPlacedBoxStyle], children: icon })) : null, showContent ? resolvedText : null, icon && iconPlacement === 'end' ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: [iconBaseBoxStyle, iconPlacedBoxStyle], children: icon })) : null] }), (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.centerOverlay, centeredSpinnerAnimatedStyle], children: spinnerVisible ? ((0, jsx_runtime_1.jsx)(LoadingSpinner_1.LoadingSpinner, { animating: spinnerVisible, color: visualColors.loadingColor, size: loadingSize })) : null })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [styles.spinnerBox, { height: loadingSize }, inlineSpinnerAnimatedStyle], children: spinnerVisible ? ((0, jsx_runtime_1.jsx)(LoadingSpinner_1.LoadingSpinner, { animating: spinnerVisible, color: visualColors.loadingColor, size: loadingSize })) : null }), icon && iconPlacement === 'start' ? ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [iconBaseBoxStyle, iconAnimatedStyle], children: icon })) : null, resolvedText ? (0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: contentAnimatedStyle, children: resolvedText }) : null, icon && iconPlacement === 'end' ? ((0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: [iconBaseBoxStyle, iconAnimatedStyle], children: icon })) : null] }))] }) }));
|
|
791
|
+
}
|
|
792
|
+
const ButtonWithRef = React.forwardRef(ButtonImpl);
|
|
793
|
+
ButtonWithRef.displayName = 'Button';
|
|
794
|
+
exports.Button = React.memo(ButtonWithRef);
|
|
795
|
+
exports.Button.displayName = 'Button';
|
|
796
|
+
const styles = react_native_1.StyleSheet.create({
|
|
797
|
+
centerContent: {
|
|
798
|
+
alignItems: 'center',
|
|
799
|
+
flexDirection: 'row',
|
|
800
|
+
justifyContent: 'center',
|
|
801
|
+
},
|
|
802
|
+
centerOverlay: {
|
|
803
|
+
alignItems: 'center',
|
|
804
|
+
bottom: 0,
|
|
805
|
+
justifyContent: 'center',
|
|
806
|
+
left: 0,
|
|
807
|
+
position: 'absolute',
|
|
808
|
+
right: 0,
|
|
809
|
+
top: 0,
|
|
810
|
+
},
|
|
811
|
+
content: {
|
|
812
|
+
alignItems: 'center',
|
|
813
|
+
flexDirection: 'row',
|
|
814
|
+
justifyContent: 'center',
|
|
815
|
+
overflow: 'hidden',
|
|
816
|
+
},
|
|
817
|
+
linkText: {
|
|
818
|
+
textDecorationLine: 'underline',
|
|
819
|
+
},
|
|
820
|
+
root: {},
|
|
821
|
+
spinnerBox: {
|
|
822
|
+
alignItems: 'center',
|
|
823
|
+
justifyContent: 'center',
|
|
824
|
+
overflow: 'hidden',
|
|
825
|
+
},
|
|
826
|
+
text: {
|
|
827
|
+
flexShrink: 1,
|
|
828
|
+
fontWeight: '600',
|
|
829
|
+
letterSpacing: 0,
|
|
830
|
+
textAlign: 'center',
|
|
831
|
+
},
|
|
832
|
+
});
|