pds-dev-kit-web 2.2.193 → 2.2.194
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/index.d.ts +6 -6
- package/dist/index.js +6 -2
- package/dist/src/common/index.d.ts +1 -1
- package/dist/src/common/services/i18n/resources/en.json +8 -1
- package/dist/src/common/services/i18n/resources/es.json +8 -1
- package/dist/src/common/services/i18n/resources/fil.json +8 -1
- package/dist/src/common/services/i18n/resources/index.d.ts +49 -0
- package/dist/src/common/services/i18n/resources/ja.json +8 -1
- package/dist/src/common/services/i18n/resources/ko.json +8 -1
- package/dist/src/common/services/i18n/resources/zh-cn.json +8 -1
- package/dist/src/common/services/i18n/resources/zh-tw.json +8 -1
- package/dist/src/common/types/text.d.ts +2 -0
- package/dist/src/core/pricing/formatter.d.ts +4 -0
- package/dist/src/core/pricing/formatter.js +18 -0
- package/dist/src/core/pricing/index.d.ts +2 -0
- package/dist/src/core/pricing/index.js +18 -0
- package/dist/src/core/pricing/policy.d.ts +26 -0
- package/dist/src/core/pricing/policy.js +98 -0
- package/dist/src/core/pricing/service.d.ts +62 -0
- package/dist/src/core/pricing/service.js +157 -0
- package/dist/src/core/pricing/translator.d.ts +26 -0
- package/dist/src/core/pricing/translator.js +50 -0
- package/dist/src/core/pricing/types.d.ts +18 -0
- package/dist/src/core/pricing/types.js +34 -0
- package/dist/src/core/pricing/validator.d.ts +29 -0
- package/dist/src/core/pricing/validator.js +105 -0
- package/dist/src/desktop/common/components/TextFieldBase/TextFieldBase.d.ts +3 -1
- package/dist/src/desktop/common/components/TextFieldBase/TextFieldBase.js +16 -11
- package/dist/src/desktop/components/PriceTextField/PriceTextField.d.ts +41 -0
- package/dist/src/desktop/components/PriceTextField/PriceTextField.js +580 -0
- package/dist/src/desktop/components/PriceTextField/index.d.ts +1 -0
- package/dist/src/desktop/components/PriceTextField/index.js +8 -0
- package/dist/src/desktop/components/PriceTextLabel/PriceTextLabel.d.ts +14 -0
- package/dist/src/desktop/components/PriceTextLabel/PriceTextLabel.js +44 -0
- package/dist/src/desktop/components/PriceTextLabel/index.d.ts +1 -0
- package/dist/src/desktop/components/PriceTextLabel/index.js +8 -0
- package/dist/src/desktop/components/TextField/TextField.d.ts +2 -1
- package/dist/src/desktop/components/TextField/TextField.js +7 -7
- package/dist/src/desktop/components/TextLabel/TextLabel.d.ts +3 -3
- package/dist/src/desktop/components/index.d.ts +3 -1
- package/dist/src/desktop/components/index.js +6 -2
- package/dist/src/desktop/index.d.ts +1 -1
- package/dist/src/desktop/index.js +3 -1
- package/dist/src/mobile/common/components/TextFieldBase/TextFieldBase.d.ts +2 -1
- package/dist/src/mobile/common/components/TextFieldBase/TextFieldBase.js +10 -10
- package/dist/src/mobile/components/PriceTextField/PriceTextField.d.ts +41 -0
- package/dist/src/mobile/components/PriceTextField/PriceTextField.js +570 -0
- package/dist/src/mobile/components/PriceTextField/index.d.ts +1 -0
- package/dist/src/mobile/components/PriceTextField/index.js +8 -0
- package/dist/src/mobile/components/PriceTextLabel/PriceTextLabel.d.ts +14 -0
- package/dist/src/mobile/components/PriceTextLabel/PriceTextLabel.js +44 -0
- package/dist/src/mobile/components/PriceTextLabel/index.d.ts +1 -0
- package/dist/src/mobile/components/PriceTextLabel/index.js +8 -0
- package/dist/src/mobile/components/TextField/TextField.d.ts +2 -1
- package/dist/src/mobile/components/TextField/TextField.js +7 -7
- package/dist/src/mobile/components/TextLabel/TextLabel.d.ts +3 -3
- package/dist/src/mobile/components/index.d.ts +3 -1
- package/dist/src/mobile/components/index.js +5 -1
- package/dist/src/mobile/index.d.ts +1 -1
- package/dist/src/mobile/index.js +4 -2
- package/package.json +1 -1
- package/release-note.md +3 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PricingService = void 0;
|
|
7
|
+
var i18next_1 = __importDefault(require("i18next"));
|
|
8
|
+
var formatter_1 = require("./formatter");
|
|
9
|
+
var policy_1 = require("./policy");
|
|
10
|
+
var translator_1 = require("./translator");
|
|
11
|
+
var types_1 = require("./types");
|
|
12
|
+
var validator_1 = require("./validator");
|
|
13
|
+
/**
|
|
14
|
+
* PricingService는 상품의 판매가, 할인, 통화 포맷 등 가격 관련 비즈니스 로직을 처리하는 도메인 서비스입니다
|
|
15
|
+
*/
|
|
16
|
+
var PricingService = /** @class */ (function () {
|
|
17
|
+
function PricingService() {
|
|
18
|
+
this.browserLanguage = null;
|
|
19
|
+
}
|
|
20
|
+
PricingService.getInstance = function () {
|
|
21
|
+
if (!PricingService.instance) {
|
|
22
|
+
PricingService.instance = new PricingService();
|
|
23
|
+
}
|
|
24
|
+
return PricingService.instance;
|
|
25
|
+
};
|
|
26
|
+
PricingService.init = function (browserLanguage) {
|
|
27
|
+
var instance = PricingService.getInstance();
|
|
28
|
+
instance.setBrowserLanguage(browserLanguage);
|
|
29
|
+
};
|
|
30
|
+
PricingService.prototype.setBrowserLanguage = function (locale) {
|
|
31
|
+
this.browserLanguage = locale;
|
|
32
|
+
translator_1.PricingTranslator.setBrowserLanguage(locale);
|
|
33
|
+
};
|
|
34
|
+
//-----------------------------------------------------------------------------
|
|
35
|
+
// 유틸리티
|
|
36
|
+
//-----------------------------------------------------------------------------
|
|
37
|
+
PricingService.getCurrency = function (currency) {
|
|
38
|
+
return types_1.CURRENCY_MAP[currency];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* publ이 지원하는 통화인지 반환합니다
|
|
42
|
+
*/
|
|
43
|
+
PricingService.isSupportedCurrency = function (currency) {
|
|
44
|
+
return policy_1.SUPPORTED_CURRENCIES.includes(currency);
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 채널의 통화 가격 정책을 반환합니다
|
|
48
|
+
*/
|
|
49
|
+
PricingService.getCurrencyPricePolicy = function (channelCode, currency) {
|
|
50
|
+
var _a;
|
|
51
|
+
return ((_a = policy_1.CHANNEL_CURRENCY_PRICE_POLICIES[channelCode]) !== null && _a !== void 0 ? _a : policy_1.DEFAULT_CURRENCY_PRICE_POLICIES[currency]);
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 유저의 선호 통화 기본값을 반환합니다
|
|
55
|
+
*/
|
|
56
|
+
PricingService.getDefaultPreferredCurrency = function (userCountryCode) {
|
|
57
|
+
// #1 사용자 국가 코드
|
|
58
|
+
if (userCountryCode) {
|
|
59
|
+
var currency = policy_1.CURRENCY_BY_LOCALE_MAP[userCountryCode];
|
|
60
|
+
if (currency) {
|
|
61
|
+
return currency;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// #2 채널 기준 통화
|
|
65
|
+
// const { channel } = PricingService.getInstance();
|
|
66
|
+
// if (!channel) {
|
|
67
|
+
// throw new Error('PricingService::getDefaultPreferredCurrency error: INVALID_CHANNEL');
|
|
68
|
+
// }
|
|
69
|
+
//
|
|
70
|
+
// return channel.baseCurrency as CurrencyCode;
|
|
71
|
+
return types_1.CurrencyCode.USD;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* 환율 변환 유틸리티
|
|
75
|
+
*
|
|
76
|
+
* @param amount 금액 (from 통화 기준)
|
|
77
|
+
* @param from 원래 통화
|
|
78
|
+
* @param to 변환할 대상 통화
|
|
79
|
+
* @param exchangeRates 기준 통화 대비 환율 테이블 (예: { USD: 1, KRW: 1300, EUR: 0.9 })
|
|
80
|
+
* @returns 환산된 금액 (소수점 반올림 포함)
|
|
81
|
+
*/
|
|
82
|
+
PricingService.exchangePrice = function (amount, from, to, exchangeRates) {
|
|
83
|
+
var _a;
|
|
84
|
+
var fromRate = exchangeRates[from];
|
|
85
|
+
var toRate = exchangeRates[to];
|
|
86
|
+
if (!fromRate || !toRate) {
|
|
87
|
+
throw new Error("PricingService::exchangePrice error: Missing rate for currency: ".concat(!fromRate ? from : to));
|
|
88
|
+
}
|
|
89
|
+
var baseAmount = amount / fromRate; // 기준 통화로 환산
|
|
90
|
+
var targetAmount = baseAmount * toRate;
|
|
91
|
+
var decimalDigits = (_a = types_1.CURRENCY_MAP[to].decimalDigits) !== null && _a !== void 0 ? _a : 0;
|
|
92
|
+
return Number(targetAmount.toFixed(decimalDigits));
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 기준 통화 상품 가격을 선호 통화 가격으로 변환합니다
|
|
96
|
+
* @param price 기준 통화의 상품 가격
|
|
97
|
+
* @param preferredCurrency 선호 통화
|
|
98
|
+
* @param exchangeRates 기준 통화 대비 환율 테이블
|
|
99
|
+
*/
|
|
100
|
+
PricingService.convertToPreferredPrice = function (price, preferredCurrency, exchangeRates) {
|
|
101
|
+
return {
|
|
102
|
+
amount: PricingService.exchangePrice(Number(price.amount), price.currency, preferredCurrency, exchangeRates),
|
|
103
|
+
currency: preferredCurrency
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 채널 가격 정책 기반의 PriceTextField Props를 반환합니다
|
|
108
|
+
*/
|
|
109
|
+
PricingService.getPriceTextFieldProps = function (channelCode, options) {
|
|
110
|
+
var _a, _b, _c, _d;
|
|
111
|
+
var policy = PricingService.getCurrencyPricePolicy(channelCode, options.currency);
|
|
112
|
+
var useRequiredValidation = (_b = (_a = options.validation) === null || _a === void 0 ? void 0 : _a.useRequiredValidation) !== null && _b !== void 0 ? _b : 'use';
|
|
113
|
+
var customMinAmount = (_c = options.validation) === null || _c === void 0 ? void 0 : _c.customMinAmount;
|
|
114
|
+
var customMaxAmount = (_d = options.validation) === null || _d === void 0 ? void 0 : _d.customMaxAmount;
|
|
115
|
+
var validation = {};
|
|
116
|
+
// Required validation
|
|
117
|
+
if (useRequiredValidation === 'use') {
|
|
118
|
+
validation.required = i18next_1.default.t('str_please_enter_price');
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
validation.required = false;
|
|
122
|
+
}
|
|
123
|
+
validation.validate = {
|
|
124
|
+
min: function (value) {
|
|
125
|
+
var _a, _b;
|
|
126
|
+
var minAmount = customMinAmount !== null && customMinAmount !== void 0 ? customMinAmount : (options.isPromotionPrice
|
|
127
|
+
? Math.min(Number(policy.minPayment.amount), Number((_b = (_a = policy.minPromotionPayment) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : policy.minPayment.amount))
|
|
128
|
+
: Number(policy.minPayment.amount));
|
|
129
|
+
return PricingService.validate.min(value, {
|
|
130
|
+
minAmount: minAmount,
|
|
131
|
+
currency: options.currency
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
max: function (value) {
|
|
135
|
+
var maxAmount = customMaxAmount !== null && customMaxAmount !== void 0 ? customMaxAmount : Number(policy.maxPayment.amount);
|
|
136
|
+
return PricingService.validate.max(value, {
|
|
137
|
+
maxAmount: maxAmount,
|
|
138
|
+
currency: options.currency
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
format: function (value) {
|
|
142
|
+
return PricingService.validate.format(value, {
|
|
143
|
+
paymentUnit: policy.paymentUnit,
|
|
144
|
+
currency: options.currency
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return {
|
|
149
|
+
validation: validation
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
PricingService.format = formatter_1.PricingFormatter;
|
|
153
|
+
PricingService.translate = translator_1.PricingTranslator;
|
|
154
|
+
PricingService.validate = validator_1.PricingValidator;
|
|
155
|
+
return PricingService;
|
|
156
|
+
}());
|
|
157
|
+
exports.PricingService = PricingService;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CurrencyCodeType, Price } from './types';
|
|
2
|
+
export interface PricingTranslateOptions {
|
|
3
|
+
friendly?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class PricingTranslator {
|
|
6
|
+
private static browserLanguage;
|
|
7
|
+
static setBrowserLanguage(browserLanguage: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 통화 표시가 금액 앞에 오는지 브라우저 언어 기준으로 판단합니다.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* isCurrencyLeading('en-US') // true → "USD 10"
|
|
13
|
+
* isCurrencyLeading('ko-KR') // false → "10 KRW"
|
|
14
|
+
*/
|
|
15
|
+
static isCurrencyLeading(browserLanguage: string | null): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 통화 문자열을 반환합니다
|
|
18
|
+
* @example "KRW" 또는 "원"
|
|
19
|
+
*/
|
|
20
|
+
static currency(code: CurrencyCodeType, opts?: PricingTranslateOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* 포맷된 금액과 통화 문자열을 결합합니다
|
|
23
|
+
* @example "10,000 KRW" 또는 "10,000원"
|
|
24
|
+
*/
|
|
25
|
+
static priceWithCurrency(price: Price, opts?: PricingTranslateOptions): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PricingTranslator = void 0;
|
|
4
|
+
var formatter_1 = require("./formatter");
|
|
5
|
+
var types_1 = require("./types");
|
|
6
|
+
var PricingTranslator = /** @class */ (function () {
|
|
7
|
+
function PricingTranslator() {
|
|
8
|
+
}
|
|
9
|
+
PricingTranslator.setBrowserLanguage = function (browserLanguage) {
|
|
10
|
+
PricingTranslator.browserLanguage = browserLanguage;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 통화 표시가 금액 앞에 오는지 브라우저 언어 기준으로 판단합니다.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* isCurrencyLeading('en-US') // true → "USD 10"
|
|
17
|
+
* isCurrencyLeading('ko-KR') // false → "10 KRW"
|
|
18
|
+
*/
|
|
19
|
+
PricingTranslator.isCurrencyLeading = function (browserLanguage) {
|
|
20
|
+
if (!browserLanguage) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return !['ko', 'ko-kr'].includes(browserLanguage.toLowerCase());
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* 통화 문자열을 반환합니다
|
|
27
|
+
* @example "KRW" 또는 "원"
|
|
28
|
+
*/
|
|
29
|
+
PricingTranslator.currency = function (code, opts) {
|
|
30
|
+
var currency = types_1.CURRENCY_MAP[code];
|
|
31
|
+
return (opts === null || opts === void 0 ? void 0 : opts.friendly) ? currency.friendlyName() : currency.name;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 포맷된 금액과 통화 문자열을 결합합니다
|
|
35
|
+
* @example "10,000 KRW" 또는 "10,000원"
|
|
36
|
+
*/
|
|
37
|
+
PricingTranslator.priceWithCurrency = function (price, opts) {
|
|
38
|
+
var formattedAmount = formatter_1.PricingFormatter.price(price);
|
|
39
|
+
var currencyString = PricingTranslator.currency(price.currency, opts);
|
|
40
|
+
if (PricingTranslator.isCurrencyLeading(PricingTranslator.browserLanguage)) {
|
|
41
|
+
return "".concat(currencyString, " ").concat(formattedAmount);
|
|
42
|
+
}
|
|
43
|
+
return (opts === null || opts === void 0 ? void 0 : opts.friendly)
|
|
44
|
+
? "".concat(formattedAmount).concat(currencyString)
|
|
45
|
+
: "".concat(formattedAmount, " ").concat(currencyString);
|
|
46
|
+
};
|
|
47
|
+
PricingTranslator.browserLanguage = null;
|
|
48
|
+
return PricingTranslator;
|
|
49
|
+
}());
|
|
50
|
+
exports.PricingTranslator = PricingTranslator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare enum CurrencyCode {
|
|
2
|
+
KRW = "KRW",
|
|
3
|
+
USD = "USD",
|
|
4
|
+
JPY = "JPY"
|
|
5
|
+
}
|
|
6
|
+
export type CurrencyCodeType = CurrencyCode | string;
|
|
7
|
+
export interface Currency {
|
|
8
|
+
code: CurrencyCode;
|
|
9
|
+
name: string;
|
|
10
|
+
friendlyName: () => string;
|
|
11
|
+
decimalDigits: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const CURRENCY_MAP: Record<CurrencyCode, Currency>;
|
|
14
|
+
export interface Price {
|
|
15
|
+
amount: number | string;
|
|
16
|
+
currency: CurrencyCodeType;
|
|
17
|
+
}
|
|
18
|
+
export type ExchangeRateMap = Partial<Record<CurrencyCode, number>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CURRENCY_MAP = exports.CurrencyCode = void 0;
|
|
8
|
+
var i18next_1 = __importDefault(require("i18next"));
|
|
9
|
+
var CurrencyCode;
|
|
10
|
+
(function (CurrencyCode) {
|
|
11
|
+
CurrencyCode["KRW"] = "KRW";
|
|
12
|
+
CurrencyCode["USD"] = "USD";
|
|
13
|
+
CurrencyCode["JPY"] = "JPY";
|
|
14
|
+
})(CurrencyCode = exports.CurrencyCode || (exports.CurrencyCode = {}));
|
|
15
|
+
exports.CURRENCY_MAP = (_a = {},
|
|
16
|
+
_a[CurrencyCode.KRW] = {
|
|
17
|
+
code: CurrencyCode.KRW,
|
|
18
|
+
name: CurrencyCode.KRW,
|
|
19
|
+
friendlyName: function () { return i18next_1.default.t('str_friendly_currency_won'); },
|
|
20
|
+
decimalDigits: 0
|
|
21
|
+
},
|
|
22
|
+
_a[CurrencyCode.USD] = {
|
|
23
|
+
code: CurrencyCode.USD,
|
|
24
|
+
name: CurrencyCode.USD,
|
|
25
|
+
friendlyName: function () { return i18next_1.default.t('str_friendly_currency_dollar'); },
|
|
26
|
+
decimalDigits: 2
|
|
27
|
+
},
|
|
28
|
+
_a[CurrencyCode.JPY] = {
|
|
29
|
+
code: CurrencyCode.JPY,
|
|
30
|
+
name: CurrencyCode.JPY,
|
|
31
|
+
friendlyName: function () { return i18next_1.default.t('str_friendly_currency_jpy'); },
|
|
32
|
+
decimalDigits: 0
|
|
33
|
+
},
|
|
34
|
+
_a);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PricingTranslateOptions } from './translator';
|
|
2
|
+
import type { CurrencyCode } from './types';
|
|
3
|
+
export declare class PricingValidator {
|
|
4
|
+
/**
|
|
5
|
+
* 최소 결제 금액 검증
|
|
6
|
+
* @returns i18n 오류 메시지 | undefined
|
|
7
|
+
*/
|
|
8
|
+
static min(value: string, options: {
|
|
9
|
+
minAmount: number;
|
|
10
|
+
currency: CurrencyCode;
|
|
11
|
+
}): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* 최대 결제 금액 검증
|
|
14
|
+
* @returns i18n 오류 메시지 | undefined
|
|
15
|
+
*/
|
|
16
|
+
static max(value: string, options: {
|
|
17
|
+
maxAmount: number;
|
|
18
|
+
currency: CurrencyCode;
|
|
19
|
+
}): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* 가격 형식 검증: 소수 자릿수 또는 결제 단위
|
|
22
|
+
* @returns i18n 오류 메시지 | undefined
|
|
23
|
+
*/
|
|
24
|
+
static format(value: string, options: {
|
|
25
|
+
paymentUnit: number;
|
|
26
|
+
currency: CurrencyCode;
|
|
27
|
+
currencyTranslateOptions?: PricingTranslateOptions;
|
|
28
|
+
}): string | undefined;
|
|
29
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PricingValidator = void 0;
|
|
7
|
+
var i18next_1 = __importDefault(require("i18next"));
|
|
8
|
+
var formatter_1 = require("./formatter");
|
|
9
|
+
var translator_1 = require("./translator");
|
|
10
|
+
var types_1 = require("./types");
|
|
11
|
+
var PricingValidator = /** @class */ (function () {
|
|
12
|
+
function PricingValidator() {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 최소 결제 금액 검증
|
|
16
|
+
* @returns i18n 오류 메시지 | undefined
|
|
17
|
+
*/
|
|
18
|
+
PricingValidator.min = function (value, options) {
|
|
19
|
+
if (!value)
|
|
20
|
+
return undefined;
|
|
21
|
+
var amount = Number(value.replace(/,/g, ''));
|
|
22
|
+
if (isNaN(amount)) {
|
|
23
|
+
return i18next_1.default.t('str_please_enter_price');
|
|
24
|
+
}
|
|
25
|
+
if (amount < options.minAmount) {
|
|
26
|
+
return i18next_1.default.t('str_min_price', {
|
|
27
|
+
minPrice: formatter_1.PricingFormatter.price({
|
|
28
|
+
amount: options.minAmount,
|
|
29
|
+
currency: options.currency
|
|
30
|
+
}),
|
|
31
|
+
currency: translator_1.PricingTranslator.currency(options.currency)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 최대 결제 금액 검증
|
|
38
|
+
* @returns i18n 오류 메시지 | undefined
|
|
39
|
+
*/
|
|
40
|
+
PricingValidator.max = function (value, options) {
|
|
41
|
+
if (!value)
|
|
42
|
+
return undefined;
|
|
43
|
+
var amount = Number(value.replace(/,/g, ''));
|
|
44
|
+
if (isNaN(amount)) {
|
|
45
|
+
return i18next_1.default.t('str_please_enter_price');
|
|
46
|
+
}
|
|
47
|
+
if (amount > options.maxAmount) {
|
|
48
|
+
return i18next_1.default.t('str_max_price', {
|
|
49
|
+
maxPrice: formatter_1.PricingFormatter.price({
|
|
50
|
+
amount: options.maxAmount,
|
|
51
|
+
currency: options.currency
|
|
52
|
+
}),
|
|
53
|
+
currency: translator_1.PricingTranslator.currency(options.currency)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 가격 형식 검증: 소수 자릿수 또는 결제 단위
|
|
60
|
+
* @returns i18n 오류 메시지 | undefined
|
|
61
|
+
*/
|
|
62
|
+
PricingValidator.format = function (value, options) {
|
|
63
|
+
if (!value)
|
|
64
|
+
return undefined;
|
|
65
|
+
var amount = Number(value.replace(/,/g, ''));
|
|
66
|
+
if (isNaN(amount)) {
|
|
67
|
+
return i18next_1.default.t('str_please_enter_price');
|
|
68
|
+
}
|
|
69
|
+
var decimalDigits = types_1.CURRENCY_MAP[options.currency].decimalDigits;
|
|
70
|
+
// #1 소수점 자리수 검증
|
|
71
|
+
var _a = value.split('.'), fraction = _a[1];
|
|
72
|
+
if (fraction && fraction.length > decimalDigits) {
|
|
73
|
+
return i18next_1.default.t('str_price_unit', {
|
|
74
|
+
priceUnit: formatter_1.PricingFormatter.price({
|
|
75
|
+
amount: options.paymentUnit,
|
|
76
|
+
currency: options.currency
|
|
77
|
+
}),
|
|
78
|
+
currency: types_1.CURRENCY_MAP[options.currency].name
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// #2 단위 검증
|
|
82
|
+
function isDivisible(amount, unit) {
|
|
83
|
+
var precision = Math.pow(10, Math.max(getDecimalPlaces(amount), getDecimalPlaces(unit)));
|
|
84
|
+
var intAmount = Math.round(amount * precision);
|
|
85
|
+
var intUnit = Math.round(unit * precision);
|
|
86
|
+
return intAmount % intUnit === 0;
|
|
87
|
+
}
|
|
88
|
+
function getDecimalPlaces(value) {
|
|
89
|
+
var decimalStr = value.toString().split('.')[1];
|
|
90
|
+
return decimalStr ? decimalStr.length : 0;
|
|
91
|
+
}
|
|
92
|
+
if (!isDivisible(amount, options.paymentUnit)) {
|
|
93
|
+
return i18next_1.default.t('str_price_unit', {
|
|
94
|
+
priceUnit: formatter_1.PricingFormatter.price({
|
|
95
|
+
amount: options.paymentUnit,
|
|
96
|
+
currency: options.currency
|
|
97
|
+
}),
|
|
98
|
+
currency: types_1.CURRENCY_MAP[options.currency].name
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
};
|
|
103
|
+
return PricingValidator;
|
|
104
|
+
}());
|
|
105
|
+
exports.PricingValidator = PricingValidator;
|
|
@@ -25,6 +25,7 @@ export type TextFieldBaseProps = {
|
|
|
25
25
|
textSize: DesktopFontSize;
|
|
26
26
|
customFontSize?: string;
|
|
27
27
|
textWeight: FontWeight;
|
|
28
|
+
hintTextWeight?: FontWeight;
|
|
28
29
|
fieldPaddingRight?: number;
|
|
29
30
|
fieldPaddingLeft?: number;
|
|
30
31
|
fieldHeight?: number;
|
|
@@ -45,8 +46,9 @@ export type TextFieldBaseProps = {
|
|
|
45
46
|
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
46
47
|
onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
47
48
|
onTarget?: () => void;
|
|
49
|
+
onDelete?: () => void;
|
|
48
50
|
inputRef?: any;
|
|
49
51
|
[x: string]: any;
|
|
50
52
|
} & Record<string, any>;
|
|
51
|
-
declare function TextFieldBase({ name, hintText, defaultText, textAlign, validation, preventBlankMode, enterSubmitMode, textLineType, multiRows, autoMinRows, autoMaxRows, inputType, inputMode, state, colorTheme, min, max, maxLength, textSize, customFontSize, textWeight, fieldPaddingRight, fieldPaddingLeft, fieldHeight, deleteIconMode, deleteIconSize, deleteIconColor, suffixText, suffixTextRightSpacingMode, isFocused, autoComplete, stepperMode, stepperRightSpacing, innerSpinButtonSize, step, onBlur, onChange, onFocus, onKeyDown, onKeyUp, onTarget, inputRef, ...rest }: TextFieldBaseProps): JSX.Element;
|
|
53
|
+
declare function TextFieldBase({ name, hintText, defaultText, textAlign, validation, preventBlankMode, enterSubmitMode, textLineType, multiRows, autoMinRows, autoMaxRows, inputType, inputMode, state, colorTheme, min, max, maxLength, textSize, customFontSize, textWeight, hintTextWeight, fieldPaddingRight, fieldPaddingLeft, fieldHeight, deleteIconMode, deleteIconSize, deleteIconColor, suffixText, suffixTextRightSpacingMode, isFocused, autoComplete, stepperMode, stepperRightSpacing, innerSpinButtonSize, step, onBlur, onChange, onFocus, onKeyDown, onKeyUp, onTarget, onDelete, inputRef, ...rest }: TextFieldBaseProps): JSX.Element;
|
|
52
54
|
export default TextFieldBase;
|
|
@@ -61,11 +61,11 @@ var common_1 = require("../../../../common");
|
|
|
61
61
|
var IconButton_1 = require("../../../components/IconButton");
|
|
62
62
|
var constants_1 = require("./constants");
|
|
63
63
|
function TextFieldBase(_a) {
|
|
64
|
-
var name = _a.name, hintText = _a.hintText, defaultText = _a.defaultText, _b = _a.textAlign, textAlign = _b === void 0 ? 'left' : _b, validation = _a.validation, _c = _a.preventBlankMode, preventBlankMode = _c === void 0 ? 'none' : _c, _d = _a.enterSubmitMode, enterSubmitMode = _d === void 0 ? 'none' : _d, _e = _a.textLineType, textLineType = _e === void 0 ? 'single' : _e, multiRows = _a.multiRows, autoMinRows = _a.autoMinRows, autoMaxRows = _a.autoMaxRows, _f = _a.inputType, inputType = _f === void 0 ? 'text' : _f, inputMode = _a.inputMode, _g = _a.state, state = _g === void 0 ? 'normal' : _g, _h = _a.colorTheme, colorTheme = _h === void 0 ? 'none' : _h, min = _a.min, max = _a.max, _j = _a.maxLength, maxLength = _j === void 0 ? Infinity : _j, _k = _a.textSize, textSize = _k === void 0 ? 'form2' : _k, customFontSize = _a.customFontSize, _l = _a.textWeight, textWeight = _l === void 0 ? 'normal' : _l, fieldPaddingRight = _a.fieldPaddingRight, fieldPaddingLeft = _a.fieldPaddingLeft,
|
|
65
|
-
var
|
|
64
|
+
var name = _a.name, hintText = _a.hintText, defaultText = _a.defaultText, _b = _a.textAlign, textAlign = _b === void 0 ? 'left' : _b, validation = _a.validation, _c = _a.preventBlankMode, preventBlankMode = _c === void 0 ? 'none' : _c, _d = _a.enterSubmitMode, enterSubmitMode = _d === void 0 ? 'none' : _d, _e = _a.textLineType, textLineType = _e === void 0 ? 'single' : _e, multiRows = _a.multiRows, autoMinRows = _a.autoMinRows, autoMaxRows = _a.autoMaxRows, _f = _a.inputType, inputType = _f === void 0 ? 'text' : _f, inputMode = _a.inputMode, _g = _a.state, state = _g === void 0 ? 'normal' : _g, _h = _a.colorTheme, colorTheme = _h === void 0 ? 'none' : _h, min = _a.min, max = _a.max, _j = _a.maxLength, maxLength = _j === void 0 ? Infinity : _j, _k = _a.textSize, textSize = _k === void 0 ? 'form2' : _k, customFontSize = _a.customFontSize, _l = _a.textWeight, textWeight = _l === void 0 ? 'normal' : _l, _m = _a.hintTextWeight, hintTextWeight = _m === void 0 ? 'normal' : _m, fieldPaddingRight = _a.fieldPaddingRight, fieldPaddingLeft = _a.fieldPaddingLeft, _o = _a.fieldHeight, fieldHeight = _o === void 0 ? 48 : _o, _p = _a.deleteIconMode, deleteIconMode = _p === void 0 ? 'use' : _p, _q = _a.deleteIconSize, deleteIconSize = _q === void 0 ? 20 : _q, _r = _a.deleteIconColor, deleteIconColor = _r === void 0 ? 'ui_cpnt_button_icon_disabled' : _r, suffixText = _a.suffixText, _s = _a.suffixTextRightSpacingMode, suffixTextRightSpacingMode = _s === void 0 ? 'none' : _s, isFocused = _a.isFocused, _t = _a.autoComplete, autoComplete = _t === void 0 ? 'on' : _t, _u = _a.stepperMode, stepperMode = _u === void 0 ? 'none' : _u, _v = _a.stepperRightSpacing, stepperRightSpacing = _v === void 0 ? 1 : _v, _w = _a.innerSpinButtonSize, innerSpinButtonSize = _w === void 0 ? 16 : _w, step = _a.step, onBlur = _a.onBlur, onChange = _a.onChange, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onKeyUp = _a.onKeyUp, onTarget = _a.onTarget, onDelete = _a.onDelete, inputRef = _a.inputRef, rest = __rest(_a, ["name", "hintText", "defaultText", "textAlign", "validation", "preventBlankMode", "enterSubmitMode", "textLineType", "multiRows", "autoMinRows", "autoMaxRows", "inputType", "inputMode", "state", "colorTheme", "min", "max", "maxLength", "textSize", "customFontSize", "textWeight", "hintTextWeight", "fieldPaddingRight", "fieldPaddingLeft", "fieldHeight", "deleteIconMode", "deleteIconSize", "deleteIconColor", "suffixText", "suffixTextRightSpacingMode", "isFocused", "autoComplete", "stepperMode", "stepperRightSpacing", "innerSpinButtonSize", "step", "onBlur", "onChange", "onFocus", "onKeyDown", "onKeyUp", "onTarget", "onDelete", "inputRef"]);
|
|
65
|
+
var _x = (0, react_hook_form_1.useFormContext)(), register = _x.register, setValue = _x.setValue, getValues = _x.getValues, clearErrors = _x.clearErrors;
|
|
66
66
|
var timeout;
|
|
67
67
|
var suffixTextRef = (0, react_1.useRef)(null);
|
|
68
|
-
var
|
|
68
|
+
var _y = (0, react_1.useState)(0), suffixTextWidth = _y[0], setSuffixTextWidth = _y[1];
|
|
69
69
|
// NOTE suffixText가 변할때마다 suffixText가 차지하는 너비를 알아내어 suffixTextWidth에 담는다.
|
|
70
70
|
(0, react_1.useEffect)(function () {
|
|
71
71
|
var calculateDivWidth = function () {
|
|
@@ -165,7 +165,7 @@ function TextFieldBase(_a) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
var textAreaRef = (0, react_1.useRef)(null);
|
|
168
|
-
var
|
|
168
|
+
var _z = register(name, validation), ref = _z.ref, refRest = __rest(_z, ["ref"]);
|
|
169
169
|
(0, react_1.useEffect)(function () {
|
|
170
170
|
if (textAreaRef === null || textAreaRef.current === null) {
|
|
171
171
|
return;
|
|
@@ -205,7 +205,12 @@ function TextFieldBase(_a) {
|
|
|
205
205
|
textAreaRef.current.style.height = "".concat(textAreaRef.current.scrollHeight, "px");
|
|
206
206
|
}, []);
|
|
207
207
|
function deleteValue() {
|
|
208
|
-
|
|
208
|
+
if (onDelete) {
|
|
209
|
+
onDelete();
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
setValue(name, '', { shouldDirty: true });
|
|
213
|
+
}
|
|
209
214
|
}
|
|
210
215
|
// NOTE: input의 type이 number일때, e나 E의 경우 숫자로 취급되어 입력이 가능하지만, publ의 기획상 막아야하기 때문에 생성한 함수
|
|
211
216
|
var preventEKeyword = function (e) {
|
|
@@ -226,7 +231,7 @@ function TextFieldBase(_a) {
|
|
|
226
231
|
}
|
|
227
232
|
var S_TextFieldBase = function () {
|
|
228
233
|
if (textLineType === 'single') {
|
|
229
|
-
return ((0, jsx_runtime_1.jsxs)(S_InputWrapper, { children: [stepperMode === 'use' && ((0, jsx_runtime_1.jsxs)(S_IconBox, __assign({ innerSpinButtonSize: innerSpinButtonSize, isFocused: isFocused, stepperRightSpacing: stepperRightSpacing }, { children: [(0, jsx_runtime_1.jsx)(components_2.Icon, { iconName: "ic_arrow_up_stepper", fillType: "fill", size: innerSpinButtonSize }), (0, jsx_runtime_1.jsx)(components_2.Icon, { iconName: "ic_arrow_down_stepper", fillType: "fill", size: innerSpinButtonSize })] }))), (0, jsx_runtime_1.jsx)(S_Input, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, type: inputType, inputMode: inputMode, state: state, readOnly: state === 'read_only', disabled: state === 'disabled', maxLength: maxLength, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, colorTheme: colorTheme, min: min, max: max, autoComplete: autoComplete, stepperMode: stepperMode, innerSpinButtonSize: innerSpinButtonSize, step: step, deleteIconMode: deleteIconMode, suffixText: suffixText, suffixTextWidth: suffixTextWidth, stepperRightSpacing: stepperRightSpacing, isFocused: isFocused, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
234
|
+
return ((0, jsx_runtime_1.jsxs)(S_InputWrapper, { children: [stepperMode === 'use' && ((0, jsx_runtime_1.jsxs)(S_IconBox, __assign({ innerSpinButtonSize: innerSpinButtonSize, isFocused: isFocused, stepperRightSpacing: stepperRightSpacing }, { children: [(0, jsx_runtime_1.jsx)(components_2.Icon, { iconName: "ic_arrow_up_stepper", fillType: "fill", size: innerSpinButtonSize }), (0, jsx_runtime_1.jsx)(components_2.Icon, { iconName: "ic_arrow_down_stepper", fillType: "fill", size: innerSpinButtonSize })] }))), (0, jsx_runtime_1.jsx)(S_Input, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, type: inputType, inputMode: inputMode, state: state, readOnly: state === 'read_only', disabled: state === 'disabled', maxLength: maxLength, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, hintTextWeight: hintTextWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, colorTheme: colorTheme, min: min, max: max, autoComplete: autoComplete, stepperMode: stepperMode, innerSpinButtonSize: innerSpinButtonSize, step: step, deleteIconMode: deleteIconMode, suffixText: suffixText, suffixTextWidth: suffixTextWidth, stepperRightSpacing: stepperRightSpacing, isFocused: isFocused, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
230
235
|
ref(e);
|
|
231
236
|
if (inputRef) {
|
|
232
237
|
inputRef.current = e;
|
|
@@ -234,7 +239,7 @@ function TextFieldBase(_a) {
|
|
|
234
239
|
} })), (deleteIconMode === 'use' || suffixText) && ((0, jsx_runtime_1.jsxs)(S_RightBox, __assign({ deleteIconMode: deleteIconMode, stepperMode: stepperMode, suffixText: suffixText, innerSpinButtonSize: innerSpinButtonSize }, { children: [deleteIconMode === 'use' && ((0, jsx_runtime_1.jsx)(S_IconButtonWrapper, __assign({ innerSpinButtonSize: innerSpinButtonSize, deleteIconMode: deleteIconMode, stepperMode: stepperMode, suffixText: suffixText, isFocused: isFocused, suffixTextWidth: suffixTextWidth, stepperRightSpacing: stepperRightSpacing }, { children: isFocused && ((0, jsx_runtime_1.jsx)(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 })) }))), suffixText && ((0, jsx_runtime_1.jsxs)(S_SuffixTextBox, __assign({ ref: suffixTextRef }, { children: [(0, jsx_runtime_1.jsx)(components_2.Spacing, { size: "spacing_b", spacingType: "width" }), (0, jsx_runtime_1.jsx)(components_1.TextLabel, { text: suffixText, styleTheme: "caption1Bold", colorTheme: "sysTextTertiary", colorOverride: stepperMode === 'use' && isFocused ? 'ui_106' : undefined, textAlign: "right", singleLineMode: "use" }), suffixTextRightSpacingMode === 'use' && ((0, jsx_runtime_1.jsx)(components_2.Spacing, { size: "spacing_b", spacingType: "width" }))] })))] })))] }));
|
|
235
240
|
}
|
|
236
241
|
if (textLineType === 'multi') {
|
|
237
|
-
return ((0, jsx_runtime_1.jsx)(S_Multi, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, rows: multiRows, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, colorTheme: colorTheme, autoComplete: autoComplete, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
242
|
+
return ((0, jsx_runtime_1.jsx)(S_Multi, __assign({}, register(name, validation), rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, rows: multiRows, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, hintTextWeight: hintTextWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, colorTheme: colorTheme, autoComplete: autoComplete, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
238
243
|
ref(e);
|
|
239
244
|
if (inputRef) {
|
|
240
245
|
inputRef.current = e;
|
|
@@ -242,7 +247,7 @@ function TextFieldBase(_a) {
|
|
|
242
247
|
} })));
|
|
243
248
|
}
|
|
244
249
|
if (textLineType === 'auto') {
|
|
245
|
-
return ((0, jsx_runtime_1.jsx)(S_Auto, __assign({}, refRest, rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, autoMinRows: autoMinRows, autoMaxRows: autoMaxRows, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, fieldHeight: fieldHeight, colorTheme: colorTheme, autoComplete: autoComplete, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
250
|
+
return ((0, jsx_runtime_1.jsx)(S_Auto, __assign({}, refRest, rest, { name: name, defaultValue: defaultText, placeholder: hintText, textAlign: textAlign, autoMinRows: autoMinRows, autoMaxRows: autoMaxRows, state: state, readOnly: state === 'read_only' && true, disabled: state === 'disabled' && true, maxLength: maxLength, textSize: textSize, customFontSize: customFontSize, textWeight: textWeight, hintTextWeight: hintTextWeight, fieldPaddingRight: fieldPaddingRight, fieldPaddingLeft: fieldPaddingLeft, fieldHeight: fieldHeight, colorTheme: colorTheme, autoComplete: autoComplete, onFocus: handleFocus, onChange: handleChange, onBlur: handleBlur, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onKeyPress: handleKeyPress, ref: function (e) {
|
|
246
251
|
ref(e);
|
|
247
252
|
if (textAreaRef) {
|
|
248
253
|
textAreaRef.current = e;
|
|
@@ -355,8 +360,8 @@ var basicStyle = (0, styled_components_1.css)(templateObject_9 || (templateObjec
|
|
|
355
360
|
var textSize = _a.textSize, customFontSize = _a.customFontSize;
|
|
356
361
|
return customFontSize ? customFontSize : common_1.desktopFontSize[textSize];
|
|
357
362
|
}, function (_a) {
|
|
358
|
-
var textWeight = _a.textWeight;
|
|
359
|
-
return common_1.fontWeight[textWeight];
|
|
363
|
+
var textWeight = _a.textWeight, hintTextWeight = _a.hintTextWeight;
|
|
364
|
+
return common_1.fontWeight[hintTextWeight || textWeight];
|
|
360
365
|
}, function (_a) {
|
|
361
366
|
var textSize = _a.textSize;
|
|
362
367
|
return common_1.desktopLineHeight[textSize];
|
|
@@ -467,7 +472,7 @@ var stepper = (0, styled_components_1.css)(templateObject_13 || (templateObject_
|
|
|
467
472
|
}
|
|
468
473
|
return;
|
|
469
474
|
});
|
|
470
|
-
var inputInnerSpinButtonStyle = (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n -webkit-appearance: none;\n z-index: 1;\n cursor: pointer;\n height: ", ";\n margin-left: ", ";\n opacity: 1;\n width: ", ";\n position: absolute;\n right: ", ";\n top: calc(\n 50% - ", "\n );\n"], ["\n -webkit-appearance: none;\n z-index: 1;\n cursor: pointer;\n height: ", ";\n margin-left: ", ";\n opacity: 1;\n width: ", ";\n position: absolute;\n right: ", ";\n top: calc(\n 50% - ", "\n );\n"])), function (_a) {
|
|
475
|
+
var inputInnerSpinButtonStyle = (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n -webkit-appearance: none;\n appearance: none;\n z-index: 1;\n cursor: pointer;\n height: ", ";\n margin-left: ", ";\n opacity: 1;\n width: ", ";\n position: absolute;\n right: ", ";\n top: calc(\n 50% - ", "\n );\n"], ["\n -webkit-appearance: none;\n appearance: none;\n z-index: 1;\n cursor: pointer;\n height: ", ";\n margin-left: ", ";\n opacity: 1;\n width: ", ";\n position: absolute;\n right: ", ";\n top: calc(\n 50% - ", "\n );\n"])), function (_a) {
|
|
471
476
|
var innerSpinButtonSize = _a.innerSpinButtonSize;
|
|
472
477
|
return innerSpinButtonSize && "".concat(innerSpinButtonSize * 2, "px");
|
|
473
478
|
}, function (_a) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Path } from 'react-hook-form';
|
|
3
|
+
import { CurrencyCode, ExchangeRateMap } from '../../../core/pricing';
|
|
4
|
+
import type { IFormValues, PDSTextType } from '../../../common';
|
|
5
|
+
import type { TextFieldBaseProps } from '../../common/components/TextFieldBase/TextFieldBase';
|
|
6
|
+
export declare const DEFAULT_DECIMAL_PLACES: {
|
|
7
|
+
readonly KRW: 0;
|
|
8
|
+
readonly USD: 2;
|
|
9
|
+
};
|
|
10
|
+
type Props = {
|
|
11
|
+
name: Path<IFormValues>;
|
|
12
|
+
hintText?: PDSTextType;
|
|
13
|
+
defaultAmount?: number;
|
|
14
|
+
size?: 'large' | 'rlarge';
|
|
15
|
+
responsiveMode?: 'none' | 'use';
|
|
16
|
+
state?: 'normal' | 'read_only' | 'disabled';
|
|
17
|
+
dropdownState?: 'normal' | 'read_only' | 'disabled';
|
|
18
|
+
customWidth?: string;
|
|
19
|
+
baseCurrency?: CurrencyCode;
|
|
20
|
+
currencies?: CurrencyCode[];
|
|
21
|
+
decimalPlaces?: Record<string, number>;
|
|
22
|
+
exchangeRates?: ExchangeRateMap;
|
|
23
|
+
hintTextFontWeight?: 'normal' | 'bold';
|
|
24
|
+
validation?: any;
|
|
25
|
+
useRequiredValidation?: 'none' | 'use';
|
|
26
|
+
returnType?: 'object' | 'string' | 'rawValue';
|
|
27
|
+
deleteBtnMode?: 'none' | 'use';
|
|
28
|
+
minPriceAmount?: string | number;
|
|
29
|
+
onChange?: (value: string) => void;
|
|
30
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement> | React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
31
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement> | React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
32
|
+
onCurrencyChange?: (selectedCurrency: string) => void;
|
|
33
|
+
onValueChange?: (data: {
|
|
34
|
+
selectedCurrency: string;
|
|
35
|
+
baseCurrencyValue: number;
|
|
36
|
+
calculatedValue: number;
|
|
37
|
+
displayValue: string;
|
|
38
|
+
}) => void;
|
|
39
|
+
} & Omit<Partial<TextFieldBaseProps>, 'textAlign' | 'preventBlankMode' | 'enterSubmitMode' | 'multiRows' | 'colorTheme'>;
|
|
40
|
+
declare function PriceTextField({ name, hintText, defaultAmount, colorTheme, size, fontWeight, hintTextFontWeight, responsiveMode, state, dropdownState, customWidth, baseCurrency, currencies, decimalPlaces, exchangeRates, textAlign, validation, useRequiredValidation, returnType, deleteBtnMode, minPriceAmount, onChange, onBlur, onFocus, onTarget, onCurrencyChange, onValueChange }: Props): JSX.Element;
|
|
41
|
+
export default PriceTextField;
|