@shopgate/pwa-common 7.30.0-alpha.7 → 7.30.0-alpha.9
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/App.js +48 -6
- package/action-creators/app/index.js +75 -12
- package/action-creators/app/spec.js +96 -1
- package/action-creators/client/index.js +27 -5
- package/action-creators/client/spec.js +44 -1
- package/action-creators/error/index.js +15 -3
- package/action-creators/index.js +9 -1
- package/action-creators/menu/index.js +23 -4
- package/action-creators/menu/spec.js +37 -1
- package/action-creators/modal/index.js +15 -3
- package/action-creators/modal/spec.js +26 -1
- package/action-creators/page/index.js +24 -4
- package/action-creators/page/spec.js +38 -1
- package/action-creators/router/index.js +48 -7
- package/action-creators/url/index.js +24 -4
- package/action-creators/url/spec.js +45 -1
- package/action-creators/user/index.js +90 -13
- package/action-creators/user/spec.js +186 -2
- package/actions/app/handleDeepLink.js +11 -2
- package/actions/app/handleLink.js +62 -6
- package/actions/app/handlePushNotification.js +32 -4
- package/actions/app/handleUniversalLink.js +11 -2
- package/actions/app/registerLinkEvents.js +24 -3
- package/actions/client/fetchClientInformation.js +26 -2
- package/actions/menu/fetchMenu.js +23 -2
- package/actions/modal/closeModal.js +18 -2
- package/actions/modal/promiseMap.js +3 -1
- package/actions/modal/showModal.js +54 -8
- package/actions/page/fetchPageConfig.js +69 -2
- package/actions/page/getPageConfig.js +6 -2
- package/actions/page/index.js +1 -1
- package/actions/router/historyPop.js +12 -2
- package/actions/router/historyPopToRoute.js +27 -2
- package/actions/router/historyPush.js +12 -2
- package/actions/router/historyRedirect.js +21 -2
- package/actions/router/historyReplace.js +20 -3
- package/actions/router/historyReset.js +11 -2
- package/actions/router/historyResetTo.js +12 -2
- package/actions/router/index.js +17 -1
- package/actions/router/routeDidPop.js +11 -2
- package/actions/router/routeDidPush.js +13 -2
- package/actions/router/routeDidReplace.js +11 -2
- package/actions/router/routeDidReset.js +11 -2
- package/actions/router/routeDidUpdate.js +10 -2
- package/actions/router/routeWillPop.js +11 -2
- package/actions/router/routeWillPush.js +13 -2
- package/actions/router/routeWillReplace.js +11 -2
- package/actions/router/routeWillReset.js +11 -2
- package/actions/router/windowOpenOverride.js +10 -2
- package/actions/user/fetchRegisterUrl.js +36 -2
- package/actions/user/fetchUser.js +29 -3
- package/actions/user/getUser.js +6 -2
- package/actions/user/index.js +1 -1
- package/actions/user/login.js +76 -9
- package/actions/user/logout.js +30 -2
- package/collections/AuthRoutes.js +73 -14
- package/collections/Configuration.js +54 -7
- package/collections/EmbeddedMedia.js +84 -11
- package/collections/PersistedReducers.js +41 -6
- package/collections/Redirects.js +103 -17
- package/collections/index.js +5 -1
- package/collections/media-providers/MediaProvider.js +151 -26
- package/collections/media-providers/Vimeo.js +113 -19
- package/collections/media-providers/YouTube.js +74 -14
- package/collections/media-providers/index.js +3 -1
- package/collections/media-providers/style.js +52 -2
- package/components/Backdrop/index.js +95 -6
- package/components/Backdrop/spec.js +23 -1
- package/components/Backdrop/style.js +11 -2
- package/components/Button/index.js +47 -5
- package/components/Button/spec.js +36 -1
- package/components/Button/style.js +6 -1
- package/components/Checkbox/index.js +126 -32
- package/components/Checkbox/spec.js +94 -3
- package/components/Consume/helpers/buildParams.js +13 -2
- package/components/Consume/index.js +14 -2
- package/components/CountdownTimer/index.js +115 -17
- package/components/CountdownTimer/spec.js +126 -12
- package/components/Drawer/index.js +131 -16
- package/components/Drawer/spec.js +76 -1
- package/components/Drawer/style.js +37 -1
- package/components/Dropdown/index.js +65 -6
- package/components/Dropdown/style.js +4 -1
- package/components/Dropdown/transitions.js +34 -1
- package/components/Ellipsis/index.js +16 -2
- package/components/Ellipsis/spec.js +13 -1
- package/components/EmbeddedMedia/index.js +56 -6
- package/components/EmbeddedMedia/spec.js +52 -3
- package/components/ErrorBoundary/connector.js +9 -2
- package/components/ErrorBoundary/index.js +43 -7
- package/components/Grid/components/Item/index.js +40 -4
- package/components/Grid/components/Item/spec.js +23 -1
- package/components/Grid/components/Item/style.js +17 -3
- package/components/Grid/index.js +36 -4
- package/components/Grid/spec.js +23 -1
- package/components/Grid/style.js +11 -2
- package/components/HtmlSanitizer/connector.js +24 -3
- package/components/HtmlSanitizer/index.js +104 -12
- package/components/HtmlSanitizer/spec.js +214 -7
- package/components/I18n/components/FormatDate/index.js +26 -2
- package/components/I18n/components/FormatDate/spec.js +46 -1
- package/components/I18n/components/FormatNumber/index.js +34 -2
- package/components/I18n/components/FormatNumber/spec.js +41 -2
- package/components/I18n/components/FormatPrice/index.js +32 -2
- package/components/I18n/components/FormatPrice/spec.js +46 -1
- package/components/I18n/components/FormatTime/index.js +26 -2
- package/components/I18n/components/FormatTime/spec.js +43 -2
- package/components/I18n/components/I18nProvider/index.js +52 -9
- package/components/I18n/components/I18nProvider/spec.js +39 -1
- package/components/I18n/components/Placeholder/index.js +8 -2
- package/components/I18n/components/Placeholder/spec.js +30 -1
- package/components/I18n/components/Translate/index.js +68 -7
- package/components/I18n/components/Translate/spec.js +30 -1
- package/components/I18n/index.js +16 -1
- package/components/Icon/index.js +25 -2
- package/components/Icon/style.js +6 -1
- package/components/Image/Image.js +176 -19
- package/components/Image/ImageInner.js +48 -2
- package/components/Image/index.js +1 -1
- package/components/Image/style.js +29 -2
- package/components/InfiniteContainer/index.js +381 -49
- package/components/InfiniteContainer/spec.js +199 -10
- package/components/Input/components/DateInput.js +262 -6
- package/components/Input/components/MultiLineInput.js +98 -12
- package/components/Input/components/SimpleInput.js +207 -31
- package/components/Input/index.js +32 -3
- package/components/Input/spec.js +122 -1
- package/components/KeyboardConsumer/index.js +48 -7
- package/components/Link/connector.js +7 -1
- package/components/Link/index.js +96 -11
- package/components/Link/spec.js +56 -1
- package/components/Link/style.js +10 -1
- package/components/List/components/Item/index.js +35 -3
- package/components/List/components/Item/style.js +16 -1
- package/components/List/index.js +20 -2
- package/components/List/spec.js +31 -1
- package/components/Loading/index.js +6 -2
- package/components/Modal/index.js +38 -3
- package/components/Modal/style.js +36 -1
- package/components/ModalContainer/connector.js +17 -3
- package/components/ModalContainer/index.js +36 -3
- package/components/ModalContainer/spec.js +105 -5
- package/components/Picker/components/Button/index.js +34 -2
- package/components/Picker/components/Button/style.js +19 -1
- package/components/Picker/components/List/index.js +33 -2
- package/components/Picker/components/List/style.js +17 -1
- package/components/Picker/components/Modal/index.js +60 -7
- package/components/Picker/components/Modal/style.js +78 -1
- package/components/Picker/index.js +167 -21
- package/components/Picker/spec.js +83 -2
- package/components/Portal/index.js +130 -19
- package/components/ProductCharacteristics/connector.js +33 -4
- package/components/ProductCharacteristics/context.js +2 -1
- package/components/ProductCharacteristics/helpers/index.js +135 -21
- package/components/ProductCharacteristics/index.js +266 -31
- package/components/RangeSlider/components/Handle/index.js +25 -2
- package/components/RangeSlider/components/Handle/style.js +14 -1
- package/components/RangeSlider/helper.js +43 -8
- package/components/RangeSlider/index.js +228 -38
- package/components/RangeSlider/style.js +14 -1
- package/components/Route/RouteNotFound.js +46 -3
- package/components/Route/index.js +78 -10
- package/components/Router/connector.js +9 -2
- package/components/Router/index.js +237 -31
- package/components/ScannerContainer/connector.js +9 -2
- package/components/ScannerContainer/index.js +42 -6
- package/components/Select/components/Item/index.js +20 -4
- package/components/Select/components/Item/style.js +4 -1
- package/components/Select/index.js +149 -28
- package/components/Select/spec.js +86 -2
- package/components/Select/style.js +17 -1
- package/components/SelectBox/components/Item/index.js +47 -5
- package/components/SelectBox/components/Item/style.js +7 -1
- package/components/SelectBox/index.js +173 -17
- package/components/SelectBox/spec.js +59 -3
- package/components/SelectBox/style.js +18 -1
- package/components/Slider/index.js +6 -2
- package/components/SurroundPortals/index.js +26 -2
- package/components/Swiper/components/SwiperItem/index.js +28 -4
- package/components/Swiper/components/SwiperItem/spec.js +21 -1
- package/components/Swiper/components/SwiperItem/styles.js +5 -1
- package/components/Swiper/index.js +210 -18
- package/components/Swiper/styles.js +75 -7
- package/components/Toaster/index.js +10 -2
- package/components/Transition/index.js +89 -13
- package/components/Widgets/components/Widget/index.js +52 -4
- package/components/Widgets/components/Widget/spec.js +68 -3
- package/components/Widgets/components/Widget/style.js +21 -3
- package/components/Widgets/components/WidgetGrid/index.js +52 -7
- package/components/Widgets/components/WidgetGrid/spec.js +46 -2
- package/components/Widgets/components/WidgetGrid/style.js +8 -1
- package/components/Widgets/helpers/shouldShowWidget.js +44 -7
- package/components/Widgets/index.js +127 -15
- package/components/Widgets/spec.js +228 -6
- package/components/index.js +9 -1
- package/constants/ActionTypes.js +97 -19
- package/constants/Configuration.js +12 -2
- package/constants/Device.js +29 -2
- package/constants/DisplayOptions.js +8 -1
- package/constants/MenuIDs.js +2 -1
- package/constants/ModalTypes.js +1 -1
- package/constants/PageIDs.js +1 -1
- package/constants/Pipelines.js +7 -1
- package/constants/Portals.js +136 -3
- package/constants/Registration.js +3 -1
- package/constants/RoutePaths.js +13 -2
- package/constants/Tracking.js +3 -1
- package/constants/client.js +6 -1
- package/constants/ui.js +2 -1
- package/constants/user.js +6 -2
- package/context/index.js +33 -3
- package/helpers/config/index.js +139 -21
- package/helpers/config/mock.js +200 -8
- package/helpers/config/theme.js +50 -4
- package/helpers/data/index.js +204 -29
- package/helpers/data/spec.js +187 -7
- package/helpers/date/index.js +58 -6
- package/helpers/date/spec.js +92 -1
- package/helpers/dom/index.js +48 -11
- package/helpers/environment/index.js +14 -2
- package/helpers/html/decodeHTML.js +7 -1
- package/helpers/html/handleDOM.js +172 -21
- package/helpers/html/parseHTML.js +67 -12
- package/helpers/i18n/getDateFormatter.js +23 -4
- package/helpers/i18n/getNumberFormatter.js +32 -4
- package/helpers/i18n/getPriceFormatter.js +38 -4
- package/helpers/i18n/getTimeFormatter.js +23 -4
- package/helpers/i18n/getTranslator.js +62 -8
- package/helpers/i18n/index.js +5 -1
- package/helpers/i18n/mergeTranslations.js +36 -9
- package/helpers/i18n/messageCache.js +3 -1
- package/helpers/legacy/index.js +47 -9
- package/helpers/modal/withShowModal.js +13 -2
- package/helpers/portals/portalCollection.js +28 -6
- package/helpers/portals/routePortals.js +12 -1
- package/helpers/redux/compareObjects.js +7 -2
- package/helpers/redux/generateResultHash.js +36 -3
- package/helpers/redux/generateSortedHash.js +7 -2
- package/helpers/redux/hasExpired.js +10 -2
- package/helpers/redux/index.js +7 -1
- package/helpers/redux/mutable.js +143 -24
- package/helpers/redux/shouldFetchData.js +46 -10
- package/helpers/redux/shouldFetchFilters.js +17 -4
- package/helpers/router/index.js +49 -5
- package/helpers/style/index.js +43 -4
- package/helpers/style/spec.js +108 -2
- package/helpers/tracking/index.js +52 -9
- package/helpers/validation/index.js +39 -12
- package/helpers/validation/spec.js +10 -1
- package/package.json +3 -4
- package/providers/index.js +4 -1
- package/providers/loading/context.js +2 -1
- package/providers/loading/index.js +137 -22
- package/providers/toast/context.js +2 -1
- package/providers/toast/index.js +105 -11
- package/reducers/client/connectivity.js +22 -2
- package/reducers/client/index.js +7 -1
- package/reducers/client/info.js +27 -2
- package/reducers/index.js +23 -4
- package/reducers/menu/index.js +5 -1
- package/reducers/menu/menusById.js +41 -2
- package/reducers/modal/index.js +14 -2
- package/reducers/page/index.js +68 -5
- package/reducers/router/index.js +48 -2
- package/reducers/url/index.js +42 -3
- package/reducers/user/data.js +27 -2
- package/reducers/user/index.js +7 -1
- package/reducers/user/login.js +65 -2
- package/selectors/client.js +138 -21
- package/selectors/history.js +49 -11
- package/selectors/menu.js +34 -6
- package/selectors/modal.js +15 -4
- package/selectors/page.js +25 -4
- package/selectors/router.js +154 -30
- package/selectors/url.js +25 -4
- package/selectors/user.js +90 -13
- package/store/index.js +60 -6
- package/store/middelwares/logger.js +7 -1
- package/store/middelwares/streams.js +19 -2
- package/streams/app.js +60 -8
- package/streams/client.js +8 -2
- package/streams/error.js +14 -3
- package/streams/index.js +6 -1
- package/streams/interval.js +6 -2
- package/streams/main.js +27 -2
- package/streams/router.js +45 -8
- package/streams/user.js +89 -15
- package/streams/view.js +97 -25
- package/styles/reset/form.js +57 -5
- package/styles/reset/index.js +6 -1
- package/styles/reset/media.js +22 -1
- package/styles/reset/root.js +33 -1
- package/styles/reset/table.js +10 -1
- package/styles/reset/typography.js +26 -1
- package/subscriptions/app.js +148 -17
- package/subscriptions/error.js +292 -13
- package/subscriptions/helpers/buildRegisterUrl.js +25 -6
- package/subscriptions/helpers/clearUpInAppBrowser.js +14 -3
- package/subscriptions/helpers/handleLinks.js +267 -25
- package/subscriptions/helpers/pipeline.js +12 -1
- package/subscriptions/history.js +34 -6
- package/subscriptions/index.js +25 -4
- package/subscriptions/menu.js +22 -5
- package/subscriptions/mock.js +39 -7
- package/subscriptions/router.js +336 -23
- package/subscriptions/user.js +93 -3
package/streams/app.js
CHANGED
|
@@ -1,17 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import { getCurrentRoute } from "../selectors/router";
|
|
2
|
+
import { APP_WILL_INIT, APP_DID_START, APP_WILL_START, PWA_DID_APPEAR, PWA_DID_DISAPPEAR, OPEN_PUSH_NOTIFICATION, OPEN_UNIVERSAL_LINK, OPEN_DEEP_LINK } from "../constants/ActionTypes";
|
|
3
|
+
import { main$ } from "./main";
|
|
4
|
+
export const appWillInit$ = main$.filter(({
|
|
5
|
+
action
|
|
6
|
+
}) => action.type === APP_WILL_INIT);
|
|
7
|
+
|
|
8
|
+
/**
|
|
2
9
|
* Gets triggered before the app starts.
|
|
3
10
|
* @type {Observable}
|
|
4
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
export const appWillStart$ = main$.filter(({
|
|
13
|
+
action
|
|
14
|
+
}) => action.type === APP_WILL_START);
|
|
15
|
+
|
|
16
|
+
/**
|
|
5
17
|
* Gets triggered when the app starts.
|
|
6
18
|
* @type {Observable}
|
|
7
|
-
*/
|
|
19
|
+
*/
|
|
20
|
+
export const appDidStart$ = main$.filter(({
|
|
21
|
+
action
|
|
22
|
+
}) => action.type === APP_DID_START);
|
|
23
|
+
|
|
24
|
+
/**
|
|
8
25
|
* Emits when the PWA appeared again after navigating back from a legacy page.
|
|
9
|
-
*/
|
|
26
|
+
*/
|
|
27
|
+
export const pwaDidAppear$ = main$.filter(({
|
|
28
|
+
action
|
|
29
|
+
}) => action.type === PWA_DID_APPEAR).map(params => ({
|
|
30
|
+
...params,
|
|
31
|
+
action: {
|
|
32
|
+
...params.action,
|
|
33
|
+
route: getCurrentRoute(params.getState())
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
/**
|
|
10
38
|
* Emits when the PWA disappears
|
|
11
|
-
*/
|
|
39
|
+
*/
|
|
40
|
+
export const pwaDidDisappear$ = main$.filter(({
|
|
41
|
+
action
|
|
42
|
+
}) => action.type === PWA_DID_DISAPPEAR).map(params => ({
|
|
43
|
+
...params,
|
|
44
|
+
action: {
|
|
45
|
+
...params.action,
|
|
46
|
+
route: getCurrentRoute(params.getState())
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
/**
|
|
12
51
|
* Emits when a push message was opened.
|
|
13
|
-
*/
|
|
52
|
+
*/
|
|
53
|
+
export const pushNotificationOpened$ = main$.filter(({
|
|
54
|
+
action
|
|
55
|
+
}) => action.type === OPEN_PUSH_NOTIFICATION);
|
|
56
|
+
|
|
57
|
+
/**
|
|
14
58
|
* Emits when a universal link was opened.
|
|
15
|
-
*/
|
|
59
|
+
*/
|
|
60
|
+
export const universalLinkOpened$ = main$.filter(({
|
|
61
|
+
action
|
|
62
|
+
}) => action.type === OPEN_UNIVERSAL_LINK);
|
|
63
|
+
|
|
64
|
+
/**
|
|
16
65
|
* Emits when a deeplink was opened.
|
|
17
|
-
*/
|
|
66
|
+
*/
|
|
67
|
+
export const deeplinkOpened$ = main$.filter(({
|
|
68
|
+
action
|
|
69
|
+
}) => action.type === OPEN_DEEP_LINK);
|
package/streams/client.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import{RECEIVE_CLIENT_INFORMATION}from"../constants/ActionTypes";
|
|
1
|
+
import { RECEIVE_CLIENT_INFORMATION } from "../constants/ActionTypes";
|
|
2
|
+
import { main$ } from "./main";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Gets triggered after the client information was updated
|
|
3
6
|
* @type {Observable}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const clientInformationDidUpdate$ = main$.filter(({
|
|
9
|
+
action
|
|
10
|
+
}) => action.type === RECEIVE_CLIENT_INFORMATION);
|
package/streams/error.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import{APP_ERROR,PIPELINE_ERROR}from"../constants/ActionTypes";
|
|
1
|
+
import { APP_ERROR, PIPELINE_ERROR } from "../constants/ActionTypes";
|
|
2
|
+
import { main$ } from "./main";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Gets triggered when an app error is received.
|
|
3
6
|
* @type {Observable}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const appError$ = main$.filter(({
|
|
9
|
+
action
|
|
10
|
+
}) => action.type === APP_ERROR);
|
|
11
|
+
|
|
12
|
+
/**
|
|
5
13
|
* Gets triggered when an pipeline error is received.
|
|
6
14
|
* @type {Observable}
|
|
7
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
export const pipelineError$ = main$.filter(({
|
|
17
|
+
action
|
|
18
|
+
}) => action.type === PIPELINE_ERROR);
|
package/streams/index.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
export*from"./app";
|
|
1
|
+
export * from "./app";
|
|
2
|
+
export * from "./client";
|
|
3
|
+
export * from "./error";
|
|
4
|
+
export * from "./main";
|
|
5
|
+
export * from "./router";
|
|
6
|
+
export * from "./user";
|
package/streams/interval.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import{Observable}from'rxjs/Observable';
|
|
1
|
+
import { Observable } from 'rxjs/Observable';
|
|
2
|
+
import 'rxjs/add/observable/interval';
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* Gets triggered every second.
|
|
3
6
|
* @type {Observable}
|
|
4
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
export const second$ = Observable.interval(1000);
|
package/streams/main.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
import{Observable}from'rxjs/Observable';
|
|
1
|
+
import { Observable } from 'rxjs/Observable';
|
|
2
|
+
import 'rxjs/add/observable/from';
|
|
3
|
+
import 'rxjs/add/operator/buffer';
|
|
4
|
+
import 'rxjs/add/operator/bufferTime';
|
|
5
|
+
import 'rxjs/add/operator/filter';
|
|
6
|
+
import 'rxjs/add/operator/first';
|
|
7
|
+
import 'rxjs/add/operator/map';
|
|
8
|
+
import 'rxjs/add/operator/merge';
|
|
9
|
+
import 'rxjs/add/operator/mergeMap';
|
|
10
|
+
import 'rxjs/add/operator/delay';
|
|
11
|
+
import 'rxjs/add/operator/zip';
|
|
12
|
+
import 'rxjs/add/operator/do';
|
|
13
|
+
import 'rxjs/add/operator/shareReplay';
|
|
14
|
+
import 'rxjs/add/operator/distinctUntilChanged';
|
|
15
|
+
import 'rxjs/add/operator/pairwise';
|
|
16
|
+
import 'rxjs/add/operator/debounceTime';
|
|
17
|
+
import 'rxjs/add/operator/switchMap';
|
|
18
|
+
import 'rxjs/add/operator/withLatestFrom';
|
|
19
|
+
import 'rxjs/add/operator/startWith';
|
|
20
|
+
import { mainSubject } from "../store/middelwares/streams";
|
|
21
|
+
|
|
22
|
+
/**
|
|
2
23
|
* Gets triggered on every redux action that is dispatched.
|
|
3
24
|
* @type {Observable}
|
|
4
|
-
*/
|
|
25
|
+
*/
|
|
26
|
+
export const main$ = Observable.from(mainSubject);
|
|
27
|
+
if (window.Cypress) {
|
|
28
|
+
window.main$ = main$;
|
|
29
|
+
}
|
package/streams/router.js
CHANGED
|
@@ -1,16 +1,53 @@
|
|
|
1
|
-
import{main$}from"./main";
|
|
1
|
+
import { main$ } from "./main";
|
|
2
|
+
import { NAVIGATE, ROUTE_WILL_ENTER, ROUTE_DID_ENTER, ROUTE_WILL_LEAVE, ROUTE_DID_LEAVE, ROUTE_DID_UPDATE, WINDOW_OPEN_OVERRIDE } from "../constants/ActionTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
2
5
|
* @type {Observable}
|
|
3
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
export const navigate$ = main$.filter(({
|
|
8
|
+
action
|
|
9
|
+
}) => action.type === NAVIGATE);
|
|
10
|
+
|
|
11
|
+
/**
|
|
4
12
|
* @type {Observable}
|
|
5
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
export const routeWillEnter$ = main$.filter(({
|
|
15
|
+
action
|
|
16
|
+
}) => action.type === ROUTE_WILL_ENTER);
|
|
17
|
+
|
|
18
|
+
/**
|
|
6
19
|
* @type {Observable}
|
|
7
|
-
*/
|
|
20
|
+
*/
|
|
21
|
+
export const routeDidEnter$ = main$.filter(({
|
|
22
|
+
action
|
|
23
|
+
}) => action.type === ROUTE_DID_ENTER);
|
|
24
|
+
|
|
25
|
+
/**
|
|
8
26
|
* @type {Observable}
|
|
9
|
-
*/
|
|
27
|
+
*/
|
|
28
|
+
export const routeWillLeave$ = main$.filter(({
|
|
29
|
+
action
|
|
30
|
+
}) => action.type === ROUTE_WILL_LEAVE);
|
|
31
|
+
|
|
32
|
+
/**
|
|
10
33
|
* @type {Observable}
|
|
11
|
-
*/
|
|
34
|
+
*/
|
|
35
|
+
export const routeDidLeave$ = main$.filter(({
|
|
36
|
+
action
|
|
37
|
+
}) => action.type === ROUTE_DID_LEAVE);
|
|
38
|
+
|
|
39
|
+
/**
|
|
12
40
|
* @type {Observable}
|
|
13
|
-
*/
|
|
41
|
+
*/
|
|
42
|
+
export const routeDidUpdate$ = main$.filter(({
|
|
43
|
+
action
|
|
44
|
+
}) => action.type === ROUTE_DID_UPDATE);
|
|
45
|
+
|
|
46
|
+
/**
|
|
14
47
|
* @type {Observable}
|
|
15
48
|
* @deprecated use routeDidEnter$
|
|
16
|
-
*/
|
|
49
|
+
*/
|
|
50
|
+
export const routeDidChange$ = routeDidEnter$;
|
|
51
|
+
export const windowOpenOverride$ = main$.filter(({
|
|
52
|
+
action
|
|
53
|
+
}) => action.type === WINDOW_OPEN_OVERRIDE);
|
package/streams/user.js
CHANGED
|
@@ -1,42 +1,116 @@
|
|
|
1
|
-
import{Observable}from'rxjs/Observable';
|
|
1
|
+
import { Observable } from 'rxjs/Observable';
|
|
2
|
+
import 'rxjs/add/observable/interval';
|
|
3
|
+
import 'rxjs/add/operator/takeUntil';
|
|
4
|
+
import { REQUEST_LOGIN, SUCCESS_LOGIN, ERROR_LOGIN, ERROR_LEGACY_CONNECT_REGISTER, REQUEST_LOGOUT, SUCCESS_LOGOUT, RECEIVE_USER, ERROR_USER } from "../constants/ActionTypes";
|
|
5
|
+
import { appDidStart$ } from "./app";
|
|
6
|
+
import { main$ } from "./main";
|
|
7
|
+
import { SESSION_EXPIRY_CHECK_INTERVAL } from "../constants/user";
|
|
8
|
+
import { getSessionExpiry, getIsSessionExpired } from "../selectors/user";
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* Gets triggered when user is requesting to login.
|
|
3
12
|
* @type {Observable}
|
|
4
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
export const userWillLogin$ = main$.filter(({
|
|
15
|
+
action
|
|
16
|
+
}) => action.type === REQUEST_LOGIN);
|
|
17
|
+
|
|
18
|
+
/**
|
|
5
19
|
* Gets triggered when user login request has gained a response.
|
|
6
20
|
* @type {Observable}
|
|
7
|
-
*/
|
|
21
|
+
*/
|
|
22
|
+
export const userLoginResponse$ = main$.filter(({
|
|
23
|
+
action
|
|
24
|
+
}) => action.type === SUCCESS_LOGIN || action.type === ERROR_LOGIN);
|
|
25
|
+
|
|
26
|
+
/**
|
|
8
27
|
* Gets triggered when user has logged in.
|
|
9
28
|
* @type {Observable}
|
|
10
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
export const userDidLogin$ = main$.filter(({
|
|
31
|
+
action
|
|
32
|
+
}) => action.type === SUCCESS_LOGIN);
|
|
33
|
+
|
|
34
|
+
/**
|
|
11
35
|
* Gets triggered when user is requesting to logout.
|
|
12
36
|
* @type {Observable}
|
|
13
|
-
*/
|
|
37
|
+
*/
|
|
38
|
+
export const userWillLogout$ = main$.filter(({
|
|
39
|
+
action
|
|
40
|
+
}) => action.type === REQUEST_LOGOUT);
|
|
41
|
+
|
|
42
|
+
/**
|
|
14
43
|
* Gets triggered when user has logged out.
|
|
15
44
|
* @type {Observable}
|
|
16
|
-
*/
|
|
45
|
+
*/
|
|
46
|
+
export const userDidLogout$ = main$.filter(({
|
|
47
|
+
action
|
|
48
|
+
}) => action.type === SUCCESS_LOGOUT);
|
|
49
|
+
|
|
50
|
+
/**
|
|
17
51
|
* Gets triggered when the user data was updated.
|
|
18
52
|
* @type {Observable}
|
|
19
|
-
*/
|
|
53
|
+
*/
|
|
54
|
+
export const userDidUpdate$ = main$.filter(({
|
|
55
|
+
action
|
|
56
|
+
}) => action.type === RECEIVE_USER || action.type === SUCCESS_LOGOUT || action.type === ERROR_USER);
|
|
57
|
+
|
|
58
|
+
/**
|
|
20
59
|
* Gets triggered when we have a stable login state of the user. Since user data is persisted,
|
|
21
60
|
* some parts of the code might not rely on the redux states.
|
|
22
61
|
* @type {Observable}
|
|
23
|
-
*/
|
|
62
|
+
*/
|
|
63
|
+
export const userDidInitialize$ = appDidStart$.switchMap(() => main$.filter(({
|
|
64
|
+
action
|
|
65
|
+
}) => action.type === RECEIVE_USER || action.type === ERROR_USER)).first();
|
|
66
|
+
|
|
67
|
+
/**
|
|
24
68
|
* Gets triggered when we received the user data.
|
|
25
69
|
* @type {Observable}
|
|
26
|
-
*/
|
|
70
|
+
*/
|
|
71
|
+
export const userDataReceived$ = userDidUpdate$.filter(({
|
|
72
|
+
action
|
|
73
|
+
}) => action.type === RECEIVE_USER);
|
|
74
|
+
|
|
75
|
+
/**
|
|
27
76
|
* Gets triggered when the login failed.
|
|
28
77
|
* @type {Observable}
|
|
29
|
-
*/
|
|
78
|
+
*/
|
|
79
|
+
export const loginDidFail$ = main$.filter(({
|
|
80
|
+
action
|
|
81
|
+
}) => action.type === ERROR_LOGIN);
|
|
82
|
+
|
|
83
|
+
/**
|
|
30
84
|
* Gets triggered when the legacy sgconnect registration failed
|
|
31
85
|
* @type {Observable}
|
|
32
|
-
*/
|
|
86
|
+
*/
|
|
87
|
+
export const legacyConnectRegisterDidFail$ = main$.filter(({
|
|
88
|
+
action
|
|
89
|
+
}) => action.type === ERROR_LEGACY_CONNECT_REGISTER);
|
|
90
|
+
|
|
91
|
+
/**
|
|
33
92
|
* Emits when user session expiry needs to be checked. That's the case when the login state in
|
|
34
93
|
* Redux contains a numeric value for the "expires" property.
|
|
35
94
|
* Checks are performed at appStart since there might be a persisted value in Redux from the last
|
|
36
95
|
* sessions, or it happens after login when the login response contained a session lease.
|
|
37
|
-
*/
|
|
96
|
+
*/
|
|
97
|
+
export const sessionExpiryNeedsToBeChecked$ = appDidStart$.merge(userDidLogin$).filter(({
|
|
98
|
+
getState
|
|
99
|
+
}) => {
|
|
100
|
+
const expiry = getSessionExpiry(getState());
|
|
101
|
+
return expiry !== null;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/**
|
|
38
105
|
* Emits when a user session with an expiry expires. Therefore it performs an interval check to
|
|
39
106
|
* check if the session is still active.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
|
|
107
|
+
*/
|
|
108
|
+
export const userSessionExpired$ = sessionExpiryNeedsToBeChecked$.switchMap(data => {
|
|
109
|
+
// At first check if the session already expired - necessary for appDidStart$
|
|
110
|
+
if (getIsSessionExpired(data.getState())) {
|
|
111
|
+
return Observable.of(data);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Setup an interval that periodically checks if the session expired - runs till user logged out
|
|
115
|
+
return Observable.interval(SESSION_EXPIRY_CHECK_INTERVAL).takeUntil(userDidLogout$).filter(() => getIsSessionExpired(data.getState())).switchMap(() => Observable.of(data));
|
|
116
|
+
});
|
package/streams/view.js
CHANGED
|
@@ -1,34 +1,106 @@
|
|
|
1
|
-
import{Observable}from'rxjs/Observable';
|
|
1
|
+
import { Observable } from 'rxjs/Observable';
|
|
2
|
+
import { Subject } from 'rxjs/Subject';
|
|
3
|
+
import { async as asyncScheduler } from 'rxjs/scheduler/async';
|
|
4
|
+
import 'rxjs/add/observable/from';
|
|
5
|
+
import 'rxjs/add/observable/fromEvent';
|
|
6
|
+
import 'rxjs/add/operator/do';
|
|
7
|
+
import 'rxjs/add/operator/throttleTime';
|
|
8
|
+
export const eventsSubject = new Subject();
|
|
9
|
+
|
|
10
|
+
/**
|
|
2
11
|
* Cold observable for View scroll events
|
|
3
12
|
* Use this to listen for scroll-related changes in any part of the app.
|
|
4
13
|
* @type {Observable}
|
|
5
|
-
*/
|
|
14
|
+
*/
|
|
15
|
+
export const viewScroll$ = Observable.from(eventsSubject);
|
|
16
|
+
|
|
17
|
+
/**
|
|
6
18
|
* Sets up throttled scroll event stream for a given element or window.
|
|
7
19
|
* Emits enriched scroll info such as direction and distance.
|
|
8
20
|
*
|
|
9
21
|
* @param {HTMLElement|Window} element - DOM node or window to observe
|
|
10
22
|
* @param {number} throttleTime - Time in ms to throttle scroll events
|
|
11
23
|
* @returns {Observable} - Observable emitting scroll-related data
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
*/
|
|
25
|
+
export const emitScrollEvents = (element, throttleTime = 250) => {
|
|
26
|
+
// In rare situation during unmounting a react dom ref might
|
|
27
|
+
// be null due to the execution order of events in fiber nodes.
|
|
28
|
+
if (!element) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
let previousScrollTop = 0;
|
|
32
|
+
// Tracks scroll direction ('up' or 'down')
|
|
33
|
+
let lastDirection = null;
|
|
34
|
+
// Minimum distance to consider a real scroll
|
|
35
|
+
const minDelta = 10;
|
|
36
|
+
// Pixels from bottom to consider "at bottom"
|
|
37
|
+
const bottomThreshold = 20;
|
|
38
|
+
// Prevent scrollUp triggering in this zone
|
|
39
|
+
const deadZoneThreshold = 30;
|
|
40
|
+
const scroll$ = Observable.fromEvent(element, 'scroll').throttleTime(throttleTime, asyncScheduler, {
|
|
41
|
+
leading: false,
|
|
42
|
+
trailing: true
|
|
43
|
+
}).map(event => {
|
|
44
|
+
// Determine if element is the window/document or a scrollable container
|
|
45
|
+
const isWindow = element === window || element === document.body || element === document.documentElement;
|
|
46
|
+
|
|
47
|
+
// Get current scroll position
|
|
48
|
+
const rawScrollTop = isWindow ? window.scrollY || window.pageYOffset || 0 : element.scrollTop;
|
|
49
|
+
|
|
50
|
+
// Compute max scroll value
|
|
51
|
+
const maxScrollTop = isWindow ? Math.max(document.documentElement.scrollHeight, document.body.scrollHeight) - window.innerHeight : element.scrollHeight - element.clientHeight;
|
|
52
|
+
|
|
53
|
+
// Clamp scrollTop to prevent overshoot from iOS bounce
|
|
54
|
+
const scrollTop = Math.min(rawScrollTop, maxScrollTop);
|
|
55
|
+
const delta = scrollTop - previousScrollTop;
|
|
56
|
+
const isScrollingDown = delta > 0;
|
|
57
|
+
const isScrollingUp = delta < 0;
|
|
58
|
+
|
|
59
|
+
// Determine direction
|
|
60
|
+
let direction = lastDirection;
|
|
61
|
+
if (isScrollingDown) direction = 'down';else if (isScrollingUp) direction = 'up';
|
|
62
|
+
|
|
63
|
+
// Are we near the bottom of the scrollable area?
|
|
64
|
+
const nearBottom = scrollTop >= maxScrollTop - bottomThreshold;
|
|
65
|
+
const inDeadZone = scrollTop >= maxScrollTop - deadZoneThreshold;
|
|
66
|
+
|
|
67
|
+
// Detect downward scroll beyond threshold and not near bottom
|
|
68
|
+
const scrollDown = isScrollingDown && delta > minDelta && !nearBottom;
|
|
69
|
+
|
|
70
|
+
// Detect upward scroll beyond threshold
|
|
71
|
+
let scrollUp = isScrollingUp && Math.abs(delta) > minDelta;
|
|
72
|
+
|
|
73
|
+
// Suppress scrollUp events in dead zone to avoid iOS bounce
|
|
74
|
+
if (scrollUp && inDeadZone && direction === 'up') {
|
|
75
|
+
scrollUp = false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Detect a bounce-back: scrollDown followed by a quick scrollUp at the bottom
|
|
79
|
+
const bounced = lastDirection === 'down' && direction === 'up' && nearBottom;
|
|
80
|
+
|
|
81
|
+
// Final scrolled flag — only emit if meaningful and not a bounce
|
|
82
|
+
const scrolled = (scrollDown || scrollUp) && !bounced;
|
|
83
|
+
|
|
84
|
+
// Update direction and scrollTop memory
|
|
85
|
+
lastDirection = direction;
|
|
86
|
+
return {
|
|
87
|
+
event,
|
|
88
|
+
scrollTop,
|
|
89
|
+
previousScrollTop,
|
|
90
|
+
scrolled,
|
|
91
|
+
scrollUp,
|
|
92
|
+
scrollDown: scrollDown && !bounced,
|
|
93
|
+
direction,
|
|
94
|
+
scrollOut: scrollDown && !bounced,
|
|
95
|
+
// legacy compatibility
|
|
96
|
+
scrollIn: scrollUp // legacy compatibility
|
|
97
|
+
};
|
|
98
|
+
}).do(event => {
|
|
99
|
+
// Store current scrollTop for next event comparison
|
|
100
|
+
previousScrollTop = event.scrollTop;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Pipe scroll data into the shared stream for global consumers
|
|
104
|
+
scroll$.subscribe(viewScroll$);
|
|
105
|
+
return scroll$;
|
|
106
|
+
};
|
package/styles/reset/form.js
CHANGED
|
@@ -1,11 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from 'glamor';
|
|
6
|
+
|
|
7
|
+
/**
|
|
4
8
|
* 1. Correct the inability to style clickable types in iOS and Safari.
|
|
5
|
-
*/
|
|
6
|
-
css.global('button',{
|
|
9
|
+
*/
|
|
10
|
+
css.global('button, html [type="button"], [type="reset"], [type="submit"]', {
|
|
11
|
+
WebkitAppearance: 'button'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// since iOS 15 button has a default color of blue rgb(0, 122, 255);
|
|
15
|
+
css.global('button', {
|
|
16
|
+
color: 'inherit'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/**
|
|
7
20
|
* 1. Change font properties to `inherit` in Safari.
|
|
8
21
|
* 2. Correct the inability to style clickable types in iOS and Safari.
|
|
9
|
-
*/
|
|
22
|
+
*/
|
|
23
|
+
css.global('::-webkit-file-upload-button', {
|
|
24
|
+
font: 'inherit',
|
|
25
|
+
WebkitAppearance: 'button'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
10
29
|
* Remove the inner padding and cancel buttons in Chrome and Safari for OS X.
|
|
11
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
css.global('::-webkit-search-cancel-button, ::-webkit-search-decoration', {
|
|
32
|
+
WebkitAppearance: 'none'
|
|
33
|
+
});
|
|
34
|
+
css.global('button, input, select, textarea', {
|
|
35
|
+
background: 'transparent',
|
|
36
|
+
border: 0,
|
|
37
|
+
fontSize: '1em',
|
|
38
|
+
margin: 0
|
|
39
|
+
});
|
|
40
|
+
css.global('input, select, textarea', {
|
|
41
|
+
fontFamily: 'inherit'
|
|
42
|
+
});
|
|
43
|
+
css.global('button, textarea', {
|
|
44
|
+
fontFamily: 'inherit',
|
|
45
|
+
lineHeight: 'inherit'
|
|
46
|
+
});
|
|
47
|
+
css.global('button', {
|
|
48
|
+
borderRadius: 0
|
|
49
|
+
});
|
|
50
|
+
css.global('button, label, [type="checkbox"], [type="radio"]', {
|
|
51
|
+
cursor: 'pointer'
|
|
52
|
+
});
|
|
53
|
+
css.global('label', {
|
|
54
|
+
display: 'inline-block'
|
|
55
|
+
});
|
|
56
|
+
css.global('textarea', {
|
|
57
|
+
minHeight: '5em',
|
|
58
|
+
maxWidth: '100%',
|
|
59
|
+
resize: 'none'
|
|
60
|
+
});
|
|
61
|
+
css.global('[type="search"]', {
|
|
62
|
+
WebkitAppearance: 'textfield'
|
|
63
|
+
});
|
package/styles/reset/index.js
CHANGED
package/styles/reset/media.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated used @shopgate/engage/styles/reset instead
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from 'glamor';
|
|
6
|
+
css.global('audio:not([controls])', {
|
|
7
|
+
display: 'none',
|
|
8
|
+
height: 0
|
|
9
|
+
});
|
|
10
|
+
css.global('figure', {
|
|
11
|
+
margin: 0
|
|
12
|
+
});
|
|
13
|
+
css.global('iframe', {
|
|
14
|
+
border: 0,
|
|
15
|
+
display: 'block',
|
|
16
|
+
width: '100%'
|
|
17
|
+
});
|
|
18
|
+
css.global('img, svg', {
|
|
19
|
+
display: 'block',
|
|
20
|
+
maxWidth: '100%'
|
|
21
|
+
});
|
|
22
|
+
css.global('progress', {
|
|
23
|
+
verticalAlign: 'baseline'
|
|
24
|
+
});
|
package/styles/reset/root.js
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated used @shopgate/engage/styles instead
|
|
3
|
-
*/
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { css } from 'glamor';
|
|
6
|
+
import { themeConfig } from "../../helpers/config";
|
|
7
|
+
const {
|
|
8
|
+
typography
|
|
9
|
+
} = themeConfig;
|
|
10
|
+
css.global('*, *:before, *:after', {
|
|
11
|
+
boxSizing: 'border-box'
|
|
12
|
+
});
|
|
13
|
+
css.global('html, body', {
|
|
14
|
+
WebkitTapHighlightColor: 'transparent',
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '100%'
|
|
17
|
+
});
|
|
18
|
+
css.global('html', {
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
21
|
+
WebkitFontSmoothing: 'antialiased',
|
|
22
|
+
MsTextSizeAdjust: '100%',
|
|
23
|
+
WebkitTextSizeAdjust: '100%',
|
|
24
|
+
minHeight: '100%'
|
|
25
|
+
});
|
|
26
|
+
css.global('body', {
|
|
27
|
+
font: `${typography.rootSize}px/${typography.lineHeight} ${typography.family}`,
|
|
28
|
+
overflow: 'auto',
|
|
29
|
+
margin: 0,
|
|
30
|
+
WebkitOverflowScrolling: 'touch',
|
|
31
|
+
WebkitUserSelect: 'none'
|
|
32
|
+
});
|
|
33
|
+
css.global('[data-pattern]', {
|
|
34
|
+
height: '100% !important'
|
|
35
|
+
});
|