poe-svelte-ui-lib 2.3.0 → 2.3.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.
@@ -81,7 +81,7 @@
81
81
 
82
82
  {#if content.name?.trim()}
83
83
  <!-- Длинная подпись на узкой кнопке - в две строки, а не обрезка -->
84
- <span class="line-clamp-2 text-center leading-[1.05] wrap-break-word">{content.name}</span>
84
+ <span class="line-clamp-2 text-center leading-[1.05]">{content.name}</span>
85
85
  {#if keyBind.key && keyBind.showHint}
86
86
  <span class="ml-1 text-[11px] font-medium tabular-nums opacity-80">
87
87
  {keyBind.ctrlKey ? "Ctrl+" : ""}{keyBind.shiftKey ? "Shift+" : ""}{keyBind.altKey ? "Alt+" : ""}{keyBind.key}
@@ -96,12 +96,14 @@
96
96
  >
97
97
  <!-- Заголовок -->
98
98
  <WidgetHeader icon={CpuIcon} label={label?.name || $T("widget.info.title")} bind:collapsed {hints}>
99
- {#snippet right()}
99
+ {#snippet right(narrow: boolean)}
100
100
  <div use:hint={{ text: $T("widget.info.hint.restart"), enabled: $hints }}>
101
101
  <UI.Button
102
102
  wrapperClass="w-auto"
103
103
  componentClass="px-3"
104
- content={{ icon: RestartIcon, name: $T("widget.info.restart") }}
104
+ content={narrow
105
+ ? { icon: RestartIcon, info: { text: $T("widget.info.restart"), side: "left" } }
106
+ : { icon: RestartIcon, name: $T("widget.info.restart") }}
105
107
  disabled={!onRestart}
106
108
  onClick={() => onRestart?.()}
107
109
  />
@@ -140,11 +140,13 @@
140
140
  >
141
141
  <!-- Заголовок -->
142
142
  <WidgetHeader icon={StorageIcon} label={label?.name || $T("widget.fs.title")} bind:collapsed {hints}>
143
- {#snippet right()}
143
+ {#snippet right(narrow: boolean)}
144
144
  <UI.Button
145
145
  wrapperClass="w-auto"
146
146
  componentClass="px-3"
147
- content={{ icon: RefreshIcon, name: $T("widget.common.refresh") }}
147
+ content={narrow
148
+ ? { icon: RefreshIcon, info: { text: $T("widget.common.refresh"), side: "left" } }
149
+ : { icon: RefreshIcon, name: $T("widget.common.refresh") }}
148
150
  disabled={!onRefresh}
149
151
  onClick={() => onRefresh?.()}
150
152
  />
@@ -15,17 +15,20 @@
15
15
  icon: Component
16
16
  label: string
17
17
  collapsed?: boolean
18
- right?: Snippet
18
+ /* Правая часть; narrow - шапка узкая: кнопки только значком, списки сжаты, чтобы всё стояло в одной строке */
19
+ right?: Snippet<[boolean]>
19
20
  /* Настройка подсказок этого виджета (hintsSetting) - показывает кнопку «?», переключающую только его подсказки */
20
21
  hints?: Writable<boolean>
21
22
  } = $props()
22
23
 
23
24
  const Icon = $derived(icon)
24
25
 
25
- /* Правая часть уходит второй строкой, если не помещается рядом с заголовком (место под значок, заголовок и «?») */
26
- const TITLE_MIN_PX = 180
26
+ /* Уже NARROW_PX шапка сжимает правую часть; если и сжатая не помещается рядом с заголовком (место под значок, заголовок и «?»), она уходит второй строкой */
27
+ const NARROW_PX = 640
28
+ const TITLE_MIN_PX = 120
27
29
  let headerWidth = $state(0)
28
30
  let rightWidth = $state(0)
31
+ let narrow = $derived(headerWidth > 0 && headerWidth < NARROW_PX)
29
32
  let wrapped = $derived(!!right && headerWidth > 0 && rightWidth + TITLE_MIN_PX + (hints ? 34 : 0) > headerWidth)
30
33
  </script>
31
34
 
@@ -51,7 +54,7 @@
51
54
  </button>
52
55
  {#if right && !wrapped}
53
56
  <div class="flex w-max shrink-0 items-center justify-end" bind:clientWidth={rightWidth}>
54
- {@render right()}
57
+ {@render right(narrow)}
55
58
  </div>
56
59
  {/if}
57
60
  {#if hints}
@@ -68,9 +71,9 @@
68
71
  {/if}
69
72
  </div>
70
73
  {#if right && wrapped}
71
- <!-- Во второй строке элементы могут переноситься; естественная ширина правой части - из первой строки -->
72
- <div class="flex max-w-full flex-wrap items-center justify-end gap-2">
73
- {@render right()}
74
+ <!-- Во второй строке элементы могут переноситься; ширина замеряется и здесь - сжатая часть возвращается в первую строку -->
75
+ <div class="flex w-max max-w-full flex-wrap items-center justify-end gap-2 self-end" bind:clientWidth={rightWidth}>
76
+ {@render right(narrow)}
74
77
  </div>
75
78
  {/if}
76
79
  </div>
@@ -4,7 +4,7 @@ type $$ComponentProps = {
4
4
  icon: Component;
5
5
  label: string;
6
6
  collapsed?: boolean;
7
- right?: Snippet;
7
+ right?: Snippet<[boolean]>;
8
8
  hints?: Writable<boolean>;
9
9
  };
10
10
  declare const WidgetHeader: Component<$$ComponentProps, {}, "collapsed">;
@@ -248,6 +248,8 @@
248
248
 
249
249
  /* Тема карты - по ближайшему предку .dark/.light (как у токенов theme.css): работает и внутри блока с другой темой, смена темы отслеживается */
250
250
  let rootEl: HTMLDivElement | undefined = $state()
251
+ /* Ширина карты: панель оператора поверх неё не заходит под кнопки справа */
252
+ let mapWidth = $state(0)
251
253
  const theme = themeState(
252
254
  () => rootEl,
253
255
  () => rootStyle,
@@ -442,12 +444,12 @@
442
444
  style={rootStyle}
443
445
  >
444
446
  <WidgetHeader icon={MapIcon} label={label?.name || $T("widget.map.title")} bind:collapsed {hints}>
445
- {#snippet right()}
447
+ {#snippet right(narrow: boolean)}
446
448
  <div class="flex items-center gap-3">
447
449
  <Button
448
450
  wrapperClass="w-auto"
449
451
  componentClass="px-3"
450
- content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.map.fitAllHint"), side: "bottom" } }}
452
+ content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.map.fitAllHint"), side: "bottom" } }}
451
453
  disabled={collapsed || visibleBoards.length === 0}
452
454
  onClick={fitAllBoards}
453
455
  />
@@ -466,7 +468,7 @@
466
468
  </WidgetHeader>
467
469
 
468
470
  {#if !collapsed}
469
- <div transition:slide={{ duration: 150 }} style="height: {height}px">
471
+ <div transition:slide={{ duration: 150 }} style="height: {height}px" bind:clientWidth={mapWidth}>
470
472
  <MapLibre
471
473
  bind:map={mapInstance}
472
474
  class="h-full w-full overflow-hidden rounded-[14px] border border-(--hairline-color)"
@@ -483,7 +485,11 @@
483
485
 
484
486
  <!-- Панель оператора поверх карты -->
485
487
  <CustomControl position="top-left">
486
- <div class="flex flex-wrap items-center gap-3 rounded-lg px-2 py-1 text-(--font-color)">
488
+ <!-- Не шире карты без колонки кнопок справа: на узкой карте пункты переносятся -->
489
+ <div
490
+ class="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg px-2 py-1 text-(--font-color)"
491
+ style="max-width: {Math.max(mapWidth - 72, 120)}px"
492
+ >
487
493
  <label class="flex items-center gap-1.5 text-sm font-medium" use:hint={{ text: $T("widget.map.hint.track"), enabled: $hints }}>
488
494
  <input type="checkbox" bind:checked={trackEnabled} />
489
495
  {$T("constructor.props.map.track")}
@@ -425,26 +425,27 @@
425
425
  style={rootStyle}
426
426
  >
427
427
  <WidgetHeader icon={MissionIcon} label={label?.name || $T("widget.mission.title")} bind:collapsed {hints}>
428
- {#snippet right()}
428
+ {#snippet right(narrow: boolean)}
429
+ <!-- На узкой шапке: кнопка значком, во время полёта - только процент, иначе - сводка -->
429
430
  <div class="flex items-center gap-3">
430
431
  <Button
431
432
  wrapperClass="w-auto"
432
433
  componentClass="px-3"
433
- content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.mission.fitHint"), side: "bottom" } }}
434
+ content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.mission.fitHint"), side: "bottom" } }}
434
435
  disabled={collapsed || missionPoints().length === 0}
435
436
  onClick={() => fitAll()}
436
437
  />
437
438
  <span class="flex items-center gap-3 text-[12px] font-semibold text-(--muted-color) tabular-nums">
438
439
  {#if headerProgress !== null}
439
440
  <span class="flex items-center gap-1.5" title={simulate ? $T("widget.sim.title") : $T("widget.mission.progressHint")}>
440
- <span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color)"
441
+ <span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color) {narrow ? 'hidden' : ''}"
441
442
  ><span class="block h-full rounded-full bg-(--accent-color)" style="width: {Math.round(headerProgress * 100)}%"></span></span
442
443
  >
443
- {Math.round(headerProgress * 100)}%{#if live}
444
+ {Math.round(headerProgress * 100)}%{#if live && !narrow}
444
445
  · {$T("widget.mission.treated")} {fmt(treatedHa, 2)} {$T("widget.mission.ha")}{/if}
445
446
  </span>
446
447
  {/if}
447
- {#if stats}
448
+ {#if stats && (!narrow || headerProgress === null)}
448
449
  <span class="text-[12px] font-semibold text-(--muted-color) tabular-nums"
449
450
  >{fmt(stats.ha, 2)} {$T("widget.mission.ha")} · {fmt(stats.total, 2)} {$T("widget.mission.km")}</span
450
451
  >
@@ -222,22 +222,23 @@
222
222
  style={rootStyle}
223
223
  >
224
224
  <WidgetHeader icon={MapIcon} label={label?.name || $T("widget.route.title")} bind:collapsed {hints}>
225
- {#snippet right()}
225
+ {#snippet right(narrow: boolean)}
226
+ <!-- На узкой шапке: кнопка значком, во время полёта - только процент, иначе - сводка -->
226
227
  <div class="flex items-center gap-3">
227
228
  <Button
228
229
  wrapperClass="w-auto"
229
230
  componentClass="px-3"
230
- content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.route.fitHint"), side: "bottom" } }}
231
+ content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.route.fitHint"), side: "bottom" } }}
231
232
  disabled={collapsed || missionPoints().length === 0}
232
233
  onClick={() => fitAll()}
233
234
  />
234
235
  <span class="flex items-center gap-3 text-[12px] font-semibold text-(--muted-color) tabular-nums">
235
236
  {#if headerProgress !== null}
236
237
  <span class="flex items-center gap-1.5" title={simulate ? $T("widget.sim.title") : $T("widget.mission.progressHint")}>
237
- <span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color)"
238
+ <span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color) {narrow ? 'hidden' : ''}"
238
239
  ><span class="block h-full rounded-full bg-(--accent-color)" style="width: {Math.round(headerProgress * 100)}%"></span></span
239
240
  >
240
- {Math.round(headerProgress * 100)}%{#if live}
241
+ {Math.round(headerProgress * 100)}%{#if live && !narrow}
241
242
  · {live.finished
242
243
  ? $T("widget.route.finished")
243
244
  : live.target > route.points.length
@@ -245,7 +246,9 @@
245
246
  : `${$T("widget.route.toPoint")} ${live.target}/${route.points.length}`}{/if}
246
247
  </span>
247
248
  {/if}
248
- <span>{stats.points} {$T("widget.route.pts")} · {km(stats.length)}</span>
249
+ {#if !narrow || headerProgress === null}
250
+ <span>{stats.points} {$T("widget.route.pts")} · {km(stats.length)}</span>
251
+ {/if}
249
252
  </span>
250
253
  </div>
251
254
  {/snippet}
@@ -51,15 +51,22 @@
51
51
  </script>
52
52
 
53
53
  <!-- Три кнопки в ряд, на узком месте переносятся -->
54
- <div class="grid grid-cols-[repeat(auto-fit,minmax(7rem,1fr))] gap-3">
54
+ <div class="grid grid-cols-[repeat(auto-fit,minmax(6.5rem,1fr))] gap-3">
55
55
  <div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.download"), enabled: hints }}>
56
- <Button variant="primary" content={{ name: $T("widget.mission.download") }} disabled={off} onClick={download} />
56
+ <Button componentClass="px-2" variant="primary" content={{ name: $T("widget.mission.download") }} disabled={off} onClick={download} />
57
57
  </div>
58
58
  <div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.copy"), enabled: hints }}>
59
- <Button variant="primary" content={{ name: $T(copied ? "widget.mission.copied" : "widget.mission.copy") }} disabled={off} onClick={copy} />
59
+ <Button
60
+ componentClass="px-2"
61
+ variant="primary"
62
+ content={{ name: $T(copied ? "widget.mission.copied" : "widget.mission.copy") }}
63
+ disabled={off}
64
+ onClick={copy}
65
+ />
60
66
  </div>
61
67
  <div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.send"), enabled: hints }}>
62
68
  <Button
69
+ componentClass="px-2"
63
70
  variant="primary"
64
71
  accent={sendState === "error" ? "red" : undefined}
65
72
  content={{ name: $T(`widget.mission.send.${sendState}`) }}
@@ -138,13 +138,23 @@
138
138
  >
139
139
  <!-- Заголовок -->
140
140
  <WidgetHeader icon={MemoryIcon} label={label?.name || $T("widget.stack.title")} bind:collapsed {hints}>
141
- {#snippet right()}
141
+ {#snippet right(narrow: boolean)}
142
142
  <div class="flex flex-wrap items-center justify-end gap-2" use:hint={{ text: $T("widget.stack.hint.poll"), enabled: $hints }}>
143
- <UI.Select wrapperClass="w-64" type="buttons" options={periods} value={period} disabled={!onRefresh} onUpdate={(value) => (period = value)} />
143
+ <!-- На узком - список вместо ряда кнопок и кнопка значком -->
144
+ <UI.Select
145
+ wrapperClass={narrow ? "w-28" : "w-64"}
146
+ type="buttons"
147
+ options={periods}
148
+ value={period}
149
+ disabled={!onRefresh}
150
+ onUpdate={(value) => (period = value)}
151
+ />
144
152
  <UI.Button
145
153
  wrapperClass="w-auto"
146
154
  componentClass="px-3"
147
- content={{ icon: RefreshIcon, name: $T("widget.common.refresh") }}
155
+ content={narrow
156
+ ? { icon: RefreshIcon, info: { text: $T("widget.common.refresh"), side: "left" } }
157
+ : { icon: RefreshIcon, name: $T("widget.common.refresh") }}
148
158
  disabled={!onRefresh}
149
159
  onClick={() => onRefresh?.()}
150
160
  />
@@ -128,8 +128,8 @@
128
128
  >
129
129
  <!-- Заголовок и переключатель режима -->
130
130
  <WidgetHeader icon={WifiIcon} label={label?.name || $T("widget.wifi.title")} bind:collapsed {hints}>
131
- {#snippet right()}
132
- <div class="w-full sm:w-72" use:hint={{ text: $T("widget.wifi.hint.mode"), enabled: $hints }}>
131
+ {#snippet right(narrow: boolean)}
132
+ <div class={narrow ? "w-36" : "w-72"} use:hint={{ text: $T("widget.wifi.hint.mode"), enabled: $hints }}>
133
133
  <UI.Select
134
134
  wrapperClass="w-full"
135
135
  type="buttons"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"