@chem-po/react-native 0.0.14 → 0.0.16
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/lib/commonjs/components/form/Field.js +4 -2
- package/lib/commonjs/components/form/Field.js.map +1 -1
- package/lib/commonjs/components/form/Form.js +20 -7
- package/lib/commonjs/components/form/Form.js.map +1 -1
- package/lib/commonjs/components/form/input/Editable.js +24 -7
- package/lib/commonjs/components/form/input/Editable.js.map +1 -1
- package/lib/commonjs/components/form/input/common/InputClearButton.js +10 -5
- package/lib/commonjs/components/form/input/common/InputClearButton.js.map +1 -1
- package/lib/commonjs/components/form/input/date/index.js +23 -15
- package/lib/commonjs/components/form/input/date/index.js.map +1 -1
- package/lib/commonjs/components/form/input/datetime/index.js +22 -18
- package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
- package/lib/commonjs/components/form/input/hooks/index.js +4 -4
- package/lib/commonjs/components/form/input/hooks/index.js.map +1 -1
- package/lib/commonjs/components/form/input/hooks/useInputStyles.js +111 -0
- package/lib/commonjs/components/form/input/hooks/useInputStyles.js.map +1 -0
- package/lib/commonjs/components/form/input/input.js +49 -11
- package/lib/commonjs/components/form/input/input.js.map +1 -1
- package/lib/commonjs/components/form/input/multipleSelect/index.js +162 -44
- package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/commonjs/components/form/input/number/index.js +10 -5
- package/lib/commonjs/components/form/input/number/index.js.map +1 -1
- package/lib/commonjs/components/form/input/select/index.js +84 -173
- package/lib/commonjs/components/form/input/select/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/index.js +7 -5
- package/lib/commonjs/components/form/input/text/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/textarea.js +10 -5
- package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
- package/lib/commonjs/components/form/input/time/index.js +22 -13
- package/lib/commonjs/components/form/input/time/index.js.map +1 -1
- package/lib/commonjs/components/form/view/file.js +18 -4
- package/lib/commonjs/components/form/view/file.js.map +1 -1
- package/lib/commonjs/components/form/view/index.js +24 -23
- package/lib/commonjs/components/form/view/index.js.map +1 -1
- package/lib/commonjs/components/form/view/multipleSelect.js +38 -10
- package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
- package/lib/commonjs/components/form/view/select.js +24 -9
- package/lib/commonjs/components/form/view/select.js.map +1 -1
- package/lib/commonjs/components/form/view/styles.js +21 -0
- package/lib/commonjs/components/form/view/styles.js.map +1 -0
- package/lib/commonjs/contexts/root.js +6 -0
- package/lib/commonjs/contexts/root.js.map +1 -1
- package/lib/module/components/form/Field.js +4 -2
- package/lib/module/components/form/Field.js.map +1 -1
- package/lib/module/components/form/Form.js +20 -7
- package/lib/module/components/form/Form.js.map +1 -1
- package/lib/module/components/form/input/Editable.js +24 -7
- package/lib/module/components/form/input/Editable.js.map +1 -1
- package/lib/module/components/form/input/common/InputClearButton.js +11 -6
- package/lib/module/components/form/input/common/InputClearButton.js.map +1 -1
- package/lib/module/components/form/input/date/index.js +23 -15
- package/lib/module/components/form/input/date/index.js.map +1 -1
- package/lib/module/components/form/input/datetime/index.js +22 -18
- package/lib/module/components/form/input/datetime/index.js.map +1 -1
- package/lib/module/components/form/input/hooks/index.js +1 -1
- package/lib/module/components/form/input/hooks/index.js.map +1 -1
- package/lib/module/components/form/input/hooks/useInputStyles.js +104 -0
- package/lib/module/components/form/input/hooks/useInputStyles.js.map +1 -0
- package/lib/module/components/form/input/input.js +51 -13
- package/lib/module/components/form/input/input.js.map +1 -1
- package/lib/module/components/form/input/multipleSelect/index.js +163 -46
- package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/module/components/form/input/number/index.js +10 -5
- package/lib/module/components/form/input/number/index.js.map +1 -1
- package/lib/module/components/form/input/select/index.js +86 -175
- package/lib/module/components/form/input/select/index.js.map +1 -1
- package/lib/module/components/form/input/text/index.js +7 -5
- package/lib/module/components/form/input/text/index.js.map +1 -1
- package/lib/module/components/form/input/text/textarea.js +11 -6
- package/lib/module/components/form/input/text/textarea.js.map +1 -1
- package/lib/module/components/form/input/time/index.js +22 -13
- package/lib/module/components/form/input/time/index.js.map +1 -1
- package/lib/module/components/form/view/file.js +18 -4
- package/lib/module/components/form/view/file.js.map +1 -1
- package/lib/module/components/form/view/index.js +25 -24
- package/lib/module/components/form/view/index.js.map +1 -1
- package/lib/module/components/form/view/multipleSelect.js +38 -10
- package/lib/module/components/form/view/multipleSelect.js.map +1 -1
- package/lib/module/components/form/view/select.js +23 -9
- package/lib/module/components/form/view/select.js.map +1 -1
- package/lib/module/components/form/view/styles.js +15 -0
- package/lib/module/components/form/view/styles.js.map +1 -0
- package/lib/module/contexts/root.js +6 -0
- package/lib/module/contexts/root.js.map +1 -1
- package/lib/typescript/components/form/Field.d.ts +2 -1
- package/lib/typescript/components/form/Field.d.ts.map +1 -1
- package/lib/typescript/components/form/Form.d.ts +7 -4
- package/lib/typescript/components/form/Form.d.ts.map +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
- package/lib/typescript/components/form/input/common/InputClearButton.d.ts +4 -2
- package/lib/typescript/components/form/input/common/InputClearButton.d.ts.map +1 -1
- package/lib/typescript/components/form/input/date/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/hooks/index.d.ts +1 -1
- package/lib/typescript/components/form/input/hooks/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts +61 -0
- package/lib/typescript/components/form/input/hooks/useInputStyles.d.ts.map +1 -0
- package/lib/typescript/components/form/input/input.d.ts.map +1 -1
- package/lib/typescript/components/form/input/multipleSelect/index.d.ts +6 -1
- package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/number/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/select/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
- package/lib/typescript/components/form/input/time/index.d.ts.map +1 -1
- package/lib/typescript/components/form/view/file.d.ts +3 -1
- package/lib/typescript/components/form/view/file.d.ts.map +1 -1
- package/lib/typescript/components/form/view/index.d.ts +3 -1
- package/lib/typescript/components/form/view/index.d.ts.map +1 -1
- package/lib/typescript/components/form/view/multipleSelect.d.ts +5 -3
- package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
- package/lib/typescript/components/form/view/select.d.ts +4 -1
- package/lib/typescript/components/form/view/select.d.ts.map +1 -1
- package/lib/typescript/components/form/view/styles.d.ts +14 -0
- package/lib/typescript/components/form/view/styles.d.ts.map +1 -0
- package/lib/typescript/contexts/root.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/components/form/Field.tsx +3 -2
- package/src/components/form/Form.tsx +41 -11
- package/src/components/form/input/Editable.tsx +23 -6
- package/src/components/form/input/common/InputClearButton.tsx +12 -4
- package/src/components/form/input/date/index.tsx +23 -12
- package/src/components/form/input/datetime/index.tsx +27 -14
- package/src/components/form/input/hooks/index.ts +1 -1
- package/src/components/form/input/hooks/useInputStyles.ts +124 -0
- package/src/components/form/input/input.tsx +57 -25
- package/src/components/form/input/multipleSelect/index.tsx +189 -60
- package/src/components/form/input/number/index.tsx +5 -4
- package/src/components/form/input/select/index.tsx +88 -166
- package/src/components/form/input/text/index.tsx +4 -9
- package/src/components/form/input/text/textarea.tsx +18 -16
- package/src/components/form/input/time/index.tsx +31 -11
- package/src/components/form/view/file.tsx +19 -4
- package/src/components/form/view/index.tsx +36 -22
- package/src/components/form/view/multipleSelect.tsx +42 -15
- package/src/components/form/view/select.tsx +28 -11
- package/src/components/form/view/styles.ts +15 -0
- package/src/contexts/root.tsx +7 -0
- package/lib/commonjs/components/form/input/hooks/useInputStyle.js +0 -50
- package/lib/commonjs/components/form/input/hooks/useInputStyle.js.map +0 -1
- package/lib/commonjs/components/form/input/styles.js +0 -17
- package/lib/commonjs/components/form/input/styles.js.map +0 -1
- package/lib/module/components/form/input/hooks/useInputStyle.js +0 -43
- package/lib/module/components/form/input/hooks/useInputStyle.js.map +0 -1
- package/lib/module/components/form/input/styles.js +0 -11
- package/lib/module/components/form/input/styles.js.map +0 -1
- package/lib/typescript/components/form/input/hooks/useInputStyle.d.ts +0 -9
- package/lib/typescript/components/form/input/hooks/useInputStyle.d.ts.map +0 -1
- package/lib/typescript/components/form/input/styles.d.ts +0 -10
- package/lib/typescript/components/form/input/styles.d.ts.map +0 -1
- package/src/components/form/input/hooks/useInputStyle.ts +0 -40
- package/src/components/form/input/styles.ts +0 -11
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { InputSize } from '@chem-po/core';
|
|
1
2
|
import { FileField } from '@chem-po/react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { ViewStyle } from 'react-native';
|
|
4
|
-
export declare const FileFieldView: ({ field, value, noLabel, style, }: {
|
|
5
|
+
export declare const FileFieldView: ({ field, value, noLabel, style, size: sizeProp, }: {
|
|
5
6
|
field: FileField;
|
|
6
7
|
value: any;
|
|
7
8
|
noLabel?: boolean;
|
|
8
9
|
style?: ViewStyle;
|
|
10
|
+
size?: InputSize;
|
|
9
11
|
}) => React.JSX.Element;
|
|
10
12
|
//# sourceMappingURL=file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/file.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/file.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,SAAS,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AAoChE,eAAO,MAAM,aAAa,GAAI,mDAM3B;IACD,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,sBAsBA,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { InputSize } from '@chem-po/core';
|
|
1
2
|
import { Field } from '@chem-po/react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { ViewStyle } from 'react-native';
|
|
4
|
-
export declare const FieldView: ({ field, value, noLabel, style, }: {
|
|
5
|
+
export declare const FieldView: ({ field, value, noLabel, style, size, }: {
|
|
5
6
|
field: Field;
|
|
6
7
|
value: any;
|
|
7
8
|
noLabel?: boolean;
|
|
8
9
|
style?: ViewStyle;
|
|
10
|
+
size?: InputSize;
|
|
9
11
|
}) => React.JSX.Element;
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,SAAS,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,KAAK,EAAe,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAA;AAmD1D,eAAO,MAAM,SAAS,GAAI,yCAMvB;IACD,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,sBAyBA,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { InputSize } from '@chem-po/core';
|
|
1
2
|
import { MultipleSelectField } from '@chem-po/react';
|
|
2
3
|
import { ViewStyle } from 'react-native';
|
|
3
|
-
export declare const MultipleSelectFieldView: ({ field, value, noLabel, style, }: {
|
|
4
|
-
field:
|
|
5
|
-
value
|
|
4
|
+
export declare const MultipleSelectFieldView: <F extends MultipleSelectField>({ field, value, noLabel, size: sizeProp, style, }: {
|
|
5
|
+
field: F;
|
|
6
|
+
value?: F["defaultValue"];
|
|
6
7
|
noLabel?: boolean;
|
|
8
|
+
size?: InputSize;
|
|
7
9
|
style?: ViewStyle;
|
|
8
10
|
}) => any;
|
|
9
11
|
//# sourceMappingURL=multipleSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipleSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/multipleSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"multipleSelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/multipleSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAgB,MAAM,gBAAgB,CAAA;AAElE,OAAc,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AA+BvE,eAAO,MAAM,uBAAuB,GAAI,CAAC,SAAS,mBAAmB,EAAE,mDAMpE;IACD,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,QAkCA,CAAA"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { BaseSelectOption, InputSize, RenderSelectOptionProps } from '@chem-po/core';
|
|
1
2
|
import { SelectField } from '@chem-po/react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { ViewStyle } from 'react-native';
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const DefaultRenderOption: <Value = string, Option extends BaseSelectOption<Value> = BaseSelectOption<Value>>({ option, }: RenderSelectOptionProps<Value, Option>) => React.JSX.Element;
|
|
6
|
+
export declare const SelectFieldView: ({ field, value, noLabel, style, size: sizeProp, }: {
|
|
5
7
|
field: SelectField;
|
|
6
8
|
value: any;
|
|
7
9
|
noLabel?: boolean;
|
|
8
10
|
style?: ViewStyle;
|
|
11
|
+
size?: InputSize;
|
|
9
12
|
}) => React.JSX.Element;
|
|
10
13
|
//# sourceMappingURL=select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/select.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACpF,OAAO,EAAE,WAAW,EAAqC,MAAM,gBAAgB,CAAA;AAC/E,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAA0B,SAAS,EAAE,MAAM,cAAc,CAAA;AAgBhE,eAAO,MAAM,mBAAmB,GAC9B,KAAK,GAAG,MAAM,EACd,MAAM,SAAS,gBAAgB,CAAC,KAAK,CAAC,GAAG,gBAAgB,CAAC,KAAK,CAAC,EAChE,aAEC,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,sBAExC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,mDAM7B;IACD,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;IACV,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,sBAyBA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/form/view/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;CAY1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/contexts/root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/contexts/root.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,WAAW,EAAkB,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAW,MAAM,OAAO,CAAA;AAUzD,MAAM,WAAW,yBACf,SAAQ,iBAAiB,CACvB,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE,gBAAgB,GAAG,QAAQ,CAAC,CACxE;IACD,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,gBAAgB,CAAC,EAAE,SAAS,CAAA;CAC7B;AACD,eAAO,MAAM,oBAAoB,GAAI,kDAIlC,yBAAyB,sBAgB3B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chem-po/react-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"types": "lib/typescript/index.d.ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -41,20 +41,21 @@
|
|
|
41
41
|
"react": "19.0.0",
|
|
42
42
|
"react-hook-form": "^7.55.0",
|
|
43
43
|
"react-native": "0.79.2",
|
|
44
|
+
"react-native-element-dropdown": "^2.12.4",
|
|
44
45
|
"react-native-gesture-handler": "~2.24.0",
|
|
45
46
|
"react-native-notifier": "^2.0.0",
|
|
46
47
|
"react-native-paper": "^5.14.3",
|
|
47
48
|
"react-native-paper-dates": "^0.22.42",
|
|
48
49
|
"react-native-svg": "15.11.2",
|
|
49
50
|
"zustand": "^4.3.3",
|
|
50
|
-
"@chem-po/core": "0.0.
|
|
51
|
-
"@chem-po/react": "0.0.
|
|
51
|
+
"@chem-po/core": "0.0.16",
|
|
52
|
+
"@chem-po/react": "0.0.16"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@babel/core": "^7.26.0",
|
|
55
56
|
"@babel/preset-env": "^7.25.4",
|
|
56
57
|
"@expo/metro-runtime": "~5.0.4",
|
|
57
|
-
"@types/react": "~19.0.
|
|
58
|
+
"@types/react": "~19.0.12",
|
|
58
59
|
"babel-plugin-react-docgen-typescript": "^1.5.1",
|
|
59
60
|
"babel-plugin-react-native-web": "^0.19.10",
|
|
60
61
|
"expo-build-properties": "~0.14.6",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { InputRef, getFieldValidate } from '@chem-po/core'
|
|
1
|
+
import { InputRef, InputSize, getFieldValidate } from '@chem-po/core'
|
|
2
2
|
import { Field, useField } from '@chem-po/react'
|
|
3
3
|
import React, { ForwardedRef, forwardRef, useMemo } from 'react'
|
|
4
4
|
import { ChangeHandler, Controller } from 'react-hook-form'
|
|
5
5
|
import { Input } from './input/input'
|
|
6
6
|
|
|
7
7
|
const FieldComponentBase = (
|
|
8
|
-
{ field, name }: { field: Field; name: string },
|
|
8
|
+
{ field, name, size: formSize }: { field: Field; name: string; size?: InputSize },
|
|
9
9
|
ref: ForwardedRef<InputRef>,
|
|
10
10
|
) => {
|
|
11
11
|
const { control, getOnChange, meta, onFocus, onBlur: fieldBlur } = useField(name, field)
|
|
@@ -31,6 +31,7 @@ const FieldComponentBase = (
|
|
|
31
31
|
onChange: getOnChange(inputProps.onChange as ChangeHandler),
|
|
32
32
|
}}
|
|
33
33
|
meta={meta}
|
|
34
|
+
formSize={formSize}
|
|
34
35
|
/>
|
|
35
36
|
)
|
|
36
37
|
}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isField, isListField } from '@chem-po/core'
|
|
1
|
+
import { InputSize, isField, isListField } from '@chem-po/core'
|
|
2
2
|
import {
|
|
3
3
|
ChempoFormProvider,
|
|
4
4
|
DataViewProps,
|
|
@@ -110,7 +110,11 @@ const styles = StyleSheet.create({
|
|
|
110
110
|
},
|
|
111
111
|
})
|
|
112
112
|
|
|
113
|
-
export const ListFieldInput: FC<{
|
|
113
|
+
export const ListFieldInput: FC<{
|
|
114
|
+
field: ListField
|
|
115
|
+
name: string
|
|
116
|
+
size: InputSize
|
|
117
|
+
}> = ({ field, name, size }) => {
|
|
114
118
|
const emptyData = useMemo(() => {
|
|
115
119
|
if (isField(field.itemField)) return ''
|
|
116
120
|
if (isListField(field.itemField)) return []
|
|
@@ -133,7 +137,7 @@ export const ListFieldInput: FC<{ field: ListField; name: string }> = ({ field,
|
|
|
133
137
|
<View key={formField.id} style={styles.listItem}>
|
|
134
138
|
<View style={styles.listItemContent}>
|
|
135
139
|
<View style={styles.listItemInput}>
|
|
136
|
-
<FormElement name={formField.id} field={field.itemField} />
|
|
140
|
+
<FormElement size={size} name={formField.id} field={field.itemField} />
|
|
137
141
|
</View>
|
|
138
142
|
<DeleteButton
|
|
139
143
|
onDelete={() => remove(idx)}
|
|
@@ -155,7 +159,15 @@ export const ListFieldInput: FC<{ field: ListField; name: string }> = ({ field,
|
|
|
155
159
|
)
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
export const FormElement = ({
|
|
162
|
+
export const FormElement = ({
|
|
163
|
+
field,
|
|
164
|
+
name,
|
|
165
|
+
size,
|
|
166
|
+
}: {
|
|
167
|
+
field: IFormElement
|
|
168
|
+
name: string
|
|
169
|
+
size: InputSize
|
|
170
|
+
}) => {
|
|
159
171
|
const fields = useMemo<Array<{ name: string; field: IFormElement }>>(() => {
|
|
160
172
|
if (isField(field) || isListField(field)) return [{ name: 'value', field }]
|
|
161
173
|
|
|
@@ -169,7 +181,7 @@ export const FormElement = ({ field, name }: { field: IFormElement; name: string
|
|
|
169
181
|
<View style={styles.formElementContainer}>
|
|
170
182
|
{fields.map(f => {
|
|
171
183
|
if (isListField(f.field)) {
|
|
172
|
-
const b = <ListFieldInput key={f.name} name={f.name} field={f.field} />
|
|
184
|
+
const b = <ListFieldInput key={f.name} name={f.name} field={f.field} size={size} />
|
|
173
185
|
return f.field.condition ? (
|
|
174
186
|
<Condition path={name} condition={f.field.condition} key={f.name}>
|
|
175
187
|
{b}
|
|
@@ -179,7 +191,7 @@ export const FormElement = ({ field, name }: { field: IFormElement; name: string
|
|
|
179
191
|
)
|
|
180
192
|
}
|
|
181
193
|
if (isField(f.field)) {
|
|
182
|
-
const b = <FieldComponent key={f.name} name={f.name} field={f.field} />
|
|
194
|
+
const b = <FieldComponent key={f.name} name={f.name} field={f.field} size={size} />
|
|
183
195
|
return f.field.condition ? (
|
|
184
196
|
<Condition path={name} condition={f.field.condition} key={f.name}>
|
|
185
197
|
{b}
|
|
@@ -189,7 +201,7 @@ export const FormElement = ({ field, name }: { field: IFormElement; name: string
|
|
|
189
201
|
)
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
const b = <FormElement key={f.name} name={f.name} field={f.field} />
|
|
204
|
+
const b = <FormElement key={f.name} name={f.name} field={f.field} size={size} />
|
|
193
205
|
return f.field.condition ? (
|
|
194
206
|
<Condition path={name} condition={f.field.condition} key={f.name}>
|
|
195
207
|
{b}
|
|
@@ -341,6 +353,7 @@ export const FieldMapForm = <F extends FieldMap>({
|
|
|
341
353
|
buttonText = 'SUBMIT',
|
|
342
354
|
renderFooter,
|
|
343
355
|
storagePath,
|
|
356
|
+
size = 'md',
|
|
344
357
|
}: FieldMapFormProps<F>) => {
|
|
345
358
|
const useSubmitDataProps = useMemo<UseFormSubmitProps<F>>(
|
|
346
359
|
() => ({
|
|
@@ -355,7 +368,7 @@ export const FieldMapForm = <F extends FieldMap>({
|
|
|
355
368
|
|
|
356
369
|
return (
|
|
357
370
|
<View style={styles.container}>
|
|
358
|
-
<FormElement name="" field={field} />
|
|
371
|
+
<FormElement name="" field={field} size={size} />
|
|
359
372
|
<FormFooter
|
|
360
373
|
uploads={uploads}
|
|
361
374
|
onSubmit={onSubmit}
|
|
@@ -371,12 +384,14 @@ export const FieldForm = <F extends Field | ListField>({
|
|
|
371
384
|
onSubmit,
|
|
372
385
|
field,
|
|
373
386
|
value,
|
|
387
|
+
size,
|
|
374
388
|
...props
|
|
375
389
|
}: FieldFormProps<F>) => {
|
|
376
390
|
const fieldMap = useMemo<FieldMap>(() => ({ children: { value: field } }), [field])
|
|
377
391
|
const fieldMapValue = useMemo<FieldMapValue<FieldMap>>(() => ({ value }), [value])
|
|
378
392
|
return (
|
|
379
393
|
<FieldMapForm
|
|
394
|
+
size={size}
|
|
380
395
|
field={fieldMap}
|
|
381
396
|
value={fieldMapValue}
|
|
382
397
|
onSubmit={data => onSubmit(data?.value)}
|
|
@@ -385,12 +400,27 @@ export const FieldForm = <F extends Field | ListField>({
|
|
|
385
400
|
)
|
|
386
401
|
}
|
|
387
402
|
|
|
388
|
-
export const Form = <F extends IFormElement>({
|
|
403
|
+
export const Form = <F extends IFormElement>({
|
|
404
|
+
field,
|
|
405
|
+
onSubmit,
|
|
406
|
+
size = 'md',
|
|
407
|
+
...props
|
|
408
|
+
}: FormProps<F>) => {
|
|
389
409
|
const body =
|
|
390
410
|
isField(field) || isListField(field) ? (
|
|
391
|
-
<FieldForm
|
|
411
|
+
<FieldForm
|
|
412
|
+
size={size}
|
|
413
|
+
field={field}
|
|
414
|
+
onSubmit={onSubmit as FormOnSubmit<Field | ListField>}
|
|
415
|
+
{...props}
|
|
416
|
+
/>
|
|
392
417
|
) : (
|
|
393
|
-
<FieldMapForm
|
|
418
|
+
<FieldMapForm
|
|
419
|
+
size={size}
|
|
420
|
+
field={field}
|
|
421
|
+
onSubmit={onSubmit as FormOnSubmit<FieldMap>}
|
|
422
|
+
{...props}
|
|
423
|
+
/>
|
|
394
424
|
)
|
|
395
425
|
|
|
396
426
|
return <ChempoFormProvider>{body}</ChempoFormProvider>
|
|
@@ -13,6 +13,8 @@ import { LoadingOverlay } from '../../loading/Loading'
|
|
|
13
13
|
import { UploadProgress } from '../UploadProgress'
|
|
14
14
|
import { FieldView } from '../view'
|
|
15
15
|
import { StandaloneInput } from './StandaloneInput'
|
|
16
|
+
import { InputClearButton } from './common/InputClearButton'
|
|
17
|
+
import { useInputStyles } from './hooks/useInputStyles'
|
|
16
18
|
|
|
17
19
|
export const Editable = <T extends Field>({
|
|
18
20
|
value: initValue,
|
|
@@ -23,9 +25,9 @@ export const Editable = <T extends Field>({
|
|
|
23
25
|
onEditClose,
|
|
24
26
|
onEditOpen,
|
|
25
27
|
containerStyle,
|
|
28
|
+
size,
|
|
26
29
|
}: EditableProps<ViewStyle, T>) => {
|
|
27
30
|
const {
|
|
28
|
-
formattedValue,
|
|
29
31
|
inputRef,
|
|
30
32
|
setValue,
|
|
31
33
|
isLoading,
|
|
@@ -38,7 +40,6 @@ export const Editable = <T extends Field>({
|
|
|
38
40
|
setEditHovered,
|
|
39
41
|
submitValue,
|
|
40
42
|
submit,
|
|
41
|
-
parse,
|
|
42
43
|
} = useEditable({
|
|
43
44
|
value: initValue,
|
|
44
45
|
field,
|
|
@@ -88,10 +89,18 @@ export const Editable = <T extends Field>({
|
|
|
88
89
|
}, [isEditing, inputRef])
|
|
89
90
|
|
|
90
91
|
const iconColor = useIconColor()
|
|
91
|
-
|
|
92
|
+
const { clearButtonSize } = useInputStyles(true, field.size, size)
|
|
92
93
|
const editingBorderColor = useColorModeValue('#00000055', '#ffffff55')
|
|
93
94
|
const submitColor = useThemeValue('colors.accent.200')
|
|
94
95
|
|
|
96
|
+
const needsClearButton = useMemo(() => {
|
|
97
|
+
if (!field.optional) return false
|
|
98
|
+
switch (field._type) {
|
|
99
|
+
case 'select':
|
|
100
|
+
return true
|
|
101
|
+
}
|
|
102
|
+
}, [field])
|
|
103
|
+
|
|
95
104
|
const handleBlur = useCallback(() => {
|
|
96
105
|
switch (field._type) {
|
|
97
106
|
case 'select':
|
|
@@ -134,20 +143,28 @@ export const Editable = <T extends Field>({
|
|
|
134
143
|
{isEditing || alwaysEditing ? (
|
|
135
144
|
<StandaloneInput
|
|
136
145
|
ref={inputRef}
|
|
137
|
-
value={
|
|
146
|
+
value={value}
|
|
138
147
|
inEditable
|
|
139
148
|
field={editableField}
|
|
140
149
|
style={style}
|
|
141
|
-
onChange={shouldSubmitOnChange ? v => submitValue(
|
|
150
|
+
onChange={shouldSubmitOnChange ? v => submitValue(v) : setValue}
|
|
142
151
|
onBlur={handleBlur}
|
|
143
152
|
/>
|
|
144
153
|
) : (
|
|
145
154
|
<FieldView noLabel style={style} field={field} value={value} />
|
|
146
155
|
)}
|
|
147
156
|
</View>
|
|
148
|
-
|
|
149
157
|
{!alwaysEditing && (
|
|
150
158
|
<View style={styles.buttonsContainer}>
|
|
159
|
+
{needsClearButton ? (
|
|
160
|
+
<InputClearButton
|
|
161
|
+
size={clearButtonSize}
|
|
162
|
+
onPress={() => {
|
|
163
|
+
submitValue(null)
|
|
164
|
+
}}
|
|
165
|
+
isActive={!!value}
|
|
166
|
+
/>
|
|
167
|
+
) : null}
|
|
151
168
|
{noCloseButton && isEditing ? null : (
|
|
152
169
|
<TouchableOpacity
|
|
153
170
|
style={styles.editButton}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useBorderColor, useIconColor } from '@chem-po/react'
|
|
1
|
+
import { useBackgroundColor, useBorderColor, useIconColor } from '@chem-po/react'
|
|
2
2
|
import { Ionicons } from '@expo/vector-icons'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { StyleSheet, TouchableOpacity } from 'react-native'
|
|
@@ -7,20 +7,26 @@ export const InputClearButton = ({
|
|
|
7
7
|
onPress,
|
|
8
8
|
isActive,
|
|
9
9
|
marginRight,
|
|
10
|
+
size,
|
|
10
11
|
}: {
|
|
11
12
|
onPress: () => void
|
|
12
13
|
isActive: boolean
|
|
13
14
|
marginRight?: number
|
|
15
|
+
size: number
|
|
14
16
|
}) => {
|
|
15
17
|
const iconColor = useIconColor()
|
|
16
18
|
const borderColor = useBorderColor()
|
|
19
|
+
const backgroundColor = useBackgroundColor(100)
|
|
17
20
|
return (
|
|
18
21
|
<TouchableOpacity
|
|
19
22
|
onPress={onPress}
|
|
20
|
-
style={[
|
|
23
|
+
style={[
|
|
24
|
+
styles.closeButton,
|
|
25
|
+
{ opacity: isActive ? 1 : 0, marginRight, borderColor, backgroundColor },
|
|
26
|
+
]}
|
|
21
27
|
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
|
|
22
28
|
disabled={!isActive}>
|
|
23
|
-
<Ionicons name="close" size={
|
|
29
|
+
<Ionicons name="close" size={size} color={iconColor} style={{ alignSelf: 'center' }} />
|
|
24
30
|
</TouchableOpacity>
|
|
25
31
|
)
|
|
26
32
|
}
|
|
@@ -28,11 +34,13 @@ export const InputClearButton = ({
|
|
|
28
34
|
export const DateInputClearButton = ({
|
|
29
35
|
onPress,
|
|
30
36
|
isActive,
|
|
37
|
+
size,
|
|
31
38
|
}: {
|
|
32
39
|
onPress: () => void
|
|
33
40
|
isActive: boolean
|
|
41
|
+
size: number
|
|
34
42
|
}) => {
|
|
35
|
-
return <InputClearButton marginRight={0} onPress={onPress} isActive={isActive} />
|
|
43
|
+
return <InputClearButton marginRight={0} onPress={onPress} isActive={isActive} size={size} />
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
const styles = StyleSheet.create({
|
|
@@ -8,7 +8,7 @@ import { DatePickerModal } from 'react-native-paper-dates'
|
|
|
8
8
|
import { FieldProps } from '../../types'
|
|
9
9
|
import { DateInputClearButton } from '../common/InputClearButton'
|
|
10
10
|
import { useInputColor } from '../hooks/useInputColor'
|
|
11
|
-
import {
|
|
11
|
+
import { useInputStyles } from '../hooks/useInputStyles'
|
|
12
12
|
|
|
13
13
|
// const parseDate = (date?: Date) =>
|
|
14
14
|
// date
|
|
@@ -21,12 +21,21 @@ export const DateInput = forwardRef<InputRef, FieldProps<DateField>>(
|
|
|
21
21
|
(
|
|
22
22
|
{
|
|
23
23
|
input: { onChange, value, onFocus, onBlur },
|
|
24
|
-
field: { placeholder, minDate, maxDate, optional },
|
|
24
|
+
field: { placeholder, minDate, maxDate, optional, size },
|
|
25
25
|
meta: { active },
|
|
26
|
+
formSize,
|
|
27
|
+
inEditable,
|
|
26
28
|
},
|
|
27
29
|
ref,
|
|
28
30
|
) => {
|
|
29
31
|
const date = useMemo(() => (value ? new Date(`${value}T00:00:00.000`) : undefined), [value])
|
|
32
|
+
const {
|
|
33
|
+
container: inputStyles,
|
|
34
|
+
iconSize,
|
|
35
|
+
text,
|
|
36
|
+
clearButtonSize,
|
|
37
|
+
buttonContainer,
|
|
38
|
+
} = useInputStyles(inEditable, size, formSize)
|
|
30
39
|
|
|
31
40
|
useImperativeHandle(ref, () => ({
|
|
32
41
|
focus: () => {
|
|
@@ -49,14 +58,20 @@ export const DateInput = forwardRef<InputRef, FieldProps<DateField>>(
|
|
|
49
58
|
|
|
50
59
|
return (
|
|
51
60
|
<View style={styles.container}>
|
|
52
|
-
<TouchableOpacity style={[styles.button, inputStyles
|
|
53
|
-
<Text style={[styles.text, { color: inputColor }]}>
|
|
61
|
+
<TouchableOpacity style={[styles.button, inputStyles]} onPress={showDialog}>
|
|
62
|
+
<Text style={[styles.text, text, { color: inputColor }]}>
|
|
54
63
|
{value ? getDateString(value, 'short') : placeholder}
|
|
55
64
|
</Text>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
<View style={buttonContainer}>
|
|
66
|
+
<Ionicons name="calendar" size={iconSize} color={iconColor} />
|
|
67
|
+
{optional && value ? (
|
|
68
|
+
<DateInputClearButton
|
|
69
|
+
size={clearButtonSize}
|
|
70
|
+
onPress={() => onChange(null)}
|
|
71
|
+
isActive={!!value}
|
|
72
|
+
/>
|
|
73
|
+
) : null}
|
|
74
|
+
</View>
|
|
60
75
|
</TouchableOpacity>
|
|
61
76
|
<Portal>
|
|
62
77
|
<DatePickerModal
|
|
@@ -92,10 +107,6 @@ const styles = StyleSheet.create({
|
|
|
92
107
|
width: '100%',
|
|
93
108
|
},
|
|
94
109
|
text: {
|
|
95
|
-
fontSize: 16,
|
|
96
110
|
flex: 1,
|
|
97
111
|
},
|
|
98
|
-
icon: {
|
|
99
|
-
marginRight: 10,
|
|
100
|
-
},
|
|
101
112
|
})
|
|
@@ -8,14 +8,23 @@ import { DatePickerModal, TimePickerModal } from 'react-native-paper-dates'
|
|
|
8
8
|
import { FieldProps } from '../../types'
|
|
9
9
|
import { DateInputClearButton } from '../common/InputClearButton'
|
|
10
10
|
import { useInputColor } from '../hooks/useInputColor'
|
|
11
|
-
import {
|
|
11
|
+
import { useInputStyles } from '../hooks/useInputStyles'
|
|
12
12
|
|
|
13
13
|
export const DateTimeInput = forwardRef<InputRef, FieldProps<DateTimeField>>(
|
|
14
|
-
(
|
|
14
|
+
(
|
|
15
|
+
{ input: { value, onBlur, onChange, onFocus }, field, meta: { active }, formSize, inEditable },
|
|
16
|
+
ref,
|
|
17
|
+
) => {
|
|
15
18
|
const { placeholder, optional } = field
|
|
16
19
|
const [showDatePicker, setShowDatePicker] = useState(true)
|
|
17
20
|
const [showTimePicker, setShowTimePicker] = useState(false)
|
|
18
|
-
|
|
21
|
+
const {
|
|
22
|
+
container: inputStyles,
|
|
23
|
+
iconSize,
|
|
24
|
+
text,
|
|
25
|
+
clearButtonSize,
|
|
26
|
+
buttonContainer,
|
|
27
|
+
} = useInputStyles(inEditable, field.size, formSize)
|
|
19
28
|
|
|
20
29
|
const selectedDate = useMemo(() => (value ? new Date(value) : new Date()), [value])
|
|
21
30
|
useImperativeHandle(ref, () => ({
|
|
@@ -77,17 +86,25 @@ export const DateTimeInput = forwardRef<InputRef, FieldProps<DateTimeField>>(
|
|
|
77
86
|
return (
|
|
78
87
|
<View style={styles.container}>
|
|
79
88
|
<TouchableOpacity
|
|
80
|
-
style={[styles.button, inputStyles
|
|
89
|
+
style={[styles.button, inputStyles]}
|
|
81
90
|
onPress={() => {
|
|
82
91
|
setShowDatePicker(true)
|
|
83
92
|
onFocus()
|
|
84
93
|
}}>
|
|
85
|
-
<Text style={[styles.text, { color: inputColor }]}>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
<
|
|
90
|
-
|
|
94
|
+
<Text style={[styles.text, text, { color: inputColor }]}>
|
|
95
|
+
{formattedValue ?? placeholder}
|
|
96
|
+
</Text>
|
|
97
|
+
<View style={buttonContainer}>
|
|
98
|
+
<Ionicons name="calendar" size={iconSize} color={iconColor} />
|
|
99
|
+
<Ionicons name="time" size={iconSize} color={iconColor} />
|
|
100
|
+
{optional && value ? (
|
|
101
|
+
<DateInputClearButton
|
|
102
|
+
size={clearButtonSize}
|
|
103
|
+
onPress={() => onChange(null)}
|
|
104
|
+
isActive={!!value}
|
|
105
|
+
/>
|
|
106
|
+
) : null}
|
|
107
|
+
</View>
|
|
91
108
|
</TouchableOpacity>
|
|
92
109
|
<Portal>
|
|
93
110
|
{showDatePicker && (
|
|
@@ -132,10 +149,6 @@ const styles = StyleSheet.create({
|
|
|
132
149
|
width: '100%',
|
|
133
150
|
},
|
|
134
151
|
text: {
|
|
135
|
-
fontSize: 16,
|
|
136
152
|
flex: 1,
|
|
137
153
|
},
|
|
138
|
-
icon: {
|
|
139
|
-
marginRight: 10,
|
|
140
|
-
},
|
|
141
154
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './useInputImperativeHandle'
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './useInputStyles'
|