Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dotdev/next-components

Package Overview
Dependencies
Maintainers
7
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dotdev/next-components - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

dist/utils/format-day-number.d.ts

7

dist/bootstrap.js

@@ -29,2 +29,3 @@ "use strict";

var ReactDom = require("react-dom");
var root_1 = require("react-hot-loader/root");
var react_router_dom_1 = require("react-router-dom");

@@ -39,3 +40,3 @@ var provider_1 = require("./provider");

var _this = this;
return (React.createElement(react_router_dom_1.BrowserRouter, null,
return this.props.data.template.name === "404" ? (React.createElement(this.props.templates.notFound, __assign({}, this.props))) : (React.createElement(react_router_dom_1.BrowserRouter, null,
React.createElement(react_router_dom_1.Switch, null,

@@ -69,4 +70,4 @@ React.createElement(react_router_dom_1.Route, { exact: true, path: "/", render: function (props) { return (React.createElement(_this.props.templates.home, __assign({}, props, _this.props))); } }),

Bootstrap.bootstrap = function (element, templates, sections, data) {
ReactDom.render(React.createElement(provider_1.ThemeProvider, { value: { cart: null, error: null } },
React.createElement(Bootstrap, { templates: templates, sections: sections, data: data })), document.getElementById(element));
root_1.hot(ReactDom.render(React.createElement(provider_1.ThemeProvider, { value: { cart: null, error: null } },
React.createElement(Bootstrap, { templates: templates, sections: sections, data: data })), document.getElementById(element)));
};

@@ -73,0 +74,0 @@ Bootstrap.element = function (templates, sections, data) {

@@ -45,3 +45,3 @@ "use strict";

settings: fields,
blocks: blocks.length
blocks: blocks
? blocks.map(function (block, i) { return ({

@@ -72,3 +72,3 @@ id: i,

return (React.createElement("main", { className: this.props.className }, this.sections(this.props.dtkSections
? this.transform(this.props.dtkSections)
? this.transform(this.props.dtkSections.slice())
: this.props.data.sections)));

@@ -75,0 +75,0 @@ };

@@ -28,3 +28,9 @@ "use strict";

? this.props.data.fields.map(function (field, i) {
return (React.createElement("input", { key: i, name: field.name, type: field.type, value: field.value }));
var value = false;
if (field.name === "checkout_url") {
var element = document.getElementsByName("checkout_url");
//@ts-ignore
value = element ? element[0].value : false;
}
return (React.createElement("input", { key: i, name: field.name, type: field.type, value: value ? value : field.value }));
})

@@ -31,0 +37,0 @@ : null,

@@ -8,3 +8,3 @@ export declare class Cart {

getCartJSON: () => void;
addItem: (id: number, qty: number) => Promise<void>;
addItem: (id: number, qty: number, properties?: any) => Promise<void>;
removeItem: (key: string) => Promise<void>;

@@ -14,4 +14,8 @@ updateQty: (key: string, qty: number) => Promise<void>;

getCart: () => Promise<void>;
updateNote: (note: string) => Promise<void>;
clearNote: () => Promise<void>;
clearCart: () => Promise<void>;
getShippingRates: () => Promise<void>;
getShippingRates: (country: string, postcode: string) => Promise<void>;
private getLocationFromPostcode;
getProductRecommendations: (id: number, limit: number) => Promise<void>;
toggleFreeShipping: (event: any) => void;

@@ -18,0 +22,0 @@ toggleUpsells: (event: any) => void;

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -56,3 +67,3 @@ return new (P || (P = Promise))(function (resolve, reject) {

};
this.addItem = function (id, qty) { return __awaiter(_this, void 0, void 0, function () {
this.addItem = function (id, qty, properties) { return __awaiter(_this, void 0, void 0, function () {
var response, err_1;

@@ -63,3 +74,3 @@ return __generator(this, function (_a) {

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.cart.addItem(id, { quantity: qty })];
return [4 /*yield*/, this.cart.addItem(id, __assign({ quantity: qty }, properties))];
case 1:

@@ -185,3 +196,3 @@ response = _a.sent();

}); };
this.clearCart = function () { return __awaiter(_this, void 0, void 0, function () {
this.updateNote = function (note) { return __awaiter(_this, void 0, void 0, function () {
var response, err_6;

@@ -192,6 +203,6 @@ return __generator(this, function (_a) {

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.cart.clearItems()];
return [4 /*yield*/, this.cart.updateNote(note)];
case 1:
response = _a.sent();
this.context.update({ message: "CART_CLEARED_SUCCESS" });
this.context.update({ message: "CART_NOTE_UPDATE_SUCCESS" });
this.getCartJSON();

@@ -202,3 +213,3 @@ return [3 /*break*/, 3];

this.context.update({
message: "CART_CLEARED_FAILED",
message: "CART_NOTE_UPDATE_FAILED",
error: err_6.message

@@ -211,3 +222,3 @@ });

}); };
this.getShippingRates = function () { return __awaiter(_this, void 0, void 0, function () {
this.clearNote = function () { return __awaiter(_this, void 0, void 0, function () {
var response, err_7;

@@ -218,7 +229,7 @@ return __generator(this, function (_a) {

_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.cart.getShippingRates()];
return [4 /*yield*/, this.cart.clearNote()];
case 1:
response = _a.sent();
this.context.update({ message: "SHIPPING_RATES_SUCCESS" });
console.log(response);
this.context.update({ message: "CART_NOTE_CLEARED_SUCCESS" });
this.getCartJSON();
return [3 /*break*/, 3];

@@ -228,3 +239,3 @@ case 2:

this.context.update({
message: "SHIPPING_RATES_FAILED",
message: "CART_NOTE_CLEARED_FAILED",
error: err_7.message

@@ -237,2 +248,142 @@ });

}); };
this.clearCart = function () { return __awaiter(_this, void 0, void 0, function () {
var response, err_8;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.cart.clearItems()];
case 1:
response = _a.sent();
this.context.update({ message: "CART_CLEARED_SUCCESS" });
this.getCartJSON();
return [3 /*break*/, 3];
case 2:
err_8 = _a.sent();
this.context.update({
message: "CART_CLEARED_FAILED",
error: err_8.message
});
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
}
});
}); };
this.getShippingRates = function (country, postcode) { return __awaiter(_this, void 0, void 0, function () {
var location, query;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getLocationFromPostcode(country, postcode)];
case 1:
location = _a.sent();
query = Object.entries(location)
.map(function (_a) {
var key = _a[0], val = _a[1];
return "shipping_address[" + key + "]=" + val;
})
.join("&");
try {
fetch("/cart/shipping_rates.json?" + query, {
credentials: "same-origin",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json;"
},
method: "GET"
})
.then(function (response) { return response.json(); })
.then(function (data) {
console.log(data.shipping_rates);
_this.context.update({
shipping: data.shipping_rates,
message: "SHIPPING_RATES_SUCCESS"
});
});
}
catch (err) {
this.context.update({
message: "SHIPPING_RATES_FAILED",
error: err.message
});
}
return [2 /*return*/];
}
});
}); };
this.getLocationFromPostcode = function (country, postcode) { return __awaiter(_this, void 0, void 0, function () {
var response, json, province;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fetch("https://maps.google.com/maps/api/geocode/json?components=country%3a" + country + "%7Cpostal_code:" + postcode + "&sensor=false&key=AIzaSyBENtlgyD5Y42WNwjbjseWLoI09ITT6UwI")];
case 1:
response = _a.sent();
return [4 /*yield*/, response.json()];
case 2:
json = _a.sent();
if (json.status !== "OK")
this.context.update({
message: "SHIPPING_RATES_FAILED",
error: "failed location lookup"
});
if (!json.results.length)
this.context.update({
message: "SHIPPING_RATES_FAILED",
error: "no locations found"
});
province = json.results[0].address_components
.filter(function (address) {
return address.types.includes("administrative_area_level_1");
})
.map(function (address) { return address.short_name; });
if (!province)
this.context.update({
message: "SHIPPING_RATES_FAILED",
error: "no province found"
});
return [2 /*return*/, {
country: country,
province: province[0],
zip: postcode
}];
}
});
}); };
this.getProductRecommendations = function (id, limit) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
try {
fetch("/recommendations/products.json?product_id=" + id + "&limit=" + (limit ? limit : 4), {
credentials: "same-origin",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json;"
},
method: "GET"
})
.then(function (response) { return response.json(); })
.then(function (_a) {
var products = _a.products;
if (products.length > 0) {
_this.context.update({
recommendations: products,
message: "PRODUCT_RECOMMENDATIONS_SUCCESS"
});
}
else {
_this.context.update({
message: "PRODUCT_RECOMMENDATIONS_NOTFOUND"
});
}
});
}
catch (err) {
this.context.update({
message: "PRODUCT_RECOMMENDATIONS_FAILED",
error: err.message
});
}
return [2 /*return*/];
});
}); };
this.toggleFreeShipping = function (event) { };

@@ -239,0 +390,0 @@ this.toggleUpsells = function (event) { };

@@ -26,3 +26,6 @@ export declare class Notifications {

SHIPPING_RATES_FAILED: string;
PRODUCT_RECOMMENDATIONS_SUCCESS: string;
PRODUCT_RECOMMENDATIONS_NOTFOUND: string;
PRODUCT_RECOMMENDATIONS_FAILED: string;
}
}

@@ -17,3 +17,3 @@ import * as React from "react";

element(data?: any): JSX.Element;
bootstrap(element: string, window?: any, data?: any): void;
bootstrap(element: string, window?: any): void;
private parse;

@@ -20,0 +20,0 @@ private parseShopifyData;

@@ -27,9 +27,9 @@ "use strict";

};
ShopifyNext.prototype.bootstrap = function (element, window, data) {
var parsedData = data ? data : this.parse();
ShopifyNext.prototype.bootstrap = function (element, window) {
var parsedData = this.parse();
if (window.location.href.includes("localhost"))
console.log(parsedData);
var view = new URLSearchParams(window.location.href.split("?")[1]).get("view");
if (view)
parsedData.template.suffix = view;
if (data)
console.log(data);
return bootstrap_1.Bootstrap.bootstrap(element, this.options.templates, this.options.sections, parsedData);

@@ -36,0 +36,0 @@ };

@@ -6,4 +6,4 @@ "use strict";

var stringFormat = format || "Do MMMM YYYY, h:mm:ss";
return moment(date).format(format);
return moment(date, "YYYY-MM-DD HH:mm").format(format);
};
//# sourceMappingURL=format-date.js.map

@@ -5,2 +5,3 @@ export * from "./asset-url";

export * from "./format-date";
export * from "./format-day-number";
export * from "./get-menu";

@@ -7,0 +8,0 @@ export * from "./parse-html";

@@ -10,2 +10,3 @@ "use strict";

__export(require("./format-date"));
__export(require("./format-day-number"));
__export(require("./get-menu"));

@@ -12,0 +13,0 @@ __export(require("./parse-html"));

{
"name": "@dotdev/next-components",
"version": "0.4.1",
"version": "0.4.2",
"license": "UNLICENSED",

@@ -14,2 +14,3 @@ "description": "Common components for Next projects",

"react-dom": "^16.7.0",
"react-hot-loader": "^4.8.0",
"react-router-dom": "^4.3.1",

@@ -16,0 +17,0 @@ "voca": "^1.4.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc