sveltekit-ui 1.0.11 → 1.0.12
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 +12 -12
- package/dist/Components/Content/index.svelte.js +97 -49
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/Dropdown/index.svelte.js +1 -5
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/Number/index.svelte.js +1 -2
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/Qr/index.svelte.js +1 -3
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/Slider/index.svelte.js +2 -4
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/TableAdvanced/index.svelte.js +28 -32
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/TextInput/index.svelte.js +1 -3
- package/dist/Components/ContentInput/AttributesInput/CustomConfig/TimeInput/index.svelte.js +1 -3
- package/dist/Components/ContentInput/AttributesInput/DefinedTypeInput/index.svelte.js +3 -13
- package/dist/Components/ContentInput/AttributesInput/index.svelte +1 -0
- package/dist/Components/ContentInput/AttributesInput/index.svelte.js +89 -120
- package/dist/Components/ContentInput/index.svelte.js +38 -62
- package/dist/Components/DataTypeInput/index.svelte.js +0 -3
- package/dist/Components/IconInput/index.svelte +1 -1
- package/dist/Components/TableAdvanced/ColumnInput/index.svelte.js +15 -62
- package/dist/Components/TableAdvanced/SortByInput/index.svelte.js +2 -1
- package/dist/Components/TableAdvanced/index.svelte.js +72 -73
- package/dist/Components/TextInput/index.svelte.js +12 -0
- package/dist/Components/VariablePathInput/index.svelte +47 -93
- package/dist/Components/VariablePathInput/index.svelte.js +205 -191
- package/dist/client/astc_formatting/index.js +15 -58
- package/dist/client/docs/index.js +4 -23
- package/dist/client/index.js +38 -90
- package/dist/client/types/index.js +2 -0
- package/dist/index.js +2 -0
- package/package.json +4 -4
- package/src/lib/Components/Content/index.svelte +12 -12
- package/src/lib/Components/Content/index.svelte.js +97 -49
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Dropdown/index.svelte.js +1 -5
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Number/index.svelte.js +1 -2
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Qr/index.svelte.js +1 -3
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Slider/index.svelte.js +2 -4
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TableAdvanced/index.svelte.js +28 -32
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TextInput/index.svelte.js +1 -3
- package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TimeInput/index.svelte.js +1 -3
- package/src/lib/Components/ContentInput/AttributesInput/DefinedTypeInput/index.svelte.js +3 -13
- package/src/lib/Components/ContentInput/AttributesInput/index.svelte +1 -0
- package/src/lib/Components/ContentInput/AttributesInput/index.svelte.js +89 -120
- package/src/lib/Components/ContentInput/index.svelte.js +38 -62
- package/src/lib/Components/DataTypeInput/index.svelte.js +0 -3
- package/src/lib/Components/IconInput/index.svelte +1 -1
- package/src/lib/Components/TableAdvanced/ColumnInput/index.svelte.js +15 -62
- package/src/lib/Components/TableAdvanced/SortByInput/index.svelte.js +2 -1
- package/src/lib/Components/TableAdvanced/index.svelte.js +72 -73
- package/src/lib/Components/TextInput/index.svelte.js +12 -0
- package/src/lib/Components/VariablePathInput/index.svelte +47 -93
- package/src/lib/Components/VariablePathInput/index.svelte.js +205 -191
- package/src/lib/client/astc_formatting/index.js +15 -58
- package/src/lib/client/docs/index.js +4 -23
- package/src/lib/client/index.js +38 -90
- package/src/lib/client/types/index.js +2 -0
- package/src/lib/index.js +2 -0
- package/src/routes/[component]/Showcase/Content/index.svelte +49 -83
- package/src/routes/[component]/Showcase/ContentInput/index.svelte +11 -13
- package/src/routes/[component]/Showcase/TableAdvanced/index.svelte +71 -252
|
@@ -331,11 +331,11 @@ export function astc_to_markdown(astc) {
|
|
|
331
331
|
return astc_element_to_markdown(astc)
|
|
332
332
|
}
|
|
333
333
|
|
|
334
|
-
export function get_variable_from_path(path, variables,
|
|
334
|
+
export function get_variable_from_path(path, variables, defs) {
|
|
335
335
|
if (Array.isArray(path)) {
|
|
336
336
|
let combined_variables_loc = deep_copy({
|
|
337
337
|
variables: variables,
|
|
338
|
-
|
|
338
|
+
defs: defs,
|
|
339
339
|
})
|
|
340
340
|
for (let path_item of path) {
|
|
341
341
|
if (Array.isArray(path_item)) {
|
|
@@ -350,13 +350,13 @@ export function get_variable_from_path(path, variables, loops) {
|
|
|
350
350
|
return null
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
export function clean_variable_path(path, variables,
|
|
354
|
-
// eg. ['variables','dddd',['
|
|
353
|
+
export function clean_variable_path(path, variables, defs) {
|
|
354
|
+
// eg. ['variables','dddd',['defs',0]] to ['variables','dddd',3]
|
|
355
355
|
if (Array.isArray(path)) {
|
|
356
356
|
let cleaned_path = []
|
|
357
357
|
for (let path_item of path) {
|
|
358
358
|
if (Array.isArray(path_item)) {
|
|
359
|
-
let sub_val_from_path = get_variable_from_path(path_item, variables,
|
|
359
|
+
let sub_val_from_path = get_variable_from_path(path_item, variables, defs)
|
|
360
360
|
cleaned_path.push(sub_val_from_path)
|
|
361
361
|
} else {
|
|
362
362
|
cleaned_path.push(path_item)
|
|
@@ -367,14 +367,14 @@ export function clean_variable_path(path, variables, loops) {
|
|
|
367
367
|
return null
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
export function clean_attributes_from_variable_path(attributes, variables,
|
|
370
|
+
export function clean_attributes_from_variable_path(attributes, variables, defs) {
|
|
371
371
|
let cleaned_attributes = attributes
|
|
372
372
|
if (Object.keys(attributes || {}).length) {
|
|
373
373
|
for (let [att_key, att_val] of Object.entries(attributes)) {
|
|
374
374
|
if (att_key.endsWith("_from_variable_path") && att_val != null) {
|
|
375
|
-
const clean_path = clean_variable_path(att_val, variables,
|
|
375
|
+
const clean_path = clean_variable_path(att_val, variables, defs)
|
|
376
376
|
const att_key_to_set = att_key.split("_from_variable_path")?.[0]
|
|
377
|
-
cleaned_attributes[att_key_to_set] = get_variable_from_path(clean_path, variables,
|
|
377
|
+
cleaned_attributes[att_key_to_set] = get_variable_from_path(clean_path, variables, defs)
|
|
378
378
|
delete cleaned_attributes[att_key]
|
|
379
379
|
}
|
|
380
380
|
}
|
|
@@ -382,18 +382,18 @@ export function clean_attributes_from_variable_path(attributes, variables, loops
|
|
|
382
382
|
return cleaned_attributes
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
export function astc_to_static_attributes(astc, variables,
|
|
385
|
+
export function astc_to_static_attributes(astc, variables, defs) {
|
|
386
386
|
if ([undefined, null].includes(astc)) {
|
|
387
387
|
return null
|
|
388
388
|
}
|
|
389
389
|
let astc_loc = deep_copy(astc)
|
|
390
390
|
if (Object.keys(astc_loc?.attributes || {}).length > 0) {
|
|
391
|
-
astc_loc.attributes = clean_attributes_from_variable_path(astc_loc?.attributes, variables,
|
|
391
|
+
astc_loc.attributes = clean_attributes_from_variable_path(astc_loc?.attributes, variables, defs)
|
|
392
392
|
}
|
|
393
393
|
if (Array.isArray(astc_loc?.children)) {
|
|
394
394
|
let cleaned_children = []
|
|
395
395
|
for (let child of astc_loc.children) {
|
|
396
|
-
cleaned_children.push(astc_to_static_attributes(child, variables,
|
|
396
|
+
cleaned_children.push(astc_to_static_attributes(child, variables, defs))
|
|
397
397
|
}
|
|
398
398
|
astc_loc.children = cleaned_children
|
|
399
399
|
}
|
|
@@ -601,25 +601,6 @@ export function astc_to_email_html(astc, options, slots_html_and_text_body) {
|
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
function increase_loops_on_path(path) {
|
|
605
|
-
let cleaned_path = null
|
|
606
|
-
if (Array.isArray(path)) {
|
|
607
|
-
cleaned_path = []
|
|
608
|
-
for (let path_item of path) {
|
|
609
|
-
if (Array.isArray(path_item)) {
|
|
610
|
-
if (path_item?.[0] == "loops" && typeof path_item?.[1] == "number") {
|
|
611
|
-
cleaned_path.push(["loops", path_item?.[1] + 1])
|
|
612
|
-
} else {
|
|
613
|
-
cleaned_path.push(increase_loops_on_path(path_item))
|
|
614
|
-
}
|
|
615
|
-
} else {
|
|
616
|
-
cleaned_path.push(path_item)
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
return cleaned_path
|
|
621
|
-
}
|
|
622
|
-
|
|
623
604
|
export function variables_data_type_remaining_to_astc(
|
|
624
605
|
variables_data_type_remaining,
|
|
625
606
|
preferred_content_use = "display",
|
|
@@ -795,15 +776,9 @@ export function variables_data_type_remaining_to_astc(
|
|
|
795
776
|
})
|
|
796
777
|
} else if (variables_data_type_remaining?.type == "array_uniform_literal") {
|
|
797
778
|
if (preferred_content_use == "input") {
|
|
798
|
-
let leading_variable_path_children = increase_loops_on_path(leading_variable_path)
|
|
799
|
-
leading_variable_path_children = [
|
|
800
|
-
...(Array.isArray(leading_variable_path_children) ? leading_variable_path_children : []),
|
|
801
|
-
["loops", 0],
|
|
802
|
-
]
|
|
803
779
|
const child_astc = variables_data_type_remaining_to_astc(
|
|
804
780
|
variables_data_type_remaining?.items,
|
|
805
|
-
preferred_content_use
|
|
806
|
-
leading_variable_path_children
|
|
781
|
+
preferred_content_use
|
|
807
782
|
)
|
|
808
783
|
return astc_element("array_uniform_input", [child_astc], {
|
|
809
784
|
val_from_variable_path: leading_variable_path,
|
|
@@ -813,15 +788,9 @@ export function variables_data_type_remaining_to_astc(
|
|
|
813
788
|
// if (preferred_content_type == "object") {
|
|
814
789
|
// // maybe infer as table
|
|
815
790
|
// }
|
|
816
|
-
let leading_variable_path_children = increase_loops_on_path(leading_variable_path)
|
|
817
|
-
leading_variable_path_children = [
|
|
818
|
-
...(Array.isArray(leading_variable_path_children) ? leading_variable_path_children : []),
|
|
819
|
-
["loops", 0],
|
|
820
|
-
]
|
|
821
791
|
const child_astc = variables_data_type_remaining_to_astc(
|
|
822
792
|
variables_data_type_remaining?.items,
|
|
823
|
-
preferred_content_use
|
|
824
|
-
leading_variable_path_children
|
|
793
|
+
preferred_content_use
|
|
825
794
|
)
|
|
826
795
|
return astc_element("loop", [child_astc], {
|
|
827
796
|
val_from_variable_path: leading_variable_path,
|
|
@@ -840,30 +809,18 @@ export function variables_data_type_remaining_to_astc(
|
|
|
840
809
|
// return astc_element("list", children)
|
|
841
810
|
} else if (variables_data_type_remaining?.type == "object_uniform_literal") {
|
|
842
811
|
if (preferred_content_use == "input") {
|
|
843
|
-
let leading_variable_path_children = increase_loops_on_path(leading_variable_path)
|
|
844
|
-
leading_variable_path_children = [
|
|
845
|
-
...(Array.isArray(leading_variable_path_children) ? leading_variable_path_children : []),
|
|
846
|
-
["loops", 0],
|
|
847
|
-
]
|
|
848
812
|
const child_astc = variables_data_type_remaining_to_astc(
|
|
849
813
|
variables_data_type_remaining?.items,
|
|
850
|
-
preferred_content_use
|
|
851
|
-
leading_variable_path_children
|
|
814
|
+
preferred_content_use
|
|
852
815
|
)
|
|
853
816
|
return astc_element("object_uniform_input", [child_astc], {
|
|
854
817
|
val_from_variable_path: leading_variable_path,
|
|
855
818
|
...(variables_data_type_remaining?.attributes ?? {}),
|
|
856
819
|
})
|
|
857
820
|
}
|
|
858
|
-
let leading_variable_path_children = increase_loops_on_path(leading_variable_path)
|
|
859
|
-
leading_variable_path_children = [
|
|
860
|
-
...(Array.isArray(leading_variable_path_children) ? leading_variable_path_children : []),
|
|
861
|
-
["loops", 0],
|
|
862
|
-
]
|
|
863
821
|
const child_astc = variables_data_type_remaining_to_astc(
|
|
864
822
|
variables_data_type_remaining?.items,
|
|
865
|
-
preferred_content_use
|
|
866
|
-
leading_variable_path_children
|
|
823
|
+
preferred_content_use
|
|
867
824
|
)
|
|
868
825
|
return astc_element("object_uniform", [child_astc], {
|
|
869
826
|
val_from_variable_path: leading_variable_path,
|
|
@@ -2111,11 +2111,6 @@ export const definitions = {
|
|
|
2111
2111
|
default: null,
|
|
2112
2112
|
description: "external data object used by show_conditions or variable-based attributes",
|
|
2113
2113
|
},
|
|
2114
|
-
loops: {
|
|
2115
|
-
type: "any",
|
|
2116
|
-
default: null,
|
|
2117
|
-
description: "tracks current iteration indexes when rendering loop nodes",
|
|
2118
|
-
},
|
|
2119
2114
|
mapkit_js_token: {
|
|
2120
2115
|
type: "string",
|
|
2121
2116
|
default: null,
|
|
@@ -2176,13 +2171,9 @@ export const definitions = {
|
|
|
2176
2171
|
type: "object",
|
|
2177
2172
|
description: "the processed content node with type, manager, and possible children",
|
|
2178
2173
|
},
|
|
2179
|
-
|
|
2174
|
+
definition_stack: {
|
|
2180
2175
|
type: "any",
|
|
2181
|
-
description: "the variables reference passed in config, potentially used by show_conditions
|
|
2182
|
-
},
|
|
2183
|
-
loops: {
|
|
2184
|
-
type: "any",
|
|
2185
|
-
description: "the current loop indexes used within array or object loops",
|
|
2176
|
+
description: "the definition_stack variables reference passed in config, potentially used by show_conditions",
|
|
2186
2177
|
},
|
|
2187
2178
|
},
|
|
2188
2179
|
},
|
|
@@ -2212,20 +2203,10 @@ export const definitions = {
|
|
|
2212
2203
|
default: null,
|
|
2213
2204
|
description: "callback invoked for certain child content manager events",
|
|
2214
2205
|
},
|
|
2215
|
-
|
|
2216
|
-
type: "any",
|
|
2217
|
-
default: null,
|
|
2218
|
-
description: "external variables object for show_conditions or other variable-based usage",
|
|
2219
|
-
},
|
|
2220
|
-
loops: {
|
|
2221
|
-
type: "any",
|
|
2222
|
-
default: null,
|
|
2223
|
-
description: "loop iteration indexes used within array or object loops",
|
|
2224
|
-
},
|
|
2225
|
-
variables_data_type: {
|
|
2206
|
+
definition_stack: {
|
|
2226
2207
|
type: "any",
|
|
2227
2208
|
default: null,
|
|
2228
|
-
description: "
|
|
2209
|
+
description: "external definition_stack variables object for show_conditions or other variable-based usage",
|
|
2229
2210
|
},
|
|
2230
2211
|
mapkit_js_token: {
|
|
2231
2212
|
type: "string",
|
package/src/lib/client/index.js
CHANGED
|
@@ -551,20 +551,32 @@ 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
|
|
555
|
-
console.log("
|
|
556
|
-
if (!Array.isArray(input?.variable_path_to_target)) {
|
|
554
|
+
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
|
+
if (!Array.isArray(input?.variable_path_to_target) || !Array.isArray(definition_stack)) {
|
|
557
557
|
throw new Error("Path must be an array")
|
|
558
558
|
}
|
|
559
|
-
let
|
|
560
|
-
let temp = content_variables_loc
|
|
559
|
+
let defined_i = null
|
|
561
560
|
const path = input.variable_path_to_target
|
|
561
|
+
const root_key = path[0]
|
|
562
|
+
for (let i = 0; i < definition_stack.length; i++) {
|
|
563
|
+
if (definition_stack?.[i].hasOwnProperty(root_key)) {
|
|
564
|
+
defined_i = i
|
|
565
|
+
break
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (defined_i == null) {
|
|
569
|
+
throw new Error("Root key not found in stack")
|
|
570
|
+
}
|
|
571
|
+
let defined_variables_loc = deep_copy(definition_stack[defined_i][root_key])
|
|
572
|
+
let temp = defined_variables_loc
|
|
562
573
|
const last_key = path[path.length - 1]
|
|
563
|
-
for (let i =
|
|
574
|
+
for (let i = 1; i < path.length - 1; i++) {
|
|
564
575
|
const key = path[i]
|
|
565
576
|
if (!(key in temp) || typeof temp[key] !== "object" || temp[key] === null) {
|
|
566
|
-
|
|
567
|
-
|
|
577
|
+
const next_key = path[i + 1]
|
|
578
|
+
if (Number.isInteger(next_key)) {
|
|
579
|
+
temp[key] = []
|
|
568
580
|
} else {
|
|
569
581
|
temp[key] = {}
|
|
570
582
|
}
|
|
@@ -576,17 +588,26 @@ export function set_content_variables(input, variables_combined, pass_event_down
|
|
|
576
588
|
if (
|
|
577
589
|
typeof input?.index_to_insert_at === "number" &&
|
|
578
590
|
input?.index_to_insert_at >= 0 &&
|
|
579
|
-
input?.index_to_insert_at <= temp
|
|
591
|
+
input?.index_to_insert_at <= temp[last_key].length
|
|
580
592
|
) {
|
|
581
593
|
temp[last_key].splice(input.index_to_insert_at, 0, input.value)
|
|
582
594
|
} else {
|
|
583
595
|
temp[last_key].push(input.value)
|
|
584
596
|
}
|
|
597
|
+
} else if (Array.isArray(temp)) {
|
|
598
|
+
if (
|
|
599
|
+
typeof input?.index_to_insert_at === "number" &&
|
|
600
|
+
input?.index_to_insert_at >= 0 &&
|
|
601
|
+
input?.index_to_insert_at <= temp.length
|
|
602
|
+
) {
|
|
603
|
+
temp.splice(input.index_to_insert_at, 0, input.value)
|
|
604
|
+
} else {
|
|
605
|
+
temp.push(input.value)
|
|
606
|
+
}
|
|
585
607
|
} else {
|
|
586
608
|
temp[last_key] = [input.value]
|
|
587
609
|
}
|
|
588
610
|
} else if (input?.type == "set_variables_delete") {
|
|
589
|
-
console.log("set_variables_delete", deep_copy({ temp, last_key }))
|
|
590
611
|
if (Array.isArray(temp)) {
|
|
591
612
|
if (typeof last_key === "number" && last_key > -1 && last_key < temp.length) {
|
|
592
613
|
temp.splice(last_key, 1)
|
|
@@ -595,7 +616,6 @@ export function set_content_variables(input, variables_combined, pass_event_down
|
|
|
595
616
|
delete temp[last_key]
|
|
596
617
|
}
|
|
597
618
|
} else if (input?.type == "set_variables_key") {
|
|
598
|
-
console.log("set_variables_key", deep_copy({ temp, last_key }))
|
|
599
619
|
if (Array.isArray(temp)) {
|
|
600
620
|
throw new Error("Cannot change key in array")
|
|
601
621
|
} else if (typeof temp === "object" && temp?.hasOwnProperty(last_key)) {
|
|
@@ -607,107 +627,35 @@ export function set_content_variables(input, variables_combined, pass_event_down
|
|
|
607
627
|
} else {
|
|
608
628
|
temp[last_key] = input?.value
|
|
609
629
|
}
|
|
610
|
-
|
|
630
|
+
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))
|
|
611
633
|
if (typeof pass_event_down === "function") {
|
|
612
634
|
pass_event_down({
|
|
613
635
|
value: input.value,
|
|
614
|
-
|
|
636
|
+
definition_stack: definition_stack,
|
|
615
637
|
set_from_content_id: input.set_from_content_id,
|
|
616
638
|
variable_path_to_target: input.variable_path_to_target,
|
|
617
639
|
})
|
|
618
640
|
}
|
|
619
641
|
return {
|
|
620
642
|
is_success: true,
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
// export function set_content_variables(input, variables_combined, pass_event_down) {
|
|
626
|
-
// console.log("set_content_variables000", input)
|
|
627
|
-
// if (!Array.isArray(input?.variable_path_to_target)) {
|
|
628
|
-
// throw new Error("Path must be an array")
|
|
629
|
-
// }
|
|
630
|
-
// let content_variables_loc = deep_copy(variables_combined)
|
|
631
|
-
// let temp = content_variables_loc
|
|
632
|
-
// const path = input.variable_path_to_target
|
|
633
|
-
// const last_key = path[path.length - 1]
|
|
634
|
-
// for (let i = 0; i < path.length - 1; i++) {
|
|
635
|
-
// const key = path[i]
|
|
636
|
-
// const nextKey = path[i + 1]
|
|
637
|
-
|
|
638
|
-
// if (!(key in temp) || typeof temp[key] !== "object" || temp[key] === null) {
|
|
639
|
-
// if (typeof nextKey === "number") {
|
|
640
|
-
// temp[key] = []
|
|
641
|
-
// } else {
|
|
642
|
-
// temp[key] = {}
|
|
643
|
-
// }
|
|
644
|
-
// }
|
|
645
|
-
// temp = temp[key]
|
|
646
|
-
// }
|
|
647
|
-
// if (input?.type == "set_variables_insert") {
|
|
648
|
-
// if (Array.isArray(temp[last_key])) {
|
|
649
|
-
// if (
|
|
650
|
-
// typeof input?.index_to_insert_at === "number" &&
|
|
651
|
-
// input?.index_to_insert_at >= 0 &&
|
|
652
|
-
// input?.index_to_insert_at <= temp?.[last_key].length
|
|
653
|
-
// ) {
|
|
654
|
-
// temp[last_key].splice(input.index_to_insert_at, 0, input.value)
|
|
655
|
-
// } else {
|
|
656
|
-
// temp[last_key].push(input.value)
|
|
657
|
-
// }
|
|
658
|
-
// } else {
|
|
659
|
-
// temp[last_key] = [input.value]
|
|
660
|
-
// }
|
|
661
|
-
// } else if (input?.type == "set_variables_delete") {
|
|
662
|
-
// if (Array.isArray(temp)) {
|
|
663
|
-
// if (typeof last_key === "number" && last_key > -1 && last_key < temp.length) {
|
|
664
|
-
// temp.splice(last_key, 1)
|
|
665
|
-
// }
|
|
666
|
-
// } else if (typeof temp === "object" && temp?.hasOwnProperty(last_key)) {
|
|
667
|
-
// delete temp[last_key]
|
|
668
|
-
// }
|
|
669
|
-
// } else if (input?.type == "set_variables_key") {
|
|
670
|
-
// if (Array.isArray(temp)) {
|
|
671
|
-
// throw new Error("Cannot change key in array")
|
|
672
|
-
// } else if (typeof temp === "object" && temp?.hasOwnProperty(last_key)) {
|
|
673
|
-
// temp[input.value] = temp[last_key]
|
|
674
|
-
// delete temp[last_key]
|
|
675
|
-
// } else {
|
|
676
|
-
// throw new Error("Key not found in object")
|
|
677
|
-
// }
|
|
678
|
-
// } else {
|
|
679
|
-
// temp[last_key] = input?.value
|
|
680
|
-
// }
|
|
681
|
-
// if (typeof pass_event_down === "function") {
|
|
682
|
-
// pass_event_down({
|
|
683
|
-
// value: input.value,
|
|
684
|
-
// variables: content_variables_loc,
|
|
685
|
-
// set_from_content_id: input.set_from_content_id,
|
|
686
|
-
// variable_path_to_target: input.variable_path_to_target,
|
|
687
|
-
// })
|
|
688
|
-
// }
|
|
689
|
-
// return {
|
|
690
|
-
// is_success: true,
|
|
691
|
-
// variables: content_variables_loc,
|
|
692
|
-
// }
|
|
693
|
-
// }
|
|
643
|
+
definition_stack: definition_stack,
|
|
644
|
+
}
|
|
645
|
+
}
|
|
694
646
|
|
|
695
647
|
// tbd could also turn into a typed thing with arrays of v or objects, color, etc
|
|
696
648
|
export function v(config) {
|
|
697
649
|
let val = $state(null)
|
|
698
|
-
|
|
699
650
|
function on_change(from_id = null) {
|
|
700
651
|
if (typeof config?.on_change == "function") {
|
|
701
652
|
config?.on_change({ val, from_id: from_id })
|
|
702
653
|
}
|
|
703
654
|
}
|
|
704
|
-
|
|
705
655
|
function init(config) {
|
|
706
656
|
val = config?.val
|
|
707
657
|
}
|
|
708
|
-
|
|
709
658
|
init(config)
|
|
710
|
-
|
|
711
659
|
return {
|
|
712
660
|
get val() {
|
|
713
661
|
return val
|
|
@@ -1996,6 +1996,8 @@ export const content_types = {
|
|
|
1996
1996
|
type: "variable_path_literal",
|
|
1997
1997
|
allowed_types: ["array_uniform_literal", "object_uniform_literal"],
|
|
1998
1998
|
},
|
|
1999
|
+
iter_identifier: { type: "text_literal" },
|
|
2000
|
+
join_text: { type: "text_literal" },
|
|
1999
2001
|
},
|
|
2000
2002
|
child_elements: {
|
|
2001
2003
|
...main_child_element_options,
|
package/src/lib/index.js
CHANGED
|
@@ -76,6 +76,8 @@ export { default as Popover } from "./Components/Popover/index.svelte"
|
|
|
76
76
|
export { create_popover_manager } from "./Components/Popover/index.svelte.js"
|
|
77
77
|
export { default as TableAdvanced } from "./Components/TableAdvanced/index.svelte"
|
|
78
78
|
export { create_table_advanced_manager } from "./Components/TableAdvanced/index.svelte.js"
|
|
79
|
+
export { default as VariablePathInput } from "./Components/VariablePathInput/index.svelte"
|
|
80
|
+
export { create_variable_path_input_manager } from "./Components/VariablePathInput/index.svelte.js"
|
|
79
81
|
export { default as Spacer } from "./Components/Spacer/index.svelte"
|
|
80
82
|
export { default as TransparentBackground } from "./Components/TransparentBackground/index.svelte"
|
|
81
83
|
export { default as XFollow } from "./Components/XFollow/index.svelte"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import
|
|
2
|
+
import Content from "$lib/Components/Content/index.svelte"
|
|
3
3
|
import { create_content_manager } from "$lib/Components/Content/index.svelte.js"
|
|
4
4
|
import { PUBLIC_APPLE_MAPKIT_JS_API_KEY } from "$env/static/public"
|
|
5
|
+
import { deep_copy, set_definition_stack } from "$lib/client/index.js"
|
|
5
6
|
|
|
6
7
|
const val = {
|
|
7
8
|
type_id: "div",
|
|
@@ -37,108 +38,73 @@
|
|
|
37
38
|
attributes: {},
|
|
38
39
|
},
|
|
39
40
|
{
|
|
40
|
-
type_id: "
|
|
41
|
-
selector_id: "
|
|
41
|
+
type_id: "checkbox",
|
|
42
|
+
selector_id: "kdotcril",
|
|
43
|
+
children: [],
|
|
44
|
+
attributes: { val_from_variable_path: ["variables", "cccc"], type: "checkbox", size: null, color: null },
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type_id: "loop",
|
|
48
|
+
selector_id: "bwrgl",
|
|
42
49
|
children: [
|
|
43
50
|
{
|
|
44
|
-
type_id: "
|
|
45
|
-
selector_id: "
|
|
51
|
+
type_id: "h5",
|
|
52
|
+
selector_id: "clrzp",
|
|
46
53
|
children: [
|
|
47
54
|
{
|
|
48
|
-
type_id: "
|
|
49
|
-
selector_id: "
|
|
50
|
-
children: [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
type_id: "base_text",
|
|
57
|
-
selector_id: "base_text_jbdbr",
|
|
58
|
-
children: [],
|
|
59
|
-
attributes: { content: "You can make tables" },
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
attributes: {},
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type_id: "td",
|
|
66
|
-
selector_id: "td_kcizj",
|
|
67
|
-
children: [
|
|
68
|
-
{
|
|
69
|
-
type_id: "base_text",
|
|
70
|
-
selector_id: "base_text_wyfea",
|
|
71
|
-
children: [],
|
|
72
|
-
attributes: { content: "yes indeed" },
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
attributes: {},
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
attributes: {},
|
|
55
|
+
type_id: "base_text",
|
|
56
|
+
selector_id: "zsaou",
|
|
57
|
+
children: [],
|
|
58
|
+
attributes: {
|
|
59
|
+
content_from_variable_path: ["variables", "stuff", ["booly_i"]],
|
|
60
|
+
text_color: { l: 15, c: 13, h: 6, o: 24, is_dark_theme_invert: true },
|
|
61
|
+
},
|
|
79
62
|
},
|
|
80
63
|
],
|
|
81
64
|
attributes: {},
|
|
82
65
|
},
|
|
83
66
|
{
|
|
84
|
-
type_id: "
|
|
85
|
-
selector_id: "
|
|
86
|
-
children: [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
children: [
|
|
95
|
-
{
|
|
96
|
-
type_id: "base_text",
|
|
97
|
-
selector_id: "base_text_jbxot",
|
|
98
|
-
children: [],
|
|
99
|
-
attributes: { content: "and other stuff" },
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
attributes: {},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type_id: "td",
|
|
106
|
-
selector_id: "td_egqxj",
|
|
107
|
-
children: [
|
|
108
|
-
{
|
|
109
|
-
type_id: "base_text",
|
|
110
|
-
selector_id: "base_text_urtfy",
|
|
111
|
-
children: [],
|
|
112
|
-
attributes: { content: "certainly" },
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
attributes: {},
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
attributes: {},
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
attributes: {},
|
|
67
|
+
type_id: "checkbox",
|
|
68
|
+
selector_id: "lqvon",
|
|
69
|
+
children: [],
|
|
70
|
+
attributes: {
|
|
71
|
+
val_from_variable_path: ["variables", "stuff", ["booly_i"]],
|
|
72
|
+
size: 2.4,
|
|
73
|
+
type: "checkbox",
|
|
74
|
+
label: null,
|
|
75
|
+
name: null,
|
|
76
|
+
},
|
|
122
77
|
},
|
|
123
78
|
],
|
|
124
|
-
attributes: {
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type_id: "code",
|
|
128
|
-
selector_id: "code_mhlkk",
|
|
129
|
-
children: [],
|
|
130
|
-
attributes: { content: "Code blocks and more222", language: null },
|
|
79
|
+
attributes: { iter_identifier: "booly_i", val_from_variable_path: ["variables", "stuff"], join_text: null },
|
|
131
80
|
},
|
|
132
81
|
],
|
|
133
82
|
attributes: {},
|
|
134
83
|
}
|
|
135
84
|
|
|
136
|
-
let
|
|
85
|
+
let variables = $state({
|
|
86
|
+
cccc: false,
|
|
87
|
+
stuff: [false, true, false],
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
let content_manager = create_content_manager({
|
|
91
|
+
val,
|
|
92
|
+
definition_stack: [{ variables }],
|
|
93
|
+
// on_event: (input) => console.log("on_event", input),
|
|
94
|
+
on_event: (input) => {
|
|
95
|
+
console.log("on_event00", input)
|
|
96
|
+
const res = set_definition_stack(input, [{ variables: variables }], content_manager.pass_event_down)
|
|
97
|
+
variables = res?.definition_stack?.[0]?.variables
|
|
98
|
+
console.log("on_event01", res?.definition_stack)
|
|
99
|
+
return res
|
|
100
|
+
},
|
|
101
|
+
})
|
|
137
102
|
</script>
|
|
138
103
|
|
|
104
|
+
<pre>{JSON.stringify(variables, null, 2)}</pre>
|
|
139
105
|
<div>
|
|
140
106
|
<div style="max-width: 65rem; margin: auto;">
|
|
141
107
|
<h4>Example</h4>
|
|
142
|
-
<
|
|
108
|
+
<Content manager={content_manager} />
|
|
143
109
|
</div>
|
|
144
110
|
</div>
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { create_json_manager } from "$lib/Components/Json/index.svelte.js"
|
|
8
8
|
import DataTypeInput from "$lib/Components/DataTypeInput/index.svelte"
|
|
9
9
|
// import { create_data_type_input_manager } from "$lib/Components/DataTypeInput/index.svelte.js"
|
|
10
|
-
import { deep_copy,
|
|
10
|
+
import { deep_copy, set_definition_stack } from "$lib/client/index.js"
|
|
11
11
|
import { PUBLIC_APPLE_MAPKIT_JS_API_KEY } from "$env/static/public"
|
|
12
12
|
|
|
13
13
|
const content_variables_initial = {
|
|
@@ -258,7 +258,7 @@
|
|
|
258
258
|
selector_id: "zsaou",
|
|
259
259
|
children: [],
|
|
260
260
|
attributes: {
|
|
261
|
-
content_from_variable_path: ["variables", "dddd", ["
|
|
261
|
+
content_from_variable_path: ["variables", "dddd", ["booly_i"]],
|
|
262
262
|
text_color: { l: 15, c: 13, h: 6, o: 24, is_dark_theme_invert: true },
|
|
263
263
|
},
|
|
264
264
|
},
|
|
@@ -270,15 +270,14 @@
|
|
|
270
270
|
selector_id: "lqvon",
|
|
271
271
|
children: [],
|
|
272
272
|
attributes: {
|
|
273
|
-
val_from_variable_path: ["variables", "dddd", ["
|
|
274
|
-
size: 2.4,
|
|
273
|
+
val_from_variable_path: ["variables", "dddd", ["booly_i"]],
|
|
275
274
|
type: "checkbox",
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
size: 2.4,
|
|
276
|
+
color: null,
|
|
278
277
|
},
|
|
279
278
|
},
|
|
280
279
|
],
|
|
281
|
-
attributes: { val_from_variable_path: ["variables", "dddd"] },
|
|
280
|
+
attributes: { iter_identifier: "booly_i", val_from_variable_path: ["variables", "dddd"], join_text: null },
|
|
282
281
|
},
|
|
283
282
|
{
|
|
284
283
|
type_id: "show_conditions",
|
|
@@ -330,17 +329,16 @@
|
|
|
330
329
|
// storage: account_storage,
|
|
331
330
|
storage_default_folder_path: ["pages"],
|
|
332
331
|
mapkit_js_token: PUBLIC_APPLE_MAPKIT_JS_API_KEY,
|
|
333
|
-
|
|
334
|
-
variables: () => variables_json_manager?.val,
|
|
332
|
+
definition_stack: [{ variables: variables_json_manager?.val }],
|
|
335
333
|
on_event: (input) => {
|
|
336
334
|
console.log("on_event00", input)
|
|
337
|
-
const res =
|
|
335
|
+
const res = set_definition_stack(
|
|
338
336
|
input,
|
|
339
|
-
{ variables: variables_json_manager?.val },
|
|
337
|
+
[{ variables: variables_json_manager?.val }],
|
|
340
338
|
content_input_manager.pass_event_down
|
|
341
339
|
)
|
|
342
|
-
variables_json_manager.set_val(res?.
|
|
343
|
-
console.log("on_event01", res?.
|
|
340
|
+
variables_json_manager.set_val(res?.definition_stack)
|
|
341
|
+
console.log("on_event01", res?.definition_stack)
|
|
344
342
|
return res
|
|
345
343
|
},
|
|
346
344
|
})
|