poe-svelte-ui-lib 1.2.0 → 1.2.1

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.
@@ -239,12 +239,10 @@
239
239
  value={component.properties.id}
240
240
  onUpdate={(value) => updateProperty('id', value as string, component, onPropertyChange)}
241
241
  />
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)}
242
+ <UI.Input
243
+ label={{ name: $t('constructor.props.wrapperclass') }}
244
+ value={component.properties.wrapperClass}
245
+ onUpdate={(value) => updateProperty('wrapperClass', value as string, component, onPropertyChange)}
248
246
  />
249
247
  <div class="flex w-full gap-4">
250
248
  <UI.Input
@@ -262,88 +260,161 @@
262
260
  type="number"
263
261
  />
264
262
  </div>
263
+ </div>
264
+ <div class="flex w-1/3 flex-col items-center px-2">
265
+ <UI.Select
266
+ label={{ name: $t('constructor.props.align') }}
267
+ type="buttons"
268
+ value={initialAlign}
269
+ options={$optionsStore.JUSTIFY_ALIGN_OPTIONS}
270
+ onUpdate={(option) => updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)}
271
+ />
265
272
 
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)}
273
+ <UI.Select
274
+ wrapperClass="h-14"
275
+ label={{ name: $t('constructor.props.colors') }}
276
+ type="buttons"
277
+ options={$optionsStore.COLOR_OPTIONS.slice(1)}
278
+ value={initialColor}
279
+ onUpdate={(option) => {
280
+ updateProperty('wrapperClass', twMerge(component.properties.wrapperClass, option.value), component, onPropertyChange)
281
+ component.properties.items.forEach((_item: any, index: number) => {
282
+ const items = [...(component.properties?.items || [])]
283
+ items[index]['class'] = twMerge(items[index].class, `text-${option.value?.slice(3)}-500`)
284
+ updateProperty('items', items, component, onPropertyChange)
285
+ })
286
+ }}
270
287
  />
271
288
  </div>
272
289
  <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)}
290
+ <UI.Select
291
+ wrapperClass="h-14"
292
+ label={{ name: $t('constructor.props.icon.text.position') }}
293
+ type="buttons"
294
+ options={$optionsStore.ICON_TEXT_POSITION_OPTIONS}
295
+ value={initialPosition}
296
+ onUpdate={(option) => {
297
+ component.properties.items.forEach((_item: any, index: number) => {
298
+ const items = [...(component.properties?.items || [])]
299
+ items[index]['class'] = twMerge(items[index].class, option.value)
300
+ updateProperty('items', items, component, onPropertyChange)
301
+ })
302
+ }}
277
303
  />
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)}
304
+ <UI.Switch
305
+ label={{
306
+ name: $t('constructor.props.widthMode'),
307
+ captionLeft: $t('constructor.props.height.small'),
308
+ captionRight: $t('constructor.props.equal'),
309
+ }}
310
+ value={initialWidth()}
311
+ onChange={(value) => {
312
+ if (value === 2) {
313
+ component.properties.items.forEach((_item: any, index: number) => {
314
+ let tabWidth = Math.max(...Array.from(document.body.querySelectorAll('.tab')).map((item) => (item as HTMLElement).offsetWidth))
315
+ const items = [...(component.properties?.items || [])]
316
+ items[index]['class'] = twMerge(items[index].class, `w-[${tabWidth}px]`)
317
+ updateProperty('items', items, component, onPropertyChange)
318
+ })
319
+ } else {
320
+ component.properties.items.forEach((_item: any, index: number) => {
321
+ const items = [...(component.properties?.items || [])]
322
+ items[index]['class'] = twMerge(items[index].class, 'w-auto')
323
+ updateProperty('items', items, component, onPropertyChange)
324
+ })
325
+ }
326
+ console.log(component.properties?.items)
327
+ }}
320
328
  />
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)}
329
+ </div>
330
+ </div>
331
+
332
+ <div class="space-y-4">
333
+ <div class="m-0 flex items-center justify-center gap-2">
334
+ <h4>{$t('constructor.props.options.title')}</h4>
335
+ <UI.Button
336
+ wrapperClass="w-8"
337
+ content={{ icon: ButtonAdd }}
338
+ onClick={() => {
339
+ let tabWidth = Math.max(...Array.from(document.body.querySelectorAll('.tab')).map((item) => (item as HTMLElement).offsetWidth))
340
+ const newItem: { name: string; icon: string; class: string } = {
341
+ name: `Tab ${component.properties?.items.length + 1}`,
342
+ class: `w-${initialWidth() === 2 ? `[${tabWidth}px]` : 'auto'} text-${initialColor?.value.slice(3)}-500 ${initialPosition?.value}`,
343
+ icon: '',
344
+ }
345
+ const items = [...(component.properties?.items || []), newItem]
346
+ updateProperty('items', items, component, onPropertyChange)
347
+ }}
325
348
  />
