poe-svelte-ui-lib 1.2.21 → 1.2.23

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.
@@ -18,7 +18,7 @@
18
18
  </script>
19
19
 
20
20
  <div
21
- {id}
21
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
22
22
  class={twMerge(
23
23
  `${outline ? 'border-none' : 'rounded-xl hover:shadow-md'} w-full
24
24
  border border-(--border-color) bg-(--container-color) p-0 transition-shadow duration-250`,
@@ -163,8 +163,9 @@
163
163
 
164
164
  <UI.Switch
165
165
  label={{ name: $t('constructor.props.open') }}
166
- value={component.properties.isOpen ? 2 : 1}
167
- onChange={(value) => updateProperty('isOpen', value === 2, component, onPropertyChange)}
166
+ value={component.properties.isOpen}
167
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
168
+ onChange={(value) => updateProperty('isOpen', value, component, onPropertyChange)}
168
169
  />
169
170
  </div>
170
171
  <div class="flex w-1/3 flex-col items-center px-2">
@@ -7,6 +7,7 @@
7
7
 
8
8
  let {
9
9
  id = crypto.randomUUID(),
10
+
10
11
  wrapperClass = '',
11
12
  componentClass = '',
12
13
  disabled = false,
@@ -67,7 +68,7 @@
67
68
 
68
69
  <div class={twMerge(`relative flex w-full flex-col items-center `, wrapperClass)}>
69
70
  <button
70
- {id}
71
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
71
72
  class="{twMerge(
72
73
  `relative m-0 inline-block w-full items-center rounded-2xl
73
74
  px-2 py-1 font-semibold transition duration-200 select-none
@@ -99,6 +99,13 @@
99
99
  />
100
100
  </div>
101
101
  <div class="flex w-1/3 flex-col px-2">
102
+ <UI.Select
103
+ label={{ name: $t('constructor.props.icon.access') }}
104
+ type="buttons"
105
+ options={$optionsStore.ACCESS_OPTION}
106
+ value={$optionsStore.ACCESS_OPTION.find((o) => o.value === component.properties.access)}
107
+ onUpdate={(option) => updateProperty('acces', option.value as string, component, onPropertyChange)}
108
+ />
102
109
  <UI.Input
103
110
  label={{ name: $t('constructor.props.name') }}
104
111
  value={component.properties.content.name}
@@ -141,8 +148,9 @@
141
148
  <UI.Switch
142
149
  wrapperClass="bg-blue"
143
150
  label={{ name: $t('constructor.props.disabled') }}
144
- value={component.properties.disabled ? 2 : 1}
145
- onChange={(value) => updateProperty('disabled', value === 2, component, onPropertyChange)}
151
+ value={component.properties.disabled}
152
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
153
+ onChange={(value) => updateProperty('disabled', value, component, onPropertyChange)}
146
154
  />
147
155
  </div>
148
156
  <div class="flex w-1/3 flex-col px-2">
@@ -5,6 +5,7 @@
5
5
 
6
6
  let {
7
7
  id = crypto.randomUUID(),
8
+
8
9
  wrapperClass = '',
9
10
  label = { name: '', class: '' },
10
11
  value = [0, 0, 0],
@@ -129,7 +130,7 @@
129
130
  })
130
131
  </script>
131
132
 
132
- <div {id} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
133
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
133
134
  {#if label.name}
134
135
  <h5 class={twMerge(`w-full px-4 text-center`, label.class)}>{label.name}</h5>
135
136
  {/if}
@@ -49,6 +49,15 @@
49
49
  }}
50
50
  />
51
51
  </div>
52
+ <div class="flex w-1/3 flex-col items-center px-2">
53
+ <UI.Select
54
+ label={{ name: $t('constructor.props.icon.access') }}
55
+ type="buttons"
56
+ options={$optionsStore.ACCESS_OPTION}
57
+ value={$optionsStore.ACCESS_OPTION.find((o) => o.value === component.properties.access)}
58
+ onUpdate={(option) => updateProperty('acces', option.value as string, component, onPropertyChange)}
59
+ />
60
+ </div>
52
61
  <div class="flex w-1/3 flex-col px-2">
53
62
  <UI.Input
54
63
  label={{ name: $t('constructor.props.label') }}
@@ -77,12 +77,19 @@
77
77
  <span class="text-sm text-gray-500">Image</span>
78
78
  {/if}
79
79
  </button>
80
- <input {id} type="file" class="absolute -z-10 h-0 w-0 overflow-hidden opacity-0" {accept} {disabled} onchange={handleFileChange} />
80
+ <input
81
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
82
+ type="file"
83
+ class="absolute -z-10 h-0 w-0 overflow-hidden opacity-0"
84
+ {accept}
85
+ {disabled}
86
+ onchange={handleFileChange}
87
+ />
81
88
  </div>
82
89
  {:else}
83
90
  <label class="relative inline-block w-full">
84
91
  <input
85
- {id}
92
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
86
93
  type="file"
87
94
  class={`h-8.5 w-full rounded-2xl bg-(--back-color) font-semibold shadow-sm transition duration-250 hover:shadow-md
88
95
  ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'} invalid:shadow-[0_0_6px(--red-color) file:h-full file:w-1/3
@@ -218,7 +218,7 @@
218
218
  }
219
219
  </script>
220
220
 
221
- <div {id} class={`relative flex w-full flex-col items-center justify-center ${wrapperClass}`}>
221
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={`relative flex w-full flex-col items-center justify-center ${wrapperClass}`}>
222
222
  {#if label.name}
223
223
  <h5 class={`w-full px-4 text-center ${label.class}`}>{label.name}</h5>
224
224
  {/if}
@@ -67,8 +67,9 @@
67
67
  <UI.Switch
68
68
  wrapperClass="bg-blue"
69
69
  label={{ name: $t('constructor.props.istest') }}
70
- value={component.properties.isTest ? 2 : 1}
71
- onChange={(value) => updateProperty('isTest', value === 2, component, onPropertyChange)}
70
+ value={component.properties.isTest}
71
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
72
+ onChange={(value) => updateProperty('isTest', value, component, onPropertyChange)}
72
73
  />
73
74
  </div>
74
75
  </div>
@@ -6,6 +6,7 @@
6
6
 
7
7
  let {
8
8
  id = crypto.randomUUID(),
9
+
9
10
  wrapperClass = '',
10
11
  label = { name: '', class: '' },
11
12
  disabled = false,
@@ -74,7 +75,7 @@
74
75
  componentClass,
75
76
  )}
76
77
  style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
77
- {id}
78
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
78
79
  {placeholder}
79
80
  {disabled}
80
81
  autocomplete={help?.autocomplete}
@@ -99,7 +100,7 @@
99
100
  componentClass,
100
101
  )}
