mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(react/collections): fix the rest of client type errors
This commit is contained in:
parent
e77e0c54f0
commit
6077da0df8
@ -3,9 +3,9 @@ import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } fr
|
|||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
import "./NoteList.css";
|
import "./NoteList.css";
|
||||||
import { ListView, GridView } from "./legacy/ListOrGridView";
|
import { ListView, GridView } from "./legacy/ListOrGridView";
|
||||||
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
import GeoView from "./geomap";
|
import GeoView from "./geomap";
|
||||||
import ViewModeStorage from "../view_widgets/view_mode_storage";
|
import ViewModeStorage from "./view_mode_storage";
|
||||||
import CalendarView from "./calendar";
|
import CalendarView from "./calendar";
|
||||||
import TableView from "./table";
|
import TableView from "./table";
|
||||||
import BoardView from "./board";
|
import BoardView from "./board";
|
||||||
|
@ -2,8 +2,9 @@ import { useContext, useEffect, useLayoutEffect, useRef } from "preact/hooks";
|
|||||||
import { EventCallBackMethods, Module, Options, Tabulator as VanillaTabulator } from "tabulator-tables";
|
import { EventCallBackMethods, Module, Options, Tabulator as VanillaTabulator } from "tabulator-tables";
|
||||||
import "tabulator-tables/dist/css/tabulator.css";
|
import "tabulator-tables/dist/css/tabulator.css";
|
||||||
import "../../../../src/stylesheets/table.css";
|
import "../../../../src/stylesheets/table.css";
|
||||||
import { JSX, RefObject, VNode } from "preact";
|
|
||||||
import { ParentComponent, renderReactWidget } from "../../react/react_utils";
|
import { ParentComponent, renderReactWidget } from "../../react/react_utils";
|
||||||
|
import { JSX } from "preact/jsx-runtime";
|
||||||
|
import { isValidElement, RefObject } from "preact";
|
||||||
|
|
||||||
interface TableProps<T> extends Omit<Options, "data" | "footerElement" | "index"> {
|
interface TableProps<T> extends Omit<Options, "data" | "footerElement" | "index"> {
|
||||||
tabulatorRef: RefObject<VanillaTabulator>;
|
tabulatorRef: RefObject<VanillaTabulator>;
|
||||||
@ -12,7 +13,7 @@ interface TableProps<T> extends Omit<Options, "data" | "footerElement" | "index"
|
|||||||
modules?: (new (table: VanillaTabulator) => Module)[];
|
modules?: (new (table: VanillaTabulator) => Module)[];
|
||||||
events?: Partial<EventCallBackMethods>;
|
events?: Partial<EventCallBackMethods>;
|
||||||
index: keyof T;
|
index: keyof T;
|
||||||
footerElement?: JSX.Element;
|
footerElement?: string | HTMLElement | JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Tabulator<T>({ className, columns, data, modules, tabulatorRef: externalTabulatorRef, footerElement, events, index, ...restProps }: TableProps<T>) {
|
export default function Tabulator<T>({ className, columns, data, modules, tabulatorRef: externalTabulatorRef, footerElement, events, index, ...restProps }: TableProps<T>) {
|
||||||
@ -33,7 +34,7 @@ export default function Tabulator<T>({ className, columns, data, modules, tabula
|
|||||||
const tabulator = new VanillaTabulator(containerRef.current, {
|
const tabulator = new VanillaTabulator(containerRef.current, {
|
||||||
columns,
|
columns,
|
||||||
data,
|
data,
|
||||||
footerElement: (parentComponent && footerElement ? renderReactWidget(parentComponent, footerElement)[0] : undefined),
|
footerElement: (parentComponent && isValidElement(footerElement) ? renderReactWidget(parentComponent, footerElement)[0] : undefined),
|
||||||
index: index as string | number | undefined,
|
index: index as string | number | undefined,
|
||||||
...restProps
|
...restProps
|
||||||
});
|
});
|
||||||
|
@ -148,19 +148,12 @@ export function TouchBarButton({ label, icon, click, enabled }: ButtonProps) {
|
|||||||
|
|
||||||
export function TouchBarSegmentedControl({ mode, segments, selectedIndex, onChange }: SegmentedControlProps) {
|
export function TouchBarSegmentedControl({ mode, segments, selectedIndex, onChange }: SegmentedControlProps) {
|
||||||
const api = useContext(TouchBarContext);
|
const api = useContext(TouchBarContext);
|
||||||
const processedSegments = segments.map((segment) => {
|
|
||||||
if (segment.icon) {
|
|
||||||
if (!api) return undefined;
|
|
||||||
return {
|
|
||||||
...segment,
|
|
||||||
icon: buildIcon(api?.nativeImage, segment.icon)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return segment;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (api) {
|
if (api) {
|
||||||
|
const processedSegments: Electron.SegmentedControlSegment[] = segments.map(({icon, ...restProps}) => ({
|
||||||
|
...restProps,
|
||||||
|
icon: icon ? buildIcon(api.nativeImage, icon) : undefined
|
||||||
|
}));
|
||||||
const item = new api.TouchBar.TouchBarSegmentedControl({
|
const item = new api.TouchBar.TouchBarSegmentedControl({
|
||||||
mode, selectedIndex,
|
mode, selectedIndex,
|
||||||
segments: processedSegments,
|
segments: processedSegments,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user