@aemforms/af-react-native 1.0.1

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 (43) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +121 -0
  3. package/lib/components/Button.d.ts +22 -0
  4. package/lib/components/Button.js +32 -0
  5. package/lib/components/Checkbox.d.ts +22 -0
  6. package/lib/components/Checkbox.js +65 -0
  7. package/lib/components/CheckboxGroup.d.ts +22 -0
  8. package/lib/components/CheckboxGroup.js +78 -0
  9. package/lib/components/DatePicker.d.ts +22 -0
  10. package/lib/components/DatePicker.js +110 -0
  11. package/lib/components/DropDown.d.ts +22 -0
  12. package/lib/components/DropDown.js +64 -0
  13. package/lib/components/FileUpload.d.ts +22 -0
  14. package/lib/components/FileUpload.js +45 -0
  15. package/lib/components/Form.d.ts +24 -0
  16. package/lib/components/Form.js +56 -0
  17. package/lib/components/NumberField.d.ts +22 -0
  18. package/lib/components/NumberField.js +81 -0
  19. package/lib/components/Panel.d.ts +23 -0
  20. package/lib/components/Panel.js +68 -0
  21. package/lib/components/PlainText.d.ts +22 -0
  22. package/lib/components/PlainText.js +39 -0
  23. package/lib/components/RadioGroup.d.ts +22 -0
  24. package/lib/components/RadioGroup.js +64 -0
  25. package/lib/components/Repeater.d.ts +23 -0
  26. package/lib/components/Repeater.js +61 -0
  27. package/lib/components/TextField.d.ts +22 -0
  28. package/lib/components/TextField.js +84 -0
  29. package/lib/index.d.ts +35 -0
  30. package/lib/index.js +55 -0
  31. package/lib/shared/FileUpload.d.ts +23 -0
  32. package/lib/shared/FileUpload.js +110 -0
  33. package/lib/shared/withRuleEngine.d.ts +22 -0
  34. package/lib/shared/withRuleEngine.js +64 -0
  35. package/lib/utils/common.d.ts +24 -0
  36. package/lib/utils/common.js +112 -0
  37. package/lib/utils/mappings.d.ts +38 -0
  38. package/lib/utils/mappings.js +54 -0
  39. package/lib/utils/theme.d.ts +19657 -0
  40. package/lib/utils/theme.js +109 -0
  41. package/lib/utils/types.d.ts +91 -0
  42. package/lib/utils/types.js +21 -0
  43. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright 2023 Adobe, Inc.
