pds-dev-kit-web 1.3.27 → 1.3.28

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.
@@ -22,7 +22,10 @@ var react_hook_form_1 = require("react-hook-form");
22
22
  var components_1 = require("../components");
23
23
  var withFormProvider = function (storyFn) {
24
24
  var methods = (0, react_hook_form_1.useForm)({ mode: 'onChange' });
25
+ var handleSubmit = function (data) {
26
+ console.log('submit success', data);
27
+ };
25
28
  return (react_1.default.createElement(react_hook_form_1.FormProvider, __assign({}, methods),
26
- react_1.default.createElement(components_1.Form, { onSubmit: function () { } }, storyFn())));
29
+ react_1.default.createElement(components_1.Form, { onSubmit: methods.handleSubmit(handleSubmit) }, storyFn())));
27
30
  };
28
31
  exports.withFormProvider = withFormProvider;
@@ -34,7 +34,8 @@ export declare type TextFieldBaseProps = {
34
34
  onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>) => void;
35
35
  onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>) => void;
36
36
  onTarget?: () => void;
37
+ inputRef?: any;
37
38
  [x: string]: any;
38
39
  } & Record<string, any>;
39
- declare function TextFieldBase({ name, hintText, defaultText, validation, preventBlankMode, enterSubmitMode, textLineType, multiRows, autoMinRows, autoMaxRows, inputType, state, colorTheme, min, max, maxLength, textSize, textWeight, textPadding, fieldHeight, deleteIconMode, deleteIconSize, deleteIconColor, isFocused, onBlur, onChange, onFocus, onKeyDown, onKeyUp, onTarget, ...rest }: TextFieldBaseProps): JSX.Element;
40
+ declare function TextFieldBase({ name, hintText, defaultText, validation, preventBlankMode, enterSubmitMode, textLineType, multiRows, autoMinRows, autoMaxRows, inputType, state, colorTheme, min, max, maxLength, textSize, textWeight, textPadding, fieldHeight, deleteIconMode, deleteIconSize, deleteIconColor, isFocused, onBlur, onChange, onFocus, onKeyDown, onKeyUp, onTarget, inputRef, ...rest }: TextFieldBaseProps): JSX.Element;
40
41
  export default TextFieldBase;
@@ -52,7 +52,7 @@ var styled_components_1 = __importStar(require("styled-components"));
52
52
  var common_1 = require("../../../../common");
53
53
  var IconButton_1 = require("../../../components/IconButton");
