@humandialog/forms.svelte 1.7.28 → 1.8.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.
Files changed (258) hide show
  1. package/components/Fab.25.svelte +473 -0
  2. package/components/Fab.25.svelte.d.ts +18 -0
  3. package/components/Fab.svelte +51 -170
  4. package/components/Floating_container.25.svelte +178 -0
  5. package/components/Floating_container.25.svelte.d.ts +23 -0
  6. package/components/Floating_container.svelte +18 -6
  7. package/components/Grid.menu.svelte +15 -16
  8. package/components/Grid.menu.svelte.d.ts +2 -2
  9. package/components/breadcrumb.svelte +27 -27
  10. package/components/checkbox.svelte +1 -1
  11. package/components/combo/combo.svelte +60 -79
  12. package/components/combo/combo.svelte.d.ts +1 -0
  13. package/components/contextmenu-25.svelte +518 -0
  14. package/components/contextmenu-25.svelte.d.ts +26 -0
  15. package/components/contextmenu.svelte +179 -65
  16. package/components/contextmenu.svelte.d.ts +2 -2
  17. package/components/date.svelte +42 -21
  18. package/components/date.svelte.d.ts +1 -0
  19. package/components/delayed.spinner.svelte +2 -1
  20. package/components/document/editor.svelte +21 -31
  21. package/components/document/editor.svelte.d.ts +0 -2
  22. package/components/document/internal/palette.row.svelte +10 -8
  23. package/components/document/internal/palette.svelte +7 -8
  24. package/components/document/rich.edit.svelte +10 -10
  25. package/components/edit.field.svelte +1 -1
  26. package/components/input.text.svelte.d.ts +2 -2
  27. package/components/inputbox.ltop.svelte +1 -1
  28. package/components/inputbox.ltop.svelte.d.ts +12 -12
  29. package/components/kanban/internal/kanban.card.svelte +27 -47
  30. package/components/kanban/internal/kanban.column.svelte +44 -24
  31. package/components/kanban/internal/kanban.inserter.svelte +11 -14
  32. package/components/kanban/internal/kanban.move.menu.svelte +12 -12
  33. package/components/kanban/internal/kanban.props.svelte +24 -9
  34. package/components/kanban/kanban.svelte +24 -77
  35. package/components/kanban/kanban.svelte.d.ts +2 -0
  36. package/components/kanban copy.zip +0 -0
  37. package/components/list/List.d.ts +1 -0
  38. package/components/list/List.js +1 -0
  39. package/components/list/internal/list.element copy.svelte +530 -0
  40. package/components/list/internal/list.element copy.svelte.d.ts +35 -0
  41. package/components/list/internal/list.element.svelte +311 -279
  42. package/components/list/internal/list.element.svelte.d.ts +5 -7
  43. package/components/list/internal/list.inserter.svelte +38 -6
  44. package/components/list/internal/note.txt +5 -0
  45. package/components/list/list.svelte +32 -11
  46. package/components/list/list.svelte.d.ts +5 -3
  47. package/components/list/list.title.svelte +2 -0
  48. package/components/list/list.title.svelte.d.ts +1 -0
  49. package/components/menu.d.ts +1 -1
  50. package/components/menu.js +3 -3
  51. package/components/paginator.svelte +79 -9
  52. package/components/prose.editable.p.svelte.d.ts +2 -2
  53. package/components/prose.editable.span.svelte.d.ts +2 -2
  54. package/components/r.edit.svelte +9 -0
  55. package/components/r.edit.svelte.d.ts +23 -0
  56. package/components/r.editable.svelte +75 -0
  57. package/components/r.editable.svelte.d.ts +31 -0
  58. package/components/r.figcaption.svelte +5 -0
  59. package/components/r.figcaption.svelte.d.ts +27 -0
  60. package/components/r.figure.svelte +25 -0
  61. package/components/r.figure.svelte.d.ts +29 -0
  62. package/components/r.icon.svelte +229 -0
  63. package/components/r.icon.svelte.d.ts +33 -0
  64. package/components/radio.svelte +1 -1
  65. package/components/ricons/arrow-up.svelte +11 -0
  66. package/components/ricons/arrow-up.svelte.d.ts +27 -0
  67. package/components/ricons/barcode.svelte +14 -0
  68. package/components/ricons/barcode.svelte.d.ts +27 -0
  69. package/components/ricons/bold.svelte +10 -0
  70. package/components/ricons/bold.svelte.d.ts +27 -0
  71. package/components/ricons/calendar.svelte +13 -0
  72. package/components/ricons/calendar.svelte.d.ts +27 -0
  73. package/components/ricons/calendars.svelte +16 -0
  74. package/components/ricons/calendars.svelte.d.ts +27 -0
  75. package/components/ricons/cat.svelte +14 -0
  76. package/components/ricons/cat.svelte.d.ts +27 -0
  77. package/components/ricons/check-check.svelte +12 -0
  78. package/components/ricons/check-check.svelte.d.ts +27 -0
  79. package/components/ricons/check.svelte +18 -0
  80. package/components/ricons/check.svelte.d.ts +27 -0
  81. package/components/ricons/chess-rook.svelte +17 -0
  82. package/components/ricons/chess-rook.svelte.d.ts +27 -0
  83. package/components/ricons/chevron-down.svelte +11 -0
  84. package/components/ricons/chevron-down.svelte.d.ts +27 -0
  85. package/components/ricons/chevron-left.svelte +11 -0
  86. package/components/ricons/chevron-left.svelte.d.ts +27 -0
  87. package/components/ricons/chevron-right.svelte +11 -0
  88. package/components/ricons/chevron-right.svelte.d.ts +27 -0
  89. package/components/ricons/chevron-up.svelte +11 -0
  90. package/components/ricons/chevron-up.svelte.d.ts +27 -0
  91. package/components/ricons/chevrons-down.svelte +12 -0
  92. package/components/ricons/chevrons-down.svelte.d.ts +27 -0
  93. package/components/ricons/chevrons-left-right.svelte +12 -0
  94. package/components/ricons/chevrons-left-right.svelte.d.ts +27 -0
  95. package/components/ricons/chevrons-left.svelte +12 -0
  96. package/components/ricons/chevrons-left.svelte.d.ts +27 -0
  97. package/components/ricons/chevrons-right.svelte +12 -0
  98. package/components/ricons/chevrons-right.svelte.d.ts +27 -0
  99. package/components/ricons/chevrons-up-down.svelte +12 -0
  100. package/components/ricons/chevrons-up-down.svelte.d.ts +27 -0
  101. package/components/ricons/chevrons-up.svelte +12 -0
  102. package/components/ricons/chevrons-up.svelte.d.ts +27 -0
  103. package/components/ricons/circle-check.svelte +28 -0
  104. package/components/ricons/circle-check.svelte.d.ts +23 -0
  105. package/components/ricons/circle-dashed.svelte +19 -0
  106. package/components/ricons/circle-dashed.svelte.d.ts +27 -0
  107. package/components/ricons/circle-dot-dashed.svelte +20 -0
  108. package/components/ricons/circle-dot-dashed.svelte.d.ts +27 -0
  109. package/components/ricons/circle.svelte +30 -0
  110. package/components/ricons/circle.svelte.d.ts +23 -0
  111. package/components/ricons/clipboard-list.svelte +17 -0
  112. package/components/ricons/clipboard-list.svelte.d.ts +27 -0
  113. package/components/ricons/clipboard-minus.svelte +9 -0
  114. package/components/ricons/clipboard-minus.svelte.d.ts +23 -0
  115. package/components/ricons/clipboard-pen-line.svelte +18 -0
  116. package/components/ricons/clipboard-pen-line.svelte.d.ts +27 -0
  117. package/components/ricons/code-xml.svelte +12 -0
  118. package/components/ricons/code-xml.svelte.d.ts +27 -0
  119. package/components/ricons/download.svelte +13 -0
  120. package/components/ricons/download.svelte.d.ts +27 -0
  121. package/components/ricons/ellipsis-vertical.svelte +14 -0
  122. package/components/ricons/ellipsis-vertical.svelte.d.ts +27 -0
  123. package/components/ricons/file-archive.svelte +18 -0
  124. package/components/ricons/file-archive.svelte.d.ts +27 -0
  125. package/components/ricons/file-text.svelte +17 -0
  126. package/components/ricons/file-text.svelte.d.ts +27 -0
  127. package/components/ricons/folder.svelte +12 -0
  128. package/components/ricons/folder.svelte.d.ts +27 -0
  129. package/components/ricons/heading-1.svelte +13 -0
  130. package/components/ricons/heading-1.svelte.d.ts +27 -0
  131. package/components/ricons/heading-2.svelte +13 -0
  132. package/components/ricons/heading-2.svelte.d.ts +27 -0
  133. package/components/ricons/heading-3.svelte +14 -0
  134. package/components/ricons/heading-3.svelte.d.ts +27 -0
  135. package/components/ricons/heading-4.svelte +14 -0
  136. package/components/ricons/heading-4.svelte.d.ts +27 -0
  137. package/components/ricons/heading-5.svelte +14 -0
  138. package/components/ricons/heading-5.svelte.d.ts +27 -0
  139. package/components/ricons/image.svelte +12 -0
  140. package/components/ricons/image.svelte.d.ts +27 -0
  141. package/components/ricons/italic.svelte +12 -0
  142. package/components/ricons/italic.svelte.d.ts +27 -0
  143. package/components/ricons/languages.svelte +15 -0
  144. package/components/ricons/languages.svelte.d.ts +27 -0
  145. package/components/ricons/list-checks.svelte +15 -0
  146. package/components/ricons/list-checks.svelte.d.ts +27 -0
  147. package/components/ricons/list-minus.svelte +14 -0
  148. package/components/ricons/list-minus.svelte.d.ts +27 -0
  149. package/components/ricons/list-ordered.svelte +16 -0
  150. package/components/ricons/list-ordered.svelte.d.ts +27 -0
  151. package/components/ricons/list-plus.svelte +14 -0
  152. package/components/ricons/list-plus.svelte.d.ts +27 -0
  153. package/components/ricons/list.svelte +15 -0
  154. package/components/ricons/list.svelte.d.ts +27 -0
  155. package/components/ricons/loader-circle.svelte +19 -0
  156. package/components/ricons/loader-circle.svelte.d.ts +27 -0
  157. package/components/ricons/log-in.svelte +12 -0
  158. package/components/ricons/log-in.svelte.d.ts +27 -0
  159. package/components/ricons/log-out.svelte +12 -0
  160. package/components/ricons/log-out.svelte.d.ts +27 -0
  161. package/components/ricons/message-square.svelte +12 -0
  162. package/components/ricons/message-square.svelte.d.ts +27 -0
  163. package/components/ricons/messages-square.svelte +15 -0
  164. package/components/ricons/messages-square.svelte.d.ts +27 -0
  165. package/components/ricons/minus.svelte +10 -0
  166. package/components/ricons/minus.svelte.d.ts +27 -0
  167. package/components/ricons/notebook-tabs.svelte +19 -0
  168. package/components/ricons/notebook-tabs.svelte.d.ts +27 -0
  169. package/components/ricons/notebook.svelte +16 -0
  170. package/components/ricons/notebook.svelte.d.ts +27 -0
  171. package/components/ricons/package.svelte +22 -0
  172. package/components/ricons/package.svelte.d.ts +27 -0
  173. package/components/ricons/paperclip.svelte +12 -0
  174. package/components/ricons/paperclip.svelte.d.ts +27 -0
  175. package/components/ricons/pencil.svelte +12 -0
  176. package/components/ricons/pencil.svelte.d.ts +27 -0
  177. package/components/ricons/pilcrow.svelte +12 -0
  178. package/components/ricons/pilcrow.svelte.d.ts +27 -0
  179. package/components/ricons/save.svelte +12 -0
  180. package/components/ricons/save.svelte.d.ts +27 -0
  181. package/components/ricons/square-check-big.svelte +13 -0
  182. package/components/ricons/square-check-big.svelte.d.ts +27 -0
  183. package/components/ricons/square-pen.svelte +14 -0
  184. package/components/ricons/square-pen.svelte.d.ts +27 -0
  185. package/components/ricons/square.svelte +10 -0
  186. package/components/ricons/square.svelte.d.ts +27 -0
  187. package/components/ricons/strikethrough.svelte +13 -0
  188. package/components/ricons/strikethrough.svelte.d.ts +27 -0
  189. package/components/ricons/sun-moon.svelte +15 -0
  190. package/components/ricons/sun-moon.svelte.d.ts +27 -0
  191. package/components/ricons/table.svelte +13 -0
  192. package/components/ricons/table.svelte.d.ts +27 -0
  193. package/components/ricons/tag.svelte +12 -0
  194. package/components/ricons/tag.svelte.d.ts +27 -0
  195. package/components/ricons/text-quote.svelte +14 -0
  196. package/components/ricons/text-quote.svelte.d.ts +27 -0
  197. package/components/ricons/turtle.svelte +13 -0
  198. package/components/ricons/turtle.svelte.d.ts +27 -0
  199. package/components/ricons/underline.svelte +11 -0
  200. package/components/ricons/underline.svelte.d.ts +27 -0
  201. package/components/ricons/upload.svelte +13 -0
  202. package/components/ricons/upload.svelte.d.ts +27 -0
  203. package/components/ricons/user.svelte +12 -0
  204. package/components/ricons/user.svelte.d.ts +27 -0
  205. package/components/ricons/users.svelte +14 -0
  206. package/components/ricons/users.svelte.d.ts +27 -0
  207. package/components/ricons/x.svelte +11 -0
  208. package/components/ricons/x.svelte.d.ts +27 -0
  209. package/components/sidebar/sidebar.brand.svelte +14 -13
  210. package/components/sidebar/sidebar.brand.svelte.d.ts +2 -2
  211. package/components/sidebar/sidebar.group.svelte +52 -30
  212. package/components/sidebar/sidebar.item.svelte +35 -141
  213. package/components/sidebar/sidebar.item.svelte.d.ts +2 -5
  214. package/components/sidebar/sidebar.list.svelte +8 -8
  215. package/components/sidebar/sidebar.svelte +19 -2
  216. package/components/simple.table.svelte.d.ts +4 -4
  217. package/components/table/_template.table.svelte.d.ts +4 -4
  218. package/components/tags.svelte +10 -3
  219. package/components/tags.svelte.d.ts +1 -0
  220. package/components/textarea.ltop.svelte.d.ts +2 -2
  221. package/components/tile.title.svelte.d.ts +2 -2
  222. package/desk.svelte +139 -144
  223. package/dialog.svelte +17 -7
  224. package/form.box.svelte.d.ts +4 -4
  225. package/horizontal.nav.tabs.svelte +197 -23
  226. package/horizontal.nav.tabs.svelte.d.ts +2 -2
  227. package/horizontal.toolbar.svelte +25 -18
  228. package/horizontal.toolbar.svelte.d.ts +2 -2
  229. package/index.d.ts +10 -3
  230. package/index.js +10 -3
  231. package/operations.svelte +51 -22
  232. package/package.json +89 -1
  233. package/page.row.svelte.d.ts +2 -2
  234. package/page.svelte +17 -7
  235. package/page.svelte.d.ts +10 -10
  236. package/paper.header.svelte +4 -0
  237. package/paper.header.svelte.d.ts +27 -0
  238. package/paper.nav.svelte +8 -0
  239. package/paper.nav.svelte.d.ts +27 -0
  240. package/paper.svelte +22 -6
  241. package/paper.svelte.d.ts +2 -0
  242. package/paper.table.svelte +27 -0
  243. package/paper.table.svelte.d.ts +27 -0
  244. package/paper.top.margin.svelte +5 -0
  245. package/paper.top.margin.svelte.d.ts +27 -0
  246. package/stores.d.ts +1 -1
  247. package/tenant.create.svelte +93 -0
  248. package/tenant.create.svelte.d.ts +29 -0
  249. package/tenant.members.svelte +116 -93
  250. package/tile.svelte.d.ts +4 -4
  251. package/tiles.row.svelte.d.ts +2 -2
  252. package/tiles.vertical.row.svelte.d.ts +2 -2
  253. package/updates.d.ts +4 -0
  254. package/updates.js +56 -14
  255. package/utils.d.ts +16 -4
  256. package/utils.js +214 -99
  257. package/vertical.toolbar.svelte +62 -47
  258. package/vertical.toolbar.svelte.d.ts +2 -2
