@salla.sa/twilight 1.6.15 → 2.0.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.
Files changed (115) hide show
  1. package/README.md +4 -214
  2. package/components/README.md +55 -0
  3. package/components/dist/cjs/index-9441fd8e.js +1554 -0
  4. package/components/dist/cjs/index.cjs.js +2 -0
  5. package/components/dist/cjs/loader.cjs.js +21 -0
  6. package/components/dist/cjs/salla-login_2.cjs.entry.js +131 -0
  7. package/components/dist/cjs/twilight-components.cjs.js +19 -0
  8. package/components/dist/collection/collection-manifest.json +13 -0
  9. package/components/dist/collection/components/generate-summary.js +35 -0
  10. package/components/dist/collection/components/salla-login/salla-login.css +104 -0
  11. package/components/dist/collection/components/salla-login/salla-login.js +113 -0
  12. package/components/dist/collection/components/search-modal/search-modal.css +9 -0
  13. package/components/dist/collection/components/search-modal/search-modal.js +161 -0
  14. package/components/dist/collection/index.js +1 -0
  15. package/components/dist/collection/interfaces/colors.js +1 -0
  16. package/components/dist/collection/interfaces/index.js +2 -0
  17. package/components/dist/collection/interfaces/ratio.js +1 -0
  18. package/components/dist/collection/plugins/tailwind-theme/index.js +32 -0
  19. package/components/dist/collection/plugins/tailwind-theme/scripts/generator.js +51 -0
  20. package/components/dist/collection/utils/utils.js +16 -0
  21. package/components/dist/esm/index-63e5409f.js +1527 -0
  22. package/components/dist/esm/index.js +1 -0
  23. package/components/dist/esm/loader.js +17 -0
  24. package/components/dist/esm/polyfills/core-js.js +11 -0
  25. package/components/dist/esm/polyfills/css-shim.js +1 -0
  26. package/components/dist/esm/polyfills/dom.js +79 -0
  27. package/components/dist/esm/polyfills/es5-html-element.js +1 -0
  28. package/components/dist/esm/polyfills/index.js +34 -0
  29. package/components/dist/esm/polyfills/system.js +6 -0
  30. package/components/dist/esm/salla-login_2.entry.js +126 -0
  31. package/components/dist/esm/twilight-components.js +17 -0
  32. package/components/dist/index.cjs.js +1 -0
  33. package/components/dist/index.js +1 -0
  34. package/components/dist/twilight-components/index.esm.js +0 -0
  35. package/components/dist/twilight-components/p-3d53781c.js +1 -0
  36. package/components/dist/twilight-components/p-fccb89fa.entry.js +1 -0
  37. package/components/dist/twilight-components/twilight-components.esm.js +1 -0
  38. package/components/dist/types/components/salla-login/salla-login.d.ts +14 -0
  39. package/components/dist/types/components/search-modal/search-modal.d.ts +26 -0
  40. package/components/dist/types/components.d.ts +76 -0
  41. package/components/dist/types/index.d.ts +6 -0
  42. package/components/dist/types/interfaces/colors.d.ts +1 -0
  43. package/components/dist/types/interfaces/index.d.ts +2 -0
  44. package/components/dist/types/interfaces/ratio.d.ts +1 -0
  45. package/components/dist/types/stencil-public-runtime.d.ts +1563 -0
  46. package/components/dist/types/utils/utils.d.ts +6 -0
  47. package/components/loader/cdn.js +3 -0
  48. package/components/loader/index.cjs.js +3 -0
  49. package/components/loader/index.d.ts +13 -0
  50. package/components/loader/index.es2017.js +3 -0
  51. package/components/loader/index.js +4 -0
  52. package/components/loader/package.json +10 -0
  53. package/components/package.json +70 -0
  54. package/components/src/plugins/tailwind-theme/index.js +32 -0
  55. package/components/src/plugins/tailwind-theme/package.json +27 -0
  56. package/components/src/plugins/tailwind-theme/readme.md +47 -0
  57. package/components/src/plugins/tailwind-theme/safe-list-css.txt +19 -0
  58. package/components/src/plugins/tailwind-theme/utilities.json +1 -0
  59. package/components.js +1 -0
  60. package/dist/twilight.js +2 -0
  61. package/dist/twilight.js.LICENSE.txt +27 -0
  62. package/package.json +53 -63
  63. package/postInstall.js +2 -0
  64. package/tailwind.js +1 -0
  65. package/tailwind_css_list.js +1 -0
  66. package/watcher.js +20 -62
  67. package/LICENSE.md +0 -674
  68. package/dist/@salla.sa/twilight.min.js +0 -20
  69. package/dist/@salla.sa/twilight.min.js.map +0 -1
  70. package/dist/cjs/index.js +0 -2
  71. package/dist/cjs/index.js.map +0 -1
  72. package/dist/esm/index.js +0 -2
  73. package/dist/esm/index.js.map +0 -1
  74. package/types/actions.d.ts +0 -47
  75. package/types/api/auth/index.d.ts +0 -17
  76. package/types/api/auth/request.d.ts +0 -42
  77. package/types/api/auth/response.d.ts +0 -22
  78. package/types/api/cart/index.d.ts +0 -24
  79. package/types/api/cart/request.d.ts +0 -8
  80. package/types/api/cart/response.d.ts +0 -66
  81. package/types/api/comment.d.ts +0 -18
  82. package/types/api/currency.d.ts +0 -17
  83. package/types/api/document.d.ts +0 -3
  84. package/types/api/index.d.ts +0 -110
  85. package/types/api/loyalty.d.ts +0 -226
  86. package/types/api/order.d.ts +0 -15
  87. package/types/api/product/index.d.ts +0 -17
  88. package/types/api/product/request.d.ts +0 -53
  89. package/types/api/product/response.d.ts +0 -103
  90. package/types/api/profile.d.ts +0 -60
  91. package/types/api/rating.d.ts +0 -49
  92. package/types/api/scope.d.ts +0 -42
  93. package/types/api/wishlist.d.ts +0 -7
  94. package/types/common.d.ts +0 -75
  95. package/types/event/auth.d.ts +0 -18
  96. package/types/event/cart.d.ts +0 -30
  97. package/types/event/comment.d.ts +0 -7
  98. package/types/event/currency.d.ts +0 -9
  99. package/types/event/document.d.ts +0 -29
  100. package/types/event/index.d.ts +0 -48
  101. package/types/event/infiniteScroll.d.ts +0 -12
  102. package/types/event/loyalty.d.ts +0 -14
  103. package/types/event/order.d.ts +0 -11
  104. package/types/event/product.d.ts +0 -30
  105. package/types/event/profile.d.ts +0 -19
  106. package/types/event/rating.d.ts +0 -13
  107. package/types/event/scope.d.ts +0 -15
  108. package/types/event/wishlist.d.ts +0 -8
  109. package/types/helpers/app-helpers.d.ts +0 -29
  110. package/types/index.d.ts +0 -37
  111. package/types/lib/config.ts +0 -14
  112. package/types/lib/form.d.ts +0 -8
  113. package/types/lib/lang.d.ts +0 -14
  114. package/types/lib/notify.d.ts +0 -14
  115. package/types/tiwlight-config.d.ts +0 -74
