Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/html/src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2868,7 +2868,9 @@ interface CTFileInputElement extends CTHTMLElement {}
interface CTImageInputElement extends CTHTMLElement {}
interface CTInputLegacyElement extends CTHTMLElement {}
interface CTCheckboxElement extends CTHTMLElement {}
interface CTAutocompleteElement extends CTHTMLElement {}
interface CTSelectElement extends CTHTMLElement {}
interface CTRadioGroupElement extends CTHTMLElement {}
interface CTPickerElement extends CTHTMLElement {}
interface CTToolsChipElement extends CTHTMLElement {}
interface CTHeadingElement extends CTHTMLElement {}
Expand Down Expand Up @@ -3328,6 +3330,29 @@ interface CTCheckboxAttributes<T> extends CTHTMLAttributes<T> {
"onct-change"?: EventHandler<any>;
}

interface CTAutocompleteAttributes<T> extends CTHTMLAttributes<T> {
"$value"?: CellLike<string | string[]>;
"items": {
value: string;
label?: string;
group?: string;
searchAliases?: string[];
}[];
"placeholder"?: string;
"maxVisible"?: number;
"allowCustom"?: boolean;
"multiple"?: boolean;
"disabled"?: boolean;
"onct-change"?: EventHandler<
{ value: string | string[]; oldValue: string | string[] }
>;
"onct-select"?: EventHandler<
{ value: string; label: string; group?: string; isCustom: boolean }
>;
"onct-open"?: EventHandler<any>;
"onct-close"?: EventHandler<any>;
}

interface CTSelectAttributes<T> extends CTHTMLAttributes<T> {
"$value": CellLike<any | any[]>;
"items": { label: string; value: any }[];
Expand All @@ -3337,6 +3362,18 @@ interface CTSelectAttributes<T> extends CTHTMLAttributes<T> {
>;
}

interface CTRadioGroupAttributes<T> extends CTHTMLAttributes<T> {
"$value"?: CellLike<any>;
"value"?: any;
"items"?: { label: string; value: any; disabled?: boolean }[];
"name"?: string;
"disabled"?: boolean;
"orientation"?: "vertical" | "horizontal";
"onct-change"?: EventHandler<
{ items: { label: string; value: any }[]; value: any; oldValue: any }
>;
}

interface CTPickerAttributes<T> extends CTHTMLAttributes<T> {
"$selectedIndex"?: CellLike<number>;
"$items": CellLike<any[]>;
Expand Down Expand Up @@ -3880,10 +3917,18 @@ declare global {
CTCheckboxAttributes<CTCheckboxElement>,
CTCheckboxElement
>;
"ct-autocomplete": CTDOM.DetailedHTMLProps<
CTAutocompleteAttributes<CTAutocompleteElement>,
CTAutocompleteElement
>;
"ct-select": CTDOM.DetailedHTMLProps<
CTSelectAttributes<CTSelectElement>,
CTSelectElement
>;
"ct-radio-group": CTDOM.DetailedHTMLProps<
CTRadioGroupAttributes<CTRadioGroupElement>,
CTRadioGroupElement
>;
"ct-picker": CTDOM.DetailedHTMLProps<
CTPickerAttributes<CTPickerElement>,
CTPickerElement
Expand Down
29 changes: 29 additions & 0 deletions packages/patterns/ct-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,35 @@ export default recipe<Input, Result>(
<p>Selected: {selected}</p>
</ct-card>

<ct-card>
<h4>
<code>ct-autocomplete</code>
</h4>
<ct-autocomplete
items={[
{ label: "Option 1", value: "opt_1" },
{ label: "Option 2", value: "opt_2" },
{ label: "Option 3", value: "opt_3" },
]}
$value={selected}
/>
</ct-card>

<ct-card>
<h4>
<code>ct-radio-group</code>
</h4>
<ct-radio-group
$value={selected}
items={[
{ label: "Option 1", value: "opt_1" },
{ label: "Option 2", value: "opt_2" },
{ label: "Option 3", value: "opt_3" },
]}
orientation="horizontal"
/>
</ct-card>

<ct-card>
<h4>Numeric Values</h4>
<p>Values can be any type, not just strings</p>
Expand Down
Loading
Loading