lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.df15d32
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.
- package/LICENSE +21 -0
- package/bin/configuration.js +304 -0
- package/bin/helper.js +64 -32
- package/bin/index.js +41 -0
- package/bin/lapikit.js +42 -10
- package/bin/legacy.js +34 -0
- package/bin/modules/adapter.js +5 -5
- package/bin/modules/plugin.js +223 -0
- package/bin/presets.js +26 -0
- package/bin/prompts.js +100 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/assets/icons/arrow-down.svelte +12 -0
- package/dist/assets/icons/arrow-down.svelte.d.ts +18 -0
- package/dist/assets/icons/arrow-up.svelte +12 -0
- package/dist/assets/icons/arrow-up.svelte.d.ts +18 -0
- package/dist/assets/icons/close-fill.svelte +12 -0
- package/dist/assets/icons/close-fill.svelte.d.ts +18 -0
- package/dist/assets/icons/loading-fill.svelte +31 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +18 -0
- package/dist/colors.css +0 -0
- package/dist/components/accordion/accordion.css +113 -0
- package/dist/components/accordion/accordion.svelte +37 -0
- package/dist/components/accordion/accordion.svelte.d.ts +4 -0
- package/dist/components/accordion/accordion.svelte.js +24 -0
- package/dist/components/accordion/modules/accordion-item.svelte +94 -0
- package/dist/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
- package/dist/components/accordion/types.d.ts +33 -0
- package/dist/components/accordion/types.js +1 -0
- package/dist/components/alert/alert.css +137 -0
- package/dist/components/alert/alert.svelte +89 -0
- package/dist/components/alert/alert.svelte.d.ts +4 -0
- package/dist/components/alert/types.d.ts +28 -0
- package/dist/components/alert/types.js +1 -0
- package/dist/components/app/app.css +16 -0
- package/dist/components/app/app.svelte +48 -0
- package/dist/components/app/app.svelte.d.ts +7 -0
- package/dist/components/app/types.d.ts +4 -0
- package/dist/components/app/types.js +1 -0
- package/dist/components/appbar/appbar.css +48 -0
- package/dist/components/appbar/appbar.svelte +40 -0
- package/dist/components/appbar/appbar.svelte.d.ts +4 -0
- package/dist/components/appbar/types.d.ts +15 -0
- package/dist/components/appbar/types.js +1 -0
- package/dist/components/aspect-ratio/aspect-ratio.css +19 -0
- package/dist/components/aspect-ratio/aspect-ratio.svelte +47 -0
- package/dist/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
- package/dist/components/aspect-ratio/types.d.ts +5 -0
- package/dist/components/aspect-ratio/types.js +1 -0
- package/dist/components/avatar/avatar.css +109 -0
- package/dist/components/avatar/avatar.svelte +46 -0
- package/dist/components/avatar/avatar.svelte.d.ts +4 -0
- package/dist/components/avatar/types.d.ts +22 -0
- package/dist/components/avatar/types.js +1 -0
- package/dist/components/button/button.css +247 -0
- package/dist/components/button/button.svelte +102 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +29 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/card/card.css +115 -0
- package/dist/components/card/card.svelte +63 -0
- package/dist/components/card/card.svelte.d.ts +4 -0
- package/dist/components/card/types.d.ts +18 -0
- package/dist/components/card/types.js +1 -0
- package/dist/components/chip/chip.css +231 -0
- package/dist/components/chip/chip.svelte +131 -0
- package/dist/components/chip/chip.svelte.d.ts +4 -0
- package/dist/components/chip/types.d.ts +32 -0
- package/dist/components/chip/types.js +1 -0
- package/dist/components/dialog/dialog.css +136 -0
- package/dist/components/dialog/dialog.svelte +67 -0
- package/dist/components/dialog/dialog.svelte.d.ts +4 -0
- package/dist/components/dialog/types.d.ts +24 -0
- package/dist/components/dialog/types.js +1 -0
- package/dist/components/dropdown/dropdown.css +22 -0
- package/dist/components/dropdown/dropdown.svelte +116 -0
- package/dist/components/dropdown/dropdown.svelte.d.ts +4 -0
- package/dist/components/dropdown/dropdown.svelte.js +148 -0
- package/dist/components/dropdown/types.d.ts +26 -0
- package/dist/components/dropdown/types.js +1 -0
- package/dist/components/icon/icon.css +79 -0
- package/dist/components/icon/icon.svelte +49 -0
- package/dist/components/icon/icon.svelte.d.ts +4 -0
- package/dist/components/icon/types.d.ts +16 -0
- package/dist/components/icon/types.js +1 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +23 -0
- package/dist/components/list/list.css +221 -0
- package/dist/components/list/list.svelte +44 -0
- package/dist/components/list/list.svelte.d.ts +4 -0
- package/dist/components/list/modules/list-item.svelte +76 -0
- package/dist/components/list/modules/list-item.svelte.d.ts +4 -0
- package/dist/components/list/types.d.ts +33 -0
- package/dist/components/list/types.js +1 -0
- package/dist/components/modal/modal.css +145 -0
- package/dist/components/modal/modal.svelte +113 -0
- package/dist/components/modal/modal.svelte.d.ts +4 -0
- package/dist/components/modal/types.d.ts +26 -0
- package/dist/components/modal/types.js +1 -0
- package/dist/components/popover/popover.css +22 -0
- package/dist/components/popover/popover.svelte +73 -0
- package/dist/components/popover/popover.svelte.d.ts +4 -0
- package/dist/components/popover/popover.svelte.js +134 -0
- package/dist/components/popover/types.d.ts +20 -0
- package/dist/components/popover/types.js +1 -0
- package/dist/components/separator/separator.css +46 -0
- package/dist/components/separator/separator.svelte +37 -0
- package/dist/components/separator/separator.svelte.d.ts +4 -0
- package/dist/components/separator/types.d.ts +11 -0
- package/dist/components/separator/types.js +1 -0
- package/dist/components/spacer/spacer.css +3 -0
- package/dist/components/spacer/spacer.svelte +7 -0
- package/dist/components/spacer/spacer.svelte.d.ts +4 -0
- package/dist/components/spacer/types.d.ts +4 -0
- package/dist/components/spacer/types.js +1 -0
- package/dist/components/textfield/textfield.css +305 -0
- package/dist/components/textfield/textfield.svelte +193 -0
- package/dist/components/textfield/textfield.svelte.d.ts +4 -0
- package/dist/components/textfield/types.d.ts +37 -0
- package/dist/components/textfield/types.js +1 -0
- package/dist/components/toolbar/toolbar.css +129 -0
- package/dist/components/toolbar/toolbar.svelte +47 -0
- package/dist/components/toolbar/toolbar.svelte.d.ts +4 -0
- package/dist/components/toolbar/types.d.ts +27 -0
- package/dist/components/toolbar/types.js +1 -0
- package/dist/components/tooltip/tooltip.css +124 -0
- package/dist/components/tooltip/tooltip.svelte +113 -0
- package/dist/components/tooltip/tooltip.svelte.d.ts +4 -0
- package/dist/components/tooltip/tooltip.svelte.js +131 -0
- package/dist/components/tooltip/types.d.ts +23 -0
- package/dist/components/tooltip/types.js +1 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.js +27 -3
- package/dist/internal/assets.svelte.d.ts +8 -0
- package/dist/internal/assets.svelte.js +54 -0
- package/dist/internal/clickOutside.d.ts +9 -0
- package/dist/internal/clickOutside.js +34 -0
- package/dist/internal/deepMerge.d.ts +44 -0
- package/dist/internal/deepMerge.js +80 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +2 -0
- package/dist/internal/ripple.d.ts +12 -0
- package/dist/internal/ripple.js +93 -0
- package/dist/internal/scroll.d.ts +1 -0
- package/dist/internal/scroll.js +6 -0
- package/dist/internal/types.d.ts +13 -0
- package/dist/internal/unit.d.ts +1 -0
- package/dist/internal/unit.js +11 -0
- package/dist/plugin/css.d.ts +1 -0
- package/dist/plugin/css.js +56 -0
- package/dist/plugin/preset-v2.d.ts +96 -0
- package/dist/plugin/preset-v2.js +114 -0
- package/dist/plugin/vitejs.d.ts +5 -1
- package/dist/plugin/vitejs.js +32 -3
- package/dist/preset.js +16 -4
- package/dist/stores/breakpoints.d.ts +6 -0
- package/dist/stores/breakpoints.js +14 -0
- package/dist/stores/components.d.ts +8 -0
- package/dist/stores/components.js +26 -0
- package/dist/stores/devices.d.ts +6 -0
- package/dist/stores/devices.js +9 -0
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +4 -0
- package/dist/stores/themes.d.ts +8 -0
- package/dist/stores/themes.js +34 -0
- package/dist/style/animation.css +62 -0
- package/dist/style/css.js +6 -3
- package/dist/style/normalize.css +2 -0
- package/dist/style/parser/color.js +15 -4
- package/dist/style/parser/device.js +31 -19
- package/dist/style/variable.css +12 -0
- package/dist/utils/convert.d.ts +1 -0
- package/dist/utils/convert.js +17 -0
- package/dist/utils/x11.d.ts +1 -1
- package/package.json +22 -4
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { innerWidth, innerHeight } from 'svelte/reactivity/window';
|
|
2
|
+
export function getPositionsTooltip() {
|
|
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
|
+
const activatorRect = activator.getBoundingClientRect();
|
|
18
|
+
const spacing = 6;
|
|
19
|
+
if (location === 'top' || location === 'bottom') {
|
|
20
|
+
if (avoidCollisions) {
|
|
21
|
+
if (location === 'top') {
|
|
22
|
+
if (activatorRect.y - (elementRect.height + spacing) < 0) {
|
|
23
|
+
axis.y = activatorRect.bottom + spacing;
|
|
24
|
+
axis.location = 'bottom';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
axis.y = activatorRect.top - (elementRect.height + spacing);
|
|
28
|
+
axis.location = 'top';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (activatorRect.y + activatorRect.height + (elementRect.height + spacing) >
|
|
33
|
+
innerHeight.current) {
|
|
34
|
+
axis.y = activatorRect.top - (elementRect.height + spacing);
|
|
35
|
+
axis.location = 'top';
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
axis.y = activatorRect.bottom + spacing;
|
|
39
|
+
axis.location = 'bottom';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (location === 'top') {
|
|
45
|
+
axis.y = activatorRect.top - (elementRect.height + spacing);
|
|
46
|
+
axis.location = 'top';
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
axis.y = activatorRect.bottom + spacing;
|
|
50
|
+
axis.location = 'bottom';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (centered &&
|
|
54
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
55
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
56
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
57
|
+
}
|
|
58
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
59
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
axis.x = activatorRect.left;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (location === 'left' || location === 'right') {
|
|
66
|
+
if (avoidCollisions) {
|
|
67
|
+
if (location === 'left' && !(activatorRect.left - elementRect.width < 0)) {
|
|
68
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
69
|
+
axis.location = 'left';
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
if (activatorRect.left + activatorRect.width + elementRect.width + spacing >
|
|
73
|
+
innerWidth.current) {
|
|
74
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
75
|
+
axis.location = 'left';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
79
|
+
axis.location = 'right';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (location === 'left') {
|
|
85
|
+
axis.x = activatorRect.left - (elementRect.width + spacing);
|
|
86
|
+
axis.location = 'left';
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
axis.x = activatorRect.left + activatorRect.width + spacing;
|
|
90
|
+
axis.location = 'right';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (centered &&
|
|
94
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
95
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
96
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
97
|
+
}
|
|
98
|
+
else if (activatorRect.y + elementRect.height > innerHeight.current) {
|
|
99
|
+
axis.y = activatorRect.y - elementRect.height + activatorRect.height;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
axis.y = activatorRect.y;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
if (centered &&
|
|
107
|
+
activatorRect.left - (elementRect.width - activatorRect.width) / 2 > 0 &&
|
|
108
|
+
activatorRect.left + elementRect.width < innerWidth.current) {
|
|
109
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width) / 2;
|
|
110
|
+
}
|
|
111
|
+
else if (activatorRect.left + elementRect.width > innerWidth.current) {
|
|
112
|
+
axis.x = activatorRect.left - (elementRect.width - activatorRect.width);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
axis.x = activatorRect.left;
|
|
116
|
+
}
|
|
117
|
+
if (centered &&
|
|
118
|
+
activatorRect.top - (elementRect.height - activatorRect.height) / 2 > 0 &&
|
|
119
|
+
activatorRect.top + elementRect.height < innerHeight.current) {
|
|
120
|
+
axis.y = activatorRect.top - (elementRect.height - activatorRect.height) / 2;
|
|
121
|
+
}
|
|
122
|
+
else if (activatorRect.bottom + elementRect.height > innerHeight.current) {
|
|
123
|
+
axis.y = activatorRect.top - elementRect.height;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
axis.y = activatorRect.bottom;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface TooltipProps extends Component {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
dark?: boolean;
|
|
6
|
+
light?: boolean;
|
|
7
|
+
rounded?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
location?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
|
+
color?: string;
|
|
11
|
+
background?: string;
|
|
12
|
+
delayDuration?: number;
|
|
13
|
+
variant?: 'arrow';
|
|
14
|
+
density?: 'compact' | 'comfortable' | 'default';
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
avoidCollisions?: boolean;
|
|
17
|
+
tooltip?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
export type PositionElement = {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
location: string | null;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
interface Lapikit {
|
|
2
|
+
adapterCSS: string;
|
|
3
|
+
breakpoints: {
|
|
4
|
+
devices: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
thresholds: {
|
|
8
|
+
[key: string]: number | string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
theme: {
|
|
12
|
+
defaultTheme: string;
|
|
13
|
+
themes: {
|
|
14
|
+
[key: string]: {
|
|
15
|
+
dark: boolean;
|
|
16
|
+
colors: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
variables: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
declare function createLapikit(lapikit: Lapikit): void;
|
|
27
|
+
export default createLapikit;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { deepMerge } from './internal/deepMerge.js';
|
|
2
|
+
import { breakpoints } from './stores/breakpoints.js';
|
|
3
|
+
import { get } from 'svelte/store';
|
|
4
|
+
import { valueToPx } from './utils/convert.js';
|
|
5
|
+
import { devices } from './stores/devices.js';
|
|
6
|
+
function createLapikit(lapikit) {
|
|
7
|
+
console.log('Creating a new Lapikit instance...');
|
|
8
|
+
console.log('Options loaded:', lapikit);
|
|
9
|
+
if (lapikit?.breakpoints?.thresholds) {
|
|
10
|
+
const currentBreakpoints = get(breakpoints);
|
|
11
|
+
const breakpointMerged = deepMerge(currentBreakpoints, lapikit.breakpoints.thresholds);
|
|
12
|
+
const formattedBreakpoints = Object.fromEntries(Object.entries(breakpointMerged).map(([key, value]) => [key, valueToPx(value)]));
|
|
13
|
+
breakpoints.set(formattedBreakpoints);
|
|
14
|
+
console.log('Breakpoints found:', formattedBreakpoints);
|
|
15
|
+
}
|
|
16
|
+
if (lapikit?.breakpoints?.devices) {
|
|
17
|
+
const currentDevices = get(devices);
|
|
18
|
+
const currentBreakpoints = get(breakpoints);
|
|
19
|
+
const deviceMerged = deepMerge(currentDevices, lapikit.breakpoints.devices);
|
|
20
|
+
const formattedDevices = Object.fromEntries(Object.entries(deviceMerged).map(([key, deviceKey]) => {
|
|
21
|
+
const breakpointValue = currentBreakpoints[deviceKey];
|
|
22
|
+
return [key, valueToPx(breakpointValue)];
|
|
23
|
+
}));
|
|
24
|
+
devices.set(formattedDevices);
|
|
25
|
+
console.log('Devices found:', formattedDevices);
|
|
26
|
+
}
|
|
4
27
|
}
|
|
28
|
+
export default createLapikit;
|
|
@@ -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 '../utils/x11.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(--kit-radius-${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 === '_default' ? '' : `${media}:`}kit--${type}`)
|
|
20
|
+
.join(' ');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return Object.entries(value)
|
|
24
|
+
.map(([media, value]) => `${media === '_default' ? '' : `${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,9 @@
|
|
|
1
|
+
type ClickOutsideOptions = {
|
|
2
|
+
exclude?: (HTMLElement | PointerEvent | null)[];
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function clickOutside(node: HTMLElement, options: ClickOutsideOptions): {
|
|
6
|
+
update(newOptions: ClickOutsideOptions): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function clickOutside(node, options) {
|
|
2
|
+
let { exclude = [], onClose } = options;
|
|
3
|
+
function isTargetExcluded(target) {
|
|
4
|
+
return exclude.some((ex) => {
|
|
5
|
+
if (!ex)
|
|
6
|
+
return false;
|
|
7
|
+
if (ex instanceof HTMLElement) {
|
|
8
|
+
return ex.contains(target);
|
|
9
|
+
}
|
|
10
|
+
if (ex instanceof PointerEvent && ex.target instanceof Node) {
|
|
11
|
+
return ex.target.contains(target);
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const handleClick = (event) => {
|
|
17
|
+
const target = event.target;
|
|
18
|
+
const isExcluded = isTargetExcluded(target);
|
|
19
|
+
const isInside = node.contains(target);
|
|
20
|
+
if (!isInside && !isExcluded) {
|
|
21
|
+
onClose();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
document.addEventListener('click', handleClick, true);
|
|
25
|
+
return {
|
|
26
|
+
update(newOptions) {
|
|
27
|
+
exclude = newOptions.exclude || [];
|
|
28
|
+
onClose = newOptions.onClose;
|
|
29
|
+
},
|
|
30
|
+
destroy() {
|
|
31
|
+
document.removeEventListener('click', handleClick, true);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively merges two objects together.
|
|
3
|
+
* Properties from the source object override those from the target object.
|
|
4
|
+
* Nested objects are merged recursively.
|
|
5
|
+
*
|
|
6
|
+
* @param target - The base object
|
|
7
|
+
* @param source - The source object to merge (can be null or undefined)
|
|
8
|
+
* @returns A new object containing the merge of both objects
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const obj1 = { primary: { light: 'pink', medium: 'purple' } };
|
|
13
|
+
* const obj2 = { primary: { dark: 'red' } };
|
|
14
|
+
* const result = deepMerge(obj1, obj2);
|
|
15
|
+
* // Result: { primary: { light: 'pink', medium: 'purple', dark: 'red' } }
|
|
16
|
+
*
|
|
17
|
+
* // Works with null/undefined source
|
|
18
|
+
* const result2 = deepMerge(obj1, null);
|
|
19
|
+
* // Result: { primary: { light: 'pink', medium: 'purple' } }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function deepMerge<T extends Record<string, unknown>, U extends Record<string, unknown>>(target: T, source: U | null | undefined): T & U;
|
|
23
|
+
/**
|
|
24
|
+
* Merges multiple objects together recursively.
|
|
25
|
+
*
|
|
26
|
+
* @param objects - The objects to merge (null and undefined values are ignored)
|
|
27
|
+
* @returns A new object containing the merge of all objects
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const result = deepMergeMultiple(
|
|
32
|
+
* { primary: { light: 'pink' } },
|
|
33
|
+
* null,
|
|
34
|
+
* { primary: { dark: 'red' } },
|
|
35
|
+
* undefined,
|
|
36
|
+
* { secondary: { light: 'blue' } }
|
|
37
|
+
* );
|
|
38
|
+
* // Result: {
|
|
39
|
+
* // primary: { light: 'pink', dark: 'red' },
|
|
40
|
+
* // secondary: { light: 'blue' }
|
|
41
|
+
* // }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function deepMergeMultiple(...objects: (Record<string, unknown> | null | undefined)[]): Record<string, unknown>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a plain object (object literal)
|
|
3
|
+
*/
|
|
4
|
+
function isPlainObject(value) {
|
|
5
|
+
return (value !== null &&
|
|
6
|
+
typeof value === 'object' &&
|
|
7
|
+
Object.prototype.toString.call(value) === '[object Object]');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Recursively merges two objects together.
|
|
11
|
+
* Properties from the source object override those from the target object.
|
|
12
|
+
* Nested objects are merged recursively.
|
|
13
|
+
*
|
|
14
|
+
* @param target - The base object
|
|
15
|
+
* @param source - The source object to merge (can be null or undefined)
|
|
16
|
+
* @returns A new object containing the merge of both objects
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const obj1 = { primary: { light: 'pink', medium: 'purple' } };
|
|
21
|
+
* const obj2 = { primary: { dark: 'red' } };
|
|
22
|
+
* const result = deepMerge(obj1, obj2);
|
|
23
|
+
* // Result: { primary: { light: 'pink', medium: 'purple', dark: 'red' } }
|
|
24
|
+
*
|
|
25
|
+
* // Works with null/undefined source
|
|
26
|
+
* const result2 = deepMerge(obj1, null);
|
|
27
|
+
* // Result: { primary: { light: 'pink', medium: 'purple' } }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function deepMerge(target, source) {
|
|
31
|
+
// If source is null or undefined, return a copy of target
|
|
32
|
+
if (source == null) {
|
|
33
|
+
return { ...target };
|
|
34
|
+
}
|
|
35
|
+
// Create a copy of the target object to avoid mutations
|
|
36
|
+
const result = { ...target };
|
|
37
|
+
for (const key in source) {
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39
|
+
const sourceValue = source[key];
|
|
40
|
+
const targetValue = result[key];
|
|
41
|
+
// If both values are plain objects, merge them recursively
|
|
42
|
+
if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
|
|
43
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Otherwise, the source value overrides the target value
|
|
47
|
+
result[key] = sourceValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Merges multiple objects together recursively.
|
|
55
|
+
*
|
|
56
|
+
* @param objects - The objects to merge (null and undefined values are ignored)
|
|
57
|
+
* @returns A new object containing the merge of all objects
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const result = deepMergeMultiple(
|
|
62
|
+
* { primary: { light: 'pink' } },
|
|
63
|
+
* null,
|
|
64
|
+
* { primary: { dark: 'red' } },
|
|
65
|
+
* undefined,
|
|
66
|
+
* { secondary: { light: 'blue' } }
|
|
67
|
+
* );
|
|
68
|
+
* // Result: {
|
|
69
|
+
* // primary: { light: 'pink', dark: 'red' },
|
|
70
|
+
* // secondary: { light: 'blue' }
|
|
71
|
+
* // }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function deepMergeMultiple(...objects) {
|
|
75
|
+
return objects
|
|
76
|
+
.filter((obj) => obj != null)
|
|
77
|
+
.reduce((acc, obj) => {
|
|
78
|
+
return deepMerge(acc, obj);
|
|
79
|
+
}, {});
|
|
80
|
+
}
|
package/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface RippleOptions {
|
|
2
|
+
component?: string;
|
|
3
|
+
center?: boolean;
|
|
4
|
+
color?: string;
|
|
5
|
+
duration?: number;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ripple(el: HTMLElement, options?: RippleOptions): {
|
|
9
|
+
destroy(): void;
|
|
10
|
+
update(newOptions: RippleOptions): void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const triggerEvents = ['pointerdown', 'touchstart', 'keydown'];
|
|
2
|
+
const cancelEvents = ['mouseleave', 'dragleave', 'touchmove', 'touchcancel', 'pointerup', 'keyup'];
|
|
3
|
+
export function ripple(el, options = {}) {
|
|
4
|
+
const rippleContainer = document.createElement('div');
|
|
5
|
+
addClasses();
|
|
6
|
+
setOptions(options);
|
|
7
|
+
function addClasses(center) {
|
|
8
|
+
const shouldBeCentered = center || options.center;
|
|
9
|
+
if (!rippleContainer.classList.contains('kit-ripple--effect')) {
|
|
10
|
+
rippleContainer.classList.add('kit-ripple--effect');
|
|
11
|
+
}
|
|
12
|
+
if (!shouldBeCentered && rippleContainer.classList.contains('kit-ripple--center')) {
|
|
13
|
+
rippleContainer.classList.remove('kit-ripple--center');
|
|
14
|
+
}
|
|
15
|
+
if (shouldBeCentered) {
|
|
16
|
+
rippleContainer.classList.add('kit-ripple--center');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function setOptions(options) {
|
|
20
|
+
if (options.disabled || el.hasAttribute('aria-disabled')) {
|
|
21
|
+
rippleContainer.remove();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
el.appendChild(rippleContainer);
|
|
25
|
+
}
|
|
26
|
+
if (options.duration && options.duration < 0) {
|
|
27
|
+
options.duration = undefined;
|
|
28
|
+
}
|
|
29
|
+
if (options.component) {
|
|
30
|
+
rippleContainer.style.setProperty('--ripple-radius', `var(--${options.component}-radius)`);
|
|
31
|
+
}
|
|
32
|
+
if (options.color) {
|
|
33
|
+
rippleContainer.style.setProperty('--ripple-color', options.color);
|
|
34
|
+
}
|
|
35
|
+
if (options.duration) {
|
|
36
|
+
rippleContainer.style.setProperty('--ripple-duration', `${options.duration}ms`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function createRipple(e, center) {
|
|
40
|
+
if (options.disabled || el.hasAttribute('aria-disabled')) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (e instanceof KeyboardEvent) {
|
|
44
|
+
if (!['Enter', 'Space'].includes(e.code) || e.repeat) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
const click = new PointerEvent('pointerdown');
|
|
49
|
+
createRipple(click, true);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
addClasses(center);
|
|
53
|
+
const rect = el.getBoundingClientRect();
|
|
54
|
+
const clientX = window.TouchEvent && e instanceof TouchEvent
|
|
55
|
+
? e.touches[0].clientX
|
|
56
|
+
: e.clientX;
|
|
57
|
+
const clientY = window.TouchEvent && e instanceof TouchEvent
|
|
58
|
+
? e.touches[0].clientY
|
|
59
|
+
: e.clientY;
|
|
60
|
+
const x = clientX - rect.left > el.offsetWidth / 2 ? 0 : el.offsetWidth;
|
|
61
|
+
const y = clientY - rect.top > el.offsetHeight / 2 ? 0 : el.offsetHeight;
|
|
62
|
+
const radius = Math.hypot(x - (clientX - rect.left), y - (clientY - rect.top));
|
|
63
|
+
const ripple = document.createElement('div');
|
|
64
|
+
ripple.classList.add('kit-ripple');
|
|
65
|
+
ripple.style.left = `${clientX - rect.left - radius}px`;
|
|
66
|
+
ripple.style.top = `${clientY - rect.top - radius}px`;
|
|
67
|
+
ripple.style.width = ripple.style.height = `${radius * 2}px`;
|
|
68
|
+
rippleContainer.appendChild(ripple);
|
|
69
|
+
function removeRipple() {
|
|
70
|
+
if (ripple === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
ripple.style.opacity = '0';
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
ripple.remove();
|
|
76
|
+
}, options.duration || 1000);
|
|
77
|
+
cancelEvents.forEach((event) => el.removeEventListener(event, removeRipple));
|
|
78
|
+
}
|
|
79
|
+
cancelEvents.forEach((event) => el.addEventListener(event, removeRipple, { passive: true }));
|
|
80
|
+
}
|
|
81
|
+
triggerEvents.forEach((event) => el.addEventListener(event, createRipple, { passive: event === 'touchstart' }));
|
|
82
|
+
return {
|
|
83
|
+
destroy() {
|
|
84
|
+
triggerEvents.forEach((event) => {
|
|
85
|
+
el.removeEventListener(event, createRipple);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
update(newOptions) {
|
|
89
|
+
options = newOptions;
|
|
90
|
+
setOptions(newOptions);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function disabledScroll(state: boolean): void;
|
package/dist/internal/types.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type IdElementType = string | undefined;
|
|
3
|
+
type ClassNameType = string | string[] | undefined;
|
|
4
|
+
type StylePropertiesType = string | undefined;
|
|
5
|
+
export interface Base {
|
|
6
|
+
id?: IdElementType;
|
|
7
|
+
class?: ClassNameType;
|
|
8
|
+
style?: StylePropertiesType;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface Component extends Base {
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
1
14
|
export type FontFamily = {
|
|
2
15
|
[key: string]: string | string[];
|
|
3
16
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setUnit: (value: string | number) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const setUnit = (value) => {
|
|
2
|
+
if (typeof value === 'number')
|
|
3
|
+
return `${value}px`;
|
|
4
|
+
if (typeof value === 'string') {
|
|
5
|
+
const cleaned = value.trim();
|
|
6
|
+
const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
|
|
7
|
+
if (isOnlyNumericLike)
|
|
8
|
+
return `${value}px`;
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function css(configuration: any): void;
|