@umbra.ui/core 0.1.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.
Files changed (272) hide show
  1. package/dist/components/controls/Dropdown/types.d.ts +5 -0
  2. package/dist/components/controls/Dropdown/types.d.ts.map +1 -0
  3. package/dist/components/controls/Dropdown/types.js +1 -0
  4. package/dist/components/controls/SegmentedControl/types.d.ts +6 -0
  5. package/dist/components/controls/SegmentedControl/types.d.ts.map +1 -0
  6. package/dist/components/controls/SegmentedControl/types.js +1 -0
  7. package/dist/components/dialogs/Alert/types.d.ts +7 -0
  8. package/dist/components/dialogs/Alert/types.d.ts.map +1 -0
  9. package/dist/components/dialogs/Alert/types.js +1 -0
  10. package/dist/components/dialogs/Toast/types.d.ts +34 -0
  11. package/dist/components/dialogs/Toast/types.d.ts.map +1 -0
  12. package/dist/components/dialogs/Toast/types.js +10 -0
  13. package/dist/components/dialogs/Toast/useToast.d.ts +36 -0
  14. package/dist/components/dialogs/Toast/useToast.d.ts.map +1 -0
  15. package/dist/components/dialogs/Toast/useToast.js +90 -0
  16. package/dist/components/indicators/Tooltip/tooltip.d.ts +3 -0
  17. package/dist/components/indicators/Tooltip/tooltip.d.ts.map +1 -0
  18. package/dist/components/indicators/Tooltip/tooltip.js +33 -0
  19. package/dist/components/indicators/Tooltip/types.d.ts +14 -0
  20. package/dist/components/indicators/Tooltip/types.d.ts.map +1 -0
  21. package/dist/components/indicators/Tooltip/types.js +1 -0
  22. package/dist/components/indicators/Tooltip/useTooltip.d.ts +18 -0
  23. package/dist/components/indicators/Tooltip/useTooltip.d.ts.map +1 -0
  24. package/dist/components/indicators/Tooltip/useTooltip.js +57 -0
  25. package/dist/components/inputs/Tags/tag-bar-styles.d.ts +14 -0
  26. package/dist/components/inputs/Tags/tag-bar-styles.d.ts.map +1 -0
  27. package/dist/components/inputs/Tags/tag-bar-styles.js +313 -0
  28. package/dist/components/inputs/Tags/types.d.ts +93 -0
  29. package/dist/components/inputs/Tags/types.d.ts.map +1 -0
  30. package/dist/components/inputs/Tags/types.js +216 -0
  31. package/dist/components/inputs/search/types.d.ts +9 -0
  32. package/dist/components/inputs/search/types.d.ts.map +1 -0
  33. package/dist/components/inputs/search/types.js +1 -0
  34. package/dist/components/navigation/adaptive/types.d.ts +16 -0
  35. package/dist/components/navigation/adaptive/types.d.ts.map +1 -0
  36. package/dist/components/navigation/adaptive/types.js +1 -0
  37. package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts +27 -0
  38. package/dist/components/navigation/adaptive/useAdaptiveLayout.d.ts.map +1 -0
  39. package/dist/components/navigation/adaptive/useAdaptiveLayout.js +40 -0
  40. package/dist/components/navigation/adaptive/useBreakpoints.d.ts +6 -0
  41. package/dist/components/navigation/adaptive/useBreakpoints.d.ts.map +1 -0
  42. package/dist/components/navigation/adaptive/useBreakpoints.js +37 -0
  43. package/dist/components/navigation/adaptive/useContainerMonitor.d.ts +93 -0
  44. package/dist/components/navigation/adaptive/useContainerMonitor.d.ts.map +1 -0
  45. package/dist/components/navigation/adaptive/useContainerMonitor.js +145 -0
  46. package/dist/components/navigation/adaptive/useViewAnimation.d.ts +31 -0
  47. package/dist/components/navigation/adaptive/useViewAnimation.d.ts.map +1 -0
  48. package/dist/components/navigation/adaptive/useViewAnimation.js +591 -0
  49. package/dist/components/navigation/adaptive/useViewResize.d.ts +52 -0
  50. package/dist/components/navigation/adaptive/useViewResize.d.ts.map +1 -0
  51. package/dist/components/navigation/adaptive/useViewResize.js +146 -0
  52. package/dist/components/navigation/navstack/useNavigationStack.d.ts +25 -0
  53. package/dist/components/navigation/navstack/useNavigationStack.d.ts.map +1 -0
  54. package/dist/components/navigation/navstack/useNavigationStack.js +133 -0
  55. package/dist/components/navigation/slideover/useSlideoverController.d.ts +20 -0
  56. package/dist/components/navigation/slideover/useSlideoverController.d.ts.map +1 -0
  57. package/dist/components/navigation/slideover/useSlideoverController.js +267 -0
  58. package/dist/components/navigation/splitview/useSplitViewController.d.ts +20 -0
  59. package/dist/components/navigation/splitview/useSplitViewController.d.ts.map +1 -0
  60. package/dist/components/navigation/splitview/useSplitViewController.js +325 -0
  61. package/dist/components/navigation/tabcontroller/types.d.ts +21 -0
  62. package/dist/components/navigation/tabcontroller/types.d.ts.map +1 -0
  63. package/dist/components/navigation/tabcontroller/types.js +1 -0
  64. package/dist/components/navigation/tabcontroller/useTabController.d.ts +5 -0
  65. package/dist/components/navigation/tabcontroller/useTabController.d.ts.map +1 -0
  66. package/dist/components/navigation/tabcontroller/useTabController.js +10 -0
  67. package/dist/components/navigation/types.d.ts +8 -0
  68. package/dist/components/navigation/types.d.ts.map +1 -0
  69. package/dist/components/navigation/types.js +1 -0
  70. package/dist/components/pickers/CollectionPicker/types.d.ts +11 -0
  71. package/dist/components/pickers/CollectionPicker/types.d.ts.map +1 -0
  72. package/dist/components/pickers/CollectionPicker/types.js +1 -0
  73. package/dist/components/pickers/ColorPicker/colors.d.ts +13 -0
  74. package/dist/components/pickers/ColorPicker/colors.d.ts.map +1 -0
  75. package/dist/components/pickers/ColorPicker/colors.js +266 -0
  76. package/dist/components/pickers/FilePicker/types.d.ts +10 -0
  77. package/dist/components/pickers/FilePicker/types.d.ts.map +1 -0
  78. package/dist/components/pickers/FilePicker/types.js +1 -0
  79. package/dist/index.d.ts +91 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +196 -0
  82. package/dist/theme.d.ts +73 -0
  83. package/dist/theme.d.ts.map +1 -0
  84. package/dist/theme.js +279 -0
  85. package/dist/themes/blank.d.ts +7 -0
  86. package/dist/themes/blank.d.ts.map +1 -0
  87. package/dist/themes/blank.js +543 -0
  88. package/dist/themes/crimson-dark.d.ts +4 -0
  89. package/dist/themes/crimson-dark.d.ts.map +1 -0
  90. package/dist/themes/crimson-dark.js +552 -0
  91. package/dist/themes/cyan-light.d.ts +4 -0
  92. package/dist/themes/cyan-light.d.ts.map +1 -0
  93. package/dist/themes/cyan-light.js +552 -0
  94. package/dist/themes/dark.d.ts +4 -0
  95. package/dist/themes/dark.d.ts.map +1 -0
  96. package/dist/themes/dark.js +551 -0
  97. package/dist/themes/gold-dark.d.ts +4 -0
  98. package/dist/themes/gold-dark.d.ts.map +1 -0
  99. package/dist/themes/gold-dark.js +552 -0
  100. package/dist/themes/grass-dark.d.ts +4 -0
  101. package/dist/themes/grass-dark.d.ts.map +1 -0
  102. package/dist/themes/grass-dark.js +552 -0
  103. package/dist/themes/indigo.d.ts +4 -0
  104. package/dist/themes/indigo.d.ts.map +1 -0
  105. package/dist/themes/indigo.js +552 -0
  106. package/dist/themes/light.d.ts +4 -0
  107. package/dist/themes/light.d.ts.map +1 -0
  108. package/dist/themes/light.js +551 -0
  109. package/dist/themes/orange-dark.d.ts +4 -0
  110. package/dist/themes/orange-dark.d.ts.map +1 -0
  111. package/dist/themes/orange-dark.js +551 -0
  112. package/dist/themes/orange-light.d.ts +4 -0
  113. package/dist/themes/orange-light.d.ts.map +1 -0
  114. package/dist/themes/orange-light.js +551 -0
  115. package/package.json +62 -0
  116. package/src/components/controls/Button/Button.vue +417 -0
  117. package/src/components/controls/Button/README.md +348 -0
  118. package/src/components/controls/Button/theme.css +200 -0
  119. package/src/components/controls/Checkbox/Checkbox.vue +164 -0
  120. package/src/components/controls/Checkbox/README.md +441 -0
  121. package/src/components/controls/Checkbox/theme.css +36 -0
  122. package/src/components/controls/Dropdown/Dropdown.vue +476 -0
  123. package/src/components/controls/Dropdown/README.md +370 -0
  124. package/src/components/controls/Dropdown/theme.css +50 -0
  125. package/src/components/controls/Dropdown/types.ts +6 -0
  126. package/src/components/controls/IconButton/IconButton.vue +267 -0
  127. package/src/components/controls/IconButton/README.md +502 -0
  128. package/src/components/controls/IconButton/theme.css +89 -0
  129. package/src/components/controls/Radio/README.md +591 -0
  130. package/src/components/controls/Radio/Radio.vue +89 -0
  131. package/src/components/controls/Radio/theme.css +14 -0
  132. package/src/components/controls/RangeSlider/README.md +608 -0
  133. package/src/components/controls/RangeSlider/RangeSlider.vue +535 -0
  134. package/src/components/controls/RangeSlider/theme.css +80 -0
  135. package/src/components/controls/SegmentedControl/README.md +587 -0
  136. package/src/components/controls/SegmentedControl/SegmentedControl.vue +284 -0
  137. package/src/components/controls/SegmentedControl/theme.css +60 -0
  138. package/src/components/controls/SegmentedControl/types.ts +5 -0
  139. package/src/components/controls/Slider/README.md +627 -0
  140. package/src/components/controls/Slider/Slider.vue +260 -0
  141. package/src/components/controls/Slider/theme.css +74 -0
  142. package/src/components/controls/Stepper/README.md +601 -0
  143. package/src/components/controls/Stepper/Stepper.vue +103 -0
  144. package/src/components/controls/Stepper/theme.css +53 -0
  145. package/src/components/controls/Switch/README.md +667 -0
  146. package/src/components/controls/Switch/Switch.vue +127 -0
  147. package/src/components/controls/Switch/theme.css +42 -0
  148. package/src/components/dialogs/Alert/Alert.vue +218 -0
  149. package/src/components/dialogs/Alert/README.md +450 -0
  150. package/src/components/dialogs/Alert/theme.css +44 -0
  151. package/src/components/dialogs/Alert/types.ts +11 -0
  152. package/src/components/dialogs/Toast/README.md +522 -0
  153. package/src/components/dialogs/Toast/Toast.vue +296 -0
  154. package/src/components/dialogs/Toast/ToastContainer.vue +330 -0
  155. package/src/components/dialogs/Toast/theme.css +44 -0
  156. package/src/components/dialogs/Toast/types.ts +46 -0
  157. package/src/components/dialogs/Toast/useToast.ts +127 -0
  158. package/src/components/indicators/ProgressBar/ProgressBar.vue +98 -0
  159. package/src/components/indicators/ProgressBar/README.md +744 -0
  160. package/src/components/indicators/ProgressBar/theme.css +36 -0
  161. package/src/components/indicators/Tooltip/README.md +723 -0
  162. package/src/components/indicators/Tooltip/TooltipProvider.vue +142 -0
  163. package/src/components/indicators/Tooltip/theme.css +18 -0
  164. package/src/components/indicators/Tooltip/tooltip.ts +48 -0
  165. package/src/components/indicators/Tooltip/types.ts +15 -0
  166. package/src/components/indicators/Tooltip/useTooltip.ts +71 -0
  167. package/src/components/inputs/AutogrowTextView/AutogrowTextView.vue +110 -0
  168. package/src/components/inputs/AutogrowTextView/README.md +643 -0
  169. package/src/components/inputs/AutogrowTextView/theme.css +28 -0
  170. package/src/components/inputs/InputCard/InputCard.vue +600 -0
  171. package/src/components/inputs/InputCard/README.md +636 -0
  172. package/src/components/inputs/InputEmail/InputEmail.vue +698 -0
  173. package/src/components/inputs/InputEmail/README.md +764 -0
  174. package/src/components/inputs/InputNumber/InputNumber.vue +300 -0
  175. package/src/components/inputs/InputNumber/README.md +749 -0
  176. package/src/components/inputs/InputPhone/InputPhone.vue +645 -0
  177. package/src/components/inputs/InputPhone/README.md +636 -0
  178. package/src/components/inputs/InputSecure/InputSecure.vue +646 -0
  179. package/src/components/inputs/InputSecure/README.md +771 -0
  180. package/src/components/inputs/InputText/InputText.vue +225 -0
  181. package/src/components/inputs/InputText/README.md +844 -0
  182. package/src/components/inputs/OTP/OTP.vue +349 -0
  183. package/src/components/inputs/OTP/README.md +736 -0
  184. package/src/components/inputs/OTP/theme.css +50 -0
  185. package/src/components/inputs/StringCapture/README.md +718 -0
  186. package/src/components/inputs/StringCapture/StringCapture.vue +315 -0
  187. package/src/components/inputs/StringCapture/theme.css +86 -0
  188. package/src/components/inputs/Tags/README.md +897 -0
  189. package/src/components/inputs/Tags/TagBar.vue +793 -0
  190. package/src/components/inputs/Tags/TagCreation.vue +219 -0
  191. package/src/components/inputs/Tags/TagPicker.vue +380 -0
  192. package/src/components/inputs/Tags/tag-bar-styles.ts +354 -0
  193. package/src/components/inputs/Tags/theme.css +121 -0
  194. package/src/components/inputs/Tags/types.ts +346 -0
  195. package/src/components/inputs/search/README.md +759 -0
  196. package/src/components/inputs/search/SearchBar.vue +394 -0
  197. package/src/components/inputs/search/SearchResults.vue +310 -0
  198. package/src/components/inputs/search/theme.css +187 -0
  199. package/src/components/inputs/search/types.ts +8 -0
  200. package/src/components/inputs/theme.css +102 -0
  201. package/src/components/menus/ActionMenu/ActionMenu.vue +383 -0
  202. package/src/components/menus/ActionMenu/README.md +825 -0
  203. package/src/components/menus/ActionMenu/theme.css +93 -0
  204. package/src/components/models/Popover/Popover.vue +551 -0
  205. package/src/components/models/Popover/README.md +885 -0
  206. package/src/components/models/Popover/theme.css +52 -0
  207. package/src/components/models/Sheet/README.md +1159 -0
  208. package/src/components/models/Sheet/Sheet.vue +465 -0
  209. package/src/components/models/Sheet/theme.css +72 -0
  210. package/src/components/models/Sidebar/README.md +1228 -0
  211. package/src/components/models/Sidebar/Sidebar.vue +480 -0
  212. package/src/components/models/Sidebar/theme.css +90 -0
  213. package/src/components/navigation/adaptive/AdaptiveLayout.vue +779 -0
  214. package/src/components/navigation/adaptive/AdaptiveLayoutBreadcrumbs.vue +192 -0
  215. package/src/components/navigation/adaptive/AdaptiveLayoutMenuButton.vue +149 -0
  216. package/src/components/navigation/adaptive/README.md +768 -0
  217. package/src/components/navigation/adaptive/types.ts +19 -0
  218. package/src/components/navigation/adaptive/useAdaptiveLayout.ts +89 -0
  219. package/src/components/navigation/adaptive/useBreakpoints.ts +41 -0
  220. package/src/components/navigation/adaptive/useContainerMonitor.ts +214 -0
  221. package/src/components/navigation/adaptive/useViewAnimation.ts +721 -0
  222. package/src/components/navigation/adaptive/useViewResize.ts +211 -0
  223. package/src/components/navigation/navstack/NavigationStack.vue +180 -0
  224. package/src/components/navigation/navstack/README.md +994 -0
  225. package/src/components/navigation/navstack/useNavigationStack.ts +164 -0
  226. package/src/components/navigation/slideover/README.md +1275 -0
  227. package/src/components/navigation/slideover/SlideoverController.vue +287 -0
  228. package/src/components/navigation/slideover/useSlideoverController.ts +320 -0
  229. package/src/components/navigation/splitview/README.md +1115 -0
  230. package/src/components/navigation/splitview/SplitViewController.vue +176 -0
  231. package/src/components/navigation/splitview/useSplitViewController.ts +388 -0
  232. package/src/components/navigation/tabcontroller/README.md +919 -0
  233. package/src/components/navigation/tabcontroller/TabController.vue +307 -0
  234. package/src/components/navigation/tabcontroller/TabItem.vue +57 -0
  235. package/src/components/navigation/tabcontroller/types.ts +24 -0
  236. package/src/components/navigation/tabcontroller/useTabController.ts +18 -0
  237. package/src/components/navigation/theme.css +91 -0
  238. package/src/components/navigation/types.ts +7 -0
  239. package/src/components/pickers/CollectionPicker/CollectionPicker.vue +398 -0
  240. package/src/components/pickers/CollectionPicker/README.md +1115 -0
  241. package/src/components/pickers/CollectionPicker/theme.css +14 -0
  242. package/src/components/pickers/CollectionPicker/types.ts +11 -0
  243. package/src/components/pickers/ColorPicker/ColorPicker.vue +376 -0
  244. package/src/components/pickers/ColorPicker/README.md +1439 -0
  245. package/src/components/pickers/ColorPicker/colors.ts +299 -0
  246. package/src/components/pickers/ColorPicker/theme.css +32 -0
  247. package/src/components/pickers/DatePicker/DatePicker.vue +660 -0
  248. package/src/components/pickers/DatePicker/README.md +1195 -0
  249. package/src/components/pickers/DatePicker/theme.css +22 -0
  250. package/src/components/pickers/FilePicker/FilePicker.vue +534 -0
  251. package/src/components/pickers/FilePicker/README.md +1542 -0
  252. package/src/components/pickers/FilePicker/theme.css +48 -0
  253. package/src/components/pickers/FilePicker/types.ts +10 -0
  254. package/src/components/pickers/IconPicker/IconPicker.vue +327 -0
  255. package/src/components/pickers/IconPicker/README.md +1161 -0
  256. package/src/components/pickers/IconPicker/theme.css +28 -0
  257. package/src/components/pickers/theme.css +82 -0
  258. package/src/components/views/MarkdownViewer/MarkdownViewer.vue +442 -0
  259. package/src/components/views/MarkdownViewer/README.md +833 -0
  260. package/src/components/views/MarkdownViewer/theme.css +130 -0
  261. package/src/index.ts +263 -0
  262. package/src/theme.ts +378 -0
  263. package/src/themes/crimson-dark.ts +556 -0
  264. package/src/themes/cyan-light.ts +556 -0
  265. package/src/themes/dark.ts +557 -0
  266. package/src/themes/gold-dark.ts +556 -0
  267. package/src/themes/grass-dark.ts +556 -0
  268. package/src/themes/indigo.ts +556 -0
  269. package/src/themes/light.ts +557 -0
  270. package/src/themes/orange-dark.ts +557 -0
  271. package/src/themes/orange-light.ts +557 -0
  272. package/src/vue.d.ts +45 -0
