Skip to content

Commit 9ae1dc0

Browse files
miscellaneous fixes and patches (#98)
* add missing card component to local api * fix missing `JSX` import in loading boundary file * fix type errors in progress-field.tsx * fix type errors in `basics.tsx` * fix type errors in data-array.ts * fix type errors related to `width` property in `table.tsx` * append special line to plugin output after `yarn dev` to ensure sourcemaps aren't stripped * fix inability to query `MarkdownListBlock`s by fields
1 parent a4324f6 commit 9ae1dc0

8 files changed

Lines changed: 23 additions & 13 deletions

File tree

esbuild.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async function build(prod) {
5151
// Copy the manifest and styles.
5252
fs.copyFileSync("manifest-beta.json", "build/plugin/manifest.json");
5353
fs.renameSync("build/plugin/main.css", "build/plugin/styles.css");
54+
fs.appendFileSync("build/plugin/main.js", "\n/* nosourcemap */")
5455
fs.writeFileSync("build/meta.json", JSON.stringify(result.metafile));
5556
}
5657

src/api/data-array.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ class DataArrayImpl<T> implements DataArray<T> {
391391
}
392392

393393
public first(): T {
394-
return this.values.length > 0 ? this.values[0] : undefined;
394+
return this.values.length > 0 ? this.values[0] : (undefined as T);
395395
}
396396
public last(): T {
397-
return this.values.length > 0 ? this.values[this.values.length - 1] : undefined;
397+
return this.values.length > 0 ? this.values[this.values.length - 1] : (undefined as T);
398398
}
399399

400400
public to(key: string): DataArray<any> {

src/api/local-api.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DataArray } from "./data-array";
2626
import { Coerce } from "./coerce";
2727
import { ScriptCache } from "./script-cache";
2828
import { Expression } from "expression/expression";
29+
import { Card } from "./ui/views/cards";
2930

3031
/** Local API provided to specific codeblocks when they are executing.
3132
* @group Core
@@ -318,6 +319,7 @@ export class DatacoreLocalApi {
318319
///////////
319320

320321
public VanillaTable = VanillaTable;
322+
public Card = Card;
321323

322324
/////////////////////////
323325
// Interative elements //

src/api/ui/basics.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const INTENT_CLASSES: Record<Intent, string> = {
2626
* @group Components
2727
*/
2828
export function Button(
29-
props: { className?: string; intent?: Intent; children: ComponentChildren } & React.HTMLProps<HTMLButtonElement>
29+
props: { className?: string; intent?: Intent; children: ComponentChildren } & React.ComponentProps<"button">
3030
) {
3131
const { className, intent, children, ...forwardingProps } = props;
3232
return (
@@ -43,7 +43,7 @@ export function Button(
4343
* A simple textbox which accepts text.
4444
* @group Components
4545
*/
46-
export function Textbox(props: { className?: string } & React.HTMLProps<HTMLInputElement>) {
46+
export function Textbox(props: React.ComponentProps<"input"> & { className?: string }) {
4747
const { className, children, ...forwardingProps } = props;
4848
return (
4949
<input type={props.type ?? "text"} className={combineClasses("dc-textbox", className)} {...forwardingProps} />
@@ -62,7 +62,7 @@ export function Checkbox(
6262
defaultChecked?: boolean;
6363
onCheckChange?: (checked: boolean) => void;
6464
children?: ComponentChildren;
65-
} & React.HTMLProps<HTMLInputElement>
65+
} & React.ComponentProps<"input">
6666
) {
6767
const {
6868
className,
@@ -105,7 +105,7 @@ export function Slider(
105105
value?: number;
106106
defaultValue?: number;
107107
onValueChange?: (value: number) => void;
108-
} & React.HTMLProps<HTMLInputElement>
108+
} & React.ComponentProps<"input">
109109
) {
110110
const { className, min = 0, max = 10, step = 1, value, defaultValue, onValueChange, ...forwardingProps } = props;
111111
const [slider, setSlider] = useControlledState(defaultValue ?? 0, value, onValueChange);
@@ -138,7 +138,7 @@ export function Switch(
138138
checked?: boolean;
139139
defaultChecked?: boolean;
140140
onToggleChange?: (checked: boolean) => void;
141-
} & React.HTMLProps<HTMLInputElement>
141+
} & React.ComponentProps<"input">
142142
) {
143143
const { className, disabled, defaultChecked, checked, onToggleChange, ...forwardingProps } = props;
144144
const [toggled, setToggled] = useControlledState(defaultChecked ?? false, checked, onToggleChange);
@@ -178,7 +178,7 @@ export function VanillaSelect(
178178
value?: string;
179179
defaultValue?: string;
180180
onValueChange?: (value: string) => void;
181-
} & React.HTMLProps<HTMLSelectElement>
181+
} & React.ComponentProps<"select">
182182
) {
183183
const { className, options = [], value, defaultValue, onValueChange, ...forwardingProps } = props;
184184
const [selectedValue, setSelectedValue] = React.useState(value ?? defaultValue ?? "");

src/api/ui/views/table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function VanillaTableHeaderCell<T>({ column }: { column: VanillaColumn<T>
148148

149149
// We use an internal div to avoid flex messing with the table layout.
150150
return (
151-
<th width={realWidth} className="datacore-table-header-cell">
151+
<th style={{ width: realWidth }} className="datacore-table-header-cell">
152152
<div className="datacore-table-header-title">{header}</div>
153153
</th>
154154
);

src/index/types/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export class MarkdownBlock implements Indexable, Linkbearing, Taggable, Fieldbea
354354

355355
/** Special block for markdown lists (of either plain list entries or tasks). */
356356
export class MarkdownListBlock extends MarkdownBlock implements Taggable, Linkbearing {
357-
static TYPES = ["markdown", "block", "block-list", TAGGABLE_TYPE, LINKBEARING_TYPE];
357+
static TYPES = ["markdown", "block", "block-list", TAGGABLE_TYPE, LINKBEARING_TYPE, FIELDBEARING_TYPE];
358358

359359
$types: string[] = MarkdownListBlock.TYPES;
360360
$typename: string = "List Block";

src/ui/fields/progress-field.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ export function ProgressEditable(
3737
},
3838
[val.current, props.sourcePath]
3939
);
40-
const readOnly = <progress value={val.current} min={props.min} max={props.max} step={props.step} />;
40+
const readOnly = <progress value={val.current} max={props.max} />;
4141

4242
const editor = (
43-
<input type="range" className="datacore-progress-editable" value={val.current} onChange={changeCB} />
43+
<input
44+
type="range"
45+
className="datacore-progress-editable"
46+
min={props.min}
47+
value={val.current}
48+
onChange={changeCB}
49+
step={props.step}
50+
/>
4451
);
4552

4653
return (

src/ui/loading-boundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Datacore } from "index/datacore";
22
import { PropsWithChildren, useEffect, useState } from "preact/compat";
33
import { useIndexUpdates } from "./hooks";
44
import { Literal } from "expression/literal";
5-
import { VNode, createElement, isValidElement } from "preact";
5+
import { JSX, VNode, createElement, isValidElement } from "preact";
66
import { ErrorMessage, Lit } from "./markdown";
77

88
import "./errors.css";

0 commit comments

Comments
 (0)