sveltekit-ui 1.0.35 → 1.0.36
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/dist/Components/TableAdvanced/index.svelte +1 -3
- package/dist/Components/TableAdvanced/index.svelte.js +9 -10
- package/package.json +1 -1
- package/src/lib/Components/TableAdvanced/index.svelte +1 -3
- package/src/lib/Components/TableAdvanced/index.svelte.js +9 -10
- package/src/routes/[component]/Showcase/TableAdvanced/index.svelte +141 -116
|
@@ -164,9 +164,7 @@
|
|
|
164
164
|
<div>
|
|
165
165
|
<FileInput manager={manager?.upload_rows_file_input_manager} />
|
|
166
166
|
</div>
|
|
167
|
-
|
|
168
|
-
<TextInput manager={manager?.upload_rows_text_input_manager} />
|
|
169
|
-
{/if}
|
|
167
|
+
<TextInput manager={manager?.upload_rows_text_input_manager} />
|
|
170
168
|
<div style="display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; margin-bottom: 1rem;">
|
|
171
169
|
<Button manager={manager?.upload_rows_prepare_text_button_manager} />
|
|
172
170
|
{#if manager?.bulk_insert_rows_prepared_data}
|
|
@@ -408,8 +408,7 @@ export function create_table_advanced_manager(config) {
|
|
|
408
408
|
() => {
|
|
409
409
|
let columns_prepped_copy = deep_copy(columns_prepped)
|
|
410
410
|
delete columns_prepped_copy[column_id]
|
|
411
|
-
|
|
412
|
-
set_rows_prepped(columns_prepped_loc)
|
|
411
|
+
set_columns(columns_prepped_copy)
|
|
413
412
|
if (typeof res.finish == "function") {
|
|
414
413
|
res.finish()
|
|
415
414
|
}
|
|
@@ -444,8 +443,7 @@ export function create_table_advanced_manager(config) {
|
|
|
444
443
|
let cleaned_columns = deep_copy(columns_prepped ?? {})
|
|
445
444
|
delete cleaned_columns[column_id]
|
|
446
445
|
cleaned_columns[res?.column_id] = res?.column
|
|
447
|
-
|
|
448
|
-
set_rows_prepped(columns_prepped_loc)
|
|
446
|
+
set_columns(cleaned_columns)
|
|
449
447
|
}
|
|
450
448
|
)
|
|
451
449
|
} else {
|
|
@@ -473,8 +471,8 @@ export function create_table_advanced_manager(config) {
|
|
|
473
471
|
() => {
|
|
474
472
|
let cleaned_columns = deep_copy(columns_prepped ?? {})
|
|
475
473
|
cleaned_columns[res?.column_id] = res?.column
|
|
476
|
-
|
|
477
|
-
|
|
474
|
+
console.log("cleaned_columns", cleaned_columns, res)
|
|
475
|
+
set_columns(cleaned_columns)
|
|
478
476
|
}
|
|
479
477
|
)
|
|
480
478
|
} else {
|
|
@@ -500,6 +498,7 @@ export function create_table_advanced_manager(config) {
|
|
|
500
498
|
row_edit_content_manager = null
|
|
501
499
|
setTimeout(() => {
|
|
502
500
|
// quick fix for when update row then edit a diff row the data for other doesnt remain in place
|
|
501
|
+
console.log("edit_row", { row_i, row_input_content })
|
|
503
502
|
row_edit_content_manager = create_content_manager({
|
|
504
503
|
val: row_input_content ?? null,
|
|
505
504
|
definition_stack: row_definition_stack,
|
|
@@ -739,9 +738,7 @@ export function create_table_advanced_manager(config) {
|
|
|
739
738
|
is_more_to_load = attributes?.is_more_to_load ?? false
|
|
740
739
|
table_header_max_height = attributes?.table_header_max_height ?? null
|
|
741
740
|
table_row_max_height = attributes?.table_row_max_height ?? null
|
|
742
|
-
|
|
743
|
-
set_rows_prepped(columns_prepped_loc)
|
|
744
|
-
row_input_content = attributes?.row_input_content ?? guess_row_input_content(attributes?.columns)
|
|
741
|
+
set_columns(attributes?.columns, attributes?.row_input_content)
|
|
745
742
|
}
|
|
746
743
|
|
|
747
744
|
function reset_definition_stack(input) {
|
|
@@ -749,9 +746,10 @@ export function create_table_advanced_manager(config) {
|
|
|
749
746
|
set_rows_prepped(columns_prepped)
|
|
750
747
|
}
|
|
751
748
|
|
|
752
|
-
function set_columns(input) {
|
|
749
|
+
function set_columns(input, row_input_content_input = null) {
|
|
753
750
|
set_columns_prepped(input)
|
|
754
751
|
set_rows_prepped(columns_prepped)
|
|
752
|
+
row_input_content = row_input_content_input ?? guess_row_input_content(input)
|
|
755
753
|
}
|
|
756
754
|
|
|
757
755
|
function init(config) {
|
|
@@ -1013,6 +1011,7 @@ export function create_table_advanced_manager(config) {
|
|
|
1013
1011
|
() => {
|
|
1014
1012
|
upload_rows_file_input_manager.clear_files()
|
|
1015
1013
|
bulk_insert_rows_prepared_data = null
|
|
1014
|
+
upload_rows_text_input_manager.set_val(null)
|
|
1016
1015
|
set_rows_prepped(columns_prepped)
|
|
1017
1016
|
}
|
|
1018
1017
|
)
|
package/package.json
CHANGED
|
@@ -164,9 +164,7 @@
|
|
|
164
164
|
<div>
|
|
165
165
|
<FileInput manager={manager?.upload_rows_file_input_manager} />
|
|
166
166
|
</div>
|
|
167
|
-
|
|
168
|
-
<TextInput manager={manager?.upload_rows_text_input_manager} />
|
|
169
|
-
{/if}
|
|
167
|
+
<TextInput manager={manager?.upload_rows_text_input_manager} />
|
|
170
168
|
<div style="display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; margin-bottom: 1rem;">
|
|
171
169
|
<Button manager={manager?.upload_rows_prepare_text_button_manager} />
|
|
172
170
|
{#if manager?.bulk_insert_rows_prepared_data}
|
|
@@ -408,8 +408,7 @@ export function create_table_advanced_manager(config) {
|
|
|
408
408
|
() => {
|
|
409
409
|
let columns_prepped_copy = deep_copy(columns_prepped)
|
|
410
410
|
delete columns_prepped_copy[column_id]
|
|
411
|
-
|
|
412
|
-
set_rows_prepped(columns_prepped_loc)
|
|
411
|
+
set_columns(columns_prepped_copy)
|
|
413
412
|
if (typeof res.finish == "function") {
|
|
414
413
|
res.finish()
|
|
415
414
|
}
|
|
@@ -444,8 +443,7 @@ export function create_table_advanced_manager(config) {
|
|
|
444
443
|
let cleaned_columns = deep_copy(columns_prepped ?? {})
|
|
445
444
|
delete cleaned_columns[column_id]
|
|
446
445
|
cleaned_columns[res?.column_id] = res?.column
|
|
447
|
-
|
|
448
|
-
set_rows_prepped(columns_prepped_loc)
|
|
446
|
+
set_columns(cleaned_columns)
|
|
449
447
|
}
|
|
450
448
|
)
|
|
451
449
|
} else {
|
|
@@ -473,8 +471,8 @@ export function create_table_advanced_manager(config) {
|
|
|
473
471
|
() => {
|
|
474
472
|
let cleaned_columns = deep_copy(columns_prepped ?? {})
|
|
475
473
|
cleaned_columns[res?.column_id] = res?.column
|
|
476
|
-
|
|
477
|
-
|
|
474
|
+
console.log("cleaned_columns", cleaned_columns, res)
|
|
475
|
+
set_columns(cleaned_columns)
|
|
478
476
|
}
|
|
479
477
|
)
|
|
480
478
|
} else {
|
|
@@ -500,6 +498,7 @@ export function create_table_advanced_manager(config) {
|
|
|
500
498
|
row_edit_content_manager = null
|
|
501
499
|
setTimeout(() => {
|
|
502
500
|
// quick fix for when update row then edit a diff row the data for other doesnt remain in place
|
|
501
|
+
console.log("edit_row", { row_i, row_input_content })
|
|
503
502
|
row_edit_content_manager = create_content_manager({
|
|
504
503
|
val: row_input_content ?? null,
|
|
505
504
|
definition_stack: row_definition_stack,
|
|
@@ -739,9 +738,7 @@ export function create_table_advanced_manager(config) {
|
|
|
739
738
|
is_more_to_load = attributes?.is_more_to_load ?? false
|
|
740
739
|
table_header_max_height = attributes?.table_header_max_height ?? null
|
|
741
740
|
table_row_max_height = attributes?.table_row_max_height ?? null
|
|
742
|
-
|
|
743
|
-
set_rows_prepped(columns_prepped_loc)
|
|
744
|
-
row_input_content = attributes?.row_input_content ?? guess_row_input_content(attributes?.columns)
|
|
741
|
+
set_columns(attributes?.columns, attributes?.row_input_content)
|
|
745
742
|
}
|
|
746
743
|
|
|
747
744
|
function reset_definition_stack(input) {
|
|
@@ -749,9 +746,10 @@ export function create_table_advanced_manager(config) {
|
|
|
749
746
|
set_rows_prepped(columns_prepped)
|
|
750
747
|
}
|
|
751
748
|
|
|
752
|
-
function set_columns(input) {
|
|
749
|
+
function set_columns(input, row_input_content_input = null) {
|
|
753
750
|
set_columns_prepped(input)
|
|
754
751
|
set_rows_prepped(columns_prepped)
|
|
752
|
+
row_input_content = row_input_content_input ?? guess_row_input_content(input)
|
|
755
753
|
}
|
|
756
754
|
|
|
757
755
|
function init(config) {
|
|
@@ -1013,6 +1011,7 @@ export function create_table_advanced_manager(config) {
|
|
|
1013
1011
|
() => {
|
|
1014
1012
|
upload_rows_file_input_manager.clear_files()
|
|
1015
1013
|
bulk_insert_rows_prepared_data = null
|
|
1014
|
+
upload_rows_text_input_manager.set_val(null)
|
|
1016
1015
|
set_rows_prepped(columns_prepped)
|
|
1017
1016
|
}
|
|
1018
1017
|
)
|
|
@@ -1397,144 +1397,169 @@
|
|
|
1397
1397
|
],
|
|
1398
1398
|
is_more_to_load: true,
|
|
1399
1399
|
on_event: async (input) => {
|
|
1400
|
-
console.log("
|
|
1400
|
+
console.log("table_advanced_on_event", input)
|
|
1401
|
+
if (input?.type == "update_table_server_sort") {
|
|
1402
|
+
console.log("update_table_server_sort", input)
|
|
1403
|
+
return { is_success: true }
|
|
1404
|
+
}
|
|
1401
1405
|
if (input?.type == "update_row") {
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1406
|
+
console.log("update_row_cb", input)
|
|
1407
|
+
const path = input?.path
|
|
1408
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1409
|
+
parent[last_key] = input?.row
|
|
1410
|
+
})
|
|
1411
|
+
return { is_success: true, row: input?.row }
|
|
1412
|
+
}
|
|
1413
|
+
if (input?.type == "insert_row") {
|
|
1414
|
+
console.log("insert_row", input)
|
|
1415
|
+
const path = input?.path
|
|
1416
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1417
|
+
if (Array.isArray(parent[last_key])) {
|
|
1418
|
+
if (typeof last_key === "number") {
|
|
1419
|
+
parent[last_key].splice(last_key, 0, input?.row)
|
|
1420
|
+
} else {
|
|
1421
|
+
parent[last_key].push(input?.row)
|
|
1422
|
+
}
|
|
1423
|
+
} else if (Array.isArray(parent)) {
|
|
1424
|
+
parent.splice(last_key, 0, input?.row)
|
|
1425
|
+
} else {
|
|
1426
|
+
parent[last_key] = [input?.row]
|
|
1408
1427
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
for (let i = 0; i < path_to_set.length - 1; i++) {
|
|
1424
|
-
if (target[path_to_set[i]] === undefined) {
|
|
1425
|
-
target[path_to_set[i]] = {}
|
|
1428
|
+
})
|
|
1429
|
+
console.log("variables22", deep_copy(variables))
|
|
1430
|
+
return { is_success: true }
|
|
1431
|
+
}
|
|
1432
|
+
if (input?.type == "bulk_insert_rows") {
|
|
1433
|
+
console.log("bulk_insert_rows", input)
|
|
1434
|
+
const path = input?.path
|
|
1435
|
+
let rows_new = null
|
|
1436
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1437
|
+
const items = Array.isArray(input?.rows) ? input.rows : []
|
|
1438
|
+
if (Array.isArray(parent) && typeof last_key === "number") {
|
|
1439
|
+
parent.splice(last_key, 0, ...items)
|
|
1440
|
+
rows_new = parent
|
|
1441
|
+
return
|
|
1426
1442
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
throw new Error("Target is not an array")
|
|
1432
|
-
}
|
|
1433
|
-
target.splice(last_key, 0, input?.row)
|
|
1434
|
-
variables = variables_loc
|
|
1435
|
-
table_manager.reset_definition_stack([{ ...variables }])
|
|
1436
|
-
return {
|
|
1437
|
-
is_success: true,
|
|
1438
|
-
row: target?.[last_key],
|
|
1439
|
-
}
|
|
1440
|
-
} else if (input?.type == "bulk_insert_rows") {
|
|
1441
|
-
console.log("bulk_insert_rows")
|
|
1442
|
-
const path_to_set = input?.path
|
|
1443
|
-
let variables_loc = deep_copy(variables)
|
|
1444
|
-
let target = variables_loc
|
|
1445
|
-
for (let i = 0; i < path_to_set.length - 1; i++) {
|
|
1446
|
-
if (target[path_to_set[i]] === undefined) {
|
|
1447
|
-
target[path_to_set[i]] = {}
|
|
1443
|
+
if (Array.isArray(parent[last_key])) {
|
|
1444
|
+
parent[last_key].push(...items)
|
|
1445
|
+
rows_new = parent[last_key]
|
|
1446
|
+
return
|
|
1448
1447
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
throw new Error("Target is not an array")
|
|
1454
|
-
}
|
|
1455
|
-
target.splice(last_key, 0, input?.value)
|
|
1456
|
-
variables = variables_loc
|
|
1457
|
-
table_manager.reset_definition_stack([{ ...variables }])
|
|
1458
|
-
return {
|
|
1459
|
-
is_success: true,
|
|
1460
|
-
rows: target?.[last_key],
|
|
1461
|
-
}
|
|
1462
|
-
} else if (input?.type == "delete_row") {
|
|
1463
|
-
console.log("delete_row", deep_copy(input))
|
|
1464
|
-
const path_to_delete = input?.path
|
|
1465
|
-
let variables_loc = deep_copy(variables)
|
|
1466
|
-
let target = variables_loc
|
|
1467
|
-
for (let i = 0; i < path_to_delete.length - 1; i++) {
|
|
1468
|
-
if (target[path_to_delete[i]] === undefined) {
|
|
1469
|
-
target[path_to_delete[i]] = {}
|
|
1448
|
+
if (Array.isArray(parent) && last_key === undefined) {
|
|
1449
|
+
parent.push(...items)
|
|
1450
|
+
rows_new = parent
|
|
1451
|
+
return
|
|
1470
1452
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1453
|
+
parent[last_key] = [...items]
|
|
1454
|
+
rows_new = parent[last_key]
|
|
1455
|
+
})
|
|
1456
|
+
console.log("variables22", deep_copy(variables))
|
|
1457
|
+
console.log("rows_new", rows_new)
|
|
1458
|
+
return { is_success: true, rows: rows_new }
|
|
1459
|
+
}
|
|
1460
|
+
if (input?.type == "delete_row") {
|
|
1461
|
+
console.log("delete_row", input)
|
|
1462
|
+
const path = input?.path
|
|
1463
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1464
|
+
if (Array.isArray(parent)) {
|
|
1465
|
+
parent.splice(last_key, 1)
|
|
1466
|
+
} else if (Array.isArray(parent[last_key])) {
|
|
1467
|
+
parent[last_key].splice(last_key, 1)
|
|
1468
|
+
} else {
|
|
1469
|
+
delete parent[last_key]
|
|
1470
|
+
}
|
|
1471
|
+
})
|
|
1472
|
+
return { is_success: true }
|
|
1473
|
+
}
|
|
1474
|
+
if (input?.type == "bulk_delete_rows") {
|
|
1475
|
+
console.log("bulk_delete_rows")
|
|
1476
|
+
const path = input?.path
|
|
1477
|
+
let deleted_row_ids = []
|
|
1478
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1479
|
+
let the_arr
|
|
1480
|
+
if (Array.isArray(parent[last_key])) {
|
|
1481
|
+
the_arr = parent[last_key]
|
|
1482
|
+
} else if (Array.isArray(parent)) {
|
|
1483
|
+
the_arr = parent
|
|
1484
|
+
} else {
|
|
1485
|
+
return
|
|
1486
|
+
}
|
|
1487
|
+
const sorted_indexes = (input?.row_indexes || []).slice().sort((a, b) => b - a)
|
|
1488
|
+
for (let idx of sorted_indexes) {
|
|
1489
|
+
const row = the_arr[idx]
|
|
1490
|
+
if (row?.id) deleted_row_ids.push(row.id)
|
|
1491
|
+
the_arr.splice(idx, 1)
|
|
1492
|
+
}
|
|
1493
|
+
})
|
|
1485
1494
|
return {
|
|
1486
1495
|
is_success: true,
|
|
1487
|
-
|
|
1496
|
+
deleted_row_ids: deleted_row_ids,
|
|
1488
1497
|
}
|
|
1489
|
-
}
|
|
1498
|
+
}
|
|
1499
|
+
if (input?.type == "insert_column") {
|
|
1490
1500
|
console.log("insert_column", deep_copy(input))
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
column: input?.column,
|
|
1495
|
-
}
|
|
1496
|
-
} else if (input?.type == "update_column") {
|
|
1501
|
+
return { is_success: true, column_id: input?.column?.id, column: input?.column }
|
|
1502
|
+
}
|
|
1503
|
+
if (input?.type == "update_column") {
|
|
1497
1504
|
console.log("update_column", deep_copy(input))
|
|
1498
|
-
return {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1502
|
-
} else if (input?.type == "delete_column") {
|
|
1505
|
+
return { is_success: true, column_id: input?.column_id, column: input?.column }
|
|
1506
|
+
}
|
|
1507
|
+
if (input?.type == "delete_column") {
|
|
1503
1508
|
console.log("delete_column", deep_copy(input))
|
|
1504
|
-
return {
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
column: input?.column,
|
|
1508
|
-
}
|
|
1509
|
-
} else if (input?.type == "update_table_name") {
|
|
1509
|
+
return { is_success: true, column_id: input?.column_id }
|
|
1510
|
+
}
|
|
1511
|
+
if (input?.type == "update_table_name") {
|
|
1510
1512
|
console.log("update_table_name", deep_copy(input))
|
|
1511
|
-
return {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
}
|
|
1515
|
-
} else if (input?.type == "update_table_description") {
|
|
1513
|
+
return { is_success: true, table_name: input?.table_name }
|
|
1514
|
+
}
|
|
1515
|
+
if (input?.type == "update_table_description") {
|
|
1516
1516
|
console.log("update_table_description", deep_copy(input))
|
|
1517
|
-
return {
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
}
|
|
1521
|
-
} else if (input?.type == "delete_table") {
|
|
1517
|
+
return { is_success: true, table_description: input?.table_description }
|
|
1518
|
+
}
|
|
1519
|
+
if (input?.type == "delete_table") {
|
|
1522
1520
|
console.log("delete_table", deep_copy(input))
|
|
1523
1521
|
return {
|
|
1524
1522
|
is_success: true,
|
|
1525
|
-
table_id:
|
|
1523
|
+
table_id: "abcdefg",
|
|
1526
1524
|
}
|
|
1527
|
-
}
|
|
1525
|
+
}
|
|
1526
|
+
if (input?.type == "load_more") {
|
|
1528
1527
|
console.log("load_more", deep_copy(input))
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1528
|
+
current_offset += 100
|
|
1529
|
+
const load_more_res_body = { rows: [], total_rows: current_offset + 100 }
|
|
1530
|
+
console.log("load_more_res_body", load_more_res_body)
|
|
1531
|
+
let is_more_to_load = false
|
|
1532
|
+
const path = input?.path
|
|
1533
|
+
mutate_variables_at_path(path, (parent, last_key) => {
|
|
1534
|
+
if (Array.isArray(parent[last_key])) {
|
|
1535
|
+
parent[last_key].push(...load_more_res_body?.rows)
|
|
1536
|
+
is_more_to_load = parent[last_key].length < load_more_res_body?.total_rows
|
|
1537
|
+
} else {
|
|
1538
|
+
parent[last_key] = [...load_more_res_body?.rows]
|
|
1539
|
+
is_more_to_load = parent[last_key].length < load_more_res_body?.total_rows
|
|
1540
|
+
}
|
|
1541
|
+
})
|
|
1542
|
+
console.log("variables_load_more", variables)
|
|
1543
|
+
return { is_success: true, is_more_to_load }
|
|
1534
1544
|
}
|
|
1535
1545
|
console.log("unaccounted event", input)
|
|
1536
1546
|
},
|
|
1537
1547
|
})
|
|
1548
|
+
|
|
1549
|
+
function mutate_variables_at_path(path, mutator) {
|
|
1550
|
+
const root = { variables: deep_copy(variables) }
|
|
1551
|
+
let target = root
|
|
1552
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
1553
|
+
if (target[path[i]] === undefined || target[path[i]] === null) {
|
|
1554
|
+
target[path[i]] = typeof path[i + 1] === "number" ? [] : {}
|
|
1555
|
+
}
|
|
1556
|
+
target = target[path[i]]
|
|
1557
|
+
}
|
|
1558
|
+
const last_key = path[path.length - 1]
|
|
1559
|
+
mutator(target, last_key)
|
|
1560
|
+
variables = root.variables
|
|
1561
|
+
table_manager.reset_definition_stack([{ variables }])
|
|
1562
|
+
}
|
|
1538
1563
|
</script>
|
|
1539
1564
|
|
|
1540
1565
|
<div>
|