react-native-native-select 1.0.2 → 1.1.1

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wayan NEEL
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # react-native-native-select
2
2
 
3
+ <p>
4
+ <a href="https://github.com/wneel/react-native-native-select/blob/HEAD/LICENSE">
5
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="React Native Wheel Picker is released under the MIT license." />
6
+ </a>
7
+ <a href="https://www.npmjs.com/package/wneel/react-native-native-select">
8
+ <img src="https://img.shields.io/npm/v/react-native-native-select?color=brightgreen&label=npm%20package" alt="Current npm package version." />
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/wneel/react-native-native-select">
11
+ <img src="https://img.shields.io/npm/dm/react-native-native-select" alt="Number of downloads per week." />
12
+ </a>
13
+ </p>
14
+
15
+
3
16
  A strictly native, performant Select component for React Native built exclusively for the **New Architecture**.
4
17
 
5
18
  It leverages actual OS primitives: `UIMenu` (iOS 14+), `UIPickerView` (iOS Wheel), and `AppCompatSpinner` (Android), offering a truly native look and feel that JS-based libraries cannot match.
@@ -8,7 +21,7 @@ It leverages actual OS primitives: `UIMenu` (iOS 14+), `UIPickerView` (iOS Wheel
8
21
 
9
22
  | iOS (Dropdown Mode) | iOS (Dialog/Wheel Mode) | Android |
10
23
  |:---:|:---:|:---:|
11
- | ![react-native-native-select-dropdown](https://github.com/user-attachments/assets/8a65c76b-f0a8-4f89-88d3-49000abe354d) | ![react-native-native-select-wheel](https://github.com/user-attachments/assets/71d98f6c-984a-49e8-bc98-abbfb86de535) | ![react-native-native-select-android](https://github.com/user-attachments/assets/5936637a-e63a-445c-9c9f-3a05940b6f9e) |
24
+ | <img src="https://github.com/user-attachments/assets/8a65c76b-f0a8-4f89-88d3-49000abe354d" height="300" /> | <img src="https://github.com/user-attachments/assets/71d98f6c-984a-49e8-bc98-abbfb86de535" height="300" /> | <img src="https://github.com/user-attachments/assets/5936637a-e63a-445c-9c9f-3a05940b6f9e" height="300" /> |
12
25
  | *Native UIMenu (iOS 14+)* | *Classic UIPickerView* | *Native AppCompatSpinner* |
13
26
 
14
27
  ## Why this library?
@@ -97,6 +110,7 @@ Please take a look at this [Android example usage](./tests/android_demo.tsx) bec
97
110
  | **`options`** | `string[]` | **Yes** | An array of strings to display in the list. |
98
111
  | **`selectedIndex`** | `number` | No | The index of the currently selected item. Defaults to `0`. |
99
112
  | **`mode`** | `'dropdown' \| 'dialog'` | No | **iOS Only.** <br>`dropdown`: Uses `UIMenu` (Modern iOS 14+). <br>`dialog`: Uses `UIPickerView` (Classic Wheel). <br> *On Android, this prop is ignored as it always uses the native Spinner.* |
113
+ | **`textColor`** | `ColorValue` | No | **iOS only.** Custom text color for the picker. Overrides the system's default Light/Dark mode colors. Accepts any standard React Native color format (e.g., `'#FF0000'`, `'red'`, `'rgba(0,0,0,0.5)'`). |
100
114
  | **`onValueChange`** | `function` | No | Callback fired when an item is selected. Returns `{ value: string, index: number }`. |
101
115
  | **`style`** | `ViewStyle` | No | Standard style prop. **Note:** You must define `width` and `height` for the view to render correctly. |
102
116
 
@@ -79,5 +79,12 @@ public class SelectViewManager extends SimpleViewManager<SelectView>
79
79
  @ReactProp(name = "mode")
80
80
  public void setMode(SelectView view, @Nullable String value) {}
81
81
 
82
+ @Override
83
+ @ReactProp(name = "textColor", customType = "Color")
84
+ public void setTextColor(SelectView view, @Nullable Integer value) {
85
+ // iOS-only feature: we don't do anything on Android,
86
+ // but the method must exist to satisfy the interface generated by TypeScript.
87
+ }
88
+
82
89
  public void setOnValueChange(SelectView view, @Nullable Object value) {}
83
90
  }
package/ios/RTNSelect.mm CHANGED
@@ -1,5 +1,6 @@
1
1
  #import "RTNSelect.h"
2
2
  #import <React/RCTComponent.h>
3
+ #import <React/RCTConversions.h>
3
4
 
4
5
  #import <react/renderer/components/RTNSelectSpec/ComponentDescriptors.h>
5
6
  #import <react/renderer/components/RTNSelectSpec/EventEmitters.h>
@@ -39,13 +40,10 @@ using namespace facebook::react;
39
40
  _pickerView.delegate = self;
40
41
  _pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
41
42
 
42
- _button = [UIButton buttonWithType:UIButtonTypeSystem];
43
+ _button = [UIButton buttonWithType:UIButtonTypeCustom];
43
44
  _button.frame = self.bounds;
44
45
  _button.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
45
-
46
- // Style du bouton (alignement à gauche, couleur noire pour le texte)
47
46
  _button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
48
- [_button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
49
47
 
50
48
  if (@available(iOS 14.0, *)) {
51
49
  _button.showsMenuAsPrimaryAction = YES;
@@ -55,6 +53,8 @@ using namespace facebook::react;
55
53
 
56
54
  [self addSubview:_pickerView];
57
55
  [self addSubview:_button];
56
+
57
+ [self applyTextColor:nil];
58
58
  }
59
59
 
60
60
  return self;
@@ -67,7 +67,22 @@ using namespace facebook::react;
67
67
  }
68
68
 
69
69
  // ============================================================================
70
- // Gestion du Menu Flottant (Dropdown)
70
+ // Core Text Color Logic (KVC)
71
+ // ============================================================================
72
+
73
+ - (void)applyTextColor:(UIColor *)color {
74
+ UIColor *resolvedColor = color ?: [UIColor labelColor];
75
+
76
+ [_pickerView setValue:resolvedColor forKey:@"textColor"];
77
+
78
+ [_button setTitleColor:resolvedColor forState:UIControlStateNormal];
79
+
80
+ [_pickerView reloadAllComponents];
81
+ [self updateButtonMenu];
82
+ }
83
+
84
+ // ============================================================================
85
+ // Managing the Dropdown Menu
71
86
  // ============================================================================
72
87
 
73
88
  - (void)updateButtonMenu {
@@ -96,7 +111,7 @@ using namespace facebook::react;
96
111
  }
97
112
 
98
113
  // ============================================================================
99
- // Méthode unifiée de sélection (appelée par Picker ou Dropdown)
114
+ // Unified selection method (Picker or Dropdown)
100
115
  // ============================================================================
101
116
 
102
117
  - (void)selectIndex:(NSInteger)index fromSource:(NSString *)source {
@@ -139,6 +154,7 @@ using namespace facebook::react;
139
154
  bool optionsChanged = oldViewProps.options != newViewProps.options;
140
155
  bool indexChanged = oldViewProps.selectedIndex != newViewProps.selectedIndex;
141
156
  bool modeChanged = oldViewProps.mode != newViewProps.mode;
157
+ bool textColorChanged = oldViewProps.textColor != newViewProps.textColor;
142
158
 
143
159
  if (optionsChanged) {
144
160
  _options = newViewProps.options;
@@ -151,6 +167,11 @@ using namespace facebook::react;
151
167
  [super updateProps:props oldProps:oldProps];
152
168
 
153
169
  dispatch_async(dispatch_get_main_queue(), ^{
170
+ if (textColorChanged) {
171
+ UIColor *newColor = RCTUIColorFromSharedColor(newViewProps.textColor);
172
+ [self applyTextColor:newColor];
173
+ }
174
+
154
175
  if (optionsChanged) {
155
176
  [self->_pickerView reloadAllComponents];
156
177
  [self updateButtonMenu];
@@ -210,6 +231,12 @@ using namespace facebook::react;
210
231
  });
211
232
  }
212
233
 
234
+ - (void)setTextColor:(UIColor *)color {
235
+ dispatch_async(dispatch_get_main_queue(), ^{
236
+ [self applyTextColor:color];
237
+ });
238
+ }
239
+
213
240
  - (void)setOnValueChange:(RCTDirectEventBlock)onValueChange {
214
241
  _onValueChangeLegacy = onValueChange;
215
242
  }
@@ -17,6 +17,7 @@ RCT_EXPORT_MODULE(RTNSelect)
17
17
  RCT_EXPORT_VIEW_PROPERTY(options, NSArray)
18
18
  RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger)
19
19
  RCT_EXPORT_VIEW_PROPERTY(mode, NSString)
20
+ RCT_EXPORT_VIEW_PROPERTY(textColor, UIColor)
20
21
  RCT_EXPORT_VIEW_PROPERTY(onValueChange, RCTDirectEventBlock)
21
22
 
22
23
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-native-select",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "react-native-native-select is a strictly native, performant Select component for React Native built exclusively for the New Architecture.",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -34,6 +34,10 @@
34
34
  "type": "git",
35
35
  "url": "git+https://github.com/wneel/react-native-native-select.git"
36
36
  },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
37
41
  "author": "Wayan NEEL <66263633+wneel@users.noreply.github.com> (https://github.com/wneel)",
38
42
  "license": "MIT",
39
43
  "bugs": {
@@ -1,6 +1,6 @@
1
1
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
2
 
3
- import type { HostComponent } from 'react-native';
3
+ import type { ColorValue, HostComponent } from 'react-native';
4
4
  import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
5
5
  import type { Int32, DirectEventHandler, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
6
6
 
@@ -12,7 +12,8 @@ type OnChangeEvent = Readonly<{
12
12
  export interface NativeProps extends ViewProps {
13
13
  options: ReadonlyArray<string>;
14
14
  selectedIndex?: Int32;
15
- mode?: WithDefault<'dialog' | 'dropdown', 'dialog'>;
15
+ mode?: WithDefault<'dialog' | 'dropdown', 'dialog'>; // iOS only
16
+ textColor?: ColorValue; // iOS only
16
17
  onValueChange?: DirectEventHandler<OnChangeEvent>;
17
18
  }
18
19