module-package-comp 1.1.0 → 1.2.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/dist/component/ComponentDisplayer.d.ts +2 -2
- package/dist/component/ComponentDisplayer.js +26 -5
- package/dist/component/ComponentDisplayer.js.map +1 -1
- package/dist/component/PrimaryBtn.d.ts +1 -3
- package/dist/component/PrimaryBtn.js +2 -2
- package/dist/component/PrimaryBtn.js.map +1 -1
- package/dist/component/ShowAttr.js +3 -2
- package/dist/component/ShowAttr.js.map +1 -1
- package/dist/component/ShowErrors.d.ts +3 -0
- package/dist/component/ShowErrors.js +6 -0
- package/dist/component/ShowErrors.js.map +1 -0
- package/dist/component/icons/WrongIcon.d.ts +1 -0
- package/dist/component/icons/WrongIcon.js +5 -0
- package/dist/component/icons/WrongIcon.js.map +1 -0
- package/dist/component/inputs/Error.d.ts +3 -0
- package/dist/component/inputs/Error.js +6 -0
- package/dist/component/inputs/Error.js.map +1 -0
- package/dist/component/inputs/Input.d.ts +5 -3
- package/dist/component/inputs/Input.js +5 -3
- package/dist/component/inputs/Input.js.map +1 -1
- package/dist/component/inputs/LableledInput.js +1 -1
- package/dist/component/inputs/LableledInput.js.map +1 -1
- package/dist/component/inputs/MultiSelect.js +0 -1
- package/dist/component/inputs/MultiSelect.js.map +1 -1
- package/dist/component/inputs/Select.js +1 -1
- package/dist/component/inputs/Select.js.map +1 -1
- package/dist/component/inputs/ShowErrors.d.ts +3 -0
- package/dist/component/inputs/ShowErrors.js +6 -0
- package/dist/component/inputs/ShowErrors.js.map +1 -0
- package/dist/index.css +64 -0
- package/dist/util/type.d.ts +4 -2
- package/package.json +1 -1
- package/src/component/ComponentDisplayer.tsx +40 -15
- package/src/component/PrimaryBtn.tsx +1 -9
- package/src/component/ShowAttr.tsx +4 -1
- package/src/component/ShowErrors.tsx +20 -0
- package/src/component/icons/WrongIcon.tsx +30 -0
- package/src/component/inputs/Input.tsx +16 -5
- package/src/component/inputs/LableledInput.tsx +2 -2
- package/src/component/inputs/MultiSelect.tsx +0 -1
- package/src/component/inputs/Select.tsx +4 -2
- package/src/util/type.ts +4 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Component, DataJSON } from "../util/type";
|
|
2
2
|
type ComponentDisplayerProps = {
|
|
3
|
-
|
|
3
|
+
component: Component;
|
|
4
4
|
data: DataJSON;
|
|
5
5
|
setData: (data: DataJSON) => void;
|
|
6
6
|
onSubmit: () => void;
|
|
7
7
|
};
|
|
8
|
-
export declare function ComponentDisplayer({
|
|
8
|
+
export declare function ComponentDisplayer({ component, data, setData, onSubmit, }: ComponentDisplayerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -2,10 +2,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { ShowAttr } from "./ShowAttr";
|
|
4
4
|
import PrimaryBtn from "./PrimaryBtn";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import ShowErrors from "./ShowErrors";
|
|
6
|
+
export function ComponentDisplayer({ component, data, setData, onSubmit, }) {
|
|
7
|
+
const [errors, setErrors] = useState([]);
|
|
8
|
+
return (_jsxs("form", { onSubmit: (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
const errs = checkRequired(component.attributes, data);
|
|
11
|
+
if (errs.length === 0) {
|
|
12
|
+
onSubmit();
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setErrors(errs);
|
|
16
|
+
}
|
|
17
|
+
}, className: "min-w-72", children: [_jsx("h1", { className: "font-bold text-center text-blue-800 text-4xl mb-8", children: component.label }), _jsx("div", { className: "space-y-3", children: component.attributes.map((attr) => {
|
|
18
|
+
if (canShow(attr, data, component.conditions || [])) {
|
|
9
19
|
return (_jsx(ShowAttr, { attribute: attr, value: data[attr.name] ? String(data[attr.name]) : "", setValue: (s) => {
|
|
10
20
|
const temp = Object.assign({}, data);
|
|
11
21
|
temp[attr.name] = s;
|
|
@@ -19,7 +29,18 @@ export function ComponentDisplayer({ components, data, setData, onSubmit, }) {
|
|
|
19
29
|
setData(temp);
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
|
-
}) }), _jsx("div", { className: "flex justify-center my-8", children: _jsx(PrimaryBtn, {
|
|
32
|
+
}) }), errors.length !== 0 && (_jsx("div", { className: "my-6", children: _jsx(ShowErrors, { errors: errors }) })), _jsx("div", { className: "flex justify-center my-8", children: _jsx(PrimaryBtn, { text: "Submit" }) })] }));
|
|
33
|
+
}
|
|
34
|
+
// check the required attributes and return array string of errors
|
|
35
|
+
function checkRequired(attributes, data) {
|
|
36
|
+
const requiredAttributes = attributes.filter((attr) => { var _a; return (_a = attr.settings) === null || _a === void 0 ? void 0 : _a.required; });
|
|
37
|
+
const errors = [];
|
|
38
|
+
requiredAttributes.forEach((attr) => {
|
|
39
|
+
if (!data[attr.name]) {
|
|
40
|
+
errors.push(`${attr.label} is required`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return errors;
|
|
23
44
|
}
|
|
24
45
|
function canShow(attr, data, conds) {
|
|
25
46
|
const conditions = conds.filter((c) => c[c.length - 1].delimiter === attr.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComponentDisplayer.js","sourceRoot":"","sources":["../../src/component/ComponentDisplayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ComponentDisplayer.js","sourceRoot":"","sources":["../../src/component/ComponentDisplayer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AAStC,MAAM,UAAU,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@
|
|
|
1
1
|
type props = {
|
|
2
2
|
text: string;
|
|
3
|
-
clickFn: () => void;
|
|
4
|
-
className?: string;
|
|
5
3
|
disabled?: boolean;
|
|
6
4
|
};
|
|
7
|
-
export default function PrimaryBtn({ text,
|
|
5
|
+
export default function PrimaryBtn({ text, disabled }: props): import("react/jsx-runtime").JSX.Element;
|
|
8
6
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
export default function PrimaryBtn({ text,
|
|
3
|
+
export default function PrimaryBtn({ text, disabled }) {
|
|
4
4
|
const btn = useRef(null);
|
|
5
|
-
return (_jsx("button", { type: "submit", ref: btn,
|
|
5
|
+
return (_jsx("button", { type: "submit", ref: btn, className: "rounded-2xl bg-[#0096DC] bg-opacity-85 px-8 py-2 font-bold text-white-shade hover:bg-opacity-100", disabled: disabled, children: text }));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=PrimaryBtn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimaryBtn.js","sourceRoot":"","sources":["../../src/component/PrimaryBtn.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PrimaryBtn.js","sourceRoot":"","sources":["../../src/component/PrimaryBtn.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO/B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAS;IAC1D,MAAM,GAAG,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAC5C,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,GAAG,EAAE,GAAG,EACR,SAAS,EACP,kGAAkG,EAEpG,QAAQ,EAAE,QAAQ,YAEjB,IAAI,GACE,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,7 @@ import LabeledMutliSelect from "./inputs/LabeledMutliSelect";
|
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { Parser } from "expr-eval";
|
|
8
8
|
export function ShowAttr({ attribute, value, setValue, showLabel = true, data, }) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
9
10
|
const label = useMemo(() => (showLabel ? attribute.label || "" : ""), [attribute.label]);
|
|
10
11
|
const type = useMemo(() => {
|
|
11
12
|
if (attribute.type)
|
|
@@ -13,9 +14,9 @@ export function ShowAttr({ attribute, value, setValue, showLabel = true, data, }
|
|
|
13
14
|
}, [attribute.type]);
|
|
14
15
|
switch (type) {
|
|
15
16
|
case AttributeTypeEnum.NUMBER:
|
|
16
|
-
return (_jsx(LabeledInput, { label: label, value: value, setValue: setValue, type: "number" }));
|
|
17
|
+
return (_jsx(LabeledInput, { label: label, value: value, setValue: setValue, type: "number", max: Number((_a = attribute.settings) === null || _a === void 0 ? void 0 : _a.max), min: Number((_b = attribute.settings) === null || _b === void 0 ? void 0 : _b.min) }));
|
|
17
18
|
case AttributeTypeEnum.TEXT:
|
|
18
|
-
return (_jsx(LabeledInput, { label: label, value: value, setValue: setValue, type: "text" }));
|
|
19
|
+
return (_jsx(LabeledInput, { label: label, value: value, setValue: setValue, type: "text", maxLength: (_c = attribute.settings) === null || _c === void 0 ? void 0 : _c.max, minLength: (_d = attribute.settings) === null || _d === void 0 ? void 0 : _d.min }));
|
|
19
20
|
case AttributeTypeEnum.LIST:
|
|
20
21
|
return (_jsx(LabeledSelect, { label: label, selected: value, setSelected: setValue, options: attribute.content || [] }));
|
|
21
22
|
case AttributeTypeEnum.BOOLEAN:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShowAttr.js","sourceRoot":"","sources":["../../src/component/ShowAttr.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,iBAAiB,EAAqB,MAAM,cAAc,CAAC;AAC/E,OAAO,aAAa,MAAM,yBAAyB,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GAAG,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACnD,OAAO,sBAAI,MAAM,GAAK,CAAC;YACzB,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe,EAAE,IAAc;IACvD,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAC9B,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAA0C,CAAW,CAAC;IAC7E,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import WrongIcon from "./icons/WrongIcon";
|
|
3
|
+
export default function ShowErrors({ errors }) {
|
|
4
|
+
return (_jsxs("div", { className: "bg-red-50 border border-red-300 text-red-600 px-3 py-2 rounded-xl relative", role: "alert", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(WrongIcon, {}), _jsxs("span", { className: "font-semibold", children: [errors.length, " error found."] })] }), _jsx("ul", { className: "mt-2 ml-7 list-disc list-inside", children: errors.map((error) => (_jsx("li", { children: error }))) })] }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ShowErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowErrors.js","sourceRoot":"","sources":["../../src/component/ShowErrors.tsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,MAAM,EAAwB;IACjE,OAAO,CACL,eACE,SAAS,EAAC,4EAA4E,EACtF,IAAI,EAAC,OAAO,aAEZ,eAAK,SAAS,EAAC,yBAAyB,aACtC,KAAC,SAAS,KAAG,EACb,gBAAM,SAAS,EAAC,eAAe,aAAE,MAAM,CAAC,MAAM,qBAAqB,IAC/D,EACN,aAAI,SAAS,EAAC,iCAAiC,YAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,uBAAK,KAAK,GAAM,CACjB,CAAC,GACC,IACD,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function WrongIcon(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export default function WrongIcon() {
|
|
3
|
+
return (_jsxs("svg", { fill: "#c01c28", width: "22px", height: "22px", viewBox: "0 0 200 200", "data-name": "Layer 1", id: "Layer_1", xmlns: "http://www.w3.org/2000/svg", stroke: "#c01c28", children: [_jsx("g", { id: "SVGRepo_bgCarrier", "stroke-width": "0" }), _jsx("g", { id: "SVGRepo_tracerCarrier", "stroke-linecap": "round", "stroke-linejoin": "round" }), _jsxs("g", { id: "SVGRepo_iconCarrier", children: [_jsx("title", {}), _jsx("path", { d: "M100,15a85,85,0,1,0,85,85A84.93,84.93,0,0,0,100,15Zm0,150a65,65,0,1,1,65-65A64.87,64.87,0,0,1,100,165Z" }), _jsx("path", { d: "M128.5,74a9.67,9.67,0,0,0-14,0L100,88.5l-14-14a9.9,9.9,0,0,0-14,14l14,14-14,14a9.9,9.9,0,0,0,14,14l14-14,14,14a9.9,9.9,0,0,0,14-14l-14-14,14-14A10.77,10.77,0,0,0,128.5,74Z" })] })] }));
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=WrongIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrongIcon.js","sourceRoot":"","sources":["../../../src/component/icons/WrongIcon.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,CACL,eACE,IAAI,EAAC,SAAS,EACd,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,OAAO,EAAC,aAAa,eACX,SAAS,EACnB,EAAE,EAAC,SAAS,EACZ,KAAK,EAAC,4BAA4B,EAClC,MAAM,EAAC,SAAS,aAEhB,YAAG,EAAE,EAAC,mBAAmB,kBAAc,GAAG,GAAG,EAE7C,YACE,EAAE,EAAC,uBAAuB,oBACX,OAAO,qBACN,OAAO,GACvB,EAEF,aAAG,EAAE,EAAC,qBAAqB,aACzB,iBAAS,EAET,eAAM,CAAC,EAAC,wGAAwG,GAAG,EAEnH,eAAM,CAAC,EAAC,6KAA6K,GAAG,IACtL,IACA,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import WrongIcon from "../icons/WrongIcon";
|
|
3
|
+
export default function ShowErrors({ errors }) {
|
|
4
|
+
return (_jsxs("div", { className: "bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative", role: "alert", children: [_jsxs("div", { className: "flex items-center", children: [_jsx(WrongIcon, {}), _jsx("span", { className: "font-bold", children: "There were 2 errors with your submission" })] }), _jsx("ul", { className: "mt-2 ml-6 list-disc list-inside", children: errors.map((error) => (_jsx("li", { children: error }))) })] }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=Error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../../src/component/inputs/Error.tsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,MAAM,EAAwB;IACjE,OAAO,CACL,eACE,SAAS,EAAC,0EAA0E,EACpF,IAAI,EAAC,OAAO,aAEZ,eAAK,SAAS,EAAC,mBAAmB,aAChC,KAAC,SAAS,KAAG,EACb,eAAM,SAAS,EAAC,WAAW,yDAEpB,IACH,EACN,aAAI,SAAS,EAAC,iCAAiC,YAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,uBAAK,KAAK,GAAM,CACjB,CAAC,GACC,IACD,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -3,11 +3,13 @@ export type InputProps = {
|
|
|
3
3
|
value?: string;
|
|
4
4
|
setValue: (s: string) => void;
|
|
5
5
|
type: HTMLInputTypeAttribute;
|
|
6
|
-
className?: string;
|
|
7
6
|
onBlur?: () => void;
|
|
8
|
-
maxLength?:
|
|
7
|
+
maxLength?: string;
|
|
8
|
+
minLength?: string;
|
|
9
|
+
max?: number;
|
|
10
|
+
min?: number;
|
|
9
11
|
placeholder?: string;
|
|
10
12
|
disabled?: boolean;
|
|
11
13
|
checked?: boolean;
|
|
12
14
|
};
|
|
13
|
-
export default function Input({ value, setValue,
|
|
15
|
+
export default function Input({ value, setValue, type, onBlur, maxLength, minLength, max, min, placeholder, disabled, checked, }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export default function Input({ value, setValue,
|
|
3
|
-
|
|
2
|
+
export default function Input({ value, setValue, type, onBlur, maxLength, minLength, max, min, placeholder, disabled, checked, }) {
|
|
3
|
+
console.log();
|
|
4
|
+
console.log(maxLength);
|
|
5
|
+
return (_jsx("input", { type: type, className: `py-1.5 px-3 ${type === "checkbox" ? "size-5" : "w-full"} border-2 border-gray-300 rounded-xl text-base focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none`, value: value, onChange: (e) => type === "checkbox"
|
|
4
6
|
? setValue(String(e.target.checked))
|
|
5
|
-
: setValue(e.target.value), disabled: disabled, onBlur: onBlur, maxLength: maxLength, placeholder: placeholder, checked: checked }));
|
|
7
|
+
: setValue(e.target.value), disabled: disabled, onBlur: onBlur, maxLength: maxLength && !isNaN(Number(maxLength)) ? Number(maxLength) : undefined, minLength: minLength && !isNaN(Number(minLength)) ? Number(minLength) : undefined, max: max, min: min, placeholder: placeholder, checked: checked }));
|
|
6
8
|
}
|
|
7
9
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/component/inputs/Input.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/component/inputs/Input.tsx"],"names":[],"mappings":";AAgBA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,GAAG,EACH,GAAG,EACH,WAAW,EACX,QAAQ,EACR,OAAO,GACI;IACX,OAAO,CAAC,GAAG,EAEV,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,CACL,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,eAAe,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,2IAA2I,EAC9M,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACd,IAAI,KAAK,UAAU;YACjB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACpC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAE9B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EACP,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAExE,SAAS,EACP,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAExE,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,GAChB,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -13,6 +13,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import Input from "./Input";
|
|
14
14
|
export default function LabeledInput(_a) {
|
|
15
15
|
var { label } = _a, inputProps = __rest(_a, ["label"]);
|
|
16
|
-
return (_jsxs("div", { className: "w-full", children: [_jsx("label", { className: "block text-
|
|
16
|
+
return (_jsxs("div", { className: "w-full flex gap-2 items-center", children: [_jsx("label", { className: "block text-base font-bold mb-1", children: label }), _jsx(Input, Object.assign({}, inputProps))] }));
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=LableledInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LableledInput.js","sourceRoot":"","sources":["../../../src/component/inputs/LableledInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAqB,MAAM,SAAS,CAAC;AAM5C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAA+B;QAA/B,EAAE,KAAK,OAAwB,EAAnB,UAAU,cAAtB,SAAwB,CAAF;IACzD,OAAO,CACL,eAAK,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"LableledInput.js","sourceRoot":"","sources":["../../../src/component/inputs/LableledInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAqB,MAAM,SAAS,CAAC;AAM5C,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAA+B;QAA/B,EAAE,KAAK,OAAwB,EAAnB,UAAU,cAAtB,SAAwB,CAAF;IACzD,OAAO,CACL,eAAK,SAAS,EAAC,gCAAgC,aAC7C,gBAAO,SAAS,EAAC,gCAAgC,YAAE,KAAK,GAAS,EACjE,KAAC,KAAK,oBAAK,UAAU,EAAI,IACrB,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.js","sourceRoot":"","sources":["../../../src/component/inputs/MultiSelect.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,MAAM,WAAW,GAA+B,CAAC,EAC/C,OAAO,EACP,eAAe,EACf,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEzC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;IAEhD,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;QAC3C,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,CAAC,GAAG,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,CAAC;IACF,
|
|
1
|
+
{"version":3,"file":"MultiSelect.js","sourceRoot":"","sources":["../../../src/component/inputs/MultiSelect.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQxC,M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EAAC,qFAAqF,YAE9F,MAAM,IAHF,MAAM,CAIN,CACR,CAAC,CACH,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,uBAAuB,+BAAsB,CAC9D,GACG,EACL,MAAM,IAAI,CACT,eAAK,SAAS,EAAC,0FAA0F,aACvG,gBACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,2CAA2C,EACrD,WAAW,EAAC,mBAAmB,EAC/B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,kBAAkB,GAC5B,EACF,cAAK,SAAS,EAAC,0BAA0B,YACtC,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAC/B,eAEE,SAAS,EAAC,0CAA0C,EACpD,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,aAExC,gBACE,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,EACzC,QAAQ,QACR,SAAS,EAAC,MAAM,GAChB,EACF,eAAM,SAAS,EAAC,MAAM,YAAE,MAAM,GAAQ,KAVjC,MAAM,CAWP,CACP,CAAC,GACE,IACF,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
export default function Select({ options, selected, setSelected, canDefault, }) {
|
|
3
|
-
return (_jsxs("select", { value: selected || "", onChange: (e) => setSelected(e.target.value), className: "py-2 px-3 bg-white block w-full border-2 border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none", children: [_jsx("option", { value: "", disabled: !canDefault, hidden: !canDefault, children: "selection" }), options.map((opt) => (_jsx("option", { value: opt, children: opt })))] }));
|
|
3
|
+
return (_jsxs("select", { value: selected || "", onChange: (e) => setSelected(e.target.value), className: "py-2 px-3 bg-white block w-full border-2 border-gray-200 rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none", children: [_jsx("option", { value: "", disabled: !canDefault, hidden: !canDefault, children: "selection" }), options.map((opt, i) => (_jsx("option", { value: opt, children: opt }, i)))] }));
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=Select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/component/inputs/Select.tsx"],"names":[],"mappings":";AAOA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GACE;IACZ,OAAO,CACL,kBACE,KAAK,EAAE,QAAQ,IAAI,EAAE,EACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,SAAS,EAAC,wKAAwK,aAElL,iBAAQ,KAAK,EAAC,EAAE,EAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,UAAU,0BAElD,EACR,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/component/inputs/Select.tsx"],"names":[],"mappings":";AAOA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,WAAW,EACX,UAAU,GACE;IACZ,OAAO,CACL,kBACE,KAAK,EAAE,QAAQ,IAAI,EAAE,EACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,SAAS,EAAC,wKAAwK,aAElL,iBAAQ,KAAK,EAAC,EAAE,EAAC,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,UAAU,0BAElD,EACR,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACvB,iBAAgB,KAAK,EAAE,GAAG,YACvB,GAAG,IADO,CAAC,CAEL,CACV,CAAC,IACK,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import WrongIcon from "../icons/WrongIcon";
|
|
3
|
+
export default function ShowErrors({ errors }) {
|
|
4
|
+
return (_jsxs("div", { className: "bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative", role: "alert", children: [_jsxs("div", { className: "flex items-center", children: [_jsx(WrongIcon, {}), _jsx("span", { className: "font-bold", children: "There were 2 errors with your submission" })] }), _jsx("ul", { className: "mt-2 ml-6 list-disc list-inside", children: errors.map((error) => (_jsx("li", { children: error }))) })] }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ShowErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowErrors.js","sourceRoot":"","sources":["../../../src/component/inputs/ShowErrors.tsx"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,MAAM,EAAwB;IACjE,OAAO,CACL,eACE,SAAS,EAAC,0EAA0E,EACpF,IAAI,EAAC,OAAO,aAEZ,eAAK,SAAS,EAAC,mBAAmB,aAChC,KAAC,SAAS,KAAG,EACb,eAAM,SAAS,EAAC,WAAW,yDAEpB,IACH,EACN,aAAI,SAAS,EAAC,iCAAiC,YAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,uBAAK,KAAK,GAAM,CACjB,CAAC,GACC,IACD,CACP,CAAC;AACJ,CAAC"}
|
package/dist/index.css
CHANGED
|
@@ -574,6 +574,11 @@ video {
|
|
|
574
574
|
z-index: 10;
|
|
575
575
|
}
|
|
576
576
|
|
|
577
|
+
.my-6 {
|
|
578
|
+
margin-top: 1.5rem;
|
|
579
|
+
margin-bottom: 1.5rem;
|
|
580
|
+
}
|
|
581
|
+
|
|
577
582
|
.my-8 {
|
|
578
583
|
margin-top: 2rem;
|
|
579
584
|
margin-bottom: 2rem;
|
|
@@ -591,6 +596,10 @@ video {
|
|
|
591
596
|
margin-left: 0.5rem;
|
|
592
597
|
}
|
|
593
598
|
|
|
599
|
+
.ml-7 {
|
|
600
|
+
margin-left: 1.75rem;
|
|
601
|
+
}
|
|
602
|
+
|
|
594
603
|
.mr-1 {
|
|
595
604
|
margin-right: 0.25rem;
|
|
596
605
|
}
|
|
@@ -619,6 +628,11 @@ video {
|
|
|
619
628
|
display: none;
|
|
620
629
|
}
|
|
621
630
|
|
|
631
|
+
.size-5 {
|
|
632
|
+
width: 1.25rem;
|
|
633
|
+
height: 1.25rem;
|
|
634
|
+
}
|
|
635
|
+
|
|
622
636
|
.max-h-60 {
|
|
623
637
|
max-height: 15rem;
|
|
624
638
|
}
|
|
@@ -639,10 +653,26 @@ video {
|
|
|
639
653
|
cursor: pointer;
|
|
640
654
|
}
|
|
641
655
|
|
|
656
|
+
.list-inside {
|
|
657
|
+
list-style-position: inside;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.list-disc {
|
|
661
|
+
list-style-type: disc;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.items-center {
|
|
665
|
+
align-items: center;
|
|
666
|
+
}
|
|
667
|
+
|
|
642
668
|
.justify-center {
|
|
643
669
|
justify-content: center;
|
|
644
670
|
}
|
|
645
671
|
|
|
672
|
+
.gap-2 {
|
|
673
|
+
gap: 0.5rem;
|
|
674
|
+
}
|
|
675
|
+
|
|
646
676
|
.space-y-3 > :not([hidden]) ~ :not([hidden]) {
|
|
647
677
|
--tw-space-y-reverse: 0;
|
|
648
678
|
margin-top: calc(0.75rem * calc(1 - var(--tw-space-y-reverse)));
|
|
@@ -669,6 +699,10 @@ video {
|
|
|
669
699
|
border-radius: 0.375rem;
|
|
670
700
|
}
|
|
671
701
|
|
|
702
|
+
.rounded-xl {
|
|
703
|
+
border-radius: 0.75rem;
|
|
704
|
+
}
|
|
705
|
+
|
|
672
706
|
.border {
|
|
673
707
|
border-width: 1px;
|
|
674
708
|
}
|
|
@@ -686,11 +720,26 @@ video {
|
|
|
686
720
|
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
|
687
721
|
}
|
|
688
722
|
|
|
723
|
+
.border-gray-300 {
|
|
724
|
+
--tw-border-opacity: 1;
|
|
725
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity));
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.border-red-300 {
|
|
729
|
+
--tw-border-opacity: 1;
|
|
730
|
+
border-color: rgb(252 165 165 / var(--tw-border-opacity));
|
|
731
|
+
}
|
|
732
|
+
|
|
689
733
|
.bg-\[\#0096DC\] {
|
|
690
734
|
--tw-bg-opacity: 1;
|
|
691
735
|
background-color: rgb(0 150 220 / var(--tw-bg-opacity));
|
|
692
736
|
}
|
|
693
737
|
|
|
738
|
+
.bg-red-50 {
|
|
739
|
+
--tw-bg-opacity: 1;
|
|
740
|
+
background-color: rgb(254 242 242 / var(--tw-bg-opacity));
|
|
741
|
+
}
|
|
742
|
+
|
|
694
743
|
.bg-white {
|
|
695
744
|
--tw-bg-opacity: 1;
|
|
696
745
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
|
@@ -724,6 +773,11 @@ video {
|
|
|
724
773
|
padding-bottom: 0.25rem;
|
|
725
774
|
}
|
|
726
775
|
|
|
776
|
+
.py-1\.5 {
|
|
777
|
+
padding-top: 0.375rem;
|
|
778
|
+
padding-bottom: 0.375rem;
|
|
779
|
+
}
|
|
780
|
+
|
|
727
781
|
.py-2 {
|
|
728
782
|
padding-top: 0.5rem;
|
|
729
783
|
padding-bottom: 0.5rem;
|
|
@@ -743,6 +797,11 @@ video {
|
|
|
743
797
|
line-height: 2.5rem;
|
|
744
798
|
}
|
|
745
799
|
|
|
800
|
+
.text-base {
|
|
801
|
+
font-size: 1rem;
|
|
802
|
+
line-height: 1.5rem;
|
|
803
|
+
}
|
|
804
|
+
|
|
746
805
|
.text-sm {
|
|
747
806
|
font-size: 0.875rem;
|
|
748
807
|
line-height: 1.25rem;
|
|
@@ -761,6 +820,11 @@ video {
|
|
|
761
820
|
color: rgb(30 64 175 / var(--tw-text-opacity));
|
|
762
821
|
}
|
|
763
822
|
|
|
823
|
+
.text-red-600 {
|
|
824
|
+
--tw-text-opacity: 1;
|
|
825
|
+
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
826
|
+
}
|
|
827
|
+
|
|
764
828
|
.filter {
|
|
765
829
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
766
830
|
}
|
package/dist/util/type.d.ts
CHANGED
|
@@ -40,17 +40,19 @@ export interface Condition {
|
|
|
40
40
|
value: string;
|
|
41
41
|
delimiter: string;
|
|
42
42
|
}
|
|
43
|
-
export interface
|
|
43
|
+
export interface ISettingsAttribute {
|
|
44
44
|
max?: string;
|
|
45
45
|
min?: string;
|
|
46
46
|
color?: string;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
newValue?: boolean;
|
|
47
49
|
}
|
|
48
50
|
export interface Attribute {
|
|
49
51
|
name: string;
|
|
50
52
|
label?: string;
|
|
51
53
|
type?: keyof typeof AttributeTypeEnum;
|
|
52
54
|
content?: Content;
|
|
53
|
-
settings?:
|
|
55
|
+
settings?: ISettingsAttribute;
|
|
54
56
|
}
|
|
55
57
|
export type Content = string | string[];
|
|
56
58
|
export interface SettingsComponent {
|
package/package.json
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Attribute,
|
|
4
|
-
Component,
|
|
5
|
-
Condition,
|
|
6
|
-
ConditionEnum,
|
|
7
|
-
DataJSON,
|
|
8
|
-
} from "../util/type";
|
|
2
|
+
import { Attribute, Component, Condition, DataJSON } from "../util/type";
|
|
9
3
|
import { ShowAttr } from "./ShowAttr";
|
|
10
4
|
import PrimaryBtn from "./PrimaryBtn";
|
|
5
|
+
import ShowErrors from "./ShowErrors";
|
|
11
6
|
|
|
12
7
|
type ComponentDisplayerProps = {
|
|
13
|
-
|
|
8
|
+
component: Component;
|
|
14
9
|
data: DataJSON;
|
|
15
10
|
setData: (data: DataJSON) => void;
|
|
16
11
|
onSubmit: () => void;
|
|
17
12
|
};
|
|
18
13
|
|
|
19
14
|
export function ComponentDisplayer({
|
|
20
|
-
|
|
15
|
+
component,
|
|
21
16
|
data,
|
|
22
17
|
setData,
|
|
23
18
|
onSubmit,
|
|
24
19
|
}: ComponentDisplayerProps) {
|
|
25
|
-
const [
|
|
20
|
+
const [errors, setErrors] = useState<string[]>([]);
|
|
26
21
|
return (
|
|
27
|
-
<form
|
|
22
|
+
<form
|
|
23
|
+
onSubmit={(e) => {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
const errs = checkRequired(component.attributes, data);
|
|
26
|
+
if (errs.length === 0) {
|
|
27
|
+
onSubmit();
|
|
28
|
+
} else {
|
|
29
|
+
setErrors(errs);
|
|
30
|
+
}
|
|
31
|
+
}}
|
|
32
|
+
className="min-w-72"
|
|
33
|
+
>
|
|
28
34
|
<h1 className="font-bold text-center text-blue-800 text-4xl mb-8">
|
|
29
|
-
{
|
|
35
|
+
{component.label}
|
|
30
36
|
</h1>
|
|
31
37
|
<div className="space-y-3">
|
|
32
|
-
{
|
|
33
|
-
if (canShow(attr, data,
|
|
38
|
+
{component.attributes.map((attr) => {
|
|
39
|
+
if (canShow(attr, data, component.conditions || [])) {
|
|
34
40
|
return (
|
|
35
41
|
<ShowAttr
|
|
36
42
|
key={attr.name}
|
|
@@ -53,13 +59,32 @@ export function ComponentDisplayer({
|
|
|
53
59
|
}
|
|
54
60
|
})}
|
|
55
61
|
</div>
|
|
62
|
+
{errors.length !== 0 && (
|
|
63
|
+
<div className="my-6">
|
|
64
|
+
<ShowErrors errors={errors} />
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
56
67
|
<div className="flex justify-center my-8">
|
|
57
|
-
<PrimaryBtn
|
|
68
|
+
<PrimaryBtn text="Submit" />
|
|
58
69
|
</div>
|
|
59
70
|
</form>
|
|
60
71
|
);
|
|
61
72
|
}
|
|
62
73
|
|
|
74
|
+
// check the required attributes and return array string of errors
|
|
75
|
+
function checkRequired(attributes: Attribute[], data: DataJSON): string[] {
|
|
76
|
+
const requiredAttributes = attributes.filter(
|
|
77
|
+
(attr) => attr.settings?.required,
|
|
78
|
+
);
|
|
79
|
+
const errors: string[] = [];
|
|
80
|
+
requiredAttributes.forEach((attr) => {
|
|
81
|
+
if (!data[attr.name]) {
|
|
82
|
+
errors.push(`${attr.label} is required`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return errors;
|
|
86
|
+
}
|
|
87
|
+
|
|
63
88
|
function canShow(
|
|
64
89
|
attr: Attribute,
|
|
65
90
|
data: DataJSON,
|
|
@@ -2,23 +2,15 @@ import { useRef } from "react";
|
|
|
2
2
|
|
|
3
3
|
type props = {
|
|
4
4
|
text: string;
|
|
5
|
-
clickFn: () => void;
|
|
6
|
-
className?: string;
|
|
7
5
|
disabled?: boolean;
|
|
8
6
|
};
|
|
9
7
|
|
|
10
|
-
export default function PrimaryBtn({
|
|
11
|
-
text,
|
|
12
|
-
clickFn,
|
|
13
|
-
className,
|
|
14
|
-
disabled,
|
|
15
|
-
}: props) {
|
|
8
|
+
export default function PrimaryBtn({ text, disabled }: props) {
|
|
16
9
|
const btn = useRef<HTMLButtonElement>(null);
|
|
17
10
|
return (
|
|
18
11
|
<button
|
|
19
12
|
type="submit"
|
|
20
13
|
ref={btn}
|
|
21
|
-
onClick={clickFn}
|
|
22
14
|
className={
|
|
23
15
|
"rounded-2xl bg-[#0096DC] bg-opacity-85 px-8 py-2 font-bold text-white-shade hover:bg-opacity-100"
|
|
24
16
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Attribute, AttributeTypeEnum, Content, DataJSON } from "../util/type";
|
|
2
2
|
import LabeledSelect from "./inputs/LableledSelect";
|
|
3
3
|
import LabeledInput from "./inputs/LableledInput";
|
|
4
|
-
import MultiSelect from "./inputs/MultiSelect";
|
|
5
4
|
import LabeledMutliSelect from "./inputs/LabeledMutliSelect";
|
|
6
5
|
import { useMemo } from "react";
|
|
7
6
|
import { Parser } from "expr-eval";
|
|
@@ -36,6 +35,8 @@ export function ShowAttr({
|
|
|
36
35
|
value={value}
|
|
37
36
|
setValue={setValue}
|
|
38
37
|
type="number"
|
|
38
|
+
max={Number(attribute.settings?.max)}
|
|
39
|
+
min={Number(attribute.settings?.min)}
|
|
39
40
|
/>
|
|
40
41
|
);
|
|
41
42
|
case AttributeTypeEnum.TEXT:
|
|
@@ -45,6 +46,8 @@ export function ShowAttr({
|
|
|
45
46
|
value={value}
|
|
46
47
|
setValue={setValue}
|
|
47
48
|
type="text"
|
|
49
|
+
maxLength={attribute.settings?.max}
|
|
50
|
+
minLength={attribute.settings?.min}
|
|
48
51
|
/>
|
|
49
52
|
);
|
|
50
53
|
case AttributeTypeEnum.LIST:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import WrongIcon from "./icons/WrongIcon";
|
|
2
|
+
|
|
3
|
+
export default function ShowErrors({ errors }: { errors: string[] }) {
|
|
4
|
+
return (
|
|
5
|
+
<div
|
|
6
|
+
className="bg-red-50 border border-red-300 text-red-600 px-3 py-2 rounded-xl relative"
|
|
7
|
+
role="alert"
|
|
8
|
+
>
|
|
9
|
+
<div className="flex items-center gap-2">
|
|
10
|
+
<WrongIcon />
|
|
11
|
+
<span className="font-semibold">{errors.length} error found.</span>
|
|
12
|
+
</div>
|
|
13
|
+
<ul className="mt-2 ml-7 list-disc list-inside">
|
|
14
|
+
{errors.map((error) => (
|
|
15
|
+
<li>{error}</li>
|
|
16
|
+
))}
|
|
17
|
+
</ul>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default function WrongIcon() {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
fill="#c01c28"
|
|
5
|
+
width="22px"
|
|
6
|
+
height="22px"
|
|
7
|
+
viewBox="0 0 200 200"
|
|
8
|
+
data-name="Layer 1"
|
|
9
|
+
id="Layer_1"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
stroke="#c01c28"
|
|
12
|
+
>
|
|
13
|
+
<g id="SVGRepo_bgCarrier" stroke-width="0" />
|
|
14
|
+
|
|
15
|
+
<g
|
|
16
|
+
id="SVGRepo_tracerCarrier"
|
|
17
|
+
stroke-linecap="round"
|
|
18
|
+
stroke-linejoin="round"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<g id="SVGRepo_iconCarrier">
|
|
22
|
+
<title />
|
|
23
|
+
|
|
24
|
+
<path d="M100,15a85,85,0,1,0,85,85A84.93,84.93,0,0,0,100,15Zm0,150a65,65,0,1,1,65-65A64.87,64.87,0,0,1,100,165Z" />
|
|
25
|
+
|
|
26
|
+
<path d="M128.5,74a9.67,9.67,0,0,0-14,0L100,88.5l-14-14a9.9,9.9,0,0,0-14,14l14,14-14,14a9.9,9.9,0,0,0,14,14l14-14,14,14a9.9,9.9,0,0,0,14-14l-14-14,14-14A10.77,10.77,0,0,0,128.5,74Z" />
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -4,9 +4,11 @@ export type InputProps = {
|
|
|
4
4
|
value?: string;
|
|
5
5
|
setValue: (s: string) => void;
|
|
6
6
|
type: HTMLInputTypeAttribute;
|
|
7
|
-
className?: string;
|
|
8
7
|
onBlur?: () => void;
|
|
9
|
-
maxLength?:
|
|
8
|
+
maxLength?: string;
|
|
9
|
+
minLength?: string;
|
|
10
|
+
max?: number;
|
|
11
|
+
min?: number;
|
|
10
12
|
placeholder?: string;
|
|
11
13
|
disabled?: boolean;
|
|
12
14
|
checked?: boolean;
|
|
@@ -15,10 +17,12 @@ export type InputProps = {
|
|
|
15
17
|
export default function Input({
|
|
16
18
|
value,
|
|
17
19
|
setValue,
|
|
18
|
-
className,
|
|
19
20
|
type,
|
|
20
21
|
onBlur,
|
|
21
22
|
maxLength,
|
|
23
|
+
minLength,
|
|
24
|
+
max,
|
|
25
|
+
min,
|
|
22
26
|
placeholder,
|
|
23
27
|
disabled,
|
|
24
28
|
checked,
|
|
@@ -26,7 +30,7 @@ export default function Input({
|
|
|
26
30
|
return (
|
|
27
31
|
<input
|
|
28
32
|
type={type}
|
|
29
|
-
className=
|
|
33
|
+
className={`py-1.5 px-3 ${type === "checkbox" ? "size-5" : "w-full"} border-2 border-gray-300 rounded-xl text-base focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none`}
|
|
30
34
|
value={value}
|
|
31
35
|
onChange={(e) =>
|
|
32
36
|
type === "checkbox"
|
|
@@ -35,7 +39,14 @@ export default function Input({
|
|
|
35
39
|
}
|
|
36
40
|
disabled={disabled}
|
|
37
41
|
onBlur={onBlur}
|
|
38
|
-
maxLength={
|
|
42
|
+
maxLength={
|
|
43
|
+
maxLength && !isNaN(Number(maxLength)) ? Number(maxLength) : undefined
|
|
44
|
+
}
|
|
45
|
+
minLength={
|
|
46
|
+
minLength && !isNaN(Number(minLength)) ? Number(minLength) : undefined
|
|
47
|
+
}
|
|
48
|
+
max={max}
|
|
49
|
+
min={min}
|
|
39
50
|
placeholder={placeholder}
|
|
40
51
|
checked={checked}
|
|
41
52
|
/>
|
|
@@ -6,8 +6,8 @@ type Props = {
|
|
|
6
6
|
|
|
7
7
|
export default function LabeledInput({ label, ...inputProps }: Props) {
|
|
8
8
|
return (
|
|
9
|
-
<div className="w-full">
|
|
10
|
-
<label className="block text-
|
|
9
|
+
<div className="w-full flex gap-2 items-center">
|
|
10
|
+
<label className="block text-base font-bold mb-1">{label}</label>
|
|
11
11
|
<Input {...inputProps} />
|
|
12
12
|
</div>
|
|
13
13
|
);
|
|
@@ -20,8 +20,10 @@ export default function Select({
|
|
|
20
20
|
<option value="" disabled={!canDefault} hidden={!canDefault}>
|
|
21
21
|
selection
|
|
22
22
|
</option>
|
|
23
|
-
{options.map((opt) => (
|
|
24
|
-
<option
|
|
23
|
+
{options.map((opt, i) => (
|
|
24
|
+
<option key={i} value={opt}>
|
|
25
|
+
{opt}
|
|
26
|
+
</option>
|
|
25
27
|
))}
|
|
26
28
|
</select>
|
|
27
29
|
);
|
package/src/util/type.ts
CHANGED
|
@@ -48,10 +48,12 @@ export interface Condition {
|
|
|
48
48
|
delimiter: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export interface
|
|
51
|
+
export interface ISettingsAttribute {
|
|
52
52
|
max?: string;
|
|
53
53
|
min?: string;
|
|
54
54
|
color?: string;
|
|
55
|
+
required?: boolean;
|
|
56
|
+
newValue?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export interface Attribute {
|
|
@@ -59,7 +61,7 @@ export interface Attribute {
|
|
|
59
61
|
label?: string;
|
|
60
62
|
type?: keyof typeof AttributeTypeEnum;
|
|
61
63
|
content?: Content;
|
|
62
|
-
settings?:
|
|
64
|
+
settings?: ISettingsAttribute;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
export type Content = string | string[];
|