@omnic/widget-locations 0.0.0-dev-20230929004158
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/@types/global.d.ts +35 -0
- package/@types/react-range-slider-input.d.ts +1 -0
- package/@types/svg.d.ts +4 -0
- package/README.md +287 -0
- package/dist/lib/api/client.d.ts +1 -0
- package/dist/lib/components/Aside/Aside.d.ts +8 -0
- package/dist/lib/components/Aside/index.d.ts +1 -0
- package/dist/lib/components/AsyncSelect/AsyncSelect.d.ts +10 -0
- package/dist/lib/components/AsyncSelect/index.d.ts +1 -0
- package/dist/lib/components/Button/Button.d.ts +13 -0
- package/dist/lib/components/Button/index.d.ts +1 -0
- package/dist/lib/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/lib/components/Checkbox/index.d.ts +1 -0
- package/dist/lib/components/CheckboxGroup/CheckboxGroup.d.ts +10 -0
- package/dist/lib/components/CheckboxGroup/index.d.ts +1 -0
- package/dist/lib/components/Chip/Chip.d.ts +8 -0
- package/dist/lib/components/Chip/index.d.ts +1 -0
- package/dist/lib/components/CloseButton/CloseButton.d.ts +6 -0
- package/dist/lib/components/CloseButton/index.d.ts +1 -0
- package/dist/lib/components/CourierBalloon/CourierBalloon.d.ts +12 -0
- package/dist/lib/components/CourierBalloon/index.d.ts +1 -0
- package/dist/lib/components/CourierDetailsModal/CourierDetailsModal.d.ts +10 -0
- package/dist/lib/components/CourierDetailsModal/index.d.ts +1 -0
- package/dist/lib/components/CourierDetailsView/CourierDetailsView.d.ts +16 -0
- package/dist/lib/components/CourierDetailsView/CourierDetailsView.utils.d.ts +20 -0
- package/dist/lib/components/CourierDetailsView/index.d.ts +2 -0
- package/dist/lib/components/CurrentLocation/CurrentLocation.d.ts +6 -0
- package/dist/lib/components/CurrentLocation/index.d.ts +1 -0
- package/dist/lib/components/Header/Header.d.ts +6 -0
- package/dist/lib/components/Header/LogoContainer.d.ts +2 -0
- package/dist/lib/components/Header/index.d.ts +1 -0
- package/dist/lib/components/Hr/Hr.d.ts +4 -0
- package/dist/lib/components/Hr/index.d.ts +1 -0
- package/dist/lib/components/Input/Input.d.ts +11 -0
- package/dist/lib/components/Input/index.d.ts +1 -0
- package/dist/lib/components/Layout/Layout.d.ts +6 -0
- package/dist/lib/components/Layout/index.d.ts +1 -0
- package/dist/lib/components/LocationAside/LocationAside.d.ts +4 -0
- package/dist/lib/components/LocationAside/index.d.ts +1 -0
- package/dist/lib/components/LocationBalloon/LocationBalloon.d.ts +10 -0
- package/dist/lib/components/LocationBalloon/index.d.ts +1 -0
- package/dist/lib/components/LocationDetailsModal/LocationDetailsModal.d.ts +10 -0
- package/dist/lib/components/LocationDetailsModal/index.d.ts +1 -0
- package/dist/lib/components/LocationSelector/CourierDeliverySelectorContainer.d.ts +6 -0
- package/dist/lib/components/LocationSelector/LocationSelector.d.ts +6 -0
- package/dist/lib/components/LocationSelector/LocationSelector.utils.d.ts +1 -0
- package/dist/lib/components/LocationSelector/SelfPickupSelectorContainer.d.ts +9 -0
- package/dist/lib/components/LocationSelector/index.d.ts +1 -0
- package/dist/lib/components/LocationView/LocationView.d.ts +15 -0
- package/dist/lib/components/LocationView/index.d.ts +1 -0
- package/dist/lib/components/MapContainer/DetailsModalContainer.d.ts +2 -0
- package/dist/lib/components/MapContainer/FilterButton.d.ts +2 -0
- package/dist/lib/components/MapContainer/MapContainer.d.ts +7 -0
- package/dist/lib/components/MapContainer/index.d.ts +1 -0
- package/dist/lib/components/MapGoogle/Clusters.d.ts +13 -0
- package/dist/lib/components/MapGoogle/ClustersContainer.d.ts +10 -0
- package/dist/lib/components/MapGoogle/CourierPoint.d.ts +10 -0
- package/dist/lib/components/MapGoogle/MapContainer.d.ts +11 -0
- package/dist/lib/components/MapGoogle/MapGoogle.constants.d.ts +4 -0
- package/dist/lib/components/MapGoogle/MapGoogle.d.ts +4 -0
- package/dist/lib/components/MapGoogle/MapGoogle.hooks.d.ts +5 -0
- package/dist/lib/components/MapGoogle/MapGoogle.utils.d.ts +2 -0
- package/dist/lib/components/MapGoogle/Point.d.ts +13 -0
- package/dist/lib/components/MapGoogle/PointSheet.d.ts +11 -0
- package/dist/lib/components/MapGoogle/index.d.ts +1 -0
- package/dist/lib/components/MapYandex/MapYandex.constants.d.ts +17 -0
- package/dist/lib/components/MapYandex/MapYandex.d.ts +4 -0
- package/dist/lib/components/MapYandex/MapYandex.utils.d.ts +25 -0
- package/dist/lib/components/MapYandex/index.d.ts +1 -0
- package/dist/lib/components/Overlay/Overlay.d.ts +7 -0
- package/dist/lib/components/Overlay/index.d.ts +1 -0
- package/dist/lib/components/Radio/Radio.d.ts +8 -0
- package/dist/lib/components/Radio/index.d.ts +1 -0
- package/dist/lib/components/RadioGroup/RadioGroup.d.ts +10 -0
- package/dist/lib/components/RadioGroup/index.d.ts +1 -0
- package/dist/lib/components/RangeSlider/RangeSlider.d.ts +7 -0
- package/dist/lib/components/RangeSlider/index.d.ts +1 -0
- package/dist/lib/components/Sidebar/HeaderContainer.d.ts +2 -0
- package/dist/lib/components/Sidebar/ReceiveFilterContainer.d.ts +8 -0
- package/dist/lib/components/Sidebar/SendFilterContainer.d.ts +8 -0
- package/dist/lib/components/Sidebar/Sidebar.d.ts +6 -0
- package/dist/lib/components/Sidebar/TypeFilterContainer.d.ts +8 -0
- package/dist/lib/components/Sidebar/index.d.ts +1 -0
- package/dist/lib/components/Spinner/Spinner.d.ts +1 -0
- package/dist/lib/components/Spinner/index.d.ts +1 -0
- package/dist/lib/components/TextArea/TextArea.d.ts +7 -0
- package/dist/lib/components/TextArea/index.d.ts +1 -0
- package/dist/lib/components/TimeRangeSlider/TimeRangeSlider.d.ts +9 -0
- package/dist/lib/components/TimeRangeSlider/index.d.ts +1 -0
- package/dist/lib/components/TypeFilter/TypeFilter.d.ts +9 -0
- package/dist/lib/components/TypeFilter/index.d.ts +1 -0
- package/dist/lib/components/WorkingHoursFilter/WorkingHoursFilter.d.ts +9 -0
- package/dist/lib/components/WorkingHoursFilter/index.d.ts +1 -0
- package/dist/lib/constants/config.d.ts +2 -0
- package/dist/lib/constants/http.d.ts +8 -0
- package/dist/lib/constants/limits.d.ts +1 -0
- package/dist/lib/constants/map.d.ts +11 -0
- package/dist/lib/constants/ui.d.ts +1 -0
- package/dist/lib/constants/widget.d.ts +1 -0
- package/dist/lib/context/config.d.ts +4 -0
- package/dist/lib/geocode.d.ts +1 -0
- package/dist/lib/hooks/index.d.ts +9 -0
- package/dist/lib/hooks/useInitializeAxios.d.ts +2 -0
- package/dist/lib/hooks/useInputProps.d.ts +6 -0
- package/dist/lib/hooks/useMapRenderer.d.ts +3 -0
- package/dist/lib/hooks/useMediaQuery.d.ts +1 -0
- package/dist/lib/hooks/useMediaWidthDown.d.ts +3 -0
- package/dist/lib/hooks/useMergedRef.d.ts +2 -0
- package/dist/lib/hooks/usePointsLoader.d.ts +1 -0
- package/dist/lib/hooks/useWidgetConfig.d.ts +2 -0
- package/dist/lib/i18n.d.ts +1 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/main.d.ts +0 -0
- package/dist/lib/services/address.d.ts +36 -0
- package/dist/lib/services/points.d.ts +12 -0
- package/dist/lib/stores/courierPoint.d.ts +9 -0
- package/dist/lib/stores/filters.d.ts +8 -0
- package/dist/lib/stores/locationAside.d.ts +8 -0
- package/dist/lib/stores/map.d.ts +21 -0
- package/dist/lib/stores/points.d.ts +15 -0
- package/dist/lib/stores/selectedPlace.d.ts +9 -0
- package/dist/lib/stores/selectedPoint.d.ts +10 -0
- package/dist/lib/stores/sidebar.d.ts +8 -0
- package/dist/lib/style.css +1 -0
- package/dist/lib/types/cities.d.ts +11 -0
- package/dist/lib/types/config.d.ts +69 -0
- package/dist/lib/types/countries.d.ts +5 -0
- package/dist/lib/types/filters.d.ts +34 -0
- package/dist/lib/types/i18n.d.ts +1 -0
- package/dist/lib/types/map.d.ts +10 -0
- package/dist/lib/types/points.d.ts +59 -0
- package/dist/lib/types/regions.d.ts +5 -0
- package/dist/lib/utils/createPointsIterator.d.ts +3 -0
- package/dist/lib/utils/fromHoursMinutesToMinutes.d.ts +2 -0
- package/dist/lib/utils/fromMinutesToHoursMinutes.d.ts +2 -0
- package/dist/lib/utils/getAddressFromLatLng.d.ts +13 -0
- package/dist/lib/utils/getBoundsFromPoint.d.ts +1 -0
- package/dist/lib/utils/getCurrentPosition.d.ts +1 -0
- package/dist/lib/utils/index.d.ts +9 -0
- package/dist/lib/utils/isHttpSuccess.d.ts +2 -0
- package/dist/lib/utils/setWidgetCSSProperty.d.ts +1 -0
- package/dist/lib/utils/stopImmediatePropagation.d.ts +1 -0
- package/dist/lib/views/Widget/LocaleProvider.d.ts +8 -0
- package/dist/lib/views/Widget/PreloaderOverlay.d.ts +2 -0
- package/dist/lib/views/Widget/Widget.d.ts +8 -0
- package/dist/lib/views/Widget/Widget.hooks.d.ts +9 -0
- package/dist/lib/views/Widget/WidgetContainer.d.ts +6 -0
- package/dist/lib/views/Widget/index.d.ts +1 -0
- package/dist/lib/widget.es.js +17013 -0
- package/dist/lib/widget.umd.js +102 -0
- package/package.json +88 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WidgetConfig } from "src/types/config";
|
|
2
|
+
|
|
3
|
+
export {};
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
type Primitive = null | number | string | boolean | undefined;
|
|
7
|
+
|
|
8
|
+
type Nullable<T> = null | undefined | T;
|
|
9
|
+
|
|
10
|
+
type Dictionary<T> = Record<string, T>;
|
|
11
|
+
|
|
12
|
+
interface HttpResponse<T> {
|
|
13
|
+
data: T;
|
|
14
|
+
success: boolean;
|
|
15
|
+
status_code: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ResponseList<T> {
|
|
19
|
+
results: T[];
|
|
20
|
+
count: number;
|
|
21
|
+
num_pages: number;
|
|
22
|
+
current_page: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Coordinates = [number, number];
|
|
26
|
+
type Size = [number, number];
|
|
27
|
+
|
|
28
|
+
type Bounds = [Coordinates, Coordinates];
|
|
29
|
+
|
|
30
|
+
declare const ymaps: typeof ymaps;
|
|
31
|
+
|
|
32
|
+
interface Window {
|
|
33
|
+
OMNIC_WIDGET_LOCATIONS_CONFIG?: WidgetConfig;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "react-range-slider-input";
|
package/@types/svg.d.ts
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# OMNIC Widget Locations
|
|
2
|
+
|
|
3
|
+
# USAGE
|
|
4
|
+
|
|
5
|
+
## Integration in `standalone` mode
|
|
6
|
+
|
|
7
|
+
When build in `standalone` mode the widget exposes `window.OMNIC_WIDGET_LOCATIONS_CONFIG` config object.
|
|
8
|
+
Add script tag to your page and pass the config object to the widget like this:
|
|
9
|
+
|
|
10
|
+
```html
|
|
11
|
+
<script>
|
|
12
|
+
window.OMNIC_WIDGET_LOCATIONS_CONFIG = {
|
|
13
|
+
INN: "INN",
|
|
14
|
+
locale: "en",
|
|
15
|
+
map: {
|
|
16
|
+
provider: "google",
|
|
17
|
+
center: [55.75, 37.57],
|
|
18
|
+
},
|
|
19
|
+
onPointClick: (point: CallbackPoint) => {
|
|
20
|
+
// TODO: process point click
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The `onPointClick` callback will be called when user clicks on a point on the map. The `point` object has the following structure:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
type Coordinates = [number, number];
|
|
30
|
+
|
|
31
|
+
interface Country {
|
|
32
|
+
uid: string;
|
|
33
|
+
name: string;
|
|
34
|
+
abbreviation: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Region {
|
|
38
|
+
uid: string;
|
|
39
|
+
name: string;
|
|
40
|
+
national_id: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface City {
|
|
44
|
+
uid: string;
|
|
45
|
+
name: string;
|
|
46
|
+
region: Region;
|
|
47
|
+
latitude: number;
|
|
48
|
+
country: Country;
|
|
49
|
+
longitude: number;
|
|
50
|
+
national_id: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Location {
|
|
54
|
+
city: City;
|
|
55
|
+
house: string;
|
|
56
|
+
block: string;
|
|
57
|
+
street: string;
|
|
58
|
+
office: string;
|
|
59
|
+
region: Region;
|
|
60
|
+
floor: unknown;
|
|
61
|
+
latitude: number;
|
|
62
|
+
country: Country;
|
|
63
|
+
longitude: number;
|
|
64
|
+
postal_index: string;
|
|
65
|
+
full_address: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface LocationPoint {
|
|
69
|
+
uid: string;
|
|
70
|
+
name: string;
|
|
71
|
+
code: string;
|
|
72
|
+
type: number;
|
|
73
|
+
brand: string;
|
|
74
|
+
status: number;
|
|
75
|
+
images: string[];
|
|
76
|
+
schedule: string[];
|
|
77
|
+
max_length: number;
|
|
78
|
+
max_weight: number;
|
|
79
|
+
is_pickup: boolean;
|
|
80
|
+
location: Location;
|
|
81
|
+
description: string;
|
|
82
|
+
is_favorite: boolean;
|
|
83
|
+
pay_by_cash: boolean;
|
|
84
|
+
pay_by_card: boolean;
|
|
85
|
+
is_delivery: boolean;
|
|
86
|
+
near_station?: string;
|
|
87
|
+
location_name?: string;
|
|
88
|
+
is_check_order: boolean;
|
|
89
|
+
round_the_clock: boolean;
|
|
90
|
+
is_dressing_room: boolean;
|
|
91
|
+
near_metro_station?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface NormalizeAddressResponseData {
|
|
95
|
+
country_name: string;
|
|
96
|
+
country_code: string;
|
|
97
|
+
region: string;
|
|
98
|
+
city: string;
|
|
99
|
+
latitude: number;
|
|
100
|
+
longitude: number;
|
|
101
|
+
street: string;
|
|
102
|
+
house: string;
|
|
103
|
+
block: string;
|
|
104
|
+
office: string;
|
|
105
|
+
postal_index: string;
|
|
106
|
+
address: string;
|
|
107
|
+
address_full: string;
|
|
108
|
+
city_place_id: string;
|
|
109
|
+
region_place_id: string;
|
|
110
|
+
place_id: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface CourierPoint {
|
|
114
|
+
coords: Coordinates;
|
|
115
|
+
address: Nullable<NormalizeAddressResponseData>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface CourierDeliveryPoint extends CourierPoint {
|
|
119
|
+
comment: string;
|
|
120
|
+
pay_by_cash: boolean;
|
|
121
|
+
pay_by_card: boolean;
|
|
122
|
+
delivery_time: string;
|
|
123
|
+
apartment_number: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// THIS IS THE TYPE OF THE CALLBACK POINT
|
|
127
|
+
type CallbackPoint = LocationPoint | CourierDeliveryPoint;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Then `OMNIC_WIDGET_LOCATIONS_CONFIG` has the following structure:
|
|
131
|
+
|
|
132
|
+
| Property | Type | Description |
|
|
133
|
+
| ------------------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| INN | string | INN of the company that uses the widget |
|
|
135
|
+
| font | string | Font family to use |
|
|
136
|
+
| radius | number | Border radius of buttons |
|
|
137
|
+
| locale | string | Locale of the widget. Currently supported: `en`, `ru` |
|
|
138
|
+
| country | string | Country code in ISO 3166-1 Alpha-2 format |
|
|
139
|
+
| palette | object | Palette config object |
|
|
140
|
+
| palette.primary | string | Primary color of the widget. Example: `#ff0000` |
|
|
141
|
+
| palette.primary-dark | string | Darker version of the primary color. Example: `#cc0000` |
|
|
142
|
+
| map | object | Map config object. See below for details |
|
|
143
|
+
| map.provider | string | Map provider. Currently supported: `google`, `yandex` |
|
|
144
|
+
| map.center | number[] | Coordinates of the map center. Example: `[55.75, 37.57]` |
|
|
145
|
+
| map.initialZoom | number | Initial zoom level of the map. Example: `10` |
|
|
146
|
+
| hideLogo | boolean | Whether to hide the logo |
|
|
147
|
+
| startScreen | string | Start screen of the widget. Currently supported: `map`, `selector` |
|
|
148
|
+
| disableCourierDelivery | boolean | Whether to disable courier delivery option |
|
|
149
|
+
| inputs | WidgetInputs | Control over widget inputs |
|
|
150
|
+
| handlers | WidgetHandlers | Handlers config object |
|
|
151
|
+
| hideMapUI | boolean | Whether to hide map UI elements, like trademarks, terms of use and etc. |
|
|
152
|
+
| hideCloseButtonOnLocationScreen | boolean | Whether to hide close button on location screen |
|
|
153
|
+
| onPointClick | function | Callback that will be called when user clicks on a point on the map. |
|
|
154
|
+
| onLocationSelect | function | Callback that will be called when user selects a location Callback will be called with `google.maps.places.PlaceResult` argument |
|
|
155
|
+
| onCloseLocationSelector | function | Callback that will be called when user closes location selector |
|
|
156
|
+
|
|
157
|
+
`WidgetInputs` type has the following structure:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface ForwardedInputElement extends Pick<HTMLInputElement, "focus" | "blur"> {
|
|
161
|
+
setValue: (value: string) => void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface InputConfig {
|
|
165
|
+
name: string;
|
|
166
|
+
ref: RefObject<ForwardedInputElement>;
|
|
167
|
+
onClick?: (name: string) => void;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface WidgetInputs {
|
|
171
|
+
/**
|
|
172
|
+
Widget Map address input
|
|
173
|
+
*/
|
|
174
|
+
address: InputConfig;
|
|
175
|
+
/**
|
|
176
|
+
* Widget city input
|
|
177
|
+
*/
|
|
178
|
+
city: InputConfig;
|
|
179
|
+
/**
|
|
180
|
+
* Courier delivery apartment input
|
|
181
|
+
*/
|
|
182
|
+
apartment: InputConfig;
|
|
183
|
+
/**
|
|
184
|
+
* Courier delivery comment input
|
|
185
|
+
*/
|
|
186
|
+
comment: InputConfig;
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`WidgetHandlers` type has the following structure:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
interface LocationSelectorElement {
|
|
194
|
+
open: () => void;
|
|
195
|
+
close: () => void;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface WidgetHandlers {
|
|
199
|
+
locationSelector: RefObject<LocationSelectorElement>;
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**NOTE:** when using screen keyboard do not forget to call `focus()` method for `address` and `city` inputs, so that autocomplete will appear.
|
|
204
|
+
|
|
205
|
+
Include `styles.css` and `widget.umd.js` in your page:
|
|
206
|
+
|
|
207
|
+
```html
|
|
208
|
+
<link rel="stylesheet" href="styles.css" />
|
|
209
|
+
<script src="widget.umd.js"></script>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
After that you can create a div block with id `@omnic/widget-locations` and widget will be rendered there:
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<div id="@omnic/widget-locations"></div>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Integration in `React` mode
|
|
219
|
+
|
|
220
|
+
When build in `React` mode the widget exposes `Widget` component. First install a package:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npm install @omnic/widget-locations
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Then import it and use like this:
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import React from "react";
|
|
230
|
+
|
|
231
|
+
import { Widget } from "@omnic/widget-locations";
|
|
232
|
+
import type { LocationPoint, CourierPoint } from "@omnic/widget-locations";
|
|
233
|
+
|
|
234
|
+
import "@omnic/widget-locations/dist/lib/style.css";
|
|
235
|
+
|
|
236
|
+
const App = () => {
|
|
237
|
+
const onPointClick = (point: LocationPoint | CourierPoint) => {
|
|
238
|
+
// TODO: process point click
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div id="@omnic/widget-locations">
|
|
243
|
+
<Widget /> {/* 👈 don't forget to provide `config` props */}
|
|
244
|
+
</div>
|
|
245
|
+
);
|
|
246
|
+
};
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`Widget` component has the following props:
|
|
250
|
+
|
|
251
|
+
| Property | Type | Description |
|
|
252
|
+
| --------------- | ------ | -------------------------------------------------------------- |
|
|
253
|
+
| config | object | Config object. See above for details |
|
|
254
|
+
| options | object | Options object |
|
|
255
|
+
| options.baseURL | string | Base URL of the widget API. Example: `https://widget.omnic.sh` |
|
|
256
|
+
|
|
257
|
+
DON'T FORGET to wrap the widget in a div with id `@omnic/widget-locations`, so that all css styles will be applied correctly.
|
|
258
|
+
|
|
259
|
+
# DEVELOPMENT
|
|
260
|
+
|
|
261
|
+
## Project setup
|
|
262
|
+
|
|
263
|
+
Install all dependencies:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
$ npm install
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Then build it in `lib` mode:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
$ npm run build:lib
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
or `standalone` mode:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
$ npm run build:app
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Use `npm run dev` to start local development server.
|
|
282
|
+
|
|
283
|
+
# API
|
|
284
|
+
|
|
285
|
+
All API and components are exposed in `src/index.ts` file.
|
|
286
|
+
|
|
287
|
+
`src/main.tsx` file is responsible for rendering the widget in `standalone` mode or in development mode.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const axiosClient: import("axios").AxiosInstance;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Aside";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { GroupBase } from "react-select";
|
|
3
|
+
import type { AsyncProps } from "react-select/async";
|
|
4
|
+
type AsyncSelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = AsyncProps<Option, IsMulti, Group> & {
|
|
5
|
+
label?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
customDropdownIcon?: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const AsyncSelect: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ label, className, customDropdownIcon, ...props }: AsyncSelectProps<Option, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AsyncSelect";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FC, ButtonHTMLAttributes, AnchorHTMLAttributes } from "react";
|
|
2
|
+
interface ButtonBaseProps {
|
|
3
|
+
variant?: "primary" | "secondary";
|
|
4
|
+
}
|
|
5
|
+
type ButtonAsButton = {
|
|
6
|
+
as?: "button";
|
|
7
|
+
} & ButtonHTMLAttributes<HTMLButtonElement> & ButtonBaseProps;
|
|
8
|
+
type ButtonAsLink = {
|
|
9
|
+
as?: "link";
|
|
10
|
+
} & AnchorHTMLAttributes<HTMLAnchorElement> & ButtonBaseProps;
|
|
11
|
+
type ButtonProps = ButtonAsLink | ButtonAsButton;
|
|
12
|
+
export declare const Button: FC<ButtonProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Button';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Checkbox";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { HTMLAttributes } from "react";
|
|
3
|
+
import type { RadioProps } from "../Radio";
|
|
4
|
+
export type CheckboxGroupProps<T> = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
5
|
+
value?: T;
|
|
6
|
+
label?: string;
|
|
7
|
+
children: React.ReactElement<RadioProps<T>>[];
|
|
8
|
+
onChange?: (value: T) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const CheckboxGroup: <T extends Dictionary<unknown>>({ label, value, onChange, children, className, ...props }: CheckboxGroupProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CheckboxGroup";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Chip";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CloseButton";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { CourierPoint } from '../../types/points';
|
|
3
|
+
type CourierBalloonProps = Partial<CourierPoint> & {
|
|
4
|
+
SSR?: boolean;
|
|
5
|
+
variant: "error" | "default";
|
|
6
|
+
hasCloseButton?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
onDetails?: () => void;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const CourierBalloon: FC<CourierBalloonProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CourierBalloon";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { CourierDeliveryPoint, CourierPoint } from '../../types/points';
|
|
3
|
+
interface CourierDetailsModalProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
location: CourierPoint;
|
|
7
|
+
onSubmit?: (point: CourierDeliveryPoint) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const CourierDetailsModal: FC<CourierDetailsModalProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CourierDetailsModal";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { CourierDeliveryPoint, CourierPoint } from '../../types/points';
|
|
3
|
+
export interface CourierDetailsViewClasses {
|
|
4
|
+
header?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
}
|
|
7
|
+
interface CourierDetailsViewProps {
|
|
8
|
+
location: CourierPoint;
|
|
9
|
+
hideActions?: boolean;
|
|
10
|
+
classes?: CourierDetailsViewClasses;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
onChange?: (location: CourierDeliveryPoint) => void;
|
|
13
|
+
onSubmit?: (location: CourierDeliveryPoint) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const MemoizedCourierDetailsView: import("react").NamedExoticComponent<CourierDetailsViewProps>;
|
|
16
|
+
export { MemoizedCourierDetailsView as CourierDetailsView };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Reducer } from "react";
|
|
2
|
+
import type { CourierDeliveryPoint } from '../../types/points';
|
|
3
|
+
type ChangeHandler = (location: CourierDeliveryPoint) => void;
|
|
4
|
+
interface ReducerParams {
|
|
5
|
+
set?: ChangeHandler;
|
|
6
|
+
}
|
|
7
|
+
export type CourierDetailsModalState = CourierDeliveryPoint;
|
|
8
|
+
export type CourierDetailsModalAction = {
|
|
9
|
+
type: "SET_COMMENT";
|
|
10
|
+
payload: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "SET_DELIVERY_TIME";
|
|
13
|
+
payload: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "SET_APARTMENT_NUMBER";
|
|
16
|
+
payload: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const createReducer: ({ set }: ReducerParams) => Reducer<CourierDetailsModalState, CourierDetailsModalAction>;
|
|
19
|
+
export declare const getStateValid: (state: CourierDetailsModalState) => boolean;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CurrentLocation";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Header";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Hr";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
|
+
import type { ForwardedInputElement } from '../../types/config';
|
|
3
|
+
interface InputProps extends React.AllHTMLAttributes<HTMLInputElement> {
|
|
4
|
+
label?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
startAdornment?: ReactNode;
|
|
7
|
+
endAdornment?: ReactNode;
|
|
8
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<ForwardedInputElement>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Input";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Layout";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LocationSelectorElement } from '../../types/config';
|
|
3
|
+
declare const MemoLocationAside: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<import("react").RefAttributes<LocationSelectorElement>>>;
|
|
4
|
+
export { MemoLocationAside as LocationAside };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LocationAside";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { LocationPoint } from '../../types/points';
|
|
3
|
+
type LocationBalloonProps = Partial<LocationPoint> & {
|
|
4
|
+
SSR?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
onSubmit?: () => void;
|
|
7
|
+
onDetails?: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare const LocationBalloon: FC<LocationBalloonProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LocationBalloon";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { LocationPoint } from '../../types/points';
|
|
3
|
+
interface LocationDetailsModalProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
location: LocationPoint;
|
|
7
|
+
onSubmit?: (point: LocationPoint) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const LocationDetailsModal: FC<LocationDetailsModalProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LocationDetailsModal";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const loadLocations: (value: string) => Promise<import("../..").LocationPoint[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { LocationPoint } from '../../types/points';
|
|
3
|
+
interface SelfPickupSelectorContainerProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
value?: null | LocationPoint;
|
|
6
|
+
onChange?: (value: null | LocationPoint) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const SelfPickupSelectorContainer: FC<SelfPickupSelectorContainerProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./LocationSelector";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { LocationPoint } from '../../types/points';
|
|
3
|
+
export interface LocationViewClasses {
|
|
4
|
+
header?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
}
|
|
7
|
+
interface LocationViewProps {
|
|
8
|
+
location: LocationPoint;
|
|
9
|
+
hideActions?: boolean;
|
|
10
|
+
classes?: LocationViewClasses;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
onSubmit?: () => void;
|
|
13
|
+
}
|
|
14
|
+
declare const MemoizedLocationView: import("react").NamedExoticComponent<LocationViewProps>;
|
|
15
|
+
export { MemoizedLocationView as LocationView };
|