Skip to content

Commit

Permalink
Upgrade MUI & Regenerate declarations
Browse files Browse the repository at this point in the history
* Material `5.15.11`
* Icons `5.15.11`
* Base `5.0.0-beta.37`
* System `5.15.11`
* Lab `5.0.0-alpha.166`
  • Loading branch information
aerialist7 committed Feb 26, 2024
1 parent 83952a7 commit 0f30103
Show file tree
Hide file tree
Showing 30 changed files with 248 additions and 317 deletions.
27 changes: 14 additions & 13 deletions buildSrc/src/main/kotlin/karakum/mui/Adapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package karakum.mui

import karakum.mui.adapters.*

fun String.adaptRawContent(): String =
adaptComponentsAndSlots()
.adaptInput()
.adaptOption()
.adaptSelect()
.adaptFormControl()
.adaptModal()
.adaptAccordion()
.adaptAutocomplete()
.adaptUseAutocomplete()
.adaptBreadcrumbs()
.adaptUseMenu()
.adaptUseSlider()
fun String.adaptRawContent(): String = this
.adaptComponentsAndSlots()
.adaptInput()
.adaptOption()
.adaptSelect()
.adaptFormControl()
.adaptModal()
.adaptAlert()
.adaptAccordion()
.adaptAutocomplete()
.adaptUseAutocomplete()
.adaptBreadcrumbs()
.adaptUseMenu()
.adaptUseSlider()
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/karakum/mui/Converter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,9 @@ private fun props(
if (propsName == "InputLabelOwnProps")
baseInterfaces += "react.PropsWithChildren"

if (propsName == "AlertProps")
baseInterfaces += "AlertSlots"

baseInterfaces
.tryToAddInheritanceInterfaces(propsName)

Expand Down
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/karakum/mui/Generator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ private fun generateSystemDeclarations(
val directories = typesDir.listFiles { file -> file.isDirectory } ?: return

directories.asSequence()
.filter { it.name.isComponentName() }
.filter { it.name.isComponentName() || it.name.isHookName() }
.filter { it.name !in setOf("useThemeProps") }
.map { it.resolve("${it.name}.d.ts") }
.flatMap { component ->
val dir = component.parentFile
Expand Down Expand Up @@ -398,7 +399,7 @@ private fun generateMaterialDeclarations(

directories.asSequence()
.filter { it.name.isComponentName() || it.name == "internal" || it.name.isHookName() }
.filter { it.name !in setOf("useTouchRipple", "useAutocomplete") }
.filter { it.name !in setOf("useTouchRipple", "useAutocomplete", "useMediaQuery") }
.filter { it.name !in BASE_TYPES }
.filter { it.name != "StyledEngineProvider" }
.onEach {
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/karakum/mui/adapters/Accordion.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package karakum.mui.adapters

fun String.adaptAccordion(): String =
replace(
fun String.adaptAccordion(): String = this
.replace(
oldValue = "export interface AccordionOwnerState extends AccordionProps {}",
newValue = "",
)
10 changes: 10 additions & 0 deletions buildSrc/src/main/kotlin/karakum/mui/adapters/Alert.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package karakum.mui.adapters

fun String.adaptAlert(): String = this
.replace(
oldValue = "export interface AlertOwnerState extends AlertProps {}",
newValue = "",
).replace(
oldValue = "AlertProps & AlertSlotsAndSlotProps",
newValue = "AlertProps"
)
9 changes: 4 additions & 5 deletions buildSrc/src/main/kotlin/karakum/mui/adapters/Modal.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package karakum.mui.adapters

fun String.adaptModal(): String {
return replace(
" & Omit<BaseModalTypeMap['props'], 'slotProps'>",
"",
fun String.adaptModal(): String = this
.replace(
oldValue = " & Omit<BaseModalTypeMap['props'], 'slotProps'>",
newValue = "",
)
}
127 changes: 3 additions & 124 deletions buildSrc/src/main/kotlin/karakum/mui/adapters/Select.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package karakum.mui.adapters

fun String.adaptSelect(): String {
return replace(
oldValue = "export interface BaseSelectProps<Value = unknown>",
newValue = "export interface SelectProps<Value = unknown>",
).replace(
"""
export interface SelectTypeMap<OptionValue extends {}, Multiple extends boolean, AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
props: SelectOwnProps<OptionValue, Multiple> & AdditionalProps;
Expand All @@ -22,127 +25,3 @@ export interface SelectType {
"",
)
}

// TODO: Was needed for mui-material 5.11.3 but was reverted bu mui team in 5.11.4
// Need to check will it be needed in future
private fun String.additionalAdaptSelect(): String {
return replace(
"""
interface CommonProps<T>
""",
"""
export interface SelectProps<Value = unknown>
""",
).replace(
"""
}
type ConditionalRenderValueType<T> =
| {
/**
* If `true`, a value is displayed even if no items are selected.
*
* In order to display a meaningful value, a function can be passed to the `renderValue` prop which
* returns the value to be displayed when no items are selected.
*
* ⚠️ When using this prop, make sure the label doesn't overlap with the empty displayed value.
* The label should either be hidden or forced to a shrunk state.
* @default false
*/
displayEmpty?: false;
/**
* If `true`, `value` must be an array and the menu will support multiple selections.
* @default false
*/
multiple?: boolean;
/**
* Render the selected value.
* You can only use it when the `native` prop is `false` (default).
*
* @param {any} value The `value` provided to the component.
* @returns {ReactNode}
*/
renderValue?: (value: T) => React.ReactNode;
}
| {
/**
* If `true`, a value is displayed even if no items are selected.
*
* In order to display a meaningful value, a function can be passed to the `renderValue` prop which
* returns the value to be displayed when no items are selected.
*
* ⚠️ When using this prop, make sure the label doesn't overlap with the empty displayed value.
* The label should either be hidden or forced to a shrunk state.
* @default false
*/
displayEmpty: true;
/**
* If `true`, `value` must be an array and the menu will support multiple selections.
* @default false
*/
multiple?: false;
/**
* Render the selected value.
* You can only use it when the `native` prop is `false` (default).
*
* @param {any} value The `value` provided to the component.
* @returns {ReactNode}
*/
renderValue?: (value: T | '') => React.ReactNode;
}
| {
/**
* If `true`, a value is displayed even if no items are selected.
*
* In order to display a meaningful value, a function can be passed to the `renderValue` prop which
* returns the value to be displayed when no items are selected.
*
* ⚠️ When using this prop, make sure the label doesn't overlap with the empty displayed value.
* The label should either be hidden or forced to a shrunk state.
* @default false
*/
displayEmpty: true;
/**
* If `true`, `value` must be an array and the menu will support multiple selections.
* @default false
*/
multiple: true;
/**
* Render the selected value.
* You can only use it when the `native` prop is `false` (default).
*
* @param {any} value The `value` provided to the component.
* @returns {ReactNode}
*/
renderValue?: (value: T) => React.ReactNode;
};
""",
"""
/**
* If `true`, a value is displayed even if no items are selected.
*
* In order to display a meaningful value, a function can be passed to the `renderValue` prop which
* returns the value to be displayed when no items are selected.
*
* ⚠️ When using this prop, make sure the label doesn't overlap with the empty displayed value.
* The label should either be hidden or forced to a shrunk state.
* @default false
*/
displayEmpty?: boolean;
/**
* If `true`, `value` must be an array and the menu will support multiple selections.
* @default false
*/
multiple?: boolean;
/**
* Render the selected value.
* You can only use it when the `native` prop is `false` (default).
*
* @param {any} value The `value` provided to the component.
* @returns {ReactNode}
*/
renderValue?: (value: T) => React.ReactNode;
};
""",
)
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ kfc.version=7.34.0
# TEMP
kfc.es.mode=false
seskar.version=2.23.0
mui-material.version=5.15.10
mui-icons-material.version=5.15.10
mui-base.version=5.0.0-beta.36
mui-system.version=5.15.9
mui-lab.version=5.0.0-alpha.165
mui-material.version=5.15.11
mui-icons-material.version=5.15.11
mui-base.version=5.0.0-beta.37
mui-system.version=5.15.11
mui-lab.version=5.0.0-alpha.166
mui-x-date-pickers.version=5.0.20
mui-x-tree-view.version=6.17.0
kotlin-wrappers.version=1.0.0-pre.684
6 changes: 6 additions & 0 deletions mui-kotlin/src/jsMain/kotlin/mui/lab/Masonry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ external interface MasonryOwnProps :
*/
var spacing: mui.system.ResponsiveStyleValue<dynamic>?

/**
* Allows using sequential order rather than adding to shortest column
* @default false
*/
var sequential: Boolean?

/**
* Allows defining system overrides as well as additional CSS styles.
*/
Expand Down
2 changes: 1 addition & 1 deletion mui-kotlin/src/jsMain/kotlin/mui/material/Accordion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ external interface AccordionProps :

/**
* Props applied to the transition element.
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
*/
var TransitionProps: mui.material.transitions.TransitionProps?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ external interface AccordionSummaryClasses {

/**
* Styles applied to the children wrapper element unless `disableGutters={true}`.
* @deprecated Combine the [.MuiAccordionSummary-gutters](/material-ui/api/accordion-summary/#AccordionSummary-classes-gutters) and [.MuiAccordionSummary-content](/material-ui/api/accordion-summary/#AccordionSummary-classes-content) classes instead.
* @deprecated Combine the [.MuiAccordionSummary-gutters](/material-ui/api/accordion-summary/#AccordionSummary-classes-gutters) and [.MuiAccordionSummary-content](/material-ui/api/accordion-summary/#AccordionSummary-classes-content) classes instead. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
*/
var contentGutters: ClassName

Expand Down
44 changes: 14 additions & 30 deletions mui-kotlin/src/jsMain/kotlin/mui/material/Alert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import mui.system.SxProps
external interface AlertProps :
mui.system.StandardProps,
PaperProps,
mui.system.PropsWithSx {
mui.system.PropsWithSx,
AlertSlots {
/**
* The action to display. It renders after the message, at the end of the alert.
*/
Expand Down Expand Up @@ -43,8 +44,7 @@ external interface AlertProps :
/**
* The components used for each slot inside.
*
* This prop is an alias for the `slots` prop.
* It's recommended to use the `slots` prop instead.
* @deprecated use the `slots` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
*
* @default {}
*/
Expand All @@ -59,8 +59,7 @@ external interface AlertProps :
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* This prop is an alias for the `slotProps` prop.
* It's recommended to use the `slotProps` prop instead, as `componentsProps` will be deprecated in the future.
* @deprecated use the `slotProps` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
*
* @default {}
*/
Expand Down Expand Up @@ -112,38 +111,23 @@ external interface AlertProps :
var variant: AlertVariant?

/**
* The extra props for the slot components.
* You can override the existing props or add new ones.
*
* This prop is an alias for the `componentsProps` prop, which will be deprecated in the future.
*
* @default {}
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
var slotProps: SlotProps?

interface SlotProps {
var closeButton: react.Props? /* IconButtonProps */
var closeIcon: react.Props? /* SvgIconProps */
}
override var sx: SxProps<Theme>?
}

external interface AlertSlots {
/**
* The components used for each slot inside.
*
* This prop is an alias for the `components` prop, which will be deprecated in the future.
*
* @default {}
* The component that renders the close button.
* @default IconButton
*/
var slots: Slots?

interface Slots {
var closeButton: react.ElementType<*>?
var closeIcon: react.ElementType<*>?
}
var closeButton: react.ElementType<*>?

/**
* The system prop that allows defining system overrides as well as additional CSS styles.
* The component that renders the close icon.
* @default svg
*/
override var sx: SxProps<Theme>?
var closeIcon: react.ElementType<*>?
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mui-kotlin/src/jsMain/kotlin/mui/material/Collapse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ external interface CollapseProps :
* API:
*
* - [Collapse API](https://mui.com/material-ui/api/collapse/)
* - inherits [Transition API](http://reactcommunity.org/react-transition-group/transition/#Transition-props)
* - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition/#Transition-props)
*/

@JsName("default")
Expand Down
2 changes: 1 addition & 1 deletion mui-kotlin/src/jsMain/kotlin/mui/material/Dialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ external interface DialogProps :

/**
* Props applied to the transition element.
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
*/
var TransitionProps: mui.material.transitions.TransitionProps?
}
Expand Down
2 changes: 1 addition & 1 deletion mui-kotlin/src/jsMain/kotlin/mui/material/Fade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ external interface FadeProps :
* API:
*
* - [Fade API](https://mui.com/material-ui/api/fade/)
* - inherits [Transition API](http://reactcommunity.org/react-transition-group/transition/#Transition-props)
* - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition/#Transition-props)
*/
@JsName("default")
external val Fade: react.FC<FadeProps>
2 changes: 1 addition & 1 deletion mui-kotlin/src/jsMain/kotlin/mui/material/Grow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ external interface GrowProps :
* API:
*
* - [Grow API](https://mui.com/material-ui/api/grow/)
* - inherits [Transition API](http://reactcommunity.org/react-transition-group/transition/#Transition-props)
* - inherits [Transition API](https://reactcommunity.org/react-transition-group/transition/#Transition-props)
*/
@JsName("default")
external val Grow: react.FC<GrowProps>
Loading

0 comments on commit 0f30103

Please sign in to comment.