54
54
  function TextFieldBase(_a) {
55
- var name = _a.name, hintText = _a.hintText, defaultText = _a.defaultText, validation = _a.validation, _b = _a.preventBlankMode, preventBlankMode = _b === void 0 ? 'none' : _b, _c = _a.enterSubmitMode, enterSubmitMode = _c === void 0 ? 'none' : _c, _d = _a.textLineType, textLineType = _d === void 0 ? 'single' : _d, multiRows = _a.multiRows, autoMinRows = _a.autoMinRows, autoMaxRows = _a.autoMaxRows, _e = _a.inputType, inputType = _e === void 0 ? 'text' : _e, _f = _a.state, state = _f === void 0 ? 'normal' : _f, _g = _a.colorTheme, colorTheme = _g === void 0 ? 'none' : _g, min = _a.min, max = _a.max, _h = _a.maxLength, maxLength = _h === void 0 ? Infinity : _h, _j = _a.textSize, textSize = _j === void 0 ? 'form2' : _j, _k = _a.textWeight, textWeight = _k === void 0 ? 'normal' : _k, textPadding = _a.textPadding, _l = _a.fieldHeight, fieldHeight = _l === void 0 ? 48 : _l, _m = _a.deleteIconMode, deleteIconMode = _m === void 0 ? 'use' : _m, _o = _a.deleteIconSize, deleteIconSize = _o === void 0 ? 20 : _o, _p = _a.deleteIconColor, deleteIconColor = _p === void 0 ? 'ui_cpnt_button_icon_disabled' : _p, isFocused = _a.isFocused, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onTarget = _a.onTarget, rest = __rest(_a, ["name", "hintText", "defaultText", "validation", "preventBlankMode", "enterSubmitMode", "textLineType", "multiRows", "autoMinRows", "autoMaxRows", "inputType", "state", "colorTheme", "min", "max", "maxLength", "textSize", "textWeight", "textPadding", "fieldHeight", "deleteIconMode", "deleteIconSize", "deleteIconColor", "isFocused", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "onTarget"]);
55
+ var name = _a.name, hintText = _a.hintText, defaultText = _a.defaultText, validation = _a.validation, _b = _a.preventBlankMode, preventBlankMode = _b === void 0 ? 'none' : _b, _c = _a.enterSubmitMode, enterSubmitMode = _c === void 0 ? 'none' : _c, _d = _a.textLineType, textLineType = _d === void 0 ? 'single' : _d, multiRows = _a.multiRows, autoMinRows = _a.autoMinRows, autoMaxRows = _a.autoMaxRows, _e = _a.inputType, inputType = _e === void 0 ? 'text' : _e, _f = _a.state, state = _f === void 0 ? 'normal' : _f, _g = _a.colorTheme, colorTheme = _g === void 0 ? 'none' : _g, min = _a.min, max = _a.max, _h = _a.maxLength, maxLength = _h === void 0 ? Infinity : _h, _j = _a.textSize, textSize = _j === void 0 ? 'form2' : _j, _k = _a.textWeight, textWeight = _k === void 0 ? 'normal' : _k, textPadding = _a.textPadding, _l = _a.fieldHeight, fieldHeight = _l === void 0 ? 48 : _l, _m = _a.deleteIconMode, deleteIconMode = _m === void 0 ? 'use' : _m, _o = _a.deleteIconSize, deleteIconSize = _o === void 0 ? 20 : _o, _p = _a.deleteIconColor, deleteIconColor = _p === void 0 ? 'ui_cpnt_button_icon_disabled' : _p, isFocused = _a.isFocused, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onTarget = _a.onTarget, inputRef = _a.inputRef, rest = __rest(_a, ["name", "hintText", "defaultText", "validation", "preventBlankMode", "enterSubmitMode", "textLineType", "multiRows", "autoMinRows", "autoMaxRows", "inputType", "state", "colorTheme", "min", "max", "maxLength", "textSize", "textWeight", "textPadding", "fieldHeight", "deleteIconMode", "deleteIconSize", "deleteIconColor", "isFocused", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "onTarget", "inputRef"]);
56
56
  var _q = (0, react_hook_form_1.useFormContext)(), register = _q.register, setValue = _q.setValue, getValues = _q.getValues, clearErrors = _q.clearErrors;
57
57
  var timeout;
58
58
  (0, react_1.useEffect)(function () {
@@ -173,16 +173,31 @@ function TextFieldBase(_a) {
173
173
  var S_TextFieldBase = function () {
174
174
  if (textLineType === 'single') {
175
175
  return (react_1.default.createElement(S_InputWrapper, null,
176
- react_1.default.createElement(S_Input, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, type: inputType, state: state, readOnly: state === 'read_only', disabled: state === 'disabled', maxLength: maxLength, textSize: textSize, textWeight: textWeight, textPadding: textPadding, colorTheme: colorTheme, min: min, max: max, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, ref: ref })),
176
+ react_1.default.createElement(S_Input, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, type: inputType, state: state, readOnly: state === 'read_only', disabled: state === 'disabled', maxLength: maxLength, textSize: textSize, textWeight: textWeight, textPadding: textPadding, colorTheme: colorTheme, min: min, max: max, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, ref: function (e) {
177
+ ref(e);
178
+ if (inputRef) {
179
+ inputRef.current = e;
180
+ }
181
+ } })),
177
182
  deleteIconMode === 'use' && isFocused && (react_1.default.createElement(IconButton_1.IconButton, { iconName: "ic_delete", baseSize: "small", shapeType: "rectangle", baseColorKey: "ui_cpnt_button_fill_base_transparent", iconSize: deleteIconSize, iconColorKey: deleteIconColor, iconFillType: "fill", state: state === 'disabled' ? 'disabled' : 'normal', tabIndex: -1, onMouseDown: deleteValue }))));
178
183
  }
179
184
  if (textLineType === 'multi') {
180
- return (react_1.default.createElement(S_Multi, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, rows: multiRows, textSize: textSize, textWeight: textWeight, textPadding: textPadding, colorTheme: colorTheme, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, ref: ref })));
185
+ return (react_1.default.createElement(S_Multi, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, rows: multiRows, textSize: textSize, textWeight: textWeight, textPadding: textPadding, colorTheme: colorTheme, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, ref: function (e) {
186
+ ref(e);
187
+ if (inputRef) {
188
+ inputRef.current = e;
189
+ }
190
+ } })));
181
191
  }
