@yoyaflow/yoya-ui 0.1.0
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/README.md +198 -0
- package/README.zh-CN.md +199 -0
- package/dist/echarts.min.js +45 -0
- package/dist/yoya-ui.umd.js +35 -0
- package/dist/yoya.core.js +1674 -0
- package/dist/yoya.echart.js +636 -0
- package/dist/yoya.ssr.js +491 -0
- package/dist/yoya.ui.css +2010 -0
- package/dist/yoya.ui.js +11899 -0
- package/package.json +94 -0
- package/types/actions.d.ts +166 -0
- package/types/async.d.ts +58 -0
- package/types/chart.d.ts +40 -0
- package/types/core.d.ts +495 -0
- package/types/css.d.ts +5 -0
- package/types/data-display.d.ts +518 -0
- package/types/effects.d.ts +40 -0
- package/types/feedback.d.ts +119 -0
- package/types/form.d.ts +486 -0
- package/types/html.d.ts +288 -0
- package/types/i18n.d.ts +56 -0
- package/types/index.d.ts +4 -0
- package/types/layout.d.ts +429 -0
- package/types/navigation.d.ts +275 -0
- package/types/router.d.ts +123 -0
- package/types/ssr.d.ts +81 -0
- package/types/svg.d.ts +158 -0
- package/types/theme.d.ts +40 -0
- package/types/yoya.core.d.ts +7 -0
- package/types/yoya.echart.d.ts +4 -0
- package/types/yoya.ssr.d.ts +4 -0
- package/types/yoya.ui.d.ts +19 -0
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yoyaflow/yoya-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A browser-native UI library that replaces React/Vue-style frameworks: declarative HTML authoring, component library, router, i18n and layout, with zero build steps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"main": "./dist/yoya-ui.umd.js",
|
|
8
|
+
"module": "./dist/yoya.ui.js",
|
|
9
|
+
"style": "./dist/yoya.ui.css",
|
|
10
|
+
"types": "./types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./types/index.d.ts",
|
|
14
|
+
"import": "./dist/yoya.ui.js",
|
|
15
|
+
"require": "./dist/yoya-ui.umd.js"
|
|
16
|
+
},
|
|
17
|
+
"./core": {
|
|
18
|
+
"types": "./types/yoya.core.d.ts",
|
|
19
|
+
"import": "./dist/yoya.core.js"
|
|
20
|
+
},
|
|
21
|
+
"./echart": {
|
|
22
|
+
"types": "./types/yoya.echart.d.ts",
|
|
23
|
+
"import": "./dist/yoya.echart.js"
|
|
24
|
+
},
|
|
25
|
+
"./ssr": {
|
|
26
|
+
"types": "./types/yoya.ssr.d.ts",
|
|
27
|
+
"import": "./dist/yoya.ssr.js"
|
|
28
|
+
},
|
|
29
|
+
"./ui": {
|
|
30
|
+
"types": "./types/index.d.ts",
|
|
31
|
+
"import": "./dist/yoya.ui.js"
|
|
32
|
+
},
|
|
33
|
+
"./ui.css": "./dist/yoya.ui.css",
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"types",
|
|
39
|
+
"!types/tests",
|
|
40
|
+
"!dist/examples"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "node scripts/build-entries.mjs && vite build --config vite.umd.config.js && vite build --config vite.examples.config.js && node scripts/copy-example-modules.mjs",
|
|
44
|
+
"build:entries": "node scripts/build-entries.mjs",
|
|
45
|
+
"build:examples": "vite build --config vite.examples.config.js && node scripts/copy-example-modules.mjs",
|
|
46
|
+
"build:umd": "vite build --config vite.umd.config.js",
|
|
47
|
+
"examples:html": "vite --config vite.examples.config.js --host 0.0.0.0",
|
|
48
|
+
"examples:i18n": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5174",
|
|
49
|
+
"examples:layout": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5175",
|
|
50
|
+
"examples:svg": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5176",
|
|
51
|
+
"examples:router": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5177",
|
|
52
|
+
"examples:admin": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5179",
|
|
53
|
+
"examples:components": "vite --config vite.examples.config.js --host 0.0.0.0 --port 5178",
|
|
54
|
+
"format": "prettier --write .",
|
|
55
|
+
"format:check": "prettier --check .",
|
|
56
|
+
"lint": "eslint .",
|
|
57
|
+
"lint:fix": "eslint . --fix",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"test:watch": "vitest",
|
|
60
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
61
|
+
"test:types": "npm run typecheck"
|
|
62
|
+
},
|
|
63
|
+
"keywords": [
|
|
64
|
+
"vite",
|
|
65
|
+
"vanilla-js",
|
|
66
|
+
"ui",
|
|
67
|
+
"web-components",
|
|
68
|
+
"frontend"
|
|
69
|
+
],
|
|
70
|
+
"author": "zhanglj",
|
|
71
|
+
"license": "MIT",
|
|
72
|
+
"repository": {
|
|
73
|
+
"type": "git",
|
|
74
|
+
"url": "git+https://github.com/yoyaflow/yoya-ui.git"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/yoyaflow/yoya-ui#readme",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/yoyaflow/yoya-ui/issues"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": "^20.19.0 || ^22.13.0 || >=24.0.0"
|
|
82
|
+
},
|
|
83
|
+
"devDependencies": {
|
|
84
|
+
"@eslint/js": "^10.0.1",
|
|
85
|
+
"@preact/signals-core": "^1.14.4",
|
|
86
|
+
"eslint": "^10.8.1",
|
|
87
|
+
"globals": "^17.11.0",
|
|
88
|
+
"jsdom": "^29.1.1",
|
|
89
|
+
"prettier": "^3.9.6",
|
|
90
|
+
"typescript": "^7.0.2",
|
|
91
|
+
"vite": "^8.2.0",
|
|
92
|
+
"vitest": "^4.1.10"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AttrValue,
|
|
3
|
+
ChildInput,
|
|
4
|
+
ElementFactory,
|
|
5
|
+
ElementOptions,
|
|
6
|
+
SetupCallback,
|
|
7
|
+
SetupInput
|
|
8
|
+
} from './core.js';
|
|
9
|
+
import type { HtmlElementNode } from './html.js';
|
|
10
|
+
|
|
11
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
12
|
+
export type ButtonSize = 'small' | 'medium' | 'large';
|
|
13
|
+
export type ButtonFormType = 'button' | 'submit' | 'reset';
|
|
14
|
+
export type DropdownPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
|
|
15
|
+
|
|
16
|
+
/** Compound button component. */
|
|
17
|
+
export class VButton extends HtmlElementNode {
|
|
18
|
+
label(content: ChildInput): VButton;
|
|
19
|
+
content(content: ChildInput): VButton;
|
|
20
|
+
type(): ButtonVariant;
|
|
21
|
+
type(value: ButtonVariant): VButton;
|
|
22
|
+
variant(): ButtonVariant;
|
|
23
|
+
variant(value: ButtonVariant): VButton;
|
|
24
|
+
formType(): string;
|
|
25
|
+
formType(value: ButtonFormType): VButton;
|
|
26
|
+
size(): ButtonSize;
|
|
27
|
+
size(value: ButtonSize): VButton;
|
|
28
|
+
disabled(): boolean;
|
|
29
|
+
disabled(value: boolean): VButton;
|
|
30
|
+
loading(): boolean;
|
|
31
|
+
loading(value: boolean): VButton;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Button group with selection state. */
|
|
35
|
+
export class VButtons extends HtmlElementNode {
|
|
36
|
+
child(...children: ChildInput[]): this;
|
|
37
|
+
variant(): ButtonVariant;
|
|
38
|
+
variant(value: ButtonVariant): VButtons;
|
|
39
|
+
size(): ButtonSize;
|
|
40
|
+
size(value: ButtonSize): VButtons;
|
|
41
|
+
selectable(value?: boolean): VButtons;
|
|
42
|
+
value(): unknown;
|
|
43
|
+
value(next: unknown): VButtons;
|
|
44
|
+
change(): ((value: unknown, buttons: VButtons) => void) | null;
|
|
45
|
+
change(handler: ((value: unknown, buttons: VButtons) => void) | null): VButtons;
|
|
46
|
+
joined(value?: boolean): VButtons;
|
|
47
|
+
disabled(value: boolean): VButtons;
|
|
48
|
+
options(): VButton[];
|
|
49
|
+
options(
|
|
50
|
+
items:
|
|
51
|
+
VButton | string | number | ButtonOption | Array<VButton | string | number | ButtonOption>
|
|
52
|
+
): VButtons;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ButtonOption {
|
|
56
|
+
label?: ChildInput;
|
|
57
|
+
value?: unknown;
|
|
58
|
+
variant?: ButtonVariant;
|
|
59
|
+
size?: ButtonSize;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Floating action button. */
|
|
65
|
+
export class VFloatButton extends HtmlElementNode {
|
|
66
|
+
icon(content: ChildInput): VFloatButton;
|
|
67
|
+
label(content: ChildInput): VFloatButton;
|
|
68
|
+
content(content: ChildInput): VFloatButton;
|
|
69
|
+
text(content: ChildInput): this;
|
|
70
|
+
variant(): ButtonVariant;
|
|
71
|
+
variant(value: ButtonVariant): VFloatButton;
|
|
72
|
+
type(): ButtonVariant;
|
|
73
|
+
type(value: ButtonVariant): VFloatButton;
|
|
74
|
+
size(): ButtonSize;
|
|
75
|
+
size(value: ButtonSize): VFloatButton;
|
|
76
|
+
disabled(): boolean;
|
|
77
|
+
disabled(value: boolean): VFloatButton;
|
|
78
|
+
fixed(value?: boolean): VFloatButton;
|
|
79
|
+
position(): string;
|
|
80
|
+
position(value: string): VFloatButton;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Icon/symbol-only button without border or outline. */
|
|
84
|
+
export class VSymbolButton extends HtmlElementNode {
|
|
85
|
+
icon(content: ChildInput): VSymbolButton;
|
|
86
|
+
ariaLabel(): AttrValue | undefined;
|
|
87
|
+
ariaLabel(value: string): VSymbolButton;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Dropdown menu anchored to a trigger. */
|
|
91
|
+
export class VDropdownMenu extends HtmlElementNode {
|
|
92
|
+
trigger(): HtmlElementNode;
|
|
93
|
+
trigger(setup: SetupInput<HtmlElementNode>): VDropdownMenu;
|
|
94
|
+
menuContent(): HtmlElementNode;
|
|
95
|
+
menuContent(setup: SetupInput<HtmlElementNode>): VDropdownMenu;
|
|
96
|
+
placement(): string;
|
|
97
|
+
placement(value: DropdownPlacement): VDropdownMenu;
|
|
98
|
+
closeOnSelect(value?: boolean): VDropdownMenu;
|
|
99
|
+
open(value?: boolean): VDropdownMenu;
|
|
100
|
+
close(): VDropdownMenu;
|
|
101
|
+
toggle(): VDropdownMenu;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Right-click context menu. */
|
|
105
|
+
export class VContextMenu extends HtmlElementNode {
|
|
106
|
+
target(): HtmlElementNode;
|
|
107
|
+
target(setup: SetupInput<HtmlElementNode>): VContextMenu;
|
|
108
|
+
menuContent(): HtmlElementNode;
|
|
109
|
+
menuContent(setup: SetupInput<HtmlElementNode>): VContextMenu;
|
|
110
|
+
closeOnSelect(value?: boolean): VContextMenu;
|
|
111
|
+
openAt(
|
|
112
|
+
pointOrX?: number | MouseEvent | { clientX?: number; clientY?: number; x?: number; y?: number },
|
|
113
|
+
y?: number
|
|
114
|
+
): VContextMenu;
|
|
115
|
+
open(value?: boolean): VContextMenu;
|
|
116
|
+
close(): VContextMenu;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const vButton: ElementFactory<VButton> & {
|
|
120
|
+
(first?: SetupInput<VButton> | null, callback?: SetupCallback<VButton>): VButton;
|
|
121
|
+
};
|
|
122
|
+
export const vButtons: ElementFactory<VButtons> & {
|
|
123
|
+
(first?: SetupInput<VButtons> | null, callback?: SetupCallback<VButtons>): VButtons;
|
|
124
|
+
};
|
|
125
|
+
export const vFloatButton: ElementFactory<VFloatButton> & {
|
|
126
|
+
(first?: SetupInput<VFloatButton> | null, callback?: SetupCallback<VFloatButton>): VFloatButton;
|
|
127
|
+
};
|
|
128
|
+
export const vSymbolButton: ElementFactory<VSymbolButton> & {
|
|
129
|
+
(
|
|
130
|
+
first?: SetupInput<VSymbolButton> | null,
|
|
131
|
+
callback?: SetupCallback<VSymbolButton>
|
|
132
|
+
): VSymbolButton;
|
|
133
|
+
};
|
|
134
|
+
export const vDropdownMenu: ElementFactory<VDropdownMenu> & {
|
|
135
|
+
(
|
|
136
|
+
first?: SetupInput<VDropdownMenu> | null,
|
|
137
|
+
callback?: SetupCallback<VDropdownMenu>
|
|
138
|
+
): VDropdownMenu;
|
|
139
|
+
};
|
|
140
|
+
export const vContextMenu: ElementFactory<VContextMenu> & {
|
|
141
|
+
(first?: SetupInput<VContextMenu> | null, callback?: SetupCallback<VContextMenu>): VContextMenu;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/** Parent-shortcut surface merged onto HtmlElementNode. */
|
|
145
|
+
export interface ActionsParentShortcuts {
|
|
146
|
+
vButton(first?: SetupInput<VButton> | null, callback?: SetupCallback<VButton>): VButton;
|
|
147
|
+
vButtons(first?: SetupInput<VButtons> | null, callback?: SetupCallback<VButtons>): VButtons;
|
|
148
|
+
vFloatButton(
|
|
149
|
+
first?: SetupInput<VFloatButton> | null,
|
|
150
|
+
callback?: SetupCallback<VFloatButton>
|
|
151
|
+
): VFloatButton;
|
|
152
|
+
vSymbolButton(
|
|
153
|
+
first?: SetupInput<VSymbolButton> | null,
|
|
154
|
+
callback?: SetupCallback<VSymbolButton>
|
|
155
|
+
): VSymbolButton;
|
|
156
|
+
vDropdownMenu(
|
|
157
|
+
first?: SetupInput<VDropdownMenu> | null,
|
|
158
|
+
callback?: SetupCallback<VDropdownMenu>
|
|
159
|
+
): VDropdownMenu;
|
|
160
|
+
vContextMenu(
|
|
161
|
+
first?: SetupInput<VContextMenu> | null,
|
|
162
|
+
callback?: SetupCallback<VContextMenu>
|
|
163
|
+
): VContextMenu;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type { ElementOptions };
|
package/types/async.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ChildInput, ElementNode, ElementOptions, SetupCallback, SetupInput } from './core.js';
|
|
2
|
+
|
|
3
|
+
export type DynamicLoaderStatus = 'pending' | 'loading' | 'loaded' | 'error';
|
|
4
|
+
|
|
5
|
+
export interface DynamicLoaderViews {
|
|
6
|
+
pending?: ChildInput | ((payload: unknown, node: DynamicLoaderNode) => ChildInput);
|
|
7
|
+
loading?: ChildInput | ((payload: unknown, node: DynamicLoaderNode) => ChildInput);
|
|
8
|
+
loaded?: ChildInput | ((payload: unknown, node: DynamicLoaderNode) => ChildInput);
|
|
9
|
+
error?: ChildInput | ((payload: unknown, node: DynamicLoaderNode) => ChildInput);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DynamicLoaderOptions {
|
|
13
|
+
loader: () => unknown | Promise<unknown>;
|
|
14
|
+
auto?: boolean;
|
|
15
|
+
cacheKey?: string | null;
|
|
16
|
+
onStateChange?: (status: DynamicLoaderStatus, payload: unknown, node: DynamicLoaderNode) => void;
|
|
17
|
+
views?: DynamicLoaderViews;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Lazy module loader node with status views. */
|
|
21
|
+
export interface DynamicLoaderNode extends ElementNode {
|
|
22
|
+
status(): DynamicLoaderStatus;
|
|
23
|
+
state(): DynamicLoaderStatus;
|
|
24
|
+
module(): unknown;
|
|
25
|
+
value(): unknown;
|
|
26
|
+
loadError(): unknown;
|
|
27
|
+
error(): unknown;
|
|
28
|
+
load(): Promise<unknown>;
|
|
29
|
+
retry(): Promise<unknown>;
|
|
30
|
+
preload(): Promise<unknown>;
|
|
31
|
+
clearCache(): DynamicLoaderNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Creates a lazy-loading node; loader may be a function or a cache-keyed option object. */
|
|
35
|
+
export function vDynamicLoader(
|
|
36
|
+
first?:
|
|
37
|
+
| DynamicLoaderOptions
|
|
38
|
+
| (() => unknown | Promise<unknown>)
|
|
39
|
+
| SetupCallback<DynamicLoaderNode>
|
|
40
|
+
| null,
|
|
41
|
+
options?: ElementOptions,
|
|
42
|
+
callback?: SetupCallback<DynamicLoaderNode>
|
|
43
|
+
): DynamicLoaderNode;
|
|
44
|
+
|
|
45
|
+
/** Preloads a module into the shared cache. */
|
|
46
|
+
export function preloadDynamicModule(
|
|
47
|
+
cacheKey: string,
|
|
48
|
+
loader: () => unknown | Promise<unknown>
|
|
49
|
+
): Promise<unknown>;
|
|
50
|
+
|
|
51
|
+
/** Clears the shared module cache (all entries when cacheKey is omitted). */
|
|
52
|
+
export function clearDynamicModuleCache(cacheKey?: string | null): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Parent-shortcut surface merged onto HtmlElementNode. vDynamicLoader is
|
|
56
|
+
* registered on ElementNode and inherited, so it is declared there.
|
|
57
|
+
*/
|
|
58
|
+
export interface AsyncParentShortcuts {}
|
package/types/chart.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ElementFactory, ElementOptions, SetupCallback, SetupInput } from './core.js';
|
|
2
|
+
import type { HtmlElementNode } from './html.js';
|
|
3
|
+
|
|
4
|
+
/** Minimal ECharts module shape accepted by echartsLib(). */
|
|
5
|
+
export interface EChartsLib {
|
|
6
|
+
init(element: HTMLElement, theme?: unknown, opts?: unknown): unknown;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** ECharts component (the echarts library itself is not bundled). */
|
|
11
|
+
export class VEchart extends HtmlElementNode {
|
|
12
|
+
echartsLib(lib: EChartsLib): VEchart;
|
|
13
|
+
option(value: Record<string, any>): VEchart;
|
|
14
|
+
width(): number | string;
|
|
15
|
+
width(value: number | string): VEchart;
|
|
16
|
+
height(): number | string;
|
|
17
|
+
height(value: number | string): VEchart;
|
|
18
|
+
theme(value: string): VEchart;
|
|
19
|
+
renderer(value: 'canvas' | 'svg' | string): VEchart;
|
|
20
|
+
devicePixelRatio(value: number): VEchart;
|
|
21
|
+
autoResize(value: boolean): VEchart;
|
|
22
|
+
loading(value: boolean, text?: string): VEchart;
|
|
23
|
+
onChartReady(callback: (chart: unknown) => void): VEchart;
|
|
24
|
+
onChartResize(callback: (width: number, height: number) => void): VEchart;
|
|
25
|
+
getChartInstance(): unknown;
|
|
26
|
+
resize(opts?: { width?: number | string; height?: number | string }): VEchart;
|
|
27
|
+
clear(): VEchart;
|
|
28
|
+
dispose(): VEchart;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const vEchart: ElementFactory<VEchart> & {
|
|
32
|
+
(first?: SetupInput<VEchart> | null, callback?: SetupCallback<VEchart>): VEchart;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Parent-shortcut surface merged onto HtmlElementNode. */
|
|
36
|
+
export interface ChartParentShortcuts {
|
|
37
|
+
vEchart(first?: SetupInput<VEchart> | null, callback?: SetupCallback<VEchart>): VEchart;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type { ElementOptions };
|