poe-svelte-ui-lib 1.4.7 → 1.4.8

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.
@@ -15,7 +15,7 @@
15
15
  onChange = () => {},
16
16
  }: IFileAttachProps = $props()
17
17
 
18
- let ID = `${id}-${crypto.randomUUID().slice(0, 6)}`
18
+ let ID = $derived(`${id}-${crypto.randomUUID().slice(0, 6)}`)
19
19
  let selectedFile = $state<File | null>(null)
20
20
  let previewUrl = $derived(currentImage ? (currentImage.startsWith('data:') ? currentImage : `data:image/png;base64,${currentImage}`) : null)
21
21
  let fileName = $state('')
@@ -31,15 +31,6 @@
31
31
  <div class="relative flex flex-row items-start justify-center">
32
32
  <!-- Сообщение для отправки в ws по нажатию кнопки -->
33
33
  <div class="flex w-1/3 flex-col items-center px-2">
34
- <UI.Select
35
- label={{ name: $t('constructor.props.variable') }}
36
- options={VARIABLE_OPTIONS}
37
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
38
- onUpdate={(value) => {
39
- updateProperty('id', value.value as string, component, onPropertyChange)
40
- onPropertyChange({ name: value.name?.split('—')[1].trim(), eventHandler: { Variables: value.value as string } })
41
- }}
42
- />
43
34
  <UI.Select
44
35
  label={{ name: $t('constructor.props.access') }}
45
36
  type="buttons"
