@ikas/storefront 0.1.15 → 0.1.17

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.
@@ -35,6 +35,7 @@ export interface Props {
35
35
  autocomplete?: string;
36
36
  tooltipText?: string;
37
37
  country?: string | null;
38
+ currentCountryCode?: string | null;
38
39
  style?: React.CSSProperties;
39
40
  textAreaPlaceholder?: string | null;
40
41
  rightContent?: React.ReactElement | null;
package/build/index.es.js CHANGED
@@ -39381,6 +39381,8 @@ var PhoneRule = /** @class */ (function (_super) {
39381
39381
  return __awaiter(this, void 0, void 0, function () {
39382
39382
  var result;
39383
39383
  return __generator(this, function (_a) {
39384
+ if (!this.value)
39385
+ return [2 /*return*/, true];
39384
39386
  result = this.value.match(/\d/g);
39385
39387
  return [2 /*return*/, ((!!result && result.length <= 11) || !!/^\+(\d{12})$/gm.test(this.value))];
39386
39388
  });
@@ -68372,10 +68374,8 @@ function (_React$Component) {
68372
68374
  }), _defineProperty$a(_class2, "supportedWrappers", ['div', 'span']), _defineProperty$a(_class2, "displayName", 'ReactTooltip'), _temp)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
68373
68375
 
68374
68376
  var FormItem = observer(function (props) {
68375
- var _a;
68376
68377
  var t = useTranslation().t;
68377
- var _b = useState(function () { return new FormItemViewModel(props); }), vm = _b[0], setVM = _b[1];
68378
- var store = IkasStorefrontConfig.store;
68378
+ var _a = useState(function () { return new FormItemViewModel(props); }), vm = _a[0], setVM = _a[1];
68379
68379
  useEffect(function () {
68380
68380
  ReactTooltip.rebuild();
68381
68381
  }, []);
@@ -68440,18 +68440,15 @@ var FormItem = observer(function (props) {
68440
68440
  });
68441
68441
  }, [props.onChange]);
68442
68442
  useEffect(function () {
68443
- vm.country = store.currentCountryCode;
68444
- }, [store.currentCountryCode]);
68445
- var currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
68443
+ if (!vm.country)
68444
+ vm.country = props.currentCountryCode;
68445
+ }, [props.currentCountryCode]);
68446
68446
  return (createElement("div", { className: vm.formItemStyle, style: props.style },
68447
68447
  createElement("div", { className: styles.FormItemWrapper },
68448
68448
  createElement("div", { className: styles.FormItemInputWrapper },
68449
68449
  createElement("label", { className: vm.labelStyle }, vm.label),
68450
68450
  vm.type === FormItemType.TEXT && (createElement(Input$2, { vm: vm, autocomplete: props.autocomplete, name: props.name })),
68451
- vm.type === FormItemType.TEL && (createElement(PhoneInput, { defaultCountry: vm.country ||
68452
- (!!((_a = currentRouting === null || currentRouting === void 0 ? void 0 : currentRouting.countryCodes) === null || _a === void 0 ? void 0 : _a.length)
68453
- ? currentRouting.countryCodes[0]
68454
- : "TR"), placeholder: t("checkout-page:enterPhoneNumber"), value: vm.value ? vm.value : "", onChange: vm.onPhoneChange, international: true, addInternationalOption: false })),
68451
+ vm.type === FormItemType.TEL && (createElement(PhoneInput, { defaultCountry: props.currentCountryCode, placeholder: t("checkout-page:enterPhoneNumber"), value: vm.value ? vm.value : "", onChange: vm.onPhoneChange, international: true, addInternationalOption: false })),
68455
68452
  vm.type === FormItemType.TEXT_AREA && createElement(TextArea, { vm: vm }),
68456
68453
  vm.type === FormItemType.SELECT && (createElement(Select, { vm: vm, autocomplete: props.autocomplete }))),
68457
68454
  !!vm.hasError && (createElement("div", { className: styles.ErrorMsg }, vm.errorText || "")),
@@ -69204,7 +69201,7 @@ var Phone = observer(function (_a) {
69204
69201
  var _b;
69205
69202
  var vm = _a.vm;
69206
69203
  var t = useTranslation().t;
69207
- return (createElement(FormItem, { type: FormItemType.TEL, inputType: FormItemInputType.TEL, label: t("checkout-page:phone"), autocomplete: "tel", value: vm.phone || "", onChange: vm.onPhoneChange, hasError: vm.isErrorsVisible && !((_b = vm.address.validationResult) === null || _b === void 0 ? void 0 : _b.phone), errorText: t("checkout-page:phoneError") }));
69204
+ return (createElement(FormItem, { type: FormItemType.TEL, inputType: FormItemInputType.TEL, label: t("checkout-page:phone"), autocomplete: "tel", value: vm.phone || "", onChange: vm.onPhoneChange, hasError: vm.isErrorsVisible && !((_b = vm.address.validationResult) === null || _b === void 0 ? void 0 : _b.phone), currentCountryCode: vm.myCountryCode, errorText: t("checkout-page:phoneError") }));
69208
69205
  });
69209
69206
  var Company = observer(function (_a) {
69210
69207
  var vm = _a.vm;
package/build/index.js CHANGED
@@ -39360,6 +39360,8 @@ var PhoneRule = /** @class */ (function (_super) {
39360
39360
  return __awaiter(this, void 0, void 0, function () {
39361
39361
  var result;
39362
39362
  return __generator(this, function (_a) {
39363
+ if (!this.value)
39364
+ return [2 /*return*/, true];
39363
39365
  result = this.value.match(/\d/g);
39364
39366
  return [2 /*return*/, ((!!result && result.length <= 11) || !!/^\+(\d{12})$/gm.test(this.value))];
39365
39367
  });
@@ -68351,10 +68353,8 @@ function (_React$Component) {
68351
68353
  }), _defineProperty$a(_class2, "supportedWrappers", ['div', 'span']), _defineProperty$a(_class2, "displayName", 'ReactTooltip'), _temp)) || _class) || _class) || _class) || _class) || _class) || _class) || _class;
68352
68354
 
68353
68355
  var FormItem = mobxReactLite.observer(function (props) {
68354
- var _a;
68355
68356
  var t = useTranslation().t;
68356
- var _b = React.useState(function () { return new FormItemViewModel(props); }), vm = _b[0], setVM = _b[1];
68357
- var store = IkasStorefrontConfig.store;
68357
+ var _a = React.useState(function () { return new FormItemViewModel(props); }), vm = _a[0], setVM = _a[1];
68358
68358
  React.useEffect(function () {
68359
68359
  ReactTooltip.rebuild();
68360
68360
  }, []);
@@ -68419,18 +68419,15 @@ var FormItem = mobxReactLite.observer(function (props) {
68419
68419
  });
68420
68420
  }, [props.onChange]);
68421
68421
  React.useEffect(function () {
68422
- vm.country = store.currentCountryCode;
68423
- }, [store.currentCountryCode]);
68424
- var currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
68422
+ if (!vm.country)
68423
+ vm.country = props.currentCountryCode;
68424
+ }, [props.currentCountryCode]);
68425
68425
  return (React.createElement("div", { className: vm.formItemStyle, style: props.style },
68426
68426
  React.createElement("div", { className: styles.FormItemWrapper },
68427
68427
  React.createElement("div", { className: styles.FormItemInputWrapper },
68428
68428
  React.createElement("label", { className: vm.labelStyle }, vm.label),
68429
68429
  vm.type === FormItemType.TEXT && (React.createElement(Input$2, { vm: vm, autocomplete: props.autocomplete, name: props.name })),
68430
- vm.type === FormItemType.TEL && (React.createElement(PhoneInput, { defaultCountry: vm.country ||
68431
- (!!((_a = currentRouting === null || currentRouting === void 0 ? void 0 : currentRouting.countryCodes) === null || _a === void 0 ? void 0 : _a.length)
68432
- ? currentRouting.countryCodes[0]
68433
- : "TR"), placeholder: t("checkout-page:enterPhoneNumber"), value: vm.value ? vm.value : "", onChange: vm.onPhoneChange, international: true, addInternationalOption: false })),
68430
+ vm.type === FormItemType.TEL && (React.createElement(PhoneInput, { defaultCountry: props.currentCountryCode, placeholder: t("checkout-page:enterPhoneNumber"), value: vm.value ? vm.value : "", onChange: vm.onPhoneChange, international: true, addInternationalOption: false })),
68434
68431
  vm.type === FormItemType.TEXT_AREA && React.createElement(TextArea, { vm: vm }),
68435
68432
  vm.type === FormItemType.SELECT && (React.createElement(Select, { vm: vm, autocomplete: props.autocomplete }))),
68436
68433
  !!vm.hasError && (React.createElement("div", { className: styles.ErrorMsg }, vm.errorText || "")),
@@ -69183,7 +69180,7 @@ var Phone = mobxReactLite.observer(function (_a) {
69183
69180
  var _b;
69184
69181
  var vm = _a.vm;
69185
69182
  var t = useTranslation().t;
69186
- return (React.createElement(FormItem, { type: FormItemType.TEL, inputType: FormItemInputType.TEL, label: t("checkout-page:phone"), autocomplete: "tel", value: vm.phone || "", onChange: vm.onPhoneChange, hasError: vm.isErrorsVisible && !((_b = vm.address.validationResult) === null || _b === void 0 ? void 0 : _b.phone), errorText: t("checkout-page:phoneError") }));
69183
+ return (React.createElement(FormItem, { type: FormItemType.TEL, inputType: FormItemInputType.TEL, label: t("checkout-page:phone"), autocomplete: "tel", value: vm.phone || "", onChange: vm.onPhoneChange, hasError: vm.isErrorsVisible && !((_b = vm.address.validationResult) === null || _b === void 0 ? void 0 : _b.phone), currentCountryCode: vm.myCountryCode, errorText: t("checkout-page:phoneError") }));
69187
69184
  });
69188
69185
  var Company = mobxReactLite.observer(function (_a) {
69189
69186
  var vm = _a.vm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",