Skip to content

Commit

Permalink
feat: ✨ 修复构建报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
G committed Dec 13, 2023
1 parent b565ae7 commit b47b6c2
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 282 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"prepare": "husky install",
"commit": "git add -A && git cz"
"commit": "git add -A && git cz",
"release": "turbo release"
},
"keywords": [],
"author": "",
Expand Down
17 changes: 15 additions & 2 deletions packages/gbeata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@
"types": "dist/index.d.ts",
"typings": "lib/index.d.ts",
"files": [
"dist"
"dist",
"lib",
"es"
],
"keywords": [
"ant",
"component",
"components",
"design",
"framework",
"frontend",
"react",
"react-component"
],
"scripts": {
"build": "father build",
Expand All @@ -20,7 +32,8 @@
"lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
"lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
"prepublishOnly": "father doctor && npm run build",
"start": "npm run dev"
"start": "npm run dev",
"release": "npm run build && npm publish"
},
"commitlint": {
"extends": [
Expand Down
57 changes: 27 additions & 30 deletions packages/gbeata/src/GFields/convertFields.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,59 @@
import { ReactElement, ReactNode } from 'react';
import { Field } from '../GForm/g-form';
import { isObj } from '../utils';
import { Field } from '../GForm/g-form'
import { ReactElement, ReactNode } from 'react'
import { isObj } from '../utils'

const getAyFieldsNode = (children: ReactNode) => {
if (!Array.isArray(children)) {
children = [children];
children = [children]
}
console.log(children)

// @ts-ignore
return children.find(
(node: ReactElement) => node?.type?.componentName === 'GFields',
);
};
return children.find((node: ReactElement) => node?.type?.componentName === 'MwFields')
}

export const convertChildrenToField = (children: ReactNode) => {
// 获得子元素名为 GFields 的节点
let ayFields = getAyFieldsNode(children);
// 获得子元素名为 MwFields 的节点
let ayFields = getAyFieldsNode(children)

if (!ayFields) {
return [];
return []
}

// 获得到子元素
let ayFieldsChildren = ayFields?.props.children;
return loop(ayFieldsChildren);
};
let ayFieldsChildren = ayFields?.props.children
return loop(ayFieldsChildren)
}