@@ -66,7 +66,7 @@
66
66
  class={twMerge(
67
67
  `w-full rounded-2xl border px-4 py-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition duration-200
68
68
  outline-none focus:shadow-[0_0_6px_var(--blue-color)] focus:border-(--blue-color) [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
69
- ${isValid ? 'border-(--bg-color)' : 'border-red-400 shadow-[0_0_6px_var(--red-color)] focus:border-red-400'}
69
+ ${isValid ? 'border-(--bg-color)' : 'border-red-400 shadow-[0_0_6px_var(--red-color)] focus:shadow-[0_0_6px_var(--red-color)] focus:border-red-400'}
70
70
  ${disabled ? 'opacity-50' : 'hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}
71
71
  ${readonly ? '' : 'hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}
72
72
  ${help?.info ? 'pl-8' : ''}
@@ -92,7 +92,7 @@
92
92
  class={twMerge(
93
93
  `h-full w-full resize-y rounded-2xl border border-(--border-color) px-2 py-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition
94
94
  duration-200 outline-none focus:border-blue-400
95
- ${isValid ? 'border-(--bg-color)' : 'border-red-400 shadow-[0_0_6px_var(--red-color)]'}
95
+ ${isValid ? 'border-(--bg-color)' : 'border-red-400 shadow-[0_0_6px_var(--red-color)] focus:shadow-[0_0_6px_var(--red-color)] focus:border-red-400'}
96
96
  ${disabled ? 'cursor-not-allowed opacity-50' : 'hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}
97
97
  ${readonly ? '' : 'hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}
98
98
  ${help?.info ? 'pl-8' : ''}
@@ -112,7 +112,11 @@
112
112
  options={$optionsStore.INPUT_TYPE_OPTIONS}
113
113
  type="buttons"
114
114
  value={$optionsStore.INPUT_TYPE_OPTIONS.find((opt) => opt.value === (component.properties.type || 'text'))}
115
- onUpdate={(selectedOption) => updateProperty('type', selectedOption.value as string)}
115
+ onUpdate={(selectedOption) => {
116
+ updateProperty('type', selectedOption.value as string)
117
+ if (selectedOption.value === 'text-area') updateProperty('componentClass', twMerge(component.properties.componentClass, 'font-mono'))
118
+ else updateProperty('componentClass', twMerge(component.properties.componentClass, 'font-[Montserrat]'))
119
+ }}
116
120
  />
117
121
  {#if component.properties.type === 'text' || component.properties.type === 'password' || component.properties.type === 'text-area'}
118
122
  <UI.Input
@@ -235,7 +239,7 @@
235
239
  <UI.Input
236
240
  label={{ name: $t('constructor.props.componentclass') }}
237
241
  value={component.properties.componentClass}
238
- onUpdate={(value) => updateProperty('componentClass', value as string)}
242
+ onUpdate={(value) => updateProperty('componentClass', twMerge(component.properties.componentClass, value as string))}
239
243
  />
240
244
  <UI.Select
241
245
  wrapperClass="h-14"
@@ -99,7 +99,7 @@
99
99
  id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
100
100
  value={value?.value ? String(value.value) : ''}
101
101
  class={twMerge(
102
- `w-full rounded-2xl border border-(--bg-color) p-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition-shadow duration-200
102
+ `w-full rounded-2xl border border-(--bg-color) p-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition duration-200
103
103
  ${disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}`,
104
104
  value?.class,
105
105
  )}
@@ -143,7 +143,7 @@
143
143
  <button
144
144
  id={option.id}
145
145
  class="{twMerge(
146
- `m-0 inline-block min-w-0 flex-1 items-center px-2 py-1 font-semibold shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition-all duration-300 select-none border border-(--bg-color)
146
+ `m-0 inline-block min-w-0 flex-1 items-center px-2 py-1 font-semibold shadow-[0_0_3px_rgb(0_0_0_/0.25)] transition duration-300 select-none border border-(--bg-color)
147
147
  ${option.disabled || disabled ? 'opacity-50' : 'cursor-pointer hover:shadow-[0_0_6px_rgb(0_0_0_/0.25)]'}
148
148
  ${option.value === value?.value && value !== null ? 'z-10 py-1 shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]' : ''}
149
149
  ${options.length > 0 && index === 0 ? 'rounded-l-2xl' : ''} ${index === options.length - 1 ? 'rounded-r-2xl' : ''}`,
@@ -166,7 +166,7 @@
166
166
  <input
167
167
  bind:value={searchValue}
168
168
  class="w-full appearance-none rounded-2xl border px-4 py-1 text-center shadow-[0_0_3px_rgb(0_0_0_/0.25)]
169
- transition-shadow duration-200 outline-none focus:shadow-[0_0_6px_var(--blue-color)]
169
+ transition duration-200 outline-none focus:shadow-[0_0_6px_var(--blue-color)]
170
170
  [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
171
171
  {disabled
172
172
  ? 'cursor-not-allowed opacity-50'
@@ -17,8 +17,8 @@
17
17
 
18
18
  const isRange = $derived(type === 'range' || (Array.isArray(value) && value.length === 2))
19
19
 
20
- const maxDigits = String(number.maxNum ?? 100).length
21
- const valueWidth = `${maxDigits + 1}ch` /* +1 на запас */
20
+ const maxDigits = $derived(String(number.maxNum ?? 100).length)
21
+ const valueWidth = $derived(`${maxDigits + 1}ch`) /* +1 на запас */
22
22
 
23
23
  /* Инициализация значений с проверкой типа */
24
24
  let singleValue = $derived(!isRange && typeof value === 'number' ? value : number.minNum)
@@ -171,9 +171,9 @@
171
171
  <div
172
172
  class={twMerge(
173
173
  `items-center justify-center border-l ${outline && index !== 0 ? ' border-(--border-color)' : 'border-transparent'} ${
174
- column.align?.header === 'center'
174
+ column.align === 'center'
175
175
  ? 'flex justify-center text-center'
176
- : column.align?.header === 'right'
176
+ : column.align === 'right'
177
177
  ? 'flex justify-end text-right'
178
178
  : 'flex justify-start text-left'
179
179
  } gap-1 bg-(--bg-color) p-2 text-left`,
@@ -201,9 +201,9 @@
201
201
  <div
202
202
  class="relative flex w-full min-w-0 items-center px-2 py-1 wrap-break-word
203
203
  {index % 2 ? 'bg-(--back-color)/40' : 'bg-[#edeef3] dark:bg-[#1f2a3a]'}
204
- {column.align?.content === 'center'
204
+ {column.align === 'center'
205
205
  ? 'flex justify-center text-center'
206
- : column.align?.content === 'right'
206
+ : column.align === 'right'
207
207
  ? 'flex justify-end text-right'
208
208
  : 'flex justify-start text-left'}
209
209
  border-t
@@ -24,7 +24,7 @@
24
24
  const DeviceVariables = getContext<{ id: string; value: string; name: string }[]>('DeviceVariables')
25
25
  let VARIABLE_OPTIONS = $derived(DeviceVariables && Array.isArray(DeviceVariables) ? DeviceVariables : [])
26
26
 
27
- let defaultIcon = $state({ isModalOpen: false, columnIndex: 0, column: component.properties.header[0] })
27
+ let defaultIcon = $derived({ isModalOpen: false, columnIndex: 0, column: component.properties.header[0] })
28
28
 
29
29
  const initialColor = $derived(
30
30
  $optionsStore.COLOR_OPTIONS.find((c) =>
@@ -77,7 +77,7 @@
77
77
  </script>
78
78
 
79
79
  {#if forConstructor}
80
- <div class="relative flex flex-row items-start justify-center">
80
+ <div class="relative flex flex-row items-start justify-center pb-4">
81
81
  <div class="flex w-1/3 flex-col px-2">
82
82
  <UI.Select
83
83
  label={{ name: $t('constructor.props.variable') }}
@@ -183,11 +183,9 @@
183
183
  <UI.Select
184
184
  label={{ name: $t('constructor.props.align.content') }}
185
185
  type="buttons"
186
- value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align?.content) || 'left')}
186
+ value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align))}
187
187
  options={$optionsStore.ALIGN_OPTIONS}
188
- onUpdate={(option) => {
189
- updateTableHeader(columnIndex, 'align', { header: option.value, content: option.value })
190
- }}
188
+ onUpdate={(option) => updateTableHeader(columnIndex, 'align', option.value)}
191
189
  />
192
190
  <UI.Switch
193
191
  wrapperClass="w-30"
@@ -288,7 +286,7 @@
288
286
  {/each}
289
287
  </div>
290
288
  {:else}
291
- <div class="relative flex flex-row items-start justify-center">
289
+ <div class="relative flex flex-row items-start justify-center pb-4">
292
290
  <div class="flex w-1/3 flex-col px-2">
293
291
  <UI.Input
294
292
  label={{ name: $t('constructor.props.id') }}
@@ -407,13 +405,6 @@
407
405
  value={Number(column.width.replace('%', ''))}
408
406
  onUpdate={(value) => updateTableHeader(columnIndex, 'width', `${value}%`)}
409
407
  />
410
- <UI.Select
411
- label={{ name: $t('constructor.props.align.header') }}
412
- type="buttons"
413
- value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align?.header) || 'left')}
414
- options={$optionsStore.ALIGN_OPTIONS}
415
- onUpdate={(option) => updateTableHeader(columnIndex, 'align', { header: option.value, content: column.align?.content })}
416
- />
417
408
  <UI.Switch
418
409
  label={{ name: $t('constructor.props.table.columns.sortable'), class: 'px-0' }}
419
410
  wrapperClass="w-30"
@@ -459,9 +450,9 @@
459
450
  <UI.Select
460
451
  label={{ name: $t('constructor.props.align.content') }}
461
452
  type="buttons"
462
- value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align?.content) || 'left')}
453
+ value={$optionsStore.ALIGN_OPTIONS.find((a) => (a.value as string).includes(column.align))}
463
454
  options={$optionsStore.ALIGN_OPTIONS}
464
- onUpdate={(option) => updateTableHeader(columnIndex, 'align', { header: column.align?.header, content: option.value })}
455
+ onUpdate={(option) => updateTableHeader(columnIndex, 'align', option.value)}
465
456
  />
466
457
  <UI.Switch
467
458
  wrapperClass="w-2/10"
@@ -23,7 +23,7 @@
23
23
 
24
24
  const isCol = $derived(!!items.find((item) => item.class?.startsWith('flex-col')))
25
25
 
26
- let currentTabIndex: number = $state(activeTab)
26
+ let currentTabIndex: number = $derived(activeTab)
27
27
  </script>
28
28
 
29
29
  <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class="w-full rounded-2xl bg-(--back-color)">
package/dist/types.d.ts CHANGED
@@ -34,10 +34,10 @@ export interface UIComponent {
34
34
  eventHandler?: IUIComponentHandler;
35
35
  }
36
36
  export interface Position {
37
- row: number;
38
- col: number;
39
- width: number;
40
- height: number;
37
+ row?: number;
38
+ col?: number;
39
+ width?: number;
40
+ height?: number;
41
41
  }
42
42
  export interface IUIComponentHandler {
43
43
  Header?: string;
@@ -233,10 +233,7 @@ export interface ITableHeader<T extends object> {
233
233
  key: keyof T;
234
234
  sortable?: boolean;
235
235
  width?: string;
236
- align?: {
237
- header?: 'left' | 'center' | 'right';
238
- content?: 'left' | 'center' | 'right';
239
- };
236
+ align?: 'left' | 'center' | 'right';
240
237
  overflow?: {
241
238
  truncated?: boolean;
242
239
  formatting?: (text: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -44,12 +44,12 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@sveltejs/adapter-static": "^3.0.10",
47
- "@sveltejs/kit": "^2.49.0",
47
+ "@sveltejs/kit": "^2.49.1",
48
48
  "@sveltejs/package": "^2.5.7",
49
49
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
50
50
  "@types/node": "^24.10.1",
51
51
  "publint": "^0.3.15",
52
- "svelte": "^5.45.3",
52
+ "svelte": "^5.45.4",
53
53
  "svelte-preprocess": "^6.0.3",
54
54
  "vite": "^7.2.6",
55
55
  "vite-plugin-compression": "^0.5.1"