@pisell/materials 1.0.1100 → 1.0.1101
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +3 -3
- package/build/lowcode/view.js +3 -3
- package/es/components/pisellGoodPassCard/index.d.ts +1 -0
- package/es/components/pisellGoodPassCard/index.js +2 -1
- package/es/components/pisellText/components/Editable/index.d.ts +2 -0
- package/es/components/pisellText/components/Editable/index.js +1 -0
- package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/es/components/productCard/components/Packages/utils.d.ts +1 -1
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/translation/index.d.ts +2 -0
- package/es/components/translation/index.js +18 -6
- package/es/components/walletCard/index.d.ts +10 -9
- package/es/components/walletCard/index.js +40 -21
- package/lib/components/pisellGoodPassCard/index.d.ts +1 -0
- package/lib/components/pisellGoodPassCard/index.js +1 -1
- package/lib/components/pisellText/components/Editable/index.d.ts +2 -0
- package/lib/components/pisellText/components/Editable/index.js +1 -0
- package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
- package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/translation/index.d.ts +2 -0
- package/lib/components/translation/index.js +18 -5
- package/lib/components/walletCard/index.d.ts +10 -9
- package/lib/components/walletCard/index.js +51 -13
- package/package.json +3 -3
|
@@ -65,8 +65,9 @@ var index = function index(props) {
|
|
|
65
65
|
}, renderVoucherContent(item));
|
|
66
66
|
};
|
|
67
67
|
var renderVoucherItem = function renderVoucherItem(item) {
|
|
68
|
+
var _item$displayKey;
|
|
68
69
|
return /*#__PURE__*/React.createElement("div", {
|
|
69
|
-
key: item.id,
|
|
70
|
+
key: (_item$displayKey = item.displayKey) !== null && _item$displayKey !== void 0 ? _item$displayKey : item.id,
|
|
70
71
|
className: "".concat(clsPrefix, "-voucher-item")
|
|
71
72
|
}, /*#__PURE__*/React.createElement("div", {
|
|
72
73
|
className: "item-title"
|
|
@@ -15,6 +15,8 @@ export interface EditableConfig {
|
|
|
15
15
|
maxLength?: number;
|
|
16
16
|
/** 编辑图标 */
|
|
17
17
|
icon?: React.ReactNode;
|
|
18
|
+
/** 多语言输入框在翻译缺失时显示原文,保持原始保存值。 */
|
|
19
|
+
fallbackToOriginal?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface EditableProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
20
22
|
/** 文本内容,支持字符串或多语言对象 */
|
|
@@ -17,4 +17,4 @@ export declare const minusSign: (item: any, type?: string) => "" | "-";
|
|
|
17
17
|
* @Author: WangHan
|
|
18
18
|
* @Date: 2024-11-22 10:58
|
|
19
19
|
*/
|
|
20
|
-
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) =>
|
|
20
|
+
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => string | number;
|
|
@@ -17,4 +17,4 @@ export declare const minusSign: (item: any, type?: string) => "" | "-";
|
|
|
17
17
|
* @Author: WangHan
|
|
18
18
|
* @Date: 2024-11-22 10:58
|
|
19
19
|
*/
|
|
20
|
-
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) =>
|
|
20
|
+
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => string | number;
|
|
@@ -161,7 +161,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
|
|
|
161
161
|
sort?: SortType | undefined;
|
|
162
162
|
mode: "" | "localStorage" | "remote";
|
|
163
163
|
currentViewMode: ModeType;
|
|
164
|
-
}) => ("filters" | "
|
|
164
|
+
}) => ("filters" | "view_mode" | "column_setting" | "order_by" | "group_by" | "gallery_setting" | "filter_setting")[];
|
|
165
165
|
export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
|
|
166
166
|
export declare const stringify: (obj: Record<string, any>) => string;
|
|
167
167
|
export {};
|
|
@@ -13,6 +13,8 @@ interface TranslationProps {
|
|
|
13
13
|
maxLength?: number;
|
|
14
14
|
type?: 'text' | 'textarea';
|
|
15
15
|
id?: string;
|
|
16
|
+
/** 缺失翻译时仅在输入框显示原文,不自动写入各语言字段。 */
|
|
17
|
+
fallbackToOriginal?: boolean;
|
|
16
18
|
}
|
|
17
19
|
declare const Translation: React.FC<TranslationProps>;
|
|
18
20
|
export default Translation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["value", "onChange", "type"];
|
|
2
|
+
var _excluded = ["value", "onChange", "type", "fallbackToOriginal"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -22,6 +22,11 @@ import classNames from 'classnames';
|
|
|
22
22
|
import useEngineContext from "../../hooks/useEngineContext";
|
|
23
23
|
import { checkIfAllValuesAreEqual, createTranslationText, locales } from "./utils";
|
|
24
24
|
import "./index.less";
|
|
25
|
+
var getTranslationInputValue = function getTranslationInputValue(value, locale, fallbackToOriginal) {
|
|
26
|
+
var _translations$locale;
|
|
27
|
+
var translations = value;
|
|
28
|
+
return (_translations$locale = translations === null || translations === void 0 ? void 0 : translations[locale]) !== null && _translations$locale !== void 0 ? _translations$locale : fallbackToOriginal ? (translations === null || translations === void 0 ? void 0 : translations.original) || (translations === null || translations === void 0 ? void 0 : translations.auto) || '' : '';
|
|
29
|
+
};
|
|
25
30
|
var defaultGlobal = {
|
|
26
31
|
shopLanguages: {
|
|
27
32
|
primary: 'en',
|
|
@@ -67,6 +72,8 @@ var Translation = function Translation(props) {
|
|
|
67
72
|
onChange = props.onChange,
|
|
68
73
|
_props$type = props.type,
|
|
69
74
|
type = _props$type === void 0 ? 'text' : _props$type,
|
|
75
|
+
_props$fallbackToOrig = props.fallbackToOriginal,
|
|
76
|
+
fallbackToOriginal = _props$fallbackToOrig === void 0 ? false : _props$fallbackToOrig,
|
|
70
77
|
others = _objectWithoutProperties(props, _excluded);
|
|
71
78
|
var context = useEngineContext();
|
|
72
79
|
var _useState = useState(false),
|
|
@@ -95,8 +102,8 @@ var Translation = function Translation(props) {
|
|
|
95
102
|
if (isString(value)) {
|
|
96
103
|
_newValue = createTranslationText(value);
|
|
97
104
|
}
|
|
98
|
-
set_value(_objectSpread(_objectSpread({}, defaultValue), _newValue));
|
|
99
|
-
}, [value]);
|
|
105
|
+
set_value(fallbackToOriginal ? _newValue : _objectSpread(_objectSpread({}, defaultValue), _newValue));
|
|
106
|
+
}, [value, fallbackToOriginal]);
|
|
100
107
|
var currentLocale = useMemo(function () {
|
|
101
108
|
return shopLanguages.primary;
|
|
102
109
|
}, [shopLanguages.primary]);
|
|
@@ -104,8 +111,8 @@ var Translation = function Translation(props) {
|
|
|
104
111
|
if (isString(value)) {
|
|
105
112
|
return value;
|
|
106
113
|
}
|
|
107
|
-
return value
|
|
108
|
-
}, [value, currentLocale]);
|
|
114
|
+
return getTranslationInputValue(value, currentLocale, fallbackToOriginal);
|
|
115
|
+
}, [value, currentLocale, fallbackToOriginal]);
|
|
109
116
|
var languageList = useMemo(function () {
|
|
110
117
|
return shopLanguages.list;
|
|
111
118
|
}, [shopLanguages.list]);
|
|
@@ -117,6 +124,11 @@ var Translation = function Translation(props) {
|
|
|
117
124
|
return obj;
|
|
118
125
|
}, []);
|
|
119
126
|
var allChange = function allChange(e) {
|
|
127
|
+
if (fallbackToOriginal) {
|
|
128
|
+
// 原文只用于回显;编辑某种语言时不补写其它缺失翻译。
|
|
129
|
+
onChange === null || onChange === void 0 || onChange(_objectSpread(_objectSpread({}, value), {}, _defineProperty({}, currentLocale, e || '')));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
120
132
|
var newValue = _objectSpread(_objectSpread({}, defaultValue), value || {});
|
|
121
133
|
if (checkIfAllValuesAreEqual(newValue)) {
|
|
122
134
|
for (var key in newValue) {
|
|
@@ -191,7 +203,7 @@ var Translation = function Translation(props) {
|
|
|
191
203
|
}, /*#__PURE__*/React.createElement(InputComponent, _extends({}, typeof others.maxLength === 'number' ? {
|
|
192
204
|
maxLength: others.maxLength
|
|
193
205
|
} : {}, {
|
|
194
|
-
value: _value
|
|
206
|
+
value: getTranslationInputValue(_value, d.code, fallbackToOriginal),
|
|
195
207
|
onChange: function onChange(e) {
|
|
196
208
|
set_value(_objectSpread(_objectSpread({}, _value), {}, _defineProperty({}, d.code, e.target.value)));
|
|
197
209
|
},
|
|
@@ -2,20 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
export interface WalletCardItem {
|
|
4
4
|
type: string;
|
|
5
|
-
custom_title?: string |
|
|
6
|
-
original: string;
|
|
7
|
-
en: string;
|
|
8
|
-
'zh-CN': string;
|
|
9
|
-
'zh-HK': string;
|
|
10
|
-
'ja': string;
|
|
11
|
-
'pt': string;
|
|
12
|
-
};
|
|
5
|
+
custom_title?: string | Record<string, string | null | undefined>;
|
|
13
6
|
display?: 0 | 1;
|
|
14
7
|
value?: number;
|
|
8
|
+
virtual_currency_info?: {
|
|
9
|
+
product_id: number | string;
|
|
10
|
+
total_balance?: number;
|
|
11
|
+
symbol?: Record<string, string | null | undefined> | [];
|
|
12
|
+
unit_label?: Record<string, string | null | undefined> | [];
|
|
13
|
+
amount_format?: string;
|
|
14
|
+
theme_color?: string;
|
|
15
|
+
};
|
|
15
16
|
}
|
|
16
17
|
export interface WalletCardProps {
|
|
17
18
|
/** 钱包ID */
|
|
18
|
-
id?: string;
|
|
19
|
+
id?: number | string;
|
|
19
20
|
/** 二维码弹窗适配平台 */
|
|
20
21
|
platform?: 'pc' | 'h5' | 'ipad';
|
|
21
22
|
/** 卡片主题 */
|
|
@@ -15,6 +15,7 @@ import classNames from 'classnames';
|
|
|
15
15
|
import React, { useMemo, useState } from 'react';
|
|
16
16
|
import Barcode from 'react-barcode';
|
|
17
17
|
import EyeOff from '@pisell/icon/es/EyeOff';
|
|
18
|
+
import { formatAmountWithOptions } from '@pisell/utils';
|
|
18
19
|
import { getText } from "../../locales/index";
|
|
19
20
|
import Iconfont from "./../iconfont";
|
|
20
21
|
import PisellModal from "./../pisellModal";
|
|
@@ -227,7 +228,7 @@ var CardHeader = function CardHeader(_ref2) {
|
|
|
227
228
|
|
|
228
229
|
// 子组件:卡片内容项
|
|
229
230
|
var CardItem = function CardItem(_ref3) {
|
|
230
|
-
var _context$appHelper2;
|
|
231
|
+
var _context$appHelper2, _item$virtual_currenc, _item$virtual_currenc2, _currencyInfo$theme_c, _ref4;
|
|
231
232
|
var item = _ref3.item,
|
|
232
233
|
symbol = _ref3.symbol;
|
|
233
234
|
var type = item.type,
|
|
@@ -236,12 +237,23 @@ var CardItem = function CardItem(_ref3) {
|
|
|
236
237
|
var context = useEngineContext();
|
|
237
238
|
var utils = context === null || context === void 0 || (_context$appHelper2 = context.appHelper) === null || _context$appHelper2 === void 0 ? void 0 : _context$appHelper2.utils;
|
|
238
239
|
var translationOriginal = (utils === null || utils === void 0 ? void 0 : utils.translationOriginal) || (utils === null || utils === void 0 ? void 0 : utils.translation);
|
|
240
|
+
var translate = function translate(text) {
|
|
241
|
+
if (typeof text === 'string') return text;
|
|
242
|
+
if (!text || Array.isArray(text)) return '';
|
|
243
|
+
var translated = translationOriginal === null || translationOriginal === void 0 ? void 0 : translationOriginal(text);
|
|
244
|
+
return typeof translated === 'string' && translated ? translated : text.original || text.en || '';
|
|
245
|
+
};
|
|
246
|
+
var currencyInfo = item.virtual_currency_info;
|
|
247
|
+
var title = custom_title || (type === 'virtual_currency' ? "Virtual currency #".concat((_item$virtual_currenc = (_item$virtual_currenc2 = item.virtual_currency_info) === null || _item$virtual_currenc2 === void 0 ? void 0 : _item$virtual_currenc2.product_id) !== null && _item$virtual_currenc !== void 0 ? _item$virtual_currenc : '') : '');
|
|
239
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
240
249
|
className: "pisell-wallet-card-item"
|
|
241
250
|
}, /*#__PURE__*/React.createElement("div", {
|
|
242
251
|
className: "pisell-wallet-card-item-label"
|
|
243
|
-
},
|
|
244
|
-
className: "pisell-wallet-card-item-value"
|
|
252
|
+
}, translate(title)), /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: "pisell-wallet-card-item-value",
|
|
254
|
+
style: type === 'virtual_currency' ? {
|
|
255
|
+
color: (currencyInfo === null || currencyInfo === void 0 || (_currencyInfo$theme_c = currencyInfo.theme_color) === null || _currencyInfo$theme_c === void 0 ? void 0 : _currencyInfo$theme_c.trim()) || undefined
|
|
256
|
+
} : undefined
|
|
245
257
|
}, type === 'rechargeable' ? /*#__PURE__*/React.createElement(Amount, {
|
|
246
258
|
className: "pisell-card-amount-item-value",
|
|
247
259
|
platform: "h5",
|
|
@@ -249,24 +261,31 @@ var CardItem = function CardItem(_ref3) {
|
|
|
249
261
|
useThousandsSeparator: true,
|
|
250
262
|
showCurrencySymbol: true,
|
|
251
263
|
value: value
|
|
264
|
+
}) : type === 'virtual_currency' ? formatAmountWithOptions((_ref4 = value !== null && value !== void 0 ? value : currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.total_balance) !== null && _ref4 !== void 0 ? _ref4 : 0, translate(currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.symbol), {
|
|
265
|
+
precision: 2,
|
|
266
|
+
hideDecimalForWholeNumbers: false,
|
|
267
|
+
useThousandsSeparator: true,
|
|
268
|
+
currencyCode: translate(currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.unit_label),
|
|
269
|
+
currencyFormat: (currencyInfo === null || currencyInfo === void 0 ? void 0 : currencyInfo.amount_format) || ''
|
|
252
270
|
}) : value || '0'));
|
|
253
271
|
};
|
|
254
272
|
|
|
255
273
|
// 子组件:卡片内容
|
|
256
|
-
var CardContent = function CardContent(
|
|
257
|
-
var items =
|
|
258
|
-
symbol =
|
|
274
|
+
var CardContent = function CardContent(_ref5) {
|
|
275
|
+
var items = _ref5.items,
|
|
276
|
+
symbol = _ref5.symbol;
|
|
259
277
|
var filteredItems = (items || []).filter(function (item) {
|
|
260
|
-
return item.display !== 0;
|
|
261
|
-
});
|
|
278
|
+
return item.type === 'virtual_currency' ? item.display === 1 : item.display !== 0;
|
|
279
|
+
}).slice(0, 4);
|
|
262
280
|
return /*#__PURE__*/React.createElement("div", {
|
|
263
281
|
className: "pisell-wallet-card-list",
|
|
264
282
|
style: {
|
|
265
283
|
justifyContent: filteredItems.length > 1 ? 'space-between' : 'flex-start'
|
|
266
284
|
}
|
|
267
285
|
}, filteredItems.map(function (item, index) {
|
|
286
|
+
var _item$virtual_currenc3, _item$virtual_currenc4;
|
|
268
287
|
return /*#__PURE__*/React.createElement(CardItem, {
|
|
269
|
-
key: index,
|
|
288
|
+
key: item.type === 'virtual_currency' ? "virtual_currency:".concat((_item$virtual_currenc3 = (_item$virtual_currenc4 = item.virtual_currency_info) === null || _item$virtual_currenc4 === void 0 ? void 0 : _item$virtual_currenc4.product_id) !== null && _item$virtual_currenc3 !== void 0 ? _item$virtual_currenc3 : index) : item.type,
|
|
270
289
|
item: item,
|
|
271
290
|
symbol: symbol
|
|
272
291
|
});
|
|
@@ -274,9 +293,9 @@ var CardContent = function CardContent(_ref4) {
|
|
|
274
293
|
};
|
|
275
294
|
|
|
276
295
|
// 子组件:二维码/条形码显示
|
|
277
|
-
var CodeDisplay = function CodeDisplay(
|
|
278
|
-
var codeType =
|
|
279
|
-
cardNo =
|
|
296
|
+
var CodeDisplay = function CodeDisplay(_ref6) {
|
|
297
|
+
var codeType = _ref6.codeType,
|
|
298
|
+
cardNo = _ref6.cardNo;
|
|
280
299
|
if (!cardNo) return null;
|
|
281
300
|
return /*#__PURE__*/React.createElement("div", {
|
|
282
301
|
className: "pisell-wallet-card-code"
|
|
@@ -306,12 +325,12 @@ var blockEvent = function blockEvent(e) {
|
|
|
306
325
|
};
|
|
307
326
|
|
|
308
327
|
// 子组件:二维码/条形码模态框
|
|
309
|
-
var CodeModal = function CodeModal(
|
|
310
|
-
var isOpen =
|
|
311
|
-
onClose =
|
|
312
|
-
codeType =
|
|
313
|
-
cardNo =
|
|
314
|
-
platform =
|
|
328
|
+
var CodeModal = function CodeModal(_ref7) {
|
|
329
|
+
var isOpen = _ref7.isOpen,
|
|
330
|
+
onClose = _ref7.onClose,
|
|
331
|
+
codeType = _ref7.codeType,
|
|
332
|
+
cardNo = _ref7.cardNo,
|
|
333
|
+
platform = _ref7.platform;
|
|
315
334
|
return /*#__PURE__*/React.createElement(PisellModal, {
|
|
316
335
|
title: getText(codeType === 'barCode' ? 'walletCard-barcode' : 'walletCard-qrcode'),
|
|
317
336
|
platform: platform,
|
|
@@ -378,9 +397,9 @@ var WalletCard = function WalletCard(props) {
|
|
|
378
397
|
var isLogin = toBooleanValue(mergedProps.isLogin);
|
|
379
398
|
var showViewPin = toBooleanValue(mergedProps === null || mergedProps === void 0 ? void 0 : mergedProps.showViewPin);
|
|
380
399
|
var context = useEngineContext();
|
|
381
|
-
var
|
|
382
|
-
utils =
|
|
383
|
-
constants =
|
|
400
|
+
var _ref8 = context.appHelper || {},
|
|
401
|
+
utils = _ref8.utils,
|
|
402
|
+
constants = _ref8.constants;
|
|
384
403
|
// 使用自定义钩子处理模态框逻辑
|
|
385
404
|
var _useCodeModal = useCodeModal(cardNo, onCodeClick, codeType),
|
|
386
405
|
isModalOpen = _useCodeModal.isModalOpen,
|
|
@@ -74,7 +74,7 @@ var index = (props) => {
|
|
|
74
74
|
);
|
|
75
75
|
};
|
|
76
76
|
const renderVoucherItem = (item) => {
|
|
77
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { key: item.id, className: `${clsPrefix}-voucher-item` }, /* @__PURE__ */ import_react.default.createElement("div", { className: "item-title" }, translation(item.format_title), item.isEditMode && (0, import_locales.getText)("pisell2.text.goodpass.last-settlement")), /* @__PURE__ */ import_react.default.createElement("div", { className: "item-content" }, renderActionElement(item)));
|
|
77
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { key: item.displayKey ?? item.id, className: `${clsPrefix}-voucher-item` }, /* @__PURE__ */ import_react.default.createElement("div", { className: "item-title" }, translation(item.format_title), item.isEditMode && (0, import_locales.getText)("pisell2.text.goodpass.last-settlement")), /* @__PURE__ */ import_react.default.createElement("div", { className: "item-content" }, renderActionElement(item)));
|
|
78
78
|
};
|
|
79
79
|
const renderModal = () => {
|
|
80
80
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
@@ -15,6 +15,8 @@ export interface EditableConfig {
|
|
|
15
15
|
maxLength?: number;
|
|
16
16
|
/** 编辑图标 */
|
|
17
17
|
icon?: React.ReactNode;
|
|
18
|
+
/** 多语言输入框在翻译缺失时显示原文,保持原始保存值。 */
|
|
19
|
+
fallbackToOriginal?: boolean;
|
|
18
20
|
}
|
|
19
21
|
export interface EditableProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
20
22
|
/** 文本内容,支持字符串或多语言对象 */
|
|
@@ -17,4 +17,4 @@ export declare const minusSign: (item: any, type?: string) => "" | "-";
|
|
|
17
17
|
* @Author: WangHan
|
|
18
18
|
* @Date: 2024-11-22 10:58
|
|
19
19
|
*/
|
|
20
|
-
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) =>
|
|
20
|
+
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => string | number;
|
|
@@ -17,4 +17,4 @@ export declare const minusSign: (item: any, type?: string) => "" | "-";
|
|
|
17
17
|
* @Author: WangHan
|
|
18
18
|
* @Date: 2024-11-22 10:58
|
|
19
19
|
*/
|
|
20
|
-
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) =>
|
|
20
|
+
export declare const _formatAmount: (price?: number, amountSymbol?: string, digit?: number) => string | number;
|
|
@@ -161,7 +161,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
|
|
|
161
161
|
sort?: SortType | undefined;
|
|
162
162
|
mode: "" | "localStorage" | "remote";
|
|
163
163
|
currentViewMode: ModeType;
|
|
164
|
-
}) => ("filters" | "
|
|
164
|
+
}) => ("filters" | "view_mode" | "column_setting" | "order_by" | "group_by" | "gallery_setting" | "filter_setting")[];
|
|
165
165
|
export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
|
|
166
166
|
export declare const stringify: (obj: Record<string, any>) => string;
|
|
167
167
|
export {};
|
|
@@ -13,6 +13,8 @@ interface TranslationProps {
|
|
|
13
13
|
maxLength?: number;
|
|
14
14
|
type?: 'text' | 'textarea';
|
|
15
15
|
id?: string;
|
|
16
|
+
/** 缺失翻译时仅在输入框显示原文,不自动写入各语言字段。 */
|
|
17
|
+
fallbackToOriginal?: boolean;
|
|
16
18
|
}
|
|
17
19
|
declare const Translation: React.FC<TranslationProps>;
|
|
18
20
|
export default Translation;
|
|
@@ -40,6 +40,10 @@ var import_classnames = __toESM(require("classnames"));
|
|
|
40
40
|
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
|
|
41
41
|
var import_utils2 = require("./utils");
|
|
42
42
|
var import_index = require("./index.less");
|
|
43
|
+
var getTranslationInputValue = (value, locale, fallbackToOriginal) => {
|
|
44
|
+
const translations = value;
|
|
45
|
+
return (translations == null ? void 0 : translations[locale]) ?? (fallbackToOriginal ? (translations == null ? void 0 : translations.original) || (translations == null ? void 0 : translations.auto) || "" : "");
|
|
46
|
+
};
|
|
43
47
|
var defaultGlobal = {
|
|
44
48
|
shopLanguages: {
|
|
45
49
|
primary: "en",
|
|
@@ -90,6 +94,7 @@ var Translation = (props) => {
|
|
|
90
94
|
value = defaultObj,
|
|
91
95
|
onChange,
|
|
92
96
|
type = "text",
|
|
97
|
+
fallbackToOriginal = false,
|
|
93
98
|
...others
|
|
94
99
|
} = props;
|
|
95
100
|
const context = (0, import_useEngineContext.default)();
|
|
@@ -112,8 +117,8 @@ var Translation = (props) => {
|
|
|
112
117
|
if ((0, import_utils.isString)(value)) {
|
|
113
118
|
_newValue = (0, import_utils2.createTranslationText)(value);
|
|
114
119
|
}
|
|
115
|
-
set_value({ ...defaultValue, ..._newValue });
|
|
116
|
-
}, [value]);
|
|
120
|
+
set_value(fallbackToOriginal ? _newValue : { ...defaultValue, ..._newValue });
|
|
121
|
+
}, [value, fallbackToOriginal]);
|
|
117
122
|
const currentLocale = (0, import_react.useMemo)(() => {
|
|
118
123
|
return shopLanguages.primary;
|
|
119
124
|
}, [shopLanguages.primary]);
|
|
@@ -121,8 +126,8 @@ var Translation = (props) => {
|
|
|
121
126
|
if ((0, import_utils.isString)(value)) {
|
|
122
127
|
return value;
|
|
123
128
|
}
|
|
124
|
-
return value
|
|
125
|
-
}, [value, currentLocale]);
|
|
129
|
+
return getTranslationInputValue(value, currentLocale, fallbackToOriginal);
|
|
130
|
+
}, [value, currentLocale, fallbackToOriginal]);
|
|
126
131
|
const languageList = (0, import_react.useMemo)(() => {
|
|
127
132
|
return shopLanguages.list;
|
|
128
133
|
}, [shopLanguages.list]);
|
|
@@ -134,6 +139,10 @@ var Translation = (props) => {
|
|
|
134
139
|
return obj;
|
|
135
140
|
}, []);
|
|
136
141
|
const allChange = (e) => {
|
|
142
|
+
if (fallbackToOriginal) {
|
|
143
|
+
onChange == null ? void 0 : onChange({ ...value, [currentLocale]: e || "" });
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
137
146
|
let newValue = {
|
|
138
147
|
...defaultValue,
|
|
139
148
|
...value || {}
|
|
@@ -201,7 +210,11 @@ var Translation = (props) => {
|
|
|
201
210
|
InputComponent,
|
|
202
211
|
{
|
|
203
212
|
...typeof others.maxLength === "number" ? { maxLength: others.maxLength } : {},
|
|
204
|
-
value:
|
|
213
|
+
value: getTranslationInputValue(
|
|
214
|
+
_value,
|
|
215
|
+
d.code,
|
|
216
|
+
fallbackToOriginal
|
|
217
|
+
),
|
|
205
218
|
onChange: (e) => {
|
|
206
219
|
set_value({ ..._value, [d.code]: e.target.value });
|
|
207
220
|
},
|
|
@@ -2,20 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
export interface WalletCardItem {
|
|
4
4
|
type: string;
|
|
5
|
-
custom_title?: string |
|
|
6
|
-
original: string;
|
|
7
|
-
en: string;
|
|
8
|
-
'zh-CN': string;
|
|
9
|
-
'zh-HK': string;
|
|
10
|
-
'ja': string;
|
|
11
|
-
'pt': string;
|
|
12
|
-
};
|
|
5
|
+
custom_title?: string | Record<string, string | null | undefined>;
|
|
13
6
|
display?: 0 | 1;
|
|
14
7
|
value?: number;
|
|
8
|
+
virtual_currency_info?: {
|
|
9
|
+
product_id: number | string;
|
|
10
|
+
total_balance?: number;
|
|
11
|
+
symbol?: Record<string, string | null | undefined> | [];
|
|
12
|
+
unit_label?: Record<string, string | null | undefined> | [];
|
|
13
|
+
amount_format?: string;
|
|
14
|
+
theme_color?: string;
|
|
15
|
+
};
|
|
15
16
|
}
|
|
16
17
|
export interface WalletCardProps {
|
|
17
18
|
/** 钱包ID */
|
|
18
|
-
id?: string;
|
|
19
|
+
id?: number | string;
|
|
19
20
|
/** 二维码弹窗适配平台 */
|
|
20
21
|
platform?: 'pc' | 'h5' | 'ipad';
|
|
21
22
|
/** 卡片主题 */
|
|
@@ -37,6 +37,7 @@ var import_classnames = __toESM(require("classnames"));
|
|
|
37
37
|
var import_react = __toESM(require("react"));
|
|
38
38
|
var import_react_barcode = __toESM(require("react-barcode"));
|
|
39
39
|
var import_EyeOff = __toESM(require("@pisell/icon/es/EyeOff"));
|
|
40
|
+
var import_utils = require("@pisell/utils");
|
|
40
41
|
var import_locales = require("../../locales/index");
|
|
41
42
|
var import_iconfont = __toESM(require("./../iconfont"));
|
|
42
43
|
var import_pisellModal = __toESM(require("./../pisellModal"));
|
|
@@ -222,25 +223,52 @@ var CardHeader = ({
|
|
|
222
223
|
)));
|
|
223
224
|
};
|
|
224
225
|
var CardItem = ({ item, symbol }) => {
|
|
225
|
-
var _a;
|
|
226
|
+
var _a, _b, _c;
|
|
226
227
|
const { type, custom_title, value } = item;
|
|
227
228
|
const context = (0, import_useEngineContext.default)();
|
|
228
229
|
const utils = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils;
|
|
229
230
|
const translationOriginal = (utils == null ? void 0 : utils.translationOriginal) || (utils == null ? void 0 : utils.translation);
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
const translate = (text) => {
|
|
232
|
+
if (typeof text === "string") return text;
|
|
233
|
+
if (!text || Array.isArray(text)) return "";
|
|
234
|
+
const translated = translationOriginal == null ? void 0 : translationOriginal(text);
|
|
235
|
+
return typeof translated === "string" && translated ? translated : text.original || text.en || "";
|
|
236
|
+
};
|
|
237
|
+
const currencyInfo = item.virtual_currency_info;
|
|
238
|
+
const title = custom_title || (type === "virtual_currency" ? `Virtual currency #${((_b = item.virtual_currency_info) == null ? void 0 : _b.product_id) ?? ""}` : "");
|
|
239
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-wallet-card-item" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-wallet-card-item-label" }, translate(title)), /* @__PURE__ */ import_react.default.createElement(
|
|
240
|
+
"div",
|
|
232
241
|
{
|
|
233
|
-
className: "pisell-card-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
className: "pisell-wallet-card-item-value",
|
|
243
|
+
style: type === "virtual_currency" ? { color: ((_c = currencyInfo == null ? void 0 : currencyInfo.theme_color) == null ? void 0 : _c.trim()) || void 0 } : void 0
|
|
244
|
+
},
|
|
245
|
+
type === "rechargeable" ? /* @__PURE__ */ import_react.default.createElement(
|
|
246
|
+
import_Amount.default,
|
|
247
|
+
{
|
|
248
|
+
className: "pisell-card-amount-item-value",
|
|
249
|
+
platform: "h5",
|
|
250
|
+
symbol,
|
|
251
|
+
useThousandsSeparator: true,
|
|
252
|
+
showCurrencySymbol: true,
|
|
253
|
+
value
|
|
254
|
+
}
|
|
255
|
+
) : type === "virtual_currency" ? (0, import_utils.formatAmountWithOptions)(
|
|
256
|
+
value ?? (currencyInfo == null ? void 0 : currencyInfo.total_balance) ?? 0,
|
|
257
|
+
translate(currencyInfo == null ? void 0 : currencyInfo.symbol),
|
|
258
|
+
{
|
|
259
|
+
precision: 2,
|
|
260
|
+
hideDecimalForWholeNumbers: false,
|
|
261
|
+
useThousandsSeparator: true,
|
|
262
|
+
currencyCode: translate(currencyInfo == null ? void 0 : currencyInfo.unit_label),
|
|
263
|
+
currencyFormat: (currencyInfo == null ? void 0 : currencyInfo.amount_format) || ""
|
|
264
|
+
}
|
|
265
|
+
) : value || "0"
|
|
266
|
+
));
|
|
241
267
|
};
|
|
242
268
|
var CardContent = ({ items, symbol }) => {
|
|
243
|
-
const filteredItems = (items || []).filter(
|
|
269
|
+
const filteredItems = (items || []).filter(
|
|
270
|
+
(item) => item.type === "virtual_currency" ? item.display === 1 : item.display !== 0
|
|
271
|
+
).slice(0, 4);
|
|
244
272
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
245
273
|
"div",
|
|
246
274
|
{
|
|
@@ -249,7 +277,17 @@ var CardContent = ({ items, symbol }) => {
|
|
|
249
277
|
justifyContent: filteredItems.length > 1 ? "space-between" : "flex-start"
|
|
250
278
|
}
|
|
251
279
|
},
|
|
252
|
-
filteredItems.map((item, index) =>
|
|
280
|
+
filteredItems.map((item, index) => {
|
|
281
|
+
var _a;
|
|
282
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
283
|
+
CardItem,
|
|
284
|
+
{
|
|
285
|
+
key: item.type === "virtual_currency" ? `virtual_currency:${((_a = item.virtual_currency_info) == null ? void 0 : _a.product_id) ?? index}` : item.type,
|
|
286
|
+
item,
|
|
287
|
+
symbol
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
})
|
|
253
291
|
);
|
|
254
292
|
};
|
|
255
293
|
var CodeDisplay = ({ codeType, cardNo }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/materials",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1101",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"antd-mobile": "^5.38.1",
|
|
98
98
|
"vod-js-sdk-v6": "^1.4.11",
|
|
99
99
|
"@pisell/date-picker": "1.0.145",
|
|
100
|
-
"@pisell/
|
|
101
|
-
"@pisell/
|
|
100
|
+
"@pisell/icon": "0.0.10",
|
|
101
|
+
"@pisell/utils": "1.0.72"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^18.0.0",
|