lapikit 0.0.0-insiders.efb49b7 → 0.0.0-insiders.f0512a6
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/bin/configuration.js +300 -0
- package/bin/helper.js +23 -0
- package/bin/index.js +41 -0
- package/bin/lapikit.js +37 -5
- package/bin/legacy.js +34 -0
- package/bin/modules/adapter.js +3 -3
- package/bin/modules/plugin.js +223 -0
- package/bin/presets.js +25 -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 +2 -0
- package/dist/assets/icons/arrow-down.svelte.d.ts +6 -14
- package/dist/assets/icons/arrow-up.svelte +2 -0
- package/dist/assets/icons/arrow-up.svelte.d.ts +6 -14
- package/dist/assets/icons/close-fill.svelte +2 -0
- package/dist/assets/icons/close-fill.svelte.d.ts +6 -14
- package/dist/assets/icons/loading-fill.svelte +2 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +6 -14
- package/dist/components/accordion/accordion.css +6 -6
- package/dist/components/alert/alert.css +19 -9
- package/dist/components/app/app.css +1 -1
- package/dist/components/app/app.svelte +28 -5
- 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.svelte +22 -0
- package/dist/components/avatar/avatar.css +5 -5
- package/dist/components/avatar/avatar.svelte +4 -4
- package/dist/components/avatar/types.d.ts +1 -1
- package/dist/components/button/button.css +165 -194
- package/dist/components/button/button.svelte +39 -31
- package/dist/components/button/button.svelte.d.ts +2 -2
- package/dist/components/button/types.d.ts +7 -5
- 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 +218 -4
- package/dist/components/chip/chip.svelte +18 -5
- package/dist/components/chip/types.d.ts +3 -1
- package/dist/components/dialog/dialog.css +5 -3
- package/dist/components/dropdown/dropdown.css +4 -4
- package/dist/components/icon/icon.css +14 -11
- package/dist/components/index.d.ts +7 -1
- package/dist/components/index.js +7 -1
- package/dist/components/list/list.css +145 -119
- package/dist/components/list/list.svelte +1 -3
- package/dist/components/list/modules/list-item.svelte +9 -1
- package/dist/components/list/types.d.ts +2 -5
- package/dist/components/modal/modal.css +18 -13
- package/dist/components/modal/modal.svelte +1 -0
- package/dist/components/popover/popover.css +4 -4
- package/dist/components/separator/separator.css +1 -1
- 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 +4 -4
- package/dist/index.d.ts +27 -1
- package/dist/index.js +27 -3
- package/dist/internal/assets.svelte.js +2 -0
- package/dist/internal/deepMerge.d.ts +44 -0
- package/dist/internal/deepMerge.js +80 -0
- package/dist/internal/ripple.d.ts +12 -0
- package/dist/internal/ripple.js +93 -0
- package/dist/internal/unit.d.ts +1 -0
- package/dist/internal/unit.js +11 -0
- package/dist/plugin/vitejs.d.ts +6 -1
- package/dist/plugin/vitejs.js +12 -7
- package/dist/preset.js +2 -2
- 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 -9
- package/dist/stores/index.js +4 -42
- package/dist/stores/themes.d.ts +8 -0
- package/dist/stores/themes.js +34 -0
- package/dist/style/animation.css +42 -0
- package/dist/style/normalize.css +2 -0
- package/dist/style/parser/color.js +2 -2
- package/dist/style/parser/device.js +31 -19
- package/dist/utils/convert.d.ts +1 -0
- package/dist/utils/convert.js +17 -0
- package/package.json +7 -3
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
.kit-toolbar {
|
|
2
|
+
--toolbar-color: var(--on, var(--kit-on-surface));
|
|
3
|
+
--toolbar-background: var(--base, var(--kit-surface));
|
|
4
|
+
--toolbar-radius: var(--shape, var(--kit-radius-md));
|
|
5
|
+
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
/* min-width: max-content; */
|
|
9
|
+
border-style: solid;
|
|
10
|
+
/* transition:
|
|
11
|
+
color 0.5s,
|
|
12
|
+
border-color 0.5s,
|
|
13
|
+
background-color 0.5s; */
|
|
14
|
+
|
|
15
|
+
border-width: 1px;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
border-radius: var(--toolbar-radius);
|
|
18
|
+
|
|
19
|
+
/* theme */
|
|
20
|
+
color: var(--toolbar-color);
|
|
21
|
+
background-color: var(--toolbar-background);
|
|
22
|
+
border-color: var(--toolbar-background);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* density */
|
|
26
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-default {
|
|
27
|
+
border-radius: calc(var(--kit-spacing) * 2.25);
|
|
28
|
+
}
|
|
29
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-default:not([class*='toolbar--orientation-vertical']) {
|
|
30
|
+
height: 3rem;
|
|
31
|
+
padding-inline: calc(var(--kit-spacing) * 1.5);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-default[class*='toolbar--orientation-vertical'] {
|
|
35
|
+
width: 3rem;
|
|
36
|
+
padding: calc(var(--kit-spacing) * 1.5) 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-compact {
|
|
40
|
+
border-radius: calc(var(--kit-spacing) * 1.75);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-compact:not([class*='toolbar--orientation-vertical']) {
|
|
44
|
+
height: 2.625rem;
|
|
45
|
+
padding-inline: calc(var(--kit-spacing) * 0.75);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-compact[class*='toolbar--orientation-vertical'] {
|
|
49
|
+
width: 2.625rem;
|
|
50
|
+
padding: calc(var(--kit-spacing) * 0.75) 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-comfortable {
|
|
54
|
+
border-radius: calc(var(--kit-spacing) * 3.5);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-comfortable:not(
|
|
58
|
+
[class*='toolbar--orientation-vertical']
|
|
59
|
+
) {
|
|
60
|
+
height: 3.5rem;
|
|
61
|
+
padding-inline: calc(var(--kit-spacing) * 2.25);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.kit-toolbar[breakpoint]kit-toolbar--density-comfortable[class*='toolbar--orientation-vertical'] {
|
|
65
|
+
width: 3.5rem;
|
|
66
|
+
padding: calc(var(--kit-spacing) * 2.25) 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.kit-toolbar[breakpoint]kit-toolbar--variant-text,
|
|
70
|
+
.kit-toolbar[breakpoint]kit-toolbar--variant-outline,
|
|
71
|
+
.kit-toolbar[breakpoint]kit-toolbar--variant-dash {
|
|
72
|
+
--toolbar-color: var(--base, var(--kit-surface));
|
|
73
|
+
background-color: transparent;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.kit-toolbar[breakpoint]kit-toolbar--variant-outline {
|
|
77
|
+
border-color: currentColor;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.kit-toolbar[breakpoint]kit-toolbar--variant-dash {
|
|
81
|
+
border-style: dashed;
|
|
82
|
+
border-color: currentColor;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.kit-toolbar[breakpoint]kit-toolbar--orientation-horizontal {
|
|
86
|
+
flex-direction: row;
|
|
87
|
+
width: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.kit-toolbar[breakpoint]kit-toolbar--orientation-vertical {
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
min-height: fit-content;
|
|
93
|
+
width: fit-content;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* wrapper */
|
|
97
|
+
.kit-toolbar .kit-toolbar--wrapper {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
/* margin-left: auto;
|
|
101
|
+
margin-right: auto; */
|
|
102
|
+
flex-direction: row;
|
|
103
|
+
height: auto;
|
|
104
|
+
width: 100%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.kit-toolbar[breakpoint]kit-toolbar--orientation-vertical .kit-toolbar--wrapper {
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
height: 100%;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* location */
|
|
113
|
+
.kit-toolbar[breakpoint]kit-toolbar--location-top {
|
|
114
|
+
top: 0px;
|
|
115
|
+
z-index: 1004;
|
|
116
|
+
transform: translateY(0px);
|
|
117
|
+
position: fixed;
|
|
118
|
+
left: 0px;
|
|
119
|
+
width: calc(100% + 0px);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.kit-toolbar[breakpoint]kit-toolbar--location-bottom {
|
|
123
|
+
z-index: 1004;
|
|
124
|
+
transform: translateY(0px);
|
|
125
|
+
position: fixed;
|
|
126
|
+
left: 0px;
|
|
127
|
+
width: calc(100% + 0px);
|
|
128
|
+
bottom: 0px;
|
|
129
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAssets } from '../../internal/index.js';
|
|
3
|
+
import type { ToolbarProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
children,
|
|
7
|
+
ref = $bindable(),
|
|
8
|
+
is = 'div',
|
|
9
|
+
classContent,
|
|
10
|
+
light,
|
|
11
|
+
dark,
|
|
12
|
+
variant,
|
|
13
|
+
rounded,
|
|
14
|
+
background,
|
|
15
|
+
color,
|
|
16
|
+
density = 'default',
|
|
17
|
+
orientation = 'horizontal',
|
|
18
|
+
location,
|
|
19
|
+
...rest
|
|
20
|
+
}: ToolbarProps = $props();
|
|
21
|
+
|
|
22
|
+
const assets = getAssets();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<svelte:element
|
|
26
|
+
this={is}
|
|
27
|
+
bind:this={ref}
|
|
28
|
+
{...rest}
|
|
29
|
+
role="toolbar"
|
|
30
|
+
class={[
|
|
31
|
+
'kit-toolbar',
|
|
32
|
+
light && 'light',
|
|
33
|
+
dark && 'dark',
|
|
34
|
+
variant && assets.className('toolbar', 'variant', variant),
|
|
35
|
+
density && assets.className('toolbar', 'density', density),
|
|
36
|
+
orientation && assets.className('toolbar', 'orientation', orientation),
|
|
37
|
+
location && assets.className('toolbar', 'location', location),
|
|
38
|
+
rest.class
|
|
39
|
+
]}
|
|
40
|
+
style:--base={assets.color(background)}
|
|
41
|
+
style:--on={assets.color(color)}
|
|
42
|
+
style:--shape={assets.shape(rounded)}
|
|
43
|
+
>
|
|
44
|
+
<div class={['kit-toolbar--wrapper', classContent]}>
|
|
45
|
+
{@render children?.()}
|
|
46
|
+
</div>
|
|
47
|
+
</svelte:element>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
type Variant = 'outline' | 'text' | 'dash';
|
|
3
|
+
type Density = 'compact' | 'comfortable' | 'default';
|
|
4
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
5
|
+
type Location = 'top' | 'bottom';
|
|
6
|
+
export interface ToolbarProps extends Component {
|
|
7
|
+
is?: 'div' | 'header' | 'nav';
|
|
8
|
+
variant?: Variant | {
|
|
9
|
+
[key: string]: Variant;
|
|
10
|
+
};
|
|
11
|
+
rounded?: string;
|
|
12
|
+
density?: Density | {
|
|
13
|
+
[key: string]: Density;
|
|
14
|
+
};
|
|
15
|
+
dark?: boolean;
|
|
16
|
+
light?: boolean;
|
|
17
|
+
color?: string;
|
|
18
|
+
orientation?: Orientation | {
|
|
19
|
+
[key: string]: Orientation;
|
|
20
|
+
};
|
|
21
|
+
background?: string;
|
|
22
|
+
location?: Location | {
|
|
23
|
+
[key: string]: Location;
|
|
24
|
+
};
|
|
25
|
+
classContent?: string | string[] | undefined;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.kit-tooltip-content {
|
|
9
|
-
--tooltip-color: var(--on, var(--kit-on-
|
|
10
|
-
--tooltip-background: var(--base, var(--kit-
|
|
9
|
+
--tooltip-color: var(--on, var(--kit-on-surface));
|
|
10
|
+
--tooltip-background: var(--base, var(--kit-surface));
|
|
11
11
|
--tooltip-radius: var(--shape, var(--kit-radius-md));
|
|
12
12
|
|
|
13
13
|
background-color: var(--tooltip-background);
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
width: auto;
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
overflow-wrap: break-word;
|
|
22
|
-
transition:
|
|
22
|
+
/* transition:
|
|
23
23
|
color 0.5s,
|
|
24
24
|
border-color 0.5s,
|
|
25
|
-
background-color 0.5s;
|
|
25
|
+
background-color 0.5s; */
|
|
26
26
|
box-shadow: 0px 16px 29px -10px color-mix(in oklab, var(--kit-scrim) 60%, transparent);
|
|
27
27
|
}
|
|
28
28
|
|
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;
|
|
@@ -34,6 +34,8 @@ export function getAssets() {
|
|
|
34
34
|
color.includes('oklch') ||
|
|
35
35
|
x11ColorNames.includes(color.toLowerCase()))
|
|
36
36
|
return color;
|
|
37
|
+
if (color.includes('transparent') || color.includes('inherit') || color.includes('initial'))
|
|
38
|
+
return color;
|
|
37
39
|
return `var(--kit-${color})`;
|
|
38
40
|
}
|
|
39
41
|
},
|
|
@@ -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
|
+
}
|
|
@@ -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 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
|
+
};
|
package/dist/plugin/vitejs.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
|
-
|
|
2
|
+
type Lapikit = {
|
|
3
|
+
minify?: boolean;
|
|
4
|
+
config?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function lapikit({ minify, config }?: Lapikit): Promise<{
|
|
3
7
|
name: string;
|
|
4
8
|
configResolved(): Promise<void>;
|
|
5
9
|
configureServer(server: ViteDevServer): Promise<void>;
|
|
6
10
|
}>;
|
|
11
|
+
export {};
|
package/dist/plugin/vitejs.js
CHANGED
|
@@ -2,21 +2,26 @@ import { importer } from './modules/importer.js';
|
|
|
2
2
|
import { processCSS } from '../style/css.js';
|
|
3
3
|
import { parseConfig } from './modules/config.js';
|
|
4
4
|
import { terminal } from '../internal/terminal.js';
|
|
5
|
-
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
const app = process.cwd();
|
|
8
|
+
export async function lapikit({ minify = false, config = 'src/plugins/lapikit.js' } = {}) {
|
|
9
|
+
const pathConfig = path.resolve(app, config);
|
|
10
|
+
console.log('pathConfig:', pathConfig);
|
|
6
11
|
return {
|
|
7
12
|
name: 'lapikit/vite.js',
|
|
8
13
|
async configResolved() {
|
|
9
|
-
const
|
|
10
|
-
const result = await parseConfig(
|
|
14
|
+
const importedConfig = await importer();
|
|
15
|
+
const result = await parseConfig(importedConfig);
|
|
11
16
|
await processCSS(result);
|
|
12
17
|
terminal('info', 'lapikit is up!');
|
|
13
18
|
},
|
|
14
19
|
async configureServer(server) {
|
|
15
|
-
server.watcher.add(
|
|
20
|
+
server.watcher.add(config);
|
|
16
21
|
server.watcher.on('change', async (filePath) => {
|
|
17
|
-
if (String(filePath).includes(
|
|
18
|
-
const
|
|
19
|
-
const result = await parseConfig(
|
|
22
|
+
if (String(filePath).includes(config)) {
|
|
23
|
+
const importedConfig = await importer();
|
|
24
|
+
const result = await parseConfig(importedConfig);
|
|
20
25
|
await processCSS(result);
|
|
21
26
|
terminal('info', 'lapikit config reloaded');
|
|
22
27
|
}
|
package/dist/preset.js
CHANGED
|
@@ -4,7 +4,7 @@ export const config = {
|
|
|
4
4
|
minify: false // true | false
|
|
5
5
|
},
|
|
6
6
|
theme: {
|
|
7
|
-
colorScheme: '
|
|
7
|
+
colorScheme: 'system', // 'light' | 'dark' | 'system'
|
|
8
8
|
colors: {
|
|
9
9
|
primary: { light: 'oklch(45% 0.24 277.023)', dark: 'oklch(45% 0.24 277.023)' },
|
|
10
10
|
'on-primary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
@@ -35,7 +35,7 @@ export const config = {
|
|
|
35
35
|
breakpoints: {
|
|
36
36
|
mobileBreakpoint: 'sm',
|
|
37
37
|
tabletBreakpoint: 'md',
|
|
38
|
-
laptopBreakpoint: '
|
|
38
|
+
laptopBreakpoint: 'lg',
|
|
39
39
|
thresholds: {
|
|
40
40
|
_default: 0, // 0px
|
|
41
41
|
xs: '28rem', //448px
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// store breakpoints and thresholds
|
|
2
|
+
import { writable } from 'svelte/store';
|
|
3
|
+
// presets
|
|
4
|
+
const ref = {
|
|
5
|
+
base: 0, // 0px
|
|
6
|
+
xs: 448, //28rem
|
|
7
|
+
sm: 640, //40rem
|
|
8
|
+
md: 768, //48rem
|
|
9
|
+
lg: 1024, //64rem
|
|
10
|
+
xl: 1280, //80rem
|
|
11
|
+
'2xl': 1536, //96rem
|
|
12
|
+
'3xl': 1792 //112rem
|
|
13
|
+
};
|
|
14
|
+
export const breakpoints = writable(ref);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
type ModalState = boolean | 'persistent';
|
|
3
|
+
export declare const modalOpen: Writable<ModalState>;
|
|
4
|
+
export declare const modalStack: Writable<string[]>;
|
|
5
|
+
export declare function setOpenModal(state: boolean | 'persistent'): void;
|
|
6
|
+
export declare const pushModal: (id: string) => void;
|
|
7
|
+
export declare const popModal: (id: string) => void;
|
|
8
|
+
export {};
|