react-hook-form-cloudscape 1.5.1 → 1.6.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
@@ -1,18 +1,17 @@
1
1
  ## React-hook-form wrapper for Cloudscape Design System
2
2
 
3
- A React library that simplifies the integration of [`react-hook-form`](https://github.com/react-hook-form/react-hook-form) with [`Cloudscape Design System`](https://github.com/cloudscape-design/components). It provides a set of pre-built, controlled input components that handle validation, allowing you to focus on building complex form logic with minimal effort.
3
+ A React library that simplifies the integration of [`react-hook-form`](https://github.com/react-hook-form/react-hook-form) with [`Cloudscape Design System`](https://github.com/cloudscape-design/components). It provides a set of pre-built, controlled input components that handle validation, allowing you to focus on building complex form logic with minimal effort.
4
4
 
5
5
  [![npmjs](https://img.shields.io/npm/v/react-hook-form-cloudscape)](https://www.npmjs.com/package/react-hook-form-cloudscape)
6
- [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/abudayah/react-hook-form-cloudscape/badge)](https://securityscorecards.dev/viewer/?uri=github.com/abudayah/react-hook-form-cloudscape)
6
+ ![Bundle size](https://pkg-size.dev/badge/bundle/9430)
7
7
  [![OpenSSF Scorecard](https://github.com/abudayah/react-hook-form-cloudscape/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/abudayah/react-hook-form-cloudscape/actions/workflows/dependabot/dependabot-updates)
8
+ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/abudayah/react-hook-form-cloudscape/badge)](https://securityscorecards.dev/viewer/?uri=github.com/abudayah/react-hook-form-cloudscape)
8
9
  [![GitHub Repo stars](https://img.shields.io/github/stars/abudayah/react-hook-form-cloudscape)](https://github.com/abudayah/react-hook-form-cloudscape)
9
10
 
10
-
11
-
12
11
  ## Installation
13
12
 
14
13
  ```
15
- npm install react-hook-form @cloudscape-design/components @cloudscape-design/global-styles react-hook-form-cloudscape
14
+ npm install react-hook-form @cloudscape-design/components react-hook-form-cloudscape
16
15
  ```
17
16
 
18
17
  ## How to use it
@@ -40,6 +39,7 @@ function App {
40
39
  You can [create bug reports or feature requests](https://github.com/abudayah/react-hook-form-cloudscape/issues/new/choose), or [start a discussion](https://github.com/abudayah/react-hook-form-cloudscape/discussions) to ask a question. To minimize duplicates, we recommend that you search for existing bug reports, feature requests, or discussions before initiating a new thread.
41
40
 
42
41
  ## Articles and guides
42
+
43
43
  - [Cloudscape Form Validation Made Easy: A Step-by-Step Guide with React-hook-form-cloudscape](https://medium.com/@abudayah/cloudscape-form-validation-made-easy-a-step-by-step-guide-with-react-hook-form-cloudscape-f2238225f125)
44
44
 
45
45
  ## License
@@ -13,5 +13,5 @@ export interface CAttributeEditorProps<T extends FieldValues> extends Omit<Attri
13
13
  onRemoveButtonClick?: (event: NonCancelableCustomEvent<AttributeEditorProps.RemoveButtonClickDetail>, remove: UseFieldArrayRemove) => void;
14
14
  onAddButtonClick?: (event: NonCancelableCustomEvent<object>, append: UseFieldArrayAppend<T, ArrayPath<T>>) => void;
15
15
  }
16
- declare const CAttributeEditor: <TFieldValues extends FieldValues>({ name, control, onRemoveButtonClick, onAddButtonClick, definition, defaultValue, handleState, ...props }: CAttributeEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
16
+ declare const CAttributeEditor: <TFieldValues extends FieldValues>({ name, control, definition, defaultValue, handleState, onAddButtonClick, onRemoveButtonClick, ...props }: CAttributeEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
17
17
  export default CAttributeEditor;
@@ -4,7 +4,7 @@ import { useMemo } from 'react';
4
4
  import { AttributeEditor } from '@cloudscape-design/components';
5
5
  import { useFieldArray, useFormState, get, } from 'react-hook-form';
6
6
  const CAttributeEditor = (_a) => {
7
- var { name, control, onRemoveButtonClick, onAddButtonClick, definition, defaultValue, handleState = true } = _a, props = __rest(_a, ["name", "control", "onRemoveButtonClick", "onAddButtonClick", "definition", "defaultValue", "handleState"]);
7
+ var { name, control, definition, defaultValue, handleState = true, onAddButtonClick, onRemoveButtonClick } = _a, props = __rest(_a, ["name", "control", "definition", "defaultValue", "handleState", "onAddButtonClick", "onRemoveButtonClick"]);
8
8
  const { errors } = useFormState({ control });
9
9
  const { fields, append, remove } = useFieldArray({
10
10
  name,
@@ -1 +1 @@
1
- {"version":3,"file":"attribute-editor.js","sourceRoot":"","sources":["../../src/components/attribute-editor/attribute-editor.tsx"],"names":[],"mappings":";;AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,eAAe,EAAkD,MAAM,+BAA+B,CAAC;AAChH,OAAO,EAIL,aAAa,EACb,YAAY,EACZ,GAAG,GAKJ,MAAM,iBAAiB,CAAC;AAsBzB,MAAM,gBAAgB,GAAG,CAAmC,EAStB,EAAE,EAAE;QATkB,EAC1D,IAAI,EACJ,OAAO,EACP,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,WAAW,GAAG,IAAI,OAEkB,EADjC,KAAK,cARkD,2GAS3D,CADS;IAER,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAe;QAC7D,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,OAAO,CACjC,GAAG,EAAE,CACH,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBACtB,SAAS,EAAE,CAAC,KAAmB,EAAE,KAAa,EAAE,EAAE,CAChD,GAAG,CAAC,KAAK;YACR,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,UAAU,CAAwB,IACpG,GAAG,EACN,CAAC,EACL,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAC3B,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,kBACd,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAG,MAAyB,IAAI,EAAE,EACvC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE;YACzB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;YACD,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC,EACD,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE;YACtB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,YAAY,CAAC,CAAC;YACvB,CAAC;YACD,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC,IACG,KAAK,EACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"attribute-editor.js","sourceRoot":"","sources":["../../src/components/attribute-editor/attribute-editor.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,eAAe,EAAkD,MAAM,+BAA+B,CAAC;AAChH,OAAO,EAIL,aAAa,EACb,YAAY,EACZ,GAAG,GAKJ,MAAM,iBAAiB,CAAC;AAqBzB,MAAM,gBAAgB,GAAG,CAAmC,EAStB,EAAE,EAAE;QATkB,EAC1D,IAAI,EACJ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,GAAG,IAAI,EAClB,gBAAgB,EAChB,mBAAmB,OAEiB,EADjC,KAAK,cARkD,2GAS3D,CADS;IAER,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,CAAe;QAC7D,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,OAAO,CACjC,GAAG,EAAE,CACH,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,iBACtB,SAAS,EAAE,CAAC,KAAmB,EAAE,KAAa,EAAE,EAAE,CAChD,GAAG,CAAC,KAAK;YACR,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,UAAU,CAAwB,IACpG,GAAG,EACN,CAAC,EACL,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAC3B,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,kBACd,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAG,MAAyB,IAAI,EAAE,EACvC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE;YACzB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7B,CAAC;YACD,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC,EACD,gBAAgB,EAAE,CAAC,CAAC,EAAE,EAAE;YACtB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,CAAC,YAAY,CAAC,CAAC;YACvB,CAAC;YACD,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,CAAC,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC,IACG,KAAK,EACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -6,8 +6,6 @@ export interface CAutosuggestProps<T extends FieldValues> extends Omit<Autosugge
6
6
  defaultValue?: FieldPathValue<T, FieldPath<T>>;
7
7
  rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
8
8
  shouldUnregister?: boolean;
9
- onBlur?: AutosuggestProps['onBlur'];
10
- onChange?: AutosuggestProps['onChange'];
11
9
  }
12
10
  export declare const CAutosuggest: <T extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onBlur, onChange, ...props }: CAutosuggestProps<T>) => import("react/jsx-runtime").JSX.Element;
13
11
  export default CAutosuggest;
@@ -5,19 +5,18 @@ import { Controller } from 'react-hook-form';
5
5
  import { Autosuggest } from '@cloudscape-design/components';
6
6
  export const CAutosuggest = (_a) => {
7
7
  var { name, control, defaultValue, rules, shouldUnregister = false, onBlur, onChange } = _a, props = __rest(_a, ["name", "control", "defaultValue", "rules", "shouldUnregister", "onBlur", "onChange"]);
8
- const handleOnBlur = useCallback((event) => {
8
+ const handleOnBlur = useCallback((formOnBlur, event) => {
9
+ var _a;
10
+ if ((_a = event.detail) === null || _a === void 0 ? void 0 : _a.value) {
11
+ formOnBlur(event.detail.value);
12
+ }
9
13
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
10
14
  }, [onBlur]);
11
- const handleOnChange = useCallback((event) => {
15
+ const handleOnChange = useCallback((formOnChange, event) => {
16
+ formOnChange(event.detail.value);
12
17
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
13
18
  }, [onChange]);
14
- return (_jsx(Controller, { name: name, control: control, defaultValue: defaultValue, rules: rules, shouldUnregister: shouldUnregister, render: ({ field: { ref, onBlur: formOnBlur, onChange: formOnChange, value } }) => (_jsx(Autosuggest, Object.assign({ ref: ref, name: name, value: value || '', onBlur: (e) => {
15
- formOnBlur();
16
- handleOnBlur(e);
17
- }, onChange: (e) => {
18
- formOnChange(e.detail.value);
19
- handleOnChange(e);
20
- } }, props))) }));
19
+ return (_jsx(Controller, { name: name, control: control, defaultValue: defaultValue, rules: rules, shouldUnregister: shouldUnregister, render: ({ field: { ref, onBlur, onChange, value } }) => (_jsx(Autosuggest, Object.assign({ ref: ref, name: name, value: value || '', onBlur: handleOnBlur.bind(null, onBlur), onChange: handleOnChange.bind(null, onChange) }, props))) }));
21
20
  };
22
21
  export default CAutosuggest;
23
22
  //# sourceMappingURL=autosuggest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"autosuggest.js","sourceRoot":"","sources":["../../src/components/autosuggest/autosuggest.tsx"],"names":[],"mappings":";;AAAA,OAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,UAAU,EAA0E,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,WAAW,EAA8C,MAAM,+BAA+B,CAAC;AAYxG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAwB,EAS7B,EAAE,EAAE;QATyB,EAClD,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,KAAK,EACL,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,QAAQ,OAEa,EADlB,KAAK,cAR0C,sFASnD,CADS;IAER,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,KAAqC,EAAE,EAAE;QACxC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAK,CAAC,CAAC;IAClB,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,KAA8D,EAAE,EAAE;QACjE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAAK,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CACjF,KAAC,WAAW,kBACV,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAG,KAAgB,IAAI,EAAE,EAC9B,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;gBACZ,UAAU,EAAE,CAAC;gBACb,YAAY,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC7B,cAAc,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC,IACG,KAAK,EACT,CACH,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"autosuggest.js","sourceRoot":"","sources":["../../src/components/autosuggest/autosuggest.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,UAAU,EAA0E,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,WAAW,EAA8C,MAAM,+BAA+B,CAAC;AAUxG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAwB,EAS7B,EAAE,EAAE;QATyB,EAClD,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,KAAK,EACL,gBAAgB,GAAG,KAAK,EACxB,MAAM,EACN,QAAQ,OAEa,EADlB,KAAK,cAR0C,sFASnD,CADS;IAER,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,UAAmC,EAAE,KAAyD,EAAE,EAAE;;QACjG,IAAI,MAAA,KAAK,CAAC,MAAM,0CAAE,KAAK,EAAE,CAAC;YACxB,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;QACD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,KAAuC,CAAC,CAAC;IACpD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,YAAqC,EAAE,KAA8D,EAAE,EAAE;QACxG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,KAA2E,CAAC,CAAC;IAC1F,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CACvD,KAAC,WAAW,kBACV,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAG,KAAgB,IAAI,EAAE,EAC9B,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EACvC,QAAQ,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IACzC,KAAK,EACT,CACH,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,8 +1,11 @@
1
1
  import { CardsProps } from '@cloudscape-design/components';
2
- import { Control, FieldValues, Path } from 'react-hook-form';
2
+ import { Control, FieldValues, Path, FieldPathValue, FieldPath, RegisterOptions } from 'react-hook-form';
3
3
  export interface ControlledCardsProps<T extends FieldValues> extends Omit<Required<Pick<CardsProps, 'trackBy'>> & Required<Pick<CardsProps, 'selectionType'>> & CardsProps, 'value'> {
4
4
  name: Path<T>;
5
5
  control?: Control<T>;
6
+ shouldUnregister?: boolean;
7
+ defaultValue?: FieldPathValue<T, FieldPath<T>>;
8
+ rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
6
9
  }
7
- export declare const CCards: <TFieldValues extends FieldValues>({ name, control, onSelectionChange, ...props }: ControlledCardsProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const CCards: <TFieldValues extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onSelectionChange, ...props }: ControlledCardsProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
8
11
  export default CCards;
@@ -1,15 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Cards } from '@cloudscape-design/components';
4
3
  import { useCallback } from 'react';
4
+ import { Cards } from '@cloudscape-design/components';
5
5
  import { Controller } from 'react-hook-form';
6
6
  export const CCards = (_a) => {
7
- var { name, control, onSelectionChange } = _a, props = __rest(_a, ["name", "control", "onSelectionChange"]);
7
+ var { name, control, defaultValue, rules, shouldUnregister = false, onSelectionChange } = _a, props = __rest(_a, ["name", "control", "defaultValue", "rules", "shouldUnregister", "onSelectionChange"]);
8
8
  const handleOnChange = useCallback((formOnChange, e) => {
9
9
  formOnChange(e.detail.selectedItems);
10
10
  onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e);
11
11
  }, [onSelectionChange]);
12
- return (_jsx(Controller, { name: name, control: control, render: ({ field: { onChange, value } }) => (_jsx(Cards, Object.assign({ onSelectionChange: handleOnChange.bind(null, onChange), selectedItems: value }, props))) }));
12
+ return (_jsx(Controller, { name: name, control: control, defaultValue: defaultValue, rules: rules, shouldUnregister: shouldUnregister, render: ({ field: { onChange, value } }) => (_jsx(Cards, Object.assign({ onSelectionChange: handleOnChange.bind(null, onChange), selectedItems: value }, props))) }));
13
13
  };
14
14
  export default CCards;
15
15
  //# sourceMappingURL=cards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/components/cards/cards.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAwC,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAc,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,UAAU,EAA8B,MAAM,iBAAiB,CAAC;AAWzE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAmC,EAKpB,EAAE,EAAE;QALgB,EACvD,IAAI,EACJ,OAAO,EACP,iBAAiB,OAEkB,EADhC,KAAK,cAJ+C,wCAKxD,CADS;IAER,MAAM,cAAc,GAAG,WAAW,CAChC,CACE,YAAqD,EACrD,CAA2E,EAC3E,EAAE;QACF,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,CAAC,CAAC;IACzB,CAAC,EACD,CAAC,iBAAiB,CAAC,CACpB,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAC1C,KAAC,KAAK,kBAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,aAAa,EAAE,KAAK,IAAM,KAAK,EAAI,CACnG,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/components/cards/cards.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAwC,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,UAAU,EAA0E,MAAM,iBAAiB,CAAC;AAcrH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAmC,EAQpB,EAAE,EAAE;QARgB,EACvD,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,KAAK,EACL,gBAAgB,GAAG,KAAK,EACxB,iBAAiB,OAEkB,EADhC,KAAK,cAP+C,qFAQxD,CADS;IAER,MAAM,cAAc,GAAG,WAAW,CAChC,CACE,YAAqD,EACrD,CAA2E,EAC3E,EAAE;QACF,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAG,CAAC,CAAC,CAAC;IACzB,CAAC,EACD,CAAC,iBAAiB,CAAC,CACpB,CAAC;IAEF,OAAO,CACL,KAAC,UAAU,IACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,CAC1C,KAAC,KAAK,kBAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,aAAa,EAAE,KAAK,IAAM,KAAK,EAAI,CACnG,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -13,5 +13,5 @@ export interface CAttributeEditorProps<T extends FieldValues> extends Omit<Attri
13
13
  onRemoveButtonClick?: (event: NonCancelableCustomEvent<AttributeEditorProps.RemoveButtonClickDetail>, remove: UseFieldArrayRemove) => void;
14
14
  onAddButtonClick?: (event: NonCancelableCustomEvent<object>, append: UseFieldArrayAppend<T, ArrayPath<T>>) => void;
15
15
  }
16
- declare const CAttributeEditor: <TFieldValues extends FieldValues>({ name, control, onRemoveButtonClick, onAddButtonClick, definition, defaultValue, handleState, ...props }: CAttributeEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
16
+ declare const CAttributeEditor: <TFieldValues extends FieldValues>({ name, control, definition, defaultValue, handleState, onAddButtonClick, onRemoveButtonClick, ...props }: CAttributeEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
17
17
  export default CAttributeEditor;
@@ -6,8 +6,6 @@ export interface CAutosuggestProps<T extends FieldValues> extends Omit<Autosugge
6
6
  defaultValue?: FieldPathValue<T, FieldPath<T>>;
7
7
  rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
8
8
  shouldUnregister?: boolean;
9
- onBlur?: AutosuggestProps['onBlur'];
10
- onChange?: AutosuggestProps['onChange'];
11
9
  }
12
10
  export declare const CAutosuggest: <T extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onBlur, onChange, ...props }: CAutosuggestProps<T>) => import("react/jsx-runtime").JSX.Element;
13
11
  export default CAutosuggest;
@@ -1,8 +1,11 @@
1
1
  import { CardsProps } from '@cloudscape-design/components';
2
- import { Control, FieldValues, Path } from 'react-hook-form';
2
+ import { Control, FieldValues, Path, FieldPathValue, FieldPath, RegisterOptions } from 'react-hook-form';
3
3
  export interface ControlledCardsProps<T extends FieldValues> extends Omit<Required<Pick<CardsProps, 'trackBy'>> & Required<Pick<CardsProps, 'selectionType'>> & CardsProps, 'value'> {
4
4
  name: Path<T>;
5
5
  control?: Control<T>;
6
+ shouldUnregister?: boolean;
7
+ defaultValue?: FieldPathValue<T, FieldPath<T>>;
8
+ rules?: Omit<RegisterOptions<T, FieldPath<T>>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
6
9
  }
7
- export declare const CCards: <TFieldValues extends FieldValues>({ name, control, onSelectionChange, ...props }: ControlledCardsProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const CCards: <TFieldValues extends FieldValues>({ name, control, defaultValue, rules, shouldUnregister, onSelectionChange, ...props }: ControlledCardsProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
8
11
  export default CCards;
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "react-hook-form-cloudscape",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "A React Hook Form wrapper designed for effortless integration of validations into Cloudscape forms and inputs",
5
+ "keywords": [
6
+ "react",
7
+ "react-hook-form",
8
+ "cloudscape",
9
+ "form-validation",
10
+ "react-component",
11
+ "typescript"
12
+ ],
5
13
  "repository": {
6
14
  "type": "git",
7
15
  "url": "git+https://github.com/abudayah/react-hook-form-cloudscape.git"
@@ -23,21 +31,21 @@
23
31
  "scripts": {
24
32
  "test": "vitest",
25
33
  "test:coverage": "vitest run --coverage",
26
- "lint": "eslint .",
27
- "lint:fix": "eslint . --fix",
28
- "format": "prettier --write '**/*.{ts,tsx,json,cjs,js}'",
34
+ "lint": "eslint . --fix",
29
35
  "clean": "rm -rf dist/ index.d.ts index.js index.js.map components/ react-hook-form-cloudscape.es.js react-hook-form-cloudscape.es.js.map react-hook-form-cloudscape.umd.js react-hook-form-cloudscape.umd.js.map",
30
- "build": "npm run clean && npm run lint:fix && npm run format && npm run test:coverage && tsc && vite build",
31
- "dry-run": "npx semantic-release --dry-run > dry-run-output.txt"
36
+ "build": "npm run clean && npm run test:coverage && tsc && vite build",
37
+ "dry-run": "npx semantic-release --dry-run > dry-run-output.txt",
38
+ "prepare": "husky"
39
+ },
40
+ "lint-staged": {
41
+ "*.{ts,tsx,cjs}": [
42
+ "eslint . --fix",
43
+ "prettier . --write"
44
+ ],
45
+ "*.json": [
46
+ "prettier . --write"
47
+ ]
32
48
  },
33
- "keywords": [
34
- "react",
35
- "react-hook-form",
36
- "cloudscape",
37
- "form-validation",
38
- "react-component",
39
- "typescript"
40
- ],
41
49
  "peerDependencies": {
42
50
  "@cloudscape-design/components": ">=3.0.0",
43
51
  "react": ">=16.8.0",
@@ -60,7 +68,9 @@
60
68
  "eslint-plugin-prettier": "^5.2.6",
61
69
  "eslint-plugin-react": "^7.37.5",
62
70
  "eslint-plugin-react-hooks": "^4.6.2",
71
+ "husky": "^9.1.7",
63
72
  "jsdom": "^25.0.1",
73
+ "lint-staged": "^15.5.2",
64
74
  "prettier": "^3.5.3",
65
75
  "react": "^18.3.1",
66
76
  "react-dom": "^18.3.1",