From c81e5079fbcdab3a0c5ec44a91c607e13958d046 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 6 Feb 2024 13:49:30 +0100 Subject: [PATCH 01/22] fix: disable filtering when there are no atributes --- src/lib/components/filters/filters.svelte | 3 ++- .../database-[database]/collection-[collection]/+page.svelte | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/components/filters/filters.svelte b/src/lib/components/filters/filters.svelte index cd2f8bfd9..38af5a6dc 100644 --- a/src/lib/components/filters/filters.svelte +++ b/src/lib/components/filters/filters.svelte @@ -9,6 +9,7 @@ export let query = '[]'; export let columns: Writable; + export let disabled = false; const parsedQueries = queryParamToMap(query); queries.set(parsedQueries); @@ -28,7 +29,7 @@
-
- +
Date: Tue, 6 Feb 2024 16:26:43 +0100 Subject: [PATCH 02/22] Update dependencies and add array support to column attributes --- package-lock.json | 18 ++--- package.json | 4 +- src/lib/components/filters/content.svelte | 69 ++++++++++++++----- src/lib/helpers/types.ts | 11 ++- .../collection-[collection]/+page.svelte | 3 +- .../collection-[collection]/table.svelte | 3 +- 6 files changed, 76 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index f95e7ad52..bbff82957 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,8 @@ "name": "@appwrite/console", "dependencies": { "@appwrite.io/console": "^0.6.0-rc.9", - "@appwrite.io/pink": "0.2.0", - "@appwrite.io/pink-icons": "0.2.0", + "@appwrite.io/pink": "0.3.0", + "@appwrite.io/pink-icons": "0.3.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", @@ -168,19 +168,19 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.2.0.tgz", - "integrity": "sha512-ni6O/yPiWkCYQ68PNcbmus6QrPpIEl7xmzKHU2dkV2L19RVio8thtBtT9ckJJ8uBMGsczASWs0fUqOxIvBmtNw==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.3.0.tgz", + "integrity": "sha512-VTYCfcEGnqScwGta7ort/qoKN0Gnyq2h/ROYcp9meEFSCjYBWMgWZWbwSSXsL8vwwxnN9aTh1sO5mJX0zHAPVg==", "dependencies": { - "@appwrite.io/pink-icons": "0.2.0", + "@appwrite.io/pink-icons": "0.3.0", "normalize.css": "^8.0.1", "the-new-css-reset": "^1.11.2" } }, "node_modules/@appwrite.io/pink-icons": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.2.0.tgz", - "integrity": "sha512-wThBUGdvpwT0q2fcUapiugfBiB4RFDvTlW6p+U7Dol61mmCpNteFSIoBPiPJzN5015n1v4UEWL/rdOia4CWdBQ==" + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.3.0.tgz", + "integrity": "sha512-Jus3jsWMidne02/mqXbRtLFsuiYQiB3fjZ2ip8auqwhvk65yzGtodPiTPA8Us1fD2vaRlNx/jER5MK0XmqXKxg==" }, "node_modules/@babel/code-frame": { "version": "7.23.5", diff --git a/package.json b/package.json index 406ce372f..8f0dd8a7e 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@appwrite.io/console": "^0.6.0-rc.9", - "@appwrite.io/pink": "0.2.0", - "@appwrite.io/pink-icons": "0.2.0", + "@appwrite.io/pink": "0.3.0", + "@appwrite.io/pink-icons": "0.3.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 450aa6375..11eb886bc 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -1,7 +1,12 @@
@@ -194,12 +214,16 @@
    {#each $tags as tag (tag)} diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index aa027c74f..13dc1f9b7 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -6,8 +6,11 @@ import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; export type Operator = { - toTag: (attribute: string, input?: string | number) => string; - toQuery: (attribute: string, input?: string | number) => string; + toTag: ( + attribute: string, + input?: string | number | string[] + ) => string | { tag: string; value: string }; + toQuery: (attribute: string, input?: string | number | string[]) => string; types: ColumnType[]; hideInput?: boolean; }; @@ -22,13 +25,13 @@ export function queryParamToMap(queryParam: string) { return new Map(queries); } -function initQueries(initialValue = new Map()) { +function initQueries(initialValue = new Map()) { const queries = writable(initialValue); type AddFilterArgs = { operator: Operator; column: Column; - value: string | number; + value: string | number | string[]; }; function addFilter({ column, operator, value }: AddFilterArgs) { From cac04c22ef143f4ae15c377a861655e5ef33f2a4 Mon Sep 17 00:00:00 2001 From: Arman Date: Fri, 9 Feb 2024 16:05:04 +0100 Subject: [PATCH 04/22] fix types? --- src/lib/components/filters/content.svelte | 44 ++++++++++++++--------- src/lib/components/filters/store.ts | 24 +++++++++---- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 86a6020b9..e7769c667 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -9,7 +9,7 @@ } from '$lib/elements/forms'; import { Query } from '@appwrite.io/console'; import { createEventDispatcher } from 'svelte'; - import { tags, type Operator, queries } from './store'; + import { tags, type Operator, queries, isTypeTagValue } from './store'; import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; @@ -23,7 +23,7 @@ let columnId: string | null = null; $: column = $columns.find((c) => c.id === columnId) as Column; - let arrayValues = []; + let arrayValues: string[] = []; dispatch('apply', { applied: $tags.length }); @@ -213,20 +213,32 @@
      {#each $tags as tag (tag)} - + {#if isTypeTagValue(tag)} + + {:else} + + {/if} {/each}
diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 13dc1f9b7..48c6ffe86 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -5,17 +5,27 @@ import { page } from '$app/stores'; import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; +type TagValue = { + tag: string; + value: string | number | string[]; +}; + +export function isTypeTagValue(obj: any): obj is TagValue { + return ( + obj && + typeof obj.tag === 'string' && + (typeof obj.value === 'string' || typeof obj.value === 'number') + ); +} + export type Operator = { - toTag: ( - attribute: string, - input?: string | number | string[] - ) => string | { tag: string; value: string }; + toTag: (attribute: string, input?: string | number | string[]) => string | TagValue; toQuery: (attribute: string, input?: string | number | string[]) => string; types: ColumnType[]; hideInput?: boolean; }; -export function mapToQueryParams(map: Map) { +export function mapToQueryParams(map: Map) { return encodeURIComponent(JSON.stringify(Array.from(map.entries()))); } @@ -25,7 +35,7 @@ export function queryParamToMap(queryParam: string) { return new Map(queries); } -function initQueries(initialValue = new Map()) { +function initQueries(initialValue = new Map()) { const queries = writable(initialValue); type AddFilterArgs = { @@ -41,7 +51,7 @@ function initQueries(initialValue = new Map { map.delete(tag); return map; From 8d0e901e42c1fbfd39f00b8fc56c30642bf1650e Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 15 Feb 2024 17:58:39 +0100 Subject: [PATCH 05/22] fix: query names --- src/lib/components/filters/content.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index e7769c667..973802398 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -68,13 +68,13 @@ toTag: (attribute, input) => `**${attribute}** not equal to **${input}**`, types: ['string', 'integer', 'double', 'boolean'] }, - 'not null': { + 'is not null': { toQuery: Query.isNotNull, toTag: (attribute) => `**${attribute}** is not null`, types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], hideInput: true }, - null: { + 'is null': { toQuery: Query.isNull, toTag: (attribute) => `**${attribute}** is null`, types: ['string', 'integer', 'double', 'boolean', 'datetime', 'relationship'], @@ -223,7 +223,7 @@ queries.removeFilter(tag); }}> - {tag.tag} + {JSON.stringify(tag.tag)} From d92eec83ee96b16b0e2a042f724eef68b13efb26 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 28 Feb 2024 16:37:42 +0100 Subject: [PATCH 06/22] fix: logic --- src/lib/components/filters/store.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 48c6ffe86..fcf5fc88c 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -14,7 +14,7 @@ export function isTypeTagValue(obj: any): obj is TagValue { return ( obj && typeof obj.tag === 'string' && - (typeof obj.value === 'string' || typeof obj.value === 'number') + (typeof obj.value === 'string' || typeof obj.value === 'number' || Array.isArray(obj.value)) ); } From dc664c5ea67e44a07d767016681ec1d990f87f57 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 5 Mar 2024 16:28:19 +0100 Subject: [PATCH 07/22] feat: add enum detection --- src/lib/components/filters/content.svelte | 37 ++++++++++--------- src/lib/helpers/types.ts | 2 + .../collection-[collection]/+page.svelte | 4 +- .../collection-[collection]/table.svelte | 5 ++- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 973802398..7e31df2ae 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -13,6 +13,7 @@ import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; + import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; export let columns: Writable; @@ -83,6 +84,7 @@ contains: { toQuery: Query.contains, toTag: (attribute, input) => { + console.log(attribute, input); return { value: input, tag: `**${attribute}** contains **${Array.isArray(input) ? formatArray(input) : input}**` @@ -110,6 +112,7 @@ /* eslint @typescript-eslint/no-explicit-any: 'off' */ let value: any = null; + let search: string; $: { columnId; value = column?.array ? [] : null; @@ -141,8 +144,6 @@ } $: isDisabled = !operator; - - $: console.log($tags);
@@ -168,26 +169,26 @@ {#if column && operator && !operator?.hideInput} {#if column?.array} - {#if column.type === 'enum'} - test - - {:else} - - {/if} + bind:tags={arrayValues} + placeholder="Enter values" /> {:else}
    - {#if column.type === 'integer' || column.type === 'double'} + {#if column.format === 'enum'} + ({ label: value, value }))} + label="Value" + showLabel={false} + interactiveOutput /> + {:else if column.type === 'integer' || column.type === 'double'} {:else if column.type === 'boolean'} >( diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte index fd9f05552..7b5de902a 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/+page.svelte @@ -29,7 +29,9 @@ title: attribute.key, type: attribute.type as ColumnType, show: selected?.includes(attribute.key) ?? true, - array: attribute?.array + array: attribute?.array, + format: 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null, + elements: 'elements' in attribute ? attribute.elements : null })) ); diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte index b2d8bcb48..b888be29d 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/table.svelte @@ -92,7 +92,10 @@ title: attribute.key, type: attribute.type as ColumnType, show: selected?.includes(attribute.key) ?? true, - array: attribute?.array + array: attribute?.array, + format: + 'format' in attribute && attribute?.format === 'enum' ? attribute.format : null, + elements: 'elements' in attribute ? attribute.elements : null })) ); } From 765d1c397e93dc42c065dfc43166a6090ae585a1 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 5 Mar 2024 17:44:27 +0100 Subject: [PATCH 08/22] Add onMount hook and fix console logs --- src/lib/components/filters/content.svelte | 18 ++++++++++-------- src/lib/components/filters/store.ts | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 7e31df2ae..02c9abab6 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -8,7 +8,7 @@ FormList } from '$lib/elements/forms'; import { Query } from '@appwrite.io/console'; - import { createEventDispatcher } from 'svelte'; + import { createEventDispatcher, onMount } from 'svelte'; import { tags, type Operator, queries, isTypeTagValue } from './store'; import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; @@ -84,7 +84,7 @@ contains: { toQuery: Query.contains, toTag: (attribute, input) => { - console.log(attribute, input); + console.table({ attribute, input, tp: typeof input }); return { value: input, tag: `**${attribute}** contains **${Array.isArray(input) ? formatArray(input) : input}**` @@ -108,15 +108,14 @@ operatorKey = null; } + let search: string; // We cast to any to not cause type errors in the input components /* eslint @typescript-eslint/no-explicit-any: 'off' */ let value: any = null; - let search: string; - $: { - columnId; + onMount(() => { value = column?.array ? [] : null; - } + }); // This Map is keyed by tags, and has a query as the value function addFilter() { @@ -144,6 +143,9 @@ } $: isDisabled = !operator; + + $: console.log(value, typeof value); + // $: console.table({ value, tp: typeof value, arrayValues });
    @@ -224,7 +226,7 @@ queries.removeFilter(tag); }}> - {JSON.stringify(tag.tag)} + asd {JSON.stringify(tag.tag)} @@ -235,7 +237,7 @@ queries.removeFilter(tag); }}> - {tag} + test{tag} diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index fcf5fc88c..04ce58485 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -11,6 +11,7 @@ type TagValue = { }; export function isTypeTagValue(obj: any): obj is TagValue { + if (typeof obj === 'string') return false; return ( obj && typeof obj.tag === 'string' && From 6757f5623f3f9f9863beb567bad8f1ba40557cee Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 10:43:00 +0100 Subject: [PATCH 09/22] fix: tag content --- src/lib/components/filters/content.svelte | 33 +++++++++++++++-------- src/lib/components/filters/store.ts | 11 +------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 02c9abab6..bc7d00283 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -9,7 +9,7 @@ } from '$lib/elements/forms'; import { Query } from '@appwrite.io/console'; import { createEventDispatcher, onMount } from 'svelte'; - import { tags, type Operator, queries, isTypeTagValue } from './store'; + import { tags, type Operator, queries, type TagValue } from './store'; import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; @@ -84,11 +84,14 @@ contains: { toQuery: Query.contains, toTag: (attribute, input) => { - console.table({ attribute, input, tp: typeof input }); - return { - value: input, - tag: `**${attribute}** contains **${Array.isArray(input) ? formatArray(input) : input}**` - }; + if (Array.isArray(input) && input.length > 2) { + return { + value: input, + tag: `**${attribute}** contains **${formatArray(input)}** ` + }; + } else { + return `**${attribute}** contains **${input}**`; + } }, types: ['string', 'integer', 'double', 'boolean', 'datetime', 'enum'] } @@ -142,10 +145,18 @@ } } - $: isDisabled = !operator; + function isTypeTagValue(obj: any): obj is TagValue { + if (typeof obj === 'string') return false; + return ( + obj && + typeof obj.tag === 'string' && + (typeof obj.value === 'string' || + typeof obj.value === 'number' || + Array.isArray(obj.value)) + ); + } - $: console.log(value, typeof value); - // $: console.table({ value, tp: typeof value, arrayValues }); + $: isDisabled = !operator;
    @@ -226,7 +237,7 @@ queries.removeFilter(tag); }}> - asd {JSON.stringify(tag.tag)} + {tag.tag} @@ -237,7 +248,7 @@ queries.removeFilter(tag); }}> - test{tag} + {tag} diff --git a/src/lib/components/filters/store.ts b/src/lib/components/filters/store.ts index 04ce58485..64fe6e2ad 100644 --- a/src/lib/components/filters/store.ts +++ b/src/lib/components/filters/store.ts @@ -5,20 +5,11 @@ import { page } from '$app/stores'; import deepEqual from 'deep-equal'; import type { Column, ColumnType } from '$lib/helpers/types'; -type TagValue = { +export type TagValue = { tag: string; value: string | number | string[]; }; -export function isTypeTagValue(obj: any): obj is TagValue { - if (typeof obj === 'string') return false; - return ( - obj && - typeof obj.tag === 'string' && - (typeof obj.value === 'string' || typeof obj.value === 'number' || Array.isArray(obj.value)) - ); -} - export type Operator = { toTag: (attribute: string, input?: string | number | string[]) => string | TagValue; toQuery: (attribute: string, input?: string | number | string[]) => string; From 078f519bd3a6ebf6c62c96e6f038a376b07e0e25 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 12:17:26 +0100 Subject: [PATCH 10/22] wip: enums --- src/lib/components/filters/content.svelte | 49 +++++++++++++++----- src/lib/elements/index.ts | 1 + src/lib/elements/selectSearchCheckbox.svelte | 30 ++++++++++++ 3 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 src/lib/elements/selectSearchCheckbox.svelte diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index bc7d00283..4c952dae1 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -14,6 +14,7 @@ import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; + import { SelectSearchCheckbox, SelectSearchItem } from '$lib/elements'; export let columns: Writable; @@ -182,25 +183,51 @@ {#if column && operator && !operator?.hideInput} {#if column?.array} - - - {:else} -
      {#if column.format === 'enum'} ({ label: value, value }))} + options={column?.elements?.map((value) => ({ + label: value, + value, + data: arrayValues + }))} label="Value" showLabel={false} - interactiveOutput /> + interactiveOutput + let:option={o}> + + {o.label} + + + + + {o.label} + + + + + {:else} + + {/if} + + {:else} +
        + {#if column.format === 'enum'} + ({ label: value, value }))} + label="Value" + showLabel={false} /> {:else if column.type === 'integer' || column.type === 'double'} {:else if column.type === 'boolean'} diff --git a/src/lib/elements/index.ts b/src/lib/elements/index.ts index dabf2f27b..172bfe149 100644 --- a/src/lib/elements/index.ts +++ b/src/lib/elements/index.ts @@ -1,3 +1,4 @@ export { default as Pill } from './pill.svelte'; export { default as SelectSearchItem } from './selectSearchItem.svelte'; export { default as Flag } from './flag.svelte'; +export { default as SelectSearchCheckbox } from './selectSearchCheckbox.svelte'; diff --git a/src/lib/elements/selectSearchCheckbox.svelte b/src/lib/elements/selectSearchCheckbox.svelte new file mode 100644 index 000000000..2740c2599 --- /dev/null +++ b/src/lib/elements/selectSearchCheckbox.svelte @@ -0,0 +1,30 @@ + + +
        + + + + + {#if data?.length} + e ?? 'null').join(' | ') + }}> + {#each data as item, i} + {#if i} + | + {/if} + {item} + {/each} + + {/if} +
        From c6479687be3e33532705b23032fddf500f65a619 Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 17:21:33 +0100 Subject: [PATCH 11/22] wip --- .../elements/forms/inputSelectCheckbox.svelte | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/lib/elements/forms/inputSelectCheckbox.svelte diff --git a/src/lib/elements/forms/inputSelectCheckbox.svelte b/src/lib/elements/forms/inputSelectCheckbox.svelte new file mode 100644 index 000000000..635c7d2fb --- /dev/null +++ b/src/lib/elements/forms/inputSelectCheckbox.svelte @@ -0,0 +1,52 @@ + + + +
        +
        +
          + {#each tags as tag} +
        • +
          + {tag} +
          +
        • + {/each} +
        +
        + +
        + +
        + + + {#each options as option, i} +
      • + +
      • + {:else} +
      • + There are no {name} that match your search +
      • + {/each} +
        + From bc33742337563d6a0235d26232db51178e26873f Mon Sep 17 00:00:00 2001 From: Arman Date: Wed, 6 Mar 2024 18:08:07 +0100 Subject: [PATCH 12/22] feat: input select checkbox --- src/lib/elements/forms/inputSelectCheckbox.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/forms/inputSelectCheckbox.svelte b/src/lib/elements/forms/inputSelectCheckbox.svelte index 635c7d2fb..4f57ad8af 100644 --- a/src/lib/elements/forms/inputSelectCheckbox.svelte +++ b/src/lib/elements/forms/inputSelectCheckbox.svelte @@ -9,7 +9,7 @@ -
        +
          {#each tags as tag} @@ -22,7 +22,7 @@
        -
        + From bc9672ec257eec764ab97f492646f71b949dac16 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 7 Mar 2024 10:45:55 +0100 Subject: [PATCH 13/22] fix: input select block --- package-lock.json | 18 +++---- package.json | 4 +- src/lib/elements/forms/index.ts | 1 + .../elements/forms/inputSelectBlock.svelte | 51 ++++++++++++++++++ .../elements/forms/inputSelectCheckbox.svelte | 52 ------------------- 5 files changed, 63 insertions(+), 63 deletions(-) create mode 100644 src/lib/elements/forms/inputSelectBlock.svelte delete mode 100644 src/lib/elements/forms/inputSelectCheckbox.svelte diff --git a/package-lock.json b/package-lock.json index f05b04a9f..605403221 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,8 @@ "name": "@appwrite/console", "dependencies": { "@appwrite.io/console": "^0.6.0-rc.17", - "@appwrite.io/pink": "0.4.0", - "@appwrite.io/pink-icons": "0.4.0", + "@appwrite.io/pink": "0.8.0", + "@appwrite.io/pink-icons": "0.8.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", @@ -167,19 +167,19 @@ } }, "node_modules/@appwrite.io/pink": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.4.0.tgz", - "integrity": "sha512-48g2MQIFaEXPXobJ77wJK73YRUkpUZSAkRNa3XJhtC0N2WSTXD3poXBAVYb2QfjGW4e5U1tM/WYC0ZQMtjEzlQ==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.8.0.tgz", + "integrity": "sha512-UZKwkUtAo2N0JiTiKDPWC8GHubTF2905DOzuCGl716fYua2gNIlS8D+HA/wd15qyRjZlgQh4MtVUAdHI8GLf8g==", "dependencies": { - "@appwrite.io/pink-icons": "0.4.0", + "@appwrite.io/pink-icons": "0.8.0", "normalize.css": "^8.0.1", "the-new-css-reset": "^1.11.2" } }, "node_modules/@appwrite.io/pink-icons": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.4.0.tgz", - "integrity": "sha512-o1r101GRK72nBbeVL76H7NIwucrW8+vbzs41AMBPbnK+uAGhNb9ui5Na7gi6NtnBxHYnPDECg93bZhoLYlQ6XA==" + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@appwrite.io/pink-icons/-/pink-icons-0.8.0.tgz", + "integrity": "sha512-UQd4mXOohGggXHNhIlYt4u2NLB/ubI6pvkdllrBQnHZEb7JL2iklff8Ne5moW8F9DeXLBt/ZQLRe240lvVjm6Q==" }, "node_modules/@babel/code-frame": { "version": "7.23.5", diff --git a/package.json b/package.json index 1afb8d285..a4a64d2d1 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ }, "dependencies": { "@appwrite.io/console": "^0.6.0-rc.17", - "@appwrite.io/pink": "0.4.0", - "@appwrite.io/pink-icons": "0.4.0", + "@appwrite.io/pink": "0.8.0", + "@appwrite.io/pink-icons": "0.8.0", "@popperjs/core": "^2.11.8", "@sentry/svelte": "^7.66.0", "@sentry/tracing": "^7.66.0", diff --git a/src/lib/elements/forms/index.ts b/src/lib/elements/forms/index.ts index 8d022c660..98a398347 100644 --- a/src/lib/elements/forms/index.ts +++ b/src/lib/elements/forms/index.ts @@ -31,3 +31,4 @@ export { default as InputDate } from './inputDate.svelte'; export { default as InputDateRange } from './inputDateRange.svelte'; export { default as InputTime } from './inputTime.svelte'; export { default as InputDigits } from './inputDigits.svelte'; +export { default as InputSelectBlock } from './inputSelectBlock.svelte'; diff --git a/src/lib/elements/forms/inputSelectBlock.svelte b/src/lib/elements/forms/inputSelectBlock.svelte new file mode 100644 index 000000000..63fc33cc8 --- /dev/null +++ b/src/lib/elements/forms/inputSelectBlock.svelte @@ -0,0 +1,51 @@ + + +
        +
        +
          + {#each tags as tag} +
        • +
          + {tag} +
          +
        • + {/each} +
        +
        + + + +
        + +
        + {#each options as option, i} +
      • + test + +
      • + {:else} +
      • + There are no {name} that match your search +
      • + {/each} +
        diff --git a/src/lib/elements/forms/inputSelectCheckbox.svelte b/src/lib/elements/forms/inputSelectCheckbox.svelte deleted file mode 100644 index 4f57ad8af..000000000 --- a/src/lib/elements/forms/inputSelectCheckbox.svelte +++ /dev/null @@ -1,52 +0,0 @@ - - - -
        -
        -
          - {#each tags as tag} -
        • -
          - {tag} -
          -
        • - {/each} -
        -
        - - - -
        - - - {#each options as option, i} -
      • - -
      • - {:else} -
      • - There are no {name} that match your search -
      • - {/each} -
        -
        From 28604068500b5e540fac1bf9dfae77b6cff223ac Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 7 Mar 2024 11:51:37 +0100 Subject: [PATCH 14/22] more work on the select checkbox --- src/lib/components/filters/content.svelte | 27 +++------- src/lib/elements/forms/index.ts | 2 +- .../elements/forms/inputSelectBlock.svelte | 51 ------------------- .../elements/forms/inputSelectCheckbox.svelte | 45 ++++++++++++++++ 4 files changed, 53 insertions(+), 72 deletions(-) delete mode 100644 src/lib/elements/forms/inputSelectBlock.svelte create mode 100644 src/lib/elements/forms/inputSelectCheckbox.svelte diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 4c952dae1..e62a9924d 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -5,7 +5,8 @@ InputSelect, InputText, InputTags, - FormList + FormList, + InputSelectCheckbox } from '$lib/elements/forms'; import { Query } from '@appwrite.io/console'; import { createEventDispatcher, onMount } from 'svelte'; @@ -184,31 +185,17 @@ {#if column?.array} {#if column.format === 'enum'} - ({ label: value, value, data: arrayValues - }))} - label="Value" - showLabel={false} - interactiveOutput - let:option={o}> - - {o.label} - - - - - {o.label} - - - - + }))}> + {:else} - import { DropList } from '$lib/components'; - - export let tags: string[] = []; - export let placeholder: string; - export let options: { value: string | boolean | number; label: string }[] = []; - - let show = false; - - -
        -
        -
          - {#each tags as tag} -
        • -
          - {tag} -
          -
        • - {/each} -
        -
        - - - -
        - -
        - {#each options as option, i} -
      • - test - -
      • - {:else} -
      • - There are no {name} that match your search -
      • - {/each} -
        diff --git a/src/lib/elements/forms/inputSelectCheckbox.svelte b/src/lib/elements/forms/inputSelectCheckbox.svelte new file mode 100644 index 000000000..a79e3cdce --- /dev/null +++ b/src/lib/elements/forms/inputSelectCheckbox.svelte @@ -0,0 +1,45 @@ + + + + + + + {#each options as option, i} + + {:else} +
      • + There are no {name} that match your search +
      • + {/each} +
        +
        From c8e38e0fd4935eb42477f1111b7d72fe84922468 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 7 Mar 2024 16:28:33 +0100 Subject: [PATCH 15/22] wip more work on select search --- src/lib/components/filters/content.svelte | 8 +++++++- .../elements/forms/inputSelectCheckbox.svelte | 8 ++++++-- src/lib/elements/selectSearchCheckbox.svelte | 18 +----------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index e62a9924d..3b8d56eca 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -194,7 +194,13 @@ label: value, value, data: arrayValues - }))}> + }))} + let:option={o}> + + {o.label} + {:else} option.label.toLowerCase().includes(search.toLowerCase())) + : options; - {#each options as option, i} + {#each filteredOptions as option} {:else}
      • diff --git a/src/lib/elements/selectSearchCheckbox.svelte b/src/lib/elements/selectSearchCheckbox.svelte index 2740c2599..b2f5b055f 100644 --- a/src/lib/elements/selectSearchCheckbox.svelte +++ b/src/lib/elements/selectSearchCheckbox.svelte @@ -1,7 +1,5 @@ @@ -13,18 +11,4 @@ - {#if data?.length} - e ?? 'null').join(' | ') - }}> - {#each data as item, i} - {#if i} - | - {/if} - {item} - {/each} - - {/if}
      • From 86c7c22e3cf5f1cfc65162eba8c6e752c1c1ce96 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 7 Mar 2024 19:30:12 +0100 Subject: [PATCH 16/22] feat: more work on input selec checkbox --- src/lib/components/dropList.svelte | 2 + src/lib/components/filters/content.svelte | 15 ++---- .../elements/forms/inputSelectCheckbox.svelte | 51 ++++++++++++++++--- src/lib/elements/selectSearchCheckbox.svelte | 18 +++---- 4 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/lib/components/dropList.svelte b/src/lib/components/dropList.svelte index c6ad97dd1..0c802cffd 100644 --- a/src/lib/components/dropList.svelte +++ b/src/lib/components/dropList.svelte @@ -13,6 +13,7 @@ export let fullWidth = false; export let wrapperFullWidth = false; export let position: 'relative' | 'static' = 'relative'; + export let noMaxWidthList = false; {#if $$slots.list}
        diff --git a/src/lib/components/filters/content.svelte b/src/lib/components/filters/content.svelte index 3b8d56eca..130f80dde 100644 --- a/src/lib/components/filters/content.svelte +++ b/src/lib/components/filters/content.svelte @@ -14,8 +14,7 @@ import type { Column } from '$lib/helpers/types'; import type { Writable } from 'svelte/store'; import { tooltip } from '$lib/actions/tooltip'; - import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte'; - import { SelectSearchCheckbox, SelectSearchItem } from '$lib/elements'; + import { SelectSearchCheckbox } from '$lib/elements'; export let columns: Writable; @@ -113,7 +112,6 @@ operatorKey = null; } - let search: string; // We cast to any to not cause type errors in the input components /* eslint @typescript-eslint/no-explicit-any: 'off' */ let value: any = null; @@ -188,19 +186,12 @@ ({ label: value, value, - data: arrayValues - }))} - let:option={o}> - - {o.label} - + checked: arrayValues.includes(value) + }))}> {:else} import { DropList } from '$lib/components'; + import { SelectSearchCheckbox } from '..'; + + type Option = { + value: string; + label: string; + checked: boolean; + }; export let name: string; - export let search = ''; export let tags: string[] = []; export let placeholder: string; - export let options: { value: string | boolean | number; label: string }[] = []; + export let options: Option[] = []; + let search = ''; + let input: HTMLInputElement; let show = false; + function addValue(option: Option) { + let tag = option.value.trim(); + if (tag.length === 0 || tags.includes(tag)) return; + + tags = [...tags, tag]; + option.checked = true; + clearSearch(); + } + + function removeValue(option: Option) { + tags = tags.filter((tag) => tag !== option.value); + option.checked = false; + } + + function clearSearch() { + search = ''; + input.value = ''; + } + $: filteredOptions = search ? options.filter((option) => option.label.toLowerCase().includes(search.toLowerCase())) : options; + + //TODO: Debounce search and open the droplist when the user starts typing - +
    - + - {#each filteredOptions as option} - + {#each filteredOptions as option (option.value + option.checked)} + (option?.checked ? removeValue(option) : addValue(option))} + bind:value={option.checked}> + {option.label} + {:else}
  • There are no {name} that match your search diff --git a/src/lib/elements/selectSearchCheckbox.svelte b/src/lib/elements/selectSearchCheckbox.svelte index b2f5b055f..d1d592678 100644 --- a/src/lib/elements/selectSearchCheckbox.svelte +++ b/src/lib/elements/selectSearchCheckbox.svelte @@ -1,14 +1,14 @@ -
    - - +
  • +
  • + + From 4def7f053e9037e891907671b74c459e5de9ebc1 Mon Sep 17 00:00:00 2001 From: Arman Date: Thu, 7 Mar 2024 19:54:49 +0100 Subject: [PATCH 17/22] wip: small design fixes --- src/lib/elements/forms/inputSelectCheckbox.svelte | 5 ++++- src/lib/elements/selectSearchCheckbox.svelte | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/elements/forms/inputSelectCheckbox.svelte b/src/lib/elements/forms/inputSelectCheckbox.svelte index 1fc107842..8b82b0221 100644 --- a/src/lib/elements/forms/inputSelectCheckbox.svelte +++ b/src/lib/elements/forms/inputSelectCheckbox.svelte @@ -1,5 +1,6 @@
    @@ -43,12 +53,13 @@

    Apply filter rules to refine the table view

    (applied = e.detail.applied)} on:clear={() => (applied = 0)} />
    - +
    @@ -77,7 +88,7 @@ on:apply={(e) => (applied = e.detail.applied)} on:clear={() => (applied = 0)} /> - +