@ikas/storefront 0.0.167-alpha.4 → 0.0.167-alpha.6

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/build/index.es.js CHANGED
@@ -41470,18 +41470,14 @@ var IkasPage = observer(function (_a) {
41470
41470
  IkasStorefrontConfig.initWithJson(configJson);
41471
41471
  var store = IkasStorefrontConfig.store;
41472
41472
  var router = useRouter();
41473
- var _b = useState(false), mounted = _b[0], setMounted = _b[1];
41474
- var _c = useState(false), isBrowser = _c[0], setIsBrowser = _c[1];
41473
+ var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
41475
41474
  var settings = useState(new IkasThemeSettings(JSON.parse(settingsStr)))[0];
41476
- var _d = useState(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr)), propValues = _d[0], setPropValues = _d[1];
41475
+ var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr)), propValues = _c[0], setPropValues = _c[1];
41477
41476
  store.currentPageType = pageType;
41478
41477
  useEffect(function () {
41479
- //@ts-ignore
41480
- store.setSettings(settingsStr);
41481
41478
  //@ts-ignore
41482
41479
  store.cartStore.getCart();
41483
41480
  store.checkLocalization();
41484
- setMounted(true);
41485
41481
  }, []);
41486
41482
  useEffect(function () {
41487
41483
  if (reInitOnBrowser)
@@ -41495,7 +41491,6 @@ var IkasPage = observer(function (_a) {
41495
41491
  var footerComponentPropValue = propValues.find(function (pv) { return pv.component.isFooter; });
41496
41492
  var others = propValues.filter(function (pv) { return !pv.component.isHeader && !pv.component.isFooter; }) || [];
41497
41493
  var pageStyle = {
41498
- visibility: mounted ? "visible" : "hidden",
41499
41494
  position: "relative",
41500
41495
  minHeight: "100vh",
41501
41496
  display: "flex",
@@ -69921,6 +69916,7 @@ var ThemeEditorComponent = observer(function (_a) {
69921
69916
  }),
69922
69917
  }),
69923
69918
  checkoutSettings: new IkasCheckoutSettings(),
69919
+ merchantSettings: null,
69924
69920
  customizationProps: __assign({}, propValues),
69925
69921
  returnPolicy: "",
69926
69922
  privacyPolicy: "",
@@ -70129,7 +70125,7 @@ var SettingsHelper = /** @class */ (function () {
70129
70125
  SettingsHelper.getSettings = function (locale) {
70130
70126
  var _this = this;
70131
70127
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
70132
- var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70128
+ var isLocal, storefrontResponse, storefront, localTheme, colorScript, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70133
70129
  return __generator(this, function (_a) {
70134
70130
  switch (_a.label) {
70135
70131
  case 0:
@@ -70148,6 +70144,7 @@ var SettingsHelper = /** @class */ (function () {
70148
70144
  return [4 /*yield*/, SettingsHelper.readLocalTheme()];
70149
70145
  case 2:
70150
70146
  localTheme = _a.sent();
70147
+ colorScript = SettingsHelper.createColorScript(localTheme.settings);
70151
70148
  resolve({
70152
70149
  storefront: storefront,
70153
70150
  themeLocalization: new IkasStorefrontThemeLocalization({
@@ -70162,7 +70159,7 @@ var SettingsHelper = /** @class */ (function () {
70162
70159
  : new IkasStorefrontRouting({}),
70163
70160
  favicon: localTheme.settings.favicon,
70164
70161
  stockPreference: localTheme.settings.stockPreference,
70165
- storefrontJSScripts: [],
70162
+ storefrontJSScripts: colorScript ? [colorScript] : [],
70166
70163
  domain: "",
70167
70164
  });
70168
70165
  return [3 /*break*/, 5];
@@ -70194,6 +70191,11 @@ var SettingsHelper = /** @class */ (function () {
70194
70191
  var themeLocalization = new IkasStorefrontThemeLocalization(result);
70195
70192
  var favicon = themeLocalization.themeJson.settings.favicon;
70196
70193
  var stockPreference = themeLocalization.themeJson.settings.stockPreference;
70194
+ if (themeLocalization.themeJson.settings) {
70195
+ var colorScript = SettingsHelper.createColorScript(themeLocalization.themeJson.settings);
70196
+ if (colorScript)
70197
+ storefrontJSScripts_1.push(colorScript);
70198
+ }
70197
70199
  resolve({
70198
70200
  storefront: storefront_1,
70199
70201
  themeLocalization: themeLocalization,
@@ -70354,6 +70356,13 @@ var SettingsHelper = /** @class */ (function () {
70354
70356
  });
70355
70357
  });
70356
70358
  };
70359
+ SettingsHelper.createColorScript = function (settings) {
70360
+ if (!settings.colors)
70361
+ return;
70362
+ return "\n <script>\n " + settings.colors.map(function (sc) {
70363
+ return "document.documentElement.style.setProperty(\"" + sc.key + "\", \"" + sc.color + "\");";
70364
+ }) + "\n </script> \n ";
70365
+ };
70357
70366
  return SettingsHelper;
70358
70367
  }());
70359
70368
 
package/build/index.js CHANGED
@@ -41450,18 +41450,14 @@ var IkasPage = mobxReactLite.observer(function (_a) {
41450
41450
  IkasStorefrontConfig.initWithJson(configJson);
41451
41451
  var store = IkasStorefrontConfig.store;
41452
41452
  var router$1 = router.useRouter();
41453
- var _b = React.useState(false), mounted = _b[0], setMounted = _b[1];
41454
- var _c = React.useState(false), isBrowser = _c[0], setIsBrowser = _c[1];
41453
+ var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
41455
41454
  var settings = React.useState(new IkasThemeSettings(JSON.parse(settingsStr)))[0];
41456
- var _d = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr)), propValues = _d[0], setPropValues = _d[1];
41455
+ var _c = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr)), propValues = _c[0], setPropValues = _c[1];
41457
41456
  store.currentPageType = pageType;
41458
41457
  React.useEffect(function () {
41459
- //@ts-ignore
41460
- store.setSettings(settingsStr);
41461
41458
  //@ts-ignore
41462
41459
  store.cartStore.getCart();
41463
41460
  store.checkLocalization();
41464
- setMounted(true);
41465
41461
  }, []);
41466
41462
  React.useEffect(function () {
41467
41463
  if (reInitOnBrowser)
@@ -41475,7 +41471,6 @@ var IkasPage = mobxReactLite.observer(function (_a) {
41475
41471
  var footerComponentPropValue = propValues.find(function (pv) { return pv.component.isFooter; });
41476
41472
  var others = propValues.filter(function (pv) { return !pv.component.isHeader && !pv.component.isFooter; }) || [];
41477
41473
  var pageStyle = {
41478
- visibility: mounted ? "visible" : "hidden",
41479
41474
  position: "relative",
41480
41475
  minHeight: "100vh",
41481
41476
  display: "flex",
@@ -69900,6 +69895,7 @@ var ThemeEditorComponent = mobxReactLite.observer(function (_a) {
69900
69895
  }),
69901
69896
  }),
69902
69897
  checkoutSettings: new IkasCheckoutSettings(),
69898
+ merchantSettings: null,
69903
69899
  customizationProps: __assign({}, propValues),
69904
69900
  returnPolicy: "",
69905
69901
  privacyPolicy: "",
@@ -70108,7 +70104,7 @@ var SettingsHelper = /** @class */ (function () {
70108
70104
  SettingsHelper.getSettings = function (locale) {
70109
70105
  var _this = this;
70110
70106
  return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
70111
- var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70107
+ var isLocal, storefrontResponse, storefront, localTheme, colorScript, settings, storefront_1, salesChannel_1, localizationMap, storefrontJSScripts_1, domain_1, themeLocalizationPath, routing_1;
70112
70108
  return __generator(this, function (_a) {
70113
70109
  switch (_a.label) {
70114
70110
  case 0:
@@ -70127,6 +70123,7 @@ var SettingsHelper = /** @class */ (function () {
70127
70123
  return [4 /*yield*/, SettingsHelper.readLocalTheme()];
70128
70124
  case 2:
70129
70125
  localTheme = _a.sent();
70126
+ colorScript = SettingsHelper.createColorScript(localTheme.settings);
70130
70127
  resolve({
70131
70128
  storefront: storefront,
70132
70129
  themeLocalization: new IkasStorefrontThemeLocalization({
@@ -70141,7 +70138,7 @@ var SettingsHelper = /** @class */ (function () {
70141
70138
  : new IkasStorefrontRouting({}),
70142
70139
  favicon: localTheme.settings.favicon,
70143
70140
  stockPreference: localTheme.settings.stockPreference,
70144
- storefrontJSScripts: [],
70141
+ storefrontJSScripts: colorScript ? [colorScript] : [],
70145
70142
  domain: "",
70146
70143
  });
70147
70144
  return [3 /*break*/, 5];
@@ -70173,6 +70170,11 @@ var SettingsHelper = /** @class */ (function () {
70173
70170
  var themeLocalization = new IkasStorefrontThemeLocalization(result);
70174
70171
  var favicon = themeLocalization.themeJson.settings.favicon;
70175
70172
  var stockPreference = themeLocalization.themeJson.settings.stockPreference;
70173
+ if (themeLocalization.themeJson.settings) {
70174
+ var colorScript = SettingsHelper.createColorScript(themeLocalization.themeJson.settings);
70175
+ if (colorScript)
70176
+ storefrontJSScripts_1.push(colorScript);
70177
+ }
70176
70178
  resolve({
70177
70179
  storefront: storefront_1,
70178
70180
  themeLocalization: themeLocalization,
@@ -70333,6 +70335,13 @@ var SettingsHelper = /** @class */ (function () {
70333
70335
  });
70334
70336
  });
70335
70337
  };
70338
+ SettingsHelper.createColorScript = function (settings) {
70339
+ if (!settings.colors)
70340
+ return;
70341
+ return "\n <script>\n " + settings.colors.map(function (sc) {
70342
+ return "document.documentElement.style.setProperty(\"" + sc.key + "\", \"" + sc.color + "\");";
70343
+ }) + "\n </script> \n ";
70344
+ };
70336
70345
  return SettingsHelper;
70337
70346
  }());
70338
70347
 
@@ -7,7 +7,7 @@ import { IkasSalesChannel } from "../models/data/sales-channel/index";
7
7
  import { IkasStorefrontRouting } from "../models/data/storefront/routing/index";
8
8
  import { IkasStorefrontThemeLocalization } from "../models/data/storefront/theme-localization/index";
9
9
  import { IkasThemeFavicon } from "../models/theme/settings/prop/favicon/index";
10
- import { IkasThemeStockPreference } from "../models/theme/settings/index";
10
+ import { IkasThemeSettings, IkasThemeStockPreference } from "../models/theme/settings/index";
11
11
  export declare class SettingsHelper {
12
12
  static readLocalTheme(): Promise<IkasTheme>;
13
13
  static readSettingsFile(): Promise<any>;
@@ -213,6 +213,7 @@ export declare class SettingsHelper {
213
213
  notFound?: undefined;
214
214
  revalidate?: undefined;
215
215
  }>;
216
+ static createColorScript(settings: IkasThemeSettings): string | undefined;
216
217
  }
217
218
  export declare type SettingsData = {
218
219
  storefront: IkasStorefront;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.167-alpha.4",
3
+ "version": "0.0.167-alpha.6",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",