@ikas/storefront-model-functions 4.0.0-alpha.10

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 (30) hide show
  1. package/package.json +39 -0
  2. package/src/functions/blog/category/index.ts +6 -0
  3. package/src/functions/blog/index.ts +6 -0
  4. package/src/functions/brand/index.ts +6 -0
  5. package/src/functions/category/index.ts +6 -0
  6. package/src/functions/category/path-item/index.ts +15 -0
  7. package/src/functions/checkout/index.ts +35 -0
  8. package/src/functions/customer/address/index.ts +90 -0
  9. package/src/functions/customer/attribute/index.ts +18 -0
  10. package/src/functions/customer/index.ts +23 -0
  11. package/src/functions/filter-category/index.ts +6 -0
  12. package/src/functions/image/index.ts +27 -0
  13. package/src/functions/order/address/index.ts +110 -0
  14. package/src/functions/order/index.ts +92 -0
  15. package/src/functions/order/line-item/index.ts +30 -0
  16. package/src/functions/order/line-item/variant/index.ts +15 -0
  17. package/src/functions/order/line-item/variant/value/index.ts +18 -0
  18. package/src/functions/payment-gateway/index.ts +44 -0
  19. package/src/functions/product/attribute-value/index.ts +5 -0
  20. package/src/functions/product/filter/index.ts +197 -0
  21. package/src/functions/product/index.ts +145 -0
  22. package/src/functions/product/option-set/index.ts +19 -0
  23. package/src/functions/product/option-set/option/index.ts +189 -0
  24. package/src/functions/product/variant/index.ts +9 -0
  25. package/src/functions/product/variant/price/index.ts +20 -0
  26. package/src/functions/raffle/index.ts +14 -0
  27. package/src/functions/variant-type/index.ts +13 -0
  28. package/src/functions/variant-type/variant-value/index.ts +13 -0
  29. package/src/index.ts +107 -0
  30. package/src/utils/helper.ts +59 -0
