myoperator-ui 0.0.172 → 0.0.173

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2125,6 +2125,8 @@ export interface SelectFieldProps {
2125
2125
  defaultValue?: string;
2126
2126
  /** Callback when value changes */
2127
2127
  onValueChange?: (value: string) => void;
2128
+ /** Callback when an option is selected, provides the full option object */
2129
+ onSelect?: (option: SelectOption) => void;
2128
2130
  /** Options to display */
2129
2131
  options: SelectOption[];
2130
2132
  /** Enable search/filter functionality */
@@ -2173,6 +2175,7 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2173
2175
  value,
2174
2176
  defaultValue,
2175
2177
  onValueChange,
2178
+ onSelect,
2176
2179
  options,
2177
2180
  searchable,
2178
2181
  searchPlaceholder = "Search...",
@@ -2187,6 +2190,20 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2187
2190
  // Internal state for search
2188
2191
  const [searchQuery, setSearchQuery] = React.useState("");
2189
2192
 
2193
+ // Handle value change and call both onValueChange and onSelect
2194
+ const handleValueChange = React.useCallback(
2195
+ (newValue: string) => {
2196
+ onValueChange?.(newValue);
2197
+ if (onSelect) {
2198
+ const selectedOption = options.find((o) => o.value === newValue);
2199
+ if (selectedOption) {
2200
+ onSelect(selectedOption);
2201
+ }
2202
+ }
2203
+ },
2204
+ [onValueChange, onSelect, options]
2205
+ );
2206
+
2190
2207
  // Derive state from props
2191
2208
  const derivedState = error ? "error" : "default";
2192
2209
 
@@ -2261,7 +2278,7 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2261
2278
  <Select
2262
2279
  value={value}
2263
2280
  defaultValue={defaultValue}
2264
- onValueChange={onValueChange}
2281
+ onValueChange={handleValueChange}
2265
2282
  disabled={disabled || loading}
2266
2283
  name={name}
2267
2284
  onOpenChange={handleOpenChange}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.172",
3
+ "version": "0.0.173",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",