poe-svelte-ui-lib 1.2.0 → 1.2.2

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.
@@ -20,7 +20,7 @@
20
20
  Components,
21
21
  }: ITabsProps = $props()
22
22
 
23
- const isCol = $derived(items.find((item) => item.class?.startsWith('flex-col')))
23
+ const isCol = $derived(!!items.find((item) => item.class?.startsWith('flex-col')))
24
24
 
25
25
  let currentTabIndex: number = $state(activeTab)
26
26
  </script>
@@ -28,13 +28,13 @@
28
28
  <div {id} class="w-full rounded-2xl bg-(--back-color)">
29
29
  <!-- Вкладки -->
30
30
  <div
31
- class="{twMerge('bg-blue sticky top-0 z-50 flex h-fit items-center overflow-x-auto rounded-t-2xl px-1 pt-1', wrapperClass)}
31
+ class="{twMerge('bg-blue sticky top-0 z-50 flex h-fit items-center overflow-x-auto rounded-t-2xl px-1', wrapperClass)}
32
32
  bg-(--bg-color)"
33
33
  >
34
34
  {#each items as item, index}
35
35
  <button
36
36
  class={twMerge(
37
- `tab mt-1 flex min-w-fit cursor-pointer items-center justify-center gap-0 self-end rounded-t-2xl px-5 py-2.5 ${!isCol && 'gap-2'}`,
37
+ `tab mt-1 flex min-w-fit cursor-pointer items-center justify-center gap-0 self-end rounded-t-2xl px-5 py-2.5 ${isCol && items.find((item) => item.icon) ? 'h-20' : 'gap-2'}`,
38
38
  item.class,
39
39
  index === currentTabIndex ? twMerge('bg-(--back-color) text-blue-500', item.class) : 'bg-(--bg-color) text-gray-500',
40
40
  )}
@@ -50,7 +50,7 @@
50
50
  {/if}
51
51
  </button>
52
52
  <span
53
- class="h-[{isCol && items.find((item) => item.icon) ? 35 : 16}px] w-0 border border-l {index !== items.length - 1 &&
53
+ class="{isCol && items.find((item) => item.icon) ? 'h-9' : 'h-4'} w-0 border border-l {index !== items.length - 1 &&
54
54
  index !== currentTabIndex &&
55
55
  index !== currentTabIndex - 1
56
56
  ? 'border-gray-500'
@@ -137,7 +137,6 @@
137
137
  updateProperty('items', items, component, onPropertyChange)
138
138
  })
139
139
  }
140
- console.log(component.properties?.items)
141
140
  }}
142
141
  />
143
142
  </div>
@@ -239,12 +238,10 @@
239
238
  value={component.properties.id}
240
239
  onUpdate={(value) => updateProperty('id', value as string, component, onPropertyChange)}
241
240
  />
242
- <UI.Select
243
- label={{ name: $t('constructor.props.type') }}
244
- type="buttons"
245
- value={initialType}
246
- options={$optionsStore.ACCORDION_TYPE_OPTIONS}
247
- onUpdate={(item) => updateProperty('outline', item.value as boolean, component, onPropertyChange)}
241
+ <UI.Input
242
+ label={{ name: $t('constructor.props.wrapperclass') }}
243
+ value={component.properties.wrapperClass}
244
+ onUpdate={(value) => updateProperty('wrapperClass', value as string, component, onPropertyChange)}
248
245
  />
249
246
  <div class="flex w-full gap-4">
250
247
  <UI.Input
@@ -262,88 +259,160 @@
262
259
  type="number"
263
260
  />
264
261
  </div>
262
+ </div>
263
+ <div class="flex w-1/3 flex-col items-center px-2">
264
+ <UI.Select
265
+ label={{ name: $t('constructor.props.align') }}
266
+ type="buttons"
267
+ value={initialAlign}
268
+ options={$optionsStore.JUSTIFY_ALIGN_OPTIONS}
269
+ onUpdate={(option) => updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)}
270
+ />
265
271
 
266
- <UI.Switch
267
- label={{ name: $t('constructor.props.open') }}
268
- value={component.properties.isOpen ? 2 : 1}
269
- onChange={(value) => updateProperty('isOpen', value === 2, component, onPropertyChange)}
272
+ <UI.Select
273
+ wrapperClass="h-14"
274
+ label={{ name: $t('constructor.props.colors') }}
275
+ type="buttons"
276
+ options={$optionsStore.COLOR_OPTIONS.slice(1)}
277
+ value={initialColor}
278
+ onUpdate={(option) => {
279
+ updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)
280
+ component.properties.items.forEach((_item: any, index: number) => {
281
+ const items = [...(component.properties?.items || [])]
282
+ items[index]['class'] = twMerge(items[index].class, `text-${option.value?.slice(3)}-500`)
283
+ updateProperty('items', items, component, onPropertyChange)
284
+ })
285
+ }}
270
286
  />