101
102
  style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
102
- {id}
103
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
103
104
  {disabled}
104
105
  {maxlength}
105
106
  rows={textareaRows}
@@ -100,6 +100,13 @@
100
100
  updateProperty('eventHandler.Variables', value.value as string)
101
101
  }}
102
102
  />
103
+ <UI.Select
104
+ label={{ name: $t('constructor.props.icon.access') }}
105
+ type="buttons"
106
+ options={$optionsStore.ACCESS_OPTION}
107
+ value={$optionsStore.ACCESS_OPTION.find((o) => o.value === component.properties.access)}
108
+ onUpdate={(option) => updateProperty('acces', option.value as string)}
109
+ />
103
110
  <UI.Select
104
111
  label={{ name: $t('constructor.props.type') }}
105
112
  options={$optionsStore.INPUT_TYPE_OPTIONS}
@@ -161,13 +168,15 @@
161
168
  />
162
169
  <UI.Switch
163
170
  label={{ name: $t('constructor.props.readonly') }}
164
- value={component.properties.readonly ? 2 : 1}
165
- onChange={(value) => updateProperty('readonly', value === 2)}
171
+ value={component.properties.readonly}
172
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
173
+ onChange={(value) => updateProperty('readonly', value)}
166
174
  />
167
175
  <UI.Switch
168
176
  label={{ name: $t('constructor.props.copy') }}
