poe-svelte-ui-lib 1.6.4 → 1.6.6

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.
@@ -114,9 +114,15 @@
114
114
  if (button.onClick) button.onClick(row)
115
115
  else if (button.eventHandler && onClick) {
116
116
  let value: Record<string, boolean | string | number | number[] | object | null> = {}
117
- button.eventHandler.Variables.forEach((v: string) => (value[v] = row[v]))
118
- button.eventHandler.Value = JSON.stringify(value)
119
- onClick(button.eventHandler)
117
+ button.eventHandler.Variables.forEach((v: string) => {
118
+ if (header.some(h => h.key === v && h.action?.type === "select")) {
119
+ value[v] = row[v][0]
120
+ } else {
121
+ value[v] = row[v]
122
+ }
123
+ button.eventHandler.Value = JSON.stringify(value)
124
+ onClick(button.eventHandler)
125
+ })
120
126
  }
121
127
  }
122
128
 
@@ -95,11 +95,33 @@
95
95
 
96
96
  const removeButtonFromColumn = (columnIndex: number, buttonIndex: number) => {
97
97
  const headers = [...component.properties.header]
98
- const buttons = [...headers[columnIndex].buttons]
98
+ const buttons = [...headers[columnIndex].action.buttons]
99
+
99
100
  buttons.splice(buttonIndex, 1)
100
- headers[columnIndex].buttons = buttons.length ? buttons : undefined
101
+ headers[columnIndex].action.buttons = buttons.length ? buttons : undefined
101
102
  updateProperty("header", headers, component, onPropertyChange)
102
103
  }
104
+
105
+ const addNewButton = (columnIndex: number) => {
106
+ const newButton = {
107
+ name: `button${(component.properties.header[columnIndex].action.buttons ? component.properties.header[columnIndex].action.buttons.length : 0) + 1}`,
108
+ class: "bg-blue",
109
+ eventHandler: { Header: "SET", Argument: "Save", Variables: [] },
110
+ onClick: () => {},
111
+ }
112
+ let action = { ...component.properties.header[columnIndex].action }
113
+
114
+ if (!action) {
115
+ action = { type: "buttons", buttons: [newButton], select: { key: "", onChange: () => {} } }
116
+ } else if (action.type === "buttons") {
117
+ const buttons = [...(action.buttons || []), newButton]
118
+ action = { ...action, buttons }
119
+ } else {
120
+ action = { type: "buttons", buttons: [newButton], select: action.select }
121
+ }
122
+
123
+ updateTableHeader(columnIndex, "action", action)
124
+ }
103
125
  </script>
104
126
 
