lapikit 0.0.0-insiders.fd1a829 → 0.0.0-insiders.fd9617d

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -1
  3. package/bin/configuration.js +303 -0
  4. package/bin/helper.js +59 -0
  5. package/bin/index.js +33 -0
  6. package/bin/presets.js +26 -0
  7. package/bin/prompts.js +67 -0
  8. package/dist/actions/accordion.svelte.d.ts +9 -0
  9. package/dist/actions/accordion.svelte.js +24 -0
  10. package/dist/actions/index.d.ts +2 -0
  11. package/dist/actions/index.js +2 -0
  12. package/dist/actions/use-theme.d.ts +1 -0
  13. package/dist/actions/use-theme.js +18 -0
  14. package/dist/assets/icons/arrow-down.svelte +12 -0
  15. package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
  16. package/dist/assets/icons/arrow-up.svelte +12 -0
  17. package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
  18. package/dist/assets/icons/close-fill.svelte +12 -0
  19. package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
  20. package/dist/assets/icons/loading-fill.svelte +31 -0
  21. package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
  22. package/dist/components/accordion/accordion.css +36 -0
  23. package/dist/components/accordion/accordion.svelte +39 -0
  24. package/dist/components/accordion/accordion.svelte.d.ts +4 -0
  25. package/dist/components/accordion/modules/accordion-item.css +68 -0
  26. package/dist/components/accordion/modules/accordion-item.svelte +94 -0
  27. package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
  28. package/dist/components/accordion/types.d.ts +33 -0
  29. package/dist/components/accordion/types.js +1 -0
  30. package/dist/components/alert/alert.css +130 -0
  31. package/dist/components/alert/alert.svelte +89 -0
  32. package/dist/components/alert/alert.svelte.d.ts +4 -0
  33. package/dist/components/alert/types.d.ts +28 -0
  34. package/dist/components/alert/types.js +1 -0
  35. package/dist/components/app/app.css +26 -0
  36. package/dist/components/app/app.svelte +79 -0
  37. package/dist/components/app/app.svelte.d.ts +4 -0
  38. package/dist/components/app/types.d.ts +10 -0
  39. package/dist/components/app/types.js +1 -0
  40. package/dist/components/appbar/appbar.css +38 -0
  41. package/dist/components/appbar/appbar.svelte +40 -0
  42. package/dist/components/appbar/appbar.svelte.d.ts +4 -0
  43. package/dist/components/appbar/types.d.ts +15 -0
  44. package/dist/components/appbar/types.js +1 -0
  45. package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
  46. package/dist/components/aspect-ratio/aspect-ratio.svelte +25 -0
  47. package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
  48. package/dist/components/aspect-ratio/types.d.ts +5 -0
  49. package/dist/components/aspect-ratio/types.js +1 -0
  50. package/dist/components/avatar/avatar.css +102 -0
  51. package/dist/components/avatar/avatar.svelte +46 -0
  52. package/dist/components/avatar/avatar.svelte.d.ts +4 -0
  53. package/dist/components/avatar/types.d.ts +22 -0
  54. package/dist/components/avatar/types.js +1 -0
  55. package/dist/components/button/button.css +240 -0
  56. package/dist/components/button/button.svelte +102 -0
  57. package/dist/components/button/button.svelte.d.ts +4 -0
  58. package/dist/components/button/types.d.ts +29 -0
  59. package/dist/components/button/types.js +1 -0
  60. package/dist/components/card/card.css +105 -0
  61. package/dist/components/card/card.svelte +67 -0
  62. package/dist/components/card/card.svelte.d.ts +4 -0
  63. package/dist/components/card/types.d.ts +20 -0
  64. package/dist/components/card/types.js +1 -0
  65. package/dist/components/chip/chip.css +224 -0
  66. package/dist/components/chip/chip.svelte +131 -0
  67. package/dist/components/chip/chip.svelte.d.ts +4 -0
  68. package/dist/components/chip/types.d.ts +32 -0
  69. package/dist/components/chip/types.js +1 -0
  70. package/dist/components/dialog/dialog.css +129 -0
  71. package/dist/components/dialog/dialog.svelte +67 -0
  72. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  73. package/dist/components/dialog/types.d.ts +24 -0
  74. package/dist/components/dialog/types.js +1 -0
  75. package/dist/components/dropdown/dropdown.css +13 -0
  76. package/dist/components/dropdown/dropdown.svelte +115 -0
  77. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  78. package/dist/components/dropdown/types.d.ts +26 -0
  79. package/dist/components/dropdown/types.js +1 -0
  80. package/dist/components/icon/icon.css +78 -0
  81. package/dist/components/icon/icon.svelte +49 -0
  82. package/dist/components/icon/icon.svelte.d.ts +4 -0
  83. package/dist/components/icon/types.d.ts +16 -0
  84. package/dist/components/icon/types.js +1 -0
  85. package/dist/components/index.d.ts +22 -0
  86. package/dist/components/index.js +23 -0
  87. package/dist/components/list/list.css +149 -0
  88. package/dist/components/list/list.svelte +44 -0
  89. package/dist/components/list/list.svelte.d.ts +4 -0
  90. package/dist/components/list/modules/list-item.css +67 -0
  91. package/dist/components/list/modules/list-item.svelte +76 -0
  92. package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
  93. package/dist/components/list/types.d.ts +33 -0
  94. package/dist/components/list/types.js +1 -0
  95. package/dist/components/modal/modal.css +137 -0
  96. package/dist/components/modal/modal.svelte +112 -0
  97. package/dist/components/modal/modal.svelte.d.ts +4 -0
  98. package/dist/components/modal/types.d.ts +26 -0
  99. package/dist/components/modal/types.js +1 -0
  100. package/dist/components/popover/popover.css +13 -0
  101. package/dist/components/popover/popover.svelte +73 -0
  102. package/dist/components/popover/popover.svelte.d.ts +4 -0
  103. package/dist/components/popover/types.d.ts +20 -0
  104. package/dist/components/popover/types.js +1 -0
  105. package/dist/components/separator/separator.css +42 -0
  106. package/dist/components/separator/separator.svelte +37 -0
  107. package/dist/components/separator/separator.svelte.d.ts +4 -0
  108. package/dist/components/separator/types.d.ts +15 -0
  109. package/dist/components/separator/types.js +1 -0
  110. package/dist/components/spacer/spacer.css +3 -0
  111. package/dist/components/spacer/spacer.svelte +7 -0
  112. package/dist/components/spacer/spacer.svelte.d.ts +4 -0
  113. package/dist/components/spacer/types.d.ts +4 -0
  114. package/dist/components/spacer/types.js +1 -0
  115. package/dist/components/textfield/textfield.css +298 -0
  116. package/dist/components/textfield/textfield.svelte +193 -0
  117. package/dist/components/textfield/textfield.svelte.d.ts +4 -0
  118. package/dist/components/textfield/types.d.ts +37 -0
  119. package/dist/components/textfield/types.js +1 -0
  120. package/dist/components/toolbar/toolbar.css +106 -0
  121. package/dist/components/toolbar/toolbar.svelte +47 -0
  122. package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
  123. package/dist/components/toolbar/types.d.ts +27 -0
  124. package/dist/components/toolbar/types.js +1 -0
  125. package/dist/components/tooltip/tooltip.css +116 -0
  126. package/dist/components/tooltip/tooltip.svelte +113 -0
  127. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  128. package/dist/components/tooltip/types.d.ts +23 -0
  129. package/dist/components/tooltip/types.js +1 -0
  130. package/dist/entry-bundler.d.ts +12 -0
  131. package/dist/entry-bundler.js +107 -0
  132. package/dist/index.d.ts +3 -1
  133. package/dist/index.js +23 -3
  134. package/dist/internal/config/presets.d.ts +149 -0
  135. package/dist/internal/config/presets.js +169 -0
  136. package/dist/internal/config/variables.d.ts +3 -0
  137. package/dist/internal/config/variables.js +3 -0
  138. package/dist/internal/core/actions/assets.svelte.d.ts +8 -0
  139. package/dist/internal/core/actions/assets.svelte.js +54 -0
  140. package/dist/internal/core/actions/dropdown.svelte.d.ts +7 -0
  141. package/dist/internal/core/actions/dropdown.svelte.js +148 -0
  142. package/dist/internal/core/actions/popover.svelte.d.ts +7 -0
  143. package/dist/internal/core/actions/popover.svelte.js +134 -0
  144. package/dist/internal/core/actions/tooltip.svelte.d.ts +7 -0
  145. package/dist/internal/core/actions/tooltip.svelte.js +131 -0
  146. package/dist/internal/core/animations/ripple.d.ts +12 -0
  147. package/dist/internal/core/animations/ripple.js +93 -0
  148. package/dist/{server/modules → internal/core/bin}/ansi.d.ts +0 -1
  149. package/dist/{server/modules → internal/core/bin}/ansi.js +0 -11
  150. package/dist/internal/core/bin/terminal.d.ts +1 -0
  151. package/dist/internal/core/bin/terminal.js +12 -0
  152. package/dist/internal/core/css.d.ts +1 -0
  153. package/dist/internal/core/css.js +16 -0
  154. package/dist/internal/core/formatter/component.d.ts +5 -0
  155. package/dist/internal/core/formatter/component.js +60 -0
  156. package/dist/internal/core/formatter/device.d.ts +5 -0
  157. package/dist/internal/core/formatter/device.js +66 -0
  158. package/dist/internal/core/formatter/index.d.ts +7 -0
  159. package/dist/internal/core/formatter/index.js +35 -0
  160. package/dist/internal/core/formatter/style.d.ts +4 -0
  161. package/dist/internal/core/formatter/style.js +15 -0
  162. package/dist/internal/core/formatter/theme.d.ts +5 -0
  163. package/dist/internal/core/formatter/theme.js +44 -0
  164. package/dist/internal/core/formatter/typography.d.ts +5 -0
  165. package/dist/internal/core/formatter/typography.js +12 -0
  166. package/dist/internal/core/standard-colors.d.ts +75 -0
  167. package/dist/internal/core/standard-colors.js +75 -0
  168. package/dist/{server/modules/x11.d.ts → internal/core/x11-colors.d.ts} +1 -1
  169. package/dist/internal/helpers/colors.d.ts +1 -0
  170. package/dist/{server/modules → internal/helpers}/colors.js +2 -2
  171. package/dist/internal/helpers/convert.d.ts +1 -0
  172. package/dist/internal/helpers/convert.js +17 -0
  173. package/dist/internal/helpers/deep-merge.d.ts +44 -0
  174. package/dist/internal/helpers/deep-merge.js +80 -0
  175. package/dist/internal/helpers/outside.d.ts +9 -0
  176. package/dist/internal/helpers/outside.js +34 -0
  177. package/dist/internal/helpers/parser.d.ts +10 -0
  178. package/dist/internal/helpers/parser.js +93 -0
  179. package/dist/internal/helpers/scroll.d.ts +1 -0
  180. package/dist/internal/helpers/scroll.js +5 -0
  181. package/dist/internal/plugins/vite.d.ts +8 -0
  182. package/dist/internal/plugins/vite.js +33 -0
  183. package/dist/internal/types/components.d.ts +14 -0
  184. package/dist/internal/types/components.js +1 -0
  185. package/dist/internal/types/configuration.d.ts +63 -0
  186. package/dist/internal/types/configuration.js +1 -0
  187. package/dist/internal/types/index.d.ts +2 -0
  188. package/dist/internal/types/index.js +2 -0
  189. package/dist/labs/components/btn/btn.svelte +13 -0
  190. package/dist/labs/components/btn/btn.svelte.d.ts +5 -0
  191. package/dist/labs/components/index.d.ts +1 -0
  192. package/dist/labs/components/index.js +2 -0
  193. package/dist/stores/breakpoints.d.ts +6 -0
  194. package/dist/stores/breakpoints.js +14 -0
  195. package/dist/stores/components.d.ts +8 -0
  196. package/dist/stores/components.js +26 -0
  197. package/dist/stores/devices.d.ts +6 -0
  198. package/dist/stores/devices.js +9 -0
  199. package/dist/stores/index.d.ts +5 -0
  200. package/dist/stores/index.js +5 -0
  201. package/dist/stores/themes.d.ts +2 -0
  202. package/dist/stores/themes.js +4 -0
  203. package/dist/stores/viewport.d.ts +7 -0
  204. package/dist/stores/viewport.js +7 -0
  205. package/dist/styles/animation.css +33 -0
  206. package/dist/styles/keyframes.css +30 -0
  207. package/dist/styles/{normalize.css → reset.css} +15 -5
  208. package/dist/styles.css.d.ts +4 -0
  209. package/dist/themes.css +0 -0
  210. package/dist/themes.css.d.ts +4 -0
  211. package/package.json +135 -74
  212. package/dist/app.d.ts +0 -13
  213. package/dist/app.html +0 -12
  214. package/dist/server/modules/colors.d.ts +0 -1
  215. package/dist/server/modules/css.d.ts +0 -1
  216. package/dist/server/modules/css.js +0 -144
  217. package/dist/server/modules/devices.d.ts +0 -1
  218. package/dist/server/modules/devices.js +0 -43
  219. package/dist/server/modules/importer.d.ts +0 -1
  220. package/dist/server/modules/importer.js +0 -13
  221. package/dist/server/modules/themes.d.ts +0 -4
  222. package/dist/server/modules/themes.js +0 -94
  223. package/dist/server/vite.d.ts +0 -11
  224. package/dist/server/vite.js +0 -17
  225. package/dist/styles/variables.css +0 -7
  226. /package/dist/{server/modules → internal/core}/minify.d.ts +0 -0
  227. /package/dist/{server/modules → internal/core}/minify.js +0 -0
  228. /package/dist/{server/modules/x11.js → internal/core/x11-colors.js} +0 -0
