lapikit 0.4.11 → 0.4.13

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 (42) hide show
  1. package/dist/labs/compiler/components.js +14 -0
  2. package/dist/labs/components/appbar/appbar.svelte +196 -0
  3. package/dist/labs/components/appbar/appbar.svelte.d.ts +4 -0
  4. package/dist/labs/components/appbar/appbar.types.d.ts +16 -0
  5. package/dist/labs/components/appbar/appbar.types.js +1 -0
  6. package/dist/labs/components/dropdown/dropdown.svelte +249 -0
  7. package/dist/labs/components/dropdown/dropdown.svelte.d.ts +4 -0
  8. package/dist/labs/components/dropdown/dropdown.svelte.js +148 -0
  9. package/dist/labs/components/dropdown/dropdown.types.d.ts +28 -0
  10. package/dist/labs/components/dropdown/dropdown.types.js +1 -0
  11. package/dist/labs/components/index.d.ts +8 -0
  12. package/dist/labs/components/index.js +8 -0
  13. package/dist/labs/components/list/list.svelte +190 -0
  14. package/dist/labs/components/list/list.svelte.d.ts +4 -0
  15. package/dist/labs/components/list/list.types.d.ts +30 -0
  16. package/dist/labs/components/list/list.types.js +1 -0
  17. package/dist/labs/components/list/modules/list-item.svelte +195 -0
  18. package/dist/labs/components/list/modules/list-item.svelte.d.ts +4 -0
  19. package/dist/labs/components/popover/popover.svelte +188 -0
  20. package/dist/labs/components/popover/popover.svelte.d.ts +4 -0
  21. package/dist/labs/components/popover/popover.svelte.js +134 -0
  22. package/dist/labs/components/popover/popover.types.d.ts +22 -0
  23. package/dist/labs/components/popover/popover.types.js +1 -0
  24. package/dist/labs/components/textfield/textfield.svelte +587 -0
  25. package/dist/labs/components/textfield/textfield.svelte.d.ts +4 -0
  26. package/dist/labs/components/textfield/textfield.types.d.ts +41 -0
  27. package/dist/labs/components/textfield/textfield.types.js +1 -0
  28. package/dist/labs/components/toolbar/toolbar.svelte +262 -0
  29. package/dist/labs/components/toolbar/toolbar.svelte.d.ts +4 -0
  30. package/dist/labs/components/toolbar/toolbar.types.d.ts +21 -0
  31. package/dist/labs/components/toolbar/toolbar.types.js +1 -0
  32. package/dist/labs/components/tooltip/tooltip.svelte +372 -0
  33. package/dist/labs/components/tooltip/tooltip.svelte.d.ts +4 -0
  34. package/dist/labs/components/tooltip/tooltip.svelte.js +131 -0
  35. package/dist/labs/components/tooltip/tooltip.types.d.ts +26 -0
  36. package/dist/labs/components/tooltip/tooltip.types.js +1 -0
  37. package/dist/labs/utils/index.d.ts +1 -0
  38. package/dist/labs/utils/index.js +1 -0
  39. package/dist/labs/utils/outside.d.ts +5 -0
  40. package/dist/labs/utils/outside.js +34 -0
  41. package/dist/labs/utils/types/index.d.ts +4 -0
  42. package/package.json +1 -1
@@ -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,22 @@
1
+ import type { Component, PropValue, RoundedType } from '../../utils/types/index.js';
2
+ import type { Snippet } from 'svelte';
3
+ export type PositionElement = {
4
+ x: number;
5
+ y: number;
6
+ location: 'top' | 'bottom' | 'left' | 'right' | null;
7
+ };
8
+ export type ModelPopoverProps = {
9
+ toggle: (element: HTMLElement | null) => void;
10
+ };
11
+ export interface PopoverProps extends Component {
12
+ ref?: HTMLElement | null;
13
+ open?: boolean;
14
+ dark?: boolean;
15
+ light?: boolean;
16
+ rounded?: RoundedType | string;
17
+ position?: 'top' | 'bottom' | 'left' | 'right';
18
+ color?: string;
19
+ background?: string;
20
+ activator?: Snippet<[ModelPopoverProps]>;
21
+ [key: string]: PropValue | Record<string, PropValue> | unknown;
22
+ }
@@ -0,0 +1 @@
1
+ export {};