@weareconceptstudio/form 0.0.8 → 0.1.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.
@@ -40,6 +40,8 @@ const BaseForm = forwardRef(({ initialValues: defaultValues, values, children, o
40
40
  }, [methods, onSubmit]);
41
41
  useImperativeHandle(ref, () => ({
42
42
  ...methods,
43
+ isValid: methods.formState.isValid,
44
+ isFormTouched: Object.keys(methods.formState.touchedFields).length > 0,
43
45
  submit: () => methods.handleSubmit(handleSubmit)(),
44
46
  }));
45
47
  return (React.createElement(FormProvider, { ...methods },
@@ -2,7 +2,7 @@ import React, { useRef, cloneElement } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { hasPrefixSuffix, hasAddon } from './utils';
4
4
  const BaseInput = (props) => {
5
- const { inputElement: inputEl, addonBefore, addonAfter, prefix, suffix, allowClear, disabled, readOnly, components, value, className, children } = props;
5
+ const { inputElement: inputEl, addonBefore, addonAfter, prefix, suffix, allowClear, disabled, readOnly, components, value, containerClassName, children } = props;
6
6
  const inputElement = children ?? inputEl;
7
7
  // ======================== Components ======================== //
8
8
  const AffixWrapperComponent = components?.affixWrapper || 'div';
@@ -52,7 +52,7 @@ const BaseInput = (props) => {
52
52
  addonAfter && React.createElement(GroupAddonComponent, null, addonAfter))));
53
53
  }
54
54
  const classString = classNames('base-input-container', {
55
- [`${className}-container`]: className,
55
+ [containerClassName]: containerClassName,
56
56
  });
57
57
  return (React.createElement("div", { className: classString }, cloneElement(element, {
58
58
  className: classNames({
@@ -1,12 +1,17 @@
1
1
  import React from 'react';
2
2
  import BaseInput from '../BaseInput';
3
3
  import { useInput } from '../../form/hooks/useInput';
4
+ import { useTranslation } from '@weareconceptstudio/core';
4
5
  const TextArea = (props) => {
5
- const { field } = useInput({
6
- name: props.name,
7
- });
6
+ const { translate } = useTranslation();
7
+ const { name, placeholder, rows = 5, onChange, onFocus, onBlur, onKeyDown, onKeyUp, disabled, className, autoComplete } = props;
8
+ const input = name ? useInput({ name, onChange, onBlur }) : null;
9
+ const field = input?.field || {
10
+ onChange: onChange,
11
+ onBlur: onBlur,
12
+ };
8
13
  return (React.createElement(BaseInput, { ...props },
9
- React.createElement("textarea", { ...field, rows: 5 })));
14
+ React.createElement("textarea", { ...field, rows: rows, onFocus: onFocus, onKeyUp: onKeyUp, disabled: disabled, className: className, onKeyDown: onKeyDown, autoComplete: autoComplete, placeholder: translate(placeholder) })));
10
15
  };
11
16
  if (process.env.NODE_ENV !== 'production') {
12
17
  TextArea.displayName = 'TextArea';
@@ -52,6 +52,13 @@ const Select = (props) => {
52
52
  select_empty || empty,
53
53
  React.createElement("p", { className: `no-options` }, 'No Data')));
54
54
  };
55
+ //! Custom Styles
56
+ const customStyles = {
57
+ menuList: (provided) => ({
58
+ ...provided,
59
+ maxHeight: '144px',
60
+ }),
61
+ };
55
62
  const options = useMemo(() => {
56
63
  const newOptions = [];
57
64
  const labelKey = optionKey ?? 'name';
@@ -82,7 +89,7 @@ const Select = (props) => {
82
89
  return (React.createElement(ReactSelect
83
90
  // unstyled
84
91
  // menuIsOpen={true}
85
- , { ...selectProps, options: options, isMulti: multiple, isLoading: loading, isDisabled: disabled, className: classString, isClearable: allowClear, isSearchable: allowSearch, components: customComponents, classNamePrefix: 'react-select', noOptionsMessage: customNoOptionsMessage, value: options.filter((opt) => (multiple ? selectProps.value.includes(opt.value) : opt.value === selectProps.value)) }));
92
+ , { ...selectProps, options: options, isMulti: multiple, isLoading: loading, styles: customStyles, isDisabled: disabled, className: classString, isClearable: allowClear, isSearchable: allowSearch, components: customComponents, classNamePrefix: 'react-select', noOptionsMessage: customNoOptionsMessage, value: options.filter((opt) => (multiple ? selectProps.value.includes(opt.value) : opt.value === selectProps.value)) }));
86
93
  };
87
94
  if (process.env.NODE_ENV !== 'production') {
88
95
  Select.displayName = 'Select';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/form",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "Concept Studio Form",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",