@bigbinary/neeto-molecules 3.15.1 → 3.15.3

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.
@@ -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,SAAC,CAAC,sCAAsC,CAAC;AAClDC,IAAAA,QAAQ,EAAE,QAAA;GACX;AACDC,EAAAA,OAAO,EAAE,GAAG;AACZC,EAAAA,IAAI,eAAEC,cAAA,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,oBAAc,CACpCf,yBAAyB,EACzBW,qBACF,CAAC,CAAA;AAED,EAAA,oBACEK,eAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,SAAS,EAAC,kCAAkC;AAC5C,IAAA,SAAA,EAAQ,8BAA8B;AACtC,IAAA,aAAA,EAAY,8BAA8B;IAAAH,QAAA,EAAA,cAE1CP,cAAA,CAACW,OAAO,EAAA;AACNhB,MAAAA,OAAO,EAAEU,eAAe,CAACX,OAAO,CAACC,OAAQ;AACzCE,MAAAA,QAAQ,EAAEQ,eAAe,CAACX,OAAO,CAACG,QAAS;AAC3Ce,MAAAA,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,CAAE;MAAAL,QAAA,eAErBP,cAAA,CAACa,mBAAI,EAAA;AAAC,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,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,CAAC,CACxE,CAAC,CAAA;AAED,EAAA,oBACEtE,eAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAC,QAAQ;AAAAH,IAAAA,QAAA,gBACrBP,cAAA,CAAA,KAAA,EAAA;AACEU,MAAAA,SAAS,EAAC,6KAA6K;AACvL,MAAA,SAAA,EAAQ,mBAAmB;AAC3B,MAAA,aAAA,EAAY,mBAAmB;AAAAH,MAAAA,QAAA,eAE/BE,eAAA,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,cAAA,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/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","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","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","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","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,yBAAyB,GAAG;AACvCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAEC,SAAC,CAAC,sCAAsC,CAAC;AAClDC,IAAAA,QAAQ,EAAE,QAAA;GACX;AACDC,EAAAA,OAAO,EAAE,GAAG;AACZC,EAAAA,IAAI,eAAEC,cAAA,CAACC,IAAI,EAAE,EAAA,CAAA;AACf,CAAC;;;;ACAD,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAAC,IAAA,EAKT;AAAA,EAAA,IA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AAA,QAAA,gBACrBP,cAAA,CAAA,KAAA,EAAA;AACEU,MAAAA,SAAS,EAAC,6KAA6K;AACvL,MAAA,SAAA,EAAQ,mBAAmB;AAC3B,MAAA,aAAA,EAAY,mBAAmB;AAAAH,MAAAA,QAAA,eAE/BE,eAAA,CAAA,KAAA,EAAA;AACEC,QAAAA,SAAS,EAAC,mBAAmB;AAC7BqC,QAAAA,KAAK,EAAE;UACL4D,mBAAmB,EAAEJ,QAAQ,GAAA,SAAA,CAAA9D,MAAA,CACf+D,gBAAgB,GAAG,CAAC,EAAA,QAAA,CAAA,GAAA,SAAA,CAAA/D,MAAA,CACpB+D,gBAAgB,EAAA,QAAA,CAAA;SAC9B;QAAAjG,QAAA,EAAA,CAED0F,eAAe,EACf,CAACM,QAAQ,IAAIL,eAAe,EAC5BC,gBAAgB,CAAA;OACd,CAAA;AAAC,KACH,CAAC,EACLI,QAAQ,iBACPvG,cAAA,CAAA,KAAA,EAAA;AAAKU,MAAAA,SAAS,EAAC,6JAA0J;AAAAH,MAAAA,QAAA,EACtK2F,eAAAA;AAAe,KACb,CACN,CAAA;AAAA,GACE,CAAC,CAAA;AAEV,EAAC;AAEDF,gBAAgB,CAACY,eAAe,GAAG1G,SAAS,CAAA;AAC5C8F,gBAAgB,CAACzE,eAAe,GAAGA,eAAe,CAAA;AAClDyE,gBAAgB,CAACa,gBAAgB,GAAGpD,UAAU;;;;"}
@@ -14,13 +14,13 @@ var Codeblock = require('./Codeblock.js');
14
14
  var jsxRuntime = require('react/jsx-runtime');
15
15
  var i18next = require('i18next');
16
16
  var Code$1 = require('@bigbinary/neeto-icons/Code');
17
- var Eye = require('@bigbinary/neeto-icons/Eye');
18
17
  var Input = require('@bigbinary/neetoui/Input');
