Skip to content

Commit ddb1e18

Browse files
committed
fix: render GUIGroup without bindPath
1 parent fcaff7b commit ddb1e18

File tree

5 files changed

+134
-117
lines changed

5 files changed

+134
-117
lines changed

packages/gui/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@galacean/gui",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "An opinionated UI library designed to create engaging and functional online tools with ease.",
55
"licenses": [
66
{
@@ -73,7 +73,8 @@
7373
"dependencies": {
7474
"@galacean/editor-ui": "workspace:*",
7575
"@radix-ui/react-use-controllable-state": "^1.1.0",
76-
"@tabler/icons-react": "^3.17.0"
76+
"@tabler/icons-react": "^3.17.0",
77+
"nanoid": "^5.1.6"
7778
},
7879
"peerDependencies": {
7980
"react": "^18.2.0",

packages/gui/src/components/FormItem/FormItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { cloneElement, forwardRef, ReactElement, ReactNode } from 'react'
22
import { styled, type CSS, VariantProps } from '@galacean/editor-ui'
3-
import { v4 as uuidv4 } from 'uuid'
43
import { Label } from './Label'
4+
import { nanoid } from 'nanoid'
55

66
const StyledField = styled('div', {
77
display: 'grid',
@@ -132,7 +132,7 @@ const FormItem = forwardRef<HTMLDivElement, FormItemProps>(function FormItem(pro
132132

133133
const name = propLabel
134134

135-
const labelId = `${(name ?? '').replace(/\s/g, '-')}-${uuidv4()}`
135+
const labelId = `${(name ?? '').replace(/\s/g, '-')}-${nanoid()}`
136136
const withoutLabel = !propLabel
137137

138138
const decorateChildren = React.Children.toArray(children).map((child) => {

packages/gui/src/components/GUIRoot/GUIRoot.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,16 @@ const StyledGroupWrapper = styled('div', {
155155
function renderGUIItem(item: GUIDefineItem, index: number) {
156156
const [data, keyOrBindPath, config] = item
157157
const { type, onChange, bindPath, label, ...rest } = config as Exclude<GUIItemConfig, GUIItemGroupConfig>
158-
const realKey = keyOrBindPath.split('.').pop()
158+
const realKey = keyOrBindPath?.split('.').pop()
159159

160160
let realLabel = label ?? realKey
161-
let value: any = data[keyOrBindPath]
161+
let value: any = keyOrBindPath ? data[keyOrBindPath] : undefined
162162
let GUIComponent = null
163163
let nested = false
164164

165165
let extraProps: any = {}
166166

167-
if (keyOrBindPath.indexOf('.') !== -1 && realKey) {
167+
if (keyOrBindPath?.indexOf('.') !== -1 && realKey) {
168168
nested = true
169169
}
170170

@@ -265,7 +265,7 @@ function renderGUIItem(item: GUIDefineItem, index: number) {
265265

266266
if (GUIComponent === FormItemGroup) {
267267
return (
268-
<StyledGroupWrapper>
268+
<StyledGroupWrapper key={`group_${index}`}>
269269
<UnControlledComponent
270270
key={`label_${index}`}
271271
label={realLabel}

packages/gui/tsup.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ export default defineConfig([
3030
globalName: 'GalaceanGUI',
3131
dts: false,
3232
sourcemap: true,
33-
noExternal: ['react', 'react-dom', '@galacean/editor-ui'],
33+
noExternal: ['react', 'react-dom', '@galacean/editor-ui', 'nanoid'],
3434
minify: true,
35+
platform: 'browser',
3536
outExtension: () => ({ js: '.umd.js' }),
37+
define: {
38+
'process.env.NODE_ENV': '"production"',
39+
},
3640
},
3741
])

0 commit comments

Comments
 (0)