codelabs-react
Advanced tools
Comparing version 1.3.1 to 1.3.2
{ | ||
"presets": [ | ||
"@babel/react" | ||
"@babel/react", | ||
"@babel/preset-env" | ||
] | ||
} |
@@ -1,6 +0,32 @@ | ||
import React from "react"; | ||
export function Header({ | ||
title | ||
}) { | ||
return /*#__PURE__*/React.createElement("header", { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Header = Header; | ||
exports.SideNavigation = SideNavigation; | ||
exports.Content = Content; | ||
exports.Main = Main; | ||
exports.H1 = H1; | ||
exports.H2 = H2; | ||
exports.H3 = H3; | ||
exports.H4 = H4; | ||
exports.H5 = H5; | ||
exports.H6 = H6; | ||
exports.Span = Span; | ||
exports.ButtonLink = ButtonLink; | ||
exports.Button = Button; | ||
exports.Link = Link; | ||
exports.Snippet = Snippet; | ||
exports.CodeBox = CodeBox; | ||
exports.InfoBox = InfoBox; | ||
exports.WarningBox = WarningBox; | ||
var _react = _interopRequireDefault(require("react")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function Header(_ref) { | ||
var title = _ref.title; | ||
return /*#__PURE__*/_react["default"].createElement("header", { | ||
style: { | ||
@@ -13,27 +39,29 @@ padding: "10px", | ||
} | ||
export function SideNavigation({ | ||
items, | ||
setPage | ||
}) { | ||
return /*#__PURE__*/React.createElement("nav", { | ||
function SideNavigation(_ref2) { | ||
var items = _ref2.items, | ||
setPage = _ref2.setPage; | ||
return /*#__PURE__*/_react["default"].createElement("nav", { | ||
style: { | ||
width: "200px" | ||
} | ||
}, /*#__PURE__*/React.createElement("ul", null, items.map((item, index) => /*#__PURE__*/React.createElement("li", { | ||
key: item | ||
}, /*#__PURE__*/React.createElement("a", { | ||
href: "#", | ||
onClick: e => { | ||
e.preventDefault(); | ||
setPage(index); | ||
}, | ||
onKeyDown: e => { | ||
e.key === "Enter" && setPage(index); | ||
} | ||
}, item))))); | ||
}, /*#__PURE__*/_react["default"].createElement("ul", null, items.map(function (item, index) { | ||
return /*#__PURE__*/_react["default"].createElement("li", { | ||
key: item | ||
}, /*#__PURE__*/_react["default"].createElement("a", { | ||
href: "#", | ||
onClick: function onClick(e) { | ||
e.preventDefault(); | ||
setPage(index); | ||
}, | ||
onKeyDown: function onKeyDown(e) { | ||
e.key === "Enter" && setPage(index); | ||
} | ||
}, item)); | ||
}))); | ||
} | ||
export function Content({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("section", { | ||
function Content(_ref3) { | ||
var children = _ref3.children; | ||
return /*#__PURE__*/_react["default"].createElement("section", { | ||
style: { | ||
@@ -45,6 +73,6 @@ flex: 1, | ||
} | ||
export function Main({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("main", { | ||
function Main(_ref4) { | ||
var children = _ref4.children; | ||
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("main", { | ||
style: { | ||
@@ -55,42 +83,42 @@ display: "flex" | ||
} | ||
export function H1({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h1", null, children); | ||
function H1(_ref5) { | ||
var children = _ref5.children; | ||
return /*#__PURE__*/_react["default"].createElement("h1", null, children); | ||
} | ||
export function H2({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h2", null, children); | ||
function H2(_ref6) { | ||
var children = _ref6.children; | ||
return /*#__PURE__*/_react["default"].createElement("h2", null, children); | ||
} | ||
export function H3({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h3", null, children); | ||
function H3(_ref7) { | ||
var children = _ref7.children; | ||
return /*#__PURE__*/_react["default"].createElement("h3", null, children); | ||
} | ||
export function H4({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h4", null, children); | ||
function H4(_ref8) { | ||
var children = _ref8.children; | ||
return /*#__PURE__*/_react["default"].createElement("h4", null, children); | ||
} | ||
export function H5({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h5", null, children); | ||
function H5(_ref9) { | ||
var children = _ref9.children; | ||
return /*#__PURE__*/_react["default"].createElement("h5", null, children); | ||
} | ||
export function H6({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("h6", null, children); | ||
function H6(_ref10) { | ||
var children = _ref10.children; | ||
return /*#__PURE__*/_react["default"].createElement("h6", null, children); | ||
} | ||
export function Span({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("span", null, children); | ||
function Span(_ref11) { | ||
var children = _ref11.children; | ||
return /*#__PURE__*/_react["default"].createElement("span", null, children); | ||
} | ||
export function ButtonLink({ | ||
children, | ||
href | ||
}) { | ||
return /*#__PURE__*/React.createElement("a", { | ||
function ButtonLink(_ref12) { | ||
var children = _ref12.children, | ||
href = _ref12.href; | ||
return /*#__PURE__*/_react["default"].createElement("a", { | ||
target: "_blank", | ||
@@ -105,8 +133,8 @@ href: href, | ||
} | ||
export function Button({ | ||
disabled, | ||
children, | ||
onClick | ||
}) { | ||
return /*#__PURE__*/React.createElement("button", { | ||
function Button(_ref13) { | ||
var disabled = _ref13.disabled, | ||
children = _ref13.children, | ||
onClick = _ref13.onClick; | ||
return /*#__PURE__*/_react["default"].createElement("button", { | ||
onClick: onClick, | ||
@@ -116,7 +144,7 @@ disabled: disabled | ||
} | ||
export function Link({ | ||
children, | ||
href | ||
}) { | ||
return /*#__PURE__*/React.createElement("a", { | ||
function Link(_ref14) { | ||
var children = _ref14.children, | ||
href = _ref14.href; | ||
return /*#__PURE__*/_react["default"].createElement("a", { | ||
target: "_blank", | ||
@@ -126,16 +154,16 @@ href: href | ||
} | ||
export function Snippet({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("pre", null, /*#__PURE__*/React.createElement("code", null, children)); | ||
function Snippet(_ref15) { | ||
var children = _ref15.children; | ||
return /*#__PURE__*/_react["default"].createElement("pre", null, /*#__PURE__*/_react["default"].createElement("code", null, children)); | ||
} | ||
export function CodeBox({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("pre", null, /*#__PURE__*/React.createElement("code", null, children)); | ||
function CodeBox(_ref16) { | ||
var children = _ref16.children; | ||
return /*#__PURE__*/_react["default"].createElement("pre", null, /*#__PURE__*/_react["default"].createElement("code", null, children)); | ||
} | ||
export function InfoBox({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("div", { | ||
function InfoBox(_ref17) { | ||
var children = _ref17.children; | ||
return /*#__PURE__*/_react["default"].createElement("div", { | ||
style: { | ||
@@ -147,6 +175,6 @@ backgroundColor: "#90EE90", | ||
} | ||
export function WarningBox({ | ||
children | ||
}) { | ||
return /*#__PURE__*/React.createElement("div", { | ||
function WarningBox(_ref18) { | ||
var children = _ref18.children; | ||
return /*#__PURE__*/_react["default"].createElement("div", { | ||
style: { | ||
@@ -153,0 +181,0 @@ backgroundColor: "#fed8b1", |
@@ -1,3 +0,12 @@ | ||
import Utils from "./utils"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var _utils = _interopRequireDefault(require("./utils")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function extractHeadingNodes(content) { | ||
@@ -12,18 +21,19 @@ return findElements(content, "HEADING_1"); | ||
function extractTitle(content) { | ||
return Utils.getParagraphText(extractTitleNode(content)); | ||
return _utils["default"].getParagraphText(extractTitleNode(content)); | ||
} | ||
function extractHeadings(content) { | ||
const headingNodes = extractHeadingNodes(content); | ||
return headingNodes.map(Utils.getParagraphText).map(header => header.trim()); | ||
var headingNodes = extractHeadingNodes(content); | ||
return headingNodes.map(_utils["default"].getParagraphText).map(function (header) { | ||
return header.trim(); | ||
}); | ||
} | ||
function extractPageNodes(content) { | ||
const headingNodes = extractHeadingNodes(content); | ||
return content.reduce((acc, current) => { | ||
const { | ||
startIndex = 0 | ||
} = current; | ||
var headingNodes = extractHeadingNodes(content); | ||
return content.reduce(function (acc, current) { | ||
var _current$startIndex = current.startIndex, | ||
startIndex = _current$startIndex === void 0 ? 0 : _current$startIndex; | ||
for (let i = headingNodes.length - 1; i > -1; i -= 1) { | ||
for (var i = headingNodes.length - 1; i > -1; i -= 1) { | ||
if (startIndex > headingNodes[i].startIndex) { | ||
@@ -41,11 +51,14 @@ acc[i] = acc[i] || []; | ||
function findElements(content, type) { | ||
return content.filter(node => node.paragraph && node.paragraph.paragraphStyle.namedStyleType === type); | ||
return content.filter(function (node) { | ||
return node.paragraph && node.paragraph.paragraphStyle.namedStyleType === type; | ||
}); | ||
} | ||
export default { | ||
extractHeadingNodes, | ||
extractHeadings, | ||
extractTitleNode, | ||
extractTitle, | ||
extractPageNodes | ||
}; | ||
var _default = { | ||
extractHeadingNodes: extractHeadingNodes, | ||
extractHeadings: extractHeadings, | ||
extractTitleNode: extractTitleNode, | ||
extractTitle: extractTitle, | ||
extractPageNodes: extractPageNodes | ||
}; | ||
exports["default"] = _default; |
@@ -1,17 +0,23 @@ | ||
const assert = require("assert"); | ||
"use strict"; | ||
const { | ||
content | ||
} = require("../stories/document-1607876232180.json"); | ||
var _extract = _interopRequireDefault(require("./extract")); | ||
import Extract from "./extract"; | ||
describe("Extract", () => { | ||
it("finds the title", () => { | ||
const title = Extract.extractTitle(content); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var assert = require("assert"); | ||
var _require = require("../stories/document-1607876232180.json"), | ||
content = _require.content; | ||
describe("Extract", function () { | ||
it("finds the title", function () { | ||
var title = _extract["default"].extractTitle(content); | ||
assert.deepStrictEqual(title, "Your First Progressive Web App"); | ||
}); | ||
it("finds h1 headers", () => { | ||
const headings = Extract.extractHeadings(content); | ||
it("finds h1 headers", function () { | ||
var headings = _extract["default"].extractHeadings(content); | ||
assert.deepStrictEqual(headings, ["Introduction", "Getting set up", "Establish a baseline", "Add a web app manifest", "Provide a basic offline experience", "Provide a full offline experience", "Add install experience", "Congratulations"]); | ||
}); | ||
}); |
@@ -1,54 +0,92 @@ | ||
import React, { useState } from "react"; | ||
import { Header, SideNavigation, Content, Main, H1, H2, H3, H4, H5, H6, Span, Button, ButtonLink, Snippet, Link, InfoBox, WarningBox, CodeBox } from "./components"; | ||
import Extract from "./extract"; | ||
import Utils from "./utils"; // TODO: this function is a mess, need to break it apart | ||
"use strict"; | ||
export function Codelabs({ | ||
content, | ||
overrides = {} | ||
}) { | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.Codelabs = Codelabs; | ||
var _react = _interopRequireWildcard(require("react")); | ||
var _components = require("./components"); | ||
var _extract = _interopRequireDefault(require("./extract")); | ||
var _utils = _interopRequireDefault(require("./utils")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
// TODO: this function is a mess, need to break it apart | ||
function Codelabs(_ref) { | ||
var content = _ref.content, | ||
_ref$overrides = _ref.overrides, | ||
overrides = _ref$overrides === void 0 ? {} : _ref$overrides; | ||
if (!content) throw new Error("Missing property: content"); | ||
const [page, setPage] = useState(0); | ||
const PageComponent = overrides.Page || Page; | ||
const HeaderComponent = overrides.Header || Header; | ||
const SideNavigationComponent = overrides.SideNavigation || SideNavigation; | ||
const ContentComponent = overrides.Content || Content; | ||
const MainComponent = overrides.Main || Main; | ||
const H1Component = overrides.H1 || H1; | ||
const H2Component = overrides.H2 || H2; | ||
const H3Component = overrides.H3 || H3; | ||
const H4Component = overrides.H4 || H4; | ||
const H5Component = overrides.H5 || H5; | ||
const H6Component = overrides.H6 || H6; | ||
const SpanComponent = overrides.Span || Span; | ||
const ButtonLinkComponent = overrides.ButtonLink || ButtonLink; | ||
const ButtonComponent = overrides.Button || Button; | ||
const SnippetComponent = overrides.Snippet || Snippet; | ||
const LinkComponent = overrides.Link || Link; | ||
const InfoBoxComponent = overrides.InfoBox || InfoBox; | ||
const WarningBoxComponent = overrides.WarningBox || WarningBox; | ||
const CodeBoxComponent = overrides.CodeBox || CodeBox; | ||
const Text = Utils.TextFactory({ | ||
H2Component, | ||
H3Component, | ||
H4Component, | ||
H5Component, | ||
H6Component, | ||
SpanComponent, | ||
ButtonLinkComponent | ||
var _useState = (0, _react.useState)(0), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
page = _useState2[0], | ||
setPage = _useState2[1]; | ||
var PageComponent = overrides.Page || Page; | ||
var HeaderComponent = overrides.Header || _components.Header; | ||
var SideNavigationComponent = overrides.SideNavigation || _components.SideNavigation; | ||
var ContentComponent = overrides.Content || _components.Content; | ||
var MainComponent = overrides.Main || _components.Main; | ||
var H1Component = overrides.H1 || _components.H1; | ||
var H2Component = overrides.H2 || _components.H2; | ||
var H3Component = overrides.H3 || _components.H3; | ||
var H4Component = overrides.H4 || _components.H4; | ||
var H5Component = overrides.H5 || _components.H5; | ||
var H6Component = overrides.H6 || _components.H6; | ||
var SpanComponent = overrides.Span || _components.Span; | ||
var ButtonLinkComponent = overrides.ButtonLink || _components.ButtonLink; | ||
var ButtonComponent = overrides.Button || _components.Button; | ||
var SnippetComponent = overrides.Snippet || _components.Snippet; | ||
var LinkComponent = overrides.Link || _components.Link; | ||
var InfoBoxComponent = overrides.InfoBox || _components.InfoBox; | ||
var WarningBoxComponent = overrides.WarningBox || _components.WarningBox; | ||
var CodeBoxComponent = overrides.CodeBox || _components.CodeBox; | ||
var Text = _utils["default"].TextFactory({ | ||
H2Component: H2Component, | ||
H3Component: H3Component, | ||
H4Component: H4Component, | ||
H5Component: H5Component, | ||
H6Component: H6Component, | ||
SpanComponent: SpanComponent, | ||
ButtonLinkComponent: ButtonLinkComponent | ||
}); | ||
const title = Extract.extractTitle(content); | ||
const headings = Extract.extractHeadings(content); | ||
const pageNodes = Extract.extractPageNodes(content); | ||
function processParagraphElements({ | ||
type | ||
}) { | ||
return function ({ | ||
textRun | ||
}) { | ||
var title = _extract["default"].extractTitle(content); | ||
var headings = _extract["default"].extractHeadings(content); | ||
var pageNodes = _extract["default"].extractPageNodes(content); | ||
function processParagraphElements(_ref2) { | ||
var type = _ref2.type; | ||
return function (_ref3) { | ||
var textRun = _ref3.textRun; | ||
if (!textRun) return null; | ||
if (Utils.isButton(textRun)) { | ||
return /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(ButtonLinkComponent, { | ||
if (_utils["default"].isButton(textRun)) { | ||
return /*#__PURE__*/_react["default"].createElement("p", null, /*#__PURE__*/_react["default"].createElement(ButtonLinkComponent, { | ||
href: textRun.textStyle.link.url | ||
@@ -58,8 +96,8 @@ }, textRun.content)); | ||
if (Utils.isCommandLineSnippet(textRun)) { | ||
return /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(SnippetComponent, null, textRun.content)); | ||
if (_utils["default"].isCommandLineSnippet(textRun)) { | ||
return /*#__PURE__*/_react["default"].createElement("p", null, /*#__PURE__*/_react["default"].createElement(SnippetComponent, null, textRun.content)); | ||
} | ||
if (Utils.isLink(textRun)) { | ||
return /*#__PURE__*/React.createElement(LinkComponent, { | ||
if (_utils["default"].isLink(textRun)) { | ||
return /*#__PURE__*/_react["default"].createElement(LinkComponent, { | ||
href: textRun.textStyle.link.url | ||
@@ -69,6 +107,6 @@ }, textRun.content); | ||
return /*#__PURE__*/React.createElement(Text, { | ||
return /*#__PURE__*/_react["default"].createElement(Text, { | ||
type: type, | ||
text: textRun.content, | ||
bold: Utils.isBold(textRun) | ||
bold: _utils["default"].isBold(textRun) | ||
}); | ||
@@ -78,14 +116,15 @@ }; | ||
const pages = pageNodes.map((page, index) => { | ||
const reactPage = page.map(node => { | ||
var pages = pageNodes.map(function (page, index) { | ||
var reactPage = page.map(function (node) { | ||
// we have text node, with possibly multiple elements | ||
if (node.paragraph) { | ||
// we can run into a few special cases based on type or other properties | ||
const type = Utils.getParagraphType(node); | ||
const pContent = node.paragraph.elements.map(processParagraphElements({ | ||
type | ||
var type = _utils["default"].getParagraphType(node); | ||
var pContent = node.paragraph.elements.map(processParagraphElements({ | ||
type: type | ||
})); | ||
if (Utils.getParagraphSpacingMode(node) === "COLLAPSE_LISTS") { | ||
return /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, pContent)); | ||
if (_utils["default"].getParagraphSpacingMode(node) === "COLLAPSE_LISTS") { | ||
return /*#__PURE__*/_react["default"].createElement("ul", null, /*#__PURE__*/_react["default"].createElement("li", null, pContent)); | ||
} | ||
@@ -99,18 +138,20 @@ | ||
if (node.table) { | ||
if (Utils.isInfoBox(node.table)) { | ||
const pContent = node.table.tableRows[0].tableCells[0].content[0].paragraph.elements.map(processParagraphElements({ | ||
if (_utils["default"].isInfoBox(node.table)) { | ||
var _pContent = node.table.tableRows[0].tableCells[0].content[0].paragraph.elements.map(processParagraphElements({ | ||
type: "NORMAL_TEXT" | ||
})); | ||
return /*#__PURE__*/React.createElement(InfoBoxComponent, null, pContent); | ||
return /*#__PURE__*/_react["default"].createElement(InfoBoxComponent, null, _pContent); | ||
} | ||
if (Utils.isWarningBox(node.table)) { | ||
const pContent = node.table.tableRows[0].tableCells[0].content[0].paragraph.elements.map(processParagraphElements({ | ||
if (_utils["default"].isWarningBox(node.table)) { | ||
var _pContent2 = node.table.tableRows[0].tableCells[0].content[0].paragraph.elements.map(processParagraphElements({ | ||
type: "NORMAL_TEXT" | ||
})); | ||
return /*#__PURE__*/React.createElement(WarningBoxComponent, null, pContent); | ||
return /*#__PURE__*/_react["default"].createElement(WarningBoxComponent, null, _pContent2); | ||
} | ||
if (Utils.isCodeBox(node.table)) { | ||
return /*#__PURE__*/React.createElement(CodeBoxComponent, null, Utils.getCode(node.table.tableRows[0].tableCells[0])); | ||
if (_utils["default"].isCodeBox(node.table)) { | ||
return /*#__PURE__*/_react["default"].createElement(CodeBoxComponent, null, _utils["default"].getCode(node.table.tableRows[0].tableCells[0])); | ||
} | ||
@@ -122,6 +163,6 @@ } | ||
reactPage.unshift( /*#__PURE__*/React.createElement(H1Component, null, index + 1, ". ", headings[index])); | ||
reactPage.unshift( /*#__PURE__*/_react["default"].createElement(H1Component, null, index + 1, ". ", headings[index])); | ||
return reactPage; | ||
}); | ||
return /*#__PURE__*/React.createElement(PageComponent, { | ||
return /*#__PURE__*/_react["default"].createElement(PageComponent, { | ||
title: title, | ||
@@ -133,7 +174,7 @@ navigationItems: headings, | ||
overrides: { | ||
HeaderComponent, | ||
SideNavigationComponent, | ||
ContentComponent, | ||
MainComponent, | ||
ButtonComponent | ||
HeaderComponent: HeaderComponent, | ||
SideNavigationComponent: SideNavigationComponent, | ||
ContentComponent: ContentComponent, | ||
MainComponent: MainComponent, | ||
ButtonComponent: ButtonComponent | ||
} | ||
@@ -143,25 +184,23 @@ }); | ||
function Page({ | ||
title, | ||
navigationItems, | ||
pages, | ||
currentPage, | ||
setPage, | ||
overrides: { | ||
HeaderComponent, | ||
SideNavigationComponent, | ||
ContentComponent, | ||
MainComponent, | ||
ButtonComponent | ||
} | ||
}) { | ||
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(HeaderComponent, { | ||
function Page(_ref4) { | ||
var title = _ref4.title, | ||
navigationItems = _ref4.navigationItems, | ||
pages = _ref4.pages, | ||
currentPage = _ref4.currentPage, | ||
setPage = _ref4.setPage, | ||
_ref4$overrides = _ref4.overrides, | ||
HeaderComponent = _ref4$overrides.HeaderComponent, | ||
SideNavigationComponent = _ref4$overrides.SideNavigationComponent, | ||
ContentComponent = _ref4$overrides.ContentComponent, | ||
MainComponent = _ref4$overrides.MainComponent, | ||
ButtonComponent = _ref4$overrides.ButtonComponent; | ||
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(HeaderComponent, { | ||
title: title | ||
}), /*#__PURE__*/React.createElement(MainComponent, null, /*#__PURE__*/React.createElement(SideNavigationComponent, { | ||
}), /*#__PURE__*/_react["default"].createElement(MainComponent, null, /*#__PURE__*/_react["default"].createElement(SideNavigationComponent, { | ||
items: navigationItems, | ||
setPage: setPage, | ||
currentPage: currentPage | ||
}), /*#__PURE__*/React.createElement(ContentComponent, { | ||
}), /*#__PURE__*/_react["default"].createElement(ContentComponent, { | ||
currentPage: currentPage | ||
}, /*#__PURE__*/React.createElement(React.Fragment, null, pages[currentPage], /*#__PURE__*/React.createElement("div", { | ||
}, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pages[currentPage], /*#__PURE__*/_react["default"].createElement("div", { | ||
style: { | ||
@@ -172,10 +211,10 @@ display: "flex", | ||
} | ||
}, /*#__PURE__*/React.createElement(ButtonComponent, { | ||
}, /*#__PURE__*/_react["default"].createElement(ButtonComponent, { | ||
disabled: currentPage - 1 < 0, | ||
onClick: () => { | ||
onClick: function onClick() { | ||
setPage(currentPage - 1); | ||
} | ||
}, "Previous"), /*#__PURE__*/React.createElement(ButtonComponent, { | ||
}, "Previous"), /*#__PURE__*/_react["default"].createElement(ButtonComponent, { | ||
disabled: currentPage + 1 === pages.length, | ||
onClick: () => { | ||
onClick: function onClick() { | ||
setPage(currentPage + 1); | ||
@@ -182,0 +221,0 @@ } |
@@ -1,2 +0,8 @@ | ||
const infoColor = { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = void 0; | ||
var infoColor = { | ||
red: 0.8509804, | ||
@@ -6,3 +12,3 @@ green: 0.91764706, | ||
}; | ||
const warningColor = { | ||
var warningColor = { | ||
red: 0.9882353, | ||
@@ -14,4 +20,4 @@ green: 0.8980392, | ||
function isEqual(object1, object2) { | ||
const keys1 = Object.keys(object1); | ||
const keys2 = Object.keys(object2); | ||
var keys1 = Object.keys(object1); | ||
var keys2 = Object.keys(object2); | ||
@@ -22,3 +28,5 @@ if (keys1.length !== keys2.length) { | ||
for (let key of keys1) { | ||
for (var _i = 0, _keys = keys1; _i < _keys.length; _i++) { | ||
var key = _keys[_i]; | ||
if (object1[key] !== object2[key]) { | ||
@@ -81,15 +89,14 @@ return false; | ||
function TextFactory({ | ||
H2Component, | ||
H3Component, | ||
H4Component, | ||
H5Component, | ||
H6Component, | ||
SpanComponent | ||
}) { | ||
return function ({ | ||
bold, | ||
type, | ||
text | ||
}) { | ||
function TextFactory(_ref) { | ||
var H2Component = _ref.H2Component, | ||
H3Component = _ref.H3Component, | ||
H4Component = _ref.H4Component, | ||
H5Component = _ref.H5Component, | ||
H6Component = _ref.H6Component, | ||
SpanComponent = _ref.SpanComponent; | ||
return function (_ref2) { | ||
var bold = _ref2.bold, | ||
type = _ref2.type, | ||
text = _ref2.text; | ||
if (type === "HEADING_2") { | ||
@@ -153,3 +160,3 @@ return /*#__PURE__*/React.createElement(H2Component, null, text); | ||
function getCode(tableCell) { | ||
return tableCell.content.reduce((acc, current) => { | ||
return tableCell.content.reduce(function (acc, current) { | ||
return acc += current.paragraph.elements[0].textRun.content; | ||
@@ -159,15 +166,16 @@ }, ""); | ||
export default { | ||
getParagraphText, | ||
getParagraphType, | ||
getParagraphSpacingMode, | ||
TextFactory, | ||
isCommandLineSnippet, | ||
isBold, | ||
isButton, | ||
isLink, | ||
isInfoBox, | ||
isWarningBox, | ||
isCodeBox, | ||
getCode | ||
}; | ||
var _default = { | ||
getParagraphText: getParagraphText, | ||
getParagraphType: getParagraphType, | ||
getParagraphSpacingMode: getParagraphSpacingMode, | ||
TextFactory: TextFactory, | ||
isCommandLineSnippet: isCommandLineSnippet, | ||
isBold: isBold, | ||
isButton: isButton, | ||
isLink: isLink, | ||
isInfoBox: isInfoBox, | ||
isWarningBox: isWarningBox, | ||
isCodeBox: isCodeBox, | ||
getCode: getCode | ||
}; | ||
exports["default"] = _default; |
{ | ||
"name": "codelabs-react", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -21,2 +20,3 @@ "test": "mocha -r esm **/*.test.js", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@storybook/addon-actions": "^6.1.11", | ||
@@ -23,0 +23,0 @@ "@storybook/addon-essentials": "^6.1.11", |
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
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
38130
1150
16
No