182
192
  if (textLineType === 'auto') {
183
193
  return (react_1.default.createElement(S_Auto, __assign({}, refRest, rest, { name: name, defaultValue: defaultText, autoMinRows: autoMinRows, autoMaxRows: autoMaxRows, placeholder: hintText, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, textSize: textSize, textWeight: textWeight, textPadding: textPadding, fieldHeight: fieldHeight, colorTheme: colorTheme, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, ref: function (e) {
184
194
  ref(e);
185
- textAreaRef.current = e;
195
+ if (textAreaRef) {
196
+ textAreaRef.current = e;
197
+ }
198
+ if (inputRef) {
199
+ inputRef.current = e;
200
+ }
186
201
  }, onInput: handleResizeHeight })));
187
202
  }
188
203
  };
@@ -34,10 +34,11 @@ function EditApplyTextField(_a) {
34
34
  var _b;
35
35
  var name = _a.name, hintText = _a.hintText, defaultText = _a.defaultText, validation = _a.validation, _c = _a.preventBlankMode, preventBlankMode = _c === void 0 ? 'none' : _c, _d = _a.size, size = _d === void 0 ? 'large' : _d, _e = _a.responsiveMode, responsiveMode = _e === void 0 ? 'none' : _e, _f = _a.textLineType, textLineType = _f === void 0 ? 'single' : _f, _g = _a.multiRows, multiRows = _g === void 0 ? 8 : _g, _h = _a.autoMinRows, autoMinRows = _h === void 0 ? 8 : _h, autoMaxRows = _a.autoMaxRows, _j = _a.inputType, inputType = _j === void 0 ? 'text' : _j, _k = _a.state, state = _k === void 0 ? 'normal' : _k, max = _a.max, maxLength = _a.maxLength, min = _a.min, getInputValue = _a.getInputValue, onBlur = _a.onBlur, onChange = _a.onChange, onClickSubmitBtn = _a.onClickSubmitBtn, onFocus = _a.onFocus, onTarget = _a.onTarget;
36
36
  var t = (0, react_i18next_1.useTranslation)('translation').t;
37
- var _l = (0, react_hook_form_1.useFormContext)(), register = _l.register, setValue = _l.setValue, trigger = _l.trigger, watch = _l.watch, errors = _l.formState.errors;
38
- var _m = (0, react_1.useState)(false), isFocused = _m[0], setIsFocused = _m[1];
39
- var _o = (0, react_1.useState)(false), isOpen = _o[0], setIsOpen = _o[1];
40
- var _p = (0, react_1.useState)(defaultText !== null && defaultText !== void 0 ? defaultText : ''), prevValue = _p[0], setPrevValue = _p[1];
37
+ var _l = (0, react_hook_form_1.useFormContext)(), register = _l.register, setValue = _l.setValue, trigger = _l.trigger, watch = _l.watch, reset = _l.reset, _m = _l.formState, errors = _m.errors, isSubmitSuccessful = _m.isSubmitSuccessful;
38
+ var _o = (0, react_1.useState)(false), isFocused = _o[0], setIsFocused = _o[1];
39
+ var _p = (0, react_1.useState)(false), isOpen = _p[0], setIsOpen = _p[1];
40
+ var _q = (0, react_1.useState)(defaultText !== null && defaultText !== void 0 ? defaultText : ''), prevValue = _q[0], setPrevValue = _q[1];
41
+ var ref = (0, react_1.useRef)();
41
42
  var currentValue = watch(name);
42
43
  var validateOnChange = register(name, validation).onChange;
43
44
  var isError = Object.keys(errors).some(function (error) { return error === name; });
@@ -49,6 +50,17 @@ function EditApplyTextField(_a) {
49
50
  }
50
51
  setValue(name, '');
51
52
  }, [defaultText]);
