module-package-comp 1.1.0 → 1.2.0
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 +27 -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 +4 -1
- package/dist/component/inputs/Input.js +3 -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/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 +111 -0
- package/dist/util/type.d.ts +4 -2
- package/package.json +1 -1
- package/src/component/ComponentDisplayer.tsx +41 -15
- package/src/component/PrimaryBtn.tsx +1 -9
- package/src/component/ShowAttr.tsx +4 -0
- package/src/component/ShowErrors.tsx +20 -0
- package/src/component/icons/WrongIcon.tsx +30 -0
- package/src/component/inputs/Input.tsx +10 -1
- package/src/component/inputs/LableledInput.tsx +2 -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,19 @@ 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
|
+
console.log(requiredAttributes);
|
|
38
|
+
const errors = [];
|
|
39
|
+
requiredAttributes.forEach((attr) => {
|
|
40
|
+
if (!data[attr.name]) {
|
|
41
|
+
errors.push(`${attr.label} is required`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return errors;
|
|
23
45
|
}
|
|
24
46
|
function canShow(attr, data, conds) {
|
|
25
47
|
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,kBAAkB,CAAC,EACjC,SAAS,EACT,IAAI,EACJ,OAAO,EACP,QAAQ,GACgB;IACxB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACnD,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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: Number((_c = attribute.settings) === null || _c === void 0 ? void 0 : _c.max), minLength: Number((_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,CAAC;AACpD,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAElD,OAAO,kBAAkB,MAAM,6BAA6B,CAAC;AAC7D,OAA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,GACzD,CACP,CAAC;QACJ,KAAK,iBAAiB,CAAC,OAAO;YAC5B,IAAI,MAAM,GAAG,CAAC,CAAC;YACf,IAAI,SAAS,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAC/D,MAAM,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"}
|
|
@@ -6,8 +6,11 @@ export type InputProps = {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
onBlur?: () => void;
|
|
8
8
|
maxLength?: number;
|
|
9
|
+
minLength?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
min?: number;
|
|
9
12
|
placeholder?: string;
|
|
10
13
|
disabled?: boolean;
|
|
11
14
|
checked?: boolean;
|
|
12
15
|
};
|
|
13
|
-
export default function Input({ value, setValue, className, type, onBlur, maxLength, placeholder, disabled, checked, }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default function Input({ value, setValue, className, type, onBlur, maxLength, minLength, max, min, placeholder, disabled, checked, }: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export default function Input({ value, setValue, className, type, onBlur, maxLength, placeholder, disabled, checked, }) {
|
|
3
|
-
return (_jsx("input", { type: type, className:
|
|
2
|
+
export default function Input({ value, setValue, className, type, onBlur, maxLength, minLength, max, min, placeholder, disabled, checked, }) {
|
|
3
|
+
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
4
|
? setValue(String(e.target.checked))
|
|
5
|
-
: setValue(e.target.value), disabled: disabled, onBlur: onBlur, maxLength: maxLength, placeholder: placeholder, checked: checked }));
|
|
5
|
+
: setValue(e.target.value), disabled: disabled, onBlur: onBlur, maxLength: maxLength, minLength: minLength, max: max, min: min, placeholder: placeholder, checked: checked }));
|
|
6
6
|
}
|
|
7
7
|
//# 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":";AAiBA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,GAAG,EACH,GAAG,EACH,WAAW,EACX,QAAQ,EACR,OAAO,GACI;IACX,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,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,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"}
|
|
@@ -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
|
@@ -579,6 +579,21 @@ video {
|
|
|
579
579
|
margin-bottom: 2rem;
|
|
580
580
|
}
|
|
581
581
|
|
|
582
|
+
.my-6 {
|
|
583
|
+
margin-top: 1.5rem;
|
|
584
|
+
margin-bottom: 1.5rem;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.mx-4 {
|
|
588
|
+
margin-left: 1rem;
|
|
589
|
+
margin-right: 1rem;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.my-4 {
|
|
593
|
+
margin-top: 1rem;
|
|
594
|
+
margin-bottom: 1rem;
|
|
595
|
+
}
|
|
596
|
+
|
|
582
597
|
.mb-1 {
|
|
583
598
|
margin-bottom: 0.25rem;
|
|
584
599
|
}
|
|
@@ -591,6 +606,10 @@ video {
|
|
|
591
606
|
margin-left: 0.5rem;
|
|
592
607
|
}
|
|
593
608
|
|
|
609
|
+
.ml-6 {
|
|
610
|
+
margin-left: 1.5rem;
|
|
611
|
+
}
|
|
612
|
+
|
|
594
613
|
.mr-1 {
|
|
595
614
|
margin-right: 0.25rem;
|
|
596
615
|
}
|
|
@@ -603,6 +622,10 @@ video {
|
|
|
603
622
|
margin-top: 0.5rem;
|
|
604
623
|
}
|
|
605
624
|
|
|
625
|
+
.ml-7 {
|
|
626
|
+
margin-left: 1.75rem;
|
|
627
|
+
}
|
|
628
|
+
|
|
606
629
|
.block {
|
|
607
630
|
display: block;
|
|
608
631
|
}
|
|
@@ -619,6 +642,11 @@ video {
|
|
|
619
642
|
display: none;
|
|
620
643
|
}
|
|
621
644
|
|
|
645
|
+
.size-5 {
|
|
646
|
+
width: 1.25rem;
|
|
647
|
+
height: 1.25rem;
|
|
648
|
+
}
|
|
649
|
+
|
|
622
650
|
.max-h-60 {
|
|
623
651
|
max-height: 15rem;
|
|
624
652
|
}
|
|
@@ -639,10 +667,30 @@ video {
|
|
|
639
667
|
cursor: pointer;
|
|
640
668
|
}
|
|
641
669
|
|
|
670
|
+
.list-inside {
|
|
671
|
+
list-style-position: inside;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.list-disc {
|
|
675
|
+
list-style-type: disc;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.items-center {
|
|
679
|
+
align-items: center;
|
|
680
|
+
}
|
|
681
|
+
|
|
642
682
|
.justify-center {
|
|
643
683
|
justify-content: center;
|
|
644
684
|
}
|
|
645
685
|
|
|
686
|
+
.gap-2 {
|
|
687
|
+
gap: 0.5rem;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
.gap-1 {
|
|
691
|
+
gap: 0.25rem;
|
|
692
|
+
}
|
|
693
|
+
|
|
646
694
|
.space-y-3 > :not([hidden]) ~ :not([hidden]) {
|
|
647
695
|
--tw-space-y-reverse: 0;
|
|
648
696
|
margin-top: calc(0.75rem * calc(1 - var(--tw-space-y-reverse)));
|
|
@@ -653,6 +701,10 @@ video {
|
|
|
653
701
|
overflow-y: auto;
|
|
654
702
|
}
|
|
655
703
|
|
|
704
|
+
.rounded {
|
|
705
|
+
border-radius: 0.25rem;
|
|
706
|
+
}
|
|
707
|
+
|
|
656
708
|
.rounded-2xl {
|
|
657
709
|
border-radius: 1rem;
|
|
658
710
|
}
|
|
@@ -669,6 +721,10 @@ video {
|
|
|
669
721
|
border-radius: 0.375rem;
|
|
670
722
|
}
|
|
671
723
|
|
|
724
|
+
.rounded-xl {
|
|
725
|
+
border-radius: 0.75rem;
|
|
726
|
+
}
|
|
727
|
+
|
|
672
728
|
.border {
|
|
673
729
|
border-width: 1px;
|
|
674
730
|
}
|
|
@@ -686,16 +742,41 @@ video {
|
|
|
686
742
|
border-color: rgb(229 231 235 / var(--tw-border-opacity));
|
|
687
743
|
}
|
|
688
744
|
|
|
745
|
+
.border-gray-300 {
|
|
746
|
+
--tw-border-opacity: 1;
|
|
747
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity));
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
.border-red-400 {
|
|
751
|
+
--tw-border-opacity: 1;
|
|
752
|
+
border-color: rgb(248 113 113 / var(--tw-border-opacity));
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.border-red-300 {
|
|
756
|
+
--tw-border-opacity: 1;
|
|
757
|
+
border-color: rgb(252 165 165 / var(--tw-border-opacity));
|
|
758
|
+
}
|
|
759
|
+
|
|
689
760
|
.bg-\[\#0096DC\] {
|
|
690
761
|
--tw-bg-opacity: 1;
|
|
691
762
|
background-color: rgb(0 150 220 / var(--tw-bg-opacity));
|
|
692
763
|
}
|
|
693
764
|
|
|
765
|
+
.bg-red-100 {
|
|
766
|
+
--tw-bg-opacity: 1;
|
|
767
|
+
background-color: rgb(254 226 226 / var(--tw-bg-opacity));
|
|
768
|
+
}
|
|
769
|
+
|
|
694
770
|
.bg-white {
|
|
695
771
|
--tw-bg-opacity: 1;
|
|
696
772
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
|
697
773
|
}
|
|
698
774
|
|
|
775
|
+
.bg-red-50 {
|
|
776
|
+
--tw-bg-opacity: 1;
|
|
777
|
+
background-color: rgb(254 242 242 / var(--tw-bg-opacity));
|
|
778
|
+
}
|
|
779
|
+
|
|
699
780
|
.bg-opacity-85 {
|
|
700
781
|
--tw-bg-opacity: 0.85;
|
|
701
782
|
}
|
|
@@ -714,6 +795,11 @@ video {
|
|
|
714
795
|
padding-right: 0.75rem;
|
|
715
796
|
}
|
|
716
797
|
|
|
798
|
+
.px-4 {
|
|
799
|
+
padding-left: 1rem;
|
|
800
|
+
padding-right: 1rem;
|
|
801
|
+
}
|
|
802
|
+
|
|
717
803
|
.px-8 {
|
|
718
804
|
padding-left: 2rem;
|
|
719
805
|
padding-right: 2rem;
|
|
@@ -724,11 +810,21 @@ video {
|
|
|
724
810
|
padding-bottom: 0.25rem;
|
|
725
811
|
}
|
|
726
812
|
|
|
813
|
+
.py-1\.5 {
|
|
814
|
+
padding-top: 0.375rem;
|
|
815
|
+
padding-bottom: 0.375rem;
|
|
816
|
+
}
|
|
817
|
+
|
|
727
818
|
.py-2 {
|
|
728
819
|
padding-top: 0.5rem;
|
|
729
820
|
padding-bottom: 0.5rem;
|
|
730
821
|
}
|
|
731
822
|
|
|
823
|
+
.py-3 {
|
|
824
|
+
padding-top: 0.75rem;
|
|
825
|
+
padding-bottom: 0.75rem;
|
|
826
|
+
}
|
|
827
|
+
|
|
732
828
|
.text-center {
|
|
733
829
|
text-align: center;
|
|
734
830
|
}
|
|
@@ -743,6 +839,11 @@ video {
|
|
|
743
839
|
line-height: 2.5rem;
|
|
744
840
|
}
|
|
745
841
|
|
|
842
|
+
.text-base {
|
|
843
|
+
font-size: 1rem;
|
|
844
|
+
line-height: 1.5rem;
|
|
845
|
+
}
|
|
846
|
+
|
|
746
847
|
.text-sm {
|
|
747
848
|
font-size: 0.875rem;
|
|
748
849
|
line-height: 1.25rem;
|
|
@@ -761,6 +862,16 @@ video {
|
|
|
761
862
|
color: rgb(30 64 175 / var(--tw-text-opacity));
|
|
762
863
|
}
|
|
763
864
|
|
|
865
|
+
.text-red-700 {
|
|
866
|
+
--tw-text-opacity: 1;
|
|
867
|
+
color: rgb(185 28 28 / var(--tw-text-opacity));
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
.text-red-600 {
|
|
871
|
+
--tw-text-opacity: 1;
|
|
872
|
+
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
873
|
+
}
|
|
874
|
+
|
|
764
875
|
.filter {
|
|
765
876
|
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
877
|
}
|
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,33 @@ 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
|
+
console.log(requiredAttributes);
|
|
80
|
+
const errors: string[] = [];
|
|
81
|
+
requiredAttributes.forEach((attr) => {
|
|
82
|
+
if (!data[attr.name]) {
|
|
83
|
+
errors.push(`${attr.label} is required`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return errors;
|
|
87
|
+
}
|
|
88
|
+
|
|
63
89
|
function canShow(
|
|
64
90
|
attr: Attribute,
|
|
65
91
|
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
|
}
|
|
@@ -36,6 +36,8 @@ export function ShowAttr({
|
|
|
36
36
|
value={value}
|
|
37
37
|
setValue={setValue}
|
|
38
38
|
type="number"
|
|
39
|
+
max={Number(attribute.settings?.max)}
|
|
40
|
+
min={Number(attribute.settings?.min)}
|
|
39
41
|
/>
|
|
40
42
|
);
|
|
41
43
|
case AttributeTypeEnum.TEXT:
|
|
@@ -45,6 +47,8 @@ export function ShowAttr({
|
|
|
45
47
|
value={value}
|
|
46
48
|
setValue={setValue}
|
|
47
49
|
type="text"
|
|
50
|
+
maxLength={Number(attribute.settings?.max)}
|
|
51
|
+
minLength={Number(attribute.settings?.min)}
|
|
48
52
|
/>
|
|
49
53
|
);
|
|
50
54
|
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
|
+
}
|
|
@@ -7,6 +7,9 @@ export type InputProps = {
|
|
|
7
7
|
className?: string;
|
|
8
8
|
onBlur?: () => void;
|
|
9
9
|
maxLength?: number;
|
|
10
|
+
minLength?: number;
|
|
11
|
+
max?: number;
|
|
12
|
+
min?: number;
|
|
10
13
|
placeholder?: string;
|
|
11
14
|
disabled?: boolean;
|
|
12
15
|
checked?: boolean;
|
|
@@ -19,6 +22,9 @@ export default function Input({
|
|
|
19
22
|
type,
|
|
20
23
|
onBlur,
|
|
21
24
|
maxLength,
|
|
25
|
+
minLength,
|
|
26
|
+
max,
|
|
27
|
+
min,
|
|
22
28
|
placeholder,
|
|
23
29
|
disabled,
|
|
24
30
|
checked,
|
|
@@ -26,7 +32,7 @@ export default function Input({
|
|
|
26
32
|
return (
|
|
27
33
|
<input
|
|
28
34
|
type={type}
|
|
29
|
-
className=
|
|
35
|
+
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
36
|
value={value}
|
|
31
37
|
onChange={(e) =>
|
|
32
38
|
type === "checkbox"
|
|
@@ -36,6 +42,9 @@ export default function Input({
|
|
|
36
42
|
disabled={disabled}
|
|
37
43
|
onBlur={onBlur}
|
|
38
44
|
maxLength={maxLength}
|
|
45
|
+
minLength={minLength}
|
|
46
|
+
max={max}
|
|
47
|
+
min={min}
|
|
39
48
|
placeholder={placeholder}
|
|
40
49
|
checked={checked}
|
|
41
50
|
/>
|
|
@@ -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
|
);
|
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[];
|