@@ -0,0 +1,518 @@
1
+ <script>import { afterUpdate, tick } from "svelte";
2
+ import Icon from "./icon.svelte";
3
+ import { contextItemsStore, pushToolsActionsOperations, popToolsActionsOperations, fabHiddenDueToPopup } from "../stores";
4
+ import { isDeviceSmallerThan, isOnScreenKeyboardVisible } from "../utils";
5
+ import {
6
+ hideWholeContextMenu,
7
+ showMenu,
8
+ showFloatingToolbar,
9
+ showGridMenu,
10
+ SHOW_MENU_BELOW,
11
+ SHOW_MENU_ABOVE,
12
+ SHOW_MENU_RIGHT,
13
+ SHOW_MENU_LEFT
14
+ } from "./menu";
15
+ import { FaTimes } from "svelte-icons/fa";
16
+ import { usePreventScroll } from "./react-aria/preventScroll";
17
+ export let widthPx = 400;
18
+ export let menu_items_id_prefix = "__hd_svelte_menuitem_";
19
+ export let owner_menu_item = void 0;
20
+ let x = 0;
21
+ let y = 0;
22
+ let visible = false;
23
+ let menu_root;
24
+ let operations = [];
25
+ let min_width_px = 200;
26
+ let focused_index = 0;
27
+ let menu_items = [];
28
+ let submenus = [];
29
+ let around_rect;
30
+ let around_preference = 0;
31
+ let css_position = "display: none";
32
+ let closeButtonPos = "";
33
+ $:
34
+ display = visible ? "block" : "none";
35
+ function calculatePosition(x2, y2, visible2, fresh) {
36
+ let result = "";
37
+ if (!visible2) {
38
+ result = "display: none";
39
+ } else if (isDeviceSmallerThan("sm")) {
40
+ let screenRect = new DOMRect();
41
+ screenRect.x = 0;
42
+ screenRect.y = 0;
43
+ screenRect.width = window.innerWidth;
44
+ screenRect.height = window.innerHeight;
45
+ const margin = 5;
46
+ let myRect = null;
47
+ if (!fresh) {
48
+ myRect = menu_root.getBoundingClientRect();
49
+ if (myRect.height == 0) {
50
+ myRect = null;
51
+ }
52
+ }
53
+ let maxHeight;
54
+ if (myRect) {
55
+ maxHeight = screenRect.height / 2 - margin;
56
+ if (myRect.height < maxHeight)
57
+ maxHeight = myRect.height;
58
+ const width = screenRect.width - 2 * margin;
59
+ x2 = margin;
60
+ y2 = screenRect.bottom - maxHeight - margin;
61
+ result = `left: ${x2}px; bottom: ${margin}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
62
+ } else {
63
+ maxHeight = screenRect.height / 2 - margin;
64
+ const width = screenRect.width - 2 * margin;
65
+ x2 = margin;
66
+ y2 = screenRect.bottom - maxHeight - margin;
67
+ result = `left: ${x2}px; bottom: ${margin}px; width: ${width}px; max-height: ${maxHeight}px; display: block`;
68
+ }
69
+ closeButtonPos = `right: 0.5rem; bottom: calc(${margin + maxHeight}px - 1.75rem)`;
70
+ } else {
71
+ let myRect = null;
72
+ if (!fresh) {
73
+ myRect = menu_root.getBoundingClientRect();
74
+ if (myRect.height == 0) {
75
+ myRect = null;
76
+ }
77
+ }
78
+ if (myRect) {
79
+ const m = 15;
80
+ let screenRect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
81
+ if (around_rect) {
82
+ const menuWidth = myRect.width;
83
+ const menuHeight = myRect.height;
84
+ let topArea;
85
+ let bottomArea;
86
+ let leftArea;
87
+ let rightArea;
88
+ switch (around_preference) {
89
+ case SHOW_MENU_BELOW:
90
+ topArea = around_rect.top - screenRect.top;
91
+ bottomArea = screenRect.bottom - around_rect.bottom;
92
+ leftArea = around_rect.right - screenRect.left;
93
+ rightArea = screenRect.right - around_rect.left;
94
+ if (menuHeight <= bottomArea)
95
+ y2 = around_rect.bottom;
96
+ else if (menuHeight <= topArea)
97
+ y2 = around_rect.top - menuHeight;
98
+ if (menuWidth <= rightArea)
99
+ x2 = around_rect.left;
100
+ else if (menuWidth <= leftArea)
101
+ x2 = around_rect.right - menuWidth;
102
+ break;
103
+ case SHOW_MENU_ABOVE:
104
+ topArea = around_rect.top - screenRect.top;
105
+ bottomArea = screenRect.bottom - around_rect.bottom;
106
+ leftArea = around_rect.right - screenRect.left;
107
+ rightArea = screenRect.right - around_rect.left;
108
+ if (menuHeight <= topArea)
109
+ y2 = around_rect.top - menuHeight;
110
+ else if (menuHeight <= bottomArea)
111
+ y2 = around_rect.bottom;
112
+ if (menuWidth <= rightArea)
113
+ x2 = around_rect.left;
114
+ else if (menuWidth <= leftArea)
115
+ x2 = around_rect.right - menuWidth;
116
+ break;
117
+ case SHOW_MENU_RIGHT:
118
+ topArea = around_rect.bottom - screenRect.top;
119
+ bottomArea = screenRect.bottom - around_rect.top;
120
+ leftArea = around_rect.left - screenRect.left;
121
+ rightArea = screenRect.right - around_rect.right;
122
+ if (menuWidth <= rightArea)
123
+ x2 = around_rect.right;
124
+ else if (menuWidth <= leftArea)
125
+ x2 = around_rect.left - menuWidth;
126
+ if (menuHeight <= bottomArea)
127
+ y2 = around_rect.top;
128
+ else if (menuHeight <= topArea)
129
+ y2 = around_rect.bottom - menuHeight;
130
+ break;
131
+ case SHOW_MENU_LEFT:
132
+ topArea = around_rect.bottom - screenRect.top;
133
+ bottomArea = screenRect.bottom - around_rect.top;
134
+ leftArea = around_rect.left - screenRect.left;
135
+ rightArea = screenRect.right - around_rect.right;
136
+ if (menuWidth <= leftArea)
137
+ x2 = around_rect.left - menuWidth;
138
+ else if (menuWidth <= rightArea)
139
+ x2 = around_rect.right;
140
+ if (menuHeight <= bottomArea)
141
+ y2 = around_rect.top;
142
+ else if (menuHeight <= topArea)
143
+ y2 = around_rect.bottom - menuHeight;
144
+ break;
145
+ }
146
+ } else {
147
+ if (myRect.right > screenRect.right)
148
+ x2 = screenRect.right - myRect.width + m;
149
+ if (myRect.bottom > screenRect.bottom)
150
+ y2 = screenRect.bottom - myRect.height;
151
+ if (myRect.left < screenRect.left)
152
+ x2 = screenRect.left;
153
+ if (myRect.top < screenRect.top)
154
+ y2 = screenRect.top;
155
+ }
156
+ }
157
+ result = `left:${x2}px; top:${y2}px; display: block; min-width: 15rem`;
158
+ closeButtonPos = "";
159
+ }
160
+ return result;
161
+ }
162
+ function intersects(lpRect1, lpRect2) {
163
+ const left = Math.max(lpRect1.left, lpRect2.left);
164
+ const right = Math.min(lpRect1.right, lpRect2.right);
165
+ const top = Math.max(lpRect1.top, lpRect2.top);
166
+ const bottom = Math.min(lpRect1.bottom, lpRect2.bottom);
167
+ return left <= right && top <= bottom;
168
+ }
169
+ let preventScrollRestorer = null;
170
+ export async function show(around, _operations, preference = 0) {
171
+ if (around instanceof DOMRect) {
172
+ switch (preference) {
173
+ case SHOW_MENU_BELOW:
174
+ x = around.left;
175
+ y = around.bottom;
176
+ break;
177
+ case SHOW_MENU_ABOVE:
178
+ x = around.left;
179
+ y = around.top;
180
+ break;
181
+ case SHOW_MENU_RIGHT:
182
+ x = around.right;
183
+ y = around.top;
184
+ break;
185
+ case SHOW_MENU_LEFT:
186
+ x = around.left;
187
+ y = around.top;
188
+ break;
189
+ }
190
+ around_preference = preference;
191
+ around_rect = around;
192
+ } else if (around instanceof DOMPoint) {
193
+ x = around.x;
194
+ y = around.y;
195
+ around_rect = new DOMRect(x, y, 0, 0);
196
+ }
197
+ visible = true;
198
+ css_position = calculatePosition(x, y, true, true);
199
+ operations = [..._operations];
200
+ focused_index = operations.findIndex((o) => !o.disabled);
201
+ const is_root_menu = owner_menu_item == void 0;
202
+ if (is_root_menu) {
203
+ hide_window_indicator = 0;
204
+ window.addEventListener("click", on_before_window_click, true);
205
+ if (isDeviceSmallerThan("sm"))
206
+ preventScrollRestorer = usePreventScroll();
207
+ }
208
+ if (isDeviceSmallerThan("sm")) {
209
+ $fabHiddenDueToPopup = true;
210
+ }
211
+ await tick();
212
+ css_position = calculatePosition(x, y, true, false);
213
+ if (is_root_menu)
214
+ menu_root.addEventListener("click", on_before_container_click, true);
215
+ if (menu_items.length && !isDeviceSmallerThan("sm"))
216
+ focus_menu_item(focused_index);
217
+ }
218
+ export function isVisible() {
219
+ return visible;
220
+ }
221
+ export function hide() {
222
+ if (visible) {
223
+ $fabHiddenDueToPopup = false;
224
+ }
225
+ visible = false;
226
+ css_position = calculatePosition(x, y, false, false);
227
+ window.removeEventListener("click", on_before_window_click, true);
228
+ menu_root?.removeEventListener("click", on_before_container_click, true);
229
+ if (preventScrollRestorer) {
230
+ preventScrollRestorer();
231
+ preventScrollRestorer = null;
232
+ }
233
+ }
234
+ export function getRenderedRect() {
235
+ if (menu_root)
236
+ return menu_root.getBoundingClientRect();
237
+ else
238
+ return void 0;
239
+ }
240
+ let hide_window_indicator = 0;
241
+ function on_before_window_click() {
242
+ hide_window_indicator++;
243
+ setTimeout(() => {
244
+ if (hide_window_indicator != 0) {
245
+ hide_window_indicator = 0;
246
+ hide();
247
+ }
248
+ }, 0);
249
+ }
250
+ function on_before_container_click() {
251
+ hide_window_indicator--;
252
+ }
253
+ function on_keydown(e, operation, index) {
254
+ switch (e.key) {
255
+ case "Esc":
256
+ case "Escape":
257
+ hideWholeContextMenu();
258
+ break;
259
+ case "ArrowDown":
260
+ navigate_down();
261
+ break;
262
+ case "ArrowUp":
263
+ navigate_up();
264
+ break;
265
+ case "ArrowLeft":
266
+ hide_submenu();
267
+ break;
268
+ case "Enter":
269
+ execute_action(void 0, operation, index);
270
+ e.preventDefault();
271
+ e.stopPropagation();
272
+ break;
273
+ }
274
+ }
275
+ function navigate_up() {
276
+ let index = get_this_or_prev_valid_index(focused_index - 1);
277
+ focus_menu_item(index);
278
+ }
279
+ function navigate_down() {
280
+ let index = get_this_or_next_valid_index(focused_index + 1);
281
+ focus_menu_item(index);
282
+ }
283
+ function on_change_focus(e) {
284
+ if (!isDeviceSmallerThan("sm")) {
285
+ if (e.relatedTarget && e.relatedTarget.id.startsWith(menu_items_id_prefix))
286
+ return;
287
+ else
288
+ hide();
289
+ }
290
+ }
291
+ function on_mouse_move(index) {
292
+ if (!isDeviceSmallerThan("sm"))
293
+ focus_menu_item(index);
294
+ }
295
+ function execute_action(e, operation, index) {
296
+ const mobile = isDeviceSmallerThan("sm");
297
+ if (operation.menu && !mobile) {
298
+ focus_menu_item(index);
299
+ return;
300
+ }
301
+ hideWholeContextMenu();
302
+ if (!operation)
303
+ return;
304
+ let owner = e?.target;
305
+ while (owner && owner.tagName != "BUTTON")
306
+ owner = owner.parentElement;
307
+ if (operation.preAction)
308
+ operation.preAction(owner);
309
+ if (operation.action) {
310
+ operation.action(owner, around_rect);
311
+ } else {
312
+ let rect;
313
+ if (around_rect)
314
+ rect = around_rect;
315
+ else
316
+ rect = owner.getBoundingClientRect();
317
+ if (operation.toolbar)
318
+ showFloatingToolbar(rect, operation.toolbar, operation.props ?? {});
319
+ else if (operation.grid) {
320
+ if (false)
321
+ showMenu(rect, operation.grid);
322
+ else
323
+ showGridMenu(rect, operation.grid, operation.caption ?? "");
324
+ } else if (operation.menu) {
325
+ showMenu(rect, operation.menu);
326
+ }
327
+ }
328
+ }
329
+ function get_this_or_next_valid_index(index) {
330
+ if (!operations)
331
+ return 0;
332
+ if (operations.length == 0)
333
+ return 0;
334
+ if (index >= operations.length)
335
+ return operations.length - 1;
336
+ if (index < 0)
337
+ return 0;
338
+ const op = operations[index];
339
+ if (op.separator || op.disabled)
340
+ return get_this_or_next_valid_index(index + 1);
341
+ else
342
+ return index;
343
+ }
344
+ function get_this_or_prev_valid_index(index) {
345
+ if (!operations)
346
+ return 0;
347
+ if (operations.length == 0)
348
+ return 0;
349
+ if (index >= operations.length)
350
+ return operations.length - 1;
351
+ if (index < 0)
352
+ return 0;
353
+ const op = operations[index];
354
+ if (op.separator || op.disabled)
355
+ return get_this_or_prev_valid_index(index - 1);
356
+ else
357
+ return index;
358
+ }
359
+ function focus_menu_item(index) {
360
+ const operation = operations[index];
361
+ if (operation.disabled)
362
+ return;
363
+ focused_index = get_this_or_next_valid_index(index);
364
+ let element = menu_items[focused_index];
365
+ element.focus();
366
+ if (submenus && submenus.length) {
367
+ if (submenus[focused_index]) {
368
+ let rect = element.getBoundingClientRect();
369
+ submenus[focused_index].show(rect, operations[focused_index].menu, SHOW_MENU_RIGHT);
370
+ }
371
+ for (let i = 0; i < submenus.length; i++) {
372
+ if (i != focused_index) {
373
+ if (submenus[i])
374
+ submenus[i].hide();
375
+ }
376
+ }
377
+ }
378
+ }
379
+ function hide_submenu() {
380
+ if (!owner_menu_item)
381
+ return;
382
+ owner_menu_item.focus();
383
+ hide();
384
+ }
385
+ function mousedown(e) {
386
+ e.preventDefault();
387
+ }
388
+ function calculateBackground(is_highlighted, active) {
389
+ if (is_highlighted) {
390
+ if (active)
391
+ return "bg-stone-400/40 dark:bg-stone-400/40";
392
+ else
393
+ return "bg-stone-400/30 dark:bg-stone-400/30";
394
+ } else {
395
+ if (active)
396
+ return "bg-stone-400/20 dark:bg-stone-400/20";
397
+ else
398
+ return "";
399
+ }
400
+ }
401
+ function isOperationActivated(operation) {
402
+ if (operation.activeFunc)
403
+ return operation.activeFunc();
404
+ else
405
+ return operation.active ?? false;
406
+ }
407
+ function isOperationDisabled(operation) {
408
+ if (operation.disabledFunc)
409
+ return operation.disabledFunc();
410
+ else
411
+ return operation.disabled ?? false;
412
+ }
413
+ </script>
414
+
415
+
416
+ <div id="__hd_svelte_contextmenu"
417
+ class="
418
+ bg-stone-100 dark:bg-stone-800 rounded-lg shadow-md shadow-stone-500 dark:shadow-black z-40 fixed
419
+ sm:shadow-xl sm:shadow-slate-700/10
420
+ sm:dark:shadow-black/80
421
+ sm:outline sm:outline-1 sm:outline-stone-500
422
+ z-40 fixed min-w-60 max-h-screen overflow-y-auto overscroll-contain"
423
+
424
+ style={css_position}
425
+ visible={visible}
426
+ bind:this={menu_root}>
427
+ <div class="
428
+ paper w-full sm:w-[24rem]
429
+ prose prose-base prose-zinc dark:prose-invert prose-a:no-underline
430
+ sm:max-w-3xl
431
+ m-0 pt-3 pb-5 px-4
432
+ sm:rounded
433
+ sm:bg-stone-100 sm:dark:bg-stone-900
434
+ flex flex-col
435
+ ">
436
+
437
+
438
+ {#if closeButtonPos}
439
+ <button class=" fixed w-6 h-6 flex items-center justify-center
440
+ focus:outline-none font-medium text-sm text-center"
441
+ style={closeButtonPos}
442
+ on:click={ hide }> <!--focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800 rounded-full text-stone-500 bg-stone-200/70 hover:bg-stone-200 dark:text-stone-500 dark:bg-stone-700/80 dark:hover:bg-stone-700 -->
443
+ <Icon component={FaTimes} s="md"/>
444
+ </button>
445
+ {/if}
446
+
447
+ {#each operations as operation, index}
448
+ {@const is_separator = operation.separator}
449
+ {#if is_separator}
450
+ {#if index>0 && index < operations.length-1}
451
+ <hr class="my-1 mx-4 border-1 border-stone-300 dark:border-stone-700">
452
+ {/if}
453
+ {:else}
454
+ {@const mobile = isDeviceSmallerThan("sm")}
455
+ {@const icon_placeholder_without_desc = mobile ? 12 : 10}
456
+ {@const icon_placeholder_with_desc = mobile ? 14 : 12}
457
+ {@const icon_placeholder_size = operation.description ? icon_placeholder_with_desc : icon_placeholder_without_desc}
458
+ {@const menu_item_id = menu_items_id_prefix + index}
459
+ {@const isTop = index==0}
460
+ {@const isBottom = index == operations.length-1}
461
+ {@const isFocused = index == focused_index}
462
+ {@const clipFocusedBorder = isFocused ? (isTop ? 'rounded-t-lg' : (isBottom ? 'rounded-b-lg' : '')) : ''}
463
+ {@const active = calculateBackground(isFocused || isOperationActivated(operation), false)}
464
+ {@const has_submenu = operation.menu !== undefined && operation.menu.length > 0}
465
+
466
+ <button class="block w-full pr-4 text-left flex flex-row cursor-context-menu {active} focus:outline-none items-center"
467
+ id={menu_item_id}
468
+ bind:this={menu_items[index]}
469
+ on:click|stopPropagation={(e) => { execute_action(e, operation, index) } }
470
+ on:mouseenter = {(e) => {on_mouse_move(index)}}
471
+ on:keydown|stopPropagation={(e) => on_keydown(e, operation, index)}
472
+ on:mousedown={mousedown}
473
+ disabled={isOperationDisabled(operation)}
474
+ class:opacity-60={isOperationDisabled(operation)}>
475
+
476
+ <div class="flex justify-center space-x-10 px-4 py-2 ml-12 sm:ml-0" >
477
+ {#if operation.icon}
478
+ {@const cc = mobile ? 7 : 6}
479
+ {@const icon_size = icon_placeholder_size - cc}
480
+ <Icon s="md" component={operation.icon}/>
481
+ {:else if operation.img}
482
+ {@const cc = mobile ? 7 : 6}
483
+ {@const icon_size = icon_placeholder_size - cc}
484
+ <div class="w-4 h-4">
485
+ <img src={operation.img} alt=""/>
486
+ </div>
487
+ {:else}
488
+ {@const cc = mobile ? 7 : 6}
489
+ {@const icon_size = icon_placeholder_size - cc}
490
+ <div class="w-4 h-4"></div>
491
+ {/if}
492
+ </div>
493
+ <div class="">
494
+ <p class=""> {operation.caption}</p>
495
+ {#if operation.description}
496
+ <p class="truncate inline-block text-xs">
497
+ {operation.description}
498
+ </p>
499
+ {/if}
500
+ </div>
501
+ {#if has_submenu}
502
+ <p class="ms-auto pr-1 text-sm font-mono text-stone-500">&rarr;</p>
503
+ <svelte:self bind:this={submenus[index]} menu_items_id_prefix={`${menu_item_id}_`} owner_menu_item={menu_items[index]}/>
504
+ {/if}
505
+ </button>
506
+ {/if}
507
+ {/each}
508
+ </div>
509
+ </div>
510
+
511
+ <!-- use usePreventScroll instead -->
512
+ <!--style>
513
+ :global(#__hd_svelte_layout_root:has(#__hd_svelte_contextmenu[visible="true"]))
514
+ {
515
+ overflow: hidden;
516
+ position: fixed;
517
+ }
518
+ </style-->
@@ -0,0 +1,26 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ widthPx?: number | undefined;
5
+ menu_items_id_prefix?: string | undefined;
6
+ owner_menu_item?: HTMLElement | undefined;
7
+ show?: ((around: DOMRect | DOMPoint, _operations: any, preference?: number) => Promise<void>) | undefined;
8
+ isVisible?: (() => boolean) | undefined;
9
+ hide?: (() => void) | undefined;
10
+ getRenderedRect?: (() => DOMRect | undefined) | undefined;
11
+ };
12
+ events: {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {};
16
+ };
17
+ export type Contextmenu_25Props = typeof __propDef.props;
18
+ export type Contextmenu_25Events = typeof __propDef.events;
19
+ export type Contextmenu_25Slots = typeof __propDef.slots;
20
+ export default class Contextmenu_25 extends SvelteComponentTyped<Contextmenu_25Props, Contextmenu_25Events, Contextmenu_25Slots> {
21
+ get show(): (around: DOMRect | DOMPoint, _operations: any, preference?: number) => Promise<void>;
22
+ get isVisible(): () => boolean;
23
+ get hide(): () => void;
24
+ get getRenderedRect(): () => DOMRect | undefined;
25
+ }
26
+ export {};