Merge develop

This commit is contained in:
Pieter Vander Vennet 2024-01-28 03:27:17 +01:00
commit 94f39e89fe
174 changed files with 3695 additions and 3420 deletions

View file

@ -4,8 +4,6 @@
import { Map as MlMap } from "maplibre-gl"
import { MapLibreAdaptor } from "../../Map/MapLibreAdaptor"
import MaplibreMap from "../../Map/MaplibreMap.svelte"
import ToSvelte from "../../Base/ToSvelte.svelte"
import Svg from "../../../Svg.js"
import Direction_stroke from "../../../assets/svg/Direction_stroke.svelte"
/**
@ -28,6 +26,7 @@
})
let mainElem: HTMLElement
function onPosChange(x: number, y: number) {
const rect = mainElem.getBoundingClientRect()
const dx = -(rect.left + rect.right) / 2 + x
@ -64,7 +63,7 @@
on:touchstart={(e) => onPosChange(e.touches[0].clientX, e.touches[0].clientY)}
>
<div class="absolute top-0 left-0 h-full w-full cursor-pointer">
<MaplibreMap {map} attribution={false} />
<MaplibreMap attribution={false} {map} />
</div>
<div bind:this={directionElem} class="absolute top-0 left-0 h-full w-full">

View file

@ -23,7 +23,7 @@
function update() {
const v = currentVal.data
const l = currentLang.data
if (translations.data === "" || translations.data === undefined) {
if (<any> translations.data === "" || translations.data === undefined) {
translations.data = {}
}
if (translations.data[l] === v) {
@ -35,7 +35,6 @@
onDestroy(
currentLang.addCallbackAndRunD((currentLang) => {
console.log("Applying current lang:", currentLang)
if (!translations.data) {
translations.data = {}
}
@ -45,7 +44,7 @@
)
onDestroy(
currentVal.addCallbackAndRunD((v) => {
currentVal.addCallbackAndRunD(() => {
update()
})
)

View file

@ -28,8 +28,12 @@
* This is only copied to 'value' when appropriate so that no invalid values leak outside;
* Additionally, the unit is added when copying
*/
let _value = new UIEventSource(value.data ?? "")
export let unvalidatedText = new UIEventSource(value.data ?? "")
if(unvalidatedText == /*Compare by reference!*/ value){
throw "Value and unvalidatedText may not be the same store!"
}
let validator: Validator = Validators.get(type ?? "string")
if (validator === undefined) {
console.warn("Didn't find a validator for type", type)
@ -41,13 +45,13 @@
if (unit && value.data) {
const [v, denom] = unit?.findDenomination(value.data, getCountry)
if (denom) {
_value.setData(v)
unvalidatedText.setData(v)
selectedUnit.setData(denom.canonical)
} else {
_value.setData(value.data ?? "")
unvalidatedText.setData(value.data ?? "")
}
} else {
_value.setData(value.data ?? "")
unvalidatedText.setData(value.data ?? "")
}
}
@ -67,8 +71,8 @@
validator = Validators.get(type ?? "string")
_placeholder = placeholder ?? validator?.getPlaceholder() ?? type
if (_value.data?.length > 0) {
feedback?.setData(validator?.getFeedback(_value.data, getCountry))
if (unvalidatedText.data?.length > 0) {
feedback?.setData(validator?.getFeedback(unvalidatedText.data, getCountry))
} else {
feedback?.setData(undefined)
}
@ -78,7 +82,7 @@
function setValues() {
// Update the value stores
const v = _value.data
const v = unvalidatedText.data
if (v === "") {
value.setData(undefined)
feedback?.setData(undefined)
@ -103,12 +107,12 @@
}
}
onDestroy(_value.addCallbackAndRun((_) => setValues()))
onDestroy(unvalidatedText.addCallbackAndRun((_) => setValues()))
if (unit === undefined) {
onDestroy(
value.addCallbackAndRunD((fromUpstream) => {
if (_value.data !== fromUpstream && fromUpstream !== "") {
_value.setData(fromUpstream)
if (unvalidatedText.data !== fromUpstream && fromUpstream !== "") {
unvalidatedText.setData(fromUpstream)
}
})
)
@ -131,7 +135,7 @@
)
}
const isValid = _value.map((v) => validator?.isValid(v, getCountry) ?? true)
const isValid = unvalidatedText.map((v) => validator?.isValid(v, getCountry) ?? true)
let htmlElem: HTMLInputElement | HTMLTextAreaElement
@ -149,7 +153,7 @@
{#if validator?.textArea}
<textarea
class="w-full"
bind:value={$_value}
bind:value={$unvalidatedText}
inputmode={validator?.inputmode ?? "text"}
placeholder={_placeholder}
bind:this={htmlElem}
@ -159,7 +163,7 @@
<div class={twMerge("inline-flex", cls)}>
<input
bind:this={htmlElem}
bind:value={$_value}
bind:value={$unvalidatedText}
class="w-full"
inputmode={validator?.inputmode ?? "text"}
placeholder={_placeholder}
@ -170,7 +174,7 @@
{/if}
{#if unit !== undefined}
<UnitInput {unit} {selectedUnit} textValue={_value} upstreamValue={value} {getCountry} />
<UnitInput {unit} {selectedUnit} textValue={unvalidatedText} upstreamValue={value} {getCountry} />
{/if}
</div>
{/if}

View file

@ -71,7 +71,7 @@ export abstract class Validator {
return Translations.t.validation[this.name].description
}
public isValid(key: string, getCountry?: () => string): boolean {
public isValid(_: string): boolean {
return true
}

View file

@ -3,7 +3,7 @@ import { Translation } from "../../i18n/Translation"
import Translations from "../../i18n/Translations"
export default class FediverseValidator extends Validator {
public static readonly usernameAtServer: RegExp = /^@?(\w+)@((\w|\.)+)$/
public static readonly usernameAtServer: RegExp = /^@?(\w+)@((\w|-|\.)+)$/
constructor() {
super(

View file

@ -1,14 +1,12 @@
import { Validator } from "../Validator"
import { Translation } from "../../i18n/Translation"
import Translations from "../../i18n/Translations"
import TagKeyValidator from "./TagKeyValidator"
import SimpleTagValidator from "./SimpleTagValidator"
/**
* Checks that the input conforms a JSON-encoded tag expression or a simpleTag`key=value`,
*/
export default class TagValidator extends Validator {
public readonly isMeta = true
constructor() {
super("tag", "A simple tag of the format `key=value` OR a tagExpression")
}

View file

@ -6,7 +6,7 @@ export default class TranslationValidator extends Validator {
super("translation", "Makes sure the the string is of format `Record<string, string>` ")
}
isValid(value: string, getCountry?: () => string): boolean {
isValid(value: string): boolean {
try {
JSON.parse(value)
return true