@ansible/ansible-ui-framework 0.0.476 → 0.0.478

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckboxProps } from '@patternfly/react-core';
3
- import { Validate } from 'react-hook-form';
4
- export type PageFormCheckboxProps = {
3
+ import { FieldPath, FieldPathValue, FieldValues, Validate } from 'react-hook-form';
4
+ export type PageFormCheckboxProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
5
5
  id?: string;
6
- name: string;
7
- validate?: Validate<string> | Record<string, Validate<string>>;
6
+ name: TFieldName;
7
+ validate?: Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues> | Record<string, Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues>>;
8
8
  } & Omit<CheckboxProps, 'id' | 'onChange' | 'value'>;
9
9
  /** PatternFly Checkbox wrapper for use with react-hook-form */
10
- export declare function PageFormCheckbox(props: PageFormCheckboxProps): JSX.Element;
10
+ export declare function PageFormCheckbox<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: PageFormCheckboxProps<TFieldValues, TFieldName>): JSX.Element;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { Validate } from 'react-hook-form';
2
+ import { FieldPath, FieldPathValue, FieldValues, Validate } from 'react-hook-form';
3
3
  import { FormGroupSelectOptionProps } from './FormGroupSelectOption';
4
- export type PageFormSelectOptionProps<T> = {
5
- name: string;
6
- validate?: Validate<string> | Record<string, Validate<string>>;
7
- } & Omit<FormGroupSelectOptionProps<T>, 'onSelect' | 'value'>;
4
+ export type PageFormSelectOptionProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TSelection = unknown> = {
5
+ name: TFieldName;
6
+ validate?: Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues> | Record<string, Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues>>;
7
+ } & Omit<FormGroupSelectOptionProps<TSelection>, 'onSelect' | 'value'>;
8
8
  /** Select wrapper for use with react-hook-form */
9
- export declare function PageFormSelectOption<T>(props: PageFormSelectOptionProps<T>): JSX.Element;
9
+ export declare function PageFormSelectOption<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TSelection = unknown>(props: PageFormSelectOptionProps<TFieldValues, TFieldName, TSelection>): JSX.Element;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
- import { Validate, ValidationRule } from 'react-hook-form';
2
+ import { FieldPath, FieldPathValue, FieldValues, Validate, ValidationRule } from 'react-hook-form';
3
3
  import { FormGroupTextAreaProps } from './FormGroupTextArea';
4
- export type PageFormTextAreaProps = {
5
- name: string;
4
+ export type PageFormTextAreaProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {
5
+ name: TFieldName;
6
6
  minLength?: number | ValidationRule<number>;
7
7
  maxLength?: number | ValidationRule<number>;
8
8
  pattern?: ValidationRule<RegExp>;
9
- validate?: Validate<string> | Record<string, Validate<string>>;
9
+ validate?: Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues> | Record<string, Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues>>;
10
10
  } & Omit<FormGroupTextAreaProps, 'onChange' | 'value'>;
11
11
  /** PatternFly TextArea wrapper for use with react-hook-form */
12
- export declare function PageFormTextArea(props: PageFormTextAreaProps): JSX.Element;
12
+ export declare function PageFormTextArea<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(props: PageFormTextAreaProps<TFieldValues, TFieldName>): JSX.Element;
@@ -1,15 +1,15 @@
1
1
  /// <reference types="react" />
2
- import { Validate, ValidationRule } from 'react-hook-form';
2
+ import { FieldPath, FieldPathValue, FieldValues, Validate, ValidationRule } from 'react-hook-form';
3
3
  import { FormGroupTextInputProps } from './FormGroupTextInput';
4
- export type PageFormTextInputProps<T> = {
5
- name: string;
4
+ export type PageFormTextInputProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TSelection extends FieldValues = FieldValues> = {
5
+ name: TFieldName;
6
6
  minLength?: number | ValidationRule<number>;
7
7
  maxLength?: number | ValidationRule<number>;
8
8
  pattern?: ValidationRule<RegExp>;
9
- validate?: Validate<string> | Record<string, Validate<string>>;
9
+ validate?: Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues> | Record<string, Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues>>;
10
10
  selectTitle?: string;
11
- selectValue?: (item: T) => string | number;
12
- selectOpen?: (callback: (item: T) => void, title: string) => void;
11
+ selectValue?: (selection: TSelection) => FieldPathValue<TSelection, FieldPath<TSelection>>;
12
+ selectOpen?: (callback: (selection: TSelection) => void, title: string) => void;
13
13
  } & Omit<FormGroupTextInputProps, 'onChange' | 'value'>;
14
14
  /** PatternFly TextInput wrapper for use with react-hook-form */
15
- export declare function PageFormTextInput<T = unknown>(props: PageFormTextInputProps<T>): JSX.Element;
15
+ export declare function PageFormTextInput<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TSelection extends FieldValues = FieldValues>(props: PageFormTextInputProps<TFieldValues, TFieldName, TSelection>): JSX.Element;
@@ -30,7 +30,9 @@ function PageFormTextInput(props) {
30
30
  return (_a = props.selectOpen) === null || _a === void 0 ? void 0 : _a.call(props, function (item) {
31
31
  if (props.selectValue) {
32
32
  var value_1 = props.selectValue(item);
33
- setValue(name, value_1, { shouldValidate: true });
33
+ setValue(name, value_1, {
34
+ shouldValidate: true,
35
+ });
34
36
  }
35
37
  }, props.selectTitle);
36
38
  }, "aria-label": "Options menu", isDisabled: isSubmitting }, { children: (0, jsx_runtime_1.jsx)(react_icons_1.SearchIcon, {}) }))) })));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "A framework for building applications using PatternFly.",
4
- "version": "0.0.476",
4
+ "version": "0.0.478",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",