@weareconceptstudio/form 0.0.2 → 0.0.4

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.
Files changed (83) hide show
  1. package/dist/FormConfig.d.ts +5 -0
  2. package/dist/FormConfig.js +19 -0
  3. package/dist/checkbox/BaseCheckbox.d.ts +3 -0
  4. package/dist/checkbox/BaseCheckbox.js +51 -0
  5. package/dist/checkbox/index.d.ts +1 -1
  6. package/dist/checkbox/index.js +16 -5
  7. package/dist/color-picker/index.d.ts +5 -2
  8. package/dist/color-picker/index.js +4 -4
  9. package/dist/date-picker/index.d.ts +7 -2
  10. package/dist/date-picker/index.js +4 -4
  11. package/dist/error-message/index.d.ts +3 -0
  12. package/dist/error-message/index.js +9 -6
  13. package/dist/form/BaseForm.d.ts +22 -17
  14. package/dist/form/BaseForm.js +41 -55
  15. package/dist/form/Builder/index.d.ts +9 -0
  16. package/dist/form/Builder/index.js +46 -0
  17. package/dist/form/Builder/style.d.ts +2 -0
  18. package/dist/form/Builder/style.js +3 -0
  19. package/dist/form/Item/index.d.ts +12 -10
  20. package/dist/form/Item/index.js +26 -19
  21. package/dist/form/hooks/rules.d.ts +3 -0
  22. package/dist/form/hooks/rules.js +44 -0
  23. package/dist/form/hooks/useEvent.d.ts +1 -0
  24. package/dist/form/hooks/useEvent.js +12 -0
  25. package/dist/form/hooks/useFormInstance.js +4 -1
  26. package/dist/form/hooks/useInput.d.ts +12 -0
  27. package/dist/form/hooks/useInput.js +46 -0
  28. package/dist/form/index.d.ts +6 -16
  29. package/dist/form/index.js +3 -2
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +4 -0
  32. package/dist/input/BaseInput/index.d.ts +5 -3
  33. package/dist/input/BaseInput/index.js +28 -39
  34. package/dist/input/Input.d.ts +5 -2
  35. package/dist/input/Input.js +18 -16
  36. package/dist/input/Number/index.d.ts +5 -2
  37. package/dist/input/Number/index.js +27 -4
  38. package/dist/input/Password/icons.d.ts +1 -1
  39. package/dist/input/Password/icons.js +6 -6
  40. package/dist/input/Password/index.d.ts +5 -2
  41. package/dist/input/Password/index.js +8 -8
  42. package/dist/input/TextArea/index.d.ts +5 -2
  43. package/dist/input/TextArea/index.js +8 -9
  44. package/dist/input/index.d.ts +11 -2
  45. package/dist/input/index.js +6 -4
  46. package/dist/phone-number/index.d.ts +7 -0
  47. package/dist/phone-number/index.js +13 -0
  48. package/dist/radio/BaseRadio.d.ts +1 -1
  49. package/dist/radio/BaseRadio.js +20 -7
  50. package/dist/radio/Group.d.ts +1 -1
  51. package/dist/radio/Group.js +24 -4
  52. package/dist/radio/context.d.ts +1 -1
  53. package/dist/radio/context.js +3 -3
  54. package/dist/radio/index.js +2 -2
  55. package/dist/select/icons.d.ts +3 -0
  56. package/dist/select/icons.js +6 -0
  57. package/dist/select/index.d.ts +5 -2
  58. package/dist/select/index.js +57 -20
  59. package/dist/styles/formStyle.d.ts +2 -0
  60. package/dist/styles/formStyle.js +585 -0
  61. package/dist/styles/theme.d.ts +2 -0
  62. package/dist/styles/theme.js +113 -0
  63. package/dist/styles/variables.d.ts +2 -0
  64. package/dist/styles/variables.js +246 -0
  65. package/dist/translations/en.d.ts +52 -0
  66. package/dist/translations/en.js +52 -0
  67. package/dist/translations/index.d.ts +54 -0
  68. package/dist/translations/index.js +2 -0
  69. package/dist/upload/UploadButton/index.d.ts +3 -0
  70. package/dist/upload/UploadButton/index.js +41 -0
  71. package/dist/upload/UploadButton/style.d.ts +2 -0
  72. package/dist/upload/UploadButton/style.js +24 -0
  73. package/dist/upload/UploadList/ListItem/index.d.ts +5 -0
  74. package/dist/upload/UploadList/ListItem/index.js +11 -0
  75. package/dist/upload/UploadList/index.d.ts +3 -0
  76. package/dist/upload/UploadList/index.js +11 -0
  77. package/dist/upload/UploadList/style.d.ts +2 -0
  78. package/dist/upload/UploadList/style.js +13 -0
  79. package/dist/upload/index.d.ts +5 -2
  80. package/dist/upload/index.js +18 -5
  81. package/dist/upload/utils.d.ts +9 -0
  82. package/dist/upload/utils.js +64 -0
  83. package/package.json +31 -34
