react-native-platform-components 1.1.0 → 1.3.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 +23 -12
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/platformcomponents/PCDatePickerView.kt +46 -2
- package/android/src/main/java/com/platformcomponents/PCNativeTheme.kt +174 -0
- package/android/src/main/java/com/platformcomponents/PCNativeThemeModule.kt +45 -0
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlView.kt +36 -3
- package/android/src/main/java/com/platformcomponents/PCSelectionMenuView.kt +14 -0
- package/android/src/main/java/com/platformcomponents/PCThemeSupport.kt +40 -5
- package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +25 -5
- package/android/src/main/jni/CMakeLists.txt +13 -1
- package/android/src/main/res/values/styles.xml +131 -0
- package/ios/PCNativeTheme.swift +56 -0
- package/ios/PCNativeThemeModule.mm +49 -0
- package/ios/PCSelectionMenu.swift +9 -1
- package/lib/commonjs/ContextMenuNativeComponent.ts +5 -4
- package/lib/commonjs/DatePickerNativeComponent.ts +17 -11
- 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 +10 -0
- package/lib/commonjs/NativePlatformComponentsTheme.js.map +1 -0
- package/lib/commonjs/NativeTheme.js +51 -0
- package/lib/commonjs/NativeTheme.js.map +1 -0
- package/lib/commonjs/SegmentedControlNativeComponent.ts +12 -11
- package/lib/commonjs/SelectionMenuNativeComponent.ts +6 -5
- package/lib/commonjs/codegenTypes.js +6 -0
- package/lib/commonjs/codegenTypes.js.map +1 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +10 -1
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/module/ContextMenuNativeComponent.ts +5 -4
- package/lib/module/DatePickerNativeComponent.ts +17 -11
- 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 +7 -0
- package/lib/module/NativePlatformComponentsTheme.js.map +1 -0
- package/lib/module/NativeTheme.js +45 -0
- package/lib/module/NativeTheme.js.map +1 -0
- package/lib/module/SegmentedControlNativeComponent.ts +12 -11
- package/lib/module/SelectionMenuNativeComponent.ts +6 -5
- package/lib/module/codegenTypes.js +4 -0
- package/lib/module/codegenTypes.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +7 -0
- package/lib/module/index.web.js.map +1 -1
- 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/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 +19 -0
- package/lib/typescript/commonjs/src/NativePlatformComponentsTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeTheme.d.ts +30 -0
- package/lib/typescript/commonjs/src/NativeTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +7 -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/codegenTypes.d.ts +12 -0
- package/lib/typescript/commonjs/src/codegenTypes.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +1 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.web.d.ts +8 -1
- package/lib/typescript/commonjs/src/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sharedTypes.d.ts +2 -2
- package/lib/typescript/commonjs/src/sharedTypes.d.ts.map +1 -1
- 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/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 +19 -0
- package/lib/typescript/module/src/NativePlatformComponentsTheme.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeTheme.d.ts +30 -0
- package/lib/typescript/module/src/NativeTheme.d.ts.map +1 -0
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +7 -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/codegenTypes.d.ts +12 -0
- package/lib/typescript/module/src/codegenTypes.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +1 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.web.d.ts +8 -1
- package/lib/typescript/module/src/index.web.d.ts.map +1 -1
- package/lib/typescript/module/src/sharedTypes.d.ts +2 -2
- package/lib/typescript/module/src/sharedTypes.d.ts.map +1 -1
- package/package.json +8 -4
- package/shared/PCDatePickerState-custom.h +2 -2
- package/shared/PCSegmentedControlState-custom.h +2 -2
- package/shared/PCSelectionMenuState-custom.h +2 -2
- package/src/ContextMenuNativeComponent.ts +5 -4
- package/src/DatePickerNativeComponent.ts +17 -11
- package/src/LiquidGlass.tsx +24 -5
- package/src/LiquidGlassNativeComponent.ts +6 -5
- package/src/NativePlatformComponentsTheme.ts +22 -0
- package/src/NativeTheme.ts +53 -0
- package/src/SegmentedControlNativeComponent.ts +12 -11
- package/src/SelectionMenuNativeComponent.ts +6 -5
- package/src/codegenTypes.ts +40 -0
- package/src/index.tsx +1 -0
- package/src/index.web.tsx +17 -1
- package/src/sharedTypes.ts +2 -2
- /package/{app.plugin.cjs → app.plugin.js} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import type { BubblingEventHandler, Int32, WithDefault } from './codegenTypes.js';
|
|
2
3
|
/**
|
|
3
4
|
* A single option in the menu.
|
|
4
5
|
*/
|
|
@@ -11,7 +12,7 @@ export type SelectionMenuOption = Readonly<{
|
|
|
11
12
|
*/
|
|
12
13
|
export type SelectionMenuSelectEvent = Readonly<{
|
|
13
14
|
/** Selected option index (implementation detail; stable for this render) */
|
|
14
|
-
index:
|
|
15
|
+
index: Int32;
|
|
15
16
|
/** Selected option label */
|
|
16
17
|
label: string;
|
|
17
18
|
/** Selected option data payload (source of truth) */
|
|
@@ -44,7 +45,7 @@ export interface SelectionMenuProps extends ViewProps {
|
|
|
44
45
|
* - Empty string means "no selection".
|
|
45
46
|
* - Native should treat this as the single source of truth.
|
|
46
47
|
*/
|
|
47
|
-
selectedData?:
|
|
48
|
+
selectedData?: WithDefault<string, ''>;
|
|
48
49
|
/**
|
|
49
50
|
* Enabled / disabled state.
|
|
50
51
|
*/
|
|
@@ -65,11 +66,11 @@ export interface SelectionMenuProps extends ViewProps {
|
|
|
65
66
|
/**
|
|
66
67
|
* Fired when the user selects an option.
|
|
67
68
|
*/
|
|
68
|
-
onSelect?:
|
|
69
|
+
onSelect?: BubblingEventHandler<SelectionMenuSelectEvent>;
|
|
69
70
|
/**
|
|
70
71
|
* Fired when dismissed without selection.
|
|
71
72
|
*/
|
|
72
|
-
onRequestClose?:
|
|
73
|
+
onRequestClose?: BubblingEventHandler<Readonly<{}>>;
|
|
73
74
|
ios?: IOSProps;
|
|
74
75
|
android?: AndroidProps;
|
|
75
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/SelectionMenuNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"SelectionMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/SelectionMenuNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAgB,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,4EAA4E;IAC5E,KAAK,EAAE,KAAK,CAAC;IAEb,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IAEd,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,yCAAyC;AACzC,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,UAAU,CAAC;AAEhE,qCAAqC;AACrC,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACnD;;OAEG;IACH,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAE5C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEvC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;IAE1D;;OAEG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpD,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;wBAII,aAAa,CAAC,kBAAkB,CAAC;AAFtC,wBAEuC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
export type BubblingEventHandler<T, _PaperName extends string | never = never> = (event: NativeSyntheticEvent<T>) => void | Promise<void>;
|
|
3
|
+
export type DirectEventHandler<T, _PaperName extends string | never = never> = (event: NativeSyntheticEvent<T>) => void | Promise<void>;
|
|
4
|
+
export type Double = number;
|
|
5
|
+
export type Float = number;
|
|
6
|
+
export type Int32 = number;
|
|
7
|
+
export type UnsafeObject = object;
|
|
8
|
+
export type UnsafeMixed = unknown;
|
|
9
|
+
type DefaultTypes = number | boolean | string | ReadonlyArray<string>;
|
|
10
|
+
export type WithDefault<Type extends DefaultTypes, _Value extends Type | string | undefined | null> = Type | undefined | null;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=codegenTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegenTypes.d.ts","sourceRoot":"","sources":["../../../../src/codegenTypes.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIzD,MAAM,MAAM,oBAAoB,CAC9B,CAAC,EACD,UAAU,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,IACvC,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,UAAU,SAAS,MAAM,GAAG,KAAK,GAAG,KAAK,IAAI,CAC7E,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAC3B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAG1B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC;AAElC,KAAK,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEtE,MAAM,MAAM,WAAW,CACrB,IAAI,SAAS,YAAY,EACzB,MAAM,SAAS,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,IAC7C,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAc,CAAC;AAC7B,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,kBAAe,CAAC;AAC9B,cAAc,kBAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAc,CAAC;AAC7B,cAAc,oBAAiB,CAAC;AAChC,cAAc,kBAAe,CAAC;AAC9B,cAAc,uBAAoB,CAAC;AACnC,cAAc,kBAAe,CAAC;AAC9B,cAAc,kBAAe,CAAC;AAC9B,cAAc,kBAAe,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
|
+
import type { ColorValue, StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
4
4
|
export type Visible = 'open' | 'closed';
|
|
5
5
|
export type Presentation = 'modal' | 'embedded';
|
|
6
6
|
export type AndroidMaterialMode = 'system' | 'm3';
|
|
@@ -124,4 +124,11 @@ export interface LiquidGlassProps extends ViewProps {
|
|
|
124
124
|
}
|
|
125
125
|
export declare const LiquidGlass: ({ children, }: LiquidGlassProps) => React.ReactElement | null;
|
|
126
126
|
export declare const isLiquidGlassSupported = false;
|
|
127
|
+
export type NativeTheme = {
|
|
128
|
+
colors: {
|
|
129
|
+
primary: ColorValue;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export declare const setNativeTheme: (_theme: NativeTheme | null) => void;
|
|
133
|
+
export declare const useNativeTheme: (_theme: NativeTheme | null | undefined) => void;
|
|
127
134
|
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/index.web.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/index.web.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMhF,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AACxC,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC;AAChD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,IAAI,CAAC;AAMlD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,gBAAgB,CAAC;IAC1D,YAAY,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC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BAA0B,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,qBAAqB,KAC5B,KAAK,CAAC,YAAY,GAAG,IAAY,CAAC;AAMrC,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,GAAI,eAEzB,gBAAgB,KAAG,KAAK,CAAC,YAAY,GAAG,IAE1C,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAM5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE;QACN,OAAO,EAAE,UAAU,CAAC;KACrB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,GAAG,IAAI,KAAG,IAAU,CAAC;AAEvE,eAAO,MAAM,cAAc,GACzB,QAAQ,WAAW,GAAG,IAAI,GAAG,SAAS,KACrC,IAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BubblingEventHandler } from './codegenTypes.js';
|
|
2
2
|
/** Shared "open/closed" control state. */
|
|
3
3
|
export type Visible = 'open' | 'closed';
|
|
4
4
|
/** Shared presentation mode for pickers/menus. */
|
|
@@ -8,5 +8,5 @@ export type AndroidMaterialMode = 'system' | 'm3';
|
|
|
8
8
|
/** Common event empty payload type. */
|
|
9
9
|
export type EmptyEvent = Readonly<{}>;
|
|
10
10
|
/** Convenience alias (optional). */
|
|
11
|
-
export type Bubbling<T> =
|
|
11
|
+
export type Bubbling<T> = BubblingEventHandler<T>;
|
|
12
12
|
//# sourceMappingURL=sharedTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedTypes.d.ts","sourceRoot":"","sources":["../../../../src/sharedTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sharedTypes.d.ts","sourceRoot":"","sources":["../../../../src/sharedTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAgB,CAAC;AAE3D,0CAA0C;AAC1C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExC,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC;AAEhD,4CAA4C;AAC5C,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,IAAI,CAAC;AAElD,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AAEtC,oCAAoC;AACpC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-platform-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Native UI components for React Native that are native on Android too: DatePicker, ContextMenu, SelectionMenu, SegmentedControl (Material 3) and LiquidGlass (iOS 26). Fabric, typed, Expo config plugin.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"./package.json": "./package.json",
|
|
31
|
-
"./app.plugin": "./app.plugin.
|
|
31
|
+
"./app.plugin": "./app.plugin.js",
|
|
32
|
+
"./app.plugin.js": "./app.plugin.js"
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
|
34
35
|
"src",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"plugin",
|
|
41
42
|
"*.podspec",
|
|
42
43
|
"react-native.config.js",
|
|
43
|
-
"app.plugin.
|
|
44
|
+
"app.plugin.js",
|
|
44
45
|
"expo-module.config.json",
|
|
45
46
|
"!ios/build",
|
|
46
47
|
"!android/build",
|
|
@@ -188,12 +189,15 @@
|
|
|
188
189
|
},
|
|
189
190
|
"codegenConfig": {
|
|
190
191
|
"name": "PlatformComponentsViewSpec",
|
|
191
|
-
"type": "
|
|
192
|
+
"type": "all",
|
|
192
193
|
"jsSrcsDir": "src",
|
|
193
194
|
"android": {
|
|
194
195
|
"javaPackageName": "com.platformcomponents"
|
|
195
196
|
},
|
|
196
197
|
"ios": {
|
|
198
|
+
"modulesProvider": {
|
|
199
|
+
"PlatformComponentsTheme": "PCNativeThemeModule"
|
|
200
|
+
},
|
|
197
201
|
"componentProvider": {
|
|
198
202
|
"PCSelectionMenu": "PCSelectionMenu",
|
|
199
203
|
"PCDatePicker": "PCDatePicker",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#include <react/renderer/core/LayoutPrimitives.h>
|
|
4
4
|
#include <memory>
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
7
7
|
#include <folly/dynamic.h>
|
|
8
8
|
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
9
9
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
@@ -37,7 +37,7 @@ struct PCDatePickerStateFrameSize {
|
|
|
37
37
|
return !(*this == other);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
#
|
|
40
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
41
41
|
// Required for Android state serialization
|
|
42
42
|
PCDatePickerStateFrameSize(
|
|
43
43
|
const PCDatePickerStateFrameSize& previousState,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#include <react/renderer/core/LayoutPrimitives.h>
|
|
4
4
|
#include <memory>
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
7
7
|
#include <folly/dynamic.h>
|
|
8
8
|
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
9
9
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
@@ -34,7 +34,7 @@ struct PCSegmentedControlStateFrameSize {
|
|
|
34
34
|
return !(*this == other);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
#
|
|
37
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
38
38
|
// Required for Android state serialization
|
|
39
39
|
PCSegmentedControlStateFrameSize(
|
|
40
40
|
const PCSegmentedControlStateFrameSize& previousState,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#include <react/renderer/core/LayoutPrimitives.h>
|
|
4
4
|
#include <memory>
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
7
7
|
#include <folly/dynamic.h>
|
|
8
8
|
#include <react/renderer/mapbuffer/MapBuffer.h>
|
|
9
9
|
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
|
|
@@ -37,7 +37,7 @@ struct PCSelectionMenuStateFrameSize {
|
|
|
37
37
|
return !(*this == other);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
#
|
|
40
|
+
#if defined(RN_SERIALIZABLE_STATE) || defined(ANDROID)
|
|
41
41
|
// Required for Android state serialization
|
|
42
42
|
PCSelectionMenuStateFrameSize(
|
|
43
43
|
const PCSelectionMenuStateFrameSize& previousState,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// ContextMenuNativeComponent.ts
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
3
3
|
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type { BubblingEventHandler } from './codegenTypes';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Attributes for a context menu action.
|
|
@@ -120,17 +121,17 @@ export interface ContextMenuProps extends ViewProps {
|
|
|
120
121
|
/**
|
|
121
122
|
* Fired when user presses an action.
|
|
122
123
|
*/
|
|
123
|
-
onPressAction?:
|
|
124
|
+
onPressAction?: BubblingEventHandler<ContextMenuPressActionEvent>;
|
|
124
125
|
|
|
125
126
|
/**
|
|
126
127
|
* Fired when menu opens.
|
|
127
128
|
*/
|
|
128
|
-
onMenuOpen?:
|
|
129
|
+
onMenuOpen?: BubblingEventHandler<Readonly<{}>>;
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
132
|
* Fired when menu closes.
|
|
132
133
|
*/
|
|
133
|
-
onMenuClose?:
|
|
134
|
+
onMenuClose?: BubblingEventHandler<Readonly<{}>>;
|
|
134
135
|
|
|
135
136
|
ios?: IOSProps;
|
|
136
137
|
android?: AndroidProps;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
// DatePickerNativeComponent.ts
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
3
3
|
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type {
|
|
5
|
+
BubblingEventHandler,
|
|
6
|
+
Double,
|
|
7
|
+
Int32,
|
|
8
|
+
WithDefault,
|
|
9
|
+
} from './codegenTypes';
|
|
4
10
|
|
|
5
|
-
export type TimestampMs =
|
|
11
|
+
export type TimestampMs = Double;
|
|
6
12
|
|
|
7
13
|
export type DateChangeEvent = {
|
|
8
|
-
timestampMs:
|
|
14
|
+
timestampMs: Double;
|
|
9
15
|
confirmed: boolean;
|
|
10
16
|
};
|
|
11
17
|
|
|
@@ -18,14 +24,14 @@ export type IOSConfirmToolbar = 'show' | 'hide';
|
|
|
18
24
|
|
|
19
25
|
export type IOSProps = {
|
|
20
26
|
preferredStyle?: string; // IOSDatePickerStyle
|
|
21
|
-
countDownDurationSeconds?:
|
|
22
|
-
minuteInterval?:
|
|
27
|
+
countDownDurationSeconds?: Double;
|
|
28
|
+
minuteInterval?: Int32;
|
|
23
29
|
roundsToMinuteInterval?: string; // IOSRoundsToMinuteInterval
|
|
24
30
|
confirmToolbar?: string; // IOSConfirmToolbar
|
|
25
31
|
};
|
|
26
32
|
|
|
27
33
|
export type AndroidProps = {
|
|
28
|
-
firstDayOfWeek?:
|
|
34
|
+
firstDayOfWeek?: Int32;
|
|
29
35
|
material?: string; // AndroidMaterialMode
|
|
30
36
|
dialogTitle?: string;
|
|
31
37
|
positiveButtonTitle?: string;
|
|
@@ -44,9 +50,9 @@ export type MacOSProps = Readonly<{}>;
|
|
|
44
50
|
export type CommonProps = {
|
|
45
51
|
mode?: string; // DatePickerMode
|
|
46
52
|
|
|
47
|
-
dateMs?:
|
|
48
|
-
minDateMs?:
|
|
49
|
-
maxDateMs?:
|
|
53
|
+
dateMs?: WithDefault<TimestampMs, -9007199254740991>;
|
|
54
|
+
minDateMs?: WithDefault<TimestampMs, -9007199254740991>;
|
|
55
|
+
maxDateMs?: WithDefault<TimestampMs, -9007199254740991>;
|
|
50
56
|
|
|
51
57
|
locale?: string;
|
|
52
58
|
timeZoneName?: string;
|
|
@@ -65,8 +71,8 @@ export interface NativeProps extends ViewProps, CommonProps {
|
|
|
65
71
|
ios?: IOSProps;
|
|
66
72
|
android?: AndroidProps;
|
|
67
73
|
|
|
68
|
-
onConfirm?:
|
|
69
|
-
onClosed?:
|
|
74
|
+
onConfirm?: BubblingEventHandler<DateChangeEvent>;
|
|
75
|
+
onClosed?: BubblingEventHandler<Readonly<{}>>;
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
export default codegenNativeComponent<NativeProps>(
|
package/src/LiquidGlass.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import NativeLiquidGlass, {
|
|
|
7
7
|
type LiquidGlassEffect,
|
|
8
8
|
type LiquidGlassPressEvent,
|
|
9
9
|
} from './LiquidGlassNativeComponent';
|
|
10
|
+
import NativePlatformComponentsTheme from './NativePlatformComponentsTheme';
|
|
10
11
|
|
|
11
12
|
export type {
|
|
12
13
|
LiquidGlassEffect,
|
|
@@ -14,14 +15,32 @@ export type {
|
|
|
14
15
|
LiquidGlassPressEvent,
|
|
15
16
|
};
|
|
16
17
|
|
|
18
|
+
function resolveLiquidGlassSupport(): boolean {
|
|
19
|
+
if (Platform.OS !== 'ios') {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
// The native module answers for this build: Liquid Glass is compiled out
|
|
24
|
+
// when the library is built with an Xcode that predates the iOS 26 SDK,
|
|
25
|
+
// and then no device version makes it available.
|
|
26
|
+
const supported = NativePlatformComponentsTheme?.isLiquidGlassSupported();
|
|
27
|
+
if (typeof supported === 'boolean') {
|
|
28
|
+
return supported;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
// Native module not available (web, tests): fall back to the OS version.
|
|
32
|
+
}
|
|
33
|
+
return parseInt(String(Platform.Version), 10) >= 26;
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
/**
|
|
18
|
-
* Whether the LiquidGlass effect is supported
|
|
19
|
-
*
|
|
37
|
+
* Whether the LiquidGlass effect is supported here: iOS 26 or newer, in a
|
|
38
|
+
* build compiled against the iOS 26 SDK. False on Android, on older iOS, and
|
|
39
|
+
* in builds made with an older Xcode, where the views fall back to a blur.
|
|
20
40
|
*
|
|
21
|
-
* Use this to conditionally render fallback UI
|
|
41
|
+
* Use this to conditionally render fallback UI.
|
|
22
42
|
*/
|
|
23
|
-
export const isLiquidGlassSupported: boolean =
|
|
24
|
-
Platform.OS === 'ios' && parseInt(String(Platform.Version), 10) >= 26;
|
|
43
|
+
export const isLiquidGlassSupported: boolean = resolveLiquidGlassSupport();
|
|
25
44
|
|
|
26
45
|
export interface LiquidGlassProps extends ViewProps {
|
|
27
46
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// LiquidGlassNativeComponent.ts
|
|
2
|
-
import type {
|
|
2
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
3
3
|
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type { DirectEventHandler, Float, WithDefault } from './codegenTypes';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Glass effect intensity/style.
|
|
@@ -64,9 +65,9 @@ export type LiquidGlassAndroidProps = Readonly<{
|
|
|
64
65
|
*/
|
|
65
66
|
export type LiquidGlassPressEvent = Readonly<{
|
|
66
67
|
/** X coordinate of touch relative to view bounds */
|
|
67
|
-
x:
|
|
68
|
+
x: Float;
|
|
68
69
|
/** Y coordinate of touch relative to view bounds */
|
|
69
|
-
y:
|
|
70
|
+
y: Float;
|
|
70
71
|
}>;
|
|
71
72
|
|
|
72
73
|
export interface LiquidGlassNativeProps extends ViewProps {
|
|
@@ -75,7 +76,7 @@ export interface LiquidGlassNativeProps extends ViewProps {
|
|
|
75
76
|
* Applied uniformly to all corners.
|
|
76
77
|
* @default 0
|
|
77
78
|
*/
|
|
78
|
-
cornerRadius?:
|
|
79
|
+
cornerRadius?: WithDefault<Float, 0>;
|
|
79
80
|
|
|
80
81
|
/**
|
|
81
82
|
* iOS-specific props.
|
|
@@ -91,7 +92,7 @@ export interface LiquidGlassNativeProps extends ViewProps {
|
|
|
91
92
|
* Fired when the glass view is pressed.
|
|
92
93
|
* Includes touch coordinates relative to view bounds.
|
|
93
94
|
*/
|
|
94
|
-
onGlassPress?:
|
|
95
|
+
onGlassPress?: DirectEventHandler<LiquidGlassPressEvent>;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export default codegenNativeComponent<LiquidGlassNativeProps>(
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// NativePlatformComponentsTheme.ts
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
import type { UnsafeObject } from './codegenTypes';
|
|
5
|
+
|
|
6
|
+
export interface Spec extends TurboModule {
|
|
7
|
+
/**
|
|
8
|
+
* `{ primary }`, where `primary` is a color from `processColor`. An empty
|
|
9
|
+
* object restores the app's own theme colors.
|
|
10
|
+
*/
|
|
11
|
+
setTheme(theme: UnsafeObject): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether this build can render Liquid Glass: true only when the library was
|
|
15
|
+
* compiled against the iOS 26 SDK *and* the device runs iOS 26 or newer.
|
|
16
|
+
* Built with an older Xcode, the glass code is compiled out and the views
|
|
17
|
+
* fall back to a blur, so the device version alone cannot answer this.
|
|
18
|
+
*/
|
|
19
|
+
isLiquidGlassSupported(): boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default TurboModuleRegistry.get<Spec>('PlatformComponentsTheme');
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// NativeTheme.ts
|
|
2
|
+
import { useLayoutEffect } from 'react';
|
|
3
|
+
import { processColor, type ColorValue } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import NativePlatformComponentsTheme from './NativePlatformComponentsTheme';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The part of an app theme that is applied to the native platform theme. A
|
|
9
|
+
* React Navigation theme has this shape, so it can be passed as is.
|
|
10
|
+
*/
|
|
11
|
+
export type NativeTheme = {
|
|
12
|
+
colors: {
|
|
13
|
+
/**
|
|
14
|
+
* Brand color. Android generates a Material 3 color scheme from it for
|
|
15
|
+
* light and dark mode (Android 13+); iOS uses it as the tint color.
|
|
16
|
+
*/
|
|
17
|
+
primary: ColorValue;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function applyProcessedPrimary(primary: unknown): void {
|
|
22
|
+
NativePlatformComponentsTheme?.setTheme(primary == null ? {} : { primary });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Applies the theme's brand color to the native platform theme, app-wide:
|
|
27
|
+
* these components and other native views that use the theme colors (the
|
|
28
|
+
* window tint color on iOS, the Material theme on Android). Pass `null` to
|
|
29
|
+
* restore the app's own theme colors.
|
|
30
|
+
*
|
|
31
|
+
* Light and dark mode follow the native appearance; use
|
|
32
|
+
* `Appearance.setColorScheme` to change it from JavaScript.
|
|
33
|
+
*/
|
|
34
|
+
export function setNativeTheme(theme: NativeTheme | null): void {
|
|
35
|
+
applyProcessedPrimary(theme ? processColor(theme.colors.primary) : null);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Keeps the native platform theme's brand color in sync with `theme`. Call it
|
|
40
|
+
* once, near the root of the app. See {@link setNativeTheme}.
|
|
41
|
+
*/
|
|
42
|
+
export function useNativeTheme(theme: NativeTheme | null | undefined): void {
|
|
43
|
+
// Processed colors are numbers or plain objects (PlatformColor,
|
|
44
|
+
// DynamicColorIOS); compare them by value so a theme object recreated on
|
|
45
|
+
// every render does not re-apply the same color.
|
|
46
|
+
const primary = JSON.stringify(
|
|
47
|
+
theme ? (processColor(theme.colors.primary) ?? null) : null
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
useLayoutEffect(() => {
|
|
51
|
+
applyProcessedPrimary(JSON.parse(primary));
|
|
52
|
+
}, [primary]);
|
|
53
|
+
}
|
|
@@ -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
|
}>;
|
|
@@ -83,7 +84,7 @@ export interface SegmentedControlProps extends ViewProps {
|
|
|
83
84
|
* Controlled selection by `value`.
|
|
84
85
|
* Empty string means "no selection".
|
|
85
86
|
*/
|
|
86
|
-
selectedValue?:
|
|
87
|
+
selectedValue?: WithDefault<string, ''>;
|
|
87
88
|
|
|
88
89
|
/**
|
|
89
90
|
* Enabled / disabled state.
|
|
@@ -122,7 +123,7 @@ export interface SegmentedControlProps extends ViewProps {
|
|
|
122
123
|
/**
|
|
123
124
|
* Fired when the user selects a segment.
|
|
124
125
|
*/
|
|
125
|
-
onSelect?:
|
|
126
|
+
onSelect?: BubblingEventHandler<SegmentedControlSelectEvent>;
|
|
126
127
|
|
|
127
128
|
ios?: IOSProps;
|
|
128
129
|
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,40 @@
|
|
|
1
|
+
// codegenTypes.ts
|
|
2
|
+
//
|
|
3
|
+
// Local mirror of React Native's `CodegenTypes`.
|
|
4
|
+
//
|
|
5
|
+
// Codegen resolves these names lexically — it matches the identifier used in a
|
|
6
|
+
// spec (`Int32`, `WithDefault`, ...) and never follows the import to its
|
|
7
|
+
// source. Declaring them here therefore produces exactly the same schema as
|
|
8
|
+
// importing them from React Native, while staying parseable by the codegen
|
|
9
|
+
// shipped with older releases: the `CodegenTypes.Int32` namespace form is only
|
|
10
|
+
// understood by React Native 0.80+, and the pre-0.80 deep import
|
|
11
|
+
// (`react-native/Libraries/Types/CodegenTypes`) no longer type-checks on 0.86.
|
|
12
|
+
//
|
|
13
|
+
// Keep these definitions in sync with
|
|
14
|
+
// `react-native/Libraries/Types/CodegenTypesNamespace.d.ts`.
|
|
15
|
+
import type { NativeSyntheticEvent } from 'react-native';
|
|
16
|
+
|
|
17
|
+
// Event types. The `_PaperName` parameter is unused by the New Architecture; it
|
|
18
|
+
// is kept so the signatures match React Native's.
|
|
19
|
+
export type BubblingEventHandler<
|
|
20
|
+
T,
|
|
21
|
+
_PaperName extends string | never = never,
|
|
22
|
+
> = (event: NativeSyntheticEvent<T>) => void | Promise<void>;
|
|
23
|
+
|
|
24
|
+
export type DirectEventHandler<T, _PaperName extends string | never = never> = (
|
|
25
|
+
event: NativeSyntheticEvent<T>
|
|
26
|
+
) => void | Promise<void>;
|
|
27
|
+
|
|
28
|
+
// Prop types.
|
|
29
|
+
export type Double = number;
|
|
30
|
+
export type Float = number;
|
|
31
|
+
export type Int32 = number;
|
|
32
|
+
export type UnsafeObject = object;
|
|
33
|
+
export type UnsafeMixed = unknown;
|
|
34
|
+
|
|
35
|
+
type DefaultTypes = number | boolean | string | ReadonlyArray<string>;
|
|
36
|
+
|
|
37
|
+
export type WithDefault<
|
|
38
|
+
Type extends DefaultTypes,
|
|
39
|
+
_Value extends Type | string | undefined | null,
|
|
40
|
+
> = Type | undefined | null;
|
package/src/index.tsx
CHANGED