lion/packages/ui/components/validate-messages/src/per-entrypoint/loadComboboxMessagesNoSideEffects.js

22 lines
792 B
JavaScript

/* eslint-disable import/no-extraneous-dependencies */
import { MatchesOption } from '@lion/ui/combobox.js';
import { getLocalizedMessage } from '../getLocalizedMessage.js';
/**
* @typedef {import('../../../form-core/types/validate/validate.js').FeedbackMessageData} FeedbackMessageData
* @typedef {import('@lion/ui/localize.js').LocalizeManager} LocalizeManager
*/
let isLoaded = false;
/**
* @param {{localize: LocalizeManager}} opts allow multiple lion/extension lib versions to provide their deduped instance of LocalizeManager
*/
export function loadComboboxMessagesNoSideEffects({ localize }) {
if (isLoaded === true) return;
/** @param {FeedbackMessageData} data */
MatchesOption.getMessage = async data => getLocalizedMessage({ data, localize });
isLoaded = true;
}