poe-svelte-ui-lib 1.1.15 → 1.1.16

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.
@@ -68,17 +68,19 @@
68
68
  }
69
69
  </script>
70
70
 
71
- {#if component && component.properties}
71
+ {#if forConstructor}
72
72
  <div class="relative flex flex-row items-start justify-center">
73
- <UI.Select
74
- label={{ name: $t('constructor.props.variable') }}
75
- options={VARIABLE_OPTIONS}
76
- value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
77
- onUpdate={(value) => {
78
- updateProperty('id', value.value as string, component, onPropertyChange, value.name?.split('—')[1].trim())
79
- updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
80
- }}
81
- />
73
+ <div class="flex w-1/3 flex-col px-2">
74
+ <UI.Select
75
+ label={{ name: $t('constructor.props.variable') }}
76
+ options={VARIABLE_OPTIONS}
77
+ value={VARIABLE_OPTIONS.find((opt) => opt.value === component.properties.id)}
78
+ onUpdate={(value) => {
79
+ updateProperty('id', value.value as string, component, onPropertyChange, value.name?.split('—')[1].trim())
80
+ updateProperty('eventHandler.Variables', value.value as string, component, onPropertyChange)
81
+ }}
82
+ />
83
+ </div>
82
84
  <div class="flex w-1/3 flex-col px-2">
83
85
  <UI.Select
84
86
  wrapperClass="!h-14"
@@ -105,7 +107,183 @@
105
107
  </div>
106
108
  </div>
107
109
 
108
- <hr class="border-[var(--border-color)]" />
110
+ <hr class="border-(--border-color)" />
111
+
112
+ <!-- Настройки столбцов таблицы -->
113
+ <div>
114
+ <div class=" flex items-center justify-center gap-2">
115
+ <h4>{$t('constructor.props.table.columns')}</h4>
116
+ <UI.Button
117
+ wrapperClass="w-8"
118
+ content={{ icon: ButtonAdd }}
119
+ onClick={() => {
120
+ const newColumn: ITableHeader<any> = {
121
+ key: `column${(component.properties.header?.length || 0) + 1}`,
122
+ label: { name: `Column ${(component.properties.header?.length || 0) + 1}`, class: '' },
123
+ width: '10%',
124
+ sortable: false,
125
+ }
126
+ const headers = [...(component.properties.header || []), newColumn]
127
+ updateProperty('header', headers, component, onPropertyChange)
128
+ updateTableBody()
129
+ }}
130
+ />
131
+ </div>
132
+
133
+ {#each component.properties.header as column, columnIndex (columnIndex)}
134
+ <div class="mr-2 flex items-end justify-around gap-6">
135
+ <UI.Input
136
+ label={{ name: $t('constructor.props.table.columns.key') }}
137
+ value={column.key}
138
+ help={{ regExp: /^[0-9a-zA-Z_-]{0,16}$/ }}
139
+ onUpdate={(value) => {
140
+ updateTableHeader(columnIndex, 'key', value)
141
+ updateTableBody()
142
+ }}
143
+ />
144
+ <UI.Input
145
+ label={{ name: $t('constructor.props.table.columns.label') }}
146
+ value={column.label.name}
147
+ onUpdate={(value) => {
148
+ updateTableHeader(columnIndex, 'label', { ['name']: value })
149
+ }}
150
+ />
151
+ <UI.Input
152
+ label={{ name: $t('constructor.props.table.columns.width') }}
153
+ type="number"
154
+ value={Number(column.width.replace('%', ''))}
155
+ onUpdate={(value) => updateTableHeader(columnIndex, 'width', `${value}%`)}
156
+ />
157
+ <UI.Switch
158
+ wrapperClass="w-2/10"
159
+ label={{ name: $t('constructor.props.table.columns.sortable') }}
160
+ value={column.sortable ? 2 : 1}
161
+ onChange={(value) => updateTableHeader(columnIndex, 'sortable', value === 2)}
162
+ />
163
+ <UI.Button
164
+ wrapperClass="w-8"
165
+ content={{ icon: ButtonAdd, info: $t('constructor.props.table.addaction') }}
166
+ onClick={() => {
167
+ const newButton = {
168
+ name: `button${(component.properties.header[columnIndex].buttons ? component.properties.header[columnIndex].buttons.length : 0) + 1}`,
169
+ class: 'bg-blue',
170
+ eventHandler: { Header: 'SET', Argument: 'Save', Variables: [] },
171
+ onClick: () => {},
172
+ }
173
+ const buttons = [...(component.properties.header[columnIndex].buttons || []), newButton]
174
+ updateTableHeader(columnIndex, 'buttons', buttons)
175
+ }}
176
+ />
177
+ <UI.Button
178
+ wrapperClass="w-8"
179
+ content={{ icon: ButtonDelete }}
180
+ onClick={() => {
181
+ const headers = [...(component.properties.header || [])]
182
+ headers.splice(columnIndex, 1)
183
+ updateProperty('header', headers, component, onPropertyChange)
184
+ }}
185
+ />
186
+ </div>
187
+ {#if column.buttons && column.buttons.length > 0}
188
+ <div class="mb-5 rounded-lg p-1">
189
+ {#each column.buttons as button, buttonIndex (buttonIndex)}
190
+ <div class="mx-14 flex items-end justify-around gap-2">
191
+ <UI.Input
192
+ label={{ name: $t('constructor.props.name') }}
193
+ wrapperClass="!w-3/10"
194
+ value={button.name}
195
+ onUpdate={(value) => updateButtonProperty(columnIndex, buttonIndex, 'name', value)}
196
+ />
197
+ <UI.Select
198
+ wrapperClass="!w-2/10"
199
+ label={{ name: $t('constructor.props.header') }}
200
+ type="buttons"
201
+ value={$optionsStore.HEADER_OPTIONS.find((h) => h.value === button.eventHandler?.Header)}
202
+ options={$optionsStore.HEADER_OPTIONS}
203
+ onUpdate={(option) => {
204
+ const handler = button.eventHandler
205
+ handler.Header = option.value as string
206
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
207
+ }}
208
+ />
209
+ <UI.Input
210
+ wrapperClass="!w-2/10"
211
+ label={{ name: $t('constructor.props.argument') }}
212
+ value={button.eventHandler?.Argument}
213
+ onUpdate={(value) => {
214
+ const handler = button.eventHandler
215
+ handler.Argument = value as string
216
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
217
+ }}
218
+ />
219
+ <UI.Input
220
+ wrapperClass="!w-2/10"
221
+ label={{ name: $t('constructor.props.table.keys') }}
222
+ value={button.eventHandler?.Variables.join(' ')}
223
+ maxlength={500}
224
+ help={{ info: $t('constructor.props.table.keys.info'), regExp: /^[a-zA-Z0-9\-_ ]{0,500}$/ }}
225
+ onUpdate={(value) => {
226
+ const handler = { ...button.eventHandler }
227
+ handler.Variables = (value as string).trim().split(/\s+/)
228
+ updateButtonProperty(columnIndex, buttonIndex, 'eventHandler', handler)
229
+ }}
230
+ />
231
+ <UI.Button wrapperClass="w-8" content={{ icon: ButtonDelete }} onClick={() => removeButtonFromColumn(columnIndex, buttonIndex)} />
232
+ </div>
233
+ {/each}
234
+ </div>
235
+ {/if}
236
+ {/each}
237
+ </div>
238
+ {:else}
239
+ <div class="relative flex flex-row items-start justify-center">
240
+ <div class="flex w-1/3 flex-col px-2">
241
+ <UI.Input
242
+ label={{ name: $t('constructor.props.id') }}
243
+ value={component.properties.id}
244
+ onUpdate={(value) => updateProperty('id', value as string, component, onPropertyChange)}
245
+ />
246
+ <UI.Input
247
+ label={{ name: $t('constructor.props.wrapperclass') }}
248
+ value={component.properties.wrapperClass}
249
+ onUpdate={(value) => updateProperty('wrapperClass', value as string, component, onPropertyChange)}
250
+ />
251
+ <UI.Select
252
+ wrapperClass=" h-14"
253
+ label={{ name: $t('constructor.props.colors') }}
254
+ type="buttons"
255
+ options={$optionsStore.COLOR_OPTIONS}
256
+ value={initialColor}
257
+ onUpdate={(option) => {
258
+ updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)
259
+ const options = [...(component.properties?.options || [])]
260
+ options.forEach((o) => {
261
+ o['class'] = option.value
262
+ })
263
+ updateProperty('options', options, component, onPropertyChange)
264
+ }}
265
+ />
266
+ </div>
267
+ <div class="flex w-1/3 flex-col px-2">
268
+ <UI.Input
269
+ label={{ name: $t('constructor.props.label') }}
270
+ value={component.properties.label.name}
271
+ onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
272
+ />
273
+ <UI.Input
274
+ label={{ name: $t('constructor.props.label.class') }}
275
+ value={component.properties.label.class}
276
+ onUpdate={(value) => updateProperty('label.class', value as string, component, onPropertyChange)}
277
+ />
278
+ <UI.Input
279
+ label={{ name: $t('constructor.props.footer') }}
280
+ value={component.properties.footer}
281
+ onUpdate={(value) => updateProperty('footer', value as string, component, onPropertyChange)}
282
+ />
283
+ </div>
284
+ </div>
285
+
286
+ <hr class="border-(--border-color)" />
109
287
 
110
288
  <!-- Настройки столбцов таблицы -->
111
289
  <div>
@@ -15,10 +15,7 @@
15
15
 
16
16
  <div
17
17
  {id}
18
- class="{twMerge(
19
- `relative flex w-full flex-col items-center ${background ? 'rounded-2xl bg-[var(--container-color)] px-6 py-2' : ''}`,
20
- wrapperClass,
21
- )} "
18
+ class="{twMerge(`relative flex w-full flex-col items-center ${background ? 'rounded-2xl bg-(--container-color) px-6 py-2' : ''}`, wrapperClass)} "
22
19
  >
23
20
  <p class={twMerge(`w-full text-center ${textSize[content.size ?? 'base']}`, content.class)}>
24
21
  {content.name}
@@ -34,7 +34,7 @@
34
34
  const initialItalic = $derived(component.properties.content?.class?.split(' ').find((cls: string) => cls.startsWith('italic')))
35
35
  </script>
36
36
 
37
- {#if component && component.properties}
37
+ {#if forConstructor}
38
38
  <div class="relative flex flex-row items-start justify-center">
39
39
  <div class="flex w-1/3 flex-col px-2">
40
40
  <UI.Select
@@ -106,4 +106,83 @@
106
106
  />
107
107
  </div>
108
108
  </div>
109
+ {:else}
110
+ <div class="relative flex flex-row items-start justify-center">
111
+ <div class="flex w-1/3 flex-col px-2">
112
+ <UI.Input
113
+ label={{ name: $t('constructor.props.id') }}
114
+ value={component.properties.id}
115
+ onUpdate={(value) => updateProperty('id', value as string, component, onPropertyChange)}
116
+ />
117
+ <UI.Input
118
+ label={{ name: $t('constructor.props.wrapperclass') }}
119
+ value={component.properties.wrapperClass}
120
+ onUpdate={(value) => updateProperty('wrapperClass', value as string, component, onPropertyChange)}
121
+ />
122
+
123
+ <UI.Select
124
+ wrapperClass="!h-14"
125
+ label={{ name: $t('constructor.props.textcolors') }}
126
+ type="buttons"
127
+ options={$optionsStore.TEXT_COLOR_OPTIONS}
128
+ value={initialColor}
129
+ onUpdate={(option) => updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)}
130
+ />
131
+ </div>
132
+ <div class="flex w-1/3 flex-col px-2">
133
+ <UI.Input
134
+ label={{ name: $t('constructor.props.label') }}
135
+ value={component.properties.content.name}
136
+ onUpdate={(value) => updateProperty('content.name', value as string, component, onPropertyChange)}
137
+ />
138
+ <UI.Select
139
+ label={{ name: $t('constructor.props.size') }}
140
+ type="buttons"
141
+ value={currentType}
142
+ options={$optionsStore.TEXTFIELD_SIZE_OPTIONS}
143
+ onUpdate={(item) => updateProperty('content.size', item.value as string, component, onPropertyChange)}
144
+ />
145
+ <UI.Input
146
+ label={{ name: $t('constructor.props.componentclass') }}
147
+ value={component.properties.content.class}
148
+ onUpdate={(value) => updateProperty('content.class', value as string, component, onPropertyChange)}
149
+ />
150
+ <UI.Select
151
+ label={{ name: $t('constructor.props.align') }}
152
+ type="buttons"
153
+ value={initialAlign}
154
+ options={$optionsStore.ALIGN_OPTIONS}
155
+ onUpdate={(option) => updateProperty('content.class', twMerge(component.properties.content.class, option.value), component, onPropertyChange)}
156
+ />
157
+ </div>
158
+ <div class="flex w-1/3 flex-col px-2">
159
+ <UI.Switch
160
+ label={{ name: $t('constructor.props.bold') }}
161
+ value={initialBold ? 2 : 1}
162
+ onChange={(value) =>
163
+ updateProperty(
164
+ 'content.class',
165
+ `${component.properties.content.class} ${value === 2 ? 'font-bold' : 'font-normal'}`,
166
+ component,
167
+ onPropertyChange,
168
+ )}
169
+ />
170
+ <UI.Switch
171
+ label={{ name: $t('constructor.props.italic') }}
172
+ value={initialItalic ? 2 : 1}
173
+ onChange={(value) =>
174
+ updateProperty(
175
+ 'content.class',
176
+ `${component.properties.content.class} ${value === 2 ? 'italic' : 'not-italic'}`,
177
+ component,
178
+ onPropertyChange,
179
+ )}
180
+ />
181
+ <UI.Switch
182
+ label={{ name: $t('constructor.props.background') }}
183
+ value={component.properties.background ? 2 : 1}
184
+ onChange={(value) => updateProperty('background', value === 2, component, onPropertyChange)}
185
+ />
186
+ </div>
187
+ </div>
109
188
  {/if}
@@ -53,6 +53,7 @@ const translations = {
53
53
  'constructor.props.form': 'Форма',
54
54
  'constructor.props.type': 'Тип',
55
55
  'constructor.props.size': 'Размер',
56
+ 'constructor.props.footer': 'Нижняя панель',
56
57
  'constructor.props.header': 'Заголовок пакета',
57
58
  'constructor.props.argument': 'Аргумент',
58
59
  'constructor.props.argument.info': 'Пользовательский аргумент (a-z, A-Z, 0-9, -_!)',
@@ -68,6 +69,8 @@ const translations = {
68
69
  'constructor.props.height': 'Высота',
69
70
  'constructor.props.colors': 'Цвет фона',
70
71
  'constructor.props.textcolors': 'Цвет текста',
72
+ 'constructor.props.textarea.rows': 'Количество строк',
73
+ 'constructor.props.autocomplete': 'Автозаполнение',
71
74
  'constructor.props.maxlenght': 'Максимальная длина',
72
75
  'constructor.props.regexp': 'Выражение валидации',
73
76
  'constructor.props.regexp.info': 'Введите RegExp без /.../ (например: ^\\d+$)',
@@ -82,7 +85,7 @@ const translations = {
82
85
  'constructor.props.istest': 'Тестовые данные',
83
86
  'constructor.props.variable': 'Имя переменной',
84
87
  'constructor.props.widthMode': 'Ширина кнопок',
85
- 'constructor.props.graphdata.title': 'Начальные данные',
88
+ 'constructor.props.graphdata.title': 'Начальные данные ',
86
89
  'constructor.props.options.title': 'Опции компонента',
87
90
  'constructor.props.valuetype': 'Тип значения',
88
91
  'constructor.props.action': 'Действие при переключении',
@@ -119,6 +122,21 @@ const translations = {
119
122
  'constructor.props.icon.network': 'Сеть',
120
123
  'constructor.props.icon.power': 'Питание',
121
124
  'constructor.props.icon.settings': 'Настройки',
125
+ 'constructor.props.autocomplete.on': 'on',
126
+ 'constructor.props.autocomplete.off': 'off',
127
+ 'constructor.props.autocomplete.given-name': 'given-name',
128
+ 'constructor.props.autocomplete.family-name': 'family-name',
129
+ 'constructor.props.autocomplete.name': 'name',
130
+ 'constructor.props.autocomplete.email': 'email',
131
+ 'constructor.props.autocomplete.username': 'username',
132
+ 'constructor.props.autocomplete.new-password': 'new-password',
133
+ 'constructor.props.autocomplete.current-password': 'current-password',
134
+ 'constructor.props.autocomplete.tel': 'tel',
135
+ 'constructor.props.autocomplete.country-name': 'country-name',
136
+ 'constructor.props.autocomplete.address-level1': 'address-level1',
137
+ 'constructor.props.autocomplete.address-level2': 'address-level2',
138
+ 'constructor.props.autocomplete.street-address': 'street-address',
139
+ 'constructor.props.autocomplete.postal-code': 'postal-code',
122
140
  },
123
141
  en: {},
124
142
  zh: {},
package/dist/options.d.ts CHANGED
@@ -85,4 +85,9 @@ export declare const optionsStore: import("svelte/store").Readable<{
85
85
  value: string;
86
86
  name: string;
87
87
  }[];
88
+ AUTOCOMPLETE_OPTIONS: {
89
+ id: string;
90
+ value: string;
91
+ name: string;
92
+ }[];
88
93
  }>;
package/dist/options.js CHANGED
@@ -92,5 +92,22 @@ export const optionsStore = derived(t, ($t) => {
92
92
  { id: id(), value: 'square', name: $t('constructor.props.type.square') },
93
93
  { id: id(), value: 'circle', name: $t('constructor.props.type.circle') },
94
94
  ],
95
+ AUTOCOMPLETE_OPTIONS: [
96
+ { id: id(), value: 'on', name: $t('constructor.props.autocomplete.on') },
97
+ { id: id(), value: 'off', name: $t('constructor.props.autocomplete.off') },
98
+ { id: id(), value: 'given-name', name: $t('constructor.props.autocomplete.given-name') },
99
+ { id: id(), value: 'family-name', name: $t('constructor.props.autocomplete.family-name') },
100
+ { id: id(), value: 'name', name: $t('constructor.props.autocomplete.name') },
101
+ { id: id(), value: 'email', name: $t('constructor.props.autocomplete.email') },
102
+ { id: id(), value: 'username', name: $t('constructor.props.autocomplete.username') },
103
+ { id: id(), value: 'new-password', name: $t('constructor.props.autocomplete.new-password') },
104
+ { id: id(), value: 'current-password', name: $t('constructor.props.autocomplete.current-password') },
105
+ { id: id(), value: 'tel', name: $t('constructor.props.autocomplete.tel') },
106
+ { id: id(), value: 'country-name', name: $t('constructor.props.autocomplete.country-name') },
107
+ { id: id(), value: 'address-level1', name: $t('constructor.props.autocomplete.address-level1') },
108
+ { id: id(), value: 'address-level2', name: $t('constructor.props.autocomplete.address-level2') },
109
+ { id: id(), value: 'street-address', name: $t('constructor.props.autocomplete.street-address') },
110
+ { id: id(), value: 'postal-code', name: $t('constructor.props.autocomplete.postal-code') },
111
+ ],
95
112
  };
96
113
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {