import { localize, LocalizeMixin } from '@lion/localize'; import { loadDefaultFeedbackMessages, MaxLength, Validator } from '@lion/validate'; import { html, storiesOf } from '@open-wc/demoing-storybook'; import { LionInput } from '../index.js'; loadDefaultFeedbackMessages(); storiesOf('Forms|Input Localize').add('localize', () => { class InputValidationExample extends LocalizeMixin(LionInput) { static get localizeNamespaces() { return [ { 'input-localize-example': locale => import(`./translations/${locale}.js`) }, ...super.localizeNamespaces, ]; } async onLocaleUpdated() { super.onLocaleUpdated(); await this.localizeNamespacesLoaded; this.label = localize.msg('input-localize-example:label'); } } if (!customElements.get('input-localize-example')) { customElements.define('input-localize-example', InputValidationExample); } class NotEqualsString extends Validator { constructor(...args) { super(...args); this.name = 'NotEqualsString'; } execute(value, param) { const hasError = value === param; return hasError; } static async getMessage() { return localize.msg(`input-localize-example:error.notEqualsString`); } } return html`

Change the locale with the buttons below:

`; });