@visactor/react-vtable 1.25.0 → 1.25.1-alpha.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.
- package/cjs/components/avatar/avatar.js.map +1 -1
- package/cjs/components/button/button.js +12 -7
- package/cjs/components/button/button.js.map +1 -1
- package/cjs/components/link/link.js +12 -7
- package/cjs/components/link/link.js.map +1 -1
- package/cjs/components/popover/popover.js +6 -3
- package/cjs/components/popover/popover.js.map +1 -1
- package/cjs/containers/withContainer.js.map +1 -1
- package/cjs/context/table.d.ts +1 -0
- package/cjs/context/table.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/table-components/base-component.js +3 -1
- package/cjs/table-components/base-component.js.map +1 -1
- package/cjs/table-components/custom/custom-layout.js +20 -6
- package/cjs/table-components/custom/custom-layout.js.map +1 -1
- package/cjs/table-components/custom/reconciler.d.ts +5 -4
- package/cjs/table-components/custom/reconciler.js +81 -39
- package/cjs/table-components/custom/reconciler.js.map +1 -1
- package/cjs/tables/base-table.js +5 -2
- package/cjs/tables/base-table.js.map +1 -1
- package/dist/react-vtable.js +1673 -1557
- package/dist/react-vtable.min.js +2 -2
- package/es/components/avatar/avatar.js.map +1 -1
- package/es/components/button/button.js +12 -7
- package/es/components/button/button.js.map +1 -1
- package/es/components/link/link.js +12 -7
- package/es/components/link/link.js.map +1 -1
- package/es/components/popover/popover.js +6 -3
- package/es/components/popover/popover.js.map +1 -1
- package/es/containers/withContainer.js.map +1 -1
- package/es/context/table.d.ts +1 -0
- package/es/context/table.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/table-components/base-component.js +3 -1
- package/es/table-components/base-component.js.map +1 -1
- package/es/table-components/custom/custom-layout.js +19 -7
- package/es/table-components/custom/custom-layout.js.map +1 -1
- package/es/table-components/custom/reconciler.d.ts +5 -4
- package/es/table-components/custom/reconciler.js +53 -13
- package/es/table-components/custom/reconciler.js.map +1 -1
- package/es/tables/base-table.js +5 -2
- package/es/tables/base-table.js.map +1 -1
- package/package.json +17 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/avatar/avatar.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAQhB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,EAAS,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAc5D,MAAM,YAAY,GAAgB;IAChC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,oBAAoB;QAC1B,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;KAChB;IACD,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,QAAQ;IACf,eAAe,EAAE,IAAI;CAEtB,CAAC;AAEF,SAAS,eAAe,CAAC,SAAsB,EAAE,GAAsB;IACrE,MAAM,KAAK,GAAgB,KAAK,CAAC,EAAE,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IAC9D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAC1C,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAS,IAAI,CAAC,CAAC;IAC3C,SAAS,GAAG,GAAG,CAAC,CAAC,CAAE,GAA+B,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/D,MAAM,WAAW,GAAyC,KAAK,CAAC,WAAW,CACzE,CAAC,KAAU,EAAQ,EAAE;QACnB,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,EACD,CAAC,OAAO,CAAC,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AS,GAAG,CAAC,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,CAAC","file":"avatar.js","sourcesContent":["import type { IGroup, IGroupGraphicAttribute } from '@visactor/vtable/es/vrender';\nimport {\n measureTextSize,\n type BackgroundAttributes,\n type Cursor,\n type IRectGraphicAttribute,\n type ITextGraphicAttribute,\n type Padding,\n type Tag,\n type TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport { isString, merge } from '@visactor/vutils';\nimport type { ReactElement } from 'react';\nimport React, { useEffect } from 'react';\nimport { Group, Image, Text } from '../../table-components';\n\nexport interface AvatarProps {\n children?: string | React.ReactNode;\n textStyle?: Partial<ITextGraphicAttribute>;\n panelStyle?: BackgroundAttributes;\n size?: number;\n shape?: 'circle' | 'square';\n visible?: boolean;\n cursor?: Cursor;\n autoFixFontSize?: boolean;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: AvatarProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: '#FFF'\n },\n panelStyle: {\n visible: true,\n fill: 'rgb(201, 205, 212)',\n lineWidth: 1,\n cornerRadius: 2\n },\n size: 40,\n shape: 'circle',\n autoFixFontSize: true\n // cursor: 'pointer',\n};\n\nfunction AvatarComponent(baseProps: AvatarProps, ref: React.Ref<IGroup>) {\n const props: AvatarProps = merge({}, defaultProps, baseProps);\n const { size, children, onClick } = props;\n let avatarRef = React.useRef<IGroup>(null);\n avatarRef = ref ? (ref as React.RefObject<IGroup>) : avatarRef;\n\n const handleClick: React.MouseEventHandler<HTMLElement> = React.useCallback(\n (event: any): void => {\n onClick && onClick(event);\n },\n [onClick]\n );\n\n const groupAttribute = getGroupAttribute(props);\n if (isString(children)) {\n const textAttribute = getTextAttribute(props);\n return (\n <Group ref={avatarRef} attribute={groupAttribute} onClick={handleClick}>\n <Text attribute={textAttribute}></Text>\n </Group>\n );\n }\n if ((children as ReactElement).type === 'image') {\n (children as ReactElement).props.attribute.width = size;\n (children as ReactElement).props.attribute.height = size;\n }\n return (\n <Group ref={avatarRef} attribute={groupAttribute} onClick={handleClick}>\n {children}\n </Group>\n );\n}\n\nfunction getTextAttribute(props: AvatarProps) {\n const { textStyle, size, children, autoFixFontSize } = props;\n\n const attribute: ITextGraphicAttribute = {\n text: children as string,\n ...textStyle\n };\n\n if (autoFixFontSize) {\n getAutoFixFontSize(size, attribute);\n }\n\n return attribute;\n}\nfunction getGroupAttribute(props: AvatarProps) {\n const { panelStyle, size, shape } = props;\n const attribute: IGroupGraphicAttribute = {\n ...panelStyle,\n width: size,\n height: size,\n clip: true,\n cornerRadius: shape === 'circle' ? size / 2 : panelStyle.cornerRadius ?? 2,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n visibleAll: true,\n path: undefined\n };\n return attribute;\n}\n\nexport const Avatar = React.forwardRef<IGroup, AvatarProps>(AvatarComponent);\n\nAvatar.displayName = 'Avatar';\n\n// auto adjust font size\nfunction getAutoFixFontSize(size: number, attribute: ITextGraphicAttribute) {\n const textWidth = measureTextSize(attribute.text, attribute).width;\n const scale = size / (textWidth + 8);\n const fontSize = Math.max(Math.floor(attribute.fontSize * scale), 6);\n attribute.fontSize = fontSize;\n}\n"]}
|
|
@@ -37,14 +37,19 @@ function ButtonComponent(baseProps, ref) {
|
|
|
37
37
|
disabled ? "function" == typeof (null == event ? void 0 : event.preventDefault) && event.preventDefault() : onClick && onClick(event);
|
|
38
38
|
}), [ disabled, onClick ]), attribute = getTagAttribute(props);
|
|
39
39
|
return useEffect((() => {
|
|
40
|
-
buttonRef.current
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
disabled || (
|
|
44
|
-
}))
|
|
40
|
+
const inst = buttonRef.current;
|
|
41
|
+
inst && (inst.addEventListener("mouseenter", (() => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
disabled || (inst.addState("hover", !0, !1), null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
44
|
+
})), inst.addEventListener("mouseleave", (() => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
disabled || (inst.removeState("hover", !1), null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
47
|
+
})));
|
|
45
48
|
})), useEffect((() => {
|
|
46
|
-
|
|
47
|
-
buttonRef.current
|
|
49
|
+
var _a, _b;
|
|
50
|
+
const inst = buttonRef.current;
|
|
51
|
+
inst && (disabled ? (inst.removeState("disabled", !1), inst.addState("disabled", !0, !1)) : inst.removeState("disabled", !1),
|
|
52
|
+
null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
48
53
|
})), React.createElement(VTag, {
|
|
49
54
|
ref: buttonRef,
|
|
50
55
|
attribute: attribute,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/button/button.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA2BzC,MAAM,YAAY,GAAgB;IAChC,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;KACb;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;KAChB;IACD,OAAO,EAAE,EAAE;IAEX,KAAK,EAAE;QACL,UAAU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,EAAE,GAAG,KAAK,CAAC;IACjH,MAAM,IAAI,GAAkB;QAC1B,IAAI,EAAE,QAAQ;QACd,SAAS;QACT,OAAO;QACP,KAAK,EAAE,UAAU;QACjB,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,MAAM,EAAE,CAAA,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,QAAQ,EAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;QACtD,gBAAgB,EAAE,KAAK;QACvB,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,KAAK,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,KAAK;gBAC9B,QAAQ,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,0CAAE,QAAQ;aACrC;YACD,KAAK,EAAE;gBACL,KAAK,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,KAAK;gBAC/B,QAAQ,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,QAAQ;aACtC;SACF;KACF,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAmB,eAAe,CAAC,CAAC;AAE1E,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","file":"button.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport { merge } from '@visactor/vutils';\nimport React, { useEffect } from 'react';\n\ninterface ButtonStateStyle {\n textStyle?: {\n hover?: Partial<ITextGraphicAttribute>;\n disabled?: Partial<ITextGraphicAttribute>;\n };\n panelStyle?: {\n hover?: Partial<IRectGraphicAttribute>;\n disabled?: Partial<IRectGraphicAttribute>;\n };\n}\n\nexport interface ButtonProps {\n children?: string;\n textStyle?: Partial<ITextGraphicAttribute>;\n padding?: Padding;\n panelStyle?: BackgroundAttributes;\n minWidth?: number;\n maxWidth?: number;\n visible?: boolean;\n state?: ButtonStateStyle;\n disabled?: boolean;\n cursor?: Cursor;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: ButtonProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: '#FFF'\n },\n panelStyle: {\n visible: true,\n fill: '#165dff',\n lineWidth: 1,\n cornerRadius: 2\n },\n padding: 10,\n // cursor: 'pointer',\n state: {\n panelStyle: {\n hover: {\n fill: '#4080ff'\n },\n disabled: {\n fill: '#94bfff'\n }\n }\n }\n};\n\nfunction ButtonComponent(baseProps: ButtonProps, ref: React.Ref<Tag>) {\n const props: ButtonProps = merge({}, defaultProps, baseProps);\n const { disabled, onClick } = props;\n let buttonRef = React.useRef<Tag>(null);\n buttonRef = ref ? (ref as React.RefObject<Tag>) : buttonRef;\n\n const handleClick: React.MouseEventHandler<HTMLElement> = React.useCallback(\n (event: any): void => {\n if (disabled) {\n typeof event?.preventDefault === 'function' && event.preventDefault();\n return;\n }\n onClick && onClick(event);\n },\n [disabled, onClick]\n );\n\n const attribute: TagAttributes = getTagAttribute(props);\n\n useEffect(() => {\n const inst = buttonRef.current;\n if (!inst) {\n return;\n }\n inst.addEventListener('mouseenter', () => {\n // console.log('mouseenter', buttonRef.current, e.clone());\n if (!disabled) {\n inst.addState('hover', true, false);\n // buttonRef.current._bgRect.addState('hover', true, false);\n // buttonRef.current._textShape.addState('hover', true, false);\n inst.stage?.renderNextFrame?.();\n }\n });\n inst.addEventListener('mouseleave', () => {\n // console.log('mouseleave', buttonRef.current, e.clone());\n if (!disabled) {\n inst.removeState('hover', false);\n // buttonRef.current._bgRect.removeState('hover', false);\n // buttonRef.current._textShape.removeState('hover', false);\n inst.stage?.renderNextFrame?.();\n }\n });\n });\n\n useEffect(() => {\n const inst = buttonRef.current;\n if (!inst) {\n return;\n }\n if (disabled) {\n inst.removeState('disabled', false);\n // buttonRef.current._bgRect.removeState('disabled', false);\n // buttonRef.current._textShape.removeState('disabled', false);\n\n inst.addState('disabled', true, false);\n // buttonRef.current._bgRect.addState('disabled', true, false);\n // buttonRef.current._textShape.addState('disabled', true, false);\n // console.log('add disable');\n } else {\n inst.removeState('disabled', false);\n // buttonRef.current._bgRect.removeState('disabled', false);\n // buttonRef.current._textShape.removeState('disabled', false);\n // console.log('remove disable');\n }\n inst.stage?.renderNextFrame?.();\n });\n\n return <VTag ref={buttonRef} attribute={attribute} onClick={handleClick}></VTag>;\n}\n\nfunction getTagAttribute(props: ButtonProps) {\n const { textStyle, padding, panelStyle, minWidth, maxWidth, visible, cursor, disabled, state, children } = props;\n const attr: TagAttributes = {\n text: children,\n textStyle,\n padding,\n panel: panelStyle,\n minWidth,\n maxWidth,\n visible,\n cursor: cursor ?? disabled ? 'not-allowed' : 'pointer',\n childrenPickable: false,\n state: {\n text: {\n hover: state?.textStyle?.hover,\n disabled: state?.textStyle?.disabled\n },\n panel: {\n hover: state?.panelStyle?.hover,\n disabled: state?.panelStyle?.disabled\n }\n }\n };\n\n return attr;\n}\n\nexport const Button = React.forwardRef<Tag, ButtonProps>(ButtonComponent);\n\nButton.displayName = 'Button';\n"]}
|
|
@@ -42,14 +42,19 @@ function LinkComponent(baseProps, ref) {
|
|
|
42
42
|
href && window.open(href));
|
|
43
43
|
}), [ disabled, href, onClick ]), attribute = getTagAttribute(props);
|
|
44
44
|
return useEffect((() => {
|
|
45
|
-
linkRef.current
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
disabled || (
|
|
49
|
-
}))
|
|
45
|
+
const inst = linkRef.current;
|
|
46
|
+
inst && (inst.addEventListener("mouseenter", (() => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
disabled || (inst.addState("hover", !0, !1), null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
49
|
+
})), inst.addEventListener("mouseleave", (() => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
disabled || (inst.removeState("hover", !1), null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
52
|
+
})));
|
|
50
53
|
}), []), useEffect((() => {
|
|
51
|
-
|
|
52
|
-
linkRef.current
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const inst = linkRef.current;
|
|
56
|
+
inst && (disabled ? (inst.removeState("disabled", !1), inst.addState("disabled", !0, !1)) : inst.removeState("disabled", !1),
|
|
57
|
+
null === (_b = null === (_a = inst.stage) || void 0 === _a ? void 0 : _a.renderNextFrame) || void 0 === _b || _b.call(_a));
|
|
53
58
|
})), React.createElement(VTag, {
|
|
54
59
|
ref: linkRef,
|
|
55
60
|
attribute: attribute,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/link/link.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA8BzC,MAAM,YAAY,GAAc;IAC9B,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,mBAAmB;KAC1B;IACD,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,CAAC;QACZ,YAAY,EAAE,CAAC;KAChB;IACD,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IAER,KAAK,EAAE;QACL,SAAS,EAAE;YACT,QAAQ,EAAE;gBACR,IAAI,EAAE,oBAAoB;aAC3B;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE;gBAEL,OAAO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AC","file":"link.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport { merge } from '@visactor/vutils';\nimport React, { useEffect } from 'react';\n\ninterface LinkStateStyle {\n textStyle?: {\n hover?: Partial<ITextGraphicAttribute>;\n disabled?: Partial<ITextGraphicAttribute>;\n };\n panelStyle?: {\n hover?: Partial<IRectGraphicAttribute>;\n disabled?: Partial<IRectGraphicAttribute>;\n };\n}\n\nexport interface LinkProps {\n children?: string;\n textStyle?: Partial<ITextGraphicAttribute>;\n padding?: Padding;\n space?: number;\n panelStyle?: BackgroundAttributes;\n minWidth?: number;\n maxWidth?: number;\n visible?: boolean;\n state?: LinkStateStyle;\n disabled?: boolean;\n icon?: boolean;\n cursor?: Cursor;\n href?: string;\n onClick?: (e: Event) => void;\n}\n\nconst defaultProps: LinkProps = {\n textStyle: {\n fontSize: 14,\n fontFamily: 'sans-serif',\n fill: 'rgb(64, 128, 255)'\n },\n panelStyle: {\n visible: true,\n opacity: 0,\n fill: 'rgba(242, 243, 245, 0.5)',\n lineWidth: 1,\n cornerRadius: 2\n },\n padding: 4,\n space: 6,\n // cursor: 'pointer',\n state: {\n textStyle: {\n disabled: {\n fill: 'rgb(148, 191, 255)'\n }\n },\n panelStyle: {\n hover: {\n // visible: true\n opacity: 1\n }\n }\n }\n};\n\nfunction LinkComponent(baseProps: LinkProps, ref: React.Ref<Tag>) {\n const props: LinkProps = merge({}, defaultProps, baseProps);\n const { disabled, href, onClick } = props;\n let linkRef = React.useRef<Tag>(null);\n linkRef = ref ? (ref as React.RefObject<Tag>) : linkRef;\n\n const handleClick: React.MouseEventHandler<HTMLElement> = React.useCallback(\n (event: any): void => {\n if (disabled) {\n typeof event?.preventDefault === 'function' && event.preventDefault();\n return;\n }\n onClick && onClick(event);\n if (href) {\n // eslint-disable-next-line no-undef\n window.open(href);\n }\n },\n [disabled, href, onClick]\n );\n\n const attribute: TagAttributes = getTagAttribute(props);\n\n useEffect(() => {\n const inst = linkRef.current;\n if (!inst) {\n return;\n }\n inst.addEventListener('mouseenter', () => {\n // console.log('mouseenter', linkRef.current, e.clone());\n if (!disabled) {\n inst.addState('hover', true, false);\n // linkRef.current._bgRect.addState('hover', true, false);\n // linkRef.current._textShape.addState('hover', true, false);\n inst.stage?.renderNextFrame?.();\n }\n });\n inst.addEventListener('mouseleave', () => {\n // console.log('mouseleave', linkRef.current, e.clone());\n if (!disabled) {\n inst.removeState('hover', false);\n // linkRef.current._bgRect.removeState('hover', false);\n // linkRef.current._textShape.removeState('hover', false);\n inst.stage?.renderNextFrame?.();\n }\n });\n }, []);\n\n useEffect(() => {\n const inst = linkRef.current;\n if (!inst) {\n return;\n }\n if (disabled) {\n inst.removeState('disabled', false);\n // linkRef.current._bgRect.removeState('disabled', false);\n // linkRef.current._textShape.removeState('disabled', false);\n\n inst.addState('disabled', true, false);\n // linkRef.current._bgRect.addState('disabled', true, false);\n // linkRef.current._textShape.addState('disabled', true, false);\n // console.log('add disable');\n } else {\n inst.removeState('disabled', false);\n // linkRef.current._bgRect.removeState('disabled', false);\n // linkRef.current._textShape.removeState('disabled', false);\n // console.log('remove disable');\n }\n inst.stage?.renderNextFrame?.();\n });\n\n return <VTag ref={linkRef} attribute={attribute} onClick={handleClick}></VTag>;\n}\n\nfunction getTagAttribute(props: LinkProps) {\n const {\n textStyle,\n padding,\n space,\n panelStyle,\n minWidth,\n maxWidth,\n visible,\n cursor,\n disabled,\n icon,\n state,\n children\n } = props;\n const attr: TagAttributes = {\n text: children,\n textStyle,\n padding,\n panel: panelStyle,\n minWidth,\n maxWidth,\n visible,\n cursor: cursor ?? disabled ? 'not-allowed' : 'pointer',\n childrenPickable: false,\n state: {\n text: {\n hover: state?.textStyle?.hover,\n disabled: state?.textStyle?.disabled\n },\n panel: {\n hover: state?.panelStyle?.hover,\n disabled: state?.panelStyle?.disabled\n }\n },\n space,\n shape: {\n visible: !!icon,\n fill: false,\n stroke: textStyle.fill,\n symbolType:\n // eslint-disable-next-line max-len\n 'M -0.2927 -15.4348 L -15.142 -0.5855 C -18.6567 2.9292 -18.6567 8.6277 -15.142 12.1424 V 12.1424 C -11.6273 15.6571 -5.9288 15.6571 -2.4141 12.1424 L 15.2636 -5.5353 C 17.6067 -7.8784 17.6067 -11.6774 15.2636 -14.0206 V -14.0206 C 12.9205 -16.3637 9.1215 -16.3637 6.7783 -14.0206 L -10.8993 3.6571 C -12.0709 4.8287 -12.0709 6.7282 -10.8993 7.8997 V 7.8997 C -9.7278 9.0713 -7.8283 9.0713 -6.6567 7.8997 L 8.1925 -6.9495'\n }\n };\n\n return attr;\n}\n\nexport const Link = React.forwardRef<Tag, LinkProps>(LinkComponent);\n\nLink.displayName = 'Link';\n"]}
|
|
@@ -43,7 +43,8 @@ function PopoverComponent(baseProps, ref) {
|
|
|
43
43
|
popoverRef = ref || popoverRef;
|
|
44
44
|
const [popupOpen, setPopupOpen] = useState(!1);
|
|
45
45
|
useEffect((() => {
|
|
46
|
-
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
setPopupOpen(!!popupVisible), null === (_c = null === (_b = null === (_a = popoverRef.current) || void 0 === _a ? void 0 : _a.stage) || void 0 === _b ? void 0 : _b.renderNextFrame) || void 0 === _c || _c.call(_b);
|
|
47
48
|
}), [ popupVisible ]), useEffect((() => {
|
|
48
49
|
var _a;
|
|
49
50
|
setPopupOpen(null !== (_a = null != popupVisible ? popupVisible : defaultPopupVisible) && void 0 !== _a && _a);
|
|
@@ -66,9 +67,11 @@ function PopoverComponent(baseProps, ref) {
|
|
|
66
67
|
anchorType: anchorType
|
|
67
68
|
}
|
|
68
69
|
}, groupMouseEnter = useCallback((event => {
|
|
69
|
-
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
isValid(popupVisible) || (setPopupOpen(!0), null === (_c = null === (_b = null === (_a = event.currentTarget) || void 0 === _a ? void 0 : _a.stage) || void 0 === _b ? void 0 : _b.renderNextFrame) || void 0 === _c || _c.call(_b));
|
|
70
72
|
}), []), groupMouseLeave = useCallback((event => {
|
|
71
|
-
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
isValid(popupVisible) || (setPopupOpen(!1), null === (_c = null === (_b = null === (_a = event.currentTarget) || void 0 === _a ? void 0 : _a.stage) || void 0 === _b ? void 0 : _b.renderNextFrame) || void 0 === _c || _c.call(_b));
|
|
72
75
|
}), []);
|
|
73
76
|
return React.createElement(Group, {
|
|
74
77
|
ref: popoverRef,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/popover/popover.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAkB/C,MAAM,YAAY,GAAiB;IACjC,mBAAmB,EAAE,KAAK;IAG1B,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,MAAM,uBAAuB,GAAkB;IAC7C,eAAe,EAAE,oBAAoB;IACrC,SAAS,EAAE,8BAA8B;IACzC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,8BAA8B;IACtC,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,KAMhB,EAAE,EAAE;IACH,MAAM,UAAU,iCACd,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EA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,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,kBAAkB;gBACxB,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,MAAM;aACrB,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,MAAM;gBACX,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;KACL;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAuB,gBAAgB,CAAC,CAAC;AAEhF,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC","file":"popover.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IGroup,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport type { BoundsAnchorType } from '@visactor/vutils';\nimport { isValid, merge } from '@visactor/vutils';\nimport type { CSSProperties, ReactElement, ReactNode } from 'react';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Group } from '../../table-components';\n\ntype Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\nexport interface PopoverProps {\n children?: ReactElement;\n defaultPopupVisible?: boolean;\n // disabled?: boolean;\n // popupHoverStay?: boolean;\n popupVisible?: boolean;\n // color?: string;\n position?: Anchor;\n content?: ReactNode;\n // onVisibleChange?: (visible: boolean) => void;\n\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}\n\nconst defaultProps: PopoverProps = {\n defaultPopupVisible: false,\n // popupHoverStay: true,\n // popupVisible: false,\n position: 'top'\n};\n\nconst defaultPoptipPanelStyle: CSSProperties = {\n backgroundColor: 'rgb(255, 255, 255)',\n boxShadow: '0 4px 10px rgba(0, 0, 0, .1)',\n fontSize: '14px',\n borderRadius: '4px',\n lineHeight: '1.5715',\n boxSizing: 'border-box',\n color: 'rgb(78, 89, 105)',\n border: '1px solid rgb(229, 230, 235)',\n padding: '12px 16px'\n};\n\nconst Tooltip = (props: {\n visible: boolean;\n content: ReactNode;\n position: Anchor;\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}) => {\n const arrowStyle: CSSProperties = {\n content: '',\n height: '8px',\n width: '8px',\n position: 'absolute',\n display: 'block',\n boxSizing: 'border-box',\n transform: 'rotate(45deg)',\n transformOrigin: '50% 50% 0',\n backgroundColor: 'rgb(255, 255, 255)',\n border: '1px solid rgb(229, 230, 235)',\n ...getArrowStyle(props.position),\n\n ...props.arrowStyle\n };\n\n return props.visible ? (\n <>\n <div style={merge({}, defaultPoptipPanelStyle, props.panelStyle)}>{props.content}</div>\n <div style={arrowStyle}></div>\n </>\n ) : (\n <></>\n );\n};\n\nfunction PopoverComponent(baseProps: PopoverProps, ref: React.Ref<IGroup>) {\n const props: PopoverProps = merge({}, defaultProps, baseProps);\n const { content, position, popupVisible, defaultPopupVisible, panelStyle, arrowStyle, children } = props;\n let popoverRef = React.useRef<IGroup>(null);\n popoverRef = ref ? (ref as React.RefObject<IGroup>) : popoverRef;\n\n const [popupOpen, setPopupOpen] = useState(false);\n\n useEffect(() => {\n if (popupVisible) {\n setPopupOpen(true);\n } else {\n setPopupOpen(false);\n }\n popoverRef.current.stage.renderNextFrame();\n }, [popupVisible]);\n\n useEffect(() => {\n setPopupOpen(popupVisible ?? defaultPopupVisible ?? false);\n }, []);\n\n const { transform, anchorType } = getTransform(position);\n const poptipContainerStyle: CSSProperties = {\n // display: popupOpen ? 'block' : 'none',\n transform: transform\n };\n\n const groupAttribute: IGroupGraphicAttribute = {\n react: {\n // width: 100,\n // height: 100,\n style: poptipContainerStyle,\n element: (\n <Tooltip\n visible={popupOpen}\n content={content}\n position={position}\n panelStyle={panelStyle}\n arrowStyle={arrowStyle}\n />\n ),\n container: null,\n visible: true,\n pointerEvents: false,\n anchorType: anchorType\n } as IGroupGraphicAttribute['react']\n };\n\n const groupMouseEnter = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(true);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n const groupMouseLeave = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(false);\n event.currentTarget.stage.renderNextFrame();\n }, []);\n\n return (\n <Group ref={popoverRef} attribute={groupAttribute} onMouseEnter={groupMouseEnter} onMouseLeave={groupMouseLeave}>\n {children}\n </Group>\n );\n}\n\nfunction getTransform(position: Anchor): { transform: string; anchorType: BoundsAnchorType } {\n switch (position) {\n case 'top':\n return {\n anchorType: 'top',\n transform: 'translate(-50%, calc(-100% - 10px))'\n };\n case 'tl':\n return {\n anchorType: 'top-left',\n transform: 'translate(0, calc(-100% - 10px))'\n };\n case 'tr':\n return {\n anchorType: 'top-right',\n transform: 'translate(-100%, calc(-100% - 10px))'\n };\n case 'bottom':\n return {\n anchorType: 'bottom',\n transform: 'translate(-50%, 10px)'\n };\n case 'bl':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(0, 10px)'\n };\n case 'br':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(-100%, 10px)'\n };\n case 'left':\n return {\n anchorType: 'left',\n transform: 'translate(calc(-100% - 10px), -50%)'\n };\n case 'lt':\n return {\n anchorType: 'top-left',\n transform: 'translate(calc(-100% - 10px), 0)'\n };\n case 'lb':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(calc(-100% - 10px), -100%)'\n };\n case 'right':\n return {\n anchorType: 'right',\n transform: 'translate(10px, -50%)'\n };\n case 'rt':\n return {\n anchorType: 'top-right',\n transform: 'translate(10px, 0)'\n };\n case 'rb':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(10px, -100%)'\n };\n }\n}\n\nfunction getArrowStyle(position: Anchor): CSSProperties {\n switch (position) {\n case 'top':\n return {\n top: 'calc(100% - 5px)',\n left: 'calc(50% - 5px)',\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tl':\n return {\n top: 'calc(100% - 4px)',\n left: '14px', // 4(1/2width) + 10(offset)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tr':\n return {\n top: 'calc(100% - 4px)',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'bottom':\n return {\n top: '-4px',\n left: 'calc(50% - 4px)',\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'bl':\n return {\n top: '-4px',\n left: '14px', // 4(1/2width) + 10(offset)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'br':\n return {\n top: '-4px',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'left':\n return {\n top: 'calc(50% - 4px)',\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'right':\n return {\n top: 'calc(50% - 4px)',\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n }\n}\n\nexport const Popover = React.forwardRef<IGroup, PopoverProps>(PopoverComponent);\n\nPopover.displayName = 'Popover';\n"]}
|
|
1
|
+
{"version":3,"sources":["components/popover/popover.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAkB/C,MAAM,YAAY,GAAiB;IACjC,mBAAmB,EAAE,KAAK;IAG1B,QAAQ,EAAE,KAAK;CAChB,CAAC;AAEF,MAAM,uBAAuB,GAAkB;IAC7C,eAAe,EAAE,oBAAoB;IACrC,SAAS,EAAE,8BAA8B;IACzC,QAAQ,EAAE,MAAM;IAChB,YAAY,EAAE,KAAK;IACnB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,kBAAkB;IACzB,MAAM,EAAE,8BAA8B;IACtC,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,KAMhB,EAAE,EAAE;IACH,MAAM,UAAU,iCACd,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,KAAK,EACb,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE,oBAAoB,EACrC,MAAM,EAAE,8BAA8B,IACnC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,GAE7B,KAAK,CAAC,UAAU,CACpB,CAAC;IAEF,OAAO,KAAK,CAAC,OAAO,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,OAAO;YACV,OAAO;gBACL,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,MAAM;gBACX,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;QACJ,KAAK,IAAI;YACP,OAAO;gBACL,GAAG,EAAE,mBAAmB;gBACxB,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;KACL;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAuB,gBAAgB,CAAC,CAAC;AAEhF,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC","file":"popover.js","sourcesContent":["import type {\n BackgroundAttributes,\n Cursor,\n IGroup,\n IGroupGraphicAttribute,\n IRectGraphicAttribute,\n ITextGraphicAttribute,\n Padding,\n Tag,\n TagAttributes\n} from '@visactor/vtable/es/vrender';\nimport { Tag as VTag } from '../vrender-components/tag';\nimport type { BoundsAnchorType } from '@visactor/vutils';\nimport { isValid, merge } from '@visactor/vutils';\nimport type { CSSProperties, ReactElement, ReactNode } from 'react';\nimport React, { useCallback, useEffect, useState } from 'react';\nimport { Group } from '../../table-components';\n\ntype Anchor = 'top' | 'tl' | 'tr' | 'bottom' | 'bl' | 'br' | 'left' | 'lt' | 'lb' | 'right' | 'rt' | 'rb';\nexport interface PopoverProps {\n children?: ReactElement;\n defaultPopupVisible?: boolean;\n // disabled?: boolean;\n // popupHoverStay?: boolean;\n popupVisible?: boolean;\n // color?: string;\n position?: Anchor;\n content?: ReactNode;\n // onVisibleChange?: (visible: boolean) => void;\n\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}\n\nconst defaultProps: PopoverProps = {\n defaultPopupVisible: false,\n // popupHoverStay: true,\n // popupVisible: false,\n position: 'top'\n};\n\nconst defaultPoptipPanelStyle: CSSProperties = {\n backgroundColor: 'rgb(255, 255, 255)',\n boxShadow: '0 4px 10px rgba(0, 0, 0, .1)',\n fontSize: '14px',\n borderRadius: '4px',\n lineHeight: '1.5715',\n boxSizing: 'border-box',\n color: 'rgb(78, 89, 105)',\n border: '1px solid rgb(229, 230, 235)',\n padding: '12px 16px'\n};\n\nconst Tooltip = (props: {\n visible: boolean;\n content: ReactNode;\n position: Anchor;\n panelStyle?: CSSProperties;\n arrowStyle?: CSSProperties;\n}) => {\n const arrowStyle: CSSProperties = {\n content: '',\n height: '8px',\n width: '8px',\n position: 'absolute',\n display: 'block',\n boxSizing: 'border-box',\n transform: 'rotate(45deg)',\n transformOrigin: '50% 50% 0',\n backgroundColor: 'rgb(255, 255, 255)',\n border: '1px solid rgb(229, 230, 235)',\n ...getArrowStyle(props.position),\n\n ...props.arrowStyle\n };\n\n return props.visible ? (\n <>\n <div style={merge({}, defaultPoptipPanelStyle, props.panelStyle)}>{props.content}</div>\n <div style={arrowStyle}></div>\n </>\n ) : (\n <></>\n );\n};\n\nfunction PopoverComponent(baseProps: PopoverProps, ref: React.Ref<IGroup>) {\n const props: PopoverProps = merge({}, defaultProps, baseProps);\n const { content, position, popupVisible, defaultPopupVisible, panelStyle, arrowStyle, children } = props;\n let popoverRef = React.useRef<IGroup>(null);\n popoverRef = ref ? (ref as React.RefObject<IGroup>) : popoverRef;\n\n const [popupOpen, setPopupOpen] = useState(false);\n\n useEffect(() => {\n if (popupVisible) {\n setPopupOpen(true);\n } else {\n setPopupOpen(false);\n }\n popoverRef.current?.stage?.renderNextFrame?.();\n }, [popupVisible]);\n\n useEffect(() => {\n setPopupOpen(popupVisible ?? defaultPopupVisible ?? false);\n }, []);\n\n const { transform, anchorType } = getTransform(position);\n const poptipContainerStyle: CSSProperties = {\n // display: popupOpen ? 'block' : 'none',\n transform: transform\n };\n\n const groupAttribute: IGroupGraphicAttribute = {\n react: {\n // width: 100,\n // height: 100,\n style: poptipContainerStyle,\n element: (\n <Tooltip\n visible={popupOpen}\n content={content}\n position={position}\n panelStyle={panelStyle}\n arrowStyle={arrowStyle}\n />\n ),\n container: null,\n visible: true,\n pointerEvents: false,\n anchorType: anchorType\n } as IGroupGraphicAttribute['react']\n };\n\n const groupMouseEnter = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(true);\n event.currentTarget?.stage?.renderNextFrame?.();\n }, []);\n\n const groupMouseLeave = useCallback((event: any) => {\n if (isValid(popupVisible)) {\n return;\n }\n setPopupOpen(false);\n event.currentTarget?.stage?.renderNextFrame?.();\n }, []);\n\n return (\n <Group ref={popoverRef} attribute={groupAttribute} onMouseEnter={groupMouseEnter} onMouseLeave={groupMouseLeave}>\n {children}\n </Group>\n );\n}\n\nfunction getTransform(position: Anchor): { transform: string; anchorType: BoundsAnchorType } {\n switch (position) {\n case 'top':\n return {\n anchorType: 'top',\n transform: 'translate(-50%, calc(-100% - 10px))'\n };\n case 'tl':\n return {\n anchorType: 'top-left',\n transform: 'translate(0, calc(-100% - 10px))'\n };\n case 'tr':\n return {\n anchorType: 'top-right',\n transform: 'translate(-100%, calc(-100% - 10px))'\n };\n case 'bottom':\n return {\n anchorType: 'bottom',\n transform: 'translate(-50%, 10px)'\n };\n case 'bl':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(0, 10px)'\n };\n case 'br':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(-100%, 10px)'\n };\n case 'left':\n return {\n anchorType: 'left',\n transform: 'translate(calc(-100% - 10px), -50%)'\n };\n case 'lt':\n return {\n anchorType: 'top-left',\n transform: 'translate(calc(-100% - 10px), 0)'\n };\n case 'lb':\n return {\n anchorType: 'bottom-left',\n transform: 'translate(calc(-100% - 10px), -100%)'\n };\n case 'right':\n return {\n anchorType: 'right',\n transform: 'translate(10px, -50%)'\n };\n case 'rt':\n return {\n anchorType: 'top-right',\n transform: 'translate(10px, 0)'\n };\n case 'rb':\n return {\n anchorType: 'bottom-right',\n transform: 'translate(10px, -100%)'\n };\n }\n}\n\nfunction getArrowStyle(position: Anchor): CSSProperties {\n switch (position) {\n case 'top':\n return {\n top: 'calc(100% - 5px)',\n left: 'calc(50% - 5px)',\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tl':\n return {\n top: 'calc(100% - 4px)',\n left: '14px', // 4(1/2width) + 10(offset)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'tr':\n return {\n top: 'calc(100% - 4px)',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderTop: 'none',\n borderLeft: 'none'\n };\n case 'bottom':\n return {\n top: '-4px',\n left: 'calc(50% - 4px)',\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'bl':\n return {\n top: '-4px',\n left: '14px', // 4(1/2width) + 10(offset)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'br':\n return {\n top: '-4px',\n left: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n borderRight: 'none',\n borderBottom: 'none'\n };\n case 'left':\n return {\n top: 'calc(50% - 4px)',\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'lb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: 'calc(100% - 5px)',\n borderLeft: 'none',\n borderBottom: 'none'\n };\n case 'right':\n return {\n top: 'calc(50% - 4px)',\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rt':\n return {\n top: '14px', // 4(1/2width) + 10(offset)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n case 'rb':\n return {\n top: 'calc(100% - 24px)', // 10(offset) + 10(width) + 4(1/2width)\n left: '-4px',\n borderRight: 'none',\n borderTop: 'none'\n };\n }\n}\n\nexport const Popover = React.forwardRef<IGroup, PopoverProps>(PopoverComponent);\n\nPopover.displayName = 'Popover';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["containers/withContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AASjE,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,IAA4C,EAC5C,IAAI,GAAG,gBAAgB,EACvB,QAAoC;IAEpC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAyB,CAAC,
|
|
1
|
+
{"version":3,"sources":["containers/withContainer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AASjE,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,IAA4C,EAC5C,IAAI,GAAG,gBAAgB,EACvB,QAAoC;IAEpC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAClE,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,KAAiB,KAAK,EAAjB,OAAO,UAAK,KAAK,EAA/C,+BAAuC,CAAQ,CAAC;QAEtD,eAAe,CAAC,GAAG,EAAE;YACnB,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,CACL,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,SAAS,EACpB,KAAK,kBACH,QAAQ,EAAE,UAAU,EACpB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,MAAM,EAC9B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,MAAM,IACzB,KAAK,KAGT,MAAM,CAAC,CAAC,CAAC,CACR,oBAAC,IAAI,kBAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,OAAO,IAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAqB,CAAC,EAAI,CAC9G,CAAC,CAAC,CAAC,CACF,yCAAK,CACN,CACG,CACP,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;IACpC,OAAO,GAAG,CAAC;AACb,CAAC","file":"withContainer.js","sourcesContent":["import React, { useRef, useState, useLayoutEffect } from 'react';\n\nexport interface ContainerProps {\n style?: React.CSSProperties;\n className?: string;\n width?: number | string;\n height?: number | string;\n}\n\nexport default function withContainer<Props extends ContainerProps, CompProps>(\n Comp: typeof React.Component<any, CompProps>,\n name = 'TableContainer',\n getProps?: (props: any) => CompProps\n) {\n const Cls = React.forwardRef<any, CompProps & Props>((props, ref) => {\n const container = useRef();\n const [inited, setInited] = useState(false);\n const { className, style, width, ...options } = props;\n\n useLayoutEffect(() => {\n setInited(true);\n }, []);\n\n return (\n <div\n ref={container}\n className={className}\n style={{\n position: 'relative',\n height: props.height || '100%',\n width: props.width || '100%',\n ...style\n }}\n >\n {inited ? (\n <Comp ref={ref} container={container.current} {...(getProps ? getProps(options) : (options as CompProps))} />\n ) : (\n <></>\n )}\n </div>\n );\n });\n Cls.displayName = name || Comp.name;\n return Cls;\n}\n"]}
|
package/es/context/table.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { ListTable, PivotTable, PivotChart } from '@visactor/vtable';
|
|
3
3
|
export interface TableContextType {
|
|
4
4
|
table?: ListTable | PivotTable | PivotChart;
|
|
5
|
+
onError?: (err: Error) => void;
|
|
5
6
|
isChildrenUpdated?: boolean;
|
|
6
7
|
}
|
|
7
8
|
declare const TableContext: React.Context<TableContextType>;
|
package/es/context/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["context/table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"sources":["context/table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AACjE,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAE1C,MAAM,UAAU,iBAAiB,CAAI,SAAiC;IACpE,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAW,CAAC,KAAU,EAAE,GAAG,EAAE,EAAE;QACzD,OAAO,CACL,oBAAC,YAAY,CAAC,QAAQ,QACnB,CAAC,GAAqB,EAAE,EAAE,CAAC,oBAAC,SAAS,kBAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,IAAM,KAAK,EAAI,CAC1D,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,IAAI,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,eAAe,YAAY,CAAC","file":"table.js","sourcesContent":["import React from 'react';\nimport type { ListTable, PivotTable, PivotChart } from '@visactor/vtable';\n\nexport interface TableContextType {\n table?: ListTable | PivotTable | PivotChart;\n onError?: (err: Error) => void;\n // optionFromChildren: any;\n isChildrenUpdated?: boolean;\n}\n\nconst TableContext = React.createContext<TableContextType>(null);\nTableContext.displayName = 'TableContext';\n\nexport function withTableInstance<T>(Component: typeof React.Component) {\n const Com = React.forwardRef<any, any>((props: any, ref) => {\n return (\n <TableContext.Consumer>\n {(ctx: TableContextType) => <Component ref={ref} table={ctx.table} {...props} />}\n </TableContext.Consumer>\n );\n });\n Com.displayName = Component.name;\n return Com;\n}\n\nexport default TableContext;\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","file":"index.js","sourcesContent":["export * from './tables';\nexport * from './table-components';\nexport * from './components';\n\nexport const version = \"1.25.1-alpha.1\";\n"]}
|
|
@@ -56,6 +56,8 @@ function parseCustomChildren(children, componentId) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function isReactElement(obj) {
|
|
59
|
-
|
|
59
|
+
if (!obj) return !1;
|
|
60
|
+
const reactElement = Symbol.for("react.element"), reactTransitionalElement = Symbol.for("react.transitional.element");
|
|
61
|
+
return obj.$$typeof === reactElement || obj.$$typeof === reactTransitionalElement;
|
|
60
62
|
}
|
|
61
63
|
//# sourceMappingURL=base-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["table-components/base-component.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAkB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/D,OAAO,gBAAgB,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAStD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC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AAK,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACxB,OAAO,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC,QAAwB,EAAE,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;aAC7F;iBAAM,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE;gBAC9F,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;aAC/E;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,GAAQ;IAC9B,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,KAAK,CAAC;KACd;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACjD,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAC1E,OAAO,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,QAAQ,KAAK,wBAAwB,CAAC;AACpF,CAAC","file":"base-component.js","sourcesContent":["import type { ReactElement, ReactNode } from 'react';\nimport React, { useContext, useEffect } from 'react';\nimport { isEqual, isNil, pickWithout } from '@visactor/vutils';\n\nimport type { TableContextType } from '../context/table';\nimport RootTableContext from '../context/table';\nimport { bindEventsToTable } from '../eventsUtils';\nimport { uid } from '../util';\nimport { CustomLayout } from './custom/custom-layout';\n\nexport interface BaseComponentProps {\n id?: string | number;\n children?: React.ReactNode;\n}\n\ntype ComponentProps = BaseComponentProps & { updateId?: number; componentId?: string; componentIndex?: number };\n\nexport const createComponent = <T extends ComponentProps>(\n componentName: string,\n optionName: string,\n supportedEvents?: Record<string, string> | null,\n isSingle?: boolean\n) => {\n const ignoreKeys = ['id', 'updateId', 'componentIndex', 'children'];\n const notOptionKeys = supportedEvents ? Object.keys(supportedEvents).concat(ignoreKeys) : ignoreKeys;\n\n const Comp = (props: T): React.ReactElement | null => {\n const context = useContext(RootTableContext);\n // const id = React.useRef<string | number>(isNil(props.id) ? uid(optionName) : props.id);\n\n const eventsBinded = React.useRef<T>(null);\n const updateId = React.useRef<number>(props.updateId);\n // const componentOption = React.useRef<Partial<T>>();\n\n if (props.updateId !== updateId.current) {\n // update triggered by table when table is rendered\n updateId.current = props.updateId;\n\n // rebind events after table render\n const hasPrevEventsBinded = supportedEvents\n ? bindEventsToTable(context.table, props as any, eventsBinded.current as any, supportedEvents)\n : false;\n if (hasPrevEventsBinded) {\n eventsBinded.current = props;\n }\n // } else {\n // const newComponentOption: Partial<T> = pickWithout<T>(props, notOptionKeys);\n\n // if (!isEqual(newComponentOption, componentOption.current)) {\n // componentOption.current = newComponentOption;\n // updateToContext(context, id.current, optionName, isSingle, newComponentOption);\n // }\n }\n\n useEffect(() => {\n return () => {\n if (supportedEvents) {\n bindEventsToTable(context.table, null, eventsBinded.current as any, supportedEvents);\n }\n // deleteToContext(context, id.current, optionName, isSingle);\n };\n }, []);\n\n // children are all custom layout temply\n // return props.children\n // ? React.cloneElement(props.children as ReactElement, { componentIndex: props.componentIndex })\n // : null;\n // if (props.children) {\n // return React.Children.map(props.children as ReactElement, (child: ReactElement) => {\n // if (child.props.role === 'custom-layout' || child.props.role === 'header-custom-layout') {\n // return React.createElement(CustomLayout, { componentId: props.componentId }, child);\n // }\n // });\n // }\n const result = parseCustomChildren(props.children, props.componentId);\n return result as React.ReactElement | null;\n };\n\n Comp.displayName = componentName;\n\n (Comp as any).parseOption = (props: T & { updateId?: number; componentId?: string }) => {\n const newComponentOption: Partial<T> = pickWithout<T>(props, notOptionKeys);\n // deal width customLayout\n if (props.children) {\n const { children } = props;\n React.Children.map(children as ReactElement, (child: ReactElement, index) => {\n parseChild(child, props, newComponentOption, notOptionKeys, props.componentId + '-' + index);\n });\n }\n // if (props.children && (props.children as React.ReactElement).props.role === 'custom-layout') {\n // (newComponentOption as any).customLayout = 'react-custom-layout';\n // }\n\n return {\n option: newComponentOption,\n optionName,\n isSingle\n };\n };\n\n return Comp;\n};\n\nfunction parseChild(\n child: ReactElement,\n componentProps: any,\n newComponentOption: any,\n notOptionKeys: string[],\n componentId: string\n) {\n if (child.props.role === 'custom-layout') {\n (newComponentOption as any).customLayout = 'react-custom-layout';\n (newComponentOption as any).customLayoutComponentId = componentId;\n }\n if (child.props.role === 'header-custom-layout') {\n (newComponentOption as any).headerCustomLayout = 'react-custom-layout';\n (newComponentOption as any).headerCustomLayoutComponentId = componentId;\n }\n if ((child.type as any).displayName === 'ListColumn') {\n if (!newComponentOption.columns) {\n newComponentOption.columns = [];\n }\n const childOption = pickWithout(child.props, notOptionKeys);\n newComponentOption.columns.push(childOption);\n childOption.componentId = componentId;\n if (child.props.children) {\n React.Children.map(child.props.children as ReactElement, (child: ReactElement, index) => {\n parseChild(child, componentProps, childOption, notOptionKeys, componentId + '-' + index);\n });\n }\n }\n}\n\nfunction parseCustomChildren(children: ReactNode, componentId: string): ReactNode | undefined {\n if (isReactElement(children) || Array.isArray(children)) {\n return React.Children.map(children as ReactElement, (child: ReactElement, index) => {\n if (child.props.children) {\n return parseCustomChildren(child.props.children as ReactElement, componentId + '-' + index);\n } else if (child.props.role === 'custom-layout' || child.props.role === 'header-custom-layout') {\n return React.createElement(CustomLayout, { componentId: componentId }, child);\n }\n return null;\n });\n }\n return null;\n}\n\nfunction isReactElement(obj: any) {\n if (!obj) {\n return false;\n }\n const reactElement = Symbol.for('react.element');\n const reactTransitionalElement = Symbol.for('react.transitional.element');\n return obj.$$typeof === reactElement || obj.$$typeof === reactTransitionalElement;\n}\n"]}
|
|
@@ -4,14 +4,21 @@ import RootTableContext from "../../context/table";
|
|
|
4
4
|
|
|
5
5
|
import { Group } from "@visactor/vtable/es/vrender";
|
|
6
6
|
|
|
7
|
-
import { reconcilor } from "./reconciler";
|
|
8
|
-
|
|
9
|
-
import { LegacyRoot } from "react-reconciler/constants";
|
|
7
|
+
import { reconcilor, createReconcilerContainer } from "./reconciler";
|
|
10
8
|
|
|
11
9
|
export const CustomLayout = (props, ref) => {
|
|
12
10
|
const {componentId: componentId, children: children} = props;
|
|
13
11
|
if (!isValidElement(children)) return null;
|
|
14
|
-
const context = useContext(RootTableContext), {table: table} = context, isHeaderCustomLayout = "header-custom-layout" === children.props.role, container = useRef(new Map),
|
|
12
|
+
const context = useContext(RootTableContext), {table: table, onError: onError} = context, isHeaderCustomLayout = "header-custom-layout" === children.props.role, container = useRef(new Map), reportReconcilerError = useCallback(((type, error) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!onError) return;
|
|
15
|
+
if (error instanceof Error) {
|
|
16
|
+
const wrapped = new Error(`[react-vtable custom-layout:${type}] ${error.message}`);
|
|
17
|
+
return wrapped.stack = error.stack, void onError(wrapped);
|
|
18
|
+
}
|
|
19
|
+
const message = "string" == typeof error ? error : null !== (_a = null == error ? void 0 : error.message) && void 0 !== _a ? _a : String(error);
|
|
20
|
+
onError(new Error(`[react-vtable custom-layout:${type}] ${message}`));
|
|
21
|
+
}), [ onError ]), createGraphic = useCallback((args => {
|
|
15
22
|
var _a, _b;
|
|
16
23
|
const key = `${null !== (_a = args.originCol) && void 0 !== _a ? _a : args.col}-${null !== (_b = args.originRow) && void 0 !== _b ? _b : args.row}${args.forComputation ? "-forComputation" : ""}`;
|
|
17
24
|
let group;
|
|
@@ -20,14 +27,14 @@ export const CustomLayout = (props, ref) => {
|
|
|
20
27
|
reconcilorUpdateContainer(children, currentContainer, args), group = currentContainer.containerInfo;
|
|
21
28
|
} else {
|
|
22
29
|
group = new Group({});
|
|
23
|
-
const currentContainer =
|
|
30
|
+
const currentContainer = createReconcilerContainer(group, "custom", reportReconcilerError);
|
|
24
31
|
container.current.set(key, currentContainer), reconcilorUpdateContainer(children, currentContainer, args);
|
|
25
32
|
}
|
|
26
33
|
return {
|
|
27
34
|
rootContainer: group,
|
|
28
35
|
renderDefault: !!children.props.renderDefault
|
|
29
36
|
};
|
|
30
|
-
}), [ children ]), removeContainer = useCallback(((col, row) => {
|
|
37
|
+
}), [ children, reportReconcilerError ]), removeContainer = useCallback(((col, row) => {
|
|
31
38
|
const key = `${col}-${row}`;
|
|
32
39
|
if (container.current.has(key)) {
|
|
33
40
|
const currentContainer = container.current.get(key);
|
|
@@ -69,7 +76,12 @@ export const CustomLayout = (props, ref) => {
|
|
|
69
76
|
};
|
|
70
77
|
|
|
71
78
|
function reconcilorUpdateContainer(children, currentContainer, args) {
|
|
72
|
-
|
|
79
|
+
const element = React.cloneElement(children, Object.assign({}, args)), updateContainerSync = reconcilor.updateContainerSync;
|
|
80
|
+
if ("function" != typeof updateContainerSync) reconcilor.updateContainer(element, currentContainer, null); else {
|
|
81
|
+
updateContainerSync(element, currentContainer, null);
|
|
82
|
+
const flushSyncWork = reconcilor.flushSyncWork;
|
|
83
|
+
"function" == typeof flushSyncWork && flushSyncWork();
|
|
84
|
+
}
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
function getCellRect(col, row, table) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AASxD,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,KAA2C,EAAE,GAAG,EAAE,EAAE;IAC5G,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,IAAI,CAA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AACd,CAAC","file":"custom-layout.js","sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { PropsWithChildren, ReactElement } from 'react';\nimport React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport RootTableContext from '../../context/table';\nimport { Group } from '@visactor/vtable/es/vrender';\nimport type { ICustomLayoutFuc, CustomRenderFunctionArg } from '@visactor/vtable/es/ts-types';\nimport type { FiberRoot } from 'react-reconciler';\nimport { reconcilor } from './reconciler';\nimport { LegacyRoot } from 'react-reconciler/constants';\n\ntype CustomLayoutProps = { componentId: string };\n\nexport type CustomLayoutFunctionArg = Partial<CustomRenderFunctionArg> & {\n role?: 'custom-layout' | 'header-custom-layout';\n renderDefault?: boolean;\n};\n\nexport const CustomLayout: React.FC<CustomLayoutProps> = (props: PropsWithChildren<CustomLayoutProps>, ref) => {\n const { componentId, children } = props;\n if (!isValidElement(children)) {\n return null;\n }\n const context = useContext(RootTableContext);\n const { table } = context;\n\n const isHeaderCustomLayout = children.props.role === 'header-custom-layout';\n\n // react customLayout component container cache\n const container = useRef<Map<string, FiberRoot>>(new Map());\n\n // customLayout function for vtable\n const createGraphic: ICustomLayoutFuc = useCallback(\n args => {\n const key = `${args.originCol ?? args.col}-${args.originRow ?? args.row}${\n args.forComputation ? '-forComputation' : ''\n }`;\n let group;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilorUpdateContainer(children, currentContainer, args);\n group = currentContainer.containerInfo;\n } else {\n group = new Group({});\n const currentContainer = reconcilor.createContainer(\n group as any,\n LegacyRoot,\n null,\n null,\n null,\n 'custom',\n null,\n null\n );\n container.current.set(key, currentContainer);\n reconcilorUpdateContainer(children, currentContainer, args);\n }\n\n return {\n rootContainer: group,\n renderDefault: !!children.props.renderDefault\n };\n },\n [children]\n );\n\n const removeContainer = useCallback((col: number, row: number) => {\n const key = `${col}-${row}`;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilor.updateContainer(null, currentContainer, null);\n // group = currentContainer.containerInfo;\n currentContainer.containerInfo.delete();\n container.current.delete(key);\n }\n }, []);\n\n const removeAllContainer = useCallback(() => {\n container.current.forEach((value, key) => {\n const currentContainer = value;\n reconcilor.updateContainer(null, currentContainer, null);\n currentContainer.containerInfo.delete();\n });\n container.current.clear();\n }, []);\n\n useLayoutEffect(() => {\n // init and release\n // eslint-disable-next-line no-undef\n console.log('init', props, table);\n // table && (table._reactCreateGraphic = createGraphic); // never go to here\n // table?.renderWithRecreateCells();\n return () => {\n // eslint-disable-next-line no-undef\n console.log('release', props, table);\n };\n }, []);\n\n useLayoutEffect(() => {\n // update props\n // eslint-disable-next-line no-undef\n console.log('update props', props, table);\n\n table?.checkReactCustomLayout(); // init reactCustomLayout component\n table?.reactCustomLayout?.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout); // set customLayout function\n\n if (table && !table.reactCustomLayout?.hasReactCreateGraphic(componentId, isHeaderCustomLayout)) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // set customLayout function\n table.reactCustomLayout?.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout); // set customLayout function\n table.reactCustomLayout?.updateCustomCell(componentId, isHeaderCustomLayout); // update cell content\n } else if (table) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // update customLayout function\n // update all container\n container.current.forEach((value, key) => {\n const [col, row] = key.split('-').map(Number);\n // const width = table.getColWidth(col); // to be fixed: may be merge cell\n // const height = table.getRowHeight(row); // to be fixed: may be merge cell\n const { width, height } = getCellRect(col, row, table);\n const currentContainer = value;\n const args = {\n col,\n row,\n dataValue: table.getCellOriginValue(col, row),\n value: table.getCellValue(col, row) || '',\n rect: {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height\n },\n table\n };\n // update element in container\n const group = currentContainer.containerInfo;\n reconcilorUpdateContainer(children, currentContainer, args);\n // reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n table.scenegraph.updateNextFrame();\n });\n }\n });\n\n return null;\n};\n\nfunction reconcilorUpdateContainer(children: ReactElement, currentContainer: any, args: any) {\n reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n // group = group.firstChild;\n // if (isReactElement(group.attribute.html?.dom)) {\n // const div = document.createElement('div');\n // const root = ReactDOM.createRoot(div as HTMLElement);\n // root.render(group.attribute.html.dom);\n // group.attribute.html.dom = div;\n // // debugger;\n // // group.html.dom = div;\n // }\n}\n\nfunction getCellRect(col: number, row: number, table: any) {\n const range = table.getCellRange(col, row);\n const rect = table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);\n return rect;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["table-components/custom/custom-layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIpD,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AASrE,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,KAA2C,EAAE,GAAG,EAAE,EAAE;IAC5G,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,IAAI,CAAC;KACb;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEnC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,CAAC;IAG5E,MAAM,SAAS,GAA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CAAC;IACpE,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;QAC7C,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACrD,MAAM,aAAa,GAAI,UAAkB,CAAC,aAAa,CAAC;QACxD,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;YACvC,aAAa,EAAE,CAAC;SACjB;QACD,OAAO;KACR;IACD,UAAU,CAAC,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAU9D,CAAC;AAED,SAAS,WAAW,CAAC,GAAW,EAAE,GAAW,EAAE,KAAU;IACvD,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC","file":"custom-layout.js","sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\nimport type { PropsWithChildren, ReactElement } from 'react';\nimport React, { isValidElement, useCallback, useContext, useLayoutEffect, useRef } from 'react';\nimport RootTableContext from '../../context/table';\nimport { Group } from '@visactor/vtable/es/vrender';\nimport type { ICustomLayoutFuc, CustomRenderFunctionArg } from '@visactor/vtable/es/ts-types';\nimport type { FiberRoot } from 'react-reconciler';\nimport type { ReconcilerErrorReporter } from './reconciler';\nimport { reconcilor, createReconcilerContainer } from './reconciler';\n\ntype CustomLayoutProps = { componentId: string };\n\nexport type CustomLayoutFunctionArg = Partial<CustomRenderFunctionArg> & {\n role?: 'custom-layout' | 'header-custom-layout';\n renderDefault?: boolean;\n};\n\nexport const CustomLayout: React.FC<CustomLayoutProps> = (props: PropsWithChildren<CustomLayoutProps>, ref) => {\n const { componentId, children } = props;\n if (!isValidElement(children)) {\n return null;\n }\n const context = useContext(RootTableContext);\n const { table, onError } = context;\n\n const isHeaderCustomLayout = children.props.role === 'header-custom-layout';\n\n // react customLayout component container cache\n const container = useRef<Map<string, FiberRoot>>(new Map());\n\n const reportReconcilerError: ReconcilerErrorReporter = useCallback(\n (type, error) => {\n if (!onError) {\n return;\n }\n if (error instanceof Error) {\n const wrapped = new Error(`[react-vtable custom-layout:${type}] ${error.message}`);\n (wrapped as any).stack = error.stack;\n onError(wrapped);\n return;\n }\n const message = typeof error === 'string' ? error : (error as any)?.message ?? String(error);\n onError(new Error(`[react-vtable custom-layout:${type}] ${message}`));\n },\n [onError]\n );\n\n // customLayout function for vtable\n const createGraphic: ICustomLayoutFuc = useCallback(\n args => {\n const key = `${args.originCol ?? args.col}-${args.originRow ?? args.row}${\n args.forComputation ? '-forComputation' : ''\n }`;\n let group;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilorUpdateContainer(children, currentContainer, args);\n group = currentContainer.containerInfo;\n } else {\n group = new Group({});\n const currentContainer = createReconcilerContainer(group as any, 'custom', reportReconcilerError);\n container.current.set(key, currentContainer);\n reconcilorUpdateContainer(children, currentContainer, args);\n }\n\n return {\n rootContainer: group,\n renderDefault: !!children.props.renderDefault\n };\n },\n [children, reportReconcilerError]\n );\n\n const removeContainer = useCallback((col: number, row: number) => {\n const key = `${col}-${row}`;\n if (container.current.has(key)) {\n const currentContainer = container.current.get(key);\n reconcilor.updateContainer(null, currentContainer, null);\n // group = currentContainer.containerInfo;\n currentContainer.containerInfo.delete();\n container.current.delete(key);\n }\n }, []);\n\n const removeAllContainer = useCallback(() => {\n container.current.forEach((value, key) => {\n const currentContainer = value;\n reconcilor.updateContainer(null, currentContainer, null);\n currentContainer.containerInfo.delete();\n });\n container.current.clear();\n }, []);\n\n useLayoutEffect(() => {\n // init and release\n // eslint-disable-next-line no-undef\n console.log('init', props, table);\n // table && (table._reactCreateGraphic = createGraphic); // never go to here\n // table?.renderWithRecreateCells();\n return () => {\n // eslint-disable-next-line no-undef\n console.log('release', props, table);\n };\n }, []);\n\n useLayoutEffect(() => {\n // update props\n // eslint-disable-next-line no-undef\n console.log('update props', props, table);\n\n table?.checkReactCustomLayout(); // init reactCustomLayout component\n table?.reactCustomLayout?.setReactRemoveAllGraphic(componentId, removeAllContainer, isHeaderCustomLayout); // set customLayout function\n\n if (table && !table.reactCustomLayout?.hasReactCreateGraphic(componentId, isHeaderCustomLayout)) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // set customLayout function\n table.reactCustomLayout?.setReactRemoveGraphic(componentId, removeContainer, isHeaderCustomLayout); // set customLayout function\n table.reactCustomLayout?.updateCustomCell(componentId, isHeaderCustomLayout); // update cell content\n } else if (table) {\n table.reactCustomLayout?.setReactCreateGraphic(\n componentId,\n createGraphic,\n // container.current,\n isHeaderCustomLayout\n ); // update customLayout function\n // update all container\n container.current.forEach((value, key) => {\n const [col, row] = key.split('-').map(Number);\n // const width = table.getColWidth(col); // to be fixed: may be merge cell\n // const height = table.getRowHeight(row); // to be fixed: may be merge cell\n const { width, height } = getCellRect(col, row, table);\n const currentContainer = value;\n const args = {\n col,\n row,\n dataValue: table.getCellOriginValue(col, row),\n value: table.getCellValue(col, row) || '',\n rect: {\n left: 0,\n top: 0,\n right: width,\n bottom: height,\n width,\n height\n },\n table\n };\n // update element in container\n const group = currentContainer.containerInfo;\n reconcilorUpdateContainer(children, currentContainer, args);\n // reconcilor.updateContainer(React.cloneElement(children, { ...args }), currentContainer, null);\n table.scenegraph.updateNextFrame();\n });\n }\n });\n\n return null;\n};\n\nfunction reconcilorUpdateContainer(children: ReactElement, currentContainer: any, args: any) {\n const element = React.cloneElement(children, { ...args });\n const updateContainerSync = (reconcilor as any).updateContainerSync;\n if (typeof updateContainerSync === 'function') {\n updateContainerSync(element, currentContainer, null);\n const flushSyncWork = (reconcilor as any).flushSyncWork;\n if (typeof flushSyncWork === 'function') {\n flushSyncWork();\n }\n return;\n }\n reconcilor.updateContainer(element, currentContainer, null);\n // group = group.firstChild;\n // if (isReactElement(group.attribute.html?.dom)) {\n // const div = document.createElement('div');\n // const root = ReactDOM.createRoot(div as HTMLElement);\n // root.render(group.attribute.html.dom);\n // group.attribute.html.dom = div;\n // // debugger;\n // // group.html.dom = div;\n // }\n}\n\nfunction getCellRect(col: number, row: number, table: any) {\n const range = table.getCellRange(col, row);\n const rect = table.getCellsRect(range.start.col, range.start.row, range.end.col, range.end.row);\n return rect;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
export declare const reconcilor:
|
|
1
|
+
type Instance = any;
|
|
2
|
+
export type ReconcilerErrorType = 'uncaught' | 'caught' | 'recoverable';
|
|
3
|
+
export type ReconcilerErrorReporter = (type: ReconcilerErrorType, error: unknown) => void;
|
|
4
|
+
export declare const reconcilor: any;
|
|
5
|
+
export declare const createReconcilerContainer: (container: Instance, identifierPrefix?: string, reportError?: ReconcilerErrorReporter) => any;
|
|
5
6
|
export {};
|