@viewfly/platform-browser 2.2.0 → 3.0.0-alpha.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/dist/jsx-dom.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JSX, ClassNames, JSXNode } from '@viewfly/core';
1
+ import { JSX, ClassNames, JSXNode, DynamicRef, Ref, RefProp } from '@viewfly/core';
2
2
  import * as CSS from 'csstype';
3
3
  export interface CSSProperties extends CSS.Properties<string | number>, CSS.PropertiesHyphen<string | number> {
4
4
  /**
@@ -200,10 +200,14 @@ interface AriaAttributes {
200
200
  'aria-valuetext'?: string;
201
201
  }
202
202
  export type StyleValue = string | CSSProperties | null;
203
- export interface HTMLAttributes<T> extends AriaAttributes, EventHandlers<Events>, JSX.RefAttributes<T> {
203
+ export interface HTMLAttributes<T> extends AriaAttributes, EventHandlers<Events>, Omit<JSX.IntrinsicAttributes, 'ref'> {
204
+ ref?: RefProp<T> | RefProp<T>[];
204
205
  children?: JSXNode;
205
206
  innerHTML?: string;
207
+ /** 支持 ClassNames / 对象解析,走 `setClass`(不经 `setProperty`)。 */
206
208
  class?: ClassNames;
209
+ /** 原生 `className`;不经 `classToString`。条件/对象类名请用 `class`。 */
210
+ className?: string;
207
211
  style?: StyleValue;
208
212
  accesskey?: string;
209
213
  contenteditable?: Booleanish | 'inherit';
@@ -621,14 +625,21 @@ export interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
621
625
  useragent?: string;
622
626
  webpreferences?: string;
623
627
  }
