Skip to content

Commit

Permalink
MUI. Fix and unify all "classes" declarations #4
Browse files Browse the repository at this point in the history
  • Loading branch information
aerialist7 committed May 5, 2024
1 parent d12f6b1 commit ccd1d92
Show file tree
Hide file tree
Showing 157 changed files with 1,364 additions and 1,366 deletions.
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/karakum/mui/Converter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ internal fun convertClasses(

if (source.isEmpty()) {
check(classesName == "ContainerClasses" || classesName == "StackClasses")
return "external interface $classesName : mui.system.$classesName"
return "typealias $classesName = mui.system.$classesName"
}

return "external interface $classesName {\n${getClassesContent(source)}\n}\n\n" +
return "sealed external interface $classesName {\n${getClassesContent(source)}\n}\n\n" +
optionalJsNameDefaultAnnotation(content) +
"external val ${classesName.replaceFirstChar(Char::lowercase)}: $classesName\n"
}
Expand All @@ -35,7 +35,7 @@ private fun getClassesContent(
.map {
val name = it.removeSuffix(": string;").removeSuffix("?")
if (name == it) return@map it
val line = "var $name: ClassName"
val line = "val $name: ClassName"
if (name.startsWith("'")) " // $line" else line
}
.joinToString("\n")
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/karakum/mui/Generator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ private fun generate(
if (classesFile.exists()) {
val classes = convertClasses(classesFileName.replaceFirstChar(Char::uppercase), classesFile)
val annotation = moduleDeclaration(pkg, subpackage, componentName)
.takeIf { "external val" in classes }
?: ""

targetDir.resolve("$componentName.classes.kt")
.writeText(fileContent(annotations = annotation, body = classes, pkg = pkg))
Expand Down
8 changes: 4 additions & 4 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Badge.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ package mui.base

import web.cssom.ClassName

external interface BadgeClasses {
sealed external interface BadgeClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** Class name applied to the badge `span` element. */
var badge: ClassName
val badge: ClassName

/** State class applied to the badge `span` element if `invisible={true}`. */
var invisible: ClassName
val invisible: ClassName
}

external val badgeClasses: BadgeClasses
10 changes: 5 additions & 5 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Button.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ package mui.base

import web.cssom.ClassName

external interface ButtonClasses {
sealed external interface ButtonClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root `button` element if `active={true}`. */
var active: ClassName
val active: ClassName

/** State class applied to the root `button` element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root `button` element if `focusVisible={true}`. */
var focusVisible: ClassName
val focusVisible: ClassName
}

external val buttonClasses: ButtonClasses
14 changes: 7 additions & 7 deletions mui-kotlin/src/jsMain/kotlin/mui/base/FormControl.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ package mui.base

import web.cssom.ClassName

external interface FormControlClasses {
sealed external interface FormControlClasses {
/** Class applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root element if `error={true}`. */
var error: ClassName
val error: ClassName

/** State class applied to the root element if the inner input has value. */
var filled: ClassName
val filled: ClassName

/** State class applied to the root element if the inner input is focused. */
var focused: ClassName
val focused: ClassName

/** State class applied to the root element if `required={true}`. */
var required: ClassName
val required: ClassName
}

external val formControlClasses: FormControlClasses
24 changes: 12 additions & 12 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Input.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ package mui.base

import web.cssom.ClassName

external interface InputClasses {
sealed external interface InputClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** Class name applied to the root element if the component is a descendant of `FormControl`. */
var formControl: ClassName
val formControl: ClassName

/** Class name applied to the root element if `startAdornment` is provided. */
var adornedStart: ClassName
val adornedStart: ClassName

/** Class name applied to the root element if `endAdornment` is provided. */
var adornedEnd: ClassName
val adornedEnd: ClassName

/** State class applied to the root element if the component is focused. */
var focused: ClassName
val focused: ClassName

/** State class applied to the root element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root element if `error={true}`. */
var error: ClassName
val error: ClassName

/** Class name applied to the root element if `multiline={true}`. */
var multiline: ClassName
val multiline: ClassName

/** Class name applied to the input element. */
var input: ClassName
val input: ClassName

/** Class name applied to the input element if `multiline={true}`. */
var inputMultiline: ClassName
val inputMultiline: ClassName

/** Class name applied to the input element if `type="search"`. */
var inputTypeSearch: ClassName
val inputTypeSearch: ClassName
}

external val inputClasses: InputClasses
8 changes: 4 additions & 4 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Menu.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ package mui.base

import web.cssom.ClassName

external interface MenuClasses {
sealed external interface MenuClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** Class name applied to the listbox element. */
var listbox: ClassName
val listbox: ClassName

/** State class applied to the root element if `open={true}`. */
var expanded: ClassName
val expanded: ClassName
}

external val menuClasses: MenuClasses
10 changes: 5 additions & 5 deletions mui-kotlin/src/jsMain/kotlin/mui/base/MenuButton.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ package mui.base

import web.cssom.ClassName

external interface MenuButtonClasses {
sealed external interface MenuButtonClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root element if `active={true}`. */
var active: ClassName
val active: ClassName

/** State class applied to the root element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root element if the associated menu is open. */
var expanded: ClassName
val expanded: ClassName
}

external val menuButtonClasses: MenuButtonClasses
8 changes: 4 additions & 4 deletions mui-kotlin/src/jsMain/kotlin/mui/base/MenuItem.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ package mui.base

import web.cssom.ClassName

external interface MenuItemClasses {
sealed external interface MenuItemClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root `button` element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root `button` element if `focusVisible={true}`. */
var focusVisible: ClassName
val focusVisible: ClassName
}

external val menuItemClasses: MenuItemClasses
8 changes: 4 additions & 4 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Modal.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ package mui.base

import web.cssom.ClassName

external interface ModalClasses {
sealed external interface ModalClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** Class name applied to the root element if the `Modal` has exited. */
var hidden: ClassName
val hidden: ClassName

/** Class name applied to the backdrop element. */
var backdrop: ClassName
val backdrop: ClassName
}

external val modalClasses: ModalClasses
10 changes: 5 additions & 5 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Option.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ package mui.base

import web.cssom.ClassName

external interface OptionClasses {
sealed external interface OptionClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root `li` element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root `li` element if `selected={true}`. */
var selected: ClassName
val selected: ClassName

/** State class applied to the root `li` element if `highlighted={true}`. */
var highlighted: ClassName
val highlighted: ClassName
}

external val optionClasses: OptionClasses
10 changes: 5 additions & 5 deletions mui-kotlin/src/jsMain/kotlin/mui/base/OptionGroup.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ package mui.base

import web.cssom.ClassName

external interface OptionGroupClasses {
sealed external interface OptionGroupClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** State class applied to the root `li` element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** Class name applied to the label element. */
var label: ClassName
val label: ClassName

/** Class name applied to the list element. */
var list: ClassName
val list: ClassName
}

external val optionGroupClasses: OptionGroupClasses
4 changes: 2 additions & 2 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Popper.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package mui.base

import web.cssom.ClassName

external interface PopperClasses {
sealed external interface PopperClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName
}

external val popperClasses: PopperClasses
16 changes: 8 additions & 8 deletions mui-kotlin/src/jsMain/kotlin/mui/base/Select.classes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ package mui.base

import web.cssom.ClassName

external interface SelectClasses {
sealed external interface SelectClasses {
/** Class name applied to the root element. */
var root: ClassName
val root: ClassName

/** Class name applied to the listbox element. */
var listbox: ClassName
val listbox: ClassName

/** Class name applied to the popper element. */
var popup: ClassName
val popup: ClassName

/** State class applied to the root `button` element if `active={true}`. */
var active: ClassName
val active: ClassName

/** State class applied to the root `button` element if `expanded={true}`. */
var expanded: ClassName
val expanded: ClassName

/** State class applied to the root `button` element and the listbox 'ul' element if `disabled={true}`. */
var disabled: ClassName
val disabled: ClassName

/** State class applied to the root `button` element if `focusVisible={true}`. */
var focusVisible: ClassName
val focusVisible: ClassName
}

external val selectClasses: SelectClasses
Loading

0 comments on commit ccd1d92

Please sign in to comment.