react-native-platform-components 1.2.0 → 1.4.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 +33 -31
- package/android/src/main/java/com/platformcomponents/PCButtonGroupView.kt +498 -0
- package/android/src/main/java/com/platformcomponents/PCButtonGroupViewManager.kt +191 -0
- package/android/src/main/java/com/platformcomponents/PCButtonSupport.kt +127 -0
- package/android/src/main/java/com/platformcomponents/PCButtonView.kt +345 -0
- package/android/src/main/java/com/platformcomponents/PCButtonViewManager.kt +126 -0
- package/android/src/main/java/com/platformcomponents/PCExpressive.kt +107 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarView.kt +115 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarViewManager.kt +65 -0
- package/android/src/main/java/com/platformcomponents/PCNativeThemeModule.kt +3 -0
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlView.kt +13 -5
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlViewManager.kt +6 -1
- package/android/src/main/java/com/platformcomponents/PCTextFieldView.kt +1018 -0
- package/android/src/main/java/com/platformcomponents/PCTextFieldViewManager.kt +248 -0
- package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +13 -6
- package/android/src/main/jni/CMakeLists.txt +13 -1
- package/android/src/main/res/values/attrs.xml +13 -0
- package/android/src/main/res/values/styles.xml +183 -0
- package/ios/PCButton.h +10 -0
- package/ios/PCButton.mm +196 -0
- package/ios/PCButtonGroup.h +10 -0
- package/ios/PCButtonGroup.mm +256 -0
- package/ios/PCButtonGroupView.swift +254 -0
- package/ios/PCButtonSupport.swift +141 -0
- package/ios/PCButtonView.swift +155 -0
- package/ios/PCFloatingToolbar.h +10 -0
- package/ios/PCFloatingToolbar.mm +76 -0
- package/ios/PCFloatingToolbarView.swift +95 -0
- package/ios/PCNativeThemeModule.mm +13 -0
- package/ios/PCSelectionMenu.swift +9 -1
- package/ios/PCTextField.h +10 -0
- package/ios/PCTextField.mm +391 -0
- package/ios/PCTextFieldView.swift +1012 -0
- package/lib/commonjs/Button.js +77 -0
- package/lib/commonjs/Button.js.map +1 -0
- package/lib/commonjs/ButtonGroup.js +99 -0
- package/lib/commonjs/ButtonGroup.js.map +1 -0
- package/lib/commonjs/ButtonGroupNativeComponent.ts +121 -0
- package/lib/commonjs/ButtonNativeComponent.ts +76 -0
- package/lib/commonjs/ContextMenuNativeComponent.ts +5 -4
- package/lib/commonjs/DatePickerNativeComponent.ts +17 -11
- package/lib/commonjs/FloatingToolbar.js +69 -0
- package/lib/commonjs/FloatingToolbar.js.map +1 -0
- package/lib/commonjs/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/commonjs/LiquidGlass.js +24 -4
- package/lib/commonjs/LiquidGlass.js.map +1 -1
- package/lib/commonjs/LiquidGlassNativeComponent.ts +6 -5
- package/lib/commonjs/NativePlatformComponentsTheme.js.map +1 -1
- package/lib/commonjs/SegmentedControl.js +11 -85
- package/lib/commonjs/SegmentedControl.js.map +1 -1
- package/lib/commonjs/SegmentedControlNativeComponent.ts +15 -11
- package/lib/commonjs/SelectionMenuNativeComponent.ts +6 -5
- package/lib/commonjs/TextField.js +195 -0
- package/lib/commonjs/TextField.js.map +1 -0
- package/lib/commonjs/TextFieldNativeComponent.ts +218 -0
- package/lib/commonjs/codegenTypes.js +6 -0
- package/lib/commonjs/codegenTypes.js.map +1 -0
- package/lib/commonjs/focusRegistry.js +78 -0
- package/lib/commonjs/focusRegistry.js.map +1 -0
- package/lib/commonjs/icons.js +92 -0
- package/lib/commonjs/icons.js.map +1 -0
- package/lib/commonjs/index.js +66 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +32 -2
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/labelStyle.js +27 -0
- package/lib/commonjs/labelStyle.js.map +1 -0
- package/lib/commonjs/reactNativeInternals.d.js +2 -0
- package/lib/commonjs/reactNativeInternals.d.js.map +1 -0
- package/lib/module/Button.js +70 -0
- package/lib/module/Button.js.map +1 -0
- package/lib/module/ButtonGroup.js +92 -0
- package/lib/module/ButtonGroup.js.map +1 -0
- package/lib/module/ButtonGroupNativeComponent.ts +121 -0
- package/lib/module/ButtonNativeComponent.ts +76 -0
- package/lib/module/ContextMenuNativeComponent.ts +5 -4
- package/lib/module/DatePickerNativeComponent.ts +17 -11
- package/lib/module/FloatingToolbar.js +62 -0
- package/lib/module/FloatingToolbar.js.map +1 -0
- package/lib/module/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/module/LiquidGlass.js +24 -4
- package/lib/module/LiquidGlass.js.map +1 -1
- package/lib/module/LiquidGlassNativeComponent.ts +6 -5
- package/lib/module/NativePlatformComponentsTheme.js.map +1 -1
- package/lib/module/SegmentedControl.js +12 -87
- package/lib/module/SegmentedControl.js.map +1 -1
- package/lib/module/SegmentedControlNativeComponent.ts +15 -11
- package/lib/module/SelectionMenuNativeComponent.ts +6 -5
- package/lib/module/TextField.js +189 -0
- package/lib/module/TextField.js.map +1 -0
- package/lib/module/TextFieldNativeComponent.ts +218 -0
- package/lib/module/codegenTypes.js +4 -0
- package/lib/module/codegenTypes.js.map +1 -0
- package/lib/module/focusRegistry.js +74 -0
- package/lib/module/focusRegistry.js.map +1 -0
- package/lib/module/icons.js +87 -0
- package/lib/module/icons.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +28 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/labelStyle.js +23 -0
- package/lib/module/labelStyle.js.map +1 -0
- package/lib/module/reactNativeInternals.d.js +2 -0
- package/lib/module/reactNativeInternals.d.js.map +1 -0
- package/lib/typescript/commonjs/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Button.d.ts +76 -0
- package/lib/typescript/commonjs/src/Button.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts +102 -0
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts +93 -0
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts +57 -0
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts +5 -4
- package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts +12 -11
- package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts +45 -0
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts +24 -0
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/LiquidGlass.d.ts +4 -3
- package/lib/typescript/commonjs/src/LiquidGlass.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts +6 -5
- package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativePlatformComponentsTheme.d.ts +10 -2
- package/lib/typescript/commonjs/src/NativePlatformComponentsTheme.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts +17 -46
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +9 -6
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts +6 -5
- package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/TextField.d.ts +174 -0
- package/lib/typescript/commonjs/src/TextField.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts +162 -0
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/codegenTypes.d.ts +12 -0
- package/lib/typescript/commonjs/src/codegenTypes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/focusRegistry.d.ts +13 -0
- package/lib/typescript/commonjs/src/focusRegistry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/icons.d.ts +52 -0
- package/lib/typescript/commonjs/src/icons.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +6 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.web.d.ts +121 -0
- package/lib/typescript/commonjs/src/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/labelStyle.d.ts +20 -0
- package/lib/typescript/commonjs/src/labelStyle.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/sharedTypes.d.ts +8 -3
- package/lib/typescript/commonjs/src/sharedTypes.d.ts.map +1 -1
- package/lib/typescript/module/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/module/src/Button.d.ts +76 -0
- package/lib/typescript/module/src/Button.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonGroup.d.ts +102 -0
- package/lib/typescript/module/src/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts +93 -0
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts +57 -0
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts +5 -4
- package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/DatePickerNativeComponent.d.ts +12 -11
- package/lib/typescript/module/src/DatePickerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/FloatingToolbar.d.ts +45 -0
- package/lib/typescript/module/src/FloatingToolbar.d.ts.map +1 -0
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts +24 -0
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/LiquidGlass.d.ts +4 -3
- package/lib/typescript/module/src/LiquidGlass.d.ts.map +1 -1
- package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts +6 -5
- package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/NativePlatformComponentsTheme.d.ts +10 -2
- package/lib/typescript/module/src/NativePlatformComponentsTheme.d.ts.map +1 -1
- package/lib/typescript/module/src/SegmentedControl.d.ts +17 -46
- package/lib/typescript/module/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +9 -6
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts +6 -5
- package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/TextField.d.ts +174 -0
- package/lib/typescript/module/src/TextField.d.ts.map +1 -0
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts +162 -0
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/codegenTypes.d.ts +12 -0
- package/lib/typescript/module/src/codegenTypes.d.ts.map +1 -0
- package/lib/typescript/module/src/focusRegistry.d.ts +13 -0
- package/lib/typescript/module/src/focusRegistry.d.ts.map +1 -0
- package/lib/typescript/module/src/icons.d.ts +52 -0
- package/lib/typescript/module/src/icons.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +6 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.web.d.ts +121 -0
- package/lib/typescript/module/src/index.web.d.ts.map +1 -1
- package/lib/typescript/module/src/labelStyle.d.ts +20 -0
- package/lib/typescript/module/src/labelStyle.d.ts.map +1 -0
- package/lib/typescript/module/src/sharedTypes.d.ts +8 -3
- package/lib/typescript/module/src/sharedTypes.d.ts.map +1 -1
- package/package.json +28 -6
- package/react-native.config.js +3 -0
- package/shared/PCButtonComponentDescriptors-custom.h +22 -0
- package/shared/PCButtonGroupComponentDescriptors-custom.h +22 -0
- package/shared/PCButtonGroupShadowNode-custom.cpp +48 -0
- package/shared/PCButtonGroupShadowNode-custom.h +55 -0
- package/shared/PCButtonGroupState-custom.h +61 -0
- package/shared/PCButtonShadowNode-custom.cpp +48 -0
- package/shared/PCButtonShadowNode-custom.h +55 -0
- package/shared/PCButtonState-custom.h +61 -0
- package/shared/PCDatePickerState-custom.h +2 -2
- package/shared/PCSegmentedControlState-custom.h +2 -2
- package/shared/PCSelectionMenuState-custom.h +2 -2
- package/shared/PCTextFieldComponentDescriptors-custom.h +22 -0
- package/shared/PCTextFieldShadowNode-custom.cpp +47 -0
- package/shared/PCTextFieldShadowNode-custom.h +55 -0
- package/shared/PCTextFieldState-custom.h +61 -0
- package/shared/react/renderer/components/PlatformComponentsViewSpec/ComponentDescriptors.h +3 -0
- package/src/Button.tsx +144 -0
- package/src/ButtonGroup.tsx +233 -0
- package/src/ButtonGroupNativeComponent.ts +121 -0
- package/src/ButtonNativeComponent.ts +76 -0
- package/src/ContextMenuNativeComponent.ts +5 -4
- package/src/DatePickerNativeComponent.ts +17 -11
- package/src/FloatingToolbar.tsx +113 -0
- package/src/FloatingToolbarNativeComponent.ts +31 -0
- package/src/LiquidGlass.tsx +24 -5
- package/src/LiquidGlassNativeComponent.ts +6 -5
- package/src/NativePlatformComponentsTheme.ts +11 -2
- package/src/SegmentedControl.tsx +26 -118
- package/src/SegmentedControlNativeComponent.ts +15 -11
- package/src/SelectionMenuNativeComponent.ts +6 -5
- package/src/TextField.tsx +494 -0
- package/src/TextFieldNativeComponent.ts +218 -0
- package/src/codegenTypes.ts +40 -0
- package/src/focusRegistry.ts +89 -0
- package/src/icons.ts +116 -0
- package/src/index.tsx +6 -0
- package/src/index.web.tsx +194 -0
- package/src/labelStyle.ts +36 -0
- package/src/reactNativeInternals.d.ts +22 -0
- package/src/sharedTypes.ts +9 -3
- /package/{app.plugin.cjs → app.plugin.js} +0 -0
|
@@ -2,31 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
// SegmentedControl.tsx
|
|
4
4
|
import React, { useCallback, useMemo } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
6
6
|
import NativeSegmentedControl from './SegmentedControlNativeComponent';
|
|
7
|
-
|
|
7
|
+
import { resolveIcon } from "./icons.js";
|
|
8
|
+
import { normalizeLabelStyle } from "./labelStyle.js";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
10
|
// Android: Minimum height to ensure visibility.
|
|
9
11
|
// Fabric's shadow node measurement isn't being called on initial render,
|
|
10
12
|
// so we apply a minHeight that matches Material design touch target guidelines.
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
const ANDROID_MIN_HEIGHT = 48;
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
* A single icon source.
|
|
16
|
-
*
|
|
17
|
-
* - `string`: shorthand for an SF Symbol name on iOS and a drawable resource
|
|
18
|
-
* name on Android (the original API).
|
|
19
|
-
* - `{ type: 'sfSymbol' }`: an SF Symbol. iOS only; ignored on Android.
|
|
20
|
-
* - `{ type: 'drawable' }`: a drawable from the app's `res/drawable`.
|
|
21
|
-
* Android only; ignored on iOS.
|
|
22
|
-
* - `{ type: 'image' }`: an image asset (`require('./icon.png')`) or a
|
|
23
|
-
* `{ uri }` source. Works on both platforms. Images are drawn as tinted
|
|
24
|
-
* templates unless `tinted` is `false`.
|
|
25
|
-
*/
|
|
15
|
+
/** A single icon source. Alias of {@link PlatformIconSource}. */
|
|
26
16
|
|
|
27
17
|
/**
|
|
28
18
|
* An icon for a segment: a single source used on both platforms, or a
|
|
29
|
-
* per-platform pair
|
|
19
|
+
* per-platform pair. Alias of {@link PlatformIcon}.
|
|
30
20
|
*/
|
|
31
21
|
|
|
32
22
|
/**
|
|
@@ -39,72 +29,14 @@ const ANDROID_MIN_HEIGHT = 48;
|
|
|
39
29
|
* their label. Screen readers still announce the label on both platforms.
|
|
40
30
|
*/
|
|
41
31
|
|
|
42
|
-
/**
|
|
43
|
-
* Font for segment labels. Each field falls back to the platform default.
|
|
44
|
-
*/
|
|
32
|
+
/** Font for segment labels. Alias of {@link LabelStyle}. */
|
|
45
33
|
|
|
46
34
|
/**
|
|
47
35
|
* Badge colors. Both default to the platform look (red with white text).
|
|
48
36
|
*/
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
iconName: '',
|
|
53
|
-
iconUri: '',
|
|
54
|
-
iconScale: 1,
|
|
55
|
-
iconTinted: 'true'
|
|
56
|
-
};
|
|
57
|
-
function pickIconSource(icon) {
|
|
58
|
-
if (icon === undefined || typeof icon === 'string' || 'type' in icon) {
|
|
59
|
-
return icon;
|
|
60
|
-
}
|
|
61
|
-
return Platform.OS === 'ios' ? icon.ios : icon.android;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Flattens the public icon shape into the strings native expects, dropping
|
|
66
|
-
* sources that don't apply to the current platform.
|
|
67
|
-
*/
|
|
68
|
-
export function resolveSegmentIcon(icon) {
|
|
69
|
-
const source = pickIconSource(icon);
|
|
70
|
-
if (source === undefined) return NO_ICON;
|
|
71
|
-
if (typeof source === 'string') {
|
|
72
|
-
if (source.length === 0) return NO_ICON;
|
|
73
|
-
return {
|
|
74
|
-
...NO_ICON,
|
|
75
|
-
iconType: Platform.OS === 'ios' ? 'sfSymbol' : 'drawable',
|
|
76
|
-
iconName: source
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
switch (source.type) {
|
|
80
|
-
case 'sfSymbol':
|
|
81
|
-
return Platform.OS === 'ios' ? {
|
|
82
|
-
...NO_ICON,
|
|
83
|
-
iconType: 'sfSymbol',
|
|
84
|
-
iconName: source.name
|
|
85
|
-
} : NO_ICON;
|
|
86
|
-
case 'drawable':
|
|
87
|
-
return Platform.OS === 'android' ? {
|
|
88
|
-
...NO_ICON,
|
|
89
|
-
iconType: 'drawable',
|
|
90
|
-
iconName: source.name
|
|
91
|
-
} : NO_ICON;
|
|
92
|
-
case 'image':
|
|
93
|
-
{
|
|
94
|
-
const resolved = Image.resolveAssetSource(source.source);
|
|
95
|
-
if (!resolved?.uri) return NO_ICON;
|
|
96
|
-
return {
|
|
97
|
-
iconType: 'image',
|
|
98
|
-
iconName: '',
|
|
99
|
-
iconUri: resolved.uri,
|
|
100
|
-
iconScale: resolved.scale > 0 ? resolved.scale : 1,
|
|
101
|
-
iconTinted: source.tinted === false ? 'false' : 'true'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
default:
|
|
105
|
-
return NO_ICON;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
38
|
+
/** Flattens a segment icon for native. Alias of {@link resolveIcon}. */
|
|
39
|
+
export const resolveSegmentIcon = resolveIcon;
|
|
108
40
|
function normalizeSelectedValue(selected) {
|
|
109
41
|
return selected ?? '';
|
|
110
42
|
}
|
|
@@ -165,21 +97,14 @@ export function SegmentedControl(props) {
|
|
|
165
97
|
const nativeSelectedSegmentColor = selectedSegmentColor ?? (Platform.OS === 'ios' ? ios?.selectedSegmentTintColor : undefined);
|
|
166
98
|
|
|
167
99
|
// Normalize the label font; empty / 0 means platform default
|
|
168
|
-
const nativeLabelStyle = useMemo(() =>
|
|
169
|
-
if (!labelStyle) return undefined;
|
|
170
|
-
return {
|
|
171
|
-
fontFamily: labelStyle.fontFamily ?? '',
|
|
172
|
-
fontSize: labelStyle.fontSize ?? 0,
|
|
173
|
-
fontWeight: labelStyle.fontWeight === undefined ? '' : String(labelStyle.fontWeight),
|
|
174
|
-
fontStyle: labelStyle.fontStyle ?? ''
|
|
175
|
-
};
|
|
176
|
-
}, [labelStyle]);
|
|
100
|
+
const nativeLabelStyle = useMemo(() => normalizeLabelStyle(labelStyle), [labelStyle]);
|
|
177
101
|
|
|
178
102
|
// Normalize Android props
|
|
179
103
|
const nativeAndroid = useMemo(() => {
|
|
180
104
|
if (!android) return undefined;
|
|
181
105
|
return {
|
|
182
|
-
selectionRequired: android.selectionRequired === false ? 'false' : 'true'
|
|
106
|
+
selectionRequired: android.selectionRequired === false ? 'false' : 'true',
|
|
107
|
+
material: android.material ?? 'expressive'
|
|
183
108
|
};
|
|
184
109
|
}, [android]);
|
|
185
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMemo","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","Platform","StyleSheet","NativeSegmentedControl","resolveIcon","normalizeLabelStyle","jsx","_jsx","ANDROID_MIN_HEIGHT","resolveSegmentIcon","normalizeSelectedValue","selected","SegmentedControl","props","style","segments","selectedValue","disabled","labelVisibility","selectedSegmentColor","activeTintColor","inactiveTintColor","labelStyle","badgeStyle","onSelect","onDeselect","ios","android","viewProps","nativeSegments","map","seg","label","value","badge","undefined","String","accessibilityLabel","icon","selectedData","handleSelect","e","index","nativeEvent","nativeIos","momentary","apportionsSegmentWidthsByContent","nativeSelectedSegmentColor","OS","selectedSegmentTintColor","nativeLabelStyle","nativeAndroid","selectionRequired","material","mergedStyle","styles","androidDefault","interactivity","androidRippleColor","rippleColor","androidStrokeColor","strokeColor","badgeBackgroundColor","backgroundColor","badgeTextColor","color","create","minHeight"],"sourceRoot":"../../src","sources":["SegmentedControl.tsx"],"mappings":";;AAAA;AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AACnD,SACEC,QAAQ,EACRC,UAAU,QAKL,cAAc;AAErB,OAAOC,sBAAsB,MAGtB,mCAAmC;AAC1C,SACEC,WAAW,QAGN,YAAS;AAChB,SAASC,mBAAmB,QAAyB,iBAAc;AAAC,SAAAC,G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Q,CAAC+C,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAO,CAACO,MAAM,CAACC,cAAc,EAAE1C,KAAK,CAAC;IACvC;IACA,OAAOA,KAAK;EACd,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEX,oBACEP,IAAA,CAACJ,sBAAsB;IACrBW,KAAK,EAAEwC,WAAY;IACnBvC,QAAQ,EAAEc,cAAe;IACzBb,aAAa,EAAEuB,YAAa;IAC5BkB,aAAa,EAAExC,QAAQ,GAAG,UAAU,GAAG,SAAU;IACjDC,eAAe,EAAEA,eAAe,IAAI,MAAO;IAC3CC,oBAAoB,EAAE4B,0BAA2B;IACjD3B,eAAe,EAAEA,eAAgB;IACjCC,iBAAiB,EAAEA,iBAAkB;IACrCqC,kBAAkB,EAAE/B,OAAO,EAAEgC,WAAY;IACzCC,kBAAkB,EAAEjC,OAAO,EAAEkC,WAAY;IACzCvC,UAAU,EAAE4B,gBAAiB;IAC7BY,oBAAoB,EAAEvC,UAAU,EAAEwC,eAAgB;IAClDC,cAAc,EAAEzC,UAAU,EAAE0C,KAAM;IAClCzC,QAAQ,EAAEA,QAAQ,IAAIC,UAAU,GAAGe,YAAY,GAAGL,SAAU;IAC5DT,GAAG,EAAEkB,SAAU;IACfjB,OAAO,EAAEwB,aAAc;IAAA,GACnBvB;EAAS,CACd,CAAC;AAEN;AAEA,MAAM2B,MAAM,GAAGrD,UAAU,CAACgE,MAAM,CAAC;EAC/BV,cAAc,EAAE;IACdW,SAAS,EAAE3D;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// SegmentedControlNativeComponent.ts
|
|
2
|
-
import type {
|
|
3
|
-
CodegenTypes,
|
|
4
|
-
ColorValue,
|
|
5
|
-
HostComponent,
|
|
6
|
-
ViewProps,
|
|
7
|
-
} from 'react-native';
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
8
3
|
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type {
|
|
5
|
+
BubblingEventHandler,
|
|
6
|
+
Double,
|
|
7
|
+
Int32,
|
|
8
|
+
WithDefault,
|
|
9
|
+
} from './codegenTypes';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* A single segment in the control.
|
|
@@ -21,7 +22,7 @@ export type SegmentedControlSegment = Readonly<{
|
|
|
21
22
|
iconType: string; // '' | 'sfSymbol' | 'drawable' | 'image'
|
|
22
23
|
iconName: string; // SF Symbol (iOS) or drawable resource name (Android)
|
|
23
24
|
iconUri: string; // Resolved image URI when iconType === 'image'
|
|
24
|
-
iconScale:
|
|
25
|
+
iconScale: Double; // Resolved image scale when iconType === 'image'
|
|
25
26
|
iconTinted: string; // 'true' | 'false' — draw the image as a tinted template
|
|
26
27
|
badge: string; // Badge text, empty = no badge
|
|
27
28
|
accessibilityLabel: string; // Screen-reader label, empty = use label
|
|
@@ -32,7 +33,7 @@ export type SegmentedControlSegment = Readonly<{
|
|
|
32
33
|
*/
|
|
33
34
|
export type SegmentedControlSelectEvent = Readonly<{
|
|
34
35
|
/** Selected segment index. -1 means the selection was cleared. */
|
|
35
|
-
index:
|
|
36
|
+
index: Int32;
|
|
36
37
|
|
|
37
38
|
/** Selected segment value. Empty when the selection was cleared. */
|
|
38
39
|
value: string;
|
|
@@ -49,7 +50,7 @@ export type SegmentedControlLabelVisibility = 'auto' | 'labeled' | 'unlabeled';
|
|
|
49
50
|
*/
|
|
50
51
|
export type LabelStyleProps = Readonly<{
|
|
51
52
|
fontFamily?: string;
|
|
52
|
-
fontSize?:
|
|
53
|
+
fontSize?: Double;
|
|
53
54
|
fontWeight?: string; // 'normal' | 'bold' | '100'..'900'
|
|
54
55
|
fontStyle?: string; // 'normal' | 'italic'
|
|
55
56
|
}>;
|
|
@@ -71,6 +72,9 @@ export type IOSProps = Readonly<{
|
|
|
71
72
|
export type AndroidProps = Readonly<{
|
|
72
73
|
/** Whether one segment must always be selected */
|
|
73
74
|
selectionRequired?: string; // 'true' | 'false'
|
|
75
|
+
|
|
76
|
+
/** Material style: 'm3' | 'expressive' */
|
|
77
|
+
material?: string;
|
|
74
78
|
}>;
|
|
75
79
|
|
|
76
80
|
export interface SegmentedControlProps extends ViewProps {
|
|
@@ -83,7 +87,7 @@ export interface SegmentedControlProps extends ViewProps {
|
|
|
83
87
|
* Controlled selection by `value`.
|
|
84
88
|
* Empty string means "no selection".
|
|
85
89
|
*/
|
|
86
|
-
selectedValue?:
|
|
90
|
+
selectedValue?: WithDefault<string, ''>;
|
|
87
91
|
|
|
88
92
|
/**
|
|
89
93
|
* Enabled / disabled state.
|
|
@@ -122,7 +126,7 @@ export interface SegmentedControlProps extends ViewProps {
|
|
|
122
126
|
/**
|
|
123
127
|
* Fired when the user selects a segment.
|
|
124
128
|
*/
|
|
125
|
-
onSelect?:
|
|
129
|
+
onSelect?: BubblingEventHandler<SegmentedControlSelectEvent>;
|
|
126
130
|
|
|
127
131
|
ios?: IOSProps;
|
|
128
132
|
android?: AndroidProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SelectionMenuNativeComponent.ts
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
3
3
|
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type { BubblingEventHandler, Int32, WithDefault } from './codegenTypes';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A single option in the menu.
|
|
@@ -15,7 +16,7 @@ export type SelectionMenuOption = Readonly<{
|
|
|
15
16
|
*/
|
|
16
17
|
export type SelectionMenuSelectEvent = Readonly<{
|
|
17
18
|
/** Selected option index (implementation detail; stable for this render) */
|
|
18
|
-
index:
|
|
19
|
+
index: Int32;
|
|
19
20
|
|
|
20
21
|
/** Selected option label */
|
|
21
22
|
label: string;
|
|
@@ -57,7 +58,7 @@ export interface SelectionMenuProps extends ViewProps {
|
|
|
57
58
|
* - Empty string means "no selection".
|
|
58
59
|
* - Native should treat this as the single source of truth.
|
|
59
60
|
*/
|
|
60
|
-
selectedData?:
|
|
61
|
+
selectedData?: WithDefault<string, ''>;
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
64
|
* Enabled / disabled state.
|
|
@@ -83,12 +84,12 @@ export interface SelectionMenuProps extends ViewProps {
|
|
|
83
84
|
/**
|
|
84
85
|
* Fired when the user selects an option.
|
|
85
86
|
*/
|
|
86
|
-
onSelect?:
|
|
87
|
+
onSelect?: BubblingEventHandler<SelectionMenuSelectEvent>;
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
90
|
* Fired when dismissed without selection.
|
|
90
91
|
*/
|
|
91
|
-
onRequestClose?:
|
|
92
|
+
onRequestClose?: BubblingEventHandler<Readonly<{}>>;
|
|
92
93
|
|
|
93
94
|
ios?: IOSProps;
|
|
94
95
|
android?: AndroidProps;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// TextField.tsx
|
|
4
|
+
import React, { forwardRef, useCallback, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import NativeTextField, { Commands } from './TextFieldNativeComponent';
|
|
6
|
+
import { resolveIcon } from "./icons.js";
|
|
7
|
+
import { normalizeLabelStyle } from "./labelStyle.js";
|
|
8
|
+
import { focusRegistry } from "./focusRegistry.js";
|
|
9
|
+
|
|
10
|
+
/** Keyboard to show; the React Native `TextInput` values. */
|
|
11
|
+
|
|
12
|
+
/** Return key label; the React Native `TextInput` values. */
|
|
13
|
+
|
|
14
|
+
/** Autofill hint; a cross-platform subset of the React Native `TextInput` values. */
|
|
15
|
+
|
|
16
|
+
/** An iOS text trait: the system default, on, or off. */
|
|
17
|
+
|
|
18
|
+
/** Focus, blur and submit events carry the text at that moment. */
|
|
19
|
+
|
|
20
|
+
/** Change events carry the text and the native edit counter. */
|
|
21
|
+
|
|
22
|
+
/** Methods available through the `ref`. */
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
export const TextField = /*#__PURE__*/forwardRef(function TextFieldComponent(props, ref) {
|
|
25
|
+
const {
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
onChangeText,
|
|
29
|
+
onChange,
|
|
30
|
+
onFocus,
|
|
31
|
+
onBlur,
|
|
32
|
+
onSubmitEditing,
|
|
33
|
+
label,
|
|
34
|
+
placeholder,
|
|
35
|
+
supportingText,
|
|
36
|
+
error,
|
|
37
|
+
prefix,
|
|
38
|
+
suffix,
|
|
39
|
+
leadingIcon,
|
|
40
|
+
trailingIcon,
|
|
41
|
+
onTrailingIconPress,
|
|
42
|
+
clearButtonMode,
|
|
43
|
+
passwordToggle,
|
|
44
|
+
showCharacterCount,
|
|
45
|
+
maxLength,
|
|
46
|
+
keyboardType,
|
|
47
|
+
returnKeyType,
|
|
48
|
+
autoCapitalize,
|
|
49
|
+
autoCorrect,
|
|
50
|
+
secureTextEntry,
|
|
51
|
+
multiline,
|
|
52
|
+
editable,
|
|
53
|
+
autoFocus,
|
|
54
|
+
selectTextOnFocus,
|
|
55
|
+
autoComplete,
|
|
56
|
+
keyboardAppearance,
|
|
57
|
+
textStyle,
|
|
58
|
+
accessibilityLabel,
|
|
59
|
+
ios,
|
|
60
|
+
android,
|
|
61
|
+
...viewProps
|
|
62
|
+
} = props;
|
|
63
|
+
const nativeRef = useRef(null);
|
|
64
|
+
const focused = useRef(false);
|
|
65
|
+
|
|
66
|
+
// The same synchronization as React Native's TextInput: every native edit
|
|
67
|
+
// reports an event count, and a controlled value is pushed with the last
|
|
68
|
+
// count JS has seen. Native drops the update when the user has typed
|
|
69
|
+
// since, and the edit that follows brings JS back in line.
|
|
70
|
+
const [mostRecentEventCount, setMostRecentEventCount] = useState(0);
|
|
71
|
+
const [lastNativeText, setLastNativeText] = useState(value ?? defaultValue);
|
|
72
|
+
|
|
73
|
+
// Registered like a TextInput, so Keyboard.dismiss() and the ScrollView
|
|
74
|
+
// keyboard props treat the field as one (see focusRegistry.ts)
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const node = nativeRef.current;
|
|
77
|
+
if (node == null) return undefined;
|
|
78
|
+
focusRegistry.register(node);
|
|
79
|
+
return () => focusRegistry.unregister(node);
|
|
80
|
+
}, []);
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
if (typeof value !== 'string' || value === lastNativeText) return;
|
|
83
|
+
setLastNativeText(value);
|
|
84
|
+
const node = nativeRef.current;
|
|
85
|
+
if (node != null) {
|
|
86
|
+
Commands.setText(node, mostRecentEventCount, value);
|
|
87
|
+
}
|
|
88
|
+
}, [value, lastNativeText, mostRecentEventCount]);
|
|
89
|
+
useImperativeHandle(ref, () => ({
|
|
90
|
+
focus: () => {
|
|
91
|
+
const node = nativeRef.current;
|
|
92
|
+
if (node != null) Commands.focus(node);
|
|
93
|
+
},
|
|
94
|
+
blur: () => {
|
|
95
|
+
const node = nativeRef.current;
|
|
96
|
+
if (node != null) Commands.blur(node);
|
|
97
|
+
},
|
|
98
|
+
clear: () => {
|
|
99
|
+
const node = nativeRef.current;
|
|
100
|
+
if (node != null) Commands.clear(node);
|
|
101
|
+
},
|
|
102
|
+
isFocused: () => focused.current
|
|
103
|
+
}), []);
|
|
104
|
+
const handleChange = useCallback(event => {
|
|
105
|
+
const {
|
|
106
|
+
text,
|
|
107
|
+
eventCount
|
|
108
|
+
} = event.nativeEvent;
|
|
109
|
+
setMostRecentEventCount(eventCount);
|
|
110
|
+
setLastNativeText(text);
|
|
111
|
+
onChange?.(event);
|
|
112
|
+
onChangeText?.(text);
|
|
113
|
+
}, [onChange, onChangeText]);
|
|
114
|
+
const handleFocus = useCallback(event => {
|
|
115
|
+
focused.current = true;
|
|
116
|
+
focusRegistry.focused(nativeRef.current);
|
|
117
|
+
onFocus?.(event);
|
|
118
|
+
}, [onFocus]);
|
|
119
|
+
const handleBlur = useCallback(event => {
|
|
120
|
+
focused.current = false;
|
|
121
|
+
focusRegistry.blurred(nativeRef.current);
|
|
122
|
+
onBlur?.(event);
|
|
123
|
+
}, [onBlur]);
|
|
124
|
+
const handleSubmit = useCallback(event => {
|
|
125
|
+
onSubmitEditing?.(event);
|
|
126
|
+
}, [onSubmitEditing]);
|
|
127
|
+
const handleTrailingIconPress = useCallback(() => {
|
|
128
|
+
onTrailingIconPress?.();
|
|
129
|
+
}, [onTrailingIconPress]);
|
|
130
|
+
const nativeLeadingIcon = useMemo(() => resolveIcon(leadingIcon), [leadingIcon]);
|
|
131
|
+
const nativeTrailingIcon = useMemo(() => resolveIcon(trailingIcon), [trailingIcon]);
|
|
132
|
+
const nativeTextStyle = useMemo(() => normalizeLabelStyle(textStyle), [textStyle]);
|
|
133
|
+
const nativeIOS = useMemo(() => ({
|
|
134
|
+
writingTools: ios?.writingTools ?? '',
|
|
135
|
+
inlinePrediction: ios?.inlinePrediction ?? '',
|
|
136
|
+
smartQuotes: ios?.smartQuotes ?? '',
|
|
137
|
+
smartDashes: ios?.smartDashes ?? '',
|
|
138
|
+
smartInsertDelete: ios?.smartInsertDelete ?? '',
|
|
139
|
+
mathExpressionCompletion: ios?.mathExpressionCompletion ?? '',
|
|
140
|
+
borderStyle: ios?.borderStyle ?? '',
|
|
141
|
+
labelPlacement: ios?.labelPlacement ?? '',
|
|
142
|
+
labelWidth: ios?.labelWidth ?? 0
|
|
143
|
+
}), [ios]);
|
|
144
|
+
const nativeAndroid = useMemo(() => ({
|
|
145
|
+
material: android?.material ?? 'm3',
|
|
146
|
+
variant: android?.variant ?? 'outlined',
|
|
147
|
+
density: android?.dense ? 'dense' : 'standard'
|
|
148
|
+
}), [android]);
|
|
149
|
+
return /*#__PURE__*/_jsx(NativeTextField, {
|
|
150
|
+
ref: nativeRef,
|
|
151
|
+
initialText: value ?? defaultValue ?? '',
|
|
152
|
+
label: label ?? '',
|
|
153
|
+
placeholder: placeholder ?? '',
|
|
154
|
+
supportingText: supportingText ?? '',
|
|
155
|
+
errorState: error ? 'error' : 'none',
|
|
156
|
+
errorText: typeof error === 'string' ? error : '',
|
|
157
|
+
prefix: prefix ?? '',
|
|
158
|
+
suffix: suffix ?? '',
|
|
159
|
+
leadingIcon: nativeLeadingIcon,
|
|
160
|
+
trailingIcon: nativeTrailingIcon,
|
|
161
|
+
clearButtonMode: clearButtonMode ?? 'never',
|
|
162
|
+
passwordToggle: passwordToggle ? 'shown' : 'hidden',
|
|
163
|
+
characterCount: showCharacterCount ? 'shown' : 'hidden',
|
|
164
|
+
maxLength: maxLength ?? 0,
|
|
165
|
+
keyboardType: keyboardType ?? 'default',
|
|
166
|
+
returnKeyType: returnKeyType ?? 'default',
|
|
167
|
+
autoCapitalize: autoCapitalize ?? 'sentences',
|
|
168
|
+
autoCorrect: autoCorrect === false ? 'disabled' : 'enabled',
|
|
169
|
+
secureTextEntry: secureTextEntry ? 'secure' : 'plain',
|
|
170
|
+
lines: multiline ? 'multiline' : 'single',
|
|
171
|
+
interactivity: editable === false ? 'disabled' : 'enabled',
|
|
172
|
+
autoFocus: autoFocus ? 'focus' : 'none',
|
|
173
|
+
selectTextOnFocus: selectTextOnFocus ? 'select' : 'keep',
|
|
174
|
+
autoComplete: autoComplete ?? '',
|
|
175
|
+
keyboardAppearance: keyboardAppearance ?? 'default',
|
|
176
|
+
textStyle: nativeTextStyle,
|
|
177
|
+
spokenLabel: accessibilityLabel ?? '',
|
|
178
|
+
ios: nativeIOS,
|
|
179
|
+
android: nativeAndroid,
|
|
180
|
+
onFieldChange: handleChange,
|
|
181
|
+
onFieldFocus: handleFocus,
|
|
182
|
+
onFieldBlur: handleBlur,
|
|
183
|
+
onFieldSubmit: onSubmitEditing ? handleSubmit : undefined,
|
|
184
|
+
onTrailingIconPress: onTrailingIconPress ? handleTrailingIconPress : undefined,
|
|
185
|
+
...viewProps
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
TextField.displayName = 'TextField';
|
|
189
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useImperativeHandle","useLayoutEffect","useMemo","useRef","useState","NativeTextField","Commands","resolveIcon","normalizeLabelStyle","focusRegistry","jsx","_jsx","TextField","TextFieldComponent","props","ref","value","defaultValue","onChangeText","onChange","onFocus","onBlur","onSubmitEditing","label","placeholder","supportingText","error","prefix","suffix","leadingIcon","trailingIcon","onTrailingIconPress","clearButtonMode","passwordToggle","showCharacterCount","maxLength","keyboardType","returnKeyType","autoCapitalize","autoCorrect","secureTextEntry","multiline","editable","autoFocus","selectTextOnFocus","autoComplete","keyboardAppearance","textStyle","accessibilityLabel","ios","android","viewProps","nativeRef","focused","mostRecentEventCount","setMostRecentEventCount","lastNativeText","setLastNativeText","node","current","undefined","register","unregister","setText","focus","blur","clear","isFocused","handleChange","event","text","eventCount","nativeEvent","handleFocus","handleBlur","blurred","handleSubmit","handleTrailingIconPress","nativeLeadingIcon","nativeTrailingIcon","nativeTextStyle","nativeIOS","writingTools","inlinePrediction","smartQuotes","smartDashes","smartInsertDelete","mathExpressionCompletion","borderStyle","labelPlacement","labelWidth","nativeAndroid","material","variant","density","dense","initialText","errorState","errorText","characterCount","lines","interactivity","spokenLabel","onFieldChange","onFieldFocus","onFieldBlur","onFieldSubmit","displayName"],"sourceRoot":"../../src","sources":["TextField.tsx"],"mappings":";;AAAA;AACA,OAAOA,KAAK,IACVC,UAAU,EACVC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,OAAOC,eAAe,IACpBC,QAAQ,QAGH,4BAA4B;AACnC,SAASC,WAAW,QAA2B,YAAS;AACxD,SAASC,mBAAmB,QAAyB,iBAAc;AACnE,SAASC,aAAa,QAAQ,oBAAiB;;AAG/C;;AAgBA;;AAIA;;AA0BA;;AAGA;;AAGA;;AAMA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAwMA,OAAO,MAAMC,SAAS,gBAAGd,UAAU,CACjC,SAASe,kBAAkBA,CAACC,KAAK,EAAEC,GAAG,EAAsB;EA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