624
- export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>, JSX.RefAttributes<T> {
628
+ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events> {
629
+ ref?: Ref<T | null> | DynamicRef<T | null> | Array<Ref<T | null> | DynamicRef<T | null>>;
625
630
  children?: JSXNode;
626
631
  innerHTML?: string;
627
632
  /**
628
633
  * SVG Styling Attributes
629
634
  * @see https://www.w3.org/TR/SVG/styling.html#ElementSpecificStyling
630
635
  */
636
+ /**
637
+ * 支持 `ClassNames` 与对象动态解析;由 core renderer 走 `setClass`,**不经** `setProperty`。
638
+ * 勿用 `className` 代替:Viewfly 中 `className` 不做 ClassNames 处理,也不映射为 `class`。
639
+ */
631
640
  class?: ClassNames;
641
+ /** 原生 className 语义(无 ClassNames 解析);若需条件/对象样式请用 `class`。 */
642
+ className?: string;
632
643
  style?: string | CSSProperties;
633
644
  color?: string;
634
645
  height?: Numberish;
@@ -644,10 +655,22 @@ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>,
644
655
  width?: Numberish;
645
656
  role?: string;
646
657
  tabindex?: Numberish;
658
+ /**
659
+ * 与 HTML/React 一致的 camelCase;运行时会写成 attribute `tabindex`。
660
+ */
661
+ tabIndex?: Numberish;
662
+ /**
663
+ * XML / xmlns 声明式属性;运行时用 `setAttribute('xml:lang' | …)` 等(见 `xml-jsx-attr-name`)。
664
+ */
665
+ xmlBase?: string;
666
+ xmlLang?: string;
667
+ xmlSpace?: 'default' | 'preserve' | (string & {});
668
+ xmlnsXlink?: string;
647
669
  'accent-height'?: Numberish;
648
670
  accumulate?: 'none' | 'sum';
649
671
  additive?: 'replace' | 'sum';
650
672
  'alignment-baseline'?: 'auto' | 'baseline' | 'before-edge' | 'text-before-edge' | 'middle' | 'central' | 'after-edge' | 'text-after-edge' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical' | 'inherit';
673
+ alignmentBaseline?: 'auto' | 'baseline' | 'before-edge' | 'text-before-edge' | 'middle' | 'central' | 'after-edge' | 'text-after-edge' | 'ideographic' | 'alphabetic' | 'hanging' | 'mathematical' | 'inherit';
651
674
  allowReorder?: 'no' | 'yes';
652
675
  alphabetic?: Numberish;
653
676
  amplitude?: Numberish;
@@ -668,6 +691,8 @@ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>,
668
691
  'cap-height'?: Numberish;
669
692
  clip?: Numberish;
670
693
  'clip-path'?: string;
694
+ /** 与 `clip-path` 同义(引用 `url(#id)` 等) */
695
+ clipPath?: string;
671
696
  clipPathUnits?: Numberish;
672
697
  'clip-rule'?: Numberish;
673
698
  'color-interpolation'?: Numberish;
@@ -698,7 +723,9 @@ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>,
698
723
  externalResourcesRequired?: Numberish;
699
724
  fill?: string;
700
725
  'fill-opacity'?: Numberish;
726
+ fillOpacity?: Numberish;
701
727
  'fill-rule'?: 'nonzero' | 'evenodd' | 'inherit';
728
+ fillRule?: 'nonzero' | 'evenodd' | 'inherit';
702
729
  filter?: string;
703
730
  filterRes?: Numberish;
704
731
  filterUnits?: Numberish;
@@ -706,7 +733,9 @@ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>,
706
733
  'flood-opacity'?: Numberish;
707
734
  focusable?: Numberish;
708
735
  'font-family'?: string;
736
+ fontFamily?: string;
709
737
  'font-size'?: Numberish;
738
+ fontSize?: Numberish;
710
739
  'font-size-adjust'?: Numberish;
711
740
  'font-stretch'?: Numberish;
712
741
  'font-style'?: Numberish;
@@ -819,12 +848,21 @@ export interface SVGAttributes<T> extends AriaAttributes, EventHandlers<Events>,
819
848
  'strikethrough-thickness'?: Numberish;
820
849
  string?: Numberish;
821
850
  stroke?: string;
851
+ /** 与 `stroke-width` 同义,对标 React camelCase */
852
+ strokeWidth?: Numberish;
822
853
  'stroke-dasharray'?: Numberish;
854
+ /** 与 `stroke-dasharray` 同义 */
855
+ strokeDasharray?: Numberish;
823
856
  'stroke-dashoffset'?: Numberish;
857
+ strokeDashoffset?: Numberish;
824
858
  'stroke-linecap'?: 'butt' | 'round' | 'square' | 'inherit';
859
+ strokeLinecap?: 'butt' | 'round' | 'square' | 'inherit';
825
860
  'stroke-linejoin'?: 'miter' | 'round' | 'bevel' | 'inherit';
861
+ strokeLinejoin?: 'miter' | 'round' | 'bevel' | 'inherit';
826
862
  'stroke-miterlimit'?: Numberish;
863
+ strokeMiterlimit?: Numberish;
827
864
  'stroke-opacity'?: Numberish;
865
+ strokeOpacity?: Numberish;
828
866
  'stroke-width'?: Numberish;
829
867
  surfaceScale?: Numberish;
830
868
  systemLanguage?: Numberish;
@@ -1055,11 +1093,20 @@ export interface SVGElements {
1055
1093
  use: SVGAttributes<SVGUseElement>;
1056
1094
  view: SVGAttributes<SVGViewElement>;
1057
1095
  }
1058
- export interface MathMLAttributes extends JSX.RefAttributes<MathMLElement> {
1096
+ export interface MathMLAttributes<T> {
1097
+ ref?: Ref<T | null> | DynamicRef<T | null> | Array<Ref<T | null> | DynamicRef<T | null>>;
1059
1098
  children?: JSXNode;
1060
1099
  scriptlevel?: string;
1100
+ /** 同 HTML/SVG:`class` 走 setClass + ClassNames;`className` 仅字符串、不经 classToString。 */
1101
+ class?: ClassNames;
1102
+ className?: string;
1103
+ style?: string | CSSProperties;
1104
+ id?: string;
1105
+ dir?: 'ltr' | 'rtl' | 'auto';
1106
+ tabindex?: Numberish;
1107
+ tabIndex?: Numberish;
1061
1108
  }
1062
- export interface MathMLMoAttributes extends MathMLAttributes {
1109
+ export interface MathMLMoAttributes<T> extends MathMLAttributes<T> {
1063
1110
  accent?: Booleanish;
1064
1111
  fence?: Booleanish;
1065
1112
  lspace?: string;
@@ -1071,28 +1118,28 @@ export interface MathMLMoAttributes extends MathMLAttributes {
1071
1118
  stretchy?: Booleanish;
1072
1119
  symmetric?: Booleanish;
1073
1120
  }
1074
- export interface MathMLMathAttributes extends MathMLAttributes {
1121
+ export interface MathMLMathAttributes<T> extends MathMLAttributes<T> {
1075
1122
  xmlns?: 'http://www.w3.org/1998/Math/MathML';
1076
1123
  display?: 'block' | 'inline';
1077
1124
  }
1078
- export interface MathMLMfracAttributes extends MathMLAttributes {
1125
+ export interface MathMLMfracAttributes<T> extends MathMLAttributes<T> {
1079
1126
  linethickness?: string;
1080
1127
  }
1081
- export interface MathMLMoverAttributes extends MathMLAttributes {
1128
+ export interface MathMLMoverAttributes<T> extends MathMLAttributes<T> {
1082
1129
  accent?: Booleanish;
1083
1130
  }
1084
- export interface MathMLMpaddedAttributes extends MathMLAttributes {
1131
+ export interface MathMLMpaddedAttributes<T> extends MathMLAttributes<T> {
1085
1132
  depth?: string;
1086
1133
  height?: string;
1087
1134
  lspace?: string;
1088
1135
  voffset?: string;
1089
1136
  width?: string;
1090
1137
  }
1091
- export interface MathMLMspaceAttributes extends MathMLAttributes {
1138
+ export interface MathMLMspaceAttributes<T> extends MathMLAttributes<T> {
1092
1139
  width?: string;
1093
1140
  height?: string;
1094
1141
  }
1095
- export interface MathMLMtableAttribute extends MathMLAttributes {
1142
+ export interface MathMLMtableAttribute<T> extends MathMLAttributes<T> {
1096
1143
  align?: string;
1097
1144
  columnalign?: string;
1098
1145
  columnlines?: Numberish;
@@ -1104,54 +1151,54 @@ export interface MathMLMtableAttribute extends MathMLAttributes {
1104
1151
  rowspacing?: Numberish;
1105
1152
  width?: string;
1106
1153
  }
1107
- export interface MathMLMtdAttributes extends MathMLAttributes {
1154
+ export interface MathMLMtdAttributes<T> extends MathMLAttributes<T> {
1108
1155
  columnalign?: string;
1109
1156
  columnspan?: Numberish;
1110
1157
  rowalign?: string;
1111
1158
  rowspan?: Numberish;
1112
1159
  }
1113
- export interface MathMLMtrAttributes extends MathMLAttributes {
1160
+ export interface MathMLMtrAttributes<T> extends MathMLAttributes<T> {
1114
1161
  columnalign?: string;
1115
1162
  rowalign?: string;
1116
1163
  }
1117
- export interface MathMLMunderAttributes extends MathMLAttributes {
1164
+ export interface MathMLMunderAttributes<T> extends MathMLAttributes<T> {
1118
1165
  accentunder?: Booleanish;
1119
1166
  }
1120
- export interface MathMLMunderoverAttributes extends MathMLAttributes {
1167
+ export interface MathMLMunderoverAttributes<T> extends MathMLAttributes<T> {
1121
1168
  accent?: Booleanish;
1122
1169
  accentunder?: Booleanish;
1123
1170
  }
1124
1171
  export interface MathMLElements {
1125
- annotation: MathMLAttributes;
1126
- 'annotation-xml': MathMLAttributes;
1127
- maction: MathMLAttributes;
1128
- math: MathMLMathAttributes;
1129
- merror: MathMLAttributes;
1130
- mfrac: MathMLMfracAttributes;
1131
- mi: MathMLAttributes;
1132
- mmultiscripts: MathMLAttributes;
1133
- mn: MathMLAttributes;
1134
- mo: MathMLMoAttributes;
1135
- mover: MathMLMoverAttributes;
1136
- mpadded: MathMLMpaddedAttributes;
1137
- mphantom: MathMLAttributes;
1138
- mprescripts: MathMLAttributes;
1139
- mroot: MathMLAttributes;
1140
- mrow: MathMLAttributes;
1141
- ms: MathMLAttributes;
1142
- mspace: MathMLMspaceAttributes;
1143
- msqrt: MathMLAttributes;
1144
- mstyle: MathMLAttributes;
1145
- msub: MathMLAttributes;
1146
- msubsup: MathMLAttributes;
1147
- msup: MathMLAttributes;
1148
- mtable: MathMLMtableAttribute;
1149
- mtd: MathMLMtdAttributes;
1150
- mtext: MathMLAttributes;
1151
- mtr: MathMLMtrAttributes;
1152
- munder: MathMLMunderAttributes;
1153
- semantics: MathMLAttributes;
1154
- munderover: MathMLMunderoverAttributes;
1172
+ annotation: MathMLAttributes<MathMLElement>;
1173
+ 'annotation-xml': MathMLAttributes<MathMLElement>;
1174
+ maction: MathMLAttributes<MathMLElement>;
1175
+ math: MathMLMathAttributes<MathMLElement>;
1176
+ merror: MathMLAttributes<MathMLElement>;
1177
+ mfrac: MathMLMfracAttributes<MathMLElement>;
1178
+ mi: MathMLAttributes<MathMLElement>;
1179
+ mmultiscripts: MathMLAttributes<MathMLElement>;
1180
+ mn: MathMLAttributes<MathMLElement>;
1181
+ mo: MathMLMoAttributes<MathMLElement>;
1182
+ mover: MathMLMoverAttributes<MathMLElement>;
1183
+ mpadded: MathMLMpaddedAttributes<MathMLElement>;
1184
+ mphantom: MathMLAttributes<MathMLElement>;
1185
+ mprescripts: MathMLAttributes<MathMLElement>;
1186
+ mroot: MathMLAttributes<MathMLElement>;
1187
+ mrow: MathMLAttributes<MathMLElement>;
1188
+ ms: MathMLAttributes<MathMLElement>;
1189
+ mspace: MathMLMspaceAttributes<MathMLElement>;
1190
+ msqrt: MathMLAttributes<MathMLElement>;
1191
+ mstyle: MathMLAttributes<MathMLElement>;
1192
+ msub: MathMLAttributes<MathMLElement>;
1193
+ msubsup: MathMLAttributes<MathMLElement>;
1194
+ msup: MathMLAttributes<MathMLElement>;
1195
+ mtable: MathMLMtableAttribute<MathMLElement>;
1196
+ mtd: MathMLMtdAttributes<MathMLElement>;
1197
+ mtext: MathMLAttributes<MathMLElement>;
1198
+ mtr: MathMLMtrAttributes<MathMLElement>;
1199
+ munder: MathMLMunderAttributes<MathMLElement>;
1200
+ semantics: MathMLAttributes<MathMLElement>;
1201
+ munderover: MathMLMunderoverAttributes<MathMLElement>;
1155
1202
  }
1156
1203
  export interface NativeElements extends DOMElements, SVGElements, MathMLElements {
1157
1204
  }
@@ -1159,85 +1206,85 @@ export interface Events {
1159
1206
  onCopy: ClipboardEvent;
1160
1207
  onCut: ClipboardEvent;
1161
1208
  onPaste: ClipboardEvent;
1162
- onCompositionend: CompositionEvent;
1163
- onCompositionstart: CompositionEvent;
1164
- onCompositionupdate: CompositionEvent;
1209
+ onCompositionEnd: CompositionEvent;
1210
+ onCompositionStart: CompositionEvent;
1211
+ onCompositionUpdate: CompositionEvent;
1165
1212
  onDrag: DragEvent;
1166
- onDragend: DragEvent;
1167
- onDragenter: DragEvent;
1168
- onDragexit: DragEvent;
1169
- onDragleave: DragEvent;
1170
- onDragover: DragEvent;
1171
- onDragstart: DragEvent;
1213
+ onDragEnd: DragEvent;
1214
+ onDragEnter: DragEvent;
1215
+ onDragExit: DragEvent;
1216
+ onDragLeave: DragEvent;
1217
+ onDragOver: DragEvent;
1218
+ onDragStart: DragEvent;
1172
1219
  onDrop: DragEvent;
1173
1220
  onFocus: FocusEvent;
1174
- onFocusin: FocusEvent;
1175
- onFocusout: FocusEvent;
1221
+ onFocusIn: FocusEvent;
1222
+ onFocusOut: FocusEvent;
1176
1223
  onBlur: FocusEvent;
1177
1224
  onChange: Event;
1178
- onBeforeinput: Event;
1225
+ onBeforeInput: Event;
1179
1226
  onInput: Event;
1180
1227
  onReset: Event;
1181
1228
  onSubmit: Event;
1182
1229
  onInvalid: Event;
1183
1230
  onLoad: Event;
1184
1231
  onError: Event;
1185
- onKeydown: KeyboardEvent;
1186
- onKeypress: KeyboardEvent;
1187
- onKeyup: KeyboardEvent;
1188
- onAuxclick: MouseEvent;
1232
+ onKeyDown: KeyboardEvent;
1233
+ onKeyPress: KeyboardEvent;
1234
+ onKeyUp: KeyboardEvent;
1235
+ onAuxClick: MouseEvent;
1189
1236
  onClick: MouseEvent;
1190
- onContextmenu: MouseEvent;
1191
- onDblclick: MouseEvent;
1192
- onMousedown: MouseEvent;
1193
- onMouseenter: MouseEvent;
1194
- onMouseleave: MouseEvent;
1195
- onMousemove: MouseEvent;
1196
- onMouseout: MouseEvent;
1197
- onMouseover: MouseEvent;
1198
- onMouseup: MouseEvent;
1237
+ onContextMenu: MouseEvent;
1238
+ onDblClick: MouseEvent;
1239
+ onMouseDown: MouseEvent;
1240
+ onMouseEnter: MouseEvent;
1241
+ onMouseLeave: MouseEvent;
1242
+ onMouseMove: MouseEvent;
1243
+ onMouseOut: MouseEvent;
1244
+ onMouseOver: MouseEvent;
1245
+ onMouseUp: MouseEvent;
1199
1246
  onAbort: Event;
1200
- onCanplay: Event;
1201
- onCanplaythrough: Event;
1202
- onDurationchange: Event;
1247
+ onCanPlay: Event;
1248
+ onCanPlayThrough: Event;
1249
+ onDurationChange: Event;
1203
1250
  onEmptied: Event;
1204
1251
  onEncrypted: Event;
1205
1252
  onEnded: Event;
1206
- onLoadeddata: Event;
1207
- onLoadedmetadata: Event;
1208
- onLoadstart: Event;
1253
+ onLoadedData: Event;
1254
+ onLoadedMetadata: Event;
1255
+ onLoadStart: Event;
1209
1256
  onPause: Event;
1210
1257
  onPlay: Event;
1211
1258
  onPlaying: Event;
1212
1259
  onProgress: Event;
1213
- onRatechange: Event;
1260
+ onRateChange: Event;
1214
1261
  onSeeked: Event;
1215
1262
  onSeeking: Event;
1216
1263
  onStalled: Event;
1217
1264
  onSuspend: Event;
1218
- onTimeupdate: Event;
1219
- onVolumechange: Event;
1265
+ onTimeUpdate: Event;
1266
+ onVolumeChange: Event;
1220
1267
  onWaiting: Event;
1221
1268
  onSelect: Event;
1222
1269
  onScroll: UIEvent;
1223
- onTouchcancel: TouchEvent;
1224
- onTouchend: TouchEvent;
1225
- onTouchmove: TouchEvent;
1226
- onTouchstart: TouchEvent;
1227
- onPointerdown: PointerEvent;
1228
- onPointermove: PointerEvent;
1229
- onPointerup: PointerEvent;
1230
- onPointercancel: PointerEvent;
1231
- onPointerenter: PointerEvent;
1232
- onPointerleave: PointerEvent;
1233
- onPointerover: PointerEvent;
1234
- onPointerout: PointerEvent;
1270
+ onTouchCancel: TouchEvent;
1271
+ onTouchEnd: TouchEvent;
1272
+ onTouchMove: TouchEvent;
1273
+ onTouchStart: TouchEvent;
1274
+ onPointerDown: PointerEvent;
1275
+ onPointerMove: PointerEvent;
1276
+ onPointerUp: PointerEvent;
1277
+ onPointerCancel: PointerEvent;
1278
+ onPointerEnter: PointerEvent;
1279
+ onPointerLeave: PointerEvent;
1280
+ onPointerOver: PointerEvent;
1281
+ onPointerOut: PointerEvent;
1235
1282
  onWheel: WheelEvent;
1236
- onAnimationstart: AnimationEvent;
1237
- onAnimationend: AnimationEvent;
1238
- onAnimationiteration: AnimationEvent;
1239
- onTransitionend: TransitionEvent;
1240
- onTransitionstart: TransitionEvent;
1283
+ onAnimationStart: AnimationEvent;
1284
+ onAnimationEnd: AnimationEvent;
1285
+ onAnimationIteration: AnimationEvent;
1286
+ onTransitionEnd: TransitionEvent;
1287
+ onTransitionStart: TransitionEvent;
1241
1288
  }
1242
1289
  type EventHandlers<E> = {
1243
1290
  [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 对标 React `possibleStandardNames`:SVG / Math 子树中 JSX 的 camelCase -> 真正写在 DOM 上的 attribute 名。
3
+ * 易错、不能简单「插横线」的名字放在 XML_JSX_NAME_TO_ATTR;其余走受控的 kebab 回退。
4
+ * @see https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/possibleStandardNames.js
5
+ */
6
+ /**
7
+ * 显式表:JSX 名 -> 属性名(多含 kebab 或需保留大小写如 viewBox)。
8
+ * 全小写、单字符(x,y,r,cx 等)不必列出,会原样使用。
9
+ */
10
+ export declare const XML_JSX_NAME_TO_ATTR: Readonly<Record<string, string>>;
11
+ /**
12
+ * 返回在 SVG / Math 元素上应使用的 content attribute 名(用于 set/removeAttribute,含 `xml:…`、`xmlns:…`)。
13
+ */
14
+ export declare function getXmlPresentationAttributeName(jsxKey: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/platform-browser",
3
- "version": "2.2.0",
3
+ "version": "3.0.0-alpha.0",
4
4
  "description": "This project is used to enable the Viewfly framework to run in a browser.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -12,18 +12,13 @@
12
12
  "require": "./dist/index.js"
13
13
  }
14
14
  },
15
- "scripts": {
16
- "build:lib": "rimraf dist && pnpm run build && rimraf dist/platform-browser",
17
- "build": "vite build --config vite.config.ts",
18
- "publish:lib": "npm run build:lib && npm publish --access=public"
19
- },
20
15
  "files": [
21
16
  "dist/**/*"
22
17
  ],
23
18
  "license": "MIT",
24
19
  "keywords": [],
25
20
  "dependencies": {
26
- "@viewfly/core": "^2.2.0",
21
+ "@viewfly/core": "^3.0.0-alpha.0",
27
22
  "csstype": "^3.1.3"
28
23
  },
29
24
  "devDependencies": {
@@ -43,5 +38,10 @@
43
38
  },
44
39
  "bugs": {
45
40
  "url": "https://github.com/viewfly/viewfly/issues"
41
+ },
42
+ "scripts": {
43
+ "build:lib": "rimraf dist && pnpm run build && rimraf dist/platform-browser",
44
+ "build": "vite build --config vite.config.ts",
45
+ "publish:lib": "npm run build:lib && npm publish --access=public"
46
46
  }
47
- }
47
+ }
@@ -1,35 +0,0 @@
1
- import { JSXNode, NativeNode } from '@viewfly/core';
2
- /**
3
- * 用于创建脱离当前 DOM 树的子节点,常用于弹窗等
4
- * @deprecated 即将弃用,请使用 @viewfly/core 模块的 Portal 组件实现
5
- * @param childRender
6
- * @param host
7
- * @example
8
- * ```tsx
9
- * function App() {
10
- * const number = createSignal(0)
11
- *
12
- * setInterval(() => {
13
- * number.set(number() + 1)
14
- * }, 1000)
15
- *
16
- * const ModalPortal = function (props) {
17
- * return createPortal(() => {
18
- * return <div class="modal">parent data is {props.text}</div>
19
- * }, document.body)
20
- * }
21
- * return () => {
22
- * return (
23
- * <div>
24
- * <div>data is {number()}</div>
25
- * <ModalPortal text={number()}/>
26
- * </div>
27
- * )
28
- * }
29
- * }
30
- * ```
31
- */
32
- export declare function createPortal<T extends NativeNode>(childRender: () => JSXNode, host: T): {
33
- $portalHost: T;
34
- $render: () => JSXNode;
35
- };