@cdek-it/widget 3.8.0
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/README.md +10 -0
- package/dist/cdek-widget.es.d.ts +293 -0
- package/dist/cdek-widget.es.js +18346 -0
- package/dist/cdek-widget.umd.js +2 -0
- package/dist/service.php +195 -0
- package/package.json +70 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Виджет ПВЗ
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://www.jsdelivr.com/package/gh/cdek-it/widget)
|
|
5
|
+
[](https://github.com/cdek-it/widget/releases)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[Документация по виджету](docs/ru/INTRO.md)
|
|
9
|
+
|
|
10
|
+
[English version of documentation](docs/en/INTRO.md)
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { AnyObject } from 'yup';
|
|
2
|
+
import { InferType } from 'yup';
|
|
3
|
+
import { LngLat } from '@yandex/ymaps3-types/common/types';
|
|
4
|
+
import { Maybe } from 'yup';
|
|
5
|
+
import { ObjectSchema } from 'yup';
|
|
6
|
+
|
|
7
|
+
declare const enum CdekDeliveryType {
|
|
8
|
+
DOOR_DOOR = 1,
|
|
9
|
+
DOOR_OFFICE = 2,
|
|
10
|
+
OFFICE_DOOR = 3,
|
|
11
|
+
OFFICE_OFFICE = 4,
|
|
12
|
+
DOOR_PICKUP = 6,
|
|
13
|
+
OFFICE_PICKUP = 7,
|
|
14
|
+
PICKUP_DOOR = 8,
|
|
15
|
+
PICKUP_OFFICE = 9,
|
|
16
|
+
PICKUP_PICKUP = 10
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const enum DeliveryMode {
|
|
20
|
+
DOOR = "door",
|
|
21
|
+
OFFICE = "office"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare interface iGeocoderComponent {
|
|
25
|
+
name: string;
|
|
26
|
+
kind: YandexGeocoderKind;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare interface iGeocoderMember {
|
|
30
|
+
name: string;
|
|
31
|
+
position: number[];
|
|
32
|
+
kind: YandexGeocoderKind;
|
|
33
|
+
precision: YandexGeocoderPrecision;
|
|
34
|
+
formatted: string;
|
|
35
|
+
country_code: string;
|
|
36
|
+
postal_code: string | null;
|
|
37
|
+
components: iGeocoderComponent[];
|
|
38
|
+
bounds: {
|
|
39
|
+
lower: number[];
|
|
40
|
+
upper: number[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare interface iOffice {
|
|
45
|
+
city_code: number;
|
|
46
|
+
city: string;
|
|
47
|
+
region: string;
|
|
48
|
+
type: OfficeType;
|
|
49
|
+
country_code: string;
|
|
50
|
+
postal_code: string;
|
|
51
|
+
have_cashless: boolean;
|
|
52
|
+
have_cash: boolean;
|
|
53
|
+
allowed_cod: boolean;
|
|
54
|
+
is_dressing_room: boolean;
|
|
55
|
+
code: string;
|
|
56
|
+
name: string;
|
|
57
|
+
address: string;
|
|
58
|
+
work_time: string;
|
|
59
|
+
location: LngLat;
|
|
60
|
+
dimensions: Array<{
|
|
61
|
+
depth: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
}> | null;
|
|
65
|
+
weight_min: number;
|
|
66
|
+
weight_max: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare interface iParcel {
|
|
70
|
+
length: number;
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
weight: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare interface iTariff {
|
|
77
|
+
tariff_code: number;
|
|
78
|
+
tariff_name: string;
|
|
79
|
+
tariff_description: string;
|
|
80
|
+
delivery_mode: CdekDeliveryType;
|
|
81
|
+
period_min: number;
|
|
82
|
+
period_max: number;
|
|
83
|
+
delivery_sum: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare interface iWidget extends InferType<typeof widgetSchema> {
|
|
87
|
+
goods: iParcel[];
|
|
88
|
+
offices: iOffice[] | null;
|
|
89
|
+
defaultLocation: string | LngLat;
|
|
90
|
+
lang: Lang;
|
|
91
|
+
onCalculate?: tCalculateFunction;
|
|
92
|
+
onReady?: tReadyFunction;
|
|
93
|
+
onChoose?: tChooseFunction;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare enum Lang {
|
|
97
|
+
RUS = "rus",
|
|
98
|
+
ENG = "eng"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare enum OfficeType {
|
|
102
|
+
ALL = "ALL",
|
|
103
|
+
OFFICE = "PVZ",
|
|
104
|
+
PICKUP = "POSTAMAT"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare type tCalculateFunction = (prices: {
|
|
108
|
+
office: iTariff[];
|
|
109
|
+
door: iTariff[];
|
|
110
|
+
pickup: iTariff[];
|
|
111
|
+
}, address: {
|
|
112
|
+
code?: number;
|
|
113
|
+
address?: string;
|
|
114
|
+
}) => void;
|
|
115
|
+
|
|
116
|
+
declare type tChooseFunction = (type: DeliveryMode, tariff: iTariff | null, target: iOffice | iGeocoderMember) => void;
|
|
117
|
+
|
|
118
|
+
declare type tReadyFunction = () => void;
|
|
119
|
+
|
|
120
|
+
declare class Widget {
|
|
121
|
+
private readonly params;
|
|
122
|
+
private readonly yandexApi;
|
|
123
|
+
private readonly cdekApi;
|
|
124
|
+
private readonly app;
|
|
125
|
+
private readonly div;
|
|
126
|
+
private readonly customDiv;
|
|
127
|
+
constructor(input: iWidget);
|
|
128
|
+
updateOffices(offices: iOffice[]): Promise<void>;
|
|
129
|
+
updateOfficesRaw(officesRaw: any): Promise<void>;
|
|
130
|
+
updateLocation(location: any): Promise<void>;
|
|
131
|
+
updateTariff(tariff: iTariff): Promise<void>;
|
|
132
|
+
clearSelection(): void;
|
|
133
|
+
destroy(): void;
|
|
134
|
+
open(): void;
|
|
135
|
+
close(): void;
|
|
136
|
+
addParcel(parcel: iParcel | iParcel[]): void;
|
|
137
|
+
getParcels(): {
|
|
138
|
+
length: number;
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
weight: number;
|
|
142
|
+
}[];
|
|
143
|
+
resetParcels(): void;
|
|
144
|
+
private fixBounds;
|
|
145
|
+
private init;
|
|
146
|
+
}
|
|
147
|
+
export default Widget;
|
|
148
|
+
|
|
149
|
+
declare const widgetSchema: ObjectSchema<{
|
|
150
|
+
apiKey: string;
|
|
151
|
+
root: string;
|
|
152
|
+
sender: boolean;
|
|
153
|
+
canChoose: boolean;
|
|
154
|
+
popup: boolean;
|
|
155
|
+
servicePath: string;
|
|
156
|
+
hideFilters: {
|
|
157
|
+
have_cashless: boolean;
|
|
158
|
+
have_cash: boolean;
|
|
159
|
+
is_dressing_room: boolean;
|
|
160
|
+
type: boolean;
|
|
161
|
+
};
|
|
162
|
+
forceFilters: {
|
|
163
|
+
have_cashless: boolean | null;
|
|
164
|
+
have_cash: boolean | null;
|
|
165
|
+
is_dressing_room: boolean | null;
|
|
166
|
+
type: OfficeType | null;
|
|
167
|
+
allowed_cod: boolean | null;
|
|
168
|
+
};
|
|
169
|
+
hideDeliveryOptions: {
|
|
170
|
+
door: boolean;
|
|
171
|
+
office: boolean;
|
|
172
|
+
};
|
|
173
|
+
debug: boolean;
|
|
174
|
+
requirePostcode: boolean;
|
|
175
|
+
fixBounds: YandexGeocoderKind.COUNTRY | YandexGeocoderKind.PROVINCE | YandexGeocoderKind.LOCALITY | null;
|
|
176
|
+
offices: any[] | null;
|
|
177
|
+
officesRaw: any[] | null;
|
|
178
|
+
tariff: {
|
|
179
|
+
tariff_code?: number | undefined;
|
|
180
|
+
tariff_name?: string | undefined;
|
|
181
|
+
tariff_description?: string | undefined;
|
|
182
|
+
delivery_mode?: number | undefined;
|
|
183
|
+
period_min?: number | undefined;
|
|
184
|
+
period_max?: number | undefined;
|
|
185
|
+
delivery_sum?: number | undefined;
|
|
186
|
+
} | null;
|
|
187
|
+
goods: {
|
|
188
|
+
width: number;
|
|
189
|
+
length: number;
|
|
190
|
+
height: number;
|
|
191
|
+
weight: number;
|
|
192
|
+
}[];
|
|
193
|
+
from: string | {
|
|
194
|
+
code: number | null;
|
|
195
|
+
postal_code: string | null;
|
|
196
|
+
country_code: string | null;
|
|
197
|
+
city: string | null;
|
|
198
|
+
address: string | null;
|
|
199
|
+
} | null;
|
|
200
|
+
defaultLocation: NonNullable<string | LngLat | undefined>;
|
|
201
|
+
lang: Lang;
|
|
202
|
+
currency: string;
|
|
203
|
+
tariffs: {
|
|
204
|
+
door: any[];
|
|
205
|
+
office: any[];
|
|
206
|
+
pickup: any[];
|
|
207
|
+
};
|
|
208
|
+
onReady: tReadyFunction | undefined;
|
|
209
|
+
onCalculate: tCalculateFunction | undefined;
|
|
210
|
+
onChoose: tChooseFunction | undefined;
|
|
211
|
+
selected: {
|
|
212
|
+
door: string | null;
|
|
213
|
+
office: string | null;
|
|
214
|
+
};
|
|
215
|
+
}, AnyObject, {
|
|
216
|
+
apiKey: any;
|
|
217
|
+
root: "cdek-map";
|
|
218
|
+
sender: false;
|
|
219
|
+
canChoose: true;
|
|
220
|
+
popup: false;
|
|
221
|
+
servicePath: "/service.php";
|
|
222
|
+
hideFilters: {
|
|
223
|
+
have_cashless: false;
|
|
224
|
+
have_cash: false;
|
|
225
|
+
is_dressing_room: false;
|
|
226
|
+
type: false;
|
|
227
|
+
};
|
|
228
|
+
forceFilters: {
|
|
229
|
+
have_cashless: null;
|
|
230
|
+
have_cash: null;
|
|
231
|
+
is_dressing_room: null;
|
|
232
|
+
type: null;
|
|
233
|
+
allowed_cod: null;
|
|
234
|
+
};
|
|
235
|
+
hideDeliveryOptions: {
|
|
236
|
+
office: false;
|
|
237
|
+
door: false;
|
|
238
|
+
};
|
|
239
|
+
debug: false;
|
|
240
|
+
requirePostcode: false;
|
|
241
|
+
fixBounds: null;
|
|
242
|
+
offices: null;
|
|
243
|
+
officesRaw: null;
|
|
244
|
+
tariff: null;
|
|
245
|
+
goods: "d";
|
|
246
|
+
from: undefined;
|
|
247
|
+
defaultLocation: undefined;
|
|
248
|
+
lang: Lang.RUS;
|
|
249
|
+
currency: "RUB";
|
|
250
|
+
tariffs: {
|
|
251
|
+
door: number[];
|
|
252
|
+
office: number[];
|
|
253
|
+
pickup: number[];
|
|
254
|
+
};
|
|
255
|
+
onReady: Maybe<tReadyFunction | undefined>;
|
|
256
|
+
onCalculate: Maybe<tCalculateFunction | undefined>;
|
|
257
|
+
onChoose: Maybe<tChooseFunction | undefined>;
|
|
258
|
+
selected: {
|
|
259
|
+
door: null;
|
|
260
|
+
office: null;
|
|
261
|
+
};
|
|
262
|
+
}, "">;
|
|
263
|
+
|
|
264
|
+
declare const enum YandexGeocoderKind {
|
|
265
|
+
OTHER = "other",
|
|
266
|
+
ENTRANCE = "entrance",
|
|
267
|
+
AIRPORT = "airport",
|
|
268
|
+
VEGETATION = "vegetation",
|
|
269
|
+
ROUTE = "route",
|
|
270
|
+
STATION = "station",
|
|
271
|
+
RAILWAY = "railway_station",
|
|
272
|
+
HYDRO = "hydro",
|
|
273
|
+
REGION = "region",
|
|
274
|
+
COUNTRY = "country",
|
|
275
|
+
PROVINCE = "province",
|
|
276
|
+
AREA = "area",
|
|
277
|
+
LOCALITY = "locality",
|
|
278
|
+
DISTRICT = "district",
|
|
279
|
+
METRO = "metro",
|
|
280
|
+
STREET = "street",
|
|
281
|
+
HOUSE = "house"
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare const enum YandexGeocoderPrecision {
|
|
285
|
+
OTHER = "other",
|
|
286
|
+
STREET = "street",
|
|
287
|
+
RANGE = "range",
|
|
288
|
+
NEAR = "near",
|
|
289
|
+
NUMBER = "number",
|
|
290
|
+
EXACT = "exact"
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export { }
|