fix: Fix module location for some utils.

This commit is contained in:
Alexis Métaireau 2024-04-02 10:27:01 +02:00
parent 5aedf51d0c
commit 5526a3f4d2
5 changed files with 27 additions and 4 deletions

View file

@ -200,6 +200,19 @@ export function usableOption(options, option) {
return options[option] !== undefined && options[option] !== ''
}
/**
* Processes a template string by replacing placeholders with corresponding
* data values.
*
* Supports dot notation for nested objects and optional static fallbacks.
* If a value is not found, the placeholder is replaced with an empty string
* or left unchanged when 'ignore' is true.
*
* @param {string} str - The template string with placeholders.
* @param {Object} data - The data object from which to pull replacement values.
* @param {boolean} [ignore=false] - If true, leaves placeholders unchanged when no value is found.
* @returns {string} The processed string with placeholders replaced.
*/
export function greedyTemplate(str, data, ignore) {
function getValue(data, path) {
let value = data
@ -310,6 +323,16 @@ export function isDataImage(value) {
return value && value.length && value.startsWith('data:image')
}
/**
* Normalizes the input string by converting to lowercase
* and removing diacritics.
*
* If the input is nullish, it defaults to an empty string.
*
* @param {string} s - The string to be normalized.
* @returns {string} - The normalized string with lowercase
* characters and no diacritics.
*/
export function normalize(s) {
return (s || '')
.toLowerCase()

View file

@ -153,7 +153,7 @@ U.AutoComplete = L.Class.extend({
this.displaySelected(choice)
this.hide()
if (this.options.callback) {
U.Utils.bind(this.options.callback, this)(choice)
L.Util.bind(this.options.callback, this)(choice)
}
}
},

View file

@ -128,7 +128,7 @@ L.DomUtil.createCopiableInput = (parent, label, value) => {
'',
wrapper,
'',
() => U.Utils.copyToClipboard(input.value),
() => L.Util.copyToClipboard(input.value),
this
)
button.title = L._('copy')

View file

@ -1032,7 +1032,7 @@ U.Map = L.Map.extend({
{
label: L._('Copy link'),
callback: () => {
U.Utils.copyToClipboard(data.permissions.anonymous_edit_url)
L.Util.copyToClipboard(data.permissions.anonymous_edit_url)
this.ui.alert({
content: L._('Secret edit link copied to clipboard!'),
level: 'info',

View file

@ -760,7 +760,7 @@ U.DataLayer = L.Evented.extend({
U.Utils.sortFeatures(features, this.map.getOption('sortKey'), L.lang)
this._index = []
for (let i = 0; i < features.length; i++) {
this._index.push(U.Utils.stamp(features[i]))
this._index.push(L.Util.stamp(features[i]))
}
},