19
18
  var Callout = require('@bigbinary/neetoui/Callout');
20
19
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
21
20
  var Delete = require('@bigbinary/neeto-icons/Delete');
22
21
  var Plus = require('@bigbinary/neeto-icons/Plus');
23
22
  var Label = require('@bigbinary/neetoui/Label');
23
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
24
24
  var Checkbox = require('@bigbinary/neetoui/Checkbox');
25
25
  var Select = require('@bigbinary/neetoui/Select');
26
26
  var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
@@ -32,17 +32,17 @@ var injectCss = require('./inject-css-vQvjPR2x.js');
32
32
  require('react-syntax-highlighter');
33
33
  require('react-syntax-highlighter/dist/esm/styles/prism');
34
34
  require('./CopyToClipboardButton.js');
35
- require('@babel/runtime/helpers/objectWithoutProperties');
36
35
  require('@bigbinary/neeto-commons-frontend/utils/general');
37
36
  require('@bigbinary/neeto-icons/Copy');
38
37
  require('@bigbinary/neeto-icons/Check');
39
38
 
40
39
  var Code = function Code(_ref) {
41
- var code = _ref.code;
40
+ var code = _ref.code,
41
+ tab = _ref.tab;
42
42
  return /*#__PURE__*/jsxRuntime.jsx("div", {
43
- className: "relative w-full overflow-y-auto",
43
+ className: "neeto-molecules-embed__code-block relative w-full overflow-y-auto",
44
44
  "data-cy": "embed-code-block",
45
- "data-testid": "embed-code-block",
45
+ "data-testid": "".concat(tab, "-code-block"),
46
46
  children: /*#__PURE__*/jsxRuntime.jsx(Codeblock, {
47
47
  code: code
48
48
  })
@@ -51,16 +51,16 @@ var Code = function Code(_ref) {
51
51
 
52
52
  var TAB_KEYS = {
53
53
  HTML: "html",
54
- PREVIEW: "preview"
54
+ REACT: "react"
55
55
  };
56
56
  var TABS = [{
57
57
  key: TAB_KEYS.HTML,
58
58
  label: i18next.t("neetoMolecules.productEmbed.tab.html"),
59
59
  icon: Code$1
60
60
  }, {
61
- key: TAB_KEYS.PREVIEW,
62
- label: i18next.t("neetoMolecules.productEmbed.tab.preview"),
63
- icon: Eye
61
+ key: TAB_KEYS.REACT,
62
+ label: i18next.t("neetoMolecules.productEmbed.tab.react"),
63
+ icon: Code$1
64
64
  }];
65
65
  var EMBED_OPTIONS = {
66
66
  INLINE: "inline",
@@ -95,17 +95,17 @@ var INITIAL_QUERY_PARAM = {
95
95
  value: ""
96
96
  };
97
97
 
98
- var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
98
+ var camelCasedAppName$1 = globalProps.appName.replace(/^neeto/i, "neeto");
99
99
  var embedBaseScript = function embedBaseScript(embedScriptLink) {
100
- 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>");
100
+ 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>");
101
101
  };
102
- var embedEnv = function embedEnv() {
102
+ var embedEnv$1 = function embedEnv() {
103
103
  return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
104
104
  };
105
- var embedQueryParam = function embedQueryParam(queryParams) {
105
+ var embedQueryParam$1 = function embedQueryParam(queryParams) {
106
106
  return queryParams ? "\n".concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
107
107
  };
108
- var parseExtraArgs = function parseExtraArgs(extraArgs) {
108
+ var parseExtraArgs$1 = function parseExtraArgs(extraArgs) {
109
109
  return ramda.toPairs(extraArgs).map(function (_ref) {
110
110
  var _ref2 = _slicedToArray(_ref, 2),
111
111
  key = _ref2[0],
@@ -113,6 +113,81 @@ var parseExtraArgs = function parseExtraArgs(extraArgs) {
113
113
  return "\n".concat(TAB_STRING, " ").concat(key, ": \"").concat(value, "\"");
114
114
  });
115
115
  };
116
+ var inlineEmbedCode$1 = function inlineEmbedCode(_ref3) {
117
+ var customization = _ref3.customization,
118
+ id = _ref3.id,
119
+ embedScriptLink = _ref3.embedScriptLink,
120
+ extraArgs = _ref3.extraArgs,
121
+ inlineWrapperStyle = _ref3.inlineWrapperStyle;
122
+ var elementSelector = customization.elementSelector,
123
+ _customization$width = customization.width,
124
+ width = _customization$width === void 0 ? 100 : _customization$width,
125
+ _customization$height = customization.height,
126
+ height = _customization$height === void 0 ? 100 : _customization$height,
127
+ queryParams = customization.queryParams;
128
+ 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 -->");
129
+ };
130
+ var floatingPopupEmbedCode$1 = function floatingPopupEmbedCode(_ref4) {
131
+ var customization = _ref4.customization,
132
+ id = _ref4.id,
133
+ embedScriptLink = _ref4.embedScriptLink,
134
+ extraArgs = _ref4.extraArgs;
135
+ var btnTextColor = customization.btnTextColor,
136
+ showIcon = customization.showIcon,
137
+ btnText = customization.btnText,
138
+ btnPosition = customization.btnPosition,
139
+ btnColor = customization.btnColor,
140
+ icon = customization.icon,
141
+ queryParams = customization.queryParams;
142
+ 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 -->");
143
+ };
144
+ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref5) {
145
+ var customization = _ref5.customization,
146
+ id = _ref5.id,
147
+ embedScriptLink = _ref5.embedScriptLink,
148
+ extraArgs = _ref5.extraArgs;
149
+ var elementSelector = customization.elementSelector,
150
+ queryParams = customization.queryParams;
151
+ 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 -->");
152
+ };
153
+ var htmlCodeGenerators = {
154
+ inline: inlineEmbedCode$1,
155
+ floatingPopup: floatingPopupEmbedCode$1,
156
+ elementPopup: elementPopupEmbedCode$1
157
+ };
158
+
159
+ var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
160
+ var embedFunctionName = "embed".concat(globalProps.appName);
161
+ 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");
162
+ var embedScript = function embedScript(scriptLink) {
163
+ return "const embedScript = document.createElement(\"script\");\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n document.body.appendChild(embedScript);\n");
164
+ };
165
+ var cleanupFunction = "// Cleanup function\n return () => {\n document.body.removeChild(baseScript);\n document.body.removeChild(embedScript);\n };";
166
+ var embedEnv = function embedEnv() {
167
+ return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, "env: \"").concat(globalProps.railsEnv, "\",") : "";
168
+ };
169
+ var embedQueryParam = function embedQueryParam(queryParams) {
170
+ return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, "queryParams: ").concat(queryParams, ",") : "";
171
+ };
172
+ var parseExtraArgs = function parseExtraArgs(extraArgs) {
173
+ return ramda.toPairs(extraArgs).map(function (_ref) {
174
+ var _ref2 = _slicedToArray(_ref, 2),
175
+ key = _ref2[0],
176
+ value = _ref2[1];
177
+ return "\n".concat(TAB_STRING).concat(TAB_STRING).concat(key, ": \"").concat(value, "\"");
178
+ });
179
+ };
180
+ var parseInlineStyle = function parseInlineStyle(styleString) {
181
+ return styleString ? styleString.split(";").map(function (rule) {
182
+ var _rule$split$map = rule.split(":").map(function (s) {
183
+ return s.trim();
184
+ }),
185
+ _rule$split$map2 = _slicedToArray(_rule$split$map, 2),
186
+ key = _rule$split$map2[0],
187
+ value = _rule$split$map2[1];
188
+ return key && value ? "".concat(key, ": \"").concat(value, "\"") : null;
189
+ }).filter(Boolean).join(", ") : 'height: "90vh", width: "100%"';
190
+ };
116
191
  var inlineEmbedCode = function inlineEmbedCode(_ref3) {
117
192
  var customization = _ref3.customization,
118
193
  id = _ref3.id,
@@ -125,7 +200,7 @@ var inlineEmbedCode = function inlineEmbedCode(_ref3) {
125
200
  _customization$height = customization.height,
126
201
  height = _customization$height === void 0 ? 100 : _customization$height,
127
202
  queryParams = customization.queryParams;
128
- 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, ".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 </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
203
+ 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 };");
129
204
  };
130
205
  var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
131
206
  var customization = _ref4.customization,
@@ -139,7 +214,7 @@ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref4) {
139
214
  btnColor = customization.btnColor,
140
215
  icon = customization.icon,
141
216
  queryParams = customization.queryParams;
142
- return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\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 </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
217
+ 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 };");
143
218
  };
144
219
  var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
145
220
  var customization = _ref5.customization,
@@ -148,55 +223,34 @@ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref5) {
148
223
  extraArgs = _ref5.extraArgs;
149
224
  var elementSelector = customization.elementSelector,
150
225
  queryParams = customization.queryParams;
151
- 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, ".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 </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
152
- };
153
- var embedCode = function embedCode(_ref6) {
154
- var type = _ref6.type,
155
- customization = _ref6.customization,
156
- id = _ref6.id,
157
- embedScriptLink = _ref6.embedScriptLink,
158
- _ref6$extraArgs = _ref6.extraArgs,
159
- extraArgs = _ref6$extraArgs === void 0 ? {} : _ref6$extraArgs,
160
- inlineWrapperStyle = _ref6.inlineWrapperStyle;
161
- switch (type) {
162
- case "inline":
163
- return inlineEmbedCode({
164
- customization: customization,
165
- id: id,
166
- embedScriptLink: embedScriptLink,
167
- extraArgs: extraArgs,
168
- inlineWrapperStyle: inlineWrapperStyle
169
- });
170
- case "floatingPopup":
171
- return floatingPopupEmbedCode({
172
- customization: customization,
173
- id: id,
174
- embedScriptLink: embedScriptLink,
175
- extraArgs: extraArgs
176
- });
177
- case "elementPopup":
178
- return elementPopupEmbedCode({
179
- customization: customization,
180
- id: id,
181
- embedScriptLink: embedScriptLink,
182
- extraArgs: extraArgs
183
- });
184
- default:
185
- return "";
186
- }
226
+ 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 };");
227
+ };
228
+ var reactCodeGenerators = {
229
+ inline: inlineEmbedCode,
230
+ floatingPopup: floatingPopupEmbedCode,
231
+ elementPopup: elementPopupEmbedCode
232
+ };
233
+
234
+ var _excluded = ["tab", "type"];
235
+ var generateCode = function generateCode(options) {
236
+ var _reactCodeGenerators$, _htmlCodeGenerators$t;
237
+ var tab = options.tab,
238
+ type = options.type,
239
+ embeddedCodeOptions = _objectWithoutProperties(options, _excluded);
240
+ 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);
187
241
  };
