poe-svelte-ui-lib 1.49.0 → 1.50.0

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.
@@ -72,3 +72,7 @@
72
72
  - При единственном элементе в `array` (`array.length == 1`) ручка визуально приглушена (`opacity-50`) и перетаскивание не запускается
73
73
  - Работает только с `MouseEvent` — нет отдельной поддержки touch/pointer-событий и клавиатурной перестановки (ручка фокусируема как `role="button"`, но `onkeydown` не обрабатывается — известное ограничение доступности)
74
74
  - `container`/`elementIndex`/`array` обязательны — компонент не проверяет их наличие и упадёт при обращении к `array.length` в классе, если `array` не передан
75
+
76
+ ## Вид перетаскивания
77
+
78
+ Один на библиотеку и приложения — `dragStyle.ts` (`applyDragGhost`, `clearDragGhost`, `createDropPlaceholder`, экспортируются из пакета): перетаскиваемый элемент — фон с заметным оттенком акцента (30%), рамка акцентом и тень, курсор «захват»; место вставки — заливка мягким акцентом (`--accent-soft`) со штриховой рамкой акцентом. Тот же вид — у перетаскивания компонентов на холсте конструктора DevCloud.
@@ -2,6 +2,7 @@
2
2
  import { tick } from "svelte"
3
3
  import MoveVerticalIcon from "./libIcons/MoveVerticalIcon.svelte"
4
4
  import { twMerge } from "tailwind-merge"
5
+ import { applyDragGhost, clearDragGhost, createDropPlaceholder } from "./dragStyle"
5
6
 
