aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-05-13 15:31:14 +0200
committerRobert Jaros <rjaros@finn.pl>2019-05-13 15:31:14 +0200
commit1033041bb1b77fac4944beea2089dd6b897f56b1 (patch)
tree745bb7b2de0c6b6f82da52347bd360469209876c
parent6416ab05253ee96647541efa9521ff6ec84d8826 (diff)
parent70e5bfa3a4057dc1610e823d4846c66d6ca91f6f (diff)
downloadkvision-1033041bb1b77fac4944beea2089dd6b897f56b1.tar.gz
kvision-1033041bb1b77fac4944beea2089dd6b897f56b1.tar.bz2
kvision-1033041bb1b77fac4944beea2089dd6b897f56b1.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--Module.md4
-rw-r--r--build.gradle1
-rw-r--r--kvision-modules/kvision-moment/build.gradle9
-rw-r--r--kvision-modules/kvision-moment/package.json.d/project.info3
-rw-r--r--kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt36
-rw-r--r--kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt91
-rw-r--r--settings.gradle1
-rw-r--r--webpack.config.d/moment.js4
8 files changed, 149 insertions, 0 deletions
diff --git a/Module.md b/Module.md
index 276f7c55..ece5b49f 100644
--- a/Module.md
+++ b/Module.md
@@ -98,6 +98,10 @@ Predictable state container based on Redux library.
A set of components for creating multiplatform automatic JSON-RPC connectivity with a backend server.
+# Package pl.treksoft.kvision.moment
+
+A set of tools for parsing, validating, manipulating, and formatting dates based on Moment Library.
+
# Package pl.treksoft.kvision.tabulator
Full-featured grid/table component based on the Tabulator library.
diff --git a/build.gradle b/build.gradle
index 304bcf15..cb32f60f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -169,6 +169,7 @@ dokka {
'kvision-modules/kvision-datacontainer/src/main/kotlin',
'kvision-modules/kvision-dialog/src/main/kotlin',
'kvision-modules/kvision-redux/src/main/kotlin',
+ 'kvision-modules/kvision-moment/src/main/kotlin',
'kvision-modules/kvision-tabulator/src/main/kotlin',
'kvision-modules/kvision-remote/src/main/kotlin',
'kvision-modules/kvision-select-remote/src/main/kotlin',
diff --git a/kvision-modules/kvision-moment/build.gradle b/kvision-modules/kvision-moment/build.gradle
new file mode 100644
index 00000000..4325a38a
--- /dev/null
+++ b/kvision-modules/kvision-moment/build.gradle
@@ -0,0 +1,9 @@
+apply from: "../shared.gradle"
+
+kotlinFrontend {
+
+ npm {
+ dependency("moment", "2.24.0")
+ }
+
+}
diff --git a/kvision-modules/kvision-moment/package.json.d/project.info b/kvision-modules/kvision-moment/package.json.d/project.info
new file mode 100644
index 00000000..c68b247f
--- /dev/null
+++ b/kvision-modules/kvision-moment/package.json.d/project.info
@@ -0,0 +1,3 @@
+{
+ "description": "KVision Moment module"
+}
diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt
new file mode 100644
index 00000000..0000db83
--- /dev/null
+++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision
+
+internal val kVManagerMomentInit = KVManagerMoment.init()
+
+/**
+ * Internal singleton object which initializes and configures KVision Moment module.
+ */
+@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught")
+internal object KVManagerMoment {
+ fun init() {}
+
+ private val moment = try {
+ require("moment/min/moment-with-locales.js")
+ } catch (e: Throwable) {}
+}
diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt
new file mode 100644
index 00000000..9eb9d9a7
--- /dev/null
+++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017-present Robert Jaros
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package pl.treksoft.kvision.moment
+
+import kotlin.js.Date
+
+@Suppress("unused")
+@JsNonModule
+@JsModule("moment")
+open external class Moment {
+ constructor(dateArray: Array<dynamic>)
+ constructor(dateString: String, patter: String)
+ constructor(dateString: String)
+ constructor(date: Date)
+ constructor()
+
+ open fun add(duration: dynamic, key: String): dynamic = definedExternally
+ open fun subtract(duration: dynamic, key: String): dynamic = definedExternally
+ open fun startOf(key: String): dynamic = definedExternally
+ open fun endOf(key: String): dynamic = definedExternally
+ open fun local(): dynamic = definedExternally
+ open fun utc(): dynamic = definedExternally
+ open fun utcOffset(): dynamic = definedExternally
+ open fun utcOffset(amount: dynamic): dynamic = definedExternally
+ open fun utcOffset(amount: dynamic, keepExistingTimeOfDay: Boolean): dynamic = definedExternally
+ open fun format(pattern: String): dynamic = definedExternally
+ open fun format(): dynamic = definedExternally
+ open fun fromNow(): dynamic = definedExternally
+ open fun fromNow(withoutSuffix: Boolean): dynamic = definedExternally
+ open fun from(moment: dynamic): dynamic = definedExternally
+ open fun from(withoutSuffix: Boolean): dynamic = definedExternally
+ open fun toNow(): dynamic = definedExternally
+ open fun toNow(withoutPrefix: Boolean): dynamic = definedExternally
+ open fun to(moment: dynamic): dynamic = definedExternally
+ open fun to(withoutPrefix: Boolean): dynamic = definedExternally
+ open fun calendar(): dynamic = definedExternally
+ open fun calendar(referenceTime: dynamic): dynamic = definedExternally
+ open fun calendar(referenceTime: dynamic, formats: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic, key: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic, key: dynamic, floatingPoint: Boolean): dynamic = definedExternally
+ open fun valueOf(): dynamic = definedExternally
+ open fun unix(): dynamic = definedExternally
+ open fun daysInMonth(): dynamic = definedExternally
+ open fun toDate(): dynamic = definedExternally
+ open fun toArray(): dynamic = definedExternally
+ open fun toJSON(): dynamic = definedExternally
+ open fun toISOString(): dynamic = definedExternally
+ open fun toISOString(keepOffset: Boolean): dynamic = definedExternally
+ open fun toObject(): dynamic = definedExternally
+ open fun inspect(): dynamic = definedExternally
+ open fun isBefore(moment: dynamic): Boolean = definedExternally
+ open fun isBefore(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSame(moment: dynamic): Boolean = definedExternally
+ open fun isSame(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isAfter(moment: dynamic): Boolean = definedExternally
+ open fun isAfter(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSameOrBefore(moment: dynamic): Boolean = definedExternally
+ open fun isSameOrBefore(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSameOrAfter(moment: dynamic): Boolean = definedExternally
+ open fun isSameOrAfter(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic, key: String, inclusivity: String): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic, key: String): Boolean = definedExternally
+ open fun isDST(): Boolean = definedExternally
+ open fun isDSTShifted(): Boolean = definedExternally
+ open fun isLeapYear(): Boolean = definedExternally
+ open fun locale(locale: String): dynamic = definedExternally
+ open fun locale(resetLocale: Boolean): dynamic = definedExternally
+ open fun lang(locale: String): dynamic = definedExternally
+ open fun lang(resetLocale: Boolean): dynamic = definedExternally
+}
diff --git a/settings.gradle b/settings.gradle
index b077fe07..995d49dd 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -16,6 +16,7 @@ include 'kvision-modules:kvision-base',
'kvision-modules:kvision-dialog',
'kvision-modules:kvision-redux',
'kvision-modules:kvision-tabulator',
+ 'kvision-modules:kvision-moment',
'kvision-modules:kvision-remote',
'kvision-modules:kvision-select-remote',
'kvision-modules:kvision-server-jooby',
diff --git a/webpack.config.d/moment.js b/webpack.config.d/moment.js
new file mode 100644
index 00000000..e8db2ea0
--- /dev/null
+++ b/webpack.config.d/moment.js
@@ -0,0 +1,4 @@
+config.plugins.push(new webpack.ProvidePlugin({
+ moment: "moment",
+ "window.moment": "moment"
+}));