@@ -0,0 +1,591 @@
1
+ import { nextTick, ref } from "vue";
2
+ import { Flip } from "gsap/Flip";
3
+ import gsap from "gsap";
4
+ gsap.registerPlugin(Flip);
5
+ const animationInProgress = ref(false);
6
+ /*
7
+ # FLIP Order of Operations
8
+ Step 1: Get State
9
+ Step 3: Manipulate DOM
10
+ Step 4: Animate
11
+ Step 5: Update Data (vue reactive state)
12
+ */
13
+ export const useViewAnimation = (views, instanceKey, containerDimensions, padding, gap) => {
14
+ /*
15
+ * Basic animation function
16
+ */
17
+ const animate = async (targets, manipulateDOMFn, updateDataFn) => {
18
+ if (animationInProgress.value) {
19
+ console.warn("Animation already in progress");
20
+ return;
21
+ }
22
+ animationInProgress.value = true;
23
+ // Step 1: Get State
24
+ const state = Flip.getState(targets);
25
+ // Step 2: Manipulate DOM
26
+ manipulateDOMFn();
27
+ // Step 3: Animate
28
+ return Flip.from(state, {
29
+ duration: 0.3,
30
+ ease: "power1.inOut",
31
+ absolute: true,
32
+ onComplete: () => {
33
+ animationInProgress.value = false;
34
+ },
35
+ }).then(() => {
36
+ // Step 5: Update Data
37
+ updateDataFn();
38
+ });
39
+ };
40
+ /*
41
+ Utility Functions
42
+ */
43
+ // Helper functions to get unique element IDs
44
+ const getOffscreenLeadingId = () => `${instanceKey}-offscreen-leading`;
45
+ const getOffscreenTrailingId = () => `${instanceKey}-offscreen-trailing`;
46
+ const getOnscreenId = () => `${instanceKey}-onscreen`;
47
+ const getViewId = (view) => `${instanceKey}-view-${view.id}`;
48
+ const getDarkenId = () => `${instanceKey}-darken`;
49
+ const getOverlayId = () => `${instanceKey}-overlay`;
50
+ const getViewElements = () => {
51
+ return views.value
52
+ .map((view) => document.getElementById(getViewId(view)))
53
+ .filter((element) => element !== null);
54
+ };
55
+ const getAllViewsBefore = (id) => {
56
+ const targetIndex = views.value.findIndex((view) => view.id === id);
57
+ return views.value.slice(0, targetIndex);
58
+ };
59
+ const getAllViewsBeforeIndex = (index) => {
60
+ return views.value.slice(0, index);
61
+ };
62
+ const getAllViewsAfterIndex = (index) => {
63
+ return views.value.slice(index + 1);
64
+ };
65
+ const getAllViewsAfter = (id) => {
66
+ const targetIndex = views.value.findIndex((view) => view.id === id);
67
+ if (targetIndex === -1) {
68
+ return []; // View not found
69
+ }
70
+ return views.value.slice(targetIndex + 1);
71
+ };
72
+ const getAllViewsAfterWithLocation = (id, location) => {
73
+ const viewsAfter = getAllViewsAfter(id);
74
+ return viewsAfter.filter((view) => view.location === location);
75
+ };
76
+ const getAllViewElementsAfterWithLocation = (id, location) => {
77
+ const viewsAfter = getAllViewsAfterWithLocation(id, location);
78
+ // Map to HTMLElements and filter out null values
79
+ return viewsAfter
80
+ .map((view) => document.getElementById(getViewId(view)))
81
+ .filter((element) => element !== null);
82
+ };
83
+ const getAllViewElementsBefore = (id) => {
84
+ const targetIndex = views.value.findIndex((view) => view.id === id);
85
+ if (targetIndex === -1) {
86
+ return []; // View not found
87
+ }
88
+ // Get all views before the target index
89
+ const precedingViews = views.value.slice(0, targetIndex);
90
+ // Map to HTMLElements and filter out null values
91
+ return precedingViews
92
+ .map((view) => document.getElementById(getViewId(view)))
93
+ .filter((element) => element !== null);
94
+ };
95
+ const getSingleViewBefore = (id) => {
96
+ const targetIndex = views.value.findIndex((view) => view.id === id);
97
+ if (targetIndex === -1 || targetIndex === 0) {
98
+ return null; // View not found or is first view
99
+ }
100
+ return views.value[targetIndex - 1];
101
+ };
102
+ const getSingleViewAfter = (id) => {
103
+ const targetIndex = views.value.findIndex((view) => view.id === id);
104
+ if (targetIndex === -1 || targetIndex === views.value.length - 1) {
105
+ return null; // View not found or is last view
106
+ }
107
+ return views.value[targetIndex + 1];
108
+ };
109
+ const getSingleViewElementBefore = (id) => {
110
+ const precedingView = getSingleViewBefore(id);
111
+ if (!precedingView) {
112
+ return null;
113
+ }
114
+ return document.getElementById(getViewId(precedingView));
115
+ };
116
+ const isOnscreen = (view) => {
117
+ return view.location === "onscreen";
118
+ };
119
+ const hasPrecedingViews = (id, location) => {
120
+ const targetIndex = views.value.findIndex((view) => view.id === id);
121
+ if (targetIndex === -1) {
122
+ return false; // View not found
123
+ }
124
+ // Check if ANY preceding view has the specified location
125
+ return views.value
126
+ .slice(0, targetIndex)
127
+ .some((view) => view.location === location);
128
+ };
129
+ const calculateContentWidth = (containerWidth, paddingString) => {
130
+ // Handle empty or invalid padding
131
+ if (!paddingString || paddingString === "0") {
132
+ return containerWidth;
133
+ }
134
+ // Split padding string by spaces and filter out empty strings
135
+ const values = paddingString
136
+ .trim()
137
+ .split(/\s+/)
138
+ .map((v) => parseFloat(v));
139
+ // Determine horizontal padding based on number of values
140
+ let horizontalPadding = 0;
141
+ switch (values.length) {
142
+ case 1:
143
+ // padding: 10px (all sides)
144
+ horizontalPadding = values[0] * 2;
145
+ break;
146
+ case 2:
147
+ // padding: 10px 20px (vertical horizontal)
148
+ horizontalPadding = values[1] * 2;
149
+ break;
150
+ case 3:
151
+ // padding: 10px 20px 15px (top horizontal bottom)
152
+ horizontalPadding = values[1] * 2;
153
+ break;
154
+ case 4:
155
+ // padding: 10px 20px 15px 25px (top right bottom left)
156
+ horizontalPadding = values[1] + values[3];
157
+ break;
158
+ }
159
+ return containerWidth - horizontalPadding;
160
+ };
161
+ const getFirstViewInOnscreen = () => {
162
+ return views.value.find((v) => v.location === "onscreen");
163
+ };
164
+ const getFirstViewInOverlay = () => {
165
+ return views.value.find((v) => v.location === "overlay");
166
+ };
167
+ const splitViewShow = async (id) => {
168
+ const view = views.value.find((v) => v.id === id);
169
+ if (view?.location === "onscreen")
170
+ return;
171
+ await splitViewNavigate(id, "show");
172
+ };
173
+ const splitViewHide = async (id) => {
174
+ // Prevent hiding the last view (would result in nothing being shown)
175
+ const viewIndex = views.value.findIndex((view) => view.id === id);
176
+ if (viewIndex === views.value.length - 1) {
177
+ return;
178
+ }
179
+ await splitViewNavigate(id, "hide");
180
+ };
181
+ const splitViewPush = async (id = null) => {
182
+ // if id is provided, push from that id
183
+ if (id) {
184
+ await splitViewNavigate(id, "push");
185
+ return;
186
+ }
187
+ else {
188
+ const firstInOnscreen = getFirstViewInOnscreen()?.id;
189
+ if (!firstInOnscreen) {
190
+ console.error("No view to push from");
191
+ return;
192
+ }
193
+ await splitViewNavigate(firstInOnscreen, "push");
194
+ return;
195
+ }
196
+ };
197
+ const splitViewPop = async (id = null) => {
198
+ // if id is provided, pop from that id
199
+ if (id) {
200
+ await splitViewNavigate(id, "pop");
201
+ return;
202
+ }
203
+ // if id is not provided, pop from the view to the right of the first view in onscreen (yes, I know it's a little weird)
204
+ else {
205
+ const firstInOnscreen = getFirstViewInOnscreen()?.id;
206
+ if (!firstInOnscreen)
207
+ return;
208
+ const nextInOnscreen = getSingleViewAfter(firstInOnscreen)?.id;
209
+ if (!nextInOnscreen) {
210
+ console.warn("nothing left to pop from");
211
+ return;
212
+ }
213
+ await splitViewNavigate(nextInOnscreen, "pop");
214
+ return;
215
+ }
216
+ };
217
+ const splitViewNavigate = async (id, type) => {
218
+ const elements = getViewElements();
219
+ // Get the appropriate view elements based on type
220
+ let viewElements = [];
221
+ switch (type) {
222
+ case "push":
223
+ viewElements = [getSingleViewElementBefore(id)];
224
+ break;
225
+ case "pop":
226
+ viewElements = getAllViewElementsBefore(id);
227
+ break;
228
+ case "show":
229
+ // Get the view with the given id AND all views after it that have location "leading"
230
+ const currentView = document.getElementById(getViewId(views.value.find((v) => v.id === id)));
231
+ const viewsAfterWithLeading = getAllViewElementsAfterWithLocation(id, "leading");
232
+ viewElements = [currentView, ...viewsAfterWithLeading];
233
+ break;
234
+ case "hide":
235
+ // Get the current view AND all views before it
236
+ const hideCurrentView = document.getElementById(getViewId(views.value.find((v) => v.id === id)));
237
+ viewElements = [hideCurrentView, ...getAllViewElementsBefore(id)];
238
+ break;
239
+ }
240
+ // Early return for push if no element found
241
+ if (type === "push" && !viewElements[0])
242
+ return;
243
+ const manipulateDOM = () => {
244
+ switch (type) {
245
+ case "push": {
246
+ const onscreen = document.getElementById(getOnscreenId());
247
+ if (!onscreen)
248
+ return;
249
+ const viewElement = viewElements[0];
250
+ if (viewElement) {
251
+ viewElement.parentNode?.removeChild(viewElement);
252
+ viewElement.style.order = "";
253
+ onscreen.insertBefore(viewElement, onscreen.children[0] || null);
254
+ }
255
+ break;
256
+ }
257
+ case "pop": {
258
+ const offscreenLeading = document.getElementById(getOffscreenLeadingId());
259
+ if (!offscreenLeading)
260
+ return;
261
+ viewElements.forEach((view) => {
262
+ if (view) {
263
+ view.parentNode?.removeChild(view);
264
+ offscreenLeading.appendChild(view);
265
+ }
266
+ });
267
+ break;
268
+ }
269
+ case "show": {
270
+ const onscreen = document.getElementById(getOnscreenId());
271
+ if (!onscreen)
272
+ return;
273
+ // Show the view with the given id and all views after it that have location "leading"
274
+ // Add them at the beginning of onscreen in reverse order to maintain correct sequence
275
+ viewElements.reverse().forEach((view) => {
276
+ if (view) {
277
+ view.parentNode?.removeChild(view);
278
+ view.style.order = "";
279
+ onscreen.insertBefore(view, onscreen.children[0] || null);
280
+ }
281
+ });
282
+ break;
283
+ }
284
+ case "hide": {
285
+ const offscreenLeading = document.getElementById(getOffscreenLeadingId());
286
+ if (!offscreenLeading)
287
+ return;
288
+ // Hide the current view and all views before it
289
+ viewElements.forEach((view) => {
290
+ if (view) {
291
+ view.parentNode?.removeChild(view);
292
+ offscreenLeading.appendChild(view);
293
+ }
294
+ });
295
+ break;
296
+ }
297
+ }
298
+ };
299
+ const updateData = async () => {
300
+ switch (type) {
301
+ case "push": {
302
+ const prevIndex = views.value.findIndex((view) => view.id === getSingleViewBefore(id)?.id);
303
+ views.value[prevIndex].location = "onscreen";
304
+ break;
305
+ }
306
+ case "pop": {
307
+ const beforeViews = getAllViewsBefore(id);
308
+ beforeViews.forEach((view) => {
309
+ view.location = "leading";
310
+ });
311
+ break;
312
+ }
313
+ case "show": {
314
+ // Update the view with the given id to be onscreen
315
+ const currentViewIndex = views.value.findIndex((v) => v.id === id);
316
+ if (currentViewIndex !== -1) {
317
+ views.value[currentViewIndex].location = "onscreen";
318
+ }
319
+ // Update all views after the given id that have location "leading" to be onscreen
320
+ const viewsAfterWithLeading = getAllViewsAfterWithLocation(id, "leading");
321
+ viewsAfterWithLeading.forEach((view) => {
322
+ view.location = "onscreen";
323
+ });
324
+ break;
325
+ }
326
+ case "hide": {
327
+ // Update the current view and all views before it to be leading/offscreen
328
+ const currentViewIndex = views.value.findIndex((v) => v.id === id);
329
+ if (currentViewIndex !== -1) {
330
+ views.value[currentViewIndex].location = "leading";
331
+ }
332
+ const beforeViews = getAllViewsBefore(id);
333
+ beforeViews.forEach((view) => {
334
+ view.location = "leading";
335
+ });
336
+ break;
337
+ }
338
+ }
339
+ };
340
+ await animate(elements, manipulateDOM, updateData);
341
+ };
342
+ /*
343
+ * Internal Functions: Slideover
344
+ For Slideover:
345
+ - show presents the overlay and the view(s) from the left.
346
+ - hide dismisses the overlay and its views.
347
+ - push presents another view to the overlay from the left.
348
+ - pop dismisses a view from the overlay to the left.
349
+ */
350
+ const slideoverShow = async (id) => {
351
+ // Get the view with the given id AND all views after it that have location "leading"
352
+ const currentView = views.value.find((v) => v.id === id);
353
+ if (currentView?.location === "onscreen") {
354
+ console.warn("This view is already onscreen.");
355
+ return;
356
+ }
357
+ const viewsAfterWithLeading = getAllViewsAfterWithLocation(id, "leading");
358
+ const viewsToShow = [currentView, ...viewsAfterWithLeading];
359
+ for (const view of viewsToShow) {
360
+ if (view) {
361
+ view.location = "overlay";
362
+ }
363
+ }
364
+ await nextTick();
365
+ const overlay = document.getElementById(getOverlayId());
366
+ if (!overlay)
367
+ return;
368
+ isOverlayOpen.value = true;
369
+ overlay.style.pointerEvents = "auto";
370
+ overlay.style.transform = "translateX(0)";
371
+ };
372
+ const slideoverHide = async () => {
373
+ const overlay = document.getElementById(getOverlayId());
374
+ if (!overlay)
375
+ return;
376
+ isOverlayOpen.value = false;
377
+ overlay.style.pointerEvents = "none";
378
+ overlay.style.transform = "translateX(calc((110% + 10px) * -1))";
379
+ setTimeout(() => {
380
+ for (const view of views.value) {
381
+ if (!view)
382
+ return;
383
+ if (view.location === "overlay") {
384
+ view.location = "leading";
385
+ }
386
+ }
387
+ }, 330);
388
+ };
389
+ const slideoverPush = async (id = null) => {
390
+ let viewId = id;
391
+ if (!viewId) {
392
+ const firstInOnscreen = getFirstViewInOnscreen()?.id;
393
+ if (!firstInOnscreen)
394
+ return;
395
+ const prevView = getSingleViewBefore(firstInOnscreen);
396
+ if (!prevView) {
397
+ console.warn("no more views to push to");
398
+ return;
399
+ }
400
+ viewId = prevView.id;
401
+ }
402
+ // exit and show the overlay if it's not open
403
+ if (!isOverlayOpen.value) {
404
+ slideoverShow(viewId);
405
+ return;
406
+ }
407
+ // get the elements
408
+ const overlay = document.getElementById(getOverlayId());
409
+ if (!overlay)
410
+ return;
411
+ const leadingViews = views.value
412
+ .filter((view) => view.location === "leading")
413
+ .map((view) => document.getElementById(getViewId(view)))
414
+ .filter((el) => el !== null);
415
+ const overlayViews = views.value
416
+ .filter((view) => view.location === "overlay")
417
+ .map((view) => document.getElementById(getViewId(view)))
418
+ .filter((el) => el !== null);
419
+ const targets = [...leadingViews, ...overlayViews, overlay];
420
+ // manupulate the DOM
421
+ const manipulateDOM = () => {
422
+ const view = getSingleViewElementBefore(viewId);
423
+ if (!view)
424
+ return;
425
+ view.parentNode?.removeChild(view);
426
+ view.style.order = "";
427
+ overlay.insertBefore(view, overlay.children[0] || null);
428
+ };
429
+ // update the data
430
+ const updateData = () => {
431
+ const data = getSingleViewBefore(viewId);
432
+ if (!data)
433
+ return;
434
+ data.location = "overlay";
435
+ };
436
+ animate(targets, manipulateDOM, updateData);
437
+ };
438
+ const slideoverPop = async (id = null) => {
439
+ // exit if the overlay is not open
440
+ if (!isOverlayOpen.value) {
441
+ console.warn("No views to pop from");
442
+ return;
443
+ }
444
+ // if id is provided, pop from that id
445
+ let viewId = id;
446
+ // if id is not provided, pop from the view to the right of the first view in overlay
447
+ if (!viewId) {
448
+ const firstInOverlay = getFirstViewInOverlay()?.id;
449
+ if (!firstInOverlay)
450
+ return;
451
+ const nextView = getSingleViewAfter(firstInOverlay);
452
+ if (!nextView) {
453
+ console.warn("nothing left to pop from");
454
+ return;
455
+ }
456
+ // if the next view is not in overlay, dismiss the overlay (since we are at the end)
457
+ if (nextView.location !== "overlay") {
458
+ console.warn("No more views in overlay... dismissing");
459
+ slideoverHide();
460
+ return;
461
+ }
462
+ viewId = nextView.id;
463
+ }
464
+ const leading = document.getElementById(getOffscreenLeadingId());
465
+ const overlay = document.getElementById(getOverlayId());
466
+ if (!leading || !overlay) {
467
+ console.error("Elements are null");
468
+ return;
469
+ }
470
+ const elements = getViewElements();
471
+ const before = getAllViewElementsBefore(viewId);
472
+ const targets = [...elements, overlay];
473
+ const manipulateDOM = () => {
474
+ const offscreenLeading = document.getElementById(getOffscreenLeadingId());
475
+ if (!offscreenLeading)
476
+ return;
477
+ leading.style.zIndex = "10";
478
+ before.forEach((view) => {
479
+ view.parentNode?.removeChild(view);
480
+ offscreenLeading.appendChild(view);
481
+ });
482
+ };
483
+ const updateData = () => {
484
+ const beforeViews = getAllViewsBefore(viewId);
485
+ beforeViews.forEach((view) => {
486
+ view.location = "leading";
487
+ });
488
+ leading.style.zIndex = "";
489
+ };
490
+ await animate(targets, manipulateDOM, updateData);
491
+ };
492
+ /*
493
+ * Internal Functions: Navstack
494
+ For Navstack:
495
+ - show presents any view fullscreen from either the left or the right depending on location in the stack
496
+ - push presents next view fullscreen from the right, and dismisses current view to the left.
497
+ - pop dismisses current view to the right, and pushes preceeding view fullscreen from the left.
498
+ */
499
+ const navstackShow = async (id) => {
500
+ const index = views.value.findIndex((view) => view.id === id);
501
+ navstackNavigateTo(index);
502
+ };
503
+ const navstackPush = async () => {
504
+ const currentIndex = views.value.findIndex((view) => view.location === "onscreen");
505
+ navstackNavigateTo(currentIndex + 1);
506
+ };
507
+ const navstackPop = async (id) => {
508
+ const currentIndex = views.value.findIndex((view) => view.location === "onscreen");
509
+ navstackNavigateTo(currentIndex - 1);
510
+ };
511
+ const navstackNavigateTo = async (index) => {
512
+ const onscreen = document.getElementById(getOnscreenId());
513
+ const offscreenLeading = document.getElementById(getOffscreenLeadingId());
514
+ const offscreenTrailing = document.getElementById(getOffscreenTrailingId());
515
+ if (!onscreen || !offscreenLeading || !offscreenTrailing)
516
+ return;
517
+ const currentIndex = views.value.findIndex((view) => view.location === "onscreen");
518
+ if (currentIndex === -1)
519
+ return;
520
+ const oldView = views.value[currentIndex];
521
+ const newView = views.value[index];
522
+ // Ensure index is within bounds
523
+ if (index < 0 || index >= views.value.length) {
524
+ console.warn(`Navigation index ${index} out of bounds`);
525
+ return;
526
+ }
527
+ const currentView = document.getElementById(getViewId(oldView));
528
+ if (!currentView)
529
+ return;
530
+ const nextView = document.getElementById(getViewId(newView));
531
+ if (!nextView)
532
+ return;
533
+ // determine which offscreen container to use
534
+ const offscreenContainerOutflow = index > currentIndex ? offscreenLeading : offscreenTrailing;
535
+ const targets = [currentView, nextView];
536
+ const manipulateDOM = () => {
537
+ currentView.style.width = `${calculateContentWidth(containerDimensions.value.width, padding)}px`;
538
+ nextView.style.width = `${calculateContentWidth(containerDimensions.value.width, padding)}px`;
539
+ currentView.parentNode?.removeChild(currentView);
540
+ offscreenContainerOutflow.appendChild(currentView);
541
+ nextView.parentNode?.removeChild(nextView);
542
+ onscreen.appendChild(nextView);
543
+ };
544
+ const updateData = () => {
545
+ // set up all views before the new view to leading
546
+ const prevViews = getAllViewsBeforeIndex(index);
547
+ prevViews.forEach((view) => {
548
+ view.location = "leading";
549
+ });
550
+ // set up all views after the new view to trailing
551
+ const nextViews = getAllViewsAfterIndex(index);
552
+ nextViews.forEach((view) => {
553
+ view.location = "trailing";
554
+ });
555
+ // set up the new view to onscreen
556
+ newView.location = "onscreen";
557
+ currentView.style.width = "";
558
+ nextView.style.width = "";
559
+ };
560
+ await animate(targets, manipulateDOM, updateData);
561
+ };
562
+ /*
563
+ State
564
+ */
565
+ const isOverlayOpen = ref(false);
566
+ return {
567
+ splitViewShow,
568
+ splitViewHide,
569
+ splitViewPush,
570
+ splitViewPop,
571
+ slideoverShow,
572
+ slideoverHide,
573
+ slideoverPush,
574
+ slideoverPop,
575
+ navstackShow,
576
+ navstackPush,
577
+ navstackPop,
578
+ getOffscreenLeadingId,
579
+ getOffscreenTrailingId,
580
+ getOnscreenId,
581
+ getViewId,
582
+ getDarkenId,
583
+ getOverlayId,
584
+ getViewElements,
585
+ isOnscreen,
586
+ hasPrecedingViews,
587
+ isOverlayOpen,
588
+ getSingleViewBefore,
589
+ getSingleViewAfter,
590
+ };
591
+ };
@@ -0,0 +1,52 @@
1
+ import { type Ref } from "vue";
2
+ export interface ResizeState {
3
+ viewId: string;
4
+ startX: number;
5
+ startWidth: number;
6
+ }
7
+ export interface ResizeTooltip {
8
+ visible: boolean;
9
+ x: number;
10
+ y: number;
11
+ width: number;
12
+ }
13
+ export interface ResizeConfig {
14
+ defaultMinWidth: number;
15
+ gap: number;
16
+ padding: number;
17
+ }
18
+ export interface ResizableView {
19
+ id: string;
20
+ minWidth?: number;
21
+ maxWidth?: number;
22
+ currentWidth?: number;
23
+ }
24
+ export declare const useViewResize: (onScreenViews: Ref<ResizableView[]>, config: ResizeConfig, props: {
25
+ gap: string;
26
+ padding: string;
27
+ }, getViewId: (view: ResizableView) => string, // Changed from (index: number) => string
28
+ getOnscreenId: () => string) => {
29
+ resizing: Ref<{
30
+ viewId: string;
31
+ startX: number;
32
+ startWidth: number;
33
+ } | null, ResizeState | {
34
+ viewId: string;
35
+ startX: number;
36
+ startWidth: number;
37
+ } | null>;
38
+ resizeTooltip: Ref<{
39
+ visible: boolean;
40
+ x: number;
41
+ y: number;
42
+ width: number;
43
+ }, ResizeTooltip | {
44
+ visible: boolean;
45
+ x: number;
46
+ y: number;
47
+ width: number;
48
+ }>;
49
+ startResize: (viewId: string, event: MouseEvent) => void;
50
+ updateViewWidth: (viewId: string, width: number) => void;
51
+ };
52
+ //# sourceMappingURL=useViewResize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useViewResize.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/adaptive/useViewResize.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,GACxB,eAAe,GAAG,CAAC,aAAa,EAAE,CAAC,EACnC,QAAQ,YAAY,EACpB,OAAO;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACvC,WAAW,CAAC,IAAI,EAAE,aAAa,KAAK,MAAM,EAAE,yCAAyC;AACrF,eAAe,MAAM,MAAM;;gBA9BnB,MAAM;gBACN,MAAM;oBACF,MAAM;;gBAFV,MAAM;gBACN,MAAM;oBACF,MAAM;;;iBAIT,OAAO;WACb,MAAM;WACN,MAAM;eACF,MAAM;;iBAHJ,OAAO;WACb,MAAM;WACN,MAAM;eACF,MAAM;;0BAwFgB,MAAM,SAAS,UAAU;8BAzDrB,MAAM,SAAS,MAAM;CAsKvD,CAAC"}