poe-svelte-ui-lib 2.3.3 → 2.3.4

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.
@@ -45,7 +45,7 @@
45
45
  let buttonsNeed = $state(0)
46
46
  $effect(() => {
47
47
  const element = measureElement
48
- if (type !== "buttons" || !element) return
48
+ if (type !== "buttons" || fitContent || !element) return
49
49
  void options
50
50
  let alive = true
51
51
  const measure = () => {
@@ -59,7 +59,8 @@
59
59
  void document.fonts?.ready.then(measure)
60
60
  return () => (alive = false)
61
61
  })
62
- const shownType = $derived(type === "buttons" && anchorWidth < buttonsNeed ? "select" : type)
62
+ /* fitContent: ширину задают сами кнопки, сворачивать нечего */
63
+ const shownType = $derived(type === "buttons" && !fitContent && anchorWidth < buttonsNeed ? "select" : type)
63
64
 
64
65
  const selectedValues = $derived(multiSelect ? (Array.isArray(value) ? (value as T[]) : []) : [value as T])
65
66
  const isSelected = (option: IOption<T>) => selectedValues.includes(option.value)
@@ -98,7 +99,7 @@
98
99
  const openUp = below < needed && above > below
99
100
  const position = openUp ? `bottom: ${window.innerHeight - anchorRect.top + GAP}px;` : `top: ${anchorRect.bottom + GAP}px;`
100
101
  return {
101
- style: `${position} left: ${anchorRect.left}px; width: ${anchorRect.width}px;`,
102
+ style: `${position} left: ${anchorRect.left}px; min-width: ${anchorRect.width}px; max-width: ${Math.max(anchorRect.width, window.innerWidth - anchorRect.left - MARGIN)}px;`,
102
103
  maxHeight: `${Math.min(listMaxPx, Math.max(openUp ? above : below, 72))}px`,
103
104
  }
104
105
  })
@@ -202,7 +203,7 @@
202
203
  <div class="relative flex w-full flex-col gap-1" bind:this={anchorElement} bind:clientWidth={anchorWidth}>
203
204
  <FieldLabel {label} for={shownType === "buttons" ? undefined : uid} id={`${uid}-label`} />
204
205
 
205
- {#if type === "buttons"}
206
+ {#if type === "buttons" && !fitContent}
206
207
  <!-- Невидимые подписи вариантов: по их ширине решается, помещается ли группа кнопок -->
207
208
  <div bind:this={measureElement} class="pointer-events-none invisible absolute top-0 left-0 flex h-0 w-max overflow-hidden" aria-hidden="true">
208
209
  {#each options as option, index (option.id ?? index)}
package/dist/defaults.js CHANGED
@@ -2,7 +2,8 @@
2
2
  import { GUI_GRID, isWidgetType } from "./gui";
3
3
  import { widgetTitle } from "./locales/i18n";
4
4
  const label = { name: "", class: "text-center" };
5
- const widget = (type) => ({ label: { name: widgetTitle(type) }, collapsed: false });
5
+ /* Новый виджет на холсте свёрнут: холст не растягивается, автор раскрывает нужный */
6
+ const widget = (type) => ({ label: { name: widgetTitle(type) }, collapsed: true });
6
7
  /* Свойства по умолчанию; у смарт-виджета id - группа полей устройства */
7
8
  export const COMPONENT_DEFAULTS = {
8
9
  WidgetWiFi: { ...widget("WidgetWiFi"), id: "CFG", allowedModes: [1, 2, 3], confirmOnAP: true },
@@ -75,18 +76,18 @@ export const COMPONENT_SIZES = {
75
76
  Tabs: { width: GUI_GRID.columns, height: 4 },
76
77
  Input: { width: 3, height: 1 },
77
78
  Select: { width: 3, height: 1 },
78
- Slider: { width: 3, height: 1 },
79
+ Slider: { width: 8, height: 1 },
79
80
  Switch: { width: 2, height: 1 },
80
81
  FileAttach: { width: 7, height: 1 },
81
- Joystick: { width: 4, height: 3 },
82
+ Joystick: { width: 6, height: 3 },
82
83
  Button: { width: 2, height: 1 },
83
84
  Table: { width: 11, height: 2 },
84
85
  ProgressBar: { width: 3, height: 1 },
85
86
  TextField: { width: 3, height: 1 },
86
- Graph: { width: 7, height: 3 },
87
+ Graph: { width: 8, height: 3 },
87
88
  PeriodChart: { width: 7, height: 4 },
88
89
  Widget: { width: 3, height: 3 },
89
- VideoViewer: { width: 7, height: 7 },
90
+ VideoViewer: { width: 6, height: 3 },
90
91
  Divider: { width: GUI_GRID.columns, height: 1 },
91
92
  };
92
93
  /* Наименьшая ширина: смарт-виджет не уже 7 клеток (треть сетки), иначе шапка и поля не помещаются */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"