105
127
  {#if forConstructor}
@@ -281,8 +303,9 @@
281
303
  wrapperClass="w-8 {column.action && column.action.type != 'none' ? 'invisible' : ''}"
282
304
  content={{ icon: ButtonAdd, info: { text: $t("constructor.props.table.addaction"), side: "top" } }}
283
305
  onClick={() => {
284
- column.action = { type: "buttons", select: { key: "" } }
285
- if (!(column.action && column.action.buttons)) {
306
+ updateTableHeader(columnIndex, "action", { type: "buttons", select: { key: "" } })
307
+ if (!column.action || column.action.buttons.length == 0) {
308
+ addNewButton(columnIndex)
286
309
  }
287
310
  }} />
288
311
  <UI.Button
@@ -313,24 +336,7 @@
313
336
  wrapperClass="w-8 {column.action.type == 'select' ? 'invisible' : ''}"
314
337
  content={{ icon: ButtonAdd, info: { text: $t("constructor.props.table.addbutton"), side: "top" } }}
315
338
  onClick={() => {
316
- const newButton = {
317
- name: `button${(component.properties.header[columnIndex].action.buttons ? component.properties.header[columnIndex].action.buttons.length : 0) + 1}`,
318
- class: "bg-blue",
319
- eventHandler: { Header: "SET", Argument: "Save", Variables: [] },
320
- onClick: () => {},
321
- }
322
- let action = { ...component.properties.header[columnIndex].action }
323
-
324
- if (!action) {
325
- action = { type: "buttons", buttons: [newButton], select: { key: "", onChange: () => {} } }
326
- } else if (action.type === "buttons") {
327
- const buttons = [...(action.buttons || []), newButton]
328
- action = { ...action, buttons }
329
- } else {
330
- action = { type: "buttons", buttons: [newButton], select: action.select }
331
- }
332
-
333
- updateTableHeader(columnIndex, "action", action)
339
+ addNewButton(columnIndex)
334
340
  }} />
335
341
 
336
342
  <UI.Button
@@ -385,14 +391,14 @@
385
391
  </div>
386
392
  {/each}
387
393
  {:else if column.action.type == "select"}
388
- <div class="ml-14 flex items-end justify-between gap-2">
389
- <UI.Select
390
- label={{ name: $t("constructor.props.variable") }}
391
- options={VARIABLE_OPTIONS}
392
- value={VARIABLE_OPTIONS.find(opt => opt.value === column.action.select.key)}
394
+ <div class="flex items-end justify-between gap-2">
395
+ <UI.Input
396
+ label={{ name: $t("constructor.props.table.select.keys") }}
397
+ value={column.action.select.key ?? ""}
398
+ maxlength={500}
399
+ help={{ info: $t("constructor.props.table.select.keys.info"), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
393
400
  onUpdate={value => {
394
- updateSelectProperty(columnIndex, "key", value.value as string)
395
- onPropertyChange({ name: value.name?.split("—")[1].trim(), eventHandler: { Variables: [value.value as string] } })
401
+ updateSelectProperty(columnIndex, "key", value as string)
396
402
  }} />
397
403
  </div>
398
404
  {/if}
@@ -556,6 +562,7 @@
556
562
  updateTableBody()
557
563
  }} />
558
564
  </div>
565
+
559
566
  <div class="flex flex-col gap-2">
560
567
  {#each component.properties.header as column, columnIndex (columnIndex)}
561
568
  <div class="rounded-2xl border border-(--border-color) p-2">
@@ -601,8 +608,9 @@
601
608
  wrapperClass="w-8 {column.action && column.action.type != 'none' ? 'invisible' : ''}"
602
609
  content={{ icon: ButtonAdd, info: { text: $t("constructor.props.table.addaction"), side: "top" } }}
603
610
  onClick={() => {
604
- column.action = { type: "buttons", select: { key: "" } }
605
- if (!(column.action && column.action.buttons)) {
611
+ updateTableHeader(columnIndex, "action", { type: "buttons", select: { key: "" } })
612
+ if (!column.action || column.action.buttons.length == 0) {
613
+ addNewButton(columnIndex)
606
614
  }
607
615
  }} />
608
616
 
@@ -699,24 +707,7 @@
699
707
  wrapperClass="w-8 {column.action.type == 'select' ? 'invisible' : ''}"
700
708
  content={{ icon: ButtonAdd, info: { text: $t("constructor.props.table.addbutton"), side: "top" } }}
701
709
  onClick={() => {
702
- const newButton = {
703
- name: `button${(component.properties.header[columnIndex].action.buttons ? component.properties.header[columnIndex].action.buttons.length : 0) + 1}`,
704
- class: "bg-blue",
705
- eventHandler: { Header: "SET", Argument: "Save", Variables: [] },
706
- onClick: () => {},
707
- }
708
- let action = { ...component.properties.header[columnIndex].action }
709
-
710
- if (!action) {
711
- action = { type: "buttons", buttons: [newButton], select: { key: "", onChange: () => {} } }
712
- } else if (action.type === "buttons") {
713
- const buttons = [...(action.buttons || []), newButton]
714
- action = { ...action, buttons }
715
- } else {
716
- action = { type: "buttons", buttons: [newButton], select: action.select }
717
- }
718
-
719
- updateTableHeader(columnIndex, "action", action)
710
+ addNewButton(columnIndex)
720
711
  }} />
721
712
 
722
713
  <UI.Button
@@ -771,14 +762,14 @@
771
762
  </div>
772
763
  {/each}
773
764
  {:else if column.action.type == "select"}
774
- <div class="ml-14 flex items-end justify-between gap-2">
775
- <UI.Select
776
- label={{ name: $t("constructor.props.variable") }}
777
- options={VARIABLE_OPTIONS}
778
- value={VARIABLE_OPTIONS.find(opt => opt.value === column.action.select.key)}
765
+ <div class="flex items-end justify-between gap-2">
766
+ <UI.Input
767
+ label={{ name: $t("constructor.props.table.select.keys") }}
768
+ value={column.action.select.key ?? ""}
769
+ maxlength={500}
770
+ help={{ info: $t("constructor.props.table.select.keys.info"), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
779
771
  onUpdate={value => {
780
- updateSelectProperty(columnIndex, "key", value.value as string)
781
- onPropertyChange({ name: value.name?.split("—")[1].trim(), eventHandler: { Variables: [value.value as string] } })
772
+ updateSelectProperty(columnIndex, "key", value as string)
782
773
  }} />
783
774
  </div>{/if}
784
775
  </div>
@@ -152,6 +152,8 @@ const translations = {
152
152
  "constructor.props.table.addbutton": "Добавить кнопку",
153
153
  "constructor.props.table.keys": "Перечень ключей",
154
154
  "constructor.props.table.keys.info": "Ключи таблицы, значения которых будут возвращаться",
155
+ "constructor.props.table.select.keys": "Ключ строки",
156
+ "constructor.props.table.select.keys.info": "Ключ, по которому будет находиться значение поля для текущей строки",
155
157
  "constructor.props.table.stashData": "Накопление данных",
156
158
  "constructor.props.table.buffersize": "Размер буфера",
157
159
  "constructor.props.table.clearButton": "Кнопка очистки",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -36,7 +36,7 @@
36
36
  "prettier": "^3.7.4",
37
37
  "prettier-plugin-svelte": "^3.4.1",
38
38
  "prettier-plugin-tailwindcss": "^0.7.2",
39
- "svelte-maplibre-gl": "^1.0.2",
39
+ "svelte-maplibre-gl": "^1.0.3",
40
40
  "tailwind-merge": "^3.4.0",
41
41
  "tailwindcss": "^4.1.18",
42
42
  "tsx": "^4.21.0",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@sveltejs/adapter-static": "^3.0.10",
47
- "@sveltejs/kit": "^2.49.2",
47
+ "@sveltejs/kit": "^2.49.3",
48
48
  "@sveltejs/package": "^2.5.7",
49
49
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
50
50
  "@types/node": "^25.0.3",