@wsxjs/wsx-base-components 0.0.5
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 +204 -0
- package/dist/index.cjs +6 -0
- package/dist/index.js +1085 -0
- package/package.json +57 -0
- package/src/ColorPicker.css +188 -0
- package/src/ColorPicker.wsx +416 -0
- package/src/ColorPickerUtils.ts +116 -0
- package/src/ReactiveCounter.css +304 -0
- package/src/ReactiveCounter.wsx +244 -0
- package/src/SimpleReactiveDemo.wsx +58 -0
- package/src/SvgDemo.wsx +241 -0
- package/src/SvgIcon.wsx +88 -0
- package/src/ThemeSwitcher.css +91 -0
- package/src/ThemeSwitcher.wsx +97 -0
- package/src/XyButton.css +257 -0
- package/src/XyButton.wsx +356 -0
- package/src/XyButtonGroup.css +30 -0
- package/src/XyButtonGroup.wsx +124 -0
- package/src/index.ts +17 -0
- package/src/jsx-inject.ts +2 -0
- package/src/types/wsx.d.ts +6 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** @jsxImportSource @wsxjs/wsx-core */
|
|
2
|
+
/**
|
|
3
|
+
* XyButtonGroup WSX Component - 迁移自xy-button.js
|
|
4
|
+
*
|
|
5
|
+
* 用于将多个xy-button组合成一个按钮组,
|
|
6
|
+
* 提供统一的样式和布局管理
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { WebComponent, autoRegister } from "@wsxjs/wsx-core";
|
|
10
|
+
import styles from "./XyButtonGroup.css?inline";
|
|
11
|
+
|
|
12
|
+
export interface XyButtonGroupConfig {
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@autoRegister({ tagName: "xy-button-group" })
|
|
17
|
+
export default class XyButtonGroup extends WebComponent {
|
|
18
|
+
private disabled: boolean = false;
|
|
19
|
+
|
|
20
|
+
static get observedAttributes(): string[] {
|
|
21
|
+
return ["disabled"];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor(config: XyButtonGroupConfig = {}) {
|
|
25
|
+
super({
|
|
26
|
+
styles,
|
|
27
|
+
styleName: "xy-button-group",
|
|
28
|
+
...config,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
this.disabled = config.disabled || false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
render(): HTMLElement {
|
|
35
|
+
return (
|
|
36
|
+
<div class="button-group-container">
|
|
37
|
+
<slot />
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 属性变化处理
|
|
44
|
+
*/
|
|
45
|
+
protected onAttributeChanged(
|
|
46
|
+
name: string,
|
|
47
|
+
oldValue: string | null,
|
|
48
|
+
newValue: string | null
|
|
49
|
+
): void {
|
|
50
|
+
switch (name) {
|
|
51
|
+
case "disabled":
|
|
52
|
+
this.disabled = newValue !== null;
|
|
53
|
+
this.updateChildrenDisabledState();
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 组件连接到DOM后的初始化
|
|
60
|
+
*/
|
|
61
|
+
protected onConnected(): void {
|
|
62
|
+
// 初始化时设置子按钮的disabled状态
|
|
63
|
+
this.updateChildrenDisabledState();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 更新所有子按钮的disabled状态
|
|
68
|
+
*/
|
|
69
|
+
private updateChildrenDisabledState(): void {
|
|
70
|
+
if (!this.disabled) return;
|
|
71
|
+
|
|
72
|
+
// 获取所有xy-button子元素
|
|
73
|
+
const buttons = this.querySelectorAll("xy-button");
|
|
74
|
+
buttons.forEach((button: Element) => {
|
|
75
|
+
if (this.disabled) {
|
|
76
|
+
button.setAttribute("disabled", "");
|
|
77
|
+
} else {
|
|
78
|
+
button.removeAttribute("disabled");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 公共API:获取/设置disabled状态
|
|
85
|
+
*/
|
|
86
|
+
public get isDisabled(): boolean {
|
|
87
|
+
return this.disabled;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public set isDisabled(value: boolean) {
|
|
91
|
+
if (value) {
|
|
92
|
+
this.setAttr("disabled", "");
|
|
93
|
+
} else {
|
|
94
|
+
this.removeAttr("disabled");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 公共API:获取组内的所有按钮
|
|
100
|
+
*/
|
|
101
|
+
public getButtons(): NodeListOf<Element> {
|
|
102
|
+
return this.querySelectorAll("xy-button");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 公共API:启用所有按钮
|
|
107
|
+
*/
|
|
108
|
+
public enableAll(): void {
|
|
109
|
+
const buttons = this.getButtons();
|
|
110
|
+
buttons.forEach((button: Element) => {
|
|
111
|
+
button.removeAttribute("disabled");
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 公共API:禁用所有按钮
|
|
117
|
+
*/
|
|
118
|
+
public disableAll(): void {
|
|
119
|
+
const buttons = this.getButtons();
|
|
120
|
+
buttons.forEach((button: Element) => {
|
|
121
|
+
button.setAttribute("disabled", "");
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @jsxImportSource @wsxjs/wsx-core */
|
|
2
|
+
|
|
3
|
+
// Export all base components (using default imports since they're default exports)
|
|
4
|
+
export { default as XyButton } from "./XyButton.wsx";
|
|
5
|
+
export { default as XyButtonGroup } from "./XyButtonGroup.wsx";
|
|
6
|
+
export { default as ColorPicker } from "./ColorPicker.wsx";
|
|
7
|
+
export { default as ReactiveCounter } from "./ReactiveCounter.wsx";
|
|
8
|
+
export { default as ThemeSwitcher } from "./ThemeSwitcher.wsx";
|
|
9
|
+
export { default as SvgIcon } from "./SvgIcon.wsx";
|
|
10
|
+
export { default as SvgDemo } from "./SvgDemo.wsx";
|
|
11
|
+
export { default as SimpleReactiveDemo } from "./SimpleReactiveDemo.wsx";
|
|
12
|
+
|
|
13
|
+
// Export utilities
|
|
14
|
+
export * from "./ColorPickerUtils";
|
|
15
|
+
|
|
16
|
+
// Note: Re-exports from core are causing TypeScript rootDir issues
|
|
17
|
+
// Users can import directly from @wsxjs/wsx-core if needed
|