Lot of updates to Svelte 5 syntax
This commit is contained in:
@@ -1,5 +1,38 @@
|
||||
<script lang="ts">
|
||||
export let log_lvl: number = 0;
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
// Expecting these for link_to_type: 'event', 'event_location', 'event_presentation', 'event_presenter', 'event_session'
|
||||
link_to_type: string;
|
||||
link_to_id: string;
|
||||
input_name?: string;
|
||||
multiple?: boolean;
|
||||
required?: boolean;
|
||||
accept?: string;
|
||||
class_li_default?: string;
|
||||
class_li?: string;
|
||||
input_class_li?: string[];
|
||||
table_class_li?: string[];
|
||||
upload_complete?: boolean;
|
||||
submit_status?: null|string;
|
||||
label?: import('svelte').Snippet;
|
||||
}
|
||||
|
||||
let {
|
||||
log_lvl = $bindable(0),
|
||||
link_to_type,
|
||||
link_to_id,
|
||||
input_name = 'file_list',
|
||||
multiple = true,
|
||||
required = true,
|
||||
accept = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh',
|
||||
class_li_default = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1',
|
||||
class_li = '',
|
||||
input_class_li = ['file_drop_area'],
|
||||
table_class_li = ['table', 'table-sm', 'table-striped', '' , 'text-sm'],
|
||||
upload_complete = $bindable(false),
|
||||
submit_status = $bindable(null),
|
||||
label
|
||||
}: Props = $props();
|
||||
|
||||
// Imports
|
||||
// Import components and elements
|
||||
@@ -14,35 +47,25 @@ import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_ev
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
import { db_events } from "$lib/ae_events/db_events";
|
||||
|
||||
|
||||
// Exports
|
||||
// Expecting these for link_to_type: 'event', 'event_location', 'event_presentation', 'event_presenter', 'event_session'
|
||||
export let link_to_type: string;
|
||||
export let link_to_id: string;
|
||||
|
||||
export let input_name = 'file_list';
|
||||
export let multiple: boolean = true;
|
||||
export let required: boolean = true;
|
||||
export let accept: string = 'audio/*, image/*, video/*, .bak, .cfg, .css, .csv, .doc, .docx, .gz, .htm, .html, .ini, .iso, .j2, .json, .key, .keynote, .md, .pdf, .ppt, .pptx, .rar, .rtf, .sql, .svelte, ttf, .txt, .xls, .xlsx, .xz, .zip, .bin, .dmg, .exe, .js, .msi, .php, .py, .sh';
|
||||
|
||||
export let class_li_default: string = 'flex flex-col gap-1 items-center justify-center w-full max-w-2xl mx-auto my-1';
|
||||
export let class_li: string = '';
|
||||
export let input_class_li: string[] = ['file_drop_area'];
|
||||
export let table_class_li: string[] = ['table', 'table-sm', 'table-striped', '' , 'text-sm'];
|
||||
|
||||
export let upload_complete: boolean = false;
|
||||
export let submit_status: null|string = null;
|
||||
|
||||
|
||||
// Local Variables
|
||||
let task_id = link_to_id;
|
||||
let input_file_list: any = null;
|
||||
let ae_promises: key_val = {}; // Promise<any>;
|
||||
let task_id = $state(link_to_id);
|
||||
let input_file_list: any = $state(null);
|
||||
let ae_promises: key_val = $state({}); // Promise<any>;
|
||||
let ae_triggers: key_val = {};
|
||||
|
||||
let input_element_id = 'ae_comp__event_files_upload__input';
|
||||
|
||||
|
||||
// *** Functions and Logic
|
||||
function preventDefault(fn) {
|
||||
return function (event) {
|
||||
event.preventDefault();
|
||||
fn.call(this, event);
|
||||
};
|
||||
}
|
||||
|
||||
async function handle_submit_form_files(event) {
|
||||
console.log('*** handle_submit_form() ***');
|
||||
|
||||
@@ -219,7 +242,7 @@ async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
|
||||
<!-- class:hidden={!$ae_loc.trusted_access} -->
|
||||
<form
|
||||
on:submit|preventDefault={handle_submit_form_files}
|
||||
onsubmit={preventDefault(handle_submit_form_files)}
|
||||
class="{class_li_default} {class_li}"
|
||||
>
|
||||
|
||||
@@ -252,7 +275,7 @@ async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
"
|
||||
class:hidden={$events_sess.files.disable_submit__event_file_obj}
|
||||
>
|
||||
<slot name="label">
|
||||
{#if label}{@render label()}{:else}
|
||||
<div class="text-lg">
|
||||
<span class="fas fa-upload"></span>
|
||||
<!-- Select files to upload -->
|
||||
@@ -264,7 +287,7 @@ async function handle_input_upload_files(input_upload_files, task_id) {
|
||||
<strong>Presentation related files only</strong><br>
|
||||
(PowerPoint, Keynote, PDF, mp4, Word Doc, Excel, txt, etc)
|
||||
</div>
|
||||
</slot>
|
||||
{/if}
|
||||
</label>
|
||||
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user