@@ -1,17 +1,7 @@
1
+ import BaseForm from './BaseForm';
2
+ import Item from './Item';
3
+ type FormComponent<T> = typeof BaseForm & {
4
+ Item: typeof Item;
5
+ };
6
+ declare const Form: FormComponent<any>;
1
7
  export default Form;
2
- declare const Form: ({ initialValues: defaultValues, values, children, onSubmit, layout, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, }: {
3
- initialValues: any;
4
- values: any;
5
- children: any;
6
- onSubmit: any;
7
- layout?: string;
8
- mode?: string;
9
- reValidateMode: any;
10
- errors: any;
11
- resetOptions: any;
12
- criteriaMode: any;
13
- shouldFocusError: any;
14
- delayError: any;
15
- shouldUseNativeValidation: any;
16
- shouldUnregister: any;
17
- }) => import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
- import BaseForm from "./BaseForm";
2
- import Item from "./Item";
1
+ import BaseForm from './BaseForm';
2
+ import Item from './Item';
3
+ // Create the Form object with both BaseForm and Item component
3
4
  const Form = BaseForm;
4
5
  Form.Item = Item;
5
6
  export default Form;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ export * from "./FormConfig";
1
2
  export { default as Form } from "./form";
3
+ export { default as FormBuilder } from "./form/Builder";
2
4
  export { default as ErrorMessage } from "./error-message";
3
5
  export { default as Input } from "./input";
4
6
  export { default as Checkbox } from "./checkbox";
@@ -7,3 +9,4 @@ export { default as DatePicker } from "./date-picker";
7
9
  export { default as Radio } from "./radio";
8
10
  export { default as Select } from "./select";
9
11
  export { default as Upload } from "./upload";
12
+ export { default as PhoneNumber } from "./phone-number";
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
+ 'use client';
2
+ export * from './FormConfig';
1
3
  export { default as Form } from './form';
4
+ export { default as FormBuilder } from './form/Builder';
2
5
  export { default as ErrorMessage } from './error-message';
3
6
  export { default as Input } from './input';
4
7
  export { default as Checkbox } from './checkbox';
@@ -7,3 +10,4 @@ export { default as DatePicker } from './date-picker';
7
10
  export { default as Radio } from './radio';
8
11
  export { default as Select } from './select';
9
12
  export { default as Upload } from './upload';
13
+ export { default as PhoneNumber } from './phone-number';
@@ -1,4 +1,6 @@
1
- export const InputContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
2
1
  export default BaseInput;
