@ng-native/components 0.22.2 → 0.24.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/android/build.gradle +22 -0
- package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +38 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuAccessibility.kt +71 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuGesture.kt +161 -0
- package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +197 -0
- package/android/src/main/java/dev/ngnative/components/MenuHost.kt +45 -0
- package/android/src/main/java/dev/ngnative/components/MenuWindowCallback.kt +76 -0
- package/android/src/main/java/dev/ngnative/components/MenusModule.kt +85 -0
- package/android/src/main/java/dev/ngnative/components/Shortcut.kt +144 -0
- package/android/src/main/java/dev/ngnative/components/WindowWrapper.kt +22 -0
- package/dist/activity-indicator.d.ts +4 -1
- package/dist/activity-indicator.js +6 -2
- package/dist/activity-indicator.js.map +1 -1
- package/dist/context-menu.d.ts +52 -0
- package/dist/context-menu.js +101 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/drag-and-drop.d.ts +52 -0
- package/dist/drag-and-drop.js +112 -0
- package/dist/drag-and-drop.js.map +1 -0
- package/dist/gesture-backend.d.ts +32 -2
- package/dist/gesture-backend.js.map +1 -1
- package/dist/gesture-dispatch.d.ts +8 -1
- package/dist/gesture-dispatch.js +60 -16
- package/dist/gesture-dispatch.js.map +1 -1
- package/dist/gesture-interaction.d.ts +13 -0
- package/dist/gesture-interaction.js +97 -0
- package/dist/gesture-interaction.js.map +1 -0
- package/dist/gesture-tracking.d.ts +18 -0
- package/dist/gesture-tracking.js +28 -0
- package/dist/gesture-tracking.js.map +1 -0
- package/dist/gestures-web.d.ts +3 -1
- package/dist/gestures-web.js +5 -2
- package/dist/gestures-web.js.map +1 -1
- package/dist/gestures.d.ts +1 -0
- package/dist/gestures.js +45 -3
- package/dist/gestures.js.map +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction-observer.d.ts +11 -0
- package/dist/interaction-observer.js +12 -0
- package/dist/interaction-observer.js.map +1 -0
- package/dist/keyboard-avoiding-view.js +3 -3
- package/dist/keyboard-avoiding-view.js.map +1 -1
- package/dist/markdown-stream.d.ts +3 -1
- package/dist/markdown-stream.js +14 -2
- package/dist/markdown-stream.js.map +1 -1
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +5 -3
- package/dist/markdown.js.map +1 -1
- package/dist/menu.d.ts +71 -0
- package/dist/menu.js +193 -0
- package/dist/menu.js.map +1 -0
- package/dist/modal.d.ts +30 -1
- package/dist/modal.js +67 -6
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +54 -0
- package/dist/native-button.js +99 -0
- package/dist/native-button.js.map +1 -0
- package/dist/native-gesture.d.ts +9 -1
- package/dist/native-gesture.js +32 -3
- package/dist/native-gesture.js.map +1 -1
- package/dist/native-id.d.ts +10 -0
- package/dist/native-id.js +70 -0
- package/dist/native-id.js.map +1 -0
- package/dist/pressable.d.ts +36 -0
- package/dist/pressable.js +106 -10
- package/dist/pressable.js.map +1 -1
- package/dist/safe-area-provider.js +15 -8
- package/dist/safe-area-provider.js.map +1 -1
- package/dist/scroll-view-props.d.ts +7 -1
- package/dist/scroll-view-props.js +54 -3
- package/dist/scroll-view-props.js.map +1 -1
- package/dist/section-list.js +2 -2
- package/dist/section-list.js.map +1 -1
- package/dist/shortcut.d.ts +21 -0
- package/dist/shortcut.js +34 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/sidebar-item.d.ts +53 -0
- package/dist/sidebar-item.js +152 -0
- package/dist/sidebar-item.js.map +1 -0
- package/dist/sidebar-section.d.ts +21 -0
- package/dist/sidebar-section.js +74 -0
- package/dist/sidebar-section.js.map +1 -0
- package/dist/sidebar.d.ts +47 -0
- package/dist/sidebar.js +110 -0
- package/dist/sidebar.js.map +1 -0
- package/dist/split-view.d.ts +63 -0
- package/dist/split-view.js +121 -0
- package/dist/split-view.js.map +1 -0
- package/dist/switch.d.ts +9 -1
- package/dist/switch.js +23 -2
- package/dist/switch.js.map +1 -1
- package/dist/text-input.d.ts +8 -3
- package/dist/text-input.js +10 -4
- package/dist/text-input.js.map +1 -1
- package/dist/transforms.d.ts +5 -0
- package/dist/transforms.js +7 -0
- package/dist/transforms.js.map +1 -1
- package/dist/tray-icon.d.ts +18 -0
- package/dist/tray-icon.js +46 -0
- package/dist/tray-icon.js.map +1 -0
- package/dist/view-base.d.ts +42 -1
- package/dist/view-base.js +67 -39
- package/dist/view-base.js.map +1 -1
- package/dist/virtual-list.js +12 -1
- package/dist/virtual-list.js.map +1 -1
- package/dist/written-props.js +25 -0
- package/dist/written-props.js.map +1 -1
- package/expo-module.config.json +6 -0
- package/ios/NgNativeButtonComponentView.mm +132 -0
- package/ios/NgNativeButtonMetrics.h +28 -0
- package/ios/NgNativeButtonMetrics.mm +68 -0
- package/ios/NgNativeButtonShadowNode.h +65 -0
- package/ios/NgNativeButtonShadowNode.mm +40 -0
- package/ios/NgNativeComponents.podspec +28 -0
- package/ios/NgNativeDragAndDrop.mm +342 -0
- package/ios/NgNativeDropItems.h +29 -0
- package/ios/NgNativeDropItems.mm +55 -0
- package/ios/NgNativeMenuBuilding.h +40 -0
- package/ios/NgNativeMenuBuilding.mm +217 -0
- package/ios/NgNativeMenus.mm +320 -0
- package/ios/NgNativeResponderHooks.h +53 -0
- package/ios/NgNativeResponderHooks.mm +215 -0
- package/ios/NgNativeSceneKeys.h +36 -0
- package/ios/NgNativeSceneKeys.mm +56 -0
- package/ios/NgNativeSplitView.mm +433 -0
- package/ios/NgNativeSplitViewDelegate.h +29 -0
- package/ios/NgNativeSplitViewDelegate.mm +122 -0
- package/ios/NgNativeSplitViewShadowNodes.h +115 -0
- package/ios/NgNativeSplitViewShadowNodes.mm +31 -0
- package/ios/NgNativeUndo.mm +107 -0
- package/ios/NgNativeUndoSteps.h +17 -0
- package/ios/NgNativeUndoSteps.mm +22 -0
- package/ios/NgNativeViewBinder.h +54 -0
- package/ios/NgNativeViewBinder.mm +225 -0
- package/ios/NgNativeWindows.mm +1126 -0
- package/package.json +13 -5
package/dist/written-props.js
CHANGED
|
@@ -5,16 +5,24 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const WRITTEN_PROPS = [
|
|
7
7
|
'accessibilityActions',
|
|
8
|
+
'accessibilityColumnCount',
|
|
9
|
+
'accessibilityDescribedBy',
|
|
8
10
|
'accessibilityElementsHidden',
|
|
9
11
|
'accessibilityHint',
|
|
10
12
|
'accessibilityIgnoresInvertColors',
|
|
13
|
+
'accessibilityInvalid',
|
|
11
14
|
'accessibilityLabel',
|
|
12
15
|
'accessibilityLabelledBy',
|
|
13
16
|
'accessibilityLanguage',
|
|
14
17
|
'accessibilityLargeContentTitle',
|
|
18
|
+
'accessibilityLevel',
|
|
15
19
|
'accessibilityLiveRegion',
|
|
20
|
+
'accessibilityPosInSet',
|
|
21
|
+
'accessibilityRequired',
|
|
16
22
|
'accessibilityRespondsToUserInteraction',
|
|
17
23
|
'accessibilityRole',
|
|
24
|
+
'accessibilityRowCount',
|
|
25
|
+
'accessibilitySetSize',
|
|
18
26
|
'accessibilityShowsLargeContentViewer',
|
|
19
27
|
'accessibilityState',
|
|
20
28
|
'accessibilityValue',
|
|
@@ -23,6 +31,7 @@ export const WRITTEN_PROPS = [
|
|
|
23
31
|
'adjustsFontSizeToFit',
|
|
24
32
|
'allowFontScaling',
|
|
25
33
|
'allowSwipeDismissal',
|
|
34
|
+
'anchor',
|
|
26
35
|
'alwaysBounceHorizontal',
|
|
27
36
|
'alwaysBounceVertical',
|
|
28
37
|
'android_hyphenationFrequency',
|
|
@@ -35,7 +44,9 @@ export const WRITTEN_PROPS = [
|
|
|
35
44
|
'automaticallyAdjustContentInsets',
|
|
36
45
|
'automaticallyAdjustKeyboardInsets',
|
|
37
46
|
'automaticallyAdjustsScrollIndicatorInsets',
|
|
47
|
+
'autosaveName',
|
|
38
48
|
'backgroundColor',
|
|
49
|
+
'badge',
|
|
39
50
|
'blurRadius',
|
|
40
51
|
'bounces',
|
|
41
52
|
'bouncesZoom',
|
|
@@ -47,12 +58,16 @@ export const WRITTEN_PROPS = [
|
|
|
47
58
|
'clearTextOnFocus',
|
|
48
59
|
'collapsable',
|
|
49
60
|
'collapsableChildren',
|
|
61
|
+
'collapsed',
|
|
62
|
+
'collapsible',
|
|
50
63
|
'color',
|
|
51
64
|
'colors',
|
|
52
65
|
'contentInset',
|
|
53
66
|
'contentInsetAdjustmentBehavior',
|
|
54
67
|
'contentOffset',
|
|
68
|
+
'contextMenu',
|
|
55
69
|
'contextMenuHidden',
|
|
70
|
+
'controlSize',
|
|
56
71
|
'cursorColor',
|
|
57
72
|
'dataDetectorType',
|
|
58
73
|
'dataDetectorTypes',
|
|
@@ -62,6 +77,8 @@ export const WRITTEN_PROPS = [
|
|
|
62
77
|
'disableFullscreenUI',
|
|
63
78
|
'disableIntervalMomentum',
|
|
64
79
|
'disabled',
|
|
80
|
+
'dragItem',
|
|
81
|
+
'drawable',
|
|
65
82
|
'dynamicTypeRamp',
|
|
66
83
|
'edges',
|
|
67
84
|
'editable',
|
|
@@ -71,6 +88,7 @@ export const WRITTEN_PROPS = [
|
|
|
71
88
|
'endFillColor',
|
|
72
89
|
'fadeDuration',
|
|
73
90
|
'fadingEdgeLength',
|
|
91
|
+
'fileDrop',
|
|
74
92
|
'flexDirection',
|
|
75
93
|
'focusable',
|
|
76
94
|
'hardwareAccelerated',
|
|
@@ -88,6 +106,8 @@ export const WRITTEN_PROPS = [
|
|
|
88
106
|
'keyboardAppearance',
|
|
89
107
|
'keyboardDismissMode',
|
|
90
108
|
'keyboardType',
|
|
109
|
+
'kind',
|
|
110
|
+
'label',
|
|
91
111
|
'lineBreakStrategyIOS',
|
|
92
112
|
'loadingIndicatorSource',
|
|
93
113
|
'maintainVisibleContentPosition',
|
|
@@ -110,6 +130,8 @@ export const WRITTEN_PROPS = [
|
|
|
110
130
|
'onTintColor',
|
|
111
131
|
'overScrollMode',
|
|
112
132
|
'pagingEnabled',
|
|
133
|
+
'paneMaxWidth',
|
|
134
|
+
'paneMinWidth',
|
|
113
135
|
'passwordRules',
|
|
114
136
|
'persistentScrollbar',
|
|
115
137
|
'pinchGestureEnabled',
|
|
@@ -137,16 +159,19 @@ export const WRITTEN_PROPS = [
|
|
|
137
159
|
'secureTextEntry',
|
|
138
160
|
'selectTextOnFocus',
|
|
139
161
|
'selectable',
|
|
162
|
+
'selected',
|
|
140
163
|
'selection',
|
|
141
164
|
'selectionColor',
|
|
142
165
|
'selectionHandleColor',
|
|
143
166
|
'sendMomentumEvents',
|
|
167
|
+
'sfSymbol',
|
|
144
168
|
'shouldRasterizeIOS',
|
|
145
169
|
'showSoftInputOnFocus',
|
|
146
170
|
'showsHorizontalScrollIndicator',
|
|
147
171
|
'showsVerticalScrollIndicator',
|
|
148
172
|
'size',
|
|
149
173
|
'smartInsertDelete',
|
|
174
|
+
'smartQuotes',
|
|
150
175
|
'snapToAlignment',
|
|
151
176
|
'snapToEnd',
|
|
152
177
|
'snapToInterval',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"written-props.js","sourceRoot":"","sources":["../src/written-props.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Every prop the components send through a host binding or a write from code, under the native\n * view's own name, which is often not the name of any input. `native-props.test.ts` holds it to\n * the sources.\n */\nexport const WRITTEN_PROPS: readonly string[] = [\n 'accessibilityActions',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityIgnoresInvertColors',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityLanguage',\n 'accessibilityLargeContentTitle',\n 'accessibilityLiveRegion',\n 'accessibilityRespondsToUserInteraction',\n 'accessibilityRole',\n 'accessibilityShowsLargeContentViewer',\n 'accessibilityState',\n 'accessibilityValue',\n 'accessibilityViewIsModal',\n 'accessible',\n 'adjustsFontSizeToFit',\n 'allowFontScaling',\n 'allowSwipeDismissal',\n 'alwaysBounceHorizontal',\n 'alwaysBounceVertical',\n 'android_hyphenationFrequency',\n 'animating',\n 'animationType',\n 'autoCapitalize',\n 'autoComplete',\n 'autoCorrect',\n 'autoFocus',\n 'automaticallyAdjustContentInsets',\n 'automaticallyAdjustKeyboardInsets',\n 'automaticallyAdjustsScrollIndicatorInsets',\n 'backgroundColor',\n 'blurRadius',\n 'bounces',\n 'bouncesZoom',\n 'canCancelContentTouches',\n 'capInsets',\n 'caretHidden',\n 'centerContent',\n 'clearButtonMode',\n 'clearTextOnFocus',\n 'collapsable',\n 'collapsableChildren',\n 'color',\n 'colors',\n 'contentInset',\n 'contentInsetAdjustmentBehavior',\n 'contentOffset',\n 'contextMenuHidden',\n 'cursorColor',\n 'dataDetectorType',\n 'dataDetectorTypes',\n 'decelerationRate',\n 'defaultSource',\n 'directionalLockEnabled',\n 'disableFullscreenUI',\n 'disableIntervalMomentum',\n 'disabled',\n 'dynamicTypeRamp',\n 'edges',\n 'editable',\n 'ellipsizeMode',\n 'enabled',\n 'enablesReturnKeyAutomatically',\n 'endFillColor',\n 'fadeDuration',\n 'fadingEdgeLength',\n 'flexDirection',\n 'focusable',\n 'hardwareAccelerated',\n 'hidesWhenStopped',\n 'hitSlop',\n 'horizontal',\n 'importantForAutofill',\n 'indeterminate',\n 'indicatorStyle',\n 'inlineImageLeft',\n 'inlineImagePadding',\n 'inputAccessoryViewID',\n 'isHighlighted',\n 'isPressable',\n 'keyboardAppearance',\n 'keyboardDismissMode',\n 'keyboardType',\n 'lineBreakStrategyIOS',\n 'loadingIndicatorSource',\n 'maintainVisibleContentPosition',\n 'maxFontSizeMultiplier',\n 'maxLength',\n 'maximumZoomScale',\n 'minimumFontScale',\n 'minimumZoomScale',\n 'mode',\n 'mostRecentEventCount',\n 'multiline',\n 'nativeBackgroundAndroid',\n 'nativeForegroundAndroid',\n 'nativeID',\n 'navigationBarTranslucent',\n 'needsOffscreenAlphaCompositing',\n 'nestedScrollEnabled',\n 'numberOfLines',\n 'on',\n 'onTintColor',\n 'overScrollMode',\n 'pagingEnabled',\n 'passwordRules',\n 'persistentScrollbar',\n 'pinchGestureEnabled',\n 'placeholder',\n 'placeholderTextColor',\n 'pointerEvents',\n 'presentationStyle',\n 'progressBackgroundColor',\n 'progressViewOffset',\n 'progressiveRenderingEnabled',\n 'refreshing',\n 'removeClippedSubviews',\n 'renderToHardwareTextureAndroid',\n 'resizeMethod',\n 'resizeMode',\n 'resizeMultiplier',\n 'returnKeyType',\n 'role',\n 'rows',\n 'scrollEnabled',\n 'scrollEventThrottle',\n 'scrollIndicatorInsets',\n 'scrollToOverflowEnabled',\n 'scrollsToTop',\n 'secureTextEntry',\n 'selectTextOnFocus',\n 'selectable',\n 'selection',\n 'selectionColor',\n 'selectionHandleColor',\n 'sendMomentumEvents',\n 'shouldRasterizeIOS',\n 'showSoftInputOnFocus',\n 'showsHorizontalScrollIndicator',\n 'showsVerticalScrollIndicator',\n 'size',\n 'smartInsertDelete',\n 'snapToAlignment',\n 'snapToEnd',\n 'snapToInterval',\n 'snapToOffsets',\n 'snapToStart',\n 'source',\n 'spellCheck',\n 'statusBarTranslucent',\n 'styleAttr',\n 'submitBehavior',\n 'supportedOrientations',\n 'testID',\n 'text',\n 'textAlign',\n 'textAlignVertical',\n 'textBreakStrategy',\n 'textContentType',\n 'thumbTintColor',\n 'tintColor',\n 'title',\n 'titleColor',\n 'trackColorForFalse',\n 'trackColorForTrue',\n 'trackTintColor',\n 'transform',\n 'transparent',\n 'underlineColorAndroid',\n 'value',\n 'visible',\n 'zIndex',\n 'zoomScale',\n];\n"]}
|
|
1
|
+
{"version":3,"file":"written-props.js","sourceRoot":"","sources":["../src/written-props.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Every prop the components send through a host binding or a write from code, under the native\n * view's own name, which is often not the name of any input. `native-props.test.ts` holds it to\n * the sources.\n */\nexport const WRITTEN_PROPS: readonly string[] = [\n 'accessibilityActions',\n 'accessibilityColumnCount',\n 'accessibilityDescribedBy',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityIgnoresInvertColors',\n 'accessibilityInvalid',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityLanguage',\n 'accessibilityLargeContentTitle',\n 'accessibilityLevel',\n 'accessibilityLiveRegion',\n 'accessibilityPosInSet',\n 'accessibilityRequired',\n 'accessibilityRespondsToUserInteraction',\n 'accessibilityRole',\n 'accessibilityRowCount',\n 'accessibilitySetSize',\n 'accessibilityShowsLargeContentViewer',\n 'accessibilityState',\n 'accessibilityValue',\n 'accessibilityViewIsModal',\n 'accessible',\n 'adjustsFontSizeToFit',\n 'allowFontScaling',\n 'allowSwipeDismissal',\n 'anchor',\n 'alwaysBounceHorizontal',\n 'alwaysBounceVertical',\n 'android_hyphenationFrequency',\n 'animating',\n 'animationType',\n 'autoCapitalize',\n 'autoComplete',\n 'autoCorrect',\n 'autoFocus',\n 'automaticallyAdjustContentInsets',\n 'automaticallyAdjustKeyboardInsets',\n 'automaticallyAdjustsScrollIndicatorInsets',\n 'autosaveName',\n 'backgroundColor',\n 'badge',\n 'blurRadius',\n 'bounces',\n 'bouncesZoom',\n 'canCancelContentTouches',\n 'capInsets',\n 'caretHidden',\n 'centerContent',\n 'clearButtonMode',\n 'clearTextOnFocus',\n 'collapsable',\n 'collapsableChildren',\n 'collapsed',\n 'collapsible',\n 'color',\n 'colors',\n 'contentInset',\n 'contentInsetAdjustmentBehavior',\n 'contentOffset',\n 'contextMenu',\n 'contextMenuHidden',\n 'controlSize',\n 'cursorColor',\n 'dataDetectorType',\n 'dataDetectorTypes',\n 'decelerationRate',\n 'defaultSource',\n 'directionalLockEnabled',\n 'disableFullscreenUI',\n 'disableIntervalMomentum',\n 'disabled',\n 'dragItem',\n 'drawable',\n 'dynamicTypeRamp',\n 'edges',\n 'editable',\n 'ellipsizeMode',\n 'enabled',\n 'enablesReturnKeyAutomatically',\n 'endFillColor',\n 'fadeDuration',\n 'fadingEdgeLength',\n 'fileDrop',\n 'flexDirection',\n 'focusable',\n 'hardwareAccelerated',\n 'hidesWhenStopped',\n 'hitSlop',\n 'horizontal',\n 'importantForAutofill',\n 'indeterminate',\n 'indicatorStyle',\n 'inlineImageLeft',\n 'inlineImagePadding',\n 'inputAccessoryViewID',\n 'isHighlighted',\n 'isPressable',\n 'keyboardAppearance',\n 'keyboardDismissMode',\n 'keyboardType',\n 'kind',\n 'label',\n 'lineBreakStrategyIOS',\n 'loadingIndicatorSource',\n 'maintainVisibleContentPosition',\n 'maxFontSizeMultiplier',\n 'maxLength',\n 'maximumZoomScale',\n 'minimumFontScale',\n 'minimumZoomScale',\n 'mode',\n 'mostRecentEventCount',\n 'multiline',\n 'nativeBackgroundAndroid',\n 'nativeForegroundAndroid',\n 'nativeID',\n 'navigationBarTranslucent',\n 'needsOffscreenAlphaCompositing',\n 'nestedScrollEnabled',\n 'numberOfLines',\n 'on',\n 'onTintColor',\n 'overScrollMode',\n 'pagingEnabled',\n 'paneMaxWidth',\n 'paneMinWidth',\n 'passwordRules',\n 'persistentScrollbar',\n 'pinchGestureEnabled',\n 'placeholder',\n 'placeholderTextColor',\n 'pointerEvents',\n 'presentationStyle',\n 'progressBackgroundColor',\n 'progressViewOffset',\n 'progressiveRenderingEnabled',\n 'refreshing',\n 'removeClippedSubviews',\n 'renderToHardwareTextureAndroid',\n 'resizeMethod',\n 'resizeMode',\n 'resizeMultiplier',\n 'returnKeyType',\n 'role',\n 'rows',\n 'scrollEnabled',\n 'scrollEventThrottle',\n 'scrollIndicatorInsets',\n 'scrollToOverflowEnabled',\n 'scrollsToTop',\n 'secureTextEntry',\n 'selectTextOnFocus',\n 'selectable',\n 'selected',\n 'selection',\n 'selectionColor',\n 'selectionHandleColor',\n 'sendMomentumEvents',\n 'sfSymbol',\n 'shouldRasterizeIOS',\n 'showSoftInputOnFocus',\n 'showsHorizontalScrollIndicator',\n 'showsVerticalScrollIndicator',\n 'size',\n 'smartInsertDelete',\n 'smartQuotes',\n 'snapToAlignment',\n 'snapToEnd',\n 'snapToInterval',\n 'snapToOffsets',\n 'snapToStart',\n 'source',\n 'spellCheck',\n 'statusBarTranslucent',\n 'styleAttr',\n 'submitBehavior',\n 'supportedOrientations',\n 'testID',\n 'text',\n 'textAlign',\n 'textAlignVertical',\n 'textBreakStrategy',\n 'textContentType',\n 'thumbTintColor',\n 'tintColor',\n 'title',\n 'titleColor',\n 'trackColorForFalse',\n 'trackColorForTrue',\n 'trackTintColor',\n 'transform',\n 'transparent',\n 'underlineColorAndroid',\n 'value',\n 'visible',\n 'zIndex',\n 'zoomScale',\n];\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#import <React/RCTComponentViewFactory.h>
|
|
2
|
+
#import <React/RCTViewComponentView.h>
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
#import "NgNativeButtonMetrics.h"
|
|
6
|
+
#import "NgNativeButtonShadowNode.h"
|
|
7
|
+
|
|
8
|
+
using namespace facebook::react;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
`<native-button>` on iOS: a UIButton drawn from a button configuration, the glass ones on iOS 26
|
|
12
|
+
and later. `kind` picks the style (`default` the prominent one, `destructive` in red, `plain`
|
|
13
|
+
borderless, anything else the plain push button), `controlSize` UIButton's own size with the
|
|
14
|
+
metrics the shadow node measures with, and a tap sends `topButtonPress`. The title follows the
|
|
15
|
+
user's text size: the button is configured again as it changes, and React Native measures it again.
|
|
16
|
+
Return and Escape press no button on iOS: `default` and `cancel` are only styles there.
|
|
17
|
+
*/
|
|
18
|
+
@interface NgNativeButtonComponentView : RCTViewComponentView
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
static NSString *string(const std::string &value)
|
|
22
|
+
{
|
|
23
|
+
return [[NSString alloc] initWithBytes:value.data() length:value.size() encoding:NSUTF8StringEncoding] ?: @"";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static UIButtonConfiguration *configurationForKind(NSString *kind)
|
|
27
|
+
{
|
|
28
|
+
if ([kind isEqualToString:@"plain"]) {
|
|
29
|
+
return [UIButtonConfiguration plainButtonConfiguration];
|
|
30
|
+
}
|
|
31
|
+
BOOL prominent = [kind isEqualToString:@"default"];
|
|
32
|
+
if (@available(iOS 26.0, *)) {
|
|
33
|
+
return prominent ? [UIButtonConfiguration prominentGlassButtonConfiguration]
|
|
34
|
+
: [UIButtonConfiguration glassButtonConfiguration];
|
|
35
|
+
}
|
|
36
|
+
return prominent ? [UIButtonConfiguration filledButtonConfiguration] : [UIButtonConfiguration grayButtonConfiguration];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@implementation NgNativeButtonComponentView {
|
|
40
|
+
UIButton *_button;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
+ (void)load
|
|
44
|
+
{
|
|
45
|
+
// Registered before any surface asks for it: a name nothing registered draws as unimplemented.
|
|
46
|
+
[[RCTComponentViewFactory currentComponentViewFactory] registerComponentViewClass:self];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
50
|
+
{
|
|
51
|
+
return concreteComponentDescriptorProvider<NgNativeButtonComponentDescriptor>();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
55
|
+
{
|
|
56
|
+
if (self = [super initWithFrame:frame]) {
|
|
57
|
+
_props = NgNativeButtonShadowNode::defaultSharedProps();
|
|
58
|
+
_button = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
59
|
+
__weak NgNativeButtonComponentView *weakSelf = self;
|
|
60
|
+
[_button addAction:[UIAction actionWithHandler:^(__kindof UIAction *action) {
|
|
61
|
+
[weakSelf ngn_sendPress];
|
|
62
|
+
}]
|
|
63
|
+
forControlEvents:UIControlEventPrimaryActionTriggered];
|
|
64
|
+
self.contentView = _button;
|
|
65
|
+
[self ngn_configureWith:static_cast<const NgNativeButtonProps &>(*_props)];
|
|
66
|
+
}
|
|
67
|
+
return self;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// VoiceOver reads the button, with the label and traits React Native sets on the element.
|
|
71
|
+
- (NSObject *)accessibilityElement
|
|
72
|
+
{
|
|
73
|
+
return _button;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
77
|
+
{
|
|
78
|
+
const auto &newProps = static_cast<const NgNativeButtonProps &>(*props);
|
|
79
|
+
const auto &previous = static_cast<const NgNativeButtonProps &>(*_props);
|
|
80
|
+
BOOL changed = newProps.title != previous.title || newProps.kind != previous.kind ||
|
|
81
|
+
newProps.controlSize != previous.controlSize || newProps.sfSymbol != previous.sfSymbol;
|
|
82
|
+
[super updateProps:props oldProps:oldProps];
|
|
83
|
+
if (changed) {
|
|
84
|
+
[self ngn_configureWith:newProps];
|
|
85
|
+
}
|
|
86
|
+
_button.enabled = newProps.enabled;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
- (void)ngn_configureWith:(const NgNativeButtonProps &)props
|
|
90
|
+
{
|
|
91
|
+
NSString *kind = string(props.kind);
|
|
92
|
+
NSString *controlSize = string(props.controlSize);
|
|
93
|
+
UIButtonConfiguration *configuration = configurationForKind(kind);
|
|
94
|
+
configuration.buttonSize = NgNativeButtonConfigurationSize(controlSize);
|
|
95
|
+
configuration.contentInsets = NgNativeButtonInsets(controlSize);
|
|
96
|
+
configuration.title = string(props.title);
|
|
97
|
+
configuration.titleLineBreakMode = NSLineBreakByTruncatingTail;
|
|
98
|
+
configuration.image = NgNativeButtonSymbol(string(props.sfSymbol), controlSize);
|
|
99
|
+
configuration.imagePadding = NgNativeButtonImagePadding;
|
|
100
|
+
UIFont *font = NgNativeButtonFont(controlSize);
|
|
101
|
+
configuration.titleTextAttributesTransformer = ^NSDictionary<NSAttributedStringKey, id> *(
|
|
102
|
+
NSDictionary<NSAttributedStringKey, id> *attributes) {
|
|
103
|
+
NSMutableDictionary *withFont = [attributes mutableCopy];
|
|
104
|
+
withFont[NSFontAttributeName] = font;
|
|
105
|
+
return withFont;
|
|
106
|
+
};
|
|
107
|
+
if ([kind isEqualToString:@"destructive"]) {
|
|
108
|
+
configuration.baseForegroundColor = UIColor.systemRedColor;
|
|
109
|
+
}
|
|
110
|
+
_button.configuration = configuration;
|
|
111
|
+
// One line, so the title truncates in a box narrower than it.
|
|
112
|
+
_button.titleLabel.numberOfLines = 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
- (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitCollection
|
|
116
|
+
{
|
|
117
|
+
[super traitCollectionDidChange:previousTraitCollection];
|
|
118
|
+
// The font is fixed in the configuration, at the text size it was made at.
|
|
119
|
+
if (![self.traitCollection.preferredContentSizeCategory
|
|
120
|
+
isEqualToString:previousTraitCollection.preferredContentSizeCategory]) {
|
|
121
|
+
[self ngn_configureWith:static_cast<const NgNativeButtonProps &>(*_props)];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
- (void)ngn_sendPress
|
|
126
|
+
{
|
|
127
|
+
if (_eventEmitter) {
|
|
128
|
+
std::static_pointer_cast<const NgNativeButtonEventEmitter>(_eventEmitter)->onButtonPress();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// How `<native-button>` is drawn and measured on iOS, in one place: the view configures its
|
|
2
|
+
// UIButton with these and the shadow node measures with them, so Yoga's size is the button's.
|
|
3
|
+
// Every call is safe off the main thread, where Fabric measures.
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#import <UIKit/UIKit.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
// The title's font for a `controlSize`, at the user's text size.
|
|
11
|
+
UIFont *NgNativeButtonFont(NSString *controlSize);
|
|
12
|
+
|
|
13
|
+
// The space around the title and symbol for a `controlSize`.
|
|
14
|
+
NSDirectionalEdgeInsets NgNativeButtonInsets(NSString *controlSize);
|
|
15
|
+
|
|
16
|
+
// UIButton's own size class for a `controlSize`: mini, small, medium (regular) or large.
|
|
17
|
+
UIButtonConfigurationSize NgNativeButtonConfigurationSize(NSString *controlSize);
|
|
18
|
+
|
|
19
|
+
// Between the symbol and the title.
|
|
20
|
+
extern const CGFloat NgNativeButtonImagePadding;
|
|
21
|
+
|
|
22
|
+
// The symbol drawn beside the title, or nil for none or a name the OS lacks.
|
|
23
|
+
UIImage *_Nullable NgNativeButtonSymbol(NSString *sfSymbol, NSString *controlSize);
|
|
24
|
+
|
|
25
|
+
// The button's natural size: one line of title, the symbol, and the insets.
|
|
26
|
+
CGSize NgNativeButtonNaturalSize(NSString *title, NSString *controlSize, NSString *sfSymbol);
|
|
27
|
+
|
|
28
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#import "NgNativeButtonMetrics.h"
|
|
2
|
+
|
|
3
|
+
const CGFloat NgNativeButtonImagePadding = 6;
|
|
4
|
+
|
|
5
|
+
UIFont *NgNativeButtonFont(NSString *controlSize)
|
|
6
|
+
{
|
|
7
|
+
if ([controlSize isEqualToString:@"mini"]) {
|
|
8
|
+
return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
|
|
9
|
+
}
|
|
10
|
+
if ([controlSize isEqualToString:@"small"]) {
|
|
11
|
+
return [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
|
|
12
|
+
}
|
|
13
|
+
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
NSDirectionalEdgeInsets NgNativeButtonInsets(NSString *controlSize)
|
|
17
|
+
{
|
|
18
|
+
if ([controlSize isEqualToString:@"mini"]) {
|
|
19
|
+
return NSDirectionalEdgeInsetsMake(3, 8, 3, 8);
|
|
20
|
+
}
|
|
21
|
+
if ([controlSize isEqualToString:@"small"]) {
|
|
22
|
+
return NSDirectionalEdgeInsetsMake(5, 10, 5, 10);
|
|
23
|
+
}
|
|
24
|
+
if ([controlSize isEqualToString:@"large"]) {
|
|
25
|
+
return NSDirectionalEdgeInsetsMake(14, 20, 14, 20);
|
|
26
|
+
}
|
|
27
|
+
return NSDirectionalEdgeInsetsMake(7, 14, 7, 14);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
UIButtonConfigurationSize NgNativeButtonConfigurationSize(NSString *controlSize)
|
|
31
|
+
{
|
|
32
|
+
if ([controlSize isEqualToString:@"mini"]) {
|
|
33
|
+
return UIButtonConfigurationSizeMini;
|
|
34
|
+
}
|
|
35
|
+
if ([controlSize isEqualToString:@"small"]) {
|
|
36
|
+
return UIButtonConfigurationSizeSmall;
|
|
37
|
+
}
|
|
38
|
+
if ([controlSize isEqualToString:@"large"]) {
|
|
39
|
+
return UIButtonConfigurationSizeLarge;
|
|
40
|
+
}
|
|
41
|
+
return UIButtonConfigurationSizeMedium;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
UIImage *_Nullable NgNativeButtonSymbol(NSString *sfSymbol, NSString *controlSize)
|
|
45
|
+
{
|
|
46
|
+
if (sfSymbol.length == 0) {
|
|
47
|
+
return nil;
|
|
48
|
+
}
|
|
49
|
+
UIImageSymbolConfiguration *configuration =
|
|
50
|
+
[UIImageSymbolConfiguration configurationWithFont:NgNativeButtonFont(controlSize)
|
|
51
|
+
scale:UIImageSymbolScaleMedium];
|
|
52
|
+
return [UIImage systemImageNamed:sfSymbol withConfiguration:configuration];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
CGSize NgNativeButtonNaturalSize(NSString *title, NSString *controlSize, NSString *sfSymbol)
|
|
56
|
+
{
|
|
57
|
+
UIFont *font = NgNativeButtonFont(controlSize);
|
|
58
|
+
CGSize text = title.length > 0 ? [title sizeWithAttributes:@{NSFontAttributeName : font}] : CGSizeZero;
|
|
59
|
+
CGFloat width = ceil(text.width);
|
|
60
|
+
CGFloat height = ceil(MAX(text.height, font.lineHeight));
|
|
61
|
+
UIImage *symbol = NgNativeButtonSymbol(sfSymbol, controlSize);
|
|
62
|
+
if (symbol != nil) {
|
|
63
|
+
width += ceil(symbol.size.width) + (title.length > 0 ? NgNativeButtonImagePadding : 0);
|
|
64
|
+
height = MAX(height, ceil(symbol.size.height));
|
|
65
|
+
}
|
|
66
|
+
NSDirectionalEdgeInsets insets = NgNativeButtonInsets(controlSize);
|
|
67
|
+
return CGSizeMake(width + insets.leading + insets.trailing, height + insets.top + insets.bottom);
|
|
68
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// `<native-button>` on iOS: the C++ side of the `NgNativeButton` Fabric component, which React
|
|
2
|
+
// Native's codegen would write for a React component. The props are the element's (title, kind,
|
|
3
|
+
// controlSize, sfSymbol, enabled), the event is `topButtonPress`, and the shadow node measures the
|
|
4
|
+
// button for Yoga from the same metrics the view draws it with (NgNativeButtonMetrics).
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
8
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
9
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
10
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
11
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
extern const char NgNativeButtonComponentName[];
|
|
18
|
+
|
|
19
|
+
class NgNativeButtonProps final : public ViewProps {
|
|
20
|
+
public:
|
|
21
|
+
NgNativeButtonProps() = default;
|
|
22
|
+
NgNativeButtonProps(
|
|
23
|
+
const PropsParserContext &context,
|
|
24
|
+
const NgNativeButtonProps &sourceProps,
|
|
25
|
+
const RawProps &rawProps);
|
|
26
|
+
|
|
27
|
+
std::string title{};
|
|
28
|
+
// `default`, `cancel`, `destructive`, `plain`, or empty for a plain push button.
|
|
29
|
+
std::string kind{};
|
|
30
|
+
// `mini`, `small`, `regular` or `large`; empty is `regular`.
|
|
31
|
+
std::string controlSize{};
|
|
32
|
+
std::string sfSymbol{};
|
|
33
|
+
bool enabled{true};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
class NgNativeButtonEventEmitter : public ViewEventEmitter {
|
|
37
|
+
public:
|
|
38
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
39
|
+
|
|
40
|
+
void onButtonPress() const
|
|
41
|
+
{
|
|
42
|
+
dispatchEvent("buttonPress");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
class NgNativeButtonShadowNode final
|
|
47
|
+
: public ConcreteViewShadowNode<NgNativeButtonComponentName, NgNativeButtonProps, NgNativeButtonEventEmitter> {
|
|
48
|
+
public:
|
|
49
|
+
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
|
50
|
+
|
|
51
|
+
static ShadowNodeTraits BaseTraits()
|
|
52
|
+
{
|
|
53
|
+
auto traits = ConcreteViewShadowNode::BaseTraits();
|
|
54
|
+
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
|
|
55
|
+
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
|
|
56
|
+
return traits;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Size measureContent(const LayoutContext &layoutContext, const LayoutConstraints &layoutConstraints)
|
|
60
|
+
const override;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
using NgNativeButtonComponentDescriptor = ConcreteComponentDescriptor<NgNativeButtonShadowNode>;
|
|
64
|
+
|
|
65
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include "NgNativeButtonShadowNode.h"
|
|
2
|
+
|
|
3
|
+
#import <react/renderer/core/LayoutConstraints.h>
|
|
4
|
+
#import <react/renderer/core/propsConversions.h>
|
|
5
|
+
|
|
6
|
+
#import "NgNativeButtonMetrics.h"
|
|
7
|
+
|
|
8
|
+
namespace facebook::react {
|
|
9
|
+
|
|
10
|
+
extern const char NgNativeButtonComponentName[] = "NgNativeButton";
|
|
11
|
+
|
|
12
|
+
NgNativeButtonProps::NgNativeButtonProps(
|
|
13
|
+
const PropsParserContext &context,
|
|
14
|
+
const NgNativeButtonProps &sourceProps,
|
|
15
|
+
const RawProps &rawProps)
|
|
16
|
+
: ViewProps(context, sourceProps, rawProps),
|
|
17
|
+
title(convertRawProp(context, rawProps, "title", sourceProps.title, {})),
|
|
18
|
+
kind(convertRawProp(context, rawProps, "kind", sourceProps.kind, {})),
|
|
19
|
+
controlSize(convertRawProp(context, rawProps, "controlSize", sourceProps.controlSize, {})),
|
|
20
|
+
sfSymbol(convertRawProp(context, rawProps, "sfSymbol", sourceProps.sfSymbol, {})),
|
|
21
|
+
enabled(convertRawProp(context, rawProps, "enabled", sourceProps.enabled, true))
|
|
22
|
+
{
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static NSString *string(const std::string &value)
|
|
26
|
+
{
|
|
27
|
+
return [[NSString alloc] initWithBytes:value.data() length:value.size() encoding:NSUTF8StringEncoding] ?: @"";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Size NgNativeButtonShadowNode::measureContent(
|
|
31
|
+
const LayoutContext & /*layoutContext*/,
|
|
32
|
+
const LayoutConstraints &layoutConstraints) const
|
|
33
|
+
{
|
|
34
|
+
const auto &props = getConcreteProps();
|
|
35
|
+
CGSize size = NgNativeButtonNaturalSize(string(props.title), string(props.controlSize), string(props.sfSymbol));
|
|
36
|
+
// A narrower box truncates the title rather than wrapping it.
|
|
37
|
+
return layoutConstraints.clamp({.width = (Float)size.width, .height = (Float)size.height});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
# The iOS side of the elements whose native view or module the host draws: `<native-button>` as a
|
|
6
|
+
# UIButton, `<split-view>` on an iPad as a UISplitViewController, the `NgNativeWindows` module,
|
|
7
|
+
# which opens `AppWindows` as iPadOS scenes, and the `NgNativeMenus`, `NgNativeUndo` and
|
|
8
|
+
# `NgNativeDragAndDrop` modules, which add context menus, drops and drags to React Native's own
|
|
9
|
+
# views by `nativeID`. Fabric components, so React Native's own C++ is a
|
|
10
|
+
# dependency.
|
|
11
|
+
Pod::Spec.new do |s|
|
|
12
|
+
s.name = 'NgNativeComponents'
|
|
13
|
+
s.version = package['version']
|
|
14
|
+
s.summary = package['description']
|
|
15
|
+
s.description = package['description']
|
|
16
|
+
s.license = package['license']
|
|
17
|
+
s.author = 'Angular Native'
|
|
18
|
+
s.homepage = 'https://github.com/ng-native/ng-native'
|
|
19
|
+
s.platforms = { :ios => '16.4' }
|
|
20
|
+
s.source = { git: 'https://github.com/ng-native/ng-native.git' }
|
|
21
|
+
s.static_framework = true
|
|
22
|
+
|
|
23
|
+
s.source_files = '**/*.{h,mm}'
|
|
24
|
+
# The unit tests build on their own: `tests/run-tests.sh`.
|
|
25
|
+
s.exclude_files = 'tests/**/*'
|
|
26
|
+
s.dependency 'React-Core'
|
|
27
|
+
install_modules_dependencies(s)
|
|
28
|
+
end
|