lapikit 0.0.0-insiders.dcdfb82 → 0.0.0-insiders.de81aed
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/helper.js +41 -32
- package/bin/lapikit.js +9 -9
- package/bin/modules/adapter.js +3 -3
- package/dist/assets/icons/loading-fill.svelte +29 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +26 -0
- package/dist/components/app/app.svelte +14 -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/button/button.css +276 -0
- package/dist/components/button/button.svelte +94 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/types.d.ts +27 -0
- package/dist/components/button/types.js +1 -0
- package/dist/components/dialog/dialog.css +143 -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 +21 -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 +76 -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 +9 -0
- package/dist/components/index.js +10 -0
- package/dist/components/modal/modal.css +19 -0
- package/dist/components/modal/modal.svelte +59 -0
- package/dist/components/modal/modal.svelte.d.ts +4 -0
- package/dist/components/modal/types.d.ts +21 -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/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/internal/assets.svelte.d.ts +8 -0
- package/dist/internal/assets.svelte.js +52 -0
- package/dist/internal/clickOutside.d.ts +9 -0
- package/dist/internal/clickOutside.js +34 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +2 -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/preset.js +14 -2
- package/dist/stores/index.d.ts +4 -0
- package/dist/stores/index.js +23 -0
- package/dist/style/animation.css +20 -0
- package/dist/style/css.js +6 -3
- package/dist/style/parser/color.js +13 -2
- package/dist/style/variable.css +7 -0
- package/dist/utils/x11.d.ts +1 -1
- package/package.json +12 -3
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAssets } from '../../internal/assets.svelte.js';
|
|
3
|
+
import { getPositionsTooltip } from './tooltip.svelte.js';
|
|
4
|
+
import type { PositionElement, TooltipProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
tooltip,
|
|
9
|
+
open = $bindable(),
|
|
10
|
+
label,
|
|
11
|
+
dark,
|
|
12
|
+
light,
|
|
13
|
+
rounded,
|
|
14
|
+
color,
|
|
15
|
+
background,
|
|
16
|
+
location = 'bottom',
|
|
17
|
+
delayDuration = 850,
|
|
18
|
+
density = 'default',
|
|
19
|
+
variant,
|
|
20
|
+
disabled,
|
|
21
|
+
avoidCollisions = true,
|
|
22
|
+
forceMount,
|
|
23
|
+
...rest
|
|
24
|
+
}: TooltipProps = $props();
|
|
25
|
+
|
|
26
|
+
const positionAxis = getPositionsTooltip();
|
|
27
|
+
const assets = getAssets();
|
|
28
|
+
|
|
29
|
+
let ref: HTMLElement | null = $state(null);
|
|
30
|
+
let refTooltip: HTMLElement | null = $state(null);
|
|
31
|
+
let timer: ReturnType<typeof setTimeout> | null = $state(null);
|
|
32
|
+
let axis: PositionElement = $state({ x: 0, y: 0, location: null });
|
|
33
|
+
let innerHeight = $state(0);
|
|
34
|
+
let innerWidth = $state(0);
|
|
35
|
+
let scrollX = $state(0);
|
|
36
|
+
let scrollY = $state(0);
|
|
37
|
+
|
|
38
|
+
axis = positionAxis?.values;
|
|
39
|
+
|
|
40
|
+
$effect(() => {
|
|
41
|
+
if (
|
|
42
|
+
open &&
|
|
43
|
+
ref &&
|
|
44
|
+
refTooltip &&
|
|
45
|
+
(scrollX > 0 || scrollY > 0 || innerHeight > 0 || innerWidth > 0)
|
|
46
|
+
) {
|
|
47
|
+
positionAxis.update(ref, refTooltip, location, true, avoidCollisions);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
if (tooltip) forceMount = true;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const handleMouse = (state: string) => {
|
|
56
|
+
if (disabled) return (open = false);
|
|
57
|
+
if (state === 'enter') {
|
|
58
|
+
timer = setTimeout(() => {
|
|
59
|
+
open = true;
|
|
60
|
+
}, delayDuration);
|
|
61
|
+
} else if (state === 'leave') {
|
|
62
|
+
if (timer) {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
timer = null;
|
|
65
|
+
}
|
|
66
|
+
open = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<svelte:window bind:innerHeight bind:innerWidth bind:scrollX bind:scrollY />
|
|
72
|
+
|
|
73
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
74
|
+
<span
|
|
75
|
+
bind:this={ref}
|
|
76
|
+
onmouseenter={() => handleMouse('enter')}
|
|
77
|
+
onmouseleave={() => handleMouse('leave')}
|
|
78
|
+
style:display="inline-flex"
|
|
79
|
+
>
|
|
80
|
+
{@render children?.()}
|
|
81
|
+
</span>
|
|
82
|
+
|
|
83
|
+
{#if open || forceMount}
|
|
84
|
+
<div
|
|
85
|
+
bind:this={refTooltip}
|
|
86
|
+
class={['kit-tooltip']}
|
|
87
|
+
role="tooltip"
|
|
88
|
+
aria-label={label}
|
|
89
|
+
style={`transform: translate(${axis.x}px, ${axis.y}px);display: ${open ? 'initial' : 'none'}`}
|
|
90
|
+
>
|
|
91
|
+
<div
|
|
92
|
+
class={[
|
|
93
|
+
'kit-tooltip-content animate-in',
|
|
94
|
+
light && 'light',
|
|
95
|
+
dark && 'dark',
|
|
96
|
+
rounded && assets.shape(rounded),
|
|
97
|
+
axis?.location && `kit-tooltip-content--${axis?.location}`,
|
|
98
|
+
variant && `kit-tooltip-content--${variant}`,
|
|
99
|
+
density && assets.className('tooltip-content', 'density', density),
|
|
100
|
+
rest.class
|
|
101
|
+
]}
|
|
102
|
+
style:--base={assets.color(background)}
|
|
103
|
+
style:--on={assets.color(color)}
|
|
104
|
+
style:--shape={assets.shape(rounded)}
|
|
105
|
+
>
|
|
106
|
+
{#if tooltip}
|
|
107
|
+
{@render tooltip?.()}
|
|
108
|
+
{:else}
|
|
109
|
+
{label}
|
|
110
|
+
{/if}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
{/if}
|
|
@@ -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 {};
|
|
@@ -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,52 @@
|
|
|
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
|
+
return `var(--kit-${color})`;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
unit(value) {
|
|
41
|
+
if (typeof value === 'number')
|
|
42
|
+
return `${value}px`;
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
const cleaned = value.trim();
|
|
45
|
+
const isOnlyNumericLike = /^[\d.,]+$/.test(cleaned);
|
|
46
|
+
if (isOnlyNumericLike)
|
|
47
|
+
return `${value}px`;
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/internal/index.d.ts
CHANGED
package/dist/internal/index.js
CHANGED
|
@@ -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
|
};
|
package/dist/preset.js
CHANGED
|
@@ -7,17 +7,29 @@ export const config = {
|
|
|
7
7
|
colorScheme: 'dark', // 'light' | 'dark' | 'auto'
|
|
8
8
|
colors: {
|
|
9
9
|
primary: { light: 'oklch(45% 0.24 277.023)', dark: 'oklch(45% 0.24 277.023)' },
|
|
10
|
+
'on-primary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
10
11
|
secondary: { light: 'oklch(65% 0.241 354.308)', dark: 'oklch(65% 0.241 354.308)' },
|
|
12
|
+
'on-secondary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
11
13
|
tertiary: { light: 'oklch(77% 0.152 181.912)', dark: 'oklch(77% 0.152 181.912)' },
|
|
14
|
+
'on-tertiary': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
12
15
|
neutral: { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
16
|
+
'on-neutral': { light: 'oklch(100% 0 0)', dark: 'oklch(100% 0 0)' },
|
|
13
17
|
info: { light: 'oklch(74% 0.16 232.661)', dark: 'oklch(74% 0.16 232.661)' },
|
|
18
|
+
'on-info': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
14
19
|
success: { light: 'oklch(76% 0.177 163.223)', dark: 'oklch(76% 0.177 163.223)' },
|
|
20
|
+
'on-success': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
15
21
|
warning: { light: 'oklch(82% 0.189 84.429)', dark: 'oklch(82% 0.189 84.429)' },
|
|
22
|
+
'on-warning': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
16
23
|
error: { light: 'oklch(71% 0.194 13.428)', dark: 'oklch(71% 0.194 13.428)' },
|
|
24
|
+
'on-error': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(14% 0.005 285.823)' },
|
|
17
25
|
base: { light: 'oklch(100% 0 0)', dark: 'oklch(25.33% 0.016 252.42)' },
|
|
26
|
+
'on-base': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
|
|
18
27
|
surface: { light: 'oklch(98% 0 0)', dark: 'oklch(23.26% 0.014 253.1)' },
|
|
28
|
+
'on-surface': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
|
|
19
29
|
container: { light: 'oklch(95% 0 0)', dark: 'oklch(21.15% 0.012 254.09)' },
|
|
20
|
-
|
|
30
|
+
'on-container': { light: 'oklch(14% 0.005 285.823)', dark: 'oklch(100% 0 0)' },
|
|
31
|
+
shadow: 'black',
|
|
32
|
+
scrim: 'oklch(0.00% 0.000 0)'
|
|
21
33
|
}
|
|
22
34
|
},
|
|
23
35
|
breakpoints: {
|
|
@@ -25,7 +37,7 @@ export const config = {
|
|
|
25
37
|
tabletBreakpoint: 'md',
|
|
26
38
|
laptopBreakpoint: 'xl',
|
|
27
39
|
thresholds: {
|
|
28
|
-
|
|
40
|
+
_default: 0, // 0px
|
|
29
41
|
xs: '28rem', //448px
|
|
30
42
|
sm: '40rem', //640px
|
|
31
43
|
md: '48rem', //768px
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
export declare const colorScheme: Writable<'auto' | 'dark' | 'light'>;
|
|
3
|
+
export declare function updateThemeStore(update: 'auto' | 'dark' | 'light'): void;
|
|
4
|
+
export declare function setColorScheme(scheme: 'auto' | 'dark' | 'light'): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
// states
|
|
3
|
+
const _default = 'light';
|
|
4
|
+
const isBrowser = typeof window !== 'undefined';
|
|
5
|
+
export const colorScheme = writable(_default);
|
|
6
|
+
export function updateThemeStore(update) {
|
|
7
|
+
colorScheme.update(() => {
|
|
8
|
+
if (isBrowser) {
|
|
9
|
+
const ref = document.documentElement.classList;
|
|
10
|
+
if (update === 'auto')
|
|
11
|
+
ref.remove('light', 'dark');
|
|
12
|
+
else {
|
|
13
|
+
ref.remove(update === 'dark' ? 'light' : 'dark');
|
|
14
|
+
ref.add(update === 'dark' ? 'dark' : 'light');
|
|
15
|
+
}
|
|
16
|
+
localStorage.setItem('@lapikit/theme', update);
|
|
17
|
+
}
|
|
18
|
+
return update;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function setColorScheme(scheme) {
|
|
22
|
+
updateThemeStore(scheme);
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@keyframes button-click {
|
|
2
|
+
0% {
|
|
3
|
+
transform: scale(0.98);
|
|
4
|
+
}
|
|
5
|
+
40% {
|
|
6
|
+
transform: scale(1.02);
|
|
7
|
+
}
|
|
8
|
+
100% {
|
|
9
|
+
transform: scale(1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@keyframes icon-rotate {
|
|
14
|
+
0% {
|
|
15
|
+
transform: rotate(10deg);
|
|
16
|
+
}
|
|
17
|
+
100% {
|
|
18
|
+
transform: rotate(380deg);
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/style/css.js
CHANGED
|
@@ -8,9 +8,10 @@ import { colors, component, devices, variables } from './parser/index.js';
|
|
|
8
8
|
import { terminal } from '../internal/terminal.js';
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
10
|
const __dirname = dirname(__filename);
|
|
11
|
-
const __components = path.resolve('src/components');
|
|
12
11
|
export const processCSS = async (config) => {
|
|
13
12
|
const _normalize = fs.readFileSync(path.resolve(__dirname, './normalize.css'), 'utf-8');
|
|
13
|
+
const _animation = fs.readFileSync(path.resolve(__dirname, './animation.css'), 'utf-8');
|
|
14
|
+
const _variables = fs.readFileSync(path.resolve(__dirname, './variable.css'), 'utf-8');
|
|
14
15
|
let styles = ``;
|
|
15
16
|
if (config.options.normalize)
|
|
16
17
|
styles += `${_normalize}\n`;
|
|
@@ -19,10 +20,12 @@ export const processCSS = async (config) => {
|
|
|
19
20
|
const variablesStyles = variables(config);
|
|
20
21
|
styles += `${colorScheme.root}\n`;
|
|
21
22
|
styles += `${variablesStyles}\n`;
|
|
23
|
+
styles += `${variablesStyles}\n`;
|
|
24
|
+
styles += `${_variables}\n`;
|
|
22
25
|
styles += `${colorScheme.className}\n`;
|
|
23
26
|
styles += `${deviceDisplay}\n`;
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
styles += component(config);
|
|
28
|
+
styles += `${_animation}\n`;
|
|
26
29
|
if (config.options.minify) {
|
|
27
30
|
styles = minify(styles);
|
|
28
31
|
terminal('success', 'css minified');
|
|
@@ -65,10 +65,21 @@ export const colors = (config) => {
|
|
|
65
65
|
// class
|
|
66
66
|
let classStyles = '';
|
|
67
67
|
for (const [property] of Object.entries(schemes.light)) {
|
|
68
|
+
// classStyles += `.${property}:not([class*='--variant-']) {\n`;
|
|
69
|
+
// classStyles += `--background-color: var(--kit-${property});\n`;
|
|
70
|
+
// classStyles += `--color: var(--kit-on-${property}, var(--kit-${property}));\n`;
|
|
71
|
+
// classStyles += `}\n`;
|
|
72
|
+
// classStyles += `.${property}[class*='--variant-'] {\n`;
|
|
73
|
+
// classStyles += `--color: var(--kit-${property});\n`;
|
|
74
|
+
// classStyles += `}\n`;
|
|
68
75
|
classStyles += `.${property} {\n`;
|
|
69
|
-
classStyles += `--
|
|
70
|
-
classStyles += `--
|
|
76
|
+
classStyles += `--base: var(--kit-${property});\n`;
|
|
77
|
+
classStyles += `--on: var(--kit-on-${property}, var(--kit-${property}));\n`;
|
|
71
78
|
classStyles += `}\n`;
|
|
79
|
+
// classStyles += `.${property}:not([class*='kit-']) {\n`;
|
|
80
|
+
// classStyles += `background-color: var(--kit-${property});\n`;
|
|
81
|
+
// classStyles += `color: var(--kit-on-${property}, var(--kit-${property}));\n`;
|
|
82
|
+
// classStyles += `}\n`;
|
|
72
83
|
}
|
|
73
84
|
return {
|
|
74
85
|
root: cssVariables,
|
package/dist/utils/x11.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lapikit",
|
|
3
|
-
"version": "0.0.0-insiders.
|
|
3
|
+
"version": "0.0.0-insiders.de81aed",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"publishConfig": {
|
|
5
6
|
"access": "public"
|
|
6
7
|
},
|
|
@@ -25,6 +26,8 @@
|
|
|
25
26
|
"files": [
|
|
26
27
|
"bin",
|
|
27
28
|
"dist",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE",
|
|
28
31
|
"!dist/**/*.test.*",
|
|
29
32
|
"!dist/**/*.spec.*"
|
|
30
33
|
],
|
|
@@ -39,12 +42,18 @@
|
|
|
39
42
|
"type": "module",
|
|
40
43
|
"exports": {
|
|
41
44
|
".": {
|
|
42
|
-
"types": "./dist/index.d.ts"
|
|
43
|
-
|
|
45
|
+
"types": "./dist/index.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./components": {
|
|
48
|
+
"svelte": "./dist/components/index.js",
|
|
49
|
+
"default": "./dist/components/index.js"
|
|
44
50
|
},
|
|
45
51
|
"./vite": {
|
|
46
52
|
"default": "./dist/plugin/vitejs.js"
|
|
47
53
|
},
|
|
54
|
+
"./stores": {
|
|
55
|
+
"default": "./dist/stores/index.js"
|
|
56
|
+
},
|
|
48
57
|
"./css": "./dist/styles.css"
|
|
49
58
|
},
|
|
50
59
|
"peerDependencies": {
|