id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_store-on-localhost_686f18bf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/ColorPicker/Alpha.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport { CustomPicker } from 'react-color'\nimport PropTypes from 'prop-types'\nimport { Alpha } from 'react-color/lib/components/common'\n\n/**\n * AlphaComponent to control alpha level\n */\nclass AlphaCustom extends React.Component {\n render() {\n const { rgb, hsl, hex, onChange } = this.props\n return (\n <div className=\"gradient-container relative w-100 mv6 alpha\">\n <Alpha\n rgb={rgb}\n hsl={hsl}\n onChange={onChange}\n pointer={() => (\n <div className=\"pointer-gradient\" style={{ background: hex }} />\n )}\n />\n </div>\n )\n }\n}\n\nAlphaCustom.propTypes = {\n /** onChange event */\n onChange: PropTypes.func.isRequired,\n /** Hex Color string */\n hex: PropTypes.string.isRequired,\n /** RGB color object */\n rgb: PropTypes.object.isRequired,\n /** HSL color object */\n hsl: PropTypes.object.isRequired,\n}\n\nexport default CustomPicker(AlphaCustom)\n\n```"
}
] |
code_store-on-localhost_66a01850
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/ColorPicker/HSVInput.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport colorutil from './colorUtil'\nimport Input from '../Input'\n\n/** HSVInput component */\nclass HSVInput extends React.Component {\n getValue = event => {\n const max = Number(event.target.max)\n const min = Number(event.target.min)\n let value = Number(event.target.value)\n\n if (value > max) value = max\n if (value < min) value = min\n\n return value\n }\n\n handleChange = (event, key) => {\n const value = this.getValue(event)\n\n const hsv = { ...this.props.color, [key]: value }\n const rgb = colorutil.hsv.to.rgb(hsv)\n const hex = colorutil.rgb.to.hex(rgb)\n\n this.props.onChange({\n rgb,\n hex,\n hsv,\n })\n }\n render() {\n return (\n <div className=\"mv3\">\n <div className=\"relative flex\">\n <div className=\"ph2 w-25\">\n <Input\n label=\"H\"\n size=\"small\"\n type=\"number\"\n min=\"0\"\n max=\"360\"\n step=\"0.000000000001\"\n value={this.props.color.h}\n onChange={e => this.handleChange(e, 'h')}\n />\n </div>\n <div className=\"ph2 w-25\">\n <Input\n label=\"S\"\n size=\"small\"\n type=\"number\"\n min=\"0\"\n max=\"1\"\n step=\"0.000000000001\"\n value={this.props.color.s}\n onChange={e => this.handleChange(e, 's')}\n />\n </div>\n <div className=\"ph2 w-25\">\n <Input\n label=\"V\"\n size=\"small\"\n type=\"number\"\n min=\"0\"\n max=\"1\"\n step=\"0.000000000001\"\n value={this.props.color.v}\n onChange={e => this.handleChange(e, 'v')}\n />\n </div>\n <div className=\"ph2 w-25\">\n <Input\n label=\"A\"\n size=\"small\"\n type=\"number\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n value={this.props.color.a}\n onChange={e => this.handleChange(e, 'a')}\n />\n </div>\n </div>\n </div>\n )\n }\n}\n\nHSVInput.propTypes = {\n /** onChange event */\n onChange: PropTypes.func.isRequired,\n /** Color input */\n color: PropTypes.object,\n}\n\nexport default HSVInput\n\n```"
}
] |
code_store-on-localhost_2615837f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/PasswordInput/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport InputPassword from '../InputPassword'\nimport deprecated from '../../modules/deprecated'\n\nexport default deprecated({\n useNewComponent: {\n old: 'PasswordInput',\n new: 'InputPassword',\n },\n})(InputPassword)\n\n```"
}
] |
code_store-on-localhost_0b648087
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport PropTypes, { InferProps } from 'prop-types'\n\nimport Toolbar from '../EXPERIMENTAL_Table/Toolbar'\nimport DataTable from '../EXPERIMENTAL_Table/DataTable'\nimport Tree from './Tree'\nimport { tablePropTypes, TableComposites } from '../EXPERIMENTAL_Table'\nimport Pagination from '../EXPERIMENTAL_Table/Pagination'\nimport FilterBar from '../EXPERIMENTAL_Table/FilterBar'\nimport { Checkboxes } from '../EXPERIMENTAL_useCheckboxTree/types'\nimport { defaultComparatorCurry } from '../EXPERIMENTAL_useCheckboxTree/constants'\nimport Headings from '../EXPERIMENTAL_Table/DataTable/Headings'\nimport useTableMotion from '../EXPERIMENTAL_Table/hooks/useTableMotion'\n\nconst CONTAINER_TRANSITIONS = [\n {\n prop: 'minHeight',\n duration: 200,\n func: 'ease-in-out',\n delay: 0,\n optimize: true,\n },\n]\n\nconst TableTree: FC<Props> & TableComposites = ({\n children,\n columns,\n items,\n checkboxes,\n nodesKey,\n comparator,\n measures,\n loading,\n empty,\n emptyState,\n onRowClick,\n}) => {\n if (!measures) {\n throw new Error('Provide measures to the TableTree')\n }\n\n const { tableHeight, rowHeight, currentDensity } = measures\n const motion = useTableMotion(CONTAINER_TRANSITIONS)\n\n return (\n <div style={{ minHeight: tableHeight }} className=\"flex flex-column\">\n {children}\n <DataTable\n loading={loading}\n emptyState={emptyState}\n empty={empty}\n motion={motion}\n height={tableHeight}>\n <thead className=\"w-100 ph4 truncate overflow-x-hidden c-muted-2 f6\">\n <Headings checkboxes={checkboxes} columns={columns} />\n </thead>\n {!empty && !loading && (\n <tbody>\n <Tree\n currentDensity={currentDensity}\n checkboxes={checkboxes}\n columns={columns}\n items={items}\n onRowClick={onRowClick}\n comparator={comparator}\n nodesKey={nodesKey}\n rowHeight={rowHeight}\n />\n </tbody>\n )}\n </DataTable>\n </div>\n )\n}\n\nTableTree.defaultProps = {\n nodesKey: 'children',\n comparator: defaultComparatorCurry,\n}\n\nconst treePropTypes = {\n nodesKey: PropTypes.string,\n comparator: PropTypes.func,\n}\n\nconst propTypes = {\n ...treePropTypes,\n ...tablePropTypes,\n}\n\ntype Props = InferProps<typeof propTypes> & {\n checkboxes?: Checkboxes<unknown>\n}\n\nTableTree.Toolbar = Toolbar\nTableTree.FilterBar = FilterBar\nTableTree.Pagination = Pagination\nTableTree.propTypes = propTypes\n\nexport type TreeState = {\n collapsedItems: Array<string>\n toggleCollapsed: (id: string) => void\n isCollapsed: (id: string) => boolean\n}\n\nexport default TableTree\n\n```"
}
] |
code_store-on-localhost_d3f76f68
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### NodesKey Prop\n\n```js\nconst useTableMeasures = require('../EXPERIMENTAL_Table/hooks/useTableMeasures.tsx')\n .default\nconst sampleData = require('./sampleData.ts').default\n\n// Define the columns\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n width: 300,\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'number',\n title: 'Number',\n },\n {\n id: 'country',\n title: 'Country',\n },\n]\n\n// Define the items\nconst items = sampleData\n\nfunction ToolbarExample() {\n const measures = useTableMeasures({\n size: items.length,\n })\n\n const comparator = item => candidate => {\n return item.email === candidate.email\n }\n\n const onRowClick = ({ rowData }) => {\n console.log(rowData)\n }\n\n return (\n <TableTree\n onRowClick={onRowClick}\n comparator={comparator}\n measures={measures}\n columns={columns}\n items={items}\n nodesKey=\"children\"\n />\n )\n}\n;<ToolbarExample />\n```\n\n#### Checkboxes\n\n```js\nconst useTableMeasures = require('../EXPERIMENTAL_Table/hooks/useTableMeasures.tsx')\n .default\nconst sampleData = require('./sampleData.ts').default\nconst useCheckboxTree = require('../EXPERIMENTAL_useCheckboxTree').default\n\n// Define the columns\nconst columns = [\n {\n id: 'name',\n title: 'name',\n width: 300,\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'number',\n title: 'Number',\n },\n {\n id: 'country',\n title: 'Country',\n },\n]\n\nconst items = [\n {\n name: \"T'Chala\",\n email: 'black.panther@gmail.com',\n number: 1.88191,\n country: '🇰🇪Wakanda',\n },\n {\n name: 'Shang-Chi',\n email: 'kungfu.master@gmail.com',\n number: 39.09222,\n country: '🇨🇳China',\n children: [],\n },\n {\n name: 'Natasha Romanoff',\n email: 'black.widow@gmail.com',\n number: 5.09291,\n country: '🇷🇺Russia',\n },\n {\n name: 'Peter Parker',\n email: 'spider.man@gmail.com',\n country: '🇺🇸USA',\n children: [\n {\n name: 'Aunt May',\n email: 'may.parker@gmail.com',\n country: '🇺🇸USA',\n },\n ],\n },\n]\n\nfunction Example() {\n const [inputValue, setInputValue] = React.useState('')\n\n const comparator = item => candidate => {\n return item.email === candidate.email\n }\n\n const onToggle = ({ checkedItems }) => {\n console.log(checkedItems)\n }\n\n const checkboxes = useCheckboxTree({\n comparator,\n items,\n onToggle,\n })\n\n const measures = useTableMeasures({\n size: items.length,\n })\n\n return (\n <TableTree\n comparator={comparator}\n checkboxes={checkboxes}\n columns={columns}\n items={checkboxes.itemTree}\n measures={measures}\n />\n )\n}\n;<Example />\n```\n\n#### Full Example\n\n```js\nconst useTableMeasures = require('../EXPERIMENTAL_Table/hooks/useTableMeasures.tsx')\n .default\nconst useTableVisibility = require('../EXPERIMENTAL_Table/hooks/useTableVisibility.ts')\n .default\nconst sampleData = require('./sampleData.ts').default\nconst useCheckboxTree = require('../EXPERIMENTAL_useCheckboxTree').default\n\n// Define the columns\nconst columns = [\n {\n id: 'name',\n title: 'Description',\n width: 350,\n cellRenderer: ({ rowHeight, data }) => (\n <span>\n <Image size={rowHeight - 10} />\n <span className=\"ph4\">{data}</span>\n </span>\n ),\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'number',\n title: 'Number',\n },\n {\n id: 'country',\n title: 'Country',\n },\n]\n\n// Define the items\nconst items = sampleData\n\nfunction Image({ size }) {\n return (\n <div className=\"dib v-mid\">\n <svg\n width={size}\n height={size}\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\">\n <rect width={size} height={size} rx=\"4\" fill=\"#AAAAAA\" />\n </svg>\n </div>\n )\n}\n\nfunction ToolbarExample() {\n const [inputValue, setInputValue] = React.useState('')\n const [displayItems, setDisplayItems] = React.useState(items)\n\n const onToggle = ({ checkedItems }) => {\n console.log(checkedItems)\n }\n\n const comparator = item => candidate => {\n return item.email === candidate.email\n }\n\n const checkboxes = useCheckboxTree({\n items,\n onToggle,\n comparator,\n checked: [\n {\n name: \"T'Chala\",\n email: 'black.panther@gmail.com',\n number: 1.88191,\n country: '🇰🇪Wakanda',\n },\n {\n name: 'Harry Osbourne',\n email: 'harry@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Green Goblin',\n email: 'norman.green@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Aunt May',\n email: 'may.parker@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Uncle Ben',\n email: 'ben.parker@gmail.com',\n country: '🇺🇸USA',\n },\n ],\n })\n\n const measures = useTableMeasures({\n size: items.length,\n })\n\n const visibility = useTableVisibility({\n columns,\n })\n\n const emptyState = {\n label: 'The table is empty',\n }\n\n const inputSearch = {\n value: inputValue,\n placeholder: 'Search stuff...',\n onChange: e => setInputValue(e.currentTarget.value),\n onClear: () => {\n setInputValue('')\n setDisplayItems(items)\n },\n onSubmit: e => {\n e.preventDefault()\n const isInputClear = inputValue === ''\n const filterFn = item =>\n item.name.toLowerCase().includes(inputValue.toLowerCase())\n setDisplayItems(isInputClear ? items : items.filter(filterFn))\n },\n }\n\n const buttonColumns = {\n label: 'Toggle visible fields',\n showAllLabel: 'Show All',\n hideAllLabel: 'Hide All',\n }\n\n const density = {\n label: 'Line density',\n compactLabel: 'Compact',\n regularLabel: 'Regular',\n comfortableLabel: 'Comfortable',\n }\n\n const download = {\n label: 'Export',\n onClick: () => alert('Clicked EXPORT'),\n }\n\n const upload = {\n label: 'Import',\n onClick: () => alert('Clicked IMPORT'),\n }\n\n const extraActions = {\n label: 'More options',\n actions: [\n {\n label: 'An action',\n onClick: () => alert('An action'),\n },\n {\n label: 'Another action',\n onClick: () => alert('Another action'),\n },\n {\n label: 'A third action',\n onClick: () => alert('A third action'),\n },\n ],\n }\n\n const newLine = {\n label: 'New',\n onClick: () => alert('handle new line callback'),\n actions: [\n 'General',\n 'Desktop & Screen Saver',\n 'Dock',\n 'Language & Region',\n ].map(label => ({\n label,\n onClick: () => alert(`Clicked ${label}`),\n })),\n }\n\n const empty = React.useMemo(\n () =>\n displayItems.length === 0 ||\n Object.keys(visibility.visibleColumns).length === 0,\n [visibility.visibleColumns, displayItems]\n )\n\n return (\n <TableTree\n comparator={comparator}\n checkboxes={checkboxes}\n columns={visibility.visibleColumns}\n items={checkboxes.itemTree}\n empty={empty}\n emptyState={emptyState}\n measures={measures}>\n <TableTree.Toolbar>\n <TableTree.Toolbar.InputSearch {...inputSearch} />\n <TableTree.Toolbar.ButtonGroup>\n <TableTree.Toolbar.ButtonGroup.Columns\n visibility={visibility}\n {...buttonColumns}\n />\n <TableTree.Toolbar.ButtonGroup.Density\n density={measures}\n {...density}\n />\n <TableTree.Toolbar.ButtonGroup.Download {...download} />\n <TableTree.Toolbar.ButtonGroup.Upload {...upload} />\n <TableTree.Toolbar.ButtonGroup.ExtraActions {...extraActions} />\n <TableTree.Toolbar.ButtonGroup.NewLine {...newLine} />\n </TableTree.Toolbar.ButtonGroup>\n </TableTree.Toolbar>\n </TableTree>\n )\n}\n;<ToolbarExample />\n```\n\n```"
}
] |
code_store-on-localhost_aee77386
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/sampleData.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport default [\n {\n name: \"T'Chala\",\n email: 'black.panther@gmail.com',\n number: 1.88191,\n country: '🇰🇪Wakanda',\n },\n {\n name: 'Shang-Chi',\n email: 'kungfu.master@gmail.com',\n number: 39.09222,\n country: '🇨🇳China',\n },\n {\n name: 'Natasha Romanoff',\n email: 'black.widow@gmail.com',\n number: 5.09291,\n country: '🇷🇺Russia',\n },\n {\n name: 'Peter Parker',\n email: 'spider.man@gmail.com',\n country: '🇺🇸USA',\n children: [\n {\n name: 'Aunt May',\n email: 'may.parker@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Uncle Ben',\n email: 'ben.parker@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Marry Jane',\n email: 'mjaaay@gmail.com',\n country: '🇺🇸USA',\n children: [\n {\n name: 'Harry Osbourne',\n email: 'harry@gmail.com',\n country: '🇺🇸USA',\n },\n {\n name: 'Normal Osbourne',\n email: 'norman@gmail.com',\n country: '🇺🇸USA',\n children: [\n {\n name: 'Green Goblin',\n email: 'norman.green@gmail.com',\n country: '🇺🇸USA',\n },\n ],\n },\n ],\n },\n ],\n },\n {\n name: 'Stephen Strange',\n country: '🇺🇸USA',\n number: 121.414,\n email: 'dr.strange@marvel.com',\n },\n {\n name: 'Steve Rogers',\n country: '🇺🇸USA',\n number: 133.313,\n email: 'capitain.america@marvel.com',\n },\n {\n name: 'Abdul Alhazred',\n country: '🇸🇦Saudi Arabia',\n number: 221.553,\n email: 'abdul@marvel.com',\n },\n {\n name: 'Carol Danvers',\n country: '🇺🇸USA',\n number: 8850.414,\n email: 'cap@marvel.com',\n },\n {\n name: 'Scott Lang',\n country: '🇺🇸USA',\n number: 313.777,\n email: 'ant.man@gmail.com',\n },\n {\n name: 'En Sabah Nuh',\n country: '🇨🇺Cuba',\n number: 471.3131,\n email: 'sabah.nuh@marvel.com',\n },\n {\n name: 'Abdul Qamar',\n country: '🇸🇦Saudi Arabia',\n number: 959.533,\n email: 'qamar@hotmail.com',\n },\n {\n name: 'Goose the Cat',\n country: '🇺🇸USA',\n number: 884.2121,\n email: 'dangerous@marvel.com',\n },\n {\n name: 'Brian Braddock',\n country: '🇬🇧Great Britain',\n number: 18841.3131,\n email: 'cap.britain@marvel.com',\n },\n {\n name: 'Marc Spector',\n country: '🇺🇸USA',\n number: 991.313,\n email: 'spector@gmail.com',\n },\n {\n name: 'John Walker',\n country: '🇺🇸USA',\n number: 9193.1313,\n email: 'im.faded@gmail.com',\n },\n {\n name: 'Dane Whitman',\n country: '🇺🇸USA',\n number: 9819.333,\n email: 'dane@marvel.com',\n },\n]\n\n```"
}
] |
code_store-on-localhost_c8260a4f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/ActionMenu/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport ButtonWithIcon from '../ButtonWithIcon'\nimport IconCaretDown from '../icon/CaretDown'\nimport Menu from '../Menu'\n\nclass ActionMenu extends Component {\n constructor(props) {\n super(props)\n this.container = React.createRef()\n this.menu = React.createRef()\n this.state = {\n isMenuOpen: false,\n }\n }\n\n openMenu = () => {\n if (this.state.isMenuOpen) return\n\n document.addEventListener('mousedown', this.handleClickOutside)\n this.setState({ isMenuOpen: true })\n }\n\n closeMenu = () => {\n if (!this.state.isMenuOpen) return\n\n document.removeEventListener('mousedown', this.handleClickOutside)\n this.setState({ isMenuOpen: false })\n }\n\n handleClick = () => {\n if (!this.state.isMenuOpen) {\n this.openMenu()\n } else {\n this.closeMenu()\n }\n }\n\n isClickOutsideMenu = target =>\n this.menu && this.menu.current && !this.menu.current.contains(target)\n\n isClickOutsideContainer = target =>\n this.container &&\n this.container.current &&\n !this.container.current.contains(target)\n\n isClickOutside = target =>\n this.isClickOutsideContainer(target) && this.isClickOutsideMenu(target)\n\n handleClickOutside = e => {\n if (this.isClickOutside(e.target) && this.state.isMenuOpen) {\n this.closeMenu()\n }\n }\n\n componentWillUnmount() {\n if (this.state.isMenuOpen) {\n this.closeMenu()\n }\n }\n\n render() {\n const {\n icon,\n label,\n options,\n menuWidth,\n align,\n buttonProps,\n hideCaretIcon,\n shouldCloseOnClick,\n isGrouped,\n isFirstOfGroup,\n isLastOfGroup,\n isActiveOfGroup,\n } = this.props\n\n const { isMenuOpen } = this.state\n\n const iconCaret = <IconCaretDown size={12} color=\"currentColor\" />\n\n return (\n <div ref={this.container}>\n <Menu\n ref={this.menu}\n open={isMenuOpen}\n align={align}\n width={menuWidth}\n options={options}\n onClose={shouldCloseOnClick ? this.closeMenu : null}>\n <ButtonWithIcon\n {...{\n icon:\n icon ||\n (!label && !hideCaretIcon ? iconCaret : <React.Fragment />),\n }}\n {...buttonProps}\n isGrouped={isGrouped}\n isFirstOfGroup={isFirstOfGroup}\n isLastOfGroup={isLastOfGroup}\n isActiveOfGroup={isActiveOfGroup}\n onClick={this.handleClick}>\n {label && (\n <span className=\"flex align-baseline items-center\">\n <span className={`${hideCaretIcon ? '' : 'mr3'}`}>{label}</span>\n {!hideCaretIcon && <span>{iconCaret}</span>}\n </span>\n )}\n </ButtonWithIcon>\n </Menu>\n </div>\n )\n }\n}\n\nActionMenu.defaultProps = {\n options: [],\n align: 'right',\n hideCaretIcon: false,\n menuWidth: 292,\n shouldCloseOnClick: true,\n isGrouped: false,\n isFirstOfGroup: false,\n isLastOfGroup: false,\n isActiveOfGroup: false,\n}\n\nActionMenu.propTypes = {\n /** Menu alignment in relation to the button*/\n align: PropTypes.oneOf(['right', 'left']),\n /** If should close the menu after clicking an option */\n shouldCloseOnClick: PropTypes.bool,\n /** Respecting ButtonWithIcon props contract. For more info, see:\n * https://styleguide.vtex.com/#/Components/Forms/Button\n */\n // TODO: match ButtonWithIcon prop types\n buttonProps: PropTypes.object,\n /** @deprecated Button icon: use buttonProps instead */\n icon: PropTypes.element,\n /** Button text label */\n label: PropTypes.node,\n /** Hide the automatic caret icon */\n hideCaretIcon: PropTypes.bool,\n /** Menu width*/\n menuWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n /** Menu options */\n options: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.node,\n handleCallback: PropTypes.func,\n /** whether option has inline toggle */\n toggle: PropTypes.shape({\n checked: PropTypes.bool,\n semantic: PropTypes.bool,\n }),\n })\n ).isRequired,\n /** */\n isGrouped: PropTypes.bool,\n /** */\n isFirstOfGroup: PropTypes.bool,\n /** */\n isLastOfGroup: PropTypes.bool,\n /** */\n isActiveOfGroup: PropTypes.bool,\n}\n\nexport default ActionMenu\n\n```"
}
] |
code_store-on-localhost_6bbffba1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/ActionMenu/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### Action Menus are contextual menus that let the user chose and execute actions from a list.\n\n### 👍 Dos\n\n- Use _isDangerous_ for destructive actions that delete data or lead to a state that is hard to recover. Danger buttons should always have a confirmation dialog.\n\n### 👎 Don'ts\n\n- It's OK to hide the caret when using the OptionsDots icon, but avoid otherwise. It's important to signify that this button behaves differently than normal ones.\n\nUsing button variations\n\n```js\nconst options = [\n {\n label: 'Open pod doors, HAL',\n onClick: () => alert('I’m sorry, Dave. I’m afraid I can’t do that.'),\n },\n {\n label: 'Have you heard about the word?',\n onClick: () => alert('sure, everybody knows that the bird is the word...'),\n },\n {\n label: 'Hey look',\n onClick: () => alert('Listen!'),\n },\n {\n label: 'Quit now and cake will be served',\n isDangerous: 'true',\n onClick: () => alert('The cake is a lie'),\n },\n]\n\n;<div className=\"flex\">\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'primary',\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'secondary',\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'tertiary',\n }}\n options={options}\n />\n </div>\n </div>\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'primary',\n disabled: true,\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'secondary',\n disabled: true,\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n buttonProps={{\n variation: 'tertiary',\n disabled: true,\n }}\n options={options}\n />\n </div>\n </div>\n</div>\n```\n\nWith icons\n\n```js\nconst OptionsDots = require('../icon/OptionsDots').default\nconst Cog = require('../icon/Cog').default\n\nconst options = [\n 'General',\n 'Desktop & Screen Saver',\n 'Dock',\n 'Language & Region',\n 'Security & Privacy',\n 'Notifications',\n 'Displays',\n 'Energy Saver',\n 'Keyboard',\n 'Mouse',\n 'Trackpad',\n 'Pronters & Scanners',\n 'Sound',\n 'Startup Disk',\n 'Internet Accounts',\n 'Software Update',\n 'Network',\n 'Bluetooth',\n 'Extensions',\n 'Sharing',\n 'Users & Groups',\n 'Parental Controls',\n 'Date & Time',\n 'Accessibility',\n].map(label => ({\n label,\n onClick: () => {},\n}))\n\n;<div className=\"flex\">\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'primary',\n icon: <Cog color=\"currentColor\" />,\n }}\n label=\"Settings\"\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'tertiary',\n icon: <Cog color=\"currentColor\" />,\n }}\n label=\"Settings\"\n options={options}\n />\n </div>\n </div>\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n hideCaretIcon\n buttonProps={{\n variation: 'primary',\n icon: <OptionsDots color=\"currentColor\" />,\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n hideCaretIcon\n buttonProps={{\n variation: 'tertiary',\n icon: <OptionsDots color=\"currentColor\" />,\n }}\n options={options}\n />\n </div>\n </div>\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n hideCaretIcon\n buttonProps={{\n variation: 'primary',\n icon: <OptionsDots color=\"currentColor\" />,\n iconPosition: 'right',\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"Actions\"\n hideCaretIcon\n buttonProps={{\n variation: 'tertiary',\n icon: <OptionsDots color=\"currentColor\" />,\n iconPosition: 'right',\n }}\n options={options}\n />\n </div>\n </div>\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'primary',\n icon: <OptionsDots color=\"currentColor\" />,\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'tertiary',\n icon: <OptionsDots color=\"currentColor\" />,\n }}\n options={options}\n />\n </div>\n </div>\n <div className=\"flex flex-column\">\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'primary',\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n buttonProps={{\n variation: 'tertiary',\n }}\n options={options}\n />\n </div>\n </div>\n</div>\n```\n\nMenu Alignment\n\n```js\nconst options = [\n {\n label: 'Open pod doors, HAL',\n onClick: () => alert('I’m sorry, Dave. I’m afraid I can’t do that.'),\n },\n {\n label: 'Have you heard about the word?',\n onClick: () => alert('sure, everybody knows that the bird is the word...'),\n },\n {\n label: 'Hey look',\n onClick: () => alert('Listen!'),\n },\n {\n label: 'Quit now and cake will be served',\n isDangerous: 'true',\n onClick: () => alert('The cake is a lie'),\n },\n]\n\n;<div className=\"flex items-center\">\n <div className=\"ma3\">\n <ActionMenu\n label=\"left-aligned\"\n align=\"left\"\n buttonProps={{\n variation: 'primary',\n }}\n options={options}\n />\n </div>\n <div className=\"ma3\">\n <ActionMenu\n label=\"right-aligned\"\n align=\"right\"\n buttonProps={{\n variation: 'primary',\n }}\n options={options}\n />\n </div>\n</div>\n```\n\n```"
}
] |
code_store-on-localhost_fd686654
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/InputPassword/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Input from '../Input'\nimport VisibilityOn from '../icon/VisibilityOn'\nimport VisibilityOff from '../icon/VisibilityOff'\nimport { withForwardedRef, refShape } from '../../modules/withForwardedRef'\n\nclass InputPassword extends Component {\n static iconSizes = {\n small: 14,\n default: 16,\n large: 18,\n 'x-large': 22,\n }\n state = {\n showPassword: false,\n }\n\n toggle = () => this.setState(state => ({ showPassword: !state.showPassword }))\n\n render() {\n const iconSize =\n InputPassword.iconSizes[this.props.size] ||\n InputPassword.iconSizes.default\n\n return (\n <Input\n {...this.props}\n type={this.state.showPassword ? 'text' : 'password'}\n token\n spellCheck=\"false\"\n suffix={\n <span className=\"pointer pt2\" onClick={() => this.toggle()}>\n {this.state.showPassword ? (\n <VisibilityOff solid size={iconSize} />\n ) : (\n <VisibilityOn solid size={iconSize} />\n )}\n </span>\n }\n />\n )\n }\n}\n\nInputPassword.propTypes = {\n /** @ignore Forwarded Ref */\n forwardedRef: refShape,\n onChange: PropTypes.func,\n size: PropTypes.string,\n value: PropTypes.string,\n}\n\nexport default withForwardedRef(InputPassword)\n\n```"
}
] |
code_store-on-localhost_87aca3a5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/InputPassword/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n```js\ninitialState = { value1: 'Passw0rd', value2: 'Passw0rd', value3: 'Passw0rd' }\n;<div>\n <form\n className=\"mb5\"\n onSubmit={e => {\n e.preventDefault()\n console.log(state.value2)\n }}\n >\n <InputPassword\n value={state.value2}\n size=\"large\"\n onChange={e => setState({ value2: e.target.value })}\n onSubmit={e => {\n e.preventDefault()\n console.log(state.value2)\n }}\n />\n </form>\n</div>\n```\n\n```"
}
] |
code_store-on-localhost_90253d13
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\nUsage:\n\n- VTEX IO: <span className=\"c-muted-1\">`import <IconName> from 'vtex.styleguide'`</span>\n- npm: <span className=\"c-muted-1\">`import <IconName> from '@vtex/styleguide/lib/icon/<IconName>'`</span>\n\n```js\n/*\n The following code is just for the table above to be rendered.\n To use the Icon components one need only to import and instanciate it.\n\n Usage:\n * VTEX IO: import <IconName> from 'vtex.styleguide'\n * npm: import <IconName> from '@vtex/styleguide/lib/icon/<IconName>'\n\n !!!!!! DO NOT IMPORT LIKE BELOW !!!!!!\n*/\n\nconst ICONS = {\n ArrowBack: require('./ArrowBack').default,\n ArrowDown: require('./ArrowDown').default,\n ArrowUp: require('./ArrowUp').default,\n Bars: require('./Bars').default,\n Calendar: require('./Calendar').default,\n CaretDown: require('./CaretDown').default,\n CaretLeft: require('./CaretLeft').default,\n CaretRight: require('./CaretRight').default,\n CaretUp: require('./CaretUp').default,\n Check: require('./Check').default,\n Clear: require('./Clear').default,\n Clock: require('./Clock').default,\n Close: require('./Close').default,\n Cog: require('./Cog').default,\n Columns: require('./Columns').default,\n Copy: require('./Copy').default,\n Delete: require('./Delete').default,\n Deny: require('./Deny').default,\n Minus: require('./Minus').default,\n Density: require('./Density').default,\n Download: require('./Download').default,\n Edit: require('./Edit').default,\n ExternalLink: require('./ExternalLink').default,\n ExternalLinkMini: require('./ExternalLinkMini').default,\n Failure: require('./Failure').default,\n Filter: require('./Filter').default,\n Grid: require('./Grid').default,\n Help: require('./Help').default,\n InlineGrid: require('./InlineGrid').default,\n Link: require('./Link').default,\n OptionsDots: require('./OptionsDots').default,\n Plus: require('./Plus').default,\n PlusLines: require('./PlusLines').default,\n Printer: require('./Printer').default,\n Save: require('./Save').default,\n Search: require('./Search').default,\n ShoppingCart: require('./ShoppingCart').default,\n Success: require('./Success').default,\n TableFilter: require('./TableFilter').default,\n Upload: require('./Upload').default,\n User: require('./User').default,\n VisibilityOff: require('./VisibilityOff').default,\n VisibilityOn: require('./VisibilityOn').default,\n Warning: require('./Warning').default,\n Info: require('./Info').default,\n}\nconst DEMO_SIZE = 20\nconst DEMO_LABEL = 'pb3 code c-muted-1 f6'\nconst TOTAL_ICONS_PER_LINE = 6\nclass IconsTable extends React.PureComponent {\n render() {\n const completeIconsArray = Object.keys(ICONS).sort((a, b) =>\n a < b ? -1 : a > b ? 1 : 0\n )\n const totalLines = Math.ceil(\n completeIconsArray.length / TOTAL_ICONS_PER_LINE\n )\n const chunkedIconsMatrix = []\n for (var i = 0; i < totalLines; i++) {\n const rangeStart = TOTAL_ICONS_PER_LINE * i\n chunkedIconsMatrix[i] = completeIconsArray.slice(\n rangeStart,\n rangeStart + TOTAL_ICONS_PER_LINE\n )\n }\n\n return (\n <table className=\"w-100\">\n <tbody>\n {chunkedIconsMatrix.map((iconsLine, row) => (\n <tr key={`icon-table-row-${row}`}>\n {iconsLine.map((icon, cell) => {\n const IconComponent = ICONS[icon]\n return (\n <td key={`icon-table-cell-${row}-${cell}`}>\n <div className={DEMO_LABEL}>{icon}</div>\n <IconComponent size={DEMO_SIZE} />\n </td>\n )\n })}\n </tr>\n ))}\n </tbody>\n </table>\n )\n }\n}\n;<IconsTable />\n```\n\n```"
}
] |
code_store-on-localhost_fb4c647c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/IconBase.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport { baseClassname } from './utils'\n\nconst Use = ({ id }) => <use href={`#${id}`} xlinkHref={`#${id}`} />\n\nUse.propTypes = {\n id: PropTypes.string.isRequired,\n}\n\nexport const Svg = props => {\n const { size, block, children, name, variation, ...svgProps } = props\n const id = variation ? `icon-${name}-${variation}` : `icon-${name}`\n const element =\n typeof document !== 'undefined' &&\n document &&\n document.getElementById(id) ? (\n <Use id={id} />\n ) : (\n children\n )\n return (\n <svg\n className={`${baseClassname(name, variation)} ${block ? 'db' : ''}`}\n width={size.width}\n height={size.height}\n {...svgProps}>\n {element}\n </svg>\n )\n}\n\nSvg.propTypes = {\n name: PropTypes.string.isRequired,\n variation: PropTypes.string,\n size: PropTypes.shape({\n width: PropTypes.number,\n height: PropTypes.number,\n }),\n block: PropTypes.bool,\n viewBox: PropTypes.string,\n fill: PropTypes.string,\n xmlns: PropTypes.string,\n xmlnsXlink: PropTypes.string,\n children: PropTypes.node,\n}\n\nSvg.defaultProps = {\n xmlns: 'http://www.w3.org/2000/svg',\n xmlnsXlink: 'http://www.w3.org/1999/xlink',\n size: {\n width: 16,\n height: 16,\n },\n block: false,\n viewBox: '0 0 16 16',\n fill: 'none',\n variation: null,\n}\n\n```"
}
] |
code_store-on-localhost_24580191
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/utils.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nexport const calcIconSize = (iconBase, newSize) => {\n const isHorizontal = iconBase.width >= iconBase.height\n\n const width = isHorizontal\n ? newSize\n : (newSize * iconBase.width) / iconBase.height\n\n const height = !isHorizontal\n ? newSize\n : (newSize * iconBase.height) / iconBase.width\n\n return { width, height }\n}\n\nexport const baseClassname = (name, variation) =>\n `vtex__icon-${name} ${variation ? `vtex__icon-${name}--${variation}` : ''}`\n\n```"
}
] |
code_store-on-localhost_eeb32dad
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport ResponsiveModal from 'react-responsive-modal'\nimport get from 'lodash/get'\n\nimport zIndex from '../utils/zIndex'\nimport TopBar from './TopBar'\nimport BottomBar from './BottomBar'\nimport styles from './modal.css'\n\nimport './modal.global.css'\n\nclass Modal extends PureComponent {\n constructor(props) {\n super(props)\n this.contentContainerReference = React.createRef()\n this.state = { shadowBottom: false, shadowTop: false }\n }\n\n componentDidMount() {\n this.setShadowState(this.contentContainerReference.current)\n }\n\n componentDidUpdate(prevProps) {\n const scrollTop = get(this, 'contentContainerReference.current.scrollTop')\n if (\n prevProps.isOpen !== this.props.isOpen ||\n (scrollTop === 0 && this.state.shadowTop)\n )\n this.setShadowState(this.contentContainerReference.current)\n }\n\n handleScroll = event => {\n this.setShadowState(event.target)\n }\n\n setShadowState = element => {\n if (!element) return\n\n const { scrollTop, scrollHeight, clientHeight } = element\n\n this.setState({ shadowTop: scrollTop !== 0 })\n this.setState({ shadowBottom: scrollHeight - scrollTop !== clientHeight })\n }\n\n render = () => {\n const {\n isOpen,\n centered,\n onClose,\n closeOnEsc,\n closeOnOverlayClick,\n showCloseIcon,\n bottomBar,\n title,\n children,\n responsiveFullScreen,\n showTopBar,\n showBottomBarBorder,\n onCloseTransitionFinish,\n container,\n } = this.props\n const { shadowBottom, shadowTop } = this.state\n\n return (\n <ResponsiveModal\n open={isOpen}\n center={centered}\n container={container}\n onClose={onClose}\n onExited={onCloseTransitionFinish}\n closeOnEsc={closeOnEsc}\n closeOnOverlayClick={closeOnOverlayClick}\n showCloseIcon={showTopBar ? false : showCloseIcon}\n classNames={{\n overlay: `vtex-modal__overlay ${\n responsiveFullScreen ? 'pa5-ns pa0' : ''\n }`,\n modal: `vtex-modal__modal ${\n responsiveFullScreen ? 'br2-ns w-100 h-100 h-auto-ns' : 'br2 w-100'\n } ${styles.mh100} flex flex-column`,\n closeIcon: 'vtex-modal__close-icon',\n }}\n styles={{\n overlay: {\n backgroundColor: 'rgba(0, 0, 0, 0.8)',\n zIndex: zIndex.modal,\n },\n modal: {\n padding: 0,\n },\n closeIcon: {\n top: '8px',\n right: '8px',\n padding: '10px',\n },\n }}\n closeIconSize={18}>\n {showTopBar && (\n <TopBar\n title={title}\n onClose={onClose}\n showBottomShadow={shadowTop}\n responsiveFullScreen={responsiveFullScreen}\n showCloseIcon={showCloseIcon}\n />\n )}\n <div\n className={`${\n responsiveFullScreen ? 'ph7 ph8-ns' : 'ph6 ph8-ns'\n } overflow-auto flex-shrink-1 flex-grow-1 ${bottomBar ? '' : 'pb8'} ${\n title ? '' : 'pt5 pt6-ns'\n } ${styles.scrollBar}`}\n ref={this.contentContainerReference}\n onScroll={this.handleScroll}>\n {children}\n </div>\n {bottomBar ? (\n <BottomBar\n showTopShadow={shadowBottom}\n showBorder={showBottomBarBorder}\n responsiveFullScreen={responsiveFullScreen}>\n {bottomBar}\n </BottomBar>\n ) : (\n ''\n )}\n </ResponsiveModal>\n )\n }\n}\n\nModal.defaultProps = {\n isOpen: false,\n closeOnEsc: true,\n closeOnOverlayClick: true,\n showCloseIcon: true,\n showTopBar: true,\n showBottomBarBorder: true,\n}\n\nModal.propTypes = {\n /** Content of the modal */\n children: PropTypes.node.isRequired,\n /** Center the modal (for small content) */\n centered: PropTypes.bool,\n /** Container in which the modal is rendered */\n container: PropTypes.object,\n /** Show or hide the modal */\n isOpen: PropTypes.bool.isRequired,\n\n onClose: PropTypes.func.isRequired,\n\n /** Show BottomBar border **/\n showBottomBarBorder: PropTypes.bool,\n /** Close the modal on ESC key press (default true) */\n closeOnEsc: PropTypes.bool,\n /** Close the modal on overlay click (default true) */\n closeOnOverlayClick: PropTypes.bool,\n /** Show the close icon on upper right corner (default true) */\n showCloseIcon: PropTypes.bool,\n /** Node to be displayed as the bottom bar of the modal. */\n bottomBar: PropTypes.node,\n /** Modal title to be displayed in top of the modal. */\n title: PropTypes.node,\n /** If true, the modal will expand to fullscreen in small view ports (e.g. mobile) */\n responsiveFullScreen: PropTypes.bool,\n /** If true, show top bar with title */\n showTopBar: PropTypes.bool,\n /** Event fired when the closing transition is finished */\n onCloseTransitionFinish: PropTypes.func,\n}\n\nexport default Modal\n\n```"
}
] |
code_store-on-localhost_78b9ee7e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### A modal is an overlay that demands the attention and action from the user, preventing her from interacting with the rest of the page. It might be used from displaying messages to providing a simple form to edit a record.\n\n### 👍 Dos\n- Keep it simple. The content of a modal should represent one, clear action from the user - even if it takes multiple steps to be completed.\n- Always use a modal to confirm any destructive actions.\n\n### 👎 Don'ts\n- Avoid stacking modals on top of other modals.\n\n### Related components\n- For more complex actions and forms where you want to maintain the user context use the Drawer (work in progress).\n\n\nDefault\n\n```js\nconst Button = require('../Button').default\n\nclass ModalExample extends React.Component {\n constructor() {\n super()\n this.state = { isModalOpen: false }\n this.handleModalToggle = this.handleModalToggle.bind(this)\n this.handleConfirmation = this.handleConfirmation.bind(this)\n }\n\n handleModalToggle() {\n this.setState({ isModalOpen: !this.state.isModalOpen })\n }\n\n handleConfirmation() {\n this.handleModalToggle()\n }\n\n render() {\n return (\n <React.Fragment>\n <Button onClick={this.handleModalToggle}>Open modal</Button>\n\n <Modal\n centered\n isOpen={this.state.isModalOpen}\n onClose={this.handleModalToggle}\n >\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim\n ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in\n reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </p>\n </Modal>\n </React.Fragment>\n )\n }\n}\n\n;<ModalExample />\n```\n\nLong content\n\n```js\nconst Button = require('../Button').default\n\nclass ModalExample extends React.Component {\n constructor() {\n super()\n this.state = { isModalOpen: false }\n this.handleOpenModal = this.handleOpenModal.bind(this)\n this.handleCloseModal = this.handleCloseModal.bind(this)\n }\n\n handleOpenModal() {\n this.setState({ isModalOpen: true })\n }\n\n handleCloseModal() {\n this.setState({ isModalOpen: false })\n }\n\n render() {\n return (\n <React.Fragment>\n <Button onClick={this.handleOpenModal}>Open modal</Button>\n\n <Modal isOpen={this.state.isModalOpen} onClose={this.handleCloseModal}>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent\n semper eget magna sit amet maximus. In rutrum, justo sodales euismod\n dignissim, justo orci venenatis lectus, vel semper turpis nunc a\n justo. Pellentesque tempor sodales ante, a dignissim metus posuere\n sed. Aenean dapibus nisl non finibus ultrices. Sed in urna nisi.\n Fusce malesuada, diam eget accumsan pharetra, diam nisl cursus\n mauris, facilisis pretium risus elit in diam. Duis tincidunt\n interdum purus sit amet interdum. Phasellus non elit id lacus\n euismod vehicula nec at velit. Ut ullamcorper pharetra vulputate.\n Praesent volutpat sem et dolor facilisis molestie in et velit.\n Quisque suscipit augue vitae nunc euismod, lacinia volutpat lacus\n porta. Curabitur eget enim urna. Sed neque lectus, pulvinar eget\n vulputate ut, tristique nec leo.\n </p>\n <p>\n Duis pulvinar sagittis lacinia. Cras vitae nibh quis tortor finibus\n luctus. Phasellus et lacus vestibulum, hendrerit sapien ac, vehicula\n dui. Class aptent taciti sociosqu ad litora torquent per conubia\n nostra, per inceptos himenaeos. Nulla pellentesque placerat nisi,\n sit amet facilisis dui. Nam maximus ex at iaculis commodo. In sit\n amet nisl vestibulum, mollis ligula vitae, accumsan tortor. Ut\n molestie bibendum velit nec maximus. Suspendisse tincidunt posuere\n urna quis hendrerit. Duis a molestie diam. Pellentesque vitae\n tristique tellus, luctus imperdiet est. Vestibulum vitae pretium\n felis.\n </p>\n <p>\n Vivamus vel purus aliquam, gravida magna eget, iaculis ipsum. Cras\n dapibus nisl ut odio molestie, mollis tempus mi hendrerit. Etiam in\n purus iaculis, interdum dui at, semper sapien. Praesent porta nulla\n justo, non eleifend odio semper ac. Nunc facilisis at mi ac pretium.\n Integer mattis consectetur faucibus. Nam nec elit nec augue\n fringilla efficitur quis eget metus. Morbi at magna quam. Proin nec\n lobortis ante. Ut ut orci quis sem eleifend imperdiet. Proin mauris\n mi, ornare tincidunt placerat nec, eleifend eget velit. Donec\n volutpat urna nibh, et elementum eros interdum eu. Nulla malesuada\n bibendum semper. Donec bibendum ultrices sapien, sit amet fermentum\n nisl semper vel. Aenean ut dapibus est. Aenean quis orci sit amet\n sapien suscipit lobortis.\n </p>\n <p>\n Phasellus eu magna ut arcu dignissim finibus ut ut sapien. Sed vitae\n diam non est congue lacinia vel id elit. Praesent convallis\n convallis justo, elementum laoreet magna congue sed. Cras sodales,\n augue nec tincidunt facilisis, nunc nisi gravida metus, ac fringilla\n metus tellus in ligula. Nulla arcu ipsum, placerat pellentesque\n gravida a, dictum at urna. Proin quis orci nec quam tempor venenatis\n sit amet vitae justo. Nam imperdiet mattis nulla id malesuada. Donec\n condimentum sem vel lorem vulputate, quis tristique lectus semper.\n In maximus sodales sapien vitae porttitor. Duis sodales metus a\n pellentesque laoreet. Donec placerat massa turpis, quis consectetur\n nisl consequat at. Donec sed purus efficitur, fringilla diam et,\n rutrum turpis. Proin tincidunt augue id ligula cursus sollicitudin.\n Suspendisse semper fermentum pulvinar.\n </p>\n <p>\n Quisque tempor vel nunc iaculis ullamcorper. Vestibulum convallis\n purus id rhoncus eleifend. Etiam a elementum diam, eget congue urna.\n Cras pretium justo leo, rutrum ornare arcu pellentesque gravida.\n Aliquam lobortis mauris quis mi vestibulum dignissim. Nam et felis\n in arcu condimentum consequat. Phasellus lectus nibh, suscipit et\n risus quis, eleifend lacinia ligula.\n </p>\n <p>\n Phasellus eu magna ut arcu dignissim finibus ut ut sapien. Sed vitae\n diam non est congue lacinia vel id elit. Praesent convallis\n convallis justo, elementum laoreet magna congue sed. Cras sodales,\n augue nec tincidunt facilisis, nunc nisi gravida metus, ac fringilla\n metus tellus in ligula. Nulla arcu ipsum, placerat pellentesque\n gravida a, dictum at urna. Proin quis orci nec quam tempor venenatis\n sit amet vitae justo. Nam imperdiet mattis nulla id malesuada. Donec\n condimentum sem vel lorem vulputate, quis tristique lectus semper.\n In maximus sodales sapien vitae porttitor. Duis sodales metus a\n pellentesque laoreet. Donec placerat massa turpis, quis consectetur\n nisl consequat at. Donec sed purus efficitur, fringilla diam et,\n rutrum turpis. Proin tincidunt augue id ligula cursus sollicitudin.\n Suspendisse semper fermentum pulvinar.\n </p>\n <p>\n Quisque tempor vel nunc iaculis ullamcorper. Vestibulum convallis\n purus id rhoncus eleifend. Etiam a elementum diam, eget congue urna.\n Cras pretium justo leo, rutrum ornare arcu pellentesque gravida.\n Aliquam lobortis mauris quis mi vestibulum dignissim. Nam et felis\n in arcu condimentum consequat. Phasellus lectus nibh, suscipit et\n risus quis, eleifend lacinia ligula.\n </p>\n </Modal>\n </React.Fragment>\n )\n }\n}\n\n;<ModalExample />\n```\n\nWith title and BottomBar\n\n```js\nconst Button = require('../Button').default\n\nclass ModalExample extends React.Component {\n constructor() {\n super()\n this.state = { isModalOpen: false }\n this.handleOpenModal = this.handleOpenModal.bind(this)\n this.handleCloseModal = this.handleCloseModal.bind(this)\n }\n\n handleOpenModal() {\n this.setState({ isModalOpen: true })\n }\n\n handleCloseModal() {\n this.setState({ isModalOpen: false })\n }\n\n render() {\n return (\n <React.Fragment>\n <Button onClick={this.handleOpenModal}>Open modal</Button>\n\n <Modal\n isOpen={this.state.isModalOpen}\n title=\"Modal title\"\n bottomBar={\n <div className=\"nowrap\">\n <span className=\"mr4\">\n <Button variation=\"tertiary\" onClick={this.handleCloseModal}>Action 1</Button>\n </span>\n <span>\n <Button variation=\"secondary\" onClick={this.handleCloseModal}>Action 2</Button>\n </span>\n </div>\n }\n onClose={this.handleCloseModal}>\n <p>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent\n semper eget magna sit amet maximus. In rutrum, justo sodales euismod\n dignissim, justo orci venenatis lectus, vel semper turpis nunc a\n justo. Pellentesque tempor sodales ante, a dignissim metus posuere\n sed. Aenean dapibus nisl non finibus ultrices. Sed in urna nisi.\n Fusce malesuada, diam eget accumsan pharetra, diam nisl cursus\n mauris, facilisis pretium risus elit in diam. Duis tincidunt\n interdum purus sit amet interdum. Phasellus non elit id lacus\n euismod vehicula nec at velit. Ut ullamcorper pharetra vulputate.\n Praesent volutpat sem et dolor facilisis molestie in et velit.\n Quisque suscipit augue vitae nunc euismod, lacinia volutpat lacus\n porta. Curabitur eget enim urna. Sed neque lectus, pulvinar eget\n vulputate ut, tristique nec leo.\n </p>\n <p>\n Duis pulvinar sagittis lacinia. Cras vitae nibh quis tortor finibus\n luctus. Phasellus et lacus vestibulum, hendrerit sapien ac, vehicula\n dui. Class aptent taciti sociosqu ad litora torquent per conubia\n nostra, per inceptos himenaeos. Nulla pellentesque placerat nisi,\n sit amet facilisis dui. Nam maximus ex at iaculis commodo. In sit\n amet nisl vestibulum, mollis ligula vitae, accumsan tortor. Ut\n molestie bibendum velit nec maximus. Suspendisse tincidunt posuere\n urna quis hendrerit. Duis a molestie diam. Pellentesque vitae\n tristique tellus, luctus imperdiet est. Vestibulum vitae pretium\n felis.\n </p>\n <p>\n Vivamus vel purus aliquam, gravida magna eget, iaculis ipsum. Cras\n dapibus nisl ut odio molestie, mollis tempus mi hendrerit. Etiam in\n purus iaculis, interdum dui at, semper sapien. Praesent porta nulla\n justo, non eleifend odio semper ac. Nunc facilisis at mi ac pretium.\n Integer mattis consectetur faucibus. Nam nec elit nec augue\n fringilla efficitur quis eget metus. Morbi at magna quam. Proin nec\n lobortis ante. Ut ut orci quis sem eleifend imperdiet. Proin mauris\n mi, ornare tincidunt placerat nec, eleifend eget velit. Donec\n volutpat urna nibh, et elementum eros interdum eu. Nulla malesuada\n bibendum semper. Donec bibendum ultrices sapien, sit amet fermentum\n nisl semper vel. Aenean ut dapibus est. Aenean quis orci sit amet\n sapien suscipit lobortis.\n </p>\n <p>\n Phasellus eu magna ut arcu dignissim finibus ut ut sapien. Sed vitae\n diam non est congue lacinia vel id elit. Praesent convallis\n convallis justo, elementum laoreet magna congue sed. Cras sodales,\n augue nec tincidunt facilisis, nunc nisi gravida metus, ac fringilla\n metus tellus in ligula. Nulla arcu ipsum, placerat pellentesque\n gravida a, dictum at urna. Proin quis orci nec quam tempor venenatis\n sit amet vitae justo. Nam imperdiet mattis nulla id malesuada. Donec\n condimentum sem vel lorem vulputate, quis tristique lectus semper.\n In maximus sodales sapien vitae porttitor. Duis sodales metus a\n pellentesque laoreet. Donec placerat massa turpis, quis consectetur\n nisl consequat at. Donec sed purus efficitur, fringilla diam et,\n rutrum turpis. Proin tincidunt augue id ligula cursus sollicitudin.\n Suspendisse semper fermentum pulvinar.\n </p>\n <p>\n Quisque tempor vel nunc iaculis ullamcorper. Vestibulum convallis\n purus id rhoncus eleifend. Etiam a elementum diam, eget congue urna.\n Cras pretium justo leo, rutrum ornare arcu pellentesque gravida.\n Aliquam lobortis mauris quis mi vestibulum dignissim. Nam et felis\n in arcu condimentum consequat. Phasellus lectus nibh, suscipit et\n risus quis, eleifend lacinia ligula.\n </p>\n <p>\n Phasellus eu magna ut arcu dignissim finibus ut ut sapien. Sed vitae\n diam non est congue lacinia vel id elit. Praesent convallis\n convallis justo, elementum laoreet magna congue sed. Cras sodales,\n augue nec tincidunt facilisis, nunc nisi gravida metus, ac fringilla\n metus tellus in ligula. Nulla arcu ipsum, placerat pellentesque\n gravida a, dictum at urna. Proin quis orci nec quam tempor venenatis\n sit amet vitae justo. Nam imperdiet mattis nulla id malesuada. Donec\n condimentum sem vel lorem vulputate, quis tristique lectus semper.\n In maximus sodales sapien vitae porttitor. Duis sodales metus a\n pellentesque laoreet. Donec placerat massa turpis, quis consectetur\n nisl consequat at. Donec sed purus efficitur, fringilla diam et,\n rutrum turpis. Proin tincidunt augue id ligula cursus sollicitudin.\n Suspendisse semper fermentum pulvinar.\n </p>\n <p>\n Quisque tempor vel nunc iaculis ullamcorper. Vestibulum convallis\n purus id rhoncus eleifend. Etiam a elementum diam, eget congue urna.\n Cras pretium justo leo, rutrum ornare arcu pellentesque gravida.\n Aliquam lobortis mauris quis mi vestibulum dignissim. Nam et felis\n in arcu condimentum consequat. Phasellus lectus nibh, suscipit et\n risus quis, eleifend lacinia ligula.\n </p>\n </Modal>\n </React.Fragment>\n )\n }\n}\n\n;<ModalExample />\n\n```\nUsing responsiveFullScreen\n\n```js\nconst Button = require('../Button').default\n\nclass ModalExample extends React.Component {\n constructor() {\n super()\n this.state = { isModalOpen: false }\n this.handleOpenModal = this.handleOpenModal.bind(this)\n this.handleCloseModal = this.handleCloseModal.bind(this)\n }\n\n handleOpenModal() {\n this.setState({ isModalOpen: true })\n }\n\n handleCloseModal() {\n this.setState({ isModalOpen: false })\n }\n\n render() {\n return (\n <React.Fragment>\n <Button onClick={this.handleOpenModal}>Open modal</Button>\n\n <Modal\n isOpen={this.state.isModalOpen}\n title=\"Modal title\"\n responsiveFullScreen\n centered\n bottomBar={\n <div className=\"nowrap\">\n <span className=\"mr4\">\n <Button variation=\"tertiary\" onClick={this.handleCloseModal}>Action 1</Button>\n </span>\n <span>\n <Button variation=\"secondary\" onClick={this.handleCloseModal}>Action 2</Button>\n </span>\n </div>\n }\n onClose={this.handleCloseModal}>\n <p>\n Phasellus eu magna ut arcu dignissim finibus ut ut sapien. Sed vitae\n diam non est congue lacinia vel id elit. Praesent convallis\n convallis justo, elementum laoreet magna congue sed. Cras sodales,\n augue nec tincidunt facilisis, nunc nisi gravida metus, ac fringilla\n metus tellus in ligula. Nulla arcu ipsum, placerat pellentesque\n gravida a, dictum at urna. Proin quis orci nec quam tempor venenatis\n sit amet vitae justo. Nam imperdiet mattis nulla id malesuada. Donec\n condimentum sem vel lorem vulputate, quis tristique lectus semper.\n In maximus sodales sapien vitae porttitor. Duis sodales metus a\n pellentesque laoreet. Donec placerat massa turpis, quis consectetur\n nisl consequat at. Donec sed purus efficitur, fringilla diam et,\n rutrum turpis. Proin tincidunt augue id ligula cursus sollicitudin.\n Suspendisse semper fermentum pulvinar.\n </p>\n </Modal>\n </React.Fragment>\n )\n }\n}\n\n;<ModalExample />\n```\n\n```"
}
] |
code_store-on-localhost_c51989dd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/TopBar.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport IconClose from '../icon/Close'\nimport styles from './modal.css'\n\nconst TopBar = props => {\n const {\n title,\n onClose,\n showBottomShadow,\n responsiveFullScreen,\n showCloseIcon,\n } = props\n\n return (\n <div\n className={`\n flex justify-content relative ${title ? 'pv5 pv6-ns' : ''}\n ${responsiveFullScreen ? 'pl7 pr8 pl8-ns pl8-ns' : 'pl6 pr8 pl8-ns'}\n ${styles.shadowTransition}\n ${showBottomShadow ? 'shadow-4' : ''}\n `}>\n <span className=\"f3 c-on-base w-100\">\n {title}\n {showBottomShadow}\n </span>\n {showCloseIcon && (\n <div\n className={\n 'vtex-modal__close-icon absolute top-0 right-0 pa5 pa6-ns pointer ml-auto items-center flex'\n }\n onClick={onClose}>\n <IconClose size={18} />\n </div>\n )}\n </div>\n )\n}\n\nTopBar.propTypes = {\n title: PropTypes.node,\n onClose: PropTypes.func,\n showBottomShadow: PropTypes.bool,\n responsiveFullScreen: PropTypes.bool,\n showCloseIcon: PropTypes.bool,\n}\n\nTopBar.defaultProps = {\n showBottomShadow: false,\n responsiveFullScreen: false,\n}\n\nexport default TopBar\n\n```"
}
] |
code_store-on-localhost_f364a703
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/modal.global.css from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.vtex-modal__overlay.pa0 {\n padding: 0;\n}\n\n@media screen and (min-width: 40rem) {\n .vtex-modal__overlay.pa5-ns {\n padding: 1.25rem;\n }\n}\n\n```"
}
] |
code_store-on-localhost_3dd85ebf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/modal.css from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.shadowTransition {\n transition: box-shadow 0.3s ease-in-out;\n}\n\n.mh100 {\n max-height: 100%;\n}\n\n.scrollBar::-webkit-scrollbar {\n background-color: transparent;\n width: 8px;\n}\n\n/* background of the scrollbar except button or resizer */\n.scrollBar::-webkit-scrollbar-track {\n background-color: transparent;\n}\n\n/* scrollbar itself */\n.scrollBar::-webkit-scrollbar-thumb {\n background-color: #e3e4e6;\n border-radius: 16px;\n}\n\n/* set button(top and bottom of the scrollbar) */\n.scrollBar::-webkit-scrollbar-button {\n display: none;\n}\n\n```"
}
] |
code_store-on-localhost_d46348b4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Modal/BottomBar.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport styles from './modal.css'\n\nconst BottomBar = props => {\n const { children, showTopShadow, responsiveFullScreen, showBorder } = props\n\n return (\n <div\n className={`\n flex justify-content flex-row-reverse \n ${showBorder ? 'bt b--muted-4 ' : ''}\n ${\n responsiveFullScreen\n ? 'ph7 pv5 ph8-ns pv6-ns '\n : 'ph6 ph8-ns pv5 pv6-ns '\n }\n ${styles.shadowTransition}\n ${showTopShadow ? 'shadow-4 ' : ''}\n `}>\n {children}\n </div>\n )\n}\n\nBottomBar.propTypes = {\n showTopShadow: PropTypes.bool,\n children: PropTypes.node,\n responsiveFullScreen: PropTypes.bool,\n showBorder: PropTypes.bool,\n}\n\nBottomBar.defaultProps = {\n showTopShadow: false,\n responsiveFullScreen: false,\n}\n\nexport default BottomBar\n\n```"
}
] |
code_store-on-localhost_984299d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/MultiSelect/DropdownList.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nexport default class DropdownList extends PureComponent {\n handleSelect = index => {\n this.props.onSelect && this.props.onSelect(index)\n }\n\n handleFocus = index => {\n this.props.onFocus && this.props.onFocus(index)\n }\n\n render() {\n const {\n emptyState,\n focused,\n formatOption,\n isVisible,\n loading,\n loadingText,\n onMouseEnter,\n onMouseLeave,\n options,\n } = this.props\n if (!isVisible) return null\n\n const optionList = options.map((opt, index) => {\n const focusedClasses =\n index === focused ? ' bg-muted-5 c-on-muted-5 ' : ' bg-base c-on-base '\n return (\n <li\n className={`pv4 ph5 pointer t-small fw3 c-on-muted-4 ${focusedClasses}`}\n dangerouslySetInnerHTML={{ __html: formatOption(opt) }}\n key={index}\n onClick={() => this.handleSelect(index)}\n onMouseEnter={() => this.handleFocus(index)}\n />\n )\n })\n const results =\n options.length === 0 ? (\n <div\n className=\"pv4 ph5 t-small c-muted-2 bg-base\"\n dangerouslySetInnerHTML={{ __html: emptyState }}\n />\n ) : (\n <ul className=\"ph0 mv0 list\">{optionList}</ul>\n )\n\n return (\n <div\n className=\"b--muted-4 br--bottom br2 b--solid bw1 absolute w-100 z-max\"\n style={{ borderTop: 'none', boxShadow: '0 1px 18px rgba(0,0,0,0.15)' }}\n onMouseEnter={() => onMouseEnter && onMouseEnter()}\n onMouseLeave={() => onMouseLeave && onMouseLeave()}>\n {loading && (\n <div className=\"pv4 ph5 t-small c-muted-2 bg-base\">{loadingText}</div>\n )}\n {!loading && results}\n </div>\n )\n }\n}\n\nDropdownList.defaultProps = {\n focused: '',\n formatOption: opt => {\n return opt.label\n },\n loading: false,\n loadingText: 'Loading...',\n options: [],\n isVisible: false,\n}\n\nDropdownList.propTypes = {\n emptyState: PropTypes.string,\n focused: PropTypes.number,\n formatOption: PropTypes.func,\n loading: PropTypes.bool,\n loadingText: PropTypes.string,\n onSelect: PropTypes.func,\n onFocus: PropTypes.func,\n onMouseEnter: PropTypes.func,\n onMouseLeave: PropTypes.func,\n options: PropTypes.array,\n isVisible: PropTypes.bool,\n}\n\n```"
}
] |
code_store-on-localhost_0fd19e5d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/MultiSelect/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport debounce from 'lodash/debounce'\n\nimport Tag from './Tag'\nimport DropdownList from './DropdownList'\n\nexport default class MultiSelect extends Component {\n constructor(props) {\n super(props)\n this.searchInput = React.createRef()\n\n this.state = {\n active: false,\n filteredOptions: [],\n focusedOption: 0,\n hovering: false,\n loading: false,\n searchTerm: '',\n }\n }\n\n handleFilter = debounce(\n async term => {\n const filteredOptions = await this.filter(term)\n this.setState({ loading: false, filteredOptions })\n },\n 275,\n { trailing: true }\n )\n\n handleFocus = () => {\n this.setState({ active: true })\n }\n\n handleBlur = () => {\n if (!this.state.hovering) {\n this.setState({ active: false })\n }\n }\n\n handleKeyPress = event => {\n if (this.state.searchTerm !== '') {\n if (event.key === 'Tab' || event.key === 'Enter') {\n event.preventDefault()\n this.selectFocused()\n } else if (event.key === 'ArrowUp') {\n event.preventDefault()\n this.moveFocusUp()\n } else if (event.key === 'ArrowDown') {\n event.preventDefault()\n this.moveFocusDown()\n }\n } else if (event.key === 'Backspace') {\n this.unselectLast()\n }\n }\n\n handleSearch = event => {\n const searchTerm = event.target.value\n this.setState(\n () => {\n return {\n searchTerm,\n focusedOption: 0,\n filteredOptions: [],\n loading: true,\n }\n },\n () => {\n this.handleFilter(searchTerm)\n }\n )\n }\n\n handleSelect = index => {\n this.props.onChange([\n ...this.props.selected,\n this.state.filteredOptions[index],\n ])\n this.setState(\n {\n hovering: false,\n searchTerm: '',\n },\n () => {\n this.searchInput.current.focus()\n }\n )\n }\n\n handleUnselect = index => {\n this.props.onChange(this.props.selected.filter((opt, i) => index !== i))\n this.searchInput.current.focus()\n }\n\n filter = term => {\n if (this.props.filter) {\n return this.props.filter(term)\n }\n return this.props.options\n .filter(opt => opt.label.toLowerCase().includes(term.toLowerCase()))\n .filter(opt => {\n for (let i = 0; i < this.props.selected.length; i++) {\n if (this.props.selected[i].value === opt.value) {\n return false\n }\n }\n return true\n })\n }\n\n moveFocusDown = () => {\n const newFocus = this.state.focusedOption + 1\n if (newFocus <= this.state.filteredOptions.length - 1) {\n this.setState({ focusedOption: newFocus })\n }\n }\n\n moveFocusUp = () => {\n const newFocus = this.state.focusedOption - 1\n if (newFocus >= 0) {\n this.setState({ focusedOption: newFocus })\n }\n }\n\n selectFocused = () => {\n const index = this.state.focusedOption\n if (this.state.filteredOptions.length > 0) {\n this.handleSelect(index)\n }\n }\n\n unselectLast = () => {\n const length = this.props.selected.length\n if (length > 0) {\n this.handleUnselect(length - 1)\n }\n }\n\n render() {\n const { disabled, label, loadingText, placeholder, selected } = this.props\n const emptyState = this.props.emptyState(\n `<span className=\"fw5\">${this.state.searchTerm}</span>`\n )\n const isDropdownVisible = this.state.active && this.state.searchTerm !== ''\n const tags = selected.map((tag, index) => (\n <div className=\"mr2 mv1 flex\" key={index}>\n <Tag\n disabled={disabled}\n onClick={() => {\n this.handleUnselect(index)\n }}>\n {tag.label}\n </Tag>\n </div>\n ))\n\n let classes = disabled ? ' bg-muted-5 c-muted-2 ' : ' bg-base c-on-base '\n classes += isDropdownVisible ? ' br--top ' : ''\n classes += this.state.active ? ' b--muted-2 ' : ' b--muted-4 '\n classes += !this.state.active && !disabled ? ' hover-b--muted-3 ' : ''\n\n return (\n <div className=\"relative\">\n <label>\n {label && (\n <span className=\"vtex-input__label db mb3 w-100 c-on-base\">\n {label}\n </span>\n )}\n <div\n className={`flex flex-wrap mt3 br2 b--solid bw1 pv2 ph5 ${classes}`}>\n <input\n className={`t-small mv3 bn outline-0 flex-grow-1 order-last ${classes}`}\n disabled={disabled}\n onBlur={this.handleBlur}\n onChange={this.handleSearch}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyPress}\n placeholder={placeholder}\n ref={this.searchInput}\n value={this.state.searchTerm}\n style={{\n WebkitAppearance: 'none',\n }}\n />\n {tags}\n </div>\n </label>\n <DropdownList\n emptyState={emptyState}\n focused={this.state.focusedOption}\n formatOption={opt =>\n opt.label.replace(\n new RegExp(this.state.searchTerm, 'i'),\n '<span className=\"fw5\">$&</span>'\n )\n }\n loading={this.state.loading}\n loadingText={loadingText}\n onFocus={opt => this.setState({ focusedOption: opt })}\n onMouseEnter={() => this.setState({ hovering: true })}\n onMouseLeave={() => this.setState({ hovering: false })}\n onSelect={this.handleSelect}\n options={this.state.filteredOptions}\n isVisible={isDropdownVisible}\n />\n </div>\n )\n }\n}\n\nMultiSelect.defaultProps = {\n disabled: false,\n emptyState: term => {\n return `No results found for \"${term}\".`\n },\n options: [],\n placeholder: 'Search...',\n selected: [],\n}\n\nMultiSelect.propTypes = {\n /** True if the component should be disabled */\n disabled: PropTypes.bool,\n /** Returns a string that will be shown if no results are found. Usage: emptyState(search term) */\n emptyState: PropTypes.func,\n /** Returns an array of filtered results. Usage: filter(search term) */\n filter: PropTypes.func,\n /** Label */\n label: PropTypes.string,\n /** Text that shows during load */\n loadingText: PropTypes.string,\n /** Called when selected options change. Usage: onChange(selected array) */\n onChange: PropTypes.func.isRequired,\n /** List of selectable options. */\n options: PropTypes.array,\n /** Search input placeholder */\n placeholder: PropTypes.string,\n /** List of selected options, which will be shown as tags */\n selected: PropTypes.array,\n}\n\n```"
}
] |
code_store-on-localhost_8c05c9be
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/MultiSelect/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n```jsx noeditor\nconst Alert = require('../Alert').default\n;<Alert type=\"warning\">\n This component will be soon deprecated. Please prefer using the{' '}\n <a\n class=\"mh2 link fw7\"\n href=\"https://styleguide.vtex.com/#/Components/%F0%9F%91%BB%20Experimental/Select\">\n Select\n </a>{' '}\n component.\n</Alert>\n```\n\n#### Like a simple dropdown, but users may select more than one option.\n\n### Related components\n\nFor single selection use a <a href=\"#/Components/Forms/Dropdown\">Dropdown</a>.\n\nSimple Use\n\n```js\ninitialState = {\n selected: [\n { label: 'Green', value: 'green' },\n { label: 'Red', value: 'red' },\n ],\n}\noptions = [\n { label: 'White', value: 'white' },\n { label: 'Black', value: 'black' },\n { label: 'Grey', value: 'grey' },\n { label: 'Yellow', value: 'yellow' },\n { label: 'Red', value: 'red' },\n { label: 'Blue', value: 'blue' },\n { label: 'Green', value: 'green' },\n { label: 'Brown', value: 'brown' },\n { label: 'Pink', value: 'pink' },\n { label: 'Orange', value: 'orange' },\n { label: 'Purple', value: 'purple' },\n { label: 'Dark-blue', value: 'dark-blue' },\n { label: 'Dark-red', value: 'dark-red' },\n { label: 'Light-blue', value: 'light-blue' },\n]\n;<div>\n <MultiSelect\n label=\"Colors\"\n options={options}\n onChange={selected => setState({ selected })}\n selected={state.selected}\n />\n <br />\n <MultiSelect\n disabled\n label=\"Disabled\"\n onChange={() => console.log('onChange')}\n placeholder=\"\"\n selected={[\n { label: 'Black', value: 'black' },\n { label: 'Pink', value: 'pink' },\n ]}\n />\n</div>\n```\n\nSimulating API\n\n```js\ninitialState = {\n selected: [\n { label: 'Green', value: 'green' },\n { label: 'Red', value: 'red' },\n ],\n}\noptions = [\n { label: 'White', value: 'white' },\n { label: 'Black', value: 'black' },\n { label: 'Grey', value: 'grey' },\n { label: 'Yellow', value: 'yellow' },\n { label: 'Red', value: 'red' },\n { label: 'Blue', value: 'blue' },\n { label: 'Green', value: 'green' },\n { label: 'Brown', value: 'brown' },\n { label: 'Pink', value: 'pink' },\n { label: 'Orange', value: 'orange' },\n { label: 'Purple', value: 'purple' },\n { label: 'Dark-blue', value: 'dark-blue' },\n { label: 'Dark-red', value: 'dark-red' },\n { label: 'Light-blue', value: 'light-blue' },\n]\nfunction sleep(ms) {\n return new Promise(r => setTimeout(r, ms))\n}\nasync function filter(term) {\n await sleep(1000)\n return options\n .filter(tag => tag.label.toLowerCase().includes(term.toLowerCase()))\n .filter(tag => {\n for (var i = 0; i < state.selected.length; i++) {\n if (state.selected[i].value === tag.value) {\n return false\n }\n }\n return true\n })\n}\n;<MultiSelect\n emptyState={term => {\n return `Your search for \"${term}\" did not find any results. Did you mean: \"<span className=\"fw5\">pink</span>\"?`\n }}\n filter={filter}\n label=\"Colors\"\n onChange={selected => setState({ selected })}\n selected={state.selected}\n/>\n```\n\n```"
}
] |
code_store-on-localhost_4de58e12
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/MultiSelect/Tag.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Close from '../icon/Close'\n\nexport default class Tag extends Component {\n constructor(props) {\n super(props)\n\n this.state = {\n hover: false,\n }\n }\n\n handleMouseEnter = () => {\n this.setState({ hover: true })\n }\n\n handleMouseLeave = () => {\n this.setState({ hover: false })\n }\n\n render() {\n const { children, disabled, onClick } = this.props\n const classes = disabled\n ? ' c-muted-2 bg-muted-4 '\n : ' pointer bg-action-secondary c-on-action-secondary '\n let hoverClass = ''\n if (!disabled) {\n hoverClass = this.state.hover ? 'c-danger' : 'c-on-action-secondary'\n }\n return (\n <button\n className={`br-pill bn dib t-small pv2 ph4 ${classes}`}\n disabled={disabled}\n onClick={() => {\n onClick && onClick()\n }}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}>\n <div className=\"flex items-center justify-center\">\n <span className=\"self-center\">{children}</span>{' '}\n <div className={`${hoverClass} ml2 pt2 self-center`}>\n <Close color=\"currentColor\" size={16} />\n </div>\n </div>\n </button>\n )\n }\n}\n\nTag.defaultProps = {\n disabled: false,\n}\n\nTag.propTypes = {\n children: PropTypes.string.isRequired,\n disabled: PropTypes.bool,\n onClick: PropTypes.func,\n}\n\n```"
}
] |
code_store-on-localhost_a74b8d79
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/SelectableCard/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport PropTypes from 'prop-types'\n\nimport CheckIcon from '../icon/Check'\n\nconst propTypes = {\n /** Content of the card */\n children: PropTypes.node.isRequired,\n /** Use the full size of the card. */\n noPadding: PropTypes.bool,\n selected: PropTypes.bool,\n onClick: PropTypes.func.isRequired,\n /** Use this to group cards on the left. */\n hasGroupLeft: PropTypes.bool,\n /** Use this to group cards on the right. */\n hasGroupRight: PropTypes.bool,\n}\n\nconst SelectableCard: FC<PropTypes.InferProps<typeof propTypes>> = ({\n children,\n noPadding,\n selected,\n onClick,\n hasGroupLeft,\n hasGroupRight,\n}) => {\n const padding = noPadding ? '' : 'pa6'\n\n return (\n <div\n className={`ba br2 bw2 relative ${\n selected ? 'b--action-primary z-999' : 'b--transparent'\n } nh2`}>\n {selected ? (\n <div className=\"absolute right--1 top--1 br-100 h2 w2 bg-action-primary z-999 pa3\">\n <CheckIcon color=\"white\" />\n </div>\n ) : null}\n <div\n style={{\n boxShadow: '0 3px 9px 0 rgba(61, 62, 64, 0.25)',\n clipPath: `inset(-10px ${hasGroupRight ? '0px' : '-10px'} -10px ${\n hasGroupLeft ? '0px' : '-10px'\n })`,\n }}\n className={`vtex-card card w-100 b2 br2 bg-base c-on-base ${padding} pointer`}\n onClick={onClick}>\n {children}\n </div>\n </div>\n )\n}\n\nSelectableCard.propTypes = propTypes\n\nexport default SelectableCard\n\n```"
}
] |
code_store-on-localhost_3525777f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/SelectableCard/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### A Selectable Card represents a need for the user to make a choice among a few offered options.\n\n### 👍 Dos\n\n- Keep the list of options short. More than 4 options might start looking weird.\n- Always leave an option from the list selected by default.\n\n### 👎 Don'ts\n\n- Don't offer overlapping options, they should be clearly mutually exclusive.\n\n### Related components\n\n- Consider using a <a href=\"#/Components/Forms/RadioGroup\">Radio Group</a> if you prefer your options to be displayed vertically.\n- Consider using a <a href=\"#/Components/Forms/Checkbox\">Checkbox</a> if you need the user to select more than one option.\n- Consider using a <a href=\"#/Components/Forms/Dropdown\">Dropdown</a> if you have several options and they don't need much explanation.\n\nDefault\n\n```js\nclass SelectableCards extends React.Component {\n constructor(props) {\n super(props)\n this.state = { selected: 'card1' }\n }\n\n isSelected(opt) {\n return opt === this.state.selected\n }\n\n changeSelected(opt) {\n this.setState({ selected: opt })\n }\n\n render() {\n return (\n <div className=\"pa5 flex justify-center\">\n <SelectableCard\n hasGroupRigth\n noPadding\n selected={this.isSelected('card1')}\n onClick={() => this.setState({ selected: 'card1' })}>\n <div className=\"pa7\">\n <div className=\"f3 tc\">Card 1</div>\n </div>\n </SelectableCard>\n <SelectableCard\n hasGroupRigth\n hasGroupLeft\n noPadding\n selected={this.isSelected('card2')}\n onClick={() => this.setState({ selected: 'card2' })}>\n <div className=\"pa7\">\n <div className=\"f3 tc\">Card 2</div>\n </div>\n </SelectableCard>\n <SelectableCard\n hasGroupRigth\n hasGroupLeft\n noPadding\n selected={this.isSelected('card3')}\n onClick={() => this.setState({ selected: 'card3' })}>\n <div className=\"pa7\">\n <div className=\"f3 tc\">Card 3</div>\n </div>\n </SelectableCard>\n <SelectableCard\n hasGroupLeft\n noPadding\n selected={this.isSelected('card4')}\n onClick={() => this.setState({ selected: 'card4' })}>\n <div className=\"pa7\">\n <div className=\"f3 tc\">Card 4</div>\n </div>\n </SelectableCard>\n </div>\n )\n }\n}\n\n;<SelectableCards />\n```\n\n```"
}
] |
code_store-on-localhost_fec97424
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/helpers.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport mergeBase from 'lodash/merge'\n\nimport { commonDefaultProps } from './commonProps'\nimport { defaultProps as defaultLineProps } from './LineChart/constants'\nimport { defaultProps as defaultBarProps } from './BarChart/constants'\n\nconst merge = (defaultProps: ChartConfig, userProps: ChartConfig) => {\n const props = defaultProps\n userProps &&\n Object.keys(userProps).forEach(\n key => (props[key] = mergeBase(props[key], userProps[key]))\n )\n return props\n}\n\nconst getRangeOfZAxis = (key: string | number, data: object[]) => {\n const values = data.map(item => item[key])\n const min = Math.min(...values)\n const max = Math.max(...values)\n return [min, max]\n}\n\nconst getChartDefaultProps = (\n userProps: ChartConfig,\n customConfig = commonDefaultProps\n) => ({\n configs: merge(merge(commonDefaultProps, customConfig), userProps),\n})\n\nconst getLineDefaultProps = (userProps: LineProps) => ({\n lineConfigs: { ...defaultLineProps, ...userProps },\n})\n\nconst getBarDefaultProps = (userProps: BarProps) => ({\n barConfigs: { ...defaultBarProps, ...userProps },\n})\n\nexport {\n getChartDefaultProps,\n getLineDefaultProps,\n getBarDefaultProps,\n getRangeOfZAxis,\n}\n\n```"
}
] |
code_store-on-localhost_71a23252
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/typings.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ntype BaseGridProps = Pick<CartesianGridProps, 'vertical' | 'horizontal'>\ntype BaseAxisProps = Pick<\n YAxisProps,\n 'axisLine' | 'tickLine' | 'tick' | 'hide' | 'type' | 'tickMargin'\n>\ntype BaseContainerProps = Pick<\n ResponsiveContainerProps,\n 'height' | 'width' | 'aspect'\n>\ntype DefaultLineProps = Pick<LineProps, 'type' | 'strokeWidth' | 'dot'>\ntype DefaultBarProps = Pick<LineProps, 'layout'>\n\ntype ChartConfig = {\n xAxis?: BaseAxisProps\n yAxis?: BaseAxisProps\n zAxis?: BaseAxisProps\n container?: BaseContainerProps\n grid?: BaseGridProps\n}\n\ntype BaseChartProps = {\n data: object[]\n dataKeys: string[]\n xAxisKey: string\n yAxisKey: string\n zAxisKey: string\n config: ChartConfig\n}\n\ntype LineProps = {\n type?: LineType\n}\n\ntype BarProps = {\n layout?: LayoutType\n}\n\n```"
}
] |
code_store-on-localhost_fbfb4da4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/commonProps.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const commonDefaultProps: ChartConfig = {\n container: {\n height: '100%',\n width: '100%',\n aspect: 4.0 / 3.0,\n },\n xAxis: {\n axisLine: false,\n tickLine: false,\n tick: true,\n tickMargin: 5,\n hide: false,\n type: 'category',\n },\n yAxis: {\n axisLine: false,\n tickLine: false,\n tick: true,\n tickMargin: 5,\n hide: false,\n type: 'number',\n },\n zAxis: {\n axisLine: false,\n tickLine: false,\n tickMargin: 5,\n tick: true,\n hide: false,\n type: 'number',\n },\n grid: {\n horizontal: false,\n vertical: false,\n },\n}\n\nexport const colors = ['#EE7850', '#4CAABF', '#9F50B6', '#479A5E', '#0000FF']\n\nexport const tooltipProps = {\n cursor: false,\n labelStyle: { color: '#828282' },\n}\n\n```"
}
] |
code_store-on-localhost_af159f08
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport PropTypes, { InferProps } from 'prop-types'\n\nimport Toolbar from './Toolbar/index'\nimport { NAMESPACES } from './constants'\nimport Pagination, { PaginationProps } from './Pagination'\nimport DataTable from './DataTable'\nimport BulkActions from './BulkActions'\nimport FilterBar from './FilterBar'\nimport Headings from './DataTable/Headings'\nimport Rows from './DataTable/Rows'\nimport { DENSITY_OPTIONS } from './hooks/useTableMeasures'\nimport { Checkboxes } from '../EXPERIMENTAL_useCheckboxTree/types'\nimport useTableMotion from './hooks/useTableMotion'\nimport Totalizer, { TotalizerProps } from './Totalizer'\nimport ActionBar, { ActionBarProps } from './ActionBar'\nimport { TableProvider } from './context'\n\nconst Table: FC<TableProps> & TableComposites = ({\n children,\n measures,\n isRowActive,\n loading,\n emptyState,\n empty,\n checkboxes,\n rowKey,\n ...props\n}) => {\n if (!measures) {\n throw new Error('Provide measures to the Table')\n }\n\n const { tableHeight, rowHeight, currentDensity } = measures\n const { columns, onRowClick, items, sorting, testId } = props\n const motion = useTableMotion()\n\n return (\n <div\n id={NAMESPACES.CONTAINER}\n data-testid={`${testId}__container`}\n style={{ minHeight: tableHeight, ...motion }}\n className=\"flex flex-column\">\n <TableProvider testId={testId}>{children}</TableProvider>\n <DataTable\n testId={testId}\n empty={empty}\n loading={loading}\n emptyState={emptyState}\n motion={motion}\n height={tableHeight}>\n <thead\n id={NAMESPACES.HEADER}\n data-testid={`${testId}__header`}\n className=\"w-100 ph4 truncate overflow-x-hidden c-muted-2 f6\">\n <Headings\n sorting={sorting}\n columns={columns}\n checkboxes={checkboxes}\n />\n </thead>\n\n {!empty && !loading && (\n <tbody id={NAMESPACES.BODY} data-testid={`${testId}__body`}>\n <Rows\n rowKey={rowKey}\n checkboxes={checkboxes}\n currentDensity={currentDensity}\n columns={columns}\n items={items}\n rowHeight={rowHeight}\n onRowClick={onRowClick}\n isRowActive={isRowActive}\n />\n </tbody>\n )}\n </DataTable>\n </div>\n )\n}\n\nexport const measuresPropTypes = {\n tableHeight: PropTypes.number,\n rowHeight: PropTypes.number,\n currentDensity: PropTypes.oneOf(DENSITY_OPTIONS),\n setCurrentDensity: PropTypes.func,\n}\n\nexport const tablePropTypes = {\n children: PropTypes.node,\n checkboxes: PropTypes.any,\n measures: PropTypes.shape(measuresPropTypes),\n rowKey: PropTypes.func,\n empty: PropTypes.bool,\n columns: PropTypes.arrayOf(\n PropTypes.shape({\n id: PropTypes.string,\n title: PropTypes.oneOfType([\n PropTypes.string,\n PropTypes.elementType,\n PropTypes.func,\n ]),\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n sortable: PropTypes.bool,\n cellRenderer: PropTypes.func,\n extended: PropTypes.bool,\n condensed: PropTypes.arrayOf(PropTypes.string),\n })\n ),\n items: PropTypes.arrayOf(PropTypes.object),\n loading: PropTypes.oneOfType([\n PropTypes.shape({\n renderAs: PropTypes.func,\n }),\n PropTypes.bool,\n ]),\n onRowClick: PropTypes.func,\n isRowActive: PropTypes.func,\n emptyState: PropTypes.shape({\n label: PropTypes.string,\n children: PropTypes.element,\n }),\n sorting: PropTypes.shape({\n sorted: PropTypes.shape({\n by: PropTypes.string,\n order: PropTypes.string,\n }),\n clear: PropTypes.func,\n sort: PropTypes.func,\n }),\n testId: PropTypes.string,\n}\n\nexport type TableProps = InferProps<typeof tablePropTypes> & {\n checkboxes: Checkboxes<unknown>\n}\n\nexport type TableComposites = {\n Toolbar: FC\n FilterBar?: FC\n Pagination?: FC<PaginationProps>\n Bulk?: FC\n Totalizer?: FC<TotalizerProps>\n ActionBar?: FC<ActionBarProps>\n}\n\nTable.Toolbar = Toolbar\nTable.FilterBar = FilterBar\nTable.Totalizer = Totalizer\nTable.Pagination = Pagination\nTable.propTypes = tablePropTypes\nTable.Bulk = BulkActions\nTable.ActionBar = ActionBar\n\nTable.defaultProps = {\n rowKey: ({ rowData }) => `row-${rowData.id}`,\n testId: 'vtex-table-v2',\n}\n\nexport default Table\n\n```"
}
] |
code_store-on-localhost_d8406f4b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Pagination.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport PaginationBase from '../Pagination/index'\nimport { NAMESPACES, ORDER_CLASSNAMES } from './constants'\nimport ActionBar from './ActionBar'\nimport { useTestingContext } from './context'\n\nconst Pagination: FC<PaginationProps> = props => {\n const { testId } = useTestingContext()\n return (\n <ActionBar\n id={NAMESPACES.PAGINATION}\n testId={`${testId}__pagination`}\n order={ORDER_CLASSNAMES.PAGINATION}\n noMargin>\n <PaginationBase {...props} />\n </ActionBar>\n )\n}\n\nexport type PaginationProps = {\n textShowRows: string\n textOf: string\n rowsOptions: Array<number>\n currentItemFrom: number\n currentItemTo: number\n totalItems: number\n onNextClick: (e: Event) => void\n onPrevClick: (e: Event) => void\n onRowsChange: (e: Event, value: unknown) => void\n}\n\nexport default Pagination\n\n```"
}
] |
code_store-on-localhost_9ad7c6f5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Totalizer.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { InferProps } from 'prop-types'\n\nimport TotalizerBase, { totalizerPropTypes } from '../Totalizer/index.js'\nimport { NAMESPACES, ORDER_CLASSNAMES } from './constants'\nimport ActionBar from './ActionBar'\nimport { E2ETestable } from './types'\nimport { useTestingContext } from './context'\n\nconst Totalizer: FC<TotalizerProps> = props => {\n const { testId } = useTestingContext()\n\n return (\n <ActionBar\n id={NAMESPACES.TOTALIZER}\n testId={`${testId}__totalizer`}\n order={ORDER_CLASSNAMES.TOTALIZER}>\n <TotalizerBase {...props} />\n </ActionBar>\n )\n}\n\nexport type TotalizerProps = InferProps<typeof totalizerPropTypes> & E2ETestable\n\nexport default Totalizer\n\n```"
}
] |
code_store-on-localhost_79b4d9b4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/FilterBar.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport { InferProps } from 'prop-types'\n\nimport FilterBarBase, { filterBarPropTypes } from '../FilterBar/index.js'\nimport { NAMESPACES, ORDER_CLASSNAMES } from './constants'\nimport ActionBar from './ActionBar'\nimport { E2ETestable } from './types'\nimport { useTestingContext } from './context'\n\nconst FilterBar: FC<FilterBarProps> = props => {\n const { testId } = useTestingContext()\n return (\n <ActionBar\n id={NAMESPACES.FILTER_BAR}\n testId={`${testId}__filter-bar`}\n order={ORDER_CLASSNAMES.FILTER_BAR}>\n <FilterBarBase {...props} />\n </ActionBar>\n )\n}\n\nexport type FilterBarProps = InferProps<typeof filterBarPropTypes> & E2ETestable\n\nexport default FilterBar\n\n```"
}
] |
code_store-on-localhost_091c4802
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/ActionBar.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classnames from 'classnames'\n\nimport { NAMESPACES, ORDER_CLASSNAMES } from './constants'\nimport { E2ETestable } from './types'\n\nconst ActionBar: FC<ActionBarProps> = ({\n id = NAMESPACES.GENERIC_ACTION_BAR,\n testId = '',\n order = ORDER_CLASSNAMES.GENERIC_ACTION_BAR,\n className,\n noMargin = false,\n children,\n ...props\n}) => {\n const classes = classnames(className, { mb5: !noMargin }, order)\n return (\n <div id={id} data-testid={testId} className={classes} {...props}>\n {children}\n </div>\n )\n}\n\ntype Div = React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n>\n\ntype Props = {\n id?: string\n order?: string\n className?: string\n noMargin?: boolean\n}\n\nexport type ActionBarProps = Div & E2ETestable & Props\n\nexport default ActionBar\n\n```"
}
] |
code_store-on-localhost_d9806915
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### A table displays any kind of structured data and offers controls to easily navigate, search and filter through it. Data may be from just numbers to complex entities that employ other components to represent themselves, like images, tags, links, etc.\n\n# Columns\n\nThe `columns` property is an `Array` used to define the table columns and how they should behave visually. Each column describes each item field should be handled by the `Table`.\n\n```ts\ntype ReturnedData = {\n data: unknown | object\n rowHeight: number\n currentDensity: Density\n motion: ReturnType<typeof useTableMotion>\n}\n\ntype Column = {\n id?: string\n title?: string | Element | Function\n width?: number | string\n cellRenderer?: (data: ReturnedData) => React.ReactNode\n sortable?: boolean\n extended?: boolean\n condensed?: string[]\n}\n```\n\n##### id\n\n- Defines the property name that the column represents.\n- This property is required and must be a string.\n\n##### title\n\n- Controls the title which appears on the table Header.\n- It can receive either a string or an element.\n\n##### width\n\n- Defines a fixed width for the specific column.\n- Receives either a string or number.\n- By default, the column's width is defined to fit the available space without breaking the content.\n\n##### cellRenderer\n\n- Customize the render method of a single column cell.\n- It receives a function that returns a node (react component).\n- The function has the following params: ({ data, rowHeight, currentDensity, motion })\n- data: the value of the current cell.\n- rowHeight: current height of the row.\n- currentDensity: current table density.\n- motion: current row motion, that can be used by internal elements.\n- The default is rendering the value as a string.\n\n##### Sortable\n\n- Indicates if the table can be sorted using this column as a reference.\n\n##### Extended\n\n- Indicates if a column is extended or not.\n- It is generally used to express actions or general information about each row.\n\n##### Condensed\n\n- Indicates if a column is condensed or not.\n- Condensed columns are a combination of two or more columns.\n- It's important to notice that it must have it's ID to represent the join.\n- It receives an array of string, which are the props that will compose the `data` object.\n\n#### Live example\n\nThis live example features all columns props (unless `sortable`, which will be discussed in the `Sort` section).\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst ActionMenu = require('../ActionMenu/index.js').default\nconst OptionsDots = require('../icon/OptionsDots/index.js').default\nconst data = require('./sampleData.ts')\n\n/** Columns definition, must be an array */\nconst columns = [\n {\n /** Prop that this column represents */\n id: 'id',\n /** Title that will appear on Header */\n title: 'ID',\n /** Fixed width */\n width: '3rem',\n },\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'qty',\n title: 'Qty',\n },\n {\n id: 'costPrice',\n title: 'Cost',\n /** Cellrenderer using the default data, which is costPrice in this case */\n cellRenderer: ({ data }) => <Currency value={data} />,\n },\n {\n id: 'retailPrice',\n title: 'Retail',\n cellRenderer: ({ data }) => <Currency value={data} />,\n },\n {\n id: 'profit',\n /** This is a custom title */\n title: <ProfitTitle />,\n /** Profit is a condensed column generated using retailPrice and costPrice props */\n condensed: ['retailPrice', 'costPrice'],\n cellRenderer: ({ data }) => {\n /** As you can see the data is the object of the two props */\n const { costPrice, retailPrice } = data\n const profit = parseFloat(retailPrice) - parseFloat(costPrice)\n return <Currency value={profit} />\n },\n },\n {\n id: 'actions',\n width: '3rem',\n cellRenderer: props => <Actions {...props} />,\n /** This column is extended, its data is the entire row */\n extended: true,\n },\n]\n\nfunction ProfitTitle() {\n return <>💸 Profit</>\n}\n\nconst formatCurrency = value => parseFloat(value).toFixed(2)\n\nfunction Currency({ value }) {\n return <span>$ {formatCurrency(value)}</span>\n}\n\nfunction Actions({ data }) {\n return (\n <ActionMenu\n buttonProps={{\n variation: 'tertiary',\n icon: <OptionsDots />,\n }}\n options={[\n {\n label: 'Action 1',\n onClick: () =>\n alert(\n `Executed action for ${data.name} of price ${data.retailPrice}`\n ),\n },\n {\n label: 'DANGEROUS Action',\n isDangerous: true,\n onClick: () =>\n alert(\n `Executed a DANGEROUS action for ${data.name} of price ${data.retailPrice}`\n ),\n },\n ]}\n />\n )\n}\n\nconst items = data.products\n\nfunction ColumnsExample() {\n /** The useTableMeasures hook will be discussed on the Measures section */\n const measures = useTableMeasures({ size: items.length })\n return <Table measures={measures} items={items} columns={columns} />\n}\n;<ColumnsExample />\n```\n\n# Table Props\n\nThis example, showcase the table using all of its simple props that are `loading`, `emptyState`, `onRowClick`, `columns`, `measures` and `items`\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst Toggle = require('../Toggle/index.js').default\nconst Button = require('../Button/index.js').default\nconst Spinner = require('../Spinner/index.js').default\nconst items = require('./sampleData.ts').customers.slice(0, 5)\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'location',\n title: 'Location',\n },\n]\n\nfunction reducer(state, action) {\n switch (action.type) {\n case 'loading':\n return {\n loading: !state.loading,\n customLoading: false,\n empty: false,\n customEmpty: false,\n }\n case 'custom-loading':\n return {\n loading: false,\n customLoading: !state.customLoading,\n empty: false,\n customEmpty: false,\n }\n case 'empty':\n return {\n loading: false,\n customLoading: false,\n empty: !state.empty,\n customEmpty: false,\n }\n case 'custom-empty':\n return {\n loading: false,\n customLoading: false,\n empty: false,\n customEmpty: !state.customEmpty,\n }\n default:\n return state\n }\n}\n\nfunction SimpleExample() {\n const measures = useTableMeasures({ size: items.length })\n const [\n { loading, customLoading, empty, customEmpty },\n dispatch,\n ] = React.useReducer(reducer, {\n loading: false,\n customLoading: false,\n empty: false,\n customEmpty: false,\n })\n\n const onRowClick = ({ rowData }) => {\n const { name, location } = rowData\n alert(`Your character is ${name}, from ${location}`)\n }\n\n const emptyState = {\n label: 'This is a default empty state for title',\n }\n\n const customEmptyState = {\n label: 'This is a default empty state for title',\n children: (\n <React.Fragment>\n <p>\n A longer explanation of what should be here, and why should I care\n about what should be here.\n </p>\n <div className=\"pt5\">\n <Button variation=\"secondary\" size=\"small\">\n <span className=\"flex align-baseline\">Suggested action</span>\n </Button>\n </div>\n </React.Fragment>\n ),\n }\n\n const tableLoading = customLoading\n ? {\n loading: {\n renderAs: () => {\n return <Spinner color=\"red\" size={50} />\n },\n },\n }\n : { loading }\n\n return (\n <>\n <div className=\"mb5 flex\">\n <Toggle\n label=\"Toggle loading\"\n checked={loading}\n onChange={() => dispatch({ type: 'loading' })}\n />\n <Toggle\n label=\"Toggle CUSTOM loading\"\n checked={customLoading}\n onChange={() => dispatch({ type: 'custom-loading' })}\n />\n </div>\n <div className=\"mb5 flex\">\n <Toggle\n label=\"Toggle empty state\"\n checked={empty}\n onChange={() => dispatch({ type: 'empty' })}\n />\n <Toggle\n label=\"Toggle CUSTOM empty state\"\n checked={customEmpty}\n onChange={() => dispatch({ type: 'custom-empty' })}\n />\n </div>\n <Table\n measures={measures}\n columns={columns}\n items={items}\n onRowClick={onRowClick}\n {...tableLoading}\n empty={empty || customEmpty}\n emptyState={empty ? emptyState : customEmptyState}\n />\n </>\n )\n}\n;<SimpleExample />\n```\n\n# State handlers\n\n## useTableMeasures\n\n```ts\nenum Density {\n Compact = 'compact',\n Regular = 'regular',\n Comfortable = 'comfortable',\n}\n```\n\n### Inputs\n\n| Property | Type | Required | Default | Description |\n| -------- | ------- | -------- | --------------- | ------------------------- |\n| size | number | ✅ | 0 | Length of the table items |\n| density | Density | 🚫 | Density.Regular | Initial Density |\n\n### Outputs\n\n| Property | Type | Description |\n| ----------------- | -------------------------- | ------------------------- |\n| currentDensity | Density | The table current density |\n| rowHeight | number | The height of each row |\n| tableHeight | number | Table's full height |\n| setCurrentDensity | (density: Density) => void | Sets the current density |\n\n### Usage\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'location',\n title: 'Location',\n },\n]\n\nconst customers = data.customers.slice(0, 5)\n\nfunction MeasuresExample() {\n const measures = useTableMeasures({ size: customers.length })\n return <Table measures={measures} columns={columns} items={customers} />\n}\n;<MeasuresExample />\n```\n\n## useTableProportion\n\n### Inputs\n\n| Property | Type | Required | Default | Description |\n| -------- | -------- | -------- | ------- | -------------------- |\n| columns | Column[] | ✅ | 🚫 | Columns of the table |\n| ratio | number[] | ✅ | 🚫 | Ratio of each column |\n\n### Outputs\n\n| Property | Type | Description |\n| ------------ | -------- | --------------------------------------------- |\n| sizedColumns | Column[] | Columns of the table with the selected ratios |\n\n### Usage\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useTableProportion = require('./hooks/useTableProportion.ts').default\nconst ButtonGroup = require('../ButtonGroup/index.js').default\nconst Button = require('../Button/index.js').default\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'id',\n title: 'ID',\n },\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'email',\n title: 'Email',\n },\n]\n\nconst items = data.customers.slice(0, 3)\n\nconst ratios = [\n {\n id: 1,\n title: '1 | 1 | 1',\n value: [1, 1, 1],\n },\n {\n id: 2,\n title: '0.1 | 0.5 | 1',\n value: [0.1, 0.5, 1],\n },\n {\n id: 3,\n title: '0.5 | 0.5 | 1',\n value: [0.5, 0.5, 1],\n },\n]\n\nfunction ProportionExample() {\n const [currentRatio, setCurrentRatio] = React.useState(ratios[0])\n const measures = useTableMeasures({\n size: items.length,\n })\n\n const { sizedColumns } = useTableProportion({\n columns,\n ratio: currentRatio.value,\n })\n\n return (\n <>\n <div className=\"mb5\">\n <ButtonGroup\n buttons={ratios.map(ratio => (\n <Button\n size=\"small\"\n isActiveOfGroup={ratio.id === currentRatio.id}\n onClick={() => setCurrentRatio(ratio)}>\n Ratio: {ratio.title}\n </Button>\n ))}\n />\n </div>\n <Table measures={measures} columns={sizedColumns} items={items} />\n </>\n )\n}\n;<ProportionExample />\n```\n\n## useTableSort\n\n```ts\nenum SortOrder {\n ASC = 'ASC',\n DSC = 'DSC',\n}\n\ntype Sorted = {\n /** order of the sorting */\n order?: SortOrder\n /** reference prop */\n by?: string\n}\n```\n\n### Outputs\n\n| Property | Type | Description |\n| -------- | -------------------- | --------------------------------------- |\n| sorted | Sorted | Order and referecen prop of the sorting |\n| clear | () => void | Clears sorting |\n| sort | (id: string) => void | Toggle sorting by some prop |\n\n### Usage\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useTableSort = require('./hooks/useTableSort.ts').default\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n sortable: true,\n },\n {\n id: 'qty',\n title: 'Qty',\n sortable: true,\n },\n {\n id: 'costPrice',\n title: 'Cost',\n sortable: true,\n },\n {\n id: 'retailPrice',\n title: 'Retail',\n sortable: true,\n },\n]\n\nconst products = data.products.slice(0, 5)\n\nconst ascOrdering = prop => (a, b) =>\n a[prop] > b[prop] ? 1 : a[prop] < b[prop] ? -1 : 0\nconst dscOrdering = prop => (a, b) =>\n a[prop] > b[prop] ? -1 : a[prop] < b[prop] ? 1 : 0\n\nfunction SortExample() {\n const sorting = useTableSort()\n const measures = useTableMeasures({\n size: products.length,\n })\n\n const items = React.useMemo(() => {\n const {\n sorted: { order, by },\n } = sorting\n if (!order) {\n return products\n }\n const ascending = order === 'ASC'\n const comparator = ascending ? ascOrdering(by) : dscOrdering(by)\n return products.sort(comparator)\n }, [sorting.sorted, data.products])\n\n return (\n <Table\n measures={measures}\n columns={columns}\n items={items}\n sorting={sorting}\n />\n )\n}\n;<SortExample />\n```\n\n## useTableVisibility\n\n### Inputs\n\n| Property | Type | Required | Default | Description |\n| ------------- | -------- | -------- | ------- | -------------------------------- |\n| columns | Column[] | ✅ | 🚫 | Columns of the table |\n| hiddenColumns | string[] | 🚫 | [] | Columns that are initally hidden |\n\n### Outputs\n\n| Property | Type | Description |\n| -------------- | -------------------- | -------------------------------- |\n| visibleColumns | Column[] | Columns that are visible |\n| hiddenColumns | string[] | Columns that are hidden |\n| toggleColumn | (id: string) => void | Toggle a column visibility by id |\n| showAllColumns | () => void | Make all columns visible |\n| hideAllColumns | () => void | Make all columns hidden |\n\n### Usage\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useTableVisibility = require('./hooks/useTableVisibility.ts').default\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'id',\n title: 'ID',\n },\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'location',\n title: 'location',\n },\n]\n\nconst items = data.customers.slice(0, 5)\n\nfunction VisibilityExample() {\n const measures = useTableMeasures({\n size: items.length,\n })\n const visibility = useTableVisibility({\n columns,\n hiddenColumns: ['id', 'location'],\n })\n\n const buttonColumns = {\n label: 'Toggle visible fields',\n showAllLabel: 'Show All',\n hideAllLabel: 'Hide All',\n visibility,\n }\n\n return (\n <>\n <Table\n measures={measures}\n columns={visibility.visibleColumns}\n items={items}>\n <Table.Toolbar>\n <Table.Toolbar.ButtonGroup>\n <Table.Toolbar.ButtonGroup.Columns {...buttonColumns} />\n </Table.Toolbar.ButtonGroup>\n </Table.Toolbar>\n </Table>\n </>\n )\n}\n;<VisibilityExample />\n```\n\n# Features\n\n<div className=\"center mw7 pv6\">\n \n</div>\n\n## Toolbar\n\nThe toolbar is a bundle of features, including search input, autocomplete, columns visibility toggle, density controls, import and export buttons, extra actions menu using ActionMenu component and a newLine button to help with entry creation (you can see the illustrative diagram in the beginning of the page for a better visualization of this structure)\n\n#### InputSearch\n\n- A wrapper around `InputSearch` component. The props are the same.\n\n#### InputAutocomplete\n\n- A wrapper around `AutocompleteInput` component. The props are the same.\n\n#### Button Group\n\nRepresents the group of buttons located at the right. It has other composites that are described down below.\n\n##### Columns\n\n- A button that toggles columns visibility.\n- It is recommended to combine it with the `useTableVisibility` hook.\n\n```ts\nenum Alignment {\n Left = 'left',\n Right = 'right',\n}\n```\n\n| Property | Type | Required | Default | Description |\n| ------------ | ---------------------------- | -------- | ------- | -------------------------------- |\n| label | string | ✅ | 🚫 | General label |\n| showAllLabel | string | ✅ | 🚫 | Label for the show all button |\n| hideAllLabel | string | ✅ | 🚫 | Label for the hide all button |\n| visibility | Return of useTableVisibility | ✅ | 🚫 | Visibility of the columns |\n| alignMenu | Alignment | 🚫 | 🚫 | Menu alignment |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n\n##### Density\n\n- A button that changes the row's density.\n- It is recommended to combine it with the `useTableMeasures` hook.\n\n```ts\nenum Alignment {\n Left = 'left',\n Right = 'right',\n}\n\nenum Density {\n Compact = 'compact',\n Regular = 'regular',\n Comfortable = 'comfortable',\n}\n```\n\n| Property | Type | Required | Default | Description |\n| ---------------- | -------------------------- | -------- | ------- | -------------------------------- |\n| density | Return of useTableMeasures | ✅ | 🚫 | Density object |\n| compactLabel | string | ✅ | 🚫 | Label of the compact option |\n| regularLabel | string | ✅ | 🚫 | Label of the regular option |\n| comfortableLabel | string | ✅ | 🚫 | Label of the comfortable option |\n| alignMenu | Alignment | 🚫 | 🚫 | Menu alignment |\n| handleCallback | (density: Density) => void | 🚫 | 🚫 | Triggered on change density |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n\n##### Download\n\n- Button to handle download or export actions.\n\n| Property | Type | Required | Default | Description |\n| -------- | ---------- | -------- | ------- | -------------------------------- |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n| label | string | 🚫 | \"\" | Button text |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n\n##### Upload\n\n- Button to handle upload or import actions.\n\n| Property | Type | Required | Default | Description |\n| -------- | ---------- | -------- | ------- | -------------------------------- |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n| label | string | 🚫 | 🚫 | Button text |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n\n##### ExtraActions\n\n- Button to perform extra actions.\n\n```ts\nenum Alignment {\n Left = 'left',\n Right = 'right',\n}\n\ntype MenuAction = {\n label: string\n onClick: Function\n toggle?: {\n checked: boolean\n semantic: boolean\n }\n id?: number | string\n}\n```\n\n| Property | Type | Required | Default | Description |\n| --------- | ------------ | -------- | ------- | -------------------------------- |\n| actions | MenuAction[] | ✅ | 🚫 | Action on click button |\n| label | string | 🚫 | 🚫 | Button label |\n| isLoading | boolean | 🚫 | false | If the button is loading or not |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n| alignMenu | Alignment | 🚫 | 🚫 | Menu alignment |\n\n##### NewLine\n\n- A button that represents creational purposes.\n\n```ts\ntype MenuAction = {\n label: string\n onClick: Function\n toggle?: {\n checked: boolean\n semantic: boolean\n }\n id?: number | string\n}\n```\n\n| Property | Type | Required | Default | Description |\n| --------- | ------------ | -------- | ------- | -------------------------------- |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n| label | string | 🚫 | 🚫 | Button text |\n| actions | MenuAction[] | 🚫 | 🚫 | Action on click button |\n| isLoading | boolean | 🚫 | false | If the button is loading or not |\n| disabled | boolean | 🚫 | false | If the button is disabled or not |\n\n#### Working example\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useTableVisibility = require('./hooks/useTableVisibility.ts').default\nconst Tag = require('../Tag/index.js').default\nconst Icons = require('react-icons/fa')\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'id',\n title: 'ID',\n },\n {\n id: 'icon',\n title: 'Icon',\n cellRenderer: ({ data, rowHeight, motion }) => (\n <Icon name={data} style={motion} height={rowHeight} />\n ),\n },\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'status',\n title: 'Status',\n cellRenderer: ({ data }) => <Status status={data} />,\n },\n]\n\nfunction Icon({ name, height, style }) {\n const SelectedIcon = Icons[name]\n return <SelectedIcon style={style} className=\"c-muted-1\" size={height - 5} />\n}\n\nfunction Status({ status }) {\n const type = status === 'ACTIVE' ? 'success' : 'neutral'\n return <Tag type={type}>{status}</Tag>\n}\n\nconst items = data.payments\n\nfunction reducer(state, action) {\n switch (action.type) {\n case 'change': {\n const { value } = action\n return {\n ...state,\n inputValue: value,\n }\n }\n case 'clear': {\n return {\n inputValue: '',\n displayItems: items,\n }\n }\n case 'submit': {\n const inputClear = state.input === ''\n const filterFn = item =>\n item.name.toLowerCase().includes(state.inputValue.toLowerCase())\n return {\n ...state,\n displayItems: inputClear ? items : items.filter(filterFn),\n }\n }\n default: {\n return state\n }\n }\n}\n\nfunction ToolbarExample() {\n const [state, dispatch] = React.useReducer(reducer, {\n inputValue: '',\n displayItems: items,\n })\n\n const visibility = useTableVisibility({\n columns,\n items,\n hiddenColumns: ['id'],\n })\n\n const measures = useTableMeasures({\n size: state.displayItems.length,\n })\n\n const inputSearch = {\n value: state.inputValue,\n placeholder: 'Search stuff...',\n onChange: e => dispatch({ type: 'change', value: e.currentTarget.value }),\n onClear: () => {\n dispatch({ type: 'clear' })\n },\n onSubmit: e => {\n e.preventDefault()\n dispatch({ type: 'submit' })\n },\n }\n\n const buttonColumns = {\n label: 'Toggle visible fields',\n showAllLabel: 'Show All',\n hideAllLabel: 'Hide All',\n visibility,\n }\n\n const density = {\n label: 'Line density',\n compactLabel: 'Compact',\n regularLabel: 'Regular',\n comfortableLabel: 'Comfortable',\n }\n\n const download = {\n label: 'Export',\n onClick: () => alert('Clicked EXPORT'),\n }\n\n const upload = {\n label: 'Import',\n onClick: () => alert('Clicked IMPORT'),\n }\n\n const extraActions = {\n label: 'More options',\n actions: [\n {\n label: 'An action',\n onClick: () => alert('An action'),\n },\n {\n label: 'Another action',\n onClick: () => alert('Another action'),\n },\n {\n label: 'A third action',\n onClick: () => alert('A third action'),\n },\n ],\n }\n\n const newLine = {\n label: 'New',\n onClick: () => alert('handle new line callback'),\n actions: [\n 'General',\n 'Desktop & Screen Saver',\n 'Dock',\n 'Language & Region',\n ].map(label => ({\n label,\n onClick: () => alert(`Clicked ${label}`),\n })),\n }\n\n const emptyState = {\n label: 'The table is empty',\n }\n\n const empty = React.useMemo(\n () =>\n state.displayItems.length === 0 ||\n Object.keys(visibility.visibleColumns).length === 0,\n [visibility.visibleColumns, state.displayItems]\n )\n\n return (\n <Table\n empty={empty}\n measures={measures}\n items={state.displayItems}\n columns={visibility.visibleColumns}\n emptyState={emptyState}>\n <Table.Toolbar>\n <Table.Toolbar.InputSearch {...inputSearch} />\n <Table.Toolbar.ButtonGroup>\n <Table.Toolbar.ButtonGroup.Columns {...buttonColumns} />\n <Table.Toolbar.ButtonGroup.Density density={measures} {...density} />\n <Table.Toolbar.ButtonGroup.Download {...download} />\n <Table.Toolbar.ButtonGroup.Upload {...upload} />\n <Table.Toolbar.ButtonGroup.ExtraActions {...extraActions} />\n <Table.Toolbar.ButtonGroup.NewLine {...newLine} />\n </Table.Toolbar.ButtonGroup>\n </Table.Toolbar>\n </Table>\n )\n}\n;<ToolbarExample />\n```\n\n## Totalizer\n\nThis uses the Totalizer component between the toolbar and the table content. You can find the full specs on the [Totalizer specific docs](https://styleguide.vtex.com/#/Components/Display/Totalizer).\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst ArrowUp = require('../icon/ArrowUp/index.js').default\nconst ArrowDown = require('../icon/ArrowDown/index.js').default\n\nconst data = require('./sampleData')\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'manufacturer',\n title: 'Manufacturer',\n },\n {\n id: 'qty',\n title: 'Qty',\n },\n {\n id: 'costPrice',\n title: 'Cost',\n cellRenderer: ({ data }) => <Currency value={data} />,\n },\n {\n id: 'retailPrice',\n title: 'Retail',\n cellRenderer: ({ data }) => <Currency value={data} />,\n },\n]\n\nconst formatCurrency = value => parseFloat(value).toFixed(2)\n\nfunction Currency({ value }) {\n return <span>$ {formatCurrency(value)}</span>\n}\n\nconst items = data.products\n\nfunction TotalizerExample() {\n const measures = useTableMeasures({\n size: items.length,\n })\n\n const totalizer = React.useMemo(() => {\n const sum = items.reduce(\n (acc, item) => {\n const { stock, cost, retail } = acc\n\n return {\n stock: stock + item.qty,\n cost: cost + item.qty * item.costPrice,\n retail: retail + item.qty * item.retailPrice,\n }\n },\n {\n stock: 0,\n cost: 0,\n retail: 0,\n }\n )\n return {\n items: [\n {\n label: 'Stock',\n value: sum.stock,\n },\n\n {\n label: 'Total cost',\n value: `$ ${formatCurrency(sum.cost)}`,\n iconBackgroundColor: '#fda4a4',\n icon: <ArrowDown color=\"#dd1616\" size={14} />,\n },\n {\n label: 'Total retail',\n value: `$ ${formatCurrency(sum.retail)}`,\n iconBackgroundColor: '#eafce3',\n icon: <ArrowUp color=\"#79B03A\" size={14} />,\n },\n {\n label: 'Expected Profit',\n value: `$ ${formatCurrency(sum.retail - sum.cost)}`,\n },\n ],\n }\n }, [items])\n\n return (\n <Table measures={measures} columns={columns} items={items}>\n <Table.Totalizer {...totalizer} />\n </Table>\n )\n}\n\n;<TotalizerExample />\n```\n\n## Bulk Actions\n\n- Bulk actions allow the user to select some or all the rows to apply an action.\n- It is recommended the usage along with the `EXPERIMENTAL_useCheckboxTree` hook which [has its docs](https://styleguide.vtex.com/#/Components/%F0%9F%91%BB%20Experimental/EXPERIMENTALUseCheckboxTree).\n- Like the `Toolbar`, `BulkActions` is a compound component.\n\n#### Actions\n\n##### Primary\n\n- Button to handle primary.\n\n| Property | Type | Required | Default | Description |\n| -------- | ---------- | -------- | ------- | ---------------------- |\n| label | string | ✅ | 🚫 | Button text |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n\n##### Secondary\n\n- Button to handle secondary actions.\n\n| Property | Type | Required | Default | Description |\n| ------------- | ----------------------- | -------- | ------- | ----------------------- |\n| label | string | ✅ | 🚫 | Button text |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n| onActionClick | (e: MenuAction) => void | 🚫 | 🚫 | Action on click actions |\n\n#### Tail\n\n##### Info\n\n- Displays information of any kind.\n- Often used to display selected rows count.\n\n| Property | Type | Required | Default | Description |\n| -------- | -------------- | -------- | ------- | --------------- |\n| children | React.ReacNode | 🚫 | 🚫 | Info to display |\n\n##### Toggle\n\n- Action that hidden when active, showing it's children.\n- It is inactive, shows a Button.\n\n```ts\ntype Button = {\n text: string\n onClick: () => void\n}\n```\n\n| Property | Type | Required | Default | Description |\n| -------- | -------------- | -------- | ------- | ----------------------------- |\n| button | Button | ✅ | 🚫 | Button props |\n| active | boolean | 🚫 | false | Action on click button |\n| children | React.ReacNode | 🚫 | 🚫 | Item to show when is inactive |\n\n##### Dismiss\n\n- Button to handle download or export actions.\n\n| Property | Type | Required | Default | Description |\n| -------- | ---------- | -------- | ------- | ---------------------- |\n| onClick | () => void | ✅ | 🚫 | Action on click button |\n\n#### Working Example\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useCheckboxTree = require('../EXPERIMENTAL_useCheckboxTree').default\nconst data = require('./sampleData')\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'manufacturer',\n title: 'Manufacturer',\n },\n {\n id: 'qty',\n title: 'Qty',\n },\n {\n id: 'costPrice',\n title: 'Cost',\n cellRenderer: props => <Currency {...props} />,\n },\n {\n id: 'wholesalePrice',\n title: 'Wholesale',\n cellRenderer: props => <Currency {...props} />,\n },\n {\n id: 'retailPrice',\n title: 'Retail',\n cellRenderer: props => <Currency {...props} />,\n },\n]\n\nfunction Currency({ data }) {\n return <>$ {parseFloat(data).toFixed(2)}</>\n}\n\nfunction useProducts() {\n const [items, setItems] = React.useState(data.products)\n\n const bulkUpdate = group => positive => {\n const groupIds = group.map(item => item.id)\n setItems(oldItems =>\n oldItems.map(item => (groupIds.includes(item.id) ? positive(item) : item))\n )\n }\n\n const discountCurry = amt => value => value - value * amt\n\n const applyDiscount = React.useCallback(\n (group, amt) => {\n const calcDiscount = discountCurry(amt)\n const update = bulkUpdate(group)\n update(item => ({\n ...item,\n retailPrice: calcDiscount(item.retailPrice),\n wholesalePrice: calcDiscount(item.wholesalePrice),\n }))\n },\n [items]\n )\n\n const increaseQty = React.useCallback(\n (group, amt) => {\n const update = bulkUpdate(group)\n update(item => ({\n ...item,\n qty: item.qty + amt,\n }))\n },\n [items]\n )\n\n const decreaseQty = React.useCallback(\n (group, amt) => {\n const update = bulkUpdate(group)\n update(item => ({\n ...item,\n qty: item.qty - amt,\n }))\n },\n [items]\n )\n\n return { items, applyDiscount, increaseQty, decreaseQty }\n}\n\nfunction BulkFullExample() {\n const { items, applyDiscount, increaseQty, decreaseQty } = useProducts()\n\n const primaryAction = {\n label: 'Apply 50% Discount',\n onClick: () => applyDiscount(checkboxes.checkedItems, 0.5),\n }\n\n const secondaryActions = {\n label: 'Quantity',\n actions: [\n {\n label: 'Increase 50',\n onClick: checked => increaseQty(checked, 50),\n },\n {\n label: 'Decrease 50',\n onClick: checked => decreaseQty(checked, 50),\n },\n ],\n onActionClick: action => action.onClick(checkboxes.checkedItems),\n }\n\n const measures = useTableMeasures({\n size: items.length,\n })\n\n const checkboxes = useCheckboxTree({\n items,\n onToggle: ({ checkedItems }) => console.table(checkedItems),\n })\n\n return (\n <>\n <Table\n measures={measures}\n checkboxes={checkboxes}\n columns={columns}\n items={items}>\n <Table.Bulk active={checkboxes.someChecked}>\n <Table.Bulk.Actions>\n <Table.Bulk.Actions.Primary {...primaryAction} />\n <Table.Bulk.Actions.Secondary {...secondaryActions} />\n </Table.Bulk.Actions>\n <Table.Bulk.Tail>\n {!checkboxes.allChecked && (\n <Table.Bulk.Tail.Info>\n All rows selected: {checkboxes.checkedItems.length}\n </Table.Bulk.Tail.Info>\n )}\n <Table.Bulk.Tail.Toggle\n button={{\n text: `Select all ${items.length}`,\n onClick: checkboxes.checkAll,\n }}\n active={checkboxes.allChecked}>\n Selected rows: {items.length}\n </Table.Bulk.Tail.Toggle>\n <Table.Bulk.Tail.Dismiss onClick={checkboxes.uncheckAll} />\n </Table.Bulk.Tail>\n </Table.Bulk>\n </Table>\n </>\n )\n}\n\n;<BulkFullExample />\n```\n\n## Autocomplete, Filters & Pagination\n\nEach component has it's own documentation ([Autocomplete](https://styleguide.vtex.com/#/Components/Forms/AutocompleteInput), [Filters](https://styleguide.vtex.com/#/Components/Display/FilterBar), [Pagination](https://styleguide.vtex.com/#/Components/Navigation/Pagination)), so it's important to you check it out to see the full capabilities.\n\n```js\nconst useTableMeasures = require('./hooks/useTableMeasures.tsx').default\nconst useTableProportion = require('./hooks/useTableProportion.ts').default\nconst Input = require('../Input/index.js').default\nconst Checkbox = require('../Checkbox/index.js').default\nconst data = require('./sampleData.ts')\n\nconst columns = [\n {\n id: 'name',\n title: 'Name',\n },\n {\n id: 'email',\n title: 'Email',\n },\n {\n id: 'location',\n title: 'Location',\n },\n]\n\nconst items = data.customers\n\n/** hook that handles pagination state */\nfunction usePagination(initialSize, items) {\n const [state, setState] = React.useState({\n tableSize: initialSize,\n currentPage: 1,\n currentItemFrom: 1,\n currentItemTo: initialSize,\n slicedItems: [...items].slice(0, initialSize),\n })\n\n /** resets state on items change */\n React.useEffect(() => {\n setState({\n tableSize: initialSize,\n currentPage: 1,\n currentItemFrom: 1,\n currentItemTo: initialSize,\n slicedItems: [...items].slice(0, initialSize),\n })\n }, [items])\n\n /** gets the next page */\n const onNextClick = React.useCallback(() => {\n const newPage = state.currentPage + 1\n const itemFrom = state.currentItemTo + 1\n const itemTo = state.tableSize * newPage\n const newItems = [...items].slice(itemFrom - 1, itemTo)\n setState(state => ({\n ...state,\n currentPage: newPage,\n currentItemFrom: itemFrom,\n currentItemTo: itemTo,\n slicedItems: newItems,\n }))\n }, [state, items])\n\n /** gets the previous page */\n const onPrevClick = React.useCallback(() => {\n if (state.currentPage === 0) return\n const newPage = state.currentPage - 1\n const itemFrom = state.currentItemFrom - state.tableSize\n const itemTo = state.currentItemFrom - 1\n const newItems = [...items].slice(itemFrom - 1, itemTo)\n setState(state => ({\n ...state,\n currentPage: newPage,\n currentItemFrom: itemFrom,\n currentItemTo: itemTo,\n slicedItems: newItems,\n }))\n }, [state, items])\n\n /** deals rows change of Pagination component */\n const onRowsChange = React.useCallback(\n (e, value) => {\n const rowValue = parseInt(value)\n setState(state => ({\n ...state,\n tableSize: rowValue,\n currentItemTo: rowValue,\n slicedItems: [...items].slice(state.currentItemFrom - 1, rowValue),\n }))\n },\n [state, items]\n )\n\n return {\n onNextClick,\n onPrevClick,\n onRowsChange,\n ...state,\n }\n}\n\nfunction PaginationExample() {\n const ITEMS_PER_PAGE = 5\n\n /** handles sizes */\n const measures = useTableMeasures({ size: ITEMS_PER_PAGE })\n\n /** handles filtering */\n const [filteredItems, setFilteredItems] = React.useState(items)\n const [filterStatements, setFilterStatements] = React.useState([])\n\n /* handles pagination */\n const { slicedItems, ...paginationProps } = usePagination(\n ITEMS_PER_PAGE,\n filteredItems\n )\n\n /** handles proportion consistency on change pages */\n const { sizedColumns } = useTableProportion({ columns, ratio: [1, 1] })\n\n /** handles autocomplete */\n const [term, setTerm] = React.useState('')\n const [loading, setLoading] = React.useState(false)\n const timeoutRef = React.useRef(null)\n\n /** props of the PaginationComponent */\n const pagination = {\n ...paginationProps,\n textOf: 'of',\n rowsOptions: [5, 10, 15],\n textShowRows: 'Show rows',\n totalItems: filteredItems.length,\n }\n\n /** function to handle filter changes more info @ Styleguides FilterBar docs */\n function handleFiltersChange(statements = []) {\n let newData = items.slice()\n statements.forEach(st => {\n if (!st || !st.object) return\n const { subject, verb, object } = st\n switch (subject) {\n case 'name':\n case 'email':\n if (verb === 'contains') {\n newData = newData.filter(item => item[subject].includes(object))\n } else if (verb === '=') {\n newData = newData.filter(item => item[subject] === object)\n } else if (verb === '!=') {\n newData = newData.filter(item => item[subject] !== object)\n }\n break\n\n case 'location':\n if (!object) return\n const selectedLocations = Object.keys(object).reduce(\n (acc, item) => (object[item] ? [...acc, item] : acc),\n []\n )\n newData = newData.filter(item =>\n selectedLocations.includes(item[subject])\n )\n break\n }\n })\n setFilteredItems(newData)\n setFilterStatements(statements)\n }\n\n /** FilterBar props */\n const filters = {\n alwaysVisibleFilters: ['name', 'location'],\n statements: filterStatements,\n onChangeStatements: handleFiltersChange,\n clearAllFiltersButtonLabel: 'Clear Filters',\n collapseLeft: true,\n options: {\n name: {\n label: 'Name',\n ...simpleInputVerbsAndLabel(),\n },\n email: {\n label: 'Email',\n ...simpleInputVerbsAndLabel(),\n },\n location: {\n label: 'Location',\n renderFilterLabel: st => {\n if (!st || !st.object) {\n return 'All'\n }\n const keys = st.object ? Object.keys(st.object) : {}\n const isAllTrue = !keys.some(key => !st.object[key])\n const isAllFalse = !keys.some(key => st.object[key])\n const trueKeys = keys.filter(key => st.object[key])\n let trueKeysLabel = ''\n trueKeys.forEach((key, index) => {\n trueKeysLabel += `${key}${\n index === trueKeys.length - 1 ? '' : ', '\n }`\n })\n return `${\n isAllTrue ? 'All' : isAllFalse ? 'None' : `${trueKeysLabel}`\n }`\n },\n verbs: [\n {\n label: 'includes',\n value: 'includes',\n object: {\n renderFn: locationSelectorObject,\n extraParams: {},\n },\n },\n ],\n },\n },\n }\n\n /** Autocomplete options prop */\n const options = {\n onSelect: (...args) => console.log('onSelect: ', ...args),\n loading,\n value: !term.length\n ? []\n : filteredItems\n .map(item => item.name)\n .filter(name =>\n typeof name === 'string'\n ? name.toLowerCase().includes(term.toLowerCase())\n : name.label.toLowerCase().includes(term.toLowerCase())\n ),\n }\n\n /** Autocomplete input prop */\n const input = {\n onChange: term => {\n if (term) {\n setLoading(true)\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n timeoutRef.current = setTimeout(() => {\n setLoading(false)\n setTerm(term)\n timeoutRef.current = null\n }, 1000)\n } else {\n setTerm(term)\n }\n },\n onSearch: (...args) => console.log('onSearch:', ...args),\n onClear: () => setTerm(''),\n placeholder: 'Search name... (e.g.: Peter)',\n value: term,\n }\n\n return (\n <Table measures={measures} items={slicedItems} columns={sizedColumns}>\n <Table.Toolbar>\n <Table.Toolbar.InputAutocomplete input={input} options={options} />\n </Table.Toolbar>\n <Table.FilterBar {...filters} />\n <Table.Pagination {...pagination} />\n </Table>\n )\n}\n\n/** simple input renderer */\nfunction simpleInputObject({ values, onChangeObjectCallback }) {\n return (\n <Input\n value={values || ''}\n onChange={e => onChangeObjectCallback(e.target.value)}\n />\n )\n}\n\n/** simple input verbs renderer */\nfunction simpleInputVerbsAndLabel() {\n return {\n renderFilterLabel: st => {\n if (!st || !st.object) {\n // you should treat empty object cases only for alwaysVisibleFilters\n return 'Any'\n }\n return `${\n st.verb === '=' ? 'is' : st.verb === '!=' ? 'is not' : 'contains'\n } ${st.object}`\n },\n verbs: [\n {\n label: 'is',\n value: '=',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n {\n label: 'is not',\n value: '!=',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n {\n label: 'contains',\n value: 'contains',\n object: {\n renderFn: simpleInputObject,\n extraParams: {},\n },\n },\n ],\n }\n}\n\n/** location input renderer */\nfunction locationSelectorObject({ values, onChangeObjectCallback }) {\n const initialValue = {\n '🇰🇪Wakanda': true,\n '🇺🇸USA': true,\n '🇨🇳China': true,\n '🇷🇺Russia': true,\n '🇬🇧Great Britain': true,\n '🇸🇦Saudi Arabia': true,\n '🇨🇺Cuba': true,\n ...(values || {}),\n }\n const toggleValueByKey = key => {\n const newValues = {\n ...(values || initialValue),\n [key]: values ? !values[key] : false,\n }\n return newValues\n }\n return (\n <div>\n {Object.keys(initialValue).map((opt, index) => {\n return (\n <div className=\"mb3\" key={`class-statment-object-${opt}-${index}`}>\n <Checkbox\n checked={values ? values[opt] : initialValue[opt]}\n label={opt}\n name=\"default-checkbox-group\"\n onChange={() => {\n const newValue = toggleValueByKey(`${opt}`)\n const newValueKeys = Object.keys(newValue)\n const isEmptyFilter = !newValueKeys.some(key => !newValue[key])\n onChangeObjectCallback(isEmptyFilter ? null : newValue)\n }}\n value={opt}\n />\n </div>\n )\n })}\n </div>\n )\n}\n\n;<PaginationExample />\n```\n\n# 🧪 E2E Testing\n\nThe Table has a lot of internal components. To avoid receiving a huge object containing id's of each component, they are semantically created based on the `testId` property.\n\nYou can reference as `[data-testid]=id` on your e2e testing tool, such as cypress.\n\n#### Table of semantic generated data-testid's:\n\n💡[id] represents the value of `testId` property, which is `vtex-table-v2` by default.\n\n| Targets | Decription |\n| ------------------------------------- | ----------------------------------------------------------------- |\n| `[id]` | Internal `table` |\n| `[id]__container` | `table`'s container |\n| `[id]__header` | `table`'s `thead` |\n| `[id]__body` | `table`'s `tbody` |\n| `[id]__loading` | `Loading` container |\n| `[id]__empty-state` | `EmptyState` component |\n| `[id]__filter-bar` | `Table.FilterBar` wrapper |\n| `[id]__totalizer` | `Table.Totalizer` wrapper |\n| `[id]__pagination` | `Table.Pagination` wrapper |\n| `[id]__toolbar` | `Table.Toolbar` root |\n| `[toolbar]__search-form` | `Table.Toolbar.InputSearch` `form` tag |\n| `[toolbar]__search-form__input` | `Table.Toolbar.InputSearch` input |\n| `[toolbar]__input-autocomplete` | `Table.Toolbar.InputAutocomplete` wrapper |\n| `[toolbar]__button-group` | `Table.Toolbar.ButtonGroup` root |\n| `[button-group]__columns` | `Table.Toolbar.ButtonGroup.Columns` button |\n| `[button-group]__columns__box` | `Table.Toolbar.ButtonGroup.Columns` box |\n| `[columns-box]__group-actions` | `Table.Toolbar.ButtonGroup.Columns` box actions |\n| `[columns-box]__group-actions--[key]` | `Table.Toolbar.ButtonGroup.Columns` box action of key (1, 2, ...) |\n| `[columns-box]__items` | `Table.Toolbar.ButtonGroup.Columns` box items |\n| `[button-group]__density` | `Table.Toolbar.ButtonGroup.Density` button |\n| `[button-group]__density__box` | `Table.Toolbar.ButtonGroup.Density` box |\n| `[density-box]__items` | `Table.Toolbar.ButtonGroup.Density` box items |\n| `[button-group]__download` | `Table.Toolbar.ButtonGroup.Download` button |\n| `[button-group]__upload` | `Table.Toolbar.ButtonGroup.Upload` button |\n| `[button-group]__extra-actions` | `Table.Toolbar.ButtonGroup.ExtraActions` button |\n| `[button-group]__new-line` | `Table.Toolbar.ButtonGroup.NewLine` button |\n\n# 📚 Migration Guide\n\nThis section is designed to `Table V1` users that desire to upgrade and enjoy the `V2` benefits. Will be discussed the key differences between the two. The reading of the V2 documentation is essential, though.\n\n### Schema vs Columns\n\nThe V1 introduced the concept of the table schema, which was a JSON object of type:\n\n```ts\ntype Schema = {\n properties: {\n [key: string]: {\n title: string\n width: number\n minWidth: number\n cellRenderer: ({\n cellData,\n rowData,\n updateCellMeasurements,\n }) => React.ReactNode\n headerRight: boolean\n sortable: boolean\n headerRenderer: ({ columnIndex, key, title }) => React.ReactNode\n }\n }\n}\n```\n\nThe V2 take on the same problem is the `columns` property, which is an array of columns of type:\n\n```ts\ntype Column = {\n id?: string\n title?: string | Element | Function\n width?: number | string\n cellRenderer?: (cellData: {\n data: unknown | object\n rowHeight: number\n currentDensity: Density\n motion: ReturnType<typeof useTableMotion>\n }) => React.ReactNode\n sortable?: boolean\n extended?: boolean\n condensed?: string[]\n}\n```\n\nWe can conclude that:\n\n- ➕ The `title` now supports strings or objects.\n- ➕ The `width` that was a number, is now a string or a number.\n- ➕ We have two new props: `extended` and `condensed`, to handle what rowData was supposed to deal with.\n- ♻️ The `key` was converted to an `id` prop of the column object.\n- ♻️ `sortable` is kept and did not even change its purpose or type.\n- The `cellRenderer` props:\n- ➕ The cell can react to `rowHeight`, `currentDensity` and `motion`.\n- ♻️ `cellData` is now called `data`\n- 🚫 `rowData` is deprecated\n- 🚫 `updateCellMeasurements` is deprecated\n- 🚫 The `minWidth` is deprecated.\n- 🚫 `headerRight` is deprecated\n- 🚫 `headerRenderer` is deprecated since its job is done by title.\n\n```"
}
] |
code_store-on-localhost_2f250988
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/types.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { Density } from './hooks/useTableMeasures'\nimport useTableMotion from './hooks/useTableMotion'\n\nexport type Items = object[]\n\nexport type ReturnedData = {\n data: unknown | object\n rowHeight: number\n currentDensity: Density\n motion: ReturnType<typeof useTableMotion>\n}\n\nexport type Column = {\n id?: string\n title?: string | Element | Function\n width?: number | string\n sortable?: boolean\n cellRenderer?: (data: ReturnedData) => React.ReactNode\n extended?: boolean\n condensed?: string[]\n}\n\nexport type E2ETestable<T = string> = {\n testId?: T\n}\n\n```"
}
] |
code_store-on-localhost_2d692fab
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/constants.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const ORDER_CLASSNAMES = {\n TOOLBAR: 'order-0',\n TOOLBAR_CHILD: {\n INPUT: 'order-0',\n POSITION_FIXER: 'order-1',\n BUTTON_GROUP: 'order-2',\n BUTTON_GROUP_CHILD: {\n COLUMNS: 'order-0',\n DENSITY: 'order-1',\n DOWNLOAD: 'order-2',\n UPLOAD: 'order-3',\n EXTRA_ACTIONS: 'order-4',\n NEWLINE: 'order-5',\n },\n },\n FILTER_BAR: 'order-1',\n TOTALIZER: 'order-2',\n GENERIC_ACTION_BAR: 'order-3',\n BULK: 'order-4',\n BULK_CHILD: {\n ACTIONS: 'order-0',\n ACTIONS_CHILD: {\n PRIMARY: 'order-0',\n SECONDARY: 'order-1',\n },\n POSITION_FIXER: 'order-1',\n RIGHT: 'order-2',\n },\n TABLE: 'order-5',\n PAGINATION: 'order-6',\n}\n\nexport const NAMESPACE_PREFIX = 'vtex-table-v2'\nexport const NAMESPACES = {\n CONTAINER: `${NAMESPACE_PREFIX}__container`,\n TABLE: `${NAMESPACE_PREFIX}`,\n HEADER: `${NAMESPACE_PREFIX}__header`,\n BODY: `${NAMESPACE_PREFIX}__body`,\n ROW: `${NAMESPACE_PREFIX}__row`,\n CELL: `${NAMESPACE_PREFIX}__cell`,\n TOOLBAR: {\n CONTAINER: `${NAMESPACE_PREFIX}__toolbar`,\n INPUT_SEARCH: `${NAMESPACE_PREFIX}__toolbar__input-search`,\n BUTTON_GROUP: `${NAMESPACE_PREFIX}__toolbar__button-group`,\n BUTTON_COLUMNS: `${NAMESPACE_PREFIX}__toolbar__button-columns`,\n BUTTON_DENSITY: `${NAMESPACE_PREFIX}__toolbar__button-density`,\n BUTTON_DOWNLOAD: `${NAMESPACE_PREFIX}__toolbar__button-download`,\n BUTTON_UPLOAD: `${NAMESPACE_PREFIX}__toolbar__button-upload`,\n BUTTON_NEWLINE: `${NAMESPACE_PREFIX}__toolbar__button-newline`,\n BUTTON_EXTRA_ACTIONS: `${NAMESPACE_PREFIX}__toolbar__button-extra-actions`,\n },\n FILTER_BAR: `${NAMESPACE_PREFIX}__filter-bar`,\n TOTALIZER: `${NAMESPACE_PREFIX}__totalizer`,\n BULK_ACTIONS: `${NAMESPACE_PREFIX}__bulk-actions`,\n CHECKBOX: `${NAMESPACE_PREFIX}__checkbox`,\n PAGINATION: `${NAMESPACE_PREFIX}__pagination`,\n GENERIC_ACTION_BAR: `${NAMESPACE_PREFIX}__action-bar`,\n}\n\n```"
}
] |
code_store-on-localhost_748d8d8c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/context.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useContext, createContext } from 'react'\n\nimport { E2ETestable } from './types'\n\nconst TestingContext = createContext<E2ETestable>(null)\n\nexport const TableProvider: FC<E2ETestable> = ({ children, testId }) => {\n return (\n <TestingContext.Provider value={{ testId }}>\n {children}\n </TestingContext.Provider>\n )\n}\n\nexport function useTestingContext() {\n const context = useContext(TestingContext)\n if (!context) {\n throw new Error(\n 'Do not use E2ETestable components outside of the testing context'\n )\n }\n return context\n}\n\n```"
}
] |
code_store-on-localhost_fff1a60c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Checkbox.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport CheckboxBase from '../Checkbox/index.js'\n\nconst Checkbox: FC<CheckboxProps> = ({ id, onClick, ...props }) => (\n <div onClick={e => e.stopPropagation()}>\n <CheckboxBase\n id={id}\n name={`row_${id}`}\n onChange={() => onClick(id)}\n {...props}\n />\n </div>\n)\n\nexport type CheckboxProps = {\n id?: string\n onClick?: (id: string) => void\n checked?: boolean\n disabled?: boolean\n partial?: boolean\n}\n\nCheckbox.defaultProps = {\n id: '',\n onClick: () => {},\n checked: false,\n partial: false,\n disabled: false,\n}\n\nexport default Checkbox\n\n```"
}
] |
code_store-on-localhost_2d8bcdc5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/sampleData.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const products = [\n {\n id: 1,\n name: 'Macbook Pro 13 inch',\n categories: ['laptop'],\n manufacturer: 'apple',\n qty: 200,\n costPrice: 800,\n retailPrice: 1299,\n wholesalePrice: 1000,\n },\n {\n id: 2,\n name: 'Pixel 4',\n categories: ['smartphone'],\n manufacturer: 'google',\n qty: 100,\n costPrice: 600,\n retailPrice: 799,\n wholesalePrice: 700,\n },\n {\n id: 3,\n name: 'Macbook Pro 16 inch',\n categories: ['laptop'],\n manufacturer: 'apple',\n qty: 10,\n costPrice: 1800,\n retailPrice: 2399,\n wholesalePrice: 2000,\n },\n {\n id: 4,\n name: 'Ipad Pro 12.9 inch',\n categories: ['tablet'],\n manufacturer: 'apple',\n qty: 210,\n costPrice: 600,\n retailPrice: 999,\n wholesalePrice: 750,\n },\n {\n id: 5,\n name: 'XPS 15',\n categories: ['laptop'],\n manufacturer: 'dell',\n qty: 500,\n costPrice: 500,\n retailPrice: 1050,\n wholesalePrice: 950,\n },\n {\n id: 6,\n name: 'Disabled Item',\n categories: ['laptop'],\n manufacturer: 'example',\n qty: 0,\n costPrice: 500,\n retailPrice: 1050,\n wholesalePrice: 950,\n },\n {\n id: 7,\n name: 'IPhone 11 Pro',\n categories: ['smartphone'],\n manufacturer: 'apple',\n qty: 450,\n costPrice: 700,\n retailPrice: 1100,\n wholesalePrice: 950,\n },\n]\n\nexport const payments = [\n {\n id: 1,\n icon: 'FaCcPaypal',\n name: 'Paypal',\n status: 'ACTIVE',\n },\n {\n id: 2,\n icon: 'FaCcMastercard',\n name: 'Mastercard',\n status: 'ACTIVE',\n },\n {\n id: 3,\n icon: 'FaCcDinersClub',\n name: 'Dinners Club',\n status: 'ACTIVE',\n },\n {\n id: 4,\n icon: 'FaCcDiscover',\n name: 'Discover',\n status: 'INACTIVE',\n },\n {\n id: 5,\n icon: 'FaCcAmazonPay',\n name: 'Amazon Pay',\n status: 'INACTIVE',\n },\n {\n id: 6,\n icon: 'FaCcApplePay',\n name: 'Apple Pay',\n status: 'ACTIVE',\n },\n {\n id: 7,\n icon: 'FaCcVisa',\n name: 'Visa',\n status: 'ACTIVE',\n },\n {\n id: 8,\n icon: 'FaCcAmex',\n name: 'American Express',\n status: 'INACTIVE',\n },\n]\n\nexport const customers = [\n {\n id: 1,\n name: \"T'Chala\",\n email: 'black.panther@gmail.com',\n location: '🇰🇪Wakanda',\n },\n {\n id: 2,\n name: 'Peter Parker',\n email: 'spider.man@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 3,\n name: 'Shang-Chi',\n email: 'kung.fu@gmail.com',\n location: '🇨🇳China',\n },\n {\n id: 4,\n name: 'Natasha Romanoff',\n email: 'black.widown@gmail.com',\n location: '🇷🇺Russia',\n },\n {\n id: 5,\n name: 'Stephen Strange',\n email: 'dr.strange@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 6,\n name: 'Steve Rogers',\n email: 'cap.america@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 7,\n name: 'Abdul Alhazred',\n email: 'abdul@gmail.com',\n location: '🇸🇦Saudi Arabia',\n },\n {\n id: 8,\n name: 'Carol Danvers',\n email: 'cap.marvel@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 9,\n name: 'Scott Lang',\n email: 'ant.man@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 10,\n name: 'En Sabah Nuh',\n email: 'sabah@gmail.com',\n location: '🇨🇺Cuba',\n },\n {\n id: 11,\n name: 'Abdul Qamar',\n email: 'qamar@gmail.com',\n location: '🇸🇦Saudi Arabia',\n },\n {\n id: 12,\n name: 'Goose the Cat',\n email: 'meow@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 13,\n name: 'Brian Braddock',\n email: 'cap.britain@gmail.com',\n location: '🇬🇧Great Britain',\n },\n {\n id: 14,\n name: 'Marc Spector',\n email: 'moon.knight@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 15,\n name: 'John Walker',\n email: 'american.agent@gmail.com',\n location: '🇺🇸USA',\n },\n {\n id: 16,\n name: 'Dane Whitman',\n email: 'black.knight@gmail.com',\n location: '🇺🇸USA',\n },\n]\n\n```"
}
] |
code_store-on-localhost_e06c062d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/PageBlock/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component, Fragment } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\n\nimport Box from '../Box/index'\n\nclass PageBlock extends Component {\n render() {\n const {\n title,\n subtitle,\n variation,\n titleAside,\n testId,\n boxProps,\n } = this.props\n const isAnnotated = variation === 'annotated'\n\n const headerClasses = classNames({\n 'w-third': isAnnotated,\n 'flex flex-row justify-between': !isAnnotated && titleAside,\n 'flex flex-column': isAnnotated && titleAside,\n })\n\n let titleClasses = 'styleguide__pageBlock_title t-heading-3 mb3 ml5 ml3-ns '\n titleClasses += titleAside ? 'mt0' : 'mt4'\n\n return (\n <div\n className={`styleguide__pageBlock flex ${\n isAnnotated ? 'flex-row' : 'flex-column'\n }`}\n data-testid={testId}>\n {/* Title, subtitle & aside */}\n {(title || subtitle) && (\n <div className={headerClasses}>\n <div className=\"flex-grow-1\">\n {title && <h2 className={titleClasses}>{title}</h2>}\n {subtitle && (\n <div\n className={`t-body lh-copy c-muted-1 mb7 ml3 ${!isAnnotated &&\n 'w-two-thirds-ns w-100'}`}>\n {subtitle}\n </div>\n )}\n </div>\n {titleAside && !isAnnotated && (\n <div className=\"flex-grow-1\">{titleAside}</div>\n )}\n </div>\n )}\n\n {/* Boxes and the content itself */}\n <div\n className={`flex flex-column flex-row-ns ${isAnnotated &&\n 'w-two-thirds'}`}>\n {variation === 'half' ? (\n <Fragment>\n <div className=\"w-50-ns w-100 mr3-ns mb0-ns mb5\">\n <Box {...boxProps}>\n {this.props.children && this.props.children[0]}\n </Box>\n </div>\n <div className=\"w-50-ns w-100 ml3-ns mb5\">\n <Box {...boxProps}>\n {this.props.children && this.props.children[1]}\n </Box>\n </div>\n </Fragment>\n ) : variation === 'aside' ? (\n <Fragment>\n <div className=\"w-two-thirds-ns w-100 mr3-ns mb0-ns mb5\">\n <Box {...boxProps}>\n {this.props.children && this.props.children[0]}\n </Box>\n </div>\n <div className=\"w-third-ns w-100 ml3-ns mb5\">\n <Box {...boxProps}>\n {this.props.children && this.props.children[1]}\n </Box>\n </div>\n </Fragment>\n ) : (\n <div className=\"w-100 mb5\">\n <Box {...boxProps}>{this.props.children}</Box>\n </div>\n )}\n </div>\n </div>\n )\n }\n}\n\nPageBlock.defaultProps = {\n variation: 'full',\n}\n\nPageBlock.propTypes = {\n /** Type of layout grid for the content. */\n variation: PropTypes.oneOf(['full', 'half', 'annotated', 'aside']),\n /** Title for the block. */\n title: PropTypes.string,\n /** Data attribute */\n testId: PropTypes.string,\n /** Subtitle for the block. */\n subtitle: PropTypes.string,\n /** Content on the right side of the title. */\n titleAside: PropTypes.node,\n /** Contents of the boxes. Can be 1 or 2 nodes depending on the variation chosen. */\n children: function(props, propName, componentName) {\n PropTypes.checkPropTypes(\n {\n children: PropTypes.node.isRequired,\n },\n props,\n 'props',\n componentName\n )\n\n const isAsideOrHalf = ['half', 'aside'].indexOf(props.variation) !== -1\n const hasRequiredChildren = props[propName] && props[propName].length === 2\n\n if (isAsideOrHalf && !hasRequiredChildren) {\n return new Error(\n `Invalid prop \\`children\\` supplied to \\`${componentName}\\` with variation \"${\n props.variation\n }\", it must have 2 nodes as children. It was passed ${\n props.children\n ? props.children.length\n ? props.children.length\n : 'one'\n : 'nothing'\n }.`\n )\n }\n },\n boxProps: PropTypes.shape({\n noPadding: PropTypes.bool,\n title: PropTypes.string,\n }),\n}\n\nexport default PageBlock\n\n```"
}
] |
code_store-on-localhost_d86b4f49
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/PageBlock/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### Page blocks are the building blocks of a page. After choosing a layout you can use the Page Blocks to design the page as you will. There are four main kinds of Page blocks, full, Half, Aside and annotated. They are off to be used to fulfill design needs and to display the page content with the due visual hierarchy.\n\n### 👍 Dos\n\n- Use to build a page layout\n- Use to create information hierarchy\n\n### 👎 Don'ts\n\n- PageBlock title is not the box title, it’s the title of a whole section. Boxes titles should be inside them.\n- Over complicate the header aside. It should be very concise such as a button or a dropdown.\n\nFull\n\n```js\n<div className=\"bg-muted-5 pa8\">\n <PageBlock variation=\"full\">\n <div />\n </PageBlock>\n</div>\n```\n\nHalf\n\n```js\n<div className=\"bg-muted-5 pa8\">\n <PageBlock variation=\"half\">\n <div />\n <div />\n </PageBlock>\n</div>\n```\n\nAside\n\n```js\n<div className=\"bg-muted-5 pa8\">\n <PageBlock variation=\"aside\">\n <div />\n <div />\n </PageBlock>\n</div>\n```\n\nAnnotated\n\n```js\n<div className=\"bg-muted-5 pa8\">\n <PageBlock variation=\"annotated\" title=\"Section title\" subtitle=\"Subtitle\">\n <div />\n </PageBlock>\n</div>\n```\n\nWith Title and subtitle\n\n```js\n<div className=\"bg-muted-5 pa8\">\n <PageBlock\n title=\"Section\"\n subtitle=\"Some explanation for your section.\"\n variation=\"full\">\n <div />\n <div />\n </PageBlock>\n</div>\n```\n\nWith Title, subtitle and aside children\n\n```js\nconst Dropdown = require('../Dropdown').default\n\n;<div className=\"bg-muted-5 pa8\">\n <PageBlock\n title=\"Section\"\n subtitle=\"Some explanation for your section.\"\n variation=\"full\"\n titleAside={\n <div className=\"mt4 flex justify-end\">\n <div className=\"w-60\">\n <Dropdown\n options={[\n { value: 'chagall', label: 'Chagall' },\n { value: 'dali', label: 'Dali' },\n ]}\n value=\"dali\"\n onChange={() => {}}\n />\n </div>\n </div>\n }>\n <div />\n <div />\n </PageBlock>\n</div>\n```\n\nFull-blown example\n\n```js\nconst Tab = require('../Tabs/Tab').default\nconst Tabs = require('../Tabs').default\nconst Dropdown = require('../Dropdown').default\nconst Input = require('../Input').default\nconst Button = require('../Button').default\nconst Table = require('../Table').default\n\n;<div className=\"bg-muted-5 pa8\">\n <PageBlock variation=\"full\">\n <div>\n <h4 className=\"t-heading-4 mt0\"> Fill this form </h4>\n\n <div className=\"mb5\">\n <Input label=\"Lorem ipsum\" />\n </div>\n\n <div className=\"mb5\">\n <Input label=\"Lorem ipsum\" />\n </div>\n\n <div className=\"mb5\">\n <Input label=\"Lorem ipsum\" />\n </div>\n\n <Button variation=\"primary\">button</Button>\n </div>\n </PageBlock>\n <PageBlock variation=\"half\">\n <div>\n <p className=\"t-body lh-copy\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus et\n neque sit amet urna rhoncus ultrices. Praesent feugiat congue ligula, ut\n eleifend ligula laoreet vel.\n </p>\n\n <Button variation=\"tertiary\" collapseLeft>\n button\n </Button>\n <Button variation=\"tertiary\">button</Button>\n </div>\n <div>\n <p className=\"t-body lh-copy\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus et\n neque sit amet urna rhoncus ultrices. Praesent feugiat congue ligula, ut\n eleifend ligula laoreet vel.\n </p>\n\n <Button variation=\"tertiary\" collapseLeft>\n button\n </Button>\n <Button variation=\"tertiary\">button</Button>\n </div>\n </PageBlock>\n\n <PageBlock\n variation=\"full\"\n title=\"Section\"\n subtitle=\"Some explanation for your section. It can be used as a helper text to guide user troughout the interface. \">\n <div>\n <div>\n <div className=\"mb5\">\n <h4 className=\"t-heading-4 mt0\"> List of people </h4>\n\n <Table\n schema={{\n properties: {\n name: {\n type: 'string',\n title: 'Name',\n width: 200,\n },\n email: {\n type: 'string',\n title: 'Email',\n width: 350,\n },\n },\n }}\n toolbar={{\n inputSearch: {\n value: () => {},\n placeholder: 'Search stuff...',\n onChange: () => {},\n onClear: () => {},\n onSubmit: () => {},\n },\n newLine: {\n label: 'New',\n handleCallback: () => {},\n },\n }}\n pagination={{\n onNextClick: () => {},\n onPrevClick: () => {},\n currentItemFrom: 1,\n currentItemTo: 7,\n onRowsChange: () => {},\n textShowRows: 'Show rows',\n textOf: 'of',\n totalItems: 7,\n rowsOptions: [7],\n }}\n items={[\n {\n email: 'olen.stamm21@yahoo.com',\n name: 'Patrick Rothfuss',\n },\n {\n email: 'junius0@gmail.com',\n name: 'Hurricane Skywalker IV',\n },\n {\n email: 'judd_gulgowski22@yahoo.com',\n name: 'Tom Braddy',\n },\n {\n email: 'catharine.leuschke62@hotmail.com',\n name: 'Momochi Zabuza',\n },\n {\n email: 'candido_ryan@hotmail.com',\n name: 'Freddie Mercury',\n },\n {\n email: 'freda_ritchie26@yahoo.com',\n name: 'Dr. Lempi Mosciski',\n },\n {\n email: 'elissa28@gmail.com',\n name: 'Nikita Feeney',\n },\n ]}\n />\n </div>\n </div>\n </div>\n </PageBlock>\n <PageBlock variation=\"aside\">\n <div>\n <Tabs>\n <Tab label=\"A tab\" active onClick={() => {}} />\n <Tab label=\"Another tab\" onClick={() => {}} />\n </Tabs>\n <p className=\"t-body lh-copy\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce elementum\n tellus in mauris aliquet, at vestibulum elit scelerisque. Fusce dapibus\n consectetur scelerisque. Nam vitae orci id metus aliquam efficitur at\n non tortor. Etiam nec tincidunt mi, sit amet ultrices ipsum. Sed mattis\n eu dui at ultrices. Pellentesque sit amet neque in nibh malesuada\n elementum. Integer condimentum, enim non vehicula ultricies, dui eros\n lobortis nunc, id convallis orci est vel nunc. Aenean iaculis vehicula\n turpis sed consequat.\n </p>\n <p className=\"t-body lh-copy\">\n Praesent consequat ligula at auctor lobortis. Ut facilisis, odio ut\n consequat consectetur, enim nisi hendrerit lectus, nec consectetur magna\n ante id arcu. Proin id dolor id enim viverra ornare et ac mauris.\n Integer efficitur egestas magna vel iaculis. Sed faucibus congue nisi,\n cursus porta erat malesuada in. Vestibulum id sollicitudin libero.\n Vivamus eu aliquet ipsum. Proin in rutrum eros.\n </p>\n </div>\n <div>\n <h4 className=\"t-heading-5 mt0\"> Summary </h4>\n <ul className=\"t-body lh-copy\">\n <li> Lorem ipsum </li>\n <li> Lorem ipsum </li>\n <li> Lorem ipsum </li>\n <li> Lorem ipsum </li>\n <li> Lorem ipsum </li>\n </ul>\n </div>\n </PageBlock>\n</div>\n```\n\n```"
}
] |
code_store-on-localhost_444352ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Tag/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport config from 'vtex-tachyons/config.json'\n\nimport Close from '../icon/Close'\n\nclass Tag extends PureComponent {\n constructor() {\n super()\n\n this.state = {\n hover: false,\n }\n }\n\n handleMouseEnter = () => {\n this.setState({ hover: true })\n }\n\n handleMouseLeave = () => {\n this.setState({ hover: false })\n }\n\n render() {\n const {\n bgColor,\n children,\n color,\n disabled,\n onClick,\n size,\n type,\n variation,\n } = this.props\n\n let sizeClasses = ''\n switch (size) {\n case 'small':\n sizeClasses = 't-mini pv2 ph4'\n break\n case 'regular':\n sizeClasses = 't-small pv2 ph4'\n break\n case 'large':\n sizeClasses = 't-body pv3 ph5'\n break\n default:\n sizeClasses = 't-small pv2 ph4'\n break\n }\n\n const baseClasses = `br-pill dib fw5 ${sizeClasses}`\n\n let theme = ''\n const variationIsLow = variation === 'low'\n\n switch (type) {\n case 'success':\n theme = variationIsLow\n ? 'bg-transparent ba c-success '\n : 'bg-success c-on-success '\n break\n case 'error':\n theme = variationIsLow\n ? 'bg-transparent ba c-danger '\n : 'bg-danger c-on-danger '\n break\n case 'warning':\n theme = variationIsLow\n ? 'bg-transparent ba c-warning '\n : 'bg-warning c-on-warning '\n break\n default:\n theme = variationIsLow\n ? 'bg-transparent ba c-muted-2 '\n : 'bg-muted-2 c-on-muted-2 '\n break\n }\n\n const btnClasses = disabled ? 'bg-muted-4 c-muted-2 ' : 'pointer '\n\n let hoverClass = ''\n if (!disabled) {\n hoverClass = this.state.hover && 'o-80'\n }\n\n return onClick ? (\n <button\n className={`${baseClasses} bn ${btnClasses} ${theme} ${hoverClass}`}\n style={{\n backgroundColor: bgColor,\n color: disabled ? config.semanticColors.text.disabled : color,\n }}\n disabled={disabled}\n onClick={onClick}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}>\n <div className=\"flex items-stretch\">\n <span>{children}</span>\n <div className=\"ml2 flex items-center\">\n <Close color={color} size={12} />\n </div>\n </div>\n </button>\n ) : (\n <div\n className={`${baseClasses} ${theme}`}\n style={{\n backgroundColor: bgColor,\n color: color,\n }}>\n {children}\n </div>\n )\n }\n}\n\nTag.defaultProps = {\n disabled: false,\n size: 'regular',\n}\n\nTag.propTypes = {\n bgColor: PropTypes.string,\n children: PropTypes.node.isRequired,\n color: PropTypes.string,\n disabled: PropTypes.bool,\n onClick: PropTypes.func,\n /** Input size */\n size: PropTypes.oneOf(['small', 'regular', 'large']),\n type: PropTypes.oneOf(['success', 'error', 'warning']),\n variation: PropTypes.oneOf(['default', 'low']),\n}\n\nexport default Tag\n\n```"
}
] |
code_store-on-localhost_426411c4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Tag/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### A Tag represents a status or a tag.\n\n### 👍 Dos\n\n- Do use semantic colors that have a clear and contextualized meaning in your application, such as _green_ for success and _red_ for errors. However, if your application employs a richer palette with unambiguous usage of colors don't hesitate to use your Tags with them.\n- Do play with contrast to convey the visual prominence more suited to your application. Use high contrast for high prominence, and low contrast for low prominence.\n\n### 👎 Don'ts\n\n- Don't do make the Tag other than the optional close button, otherwise they should always be read-only.\n- Don't use color contrast combinations that don't pass Accessibility tests.\n\n** @todo: update examples to use VTEX Tachyons colors without hardcoding them **\n\nDefault\n\n```js\n<Tag>Neutral</Tag>\n```\n\nSizes\n\n```js\n<span className=\"mr4\">\n <Tag size=\"small\">\n Small\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag size=\"regular\">\n Regular\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag size=\"large\">\n Large\n </Tag>\n</span>\n```\n\nTypes\n\n```js\n<span className=\"mr4\">\n <Tag type=\"error\">\n Error\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag type=\"warning\">\n Warning\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag type=\"success\">\n Success\n </Tag>\n</span>\n```\n\nLow prominence\n\n```js\n<div>\n <span className=\"mr4\">\n <Tag type=\"error\" variation=\"low\">\n Error\n </Tag>\n </span>\n <span className=\"mr4\">\n <Tag type=\"warning\" variation=\"low\">\n Warning\n </Tag>\n </span>\n <span className=\"mr4\">\n <Tag type=\"success\" variation=\"low\">\n Success\n </Tag>\n </span>\n <span className=\"mr4\">\n <Tag variation=\"low\">Neutral</Tag>\n </span>\n</div>\n```\n\nCustom colors\n\n```js\n<span className=\"mr4\">\n <Tag bgColor=\"#F71963\">\n Label\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag bgColor=\"#134CD8\" color=\"#ffffff\">\n Label\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag bgColor=\"#FFF6E0\" color=\"#0C389F\">\n Label\n </Tag>\n</span>\n```\n\nWith remove\n\n```js\n<span className=\"mr4\">\n <Tag onClick={() => console.log('callback')}>Default</Tag>\n</span>\n<span className=\"mr4\">\n <Tag disabled onClick={() => console.log('callback')}>Disabled</Tag>\n</span>\n<span className=\"mr4\">\n <Tag onClick={() => console.log('callback')} bgColor=\"#134CD8\" color=\"#fff\">With color</Tag>\n</span>\n<span className=\"mr4\">\n <Tag onClick={() => console.log('callback')} type=\"error\">\n Error\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag onClick={() => console.log('callback')} type=\"warning\">\n Warning\n </Tag>\n</span>\n<span className=\"mr4\">\n <Tag onClick={() => console.log('callback')} type=\"success\">\n Success\n </Tag>\n</span>\n```\n\n```"
}
] |
code_store-on-localhost_d6e6bfbe
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/NumericStepper/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\n\nimport styles from '../Input/Input.css'\n\nconst normalizeMin = min => (min == null ? -Infinity : min)\nconst normalizeMax = max => (max == null ? Infinity : max)\n\nconst validateValue = (value, min, max, defaultValue) => {\n // This function always return a valid numeric value from the current input.\n // Compare with the function validateDisplayValue\n min = normalizeMin(min)\n max = normalizeMax(max)\n\n if (isNaN(value) || value == null) {\n if (defaultValue < min) return min\n if (defaultValue > max) return max\n return defaultValue\n } else if (value < min) {\n return min\n } else if (value > max) {\n return max\n }\n return parseInt(value, 10)\n}\n\nconst validateDisplayValue = (value, min, max) => {\n // This function validates the input as the user types\n // It allows for temporarily invalid values (namely, empty string and minus sign without a number following it)\n // However, it prevents values out of boundaries, and invalid characters, e.g. letters\n\n min = normalizeMin(min)\n max = normalizeMax(max)\n\n const parsedValue = parseInt(value, 10)\n\n if (value === '') {\n return value\n }\n // Only allows typing the negative sign if negative values are allowed\n if (value === '-' && min < 0) {\n return value\n }\n if (isNaN(parsedValue)) {\n return ''\n }\n // Only limit by lower bounds if the min value is 1\n // Otherwise, it could prevent typing, for example, 10 if the min value is 2\n if (parsedValue < min && min === 1) {\n return min\n }\n if (parsedValue > max) {\n return max\n }\n return parsedValue\n}\n\nclass NumericStepper extends Component {\n state = {\n inputFocused: false,\n // used for comparison whether to trigger onChange or not\n value: 0,\n // used for temporarily invalid values during typing--specifically, when it's empty\n displayValue: 0,\n }\n\n componentDidMount() {\n if (this.props.size === 'x-large') {\n console.warn(\n 'NumericStepper: The value \"x-large\" for the prop \"size\" is deprecated. In the next major version, it will be equivalent to \"large\", and removed altogether in future versions'\n )\n }\n }\n\n static getDerivedStateFromProps(props, state) {\n const { value, minValue, maxValue, defaultValue } = props\n\n const validatedValue = validateValue(\n value,\n minValue,\n maxValue,\n defaultValue\n )\n\n return {\n value: validatedValue,\n ...(!state.inputFocused && {\n displayValue: validateDisplayValue(value, minValue, maxValue),\n }),\n }\n }\n\n changeValue = (value, event) => {\n const parsedValue = parseInt(value, 10)\n\n const { minValue, maxValue, defaultValue, onChange } = this.props\n\n const validatedValue = validateValue(\n parsedValue,\n minValue,\n maxValue,\n defaultValue\n )\n\n const displayValue = validateDisplayValue(value, minValue, maxValue)\n\n this.setState({\n value: validatedValue,\n displayValue,\n })\n\n if (this.state.value !== validatedValue && onChange) {\n // React synthetic events are reused for performance reasons.\n // New properties added to it are never released.\n // Calling event.persist() releases the event from the pool\n // https://reactjs.org/docs/events.html#event-pooling\n event.persist()\n event.value = validatedValue\n onChange(event)\n }\n }\n\n handleTypeQuantity = event => {\n this.changeValue(event.target.value, event)\n }\n\n handleIncreaseValue = event => {\n this.changeValue(this.state.value + 1, event)\n }\n\n handleDecreaseValue = event => {\n this.changeValue(this.state.value - 1, event)\n }\n\n handleFocusInput = e => {\n e.target.select()\n this.setState({ inputFocused: true })\n }\n\n handleBlurInput = () => {\n this.setState({\n displayValue: this.state.value,\n inputFocused: false,\n })\n }\n\n render() {\n const { value, displayValue } = this.state\n const {\n maxValue,\n minValue,\n size,\n block,\n label,\n lean,\n readOnly,\n } = this.props\n\n const isMin = value <= normalizeMin(minValue)\n const isMax = value >= normalizeMax(maxValue)\n\n let labelClasses = ''\n let buttonClasses = ''\n let inputClasses = ''\n\n switch (size) {\n case 'small': {\n buttonClasses += `h-small ${lean ? 'f4' : 'f6'} `\n const inputWidth = lean ? 'w1' : 'w3'\n inputClasses += `h-small t-small ${block ? 'flex-grow-1' : inputWidth} `\n labelClasses += 't-small '\n break\n }\n case 'large': {\n buttonClasses += `h-large ${lean ? 'f3' : 'f5'} `\n const inputWidth = lean ? 'w2' : 'w3'\n inputClasses += `h-large t-body ${block ? 'flex-grow-1' : inputWidth} `\n labelClasses += 't-body '\n break\n }\n case 'x-large': {\n // DEPRECATED\n buttonClasses += `pv5 ${lean ? 'f2' : 'f4'} `\n const inputWidth = lean ? 'w3' : 'w4'\n inputClasses += `pv5 t-body ${block ? 'flex-grow-1' : inputWidth} `\n labelClasses += 't-body '\n break\n }\n default: {\n buttonClasses += `h-regular ${lean ? 'f4' : 'f6'} `\n const inputWidth = lean ? 'w2' : 'w3'\n inputClasses += `h-regular t-body ${\n block ? 'flex-grow-1' : inputWidth\n } `\n labelClasses += 't-small '\n break\n }\n }\n\n if (lean) inputClasses += 'br2 hover-b--muted-4 ba outline-transparent'\n\n const borderClasses = lean ? 'b--transparent ' : 'ba b--muted-4 bw1 '\n\n const buttonDisabledClasses = lean\n ? 'c-disabled bg-transparent '\n : 'bg-muted-5 c-disabled o-100 '\n\n const buttonEnabledClasses = `pointer bg-base c-action-primary ${\n lean ? 'outline-0' : ''\n } `\n\n const content = (\n <React.Fragment>\n {label && (\n <span\n className={`numeric-stepper__label db mb3 w-100 c-on-base ${labelClasses}`}>\n {label}\n </span>\n )}\n <div className=\"numeric-stepper-container flex self-start\">\n <input\n type=\"tel\"\n readOnly={readOnly}\n className={`numeric-stepper__input z-1 order-1 tc bw1 ${borderClasses} br0 ${inputClasses} ${styles.hideDecorators}`}\n style={{\n ...(block && {\n width: 0,\n }),\n WebkitAppearance: 'none',\n }}\n value={displayValue}\n onChange={this.handleTypeQuantity}\n onFocus={this.handleFocusInput}\n onBlur={this.handleBlurInput}\n />\n <div className=\"numeric-stepper__plus-button-container z-2 order-2 flex-none\">\n <button\n type=\"button\"\n className={`numeric-stepper__plus-button br2 pa0 bl-0 flex items-center justify-center ${borderClasses} ${buttonClasses} ${\n readOnly || isMax ? buttonDisabledClasses : buttonEnabledClasses\n }`}\n style={{\n borderTopLeftRadius: 0,\n borderBottomLeftRadius: 0,\n width: lean ? '2em' : '3em',\n transition: 'opacity 150ms',\n }}\n disabled={readOnly || isMax}\n aria-label=\"+\"\n tabIndex={0}\n onClick={this.handleIncreaseValue}>\n <div className=\"numeric-stepper__plus-button__text b\">\n {/* fullwidth plus sign (U+FF0B) http://graphemica.com/%EF%BC%8B */}\n +\n </div>\n </button>\n </div>\n <div className=\"numeric-stepper__minus-button-container z-2 order-0 flex-none\">\n <button\n type=\"button\"\n className={`numeric-stepper__minus-button br2 pa0 br-0 flex items-center justify-center ${borderClasses} ${buttonClasses} ${\n readOnly || isMin ? buttonDisabledClasses : buttonEnabledClasses\n }`}\n style={{\n borderTopRightRadius: 0,\n borderBottomRightRadius: 0,\n width: lean ? '2em' : '3em',\n transition: 'opacity 150ms',\n }}\n disabled={readOnly || isMin}\n aria-label=\"−\"\n // This is a minus sign (U+2212), not a regular hyphen (-, U+002D),\n // which is the default keyboard character.\n // Used for screen readers.\n tabIndex={0}\n onClick={this.handleDecreaseValue}>\n <span className=\"numeric-stepper__minus-button__text b\">\n {/* fullwidth hyphen-minus (U+FF0D) http://graphemica.com/%EF%BC%8D */}\n -\n </span>\n </button>\n </div>\n </div>\n </React.Fragment>\n )\n\n // Refrain from using label tag if not needed, to prevent\n // iOS from focusing on the text field and popping up the\n // keyboard when increment/decrement is pressed\n if (label && !lean) {\n return <label className=\"numeric-stepper-wrapper\">{content}</label>\n }\n return <div className=\"numeric-stepper-wrapper\">{content}</div>\n }\n}\n\nNumericStepper.propTypes = {\n /** Value of the input */\n value: PropTypes.number,\n /** onChange event handler */\n onChange: PropTypes.func.isRequired,\n /** Minimum value (will be the default value in case of invalid input, e.g. letters).\n Set to null or -Infinity in case there is no miminum. Default is 0.\n */\n minValue: PropTypes.number,\n /** Maximum value (null or Infinity in case there is no maximum. Default is Infinity) */\n maxValue: PropTypes.number,\n /** Default value in case of invalid input (e.g. letters) and there is no minimum value */\n defaultValue: PropTypes.number,\n /** Makes input readonly and disables buttons */\n readOnly: PropTypes.bool,\n /** Input size */\n size: PropTypes.oneOf(['small', 'regular', 'large']),\n /** Block or default size. */\n block: PropTypes.bool,\n /** Input label */\n label: PropTypes.string,\n /** Lean mode, with subtler styling */\n lean: PropTypes.bool,\n}\n\nNumericStepper.defaultProps = {\n minValue: 0,\n maxValue: Infinity,\n defaultValue: 0,\n readOnly: false,\n size: 'regular',\n block: false,\n}\n\nexport default NumericStepper\n\n```"
}
] |
code_store-on-localhost_433ea4a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/NumericStepper/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### This is a special case of a regular numerical input where you expect the user to modify it by a few incremental steps.\n\n### 👍 Dos\n\n- Do use a default value. If you don't know which do use, use 1. This way the user is not forced to type something and then click the buttons.\n- The lean mode is intended to be used on lists, that: have a high density of content, and where being able to type the number is not important. It is especially useful in mobile contexts or cramped containers.\n\n### 👎 Don'ts\n\n- Don't use for big numbers. Steppers make more sense for small numbers that might be adjusted with a few clicks.\n- Don't stretch it too much, the buttons in the extremes and the centered label will look really weird.\n\n### Related components\n\nIn doubt, use a regular <a href=\"#/Components/Forms/Input\">Input</a>.\n\nSizes\n\n```js\ninitialState = {\n value1: 0,\n value2: 0,\n value3: 0,\n}\n\n;<React.Fragment>\n <div className=\"mb5 flex\">\n <NumericStepper\n label=\"Small\"\n size=\"small\"\n value={state.value1}\n onChange={event => setState({ value1: event.value })}\n />\n </div>\n <div className=\"mb5 flex\">\n <NumericStepper\n label=\"Regular\"\n value={state.value2}\n onChange={event => setState({ value2: event.value })}\n />\n </div>\n <div className=\"mb5 flex\">\n <NumericStepper\n label=\"Large\"\n size=\"large\"\n value={state.value3}\n onChange={event => setState({ value3: event.value })}\n />\n </div>\n</React.Fragment>\n```\n\nMinimum and maximum values\n\n```js\ninitialState = {\n value1: 1,\n value2: 2,\n value3: 0,\n}\n\n;<React.Fragment>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Minimum value = 1\"\n minValue={1}\n value={state.value1}\n onChange={event => setState({ value1: event.value })}\n />\n </div>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Minimum 2, maximum 6\"\n minValue={2}\n maxValue={6}\n value={state.value2}\n onChange={event => setState({ value2: event.value })}\n />\n </div>\n</React.Fragment>\n```\n\nStyling\n\n```js\ninitialState = {\n value1: 1,\n value2: 1,\n value3: 1,\n value4: 1,\n}\n\n;<React.Fragment>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Default\"\n minValue={1}\n value={state.value1}\n onChange={event => setState({ value1: event.value })}\n />\n </div>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Lean mode\"\n minValue={1}\n lean\n value={state.value2}\n onChange={event => setState({ value2: event.value })}\n />\n </div>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Read Only\"\n minValue={1}\n readOnly\n value={state.value3}\n onChange={event => setState({ value3: event.value })}\n />\n </div>\n <div className=\"mb5\">\n <NumericStepper\n label=\"lean Read Only\"\n minValue={1}\n lean\n readOnly\n value={state.value4}\n onChange={event => setState({ value4: event.value })}\n />\n </div>\n</React.Fragment>\n```\n\nBox types\n\nUsed to make the component fit the parent container's width, either larger or smaller than the default size.\n\n```js\n<React.Fragment>\n <div className=\"mb5\">\n <NumericStepper\n label=\"Default\"\n size=\"small\"\n value={1}\n onChange={() => {}}\n />\n </div>\n <div className=\"mb5\">\n <NumericStepper size=\"large\" value={1} onChange={() => {}} />\n </div>\n <div className=\"mb5 w4 ba b--gray\" style={{ borderStyle: 'dotted' }}>\n <NumericStepper\n label=\"Block\"\n size=\"small\"\n value={1}\n block\n onChange={() => {}}\n />\n </div>\n <div className=\"mb5 ba b--gray\" style={{ borderStyle: 'dotted' }}>\n <NumericStepper size=\"large\" value={1} block onChange={() => {}} />\n </div>\n</React.Fragment>\n```\n\n```"
}
] |
code_store-on-localhost_2882f3bd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Totalizer/TotalizerIcon.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nconst CIRCLE_DIAMETER = '2.4rem'\n\nclass TotalizerIcon extends PureComponent {\n render() {\n const {\n item: { icon, iconBackgroundColor },\n } = this.props\n\n return (\n <div className=\"flex items-center mr3\">\n <div\n className=\"flex items-center justify-center br-100 pa3 bg-light-silver c-muted-1\"\n style={{\n height: CIRCLE_DIAMETER,\n width: CIRCLE_DIAMETER,\n backgroundColor: iconBackgroundColor,\n }}>\n {icon}\n </div>\n </div>\n )\n }\n}\n\nTotalizerIcon.propTypes = {\n item: PropTypes.shape({\n icon: PropTypes.node.isRequired,\n iconBackgroundColor: PropTypes.string,\n }).isRequired,\n}\n\nexport default TotalizerIcon\n\n```"
}
] |
code_store-on-localhost_fed13137
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Totalizer/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\nimport classNames from 'classnames'\n\nimport TotalizerLabel from './TotalizerLabel'\nimport TotalizerValue from './TotalizerValue'\nimport TotalizerIcon from './TotalizerIcon'\n\nconst BORDER_COLOR = 'b--muted-4'\n\nclass Totalizer extends PureComponent {\n render() {\n const { items, mobileScroll, horizontalLayout } = this.props\n\n const OUTER_CONTAINER_CLASSES = classNames({\n 'overflow-x-hidden': mobileScroll,\n })\n\n const INNER_CONTAINER_CLASSES = classNames(\n `w-100 flex flex-row-ns ba br3 ${BORDER_COLOR}`,\n {\n 'flex-row overflow-y-hidden overflow-x-scroll overflow-x-hidden-ns': mobileScroll,\n 'flex-column': !mobileScroll,\n }\n )\n\n const TOTALIZER_BASE_CLASSES = classNames(\n `flex flex-column pa4 ${BORDER_COLOR}`,\n {\n 'flex-auto-ns': mobileScroll,\n 'flex-auto': !mobileScroll,\n }\n )\n\n const invertedMargin = 2\n\n if (items.length === 0) {\n return null\n }\n\n return (\n <div className={OUTER_CONTAINER_CLASSES}>\n <div className={INNER_CONTAINER_CLASSES}>\n {items.map((item, i) => {\n const IS_NOT_LAST = items.length > 1 && i < items.length - 1\n\n const EXTRA_BORDER = classNames({\n 'bb bb-0-ns br-ns ': IS_NOT_LAST,\n 'bb-0 ': mobileScroll,\n br: mobileScroll && IS_NOT_LAST,\n })\n\n const ITEM_CLASSES = classNames(\n `${TOTALIZER_BASE_CLASSES} ${EXTRA_BORDER}`\n )\n\n const WITH_ICON_CONTAINER_CLASSES = classNames(\n 'item_container flex flex-row',\n {\n 'items-center': horizontalLayout,\n }\n )\n\n const WITH_ICON_ITEM_CONTAINER_CLASSES = classNames(\n 'item_container',\n {\n 'flex flex-row items-baseline': horizontalLayout,\n }\n )\n\n const WITHOUT_ICON_ITEM_CONTAINER_CLASSES = classNames(\n 'item_container',\n {\n 'flex flex-row items-baseline': horizontalLayout,\n }\n )\n\n return (\n <div className={ITEM_CLASSES} key={item.label}>\n {item.icon ? (\n <div className={WITH_ICON_CONTAINER_CLASSES}>\n <TotalizerIcon item={item} />\n\n <div className={WITH_ICON_ITEM_CONTAINER_CLASSES}>\n {item.inverted && (\n <div className={horizontalLayout ? 'mr3' : ''}>\n <TotalizerValue\n item={item}\n mobileScroll={mobileScroll}\n />\n </div>\n )}\n <TotalizerLabel\n label={item.label}\n mobileScroll={mobileScroll}\n />\n {!item.inverted && (\n <TotalizerValue\n item={item}\n mobileScroll={mobileScroll}\n />\n )}\n </div>\n </div>\n ) : (\n <div className={WITHOUT_ICON_ITEM_CONTAINER_CLASSES}>\n {item.inverted && (\n <div\n className={`m${\n horizontalLayout ? 'r' : 'b'\n }${invertedMargin}`}>\n <TotalizerValue\n item={item}\n mobileScroll={mobileScroll}\n />\n </div>\n )}\n <TotalizerLabel\n label={item.label}\n mobileScroll={mobileScroll}\n />\n {!item.inverted && (\n <div className={`mt${invertedMargin}`}>\n <TotalizerValue\n item={item}\n mobileScroll={mobileScroll}\n />\n </div>\n )}\n </div>\n )}\n </div>\n )\n })}\n </div>\n </div>\n )\n }\n}\n\nTotalizer.defaultProps = {\n value: null,\n iconBackgroundColor: '',\n icon: null,\n isLoading: false,\n mobileScroll: false,\n horizontalLayout: false,\n}\n\nexport const totalizerPropTypes = {\n /** Sets the items horizontally instead of vertically on mobile. */\n mobileScroll: PropTypes.bool,\n horizontalLayout: PropTypes.bool,\n items: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string.isRequired,\n value: PropTypes.node,\n iconBackgroundColor: PropTypes.string,\n icon: PropTypes.node,\n isLoading: PropTypes.bool,\n invertedWeight: PropTypes.bool,\n })\n ).isRequired,\n}\n\nTotalizer.propTypes = totalizerPropTypes\n\nexport default Totalizer\n\n```"
}
] |
code_store-on-localhost_a2a4146e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Totalizer/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### Totalizers are used to consolidate important numeric data. It usually displays numbers that the user what to access fastly.\n\n### 👍 Dos\n\n- Use icons to support the user scanning the information\n- Create clear clues with titles\n- Display the most important, and needed, numbers\n\n### 👎 Don'ts\n\n- Never replace the number with text\n- Avoid using seccondary information\n- Avoid using on the bottom of the page\n\n### Related components\n\n- Consider using a <a href=\"#/Components/Display/Table\">Table</a> if the information on totalizer is followed by a list of data.\n\n#### Default\n\n```js\n<Totalizer\n items={[\n {\n label: 'Saldo em conta',\n value: 23837,\n },\n {\n label: 'Entradas',\n value: 'R$ 36239,05',\n },\n\n {\n label: 'Saídas',\n value: '- R$ 13.485,26',\n },\n {\n label: 'Vendas',\n value: 23837,\n isLoading: true,\n },\n ]}\n/>\n```\n\n#### Horizontal layout\n\n```js\nconst ShoppingCart = require('../icon/ShoppingCart').default\n;<Totalizer\n horizontalLayout\n items={[\n {\n label: 'Orders',\n value: '566',\n inverted: true,\n },\n {\n label: 'Average Ticket',\n value: 'R$55.47',\n inverted: true,\n },\n {\n label: 'Gross',\n value: 'R$554.70',\n inverted: true,\n },\n ]}\n/>\n```\n\n#### Horizontal layout with icons\n\n```js\nconst ArrowDown = require('../icon/ArrowDown').default\nconst ArrowUp = require('../icon/ArrowUp').default\nconst ShoppingCart = require('../icon/ShoppingCart').default\n;<Totalizer\n horizontalLayout\n items={[\n {\n label: 'Orders',\n value: '566',\n inverted: true,\n iconBackgroundColor: '#eafce3',\n icon: <ArrowUp color=\"#79B03A\" size={14} />,\n },\n {\n label: 'Average Ticket',\n value: 'R$55.47',\n inverted: true,\n iconBackgroundColor: '#cce8ff',\n icon: <ShoppingCart color=\"#368df7\" size={14} />,\n },\n {\n label: 'Gross',\n value: 'R$554.70',\n inverted: true,\n iconBackgroundColor: '#fda4a4',\n icon: <ArrowDown color=\"#dd1616\" size={14} />,\n },\n ]}\n/>\n```\n\n#### With inverted first item\n\n```js\n<Totalizer\n items={[\n {\n inverted: true,\n value: 'Total Orders',\n label: 'Until 10h10',\n },\n {\n label: 'Today',\n value: 12364,\n },\n {\n label: 'Yesterday',\n value: 11980,\n },\n\n {\n label: 'Last Week',\n value: 10776,\n },\n {\n label: 'Last Year',\n value: 9802,\n },\n ]}\n/>\n```\n\n#### With Icons\n\n```js\nconst ArrowDown = require('../icon/ArrowDown').default\nconst ArrowUp = require('../icon/ArrowUp').default\nconst ShoppingCart = require('../icon/ShoppingCart').default\n;<Totalizer\n items={[\n {\n label: 'Pedidos',\n value: 23837,\n iconBackgroundColor: '#cce8ff',\n icon: <ShoppingCart color=\"#368df7\" size={14} />,\n },\n {\n label: 'Entradas',\n value: 'R$ 36239,05',\n iconBackgroundColor: '#eafce3',\n icon: <ArrowUp color=\"#79B03A\" size={14} />,\n },\n\n {\n label: 'Saídas',\n value: '- R$ 13.485,26',\n iconBackgroundColor: '#fda4a4',\n icon: <ArrowDown color=\"#dd1616\" size={14} />,\n },\n ]}\n/>\n```\n\n#### Mobile scroll\n\n```js\n<Totalizer\n mobileScroll\n items={[\n {\n label: 'Saldo em conta',\n value: 23837,\n },\n {\n label: 'Entradas',\n value: 'R$ 36239,05',\n },\n\n {\n label: 'Saídas',\n value: '- R$ 13.485,26',\n },\n {\n label: 'Vendas',\n value: 23837,\n isLoading: true,\n },\n ]}\n/>\n```\n\n#### Icons & mobile scroll\n\n```js\nconst ArrowDown = require('../icon/ArrowDown').default\nconst ArrowUp = require('../icon/ArrowUp').default\nconst ShoppingCart = require('../icon/ShoppingCart').default\n;<Totalizer\n mobileScroll\n items={[\n {\n label: 'Pedidos',\n value: 23837,\n iconBackgroundColor: '#cce8ff',\n icon: <ShoppingCart color=\"#368df7\" size={14} />,\n },\n {\n label: 'Entradas',\n value: 'R$ 36239,05',\n iconBackgroundColor: '#eafce3',\n icon: <ArrowUp color=\"#79B03A\" size={14} />,\n },\n\n {\n label: 'Saídas',\n value: '- R$ 13.485,26',\n iconBackgroundColor: '#fda4a4',\n icon: <ArrowDown color=\"#dd1616\" size={14} />,\n },\n ]}\n/>\n```\n\n```"
}
] |
code_store-on-localhost_1ac9e468
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Totalizer/TotalizerLabel.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nconst TotalizerLabel = ({ label, mobileScroll }) => (\n <div className={`c-muted-2 f6 ${mobileScroll ? 'nowrap' : ''}`}>{label}</div>\n)\n\nTotalizerLabel.propTypes = {\n label: PropTypes.string.isRequired,\n mobileScroll: PropTypes.bool,\n}\n\nexport default TotalizerLabel\n\n```"
}
] |
code_store-on-localhost_eaf4d070
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Totalizer/TotalizerValue.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Spinner from '../Spinner'\n\nclass TotalizerValue extends PureComponent {\n render() {\n const {\n item: { value, isLoading },\n mobileScroll,\n } = this.props\n\n if (isLoading) {\n return (\n <div className=\"c-muted-1\">\n <Spinner size={14} color=\"currentColor\" />\n </div>\n )\n }\n\n if (value == null) {\n return null\n }\n\n return (\n <div className={`f4 fw5 c-on-base ${mobileScroll ? 'nowrap' : ''}`}>\n {value}\n </div>\n )\n }\n}\n\nTotalizerValue.propTypes = {\n mobileScroll: PropTypes.bool,\n item: PropTypes.shape({\n label: PropTypes.string.isRequired,\n value: PropTypes.node,\n iconBackgroundColor: PropTypes.string,\n icon: PropTypes.node,\n isLoading: PropTypes.bool,\n }),\n}\n\nexport default TotalizerValue\n\n```"
}
] |
code_store-on-localhost_9e442e00
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/FloatingActionBar/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Button from '../Button/index.js'\n\nimport './action-bar.global.css'\n\nconst propTypes = {\n /** The Save button props (label + Styleguide Button props) */\n save: PropTypes.shape({\n /** Label to save button */\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n /** Styleguide Button props */\n ...Button.propTypes,\n }),\n /** The Cancel button props (label + Styleguide Button props) */\n cancel: PropTypes.shape({\n /** Label to save button */\n label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n /** Styleguide Button props */\n ...Button.propTypes,\n }),\n}\n\nconst defaultProps = {\n save: {},\n cancel: {},\n}\n\nconst FloatingActionBar: FC<PropTypes.InferProps<typeof propTypes>> = ({\n save: { label: saveLabel, ...saveProps },\n cancel: { label: cancelLabel, ...cancelProps },\n}) => (\n <div className=\"styleguide__floating-action-bar shadow-active w-100 bg-base tr pv5 pr7 absolute fixed bottom-0 left-0 z-999\">\n <span className=\"mr5\">\n <Button variation=\"tertiary\" {...cancelProps}>\n {cancelLabel}\n </Button>\n </span>\n <span>\n <Button variation=\"primary\" {...saveProps}>\n {saveLabel}\n </Button>\n </span>\n </div>\n)\n\nFloatingActionBar.propTypes = propTypes\nFloatingActionBar.defaultProps = defaultProps\n\nexport default FloatingActionBar\n\n```"
}
] |
code_store-on-localhost_9ccc36b3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/FloatingActionBar/action-bar.global.css from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n.shadow-active {\n box-shadow: 0px 1px 18px rgba(0, 0, 0, 0.14);\n}\n\n@media (min-width: 64rem) {\n .styleguide__layout .mw8 .styleguide__floating-action-bar {\n padding-right: calc((100% - 60.2rem) / 2);\n }\n}\n\n```"
}
] |
code_store-on-localhost_fd3d0316
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/FloatingActionBar/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### Floating Action Bar allow users to easily find the save button while editing an instance of an entity.\n\n### 👍 Dos\n\n- Only use when the action affects the whole page.\n- The actions on this component may be used to help user cancel or proceed a new change.\n- This component can be used anywhere but it will always show at the bottom of the page.\n\n### Usage\n\nSee the action bar at the bottom of this page.\n\n```js\nclass ActionBar extends React.Component {\n constructor(props) {\n super(props)\n this.state = { loading: false }\n }\n render() {\n return (\n <FloatingActionBar\n save={{\n label: 'save',\n isLoading: this.state.loading,\n onClick: () => {\n this.setState({ loading: true })\n setTimeout(() => {\n alert('This was invoked because save was pressed')\n this.setState({ loading: false })\n }, 2000)\n },\n }}\n cancel={{\n label: 'cancel',\n }}\n />\n )\n }\n}\n\n;<ActionBar />\n```\n\n```"
}
] |
code_store-on-localhost_645c7d57
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Tooltip/utils/dom.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n// From @reach-ui\nconst props = ['width', 'height', 'top', 'right', 'bottom', 'left']\n\nconst rectChanged = (a = {}, b = {}) => props.some(prop => a[prop] !== b[prop])\n\nconst observedNodes = new Map()\nlet rafId = null\n\nconst run = () => {\n observedNodes.forEach(state => {\n if (state.hasRectChanged) {\n state.callbacks.forEach(cb => cb(state.rect))\n state.hasRectChanged = false\n }\n })\n\n setTimeout(() => {\n observedNodes.forEach((state, node) => {\n if (node) {\n const newRect = node.getBoundingClientRect()\n if (rectChanged(newRect, state.rect)) {\n state.hasRectChanged = true\n state.rect = newRect\n }\n }\n })\n }, 0)\n\n rafId = requestAnimationFrame(run)\n}\n\nexport default (node, cb) => ({\n observe() {\n const wasEmpty = observedNodes.size === 0\n if (observedNodes.has(node)) {\n observedNodes.get(node).callbacks.push(cb)\n } else {\n observedNodes.set(node, {\n rect: undefined,\n hasRectChanged: true,\n callbacks: [cb],\n })\n }\n if (wasEmpty) run()\n },\n\n unobserve() {\n const state = observedNodes.get(node)\n if (state) {\n // Remove the callback\n const index = state.callbacks.indexOf(cb)\n if (index >= 0) state.callbacks.splice(index, 1)\n\n // Remove the node reference\n if (!state.callbacks.length) observedNodes.delete(node)\n\n // Stop the loop\n if (!observedNodes.size) cancelAnimationFrame(rafId)\n }\n },\n})\n\n```"
}
] |
code_store-on-localhost_98b5a770
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_useCheckboxTree/__tests__/util.test.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { getFlat, getToggledState } from '../util'\n\nconst props = ['children', 'related', 'friends']\nconst comparator = item => candidate => item.name === candidate.name\n\ndescribe('CheckboxTree util tests', () => {\n it('should flat the tree correctly', () => {\n props.forEach(prop => {\n expect(getFlat(treeForProp(prop), [], prop)).toEqual(\n flattenedTreeForProp(prop)\n )\n })\n })\n it('should toggle state correctly on a item without chidren', () => {\n props.forEach(prop => {\n expect(\n getToggledState([], { name: 'Alok' }, prop, comparator, () => false)\n ).toEqual([{ name: 'Alok' }])\n expect(\n getToggledState([], { name: 'KVSH' }, prop, comparator, () => false)\n ).toEqual([{ name: 'KVSH' }])\n })\n })\n it('should toggle state correctly on a item with chidren', () => {\n props.forEach(prop => {\n expect(\n getToggledState(\n [],\n {\n name: 'Vintage Culture',\n [prop]: [\n { name: 'Alok' },\n {\n name: 'Cat Dealers',\n [prop]: [{ name: 'KVSH' }],\n },\n ],\n },\n prop,\n comparator,\n () => false\n )\n ).toEqual([\n {\n name: 'Vintage Culture',\n [prop]: [\n { name: 'Alok' },\n {\n name: 'Cat Dealers',\n [prop]: [{ name: 'KVSH' }],\n },\n ],\n },\n { name: 'Alok' },\n {\n name: 'Cat Dealers',\n [prop]: [{ name: 'KVSH' }],\n },\n { name: 'KVSH' },\n ])\n })\n })\n})\n\nfunction treeForProp(prop: string) {\n return {\n vtexTableTreeRoot: 'root',\n [prop]: [\n {\n name: 'Vintage Culture',\n [prop]: [\n { name: 'Alok' },\n {\n name: 'Cat Dealers',\n [prop]: [{ name: 'KVSH' }],\n },\n ],\n },\n {\n name: 'Metallica',\n [prop]: [\n {\n name: 'Iron Maiden',\n [prop]: [\n {\n name: 'Pantera',\n [prop]: [{ name: 'Slayer' }],\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\nfunction flattenedTreeForProp(prop: string) {\n return [\n {\n [prop]: [\n {\n [prop]: [\n { name: 'Alok' },\n {\n [prop]: [{ name: 'KVSH' }],\n\n name: 'Cat Dealers',\n },\n ],\n\n name: 'Vintage Culture',\n },\n {\n [prop]: [\n {\n [prop]: [\n {\n [prop]: [{ name: 'Slayer' }],\n\n name: 'Pantera',\n },\n ],\n\n name: 'Iron Maiden',\n },\n ],\n name: 'Metallica',\n },\n ],\n vtexTableTreeRoot: 'root',\n },\n {\n [prop]: [\n { name: 'Alok' },\n {\n [prop]: [{ name: 'KVSH' }],\n\n name: 'Cat Dealers',\n },\n ],\n name: 'Vintage Culture',\n },\n { name: 'Alok' },\n {\n [prop]: [{ name: 'KVSH' }],\n name: 'Cat Dealers',\n },\n { name: 'KVSH' },\n {\n [prop]: [\n {\n [prop]: [\n {\n [prop]: [{ name: 'Slayer' }],\n name: 'Pantera',\n },\n ],\n name: 'Iron Maiden',\n },\n ],\n name: 'Metallica',\n },\n {\n [prop]: [\n {\n [prop]: [{ name: 'Slayer' }],\n\n name: 'Pantera',\n },\n ],\n name: 'Iron Maiden',\n },\n {\n [prop]: [{ name: 'Slayer' }],\n name: 'Pantera',\n },\n { name: 'Slayer' },\n ]\n}\n\n```"
}
] |
code_store-on-localhost_4edb1f78
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Conditions/Atoms/SubjectAtom.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport Select from '../../EXPERIMENTAL_Select'\nimport { withForwardedRef, refShape } from '../../../modules/withForwardedRef'\n\nclass SubjectAtom extends React.Component {\n handleChangeStatement = (newValue, structure) => {\n this.props.onChangeStatement(newValue, structure)\n }\n\n render() {\n const {\n forwardedRef,\n options,\n statements,\n isFullWidth,\n statementIndex,\n placeholder,\n } = this.props\n const condition = statements[statementIndex]\n\n const subjectOptions = Object.keys(options).map(choiceKey => {\n return {\n value: choiceKey,\n label: options[choiceKey].label,\n unique: options[choiceKey].unique || false,\n }\n })\n\n const subjectsInUse = statements\n .map(statement => {\n return statement.subject\n })\n .filter(subject => {\n return subject !== ''\n })\n\n const uniqueOptions = subjectOptions.filter(option => {\n if (!option.unique) {\n return true\n }\n\n const alreadyInUse = subjectsInUse.indexOf(option.value) > -1\n if (!alreadyInUse) {\n return true\n }\n\n if (subjectsInUse.indexOf(option.value) === statementIndex) {\n return true\n }\n\n return false\n })\n\n return (\n <div className={`mh3 ${isFullWidth ? 'pb3' : ''} w-30`}>\n <Select\n ref={forwardedRef}\n placeholder={placeholder}\n options={uniqueOptions}\n value={\n !condition.subject\n ? ''\n : uniqueOptions.find(\n option => option.value === condition.subject\n ) || ''\n }\n onChange={value => {\n const subject = value !== null ? value.value : null\n this.handleChangeStatement(subject, 'subject')\n }}\n multi={false}\n />\n </div>\n )\n }\n}\n\nSubjectAtom.defaultProps = {\n onChangeStatement: () => {},\n}\n\nSubjectAtom.propTypes = {\n /** @ignore Forwarded Ref */\n forwardedRef: refShape,\n /** Current selected options for this Statement */\n statements: PropTypes.arrayOf(\n PropTypes.shape({\n subject: PropTypes.string,\n verb: PropTypes.string,\n object: PropTypes.any,\n error: PropTypes.string,\n })\n ),\n /** Possible options and respective data types, verb options */\n options: PropTypes.object.isRequired,\n /** Placeholder for dropdown */\n placeholder: PropTypes.string.isRequired,\n /** Stretch component to 100% of the width */\n isFullWidth: PropTypes.bool,\n /** To which row does this Statement belong to? */\n statementIndex: PropTypes.number,\n /** Value changed callback */\n onChangeStatement: PropTypes.func,\n}\n\nexport default withForwardedRef(SubjectAtom)\n\n```"
}
] |
code_store-on-localhost_5b0d11cc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Conditions/Atoms/VerbAtom.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport Select from '../../EXPERIMENTAL_Select'\nimport { withForwardedRef, refShape } from '../../../modules/withForwardedRef'\n\nclass VerbAtom extends React.Component {\n handleChangeStatement = (newValue, structure) => {\n this.props.onChangeStatement(newValue, structure)\n }\n\n render() {\n const {\n forwardedRef,\n options,\n isFullWidth,\n statements,\n statementIndex,\n } = this.props\n const condition = statements[statementIndex]\n const myChoice = options[condition.subject]\n const verbs = (myChoice && myChoice.verbs) || [{ label: '', value: '' }]\n return (\n <div className={`mh3 ${isFullWidth ? 'pb3' : ''} flex-grow-1`}>\n <Select\n ref={forwardedRef}\n placeholder=\"\"\n options={verbs}\n value={\n !condition.subject\n ? ''\n : verbs.find(verb => verb.value === condition.verb) || ''\n }\n onChange={value => {\n const verb = value !== null ? value.value : null\n this.handleChangeStatement(verb, 'verb')\n }}\n multi={false}\n disabled={!condition.subject}\n />\n </div>\n )\n }\n}\n\nVerbAtom.defaultProps = {\n onChangeStatement: () => {},\n}\n\nVerbAtom.propTypes = {\n /** @ignore Forwarded Ref */\n forwardedRef: refShape,\n /** Current selected options for this Statement */\n statements: PropTypes.arrayOf(\n PropTypes.shape({\n subject: PropTypes.string,\n verb: PropTypes.string,\n object: PropTypes.any,\n error: PropTypes.string,\n })\n ),\n /** Possible options and respective data types, verb options */\n options: PropTypes.object.isRequired,\n /** Stretch component to 100% of the width */\n isFullWidth: PropTypes.bool,\n /** To which row does this Statement belong to? */\n statementIndex: PropTypes.number,\n /** Value changed callback */\n onChangeStatement: PropTypes.func,\n}\n\nexport default withForwardedRef(VerbAtom)\n\n```"
}
] |
code_store-on-localhost_17f79901
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Conditions/Atoms/ObjectAtom.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport Input from '../../Input'\n\nclass ObjectAtom extends React.Component {\n static EmptyObjectAtom = () => (\n <div className=\"flex-auto\">\n <div className=\"mh3 mb3\">\n <Input disabled />\n </div>\n </div>\n )\n\n render() {\n const {\n options,\n isFullWidth,\n statements,\n statementIndex,\n onChangeObjectCallback,\n } = this.props\n const condition = statements[statementIndex]\n const myChoice = options[condition.subject]\n\n if (!condition.verb) {\n return <ObjectAtom.EmptyObjectAtom />\n }\n\n if (!myChoice) {\n return <ObjectAtom.EmptyObjectAtom />\n }\n\n const currentVerb = myChoice.verbs.find(\n verb => verb.value === condition.verb\n )\n\n if (!currentVerb) {\n return <ObjectAtom.EmptyObjectAtom />\n }\n\n return (\n <div className=\"mh3 flex-auto\">\n {currentVerb.object.renderFn({\n statementIndex: statementIndex,\n statements: statements,\n isFullWidth: isFullWidth,\n values: condition.object,\n error: null,\n extraParams: currentVerb.object.extraParams,\n onChangeObjectCallback,\n })}\n </div>\n )\n }\n}\n\nObjectAtom.defaultProps = {\n onChangeStatement: () => {},\n onChangeObjectCallback: () => {},\n}\n\nObjectAtom.propTypes = {\n /** Current selected options for this Statement */\n statements: PropTypes.arrayOf(\n PropTypes.shape({\n subject: PropTypes.string,\n verb: PropTypes.string,\n object: PropTypes.any,\n error: PropTypes.string,\n })\n ),\n /** Possible options and respective data types, verb options */\n options: PropTypes.object.isRequired,\n /** Stretch component to 100% of the width */\n isFullWidth: PropTypes.bool,\n /** To which row does this Statement belong to? */\n statementIndex: PropTypes.number,\n /** Value changed callback */\n onChangeStatement: PropTypes.func,\n /** Object Value changed callback */\n onChangeObjectCallback: PropTypes.func,\n}\n\nexport default ObjectAtom\n\n```"
}
] |
code_store-on-localhost_4233f221
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Progress/Steps/styles.css from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```css\n@keyframes scroll{\n 0% {\n transform: translate3d(0,0,0);\n }\n 100% {\n transform: translate3d(26px,0,0);\n }\n}\n\n.scrollStep {\n animation: scroll 300ms infinite linear;\n}\n\n.roundedLeft {\n border-radius: 4px 0 0 4px\n}\n\n.roundedRight {\n border-radius: 0 4px 4px 0\n}\n\n```"
}
] |
code_store-on-localhost_0e3892e2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Progress/Steps/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport Step from './Step'\n\nexport const ProgressStepsTypes = {\n /** Array of steps, it should be composed of instances of the following strings:'completed', 'inProgress' and 'toDo' */\n steps: PropTypes.arrayOf(\n PropTypes.oneOf(['completed', 'inProgress', 'toDo'])\n ),\n /** Boolean representing a dangerous state of the progress (e.g. a late or critical progress), if true this changes the color of the steps */\n danger: PropTypes.bool,\n /** Boolean representing if the progress bar should be slim or not, if true this decreases the height of the bar */\n slim: PropTypes.bool,\n}\n\nexport class ProgressSteps extends PureComponent {\n isFirstElement(index) {\n return index === 0\n }\n\n isLastElement(index, array) {\n return index === array.length - 1\n }\n\n render() {\n const { steps, danger, slim } = this.props\n\n const stepsElements = steps.map((type, index) => {\n const isFirstElement = this.isFirstElement(index)\n const isLastElement = this.isLastElement(index, steps)\n\n const marginRightCSS = isLastElement ? '' : 'mr2'\n return (\n <div className={`w-100 ${marginRightCSS}`} key={index}>\n <Step\n type={type}\n roundLeft={isFirstElement}\n roundRight={isLastElement}\n danger={danger}\n slim={slim}\n />\n </div>\n )\n })\n return <div className=\"w-100 mb3 inline-flex flex-row\">{stepsElements}</div>\n }\n}\n\nProgressSteps.propTypes = ProgressStepsTypes\n\n```"
}
] |
code_store-on-localhost_7ad74092
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Progress/Steps/Step.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { scrollStep, roundedRight, roundedLeft } from './styles.css'\n\nconst COMPLETED = 'completed'\nconst IN_PROGRESS = 'inProgress'\nconst TO_DO = 'toDo'\n\nclass Step extends PureComponent {\n render() {\n const { type, roundLeft, roundRight, danger, slim } = this.props\n\n const halfOpacity = 'rgba(255, 255, 255, 0.5)'\n const fullOpacity = 'rgba(255, 255, 255, 0)'\n const gradientBackgroundStyle = {\n background: `repeating-linear-gradient(-45deg, ${fullOpacity}, ${fullOpacity} 10px, ${halfOpacity} 10px, ${halfOpacity} 20px)`,\n }\n\n const backgroundColorClass = danger ? 'bg-danger' : 'bg-action-primary'\n\n const roundLeftCSS = roundLeft ? roundedLeft : ''\n const roundRightCSS = roundRight ? roundedRight : ''\n const roundingStyle =\n roundLeft && roundRight ? 'br2' : roundRightCSS || roundLeftCSS\n\n const paddingClass = slim ? 'pa1' : 'pa2'\n\n switch (type) {\n case IN_PROGRESS:\n return (\n <div\n className={`relative ${paddingClass} ${backgroundColorClass} overflow-hidden ${roundingStyle}`}>\n <div\n style={gradientBackgroundStyle}\n className={`${scrollStep} absolute top-0 bottom-0 right-0 left--2 pr2`}\n />\n </div>\n )\n case COMPLETED:\n return (\n <div\n className={`${roundingStyle} ${paddingClass} ${backgroundColorClass} flex flex-row`}\n />\n )\n case TO_DO:\n default:\n return (\n <div\n className={`${roundingStyle} ${paddingClass} bg-muted-3 flex flex-row `}\n />\n )\n }\n }\n}\n\nStep.propTypes = {\n type: PropTypes.oneOf([COMPLETED, IN_PROGRESS, TO_DO]).isRequired,\n roundLeft: PropTypes.bool,\n roundRight: PropTypes.bool,\n danger: PropTypes.bool,\n slim: PropTypes.bool,\n}\n\nexport default Step\n\n```"
}
] |
code_store-on-localhost_70364bd5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Statement/Atoms/SubjectAtom.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Select from '../../EXPERIMENTAL_Select/index'\nimport { VerbOption } from './VerbAtom'\nimport { GroupedOptions, SelectOptionGroup, SelectedOption } from '../typings'\n\nconst ATOM_COMPONENT_MIN_WIDTH = '20%'\n\nexport type SubjectOptions = {\n [key: string]: {\n group?: string\n label: string\n unique?: boolean\n verbs: VerbOption[]\n }\n}\n\ntype Props = {\n subject?: string\n onChange: (string) => void\n options: SubjectOptions\n placeholder: string\n isFullWidth: boolean\n}\n\nconst groupOptions = options => {\n const groupedOptions = Object.keys(options).reduce<GroupedOptions>(\n (optionsGroup, subject) => {\n const option = options[subject]\n return {\n ...optionsGroup,\n [option.group]: [\n ...(optionsGroup[option.group] || []),\n {\n value: subject,\n label: option.label || subject,\n },\n ],\n }\n },\n {}\n )\n\n return Object.keys(groupedOptions).map<SelectOptionGroup>(group => {\n return {\n label: group,\n options: groupedOptions[group],\n }\n })\n}\n\nconst SubjectAtom: React.FC<Props> = ({\n isFullWidth,\n onChange,\n options,\n placeholder,\n subject,\n}) => {\n const optionsGroup = groupOptions(options)\n\n const subjectOptions =\n optionsGroup.length === 1 && optionsGroup[0].label === 'undefined'\n ? optionsGroup[0].options\n : optionsGroup\n\n const selected = optionsGroup.reduce<SelectedOption>((selected, group) => {\n if (selected) {\n return selected\n }\n\n const option = group.options.find(option => option.value === subject)\n if (option) {\n return {\n group: group.label !== 'undefined' ? group.label : undefined,\n option: option,\n }\n }\n }, undefined)\n\n return (\n <div\n className={`mh3 ${isFullWidth ? 'pb3' : ''}`}\n style={{ minWidth: ATOM_COMPONENT_MIN_WIDTH }}>\n <Select\n clearable={false}\n multi={false}\n onChange={option => onChange(option && option.value)}\n options={subjectOptions}\n placeholder={placeholder}\n value={selected && selected.option}\n />\n </div>\n )\n}\n\nexport default SubjectAtom\n\n```"
}
] |
code_store-on-localhost_551664fa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Statement/Atoms/VerbAtom.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Select from '../../EXPERIMENTAL_Select/index'\nimport { ObjectOption } from './ObjectAtom'\n\nexport type VerbOption = {\n label: string\n value: string\n object: ObjectOption\n}\n\ntype Props = {\n disabled?: boolean\n isFullWidth?: boolean\n verb?: string\n verbOptions: VerbOption[]\n onChange: (string) => void\n}\n\nconst VerbAtom: React.FC<Props> = ({\n disabled,\n isFullWidth,\n onChange,\n verb,\n verbOptions,\n}) => {\n const value = verbOptions.find(option => option.value === verb)\n\n return (\n <div\n className={`mh3 ${isFullWidth ? 'pb3' : ''} flex items-center`}\n style={verbOptions.length !== 1 ? { minWidth: '20%' } : {}}>\n {verbOptions.length !== 1 ? (\n <div className=\"flex-auto\">\n <Select\n clearable={false}\n disabled={disabled}\n multi={false}\n onChange={option => onChange(option && option.value)}\n options={verbOptions}\n placeholder=\"\"\n value={value}\n />\n </div>\n ) : (\n <span>{value.label}</span>\n )}\n </div>\n )\n}\n\nexport default VerbAtom\n\n```"
}
] |
code_store-on-localhost_ae8da5a8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/Statement/Atoms/ObjectAtom.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\n\nimport Input from '../../Input/index'\n\nexport type ObjectOption = (renderProps: RenderProps) => React.ReactElement\n\ntype RenderProps = {\n error: Props['error']\n onChange: Props['onChange']\n value: Props['object']\n}\n\ntype Props = {\n /** Disabled state */\n disabled?: boolean\n /** Statement error message */\n error?: string\n /** Current selected object for this Statement */\n object: unknown\n /** Object Value changed callback */\n onChange: (value: Props['object'], error?: Props['error']) => void\n /** Possible options and respective data types, verb options */\n renderObject: ObjectOption\n}\n\nconst EmptyObjectAtom = () => (\n <div className=\"flex-auto mh3\">\n <Input disabled />\n </div>\n)\n\nconst ObjectAtom: React.FC<Props> = ({\n disabled,\n error,\n object,\n onChange,\n renderObject,\n}) => {\n if (disabled) {\n return <EmptyObjectAtom />\n }\n\n return (\n <div className=\"mh3 flex-auto\">\n {renderObject({\n error,\n onChange,\n value: object,\n })}\n </div>\n )\n}\n\nexport default ObjectAtom\n\n```"
}
] |
code_store-on-localhost_c79d3c4f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/AutocompleteInput/SearchInput/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React, { useState } from 'react'\n\nimport IconSearch from '../../icon/Search'\nimport ClearInputIcon from '../../icon/Clear'\n\nconst propTypes = {\n /** Determine if the input's bottom corners should be rounded or not */\n roundedBottom: PropTypes.bool,\n\n /* Input props */\n /** Input value */\n value: PropTypes.string,\n /** Clear event handler */\n onClear: PropTypes.func,\n /** Change event handler */\n onChange: PropTypes.func,\n /** Search event handler. Called on enter or when clicking the search button */\n onSearch: PropTypes.func,\n /** Focus event handler */\n onFocus: PropTypes.func,\n /** Blur event handler */\n onBlur: PropTypes.func,\n /** Determine if the input and the button should be disabled */\n disabled: PropTypes.bool,\n}\n\nconst defaultProps = {\n roundedBottom: true,\n}\n\nconst SearchInput: React.FC<PropTypes.InferProps<typeof propTypes> &\n Omit<React.HTMLProps<HTMLInputElement>, 'onChange' | 'value'>> = props => {\n const {\n onClear,\n onSearch,\n roundedBottom,\n value,\n onChange,\n onFocus,\n onBlur,\n disabled,\n ...inputProps\n } = props\n\n const [focused, setFocused] = useState(false)\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange && onChange(e.target.value)\n }\n\n const handleClear = () => {\n onClear && onClear()\n }\n\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true)\n onFocus && onFocus(e)\n }\n\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n onBlur && onBlur(e)\n }\n\n const activeClass = classNames({\n 'b--muted-3': focused,\n 'b--muted-4': !focused,\n 'br--top': !roundedBottom,\n })\n\n const buttonClasses = classNames(\n activeClass,\n 'bg-base br2 br--right h-regular w3 bw1 ba pa0 bl-0',\n {\n 'c-link pointer': !disabled,\n 'c-disabled': disabled,\n }\n )\n\n return (\n <div className=\"flex flex-row\">\n <div className=\"relative w-100\">\n <input\n className={`${activeClass} w-100 ma0 border-box bw1 br2 ba outline-0 bg-base c-on-base t-body h-regular ph5 pr8 br--left`}\n value={value as any}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n disabled={disabled}\n {...inputProps}\n />\n {onClear && value && (\n <span\n className=\"absolute c-muted-3 fw5 flex items-center ph3 t-body top-0 right-0 h-100 pointer\"\n onClick={handleClear}>\n <ClearInputIcon />\n </span>\n )}\n </div>\n <button\n className={buttonClasses}\n disabled={disabled}\n onClick={() => onSearch(value)}>\n <IconSearch size={16} />\n </button>\n </div>\n )\n}\n\nSearchInput.propTypes = propTypes\nSearchInput.defaultProps = defaultProps\n\nexport default SearchInput\n\n```"
}
] |
code_store-on-localhost_18c69033
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/Tree/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useCallback } from 'react'\nimport uuid from 'uuid'\n\nimport {\n comparatorCurry,\n Checkboxes,\n Tree as TreeType,\n} from '../../EXPERIMENTAL_useCheckboxTree/types'\nimport { Column, Items } from '../../EXPERIMENTAL_Table/types'\nimport { Density } from '../../EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport Node from './Node'\n\nconst Tree: FC<TreeProps> = ({\n checkboxes,\n items,\n comparator,\n ...nodeProps\n}) => {\n const [collapsedItems, setCollapsedItems] = React.useState<Array<unknown>>([])\n\n const listToRender = checkboxes ? items[nodeProps.nodesKey] : items\n\n const isCollapsed = useCallback(\n (item: unknown) => collapsedItems.some(comparator(item)),\n [collapsedItems, comparator]\n )\n\n const toggleCollapsed = React.useCallback(\n (item: unknown) => {\n isCollapsed(item)\n ? setCollapsedItems(\n collapsedItems.filter(\n collapsedItem => !comparator(collapsedItem)(item)\n )\n )\n : setCollapsedItems([...collapsedItems, item])\n },\n [collapsedItems, comparator, isCollapsed]\n )\n\n return (\n <>\n {listToRender.map(data => (\n <Node\n isCollapsed={isCollapsed}\n toggleCollapsed={toggleCollapsed}\n checkboxes={checkboxes}\n {...nodeProps}\n key={`row-${uuid()}`}\n data={data}\n />\n ))}\n </>\n )\n}\n\ntype TreeProps = {\n items: Items\n currentDensity: Density\n nodesKey: string\n columns: Array<Column>\n comparator: comparatorCurry<TreeType<unknown>>\n rowHeight: number\n checkboxes?: Checkboxes<unknown>\n onRowClick?: ({ rowData: unknown }) => void\n}\n\nexport default React.memo(Tree)\n\n```"
}
] |
code_store-on-localhost_06d3c2c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/Tree/CollapseToggle.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport CaretUp from '../../icon/CaretUp/index.js'\nimport CaretDown from '../../icon/CaretDown/index.js'\nimport ButtonWithIcon from '../../ButtonWithIcon/index.js'\n\nconst ICON_SIZE = 14\n\nconst CollapseToggle: FC<CollapseToggleProps> = ({ collapsed, onClick }) => {\n const icon = collapsed ? (\n <CaretUp size={ICON_SIZE} />\n ) : (\n <CaretDown size={ICON_SIZE} />\n )\n return (\n <ButtonWithIcon\n size=\"small\"\n onClick={onClick}\n icon={icon}\n variation=\"tertiary\"\n />\n )\n}\n\nexport type CollapseToggleProps = {\n collapsed: boolean\n onClick: Function\n}\n\nexport default CollapseToggle\n\n```"
}
] |
code_store-on-localhost_baf41d65
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_TableTree/Tree/Node.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useCallback } from 'react'\nimport uuid from 'uuid'\nimport isEmpty from 'lodash/isEmpty'\nimport pick from 'lodash/pick'\n\nimport Row, { ROW_TRANSITIONS } from '../../EXPERIMENTAL_Table/DataTable/Row'\nimport CollapseToggle from './CollapseToggle'\nimport { Checkboxes } from '../../EXPERIMENTAL_useCheckboxTree/types'\nimport { Column } from '../../EXPERIMENTAL_Table/types'\nimport { Density } from '../../EXPERIMENTAL_Table/hooks/useTableMeasures'\nimport useTableMotion from '../../EXPERIMENTAL_Table/hooks/useTableMotion'\n\nconst Node: FC<NodeProps> = ({\n columns,\n rowHeight,\n nodesKey,\n checkboxes,\n toggleCollapsed,\n isCollapsed,\n data,\n depth,\n currentDensity,\n onRowClick,\n}) => {\n const motion = useTableMotion(ROW_TRANSITIONS)\n const toggleChildren = useCallback(() => toggleCollapsed(data), [\n data,\n toggleCollapsed,\n ])\n const toggleChecked = useCallback(() => checkboxes.toggle(data), [\n checkboxes,\n data,\n ])\n\n const isRowChecked = checkboxes && checkboxes.isChecked(data)\n const isRowPartiallyChecked =\n checkboxes && checkboxes.isPartiallyChecked(data)\n const isRowSelected = isRowChecked || isRowPartiallyChecked\n const hasChildren = data[nodesKey] && !isEmpty(data[nodesKey])\n\n const clickableRow = onRowClick\n ? { onClick: () => onRowClick({ rowData: data }) }\n : undefined\n\n const clickableCell = hasChildren\n ? clickableRow\n ? undefined\n : { onClick: toggleChildren }\n : undefined\n\n const renderCells = (hasChild?: boolean) => {\n return (\n <Row\n {...clickableRow}\n motion={motion}\n height={rowHeight}\n active={isRowSelected}>\n {columns.map((column: Column, cellIndex: number) => {\n const { cellRenderer, width } = column\n const cellData = column.condensed\n ? pick(data, column.condensed)\n : column.extended\n ? data\n : data[column.id]\n const content = cellRenderer\n ? cellRenderer({\n data: cellData,\n rowHeight,\n currentDensity,\n motion,\n })\n : cellData\n return cellIndex === 0 ? (\n <Row.Cell {...clickableCell} key={`cel-${uuid()}`} width={width}>\n <Row.Cell.Prefix depth={depth}>\n {hasChild && (\n <CollapseToggle\n collapsed={isCollapsed(data)}\n onClick={toggleChildren}\n />\n )}\n {checkboxes && (\n <span className=\"ph3\">\n <Row.Cell.Prefix.Checkbox\n checked={isRowChecked}\n partial={isRowPartiallyChecked}\n onClick={toggleChecked}\n />\n </span>\n )}\n </Row.Cell.Prefix>\n {content}\n </Row.Cell>\n ) : (\n <Row.Cell key={`cel-${uuid()}`} width={width}>\n {content}\n </Row.Cell>\n )\n })}\n </Row>\n )\n }\n\n return hasChildren ? (\n <>\n {renderCells(true)}\n {isCollapsed(data) &&\n (data[nodesKey] as Array<unknown>).map(data => (\n <Node\n onRowClick={onRowClick}\n currentDensity={currentDensity}\n isCollapsed={isCollapsed}\n toggleCollapsed={toggleCollapsed}\n checkboxes={checkboxes}\n nodesKey={nodesKey}\n rowHeight={rowHeight}\n columns={columns}\n key={`row-child-${uuid()}`}\n depth={depth + 1}\n data={data}\n />\n ))}\n </>\n ) : (\n renderCells()\n )\n}\n\ntype NodeProps = {\n toggleCollapsed: (uniqueKey: unknown) => void\n isCollapsed: (uniqueKey: unknown) => boolean\n columns: Array<Column>\n currentDensity: Density\n rowHeight: number\n nodesKey: string\n checkboxes?: Checkboxes<unknown>\n data: unknown\n depth?: number\n onRowClick?: ({ rowData: unknown }) => void\n}\n\nNode.defaultProps = {\n depth: 0,\n}\n\nexport default Node\n\n```"
}
] |
code_store-on-localhost_5920ec6f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/CaretDown/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 10,\n}\n\nclass CaretDown extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"caret-down\" size={newSize} block={block} viewBox=\"0 0 14 10\">\n <path\n d=\"M7.72356 8.48154C7.32958 8.89452 6.67042 8.89452 6.27644 8.48154L0 1.90235L1.81481 0L7 5.43529L12.1852 0L14 1.90235L7.72356 8.48154Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCaretDown.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCaretDown.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default CaretDown\n\n```"
}
] |
code_store-on-localhost_35c1511a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/PlusLines/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass PlusLines extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"PlusLines\" size={newSize} block={block}>\n <path\n d=\"M14 7C14 7.55228 13.5523 8 13 8H8V13C8 13.5523 7.55228 14 7 14C6.44772 14 6 13.5523 6 13V8H1C0.447715 8 0 7.55228 0 7C0 6.44772 0.447715 6 1 6H6V1C6 0.447715 6.44772 0 7 0C7.55228 0 8 0.447715 8 1V6H13C13.5523 6 14 6.44772 14 7Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nPlusLines.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nPlusLines.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default PlusLines\n\n```"
}
] |
code_store-on-localhost_d44f6d26
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/InlineGrid/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass InlineGrid extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"inline-grid\" size={newSize} block={block}>\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M1 0C0.447715 0 0 0.447715 0 1V6C0 6.55228 0.447715 7 1 7H15C15.5523 7 16 6.55228 16 6V1C16 0.447715 15.5523 0 15 0H1ZM1 9C0.447715 9 0 9.44771 0 10V15C0 15.5523 0.447715 16 1 16H15C15.5523 16 16 15.5523 16 15V10C16 9.44772 15.5523 9 15 9H1Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nInlineGrid.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nInlineGrid.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default InlineGrid\n\n```"
}
] |
code_store-on-localhost_49f35adc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/CaretUp/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 10,\n}\n\nclass CaretUp extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"caret-up\" size={newSize} block={block} viewBox=\"0 0 14 10\">\n <path\n d=\"M7.72356 8.48154C7.32958 8.89452 6.67042 8.89452 6.27644 8.48154L0 1.90235L1.81481 0L7 5.43529L12.1852 0L14 1.90235L7.72356 8.48154Z\"\n transform=\"translate(14 10) rotate(-180)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCaretUp.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCaretUp.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default CaretUp\n\n```"
}
] |
code_store-on-localhost_1b7c2c8a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ArrowBack/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 11,\n}\n\nclass ArrowBack extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"arrow-back\" size={newSize} block={block} viewBox=\"0 0 16 11\">\n <path\n d=\"M5.5 15.5002C5.75781 15.5002 5.92969 15.4169 6.10156 15.2502L11 10.5002L9.79687 9.33356L6.35938 12.6669L6.35938 0H4.64063L4.64062 12.6669L1.20312 9.33356L0 10.5002L4.89844 15.2502C5.07031 15.4169 5.24219 15.5002 5.5 15.5002Z\"\n transform=\"translate(16.0002) rotate(90)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nArrowBack.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nArrowBack.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ArrowBack\n\n```"
}
] |
code_store-on-localhost_8345a466
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/CheckPartial/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 12,\n height: 12,\n}\n\nclass CheckPartial extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"check\" size={newSize} block={block} viewBox=\"0 0 12 12\">\n <path d=\"M2 5V7H10V5H2Z\" fill={color} />\n </Svg>\n )\n }\n}\n\nCheckPartial.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCheckPartial.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default CheckPartial\n\n```"
}
] |
code_store-on-localhost_05b03ba4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/OptionsDots/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass OptionsDots extends PureComponent {\n render() {\n const { color, size, block, radius } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"options-dots\" size={newSize} block={block} viewBox=\"0 0 32 32\">\n <g className=\"nc-icon-wrapper\" fill={color}>\n <g\n className=\"nc-interact_dots-close-o-32\"\n transform=\"rotate(90 16 16)\">\n {' '}\n <g className=\"nc-dot_left\" transform=\"translate(0)\">\n {' '}\n <circle\n cx=\"6\"\n cy=\"16\"\n r={radius}\n fill={color}\n data-cap=\"butt\"\n data-stroke=\"none\"\n strokeLinecap=\"butt\"\n strokeLinejoin=\"miter\"\n />{' '}\n <circle\n cx=\"6\"\n cy=\"16\"\n r={radius}\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"square\"\n strokeLinejoin=\"miter\"\n strokeWidth=\"2\"\n />{' '}\n </g>{' '}\n <g className=\"nc-dot_right\" transform=\"translate(-0)\">\n {' '}\n <circle\n cx=\"26\"\n cy=\"16\"\n r={radius}\n fill={color}\n data-cap=\"butt\"\n data-stroke=\"none\"\n strokeLinecap=\"butt\"\n strokeLinejoin=\"miter\"\n />{' '}\n <circle\n cx=\"26\"\n cy=\"16\"\n r={radius}\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"square\"\n strokeLinejoin=\"miter\"\n strokeWidth=\"2\"\n />{' '}\n </g>{' '}\n <g className=\"nc-dot_center\">\n {' '}\n <circle\n cx=\"16\"\n cy=\"16\"\n r={radius}\n fill={color}\n data-cap=\"butt\"\n data-stroke=\"none\"\n strokeLinecap=\"butt\"\n strokeLinejoin=\"miter\"\n />{' '}\n <circle\n cx=\"16\"\n cy=\"16\"\n r={radius}\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"square\"\n strokeLinejoin=\"miter\"\n strokeWidth=\"2\"\n />{' '}\n </g>{' '}\n <path\n className=\"nc-line_top-right\"\n data-cap=\"none\"\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M16 16L27 5\"\n strokeDasharray=\"15.56 15.56\"\n strokeDashoffset=\"15.56\"\n opacity=\"0\"\n />{' '}\n <path\n className=\"nc-line_bottom-left\"\n data-cap=\"none\"\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M5 27l11-11\"\n strokeDasharray=\"15.56 15.56\"\n strokeDashoffset=\"-15.56\"\n opacity=\"0\"\n />{' '}\n <path\n className=\"nc-line_bottom-right\"\n data-cap=\"none\"\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M16 16l11 11\"\n strokeDasharray=\"15.56 15.56\"\n strokeDashoffset=\"15.56\"\n opacity=\"0\"\n />{' '}\n <path\n className=\"nc-line_top-left\"\n data-cap=\"none\"\n fill=\"none\"\n stroke={color}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M5 5l11 11\"\n strokeDasharray=\"15.56 15.56\"\n strokeDashoffset=\"-15.56\"\n opacity=\"0\"\n />{' '}\n </g>\n </g>\n </Svg>\n )\n }\n}\n\nOptionsDots.defaultProps = {\n color: '#444444',\n size: 16,\n radius: 2,\n block: false,\n}\n\nOptionsDots.propTypes = {\n color: PropTypes.string,\n radius: PropTypes.number,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default OptionsDots\n\n```"
}
] |
code_store-on-localhost_0053b57d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Calendar/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Calendar extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"calendar\" size={newSize} block={block}>\n <path\n d=\"M4.66667 7.2H3.11111V8.8H4.66667V7.2ZM7.77778 7.2H6.22222V8.8H7.77778V7.2ZM10.8889 7.2H9.33333V8.8H10.8889V7.2ZM12.4444 1.6H11.6667V0H10.1111V1.6H3.88889V0H2.33333V1.6H1.55556C0.692222 1.6 0.00777777 2.32 0.00777777 3.2L0 14.4C0 15.28 0.692222 16 1.55556 16H12.4444C13.3 16 14 15.28 14 14.4V3.2C14 2.32 13.3 1.6 12.4444 1.6ZM12.4444 14.4H1.55556V5.6H12.4444V14.4Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCalendar.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCalendar.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Calendar\n\n```"
}
] |
code_store-on-localhost_a8bd01e7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/VisibilityOff/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass VisibilityOff extends PureComponent {\n render() {\n const { color, size, solid } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"visibility-off\"\n variation={solid ? 'solid' : null}\n size={newSize}>\n {solid ? (\n <>\n <path\n d=\"M14.6 5.59961L6.39999 13.7996C6.89999 13.8996 7.49999 13.9996 7.99999 13.9996C11.6 13.9996 14.4 10.8996 15.6 9.09961C16.1 8.39961 16.1 7.49961 15.6 6.79961C15.4 6.49961 15 6.09961 14.6 5.59961Z\"\n fill={color}\n />\n <path\n d=\"M14.3 0.3L11.6 3C10.5 2.4 9.3 2 8 2C4.4 2 1.6 5.1 0.4 6.9C-0.1 7.6 -0.1 8.5 0.4 9.1C0.9 9.9 1.8 10.9 2.8 11.8L0.3 14.3C-0.1 14.7 -0.1 15.3 0.3 15.7C0.5 15.9 0.7 16 1 16C1.3 16 1.5 15.9 1.7 15.7L15.7 1.7C16.1 1.3 16.1 0.7 15.7 0.3C15.3 -0.1 14.7 -0.1 14.3 0.3ZM5.3 9.3C5.1 8.9 5 8.5 5 8C5 6.3 6.3 5 8 5C8.5 5 8.9 5.1 9.3 5.3L5.3 9.3Z\"\n fill={color}\n />\n </>\n ) : (\n <>\n <path\n d=\"M14.5744 5.66895L13.1504 7.09295C13.4284 7.43995 13.6564 7.75695 13.8194 7.99995C13.0594 9.12995 10.9694 11.8199 8.25838 11.9849L6.44337 13.7999C6.93937 13.9239 7.45737 13.9999 8.00037 13.9999C12.7074 13.9999 15.7444 8.71594 15.8714 8.49194C16.0424 8.18794 16.0434 7.81595 15.8724 7.51195C15.8254 7.42695 15.3724 6.63095 14.5744 5.66895Z\"\n fill={color}\n />\n <path\n d=\"M0.293375 15.7072C0.488375 15.9022 0.744375 16.0002 1.00038 16.0002C1.25638 16.0002 1.51238 15.9022 1.70738 15.7072L15.7074 1.70725C16.0984 1.31625 16.0984 0.68425 15.7074 0.29325C15.3164 -0.09775 14.6844 -0.09775 14.2934 0.29325L11.5484 3.03825C10.5154 2.43125 9.33137 2.00025 8.00037 2.00025C3.24537 2.00025 0.251375 7.28925 0.126375 7.51425C-0.0426249 7.81725 -0.0416249 8.18625 0.128375 8.48925C0.198375 8.61425 1.17238 10.2913 2.82138 11.7653L0.292375 14.2942C-0.0976249 14.6842 -0.0976249 15.3162 0.293375 15.7072ZM2.18138 7.99925C2.95838 6.83525 5.14637 4.00025 8.00037 4.00025C8.74237 4.00025 9.43737 4.20125 10.0784 4.50825L8.51237 6.07425C8.34837 6.02925 8.17837 6.00025 8.00037 6.00025C6.89537 6.00025 6.00038 6.89525 6.00038 8.00025C6.00038 8.17825 6.02938 8.34825 6.07438 8.51225L4.24038 10.3462C3.28538 9.51025 2.55938 8.56225 2.18138 7.99925Z\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nVisibilityOff.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n}\n\nVisibilityOff.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n}\n\nexport default VisibilityOff\n\n```"
}
] |
code_store-on-localhost_ee9fdd62
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Close/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 18,\n}\n\nclass Close extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"close\" size={newSize} block={block} viewBox=\"0 0 18 18\">\n <g fill={color}>\n <path d=\"M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z\" />\n </g>\n </Svg>\n )\n }\n}\n\nClose.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nClose.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Close\n\n```"
}
] |
code_store-on-localhost_97e78439
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Success/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Success extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"success\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM7 11.4L3.6 8L5 6.6L7 8.6L11 4.6L12.4 6L7 11.4Z\"\n fill={color}\n />\n ) : (\n <>\n <path\n d=\"M8 0C3.589 0 0 3.589 0 8C0 12.411 3.589 16 8 16C12.411 16 16 12.411 16 8C16 3.589 12.411 0 8 0ZM8 14C4.691 14 2 11.309 2 8C2 4.691 4.691 2 8 2C11.309 2 14 4.691 14 8C14 11.309 11.309 14 8 14Z\"\n fill={color}\n />\n <path\n d=\"M3.414 6.828L-3.43323e-08 3.414L1.414 2L3.414 4L7.414 -3.43323e-08L8.828 1.414L3.414 6.828Z\"\n transform=\"translate(3.58606 4.586)\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nSuccess.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nSuccess.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Success\n\n```"
}
] |
code_store-on-localhost_79646843
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Underline/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Underline extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"underline\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <path\n d=\"M55,4H37V8h4a2,2,0,0,1,2,2V34.51c0,5.742-4.187,10.879-9.9,11.436A11.012,11.012,0,0,1,21,35V10a2,2,0,0,1,2-2h4V4H9V8h4a2,2,0,0,1,2,2V34.4c0,9.046,6.811,16.957,15.836,17.561A17.018,17.018,0,0,0,49,35V10a2,2,0,0,1,2-2h4Z\"\n fill={color}\n />\n <path fill={color} d=\"M62,60H2a1,1,0,0,1,0-2H62a1,1,0,0,1,0,2Z\" />\n </Svg>\n )\n }\n}\n\nUnderline.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nUnderline.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Underline\n\n```"
}
] |
code_store-on-localhost_c69f2e39
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Minus/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 14,\n}\n\nclass Minus extends PureComponent {\n render() {\n const { color, size, block, solid } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"minus\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <path\n xmlns=\"http://www.w3.org/2000/svg\"\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M8 16C12.418 16 16 12.4185 16 8C16 3.58154 12.418 0 8 0C3.58203 0 0 3.58154 0 8C0 12.4185 3.58203 16 8 16ZM5 7C4.44727 7 4 7.44775 4 8C4 8.55225 4.44727 9 5 9H11C11.5527 9 12 8.55225 12 8C12 7.44775 11.5527 7 11 7H5Z\"\n fill={color}\n />\n ) : (\n <>\n <circle cx=\"8\" cy=\"8\" r=\"7\" stroke={color} strokeWidth=\"2\" />\n <path\n d=\"M4 8.5V7.5C4 7.22386 4.22386 7 4.5 7H11.5C11.7761 7 12 7.22386 12 7.5V8.5C12 8.77614 11.7761 9 11.5 9H4.5C4.22386 9 4 8.77614 4 8.5Z\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nMinus.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n solid: false,\n}\n\nMinus.propTypes = {\n color: PropTypes.string,\n solid: PropTypes.bool,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Minus\n\n```"
}
] |
code_store-on-localhost_f5531547
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Delete/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Delete extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"delete\" size={newSize} block={block}>\n <path d=\"M2 0H0V6H2V0Z\" transform=\"translate(5 7)\" fill={color} />\n <path d=\"M2 0H0V6H2V0Z\" transform=\"translate(9 7)\" fill={color} />\n <path\n d=\"M12 1C12 0.4 11.6 0 11 0H5C4.4 0 4 0.4 4 1V3H0V5H1V15C1 15.6 1.4 16 2 16H14C14.6 16 15 15.6 15 15V5H16V3H12V1ZM6 2H10V3H6V2ZM13 5V14H3V5H13Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nDelete.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nDelete.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Delete\n\n```"
}
] |
code_store-on-localhost_5fc11860
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/VisibilityOn/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass VisibilityOn extends PureComponent {\n render() {\n const { color, size, solid } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"visibility-on\"\n variation={solid ? 'solid' : null}\n size={newSize}>\n {solid ? (\n <path\n d=\"M7.975 14C11.575 14 14.375 10.9 15.575 9.1C16.075 8.4 16.075 7.5 15.575 6.8C14.375 5.1 11.575 2 7.975 2C4.375 2 1.575 5.1 0.375 6.9C-0.125 7.6 -0.125 8.5 0.375 9.1C1.575 10.9 4.375 14 7.975 14ZM7.975 5C9.675 5 10.975 6.3 10.975 8C10.975 9.7 9.675 11 7.975 11C6.275 11 4.975 9.7 4.975 8C4.975 6.3 6.275 5 7.975 5Z\"\n fill={color}\n />\n ) : (\n <>\n <g clipPath=\"url(#clip0)\">\n <path\n d=\"M8.00013 14C12.7071 14 15.7441 8.716 15.8711 8.492C16.0421 8.188 16.0431 7.816 15.8721 7.512C15.7461 7.287 12.7311 2 8.00013 2C3.24513 2 0.251127 7.289 0.126127 7.514C-0.0428725 7.817 -0.0418725 8.186 0.128127 8.489C0.254127 8.713 3.26913 14 8.00013 14ZM8.00013 4C10.8391 4 13.0361 6.835 13.8181 8C13.0341 9.166 10.8371 12 8.00013 12C5.15913 12 2.96213 9.162 2.18113 7.999C2.95813 6.835 5.14613 4 8.00013 4Z\"\n fill={color}\n />\n <path\n d=\"M8.00013 10C9.1047 10 10.0001 9.10457 10.0001 8C10.0001 6.89543 9.1047 6 8.00013 6C6.89556 6 6.00013 6.89543 6.00013 8C6.00013 9.10457 6.89556 10 8.00013 10Z\"\n fill={color}\n />\n </g>\n <defs>\n <clipPath id=\"clip0\">\n <rect width=\"16\" height=\"16\" fill=\"none\" />\n </clipPath>\n </defs>\n </>\n )}\n </Svg>\n )\n }\n}\n\nVisibilityOn.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n}\n\nVisibilityOn.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n}\n\nexport default VisibilityOn\n\n```"
}
] |
code_store-on-localhost_8eecc191
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ArrowUp/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 17,\n height: 16,\n}\n\nclass ArrowUp extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"arrow-up\" size={newSize} block={block} viewBox=\"0 0 17 16\">\n <path\n d=\"M8.39162 16C8.78498 16 9.04721 15.8667 9.30945 15.6L16.7832 8L14.9476 6.13333L9.70281 11.4667V0H7.08043V11.4667L1.83567 6.13333L3.12612e-08 8L7.47379 15.6C7.73602 15.8667 7.99826 16 8.39162 16Z\"\n transform=\"translate(16.7832 16) rotate(-180)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nArrowUp.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nArrowUp.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ArrowUp\n\n```"
}
] |
code_store-on-localhost_dcb3a3a0
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ExternalLinkMini/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 14,\n}\n\nclass ExternalLinkMini extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"external-link-mini\"\n size={newSize}\n block={block}\n viewBox=\"0 0 14 14\">\n <path\n d=\"M12.5567 0H2.45361V2.8866H9.09278L0 11.9794L2.02062 14L11.1134 4.90722V11.5464H14V1.4433C14 0.57732 13.4227 0 12.5567 0Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nExternalLinkMini.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nExternalLinkMini.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ExternalLinkMini\n\n```"
}
] |
code_store-on-localhost_7ed575ce
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Printer/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 15,\n}\n\nclass Printer extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"Printer\" size={newSize} block={block} viewBox=\"0 0 16 15\">\n <path\n d=\"M13.6 4H2.4C1.072 4 0 5.072 0 6.4V10.2C0 10.7523 0.447715 11.2 1 11.2H3.2V13.4C3.2 13.9523 3.64772 14.4 4.2 14.4H11.8C12.3523 14.4 12.8 13.9523 12.8 13.4V11.2H15C15.5523 11.2 16 10.7523 16 10.2V6.4C16 5.072 14.928 4 13.6 4ZM11.2 12.8H4.8V8.8H11.2V12.8ZM13.6 7.2C13.16 7.2 12.8 6.84 12.8 6.4C12.8 5.96 13.16 5.6 13.6 5.6C14.04 5.6 14.4 5.96 14.4 6.4C14.4 6.84 14.04 7.2 13.6 7.2ZM12.8 1C12.8 0.447716 12.3523 0 11.8 0H4.2C3.64771 0 3.2 0.447715 3.2 1V3.2H12.8V1Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nPrinter.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nPrinter.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Printer\n\n```"
}
] |
code_store-on-localhost_3f0ce342
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/OrderedList/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass OrderedList extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"orderedList\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <path d=\"M3.985,18.909V17.014l2.063-.168c.336-.024.384-.12.384-.481V7.994c0-.288-.073-.432-.312-.5L4.033,7.058,4.3,5.091h5.757V16.365c0,.384.024.457.384.481l1.967.168v1.895Z\" />{' '}\n <path\n data-color=\"color-2\"\n d=\"M2.738,39.088v-2.23l3.214-3.143c2.423-2.351,3.454-3.311,3.454-4.678,0-.887-.432-1.535-1.7-1.535-1.319,0-1.87.431-1.87,2.135L2.57,29.349c.024-3.814,2.927-4.437,5.445-4.437,3.718,0,5.038,1.583,5.038,3.838s-1.56,3.741-3.311,5.421L7.032,36.76h3.525c.241,0,.336-.047.384-.285l.336-1.9H13.82v4.51Z\"\n />{' '}\n <path\n data-color=\"color-2\"\n d=\"M10.834,51.736A3.385,3.385,0,0,1,14,55.43c0,3.166-2.375,4.654-5.8,4.654a7.921,7.921,0,0,1-5.8-2.207l1.919-2.113a4.781,4.781,0,0,0,3.6,1.586c1.343,0,2.494-.481,2.494-2.16,0-1.463-.911-2.063-2.4-2.063a9.691,9.691,0,0,0-1.775.168V50.9L7.4,50.752c1.728-.215,2.663-1.055,2.663-2.59,0-.912-.408-1.656-1.751-1.656-1.3,0-1.92.431-1.92,2.134l-3.286-.287c0-3.789,2.854-4.437,5.373-4.437,3.7,0,5.11,1.414,5.11,3.98a3.756,3.756,0,0,1-2.758,3.743Z\"\n fill={color}\n />\n <path d=\"M61,13H21a1,1,0,0,1,0-2H61a1,1,0,0,1,0,2Z\" fill={color} />\n <path d=\"M46,33H21a1,1,0,0,1,0-2H46a1,1,0,0,1,0,2Z\" fill={color} />\n <path d=\"M61,53H21a1,1,0,0,1,0-2H61a1,1,0,0,1,0,2Z\" fill={color} />\n </Svg>\n )\n }\n}\n\nOrderedList.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nOrderedList.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default OrderedList\n\n```"
}
] |
code_store-on-localhost_fdcfb6b4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Cog/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 20,\n height: 20,\n}\n\nclass Cog extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"cog\" size={newSize} block={block} viewBox=\"0 0 20 20\">\n <path\n d=\"M18.9188 8.48C17.29 8.0725 16.5175 6.2075 17.3813 4.76875C17.7838 4.09875 17.6625 3.52125 17.2638 3.12375L16.8763 2.73625C16.4788 2.33875 15.9013 2.2175 15.2313 2.61875C13.7913 3.4825 11.9262 2.71 11.52 1.08125C11.3312 0.3225 10.8362 0 10.2738 0H9.72625C9.16375 0 8.67 0.3225 8.48 1.08125C8.0725 2.71 6.2075 3.4825 4.76875 2.61875C4.09875 2.21625 3.52 2.3375 3.1225 2.735L2.735 3.1225C2.3375 3.52 2.21625 4.09875 2.61875 4.76875C3.4825 6.20875 2.71 8.07375 1.08125 8.48C0.325 8.66875 0 9.1625 0 9.72625V10.2738C0 10.8362 0.3225 11.33 1.08125 11.52C2.71 11.9275 3.4825 13.7925 2.61875 15.2313C2.21625 15.9013 2.3375 16.4788 2.73625 16.8763L3.12375 17.2638C3.5225 17.6625 4.10125 17.7825 4.76875 17.3813C6.20875 16.5175 8.07375 17.29 8.48 18.9188C8.66875 19.6775 9.16375 20 9.72625 20H10.2738C10.8362 20 11.33 19.6775 11.52 18.9188C11.9275 17.29 13.7925 16.5175 15.2313 17.3813C15.9 17.7825 16.4775 17.6625 16.8763 17.2638L17.2638 16.8763C17.6612 16.4788 17.7825 15.9013 17.3813 15.2313C16.5175 13.7913 17.29 11.9262 18.9188 11.52C19.6775 11.3312 20 10.8362 20 10.2738V9.72625C20 9.1625 19.675 8.66875 18.9188 8.48ZM10 13.75C7.92875 13.75 6.25 12.0712 6.25 10C6.25 7.92875 7.92875 6.25 10 6.25C12.0712 6.25 13.75 7.92875 13.75 10C13.75 12.0712 12.0712 13.75 10 13.75Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCog.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCog.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Cog\n\n```"
}
] |
code_store-on-localhost_c0077f9f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Italic/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Italic extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"italic\" size={newSize} block={block} viewBox=\"0 0 64 64\">\n <path\n fill={color}\n d=\"M18,62v-4l5.25626-0.64264c1.16066-0.08098,1.32598-0.41163,1.49131-1.65664l6.62993-47.40145 c0.16533-1.24501,0.08435-1.57566-1.07631-1.66001L26,6V2h20v4l-5.58691,0.72361c-1.24501,0.16533-1.32936,0.33065-1.49469,1.57566 l-6.7109,47.32048c-0.16533,1.32598-0.16533,1.49131,1.07631,1.65664L38,58v4H18z\"\n />\n </Svg>\n )\n }\n}\n\nItalic.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nItalic.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Italic\n\n```"
}
] |
code_store-on-localhost_fa951c87
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Density/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 13,\n}\n\nclass Density extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"density\"\n size={newSize}\n block={block}\n viewBox=\"0 0 14 13\"\n fill={color}>\n <rect\n y=\"11.1426\"\n width={newSize.width}\n height=\"1.85714\"\n rx=\"0.928571\"\n fill={color}\n />\n <rect\n y=\"7.42871\"\n width={newSize.width}\n height=\"1.85714\"\n rx=\"0.928571\"\n fill={color}\n />\n <rect width={newSize.width} height=\"5.57143\" rx=\"1\" fill={color} />\n </Svg>\n )\n }\n}\n\nDensity.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nDensity.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Density\n\n```"
}
] |
code_store-on-localhost_4839e671
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/User/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 44,\n height: 44,\n}\n\nclass User extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"user\" size={newSize} block={block} viewBox=\"0 0 32 32\">\n <path\n d=\"M16 0C7.17733 0 0 7.17733 0 16C0 24.8227 7.17733 32 16 32C24.8227 32 32 24.8227 32 16C32 7.17733 24.8227 0 16 0ZM24.9307 25.872C24.0453 23.2413 21.5973 21.3333 18.6667 21.3333H13.3333C10.4027 21.3333 7.95733 23.2427 7.072 25.8733C4.37467 23.432 2.66667 19.916 2.66667 16C2.66667 8.648 8.648 2.66667 16 2.66667C23.352 2.66667 29.3333 8.648 29.3333 16C29.3333 19.9147 27.6267 23.4307 24.9307 25.872Z\"\n fill={color}\n />\n <path\n d=\"M15.9998 6.66699C13.0545 6.66699 10.6665 9.05499 10.6665 12.0003V13.3337C10.6665 16.279 13.0545 18.667 15.9998 18.667C18.9452 18.667 21.3332 16.279 21.3332 13.3337V12.0003C21.3332 9.05499 18.9452 6.66699 15.9998 6.66699Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nUser.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nUser.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default User\n\n```"
}
] |
code_store-on-localhost_312747a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Image/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Image extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"image\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <path d=\"M52,10H12V6a2,2,0,0,1,2-2H50a2,2,0,0,1,2,2Z\" fill={color} />\n <path\n d=\"M59,12H5a2,2,0,0,0-2,2V58a2,2,0,0,0,2,2H59a2,2,0,0,0,2-2V14A2,2,0,0,0,59,12ZM21,20a4,4,0,1,1-4,4A4,4,0,0,1,21,20ZM52.87,49.493A1,1,0,0,1,52,50H12a1,1,0,0,1-.832-1.555l8-12a1,1,0,0,1,1.539-.152l7.185,7.185L39.2,28.4a.973.973,0,0,1,.852-.4,1,1,0,0,1,.8.484l12,20A1,1,0,0,1,52.87,49.493Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nImage.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nImage.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Image\n\n```"
}
] |
code_store-on-localhost_546d1a44
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Search/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Search extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"search\" size={newSize} block={block}>\n <path\n d=\"M15.707 13.293L13 10.586C13.63 9.536 14 8.311 14 7C14 3.14 10.859 0 7 0C3.141 0 0 3.14 0 7C0 10.86 3.141 14 7 14C8.312 14 9.536 13.631 10.586 13L13.293 15.707C13.488 15.902 13.744 16 14 16C14.256 16 14.512 15.902 14.707 15.707L15.707 14.707C16.098 14.316 16.098 13.684 15.707 13.293ZM7 12C4.239 12 2 9.761 2 7C2 4.239 4.239 2 7 2C9.761 2 12 4.239 12 7C12 9.761 9.761 12 7 12Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nSearch.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nSearch.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Search\n\n```"
}
] |
code_store-on-localhost_6d3a8f6c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Clear/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\n\nclass Clear extends PureComponent {\n render() {\n const { size, color } = this.props\n const newSize = {\n width: size,\n height: size,\n }\n return (\n <Svg name=\"clear\" size={newSize} viewBox=\"0 0 16 16\">\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM11.1464 9.74645C11.3417 9.94171 11.3417 10.2583 11.1464 10.4536L10.4536 11.1464C10.2583 11.3417 9.94171 11.3417 9.74645 11.1464L8 9.4L6.25355 11.1464C6.05829 11.3417 5.74171 11.3417 5.54645 11.1464L4.85355 10.4536C4.65829 10.2583 4.65829 9.94171 4.85355 9.74645L6.6 8L4.85355 6.25355C4.65829 6.05829 4.65829 5.74171 4.85355 5.54645L5.54645 4.85355C5.74171 4.65829 6.05829 4.65829 6.25355 4.85355L8 6.6L9.74645 4.85355C9.94171 4.65829 10.2583 4.65829 10.4536 4.85355L11.1464 5.54645C11.3417 5.74171 11.3417 6.05829 11.1464 6.25355L9.4 8L11.1464 9.74645Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nClear.defaultProps = {\n size: 16,\n color: 'currentColor',\n}\n\nClear.propTypes = {\n size: PropTypes.number.isRequired,\n color: PropTypes.string.isRequired,\n}\n\nexport default Clear\n\n```"
}
] |
code_store-on-localhost_b62be17e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Bars/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Bars extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"bars\" size={newSize} block={block} viewBox=\"0 0 18 12\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M0 12H18V10H0V12ZM0 7H18V5H0V7ZM0 0V2H18V0H0Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nBars.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nBars.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Bars\n\n```"
}
] |
code_store-on-localhost_9ab443c2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Info/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nconst Info = ({ color, size, block }) => {\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"info\" size={newSize} block={block}>\n <path\n d=\"M8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16ZM8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2Z\"\n fill={color}\n />\n <path d=\"M7 12H9V7H7L7 12Z\" fill={color} />\n <path\n d=\"M8 4C7.44772 4 7 4.44772 7 5C7 5.55228 7.44772 6 8 6C8.55228 6 9 5.55228 9 5C9 4.44772 8.55228 4 8 4Z\"\n fill={color}\n />\n </Svg>\n )\n}\n\nInfo.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nInfo.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Info\n\n```"
}
] |
code_store-on-localhost_6e25f8b2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Edit/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Edit extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"edit\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <>\n <path\n d=\"M8.1 0L0.3 7.8C0.1 8 0 8.2 0 8.5V11.5C0 12.1 0.4 12.5 1 12.5H4C4.3 12.5 4.5 12.4 4.7 12.2L12.5 4.4L8.1 0Z\"\n transform=\"translate(0 3.5)\"\n fill={color}\n />\n <path\n d=\"M6.2 3.3L3.2 0.3C2.8 -0.1 2.2 -0.1 1.8 0.3L0 2.1L4.4 6.5L6.2 4.7C6.6 4.3 6.6 3.7 6.2 3.3Z\"\n transform=\"translate(9.5)\"\n fill={color}\n />\n </>\n ) : (\n <path\n d=\"M11.7 0.3C11.3 -0.1 10.7 -0.1 10.3 0.3L0.3 10.3C0.1 10.5 0 10.7 0 11V15C0 15.6 0.4 16 1 16H5C5.3 16 5.5 15.9 5.7 15.7L15.7 5.7C16.1 5.3 16.1 4.7 15.7 4.3L11.7 0.3ZM4.6 14H2V11.4L8 5.4L10.6 8L4.6 14ZM12 6.6L9.4 4L11 2.4L13.6 5L12 6.6Z\"\n fill={color}\n />\n )}\n </Svg>\n )\n }\n}\n\nEdit.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nEdit.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Edit\n\n```"
}
] |
code_store-on-localhost_760123c3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Warning/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Warning extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"warning\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 12C7.4 12 7 11.6 7 11C7 10.4 7.4 10 8 10C8.6 10 9 10.4 9 11C9 11.6 8.6 12 8 12ZM9 9H7V4H9V9Z\"\n fill={color}\n />\n ) : (\n <>\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14Z\"\n fill={color}\n />\n <path d=\"M2 0H0V5H2V0Z\" transform=\"translate(7 4)\" fill={color} />\n <path\n d=\"M1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2Z\"\n transform=\"translate(7 10)\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nWarning.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nWarning.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Warning\n\n```"
}
] |
code_store-on-localhost_7e994a8f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Deny/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 14,\n}\n\nclass Deny extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"deny\" size={newSize} block={block} viewBox=\"0 0 14 14\">\n <path\n d=\"M11.9071 0.707107C11.5166 0.316582 10.8834 0.316582 10.4929 0.707107L7 4.2L3.50711 0.707107C3.11658 0.316582 2.48342 0.316583 2.09289 0.707107L0.707107 2.09289C0.316582 2.48342 0.316583 3.11658 0.707107 3.50711L4.2 7L0.707107 10.4929C0.316582 10.8834 0.316583 11.5166 0.707107 11.9071L2.09289 13.2929C2.48342 13.6834 3.11658 13.6834 3.50711 13.2929L7 9.8L10.4929 13.2929C10.8834 13.6834 11.5166 13.6834 11.9071 13.2929L13.2929 11.9071C13.6834 11.5166 13.6834 10.8834 13.2929 10.4929L9.8 7L13.2929 3.50711C13.6834 3.11658 13.6834 2.48342 13.2929 2.09289L11.9071 0.707107Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nDeny.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nDeny.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Deny\n\n```"
}
] |
code_store-on-localhost_e860b989
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Link/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Link extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"link\" size={newSize} block={block}>\n <path\n d=\"M5 0C3.7 0 2.4 0.5 1.5 1.5L0.3 2.6C-0.0999998 3 -0.0999998 3.6 0.3 4C0.7 4.4 1.3 4.4 1.7 4L2.9 2.8C4 1.7 6 1.7 7.1 2.8C7.7 3.4 8 4.2 8 5C8 5.8 7.7 6.6 7.1 7.1L6 8.3C5.6 8.7 5.6 9.3 6 9.7C6.2 9.9 6.5 10 6.7 10C6.9 10 7.2 9.9 7.4 9.7L8.6 8.5C9.5 7.6 10 6.3 10 5C10 3.7 9.5 2.4 8.5 1.5C7.6 0.5 6.3 0 5 0Z\"\n transform=\"translate(6)\"\n fill={color}\n />\n <path\n d=\"M8.3 6L7.1 7.2C6 8.3 4 8.3 2.9 7.2C2.3 6.6 2 5.8 2 5C2 4.2 2.3 3.4 2.9 2.9L4 1.7C4.4 1.3 4.4 0.7 4 0.3C3.6 -0.0999998 3 -0.0999998 2.6 0.3L1.5 1.5C0.5 2.4 0 3.7 0 5C0 6.3 0.5 7.6 1.5 8.5C2.4 9.5 3.7 10 5 10C6.3 10 7.6 9.5 8.5 8.5L9.7 7.3C10.1 6.9 10.1 6.3 9.7 5.9C9.3 5.5 8.7 5.6 8.3 6Z\"\n transform=\"translate(0 6)\"\n fill={color}\n />\n <path\n d=\"M4.5 0.3L0.3 4.5C-0.1 4.9 -0.1 5.5 0.3 5.9C0.5 6.1 0.8 6.2 1 6.2C1.2 6.2 1.5 6.1 1.7 5.9L5.9 1.7C6.3 1.3 6.3 0.7 5.9 0.3C5.5 -0.1 4.9 -0.1 4.5 0.3Z\"\n transform=\"translate(4.8999 4.90002)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nLink.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nLink.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Link\n\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.