pds-dev-kit-web 2.2.210 → 2.2.211
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/src/desktop/components/PriceTextField/PriceTextField.d.ts +5 -4
- package/dist/src/desktop/components/PriceTextField/PriceTextField.js +53 -70
- package/dist/src/mobile/components/PriceTextField/PriceTextField.d.ts +5 -4
- package/dist/src/mobile/components/PriceTextField/PriceTextField.js +53 -70
- package/package.json +1 -1
- package/release-note.md +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Path } from 'react-hook-form';
|
|
3
|
-
import { CurrencyCode
|
|
3
|
+
import { CurrencyCode } from '../../../core/pricing';
|
|
4
4
|
import type { IFormValues, PDSTextType } from '../../../common';
|
|
5
5
|
import type { TextFieldBaseProps } from '../../common/components/TextFieldBase/TextFieldBase';
|
|
6
6
|
export declare const DEFAULT_DECIMAL_PLACES: {
|
|
@@ -19,12 +19,13 @@ type Props = {
|
|
|
19
19
|
baseCurrency?: CurrencyCode;
|
|
20
20
|
currencies?: CurrencyCode[];
|
|
21
21
|
decimalPlaces?: Record<string, number>;
|
|
22
|
-
exchangeRates?:
|
|
22
|
+
exchangeRates?: {
|
|
23
|
+
[key: string]: number;
|
|
24
|
+
};
|
|
23
25
|
hintTextFontWeight?: 'normal' | 'bold';
|
|
24
26
|
validation?: any;
|
|
25
27
|
useRequiredValidation?: 'none' | 'use';
|
|
26
28
|
useDotBadge?: 'none' | 'use';
|
|
27
|
-
returnType?: 'object' | 'string' | 'rawValue';
|
|
28
29
|
deleteBtnMode?: 'none' | 'use';
|
|
29
30
|
minPriceAmount?: string | number;
|
|
30
31
|
onExChange?: (e: React.ChangeEvent<HTMLInputElement> | React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
@@ -39,5 +40,5 @@ type Props = {
|
|
|
39
40
|
displayValue: string;
|
|
40
41
|
}) => void;
|
|
41
42
|
} & Omit<Partial<TextFieldBaseProps>, 'textAlign' | 'preventBlankMode' | 'enterSubmitMode' | 'multiRows' | 'colorTheme'>;
|
|
42
|
-
declare function PriceTextField({ name, hintText, defaultAmount, colorTheme, size, fontWeight, hintTextFontWeight, responsiveMode, state, dropdownState, customWidth, baseCurrency, currencies, decimalPlaces, exchangeRates, textAlign, validation, useRequiredValidation, useDotBadge,
|
|
43
|
+
declare function PriceTextField({ name, hintText, defaultAmount, colorTheme, size, fontWeight, hintTextFontWeight, responsiveMode, state, dropdownState, customWidth, baseCurrency, currencies, decimalPlaces, exchangeRates, textAlign, validation, useRequiredValidation, useDotBadge, deleteBtnMode, minPriceAmount, onChange, onExChange, onBlur, onFocus, onTarget, onCurrencyChange, onValueChange }: Props): JSX.Element;
|
|
43
44
|
export default PriceTextField;
|
|
@@ -66,18 +66,50 @@ exports.DEFAULT_DECIMAL_PLACES = {
|
|
|
66
66
|
function PriceTextField(_a) {
|
|
67
67
|
var _b;
|
|
68
68
|
var _c;
|
|
69
|
-
var name = _a.name, hintText = _a.hintText, defaultAmount = _a.defaultAmount, _d = _a.colorTheme, colorTheme = _d === void 0 ? 'none' : _d, _e = _a.size, size = _e === void 0 ? 'large' : _e, _f = _a.fontWeight, fontWeight = _f === void 0 ? 'bold' : _f, _g = _a.hintTextFontWeight, hintTextFontWeight = _g === void 0 ? 'normal' : _g, _h = _a.responsiveMode, responsiveMode = _h === void 0 ? 'none' : _h, _j = _a.state, state = _j === void 0 ? 'normal' : _j, _k = _a.dropdownState, dropdownState = _k === void 0 ? 'normal' : _k, customWidth = _a.customWidth, _l = _a.baseCurrency, baseCurrency = _l === void 0 ? pricing_1.CurrencyCode.KRW : _l, _m = _a.currencies, currencies = _m === void 0 ? [pricing_1.CurrencyCode.KRW, pricing_1.CurrencyCode.USD] : _m, _o = _a.decimalPlaces, decimalPlaces = _o === void 0 ? exports.DEFAULT_DECIMAL_PLACES : _o, _p = _a.exchangeRates, exchangeRates = _p === void 0 ? (_b = {}, _b[pricing_1.CurrencyCode.KRW] = 1300, _b[pricing_1.CurrencyCode.USD] = 1, _b) : _p, _q = _a.textAlign, textAlign = _q === void 0 ? 'right' : _q, validation = _a.validation, _r = _a.useRequiredValidation, useRequiredValidation = _r === void 0 ? 'use' : _r, _s = _a.useDotBadge, useDotBadge = _s === void 0 ? 'use' : _s, _t = _a.
|
|
69
|
+
var name = _a.name, hintText = _a.hintText, defaultAmount = _a.defaultAmount, _d = _a.colorTheme, colorTheme = _d === void 0 ? 'none' : _d, _e = _a.size, size = _e === void 0 ? 'large' : _e, _f = _a.fontWeight, fontWeight = _f === void 0 ? 'bold' : _f, _g = _a.hintTextFontWeight, hintTextFontWeight = _g === void 0 ? 'normal' : _g, _h = _a.responsiveMode, responsiveMode = _h === void 0 ? 'none' : _h, _j = _a.state, state = _j === void 0 ? 'normal' : _j, _k = _a.dropdownState, dropdownState = _k === void 0 ? 'normal' : _k, customWidth = _a.customWidth, _l = _a.baseCurrency, baseCurrency = _l === void 0 ? pricing_1.CurrencyCode.KRW : _l, _m = _a.currencies, currencies = _m === void 0 ? [pricing_1.CurrencyCode.KRW, pricing_1.CurrencyCode.USD] : _m, _o = _a.decimalPlaces, decimalPlaces = _o === void 0 ? exports.DEFAULT_DECIMAL_PLACES : _o, _p = _a.exchangeRates, exchangeRates = _p === void 0 ? (_b = {}, _b[pricing_1.CurrencyCode.KRW] = 1300, _b[pricing_1.CurrencyCode.USD] = 1, _b) : _p, _q = _a.textAlign, textAlign = _q === void 0 ? 'right' : _q, validation = _a.validation, _r = _a.useRequiredValidation, useRequiredValidation = _r === void 0 ? 'use' : _r, _s = _a.useDotBadge, useDotBadge = _s === void 0 ? 'use' : _s, _t = _a.deleteBtnMode, deleteBtnMode = _t === void 0 ? 'use' : _t, minPriceAmount = _a.minPriceAmount, onChange = _a.onChange, onExChange = _a.onExChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onTarget = _a.onTarget, onCurrencyChange = _a.onCurrencyChange, onValueChange = _a.onValueChange;
|
|
70
70
|
var t = (0, react_i18next_1.useTranslation)('translation').t;
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
71
|
+
var _u = (0, react_1.useState)(defaultAmount ? String(defaultAmount) : ''), baseCurrencyValue = _u[0], setBaseCurrencyValue = _u[1];
|
|
72
|
+
var _v = (0, react_1.useState)(baseCurrency), selectedCurrency = _v[0], setSelectedCurrency = _v[1];
|
|
73
|
+
var _w = (0, react_1.useState)(false), isDropdownFocused = _w[0], setIsDropdownFocused = _w[1];
|
|
74
|
+
var _x = (0, react_1.useState)(false), isInputFocused = _x[0], setIsInputFocused = _x[1];
|
|
75
|
+
var _y = (0, react_1.useState)(null), contextMenuSizeOffset = _y[0], setContextMenuSizeOffset = _y[1];
|
|
76
|
+
var _z = (0, react_1.useState)(null), dropdownPositionOffset = _z[0], setDropdownPositionOffset = _z[1];
|
|
77
|
+
/** 입력 시 천 단위 콤마 추가 함수 */
|
|
78
|
+
var addCommas = function (value) {
|
|
79
|
+
if (!value)
|
|
80
|
+
return '';
|
|
81
|
+
var parts = value.split('.');
|
|
82
|
+
var integerPart = parts[0];
|
|
83
|
+
var decimalPart = parts[1];
|
|
84
|
+
// 정수 부분에 콤마 추가
|
|
85
|
+
var formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
86
|
+
// 소수점이 있으면 합치기
|
|
87
|
+
return decimalPart !== undefined ? "".concat(formattedInteger, ".").concat(decimalPart) : formattedInteger;
|
|
88
|
+
};
|
|
89
|
+
var displayValue = (0, react_1.useMemo)(function () {
|
|
90
|
+
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
if (selectedCurrency === baseCurrency) {
|
|
94
|
+
return isInputFocused
|
|
95
|
+
? addCommas(baseCurrencyValue)
|
|
96
|
+
: formatCurrency(Number(baseCurrencyValue), selectedCurrency, decimalPlaces);
|
|
97
|
+
}
|
|
98
|
+
var rate = exchangeRates[selectedCurrency] || 1;
|
|
99
|
+
var baseRate = exchangeRates[baseCurrency] || 1;
|
|
100
|
+
var convertedValue = (Number(baseCurrencyValue) / baseRate) * rate;
|
|
101
|
+
return formatCurrency(convertedValue, selectedCurrency, decimalPlaces);
|
|
102
|
+
}, [
|
|
103
|
+
baseCurrencyValue,
|
|
104
|
+
selectedCurrency,
|
|
105
|
+
baseCurrency,
|
|
106
|
+
exchangeRates,
|
|
107
|
+
decimalPlaces,
|
|
108
|
+
isInputFocused
|
|
109
|
+
]);
|
|
78
110
|
var contextMenuRef = (0, react_1.useRef)(null);
|
|
79
111
|
var dropdownRef = (0, react_1.useRef)(null);
|
|
80
|
-
var
|
|
112
|
+
var _0 = (0, react_hook_form_1.useFormContext)(), register = _0.register, trigger = _0.trigger, errors = _0.formState.errors, setValue = _0.setValue;
|
|
81
113
|
/** 기본 validation */
|
|
82
114
|
var defaultValidation = (0, react_1.useMemo)(function () {
|
|
83
115
|
var validationConfig = {};
|
|
@@ -192,30 +224,13 @@ function PriceTextField(_a) {
|
|
|
192
224
|
};
|
|
193
225
|
// 환율 계산된 값 계산 (항상 baseCurrency 기준으로)
|
|
194
226
|
var calculatedValue = (0, react_1.useMemo)(function () {
|
|
195
|
-
if (selectedCurrency === baseCurrency) {
|
|
227
|
+
if (!baseCurrencyValue || selectedCurrency === baseCurrency) {
|
|
196
228
|
return Number(baseCurrencyValue);
|
|
197
229
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (isInputFocused && selectedCurrency === baseCurrency) {
|
|
203
|
-
setDisplayValue(addCommas(baseCurrencyValue) || '');
|
|
204
|
-
}
|
|
205
|
-
else if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
206
|
-
setDisplayValue('');
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
setDisplayValue(formatCurrency(calculatedValue, selectedCurrency, decimalPlaces));
|
|
210
|
-
}
|
|
211
|
-
}, [
|
|
212
|
-
baseCurrencyValue,
|
|
213
|
-
calculatedValue,
|
|
214
|
-
selectedCurrency,
|
|
215
|
-
isInputFocused,
|
|
216
|
-
baseCurrency,
|
|
217
|
-
decimalPlaces
|
|
218
|
-
]);
|
|
230
|
+
var rate = exchangeRates[selectedCurrency] || 1;
|
|
231
|
+
var baseRate = exchangeRates[baseCurrency] || 1;
|
|
232
|
+
return (Number(baseCurrencyValue) / baseRate) * rate;
|
|
233
|
+
}, [baseCurrencyValue, selectedCurrency, baseCurrency, exchangeRates]);
|
|
219
234
|
/** 드롭다운 위치 업데이트 */
|
|
220
235
|
(0, react_1.useEffect)(function () {
|
|
221
236
|
if (!isDropdownFocused && contextMenuRef.current) {
|
|
@@ -245,36 +260,16 @@ function PriceTextField(_a) {
|
|
|
245
260
|
}
|
|
246
261
|
return formatCurrency(calculatedValue || 0, selectedCurrency, decimalPlaces);
|
|
247
262
|
}, [baseCurrencyValue, calculatedValue, selectedCurrency, decimalPlaces]);
|
|
248
|
-
/** returnType에 따른 폼 값 */
|
|
249
|
-
var formValue = (0, react_1.useMemo)(function () {
|
|
250
|
-
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
251
|
-
return '';
|
|
252
|
-
}
|
|
253
|
-
switch (returnType) {
|
|
254
|
-
case 'string':
|
|
255
|
-
return formattedValue;
|
|
256
|
-
case 'rawValue':
|
|
257
|
-
return baseCurrencyValue;
|
|
258
|
-
case 'object':
|
|
259
|
-
default:
|
|
260
|
-
return formattedValue;
|
|
261
|
-
}
|
|
262
|
-
}, [baseCurrencyValue, formattedValue, returnType]);
|
|
263
263
|
/** 폼 값 업데이트 */
|
|
264
264
|
(0, react_1.useEffect)(function () {
|
|
265
|
-
setValue(name,
|
|
266
|
-
}, [name, setValue,
|
|
265
|
+
setValue(name, baseCurrencyValue);
|
|
266
|
+
}, [name, setValue, baseCurrencyValue]);
|
|
267
267
|
/** onChange 콜백 처리 */
|
|
268
268
|
(0, react_1.useEffect)(function () {
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
272
|
-
onChange('');
|
|
273
|
-
return;
|
|
269
|
+
if (onChange && baseCurrencyValue) {
|
|
270
|
+
onChange(baseCurrencyValue);
|
|
274
271
|
}
|
|
275
|
-
|
|
276
|
-
onChange(callbackValue);
|
|
277
|
-
}, [onChange, baseCurrencyValue, formattedValue, formValue, returnType]);
|
|
272
|
+
}, [onChange, baseCurrencyValue]);
|
|
278
273
|
/** onValueChange 콜백 처리 */
|
|
279
274
|
(0, react_1.useEffect)(function () {
|
|
280
275
|
if (!onValueChange)
|
|
@@ -289,18 +284,6 @@ function PriceTextField(_a) {
|
|
|
289
284
|
displayValue: formattedValue
|
|
290
285
|
});
|
|
291
286
|
}, [baseCurrencyValue, selectedCurrency, calculatedValue, formattedValue]);
|
|
292
|
-
/** 입력 시 천 단위 콤마 추가 함수 */
|
|
293
|
-
var addCommas = function (value) {
|
|
294
|
-
if (!value)
|
|
295
|
-
return '';
|
|
296
|
-
var parts = value.split('.');
|
|
297
|
-
var integerPart = parts[0];
|
|
298
|
-
var decimalPart = parts[1];
|
|
299
|
-
// 정수 부분에 콤마 추가
|
|
300
|
-
var formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
301
|
-
// 소수점이 있으면 합치기
|
|
302
|
-
return decimalPart !== undefined ? "".concat(formattedInteger, ".").concat(decimalPart) : formattedInteger;
|
|
303
|
-
};
|
|
304
287
|
var handleChange = function (e) {
|
|
305
288
|
var _a = e.target, value = _a.value, selectionStart = _a.selectionStart;
|
|
306
289
|
var prevValue = displayValue;
|
|
@@ -434,13 +417,13 @@ function PriceTextField(_a) {
|
|
|
434
417
|
};
|
|
435
418
|
var handleDelete = (0, react_1.useCallback)(function () {
|
|
436
419
|
setBaseCurrencyValue('');
|
|
437
|
-
setDisplayValue('');
|
|
438
420
|
setValue(name, '');
|
|
439
421
|
}, [name, setValue]);
|
|
440
422
|
return ((0, jsx_runtime_1.jsxs)(S_PriceTextField, __assign({ "x-pds-name": "PriceTextField", "x-pds-element-type": "component", "x-pds-device-type": "desktop", inputSize: size, responsiveMode: responsiveMode, customWidth: customWidth }, { children: [(0, jsx_runtime_1.jsxs)(S_ComponentBox, __assign({ inputSize: size, responsiveMode: responsiveMode, isFocused: isInputFocused, isError: Boolean(isError), state: state, customWidth: customWidth, isInputReadOnly: isInputReadOnly }, { children: [(0, jsx_runtime_1.jsx)(S_TextFieldBaseWrapper, __assign({ state: state, isError: Boolean(isError), isFocused: isInputFocused, inputSize: size, isInputReadOnly: isInputReadOnly }, { children: (0, jsx_runtime_1.jsx)(components_1.TextFieldBase, { name: name, hintText: hintText ||
|
|
441
423
|
t('str_channel_min_price', {
|
|
442
424
|
channelMinPrice: pricing_1.PricingService.format.price({
|
|
443
|
-
amount: minPriceAmount ||
|
|
425
|
+
amount: minPriceAmount ||
|
|
426
|
+
policy_1.DEFAULT_CURRENCY_PRICE_POLICIES[baseCurrency].minPayment.amount,
|
|
444
427
|
currency: baseCurrency
|
|
445
428
|
})
|
|
446
429
|
}), value: displayValue, textAlign: textAlign, validation: finalValidation, textLineType: "single", inputType: "text", inputMode: "decimal", preventBlankMode: "all", enterSubmitMode: "none", state: isInputReadOnly ? 'read_only' : state, colorTheme: colorTheme, textSize: "form2", textWeight: fontWeight === 'bold' ? 'bold' : 'normal', hintTextWeight: hintTextFontWeight === 'bold' ? 'bold' : 'normal', fieldPaddingRight: size === 'large' || size === 'rlarge' ? 12 : undefined, deleteIconMode: deleteBtnMode, deleteIconSize: size === 'large' || size === 'rlarge' ? 20 : 16, deleteIconColor: deleteIconColor, isFocused: isInputFocused, suffixTextRightSpacingMode: size === 'large' || size === 'rlarge' ? 'use' : 'none', onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onDelete: handleDelete }) })), (0, jsx_runtime_1.jsx)(S_DropdownWrapper, __assign({ ref: dropdownRef, inputSize: size, onClick: handleDropdownClick, onBlur: handleDropdownBlur, tabIndex: 0, isFocused: isDropdownFocused, state: dropdownState, isError: Boolean(isError) }, { children: (0, jsx_runtime_1.jsxs)(S_Select, __assign({ inputSize: size }, { children: [useDotBadge === 'use' && selectedCurrency === baseCurrency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(S_Badge, {}), (0, jsx_runtime_1.jsx)(hybrid_1.Spacing, { size: "spacing_a", spacingType: "width" })] })), (0, jsx_runtime_1.jsx)(TextLabel_1.TextLabel, { text: selectedCurrency, styleTheme: "form2Bold", singleLineMode: "use", colorTheme: "sysTextPrimary", ellipsisMode: "use", customFontWeight: "bold", colorOverride: getDropdownTextColorKey(), lineLimit: 1 }), (0, jsx_runtime_1.jsx)(hybrid_1.Spacing, { size: "spacing_a", spacingType: "width" }), (0, jsx_runtime_1.jsx)(hybrid_1.Icon, { size: 16, fillType: "line", iconName: isDropdownFocused ? 'ic_arrow_up' : 'ic_arrow_down', colorKey: getArrowIconColorKey() })] })) }))] })), isDropdownFocused &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Path } from 'react-hook-form';
|
|
3
|
-
import { CurrencyCode
|
|
3
|
+
import { CurrencyCode } from '../../../core/pricing';
|
|
4
4
|
import type { IFormValues, PDSTextType } from '../../../common';
|
|
5
5
|
import type { TextFieldBaseProps } from '../../common/components/TextFieldBase/TextFieldBase';
|
|
6
6
|
export declare const DEFAULT_DECIMAL_PLACES: {
|
|
@@ -19,12 +19,13 @@ type Props = {
|
|
|
19
19
|
baseCurrency?: CurrencyCode;
|
|
20
20
|
currencies?: CurrencyCode[];
|
|
21
21
|
decimalPlaces?: Record<string, number>;
|
|
22
|
-
exchangeRates?:
|
|
22
|
+
exchangeRates?: {
|
|
23
|
+
[key: string]: number;
|
|
24
|
+
};
|
|
23
25
|
hintTextFontWeight?: 'normal' | 'bold';
|
|
24
26
|
validation?: any;
|
|
25
27
|
useRequiredValidation?: 'none' | 'use';
|
|
26
28
|
useDotBadge?: 'none' | 'use';
|
|
27
|
-
returnType?: 'object' | 'string' | 'rawValue';
|
|
28
29
|
deleteBtnMode?: 'none' | 'use';
|
|
29
30
|
minPriceAmount?: string | number;
|
|
30
31
|
onChange?: (value: string) => void;
|
|
@@ -38,5 +39,5 @@ type Props = {
|
|
|
38
39
|
displayValue: string;
|
|
39
40
|
}) => void;
|
|
40
41
|
} & Omit<Partial<TextFieldBaseProps>, 'textAlign' | 'preventBlankMode' | 'enterSubmitMode' | 'multiRows' | 'colorTheme'>;
|
|
41
|
-
declare function PriceTextField({ name, hintText, defaultAmount, colorTheme, size, fontWeight, hintTextFontWeight, responsiveMode, state, dropdownState, customWidth, baseCurrency, currencies, decimalPlaces, exchangeRates, textAlign, validation, useRequiredValidation, useDotBadge,
|
|
42
|
+
declare function PriceTextField({ name, hintText, defaultAmount, colorTheme, size, fontWeight, hintTextFontWeight, responsiveMode, state, dropdownState, customWidth, baseCurrency, currencies, decimalPlaces, exchangeRates, textAlign, validation, useRequiredValidation, useDotBadge, deleteBtnMode, minPriceAmount, onChange, onBlur, onFocus, onTarget, onCurrencyChange, onValueChange }: Props): JSX.Element;
|
|
42
43
|
export default PriceTextField;
|
|
@@ -66,18 +66,50 @@ exports.DEFAULT_DECIMAL_PLACES = {
|
|
|
66
66
|
function PriceTextField(_a) {
|
|
67
67
|
var _b;
|
|
68
68
|
var _c;
|
|
69
|
-
var name = _a.name, hintText = _a.hintText, defaultAmount = _a.defaultAmount, _d = _a.colorTheme, colorTheme = _d === void 0 ? 'none' : _d, _e = _a.size, size = _e === void 0 ? 'large' : _e, _f = _a.fontWeight, fontWeight = _f === void 0 ? 'bold' : _f, _g = _a.hintTextFontWeight, hintTextFontWeight = _g === void 0 ? 'normal' : _g, _h = _a.responsiveMode, responsiveMode = _h === void 0 ? 'none' : _h, _j = _a.state, state = _j === void 0 ? 'normal' : _j, _k = _a.dropdownState, dropdownState = _k === void 0 ? 'normal' : _k, customWidth = _a.customWidth, _l = _a.baseCurrency, baseCurrency = _l === void 0 ? pricing_1.CurrencyCode.KRW : _l, _m = _a.currencies, currencies = _m === void 0 ? [pricing_1.CurrencyCode.KRW, pricing_1.CurrencyCode.USD] : _m, _o = _a.decimalPlaces, decimalPlaces = _o === void 0 ? exports.DEFAULT_DECIMAL_PLACES : _o, _p = _a.exchangeRates, exchangeRates = _p === void 0 ? (_b = {}, _b[pricing_1.CurrencyCode.KRW] = 1300, _b[pricing_1.CurrencyCode.USD] = 1, _b) : _p, _q = _a.textAlign, textAlign = _q === void 0 ? 'right' : _q, validation = _a.validation, _r = _a.useRequiredValidation, useRequiredValidation = _r === void 0 ? 'use' : _r, _s = _a.useDotBadge, useDotBadge = _s === void 0 ? 'use' : _s, _t = _a.
|
|
69
|
+
var name = _a.name, hintText = _a.hintText, defaultAmount = _a.defaultAmount, _d = _a.colorTheme, colorTheme = _d === void 0 ? 'none' : _d, _e = _a.size, size = _e === void 0 ? 'large' : _e, _f = _a.fontWeight, fontWeight = _f === void 0 ? 'bold' : _f, _g = _a.hintTextFontWeight, hintTextFontWeight = _g === void 0 ? 'normal' : _g, _h = _a.responsiveMode, responsiveMode = _h === void 0 ? 'none' : _h, _j = _a.state, state = _j === void 0 ? 'normal' : _j, _k = _a.dropdownState, dropdownState = _k === void 0 ? 'normal' : _k, customWidth = _a.customWidth, _l = _a.baseCurrency, baseCurrency = _l === void 0 ? pricing_1.CurrencyCode.KRW : _l, _m = _a.currencies, currencies = _m === void 0 ? [pricing_1.CurrencyCode.KRW, pricing_1.CurrencyCode.USD] : _m, _o = _a.decimalPlaces, decimalPlaces = _o === void 0 ? exports.DEFAULT_DECIMAL_PLACES : _o, _p = _a.exchangeRates, exchangeRates = _p === void 0 ? (_b = {}, _b[pricing_1.CurrencyCode.KRW] = 1300, _b[pricing_1.CurrencyCode.USD] = 1, _b) : _p, _q = _a.textAlign, textAlign = _q === void 0 ? 'right' : _q, validation = _a.validation, _r = _a.useRequiredValidation, useRequiredValidation = _r === void 0 ? 'use' : _r, _s = _a.useDotBadge, useDotBadge = _s === void 0 ? 'use' : _s, _t = _a.deleteBtnMode, deleteBtnMode = _t === void 0 ? 'use' : _t, minPriceAmount = _a.minPriceAmount, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onTarget = _a.onTarget, onCurrencyChange = _a.onCurrencyChange, onValueChange = _a.onValueChange;
|
|
70
70
|
var t = (0, react_i18next_1.useTranslation)('translation').t;
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
71
|
+
var _u = (0, react_1.useState)(defaultAmount ? String(defaultAmount) : ''), baseCurrencyValue = _u[0], setBaseCurrencyValue = _u[1];
|
|
72
|
+
var _v = (0, react_1.useState)(baseCurrency), selectedCurrency = _v[0], setSelectedCurrency = _v[1];
|
|
73
|
+
var _w = (0, react_1.useState)(false), isDropdownFocused = _w[0], setIsDropdownFocused = _w[1];
|
|
74
|
+
var _x = (0, react_1.useState)(false), isInputFocused = _x[0], setIsInputFocused = _x[1];
|
|
75
|
+
var _y = (0, react_1.useState)(null), contextMenuSizeOffset = _y[0], setContextMenuSizeOffset = _y[1];
|
|
76
|
+
var _z = (0, react_1.useState)(null), dropdownPositionOffset = _z[0], setDropdownPositionOffset = _z[1];
|
|
77
|
+
/** 입력 시 천 단위 콤마 추가 함수 */
|
|
78
|
+
var addCommas = function (value) {
|
|
79
|
+
if (!value)
|
|
80
|
+
return '';
|
|
81
|
+
var parts = value.split('.');
|
|
82
|
+
var integerPart = parts[0];
|
|
83
|
+
var decimalPart = parts[1];
|
|
84
|
+
// 정수 부분에 콤마 추가
|
|
85
|
+
var formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
86
|
+
// 소수점이 있으면 합치기
|
|
87
|
+
return decimalPart !== undefined ? "".concat(formattedInteger, ".").concat(decimalPart) : formattedInteger;
|
|
88
|
+
};
|
|
89
|
+
var displayValue = (0, react_1.useMemo)(function () {
|
|
90
|
+
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
if (selectedCurrency === baseCurrency) {
|
|
94
|
+
return isInputFocused
|
|
95
|
+
? addCommas(baseCurrencyValue)
|
|
96
|
+
: formatCurrency(Number(baseCurrencyValue), selectedCurrency, decimalPlaces);
|
|
97
|
+
}
|
|
98
|
+
var rate = exchangeRates[selectedCurrency] || 1;
|
|
99
|
+
var baseRate = exchangeRates[baseCurrency] || 1;
|
|
100
|
+
var convertedValue = (Number(baseCurrencyValue) / baseRate) * rate;
|
|
101
|
+
return formatCurrency(convertedValue, selectedCurrency, decimalPlaces);
|
|
102
|
+
}, [
|
|
103
|
+
baseCurrencyValue,
|
|
104
|
+
selectedCurrency,
|
|
105
|
+
baseCurrency,
|
|
106
|
+
exchangeRates,
|
|
107
|
+
decimalPlaces,
|
|
108
|
+
isInputFocused
|
|
109
|
+
]);
|
|
78
110
|
var contextMenuRef = (0, react_1.useRef)(null);
|
|
79
111
|
var dropdownRef = (0, react_1.useRef)(null);
|
|
80
|
-
var
|
|
112
|
+
var _0 = (0, react_hook_form_1.useFormContext)(), register = _0.register, trigger = _0.trigger, errors = _0.formState.errors, setValue = _0.setValue;
|
|
81
113
|
/** 기본 validation */
|
|
82
114
|
var defaultValidation = (0, react_1.useMemo)(function () {
|
|
83
115
|
var validationConfig = {};
|
|
@@ -192,30 +224,13 @@ function PriceTextField(_a) {
|
|
|
192
224
|
};
|
|
193
225
|
// 환율 계산된 값 계산 (항상 baseCurrency 기준으로)
|
|
194
226
|
var calculatedValue = (0, react_1.useMemo)(function () {
|
|
195
|
-
if (selectedCurrency === baseCurrency) {
|
|
227
|
+
if (!baseCurrencyValue || selectedCurrency === baseCurrency) {
|
|
196
228
|
return Number(baseCurrencyValue);
|
|
197
229
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (isInputFocused && selectedCurrency === baseCurrency) {
|
|
203
|
-
setDisplayValue(addCommas(baseCurrencyValue) || '');
|
|
204
|
-
}
|
|
205
|
-
else if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
206
|
-
setDisplayValue('');
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
setDisplayValue(formatCurrency(calculatedValue, selectedCurrency, decimalPlaces));
|
|
210
|
-
}
|
|
211
|
-
}, [
|
|
212
|
-
baseCurrencyValue,
|
|
213
|
-
calculatedValue,
|
|
214
|
-
selectedCurrency,
|
|
215
|
-
isInputFocused,
|
|
216
|
-
baseCurrency,
|
|
217
|
-
decimalPlaces
|
|
218
|
-
]);
|
|
230
|
+
var rate = exchangeRates[selectedCurrency] || 1;
|
|
231
|
+
var baseRate = exchangeRates[baseCurrency] || 1;
|
|
232
|
+
return (Number(baseCurrencyValue) / baseRate) * rate;
|
|
233
|
+
}, [baseCurrencyValue, selectedCurrency, baseCurrency, exchangeRates]);
|
|
219
234
|
/** 드롭다운 위치 업데이트 */
|
|
220
235
|
(0, react_1.useEffect)(function () {
|
|
221
236
|
if (!isDropdownFocused && contextMenuRef.current) {
|
|
@@ -245,36 +260,16 @@ function PriceTextField(_a) {
|
|
|
245
260
|
}
|
|
246
261
|
return formatCurrency(calculatedValue || 0, selectedCurrency, decimalPlaces);
|
|
247
262
|
}, [baseCurrencyValue, calculatedValue, selectedCurrency, decimalPlaces]);
|
|
248
|
-
/** returnType에 따른 폼 값 */
|
|
249
|
-
var formValue = (0, react_1.useMemo)(function () {
|
|
250
|
-
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
251
|
-
return '';
|
|
252
|
-
}
|
|
253
|
-
switch (returnType) {
|
|
254
|
-
case 'string':
|
|
255
|
-
return formattedValue;
|
|
256
|
-
case 'rawValue':
|
|
257
|
-
return baseCurrencyValue;
|
|
258
|
-
case 'object':
|
|
259
|
-
default:
|
|
260
|
-
return formattedValue;
|
|
261
|
-
}
|
|
262
|
-
}, [baseCurrencyValue, formattedValue, returnType]);
|
|
263
263
|
/** 폼 값 업데이트 */
|
|
264
264
|
(0, react_1.useEffect)(function () {
|
|
265
|
-
setValue(name,
|
|
266
|
-
}, [name, setValue,
|
|
265
|
+
setValue(name, baseCurrencyValue);
|
|
266
|
+
}, [name, setValue, baseCurrencyValue]);
|
|
267
267
|
/** onChange 콜백 처리 */
|
|
268
268
|
(0, react_1.useEffect)(function () {
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
if (!baseCurrencyValue || baseCurrencyValue === '') {
|
|
272
|
-
onChange('');
|
|
273
|
-
return;
|
|
269
|
+
if (onChange && baseCurrencyValue) {
|
|
270
|
+
onChange(baseCurrencyValue);
|
|
274
271
|
}
|
|
275
|
-
|
|
276
|
-
onChange(callbackValue);
|
|
277
|
-
}, [onChange, baseCurrencyValue, formattedValue, formValue, returnType]);
|
|
272
|
+
}, [onChange, baseCurrencyValue]);
|
|
278
273
|
/** onValueChange 콜백 처리 */
|
|
279
274
|
(0, react_1.useEffect)(function () {
|
|
280
275
|
if (!onValueChange)
|
|
@@ -289,18 +284,6 @@ function PriceTextField(_a) {
|
|
|
289
284
|
displayValue: formattedValue
|
|
290
285
|
});
|
|
291
286
|
}, [baseCurrencyValue, selectedCurrency, calculatedValue, formattedValue]);
|
|
292
|
-
/** 입력 시 천 단위 콤마 추가 함수 */
|
|
293
|
-
var addCommas = function (value) {
|
|
294
|
-
if (!value)
|
|
295
|
-
return '';
|
|
296
|
-
var parts = value.split('.');
|
|
297
|
-
var integerPart = parts[0];
|
|
298
|
-
var decimalPart = parts[1];
|
|
299
|
-
// 정수 부분에 콤마 추가
|
|
300
|
-
var formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
301
|
-
// 소수점이 있으면 합치기
|
|
302
|
-
return decimalPart !== undefined ? "".concat(formattedInteger, ".").concat(decimalPart) : formattedInteger;
|
|
303
|
-
};
|
|
304
287
|
var handleChange = function (e) {
|
|
305
288
|
var _a = e.target, value = _a.value, selectionStart = _a.selectionStart;
|
|
306
289
|
var prevValue = displayValue;
|
|
@@ -431,13 +414,13 @@ function PriceTextField(_a) {
|
|
|
431
414
|
};
|
|
432
415
|
var handleDelete = (0, react_1.useCallback)(function () {
|
|
433
416
|
setBaseCurrencyValue('');
|
|
434
|
-
setDisplayValue('');
|
|
435
417
|
setValue(name, '');
|
|
436
418
|
}, [name, setValue]);
|
|
437
419
|
return ((0, jsx_runtime_1.jsxs)(S_PriceTextField, __assign({ "x-pds-name": "PriceTextField", "x-pds-element-type": "component", "x-pds-device-type": "mobile", inputSize: size, responsiveMode: responsiveMode, customWidth: customWidth }, { children: [(0, jsx_runtime_1.jsxs)(S_ComponentBox, __assign({ inputSize: size, responsiveMode: responsiveMode, isFocused: isInputFocused, isError: Boolean(isError), state: state, customWidth: customWidth, isInputReadOnly: isInputReadOnly }, { children: [(0, jsx_runtime_1.jsx)(S_TextFieldBaseWrapper, __assign({ state: state, isError: Boolean(isError), isFocused: isInputFocused, inputSize: size, isInputReadOnly: isInputReadOnly }, { children: (0, jsx_runtime_1.jsx)(components_1.TextFieldBase, { name: name, hintText: hintText ||
|
|
438
420
|
t('str_channel_min_price', {
|
|
439
421
|
channelMinPrice: pricing_1.PricingService.format.price({
|
|
440
|
-
amount: minPriceAmount ||
|
|
422
|
+
amount: minPriceAmount ||
|
|
423
|
+
policy_1.DEFAULT_CURRENCY_PRICE_POLICIES[baseCurrency].minPayment.amount,
|
|
441
424
|
currency: baseCurrency
|
|
442
425
|
})
|
|
443
426
|
}), value: displayValue, textAlign: textAlign, validation: finalValidation, textLineType: "single", inputType: "text", inputMode: "decimal", preventBlankMode: "all", enterSubmitMode: "none", state: isInputReadOnly ? 'read_only' : state, colorTheme: colorTheme, textSize: "form2", textWeight: fontWeight === 'bold' ? 'bold' : 'normal', hintTextWeight: hintTextFontWeight === 'bold' ? 'bold' : 'normal', fieldPaddingRight: size === 'large' || size === 'rlarge' ? 12 : undefined, deleteIconMode: deleteBtnMode, deleteIconSize: size === 'large' || size === 'rlarge' ? 20 : 16, deleteIconColor: deleteIconColor, isFocused: isInputFocused, suffixTextRightSpacingMode: size === 'large' || size === 'rlarge' ? 'use' : 'none', onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, onTarget: handleTarget, onDelete: handleDelete }) })), (0, jsx_runtime_1.jsx)(S_DropdownWrapper, __assign({ ref: dropdownRef, inputSize: size, onClick: handleDropdownClick, onBlur: handleDropdownBlur, tabIndex: 0, isFocused: isDropdownFocused, state: dropdownState, isError: Boolean(isError) }, { children: (0, jsx_runtime_1.jsxs)(S_Select, __assign({ inputSize: size }, { children: [useDotBadge === 'use' && selectedCurrency === baseCurrency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(S_Badge, {}), (0, jsx_runtime_1.jsx)(hybrid_1.Spacing, { size: "spacing_a", spacingType: "width" })] })), (0, jsx_runtime_1.jsx)(TextLabel_1.TextLabel, { text: selectedCurrency, styleTheme: "form2Bold", singleLineMode: "use", colorTheme: "sysTextPrimary", ellipsisMode: "use", customFontWeight: "bold", colorOverride: getDropdownTextColorKey(), lineLimit: 1 }), (0, jsx_runtime_1.jsx)(hybrid_1.Spacing, { size: "spacing_a", spacingType: "width" }), (0, jsx_runtime_1.jsx)(hybrid_1.Icon, { size: 16, fillType: "line", iconName: isDropdownFocused ? 'ic_arrow_up' : 'ic_arrow_down', colorKey: getArrowIconColorKey() })] })) }))] })), isDropdownFocused &&
|
package/package.json
CHANGED
package/release-note.md
CHANGED