mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-10-20 23:00:29 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
8166d4b99b | |||
b61d2ae2eb | |||
4790fe0aea | |||
bc37b11cee | |||
223fed910f | |||
b85ab7b061 | |||
888dc299c9 | |||
e113dc28ed | |||
31e55d2307 | |||
e90645f248 | |||
4bb7ba2571 | |||
8d31c25bf8 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,5 +1,18 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.9.19
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Coroutines`: `1.6.0` -> `1.6.1`
|
||||||
|
* `Repos`:
|
||||||
|
* `Exposed`:
|
||||||
|
* Fixes in `ExposedStandardVersionsRepoProxy`
|
||||||
|
|
||||||
|
## 0.9.18
|
||||||
|
|
||||||
|
* `Common`
|
||||||
|
* New extensions for `Element`: `Element#onActionOutside` and `Element#onClickOutside`
|
||||||
|
|
||||||
## 0.9.17
|
## 0.9.17
|
||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
|
@@ -51,7 +51,6 @@ class EitherSerializer<T1, T2>(
|
|||||||
private val t1EitherSerializer = EitherFirst.serializer(t1Serializer, t2Serializer)
|
private val t1EitherSerializer = EitherFirst.serializer(t1Serializer, t2Serializer)
|
||||||
private val t2EitherSerializer = EitherSecond.serializer(t1Serializer, t2Serializer)
|
private val t2EitherSerializer = EitherSecond.serializer(t1Serializer, t2Serializer)
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class, InternalSerializationApi::class)
|
|
||||||
override fun deserialize(decoder: Decoder): Either<T1, T2> {
|
override fun deserialize(decoder: Decoder): Either<T1, T2> {
|
||||||
return decoder.decodeStructure(descriptor) {
|
return decoder.decodeStructure(descriptor) {
|
||||||
var type: String? = null
|
var type: String? = null
|
||||||
@@ -83,7 +82,6 @@ class EitherSerializer<T1, T2>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalSerializationApi::class, InternalSerializationApi::class)
|
|
||||||
override fun serialize(encoder: Encoder, value: Either<T1, T2>) {
|
override fun serialize(encoder: Encoder, value: Either<T1, T2>) {
|
||||||
encoder.encodeStructure(descriptor) {
|
encoder.encodeStructure(descriptor) {
|
||||||
when (value) {
|
when (value) {
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
package dev.inmo.micro_utils.common
|
||||||
|
|
||||||
|
import kotlinx.browser.document
|
||||||
|
import org.w3c.dom.*
|
||||||
|
import org.w3c.dom.events.Event
|
||||||
|
import org.w3c.dom.events.EventListener
|
||||||
|
|
||||||
|
fun Element.onActionOutside(type: String, options: dynamic = null, callback: (Event) -> Unit): EventListener {
|
||||||
|
lateinit var observer: MutationObserver
|
||||||
|
val listener = EventListener {
|
||||||
|
val elementsToCheck = mutableListOf<Element>(this@onActionOutside)
|
||||||
|
while (it.target != this@onActionOutside && elementsToCheck.isNotEmpty()) {
|
||||||
|
val childrenGettingElement = elementsToCheck.removeFirst()
|
||||||
|
for (i in 0 until childrenGettingElement.childElementCount) {
|
||||||
|
elementsToCheck.add(childrenGettingElement.children[i] ?: continue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (elementsToCheck.isEmpty()) {
|
||||||
|
callback(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options == null) {
|
||||||
|
document.addEventListener(type, listener)
|
||||||
|
} else {
|
||||||
|
document.addEventListener(type, listener, options)
|
||||||
|
}
|
||||||
|
observer = onRemoved {
|
||||||
|
if (options == null) {
|
||||||
|
document.removeEventListener(type, listener)
|
||||||
|
} else {
|
||||||
|
document.removeEventListener(type, listener, options)
|
||||||
|
}
|
||||||
|
observer.disconnect()
|
||||||
|
}
|
||||||
|
return listener
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Element.onClickOutside(options: dynamic = null, callback: (Event) -> Unit) = onActionOutside("click", options, callback)
|
@@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.9.17
|
version=0.9.19
|
||||||
android_code_version=107
|
android_code_version=109
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
kt = "1.6.10"
|
kt = "1.6.10"
|
||||||
kt-serialization = "1.3.2"
|
kt-serialization = "1.3.2"
|
||||||
kt-coroutines = "1.6.0"
|
kt-coroutines = "1.6.1"
|
||||||
|
|
||||||
jb-compose = "1.1.1"
|
jb-compose = "1.1.1"
|
||||||
jb-exposed = "0.37.3"
|
jb-exposed = "0.37.3"
|
||||||
|
@@ -13,12 +13,12 @@ interface VersionsRepo<T> : Repo {
|
|||||||
* By default, instance of this interface will check that version of table with name [tableName] is less than
|
* By default, instance of this interface will check that version of table with name [tableName] is less than
|
||||||
* [version] or is absent
|
* [version] or is absent
|
||||||
*
|
*
|
||||||
* * In case if [tableName] didn't found, will be called [onCreate] and version of table will be set up to [version]
|
* In case if [tableName] didn't found, will be called [onCreate]. Then in case if [tableName] have version less
|
||||||
* * In case if [tableName] have version less than parameter [version], it will increase version one-by-one
|
* than parameter [version] or null, it will increase version one-by-one until database version will be equal to
|
||||||
* until database version will be equal to [version]
|
* [version]
|
||||||
*
|
*
|
||||||
* @param version Current version of table
|
* @param version Current version of table
|
||||||
* @param onCreate This callback will be called in case when table have no information about table
|
* @param onCreate This callback will be called in case when repo have no information about table
|
||||||
* @param onUpdate This callback will be called after **iterative** changing of version. It is expected that parameter
|
* @param onUpdate This callback will be called after **iterative** changing of version. It is expected that parameter
|
||||||
* "to" will always be greater than "from"
|
* "to" will always be greater than "from"
|
||||||
*/
|
*/
|
||||||
|
@@ -19,7 +19,7 @@ class ExposedStandardVersionsRepoProxy(
|
|||||||
override val database: Database
|
override val database: Database
|
||||||
) : StandardVersionsRepoProxy<Database>, Table("ExposedVersionsProxy"), ExposedRepo {
|
) : StandardVersionsRepoProxy<Database>, Table("ExposedVersionsProxy"), ExposedRepo {
|
||||||
val tableNameColumn = text("tableName")
|
val tableNameColumn = text("tableName")
|
||||||
val tableVersionColumn = integer("tableName")
|
val tableVersionColumn = integer("tableVersion")
|
||||||
|
|
||||||
init {
|
init {
|
||||||
initTable()
|
initTable()
|
||||||
|
Reference in New Issue
Block a user