@daracl/form 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/daracl.form.js +2 -2
  2. package/dist/daracl.form.min.js +2 -2
  3. package/dist/daracl.form.min.js.LICENSE.txt +1 -1
  4. package/dist/daracl.vender.min.js +1 -1
  5. package/dist/main.css +1 -1
  6. package/package.json +5 -7
  7. package/src/DaraForm.ts +0 -431
  8. package/src/FieldInfoMap.ts +0 -356
  9. package/src/FormTemplate.ts +0 -207
  10. package/src/constants.ts +0 -100
  11. package/src/event/renderEvents.ts +0 -41
  12. package/src/index copy.html +0 -591
  13. package/src/index-grid.html +0 -655
  14. package/src/index-tab.html +0 -639
  15. package/src/index.html +0 -485
  16. package/src/indexVender.ts +0 -9
  17. package/src/renderer/ButtonRender.ts +0 -51
  18. package/src/renderer/CheckboxRender.ts +0 -214
  19. package/src/renderer/CustomRender.ts +0 -100
  20. package/src/renderer/DateRender.ts +0 -104
  21. package/src/renderer/DropdownRender.ts +0 -149
  22. package/src/renderer/FileRender.ts +0 -239
  23. package/src/renderer/GridRender.ts +0 -289
  24. package/src/renderer/GroupRender.ts +0 -47
  25. package/src/renderer/HiddenRender.ts +0 -36
  26. package/src/renderer/NumberRender.ts +0 -68
  27. package/src/renderer/PasswordRender.ts +0 -69
  28. package/src/renderer/RadioRender.ts +0 -191
  29. package/src/renderer/RangeRender.ts +0 -79
  30. package/src/renderer/Render.ts +0 -194
  31. package/src/renderer/TabRender.ts +0 -229
  32. package/src/renderer/TextAreaRender.ts +0 -72
  33. package/src/renderer/TextRender.ts +0 -68
  34. package/src/rule/fileValidator.ts +0 -26
  35. package/src/rule/numberValidator.ts +0 -96
  36. package/src/rule/regexpValidator.ts +0 -45
  37. package/src/rule/stringValidator.ts +0 -64
  38. package/src/rule/validator.ts +0 -49
  39. package/src/types/DataMap.d.ts +0 -17
  40. package/src/types/DateTimePicker.d.ts +0 -5
  41. package/src/types/FormField.d.ts +0 -129
  42. package/src/types/FormOptions.d.ts +0 -91
  43. package/src/types/Message.d.ts +0 -40
  44. package/src/types/ValidResult.d.ts +0 -9
  45. package/src/util/Lanauage.ts +0 -127
  46. package/src/util/renderFactory.ts +0 -26
  47. package/src/util/styleUtils.ts +0 -85
  48. package/src/util/utils.ts +0 -283
  49. package/src/util/validUtils.ts +0 -53
