@weareconceptstudio/form 0.0.0 → 0.0.2
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/checkbox/index.d.ts +1 -1
- package/dist/checkbox/index.js +2 -2
- package/dist/color-picker/index.d.ts +1 -1
- package/dist/date-picker/index.d.ts +1 -1
- package/dist/form/BaseForm.d.ts +2 -4
- package/dist/form/BaseForm.js +3 -5
- package/dist/form/Item/index.d.ts +2 -2
- package/dist/form/Item/index.js +1 -3
- package/dist/form/index.d.ts +1 -3
- package/dist/input/BaseInput/index.d.ts +1 -1
- package/dist/input/Input.d.ts +1 -1
- package/dist/input/Input.js +2 -2
- package/dist/input/Number/index.d.ts +1 -1
- package/dist/input/Password/icons.js +5 -5
- package/dist/input/Password/index.d.ts +1 -1
- package/dist/input/Password/index.js +1 -1
- package/dist/input/TextArea/index.d.ts +1 -1
- package/dist/input/index.d.ts +1 -1
- package/dist/radio/BaseRadio.d.ts +1 -1
- package/dist/radio/BaseRadio.js +2 -3
- package/dist/radio/Group.d.ts +1 -1
- package/dist/radio/context.d.ts +1 -1
- package/dist/select/index.d.ts +1 -1
- package/dist/select/index.js +5 -3
- package/dist/upload/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/config-provider/cssVariables.d.ts +0 -2
- package/dist/config-provider/cssVariables.js +0 -25
- package/dist/config-provider/index.d.ts +0 -12
- package/dist/config-provider/index.js +0 -20
package/dist/checkbox/index.d.ts
CHANGED
package/dist/checkbox/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
const Checkbox = React.forwardRef(({ type = 'checkbox', children }, forwardRef) => {
|
|
2
|
+
const Checkbox = React.forwardRef(({ type = 'checkbox', children, ...restProps }, forwardRef) => {
|
|
3
3
|
return (React.createElement("label", null,
|
|
4
|
-
React.createElement("input", { type: type, ...forwardRef }),
|
|
4
|
+
React.createElement("input", { type: type, ...forwardRef, ...restProps }),
|
|
5
5
|
children !== undefined && React.createElement("span", null, children)));
|
|
6
6
|
});
|
|
7
7
|
if (process.env.NODE_ENV !== 'production') {
|
package/dist/form/BaseForm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default BaseForm;
|
|
2
|
-
declare function BaseForm({ initialValues: defaultValues, values, children, onSubmit, layout, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister,
|
|
2
|
+
declare function BaseForm({ initialValues: defaultValues, values, children, onSubmit, layout, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, }: {
|
|
3
3
|
initialValues: any;
|
|
4
4
|
values: any;
|
|
5
5
|
children: any;
|
|
@@ -14,7 +14,5 @@ declare function BaseForm({ initialValues: defaultValues, values, children, onSu
|
|
|
14
14
|
delayError: any;
|
|
15
15
|
shouldUseNativeValidation: any;
|
|
16
16
|
shouldUnregister: any;
|
|
17
|
-
globalPrefixCls: any;
|
|
18
|
-
theme: any;
|
|
19
17
|
}): React.JSX.Element;
|
|
20
|
-
import * as React from
|
|
18
|
+
import * as React from "react";
|
package/dist/form/BaseForm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FormProvider, useForm } from "react-hook-form";
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import ConfigProvider from '../config-provider';
|
|
5
4
|
// initialValues: object || async () => fetch('/api-endpoint')
|
|
6
5
|
// values: object
|
|
7
6
|
// children: React elements
|
|
@@ -47,7 +46,7 @@ const StyledForm = styled.form `
|
|
|
47
46
|
margin-bottom: 24px;
|
|
48
47
|
}
|
|
49
48
|
`;
|
|
50
|
-
const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit, layout = 'vertical', mode = 'onChange', reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister,
|
|
49
|
+
const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit, layout = 'vertical', mode = 'onChange', reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, }) => {
|
|
51
50
|
const methods = useForm({
|
|
52
51
|
defaultValues,
|
|
53
52
|
values,
|
|
@@ -61,8 +60,7 @@ const BaseForm = ({ initialValues: defaultValues, values, children, onSubmit, la
|
|
|
61
60
|
shouldUseNativeValidation,
|
|
62
61
|
shouldUnregister,
|
|
63
62
|
});
|
|
64
|
-
return (React.createElement(
|
|
65
|
-
React.createElement(
|
|
66
|
-
React.createElement(StyledForm, { onSubmit: methods.handleSubmit(onSubmit), className: layout }, children))));
|
|
63
|
+
return (React.createElement(FormProvider, { ...methods },
|
|
64
|
+
React.createElement(StyledForm, { onSubmit: methods.handleSubmit(onSubmit), className: layout }, children)));
|
|
67
65
|
};
|
|
68
66
|
export default BaseForm;
|
package/dist/form/Item/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useFormContext } from "react-hook-form";
|
|
|
4
4
|
//* Components
|
|
5
5
|
import ErrorMessage from '../../error-message';
|
|
6
6
|
const FormItem = ({ label, name, children, rules = {} }) => {
|
|
7
|
-
const { register, getValues
|
|
7
|
+
const { register, getValues } = useFormContext();
|
|
8
8
|
const innerRef = register(name, rules);
|
|
9
9
|
return (React.createElement("div", { className: "form-item" },
|
|
10
10
|
React.createElement("div", { className: "form-item-row" },
|
|
@@ -12,8 +12,6 @@ const FormItem = ({ label, name, children, rules = {} }) => {
|
|
|
12
12
|
React.createElement("label", { htmlFor: name }, label)),
|
|
13
13
|
React.createElement("div", { className: 'form-item-control' }, React.cloneElement(children, {
|
|
14
14
|
ref: innerRef,
|
|
15
|
-
getValues,
|
|
16
|
-
setValue,
|
|
17
15
|
name,
|
|
18
16
|
value: getValues()[name]
|
|
19
17
|
})),
|
package/dist/form/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default Form;
|
|
2
|
-
declare const Form: ({ initialValues: defaultValues, values, children, onSubmit, layout, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister,
|
|
2
|
+
declare const Form: ({ initialValues: defaultValues, values, children, onSubmit, layout, mode, reValidateMode, errors, resetOptions, criteriaMode, shouldFocusError, delayError, shouldUseNativeValidation, shouldUnregister, }: {
|
|
3
3
|
initialValues: any;
|
|
4
4
|
values: any;
|
|
5
5
|
children: any;
|
|
@@ -14,6 +14,4 @@ declare const Form: ({ initialValues: defaultValues, values, children, onSubmit,
|
|
|
14
14
|
delayError: any;
|
|
15
15
|
shouldUseNativeValidation: any;
|
|
16
16
|
shouldUnregister: any;
|
|
17
|
-
globalPrefixCls: any;
|
|
18
|
-
theme: any;
|
|
19
17
|
}) => import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export const InputContainer: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>;
|
|
2
2
|
export default BaseInput;
|
|
3
|
-
import * as React from
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
declare const BaseInput: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
package/dist/input/Input.d.ts
CHANGED
package/dist/input/Input.js
CHANGED
|
@@ -11,8 +11,8 @@ const StyledInput = styled.input `
|
|
|
11
11
|
outline: none;
|
|
12
12
|
`;
|
|
13
13
|
const Input = React.forwardRef((props, forwardRef) => {
|
|
14
|
-
const { autoComplete, onChange, onFocus, onBlur, onPressEnter, onKeyDown, onKeyUp, disabled, className, type = 'text', value, } = props;
|
|
14
|
+
const { autoComplete, onChange, onFocus, onBlur, onPressEnter, onKeyDown, onKeyUp, disabled, className, type = 'text', placeholder, value, } = props;
|
|
15
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, ...forwardRef })));
|
|
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
17
|
});
|
|
18
18
|
export default Input;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export const eyeIcon = React.createElement("svg", {
|
|
3
|
-
React.createElement("path", { d: "
|
|
4
|
-
React.createElement("path", { d: "
|
|
5
|
-
export const openEye = React.createElement("svg", {
|
|
6
|
-
React.createElement("path", { d: "
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { omit } from '@weareconceptstudio/
|
|
2
|
+
import { omit } from '@weareconceptstudio/core';
|
|
3
3
|
import { eyeIcon, openEye } from './icons';
|
|
4
4
|
import Input from '../Input';
|
|
5
5
|
const defaultIconRender = (visible) => visible ? openEye : eyeIcon;
|
package/dist/input/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export default Input;
|
|
2
|
-
import Input from
|
|
2
|
+
import Input from "./Input";
|
package/dist/radio/BaseRadio.js
CHANGED
|
@@ -5,13 +5,12 @@ const Radio = React.forwardRef(({ children, ...restProps }, forwardRef) => {
|
|
|
5
5
|
const groupContext = React.useContext(RadioGroupContext);
|
|
6
6
|
const radioProps = {
|
|
7
7
|
ref: forwardRef,
|
|
8
|
+
...restProps
|
|
8
9
|
};
|
|
9
10
|
if (groupContext) {
|
|
10
11
|
radioProps.ref = groupContext.forwardRef;
|
|
11
12
|
}
|
|
12
|
-
return (React.createElement(
|
|
13
|
-
React.createElement(Checkbox, { type: 'radio', ...radioProps }),
|
|
14
|
-
children !== undefined ? React.createElement("span", null, children) : null));
|
|
13
|
+
return (React.createElement(Checkbox, { type: 'radio', ...radioProps }, children));
|
|
15
14
|
});
|
|
16
15
|
if (process.env.NODE_ENV !== 'production') {
|
|
17
16
|
Radio.displayName = 'Radio';
|
package/dist/radio/Group.d.ts
CHANGED
package/dist/radio/context.d.ts
CHANGED
|
@@ -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
|
|
5
|
+
import * as React from "react";
|
|
6
6
|
declare const RadioGroupContext: React.Context<any>;
|
package/dist/select/index.d.ts
CHANGED
package/dist/select/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import ReactSelect from 'react-select';
|
|
3
|
+
import useFormInstance from '../form/hooks/useFormInstance';
|
|
3
4
|
const Select = React.forwardRef((props, forwardRef) => {
|
|
4
|
-
const { name,
|
|
5
|
-
const
|
|
5
|
+
const { name, multiple = false, allowClear = false, allowSearch = true, disabled = false, loading = false, options = [], } = props;
|
|
6
|
+
const formInstance = useFormInstance();
|
|
7
|
+
const [val, setVal] = React.useState(formInstance.getValues()[name] || (multiple ? [] : ''));
|
|
6
8
|
const handleChange = React.useCallback((newVal) => {
|
|
7
9
|
let vals;
|
|
8
10
|
if (multiple) {
|
|
@@ -11,7 +13,7 @@ const Select = React.forwardRef((props, forwardRef) => {
|
|
|
11
13
|
else {
|
|
12
14
|
vals = newVal.value;
|
|
13
15
|
}
|
|
14
|
-
setValue(name, vals);
|
|
16
|
+
formInstance.setValue(name, vals);
|
|
15
17
|
setVal(vals);
|
|
16
18
|
}, [name, multiple]);
|
|
17
19
|
return (React.createElement("div", null,
|
package/dist/upload/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weareconceptstudio/form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Concept Studio Form",
|
|
5
5
|
"author": "Concept Studio",
|
|
6
6
|
"license": "ISC",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"watch": "tsc -m es6 --watch"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@weareconceptstudio/
|
|
22
|
+
"@weareconceptstudio/core": "*",
|
|
23
23
|
"classnames": "2.5.1",
|
|
24
24
|
"react": "^18.3.1",
|
|
25
25
|
"react-dom": "^18.3.1",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { warning, canUseDom, updateCSS } from '@weareconceptstudio/utils';
|
|
2
|
-
export function getStyle(globalPrefixCls = 'cs-form', theme) {
|
|
3
|
-
const variables = {};
|
|
4
|
-
const fillColor = (colorVal, type) => {
|
|
5
|
-
variables[`${type}-color`] = colorVal;
|
|
6
|
-
};
|
|
7
|
-
if (theme.primaryColor) {
|
|
8
|
-
fillColor(theme.primaryColor, 'primary');
|
|
9
|
-
}
|
|
10
|
-
const cssList = Object.keys(variables).map((key) => `--${globalPrefixCls}-${key}: ${variables[key]};`);
|
|
11
|
-
return `
|
|
12
|
-
:root {
|
|
13
|
-
${cssList.join('\n')}
|
|
14
|
-
}
|
|
15
|
-
`.trim();
|
|
16
|
-
}
|
|
17
|
-
export function registerTheme(globalPrefixCls, theme) {
|
|
18
|
-
const style = getStyle(globalPrefixCls, theme);
|
|
19
|
-
if (canUseDom()) {
|
|
20
|
-
updateCSS(style, 'dynamic-theme');
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
warning(false, 'SSR do not support dynamic theme with css variables.');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export declare const ConfigContext: React.Context<{}>;
|
|
3
|
-
interface ConfigProviderProps {
|
|
4
|
-
globalPrefixCls?: string;
|
|
5
|
-
theme?: object;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
declare const ConfigProvider: {
|
|
9
|
-
(props: ConfigProviderProps): React.JSX.Element;
|
|
10
|
-
displayName: string;
|
|
11
|
-
};
|
|
12
|
-
export default ConfigProvider;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { registerTheme } from './cssVariables';
|
|
3
|
-
export const ConfigContext = React.createContext({});
|
|
4
|
-
const ProviderChildren = (props) => {
|
|
5
|
-
const { globalPrefixCls = 'cs-form', theme, children } = props;
|
|
6
|
-
if (theme) {
|
|
7
|
-
registerTheme(globalPrefixCls, theme);
|
|
8
|
-
}
|
|
9
|
-
return (React.createElement(ConfigContext.Provider, { value: {
|
|
10
|
-
globalPrefixCls,
|
|
11
|
-
theme
|
|
12
|
-
} }, children));
|
|
13
|
-
};
|
|
14
|
-
const ConfigProvider = (props) => {
|
|
15
|
-
return React.createElement(ProviderChildren, { ...props });
|
|
16
|
-
};
|
|
17
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
18
|
-
ConfigProvider.displayName = 'ConfigProvider';
|
|
19
|
-
}
|
|
20
|
-
export default ConfigProvider;
|