@luscii-healthtech/web-ui 2.65.0 → 2.66.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.
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Control, RegisterOptions } from "react-hook-form";
3
+ import { TextareaProps } from "../Textarea/Textarea";
4
+ import { FieldTextareaConfiguration, FormFieldLabelerWithFormProps } from "./form.types";
5
+ interface FormTextareaProps extends FieldTextareaConfiguration, Omit<TextareaProps, "name">, FormFieldLabelerWithFormProps {
6
+ control: Control;
7
+ rules?: Exclude<RegisterOptions, "valueAsNumber" | "valueAsDate" | "setValueAs">;
8
+ type: "textarea";
9
+ }
10
+ /**
11
+ * Input field that can be used in any react-hook-form context.
12
+ */
13
+ export declare const FormTextarea: React.ForwardRefExoticComponent<FormTextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
14
+ export {};
@@ -7,6 +7,7 @@ import { ImagePickerProps } from "../ImagePicker/ImagePicker";
7
7
  import { PartialProperties } from "../../types/general.types";
8
8
  import { CheckboxProps } from "../Checkbox/Checkbox";
9
9
  import { CheckboxListProps } from "../CheckboxList/CheckboxList.types";
10
+ import { TextareaProps } from "../Textarea/Textarea";
10
11
  export declare type AllowedTextInputTypes = Extract<HTMLInputTypeAttribute, "email" | "number" | "password" | "text">;
11
12
  export declare type FormFieldWidth = "sm" | "md" | "lg" | "xl" | "full";
