lapikit 0.0.0-insiders.13c16e2

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 (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/bin/helper.js +74 -0
  4. package/bin/lapikit.js +54 -0
  5. package/bin/modules/adapter.js +52 -0
  6. package/bin/modules/preset.js +11 -0
  7. package/dist/app.d.ts +13 -0
  8. package/dist/app.html +12 -0
  9. package/dist/assets/icons/loading-fill.svelte +29 -0
  10. package/dist/assets/icons/loading-fill.svelte.d.ts +26 -0
  11. package/dist/components/app/app.css +16 -0
  12. package/dist/components/app/app.svelte +23 -0
  13. package/dist/components/app/app.svelte.d.ts +7 -0
  14. package/dist/components/app/types.d.ts +4 -0
  15. package/dist/components/app/types.js +1 -0
  16. package/dist/components/button/button.css +276 -0
  17. package/dist/components/button/button.svelte +94 -0
  18. package/dist/components/button/button.svelte.d.ts +4 -0
  19. package/dist/components/button/types.d.ts +27 -0
  20. package/dist/components/button/types.js +1 -0
  21. package/dist/components/dialog/dialog.css +134 -0
  22. package/dist/components/dialog/dialog.svelte +67 -0
  23. package/dist/components/dialog/dialog.svelte.d.ts +4 -0
  24. package/dist/components/dialog/types.d.ts +21 -0
  25. package/dist/components/dialog/types.js +1 -0
  26. package/dist/components/dropdown/dropdown.css +22 -0
  27. package/dist/components/dropdown/dropdown.svelte +116 -0
  28. package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
  29. package/dist/components/dropdown/dropdown.svelte.js +148 -0
  30. package/dist/components/dropdown/types.d.ts +26 -0
  31. package/dist/components/dropdown/types.js +1 -0
  32. package/dist/components/icon/icon.css +76 -0
  33. package/dist/components/icon/icon.svelte +49 -0
  34. package/dist/components/icon/icon.svelte.d.ts +4 -0
  35. package/dist/components/icon/types.d.ts +16 -0
  36. package/dist/components/icon/types.js +1 -0
  37. package/dist/components/index.d.ts +9 -0
  38. package/dist/components/index.js +10 -0
  39. package/dist/components/modal/modal.css +95 -0
  40. package/dist/components/modal/modal.svelte +87 -0
  41. package/dist/components/modal/modal.svelte.d.ts +4 -0
  42. package/dist/components/modal/types.d.ts +21 -0
  43. package/dist/components/modal/types.js +1 -0
  44. package/dist/components/popover/popover.css +22 -0
  45. package/dist/components/popover/popover.svelte +73 -0
  46. package/dist/components/popover/popover.svelte.d.ts +4 -0
  47. package/dist/components/popover/popover.svelte.js +134 -0
  48. package/dist/components/popover/types.d.ts +20 -0
  49. package/dist/components/popover/types.js +1 -0
  50. package/dist/components/separator/separator.css +46 -0
  51. package/dist/components/separator/separator.svelte +37 -0
  52. package/dist/components/separator/separator.svelte.d.ts +4 -0
  53. package/dist/components/separator/types.d.ts +11 -0
  54. package/dist/components/separator/types.js +1 -0
  55. package/dist/components/tooltip/tooltip.css +124 -0
  56. package/dist/components/tooltip/tooltip.svelte +113 -0
  57. package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
  58. package/dist/components/tooltip/tooltip.svelte.js +131 -0
  59. package/dist/components/tooltip/types.d.ts +23 -0
  60. package/dist/components/tooltip/types.js +1 -0
  61. package/dist/index.d.ts +1 -0
  62. package/dist/index.js +4 -0
  63. package/dist/internal/ansi.d.ts +40 -0
  64. package/dist/internal/ansi.js +44 -0
  65. package/dist/internal/assets.svelte.d.ts +8 -0
  66. package/dist/internal/assets.svelte.js +52 -0
  67. package/dist/internal/clickOutside.d.ts +9 -0
  68. package/dist/internal/clickOutside.js +34 -0
  69. package/dist/internal/colors.d.ts +1 -0
  70. package/dist/internal/colors.js +50 -0
  71. package/dist/internal/index.d.ts +4 -0
  72. package/dist/internal/index.js +4 -0
  73. package/dist/internal/minify.d.ts +1 -0
  74. package/dist/internal/minify.js +10 -0
  75. package/dist/internal/scroll.d.ts +1 -0
  76. package/dist/internal/scroll.js +6 -0
  77. package/dist/internal/terminal.d.ts +1 -0
  78. package/dist/internal/terminal.js +12 -0
  79. package/dist/internal/types.d.ts +57 -0
  80. package/dist/internal/types.js +1 -0
  81. package/dist/plugin/modules/config.d.ts +2 -0
  82. package/dist/plugin/modules/config.js +54 -0
  83. package/dist/plugin/modules/importer.d.ts +1 -0
  84. package/dist/plugin/modules/importer.js +15 -0
  85. package/dist/plugin/vitejs.d.ts +6 -0
  86. package/dist/plugin/vitejs.js +26 -0
  87. package/dist/preset.d.ts +2 -0
  88. package/dist/preset.js +92 -0
  89. package/dist/stores/index.d.ts +6 -0
  90. package/dist/stores/index.js +28 -0
  91. package/dist/style/animation.css +20 -0
  92. package/dist/style/css.d.ts +2 -0
  93. package/dist/style/css.js +34 -0
  94. package/dist/style/normalize.css +123 -0
  95. package/dist/style/parser/color.d.ts +5 -0
  96. package/dist/style/parser/color.js +88 -0
  97. package/dist/style/parser/component.d.ts +2 -0
  98. package/dist/style/parser/component.js +115 -0
  99. package/dist/style/parser/device.d.ts +2 -0
  100. package/dist/style/parser/device.js +28 -0
  101. package/dist/style/parser/index.d.ts +4 -0
  102. package/dist/style/parser/index.js +4 -0
  103. package/dist/style/parser/variable.d.ts +2 -0
  104. package/dist/style/parser/variable.js +25 -0
  105. package/dist/style/variable.css +12 -0
  106. package/dist/styles.css +0 -0
  107. package/dist/utils/x11.d.ts +4 -0
  108. package/dist/utils/x11.js +151 -0
  109. package/package.json +89 -0
@@ -0,0 +1,76 @@
1
+ .kit-icon {
2
+ --icon-size: 1rem;
3
+ --icon-color: var(--base, var(--kit-on-neutral));
4
+
5
+ display: inline-flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ transition: color 0.5s;
9
+ text-indent: 0;
10
+ }
11
+
12
+ .kit-icon:before {
13
+ font-size: calc(var(--icon-size-multiplier) * var(--icon-size));
14
+ color: var(--icon-color);
15
+ }
16
+
17
+ .kit-icon svg {
18
+ color: var(--icon-color);
19
+ }
20
+
21
+ .kit-icon svg,
22
+ .kit-icon img {
23
+ width: calc(var(--icon-size-multiplier) * var(--icon-size));
24
+ height: calc(var(--icon-size-multiplier) * var(--icon-size));
25
+ }
26
+
27
+ /* size */
28
+ .kit-icon[breakpoint]kit-icon--size-xs {
29
+ --icon-size-multiplier: 0.875;
30
+ }
31
+
32
+ .kit-icon[breakpoint]kit-icon--size-sm {
33
+ --icon-size-multiplier: 1;
34
+ }
35
+
36
+ .kit-icon[breakpoint]kit-icon--size-md {
37
+ --icon-size-multiplier: 1.125;
38
+ }
39
+
40
+ .kit-icon[breakpoint]kit-icon--size-lg {
41
+ --icon-size-multiplier: 1.25;
42
+ }
43
+
44
+ .kit-icon[breakpoint]kit-icon--size-xl {
45
+ --icon-size-multiplier: 1.5;
46
+ }
47
+
48
+ /* state */
49
+ .kit-icon.kit-icon--info {
50
+ --base: var(--kit-info);
51
+ }
52
+ .kit-icon.kit-icon--success {
53
+ --base: var(--kit-success);
54
+ }
55
+ .kit-icon.kit-icon--warning {
56
+ --base: var(--kit-warning);
57
+ }
58
+ .kit-icon.kit-icon--error {
59
+ --base: var(--kit-error);
60
+ }
61
+
62
+ /* disabled */
63
+ .kit-icon.kit-icon--disabled {
64
+ -webkit-user-select: none;
65
+ user-select: none;
66
+ pointer-events: none;
67
+ }
68
+
69
+ .kit-icon.kit-icon--disabled img {
70
+ opacity: 0.38;
71
+ }
72
+
73
+ .kit-icon.kit-icon--disabled svg,
74
+ .kit-icon.kit-icon--disabled:before {
75
+ color: color-mix(in oklab, var(--icon-color) 40%, transparent) !important;
76
+ }
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/assets.svelte.js';
3
+ import type { IconProps } from './types.js';
4
+ let {
5
+ children,
6
+ ref = $bindable(),
7
+ is = 'i',
8
+ light,
9
+ dark,
10
+ icon,
11
+ size = 'md',
12
+ error,
13
+ info,
14
+ success,
15
+ warning,
16
+ disabled,
17
+ alt,
18
+ color,
19
+ ...rest
20
+ }: IconProps = $props();
21
+
22
+ const assets = getAssets();
23
+ </script>
24
+
25
+ <svelte:element
26
+ this={icon && icon.includes('/') ? 'div' : is}
27
+ bind:this={ref}
28
+ {...rest}
29
+ class={[
30
+ 'kit-icon',
31
+ icon && !icon.includes('/') && icon,
32
+ light && 'light',
33
+ dark && 'dark',
34
+ info && 'kit-icon--info',
35
+ success && 'kit-icon--success',
36
+ warning && 'kit-icon--warning',
37
+ error && 'kit-icon--error',
38
+ disabled && 'kit-icon--disabled',
39
+ size && assets.className('icon', 'size', size),
40
+ rest.class
41
+ ]}
42
+ style:--base={assets.color(color)}
43
+ >
44
+ {#if icon && icon.includes('/')}
45
+ <img src={icon} {alt} />
46
+ {:else}
47
+ {@render children?.()}
48
+ {/if}
49
+ </svelte:element>
@@ -0,0 +1,4 @@
1
+ import type { IconProps } from './types.js';
2
+ declare const Icon: import("svelte").Component<IconProps, {}, "ref">;
3
+ type Icon = ReturnType<typeof Icon>;
4
+ export default Icon;
@@ -0,0 +1,16 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ export interface IconProps extends Component {
3
+ ref?: HTMLElement | null;
4
+ is?: 'i' | 'div';
5
+ dark?: boolean;
6
+ light?: boolean;
7
+ error?: boolean;
8
+ info?: boolean;
9
+ warning?: boolean;
10
+ success?: boolean;
11
+ disabled?: boolean;
12
+ color?: string;
13
+ size?: string | {
14
+ [key: string]: string;
15
+ };
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export { default as App } from './app/app.svelte';
2
+ export { default as Btn } from './button/button.svelte';
3
+ export { default as Icon } from './icon/icon.svelte';
4
+ export { default as Dropdown } from './dropdown/dropdown.svelte';
5
+ export { default as Popover } from './popover/popover.svelte';
6
+ export { default as Tooltip } from './tooltip/tooltip.svelte';
7
+ export { default as Dialog } from './dialog/dialog.svelte';
8
+ export { default as Separator } from './separator/separator.svelte';
9
+ export { default as Modal } from './modal/modal.svelte';
@@ -0,0 +1,10 @@
1
+ // components
2
+ export { default as App } from './app/app.svelte';
3
+ export { default as Btn } from './button/button.svelte';
4
+ export { default as Icon } from './icon/icon.svelte';
5
+ export { default as Dropdown } from './dropdown/dropdown.svelte';
6
+ export { default as Popover } from './popover/popover.svelte';
7
+ export { default as Tooltip } from './tooltip/tooltip.svelte';
8
+ export { default as Dialog } from './dialog/dialog.svelte';
9
+ export { default as Separator } from './separator/separator.svelte';
10
+ export { default as Modal } from './modal/modal.svelte';
@@ -0,0 +1,95 @@
1
+ .kit-modal {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+
6
+ /* .kit-modal:not(.kit-modal--contain) .kit-modal-overlay {
7
+ top: 0;
8
+ left: 0;
9
+ } */
10
+
11
+ /* .kit-modal-overlay {
12
+ background-color: var(--kit-shadow);
13
+ position: fixed;
14
+ } */
15
+
16
+ .kit-modal-container {
17
+ --modal-color: var(--on, var(--kit-on-neutral));
18
+ --modal-background: var(--base, var(--kit-neutral));
19
+ --modal-radius: var(--shape, var(--kit-radius-md));
20
+ --modal-translate-x: -50%;
21
+ --modal-translate-y: -50%;
22
+
23
+ position: fixed;
24
+
25
+ z-index: 9100;
26
+ width: 100%;
27
+ height: 100%;
28
+
29
+ /* theme */
30
+ color: var(--modal-color);
31
+ background-color: var(--modal-background);
32
+ border-color: var(--modal-background);
33
+ }
34
+
35
+ /* size */
36
+ .kit-modal [breakpoint]kit-modal-container--size-xs {
37
+ max-width: var(--kit-modal-size-xs);
38
+ max-height: calc(100% - 3rem);
39
+ height: fit-content;
40
+ margin: 0 auto;
41
+ top: 50%;
42
+ left: 50%;
43
+ bottom: initial;
44
+ translate: var(--modal-translate-x) var(--modal-translate-y);
45
+ }
46
+ .kit-modal [breakpoint]kit-modal-container--size-sm {
47
+ max-width: var(--kit-modal-size-sm);
48
+ max-height: calc(100% - 3rem);
49
+ height: fit-content;
50
+ margin: 0 auto;
51
+ top: 50%;
52
+ left: 50%;
53
+ bottom: initial;
54
+ translate: var(--modal-translate-x) var(--modal-translate-y);
55
+ }
56
+ .kit-modal [breakpoint]kit-modal-container--size-md {
57
+ max-width: var(--kit-modal-size-md);
58
+ max-height: calc(100% - 3rem);
59
+ height: fit-content;
60
+ margin: 0 auto;
61
+ top: 50%;
62
+ left: 50%;
63
+ bottom: initial;
64
+ translate: var(--modal-translate-x) var(--modal-translate-y);
65
+ }
66
+ .kit-modal [breakpoint]kit-modal-container--size-lg {
67
+ max-width: var(--kit-modal-size-lg);
68
+ max-height: calc(100% - 3rem);
69
+ height: fit-content;
70
+ margin: 0 auto;
71
+ top: 50%;
72
+ left: 50%;
73
+ bottom: initial;
74
+ translate: var(--modal-translate-x) var(--modal-translate-y);
75
+ }
76
+ .kit-modal [breakpoint]kit-modal-container--size-xl {
77
+ max-width: var(--kit-modal-size-xl);
78
+ max-height: calc(100% - 3rem);
79
+ height: fit-content;
80
+ margin: 0 auto;
81
+ top: 50%;
82
+ left: 50%;
83
+ bottom: initial;
84
+ translate: var(--modal-translate-x) var(--modal-translate-y);
85
+ }
86
+ .kit-modal [breakpoint]kit-modal-container--size-full {
87
+ max-width: 100%;
88
+ max-height: calc(100% - 3rem);
89
+ margin: 0 auto;
90
+ bottom: 0;
91
+ translate: 0 0;
92
+ left: 0;
93
+ top: initial;
94
+ height: 100%;
95
+ }
@@ -0,0 +1,87 @@
1
+ <script lang="ts">
2
+ // import { disabledScroll } from '../../internal/index.js';
3
+ import { getAssets } from '../../internal/index.js';
4
+ import { modalOpen, setOpenModal } from '../../stores/index.js';
5
+ import type { ModalProps } from './types.js';
6
+
7
+ let {
8
+ children,
9
+ ref = $bindable(),
10
+ open = $bindable(),
11
+ contain,
12
+ size,
13
+ persistent,
14
+ dark,
15
+ light,
16
+ // classContent,
17
+ // color,
18
+ // background,
19
+ // size = 'md',
20
+ // persistent,
21
+ // position = 'center',
22
+ // rounded,
23
+ // density = 'default',
24
+ ...rest
25
+ }: ModalProps = $props();
26
+
27
+ const assets = getAssets();
28
+
29
+ // $effect(() => {
30
+ // if (ref && open) ref.showModal();
31
+ // if (ref && !open) ref.close();
32
+ // disabledScroll(open ? true : false);
33
+ // });
34
+
35
+ $effect(() => {
36
+ if (open !== undefined && !contain)
37
+ setOpenModal(open ? (persistent ? 'persistent' : open) : open);
38
+ });
39
+
40
+ $effect(() => {
41
+ if ($modalOpen === false && !contain) open = false;
42
+ });
43
+ </script>
44
+
45
+ {#if open}
46
+ <div class={['kit-modal', contain && 'kit-modal--contain', rest.class]}>
47
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
48
+ {#if contain}
49
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
50
+ <div
51
+ class={['kit-overlay', persistent && 'kit-overlay--persistent']}
52
+ onclick={() => (open = false)}
53
+ ></div>
54
+ {/if}
55
+
56
+ <div
57
+ class={[
58
+ 'kit-modal-container',
59
+ light && 'light',
60
+ dark && 'dark',
61
+ size && assets.className('modal-container', 'size', size)
62
+ ]}
63
+ role="dialog"
64
+ >
65
+ {@render children?.()}
66
+ </div>
67
+ <!-- surcharge-dialog autofocus-action-element -->
68
+ <!-- <button type="button" class="close-dialog">close</button>
69
+ <div
70
+ {...rest}
71
+ class={[
72
+ 'kit-modal-container',
73
+ light && 'light',
74
+ dark && 'dark',
75
+ classContent,
76
+ density && assets.className('dialog-container', 'density', density),
77
+ rest.class
78
+ ]}
79
+ onclick={(event: MouseEvent) => event.stopPropagation()}
80
+ style:--base={assets.color(background)}
81
+ style:--on={assets.color(color)}
82
+ style:--shape={assets.shape(rounded)}
83
+ >
84
+ {@render children?.()}
85
+ </div> -->
86
+ </div>
87
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { ModalProps } from './types.js';
2
+ declare const Modal: import("svelte").Component<ModalProps, {}, "ref" | "open">;
3
+ type Modal = ReturnType<typeof Modal>;
4
+ export default Modal;
@@ -0,0 +1,21 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ type ModalSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
3
+ type ModalPosition = 'bottom' | 'center' | 'top';
4
+ export interface ModalProps extends Component {
5
+ ref?: HTMLDivElement;
6
+ open?: boolean;
7
+ classContent?: string | string[] | undefined;
8
+ size?: ModalSize | {
9
+ [key: string]: ModalSize;
10
+ };
11
+ persistent?: boolean;
12
+ position?: ModalPosition | {
13
+ [key: string]: ModalPosition;
14
+ };
15
+ dark?: boolean;
16
+ light?: boolean;
17
+ color?: string;
18
+ background?: string;
19
+ density?: 'compact' | 'comfortable' | 'default';
20
+ }
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ .kit-popover-content {
2
+ --popover-color: var(--on, var(--kit-on-neutral));
3
+ --popover-background: var(--base, var(--kit-neutral));
4
+ --popover-radius: var(--shape, var(--kit-radius-md));
5
+
6
+ inset: 0px auto auto 0px;
7
+ margin: 0px;
8
+ position: fixed;
9
+ z-index: 9999;
10
+ display: inline-block;
11
+ width: auto;
12
+ opacity: 1;
13
+ transition-property: opacity, transform;
14
+ transition:
15
+ color 0.5s,
16
+ background-color 0.5s;
17
+
18
+ /* theme */
19
+ background-color: var(--popover-background);
20
+ color: var(--popover-color);
21
+ border-radius: var(--popover-radius);
22
+ }
@@ -0,0 +1,73 @@
1
+ <script lang="ts">
2
+ import { getAssets } from '../../internal/assets.svelte.js';
3
+ import { clickOutside } from '../../internal/clickOutside.js';
4
+ import { getPositions } from './popover.svelte.js';
5
+ import type { PopoverProps, ModelPopoverProps } from './types.js';
6
+
7
+ let {
8
+ open = $bindable(),
9
+ children,
10
+ activator,
11
+ dark,
12
+ light,
13
+ rounded,
14
+ position,
15
+ color,
16
+ background,
17
+ ...rest
18
+ }: PopoverProps = $props();
19
+
20
+ const positionAxis = getPositions();
21
+ const assets = getAssets();
22
+
23
+ let ref: HTMLElement | null = $state(null);
24
+ let refActivator: HTMLElement | null = $state(null);
25
+ let axis = $state({ x: 0, y: 0 });
26
+ let innerHeight = $state(0);
27
+ let innerWidth = $state(0);
28
+ let scrollX = $state(0);
29
+ let scrollY = $state(0);
30
+
31
+ axis = positionAxis?.values;
32
+
33
+ let model: ModelPopoverProps = {
34
+ toggle: (element) => handleToggle(element)
35
+ };
36
+
37
+ const handleToggle = (element: HTMLElement | null) => {
38
+ if (element === null) return;
39
+ refActivator = element;
40
+ open = !open;
41
+ };
42
+
43
+ $effect(() => {
44
+ if (
45
+ open &&
46
+ ref &&
47
+ refActivator &&
48
+ (scrollX > 0 || scrollY > 0 || innerHeight > 0 || innerWidth > 0)
49
+ ) {
50
+ positionAxis.update(refActivator, ref, position);
51
+ }
52
+ });
53
+ </script>
54
+
55
+ <svelte:window bind:innerHeight bind:innerWidth bind:scrollX bind:scrollY />
56
+
57
+ {@render activator?.(model)}
58
+
59
+ {#if open}
60
+ <div
61
+ bind:this={ref}
62
+ {...rest}
63
+ role="menu"
64
+ class={['kit-popover-content', light && 'light', dark && 'dark', rest.class]}
65
+ style={`transform: translate(${axis.x}px, ${axis.y}px);`}
66
+ style:--base={assets.color(background)}
67
+ style:--on={assets.color(color)}
68
+ style:--shape={assets.shape(rounded)}
69
+ use:clickOutside={{ exclude: [ref, refActivator], onClose: () => (open = false) }}
70
+ >
71
+ {@render children?.()}
72
+ </div>
73
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { PopoverProps } from './types.js';
2
+ declare const Popover: import("svelte").Component<PopoverProps, {}, "open">;
3
+ type Popover = ReturnType<typeof Popover>;
4
+ export default Popover;
@@ -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,20 @@
1
+ import type { Component } from '../../internal/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ export type PositionElement = {
4
+ x: number;
5
+ y: number;
6
+ location: string | null;
7
+ };
8
+ export interface PopoverProps extends Component {
9
+ open?: boolean;
10
+ dark?: boolean;
11
+ light?: boolean;
12
+ rounded?: string;
13
+ position?: 'top' | 'bottom' | 'left' | 'right';
14
+ color?: string;
15
+ background?: string;
16
+ activator?: Snippet<[ModelPopoverProps]>;
17
+ }
18
+ export type ModelPopoverProps = {
19
+ toggle: (element: HTMLElement | null) => void;
20
+ };
@@ -0,0 +1 @@
1
+ export {};