Skip to content

Commit b42cf17

Browse files
Copilothuangyiirene
andcommitted
Fix slider defaultValue and icon home -> house mapping
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 1ed054d commit b42cf17

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

docs/components/form/slider.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ComponentDemo, DemoGrid } from '@/app/components/ComponentDemo';
1111
schema={{
1212
type: "slider",
1313
label: "Volume",
14-
defaultValue: 50
14+
defaultValue: [50]
1515
}}
1616
title="Basic Slider"
1717
/>

packages/components/src/renderers/basic/icon.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ function toPascalCase(str: string): string {
2121
.join('');
2222
}
2323

24+
// Map of renamed icons in lucide-react (from old name to new name)
25+
const iconNameMap: Record<string, string> = {
26+
'Home': 'House', // "Home" was renamed to "House" in lucide-react's icons object
27+
};
28+
2429
const IconRenderer = forwardRef<SVGSVGElement, { schema: IconSchema; className?: string; [key: string]: any }>(
2530
({ schema, className, ...props }, ref) => {
2631
// Extract designer-related props
@@ -33,10 +38,12 @@ const IconRenderer = forwardRef<SVGSVGElement, { schema: IconSchema; className?:
3338

3439
// Convert icon name to PascalCase for Lucide lookup
3540
const iconName = toPascalCase(schema.name);
36-
const Icon = (icons as any)[iconName];
41+
// Apply icon name mapping for renamed icons
42+
const mappedIconName = iconNameMap[iconName] || iconName;
43+
const Icon = (icons as any)[mappedIconName];
3744

3845
if (!Icon) {
39-
console.warn(`Icon "${schema.name}" (lookup: "${iconName}") not found in lucide-react`);
46+
console.warn(`Icon "${schema.name}" (lookup: "${iconName}"${mappedIconName !== iconName ? ` -> "${mappedIconName}"` : ''}) not found in lucide-react`);
4047
return null;
4148
}
4249

packages/components/src/renderers/form/slider.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ ComponentRegistry.register('slider',
2020
...sliderProps
2121
} = props;
2222

23+
// Ensure defaultValue is an array for backward compatibility
24+
const defaultValue = Array.isArray(schema.defaultValue)
25+
? schema.defaultValue
26+
: schema.defaultValue !== undefined
27+
? [schema.defaultValue]
28+
: undefined;
29+
2330
return (
2431
<Slider
25-
defaultValue={schema.defaultValue}
32+
defaultValue={defaultValue}
2633
max={schema.max}
2734
min={schema.min}
2835
step={schema.step}

0 commit comments

Comments
 (0)