12
13
  interface FormFieldBaseConfiguration<TFieldType> extends FormFieldLabelerProps {
@@ -31,7 +32,7 @@ export interface FormFieldLabelerProps {
31
32
  interface FieldVoidConfiguration extends Partial<FormFieldBaseConfiguration<never>> {
32
33
  type: "void";
33
34
  }
34
- export declare type FormFieldConfiguration<TFieldValues> = FieldInputConfiguration | FieldSelectConfiguration | FieldImagePickerConfiguration | FieldRadioGroupConfiguration | FieldRowConfiguration<TFieldValues> | FieldCheckboxConfiguration | FieldCheckboxListConfiguration | FieldVoidConfiguration;
35
+ export declare type FormFieldConfiguration<TFieldValues> = FieldInputConfiguration | FieldSelectConfiguration | FieldImagePickerConfiguration | FieldRadioGroupConfiguration | FieldRowConfiguration<TFieldValues> | FieldCheckboxConfiguration | FieldCheckboxListConfiguration | FieldTextareaConfiguration | FieldVoidConfiguration;
35
36
  /**
36
37
  * @backwardscompatibility
37
38
  * @deprecated - this is an alias for `FormFieldConfiguration`, for backwards compatibility the name can remain for now, but
@@ -46,6 +47,9 @@ export interface FieldRowConfiguration<TFieldValues> extends Record<keyof FormFi
46
47
  export interface FieldInputConfiguration extends FormFieldBaseConfiguration<Omit<InputProps, "name">> {
47
48
  type: AllowedTextInputTypes;
48
49
  }
50
+ export interface FieldTextareaConfiguration extends FormFieldBaseConfiguration<Omit<TextareaProps, "name">> {
51
+ type: "textarea";
52
+ }
49
53
  export interface FieldRadioGroupConfiguration extends FormFieldBaseConfiguration<Omit<RadioGroupProps, "name">> {
50
54
  type: "radioGroup";
51
55
  }
@@ -1,22 +1,29 @@
1
- export default Textarea;
2
- declare function Textarea(props: any): JSX.Element;
3
- declare namespace Textarea {
4
- namespace propTypes {
5
- const className: PropTypes.Requireable<string>;
6
- const value: PropTypes.Requireable<string>;
7
- const name: PropTypes.Validator<string>;
8
- const placeholder: PropTypes.Requireable<string>;
9
- const maxLength: PropTypes.Requireable<number>;
10
- const rows: PropTypes.Requireable<number>;
11
- const resizable: PropTypes.Requireable<string>;
12
- const isDisabled: PropTypes.Requireable<boolean>;
13
- const icon: PropTypes.Requireable<string>;
14
- const onChange: PropTypes.Validator<(...args: any[]) => any>;
15
- const onBlur: PropTypes.Requireable<(...args: any[]) => any>;
16
- const onFocus: PropTypes.Requireable<(...args: any[]) => any>;
17
- const onKeyPress: PropTypes.Requireable<(...args: any[]) => any>;
18
- const onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
19
- const onCtrlEnter: PropTypes.Requireable<(...args: any[]) => any>;
20
- }
1
+ import React, { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
2
+ import "./Textarea.scss";
3
+ declare const resizeTypes: {
4
+ readonly NONE: "none";
5
+ readonly BOTH: "both";
6
+ readonly HORIZONTAL: "horizontal";
7
+ readonly VERTICAL: "vertical";
8
+ };
9
+ export declare type ResizeTypes = (typeof resizeTypes)[keyof typeof resizeTypes];
10
+ export interface TextareaProps {
11
+ className?: string;
12
+ value?: string;
13
+ name?: string;
14
+ placeholder?: string;
15
+ maxLength?: number;
16
+ rows?: number;
17
+ resizable?: ResizeTypes;
18
+ isDisabled?: boolean;
19
+ icon?: string;
20
+ onChange: (event: ChangeEvent) => void;
21
+ onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
22
+ onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
23
+ onKeyPress?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
24
+ onKeyDown?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
25
+ onCtrlEnter?: () => void;
26
+ isError?: boolean;
21
27
  }
22
- import PropTypes from "prop-types";
28
+ export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
29
+ export {};
package/dist/index.d.ts CHANGED
@@ -61,7 +61,7 @@ export { PageHeader, PageHeaderProps } from "./components/PageHeader";
61
61
  export { default as TabLinks } from "./components/TabLinks/TabLinks";
62
62
  export { default as Tag } from "./components/Tag/Tag";
63
63
  export { default as TagGroup } from "./components/Tag/TagGroup";
64
- export { default as TextArea } from "./components/Textarea/Textarea";
64
+ export { Textarea, TextareaProps, ResizeTypes, } from "./components/Textarea/Textarea";
65
65
  export { default as TextEditor } from "./components/TextEditor/TextEditor";
66
66
  export { default as TextEditorV2 } from "./components/TextEditorV2/TextEditorV2";
67
67
  export { TextLink, TextLinkProps } from "./components/TextLink/TextLink";
@@ -34,6 +34,7 @@ var htmlToDraft = _interopDefault(require('html-to-draftjs'));
34
34
  require('react-draft-wysiwyg/dist/react-draft-wysiwyg.css');
35
35
  var pick = _interopDefault(require('lodash/pick'));
36
36
  var index_ie11 = require('react-hook-form/dist/index.ie11');
37
+ var reactHookForm = require('react-hook-form');
37
38
 
38
39
  function _regeneratorRuntime() {
39
40
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -7834,50 +7835,32 @@ var css_248z$p = ".cweb-textarea {\n border: 1px solid #cccccc;\n border-radiu
7834
7835
  styleInject(css_248z$p);
7835
7836
 
7836
7837
  var _excluded$s = ["className", "value", "name", "placeholder", "maxLength", "rows", "resizable", "isDisabled", "icon", "onChange", "onBlur", "onFocus", "onKeyPress", "onKeyDown", "onCtrlEnter"];
7837
- var RESIZE_TYPES = {
7838
+ var resizeTypes = {
7838
7839
  NONE: "none",
7839
7840
  BOTH: "both",
7840
7841
  HORIZONTAL: "horizontal",
7841
7842
  VERTICAL: "vertical"
7842
7843
  };
7843
- Textarea.propTypes = {
7844
- className: PropTypes.string,
7845
- value: PropTypes.string,
7846
- name: PropTypes.string.isRequired,
7847
- placeholder: PropTypes.string,
7848
- maxLength: PropTypes.number,
7849
- rows: PropTypes.number,
7850
- resizable: /*#__PURE__*/PropTypes.oneOf([RESIZE_TYPES.BOTH, RESIZE_TYPES.HORIZONTAL, RESIZE_TYPES.VERTICAL, RESIZE_TYPES.NONE]),
7851
- isDisabled: PropTypes.bool,
7852
- icon: PropTypes.string,
7853
- onChange: PropTypes.func.isRequired,
7854
- onBlur: PropTypes.func,
7855
- onFocus: PropTypes.func,
7856
- onKeyPress: PropTypes.func,
7857
- onKeyDown: PropTypes.func,
7858
- onCtrlEnter: PropTypes.func
7859
- };
7860
-
7861
- function Textarea(props) {
7862
- var className = props.className,
7863
- value = props.value,
7864
- name = props.name,
7865
- placeholder = props.placeholder,
7866
- maxLength = props.maxLength,
7867
- _props$rows = props.rows,
7868
- rows = _props$rows === void 0 ? 4 : _props$rows,
7869
- _props$resizable = props.resizable,
7870
- resizable = _props$resizable === void 0 ? RESIZE_TYPES.VERTICAL : _props$resizable,
7871
- _props$isDisabled = props.isDisabled,
7872
- isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
7873
- icon = props.icon,
7874
- onChange = props.onChange,
7875
- onBlur = props.onBlur,
7876
- onFocus = props.onFocus,
7877
- onKeyPress = props.onKeyPress,
7878
- _onKeyDown = props.onKeyDown,
7879
- onCtrlEnter = props.onCtrlEnter,
7880
- otherProps = _objectWithoutPropertiesLoose(props, _excluded$s);
7844
+ var Textarea = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
7845
+ var className = _ref.className,
7846
+ value = _ref.value,
7847
+ name = _ref.name,
7848
+ placeholder = _ref.placeholder,
7849
+ maxLength = _ref.maxLength,
7850
+ _ref$rows = _ref.rows,
7851
+ rows = _ref$rows === void 0 ? 4 : _ref$rows,
7852
+ _ref$resizable = _ref.resizable,
7853
+ resizable = _ref$resizable === void 0 ? resizeTypes.VERTICAL : _ref$resizable,
7854
+ _ref$isDisabled = _ref.isDisabled,
7855
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
7856
+ icon = _ref.icon,
7857
+ onChange = _ref.onChange,
7858
+ onBlur = _ref.onBlur,
7859
+ onFocus = _ref.onFocus,
7860
+ onKeyPress = _ref.onKeyPress,
7861
+ _onKeyDown = _ref.onKeyDown,
7862
+ onCtrlEnter = _ref.onCtrlEnter,
7863
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$s);
7881
7864
 
7882
7865
  var style;
7883
7866
 
@@ -7896,7 +7879,7 @@ function Textarea(props) {
7896
7879
  onFocus: onFocus,
7897
7880
  onKeyPress: onKeyPress,
7898
7881
  onKeyDown: function onKeyDown(event) {
7899
- _onKeyDown == null ? void 0 : _onKeyDown();
7882
+ _onKeyDown == null ? void 0 : _onKeyDown(event);
7900
7883
  var ctrlKey = event.ctrlKey,
7901
7884
  metaKey = event.metaKey,
7902
7885
  key = event.key;
@@ -7910,13 +7893,14 @@ function Textarea(props) {
7910
7893
  disabled: isDisabled,
7911
7894
  className: classNames("cweb-textarea", className, "p-2", "border", "placeholder-gray-500", "text-sm", "border-solid", "border-input-border", "hover:border-input-border-dark", "focus:outline-primary", "transition-colors", "duration-300", "w-full", "focus:border-primary", {
7912
7895
  "has-icon": !!icon,
7913
- resizable: resizable === RESIZE_TYPES.BOTH,
7914
- "resizable-x": resizable === RESIZE_TYPES.HORIZONTAL,
7915
- "resizable-y": resizable === RESIZE_TYPES.VERTICAL
7896
+ resizable: resizable === resizeTypes.BOTH,
7897
+ "resizable-x": resizable === resizeTypes.HORIZONTAL,
7898
+ "resizable-y": resizable === resizeTypes.VERTICAL
7916
7899
  }),
7917
- style: style
7900
+ style: style,
7901
+ ref: ref
7918
7902
  }));
7919
- }
7903
+ });
7920
7904
 