package/src/index.ts ADDED
@@ -0,0 +1,107 @@
1
+ // BLOG-CATEGORY
2
+ import * as IkasBlogCategoryFunctions from "./functions/blog/category";
3
+ export { IkasBlogCategoryFunctions };
4
+
5
+ // BLOG
6
+ import * as IkasBlogFunctions from "./functions/blog";
7
+ export { IkasBlogFunctions };
8
+
9
+ // BRAND
10
+ import * as IkasBrandFunctions from "./functions/brand";
11
+ export { IkasBrandFunctions };
12
+
13
+ // CATEGORY-PATH-ITEM
14
+ import * as IkasCategoryPathItemFunctions from "./functions/category/path-item";
15
+ export { IkasCategoryPathItemFunctions };
16
+
17
+ // CATEGORY
18
+ import * as IkasCategoryFunctions from "./functions/category";
19
+ export { IkasCategoryFunctions };
20
+
21
+ // CHECKOUT
22
+ import * as IkasCheckoutFunctions from "./functions/checkout";
23
+ export { IkasCheckoutFunctions };
24
+
25
+ // CUSTOMER-ADDRESS
26
+ import * as IkasCustomerAddressFunctions from "./functions/customer/address";
27
+ export { IkasCustomerAddressFunctions };
28
+
29
+ // CUSTOMER-ATTRIBUTE
30
+ import * as IkasCustomerAttributeFunctions from "./functions/customer/attribute";
31
+ export { IkasCustomerAttributeFunctions };
32
+
33
+ // CUSTOMER
34
+ import * as IkasCustomerFunctions from "./functions/customer";
35
+ export { IkasCustomerFunctions };
36
+
37
+ // FILTER-CATEGORY
38
+ import * as IkasFilterCategoryFunctions from "./functions/filter-category";
39
+ export { IkasFilterCategoryFunctions };
40
+
41
+ // IMAGE
42
+ import * as IkasImageFunctions from "./functions/image";
43
+ export { IkasImageFunctions };
44
+
45
+ // ORDER-ADDRESS
46
+ import * as IkasOrderAddressFunctions from "./functions/order/address";
47
+ export { IkasOrderAddressFunctions };
48
+
49
+ // ORDER-LINE-ITEM-VARIANT-VALUE
50
+ import * as IkasOrderLineItemVariantValueFunctions from "./functions/order/line-item/variant/value";
51
+ export { IkasOrderLineItemVariantValueFunctions };
52
+
53
+ // ORDER-LINE-ITEM-VARIANT
54
+ import * as IkasOrderLineItemVariantFunctions from "./functions/order/line-item/variant";
55
+ export { IkasOrderLineItemVariantFunctions };
56
+
57
+ // ORDER-LINE-ITEM
58
+ import * as IkasOrderLineItemFunctions from "./functions/order/line-item";
59
+ export { IkasOrderLineItemFunctions };
60
+
61
+ // ORDER
62
+ import * as IkasOrderFunctions from "./functions/order";
63
+ export { IkasOrderFunctions };
64
+
65
+ // PAYMENT-GATEWAY
66
+ import * as IkasPaymentGatewayFunctions from "./functions/payment-gateway";
67
+ export { IkasPaymentGatewayFunctions };
68
+
69
+ // PRODUCT-ATTRIBUTE-VALUE
70
+ import * as IkasProductAttributeValueFunctions from "./functions/product/attribute-value";
71
+ export { IkasProductAttributeValueFunctions };
72
+
73
+ // PRODUCT-FILTER
74
+ import * as IkasProductFilterFunctions from "./functions/product/filter";
75
+ export { IkasProductFilterFunctions };
76
+
77
+ // PRODUCT-OPTION
78
+ import * as IkasProductOptionFunctions from "./functions/product/option-set/option";
79
+ export { IkasProductOptionFunctions };
80
+
81
+ // PRODUCT-OPTION-SET
82
+ import * as IkasProductOptionSetFunctions from "./functions/product/option-set";
83
+ export { IkasProductOptionSetFunctions };
84
+
85
+ // PRODUCT-PRICE
86
+ import * as IkasProductPriceFunctions from "./functions/product/variant/price";
87
+ export { IkasProductPriceFunctions };
88
+
89
+ // PRODUCT-VARIANT
90
+ import * as IkasProductVariantFunctions from "./functions/product/variant";
91
+ export { IkasProductVariantFunctions };
92
+
93
+ // PRODUCT
94
+ import * as IkasProductFunctions from "./functions/product";
95
+ export { IkasProductFunctions };
96
+
97
+ // RAFFLE
98
+ import * as IkasRaffleFunctions from "./functions/raffle";
99
+ export { IkasRaffleFunctions };
100
+
101
+ // VARIANT-VALUE
102
+ import * as IkasVariantValueFunctions from "./functions/variant-type/variant-value";
103
+ export { IkasVariantValueFunctions };
104
+
105
+ // VARIANT-TYPE
106
+ import * as IkasVariantTypeFunctions from "./functions/variant-type";
107
+ export { IkasVariantTypeFunctions };
@@ -0,0 +1,59 @@
1
+ import { IkasStorefrontConfig } from "@ikas/storefront-config";
2
+
3
+ export const validatePhoneNumber = (str: string) => {
4
+ const regex = /^\+?\d+$/;
5
+ return regex.test(str);
6
+ };
7
+
8
+ export const stringToSlug = (str: string) => {
9
+ str = str.replace(/^\s+|\s+$/g, ""); // trim
10
+ str = str.toLocaleLowerCase("tr-TR");
11
+
12
+ // remove accents, swap ñ for n, etc
13
+ const from = "àáäâèéëêìíïîıòóöôùúüûñçşğ·/_,:;";
14
+ const to = "aaaaeeeeiiiiioooouuuuncsg------";
15
+ for (let i = 0, l = from.length; i < l; i++) {
16
+ str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
17
+ }
18
+
19
+ str = str
20
+ .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
21
+ .replace(/\s+/g, "-") // collapse whitespace and replace by -
22
+ .replace(/-+/g, "-"); // collapse dashes
23
+
24
+ return str;
25
+ };
26
+
27
+ export function formatDate(date: Date) {
28
+ const options: Intl.DateTimeFormatOptions = {
29
+ year: "numeric",
30
+ month: "long",
31
+ day: "numeric",
32
+ hour: "numeric",
33
+ minute: "numeric",
34
+ hour12: false,
35
+ };
36
+ const locale = IkasStorefrontConfig.getCurrentLocale();
37
+
38
+ function is12Hour(locale: string) {
39
+ return !!new Intl.DateTimeFormat(locale, { hour: "numeric" })
40
+ .format(0)
41
+ .match(/\s/);
42
+ }
43
+
44
+ if (typeof navigator !== "undefined") {
45
+ options.hour12 = is12Hour(navigator.language);
46
+ } else {
47
+ options.hour12 = is12Hour(locale);
48
+ }
49
+
50
+ return new Intl.DateTimeFormat(locale, options).format(date);
51
+ }
52
+
53
+ export const validateEmail = (str: string) => {
54
+ const matcher =
55
+ /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
56
+
57
+ if (str.length > 320) return false;
58
+ return matcher.test(str);
59
+ };