169
- value={component.properties.help.copyButton ? 2 : 1}
170
- onChange={(value) => updateProperty('help.copyButton', value === 2)}
177
+ value={component.properties.help.copyButton}
178
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
179
+ onChange={(value) => updateProperty('help.copyButton', value)}
171
180
  />
172
181
  </div>
173
182
  <div class="flex w-1/3 flex-col px-2">
@@ -320,18 +329,21 @@
320
329
 
321
330
  <UI.Switch
322
331
  label={{ name: $t('constructor.props.readonly') }}
323
- value={component.properties.readonly ? 2 : 1}
324
- onChange={(value) => updateProperty('readonly', value === 2)}
332
+ value={component.properties.readonly}
333
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
334
+ onChange={(value) => updateProperty('readonly', value)}
325
335
  />
326
336
  <UI.Switch
327
337
  label={{ name: $t('constructor.props.copy') }}
328
- value={component.properties.help.copyButton ? 2 : 1}
329
- onChange={(value) => updateProperty('help.copyButton', value === 2)}
338
+ value={component.properties.help.copyButton}
339
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
340
+ onChange={(value) => updateProperty('help.copyButton', value)}
330
341
  />
331
342
  <UI.Switch
332
343
  label={{ name: $t('constructor.props.disabled') }}
333
- value={component.properties.disabled ? 2 : 1}
334
- onChange={(value) => updateProperty('disabled', value === 2)}
344
+ value={component.properties.disabled}
345
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
346
+ onChange={(value) => updateProperty('disabled', value)}
335
347
  />
336
348
  </div>
337
349
  </div>
@@ -4,6 +4,7 @@
4
4
 
5
5
  let {
6
6
  id = crypto.randomUUID(),
7
+
7
8
  wrapperClass = '',
8
9
  label = { name: '', class: '' },
9
10
  value = $bindable([0, 0, 0]),
@@ -27,7 +28,7 @@
27
28
  return
28
29
  }
29
30
 
30
- value[2] += sensitivity
31
+ value[2] = roundToClean(value[2] + sensitivity)
31
32
  onUpdate(value)
32
33
  },
33
34
  },
@@ -40,14 +41,14 @@
40
41
  value[2] = limits[2].maxNum
41
42
  onUpdate(value)
42
43
  } else {
43
- value[2] += sensitivity
44
+ value[2] = roundToClean(value[2] + sensitivity)
44
45
  onUpdate(value)
45
46
  }
46
47
  if (value[1] - sensitivity <= limits[1].minNum) {
47
48
  value[1] = limits[1].minNum
48
49
  onUpdate(value)
49
50
  } else {
50
- value[1] -= sensitivity
51
+ value[1] = roundToClean(value[1] - sensitivity)
51
52
  onUpdate(value)
52
53
  }
53
54
  },
@@ -62,7 +63,7 @@
62
63
  onUpdate(value)
63
64
  return
64
65
  }
65
- value[1] -= sensitivity
66
+ value[1] = roundToClean(value[1] - sensitivity)
66
67
  onUpdate(value)
67
68
  },
68
69
  },
@@ -75,14 +76,14 @@
75
76
  value[2] = limits[2].minNum
76
77
  onUpdate(value)
77
78
  } else {
78
- value[2] -= sensitivity
79
+ value[2] = roundToClean(value[2] - sensitivity)
79
80
  onUpdate(value)
80
81
  }
81
82
  if (value[1] - sensitivity <= limits[1].minNum) {
82
83
  value[1] = limits[1].minNum
83
84
  onUpdate(value)
84
85
  } else {
85
- value[1] -= sensitivity
86
+ value[1] = roundToClean(value[1] - sensitivity)
86
87
  onUpdate(value)
87
88
  }
88
89
  },
@@ -97,7 +98,7 @@
97
98
  onUpdate(value)
98
99
  return
99
100
  }
100
- value[2] -= sensitivity
101
+ value[2] = roundToClean(value[2] - sensitivity)
101
102
  onUpdate(value)
102
103
  },
103
104
  },
