sveltekit-ui 1.0.11 → 1.0.13

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.
Files changed (56) hide show
  1. package/dist/Components/Content/index.svelte +12 -12
  2. package/dist/Components/Content/index.svelte.js +73 -61
  3. package/dist/Components/ContentInput/AttributesInput/CustomConfig/Dropdown/index.svelte.js +1 -5
  4. package/dist/Components/ContentInput/AttributesInput/CustomConfig/Number/index.svelte.js +1 -2
  5. package/dist/Components/ContentInput/AttributesInput/CustomConfig/Qr/index.svelte.js +1 -3
  6. package/dist/Components/ContentInput/AttributesInput/CustomConfig/Slider/index.svelte.js +2 -4
  7. package/dist/Components/ContentInput/AttributesInput/CustomConfig/TableAdvanced/index.svelte.js +28 -32
  8. package/dist/Components/ContentInput/AttributesInput/CustomConfig/TextInput/index.svelte.js +1 -3
  9. package/dist/Components/ContentInput/AttributesInput/CustomConfig/TimeInput/index.svelte.js +1 -3
  10. package/dist/Components/ContentInput/AttributesInput/DefinedTypeInput/index.svelte.js +3 -13
  11. package/dist/Components/ContentInput/AttributesInput/index.svelte +1 -0
  12. package/dist/Components/ContentInput/AttributesInput/index.svelte.js +89 -120
  13. package/dist/Components/ContentInput/index.svelte.js +38 -62
  14. package/dist/Components/DataTypeInput/index.svelte.js +0 -3
  15. package/dist/Components/IconInput/index.svelte +1 -1
  16. package/dist/Components/TableAdvanced/ColumnInput/index.svelte.js +16 -64
  17. package/dist/Components/TableAdvanced/SortByInput/index.svelte.js +2 -1
  18. package/dist/Components/TableAdvanced/index.svelte.js +124 -98
  19. package/dist/Components/TextInput/index.svelte.js +12 -0
  20. package/dist/Components/VariablePathInput/index.svelte +47 -93
  21. package/dist/Components/VariablePathInput/index.svelte.js +205 -191
  22. package/dist/client/astc_formatting/index.js +15 -58
  23. package/dist/client/docs/index.js +4 -23
  24. package/dist/client/index.js +86 -90
  25. package/dist/client/types/index.js +2 -0
  26. package/dist/index.js +2 -0
  27. package/package.json +4 -4
  28. package/src/lib/Components/Content/index.svelte +12 -12
  29. package/src/lib/Components/Content/index.svelte.js +73 -61
  30. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Dropdown/index.svelte.js +1 -5
  31. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Number/index.svelte.js +1 -2
  32. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Qr/index.svelte.js +1 -3
  33. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/Slider/index.svelte.js +2 -4
  34. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TableAdvanced/index.svelte.js +28 -32
  35. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TextInput/index.svelte.js +1 -3
  36. package/src/lib/Components/ContentInput/AttributesInput/CustomConfig/TimeInput/index.svelte.js +1 -3
  37. package/src/lib/Components/ContentInput/AttributesInput/DefinedTypeInput/index.svelte.js +3 -13
  38. package/src/lib/Components/ContentInput/AttributesInput/index.svelte +1 -0
  39. package/src/lib/Components/ContentInput/AttributesInput/index.svelte.js +89 -120
  40. package/src/lib/Components/ContentInput/index.svelte.js +38 -62
  41. package/src/lib/Components/DataTypeInput/index.svelte.js +0 -3
  42. package/src/lib/Components/IconInput/index.svelte +1 -1
  43. package/src/lib/Components/TableAdvanced/ColumnInput/index.svelte.js +16 -64
  44. package/src/lib/Components/TableAdvanced/SortByInput/index.svelte.js +2 -1
  45. package/src/lib/Components/TableAdvanced/index.svelte.js +124 -98
  46. package/src/lib/Components/TextInput/index.svelte.js +12 -0
  47. package/src/lib/Components/VariablePathInput/index.svelte +47 -93
  48. package/src/lib/Components/VariablePathInput/index.svelte.js +205 -191
  49. package/src/lib/client/astc_formatting/index.js +15 -58
  50. package/src/lib/client/docs/index.js +4 -23
  51. package/src/lib/client/index.js +86 -90
  52. package/src/lib/client/types/index.js +2 -0
  53. package/src/lib/index.js +2 -0
  54. package/src/routes/[component]/Showcase/Content/index.svelte +49 -83
  55. package/src/routes/[component]/Showcase/ContentInput/index.svelte +11 -13
  56. package/src/routes/[component]/Showcase/TableAdvanced/index.svelte +108 -418
