@qw-ui/core 0.3.0-next.10 → 0.3.0-next.12

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/dist/index.d.ts CHANGED
@@ -28,3 +28,5 @@ export { TAG_PARTS, TAG_SIZES, TAG_VARIANTS } from "./tag/index.js";
28
28
  export type { TagPart, TagSize, TagVariant, QwTagProps } from "./tag/index.js";
29
29
  export { createInputProps } from "./input/index.js";
30
30
  export type { QwInputProps, InputApi, InputMode, InputReadOnlyOverflow } from "./input/index.js";
31
+ export { SWITCH_PARTS, getSwitchRootProps, getSwitchThumbProps, resolveSwitchState } from "./switch/index.js";
32
+ export type { SwitchPart, QwSwitchProps, ResolvedSwitchState, SwitchRootProps, SwitchThumbProps } from "./switch/index.js";
package/dist/index.js CHANGED
@@ -13,4 +13,5 @@ import { AVATAR_BADGE_TYPES, AVATAR_LOAD_STATUS, AVATAR_PARTS, AVATAR_SHAPES, AV
13
13
  import { connect as connect$1, createTextAreaProps, machine } from "./textarea/index.js";
14
14
  import { TAG_PARTS, TAG_SIZES, TAG_VARIANTS } from "./tag/index.js";
15
15
  import { createInputProps } from "./input/index.js";
16
- export { AVATAR_BADGE_TYPES, AVATAR_LOAD_STATUS, AVATAR_PARTS, AVATAR_SHAPES, AVATAR_SIZES, BADGE_COUNT_MAX, BUTTON_ICON_POSITIONS, BUTTON_PARTS, BUTTON_SHAPES, BUTTON_SIZES, BUTTON_TONES, BUTTON_VARIANTS, DEFAULT_OVERLAY_PANEL_HEADER_HEIGHT, DEFAULT_TOAST_DURATION, DEFAULT_TOAST_POSITION, DIVIDER_ORIENTATIONS, DIVIDER_PARTS, DIVIDER_WEIGHTS, EMPTY_PARTS, ICON_FALLBACK_NAME, ICON_PARTS, LOADING_SIZES, OVERLAY_PANEL_PARTS, SKELETON_ANIMATIONS, SKELETON_PARTS, SKELETON_RADII, SKELETON_VARIANTS, TAG_PARTS, TAG_SIZES, TAG_VARIANTS, TOAST_ICON_TYPES, TOAST_PARTS, TOAST_POSITIONS, TOPBAR_VARIANTS, connect, createDialogProps, createInputProps, createTabsProps, createTextAreaProps, createTopBarProps, dialogMachine, extractInitials, getAvatarBadgeProps, getAvatarFallbackProps, getAvatarImageElementProps, getAvatarImageProps, getAvatarRootProps, getButtonRootProps, isToastIconType, resolveAvatarState, resolveButtonState, resolveIconName, resolveOverlayPanelHeight, resolveToastDuration, tabsMachine, connect$1 as textAreaConnect, machine as textAreaMachine };
16
+ import { SWITCH_PARTS, getSwitchRootProps, getSwitchThumbProps, resolveSwitchState } from "./switch/index.js";
17
+ export { AVATAR_BADGE_TYPES, AVATAR_LOAD_STATUS, AVATAR_PARTS, AVATAR_SHAPES, AVATAR_SIZES, BADGE_COUNT_MAX, BUTTON_ICON_POSITIONS, BUTTON_PARTS, BUTTON_SHAPES, BUTTON_SIZES, BUTTON_TONES, BUTTON_VARIANTS, DEFAULT_OVERLAY_PANEL_HEADER_HEIGHT, DEFAULT_TOAST_DURATION, DEFAULT_TOAST_POSITION, DIVIDER_ORIENTATIONS, DIVIDER_PARTS, DIVIDER_WEIGHTS, EMPTY_PARTS, ICON_FALLBACK_NAME, ICON_PARTS, LOADING_SIZES, OVERLAY_PANEL_PARTS, SKELETON_ANIMATIONS, SKELETON_PARTS, SKELETON_RADII, SKELETON_VARIANTS, SWITCH_PARTS, TAG_PARTS, TAG_SIZES, TAG_VARIANTS, TOAST_ICON_TYPES, TOAST_PARTS, TOAST_POSITIONS, TOPBAR_VARIANTS, connect, createDialogProps, createInputProps, createTabsProps, createTextAreaProps, createTopBarProps, dialogMachine, extractInitials, getAvatarBadgeProps, getAvatarFallbackProps, getAvatarImageElementProps, getAvatarImageProps, getAvatarRootProps, getButtonRootProps, getSwitchRootProps, getSwitchThumbProps, isToastIconType, resolveAvatarState, resolveButtonState, resolveIconName, resolveOverlayPanelHeight, resolveSwitchState, resolveToastDuration, tabsMachine, connect$1 as textAreaConnect, machine as textAreaMachine };
@@ -0,0 +1 @@
1
+ export * from "./switch.js";
@@ -0,0 +1,43 @@
1
+ //#region src/switch/switch.ts
2
+ /**
3
+ * Switch 的跨框架行为契约。
4
+ *
5
+ * Switch 是无状态的 Prototype A:交互由原生 button 承担,
6
+ * 这里仅归一化公开 props(checked / defaultChecked / disabled)。
7
+ * React/Vue 适配器不得复制 disabled 或 checked 的组合规则。
8
+ */
9
+ /** Switch 各渲染部位全集(data-part 取值)。 */
10
+ const SWITCH_PARTS = ["root", "thumb"];
11
+ /** 将公开输入归一化为唯一的跨框架状态。 */
12
+ function resolveSwitchState(props = {}) {
13
+ return {
14
+ checked: props.checked ?? props.defaultChecked ?? false,
15
+ disabled: props.disabled ?? false,
16
+ type: props.type ?? "button"
17
+ };
18
+ }
19
+ /** 将归一化结果转成 root 属性。 */
20
+ function getSwitchRootProps(state) {
21
+ return {
22
+ type: state.type,
23
+ role: "switch",
24
+ disabled: state.disabled,
25
+ "aria-checked": state.checked ? "true" : "false",
26
+ "data-scope": "switch",
27
+ "data-part": "root",
28
+ "data-checked": state.checked ? "true" : "false",
29
+ ...state.disabled ? { "data-disabled": "true" } : {}
30
+ };
31
+ }
32
+ /** 生成旋钮属性。 */
33
+ function getSwitchThumbProps() {
34
+ return {
35
+ "data-scope": "switch",
36
+ "data-part": "thumb",
37
+ "aria-hidden": "true"
38
+ };
39
+ }
40
+ //#endregion
41
+ export { SWITCH_PARTS, getSwitchRootProps, getSwitchThumbProps, resolveSwitchState };
42
+
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/switch/switch.ts"],"sourcesContent":["/**\n * Switch 的跨框架行为契约。\n *\n * Switch 是无状态的 Prototype A:交互由原生 button 承担,\n * 这里仅归一化公开 props(checked / defaultChecked / disabled)。\n * React/Vue 适配器不得复制 disabled 或 checked 的组合规则。\n */\n\n/** Switch 各渲染部位全集(data-part 取值)。 */\nexport const SWITCH_PARTS = [\"root\", \"thumb\"] as const;\n\nexport type SwitchPart = (typeof SWITCH_PARTS)[number];\n\n/**\n * QwSwitchProps — 双栈共享的行为契约(全字段可选)。\n * checked 未传时走非受控模式,由适配层管理内部状态。\n */\nexport interface QwSwitchProps {\n /** 受控值。未传时走非受控模式。 */\n checked?: boolean;\n /** 非受控初始值,默认 false。仅在 checked 未传时生效。 */\n defaultChecked?: boolean;\n /** 状态变化回调,参数为新的 checked 值。 */\n onToggle?: (checked: boolean) => void;\n /** 禁用状态。 */\n disabled?: boolean;\n /** 原生 button 类型,默认 `button`。 */\n type?: \"button\" | \"submit\" | \"reset\";\n}\n\n/** 适配器唯一可消费的归一化结果。 */\nexport interface ResolvedSwitchState {\n checked: boolean;\n disabled: boolean;\n type: \"button\" | \"submit\" | \"reset\";\n}\n\n/** Core 生成、由适配器最后覆盖到根元素的属性。 */\nexport interface SwitchRootProps {\n type: \"button\" | \"submit\" | \"reset\";\n role: \"switch\";\n disabled: boolean;\n \"aria-checked\": \"true\" | \"false\";\n \"data-scope\": \"switch\";\n \"data-part\": \"root\";\n \"data-checked\": \"true\" | \"false\";\n \"data-disabled\"?: \"true\";\n}\n\n/** 旋钮属性(纯视觉元素)。 */\nexport interface SwitchThumbProps {\n \"data-scope\": \"switch\";\n \"data-part\": \"thumb\";\n \"aria-hidden\": \"true\";\n}\n\n/** 将公开输入归一化为唯一的跨框架状态。 */\nexport function resolveSwitchState(props: QwSwitchProps = {}): ResolvedSwitchState {\n return {\n checked: props.checked ?? props.defaultChecked ?? false,\n disabled: props.disabled ?? false,\n type: props.type ?? \"button\",\n };\n}\n\n/** 将归一化结果转成 root 属性。 */\nexport function getSwitchRootProps(state: ResolvedSwitchState): SwitchRootProps {\n return {\n type: state.type,\n role: \"switch\",\n disabled: state.disabled,\n \"aria-checked\": state.checked ? \"true\" : \"false\",\n \"data-scope\": \"switch\",\n \"data-part\": \"root\",\n \"data-checked\": state.checked ? \"true\" : \"false\",\n ...(state.disabled ? { \"data-disabled\": \"true\" as const } : {}),\n };\n}\n\n/** 生成旋钮属性。 */\nexport function getSwitchThumbProps(): SwitchThumbProps {\n return {\n \"data-scope\": \"switch\",\n \"data-part\": \"thumb\",\n \"aria-hidden\": \"true\",\n };\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,eAAe,CAAC,QAAQ,OAAO;;AAgD5C,SAAgB,mBAAmB,QAAuB,CAAC,GAAwB;CACjF,OAAO;EACL,SAAS,MAAM,WAAW,MAAM,kBAAkB;EAClD,UAAU,MAAM,YAAY;EAC5B,MAAM,MAAM,QAAQ;CACtB;AACF;;AAGA,SAAgB,mBAAmB,OAA6C;CAC9E,OAAO;EACL,MAAM,MAAM;EACZ,MAAM;EACN,UAAU,MAAM;EAChB,gBAAgB,MAAM,UAAU,SAAS;EACzC,cAAc;EACd,aAAa;EACb,gBAAgB,MAAM,UAAU,SAAS;EACzC,GAAI,MAAM,WAAW,EAAE,iBAAiB,OAAgB,IAAI,CAAC;CAC/D;AACF;;AAGA,SAAgB,sBAAwC;CACtD,OAAO;EACL,cAAc;EACd,aAAa;EACb,eAAe;CACjB;AACF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Switch 的跨框架行为契约。
3
+ *
4
+ * Switch 是无状态的 Prototype A:交互由原生 button 承担,
5
+ * 这里仅归一化公开 props(checked / defaultChecked / disabled)。
6
+ * React/Vue 适配器不得复制 disabled 或 checked 的组合规则。
7
+ */
8
+ /** Switch 各渲染部位全集(data-part 取值)。 */
9
+ export declare const SWITCH_PARTS: readonly ["root", "thumb"];
10
+ export type SwitchPart = (typeof SWITCH_PARTS)[number];
11
+ /**
12
+ * QwSwitchProps — 双栈共享的行为契约(全字段可选)。
13
+ * checked 未传时走非受控模式,由适配层管理内部状态。
14
+ */
15
+ export interface QwSwitchProps {
16
+ /** 受控值。未传时走非受控模式。 */
17
+ checked?: boolean;
18
+ /** 非受控初始值,默认 false。仅在 checked 未传时生效。 */
19
+ defaultChecked?: boolean;
20
+ /** 状态变化回调,参数为新的 checked 值。 */
21
+ onToggle?: (checked: boolean) => void;
22
+ /** 禁用状态。 */
23
+ disabled?: boolean;
24
+ /** 原生 button 类型,默认 `button`。 */
25
+ type?: "button" | "submit" | "reset";
26
+ }
27
+ /** 适配器唯一可消费的归一化结果。 */
28
+ export interface ResolvedSwitchState {
29
+ checked: boolean;
30
+ disabled: boolean;
31
+ type: "button" | "submit" | "reset";
32
+ }
33
+ /** Core 生成、由适配器最后覆盖到根元素的属性。 */
34
+ export interface SwitchRootProps {
35
+ type: "button" | "submit" | "reset";
36
+ role: "switch";
37
+ disabled: boolean;
38
+ "aria-checked": "true" | "false";
39
+ "data-scope": "switch";
40
+ "data-part": "root";
41
+ "data-checked": "true" | "false";
42
+ "data-disabled"?: "true";
43
+ }
44
+ /** 旋钮属性(纯视觉元素)。 */
45
+ export interface SwitchThumbProps {
46
+ "data-scope": "switch";
47
+ "data-part": "thumb";
48
+ "aria-hidden": "true";
49
+ }
50
+ /** 将公开输入归一化为唯一的跨框架状态。 */
51
+ export declare function resolveSwitchState(props?: QwSwitchProps): ResolvedSwitchState;
52
+ /** 将归一化结果转成 root 属性。 */
53
+ export declare function getSwitchRootProps(state: ResolvedSwitchState): SwitchRootProps;
54
+ /** 生成旋钮属性。 */
55
+ export declare function getSwitchThumbProps(): SwitchThumbProps;
@@ -16,6 +16,8 @@ export type QwVisualState = "default" | "hover" | "active" | "focus-visible" | "
16
16
  export type QwVisualTheme = "light" | "dark";
17
17
  /** 框架轴。 */
18
18
  export type QwVisualFramework = "react" | "vue";
19
+ /** visual target 的查找作用域;省略时先查 demo canvas,再回退到整页。 */
20
+ export type QwVisualTargetScope = "canvas" | "page";
19
21
  /** 视口配置(预留扩展;默认 mobile = 390×844 @2x,与 G3 一致)。 */
20
22
  export type QwVisualViewport = "mobile";
21
23
  /**
@@ -101,6 +103,8 @@ export interface QwVisualScenario {
101
103
  demo: string;
102
104
  /** 对应 demo 中 `data-visual-target` 的值。 */
103
105
  target: string;
106
+ /** Portal 等已知整页目标可声明 page,避免先等待 canvas 查找超时。 */
107
+ targetScope?: QwVisualTargetScope;
104
108
  /** 本场景要验证的视觉状态列表。 */
105
109
  states: QwVisualState[];
106
110
  /** 主题列表,默认 light + dark(主题 delta 使用;parity 仍跑双主题)。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qw-ui/core",
3
- "version": "0.3.0-next.10",
3
+ "version": "0.3.0-next.12",
4
4
  "description": "L2 · Headless Core — zag.js machine 薄包装,纯 TS / SSR-safe,零样式。",
5
5
  "license": "MIT",
6
6
  "author": "qw-ui contributors",
@@ -95,6 +95,10 @@
95
95
  "./input": {
96
96
  "types": "./dist/input/index.d.ts",
97
97
  "import": "./dist/input/index.js"
98
+ },
99
+ "./switch": {
100
+ "types": "./dist/switch/index.d.ts",
101
+ "import": "./dist/switch/index.js"
98
102
  }
99
103
  },
100
104
  "sideEffects": false,
@@ -103,7 +107,7 @@
103
107
  "@zag-js/dialog": "^1.42.0",
104
108
  "@zag-js/tabs": "^1.42.0",
105
109
  "@zag-js/utils": "1.42.0",
106
- "@qw-ui/icons": "^0.3.0-next.10"
110
+ "@qw-ui/icons": "^0.3.0-next.12"
107
111
  },
108
112
  "devDependencies": {
109
113
  "@microsoft/api-extractor": "^7.58.9",