2
+
3
+ Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # React Native Components For Headless Adaptive Form
2
+ The document provides detailed information on React Native Components that you can use to render [Headless Adaptive Form](https://experienceleague.adobe.com/docs/experience-manager-headless-adaptive-forms/using/overview.html?lang=en). To learn about the capabilties of Headless Adaptive Forms, see [Overview of Headless Adaptive Forms](https://experienceleague.adobe.com/docs/experience-manager-headless-adaptive-forms/using/overview.html?lang=en)
3
+
4
+ ## Demo Link
5
+ [Demo](coming soon)
6
+
7
+ ## Table of Contents
8
+ - List of Components
9
+ - Button
10
+ - Checkbox
11
+ - Checkbox Group
12
+ - Drop Down
13
+ - Date Picker
14
+ - File Upload
15
+ - Password
16
+ - Number Field
17
+ - Panel
18
+ - Plain Text
19
+ - Radio Group
20
+ - Repeater
21
+ - Text Area Field
22
+ - Text Field
23
+ - Themes
24
+ - Primary
25
+ - Tertiary
26
+ - Rose
27
+ - Warning
28
+ - Indigo
29
+ - Mappings
30
+
31
+
32
+
33
+ ## Before you start {#pre-requisites}
34
+ To create and run a React Native app, you should have Node.js, npm (Node Package Manager), Xcode and Android Studio installed on your computer:
35
+ * Install the [latest release of Git](https://git-scm.com/downloads). If you are new to Git, see [Installing Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
36
+ * Install [Node.js 16.13.0 or later](https://nodejs.org/en/download/). If you are new to Node.js, see [How to install Node.js](https://nodejs.dev/en/learn/how-to-install-nodejs).
37
+
38
+
39
+ ## Setup Project
40
+
41
+ Create a React native Application using the following commands or follow the [link](https://reactnative.dev/docs/environment-setup).
42
+
43
+ ```
44
+ npx react-native init AwesomeProject
45
+
46
+ ```
47
+
48
+ ## Installation
49
+ Run the following command to add Adaptive Forms Components to you React Native Application:
50
+
51
+ ```
52
+ npm install --save @aemforms/af-react-native
53
+
54
+ ```
55
+
56
+ These form components are depend on `@aemforms/af-core` and `@aemforms/af-react-renderer` libraries. Run the following command to add these dependecies to your React Application:
57
+
58
+ ```
59
+ npm install --save @aemforms/af-core @aemforms/af-react-renderer
60
+
61
+ ```
62
+
63
+ ## Usage
64
+ ```jsx
65
+ import React from 'react';
66
+ import { AdaptiveForm } from '@aemforms/af-react-renderer';
67
+ import { NativeBaseProvider} from 'native-base';
68
+ import {mappings, Themes} from '@aemforms/af-react-native';
69
+ const json = {
70
+ "adaptiveform": "0.10.0",
71
+ "items": [
72
+ {
73
+ "name": "name",
74
+ "type": "string",
75
+ "fieldType": "text-input",
76
+ "required": true,
77
+ "label": {
78
+ "value": "Name"
79
+ }
80
+ },
81
+ {
82
+ "name": "mobile",
83
+ "type": "number",
84
+ "fieldType": "number-input",
85
+ "required": true,
86
+ "label": {
87
+ "value": "Mobile Number"
88
+ }
89
+ },
90
+ {
91
+ "name": "submit",
92
+ "fieldType": "button",
93
+ "label": {
94
+ "value": "submit"
95
+ }
96
+ }
97
+ ],
98
+ "metadata": {
99
+ "version": "1.0.0"
100
+ }
101
+ }
102
+ const App = () => {
103
+ return (
104
+ <NativeBaseProvider theme={Themes.primary}>
105
+ <AdaptiveForm
106
+ formJson={json}
107
+ mappings={mappings}
108
+ />
109
+ </NativeBaseProvider>
110
+ );
111
+ };
112
+ export default App;
113
+ ```
114
+
115
+ ## License
116
+
117
+ Copyright 2023 Adobe, Inc.
118
+
119
+ Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
120
+
121
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*************************************************************************
3
+ * ADOBE CONFIDENTIAL
4
+ * ___________________
5
+ *
6
+ * Copyright 2023 Adobe
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Adobe and its suppliers, if any. The intellectual
11
+ * and technical concepts contained herein are proprietary to Adobe
12
+ * and its suppliers and are protected by all applicable intellectual
13
+ * property laws, including trade secret and copyright laws.
14
+ * Dissemination of this information or reproduction of this material
15
+ * is strictly forbidden unless prior written permission is obtained
16
+ * from Adobe.
17
+
18
+ * Adobe permits you to use and modify this file solely in accordance with
19
+ * the terms of the Adobe license agreement accompanying it.
20
+ *************************************************************************/
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const native_base_1 = require("native-base");
26
+ const react_1 = __importDefault(require("react"));
27
+ const withRuleEngine_1 = __importDefault(require("../shared/withRuleEngine"));
28
+ const ButtonComponent = function (props) {
29
+ const { label, enabled, dispatchClick } = props;
30
+ return react_1.default.createElement(native_base_1.Button, { onPress: dispatchClick, isDisabled: enabled === false }, label === null || label === void 0 ? void 0 : label.value);
31
+ };
32
+ exports.default = (0, withRuleEngine_1.default)(ButtonComponent);
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /*************************************************************************
3
+ * ADOBE CONFIDENTIAL
4
+ * ___________________
5
+ *
6
+ * Copyright 2023 Adobe
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Adobe and its suppliers, if any. The intellectual
11
+ * and technical concepts contained herein are proprietary to Adobe
12
+ * and its suppliers and are protected by all applicable intellectual
13
+ * property laws, including trade secret and copyright laws.
14
+ * Dissemination of this information or reproduction of this material
15
+ * is strictly forbidden unless prior written permission is obtained
16
+ * from Adobe.
17
+
18
+ * Adobe permits you to use and modify this file solely in accordance with
19
+ * the terms of the Adobe license agreement accompanying it.
20
+ *************************************************************************/
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __importStar = (this && this.__importStar) || function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const react_1 = __importStar(require("react"));
49
+ const native_base_1 = require("native-base");
50
+ const withRuleEngine_1 = __importDefault(require("../shared/withRuleEngine"));
51
+ const CheckboxComponent = function (props) {
52
+ var _a, _b, _c;
53
+ const { isError, required, label, errorMessage, description, value, dispatchChange } = props;
54
+ const selectedValue = (_a = props.enum) === null || _a === void 0 ? void 0 : _a[0];
55
+ const unselectedValue = (((_b = props.enum) === null || _b === void 0 ? void 0 : _b.length) || 0) < 2 ? null : (_c = props.enum) === null || _c === void 0 ? void 0 : _c[1];
56
+ const changeHandler = (0, react_1.useCallback)((val) => {
57
+ const updatedValue = val ? selectedValue : unselectedValue;
58
+ dispatchChange(updatedValue);
59
+ }, [dispatchChange, selectedValue, unselectedValue]);
60
+ return (react_1.default.createElement(native_base_1.FormControl, { isInvalid: isError, isRequired: required },
61
+ react_1.default.createElement(native_base_1.Checkbox, { onChange: changeHandler, value: value }, (label === null || label === void 0 ? void 0 : label.visible) ? label === null || label === void 0 ? void 0 : label.value : ''),
62
+ errorMessage ? react_1.default.createElement(native_base_1.FormControl.ErrorMessage, { testID: `${props.id}-error` }, errorMessage) : null,
63
+ description && !errorMessage ? react_1.default.createElement(native_base_1.FormControl.HelperText, { testID: `${props.id}-description` }, description) : null));
64
+ };
65
+ exports.default = (0, withRuleEngine_1.default)(CheckboxComponent);
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /*************************************************************************
3
+ * ADOBE CONFIDENTIAL
4
+ * ___________________
5
+ *
6
+ * Copyright 2023 Adobe
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Adobe and its suppliers, if any. The intellectual
11
+ * and technical concepts contained herein are proprietary to Adobe
12
+ * and its suppliers and are protected by all applicable intellectual
13
+ * property laws, including trade secret and copyright laws.
14
+ * Dissemination of this information or reproduction of this material
15
+ * is strictly forbidden unless prior written permission is obtained
16
+ * from Adobe.
17
+
18
+ * Adobe permits you to use and modify this file solely in accordance with
19
+ * the terms of the Adobe license agreement accompanying it.
20
+ *************************************************************************/
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __importStar = (this && this.__importStar) || function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const react_1 = __importStar(require("react"));
49
+ const native_base_1 = require("native-base");
50
+ const withRuleEngine_1 = __importDefault(require("../shared/withRuleEngine"));
51
+ const CheckboxGroupComponent = function (props) {
52
+ const { isError, required, label, errorMessage, description, value, type, enumNames, dispatchChange } = props;
53
+ const enums = props.enum || [];
54
+ const isArray = (type || '[]').indexOf('[]') > -1;
55
+ const options = (enumNames === null || enumNames === void 0 ? void 0 : enumNames.length) ? enumNames : enums;
56
+ const changeHandler = (0, react_1.useCallback)((val) => {
57
+ let finalVal;
58
+ if (val === null) {
59
+ finalVal = null;
60
+ }
61
+ if (isArray) {
62
+ finalVal = val;
63
+ }
64
+ else if (val.length > 0) {
65
+ finalVal = val.filter((x) => value !== x)[0];
66
+ }
67
+ else {
68
+ finalVal = null;
69
+ }
70
+ dispatchChange(finalVal);
71
+ }, [value, isArray, dispatchChange]);
72
+ return (react_1.default.createElement(native_base_1.FormControl, { isInvalid: isError, isRequired: required },
73
+ (label === null || label === void 0 ? void 0 : label.visible) && react_1.default.createElement(native_base_1.FormControl.Label, null, label === null || label === void 0 ? void 0 : label.value),
74
+ react_1.default.createElement(native_base_1.Checkbox.Group, { onChange: changeHandler }, options === null || options === void 0 ? void 0 : options.map((text, index) => (react_1.default.createElement(native_base_1.Checkbox, { key: enums[index], value: enums[index] }, text)))),
75
+ errorMessage ? react_1.default.createElement(native_base_1.FormControl.ErrorMessage, { testID: `${props.id}-error` }, errorMessage) : null,
76
+ description && !errorMessage ? react_1.default.createElement(native_base_1.FormControl.HelperText, { testID: `${props.id}-description` }, description) : null));
77
+ };
78
+ exports.default = (0, withRuleEngine_1.default)(CheckboxGroupComponent);
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /*************************************************************************
3
+ * ADOBE CONFIDENTIAL
4
+ * ___________________
5
+ *
6
+ * Copyright 2023 Adobe
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Adobe and its suppliers, if any. The intellectual
11
+ * and technical concepts contained herein are proprietary to Adobe
12
+ * and its suppliers and are protected by all applicable intellectual
13
+ * property laws, including trade secret and copyright laws.
14
+ * Dissemination of this information or reproduction of this material
15
+ * is strictly forbidden unless prior written permission is obtained
16
+ * from Adobe.
17
+
18
+ * Adobe permits you to use and modify this file solely in accordance with
19
+ * the terms of the Adobe license agreement accompanying it.
20
+ *************************************************************************/
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __importStar = (this && this.__importStar) || function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const react_1 = __importStar(require("react"));
49
+ const native_base_1 = require("native-base");
50
+ const react_native_1 = require("react-native");
51
+ const react_native_date_picker_1 = __importDefault(require("react-native-date-picker"));
52
+ const withRuleEngine_1 = __importDefault(require("../shared/withRuleEngine"));
53
+ //@ts-ignore
54
+ const af_formatters_1 = require("@aemforms/af-formatters");
55
+ //@ts-ignore
56
+ const calendar_icon_png_1 = __importDefault(require("../image/calendar-icon.png"));
57
+ const DatePickerComponent = function (props) {
58
+ const { isError, required, label, errorMessage, description, value, displayFormat, dispatchChange, dispatchBlur, dispatchFocus } = props;
59
+ const [open, setOpen] = (0, react_1.useState)(false);
60
+ const [typedValue, setTypedValue] = (0, react_1.useState)(value ? value : '');
61
+ const formatDate = (0, react_1.useCallback)((date) => {
62
+ var d = new Date(date);
63
+ const month = d.getMonth() + 1;
64
+ const day = d.getDate();
65
+ return `${d.getFullYear()}-${month < 10 ? `0${month}` : month}-${day < 10 ? `0${day}` : day}`;
66
+ }, []);
67
+ const confirmHandler = (0, react_1.useCallback)((date) => {
68
+ setOpen(false);
69
+ // @ts-ignore
70
+ dispatchChange(formatDate(date));
71
+ setTypedValue((0, af_formatters_1.format)(date, 'en-US', displayFormat));
72
+ }, [dispatchChange]);
73
+ const cancelHandler = (0, react_1.useCallback)(() => {
74
+ setOpen(false);
75
+ }, []);
76
+ const inputProps = {
77
+ placeholder: props.placeholder || '',
78
+ value: typedValue,
79
+ onChangeText: (value) => { setTypedValue(value); },
80
+ onBlur: () => {
81
+ const parsedDate = formatDate((0, af_formatters_1.parse)(typedValue, 'en-US', displayFormat));
82
+ dispatchChange(parsedDate);
83
+ dispatchBlur(parsedDate);
84
+ },
85
+ isReadOnly: props.readOnly === true,
86
+ isRequired: props.required === true,
87
+ isDisabled: props.enabled === false,
88
+ KeyboardTypeOptions: 'default',
89
+ type: 'text'
90
+ };
91
+ return (react_1.default.createElement(react_1.default.Fragment, null,
92
+ react_1.default.createElement(native_base_1.FormControl, { isInvalid: isError, isRequired: required },
93
+ (label === null || label === void 0 ? void 0 : label.visible) && react_1.default.createElement(native_base_1.FormControl.Label, null, label === null || label === void 0 ? void 0 : label.value),
94
+ react_1.default.createElement(native_base_1.Input, Object.assign({}, inputProps, { InputRightElement: (react_1.default.createElement(native_base_1.Button, { onPress: () => setOpen(true), style: styles.button },
95
+ react_1.default.createElement(native_base_1.Image, { source: calendar_icon_png_1.default, alt: 'calendar', style: styles.calendar }))) })),
96
+ errorMessage ? react_1.default.createElement(native_base_1.FormControl.ErrorMessage, { testID: `${props.id}-error` }, errorMessage) : null,
97
+ description && !errorMessage ? react_1.default.createElement(native_base_1.FormControl.HelperText, { testID: `${props.id}-description` }, description) : null),
98
+ react_1.default.createElement(react_native_date_picker_1.default, { modal: true, open: open, mode: "date", date: value ? new Date(value) : new Date(), onConfirm: confirmHandler, onCancel: cancelHandler })));
99
+ };
100
+ const styles = react_native_1.StyleSheet.create({
101
+ calendar: {
102
+ width: 31,
103
+ height: 31
104
+ },
105
+ button: {
106
+ backgroundColor: 'transparent',
107
+ height: 31
108
+ }
109
+ });
110
+ exports.default = (0, withRuleEngine_1.default)(DatePickerComponent);
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ /*************************************************************************
3
+ * ADOBE CONFIDENTIAL
4
+ * ___________________
5
+ *
6
+ * Copyright 2023 Adobe
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Adobe and its suppliers, if any. The intellectual
11
+ * and technical concepts contained herein are proprietary to Adobe
12
+ * and its suppliers and are protected by all applicable intellectual
13
+ * property laws, including trade secret and copyright laws.
14
+ * Dissemination of this information or reproduction of this material
15
+ * is strictly forbidden unless prior written permission is obtained
16
+ * from Adobe.
17
+
18
+ * Adobe permits you to use and modify this file solely in accordance with
19
+ * the terms of the Adobe license agreement accompanying it.
20
+ *************************************************************************/
21
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ var desc = Object.getOwnPropertyDescriptor(m, k);
24
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
25
+ desc = { enumerable: true, get: function() { return m[k]; } };
26
+ }
27
+ Object.defineProperty(o, k2, desc);
28
+ }) : (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ o[k2] = m[k];
31
+ }));
32
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
33
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
34
+ }) : function(o, v) {
35
+ o["default"] = v;
36
+ });
37
+ var __importStar = (this && this.__importStar) || function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ const react_1 = __importStar(require("react"));
49
+ const native_base_1 = require("native-base");
50
+ const withRuleEngine_1 = __importDefault(require("../shared/withRuleEngine"));
51
+ const DropDownComponent = function (props) {
52
+ const { isError, required, label, errorMessage, description, value, enumNames, placeholder, dispatchChange } = props;
53
+ const enums = props.enum || [];
54
+ const options = (enumNames === null || enumNames === void 0 ? void 0 : enumNames.length) ? enumNames : enums;
55
+ const changeHandler = (0, react_1.useCallback)((val) => {
56
+ dispatchChange(val);
57
+ }, [dispatchChange]);
58
+ return (react_1.default.createElement(native_base_1.FormControl, { isInvalid: isError, isRequired: required },
59
+ (label === null || label === void 0 ? void 0 : label.visible) && react_1.default.createElement(native_base_1.FormControl.Label, null, label === null || label === void 0 ? void 0 : label.value),
60
+ react_1.default.createElement(native_base_1.Select, { onValueChange: changeHandler, selectedValue: value, placeholder: placeholder }, options === null || options === void 0 ? void 0 : options.map((text, index) => (react_1.default.createElement(native_base_1.Select.Item, { key: enums[index], value: enums[index], label: text })))),
61
+ errorMessage ? react_1.default.createElement(native_base_1.FormControl.ErrorMessage, { testID: `${props.id}-error` }, errorMessage) : null,
62
+ description && !errorMessage ? react_1.default.createElement(native_base_1.FormControl.HelperText, { testID: `${props.id}-description` }, description) : null));
63
+ };
64
+ exports.default = (0, withRuleEngine_1.default)(DropDownComponent);
@@ -0,0 +1,22 @@
1
+ /*************************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * ___________________
4
+ *
5
+ * Copyright 2023 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+
17
+ * Adobe permits you to use and modify this file solely in accordance with
18
+ * the terms of the Adobe license agreement accompanying it.
19
+ *************************************************************************/
20
+ import React from 'react';
21
+ declare const _default: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => React.JSX.Element | null;
22
+ export default _default;