53
+ /**
54
+ * @when submit 버튼을 마우스로 클릭한 후 폼 제출에 성공했을 때
55
+ * @expected 인풋을 블러처리하고 인풋의 값은 유지한 채 isSubmitSuccessful을 초기화합니다.
56
+ */
57
+ (0, react_1.useEffect)(function () {
58
+ var _a;
59
+ if (isSubmitSuccessful) {
60
+ (_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.blur();
61
+ reset({ name: name }, { keepValues: true });
62
+ }
63
+ }, [isSubmitSuccessful]);
52
64
  function handleFocus(e) {
53
65
  if (state !== 'read_only') {
54
66
  setIsFocused(true);
@@ -82,44 +94,58 @@ function EditApplyTextField(_a) {
82
94
  function handleCancel() {
83
95
  setValue(name, prevValue);
84
96
  }
85
- function handleSubmit() {
86
- // NOTE: preventBlankMode는 input에만 적용 가능
87
- // NOTE: 다른 TextField의 경우 'preventBlankMode === 'trim'일 경우에는 무조건 onBlur 시점에 적용'된다고 정의해두었지만, EditApplyTextField는 onBlur 시점에 모든 값이 초기값으로 돌리는 기획이 있기때문에 EditApplyTextField에서는 submit 버튼을 눌렀을 경우에 시행
97
+ /*
98
+ * NOTE
99
+ * preventBlankMode input에만 적용 가능
100
+ * 다른 TextField의 경우 'preventBlankMode === 'trim'일 경우에는 무조건 onBlur 시점에 적용'된다고 정의해두었지만,
101
+ * EditApplyTextField는 onBlur 시점에 모든 값이 초기값으로 돌리는 기획이 있기때문에 EditApplyTextField에서는 submit 버튼을 눌렀을 경우에 시행
102
+ */
103
+ function checkBlankMode() {
88
104
  if (textLineType === 'single' && preventBlankMode === 'trim') {
89
105
  setValue(name, currentValue.replace(/^\s+|\s+$/gm, ''));
90
106
  setPrevValue(currentValue.replace(/^\s+|\s+$/gm, ''));
91
- if (getInputValue)
107
+ if (getInputValue) {
92
108
  getInputValue([name, currentValue.replace(/^\s+|\s+$/gm, '')]);
109
+ }
93
110
  }
94
111
  if (preventBlankMode !== 'trim') {
95
112
  setValue(name, currentValue);
96
113
  setPrevValue(currentValue);
97
- if (getInputValue)
114
+ if (getInputValue) {
98
115
  getInputValue([name, currentValue]);
116
+ }
99
117
  }
100
118
  if (onClickSubmitBtn) {
101
119
  onClickSubmitBtn();
102
120
  }
103
121
  }
104
- var handleKeyUp = function (e) {
122
+ var handleKeyDown = function (e) {
105
123
  if (textLineType === 'single' && e.key === 'Enter') {
106
- e.target.blur();
107
- handleSubmit();
124
+ checkBlankMode();
108
125
  }
109
126
  if (e.key === 'Escape') {
110
127
  e.target.blur();
111
128
  }
112
129
  };
130
+ var handleKeyUp = function (e) {
131
+ if (textLineType === 'single' && e.key === 'Enter') {
132
+ e.target.blur();
133
+ }
134
+ };
135
+ var handleMouseDown = function (e) {
136
+ e.preventDefault();
137
+ checkBlankMode();
138
+ };
113
139
  var S_TextFieldBase = function () {
114
140
  if (textLineType === 'multi') {
115
- return (react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, textLineType: "multi", multiRows: multiRows, state: state, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, onKeyUp: handleKeyUp }));
141
+ return (react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, textLineType: "multi", multiRows: multiRows, state: state, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, inputRef: ref }));
116
142
  }
117
143
  if (textLineType === 'auto') {
118
- return (react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, textLineType: "auto", autoMinRows: autoMinRows, autoMaxRows: autoMaxRows, state: state, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, onKeyUp: handleKeyUp }));
144
+ return (react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, textLineType: "auto", autoMinRows: autoMinRows, autoMaxRows: autoMaxRows, state: state, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, inputRef: ref }));
119
145
  }