@@ -110,14 +111,14 @@
110
111
  value[1] = limits[1].maxNum
111
112
  onUpdate(value)
112
113
  } else {
113
- value[1] += sensitivity
114
+ value[1] = roundToClean(value[1] + sensitivity)
114
115
  onUpdate(value)
115
116
  }
116
117
  if (value[2] - sensitivity <= limits[2].minNum) {
117
118
  value[2] = limits[2].minNum
118
119
  onUpdate(value)
119
120
  } else {
120
- value[2] -= sensitivity
121
+ value[2] = roundToClean(value[2] - sensitivity)
121
122
  onUpdate(value)
122
123
  }
123
124
  },
@@ -132,7 +133,7 @@
132
133
  onUpdate(value)
133
134
  return
134
135
  }
135
- value[1] += sensitivity
136
+ value[1] = roundToClean(value[1] + sensitivity)
136
137
  onUpdate(value)
137
138
  },
138
139
  },
@@ -145,14 +146,14 @@
145
146
  value[1] = limits[1].maxNum
146
147
  onUpdate(value)
147
148
  } else {
148
- value[1] += sensitivity
149
+ value[1] = roundToClean(value[1] + sensitivity)
149
150
  onUpdate(value)
150
151
  }
151
152
  if (value[2] + sensitivity >= limits[2].maxNum) {
152
153
  value[2] = limits[2].maxNum
153
154
  onUpdate(value)
154
155
  } else {
155
- value[2] += sensitivity
156
+ value[2] = roundToClean(value[2] + sensitivity)
156
157
  onUpdate(value)
157
158
  }
158
159
  },
@@ -164,15 +165,28 @@
164
165
 
165
166
  let clipPos = Math.cos(Math.PI / directions.length) * 100
166
167
  let angle = 360 / directions.length
168
+
169
+ const roundToClean = (num: number): number => {
170
+ if (Number.isInteger(num)) return num
171
+
172
+ const rounded1 = Number(num.toFixed(1))
173
+ if (Math.abs(rounded1 - num) < 1e-10) return rounded1
174
+
175
+ const rounded2 = Number(num.toFixed(2))
176
+ if (Math.abs(rounded2 - num) < 1e-10) return rounded2
177
+
178
+ return rounded2
179
+ }
167
180
  </script>
168
181
 
