id
stringlengths
12
53
messages
listlengths
3
3
code_store-on-localhost_92d737ad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/LineChart.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport LineChart from './components/EXPERIMENTAL_Charts/LineChart'\n\nexport default LineChart\n\n```" } ]
code_store-on-localhost_00922442
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/IconInlineGrid.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport InlineGrid from './components/icon/InlineGrid/index'\n\nexport default InlineGrid\n\n```" } ]
code_store-on-localhost_543e216f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/IconCaretDown.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport CaretDown from './components/icon/CaretDown/index'\n\nexport default CaretDown\n\n```" } ]
code_store-on-localhost_7c7ba877
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/Input.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Input from './components/Input/index'\n\nexport default Input\n\n```" } ]
code_store-on-localhost_d821113d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/withToast.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { withToast } from './components/ToastProvider/index'\n\nexport default withToast\n\n```" } ]
code_store-on-localhost_37a12bf6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/IconDeny.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Deny from './components/icon/Deny/index'\n\nexport default Deny\n\n```" } ]
code_store-on-localhost_d593bb51
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/EXPERIMENTAL_useCheckboxTree.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport { default } from './components/EXPERIMENTAL_useCheckboxTree'\n\n```" } ]
code_store-on-localhost_3849d42e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/EXPERIMENTAL_useTableMeasures.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport { default } from './components/EXPERIMENTAL_Table/hooks/useTableMeasures'\n\n```" } ]
code_store-on-localhost_aa9c1021
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/IconDelete.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Delete from './components/icon/Delete/index'\n\nexport default Delete\n\n```" } ]
code_store-on-localhost_10493f74
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/IconCaretRight.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport CaretRight from './components/icon/CaretRight/index'\n\nexport default CaretRight\n\n```" } ]
code_store-on-localhost_6e709c52
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/BarChart.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport BarChart from './components/EXPERIMENTAL_Charts/BarChart'\n\nexport default BarChart\n\n```" } ]
code_store-on-localhost_60f003a0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/DatePicker.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport DatePicker from './components/DatePicker/index'\n\nexport default DatePicker\n\n```" } ]
code_store-on-localhost_186ab305
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/ToastConsumer.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport { ToastConsumer } from './components/ToastProvider/index'\n\nexport default ToastConsumer\n\n```" } ]
code_store-on-localhost_7a76d37c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/Col.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport useResponsiveValues from '../ResponsiveValues/useResponsiveValues'\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nimport {\n FlexLayoutTypes,\n useFlexLayoutContext,\n FlexLayoutContextProvider,\n} from './components/FlexLayoutContext'\nimport {\n TachyonsScaleInput,\n parseTachyonsGroup,\n parseMargins,\n parsePaddings,\n parseBorders,\n} from './modules/valuesParser'\n\nenum VerticalAlign {\n top = 'top',\n middle = 'middle',\n bottom = 'bottom',\n}\n\nenum HorizontalAlign {\n left = 'left',\n right = 'right',\n center = 'center',\n}\n\ninterface Props extends Flex, Gap, Border {\n blockClass?: string\n height?: string\n marginLeft: TachyonsScaleInput\n marginRight: TachyonsScaleInput\n paddingLeft: TachyonsScaleInput\n paddingRight: TachyonsScaleInput\n preventVerticalStretch?: boolean\n verticalAlign?: VerticalAlign\n horizontalAlign?: HorizontalAlign\n}\n\nconst parseVerticalAlign = (input?: string) => {\n switch (input) {\n case VerticalAlign.middle:\n return 'justify-center'\n case VerticalAlign.bottom:\n return 'justify-end'\n }\n return ''\n}\n\nconst parseHorizontalAlign = (input?: string) => {\n switch (input) {\n case HorizontalAlign.center:\n return 'items-center'\n case HorizontalAlign.right:\n return 'items-end'\n }\n return ''\n}\n\nconst CSS_HANDLES = ['flexCol', 'flexColChild'] as const\n\nconst Col: StorefrontFunctionComponent<Props> = ({ children, ...props }) => {\n const {\n colGap,\n rowGap,\n marginLeft,\n marginRight,\n paddingLeft,\n paddingRight,\n border,\n borderWidth,\n borderColor,\n grow,\n preventVerticalStretch,\n verticalAlign,\n horizontalAlign,\n blockClass,\n } = useResponsiveValues(props) as Props\n\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES, {blockClass})\n\n const gaps = parseTachyonsGroup({\n colGap: colGap != null ? colGap : context.colGap,\n rowGap: rowGap != null ? rowGap : context.rowGap,\n })\n\n const margins = parseMargins({\n marginLeft,\n marginRight,\n })\n\n const paddings = parsePaddings({\n paddingLeft,\n paddingRight,\n })\n\n const borders = parseBorders({\n border,\n borderWidth,\n borderColor,\n })\n\n if (context.parent === FlexLayoutTypes.COL) {\n console.warn(\n 'A `flex-layout.col` is being inserted directly into another `flex-layout.col`. This might might have unpredicted behaviour.'\n )\n }\n\n if (context.parent === FlexLayoutTypes.NONE) {\n console.warn(\n 'A `flex-layout.col` block is being inserted directly into the page, but it needs to be inserted into a `flex-layout.row` block.'\n )\n return null\n }\n\n const vertical = parseVerticalAlign(verticalAlign)\n const horizontal = parseHorizontalAlign(horizontalAlign)\n\n const rowsNum = React.Children.count(children)\n\n return (\n <FlexLayoutContextProvider parent={FlexLayoutTypes.COL} {...gaps}>\n <div\n className={`${handles.flexCol} ${\n grow ? 'flex-grow-1' : ''\n } ${margins} ${paddings} ${borders} ${vertical} ${horizontal} flex flex-column h-100 w-100`}\n >\n {React.Children.map(children, (row, i) => {\n const isLast = i === rowsNum - 1\n const rowGap = isLast ? 0 : gaps.rowGap\n\n return (\n <div\n key={i}\n className={`${handles.flexColChild} pb${rowGap}`}\n style={{\n height:\n preventVerticalStretch || verticalAlign ? 'auto' : '100%',\n }}\n >\n {row}\n </div>\n )\n })}\n </div>\n </FlexLayoutContextProvider>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.column.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.column.description',\n },\n})\n\nCol.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default Col as any\n\n```" } ]
code_store-on-localhost_aaf68b3a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/Row.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nimport {\n FlexLayoutTypes,\n FlexLayoutContextProvider,\n useFlexLayoutContext,\n} from './components/FlexLayoutContext'\n\nimport { useResponsiveWidth } from './hooks/responsiveWidth'\nimport {\n parseTachyonsGroup,\n TachyonsScaleInput,\n parseMargins,\n parsePaddings,\n parseBorders,\n} from './modules/valuesParser'\n\nimport styles from './Row.css'\n\nenum HorizontalAlign {\n left = 'left',\n right = 'right',\n center = 'center',\n}\n\nconst HORIZONTAL_ALIGN_MAP = {\n left: 'justify-start',\n center: 'justify-center',\n right: 'justify-end',\n}\n\nenum ColSizing {\n equal = 'equal',\n auto = 'auto',\n}\n\nenum ColJustify {\n between = 'between',\n around = 'around',\n}\n\nconst JustifyValues = {\n [ColJustify.between]: 'justify-between',\n [ColJustify.around]: 'justify-around',\n}\n\nconst CSS_HANDLES = ['flexRowContent'] as const\n\nexport interface Props extends Flex, Gap, Border {\n blockClass?: string\n marginTop: TachyonsScaleInput\n marginBottom: TachyonsScaleInput\n paddingTop: TachyonsScaleInput\n paddingBottom: TachyonsScaleInput\n preserveLayoutOnMobile?: boolean\n preventHorizontalStretch?: boolean\n preventVerticalStretch?: boolean\n horizontalAlign?: HorizontalAlign\n colSizing?: ColSizing\n colJustify?: ColJustify\n}\n\nconst Row: StorefrontFunctionComponent<Props> = ({\n children,\n colGap,\n rowGap,\n marginTop,\n marginBottom,\n paddingTop,\n paddingBottom,\n border,\n borderWidth,\n borderColor,\n preserveLayoutOnMobile,\n preventHorizontalStretch,\n preventVerticalStretch,\n horizontalAlign,\n colSizing,\n colJustify = ColJustify.between,\n blockClass,\n}) => {\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES, {blockClass})\n\n const gaps = parseTachyonsGroup({\n colGap: colGap != null ? colGap : context.colGap,\n rowGap: rowGap != null ? rowGap : context.rowGap,\n })\n\n const margins = parseMargins({\n marginTop,\n marginBottom,\n })\n\n const paddings = parsePaddings({\n paddingTop,\n paddingBottom,\n })\n\n const borders = parseBorders({\n border,\n borderWidth,\n borderColor,\n })\n\n const { cols, breakOnMobile } = useResponsiveWidth(children, {\n preserveLayoutOnMobile,\n })\n\n if (context.parent === FlexLayoutTypes.ROW) {\n console.warn(\n 'A flex-row is being inserted directly into another flex-row. This might have unpredicted behaviour.'\n )\n }\n\n const isSizingAuto = colSizing === ColSizing.auto\n\n const justifyToken =\n JustifyValues[colJustify] || JustifyValues[ColJustify.between]\n\n const horizontalAlignClass =\n HORIZONTAL_ALIGN_MAP[horizontalAlign || HorizontalAlign.left] ||\n HORIZONTAL_ALIGN_MAP.left\n\n return (\n <FlexLayoutContextProvider parent={FlexLayoutTypes.ROW} {...gaps}>\n <div\n className={`${\n breakOnMobile ? 'flex-none flex-ns' : 'flex'\n } ${margins} ${paddings} ${borders} ${horizontalAlignClass} ${\n isSizingAuto ? justifyToken : ''\n } ${handles.flexRowContent} items-stretch w-100`}\n >\n {cols.map((col, i) => {\n const isLast = i === cols.length - 1\n const colGap = isLast ? 0 : gaps.colGap\n const rowGap = isLast ? 0 : gaps.rowGap\n\n return (\n <div\n key={i}\n className={`${\n /** If it breaks line on mobile, use the rowGap as bottom padding */\n breakOnMobile\n ? `pr${colGap}-ns pb${rowGap} pb0-ns`\n : `pr${colGap}`\n } ${preventVerticalStretch ? '' : 'items-stretch'} ${\n preventHorizontalStretch ? '' : styles.stretchChildrenWidth\n } ${col.width === 'grow' ? 'flex-grow-1' : ''} flex`}\n style={{\n width:\n preventHorizontalStretch ||\n (isSizingAuto && !col.hasDefinedWidth)\n ? 'auto'\n : breakOnMobile\n ? '100%'\n : col.width,\n }}\n >\n {col.element}\n </div>\n )\n })}\n </div>\n </FlexLayoutContextProvider>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.row.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.row.description',\n },\n})\n\nRow.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default Row as any\n\n```" } ]
code_store-on-localhost_58aeee67
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/Row.css from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n/** Stretches the width of the children to 100% (except images, which would be distorted. They are then centered)\n * This is done because the direct parent of the children of the Row component is flex now, which changes the\n * way children blocks are rendered (children with display: block of non-flex elements have 100% width, and\n * children of flex elements have the minimum possible width in respect of their content).\n * This can be cancelled with the prop `preventHorizontalStretch`\n */\n\n.stretchChildrenWidth {\n justify-content: center;\n}\n.stretchChildrenWidth > *:not(img) {\n width: 100%;\n}\n```" } ]
code_store-on-localhost_31697e81
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/FlexLayout.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport Container from '../StoreComponents/Container'\nimport useResponsiveValues from '../ResponsiveValues/useResponsiveValues'\n\nimport {\n FlexLayoutTypes,\n useFlexLayoutContext,\n} from './components/FlexLayoutContext'\nimport Row, { Props as RowProps } from './Row'\n\ninterface Props extends RowProps {\n fullWidth?: boolean\n}\n\nconst CSS_HANDLES = ['flexRow'] as const\n\nconst FlexLayout: StorefrontFunctionComponent<Props> = props => {\n const responsiveProps = useResponsiveValues(props) as Props\n const { fullWidth } = responsiveProps\n const context = useFlexLayoutContext()\n const handles = useCssHandles(CSS_HANDLES)\n\n const content = <Row {...responsiveProps} />\n\n const isTopLevel = context.parent === FlexLayoutTypes.NONE\n\n if (fullWidth && !isTopLevel) {\n console.warn(\n 'Prop `fullWidth` is allowed only on top-level `flex-layout.row` blocks.'\n )\n }\n\n if (fullWidth || !isTopLevel) {\n return <div className={handles.flexRow}>{content}</div>\n }\n\n return (\n <div className={handles.flexRow}>\n <Container>{content}</Container>\n </div>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.row.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.row.description',\n },\n})\n\nFlexLayout.schema = {\n title: messages.title.id,\n description: messages.description.id,\n}\n\nexport default FlexLayout\n\n```" } ]
code_store-on-localhost_1e231a56
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/FlexLayoutDummy.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nconst FlexLayoutDummy = () => {\n console.warn(\n 'You are inserting the `flex-layout` block directly. Please use `flex-layout.row` instead.'\n )\n\n return <span />\n}\n\nexport default FlexLayoutDummy\n\n```" } ]
code_store-on-localhost_eb85c7b7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/SliderLayout.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport useListContext from '../ListContext/useListContext'\nimport useResponsiveValue from '../ResponsiveValues/useResponsiveValue'\n\nimport Slider from './components/Slider'\nimport { SliderContextProvider } from './components/SliderContext'\n\nconst SliderLayout: StorefrontFunctionComponent<\n SliderLayoutProps & SliderLayoutSiteEditorProps\n> = ({\n totalItems,\n infinite = false,\n showNavigationArrows = 'always',\n showPaginationDots = 'always',\n usePagination = true,\n fullWidth = true,\n arrowSize = 25,\n children,\n ...contextProps\n}) => {\n const { list } = useListContext() || [] as any\n const totalSlides = totalItems || React.Children.count(children) + list.length\n const responsiveArrowIconSize = useResponsiveValue(arrowSize)\n\n return (\n <SliderContextProvider totalItems={totalSlides} {...contextProps}>\n <Slider\n infinite={infinite}\n showNavigationArrows={showNavigationArrows}\n showPaginationDots={showPaginationDots}\n totalItems={totalSlides}\n usePagination={usePagination}\n fullWidth={fullWidth}\n arrowSize={responsiveArrowIconSize}\n >\n {children}\n </Slider>\n </SliderContextProvider>\n )\n}\n\nconst messages = defineMessages({\n sliderTitle: {\n id: 'admin/editor.slider-layout.title',\n defaultMessage: '',\n },\n sliderInfinite: {\n id: 'admin/editor.slider-layout.infinite',\n defaultMessage: '',\n },\n sliderShowNavigation: {\n id: 'admin/editor.slider-layout.showNavigation',\n defaultMessage: '',\n },\n sliderShowPaginationDots: {\n id: 'admin/editor.slider-layout.showPaginationDots',\n defaultMessage: '',\n },\n sliderUsePagination: {\n id: 'admin/editor.slider-layout.usePagination',\n defaultMessage: '',\n },\n})\n\nSliderLayout.schema = {\n title: messages.sliderTitle.id,\n description: messages.sliderTitle.id,\n type: 'object',\n properties: {\n infinite: {\n default: true,\n title: messages.sliderInfinite.id,\n type: 'boolean',\n },\n showNavigationArrows: {\n default: 'always',\n enum: ['mobileOnly', 'desktopOnly', 'always', 'never'],\n title: messages.sliderShowNavigation.id,\n type: 'string',\n },\n showPaginationDots: {\n default: 'always',\n enum: ['mobileOnly', 'desktopOnly', 'always', 'never'],\n title: messages.sliderShowPaginationDots.id,\n type: 'string',\n },\n usePagination: {\n default: true,\n title: messages.sliderUsePagination.id,\n type: 'boolean',\n },\n },\n}\n\nexport default SliderLayout as any\n\n```" } ]
code_store-on-localhost_954a7d72
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/AddToCartButton.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useEffect, useState } from 'react'\nimport { useMutation } from 'react-apollo'\nimport {\n FormattedMessage,\n injectIntl,\n WrappedComponentProps,\n defineMessages,\n MessageDescriptor,\n} from 'react-intl'\nimport Button from '../Styleguide/Button'\nimport Tooltip from '../Styleguide/Tooltip'\nimport OrderForm from '../OrderManager/OrderForm'\nimport CheckoutUtils from '../CheckoutResources/Utils'\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport { useRuntime } from '../../../../vtex.render-runtime'\nimport { usePixel } from '../PixelContext/PixelContext'\nimport { loader } from 'graphql.macro'\n\nimport ProductDispatchContext from '../ProductContext/ProductDispatchContext'\nimport PWAContext from '../StoreResources/PWAContext'\n\nimport { compareObjects } from './modules/compareObjects'\nimport { MapCatalogItemToCartReturn } from './modules/catalogItemToCart'\n\nconst ADD_TO_CART = loader('../CheckoutResources/mutations/addToCart.graphql')\n\nconst { useCheckoutURL } = CheckoutUtils\nconst { usePWA } = PWAContext\nconst { useProductDispatch } = ProductDispatchContext\n\ninterface Props extends WrappedComponentProps {\n isOneClickBuy: boolean\n available: boolean\n disabled: boolean\n customToastUrl: string\n customOneClickBuyLink: string\n skuItems: MapCatalogItemToCartReturn[]\n showToast: Function\n allSkuVariationsSelected: boolean\n}\n\ninterface OrderFormContext {\n loading: boolean\n orderForm: OrderForm | undefined\n setOrderForm: (orderForm: Partial<OrderForm>) => void\n}\n\nconst CSS_HANDLES = ['buttonText', 'buttonDataContainer']\n\nconst messages = defineMessages({\n success: { id: 'store/add-to-cart.success', defaultMessage: '' },\n duplicate: { id: 'store/add-to-cart.duplicate', defaultMessage: '' },\n error: { id: 'store/add-to-cart.failure', defaultMessage: '' },\n seeCart: { id: 'store/add-to-cart.see-cart', defaultMessage: '' },\n})\n\nconst useWaitForOrderFormAndAddToCart = (\n orderFormLoading: boolean,\n addToCart: () => Promise<void>\n): [boolean, (state: boolean) => void] => {\n const [waitingOrderFormLoad, setWaitForOrderForm] = useState(false)\n useEffect(() => {\n if (!orderFormLoading && waitingOrderFormLoad) {\n addToCart().then(() => {\n setWaitForOrderForm(false)\n })\n }\n }, [addToCart, orderFormLoading, waitingOrderFormLoad])\n\n return [waitingOrderFormLoad, setWaitForOrderForm]\n}\n\nconst adjustItemsForMutationInput = (\n newItems: MapCatalogItemToCartReturn[]\n): OrderFormItemInput[] => {\n return newItems.map(item => ({\n id: Number.parseInt(item.skuId),\n index: item.index,\n seller: item.seller,\n quantity: item.quantity,\n options: item.options,\n }))\n}\n\nconst adjustSkuItemForPixelEvent = (skuItem: MapCatalogItemToCartReturn) => {\n // Changes this `/Apparel & Accessories/Clothing/Tops/`\n // to this `Apparel & Accessories/Clothing/Tops`\n const category = skuItem.category ? skuItem.category.slice(1, -1) : ''\n\n return {\n skuId: skuItem.skuId,\n variant: skuItem.variant,\n price: skuItem.price,\n name: skuItem.name,\n quantity: skuItem.quantity,\n productRefId: skuItem.productRefId,\n brand: skuItem.brand,\n category,\n detailUrl: skuItem.detailUrl,\n imageUrl: skuItem.imageUrl,\n }\n}\n\nconst AddToCartButton: FC<Props> = ({\n intl,\n isOneClickBuy,\n customOneClickBuyLink,\n available,\n disabled,\n skuItems,\n customToastUrl,\n showToast,\n allSkuVariationsSelected = true,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n const {\n orderForm,\n setOrderForm,\n loading,\n }: OrderFormContext = OrderForm.useOrderForm()\n const dispatch = useProductDispatch()\n const { rootPath = '', navigate } = useRuntime()\n const { url: checkoutURL, major } = useCheckoutURL()\n const { push } = usePixel()\n const { settings = {}, showInstallPrompt = undefined } = usePWA() || {}\n const { promptOnCustomEvent } = settings\n const translateMessage = (message: MessageDescriptor) =>\n intl.formatMessage(message)\n\n const resolveToastMessage = (success: boolean, isNewItem: boolean) => {\n if (!success) return translateMessage(messages.error)\n if (!isNewItem) return translateMessage(messages.duplicate)\n\n return translateMessage(messages.success)\n }\n\n const toastMessage = ({\n success,\n isNewItem,\n }: {\n success: boolean\n isNewItem: boolean\n }) => {\n const message = resolveToastMessage(success, isNewItem)\n\n const action = success\n ? {\n label: translateMessage(messages.seeCart),\n href: customToastUrl,\n }\n : undefined\n\n showToast({ message, action })\n }\n\n const [\n addToCart,\n { error: mutationError, loading: mutationLoading },\n ] = useMutation<{ addToCart: OrderForm }, { items: OrderFormItemInput[] }>(\n ADD_TO_CART\n )\n\n const beforeAddToCart = (event: React.MouseEvent) => {\n event.stopPropagation()\n event.preventDefault()\n }\n\n const callAddToCart = async () => {\n const adjustedSkuItems = adjustItemsForMutationInput(skuItems)\n\n const mutationResult = await addToCart({\n variables: { items: adjustedSkuItems },\n })\n\n if (mutationError) {\n console.error(mutationError)\n toastMessage({ success: false, isNewItem: false })\n return\n }\n\n if (\n mutationResult.data &&\n compareObjects(mutationResult.data.addToCart, orderForm)\n ) {\n toastMessage({ success: true, isNewItem: false })\n return\n }\n\n // Update OrderForm from the context\n mutationResult.data && setOrderForm(mutationResult.data.addToCart)\n\n // Send event to pixel-manager\n const pixelEventItems = skuItems.map(adjustSkuItemForPixelEvent)\n push({\n event: 'addToCart',\n items: pixelEventItems,\n })\n\n if (isOneClickBuy) {\n if (\n major > 0 &&\n (!customOneClickBuyLink || customOneClickBuyLink === checkoutURL)\n ) {\n navigate({ to: checkoutURL })\n } else {\n window.location.assign(rootPath + (customOneClickBuyLink || checkoutURL))\n }\n }\n\n toastMessage({ success: true, isNewItem: true })\n\n /* PWA */\n if (promptOnCustomEvent === 'addToCart' && showInstallPrompt) {\n showInstallPrompt()\n }\n }\n\n const [\n waitingOrderFormLoad,\n setWaitOrderFormLoad,\n ] = useWaitForOrderFormAndAddToCart(loading, callAddToCart)\n\n const handleAddToCart = async (event: React.MouseEvent) => {\n beforeAddToCart(event)\n await callAddToCart()\n }\n\n const handleClick = (e: React.MouseEvent) => {\n if (dispatch) {\n dispatch({ type: 'SET_BUY_BUTTON_CLICKED', args: { clicked: true } })\n }\n\n if (allSkuVariationsSelected) {\n if (loading) {\n // Just call the beforeAddToCart method and wait for the hook useAddWhileLoadingHandler to call the add to cart logic\n beforeAddToCart(e)\n setWaitOrderFormLoad(true)\n } else {\n handleAddToCart(e)\n }\n }\n }\n\n const availableButtonContent = (\n <div className={`${handles.buttonDataContainer} flex justify-center`}>\n <FormattedMessage id=\"store/add-to-cart.add-to-cart\">\n {message => <span className={handles.buttonText}>{message}</span>}\n </FormattedMessage>\n </div>\n )\n\n const unavailableButtonContent = (\n <FormattedMessage id=\"store/buyButton-label-unavailable\">\n {message => <span className={handles.buttonText}>{message}</span>}\n </FormattedMessage>\n )\n\n const tooltipLabel = (\n <FormattedMessage id=\"store/add-to-cart.select-sku-variations\">\n {message => <span className={handles.errorMessage}>{message}</span>}\n </FormattedMessage>\n )\n\n const ButtonWithLabel = (\n <Button\n block\n disabled={\n disabled || !available || mutationLoading || waitingOrderFormLoad\n }\n isLoading={mutationLoading || waitingOrderFormLoad}\n onClick={handleClick}\n >\n {available ? availableButtonContent : unavailableButtonContent}\n </Button>\n )\n\n return allSkuVariationsSelected ? (\n ButtonWithLabel\n ) : (\n <Tooltip trigger=\"click\" label={tooltipLabel}>\n {ButtonWithLabel}\n </Tooltip>\n )\n}\n\nexport default injectIntl(AddToCartButton)\n\n```" } ]
code_store-on-localhost_31705eef
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/Wrapper.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport useProduct from '../ProductContext/useProduct'\nimport withToast from '../Styleguide/withToast'\n\nimport AddToCartButton from './AddToCartButton'\nimport { mapCatalogItemToCart } from './modules/catalogItemToCart'\n\ninterface Props {\n isOneClickBuy: boolean\n available: boolean\n disabled: boolean\n customToastUrl: string\n customOneClickBuyLink: string\n showToast: Function\n}\n\nconst Wrapper: FC<Props> = ({\n isOneClickBuy,\n available,\n disabled,\n customToastUrl,\n showToast,\n customOneClickBuyLink,\n}) => {\n const productContext: any = useProduct()\n\n if (!productContext) {\n throw new Error('useProduct must be used within a ProductContextProvider')\n }\n\n const isEmptyContext = Object.keys(productContext).length === 0\n\n const product = productContext && productContext.product\n const selectedItem = productContext && productContext.selectedItem\n const assemblyOptions = productContext && productContext.assemblyOptions\n const selectedSeller =\n productContext &&\n productContext.selectedItem &&\n productContext.selectedItem.sellers[0]\n const selectedQuantity =\n productContext && productContext.selectedQuantity != null\n ? productContext.selectedQuantity\n : 1\n\n const skuItems = mapCatalogItemToCart({\n product,\n selectedItem,\n selectedQuantity,\n selectedSeller,\n assemblyOptions,\n })\n\n const isAvailable =\n isEmptyContext || available != null\n ? available\n : Boolean(\n selectedSeller &&\n selectedSeller.commertialOffer &&\n selectedSeller.commertialOffer.AvailableQuantity > 0\n )\n\n const groupsValidArray =\n (assemblyOptions &&\n assemblyOptions.areGroupsValid &&\n Object.values(assemblyOptions.areGroupsValid)) ||\n []\n\n const areAssemblyGroupsValid = groupsValidArray.every(Boolean)\n const isDisabled =\n isEmptyContext || disabled != null ? disabled : !areAssemblyGroupsValid\n\n const areAllSkuVariationsSelected =\n productContext && productContext.skuSelector.areAllVariationsSelected\n\n return (\n <AddToCartButton\n allSkuVariationsSelected={areAllSkuVariationsSelected}\n skuItems={skuItems}\n available={isAvailable}\n isOneClickBuy={isOneClickBuy}\n disabled={isDisabled}\n customToastUrl={customToastUrl}\n showToast={showToast}\n customOneClickBuyLink={customOneClickBuyLink}\n />\n )\n}\n\nexport default withToast(Wrapper)\n\n```" } ]
code_store-on-localhost_0a3346e5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/useResponsiveValues.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useResponsiveValues } from './hooks/useResponsiveValue'\n\nexport default useResponsiveValues\n\n```" } ]
code_store-on-localhost_092c8601
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/useResponsiveValue.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useResponsiveValue } from './hooks/useResponsiveValue'\n\nexport default useResponsiveValue\n\n```" } ]
code_store-on-localhost_f7d95980
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/index.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport PropTypes from 'prop-types'\nimport React, { ReactNode } from 'react'\n\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport { Link } from '../../../../vtex.render-runtime'\nimport Container from '../StoreComponents/Container'\nimport Options from './constants/Options'\n\n// This is required because is used in static schema attribute of Menu Component\nconst GLOBAL_PAGES =\n (global as any).__RUNTIME__ && Object.keys((global as any).__RUNTIME__.pages)\n\nconst MAX_ITEMS: number = 10\n\nconst CSS_HANDLES = [\n 'container',\n 'linkLeft',\n 'linkMiddle',\n 'linkRight',\n 'menuLinkNav',\n 'menuLinkDivLeft',\n 'menuLinkDivMiddle',\n 'menuLinkDivRight',\n 'renderLink',\n] as const\n\ninterface Link {\n text?: string | null\n internalPage: string | null\n params?: string | null\n externalPage?: string | null\n typeOfRoute?: string | null\n page?: string | null\n position?: string | null\n}\n\ninterface Options {\n LEFT: string\n MIDDLE: string\n RIGHT: string\n INTERNAL: string\n EXTERNAL: string\n}\n\ninterface Props {\n links?: Link[]\n}\n\n/**\n * Convert the string params to a js object\n */\nconst getParams = (params?: string | null): { [key: string]: string } => {\n const json: { [key: string]: string } = {}\n if (params) {\n const array: string[] = params.split(',')\n array.forEach((item: string) => {\n const pair: string[] = item.split('=')\n json[pair[0]] = pair[1]\n })\n }\n return json\n}\n\nconst getValidPage = (page?: string | null): string => {\n if (!page || (!page.startsWith('http://') && !page.startsWith('https://'))) {\n page = `http://${page}`\n }\n return page\n}\n\n/**\n * Links MenuLink Component.\n * Shows a menu bar with links.\n */\nconst MenuLink: StorefrontFunctionComponent<Props> = ({ links = [] }) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n const renderLink = (link: Link, index: number): ReactNode => {\n let className: string = `${handles.renderLink} t-small link c-muted-2 dib dim mr3 mr4-ns`\n switch (link.position) {\n case Options.LEFT:\n className = `${handles.linkLeft} ${className}`\n break\n case Options.MIDDLE:\n className = `${handles.linkMiddle} ${className}`\n break\n case Options.RIGHT:\n className = `${handles.linkRight} ${className}`\n break\n }\n return link.typeOfRoute === Options.INTERNAL ? (\n <Link\n className={className}\n key={`${link.text}-${link.position}-${index}`}\n page={link.internalPage}\n params={getParams(link.params)}\n >\n {link.text}\n </Link>\n ) : (\n <a\n className={className}\n key={`${link.text}-${link.position}-${index}`}\n href={getValidPage(link.externalPage)}\n target=\"_blank\"\n >\n {link.text}\n </a>\n )\n }\n\n if (!links.length) {\n return null\n }\n return (\n <div className={`${handles.container} bg-base h2 c-muted-2 w-100 dn db-ns`}>\n <Container>\n <nav className={`${handles.menuLinkNav} flex justify-between`}>\n <div className={`${handles.menuLinkDivLeft} flex-grow pa3 flex items-center`}>\n {links\n .filter(link => link.position === Options.LEFT)\n .map((link, index) => {\n return renderLink(link, index)\n })}\n </div>\n <div className={`${handles.menuLinkDivMiddle} flex-grow pa3 flex items-center`}>\n {links\n .filter(link => link.position === Options.MIDDLE)\n .map((link, index) => {\n return renderLink(link, index)\n })}\n </div>\n <div className={`${handles.menuLinkDivRight} flex-grow pa3 flex items-center`}>\n {links\n .filter(link => link.position === Options.RIGHT)\n .map((link, index) => {\n return renderLink(link, index)\n })}\n </div>\n </nav>\n </Container>\n </div>\n )\n}\n\n// MenuLink.propTypes = {\n// links: PropTypes.arrayOf(\n// PropTypes.shape({\n// /** External page to redirect */\n// externalPage: PropTypes.string,\n// /** Internal page to redirect */\n// internalPage: PropTypes.string.isRequired,\n// /** Page route to redirect when clicked */\n// page: PropTypes.string,\n// /** Params to redirect to internal page */\n// params: PropTypes.string,\n// /** Link position */\n// position: PropTypes.string,\n// /** Link text */\n// text: PropTypes.string,\n// /** Type of Route (internal or external) */\n// typeOfRoute: PropTypes.string,\n// }).isRequired\n// ),\n// }\n\n// tslint:disable: object-literal-sort-keys\nMenuLink.schema = {\n title: 'admin/editor.menu-link',\n description: 'admin/editor.menu-link.description',\n type: 'object',\n properties: {\n links: {\n title: 'admin/editor.menu-link.links',\n type: 'array',\n minItems: 0,\n maxItems: MAX_ITEMS,\n items: {\n title: 'admin/editor.menu-link.links.link',\n type: 'object',\n properties: {\n text: {\n title: 'admin/editor.menu-link.links.link.text',\n type: 'string',\n },\n internalPage: {\n title: 'admin/editor.menu-link.links.link.internalPage',\n description:\n 'admin/editor.menu-link.links.link.internalPage.description',\n type: 'string',\n enum: GLOBAL_PAGES,\n },\n params: {\n title: 'admin/editor.menu-link.links.link.params',\n description: 'admin/editor.menu-link.links.link.params.description',\n type: 'string',\n },\n externalPage: {\n title: 'admin/editor.menu-link.links.link.externalPage',\n description:\n 'admin/editor.menu-link.links.link.externalPage.description',\n type: 'string',\n },\n typeOfRoute: {\n title: 'admin/editor.menu-link.links.link.typeOfRoute',\n type: 'string',\n enum: [Options.INTERNAL, Options.EXTERNAL],\n enumNames: [\n 'admin/editor.menu-link.links.link.typeOfRoute.internal',\n 'admin/editor.menu-link.links.link.typeOfRoute.external',\n ],\n default: Options.INTERNAL,\n widget: {\n 'ui:widget': 'radio',\n 'ui:options': {\n inline: true,\n },\n },\n },\n position: {\n title: 'admin/editor.menu-link.links.link.position',\n type: 'string',\n enum: [Options.LEFT, Options.MIDDLE, Options.RIGHT],\n enumNames: [\n 'admin/editor.menu-link.links.link.position.left',\n 'admin/editor.menu-link.links.link.position.middle',\n 'admin/editor.menu-link.links.link.position.right',\n ],\n default: Options.MIDDLE,\n },\n },\n },\n },\n },\n}\n\nexport default MenuLink\n\n```" } ]
code_store-on-localhost_38c5315a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/Submenu.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\n\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nconst CSS_HANDLES = ['submenu', 'submenuWrapper', 'submenuContainer'] as const\n\nconst MAX_TACHYONS_SCALE = 11\n\nenum Orientation {\n horizontal = 'horizontal',\n vertical = 'vertical',\n}\n\nexport type TachyonsScaleInput = string | number | undefined\n\n/** TODO: This function is copied from the flex-layout app.\n * It should probably be exported to a separate package.\n */\nconst parseTachyonsValue = (value: TachyonsScaleInput, name?: string) => {\n if (!value) {\n return 0\n }\n\n const parsedValue = typeof value === 'string' ? parseInt(value, 10) : value\n\n if (isNaN(parsedValue) || String(parsedValue) !== String(value) || parsedValue < 0 || parsedValue > MAX_TACHYONS_SCALE) {\n if (name) {\n console.warn(`Invalid ${name} value. It should be an integer between 0 and ${MAX_TACHYONS_SCALE}.`)\n }\n return 0\n }\n\n return parsedValue\n}\n\n\nconst Submenu: StorefrontFunctionComponent<SubmenuProps> = ({\n isOpen,\n width,\n children,\n orientation = Orientation.horizontal,\n paddingTop = 4,\n paddingBottom = 4,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div className={`${handles.submenuContainer} ${width === '100%' ? '' : 'relative'}`}>\n <div\n className={classNames(handles.submenuWrapper, `absolute left-0 bg-base pt${parseTachyonsValue(paddingTop, 'paddingTop')} pb${parseTachyonsValue(paddingBottom, 'paddingBottom')} bw1 bb b--muted-3 z-2`,\n {\n dn: !isOpen,\n flex: isOpen,\n 'w-100': width === '100%',\n 'w-auto ml6': width === 'auto',\n }\n )}\n >\n <section className={classNames(handles.submenu, 'w-100 flex justify-center', { 'flex-column': orientation === Orientation.vertical })}>{children}</section>\n </div>\n </div>\n )\n}\n\nexport interface SubmenuProps extends SubmenuSchema {\n isOpen: boolean\n orientation: Orientation\n paddingTop: number | string\n paddingBottom: number | string\n blockClass?: string\n}\n\ninterface SubmenuSchema {\n width: '100%' | 'auto'\n}\n\nconst messages = defineMessages({\n submenuTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.submenu.title',\n },\n submenuWidthTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.submenuWidth.title',\n },\n})\n\n// tslint:disable: object-literal-sort-keys\nSubmenu.getSchema = () => ({\n title: messages.submenuTitle.id,\n})\n\nexport default Submenu\n\n```" } ]
code_store-on-localhost_86d9b246
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/SubmenuAccordion.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport Collapsible from './components/Collapsible'\n\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nconst CSS_HANDLES = ['submenuAccordion'] as const\n\ninterface Props {\n isOpen: boolean\n blockClass?: string\n}\n\nconst SubmenuAccordion: StorefrontFunctionComponent<Props> = ({\n isOpen,\n children,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <Collapsible open={isOpen} >\n <section className={classNames(handles.submenuAccordion, 'w-100 flex pl4 flex')}>\n {children}\n </section>\n </Collapsible>\n )\n}\n\nconst messages = defineMessages({\n submenuTitle: {\n defaultMessage: '',\n id: 'editor.menu.submenu.title',\n },\n})\n\nSubmenuAccordion.getSchema = () => ({\n title: messages.submenuTitle.id,\n type: 'object',\n})\n\nexport default SubmenuAccordion\n\n```" } ]
code_store-on-localhost_dbdce7c2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/MenuItem.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { path } from 'ramda'\nimport React, { Reducer, useReducer, useContext } from 'react'\n\nimport classNames from 'classnames'\n\nimport { defineMessages } from 'react-intl'\n// import { ExtensionPoint } from 'vtex.render-runtime'\nimport { CategoryItemSchema } from './components/CategoryItem'\nimport { CustomItemSchema } from './components/CustomItem'\nimport Item from './components/Item'\nimport { IconProps} from './components/StyledLink'\nimport useSubmenuImplementation from './hooks/useSubmenuImplementation'\n\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport MenuContext from './components/MenuContext'\n\nconst CSS_HANDLES = ['menuItem', 'menuItemInnerDiv']\n\nconst submenuInitialState = {\n hasBeenActive: false,\n isActive: false,\n}\n\ntype SubmenuState = typeof submenuInitialState\n\ntype SubmenuAction = \n | {type: 'SHOW_SUBMENU'}\n | {type: 'HIDE_SUBMENU'}\n\nconst submenuReducer: Reducer<SubmenuState, SubmenuAction> = (state, action) => {\n switch (action.type) {\n case 'SHOW_SUBMENU':\n return {\n hasBeenActive: true,\n isActive: true,\n }\n case 'HIDE_SUBMENU':\n return {\n ...state,\n isActive: false,\n }\n default:\n return state\n }\n}\n\nconst MenuItem: StorefrontFunctionComponent<MenuItemSchema> = ({\n children,\n ...props\n}) => {\n const { experimentalOptimizeRendering } = useContext(MenuContext)\n const [{ isActive, hasBeenActive }, dispatch] = useReducer(submenuReducer, submenuInitialState)\n const handles = useCssHandles(CSS_HANDLES)\n\n const setActive = (value: boolean) => {\n dispatch({ type: value ? 'SHOW_SUBMENU' : 'HIDE_SUBMENU' })\n }\n\n /* This is a temporary check of which kind of submenu is being\n * inserted. This will be replaced by new functionality of useChildBlocks\n * in the future. */\n const submenuImplementation = useSubmenuImplementation()\n const isCollapsible = submenuImplementation === 'submenu.accordion'\n \n if (isCollapsible) {\n return (\n <li className={classNames(handles.menuItem, 'list')}>\n <div className={handles.menuItemInnerDiv}\n onClick={event => {\n setActive(!isActive)\n event.stopPropagation()\n }}>\n <Item {...props} accordion active={isActive} />\n </div>\n {(hasBeenActive || !experimentalOptimizeRendering) && children && ( /* Collapsible menus need to still persist after being open,\n * to make the closing transition work properly */\n <>\n {/* <ExtensionPoint id=\"submenu\" isOpen={isActive} />\n <ExtensionPoint id=\"unstable--submenu\" isOpen={isActive} /> */}\n {/* <S */}\n {/* {props.submenuProps ? <Submenu {...props.submenuProps} /> : null} */}\n {/* {children} */}\n {React.cloneElement(children, { isOpen: isActive})}\n </>\n )}\n </li>\n )\n }\n\n return (\n <li\n className={classNames(handles.menuItem, 'list')}\n onMouseEnter={() => setActive(true)}\n onMouseLeave={() => setActive(false)}>\n <Item {...props} active={isActive} />\n {(isActive || !experimentalOptimizeRendering) && children && (\n <>\n {/* {children} */}\n {React.cloneElement(children, { isOpen: isActive})}\n {/* <ExtensionPoint id=\"submenu\" isOpen={isActive} />\n <ExtensionPoint id=\"unstable--submenu\" isOpen={isActive} /> */}\n </>\n )}\n </li>\n )\n}\n\nexport interface MenuItemSchema {\n id: string\n type: 'category' | 'custom'\n iconProps: IconProps\n iconPosition: 'left' | 'right'\n highlight: boolean\n itemProps: CategoryItemSchema | CustomItemSchema\n blockClass?: string\n experimentalOptimizeRendering?: boolean\n submenuProps?: any\n}\n\nconst messages = defineMessages({\n categoryIdTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.categoryId.title',\n },\n categoryTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.category.title',\n },\n customTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.custom.title',\n },\n customTypeTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.type.title',\n },\n externalTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.external.title',\n },\n highlightTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.highlight.title',\n },\n hrefTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.href.title',\n },\n iconIdTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.iconId.title',\n },\n internalTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.internal.title',\n },\n itemIdTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.id.title',\n },\n itemsTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.items.title',\n },\n noFollowTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.noFollow.title',\n },\n paramsTextTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.text.title',\n },\n paramsTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.title',\n },\n tagTitleTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.params.tagTitle.title',\n },\n typeTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.item.type.title',\n },\n})\n\nMenuItem.getSchema = props => {\n const text = path(['itemProps', 'text'], props)\n const id = props && props.id ? props.id : ''\n\n // tslint:disable: object-literal-sort-keys\n return {\n title: [text, id, messages.itemsTitle.id].find(e => !!e),\n type: 'object',\n required: ['type'],\n properties: {\n id: {\n default: id,\n title: messages.itemIdTitle.id,\n type: 'string',\n },\n },\n }\n}\n\nexport default MenuItem\n\n\n```" } ]
code_store-on-localhost_3ce735d3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/Menu.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useContext, useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { defineMessages } from 'react-intl'\n\nimport CategoryMenu from './components/CategoryMenu'\nimport Item from './components/Item'\nimport LevelContext from './components/LevelContext'\nimport MenuContext from './components/MenuContext'\nimport MenuItem, { MenuItemSchema } from './MenuItem'\n\nimport useCssHandles from '../CssHandles/useCssHandles' \n\nconst CSS_HANDLES = ['menuContainer', 'menuContainerNav'] as const\n\nconst TypographyMap: Record<string, string> = {\n body: 't-body',\n heading1: 't-heading-1',\n heading2: 't-heading-2',\n heading3: 't-heading-3',\n heading4: 't-heading-4',\n heading5: 't-heading-5',\n mini: 't-mini',\n small: 't-small',\n}\n\nconst Menu: StorefrontFunctionComponent<MenuSchema> = ({\n orientation = 'horizontal',\n textType,\n title,\n categoryId,\n items: itemsProps = [],\n children,\n experimentalOptimizeRendering = false,\n}) => {\n const level = useContext(LevelContext)\n const handles = useCssHandles(CSS_HANDLES)\n const menuContext = useMemo(\n () => ({\n experimentalOptimizeRendering,\n hasTitle: title || categoryId ? true : false,\n orientation,\n textType: textType ? TypographyMap[textType] : TypographyMap.body,\n }),\n [orientation, textType]\n )\n\n const menuItems = itemsProps.map(\n ({ itemProps: { text }, itemProps, ...rest }) => (\n <MenuItem key={text} itemProps={itemProps} {...rest} />\n )\n )\n\n return (\n <LevelContext.Provider value={level + 1}>\n <MenuContext.Provider value={menuContext}>\n <nav className={handles.menuContainerNav}>\n <ul\n className={classNames(handles.menuContainer, 'list flex pl0 mv0', {\n 'flex-column': orientation === 'vertical',\n 'flex-row': orientation === 'horizontal',\n })}\n >\n {!categoryId && title && <Item {...title} isTitle />}\n {categoryId && <CategoryMenu categoryId={categoryId} />}\n {children}\n {menuItems}\n </ul>\n </nav>\n </MenuContext.Provider>\n </LevelContext.Provider>\n )\n}\n\ninterface MenuSchema {\n orientation?: 'vertical' | 'horizontal'\n categoryId?: number\n textType?: Typography\n title?: MenuItemSchema\n additionalDef?: string\n blockClass?: string\n items?: MenuItemSchema[]\n experimentalOptimizeRendering?: boolean\n}\n\nenum Typography {\n heading1 = 't-heading-1',\n heading2 = 't-heading-2',\n heading3 = 't-heading-3',\n heading4 = 't-heading-4',\n heading5 = 't-heading-5',\n body = 't-body',\n small = 't-small',\n mini = 't-mini',\n}\n\nconst messages = defineMessages({\n categoryDef: {\n defaultMessage: '',\n id: 'admin/editor.menu.def.category',\n },\n categoryIdTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.categoryId.title',\n },\n defTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.additionalDef.title',\n },\n horizontalLabel: {\n defaultMessage: '',\n id: 'admin/editor.menu.orientation.horizontal.label',\n },\n menuTitle: {\n defaultMessage: '',\n id: 'admin/editor.future-menu.title',\n },\n noneDef: {\n defaultMessage: '',\n id: 'admin/editor.menu.def.none',\n },\n orientationTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.orientation.title',\n },\n titleDef: {\n defaultMessage: '',\n id: 'admin/editor.menu.def.title',\n },\n typographyTitle: {\n defaultMessage: '',\n id: 'admin/editor.menu.typography.title',\n },\n verticalLabel: {\n defaultMessage: '',\n id: 'admin/editor.menu.orientation.vertical.label',\n },\n})\n\nMenu.getSchema = () => {\n // tslint:disable: object-literal-sort-keys\n return {\n title: messages.menuTitle.id,\n }\n}\n\nexport default Menu\n\n```" } ]
code_store-on-localhost_b53f9db9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/Column.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\n\nconst Column: FunctionComponent<Props> = props => {\n return <div>{props.children}</div>\n}\n\ninterface Props {\n children: React.ReactChildren\n}\n\nexport default Column\n\n```" } ]
code_store-on-localhost_731d1353
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/NativeTypes/IOMessage.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { FormattedMessage, injectIntl } from 'react-intl'\n\nconst IOMessage = ({ children, id, ...props }) => {\n const intlMessage = props.intl.messages[id]\n\n if (intlMessage) {\n return (\n <FormattedMessage id={id} {...props}>\n {children}\n </FormattedMessage>\n )\n }\n\n if (children && typeof children === 'function') {\n return children(intlMessage === '' ? '' : id)\n }\n\n return intlMessage === '' ? null : <>{id}</>\n}\n\nexport default injectIntl(IOMessage)\n```" } ]
code_store-on-localhost_4f2116a5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/NativeTypes/formatIOMessage.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nconst formatIOMessage = (\n { intl, ...messageDescriptor },\n values\n) => {\n const { id } = messageDescriptor\n\n const intlMessage = intl.messages[id]\n\n if (intlMessage) {\n return intl.formatMessage(messageDescriptor, values)\n }\n\n if (intlMessage === '') {\n return ''\n }\n\n return id\n}\n\nexport default formatIOMessage\n```" } ]
code_store-on-localhost_f2ab2041
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/OrderManager/OrderForm.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n createContext,\n useContext,\n useMemo,\n useReducer,\n useEffect,\n useState,\n FC,\n} from 'react'\nimport { ApolloClient, ApolloError } from 'apollo-client'\nimport { useQuery } from 'react-apollo'\nimport { loader } from 'graphql.macro'\n\nimport { dummyOrderForm, emptyOrderForm } from './utils/dummyOrderForm'\nimport { logSplunk } from './utils/logger'\n\nconst OrderFormQuery = loader('../CheckoutResources/queries/orderForm.graphql')\n\ntype OrderForm = any\n\n\ninterface Context {\n loading: boolean\n orderForm: OrderForm | undefined\n setOrderForm: (orderForm: Partial<OrderForm>) => void\n error: ApolloError | undefined\n}\n\nconst OrderFormContext = createContext<Context | undefined>(undefined)\n\nconst updateApolloCache = (client: ApolloClient<any>, orderForm: OrderForm) => {\n const data = client.readQuery({ query: OrderFormQuery })\n client.writeQuery({\n query: OrderFormQuery,\n data: {\n ...data,\n orderForm,\n },\n })\n}\n\nexport const OrderFormProvider: FC = ({ children }) => {\n const { client, loading: loadingQuery, data, error } = useQuery<{\n orderForm: OrderForm\n }>(OrderFormQuery, {\n ssr: false,\n })\n\n const [orderForm, setOrderForm] = useReducer(\n (orderForm: OrderForm, newOrderForm: Partial<OrderForm>) => ({\n ...orderForm,\n ...newOrderForm,\n }),\n dummyOrderForm\n )\n\n const [loading, setLoading] = useState(true)\n\n useEffect(() => {\n if (error) {\n logSplunk({\n level: 'Important',\n type: 'Error',\n workflowType: 'OrderManager',\n workflowInstance: 'orderform-query',\n event: {\n message: error.message,\n },\n })\n console.error(error.message)\n }\n\n if (loadingQuery) {\n return\n }\n\n setLoading(false)\n\n if (data) {\n setOrderForm(data.orderForm)\n updateApolloCache(client, data.orderForm)\n }\n }, [client, data, error, loadingQuery])\n\n const value = useMemo(\n () => ({\n error,\n loading,\n orderForm: error ? emptyOrderForm : orderForm,\n setOrderForm: (newOrderForm: Partial<OrderForm>) => {\n updateApolloCache(client, { ...orderForm, ...newOrderForm })\n setOrderForm(newOrderForm)\n },\n }),\n [client, error, loading, orderForm]\n )\n return (\n <OrderFormContext.Provider value={value}>\n {children}\n </OrderFormContext.Provider>\n )\n}\n\nexport const useOrderForm = () => {\n const context = useContext(OrderFormContext)\n if (context === undefined) {\n throw new Error('useOrderForm must be used within a OrderFormProvider')\n }\n\n return context\n}\n\nexport default { OrderFormProvider, useOrderForm }\n\n```" } ]
code_store-on-localhost_b093ca77
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/OrderManager/constants.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport enum QueueStatus {\n PENDING = 'Pending',\n FULFILLED = 'Fulfilled',\n}\n\n```" } ]
code_store-on-localhost_4baf2e96
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/OrderManager/OrderQueue.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n createContext,\n FC,\n ReactNode,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport { QueueStatus } from './constants'\nimport { TaskQueue } from './modules/TaskQueue'\nimport { CancellablePromiseLike } from './modules/SequentialTaskQueue'\n\ntype ListenFunction = (event: QueueStatus, callback: () => any) => () => void\n\ninterface Context {\n enqueue: <T extends any>(\n task: () => Promise<T>,\n id?: string\n ) => CancellablePromiseLike<T>\n listen: ListenFunction\n isWaiting: (id: string) => boolean\n}\n\ninterface OrderQueueProviderProps {\n children: ReactNode\n}\n\nconst OrderQueueContext = createContext<Context | undefined>(undefined)\n\nexport const useQueueStatus = (listen: ListenFunction) => {\n const queueStatus = useRef(QueueStatus.FULFILLED)\n\n useEffect(() => {\n const unlisten = listen(\n QueueStatus.PENDING,\n () => (queueStatus.current = QueueStatus.PENDING)\n )\n return unlisten\n }, [listen])\n\n useEffect(() => {\n const unlisten = listen(\n QueueStatus.FULFILLED,\n () => (queueStatus.current = QueueStatus.FULFILLED)\n )\n return unlisten\n }, [listen])\n\n return queueStatus\n}\n\nexport const OrderQueueProvider: FC<OrderQueueProviderProps> = ({\n children,\n}) => {\n const [queue] = useState(() => new TaskQueue())\n\n const value = useMemo(\n () => ({\n enqueue: queue.enqueue.bind(queue),\n listen: queue.listen.bind(queue),\n isWaiting: queue.isWaiting.bind(queue),\n }),\n [queue]\n )\n\n return (\n <OrderQueueContext.Provider value={value}>\n {children}\n </OrderQueueContext.Provider>\n )\n}\n\nexport const useOrderQueue = () => {\n const context = useContext(OrderQueueContext)\n if (context === undefined) {\n throw new Error('useOrderQueue must be used within a OrderQueueProvider')\n }\n\n return context\n}\n\nexport default {\n OrderQueueProvider,\n QueueStatus,\n useOrderQueue,\n useQueueStatus,\n}\n\n```" } ]
code_store-on-localhost_a05626b6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/PixelContext/PixelContext.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport hoistNonReactStatics from 'hoist-non-react-statics'\nimport React, { useContext, createContext, PureComponent } from 'react'\n\ntype EventType =\n | 'homeView'\n | 'productView'\n | 'productClick'\n | 'productImpression'\n | 'otherView'\n | 'categoryView'\n | 'departmentView'\n | 'internalSiteSearchView'\n | 'pageInfo'\n | 'pageView'\n | 'addToCart'\n | 'removeFromCart'\n | 'pageComponentInteraction'\n | 'orderPlaced'\n | 'installWebApp'\n\nexport interface PixelData {\n event?: EventType\n [data: string]: any\n}\n\ninterface PixelEvent extends Event {\n data: any\n}\n\nexport interface PixelContextType {\n push: (data: PixelData) => void\n}\n\ndeclare var process: {\n env: {\n NODE_ENV: 'production' | 'development'\n VTEX_APP_ID: string\n }\n}\n\ninterface Props {\n currency: string\n}\n\nconst PixelContext = createContext<PixelContextType>({\n push: () => undefined,\n})\n\nconst getDisplayName = <T extends {}>(comp: React.ComponentType<T>) =>\n comp.displayName || comp.name || 'Component'\n\nexport const usePixel = () => useContext(PixelContext)\n\n/**\n * withPixel is the HOC Component that provides an event subscription to the\n * Wrapped Component. This component will be used by the installed apps.\n */\nexport function withPixel<T>(\n WrappedComponent: React.ComponentType<T & PixelContextType>\n) {\n const PixelComponent: React.FC<T> = props => {\n const { push } = usePixel()\n return <WrappedComponent {...props} push={push} />\n }\n\n PixelComponent.displayName = `withPixel(${getDisplayName(WrappedComponent)})`\n\n return hoistNonReactStatics(PixelComponent, WrappedComponent)\n}\n\nclass PixelProvider extends PureComponent<Props> {\n private pixelContextValue: PixelContextType\n\n public constructor(props: Props) {\n super(props)\n\n this.pixelContextValue = {\n push: this.push,\n }\n }\n\n public componentDidMount() {\n window.addEventListener('message', this.handleWindowMessage)\n }\n\n public componentWillUnmount() {\n window.removeEventListener('message', this.handleWindowMessage)\n }\n\n /**\n * Push event to iframe\n */\n public push = (data: PixelData) => {\n // Add all events to window when is linking to ease debugging\n // **Don't make those if's one!**\n if (process.env.NODE_ENV === 'development') {\n if (typeof window !== 'undefined') {\n window.pixelManagerEvents = window.pixelManagerEvents || []\n window.pixelManagerEvents.push(data)\n }\n }\n\n this.handlePixelEvent(data)\n }\n\n public render() {\n return (\n <PixelContext.Provider value={this.pixelContextValue}>\n {this.props.children}\n </PixelContext.Provider>\n )\n }\n\n private handleWindowMessage = (e: PixelEvent) => {\n if (e.data.pageComponentInteraction) {\n this.push({\n data: e.data,\n event: 'pageComponentInteraction',\n })\n }\n }\n\n private enhanceEvent = (event: PixelData, currency: string) => ({\n currency,\n eventName: `vtex:${event.event}`,\n ...event,\n })\n\n private handlePixelEvent = (event: PixelData) => {\n const eventData = this.enhanceEvent(event, this.props.currency)\n try {\n window.postMessage(eventData, window.origin)\n } catch (e) {\n // IE and Edge have a bug on postMessage inside promises.\n // Ignoring for now, will try to find a workaround that\n // makes postMessage work on those browsers.\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14719328/\n }\n }\n}\n\nexport default { Pixel: withPixel, withPixel, PixelProvider, usePixel }\n```" } ]
code_store-on-localhost_4567f1c1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/DeviceDetector/DeviceDetector.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent } from 'react'\nimport useDevice, { DeviceInfo } from './useDevice'\n\nexport interface Props {\n children?: (deviceInfo: DeviceInfo) => React.ReactElement\n}\n\nconst DeviceDetector: FunctionComponent<Props> = ({ children }) => {\n const { device, isMobile } = useDevice()\n\n if (!children) {\n return null\n }\n\n return children({ device, isMobile })\n}\n\nexport default DeviceDetector\n\n```" } ]
code_store-on-localhost_8ccc6743
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/DeviceDetector/useDevice.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useMedia } from 'use-media'\nimport { useSSR, useRuntime } from '../../../../vtex.render-runtime'\n\nexport interface DeviceInfo {\n device: Device\n isMobile: boolean\n}\n\nexport enum Device {\n phone = 'phone',\n tablet = 'tablet',\n desktop = 'desktop',\n}\n\nconst useDevice = () => {\n const isSSR = useSSR()\n const { hints } = useRuntime()\n\n /** These screensizes are hardcoded, based on the default\n * Tachyons breakpoints. They should probably be the ones\n * configured via the style.json file, if available. */\n const isScreenMedium = useMedia({ minWidth: '40rem' })\n const isScreenLarge = useMedia({ minWidth: '64.1rem' })\n\n if (isSSR) {\n return {\n device: hints.phone\n ? Device.phone\n : hints.tablet\n ? Device.tablet\n : Device.desktop,\n isMobile: hints.mobile,\n }\n }\n\n return {\n device: isScreenLarge\n ? Device.desktop\n : isScreenMedium\n ? Device.tablet\n : Device.phone,\n isMobile: !isScreenLarge,\n }\n}\n\nexport default useDevice\n\n```" } ]
code_store-on-localhost_8547fb25
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/DeviceDetector/withDevice.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, ComponentType } from 'react'\nimport useDevice, { DeviceInfo } from './useDevice'\n\ninterface WithDeviceProps {\n deviceInfo: DeviceInfo\n}\n\nconst withDevice = <P extends object>(\n Component: ComponentType<P>\n): FC<P & WithDeviceProps> => ({ ...props }: WithDeviceProps) => {\n const { isMobile, device } = useDevice()\n\n return <Component device={device} isMobile={isMobile} {...(props as P)} />\n}\n\nexport default withDevice\n\n```" } ]
code_store-on-localhost_4ffc3617
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreImage/ImageList.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages } from 'react-intl'\nimport useDevice from '../DeviceDetector/useDevice'\nimport useListContext from '../ListContext/useListContext'\nimport ListContextProvider from '../ListContext/ListContextProvider'\n\nimport Image from './Image'\n\ninterface Link {\n url: string\n noFollow: boolean\n openNewTab: boolean\n title: string\n}\n\ninterface Image {\n link?: Link\n image: string\n mobileImage: string\n description: string\n}\n\ninterface Props {\n images: Image[]\n height: number\n}\n\nconst ImageList: StorefrontFunctionComponent<Props> = ({\n images,\n height = 420,\n children,\n}) => {\n const { isMobile } = useDevice()\n const { list } = useListContext() || { list: [] }\n\n const imageListContent = images.map(\n ({ link, image, mobileImage, description }, idx) => (\n <Image\n key={idx}\n src={isMobile && mobileImage ? mobileImage : image}\n alt={description}\n link={link}\n maxHeight={height}\n width=\"100%\"\n />\n )\n )\n\n const newListContextValue = list.concat(imageListContent)\n\n return (\n <ListContextProvider list={newListContextValue}>\n {children}\n </ListContextProvider>\n )\n}\n\nconst messages = defineMessages({\n title: { id: 'admin/editor.image-list.title', defaultMessage: '' },\n description: {\n id: 'admin/editor.image-list.description',\n defaultMessage: '',\n },\n imagesImageTitle: {\n id: 'admin/editor.image-list.images.image.title',\n defaultMessage: '',\n },\n imagesMobileImageTitle: {\n id: 'admin/editor.image-list.images.mobileImage.title',\n defaultMessage: '',\n },\n imagesImageDescription: {\n id: 'admin/editor.image-list.images.description.title',\n defaultMessage: '',\n },\n imagesImageLinkUrl: {\n id: 'admin/editor.image-list.images.link.url.title',\n defaultMessage: '',\n },\n imagesImageLinkOpenNewTab: {\n id: 'admin/editor.image-list.images.link.openNewTab.title',\n defaultMessage: '',\n },\n imagesImageLinkNoFollow: {\n id: 'admin/editor.image-list.images.link.noFollow.title',\n defaultMessage: '',\n },\n imagesImageLinkTitle: {\n id: 'admin/editor.image-list.images.link.title.title',\n defaultMessage: '',\n },\n imagesTitle: {\n id: 'admin/editor.image-list.images.title',\n defaultMessage: '',\n },\n heightTitle: {\n id: 'admin/editor.image-list.height.title',\n defaultMessage: '',\n },\n})\n\nImageList.schema = {\n title: messages.title.id,\n description: messages.description.id,\n type: 'object',\n properties: {\n height: {\n default: 420,\n enum: [420, 440],\n isLayout: true,\n title: messages.heightTitle.id,\n type: 'number',\n },\n },\n}\n\nexport default ImageList\n\n```" } ]
code_store-on-localhost_476fbf68
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreImage/Image.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { ImgHTMLAttributes, Fragment } from 'react'\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport { injectIntl, WrappedComponentProps, defineMessages } from 'react-intl'\nimport formatIOMessage from '../NativeTypes/formatIOMessage'\n\nexport interface ImageProps extends ImgHTMLAttributes<HTMLImageElement>, WrappedComponentProps {\n maxWidth?: string | number\n maxHeight?: string | number\n minWidth?: string | number\n minHeight?: string | number\n blockClass?: string\n link?: {\n url: string\n noFollow: boolean\n openNewTab: boolean\n title: string\n }\n}\n\nconst CSS_HANDLES = ['imageElement', 'imageElementLink'] as const\n\nconst Image: StorefrontFunctionComponent<ImageProps> = ({\n src,\n alt = '',\n maxWidth,\n maxHeight,\n minWidth,\n minHeight,\n width,\n height,\n srcSet = '',\n sizes = '',\n link,\n intl,\n}) => {\n const handles = useCssHandles(CSS_HANDLES, {\n migrationFrom: 'vtex.store-components@3.x',\n })\n const imageDimensions = {\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n width,\n height,\n }\n\n const formattedSrc = formatIOMessage({ id: src, intl })\n const formattedAlt = formatIOMessage({ id: alt, intl })\n\n const imgElement = (\n <img\n src={formattedSrc}\n srcSet={srcSet}\n sizes={sizes}\n alt={formattedAlt}\n style={imageDimensions}\n className={handles.imageElement}\n />\n )\n\n return link ? (\n <a\n href={formatIOMessage({ id: link.url, intl })}\n rel={link.noFollow ? 'nofollow' : ''}\n target={link.openNewTab ? '_blank' : ''}\n title={formatIOMessage({ id: link.title, intl })}\n className={handles.imageElementLink}>\n {imgElement}\n </a>\n ) : (\n <Fragment>{imgElement}</Fragment>\n )\n}\n\nconst messages = defineMessages({\n title: {\n defaultMessage: '',\n id: 'admin/editor.store-image.title',\n },\n description: {\n defaultMessage: '',\n id: 'admin/editor.store-image.description',\n },\n blockClassTitle: {\n defaultMessage: '',\n id: 'admin/editor.store-image.blockClass.title',\n },\n blockClassDescription: {\n defaultMessage: '',\n id: 'admin/editor.store-image.blockClass.description',\n },\n})\n\nImage.schema = {\n title: messages.title.id,\n description: messages.description.id,\n type: 'object',\n properties: {\n blockClass: {\n title: messages.blockClassTitle.id,\n description: messages.blockClassDescription.id,\n type: 'string',\n isLayout: true,\n },\n },\n}\n\nexport default injectIntl(Image)\n\n```" } ]
code_store-on-localhost_9dcaf0e2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreImage/ImageSlider.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'\nimport SliderLayout from '../SliderLayout/SliderLayout'\nimport useDevice from '../DeviceDetector/useDevice'\nimport formatIOMessage from '../NativeTypes/formatIOMessage'\n\nimport Image from './Image'\n\ninterface Image {\n link?: {\n url: string\n noFollow: boolean\n openNewTab: boolean\n title: string\n }\n image: string\n mobileImage: string\n description: string\n}\n\ninterface SliderConfig {\n itemsPerPage: {\n desktop: number\n tablet: number\n phone: number\n }\n showNavigationArrows: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n showPaginationDots: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n usePagination: boolean\n infinite: boolean\n}\n\ninterface Props {\n images: Image[]\n height: number\n sliderLayoutConfig: SliderConfig\n}\n\nfunction getImageUrl(isMobile: boolean, image: string, mobileImage: string) {\n return !!mobileImage && isMobile ? mobileImage : image\n}\n\nconst ImageSlider: StorefrontFunctionComponent<Props & WrappedComponentProps> = ({\n images,\n height,\n sliderLayoutConfig = {\n itemsPerPage: {\n desktop: 1,\n tablet: 1,\n phone: 1,\n },\n infinite: true,\n showNavigationArrows: 'always',\n showPaginationDots: 'always',\n usePagination: true,\n },\n intl,\n}) => {\n const { isMobile } = useDevice()\n\n return (\n <SliderLayout {...sliderLayoutConfig} totalItems={images.length}>\n {images.map(({ link, image, mobileImage, description }, idx) => {\n const imageUrl = getImageUrl(\n isMobile,\n formatIOMessage({ id: image, intl }),\n formatIOMessage({ id: mobileImage, intl })\n )\n const imageAltDescription = formatIOMessage({ id: description, intl })\n const imageLink = link && {\n ...link,\n url: formatIOMessage({ id: link.url, intl }),\n title: formatIOMessage({ id: link.title, intl }),\n }\n\n return (\n <Image\n key={idx}\n src={imageUrl}\n alt={imageAltDescription}\n link={imageLink}\n maxHeight={height}\n width=\"100%\"\n />\n )\n })}\n </SliderLayout>\n )\n}\n\nconst messages = defineMessages({\n title: { id: 'admin/editor.image-slider.title', defaultMessage: '' },\n description: {\n id: 'admin/editor.image-slider.description',\n defaultMessage: '',\n },\n imagesImageTitle: {\n id: 'admin/editor.image-list.images.image.title',\n defaultMessage: '',\n },\n imagesMobileImageTitle: {\n id: 'admin/editor.image-list.images.mobileImage.title',\n defaultMessage: '',\n },\n imagesImageDescription: {\n id: 'admin/editor.image-list.images.description.title',\n defaultMessage: '',\n },\n imagesImageLinkUrl: {\n id: 'admin/editor.image-list.images.link.url.title',\n defaultMessage: '',\n },\n imagesImageLinkOpenNewTab: {\n id: 'admin/editor.image-list.images.link.openNewTab.title',\n defaultMessage: '',\n },\n imagesImageLinkNoFollow: {\n id: 'admin/editor.image-list.images.link.noFollow.title',\n defaultMessage: '',\n },\n imagesImageLinkTitle: {\n id: 'admin/editor.image-list.images.link.title.title',\n defaultMessage: '',\n },\n imagesTitle: {\n id: 'admin/editor.image-list.images.title',\n defaultMessage: '',\n },\n heightTitle: {\n id: 'admin/editor.image-list.height.title',\n defaultMessage: '',\n },\n sliderTitle: {\n id: 'admin/editor.image-slider.slider.title',\n defaultMessage: '',\n },\n sliderInfinite: {\n id: 'admin/editor.image-slider.slider.infinite',\n defaultMessage: '',\n },\n sliderShowNavigation: {\n id: 'admin/editor.image-slider.slider.showNavigation',\n defaultMessage: '',\n },\n sliderShowPaginationDots: {\n id: 'admin/editor.image-slider.slider.showPaginationDots',\n defaultMessage: '',\n },\n sliderUsePagination: {\n id: 'admin/editor.image-slider.slider.usePagination',\n defaultMessage: '',\n },\n})\n\nImageSlider.schema = {\n title: messages.title.id,\n description: messages.description.id,\n type: 'object',\n properties: {\n height: {\n default: 420,\n enum: [420, 440],\n isLayout: true,\n title: messages.heightTitle.id,\n type: 'number',\n },\n sliderLayoutConfig: {\n title: messages.sliderTitle.id,\n properties: {\n infinite: {\n default: true,\n title: messages.sliderInfinite.id,\n type: 'boolean',\n },\n showNavigationArrows: {\n default: 'always',\n enum: ['mobileOnly', 'desktopOnly', 'always', 'never'],\n title: messages.sliderShowNavigation.id,\n type: 'string',\n },\n showPaginationDots: {\n default: 'always',\n enum: ['mobileOnly', 'desktopOnly', 'always', 'never'],\n title: messages.sliderShowPaginationDots.id,\n type: 'string',\n },\n usePagination: {\n default: true,\n title: messages.sliderUsePagination.id,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n },\n}\n\nexport default injectIntl(ImageSlider)\n\n```" } ]
code_store-on-localhost_213ad2ae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSpecificationBadges/index.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport useProduct from '../ProductContext/useProduct'\nimport BaseSpecificationBadges from './components/BaseSpecificationBadges'\n\nconst ProductSpecificationBadges: StorefrontFunctionComponent<BaseProps> = ({\n specificationGroupName,\n visibleWhen,\n specificationsOptions,\n specificationName,\n displayValue,\n orientation\n}) => {\n const { product } = useProduct() as any\n return (\n <BaseSpecificationBadges\n product={product}\n orientation={orientation}\n specificationGroupName={specificationGroupName}\n visibleWhen={visibleWhen}\n specificationsOptions={specificationsOptions}\n specificationName={specificationName}\n displayValue={displayValue}\n />\n )\n}\n\nProductSpecificationBadges.schema = {\n ...BaseSpecificationBadges.schema,\n title: 'admin/editor.product-specification-badges.title',\n description: 'admin/editor.product-specification-badges.description',\n}\n\nexport default ProductSpecificationBadges\n\n```" } ]
code_store-on-localhost_9f6886f5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductSpecificationBadges/BaseSpecificationBadges.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport BaseSpecificationBadges from './components/BaseSpecificationBadges'\n\nexport default BaseSpecificationBadges\n\n```" } ]
code_store-on-localhost_4a8a463e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ListContext/useListContext.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useContext } from 'react'\nimport { ListContext } from './ListContextProvider'\n\nconst useListContext = () => {\n return useContext(ListContext)\n}\n\nexport default useListContext\n\n```" } ]
code_store-on-localhost_58bdd1b3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ListContext/ListContextProvider.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { useMemo, FC } from 'react'\n\nexport interface ListContextProps {\n list: JSX.Element[]\n}\n\nexport const ListContext = React.createContext<ListContextProps>({\n list: [],\n})\nListContext.displayName = 'ListContext'\n\nconst ListContextProvider: FC<ListContextProps> = ({ list = [], children }) => {\n const value = useMemo(() => ({ list }), [list])\n return <ListContext.Provider value={value}>{children}</ListContext.Provider>\n}\nListContextProvider.displayName = 'ListContextProvider'\n\nexport default ListContextProvider\n\n```" } ]
code_store-on-localhost_860f41e7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ListContext/package.json from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --quiet --fix --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.3\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.6\",\n \"react-apollo\": \"^2.5.8\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.2\",\n \"@types/ramda\": \"^0.26.33\",\n \"@types/react\": \"^16.8.22\",\n \"@types/react-intl\": \"^2.3.18\",\n \"@vtex/test-tools\": \"^0.3.2\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"eslint\": \"^6.4.0\",\n \"eslint-config-vtex\": \"^11.0.0\",\n \"eslint-config-vtex-react\": \"^5.0.1\",\n \"prettier\": \"^1.18.2\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.1.1\"\n}\n\n```" } ]
code_store-on-localhost_9175ab5d
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/OrderItems/OrderItems.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, {\n createContext,\n FC,\n useCallback,\n useContext,\n useMemo,\n useRef,\n} from 'react'\nimport { useMutation } from 'react-apollo'\nimport OrderQueue from '../OrderManager/OrderQueue'\nimport OrderFormOrder from '../OrderManager/OrderForm'\nimport { loader } from 'graphql.macro'\n\nconst { \n QueueStatus,\n useOrderQueue,\n useQueueStatus,\n} = OrderQueue\n\nconst UpdateItems = loader('../CheckoutResources/mutations/updateItems.graphql')\n\nconst { useOrderForm } = OrderFormOrder\n\nconst AVAILABLE = 'available'\nconst TASK_CANCELLED = 'TASK_CANCELLED'\n\nenum Totalizers {\n SUBTOTAL = 'Items',\n DISCOUNT = 'Discounts',\n}\n\ninterface Context {\n updateQuantity: (props: Partial<Item>) => void\n removeItem: (props: Partial<Item>) => void\n}\n\ninterface CancellablePromiseLike<T> extends Promise<T> {\n cancel: () => void\n}\n\ninterface EnqueuedTask {\n promise?: CancellablePromiseLike<any>\n variables?: any\n}\n\nconst OrderItemsContext = createContext<Context | undefined>(undefined)\n\nconst noop = async (_: Partial<Item>) => {}\n\nconst maybeUpdateTotalizers = (\n totalizers: Totalizer[],\n value: number,\n oldItem: Item,\n newItem: Item\n) => {\n if (oldItem.availability !== AVAILABLE) {\n return {}\n }\n\n const oldPrice = oldItem.price * oldItem.quantity\n const newPrice = newItem.price * newItem.quantity\n const subtotalDifference = newPrice - oldPrice\n\n const oldDiscount = (oldItem.sellingPrice - oldItem.price) * oldItem.quantity\n const newDiscount = (newItem.sellingPrice - newItem.price) * newItem.quantity\n const discountDifference = newDiscount - oldDiscount\n\n const newTotalizers = totalizers.map((totalizer: Totalizer) => {\n switch (totalizer.id) {\n case Totalizers.SUBTOTAL:\n return { ...totalizer, value: totalizer.value + subtotalDifference }\n case Totalizers.DISCOUNT:\n return { ...totalizer, value: totalizer.value + discountDifference }\n default:\n return totalizer\n }\n })\n const newValue = value + subtotalDifference + discountDifference\n\n return { totalizers: newTotalizers, value: newValue }\n}\n\nconst enqueueTask = ({\n task,\n enqueue,\n queueStatusRef,\n setOrderForm,\n taskId,\n}: {\n task: () => Promise<any>\n enqueue: (task: any, id?: string) => CancellablePromiseLike<any>\n queueStatusRef: React.MutableRefObject<any>\n setOrderForm: (orderForm: Partial<OrderForm>) => void\n taskId?: string\n}) => {\n const promise = enqueue(task, taskId)\n const cancelPromise = promise.cancel\n const newPromise = promise\n .then((newOrderForm: OrderForm) => {\n if (queueStatusRef.current === QueueStatus.FULFILLED) {\n setOrderForm(newOrderForm)\n }\n })\n .catch((error: any) => {\n if (!error || error.code !== TASK_CANCELLED) {\n throw error\n }\n }) as CancellablePromiseLike<void>\n\n newPromise.cancel = cancelPromise\n return newPromise\n}\n\nexport const OrderItemsProvider: FC = ({ children }) => {\n const { enqueue, listen, isWaiting } = useOrderQueue()\n const { loading, orderForm, setOrderForm } = useOrderForm()\n\n const [updateItems] = useMutation(UpdateItems)\n\n const queueStatusRef = useQueueStatus(listen)\n const lastUpdateTaskRef = useRef({\n promise: undefined,\n variables: undefined,\n } as EnqueuedTask)\n\n if (!orderForm) {\n throw new Error('Unable to fetch order form.')\n }\n\n const { items, totalizers, value: orderFormValue } = orderForm\n\n const itemIds = useCallback(\n (props: Partial<Item>) => {\n let index = props.index\n let uniqueId = props.uniqueId\n\n if (index) {\n uniqueId = items[index].uniqueId as string\n } else if (uniqueId) {\n index = items.findIndex(\n (item: Item) => item.uniqueId === props.uniqueId\n ) as number\n } else {\n throw new Error(\n 'Either index or uniqueId must be provided when updating an item'\n )\n }\n\n return { index, uniqueId }\n },\n [items]\n )\n\n const updateOrderForm = useCallback(\n (index: number, props: Partial<Item>) => {\n const newItem = { ...items[index], ...props }\n\n const updatedList = [\n ...items.slice(0, index),\n ...(props.quantity === 0 ? [] : [newItem]),\n ...items.slice(index + 1),\n ]\n\n setOrderForm({\n ...maybeUpdateTotalizers(\n totalizers,\n orderFormValue,\n items[index],\n newItem\n ),\n items: updatedList,\n })\n },\n [items, totalizers, orderFormValue, setOrderForm]\n )\n\n const mutationTask = useCallback(\n (items: Partial<Item>[]) => async () => {\n const {\n data: { updateItems: newOrderForm },\n } = await updateItems({\n variables: {\n orderItems: items,\n },\n })\n\n return newOrderForm\n },\n [updateItems]\n )\n\n const updateQuantity = useCallback(\n async (props: Partial<Item>) => {\n const { index, uniqueId } = itemIds(props)\n updateOrderForm(index, { quantity: props.quantity })\n const taskId = 'OrderItems-updateQuantity'\n let items = [{ uniqueId, quantity: props.quantity }]\n\n if (lastUpdateTaskRef.current.promise && isWaiting(taskId)) {\n lastUpdateTaskRef.current.promise.cancel()\n items = [\n ...lastUpdateTaskRef.current.variables.filter(\n (item: Pick<Item, 'uniqueId'>) => item.uniqueId !== uniqueId\n ),\n ...items,\n ]\n }\n\n lastUpdateTaskRef.current.promise = enqueueTask({\n task: mutationTask(items),\n enqueue: enqueue as any,\n queueStatusRef,\n setOrderForm,\n taskId,\n })\n lastUpdateTaskRef.current.variables = items\n },\n [enqueue, itemIds, mutationTask, setOrderForm, updateOrderForm]\n )\n\n const removeItem = useCallback(\n (props: Partial<Item>) => updateQuantity({ ...props, quantity: 0 }),\n [updateQuantity]\n )\n\n const value = useMemo(\n () =>\n loading\n ? {\n updateQuantity: noop,\n removeItem: noop,\n }\n : { updateQuantity, removeItem },\n [loading, updateQuantity, removeItem]\n )\n\n return (\n <OrderItemsContext.Provider value={value}>\n {children}\n </OrderItemsContext.Provider>\n )\n}\n\nexport const useOrderItems = () => {\n const context = useContext(OrderItemsContext)\n if (context === undefined) {\n throw new Error('useOrderItems must be used within a OrderItemsProvider')\n }\n\n return context\n}\n\nexport default { OrderItemsProvider, useOrderItems }\n\n```" } ]
code_store-on-localhost_8b8175f0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CssHandles/applyModifiers.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nconst validateModifier = (modifier: string) => {\n if (typeof modifier !== 'string') {\n console.error(\n `Invalid modifier type on \\`cssHandles.applyModifier\\`. All modifiers should be strings, found \"${modifier}\" `\n )\n return false\n }\n\n /* This is not an error, so doesn't log any message, but should\n * invalidate the current modifier and not include it*/\n if (modifier === '') {\n return false\n }\n\n if (/[^A-z0-9-]/.test(modifier)) {\n console.error(\n `Invalid modifier on \\`cssHandles.applyModifier\\`. Modifiers should contain only letters, numbers or -`\n )\n return false\n }\n\n return true\n}\n\nconst applyModifiers = (handles: string, modifier: string | string[]) => {\n const normalizedModifiers =\n typeof modifier === 'string' ? [modifier] : modifier\n if (!Array.isArray(normalizedModifiers)) {\n console.error(\n 'Invalid modifier type on `cssHandles.applyModifier`. Please use either a string or an array of strings'\n )\n return handles\n }\n\n const splitHandles = handles?.split(' ')\n\n const modifiedHandles = normalizedModifiers\n .map(currentModifier => {\n const isValid = validateModifier(currentModifier)\n\n if (!isValid) {\n return ''\n }\n\n return splitHandles\n ?.map(handle => `${handle}--${currentModifier}`)\n .join(' ')\n .trim()\n })\n .filter(l => l?.length > 0)\n .join(' ')\n .trim()\n\n return splitHandles\n ?.concat(modifiedHandles)\n .join(' ')\n .trim()\n}\n\nexport default applyModifiers\n\n```" } ]
code_store-on-localhost_0f302f67
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CssHandles/package.json from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"lint\": \"tsc --noEmit && eslint --quiet --fix --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"apollo-client\": \"^2.6.3\",\n \"react\": \"^16.10.1\",\n \"react-apollo\": \"^2.5.8\",\n \"react-dom\": \"^16.8.6\",\n \"react-intl\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.2\",\n \"@types/react\": \"^16.9.4\",\n \"@types/react-intl\": \"^2.3.18\",\n \"@vtex/test-tools\": \"^0.3.2\",\n \"@vtex/tsconfig\": \"^0.2.0\",\n \"eslint\": \"5.x\",\n \"eslint-config-vtex-react\": \"^5.0.1\",\n \"prettier\": \"^1.18.2\",\n \"prop-types\": \"^15.7.2\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.4.1\"\n}\n\n```" } ]
code_store-on-localhost_ecfac064
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CssHandles/withCssHandles.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport useCssHandles from './useCssHandles'\nimport { ComponentType } from 'react'\n\nconst withCssHandles = <T extends CssHandlesInput, ComponentProps>(\n handles: T,\n options?: CssHandlesOptions\n) => (\n Component: ComponentType<ComponentProps & { cssHandles: CssHandles<T> }>\n) => {\n const EnhancedComponent = (props: ComponentProps) => {\n const cssHandles = useCssHandles(handles, options)\n\n return <Component cssHandles={cssHandles} {...props} />\n }\n\n const displayName = Component.displayName || Component.name || 'Component'\n EnhancedComponent.displayName = `withCssHandles(${displayName})`\n\n return EnhancedComponent\n}\n\nexport default withCssHandles\n\n```" } ]
code_store-on-localhost_49aeaa36
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/CssHandles/useCssHandles.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useMemo } from 'react'\nimport { useExtension } from './hooks/useExtension'\nimport applyModifiers from './applyModifiers'\n\n/** Verifies if the handle contains only letters and numbers, and does not begin with a number */\nconst validateCssHandle = (handle: string) => !/^\\d|[^A-z0-9]/.test(handle)\n\nconst parseComponentName = (componentName: string) => {\n /* Matches until the first `.` or `@`.\n * Used to split something like `vtex.style-guide@2.0.1` into\n * `vtex`, `style-guide`, and `2`. */\n const splitAppName = /[^@.]+/g\n\n /* regex.exec is stateful, this is why running the command 3 times\n * provides 3 different results. Yeah I know.\n * There exists a `String.matchAll()` function but it's not\n * supported on Safari */\n const [vendor] = splitAppName.exec(componentName) || [null]\n const [name] = splitAppName.exec(componentName) || [null]\n const [major] = splitAppName.exec(componentName) || [null]\n\n return { vendor, name, major }\n}\n\nconst normalizeComponentName = (componentName: string) => {\n const { vendor, name, major } = parseComponentName(componentName)\n\n return vendor && name && major && `${vendor}-${name}-${major}-x`\n}\n\nconst generateCssHandles = <T extends CssHandlesInput>(\n namespace: string,\n handles: T,\n modifiers?: string | string[]\n) => {\n return handles.reduce<Record<string, string>>((acc, handle) => {\n const isValid = !!namespace && validateCssHandle(handle)\n const transformedHandle = `${namespace}-${handle}`\n acc[handle] = isValid\n ? modifiers\n ? applyModifiers(transformedHandle, modifiers)\n : transformedHandle\n : ''\n\n if (!isValid) {\n console.error(\n `Invalid CSS handle \"${handle}\". It should only contain letters or numbers, and should start with a letter.`\n )\n }\n\n return acc\n }, {}) as CssHandles<T>\n}\n\n/**\n * Useful for creating CSS handles without creating a CSS file with empty\n * declarations.\n * Receives an array of strings (e.g. ['foo', 'bar']) and returns an\n * object with generated css class names, e.g.\n * { foo: 'vendor-appname-1-x-foo', bar: 'vendor-appname-1-x-bar' }.\n */\nconst useCssHandles = <T extends CssHandlesInput>(\n handles: T,\n options: CssHandlesOptions = {}\n): CssHandles<T> => {\n const extension = useExtension()\n\n const { props = {}, component = '' } = extension || {}\n const blockClass = props.cssHandle || props.blockClass || options.blockClass\n\n const values = useMemo<CssHandles<T>>(() => {\n const { migrationFrom } = options\n const normalizedComponent = normalizeComponentName(component)\n\n const namespaces = normalizedComponent ? [normalizedComponent] : []\n if (migrationFrom) {\n const migrations = Array.isArray(migrationFrom)\n ? migrationFrom\n : [migrationFrom]\n\n const normalizedMigrations = migrations\n .map(normalizeComponentName)\n .filter(\n current => !!current && current !== normalizedComponent\n ) as string[]\n\n namespaces.push(...normalizedMigrations)\n }\n\n return namespaces\n .map(component => generateCssHandles(component, handles, blockClass))\n .reduce<CssHandles<T>>(\n (acc: null | CssHandles<T>, cur: CssHandles<T>) => {\n if (!acc) {\n return cur\n }\n Object.keys(cur).forEach((key: ValueOf<T>) => {\n acc[key] = `${acc[key]} ${cur[key]}`\n })\n return acc\n },\n undefined as any\n )\n }, [blockClass, component, handles, options])\n\n return values || {} as any\n}\n\nexport default useCssHandles\n\n```" } ]
code_store-on-localhost_65a77b13
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/RichText/index.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent, memo, useEffect, useState, useRef, useMemo } from 'react'\nimport { injectIntl, WrappedComponentProps } from 'react-intl'\nimport marked, { Renderer } from 'marked'\nimport { values, last, test } from 'ramda'\nimport escapeHtml from 'escape-html'\nimport insane from 'insane'\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nimport formatIOMessage from '../NativeTypes/formatIOMessage'\n\n//@ts-ignore\nimport styles from './styles/index.css'\n\nimport {\n textPositionTypes,\n textAlignmentTypes,\n textPositionValues,\n textAlignmentValues,\n} from './typings/SchemaTypes'\n\nconst CSS_HANDLES = [\n 'container',\n 'paragraph',\n 'strong',\n 'italic',\n 'heading',\n 'link',\n 'table',\n 'tableHead',\n 'tableBody',\n 'headingLevel1',\n 'headingLevel2',\n 'headingLevel3',\n 'headingLevel4',\n 'headingLevel5',\n 'headingLevel6',\n 'list',\n 'listOrdered',\n 'listItem',\n 'image'\n] as const\n\nconst justifyTokens = {\n [textPositionValues.LEFT]: 'justify-start',\n [textPositionValues.CENTER]: 'justify-center',\n [textPositionValues.RIGHT]: 'justify-end',\n}\n\nconst alignTokens = {\n [textAlignmentValues.LEFT]: 'tl',\n [textAlignmentValues.CENTER]: 'tc',\n [textAlignmentValues.RIGHT]: 'tr',\n}\n\nconst itemsTokens = {\n [textAlignmentValues.LEFT]: 'items-start',\n [textAlignmentValues.CENTER]: 'items-center',\n [textAlignmentValues.RIGHT]: 'items-end',\n}\n\ntype PropTokensNames = 'textPosition' | 'textAlignment'\n\nconst defaultValues = {\n textPosition: textPositionTypes.TEXT_POSITION_LEFT.value,\n textAlignment: textAlignmentTypes.TEXT_ALIGNMENT_LEFT.value,\n}\n\nconst getEnumValues = (\n enumObject: Record<string, { value: string; name: string }>\n) => values(enumObject).map(({ value }) => value)\nconst getEnumNames = (\n enumObject: Record<string, { value: string; name: string }>\n) => values(enumObject).map(({ name }) => name)\n\nconst safelyGetToken = (\n tokenMap: Record<string, string>,\n valueWanted: string,\n propName: PropTokensNames\n) => tokenMap[valueWanted] || defaultValues[propName]\n\ninterface Props extends WrappedComponentProps {\n font: string\n text: string\n textAlignment: textAlignmentValues\n textColor: string\n textPosition: textPositionValues\n htmlId?: string\n}\n\ninterface VTEXIOComponent extends FunctionComponent<Props> {\n schema?: any\n}\n\ntype RichTextCssHandles = CssHandles<typeof CSS_HANDLES>\n\nconst sanitizerConfig = {\n allowedTags: ['p', 'span', 'a', 'div', 'br', 'img', 'iframe', 'table', 'thead', 'tbody', 'tr', 'td', 'th', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'li'],\n allowedAttributes: {\n a: ['class', 'href', 'title', 'target'],\n span: ['class'],\n p: ['class'],\n div: ['class'],\n table: ['class'],\n thead: ['class'],\n tbody: ['class'],\n img: ['class', 'src', 'title', 'alt'],\n iframe: ['frameborder', 'height', 'src', 'width', 'style'],\n h1: ['class'],\n h2: ['class'],\n h3: ['class'],\n h4: ['class'],\n h5: ['class'],\n h6: ['class'],\n ul: ['class'],\n ol: ['class'],\n li: ['class'],\n },\n allowedSchemes: ['http', 'https', 'mailto', 'tel'],\n}\n\nconst getLevel = (level: number) => level > 0 && level <= 6 ? level : 6\n\nconst getTargetFromUrl = (url: string) => {\n const urlSplit = url.split('?')\n if (urlSplit.length < 2) {\n return ''\n }\n const qs = urlSplit[1]\n const hastTargetBlank = qs.includes('target=_blank')\n return hastTargetBlank ? 'target=_blank' : ''\n}\n\nconst typography = [\n 't-heading-1',\n 't-heading-2',\n 't-heading-3',\n 't-heading-4',\n 't-heading-5',\n 't-heading-6',\n 't-body',\n 't-small',\n 't-mini',\n 't-code',\n]\n\nconst sanitizeFont = (font: string) => {\n if (!font) {\n return 't-body'\n }\n\n const first = font.split(' ')[0]\n\n if (typography.indexOf(first) === -1) {\n return 't-body'\n }\n\n return first\n}\n\nconst sanitizeColor = (color: string) => {\n if (!color) {\n return 'c-on-base'\n }\n\n const first = color.split(' ')[0]\n\n if (first.indexOf('c-') === 0) {\n return first\n }\n\n return 'c-on-base'\n}\n\nconst getHeadingLevelClass = (handles: RichTextCssHandles, level: number) => {\n switch (level) {\n case 1:\n return handles.headingLevel1\n case 2:\n return handles.headingLevel2\n case 3:\n return handles.headingLevel3\n case 4:\n return handles.headingLevel4\n case 5:\n return handles.headingLevel5\n case 6:\n return handles.headingLevel6\n default:\n return ''\n }\n}\n\nconst renderHeading = (handles: RichTextCssHandles) => (text: string, level: number) => {\n const levelNumber = getLevel(level)\n const classes =\n `${handles.heading} t-heading-${levelNumber} ${getHeadingLevelClass(handles, levelNumber)} ${styles[`heading-level-${levelNumber}`]}`\n return `<h${levelNumber} class=\"${classes}\">${text}</h${levelNumber}>`\n}\n\nconst RichText: FunctionComponent<any> = ({\n font,\n text,\n textAlignment,\n textColor,\n textPosition,\n htmlId,\n intl,\n blockClass,\n}) => {\n return null\n // const [isMounted, setMounted] = useState(false)\n // const handles = useCssHandles(CSS_HANDLES,{blockClass})\n // const renderer = useRef<Renderer>()\n // useEffect(() => {\n // setMounted(true)\n // }, [])\n\n // if (!isMounted) {\n // renderer.current = new Renderer()\n // renderer.current.paragraph = text =>\n // `<p class=\"lh-copy ${handles.paragraph}\">${text}</p>`\n // renderer.current.strong = text => `<span class=\"b ${handles.strong}\">${text}</span>`\n // renderer.current.em = text => `<span class=\"i ${handles.italic}\">${text}</span>`\n // renderer.current.heading = renderHeading(handles)\n // renderer.current.link = (href: string, title: string, text: string) => {\n // const targetAtr = getTargetFromUrl(href)\n // const targetRemoved = !!targetAtr ? href.replace(/target=_blank/, '').replace(/\\?\\&/, '?') : href\n\n // //clean trailing ? or &\n // const cleanHref = test(/\\?|\\&/, last(targetRemoved)) ? targetRemoved.slice(0, -1) : targetRemoved\n // const titleAtr = title ? `title=\"${title}\"` : ''\n\n // let finalLink = `<a class=\"${handles.link}\" href=\"${cleanHref}\"`\n // if (titleAtr) {\n // finalLink += ` ${titleAtr}`\n // }\n\n // if (targetAtr) {\n // finalLink += ` ${targetAtr}`\n // }\n\n // finalLink += `>${text}</any>`\n // return finalLink\n // }\n // renderer.current.html = html => escapeHtml(html)\n // renderer.current.table = (header, body) => `\n // <table class=\"${handles.table}\">\n // <thead class=\"${handles.tableHead}\">\n // ${header}\n // </thead>\n // <tbody class=\"${handles.tableBody}\">\n // ${body}\n // </tbody>\n // </table>`\n // renderer.current.image = (href: string, title: string, text: string) =>\n // `<img class=\"${\n // handles.image\n // }\" src=\"${href}\" alt=\"${text}\" ${title ? `title=\"${title}\"` : ''} />`\n // renderer.current.list = (body: string, ordered: boolean) => {\n // const tag = ordered ? 'ol' : 'ul'\n // return `<${tag} class=\"${handles.list} ${ordered ? handles.listOrdered : ''}\">${body}</${tag}>`\n // }\n // renderer.current.listitem = (text: string) => `<li class=\"${handles.listItem}\">${text}</li>`\n // }\n\n // const alignToken = safelyGetToken(alignTokens, textAlignment, 'textAlignment')\n // const itemsToken = safelyGetToken(itemsTokens, textPosition, 'textPosition')\n // const justifyToken = safelyGetToken(\n // justifyTokens,\n // textPosition,\n // 'textPosition'\n // )\n\n // const html = useMemo(() => {\n // marked.setOptions({\n // gfm: true,\n // breaks: true,\n // sanitize: false, //Use insane lib for sanitizing\n // smartLists: true,\n // renderer: renderer.current,\n // })\n\n // return insane(\n // //TODO: While markdown component isn't released, it needs to be done this way.\n // marked(formatIOMessage({ id: text, intl })),\n // sanitizerConfig\n // )\n // }, [text, intl, sanitizerConfig, marked, insane, formatIOMessage])\n\n // return (\n // <div\n // id={htmlId}\n // className={`${handles.container} flex ${alignToken} ${itemsToken} ${justifyToken} ${sanitizeFont(font)} ${sanitizeColor(textColor)}`}\n // >\n // <div dangerouslySetInnerHTML={{ __html: html }} />\n // </div>\n // )\n}\n\nRichText.defaultProps = {\n font: 't-body',\n text: '',\n textPosition: defaultValues.textPosition,\n textAlignment: defaultValues.textAlignment,\n textColor: 'c-on-base',\n}\n\nconst MemoizedRichText: VTEXIOComponent = memo(RichText)\n\nMemoizedRichText.schema = {\n title: 'admin/editor.rich-text.title',\n description: 'admin/editor.rich-text.description',\n type: 'object',\n properties: {\n textPosition: {\n title: 'admin/editor.rich-text.textPosition.title',\n description: 'admin/editor.rich-text.textPosition.description',\n type: 'string',\n enum: getEnumValues(textPositionTypes),\n enumNames: getEnumNames(textPositionTypes),\n default: defaultValues.textPosition,\n isLayout: true,\n },\n textAlignment: {\n title: 'admin/editor.rich-text.textAlignment.title',\n description: 'admin/editor.rich-text.textAlignment.description',\n type: 'string',\n default: defaultValues.textAlignment,\n enum: getEnumValues(textAlignmentTypes),\n enumNames: getEnumNames(textAlignmentTypes),\n isLayout: true,\n },\n font: {\n title: 'admin/editor.rich-text.font.title',\n description: 'admin/editor.rich-text.font.description',\n type: 'string',\n default: 't-body',\n isLayout: true,\n },\n textColor: {\n title: 'admin/editor.rich-text.textColor.title',\n description: 'admin/editor.rich-text.textColor.description',\n type: 'string',\n default: 'c-on-base',\n isLayout: true,\n },\n blockClass: {\n title: 'admin/editor.rich-text.blockClass.title',\n description: 'admin/editor.rich-text.blockClass.description',\n type: 'string',\n default: null,\n isLayout: true,\n },\n },\n}\n\nexport default injectIntl(MemoizedRichText) as any\n\n```" } ]
code_store-on-localhost_9d1c6b17
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/RichText/package.json from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.rich-text\",\n \"scripts\": {\n \"lint\": \"eslint . --ext .ts --ext .tsx\",\n \"lint:fix\": \"eslint --fix . --ext .ts --ext .tsx\",\n \"pretest\": \"yarn\",\n \"test\": \"vtex-test-tools test\"\n },\n \"dependencies\": {\n \"escape-html\": \"^1.0.3\",\n \"insane\": \"^2.6.2\",\n \"marked\": \"^0.6.1\",\n \"ramda\": \"^0.26.1\",\n \"react-intl\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@babel/core\": \"^7.3.4\",\n \"@babel/preset-env\": \"^7.3.4\",\n \"@types/escape-html\": \"^0.0.20\",\n \"@types/jest\": \"^24.0.9\",\n \"@types/marked\": \"^0.6.4\",\n \"@types/node\": \"^11.10.0\",\n \"@types/ramda\": \"^0.26.6\",\n \"@types/react\": \"^16.8.6\",\n \"@vtex/test-tools\": \"^0.2.0\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.0.0\",\n \"prettier\": \"^1.16.4\",\n \"react-dom\": \"^16.8.4\",\n \"typescript\": \"3.5.2\"\n },\n \"version\": \"0.8.2\"\n}\n\n```" } ]
code_store-on-localhost_46b5d148
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Shelf/Shelf.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\nimport React, { useMemo } from 'react'\nimport { graphql } from 'react-apollo'\nimport { Loading } from '../../../../vtex.render-runtime'\nimport useDevice from '../DeviceDetector/useDevice'\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport ProductListContext from '../ProductListContext/ProductListContext'\n\nimport OrdenationTypes, {\n getOrdenationNames,\n getOrdenationValues,\n} from './utils/OrdenationTypes'\nimport ProductList from './components/ProductList'\nimport {\n productListSchemaPropTypes,\n shelfContentPropTypes,\n} from './utils/propTypes'\nimport { normalizeBuyable } from './utils/normalize'\nimport { loader } from 'graphql.macro'\n\nconst productsQuery = loader('./queries/productsQuery.gql')\n\nconst CSS_HANDLES = ['container']\n\nconst { ProductListProvider } = ProductListContext\n\n/**\n * Shelf Component. Queries a list of products and shows them.\n */\nconst Shelf = props => {\n const {\n data,\n paginationDotsVisibility = 'visible',\n productList = ProductList.defaultProps,\n } = props\n const handles = useCssHandles(CSS_HANDLES)\n const { isMobile } = useDevice()\n const { loading, error, products } = data || {}\n\n const filteredProducts = useMemo(() => {\n return products && products.map(normalizeBuyable).filter(Boolean)\n }, [products])\n\n const productListProps = {\n ...productList,\n isMobile,\n loading: loading,\n paginationDotsVisibility,\n products: filteredProducts,\n }\n\n if (loading) {\n return <Loading />\n }\n\n if (error) {\n return null\n }\n\n return (\n <div className={`${handles.container} pv4 pb9`}>\n <ProductListProvider>\n <ProductList {...productListProps} />\n </ProductListProvider>\n </div>\n )\n}\n\nShelf.propTypes = {\n /** Graphql data response. */\n data: PropTypes.shape({\n products: shelfContentPropTypes.products,\n }),\n /** Category Id. */\n category: PropTypes.string,\n /** Collection Id. */\n collection: PropTypes.string,\n /** Ordenation Type. */\n orderBy: PropTypes.oneOf(getOrdenationValues()),\n /** Hide unavailable items */\n hideUnavailableItems: PropTypes.bool,\n /** Should display navigation dots below the Shelf */\n paginationDotsVisibility: PropTypes.oneOf([\n 'visible',\n 'hidden',\n 'mobileOnly',\n 'desktopOnly',\n ]),\n /** ProductList schema configuration */\n productList: PropTypes.shape(productListSchemaPropTypes),\n}\n\nconst parseFilters = ({ id, value }) => `specificationFilter_${id}:${value}`\n\nconst toBoolean = x => (typeof x === 'boolean' ? x : x === 'true')\n\nconst options = {\n options: ({\n category,\n collection,\n hideUnavailableItems,\n orderBy = OrdenationTypes.ORDER_BY_TOP_SALE_DESC.value,\n specificationFilters = [],\n maxItems = ProductList.defaultProps.maxItems,\n skusFilter,\n }) => ({\n variables: {\n ...(category && { category: category.toString() }),\n ...(collection && { collection: collection.toString() }),\n specificationFilters: specificationFilters.map(parseFilters),\n orderBy,\n from: 0,\n to: maxItems - 1,\n hideUnavailableItems: toBoolean(hideUnavailableItems),\n skusFilter,\n },\n }),\n}\n\nconst EnhancedShelf = graphql(productsQuery, options)(Shelf)\n\nEnhancedShelf.schema = {\n title: 'admin/editor.shelf.title',\n}\n\nexport default EnhancedShelf\n\n```" } ]
code_store-on-localhost_0df2693c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Shelf/TabbedShelf.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport TabbedShelf from './components/TabbedShelf/index'\n\nexport default TabbedShelf\n```" } ]
code_store-on-localhost_c556105a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Shelf/RelatedProducts.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { useMemo } from 'react'\nimport PropTypes from 'prop-types'\nimport { path, last } from 'ramda'\nimport { Query } from 'react-apollo'\nimport useDevice from '../DeviceDetector/useDevice'\nimport ProductListContext from '../ProductListContext/ProductListContext'\nimport useProduct from '../ProductContext/useProduct'\nimport useCssHandles from '../CssHandles/useCssHandles'\nimport { loader } from 'graphql.macro'\n\nimport ProductList from './components/ProductList'\nimport { productListSchemaPropTypes } from './utils/propTypes'\n\nconst productRecommendations = loader('./queries/productRecommendations.gql')\nconst CSS_HANDLES = ['relatedProducts']\n\nconst { ProductListProvider } = ProductListContext\n\n// Previous values were in a wrong format with the message string in the enum value.\nconst fixRecommendation = recommendation => {\n if (recommendation.includes('editor.relatedProducts.')) {\n return last(recommendation.split('.'))\n }\n return recommendation\n}\n\n/**\n * Related Products Component. Queries and shows the related products\n */\nconst RelatedProducts = ({\n productQuery,\n productList,\n recommendation: cmsRecommendation,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n const { isMobile } = useDevice()\n\n const productContext = useProduct()\n\n const productId =\n path(['product', 'productId'], productQuery) ||\n path(['product', 'productId'], productContext)\n\n const recommendation = productId ? fixRecommendation(cmsRecommendation) : null\n const variables = useMemo(() => {\n if (!productId) {\n return null\n }\n\n return {\n identifier: { field: 'id', value: productId },\n type: recommendation,\n }\n }, [productId, recommendation])\n\n if (!productId) {\n return null\n }\n\n return (\n <Query\n query={productRecommendations}\n variables={variables}\n partialRefetch\n ssr={false}\n >\n {({ data, loading }) => {\n if (!data) {\n return null\n }\n const { productRecommendations } = data\n const productListProps = {\n products: productRecommendations || [],\n loading,\n isMobile,\n ...productList,\n }\n return (\n <div className={handles.relatedProducts}>\n <ProductListProvider>\n <ProductList {...productListProps} />\n </ProductListProvider>\n </div>\n )\n }}\n </Query>\n )\n}\n\nRelatedProducts.propTypes = {\n /** Main product to have related products queried */\n slug: PropTypes.string,\n /** Graphql productQuery response. */\n productQuery: PropTypes.shape({\n /** Product to have related products queried */\n product: PropTypes.shape({\n productId: PropTypes.string,\n }),\n loading: PropTypes.bool,\n }),\n /** ProductList schema configuration */\n productList: PropTypes.shape(productListSchemaPropTypes),\n}\n\nRelatedProducts.defaultProps = {\n recommendation: 'similars',\n productList: {\n ...ProductList.defaultProps,\n titleText: 'Related Products',\n },\n}\n\nRelatedProducts.schema = {\n title: 'admin/editor.relatedProducts.title',\n description: 'admin/editor.relatedProducts.description',\n type: 'object',\n properties: {\n recommendation: {\n title: 'admin/editor.relatedProducts.recommendation',\n description: 'admin/editor.relatedProducts.recommendation.description',\n type: 'string',\n default: RelatedProducts.defaultProps.recommendation,\n enum: [\n 'similars',\n 'view',\n 'buy',\n 'accessories',\n 'viewAndBought',\n 'suggestions',\n ],\n enumNames: [\n 'admin/editor.relatedProducts.similars',\n 'admin/editor.relatedProducts.view',\n 'admin/editor.relatedProducts.buy',\n 'admin/editor.relatedProducts.accessories',\n 'admin/editor.relatedProducts.viewAndBought',\n 'admin/editor.relatedProducts.suggestions',\n ],\n },\n productList: ProductList.schema,\n },\n}\n\nexport default RelatedProducts\n\n```" } ]
code_store-on-localhost_d04466c0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Shelf/ProductList.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductList from './components/ProductList'\n\nexport default ProductList\n```" } ]
code_store-on-localhost_2f7ffac5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/InfoCard.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport InfoCard from './components/InfoCard/index'\n\nexport default InfoCard\n\n```" } ]
code_store-on-localhost_14e59caf
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/UserAddress.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport UserAddress from './components/UserAddress/index'\n\nexport default UserAddress\n\n```" } ]
code_store-on-localhost_834bd129
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/NotificationBar.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport NotificationBar from './components/Notification/notificationBar'\n\nexport default NotificationBar\n\n```" } ]
code_store-on-localhost_f2e7a3df
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/BuyButton.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport BuyButton from './components/BuyButton/Wrapper'\n\nexport default BuyButton\n\n```" } ]
code_store-on-localhost_888a9dc7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/CollectionBadges.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport CollectionBadges from './components/CollectionBadges/index'\n\nexport default CollectionBadges\n\n```" } ]
code_store-on-localhost_06d8c892
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/CategoriesHighlights.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport CategoriesHighlights from './components/CategoriesHighlights'\n\nexport default CategoriesHighlights\n\n```" } ]
code_store-on-localhost_3f0e6ea2
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/NotificationInline.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport NotificationInline from './components/Notification/notificationInline'\n\nexport default NotificationInline\n\n```" } ]
code_store-on-localhost_b76fe37f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductImages.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductImages from './components/ProductImages/Wrapper'\n\nexport default ProductImages\n\n```" } ]
code_store-on-localhost_c8e78d5c
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductName.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductName from './components/ProductName/Wrapper'\n\nexport default ProductName\n\n```" } ]
code_store-on-localhost_30a1dc3b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/AvailabilitySubscriber.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nexport { default } from './components/AvailabilitySubscriber/Wrapper'\n\n```" } ]
code_store-on-localhost_1c119fc9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/DiscountBadge.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport DiscountBadge from './components/DiscountBadge/index'\n\nexport default DiscountBadge\n\n```" } ]
code_store-on-localhost_7f48d7d4
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/SearchBar.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport SearchBar from './components/SearchBar/index'\n\nexport default SearchBar\n\n```" } ]
code_store-on-localhost_03049cfe
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductSeparator.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\n\nexport default () => <hr className=\"o-30\" size=\"1\" />\n\n\n```" } ]
code_store-on-localhost_c012890f
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/GradientCollapse.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport GradientCollapse from './components/GradientCollapse/index'\n\nexport default GradientCollapse\n\n```" } ]
code_store-on-localhost_6b07993e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Image.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Image from '../StoreImage/Image'\n\nexport default Image\n\n```" } ]
code_store-on-localhost_b48b5096
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/SKUSelector.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport SKUSelector from './components/SKUSelector/Wrapper'\n\nexport default SKUSelector\n\n```" } ]
code_store-on-localhost_3bed06f7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/AutocompleteResults.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport AutocompleteResults from './components/AutocompleteResults/index'\n\nexport default AutocompleteResults\n\n```" } ]
code_store-on-localhost_f687c8d8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductDescription.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductDescription from './components/ProductDescription/Wrapper'\n\nexport default ProductDescription\n\n```" } ]
code_store-on-localhost_c1b54cd1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductHighlights.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductHighlights from './components/ProductHighlights/Wrapper'\n\nexport default ProductHighlights\n\n```" } ]
code_store-on-localhost_83df9c97
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Slider.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Slider from './components/Slider/index'\n\nexport default Slider\n\n```" } ]
code_store-on-localhost_d85ceb3e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Animation.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Animation from './components/Animation/index'\n\nexport default Animation\n\n```" } ]
code_store-on-localhost_71c99c30
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Logo.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Logo from './components/Logo/index'\n\nexport default Logo\n\n```" } ]
code_store-on-localhost_d734deae
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Container.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Container from './components/Container/index'\n\nexport default Container\n\n```" } ]
code_store-on-localhost_e5203778
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductBrand.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductBrand from './components/ProductBrand'\n\nexport default ProductBrand\n\n```" } ]
code_store-on-localhost_717cea4b
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Newsletter.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Newsletter from './components/Newsletter/index'\n\nexport default Newsletter\n\n```" } ]
code_store-on-localhost_a9a1650e
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductPrice.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductPrice from './components/ProductPrice/Wrapper'\n\nexport default ProductPrice\n\n```" } ]
code_store-on-localhost_0c2d25bb
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/Share.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Share from './components/Share/Wrapper'\n\nexport default Share\n\n```" } ]
code_store-on-localhost_9a807fa1
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/StoreComponents/ProductSpecifications.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport ProductSpecifications from './components/ProductSpecifications/Wrapper'\n\nexport default ProductSpecifications\n\n```" } ]
code_store-on-localhost_97794987
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ReactPortal/index.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport Overlay from './Overlay'\n\nexport { Overlay }\n\n```" } ]
code_store-on-localhost_a33a03ad
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ReactPortal/Overlay.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n useRef,\n useEffect,\n useState,\n FunctionComponent,\n useCallback,\n} from 'react'\nimport Portal, { Props as PortalProps } from './components/Portal'\n\ninterface Props extends PortalProps {\n fullWindow: boolean\n alignment: HorizontalAlignment\n}\n\ninterface Position {\n x: number\n y: number\n}\n\nenum HorizontalAlignment {\n right = 'right',\n left = 'left',\n center = 'center',\n}\n\nconst getXPositionByHorizontalAlignment = (\n alignment: HorizontalAlignment,\n bounds: ClientRect | DOMRect\n) => {\n switch (alignment) {\n case 'left':\n return bounds.left\n case 'right':\n return bounds.right\n case 'center':\n return (bounds.right + bounds.left) / 2\n default:\n return bounds.left\n }\n}\n\nconst getJustifyTypeByHorizontalAlignment = (\n alignment: HorizontalAlignment\n) => {\n switch (alignment) {\n case 'left':\n return 'justify-start'\n case 'right':\n return 'justify-end'\n case 'center':\n return 'justify-center'\n default:\n return 'justify-start'\n }\n}\n\nconst Overlay: FunctionComponent<Props> = ({\n children,\n fullWindow,\n target,\n alignment = HorizontalAlignment.left,\n}) => {\n const container = useRef<HTMLDivElement>(null)\n const [position, setPosition] = useState<Position>()\n\n const updatePosition = useCallback(() => {\n if (!fullWindow && container.current) {\n const bounds = container.current.getBoundingClientRect()\n\n setPosition({\n x: getXPositionByHorizontalAlignment(alignment, bounds),\n y: bounds.top,\n })\n }\n }, [alignment, fullWindow])\n\n useEffect(() => {\n updatePosition()\n\n if (window) {\n window.addEventListener('scroll', updatePosition)\n window.addEventListener('load', updatePosition)\n window.addEventListener('resize', updatePosition)\n window.addEventListener('visibilitychange', updatePosition)\n }\n\n return () => {\n if (window) {\n window.removeEventListener('scroll', updatePosition)\n window.removeEventListener('load', updatePosition)\n window.removeEventListener('resize', updatePosition)\n window.removeEventListener('visibilitychange', updatePosition)\n }\n }\n }, [alignment, fullWindow, updatePosition, children])\n\n if (!fullWindow) {\n return (\n // Div used for anchoring the position of the overlay, for popovers etc\n <div\n ref={container}\n style={{\n width: 'auto',\n height: 1,\n marginTop: -1,\n }}\n >\n {position && (\n <Portal target={target}>\n <div\n className={`flex ${getJustifyTypeByHorizontalAlignment(\n alignment\n )}`}\n style={{\n position: 'absolute',\n left: position.x,\n top: position.y,\n }}\n >\n <div className=\"absolute\">{children}</div>\n </div>\n </Portal>\n )}\n </div>\n )\n }\n\n return (\n <Portal target={target} cover>\n {children}\n </Portal>\n )\n}\n\nexport default Overlay as any\n\n```" } ]
code_store-on-localhost_fdb968b9
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductContext/ProductContext.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { createContext } from 'react'\n\nexport default createContext({})\n\n```" } ]
code_store-on-localhost_9ee4b1d7
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductContext/ProductContextProvider.tsx from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useEffect, Dispatch } from 'react'\nimport ProductContext from './ProductContext'\nimport { ProductDispatchContext } from './ProductDispatchContext'\nimport { useProductReducer, getSelectedItem } from './reducer'\nimport { getSelectedSKUFromQueryString } from './modules/skuQueryString'\n\nfunction useProductInState(product: MaybeProduct, dispatch: Dispatch<Actions>) {\n useEffect(() => {\n if (product) {\n dispatch({\n type: 'SET_PRODUCT',\n args: { product },\n })\n }\n }, [product, dispatch])\n}\n\nfunction useSelectedItemFromId(\n dispatch: Dispatch<Actions>,\n product: MaybeProduct,\n skuId?: string\n) {\n useEffect(() => {\n const items = (product && product.items) || []\n dispatch({\n type: 'SET_SELECTED_ITEM',\n args: { item: getSelectedItem(skuId, items as any) },\n })\n }, [dispatch, skuId, product])\n}\n\nconst ProductContextProvider: FC<ProductAndQuery> = ({\n query,\n product,\n children,\n}) => {\n const [state, dispatch] = useProductReducer({ query, product })\n\n // These hooks are used to keep the state in sync with API data, specially when switching between products without exiting the product page\n useProductInState(product, dispatch)\n const selectedSkuQueryString = getSelectedSKUFromQueryString(query)\n useSelectedItemFromId(dispatch, product, selectedSkuQueryString)\n\n return (\n <ProductContext.Provider value={state}>\n <ProductDispatchContext.Provider value={dispatch}>\n {children}\n </ProductDispatchContext.Provider>\n </ProductContext.Provider>\n )\n}\n\nexport default ProductContextProvider\n\n```" } ]
code_store-on-localhost_23a9e4f6
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductContext/useProduct.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useContext } from 'react'\nimport ProductContext from './ProductContext'\n\nfunction useProduct() {\n return useContext(ProductContext)\n}\n\nexport default useProduct\n\n```" } ]
code_store-on-localhost_c6396113
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ProductContext/ProductDispatchContext.ts from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { createContext, useContext, Dispatch } from 'react'\n\nexport const ProductDispatchContext = createContext<Dispatch<Actions> | null>(\n null\n)\nfunction useProductDispatch() {\n return useContext(ProductDispatchContext)\n}\nexport default { ProductDispatchContext, useProductDispatch }\n\n```" } ]
code_store-on-localhost_dd7aca8a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/styles.css from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.container {}\n\n.contentInitialScreen {}\n\n.contentFormVisible {}\n\n.profile {}\n\n.label {}\n\n.loading {}\n\n.optionsSticky {}\n\n.optionsList {}\n\n.optionsListItem {}\n\n.optionsListItemContainer {}\n\n.accessCodeOptionBtn {}\n\n.emailPasswordOptionBtn {}\n\n.facebookOptionBtn {}\n\n.googleOptionBtn {}\n\n.customOAuthOptionBtn {}\n\n.oauthProvider {}\n\n.oauthAutoRedirect {}\n\n.oauthAutoRedirectLoading {}\n\n.inputContainer {}\n\n.inputContainerAccessCode {}\n\n.inputContainerPassword {}\n\n.inputContainerEmail {}\n\n.emailVerification {}\n\n.emailForm {}\n\n.emailAndPasswordForm {}\n\n.forgotPasswordForm {}\n\n.formLinkContainer {}\n\n.arrowUp {}\n\n.buttonLink {}\n\n.formError {}\n\n.content {}\n\n.button {}\n\n.sendButton {}\n\n.buttonSocial {}\n\n.buttonDanger {}\n\n.backButton {}\n\n.accountOptions {}\n\n.codeConfirmation {}\n\n.formTitle {\n white-space: pre-line;\n}\n\n.box {\n top: 100%;\n visibility: visible;\n min-width: 19.375rem;\n}\n\n.contentContainer {\n min-width: 100%;\n}\n\n.formFooter {\n min-height: 2rem;\n}\n\n.contentForm {\n min-width: 18.125rem;\n}\n\n.contentAlwaysWithOptions {\n min-height: 18.75rem;\n max-width: 43.75rem;\n}\n\n@media only screen and (max-width: 600px) {\n .contentAlwaysWithOptions {\n max-width: 25rem;\n }\n}\n\n.options {\n min-width: 20rem;\n}\n\n.sendButton:only-child {\n margin: 0;\n width: 100%;\n}\n\n.sendButton:only-child :global(.vtex-button) {\n width: 100%;\n}\n\n.tooltipContainer {\n width: max-content;\n} \n\n.tooltipContainerTop {\n bottom: 110%;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.tooltipContainerLeft {\n top: 50%;\n transform: translateY(-50%);\n right: 102%;\n}\n\n.tooltipContainerLeft::after {\n content: '';\n position: absolute;\n top: 45%;\n left: 100%;\n border-width: 0.625rem;\n border-style: solid;\n border-color: transparent transparent transparent #3b3b3b;\n}\n\n.tooltipContainerTop::after {\n content: '';\n position: absolute;\n left: 45%;\n top: 100%;\n border-width: 0.625rem;\n border-style: solid;\n border-color: #3b3b3b transparent transparent transparent;\n}\n\n.button :global(.vtex-button) {\n border: 1px solid rgb(233, 233, 233);\n width: 100%;\n min-height: 2.5rem;\n}\n\n.button :global(.vtex-button) .oauthLabel {\n margin: 0 1.25rem 0 1.25rem;\n}\n\n.buttonDanger > :global(.vtex-button){\n background-color: #ffe6e6;\n color: #FF4C4C;\n}\n\n.buttonDanger > :global(.vtex-button) :global(.vtex__icon-spinner){\n color: #FF4C4C;\n}\n\n```" } ]
code_store-on-localhost_88bd22c3
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/README.md from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Login\nLogin is a canonical component that any VTEX app can import.\n\nTo import it into your code: \n```js\nimport Login from 'vtex.store-components/Login'\n```\n\n## Usage\nYou can use it in your code like a React component with the jsx tag: `<Login />`. \n```html\n<Login />\n```\n\n```" } ]
code_store-on-localhost_8a60dde5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/LoginContent.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Suspense } from 'react'\nimport LoginContent from './components/LoginContent'\nimport { NoSSR } from '../../../../vtex.render-runtime'\nimport Loading from './components/Loading'\n\nconst LoginContentWrapper = props => {\n return (\n <NoSSR>\n <Suspense fallback={<Loading />}>\n <LoginContent {...props} />\n </Suspense>\n </NoSSR>\n )\n}\n\nLoginContentWrapper.getSchema = () => ({\n title: 'admin/editor.loginPage.title',\n ...LoginSchema,\n properties: {\n ...LoginSchema.properties,\n isInitialScreenOptionOnly: {\n title: 'admin/editor.login.isInitialScreenOptionOnly.title',\n type: 'boolean',\n default: true,\n isLayout: true,\n },\n defaultOption: {\n title: 'admin/editor.login.defaultOption.title',\n type: 'number',\n default: 0,\n isLayout: true,\n enum: [0, 1],\n enumNames: [\n 'admin/editor.login.defaultOption.token',\n 'admin/editor.login.defaultOption.emailAndPassword',\n ],\n widget: {\n 'ui:widget': 'radio',\n 'ui:options': {\n inline: true,\n },\n },\n },\n },\n})\n\nexport default LoginContentWrapper\n```" } ]
code_store-on-localhost_aeeb2142
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/Login.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\n\nimport { withSession } from '../../../../vtex.render-runtime'\nimport { injectIntl } from 'react-intl'\n\nimport { LoginSchema } from './schema'\nimport { setCookie } from './utils/set-cookie'\nimport { LoginContainerProptypes } from './propTypes'\nimport LoginComponent from './components/LoginComponent'\nimport { getProfile } from './utils/profile'\n\nconst DEFAULT_CLASSES = 'gray'\n\n/** Canonical login that calls a mutation to retrieve the authentication token */\n\nexport default class Login extends Component {\n static propTypes = LoginContainerProptypes\n\n static defaultProps = {\n labelClasses: DEFAULT_CLASSES,\n }\n\n state = {\n isBoxOpen: false,\n renderIconAsLink: false,\n sessionProfile: null,\n }\n\n getSessionPromiseFromWindow = () =>\n !window.__RENDER_8_SESSION__ || !window.__RENDER_8_SESSION__.sessionPromise\n ? Promise.resolve(null)\n : window.__RENDER_8_SESSION__.sessionPromise\n\n componentDidMount() {\n window.addEventListener('resize', this.handleResize)\n this.handleResize()\n\n if (window.location.href.indexOf('accountAuthCookieName') > 0) {\n setCookie(window.location.href)\n }\n\n this.getSessionPromiseFromWindow().then(data => {\n const sessionResponse = (data || {}).response\n const sessionProfile = getProfile(sessionResponse)\n if (sessionProfile) this.setState({ sessionProfile })\n })\n }\n\n componentWillUnmount() {\n window.removeEventListener('resize', this.handleResize)\n }\n\n handleResize = () => {\n const WIDTH_THRESHOLD = 640\n\n if (window.innerWidth < WIDTH_THRESHOLD && !this.state.renderIconAsLink) {\n this.setState({\n renderIconAsLink: true,\n })\n } else if (\n window.innerWidth >= WIDTH_THRESHOLD &&\n this.state.renderIconAsLink\n ) {\n this.setState({\n renderIconAsLink: false,\n })\n }\n }\n\n handleProfileIconClick = () => {\n this.setState({ isBoxOpen: !this.state.isBoxOpen })\n }\n\n handleOutSideBoxClick = () => {\n this.setState({ isBoxOpen: false })\n }\n\n render() {\n return (\n <LoginWithSession\n isBoxOpen={this.state.isBoxOpen}\n renderIconAsLink={this.state.renderIconAsLink}\n sessionProfile={this.state.sessionProfile}\n {...this.props}\n onOutSideBoxClick={this.handleOutSideBoxClick}\n onProfileIconClick={this.handleProfileIconClick}\n />\n )\n }\n}\n\nLogin.getSchema = () => ({\n title: 'admin/editor.login.title',\n ...LoginSchema,\n properties: {\n ...LoginSchema.properties,\n mirrorTooltipToRight: {\n title: 'admin/editor.login.mirrorTooltipToRightTitle',\n type: 'boolean',\n default: 'false',\n },\n },\n})\n\nconst LoginWithSession = withSession({ renderWhileLoading: true })(injectIntl(LoginComponent))\n\n```" } ]
code_store-on-localhost_93a81d65
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/schema.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nexport const LoginSchema = {\n type: 'object',\n properties: {\n optionsTitle: {\n title: 'admin/editor.login.optionsTitle',\n type: 'string',\n widget: {\n 'ui:widget': 'textarea',\n },\n },\n emailAndPasswordTitle: {\n title: 'admin/editor.login.emailAndPasswordTitle',\n type: 'string',\n widget: {\n 'ui:widget': 'textarea',\n },\n },\n accessCodeTitle: {\n title: 'admin/editor.login.accessCodeTitle',\n type: 'string',\n widget: {\n 'ui:widget': 'textarea',\n },\n },\n emailPlaceholder: {\n title: 'admin/editor.login.emailPlaceholder',\n type: 'string',\n },\n passwordPlaceholder: {\n title: 'admin/editor.login.passwordPlaceholder',\n type: 'string',\n },\n showPasswordVerificationIntoTooltip: {\n title: 'admin/editor.login.showPasswordVerificationIntoTooltip.title',\n type: 'boolean',\n isLayout: true,\n },\n accessCodePlaceholder: {\n title: 'admin/editor.login.accessCodePlaceholder',\n type: 'string',\n },\n showIconProfile: {\n title: 'admin/editor.login.showIconProfile',\n type: 'boolean',\n },\n iconLabel: {\n title: 'admin/editor.login.iconLabel',\n type: 'string',\n },\n providerPasswordButtonLabel: {\n title: 'admin/editor.login.providerPasswordButtonLabel',\n type: 'string',\n },\n hasIdentifierExtension: {\n title: 'admin/editor.login.hasIdentifierExtension',\n type: 'boolean',\n },\n },\n dependencies: {\n hasIdentifierExtension: {\n oneOf: [\n {\n properties: {\n hasIdentifierExtension: {\n enum: [true],\n },\n identifierPlaceholder: {\n title: 'admin/editor.login.identifierPlaceholder',\n type: 'string',\n },\n invalidIdentifierError: {\n title: 'admin/editor.login.invalidIdentifierError',\n type: 'string',\n },\n },\n },\n ],\n },\n },\n}\n\n```" } ]
code_store-on-localhost_f8e197d0
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Login/propTypes.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport PropTypes from 'prop-types'\n\nexport const LoginContainerProptypes = {\n /** Title of login options */\n optionsTitle: PropTypes.string,\n /** Title of classic login */\n emailAndPasswordTitle: PropTypes.string,\n /** Title of access code login */\n accessCodeTitle: PropTypes.string,\n /** Placeholder to email input */\n emailPlaceholder: PropTypes.string,\n /** Placeholder to password input */\n passwordPlaceholder: PropTypes.string,\n /** Placeholder to access code input */\n accessCodePlaceholder: PropTypes.string,\n /** Set the type of password verification ui */\n showPasswordVerificationIntoTooltip: PropTypes.bool,\n /** Icon's size */\n iconSize: PropTypes.number,\n /** Icon's label */\n iconLabel: PropTypes.string,\n /** Label's classnames */\n labelClasses: PropTypes.string,\n /** Determines if the icon profile will be hidden */\n showIconProfile: PropTypes.bool,\n /** Password login button text */\n providerPasswordButtonLabel: PropTypes.string,\n /** Whether the identifier extension values are enabled in the site editor */\n hasIdentifierExtension: PropTypes.bool,\n /** Placeholder for the identifier extension */\n identifierPlaceholder: PropTypes.string,\n /** Error message for the user identifier */\n invalidIdentifierError: PropTypes.string,\n /** Determines if the tooltip opens towards the right side */\n mirrorTooltipToRight: PropTypes.bool,\n}\n\nexport const LoginPropTypes = {\n /** User profile information */\n profile: PropTypes.shape({}),\n /** Is box with the login options should be opened or not */\n isBoxOpen: PropTypes.bool.isRequired,\n /** Should the Icon be rendered as link or not */\n renderIconAsLink: PropTypes.bool.isRequired,\n /** Function called when the user click outside of the box*/\n onOutSideBoxClick: PropTypes.func.isRequired,\n /** Function called when the user clicks on the icon*/\n onProfileIconClick: PropTypes.func.isRequired,\n /** Runtime context. */\n runtime: PropTypes.shape({\n history: PropTypes.shape({\n location: PropTypes.shape({\n pathname: PropTypes.string,\n search: PropTypes.string,\n }),\n }),\n }),\n /** Props received through the LoginContainer */\n ...LoginContainerProptypes,\n}\n\n```" } ]
code_store-on-localhost_2e26b1b5
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/ForceCenter.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport useCssHandles from '../CssHandles/useCssHandles'\n\nconst CSS_HANDLES = ['forceCenter', 'forceCenterInnerContainer']\n\nconst ForceCenter = ({ children }) => {\n const handles = useCssHandles(CSS_HANDLES)\n\n return (\n <div\n className={`${handles.forceCenter} absolute left-0 right-0 flex justify-center z-1`}\n style={{ pointerEvents: 'none' }}\n >\n <div\n className={handles.forceCenterInnerContainer}\n style={{ pointerEvents: 'all' }}\n >\n {children}\n </div>\n </div>\n )\n}\n\nexport default ForceCenter\n\n```" } ]
code_store-on-localhost_455dd27a
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/Layout.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Layout from './components/Layout'\n\nexport default Layout\n\n```" } ]
code_store-on-localhost_4be0c6d8
[ { "role": "system", "content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms." }, { "role": "user", "content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/header/Spacer.js from the store-on-localhost VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```javascript\nimport Spacer from './components/Spacer'\n\nexport default Spacer\n\n```" } ]