@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.
- package/LICENSE +5 -0
- package/README.md +121 -0
- package/lib/components/Button.d.ts +22 -0
- package/lib/components/Button.js +32 -0
- package/lib/components/Checkbox.d.ts +22 -0
- package/lib/components/Checkbox.js +65 -0
- package/lib/components/CheckboxGroup.d.ts +22 -0
- package/lib/components/CheckboxGroup.js +78 -0
- package/lib/components/DatePicker.d.ts +22 -0
- package/lib/components/DatePicker.js +110 -0
- package/lib/components/DropDown.d.ts +22 -0
- package/lib/components/DropDown.js +64 -0
- package/lib/components/FileUpload.d.ts +22 -0
- package/lib/components/FileUpload.js +45 -0
- package/lib/components/Form.d.ts +24 -0
- package/lib/components/Form.js +56 -0
- package/lib/components/NumberField.d.ts +22 -0
- package/lib/components/NumberField.js +81 -0
- package/lib/components/Panel.d.ts +23 -0
- package/lib/components/Panel.js +68 -0
- package/lib/components/PlainText.d.ts +22 -0
- package/lib/components/PlainText.js +39 -0
- package/lib/components/RadioGroup.d.ts +22 -0
- package/lib/components/RadioGroup.js +64 -0
- package/lib/components/Repeater.d.ts +23 -0
- package/lib/components/Repeater.js +61 -0
- package/lib/components/TextField.d.ts +22 -0
- package/lib/components/TextField.js +84 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.js +55 -0
- package/lib/shared/FileUpload.d.ts +23 -0
- package/lib/shared/FileUpload.js +110 -0
- package/lib/shared/withRuleEngine.d.ts +22 -0
- package/lib/shared/withRuleEngine.js +64 -0
- package/lib/utils/common.d.ts +24 -0
- package/lib/utils/common.js +112 -0
- package/lib/utils/mappings.d.ts +38 -0
- package/lib/utils/mappings.js +54 -0
- package/lib/utils/theme.d.ts +19657 -0
- package/lib/utils/theme.js +109 -0
- package/lib/utils/types.d.ts +91 -0
- package/lib/utils/types.js +21 -0
- package/package.json +76 -0
|
@@ -0,0 +1,84 @@
|
|
|
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 TextFieldComponent = function (props) {
|
|
52
|
+
const { isError, required, label, errorMessage, description } = props;
|
|
53
|
+
const changeHandler = (0, react_1.useCallback)((event) => {
|
|
54
|
+
props.dispatchChange(event);
|
|
55
|
+
}, [props.dispatchChange]);
|
|
56
|
+
const blurHandler = (0, react_1.useCallback)((event) => {
|
|
57
|
+
props.dispatchBlur(event);
|
|
58
|
+
}, [props.dispatchBlur]);
|
|
59
|
+
const focusHandler = (0, react_1.useCallback)((event) => {
|
|
60
|
+
props.dispatchFocus(event);
|
|
61
|
+
}, [props.dispatchFocus]);
|
|
62
|
+
const inputProps = {
|
|
63
|
+
placeholder: props.placeholder || '',
|
|
64
|
+
value: props.value == null ? '' : props.value,
|
|
65
|
+
onChangeText: changeHandler,
|
|
66
|
+
onBlur: blurHandler,
|
|
67
|
+
onFocus: focusHandler,
|
|
68
|
+
isReadOnly: props.readOnly === true,
|
|
69
|
+
isRequired: props.required === true,
|
|
70
|
+
isDisabled: props.enabled === false,
|
|
71
|
+
KeyboardTypeOptions: 'default',
|
|
72
|
+
maxLength: props.maxLength,
|
|
73
|
+
minLength: props.minLength,
|
|
74
|
+
pattern: props.pattern,
|
|
75
|
+
type: props[':type'] === 'password-input' ? 'password' : 'text'
|
|
76
|
+
};
|
|
77
|
+
const Comp = props.fieldType === 'multiline-input' ? native_base_1.TextArea : native_base_1.Input;
|
|
78
|
+
return (react_1.default.createElement(native_base_1.FormControl, { isInvalid: isError, isRequired: required },
|
|
79
|
+
(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),
|
|
80
|
+
react_1.default.createElement(Comp, Object.assign({}, inputProps)),
|
|
81
|
+
errorMessage && react_1.default.createElement(native_base_1.FormControl.ErrorMessage, { testID: `${props.id}-error` }, errorMessage),
|
|
82
|
+
description && !errorMessage && react_1.default.createElement(native_base_1.FormControl.HelperText, { testID: `${props.id}-description` }, description)));
|
|
83
|
+
};
|
|
84
|
+
exports.default = (0, withRuleEngine_1.default)(TextFieldComponent);
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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 mappings from "./utils/mappings";
|
|
21
|
+
import Button from "./components/Button";
|
|
22
|
+
import Checkbox from "./components/Checkbox";
|
|
23
|
+
import CheckboxGroup from "./components/CheckboxGroup";
|
|
24
|
+
import DropDown from "./components/DropDown";
|
|
25
|
+
import FileUpload from "./components/FileUpload";
|
|
26
|
+
import Form from "./components/Form";
|
|
27
|
+
import NumberField from "./components/NumberField";
|
|
28
|
+
import Panel from "./components/Panel";
|
|
29
|
+
import PlainText from "./components/PlainText";
|
|
30
|
+
import RadioGroup from "./components/RadioGroup";
|
|
31
|
+
import Repeater from "./components/Repeater";
|
|
32
|
+
import TextField from "./components/TextField";
|
|
33
|
+
import DatePicker from "./components/DatePicker";
|
|
34
|
+
import Themes from './utils/theme';
|
|
35
|
+
export { mappings, Button, Checkbox, CheckboxGroup, DropDown, FileUpload, Form, NumberField, Panel, PlainText, RadioGroup, Repeater, TextField, DatePicker, Themes };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
exports.Themes = exports.DatePicker = exports.TextField = exports.Repeater = exports.RadioGroup = exports.PlainText = exports.Panel = exports.NumberField = exports.Form = exports.FileUpload = exports.DropDown = exports.CheckboxGroup = exports.Checkbox = exports.Button = exports.mappings = void 0;
|
|
26
|
+
const mappings_1 = __importDefault(require("./utils/mappings"));
|
|
27
|
+
exports.mappings = mappings_1.default;
|
|
28
|
+
const Button_1 = __importDefault(require("./components/Button"));
|
|
29
|
+
exports.Button = Button_1.default;
|
|
30
|
+
const Checkbox_1 = __importDefault(require("./components/Checkbox"));
|
|
31
|
+
exports.Checkbox = Checkbox_1.default;
|
|
32
|
+
const CheckboxGroup_1 = __importDefault(require("./components/CheckboxGroup"));
|
|
33
|
+
exports.CheckboxGroup = CheckboxGroup_1.default;
|
|
34
|
+
const DropDown_1 = __importDefault(require("./components/DropDown"));
|
|
35
|
+
exports.DropDown = DropDown_1.default;
|
|
36
|
+
const FileUpload_1 = __importDefault(require("./components/FileUpload"));
|
|
37
|
+
exports.FileUpload = FileUpload_1.default;
|
|
38
|
+
const Form_1 = __importDefault(require("./components/Form"));
|
|
39
|
+
exports.Form = Form_1.default;
|
|
40
|
+
const NumberField_1 = __importDefault(require("./components/NumberField"));
|
|
41
|
+
exports.NumberField = NumberField_1.default;
|
|
42
|
+
const Panel_1 = __importDefault(require("./components/Panel"));
|
|
43
|
+
exports.Panel = Panel_1.default;
|
|
44
|
+
const PlainText_1 = __importDefault(require("./components/PlainText"));
|
|
45
|
+
exports.PlainText = PlainText_1.default;
|
|
46
|
+
const RadioGroup_1 = __importDefault(require("./components/RadioGroup"));
|
|
47
|
+
exports.RadioGroup = RadioGroup_1.default;
|
|
48
|
+
const Repeater_1 = __importDefault(require("./components/Repeater"));
|
|
49
|
+
exports.Repeater = Repeater_1.default;
|
|
50
|
+
const TextField_1 = __importDefault(require("./components/TextField"));
|
|
51
|
+
exports.TextField = TextField_1.default;
|
|
52
|
+
const DatePicker_1 = __importDefault(require("./components/DatePicker"));
|
|
53
|
+
exports.DatePicker = DatePicker_1.default;
|
|
54
|
+
const theme_1 = __importDefault(require("./utils/theme"));
|
|
55
|
+
exports.Themes = theme_1.default;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
import { FileUploadType } from '../utils/types';
|
|
22
|
+
declare const FileUpload: (props: FileUploadType) => React.JSX.Element;
|
|
23
|
+
export default FileUpload;
|
|
@@ -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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
45
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
46
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
47
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
48
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
49
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
50
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
const react_1 = __importStar(require("react"));
|
|
58
|
+
const native_base_1 = require("native-base");
|
|
59
|
+
const react_native_document_picker_1 = __importDefault(require("react-native-document-picker"));
|
|
60
|
+
const common_1 = require("../utils/common");
|
|
61
|
+
const FileUpload = (props) => {
|
|
62
|
+
const { maxFileSizeInBytes, accept, multiple, onChange, value } = props;
|
|
63
|
+
const [files, setFiles] = (0, react_1.useState)(value || []);
|
|
64
|
+
const fileListArray = (0, react_1.useCallback)((fileList) => {
|
|
65
|
+
let localFiles = [];
|
|
66
|
+
fileList.forEach((file) => {
|
|
67
|
+
if (file.size <= maxFileSizeInBytes) {
|
|
68
|
+
localFiles.push(file);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
localFiles = multiple ? files.concat(localFiles) : localFiles;
|
|
72
|
+
return localFiles;
|
|
73
|
+
}, [maxFileSizeInBytes, multiple, files]);
|
|
74
|
+
const fileSelectionHandler = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
try {
|
|
76
|
+
const selectedFiles = yield react_native_document_picker_1.default.pick({
|
|
77
|
+
type: [...(0, common_1.FetchFileTypes)(accept)],
|
|
78
|
+
allowMultiSelection: !!multiple
|
|
79
|
+
});
|
|
80
|
+
const previewFileList = fileListArray(selectedFiles);
|
|
81
|
+
const fileList = (0, common_1.fileListConvert)(previewFileList);
|
|
82
|
+
onChange(multiple ? fileList : fileList[0]);
|
|
83
|
+
setFiles(previewFileList);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.log(err);
|
|
87
|
+
}
|
|
88
|
+
}), [accept, multiple, onChange, fileListArray]);
|
|
89
|
+
const deleteHandler = (0, react_1.useCallback)((index) => {
|
|
90
|
+
const previewFileList = [...files];
|
|
91
|
+
previewFileList.splice(index, 1);
|
|
92
|
+
const fileList = (0, common_1.fileListConvert)(previewFileList);
|
|
93
|
+
setFiles(previewFileList);
|
|
94
|
+
onChange(multiple ? fileList : null);
|
|
95
|
+
}, [files, onChange, multiple]);
|
|
96
|
+
const imagePreview = (file, index) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
97
|
+
react_1.default.createElement(native_base_1.Image, Object.assign({ source: { uri: file.uri } }, common_1.styles.image)),
|
|
98
|
+
react_1.default.createElement(native_base_1.Button, Object.assign({ onPress: () => { deleteHandler(index); } }, common_1.styles.DeleteButton),
|
|
99
|
+
react_1.default.createElement(native_base_1.MinusIcon, Object.assign({}, common_1.styles.DeleteIcon)))));
|
|
100
|
+
const listPreview = (file, index) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
101
|
+
react_1.default.createElement(native_base_1.Box, Object.assign({}, common_1.styles.PlaceholderTitleBox),
|
|
102
|
+
react_1.default.createElement(native_base_1.Text, Object.assign({}, common_1.styles.PlaceholderTitleText), file.name)),
|
|
103
|
+
react_1.default.createElement(native_base_1.Text, Object.assign({}, common_1.styles.PlaceholderSizeText), `${(file.size / 1000000).toFixed(2)}MB`),
|
|
104
|
+
react_1.default.createElement(native_base_1.Button, Object.assign({ onPress: () => { deleteHandler(index); } }, common_1.styles.DeleteButton),
|
|
105
|
+
react_1.default.createElement(native_base_1.MinusIcon, Object.assign({}, common_1.styles.DeleteIcon)))));
|
|
106
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
107
|
+
react_1.default.createElement(native_base_1.Button, { variant: "outline", onPress: fileSelectionHandler }, "Upload"),
|
|
108
|
+
react_1.default.createElement(native_base_1.HStack, Object.assign({}, common_1.styles.hstack), files.map((file, index) => (react_1.default.createElement(native_base_1.Box, Object.assign({ key: index }, common_1.styles.container), file.type === 'image/jpeg' ? imagePreview(file, index) : listPreview(file, index)))))));
|
|
109
|
+
};
|
|
110
|
+
exports.default = FileUpload;
|
|
@@ -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, { JSXElementConstructor } from 'react';
|
|
21
|
+
import { State, FieldJson } from '@aemforms/af-core';
|
|
22
|
+
export default function withRuleEngine(Component: JSXElementConstructor<any>): (fieldset: State<FieldJson>) => React.JSX.Element | null;
|
|
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const react_1 = __importDefault(require("react"));
|
|
26
|
+
const af_core_1 = require("@aemforms/af-core");
|
|
27
|
+
const af_react_renderer_1 = require("@aemforms/af-react-renderer");
|
|
28
|
+
const DEFAULT_ERROR_MESSAGE = 'There is an error in the field';
|
|
29
|
+
const formateErrorMessage = (state) => {
|
|
30
|
+
const errorMessage = state.errorMessage === '' && state.valid === false ? DEFAULT_ERROR_MESSAGE : state.errorMessage;
|
|
31
|
+
return errorMessage;
|
|
32
|
+
};
|
|
33
|
+
const getValidationState = (state) => {
|
|
34
|
+
const optionalValidation = !(0, af_core_1.checkIfConstraintsArePresent)(state) && state.type === 'string';
|
|
35
|
+
const validationState = state.valid === false ? 'invalid' : ((state.valid === undefined || (0, af_core_1.isEmpty)(state.value) || optionalValidation) ? undefined : 'valid');
|
|
36
|
+
return validationState;
|
|
37
|
+
};
|
|
38
|
+
const getLocalizeLabel = (i18n, state) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const labelId = (0, af_core_1.getOrElse)(state, ['properties', 'afs:translationIds', 'label.value']);
|
|
41
|
+
const label = labelId ? i18n.formatMessage({ id: labelId, defaultMessage: (_a = state === null || state === void 0 ? void 0 : state.label) === null || _a === void 0 ? void 0 : _a.value }) : (_b = state === null || state === void 0 ? void 0 : state.label) === null || _b === void 0 ? void 0 : _b.value;
|
|
42
|
+
return label;
|
|
43
|
+
};
|
|
44
|
+
const getLocalizeDescription = (i18n, state) => {
|
|
45
|
+
const descriptionId = (0, af_core_1.getOrElse)(state, ['properties', 'afs:translationIds', 'description']);
|
|
46
|
+
const description = descriptionId ? i18n.formatMessage({ id: descriptionId, defaultMessage: state === null || state === void 0 ? void 0 : state.description }) : state === null || state === void 0 ? void 0 : state.description;
|
|
47
|
+
return description;
|
|
48
|
+
};
|
|
49
|
+
const getLocalizePlaceholder = (i18n, state) => {
|
|
50
|
+
const placeholderId = (0, af_core_1.getOrElse)(state, ['properties', 'afs:translationIds', 'placeholder']);
|
|
51
|
+
const placeholder = placeholderId ? i18n.formatMessage({ id: placeholderId, defaultMessage: state === null || state === void 0 ? void 0 : state.placeholder }) : state === null || state === void 0 ? void 0 : state.placeholder;
|
|
52
|
+
return placeholder;
|
|
53
|
+
};
|
|
54
|
+
function withRuleEngine(Component) {
|
|
55
|
+
return function WrappedComponent(fieldset) {
|
|
56
|
+
var _a;
|
|
57
|
+
const [state, handlers] = (0, af_react_renderer_1.useRuleEngine)(fieldset);
|
|
58
|
+
const i18n = (0, af_react_renderer_1.useFormIntl)();
|
|
59
|
+
const localizeState = Object.assign(Object.assign({}, state), { description: getLocalizeDescription(i18n, state), placeholder: getLocalizePlaceholder(i18n, state), label: Object.assign(Object.assign({}, state === null || state === void 0 ? void 0 : state.label), { value: getLocalizeLabel(i18n, state), visible: ((_a = state.label) === null || _a === void 0 ? void 0 : _a.visible) !== false }), isError: getValidationState(state) === 'invalid', errorMessage: formateErrorMessage(state) });
|
|
60
|
+
const visible = typeof state.visible === 'undefined' || state.visible;
|
|
61
|
+
return visible ? react_1.default.createElement(Component, Object.assign({}, localizeState, handlers)) : null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.default = withRuleEngine;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { FileOptions, FileType, Styles } from './types';
|
|
21
|
+
export declare const fileTypes: FileOptions;
|
|
22
|
+
export declare const FetchFileTypes: (accept: Array<string> | string) => string[];
|
|
23
|
+
export declare const fileListConvert: (files: FileType[]) => File[];
|
|
24
|
+
export declare const styles: Styles;
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
exports.styles = exports.fileListConvert = exports.FetchFileTypes = exports.fileTypes = void 0;
|
|
26
|
+
const react_native_document_picker_1 = __importDefault(require("react-native-document-picker"));
|
|
27
|
+
exports.fileTypes = {
|
|
28
|
+
'image/*': [react_native_document_picker_1.default.types.images],
|
|
29
|
+
'audio/*': [react_native_document_picker_1.default.types.audio],
|
|
30
|
+
'video/*': [react_native_document_picker_1.default.types.video],
|
|
31
|
+
'text/*': [react_native_document_picker_1.default.types.doc, react_native_document_picker_1.default.types.docx],
|
|
32
|
+
'application/pdf': [react_native_document_picker_1.default.types.pdf],
|
|
33
|
+
'.jpg': [react_native_document_picker_1.default.types.images],
|
|
34
|
+
'.jpeg': [react_native_document_picker_1.default.types.images],
|
|
35
|
+
'.png': [react_native_document_picker_1.default.types.images],
|
|
36
|
+
'.gif': [react_native_document_picker_1.default.types.video],
|
|
37
|
+
'.xml': [react_native_document_picker_1.default.types.plainText],
|
|
38
|
+
'.bat': [react_native_document_picker_1.default.types.plainText],
|
|
39
|
+
'.pdf': [react_native_document_picker_1.default.types.pdf],
|
|
40
|
+
'.zip': [react_native_document_picker_1.default.types.zip],
|
|
41
|
+
'.csv': [react_native_document_picker_1.default.types.csv],
|
|
42
|
+
'.doc': [react_native_document_picker_1.default.types.doc],
|
|
43
|
+
'.docx': [react_native_document_picker_1.default.types.docx],
|
|
44
|
+
'.ppt': [react_native_document_picker_1.default.types.ppt],
|
|
45
|
+
pptx: [react_native_document_picker_1.default.types.pptx],
|
|
46
|
+
xls: [react_native_document_picker_1.default.types.xls],
|
|
47
|
+
xlsx: [react_native_document_picker_1.default.types.xlsx],
|
|
48
|
+
default: [react_native_document_picker_1.default.types.allFiles]
|
|
49
|
+
};
|
|
50
|
+
const FetchFileTypes = (accept) => {
|
|
51
|
+
let acceptFileTypes = [];
|
|
52
|
+
const accepts = Array.isArray(accept) ? accept : accept.split(',');
|
|
53
|
+
accepts.forEach((opt) => {
|
|
54
|
+
acceptFileTypes = [...acceptFileTypes, ...(exports.fileTypes[opt] || exports.fileTypes.default)];
|
|
55
|
+
});
|
|
56
|
+
if (!acceptFileTypes.length) {
|
|
57
|
+
acceptFileTypes.push(react_native_document_picker_1.default.types.allFiles);
|
|
58
|
+
}
|
|
59
|
+
return acceptFileTypes;
|
|
60
|
+
};
|
|
61
|
+
exports.FetchFileTypes = FetchFileTypes;
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
const fileListConvert = (files) => files.map((file) => new File([''], file.uri, Object.assign({}, file)));
|
|
64
|
+
exports.fileListConvert = fileListConvert;
|
|
65
|
+
exports.styles = {
|
|
66
|
+
hstack: {
|
|
67
|
+
alignSelf: 'flex-start',
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
flexWrap: 'wrap'
|
|
70
|
+
},
|
|
71
|
+
container: {
|
|
72
|
+
alignSelf: 'flex-start',
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
flexWrap: 'wrap',
|
|
75
|
+
width: '25%',
|
|
76
|
+
margin: '2',
|
|
77
|
+
height: '95',
|
|
78
|
+
backgroundColor: 'gray.300'
|
|
79
|
+
},
|
|
80
|
+
image: {
|
|
81
|
+
alt: 'Alternate Text',
|
|
82
|
+
size: 'lg',
|
|
83
|
+
borderTopRightRadius: 'xl',
|
|
84
|
+
width: '100%'
|
|
85
|
+
},
|
|
86
|
+
DeleteButton: {
|
|
87
|
+
backgroundColor: 'white',
|
|
88
|
+
borderRadius: 'full',
|
|
89
|
+
position: 'absolute',
|
|
90
|
+
right: '-4',
|
|
91
|
+
top: '-4',
|
|
92
|
+
variant: 'unstyled',
|
|
93
|
+
padding: '3px'
|
|
94
|
+
},
|
|
95
|
+
DeleteIcon: {
|
|
96
|
+
color: 'red.500'
|
|
97
|
+
},
|
|
98
|
+
PlaceholderTitleBox: {
|
|
99
|
+
padding: '2',
|
|
100
|
+
marginTop: '2'
|
|
101
|
+
},
|
|
102
|
+
PlaceholderTitleText: {
|
|
103
|
+
fontSize: '10px',
|
|
104
|
+
numberOfLines: 3
|
|
105
|
+
},
|
|
106
|
+
PlaceholderSizeText: {
|
|
107
|
+
fontSize: '10px',
|
|
108
|
+
position: 'absolute',
|
|
109
|
+
bottom: '2',
|
|
110
|
+
left: '2'
|
|
111
|
+
}
|
|
112
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
/// <reference types="react" />
|
|
21
|
+
declare const _default: {
|
|
22
|
+
form: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldsetJson>) => import("react").JSX.Element;
|
|
23
|
+
'text-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
24
|
+
'multiline-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
25
|
+
'number-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
26
|
+
panel: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldsetJson>) => import("react").JSX.Element | null;
|
|
27
|
+
button: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
28
|
+
repeater: (props: import("./types").REPEATER) => import("react").JSX.Element;
|
|
29
|
+
checkbox: (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
30
|
+
'checkbox-group': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
31
|
+
'radio-group': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
32
|
+
'drop-down': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
33
|
+
'password-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
34
|
+
'plain-text': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
35
|
+
'file-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
36
|
+
'date-input': (fieldset: import("@aemforms/af-core").State<import("@aemforms/af-core").FieldJson>) => import("react").JSX.Element | null;
|
|
37
|
+
};
|
|
38
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 Form_1 = __importDefault(require("../components/Form"));
|
|
26
|
+
const TextField_1 = __importDefault(require("../components/TextField"));
|
|
27
|
+
const NumberField_1 = __importDefault(require("../components/NumberField"));
|
|
28
|
+
const Panel_1 = __importDefault(require("../components/Panel"));
|
|
29
|
+
const Button_1 = __importDefault(require("../components/Button"));
|
|
30
|
+
const Repeater_1 = __importDefault(require("../components/Repeater"));
|
|
31
|
+
const Checkbox_1 = __importDefault(require("../components/Checkbox"));
|
|
32
|
+
const CheckboxGroup_1 = __importDefault(require("../components/CheckboxGroup"));
|
|
33
|
+
const RadioGroup_1 = __importDefault(require("../components/RadioGroup"));
|
|
34
|
+
const DropDown_1 = __importDefault(require("../components/DropDown"));
|
|
35
|
+
const PlainText_1 = __importDefault(require("../components/PlainText"));
|
|
36
|
+
const FileUpload_1 = __importDefault(require("../components/FileUpload"));
|
|
37
|
+
const DatePicker_1 = __importDefault(require("../components/DatePicker"));
|
|
38
|
+
exports.default = {
|
|
39
|
+
form: Form_1.default,
|
|
40
|
+
'text-input': TextField_1.default,
|
|
41
|
+
'multiline-input': TextField_1.default,
|
|
42
|
+
'number-input': NumberField_1.default,
|
|
43
|
+
panel: Panel_1.default,
|
|
44
|
+
button: Button_1.default,
|
|
45
|
+
repeater: Repeater_1.default,
|
|
46
|
+
checkbox: Checkbox_1.default,
|
|
47
|
+
'checkbox-group': CheckboxGroup_1.default,
|
|
48
|
+
'radio-group': RadioGroup_1.default,
|
|
49
|
+
'drop-down': DropDown_1.default,
|
|
50
|
+
'password-input': TextField_1.default,
|
|
51
|
+
'plain-text': PlainText_1.default,
|
|
52
|
+
'file-input': FileUpload_1.default,
|
|
53
|
+
'date-input': DatePicker_1.default
|
|
54
|
+
};
|