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
78 changes: 68 additions & 10 deletions packages/html/src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// deno-lint-ignore-file ban-types
import type { Cell, CellLike, Props, RenderNode, VNode } from "commontools";

/**
* Used to represent DOM API's where users can either pass
* true or false as a boolean or as its equivalent strings.
*/
type Booleanish = boolean | "true" | "false";

// DOM-ish types for the CT runtime.
// The DOM is not directly available within the runtime, but the JSX
// produced must be typed. This defines DOM types like React or Preact,
// with a subset of supported features, and cannot rely on globals
// existing like `HTMLElement` from TypeScript's `dom` lib.
declare namespace CTDOM {
/**
* Used to represent DOM API's where users can either pass
* true or false as a boolean or as its equivalent strings.
*/
type Booleanish = boolean | "true" | "false";

/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN}
*/
Expand Down Expand Up @@ -1764,6 +1764,7 @@ declare namespace CTDOM {
export interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
// CT extensions
"onClick"?: CellLike<HandlerEvent<unknown>>;
"onChange"?: CellLike<HandlerEvent<unknown>>;
"children"?: RenderNode | undefined;
// Allow React-isms
"key"?: number;
Expand Down Expand Up @@ -1794,7 +1795,7 @@ declare namespace CTDOM {
| "search"
| "send"
| undefined;
hidden?: boolean | undefined;
hidden?: Booleanish; // CT addition to be compatible with our component usage of `hidden`
id?: string | undefined;
lang?: string | undefined;
nonce?: string | undefined;
Expand Down Expand Up @@ -2854,6 +2855,7 @@ interface CTHeadingElement extends CTHTMLElement {}
interface CTCollapsibleElement extends CTHTMLElement {}
interface CTThemeElement extends CTHTMLElement {}
interface CTCodeEditorElement extends CTHTMLElement {}
interface CTCodeEditorLegacyElement extends CTHTMLElement {}
interface CTScreenElement extends CTHTMLElement {}
interface CTAutoLayoutElement extends CTHTMLElement {}
interface CTButtonElement extends CTHTMLElement {}
Expand Down Expand Up @@ -2881,6 +2883,28 @@ interface CTCTCollapsibleElement extends CTHTMLElement {}
interface CTFragmentElement extends CTHTMLElement {}
interface CTUpdaterElement extends CTHTMLElement {}
interface CTGoogleOAuthElement extends CTHTMLElement {}
interface CTCanvasElement extends CTHTMLElement {}
interface CTDraggableElement extends CTHTMLElement {}
interface CTPlaidLinkElement extends CTHTMLElement {}

interface CTDraggableAttributes<T> extends CTHTMLAttributes<T> {
"key"?: number;
"x"?: CellLike<HandlerEvent<any>>;
"y"?: CellLike<HandlerEvent<any>>;
"hidden"?: Booleanish;
"onpositionchange"?: CellLike<HandlerEvent<any>>;
}

interface CTCanvasAttributes<T> extends CTHTMLAttributes<T> {
"width"?: string | number;
"height"?: string | number;
"onct-canvas-click"?: CellLike<HandlerEvent<any>>;
}

interface CTPlaidLinkAttributes<T> extends CTHTMLAttributes<T> {
"$auth"?: any;
"products"?: string[];
}

interface CTGoogleOAuthAttributes<T> extends CTHTMLAttributes<T> {
"$auth"?: any;
Expand Down Expand Up @@ -2990,9 +3014,11 @@ interface CTMessageInputAttributes<T> extends CTHTMLAttributes<T> {

interface CTSendMessageAttributes<T> extends CTHTMLAttributes<T> {
"name"?: string;
"value"?: any;
"placeholder"?: string;
"appearance"?: "rounded";
"onmessagesend"?: CellLike<HandlerEvent<{ message: string }>>;
"inline"?: Booleanish;
}

interface CTScrollAttributes<T> extends CTHTMLAttributes<T> {
Expand Down Expand Up @@ -3025,9 +3051,11 @@ interface CTButtonAttributes<T> extends CTHTMLAttributes<T> {
| "secondary"
| "ghost"
| "link"
| "danger"
| "pill";
"size"?: "default" | "sm" | "lg" | "icon";
"disabled"?: boolean;
"outline"?: boolean;
"type"?: "button" | "submit" | "reset";
}

Expand Down Expand Up @@ -3099,7 +3127,7 @@ interface CTInputAttributes<T> extends CTHTMLAttributes<T> {
"validationPattern"?: string;
"showValidation"?: boolean;
"timingStrategy"?: string;
"timingDelay"?: number;
"timingDelay"?: number | string;
"onct-change"?: any;
"onct-focus"?: any;
"onct-blur"?: any;
Expand All @@ -3122,7 +3150,7 @@ interface CTCheckboxAttributes<T> extends CTHTMLAttributes<T> {
"indeterminate"?: boolean;
"name"?: string;
"value"?: string;
"onct-change"?: any;
"onct-change"?: CellLike<HandlerEvent<any>>;
}

interface CTSelectAttributes<T> extends CTHTMLAttributes<T> {
Expand Down Expand Up @@ -3166,11 +3194,17 @@ interface CTCollapsibleAttributes<T> extends CTHTMLAttributes<T> {
interface CTThemeAttributes<T> extends CTHTMLAttributes<T> {
theme?: CTThemeInput;
}
interface CTCodeEditorLegacyAttributes<T> extends CTHTMLAttributes<T> {
"source"?: string;
"language"?: `text/${string}`;
"onChange"?: any;
"errors"?: any[];
}

interface CTCodeEditorAttributes<T> extends CTHTMLAttributes<T> {
"$value"?: CellLike<string>;
"value"?: string;
"language"?: string;
"language"?: `text/${string}`;
"disabled"?: boolean;
"readonly"?: boolean;
"placeholder"?: string;
Expand Down Expand Up @@ -3777,6 +3811,30 @@ declare global {
CTGoogleOAuthAttributes<CTGoogleOAuthElement>,
CTGoogleOAuthElement
>;
"ct-canvas": CTDOM.DetailedHTMLProps<
CTCanvasAttributes<CTCanvasElement>,
CTCanvasElement
>;
"ct-draggable": CTDOM.DetailedHTMLProps<
CTDraggableAttributes<CTDraggableElement>,
CTDraggableElement
>;
"ct-alert": CTDOM.DetailedHTMLProps<
CTHTMLAttributes<CTHTMLElement>,
CTHTMLElement
>;
"os-container": CTDOM.DetailedHTMLProps<
CTHTMLAttributes<CTHTMLElement>,
CTHTMLElement
>;
"common-code-editor": CTDOM.DetailedHTMLProps<
CTCodeEditorLegacyAttributes<CTCodeEditorLegacyElement>,
CTCodeEditorLegacyElement
>;
"common-plaid-link": CTDOM.DetailedHTMLProps<
CTPlaidLinkAttributes<CTPlaidLinkElement>,
CTPlaidLinkElement
>;
// Define both `ct-` and `common-` variants
"ct-hstack": CTDOM.DetailedHTMLProps<
CTStackAttributes<CTHStackElement>,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export default recipe(
// The framework will handle empty content cases reactively
const extractionResult = llm({
system: systemPrompt,
messages: [userPrompt],
messages: [{ role: "user", content: userPrompt }],
model: "google:gemini-2.5-flash",
mode: "json",
});
Expand Down
8 changes: 4 additions & 4 deletions recipes/gpeople.tsx → recipes/_gpeople.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1290,16 +1290,16 @@ export default recipe(
})}
/>
</div>
<common-button
<ct-button
onClick={peopleUpdater({ contacts, auth, settings })}
>
Fetch Contacts
</common-button>
<common-button
</ct-button>
<ct-button
onClick={clearContacts({ contacts })}
>
Clear Contacts
</common-button>
</ct-button>
</common-vstack>
</common-hstack>
<common-google-oauth
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions recipes/compiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export default recipe<Input>(
{ifElse(
error,
<b>fix the errors</b>,
<common-button
<ct-button
onClick={visit({ code })}
>
Navigate To Charm
</common-button>,
</ct-button>,
)}
</div>
),
Expand Down
6 changes: 3 additions & 3 deletions recipes/email-summarizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export default recipe(
// Call LLM to generate summary
const summaryResult = llm({
system: systemPrompt,
messages: [userPrompt],
messages: [{ role: "user", content: userPrompt }],
});

// Return a simple object that references the original email
Expand Down Expand Up @@ -348,9 +348,9 @@ export default recipe(
</div>

<div>
<common-checkbox
<ct-checkbox
checked={settings.includeTags}
oncommon-checked={includeTagsHandler}
onct-change={includeTagsHandler}
/>
<label>Include Tags</label>
</div>
Expand Down
12 changes: 6 additions & 6 deletions recipes/gcal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -620,11 +620,11 @@ export default recipe(
<div>
<label>
Calendars
<common-button
<ct-button
onClick={getCalendars({ auth, calendars })}
>
Fetch Calendar List
</common-button>
</ct-button>
</label>
<table>
<thead>
Expand Down Expand Up @@ -659,20 +659,20 @@ export default recipe(
})}
/>
</div>
<common-button
<ct-button
onClick={calendarUpdater({
events,
auth,
settings,
})}
>
Fetch Events
</common-button>
<common-button
</ct-button>
<ct-button
onClick={clearEvents({ events })}
>
Clear Events
</common-button>
</ct-button>
</common-vstack>
</common-hstack>
<common-google-oauth
Expand Down
1 change: 1 addition & 0 deletions tasks/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if [[ ! " ${DENO_VERSIONS_ALLOWED[@]} " =~ " ${DENO_VERSION} " ]]; then
exit 1
fi

deno check recipes/[!_]*.ts*
deno check \
packages/api \
packages/background-charm-service \
Expand Down