@@ -36,38 +36,50 @@ export function create_content_input_manager(config) {
36
36
  let paste_astc_markdown_finish_button_manager = $state(null)
37
37
  let location_to_add_element = $state(null)
38
38
  let content_manager = $state(null)
39
- let content_overall_manager = $state(null)
40
39
  let attributes_input = $state(null)
41
40
  let focused_selector_id = $state(null)
41
+ let definition_stack = $state([])
42
42
 
43
- let loops = $derived(set_closurable(config?.loops, null))
44
- let variables = $derived(set_closurable(config?.variables, null))
45
- let variables_data_type = $derived(set_closurable(config?.variables_data_type, null) ?? json_to_data_type(variables))
46
43
  let mapkit_js_token = $derived(set_closurable(config?.mapkit_js_token, null))
47
44
 
48
- function increase_loops_on_path(path) {
49
- let cleaned_path = null
50
- if (Array.isArray(path)) {
51
- cleaned_path = []
52
- for (let path_item of path) {
53
- if (Array.isArray(path_item)) {
54
- if (path_item?.[0] == "loops" && typeof path_item?.[1] == "number") {
55
- cleaned_path.push(["loops", path_item?.[1] + 1])
56
- } else {
57
- cleaned_path.push(increase_loops_on_path(path_item))
45
+ function pass_event_down(input) {
46
+ if (typeof content_manager?.pass_event_down == "function") {
47
+ content_manager?.pass_event_down(input)
48
+ }
49
+ }
50
+
51
+ function get_defined_at_selector_id(selector_id) {
52
+ function traverse(input) {
53
+ let defined = {}
54
+ if (input?.type_id == selector_id) {
55
+ return { defined, is_found_selector_id: true }
56
+ } else if (input?.type_id == "loop") {
57
+ defined[input?.attributes?.iter_identifier] = { type: "text_literal" }
58
+ }
59
+ if (Array.isArray(input?.children)) {
60
+ for (let child of input?.children) {
61
+ let res = traverse(child)
62
+ defined = { ...defined, ...res?.defined }
63
+ if (res?.is_found_selector_id) {
64
+ break
58
65
  }
59
- } else {
60
- cleaned_path.push(path_item)
61
66
  }
62
67
  }
68
+ return { defined }
63
69
  }
64
- return cleaned_path
70
+ return traverse(versions?.[selected_version_index])?.defined
65
71
  }
66
72
 
67
- function pass_event_down(input) {
68
- if (typeof content_manager?.pass_event_down == "function") {
69
- content_manager?.pass_event_down(input)
70
- }
73
+ function get_defined_options(selector_id) {
74
+ const defined_at_selector_id = get_defined_at_selector_id(selector_id)
75
+ const defined_data_type = json_to_data_type(Object.assign({}, ...[...definition_stack].reverse()))
76
+ return Object.entries({ ...(defined_data_type?.properties || {}), ...defined_at_selector_id }).map(
77
+ ([key, val]) => ({
78
+ key,
79
+ name: key,
80
+ data_type: val,
81
+ })
82
+ )
71
83
  }
72
84
 
73
85
  function set_selected_version(version_index) {
@@ -79,20 +91,13 @@ export function create_content_input_manager(config) {
79
91
  on_event: config?.on_event,
80
92
  storage_path: storage_path,
81
93
  mapkit_js_token: mapkit_js_token,
82
- variables: () => variables,
83
- loops: () => loops,
84
- })
85
- content_overall_manager = create_content_overall_manager()
86
- }
87
-
88
- function create_content_overall_manager() {
89
- return {
94
+ definition_stack: definition_stack,
90
95
  get focused_selector_id() {
91
96
  return focused_selector_id
92
97
  },
93
98
  set_focused_selector_id,
94
99
  open_edit_element_attributes_popover,
95
- }
100
+ })
96
101
  }
97
102
 
98
103
  function prep_element(element) {
@@ -123,7 +128,6 @@ export function create_content_input_manager(config) {
123
128
  })
124
129
  function open_edit_attributes_popover() {
125
130
  attributes_input.init({
126
- variables_data_type: () => variables_data_type,
127
131
  storage: storage,
128
132
  storage_default_folder_path: storage_default_folder_path,
129
133
  storage_path: storage_path,
@@ -133,8 +137,8 @@ export function create_content_input_manager(config) {
133
137
  content_type: element?.type_id,
134
138
  selector_id: element?.selector_id,
135
139
  val: element?.attributes,
140
+ get_defined_options: () => get_defined_options(element?.selector_id),
136
141
  on_finish: (input) => {
137
- console.log("on_finish_attribute", input)
138
142
  attributes_input.popover_manager.close()
139
143
  set_element_attributes(element?.selector_id, input)
140
144
  },
@@ -387,7 +391,6 @@ export function create_content_input_manager(config) {
387
391
  }
388
392
 
389
393
  function add_version(version) {
390
- // let new_version = version ? version : convert_prepped_to_version(selected_version_prepped)
391
394
  versions = [deep_copy(version), ...versions.slice(selected_version_index)]
392
395
  selected_version_index = 0
393
396
  set_selected_version(0)
@@ -396,25 +399,6 @@ export function create_content_input_manager(config) {
396
399
  }
397
400
  }
398
401
 
399
- // function convert_prepped_to_version(version_prepped) {
400
- // let element = version_prepped?.element
401
- // let cleaned_children = []
402
- // if (Array.isArray(element?.children)) {
403
- // for (let child of element?.children) {
404
- // if (Array.isArray(child)) {
405
- // let sub_children = []
406
- // for (let sub_child of child) {
407
- // sub_children.push(convert_prepped_to_version(sub_child))
408
- // }
409
- // cleaned_children.push(convert_prepped_to_version(sub_children))
410
- // } else {
411
- // cleaned_children.push(convert_prepped_to_version(child))
412
- // }
413
- // }
414
- // }
415
- // return { ...element, children: cleaned_children }
416
- // }
417
-
418
402
  function copy_markdown() {
419
403
  copy_to_clipboard(astc_to_markdown(selected_version_prepped?.element))
420
404
  }
@@ -861,6 +845,7 @@ export function create_content_input_manager(config) {
861
845
  }
862
846
 
863
847
  function init(config) {
848
+ definition_stack = config?.definition_stack ?? []
864
849
  versions = [config?.val]
865
850
  storage = config?.storage
866
851
  storage_default_folder_path = config?.storage_default_folder_path
@@ -952,10 +937,10 @@ export function create_content_input_manager(config) {
952
937
  },
953
938
  })
954
939
  attributes_input = create_attributes_input_manager({
955
- variables_data_type: () => variables_data_type,
956
940
  storage: storage,
957
941
  storage_default_folder_path: storage_default_folder_path,
958
942
  storage_path: storage_path,
943
+ get_defined_options: get_defined_options,
959
944
  })
960
945
  set_selected_version(0)
961
946
  }
@@ -967,12 +952,6 @@ export function create_content_input_manager(config) {
967
952
  get val() {
968
953
  return versions?.[selected_version_index]
969
954
  },
970
- get variables_data_type() {
971
- return variables_data_type
972
- },
973
- get variables() {
974
- return variables
975
- },
976
955
  get versions_len() {
977
956
  return versions_len
978
957
  },
@@ -1021,9 +1000,6 @@ export function create_content_input_manager(config) {
1021
1000
  get content_manager() {
1022
1001
  return content_manager
1023
1002
  },
1024
- get content_overall_manager() {
1025
- return content_overall_manager
1026
- },
1027
1003
  get attributes_input() {
1028
1004
  return attributes_input
1029
1005
  },
@@ -542,9 +542,6 @@ export function create_data_type_input_manager(config) {
542
542
  get guess_from_variables_button_manager() {
543
543
  return guess_from_variables_button_manager
544
544
  },
545
- get data_sample() {
546
- return data_sample
547
- },
548
545
  get type_options() {
549
546
  return type_options
550
547
  },
@@ -9,7 +9,7 @@
9
9
  </script>
10
10
 
11
11
  {#snippet selected_icon()}
12
- <div style="display: flex; gap: 1rem; align-items: center;">
12
+ <div style="display: flex; gap: 1rem; align-items: center; color: var(--g2-t);">
13
13
  {manager?.icon_options.find((h) => h.key == (manager?.is_icon_only ? manager?.val : manager?.val?.icon))?.name ??
14
14
  (manager?.is_icon_only ? manager?.val : manager?.val?.icon) ??
15
15
  "Select Icon"}
@@ -10,9 +10,8 @@ import { create_data_type_input_manager } from "../../DataTypeInput/index.svelte
10
10
  import {
11
11
  set_closurable,
12
12
  node_types,
13
- deep_copy,
14
13
  variables_data_type_remaining_to_astc,
15
- set_content_variables,
14
+ set_definition_stack,
16
15
  astc_element,
17
16
  } from "../../../client/index.js"
18
17
 
@@ -49,13 +48,10 @@ export function create_column_input_manager(config) {
49
48
  let delete_column_cancel_button_manager = $state(null)
50
49
 
51
50
  let rows_data_from_variable_path = $derived(set_closurable(config?.rows_data_from_variable_path, null))
52
- let variables = $derived(set_closurable(config?.variables, null))
53
- let variables_data_type = $derived(set_closurable(config?.variables_data_type, null))
54
51
  let columns = $derived(set_closurable(config?.columns, null))
55
52
  let columns_length = $derived(Object.keys(columns || {}).length)
56
- let row_data_type = $derived(set_closurable(config?.row_data_type, null))
57
53
  let column_id = $derived(set_closurable(config?.column_id, null))
58
- let loops = $derived(set_closurable(config?.loops, null))
54
+ let definition_stack = $derived(set_closurable(config?.definition_stack, null))
59
55
  let is_column_update = $derived(set_closurable(config?.is_column_update, true))
60
56
  let column_input_options = $derived(set_closurable(config?.column_input_options, null))
61
57
 
@@ -68,46 +64,6 @@ export function create_column_input_manager(config) {
68
64
  : null
69
65
  )
70
66
 
71
- let variables_data_type_with_this_col = $derived(get_variables_data_type_with_this_col())
72
- function get_variables_data_type_with_this_col() {
73
- if (
74
- column_id_text_input_manager?.val &&
75
- !column_id_text_warning &&
76
- column_is_db_column_checkbox_manager?.val &&
77
- column_db_data_type_input_manager?.val
78
- ) {
79
- const path_to_set = [...rows_data_from_variable_path]
80
- let variables_data_type_combined_loc = $state(
81
- deep_copy({
82
- type: "object_literal",
83
- properties: {
84
- variables: variables_data_type,
85
- loops: { type: "loop" },
86
- },
87
- })
88
- )
89
- let target = variables_data_type_combined_loc
90
- for (let i = 0; i < path_to_set.length; i++) {
91
- if (target?.type === "loop") {
92
- target = target.items
93
- } else if (target?.type === "object_literal") {
94
- if (!target.properties) {
95
- target.properties = {}
96
- }
97
- target = target.properties[path_to_set[i]]
98
- }
99
- if (target === undefined) {
100
- break
101
- }
102
- }
103
- if (target?.items?.type === "object_literal" && target?.items?.properties) {
104
- target.items.properties[column_id_text_input_manager?.val] = column_db_data_type_input_manager?.val
105
- }
106
- return variables_data_type_combined_loc?.properties?.variables
107
- }
108
- return variables_data_type
109
- }
110
-
111
67
  let column_data_postgres_type = $derived(
112
68
  column_db_data_type_input_manager?.val?.type == "array_uniform_literal" &&
113
69
  column_db_data_type_input_manager?.val?.items?.type == "text_literal"
@@ -158,24 +114,20 @@ export function create_column_input_manager(config) {
158
114
  val: config?.val?.header_content ?? null,
159
115
  storage: null,
160
116
  storage_default_folder_path: null,
161
- variables_data_type: () => variables_data_type_with_this_col,
162
- variables: () => variables,
163
- loops: () => loops,
117
+ definition_stack: definition_stack,
164
118
  on_event: (input) => {
165
- console.log("set_content_variables_tbd400", input)
166
- // set_content_variables(input)
119
+ console.log("set_definition_stack_tbd400", input)
120
+ set_definition_stack(input)
167
121
  },
168
122
  })
169
123
  body_content_input_manager = create_content_input_manager({
170
124
  val: config?.val?.body_content ?? null,
171
125
  storage: config?.storage,
172
126
  storage_default_folder_path: null,
173
- variables_data_type: () => variables_data_type_with_this_col,
174
- variables: () => variables,
175
- loops: () => [0, ...(Array.isArray(loops) ? loops : [])],
127
+ definition_stack: () => definition_stack,
176
128
  on_event: (input) => {
177
- console.log("set_content_variables_tbd401")
178
- // set_content_variables(input)
129
+ console.log("set_definition_stack_tbd33")
130
+ set_definition_stack(input)
179
131
  },
180
132
  })
181
133
  column_description_text_input_manager = create_text_input_manager({
@@ -234,23 +186,23 @@ export function create_column_input_manager(config) {
234
186
  val: config?.val?.is_db_column ?? column_input_options?.is_db_column?.default_value ?? false,
235
187
  })
236
188
  column_db_data_type_input_manager = create_data_type_input_manager({
237
- data_sample: () => variables,
189
+ // data_sample: () => variables,
238
190
  table_options: config?.table_options,
239
- val: config?.val?.db_data_type ?? row_data_type?.properties?.[column_id_text_input_manager?.val],
191
+ val: config?.val?.db_data_type,
240
192
  on_finish: (input) => {
241
- let default_content_input_astc = variables_data_type_remaining_to_astc(input, "input", ["variables"])
193
+ let default_content_input_astc = variables_data_type_remaining_to_astc(input, "input", ["rows"])
242
194
  column_default_value_content_manager = create_content_manager({
243
195
  val: default_content_input_astc,
244
196
  table_options: config?.table_options,
245
197
  on_search_table_row_ids: config?.on_search_table_row_ids,
246
- variables: () => default_value,
198
+ definition_stack: () => definition_stack,
247
199
  on_event: (input) => {
248
- const res = set_content_variables(
200
+ const res = set_definition_stack(
249
201
  input,
250
- { variables: default_value },
202
+ definition_stack,
251
203
  column_default_value_content_manager?.pass_event_down
252
204
  )
253
- default_value = res?.variables
205
+ definition_stack = res?.definition_stack
254
206
  return res
255
207
  },
256
208
  })
@@ -325,7 +277,7 @@ export function create_column_input_manager(config) {
325
277
  let guessed_column_display_content = variables_data_type_remaining_to_astc(
326
278
  column_db_data_type_input_manager?.val,
327
279
  "display",
328
- ["variables", "rows", ["loops", 0], column_id_text_input_manager.val]
280
+ ["rows", ["row_i"], column_id_text_input_manager.val]
329
281
  )
330
282
  console.log("guessed_column_display_content", guessed_column_display_content)
331
283
  body_content_input_manager.add_version(guessed_column_display_content)
@@ -91,7 +91,8 @@ export function create_sort_by_input_manager(config) {
91
91
  })
92
92
  let data_row_variable_path_input_manager = create_variable_path_input_manager({
93
93
  is_popover: false,
94
- variables_data_type: () => row_data_type,
94
+ defined_data_type: row_data_type,
95
+ get_defined_options: config?.get_defined_options,
95
96
  val: sorts?.[i]?.data_row_variable_path ?? null,
96
97
  })
97
98
  sorts_prepped_loc.push({