271
287
  </div>
272
288
  <div class="flex w-1/3 flex-col items-center px-2">
273
- <UI.Input
274
- label={{ name: $t('constructor.props.wrapperclass') }}
275
- value={component.properties.wrapperClass}
276
- onUpdate={(value) => updateProperty('wrapperClass', value as string, component, onPropertyChange)}
289
+ <UI.Select
290
+ wrapperClass="h-14"
291
+ label={{ name: $t('constructor.props.icon.text.position') }}
292
+ type="buttons"
293
+ options={$optionsStore.ICON_TEXT_POSITION_OPTIONS}
294
+ value={initialPosition}
295
+ onUpdate={(option) => {
296
+ component.properties.items.forEach((_item: any, index: number) => {
297
+ const items = [...(component.properties?.items || [])]
298
+ items[index]['class'] = twMerge(items[index].class, option.value)
299
+ updateProperty('items', items, component, onPropertyChange)
300
+ })
301
+ }}
277
302
  />
278
- <div class="relative mt-5 flex w-full gap-2">
279
- <UI.Button content={{ name: $t('constructor.props.labelicon') }} onClick={() => (showIconLib = true)} />
280
- {#if showIconLib}
281
- <Modal bind:isOpen={showIconLib} wrapperClass="w-130">
282
- {#snippet main()}
283
- <div class="grid grid-cols-3">
284
- {#each ICONS as category}
285
- <div class="relative m-1.5 rounded-xl border-2 border-(--border-color) p-3">
286
- <div class="absolute -top-3.5 bg-(--back-color) px-1">{$t(`constructor.props.icon.${category[0]}`)}</div>
287
- <div class="grid grid-cols-3 place-items-center gap-2">
288
- {#each category[1] as icon}
289
- <button
290
- class="h-8 w-8 cursor-pointer [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
291
- onclick={() => {
292
- updateProperty('label.icon', icon as string, component, onPropertyChange)
293
- }}
294
- >
295
- {@html icon}
296
- </button>{/each}
297
- </div>
298
- </div>
299
- {/each}
300
- </div>
301
- {/snippet}
302
- </Modal>
303
- {/if}
304
- {#if component.properties.label.icon}
305
- <Button
306
- wrapperClass="w-8.5 "
307
- componentClass="p-0.5 bg-red"
308
- content={{ icon: CrossIcon }}
309
- onClick={() => {
310
- updateProperty('label.icon', '', component, onPropertyChange)
311
- }}
312
- />
313
- {/if}
314
- </div>
315
-
316
- <UI.Input
317
- label={{ name: $t('constructor.props.label') }}
318
- value={component.properties.label.name}
319
- onUpdate={(value) => updateProperty('label.name', value as string, component, onPropertyChange)}
303
+ <UI.Switch
304
+ label={{
305
+ name: $t('constructor.props.widthMode'),
306
+ captionLeft: $t('constructor.props.height.small'),
307
+ captionRight: $t('constructor.props.equal'),
308
+ }}
309
+ value={initialWidth()}
310
+ onChange={(value) => {
311
+ if (value === 2) {
312
+ component.properties.items.forEach((_item: any, index: number) => {
313
+ let tabWidth = Math.max(...Array.from(document.body.querySelectorAll('.tab')).map((item) => (item as HTMLElement).offsetWidth))
314
+ const items = [...(component.properties?.items || [])]
315
+ items[index]['class'] = twMerge(items[index].class, `w-[${tabWidth}px]`)
316
+ updateProperty('items', items, component, onPropertyChange)
317
+ })
318
+ } else {
319
+ component.properties.items.forEach((_item: any, index: number) => {
320
+ const items = [...(component.properties?.items || [])]
321
+ items[index]['class'] = twMerge(items[index].class, 'w-auto')
322
+ updateProperty('items', items, component, onPropertyChange)
323
+ })
324
+ }
325
+ }}
320
326
  />
321
- <UI.Input
322
- label={{ name: $t('constructor.props.label.class') }}
323
- value={component.properties.label.class}
324
- onUpdate={(value) => updateProperty('label.class', value as string, component, onPropertyChange)}
327
+ </div>
328
+ </div>
329
+
330
+ <div class="space-y-4">
331
+ <div class="m-0 flex items-center justify-center gap-2">
332
+ <h4>{$t('constructor.props.options.title')}</h4>
333
+ <UI.Button
334
+ wrapperClass="w-8"
335
+ content={{ icon: ButtonAdd }}
336
+ onClick={() => {
337
+ let tabWidth = Math.max(...Array.from(document.body.querySelectorAll('.tab')).map((item) => (item as HTMLElement).offsetWidth))
338
+ const newItem: { name: string; icon: string; class: string } = {
339
+ name: `Tab ${component.properties?.items.length + 1}`,
340
+ class: `w-${initialWidth() === 2 ? `[${tabWidth}px]` : 'auto'} text-${initialColor?.value.slice(3)}-500 ${initialPosition?.value}`,
341
+ icon: '',
342
+ }
343
+ const items = [...(component.properties?.items || []), newItem]
344
+ updateProperty('items', items, component, onPropertyChange)
345
+ }}
325
346
  />
326
347
  </div>
327
- <div class="flex w-1/3 flex-col items-center gap-2 px-2">
328
- <div class="flex">
329
- <UI.FileAttach
330
- type="image"
331
- label={{ name: $t('constructor.props.image') }}
332
- accept="image/png, image/jpeg, image/webp"
333
- bind:currentImage
334
- onChange={handleImageUpload}
348
+
349
+ {#each component.properties.items || [] as tab, index}
350
+ <div class="m-0 flex items-end justify-around gap-2 border-gray-400">
351
+ <UI.Input
352
+ label={{ name: $t('constructor.props.optionname') }}
353
+ wrapperClass="w-5/10"
354
+ value={tab.name}
355
+ onUpdate={(value) => {
356
+ const items = [...(component.properties?.items || [])]
357
+ items[index]['name'] = value
358
+ updateProperty('items', items, component, onPropertyChange)
359
+ }}
335
360
  />
336
- {#if currentImage}
337
- <Button
338
- wrapperClass="w-8.5 mt-6"
339
- componentClass="p-0.5 bg-red"
340
- content={{ icon: CrossIcon }}
361
+ <div class="relative mt-5 flex w-3/10 gap-2">
362
+ <UI.Button content={{ name: $t('constructor.props.labelicon') }} onClick={() => (tabIcon = { index: index, isModalOpen: true })} />
363
+
364
+ {#if tab.icon}
365
+ <Button
366
+ wrapperClass="w-8.5 "
367
+ componentClass="p-0.5 bg-red"
368
+ content={{ icon: CrossIcon }}
369
+ onClick={() => {
370
+ const items = [...(component.properties?.items || [])]
371
+ items[index]['icon'] = ''
372
+ updateProperty('items', items, component, onPropertyChange)
373
+ }}
374
+ />
375
+ {/if}
376
+ </div>
377
+
378
+ {#if component.properties.items.length > 1}
379
+ <UI.Button
380
+ wrapperClass="w-8"
381
+ content={{ icon: ButtonDelete }}
341
382
  onClick={() => {
342
- updateProperty('image', '', component, onPropertyChange)
383
+ const items = [...(component.properties?.items || [])]
384
+ items.splice(index, 1)
385
+ updateProperty('items', items, component, onPropertyChange)
343
386
  }}
344
387
  />
345
388
  {/if}
346
389
  </div>
347
- </div>
390
+ {/each}
391
+ {#if tabIcon.isModalOpen}
392
+ <Modal bind:isOpen={tabIcon.isModalOpen} wrapperClass="w-130">
393
+ {#snippet main()}
394
+ <div class="grid grid-cols-3">
395
+ {#each ICONS as category}
396
+ <div class="relative m-1.5 rounded-xl border-2 border-(--border-color) p-3">
397
+ <div class="absolute -top-3.5 bg-(--back-color) px-1">{$t(`constructor.props.icon.${category[0]}`)}</div>
398
+ <div class="grid grid-cols-3 place-items-center gap-2">
399
+ {#each category[1] as icon}
400
+ <button
401
+ class="h-8 w-8 cursor-pointer [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
402
+ onclick={() => {
403
+ const items = [...(component.properties?.items || [])]
404
+ items[tabIcon.index]['icon'] = icon as string
405
+ updateProperty('items', items, component, onPropertyChange)
406
+ }}
407
+ >
408
+ {@html icon}
409
+ </button>{/each}
410
+ </div>
411
+ </div>
412
+ {/each}
413
+ </div>
414
+ {/snippet}
415
+ </Modal>
416
+ {/if}
348
417
  </div>
349
418
  {/if}
package/dist/index.d.ts CHANGED
@@ -26,4 +26,4 @@ export { default as TextField } from './TextField/TextField.svelte';
26
26
  export { default as TextFieldProps } from './TextField/TextFieldProps.svelte';
27
27
  export * from './locales/i18n';
28
28
  export * from './locales/translations';
29
- export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type ISelectOption, type ISwitchProps, type IColorPickerProps, type ISliderProps, type ITextFieldProps, type IProgressBarProps, type IGraphProps, type IGraphDataObject, type ITableHeader, type ITabsProps, } from './types';
29
+ export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type ISelectOption, type ISwitchProps, type IColorPickerProps, type ISliderProps, type ITextFieldProps, type IProgressBarProps, type IGraphProps, type IGraphDataObject, type ITableHeader, type ITableProps, type ITabsProps, } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {