@4alldigital/foundation-ui--gamma 1.31.6 → 1.31.7

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/dist/index.esm.js CHANGED
@@ -612,7 +612,7 @@ var Card = function (_a) {
612
612
  Card.displayName = 'Card';
613
613
 
614
614
  var Form = function (_a) {
615
- var children = _a.children, className = _a.className, submit = _a.submit, _b = _a.onSubmit, onSubmit = _b === void 0 ? function () { } : _b, onChange = _a.onChange, hideSubmit = _a.hideSubmit, ariaSubmitLabel = _a.ariaSubmitLabel, submitID = _a.submitID, _c = _a.submitVariant, submitVariant = _c === void 0 ? BTN_VARIANTS.PRIMARY : _c, _d = _a.initialValues, initialValues = _d === void 0 ? {} : _d, _e = _a.isBoxed, isBoxed = _e === void 0 ? false : _e;
615
+ var children = _a.children, className = _a.className, submit = _a.submit, _b = _a.onSubmit, onSubmit = _b === void 0 ? function () { } : _b, onChange = _a.onChange, hideSubmit = _a.hideSubmit, ariaSubmitLabel = _a.ariaSubmitLabel, submitID = _a.submitID, _c = _a.submitVariant, submitVariant = _c === void 0 ? BTN_VARIANTS.PRIMARY : _c, _d = _a.initialValues, initialValues = _d === void 0 ? {} : _d, _e = _a.isBoxed, isBoxed = _e === void 0 ? false : _e, _f = _a.submitType, submitType = _f === void 0 ? BTN_TYPES.SUBMIT : _f, _g = _a.disabledSubmitWithReturn, disabledSubmitWithReturn = _g === void 0 ? false : _g;
616
616
  var methods = useForm({
617
617
  defaultValues: initialValues,
618
618
  mode: 'onBlur',
@@ -625,7 +625,11 @@ var Form = function (_a) {
625
625
  }
626
626
  }, []);
627
627
  var submitClasses = cx({ 'sr-only': hideSubmit });
628
- return (jsx(FormProvider, __assign({}, methods, { children: jsx("div", { "data-testid": "Form", className: cx('w-full max-w-s @containers @form'), children: jsxs("form", { onSubmit: methods.handleSubmit(onSubmit), className: cx('mb-4 w-2xs relative', { 'form px-8 pt-6 pb-8 ': isBoxed }, { 'opacity-50': methods.formState.isSubmitting }, className), children: [children, submit && (jsx("div", { className: "flex items-center justify-end py-2", children: jsx(Button, { id: submitID || submit, className: submitClasses, ariaLabel: ariaSubmitLabel || submit || 'Submit', type: BTN_TYPES.SUBMIT, outline: true, isLoading: methods.formState.isSubmitting, disabled: methods.formState.isSubmitting || !methods.formState.isValid, variant: submitVariant, children: submit }) }))] }) }) })));
628
+ return (jsx(FormProvider, __assign({}, methods, { children: jsx("div", { "data-testid": "Form", className: cx('w-full max-w-s @containers @form'), children: jsxs("form", { onSubmit: methods.handleSubmit(onSubmit), onKeyDown: function (event) {
629
+ if (disabledSubmitWithReturn && event.key === 'Enter') {
630
+ event.preventDefault();
631
+ }
632
+ }, className: cx('mb-4 w-2xs relative', { 'form px-8 pt-6 pb-8 ': isBoxed }, { 'opacity-50': methods.formState.isSubmitting }, className), children: [children, submit && (jsx("div", { className: "flex items-center justify-end py-2", children: jsx(Button, { id: submitID || submit, className: submitClasses, ariaLabel: ariaSubmitLabel || submit || 'Submit', type: submitType, outline: true, isLoading: methods.formState.isSubmitting, disabled: methods.formState.isSubmitting || !methods.formState.isValid, variant: submitVariant, children: submit }) }))] }) }) })));
629
633
  };
630
634
  Form.displayName = 'Form';
631
635
 
package/dist/index.js CHANGED
@@ -614,7 +614,7 @@ var Card = function (_a) {
614
614
  Card.displayName = 'Card';
615
615
 
616
616
  var Form = function (_a) {
617
- var children = _a.children, className = _a.className, submit = _a.submit, _b = _a.onSubmit, onSubmit = _b === void 0 ? function () { } : _b, onChange = _a.onChange, hideSubmit = _a.hideSubmit, ariaSubmitLabel = _a.ariaSubmitLabel, submitID = _a.submitID, _c = _a.submitVariant, submitVariant = _c === void 0 ? exports.BTN_VARIANTS.PRIMARY : _c, _d = _a.initialValues, initialValues = _d === void 0 ? {} : _d, _e = _a.isBoxed, isBoxed = _e === void 0 ? false : _e;
617
+ var children = _a.children, className = _a.className, submit = _a.submit, _b = _a.onSubmit, onSubmit = _b === void 0 ? function () { } : _b, onChange = _a.onChange, hideSubmit = _a.hideSubmit, ariaSubmitLabel = _a.ariaSubmitLabel, submitID = _a.submitID, _c = _a.submitVariant, submitVariant = _c === void 0 ? exports.BTN_VARIANTS.PRIMARY : _c, _d = _a.initialValues, initialValues = _d === void 0 ? {} : _d, _e = _a.isBoxed, isBoxed = _e === void 0 ? false : _e, _f = _a.submitType, submitType = _f === void 0 ? exports.BTN_TYPES.SUBMIT : _f, _g = _a.disabledSubmitWithReturn, disabledSubmitWithReturn = _g === void 0 ? false : _g;
618
618
  var methods = reactHookForm.useForm({
619
619
  defaultValues: initialValues,
620
620
  mode: 'onBlur',
@@ -627,7 +627,11 @@ var Form = function (_a) {
627
627
  }
628
628
  }, []);
629
629
  var submitClasses = cx({ 'sr-only': hideSubmit });
630
- return (jsxRuntime.jsx(reactHookForm.FormProvider, __assign({}, methods, { children: jsxRuntime.jsx("div", { "data-testid": "Form", className: cx('w-full max-w-s @containers @form'), children: jsxRuntime.jsxs("form", { onSubmit: methods.handleSubmit(onSubmit), className: cx('mb-4 w-2xs relative', { 'form px-8 pt-6 pb-8 ': isBoxed }, { 'opacity-50': methods.formState.isSubmitting }, className), children: [children, submit && (jsxRuntime.jsx("div", { className: "flex items-center justify-end py-2", children: jsxRuntime.jsx(Button, { id: submitID || submit, className: submitClasses, ariaLabel: ariaSubmitLabel || submit || 'Submit', type: exports.BTN_TYPES.SUBMIT, outline: true, isLoading: methods.formState.isSubmitting, disabled: methods.formState.isSubmitting || !methods.formState.isValid, variant: submitVariant, children: submit }) }))] }) }) })));
630
+ return (jsxRuntime.jsx(reactHookForm.FormProvider, __assign({}, methods, { children: jsxRuntime.jsx("div", { "data-testid": "Form", className: cx('w-full max-w-s @containers @form'), children: jsxRuntime.jsxs("form", { onSubmit: methods.handleSubmit(onSubmit), onKeyDown: function (event) {
631
+ if (disabledSubmitWithReturn && event.key === 'Enter') {
632
+ event.preventDefault();
633
+ }
634
+ }, className: cx('mb-4 w-2xs relative', { 'form px-8 pt-6 pb-8 ': isBoxed }, { 'opacity-50': methods.formState.isSubmitting }, className), children: [children, submit && (jsxRuntime.jsx("div", { className: "flex items-center justify-end py-2", children: jsxRuntime.jsx(Button, { id: submitID || submit, className: submitClasses, ariaLabel: ariaSubmitLabel || submit || 'Submit', type: submitType, outline: true, isLoading: methods.formState.isSubmitting, disabled: methods.formState.isSubmitting || !methods.formState.isValid, variant: submitVariant, children: submit }) }))] }) }) })));
631
635
  };
632
636
  Form.displayName = 'Form';
633
637
 
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Props } from './Form.types';
3
3
  declare const Form: {
4
- ({ children, className, submit, onSubmit, onChange, hideSubmit, ariaSubmitLabel, submitID, submitVariant, initialValues, isBoxed, }: Props): React.ReactElement;
4
+ ({ children, className, submit, onSubmit, onChange, hideSubmit, ariaSubmitLabel, submitID, submitVariant, initialValues, isBoxed, submitType, disabledSubmitWithReturn, }: Props): React.ReactElement;
5
5
  displayName: string;
6
6
  };
7
7
  export default Form;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { BTN_VARIANTS } from '../Button/Button.types';
2
+ import { BTN_TYPES, BTN_VARIANTS } from '../Button/Button.types';
3
3
  export interface Props {
4
4
  /** The form inputs and content. */
5
5
  children: React.ReactNode;
@@ -27,4 +27,7 @@ export interface Props {
27
27
  submitVariant?: BTN_VARIANTS;
28
28
  /** The form is boxed. */
29
29
  isBoxed?: boolean;
30
+ /** The submit button type. */
31
+ submitType?: BTN_TYPES.SUBMIT | BTN_TYPES.BUTTON;
32
+ disabledSubmitWithReturn?: boolean;
30
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4alldigital/foundation-ui--gamma",
3
- "version": "1.31.6",
3
+ "version": "1.31.7",
4
4
  "description": "Foundation UI Component library with GAMMA theme. ",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -25,7 +25,7 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
- "gitHead": "2dee6ed0cc592c27c3c936a79b39430fa2b4a025",
28
+ "gitHead": "e417e292c98e15ed7050342a41ac6dd36736850d",
29
29
  "dependencies": {
30
30
  "@elastic/datemath": "^5.0.3",
31
31
  "@elastic/eui": "^94.1.0",