@nemigo/layout 0.1.0 → 0.1.1
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.
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script module lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<script lang="ts">import { enterKeyHook, preventStop, preventStopHook } from "@nemigo/helpers/html";
|
|
4
|
+
let {
|
|
5
|
+
id,
|
|
6
|
+
label,
|
|
7
|
+
class: className,
|
|
8
|
+
style,
|
|
9
|
+
disabled,
|
|
10
|
+
load,
|
|
11
|
+
onclick: onClick,
|
|
12
|
+
onmousedown,
|
|
13
|
+
onkeydown,
|
|
14
|
+
oncontextmenu,
|
|
15
|
+
children
|
|
16
|
+
} = $props();
|
|
17
|
+
let ariaLabel = $derived(label ?? void 0);
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{#if onClick}
|
|
21
|
+
{@const onclick = preventStopHook(onClick, { condition: () => !load && !disabled })}
|
|
22
|
+
<div
|
|
23
|
+
aria-label={ariaLabel}
|
|
24
|
+
title={ariaLabel}
|
|
25
|
+
aria-busy={load}
|
|
26
|
+
aria-disabled={disabled}
|
|
27
|
+
role="button"
|
|
28
|
+
tabindex="0"
|
|
29
|
+
{id}
|
|
30
|
+
class={[load ? "cursor-wait" : disabled ? "cursor-not-allowed" : "cursor-pointer", className ?? "contents"]}
|
|
31
|
+
{style}
|
|
32
|
+
{oncontextmenu}
|
|
33
|
+
onclick={onmousedown === "onclick" ? preventStop : onclick}
|
|
34
|
+
onkeydown={onkeydown ??
|
|
35
|
+
enterKeyHook(
|
|
36
|
+
(e) => {
|
|
37
|
+
// @ts-expect-error <сужение на уровне типов у компонента>
|
|
38
|
+
oncontextmenu && (e.ctrlKey || e.metaKey) ? oncontextmenu(e) : onClick(e);
|
|
39
|
+
},
|
|
40
|
+
{ condition: () => !load && !disabled }
|
|
41
|
+
)}
|
|
42
|
+
onmousedown={onmousedown === "onclick" ? onclick : (onmousedown ?? undefined)}>
|
|
43
|
+
{@render children()}
|
|
44
|
+
</div>
|
|
45
|
+
{:else}
|
|
46
|
+
<div aria-label={ariaLabel} title={ariaLabel} {id} class={className ?? "contents"} {style}>
|
|
47
|
+
{@render children()}
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { ClassValue, KeyboardEventHandler } from "svelte/elements";
|
|
3
|
+
interface BaseEnterBlockProps {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
class?: ClassValue;
|
|
7
|
+
style?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
load?: boolean;
|
|
10
|
+
onmousedown?: ((e: MouseEvent) => void) | "onclick";
|
|
11
|
+
children: Snippet;
|
|
12
|
+
}
|
|
13
|
+
export interface OnKeydownEnterBlockProps extends BaseEnterBlockProps {
|
|
14
|
+
onclick?: (e: MouseEvent) => void;
|
|
15
|
+
oncontextmenu?: (e: MouseEvent) => void;
|
|
16
|
+
onkeydown: KeyboardEventHandler<HTMLDivElement>;
|
|
17
|
+
}
|
|
18
|
+
export interface NotKeydownEnterBlockProps extends BaseEnterBlockProps {
|
|
19
|
+
onclick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
20
|
+
oncontextmenu?: (e: MouseEvent | KeyboardEvent) => void;
|
|
21
|
+
onkeydown?: undefined;
|
|
22
|
+
}
|
|
23
|
+
export type EnterBlockProps = OnKeydownEnterBlockProps | NotKeydownEnterBlockProps;
|
|
24
|
+
declare const EnterBlock: import("svelte").Component<EnterBlockProps, {}, "">;
|
|
25
|
+
type EnterBlock = ReturnType<typeof EnterBlock>;
|
|
26
|
+
export default EnterBlock;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { LoaderStore } from "@nemigo/svelte/loader";
|
|
2
|
+
export declare const loaderCursorStore: LoaderStore;
|
|
2
3
|
declare const LoaderCursor: import("svelte").Component<Record<string, never>, {}, "">;
|
|
3
4
|
type LoaderCursor = ReturnType<typeof LoaderCursor>;
|
|
4
5
|
export default LoaderCursor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemigo/layout",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Vlad Logvin",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/Context.svelte.d.ts",
|
|
19
19
|
"svelte": "./dist/Context.svelte"
|
|
20
20
|
},
|
|
21
|
+
"./blocks/EnterBlock": {
|
|
22
|
+
"types": "./dist/blocks/EnterBlock.svelte.d.ts",
|
|
23
|
+
"svelte": "./dist/blocks/EnterBlock.svelte"
|
|
24
|
+
},
|
|
21
25
|
"./blocks/LazyBlock": {
|
|
22
26
|
"types": "./dist/blocks/LazyBlock.svelte.d.ts",
|
|
23
27
|
"svelte": "./dist/blocks/LazyBlock.svelte"
|
|
@@ -28,9 +32,9 @@
|
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"peerDependencies": {
|
|
31
|
-
"@nemigo/helpers": "
|
|
32
|
-
"@nemigo/svelte": "
|
|
33
|
-
"svelte": "
|
|
35
|
+
"@nemigo/helpers": ">=0.7.0",
|
|
36
|
+
"@nemigo/svelte": ">=0.3.0",
|
|
37
|
+
"svelte": ">=5.0.0"
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
36
40
|
"@nemigo/configs": "workspace:*",
|