Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Integrate combobox
Andrey Okonetchnikov4d21cb88fe6f
diff --git a/apps/designer/app/designer/features/props-panel/props-panel.tsx b/apps/designer/app/designer/features/props-panel/props-panel.tsxindex cbc29e8c58..f6cdc5f0c3 100644--- a/apps/designer/app/designer/features/props-panel/props-panel.tsx+++ b/apps/designer/app/designer/features/props-panel/props-panel.tsx@@ -7,7 +7,14 @@ import {import { Control } from "~/designer/features/props-panel/control";import { CollapsibleSection, ComponentInfo } from "~/designer/shared/inspector";import type { SelectedInstanceData } from "~/shared/canvas-components";-import { Box, Button, Grid, TextField, Tooltip } from "~/shared/design-system";+import {+ Box,+ Button,+ Combobox,+ Grid,+ TextField,+ Tooltip,+} from "~/shared/design-system";import { PlusIcon, TrashIcon, ExclamationTriangleIcon } from "~/shared/icons";import { handleChangePropType, usePropsLogic } from "./use-props-logic";@@ -35,25 +42,40 @@ const Property = ({const type = argType?.control.type || "text";const defaultValue = argType?.control.defaultValue;const options = argType?.options;+ const allProps = Object.keys(meta.argTypes).map((prop) => ({+ value: prop,+ label: prop,+ }));return (<Gridgap="1"css={{ gridTemplateColumns: "1fr 1fr auto", alignItems: "center" }}>- <TextField- readOnly={required}- variant="ghost"- placeholder="Property"+ <Comboboxname="prop"- value={prop}- onChange={(event) => {- onChange(id, "prop", event.target.value);+ options={allProps}+ value={{+ value: prop,+ label: prop,+ }}+ onOptionSelect={({ value }) => {+ console.log(value);+ onChange(id, "prop", value);}}+ disclosure={(props) => (+ <TextField+ {...props}+ readOnly={required}+ variant="ghost"+ placeholder="Property"+ />+ )}/>+{isInvalidProp ? (<Tooltip content={`Invalid property name: ${prop}`}><ExclamationTriangleIcon width={12} height={12} />- </Tooltip>+ </Tooltip>) : (<Controltype={type}diff --git a/apps/designer/app/shared/design-system/components/combobox.tsx b/apps/designer/app/shared/design-system/components/combobox.tsxindex 5e8aa77e7b..aa243a1039 100644--- a/apps/designer/app/shared/design-system/components/combobox.tsx+++ b/apps/designer/app/shared/design-system/components/combobox.tsx@@ -3,6 +3,7 @@ import { useCombobox } from "downshift";import { matchSorter } from "match-sorter";import { type ComponentProps, useState } from "react";import {+ Box,Popover,PopoverContent,PopoverTrigger,@@ -31,8 +32,8 @@ type ComboboxProps<Option> = {disclosure?: (props: DisclosureProps) => JSX.Element;};-const Listbox = styled("ul", panelStyles, { margin: 0 });-const ListboxItem = styled("li", itemCss);+const Listbox = styled("ul", panelStyles, { padding: 0, margin: 0 });+const ListboxItem = styled("li", itemCss, { padding: 0, margin: 0 });export const Combobox = <Option extends BaseOption>({options,@@ -74,30 +75,43 @@ export const Combobox = <Option extends BaseOption>({});return (- <div {...getComboboxProps()}>+ <Box+ {...getComboboxProps()}+ css={{+ position: "relative",+ }}+ >{disclosure(getInputProps({ name }))}- <IconButton variant="ghost" size="1">- <ChevronDownIcon />- </IconButton>- <Listbox {...getMenuProps()}>- {items.map((item, index) => {- return (- <ListboxItem- key={index}- {...getItemProps({- item,- index,- disabled: item.disabled,- ...(item.disabled ? { "data-disabled": true } : {}),- ...(highlightedIndex === index ? { "data-found": true } : {}),- })}- >- {getTextValue<Option>(item)}- {selectedItem === item && <CheckIcon />}- </ListboxItem>- );- })}- </Listbox>- </div>+ {/*<IconButton variant="ghost" size="1">*/}+ {/* <ChevronDownIcon />*/}+ {/*</IconButton>*/}+ {isOpen && (+ <Listbox+ {...getMenuProps()}+ css={{+ position: "absolute",+ width: "100%",+ }}+ >+ {items.map((item, index) => {+ return (+ <ListboxItem+ key={index}+ {...getItemProps({+ item,+ index,+ disabled: item.disabled,+ ...(item.disabled ? { "data-disabled": true } : {}),+ ...(highlightedIndex === index ? { "data-found": true } : {}),+ })}+ >+ {getTextValue<Option>(item)}+ {selectedItem === item && <CheckIcon />}+ </ListboxItem>+ );+ })}+ </Listbox>+ )}+ </Box>);};