@@ -0,0 +1,169 @@
1
+ import { variables } from './variables.js';
2
+ import standardColors from '../core/standard-colors.js';
3
+ export const preset = {
4
+ breakpoints: {
5
+ devices: {
6
+ desktop: 1024, //64rem (lg)
7
+ tablet: 768, //48rem (md)
8
+ mobile: 640 //40rem (sm)
9
+ },
10
+ thresholds: {
11
+ base: 0, // 0px
12
+ xs: 448, //28rem
13
+ sm: 640, //40rem
14
+ md: 768, //48rem
15
+ lg: 1024, //64rem
16
+ xl: 1280, //80rem
17
+ '2xl': 1536, //96rem
18
+ '3xl': 1792 //112rem
19
+ }
20
+ },
21
+ theme: {
22
+ defaultTheme: 'light',
23
+ colorScheme: true,
24
+ themes: {
25
+ light: {
26
+ dark: false,
27
+ colors: {
28
+ label: {
29
+ primary: '#000000',
30
+ secondary: standardColors.gray.light,
31
+ tertiary: standardColors.gray2.light,
32
+ quaternary: standardColors.gray3.light
33
+ },
34
+ accent: {
35
+ primary: standardColors.blue.light,
36
+ success: standardColors.green.light,
37
+ warning: standardColors.orange.light,
38
+ destructive: standardColors.red.light,
39
+ info: standardColors.cyan.light
40
+ },
41
+ separator: {
42
+ default: standardColors.gray3.light,
43
+ opaque: standardColors.gray4.light
44
+ },
45
+ state: {
46
+ placeholder: standardColors.gray3.light,
47
+ disabled: standardColors.gray2.light,
48
+ link: standardColors.blue.light,
49
+ highlight: standardColors.gray5.light,
50
+ shadow: '#00000033'
51
+ },
52
+ background: {
53
+ primary: '#FFFFFF',
54
+ secondary: standardColors.gray6.light,
55
+ tertiary: standardColors.gray5.light,
56
+ grouped: {
57
+ primary: standardColors.gray6.light,
58
+ secondary: '#FFFFFF',
59
+ tertiary: standardColors.gray6.light
60
+ }
61
+ }
62
+ },
63
+ variables: variables
64
+ },
65
+ dark: {
66
+ dark: true,
67
+ colors: {
68
+ pink: 'pink',
69
+ label: {
70
+ primary: '#FFFFFF',
71
+ secondary: standardColors.gray2.dark,
72
+ tertiary: standardColors.gray3.dark,
73
+ quaternary: standardColors.gray4.dark
74
+ },
75
+ accent: {
76
+ primary: standardColors.blue.dark,
77
+ success: standardColors.green.dark,
78
+ warning: standardColors.orange.dark,
79
+ destructive: standardColors.red.dark,
80
+ info: standardColors.cyan.dark
81
+ },
82
+ separator: {
83
+ default: standardColors.gray3.dark,
84
+ opaque: standardColors.gray4.dark
85
+ },
86
+ state: {
87
+ placeholder: standardColors.gray3.dark,
88
+ disabled: standardColors.gray4.dark,
89
+ link: standardColors.blue.dark,
90
+ highlight: standardColors.gray5.dark,
91
+ shadow: '#00000066'
92
+ },
93
+ background: {
94
+ primary: '#000000',
95
+ secondary: standardColors.gray6.dark,
96
+ tertiary: standardColors.gray5.dark,
97
+ grouped: {
98
+ primary: standardColors.gray6.dark,
99
+ secondary: standardColors.gray5.dark,
100
+ tertiary: standardColors.gray4.dark
101
+ }
102
+ }
103
+ },
104
+ variables: variables
105
+ }
106
+ }
107
+ },
108
+ typography: {
109
+ defaultTypography: 'default',
110
+ fonts: {
111
+ default: {
112
+ sans: [
113
+ 'system-ui',
114
+ '-apple-system',
115
+ 'BlinkMacSystemFont',
116
+ 'Segoe UI',
117
+ 'Roboto',
118
+ 'Helvetica Neue',
119
+ 'Arial',
120
+ 'sans-serif',
121
+ 'Apple Color Emoji',
122
+ 'Segoe UI Emoji',
123
+ 'Segoe UI Symbol'
124
+ ],
125
+ mono: [
126
+ 'SFMono-Regular',
127
+ 'ui-monospace',
128
+ 'SF Mono',
129
+ 'Menlo',
130
+ 'Monaco',
131
+ 'Consolas',
132
+ 'Liberation Mono',
133
+ 'Courier New',
134
+ 'monospace'
135
+ ],
136
+ serif: ['Merriweather', 'Georgia', 'Cambria', 'Times New Roman', 'Times', 'serif']
137
+ }
138
+ }
139
+ },
140
+ styles: {
141
+ spacing: '0.125rem', // 2px
142
+ shape: {
143
+ sm: '0.125rem', // 2px
144
+ md: '0.25rem', // 4px
145
+ lg: '0.5rem', // 8px
146
+ xl: '0.75rem', // 12px
147
+ '2xl': '1rem', // 16px
148
+ '3xl': '1.5rem', // 24px
149
+ full: '9999px' // 9999px
150
+ },
151
+ dialog: {
152
+ xs: '18.75rem', // 300px
153
+ sm: '25rem', // 400px
154
+ md: '37.5rem', // 600px
155
+ lg: '53.125rem', // 850px
156
+ xl: '75rem' // 1200px
157
+ },
158
+ modal: {
159
+ xs: '18.75rem', // 300px
160
+ sm: '25rem', // 400px
161
+ md: '37.5rem', // 600px
162
+ lg: '53.125rem', // 850px
163
+ xl: '75rem' // 1200px
164
+ },
165
+ animation: {
166
+ 'ripple-duration': '0.4s'
167
+ }
168
+ }
169
+ };
@@ -0,0 +1,3 @@
1
+ export declare const variables: {
2
+ 'test-variable': string;
3
+ };
@@ -0,0 +1,3 @@
1
+ export const variables = {
2
+ 'test-variable': '1rem'
3
+ };
@@ -0,0 +1,8 @@
1
+ export declare function getAssets(): {
2
+ shape(params?: string): string | undefined;
3
+ className(key: string, type: string, value: string | boolean | Array<string> | {
4
+ [key: string]: string;
5
+ }): string | undefined;
6
+ color(color?: string): string | undefined;
7
+ unit(value?: string | number): string | undefined;
8
+ };
@@ -0,0 +1,54 @@
1
+ import { x11ColorNames } from '../x11-colors.js';
2
+ export function getAssets() {
3
+ return {
4
+ shape(params) {
5
+ if (params) {
6
+ if (params === 'none' || params == '0')
7
+ return '0';
8
+ return `var(--system-shape-${params})`;
9
+ }
10
+ },
11
+ className(key, type, value) {
12
+ if (typeof value === 'string')
13
+ return `kit-${key}--${type}-${value}`;
14
+ else if (typeof value === 'boolean' && value)
15
+ return `kit-${key}--${type}`;
16
+ else if (typeof value === 'object') {
17
+ if (Array.isArray(value)) {
18
+ return value
19
+ .map((media) => `${media === 'base' ? '' : `${media}:`}kit--${type}`)
20
+ .join(' ');
21
+ }
22
+ else {
23
+ return Object.entries(value)
24
+ .map(([media, value]) => `${media === 'base' ? '' : `${media}:`}kit-${key}--${type}-${value}`)
25
+ .join(' ');
26
+ }
27
+ }
28
+ },
29
+ color(color) {
30
+ if (color) {
31
+ if (color.includes('#') ||
32
+ color.includes('rgb') ||
33
+ color.includes('rgba') ||
34
+ color.includes('oklch') ||
35
+ x11ColorNames.includes(color.toLowerCase()))
36
+ return color;
37
+ if (color.includes('transparent') || color.includes('inherit') || color.includes('initial'))
38
+ return color;
39
+ return `var(--kit-${color})`;
40
+ }
41
+ },
42
+ unit(value) {
43
+ if (typeof value === 'number')
44
+ return `${value}px`;
45
+ if (typeof value === 'string') {
46
+ const cleaned = value.trim();
47
+ const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
48
+ if (isOnlyNumericLike)
49
+ return `${value}px`;
50
+ }
51
+ return value;
52
+ }
53
+ };
54
+ }
@@ -0,0 +1,7 @@
1
+ import type { PositionElement } from '../../../components/dropdown/types.js';
2
+ type Location = 'top' | 'bottom' | 'left' | 'right';
3
+ export declare function getPositions(): {
4
+ readonly values: PositionElement;
5
+ update(activator: HTMLElement | PointerEvent, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
6
+ };
7
+ export {};
@@ -0,0 +1,148 @@
1
+ import { innerWidth, innerHeight } from 'svelte/reactivity/window';
2
+ export function getPositions() {
3
+ // state
4
+ const axis = $state({
5
+ x: 0,
6
+ y: 0,
7
+ location: null
8
+ });
9
+ return {
10
+ get values() {
11
+ return axis;
12
+ },
13
+ update(activator, element, location, centered, avoidCollisions) {
14
+ if (!activator || !element)
15
+ return;
16
+ const elementRect = element.getBoundingClientRect();
17
+ if (!(activator instanceof HTMLElement)) {
18
+ if (activator.clientX + elementRect.width > innerWidth.current) {
19
+ axis.x = activator.clientX - elementRect.width;
20
+ }
21
+ else {
22
+ axis.x = activator.clientX;
23
+ }
24
+ if (activator.clientY + elementRect.height > innerHeight.current) {
25
+ axis.y = activator.clientY - elementRect.height;
26
+ }
27
+ else {
28
+ axis.y = activator.clientY;
29
+ }
30
+ }
31
+ else if (activator instanceof HTMLElement) {
32
+ const activatorRect = activator.getBoundingClientRect();
33
+ const spacing = 0;
34
+ const _activator = activatorRect.y + activatorRect.height;
35
+ const _element = elementRect.height + spacing;
36
+ if (location === 'top' || location === 'bottom') {
37
+ if (avoidCollisions) {
38
+ if (location === 'top') {
39
+ if (activatorRect.y - _element < 0) {
40
+ axis.y = activatorRect.bottom + spacing;
41
+ axis.location = 'bottom';
42
+ }
43
+ else {
44
+ axis.y = activatorRect.top - _element;
45
+ axis.location = 'top';
46
+ }
47
+ }
48
+ else {
49
+ if (_activator + _element > innerHeight.current) {
50
+ axis.y = activatorRect.top - _element;
51
+ axis.location = 'top';
52
+ }
53
+ else {
54
+ axis.y = activatorRect.bottom + spacing;
55
+ axis.location = 'bottom';
56
+ }
57
+ }
58
+ }
59
+ else {
60
+ if (location === 'top') {
61
+ axis.y = activatorRect.top - _element;
62
+ axis.location = 'top';
63
+ }
64
+ else {
65
+ axis.y = activatorRect.bottom + spacing;
66
+ axis.location = 'bottom';
67
+ }
68
+ }
69
+ if (centered &&
70
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
71
+ activatorRect.left + elementRect.width < innerWidth.current) {
72
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
73
+ }
74
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
75
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
76
+ }
77
+ else {
78
+ axis.x = activatorRect.left;
79
+ }
80
+ }
81
+ else if (location === 'left' || location === 'right') {
82
+ if (avoidCollisions) {
83
+ if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
84
+ axis.x = activatorRect.left - (elementRect.width + spacing);
85
+ axis.location = 'left';
86
+ }
87
+ else {
88
+ if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
89
+ innerWidth.current) {
90
+ axis.x = activatorRect.left - (elementRect.width + spacing);
91
+ axis.location = 'left';
92
+ }
93
+ else {
94
+ axis.x = activatorRect.left + activatorRect.width + spacing;
95
+ axis.location = 'right';
96
+ }
97
+ }
98
+ }
99
+ else {
100
+ if (location === 'left') {
101
+ axis.x = activatorRect.left - (elementRect.width + spacing);
102
+ axis.location = 'left';
103
+ }
104
+ else {
105
+ axis.x = activatorRect.left + activatorRect.width + spacing;
106
+ axis.location = 'right';
107
+ }
108
+ }
109
+ if (centered &&
110
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
111
+ activatorRect.top + elementRect.height < innerHeight.current) {
112
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
113
+ }
114
+ else if (activatorRect.y + elementRect.height > innerHeight.current) {
115
+ axis.y = activatorRect.y - elementRect.height + activatorRect.height;
116
+ }
117
+ else {
118
+ axis.y = activatorRect.y;
119
+ }
120
+ }
121
+ else {
122
+ if (centered &&
123
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
124
+ activatorRect.left + elementRect.width < innerWidth.current) {
125
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
126
+ }
127
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
128
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
129
+ }
130
+ else {
131
+ axis.x = activatorRect.left;
132
+ }
133
+ if (centered &&
134
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
135
+ activatorRect.top + elementRect.height < innerHeight.current) {
136
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
137
+ }
138
+ else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
139
+ axis.y = activatorRect.top - elementRect.height;
140
+ }
141
+ else {
142
+ axis.y = activatorRect.bottom;
143
+ }
144
+ }
145
+ }
146
+ }
147
+ };
148
+ }
@@ -0,0 +1,7 @@
1
+ import type { PositionElement } from '../../../components/popover/types.js';
2
+ type Location = 'top' | 'bottom' | 'left' | 'right';
3
+ export declare function getPositions(): {
4
+ readonly values: PositionElement;
5
+ update(activator: HTMLElement, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
6
+ };
7
+ export {};
@@ -0,0 +1,134 @@
1
+ import { innerWidth, innerHeight } from 'svelte/reactivity/window';
2
+ export function getPositions() {
3
+ // state
4
+ const axis = $state({
5
+ x: 0,
6
+ y: 0,
7
+ location: null
8
+ });
9
+ return {
10
+ get values() {
11
+ return axis;
12
+ },
13
+ update(activator, element, location, centered, avoidCollisions) {
14
+ if (!activator || !element)
15
+ return;
16
+ const elementRect = element.getBoundingClientRect();
17
+ if (activator instanceof HTMLElement) {
18
+ const activatorRect = activator.getBoundingClientRect();
19
+ const spacing = 6;
20
+ const _activator = activatorRect.y + activatorRect.height;
21
+ const _element = elementRect.height + spacing;
22
+ if (location === 'top' || location === 'bottom') {
23
+ if (avoidCollisions) {
24
+ if (location === 'top') {
25
+ if (activatorRect.y - _element < 0) {
26
+ axis.y = activatorRect.bottom + spacing;
27
+ axis.location = 'bottom';
28
+ }
29
+ else {
30
+ axis.y = activatorRect.top - _element;
31
+ axis.location = 'top';
32
+ }
33
+ }
34
+ else {
35
+ if (_activator + _element > innerHeight.current) {
36
+ axis.y = activatorRect.top - _element;
37
+ axis.location = 'top';
38
+ }
39
+ else {
40
+ axis.y = activatorRect.bottom + spacing;
41
+ axis.location = 'bottom';
42
+ }
43
+ }
44
+ }
45
+ else {
46
+ if (location === 'top') {
47
+ axis.y = activatorRect.top - _element;
48
+ axis.location = 'top';
49
+ }
50
+ else {
51
+ axis.y = activatorRect.bottom + spacing;
52
+ axis.location = 'bottom';
53
+ }
54
+ }
55
+ if (centered &&
56
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
57
+ activatorRect.left + elementRect.width < innerWidth.current) {
58
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
59
+ }
60
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
61
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
62
+ }
63
+ else {
64
+ axis.x = activatorRect.left;
65
+ }
66
+ }
67
+ else if (location === 'left' || location === 'right') {
68
+ if (avoidCollisions) {
69
+ if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
70
+ axis.x = activatorRect.left - (elementRect.width + spacing);
71
+ axis.location = 'left';
72
+ }
73
+ else {
74
+ if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
75
+ innerWidth.current) {
76
+ axis.x = activatorRect.left - (elementRect.width + spacing);
77
+ axis.location = 'left';
78
+ }
79
+ else {
80
+ axis.x = activatorRect.left + activatorRect.width + spacing;
81
+ axis.location = 'right';
82
+ }
83
+ }
84
+ }
85
+ else {
86
+ if (location === 'left') {
87
+ axis.x = activatorRect.left - (elementRect.width + spacing);
88
+ axis.location = 'left';
89
+ }
90
+ else {
91
+ axis.x = activatorRect.left + activatorRect.width + spacing;
92
+ axis.location = 'right';
93
+ }
94
+ }
95
+ if (centered &&
96
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
97
+ activatorRect.top + elementRect.height < innerHeight.current) {
98
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
99
+ }
100
+ else if (activatorRect.y + elementRect.height > innerHeight.current) {
101
+ axis.y = activatorRect.y - elementRect.height + activatorRect.height;
102
+ }
103
+ else {
104
+ axis.y = activatorRect.y;
105
+ }
106
+ }
107
+ else {
108
+ if (centered &&
109
+ activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
110
+ activatorRect.left + elementRect.width < innerWidth.current) {
111
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
112
+ }
113
+ else if (activatorRect.left + elementRect.width > innerWidth.current) {
114
+ axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
115
+ }
116
+ else {
117
+ axis.x = activatorRect.left;
118
+ }
119
+ if (centered &&
120
+ activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
121
+ activatorRect.top + elementRect.height < innerHeight.current) {
122
+ axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
123
+ }
124
+ else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
125
+ axis.y = activatorRect.top - elementRect.height;
126
+ }
127
+ else {
128
+ axis.y = activatorRect.bottom;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ };
134
+ }
@@ -0,0 +1,7 @@
1
+ import type { PositionElement } from '../../../components/tooltip/types.js';
2
+ type Location = 'top' | 'bottom' | 'left' | 'right';
3
+ export declare function getPositionsTooltip(): {
4
+ readonly values: PositionElement;
5
+ update(activator: HTMLElement, element: HTMLElement, location?: Location, centered?: boolean, avoidCollisions?: boolean): void;
6
+ };
7
+ export {};