169
- <div {id} class={twMerge(`bg-blue relative flex w-full flex-col items-center`, wrapperClass)}>
182
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`bg-red relative flex w-full flex-col items-center`, wrapperClass)}>
170
183
  {#if label.name}
171
184
  <h5 class={twMerge(` w-full px-4 text-center`, label.class)}>{label.name}</h5>
172
185
  {/if}
173
186
 
174
- <div class=" flex items-center justify-center">
187
+ <div class=" flex w-1/2 items-center justify-center">
175
188
  <div class="relative z-10 flex size-40 items-center justify-center rounded-full bg-(--bg-color) shadow-[0_0_20px_rgb(0_0_0_/0.25)]">
189
+ <!-- Основные кнопки (оси pitch и yaw) -->
176
190
  <div class="absolute h-full w-full overflow-hidden rounded-full">
177
191
  {#each directions as direction, index}
178
192
  <button
@@ -205,6 +219,7 @@
205
219
  </button>
206
220
  {/each}
207
221
  </div>
222
+ <!-- Линии для разделения на сектора -->
208
223
  <div class="pointer-events-none absolute h-full w-full overflow-hidden rounded-full">
209
224
  {#each directions as direction, index}
210
225
  <span
@@ -216,6 +231,7 @@
216
231
  </span>
217
232
  {/each}
218
233
  </div>
234
+ <!-- Кнопка домой -->
219
235
  <div
220
236
  class="z-20 flex size-20 items-center justify-center rounded-full bg-(--bg-color) shadow-[0_0_15px_rgb(0_0_0_/0.25)] transition hover:scale-103"
221
237
  >
@@ -235,6 +251,7 @@
235
251
  >
236
252
  </div>
237
253
  </div>
254
+ <!-- Боковые кнопки (ось roll) -->
238
255
  <div
239
256
  class="absolute flex h-15 w-65 items-center justify-between rounded-full shadow-[0_0_15px_rgb(0_0_0_/0.25)]"
240
257
  style="background: color-mix(in srgb, var(--bg-color), var(--shadow-color) 10%)"
@@ -288,40 +305,51 @@
288
305
  </div>
289
306
  </div>
290
307
 
291
- <p>{value[0]}</p>
292
- <p>{value[1]}</p>
293
- <p>{value[2]}</p>
294
-
295
- <div {id} class="flex h-full w-full flex-row justify-center rounded-full p-10">
296
- {#each sensitivityOptions as option, index}
297
- <button
298
- id={crypto.randomUUID()}
299
- class={twMerge(`m-0 inline-block min-w-0 flex-1 cursor-pointer items-center px-2 py-1 font-semibold shadow-sm transition-all duration-300
308
+ <div class="absolute right-10 flex items-center">
309
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class="flex h-full flex-col justify-center rounded-full p-10">
310
+ {#each sensitivityOptions as option, index}
311
+ <button
312
+ id={crypto.randomUUID()}
313
+ class={twMerge(`m-0 inline-block min-w-0 flex-1 cursor-pointer items-center px-2 py-1 font-semibold shadow-sm transition-all duration-300
300
314
  select-none hover:shadow-md
301
315
  ${
302
316
  option === sensitivity && sensitivity !== null
303
317
  ? 'z-10 py-1 shadow-[0_0_10px_var(--shadow-color)] hover:shadow-[0_0_15px_var(--shadow-color)]'
304
318
  : ''
305
319
  }
306
- ${sensitivityOptions.length > 0 && index === 0 ? 'rounded-l-2xl' : ''} ${
307
- index === sensitivityOptions.length - 1 ? 'rounded-r-2xl' : ''
320
+ ${sensitivityOptions.length > 0 && index === 0 ? 'rounded-t-2xl' : ''} ${
321
+ index === sensitivityOptions.length - 1 ? 'rounded-b-2xl' : ''
308
322
  } bg-(--back-color)`)}
309
- onclick={() => {
310
- sensitivity = option
311
- }}
312
- >
313
- <span class="flex flex-row items-center justify-center gap-4">
314
- {#if option}
315
- <div class="flex-1">
316
- {option}
317
- </div>
318
- {/if}
319
- </span>
320
- </button>
321
- {/each}
323
+ onclick={() => {
324
+ sensitivity = option
325
+ }}
326
+ >
327
+ <span class="flex flex-row items-center justify-center gap-4">
328
+ {#if option}
329
+ <div class="flex-1">
330
+ {option}
331
+ </div>
332
+ {/if}
333
+ </span>
334
+ </button>
335
+ {/each}
336
+ </div>
337
+
338
+ <div>
339
+ {#each [0, 1, 2] as num}
340
+ <h5 class={twMerge(` w-full px-4 text-center`, label.class)}>{num == 0 ? 'Roll' : num == 1 ? 'Pitch' : 'Yaw'}</h5>
341
+ <input
342
+ class={`w-20 rounded-2xl border border-(--border-color) px-4 py-1 text-center transition-all duration-300 outline-none
343
+ hover:shadow-md
344
+ [&::-webkit-inner-spin-button]:hidden
345
+ [&::-webkit-outer-spin-button]:hidden`}
346
+ style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
347
+ value={value[num]}
348
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
349
+ readonly
350
+ />
351
+ {/each}
352
+ </div>
322
353
  </div>
323
- <!-- {direction.content ? 2 * 6.25 * Math.sin((Math.PI * 65) / 360) : 2 * 6.25 * Math.sin((Math.PI * 25) / 360)} -->
324
- <!-- angle / 2 + angle * index -->
325
- <!-- ? 'shadow-[0_-2px_5px_rgb(254_202_202)] '
326
- : 'shadow-[0_2px_5px_rgb(254_202_202)]'}" -->
327
354
  </div>
355
+ <!-- sensitivity == 0.01 ? value[num].toFixed(2) : sensitivity == 0.1 ? value[num].toFixed(1) : value[num].toFixed(0) -->
@@ -40,7 +40,7 @@
40
40
  })
41
41
  </script>
42
42
 
43
- <div {id} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
43
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class={twMerge(`relative flex w-full flex-col items-center`, wrapperClass)}>
44
44
  {#if label.name}
45
45
  <h5 class={twMerge(` w-full px-4 text-center`, label.class)}>{label.name}</h5>
46
46
  {/if}
@@ -14,11 +14,13 @@
14
14
 
15
15
  let {
16
16
  id = crypto.randomUUID(),
17
+
17
18
  wrapperClass = '',
18
19
  disabled = false,
19
20
  label = { name: '', class: '' },
20
21
  type = 'select',
21
22
  value = $bindable(),
23
+ bitMode = false,
22
24
  options = [],
23
25
  onUpdate,
24
26
  }: ISelectProps<T> = $props()
@@ -92,7 +94,7 @@
92
94
  {/if}
93
95
  {#if type === 'select'}
94
96
  <button
95
- {id}
97
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
96
98
  value={value?.value ? String(value.value) : ''}
97
99
  class={twMerge(
98
100
  `w-full rounded-2xl border border-(--border-color) p-1 text-center duration-250
@@ -133,7 +135,7 @@
133
135
  </div>
134
136
  {/if}
135
137
  {:else if type === 'buttons'}
136
- <div {id} class="flex h-full w-full flex-row justify-center rounded-full border border-(--bg-color)">
138
+ <div id={`${id}-${crypto.randomUUID().slice(0, 6)}`} class="flex h-full w-full flex-row justify-center rounded-full border border-(--bg-color)">
137
139
  {#each options as option, index (option.id)}
138
140
  <button
139
141
  id={option.id}
@@ -165,7 +167,7 @@
165
167
  [&::-webkit-inner-spin-button]:hidden [&::-webkit-outer-spin-button]:hidden
166
168
  {disabled ? 'cursor-not-allowed opacity-50' : 'cursor-text'} border-(--border-color)"
167
169
  style="background: color-mix(in srgb, var(--bg-color), var(--back-color) 70%);"
168
- {id}
170
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
169
171
  {disabled}
170
172
  oninput={(e) => handleSearch((e.currentTarget as HTMLInputElement).value)}
171
173
  onclick={(e) => {
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { getContext } from 'svelte'
2
+ import { getContext, onMount } from 'svelte'
3
3
  import { t } from '../locales/i18n'
4
4
  import { type UIComponent, type ISelectProps, type ISelectOption, updateProperty } from '../types'
5
5
  import * as UI from '..'
@@ -46,11 +46,26 @@
46
46
 
47
47
  let currentType = $derived($optionsStore.SELECT_TYPE_OPTIONS.find((t) => t.value === component.properties.type))
48
48
 
49
- const initialColor = $derived(
50
- $optionsStore.COLOR_OPTIONS.find((c) =>
51
- (c.value as string).includes(component.properties.wrapperClass?.split(' ').find((cls: string) => cls.startsWith('bg-'))),
52
- ),
53
- )
49
+ let range = $state({ start: 0, end: 0 })
50
+
51
+ const generateBitOptions = () => {
52
+ const bitsNeeded = range.end - range.start + 1
53
+ const count = Math.pow(2, bitsNeeded)
54
+
55
+ const options: ISelectOption<number>[] = []
56
+
57
+ for (let i = 0; i < count; i++) {
58
+ const binary = i.toString(2).padStart(bitsNeeded, '0')
59
+
60
+ options.push({
61
+ id: crypto.randomUUID(),
62
+ value: parseInt(binary, 2) << range.start,
63
+ name: binary,
64
+ class: 'bg-max',
65
+ })
66
+ }
67
+ updateProperty('options', options, component, onPropertyChange)
68
+ }
54
69
 
55
70
  const initialAlign = $derived(
56
71
  $optionsStore.TEXT_ALIGN_OPTIONS.find((a) =>
@@ -103,6 +118,7 @@
103
118
  wrapperClass="h-14"
104
119
  label={{ name: $t('constructor.props.valuetype') }}
105
120
  type="buttons"
121
+ disabled={component.properties.bitMode}
106
122
  options={$optionsStore.SELECT_VALUE_TYPE_OPTIONS}
107
123
  value={currentValueType}
108
124
  onUpdate={(value) => {
@@ -116,6 +132,32 @@
116
132
  updateProperty('options', options, component, onPropertyChange)
117
133
  }}
118
134
  />
135
+ {#if component.properties.bitMode}
136
+ <div class="flex w-full gap-4">
137
+ <UI.Input
138
+ label={{ name: $t('constructor.props.range.start') }}
139
+ value={range.start}
140
+ onUpdate={(value) => {
141
+ range.start = value as number
142
+ generateBitOptions()
143
+ }}
144
+ number={{ minNum: 0, maxNum: 31, step: 1 }}
145
+ help={{ info: $t('constructor.props.range.start.help') }}
146
+ type="number"
147
+ />
148
+ <UI.Input
149
+ label={{ name: $t('constructor.props.range.end') }}
150
+ value={range.end}
151
+ onUpdate={(value) => {
152
+ range.end = value as number
153
+ generateBitOptions()
154
+ }}
155
+ number={{ minNum: 0, maxNum: 31, step: 1 }}
156
+ help={{ info: $t('constructor.props.range.end.help') }}
157
+ type="number"
158
+ />
159
+ </div>
160
+ {/if}
119
161
  </div>
120
162
  <div class="flex w-1/3 flex-col items-center px-2">
121
163
  <UI.Input
@@ -130,6 +172,24 @@
130
172
  options={$optionsStore.TEXT_ALIGN_OPTIONS}
131
173
  onUpdate={(option) => updateProperty('label.class', twMerge(component.properties.label.class, option.value), component, onPropertyChange)}
132
174
  />
175
+ <UI.Switch
176
+ wrapperClass="bg-blue"
177
+ label={{ name: $t('constructor.props.bitmode') }}
178
+ value={component.properties.bitMode}
179
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
180
+ onChange={(value) => {
181
+ updateProperty('bitMode', value, component, onPropertyChange)
182
+ currentValueType = $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1] as ValueTypeOption
183
+ const options = [...(component.properties?.options || [])]
184
+ const newType = $optionsStore.SELECT_VALUE_TYPE_OPTIONS[1].value
185
+ options.forEach((option) => {
186
+ if (newType === 'number') option.value = option.value !== undefined ? Number(option.value) : 0
187
+ else option.value = option.value !== undefined ? String(option.value) : ''
188
+ })
189
+ updateProperty('options', options, component, onPropertyChange)
190
+ if (value) generateBitOptions()
191
+ }}
192
+ />
133
193
  </div>
134
194
  </div>
135
195
 
@@ -232,8 +292,9 @@
232
292
  <UI.Switch
233
293
  wrapperClass="bg-blue"
234
294
  label={{ name: $t('constructor.props.disabled') }}
235
- value={component.properties.disabled ? 2 : 1}
236
- onChange={(value) => updateProperty('disabled', value === 2, component, onPropertyChange)}
295
+ value={component.properties.disabled}
296
+ options={[{ id: crypto.randomUUID(), value: 0, class: '' }]}
297
+ onChange={(value) => updateProperty('disabled', value, component, onPropertyChange)}
237
298
  />
238
299
  </div>
239
300
  <div class="flex w-1/3 flex-col items-center px-2">
@@ -98,7 +98,10 @@
98
98
  {/if}
99
99
 
100
100
  <!-- Слайдер -->
101
- <div {id} class="relative flex h-7 w-full justify-center rounded-full {disabled ? 'cursor-not-allowed opacity-50' : ''}">
101
+ <div
102
+ id={`${id}-${crypto.randomUUID().slice(0, 6)}`}
103
+ class="relative flex h-7 w-full justify-center rounded-full {disabled ? 'cursor-not-allowed opacity-50' : ''}"
104
+ >
102
105
  {#if isRange}
103
106
  <!-- Трек и активная зона -->
104
107
  <div