3
- import * as React from "react";
4
- declare const BaseInput: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
2
+ declare function BaseInput(props: any): React.JSX.Element;
3
+ declare namespace BaseInput {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -1,36 +1,22 @@
1
- import * as React from 'react';
2
- import styled from 'styled-components';
3
- import clsx from 'classnames';
1
+ import React, { useRef, cloneElement } from 'react';
2
+ import classNames from 'classnames';
4
3
  import { hasPrefixSuffix, hasAddon } from './utils';
5
- export const InputContainer = styled.div `
6
- .affix-wrapper {
7
- position:relative;
8
- display:inline-flex;
9
-
10
- .clear-icon {
11
- font-size: 12px;
12
- cursor: pointer;
13
-
14
- &-hidden {
15
- display: none;
16
- }
17
- }
18
- }
19
- `;
20
- const BaseInput = React.forwardRef((props, forwardRef) => {
4
+ const BaseInput = (props) => {
21
5
  const { inputElement: inputEl, addonBefore, addonAfter, prefix, suffix, allowClear, disabled, readOnly, components, value, className, children } = props;
22
6
  const inputElement = children ?? inputEl;
23
7
  // ======================== Components ======================== //
24
- const AffixWrapperComponent = components?.affixWrapper || 'span';
25
- const GroupWrapperComponent = components?.groupWrapper || 'span';
26
- const WrapperComponent = components?.wrapper || 'span';
27
- const GroupAddonComponent = components?.groupAddon || 'span';
8
+ const AffixWrapperComponent = components?.affixWrapper || 'div';
9
+ const GroupWrapperComponent = components?.groupWrapper || 'div';
10
+ const WrapperComponent = components?.wrapper || 'div';
11
+ const GroupAddonComponent = components?.groupAddon || 'div';
28
12
  // ======================== Refs ======================== //
29
- const containerRef = React.useRef(null);
30
- const groupRef = React.useRef(null);
31
- let element = React.cloneElement(inputElement, {
32
- // ...props,
33
- className: `base-input`
13
+ const containerRef = useRef(null);
14
+ const groupRef = useRef(null);
15
+ let element = cloneElement(inputElement, {
16
+ className: classNames({
17
+ 'base-input': true,
18
+ [`${inputElement.props.className}`]: inputElement.props.className,
19
+ }),
34
20
  });
35
21
  // ======================== Prefix && Suffix ======================== //
36
22
  if (hasPrefixSuffix(props)) {
@@ -38,15 +24,13 @@ const BaseInput = React.forwardRef((props, forwardRef) => {
38
24
  if (allowClear) {
39
25
  const needClear = !disabled && !readOnly && !!value;
40
26
  const clearIconCls = 'clear-icon';
41
- const iconNode = typeof allowClear === 'object' && allowClear?.clearIcon
42
- ? allowClear.clearIcon
43
- : '✖';
27
+ const iconNode = typeof allowClear === 'object' && allowClear?.clearIcon ? allowClear.clearIcon : '✖';
44
28
  clearIcon = (React.createElement("span", {
45
29
  // onClick={(event) => {
46
30
  // handleReset?.(event);
47
31
  // onClear?.();
48
32
  // }}
49
- onMouseDown: (e) => e.preventDefault(), role: "button", tabIndex: -1, className: clsx(clearIconCls, {
33
+ onMouseDown: (e) => e.preventDefault(), role: 'button', tabIndex: -1, className: classNames(clearIconCls, {
50
34
  [`${clearIconCls}-hidden`]: !needClear,
51
35
  [`${clearIconCls}-has-suffix`]: !!suffix,
52
36
  }) }, iconNode));
@@ -55,22 +39,27 @@ const BaseInput = React.forwardRef((props, forwardRef) => {
55
39
  clearIcon,
56
40
  suffix));
57
41
  element = (React.createElement(AffixWrapperComponent, { ref: containerRef, className: 'affix-wrapper' },
58
- prefix && (React.createElement("span", null, prefix)),
42
+ prefix && React.createElement("span", null, prefix),
59
43
  element,
60
44
  suffixNode));
61
45
  }
62
46
  // ======================== Addon (Before && After) ======================== //
63
47
  if (hasAddon(props)) {
64
- element = (React.createElement(GroupWrapperComponent, { ref: groupRef },
48
+ element = (React.createElement(GroupWrapperComponent, { className: 'group-wrapper', ref: groupRef },
65
49
  React.createElement(WrapperComponent, null,
66
- addonBefore && (React.createElement(GroupAddonComponent, null, addonBefore)),
50
+ addonBefore && React.createElement(GroupAddonComponent, null, addonBefore),
67
51
  element,
68
- addonAfter && (React.createElement(GroupAddonComponent, null, addonAfter)))));
52
+ addonAfter && React.createElement(GroupAddonComponent, null, addonAfter))));
69
53
  }
70
- return (React.createElement(InputContainer, null, React.cloneElement(element, {
71
- className: clsx(element.props?.className, className) || null,
54
+ const classString = classNames('base-input-container', {
55
+ [`${className}-container`]: className,
56
+ });
57
+ return (React.createElement("div", { className: classString }, cloneElement(element, {
58
+ className: classNames({
59
+ [element.props.className]: element.props.className,
60
+ }),
72
61
  })));
73
- });
62
+ };
74
63
  if (process.env.NODE_ENV !== 'production') {
75
64
  BaseInput.displayName = 'BaseInput';
76
65
  }
@@ -1,3 +1,6 @@
1
1
  export default Input;
2
- declare const Input: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
2
+ declare function Input(props: any): React.JSX.Element;
3
+ declare namespace Input {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -1,18 +1,20 @@
1
- import * as React from 'react';
2
- import styled from 'styled-components';
1
+ import React from 'react';
3
2
  import BaseInput from './BaseInput';
4
- const StyledInput = styled.input `
5
- box-sizing: border-box;
6
- margin: 0;
7
- list-style: none;
8
- display: inline-block;
9
- font-size: 14px;
10
- padding: 4px 11px;
11
- outline: none;
12
- `;
13
- const Input = React.forwardRef((props, forwardRef) => {
14
- const { autoComplete, onChange, onFocus, onBlur, onPressEnter, onKeyDown, onKeyUp, disabled, className, type = 'text', placeholder, value, } = props;
15
- return (React.createElement(BaseInput, { ...props, value: value, disabled: disabled },
16
- React.createElement(StyledInput, { type: type, autoComplete: autoComplete, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onPressEnter: onPressEnter, onKeyDown: onKeyDown, onKeyUp: onKeyUp, disabled: disabled, className: className, placeholder: placeholder, ...forwardRef })));
17
- });
3
+ import { useInput } from '../form/hooks/useInput';
4
+ import { useTranslation } from '@weareconceptstudio/core';
5
+ const Input = (props) => {
6
+ const { name, autoComplete = 'new-password', onChange, onFocus, onBlur, onKeyDown, onKeyUp, disabled, className, type = 'text', placeholder } = props;
7
+ const { translate } = useTranslation();
8
+ const { field } = useInput({
9
+ type,
10
+ name,
11
+ onChange,
12
+ onBlur,
13
+ });
14
+ return (React.createElement(BaseInput, { ...props, value: field.value, disabled: disabled },
15
+ React.createElement("input", { type: type, onFocus: onFocus, onKeyUp: onKeyUp, disabled: disabled, className: className, onKeyDown: onKeyDown, placeholder: translate(placeholder), autoComplete: autoComplete, ...field })));
16
+ };
17
+ if (process.env.NODE_ENV !== 'production') {
18
+ Input.displayName = 'Input';
19
+ }
18
20
  export default Input;
@@ -1,3 +1,6 @@
1
1
  export default Number;
2
- declare const Number: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
2
+ declare function Number(props: any): React.JSX.Element;
3
+ declare namespace Number {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -1,8 +1,31 @@
1
- import * as React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import Input from '../Input';
3
- const Number = React.forwardRef((props, forwardRef) => {
4
- return (React.createElement(Input, { ref: forwardRef, type: 'number', ...props }));
5
- });
3
+ const Number = (props) => {
4
+ //! Disable number input scroll
5
+ useEffect(() => {
6
+ const handleMouseWheel = (e) => {
7
+ e.target.blur();
8
+ };
9
+ const handleKeyDown = (e) => {
10
+ const key = e.charCode || e.keyCode;
11
+ if (key === 38 || key === 40) {
12
+ e.preventDefault();
13
+ }
14
+ };
15
+ const numberInputs = document.querySelectorAll('input[type="number"]');
16
+ numberInputs.forEach((input) => {
17
+ input.addEventListener('mousewheel', handleMouseWheel);
18
+ input.addEventListener('keydown', handleKeyDown);
19
+ });
20
+ return () => {
21
+ numberInputs.forEach((input) => {
22
+ input.removeEventListener('mousewheel', handleMouseWheel);
23
+ input.removeEventListener('keydown', handleKeyDown);
24
+ });
25
+ };
26
+ }, []);
27
+ return (React.createElement(Input, { type: 'number', ...props }));
28
+ };
6
29
  if (process.env.NODE_ENV !== 'production') {
7
30
  Number.displayName = 'InputNumber';
8
31
  }
@@ -1,3 +1,3 @@
1
1
  export const eyeIcon: React.JSX.Element;
2
2
  export const openEye: React.JSX.Element;
3
- import React from "react";
3
+ import React from 'react';
@@ -1,6 +1,6 @@
1
- import React from "react";
2
- export const eyeIcon = React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", viewBox: "0 0 32 32" },
3
- React.createElement("path", { d: "M15.817 26.533c-8.133 0-14.267-8.8-14.533-9.2s-0.267-1.067 0-1.6c0.267-0.4 6.667-9.067 14.667-9.067 8.133 0 14.267 8.667 14.533 9.067s0.267 1.067 0 1.6c-0.267 0.4-6.667 9.2-14.667 9.2zM4.083 16.533c1.6 2 6.4 7.333 11.733 7.333 5.467 0 10.267-5.333 11.867-7.333-1.6-2-6.4-7.2-11.733-7.2-5.467 0-10.267 5.2-11.867 7.2z" }),
4
- React.createElement("path", { d: "M15.952 22.266c-3.2 0-5.733-2.533-5.733-5.733s2.533-5.733 5.733-5.733c3.2 0 5.733 2.533 5.733 5.733s-2.533 5.733-5.733 5.733zM15.952 13.466c-1.733 0-3.067 1.333-3.067 3.067s1.333 3.067 3.067 3.067c1.733 0 3.067-1.333 3.067-3.067s-1.333-3.067-3.067-3.067z" }));
5
- export const openEye = React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", viewBox: "0 0 32 32" },
6
- React.createElement("path", { d: "M29.983 8.366c-0.533-0.4-1.333-0.4-1.867 0.133 0 0.133-5.867 7.067-12.4 7.067s-12.267-7.067-12.267-7.067c-0.4-0.533-1.333-0.667-1.867-0.267-0.533 0.667-0.667 1.467-0.267 2 0.133 0.133 1.733 2.267 4.4 4.267l-2.933 3.067c-0.533 0.533-0.533 1.333 0 1.867 0.267 0.267 0.533 0.4 0.933 0.4s0.667-0.133 0.933-0.4l3.2-3.333c1.867 1.067 4 2 6.4 2.267l-0.4 4.133c-0.133 0.667 0.4 1.333 1.2 1.467h0.133c0.667 0 1.2-0.533 1.333-1.2l0.4-4.533c2.533-0.267 4.8-1.2 6.8-2.4l2.933 3.067c0.267 0.267 0.667 0.4 0.933 0.4s0.667-0.133 0.933-0.4c0.533-0.533 0.533-1.333 0-1.867l-2.667-2.8c2.533-2 4.133-4 4.267-4.133 0.533-0.4 0.4-1.2-0.133-1.733z" }));
1
+ import React from 'react';
2
+ export const eyeIcon = (React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M15.817 26.533c-8.133 0-14.267-8.8-14.533-9.2s-0.267-1.067 0-1.6c0.267-0.4 6.667-9.067 14.667-9.067 8.133 0 14.267 8.667 14.533 9.067s0.267 1.067 0 1.6c-0.267 0.4-6.667 9.2-14.667 9.2zM4.083 16.533c1.6 2 6.4 7.333 11.733 7.333 5.467 0 10.267-5.333 11.867-7.333-1.6-2-6.4-7.2-11.733-7.2-5.467 0-10.267 5.2-11.867 7.2z' }),
4
+ React.createElement("path", { d: 'M15.952 22.266c-3.2 0-5.733-2.533-5.733-5.733s2.533-5.733 5.733-5.733c3.2 0 5.733 2.533 5.733 5.733s-2.533 5.733-5.733 5.733zM15.952 13.466c-1.733 0-3.067 1.333-3.067 3.067s1.333 3.067 3.067 3.067c1.733 0 3.067-1.333 3.067-3.067s-1.333-3.067-3.067-3.067z' })));
5
+ export const openEye = (React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg' },
6
+ React.createElement("path", { d: 'M29.983 8.366c-0.533-0.4-1.333-0.4-1.867 0.133 0 0.133-5.867 7.067-12.4 7.067s-12.267-7.067-12.267-7.067c-0.4-0.533-1.333-0.667-1.867-0.267-0.533 0.667-0.667 1.467-0.267 2 0.133 0.133 1.733 2.267 4.4 4.267l-2.933 3.067c-0.533 0.533-0.533 1.333 0 1.867 0.267 0.267 0.533 0.4 0.933 0.4s0.667-0.133 0.933-0.4l3.2-3.333c1.867 1.067 4 2 6.4 2.267l-0.4 4.133c-0.133 0.667 0.4 1.333 1.2 1.467h0.133c0.667 0 1.2-0.533 1.333-1.2l0.4-4.533c2.533-0.267 4.8-1.2 6.8-2.4l2.933 3.067c0.267 0.267 0.667 0.4 0.933 0.4s0.667-0.133 0.933-0.4c0.533-0.533 0.533-1.333 0-1.867l-2.667-2.8c2.533-2 4.133-4 4.267-4.133 0.533-0.4 0.4-1.2-0.133-1.733z' })));
@@ -1,3 +1,6 @@
1
1
  export default Password;
2
- declare const Password: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
2
+ declare function Password(props: any): React.JSX.Element;
3
+ declare namespace Password {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -1,17 +1,17 @@
1
- import * as React from 'react';
1
+ import React, { useState, useEffect, forwardRef, isValidElement, cloneElement } from 'react';
2
2
  import { omit } from '@weareconceptstudio/core';
3
3
  import { eyeIcon, openEye } from './icons';
4
4
  import Input from '../Input';
5
- const defaultIconRender = (visible) => visible ? openEye : eyeIcon;
5
+ const defaultIconRender = (visible) => (visible ? openEye : eyeIcon);
6
6
  const actionMap = {
7
7
  click: 'onClick',
8
8
  hover: 'onMouseOver',
9
9
  };
10
- const Password = React.forwardRef((props, ref) => {
10
+ const Password = (props) => {
11
11
  const { disabled, action = 'click', visibilityToggle = true, iconRender = defaultIconRender } = props;
12
12
  const visibilityControlled = typeof visibilityToggle === 'object' && visibilityToggle.visible !== undefined;
13
- const [visible, setVisible] = React.useState(() => visibilityControlled ? visibilityToggle.visible : false);
14
- React.useEffect(() => {
13
+ const [visible, setVisible] = useState(() => (visibilityControlled ? visibilityToggle.visible : false));
14
+ useEffect(() => {
15
15
  if (visibilityControlled) {
16
16
  setVisible(visibilityToggle.visible);
17
17
  }
@@ -42,7 +42,7 @@ const Password = React.forwardRef((props, ref) => {
42
42
  e.preventDefault();
43
43
  },
44
44
  };
45
- return React.cloneElement(React.isValidElement(icon) ? icon : React.createElement("span", null, icon), iconProps);
45
+ return cloneElement(isValidElement(icon) ? icon : React.createElement("span", null, icon), iconProps);
46
46
  };
47
47
  const suffixIcon = visibilityToggle && getIcon();
48
48
  const { className, ...restProps } = props;
@@ -51,8 +51,8 @@ const Password = React.forwardRef((props, ref) => {
51
51
  type: visible ? 'text' : 'password',
52
52
  suffix: suffixIcon,
53
53
  };
54
- return (React.createElement(Input, { ref: ref, ...omittedProps }));
55
- });
54
+ return React.createElement(Input, { ...omittedProps });
55
+ };
56
56
  if (process.env.NODE_ENV !== 'production') {
57
57
  Password.displayName = 'InputPassword';
58
58
  }
@@ -1,3 +1,6 @@
1
1
  export default TextArea;
2
- declare const TextArea: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
2
+ declare function TextArea(props: any): React.JSX.Element;
3
+ declare namespace TextArea {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';
@@ -1,14 +1,13 @@
1
- import * as React from 'react';
2
- import styled from 'styled-components';
1
+ import React from 'react';
3
2
  import BaseInput from '../BaseInput';
4
- const StyledTextArea = styled.textarea `
5
- font-size: 14px;
6
- padding: 4px 11px;
7
- `;
8
- const TextArea = React.forwardRef((props, forwardRef) => {
3
+ import { useInput } from '../../form/hooks/useInput';
4
+ const TextArea = (props) => {
5
+ const { field } = useInput({
6
+ name: props.name,
7
+ });
9
8
  return (React.createElement(BaseInput, { ...props },
10
- React.createElement(StyledTextArea, { ...forwardRef, rows: 5 })));
11
- });
9
+ React.createElement("textarea", { ...field, rows: 5 })));
10
+ };
12
11
  if (process.env.NODE_ENV !== 'production') {
13
12
  TextArea.displayName = 'TextArea';
14
13
  }
@@ -1,2 +1,11 @@
1
- export default Input;
2
- import Input from "./Input";
1
+ import Input from './Input';
2
+ import TextArea from './TextArea';
3
+ import Password from './Password';
4
+ import Number from './Number';
5
+ type InputComponent = typeof Input & {
6
+ TextArea: typeof TextArea;
7
+ Password: typeof Password;
8
+ Number: typeof Number;
9
+ };
10
+ declare const EnhancedInput: InputComponent;
11
+ export default EnhancedInput;
@@ -2,7 +2,9 @@ import Input from './Input';
2
2
  import TextArea from './TextArea';
3
3
  import Password from './Password';
4
4
  import Number from './Number';
5
- Input.TextArea = TextArea;
6
- Input.Password = Password;
7
- Input.Number = Number;
8
- export default Input;
5
+ // Assign the sub-components to the Input component
6
+ const EnhancedInput = Input;
7
+ EnhancedInput.TextArea = TextArea;
8
+ EnhancedInput.Password = Password;
9
+ EnhancedInput.Number = Number;
10
+ export default EnhancedInput;
@@ -0,0 +1,7 @@
1
+ export default PhoneNumber;
2
+ declare function PhoneNumber({ name, className, autoComplete }: {
3
+ name: any;
4
+ className: any;
5
+ autoComplete?: string;
6
+ }): React.JSX.Element;
7
+ import React from 'react';
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import classNames from 'classnames';
3
+ import Input from 'react-phone-number-input/react-hook-form-input';
4
+ import useFormInstance from '../form/hooks/useFormInstance';
5
+ const PhoneNumber = ({ name, className, autoComplete = 'new-password' }) => {
6
+ const { control } = useFormInstance();
7
+ //! ClassName
8
+ const classString = classNames('phone-number-input', {
9
+ [className]: className,
10
+ });
11
+ return (React.createElement(Input, { name: name, country: 'AM', international: true, maxLength: 14, control: control, withCountryCallingCode: true, className: classString, autoComplete: autoComplete }));
12
+ };
13
+ export default PhoneNumber;
@@ -1,3 +1,3 @@
1
1
  export default Radio;
2
2
  declare const Radio: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
3
+ import React from 'react';
@@ -1,16 +1,29 @@
1
- import * as React from 'react';
2
- import RadioGroupContext, { RadioOptionTypeContext } from './context';
3
- import Checkbox from "../checkbox";
4
- const Radio = React.forwardRef(({ children, ...restProps }, forwardRef) => {
5
- const groupContext = React.useContext(RadioGroupContext);
1
+ import React, { forwardRef, useContext } from 'react';
2
+ import RadioGroupContext from './context';
3
+ import classNames from 'classnames';
4
+ import BaseCheckbox from '../checkbox/BaseCheckbox';
5
+ const Radio = forwardRef(({ prefixCls = 'radio', children, ...props }, forwardRef) => {
6
+ const groupContext = useContext(RadioGroupContext);
7
+ const onChange = (e) => {
8
+ props.onChange?.(e);
9
+ groupContext?.onChange?.(e);
10
+ };
6
11
  const radioProps = {
7
12
  ref: forwardRef,
8
- ...restProps
13
+ ...props,
9
14
  };
10
15
  if (groupContext) {
11
16
  radioProps.ref = groupContext.forwardRef;
17
+ radioProps.checked = props.value === groupContext.value;
18
+ radioProps.onChange = onChange;
12
19
  }
13
- return (React.createElement(Checkbox, { type: 'radio', ...radioProps }, children));
20
+ const wrapperClassString = classNames(`${prefixCls}-wrapper`, {
21
+ [`${prefixCls}-wrapper-checked`]: radioProps.checked,
22
+ [`${prefixCls}-wrapper-disabled`]: radioProps.disabled,
23
+ });
24
+ return (React.createElement("label", { className: wrapperClassString },
25
+ React.createElement(BaseCheckbox, { type: 'radio', prefixCls: prefixCls, ...radioProps }),
26
+ children !== undefined && React.createElement("span", { className: `${prefixCls}-content` }, children)));
14
27
  });
15
28
  if (process.env.NODE_ENV !== 'production') {
16
29
  Radio.displayName = 'Radio';
@@ -1,3 +1,3 @@
1
1
  export default RadioGroup;
2
2
  declare const RadioGroup: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
3
+ import React from 'react';
@@ -1,20 +1,40 @@
1
- import * as React from 'react';
1
+ import React, { forwardRef } from 'react';
2
+ import { useMergedState } from '@weareconceptstudio/core';
2
3
  import { RadioGroupContextProvider } from './context';
3
4
  import Radio from './BaseRadio';
4
- const RadioGroup = React.forwardRef((props, forwardRef) => {
5
+ const RadioGroup = forwardRef((props, forwardRef) => {
6
+ const [value, setValue] = useMergedState(props.defaultValue, {
7
+ value: props.value,
8
+ });
9
+ const onRadioChange = (ev) => {
10
+ const lastValue = value;
11
+ const val = ev.target.value;
12
+ if (!('value' in props)) {
13
+ setValue(val);
14
+ }
15
+ const { onChange } = props;
16
+ if (onChange && val !== lastValue) {
17
+ onChange(ev);
18
+ }
19
+ };
5
20
  const { children, options } = props;
6
21
  let childrenToRender = children;
7
22
  if (options && options.length > 0) {
8
- childrenToRender = options.map(option => {
23
+ childrenToRender = options.map((option) => {
9
24
  if (typeof option === 'string' || typeof option === 'number') {
10
25
  return (React.createElement(Radio, { key: option.toString(), value: option }, option));
11
26
  }
12
27
  return (React.createElement(Radio, { key: `radio-group-value-options-${option.value}`, value: option.value }, option.label));
13
28
  });
14
29
  }
15
- return (React.createElement("div", null,
30
+ return (React.createElement("div", { className: 'radio-group' },
16
31
  React.createElement(RadioGroupContextProvider, { value: {
32
+ onChange: onRadioChange,
17
33
  forwardRef: forwardRef,
34
+ value,
18
35
  } }, childrenToRender)));
19
36
  });
37
+ if (process.env.NODE_ENV !== 'production') {
38
+ RadioGroup.displayName = 'RadioGroup';
39
+ }
20
40
  export default RadioGroup;
@@ -2,5 +2,5 @@ export const RadioGroupContextProvider: React.Provider<any>;
2
2
  export default RadioGroupContext;
3
3
  export const RadioOptionTypeContext: React.Context<any>;
4
4
  export const RadioOptionTypeContextProvider: React.Provider<any>;
5
- import * as React from "react";
5
+ import React from 'react';
6
6
  declare const RadioGroupContext: React.Context<any>;
@@ -1,6 +1,6 @@
1
- import * as React from 'react';
2
- const RadioGroupContext = React.createContext(null);
1
+ import React, { createContext } from 'react';
2
+ const RadioGroupContext = createContext(null);
3
3
  export const RadioGroupContextProvider = RadioGroupContext.Provider;
4
4
  export default RadioGroupContext;
5
- export const RadioOptionTypeContext = React.createContext(null);
5
+ export const RadioOptionTypeContext = createContext(null);
6
6
  export const RadioOptionTypeContextProvider = RadioOptionTypeContext.Provider;
@@ -1,5 +1,5 @@
1
- import BaseRadio from "./BaseRadio";
2
- import RadioGroup from "./Group";
1
+ import BaseRadio from './BaseRadio';
2
+ import RadioGroup from './Group';
3
3
  const Radio = BaseRadio;
4
4
  Radio.Group = RadioGroup;
5
5
  export default Radio;
@@ -0,0 +1,3 @@
1
+ export const bottom_arrow: React.JSX.Element;
2
+ export const empty: React.JSX.Element;
3
+ import React from 'react';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export const bottom_arrow = (React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg' },
3
+ React.createElement("path", { d: 'M15.644 25.954c-0.533 0-1.067-0.178-1.422-0.711l-12.978-15.822c-0.711-0.711-0.533-1.778 0.178-2.489s1.956-0.533 2.489 0.178l11.733 14.222 12.267-14.222c0.711-0.711 1.778-0.889 2.489-0.178s0.889 1.778 0.178 2.489l-13.689 15.822c-0.178 0.356-0.711 0.711-1.244 0.711z' })));
4
+ export const empty = (React.createElement("svg", { version: '1.1', viewBox: '0 0 32 32', xmlns: 'http://www.w3.org/2000/svg' },
5
+ React.createElement("path", { d: 'M29.567 5.773v-1.153c0-0.008 0-0.017 0-0.027 0-1.603-1.298-2.903-2.9-2.907h-21.334c-1.587 0.019-2.867 1.31-2.867 2.9 0 0.012 0 0.024 0 0.035l-0-0.002v1.153c-1.414 0.303-2.459 1.538-2.467 3.019v18.414c0 0 0 0 0 0 0 1.713 1.387 3.103 3.1 3.107h25.794c1.716 0 3.107-1.391 3.107-3.107v0-18.413c-0.004-1.473-1.034-2.704-2.413-3.016l-0.021-0.004zM30.667 8.793v5.767h-1.1v-7.393c0.65 0.266 1.1 0.894 1.1 1.627v0zM5.333 3.020h21.333c0.855 0.019 1.54 0.716 1.54 1.573 0 0.010-0 0.019-0 0.028l0-0.001v9.94h-3.82c-0.998 0.001-1.848 0.64-2.162 1.531l-0.005 0.016-0.587 1.687c-0.127 0.388-0.484 0.663-0.906 0.667h-9.46c-0.422-0.003-0.78-0.279-0.905-0.66l-0.002-0.007-0.587-1.687c-0.322-0.908-1.173-1.547-2.173-1.547-0 0-0 0-0 0h-3.833v-9.94c-0-0.008-0-0.017-0-0.027 0-0.867 0.701-1.57 1.567-1.573h0zM2.467 7.167v7.393h-1.133v-5.767c0-0.733 0.45-1.361 1.088-1.622l0.012-0.004zM28.893 28.98h-25.793c-0.977-0.004-1.767-0.796-1.767-1.773 0 0 0 0 0 0v0-11.333h6.267c0.425 0 0.785 0.277 0.911 0.66l0.002 0.007 0.587 1.68c0.319 0.907 1.168 1.546 2.167 1.547h9.46c0.998-0.001 1.848-0.64 2.162-1.531l0.005-0.016 0.587-1.68c0.127-0.388 0.484-0.663 0.906-0.667h6.28v11.333c0 0.979-0.794 1.773-1.773 1.773v0z' }),
6
+ React.createElement("path", { d: 'M13.020 11.387c0.12 0.12 0.286 0.193 0.469 0.193 0.001 0 0.003 0 0.004 0h-0c0.182-0.001 0.347-0.074 0.467-0.193l-0 0 2.040-2.053 2.033 2c0.12 0.12 0.286 0.193 0.469 0.193 0.001 0 0.003 0 0.004 0h-0c0.182-0.001 0.347-0.074 0.467-0.193l-0 0c0.12-0.12 0.194-0.287 0.194-0.47s-0.074-0.35-0.194-0.47l0 0-2.033-2.040 2.033-2c0.143-0.123 0.233-0.304 0.233-0.506 0-0.368-0.298-0.667-0.667-0.667-0.202 0-0.383 0.090-0.506 0.232l-0.001 0.001-2.033 2.053-2.040-2c-0.123-0.143-0.304-0.233-0.506-0.233-0.368 0-0.667 0.298-0.667 0.667 0 0.202 0.090 0.383 0.232 0.506l0.001 0.001 2 2-2 2.040c-0.12 0.12-0.194 0.287-0.194 0.47s0.074 0.35 0.194 0.47l-0-0z' })));
@@ -1,3 +1,6 @@
1
1
  export default Select;
2
- declare const Select: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
3
- import * as React from "react";
2
+ declare function Select(props: any): React.JSX.Element;
3
+ declare namespace Select {
4
+ let displayName: string;
5
+ }
6
+ import React from 'react';