6
7
  let dragState = $state({
7
8
  isDragging: false,
@@ -48,24 +49,19 @@
48
49
  const element = movedElement.cloneNode(true) as HTMLElement
49
50
  const rect = movedElement.getBoundingClientRect()
50
51
 
51
- /* Создаем визуальный эффект перетаскивания */
52
+ /* Визуальный эффект перетаскивания — общий для библиотеки и приложений (dragStyle.ts) */
52
53
  element.id = "drag-element"
53
54
  element.style.position = "fixed"
54
55
  element.style.zIndex = "9999"
55
56
  element.style.minHeight = `${rect.height}px`
56
57
  element.style.pointerEvents = "none"
57
58
  element.style.width = `${rect.width}px`
58
- element.style.background = "var(--field-color)"
59
- element.style.padding = "0.25rem"
60
- element.style.borderRadius = "1rem"
59
+ element.style.left = `${rect.left}px`
61
60
  element.style.top = `${rect.top}px`
61
+ applyDragGhost(element)
62
62
  movedElement.parentNode?.appendChild(element)
63
63
 
64
- const placeholder = document.createElement("div")
65
- placeholder.style.minHeight = `${rect.height}px`
66
- placeholder.style.width = "100%"
67
- placeholder.style.border = "2px dashed var(--blue-color)"
68
- placeholder.style.borderRadius = "1rem"
64
+ const placeholder = createDropPlaceholder(rect.height)
69
65
  element.parentNode?.insertBefore(placeholder, movedElement)
70
66
 
71
67
  const [movedItem] = array.splice(elementIndex, 1)
@@ -127,6 +123,7 @@
127
123
 
128
124
  if (dragState.placeholderElement) dragState.placeholderElement.remove()
129
125
  if (dragState.ghostElement) dragState.ghostElement.remove()
126
+ clearDragGhost()
130
127
 
131
128
  dragState = {
132
129
  isDragging: false,
@@ -0,0 +1,3 @@
1
+ export declare const applyDragGhost: (element: HTMLElement) => void;
2
+ export declare const clearDragGhost: (element?: HTMLElement | null) => void;
3
+ export declare const createDropPlaceholder: (height: number) => HTMLElement;
@@ -0,0 +1,35 @@
1
+ /* $lib/dragStyle.ts — единый вид перетаскивания для библиотеки и приложений (списки Dragging, холст конструктора DevCloud):
2
+ перетаскиваемый элемент — фон с заметным оттенком акцента, рамка акцентом и тень; место вставки — заливка мягким акцентом со штриховой рамкой */
3
+ const GHOST_STYLE = {
4
+ background: "color-mix(in srgb, var(--accent-color) 30%, var(--back-color))",
5
+ outline: "2px solid var(--accent-color)",
6
+ outlineOffset: "-2px",
7
+ boxShadow: "var(--elevation-3)",
8
+ borderRadius: "12px",
9
+ opacity: "1",
10
+ };
11
+ /* Оформить перетаскиваемый элемент; курсор «захват» — на всё время перетаскивания */
12
+ export const applyDragGhost = (element) => {
13
+ Object.assign(element.style, GHOST_STYLE);
14
+ document.body.style.cursor = "grabbing";
15
+ };
16
+ /* Снять оформление перетаскивания с элемента (если он остаётся на странице) и вернуть курсор */
17
+ export const clearDragGhost = (element) => {
18
+ if (element)
19
+ for (const key of Object.keys(GHOST_STYLE))
20
+ element.style[key] = "";
21
+ document.body.style.cursor = "";
22
+ };
23
+ /* Место вставки: заливка мягким акцентом и штриховая рамка акцентом */
24
+ export const createDropPlaceholder = (height) => {
25
+ const placeholder = document.createElement("div");
26
+ Object.assign(placeholder.style, {
27
+ minHeight: `${height}px`,
28
+ width: "100%",
29
+ background: "var(--accent-soft)",
30
+ border: "2px dashed var(--accent-color)",
31
+ borderRadius: "12px",
32
+ boxSizing: "border-box",
33
+ });
34
+ return placeholder;
35
+ };
package/dist/index.d.ts CHANGED
@@ -54,5 +54,6 @@ export * from "./locales/i18n";
54
54
  export * from "./locales/languages";
55
55
  export * from "./locales/localize";
56
56
  export { widgetAccentStyle } from "./widgetAccent";
57
+ export { applyDragGhost, clearDragGhost, createDropPlaceholder } from "./dragStyle";
57
58
  export * from "./ModalStackStore";
58
59
  export { type UIComponent, type Position, type IUIComponentHandler, type IButtonProps, type IAccordionProps, type IInputProps, type ISelectProps, type IOption, type ISwitchProps, type IDividerProps, type ISliderProps, type ITextFieldProps, type IProgressBarProps, type IWidgetProps, type IWidgetWiFiProps, type IWidgetWiFiConfig, type IWidgetDeviceInfoProps, type IWidgetDeviceInfoConfig, type IWidgetFileSystemProps, type IWidgetFileSystemInfo, type IWidgetFileSystemFile, type IWidgetFileSystemUpload, type IWidgetStackInfoProps, type IWidgetStackInfo, type IWidgetStackInfoHeap, type IWidgetStackInfoTask, type IWidgetRGBStripProps, type IWidgetRGBStripConfig, type IWidgetPFDProps, type IWidgetPFDData, type IWidgetPFDLimits, type IWidgetMapProps, type IWidgetMapData, type IGraphProps, type IGraphDataObject, type IGraphHistoryPoint, type IGraphHistorySeries, type ITableHeader, type ITableText, type ITableSelect, type ITableButton, type ITableProgressBar, type ITableImage, type ITableContent, type ITableProps, type ITabsProps, type IJoystickProps, type IFileAttachProps, type ICarouselProps, type IReceivingDataObject, type IVideoViewerProps, type IPeriodChartProps, type IPeriodChartLevel, } from "./types";
package/dist/index.js CHANGED
@@ -55,5 +55,6 @@ export * from "./locales/i18n";
55
55
  export * from "./locales/languages";
56
56
  export * from "./locales/localize";
57
57
  export { widgetAccentStyle } from "./widgetAccent";
58
+ export { applyDragGhost, clearDragGhost, createDropPlaceholder } from "./dragStyle";
58
59
  export * from "./ModalStackStore";
59
60
  export {} from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "1.49.0",
3
+ "version": "1.50.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"