function loop(children: ReactNode) {
if (!Array.isArray(children)) {
children = [children];
children = [children]
}

let newChildren: Field[] = [];
let newChildren: Field[] = []

// @ts-ignore
children.forEach((node) => {
children.forEach(node => {
if (node) {
if (
node?.type?.toString() === 'Symbol(react.fragment)' &&
node?.props?.children
) {
newChildren.push(...loop(node.props.children));
return;
if (node?.type?.toString() === 'Symbol(react.fragment)' && node?.props?.children) {
newChildren.push(...loop(node.props.children))
return
}
let newNode = {
...node?.props,
key: node.key,
};
key: node.key
}

if (Array.isArray(newNode?.children) || isObj(newNode?.children)) {
if (isObj(newNode?.children)) {
newNode.children = loop([newNode.children]);
newNode.children = loop([newNode.children])
} else {
newNode.children = loop([...newNode.children]);
newNode.children = loop([...newNode.children])
}
}

newChildren.push(newNode);
newChildren.push(newNode)
}
});
return newChildren;
})
return newChildren
}
17 changes: 14 additions & 3 deletions packages/gbeata/src/GFields/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
export default function GFields() {
return null;
import React from 'react';

export interface GFieldsCompProps {
// Define your component props here
children: React.ReactNode;
}

GFields.componentName = 'GFields';
const GFields: React.FC<GFieldsCompProps> = (props) => {
// Your component logic here
return null;
};

// Adding a static property to the function component
(GFields as any).componentName = 'GFields';

export default GFields;
10 changes: 6 additions & 4 deletions packages/gbeata/src/GSearchList/AySearchListDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
GSearchList,
GSearchTableField,
GTableCtrlField,
Selection,
SelectionAll,
} from 'gbeata';
import React from 'react';
import {
Expand Down Expand Up @@ -94,15 +96,15 @@ export default function AySearchDemo() {
}}
>
<Col flex="20px">
<GSearchList.SelectionAll />
<SelectionAll />
</Col>
<Col flex="1" style={{ paddingLeft: 8 }}>
干员信息
</Col>
<Col flex="130px">操作</Col>
</Row>
}
renderItem={(record: AnyKeyProps, index: number) => {
renderItem={(record: AnyKeyProps) => {
let starMap: AnyKeyProps = {
5: '⭐️⭐️⭐️⭐️⭐️⭐️',
4: '⭐️⭐️⭐️⭐️⭐️',
Expand All @@ -115,7 +117,7 @@ export default function AySearchDemo() {
<List.Item
key={record.sort_id}
actions={[
<GCtrl>
<GCtrl key={record.sort_id}>
<GAction record={record} action="view">
详情
</GAction>
Expand All @@ -128,7 +130,7 @@ export default function AySearchDemo() {
</GCtrl>,
]}
>
<GSearchList.Selection record={record} style={{ marginRight: 8 }} />
<Selection record={record} style={{ marginRight: 8 }} />
<List.Item.Meta
avatar={<Avatar src={record.icon} size="large" />}
title={
Expand Down
10 changes: 4 additions & 6 deletions packages/gbeata/src/GSearchList/AySearchListDemoTsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ export default function AySearchDemo() {
fontWeight: 500,
}}
>
<Col flex="20px">
<GSearchList.SelectionAll />
</Col>
<Col flex="20px">{/* <GSearchList.SelectionAll /> */}</Col>
<Col flex="1" style={{ paddingLeft: 8 }}>
干员信息
</Col>
<Col flex="130px">操作</Col>
</Row>
}
renderItem={(record: AnyKeyProps, index: number) => {
renderItem={(record: AnyKeyProps) => {
let starMap: AnyKeyProps = {
5: '⭐️⭐️⭐️⭐️⭐️⭐️',
4: '⭐️⭐️⭐️⭐️⭐️',
Expand All @@ -79,7 +77,7 @@ export default function AySearchDemo() {
<List.Item
key={record.sort_id}
actions={[
<GCtrl>
<GCtrl key="ctrl">
<GAction record={record} action="view">
详情
</GAction>
Expand All @@ -92,7 +90,7 @@ export default function AySearchDemo() {
</GCtrl>,
]}
>
<GSearchList.Selection record={record} style={{ marginRight: 8 }} />
{/* <GSearchList.Selection record={record} style={{ marginRight: 8 }} /> */}
<List.Item.Meta
avatar={<Avatar src={record.icon} size="large" />}
title={
Expand Down
1 change: 1 addition & 0 deletions packages/gbeata/src/GSearchList/g-search-list.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ export interface GSearchListProps extends SearchListInitConfig {
export interface GSelectionProps {
record: AnyKeyProps;
disabled?: boolean;
style?: React.CSSProperties;
}
12 changes: 5 additions & 7 deletions packages/gbeata/src/GSearchList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Space } from 'antd';
import React, {
ForwardRefExoticComponent,
MutableRefObject,
ReactNode,
Ref,
RefAttributes,
forwardRef,
useImperativeHandle,
useMemo,
Expand Down Expand Up @@ -420,11 +422,7 @@ function GSearchList(props: GSearchListProps, ref: Ref<any>) {
);
}

let component = forwardRef(GSearchList);

// @ts-ignore
component.Selection = Selection;
// @ts-ignore
component.SelectionAll = SelectionAll;

let component: ForwardRefExoticComponent<
GSearchListProps & RefAttributes<any>
> = forwardRef(GSearchList);
export default component;
9 changes: 0 additions & 9 deletions packages/gbeata/src/MwDialog/index.d.ts

This file was deleted.

Loading

0 comments on commit b47b6c2

Please sign in to comment.