generated from mpetuska/template-kmp-library
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
666 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* N/A | ||
### New modules wrapped | ||
- [x] mdc-switch | ||
- [x] mdc-slider | ||
|
||
# 0.0.2 | ||
## Versions | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
kmdc/kmdc-segmented-button/src/jsMain/kotlin/MDCSegmentedButtonModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package dev.petuska.kmdc.segmented.button | ||
|
||
import dev.petuska.kmdc.core.MDCEvent | ||
import dev.petuska.kmdc.ripple.MDCRippleModule | ||
import org.w3c.dom.Element | ||
|
||
@JsModule("@material/segmented-button") | ||
public external object MDCSegmentedButtonModule { | ||
public class MDCSegmentedButton(element: Element) { | ||
public companion object { | ||
public fun attachTo(element: Element): MDCSegmentedButton | ||
} | ||
|
||
public val segments: Array<MDCSegmentedButtonSegment> | ||
public fun initialize( | ||
segmentFactory: ( | ||
el: Element, | ||
foundation: dynamic | ||
) -> MDCSegmentedButtonSegment = definedExternally | ||
) | ||
|
||
public fun initialSyncWithDOM() | ||
public fun destroy() | ||
public fun getDefaultFoundation(): dynamic | ||
public fun getSelectedSegments(): Array<dynamic> | ||
public fun selectSegment(indexOrSegmentId: dynamic) | ||
public fun unselectSegment(indexOrSegmentId: dynamic) | ||
public fun isSegmentSelected(indexOrSegmentId: dynamic): Boolean | ||
} | ||
|
||
public class MDCSegmentedButtonSegment(element: Element) { | ||
public companion object { | ||
public fun attachTo(element: Element): MDCSegmentedButtonSegment | ||
} | ||
|
||
public var ripple: MDCRippleModule.MDCRipple | ||
public fun initialize(rippleFactory: (el: Element, foundation: dynamic) -> MDCRippleModule.MDCRipple) | ||
public fun initialSyncWithDOM() | ||
public fun destroy() | ||
public fun getDefaultFoundation(): dynamic | ||
public fun setIndex(index: Number) | ||
public fun setIsSingleSelect(isSingleSelect: Boolean) | ||
public fun isSelected(): Boolean | ||
public fun setSelected() | ||
public fun setUnselected() | ||
public fun getSegmentId(): dynamic | ||
} | ||
|
||
public interface SegmentDetail { | ||
public val index: Number | ||
public val selected: Boolean | ||
public val segmentId: String? | ||
} | ||
|
||
public class MDCSegmentedButtonEvent : MDCEvent<SegmentDetail> | ||
|
||
public class MDCSegmentedButtonSegmentEvent : MDCEvent<SegmentDetail> | ||
public class MDCSegmentedButtonSegmentClickEvent : MDCEvent<Number> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package dev.petuska.kmdc.segmented.button | ||
|
||
import dev.petuska.kmdc.core.MDCAttrsDsl | ||
|
||
@JsModule("@material/segmented-button/segmented-button/constants") | ||
private external object SegmentedButtonModuleConstants { | ||
@Suppress("ClassName") | ||
object events { | ||
val CHANGE: String | ||
val SELECTED: String | ||
} | ||
} | ||
|
||
/** | ||
* [JS API](https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-segmented-button) | ||
*/ | ||
@MDCAttrsDsl | ||
public fun MDCSegmentedButtonAttrsScope.onSegmentSelected( | ||
listener: (event: MDCSegmentedButtonModule.MDCSegmentedButtonEvent) -> Unit | ||
) { | ||
addEventListener(SegmentedButtonModuleConstants.events.SELECTED) { | ||
listener(it.nativeEvent.unsafeCast<MDCSegmentedButtonModule.MDCSegmentedButtonEvent>()) | ||
} | ||
} | ||
|
||
/** | ||
* [JS API](https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-segmented-button) | ||
*/ | ||
@MDCAttrsDsl | ||
public fun MDCSegmentedButtonAttrsScope.onSegmentChange( | ||
listener: (event: MDCSegmentedButtonModule.MDCSegmentedButtonEvent) -> Unit | ||
) { | ||
addEventListener(SegmentedButtonModuleConstants.events.CHANGE) { | ||
listener(it.nativeEvent.unsafeCast<MDCSegmentedButtonModule.MDCSegmentedButtonEvent>()) | ||
} | ||
} | ||
|
||
@JsModule("@material/segmented-button/segment/constants") | ||
private external object SegmentModuleConstants { | ||
@Suppress("ClassName") | ||
object events { | ||
val CLICK: String | ||
val SELECTED: String | ||
} | ||
} | ||
|
||
/** | ||
* [JS API](https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-segmented-button) | ||
*/ | ||
@MDCAttrsDsl | ||
public fun MDCSegmentedButtonSegmentAttrsScope.onSegmentSelected( | ||
listener: (event: MDCSegmentedButtonModule.MDCSegmentedButtonSegmentEvent) -> Unit | ||
) { | ||
addEventListener(SegmentModuleConstants.events.SELECTED) { | ||
listener(it.nativeEvent.unsafeCast<MDCSegmentedButtonModule.MDCSegmentedButtonSegmentEvent>()) | ||
} | ||
} | ||
|
||
/** | ||
* [JS API](https://github.com/material-components/material-components-web/tree/v13.0.0/packages/mdc-segmented-button) | ||
*/ | ||
@MDCAttrsDsl | ||
public fun MDCSegmentedButtonSegmentAttrsScope.onSegmentClick( | ||
listener: (event: MDCSegmentedButtonModule.MDCSegmentedButtonSegmentClickEvent) -> Unit | ||
) { | ||
addEventListener(SegmentModuleConstants.events.CLICK) { | ||
listener(it.nativeEvent.unsafeCast<MDCSegmentedButtonModule.MDCSegmentedButtonSegmentClickEvent>()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import util.mdcVersion | ||
|
||
plugins { | ||
id("plugin.library-compose") | ||
id("plugin.publishing-mpp") | ||
} | ||
|
||
description = "Compose Multiplatform Kotlin/JS wrappers for @material/slider" | ||
|
||
kotlin { | ||
sourceSets { | ||
jsMain { | ||
dependencies { | ||
api(project(":kmdc:kmdc-core")) | ||
api(npm("@material/slider", mdcVersion)) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.