@bigbinary/neeto-molecules 3.15.6-beta1 → 3.15.7
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/dist/BrowserPreview.js +3 -2
- package/dist/BrowserPreview.js.map +1 -1
- package/dist/{Chevron-tz1-4YT4.js → Chevron-C3M0XG3p.js} +2 -2
- package/dist/{Chevron-tz1-4YT4.js.map → Chevron-C3M0XG3p.js.map} +1 -1
- package/dist/Codeblock.js +1 -1
- package/dist/Codeblock.js.map +1 -1
- package/dist/ConfigurePageSidebar.js +1 -1
- package/dist/Header.js +14 -14
- package/dist/Header.js.map +1 -1
- package/dist/NavigationHeader.js +58 -15
- package/dist/NavigationHeader.js.map +1 -1
- package/dist/ProductEmbed.js +154 -80
- package/dist/ProductEmbed.js.map +1 -1
- package/dist/ShareViaLink.js +37 -18
- package/dist/ShareViaLink.js.map +1 -1
- package/dist/Sidebar.js +17 -3
- package/dist/Sidebar.js.map +1 -1
- package/dist/StatusDropdown.js +10 -4
- package/dist/StatusDropdown.js.map +1 -1
- package/dist/cjs/BrowserPreview.js +3 -2
- package/dist/cjs/BrowserPreview.js.map +1 -1
- package/dist/cjs/{Chevron-55AGkSis.js → Chevron-kf8dWOcZ.js} +2 -2
- package/dist/cjs/{Chevron-55AGkSis.js.map → Chevron-kf8dWOcZ.js.map} +1 -1
- package/dist/cjs/Codeblock.js +1 -1
- package/dist/cjs/Codeblock.js.map +1 -1
- package/dist/cjs/ConfigurePageSidebar.js +1 -1
- package/dist/cjs/Header.js +14 -14
- package/dist/cjs/Header.js.map +1 -1
- package/dist/cjs/NavigationHeader.js +56 -13
- package/dist/cjs/NavigationHeader.js.map +1 -1
- package/dist/cjs/ProductEmbed.js +152 -78
- package/dist/cjs/ProductEmbed.js.map +1 -1
- package/dist/cjs/ShareViaLink.js +36 -17
- package/dist/cjs/ShareViaLink.js.map +1 -1
- package/dist/cjs/Sidebar.js +17 -3
- package/dist/cjs/Sidebar.js.map +1 -1
- package/dist/cjs/StatusDropdown.js +10 -4
- package/dist/cjs/StatusDropdown.js.map +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +3 -2
- package/types/BrowserPreview.d.ts +1 -0
- package/types/NavigationHeader.d.ts +3 -2
- package/types/ProductEmbed.d.ts +3 -0
- package/types/Sidebar.d.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationHeader.js","sources":["../src/components/NavigationHeader/constants.jsx","../src/components/NavigationHeader/LeftBlock.jsx","../src/components/NavigationHeader/Navigation.jsx","../src/components/NavigationHeader/RightBlock.jsx","../src/components/NavigationHeader/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport { Home } from \"neetoicons\";\n\nexport const DEFAULT_HOME_BUTTON_PROPS = {\n tooltip: {\n content: t(\"neetoMolecules.navigationHeader.home\"),\n position: \"bottom\",\n },\n homeUrl: \"/\",\n icon: <Home />,\n};\n","import { isPresent } from \"neetocist\";\nimport { Tooltip } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { mergeDeepRight } from \"ramda\";\nimport { Link } from \"react-router-dom\";\n\nimport Rename from \"components/Rename\";\n\nimport { DEFAULT_HOME_BUTTON_PROPS } from \"./constants\";\n\nconst LeftBlock = ({\n homeButtonProps: customHomeButtonProps,\n homeUrl,\n renameProps,\n children,\n}) => {\n const homeButtonProps = mergeDeepRight(\n DEFAULT_HOME_BUTTON_PROPS,\n customHomeButtonProps\n );\n\n return (\n <div\n className=\"flex items-center gap-1 md:gap-2\"\n data-cy=\"navigation-header-left-block\"\n data-testid=\"navigation-header-left-block\"\n >\n <Tooltip\n content={homeButtonProps.tooltip.content}\n position={homeButtonProps.tooltip.position}\n touch={[\"hold\", 500]}\n >\n <Link data-cy=\"home-button\" data-testid=\"home-button\" to={homeUrl}>\n <div className=\"neeto-ui-rounded hover:neeto-ui-bg-gray-200 p-1\">\n {homeButtonProps.icon}\n </div>\n </Link>\n </Tooltip>\n {isPresent(renameProps) && (\n <Rename\n dropdownItems={renameProps.dropdownItems}\n value={renameProps.value}\n {...renameProps}\n />\n )}\n {children}\n </div>\n );\n};\n\nLeftBlock.propTypes = {\n /**\n * Object containing the home button icon and the props to be passed to the tooltip of the home button.\n */\n homeButtonProps: PropTypes.shape({\n tooltip: PropTypes.shape({\n content: PropTypes.string,\n postition: PropTypes.string,\n }),\n icon: PropTypes.node,\n }),\n /**\n * URL to navigate when the home button is clicked.\n */\n homeUrl: PropTypes.string.isRequired,\n /**\n * Props to be passed to the `Rename` component. Please check the `Rename` component props for more details\n */\n renameProps: PropTypes.object,\n /**\n * To render extra content in the block.\n */\n children: PropTypes.node,\n};\n\nexport default LeftBlock;\n","import { joinHyphenCase } from \"neetocommons/utils/general\";\nimport { Typography } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { NavLink } from \"react-router-dom\";\n\nconst NavigationLinks = ({ headerLinks }) => (\n <div\n className=\"flex w-full items-center justify-between gap-4 md:justify-center md:gap-3 lg:gap-6\"\n data-cy=\"navigation-header-navigation-links\"\n data-testid=\"navigation-header-navigation-links\"\n >\n {headerLinks.map(headerLink => (\n <NavLink\n activeClassName=\"active\"\n className=\"neeto-molecules-navigation-header__link px-2 capitalize no-underline md:px-0\"\n data-cy={`${joinHyphenCase(headerLink.key)}-tab`}\n key={headerLink.key}\n {...headerLink}\n >\n <Typography lineHeight=\"normal\" style=\"h4\" weight=\"semibold\">\n {headerLink.label}\n </Typography>\n </NavLink>\n ))}\n </div>\n);\n\nNavigationLinks.propTypes = {\n /**\n * Links to be rendered in the center of the navigation header. It is an array of objects.\n * Each object should have the properties `key`, `to` and `label`. Other props will be passed on to the `Navlink` component from\n `react-router-dom`.\n */\n headerLinks: PropTypes.arrayOf(\n PropTypes.shape({\n key: PropTypes.string,\n to: PropTypes.string,\n label: PropTypes.string,\n })\n ),\n};\n\nexport default NavigationLinks;\n","import classNames from \"classnames\";\nimport PropTypes from \"prop-types\";\nimport { useTranslation } from \"react-i18next\";\n\nimport PublishBlock from \"components/PublishBlock\";\n\nimport \"./navigation-header.scss\";\n\nconst RightBlock = ({\n isDraftBlockHidden,\n previewDraftUrl,\n isResetDraftButtonVisible,\n onResetClick,\n isResetting,\n isPublishDisabled,\n isPublishing,\n handlePublish,\n isPublishPreviewDisabled,\n previewPublishedUrl,\n isPublishButtonVisible,\n isResetAlertOpen,\n setIsResetAlertOpen,\n handleReset,\n publishAlertTitle,\n publishAlertDescription,\n publishButtonProps = {},\n}) => {\n const { t } = useTranslation();\n\n const renderDraftButtons = ({ ViewDraftButton, ResetDraftButton }) =>\n !isDraftBlockHidden && (\n <>\n <ViewDraftButton to={previewDraftUrl} />\n {isResetDraftButtonVisible && (\n <ResetDraftButton\n loading={isResetting}\n onClick={() => onResetClick()}\n />\n )}\n </>\n );\n\n const renderPublishButtons = ({ PublishButton, PublishPreviewButton }) => (\n <>\n {isPublishButtonVisible && (\n <PublishButton\n disabled={isPublishDisabled}\n loading={isPublishing}\n onClick={() => handlePublish()}\n {...publishButtonProps}\n />\n )}\n <PublishPreviewButton\n disabled={isPublishPreviewDisabled}\n to={previewPublishedUrl}\n className={classNames({\n \"standalone-publish-preview-button\": !isPublishButtonVisible,\n })}\n />\n </>\n );\n\n return (\n <>\n <PublishBlock {...{ renderDraftButtons, renderPublishButtons }} />\n <PublishBlock.Alert\n isOpen={isResetAlertOpen}\n isSubmitting={isResetting}\n message={\n publishAlertDescription ||\n t(\"neetoMolecules.navigationHeader.resetDescription\")\n }\n title={\n publishAlertTitle || t(\"neetoMolecules.navigationHeader.resetTitle\")\n }\n onClose={() => setIsResetAlertOpen(false)}\n onSubmit={handleReset}\n />\n </>\n );\n};\n\nRightBlock.propTypes = {\n /**\n * To show/hide the draft block.\n */\n isDraftBlockHidden: PropTypes.bool,\n /**\n * Draft preview URL, when the draft button is clicked user will be redirected to this URL.\n */\n previewDraftUrl: PropTypes.string,\n /**\n * Boolean to control the visibility of reset draft button.\n */\n isResetDraftButtonVisible: PropTypes.bool,\n /**\n * Callback function that will be called when the reset button is clicked.\n */\n onResetClick: PropTypes.func,\n /**\n * Setting this to `true` will show a spinner on the reset button. Use when the reset process is in progress.\n */\n isResetting: PropTypes.bool,\n /**\n * To disable the publish button.\n */\n isPublishDisabled: PropTypes.bool,\n /**\n * Setting this to `true` will show a spinner on the publish button. Use when the publish process is in progress.\n */\n isPublishing: PropTypes.bool,\n /**\n * Callback function that will be called when the publish button is clicked.\n */\n handlePublish: PropTypes.func,\n /**\n * To disable the publish preview button.\n */\n isPublishPreviewDisabled: PropTypes.bool,\n /**\n * Publish preview URL, when the preview publish button is clicked user will be redirected to this URL.\n */\n previewPublishedUrl: PropTypes.string,\n /**\n * Boolean to control whether the user have the ability to publish.\n */\n isPublishButtonVisible: PropTypes.bool,\n /**\n * Boolean to control whether the reset alert is open.\n */\n isResetAlertOpen: PropTypes.bool,\n /**\n * Handler to control the `isResetAlert` state variable.\n */\n setIsResetAlertOpen: PropTypes.func,\n /**\n * Callback function that will be called when the reset button is clicked.\n */\n handleReset: PropTypes.func,\n /**\n * Description to be shown in the publish alert\n */\n publishAlertDescription: PropTypes.string,\n /**\n * Title of the publish alert\n */\n publishAlertTitle: PropTypes.string,\n /**\n * Props to be passed to the publish button\n */\n publishButtonProps: PropTypes.object,\n};\n\nexport default RightBlock;\n","import { isPresent } from \"neetocist\";\nimport useBreakpoints from \"neetocommons/react-utils/useBreakpoints\";\nimport PropTypes from \"prop-types\";\nimport { filter, length } from \"ramda\";\n\nimport LeftBlock from \"./LeftBlock\";\nimport NavigationLinks from \"./Navigation\";\nimport RightBlock from \"./RightBlock\";\n\nconst NavigationHeader = ({\n leftActionBlock,\n navigationLinks,\n rightActionBlock,\n}) => {\n const { isSize } = useBreakpoints();\n const isMobile = isSize(\"mobile\");\n\n const numberOfChildren = length(\n filter(isPresent, [leftActionBlock, navigationLinks, rightActionBlock])\n );\n\n return (\n <div className=\"w-full\">\n <div\n className=\"neeto-molecules-navigation-header neeto-ui-border-gray-200 neeto-ui-bg-white flex h-16 w-full flex-shrink-0 items-center overflow-x-auto border-b px-2 py-2 md:px-4 lg:px-6\"\n data-cy=\"navigation-header\"\n data-testid=\"navigation-header\"\n >\n <div\n className=\"grid w-full gap-4\"\n style={{\n gridTemplateColumns: isMobile\n ? `repeat(${numberOfChildren - 1}, 1fr)`\n : `repeat(${numberOfChildren}, 1fr)`,\n }}\n >\n {leftActionBlock}\n {!isMobile && navigationLinks}\n {rightActionBlock}\n </div>\n </div>\n {isMobile && (\n <div className=\"neeto-molecules-navigation-header neeto-ui-border-gray-200 neeto-ui-bg-white ßflex-shrink-0 flex items-center overflow-x-auto border-b px-4 py-2 lg:px-6\">\n {navigationLinks}\n </div>\n )}\n </div>\n );\n};\n\nNavigationHeader.LeftActionBlock = LeftBlock;\nNavigationHeader.NavigationLinks = NavigationLinks;\nNavigationHeader.RightActionBlock = RightBlock;\n\nNavigationHeader.propTypes = {\n /**\n * To specify the content to be rendered in the left side of the `NavigationHeader`.\n */\n leftActionBlock: PropTypes.node,\n /**\n * To specify the content to be rendered at the center of the `NavigationHeader`.\n */\n navigationLinks: PropTypes.node,\n /**\n * To specify the content to be rendered in the right side of the `NavigationHeader`.\n */\n rightActionBlock: PropTypes.node,\n};\n\nexport default NavigationHeader;\n"],"names":["DEFAULT_HOME_BUTTON_PROPS","tooltip","content","t","position","homeUrl","icon","_jsx","Home","LeftBlock","_ref","customHomeButtonProps","homeButtonProps","renameProps","children","mergeDeepRight","_jsxs","className","Tooltip","touch","Link","to","isPresent","Rename","_objectSpread","dropdownItems","value","NavigationLinks","headerLinks","map","headerLink","NavLink","activeClassName","concat","joinHyphenCase","key","Typography","lineHeight","style","weight","label","RightBlock","isDraftBlockHidden","previewDraftUrl","isResetDraftButtonVisible","onResetClick","isResetting","isPublishDisabled","isPublishing","handlePublish","isPublishPreviewDisabled","previewPublishedUrl","isPublishButtonVisible","isResetAlertOpen","setIsResetAlertOpen","handleReset","publishAlertTitle","publishAlertDescription","_ref$publishButtonPro","publishButtonProps","_useTranslation","useTranslation","renderDraftButtons","_ref2","ViewDraftButton","ResetDraftButton","_Fragment","loading","onClick","renderPublishButtons","_ref3","PublishButton","PublishPreviewButton","disabled","classNames","PublishBlock","Alert","isOpen","isSubmitting","message","title","onClose","onSubmit","NavigationHeader","leftActionBlock","navigationLinks","rightActionBlock","_useBreakpoints","useBreakpoints","isSize","isMobile","numberOfChildren","length","filter","gridTemplateColumns","LeftActionBlock","RightActionBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,yBAAyB,GAAG;AACvCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAEC,CAAC,CAAC,sCAAsC,CAAC;AAClDC,IAAAA,QAAQ,EAAE,QAAA;GACX;AACDC,EAAAA,OAAO,EAAE,GAAG;AACZC,EAAAA,IAAI,eAAEC,GAAA,CAACC,IAAI,EAAE,EAAA,CAAA;AACf,CAAC;;;;ACAD,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAAC,IAAA,EAKT;AAAA,EAAA,IAJaC,qBAAqB,GAAAD,IAAA,CAAtCE,eAAe;IACfP,OAAO,GAAAK,IAAA,CAAPL,OAAO;IACPQ,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ,CAAA;AAER,EAAA,IAAMF,eAAe,GAAGG,cAAc,CACpCf,yBAAyB,EACzBW,qBACF,CAAC,CAAA;AAED,EAAA,oBACEK,IAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,SAAS,EAAC,kCAAkC;AAC5C,IAAA,SAAA,EAAQ,8BAA8B;AACtC,IAAA,aAAA,EAAY,8BAA8B;IAAAH,QAAA,EAAA,cAE1CP,GAAA,CAACW,OAAO,EAAA;AACNhB,MAAAA,OAAO,EAAEU,eAAe,CAACX,OAAO,CAACC,OAAQ;AACzCE,MAAAA,QAAQ,EAAEQ,eAAe,CAACX,OAAO,CAACG,QAAS;AAC3Ce,MA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CAAA;AAEjC,EAAA,IAAME,gBAAgB,GAAGC,MAAM,CAC7BC,MAAM,CAACvE,SAAS,EAAE,CAAC8D,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,CAAC,CACxE,CAAC,CAAA;AAED,EAAA,oBACEtE,IAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,QAAQ;AAAAH,IAAAA,QAAA,gBACrBP,GAAA,CAAA,KAAA,EAAA;AACEU,MAAAA,SAAS,EAAC,6KAA6K;AACvL,MAAA,SAAA,EAAQ,mBAAmB;AAC3B,MAAA,aAAA,EAAY,mBAAmB;AAAAH,MAAAA,QAAA,eAE/BE,IAAA,CAAA,KAAA,EAAA;AACEC,QAAAA,SAAS,EAAC,mBAAmB;AAC7BqB,QAAAA,KAAK,EAAE;UACLwD,mBAAmB,EAAEJ,QAAQ,GAAA,SAAA,CAAAzD,MAAA,CACf0D,gBAAgB,GAAG,CAAC,EAAA,QAAA,CAAA,GAAA,SAAA,CAAA1D,MAAA,CACpB0D,gBAAgB,EAAA,QAAA,CAAA;SAC9B;QAAA7E,QAAA,EAAA,CAEDsE,eAAe,EACf,CAACM,QAAQ,IAAIL,eAAe,EAC5BC,gBAAgB,CAAA;OACd,CAAA;AAAC,KACH,CAAC,EACLI,QAAQ,iBACPnF,GAAA,CAAA,KAAA,EAAA;AAAKU,MAAAA,SAAS,EAAC,6JAA0J;AAAAH,MAAAA,QAAA,EACtKuE,eAAAA;AAAe,KACb,CACN,CAAA;AAAA,GACE,CAAC,CAAA;AAEV,EAAC;AAEDF,gBAAgB,CAACY,eAAe,GAAGtF,SAAS,CAAA;AAC5C0E,gBAAgB,CAACxD,eAAe,GAAGA,eAAe,CAAA;AAClDwD,gBAAgB,CAACa,gBAAgB,GAAGvD,UAAU;;;;"}
|
|
1
|
+
{"version":3,"file":"NavigationHeader.js","sources":["../src/components/NavigationHeader/constants.jsx","../src/components/NavigationHeader/LeftBlock.jsx","../src/components/NavigationHeader/Navigation.jsx","../src/components/NavigationHeader/utils.js","../src/components/NavigationHeader/RightBlock.jsx","../src/components/NavigationHeader/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport { Home } from \"neetoicons\";\n\nexport const DEFAULT_HOME_BUTTON_PROPS = {\n tooltip: {\n content: t(\"neetoMolecules.navigationHeader.home\"),\n position: \"bottom\",\n },\n homeUrl: \"/\",\n icon: <Home />,\n};\n","import { isPresent } from \"neetocist\";\nimport { Tooltip } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { mergeDeepRight } from \"ramda\";\nimport { Link } from \"react-router-dom\";\n\nimport Rename from \"components/Rename\";\n\nimport { DEFAULT_HOME_BUTTON_PROPS } from \"./constants\";\n\nconst LeftBlock = ({\n homeButtonProps: customHomeButtonProps,\n homeUrl,\n renameProps,\n children,\n}) => {\n const homeButtonProps = mergeDeepRight(\n DEFAULT_HOME_BUTTON_PROPS,\n customHomeButtonProps\n );\n\n return (\n <div\n className=\"flex items-center gap-1 md:gap-2\"\n data-cy=\"navigation-header-left-block\"\n data-testid=\"navigation-header-left-block\"\n >\n <Tooltip\n content={homeButtonProps.tooltip.content}\n position={homeButtonProps.tooltip.position}\n touch={[\"hold\", 500]}\n >\n <Link data-cy=\"home-button\" data-testid=\"home-button\" to={homeUrl}>\n <div className=\"neeto-ui-rounded hover:neeto-ui-bg-gray-200 p-1\">\n {homeButtonProps.icon}\n </div>\n </Link>\n </Tooltip>\n {isPresent(renameProps) && (\n <Rename\n dropdownItems={renameProps.dropdownItems}\n value={renameProps.value}\n {...renameProps}\n />\n )}\n {children}\n </div>\n );\n};\n\nLeftBlock.propTypes = {\n /**\n * Object containing the home button icon and the props to be passed to the tooltip of the home button.\n */\n homeButtonProps: PropTypes.shape({\n tooltip: PropTypes.shape({\n content: PropTypes.string,\n postition: PropTypes.string,\n }),\n icon: PropTypes.node,\n }),\n /**\n * URL to navigate when the home button is clicked.\n */\n homeUrl: PropTypes.string.isRequired,\n /**\n * Props to be passed to the `Rename` component. Please check the `Rename` component props for more details\n */\n renameProps: PropTypes.object,\n /**\n * To render extra content in the block.\n */\n children: PropTypes.node,\n};\n\nexport default LeftBlock;\n","import classNames from \"classnames\";\nimport { existsBy, isNotEmpty } from \"neetocist\";\nimport { joinHyphenCase } from \"neetocommons/utils/general\";\nimport { Dropdown, Typography } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { useTranslation } from \"react-i18next\";\nimport { NavLink, useLocation } from \"react-router-dom\";\n\nconst { Menu, MenuItem } = Dropdown;\n\nconst NavigationLinks = ({ headerLinks, maxVisibleLinks = 5 }) => {\n const { pathname } = useLocation();\n const { t } = useTranslation();\n\n const visibleLinks = headerLinks.slice(0, maxVisibleLinks);\n const overflowLinks = headerLinks.slice(maxVisibleLinks);\n\n const isMoreButtonActive = existsBy({ to: pathname }, overflowLinks);\n\n return (\n <div\n className=\"font- flex w-full items-center justify-between gap-4 md:justify-center md:gap-3 lg:gap-6\"\n data-cy=\"navigation-header-navigation-links\"\n data-testid=\"navigation-header-navigation-links\"\n >\n {visibleLinks.map(headerLink => (\n <NavLink\n activeClassName=\"active\"\n className=\"neeto-molecules-navigation-header__link px-2 capitalize no-underline md:px-0\"\n data-cy={`${joinHyphenCase(headerLink.key)}-tab`}\n key={headerLink.key}\n {...headerLink}\n >\n <Typography\n component=\"span\"\n lineHeight=\"normal\"\n style=\"h4\"\n weight=\"semibold\"\n >\n {headerLink.label}\n </Typography>\n </NavLink>\n ))}\n {isNotEmpty(overflowLinks) && (\n <Dropdown\n buttonStyle=\"text\"\n label={t(\"neetoMolecules.navigationHeader.more\")}\n position=\"bottom-end\"\n buttonProps={{\n className: classNames(\n \"neeto-molecules-navigation-header__link neeto-molecules-navigation-header__link--more neeto-ui-typography neeto-ui-text-h4 neeto-ui-font-semibold neeto-ui-leading-normal px-2 capitalize no-underline md:px-0\",\n { active: isMoreButtonActive }\n ),\n }}\n >\n <Menu>\n {overflowLinks.map(headerLink => (\n <MenuItem.Button\n data-cy={`${joinHyphenCase(headerLink.key)}-more-tab`}\n isActive={headerLink.to === pathname}\n key={headerLink.key}\n to={headerLink.to}\n {...headerLink}\n >\n {headerLink.label}\n </MenuItem.Button>\n ))}\n </Menu>\n </Dropdown>\n )}\n </div>\n );\n};\n\nNavigationLinks.propTypes = {\n /**\n * Links to be rendered in the center of the navigation header. It is an array of objects.\n * Each object should have the properties `key`, `to` and `label`. Other props will be passed on to the `Navlink` component from\n `react-router-dom`.\n */\n headerLinks: PropTypes.arrayOf(\n PropTypes.shape({\n key: PropTypes.string,\n to: PropTypes.string,\n label: PropTypes.string,\n })\n ),\n /**\n * Maximum number of links to be visible in the navigation header. Remaining links will be shown in a more dropdown.\n */\n maxVisibleLinks: PropTypes.number,\n};\n\nexport default NavigationLinks;\n","export const isAbsoluteUrl = url => /^https?:\\/\\//.test(url);\n","import classNames from \"classnames\";\nimport PropTypes from \"prop-types\";\nimport { useTranslation } from \"react-i18next\";\n\nimport PublishBlock from \"components/PublishBlock\";\n\nimport \"./navigation-header.scss\";\nimport { isAbsoluteUrl } from \"./utils\";\n\nconst RightBlock = ({\n isDraftBlockHidden,\n previewDraftUrl,\n isResetDraftButtonVisible,\n onResetClick,\n isResetting,\n isPublishDisabled,\n isPublishing,\n handlePublish,\n isPublishPreviewDisabled,\n previewPublishedUrl,\n isPublishButtonVisible,\n isResetAlertOpen,\n setIsResetAlertOpen,\n handleReset,\n publishAlertTitle,\n publishAlertDescription,\n publishButtonProps = {},\n}) => {\n const { t } = useTranslation();\n\n const renderDraftButtons = ({ ViewDraftButton, ResetDraftButton }) =>\n !isDraftBlockHidden && (\n <>\n <ViewDraftButton\n {...(isAbsoluteUrl(previewDraftUrl)\n ? { href: previewDraftUrl }\n : { to: previewDraftUrl })}\n />\n {isResetDraftButtonVisible && (\n <ResetDraftButton\n loading={isResetting}\n onClick={() => onResetClick()}\n />\n )}\n </>\n );\n\n const renderPublishButtons = ({ PublishButton, PublishPreviewButton }) => (\n <>\n {isPublishButtonVisible && (\n <PublishButton\n disabled={isPublishDisabled}\n loading={isPublishing}\n onClick={() => handlePublish()}\n {...publishButtonProps}\n />\n )}\n <PublishPreviewButton\n {...(isAbsoluteUrl(previewPublishedUrl)\n ? { href: previewPublishedUrl }\n : { to: previewPublishedUrl })}\n disabled={isPublishPreviewDisabled}\n className={classNames({\n \"standalone-publish-preview-button\": !isPublishButtonVisible,\n })}\n />\n </>\n );\n\n return (\n <>\n <PublishBlock {...{ renderDraftButtons, renderPublishButtons }} />\n <PublishBlock.Alert\n isOpen={isResetAlertOpen}\n isSubmitting={isResetting}\n message={\n publishAlertDescription ||\n t(\"neetoMolecules.navigationHeader.resetDescription\")\n }\n title={\n publishAlertTitle || t(\"neetoMolecules.navigationHeader.resetTitle\")\n }\n onClose={() => setIsResetAlertOpen(false)}\n onSubmit={handleReset}\n />\n </>\n );\n};\n\nRightBlock.propTypes = {\n /**\n * To show/hide the draft block.\n */\n isDraftBlockHidden: PropTypes.bool,\n /**\n * Draft preview URL, when the draft button is clicked user will be redirected to this URL.\n */\n previewDraftUrl: PropTypes.string,\n /**\n * Boolean to control the visibility of reset draft button.\n */\n isResetDraftButtonVisible: PropTypes.bool,\n /**\n * Callback function that will be called when the reset button is clicked.\n */\n onResetClick: PropTypes.func,\n /**\n * Setting this to `true` will show a spinner on the reset button. Use when the reset process is in progress.\n */\n isResetting: PropTypes.bool,\n /**\n * To disable the publish button.\n */\n isPublishDisabled: PropTypes.bool,\n /**\n * Setting this to `true` will show a spinner on the publish button. Use when the publish process is in progress.\n */\n isPublishing: PropTypes.bool,\n /**\n * Callback function that will be called when the publish button is clicked.\n */\n handlePublish: PropTypes.func,\n /**\n * To disable the publish preview button.\n */\n isPublishPreviewDisabled: PropTypes.bool,\n /**\n * Publish preview URL, when the preview publish button is clicked user will be redirected to this URL.\n */\n previewPublishedUrl: PropTypes.string,\n /**\n * Boolean to control whether the user have the ability to publish.\n */\n isPublishButtonVisible: PropTypes.bool,\n /**\n * Boolean to control whether the reset alert is open.\n */\n isResetAlertOpen: PropTypes.bool,\n /**\n * Handler to control the `isResetAlert` state variable.\n */\n setIsResetAlertOpen: PropTypes.func,\n /**\n * Callback function that will be called when the reset button is clicked.\n */\n handleReset: PropTypes.func,\n /**\n * Description to be shown in the publish alert\n */\n publishAlertDescription: PropTypes.string,\n /**\n * Title of the publish alert\n */\n publishAlertTitle: PropTypes.string,\n /**\n * Props to be passed to the publish button\n */\n publishButtonProps: PropTypes.object,\n};\n\nexport default RightBlock;\n","import { isPresent } from \"neetocist\";\nimport useBreakpoints from \"neetocommons/react-utils/useBreakpoints\";\nimport PropTypes from \"prop-types\";\nimport { filter, length } from \"ramda\";\n\nimport LeftBlock from \"./LeftBlock\";\nimport NavigationLinks from \"./Navigation\";\nimport RightBlock from \"./RightBlock\";\n\nconst NavigationHeader = ({\n leftActionBlock,\n navigationLinks,\n rightActionBlock,\n}) => {\n const { isSize } = useBreakpoints();\n const isMobile = isSize(\"mobile\");\n\n const numberOfChildren = length(\n filter(isPresent, [leftActionBlock, navigationLinks, rightActionBlock])\n );\n\n return (\n <div className=\"w-full\">\n <div\n className=\"neeto-molecules-navigation-header neeto-ui-border-gray-200 neeto-ui-bg-white flex h-16 w-full flex-shrink-0 items-center overflow-x-auto border-b px-2 py-2 md:px-4 lg:px-6\"\n data-cy=\"navigation-header\"\n data-testid=\"navigation-header\"\n >\n <div\n className=\"grid w-full gap-4\"\n style={{\n gridTemplateColumns: isMobile\n ? `repeat(${numberOfChildren - 1}, 1fr)`\n : `repeat(${numberOfChildren}, 1fr)`,\n }}\n >\n {leftActionBlock}\n {!isMobile && navigationLinks}\n {rightActionBlock}\n </div>\n </div>\n {isMobile && (\n <div className=\"neeto-molecules-navigation-header neeto-ui-border-gray-200 neeto-ui-bg-white ßflex-shrink-0 flex items-center overflow-x-auto border-b px-4 py-2 lg:px-6\">\n {navigationLinks}\n </div>\n )}\n </div>\n );\n};\n\nNavigationHeader.LeftActionBlock = LeftBlock;\nNavigationHeader.NavigationLinks = NavigationLinks;\nNavigationHeader.RightActionBlock = RightBlock;\n\nNavigationHeader.propTypes = {\n /**\n * To specify the content to be rendered in the left side of the `NavigationHeader`.\n */\n leftActionBlock: PropTypes.node,\n /**\n * To specify the content to be rendered at the center of the `NavigationHeader`.\n */\n navigationLinks: PropTypes.node,\n /**\n * To specify the content to be rendered in the right side of the `NavigationHeader`.\n */\n rightActionBlock: PropTypes.node,\n};\n\nexport default NavigationHeader;\n"],"names":["DEFAULT_HOME_BUTTON_PROPS","tooltip","content","t","position","homeUrl","icon","_jsx","Home","LeftBlock","_ref","customHomeButtonProps","homeButtonProps","renameProps","children","mergeDeepRight","_jsxs","className","Tooltip","touch","Link","to","isPresent","Rename","_objectSpread","dropdownItems","value","Menu","Dropdown","MenuItem","NavigationLinks","headerLinks","_ref$maxVisibleLinks","maxVisibleLinks","_useLocation","useLocation","pathname","_useTranslation","useTranslation","visibleLinks","slice","overflowLinks","isMoreButtonActive","existsBy","map","headerLink","NavLink","activeClassName","concat","joinHyphenCase","key","Typography","component","lineHeight","style","weight","label","isNotEmpty","buttonStyle","buttonProps","classNames","active","Button","isActive","isAbsoluteUrl","url","test","RightBlock","isDraftBlockHidden","previewDraftUrl","isResetDraftButtonVisible","onResetClick","isResetting","isPublishDisabled","isPublishing","handlePublish","isPublishPreviewDisabled","previewPublishedUrl","isPublishButtonVisible","isResetAlertOpen","setIsResetAlertOpen","handleReset","publishAlertTitle","publishAlertDescription","_ref$publishButtonPro","publishButtonProps","renderDraftButtons","_ref2","ViewDraftButton","ResetDraftButton","_Fragment","href","loading","onClick","renderPublishButtons","_ref3","PublishButton","PublishPreviewButton","disabled","PublishBlock","Alert","isOpen","isSubmitting","message","title","onClose","onSubmit","NavigationHeader","leftActionBlock","navigationLinks","rightActionBlock","_useBreakpoints","useBreakpoints","isSize","isMobile","numberOfChildren","length","filter","gridTemplateColumns","LeftActionBlock","RightActionBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAMA,y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C,gBAAgB,CAAA;OACd,CAAA;AAAC,KACH,CAAC,EACLI,QAAQ,iBACP3G,GAAA,CAAA,KAAA,EAAA;AAAKU,MAAAA,SAAS,EAAC,6JAA0J;AAAAH,MAAAA,QAAA,EACtK+F,eAAAA;AAAe,KACb,CACN,CAAA;AAAA,GACE,CAAC,CAAA;AAEV,EAAC;AAEDF,gBAAgB,CAACY,eAAe,GAAG9G,SAAS,CAAA;AAC5CkG,gBAAgB,CAAC7E,eAAe,GAAGA,eAAe,CAAA;AAClD6E,gBAAgB,CAACa,gBAAgB,GAAGrD,UAAU;;;;"}
|
package/dist/ProductEmbed.js
CHANGED
|
@@ -2,23 +2,23 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
3
|
import { useState, useEffect, createElement } from 'react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { noop } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { filterBy, noop } from '@bigbinary/neeto-cist';
|
|
6
6
|
import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
|
|
7
7
|
import Button from '@bigbinary/neetoui/Button';
|
|
8
8
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
9
|
-
import {
|
|
9
|
+
import { toPairs, mergeDeepLeft, isEmpty, mergeLeft } from 'ramda';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import Codeblock from './Codeblock.js';
|
|
12
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
13
13
|
import { t } from 'i18next';
|
|
14
14
|
import Code$1 from '@bigbinary/neeto-icons/Code';
|
|
15
|
-
import Eye from '@bigbinary/neeto-icons/Eye';
|
|
16
15
|
import Input from '@bigbinary/neetoui/Input';
|
|
17
16
|
import Callout from '@bigbinary/neetoui/Callout';
|
|
18
17
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
19
18
|
import Delete from '@bigbinary/neeto-icons/Delete';
|
|
20
19
|
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
21
20
|
import Label from '@bigbinary/neetoui/Label';
|
|
21
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
22
22
|
import Checkbox from '@bigbinary/neetoui/Checkbox';
|
|
23
23
|
import Select from '@bigbinary/neetoui/Select';
|
|
24
24
|
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
@@ -30,17 +30,17 @@ import { n } from './inject-css-DmrvuTKK.js';
|
|
|
30
30
|
import 'react-syntax-highlighter';
|
|
31
31
|
import 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
32
32
|
import './CopyToClipboardButton.js';
|
|
33
|
-
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
34
33
|
import '@bigbinary/neeto-commons-frontend/utils/general';
|
|
35
34
|
import '@bigbinary/neeto-icons/Copy';
|
|
36
35
|
import '@bigbinary/neeto-icons/Check';
|
|
37
36
|
|
|
38
37
|
var Code = function Code(_ref) {
|
|
39
|
-
var code = _ref.code
|
|
38
|
+
var code = _ref.code,
|
|
39
|
+
tab = _ref.tab;
|
|
40
40
|
return /*#__PURE__*/jsx("div", {
|
|
41
|
-
className: "relative w-full overflow-y-auto",
|
|
41
|
+
className: "neeto-molecules-embed__code-block relative w-full overflow-y-auto",
|
|
42
42
|
"data-cy": "embed-code-block",
|
|
43
|
-
"data-testid": "
|
|
43
|
+
"data-testid": "".concat(tab, "-code-block"),
|
|
44
44
|
children: /*#__PURE__*/jsx(Codeblock, {
|
|
45
45
|
code: code
|
|
46
46
|
})
|
|
@@ -49,16 +49,16 @@ var Code = function Code(_ref) {
|
|
|
49
49
|
|
|
50
50
|
var TAB_KEYS = {
|
|
51
51
|
HTML: "html",
|
|
52
|
-
|
|
52
|
+
REACT: "react"
|
|
53
53
|
};
|
|
54
54
|
var TABS = [{
|
|
55
55
|
key: TAB_KEYS.HTML,
|
|
56
56
|
label: t("neetoMolecules.productEmbed.tab.html"),
|
|
57
57
|
icon: Code$1
|
|
58
58
|
}, {
|
|
59
|
-
key: TAB_KEYS.
|
|
60
|
-
label: t("neetoMolecules.productEmbed.tab.
|
|
61
|
-
icon:
|
|
59
|
+
key: TAB_KEYS.REACT,
|
|
60
|
+
label: t("neetoMolecules.productEmbed.tab.react"),
|
|
61
|
+
icon: Code$1
|
|
62
62
|
}];
|
|
63
63
|
var EMBED_OPTIONS = {
|
|
64
64
|
INLINE: "inline",
|
|
@@ -93,17 +93,17 @@ var INITIAL_QUERY_PARAM = {
|
|
|
93
93
|
value: ""
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
96
|
+
var camelCasedAppName$1 = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
97
97
|
var embedBaseScript = function embedBaseScript(embedScriptLink) {
|
|
98
|
-
return "<script>window.".concat(camelCasedAppName, " = window.").concat(camelCasedAppName, " || { embed: function(){(").concat(camelCasedAppName, ".q=").concat(camelCasedAppName, ".q||[]).push(arguments)} };</script>\n <script async\n src=\"").concat(embedScriptLink, "\">\n </script>");
|
|
98
|
+
return "<script>window.".concat(camelCasedAppName$1, " = window.").concat(camelCasedAppName$1, " || { embed: function(){(").concat(camelCasedAppName$1, ".q=").concat(camelCasedAppName$1, ".q||[]).push(arguments)} };</script>\n <script async\n src=\"").concat(embedScriptLink, "\">\n </script>");
|
|
99
99
|
};
|
|
100
|
-
var embedEnv = function embedEnv() {
|
|
100
|
+
var embedEnv$1 = function embedEnv() {
|
|
101
101
|
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
102
102
|
};
|
|
103
|
-
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
103
|
+
var embedQueryParam$1 = function embedQueryParam(queryParams) {
|
|
104
104
|
return queryParams ? "\n".concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
|
|
105
105
|
};
|
|
106
|
-
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
106
|
+
var parseExtraArgs$1 = function parseExtraArgs(extraArgs) {
|
|
107
107
|
return toPairs(extraArgs).map(function (_ref) {
|
|
108
108
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
109
109
|
key = _ref2[0],
|
|
@@ -111,6 +111,81 @@ var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
|
111
111
|
return "\n".concat(TAB_STRING, " ").concat(key, ": \"").concat(value, "\"");
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
|
+
var inlineEmbedCode$1 = function inlineEmbedCode(_ref3) {
|
|
115
|
+
var customization = _ref3.customization,
|
|
116
|
+
id = _ref3.id,
|
|
117
|
+
embedScriptLink = _ref3.embedScriptLink,
|
|
118
|
+
extraArgs = _ref3.extraArgs,
|
|
119
|
+
inlineWrapperStyle = _ref3.inlineWrapperStyle;
|
|
120
|
+
var elementSelector = customization.elementSelector,
|
|
121
|
+
_customization$width = customization.width,
|
|
122
|
+
width = _customization$width === void 0 ? 100 : _customization$width,
|
|
123
|
+
_customization$height = customization.height,
|
|
124
|
+
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
125
|
+
queryParams = customization.queryParams;
|
|
126
|
+
return "\n <!-- ".concat(globalProps.appName, " inline embed code begins -->\n <div style=\"").concat(inlineWrapperStyle || "height: 90vh; width: 100%;", "\" id=\"").concat(elementSelector, "\">\n <!-- ").concat(globalProps.appName, " widget will be added here -->\n </div>\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: { height: \"").concat(height, "%\", width: \"").concat(width, "%\"},").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
|
|
127
|
+
};
|
|
128
|
+
var floatingPopupEmbedCode$1 = function floatingPopupEmbedCode(_ref4) {
|
|
129
|
+
var customization = _ref4.customization,
|
|
130
|
+
id = _ref4.id,
|
|
131
|
+
embedScriptLink = _ref4.embedScriptLink,
|
|
132
|
+
extraArgs = _ref4.extraArgs;
|
|
133
|
+
var btnTextColor = customization.btnTextColor,
|
|
134
|
+
showIcon = customization.showIcon,
|
|
135
|
+
btnText = customization.btnText,
|
|
136
|
+
btnPosition = customization.btnPosition,
|
|
137
|
+
btnColor = customization.btnColor,
|
|
138
|
+
icon = customization.icon,
|
|
139
|
+
queryParams = customization.queryParams;
|
|
140
|
+
return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\", ").concat(icon ? "\n".concat(TAB_STRING).concat(TAB_STRING, "showIcon: ").concat(showIcon, ",") : "", "\n },").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
|
|
141
|
+
};
|
|
142
|
+
var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
|
|
143
|
+
var customization = _ref5.customization,
|
|
144
|
+
id = _ref5.id,
|
|
145
|
+
embedScriptLink = _ref5.embedScriptLink,
|
|
146
|
+
extraArgs = _ref5.extraArgs;
|
|
147
|
+
var elementSelector = customization.elementSelector,
|
|
148
|
+
queryParams = customization.queryParams;
|
|
149
|
+
return "\n <!-- This is a demo button, you can use any element on your website instead. -->\n <button id=\"".concat(elementSelector, "\">Click to open popup</button>\n\n <!-- ").concat(globalProps.appName, " element-click embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
|
|
150
|
+
};
|
|
151
|
+
var htmlCodeGenerators = {
|
|
152
|
+
inline: inlineEmbedCode$1,
|
|
153
|
+
floatingPopup: floatingPopupEmbedCode$1,
|
|
154
|
+
elementPopup: elementPopupEmbedCode$1
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
|
|
158
|
+
var embedFunctionName = "embed".concat(globalProps.appName);
|
|
159
|
+
var baseScript = "const baseScript = document.createElement(\"script\");\n baseScript.innerHTML = `window.".concat(camelCasedAppName, " = window.").concat(camelCasedAppName, " || { embed: function(){(").concat(camelCasedAppName, ".q=").concat(camelCasedAppName, ".q||[]).push(arguments)} };`\n document.body.appendChild(baseScript);\n");
|
|
160
|
+
var embedScript = function embedScript(scriptLink) {
|
|
161
|
+
return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n document.body.appendChild(embedScript);\n");
|
|
162
|
+
};
|
|
163
|
+
var cleanupFunction = "// Cleanup function\n return () => {\n document.body.removeChild(baseScript);\n document.body.removeChild(embedScript);\n };";
|
|
164
|
+
var embedEnv = function embedEnv() {
|
|
165
|
+
return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
|
|
166
|
+
};
|
|
167
|
+
var embedQueryParam = function embedQueryParam(queryParams) {
|
|
168
|
+
return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
|
|
169
|
+
};
|
|
170
|
+
var parseExtraArgs = function parseExtraArgs(extraArgs) {
|
|
171
|
+
return toPairs(extraArgs).map(function (_ref) {
|
|
172
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
173
|
+
key = _ref2[0],
|
|
174
|
+
value = _ref2[1];
|
|
175
|
+
return "\n".concat(TAB_STRING).concat(TAB_STRING).concat(key, ": \"").concat(value, "\"");
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
var parseInlineStyle = function parseInlineStyle(styleString) {
|
|
179
|
+
return styleString ? styleString.split(";").map(function (rule) {
|
|
180
|
+
var _rule$split$map = rule.split(":").map(function (s) {
|
|
181
|
+
return s.trim();
|
|
182
|
+
}),
|
|
183
|
+
_rule$split$map2 = _slicedToArray(_rule$split$map, 2),
|
|
184
|
+
key = _rule$split$map2[0],
|
|
185
|
+
value = _rule$split$map2[1];
|
|
186
|
+
return key && value ? "".concat(key, ": \"").concat(value, "\"") : null;
|
|
187
|
+
}).filter(Boolean).join(", ") : 'height: "90vh", width: "100%"';
|
|
188
|
+
};
|
|
114
189
|
var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
115
190
|
var customization = _ref3.customization,
|
|
116
191
|
id = _ref3.id,
|
|
@@ -123,7 +198,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
|
|
|
123
198
|
_customization$height = customization.height,
|
|
124
199
|
height = _customization$height === void 0 ? 100 : _customization$height,
|
|
125
200
|
queryParams = customization.queryParams;
|
|
126
|
-
return "\n
|
|
201
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").concat(camelCasedAppName, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: { height: \"").concat(height, "%\", width: \"").concat(width, "%\" },").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return (\n <div\n id=\"inline-embed-container\"\n style={{ ").concat(parseInlineStyle(inlineWrapperStyle), " }}\n />\n );\n };");
|
|
127
202
|
};
|
|
128
203
|
var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
129
204
|
var customization = _ref4.customization,
|
|
@@ -137,7 +212,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
|
|
|
137
212
|
btnColor = customization.btnColor,
|
|
138
213
|
icon = customization.icon,
|
|
139
214
|
queryParams = customization.queryParams;
|
|
140
|
-
return "\n
|
|
215
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").concat(camelCasedAppName, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\",").concat(icon ? "\n".concat(TAB_STRING).concat(TAB_STRING, " showIcon: ").concat(showIcon, ",") : "", "\n },").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <div />;\n };");
|
|
141
216
|
};
|
|
142
217
|
var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
143
218
|
var customization = _ref5.customization,
|
|
@@ -146,55 +221,34 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
|
|
|
146
221
|
extraArgs = _ref5.extraArgs;
|
|
147
222
|
var elementSelector = customization.elementSelector,
|
|
148
223
|
queryParams = customization.queryParams;
|
|
149
|
-
return "\n
|
|
150
|
-
};
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
embedScriptLink: embedScriptLink,
|
|
165
|
-
extraArgs: extraArgs,
|
|
166
|
-
inlineWrapperStyle: inlineWrapperStyle
|
|
167
|
-
});
|
|
168
|
-
case "floatingPopup":
|
|
169
|
-
return floatingPopupEmbedCode({
|
|
170
|
-
customization: customization,
|
|
171
|
-
id: id,
|
|
172
|
-
embedScriptLink: embedScriptLink,
|
|
173
|
-
extraArgs: extraArgs
|
|
174
|
-
});
|
|
175
|
-
case "elementPopup":
|
|
176
|
-
return elementPopupEmbedCode({
|
|
177
|
-
customization: customization,
|
|
178
|
-
id: id,
|
|
179
|
-
embedScriptLink: embedScriptLink,
|
|
180
|
-
extraArgs: extraArgs
|
|
181
|
-
});
|
|
182
|
-
default:
|
|
183
|
-
return "";
|
|
184
|
-
}
|
|
224
|
+
return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(baseScript, "\n ").concat(embedScript(embedScriptLink), "\n ").concat(camelCasedAppName, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <button id=\"").concat(elementSelector, "\">Click to open popup</button>;\n };");
|
|
225
|
+
};
|
|
226
|
+
var reactCodeGenerators = {
|
|
227
|
+
inline: inlineEmbedCode,
|
|
228
|
+
floatingPopup: floatingPopupEmbedCode,
|
|
229
|
+
elementPopup: elementPopupEmbedCode
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var _excluded = ["tab", "type"];
|
|
233
|
+
var generateCode = function generateCode(options) {
|
|
234
|
+
var _reactCodeGenerators$, _htmlCodeGenerators$t;
|
|
235
|
+
var tab = options.tab,
|
|
236
|
+
type = options.type,
|
|
237
|
+
embeddedCodeOptions = _objectWithoutProperties(options, _excluded);
|
|
238
|
+
return tab === "react" ? (_reactCodeGenerators$ = reactCodeGenerators[type]) === null || _reactCodeGenerators$ === void 0 ? void 0 : _reactCodeGenerators$.call(reactCodeGenerators, embeddedCodeOptions) : (_htmlCodeGenerators$t = htmlCodeGenerators[type]) === null || _htmlCodeGenerators$t === void 0 ? void 0 : _htmlCodeGenerators$t.call(htmlCodeGenerators, embeddedCodeOptions);
|
|
185
239
|
};
|
|
186
240
|
var buildDefaultCustomization = function buildDefaultCustomization(defaultCustomizations) {
|
|
187
241
|
return mergeDeepLeft(defaultCustomizations, DEFAULT_CUSTOMIZATION);
|
|
188
242
|
};
|
|
189
243
|
var buildQueryParamsFromInputFields = function buildQueryParamsFromInputFields(inputFields) {
|
|
190
|
-
var filteredInputFields = inputFields.filter(function (
|
|
191
|
-
var name =
|
|
192
|
-
value =
|
|
244
|
+
var filteredInputFields = inputFields.filter(function (_ref) {
|
|
245
|
+
var name = _ref.name,
|
|
246
|
+
value = _ref.value;
|
|
193
247
|
return name && value;
|
|
194
248
|
});
|
|
195
|
-
var queryParams = filteredInputFields.reduce(function (queryParams,
|
|
196
|
-
var name =
|
|
197
|
-
value =
|
|
249
|
+
var queryParams = filteredInputFields.reduce(function (queryParams, _ref2) {
|
|
250
|
+
var name = _ref2.name,
|
|
251
|
+
value = _ref2.value;
|
|
198
252
|
queryParams[name] = value;
|
|
199
253
|
return queryParams;
|
|
200
254
|
}, {});
|
|
@@ -515,14 +569,15 @@ var Customization = function Customization(_ref) {
|
|
|
515
569
|
};
|
|
516
570
|
|
|
517
571
|
var Header = function Header(_ref) {
|
|
518
|
-
var
|
|
519
|
-
setTab = _ref.setTab
|
|
572
|
+
var supportedLanguagesTabs = _ref.supportedLanguagesTabs,
|
|
573
|
+
setTab = _ref.setTab,
|
|
574
|
+
tab = _ref.tab;
|
|
520
575
|
return /*#__PURE__*/jsx("div", {
|
|
521
|
-
className: "flex w-full
|
|
576
|
+
className: "flex w-full",
|
|
522
577
|
children: /*#__PURE__*/jsx(Tab, {
|
|
523
578
|
noUnderline: true,
|
|
524
579
|
className: "neeto-molecules-product-embed-tab",
|
|
525
|
-
children:
|
|
580
|
+
children: supportedLanguagesTabs.map(function (_ref2) {
|
|
526
581
|
var key = _ref2.key,
|
|
527
582
|
label = _ref2.label,
|
|
528
583
|
icon = _ref2.icon;
|
|
@@ -675,6 +730,8 @@ var Preview = function Preview(_ref) {
|
|
|
675
730
|
});
|
|
676
731
|
}
|
|
677
732
|
return /*#__PURE__*/jsx(BrowserPreview, {
|
|
733
|
+
className: "h-full",
|
|
734
|
+
wrapperClassName: "neeto-molecules-embed__browser-preview pointer-events-auto",
|
|
678
735
|
children: /*#__PURE__*/jsx(Component, {
|
|
679
736
|
customization: customization,
|
|
680
737
|
iframeURL: iframeURL
|
|
@@ -682,7 +739,7 @@ var Preview = function Preview(_ref) {
|
|
|
682
739
|
});
|
|
683
740
|
};
|
|
684
741
|
|
|
685
|
-
var css = ".neeto-molecules-product-embed-size-input.neeto-ui-input__wrapper .neeto-ui-input__prefix{align-self:stretch;background-color:rgb(var(--neeto-ui-gray-200));margin-left:0!important;padding-left:.75rem;padding-right:.75rem}.neeto-molecules-product-embed-tab{gap:.5rem}.neeto-molecules-product-embed-tab .neeto-ui-tab{border-radius:var(--neeto-ui-btn-border-radius);color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-product-embed-tab .neeto-ui-tab:not(.active):hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-molecules-product-embed-tab .neeto-ui-tab.active{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-molecules-embed__left-sidebar{align-items:flex-start;display:flex;flex-direction:column;flex-shrink:0;overflow-y:auto;padding:1.5rem;width:100%}@media (min-width:768px){.neeto-molecules-embed__left-sidebar{border-right:1px solid rgb(var(--neeto-ui-gray-200));max-width:25rem}}@media (min-width:1024px){.neeto-molecules-embed__left-sidebar{max-width:27.5rem}}";
|
|
742
|
+
var css = ".neeto-molecules-product-embed-size-input.neeto-ui-input__wrapper .neeto-ui-input__prefix{align-self:stretch;background-color:rgb(var(--neeto-ui-gray-200));margin-left:0!important;padding-left:.75rem;padding-right:.75rem}.neeto-molecules-product-embed-tab{gap:.5rem}.neeto-molecules-product-embed-tab .neeto-ui-tab{border-radius:var(--neeto-ui-btn-border-radius);color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-product-embed-tab .neeto-ui-tab:not(.active):hover{background-color:rgb(var(--neeto-ui-gray-100))}.neeto-molecules-product-embed-tab .neeto-ui-tab.active{background-color:rgb(var(--neeto-ui-gray-200))}.neeto-molecules-embed__left-sidebar{align-items:flex-start;display:flex;flex-direction:column;flex-shrink:0;overflow-y:auto;padding:1.5rem;width:100%}@media (min-width:768px){.neeto-molecules-embed__left-sidebar{border-right:1px solid rgb(var(--neeto-ui-gray-200));max-width:25rem}}@media (min-width:1024px){.neeto-molecules-embed__left-sidebar{max-width:27.5rem}}.neeto-molecules-embed__code-block .neeto-molecules-code-block{font-size:.875rem;height:15.625rem;margin-top:0!important}.neeto-molecules-embed__browser-preview{height:100%;min-height:18.75rem}.neeto-molecules-embed__browser-preview .neeto-molecules-browser-preview__body{position:relative}.neeto-molecules-embed__browser-preview .neeto-molecules-browser-preview__body iframe{height:100%;left:0;position:absolute;top:0;width:100%}";
|
|
686
743
|
n(css,{});
|
|
687
744
|
|
|
688
745
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -706,12 +763,19 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
706
763
|
_ref$otherCustomizati = _ref.otherCustomizations,
|
|
707
764
|
otherCustomizations = _ref$otherCustomizati === void 0 ? noop : _ref$otherCustomizati,
|
|
708
765
|
_ref$inlineWrapperSty = _ref.inlineWrapperStyle,
|
|
709
|
-
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty
|
|
766
|
+
inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty,
|
|
767
|
+
_ref$supportedLanguag = _ref.supportedLanguages,
|
|
768
|
+
supportedLanguages = _ref$supportedLanguag === void 0 ? ["html"] : _ref$supportedLanguag;
|
|
769
|
+
var supportedLanguagesTabs = filterBy({
|
|
770
|
+
key: function key(_key) {
|
|
771
|
+
return supportedLanguages === null || supportedLanguages === void 0 ? void 0 : supportedLanguages.includes(_key);
|
|
772
|
+
}
|
|
773
|
+
}, TABS);
|
|
710
774
|
var _useState = useState(true),
|
|
711
775
|
_useState2 = _slicedToArray(_useState, 2),
|
|
712
776
|
isScriptLoading = _useState2[0],
|
|
713
777
|
setIsScriptLoading = _useState2[1];
|
|
714
|
-
var _useState3 = useState(
|
|
778
|
+
var _useState3 = useState(supportedLanguagesTabs[0].key),
|
|
715
779
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
716
780
|
tab = _useState4[0],
|
|
717
781
|
setTab = _useState4[1];
|
|
@@ -728,8 +792,9 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
728
792
|
var _useTranslation = useTranslation(),
|
|
729
793
|
t = _useTranslation.t;
|
|
730
794
|
var embedScriptLink = customEmbedScriptPath || "".concat(window.location.protocol, "//").concat(window.location.host, "/javascript/embed.js");
|
|
731
|
-
var code =
|
|
795
|
+
var code = generateCode({
|
|
732
796
|
id: id,
|
|
797
|
+
tab: tab,
|
|
733
798
|
type: selectedOption,
|
|
734
799
|
customization: customizations[selectedOption],
|
|
735
800
|
embedScriptLink: embedScriptLink,
|
|
@@ -786,21 +851,30 @@ var ProductEmbed = function ProductEmbed(_ref) {
|
|
|
786
851
|
})]
|
|
787
852
|
})]
|
|
788
853
|
}), /*#__PURE__*/jsxs("div", {
|
|
789
|
-
className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-
|
|
854
|
+
className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-3 overflow-y-auto p-6 md:min-h-0 md:flex-grow",
|
|
790
855
|
children: [/*#__PURE__*/jsx(Header, {
|
|
791
856
|
setTab: setTab,
|
|
857
|
+
supportedLanguagesTabs: supportedLanguagesTabs,
|
|
792
858
|
tab: tab
|
|
793
|
-
}), /*#__PURE__*/
|
|
794
|
-
className: "flex flex-grow
|
|
795
|
-
children:
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
859
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
860
|
+
className: "flex min-h-0 flex-grow flex-col gap-3",
|
|
861
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
862
|
+
className: "flex-shrink-0",
|
|
863
|
+
"data-testid": "embed-code-block",
|
|
864
|
+
children: /*#__PURE__*/jsx(Code, {
|
|
865
|
+
code: code,
|
|
866
|
+
tab: tab
|
|
867
|
+
})
|
|
868
|
+
}), /*#__PURE__*/jsx("div", {
|
|
869
|
+
className: "flex-grow",
|
|
870
|
+
children: /*#__PURE__*/jsx(Preview, {
|
|
871
|
+
customPreviewIframeUrl: customPreviewIframeUrl,
|
|
872
|
+
id: id,
|
|
873
|
+
isScriptLoading: isScriptLoading,
|
|
874
|
+
selectedOption: selectedOption,
|
|
875
|
+
customization: customizations[selectedOption]
|
|
876
|
+
})
|
|
877
|
+
})]
|
|
804
878
|
})]
|
|
805
879
|
})]
|
|
806
880
|
});
|