id
stringlengths
12
53
messages
listlengths
3
3
code_mycheckout-store-framework_7fcc6f85
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Menu/Rows/ColorPicker/styles.css from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.inputColorContainer {\n display: flex;\n align-items: center;\n margin: 0;\n padding: 0;\n position: relative;\n}\n\n.buttonColor {\n width: 53px;\n height: 31px;\n border-radius: 3px;\n outline: none;\n border: none;\n box-shadow: 0px -1px 0px rgb(227 228 230 / 70%);\n position: relative;\n z-index: 2;\n}\n\n.chromePickerContainer {\n position: absolute;\n z-index: 3;\n}\n\n.positionTop {\n bottom: 37px;\n}\n\n.positionBottom {\n top: 35px;\n}\n\n.chromePickerFixed {\n position: fixed;\n inset: 0;\n}\n\n.inputColorlabel {\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n margin: 0;\n padding: 0 0 0 18px;\n}\n\n```" } ]
code_mycheckout-store-framework_28f988e0
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Body/index.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { Spinner } from 'vtex.styleguide'\n\nimport styles from './styles.css'\nimport { Pdp } from './Pdp'\nimport { useStyleSettings } from '../../../hooks'\nimport { KuikpayModal } from './KuikpayModal'\nimport '../../../../../../App.global.css'\n\nexport const Body = () => {\n const { loadingStyles, componentSelected, deviceSelected } =\n useStyleSettings()\n\n const showModal = componentSelected === 'modal'\n\n return (\n <div className={styles.bodyContainer}>\n {loadingStyles ? (\n <Spinner />\n ) : (\n <div\n style={\n showModal && deviceSelected === 'mobile'\n ? { position: 'relative', width: '450px', height: '70vh' }\n : { position: 'relative', width: '100%', height: '70vh' }\n }\n >\n {!showModal && <Pdp />}\n {showModal && <KuikpayModal />}\n </div>\n )}\n </div>\n )\n}\n\n```" } ]
code_mycheckout-store-framework_e840ddde
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Body/KuikpayModal.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { KuikpayModalPreview } from 'kuikpay-sdk'\n\nimport { useKuikpayModal } from '../../../hooks'\nimport styles from './styles.css'\n\nexport const KuikpayModal = () => {\n const { isMobile, refModal } = useKuikpayModal()\n\n return (\n <div\n ref={refModal}\n className={`${styles.modalContainerDesktop} ${\n isMobile && styles.modalContainerMobile\n }`}\n >\n <KuikpayModalPreview />\n </div>\n )\n}\n\n```" } ]
code_mycheckout-store-framework_1faa1e7c
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Body/styles.css from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.bodyContainer {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 70vh;\n}\n\n.pdpContainerDesktop {\n display: grid;\n grid-template-areas: 'select image info';\n grid-template-columns: 62px 1fr 1fr;\n}\n\n.pdpContainerMobile {\n display: grid;\n grid-template-areas:\n 'image'\n 'info';\n grid-template-columns: 1fr;\n}\n\n.selectImageContainer {\n display: flex;\n grid-area: 'select';\n justify-content: center;\n width: 100%;\n}\n\n.selectImageContainer img {\n border-radius: 4px;\n border: 2px solid #134cd8;\n box-sizing: border-box;\n height: 58px;\n width: 58px;\n}\n\n.currentImgContainerDesktop {\n display: flex;\n grid-area: 'image';\n justify-content: center;\n width: 100%;\n}\n\n.currentImgContainerMobile {\n display: flex;\n justify-content: center;\n}\n\n.currentImgContainerMobile img {\n object-fit: cover;\n width: 350px;\n}\n\n.infoContainer {\n grid-area: 'info';\n}\n\n.infoContainer h5 {\n font-size: 16px;\n margin-bottom: 10px;\n}\n\n.infoContainer p {\n font-size: 14px;\n margin: 0;\n padding: 0;\n}\n\n.specificationContainer {\n margin-bottom: 10px;\n}\n\n.payButtonContainer {\n display: flex;\n height: 48px;\n justify-content: center;\n width: 100%;\n}\n\n.payButtonContainer a {\n height: 100%;\n width: 100%;\n}\n\n.payButtonContainer div {\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n}\n\n.payButtonContainer div p span {\n font-size: 16px;\n font-weight: 300;\n}\n\n.modalContainerDesktop {\n border-radius: 5px;\n bottom: 0;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.modalContainerMobile {\n width: 100%;\n}\n\n.modalPositionContainer {\n position: relative !important;\n width: 100% !important;\n height: 100% !important;\n overflow-y: scroll !important;\n}\n\n.modalCheckoutlessHeight {\n height: 100% !important;\n z-index: 1 !important;\n}\n\n.modalBuyButtonPosition {\n width: 100% !important;\n position: relative !important;\n}\n\n```" } ]
code_mycheckout-store-framework_4453200f
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Body/Pdp.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { KuikpayButtonPreview } from 'kuikpay-sdk'\n\nimport styles from './styles.css'\nimport { usePayButtonPreview } from '../../../hooks'\n\nexport const Pdp = () => {\n const { refPayButton, deviceSelected, value } = usePayButtonPreview()\n const isDesktop = deviceSelected === 'desktop'\n\n return (\n <div\n className={\n isDesktop ? styles.pdpContainerDesktop : styles.pdpContainerMobile\n }\n >\n {isDesktop && (\n <div className={styles.selectImageContainer}>\n <img\n src=\"https://personalinteractive.nizza.com/laptop-dorada.jpeg\"\n alt=\"laptop-dorada\"\n />\n </div>\n )}\n <div\n className={\n isDesktop\n ? styles.currentImgContainerDesktop\n : styles.currentImgContainerMobile\n }\n >\n <img\n src=\"https://personalinteractive.nizza.com/laptop-dorada.jpeg\"\n alt=\"laptop-dorada\"\n />\n </div>\n <div className={styles.infoContainer}>\n <h5>\n Computador Portátil Gaming 15.6 Intel® Core™ i5-9300H 8GB 256GB SSD\n GTX 1050\n </h5>\n\n <div className={styles.specificationContainer}>\n <p>Procesador</p>\n <p>Intel® Core™ i5-9300H</p>\n </div>\n\n <div className={styles.specificationContainer}>\n <p>Memoria del Sistema Ram</p>\n <p>8 GB</p>\n </div>\n\n <div className={styles.specificationContainer}>\n <p>Tamaño de Pantalla</p>\n <p>15.6 Pulgadas</p>\n </div>\n\n <div className={styles.payButtonContainer} ref={refPayButton}>\n <div>\n <KuikpayButtonPreview text={value} />\n </div>\n </div>\n </div>\n </div>\n )\n}\n\n```" } ]
code_mycheckout-store-framework_a40ee901
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Header/index.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { ActionMenu, Divider } from 'vtex.styleguide'\nimport { useIntl, messages, defineMessages } from 'react-intl'\n\nimport DesktopIcon from '../../../../../assets/icons/desktop.svg'\nimport PhoneIcon from '../../../../../assets/icons/mobile.svg'\nimport styles from './styles.css'\nimport { useStyleSettings } from '../../../hooks'\n\nconst messages = defineMessages({\n modalLabel: { id: 'checkoutless.styleSettings.preview-modal' },\n buttonLabel: { id: 'checkoutless.styleSettings.preview-button' },\n buttonDesignLabel: { id: 'checkoutless.styleSettings.preview-button-design' },\n modalDesignLabel: { id: 'checkoutless.styleSettings.preview-modal-design' },\n})\n\nexport const Header = () => {\n const { formatMessage } = useIntl()\n const {\n deviceSelected,\n componentSelected,\n setComponentSelected,\n setDeviceSelected,\n } = useStyleSettings()\n\n const options = [\n {\n label: formatMessage(messages.buttonDesignLabel),\n onClick: () => setComponentSelected('payButton'),\n },\n {\n label: formatMessage(messages.modalDesignLabel),\n onClick: () => setComponentSelected('modal'),\n },\n ]\n\n return (\n <div className={styles.header}>\n <div className={styles.title}>\n <ActionMenu\n label={formatMessage(\n componentSelected === 'payButton'\n ? messages.buttonLabel\n : messages.modalLabel\n )}\n align=\"left\"\n buttonProps={{\n variation: 'tertiary',\n }}\n options={options}\n />\n </div>\n\n <div className={styles.devicesContainer}>\n <button\n data-selected={deviceSelected === 'mobile'}\n onClick={() => {\n setDeviceSelected('mobile')\n }}\n >\n <img src={PhoneIcon} alt=\"mobile\" />\n </button>\n <button\n data-selected={deviceSelected === 'desktop'}\n onClick={() => {\n setDeviceSelected('desktop')\n }}\n >\n <img src={DesktopIcon} alt=\"desktop\" />\n </button>\n </div>\n <div className=\"mv6\">\n <Divider orientation=\"horizontal\" />\n </div>\n </div>\n )\n}\n\n```" } ]
code_mycheckout-store-framework_4e7aa3d4
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/components/Preview/Header/styles.css from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```css\n.header {\n display: flex;\n flex-direction: row;\n align-items: center;\n width: 100%;\n margin-bottom: 0.5em;\n}\n\n.title {\n flex: 5;\n display: flex;\n width: 100%;\n}\n\n.devicesContainer {\n flex: 1;\n display: flex;\n justify-content: space-evenly;\n}\n\n.devicesContainer button {\n padding: unset;\n background: unset;\n border: unset;\n width: 42px;\n height: 42px;\n border-radius: 4px;\n cursor: pointer;\n}\n\n.devicesContainer button:hover {\n background: #eef3f7 0% 0% no-repeat padding-box;\n}\n\n.devicesContainer button[data-selected='true'] {\n background: #eef3f7 0% 0% no-repeat padding-box;\n}\n```" } ]
code_mycheckout-store-framework_579d8f8b
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/context/StyleSettingsProvider.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport type { FC } from 'react'\nimport React, { useCallback, useState, useEffect } from 'react'\nimport { useMutation, useQuery } from 'react-apollo'\nimport { messages, defineMessages } from 'react-intl'\n\nimport type {\n IStyleSettingsCtx,\n Device,\n CustomizableComponent,\n IStyleSettingsQuery,\n PayButtonStyles,\n ModalStyles,\n IAlert,\n} from '../../interfaces'\nimport { StyleSettingsContext } from './styleSettingsContext'\nimport { useStyleSettingsReducer } from '../reducer/styleSettingsReducer'\nimport UPDATE_STYLES from '../../../../graphql/styles/updateStyles.graphql'\nimport GET_STYLES from '../../../../graphql/styles/getStyles.graphql'\nimport { defaultStyleSettingState } from '../../constants'\n\nconst messages = defineMessages({\n errorUpdateMessage: { id: 'checkoutless.styleSettings.error-update-styles' },\n})\n\nexport const StyleSettingsProvider: FC = ({ children }) => {\n const [componentSelected, setComponentSelected] =\n useState<CustomizableComponent>('payButton')\n\n const [deviceSelected, setDeviceSelected] = useState<Device>('desktop')\n const [alert, setAlert] = useState<IAlert>({\n message: {\n id: '',\n },\n type: 'success',\n })\n\n const [state, dispatch] = useStyleSettingsReducer()\n const [updateStylesMutations] = useMutation(UPDATE_STYLES)\n const { loading, data } = useQuery(GET_STYLES)\n\n const saveStyles = async (\n button: PayButtonStyles,\n modal: ModalStyles,\n restore: boolean\n ) => {\n const variables = {\n buttonText: button.value,\n styles: JSON.stringify({\n button,\n modal,\n }),\n restore,\n }\n\n try {\n await updateStylesMutations({\n variables,\n })\n } catch (_error) {\n setAlert({\n message: messages.errorUpdateMessage,\n type: 'error',\n })\n }\n }\n\n const setStyles = useCallback(\n (button: PayButtonStyles, modal: ModalStyles) => {\n dispatch({ type: 'SET_PAYBUTTON_STYLES', args: { styles: button } })\n dispatch({ type: 'SET_MODAL_STYLES', args: { styles: modal } })\n },\n [dispatch]\n )\n\n const updateStyles = () =>\n saveStyles(state.buttonStyles, state.modalStyles, false)\n\n const restoreStyles = async () => {\n const { buttonStyles, modalStyles } = defaultStyleSettingState\n\n setStyles(buttonStyles, modalStyles)\n await saveStyles(buttonStyles, modalStyles, true)\n }\n\n const clearAlert = () =>\n setAlert({\n message: {\n id: '',\n },\n type: 'success',\n })\n\n useEffect(() => {\n if (loading || !data || !data?.getStyles?.styles) return\n const styles: IStyleSettingsQuery = JSON.parse(data.getStyles.styles)\n\n setStyles(styles.button, styles.modal)\n }, [data, dispatch, loading, setStyles])\n\n const context: IStyleSettingsCtx = {\n state,\n componentSelected,\n deviceSelected,\n alert,\n dispatch,\n setComponentSelected,\n setDeviceSelected,\n updateStyles,\n restoreStyles,\n setAlert,\n clearAlert,\n loadingStyles: loading,\n }\n\n return (\n <StyleSettingsContext.Provider value={context}>\n {children}\n </StyleSettingsContext.Provider>\n )\n}\n\n```" } ]
code_mycheckout-store-framework_3a51bddf
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/context/index.ts from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport * from './StyleSettingsProvider'\nexport * from './styleSettingsContext'\n\n```" } ]
code_mycheckout-store-framework_18a17a2c
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/context/styleSettingsContext.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { createContext, useContext } from 'react'\n\nimport type { IStyleSettingsCtx } from '../../interfaces'\nimport { defaultStyleSettingState } from '../../constants'\n\nexport const styleSettingsCtxDefault: IStyleSettingsCtx = {\n componentSelected: 'payButton',\n deviceSelected: 'desktop',\n alert: {\n message: {\n id: '',\n },\n type: 'success',\n },\n state: defaultStyleSettingState,\n loadingStyles: true,\n setComponentSelected: () => null,\n setDeviceSelected: () => null,\n dispatch: () => null,\n updateStyles: async () => {},\n restoreStyles: async () => {},\n setAlert: () => null,\n clearAlert: () => null,\n}\n\nexport const StyleSettingsContext = createContext<IStyleSettingsCtx>(\n styleSettingsCtxDefault\n)\nexport const useStyleSettings = () => useContext(StyleSettingsContext)\n\n```" } ]
code_mycheckout-store-framework_3da34960
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/reducer/styleSettingsReducer.tsx from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { useReducer } from 'react'\n\nimport { defaultStyleSettingState } from '../../constants'\nimport type { Actions, IStyleSettings } from '../../interfaces'\nimport { modalReducer } from './modalReducer'\nimport { payButtonReducer } from './payButtonReducer'\n\nconst reducer = (state: IStyleSettings, action: Actions): IStyleSettings => {\n return {\n buttonStyles: payButtonReducer(state.buttonStyles, action),\n modalStyles: modalReducer(state.modalStyles, action),\n }\n}\n\nfunction initReducer() {\n return {\n ...defaultStyleSettingState,\n }\n}\n\nexport const useStyleSettingsReducer = () =>\n useReducer(reducer, {}, initReducer)\n\n```" } ]
code_mycheckout-store-framework_94af5c90
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/reducer/payButtonReducer.ts from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Actions, PayButtonStyles } from '../../interfaces'\n\nexport const payButtonReducer = (\n state: PayButtonStyles,\n action: Actions\n): PayButtonStyles => {\n switch (action.type) {\n case 'SET_PAYBUTTON_VALUE': {\n const { args } = action\n\n return {\n ...state,\n value: args.value,\n }\n }\n\n case 'SET_PAYBUTTON_FONT': {\n const { args } = action\n\n return {\n ...state,\n font: args.font,\n }\n }\n\n case 'SET_PAYBUTTON_RADIO': {\n const { args } = action\n\n return {\n ...state,\n borderRadius: args.borderRadius,\n }\n }\n\n case 'SET_PAYBUTTON_WIDTH': {\n const { args } = action\n\n return {\n ...state,\n width: args.width,\n }\n }\n\n case 'SET_PAYBUTTON_NORMAL_TEXT_COLOR': {\n const { args } = action\n const { normal } = state\n\n return {\n ...state,\n normal: {\n ...normal,\n textColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_NORMAL_BACKGROUND_COLOR': {\n const { args } = action\n const { normal } = state\n\n return {\n ...state,\n normal: {\n ...normal,\n backgroundColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_NORMAL_OUTLINE_COLOR': {\n const { args } = action\n const { normal } = state\n\n return {\n ...state,\n normal: {\n ...normal,\n outlineColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_HOVER_TEXT_COLOR': {\n const { args } = action\n const { hover } = state\n\n return {\n ...state,\n hover: {\n ...hover,\n textColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_HOVER_BACKGROUND_COLOR': {\n const { args } = action\n const { hover } = state\n\n return {\n ...state,\n hover: {\n ...hover,\n backgroundColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_HOVER_OUTLINE_COLOR': {\n const { args } = action\n const { hover } = state\n\n return {\n ...state,\n hover: {\n ...hover,\n outlineColor: args.color,\n },\n }\n }\n\n case 'SET_PAYBUTTON_STYLES': {\n const { args } = action\n\n return {\n ...state,\n ...args.styles,\n }\n }\n\n default:\n return state\n }\n}\n\n```" } ]
code_mycheckout-store-framework_d58dc34f
[ { "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 mycheckout-store-framework/react/admin/component/StyleSettings/hooks/reducer/modalReducer.ts from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport type { Actions, ModalStyles } from '../../interfaces'\n\nexport const modalReducer = (\n state: ModalStyles,\n action: Actions\n): ModalStyles => {\n switch (action.type) {\n case 'SET_MODAL_FONT': {\n const { args } = action\n\n return {\n ...state,\n font: args.font,\n }\n }\n\n case 'SET_MODAL_ICONS_COLOR': {\n const { args } = action\n const { icons } = state\n\n return {\n ...state,\n icons: {\n ...icons,\n color: args.iconsColor,\n },\n }\n }\n\n case 'SET_MODAL_BACKGROUND_COLOR': {\n const { args } = action\n\n return {\n ...state,\n backgroundColor: args.backgroundColor,\n }\n }\n\n case 'SET_MODAL_RADIO': {\n const { args } = action\n const { button } = state\n\n return {\n ...state,\n button: {\n ...button,\n borderRadius: args.borderRadiusBtn,\n },\n }\n }\n\n case 'SET_MODAL_BTN_NORMAL_TEXT_COLOR': {\n const { args } = action\n const { button } = state\n const { normal } = button\n\n return {\n ...state,\n button: {\n ...button,\n normal: {\n ...normal,\n textColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_BTN_NORMAL_BACKGROUND_COLOR': {\n const { args } = action\n const { button } = state\n const { normal } = button\n\n return {\n ...state,\n button: {\n ...button,\n normal: {\n ...normal,\n backgroundColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_BTN_NORMAL_OUTLINE_COLOR': {\n const { args } = action\n const { button } = state\n const { normal } = button\n\n return {\n ...state,\n button: {\n ...button,\n normal: {\n ...normal,\n outlineColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_BTN_HOVER_TEXT_COLOR': {\n const { args } = action\n const { button } = state\n const { hover } = button\n\n return {\n ...state,\n button: {\n ...button,\n hover: {\n ...hover,\n textColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_BTN_HOVER_BACKGROUND_COLOR': {\n const { args } = action\n const { button } = state\n const { hover } = button\n\n return {\n ...state,\n button: {\n ...button,\n hover: {\n ...hover,\n backgroundColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_BTN_HOVER_OUTLINE_COLOR': {\n const { args } = action\n const { button } = state\n const { hover } = button\n\n return {\n ...state,\n button: {\n ...button,\n hover: {\n ...hover,\n outlineColor: args.color,\n },\n },\n }\n }\n\n case 'SET_MODAL_STYLES': {\n const { args } = action\n\n return {\n ...state,\n ...args.styles,\n }\n }\n\n default:\n return state\n }\n}\n\n```" } ]
code_mycheckout-store-framework_a62c615d
[ { "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 mycheckout-store-framework/react/admin/graphql/metrics/getConversionRate.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getConversionRate(\n $visualization: String\n $selectedFrom: String\n $selectedUntil: String\n $previousFrom: String\n $previousUntil: String\n $timezone: String\n) {\n conversionRate(\n data: {\n filters: {\n visualization: $visualization\n selectedPeriod: { from: $selectedFrom, until: $selectedUntil }\n previousPeriod: { from: $previousFrom, until: $previousUntil }\n }\n timezone: $timezone\n }\n ) @context(provider: \"kuikpay.my-checkout\") {\n selectedPeriodCR {\n _id\n cr\n }\n currentDayCR\n currentMonthCR\n currentDayVariationCR\n previousPeriodCR {\n _id\n cr\n }\n }\n}\n\n```" } ]
code_mycheckout-store-framework_b9a1e470
[ { "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 mycheckout-store-framework/react/admin/graphql/metrics/getCheckout.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getCheckout(\n $visualization: String\n $selectedFrom: String\n $selectedUntil: String\n $previousFrom: String\n $previousUntil: String\n $timezone: String\n) {\n checkout(\n data: {\n filters: {\n visualization: $visualization\n selectedPeriod: { from: $selectedFrom, until: $selectedUntil }\n previousPeriod: { from: $previousFrom, until: $previousUntil }\n }\n timezone: $timezone\n }\n ) @context(provider: \"kuikpay.my-checkout\") {\n selectedPeriodCheckout {\n _id\n closedPurchases\n }\n currentDayCheckout\n currentMonthCheckout\n currentDayVariationCheckout\n previousPeriodCheckout {\n _id\n closedPurchases\n }\n }\n}\n\n```" } ]
code_mycheckout-store-framework_9d42b8e7
[ { "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 mycheckout-store-framework/react/admin/graphql/metrics/getTicketAverage.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getTicketAverage(\n $visualization: String\n $selectedFrom: String\n $selectedUntil: String\n $previousFrom: String\n $previousUntil: String\n $timezone: String\n) {\n ticketAverage(\n data: {\n filters: {\n visualization: $visualization\n selectedPeriod: { from: $selectedFrom, until: $selectedUntil }\n previousPeriod: { from: $previousFrom, until: $previousUntil }\n }\n timezone: $timezone\n }\n ) @context(provider: \"kuikpay.my-checkout\") {\n selectedPeriodTicket {\n _id\n ticketAverage\n }\n currentDayTicket\n currentMonthTicket\n currentDayVariationTicket\n previousPeriodTicket {\n _id\n ticketAverage\n }\n }\n}\n\n```" } ]
code_mycheckout-store-framework_a625e8b4
[ { "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 mycheckout-store-framework/react/admin/graphql/metrics/getButtonUses.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery getButtonUses(\n $visualization: String\n $selectedFrom: String\n $selectedUntil: String\n $previousFrom: String\n $previousUntil: String\n $timezone: String\n) {\n button(\n data: {\n filters: {\n visualization: $visualization\n selectedPeriod: { from: $selectedFrom, until: $selectedUntil }\n previousPeriod: { from: $previousFrom, until: $previousUntil }\n }\n timezone: $timezone\n }\n ) @context(provider: \"kuikpay.my-checkout\") {\n selectedPeriodButton {\n _id\n use\n }\n currentDayButton\n currentMonthButton\n currentDayVariationButton\n previousPeriodButton {\n _id\n use\n }\n }\n}\n\n```" } ]
code_mycheckout-store-framework_3482689a
[ { "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 mycheckout-store-framework/react/admin/graphql/styles/getStyles.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nquery {\n getStyles @context(provider: \"kuikpay.my-checkout\") {\n styles\n text\n }\n}\n\n```" } ]
code_mycheckout-store-framework_0d2e1317
[ { "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 mycheckout-store-framework/react/admin/graphql/styles/updateStyles.graphql from the mycheckout-store-framework VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```graphql\nmutation ($buttonText: String, $styles: String, $restore: Boolean)\n@context(provider: \"kuikpay.my-checkout\") {\n updateStyles(styles: $styles, buttonText: $buttonText, restore: $restore) {\n account\n }\n}\n\n```" } ]
code_slider-layout_f9a5f1f9
[ { "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 slider-layout/messages/it-IT.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Slider-Layout\",\n \"admin/editor.slider-layout.infinite\": \"Infinito\",\n \"admin/editor.slider-layout.showNavigation\": \"Mostra frecce di navigazione\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Mostra punti di impaginazione\",\n \"admin/editor.slider-layout.usePagination\": \"Utilizza impaginazione\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Larghezza massima\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Controlla se le diapositive debbano occupare o meno l'intera larghezza disponibile, facendo in modo che le frecce appaiano su di esse.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Solo dispositivi mobili\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Solo desktop\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Sempre\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Mai\"\n}\n\n```" } ]
code_slider-layout_ab052fb0
[ { "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 slider-layout/messages/th-TH.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"เค้าโครงตัวเลื่อน\",\n \"admin/editor.slider-layout.infinite\": \"ไม่จำกัด\",\n \"admin/editor.slider-layout.showNavigation\": \"แสดงลูกศรการนำทาง\",\n \"admin/editor.slider-layout.showPaginationDots\": \"แสดงจุดประการแบ่งหน้า\",\n \"admin/editor.slider-layout.usePagination\": \"ใช้การแบ่งหน้า\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"ความกว้างเต็มที่\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"ควบคุมว่าควรแสดงสไลด์เต็มความกว้างที่ใช้ได้หรือไม่ โดยแสดงลูกศรที่ด้านบนสุดของสไลด์\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"เฉพาะอุปกรณ์เคลื่อนที่\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"เฉพาะเดสก์ท็อป\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"ทุกครั้ง\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"ไม่ต้อง\"\n}\n\n```" } ]
code_slider-layout_d09e759e
[ { "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 slider-layout/messages/ko-KR.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"슬라이더 레이아웃\",\n \"admin/editor.slider-layout.infinite\": \"무한\",\n \"admin/editor.slider-layout.showNavigation\": \"탐색 화살표 표시\",\n \"admin/editor.slider-layout.showPaginationDots\": \"페이지 번호 점 표시\",\n \"admin/editor.slider-layout.usePagination\": \"페이지 번호 사용\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"전체 넓이\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"슬라이드가 사용 가능한 전체 너비를 채워, 화살표가 맨 위에 나타나는지 여부를 제어합니다.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"모바일 전용\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"데스크톱 전용\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"항상\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"안 함\"\n}\n\n```" } ]
code_slider-layout_37fa5dad
[ { "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 slider-layout/messages/ja-JP.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"スライダーレイアウト\",\n \"admin/editor.slider-layout.infinite\": \"上限なし\",\n \"admin/editor.slider-layout.showNavigation\": \"方向矢印を表示する\",\n \"admin/editor.slider-layout.showPaginationDots\": \"ページネーションドットを表示する\",\n \"admin/editor.slider-layout.usePagination\": \"ページネーションを使う\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"全幅\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"スライドが最大幅を埋め、最上部に矢印が表示されるようにするかどうかを制御します。\"\n}\n\n```" } ]
code_slider-layout_f44a96be
[ { "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 slider-layout/messages/bg-BG.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Оформление на слайдера\",\n \"admin/editor.slider-layout.infinite\": \"Безкрайно\",\n \"admin/editor.slider-layout.showNavigation\": \"Показване на навигационни стрелки\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Показване на точки за страниране\",\n \"admin/editor.slider-layout.usePagination\": \"Използване на страниране\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Пълна ширина\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Контролира дали слайдовете да изпълват цялата налична ширина, а стрелките да се виждат върху тях.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Само за мобилни устройства\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Само за настолен компютър\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Винаги\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Никога\"\n}\n\n```" } ]
code_slider-layout_af53aca9
[ { "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 slider-layout/messages/pt.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Layout do slider\",\n \"admin/editor.slider-layout.infinite\": \"Infinito\",\n \"admin/editor.slider-layout.showNavigation\": \"Mostrar setas para navegação\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Mostrar indicadores de paginação\",\n \"admin/editor.slider-layout.usePagination\": \"Usar paginação\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Largura completa\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Controla se os slides devem ou não ocupar toda a largura disponível, fazendo as setas aparecerem sobre eles.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Somente dispositivos móveis\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Somente desktop\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Sempre\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Nunca\",\n \"store/slider-layout.sliderTrack.aria-label\": \"Slide atual é {slide} de {total}\"\n}\n\n```" } ]
code_slider-layout_794d09cf
[ { "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 slider-layout/messages/en.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Slider Layout\",\n \"admin/editor.slider-layout.infinite\": \"Infinite\",\n \"admin/editor.slider-layout.showNavigation\": \"Show navigation arrows\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Show pagination dots\",\n \"admin/editor.slider-layout.usePagination\": \"Use pagination\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Full width\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Controls whether the slides should fill the full available width, making the arrows appear on top of them.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Mobile Only\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Desktop Only\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Always\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Never\",\n \"store/slider-layout.sliderTrack.aria-label\": \"Current slide is {slide} of {total}\"\n}\n\n```" } ]
code_slider-layout_12270622
[ { "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 slider-layout/messages/ro-RO.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Layout slider\",\n \"admin/editor.slider-layout.infinite\": \"Infinit\",\n \"admin/editor.slider-layout.showNavigation\": \"Arată săgețile de navigare\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Arată punctele de paginație\",\n \"admin/editor.slider-layout.usePagination\": \"Folosește paginația\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Lățime completă\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Controlează dacă slide-urile trebuie sau nu să ocupe întreaga lățime disponibilă, făcând ca săgețile să apară deasupra lor.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Doar pentru mobil\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Doar pentru desktop\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Mereu\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Niciodată\"\n}\n\n```" } ]
code_slider-layout_9b608bf2
[ { "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 slider-layout/messages/de-DE.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Slider Layout\",\n \"admin/editor.slider-layout.infinite\": \"Unendlich\",\n \"admin/editor.slider-layout.showNavigation\": \"Navigationspfeile anzeigen\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Seitenumbruch-Punkte anzeigen\",\n \"admin/editor.slider-layout.usePagination\": \"Seitennavigation verwenden\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Volle Breite\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Legt fest, ob die Diapositive die volle verfügbare Breite füllen sollen, so dass die Pfeile oben auf ihnen erscheinen.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Nur mobil\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Nur Desktop\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Immer\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Niemals\"\n}\n\n```" } ]
code_slider-layout_afe50533
[ { "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 slider-layout/messages/fr-FR.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Disposition du curseur\",\n \"admin/editor.slider-layout.infinite\": \"Infini\",\n \"admin/editor.slider-layout.showNavigation\": \"Afficher les flèches de navigation\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Afficher les points de pagination\",\n \"admin/editor.slider-layout.usePagination\": \"Utiliser la pagination\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Largeur totale\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Vérifie si les diapos doivent ou non remplir toute la largeur disponible, en faisant apparaître les flèches au-dessus d’elles.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Mobile uniquement\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Bureau uniquement\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Toujours\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Jamais\"\n}\n\n```" } ]
code_slider-layout_4c94b9d5
[ { "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 slider-layout/messages/nl-NL.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Schuifregelaar layout\",\n \"admin/editor.slider-layout.infinite\": \"Oneindig\",\n \"admin/editor.slider-layout.showNavigation\": \"Toon navigatiepijlen\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Toon pagineringstippen\",\n \"admin/editor.slider-layout.usePagination\": \"Gebruik paginering\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Volledige breedte\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Bepaalt of de dia's de volledige beschikbare breedte moeten vullen, waardoor de pijlen erboven verschijnen.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Alleen mobiel\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Alleen desktop\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Altijd\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Nooit\"\n}\n\n```" } ]
code_slider-layout_b0e492e3
[ { "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 slider-layout/messages/es.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"admin/editor.slider-layout.title\": \"Layout del slider\",\n \"admin/editor.slider-layout.infinite\": \"Infinito\",\n \"admin/editor.slider-layout.showNavigation\": \"Mostrar flechas de navegación\",\n \"admin/editor.slider-layout.showPaginationDots\": \"Mostrar puntos de paginación\",\n \"admin/editor.slider-layout.usePagination\": \"Usar paginación\",\n \"admin/editor.slider-layout.sliderFullWidth\": \"Anchura completa\",\n \"admin/editor.slider-layout.sliderFullWidthDescription\": \"Controla si las diapositivas deben ocupar la anchura completa y hacer que las flechas desaparezcan encima de ellas.\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\": \"Solo móvil\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\": \"Solo escritorio\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\": \"Siempre\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\": \"Nunca\"\n}\n\n```" } ]
code_slider-layout_6a801381
[ { "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 slider-layout/docs/README.md from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n📢 Use this project, [contribute](https://github.com/vtex-apps/slider-layout) to it or open issues to help evolve it using [Store Discussion](https://github.com/vtex-apps/store-discussion).\n\n# Slider Layout\n\n<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->\n[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors-)\n<!-- ALL-CONTRIBUTORS-BADGE:END -->\n\nSlider Layout is a flexible solution for building block sliders in VTEX Store Framework, such as a carousel component.\n\n![](https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-slider-layout-0.png)\n\n> _To use the Slider layout as a substitute for the [Carousel app](https://github.com/vtex-apps/carousel), read the [Building a Carousel through lists and Slider Layout](https://developers.vtex.com/docs/guides/vtex-io-documentation-building-a-carousel-using-slider-layout) documentation._\n\n## Google Analytics 4 Integration\n\nSlider Layout enables you to integrate your component with [Google Analytics 4](https://developers.google.com/analytics/devguides/collection/ga4). \nThe integration happens through the [`GA4 view_promotion`](https://developers.google.com/analytics/devguides/collection/ga4/reference/events?client_type=gtm#view_promotion) event, which is typically associated with the promotion banners carousel displayed by the Slider Layout.\n\nBy integrating with Google Analytics 4, you can set the `Product ID` and `Product Name`, and position of your promotion on [Site Editor](https://help.vtex.com/en/tutorial/site-editor-overview--299Dbeb9mFczUTyNQ9xPe1) to be shown on a Google Analytics dashboard.\n\nTo set this up, go to the VTEX Admin, access **Storefront > Site Editor**, and open the image settings of the internal promotion you want to track. These settings are displayed on the right side of the page.\n\n![ga4-in-site-editor](https://vtexhelp.vtexassets.com/assets/docs/src/gtm-site-editor___bc52365aafad63deb5bfed1d74f307c0.png)\n\n> For more information about managing your page content, read [Managing page and template content](https://help.vtex.com/en/tutorial/managing-page-and-template-content--3tMbx6HXy4Fy5r9EhboG37).\n\nAfter setup, Google Analytics can track your internal promotions and generate reports of their views, clicks, click-through rate, conversions, and revenue.\n\n## Configuration\n\n1. Add the `slider-layout` app to your theme dependencies in the `manifest.json` file:\n\n```json\n\"dependencies\": {\n \"vtex.slider-layout\": \"0.x\"\n}\n```\n\nNow, you can use all blocks exported by the `slider-layout` app. See the complete list below:\n\n| Block name | Description |\n| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `slider-layout` | ![https://img.shields.io/badge/-Mandatory-red](https://img.shields.io/badge/-Mandatory-red) Builds block sliders for your store through its `children` list blocks. |\n| `slider-layout-group` | Enables you to keep a group of `slider-layout` blocks synched with each other. For more information about this, see the Advanced configuration section below. |\n\n2. Add the `slider-layout` block to your template. For example:\n\n```json\n \"slider-layout#text-test\": {\n \"props\": {\n \"itemsPerPage\": {\n \"desktop\": 1,\n \"tablet\": 1,\n \"phone\": 1\n },\n \"infinite\": true,\n \"showNavigationArrows\": \"desktopOnly\",\n \"blockClass\": \"carousel\"\n },\n \"children\": [\"rich-text#1\", \"rich-text#2\", \"rich-text#3\"]\n },\n\n \"rich-text#1\": {\n \"props\": {\n \"text\": \"Test1\"\n }\n },\n \"rich-text#2\": {\n \"props\": {\n \"text\": \"Test2\"\n }\n },\n \"rich-text#3\": {\n \"props\": {\n \"text\": \"Test3\"\n }\n },\n```\n\n| Prop name | Type | Description | Default value |\n| ---------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- |\n| `label` | `string` | `aria-label` attribute value to be used by the `<Slider/>` component when rendered. The `aria-label` value should explicitly tell users what the inspected HTML element does. | `slider` |\n| `showNavigationArrows` | `enum` | Indicates when navigation arrows should be rendered. Possible values are: `mobileOnly`, `desktopOnly`, `always`, or `never`. | `always` |\n| `showPaginationDots` | `enum` | Indicates when pagination dots should be rendered. Possible values are: `mobileOnly`, `desktopOnly`, `always`, or `never`. | `always` |\n| `infinite` | `boolean` | Determines whether the slider should be infinite (`true`) or not (`false`). When this prop is set as `false`, the slider will have an explicit end for users. | `false` |\n| `usePagination` | `boolean` | Determines whether the slider should use slide pages (`true`) or not (`false`). When this prop is set as `false`, the slider will use smooth scrolling for slide navigation instead of arrows. | `true` |\n| `itemsPerPage` | `object` | The number of slider items to be shown on each type of device. For more information about this, see the `itemsPerPage` object section below. | `{ desktop: 5, tablet: 3, phone: 1 }` |\n| `navigationStep` | `number` / `enum` | The number of slider items that should be displayed when users click one of the slider arrows. It is also possible to set this prop value as `page`, meaning that the number of slider items to be displayed when one of the arrows is clicked is equal to the number of slider items set per page (in the `itemsPerPage` prop). | `page` |\n| `slideTransition` | `object` | Controls the transition animation between slides based on [CSS attributes](https://developer.mozilla.org/en-US/docs/Web/CSS/transition). For more information about this, see the `slideTransition` object section below. | `{ speed: 400, delay: 0, timing: '' }` |\n| `autoplay` | `object` | Controls the autoplay feature behavior. For more information about this, see the `autoplay` object section below. | `undefined` |\n| `fullWidth` | `boolean` | Determines whether the slides should occupy the full page width, making the arrows appear on top of them (`true`) or not (`false`). | `true` |\n| `arrowSize` | `number` / `object` | Slider arrows size (height and width) in pixels. This is a responsive prop, which means you can pass to it an object with different values for each breakpoint (`desktop`, `mobile`, `tablet`, and `phone`). | `25` |\n| `centerMode` | `enum` / `object` | Defines positioning of the slider elements on the screen. Possible values are: `center` (elements are centered, allowing users to see a peek of the previous and next slides), `to-the-left` (aligns elements to the left side, allowing users to see a peek of the next slide, but not the previous one), and `disabled` (disables the feature, rendering elements on the whole screen without showing a peek of the previous and next slides). Note: This is a responsive prop, which means you can pass to it an object with different values for each breakpoint (`desktop`, `mobile`, `tablet`, and `phone`). | `disabled` |\n| `centerModeSlidesGap` | `number` | Number of pixels between slides when `centerMode` is set to `center` or `to-the-left`. | `undefined` |\n\n- **`itemsPerPage` object**\n\n| Prop name | Type | Description | Default value |\n| --------- | -------- | -------------------------------------------------------- | ------------- |\n| `desktop` | `number` | The number of slides to be displayed on desktop devices. | `5` |\n| `tablet` | `number` | The number of slides to be displayed on tablet devices. | `3` |\n| `phone` | `number` | The number of slides to be displayed on phone devices. | `1` |\n\n- **`slideTransition` object**\n\n| Prop name | Type | Description | Default value |\n| --------- | -------- | ----------------------------------------- | ------------- |\n| `speed` | `number` | Transition speed (in `ms`). | `400` |\n| `delay` | `number` | Delay between slide transition (in `ms`). | `0` |\n| `timing` | `string` | Timing function. | `''` |\n\n- **`autoplay` object**\n\n| Prop name | Type | Description | Default value |\n| ------------- | --------- | -------------------------------------------------------------------------------------------------------------- | ------------- |\n| `timeout` | `number` | Timeout (in `ms`) between each slide. | `undefined` |\n| `stopOnHover` | `boolean` | Determines whether the autoplay should stop when users are hovering over the slider (`true`) or not (`false`). | `undefined` |\n\n## Advanced configuration\n\nThe `slider-layout-group` block synchronizes the slides rendered by each `slider-layout` block declared in it.\n\nTherefore, the `slider-layout-group` does not render any specific component on the store UI. It is really a logical block that only expects to receive a `children` block list containing the desired `slider-layout` blocks that should be rendered. For example:\n\n```json\n{\n \"slider-layout-group#test\": {\n \"children\": [\"slider-layout#1\", \"slider-layout#2\", \"slider-layout#3\"]\n }\n}\n```\n\nBelow, you can find a practical example using three `slider-layout` blocks inside of a `slider-layout-group`. Each `slider-layout` received three `rich-text` blocks as `children` to serve as individual slides:\n\n![slider-layout-group demo](https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-slider-layout-3.gif)\n\n> ⚠️ **\\*All `slider-layout` blocks declared in the `slider-layout-group` must have the same configuration, meaning the same props and values**. Due to implementation rules, they can only differ in their `children` block list. Keep in mind that declaring `slider-layout` blocks with different configurations will result in unexpected behavior, leading to errors that are **not** supported by the VTEX Store Framework team.\\*\n\n## Customization\n\nTo apply CSS customizations to this and other blocks, follow the instructions given in the recipe on [Using CSS handles for store customization](https://developers.vtex.com/docs/guides/vtex-io-documentation-using-css-handles-for-store-customization).\n\n| CSS handles |\n| ------------------------- |\n| `paginationDot--isActive` |\n| `paginationDot` |\n| `paginationDotsContainer` |\n| `slide--firstVisible` |\n| `slide--hidden` |\n| `slide--lastVisible` |\n| `slide--visible` |\n| `slideChildrenContainer` |\n| `slide` |\n| `sliderArrows` |\n| `sliderLayoutContainer` |\n| `sliderLeftArrow` |\n| `sliderRightArrow` |\n| `sliderTrackContainer` |\n| `sliderTrack` |\n\n<!-- DOCS-IGNORE:start -->\n\n## Contributors ✨\n\nThanks goes to these wonderful people:\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- prettier-ignore-end -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n<!-- DOCS-IGNORE:end -->\n\n```" } ]
code_slider-layout_e19366a7
[ { "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 slider-layout/react/SliderLayout.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { PropsWithChildren } from 'react'\nimport { defineMessages } from 'react-intl'\nimport { CssHandlesTypes, useCssHandles } from 'vtex.css-handles'\nimport { useListContext } from 'vtex.list-context'\nimport { useResponsiveValue } from 'vtex.responsive-values'\n\nimport Slider, { CSS_HANDLES as SliderCssHandles } from './components/Slider'\nimport {\n SliderContextProvider,\n SliderLayoutProps,\n SliderLayoutSiteEditorProps,\n} from './components/SliderContext'\nimport { CssHandlesProvider } from './modules/cssHandles'\n\nexport const CSS_HANDLES = SliderCssHandles\n\ninterface Props {\n /** Used to override default CSS handles */\n classes?: CssHandlesTypes.CustomClasses<typeof CSS_HANDLES>\n}\n\nfunction SliderLayout({\n totalItems,\n infinite = false,\n showNavigationArrows = 'always',\n showPaginationDots = 'always',\n usePagination = true,\n fullWidth = true,\n arrowSize = 25,\n children,\n centerMode = 'disabled',\n centerModeSlidesGap,\n itemsPerPage = {\n desktop: 5,\n tablet: 3,\n phone: 1,\n },\n classes,\n ...contextProps\n}: PropsWithChildren<SliderLayoutProps & SliderLayoutSiteEditorProps & Props>) {\n const { handles, withModifiers } = useCssHandles(CSS_HANDLES, { classes })\n const list = useListContext()?.list ?? []\n const totalSlides = totalItems ?? React.Children.count(children) + list.length\n const responsiveArrowIconSize = useResponsiveValue(arrowSize)\n const responsiveItemsPerPage = useResponsiveValue(itemsPerPage)\n const responsiveCenterMode = useResponsiveValue(centerMode)\n const slides = React.Children.toArray(children).concat(list)\n // Force fullWidth mode when centerMode is on\n const resolvedFullWidth = fullWidth || responsiveCenterMode !== 'disabled'\n\n return (\n <CssHandlesProvider handles={handles} withModifiers={withModifiers}>\n <SliderContextProvider\n infinite={infinite}\n totalItems={totalSlides}\n itemsPerPage={responsiveItemsPerPage}\n centerMode={responsiveCenterMode}\n centerModeSlidesGap={centerModeSlidesGap}\n {...contextProps}\n >\n <Slider\n centerMode={responsiveCenterMode}\n centerModeSlidesGap={centerModeSlidesGap}\n infinite={infinite}\n showNavigationArrows={showNavigationArrows}\n showPaginationDots={showPaginationDots}\n totalItems={totalSlides}\n usePagination={usePagination}\n fullWidth={resolvedFullWidth}\n arrowSize={responsiveArrowIconSize}\n itemsPerPage={responsiveItemsPerPage}\n >\n {slides}\n </Slider>\n </SliderContextProvider>\n </CssHandlesProvider>\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 sliderFullWidth: {\n id: 'admin/editor.slider-layout.sliderFullWidth',\n defaultMessage: '',\n },\n sliderFullWidthDescription: {\n id: 'admin/editor.slider-layout.sliderFullWidthDescription',\n defaultMessage: '',\n },\n sliderNavigationAndPaginationPropertyMobileOnly: {\n id:\n 'admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly',\n defaultMessage: '',\n },\n sliderNavigationAndPaginationPropertyDesktopOnly: {\n id:\n 'admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly',\n defaultMessage: '',\n },\n sliderNavigationAndPaginationPropertyAlways: {\n id:\n 'admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways',\n defaultMessage: '',\n },\n sliderNavigationAndPaginationPropertyNever: {\n id: 'admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever',\n defaultMessage: '',\n },\n})\n\nSliderLayout.schema = {\n title: messages.sliderTitle.id,\n type: 'object',\n properties: {\n autoplay: {\n type: 'object',\n isLayout: true,\n properties: {\n timeout: {\n type: 'number',\n },\n stopOnHover: {\n type: 'boolean',\n },\n },\n },\n itemsPerPage: {\n type: 'object',\n isLayout: true,\n properties: {\n desktop: {\n default: 5,\n type: 'number',\n },\n tablet: {\n default: 3,\n type: 'number',\n },\n phone: {\n default: 1,\n type: 'number',\n },\n },\n },\n },\n}\n\nexport default SliderLayout\n\n```" } ]
code_slider-layout_7959316c
[ { "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 slider-layout/react/SliderLayoutGroup.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useReducer, useContext } from 'react'\n\ninterface State {\n currentSlide: number\n transform?: null | number\n isHovering: boolean\n}\n\ninterface SlideAction {\n type: 'SLIDE'\n payload: {\n currentSlide: number\n transform?: number\n }\n}\n\ninterface HoverAction {\n type: 'HOVER'\n payload: {\n isHovering: boolean\n }\n}\n\ntype Action = SlideAction | HoverAction\ntype Dispatch = (action: Action) => void\n\nconst SliderGroupStateContext = createContext<State | undefined>(undefined)\n\nconst SliderGroupDispatchContext = createContext<Dispatch | undefined>(\n undefined\n)\n\nconst reducer = (state: State, action: Action): State => {\n switch (action.type) {\n case 'SLIDE': {\n return {\n ...state,\n currentSlide: action.payload.currentSlide,\n transform: action.payload.transform,\n }\n }\n\n default: {\n return state\n }\n }\n}\n\nconst SliderLayoutGroup: React.FC = ({ children }) => {\n const [state, dispatch] = useReducer(reducer, {\n currentSlide: 0,\n transform: null,\n isHovering: false,\n })\n\n return (\n <SliderGroupStateContext.Provider value={state}>\n <SliderGroupDispatchContext.Provider value={dispatch}>\n {children}\n </SliderGroupDispatchContext.Provider>\n </SliderGroupStateContext.Provider>\n )\n}\n\nexport function useSliderGroupState() {\n const context = useContext(SliderGroupStateContext)\n\n return context\n}\n\nexport function useSliderGroupDispatch() {\n const context = useContext(SliderGroupDispatchContext)\n\n return context\n}\n\nexport default SliderLayoutGroup\n\n```" } ]
code_slider-layout_68675d01
[ { "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 slider-layout/react/package.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.slider-layout\",\n \"version\": \"0.24.8\",\n \"description\": \"A React Slider component that works well in SPA and SSR\",\n \"files\": [\n \"react\"\n ],\n \"scripts\": {\n \"pretest\": \"yarn\",\n \"lint\": \"tsc --noEmit && eslint --ext ts,tsx .\",\n \"test\": \"vtex-test-tools test\",\n \"test:watch\": \"vtex-test-tools test --watch\"\n },\n \"dependencies\": {\n \"react\": \"^16.6.3\",\n \"react-intl\": \"^4.5.8\"\n },\n \"devDependencies\": {\n \"@apollo/react-testing\": \"^3.1.4\",\n \"@types/react\": \"^16.8.15\",\n \"@vtex/test-tools\": \"^3.1.0\",\n \"@vtex/tsconfig\": \"^0.5.0\",\n \"prettier\": \"^1.18.2\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@1.0.0/public/@types/vtex.css-handles\",\n \"vtex.device-detector\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.device-detector@0.2.6/public/@types/vtex.device-detector\",\n \"vtex.list-context\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.list-context@0.1.1/public/@types/vtex.list-context\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.4/public/@types/vtex.render-runtime\",\n \"vtex.responsive-values\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.responsive-values@0.4.0/public/@types/vtex.responsive-values\",\n \"vtex.store-icons\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.store-icons@0.18.0/public/@types/vtex.store-icons\"\n }\n}\n\n```" } ]
code_slider-layout_6017e67b
[ { "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 slider-layout/store/contentSchemas.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"definitions\": {\n \"SliderLayout\": {\n \"type\": \"object\",\n \"properties\": {\n \"infinite\": {\n \"default\": true,\n \"title\": \"admin/editor.slider-layout.infinite\",\n \"type\": \"boolean\"\n },\n \"showNavigationArrows\": {\n \"default\": \"always\",\n \"enum\": [\"mobileOnly\", \"desktopOnly\", \"always\", \"never\"],\n \"enumNames\": [\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\"\n ],\n \"title\": \"admin/editor.slider-layout.showNavigation\",\n \"type\": \"string\"\n },\n \"showPaginationDots\": {\n \"default\": \"always\",\n \"enum\": [\"mobileOnly\", \"desktopOnly\", \"always\", \"never\"],\n \"enumNames\": [\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyMobileOnly\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyDesktopOnly\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyAlways\",\n \"admin/editor.slider-layout.sliderNavigationAndPaginationPropertyNever\"\n ],\n \"title\": \"admin/editor.slider-layout.showPaginationDots\",\n \"type\": \"string\"\n },\n \"usePagination\": {\n \"default\": true,\n \"title\": \"admin/editor.slider-layout.usePagination\",\n \"type\": \"boolean\"\n },\n \"fullWidth\": {\n \"default\": true,\n \"title\": \"admin/editor.slider-layout.sliderFullWidth\",\n \"description\": \"admin/editor.slider-layout.sliderFullWidthDescription\",\n \"type\": \"boolean\"\n }\n }\n }\n }\n}\n\n```" } ]
code_slider-layout_2f72f6a2
[ { "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 slider-layout/store/interfaces.json from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"slider-layout\": {\n \"component\": \"SliderLayout\",\n \"composition\": \"children\",\n \"content\": {\n \"$ref\": \"#/definitions/SliderLayout\"\n }\n },\n \"slider-layout-group\": {\n \"component\": \"SliderLayoutGroup\",\n \"composition\": \"children\"\n }\n}\n\n```" } ]
code_slider-layout_c6ca0a95
[ { "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 slider-layout/react/__fixtures__/CssHandlesHelper.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { CssHandlesTypes } from 'vtex.css-handles'\n\nexport const mockedUseContextCssHandlesFn = (\n CSS_HANDLES: CssHandlesTypes.CssHandlesList\n) => ({\n handles: CSS_HANDLES.reduce<Record<string, string>>((acc, handle) => {\n acc[handle] = handle\n\n return acc\n }, {}),\n withModifiers: (handle: string, modifier: string | string[]) =>\n `${handle} ${handle}--${modifier}`,\n})\n\n```" } ]
code_slider-layout_250e38df
[ { "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 slider-layout/react/__fixtures__/SliderStateContext.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nexport const mockInitialSlides = [\n <div key={1}>I am a slide. My index is 1</div>,\n <div key={2}>I am a slide. My index is 2</div>,\n <div key={3}>I am a slide. My index is 3</div>,\n <div key={4}>I am a slide. My index is 4</div>,\n <div key={5}>I am a slide. My index is 5</div>,\n <div key={6}>I am a slide. My index is 6</div>,\n <div key={7}>I am a slide. My index is 7</div>,\n <div key={8}>I am a slide. My index is 8</div>,\n <div key={9}>I am a slide. My index is 9</div>,\n <div key={10}>I am a slide. My index is 10</div>,\n]\n\nexport const mockInitialInfiniteSliderState = {\n slideWidth: 5,\n slidesPerPage: 5,\n currentSlide: 0,\n transform: -25,\n transformMap: {\n 0: -25,\n 1: -30,\n 2: -35,\n 3: -40,\n 4: -45,\n 5: -50,\n 6: -55,\n 7: -60,\n 8: -65,\n 9: -70,\n 10: -75,\n 11: -80,\n 12: -85,\n 13: -90,\n 14: -95,\n '-5': 0,\n '-4': -5,\n '-3': -10,\n '-2': -15,\n '-1': -20,\n },\n navigationStep: 2,\n slideTransition: {\n speed: 400,\n delay: 0,\n timing: '',\n },\n itemsPerPage: 5,\n label: 'slider',\n totalItems: 10,\n isPageNavigationStep: true,\n isOnTouchMove: false,\n useSlidingTransitionEffect: false,\n}\n\nexport const mockInitialNonInfiniteSliderState = {\n slideWidth: 10,\n slidesPerPage: 5,\n currentSlide: 0,\n transform: 0,\n transformMap: {\n '0': 0,\n '1': -10,\n '2': -20,\n '3': -30,\n '4': -40,\n '5': -50,\n '6': -60,\n '7': -70,\n '8': -80,\n '9': -90,\n },\n navigationStep: 2,\n slideTransition: {\n speed: 400,\n delay: 0,\n timing: '',\n },\n itemsPerPage: 5,\n label: 'slider',\n totalItems: 10,\n isPageNavigationStep: true,\n isOnTouchMove: false,\n useSlidingTransitionEffect: false,\n}\n\n```" } ]
code_slider-layout_3e7c4fe0
[ { "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 slider-layout/react/typings/vtex.list-context.d.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.list-context' {\n export const useListContext: () => undefined | { list: unknown[] }\n}\n\n```" } ]
code_slider-layout_04750776
[ { "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 slider-layout/react/typings/vtex.store-icons.d.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-icons' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export const IconCaret: any\n}\n\n```" } ]
code_slider-layout_bb903cd4
[ { "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 slider-layout/react/typings/css.d.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: Record<string, string>\n export default css\n}\n\n```" } ]
code_slider-layout_8e29d521
[ { "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 slider-layout/react/components/Slider.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useRef, Fragment, ReactNode } from 'react'\nimport { useDevice } from 'vtex.device-detector'\n\nimport { useScreenResize } from '../hooks/useScreenResize'\nimport { useTouchHandlers } from '../hooks/useTouchHandlers'\nimport { useAutoplay } from '../hooks/useAutoplay'\nimport {\n SliderLayoutProps,\n SliderLayoutSiteEditorProps,\n useSliderState,\n} from './SliderContext'\nimport SliderTrack, {\n CSS_HANDLES as SliderTrackCssHandles,\n} from './SliderTrack'\nimport Arrow, { CSS_HANDLES as ArrowCssHandles } from './Arrow'\nimport PaginationDots, {\n CSS_HANDLES as PaginationDotsCssHandles,\n} from './PaginationDots'\nimport { useContextCssHandles } from '../modules/cssHandles'\n\ninterface Props extends SliderLayoutSiteEditorProps {\n arrowSize: number\n totalItems: number\n itemsPerPage: number\n centerMode: SliderLayoutProps['centerMode']\n centerModeSlidesGap?: SliderLayoutProps['centerModeSlidesGap']\n // This type comes from React itself. It is the return type for\n // React.Children.toArray().\n children?: Array<Exclude<ReactNode, boolean | null | undefined>>\n}\n\nexport const CSS_HANDLES = [\n 'sliderLayoutContainer',\n 'sliderTrackContainer',\n ...SliderTrackCssHandles,\n ...ArrowCssHandles,\n ...PaginationDotsCssHandles,\n] as const\n\nconst Slider: FC<Props> = ({\n children,\n totalItems,\n infinite = false,\n showNavigationArrows,\n showPaginationDots,\n usePagination: shouldUsePagination = true,\n arrowSize,\n fullWidth,\n itemsPerPage,\n centerMode,\n centerModeSlidesGap,\n}) => {\n const { handles } = useContextCssHandles()\n const { isMobile } = useDevice()\n const { label = 'slider', slidesPerPage } = useSliderState()\n const containerRef = useRef<HTMLDivElement>(null)\n const { onTouchEnd, onTouchStart, onTouchMove } = useTouchHandlers({\n infinite,\n centerMode,\n })\n\n useAutoplay(infinite, containerRef)\n useScreenResize(infinite, itemsPerPage)\n\n const shouldBeStaticList = slidesPerPage >= totalItems\n\n const controls = `${label\n .toLowerCase()\n .trim()\n .replace(/ /g, '-')}-items-${Math.random()\n .toString(36)\n .substring(2, 9)}`\n\n const shouldShowArrows = Boolean(\n (showNavigationArrows === 'always' ||\n (showNavigationArrows === 'mobileOnly' && isMobile) ||\n (showNavigationArrows === 'desktopOnly' && !isMobile)) &&\n !shouldBeStaticList\n )\n\n const shouldShowPaginationDots = Boolean(\n (showPaginationDots === 'always' ||\n (showPaginationDots === 'mobileOnly' && isMobile) ||\n (showPaginationDots === 'desktopOnly' && !isMobile)) &&\n !shouldBeStaticList\n )\n\n const touchStartHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchStart(e) : null\n\n const touchEndHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchEnd(e) : null\n\n const touchMoveHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchMove(e) : null\n\n return (\n <section\n onTouchStart={touchStartHandler}\n onTouchEnd={touchEndHandler}\n onTouchMove={touchMoveHandler}\n aria-label={label}\n id={controls}\n style={{\n WebkitOverflowScrolling: !shouldUsePagination ? 'touch' : undefined,\n paddingLeft: fullWidth ? undefined : arrowSize * 2,\n paddingRight: fullWidth ? undefined : arrowSize * 2,\n touchAction: 'pan-y',\n }}\n className={`w-100 flex items-center relative ${handles.sliderLayoutContainer}`}\n >\n <div\n className={`w-100 ${handles.sliderTrackContainer} ${\n shouldUsePagination ? 'overflow-hidden' : 'overflow-x-scroll'\n }`}\n ref={containerRef}\n >\n <SliderTrack\n centerMode={centerMode}\n centerModeSlidesGap={centerModeSlidesGap}\n infinite={infinite}\n totalItems={totalItems}\n usePagination={shouldUsePagination}\n >\n {children}\n </SliderTrack>\n </div>\n {shouldShowArrows && shouldUsePagination && (\n <Fragment>\n <Arrow\n totalItems={totalItems}\n orientation=\"left\"\n controls={controls}\n infinite={infinite}\n arrowSize={arrowSize}\n />\n <Arrow\n totalItems={totalItems}\n orientation=\"right\"\n controls={controls}\n infinite={infinite}\n arrowSize={arrowSize}\n />\n </Fragment>\n )}\n {shouldShowPaginationDots && shouldUsePagination && (\n <PaginationDots\n totalItems={totalItems}\n controls={controls}\n infinite={infinite}\n />\n )}\n </section>\n )\n}\n\nexport default Slider\n\n```" } ]
code_slider-layout_ecb69ca7
[ { "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 slider-layout/react/components/Arrow.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { memo, FC, ReactNode } from 'react'\nimport { IconCaret } from 'vtex.store-icons'\n\nimport { useSliderState } from './SliderContext'\nimport useKeyboardArrows from '../hooks/useKeyboardArrows'\nimport { useSliderControls } from '../hooks/useSliderControls'\nimport { useContextCssHandles } from '../modules/cssHandles'\n\ninterface Props {\n custom?: ReactNode\n orientation: 'left' | 'right'\n controls: string\n totalItems: number\n infinite: boolean\n arrowSize: number\n}\n\nexport const CSS_HANDLES = [\n 'sliderLeftArrow',\n 'sliderRightArrow',\n 'sliderArrows',\n] as const\n\nconst Arrow: FC<Props> = ({\n custom,\n orientation,\n controls,\n totalItems,\n infinite,\n arrowSize,\n}) => {\n const { currentSlide, slidesPerPage } = useSliderState()\n const { goBack, goForward } = useSliderControls(infinite)\n\n const { handles } = useContextCssHandles()\n\n const isLeftEndReached = currentSlide === 0\n const isRightEndReached = !(currentSlide + 1 + slidesPerPage <= totalItems)\n const disabled =\n !infinite &&\n ((orientation === 'left' && isLeftEndReached) ||\n (orientation === 'right' && isRightEndReached))\n\n useKeyboardArrows(goBack, goForward)\n\n function handleArrowClick(\n event: React.MouseEvent<HTMLButtonElement, MouseEvent>\n ) {\n if (event) {\n event.stopPropagation()\n event.preventDefault()\n }\n\n if (orientation === 'left') {\n goBack()\n }\n\n if (orientation === 'right') {\n goForward()\n }\n }\n\n return (\n <button\n className={`${\n orientation === 'left'\n ? `${handles.sliderLeftArrow} left-0`\n : `${handles.sliderRightArrow} right-0`\n } ${\n handles.sliderArrows\n } absolute transparent ma2 flex items-center justify-center bn outline-0 pointer`}\n style={{ background: 'transparent' }}\n onClick={handleArrowClick}\n aria-controls={controls}\n aria-label={`${orientation === 'left' ? 'Previous' : 'Next'} Slide`}\n disabled={disabled}\n >\n {custom ?? <IconCaret size={arrowSize} orientation={orientation} thin />}\n </button>\n )\n}\n\nexport default memo(Arrow)\n\n```" } ]
code_slider-layout_10ac34ca
[ { "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 slider-layout/react/components/PaginationDots.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { memo, FC } from 'react'\n\nimport { useContextCssHandles } from '../modules/cssHandles'\nimport { useSliderState } from './SliderContext'\nimport { useSliderControls } from '../hooks/useSliderControls'\n\nconst DOTS_DEFAULT_SIZE = 0.625\n\ninterface Props {\n controls: string\n totalItems: number\n infinite: boolean\n}\n\nexport const CSS_HANDLES = ['paginationDotsContainer', 'paginationDot'] as const\n\nconst getSelectedDot = (\n passVisibleSlides: boolean,\n currentSlide: number,\n slidesToShow: number\n): number => {\n const realCurrentSlide = passVisibleSlides\n ? currentSlide + (slidesToShow - 1)\n : currentSlide\n\n return passVisibleSlides\n ? Math.floor(realCurrentSlide / slidesToShow)\n : realCurrentSlide\n}\n\nconst getSlideIndices = (\n slidesToShow: number,\n passVisibleSlides: boolean,\n totalItems: number\n): number[] =>\n slidesToShow\n ? [\n ...Array(\n passVisibleSlides ? Math.ceil(totalItems / slidesToShow) : totalItems\n ).keys(),\n ]\n : []\n\nconst PaginationDots: FC<Props> = ({ controls, totalItems, infinite }) => {\n const { slidesPerPage, currentSlide, navigationStep } = useSliderState()\n const { goBack, goForward } = useSliderControls(infinite)\n const { handles, withModifiers } = useContextCssHandles()\n const passVisibleSlides = navigationStep === slidesPerPage\n\n const slideIndexes = getSlideIndices(\n slidesPerPage,\n passVisibleSlides,\n totalItems\n )\n\n const handleDotClick = (\n event: React.KeyboardEvent | React.MouseEvent,\n index: number\n ) => {\n if (event) {\n event.stopPropagation()\n if ('key' in event && event.key !== 'Tab') {\n event.preventDefault()\n }\n }\n\n // Considering that each pagination dot represents a page, pageDelta\n // represents how many pages did the user \"skip\" by clicking in the dot.\n const pageDelta =\n index - getSelectedDot(passVisibleSlides, currentSlide, slidesPerPage)\n\n const slidesToPass = Math.abs(pageDelta) * navigationStep\n\n pageDelta > 0 ? goForward(slidesToPass) : goBack(slidesToPass)\n }\n\n return (\n <div\n className={`${handles.paginationDotsContainer} flex absolute justify-center pa0 ma0 bottom-0 left-0 right-0`}\n role=\"group\"\n aria-label=\"Slider pagination dots\"\n >\n {slideIndexes.map(index => {\n const isActive =\n index ===\n getSelectedDot(passVisibleSlides, currentSlide, slidesPerPage)\n\n return (\n <div\n className={`${withModifiers(\n 'paginationDot',\n isActive ? 'isActive' : ''\n )} ${\n isActive ? 'bg-emphasis' : 'bg-muted-3'\n } grow dib br-100 pa2 mr2 ml2 bw0 pointer outline-0`}\n style={{\n height: `${DOTS_DEFAULT_SIZE}rem`,\n width: `${DOTS_DEFAULT_SIZE}rem`,\n }}\n key={index}\n tabIndex={isActive ? 0 : -1}\n onKeyDown={event => handleDotClick(event, index)}\n onClick={event => handleDotClick(event, index)}\n role=\"button\"\n aria-controls={controls}\n aria-label={`Dot ${index + 1} of ${slideIndexes.length}`}\n data-testid=\"paginationDot\"\n />\n )\n })}\n </div>\n )\n}\n\nexport default memo(PaginationDots)\n\n```" } ]
code_slider-layout_e35b8ccf
[ { "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 slider-layout/react/components/SliderTrack.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { cloneElement, FC, ReactElement, ReactNode } from 'react'\nimport { useIntl } from 'react-intl'\n\nimport {\n useSliderState,\n useSliderDispatch,\n SliderLayoutProps,\n} from './SliderContext'\nimport { useSliderGroupDispatch } from '../SliderLayoutGroup'\nimport { useSliderVisibility } from '../hooks/useSliderVisibility'\nimport { useContextCssHandles } from '../modules/cssHandles'\n\nexport const CSS_HANDLES = [\n 'sliderTrack',\n 'slide',\n 'slideChildrenContainer',\n] as const\n\ninterface Props {\n totalItems: number\n infinite: boolean\n usePagination: boolean\n centerMode: SliderLayoutProps['centerMode']\n centerModeSlidesGap?: SliderLayoutProps['centerModeSlidesGap']\n // This type comes from React itself. It is the return type for\n // React.Children.toArray().\n children?: Array<Exclude<ReactNode, boolean | null | undefined>>\n}\n\ninterface ResolveAriaAttributesProps {\n visible: boolean\n index: number\n totalItems: number\n intl: any\n}\n\nconst resolveAriaAttributes = ({\n visible,\n index,\n totalItems,\n intl,\n}: ResolveAriaAttributesProps) => {\n if (index < 0 || index >= totalItems) {\n return {\n 'aria-hidden': !visible,\n role: 'none presentation',\n }\n }\n\n return {\n 'aria-hidden': !visible,\n role: 'group',\n 'aria-roledescription': 'slide',\n 'aria-label': `${intl.formatMessage(\n { id: 'store/slider-layout.sliderTrack.aria-label' },\n { slide: index + 1, total: totalItems }\n )}`,\n }\n}\n\nconst getFirstOrLastVisible = (slidesPerPage: number, index: number) => {\n // every multiple of the number of slidesPerPage is a first (e.g. 0,3,6 if slidesPerPage is 3)\n if (index % slidesPerPage === 0) {\n return 'firstVisible'\n }\n\n // every slide before the multiple of the number of slidesPerPage is a last (e.g. 2,5,8 if slidesPerPage is 3)\n if ((index + 1) % slidesPerPage === 0) {\n return 'lastVisible'\n }\n\n return ''\n}\n\nconst removeAnalyticsProperties = (children: ReactElement[]) => {\n return React.Children.toArray(\n React.Children.map(children, child =>\n typeof child === 'string' || typeof child === 'number'\n ? child\n : cloneElement(child, {\n ...child.props,\n // Tells the component it is being duplicated. Each component should handle it\n __isDuplicated: true,\n })\n )\n )\n}\n\nconst SliderTrack: FC<Props> = ({\n infinite,\n usePagination,\n centerMode,\n centerModeSlidesGap,\n totalItems,\n children,\n}) => {\n const {\n slideWidth,\n slidesPerPage,\n currentSlide,\n isOnTouchMove,\n useSlidingTransitionEffect,\n slideTransition: { speed, timing, delay },\n transformMap,\n transform,\n } = useSliderState()\n\n const dispatch = useSliderDispatch()\n const intl = useIntl()\n const groupDispatch = useSliderGroupDispatch()\n const { handles, withModifiers } = useContextCssHandles()\n\n const { shouldRenderItem, isItemVisible } = useSliderVisibility({\n currentSlide,\n slidesPerPage,\n totalItems,\n centerMode,\n })\n\n const postRenderedSlides =\n infinite && children\n ? removeAnalyticsProperties(children as ReactElement[]).slice(\n 0,\n slidesPerPage\n )\n : []\n\n const preRenderedSlides =\n infinite && children\n ? removeAnalyticsProperties(children as ReactElement[]).slice(\n children.length - slidesPerPage\n )\n : []\n\n const slides = preRenderedSlides.concat(children ?? [], postRenderedSlides)\n\n const trackWidth =\n slidesPerPage <= totalItems\n ? `${(slides.length * 100) / slidesPerPage}%`\n : '100%'\n\n return (\n <div\n data-testid=\"slider-track\"\n className={`${handles.sliderTrack} flex ${\n centerMode !== 'disabled' ? '' : 'justify-around'\n } relative pa0 ma0`}\n style={{\n transition:\n isOnTouchMove || !useSlidingTransitionEffect\n ? undefined\n : `transform ${speed}ms ${timing} ${delay}ms`,\n transform: `translate3d(${\n isOnTouchMove ? transform : transformMap[currentSlide]\n }%, 0, 0)`,\n width: trackWidth,\n }}\n onTransitionEnd={() => {\n dispatch({ type: 'DISABLE_TRANSITION' })\n\n if (currentSlide >= totalItems) {\n dispatch({\n type: 'ADJUST_CURRENT_SLIDE',\n payload: {\n currentSlide: 0,\n transform: transformMap[0],\n },\n })\n groupDispatch?.({\n type: 'SLIDE',\n payload: {\n currentSlide: 0,\n transform: transformMap[0],\n },\n })\n }\n\n if (currentSlide < 0) {\n dispatch({\n type: 'ADJUST_CURRENT_SLIDE',\n payload: {\n currentSlide: currentSlide + totalItems,\n transform: transformMap[currentSlide + totalItems],\n },\n })\n groupDispatch?.({\n type: 'SLIDE',\n payload: {\n currentSlide: currentSlide + totalItems,\n transform: transformMap[currentSlide + totalItems],\n },\n })\n }\n }}\n aria-atomic=\"false\"\n aria-live=\"polite\"\n >\n {slides.map((child, index) => {\n // This is to take into account that there is a clone of the last page\n // in the left, to enable the infinite loop effect in case infinite\n // is set to true.\n const adjustedIndex = index - (infinite ? slidesPerPage : 0)\n const slideContainerStyles = {\n width: `${slideWidth}%`,\n marginLeft:\n centerMode !== 'disabled' && !centerModeSlidesGap\n ? `${slideWidth / (8 * slidesPerPage)}%`\n : undefined,\n marginRight:\n centerMode !== 'disabled' && !centerModeSlidesGap\n ? `${slideWidth / (8 * slidesPerPage)}%`\n : undefined,\n paddingLeft:\n centerMode !== 'disabled' && centerModeSlidesGap\n ? centerModeSlidesGap / 2\n : undefined,\n paddingRight:\n centerMode !== 'disabled' && centerModeSlidesGap\n ? centerModeSlidesGap / 2\n : undefined,\n }\n\n return (\n <div\n key={adjustedIndex}\n {...resolveAriaAttributes({\n visible: isItemVisible(adjustedIndex),\n index: adjustedIndex,\n totalItems,\n intl,\n })}\n className={`${withModifiers('slide', [\n getFirstOrLastVisible(slidesPerPage, adjustedIndex),\n isItemVisible(adjustedIndex) ? 'visible' : 'hidden',\n ])} flex relative`}\n data-index={\n adjustedIndex >= 0 && adjustedIndex < totalItems\n ? adjustedIndex + 1\n : undefined\n }\n style={slideContainerStyles}\n >\n <div\n className={`${handles.slideChildrenContainer} flex justify-center items-center w-100`}\n >\n {!usePagination || shouldRenderItem(adjustedIndex) ? child : null}\n </div>\n </div>\n )\n })}\n </div>\n )\n}\n\nexport default SliderTrack\n\n```" } ]
code_slider-layout_e29a3c64
[ { "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 slider-layout/react/components/SliderContext.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n createContext,\n useReducer,\n useContext,\n FC,\n useMemo,\n useState,\n} from 'react'\nimport { ResponsiveValuesTypes } from 'vtex.responsive-values'\n\nimport { useSliderGroupState } from '../SliderLayoutGroup'\n\ninterface AdjustOnResizeAction {\n type: 'ADJUST_ON_RESIZE'\n payload: {\n shouldCorrectItemPosition: boolean\n slidesPerPage: number\n navigationStep: number\n }\n}\n\ninterface SlideAction {\n type: 'SLIDE'\n payload: {\n transform?: number\n currentSlide: number\n }\n}\n\ninterface TouchAction {\n type: 'TOUCH'\n payload: {\n transform?: number\n isOnTouchMove: boolean\n }\n}\n\ninterface DisableTransitionAction {\n type: 'DISABLE_TRANSITION'\n}\n\ninterface AdjustCurrentSlideAction {\n type: 'ADJUST_CURRENT_SLIDE'\n payload: {\n currentSlide: number\n transform?: number\n }\n}\n\ninterface SyncSliderGroupAction {\n type: 'SYNC_SLIDER_GROUP'\n payload: {\n currentSlide: number\n transform?: number\n }\n}\n\ninterface AdjustContextValuesAction {\n type: 'ADJUST_CONTEXT_VALUES'\n payload: {\n transformMap: State['transformMap']\n slideWidth: State['slideWidth']\n slidesPerPage: State['slidesPerPage']\n transform: State['transform']\n navigationStep: State['navigationStep']\n totalItems: State['totalItems']\n }\n}\n\nexport interface SliderLayoutSiteEditorProps {\n infinite?: boolean\n showNavigationArrows?: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n showPaginationDots?: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n usePagination?: boolean\n fullWidth?: boolean\n arrowSize?: ResponsiveValuesTypes.ResponsiveValue<number>\n}\n\nexport interface SliderLayoutProps {\n totalItems?: number\n label?: string\n slideTransition?: {\n /** Transition speed in ms */\n speed: number\n /** Transition delay in ms */\n delay: number\n timing: string\n }\n autoplay?: {\n /** Timeout duration in ms */\n timeout: number\n stopOnHover?: boolean\n }\n navigationStep?: number | 'page'\n itemsPerPage?: ResponsiveValuesTypes.ResponsiveValue<number>\n centerMode?: ResponsiveValuesTypes.ResponsiveValue<\n 'center' | 'to-the-left' | 'disabled'\n >\n centerModeSlidesGap?: number\n}\n\ninterface State extends Partial<SliderLayoutProps> {\n /** Width of each slide */\n slideWidth: number\n /** Number of slides to show per page */\n slidesPerPage: number\n /** Index of the leftmost slide of the current page */\n currentSlide: number\n /** Current transform value */\n transform: number\n /** Total number of slides */\n totalItems: number\n /** Number of slides to slide in navigation */\n navigationStep: number\n /** Whether or not navigationStep prop is set to 'page' */\n isPageNavigationStep: boolean\n /** Whether or not a touchmove event is happening */\n isOnTouchMove: boolean\n useSlidingTransitionEffect: boolean\n transformMap: Record<number, number>\n slideTransition: Exclude<SliderLayoutProps['slideTransition'], undefined>\n}\n\ninterface SliderContextProps extends SliderLayoutProps {\n totalItems: number\n itemsPerPage: number\n infinite: SliderLayoutSiteEditorProps['infinite']\n}\n\ntype Action =\n | AdjustOnResizeAction\n | SlideAction\n | TouchAction\n | DisableTransitionAction\n | AdjustCurrentSlideAction\n | AdjustContextValuesAction\n | SyncSliderGroupAction\ntype Dispatch = (action: Action) => void\n\nconst SliderStateContext = createContext<State | undefined>(undefined)\nconst SliderDispatchContext = createContext<Dispatch | undefined>(undefined)\n\nfunction sliderContextReducer(state: State, action: Action): State {\n switch (action.type) {\n case 'ADJUST_ON_RESIZE':\n return {\n ...state,\n slidesPerPage: action.payload.slidesPerPage,\n navigationStep: action.payload.navigationStep,\n transform: action.payload.shouldCorrectItemPosition\n ? state.transformMap[state.currentSlide]\n : state.transform,\n }\n\n case 'SLIDE':\n return {\n ...state,\n transform: action.payload.transform ?? state.transform,\n currentSlide: action.payload.currentSlide,\n useSlidingTransitionEffect: true,\n }\n\n case 'TOUCH':\n return {\n ...state,\n transform: action.payload.transform ?? state.transform,\n isOnTouchMove: action.payload.isOnTouchMove,\n }\n\n case 'DISABLE_TRANSITION':\n return {\n ...state,\n useSlidingTransitionEffect: false,\n }\n\n case 'ADJUST_CURRENT_SLIDE':\n return {\n ...state,\n currentSlide: action.payload.currentSlide,\n transform: action.payload.transform ?? state.transform,\n }\n\n case 'SYNC_SLIDER_GROUP':\n return {\n ...state,\n currentSlide: action.payload.currentSlide,\n transform: action.payload.transform ?? state.transform,\n useSlidingTransitionEffect: true,\n }\n\n case 'ADJUST_CONTEXT_VALUES':\n return {\n ...state,\n transformMap: action.payload.transformMap,\n slideWidth: action.payload.slideWidth,\n slidesPerPage: action.payload.slidesPerPage,\n transform: action.payload.transform,\n navigationStep: action.payload.navigationStep,\n totalItems: action.payload.totalItems,\n }\n\n default:\n return state\n }\n}\n\nconst SliderContextProvider: FC<SliderContextProps> = ({\n autoplay,\n children,\n totalItems,\n label = 'slider',\n navigationStep = 'page',\n infinite = false,\n itemsPerPage,\n centerMode,\n slideTransition = {\n speed: 400,\n delay: 0,\n timing: '',\n },\n centerModeSlidesGap,\n}) => {\n const sliderGroupState = useSliderGroupState()\n\n // This enables us to support dynamic slider-layouts\n const [prevProps, setPrevProps] = useState<{\n itemsPerPage: SliderContextProps['itemsPerPage'] | null\n totalItems: SliderContextProps['totalItems'] | null\n }>({\n itemsPerPage: null,\n totalItems: null,\n })\n\n const resolvedNavigationStep: number =\n navigationStep === 'page' ? itemsPerPage : navigationStep\n\n const resolvedSlidesPerPage: number =\n totalItems <= itemsPerPage ? totalItems : itemsPerPage\n\n const hiddenSlides = infinite ? resolvedSlidesPerPage * 2 : 0\n\n const newTotalItems = hiddenSlides + totalItems\n\n const slideWidth = useMemo(() => {\n const baseSlideWidth = 100 / newTotalItems\n\n let resultingSlideWidth = baseSlideWidth\n\n if (centerMode !== 'disabled') {\n resultingSlideWidth =\n (resolvedSlidesPerPage / (resolvedSlidesPerPage + 1)) * baseSlideWidth\n\n if (centerMode === 'to-the-left' && centerModeSlidesGap) {\n resultingSlideWidth =\n (baseSlideWidth * resolvedSlidesPerPage) /\n (resolvedSlidesPerPage + 1 / 2)\n }\n }\n\n return resultingSlideWidth\n }, [newTotalItems, centerMode, centerModeSlidesGap, resolvedSlidesPerPage])\n\n const transformMap = useMemo(() => {\n const currentMap: Record<number, number> = {}\n\n for (let idx = 0; idx < newTotalItems; ++idx) {\n const currIdx = infinite ? idx - resolvedSlidesPerPage : idx\n let transformValue = -(slideWidth * idx)\n\n if (centerMode !== 'disabled') {\n // This represents the new value for each transformValue taking into\n // account the changes made to slideWidth's value due to the fact that\n // centerMode is enabled.\n const adjustedTransformValue = -(\n (1 + 1 / (4 * resolvedSlidesPerPage)) *\n slideWidth *\n idx\n )\n\n transformValue = adjustedTransformValue\n\n if (centerMode === 'center') {\n // This is a correction factor to center the slides when centerMode\n // is enabled and set to 'center'.\n const transformCenterCorrection =\n centerMode === 'center' ? (slideWidth * 3) / 8 : 0\n\n transformValue += transformCenterCorrection\n }\n\n if (centerModeSlidesGap) {\n transformValue =\n centerMode === 'center'\n ? -(slideWidth * (idx - 1 / 2))\n : -(slideWidth * idx)\n }\n }\n\n currentMap[currIdx] = transformValue\n }\n\n return currentMap\n }, [\n slideWidth,\n newTotalItems,\n resolvedSlidesPerPage,\n infinite,\n centerMode,\n centerModeSlidesGap,\n ])\n\n const initialSlide = useMemo(() => sliderGroupState?.currentSlide ?? 0, [\n sliderGroupState,\n ])\n\n const initialTransform = useMemo(\n () => sliderGroupState?.transform ?? transformMap[initialSlide],\n [transformMap, initialSlide, sliderGroupState]\n )\n\n const [state, dispatch] = useReducer(sliderContextReducer, {\n slideWidth,\n slidesPerPage: resolvedSlidesPerPage,\n currentSlide: initialSlide,\n transform: initialTransform,\n transformMap,\n navigationStep: resolvedNavigationStep,\n slideTransition,\n itemsPerPage,\n label,\n autoplay,\n totalItems,\n isPageNavigationStep: navigationStep === 'page',\n isOnTouchMove: false,\n useSlidingTransitionEffect: false,\n })\n\n if (\n itemsPerPage !== prevProps.itemsPerPage ||\n totalItems !== prevProps.totalItems\n ) {\n dispatch({\n type: 'ADJUST_CONTEXT_VALUES',\n payload: {\n transformMap,\n slideWidth,\n slidesPerPage: resolvedSlidesPerPage,\n transform: transformMap[state.currentSlide],\n navigationStep: resolvedNavigationStep,\n totalItems,\n },\n })\n setPrevProps({ itemsPerPage, totalItems })\n }\n\n if (\n sliderGroupState &&\n sliderGroupState.currentSlide !== state.currentSlide\n ) {\n const newCurrentSlide = sliderGroupState?.currentSlide ?? state.currentSlide\n const newTransformValue =\n sliderGroupState?.transform ?? transformMap[newCurrentSlide]\n\n dispatch({\n type: 'SYNC_SLIDER_GROUP',\n payload: {\n currentSlide: newCurrentSlide,\n transform: newTransformValue,\n },\n })\n }\n\n return (\n <SliderStateContext.Provider value={state}>\n <SliderDispatchContext.Provider value={dispatch}>\n {children}\n </SliderDispatchContext.Provider>\n </SliderStateContext.Provider>\n )\n}\n\nfunction useSliderState() {\n const context = useContext(SliderStateContext)\n\n if (context === undefined) {\n throw new Error(\n 'useSliderState must be used within a SliderContextProvider'\n )\n }\n\n return context\n}\n\nfunction useSliderDispatch() {\n const context = useContext(SliderDispatchContext)\n\n if (context === undefined) {\n throw new Error(\n 'useSliderDispatch must be used within a SliderContextProvider'\n )\n }\n\n return context\n}\n\nexport { SliderContextProvider, useSliderDispatch, useSliderState }\n\n```" } ]
code_slider-layout_e925b0e1
[ { "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 slider-layout/react/__tests__/PaginationDots.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render, fireEvent } from '@vtex/test-tools/react'\n\nimport PaginationDots, { CSS_HANDLES } from '../components/PaginationDots'\nimport { useContextCssHandles } from '../modules/cssHandles'\nimport { mockedUseContextCssHandlesFn } from '../__fixtures__/CssHandlesHelper'\n\nconst mockGoForward = jest.fn()\nconst mockGoBack = jest.fn()\n\njest.mock('../components/SliderContext', () => {\n return {\n useSliderState: () => ({\n slideWidth: 20,\n slidesPerPage: 5,\n currentSlide: 0,\n transform: 0,\n navigationStep: 5,\n slideTransition: {\n speed: 400,\n delay: 0,\n timing: '',\n },\n itemsPerPage: {\n desktop: 5,\n tablet: 5,\n phone: 5,\n },\n label: 'slider',\n totalItems: 20,\n isPageNavigationStep: true,\n isOnTouchMove: false,\n }),\n }\n})\n\njest.mock('../hooks/useSliderControls', () => {\n return {\n useSliderControls: () => ({\n goForward: mockGoForward,\n goBack: mockGoBack,\n }),\n }\n})\n\njest.mock('../modules/cssHandles', () => ({\n useContextCssHandles: jest.fn(),\n}))\n\nconst mockedUseContextCssHandles = useContextCssHandles as jest.Mock<\n ReturnType<typeof useContextCssHandles>\n>\n\nmockedUseContextCssHandles.mockImplementation(() =>\n mockedUseContextCssHandlesFn(CSS_HANDLES)\n)\n\ndescribe('Basic rendering', () => {\n it('should render the correct number of pagination dots based on the number of slider pages', () => {\n const { queryAllByTestId } = render(\n <PaginationDots\n controls=\"pagination-dots-test\"\n infinite\n totalItems={20}\n />\n )\n\n const numberOfPagesBasedOnTotalItems = 4\n const testId = 'paginationDot'\n\n expect(queryAllByTestId(testId)).toHaveLength(\n numberOfPagesBasedOnTotalItems\n )\n })\n})\n\ndescribe('Accessibility', () => {\n it('should have correct aria role and label in its container', () => {\n const { queryByRole, queryByLabelText } = render(\n <PaginationDots\n controls=\"pagination-dots-test\"\n infinite\n totalItems={20}\n />\n )\n\n const expectedContainerRole = 'group'\n const expectedContainerAriaLabel = 'Slider pagination dots'\n\n expect(queryByRole(expectedContainerRole)).toBeTruthy()\n expect(queryByLabelText(expectedContainerAriaLabel)).toBeTruthy()\n })\n\n it('should have correct aria attributes in each dot', () => {\n const { queryAllByRole, queryByLabelText } = render(\n <PaginationDots\n controls=\"pagination-dots-test\"\n infinite\n totalItems={20}\n />\n )\n\n const expectedDotsRole = 'button'\n const expectedNumberOfRenderedDots = 4\n\n expect(queryByLabelText('Dot 1 of 4')).toBeTruthy()\n expect(queryByLabelText('Dot 2 of 4')).toBeTruthy()\n expect(queryByLabelText('Dot 3 of 4')).toBeTruthy()\n expect(queryByLabelText('Dot 4 of 4')).toBeTruthy()\n\n expect(queryAllByRole(expectedDotsRole)).toHaveLength(\n expectedNumberOfRenderedDots\n )\n })\n})\n\ndescribe('Behavior upon interaction', () => {\n it('should call goForward() and goBack() methods with correct arguments as the user clicks in a dot', () => {\n const { queryAllByTestId } = render(\n <PaginationDots\n controls=\"pagination-dots-test\"\n infinite\n totalItems={20}\n />\n )\n\n const renderedDots = queryAllByTestId('paginationDot')\n\n expect(renderedDots).toHaveLength(4)\n\n // Since the initial active dot is always index 0,\n // this should simulate a user clicking in the third\n // pagination dot.\n fireEvent.click(renderedDots[2])\n\n // Notice that this call does NOT update the sliderState,\n // so in the next assertion, the PaginationDots component\n // will behave as if it were still with the first dot active.\n expect(mockGoForward).toBeCalledWith(10)\n\n // Simulate the user clicking in the first pagination dot.\n fireEvent.click(renderedDots[0])\n expect(mockGoBack).toBeCalledWith(0)\n })\n})\n\n```" } ]
code_slider-layout_9b5f8cd9
[ { "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 slider-layout/react/__tests__/hooks.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { hooks } from '@vtex/test-tools/react'\n\nimport { useSliderControls } from '../hooks/useSliderControls'\nimport {\n mockInitialInfiniteSliderState,\n mockInitialNonInfiniteSliderState,\n} from '../__fixtures__/SliderStateContext'\n\nconst { renderHook, act } = hooks\n\nconst mockDispatch = jest.fn()\nlet mockSliderInitialState: any\n\njest.mock('../components/SliderContext', () => ({\n useSliderState: () => mockSliderInitialState,\n useSliderDispatch: () => mockDispatch,\n}))\n\nbeforeEach(() => {\n mockDispatch.mockClear()\n})\n\ndescribe('useAutoplay', () => {\n it.todo('should call goForward() after the correct interval')\n it.todo('should stop if user is hovering the slider')\n it.todo(\n 'should trigger autoplay again after user moves the mouse away from the slider'\n )\n})\n\ndescribe('useHovering', () => {\n it.todo('should return true if user is hovering the slider')\n it.todo('should return false if user is not hovering the slider')\n})\n\ndescribe('useKeyboardArrows', () => {\n it.todo('should call onRight() function when user presses ArrowRight key')\n it.todo('should call onLeft() function when user presses ArrowLeft key')\n})\n\ndescribe('useScreenResize', () => {\n it.todo('should perform an ADJUST_ON_RESIZE dispatch call upon screen resize')\n it.todo(\n 'should calculate the correct number of slides per page after a change in device'\n )\n it.todo(\n 'should calculate the correct navigation step after a change in device'\n )\n it.todo(\n `should use the total number of slides for slides per page when that number\n is smaller than the resolved slides per page based on device type`\n )\n it.todo(\n `should use the total number of slides for navigation step when that number\n is smaller than the resolved slides per page based on device type`\n )\n})\n\ndescribe('useSliderControls', () => {\n describe('goBack()', () => {\n it('should dispatch a SLIDE action to go back the navigationStep when goBack() is called with no arguments', async () => {\n mockSliderInitialState = mockInitialInfiniteSliderState\n const { result } = renderHook(() => useSliderControls(true))\n\n await act(() => Promise.resolve())\n result.current.goBack()\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: -2,\n transform: mockInitialInfiniteSliderState.transformMap[-2],\n },\n })\n })\n\n it('should dispatch a SLIDE action to go back `step` pages when goBack() is called', async () => {\n mockSliderInitialState = mockInitialInfiniteSliderState\n const { result } = renderHook(() => useSliderControls(true))\n\n await act(() => Promise.resolve())\n result.current.goBack(3)\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: -3,\n transform: mockInitialInfiniteSliderState.transformMap[-3],\n },\n })\n })\n\n it('should prevent SLIDE action to set `currentSlide` to a negative number if the slider is not an infinite one', async () => {\n mockSliderInitialState = mockInitialNonInfiniteSliderState\n const { result } = renderHook(() => useSliderControls(false))\n\n await act(() => Promise.resolve())\n result.current.goBack()\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: 0,\n transform: 0,\n },\n })\n })\n })\n\n describe('goForward()', () => {\n it('should dispatch a SLIDE action to go forward exactly one page when goForward() is called with no arguments', async () => {\n mockSliderInitialState = mockInitialInfiniteSliderState\n const { result } = renderHook(() => useSliderControls(true))\n\n await act(() => Promise.resolve())\n result.current.goForward()\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: 2,\n transform: mockInitialInfiniteSliderState.transformMap[2],\n },\n })\n })\n it('should dispatch a SLIDE action to go forward `step` pages when goForward() is called', async () => {\n mockSliderInitialState = mockInitialInfiniteSliderState\n const { result } = renderHook(() => useSliderControls(true))\n\n await act(() => Promise.resolve())\n result.current.goForward(4)\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: 4,\n transform: mockInitialInfiniteSliderState.transformMap[4],\n },\n })\n })\n it(`should dispatch SLIDE action to set \\`currentSlide\\` to the start of the last page if slider is not an infinite one`, async () => {\n mockSliderInitialState = mockInitialNonInfiniteSliderState\n mockSliderInitialState.currentSlide = 7\n const { result } = renderHook(() => useSliderControls(false))\n\n await act(() => Promise.resolve())\n result.current.goForward(4)\n\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'SLIDE',\n payload: {\n currentSlide: 5,\n transform: mockInitialInfiniteSliderState.transformMap[5],\n },\n })\n })\n })\n})\n\ndescribe('useTouchHandlers', () => {\n it.todo('should update transform value accordingly to touch movement')\n it.todo(\n \"should not call slider controls if the user's touch movement delta was below the threshold\"\n )\n it.todo(\n 'should trigger forward slide movement if a user swipes from right to left'\n )\n it.todo(\n 'should trigger backward slide movement if a user swipes from left to right'\n )\n})\n\ndescribe('useSliderVisibility', () => {\n it.todo(\n 'should return ({ shouldRenderItem: false, isItemVisible: false }) if slide has never been seen'\n )\n it.todo(\n `should return ({ shouldRenderItem: true, isItemVisible: false }) if slide has been seen,\n but is not currently visible`\n )\n it.todo(\n 'should return ({ shouldRenderItem: true, isItemVisible: true }) if slide is currently visible'\n )\n})\n\n```" } ]
code_slider-layout_f4105995
[ { "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 slider-layout/react/__tests__/SliderLayoutGroup.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport {\n render,\n getByLabelText,\n getByText,\n fireEvent,\n} from '@vtex/test-tools/react'\nimport { useResponsiveValue } from 'vtex.responsive-values'\n\nimport SliderLayoutGroup from '../SliderLayoutGroup'\nimport SliderLayout from '../SliderLayout'\n\nconst mockedUseResponsiveValue = useResponsiveValue as jest.Mock<\n number | string\n>\n\nmockedUseResponsiveValue.mockImplementation(args => {\n if (typeof args === 'string') return args\n\n return 1\n})\n\ntest('should move all sliders in a group together', () => {\n const { container } = render(\n <SliderLayoutGroup>\n <div id=\"first-slider\">\n <SliderLayout showPaginationDots=\"never\">\n <div>Slider 1 Item 1</div>\n <div>Slider 1 Item 2</div>\n <div>Slider 1 Item 3</div>\n </SliderLayout>\n </div>\n <div id=\"second-slider\">\n <SliderLayout showPaginationDots=\"never\">\n <div>Slider 2 Item 1</div>\n <div>Slider 2 Item 2</div>\n <div>Slider 2 Item 3</div>\n </SliderLayout>\n </div>\n </SliderLayoutGroup>\n )\n\n const firstSlider = container.querySelector('#first-slider') as HTMLElement\n const secondSlider = container.querySelector('#second-slider') as HTMLElement\n\n const nextArrow = getByLabelText(firstSlider, 'Next Slide')\n const previousArrow = getByLabelText(secondSlider, 'Previous Slide')\n\n // Go to the right\n fireEvent.click(nextArrow)\n\n let visibleSlideFirstSlider: HTMLElement | null = firstSlider.querySelector(\n '[aria-hidden=false]'\n )\n\n let visibleSlideSecondSlider: HTMLElement | null = secondSlider.querySelector(\n '[aria-hidden=false]'\n )\n\n if (!visibleSlideFirstSlider || !visibleSlideSecondSlider) {\n throw new Error('Could not find any visible slides')\n }\n\n let secondSlide1 = getByText(visibleSlideFirstSlider, 'Slider 1 Item 2')\n let secondSlide2 = getByText(visibleSlideSecondSlider, 'Slider 2 Item 2')\n\n expect(secondSlide1).toBeDefined()\n expect(secondSlide2).toBeDefined()\n\n // Go to the left\n fireEvent.click(previousArrow)\n\n visibleSlideFirstSlider = firstSlider.querySelector('[aria-hidden=false]')\n\n visibleSlideSecondSlider = secondSlider.querySelector('[aria-hidden=false]')\n\n if (!visibleSlideFirstSlider || !visibleSlideSecondSlider) {\n throw new Error('Could not find any visible slides')\n }\n\n secondSlide1 = getByText(visibleSlideFirstSlider, 'Slider 1 Item 1')\n secondSlide2 = getByText(visibleSlideSecondSlider, 'Slider 2 Item 1')\n\n expect(secondSlide1).toBeDefined()\n expect(secondSlide2).toBeDefined()\n})\n\n```" } ]
code_slider-layout_20c3ccea
[ { "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 slider-layout/react/__tests__/CssHandles.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\ndescribe('CSS Handles API', () => {\n it.todo('should render with all expected CSS handles')\n})\n\n```" } ]
code_slider-layout_3cd230bc
[ { "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 slider-layout/react/__tests__/SliderTrack.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render, fireEvent } from '@vtex/test-tools/react'\n\nimport SliderTrack, { CSS_HANDLES } from '../components/SliderTrack'\nimport { useSliderState } from '../components/SliderContext'\nimport {\n mockInitialSlides,\n mockInitialInfiniteSliderState,\n mockInitialNonInfiniteSliderState,\n} from '../__fixtures__/SliderStateContext'\nimport { useContextCssHandles } from '../modules/cssHandles'\nimport { mockedUseContextCssHandlesFn } from '../__fixtures__/CssHandlesHelper'\n\nconst mockDispatch = jest.fn()\n\nconst mockedUseSliderState = useSliderState as jest.Mock\n\njest.mock('../components/SliderContext', () => ({\n useSliderState: jest.fn(),\n useSliderDispatch: () => mockDispatch,\n}))\n\njest.mock('../modules/cssHandles', () => ({\n useContextCssHandles: jest.fn(),\n}))\n\nconst mockedUseContextCssHandles = useContextCssHandles as jest.Mock<\n ReturnType<typeof useContextCssHandles>\n>\n\nmockedUseContextCssHandles.mockImplementation(() =>\n mockedUseContextCssHandlesFn(CSS_HANDLES)\n)\n\ndescribe('Basic rendering', () => {\n mockedUseSliderState.mockImplementation(() => mockInitialInfiniteSliderState)\n\n it('should render with correct width based on slides to render', () => {\n const TOTAL_ITEMS = 10\n const SLIDES_PER_PAGE = 5\n\n // slidesPerPage < totalItems\n const { getByTestId, rerender } = render(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedSliderTrack = getByTestId('slider-track')\n\n // Since this slider is infinite, track width should be calculated\n // based on 2 * TOTAL_ITEMS.\n expect(renderedSliderTrack.style.width).toEqual(\n `${(2 * TOTAL_ITEMS * 100) / SLIDES_PER_PAGE}%`\n )\n\n // slidesPerPage === totalItems\n rerender(\n <SliderTrack centerMode=\"disabled\" usePagination totalItems={5} infinite>\n {mockInitialSlides}\n </SliderTrack>\n )\n renderedSliderTrack = getByTestId('slider-track')\n expect(renderedSliderTrack.style.width).toEqual(\n `${(2 * TOTAL_ITEMS * 100) / SLIDES_PER_PAGE}%`\n )\n\n // slidesPerPage > totalItems\n rerender(\n <SliderTrack centerMode=\"disabled\" usePagination totalItems={3} infinite>\n {mockInitialSlides}\n </SliderTrack>\n )\n renderedSliderTrack = getByTestId('slider-track')\n expect(renderedSliderTrack.style.width).toEqual('100%')\n })\n\n it('should render with correct translate3d(x, y, z), set to the initial slide', () => {\n // infinite slider\n const { getByTestId, rerender } = render(\n <SliderTrack centerMode=\"disabled\" usePagination totalItems={10} infinite>\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedSliderTrack = getByTestId('slider-track')\n\n expect(renderedSliderTrack.style.transform).toEqual(\n `translate3d(-25%, 0, 0)`\n )\n\n // non-infinite slider\n mockedUseSliderState.mockImplementationOnce(\n () => mockInitialNonInfiniteSliderState\n )\n\n rerender(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={10}\n infinite={false}\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n renderedSliderTrack = getByTestId('slider-track')\n expect(renderedSliderTrack.style.transform).toEqual(`translate3d(0%, 0, 0)`)\n })\n\n it('should render slides with correct indexes', () => {\n const TOTAL_ITEMS = 10\n const SLIDES_PER_PAGE = 5\n\n // infinite slider\n const { getByTestId, rerender } = render(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedSliderTrack = getByTestId('slider-track')\n\n renderedSliderTrack.childNodes.forEach((element, idx) => {\n // This condition is due to the fact that this slider is infinite, so the\n // first SLIDES_PER_PAGE elements are a copy of the slider's last page,\n // and the last SLIDES_PER_PAGE elements are a copy of the first page.\n if (idx >= TOTAL_ITEMS + SLIDES_PER_PAGE || idx < SLIDES_PER_PAGE) {\n expect(element).not.toHaveAttribute('data-index')\n\n return\n }\n\n expect(element).toHaveAttribute(\n 'data-index',\n `${idx + 1 - SLIDES_PER_PAGE}`\n )\n })\n\n // non-infinite slider\n mockedUseSliderState.mockImplementationOnce(\n () => mockInitialNonInfiniteSliderState\n )\n\n rerender(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite={false}\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n renderedSliderTrack = getByTestId('slider-track')\n\n renderedSliderTrack.childNodes.forEach((element, idx) => {\n expect(element).toHaveAttribute('data-index', `${idx + 1}`)\n })\n })\n\n it('should only render visible slides on initial mount', () => {\n const TOTAL_ITEMS = 10\n const SLIDES_PER_PAGE = 5\n const INDEXES = Array.from(new Array(10), (_, i) => i + 1)\n\n // infinite slider\n const { rerender, queryByText } = render(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedSlides = INDEXES.map(idx =>\n queryByText(`I am a slide. My index is ${idx}`)\n ).filter(Boolean)\n\n expect(renderedSlides).toHaveLength(SLIDES_PER_PAGE)\n\n // non-infinite slider\n mockedUseSliderState.mockImplementationOnce(\n () => mockInitialNonInfiniteSliderState\n )\n\n rerender(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite={false}\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n renderedSlides = INDEXES.map(idx =>\n queryByText(`I am a slide. My index is ${idx}`)\n ).filter(Boolean)\n\n expect(renderedSlides).toHaveLength(SLIDES_PER_PAGE)\n })\n\n it('should render all slides on initial mount when slider is not using pagination', () => {\n const TOTAL_ITEMS = 10\n const INDEXES = Array.from(new Array(10), (_, i) => i + 1)\n\n // infinite slider\n const { rerender, queryByText, queryAllByText } = render(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination={false}\n totalItems={TOTAL_ITEMS}\n infinite\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedSlides: Array<HTMLElement | null | void> = INDEXES.map(idx =>\n expect(queryAllByText(`I am a slide. My index is ${idx}`)).toHaveLength(2)\n )\n\n expect(renderedSlides).toHaveLength(TOTAL_ITEMS)\n\n // non-infinite slider\n mockedUseSliderState.mockImplementationOnce(\n () => mockInitialNonInfiniteSliderState\n )\n\n rerender(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination={false}\n totalItems={TOTAL_ITEMS}\n infinite={false}\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n renderedSlides = INDEXES.map(idx =>\n queryByText(`I am a slide. My index is ${idx}`)\n ).filter(Boolean)\n\n expect(renderedSlides).toHaveLength(TOTAL_ITEMS)\n })\n})\n\ndescribe('Behavior upon interaction', () => {\n it('should correct slider state after infinite loop transitions', () => {\n const TOTAL_ITEMS = 10\n\n // This is a state where the slider is in its first page clone\n mockedUseSliderState.mockImplementation(() => ({\n ...mockInitialInfiniteSliderState,\n currentSlide: 10,\n transform: mockInitialInfiniteSliderState.transformMap[10],\n }))\n\n const { getByTestId, rerender } = render(\n <SliderTrack\n centerMode=\"disabled\"\n totalItems={TOTAL_ITEMS}\n infinite\n usePagination\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n let renderedTrack = getByTestId('slider-track')\n\n fireEvent.transitionEnd(renderedTrack)\n\n expect(mockDispatch).toHaveBeenCalledWith({ type: 'DISABLE_TRANSITION' })\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'ADJUST_CURRENT_SLIDE',\n payload: {\n currentSlide: 0,\n transform: mockInitialInfiniteSliderState.transformMap[0],\n },\n })\n\n // This is a state where the slider is in its last page clone\n mockedUseSliderState.mockImplementation(() => ({\n ...mockInitialInfiniteSliderState,\n currentSlide: -1,\n transform: mockInitialInfiniteSliderState.transformMap[-1],\n }))\n\n rerender(\n <SliderTrack\n centerMode=\"disabled\"\n totalItems={TOTAL_ITEMS}\n infinite\n usePagination\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n renderedTrack = getByTestId('slider-track')\n fireEvent.transitionEnd(renderedTrack)\n\n expect(mockDispatch).toHaveBeenCalledWith({ type: 'DISABLE_TRANSITION' })\n expect(mockDispatch).toHaveBeenCalledWith({\n type: 'ADJUST_CURRENT_SLIDE',\n payload: {\n currentSlide: 9,\n transform: mockInitialInfiniteSliderState.transformMap[9],\n },\n })\n })\n\n mockedUseSliderState.mockClear()\n})\n\ndescribe('Accessibility', () => {\n it('should have correct aria attributes set for each slide', () => {\n mockedUseSliderState.mockImplementation(\n () => mockInitialInfiniteSliderState\n )\n\n const TOTAL_ITEMS = 10\n const SLIDES_PER_PAGE = 5\n const INDEXES = Array.from(new Array(10), (_, i) => i + 1)\n\n const { getByTestId, getByLabelText } = render(\n <SliderTrack\n centerMode=\"disabled\"\n usePagination\n totalItems={TOTAL_ITEMS}\n infinite\n >\n {mockInitialSlides}\n </SliderTrack>\n )\n\n const renderedSliderTrack = getByTestId('slider-track')\n\n const clones = renderedSliderTrack.querySelectorAll(\n \"[role='none presentation']\"\n )\n\n expect(clones).toHaveLength(SLIDES_PER_PAGE * 2)\n\n const visibleSlides = renderedSliderTrack.querySelectorAll(\n '[aria-hidden=false]'\n )\n\n expect(visibleSlides).toHaveLength(SLIDES_PER_PAGE)\n\n const nonCloneSlides = renderedSliderTrack.querySelectorAll(\n '[aria-roledescription=slide]'\n )\n\n expect(nonCloneSlides).toHaveLength(TOTAL_ITEMS)\n\n const slidesWithLabels = INDEXES.map(idx =>\n getByLabelText(`Current slide is ${idx} of ${TOTAL_ITEMS}`)\n ).filter(Boolean)\n\n expect(slidesWithLabels).toHaveLength(TOTAL_ITEMS)\n })\n})\n\n```" } ]
code_slider-layout_43398d55
[ { "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 slider-layout/react/__tests__/SliderContext.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { renderHook } from '@vtex/test-tools/react'\n\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\n\ndescribe('Initialization', () => {\n it.todo(\n 'should correctly resolve initial navigationStep based on received props'\n )\n it.todo(\n 'should correctly resolve initial slidesPerPage based on received props'\n )\n it.todo('should correctly initiate transformMap')\n it.todo('should correctly create clones if slider is infinite')\n it.todo('should correctly initiate transformMap in an infinite slider')\n})\n\n/**\n * Most of the actions are pretty simple, since they just update the state using the\n * values from their payloads directly.\n * That being said, if there's an issue in the slider's state behavior, it's likely\n * caused by dispatch callers, and not the reducer itself. Check './hooks.test.tsx'.\n */\ndescribe('Reducer actions', () => {\n it.todo('SLIDE')\n it.todo('TOUCH')\n it.todo('ADJUST_ON_RESIZE')\n it.todo('DISABLE_TRANSITION')\n it.todo('ADJUST_CURRENT_SLIDE')\n it.todo('ADJUST_CONTEXT_VALUES')\n})\n\ndescribe('useSliderState and useSliderDispatch hooks', () => {\n it('should throw an error when used outside SliderContext', () => {\n const { result: sliderStateResult } = renderHook(() => useSliderState())\n\n const expectedUseStateError = new Error(\n 'useSliderState must be used within a SliderContextProvider'\n )\n\n expect(sliderStateResult.error).toEqual(expectedUseStateError)\n\n const { result: sliderDispatchResult } = renderHook(() =>\n useSliderDispatch()\n )\n\n const expectedUseDispatchError = new Error(\n 'useSliderDispatch must be used within a SliderContextProvider'\n )\n\n expect(sliderDispatchResult.error).toEqual(expectedUseDispatchError)\n })\n})\n\n```" } ]
code_slider-layout_95bbed62
[ { "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 slider-layout/react/__tests__/Arrows.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, { Fragment } from 'react'\nimport { render, fireEvent } from '@vtex/test-tools/react'\n\nimport { useSliderState } from '../components/SliderContext'\nimport Arrow, { CSS_HANDLES } from '../components/Arrow'\nimport { useContextCssHandles } from '../modules/cssHandles'\nimport { mockedUseContextCssHandlesFn } from '../__fixtures__/CssHandlesHelper'\n\nconst mockGoForward = jest.fn()\nconst mockGoBack = jest.fn()\n\nconst mockedUseSliderState = useSliderState as jest.Mock\n\njest.mock('../components/SliderContext', () => ({\n useSliderState: jest.fn(),\n}))\n\njest.mock('../hooks/useSliderControls', () => ({\n useSliderControls: () => ({\n goForward: mockGoForward,\n goBack: mockGoBack,\n }),\n}))\n\njest.mock('../modules/cssHandles', () => ({\n useContextCssHandles: jest.fn(),\n}))\n\nconst mockedUseContextCssHandles = useContextCssHandles as jest.Mock<\n ReturnType<typeof useContextCssHandles>\n>\n\nmockedUseContextCssHandles.mockImplementation(() =>\n mockedUseContextCssHandlesFn(CSS_HANDLES)\n)\n\nbeforeEach(() => {\n mockGoForward.mockClear()\n mockGoBack.mockClear()\n // eslint-disable-next-line prettier/prettier\n})\n\ndescribe('Accessibility', () => {\n mockedUseSliderState.mockImplementation(() => ({\n currentSlide: 0,\n slidesPerPage: 5,\n navigationStep: 5,\n }))\n\n it('should render with correct aria attributes in each arrow', () => {\n const expectedLabelLeft = 'Previous Slide'\n const expectedLabelRight = 'Next Slide'\n const expectedContainerRole = 'button'\n\n const { queryAllByRole, queryByLabelText } = render(\n <Fragment>\n <Arrow\n infinite\n arrowSize={25}\n totalItems={20}\n orientation=\"left\"\n controls=\"slider-items\"\n />\n <Arrow\n infinite\n arrowSize={25}\n totalItems={20}\n orientation=\"right\"\n controls=\"slider-items\"\n />\n </Fragment>\n )\n\n expect(queryAllByRole(expectedContainerRole)).toHaveLength(2)\n expect(queryByLabelText(expectedLabelLeft)).toBeTruthy()\n expect(queryByLabelText(expectedLabelRight)).toBeTruthy()\n })\n})\n\ndescribe('Behavior upon interaction', () => {\n mockedUseSliderState.mockImplementation(() => ({\n currentSlide: 0,\n slidesPerPage: 5,\n navigationStep: 5,\n }))\n\n it('should go to the next page if right arrow is clicked', () => {\n const { getByTestId } = render(\n <Arrow\n infinite\n arrowSize={25}\n totalItems={20}\n orientation=\"right\"\n controls=\"slider-items\"\n />\n )\n\n const rightArrow = getByTestId('icon-caret-right')\n\n fireEvent.click(rightArrow)\n expect(mockGoForward).toHaveBeenCalledTimes(1)\n })\n\n it('should go to the previous page if left arrow is clicked', () => {\n const { getByTestId } = render(\n <Arrow\n infinite\n arrowSize={25}\n totalItems={20}\n orientation=\"left\"\n controls=\"slider-items\"\n />\n )\n\n const leftArrow = getByTestId('icon-caret-left')\n\n fireEvent.click(leftArrow)\n expect(mockGoBack).toHaveBeenCalledTimes(1)\n })\n\n it('should not go back on click if the slider is not infinite and left-end is reached', () => {\n const { getByTestId } = render(\n <Arrow\n infinite={false}\n arrowSize={25}\n totalItems={10}\n orientation=\"left\"\n controls=\"slider-items\"\n />\n )\n\n const leftArrow = getByTestId('icon-caret-left')\n\n fireEvent.click(leftArrow)\n expect(mockGoBack).toHaveBeenCalledTimes(0)\n })\n\n it('should not go forward on click if if the slider is not infinite and right-end is reached', () => {\n mockedUseSliderState.mockImplementation(() => ({\n currentSlide: 5,\n slidesPerPage: 5,\n navigationStep: 5,\n }))\n\n const { getByTestId } = render(\n <Arrow\n infinite={false}\n arrowSize={25}\n totalItems={10}\n orientation=\"right\"\n controls=\"slider-items\"\n />\n )\n\n const rightArrow = getByTestId('icon-caret-right')\n\n fireEvent.click(rightArrow)\n expect(mockGoForward).toHaveBeenCalledTimes(0)\n })\n})\n\n```" } ]
code_slider-layout_c14ab1e0
[ { "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 slider-layout/react/__tests__/Slider.test.tsx from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { render } from '@vtex/test-tools/react'\n\nimport Slider, { CSS_HANDLES } from '../components/Slider'\nimport { mockInitialInfiniteSliderState } from '../__fixtures__/SliderStateContext'\nimport { mockedUseContextCssHandlesFn } from '../__fixtures__/CssHandlesHelper'\nimport { useContextCssHandles } from '../modules/cssHandles'\n\nlet mockDeviceDetectorReturn = { device: 'desktop', isMobile: false }\n\njest.mock('../hooks/useTouchHandlers', () => ({\n useTouchHandlers: () => ({\n onTouchStart: jest.fn(),\n onTouchMove: jest.fn(),\n onTouchEnd: jest.fn(),\n }),\n}))\n\njest.mock('../components/SliderContext', () => ({\n useSliderState: () => mockInitialInfiniteSliderState,\n useSliderDispatch: () => jest.fn(),\n}))\n\njest.mock('vtex.device-detector', () => ({\n useDevice: jest.fn(() => mockDeviceDetectorReturn),\n}))\n\njest.mock('../modules/cssHandles', () => ({\n useContextCssHandles: jest.fn(),\n}))\n\nconst mockedUseContextCssHandles = useContextCssHandles as jest.Mock<\n ReturnType<typeof useContextCssHandles>\n>\n\nmockedUseContextCssHandles.mockImplementation(() =>\n mockedUseContextCssHandlesFn(CSS_HANDLES)\n)\n\ndescribe('Basic rendering', () => {\n it('should render complete slider, with arrows and pagination dots on default settings', () => {\n const { getByTestId, getByLabelText } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n arrowSize={25}\n fullWidth\n infinite\n usePagination\n />\n )\n\n const expectedCarouselRole = getByLabelText('slider')\n const leftArrow = getByTestId('icon-caret-left')\n const rightArrow = getByTestId('icon-caret-right')\n const paginationDots = getByLabelText('Slider pagination dots')\n\n expect(expectedCarouselRole).toBeInTheDocument()\n expect(leftArrow).toBeInTheDocument()\n expect(rightArrow).toBeInTheDocument()\n expect(paginationDots).toBeInTheDocument()\n })\n\n it('should render without pagination features and use x-scrolling if usePagination is set to false', () => {\n const { getByLabelText, queryByTestId, queryByLabelText } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n usePagination={false}\n arrowSize={25}\n fullWidth\n infinite\n />\n )\n\n const renderedSlider = getByLabelText('slider')\n const sliderTrackContainer = renderedSlider.firstChild\n\n const leftArrow = queryByTestId('icon-caret-left')\n const rightArrow = queryByTestId('icon-caret-right')\n const paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n expect(sliderTrackContainer).toHaveClass('overflow-x-scroll')\n })\n\n it('should render without pagination features if there are not enough slides to fill a page', () => {\n const { getByLabelText, queryByTestId, queryByLabelText } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={3}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n const leftArrow = queryByTestId('icon-caret-left')\n const rightArrow = queryByTestId('icon-caret-right')\n const paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n\n const renderedSlider = getByLabelText('slider')\n const sliderTrackContainer = renderedSlider.firstChild\n\n // Make sure that the slider renders without x-scrolling, since usePagination is set to true\n expect(sliderTrackContainer).not.toHaveClass('overflow-x-scroll')\n })\n\n it('should add appropriate padding in the x-axis if slider is not a full width one', () => {\n const { getByLabelText } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n fullWidth={false}\n arrowSize={25}\n usePagination\n infinite\n />\n )\n\n const sliderSectionElement = getByLabelText('slider')\n\n expect(sliderSectionElement).toHaveStyle({\n paddingLeft: '50px',\n paddingRight: '50px',\n })\n })\n})\n\ndescribe('Behavior upon interaction', () => {\n it('should correctly toggle arrows and pagination dots visibility on mobile devices', () => {\n mockDeviceDetectorReturn = { device: 'phone', isMobile: true }\n\n // 'mobileOnly'\n const { queryByTestId, queryByLabelText, rerender } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"mobileOnly\"\n showPaginationDots=\"mobileOnly\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n let leftArrow = queryByTestId('icon-caret-left')\n let rightArrow = queryByTestId('icon-caret-right')\n let paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).toBeInTheDocument()\n expect(rightArrow).toBeInTheDocument()\n expect(paginationDots).toBeInTheDocument()\n\n // 'desktopOnly'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"desktopOnly\"\n showPaginationDots=\"desktopOnly\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n\n // 'always'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).toBeInTheDocument()\n expect(rightArrow).toBeInTheDocument()\n expect(paginationDots).toBeInTheDocument()\n\n // 'never'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"never\"\n showPaginationDots=\"never\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n })\n\n it('should correctly toggle arrows and pagination dots visibility on desktop devices', () => {\n mockDeviceDetectorReturn = { device: 'desktop', isMobile: false }\n\n // 'mobileOnly'\n const { queryByTestId, queryByLabelText, rerender } = render(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"mobileOnly\"\n showPaginationDots=\"mobileOnly\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n let leftArrow = queryByTestId('icon-caret-left')\n let rightArrow = queryByTestId('icon-caret-right')\n let paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n\n // 'desktopOnly'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"desktopOnly\"\n showPaginationDots=\"desktopOnly\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).toBeInTheDocument()\n expect(rightArrow).toBeInTheDocument()\n expect(paginationDots).toBeInTheDocument()\n\n // 'always'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"always\"\n showPaginationDots=\"always\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).toBeInTheDocument()\n expect(rightArrow).toBeInTheDocument()\n expect(paginationDots).toBeInTheDocument()\n\n // 'never'\n rerender(\n <Slider\n centerMode=\"disabled\"\n totalItems={10}\n itemsPerPage={5}\n showNavigationArrows=\"never\"\n showPaginationDots=\"never\"\n arrowSize={25}\n usePagination\n fullWidth\n infinite\n />\n )\n\n leftArrow = queryByTestId('icon-caret-left')\n rightArrow = queryByTestId('icon-caret-right')\n paginationDots = queryByLabelText('Slider pagination dots')\n\n expect(leftArrow).not.toBeInTheDocument()\n expect(rightArrow).not.toBeInTheDocument()\n expect(paginationDots).not.toBeInTheDocument()\n })\n})\n\n```" } ]
code_slider-layout_2eaeee8f
[ { "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 slider-layout/react/hooks/useTouchHandlers.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useState } from 'react'\n\nimport { useSliderControls } from './useSliderControls'\nimport {\n SliderLayoutProps,\n useSliderDispatch,\n useSliderState,\n} from '../components/SliderContext'\n\nconst SWIPE_THRESHOLD = 75\nconst TOUCH_MOVE_DAMPING = 25\n\nexport const useTouchHandlers = ({\n infinite,\n centerMode,\n}: {\n infinite: boolean\n centerMode: SliderLayoutProps['centerMode']\n}) => {\n const dispatch = useSliderDispatch()\n const { transform } = useSliderState()\n const { goForward, goBack } = useSliderControls(infinite)\n\n const [touchState, setTouchState] = useState({\n touchStartX: 0,\n touchInitialTransform: transform,\n })\n\n const onTouchStart = (e: React.TouchEvent) => {\n const startX = e.touches[0].clientX\n\n setTouchState({ touchStartX: startX, touchInitialTransform: transform })\n }\n\n const onTouchMove = (e: React.TouchEvent) => {\n const currentX = e.touches[0].clientX\n const touchMoveDelta = currentX - touchState.touchStartX\n\n const newTransform =\n touchState.touchInitialTransform +\n touchMoveDelta /\n ((centerMode !== 'disabled' ? 2 : 1) * TOUCH_MOVE_DAMPING)\n\n dispatch({\n type: 'TOUCH',\n payload: { transform: newTransform, isOnTouchMove: true },\n })\n }\n\n const onTouchEnd = (e: React.TouchEvent) => {\n const endX = e.changedTouches[0].clientX\n const delta = endX - touchState.touchStartX\n\n if (Math.abs(delta) > SWIPE_THRESHOLD) {\n // Swipe from left to right\n if (delta > 0) {\n goBack()\n }\n\n // Swipe from right to left\n if (delta < 0) {\n goForward()\n }\n } else {\n // Ignore the swipe if SWIPE_THRESHOLD is not reached\n dispatch({\n type: 'TOUCH',\n payload: {\n transform: touchState.touchInitialTransform,\n isOnTouchMove: false,\n },\n })\n }\n\n setTouchState({ touchStartX: 0, touchInitialTransform: transform })\n dispatch({\n type: 'TOUCH',\n payload: {\n isOnTouchMove: false,\n },\n })\n }\n\n return { onTouchEnd, onTouchStart, onTouchMove }\n}\n\n```" } ]
code_slider-layout_df085455
[ { "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 slider-layout/react/hooks/useScreenResize.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\n\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\n\nexport const useScreenResize = (infinite: boolean, itemsPerPage: number) => {\n const { navigationStep, isPageNavigationStep, totalItems } = useSliderState()\n const dispatch = useSliderDispatch()\n\n useEffect(() => {\n const newSlidesPerPage =\n totalItems <= itemsPerPage ? totalItems : itemsPerPage\n\n const newNavigationStep = isPageNavigationStep\n ? newSlidesPerPage\n : navigationStep\n\n const setNewState = (shouldCorrectItemPosition: boolean) => {\n dispatch({\n type: 'ADJUST_ON_RESIZE',\n payload: {\n shouldCorrectItemPosition,\n slidesPerPage: newSlidesPerPage,\n navigationStep: newNavigationStep,\n },\n })\n }\n\n const onResize = (value?: UIEvent): void => {\n setNewState(!value || infinite)\n }\n\n setNewState(false)\n\n window.addEventListener('resize', onResize)\n\n return () => window.removeEventListener('resize', onResize)\n }, [\n infinite,\n dispatch,\n totalItems,\n itemsPerPage,\n isPageNavigationStep,\n navigationStep,\n ])\n}\n\n```" } ]
code_slider-layout_471ba0aa
[ { "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 slider-layout/react/hooks/useAutoplay.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\n\nimport { useSliderState } from '../components/SliderContext'\nimport { useSliderControls } from './useSliderControls'\nimport useHovering from './useHovering'\n\nexport const useAutoplay = (\n infinite: boolean,\n containerRef: React.RefObject<HTMLDivElement>\n) => {\n const { autoplay } = useSliderState()\n const { isHovering } = useHovering(containerRef)\n\n const shouldStop = autoplay?.stopOnHover && isHovering\n\n const { goForward } = useSliderControls(infinite)\n\n useEffect(() => {\n if (!autoplay) {\n return\n }\n\n const timeout = setTimeout(() => {\n goForward()\n }, autoplay.timeout)\n\n shouldStop && clearTimeout(timeout)\n\n return () => clearTimeout(timeout)\n }, [goForward, shouldStop, autoplay])\n}\n\n```" } ]
code_slider-layout_19b51b03
[ { "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 slider-layout/react/hooks/useSliderControls.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\nimport { useSliderGroupDispatch } from '../SliderLayoutGroup'\n\nexport const useSliderControls = (infinite: boolean) => {\n const {\n currentSlide,\n slidesPerPage,\n totalItems,\n navigationStep,\n transformMap,\n } = useSliderState()\n\n const dispatch = useSliderDispatch()\n const groupDispatch = useSliderGroupDispatch()\n\n const goBack = (step?: number) => {\n let nextSlide = 0\n let nextTransformValue = 0\n const activeNavigationStep = step ?? navigationStep\n\n const nextMaximumSlides = currentSlide - activeNavigationStep\n\n if (nextMaximumSlides >= 0) {\n /** Have more slides hidden on left */\n nextSlide = nextMaximumSlides\n nextTransformValue = transformMap[nextSlide]\n } else if (currentSlide !== 0) {\n /** Prevent over-slide */\n nextSlide = 0\n nextTransformValue = 0\n } else if (infinite) {\n /** Have more slides hidden on left */\n nextSlide = nextMaximumSlides\n nextTransformValue = transformMap[nextSlide]\n }\n\n if (groupDispatch) {\n groupDispatch({\n type: 'SLIDE',\n payload: {\n currentSlide: nextSlide,\n transform: nextTransformValue,\n },\n })\n }\n\n dispatch({\n type: 'SLIDE',\n payload: {\n transform: nextTransformValue,\n currentSlide: nextSlide,\n },\n })\n }\n\n const goForward = (step?: number) => {\n let nextSlide = 0\n let nextTransformValue = 0\n const activeNavigationStep = step ?? navigationStep\n\n const nextMaximumSlides =\n currentSlide + 1 + slidesPerPage + activeNavigationStep\n\n if (nextMaximumSlides <= totalItems) {\n /** There are some slides hidden on the right */\n nextSlide = currentSlide + activeNavigationStep\n nextTransformValue = transformMap[nextSlide]\n } else if (!infinite || currentSlide < totalItems - slidesPerPage) {\n /** Prevent over-slide */\n nextSlide = totalItems - slidesPerPage\n nextTransformValue = transformMap[nextSlide]\n } else if (infinite) {\n nextSlide = currentSlide + activeNavigationStep\n nextTransformValue = transformMap[nextSlide]\n }\n\n if (groupDispatch) {\n groupDispatch({\n type: 'SLIDE',\n payload: {\n currentSlide: nextSlide,\n transform: nextTransformValue,\n },\n })\n }\n\n dispatch({\n type: 'SLIDE',\n payload: {\n transform: nextTransformValue,\n currentSlide: nextSlide,\n },\n })\n }\n\n return { goForward, goBack }\n}\n\n```" } ]
code_slider-layout_51a27952
[ { "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 slider-layout/react/hooks/useSliderVisibility.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useEffect, useRef } from 'react'\n\nimport { SliderLayoutProps } from '../components/SliderContext'\n\nconst isSlideVisible = ({\n index,\n currentSlide,\n slidesToShow,\n totalItems,\n centerMode,\n}: {\n index: number\n currentSlide: number\n slidesToShow: number\n totalItems: number\n centerMode: SliderLayoutProps['centerMode']\n}): boolean => {\n const isClonedSlide = currentSlide < 0 || currentSlide >= totalItems\n let isVisible = index >= currentSlide && index < currentSlide + slidesToShow\n\n if (centerMode !== 'disabled') {\n isVisible =\n isVisible ||\n (index + 1 >= currentSlide && index + 1 < currentSlide + slidesToShow) ||\n (index - 1 >= currentSlide && index - 1 < currentSlide + slidesToShow)\n }\n\n return isVisible || isClonedSlide\n}\n\nexport const useSliderVisibility = ({\n currentSlide,\n slidesPerPage,\n totalItems,\n centerMode,\n}: {\n currentSlide: number\n slidesPerPage: number\n totalItems: number\n centerMode: SliderLayoutProps['centerMode']\n}) => {\n /** Keeps track of slides that have been visualized before.\n * We want to keep rendering them because the issue is mostly rendering\n * slides that might never be viewed; On the other hand, hiding slides\n * that were visible causes visual glitches */\n const visitedSlides = useRef<Set<number>>(new Set())\n\n useEffect(() => {\n for (let i = 0; i < slidesPerPage; i++) {\n visitedSlides.current.add(currentSlide + i)\n }\n }, [currentSlide, slidesPerPage])\n\n const isItemVisible = (index: number) =>\n isSlideVisible({\n index,\n currentSlide,\n slidesToShow: slidesPerPage,\n totalItems,\n centerMode,\n })\n\n const shouldRenderItem = (index: number) => {\n return visitedSlides.current.has(index) || isItemVisible(index)\n }\n\n return { shouldRenderItem, isItemVisible }\n}\n\n```" } ]
code_slider-layout_f55c2a8b
[ { "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 slider-layout/react/hooks/useKeyboardArrows.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\n\n/**\n * Adds event listener to call passed functions by pressing the left or right arrows\n * @param onLeft Function that is called on left arrow key press\n * @param onRight Function that is called on arrow arrow key press\n */\nconst useKeyboardArrows = (onLeft: () => void, onRight: () => void) => {\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n event.code === 'ArrowLeft' && onLeft()\n event.code === 'ArrowRight' && onRight()\n }\n\n window.addEventListener('keydown', onKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onKeyDown)\n }\n }, [onLeft, onRight])\n}\n\nexport default useKeyboardArrows\n\n```" } ]
code_slider-layout_31b37a6b
[ { "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 slider-layout/react/hooks/useHovering.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { useState, useEffect } from 'react'\n\nimport {\n useSliderGroupState,\n useSliderGroupDispatch,\n} from '../SliderLayoutGroup'\n\n/**\n * Hook that returns the hover state of a passed ref\n * @param ref React ref\n */\nconst useHovering = (ref: React.RefObject<HTMLDivElement>) => {\n const [isHovering, setHovering] = useState(false)\n const groupState = useSliderGroupState()\n const groupDispatch = useSliderGroupDispatch()\n\n useEffect(() => {\n const onMouseEnter = () => {\n groupDispatch?.({ type: 'HOVER', payload: { isHovering: true } })\n\n setHovering(true)\n }\n\n const onMouseLeave = () => {\n groupDispatch?.({ type: 'HOVER', payload: { isHovering: false } })\n\n setHovering(false)\n }\n\n if (ref?.current) {\n ref.current.addEventListener('mouseenter', onMouseEnter)\n ref.current.addEventListener('mouseleave', onMouseLeave)\n }\n\n return () => {\n const { current } = ref\n\n if (!current) {\n return\n }\n\n current.removeEventListener('mouseenter', onMouseEnter)\n current.removeEventListener('mouseleave', onMouseLeave)\n }\n }, [ref, groupDispatch])\n\n if (groupState?.isHovering) {\n return { isHovering: true }\n }\n\n return { isHovering }\n}\n\nexport default useHovering\n\n```" } ]
code_slider-layout_13ca76f3
[ { "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 slider-layout/react/modules/cssHandles.ts from the slider-layout VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { createCssHandlesContext } from 'vtex.css-handles'\n\nimport { CSS_HANDLES } from '../SliderLayout'\n\nconst { CssHandlesProvider, useContextCssHandles } = createCssHandlesContext(\n CSS_HANDLES\n)\n\nexport { CssHandlesProvider, useContextCssHandles }\n\n```" } ]
code_checkout-step-group_26f3600a
[ { "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 checkout-step-group/messages/pt.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout-label\": \"Checkout\",\n \"store/checkout-autofill-message\": \"Bem vindo de volta! Seus dados foram preenchidos com segurança.\",\n \"store/checkout-autofill-close-label\": \"Fechar\",\n \"store/checkout-profile-step-title\": \"Perfil\",\n \"store/checkout-shipping-step-title\": \"Entrega\",\n \"store/checkout-address-step-title\": \"Endereço\",\n \"store/checkout-payment-step-title\": \"Pagamento\"\n}\n\n```" } ]
code_checkout-step-group_3b1c0dd8
[ { "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 checkout-step-group/messages/en.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout-label\": \"Checkout\",\n \"store/checkout-autofill-message\": \"Welcome back! Your data was filled securely.\",\n \"store/checkout-autofill-close-label\": \"Close\",\n \"store/checkout-profile-step-title\": \"Profile\",\n \"store/checkout-shipping-step-title\": \"Shipping\",\n \"store/checkout-address-step-title\": \"Address\",\n \"store/checkout-payment-step-title\": \"Payment\"\n}\n\n```" } ]
code_checkout-step-group_531d7e01
[ { "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 checkout-step-group/messages/es.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"store/checkout-label\": \"Checkout\",\n \"store/checkout-autofill-message\": \"¡Dar una buena acogida! Sus datos han sido completados de forma segura.\",\n \"store/checkout-autofill-close-label\": \"Cerca\",\n \"store/checkout-profile-step-title\": \"Perfil\",\n \"store/checkout-shipping-step-title\": \"Entrega\",\n \"store/checkout-address-step-title\": \"Dirección\",\n \"store/checkout-payment-step-title\": \"Pago\"\n}\n\n```" } ]
code_checkout-step-group_2e7c9cbb
[ { "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 checkout-step-group/docs/README.md from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# Checkout Step Group\n\nThe Step Group component renders a list of \"steps\" in the Checkout interfaces. Each step\nis represented by a required part of the checkout process that the user must complete before\nthey finish their order.\n\n![Illustration of the checkout step group component](https://user-images.githubusercontent.com/10223856/75803899-ed222100-5d5d-11ea-8d02-133f17950297.png)\n\n## Configuration\n\n1. Add the Step Group app to your theme's dependencies in the `manifest.json`. For example:\n\n```json\n{\n \"dependencies\": {\n \"vtex.checkout-step-group\": \"0.x\"\n }\n}\n```\n\n2. Add the `checkout-step-group` block inside the block which renders the checkout. For example:\n\n```jsonc\n// interfaces.json\n{\n \"my-checkout-page\": {\n \"around\": [\"checkout-container\"],\n \"composition\": \"children\"\n }\n}\n```\n\n```jsonc\n// blocks.json\n{\n \"my-checkout-page\": {\n \"children\": [\"checkout-step-group\"]\n }\n}\n```\n\n## Advanced customization\n\nThe `checkout-step-group` block renders by default 3 steps, the most common ones in the checkout process:\n\n- `profile-step`: Renders the profile form, and the profile summary\n- `shipping-step`: Renders the shipping form, which includes the address form and pickup point\n- `payment-step`: Renders the payment form, with all the available payment methods in the current store\n\n\nIf you want to customize and remove (or add) one of these steps, you can do so by doing the following:\n\n```jsonc\n// blocks.json\n{\n \"checkout-step-group#my-checkout\": {\n \"children\": [\n // you can include here only the steps you need\n // in your store\n \"profile-step\",\n \"payment-step\"\n ]\n },\n \"my-checkout-page\": {\n \"children\": [\"checkout-step-group#my-checkout\"]\n }\n}\n```\n\n## CSS Customization\n\nIn order to apply CSS customizations in this and other blocks, follow the instructions given in [this recipe](https://vtex.io/docs/recipes/style/using-css-handles-for-store-customization)\nregarding using CSS classes for store customization.\n\n| CSS Handles |\n| --- |\n| `stepGroupWrapper` |\n| `stepGroupList` |\n| `stepGroupCheckoutLabel` |\n| `step` |\n| `indicator` |\n| `indicatorActive` |\n| `indicatorInactive` |\n| `stepTitle` |\n| `stepContentWrapper` |\n| `stepDivider` |\n| `stepContent` |\n\n```" } ]
code_checkout-step-group_68e3c46f
[ { "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 checkout-step-group/react/ShippingStep.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { ButtonPlain, IconEdit } from 'vtex.styleguide'\nimport { Router, ContainerContext, routes } from 'vtex.checkout-container'\nimport { ShippingSummary, ShippingForm } from 'vtex.checkout-shipping'\n\nimport Step from './Step'\n\nconst { useHistory, useRouteMatch } = Router\nconst { useCheckoutContainer } = ContainerContext\n\nconst ShippingStep: React.FC = () => {\n const history = useHistory()\n const match = useRouteMatch(routes.SHIPPING)\n const { isShippingEditable } = useCheckoutContainer()\n\n return (\n <Step\n title={<FormattedMessage id=\"store/checkout-shipping-step-title\" />}\n data-testid=\"edit-shipping-step\"\n actionButton={\n !match &&\n isShippingEditable && (\n <ButtonPlain onClick={() => history.push(routes.SHIPPING)}>\n <IconEdit solid />\n </ButtonPlain>\n )\n }\n active={!!match}\n >\n <Router.Switch>\n <Router.Route path={routes.SHIPPING}>\n <ShippingForm />\n </Router.Route>\n <Router.Route path=\"*\">\n <ShippingSummary />\n </Router.Route>\n </Router.Switch>\n </Step>\n )\n}\n\nexport default ShippingStep\n\n```" } ]
code_checkout-step-group_177657c5
[ { "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 checkout-step-group/react/StepGroup.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React, {\n useMemo,\n useRef,\n useContext,\n useLayoutEffect,\n useCallback,\n useState,\n} from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\nimport { OrderForm } from 'vtex.order-manager'\nimport { Alert } from 'vtex.styleguide'\nimport { FormattedMessage, useIntl } from 'react-intl'\n\nconst { useOrderForm } = OrderForm\n\n/**\n * The component below is implemented following the \"guidelines\" of\n * this [1] gist. It is known that creating compound components in React\n * that have a strong relation of parent-child (like a select and their\n * option's) is hard, and there is currently no good way to implement this\n * because of the lack of primitives in the library.\n *\n * [1] https://gist.github.com/ryanflorence/10e9387f633f9d2e6f444a9bddaabf6e\n */\n\ninterface StepContext {\n items: React.MutableRefObject<HTMLLIElement[]>\n assigning: React.MutableRefObject<boolean>\n activeIndex: number | undefined\n updateParent: () => void\n setActive: (element: HTMLLIElement | undefined) => void\n}\n\nconst ctx = React.createContext<StepContext | undefined>(undefined)\n\nconst useForceUpdate = (): [object, () => void] => {\n const [sentinel, setSentinel] = useState<object>({})\n\n return [\n sentinel,\n useCallback(() => {\n setSentinel({})\n }, []),\n ]\n}\n\nexport const useStepContext = () => {\n const value = useContext(ctx)\n\n if (!value) {\n throw new Error('useStepContext must be used inside a <StepGroup />')\n }\n\n return value\n}\n\nconst classes = [\n 'stepGroupWrapper',\n 'stepGroupList',\n 'stepGroupCheckoutLabel',\n 'stepGroupAlert',\n] as const\n\nconst StepGroup: React.FC = ({ children }) => {\n const { orderForm } = useOrderForm()\n const intl = useIntl()\n const [alertOpen, setAlertOpen] = useState(!orderForm.canEditData)\n\n const [activeElement, setActive] = useState<HTMLLIElement | undefined>(\n undefined\n )\n\n const assigning = useRef(true)\n\n const [sentinel, forceUpdate] = useForceUpdate()\n const stepListRef = useRef<HTMLLIElement[]>([])\n\n const cssHandles = useCssHandles(classes)\n\n useLayoutEffect(() => {\n if (assigning.current) {\n // At this point all of the children have pushed into the array so we set\n // assigning to false and force an update. Since we're in\n // useLayoutEffect, we won't get a flash of rendered content, it will all\n // happen synchronously. And now that this is false, children won't push\n // into the array on the forceUpdate\n assigning.current = false\n forceUpdate()\n } else {\n // After the forceUpdate completes, we end up here and set assigning back\n // to true for the next update from the app\n assigning.current = true\n }\n\n return () => {\n // this cleanup function runs right before the next render, so it's the\n // right time to empty out the array to be reassigned with whatever shows\n // up next render.\n if (assigning.current) {\n // we only want to empty out the array before the next render cycle if\n // it was NOT the result of our forceUpdate, so being guarded behind\n // assigning.current works\n stepListRef.current = []\n }\n }\n }, [forceUpdate, sentinel])\n\n const contextValue = useMemo(\n () => ({\n activeIndex: activeElement && stepListRef.current.indexOf(activeElement),\n setActive,\n items: stepListRef,\n assigning,\n updateParent: forceUpdate,\n sentinel,\n }),\n [activeElement, forceUpdate, sentinel]\n )\n\n const handleAlertClose = () => {\n setAlertOpen(false)\n }\n\n return (\n <ctx.Provider value={contextValue}>\n <div className={cssHandles.stepGroupWrapper}>\n <h3\n className={`${cssHandles.stepGroupCheckoutLabel} c-muted-1 f5 mb5 mb6-ns mt7 pt4`}\n >\n <FormattedMessage id=\"store/checkout-label\" />\n </h3>\n {alertOpen && (\n <div className={`${cssHandles.stepGroupAlert} mb5 mb6-ns`}>\n <Alert\n type=\"success\"\n closeIconLabel={intl.formatMessage({\n id: 'store/checkout-autofill-close-label',\n })}\n onClose={handleAlertClose}\n >\n <FormattedMessage id=\"store/checkout-autofill-message\" />\n </Alert>\n </div>\n )}\n <ol className={`${cssHandles.stepGroupList} pa0 ma0`}>{children}</ol>\n </div>\n </ctx.Provider>\n )\n}\n\nexport default StepGroup\n\n```" } ]
code_checkout-step-group_a25cf834
[ { "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 checkout-step-group/react/PaymentStep.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { ButtonPlain, IconEdit } from 'vtex.styleguide'\nimport { Router, ContainerContext, routes } from 'vtex.checkout-container'\nimport { Payment, PaymentSummary } from 'vtex.checkout-payment'\nimport { useOrderPayment } from 'vtex.order-payment/OrderPayment'\n\nimport Step from './Step'\n\nconst { useHistory, useRouteMatch } = Router\nconst { useCheckoutContainer } = ContainerContext\n\nconst PaymentStep: React.FC = () => {\n const history = useHistory()\n const match = useRouteMatch(routes.PAYMENT)\n const { isFreePurchase } = useOrderPayment()\n const { isPaymentEditable } = useCheckoutContainer()\n\n const shouldShowEditButton = !match && !isFreePurchase && isPaymentEditable\n\n return (\n <Step\n title={<FormattedMessage id=\"store/checkout-payment-step-title\" />}\n data-testid=\"edit-payment-step\"\n actionButton={\n shouldShowEditButton && (\n <ButtonPlain onClick={() => history.push(routes.PAYMENT)}>\n <IconEdit solid />\n </ButtonPlain>\n )\n }\n active={!!match}\n >\n <div hidden={!match}>\n <Payment />\n </div>\n <div hidden={match}>\n <PaymentSummary />\n </div>\n </Step>\n )\n}\n\nexport default PaymentStep\n\n```" } ]
code_checkout-step-group_efc44e96
[ { "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 checkout-step-group/react/Step.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport React, { useEffect, useLayoutEffect, useRef } from 'react'\nimport { useCssHandles } from 'vtex.css-handles'\n\nimport { useStepContext } from './StepGroup'\n\nconst CSS_HANDLES = [\n 'step',\n 'stepTitle',\n 'stepContentWrapper',\n 'stepContent',\n 'stepDivider',\n 'indicator',\n 'indicatorActive',\n 'indicatorInactive',\n] as const\n\nconst useStepIndicator = (elementRef: React.RefObject<HTMLLIElement>) => {\n const indexRef = useRef<number>(-1)\n const { assigning, items, updateParent, ...context } = useStepContext()\n\n useLayoutEffect(() => {\n if (!assigning.current) {\n return\n }\n\n indexRef.current = items.current.push(elementRef.current!) - 1\n updateParent()\n })\n\n return {\n // index is wrong on the first render, but the parent forces a\n // synchronous second render that fixes its value without flashing\n // the component\n index: indexRef.current,\n lastIndex: items.current.length - 1,\n ...context,\n }\n}\n\ninterface StepProps {\n title: React.ReactNode\n 'data-testid'?: string\n actionButton?: React.ReactNode\n active?: boolean\n}\n\nconst Step: React.FC<StepProps> = ({\n children,\n title,\n 'data-testid': dataTestId,\n active = false,\n actionButton = null,\n}) => {\n const elementRef = useRef<HTMLLIElement>(null)\n const { index, lastIndex, activeIndex, setActive } = useStepIndicator(\n elementRef\n )\n\n useEffect(() => {\n if (!active) {\n return\n }\n\n setActive(elementRef.current!)\n\n return () => setActive(undefined)\n }, [active, index, setActive])\n\n const handles = useCssHandles(CSS_HANDLES)\n\n const isActive = activeIndex === index\n\n const borderWidth = (index ?? 0) < lastIndex ? 1 : 0\n\n return (\n <li\n className={classNames(handles.step, 'flex flex-wrap items-center')}\n ref={elementRef}\n >\n <span\n className={classNames(\n handles.indicator,\n 'w1 h1 br-100 b flex items-center justify-center',\n {\n [handles.indicatorInactive]: !isActive,\n [handles.indicatorActive]: isActive,\n 'bg-muted-5 c-on-muted-5 pa2 pa3-ns f6 f5-ns': !isActive,\n 'bg-muted-4 c-on-muted-4 na2-ns pa3 pa4-ns f5 f4-ns': isActive,\n }\n )}\n >\n {index + 1}\n </span>\n <span\n className={classNames(\n handles.stepTitle,\n 'flex items-center lh-copy ml3 ml4-ns pl2-ns',\n {\n 'c-muted-1': activeIndex !== undefined && !isActive,\n }\n )}\n >\n <h2 className={classNames('mv0 fw6', { f5: !active, f4: active })}>\n {title}\n </h2>\n {actionButton && (\n <div className=\"pl4\" data-testid={dataTestId}>\n {actionButton}\n </div>\n )}\n </span>\n <div\n className={classNames(\n handles.stepContentWrapper,\n 'mt4 mb6 mb7-ns w-100 flex',\n {\n 'mt3-ns': !active,\n 'mt5-ns': active,\n }\n )}\n >\n <div\n style={{ width: borderWidth, minWidth: borderWidth }}\n className={classNames(\n handles.stepDivider,\n 'dn db-ns bg-muted-4 nt4 nb6 nb7-ns mh5',\n {\n 'nt3-ns': !active,\n 'nt5-ns': active,\n }\n )}\n />\n <div className={classNames(handles.stepContent, 'ml5-ns w-100 pr8-ns')}>\n {children}\n </div>\n </div>\n </li>\n )\n}\n\nexport default Step\n\n```" } ]
code_checkout-step-group_337fa861
[ { "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 checkout-step-group/react/package.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"name\": \"vtex.checkout-step-group\",\n \"version\": \"0.13.0\",\n \"private\": true,\n \"license\": \"UNLICENSED\",\n \"dependencies\": {\n \"classnames\": \"^2.2.6\",\n \"react\": \"^16.12.0\",\n \"react-intl\": \"^3.12.0\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.9\",\n \"@types/node\": \"^13.7.2\",\n \"@types/react\": \"^16.9.20\",\n \"@types/react-dom\": \"^16.9.5\",\n \"vtex.checkout-container\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-container@0.7.0/public/@types/vtex.checkout-container\",\n \"vtex.checkout-payment\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-payment@0.13.0/public/@types/vtex.checkout-payment\",\n \"vtex.checkout-profile\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-profile@0.3.0/public/@types/vtex.checkout-profile\",\n \"vtex.checkout-shipping\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.checkout-shipping@0.7.1/public/@types/vtex.checkout-shipping\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.4/public/@types/vtex.css-handles\",\n \"vtex.order-manager\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-manager@0.9.0/public/@types/vtex.order-manager\",\n \"vtex.order-payment\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-payment@0.8.0/public/@types/vtex.order-payment\",\n \"vtex.order-shipping\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.order-shipping@0.7.0/public/@types/vtex.order-shipping\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.126.11/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.3/public/@types/vtex.styleguide\"\n }\n}\n\n```" } ]
code_checkout-step-group_b54b725a
[ { "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 checkout-step-group/react/ProfileStep.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { ButtonPlain, IconEdit } from 'vtex.styleguide'\nimport { Router, ContainerContext, routes } from 'vtex.checkout-container'\nimport { ProfileForm, ProfileSummary } from 'vtex.checkout-profile'\nimport { OrderForm } from 'vtex.order-manager'\n\nimport Step from './Step'\n\nconst { useOrderForm } = OrderForm\nconst { useHistory, useRouteMatch } = Router\nconst { useCheckoutContainer } = ContainerContext\n\nconst ProfileStep: React.FC = () => {\n const { orderForm } = useOrderForm()\n const history = useHistory()\n const match = useRouteMatch(routes.PROFILE)\n const { requestLogin, isProfileEditable } = useCheckoutContainer()\n\n const handleProfileEdit = () => {\n if (orderForm.canEditData) {\n history.push(routes.PROFILE)\n } else {\n requestLogin()\n }\n }\n\n return (\n <Step\n title={<FormattedMessage id=\"store/checkout-profile-step-title\" />}\n data-testid=\"edit-profile-step\"\n actionButton={\n !match &&\n isProfileEditable && (\n <ButtonPlain onClick={handleProfileEdit}>\n <IconEdit solid />\n </ButtonPlain>\n )\n }\n active={!!match}\n >\n <Router.Switch>\n <Router.Route path={routes.PROFILE}>\n <ProfileForm />\n </Router.Route>\n <Router.Route path=\"*\">\n <ProfileSummary />\n </Router.Route>\n </Router.Switch>\n </Step>\n )\n}\n\nexport default ProfileStep\n\n```" } ]
code_checkout-step-group_bb1621cc
[ { "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 checkout-step-group/react/AddressStep.tsx from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport { FormattedMessage } from 'react-intl'\nimport { ButtonPlain, IconEdit } from 'vtex.styleguide'\nimport { Router, ContainerContext, routes } from 'vtex.checkout-container'\nimport { AddressSummary, ShippingAddress } from 'vtex.checkout-shipping'\nimport { OrderForm } from 'vtex.order-manager'\nimport { OrderShipping } from 'vtex.order-shipping'\n\nimport Step from './Step'\n\nconst { useOrderForm } = OrderForm\nconst { useOrderShipping } = OrderShipping\nconst { useHistory, useRouteMatch } = Router\nconst { useCheckoutContainer } = ContainerContext\n\nconst AddressStep: React.FC = () => {\n const history = useHistory()\n const match = useRouteMatch(routes.ADDRESS)\n const { requestLogin, isAddressEditable } = useCheckoutContainer()\n const { orderForm } = useOrderForm()\n const { selectedAddress } = useOrderShipping()\n\n const handleAddressEdit = () => {\n if (orderForm.canEditData || selectedAddress?.isDisposable) {\n history.push(routes.ADDRESS)\n } else {\n requestLogin()\n }\n }\n\n return (\n <Step\n title={<FormattedMessage id=\"store/checkout-address-step-title\" />}\n data-testid=\"edit-address-step\"\n actionButton={\n !match &&\n isAddressEditable && (\n <ButtonPlain onClick={handleAddressEdit}>\n <IconEdit solid />\n </ButtonPlain>\n )\n }\n active={!!match}\n >\n <Router.Switch>\n <Router.Route path={routes.ADDRESS}>\n <ShippingAddress />\n </Router.Route>\n <Router.Route path=\"*\">\n <AddressSummary />\n </Router.Route>\n </Router.Switch>\n </Step>\n )\n}\n\nexport default AddressStep\n\n```" } ]
code_checkout-step-group_d5e9618b
[ { "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 checkout-step-group/store/blocks.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"checkout-step-group\": {\n \"children\": [\n \"profile-step\",\n \"shipping-step\",\n \"address-step\",\n \"payment-step\"\n ]\n }\n}\n\n```" } ]
code_checkout-step-group_ab39435e
[ { "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 checkout-step-group/store/interfaces.json from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"checkout-step-group\": {\n \"component\": \"StepGroup\",\n \"composition\": \"children\"\n },\n \"checkout-step\": {\n \"component\": \"Step\",\n \"composition\": \"children\"\n },\n \"profile-step\": {\n \"component\": \"ProfileStep\"\n },\n \"shipping-step\": {\n \"component\": \"ShippingStep\",\n \"preview\": {\n \"type\": \"box\",\n \"height\": 250,\n \"fullWidth\": true,\n \"options\": {\n \"padding\": 0\n }\n }\n },\n \"address-step\": {\n \"component\": \"AddressStep\",\n \"preview\": {\n \"type\": \"box\",\n \"height\": 250,\n \"fullWidth\": true,\n \"options\": {\n \"padding\": 0\n }\n }\n },\n \"payment-step\": {\n \"component\": \"PaymentStep\"\n }\n}\n\n```" } ]
code_checkout-step-group_d14f6598
[ { "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 checkout-step-group/react/typings/vtex.order-payment.d.ts from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.order-payment/OrderPayment' {\n export * from 'vtex.order-payment/react/OrderPayment'\n export { default } from 'vtex.order-payment/react/OrderPayment'\n}\n\n```" } ]
code_checkout-step-group_6c4e3abf
[ { "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 checkout-step-group/react/typings/vtex.checkout-payment.d.ts from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.checkout-payment/Payment' {\n export { default } from 'vtex.checkout-payment/react/Payment'\n}\n\n```" } ]
code_checkout-step-group_33380cbc
[ { "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 checkout-step-group/react/typings/assets.d.ts from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const styles: { [name: string]: string }\n export default styles\n}\n\n```" } ]
code_checkout-step-group_11c34e1d
[ { "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 checkout-step-group/react/typings/vtex.styleguide.d.ts from the checkout-step-group VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport * as Styleguide from 'vtex.styleguide'\n\ndeclare module 'vtex.styleguide' {\n import React from 'react'\n\n export const Alert: React.FC\n\n export const Button: React.FC\n\n export const Input: React.FC\n\n export const IconCheck: React.FC\n export const IconClose: React.FC\n export const IconEdit: React.FC\n}\n\n```" } ]
code_rtbhouse_5cdfbeb1
[ { "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 rtbhouse/docs/README.md from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# RTB House\n\nThe RTB House engine, one of its kind powered by **deep learning algorithms**, identifies potential buyers and boosts performance via 1:1 ultra-personalized retargeting **up to 50 percent more efficient** than standard machine learning AI-based approaches.\nFor more information please visit, [RTB HOUSE](https://www.rtbhouse.com/) website.\n\n## App Installation\nOpen the VTEX APP Store and install the RTB HOUSE app on your store.\n\nor\n\nRun the following command:\n\n```sh\nvtex install vtex.rtbhouse@1.x\n```\n\nNext, open the app settings on your admin and fill the form with your RTB House ID.\n\n```" } ]
code_rtbhouse_7848984c
[ { "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 rtbhouse/react/index.tsx from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { canUseDOM } from 'vtex.render-runtime'\nimport { PixelMessage } from './typings/events'\nimport { getCategories, getDepartment, createIframeTag } from './helpers/index'\n\nfunction handleMessages(e: PixelMessage) {\n const { rtbhouseId } = window\n switch (e.data.eventName) {\n case 'vtex:pageInfo': {\n createIframeTag(`//us.creativecdn.com/tags?id=pr_${rtbhouseId}&amp;ncm=1`)\n if (e.data.eventType !== 'homeView') break\n const iframeId = 'rtbhouse_home'\n const src = `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_home`\n const iframe = document.getElementById(iframeId)\n if (!iframe) createIframeTag(src, iframeId)\n break\n }\n case 'vtex:productView': {\n const {\n product: { productId },\n } = e.data\n if (productId)\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_offer_${productId}`\n )\n break\n }\n case 'vtex:internalSiteSearchView': {\n const { products } = e.data\n const skus = products\n .map(({ productId }) => productId)\n .slice(0, 5)\n .join()\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_listing_${skus}`,\n 'rtbhouse_search'\n )\n break\n }\n case 'vtex:categoryView': {\n const { products } = e.data\n const categories = getCategories(products)\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_category2_${categories}`,\n 'rtbhouse_category'\n )\n break\n }\n case 'vtex:departmentView': {\n const { products } = e.data\n const categories = getDepartment(products)\n const department = categories[0]\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_category2_${department}`,\n 'rtbhouse_category'\n )\n break\n }\n case 'vtex:orderPlaced': {\n const { transactionSubtotal, transactionId, transactionProducts } = e.data\n const skus = transactionProducts.map(({ id }) => id).join(',')\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}_orderstatus2_${transactionSubtotal}_${transactionId}_${skus}&cd=default`,\n 'rtbhouse_purchase'\n )\n break\n }\n default:\n break\n }\n}\n\nfunction handleLoad() {\n const {\n rtbhouseId,\n location: { pathname },\n } = window\n if (pathname !== '/login') return\n const iframeId = 'rtbhouse_otherPages'\n const iframe = document.getElementById(iframeId)\n if (!iframe)\n createIframeTag(\n `//us.creativecdn.com/tags?id=pr_${rtbhouseId}&ncm=1`,\n iframeId\n )\n}\n\nif (canUseDOM) {\n window.addEventListener('message', handleMessages)\n window.addEventListener('load', handleLoad)\n}\n\n```" } ]
code_rtbhouse_72c65370
[ { "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 rtbhouse/react/package.json from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\"\n },\n \"devDependencies\": {\n \"@types/graphql\": \"^14.2.0\",\n \"@types/jest\": \"^24.0.11\",\n \"@types/node\": \"^11.13.0\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"prettier\": \"^1.18.2\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.7.3\",\n \"vtex.render-runtime\": \"http://vtex.vteximg.com.br/_v/public/typings/v1/vtex.render-runtime@8.50.0/public/_types/react\",\n \"vtex.pixel-interfaces\": \"http://vtex.vteximg.com.br/_v/public/typings/v1/vtex.pixel-interfaces@1.1.0/public/_types/react\"\n },\n \"version\": \"1.0.1\"\n}\n\n```" } ]
code_rtbhouse_b19c0c24
[ { "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 rtbhouse/store/interfaces.json from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"pixel.rtbhouse\": {\n \"component\": \"index\"\n }\n}\n\n```" } ]
code_rtbhouse_85c1490d
[ { "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 rtbhouse/react/typings/events.d.ts from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nexport interface PixelMessage extends MessageEvent {\n data:\n | PageInfoData\n | ProductViewData\n | ProductClickData\n | OrderPlacedData\n | PageViewData\n | ProductImpressionData\n | AddToCartData\n | RemoveToCartData\n | InternalSiteSearchViewData\n | CategoryViewData\n | DepartmentData\n}\n\nexport interface EventData {\n event: string\n eventName: string\n currency: string\n}\n\nexport interface PageViewData extends EventData {\n event: 'pageView'\n eventName: 'vtex:pageView'\n pageTitle: string\n pageUrl: string\n referrer: string\n}\n\nexport interface PageInfoData extends EventData {\n event: 'pageInfo'\n eventName: 'vtex:pageInfo'\n eventType: string\n pageUrl: string\n}\n\nexport interface InternalSiteSearchViewData extends EventData {\n event: 'internalSiteSearchView'\n eventName: 'vtex:internalSiteSearchView'\n products: Product[]\n currency: string\n}\n\nexport interface CategoryViewData extends EventData {\n event: 'categoryView'\n eventName: 'vtex:categoryView'\n products: Product[]\n currency: string\n}\n\nexport interface DepartmentData extends EventData {\n event: 'departmentView'\n eventName: 'vtex:departmentView'\n products: Product[]\n currency: string\n}\n\nexport interface AddToCartData extends EventData {\n event: 'addToCart'\n eventName: 'vtex:addToCart'\n items: CartItem[]\n}\n\nexport interface RemoveToCartData extends EventData {\n event: 'removeFromCart'\n eventName: 'vtex:removeFromCart'\n items: CartItem[]\n}\n\nexport interface OrderPlacedData extends Order, EventData {\n event: 'orderPlaced'\n eventName: 'vtex:orderPlaced'\n}\n\nexport interface ProductViewData extends EventData {\n event: 'productView'\n eventName: 'vtex:productView'\n product: Product\n}\n\nexport interface ProductClickData extends EventData {\n event: 'productClick'\n eventName: 'vtex:productClick'\n product: Product\n}\n\nexport interface ProductImpressionData extends EventData {\n event: 'productImpression'\n eventName: 'vtex:productImpression'\n impressions: Impression[]\n product?: Product // deprecated, use impressions list!\n position?: number // deprecated, use impressions list!\n list: string\n}\n\ninterface CartItem {\n skuId: string\n variant: string\n price: number\n name: string\n quantity: number\n productRefId: string\n brand: string\n category: string\n}\n\nexport interface Order {\n currency: string\n accountName: string\n orderGroup: string\n salesChannel: string\n coupon: string\n visitorType: string\n visitorContactInfo: string[]\n visitorAddressState: string\n visitorAddressCountry: string\n visitorAddressPostalCode: string\n transactionId: string\n transactionDate: string\n transactionAffiliation: string\n transactionTotal: number\n transactionShipping: number\n transactionSubtotal: number\n transactionDiscounts: number\n transactionTax: number\n transactionCurrency: string\n transactionPaymentType: PaymentType[]\n transactionShippingMethod: ShippingMethod[]\n transactionProducts: ProductOrder[]\n transactionPayment: {\n id: string\n }\n}\n\nexport interface Impression {\n product: Product\n position: number\n}\n\ninterface PaymentType {\n group: string\n paymentSystemName: string\n installments: number\n value: number\n}\n\ninterface ShippingMethod {\n itemId: string\n selectedSla: string\n}\n\ninterface ProductOrder {\n id: string\n name: string\n sku: string\n skuRefId: string\n skuName: string\n productRefId: string\n ean: string\n slug: string\n brand: string\n brandId: string\n seller: string\n sellerId: string\n category: string\n categoryId: string\n categoryTree: string[]\n categoryIdTree: string[]\n priceTags: PriceTag[]\n originalPrice: number\n price: number\n sellingPrice: number\n tax: number\n quantity: number\n components: any[]\n measurementUnit: string\n unitMultiplier: number\n}\n\ninterface PriceTag {\n identifier: string\n isPercentual: boolean\n value: number\n}\n\ninterface Product {\n brand: string\n categoryId?: string // inconsistency\n categories: string[]\n productId: string\n productName: string\n selectedSku: {\n itemId: string\n } // inconsistency\n items: Item[]\n sku: Item\n [key: string]: any\n}\n\ninterface Item {\n itemId: string\n name: string\n seller?: Seller\n [key: string]: any\n}\n\ninterface Seller {\n commertialOffer: CommertialOffer\n [key: string]: any\n}\n\ninterface CommertialOffer {\n Price: number\n [key: string]: any\n}\n\n```" } ]
code_rtbhouse_17b67cd6
[ { "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 rtbhouse/react/typings/vtex.render-runtime.d.ts from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.render-runtime' {\n export const canUseDOM: boolean\n}\n\n```" } ]
code_rtbhouse_052bceb6
[ { "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 rtbhouse/react/typings/global.d.ts from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\ninterface Window extends Window {\n rtbhouseId: string\n}\n\n```" } ]
code_rtbhouse_9f439885
[ { "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 rtbhouse/react/helpers/index.tsx from the rtbhouse VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { Product } from '../typings/events'\n\nexport function getCategories(products: Product[]) {\n const [categories] = products.map(({ categories: [category] }) =>\n strNormalize(\n category\n .split('/')\n .filter(item => item)\n .join(',')\n )\n )\n return categories\n}\n\nexport function getDepartment(products: Product[]) {\n const [department] = products.map(\n ({ categories: [category] }) =>\n category.split('/').filter(item => item)\n )\n return department\n}\n\nexport function createIframeTag(src: string, id?: string) {\n const iframe = document.createElement('iframe')\n iframe.setAttribute('src', src)\n id && iframe.setAttribute('id', id)\n iframe.setAttribute('width', '1')\n iframe.setAttribute('height', '1')\n iframe.setAttribute('scrolling', '1')\n iframe.setAttribute('frameborder', '0')\n iframe.setAttribute('style', 'display:none')\n document.body.appendChild(iframe)\n}\n\nexport function strNormalize(str: string): string {\n let strNormalized = str.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\")\n return strNormalized\n}\n\n```" } ]
code_omnichannel-order-status_16bfdb89
[ { "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 omnichannel-order-status/messages/pt.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"b2bOrders.link\": \"Pedidos B2B\",\n \"titleOrderDetails\": \"Detalhes do pedido\",\n \"title.OrderPage\": \"Pedido B2B\",\n \"message.results\": \"Nenhum registro encontrado\",\n \"message.error\": \"Erro ao carregar dados. Por favor, tenten novamente.\",\n \"title.searchOrders\": \"Pesquisar por número de pedido\",\n \"title.searchDate\": \"Pesquisar por data\",\n \"label.numberOrderWeb\": \"Número pedido web\",\n \"label.numberDigimess\": \"Número pedido ERP\",\n \"label.myOrder\": \"Meu pedido\",\n \"label.date\": \"Data\",\n \"label.dateUpTo\": \"Até\",\n \"btn.search\": \"Pesquisar\",\n \"table.orderNumber\": \"Númedo do pedido\",\n \"table.orderStatus\": \"Status do pedido\",\n \"table.orderDate\": \"Data do pedido\",\n \"table.orderTotal\": \"Total do pedido\",\n \"table.details\": \"Detalhes\",\n \"table.invoice\": \"Nota fiscal\",\n \"table.name\": \"Nome\",\n \"order.tracking\": \"Rastreamento do pedido\",\n \"order.inAnalysis\": \"Em analise\",\n \"order.waiting\": \"Aguardando\",\n \"order.commercialRelease\": \"Liberação Comercial\",\n \"order.financeRelease\": \"Liberação Financeira\",\n \"order.separation\": \"Separação\",\n \"order.dispatch\": \"Despacho\",\n \"order.delivery\": \"Entrega\",\n \"order.billingAddress\": \"Endereço de cobrança\",\n \"order.deliveryAddress\": \"Endereço de entrega\",\n \"order.otherInformations\": \"Outras informações\",\n \"order.purchaseData\": \"Dados da compra\",\n \"table.price\": \"Preço\",\n \"table.quantity\": \"Quantidade\",\n \"table.freight\": \"Frete\",\n \"title.serviceTax\": \"Serviços & Área fiscal\",\n \"table.city\": \"Cidade\",\n \"table.state\": \"Estado\",\n \"table.address\": \"Endereço\",\n \"table.zipCode\": \"Cep\",\n \"table.methodPayment\": \"Forma de pagamento\",\n \"table.optionPayment\": \"Opção de pagamento\",\n \"label.required\": \"Informe um valor\",\n \"table.deliveryMethod\": \"Método de entrega\",\n \"table.carrierLink\": \"Link da Transportadora\"\n}\n```" } ]
code_omnichannel-order-status_de4e3312
[ { "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 omnichannel-order-status/messages/en.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"b2bOrders.link\": \"Orders B2B\",\n \"titleOrderDetails\": \"Order Details\",\n \"title.OrderPage\": \"Order B2B\",\n \"message.results\": \"No record found\",\n \"message.error\": \"Error on load data. Please, try again.\",\n \"title.searchOrders\": \"Search by order number\",\n \"title.searchDate\": \"Search by date\",\n \"label.numberOrderWeb\": \"Web number order\",\n \"label.numberDigimess\": \"ERP order number\",\n \"label.myOrder\": \"My order\",\n \"label.date\": \"Date\",\n \"label.dateUpTo\": \"Up to\",\n \"btn.search\": \"Search\",\n \"table.orderNumber\": \"Order number\",\n \"table.orderStatus\": \"Order status\",\n \"table.orderDate\": \"Order date\",\n \"table.orderTotal\": \"Order total\",\n \"table.details\": \"Details\",\n \"table.invoice\": \"Invoice\",\n \"table.name\": \"Name\",\n \"order.tracking\": \"Order tracking\",\n \"order.inAnalysis\": \"in analysis\",\n \"order.waiting\": \"Waiting\",\n \"order.commercialRelease\": \"Commercial release\",\n \"order.financeRelease\": \"Finance release\",\n \"order.separation\": \"Separation\",\n \"order.dispatch\": \"Dispatch\",\n \"order.delivery\": \"Delivery\",\n \"order.billingAddress\": \"Billing Address\",\n \"order.deliveryAddress\": \"Delivery Address\",\n \"order.otherInformations\": \"Other Informations\",\n \"order.purchaseData\": \"Purchase Data\",\n \"table.price\": \"Price\",\n \"table.quantity\": \"Quantity\",\n \"table.freight\": \"Freight\",\n \"title.serviceTax\": \"Services & Taxes\",\n \"table.city\": \"City\",\n \"table.state\": \"State\",\n \"table.address\": \"Address\",\n \"table.zipCode\": \"Zip Code\",\n \"table.methodPayment\": \"Payment Method\",\n \"table.optionPayment\": \"Payment information\",\n \"label.required\": \"Fill this field\",\n \"table.deliveryMethod\": \"Delivery Method\",\n \"table.carrierLink\": \"Carrier Link\"\n}\n```" } ]
code_omnichannel-order-status_b6351cc9
[ { "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 omnichannel-order-status/messages/context.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"b2bOrders.link\": \"Orders B2B\",\n \"titleOrderDetails\": \"Orders Details\",\n \"title.OrderPage\": \"Order B2B\",\n \"message.results\": \"No record found\",\n \"message.error\": \"Error on load data. Please, try again.\",\n \"title.searchOrders\": \"Search by order number\",\n \"title.searchDate\": \"Search by date\",\n \"label.numberOrderWeb\": \"Web number order\",\n \"label.numberDigimess\": \"ERP order number\",\n \"label.myOrder\": \"My order\",\n \"label.date\": \"Date\",\n \"label.dateUpTo\": \"Up to\",\n \"btn.search\": \"Search\",\n \"table.orderNumber\": \"Order number\",\n \"table.orderStatus\": \"Order status\",\n \"table.orderDate\": \"Order date\",\n \"table.orderTotal\": \"Order total\",\n \"table.details\": \"Details\",\n \"table.invoice\": \"Invoice\",\n \"table.name\": \"Name\",\n \"order.tracking\": \"Order tracking\",\n \"order.inAnalysis\": \"in analysis\",\n \"order.waiting\": \"Waiting\",\n \"order.commercialRelease\": \"Commercial release\",\n \"order.financeRelease\": \"Finance release\",\n \"order.separation\": \"Separation\",\n \"order.dispatch\": \"Dispatch\",\n \"order.delivery\": \"Delivery\",\n \"order.billingAddress\": \"Billing Address\",\n \"order.deliveryAddress\": \"Delivery Address\",\n \"order.otherInformations\": \"Other Informations\",\n \"order.purchaseData\": \"Purchase Data\",\n \"table.price\": \"Price\",\n \"table.quantity\": \"Quantity\",\n \"table.freight\": \"Freight\",\n \"title.serviceTax\": \"Services & Tax Area\",\n \"table.city\": \"City\",\n \"table.state\": \"State\",\n \"table.address\": \"Address\",\n \"table.zipCode\": \"Zip Code\",\n \"table.methodPayment\": \"Form Payment\",\n \"table.optionPayment\": \"Option Payment\",\n \"label.required\": \"Fill this field\"\n}\n```" } ]
code_omnichannel-order-status_3686e402
[ { "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 omnichannel-order-status/docs/README.md from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```markdown\n# B2B Orders\n\nIn a B2B business model, your company and your partners may need to share selected information, such as order statuses. \n\nFor these scenarios, we recommend that you install and set up the *B2B Orders* app in your VTEX account. \n\nBy communicating with your *Enterprise resource planning (ERP)*, this app allows your business' customers to securely check their order status at any time they want.\n \nFor more information on how to set up the *B2B Orders* app and its related external APIs to the ERP, check the following section.\n\n### Prerequisites - Changes to existing **CL** table\nWe need to add one field to existing **CL** master data table. \n```\ncompanyId: Integer\n```\n\nThis field is an identifier that will be automatically passed when requesting the APIs below. Thus, the endpoints will be able to know which client is involved in the request\n\n> **companyId** field should check following checkboxes \n> **Is nullable**, \n> **Make readable without credential**, \n> **Allow editing without credential**, \n> **Allow filter without credential**, \n> **Is searchable**, \n> **Is filterable**, \n\nDont forget to `save` and `reindex` `CL` table once you add all the fields. \n\n## Install and setup\n\n1. Clone this app using you prefered git app\n\n2. At the manifest.json file, change the value of `policies` -> `attrs` -> `host` setting the hostname of your API. Eg: apivtex.vtex.com.br\n\n3. Using a testing workspace, kink the app using `vtex link` [https://developers.vtex.com/vtex-developer-docs/docs/vtex-io-documentation-linking-an-app]\n\n4. In your browser, access your account's admin as in `https://{workspace}--{accountname}.myvtex.com/admin`.\n\n>⚠️ *Remember to replace the values between the curly brackets according to your scenario.*\n\n5. Under `Account Settings`, go to `Apps > My apps`. Look for the *B2B Orders*.\n\n6. Click on `Settings` to set up the necessary information for communicating with the desired service. That is:\n\n- **Link endpoint** - the endpoint address of the desired service.\n- **Login** - credentials for accessing the service.\n- **Token** - authentication token for accessing the service.\n\n![omnichannel-order](https://user-images.githubusercontent.com/60782333/99416894-17aa0f00-28d8-11eb-8414-28ded9fc2d1e.png)\n\n>⚠️ *So that the *B2B Orders* app can properly work, your ERP API must have different endpoints for each of the following scenarios: order search, order details, order documents. To learn more about it, check the [ERP API requirements](#erp-api-requirements) section.*\n\n7. Save your changes.\n\nOnce your changes are duly saved, a new option, namely **Orders B2B**, will be available in your client's menu, as in the following image:\n\n![client-view](https://user-images.githubusercontent.com/60782333/95912705-83e5a000-0d79-11eb-866c-f6f10832a36f.png)\n\n>⚠️ After you finished you testing API, don't forget to publish and install at your master workspace. Instructions here: https://vtex.io/docs/recipes/development/publishing-an-app\n\n## ERP API requirements\n\nTo facilitate its implementation, the *B2B Orders* app comes with a well-defined pattern for communicating with the ERP API.\n\nThis pattern implies that your company's ERP API has different endpoints for each of the following scenarios: \n\n- Order search.\n- Order details.\n- [OPTIONAL] Order documents.\n\n>⚠️ *For specific needs, not satisfied by the scenarios presented, you might need to customize the B2B Orders.*\n\nIn the following, we present the possible requests and response format for each one of the ERP API's related endpoints.\n\n### Order search\n\nBy exposing the `POST` `api/v1/pedido/pesquisa` endpoint, your company's client will be able to search for orders in the ERP by filling one of the following objects: `porPeriodo`, `porCodigo` or `porNotaFiscal`.\n\n#### Request format\n\n```\n{\n \"revendaId\": number,\n \"porCodigo\": {\n \"codigo\": string,\n \"tipo\": number (PedidoId: 0, PedidoClienteId: 1, PedidoErpId: 2)\n },\n \"porPeriodo\": {\n \"dataInicial\": Date,\n \"dataFim\": Date\n },\n \"porNotaFiscal\": {\n \"notaFiscal\": string,\n \"serieNotaFiscal\": string\n }\n}\n\n```\n\n#### Response format\n\n```\n{\n \"itens\": [\n {\n \"pedidoErpId\": string,\n \"pedidoClienteId\": string,\n \"totalPedido\": number,\n \"status\": number,\n \"dataPedido\": Date,\n \"observacao\": string,\n \"notaFiscal\": string,\n \"serieNotaFiscal\": string,\n }\n ]\n}\n\n```\n\n### Order Details\n\n\nBy exposing the `GET` `api/v1/pedido?pedidoErpId={pedidoErpId}&revendaId={revendaId}` endpoint, your company's client will be able to consult the details of a specific order directly from the ERP.\n\n#### Request format\n\n```\n{\n pedidoErpId: string\n revendaId: number\n}\n\n```\n\n#### Response format\n\n```\n{\n \"pedidoErpId\": string,\n \"status\": integer,\n \"itens\": [\n {\n \"partNumber\": string,\n \"descricaoDoProduto\": string,\n \"quantidade\": decimal number,\n \"valorUnitario\": decimal number,\n \"valorTotal\": decimal number,\n \"comissao\": decimal number\n }\n ],\n \"revendaId\": integer,\n \"clienteFinalId\": string,\n \"clienteFinalCnpj\": string,\n \"clienteFinalCpf\": string,\n \"clienteFinalNome\": string,\n \"valorFrete\": decimal number,\n \"valorTotalPedido\": decimal number,\n \"dataPedido\": Date,\n \"dataPrevisaoEntrega\": Date,\n \"observacao\": string,\n \"notaFiscal\": string\",\n \"serieNotaFiscal\": string,\n \"paymentMethod\": string,\n \"paymentOptions\": string,\n \"linkTransportadora\": string,\n \"billingAddressCorpname\": string,\n \"billingAddressFormattedAddres\": string,\n \"billingAddressCity\": string,\n \"billingAddressState\": string,\n \"billingAddresszipcode\": string,\n \"deliveryAddressCorpname\": string,\n \"deliveryAddressformattedAddres\": string,\n \"deliveryAddressCity\": string,\n \"deliveryAddressState\": string,\n \"deliveryAddresszipcode\": string,\n \"paymentMethod\": string,\n \"paymentOptions\": string,\n \"deliveryMethod\": string,\n \"centrosDeDistribuicao\": [\n {\n \"distributionCenterPrefix\": string,\n \"itens\": [\n {\n \"partNumber\": string,\n \"descricaoDoProduto\": string,\n \"quantidade\": decimal number,\n \"valorUnitario\": decimal number,\n \"valorTotal\": decimal number,\n \"comissao\": decimal number\n }\n ],\n \"valorFrete\": decimal number,\n \"valorTotalCD\": decimal number\n },\n {\n \"distributionCenterPrefix\": string,\n \"itens\": [\n {\n \"partNumber\": string,\n \"descricaoDoProduto\": string,\n \"quantidade\": decimal number,\n \"valorUnitario\": decimal number,\n \"valorTotal\": decimal number,\n \"comissao\": decimal number\n }\n ],\n \"valorFrete\": decimal number,\n \"valorTotalCD\": decimal number\n }\n ]\n}\n\n```\n\n### [OPTIONAL] Order documents\n\nBy exposing the `GET` `api/v1/arquivospedido?pedidoErpId={pedidoErpId}&revendaId={revendaId}` endpoint, your company's client will be able to consult the document files related to a given order by providing the related order number.\n\n#### Request format\n\n```\n{\n pedidoErpId: string\n revendaId: number\n}\n\n```\n\n#### Response format\n\n```\n{\n \"pedidoErpId\": string,\n \"itens\": [\n {\n \"tipoArquivo\": number (SegundaViaBoleto: 0, SegundaViaTransferencia: 1, Xml: 2, Danfe: 3, NumeroDeSerie: 4, GARE: 5, GNRE: 6, Outros: 7),\n \"descricao\": string,\n \"url\": string\"\n },\n {\n \"tipoArquivo\": number,\n \"descricao\": string,\n \"url\": string\"\n }\n ]\n}\n\n```\n\n```" } ]
code_omnichannel-order-status_b497b5a5
[ { "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 omnichannel-order-status/node/service.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"memory\": 256,\n \"ttl\": 10,\n \"timeout\": 10,\n \"minReplicas\": 2,\n \"maxReplicas\": 4,\n \"routes\": {\n \"ordersb2b\": {\n \"path\": \"/_v/ordersb2b/:order\",\n \"public\": true\n },\n \"ordersDate\": {\n \"path\": \"/_v/ordersb2b/date\",\n \"public\": true\n },\n \"ordersFiles\": {\n \"path\": \"/_v/ordersb2b/files/:order\",\n \"public\": true\n }\n }\n}\n\n```" } ]
code_omnichannel-order-status_d744570f
[ { "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 omnichannel-order-status/node/package.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"dependencies\": {\n \"co-body\": \"^6.0.0\",\n \"ramda\": \"^0.25.0\"\n },\n \"devDependencies\": {\n \"@types/co-body\": \"^0.0.3\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"8.x\",\n \"@types/ramda\": \"types/npm-ramda#dist\",\n \"@vtex/api\": \"3.8.1\",\n \"@vtex/test-tools\": \"^1.0.0\",\n \"tslint\": \"^5.14.0\",\n \"tslint-config-vtex\": \"^2.1.0\",\n \"typescript\": \"3.9.7\"\n },\n \"scripts\": {\n \"lint\": \"tsc --noEmit --pretty && tslint -c tslint.json --fix './**/*.ts'\"\n },\n \"version\": \"0.2.0\"\n}\n\n```" } ]
code_omnichannel-order-status_0db5c024
[ { "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 omnichannel-order-status/node/index.ts from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```typescript\nimport { ClientsConfig, Service, ServiceContext } from '@vtex/api'\n\nimport { Clients } from './clients'\nimport {\n ordersMiddleware,\n ordersFilesMiddleware,\n ordersPeriodMiddleware,\n} from './middlewares/orders'\n\nimport { orderValidationMiddleware } from './middlewares/oderValidation'\n\nconst TIMEOUT_MS = 10000\n\nconst clients: ClientsConfig<Clients> = {\n implementation: Clients,\n options: {\n default: {\n retries: 2,\n timeout: TIMEOUT_MS,\n },\n },\n}\n\ndeclare global {\n type Context = ServiceContext<Clients, State>\n interface State {\n order: String\n }\n}\n\n// Export a service that defines route handlers and client options.\nexport default new Service<Clients, State>({\n clients,\n routes: {\n // `status` is the route ID from service.json. It maps to an array of middlewares (or a single handler).\n ordersb2b: [orderValidationMiddleware, ordersMiddleware],\n ordersFiles: [orderValidationMiddleware, ordersFilesMiddleware],\n ordersDate: [ordersPeriodMiddleware],\n },\n})\n\n```" } ]
code_omnichannel-order-status_2240dddf
[ { "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 omnichannel-order-status/react/OrdersB2BPage.tsx from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\n\nimport React, { Fragment } from 'react'\nimport { Route } from 'react-router-dom'\n\n// Your component pages\nimport OrderB2B from './components/OrdersB2B'\nimport OrderDetail from './components/OrderDetails'\n\nconst OrdersB2BPage = () => (\n <Fragment>\n <Route path=\"/b2b-order\" component={OrderB2B}/>\n <Route path=\"/b2b-order-details/:order\" component={OrderDetail}/>\n </Fragment>\n)\n\nexport default OrdersB2BPage\n```" } ]
code_omnichannel-order-status_23d620e6
[ { "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 omnichannel-order-status/react/OrdersB2BLink.tsx from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```tsx\nimport { FunctionComponent } from 'react'\nimport { InjectedIntlProps, injectIntl } from 'react-intl'\n\nconst OrdersB2BLink: FunctionComponent<Props> = ({ render, intl }) => {\n return render([\n {\n name: intl.formatMessage({\n id: 'b2bOrders.link',\n }),\n path: '/b2b-order',\n },\n ])\n}\n\ninterface Props extends InjectedIntlProps {\n render: (args: { name: string; path: string }[]) => any\n}\n\nexport default injectIntl(OrdersB2BLink)\n```" } ]
code_omnichannel-order-status_5ee6b501
[ { "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 omnichannel-order-status/react/package.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"scripts\": {\n \"test\": \"vtex-test-tools test\",\n \"lint\": \"tsc --noEmit && eslint --ext js,ts,tsx .\",\n \"format\": \"prettier --write \\\"**/*.{ts,js,json}\\\"\"\n },\n \"dependencies\": {\n \"@vtex/css-handles\": \"^1.0.0\",\n \"@vtex/styleguide\": \"^9.135.4\",\n \"axios\": \"^0.19.2\",\n \"classnames\": \"^2.2.6\",\n \"ramda\": \"^0.26.1\",\n \"react\": \"^16.8.3\",\n \"react-apollo\": \"^3.1.3\",\n \"react-dom\": \"^16.8.3\",\n \"react-intl\": \"^2.7.2\",\n \"react-router-dom\": \"^4.3.1\"\n },\n \"devDependencies\": {\n \"@types/classnames\": \"^2.2.7\",\n \"@types/jest\": \"^24.0.18\",\n \"@types/node\": \"^12.7.5\",\n \"@types/prop-types\": \"^15.7.0\",\n \"@types/ramda\": \"^0.26.5\",\n \"@types/react\": \"^16.9.2\",\n \"@types/react-datepicker\": \"^2.11.0\",\n \"@types/react-router-dom\": \"^5.1.5\",\n \"@vtex/test-tools\": \"^1.1.0\",\n \"apollo-client\": \"^2.5.1\",\n \"eslint\": \"^5.16.0\",\n \"eslint-config-vtex-react\": \"^4.1.0\",\n \"@vtex/prettier-config\": \"^0.1.3\",\n \"tslint-eslint-rules\": \"^5.4.0\",\n \"typescript\": \"3.9.7\",\n \"vtex.css-handles\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.css-handles@0.4.2/public/@types/vtex.css-handles\",\n \"vtex.render-runtime\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.render-runtime@8.94.0/public/@types/vtex.render-runtime\",\n \"vtex.styleguide\": \"http://vtex.vtexassets.com/_v/public/typings/v1/vtex.styleguide@9.135.4/public/@types/vtex.styleguide\"\n },\n \"version\": \"0.2.0\"\n}\n\n```" } ]
code_omnichannel-order-status_a388d044
[ { "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 omnichannel-order-status/store/interfaces.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"my-account-link.orders-b2b-link\": {\n \"component\": \"OrdersB2BLink\"\n },\n \"my-account-link.orders-b2b-page\": {\n \"component\": \"OrdersB2BPage\"\n }\n}\n```" } ]
code_omnichannel-order-status_2cbe4afa
[ { "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 omnichannel-order-status/store/plugins.json from the omnichannel-order-status VTEX app." }, { "role": "assistant", "content": "Here's the implementation:\n\n```json\n{\n \"my-account-menu > my-account-link\": \"my-account-link.orders-b2b-link\",\n \"my-account-pages > my-account-page\": \"my-account-link.orders-b2b-page\"\n}\n```" } ]