diff --git a/package.json b/package.json index 4ad9829..b8ac10a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": false, "name": "bluelib", - "version": "0.11.4", + "version": "0.11.5", "license": "AGPL-3.0-or-later", "source": "src/index.js", "main": "dist/index.js", diff --git a/src/components/Layout/HInput.js b/src/components/Layout/HInput.js new file mode 100644 index 0000000..afd6c48 --- /dev/null +++ b/src/components/Layout/HInput.js @@ -0,0 +1,11 @@ +import style from './HInput.less'; + +export default function (props) { + return ( + + ); +} diff --git a/src/components/Layout/HInput.less b/src/components/Layout/HInput.less new file mode 100644 index 0000000..16936d4 --- /dev/null +++ b/src/components/Layout/HInput.less @@ -0,0 +1,21 @@ +@import "../../styles/constants.less"; + +.label { + width: 100%; + display: flex; + align-items: center; + margin-top: 2px; + margin-bottom: 2px; +} + +.text { + flex-grow: 1; + max-width: 160px; + text-align: right; + margin-right: 4px; +} + +.input { + margin-left: 4px; + flex-grow: 2; +} diff --git a/src/index.js b/src/index.js index 6eb023a..2e70a15 100644 --- a/src/index.js +++ b/src/index.js @@ -7,6 +7,7 @@ import TablePanel from "./components/Elements/TablePanel"; import Timer from "./components/Elements/Timer"; import Todo from "./components/Elements/Todo"; +import HInput from "./components/Layout/HInput"; import Split from "./components/Layout/Split"; import BLatex from "./components/Rendering/BLatex"; @@ -28,6 +29,10 @@ import useRoyalnetInstanceValidator from "./hooks/useRoyalnetInstanceValidator"; import theme from "./styles/theme.less"; +import concatClass from "./utils/concatClass"; +import getEventValue from "./utils/getEventValue"; +import isString from "./utils/isString"; +import isValidDate from "./utils/isValidDate"; import stripTabs from "./utils/stripTabs"; import {royalnetApiRequest, RoyalnetApiError} from "./utils/royalnetApiRequest"; @@ -41,7 +46,10 @@ export { TablePanel, Timer, Todo, + + HInput, Split, + BLatex, Code, ILatex, @@ -49,14 +57,22 @@ export { LatexDisplay, Markdown, PLatex, + LatexDefaultDisplay, LatexDefaultInline, LatexRenderColor, RoyalnetInstanceUrl, + useFormValidator, useRoyalnetData, useRoyalnetInstanceValidator, + theme, + + concatClass, + getEventValue, + isString, + isValidDate, stripTabs, royalnetApiRequest, RoyalnetApiError, diff --git a/src/utils/concatClass.js b/src/utils/concatClass.js new file mode 100644 index 0000000..503c3aa --- /dev/null +++ b/src/utils/concatClass.js @@ -0,0 +1,25 @@ +export default function concatClass(...args) { + let result = ""; + + for(let i = 0; i < args.length; i++) { + let arg = args[i]; + if(arg instanceof Array) { + result += concatClass(...arg) + } + else if(typeof arg == "string" || arg instanceof String) { + result += arg + } + else if(arg === null || arg === undefined) { + continue + } + else { + throw Error(`Invalid type '${typeof(arg)}' passed to extendableClasses, which only accepts Arrays and Strings.`) + } + + if(i < args.length - 1) { + result += " " + } + } + + return result +} diff --git a/src/utils/getEventValue.js b/src/utils/getEventValue.js new file mode 100644 index 0000000..36f56cc --- /dev/null +++ b/src/utils/getEventValue.js @@ -0,0 +1,5 @@ +export default function(f) { + return function(event) { + return f(event.target.value) + } +} diff --git a/src/utils/isString.js b/src/utils/isString.js new file mode 100644 index 0000000..7caef67 --- /dev/null +++ b/src/utils/isString.js @@ -0,0 +1,3 @@ +export default function(s) { + return typeof s === "string" || s instanceof String +} diff --git a/src/utils/isValidDate.js b/src/utils/isValidDate.js new file mode 100644 index 0000000..26afe66 --- /dev/null +++ b/src/utils/isValidDate.js @@ -0,0 +1,3 @@ +export default function(d) { + return d instanceof Date && !isNaN(d.getTime()) +}