diff --git a/package-lock.json b/package-lock.json
index 4b75ed1bd..37d66f466 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,7 +8,7 @@
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@appwrite.io/console": "0.1.0-preview-0.1",
- "@appwrite.io/pink": "^0.0.6-rc.6",
+ "@appwrite.io/pink": "^0.0.6-rc.7",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
@@ -155,9 +155,9 @@
}
},
"node_modules/@appwrite.io/pink": {
- "version": "0.0.6-rc.6",
- "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.6.tgz",
- "integrity": "sha512-mSOUI2UxRqO3MS4ZXz9bdyAt0VFGRhOwWYGXw+oFfYPjmu6GSKnLEQwjF37DeuArEGRNriTiOFrKqXO0HW0odA==",
+ "version": "0.0.6-rc.7",
+ "resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.7.tgz",
+ "integrity": "sha512-3I+DG4HiysIRJF9ksr+aWMmazUtZ6KrivISu3k+pIX7MjyDhN5la6LVNKgU3d8WWstbHCHoEq5+FYyjsYWWIpA==",
"dependencies": {
"@appwrite.io/pink-icons": "*",
"normalize.css": "^8.0.1",
diff --git a/package.json b/package.json
index a021b5e8f..4790cb235 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,7 @@
"dependencies": {
"@analytics/google-analytics": "^1.0.5",
"@appwrite.io/console": "0.1.0-preview-0.1",
- "@appwrite.io/pink": "^0.0.6-rc.6",
+ "@appwrite.io/pink": "^0.0.6-rc.7",
"@popperjs/core": "^2.11.6",
"@sentry/svelte": "^7.44.2",
"@sentry/tracing": "^7.44.2",
diff --git a/src/lib/components/clickableList.svelte b/src/lib/components/clickableList.svelte
new file mode 100644
index 000000000..733607b9b
--- /dev/null
+++ b/src/lib/components/clickableList.svelte
@@ -0,0 +1,3 @@
+
diff --git a/src/lib/components/clickableListItem.svelte b/src/lib/components/clickableListItem.svelte
new file mode 100644
index 000000000..00308d47a
--- /dev/null
+++ b/src/lib/components/clickableListItem.svelte
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts
index 5a9db65b2..6927dd1e5 100644
--- a/src/lib/components/index.ts
+++ b/src/lib/components/index.ts
@@ -51,3 +51,5 @@ export { default as ViewSelector } from './viewSelector.svelte';
export { default as LabelCard } from './labelCard.svelte';
export { default as Limit } from './limit.svelte';
export { default as PaginationWithLimit } from './paginationWithLimit.svelte';
+export { default as ClickableList } from './clickableList.svelte';
+export { default as ClickableListItem } from './clickableListItem.svelte';
diff --git a/src/lib/elements/forms/inputSelectSearch.svelte b/src/lib/elements/forms/inputSelectSearch.svelte
index b30bbd7c2..954ab2d38 100644
--- a/src/lib/elements/forms/inputSelectSearch.svelte
+++ b/src/lib/elements/forms/inputSelectSearch.svelte
@@ -3,6 +3,14 @@
import { onMount } from 'svelte';
import { Label } from '.';
+ type Option = $$Generic<{
+ value: string | boolean | number | Record;
+ label: string;
+ data?: string[];
+ }>;
+ type OptionArray = Option[];
+
+ export let options: OptionArray;
export let id: string;
export let label: string;
export let name = 'elements';
@@ -12,18 +20,13 @@
export let required = false;
export let disabled = false;
export let autofocus = false;
- export let debounce = 250;
- export let options: {
- value: string | boolean | number;
- label: string;
- }[];
// Input value
- export let search: string = null;
+ export let search = '';
// The actual selected value
- export let value: string | number | boolean;
+ export let value: Option['value'];
+ $: selectedOption = options.find((option) => option.value === value);
let element: HTMLInputElement;
- let timer: ReturnType;
let hasFocus = false;
let selected: number = null;
@@ -37,13 +40,8 @@
}
});
- function handleInput(event: Event) {
+ function handleInput() {
hasFocus = true;
- clearTimeout(timer);
- timer = setTimeout(() => {
- const target = event.target as HTMLInputElement;
- search = target.value;
- }, debounce);
}
function handleKeydown(event: KeyboardEvent) {
@@ -70,14 +68,27 @@
case 'Enter':
if (selected !== null) {
event.preventDefault();
- value = options[selected].value;
- search = options[selected].label;
- hasFocus = false;
+ selectOption(options[selected]);
}
break;
}
}
+ function selectOption(option: Option) {
+ value = option.value;
+ search = option.label;
+ // It's not working without this line.
+ element.value = search;
+ hasFocus = false;
+ }
+
+ function clearOption() {
+ value = null;
+ search = '';
+ element.value = search;
+ hasFocus = false;
+ }
+
$: showClearBtn = (hasFocus && search) || value;
@@ -96,19 +107,25 @@
-
-
(hasFocus = true)}
- on:click={() => (hasFocus = true)}
- on:input={handleInput}
- on:keydown={handleKeydown} />
+
+ {#if $$slots.default && selectedOption}
+
+ {:else}
+
(hasFocus = true)}
+ on:click={() => (hasFocus = true)}
+ on:input={handleInput}
+ on:keydown={handleKeydown} />
+ {/if}
{#if showClearBtn}
@@ -116,10 +133,7 @@
class="options-list-button"
aria-label="clear field"
type="button"
- on:click|preventDefault={() => {
- search = '';
- value = null;
- }}>
+ on:click|preventDefault={clearOption}>
{/if}
@@ -140,11 +154,11 @@
class:is-selected={selected === i}
type="button"
on:click|preventDefault={() => {
- value = option.value;
- search = option.label;
- hasFocus = false;
+ selectOption(option);
}}>
-
{option.label}
+
+ {option.label}
+
{:else}
diff --git a/src/lib/elements/index.ts b/src/lib/elements/index.ts
index 2ebcd3892..ffd1477bb 100644
--- a/src/lib/elements/index.ts
+++ b/src/lib/elements/index.ts
@@ -1 +1,2 @@
export { default as Pill } from './pill.svelte';
+export { default as SelectSearchItem } from './selectSearchItem.svelte';
diff --git a/src/lib/elements/selectSearchItem.svelte b/src/lib/elements/selectSearchItem.svelte
new file mode 100644
index 000000000..ce13a3355
--- /dev/null
+++ b/src/lib/elements/selectSearchItem.svelte
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ {#if data.length}
+ e ?? e?.toString()).join(' | ')
+ }}>
+ {#each data as item, i}
+ {#if i}
+ |
+ {/if}
+ {item}
+ {/each}
+
+ {/if}
+
diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte
index b323d76c1..96f5ecf40 100644
--- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte
+++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte
@@ -44,6 +44,7 @@
import arrowOne from './arrow-one.svg';
import arrowTwo from './arrow-two.svg';
import { camelize } from '$lib/helpers/string';
+ import { SelectSearchItem } from '$lib/elements';
// Props
export let data: Partial
;
@@ -141,7 +142,12 @@
required
placeholder="Select a collection"
disabled={editing}
- options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} />
+ options={collections?.map((n) => ({ value: n.$id, label: n.$id, data: [n.name] })) ?? []}
+ let:option={o}>
+
+ {o.label}
+
+
{#if data?.relatedCollection}
diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte
index 6f5cb72b7..d4a675358 100644
--- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte
+++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/document-[document]/attributes/relationship.svelte
@@ -1,5 +1,6 @@
{#if isArray}
@@ -83,16 +85,9 @@
{/each}
+
{#if showInput}
({
- value: n.$id,
- label: n.$id
- })) ?? []} />
+ options={documentList?.documents?.map((n) => {
+ const data = displayNames
+ .filter((name) => name !== '$id')
+ .map((name) => n?.[name]);
+ return {
+ value: { label: n.$id, data },
+ label: n.$id,
+ data
+ };
+ }) ?? []}
+ let:option={o}>
+
+ {o.label}
+
+