lapikit 0.0.0-insiders.fbbc9f6 → 0.0.0-insiders.fbd9b54
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 +22 -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/prompts.js +101 -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 +2 -0
- package/dist/assets/icons/loading-fill.svelte.d.ts +6 -14
- 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 +31 -2
- 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 +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 +231 -0
- package/dist/components/chip/chip.svelte +129 -0
- package/dist/components/chip/chip.svelte.d.ts +4 -0
- package/dist/components/chip/types.d.ts +31 -0
- package/dist/components/chip/types.js +1 -0
- package/dist/components/dialog/dialog.css +134 -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 +14 -11
- package/dist/components/index.d.ts +20 -1
- package/dist/components/index.js +20 -1
- 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 +144 -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/internal/assets.svelte.d.ts +1 -0
- package/dist/internal/assets.svelte.js +13 -0
- package/dist/internal/clickOutside.d.ts +9 -0
- package/dist/internal/clickOutside.js +34 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +1 -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/unit.d.ts +1 -0
- package/dist/internal/unit.js +11 -0
- package/dist/preset.js +2 -2
- package/dist/stores/index.d.ts +9 -3
- package/dist/stores/index.js +27 -3
- package/dist/style/animation.css +42 -0
- package/dist/style/css.js +3 -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/style/variable.css +12 -0
- package/package.json +12 -4
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getAssets } from '../../internal/index.js';
|
|
3
|
+
import type { TextfieldProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
//external
|
|
6
|
+
import { Icon } from '../index.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
ref = $bindable(),
|
|
10
|
+
prepend,
|
|
11
|
+
append,
|
|
12
|
+
prependInner,
|
|
13
|
+
appendInner,
|
|
14
|
+
value = $bindable(),
|
|
15
|
+
type = 'text',
|
|
16
|
+
density = 'default',
|
|
17
|
+
size = 'md',
|
|
18
|
+
variant = 'filled',
|
|
19
|
+
placeholder,
|
|
20
|
+
light,
|
|
21
|
+
dark,
|
|
22
|
+
counter,
|
|
23
|
+
min,
|
|
24
|
+
max,
|
|
25
|
+
prefix,
|
|
26
|
+
suffix,
|
|
27
|
+
message,
|
|
28
|
+
messagePrefix,
|
|
29
|
+
messageSuffix,
|
|
30
|
+
clearable,
|
|
31
|
+
persistentClear,
|
|
32
|
+
disabled,
|
|
33
|
+
error,
|
|
34
|
+
errorMessage,
|
|
35
|
+
persistentMessage,
|
|
36
|
+
hideSpinButtons, // only type="number"
|
|
37
|
+
readonly,
|
|
38
|
+
color,
|
|
39
|
+
background,
|
|
40
|
+
rounded,
|
|
41
|
+
...rest
|
|
42
|
+
}: TextfieldProps = $props();
|
|
43
|
+
|
|
44
|
+
const assets = getAssets();
|
|
45
|
+
|
|
46
|
+
let counterValue: number = $state(0);
|
|
47
|
+
let displayMessage: boolean = $state(false);
|
|
48
|
+
let displayClear: boolean = $state(false);
|
|
49
|
+
|
|
50
|
+
const inputClear = () => {
|
|
51
|
+
value = undefined;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const handleFocus = () => {
|
|
55
|
+
if (!error && !persistentMessage) displayMessage = true;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const handleBlur = () => {
|
|
59
|
+
if (!error && !persistentMessage) displayMessage = false;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
$effect(() => {
|
|
63
|
+
if (persistentClear) displayClear = true;
|
|
64
|
+
if (persistentMessage) displayMessage = true;
|
|
65
|
+
else if (error) displayMessage = true;
|
|
66
|
+
else if (!error) displayMessage = false;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
$effect(() => {
|
|
70
|
+
const valueStr = value?.toString() || '';
|
|
71
|
+
|
|
72
|
+
if (valueStr && typeof max === 'number' && max > 0 && valueStr.length > max) {
|
|
73
|
+
const truncated = valueStr.slice(0, max);
|
|
74
|
+
if (typeof value === 'number') {
|
|
75
|
+
const numValue = Number(truncated);
|
|
76
|
+
value = isNaN(numValue) ? undefined : numValue;
|
|
77
|
+
} else {
|
|
78
|
+
value = truncated;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
counterValue = valueStr.length;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
$effect(() => {
|
|
86
|
+
if (!persistentClear) {
|
|
87
|
+
if (value) displayClear = true;
|
|
88
|
+
else displayClear = false;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<div
|
|
94
|
+
bind:this={ref}
|
|
95
|
+
{...rest}
|
|
96
|
+
class={[
|
|
97
|
+
'kit-textfield',
|
|
98
|
+
light && 'light',
|
|
99
|
+
dark && 'dark',
|
|
100
|
+
size && assets.className('textfield', 'size', size),
|
|
101
|
+
variant && assets.className('textfield', 'variant', variant),
|
|
102
|
+
density && assets.className('textfield', 'density', density),
|
|
103
|
+
disabled && 'kit-textfield--disabled',
|
|
104
|
+
readonly && 'kit-textfield--readonly',
|
|
105
|
+
error && 'kit-textfield--error',
|
|
106
|
+
type === 'number' && hideSpinButtons && 'kit-textfield--hide-spin-buttons',
|
|
107
|
+
rest.class
|
|
108
|
+
]}
|
|
109
|
+
style:--base={assets.color(background)}
|
|
110
|
+
style:--on={assets.color(color)}
|
|
111
|
+
style:--shape={assets.shape(rounded)}
|
|
112
|
+
>
|
|
113
|
+
{#if prepend}
|
|
114
|
+
<div class="kit-textfield-prepend">
|
|
115
|
+
{@render prepend?.()}
|
|
116
|
+
</div>
|
|
117
|
+
{/if}
|
|
118
|
+
<div class="kit-textfield-control">
|
|
119
|
+
<div class="kit-field">
|
|
120
|
+
{#if prependInner}
|
|
121
|
+
<div class="kit-textfield-prepend-inner">
|
|
122
|
+
{@render prependInner?.()}
|
|
123
|
+
</div>
|
|
124
|
+
{/if}
|
|
125
|
+
<div class="kit-field--field">
|
|
126
|
+
{#if prefix}
|
|
127
|
+
<span class="kit-field--field-prefix">
|
|
128
|
+
<span class="kit-textfield--field-prefix--text">{prefix}</span>
|
|
129
|
+
</span>
|
|
130
|
+
{/if}
|
|
131
|
+
<input
|
|
132
|
+
{type}
|
|
133
|
+
size="1"
|
|
134
|
+
{placeholder}
|
|
135
|
+
bind:value
|
|
136
|
+
onfocus={handleFocus}
|
|
137
|
+
onblur={handleBlur}
|
|
138
|
+
{...max && { maxlength: max }}
|
|
139
|
+
{...min && { minlength: min }}
|
|
140
|
+
{...disabled && { disabled: true }}
|
|
141
|
+
{...readonly && { readonly: true }}
|
|
142
|
+
/>
|
|
143
|
+
{#if suffix}
|
|
144
|
+
<span class="kit-field--field-suffix">
|
|
145
|
+
<span class="kit-textfield--field-suffix--text">{suffix}</span>
|
|
146
|
+
</span>
|
|
147
|
+
{/if}
|
|
148
|
+
</div>
|
|
149
|
+
{#if clearable}
|
|
150
|
+
<div
|
|
151
|
+
class={['kit-textfield-clearable', displayClear && 'kit-textfield-clearable--visible']}
|
|
152
|
+
>
|
|
153
|
+
<Icon icon="mgc_close_circle_fill" onclick={() => inputClear()} />
|
|
154
|
+
</div>
|
|
155
|
+
{/if}
|
|
156
|
+
|
|
157
|
+
{#if appendInner}
|
|
158
|
+
<div class="kit-textfield-append-inner">
|
|
159
|
+
{@render appendInner?.()}
|
|
160
|
+
</div>
|
|
161
|
+
{/if}
|
|
162
|
+
|
|
163
|
+
<div class="kit-textfield-outline"></div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
{#if append}
|
|
167
|
+
<div class="kit-textfield-append">
|
|
168
|
+
{@render append?.()}
|
|
169
|
+
</div>
|
|
170
|
+
{/if}
|
|
171
|
+
|
|
172
|
+
<div class={['kit-textfield-message', displayMessage && 'kit-textfield-message--visible']}>
|
|
173
|
+
<div class={['kit-message', error && 'kit-message--message-error']}>
|
|
174
|
+
{#if messagePrefix}
|
|
175
|
+
<div class="kit-message--prepend">{messagePrefix}</div>
|
|
176
|
+
{/if}
|
|
177
|
+
{#if message || error}
|
|
178
|
+
<div class="kit-message--message">
|
|
179
|
+
{error ? errorMessage || message : message}
|
|
180
|
+
</div>
|
|
181
|
+
{/if}
|
|
182
|
+
{#if counter || messageSuffix}
|
|
183
|
+
<div class="kit-message--append">
|
|
184
|
+
{#if counter}
|
|
185
|
+
{counterValue}{max ? `/${max}` : ''}
|
|
186
|
+
{:else if messageSuffix}
|
|
187
|
+
{messageSuffix}
|
|
188
|
+
{/if}
|
|
189
|
+
</div>
|
|
190
|
+
{/if}
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Component } from '../../internal/types.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface TextfieldProps extends Component {
|
|
4
|
+
ref?: HTMLElement | null;
|
|
5
|
+
dark?: boolean;
|
|
6
|
+
light?: boolean;
|
|
7
|
+
value?: string | number;
|
|
8
|
+
type?: 'text' | 'email' | 'password' | 'number';
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
counter?: boolean;
|
|
11
|
+
min?: number;
|
|
12
|
+
max?: number;
|
|
13
|
+
variant?: 'outline' | 'text' | 'filled';
|
|
14
|
+
density?: 'compact' | 'comfortable' | 'default';
|
|
15
|
+
error?: boolean;
|
|
16
|
+
errorMessage?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
color?: string;
|
|
19
|
+
background?: string;
|
|
20
|
+
size?: string | {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
hideSpinButtons?: boolean;
|
|
25
|
+
persistentMessage?: boolean;
|
|
26
|
+
persistentClear?: boolean;
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
message?: string;
|
|
29
|
+
messagePrefix?: string;
|
|
30
|
+
messageSuffix?: string;
|
|
31
|
+
append?: Snippet;
|
|
32
|
+
prepend?: Snippet;
|
|
33
|
+
prependInner?: Snippet;
|
|
34
|
+
appendInner?: Snippet;
|
|
35
|
+
prefix?: string;
|
|
36
|
+
suffix?: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
.kit-tooltip {
|
|
2
|
+
inset: 0px auto auto 0px;
|
|
3
|
+
margin: 0px;
|
|
4
|
+
position: fixed;
|
|
5
|
+
z-index: 2000;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.kit-tooltip-content {
|
|
9
|
+
--tooltip-color: var(--on, var(--kit-on-surface));
|
|
10
|
+
--tooltip-background: var(--base, var(--kit-surface));
|
|
11
|
+
--tooltip-radius: var(--shape, var(--kit-radius-md));
|
|
12
|
+
|
|
13
|
+
background-color: var(--tooltip-background);
|
|
14
|
+
color: var(--tooltip-color);
|
|
15
|
+
border-radius: var(--tooltip-radius);
|
|
16
|
+
border: 1px solid var(--tooltip-background);
|
|
17
|
+
font-size: 0.875rem;
|
|
18
|
+
display: inline-block;
|
|
19
|
+
width: auto;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
overflow-wrap: break-word;
|
|
22
|
+
/* transition:
|
|
23
|
+
color 0.5s,
|
|
24
|
+
border-color 0.5s,
|
|
25
|
+
background-color 0.5s; */
|
|
26
|
+
box-shadow: 0px 16px 29px -10px color-mix(in oklab, var(--kit-scrim) 60%, transparent);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* density */
|
|
30
|
+
.kit-tooltip-content[breakpoint]kit-tooltip-content--density-default {
|
|
31
|
+
padding: 0.15rem 0.625rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.kit-tooltip-content[breakpoint]kit-tooltip-content--density-compact {
|
|
35
|
+
padding: 0.125rem 0.5rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.kit-tooltip-content[breakpoint]kit-tooltip-content--density-comfortable {
|
|
39
|
+
padding: 0.35rem 0.75rem;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.kit-tooltip-content--arrow::after {
|
|
43
|
+
content: ' ';
|
|
44
|
+
position: absolute;
|
|
45
|
+
border-style: solid;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--bottom::after,
|
|
49
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--top::after {
|
|
50
|
+
left: 50%;
|
|
51
|
+
margin-left: -0.35rem;
|
|
52
|
+
border-width: 0.35rem;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--bottom::after {
|
|
56
|
+
bottom: 100%;
|
|
57
|
+
border-color: transparent transparent var(--tooltip-background) transparent;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--top::after {
|
|
61
|
+
top: 100%;
|
|
62
|
+
border-color: var(--tooltip-background) transparent transparent transparent;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--left::after,
|
|
66
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--right::after {
|
|
67
|
+
top: 50%;
|
|
68
|
+
margin-top: -0.35rem;
|
|
69
|
+
border-width: 0.35rem;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--right::after {
|
|
73
|
+
right: 100%;
|
|
74
|
+
border-color: transparent var(--tooltip-background) transparent transparent;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.kit-tooltip-content--arrow.kit-tooltip-content--left::after {
|
|
78
|
+
left: 100%;
|
|
79
|
+
border-color: transparent transparent transparent var(--tooltip-background);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.kit-tooltip-content--top,
|
|
83
|
+
.kit-tooltip-content--bottom,
|
|
84
|
+
.kit-tooltip-content--right,
|
|
85
|
+
.kit-tooltip-content--left {
|
|
86
|
+
animation-duration: 150ms;
|
|
87
|
+
animation-name: enter;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.kit-tooltip-content--top {
|
|
91
|
+
--animate-enter-pos1: 0;
|
|
92
|
+
--animate-enter-pos2: 0.5rem;
|
|
93
|
+
--animate-enter-pos3: 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.kit-tooltip-content--bottom {
|
|
97
|
+
--animate-enter-pos1: 0;
|
|
98
|
+
--animate-enter-pos2: -0.5rem;
|
|
99
|
+
--animate-enter-pos3: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.kit-tooltip-content--right {
|
|
103
|
+
--animate-enter-pos1: -0.5rem;
|
|
104
|
+
--animate-enter-pos2: 0;
|
|
105
|
+
--animate-enter-pos3: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.kit-tooltip-content--left {
|
|
109
|
+
--animate-enter-pos1: 0.5rem;
|
|
110
|
+
--animate-enter-pos2: 0;
|
|
111
|
+
--animate-enter-pos3: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@keyframes enter {
|
|
115
|
+
0% {
|
|
116
|
+
opacity: 0;
|
|
117
|
+
transform: translate3d(
|
|
118
|
+
var(--animate-enter-pos1),
|
|
119
|
+
var(--animate-enter-pos2),
|
|
120
|
+
var(--animate-enter-pos3)
|
|
121
|
+
)
|
|
122
|
+
scale3d(0.95, 0.95, 0.95) rotate(0);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -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}
|