sveltekit-ui 1.0.12 → 1.0.14
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/Content/index.svelte.js +11 -47
- package/dist/Components/ContentInput/index.svelte.js +3 -1
- package/dist/Components/TableAdvanced/ColumnInput/index.svelte.js +16 -6
- package/dist/Components/TableAdvanced/index.svelte.js +110 -82
- package/dist/client/index.js +49 -3
- package/dist/index.js +5 -0
- package/package.json +1 -1
- package/src/lib/Components/Content/index.svelte.js +11 -47
- package/src/lib/Components/ContentInput/index.svelte.js +3 -1
- package/src/lib/Components/TableAdvanced/ColumnInput/index.svelte.js +16 -6
- package/src/lib/Components/TableAdvanced/index.svelte.js +110 -82
- package/src/lib/client/index.js +49 -3
- package/src/lib/index.js +5 -0
- package/src/routes/[component]/Showcase/TableAdvanced/index.svelte +37 -175
|
@@ -26,7 +26,15 @@ import { create_qr_manager } from "../Qr/index.svelte.js"
|
|
|
26
26
|
import { create_file_input_manager } from "../FileInput/index.svelte.js"
|
|
27
27
|
import { create_cron_input_manager } from "../CronInput/index.svelte.js"
|
|
28
28
|
import { create_button_manager } from "../Button/index.svelte.js"
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
node_types,
|
|
31
|
+
deep_copy,
|
|
32
|
+
set_closurable,
|
|
33
|
+
create_unique_id,
|
|
34
|
+
copy_to_clipboard,
|
|
35
|
+
get_def_from_variable_path,
|
|
36
|
+
is_defined,
|
|
37
|
+
} from "../../client/index.js"
|
|
30
38
|
|
|
31
39
|
export function create_content_manager(config) {
|
|
32
40
|
const id = create_unique_id(null, 20)
|
|
@@ -36,57 +44,13 @@ export function create_content_manager(config) {
|
|
|
36
44
|
let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
|
|
37
45
|
let val_prepped = $state(null)
|
|
38
46
|
|
|
39
|
-
function get_def(input) {
|
|
40
|
-
for (let item of definition_stack) {
|
|
41
|
-
if (item.hasOwnProperty(input)) {
|
|
42
|
-
return item?.[input]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function get_def_from_variable_path(input) {
|
|
49
|
-
let val = null
|
|
50
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
51
|
-
val = get_def(input?.[0])
|
|
52
|
-
for (let i = 1; i < input.length; i++) {
|
|
53
|
-
if (Array.isArray(input?.[i])) {
|
|
54
|
-
const res = get_def_from_variable_path(input?.[i])
|
|
55
|
-
val = val?.[res]
|
|
56
|
-
} else {
|
|
57
|
-
val = val?.[input?.[i]]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return val
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function is_defined(input) {
|
|
65
|
-
for (let item of definition_stack) {
|
|
66
|
-
if (item.hasOwnProperty(input)) {
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function set_def(identifier, value) {
|
|
74
|
-
console.log("set_def", identifier, value)
|
|
75
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
76
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
77
|
-
definition_stack[i][identifier] = value
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
47
|
function clean_attributes_from_variable_path(attributes) {
|
|
84
48
|
let cleaned_attributes = attributes
|
|
85
49
|
if (Object.keys(attributes || {}).length) {
|
|
86
50
|
for (let [att_key, att_val] of Object.entries(attributes)) {
|
|
87
51
|
if (att_key.endsWith("_from_variable_path") && att_val != null) {
|
|
88
52
|
const att_key_to_set = att_key.split("_from_variable_path")?.[0]
|
|
89
|
-
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val)
|
|
53
|
+
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val, definition_stack)
|
|
90
54
|
}
|
|
91
55
|
}
|
|
92
56
|
}
|
|
@@ -128,7 +92,7 @@ export function create_content_manager(config) {
|
|
|
128
92
|
function clean_variable_path(input) {
|
|
129
93
|
let cleaned_path = []
|
|
130
94
|
if (Array.isArray(input) && input.length > 0) {
|
|
131
|
-
let is_def = is_defined(input?.[0])
|
|
95
|
+
let is_def = is_defined(input?.[0], definition_stack)
|
|
132
96
|
if (!is_def) {
|
|
133
97
|
return []
|
|
134
98
|
}
|
|
@@ -72,7 +72,9 @@ export function create_content_input_manager(config) {
|
|
|
72
72
|
|
|
73
73
|
function get_defined_options(selector_id) {
|
|
74
74
|
const defined_at_selector_id = get_defined_at_selector_id(selector_id)
|
|
75
|
-
const defined_data_type = json_to_data_type(
|
|
75
|
+
const defined_data_type = json_to_data_type(
|
|
76
|
+
Object.assign({}, ...[...(Array.isArray(definition_stack) ? definition_stack : [])].reverse())
|
|
77
|
+
)
|
|
76
78
|
return Object.entries({ ...(defined_data_type?.properties || {}), ...defined_at_selector_id }).map(
|
|
77
79
|
([key, val]) => ({
|
|
78
80
|
key,
|
|
@@ -39,6 +39,7 @@ export function create_column_input_manager(config) {
|
|
|
39
39
|
let column_is_cascade_checkbox_manager = $state(null)
|
|
40
40
|
let guess_header_content_button_manager = $state(null)
|
|
41
41
|
let guess_body_content_button_manager = $state(null)
|
|
42
|
+
let definition_stack = $state(null)
|
|
42
43
|
|
|
43
44
|
let default_value = $state(null)
|
|
44
45
|
|
|
@@ -48,11 +49,10 @@ export function create_column_input_manager(config) {
|
|
|
48
49
|
let delete_column_cancel_button_manager = $state(null)
|
|
49
50
|
|
|
50
51
|
let rows_data_from_variable_path = $derived(set_closurable(config?.rows_data_from_variable_path, null))
|
|
52
|
+
let row_iter_identifier = $derived(set_closurable(config?.row_iter_identifier, "row_i"))
|
|
51
53
|
let columns = $derived(set_closurable(config?.columns, null))
|
|
52
54
|
let columns_length = $derived(Object.keys(columns || {}).length)
|
|
53
|
-
let row_data_type = $derived(set_closurable(config?.row_data_type, null))
|
|
54
55
|
let column_id = $derived(set_closurable(config?.column_id, null))
|
|
55
|
-
let definition_stack = $derived(set_closurable(config?.definition_stack, null))
|
|
56
56
|
let is_column_update = $derived(set_closurable(config?.is_column_update, true))
|
|
57
57
|
let column_input_options = $derived(set_closurable(config?.column_input_options, null))
|
|
58
58
|
|
|
@@ -105,8 +105,13 @@ export function create_column_input_manager(config) {
|
|
|
105
105
|
is_cascade: column_is_cascade_checkbox_manager?.val,
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
function reset_definition_stack(input) {
|
|
109
|
+
definition_stack = input
|
|
110
|
+
}
|
|
111
|
+
|
|
108
112
|
function init(config) {
|
|
109
113
|
console.log("column_input_init", config)
|
|
114
|
+
definition_stack = config?.definition_stack
|
|
110
115
|
column_id_text_input_manager = create_text_input_manager({
|
|
111
116
|
label: "Column ID",
|
|
112
117
|
val: config?.column_id ?? config?.val?.id ?? null,
|
|
@@ -125,7 +130,7 @@ export function create_column_input_manager(config) {
|
|
|
125
130
|
val: config?.val?.body_content ?? null,
|
|
126
131
|
storage: config?.storage,
|
|
127
132
|
storage_default_folder_path: null,
|
|
128
|
-
definition_stack:
|
|
133
|
+
definition_stack: definition_stack,
|
|
129
134
|
on_event: (input) => {
|
|
130
135
|
console.log("set_definition_stack_tbd33")
|
|
131
136
|
set_definition_stack(input)
|
|
@@ -189,14 +194,14 @@ export function create_column_input_manager(config) {
|
|
|
189
194
|
column_db_data_type_input_manager = create_data_type_input_manager({
|
|
190
195
|
// data_sample: () => variables,
|
|
191
196
|
table_options: config?.table_options,
|
|
192
|
-
val: config?.val?.db_data_type
|
|
197
|
+
val: config?.val?.db_data_type,
|
|
193
198
|
on_finish: (input) => {
|
|
194
199
|
let default_content_input_astc = variables_data_type_remaining_to_astc(input, "input", ["rows"])
|
|
195
200
|
column_default_value_content_manager = create_content_manager({
|
|
196
201
|
val: default_content_input_astc,
|
|
197
202
|
table_options: config?.table_options,
|
|
198
203
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
199
|
-
definition_stack:
|
|
204
|
+
definition_stack: definition_stack,
|
|
200
205
|
on_event: (input) => {
|
|
201
206
|
const res = set_definition_stack(
|
|
202
207
|
input,
|
|
@@ -278,7 +283,11 @@ export function create_column_input_manager(config) {
|
|
|
278
283
|
let guessed_column_display_content = variables_data_type_remaining_to_astc(
|
|
279
284
|
column_db_data_type_input_manager?.val,
|
|
280
285
|
"display",
|
|
281
|
-
[
|
|
286
|
+
[
|
|
287
|
+
...(Array.isArray(rows_data_from_variable_path) ? rows_data_from_variable_path : []),
|
|
288
|
+
[row_iter_identifier],
|
|
289
|
+
column_id_text_input_manager.val,
|
|
290
|
+
]
|
|
282
291
|
)
|
|
283
292
|
console.log("guessed_column_display_content", guessed_column_display_content)
|
|
284
293
|
body_content_input_manager.add_version(guessed_column_display_content)
|
|
@@ -443,5 +452,6 @@ export function create_column_input_manager(config) {
|
|
|
443
452
|
get columns_length() {
|
|
444
453
|
return columns_length
|
|
445
454
|
},
|
|
455
|
+
reset_definition_stack,
|
|
446
456
|
}
|
|
447
457
|
}
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
json_to_csv,
|
|
15
15
|
csv_to_json,
|
|
16
16
|
create_unique_id,
|
|
17
|
-
set_closurable,
|
|
18
|
-
get_data_type_at_path,
|
|
19
17
|
set_definition_stack,
|
|
18
|
+
set_def,
|
|
19
|
+
get_def_from_variable_path,
|
|
20
|
+
variables_data_type_remaining_to_astc,
|
|
20
21
|
} from "../../client/index.js"
|
|
21
22
|
import { tick } from "svelte"
|
|
22
23
|
import { browser } from "$app/environment"
|
|
@@ -95,6 +96,7 @@ export function create_table_advanced_manager(config) {
|
|
|
95
96
|
let column_edit_input_manager = $state(null)
|
|
96
97
|
let column_edit_upsert_column_button_manager = $state(null)
|
|
97
98
|
|
|
99
|
+
let row_edit_def_identifier = $state("edit_row_1001234")
|
|
98
100
|
let row_edit_index = $state(null)
|
|
99
101
|
let preempt_insert_row_popover_manager = $state(null)
|
|
100
102
|
let row_edit_content_manager = $state(null)
|
|
@@ -106,9 +108,7 @@ export function create_table_advanced_manager(config) {
|
|
|
106
108
|
let is_loading_rows = $state(false)
|
|
107
109
|
let loading_rows_progress = $state(0)
|
|
108
110
|
|
|
109
|
-
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path))
|
|
110
|
-
let row_data_type = $state(null)
|
|
111
|
-
|
|
111
|
+
let rows_data = $derived(get_def_from_variable_path(rows_data_from_variable_path, definition_stack))
|
|
112
112
|
let row_indexes_display_order = $derived(get_available_row_indexes())
|
|
113
113
|
let row_indexes_display_order_shown = $derived(get_row_indexes_shown())
|
|
114
114
|
|
|
@@ -126,53 +126,6 @@ export function create_table_advanced_manager(config) {
|
|
|
126
126
|
: []
|
|
127
127
|
)
|
|
128
128
|
|
|
129
|
-
function get_def(input, definition_stack_loc) {
|
|
130
|
-
let definition_stack_to_use = definition_stack_loc ?? definition_stack
|
|
131
|
-
if (Array.isArray(definition_stack_to_use)) {
|
|
132
|
-
for (let item of definition_stack_to_use) {
|
|
133
|
-
if (item.hasOwnProperty(input)) {
|
|
134
|
-
return item?.[input]
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function get_def_from_variable_path(input, definition_stack_loc) {
|
|
142
|
-
let val = null
|
|
143
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
144
|
-
val = get_def(input?.[0], definition_stack_loc)
|
|
145
|
-
for (let i = 1; i < input.length; i++) {
|
|
146
|
-
if (Array.isArray(input?.[i])) {
|
|
147
|
-
const res = get_def_from_variable_path(input?.[i], definition_stack_loc)
|
|
148
|
-
val = val?.[res]
|
|
149
|
-
} else {
|
|
150
|
-
val = val?.[input?.[i]]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return val
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function is_defined(input) {
|
|
158
|
-
for (let item of definition_stack) {
|
|
159
|
-
if (item.hasOwnProperty(input)) {
|
|
160
|
-
return true
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return false
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function set_def(identifier, value) {
|
|
167
|
-
console.log("set_def", identifier, value)
|
|
168
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
169
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
170
|
-
definition_stack[i][identifier] = value
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
129
|
function get_available_row_indexes() {
|
|
177
130
|
let row_indexes = []
|
|
178
131
|
if (
|
|
@@ -411,14 +364,13 @@ export function create_table_advanced_manager(config) {
|
|
|
411
364
|
foreign_table_id: column?.foreign_table_id,
|
|
412
365
|
is_cascade: column?.is_cascade,
|
|
413
366
|
},
|
|
367
|
+
row_iter_identifier: row_iter_identifier,
|
|
368
|
+
rows_data_from_variable_path: rows_data_from_variable_path,
|
|
414
369
|
column_input_options: config?.column_input_options,
|
|
415
370
|
table_options: config?.table_options,
|
|
416
371
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
417
|
-
|
|
418
|
-
definition_stack: () => definition_stack,
|
|
372
|
+
definition_stack: definition_stack,
|
|
419
373
|
columns: () => columns_prepped,
|
|
420
|
-
rows_data_from_variable_path: () => rows_data_from_variable_path,
|
|
421
|
-
row_data_type: () => row_data_type,
|
|
422
374
|
on_delete: async () => {
|
|
423
375
|
if (typeof config?.on_event == "function") {
|
|
424
376
|
const res = await config?.on_event({
|
|
@@ -518,39 +470,28 @@ export function create_table_advanced_manager(config) {
|
|
|
518
470
|
|
|
519
471
|
function edit_row(row_i) {
|
|
520
472
|
row_edit_index = row_i
|
|
521
|
-
let definition_stack_loc = $state([{ [row_iter_identifier]: row_i }, ...definition_stack])
|
|
522
473
|
const path_to_set = [...rows_data_from_variable_path, Number.isInteger(row_i) ? row_i : 0]
|
|
474
|
+
let editable_row = null
|
|
523
475
|
if (!Number.isInteger(row_i)) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (target === undefined) break
|
|
529
|
-
}
|
|
530
|
-
const last_key = path_to_set[path_to_set.length - 1]
|
|
531
|
-
if (Array.isArray(target[last_key])) {
|
|
532
|
-
target[last_key].splice(0, 0, row_default_to_insert)
|
|
533
|
-
} else {
|
|
534
|
-
target[last_key] = row_default_to_insert
|
|
535
|
-
}
|
|
476
|
+
console.log("columns_prepped", columns_prepped)
|
|
477
|
+
editable_row = {}
|
|
478
|
+
} else {
|
|
479
|
+
editable_row = get_def_from_variable_path([...rows_data_from_variable_path, row_i], definition_stack)
|
|
536
480
|
}
|
|
481
|
+
let row_definition_stack = $state([{ [row_edit_def_identifier]: editable_row }, ...definition_stack])
|
|
537
482
|
row_edit_content_manager = null
|
|
538
483
|
setTimeout(() => {
|
|
539
484
|
// quick fix for when update row then edit a diff row the data for other doesnt remain in place
|
|
540
|
-
console.log("row_input_content2222", { row_input_content, ds: [{ row_i }, ...definition_stack] })
|
|
541
485
|
row_edit_content_manager = create_content_manager({
|
|
542
486
|
val: row_input_content ?? null,
|
|
543
|
-
|
|
544
|
-
table_options: config?.table_options,
|
|
487
|
+
definition_stack: row_definition_stack,
|
|
545
488
|
mapkit_js_token: mapkit_js_token,
|
|
489
|
+
storage_items: null, // tbd
|
|
546
490
|
on_search_table_row_ids: config?.on_search_table_row_ids,
|
|
547
|
-
definition_stack: [{ row_i }, ...definition_stack],
|
|
548
491
|
on_event: (input) => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
definition_stack_loc = res?.definition_stack
|
|
553
|
-
const row_data = get_def_from_variable_path(path_to_set, definition_stack_loc)
|
|
492
|
+
const res = set_definition_stack(input, row_definition_stack)
|
|
493
|
+
row_definition_stack = res?.definition_stack
|
|
494
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
554
495
|
return {
|
|
555
496
|
is_success: true,
|
|
556
497
|
data: {
|
|
@@ -566,8 +507,8 @@ export function create_table_advanced_manager(config) {
|
|
|
566
507
|
is_loading: () => upsert_row_is_loading,
|
|
567
508
|
on_click: async () => {
|
|
568
509
|
upsert_row_is_loading = true
|
|
569
|
-
const row_data = get_def_from_variable_path(
|
|
570
|
-
console.log("edited_row", {
|
|
510
|
+
const row_data = get_def_from_variable_path([row_edit_def_identifier], row_definition_stack)
|
|
511
|
+
console.log("edited_row", { row_i, row_data })
|
|
571
512
|
if (Number.isInteger(row_i)) {
|
|
572
513
|
if (typeof config?.on_event == "function") {
|
|
573
514
|
const res = await config?.on_event({
|
|
@@ -603,6 +544,7 @@ export function create_table_advanced_manager(config) {
|
|
|
603
544
|
row: row_data,
|
|
604
545
|
path: path_to_set,
|
|
605
546
|
})
|
|
547
|
+
console.log("insert_row_res", { res, columns_prepped })
|
|
606
548
|
if (res?.is_success) {
|
|
607
549
|
preempt_insert_row_popover_manager.show_temp_message(
|
|
608
550
|
"Successfully inserted row",
|
|
@@ -677,9 +619,81 @@ export function create_table_advanced_manager(config) {
|
|
|
677
619
|
})
|
|
678
620
|
}
|
|
679
621
|
|
|
622
|
+
function guess_row_input_content(columns) {
|
|
623
|
+
return {
|
|
624
|
+
type_id: "div",
|
|
625
|
+
selector_id: create_unique_id(null, 8),
|
|
626
|
+
children: Object.entries(columns || {})
|
|
627
|
+
.sort(([a_column_id, a_val], [b_column_id, b_val]) => {
|
|
628
|
+
const a_order = a_val?.display_order ?? 0
|
|
629
|
+
const b_order = b_val?.display_order ?? 0
|
|
630
|
+
return a_order - b_order
|
|
631
|
+
})
|
|
632
|
+
.map(([column_id, val]) => {
|
|
633
|
+
if (val?.is_autogenerated) {
|
|
634
|
+
// let guessed_column_display_content = variables_data_type_remaining_to_astc(val?.db_data_type, "display", [
|
|
635
|
+
// "variables",
|
|
636
|
+
// "rows",
|
|
637
|
+
// ["row_i"],
|
|
638
|
+
// column_id,
|
|
639
|
+
// ])
|
|
640
|
+
return {
|
|
641
|
+
type_id: "div",
|
|
642
|
+
selector_id: create_unique_id(null, 8),
|
|
643
|
+
children: [
|
|
644
|
+
{
|
|
645
|
+
type_id: "span",
|
|
646
|
+
selector_id: create_unique_id(null, 8),
|
|
647
|
+
children: [
|
|
648
|
+
{
|
|
649
|
+
type_id: "strong",
|
|
650
|
+
selector_id: create_unique_id(null, 8),
|
|
651
|
+
children: [],
|
|
652
|
+
attributes: { content: column_id },
|
|
653
|
+
},
|
|
654
|
+
{
|
|
655
|
+
type_id: "em",
|
|
656
|
+
selector_id: create_unique_id(null, 8),
|
|
657
|
+
children: [],
|
|
658
|
+
attributes: { content: " autogenerated " },
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
attributes: {},
|
|
662
|
+
},
|
|
663
|
+
// guessed_column_display_content,
|
|
664
|
+
{
|
|
665
|
+
type_id: "br",
|
|
666
|
+
selector_id: create_unique_id(null, 8),
|
|
667
|
+
children: [],
|
|
668
|
+
attributes: {},
|
|
669
|
+
},
|
|
670
|
+
],
|
|
671
|
+
attributes: {},
|
|
672
|
+
}
|
|
673
|
+
} else {
|
|
674
|
+
let guessed_column_input_content = variables_data_type_remaining_to_astc(val?.db_data_type, "input", [
|
|
675
|
+
row_edit_def_identifier,
|
|
676
|
+
column_id,
|
|
677
|
+
])
|
|
678
|
+
if (guessed_column_input_content?.hasOwnProperty("attributes")) {
|
|
679
|
+
if (!guessed_column_input_content.attributes) {
|
|
680
|
+
guessed_column_input_content.attributes = {}
|
|
681
|
+
}
|
|
682
|
+
guessed_column_input_content.attributes.label = column_id
|
|
683
|
+
}
|
|
684
|
+
return {
|
|
685
|
+
type_id: "div",
|
|
686
|
+
selector_id: create_unique_id(null, 8),
|
|
687
|
+
children: [guessed_column_input_content],
|
|
688
|
+
attributes: {},
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}),
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
680
695
|
function set_attributes(attributes) {
|
|
681
696
|
rows_data_from_variable_path = attributes?.rows_data_from_variable_path
|
|
682
|
-
row_input_content = attributes?.row_input_content
|
|
683
697
|
is_data_editable = attributes?.is_data_editable ?? false
|
|
684
698
|
nav_items = Array.isArray(attributes?.nav_items)
|
|
685
699
|
? attributes.nav_items.filter((item) =>
|
|
@@ -702,6 +716,18 @@ export function create_table_advanced_manager(config) {
|
|
|
702
716
|
table_row_max_height = attributes?.table_row_max_height ?? null
|
|
703
717
|
const columns_prepped_loc = set_columns_prepped(attributes?.columns)
|
|
704
718
|
set_rows_prepped(columns_prepped_loc)
|
|
719
|
+
row_input_content = attributes?.row_input_content ?? guess_row_input_content(attributes?.columns)
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function reset_definition_stack(input) {
|
|
723
|
+
console.log("reset_definition_stack", deep_copy(input))
|
|
724
|
+
definition_stack = input
|
|
725
|
+
set_rows_prepped(columns_prepped)
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function set_columns(input) {
|
|
729
|
+
set_columns_prepped(input)
|
|
730
|
+
set_rows_prepped(columns_prepped)
|
|
705
731
|
}
|
|
706
732
|
|
|
707
733
|
function init(config) {
|
|
@@ -709,7 +735,7 @@ export function create_table_advanced_manager(config) {
|
|
|
709
735
|
table_name = config?.table_name
|
|
710
736
|
table_description = config?.table_description
|
|
711
737
|
rows_data_from_variable_path = config?.rows_data_from_variable_path
|
|
712
|
-
row_iter_identifier = config?.row_iter_identifier
|
|
738
|
+
row_iter_identifier = config?.row_iter_identifier ?? "row_i"
|
|
713
739
|
definition_stack = config?.definition_stack
|
|
714
740
|
mapkit_js_token = config?.mapkit_js_token
|
|
715
741
|
set_attributes(config)
|
|
@@ -1417,5 +1443,7 @@ export function create_table_advanced_manager(config) {
|
|
|
1417
1443
|
download_csv,
|
|
1418
1444
|
copy_structure,
|
|
1419
1445
|
set_attributes,
|
|
1446
|
+
reset_definition_stack,
|
|
1447
|
+
set_columns,
|
|
1420
1448
|
}
|
|
1421
1449
|
}
|
package/dist/client/index.js
CHANGED
|
@@ -551,8 +551,56 @@ export function get_data_type_at_path(path, full_data_type) {
|
|
|
551
551
|
return data_type_at_path_loc
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
+
export function get_def(input, definition_stack) {
|
|
555
|
+
if (Array.isArray(definition_stack)) {
|
|
556
|
+
for (let item of definition_stack) {
|
|
557
|
+
if (item.hasOwnProperty(input)) {
|
|
558
|
+
return item?.[input]
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return null
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function get_def_from_variable_path(input, definition_stack) {
|
|
566
|
+
let val = null
|
|
567
|
+
if (Array.isArray(input) && input.length > 0) {
|
|
568
|
+
val = get_def(input?.[0], definition_stack)
|
|
569
|
+
for (let i = 1; i < input.length; i++) {
|
|
570
|
+
if (Array.isArray(input?.[i])) {
|
|
571
|
+
const res = get_def_from_variable_path(input?.[i], definition_stack)
|
|
572
|
+
val = val?.[res]
|
|
573
|
+
} else {
|
|
574
|
+
val = val?.[input?.[i]]
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return val
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export function is_defined(input, definition_stack) {
|
|
582
|
+
if (Array.isArray(definition_stack)) {
|
|
583
|
+
for (let item of definition_stack) {
|
|
584
|
+
if (item && typeof item == "object" && item.hasOwnProperty(input)) {
|
|
585
|
+
return true
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return false
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function set_def(identifier, value, definition_stack) {
|
|
593
|
+
if (Array.isArray(definition_stack)) {
|
|
594
|
+
for (let i = 0; i < definition_stack.length; i++) {
|
|
595
|
+
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
596
|
+
definition_stack[i][identifier] = value
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
return definition_stack
|
|
601
|
+
}
|
|
602
|
+
|
|
554
603
|
export function set_definition_stack(input, definition_stack, pass_event_down) {
|
|
555
|
-
console.log("set_definition_stack00", deep_copy({ input, definition_stack, pass_event_down }))
|
|
556
604
|
if (!Array.isArray(input?.variable_path_to_target) || !Array.isArray(definition_stack)) {
|
|
557
605
|
throw new Error("Path must be an array")
|
|
558
606
|
}
|
|
@@ -628,8 +676,6 @@ export function set_definition_stack(input, definition_stack, pass_event_down) {
|
|
|
628
676
|
temp[last_key] = input?.value
|
|
629
677
|
}
|
|
630
678
|
definition_stack[defined_i][root_key] = defined_variables_loc
|
|
631
|
-
console.log("defined_variables_loc112", defined_variables_loc)
|
|
632
|
-
console.log("vars_fin", deep_copy(definition_stack))
|
|
633
679
|
if (typeof pass_event_down === "function") {
|
|
634
680
|
pass_event_down({
|
|
635
681
|
value: input.value,
|
package/dist/index.js
CHANGED
|
@@ -153,6 +153,11 @@ export {
|
|
|
153
153
|
astc_to_email_html,
|
|
154
154
|
variables_data_type_remaining_to_astc,
|
|
155
155
|
hcl_to_hex,
|
|
156
|
+
get_def,
|
|
157
|
+
get_def_from_variable_path,
|
|
158
|
+
is_defined,
|
|
159
|
+
set_def,
|
|
160
|
+
set_definition_stack,
|
|
156
161
|
node_types,
|
|
157
162
|
content_types,
|
|
158
163
|
acceptable_storage_mime_types,
|
package/package.json
CHANGED
|
@@ -26,7 +26,15 @@ import { create_qr_manager } from "$lib/Components/Qr/index.svelte.js"
|
|
|
26
26
|
import { create_file_input_manager } from "$lib/Components/FileInput/index.svelte.js"
|
|
27
27
|
import { create_cron_input_manager } from "$lib/Components/CronInput/index.svelte.js"
|
|
28
28
|
import { create_button_manager } from "$lib/Components/Button/index.svelte.js"
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
node_types,
|
|
31
|
+
deep_copy,
|
|
32
|
+
set_closurable,
|
|
33
|
+
create_unique_id,
|
|
34
|
+
copy_to_clipboard,
|
|
35
|
+
get_def_from_variable_path,
|
|
36
|
+
is_defined,
|
|
37
|
+
} from "$lib/client/index.js"
|
|
30
38
|
|
|
31
39
|
export function create_content_manager(config) {
|
|
32
40
|
const id = create_unique_id(null, 20)
|
|
@@ -36,57 +44,13 @@ export function create_content_manager(config) {
|
|
|
36
44
|
let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
|
|
37
45
|
let val_prepped = $state(null)
|
|
38
46
|
|
|
39
|
-
function get_def(input) {
|
|
40
|
-
for (let item of definition_stack) {
|
|
41
|
-
if (item.hasOwnProperty(input)) {
|
|
42
|
-
return item?.[input]
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function get_def_from_variable_path(input) {
|
|
49
|
-
let val = null
|
|
50
|
-
if (Array.isArray(input) && input.length > 0) {
|
|
51
|
-
val = get_def(input?.[0])
|
|
52
|
-
for (let i = 1; i < input.length; i++) {
|
|
53
|
-
if (Array.isArray(input?.[i])) {
|
|
54
|
-
const res = get_def_from_variable_path(input?.[i])
|
|
55
|
-
val = val?.[res]
|
|
56
|
-
} else {
|
|
57
|
-
val = val?.[input?.[i]]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return val
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function is_defined(input) {
|
|
65
|
-
for (let item of definition_stack) {
|
|
66
|
-
if (item.hasOwnProperty(input)) {
|
|
67
|
-
return true
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function set_def(identifier, value) {
|
|
74
|
-
console.log("set_def", identifier, value)
|
|
75
|
-
for (let i = 0; i < definition_stack.length; i++) {
|
|
76
|
-
if (definition_stack[i].hasOwnProperty(identifier)) {
|
|
77
|
-
definition_stack[i][identifier] = value
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
console.log("definition_stack_after_Set", definition_stack)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
47
|
function clean_attributes_from_variable_path(attributes) {
|
|
84
48
|
let cleaned_attributes = attributes
|
|
85
49
|
if (Object.keys(attributes || {}).length) {
|
|
86
50
|
for (let [att_key, att_val] of Object.entries(attributes)) {
|
|
87
51
|
if (att_key.endsWith("_from_variable_path") && att_val != null) {
|
|
88
52
|
const att_key_to_set = att_key.split("_from_variable_path")?.[0]
|
|
89
|
-
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val)
|
|
53
|
+
cleaned_attributes[att_key_to_set] = get_def_from_variable_path(att_val, definition_stack)
|
|
90
54
|
}
|
|
91
55
|
}
|
|
92
56
|
}
|
|
@@ -128,7 +92,7 @@ export function create_content_manager(config) {
|
|
|
128
92
|
function clean_variable_path(input) {
|
|
129
93
|
let cleaned_path = []
|
|
130
94
|
if (Array.isArray(input) && input.length > 0) {
|
|
131
|
-
let is_def = is_defined(input?.[0])
|
|
95
|
+
let is_def = is_defined(input?.[0], definition_stack)
|
|
132
96
|
if (!is_def) {
|
|
133
97
|
return []
|
|
134
98
|
}
|
|
@@ -72,7 +72,9 @@ export function create_content_input_manager(config) {
|
|
|
72
72
|
|
|
73
73
|
function get_defined_options(selector_id) {
|
|
74
74
|
const defined_at_selector_id = get_defined_at_selector_id(selector_id)
|
|
75
|
-
const defined_data_type = json_to_data_type(
|
|
75
|
+
const defined_data_type = json_to_data_type(
|
|
76
|
+
Object.assign({}, ...[...(Array.isArray(definition_stack) ? definition_stack : [])].reverse())
|
|
77
|
+
)
|
|
76
78
|
return Object.entries({ ...(defined_data_type?.properties || {}), ...defined_at_selector_id }).map(
|
|
77
79
|
([key, val]) => ({
|
|
78
80
|
key,
|