@dotdev/next-components
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -40,25 +40,25 @@ "use strict"; | ||
React.createElement(react_router_dom_1.Switch, null, | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/", render: function (props) { return React.createElement(_this.props.templates.home, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections", render: function (props) { return React.createElement(_this.props.templates.collections, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection", render: function (props) { return React.createElement(_this.props.templates.collection, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection/:tag", render: function (props) { return React.createElement(_this.props.templates.collection, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/products/:productId", render: function (props) { return React.createElement(_this.props.templates.product, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection/products/:productId", render: function (props) { return React.createElement(_this.props.templates.product, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/search", render: function (props) { return React.createElement(_this.props.templates.search, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/cart", render: function (props) { return React.createElement(_this.props.templates.cart, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/checkout", render: function (props) { return React.createElement(_this.props.templates.checkout, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/pages/:page", render: function (props) { return React.createElement(_this.props.templates.page, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog", render: function (props) { return React.createElement(_this.props.templates.blog, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog/tagged/:tag", render: function (props) { return React.createElement(_this.props.templates.blog, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog/:article", render: function (props) { return React.createElement(_this.props.templates.article, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account", render: function (props) { return React.createElement(_this.props.templates.account.details, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/login", render: function (props) { return React.createElement(_this.props.templates.account.login, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/register", render: function (props) { return React.createElement(_this.props.templates.account.register, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/addresses", render: function (props) { return React.createElement(_this.props.templates.account.addresses, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/orders/:orderId", render: function (props) { return React.createElement(_this.props.templates.account.order, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/reset/:id/:token", render: function (props) { return React.createElement(_this.props.templates.account.reset, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/logout", render: function (props) { return React.createElement(_this.props.templates.account.logout, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/giftcard/:number", render: function (props) { return React.createElement(_this.props.templates.giftcard, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/password", render: function (props) { return React.createElement(_this.props.templates.password, __assign({}, props, _this.props)); } }), | ||
React.createElement(react_router_dom_1.Route, { render: function (props) { return React.createElement(_this.props.templates.notFound, __assign({}, props, _this.props)); } })))); | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/", render: function (props) { return (React.createElement(_this.props.templates.home, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections", render: function (props) { return (React.createElement(_this.props.templates.collections, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection", render: function (props) { return (React.createElement(_this.props.templates.collection, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection/:tag", render: function (props) { return (React.createElement(_this.props.templates.collection, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/products/:productId", render: function (props) { return (React.createElement(_this.props.templates.product, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/collections/:collection/products/:productId", render: function (props) { return (React.createElement(_this.props.templates.product, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/search", render: function (props) { return (React.createElement(_this.props.templates.search, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/cart", render: function (props) { return (React.createElement(_this.props.templates.cart, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/checkout", render: function (props) { return (React.createElement(_this.props.templates.checkout, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/pages/:page", render: function (props) { return (React.createElement(_this.props.templates.page, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog", render: function (props) { return (React.createElement(_this.props.templates.blog, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog/tagged/:tag", render: function (props) { return (React.createElement(_this.props.templates.blog, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/blogs/:blog/:article", render: function (props) { return (React.createElement(_this.props.templates.article, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account", render: function (props) { return (React.createElement(_this.props.templates.account.details, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/login", render: function (props) { return (React.createElement(_this.props.templates.account.login, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/register", render: function (props) { return (React.createElement(_this.props.templates.account.register, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/addresses", render: function (props) { return (React.createElement(_this.props.templates.account.addresses, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/orders/:orderId", render: function (props) { return (React.createElement(_this.props.templates.account.order, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/reset/:id/:token", render: function (props) { return (React.createElement(_this.props.templates.account.reset, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/account/logout", render: function (props) { return (React.createElement(_this.props.templates.account.logout, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/giftcard/:number", render: function (props) { return (React.createElement(_this.props.templates.giftcard, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { exact: true, path: "/password", render: function (props) { return (React.createElement(_this.props.templates.password, __assign({}, props, _this.props))); } }), | ||
React.createElement(react_router_dom_1.Route, { render: function (props) { return (React.createElement(_this.props.templates.notFound, __assign({}, props, _this.props))); } })))); | ||
}; | ||
@@ -70,3 +70,3 @@ Bootstrap.bootstrap = function (element, templates, sections, data) { | ||
Bootstrap.element = function (templates, sections, data) { | ||
return (React.createElement(Bootstrap, { templates: templates, sections: sections, data: data })); | ||
return React.createElement(Bootstrap, { templates: templates, sections: sections, data: data }); | ||
}; | ||
@@ -73,0 +73,0 @@ return Bootstrap; |
@@ -45,7 +45,9 @@ "use strict"; | ||
settings: fields, | ||
blocks: blocks.length ? blocks.map(function (block, i) { return ({ | ||
id: i, | ||
type: "default", | ||
settings: block | ||
}); }) : [] | ||
blocks: blocks.length | ||
? blocks.map(function (block, i) { return ({ | ||
id: i, | ||
type: "default", | ||
settings: block | ||
}); }) | ||
: [] | ||
}); | ||
@@ -64,6 +66,10 @@ }); | ||
var _this = this; | ||
return sections ? sections.map(function (section, i) { return _this.section(section, i); }) : []; | ||
return sections | ||
? sections.map(function (section, i) { return _this.section(section, i); }) | ||
: []; | ||
}; | ||
DynamicSections.prototype.render = function () { | ||
return (React.createElement("main", { className: this.props.className }, this.sections(this.props.dtkSections ? this.transform(this.props.dtkSections) : this.props.data.sections))); | ||
return (React.createElement("main", { className: this.props.className }, this.sections(this.props.dtkSections | ||
? this.transform(this.props.dtkSections) | ||
: this.props.data.sections))); | ||
}; | ||
@@ -70,0 +76,0 @@ return DynamicSections; |
@@ -23,6 +23,10 @@ "use strict"; | ||
Forms.prototype.render = function () { | ||
return (React.createElement("form", { id: this.props.data.form.id, method: this.props.data.form.method, action: this.props.data.form.action, acceptCharset: this.props.data.form.accept_charset ? this.props.data.form.accept_charset : '', encType: this.props.data.form.enctype ? this.props.data.form.enctype : '', className: (this.props.data.form.class ? this.props.data.form.class : '') + " " + this.props.className }, | ||
this.props.data.fields.length ? this.props.data.fields.map(function (field, i) { | ||
return React.createElement("input", { key: i, name: field.name, type: field.type, value: field.value }); | ||
}) : null, | ||
return (React.createElement("form", { id: this.props.data.form.id, method: this.props.data.form.method, action: this.props.data.form.action, acceptCharset: this.props.data.form.accept_charset | ||
? this.props.data.form.accept_charset | ||
: "", encType: this.props.data.form.enctype ? this.props.data.form.enctype : "", className: (this.props.data.form.class ? this.props.data.form.class : "") + " " + this.props.className }, | ||
this.props.data.fields.length | ||
? this.props.data.fields.map(function (field, i) { | ||
return (React.createElement("input", { key: i, name: field.name, type: field.type, value: field.value })); | ||
}) | ||
: null, | ||
this.props.children)); | ||
@@ -29,0 +33,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import * as React from "react"; | ||
export declare const ThemeContext: React.Context<ThemeContext.Store>; | ||
@@ -3,0 +3,0 @@ export declare namespace ThemeContext { |
@@ -14,3 +14,4 @@ export declare class Cart { | ||
clearCart: () => Promise<void>; | ||
getShippingRates: () => Promise<void>; | ||
getShippingRates: (country: string, postcode: string) => Promise<void>; | ||
private getLocationFromPostcode; | ||
toggleFreeShipping: (event: any) => void; | ||
@@ -17,0 +18,0 @@ toggleUpsells: (event: any) => void; |
@@ -206,22 +206,79 @@ "use strict"; | ||
}); }; | ||
this.getShippingRates = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var response, err_7; | ||
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: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.cart.getShippingRates()]; | ||
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(); | ||
this.context.update({ message: "SHIPPING_RATES_SUCCESS" }); | ||
console.log(response); | ||
return [3 /*break*/, 3]; | ||
return [4 /*yield*/, response.json()]; | ||
case 2: | ||
err_7 = _a.sent(); | ||
this.context.update({ | ||
message: "SHIPPING_RATES_FAILED", | ||
error: err_7.message | ||
}); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
json = _a.sent(); | ||
if (json.status !== "OK") | ||
this.context.update({ | ||
message: "SHIPPING_RATES_FAILED", | ||
error: "failed location lookup" | ||
}); | ||
if (!json.results) | ||
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 | ||
}]; | ||
} | ||
@@ -228,0 +285,0 @@ }); |
@@ -11,3 +11,3 @@ "use strict"; | ||
}; | ||
this.set = function (messages) { return _this.messages = messages; }; | ||
this.set = function (messages) { return (_this.messages = messages); }; | ||
this.get = function (message) { return _this.messages[message]; }; | ||
@@ -14,0 +14,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import * as React from 'react'; | ||
import * as React from "react"; | ||
export declare class ThemeProvider extends React.Component<ThemeProvider.Props, ThemeProvider.State> { | ||
@@ -3,0 +3,0 @@ constructor(props: any); |
@@ -13,5 +13,7 @@ "use strict"; | ||
}; | ||
var replacement = Numeral(cents).divide(100).format(shopifyFormat[stringFormat.match(regex)[1]]); | ||
var replacement = Numeral(cents) | ||
.divide(100) | ||
.format(shopifyFormat[stringFormat.match(regex)[1]]); | ||
return stringFormat.replace(regex, replacement); | ||
}; | ||
//# sourceMappingURL=format-money.js.map |
@@ -6,4 +6,6 @@ "use strict"; | ||
if (wrap === void 0) { wrap = false; } | ||
return (React.createElement("span", { dangerouslySetInnerHTML: { __html: !html.startsWith('<') && wrap ? "<p>" + html + "</p>" : html } })); | ||
return (React.createElement("span", { dangerouslySetInnerHTML: { | ||
__html: !html.startsWith("<") && wrap ? "<p>" + html + "</p>" : html | ||
} })); | ||
}; | ||
//# sourceMappingURL=parse-html.js.map |
@@ -5,4 +5,4 @@ "use strict"; | ||
if (ellipse === void 0) { ellipse = "..."; } | ||
return (str.length > length) ? "" + str.slice(0, length) + ellipse : str; | ||
return str.length > length ? "" + str.slice(0, length) + ellipse : str; | ||
}; | ||
//# sourceMappingURL=truncate-string.js.map |
{ | ||
"name": "@dotdev/next-components", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "description": "Common components for Next projects", |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73704
1112
4