react-native-native-select 1.0.2 → 1.1.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 CHANGED
@@ -97,6 +97,7 @@ Please take a look at this [Android example usage](./tests/android_demo.tsx) bec
97
97
  | **`options`** | `string[]` | **Yes** | An array of strings to display in the list. |
98
98
  | **`selectedIndex`** | `number` | No | The index of the currently selected item. Defaults to `0`. |
99
99
  | **`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.* |
100
+ | **`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
101
  | **`onValueChange`** | `function` | No | Callback fired when an item is selected. Returns `{ value: string, index: number }`. |
101
102
  | **`style`** | `ViewStyle` | No | Standard style prop. **Note:** You must define `width` and `height` for the view to render correctly. |
102
103
 
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.0",
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