mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: types.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { beforeNavigate } from '$app/navigation';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import type { PinkSheetColumn } from '$lib/helpers/types';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import type { Writable } from 'svelte/store';
|
||||
import Content from './content.svelte';
|
||||
import {
|
||||
@@ -19,7 +19,7 @@
|
||||
import { Click, Submit, trackEvent } from '$lib/actions/analytics';
|
||||
|
||||
export let query = '[]';
|
||||
export let columns: Writable<PinkSheetColumn[]>;
|
||||
export let columns: Writable<Column[]>;
|
||||
export let disabled = false;
|
||||
export let fullWidthMobile = false;
|
||||
export let singleCondition = false;
|
||||
|
||||
@@ -4,7 +4,7 @@ import deepEqual from 'deep-equal';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { derived, get, writable } from 'svelte/store';
|
||||
import type { SheetColumn, SheetColumnType } from '$lib/helpers/types';
|
||||
import type { Column, ColumnType } from '$lib/helpers/types';
|
||||
|
||||
export type TagValue = {
|
||||
tag: string;
|
||||
@@ -14,7 +14,7 @@ export type TagValue = {
|
||||
export type Operator = {
|
||||
toTag: (attribute: string, input?: string | number | string[], type?: string) => TagValue;
|
||||
toQuery: (attribute: string, input?: string | number | string[]) => string;
|
||||
types: SheetColumnType[];
|
||||
types: ColumnType[];
|
||||
hideInput?: boolean;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ function initQueries(initialValue = new Map<TagValue, string>()) {
|
||||
|
||||
type AddFilterArgs = {
|
||||
operator: Operator;
|
||||
column: SheetColumn;
|
||||
column: Column;
|
||||
value: string | number | string[];
|
||||
};
|
||||
|
||||
@@ -91,14 +91,14 @@ export const tags = derived(queries, ($queries) => Array.from($queries.keys()));
|
||||
|
||||
/* eslint @typescript-eslint/no-explicit-any: 'off' */
|
||||
export function addFilter(
|
||||
columns: SheetColumn[],
|
||||
columns: Column[],
|
||||
columnId: string,
|
||||
operatorKey: string,
|
||||
value: any, // We cast to any to not cause type errors in the input components
|
||||
arrayValues: string[] = []
|
||||
) {
|
||||
const operator = operatorKey ? operators[operatorKey] : null;
|
||||
const column = columns.find((c) => c.id === columnId) as SheetColumn;
|
||||
const column = columns.find((c) => c.id === columnId) as Column;
|
||||
if (!column || !operator) return;
|
||||
if (column.array) {
|
||||
queries.addFilter({ column, operator, value: arrayValues });
|
||||
@@ -135,7 +135,7 @@ const operatorsDefault = new Map<
|
||||
ValidOperators,
|
||||
{
|
||||
query: (attr: string, input: string | number | string[]) => string;
|
||||
types: SheetColumnType[];
|
||||
types: ColumnType[];
|
||||
hideInput?: boolean;
|
||||
}
|
||||
>([
|
||||
|
||||
@@ -15,25 +15,6 @@ export type PinkColumn = {
|
||||
hide?: boolean;
|
||||
};
|
||||
|
||||
export type PinkSheetColumn = {
|
||||
id: string;
|
||||
width?:
|
||||
| {
|
||||
min: number;
|
||||
max: number;
|
||||
}
|
||||
| {
|
||||
min: number;
|
||||
}
|
||||
| number;
|
||||
hide?: boolean;
|
||||
fixed?: boolean;
|
||||
resizable?: boolean;
|
||||
draggable?: boolean;
|
||||
resizedWidth?: number;
|
||||
isAction?: boolean;
|
||||
};
|
||||
|
||||
export type WritableValue<T> = T extends Writable<infer U> ? U : never;
|
||||
|
||||
export function isHTMLElement(el: unknown): el is HTMLElement {
|
||||
@@ -55,10 +36,10 @@ const columnTypes = [
|
||||
'relationship',
|
||||
'enum'
|
||||
] as const;
|
||||
export type SheetColumnType = (typeof columnTypes)[number];
|
||||
export type SheetColumn = PinkSheetColumn & {
|
||||
export type ColumnType = (typeof columnTypes)[number];
|
||||
export type Column = PinkColumn & {
|
||||
title: string;
|
||||
type: SheetColumnType;
|
||||
type: ColumnType;
|
||||
filter?: boolean;
|
||||
array?: boolean;
|
||||
format?: string;
|
||||
@@ -68,6 +49,11 @@ export type SheetColumn = PinkSheetColumn & {
|
||||
icon?: ComponentType;
|
||||
isPrimary?: boolean;
|
||||
isEditable?: boolean;
|
||||
fixed?: boolean;
|
||||
resizable?: boolean;
|
||||
draggable?: boolean;
|
||||
resizedWidth?: number;
|
||||
isAction?: boolean;
|
||||
};
|
||||
|
||||
export function isValueOfStringEnum<T extends Record<string, string>>(
|
||||
|
||||
Reference in New Issue
Block a user