Skip to content

Commit

Permalink
mui-x-tree-view.version=7.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
aerialist7 committed Jun 9, 2024
1 parent 8cef7ef commit f5cdc92
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 15 deletions.
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/karakum/mui/Adapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import karakum.mui.adapters.treeview.adaptTreeView

fun String.adaptRawContent(): String = this
.adaptComponentsAndSlots()
.adaptClasses()
.adaptInput()
.adaptOption()
.adaptSelect()
Expand Down
10 changes: 8 additions & 2 deletions buildSrc/src/main/kotlin/karakum/mui/Converter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ internal fun convertClasses(
"external val ${classesName.replaceFirstChar(Char::lowercase)}: $classesName\n"
}

internal fun convertInlineClasses(
classesName: String,
source: String,
): String {
return "interface $classesName \n${getClassesContent(source)}"
}

private fun getClassesContent(
source: String,
): String = source
Expand Down Expand Up @@ -132,8 +139,7 @@ internal fun convertDefinitions(
}

private fun String.removeInlineClasses(): String =
removeInlineClasses(" classes: ")
.removeInlineClasses(" classes?: ")
removeInlineClasses(" classes?: ")

private fun String.removeDeprecated(): String {
if ("interface MuiMediaQuery" !in this)
Expand Down
11 changes: 7 additions & 4 deletions buildSrc/src/main/kotlin/karakum/mui/KotlinType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,14 @@ internal fun kotlinType(
if (type.endsWith("']") || type.endsWith("'] | 'auto'"))
return "$DYNAMIC /* $type */"

if (name == "classes" && type.contains("{\n")) {
val interfaceName = name.replaceFirstChar(Char::titlecase)
return interfaceName + "\n\n" + convertInlineClasses(interfaceName, type)
}

// TODO: Remove when MUI completes migration to slots
if ((name == "components" || name == "componentsProps") && type.startsWith("{\n") && "/**" !in type) {
@Suppress("DEPRECATION")
val interfaceName = name.capitalize()
val interfaceName = name.replaceFirstChar(Char::titlecase)
val defaultType = if (name == "components") "react.ElementType<*>" else "react.Props"
return interfaceName + "\n\n" + componentInterface(interfaceName, type, defaultType)
}
Expand All @@ -484,8 +488,7 @@ internal fun kotlinType(
.replace("<TValue>", "")
} else {
// TODO: Else branch should die when MUI fully migrates to named slot types
@Suppress("DEPRECATION")
val interfaceName = name.capitalize()
val interfaceName = name.replaceFirstChar(Char::titlecase)
val defaultType = if (name == "slots") "react.ElementType<*>" else "react.Props"
interfaceName + "\n\n" + componentInterface(interfaceName, type, defaultType)
}
Expand Down
43 changes: 43 additions & 0 deletions buildSrc/src/main/kotlin/karakum/mui/adapters/Classes.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package karakum.mui.adapters

// TODO: Fix problem with incorrect comments processing for inline types
fun String.adaptClasses(): String {
return cleanupTreeItemContentClasses()
}

private fun String.cleanupTreeItemContentClasses(): String {
return replace(
"""
classes: {
/** Styles applied to the root element. */
root: string;
/** State class applied to the content element when expanded. */
expanded: string;
/** State class applied to the content element when selected. */
selected: string;
/** State class applied to the content element when focused. */
focused: string;
/** State class applied to the element when disabled. */
disabled: string;
/** Styles applied to the tree item icon and collapse/expand icon. */
iconContainer: string;
/** Styles applied to the label element. */
label: string;
/** Styles applied to the checkbox element. */
checkbox: string;
};
""",
"""
classes: {
root: string;
expanded: string;
selected: string;
focused: string;
disabled: string;
iconContainer: string;
label: string;
checkbox: string;
};
""",
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package karakum.mui.adapters

// TODO: Removing comments required
// It can be deleted when MUI finishes separating `Slot` & `Component` props to separate interfaces
// TODO: Fix problem with incorrect comments processing for inline types
fun String.adaptComponentsAndSlots(): String {
return cleanupFormControlLabelSlots()
.cleanupStepLabelSlots()
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mui-base.version=5.0.0-beta.47
mui-system.version=5.15.15
mui-lab.version=5.0.0-alpha.170
mui-x-date-pickers.version=5.0.20
mui-x-tree-view.version=7.6.1
mui-x-tree-view.version=7.6.2
# Flags
org.gradle.jvmargs=-Xms2g -Xmx4g
org.gradle.parallel=true
Expand Down
13 changes: 12 additions & 1 deletion mui-kotlin/src/jsMain/kotlin/muix/tree/view/TreeItemContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ external interface TreeItemContentProps :
/**
* Override or extend the styles applied to the component.
*/
var classes: dynamic
var classes: Classes

interface Classes {
val root: ClassName
val expanded: ClassName
val selected: ClassName
val focused: ClassName
val disabled: ClassName
val iconContainer: ClassName
val label: ClassName
val checkbox: ClassName
}

/**
* The tree item label.
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5cdc92

Please sign in to comment.