@@ -1,103 +0,0 @@
1
- import {Category as ShortCategory, Product, SuccessResponse} from "../../common";
2
- import {Category} from "./request";
3
- type offerType = 'buy_x_get_y' | 'percentage' | 'fixed_amount';
4
- type paymentMethod = {
5
- id: number;
6
- slug: 'bank';
7
- name: 'BankTransfer';
8
- };
9
- export interface SizeGuide {
10
- name: string;
11
- description: string;
12
- }
13
- export interface Offer {
14
- id: number;
15
- name: string;
16
- message: string;
17
- expiry_date: string | '2022-02-22 00:00:00';
18
- formatted_date: string;
19
- offer_type: offerType;
20
- applied_to: 'order' | 'category' | 'product' | 'paymentMethod';
21
- buy: {
22
- type: 'product' | 'category';
23
- quantity: number;
24
- products?: Product[];
25
- categories?: ShortCategory[];
26
- min_amount?: number; //when offer_type != 'buy_x_get_y'
27
- min_items?: number; //when offer_type != 'buy_x_get_y'
28
- payment_methods: paymentMethod[];
29
- };
30
- get: {
31
- products?: Product[];
32
- categories?: ShortCategory[];
33
- type: 'product' | 'category';
34
- discount_type: 'free-product' | 'percentage';
35
- quantity?: number;//when discount_type == 'percentage'
36
- discount_amount?: number; //when offer_type != 'buy_x_get_y' or get.discount_type !='free-product'
37
- }
38
- }
39
-
40
- /**
41
- * Gifting System
42
- */
43
- export interface Gift {
44
- quantity: number;
45
- product: Product;
46
- sender_name: string;
47
- images: GiftImage[];
48
- texts: GiftText[];
49
- }
50
-
51
- export interface GiftImage {
52
- id: number;
53
- url: string;
54
- }
55
-
56
- export interface GiftText {
57
- id: number;
58
- text: string;
59
- }
60
-
61
- export namespace ProductResponse {
62
- export interface search extends SuccessResponse {
63
- data: Product[];
64
- cursor: {
65
- current: number;
66
- previous?: string;
67
- next?: string;
68
- count: number;
69
- };
70
- }
71
-
72
- export interface getPrice extends SuccessResponse {
73
- data: {
74
- price: number;
75
- regular_price: number;
76
- has_sale_price: boolean;
77
- }
78
- }
79
-
80
- export interface categories extends SuccessResponse {
81
- data: Category | Category[]; //single category when getting subCategories by passing categoryId
82
- }
83
-
84
- export interface offers extends SuccessResponse {
85
- data: Offer[] | [];
86
- }
87
-
88
- export interface sizeGuides extends SuccessResponse {
89
- data: Array<SizeGuide>;
90
- }
91
-
92
- export interface giftResponse extends SuccessResponse {
93
- data: Gift
94
- }
95
-
96
- export interface giftToCart extends SuccessResponse {
97
- data: Object
98
- }
99
-
100
- export interface giftImageUpload extends SuccessResponse {
101
- data: Object | String
102
- }
103
- }
@@ -1,60 +0,0 @@
1
- import {SuccessResponse} from "../common";
2
- import {AuthRequest, VerificationStatus} from "./auth";
3
-
4
- export interface ProfileUpdatePayload {
5
- first_name: string;
6
- last_name: string;
7
- birthday?: string | '2022-02-22';
8
- gender?: 'male' | 'female';
9
- avatar?: BinaryType;
10
- }
11
-
12
- export interface ProfileUpdateContactPayload {
13
- phone?: string | number; //required if there is no email
14
- country_code?: string | 'SA'; //required if there is phone
15
- email?: string; //required if there is no phone
16
- }
17
-
18
- export interface ProfileResponse extends SuccessResponse {
19
- data: {
20
- id: number;
21
- first_name: string;
22
- last_name: string;
23
- currency: string | 'SAR';
24
- language: string | 'ar';
25
- phone: {
26
- code: string | "+966";
27
- number: string | number;
28
- country: string | "SA";
29
- };
30
- email: string;
31
- avatar: string;
32
- gender?: 'male' | 'female';
33
- birthday: string | '2022-02-22';
34
- verification?: VerificationStatus; //exists when trying to update email/phone
35
- };
36
- }
37
-
38
- export interface VerifyContactResponse extends SuccessResponse {
39
- data: {
40
- message: string;
41
- verification: VerificationStatus;
42
- }
43
- }
44
-
45
- export interface NotificationSettingPayload {
46
- check: Number
47
- }
48
-
49
- export interface AccountDeletionPayload {
50
- user_id: Number
51
- }
52
-
53
- export default interface ProfileApi {
54
- info: () => Promise<ProfileResponse>;
55
- update: (data: ProfileUpdatePayload) => Promise<ProfileResponse>;
56
- verify: (data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail) => Promise<VerifyContactResponse>;
57
- updateContacts: (data: ProfileUpdateContactPayload) => Promise<ProfileResponse>;//need to verify after success event
58
- setNotification: (data: NotificationSettingPayload) => Promise<SuccessResponse>;
59
- deleteAccount: (data: AccountDeletionPayload) => Promise<SuccessResponse>
60
- }
@@ -1,49 +0,0 @@
1
- import { Product, Rating, SuccessResponse} from "../common";
2
-
3
- export interface OrderDetailsResponse extends SuccessResponse {
4
- data: {
5
- id: number;
6
- store?: { feedback: RatingContent };
7
- shipping?: {
8
- feedback: RatingContent;
9
- company: {
10
- id: number;
11
- name: string;
12
- logo?: string;
13
- }
14
- };
15
- products: Array<{ feedback: RatingContent; product: Product; }>;
16
- testimonials_enabled: boolean;
17
- shipping_enabled: boolean;
18
- products_enabled: boolean;
19
- thanks_message: string;
20
- }
21
- }
22
-
23
- export interface RatingContent {
24
- content: string;
25
- rating: Rating;
26
- status?: 'approved' | 'pending';
27
- }
28
-
29
- export interface RatingStorePayload {
30
- comment: string;
31
- order_id: number;
32
- rating: Rating;
33
- }
34
-
35
- export interface RatingProductsPayload {
36
- products: Array<{ product_id: number; comment: string; rating: Rating; }>
37
- order_id: number;
38
- }
39
-
40
- export interface RatingShippingPayload extends RatingStorePayload {
41
- shipping_company_id: number;
42
- }
43
-
44
- export default interface RatingApi {
45
- order: (order_id: number) => Promise<OrderDetailsResponse>;
46
- store: (data: RatingStorePayload) => Promise<SuccessResponse>;
47
- products: (data: RatingProductsPayload) => Promise<SuccessResponse>;
48
- shipping: (data: RatingShippingPayload) => Promise<SuccessResponse>;
49
- }
@@ -1,42 +0,0 @@
1
- import { SuccessResponse } from "../common";
2
-
3
- export interface Scope {
4
- id: number;
5
- name: string;
6
- selected: boolean;
7
- }
8
-
9
- export interface ProductAvailability {
10
- name: string;
11
- selected: boolean;
12
- availability: Availability;
13
- }
14
-
15
- export interface Availability {
16
- label: string;
17
- key: string;
18
- color: string;
19
- }
20
-
21
-
22
- export namespace ScopeApiResponse {
23
-
24
- export interface scopeList extends SuccessResponse {
25
- data: Scope[];
26
- }
27
-
28
- export interface scopeAddition extends SuccessResponse {
29
- data: Scope
30
- }
31
-
32
- export interface availability extends SuccessResponse {
33
- data: ProductAvailability[];
34
- }
35
- }
36
-
37
-
38
- export default interface ScopeApi {
39
- get: () => Promise<ScopeApiResponse.scopeList>
40
- change: (payload: Object) => Promise<SuccessResponse>
41
- getProductAvailability: (product_id: number) => Promise<ScopeApiResponse.availability>
42
- }
@@ -1,7 +0,0 @@
1
- import {SuccessResponse} from "../common";
2
-
3
- export default interface WishlistApi {
4
- add: (product_id: number) => Promise<SuccessResponse>;
5
- remove: (product_id: number) => Promise<SuccessResponse>;
6
- toggle: (product_id: number) => Promise<SuccessResponse>;
7
- }
package/types/common.d.ts DELETED
@@ -1,75 +0,0 @@
1
- type ProductType = 'product' | 'service' | 'group_products' | 'codes' | 'digital' | 'food' | 'donating';
2
- type Rating = 1 | 2 | 3 | 4 | 5;
3
- type RequestError = Error & { response: any }
4
- type RequestErrorEvent = (callback: (error: RequestError | string) => void) => void;
5
- type RequestErrorEventWithData<data> = (callback: (error: RequestError | string, data) => void) => void;
6
-
7
- export interface Price {
8
- amount: string;
9
- currency: string;
10
- }
11
-
12
- export interface SuccessResponse {
13
- status: 200;
14
- success: true;
15
- data: {
16
- message?: string;
17
- events?: { [event_name: string]: any };
18
- [key: string]: any;
19
- };
20
- }
21
-
22
- export interface ErrorResponse {
23
- status: 422 | 404;
24
- success: false;
25
- error: {
26
- message?: string | 'alert.invalid_fields';
27
- code?: any;
28
- case?: string | 'resend_counter' | 'invalid_code';
29
- events?: { [event_name: string]: any };
30
- fields?: { [field_name: string]: Array<string> };
31
- [key: string]: any;
32
- }
33
- }
34
-
35
- export interface Currency {
36
- code: string | 'SAR';
37
- name: string;
38
- symbol: string;
39
- amount?: number;
40
- country_code?: string;
41
- }
42
-
43
- export interface Product {
44
- id: number;
45
- name: string;
46
- type: ProductType;
47
- promotion: {
48
- title?: string;
49
- sub_title?: string;
50
- };
51
- price: Price;
52
- sale_price?: Price;
53
- regular_price: Price;
54
- has_special_price: boolean;
55
- status: 'sale' | 'out';
56
- is_available: boolean;
57
- sku?: string;
58
- currency: string | 'SAR';
59
- url: string;
60
- thumbnail: string;
61
- calories?: number;
62
- }
63
-
64
- export interface Category {
65
- id: number;
66
- name: string;
67
- url: string;
68
- }
69
-
70
- export interface RequestInfo {
71
- endPoint: string;
72
- method: string;
73
- payload: any,
74
- options: {},
75
- }
@@ -1,18 +0,0 @@
1
- import {AuthResponse} from "../api/auth";
2
- import {RequestError, SuccessResponse} from "../common";
3
-
4
- export default interface AuthEvent {
5
- //Success Responses
6
- onCodeSent: (callback: (response: AuthResponse.loginOrResendCode, type?: 'mobile' | 'email') => void) => void;
7
- onVerified: (callback: (response: AuthResponse.verify, type?: 'mobile' | 'email') => void) => void;
8
- onRegistered: (callback: (response: AuthResponse.verify) => void) => void;
9
- onLoggedIn: (callback: (response: AuthResponse.verify) => void) => void;
10
- onLoggedOut: (callback: (response: SuccessResponse) => void) => void;
11
-
12
- //Error Responses
13
- onCodeNotSent: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
14
- onVerificationFailed: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
15
- onRegistrationFailed: (callback: (error: RequestError) => void) => void;
16
- onFailedLogout: (callback: (error: RequestError) => void) => void;
17
- onRefreshFailed: (callback: (error: RequestError) => void) => void;
18
- }
@@ -1,30 +0,0 @@
1
- import {CartResponse, CartSummary} from "../api/cart";
2
- import { RequestError, SuccessResponse} from "../common";
3
-
4
- export default interface CartEvent {
5
- // listeners
6
- onUpdated: (callback: (cart_summary: CartSummary) => void) => void;
7
- onItemAdded: (callback: (response: CartResponse.update, product_id: number) => void) => void;
8
- onItemUpdated: (callback: (response: CartResponse.update, product_id: number) => void) => void;
9
- onItemDeleted: (callback: (response: CartResponse.update, product_id: number) => void) => void;
10
- onLatestFetched: (callback: (response: CartResponse.update) => void) => void;
11
- onSubmitted: (callback: (response: CartResponse.status) => void) => void;
12
- onImageDeleted: (callback: (response: SuccessResponse, file_id: number) => void) => void;
13
- onDetailsFetched: (callback: (response: CartResponse.status) => void) => void;
14
- onSuccessReset: (callback: () => void) => void;
15
-
16
- //errors
17
- onLatestFailed: (callback: (error: RequestError) => void) => void;
18
- onItemUpdatedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
19
- onItemAddedFailed: (callback: (error: RequestError | 'There is no product "id"!', product_id?: number) => void) => void;
20
- onItemDeletedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
21
- onSubmitFailed: (callback: (error: RequestError | "Can't find next_step );") => void) => void;
22
- onImageNotDeleted: (callback: (error: RequestError | 'There is no "id"!', file_id?: number) => void) => void;
23
- onDetailsNotFetched: (callback: (error: RequestError) => void) => void;
24
-
25
- //coupons
26
- onCouponAdded: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
27
- onCouponDeleted: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
28
- onCouponAdditionFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
29
- onCouponDeletionFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
30
- }
@@ -1,7 +0,0 @@
1
- import {RequestErrorEventWithData} from "../common";
2
- import {AddCommentResponse} from "../api/comment";
3
-
4
- export default interface CommentEvent {
5
- onAdded: (callback: (response: AddCommentResponse) => void, /*product/page id*/ id:number) => void;
6
- onAdditionFailed: RequestErrorEventWithData</*product/page id*/number>;
7
- }
@@ -1,9 +0,0 @@
1
- import {ChangeCurrencyResponse, ListCurrenciesResponse} from "../api/currency";
2
- import {RequestErrorEvent} from "../common";
3
-
4
- export default interface CurrencyEvent {
5
- onChanged: (callback: (response: ChangeCurrencyResponse, currency: 'SAR' | string) => void) => void;
6
- onFetched: (callback: (response: ListCurrenciesResponse) => void) => void;
7
- onFailed: RequestErrorEvent;
8
- onFailedToFetch: RequestErrorEvent;
9
- }
@@ -1,29 +0,0 @@
1
- import {RequestError} from "../common";
2
-
3
- export interface requestPayload {
4
- namespace: string | 'cart';
5
- action: string | 'latest';
6
- hook: string | 'latest';
7
- url: string | 'cart/latest';
8
- payload: {} | { params: {} };
9
- method: 'get' | 'post' | 'put' | 'delete';
10
- headers?: {};
11
- }
12
-
13
-
14
- export default interface DocumentEvent {
15
- onClick: (selector: string | ((event) => void), callback?: (event) => void) => void;
16
- onChange: (selector: string | ((event) => void), callback?: (event) => void) => void;
17
- onSubmit: (selector: string | ((event) => void), callback?: (event) => void) => void;
18
- onKeyup: (selector: string | ((event) => void), callback?: (event) => void) => void;
19
- onLeaving: (event: BeforeUnloadEvent) => boolean; //return false to show alert 'Changes you made may not be saved.'
20
- onRequest: (payload: requestPayload) => void; //💡handy when there is need to prevent request by throwing an error `throw 'stop the request';`.
21
- onRequestFailed: (payload: requestPayload, error?: RequestError) => void;
22
- /**
23
- * Helper method to fake firing event on element, for
24
- * @example someInput.addEventListener("change",()=>{...});
25
- * we want to fire this event programmatically, we can do that by:
26
- * @example salla.document.event.fireEvent(someInput, 'change', {'bubbles': true})
27
- */
28
- fireEvent: (element: HTMLElement, eventName: 'click' | 'change' | string, payload: undefined | Object) => void;
29
- }
@@ -1,48 +0,0 @@
1
- import AuthEvent from "./auth";
2
- import CartEvent from "./cart";
3
- import OrderEvent from "./order";
4
- import RatingEvent from "./rating";
5
- import CommentEvent from "./comment";
6
- import LoyaltyEvent from "./loyalty";
7
- import ProductEvent from "./product";
8
- import ProfileEvent from "./profile";
9
- import CurrencyEvent from "./currency";
10
- import DocumentEvent from "./document";
11
- import WishlistEvent from "./wishlist";
12
- import InfiniteScrollEvent from "./infiniteScroll";
13
- import ScopeEvents from "./scope";
14
- import Emitter from "@salla.sa/base/types/event";
15
-
16
- export type event = (symbol | string);
17
-
18
- export {
19
- AuthEvent,
20
- CartEvent,
21
- OrderEvent,
22
- RatingEvent,
23
- CommentEvent,
24
- LoyaltyEvent,
25
- ProductEvent,
26
- ProfileEvent,
27
- CurrencyEvent,
28
- DocumentEvent,
29
- WishlistEvent,
30
- InfiniteScrollEvent,
31
- ScopeEvents,
32
- }
33
-
34
- export default interface TwilightEmitter extends Emitter {
35
- auth: AuthEvent;
36
- cart: CartEvent;
37
- order: OrderEvent;
38
- rating: RatingEvent;
39
- comment: CommentEvent;
40
- loyalty: LoyaltyEvent;
41
- product: ProductEvent;
42
- profile: ProfileEvent;
43
- currency: CurrencyEvent;
44
- document: DocumentEvent;
45
- wishlist: WishlistEvent;
46
- scope: ScopeEvents,
47
- infiniteScroll: InfiniteScrollEvent;
48
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * @see https://infinite-scroll.com/events.html
3
- */
4
- export default interface InfiniteScrollEvent {
5
- onScrollThreshold: (callback: (event: Event) => void) => void;
6
- onRequest: (callback: (event: Event, path: string, fetchPromise: Promise<any>) => void) => void;
7
- onLoad: (callback: (event: Event, body: Body, path: string, response: Response) => void) => void;
8
- onAppend: (callback: (event: Event, body: Body, path: string, items: NodeList, response: Response) => void) => void;
9
- onError: (callback: (event: Event, error: Error, path: string, response: Response) => void) => void;
10
- onLast: (callback: (event: Event, body: Body, path: string) => void) => void;
11
- onHistory: (callback: (event: Event, title: string, path: string) => void) => void;
12
- }
@@ -1,14 +0,0 @@
1
- import { RequestErrorEvent, SuccessResponse } from "../common";
2
- import { LoyaltyApiResponse } from '../api/loyalty'
3
-
4
- export default interface LoyaltyEvent {
5
-
6
- onProgramFetched: (callback: (response: LoyaltyApiResponse.program, prod_id: number) => void) => void;
7
- onProgramNotFetched: RequestErrorEvent;
8
- // Point
9
- onExchangeFetched: (callback: (response: LoyaltyApiResponse.point, prod_id: number) => void) => void;
10
- onExchangeFetchFailed: RequestErrorEvent;
11
- // Reset Exchange
12
- onResetSucceeded: (callback: (response: SuccessResponse) => void) => void;
13
- onResetFailed: RequestErrorEvent
14
- }
@@ -1,11 +0,0 @@
1
- import {RequestError, SuccessResponse} from "../common";
2
- import {CreateCartFromOrderResponse} from "../api/order";
3
-
4
- export default interface OrderEvent {
5
- onCanceled: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
6
- onNotCanceled: (callback: (error: RequestError, order_id?: number) => void) => void;
7
- onOrderCreated: (callback: (response: CreateCartFromOrderResponse, order_id?: number) => void) => void;
8
- onOrderCreationFailed: (callback: (error: RequestError, order_id?: number) => void) => void;
9
- onInvoiceSent: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
10
- onInvoiceNotSent: (callback: (error: RequestError | 'There is no id!', order_id?: number) => void) => void;
11
- }
@@ -1,30 +0,0 @@
1
- import { OfferSummary } from "../api/cart";
2
- import { ProductResponse } from "../api/product";
3
- import { RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse } from "../common";
4
-
5
- export default interface ProductEvent {
6
- onPriceUpdated: (callback: (response: ProductResponse.getPrice, product_id: number) => void) => void;
7
- onPriceUpdateFailed: RequestErrorEventWithData</*product_id*/ number>;
8
- onAvailabilitySubscribed: (callback: (response: SuccessResponse, product_id: number) => void) => void;
9
- onAvailabilitySubscribeFailed: RequestErrorEventWithData</*product_id*/ number>;
10
- onCategoriesFetched: (callback: (response: ProductResponse.categories) => void) => void;
11
- onCategoriesFailed: RequestError;
12
- onSearchResults: (callback: (response: ProductResponse.search, query?: string) => void) => void;
13
- onSearchFailed: RequestErrorEventWithData</*query*/string | undefined>;
14
-
15
- onOfferExisted: (callback: (offer: OfferSummary) => void) => void;
16
- onOffersFetched: (callback: (response: ProductResponse.offers) => void) => void;
17
- onFetchOffersFailed: RequestErrorEvent;
18
-
19
- onSizeGuideFetched: (callback: (response: ProductResponse.sizeGuides, prod_id: number) => void) => void;
20
- onSizeGuideFetchFailed: RequestErrorEvent;
21
-
22
- onGiftFetched: (callback: (response: ProductResponse.giftResponse, product_id: number) => void) => void;
23
- onGiftFetchFailed: RequestErrorEvent;
24
-
25
- onAddGiftToCartSucceeded: (callback: (response: ProductResponse.giftToCart, product_id: number) => void) => void;
26
- onAddGiftToCartFailed: RequestErrorEvent;
27
-
28
- onGiftImageUploadSucceeded: (callback: (response: ProductResponse.giftImageUpload) => void) => void;
29
- onGiftImageUploadFailed: RequestErrorEvent;
30
- }
@@ -1,19 +0,0 @@
1
- import { ProfileResponse } from "../api/profile";
2
- import { RequestErrorEvent, SuccessResponse } from "../common";
3
-
4
- export default interface ProfileEvent {
5
- onUpdated: (callback: (response: ProfileResponse) => void) => void;
6
- onVerified: (callback: (response: SuccessResponse) => void) => void;
7
- onVerificationCodeSent: (callback: (response: ProfileResponse) => void) => void; //should trigger action to fill verify code, then calling salla.profile.verify(...)
8
-
9
- //errors
10
- onUpdateFailed: RequestErrorEvent;
11
- onUnverified: RequestErrorEvent;
12
- onUpdateContactsFailed: RequestErrorEvent;
13
-
14
- onSettingsUpdated: (callback: (response: SuccessResponse) => void) => void;
15
- onUpdateSettingsFailed: RequestErrorEvent;
16
-
17
- onDeleted: (callback: (response: SuccessResponse) => void) => void;
18
- onNotDeleted: RequestErrorEvent;
19
- }
@@ -1,13 +0,0 @@
1
- import {OrderDetailsResponse, RatingStorePayload, RatingProductsPayload, RatingShippingPayload} from "../api/rating";
2
- import {RequestErrorEventWithData, SuccessResponse} from "../common";
3
-
4
- export default interface RatingEvent {
5
- onOrderFetched: (callback: (response: OrderDetailsResponse, order_id: number) => void) => void;
6
- onOrderNotFetched: RequestErrorEventWithData</*order_id*/number>;
7
- onStoreRated: (callback: (response: SuccessResponse, data: RatingStorePayload) => void) => void;
8
- onStoreFailed: RequestErrorEventWithData</*data*/RatingStorePayload>;
9
- onProductRated: (callback: (response: SuccessResponse, data: RatingProductsPayload) => void) => void;
10
- onProductFailed: RequestErrorEventWithData</*data*/RatingProductsPayload>;
11
- onShippingRated: (callback: (response: SuccessResponse, data: RatingShippingPayload) => void) => void;
12
- onShippingFailed: RequestErrorEventWithData</*data*/RatingShippingPayload>;
13
- }
@@ -1,15 +0,0 @@
1
- import { RequestErrorEvent } from "../common";
2
- import { ScopeApiResponse } from '../api/scope'
3
-
4
- export default interface ScopeEvents {
5
- onFetched: (callback: (response: ScopeApiResponse.scopeList) => void) => void;
6
- onNotFetched: RequestErrorEvent;
7
-
8
- // POST
9
- onChangeSucceeded: (callback: (response: ScopeApiResponse.scopeAddition) => void) => void;
10
- onChangeFailed: RequestErrorEvent;
11
-
12
- // Availability
13
- onProductAvailabilityFetched: (callback: (response: ScopeApiResponse.availability, product_id: number) => void) => void;
14
- onProductAvailabilityNotFetched: RequestErrorEvent;
15
- }
@@ -1,8 +0,0 @@
1
- import {RequestErrorEventWithData, SuccessResponse} from "../common";
2
-
3
- export default interface WishlistEvent {
4
- onAdded: (callback: (response: SuccessResponse, product_id: number) => void) => void;
5
- onRemoved: (callback: (response: SuccessResponse, product_id: number) => void) => void;
6
- onAdditionFailed: RequestErrorEventWithData</*product_id*/number>;
7
- onRemovingFailed: RequestErrorEventWithData</*product_id*/number>;
8
- }
@@ -1,29 +0,0 @@
1
- type ElementOrSelector = string | HTMLElement;
2
- type EventTypes = 'click' | 'keyup' | 'input' | 'change' | string;
3
- export default interface AppHelpers {
4
- toggleClassIf: (selector: string, classes1: string | Array<string>, classes2: string | Array<string>, callback: (element: HTMLElement) => boolean) => AppHelpers;
5
- toggleElementClassIf: (element: HTMLElement, classes1: string | Array<string>, classes2: string | Array<string>, callback: (element: HTMLElement) => boolean) => AppHelpers;
6
-
7
- isValidEmail: (email: string) => boolean;
8
-
9
- element: (selector: ElementOrSelector) => HTMLElement | undefined;
10
- watchElement: (name: string, selector: ElementOrSelector) => AppHelpers;
11
- watchElements: (elements: { [key: string]: [value: ElementOrSelector] }) => AppHelpers;
12
- hideElement: (element: ElementOrSelector) => AppHelpers;
13
- showElement: (element: ElementOrSelector) => AppHelpers;
14
- //💡 you can pass one or multi classes: this.removeClass(element, 'class_1', 'class_2', ...)
15
- removeClass: (element: ElementOrSelector, ...className: string[]) => AppHelpers;
16
- addClass: (element: ElementOrSelector, ...className: string[]) => AppHelpers;
17
- //💡instead of: `document.querySelectorAll('.test').forEach(element=>{...})`
18
- // you can use: `this.all('.test', element=>{...})`
19
- all: (element: ElementOrSelector, callback: (element: HTMLElement) => void) => AppHelpers;
20
-
21
- //💡instead of: `document.querySelectorAll('.test').forEach(el => el.addEventListener('keyup', callback));`
22
- // you can use: `this.on('.test', 'keyup', callback)`
23
- // or can use: `this.onKeyUp('.test', callback)`
24
- on: (eventType: EventTypes, element: ElementOrSelector, callback: EventListener, options?: AddEventListenerOptions) => AppHelpers;
25
- onClick: (element: ElementOrSelector, callback: EventListener) => AppHelpers;
26
- onKeyUp: (element: ElementOrSelector, callback: EventListener) => AppHelpers;
27
- onEnter: (element: ElementOrSelector, callback: EventListener) => AppHelpers;
28
- debounce: (callback: () => unknown) => (...data: any | undefined) => Promise<unknown>
29
- }