@poirazis/supercomponents-shared 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/index.js +30635 -0
- package/dist/index.umd.cjs +12 -0
- package/dist/style.css +1 -0
- package/package.json +117 -0
- package/src/index.js +29 -0
- package/src/index.ts +31 -0
- package/src/lib/Actions/autoresize_textarea.js +14 -0
- package/src/lib/Actions/click_outside.js +80 -0
- package/src/lib/Actions/index.js +4 -0
- package/src/lib/Actions/position_dropdown.js +129 -0
- package/src/lib/SuperButton/SuperButton.svelte +341 -0
- package/src/lib/SuperFieldLabel/SuperFieldLabel.svelte +91 -0
- package/src/lib/SuperFieldsCommon.css +54 -0
- package/src/lib/SuperList/SuperList.svelte +308 -0
- package/src/lib/SuperList/drag-handle.svelte +31 -0
- package/src/lib/SuperPopover/SuperPopover.svelte +134 -0
- package/src/lib/SuperTable/SuperTable.css +410 -0
- package/src/lib/SuperTable/SuperTable.svelte +1332 -0
- package/src/lib/SuperTable/constants.js +85 -0
- package/src/lib/SuperTable/controls/ColumnsSection.svelte +34 -0
- package/src/lib/SuperTable/controls/ControlSection.svelte +3 -0
- package/src/lib/SuperTable/controls/RowButtonsColumn.svelte +169 -0
- package/src/lib/SuperTable/controls/SelectionColumn.svelte +174 -0
- package/src/lib/SuperTable/controls/SuperTableWelcome.svelte +58 -0
- package/src/lib/SuperTable/overlays/AddNewRowOverlay.svelte +52 -0
- package/src/lib/SuperTable/overlays/EmptyResultSetOverlay.svelte +13 -0
- package/src/lib/SuperTable/overlays/LoadingOverlay.svelte +3 -0
- package/src/lib/SuperTable/overlays/RowContextMenu copy.svelte +57 -0
- package/src/lib/SuperTable/overlays/RowContextMenu.svelte +58 -0
- package/src/lib/SuperTable/overlays/ScrollbarsOverlay.svelte +184 -0
- package/src/lib/SuperTable/overlays/SelectedActionsOverlay.svelte +64 -0
- package/src/lib/SuperTable/state/API.js +0 -0
- package/src/lib/SuperTable/state/SuperTableStateMachine.js +0 -0
- package/src/lib/SuperTable/types.js +0 -0
- package/src/lib/SuperTableCells/CellAttachment.svelte +288 -0
- package/src/lib/SuperTableCells/CellBoolean.svelte +158 -0
- package/src/lib/SuperTableCells/CellColor.svelte +460 -0
- package/src/lib/SuperTableCells/CellCommon.css +319 -0
- package/src/lib/SuperTableCells/CellDatetime.svelte +180 -0
- package/src/lib/SuperTableCells/CellIcon.svelte +627 -0
- package/src/lib/SuperTableCells/CellJSON.svelte +297 -0
- package/src/lib/SuperTableCells/CellLink.svelte +274 -0
- package/src/lib/SuperTableCells/CellLinkAdvanced.svelte +298 -0
- package/src/lib/SuperTableCells/CellLinkPickerSelect.svelte +355 -0
- package/src/lib/SuperTableCells/CellLinkPickerTable.svelte +91 -0
- package/src/lib/SuperTableCells/CellLinkPickerTree.svelte +226 -0
- package/src/lib/SuperTableCells/CellNumber.svelte +179 -0
- package/src/lib/SuperTableCells/CellNumberSimple.svelte +56 -0
- package/src/lib/SuperTableCells/CellOptions.svelte +631 -0
- package/src/lib/SuperTableCells/CellOptionsAdvanced.svelte +684 -0
- package/src/lib/SuperTableCells/CellSkeleton.svelte +59 -0
- package/src/lib/SuperTableCells/CellString.svelte +178 -0
- package/src/lib/SuperTableCells/CellStringSimple.svelte +55 -0
- package/src/lib/SuperTableCells/index.js +21 -0
- package/src/lib/SuperTableCells/remixIcons.js +6772 -0
- package/src/lib/SuperTableColumn/SuperTableColumn.svelte +392 -0
- package/src/lib/SuperTableColumn/index.js +9 -0
- package/src/lib/SuperTableColumn/parts/SuperColumnBody.svelte +57 -0
- package/src/lib/SuperTableColumn/parts/SuperColumnFooter.svelte +14 -0
- package/src/lib/SuperTableColumn/parts/SuperColumnHeader.svelte +228 -0
- package/src/lib/SuperTableColumn/parts/SuperColumnRow.svelte +142 -0
- package/src/lib/SuperTableColumn/parts/SuperColumnRowNew.svelte +34 -0
- package/src/lib/SuperTree/SuperTree.svelte +117 -0
- package/src/types/svelte-portal.d.ts +1 -0
@@ -0,0 +1,298 @@
|
|
1
|
+
<script>
|
2
|
+
import { createEventDispatcher } from "svelte";
|
3
|
+
import fsm from "svelte-fsm";
|
4
|
+
import SuperPopover from "../SuperPopover/SuperPopover.svelte";
|
5
|
+
import CellLinkPickerTree from "../../lib/SuperTableCells/CellLinkPickerTree.svelte";
|
6
|
+
const dispatch = createEventDispatcher();
|
7
|
+
|
8
|
+
export let value;
|
9
|
+
export let fieldSchema;
|
10
|
+
export let cellOptions;
|
11
|
+
export let simpleView = true;
|
12
|
+
export let filter = [];
|
13
|
+
export let limit = 100;
|
14
|
+
|
15
|
+
let originalValue = JSON.stringify(value);
|
16
|
+
let anchor;
|
17
|
+
let popup;
|
18
|
+
let search;
|
19
|
+
let hasFocus;
|
20
|
+
let searchTerm;
|
21
|
+
|
22
|
+
export let cellState = fsm(cellOptions.initialState ?? "View", {
|
23
|
+
"*": {
|
24
|
+
goTo(state) {
|
25
|
+
return state;
|
26
|
+
},
|
27
|
+
},
|
28
|
+
View: {
|
29
|
+
_enter() {
|
30
|
+
search = false;
|
31
|
+
},
|
32
|
+
focus() {
|
33
|
+
if (!cellOptions.readonly && !cellOptions.disabled) return "Editing";
|
34
|
+
},
|
35
|
+
},
|
36
|
+
Hovered: {
|
37
|
+
cancel: () => {
|
38
|
+
return "View";
|
39
|
+
},
|
40
|
+
},
|
41
|
+
Focused: {
|
42
|
+
unfocus() {
|
43
|
+
return "View";
|
44
|
+
},
|
45
|
+
},
|
46
|
+
Error: { check: "View" },
|
47
|
+
Editing: {
|
48
|
+
_enter() {
|
49
|
+
originalValue = JSON.stringify(localValue);
|
50
|
+
editorState.open();
|
51
|
+
dispatch("enteredit");
|
52
|
+
},
|
53
|
+
_exit() {
|
54
|
+
editorState.close();
|
55
|
+
dispatch("exitedit");
|
56
|
+
},
|
57
|
+
checkFocus() {
|
58
|
+
return hasFocus();
|
59
|
+
},
|
60
|
+
focusout(e) {
|
61
|
+
if (popup?.contains(e.relatedTarget)) return;
|
62
|
+
this.submit();
|
63
|
+
},
|
64
|
+
popupfocusout(e) {
|
65
|
+
console.log(e);
|
66
|
+
},
|
67
|
+
clear() {
|
68
|
+
localValue = [];
|
69
|
+
},
|
70
|
+
submit() {
|
71
|
+
if (isDirty)
|
72
|
+
dispatch(
|
73
|
+
"change",
|
74
|
+
returnSingle && localValue ? localValue[0] : localValue
|
75
|
+
);
|
76
|
+
editorState.close();
|
77
|
+
return "View";
|
78
|
+
},
|
79
|
+
cancel() {
|
80
|
+
editorState.close();
|
81
|
+
return "View";
|
82
|
+
},
|
83
|
+
},
|
84
|
+
});
|
85
|
+
|
86
|
+
const editorState = fsm("Closed", {
|
87
|
+
Open: {
|
88
|
+
close() {
|
89
|
+
return "Closed";
|
90
|
+
},
|
91
|
+
toggle() {
|
92
|
+
return "Closed";
|
93
|
+
},
|
94
|
+
},
|
95
|
+
Closed: {
|
96
|
+
open() {
|
97
|
+
return "Open";
|
98
|
+
},
|
99
|
+
toggle() {
|
100
|
+
return "Open";
|
101
|
+
},
|
102
|
+
},
|
103
|
+
});
|
104
|
+
|
105
|
+
$: pills = cellOptions.relViewMode == "pills";
|
106
|
+
$: multi = !fieldSchema?.type?.includes("_single");
|
107
|
+
$: isUser = fieldSchema?.type?.includes("bb_reference");
|
108
|
+
$: localValue = enrichValue(value);
|
109
|
+
$: inEdit = $cellState == "Editing";
|
110
|
+
$: isDirty = inEdit && originalValue != JSON.stringify(localValue);
|
111
|
+
$: simpleView = cellOptions.relViewMode == "text";
|
112
|
+
$: inline = cellOptions.role == "inlineInput";
|
113
|
+
$: expanded = cellOptions.controlType == "expanded";
|
114
|
+
$: multirow =
|
115
|
+
cellOptions.controlType == "expanded" && (localValue?.length > 1 || inEdit);
|
116
|
+
$: singleSelect =
|
117
|
+
fieldSchema?.relationshipType == "one-to-many" ||
|
118
|
+
fieldSchema?.relationshipType == "many-to-one" ||
|
119
|
+
fieldSchema?.relationshipType == "self" ||
|
120
|
+
!multi;
|
121
|
+
|
122
|
+
$: returnSingle = isUser && !multi;
|
123
|
+
|
124
|
+
const handleKeyboard = (e) => {
|
125
|
+
if (e.keyCode == 32 && $cellState == "Editing") {
|
126
|
+
e.preventDefault();
|
127
|
+
e.stopPropagation();
|
128
|
+
editorState.toggle();
|
129
|
+
} else if (e.key != "Tab") {
|
130
|
+
search = true;
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
const handleChange = (e) => {
|
135
|
+
localValue = e.detail;
|
136
|
+
let val = returnSingle ? (localValue[0] ?? {}) : localValue;
|
137
|
+
|
138
|
+
if (expanded) {
|
139
|
+
dispatch("change", val);
|
140
|
+
}
|
141
|
+
|
142
|
+
if (singleSelect) {
|
143
|
+
editorState.close();
|
144
|
+
}
|
145
|
+
};
|
146
|
+
|
147
|
+
const enrichValue = (x) => {
|
148
|
+
if (fieldSchema.relationshipType == "self" && x) {
|
149
|
+
return safeParse(x);
|
150
|
+
} else if (multi) {
|
151
|
+
return value ? [...value] : [];
|
152
|
+
} else {
|
153
|
+
return value ? [value] : [];
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
const safeParse = (x) => {
|
158
|
+
let res;
|
159
|
+
try {
|
160
|
+
res = JSON.parse(x);
|
161
|
+
} catch {
|
162
|
+
res = undefined;
|
163
|
+
}
|
164
|
+
return res;
|
165
|
+
};
|
166
|
+
</script>
|
167
|
+
|
168
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
169
|
+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
170
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
171
|
+
<div
|
172
|
+
class="superCell"
|
173
|
+
bind:this={anchor}
|
174
|
+
tabindex={"0"}
|
175
|
+
class:inEdit
|
176
|
+
class:isDirty={isDirty && cellOptions.showDirty}
|
177
|
+
class:focused={$cellState == "Editing"}
|
178
|
+
class:inline
|
179
|
+
class:multirow
|
180
|
+
class:tableCell={cellOptions.role == "tableCell"}
|
181
|
+
class:formInput={cellOptions.role == "formInput"}
|
182
|
+
class:disabled={cellOptions.disabled}
|
183
|
+
class:readonly={cellOptions.readonly}
|
184
|
+
class:error={cellOptions.error}
|
185
|
+
style:color={cellOptions.color}
|
186
|
+
style:background={cellOptions.background}
|
187
|
+
style:font-weight={cellOptions.fontWeight}
|
188
|
+
on:keydown={handleKeyboard}
|
189
|
+
on:focusin={cellState.focus}
|
190
|
+
on:focusout={cellState.focusout}
|
191
|
+
on:mousedown={editorState.toggle}
|
192
|
+
>
|
193
|
+
{#if cellOptions?.icon}
|
194
|
+
<i class={cellOptions.icon + " icon"}></i>
|
195
|
+
{/if}
|
196
|
+
|
197
|
+
<div
|
198
|
+
class="value"
|
199
|
+
class:with-icon={cellOptions?.icon}
|
200
|
+
class:placeholder={localValue?.length < 1}
|
201
|
+
>
|
202
|
+
{#if localValue?.length < 1}
|
203
|
+
<span>
|
204
|
+
{cellOptions.placeholder ?? null}
|
205
|
+
</span>
|
206
|
+
{:else if localValue?.length > 0}
|
207
|
+
<div class="items" class:pills>
|
208
|
+
{#each localValue as val}
|
209
|
+
<div
|
210
|
+
class="item"
|
211
|
+
class:rel-bb-reference={!simpleView && fieldSchema.type != "link"}
|
212
|
+
>
|
213
|
+
{#if !simpleView}
|
214
|
+
<i
|
215
|
+
class={fieldSchema.type == "link"
|
216
|
+
? "ri-links-line"
|
217
|
+
: "ri-user-line"}
|
218
|
+
/>
|
219
|
+
{/if}
|
220
|
+
<span>{val.primaryDisplay}</span>
|
221
|
+
</div>
|
222
|
+
{/each}
|
223
|
+
</div>
|
224
|
+
{/if}
|
225
|
+
|
226
|
+
{#if inEdit && localValue?.length}
|
227
|
+
<i
|
228
|
+
class="ri-close-line clearIcon"
|
229
|
+
on:mousedown|preventDefault={cellState.clear}
|
230
|
+
></i>
|
231
|
+
{/if}
|
232
|
+
{#if cellOptions.role == "formInput" || inEdit}
|
233
|
+
<i class="ri-arrow-down-s-line controlIcon"></i>
|
234
|
+
{/if}
|
235
|
+
</div>
|
236
|
+
</div>
|
237
|
+
|
238
|
+
{#if inEdit}
|
239
|
+
<SuperPopover
|
240
|
+
{anchor}
|
241
|
+
useAnchorWidth
|
242
|
+
open={$editorState == "Open"}
|
243
|
+
bind:popup
|
244
|
+
on:close={cellState.focusout}
|
245
|
+
>
|
246
|
+
<CellLinkPickerTree
|
247
|
+
{fieldSchema}
|
248
|
+
{filter}
|
249
|
+
{search}
|
250
|
+
{searchTerm}
|
251
|
+
{limit}
|
252
|
+
joinColumn={cellOptions.joinColumn}
|
253
|
+
value={localValue}
|
254
|
+
multi={false}
|
255
|
+
on:change={handleChange}
|
256
|
+
on:focusout={(e) => setTimeout(cellState.focusout, 20, e)}
|
257
|
+
/>
|
258
|
+
</SuperPopover>
|
259
|
+
{/if}
|
260
|
+
|
261
|
+
<style>
|
262
|
+
.rel-pills {
|
263
|
+
background-color: var(--spectrum-global-color-gray-200);
|
264
|
+
}
|
265
|
+
.rel-bb-reference {
|
266
|
+
background-color: var(--spectrum-global-color-gray-200);
|
267
|
+
}
|
268
|
+
|
269
|
+
.actionIcon {
|
270
|
+
height: 100%;
|
271
|
+
display: flex;
|
272
|
+
justify-content: center;
|
273
|
+
align-items: center;
|
274
|
+
min-width: 2rem;
|
275
|
+
font-size: 16px;
|
276
|
+
transition: all 130ms;
|
277
|
+
margin-right: 8px;
|
278
|
+
}
|
279
|
+
.actionIcon:hover {
|
280
|
+
cursor: pointer;
|
281
|
+
background-color: var(--spectrum-global-color-gray-75);
|
282
|
+
color: var(--spectrum-global-color-red-500);
|
283
|
+
font-weight: 800;
|
284
|
+
}
|
285
|
+
|
286
|
+
.loader {
|
287
|
+
width: 120px;
|
288
|
+
height: 20px;
|
289
|
+
background: linear-gradient(90deg, #0001 33%, #0005 50%, #0001 66%) #f2f2f2;
|
290
|
+
background-size: 300% 100%;
|
291
|
+
animation: l1 1s infinite linear;
|
292
|
+
}
|
293
|
+
@keyframes l1 {
|
294
|
+
0% {
|
295
|
+
background-position: right;
|
296
|
+
}
|
297
|
+
}
|
298
|
+
</style>
|
@@ -0,0 +1,355 @@
|
|
1
|
+
<script>
|
2
|
+
import { getContext, createEventDispatcher } from "svelte";
|
3
|
+
import { fly } from "svelte/transition";
|
4
|
+
|
5
|
+
const { API, fetchData } = getContext("sdk");
|
6
|
+
const dispatch = createEventDispatcher();
|
7
|
+
|
8
|
+
export let value = [];
|
9
|
+
export let fieldSchema;
|
10
|
+
export let filter = [];
|
11
|
+
export let wide = false;
|
12
|
+
export let singleSelect;
|
13
|
+
|
14
|
+
let schema = fieldSchema;
|
15
|
+
let tableId = fieldSchema.tableId;
|
16
|
+
let appliedFilter = [];
|
17
|
+
let focusIdx = -1;
|
18
|
+
let control;
|
19
|
+
let filterTerm;
|
20
|
+
|
21
|
+
$: isBBReference = fieldSchema?.type?.includes("bb_reference");
|
22
|
+
$: isMultiReference =
|
23
|
+
isBBReference && !fieldSchema?.type?.includes("_single");
|
24
|
+
$: type = isBBReference ? "user" : "table";
|
25
|
+
$: localValue = Array.isArray(value) ? value : [];
|
26
|
+
$: fetch = fetchData({
|
27
|
+
API,
|
28
|
+
datasource: {
|
29
|
+
type,
|
30
|
+
tableId: tableId,
|
31
|
+
},
|
32
|
+
options: {
|
33
|
+
filter,
|
34
|
+
limit: 1000,
|
35
|
+
},
|
36
|
+
});
|
37
|
+
|
38
|
+
$: primaryDisplay = $fetch?.definition?.primaryDisplay || "email";
|
39
|
+
|
40
|
+
const rowSelected = (val) => {
|
41
|
+
if (value) {
|
42
|
+
let found = value.find((e) => e._id == val._id);
|
43
|
+
return found;
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
const selectRow = (val) => {
|
48
|
+
if (singleSelect) {
|
49
|
+
if (localValue[0]?._id == val._id) {
|
50
|
+
localValue = [];
|
51
|
+
} else
|
52
|
+
localValue = [{ _id: val._id, primaryDisplay: val[primaryDisplay] }];
|
53
|
+
} else {
|
54
|
+
let pos = localValue.findIndex((v) => v._id == val._id);
|
55
|
+
if (pos > -1) {
|
56
|
+
localValue.splice(pos, 1);
|
57
|
+
localValue = localValue;
|
58
|
+
} else {
|
59
|
+
localValue.push({ _id: val._id, primaryDisplay: val[primaryDisplay] });
|
60
|
+
localValue = localValue;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
dispatch("change", localValue);
|
64
|
+
};
|
65
|
+
|
66
|
+
const unselectRow = (val) => {
|
67
|
+
localValue.splice(
|
68
|
+
localValue.findIndex((e) => e._id === val._id),
|
69
|
+
1
|
70
|
+
);
|
71
|
+
localValue = localValue;
|
72
|
+
dispatch("change", localValue);
|
73
|
+
};
|
74
|
+
|
75
|
+
const handleSearch = (e) => {
|
76
|
+
filterTerm = e.target.value;
|
77
|
+
if (e.target.value) {
|
78
|
+
appliedFilter = [
|
79
|
+
...filter,
|
80
|
+
{
|
81
|
+
field: primaryDisplay,
|
82
|
+
type: "string",
|
83
|
+
operator: "fuzzy",
|
84
|
+
value: e.target.value,
|
85
|
+
valueType: "Value",
|
86
|
+
},
|
87
|
+
];
|
88
|
+
} else {
|
89
|
+
appliedFilter = filter ?? [];
|
90
|
+
}
|
91
|
+
|
92
|
+
fetch?.update({
|
93
|
+
filter: appliedFilter,
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
const handleNavigation = (e) => {
|
98
|
+
if (e.key == "ArrowDown") {
|
99
|
+
e.preventDefault();
|
100
|
+
focusIdx += 1;
|
101
|
+
if (focusIdx > $fetch.rows.length - 1) focusIdx = 0;
|
102
|
+
} else if (e.key == "ArrowUp") {
|
103
|
+
e.preventDefault();
|
104
|
+
focusIdx -= 1;
|
105
|
+
if (focusIdx < 0) focusIdx = $fetch.rows.length - 1;
|
106
|
+
} else if (e.key == "Enter" && focusIdx > -1)
|
107
|
+
selectRow($fetch.rows[focusIdx]);
|
108
|
+
if (e.key == "Tab" || e.key == "Escape") dispatch("close");
|
109
|
+
};
|
110
|
+
|
111
|
+
export const api = {
|
112
|
+
focus: () => {
|
113
|
+
control?.focus();
|
114
|
+
},
|
115
|
+
hasFocus: () => {
|
116
|
+
return document.activeElement === control;
|
117
|
+
},
|
118
|
+
};
|
119
|
+
</script>
|
120
|
+
|
121
|
+
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
122
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
123
|
+
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
124
|
+
<div class="control">
|
125
|
+
<div class="searchControl">
|
126
|
+
<i
|
127
|
+
class={$fetch.loading
|
128
|
+
? "ri-loader-2-line"
|
129
|
+
: control?.value
|
130
|
+
? "ri-filter-fill"
|
131
|
+
: "ri-search-line"}
|
132
|
+
style:color={filterTerm
|
133
|
+
? "var(--spectrum-global-color-blue-400)"
|
134
|
+
: "var(--spectrum-global-color-gray-700)"}
|
135
|
+
/>
|
136
|
+
<input
|
137
|
+
bind:this={control}
|
138
|
+
class="search"
|
139
|
+
class:placeholder={!filterTerm}
|
140
|
+
type="text"
|
141
|
+
placeholder={$fetch.loading ? "Loading..." : "Search"}
|
142
|
+
on:input={handleSearch}
|
143
|
+
on:keydown={handleNavigation}
|
144
|
+
on:blur={() => dispatch("close")}
|
145
|
+
/>
|
146
|
+
</div>
|
147
|
+
|
148
|
+
{#if $fetch?.loaded}
|
149
|
+
{#if wide}
|
150
|
+
<div class="listWrapper" on:mousedown|preventDefault={() => {}}>
|
151
|
+
<div class="list">
|
152
|
+
<div class="options">
|
153
|
+
{#key localValue}
|
154
|
+
{#if $fetch?.rows.length}
|
155
|
+
{#each $fetch.rows as row, idx (idx)}
|
156
|
+
{#if !rowSelected(row)}
|
157
|
+
<div
|
158
|
+
class="option wide"
|
159
|
+
class:highlighted={focusIdx == idx}
|
160
|
+
on:mouseenter={() => (focusIdx = idx)}
|
161
|
+
on:mouseleave={() => (focusIdx = -1)}
|
162
|
+
on:mousedown|preventDefault={selectRow(row)}
|
163
|
+
>
|
164
|
+
{row[primaryDisplay]}
|
165
|
+
<i class="ri-add-line" />
|
166
|
+
</div>
|
167
|
+
{/if}
|
168
|
+
{/each}
|
169
|
+
{:else}
|
170
|
+
<div class="option">No Results Found</div>
|
171
|
+
{/if}
|
172
|
+
{/key}
|
173
|
+
</div>
|
174
|
+
</div>
|
175
|
+
<div class="list listSelected">
|
176
|
+
<div class="options">
|
177
|
+
{#if localValue.length}
|
178
|
+
{#each localValue as val, idx (idx)}
|
179
|
+
{#if rowSelected(val)}
|
180
|
+
<div
|
181
|
+
transition:fly={{ x: -20, duration: 130 }}
|
182
|
+
class="option wide selected"
|
183
|
+
on:mousedown|stopPropagation|preventDefault={unselectRow(
|
184
|
+
val
|
185
|
+
)}
|
186
|
+
>
|
187
|
+
{val.primaryDisplay}
|
188
|
+
<i class="ri-close-line" />
|
189
|
+
</div>
|
190
|
+
{/if}
|
191
|
+
{/each}
|
192
|
+
{:else}
|
193
|
+
<span>Nothing Selected</span>
|
194
|
+
{/if}
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
{:else}
|
199
|
+
<div class="listWrapper" on:mousedown|preventDefault={() => {}}>
|
200
|
+
<div class="list">
|
201
|
+
<div class="options">
|
202
|
+
{#key localValue}
|
203
|
+
{#if $fetch?.rows.length}
|
204
|
+
{#each $fetch?.rows as row, idx (idx)}
|
205
|
+
<div
|
206
|
+
class="option"
|
207
|
+
class:selected={rowSelected(row)}
|
208
|
+
class:highlighted={focusIdx == idx}
|
209
|
+
on:mouseenter={() => (focusIdx = idx)}
|
210
|
+
on:mouseleave={() => (focusIdx = -1)}
|
211
|
+
on:mousedown|preventDefault={selectRow(row)}
|
212
|
+
>
|
213
|
+
{row[primaryDisplay]}
|
214
|
+
<i class="ri-checkbox-circle-fill" />
|
215
|
+
</div>
|
216
|
+
{/each}
|
217
|
+
{:else}
|
218
|
+
<div class="option">No Results Found</div>
|
219
|
+
{/if}
|
220
|
+
{/key}
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
</div>
|
224
|
+
{/if}
|
225
|
+
{/if}
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<style>
|
229
|
+
.control {
|
230
|
+
flex: auto;
|
231
|
+
flex-direction: column;
|
232
|
+
display: flex;
|
233
|
+
align-items: stretch;
|
234
|
+
justify-content: space-around;
|
235
|
+
gap: 0.25rem;
|
236
|
+
padding: 0.25rem;
|
237
|
+
padding-top: 0rem;
|
238
|
+
overflow-x: hidden;
|
239
|
+
|
240
|
+
&:focus {
|
241
|
+
border: 1px solid white;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
.searchControl {
|
246
|
+
height: 2rem;
|
247
|
+
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
|
248
|
+
display: flex;
|
249
|
+
align-items: center;
|
250
|
+
padding-left: 0.5rem;
|
251
|
+
gap: 0.25rem;
|
252
|
+
|
253
|
+
& > i {
|
254
|
+
font-size: 14px;
|
255
|
+
transition: all 230ms;
|
256
|
+
}
|
257
|
+
|
258
|
+
& > input {
|
259
|
+
height: 100%;
|
260
|
+
width: 100%;
|
261
|
+
outline: none;
|
262
|
+
background: none;
|
263
|
+
border: none;
|
264
|
+
color: inherit;
|
265
|
+
padding-left: 0.5rem;
|
266
|
+
font-family: inherit;
|
267
|
+
font-size: inherit;
|
268
|
+
|
269
|
+
&.placeholder {
|
270
|
+
font-style: italic;
|
271
|
+
color: var(--spectrum-global-color-gray-600);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
.listWrapper {
|
277
|
+
flex: auto;
|
278
|
+
display: flex;
|
279
|
+
justify-content: stretch;
|
280
|
+
align-content: stretch;
|
281
|
+
gap: 0.25rem;
|
282
|
+
overflow: hidden;
|
283
|
+
}
|
284
|
+
|
285
|
+
.list {
|
286
|
+
flex: 1 1 50%;
|
287
|
+
height: 200px;
|
288
|
+
overflow-y: auto;
|
289
|
+
overflow-x: hidden;
|
290
|
+
color: var(--spectrum-global-color-gray-800);
|
291
|
+
}
|
292
|
+
|
293
|
+
.listSelected {
|
294
|
+
color: var(--spectrum-global-color-gray-800);
|
295
|
+
border-left: 1px solid var(--spectrum-global-color-gray-300);
|
296
|
+
padding-left: 0.25rem;
|
297
|
+
}
|
298
|
+
.options {
|
299
|
+
display: flex;
|
300
|
+
flex-direction: column;
|
301
|
+
justify-content: flex-start;
|
302
|
+
align-items: stretch;
|
303
|
+
overflow-y: auto;
|
304
|
+
gap: 0rem;
|
305
|
+
min-width: 0;
|
306
|
+
}
|
307
|
+
.option {
|
308
|
+
line-height: 1.5rem;
|
309
|
+
padding: 0.15rem 0.5rem;
|
310
|
+
overflow: hidden;
|
311
|
+
text-overflow: ellipsis;
|
312
|
+
white-space: nowrap;
|
313
|
+
display: flex;
|
314
|
+
justify-content: space-between;
|
315
|
+
|
316
|
+
& > i {
|
317
|
+
visibility: hidden;
|
318
|
+
}
|
319
|
+
|
320
|
+
&.wide:hover {
|
321
|
+
& > i {
|
322
|
+
visibility: visible;
|
323
|
+
color: var(--spectrum-global-color-green-500);
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
&.selected {
|
328
|
+
background-color: var(--spectrum-global-color-gray-75);
|
329
|
+
color: var(--spectrum-global-color-gray-900);
|
330
|
+
& > i {
|
331
|
+
visibility: visible;
|
332
|
+
color: var(--spectrum-global-color-green-500);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
&.highlighted {
|
337
|
+
background-color: var(--spectrum-global-color-gray-200);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
.options > span {
|
342
|
+
color: var(--spectrum-global-color-gray-500);
|
343
|
+
font-style: italic;
|
344
|
+
flex: auto;
|
345
|
+
display: flex;
|
346
|
+
align-items: center;
|
347
|
+
justify-content: center;
|
348
|
+
}
|
349
|
+
|
350
|
+
.option:hover {
|
351
|
+
background-color: var(--spectrum-global-color-gray-200);
|
352
|
+
border-radius: 4px;
|
353
|
+
cursor: pointer;
|
354
|
+
}
|
355
|
+
</style>
|