188
242
  var buildDefaultCustomization = function buildDefaultCustomization(defaultCustomizations) {
189
243
  return ramda.mergeDeepLeft(defaultCustomizations, DEFAULT_CUSTOMIZATION);
190
244
  };
191
245
  var buildQueryParamsFromInputFields = function buildQueryParamsFromInputFields(inputFields) {
192
- var filteredInputFields = inputFields.filter(function (_ref7) {
193
- var name = _ref7.name,
194
- value = _ref7.value;
246
+ var filteredInputFields = inputFields.filter(function (_ref) {
247
+ var name = _ref.name,
248
+ value = _ref.value;
195
249
  return name && value;
196
250
  });
197
- var queryParams = filteredInputFields.reduce(function (queryParams, _ref8) {
198
- var name = _ref8.name,
199
- value = _ref8.value;
251
+ var queryParams = filteredInputFields.reduce(function (queryParams, _ref2) {
252
+ var name = _ref2.name,
253
+ value = _ref2.value;
200
254
  queryParams[name] = value;
201
255
  return queryParams;
202
256
  }, {});
@@ -517,14 +571,15 @@ var Customization = function Customization(_ref) {
517
571
  };
518
572
 
519
573
  var Header = function Header(_ref) {
520
- var tab = _ref.tab,
521
- setTab = _ref.setTab;
574
+ var supportedLanguagesTabs = _ref.supportedLanguagesTabs,
575
+ setTab = _ref.setTab,
576
+ tab = _ref.tab;
522
577
  return /*#__PURE__*/jsxRuntime.jsx("div", {
523
- className: "flex w-full pt-2",
578
+ className: "flex w-full",
524
579
  children: /*#__PURE__*/jsxRuntime.jsx(Tab, {
525
580
  noUnderline: true,
526
581
  className: "neeto-molecules-product-embed-tab",
527
- children: TABS.map(function (_ref2) {
582
+ children: supportedLanguagesTabs.map(function (_ref2) {
528
583
  var key = _ref2.key,
529
584
  label = _ref2.label,
530
585
  icon = _ref2.icon;
@@ -677,6 +732,8 @@ var Preview = function Preview(_ref) {
677
732
  });
678
733
  }
679
734
  return /*#__PURE__*/jsxRuntime.jsx(BrowserPreview, {
735
+ className: "h-full",
736
+ wrapperClassName: "neeto-molecules-embed__browser-preview pointer-events-auto",
680
737
  children: /*#__PURE__*/jsxRuntime.jsx(Component, {
681
738
  customization: customization,
682
739
  iframeURL: iframeURL
@@ -684,7 +741,7 @@ var Preview = function Preview(_ref) {
684
741
  });
685
742
  };
686
743
 
687
- 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}}";
744
+ 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%}";
688
745
  injectCss.n(css,{});
689
746
 
690
747
  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; }
@@ -708,12 +765,19 @@ var ProductEmbed = function ProductEmbed(_ref) {
708
765
  _ref$otherCustomizati = _ref.otherCustomizations,
709
766
  otherCustomizations = _ref$otherCustomizati === void 0 ? neetoCist.noop : _ref$otherCustomizati,
710
767
  _ref$inlineWrapperSty = _ref.inlineWrapperStyle,
711
- inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty;
768
+ inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "" : _ref$inlineWrapperSty,
769
+ _ref$supportedLanguag = _ref.supportedLanguages,
770
+ supportedLanguages = _ref$supportedLanguag === void 0 ? ["html"] : _ref$supportedLanguag;
771
+ var supportedLanguagesTabs = neetoCist.filterBy({
772
+ key: function key(_key) {
773
+ return supportedLanguages === null || supportedLanguages === void 0 ? void 0 : supportedLanguages.includes(_key);
774
+ }
775
+ }, TABS);
712
776
  var _useState = React.useState(true),
713
777
  _useState2 = _slicedToArray(_useState, 2),
714
778
  isScriptLoading = _useState2[0],
715
779
  setIsScriptLoading = _useState2[1];
716
- var _useState3 = React.useState(TAB_KEYS.HTML),
780
+ var _useState3 = React.useState(supportedLanguagesTabs[0].key),
717
781
  _useState4 = _slicedToArray(_useState3, 2),
718
782
  tab = _useState4[0],
719
783
  setTab = _useState4[1];
@@ -730,8 +794,9 @@ var ProductEmbed = function ProductEmbed(_ref) {
730
794
  var _useTranslation = reactI18next.useTranslation(),
731
795
  t = _useTranslation.t;
732
796
  var embedScriptLink = customEmbedScriptPath || "".concat(window.location.protocol, "//").concat(window.location.host, "/javascript/embed.js");
733
- var code = embedCode({
797
+ var code = generateCode({
734
798
  id: id,
799
+ tab: tab,
735
800
  type: selectedOption,
736
801
  customization: customizations[selectedOption],
737
802
  embedScriptLink: embedScriptLink,
@@ -788,21 +853,30 @@ var ProductEmbed = function ProductEmbed(_ref) {
788
853
  })]
789
854
  })]
790
855
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
791
- className: "neeto-molecules-embed__preview neeto-ui-bg-white flex min-h-screen w-full min-w-0 flex-col gap-4 p-6 md:min-h-0 md:flex-grow",
856
+ 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",
792
857
  children: [/*#__PURE__*/jsxRuntime.jsx(Header, {
793
858
  setTab: setTab,
859
+ supportedLanguagesTabs: supportedLanguagesTabs,
794
860
  tab: tab
795
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
796
- className: "flex flex-grow overflow-y-auto",
797
- children: tab === TAB_KEYS.PREVIEW ? /*#__PURE__*/jsxRuntime.jsx(Preview, {
798
- customPreviewIframeUrl: customPreviewIframeUrl,
799
- id: id,
800
- isScriptLoading: isScriptLoading,
801
- selectedOption: selectedOption,
802
- customization: customizations[selectedOption]
803
- }) : /*#__PURE__*/jsxRuntime.jsx(Code, {
804
- code: code
805
- })
861
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
862
+ className: "flex min-h-0 flex-grow flex-col gap-3",
863
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
864
+ className: "flex-shrink-0",
865
+ "data-testid": "embed-code-block",
866
+ children: /*#__PURE__*/jsxRuntime.jsx(Code, {
867
+ code: code,
868
+ tab: tab
869
+ })
870
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
871
+ className: "flex-grow",
872
+ children: /*#__PURE__*/jsxRuntime.jsx(Preview, {
873
+ customPreviewIframeUrl: customPreviewIframeUrl,
874
+ id: id,
875
+ isScriptLoading: isScriptLoading,
876
+ selectedOption: selectedOption,
877
+ customization: customizations[selectedOption]
878
+ })
879
+ })]
806
880
  })]
807
881
  })]
808
882
  });