myoperator-ui 0.0.179 → 0.0.180

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 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2127,6 +2127,14 @@ export interface SelectFieldProps {
2127
2127
  onValueChange?: (value: string) => void;
2128
2128
  /** Callback when an option is selected, provides the full option object */
2129
2129
  onSelect?: (option: SelectOption) => void;
2130
+ /**
2131
+ * Intercept a value change before it commits. Return \`false\` to prevent
2132
+ * \`onValueChange\` from firing (only \`onSelect\` will fire). Useful for
2133
+ * "action" items like "Add custom date" that should open a modal instead
2134
+ * of committing a value. Requires controlled mode (\`value\` prop) to
2135
+ * visually revert the selection.
2136
+ */
2137
+ interceptValue?: (value: string) => boolean;
2130
2138
  /** Options to display */
2131
2139
  options: SelectOption[];
2132
2140
  /** Enable search/filter functionality */
@@ -2176,6 +2184,7 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2176
2184
  defaultValue,
2177
2185
  onValueChange,
2178
2186
  onSelect,
2187
+ interceptValue,
2179
2188
  options,
2180
2189
  searchable,
2181
2190
  searchPlaceholder = "Search...",
@@ -2190,10 +2199,16 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2190
2199
  // Internal state for search
2191
2200
  const [searchQuery, setSearchQuery] = React.useState("");
2192
2201
 
2193
- // Combined value change handler that also fires onSelect with full option object
2202
+ // Combined value change handler that also fires onSelect with full option object.
2203
+ // When interceptValue returns false, onValueChange is skipped (only onSelect fires).
2194
2204
  const handleValueChange = React.useCallback(
2195
2205
  (newValue: string) => {
2196
- onValueChange?.(newValue);
2206
+ const intercepted = interceptValue?.(newValue) === false;
2207
+
2208
+ if (!intercepted) {
2209
+ onValueChange?.(newValue);
2210
+ }
2211
+
2197
2212
  if (onSelect) {
2198
2213
  const option = options.find((o) => o.value === newValue);
2199
2214
  if (option) {
@@ -2201,7 +2216,7 @@ const SelectField = React.forwardRef<HTMLButtonElement, SelectFieldProps>(
2201
2216
  }
2202
2217
  }
2203
2218
  },
2204
- [onValueChange, onSelect, options]
2219
+ [onValueChange, onSelect, interceptValue, options]
2205
2220
  );
2206
2221
 
2207
2222
  // Derive state from props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myoperator-ui",
3
- "version": "0.0.179",
3
+ "version": "0.0.180",
4
4
  "description": "CLI for adding myOperator UI components to your project",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",