react-native-platform-components 1.3.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 +24 -30
- 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/PCSegmentedControlView.kt +11 -3
- 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 +4 -0
- 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/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/FloatingToolbar.js +69 -0
- package/lib/commonjs/FloatingToolbar.js.map +1 -0
- package/lib/commonjs/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/commonjs/SegmentedControl.js +11 -85
- package/lib/commonjs/SegmentedControl.js.map +1 -1
- package/lib/commonjs/SegmentedControlNativeComponent.ts +3 -0
- 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/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/FloatingToolbar.js +62 -0
- package/lib/module/FloatingToolbar.js.map +1 -0
- package/lib/module/FloatingToolbarNativeComponent.ts +31 -0
- package/lib/module/SegmentedControl.js +12 -87
- package/lib/module/SegmentedControl.js.map +1 -1
- package/lib/module/SegmentedControlNativeComponent.ts +3 -0
- 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/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/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/SegmentedControl.d.ts +17 -46
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +2 -0
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.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/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 +6 -1
- 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/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/SegmentedControl.d.ts +17 -46
- package/lib/typescript/module/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +2 -0
- package/lib/typescript/module/src/SegmentedControlNativeComponent.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/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 +6 -1
- package/lib/typescript/module/src/sharedTypes.d.ts.map +1 -1
- package/package.json +25 -4
- 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/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/FloatingToolbar.tsx +113 -0
- package/src/FloatingToolbarNativeComponent.ts +31 -0
- package/src/SegmentedControl.tsx +26 -118
- package/src/SegmentedControlNativeComponent.ts +3 -0
- package/src/TextField.tsx +494 -0
- package/src/TextFieldNativeComponent.ts +218 -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 +7 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Button = Button;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ButtonNativeComponent = _interopRequireDefault(require("./ButtonNativeComponent"));
|
|
9
|
+
var _icons = require("./icons");
|
|
10
|
+
var _labelStyle = require("./labelStyle");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
// Button.tsx
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Emphasis of the button, from highest to lowest.
|
|
18
|
+
*
|
|
19
|
+
* | Variant | Android (Material 3 Expressive) | iOS (`UIButton.Configuration`) |
|
|
20
|
+
* | ---------- | ------------------------------- | ------------------------------ |
|
|
21
|
+
* | `filled` | Filled button | `.filled()` |
|
|
22
|
+
* | `tonal` | Filled tonal button | `.tinted()` |
|
|
23
|
+
* | `outlined` | Outlined button | `.bordered()` |
|
|
24
|
+
* | `text` | Text button | `.plain()` |
|
|
25
|
+
* | `elevated` | Elevated button | `.gray()` |
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Button size. Material 3 Expressive defines five sizes; iOS maps them onto
|
|
30
|
+
* `UIButton.Configuration.Size` (`xsmall` → mini, `xlarge` → large).
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Corner shape. `round` is a pill; `square` keeps rounded corners. Unset
|
|
35
|
+
* means the platform default (round on Android, dynamic on iOS).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function Button(props) {
|
|
39
|
+
const {
|
|
40
|
+
label,
|
|
41
|
+
icon,
|
|
42
|
+
variant,
|
|
43
|
+
size,
|
|
44
|
+
shape,
|
|
45
|
+
disabled,
|
|
46
|
+
color,
|
|
47
|
+
tintColor,
|
|
48
|
+
labelStyle,
|
|
49
|
+
accessibilityLabel,
|
|
50
|
+
onPress,
|
|
51
|
+
android,
|
|
52
|
+
...viewProps
|
|
53
|
+
} = props;
|
|
54
|
+
const nativeIcon = (0, _react.useMemo)(() => (0, _icons.resolveIcon)(icon), [icon]);
|
|
55
|
+
const nativeLabelStyle = (0, _react.useMemo)(() => (0, _labelStyle.normalizeLabelStyle)(labelStyle), [labelStyle]);
|
|
56
|
+
const handlePress = (0, _react.useCallback)(() => {
|
|
57
|
+
onPress?.();
|
|
58
|
+
}, [onPress]);
|
|
59
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonNativeComponent.default, {
|
|
60
|
+
label: label ?? '',
|
|
61
|
+
icon: nativeIcon,
|
|
62
|
+
variant: variant ?? 'filled',
|
|
63
|
+
size: size ?? 'small',
|
|
64
|
+
shape: shape ?? '',
|
|
65
|
+
interactivity: disabled ? 'disabled' : 'enabled',
|
|
66
|
+
color: color,
|
|
67
|
+
foregroundColor: tintColor,
|
|
68
|
+
androidRippleColor: android?.rippleColor,
|
|
69
|
+
androidStrokeColor: android?.strokeColor,
|
|
70
|
+
androidMaterial: android?.material ?? 'expressive',
|
|
71
|
+
labelStyle: nativeLabelStyle,
|
|
72
|
+
spokenLabel: accessibilityLabel ?? '',
|
|
73
|
+
onButtonPress: onPress ? handlePress : undefined,
|
|
74
|
+
...viewProps
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_ButtonNativeComponent","_interopRequireDefault","_icons","_labelStyle","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Button","props","label","icon","variant","size","shape","disabled","color","tintColor","labelStyle","accessibilityLabel","onPress","android","viewProps","nativeIcon","useMemo","resolveIcon","nativeLabelStyle","normalizeLabelStyle","handlePress","useCallback","jsx","interactivity","foregroundColor","androidRippleColor","rippleColor","androidStrokeColor","strokeColor","androidMaterial","material","spokenLabel","onButtonPress","undefined"],"sourceRoot":"../../src","sources":["Button.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAAoE,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,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AW,EAACd,IAAI,CAAC,EAAE,CAACA,IAAI,CAAC,CAAC;EAC3D,MAAMe,gBAAgB,GAAG,IAAAF,cAAO,EAC9B,MAAM,IAAAG,+BAAmB,EAACT,UAAU,CAAC,EACrC,CAACA,UAAU,CACb,CAAC;EAED,MAAMU,WAAW,GAAG,IAAAC,kBAAW,EAAC,MAAM;IACpCT,OAAO,GAAG,CAAC;EACb,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,oBACE,IAAAhC,WAAA,CAAA0C,GAAA,EAAC9C,sBAAA,CAAAO,OAAY;IACXmB,KAAK,EAAEA,KAAK,IAAI,EAAG;IACnBC,IAAI,EAAEY,UAAW;IACjBX,OAAO,EAAEA,OAAO,IAAI,QAAS;IAC7BC,IAAI,EAAEA,IAAI,IAAI,OAAQ;IACtBC,KAAK,EAAEA,KAAK,IAAI,EAAG;IACnBiB,aAAa,EAAEhB,QAAQ,GAAG,UAAU,GAAG,SAAU;IACjDC,KAAK,EAAEA,KAAM;IACbgB,eAAe,EAAEf,SAAU;IAC3BgB,kBAAkB,EAAEZ,OAAO,EAAEa,WAAY;IACzCC,kBAAkB,EAAEd,OAAO,EAAEe,WAAY;IACzCC,eAAe,EAAEhB,OAAO,EAAEiB,QAAQ,IAAI,YAAa;IACnDpB,UAAU,EAAEQ,gBAAiB;IAC7Ba,WAAW,EAAEpB,kBAAkB,IAAI,EAAG;IACtCqB,aAAa,EAAEpB,OAAO,GAAGQ,WAAW,GAAGa,SAAU;IAAA,GAC7CnB;EAAS,CACd,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ButtonGroup = ButtonGroup;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ButtonGroupNativeComponent = _interopRequireDefault(require("./ButtonGroupNativeComponent"));
|
|
9
|
+
var _icons = require("./icons");
|
|
10
|
+
var _labelStyle = require("./labelStyle");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
// ButtonGroup.tsx
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Selection behavior of the group.
|
|
18
|
+
*
|
|
19
|
+
* - `none` (default): the buttons are plain actions.
|
|
20
|
+
* - `single`: at most one button is selected at a time.
|
|
21
|
+
* - `multiple`: any number of buttons can be selected.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** What happens to buttons that don't fit the group's width (Android). */
|
|
25
|
+
|
|
26
|
+
function ButtonGroup(props) {
|
|
27
|
+
const {
|
|
28
|
+
buttons,
|
|
29
|
+
variant,
|
|
30
|
+
size,
|
|
31
|
+
shape,
|
|
32
|
+
connected,
|
|
33
|
+
spacing,
|
|
34
|
+
selection,
|
|
35
|
+
selectedValues,
|
|
36
|
+
selectionRequired,
|
|
37
|
+
disabled,
|
|
38
|
+
color,
|
|
39
|
+
tintColor,
|
|
40
|
+
labelStyle,
|
|
41
|
+
onPress,
|
|
42
|
+
onSelectionChange,
|
|
43
|
+
android,
|
|
44
|
+
...viewProps
|
|
45
|
+
} = props;
|
|
46
|
+
const selectionMode = selection ?? 'none';
|
|
47
|
+
const nativeButtons = (0, _react.useMemo)(() => {
|
|
48
|
+
return buttons.map(button => ({
|
|
49
|
+
label: button.label ?? '',
|
|
50
|
+
value: button.value,
|
|
51
|
+
disabled: button.disabled ? 'disabled' : 'enabled',
|
|
52
|
+
accessibilityLabel: button.accessibilityLabel ?? '',
|
|
53
|
+
...(0, _icons.resolveIcon)(button.icon)
|
|
54
|
+
}));
|
|
55
|
+
}, [buttons]);
|
|
56
|
+
const nativeSelectedValues = (0, _react.useMemo)(() => {
|
|
57
|
+
if (selectionMode === 'none' || !selectedValues) return [];
|
|
58
|
+
return selectionMode === 'single' ? selectedValues.slice(0, 1) : [...selectedValues];
|
|
59
|
+
}, [selectionMode, selectedValues]);
|
|
60
|
+
const nativeLabelStyle = (0, _react.useMemo)(() => (0, _labelStyle.normalizeLabelStyle)(labelStyle), [labelStyle]);
|
|
61
|
+
const handlePress = (0, _react.useCallback)(e => {
|
|
62
|
+
const {
|
|
63
|
+
index,
|
|
64
|
+
value
|
|
65
|
+
} = e.nativeEvent;
|
|
66
|
+
onPress?.(value, index);
|
|
67
|
+
}, [onPress]);
|
|
68
|
+
const handleSelectionChange = (0, _react.useCallback)(e => {
|
|
69
|
+
onSelectionChange?.([...e.nativeEvent.values]);
|
|
70
|
+
}, [onSelectionChange]);
|
|
71
|
+
const nativeAndroid = (0, _react.useMemo)(() => ({
|
|
72
|
+
overflow: android?.overflow ?? 'none',
|
|
73
|
+
material: android?.material ?? 'expressive'
|
|
74
|
+
}), [android]);
|
|
75
|
+
const isConnected = connected ?? selectionMode !== 'none';
|
|
76
|
+
const isSelectionRequired = selectionRequired ?? (selectionMode === 'single' ? true : false);
|
|
77
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ButtonGroupNativeComponent.default, {
|
|
78
|
+
buttons: nativeButtons,
|
|
79
|
+
variant: variant ?? 'outlined',
|
|
80
|
+
size: size ?? 'small',
|
|
81
|
+
shape: shape ?? '',
|
|
82
|
+
connected: isConnected ? 'true' : 'false',
|
|
83
|
+
spacing: spacing ?? -1,
|
|
84
|
+
selection: selectionMode,
|
|
85
|
+
selectedValues: nativeSelectedValues,
|
|
86
|
+
selectionRequired: isSelectionRequired ? 'true' : 'false',
|
|
87
|
+
interactivity: disabled ? 'disabled' : 'enabled',
|
|
88
|
+
color: color,
|
|
89
|
+
foregroundColor: tintColor,
|
|
90
|
+
androidRippleColor: android?.rippleColor,
|
|
91
|
+
androidStrokeColor: android?.strokeColor,
|
|
92
|
+
labelStyle: nativeLabelStyle,
|
|
93
|
+
onButtonPress: onPress ? handlePress : undefined,
|
|
94
|
+
onGroupSelectionChange: onSelectionChange ? handleSelectionChange : undefined,
|
|
95
|
+
android: nativeAndroid,
|
|
96
|
+
...viewProps
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=ButtonGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_ButtonGroupNativeComponent","_interopRequireDefault","_icons","_labelStyle","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ButtonGroup","props","buttons","variant","size","shape","connected","spacing","selection","selectedValues","selectionRequired","disabled","color","tintColor","labelStyle","onPress","onSelectionChange","android","viewProps","selectionMode","nativeButtons","useMemo","map","button","label","value","accessibilityLabel","resolveIcon","icon","nativeSelectedValues","slice","nativeLabelStyle","normalizeLabelStyle","handlePress","useCallback","index","nativeEvent","handleSelectionChange","values","nativeAndroid","overflow","material","isConnected","isSelectionRequired","jsx","interactivity","foregroundColor","androidRippleColor","rippleColor","androidStrokeColor","strokeColor","onButtonPress","undefined","onGroupSelectionChange"],"sourceRoot":"../../src","sources":["ButtonGroup.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,2BAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;A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BAAkB,EAAE9B,OAAO,EAAE+B,WAAY;IACzCC,kBAAkB,EAAEhC,OAAO,EAAEiC,WAAY;IACzCpC,UAAU,EAAEiB,gBAAiB;IAC7BoB,aAAa,EAAEpC,OAAO,GAAGkB,WAAW,GAAGmB,SAAU;IACjDC,sBAAsB,EACpBrC,iBAAiB,GAAGqB,qBAAqB,GAAGe,SAC7C;IACDnC,OAAO,EAAEsB,aAAc;IAAA,GACnBrB;EAAS,CACd,CAAC;AAEN","ignoreList":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// ButtonGroupNativeComponent.ts
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type { BubblingEventHandler, Double, Int32 } from './codegenTypes';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A single button in the group. Icons are pre-resolved on the JS side (see
|
|
8
|
+
* icons.ts) so native only deals with flat strings.
|
|
9
|
+
*/
|
|
10
|
+
export type ButtonGroupButton = Readonly<{
|
|
11
|
+
label: string; // Empty for an icon-only button
|
|
12
|
+
value: string;
|
|
13
|
+
disabled: string; // 'enabled' | 'disabled'
|
|
14
|
+
iconType: string; // '' | 'sfSymbol' | 'drawable' | 'image'
|
|
15
|
+
iconName: string; // SF Symbol (iOS) or drawable resource name (Android)
|
|
16
|
+
iconUri: string; // Resolved image URI when iconType === 'image'
|
|
17
|
+
iconScale: Double; // Resolved image scale when iconType === 'image'
|
|
18
|
+
iconTinted: string; // 'true' | 'false' — draw the image as a tinted template
|
|
19
|
+
accessibilityLabel: string; // Screen-reader label, empty = use label
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Event emitted when a button is pressed.
|
|
24
|
+
*/
|
|
25
|
+
export type ButtonGroupPressEvent = Readonly<{
|
|
26
|
+
index: Int32;
|
|
27
|
+
value: string;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Event emitted when the selection changes (single / multiple selection).
|
|
32
|
+
*/
|
|
33
|
+
export type ButtonGroupSelectionEvent = Readonly<{
|
|
34
|
+
/** Values of the selected buttons, in button order. */
|
|
35
|
+
// Codegen only understands the `T[]` array form in event payloads.
|
|
36
|
+
values: string[];
|
|
37
|
+
}>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Label font. Empty strings / 0 mean "platform default".
|
|
41
|
+
*/
|
|
42
|
+
export type ButtonGroupLabelStyleProps = Readonly<{
|
|
43
|
+
fontFamily?: string;
|
|
44
|
+
fontSize?: Double;
|
|
45
|
+
fontWeight?: string; // 'normal' | 'bold' | '100'..'900'
|
|
46
|
+
fontStyle?: string; // 'normal' | 'italic'
|
|
47
|
+
}>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Android-specific configuration.
|
|
51
|
+
*/
|
|
52
|
+
export type ButtonGroupAndroidProps = Readonly<{
|
|
53
|
+
/** What happens to buttons that don't fit: 'none' | 'menu' | 'wrap' */
|
|
54
|
+
overflow?: string;
|
|
55
|
+
|
|
56
|
+
/** Material style: 'm3' | 'expressive' */
|
|
57
|
+
material?: string;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
60
|
+
export interface ButtonGroupNativeProps extends ViewProps {
|
|
61
|
+
/** Buttons to display. */
|
|
62
|
+
buttons: ReadonlyArray<ButtonGroupButton>;
|
|
63
|
+
|
|
64
|
+
/** 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated' */
|
|
65
|
+
variant?: string;
|
|
66
|
+
|
|
67
|
+
/** 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' */
|
|
68
|
+
size?: string;
|
|
69
|
+
|
|
70
|
+
/** '' (platform default) | 'round' | 'square' */
|
|
71
|
+
shape?: string;
|
|
72
|
+
|
|
73
|
+
/** 'true' | 'false': connected group (shared outline, small inner corners) */
|
|
74
|
+
connected?: string;
|
|
75
|
+
|
|
76
|
+
/** Gap between buttons in points; negative means the platform default. */
|
|
77
|
+
spacing?: Double;
|
|
78
|
+
|
|
79
|
+
/** 'none' | 'single' | 'multiple' */
|
|
80
|
+
selection?: string;
|
|
81
|
+
|
|
82
|
+
/** Values of the selected buttons (single / multiple selection). */
|
|
83
|
+
selectedValues?: ReadonlyArray<string>;
|
|
84
|
+
|
|
85
|
+
/** 'true' | 'false': whether at least one button must stay selected */
|
|
86
|
+
selectionRequired?: string;
|
|
87
|
+
|
|
88
|
+
/** 'enabled' | 'disabled' */
|
|
89
|
+
interactivity?: string;
|
|
90
|
+
|
|
91
|
+
/** Container (background) color of the buttons. */
|
|
92
|
+
color?: ColorValue;
|
|
93
|
+
|
|
94
|
+
/** Label and icon color of the buttons. */
|
|
95
|
+
foregroundColor?: ColorValue;
|
|
96
|
+
|
|
97
|
+
/** Android: ripple color shown while pressing a button. */
|
|
98
|
+
androidRippleColor?: ColorValue;
|
|
99
|
+
|
|
100
|
+
/** Android: outline color (outlined variant). */
|
|
101
|
+
androidStrokeColor?: ColorValue;
|
|
102
|
+
|
|
103
|
+
/** Label font. */
|
|
104
|
+
labelStyle?: ButtonGroupLabelStyleProps;
|
|
105
|
+
|
|
106
|
+
/** Fired when a button is pressed. */
|
|
107
|
+
onButtonPress?: BubblingEventHandler<ButtonGroupPressEvent>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Fired when the selection changes. Not `onSelectionChange`: React Native's
|
|
111
|
+
* TextInput registers `topSelectionChange` as a direct event, and an event
|
|
112
|
+
* name can't be both direct and bubbling.
|
|
113
|
+
*/
|
|
114
|
+
onGroupSelectionChange?: BubblingEventHandler<ButtonGroupSelectionEvent>;
|
|
115
|
+
|
|
116
|
+
android?: ButtonGroupAndroidProps;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default codegenNativeComponent<ButtonGroupNativeProps>(
|
|
120
|
+
'PCButtonGroup'
|
|
121
|
+
) as HostComponent<ButtonGroupNativeProps>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// ButtonNativeComponent.ts
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
import type { BubblingEventHandler, Double } from './codegenTypes';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Icon fields, pre-resolved on the JS side (see icons.ts).
|
|
8
|
+
*/
|
|
9
|
+
export type ButtonIconProps = Readonly<{
|
|
10
|
+
iconType: string; // '' | 'sfSymbol' | 'drawable' | 'image'
|
|
11
|
+
iconName: string; // SF Symbol (iOS) or drawable resource name (Android)
|
|
12
|
+
iconUri: string; // Resolved image URI when iconType === 'image'
|
|
13
|
+
iconScale: Double; // Resolved image scale when iconType === 'image'
|
|
14
|
+
iconTinted: string; // 'true' | 'false' — draw the image as a tinted template
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Label font. Empty strings / 0 mean "platform default".
|
|
19
|
+
*/
|
|
20
|
+
export type ButtonLabelStyleProps = Readonly<{
|
|
21
|
+
fontFamily?: string;
|
|
22
|
+
fontSize?: Double;
|
|
23
|
+
fontWeight?: string; // 'normal' | 'bold' | '100'..'900'
|
|
24
|
+
fontStyle?: string; // 'normal' | 'italic'
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
export interface ButtonNativeProps extends ViewProps {
|
|
28
|
+
/** Button text. Empty for an icon-only button. */
|
|
29
|
+
label?: string;
|
|
30
|
+
|
|
31
|
+
/** Icon shown before the label, or alone when there is no label. */
|
|
32
|
+
icon?: ButtonIconProps;
|
|
33
|
+
|
|
34
|
+
/** 'filled' | 'tonal' | 'outlined' | 'text' | 'elevated' */
|
|
35
|
+
variant?: string;
|
|
36
|
+
|
|
37
|
+
/** 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' */
|
|
38
|
+
size?: string;
|
|
39
|
+
|
|
40
|
+
/** '' (platform default) | 'round' | 'square' */
|
|
41
|
+
shape?: string;
|
|
42
|
+
|
|
43
|
+
/** 'enabled' | 'disabled' */
|
|
44
|
+
interactivity?: string;
|
|
45
|
+
|
|
46
|
+
/** Container (background) color. */
|
|
47
|
+
color?: ColorValue;
|
|
48
|
+
|
|
49
|
+
/** Label and icon color. */
|
|
50
|
+
foregroundColor?: ColorValue;
|
|
51
|
+
|
|
52
|
+
/** Android: ripple color shown while pressing. */
|
|
53
|
+
androidRippleColor?: ColorValue;
|
|
54
|
+
|
|
55
|
+
/** Android: outline color (outlined variant). */
|
|
56
|
+
androidStrokeColor?: ColorValue;
|
|
57
|
+
|
|
58
|
+
/** Android: Material style, 'm3' | 'expressive' */
|
|
59
|
+
androidMaterial?: string;
|
|
60
|
+
|
|
61
|
+
/** Label font. */
|
|
62
|
+
labelStyle?: ButtonLabelStyleProps;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Screen-reader label, applied to the native button rather than the host
|
|
66
|
+
* view. Empty means "use the label".
|
|
67
|
+
*/
|
|
68
|
+
spokenLabel?: string;
|
|
69
|
+
|
|
70
|
+
/** Fired when the button is pressed. */
|
|
71
|
+
onButtonPress?: BubblingEventHandler<Readonly<{}>>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default codegenNativeComponent<ButtonNativeProps>(
|
|
75
|
+
'PCButton'
|
|
76
|
+
) as HostComponent<ButtonNativeProps>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FloatingToolbar = FloatingToolbar;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _FloatingToolbarNativeComponent = _interopRequireDefault(require("./FloatingToolbarNativeComponent"));
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
// FloatingToolbar.tsx
|
|
14
|
+
|
|
15
|
+
/** Glass effect style of the toolbar on iOS 26. */
|
|
16
|
+
|
|
17
|
+
/** Material 3 color variant of the toolbar on Android. */
|
|
18
|
+
|
|
19
|
+
function FloatingToolbar(props) {
|
|
20
|
+
const {
|
|
21
|
+
style,
|
|
22
|
+
orientation,
|
|
23
|
+
color,
|
|
24
|
+
ios,
|
|
25
|
+
android,
|
|
26
|
+
children,
|
|
27
|
+
...viewProps
|
|
28
|
+
} = props;
|
|
29
|
+
const nativeIos = (0, _react.useMemo)(() => {
|
|
30
|
+
if (_reactNative.Platform.OS !== 'ios' || !ios) return undefined;
|
|
31
|
+
return {
|
|
32
|
+
effect: ios.effect ?? 'regular'
|
|
33
|
+
};
|
|
34
|
+
}, [ios]);
|
|
35
|
+
const nativeAndroid = (0, _react.useMemo)(() => {
|
|
36
|
+
if (_reactNative.Platform.OS !== 'android' || !android) return undefined;
|
|
37
|
+
return {
|
|
38
|
+
variant: android.variant ?? 'standard'
|
|
39
|
+
};
|
|
40
|
+
}, [android]);
|
|
41
|
+
const mergedStyle = (0, _react.useMemo)(() => [styles.toolbar, orientation === 'vertical' ? styles.vertical : styles.horizontal, style], [orientation, style]);
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingToolbarNativeComponent.default, {
|
|
43
|
+
style: mergedStyle,
|
|
44
|
+
color: color,
|
|
45
|
+
ios: nativeIos,
|
|
46
|
+
android: nativeAndroid,
|
|
47
|
+
...viewProps,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Material 3 floating toolbar: 8dp container padding, 4dp between actions.
|
|
53
|
+
// The capsule shape comes from native.
|
|
54
|
+
const styles = _reactNative.StyleSheet.create({
|
|
55
|
+
toolbar: {
|
|
56
|
+
alignSelf: 'center',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
padding: 8,
|
|
60
|
+
gap: 4
|
|
61
|
+
},
|
|
62
|
+
horizontal: {
|
|
63
|
+
flexDirection: 'row'
|
|
64
|
+
},
|
|
65
|
+
vertical: {
|
|
66
|
+
flexDirection: 'column'
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=FloatingToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_FloatingToolbarNativeComponent","_interopRequireDefault","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","FloatingToolbar","props","style","orientation","color","ios","android","children","viewProps","nativeIos","useMemo","Platform","OS","undefined","effect","nativeAndroid","variant","mergedStyle","styles","toolbar","vertical","horizontal","jsx","StyleSheet","create","alignSelf","alignItems","justifyContent","padding","gap","flexDirection"],"sourceRoot":"../../src","sources":["FloatingToolbar.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,+BAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAqE,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,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|
|
1
|
+
// FloatingToolbarNativeComponent.ts
|
|
2
|
+
import type { ColorValue, HostComponent, ViewProps } from 'react-native';
|
|
3
|
+
import { codegenNativeComponent } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* iOS-specific configuration.
|
|
7
|
+
*/
|
|
8
|
+
export type FloatingToolbarIOSProps = Readonly<{
|
|
9
|
+
/** Glass effect style on iOS 26: 'regular' | 'clear' */
|
|
10
|
+
effect?: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Android-specific configuration.
|
|
15
|
+
*/
|
|
16
|
+
export type FloatingToolbarAndroidProps = Readonly<{
|
|
17
|
+
/** Material color variant: 'standard' | 'vibrant' */
|
|
18
|
+
variant?: string;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
export interface FloatingToolbarNativeProps extends ViewProps {
|
|
22
|
+
/** Container color. Default: the platform's toolbar material. */
|
|
23
|
+
color?: ColorValue;
|
|
24
|
+
|
|
25
|
+
ios?: FloatingToolbarIOSProps;
|
|
26
|
+
android?: FloatingToolbarAndroidProps;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default codegenNativeComponent<FloatingToolbarNativeProps>(
|
|
30
|
+
'PCFloatingToolbar'
|
|
31
|
+
) as HostComponent<FloatingToolbarNativeProps>;
|
|
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SegmentedControl = SegmentedControl;
|
|
7
|
-
exports.resolveSegmentIcon =
|
|
7
|
+
exports.resolveSegmentIcon = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _SegmentedControlNativeComponent = _interopRequireDefault(require("./SegmentedControlNativeComponent"));
|
|
11
|
+
var _icons = require("./icons");
|
|
12
|
+
var _labelStyle = require("./labelStyle");
|
|
11
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -18,22 +20,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
18
20
|
// so we apply a minHeight that matches Material design touch target guidelines.
|
|
19
21
|
const ANDROID_MIN_HEIGHT = 48;
|
|
20
22
|
|
|
21
|
-
/**
|
|
22
|
-
* A single icon source.
|
|
23
|
-
*
|
|
24
|
-
* - `string`: shorthand for an SF Symbol name on iOS and a drawable resource
|
|
25
|
-
* name on Android (the original API).
|
|
26
|
-
* - `{ type: 'sfSymbol' }`: an SF Symbol. iOS only; ignored on Android.
|
|
27
|
-
* - `{ type: 'drawable' }`: a drawable from the app's `res/drawable`.
|
|
28
|
-
* Android only; ignored on iOS.
|
|
29
|
-
* - `{ type: 'image' }`: an image asset (`require('./icon.png')`) or a
|
|
30
|
-
* `{ uri }` source. Works on both platforms. Images are drawn as tinted
|
|
31
|
-
* templates unless `tinted` is `false`.
|
|
32
|
-
*/
|
|
23
|
+
/** A single icon source. Alias of {@link PlatformIconSource}. */
|
|
33
24
|
|
|
34
25
|
/**
|
|
35
26
|
* An icon for a segment: a single source used on both platforms, or a
|
|
36
|
-
* per-platform pair
|
|
27
|
+
* per-platform pair. Alias of {@link PlatformIcon}.
|
|
37
28
|
*/
|
|
38
29
|
|
|
39
30
|
/**
|
|
@@ -46,72 +37,14 @@ const ANDROID_MIN_HEIGHT = 48;
|
|
|
46
37
|
* their label. Screen readers still announce the label on both platforms.
|
|
47
38
|
*/
|
|
48
39
|
|
|
49
|
-
/**
|
|
50
|
-
* Font for segment labels. Each field falls back to the platform default.
|
|
51
|
-
*/
|
|
40
|
+
/** Font for segment labels. Alias of {@link LabelStyle}. */
|
|
52
41
|
|
|
53
42
|
/**
|
|
54
43
|
* Badge colors. Both default to the platform look (red with white text).
|
|
55
44
|
*/
|
|
56
45
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
iconName: '',
|
|
60
|
-
iconUri: '',
|
|
61
|
-
iconScale: 1,
|
|
62
|
-
iconTinted: 'true'
|
|
63
|
-
};
|
|
64
|
-
function pickIconSource(icon) {
|
|
65
|
-
if (icon === undefined || typeof icon === 'string' || 'type' in icon) {
|
|
66
|
-
return icon;
|
|
67
|
-
}
|
|
68
|
-
return _reactNative.Platform.OS === 'ios' ? icon.ios : icon.android;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Flattens the public icon shape into the strings native expects, dropping
|
|
73
|
-
* sources that don't apply to the current platform.
|
|
74
|
-
*/
|
|
75
|
-
function resolveSegmentIcon(icon) {
|
|
76
|
-
const source = pickIconSource(icon);
|
|
77
|
-
if (source === undefined) return NO_ICON;
|
|
78
|
-
if (typeof source === 'string') {
|
|
79
|
-
if (source.length === 0) return NO_ICON;
|
|
80
|
-
return {
|
|
81
|
-
...NO_ICON,
|
|
82
|
-
iconType: _reactNative.Platform.OS === 'ios' ? 'sfSymbol' : 'drawable',
|
|
83
|
-
iconName: source
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
switch (source.type) {
|
|
87
|
-
case 'sfSymbol':
|
|
88
|
-
return _reactNative.Platform.OS === 'ios' ? {
|
|
89
|
-
...NO_ICON,
|
|
90
|
-
iconType: 'sfSymbol',
|
|
91
|
-
iconName: source.name
|
|
92
|
-
} : NO_ICON;
|
|
93
|
-
case 'drawable':
|
|
94
|
-
return _reactNative.Platform.OS === 'android' ? {
|
|
95
|
-
...NO_ICON,
|
|
96
|
-
iconType: 'drawable',
|
|
97
|
-
iconName: source.name
|
|
98
|
-
} : NO_ICON;
|
|
99
|
-
case 'image':
|
|
100
|
-
{
|
|
101
|
-
const resolved = _reactNative.Image.resolveAssetSource(source.source);
|
|
102
|
-
if (!resolved?.uri) return NO_ICON;
|
|
103
|
-
return {
|
|
104
|
-
iconType: 'image',
|
|
105
|
-
iconName: '',
|
|
106
|
-
iconUri: resolved.uri,
|
|
107
|
-
iconScale: resolved.scale > 0 ? resolved.scale : 1,
|
|
108
|
-
iconTinted: source.tinted === false ? 'false' : 'true'
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
default:
|
|
112
|
-
return NO_ICON;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
46
|
+
/** Flattens a segment icon for native. Alias of {@link resolveIcon}. */
|
|
47
|
+
const resolveSegmentIcon = exports.resolveSegmentIcon = _icons.resolveIcon;
|
|
115
48
|
function normalizeSelectedValue(selected) {
|
|
116
49
|
return selected ?? '';
|
|
117
50
|
}
|
|
@@ -172,21 +105,14 @@ function SegmentedControl(props) {
|
|
|
172
105
|
const nativeSelectedSegmentColor = selectedSegmentColor ?? (_reactNative.Platform.OS === 'ios' ? ios?.selectedSegmentTintColor : undefined);
|
|
173
106
|
|
|
174
107
|
// Normalize the label font; empty / 0 means platform default
|
|
175
|
-
const nativeLabelStyle = (0, _react.useMemo)(() =>
|
|
176
|
-
if (!labelStyle) return undefined;
|
|
177
|
-
return {
|
|
178
|
-
fontFamily: labelStyle.fontFamily ?? '',
|
|
179
|
-
fontSize: labelStyle.fontSize ?? 0,
|
|
180
|
-
fontWeight: labelStyle.fontWeight === undefined ? '' : String(labelStyle.fontWeight),
|
|
181
|
-
fontStyle: labelStyle.fontStyle ?? ''
|
|
182
|
-
};
|
|
183
|
-
}, [labelStyle]);
|
|
108
|
+
const nativeLabelStyle = (0, _react.useMemo)(() => (0, _labelStyle.normalizeLabelStyle)(labelStyle), [labelStyle]);
|
|
184
109
|
|
|
185
110
|
// Normalize Android props
|
|
186
111
|
const nativeAndroid = (0, _react.useMemo)(() => {
|
|
187
112
|
if (!android) return undefined;
|
|
188
113
|
return {
|
|
189
|
-
selectionRequired: android.selectionRequired === false ? 'false' : 'true'
|
|
114
|
+
selectionRequired: android.selectionRequired === false ? 'false' : 'true',
|
|
115
|
+
material: android.material ?? 'expressive'
|
|
190
116
|
};
|
|
191
117
|
}, [android]);
|
|
192
118
|
|