326
349
  </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}
350
+
351
+ {#each component.properties.items || [] as tab, index}
352
+ <div class="m-0 flex items-end justify-around gap-2 border-gray-400">
353
+ <UI.Input
354
+ label={{ name: $t('constructor.props.optionname') }}
355
+ wrapperClass="w-5/10"
356
+ value={tab.name}
357
+ onUpdate={(value) => {
358
+ const items = [...(component.properties?.items || [])]
359
+ items[index]['name'] = value
360
+ updateProperty('items', items, component, onPropertyChange)
361
+ }}
335
362
  />
336
- {#if currentImage}
337
- <Button
338
- wrapperClass="w-8.5 mt-6"
339
- componentClass="p-0.5 bg-red"
340
- content={{ icon: CrossIcon }}
363
+ <div class="relative mt-5 flex w-3/10 gap-2">
364
+ <UI.Button content={{ name: $t('constructor.props.labelicon') }} onClick={() => (tabIcon = { index: index, isModalOpen: true })} />
365
+
366
+ {#if tab.icon}
367
+ <Button
368
+ wrapperClass="w-8.5 "
369
+ componentClass="p-0.5 bg-red"
370
+ content={{ icon: CrossIcon }}
371
+ onClick={() => {
372
+ const items = [...(component.properties?.items || [])]
373
+ items[index]['icon'] = ''
374
+ updateProperty('items', items, component, onPropertyChange)
375
+ }}
376
+ />
377
+ {/if}
378
+ </div>
379
+
380
+ {#if component.properties.items.length > 1}
381
+ <UI.Button
382
+ wrapperClass="w-8"
383
+ content={{ icon: ButtonDelete }}
341
384
  onClick={() => {
342
- updateProperty('image', '', component, onPropertyChange)
385
+ const items = [...(component.properties?.items || [])]
386
+ items.splice(index, 1)
387
+ updateProperty('items', items, component, onPropertyChange)
343
388
  }}
344
389
  />
345
390
  {/if}
346
391
  </div>
347
- </div>
392
+ {/each}
393
+ {#if tabIcon.isModalOpen}
394
+ <Modal bind:isOpen={tabIcon.isModalOpen} wrapperClass="w-130">
395
+ {#snippet main()}
396
+ <div class="grid grid-cols-3">
397
+ {#each ICONS as category}
398
+ <div class="relative m-1.5 rounded-xl border-2 border-(--border-color) p-3">
399
+ <div class="absolute -top-3.5 bg-(--back-color) px-1">{$t(`constructor.props.icon.${category[0]}`)}</div>
400
+ <div class="grid grid-cols-3 place-items-center gap-2">
401
+ {#each category[1] as icon}
402
+ <button
403
+ class="h-8 w-8 cursor-pointer [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
404
+ onclick={() => {
405
+ const items = [...(component.properties?.items || [])]
406
+ items[tabIcon.index]['icon'] = icon as string
407
+ updateProperty('items', items, component, onPropertyChange)
408
+ }}
409
+ >
410
+ {@html icon}
411
+ </button>{/each}
412
+ </div>
413
+ </div>
414
+ {/each}
415
+ </div>
416
+ {/snippet}
417
+ </Modal>
418
+ {/if}
348
419
  </div>
349
420
  {/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.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {