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.
- package/dist/Tabs/Tabs.svelte +4 -4
- package/dist/Tabs/TabsProps.svelte +145 -76
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/Tabs/Tabs.svelte
CHANGED
|
@@ -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
|
|
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 ${
|
|
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="
|
|
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.
|
|
243
|
-
label={{ name: $t('constructor.props.
|
|
244
|
-
|
|
245
|
-
|
|
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.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
label={{ name: $t('constructor.props.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
|
|
337
|
-
<Button
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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';
|