7921
7905
  var css_248z$q = ".ql-editor {\n resize: vertical;\n min-height: 10rem;\n}\n\n.ql-snow.ql-toolbar {\n display: block;\n background: #f1f5f9;\n border-top-left-radius: 0.5em;\n border-top-right-radius: 0.5em;\n margin-top: 0.5em;\n}";
7922
7906
  styleInject(css_248z$q);
@@ -8513,6 +8497,42 @@ var FormFieldCheckboxList = function FormFieldCheckboxList(_ref) {
8513
8497
  }));
8514
8498
  };
8515
8499
 
8500
+ var _excluded$z = ["control", "name", "rules", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
8501
+ /**
8502
+ * Input field that can be used in any react-hook-form context.
8503
+ */
8504
+
8505
+ var FormTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
8506
+ var control = _ref.control,
8507
+ name = _ref.name,
8508
+ rules = _ref.rules,
8509
+ fieldErrors = _ref.fieldErrors,
8510
+ fieldRequired = _ref.fieldRequired,
8511
+ label = _ref.label,
8512
+ info = _ref.info,
8513
+ decoratorClassname = _ref.decoratorClassname,
8514
+ fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$z);
8515
+
8516
+ return /*#__PURE__*/React__default.createElement(FormFieldLabeler, {
8517
+ name: name,
8518
+ fieldErrors: fieldErrors,
8519
+ fieldRequired: fieldRequired,
8520
+ label: label,
8521
+ info: info,
8522
+ decoratorClassname: decoratorClassname
8523
+ }, /*#__PURE__*/React__default.createElement(reactHookForm.Controller, {
8524
+ name: name,
8525
+ control: control,
8526
+ rules: rules,
8527
+ render: function render(field) {
8528
+ return /*#__PURE__*/React__default.createElement(Textarea, _extends({}, fieldProps, field, {
8529
+ isError: hasError(name, fieldErrors),
8530
+ ref: innerRef
8531
+ }));
8532
+ }
8533
+ }));
8534
+ });
8535
+
8516
8536
  /**
8517
8537
  * Create a straight forward Form, which takes away the 'overhead' of react-hook-form.
8518
8538
  *
@@ -8669,6 +8689,20 @@ function FormFieldMapper(formFieldProps, useFormReturn) {
8669
8689
  }));
8670
8690
  }
8671
8691
 
8692
+ case "textarea":
8693
+ {
8694
+ return /*#__PURE__*/React__default.createElement(FormTextarea, _extends({
8695
+ key: name
8696
+ }, decoratorProps, {
8697
+ fieldRequired: isRequired(options),
8698
+ fieldErrors: errors,
8699
+ type: "textarea",
8700
+ name: name,
8701
+ rules: options,
8702
+ control: control
8703
+ }, fieldProps));
8704
+ }
8705
+
8672
8706
  case "void":
8673
8707
  return null;
8674
8708
 
@@ -8848,10 +8882,10 @@ exports.Tag = Tag;
8848
8882
  exports.TagGroup = TagGroup;
8849
8883
  exports.TertiaryButton = TertiaryButton;
8850
8884
  exports.Text = Text;
8851
- exports.TextArea = Textarea;
8852
8885
  exports.TextEditor = TextEditor;
8853
8886
  exports.TextEditorV2 = TextEditorV2;
8854
8887
  exports.TextLink = TextLink;
8888
+ exports.Textarea = Textarea;
8855
8889
  exports.Timeline = Timeline;
8856
8890
  exports.Title = Title;
8857
8891
  exports.Toaster = Toaster;