@etsoo/appscript 1.4.51 → 1.4.52
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.
|
@@ -149,16 +149,20 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
149
149
|
*/
|
|
150
150
|
get owner(): ShoppingCartOwner | undefined;
|
|
151
151
|
set owner(value: ShoppingCartOwner | undefined);
|
|
152
|
+
_currency: Currency;
|
|
152
153
|
/**
|
|
153
154
|
* ISO currency id
|
|
154
155
|
* 标准货币编号
|
|
155
156
|
*/
|
|
156
|
-
|
|
157
|
+
get currency(): Currency;
|
|
158
|
+
private set currency(value);
|
|
159
|
+
_culture: string;
|
|
157
160
|
/**
|
|
158
161
|
* ISO culture id, like zh-Hans
|
|
159
162
|
* 标准语言文化编号
|
|
160
163
|
*/
|
|
161
|
-
|
|
164
|
+
get culture(): string;
|
|
165
|
+
private set culture(value);
|
|
162
166
|
_items: T[];
|
|
163
167
|
/**
|
|
164
168
|
* Items
|
|
@@ -178,11 +182,13 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
178
182
|
* 关联的表单数据
|
|
179
183
|
*/
|
|
180
184
|
formData: any;
|
|
185
|
+
_symbol: string | undefined;
|
|
181
186
|
/**
|
|
182
187
|
* Currency symbol
|
|
183
188
|
* 币种符号
|
|
184
189
|
*/
|
|
185
|
-
|
|
190
|
+
get symbol(): string | undefined;
|
|
191
|
+
private set symbol(value);
|
|
186
192
|
/**
|
|
187
193
|
* Cart identifier
|
|
188
194
|
* 购物篮标识
|
|
@@ -258,6 +264,16 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
258
264
|
* @param overrideExisting Override existing price
|
|
259
265
|
*/
|
|
260
266
|
cachePrice(id: T['id'], price: number, overrideExisting?: boolean): void;
|
|
267
|
+
/**
|
|
268
|
+
* Change currency
|
|
269
|
+
* @param currency Currency
|
|
270
|
+
*/
|
|
271
|
+
changeCurrency(currency: Currency): void;
|
|
272
|
+
/**
|
|
273
|
+
* Change culture
|
|
274
|
+
* @param culture Culture
|
|
275
|
+
*/
|
|
276
|
+
changeCulture(culture: string): void;
|
|
261
277
|
/**
|
|
262
278
|
* Clear storage
|
|
263
279
|
* @param keepOwner Keep owner data
|
|
@@ -276,10 +292,16 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
276
292
|
*/
|
|
277
293
|
getItem(id: T['id']): T | undefined;
|
|
278
294
|
/**
|
|
279
|
-
* Reset
|
|
295
|
+
* Reset currency and culture
|
|
296
|
+
* @param currency New currency
|
|
297
|
+
* @param culture New culture
|
|
298
|
+
*/
|
|
299
|
+
reset(currency: Currency, culture: string): void;
|
|
300
|
+
/**
|
|
301
|
+
* Reset item
|
|
280
302
|
* @param item Shopping cart item
|
|
281
303
|
*/
|
|
282
|
-
|
|
304
|
+
resetItem(item: ShoppingCartItem): void;
|
|
283
305
|
/**
|
|
284
306
|
* Save cart data
|
|
285
307
|
* @param persisted For persisted storage
|
|
@@ -79,6 +79,26 @@ class ShoppingCart {
|
|
|
79
79
|
this.setCartData(data);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* ISO currency id
|
|
84
|
+
* 标准货币编号
|
|
85
|
+
*/
|
|
86
|
+
get currency() {
|
|
87
|
+
return this._currency;
|
|
88
|
+
}
|
|
89
|
+
set currency(value) {
|
|
90
|
+
this._currency = value;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* ISO culture id, like zh-Hans
|
|
94
|
+
* 标准语言文化编号
|
|
95
|
+
*/
|
|
96
|
+
get culture() {
|
|
97
|
+
return this._culture;
|
|
98
|
+
}
|
|
99
|
+
set culture(value) {
|
|
100
|
+
this._culture = value;
|
|
101
|
+
}
|
|
82
102
|
/**
|
|
83
103
|
* Items
|
|
84
104
|
* 项目
|
|
@@ -99,6 +119,16 @@ class ShoppingCart {
|
|
|
99
119
|
set promotions(value) {
|
|
100
120
|
this._promotions = value;
|
|
101
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Currency symbol
|
|
124
|
+
* 币种符号
|
|
125
|
+
*/
|
|
126
|
+
get symbol() {
|
|
127
|
+
return this._symbol;
|
|
128
|
+
}
|
|
129
|
+
set symbol(value) {
|
|
130
|
+
this._symbol = value;
|
|
131
|
+
}
|
|
102
132
|
/**
|
|
103
133
|
* Cart identifier
|
|
104
134
|
* 购物篮标识
|
|
@@ -165,15 +195,14 @@ class ShoppingCart {
|
|
|
165
195
|
*/
|
|
166
196
|
this.prices = {};
|
|
167
197
|
if (Array.isArray(currencyOrState)) {
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
198
|
+
this.changeCurrency(currencyOrState[0]);
|
|
199
|
+
this.changeCulture(currencyOrState[1]);
|
|
170
200
|
}
|
|
171
201
|
else {
|
|
172
202
|
this.setCartData(currencyOrState);
|
|
173
|
-
this.
|
|
174
|
-
this.
|
|
203
|
+
this.changeCurrency(currencyOrState.currency);
|
|
204
|
+
this.changeCulture(currencyOrState.culture);
|
|
175
205
|
}
|
|
176
|
-
this.symbol = shared_1.NumberUtils.getCurrencySymbol(this.currency);
|
|
177
206
|
}
|
|
178
207
|
setCartData(state) {
|
|
179
208
|
const { owner, items = [], promotions = [], formData } = state !== null && state !== void 0 ? state : {};
|
|
@@ -212,6 +241,21 @@ class ShoppingCart {
|
|
|
212
241
|
if (overrideExisting || this.prices[id] == null)
|
|
213
242
|
this.prices[id] = price;
|
|
214
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Change currency
|
|
246
|
+
* @param currency Currency
|
|
247
|
+
*/
|
|
248
|
+
changeCurrency(currency) {
|
|
249
|
+
this.currency = currency;
|
|
250
|
+
this.symbol = shared_1.NumberUtils.getCurrencySymbol(this.currency);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Change culture
|
|
254
|
+
* @param culture Culture
|
|
255
|
+
*/
|
|
256
|
+
changeCulture(culture) {
|
|
257
|
+
this.culture = culture;
|
|
258
|
+
}
|
|
215
259
|
/**
|
|
216
260
|
* Clear storage
|
|
217
261
|
* @param keepOwner Keep owner data
|
|
@@ -251,10 +295,20 @@ class ShoppingCart {
|
|
|
251
295
|
return this.items.find((item) => item.id === id);
|
|
252
296
|
}
|
|
253
297
|
/**
|
|
254
|
-
* Reset
|
|
298
|
+
* Reset currency and culture
|
|
299
|
+
* @param currency New currency
|
|
300
|
+
* @param culture New culture
|
|
301
|
+
*/
|
|
302
|
+
reset(currency, culture) {
|
|
303
|
+
this.clear(true);
|
|
304
|
+
this.changeCurrency(currency);
|
|
305
|
+
this.changeCulture(culture);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Reset item
|
|
255
309
|
* @param item Shopping cart item
|
|
256
310
|
*/
|
|
257
|
-
|
|
311
|
+
resetItem(item) {
|
|
258
312
|
item.discount = 0;
|
|
259
313
|
item.currentPrice = undefined;
|
|
260
314
|
item.promotions = [];
|
|
@@ -149,16 +149,20 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
149
149
|
*/
|
|
150
150
|
get owner(): ShoppingCartOwner | undefined;
|
|
151
151
|
set owner(value: ShoppingCartOwner | undefined);
|
|
152
|
+
_currency: Currency;
|
|
152
153
|
/**
|
|
153
154
|
* ISO currency id
|
|
154
155
|
* 标准货币编号
|
|
155
156
|
*/
|
|
156
|
-
|
|
157
|
+
get currency(): Currency;
|
|
158
|
+
private set currency(value);
|
|
159
|
+
_culture: string;
|
|
157
160
|
/**
|
|
158
161
|
* ISO culture id, like zh-Hans
|
|
159
162
|
* 标准语言文化编号
|
|
160
163
|
*/
|
|
161
|
-
|
|
164
|
+
get culture(): string;
|
|
165
|
+
private set culture(value);
|
|
162
166
|
_items: T[];
|
|
163
167
|
/**
|
|
164
168
|
* Items
|
|
@@ -178,11 +182,13 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
178
182
|
* 关联的表单数据
|
|
179
183
|
*/
|
|
180
184
|
formData: any;
|
|
185
|
+
_symbol: string | undefined;
|
|
181
186
|
/**
|
|
182
187
|
* Currency symbol
|
|
183
188
|
* 币种符号
|
|
184
189
|
*/
|
|
185
|
-
|
|
190
|
+
get symbol(): string | undefined;
|
|
191
|
+
private set symbol(value);
|
|
186
192
|
/**
|
|
187
193
|
* Cart identifier
|
|
188
194
|
* 购物篮标识
|
|
@@ -258,6 +264,16 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
258
264
|
* @param overrideExisting Override existing price
|
|
259
265
|
*/
|
|
260
266
|
cachePrice(id: T['id'], price: number, overrideExisting?: boolean): void;
|
|
267
|
+
/**
|
|
268
|
+
* Change currency
|
|
269
|
+
* @param currency Currency
|
|
270
|
+
*/
|
|
271
|
+
changeCurrency(currency: Currency): void;
|
|
272
|
+
/**
|
|
273
|
+
* Change culture
|
|
274
|
+
* @param culture Culture
|
|
275
|
+
*/
|
|
276
|
+
changeCulture(culture: string): void;
|
|
261
277
|
/**
|
|
262
278
|
* Clear storage
|
|
263
279
|
* @param keepOwner Keep owner data
|
|
@@ -276,10 +292,16 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
276
292
|
*/
|
|
277
293
|
getItem(id: T['id']): T | undefined;
|
|
278
294
|
/**
|
|
279
|
-
* Reset
|
|
295
|
+
* Reset currency and culture
|
|
296
|
+
* @param currency New currency
|
|
297
|
+
* @param culture New culture
|
|
298
|
+
*/
|
|
299
|
+
reset(currency: Currency, culture: string): void;
|
|
300
|
+
/**
|
|
301
|
+
* Reset item
|
|
280
302
|
* @param item Shopping cart item
|
|
281
303
|
*/
|
|
282
|
-
|
|
304
|
+
resetItem(item: ShoppingCartItem): void;
|
|
283
305
|
/**
|
|
284
306
|
* Save cart data
|
|
285
307
|
* @param persisted For persisted storage
|
|
@@ -76,6 +76,26 @@ export class ShoppingCart {
|
|
|
76
76
|
this.setCartData(data);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* ISO currency id
|
|
81
|
+
* 标准货币编号
|
|
82
|
+
*/
|
|
83
|
+
get currency() {
|
|
84
|
+
return this._currency;
|
|
85
|
+
}
|
|
86
|
+
set currency(value) {
|
|
87
|
+
this._currency = value;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* ISO culture id, like zh-Hans
|
|
91
|
+
* 标准语言文化编号
|
|
92
|
+
*/
|
|
93
|
+
get culture() {
|
|
94
|
+
return this._culture;
|
|
95
|
+
}
|
|
96
|
+
set culture(value) {
|
|
97
|
+
this._culture = value;
|
|
98
|
+
}
|
|
79
99
|
/**
|
|
80
100
|
* Items
|
|
81
101
|
* 项目
|
|
@@ -96,6 +116,16 @@ export class ShoppingCart {
|
|
|
96
116
|
set promotions(value) {
|
|
97
117
|
this._promotions = value;
|
|
98
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Currency symbol
|
|
121
|
+
* 币种符号
|
|
122
|
+
*/
|
|
123
|
+
get symbol() {
|
|
124
|
+
return this._symbol;
|
|
125
|
+
}
|
|
126
|
+
set symbol(value) {
|
|
127
|
+
this._symbol = value;
|
|
128
|
+
}
|
|
99
129
|
/**
|
|
100
130
|
* Cart identifier
|
|
101
131
|
* 购物篮标识
|
|
@@ -162,15 +192,14 @@ export class ShoppingCart {
|
|
|
162
192
|
*/
|
|
163
193
|
this.prices = {};
|
|
164
194
|
if (Array.isArray(currencyOrState)) {
|
|
165
|
-
this.
|
|
166
|
-
this.
|
|
195
|
+
this.changeCurrency(currencyOrState[0]);
|
|
196
|
+
this.changeCulture(currencyOrState[1]);
|
|
167
197
|
}
|
|
168
198
|
else {
|
|
169
199
|
this.setCartData(currencyOrState);
|
|
170
|
-
this.
|
|
171
|
-
this.
|
|
200
|
+
this.changeCurrency(currencyOrState.currency);
|
|
201
|
+
this.changeCulture(currencyOrState.culture);
|
|
172
202
|
}
|
|
173
|
-
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
174
203
|
}
|
|
175
204
|
setCartData(state) {
|
|
176
205
|
const { owner, items = [], promotions = [], formData } = state !== null && state !== void 0 ? state : {};
|
|
@@ -209,6 +238,21 @@ export class ShoppingCart {
|
|
|
209
238
|
if (overrideExisting || this.prices[id] == null)
|
|
210
239
|
this.prices[id] = price;
|
|
211
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Change currency
|
|
243
|
+
* @param currency Currency
|
|
244
|
+
*/
|
|
245
|
+
changeCurrency(currency) {
|
|
246
|
+
this.currency = currency;
|
|
247
|
+
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Change culture
|
|
251
|
+
* @param culture Culture
|
|
252
|
+
*/
|
|
253
|
+
changeCulture(culture) {
|
|
254
|
+
this.culture = culture;
|
|
255
|
+
}
|
|
212
256
|
/**
|
|
213
257
|
* Clear storage
|
|
214
258
|
* @param keepOwner Keep owner data
|
|
@@ -248,10 +292,20 @@ export class ShoppingCart {
|
|
|
248
292
|
return this.items.find((item) => item.id === id);
|
|
249
293
|
}
|
|
250
294
|
/**
|
|
251
|
-
* Reset
|
|
295
|
+
* Reset currency and culture
|
|
296
|
+
* @param currency New currency
|
|
297
|
+
* @param culture New culture
|
|
298
|
+
*/
|
|
299
|
+
reset(currency, culture) {
|
|
300
|
+
this.clear(true);
|
|
301
|
+
this.changeCurrency(currency);
|
|
302
|
+
this.changeCulture(culture);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Reset item
|
|
252
306
|
* @param item Shopping cart item
|
|
253
307
|
*/
|
|
254
|
-
|
|
308
|
+
resetItem(item) {
|
|
255
309
|
item.discount = 0;
|
|
256
310
|
item.currentPrice = undefined;
|
|
257
311
|
item.promotions = [];
|
package/package.json
CHANGED
|
@@ -216,17 +216,30 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
_currency!: Currency;
|
|
220
|
+
|
|
219
221
|
/**
|
|
220
222
|
* ISO currency id
|
|
221
223
|
* 标准货币编号
|
|
222
224
|
*/
|
|
223
|
-
|
|
225
|
+
get currency() {
|
|
226
|
+
return this._currency;
|
|
227
|
+
}
|
|
228
|
+
private set currency(value: Currency) {
|
|
229
|
+
this._currency = value;
|
|
230
|
+
}
|
|
224
231
|
|
|
232
|
+
_culture!: string;
|
|
225
233
|
/**
|
|
226
234
|
* ISO culture id, like zh-Hans
|
|
227
235
|
* 标准语言文化编号
|
|
228
236
|
*/
|
|
229
|
-
|
|
237
|
+
get culture() {
|
|
238
|
+
return this._culture;
|
|
239
|
+
}
|
|
240
|
+
private set culture(value: string) {
|
|
241
|
+
this._culture = value;
|
|
242
|
+
}
|
|
230
243
|
|
|
231
244
|
_items: T[] = [];
|
|
232
245
|
|
|
@@ -259,11 +272,17 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
259
272
|
*/
|
|
260
273
|
formData: any;
|
|
261
274
|
|
|
275
|
+
_symbol: string | undefined;
|
|
262
276
|
/**
|
|
263
277
|
* Currency symbol
|
|
264
278
|
* 币种符号
|
|
265
279
|
*/
|
|
266
|
-
|
|
280
|
+
get symbol() {
|
|
281
|
+
return this._symbol;
|
|
282
|
+
}
|
|
283
|
+
private set symbol(value: string | undefined) {
|
|
284
|
+
this._symbol = value;
|
|
285
|
+
}
|
|
267
286
|
|
|
268
287
|
/**
|
|
269
288
|
* Cart identifier
|
|
@@ -369,14 +388,13 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
369
388
|
private readonly storage: IStorage = new WindowStorage()
|
|
370
389
|
) {
|
|
371
390
|
if (Array.isArray(currencyOrState)) {
|
|
372
|
-
this.
|
|
373
|
-
this.
|
|
391
|
+
this.changeCurrency(currencyOrState[0]);
|
|
392
|
+
this.changeCulture(currencyOrState[1]);
|
|
374
393
|
} else {
|
|
375
394
|
this.setCartData(currencyOrState);
|
|
376
|
-
this.
|
|
377
|
-
this.
|
|
395
|
+
this.changeCurrency(currencyOrState.currency);
|
|
396
|
+
this.changeCulture(currencyOrState.culture);
|
|
378
397
|
}
|
|
379
|
-
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
380
398
|
}
|
|
381
399
|
|
|
382
400
|
private setCartData(state: ShoppingCartData<T> | undefined) {
|
|
@@ -420,6 +438,23 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
420
438
|
this.prices[id] = price;
|
|
421
439
|
}
|
|
422
440
|
|
|
441
|
+
/**
|
|
442
|
+
* Change currency
|
|
443
|
+
* @param currency Currency
|
|
444
|
+
*/
|
|
445
|
+
changeCurrency(currency: Currency) {
|
|
446
|
+
this.currency = currency;
|
|
447
|
+
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Change culture
|
|
452
|
+
* @param culture Culture
|
|
453
|
+
*/
|
|
454
|
+
changeCulture(culture: string) {
|
|
455
|
+
this.culture = culture;
|
|
456
|
+
}
|
|
457
|
+
|
|
423
458
|
/**
|
|
424
459
|
* Clear storage
|
|
425
460
|
* @param keepOwner Keep owner data
|
|
@@ -464,10 +499,21 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
464
499
|
}
|
|
465
500
|
|
|
466
501
|
/**
|
|
467
|
-
* Reset
|
|
502
|
+
* Reset currency and culture
|
|
503
|
+
* @param currency New currency
|
|
504
|
+
* @param culture New culture
|
|
505
|
+
*/
|
|
506
|
+
reset(currency: Currency, culture: string) {
|
|
507
|
+
this.clear(true);
|
|
508
|
+
this.changeCurrency(currency);
|
|
509
|
+
this.changeCulture(culture);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Reset item
|
|
468
514
|
* @param item Shopping cart item
|
|
469
515
|
*/
|
|
470
|
-
|
|
516
|
+
resetItem(item: ShoppingCartItem) {
|
|
471
517
|
item.discount = 0;
|
|
472
518
|
item.currentPrice = undefined;
|
|
473
519
|
item.promotions = [];
|