dynamic-modal 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-ES.md +45 -3
- package/README.md +45 -3
- package/dist/components/input-upload/input-upload.d.ts +4 -0
- package/dist/components/input-upload/input-upload.js +84 -0
- package/dist/components/make-autocomplete/make-autocomplete.d.ts +4 -0
- package/dist/components/make-autocomplete/make-autocomplete.js +63 -0
- package/dist/components/make-button/make-button.d.ts +4 -0
- package/dist/components/make-button/make-button.js +22 -0
- package/dist/components/make-input/make-input.d.ts +4 -0
- package/dist/components/make-input/make-input.js +63 -0
- package/dist/components/make-multi-select/make-multi-select.d.ts +4 -0
- package/dist/components/make-multi-select/make-multi-select.js +63 -0
- package/dist/components/make-select/make-select.d.ts +4 -0
- package/dist/components/make-select/make-select.js +63 -0
- package/dist/components/make-text/make-text.d.ts +4 -0
- package/dist/components/make-text/make-text.js +11 -0
- package/dist/components/make-textarea/make-textarea.d.ts +4 -0
- package/dist/components/make-textarea/make-textarea.js +63 -0
- package/dist/components/make-title/make-title.d.ts +4 -0
- package/dist/components/make-title/make-title.js +10 -0
- package/dist/components/make-toggle/make-toggle.d.ts +4 -0
- package/dist/components/make-toggle/make-toggle.js +51 -0
- package/dist/components/make-upload/make-upload.d.ts +4 -0
- package/dist/components/make-upload/make-upload.js +26 -0
- package/dist/components/portal/portal.d.ts +3 -0
- package/dist/components/portal/portal.js +55 -0
- package/dist/hooks/field-render.d.ts +19 -0
- package/dist/hooks/field-render.js +83 -0
- package/dist/hooks/modal-handler.d.ts +7 -0
- package/dist/hooks/modal-handler.js +28 -0
- package/dist/interfaces/field.d.ts +27 -0
- package/dist/interfaces/field.js +2 -0
- package/dist/interfaces/input-upload.d.ts +32 -0
- package/dist/interfaces/input-upload.js +2 -0
- package/dist/interfaces/make-autocomplete.d.ts +13 -0
- package/dist/interfaces/make-autocomplete.js +2 -0
- package/dist/interfaces/make-button.d.ts +18 -0
- package/dist/interfaces/make-button.js +2 -0
- package/dist/interfaces/make-field-group.d.ts +11 -0
- package/dist/interfaces/make-field-group.js +2 -0
- package/dist/interfaces/make-field.d.ts +12 -0
- package/dist/interfaces/make-field.js +2 -0
- package/dist/interfaces/make-multi-select.d.ts +12 -0
- package/dist/interfaces/make-multi-select.js +2 -0
- package/dist/interfaces/make-select.d.ts +12 -0
- package/dist/interfaces/make-select.js +2 -0
- package/dist/interfaces/make-text.d.ts +10 -0
- package/dist/interfaces/make-text.js +2 -0
- package/dist/interfaces/make-textarea.d.ts +9 -0
- package/dist/interfaces/make-textarea.js +2 -0
- package/dist/interfaces/make-title.d.ts +3 -0
- package/dist/interfaces/make-title.js +2 -0
- package/dist/interfaces/make-toggle.d.ts +7 -0
- package/dist/interfaces/make-toggle.js +2 -0
- package/dist/interfaces/make-upload.d.ts +11 -0
- package/dist/interfaces/make-upload.js +2 -0
- package/dist/interfaces/modal.d.ts +43 -0
- package/dist/interfaces/modal.js +2 -0
- package/dist/interfaces/option.d.ts +4 -0
- package/dist/interfaces/option.js +2 -0
- package/dist/interfaces/portal.d.ts +7 -0
- package/dist/interfaces/portal.js +2 -0
- package/dist/modal.d.ts +4 -0
- package/dist/modal.js +150 -0
- package/dist/tools/general.d.ts +1 -0
- package/dist/tools/general.js +10 -0
- package/examples/enable-if.ts +1 -0
- package/examples/live-data.ts +2 -1
- package/examples/render-if.ts +1 -0
- package/index.ts +1 -1
- package/package.json +2 -2
- package/src/components/make-autocomplete/make-autocomplete.tsx +2 -2
- package/src/interfaces/modal.ts +4 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
27
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
28
|
+
const field_render_1 = require("../../hooks/field-render");
|
|
29
|
+
const react_2 = require("@nextui-org/react");
|
|
30
|
+
const general_1 = require("../../tools/general");
|
|
31
|
+
const MakeToggle = (props) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const { render, enable, checkField } = (0, field_render_1.useFieldRender)(props);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
const subscription = props.watch((value, { name, type }) => checkField(value, { name, type }));
|
|
36
|
+
return () => subscription.unsubscribe();
|
|
37
|
+
}, [checkField, props, props.watch]);
|
|
38
|
+
return (render
|
|
39
|
+
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: props.element.name, rules: {
|
|
40
|
+
required: props.element.validation.required,
|
|
41
|
+
pattern: {
|
|
42
|
+
value: (_a = props.element.validation.regex) !== null && _a !== void 0 ? _a : /(.*)/,
|
|
43
|
+
message: (_b = props.element.validation.message) !== null && _b !== void 0 ? _b : ''
|
|
44
|
+
}
|
|
45
|
+
}, render: ({ field: { onChange, value } }) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return (react_1.default.createElement(react_2.Switch, Object.assign({}, props.element, { id: (_a = props.element.id) !== null && _a !== void 0 ? _a : (0, general_1.generateId)(), isSelected: value, onValueChange: onChange, isDisabled: (_b = props.element.disabled) !== null && _b !== void 0 ? _b : !enable }), props.element.label));
|
|
48
|
+
} })
|
|
49
|
+
: null);
|
|
50
|
+
};
|
|
51
|
+
exports.default = MakeToggle;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
7
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
8
|
+
const input_upload_1 = __importDefault(require("../input-upload/input-upload"));
|
|
9
|
+
const field_render_1 = require("../../hooks/field-render");
|
|
10
|
+
const MakeUpload = (props) => {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const { render, enable } = (0, field_render_1.useFieldRender)(props);
|
|
13
|
+
return (render
|
|
14
|
+
? react_1.default.createElement(react_hook_form_1.Controller, { control: props.control, name: props.element.name, rules: {
|
|
15
|
+
required: props.element.validation.required,
|
|
16
|
+
pattern: {
|
|
17
|
+
value: (_a = props.element.validation.regex) !== null && _a !== void 0 ? _a : /(.*)/,
|
|
18
|
+
message: (_b = props.element.validation.message) !== null && _b !== void 0 ? _b : ''
|
|
19
|
+
}
|
|
20
|
+
}, render: ({ field: { onChange } }) => {
|
|
21
|
+
var _a;
|
|
22
|
+
return (react_1.default.createElement(input_upload_1.default, { id: props.element.id, name: props.element.name, disabled: (_a = props.element.disabled) !== null && _a !== void 0 ? _a : !enable, onChange: onChange, label: props.element.label, helpText: props.element.helpText, style: props.element.styles, accept: props.element.accept, read: props.element.read }));
|
|
23
|
+
} })
|
|
24
|
+
: null);
|
|
25
|
+
};
|
|
26
|
+
exports.default = MakeUpload;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Portal = void 0;
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const react_dom_1 = require("react-dom");
|
|
30
|
+
const Portal = (props) => {
|
|
31
|
+
const ref = (0, react_1.useRef)(null);
|
|
32
|
+
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
var _a;
|
|
35
|
+
if (mounted && !props.portalOpen && props.closeTime > 0) {
|
|
36
|
+
const timeoutId = setTimeout(() => {
|
|
37
|
+
setMounted(false);
|
|
38
|
+
ref.current = null;
|
|
39
|
+
}, props.closeTime);
|
|
40
|
+
return () => clearTimeout(timeoutId);
|
|
41
|
+
}
|
|
42
|
+
else if (mounted && !props.portalOpen) {
|
|
43
|
+
setMounted(false);
|
|
44
|
+
ref.current = null;
|
|
45
|
+
}
|
|
46
|
+
else if (!mounted && props.portalOpen) {
|
|
47
|
+
ref.current = document.querySelector((_a = props.portalTag) !== null && _a !== void 0 ? _a : '#portal');
|
|
48
|
+
setMounted(true);
|
|
49
|
+
}
|
|
50
|
+
}, [mounted, props.closeTime, props.portalOpen, props.portalTag]);
|
|
51
|
+
return (mounted && ref.current
|
|
52
|
+
? (0, react_dom_1.createPortal)(react_1.default.createElement("div", { className: 'transition-all delay-100 fixed top-0 left-0 w-full h-full grid place-items-center bg-black bg-opacity-40 z-20' }, props.children), ref.current)
|
|
53
|
+
: null);
|
|
54
|
+
};
|
|
55
|
+
exports.Portal = Portal;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IField, IFieldProps } from '../interfaces/field';
|
|
2
|
+
import { IOption } from '../interfaces/option';
|
|
3
|
+
import { IModalLiveDataCondition } from '../interfaces/modal';
|
|
4
|
+
export type IFormData = Record<string, unknown>;
|
|
5
|
+
export interface IWatchEvent {
|
|
6
|
+
name: string | undefined;
|
|
7
|
+
type: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface IFieldRender {
|
|
10
|
+
render: boolean | null;
|
|
11
|
+
enable: boolean | null;
|
|
12
|
+
checkField: (formData: IFormData, { name, type }: IWatchEvent) => void;
|
|
13
|
+
liveData?: Array<IOption>;
|
|
14
|
+
liveSearching?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IFieldRenderProps extends Pick<IFieldProps, 'setValue'> {
|
|
17
|
+
element: Partial<Pick<IField, 'enableIf' | 'renderIf' | 'name'>> & Partial<Record<'liveData', IModalLiveDataCondition>>;
|
|
18
|
+
}
|
|
19
|
+
export declare const useFieldRender: (props: IFieldRenderProps) => IFieldRender;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.useFieldRender = void 0;
|
|
14
|
+
const react_1 = require("react");
|
|
15
|
+
const useFieldRender = (props) => {
|
|
16
|
+
const [render, setRender] = (0, react_1.useState)(null);
|
|
17
|
+
const [enable, setEnable] = (0, react_1.useState)(null);
|
|
18
|
+
const [liveSearching, setLiveSearching] = (0, react_1.useState)(false);
|
|
19
|
+
const [liveData, setLiveData] = (0, react_1.useState)(undefined);
|
|
20
|
+
const renderCondition = (0, react_1.useMemo)(() => {
|
|
21
|
+
const isRender = props.element.renderIf !== undefined;
|
|
22
|
+
if (render === null)
|
|
23
|
+
setRender(!isRender);
|
|
24
|
+
return isRender;
|
|
25
|
+
}, [props.element.renderIf, render]);
|
|
26
|
+
const enableCondition = (0, react_1.useMemo)(() => {
|
|
27
|
+
const isEnable = props.element.enableIf !== undefined;
|
|
28
|
+
if (enable === null)
|
|
29
|
+
setEnable(!isEnable);
|
|
30
|
+
return isEnable;
|
|
31
|
+
}, [props.element.enableIf, enable]);
|
|
32
|
+
const liveDataCondition = (0, react_1.useMemo)(() => {
|
|
33
|
+
return props.element.liveData !== undefined;
|
|
34
|
+
}, [props.element.liveData]);
|
|
35
|
+
const renderConditionList = (0, react_1.useMemo)(() => {
|
|
36
|
+
return renderCondition ? Object.keys(props.element.renderIf) : [];
|
|
37
|
+
}, [props.element.renderIf, renderCondition]);
|
|
38
|
+
const enableConditionList = (0, react_1.useMemo)(() => {
|
|
39
|
+
return enableCondition ? Object.keys(props.element.enableIf) : [];
|
|
40
|
+
}, [enableCondition, props.element.enableIf]);
|
|
41
|
+
const liveDataAction = (0, react_1.useCallback)((field, formData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
if (typeof field === 'string' && ((_a = props.element.liveData) === null || _a === void 0 ? void 0 : _a.action)) {
|
|
44
|
+
const options = props.element.liveData.action(field, formData);
|
|
45
|
+
return options !== null && options !== void 0 ? options : [];
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}), [props.element.liveData]);
|
|
49
|
+
const checkField = (0, react_1.useCallback)((formData_1, _a) => __awaiter(void 0, [formData_1, _a], void 0, function* (formData, { name }) {
|
|
50
|
+
var _b;
|
|
51
|
+
const key = name !== null && name !== void 0 ? name : '';
|
|
52
|
+
const targetField = formData[key];
|
|
53
|
+
if (renderCondition && renderConditionList.includes(key)) {
|
|
54
|
+
const renderStatus = props.element.renderIf[key].includes(targetField);
|
|
55
|
+
if (render !== renderStatus)
|
|
56
|
+
setRender(renderStatus);
|
|
57
|
+
}
|
|
58
|
+
else if (enableCondition && enableConditionList.includes(key)) {
|
|
59
|
+
const enableStatus = props.element.enableIf[key].includes(targetField);
|
|
60
|
+
if (enable !== enableStatus)
|
|
61
|
+
setEnable(enableStatus);
|
|
62
|
+
}
|
|
63
|
+
if (liveDataCondition && key === ((_b = props.element.liveData) === null || _b === void 0 ? void 0 : _b.condition)) {
|
|
64
|
+
if (targetField) {
|
|
65
|
+
setLiveSearching(true);
|
|
66
|
+
const options = yield liveDataAction(targetField, formData);
|
|
67
|
+
if (liveData && JSON.stringify(liveData) !== JSON.stringify(options)) {
|
|
68
|
+
props.setValue(props.element.name, options);
|
|
69
|
+
}
|
|
70
|
+
setLiveData(options);
|
|
71
|
+
setLiveSearching(false);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}), [enable, enableCondition, enableConditionList, liveData, liveDataAction, liveDataCondition, props, render, renderCondition, renderConditionList]);
|
|
75
|
+
return {
|
|
76
|
+
render,
|
|
77
|
+
enable,
|
|
78
|
+
checkField,
|
|
79
|
+
liveData,
|
|
80
|
+
liveSearching
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.useFieldRender = useFieldRender;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useModalHandler = useModalHandler;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useModalHandler() {
|
|
7
|
+
const initialState = {
|
|
8
|
+
modalProps: {
|
|
9
|
+
config: {},
|
|
10
|
+
close: () => { },
|
|
11
|
+
open: false,
|
|
12
|
+
},
|
|
13
|
+
openModal: () => { },
|
|
14
|
+
};
|
|
15
|
+
const [modalConfig, setModalConfig] = (0, react_1.useState)(initialState);
|
|
16
|
+
const openModal = (config) => {
|
|
17
|
+
if (!config) {
|
|
18
|
+
alert(`¡WARNING! this modal was not returned config, please check before use`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
setModalConfig({ openModal, modalProps: { config, open: true, close } });
|
|
22
|
+
};
|
|
23
|
+
const closeModal = () => setModalConfig(initialState);
|
|
24
|
+
return {
|
|
25
|
+
openModal,
|
|
26
|
+
modalProps: Object.assign(Object.assign({}, modalConfig.modalProps), { close: closeModal }),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { Control, FieldValues, UseFormSetValue, UseFormWatch } from 'react-hook-form';
|
|
3
|
+
import { IOption } from './option';
|
|
4
|
+
export interface IFieldLiveData {
|
|
5
|
+
action: (data: string, ...args: unknown[]) => Promise<Array<IOption>>;
|
|
6
|
+
condition: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IField {
|
|
9
|
+
name: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
styles?: CSSProperties;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
renderIf?: Record<string, Array<string | number>>;
|
|
15
|
+
enableIf?: Record<string, Array<string | number>>;
|
|
16
|
+
validation: {
|
|
17
|
+
required: boolean;
|
|
18
|
+
regex?: RegExp;
|
|
19
|
+
message?: string;
|
|
20
|
+
};
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface IFieldProps {
|
|
24
|
+
control: Control<FieldValues, unknown>;
|
|
25
|
+
watch: UseFormWatch<FieldValues>;
|
|
26
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChangeEvent, CSSProperties } from 'react';
|
|
2
|
+
export interface IFileResult {
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
data: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IFile {
|
|
8
|
+
data?: string;
|
|
9
|
+
name: string;
|
|
10
|
+
size: number;
|
|
11
|
+
}
|
|
12
|
+
export interface IInputState {
|
|
13
|
+
state: boolean;
|
|
14
|
+
file: IFile;
|
|
15
|
+
}
|
|
16
|
+
export interface IInputStorage {
|
|
17
|
+
setData: (file: IInputState) => void;
|
|
18
|
+
clearFuntion: () => void;
|
|
19
|
+
}
|
|
20
|
+
export interface IInputUpload {
|
|
21
|
+
id?: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
onChange: (event: ChangeEvent<HTMLInputElement> | IFileResult | FileList | null) => void;
|
|
24
|
+
accept?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
helpText?: string;
|
|
27
|
+
clearfunction?: () => void;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
name: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
read?: boolean;
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IField, IFieldProps } from './field';
|
|
2
|
+
import { IModalLiveDataCondition } from './modal';
|
|
3
|
+
import { IOption } from './option';
|
|
4
|
+
export interface IMakeAutoComplete extends IField {
|
|
5
|
+
elementType: 'autocomplete';
|
|
6
|
+
options: Array<IOption>;
|
|
7
|
+
defaultOption?: boolean;
|
|
8
|
+
defaultOptionName?: string;
|
|
9
|
+
liveData?: IModalLiveDataCondition;
|
|
10
|
+
}
|
|
11
|
+
export interface IMakeAutoCompleteProps extends IFieldProps {
|
|
12
|
+
element: IMakeAutoComplete;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { IFieldProps } from './field';
|
|
3
|
+
export interface IMakeButton {
|
|
4
|
+
elementType: 'button';
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
variant?: 'solid' | 'light' | 'flat' | 'bordered' | 'faded' | 'shadow' | 'ghost';
|
|
8
|
+
text?: string;
|
|
9
|
+
type?: 'button' | 'submit' | 'reset';
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
iconName?: string;
|
|
12
|
+
iconSize?: number | string;
|
|
13
|
+
iconClassName?: CSSProperties;
|
|
14
|
+
color?: 'primary' | 'secondary' | 'default' | 'success' | 'warning' | 'danger';
|
|
15
|
+
}
|
|
16
|
+
export interface IMakeButtonProps extends IFieldProps {
|
|
17
|
+
element: IMakeButton;
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { IFieldProps } from './field';
|
|
3
|
+
import { IModalField } from './modal';
|
|
4
|
+
export interface IMakeFieldGroup {
|
|
5
|
+
elementType: 'group';
|
|
6
|
+
groups: Array<IModalField>;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
}
|
|
9
|
+
export interface IMakeFieldGroupProps extends IFieldProps {
|
|
10
|
+
element: IMakeFieldGroup;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLInputTypeAttribute } from 'react';
|
|
2
|
+
import { IField, IFieldProps } from './field';
|
|
3
|
+
export interface IMakeInput extends IField {
|
|
4
|
+
elementType: 'input';
|
|
5
|
+
placeHolder?: string;
|
|
6
|
+
min?: string;
|
|
7
|
+
max?: string;
|
|
8
|
+
type?: HTMLInputTypeAttribute;
|
|
9
|
+
}
|
|
10
|
+
export interface IMakeInputProps extends IFieldProps {
|
|
11
|
+
element: IMakeInput;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IOption } from './option';
|
|
2
|
+
import { IField, IFieldProps } from './field';
|
|
3
|
+
import { IModalLiveDataCondition } from './modal';
|
|
4
|
+
export interface IMakeMultiSelect extends Omit<IField, 'defaultValue'> {
|
|
5
|
+
elementType: 'multiselect';
|
|
6
|
+
options: Array<IOption>;
|
|
7
|
+
liveData?: IModalLiveDataCondition;
|
|
8
|
+
defaultValue?: Array<string>;
|
|
9
|
+
}
|
|
10
|
+
export interface IMakeMultiSelectProps extends IFieldProps {
|
|
11
|
+
element: IMakeMultiSelect;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IField, IFieldProps } from './field';
|
|
2
|
+
import { IModalLiveDataCondition } from './modal';
|
|
3
|
+
export interface IMakeSelect extends IField {
|
|
4
|
+
elementType: 'select';
|
|
5
|
+
options: Array<Record<'id' | 'name', string>>;
|
|
6
|
+
defaultOption?: boolean;
|
|
7
|
+
defaultOptionName?: string;
|
|
8
|
+
liveData?: IModalLiveDataCondition;
|
|
9
|
+
}
|
|
10
|
+
export interface IMakeSelectProps extends IFieldProps {
|
|
11
|
+
element: IMakeSelect;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { IFieldProps } from './field';
|
|
3
|
+
export interface IMakeText {
|
|
4
|
+
elementType: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
styles?: CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
export interface IMakeTextProps extends IFieldProps {
|
|
9
|
+
element: IMakeText;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IField, IFieldProps } from './field';
|
|
2
|
+
export interface IMakeUpload extends Omit<IField, 'defaultValue'> {
|
|
3
|
+
elementType: 'upload';
|
|
4
|
+
helpText?: string;
|
|
5
|
+
read: boolean;
|
|
6
|
+
image?: boolean;
|
|
7
|
+
accept?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface IMakeUploadProps extends IFieldProps {
|
|
10
|
+
element: IMakeUpload;
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { IMakeSelect } from './make-select';
|
|
3
|
+
import { IMakeInput } from './make-field';
|
|
4
|
+
import { IMakeTextarea } from './make-textarea';
|
|
5
|
+
import { IMakeToggle } from './make-toggle';
|
|
6
|
+
import { IMakeMultiSelect } from './make-multi-select';
|
|
7
|
+
import { IMakeText } from './make-text';
|
|
8
|
+
import { IMakeFieldGroup } from './make-field-group';
|
|
9
|
+
import { IMakeUpload } from './make-upload';
|
|
10
|
+
import { IOption } from './option';
|
|
11
|
+
import { IMakeButton } from './make-button';
|
|
12
|
+
import { IMakeAutoComplete } from './make-autocomplete';
|
|
13
|
+
export type IModalField = IMakeSelect | IMakeInput | IMakeFieldGroup | IMakeTextarea | IMakeToggle | IMakeMultiSelect | IMakeText | IMakeUpload | IMakeButton | IMakeAutoComplete;
|
|
14
|
+
export type IFormField = IMakeSelect | IMakeInput | IMakeTextarea | IMakeToggle | IMakeMultiSelect;
|
|
15
|
+
export type IModalRenderCondition = Record<string, Array<string | number>>;
|
|
16
|
+
export type IModalLiveDataCondition = {
|
|
17
|
+
action: (data: string, ...args: any[]) => Promise<Array<IOption>>;
|
|
18
|
+
condition: string;
|
|
19
|
+
};
|
|
20
|
+
export interface IModalConfigProps {
|
|
21
|
+
fields: Array<IModalField>;
|
|
22
|
+
title: string;
|
|
23
|
+
action: {
|
|
24
|
+
name: string;
|
|
25
|
+
action?: (data: any) => void;
|
|
26
|
+
hide?: boolean;
|
|
27
|
+
};
|
|
28
|
+
cancel?: {
|
|
29
|
+
name?: string;
|
|
30
|
+
action?: () => void;
|
|
31
|
+
hide?: boolean;
|
|
32
|
+
};
|
|
33
|
+
reservedData?: Record<string, string | number>;
|
|
34
|
+
styles?: CSSProperties;
|
|
35
|
+
overFlowBody?: string | number;
|
|
36
|
+
minHeightBody?: string | number;
|
|
37
|
+
}
|
|
38
|
+
export type IModalConfigLoader<T = any, D = any> = (props: T, action: (modalResult: D) => void) => IModalConfigProps;
|
|
39
|
+
export interface IModal {
|
|
40
|
+
open: boolean;
|
|
41
|
+
close: () => void;
|
|
42
|
+
config: IModalConfigProps;
|
|
43
|
+
}
|
package/dist/modal.d.ts
ADDED