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,545 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.TextInput = exports.TextInputPrimitive = void 0;
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const MaterialIcons_1 = __importDefault(require("@expo/vector-icons/MaterialIcons"));
|
|
42
|
+
const React = __importStar(require("react"));
|
|
43
|
+
const react_native_1 = require("react-native");
|
|
44
|
+
const zkit_tools_1 = require("zkit-tools");
|
|
45
|
+
const useI18n_1 = require("../../i18n/useI18n");
|
|
46
|
+
const useTheme_1 = require("../../theme/useTheme");
|
|
47
|
+
const Text_1 = require("../Text");
|
|
48
|
+
const TextInputPrimitive_1 = require("./TextInputPrimitive");
|
|
49
|
+
var TextInputPrimitive_2 = require("./TextInputPrimitive");
|
|
50
|
+
Object.defineProperty(exports, "TextInputPrimitive", { enumerable: true, get: function () { return TextInputPrimitive_2.TextInputPrimitive; } });
|
|
51
|
+
const SEMANTIC_COLORS = {
|
|
52
|
+
danger: '#DC2626',
|
|
53
|
+
error: '#DC2626',
|
|
54
|
+
info: '#2563EB',
|
|
55
|
+
success: '#16A34A',
|
|
56
|
+
warn: '#D97706',
|
|
57
|
+
warning: '#D97706',
|
|
58
|
+
};
|
|
59
|
+
const SIZE_TOKENS = {
|
|
60
|
+
sm: {
|
|
61
|
+
minHeight: 40,
|
|
62
|
+
paddingHorizontal: 12,
|
|
63
|
+
paddingVertical: 8,
|
|
64
|
+
gap: 8,
|
|
65
|
+
radius: 10,
|
|
66
|
+
textSize: 14,
|
|
67
|
+
textLineHeight: 20,
|
|
68
|
+
clearButtonSize: 26,
|
|
69
|
+
clearIconSize: 16,
|
|
70
|
+
},
|
|
71
|
+
md: {
|
|
72
|
+
minHeight: 48,
|
|
73
|
+
paddingHorizontal: 14,
|
|
74
|
+
paddingVertical: 10,
|
|
75
|
+
gap: 10,
|
|
76
|
+
radius: 12,
|
|
77
|
+
textSize: 15,
|
|
78
|
+
textLineHeight: 21,
|
|
79
|
+
clearButtonSize: 28,
|
|
80
|
+
clearIconSize: 17,
|
|
81
|
+
},
|
|
82
|
+
lg: {
|
|
83
|
+
minHeight: 56,
|
|
84
|
+
paddingHorizontal: 16,
|
|
85
|
+
paddingVertical: 12,
|
|
86
|
+
gap: 10,
|
|
87
|
+
radius: 14,
|
|
88
|
+
textSize: 16,
|
|
89
|
+
textLineHeight: 22,
|
|
90
|
+
clearButtonSize: 30,
|
|
91
|
+
clearIconSize: 18,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const WEB_INPUT_RESET_STYLE = react_native_1.Platform.OS === 'web'
|
|
95
|
+
? {
|
|
96
|
+
outlineStyle: 'solid',
|
|
97
|
+
outlineWidth: 0,
|
|
98
|
+
}
|
|
99
|
+
: null;
|
|
100
|
+
const IS_IOS = react_native_1.Platform.OS === 'ios';
|
|
101
|
+
const IS_WEB = react_native_1.Platform.OS === 'web';
|
|
102
|
+
function isPrimitiveNode(node) {
|
|
103
|
+
return typeof node === 'string' || typeof node === 'number';
|
|
104
|
+
}
|
|
105
|
+
function extractReadableText(node) {
|
|
106
|
+
if (node == null || typeof node === 'boolean')
|
|
107
|
+
return undefined;
|
|
108
|
+
if (isPrimitiveNode(node))
|
|
109
|
+
return String(node);
|
|
110
|
+
if (Array.isArray(node)) {
|
|
111
|
+
const text = node
|
|
112
|
+
.map((item) => extractReadableText(item))
|
|
113
|
+
.filter(Boolean)
|
|
114
|
+
.join(' ')
|
|
115
|
+
.trim();
|
|
116
|
+
return text || undefined;
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
function isProcessableColor(color) {
|
|
121
|
+
return (0, react_native_1.processColor)(color) != null;
|
|
122
|
+
}
|
|
123
|
+
function colorToRgba(color, alpha) {
|
|
124
|
+
const processed = (0, react_native_1.processColor)(color);
|
|
125
|
+
if (typeof processed !== 'number')
|
|
126
|
+
return undefined;
|
|
127
|
+
const normalized = processed >>> 0;
|
|
128
|
+
const r = (normalized >> 16) & 255;
|
|
129
|
+
const g = (normalized >> 8) & 255;
|
|
130
|
+
const b = normalized & 255;
|
|
131
|
+
const a = Math.max(0, Math.min(1, alpha));
|
|
132
|
+
return `rgba(${r},${g},${b},${a})`;
|
|
133
|
+
}
|
|
134
|
+
function resolveColorToken(input, fallback, theme) {
|
|
135
|
+
var _a;
|
|
136
|
+
if (input == null)
|
|
137
|
+
return fallback;
|
|
138
|
+
const key = input.trim();
|
|
139
|
+
if (!key)
|
|
140
|
+
return fallback;
|
|
141
|
+
const resolved = key === 'primary'
|
|
142
|
+
? theme.colors.primary
|
|
143
|
+
: key === 'onPrimary'
|
|
144
|
+
? theme.colors.onPrimary
|
|
145
|
+
: key === 'secondary' || key === 'neutral'
|
|
146
|
+
? theme.colors.secondary
|
|
147
|
+
: key === 'onSecondary'
|
|
148
|
+
? theme.colors.onSecondary
|
|
149
|
+
: key === 'surface'
|
|
150
|
+
? theme.colors.surface
|
|
151
|
+
: key === 'onSurface'
|
|
152
|
+
? theme.colors.onSurface
|
|
153
|
+
: key === 'border'
|
|
154
|
+
? theme.colors.border
|
|
155
|
+
: key === 'muted'
|
|
156
|
+
? theme.colors.muted
|
|
157
|
+
: key === 'disabled'
|
|
158
|
+
? theme.colors.disabled
|
|
159
|
+
: (_a = SEMANTIC_COLORS[key]) !== null && _a !== void 0 ? _a : key;
|
|
160
|
+
return isProcessableColor(resolved) ? resolved : fallback;
|
|
161
|
+
}
|
|
162
|
+
function resolveToneAccent(tone, theme) {
|
|
163
|
+
if (tone === 'neutral')
|
|
164
|
+
return theme.colors.onSurface;
|
|
165
|
+
if (tone === 'success')
|
|
166
|
+
return SEMANTIC_COLORS.success;
|
|
167
|
+
if (tone === 'warning')
|
|
168
|
+
return SEMANTIC_COLORS.warning;
|
|
169
|
+
if (tone === 'danger')
|
|
170
|
+
return SEMANTIC_COLORS.danger;
|
|
171
|
+
if (tone === 'info')
|
|
172
|
+
return SEMANTIC_COLORS.info;
|
|
173
|
+
return theme.colors.primary;
|
|
174
|
+
}
|
|
175
|
+
function resolveMetrics(size, layout) {
|
|
176
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
177
|
+
const token = (_a = SIZE_TOKENS[size]) !== null && _a !== void 0 ? _a : SIZE_TOKENS.md;
|
|
178
|
+
return {
|
|
179
|
+
minHeight: (_b = layout === null || layout === void 0 ? void 0 : layout.minHeight) !== null && _b !== void 0 ? _b : (0, zkit_tools_1.wp)(token.minHeight),
|
|
180
|
+
paddingHorizontal: (_c = layout === null || layout === void 0 ? void 0 : layout.paddingHorizontal) !== null && _c !== void 0 ? _c : (0, zkit_tools_1.wp)(token.paddingHorizontal),
|
|
181
|
+
paddingVertical: (_d = layout === null || layout === void 0 ? void 0 : layout.paddingVertical) !== null && _d !== void 0 ? _d : (0, zkit_tools_1.wp)(token.paddingVertical),
|
|
182
|
+
gap: (_e = layout === null || layout === void 0 ? void 0 : layout.gap) !== null && _e !== void 0 ? _e : (0, zkit_tools_1.wp)(token.gap),
|
|
183
|
+
radius: (_f = layout === null || layout === void 0 ? void 0 : layout.radius) !== null && _f !== void 0 ? _f : (0, zkit_tools_1.wp)(token.radius),
|
|
184
|
+
textSize: (_g = layout === null || layout === void 0 ? void 0 : layout.textSize) !== null && _g !== void 0 ? _g : (0, zkit_tools_1.wp)(token.textSize),
|
|
185
|
+
textLineHeight: (_h = layout === null || layout === void 0 ? void 0 : layout.textLineHeight) !== null && _h !== void 0 ? _h : (0, zkit_tools_1.wp)(token.textLineHeight),
|
|
186
|
+
clearButtonSize: (0, zkit_tools_1.wp)(token.clearButtonSize),
|
|
187
|
+
clearIconSize: (0, zkit_tools_1.wp)(token.clearIconSize),
|
|
188
|
+
borderWidth: (0, zkit_tools_1.wp)(1),
|
|
189
|
+
labelGap: (0, zkit_tools_1.wp)(6),
|
|
190
|
+
messageGap: (0, zkit_tools_1.wp)(6),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function normalizeRows(value, fallback) {
|
|
194
|
+
if (value == null)
|
|
195
|
+
return fallback;
|
|
196
|
+
if (!Number.isFinite(value))
|
|
197
|
+
return fallback;
|
|
198
|
+
return Math.max(1, Math.round(value));
|
|
199
|
+
}
|
|
200
|
+
function resolveVisualColors({ colors, disabled, status, theme, variant, }) {
|
|
201
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
202
|
+
const subtleSurface = (_a = colorToRgba(theme.colors.onSurface, 0.04)) !== null && _a !== void 0 ? _a : theme.colors.secondary;
|
|
203
|
+
const statusColor = status === 'error'
|
|
204
|
+
? (_b = colors === null || colors === void 0 ? void 0 : colors.error) !== null && _b !== void 0 ? _b : SEMANTIC_COLORS.danger
|
|
205
|
+
: status === 'warning'
|
|
206
|
+
? (_c = colors === null || colors === void 0 ? void 0 : colors.warning) !== null && _c !== void 0 ? _c : SEMANTIC_COLORS.warning
|
|
207
|
+
: status === 'success'
|
|
208
|
+
? (_d = colors === null || colors === void 0 ? void 0 : colors.success) !== null && _d !== void 0 ? _d : SEMANTIC_COLORS.success
|
|
209
|
+
: undefined;
|
|
210
|
+
const baseBackground = variant === 'plain'
|
|
211
|
+
? 'transparent'
|
|
212
|
+
: variant === 'filled'
|
|
213
|
+
? subtleSurface
|
|
214
|
+
: theme.colors.surface;
|
|
215
|
+
const baseBorder = variant === 'plain' ? 'transparent' : theme.colors.border;
|
|
216
|
+
const borderColor = (_e = statusColor !== null && statusColor !== void 0 ? statusColor : colors === null || colors === void 0 ? void 0 : colors.border) !== null && _e !== void 0 ? _e : baseBorder;
|
|
217
|
+
if (disabled) {
|
|
218
|
+
return {
|
|
219
|
+
backgroundColor: (_f = colors === null || colors === void 0 ? void 0 : colors.disabledBackground) !== null && _f !== void 0 ? _f : (variant === 'plain' ? 'transparent' : subtleSurface),
|
|
220
|
+
borderColor: (_g = colors === null || colors === void 0 ? void 0 : colors.disabledBorder) !== null && _g !== void 0 ? _g : (variant === 'plain' ? 'transparent' : theme.colors.border),
|
|
221
|
+
textColor: (_h = colors === null || colors === void 0 ? void 0 : colors.disabledText) !== null && _h !== void 0 ? _h : theme.colors.disabled,
|
|
222
|
+
placeholderColor: (_j = colors === null || colors === void 0 ? void 0 : colors.placeholder) !== null && _j !== void 0 ? _j : theme.colors.disabled,
|
|
223
|
+
labelColor: (_k = colors === null || colors === void 0 ? void 0 : colors.label) !== null && _k !== void 0 ? _k : theme.colors.disabled,
|
|
224
|
+
messageColor: (_l = colors === null || colors === void 0 ? void 0 : colors.description) !== null && _l !== void 0 ? _l : theme.colors.disabled,
|
|
225
|
+
countColor: (_m = colors === null || colors === void 0 ? void 0 : colors.description) !== null && _m !== void 0 ? _m : theme.colors.disabled,
|
|
226
|
+
iconColor: (_o = colors === null || colors === void 0 ? void 0 : colors.icon) !== null && _o !== void 0 ? _o : theme.colors.disabled,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
backgroundColor: (_p = colors === null || colors === void 0 ? void 0 : colors.background) !== null && _p !== void 0 ? _p : baseBackground,
|
|
231
|
+
borderColor,
|
|
232
|
+
textColor: (_q = colors === null || colors === void 0 ? void 0 : colors.text) !== null && _q !== void 0 ? _q : theme.colors.onSurface,
|
|
233
|
+
placeholderColor: (_r = colors === null || colors === void 0 ? void 0 : colors.placeholder) !== null && _r !== void 0 ? _r : theme.colors.muted,
|
|
234
|
+
labelColor: (_s = colors === null || colors === void 0 ? void 0 : colors.label) !== null && _s !== void 0 ? _s : theme.colors.onSurface,
|
|
235
|
+
messageColor: (_t = statusColor !== null && statusColor !== void 0 ? statusColor : colors === null || colors === void 0 ? void 0 : colors.description) !== null && _t !== void 0 ? _t : theme.colors.muted,
|
|
236
|
+
countColor: (_u = colors === null || colors === void 0 ? void 0 : colors.description) !== null && _u !== void 0 ? _u : theme.colors.muted,
|
|
237
|
+
iconColor: (_v = colors === null || colors === void 0 ? void 0 : colors.icon) !== null && _v !== void 0 ? _v : theme.colors.muted,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function renderTextNode(node, props) {
|
|
241
|
+
if (node == null || typeof node === 'boolean')
|
|
242
|
+
return null;
|
|
243
|
+
if (isPrimitiveNode(node)) {
|
|
244
|
+
return (0, jsx_runtime_1.jsx)(Text_1.Text, { ...props, children: node });
|
|
245
|
+
}
|
|
246
|
+
return node;
|
|
247
|
+
}
|
|
248
|
+
function renderAffix(node, color, style, textSize, lineHeight) {
|
|
249
|
+
if (node == null || typeof node === 'boolean')
|
|
250
|
+
return null;
|
|
251
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { pointerEvents: "box-none", style: [styles.affix, style], children: isPrimitiveNode(node) ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { numberOfLines: 1, style: [
|
|
252
|
+
styles.affixText,
|
|
253
|
+
{
|
|
254
|
+
color,
|
|
255
|
+
fontSize: textSize,
|
|
256
|
+
lineHeight,
|
|
257
|
+
},
|
|
258
|
+
], children: node })) : (node) }));
|
|
259
|
+
}
|
|
260
|
+
function assignRef(ref, value) {
|
|
261
|
+
if (typeof ref === 'function') {
|
|
262
|
+
ref(value);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (ref) {
|
|
266
|
+
ref.current = value;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const TextInputBase = React.forwardRef(function TextInput({ value, defaultValue = '', onChange, onNativeChange, onSubmit, disabled = false, readOnly = false, required = false, invalid, variant = 'outline', tone = 'primary', status = 'default', size = 'md', color, colors, layout, label, labelAction, description, error, prefix, suffix, clearable = false, clearIcon, clearAccessibilityLabel, onClear, minRows, maxRows, showCount = false, renderCount, style, fieldStyle, inputStyle, labelStyle, descriptionStyle, errorStyle, countStyle, prefixStyle, suffixStyle, clearButtonStyle, maxFontSizeMultiplier, placeholderTextColor, selectionColor, cursorColor, selectionHandleColor, onBlur, onFocus, onSubmitEditing, accessibilityLabel, accessibilityHint, accessibilityState, maxLength, multiline = false, numberOfLines, testID, underlineColorAndroid, ...nativeProps }, forwardedRef) {
|
|
270
|
+
var _a, _b, _c;
|
|
271
|
+
const theme = (0, useTheme_1.useTheme)();
|
|
272
|
+
const { t } = (0, useI18n_1.useI18n)();
|
|
273
|
+
const inputRef = React.useRef(null);
|
|
274
|
+
const isControlled = value !== undefined;
|
|
275
|
+
const initialValueRef = React.useRef(defaultValue);
|
|
276
|
+
const currentValueRef = React.useRef(isControlled ? value !== null && value !== void 0 ? value : '' : initialValueRef.current);
|
|
277
|
+
const shouldTrackValue = clearable || showCount || renderCount != null;
|
|
278
|
+
const hasSyncedUncontrolledValueRef = React.useRef(false);
|
|
279
|
+
const [, scheduleValueRender] = React.useReducer((revision) => revision + 1, 0);
|
|
280
|
+
if (isControlled) {
|
|
281
|
+
currentValueRef.current = value !== null && value !== void 0 ? value : '';
|
|
282
|
+
}
|
|
283
|
+
const shouldSyncUncontrolledValue = !isControlled && (shouldTrackValue || hasSyncedUncontrolledValueRef.current);
|
|
284
|
+
React.useEffect(() => {
|
|
285
|
+
if (!isControlled && shouldTrackValue) {
|
|
286
|
+
hasSyncedUncontrolledValueRef.current = true;
|
|
287
|
+
}
|
|
288
|
+
}, [isControlled, shouldTrackValue]);
|
|
289
|
+
const setInputRef = React.useCallback((node) => {
|
|
290
|
+
inputRef.current = node;
|
|
291
|
+
assignRef(forwardedRef, node);
|
|
292
|
+
}, [forwardedRef]);
|
|
293
|
+
const interactive = !disabled && !readOnly;
|
|
294
|
+
const resolvedStatus = error != null || invalid ? 'error' : status;
|
|
295
|
+
const metrics = React.useMemo(() => resolveMetrics(size, layout), [layout, size]);
|
|
296
|
+
const accentColor = React.useMemo(() => resolveColorToken(color, resolveToneAccent(tone, theme), theme), [color, theme, tone]);
|
|
297
|
+
const visualColors = React.useMemo(() => resolveVisualColors({
|
|
298
|
+
colors,
|
|
299
|
+
disabled,
|
|
300
|
+
status: resolvedStatus,
|
|
301
|
+
theme,
|
|
302
|
+
variant,
|
|
303
|
+
}), [colors, disabled, resolvedStatus, theme, variant]);
|
|
304
|
+
const displayValue = isControlled ? value !== null && value !== void 0 ? value : '' : currentValueRef.current;
|
|
305
|
+
const nativeValue = isControlled || shouldSyncUncontrolledValue ? displayValue : undefined;
|
|
306
|
+
const nativeDefaultValue = !isControlled && !shouldSyncUncontrolledValue ? initialValueRef.current : undefined;
|
|
307
|
+
const hasValue = displayValue.length > 0;
|
|
308
|
+
const count = displayValue.length;
|
|
309
|
+
const resolvedMinRows = multiline
|
|
310
|
+
? normalizeRows(minRows !== null && minRows !== void 0 ? minRows : numberOfLines, 3)
|
|
311
|
+
: 1;
|
|
312
|
+
const resolvedMaxRows = multiline && maxRows != null
|
|
313
|
+
? Math.max(resolvedMinRows, normalizeRows(maxRows, resolvedMinRows))
|
|
314
|
+
: undefined;
|
|
315
|
+
const inputMinHeight = metrics.textLineHeight * resolvedMinRows;
|
|
316
|
+
const inputMaxHeight = resolvedMaxRows == null ? undefined : metrics.textLineHeight * resolvedMaxRows;
|
|
317
|
+
const fieldPaddingHorizontal = variant === 'plain' ? 0 : metrics.paddingHorizontal;
|
|
318
|
+
const fieldPaddingVertical = variant === 'plain' ? 0 : metrics.paddingVertical;
|
|
319
|
+
const fieldBorderWidth = variant === 'plain' ? 0 : metrics.borderWidth;
|
|
320
|
+
const fieldMinHeight = Math.max(metrics.minHeight, inputMinHeight + fieldPaddingVertical * 2 + fieldBorderWidth * 2);
|
|
321
|
+
const singleLineInputHeight = Math.max(metrics.textLineHeight, fieldMinHeight - fieldPaddingVertical * 2 - fieldBorderWidth * 2);
|
|
322
|
+
const fieldMaxHeight = (_a = layout === null || layout === void 0 ? void 0 : layout.maxHeight) !== null && _a !== void 0 ? _a : (inputMaxHeight == null
|
|
323
|
+
? undefined
|
|
324
|
+
: inputMaxHeight + fieldPaddingVertical * 2 + fieldBorderWidth * 2);
|
|
325
|
+
const rootSizeStyle = React.useMemo(() => ({
|
|
326
|
+
...((layout === null || layout === void 0 ? void 0 : layout.width) !== undefined ? { width: layout.width } : undefined),
|
|
327
|
+
...((layout === null || layout === void 0 ? void 0 : layout.minWidth) !== undefined ? { minWidth: layout.minWidth } : undefined),
|
|
328
|
+
...((layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== undefined ? { maxWidth: layout.maxWidth } : undefined),
|
|
329
|
+
}), [layout === null || layout === void 0 ? void 0 : layout.maxWidth, layout === null || layout === void 0 ? void 0 : layout.minWidth, layout === null || layout === void 0 ? void 0 : layout.width]);
|
|
330
|
+
const fieldSizeStyle = React.useMemo(() => ({
|
|
331
|
+
...((layout === null || layout === void 0 ? void 0 : layout.height) !== undefined
|
|
332
|
+
? { height: layout.height }
|
|
333
|
+
: multiline
|
|
334
|
+
? undefined
|
|
335
|
+
: { height: fieldMinHeight }),
|
|
336
|
+
...(multiline && fieldMaxHeight !== undefined ? { maxHeight: fieldMaxHeight } : undefined),
|
|
337
|
+
minHeight: fieldMinHeight,
|
|
338
|
+
paddingHorizontal: fieldPaddingHorizontal,
|
|
339
|
+
paddingVertical: fieldPaddingVertical,
|
|
340
|
+
}), [
|
|
341
|
+
fieldMaxHeight,
|
|
342
|
+
fieldMinHeight,
|
|
343
|
+
fieldPaddingHorizontal,
|
|
344
|
+
fieldPaddingVertical,
|
|
345
|
+
layout === null || layout === void 0 ? void 0 : layout.height,
|
|
346
|
+
multiline,
|
|
347
|
+
]);
|
|
348
|
+
const fieldVisualStyle = React.useMemo(() => ({
|
|
349
|
+
alignItems: multiline ? 'flex-start' : 'center',
|
|
350
|
+
backgroundColor: visualColors.backgroundColor,
|
|
351
|
+
borderColor: visualColors.borderColor,
|
|
352
|
+
borderRadius: variant === 'plain' ? 0 : metrics.radius,
|
|
353
|
+
borderWidth: fieldBorderWidth,
|
|
354
|
+
gap: metrics.gap,
|
|
355
|
+
}), [
|
|
356
|
+
fieldBorderWidth,
|
|
357
|
+
metrics.gap,
|
|
358
|
+
metrics.radius,
|
|
359
|
+
multiline,
|
|
360
|
+
variant,
|
|
361
|
+
visualColors.backgroundColor,
|
|
362
|
+
visualColors.borderColor,
|
|
363
|
+
]);
|
|
364
|
+
const inputBaseStyle = React.useMemo(() => ({
|
|
365
|
+
backgroundColor: 'transparent',
|
|
366
|
+
borderWidth: 0,
|
|
367
|
+
color: visualColors.textColor,
|
|
368
|
+
fontSize: metrics.textSize,
|
|
369
|
+
includeFontPadding: false,
|
|
370
|
+
lineHeight: IS_IOS && !multiline ? undefined : metrics.textLineHeight,
|
|
371
|
+
maxHeight: multiline ? inputMaxHeight : undefined,
|
|
372
|
+
minHeight: multiline ? inputMinHeight : singleLineInputHeight,
|
|
373
|
+
padding: 0,
|
|
374
|
+
paddingBottom: 0,
|
|
375
|
+
paddingHorizontal: 0,
|
|
376
|
+
paddingTop: 0,
|
|
377
|
+
paddingVertical: 0,
|
|
378
|
+
textAlignVertical: multiline ? 'top' : 'center',
|
|
379
|
+
}), [
|
|
380
|
+
inputMaxHeight,
|
|
381
|
+
inputMinHeight,
|
|
382
|
+
metrics.textLineHeight,
|
|
383
|
+
metrics.textSize,
|
|
384
|
+
multiline,
|
|
385
|
+
singleLineInputHeight,
|
|
386
|
+
visualColors.textColor,
|
|
387
|
+
]);
|
|
388
|
+
const finalSelectionColor = selectionColor !== null && selectionColor !== void 0 ? selectionColor : accentColor;
|
|
389
|
+
const finalCursorColor = cursorColor !== null && cursorColor !== void 0 ? cursorColor : finalSelectionColor;
|
|
390
|
+
const finalHandleColor = selectionHandleColor !== null && selectionHandleColor !== void 0 ? selectionHandleColor : finalSelectionColor;
|
|
391
|
+
const webCaretStyle = React.useMemo(() => (IS_WEB ? { caretColor: finalCursorColor } : null), [finalCursorColor]);
|
|
392
|
+
const computedAccessibilityLabel = (_b = accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : extractReadableText(label)) !== null && _b !== void 0 ? _b : nativeProps.placeholder;
|
|
393
|
+
const computedAccessibilityHint = accessibilityHint !== null && accessibilityHint !== void 0 ? accessibilityHint : extractReadableText(resolvedStatus === 'error' ? error : description);
|
|
394
|
+
const finalClearAccessibilityLabel = clearAccessibilityLabel !== null && clearAccessibilityLabel !== void 0 ? clearAccessibilityLabel : t('textInput.clear');
|
|
395
|
+
const commitValue = React.useCallback((nextValue) => {
|
|
396
|
+
currentValueRef.current = nextValue;
|
|
397
|
+
if (shouldSyncUncontrolledValue) {
|
|
398
|
+
scheduleValueRender();
|
|
399
|
+
}
|
|
400
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue);
|
|
401
|
+
}, [onChange, shouldSyncUncontrolledValue]);
|
|
402
|
+
const handleChangeText = React.useCallback((nextValue) => {
|
|
403
|
+
commitValue(nextValue);
|
|
404
|
+
}, [commitValue]);
|
|
405
|
+
const handleNativeChange = React.useCallback((event) => {
|
|
406
|
+
onNativeChange === null || onNativeChange === void 0 ? void 0 : onNativeChange(event);
|
|
407
|
+
}, [onNativeChange]);
|
|
408
|
+
const handleFocus = React.useCallback((event) => {
|
|
409
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
410
|
+
}, [onFocus]);
|
|
411
|
+
const handleBlur = React.useCallback((event) => {
|
|
412
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
413
|
+
}, [onBlur]);
|
|
414
|
+
const handleSubmitEditing = React.useCallback((event) => {
|
|
415
|
+
onSubmitEditing === null || onSubmitEditing === void 0 ? void 0 : onSubmitEditing(event);
|
|
416
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(currentValueRef.current, event);
|
|
417
|
+
}, [onSubmit, onSubmitEditing]);
|
|
418
|
+
const handleClear = React.useCallback((event) => {
|
|
419
|
+
var _a, _b;
|
|
420
|
+
event.preventDefault();
|
|
421
|
+
if (!interactive)
|
|
422
|
+
return;
|
|
423
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.clear();
|
|
424
|
+
commitValue('');
|
|
425
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
426
|
+
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
427
|
+
}, [commitValue, interactive, onClear]);
|
|
428
|
+
const labelNode = renderTextNode(label, {
|
|
429
|
+
variant: 'label',
|
|
430
|
+
color: visualColors.labelColor,
|
|
431
|
+
weight: 'semibold',
|
|
432
|
+
style: [styles.labelText, labelStyle],
|
|
433
|
+
});
|
|
434
|
+
const messageNode = resolvedStatus === 'error' && error != null
|
|
435
|
+
? renderTextNode(error, {
|
|
436
|
+
variant: 'caption',
|
|
437
|
+
color: visualColors.messageColor,
|
|
438
|
+
style: [styles.messageText, errorStyle],
|
|
439
|
+
})
|
|
440
|
+
: renderTextNode(description, {
|
|
441
|
+
variant: 'caption',
|
|
442
|
+
color: visualColors.messageColor,
|
|
443
|
+
style: [styles.messageText, descriptionStyle],
|
|
444
|
+
});
|
|
445
|
+
const countNode = showCount || renderCount
|
|
446
|
+
? renderTextNode((_c = renderCount === null || renderCount === void 0 ? void 0 : renderCount({ count, maxLength })) !== null && _c !== void 0 ? _c : (maxLength != null ? `${count}/${maxLength}` : String(count)), {
|
|
447
|
+
variant: 'caption',
|
|
448
|
+
color: visualColors.countColor,
|
|
449
|
+
style: [styles.countText, countStyle],
|
|
450
|
+
})
|
|
451
|
+
: null;
|
|
452
|
+
const prefixNode = renderAffix(prefix, visualColors.iconColor, prefixStyle, metrics.textSize, metrics.textLineHeight);
|
|
453
|
+
const suffixNode = renderAffix(suffix, visualColors.iconColor, suffixStyle, metrics.textSize, metrics.textLineHeight);
|
|
454
|
+
const showClearButton = clearable && interactive && hasValue;
|
|
455
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.root, rootSizeStyle, style], children: [labelNode || labelAction ? ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.labelRow, { marginBottom: metrics.labelGap }], children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.labelContent, children: [labelNode, required && labelNode ? ((0, jsx_runtime_1.jsx)(Text_1.Text, { accessibilityElementsHidden: true, tone: "danger", importantForAccessibility: "no", style: styles.requiredMark, children: "*" })) : null] }), labelAction ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.labelAction, children: labelAction }) : null] })) : null, (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.field, fieldSizeStyle, fieldVisualStyle, fieldStyle], children: [prefixNode, (0, jsx_runtime_1.jsx)(TextInputPrimitive_1.TextInputPrimitive, { ref: setInputRef, ...nativeProps, accessibilityHint: computedAccessibilityHint, accessibilityLabel: computedAccessibilityLabel, accessibilityState: {
|
|
456
|
+
...accessibilityState,
|
|
457
|
+
disabled,
|
|
458
|
+
}, cursorColor: finalCursorColor, defaultValue: nativeDefaultValue, editable: interactive, maxFontSizeMultiplier: maxFontSizeMultiplier, maxLength: maxLength, multiline: multiline, numberOfLines: multiline ? resolvedMinRows : numberOfLines, onBlur: handleBlur, onChange: handleNativeChange, onChangeText: handleChangeText, onFocus: handleFocus, onSubmitEditing: handleSubmitEditing, placeholderTextColor: placeholderTextColor !== null && placeholderTextColor !== void 0 ? placeholderTextColor : visualColors.placeholderColor, readOnly: readOnly || disabled, selectionColor: finalSelectionColor, selectionHandleColor: finalHandleColor, style: [styles.input, inputBaseStyle, WEB_INPUT_RESET_STYLE, webCaretStyle, inputStyle], testID: testID, underlineColorAndroid: underlineColorAndroid !== null && underlineColorAndroid !== void 0 ? underlineColorAndroid : 'transparent', value: nativeValue }), showClearButton ? ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityLabel: finalClearAccessibilityLabel, accessibilityRole: "button", hitSlop: {
|
|
459
|
+
bottom: (0, zkit_tools_1.wp)(8),
|
|
460
|
+
left: (0, zkit_tools_1.wp)(8),
|
|
461
|
+
right: (0, zkit_tools_1.wp)(8),
|
|
462
|
+
top: (0, zkit_tools_1.wp)(8),
|
|
463
|
+
}, onPress: handleClear, style: [
|
|
464
|
+
styles.clearButton,
|
|
465
|
+
{
|
|
466
|
+
height: metrics.clearButtonSize,
|
|
467
|
+
width: metrics.clearButtonSize,
|
|
468
|
+
},
|
|
469
|
+
clearButtonStyle,
|
|
470
|
+
], children: clearIcon !== null && clearIcon !== void 0 ? clearIcon : ((0, jsx_runtime_1.jsx)(MaterialIcons_1.default, { color: visualColors.iconColor, name: "close", size: metrics.clearIconSize })) })) : null, suffixNode] }), messageNode || countNode ? ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.footerRow, { marginTop: metrics.messageGap }], children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.messageSlot, children: messageNode }), countNode ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.countSlot, children: countNode }) : null] })) : null] }));
|
|
471
|
+
});
|
|
472
|
+
TextInputBase.displayName = 'TextInput';
|
|
473
|
+
exports.TextInput = Object.assign(TextInputBase, { State: TextInputPrimitive_1.TextInputPrimitive.State });
|
|
474
|
+
const styles = react_native_1.StyleSheet.create({
|
|
475
|
+
root: {
|
|
476
|
+
width: '100%',
|
|
477
|
+
},
|
|
478
|
+
labelRow: {
|
|
479
|
+
alignItems: 'center',
|
|
480
|
+
flexDirection: 'row',
|
|
481
|
+
justifyContent: 'space-between',
|
|
482
|
+
},
|
|
483
|
+
labelContent: {
|
|
484
|
+
alignItems: 'center',
|
|
485
|
+
flex: 1,
|
|
486
|
+
flexDirection: 'row',
|
|
487
|
+
minWidth: 0,
|
|
488
|
+
},
|
|
489
|
+
labelText: {
|
|
490
|
+
flexShrink: 1,
|
|
491
|
+
},
|
|
492
|
+
requiredMark: {
|
|
493
|
+
fontSize: (0, zkit_tools_1.wp)(13),
|
|
494
|
+
fontWeight: '700',
|
|
495
|
+
lineHeight: (0, zkit_tools_1.wp)(18),
|
|
496
|
+
marginLeft: (0, zkit_tools_1.wp)(3),
|
|
497
|
+
},
|
|
498
|
+
labelAction: {
|
|
499
|
+
flexShrink: 0,
|
|
500
|
+
marginLeft: (0, zkit_tools_1.wp)(12),
|
|
501
|
+
},
|
|
502
|
+
field: {
|
|
503
|
+
flexDirection: 'row',
|
|
504
|
+
overflow: 'hidden',
|
|
505
|
+
},
|
|
506
|
+
input: {
|
|
507
|
+
flex: 1,
|
|
508
|
+
margin: 0,
|
|
509
|
+
minWidth: 0,
|
|
510
|
+
},
|
|
511
|
+
affix: {
|
|
512
|
+
alignItems: 'center',
|
|
513
|
+
flexShrink: 0,
|
|
514
|
+
justifyContent: 'center',
|
|
515
|
+
minHeight: (0, zkit_tools_1.wp)(24),
|
|
516
|
+
},
|
|
517
|
+
affixText: {
|
|
518
|
+
fontWeight: '500',
|
|
519
|
+
},
|
|
520
|
+
clearButton: {
|
|
521
|
+
alignItems: 'center',
|
|
522
|
+
borderRadius: (0, zkit_tools_1.wp)(999),
|
|
523
|
+
flexShrink: 0,
|
|
524
|
+
justifyContent: 'center',
|
|
525
|
+
},
|
|
526
|
+
footerRow: {
|
|
527
|
+
alignItems: 'flex-start',
|
|
528
|
+
flexDirection: 'row',
|
|
529
|
+
justifyContent: 'space-between',
|
|
530
|
+
},
|
|
531
|
+
messageSlot: {
|
|
532
|
+
flex: 1,
|
|
533
|
+
minWidth: 0,
|
|
534
|
+
},
|
|
535
|
+
messageText: {
|
|
536
|
+
flexShrink: 1,
|
|
537
|
+
},
|
|
538
|
+
countSlot: {
|
|
539
|
+
flexShrink: 0,
|
|
540
|
+
marginLeft: (0, zkit_tools_1.wp)(12),
|
|
541
|
+
},
|
|
542
|
+
countText: {
|
|
543
|
+
textAlign: 'right',
|
|
544
|
+
},
|
|
545
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ColorValue, type NativeSyntheticEvent, type ViewProps } from 'react-native';
|
|
3
|
+
export type ZKitWheelPickerValue = string | number;
|
|
4
|
+
export type ZKitWheelPickerItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: ZKitWheelPickerValue;
|
|
7
|
+
textColor?: ColorValue;
|
|
8
|
+
testID?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ZKitWheelPickerChangeEvent = {
|
|
11
|
+
newIndex: number;
|
|
12
|
+
newValue: ZKitWheelPickerValue | null;
|
|
13
|
+
};
|
|
14
|
+
export type ZKitWheelPickerProps = ViewProps & {
|
|
15
|
+
items: ZKitWheelPickerItem[];
|
|
16
|
+
selectedIndex: number;
|
|
17
|
+
color?: ColorValue;
|
|
18
|
+
fontFamily?: string;
|
|
19
|
+
fontSize?: number;
|
|
20
|
+
fontStyle?: string;
|
|
21
|
+
fontWeight?: string;
|
|
22
|
+
numberOfLines?: number;
|
|
23
|
+
rowHeight?: number;
|
|
24
|
+
onChange?: (event: NativeSyntheticEvent<ZKitWheelPickerChangeEvent>) => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const ZKitWheelPicker: React.ForwardRefExoticComponent<ViewProps & {
|
|
27
|
+
items: ZKitWheelPickerItem[];
|
|
28
|
+
selectedIndex: number;
|
|
29
|
+
color?: ColorValue;
|
|
30
|
+
fontFamily?: string;
|
|
31
|
+
fontSize?: number;
|
|
32
|
+
fontStyle?: string;
|
|
33
|
+
fontWeight?: string;
|
|
34
|
+
numberOfLines?: number;
|
|
35
|
+
rowHeight?: number;
|
|
36
|
+
onChange?: (event: NativeSyntheticEvent<ZKitWheelPickerChangeEvent>) => void;
|
|
37
|
+
} & React.RefAttributes<React.Component<ZKitWheelPickerProps, {}, any> & import("react-native").NativeMethods>>;
|
|
38
|
+
export declare function syncZKitWheelPickerCurrentSelection(target: unknown): boolean;
|
|
39
|
+
//# sourceMappingURL=ZKitWheelPickerNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZKitWheelPickerNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/WheelColumn/ZKitWheelPickerNativeComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAItB,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,oBAAoB,CAAC;IAC5B,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG;IAC7C,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,KAAK,IAAI,CAAC;CAC9E,CAAC;AAOF,eAAO,MAAM,eAAe;WAjBnB,mBAAmB,EAAE;mBACb,MAAM;YACb,UAAU;iBACL,MAAM;eACR,MAAM;gBACL,MAAM;iBACL,MAAM;oBACH,MAAM;gBACV,MAAM;eACP,CAAC,KAAK,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,KAAK,IAAI;+GAiB5E,CAAC;AAEH,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,OAAO,WAWlE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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.ZKitWheelPicker = void 0;
|
|
37
|
+
exports.syncZKitWheelPickerCurrentSelection = syncZKitWheelPickerCurrentSelection;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
39
|
+
const React = __importStar(require("react"));
|
|
40
|
+
const react_native_1 = require("react-native");
|
|
41
|
+
const COMPONENT_NAME = 'ZKitWheelPicker';
|
|
42
|
+
const NativeZKitWheelPicker = react_native_1.Platform.OS === 'ios' ? (0, react_native_1.requireNativeComponent)(COMPONENT_NAME) : null;
|
|
43
|
+
exports.ZKitWheelPicker = React.forwardRef(function ZKitWheelPicker(props, ref) {
|
|
44
|
+
if (react_native_1.Platform.OS !== 'ios' || NativeZKitWheelPicker == null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (0, jsx_runtime_1.jsx)(NativeZKitWheelPicker, { ...props, ref: ref });
|
|
48
|
+
});
|
|
49
|
+
function syncZKitWheelPickerCurrentSelection(target) {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
if (react_native_1.Platform.OS !== 'ios')
|
|
52
|
+
return false;
|
|
53
|
+
const command = (_b = (_a = react_native_1.UIManager.getViewManagerConfig(COMPONENT_NAME)) === null || _a === void 0 ? void 0 : _a.Commands) === null || _b === void 0 ? void 0 : _b.syncCurrentSelection;
|
|
54
|
+
const handle = (0, react_native_1.findNodeHandle)(target);
|
|
55
|
+
if (command == null || handle == null) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
react_native_1.UIManager.dispatchViewManagerCommand(handle, command, []);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/ui/WheelColumn/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,YAAY,CAAC"}
|