@@ -1,129 +0,0 @@
1
- import DaraForm from "src/DaraForm";
2
- import { RENDER_TYPE, REGEXP_TYPE, TEXT_ALIGN_TYPE, FIELD_POSITION, ORIENTATION_TYPE } from "src/constants";
3
- import Render from "src/renderer/Render";
4
-
5
- export interface OptionCallback {
6
- (...params: any[]): any;
7
- }
8
-
9
- export interface ValuesInfo {
10
- labelField: string;
11
- valueField: string;
12
- list: any[];
13
- orientation: ORIENTATION_TYPE;
14
- }
15
-
16
- /**
17
- * 첨부 파일 정보
18
- *
19
- * @export
20
- * @interface FileInfo
21
- * @typedef {FileInfo}
22
- */
23
- export interface FileInfo {
24
- fileId: string;
25
- fileName: string;
26
- fileSize: number;
27
- $seq: number;
28
- lastModified?: any;
29
- }
30
-
31
- /**
32
- * 상태 체크 정보
33
- *
34
- * @export
35
- * @interface ConditionInfo
36
- * @typedef {ConditionInfo}
37
- */
38
- export interface ConditionInfo {
39
- show: boolean;
40
- field: string;
41
- eq: any;
42
- custom?: OptionCallback;
43
- }
44
-
45
- export interface FieldStyle {
46
- rowStyleClass?: string;
47
- fieldClass?: string;
48
- fieldStyle?: string;
49
- labelClass?: string;
50
- labelStyle?: string;
51
- labelAlignClass?: string;
52
- valueClass?: string;
53
- valueStyle?: string;
54
- tabAlignClass?: string;
55
- }
56
-
57
- /**
58
- * form field
59
- *
60
- * @export
61
- * @interface FormField
62
- * @typedef {FormField}
63
- */
64
- export interface FormField {
65
- name: string; // 'name'
66
- renderType?: RENDER_TYPE | string;
67
- customOptions: any;
68
- label: string; // '아이디'
69
- style: {
70
- width: string | number;
71
- labelHide: boolean;
72
- labelWidth: string | number;
73
- customClass: string;
74
- valueWidth: string | number;
75
- position: string;
76
- tabAlign: string;
77
- };
78
- tooltip: string; // 툴팁 문구
79
- disabled?: boolean; // disabled
80
- description: string; // 설명
81
- placeholder: string; // input , textarea 문구
82
- orientation: ORIENTATION_TYPE; // children에 사용
83
- required?: boolean; //true // 필수 여부
84
- regexpType?: REGEXP_TYPE; // 정규식 타입
85
- rule: {
86
- // 규칙
87
- minLength: number; // 3
88
- maxLength: number; //100
89
- minimum: number;
90
- exclusiveMinimum: boolean;
91
- maximum: number;
92
- exclusiveMaximum: boolean;
93
- };
94
- different: {
95
- // field 값이 다른지 비교
96
- field: string;
97
- message: string;
98
- };
99
- identical: {
100
- // field 값이 같은지 비교
101
- field: string;
102
- message: string;
103
- };
104
- template: OptionCallback | string; // 필드 템플릿
105
- defaultValue: string; // 기본값
106
- listItem: ValuesInfo; // dropdown, radio, checkbox
107
- children: FormField[]; // child field
108
- validator?: OptionCallback; // custom validator
109
- onChange: OptionCallback; // 입력값 변경시 체크 function
110
- onClick: OptionCallback; // button onclick function
111
- fileDownload: OptionCallback; // file download function
112
- renderer: Render; // custom renderer
113
- conditional: ConditionInfo; // 보이기 여부
114
- gridOptions?: {
115
- disableAddButton?: boolean; // renderer 그리드 타입 추가 버튼 유무
116
- disableRemoveButton?: boolean; // renderer 그리드 타입 추가 버튼 유무
117
- align?: TEXT_ALIGN_TYPE; // renderer 그리드 타입 추가 버튼 유무
118
- height: string; // grid 높이값
119
- };
120
- $renderType: Render; // render Type
121
- $instance: Render; // 실제 render
122
- $orgin: FormField;
123
- $xssName: string; // xss 변경명
124
- $key: string; // 내부 key
125
- $value: string; // 내부 사용 value
126
- $parent: FormField;
127
- $tabForm?: DaraForm; //tab 일경우 폼 정보
128
- $validName: string; //
129
- }
@@ -1,91 +0,0 @@
1
- import { FORM_MODE, TEXT_ALIGN_TYPE } from "src/constants";
2
- import { OptionCallback } from "./FormField";
3
-
4
- /**
5
- * form options
6
- *
7
- * @export
8
- * @interface FormOptions
9
- * @typedef {FormOptions}
10
- */
11
- export interface FormOptions {
12
- /**
13
- * style 옵션
14
- *
15
- * @example
16
- * ```
17
- * width: '600px',
18
- position: 'left',
19
- labelWidth: '3'
20
- valueWidth: '9'
21
- * ```
22
- */
23
- style: {
24
- /**
25
- * form width
26
- * @example
27
- * 600px, 100em
28
- */
29
- width: string;
30
- /**
31
- * field label width
32
- * @example
33
- * bootstrap width 참고 (1 ~ 12) 또는 '600px'
34
- */
35
- labelWidth: string | number;
36
- /**
37
- * field value width
38
- * @example
39
- * bootstrap width 참고 (1 ~ 12) 또는 '600px'
40
- */
41
- valueWidth: string | number;
42
- /**
43
- * field label position
44
- * @example
45
- * "top" | "left" | "left-left" | "left-right" | "right" | "right-left" | "right-right" | "bottom"
46
- */
47
- position: string;
48
- };
49
-
50
- /**
51
- * form에 값을 renderer type별로 값을 구 할지 여부. tab 값을 구할때 영향이 있음
52
- * @default false
53
- * @example
54
- * true or false
55
- *
56
- */
57
- useTypeValue?: boolean;
58
-
59
- /**
60
- * form 자동 생성 여부
61
- * @default true
62
- * @example
63
- * true or false
64
- */
65
- autoCreate?: boolean;
66
- /**
67
- * field 자동 포커스
68
- * @default true
69
- * @example
70
- * true or false
71
- */
72
- autoFocus?: boolean; // default true
73
- notValidMessage?: string; //'This value is not valid'
74
- onMounted?: OptionCallback;
75
- mode?: FORM_MODE;
76
- message?: {
77
- required: string; // '{name} 필수 입력사항입니다.'
78
- string: {
79
- minLength: string; //'{size} 글자 이상 입력해야합니다.'
80
- maxLength: string; //'{size} 글자 이상 입력할 수 없습니다.'
81
- };
82
- number: {
83
- min: string; //'{size} 보다 커야 합니다'
84
- max: string; //'{size} 보다 커야 합니다'
85
- };
86
- type: {
87
- message: string; // '{type} 유효하지 않습니다.'
88
- };
89
- };
90
- fields: any[];
91
- }
@@ -1,40 +0,0 @@
1
- export interface Message {
2
- required: string;
3
- fileButton: string;
4
- selection: string;
5
-
6
- // string
7
- string: {
8
- minLength: string;
9
- maxLength: string;
10
- between: string;
11
- };
12
-
13
- // number message
14
- number: {
15
- nan: string;
16
- minimum: string;
17
- exclusiveMinimum: string;
18
- maximum: string;
19
- exclusiveMaximum: string;
20
- between: string;
21
- betweenExclusiveMin: string;
22
- betweenExclusiveMax: string;
23
- betweenExclusiveMinMax: string;
24
- };
25
-
26
- // 정규식 메시지
27
- regexp: {
28
- mobile: string;
29
- email: string;
30
- url: string;
31
- number: string;
32
- alpha: string;
33
- "alpha-num": string;
34
- variable: string;
35
- "number-char": string;
36
- "upper-char": string;
37
- "upper-char-special": string;
38
- "upper-char-special-number": string;
39
- };
40
- }
@@ -1,9 +0,0 @@
1
- import { RULES } from '../constants';
2
-
3
- export interface ValidResult {
4
- name: string
5
- constraint: any[]
6
- regexp?: string
7
- validator?: any
8
- message?: string
9
- }
@@ -1,127 +0,0 @@
1
- import { Message } from "@t/Message";
2
- import { FormField } from "../types/FormField";
3
- import { ValidResult } from "@t/ValidResult";
4
- import { RULES } from "src/constants";
5
-
6
- let localeMessage: Message = {
7
- required: "{label} 필수 입력사항입니다.",
8
- fileButton: "파일찾기",
9
- selection: "선택",
10
- string: {
11
- minLength: "{minLength} 글자 이상으로 입력하세요.",
12
- maxLength: "{maxLength} 글자 이하로 입력하세요.",
13
- between: "{minLength} ~ {maxLength} 사이의 글자를 입력하세요.",
14
- },
15
- number: {
16
- nan: "숫자만 입력 가능 합니다.",
17
- minimum: "{minimum} 값과 같거나 커야 합니다",
18
- exclusiveMinimum: "{minimum} 보다 커야 합니다",
19
- maximum: "{maximum} 값과 같거나 작아야 합니다",
20
- exclusiveMaximum: "{maximum} 보다 작아야 합니다.",
21
- between: "{minimum}~{maximum} 사이의 값을 입력하세요.",
22
- betweenExclusiveMin: "{minimum} 보다 크고 {maximum} 보다 같거나 작아야 합니다",
23
- betweenExclusiveMax: "{minimum} 보다 같거나 크고 {maximum} 보다 작아야 합니다",
24
- betweenExclusiveMinMax: "{minimum} 보다 크고 {maximum} 보다 작아야 합니다",
25
- },
26
- regexp: {
27
- mobile: "핸드폰 번호가 유효하지 않습니다.",
28
- email: "이메일이 유효하지 않습니다.",
29
- url: "URL이 유효하지 않습니다.",
30
- alpha: "영문만 입력 가능 합니다.",
31
- "alpha-num": "영문과 숫자만 입력 가능 합니다.",
32
- number: "숫자만 입력 가능 합니다.",
33
- variable: "값이 유효하지 않습니다.",
34
- "number-char": "숫자, 문자 각각 하나 이상 포함 되어야 합니다.",
35
- "upper-char": "대문자가 하나 이상 포함 되어야 합니다.",
36
- "upper-char-special": "대문자,소문자,특수문자 각각 하나 이상 포함 되어야 합니다.",
37
- "upper-char-special-number": "대문자,소문자,특수문자,숫자 각각 하나 이상 포함 되어야합니다.",
38
- },
39
- };
40
-
41
- /**
42
- * validation 메시지 처리.
43
- *
44
- * @class Language
45
- * @typedef {Language}
46
- */
47
- class Language {
48
- private lang: Message = localeMessage;
49
-
50
- /**
51
- * 다국어 메시지 등록
52
- *
53
- * @public
54
- * @param {?Message} [lang] 둥록할 메시지
55
- */
56
- public set(lang?: Message) {
57
- this.lang = Object.assign({}, localeMessage, lang);
58
- }
59
-
60
- /**
61
- * 메시지 얻기
62
- *
63
- * @public
64
- * @param {string} messageKey 메시지 키
65
- * @returns {*}
66
- */
67
- public getMessage(messageKey: string): any {
68
- return (this.lang as any)[messageKey];
69
- }
70
-
71
- /**
72
- * ValidResult 값을 메시지로 변경.
73
- *
74
- * @public
75
- * @param {FormField} field
76
- * @param {ValidResult} validResult
77
- * @returns {string[]}
78
- */
79
- public validMessage(field: FormField, validResult: ValidResult): string[] {
80
- let messageFormat = "";
81
-
82
- let messageFormats: string[] = [];
83
-
84
- if (validResult.regexp) {
85
- messageFormat = (this.lang.regexp as any)[validResult.regexp];
86
- messageFormats.push(messageFormat);
87
- }
88
-
89
- (validResult.constraint ?? []).forEach((constraint) => {
90
- if (constraint === RULES.REQUIRED) {
91
- messageFormat = message(this.lang.required, field);
92
- messageFormats.push(messageFormat);
93
- }
94
-
95
- if (field.renderType == "number" || field.renderType == "range") {
96
- messageFormat = (this.lang.number as any)[constraint];
97
- messageFormats.push(messageFormat);
98
- } else {
99
- messageFormat = (this.lang.string as any)[constraint];
100
- messageFormats.push(messageFormat);
101
- }
102
- });
103
-
104
- const reMessage: string[] = [];
105
-
106
- const msgParam = Object.assign({}, { name: field.name, label: field.label }, field.rule);
107
- messageFormats.forEach((msgFormat) => {
108
- if (msgFormat) {
109
- reMessage.push(message(msgFormat, msgParam));
110
- }
111
- });
112
-
113
- if (validResult.validator) {
114
- reMessage.push(validResult.validator.message);
115
- }
116
-
117
- return reMessage;
118
- }
119
- }
120
-
121
- function message(msgFormat: string, msgParam: any): string {
122
- return msgFormat.replace(/\{{1,1}([A-Za-z0-9_.]*)\}{1,1}/g, (match, key) => {
123
- return typeof msgParam[key] !== "undefined" ? msgParam[key] : match;
124
- });
125
- }
126
-
127
- export default new Language();
@@ -1,26 +0,0 @@
1
- import { FormField } from "@t/FormField";
2
-
3
- import Render from "../renderer/Render";
4
- import { RENDER_TEMPLATE } from "../constants";
5
- import * as utils from "./utils";
6
-
7
- export const getRenderer = (field: FormField): Render => {
8
- let render;
9
- if (field.renderType) {
10
- render = RENDER_TEMPLATE[field.renderType];
11
- }
12
-
13
- if (render && (render.isDataRender() === false || !utils.isUndefined(field.name))) {
14
- return render;
15
- }
16
-
17
- if (utils.isUndefined(field.name)) {
18
- if (field.children) {
19
- return RENDER_TEMPLATE["group"];
20
- } else {
21
- return RENDER_TEMPLATE["hidden"];
22
- }
23
- }
24
-
25
- return RENDER_TEMPLATE["text"];
26
- };
@@ -1,85 +0,0 @@
1
- import { FieldStyle, FormField } from "@t/FormField";
2
- import * as utils from "./utils";
3
- import { FIELD_POSITION_STYLE, ALIGN } from "src/constants";
4
- import { FormOptions } from "@t/FormOptions";
5
-
6
- export default {
7
- /**
8
- * field style 처리
9
- *
10
- * @param formOptions FormOptions
11
- * @param field FormField
12
- * @param beforeField FormField
13
- * @returns FieldStyle
14
- */
15
- fieldStyle(formOptions: FormOptions, field: FormField, beforeField?: FormField | null, isLabelHide?: boolean): FieldStyle {
16
- const fieldStyle = {
17
- rowStyleClass: field.orientation === "horizontal" ? "horizontal" : "vertical",
18
- fieldClass: "",
19
- fieldStyle: "",
20
- labelClass: "",
21
- labelStyle: "",
22
- labelAlignClass: "",
23
- valueClass: "",
24
- valueStyle: "",
25
- tabAlignClass: "",
26
- };
27
-
28
- const defaultLabelWidth = beforeField?.style?.labelWidth ?? formOptions.style.labelWidth ?? "3";
29
- let defaultValueWidth = beforeField?.style?.valueWidth ?? formOptions.style.valueWidth ?? "9";
30
- const position = beforeField?.style?.position ?? formOptions.style.position;
31
-
32
- const width = field.style?.width;
33
- const positionArr = FIELD_POSITION_STYLE[field.style?.position] ?? FIELD_POSITION_STYLE[position] ?? FIELD_POSITION_STYLE.top;
34
-
35
- fieldStyle.fieldClass = `${positionArr[0]} ${field.style?.customClass || ""}`;
36
- if (width) {
37
- if (utils.isNumber(width)) {
38
- fieldStyle.fieldClass += utils.isNumber(width) ? ` col-xs-${width}` : "";
39
- } else {
40
- fieldStyle.fieldStyle = utils.isNumber(width) ? "" : `width:${width};`;
41
- }
42
- }
43
-
44
- fieldStyle.tabAlignClass = "tab-al-" + (["right", "center"].includes(field.style?.tabAlign) ? field.style.tabAlign : "left");
45
-
46
- const labelWidth = field.style?.labelWidth || defaultLabelWidth;
47
- fieldStyle.labelAlignClass = positionArr[1];
48
-
49
- if (!isLabelHide && labelWidth && !["top", "bottom"].includes(positionArr[0])) {
50
- if (utils.isNumber(labelWidth)) {
51
- const labelWidthValue = +labelWidth;
52
- defaultValueWidth = 12 - labelWidthValue;
53
- fieldStyle.labelClass = `col-xs-${labelWidthValue}`;
54
- fieldStyle.valueClass = fieldStyle.labelStyle ? "col-full" : `col-xs-${defaultValueWidth}`;
55
- } else {
56
- fieldStyle.labelStyle = `width:${labelWidth};`;
57
- }
58
- }
59
-
60
- const valueWidth = field.style?.valueWidth || defaultValueWidth;
61
- if (isLabelHide && !["left", "right"].includes(positionArr[0])) {
62
- fieldStyle.valueClass = "col-full";
63
- } else {
64
- if (valueWidth && !["top", "bottom"].includes(positionArr[0])) {
65
- if (utils.isNumber(valueWidth)) {
66
- fieldStyle.valueClass = fieldStyle.labelStyle ? "col-full" : `col-xs-${valueWidth}`;
67
- } else {
68
- fieldStyle.valueStyle = `width:${valueWidth};`;
69
- }
70
- } else {
71
- fieldStyle.valueClass = fieldStyle.labelStyle ? "col-full" : "";
72
- }
73
- }
74
-
75
- fieldStyle.fieldClass = spaceReplace(fieldStyle.fieldClass);
76
- fieldStyle.labelClass = spaceReplace(fieldStyle.labelClass);
77
- fieldStyle.valueClass = spaceReplace(fieldStyle.valueClass);
78
-
79
- return fieldStyle;
80
- },
81
- };
82
-
83
- function spaceReplace(str: string): string {
84
- return str.replace(/\s+/g, " ").trim();
85
- }