feat: migration to Svelte 5
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { run, preventDefault } from 'svelte/legacy';
|
||||
|
||||
import { createEventDispatcher, onMount, tick } from 'svelte';
|
||||
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
@@ -7,17 +9,31 @@
|
||||
import { check_hosted_file_obj_w_hash } from '$lib/ae_core/core__check_hosted_file_obj_w_hash';
|
||||
import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/stores/ae_stores';
|
||||
|
||||
// export let element_id = 'svelte_input_file_element';
|
||||
export let container_class_li: string[] = [];
|
||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '', 'text-sm'];
|
||||
|
||||
|
||||
export let untrusted_extension_list = ['bin', 'dmg', 'exe', 'js', 'msi', 'php', 'py', 'sh'];
|
||||
export let legacy_extension_list = ['avi', 'doc', 'ppt', 'xls', 'wmv'];
|
||||
export let use_selected_file_table = true;
|
||||
|
||||
export let input_file_list: any = null;
|
||||
export let file_list_status: null | string = null;
|
||||
export let processed_file_list: any[] = [];
|
||||
interface Props {
|
||||
// export let element_id = 'svelte_input_file_element';
|
||||
container_class_li?: string[];
|
||||
table_class_li?: string[];
|
||||
untrusted_extension_list?: any;
|
||||
legacy_extension_list?: any;
|
||||
use_selected_file_table?: boolean;
|
||||
input_file_list?: any;
|
||||
file_list_status?: null | string;
|
||||
processed_file_list?: any[];
|
||||
}
|
||||
|
||||
let {
|
||||
container_class_li = [],
|
||||
table_class_li = ['table', 'table-sm', 'table-striped', '', 'text-sm'],
|
||||
untrusted_extension_list = ['bin', 'dmg', 'exe', 'js', 'msi', 'php', 'py', 'sh'],
|
||||
legacy_extension_list = ['avi', 'doc', 'ppt', 'xls', 'wmv'],
|
||||
use_selected_file_table = true,
|
||||
input_file_list = $bindable(null),
|
||||
file_list_status = $bindable(null),
|
||||
processed_file_list = $bindable([])
|
||||
}: Props = $props();
|
||||
|
||||
// const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -27,33 +43,6 @@
|
||||
console.log('** Element Mounted: ** Element Input File');
|
||||
});
|
||||
|
||||
$: if (input_file_list) {
|
||||
console.log(input_file_list);
|
||||
|
||||
process_file_list(input_file_list).then(function (result) {
|
||||
// console.log(result);
|
||||
|
||||
if (!result || !result.length) {
|
||||
processed_file_list = [];
|
||||
file_list_status = 'none';
|
||||
}
|
||||
|
||||
// Save the results to the file upload list to be displayed as a table.
|
||||
// input_file_list_processed = result; // Includes file hash
|
||||
|
||||
// dispatch(
|
||||
// 'input_file_list_updated',
|
||||
// {
|
||||
// element_id: element_id,
|
||||
// input_file_list: input_file_list,
|
||||
// input_file_list_processed: result, // Includes file hash
|
||||
// }
|
||||
// );
|
||||
});
|
||||
} else {
|
||||
processed_file_list = [];
|
||||
file_list_status = 'none';
|
||||
}
|
||||
|
||||
async function process_file_list(file_list) {
|
||||
console.log('*** process_file_list() ***');
|
||||
@@ -310,6 +299,35 @@
|
||||
|
||||
return true;
|
||||
}
|
||||
run(() => {
|
||||
if (input_file_list) {
|
||||
console.log(input_file_list);
|
||||
|
||||
process_file_list(input_file_list).then(function (result) {
|
||||
// console.log(result);
|
||||
|
||||
if (!result || !result.length) {
|
||||
processed_file_list = [];
|
||||
file_list_status = 'none';
|
||||
}
|
||||
|
||||
// Save the results to the file upload list to be displayed as a table.
|
||||
// input_file_list_processed = result; // Includes file hash
|
||||
|
||||
// dispatch(
|
||||
// 'input_file_list_updated',
|
||||
// {
|
||||
// element_id: element_id,
|
||||
// input_file_list: input_file_list,
|
||||
// input_file_list_processed: result, // Includes file hash
|
||||
// }
|
||||
// );
|
||||
});
|
||||
} else {
|
||||
processed_file_list = [];
|
||||
file_list_status = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -346,9 +364,9 @@
|
||||
<tr>
|
||||
<td class="file_remove">
|
||||
<button
|
||||
on:click|preventDefault={() => {
|
||||
onclick={preventDefault(() => {
|
||||
remove_file_from_filelist(file_index);
|
||||
}}
|
||||
})}
|
||||
class="btn btn-md preset-tonal-warning hover:preset-filled-secondary-500 m-1"
|
||||
title="Remove file from upload list"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user