120
146
  if (textLineType === 'single') {
121
147
  return (react_1.default.createElement(react_1.default.Fragment, null,
122
- react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, preventBlankMode: preventBlankMode, textLineType: "single", inputType: inputType, state: state, min: min, max: max, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, onKeyUp: handleKeyUp })));
148
+ react_1.default.createElement(components_1.TextFieldBase, { name: name, hintText: hintText, defaultText: defaultText, validation: validation, preventBlankMode: preventBlankMode, enterSubmitMode: "use", textLineType: "single", inputType: inputType, state: state, min: min, max: max, maxLength: maxLength, textSize: size === 'large' || size === 'rlarge' ? 'form2' : 'heading', textWeight: size === 'large' || size === 'rlarge' ? 'normal' : 'bold', onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onChange: handleChange, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, inputRef: ref })));
123
149
  }
124
150
  };
125
151
  return (react_1.default.createElement(react_1.default.Fragment, null,
@@ -128,7 +154,7 @@ function EditApplyTextField(_a) {
128
154
  react_1.default.createElement(S_S_TextFieldBaseWrapper, { size: size, responsiveMode: responsiveMode, textLineType: textLineType, isFocused: isFocused, isError: isError, state: state }, S_TextFieldBase()),
129
155
  isOpen === true && (react_1.default.createElement(S_ButtonBox, null,
130
156
  react_1.default.createElement(IconButton_1.IconButton, { iconName: "ic_xmark", fillType: "fill", baseSize: "small", iconSize: 16, shapeType: "circular", shadow: "visible", iconColorKey: "ui_cpnt_button_icon_enabled", baseColorKey: "ui_cpnt_button_fill_base_white", tabIndex: -1, onMouseDown: handleCancel }),
131
- react_1.default.createElement(IconButton_1.IconButton, { iconName: "ic_check", fillType: "fill", baseSize: "small", iconSize: 16, shapeType: "circular", shadow: "visible", iconColorKey: "ui_cpnt_button_icon_on_primary", baseColorKey: "ui_cpnt_button_fill_base_primary", state: isError === true ? 'disabled' : 'normal', tabIndex: -1, onMouseDown: handleSubmit, type: "submit" })))),
157
+ react_1.default.createElement(IconButton_1.IconButton, { iconName: "ic_check", fillType: "fill", baseSize: "small", iconSize: 16, shapeType: "circular", shadow: "visible", iconColorKey: "ui_cpnt_button_icon_on_primary", baseColorKey: "ui_cpnt_button_fill_base_primary", state: isError === true ? 'disabled' : 'normal', tabIndex: -1, onMouseDown: handleMouseDown, type: "submit" })))),
132
158
  ((_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message) && (react_1.default.createElement(S_Error, { isFocused: isFocused }, t(errors[name].message))))));
133
159
  }
134
160
  var S_EditApplyTextFieldWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", ";\n"], ["\n width: ", ";\n"])), function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web",
3
- "version": "1.3.27",
3
+ "version": "1.3.28",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
package/release-note.md CHANGED
@@ -1,9 +1,6 @@
1
1
  # PDS-DEV-KIT-WEB Release Notes
2
- ## [v1.3.27]
2
+ ## [v1.3.28]
3
3
 
4
4
  ### Component
5
- * IconButton
6
- * baseColorKey가 ui_cpnt_button_fill_base_transparent(투명)일때, icon색상 변경
7
-
8
- ### Color
9
- * 컬러 키 값 22.05.31 22시 10분 기준 싱크
5
+ * EditApplyTextField
6
+ * Form 컴포넌트의 onSubmit을 이용했을 때에도 submit과 blur 처리가 제대로 작동할 수 있게끔 수정