@felleslosninger/minid-elements 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { css, html, LitElement } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n override render() {\n return html`\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAClD,SAAS;AAChB,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BT;AACF;AA9Ba,eAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,YAAA;"}
1
+ {"version":3,"file":"spinner.js","sources":["../../src/components/spinner.component.ts"],"sourcesContent":["import { customElement, property } from 'lit/decorators.js';\nimport { css, html, LitElement, nothing } from 'lit';\nimport { styled } from '../mixins/tailwind.mixin';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-spinner': MinidSpinner;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: inline-flex;\n }\n `,\n];\n\n/**\n * Size and color can be adjusted with `font-size` and `color` css properties\n */\n@customElement('mid-spinner')\nexport class MinidSpinner extends styled(LitElement, styles) {\n\n @property()\n label = '';\n\n override render() {\n return html`\n ${!this.label\n ? nothing\n : html`<span class=\"sr-only\">${this.label}</span>`}\n <svg\n class=\"animate-spin-slow\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 50 50\"\n aria-hidden=\"true\"\n >\n <circle\n opacity=\"0.2\"\n stroke=\"currentColor\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n ></circle>\n <circle\n class=\"animate-dash\"\n cx=\"25\"\n cy=\"25\"\n r=\"20\"\n fill=\"none\"\n stroke-width=\"5\"\n stroke=\"currentColor\"\n ></circle>\n </svg>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAMO,IAAM,eAAN,cAA2B,OAAO,YAAY,MAAM,EAAE;AAAA,EAAtD,cAAA;AAAA,UAAA,GAAA,SAAA;AAGL,SAAA,QAAQ;AAAA,EAAA;AAAA,EAEC,SAAS;AAChB,WAAO;AAAA,QACH,CAAC,KAAK,QACJ,UACA,6BAA6B,KAAK,KAAK,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BxD;AACF;AAnCE,gBAAA;AAAA,EADC,SAAA;AAAS,GAFC,aAGX,WAAA,SAAA,CAAA;AAHW,eAAN,gBAAA;AAAA,EADN,cAAc,aAAa;AAAA,GACf,YAAA;"}
@@ -25,6 +25,7 @@ declare const MinidTextfield_base: import('../types/mixin-constructor.ts').Const
25
25
  * @csspart field - The element that wraps the label, input, and help text.
26
26
  * @csspart clear-button - The clear button
27
27
  * @csspart password-toggle-button - The button for toggling password visibility
28
+ * @csspart validation-message - The error message shown by `invalidmessage`.
28
29
  */
29
30
  export declare class MinidTextfield extends MinidTextfield_base {
30
31
  private readonly inputId;
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.component.d.ts","sourceRoot":"","sources":["../../src/components/textfield.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAW,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAiB1E,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKjD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,cAAc,CAAC;KACjC;CACF;;AAyBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,cAAe,SAAQ,mBAA4C;IAC9E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAU;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4D;IAC7F,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,YAAY,CAAM;IAG1B,KAAK,EAAG,gBAAgB,CAAC;IAGzB,KAAK,SAAM;IAGX,WAAW,SAAM;IAGjB,KAAK,SAAM;IAGX,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAQ;IAGhC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IAEH,SAAS,UAAS;IAElB;;OAEG;IAEH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42
42
  .ds-field-affixes {
43
43
  background: var(--ds-color-neutral-background-tinted);
44
44
  }
45
+
46
+ /* The validation message stays in the DOM so its text lands in a live region
47
+ the screen reader is already watching - WebKit does not reliably announce
48
+ one revealed at the same moment the text arrives. When empty it must paint
49
+ nothing and take no room: the element drops the ds-validation-message class
50
+ (whose ::before paints an error icon regardless of the text) and this rule
51
+ cancels the sibling spacing from .ds-field > * + *, which the .ds-field >
52
+ prefix is enough to outrank without !important. */
53
+ .ds-field > .validation-message--empty {
54
+ margin-top: 0;
55
+ }
45
56
  `
46
57
  ];
47
58
  let nextUniqueId = 0;
@@ -230,6 +241,7 @@ let MinidTextfield = class extends FormControlMixin(styled(LitElement, styles))
230
241
  .value=${live(this.value)}
231
242
  ?disabled=${this.disabled}
232
243
  ?readonly=${this.readonly}
244
+ ?required=${this.required}
233
245
  ?autofocus=${this.autofocus}
234
246
  autocomplete=${ifDefined(this.autocomplete)}
235
247
  type=${this.type === "password" && this.passwordvisible ? "text" : this.type}
@@ -292,10 +304,13 @@ let MinidTextfield = class extends FormControlMixin(styled(LitElement, styles))
292
304
  ${hasSuffix ? html`<span part="suffix" class="ds-field-affix"><slot name="suffix"></slot></span>` : html`<slot name="suffix"></slot>`}
293
305
  </div>
294
306
  <p
295
- class="ds-validation-message"
307
+ class="${classMap({
308
+ "ds-validation-message": !!this.invalidmessage,
309
+ "validation-message--empty": !this.invalidmessage
310
+ })}"
311
+ part="validation-message"
296
312
  id="${this.validationId}"
297
313
  aria-live="polite"
298
- ?hidden=${!this.invalidmessage}
299
314
  >
300
315
  ${this.invalidmessage}
301
316
  </p>
@@ -1 +1 @@
1
- {"version":3,"file":"textfield.js","sources":["../../src/components/textfield.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { stringConverter } from '../internal/string-converter';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { HasSlotController } from '../internal/slot';\nimport { FormControlMixin } from '../mixins/form-control.mixin';\nimport {\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n requiredValidator,\n typeMismatchValidator,\n} from '../mixins/validators';\nimport { watch } from '../internal/watch';\nimport './icon/icon.component.ts';\nimport { MaskInput, type MaskType } from 'maska';\nimport { getLang } from '../utilities/lang';\nimport { getTranslations } from '../utilities/translations';\nimport { LangController } from '../controllers/lang.controller.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-textfield': MinidTextfield;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n\n /* Hide increment/decrement buttons on inputs */\n input[type='number']::-webkit-outer-spin-button,\n input[type='number']::-webkit-inner-spin-button,\n input[type='number'] {\n -webkit-appearance: none;\n margin: 0;\n -moz-appearance: textfield !important;\n }\n\n .ds-field-affixes {\n background: var(--ds-color-neutral-background-tinted);\n }\n `,\n];\n\nlet nextUniqueId = 0;\n\n/**\n *\n * @event mid-change - Emitted when a change to the input value is comitted by the user\n * @event mid-input - Emitted when the input element recieves input\n * @event mid-clear - Emitted when the input value is cleared\n * @event mid-focus - Emitted when input element is focused\n * @event mid-blur - Emitted when focus moves away from input element\n * @event {detail: { validity: ValidityState }} mid-invalid-hide - Emitted when the error message should be hidden\n * @event {detail: { validity: ValidityState }} mid-invalid-show - Emitted when the error message should be shown\n *\n * @slot prefix - Used for decoration to the left of the input\n * @slot suffix - Used for decoration to the right of the input\n * @slot label - The input's label. Alternatively, you can use the `label` attribute.\n *\n * @csspart base - The input's wrapper that has the input field styling.\n * @csspart input - The internal `<input>` element.\n * @csspart field - The element that wraps the label, input, and help text.\n * @csspart clear-button - The clear button\n * @csspart password-toggle-button - The button for toggling password visibility\n */\n@customElement('mid-textfield')\nexport class MinidTextfield extends FormControlMixin(styled(LitElement, styles)) {\n private readonly inputId!: string;\n private readonly descriptionId!: string;\n private readonly validationId!: string;\n private readonly hasSlotControler = new HasSlotController(this, 'label', 'prefix', 'suffix');\n private inputMask?: MaskInput;\n private initialValue = '';\n\n @query('input')\n input!: HTMLInputElement;\n\n @property()\n label = '';\n\n @property()\n description = '';\n\n @property()\n value = '';\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property({ converter: stringConverter })\n placeholder?: string;\n\n /**\n * Autofocus the input field on page load\n */\n @property({ type: Boolean })\n autofocus = false;\n\n /**\n * User agent autocomplete hint\n */\n @property()\n autocomplete?: AutoFill;\n\n /**\n * The minimum length of input that will be considered valid.\n */\n @property({ type: Number })\n minlength?: number;\n\n /**\n * The maximum length of input that will be considered valid.\n */\n @property({ type: Number })\n maxlength?: number;\n\n /**\n * The input's minimum value. Only applies to date and number input types.\n */\n @property()\n min?: number | string;\n\n /**\n * The input's maximum value. Only applies to date and number input types.\n */\n @property()\n max?: number | string;\n\n /**\n * Error message to display when the input is invalid, also activates invalid styling\n */\n @property()\n invalidmessage = '';\n\n @property()\n type:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'file'\n | 'month'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url'\n | 'week' = 'text';\n\n /**\n * For displaying appropriate virtual keyboard\n */\n @property()\n inputmode:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal' = 'text';\n\n /**\n * Adds a clear button when the input is not empty.\n */\n @property({ type: Boolean })\n clearable = false;\n\n /**\n * Adds a button to toggle the password's visibility.\n * Only applies if type is password\n */\n @property({ type: Boolean })\n passwordtoggle = false;\n\n /**\n * Determines wether the password is currently visible.\n * Only applies if type is password\n */\n @property({ type: Boolean })\n passwordvisible = false;\n\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /**\n * A regular expression pattern to validate input against.\n */\n @property()\n pattern?: string;\n\n /**\n * Makes the input required\n */\n @property({ type: Boolean })\n required = false;\n\n /**\n * Visually hides `label` and `description` (still available for screen readers)\n */\n @property({ type: Boolean })\n hidelabel = false;\n\n /**\n * Modify input value based on mask e.g: `\"##:##\"` = 12:34.\n * `#`: /[0-9]/\n * `@`: /[a-zA-Z]/\n * `*`: /[a-zA-Z0-9]/\n * For more information go to https://beholdr.github.io/maska\n */\n @property()\n mask?: MaskType;\n\n @state()\n hasFocus = false;\n\n static get formControlValidators() {\n return [\n requiredValidator,\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n typeMismatchValidator,\n ];\n }\n\n constructor() {\n super();\n new LangController(this);\n nextUniqueId++;\n this.inputId = `mid-textfield-input-${nextUniqueId}`;\n this.descriptionId = `mid-textfield-description-${nextUniqueId}`;\n this.validationId = `mid-textfield-validation-${nextUniqueId}`;\n this.setValue(this.value);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.initialValue = this.value;\n }\n\n get validationTarget() {\n return this.input;\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.setValue(this.value);\n }\n\n disconnectedCallback(): void {\n this.inputMask?.destroy();\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n if (!event.defaultPrevented && !event.isComposing) {\n this.form.requestSubmit();\n }\n });\n }\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.dispatchEvent(\n new Event('mid-blur', { bubbles: true, composed: true })\n );\n }\n\n private handleChange() {\n this.value = this.input.value;\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n }\n\n private handleInput() {\n let tmp_value = this.input.value;\n\n if (this.type === 'number') {\n tmp_value = tmp_value.replace(/[^0-9]/g, '');\n }\n\n this.value = tmp_value;\n this.setValue(this.value);\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n\n private handleFocus() {\n this.hasFocus = true;\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handlePasswordToggle() {\n this.passwordvisible = !this.passwordvisible;\n }\n\n private handleClearClick(event: MouseEvent) {\n event.preventDefault();\n\n if (this.value !== '') {\n this.value = '';\n this.dispatchEvent(\n new Event('mid-clear', { composed: true, bubbles: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { composed: true, bubbles: true })\n );\n this.dispatchEvent(\n new Event('mid-change', { composed: true, bubbles: true })\n );\n }\n\n this.input.focus();\n }\n\n focus() {\n this.hasFocus = true;\n this.input.focus();\n }\n\n resetFormControl() {\n this.invalidmessage = '';\n this.value = this.initialValue;\n }\n\n forceError(message?: string): void {\n super.forceError(message);\n }\n\n @watch('value')\n handleValueUpdate() {\n this.setValue(this.value);\n }\n\n @watch('mask')\n async handleMaskUpdate() {\n if (!this.mask) return;\n await this.updateComplete;\n this.inputMask?.destroy();\n this.inputMask = new MaskInput(this.input, {\n mask: this.mask,\n eager: true,\n });\n }\n\n override render() {\n const lang = getLang(this);\n const t = getTranslations(lang);\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n const hasPrefix = this.hasSlotControler.test('prefix');\n const hasSuffix = this.hasSlotControler.test('suffix');\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const hasAffixes = hasPrefix || hasSuffix || hasClearIcon || (this.passwordtoggle && !this.disabled);\n const isClearIconVisible =\n hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n const describedBy = [\n this.description ? this.descriptionId : undefined,\n this.invalidmessage ? this.validationId : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n\n return html`\n <ds-field\n part=\"field\"\n class=\"ds-field\"\n data-size=${this.size}\n >\n <label\n for=\"${this.inputId}\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n })} ds-label\"\n >\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n ${this.description\n ? html`\n <div\n id=\"${this.descriptionId}\"\n part=\"description\"\n aria-hidden=\"true\"\n class=\"${classMap({\n 'sr-only': this.hidelabel,\n })}\"\n >\n ${this.description}\n </div>\n `\n : nothing}\n <div\n part=\"base\"\n class=\"${hasAffixes ? 'ds-field-affixes' : ''}\"\n >\n ${hasPrefix ? html`<span class=\"ds-field-affix\"><slot name=\"prefix\"></slot></span>` : html`<slot name=\"prefix\"></slot>`}\n <input\n id=\"${this.inputId}\"\n class=\"ds-input\"\n part=\"input\"\n lang=${lang}\n .value=${live(this.value)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?autofocus=${this.autofocus}\n autocomplete=${ifDefined(this.autocomplete as any)}\n type=${this.type === 'password' && this.passwordvisible\n ? 'text'\n : this.type}\n aria-describedby=${ifDefined(describedBy || undefined)}\n aria-invalid=${this.invalidmessage ? 'true' : 'false'}\n aria-errormessage=${ifDefined(\n this.invalidmessage ? this.validationId : undefined\n )}\n placeholder=${ifDefined(this.placeholder)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n pattern=${ifDefined(this.pattern)}\n inputmode=${this.inputmode}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}\n />\n ${isClearIconVisible\n ? html`\n <span class=\"ds-field-affix\" part=\"clear-button\">\n <button\n type=\"button\"\n class=\"focus-visible:focus-ring flex items-center justify-center rounded-sm\"\n aria-label=${t.clear}\n @click=${this.handleClearClick}\n >\n <mid-icon\n class=\"size-7\"\n library=\"nav-aksel\"\n name=\"trash\"\n ></mid-icon>\n </button>\n </span>\n `\n : ''}\n ${this.passwordtoggle && !this.disabled\n ? html`\n <span class=\"ds-field-affix\" part=\"password-toggle-button\">\n <button\n type=\"button\"\n class=\"focus-visible:focus-ring flex items-center justify-center rounded-sm\"\n aria-label=${this.passwordvisible\n ? t.hidePassword\n : t.showPassword}\n @click=${this.handlePasswordToggle}\n >\n ${this.passwordvisible\n ? html` <mid-icon\n class=\"size-7\"\n library=\"system\"\n name=\"eye-slash\"\n ></mid-icon>`\n : html`\n <mid-icon\n class=\"size-7\"\n library=\"system\"\n name=\"eye\"\n ></mid-icon>\n `}\n </button>\n </span>\n `\n : ''}\n ${hasSuffix ? html`<span part=\"suffix\" class=\"ds-field-affix\"><slot name=\"suffix\"></slot></span>` : html`<slot name=\"suffix\"></slot>`}\n </div>\n <p\n class=\"ds-validation-message\"\n id=\"${this.validationId}\"\n aria-live=\"polite\"\n ?hidden=${!this.invalidmessage}\n >\n ${this.invalidmessage}\n </p>\n </ds-field>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBF;AAEA,IAAI,eAAe;AAuBZ,IAAM,iBAAN,cAA6B,iBAAiB,OAAO,YAAY,MAAM,CAAC,EAAE;AAAA,EAoK/E,cAAc;AACZ,UAAA;AAjKF,SAAiB,mBAAmB,IAAI,kBAAkB,MAAM,SAAS,UAAU,QAAQ;AAE3F,SAAQ,eAAe;AAMvB,SAAA,QAAQ;AAGR,SAAA,cAAc;AAGd,SAAA,QAAQ;AAGR,SAAA,OAA2B;AAS3B,SAAA,YAAY;AAoCZ,SAAA,iBAAiB;AAGjB,SAAA,OAaa;AAMb,SAAA,YAOgB;AAMhB,SAAA,YAAY;AAOZ,SAAA,iBAAiB;AAOjB,SAAA,kBAAkB;AAGlB,SAAA,WAAW;AAGX,SAAA,WAAW;AAYX,SAAA,WAAW;AAMX,SAAA,YAAY;AAaZ,SAAA,WAAW;AAcT,QAAI,eAAe,IAAI;AACvB;AACA,SAAK,UAAU,uBAAuB,YAAY;AAClD,SAAK,gBAAgB,6BAA6B,YAAY;AAC9D,SAAK,e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A;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA3GhB,eA4GX,WAAA,kBAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAlHhB,eAmHX,WAAA,mBAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GArH/B,eAsHX,WAAA,YAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,GAxH/B,eAyHX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAA;AAAS,GA9HC,eA+HX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GApIhB,eAqIX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GA1IhB,eA2IX,WAAA,aAAA,CAAA;AAUA,gBAAA;AAAA,EADC,SAAA;AAAS,GApJC,eAqJX,WAAA,QAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAA;AAAM,GAvJI,eAwJX,WAAA,YAAA,CAAA;AA8HA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GArRH,eAsRX,WAAA,qBAAA,CAAA;AAKM,gBAAA;AAAA,EADL,MAAM,MAAM;AAAA,GA1RF,eA2RL,WAAA,oBAAA,CAAA;AA3RK,iBAAN,gBAAA;AAAA,EADN,cAAc,eAAe;AAAA,GACjB,cAAA;"}
1
+ {"version":3,"file":"textfield.js","sources":["../../src/components/textfield.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing, type PropertyValues } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { stringConverter } from '../internal/string-converter';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styled } from '../mixins/tailwind.mixin.ts';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { HasSlotController } from '../internal/slot';\nimport { FormControlMixin } from '../mixins/form-control.mixin';\nimport {\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n requiredValidator,\n typeMismatchValidator,\n} from '../mixins/validators';\nimport { watch } from '../internal/watch';\nimport './icon/icon.component.ts';\nimport { MaskInput, type MaskType } from 'maska';\nimport { getLang } from '../utilities/lang';\nimport { getTranslations } from '../utilities/translations';\nimport { LangController } from '../controllers/lang.controller.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'mid-textfield': MinidTextfield;\n }\n}\n\nconst styles = [\n css`\n :host {\n display: block;\n }\n\n /* Hide increment/decrement buttons on inputs */\n input[type='number']::-webkit-outer-spin-button,\n input[type='number']::-webkit-inner-spin-button,\n input[type='number'] {\n -webkit-appearance: none;\n margin: 0;\n -moz-appearance: textfield !important;\n }\n\n .ds-field-affixes {\n background: var(--ds-color-neutral-background-tinted);\n }\n\n /* The validation message stays in the DOM so its text lands in a live region\n the screen reader is already watching - WebKit does not reliably announce\n one revealed at the same moment the text arrives. When empty it must paint\n nothing and take no room: the element drops the ds-validation-message class\n (whose ::before paints an error icon regardless of the text) and this rule\n cancels the sibling spacing from .ds-field > * + *, which the .ds-field >\n prefix is enough to outrank without !important. */\n .ds-field > .validation-message--empty {\n margin-top: 0;\n }\n `,\n];\n\nlet nextUniqueId = 0;\n\n/**\n *\n * @event mid-change - Emitted when a change to the input value is comitted by the user\n * @event mid-input - Emitted when the input element recieves input\n * @event mid-clear - Emitted when the input value is cleared\n * @event mid-focus - Emitted when input element is focused\n * @event mid-blur - Emitted when focus moves away from input element\n * @event {detail: { validity: ValidityState }} mid-invalid-hide - Emitted when the error message should be hidden\n * @event {detail: { validity: ValidityState }} mid-invalid-show - Emitted when the error message should be shown\n *\n * @slot prefix - Used for decoration to the left of the input\n * @slot suffix - Used for decoration to the right of the input\n * @slot label - The input's label. Alternatively, you can use the `label` attribute.\n *\n * @csspart base - The input's wrapper that has the input field styling.\n * @csspart input - The internal `<input>` element.\n * @csspart field - The element that wraps the label, input, and help text.\n * @csspart clear-button - The clear button\n * @csspart password-toggle-button - The button for toggling password visibility\n * @csspart validation-message - The error message shown by `invalidmessage`.\n */\n@customElement('mid-textfield')\nexport class MinidTextfield extends FormControlMixin(styled(LitElement, styles)) {\n private readonly inputId!: string;\n private readonly descriptionId!: string;\n private readonly validationId!: string;\n private readonly hasSlotControler = new HasSlotController(this, 'label', 'prefix', 'suffix');\n private inputMask?: MaskInput;\n private initialValue = '';\n\n @query('input')\n input!: HTMLInputElement;\n\n @property()\n label = '';\n\n @property()\n description = '';\n\n @property()\n value = '';\n\n @property()\n size: 'sm' | 'md' | 'lg' = 'md';\n\n @property({ converter: stringConverter })\n placeholder?: string;\n\n /**\n * Autofocus the input field on page load\n */\n @property({ type: Boolean })\n autofocus = false;\n\n /**\n * User agent autocomplete hint\n */\n @property()\n autocomplete?: AutoFill;\n\n /**\n * The minimum length of input that will be considered valid.\n */\n @property({ type: Number })\n minlength?: number;\n\n /**\n * The maximum length of input that will be considered valid.\n */\n @property({ type: Number })\n maxlength?: number;\n\n /**\n * The input's minimum value. Only applies to date and number input types.\n */\n @property()\n min?: number | string;\n\n /**\n * The input's maximum value. Only applies to date and number input types.\n */\n @property()\n max?: number | string;\n\n /**\n * Error message to display when the input is invalid, also activates invalid styling\n */\n @property()\n invalidmessage = '';\n\n @property()\n type:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'file'\n | 'month'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url'\n | 'week' = 'text';\n\n /**\n * For displaying appropriate virtual keyboard\n */\n @property()\n inputmode:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal' = 'text';\n\n /**\n * Adds a clear button when the input is not empty.\n */\n @property({ type: Boolean })\n clearable = false;\n\n /**\n * Adds a button to toggle the password's visibility.\n * Only applies if type is password\n */\n @property({ type: Boolean })\n passwordtoggle = false;\n\n /**\n * Determines wether the password is currently visible.\n * Only applies if type is password\n */\n @property({ type: Boolean })\n passwordvisible = false;\n\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @property({ type: Boolean, reflect: true })\n readonly = false;\n\n /**\n * A regular expression pattern to validate input against.\n */\n @property()\n pattern?: string;\n\n /**\n * Makes the input required\n */\n @property({ type: Boolean })\n required = false;\n\n /**\n * Visually hides `label` and `description` (still available for screen readers)\n */\n @property({ type: Boolean })\n hidelabel = false;\n\n /**\n * Modify input value based on mask e.g: `\"##:##\"` = 12:34.\n * `#`: /[0-9]/\n * `@`: /[a-zA-Z]/\n * `*`: /[a-zA-Z0-9]/\n * For more information go to https://beholdr.github.io/maska\n */\n @property()\n mask?: MaskType;\n\n @state()\n hasFocus = false;\n\n static get formControlValidators() {\n return [\n requiredValidator,\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n typeMismatchValidator,\n ];\n }\n\n constructor() {\n super();\n new LangController(this);\n nextUniqueId++;\n this.inputId = `mid-textfield-input-${nextUniqueId}`;\n this.descriptionId = `mid-textfield-description-${nextUniqueId}`;\n this.validationId = `mid-textfield-validation-${nextUniqueId}`;\n this.setValue(this.value);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.initialValue = this.value;\n }\n\n get validationTarget() {\n return this.input;\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.setValue(this.value);\n }\n\n disconnectedCallback(): void {\n this.inputMask?.destroy();\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n if (!event.defaultPrevented && !event.isComposing) {\n this.form.requestSubmit();\n }\n });\n }\n }\n\n private handleBlur() {\n this.hasFocus = false;\n this.dispatchEvent(\n new Event('mid-blur', { bubbles: true, composed: true })\n );\n }\n\n private handleChange() {\n this.value = this.input.value;\n this.dispatchEvent(\n new Event('mid-change', { bubbles: true, composed: true })\n );\n }\n\n private handleInput() {\n let tmp_value = this.input.value;\n\n if (this.type === 'number') {\n tmp_value = tmp_value.replace(/[^0-9]/g, '');\n }\n\n this.value = tmp_value;\n this.setValue(this.value);\n this.dispatchEvent(\n new Event('mid-input', { bubbles: true, composed: true })\n );\n }\n\n private handleFocus() {\n this.hasFocus = true;\n this.dispatchEvent(\n new Event('mid-focus', { composed: true, bubbles: true })\n );\n }\n\n private handlePasswordToggle() {\n this.passwordvisible = !this.passwordvisible;\n }\n\n private handleClearClick(event: MouseEvent) {\n event.preventDefault();\n\n if (this.value !== '') {\n this.value = '';\n this.dispatchEvent(\n new Event('mid-clear', { composed: true, bubbles: true })\n );\n this.dispatchEvent(\n new Event('mid-input', { composed: true, bubbles: true })\n );\n this.dispatchEvent(\n new Event('mid-change', { composed: true, bubbles: true })\n );\n }\n\n this.input.focus();\n }\n\n focus() {\n this.hasFocus = true;\n this.input.focus();\n }\n\n resetFormControl() {\n this.invalidmessage = '';\n this.value = this.initialValue;\n }\n\n forceError(message?: string): void {\n super.forceError(message);\n }\n\n @watch('value')\n handleValueUpdate() {\n this.setValue(this.value);\n }\n\n @watch('mask')\n async handleMaskUpdate() {\n if (!this.mask) return;\n await this.updateComplete;\n this.inputMask?.destroy();\n this.inputMask = new MaskInput(this.input, {\n mask: this.mask,\n eager: true,\n });\n }\n\n override render() {\n const lang = getLang(this);\n const t = getTranslations(lang);\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n const hasPrefix = this.hasSlotControler.test('prefix');\n const hasSuffix = this.hasSlotControler.test('suffix');\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const hasAffixes = hasPrefix || hasSuffix || hasClearIcon || (this.passwordtoggle && !this.disabled);\n const isClearIconVisible =\n hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n const describedBy = [\n this.description ? this.descriptionId : undefined,\n this.invalidmessage ? this.validationId : undefined,\n ]\n .filter(Boolean)\n .join(' ');\n\n return html`\n <ds-field\n part=\"field\"\n class=\"ds-field\"\n data-size=${this.size}\n >\n <label\n for=\"${this.inputId}\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n })} ds-label\"\n >\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n ${this.description\n ? html`\n <div\n id=\"${this.descriptionId}\"\n part=\"description\"\n aria-hidden=\"true\"\n class=\"${classMap({\n 'sr-only': this.hidelabel,\n })}\"\n >\n ${this.description}\n </div>\n `\n : nothing}\n <div\n part=\"base\"\n class=\"${hasAffixes ? 'ds-field-affixes' : ''}\"\n >\n ${hasPrefix ? html`<span class=\"ds-field-affix\"><slot name=\"prefix\"></slot></span>` : html`<slot name=\"prefix\"></slot>`}\n <input\n id=\"${this.inputId}\"\n class=\"ds-input\"\n part=\"input\"\n lang=${lang}\n .value=${live(this.value)}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n ?autofocus=${this.autofocus}\n autocomplete=${ifDefined(this.autocomplete as any)}\n type=${this.type === 'password' && this.passwordvisible\n ? 'text'\n : this.type}\n aria-describedby=${ifDefined(describedBy || undefined)}\n aria-invalid=${this.invalidmessage ? 'true' : 'false'}\n aria-errormessage=${ifDefined(\n this.invalidmessage ? this.validationId : undefined\n )}\n placeholder=${ifDefined(this.placeholder)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n pattern=${ifDefined(this.pattern)}\n inputmode=${this.inputmode}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @focus=${this.handleFocus}\n @blur=${this.handleBlur}\n @keydown=${this.handleKeydown}\n />\n ${isClearIconVisible\n ? html`\n <span class=\"ds-field-affix\" part=\"clear-button\">\n <button\n type=\"button\"\n class=\"focus-visible:focus-ring flex items-center justify-center rounded-sm\"\n aria-label=${t.clear}\n @click=${this.handleClearClick}\n >\n <mid-icon\n class=\"size-7\"\n library=\"nav-aksel\"\n name=\"trash\"\n ></mid-icon>\n </button>\n </span>\n `\n : ''}\n ${this.passwordtoggle && !this.disabled\n ? html`\n <span class=\"ds-field-affix\" part=\"password-toggle-button\">\n <button\n type=\"button\"\n class=\"focus-visible:focus-ring flex items-center justify-center rounded-sm\"\n aria-label=${this.passwordvisible\n ? t.hidePassword\n : t.showPassword}\n @click=${this.handlePasswordToggle}\n >\n ${this.passwordvisible\n ? html` <mid-icon\n class=\"size-7\"\n library=\"system\"\n name=\"eye-slash\"\n ></mid-icon>`\n : html`\n <mid-icon\n class=\"size-7\"\n library=\"system\"\n name=\"eye\"\n ></mid-icon>\n `}\n </button>\n </span>\n `\n : ''}\n ${hasSuffix ? html`<span part=\"suffix\" class=\"ds-field-affix\"><slot name=\"suffix\"></slot></span>` : html`<slot name=\"suffix\"></slot>`}\n </div>\n <p\n class=\"${classMap({\n 'ds-validation-message': !!this.invalidmessage,\n 'validation-message--empty': !this.invalidmessage,\n })}\"\n part=\"validation-message\"\n id=\"${this.validationId}\"\n aria-live=\"polite\"\n >\n ${this.invalidmessage}\n </p>\n </ds-field>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BF;AAEA,IAAI,eAAe;AAwBZ,IAAM,iBAAN,cAA6B,iBAAiB,OAAO,YAAY,MAAM,CAAC,EAAE;AAAA,EAoK/E,cAAc;AACZ,UAAA;AAjKF,SAAiB,mBAAmB,IAAI,kBAAkB,MAAM,SAAS,UAAU,QAAQ;AAE3F,SAAQ,eAAe;AAMvB,SAAA,QAAQ;AAGR,SAAA,cAAc;AAGd,S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wJX,WAAA,YAAA,CAAA;AA8HA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GArRH,eAsRX,WAAA,qBAAA,CAAA;AAKM,gBAAA;AAAA,EADL,MAAM,MAAM;AAAA,GA1RF,eA2RL,WAAA,oBAAA,CAAA;AA3RK,iBAAN,gBAAA;AAAA,EADN,cAAc,eAAe;AAAA,GACjB,cAAA;"}
@@ -8,6 +8,7 @@ export interface ComponentTranslations {
8
8
  hidePassword: string;
9
9
  openCountrySelector: string;
10
10
  close: string;
11
+ loading: string;
11
12
  }
12
13
  /**
13
14
  * Override or extend translations for a given BCP-47 language tag.
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/utilities/translations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC3C,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAMnE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../src/utilities/translations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AA0CD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC3C,IAAI,CAIN;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAMnE"}
@@ -4,28 +4,32 @@ const builtins = {
4
4
  showPassword: "Vis passord",
5
5
  hidePassword: "Skjul passord",
6
6
  openCountrySelector: "Åpne landsvelger",
7
- close: "Lukk"
7
+ close: "Lukk",
8
+ loading: "Laster"
8
9
  },
9
10
  nn: {
10
11
  clear: "Tøm",
11
12
  showPassword: "Vis passord",
12
13
  hidePassword: "Gøym passord",
13
14
  openCountrySelector: "Opna landsveljar",
14
- close: "Lukk"
15
+ close: "Lukk",
16
+ loading: "Lastar"
15
17
  },
16
18
  se: {
17
19
  clear: "Sihko",
18
20
  showPassword: "Čájet sátnesuodji",
19
21
  hidePassword: "Čiehka sátnesuodji",
20
22
  openCountrySelector: "Rahpat riikkaválljenjoavkku",
21
- close: "Gidde"
23
+ close: "Gidde",
24
+ loading: "Viežžamin"
22
25
  },
23
26
  en: {
24
27
  clear: "Clear",
25
28
  showPassword: "Show password",
26
29
  hidePassword: "Hide password",
27
30
  openCountrySelector: "Open country selector",
28
- close: "Close"
31
+ close: "Close",
32
+ loading: "Loading"
29
33
  }
30
34
  };
31
35
  const registry = new Map(
@@ -1 +1 @@
1
- {"version":3,"file":"translations.js","sources":["../../src/utilities/translations.ts"],"sourcesContent":["/**\n * All UI strings that components render themselves (e.g. aria-labels on\n * icon-only buttons). Every supported language must provide all keys.\n */\nexport interface ComponentTranslations {\n clear: string;\n showPassword: string;\n hidePassword: string;\n openCountrySelector: string;\n close: string;\n}\n\n\nconst builtins: Record<string, ComponentTranslations> = {\n nb: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Skjul passord',\n openCountrySelector: 'Åpne landsvelger',\n close: 'Lukk',\n },\n nn: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Gøym passord',\n openCountrySelector: 'Opna landsveljar',\n close: 'Lukk',\n },\n se: {\n clear: 'Sihko',\n showPassword: 'Čájet sátnesuodji',\n hidePassword: 'Čiehka sátnesuodji',\n openCountrySelector: 'Rahpat riikkaválljenjoavkku',\n close: 'Gidde',\n },\n en: {\n clear: 'Clear',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n openCountrySelector: 'Open country selector',\n close: 'Close',\n },\n};\n\nconst registry = new Map<string, ComponentTranslations>(\n Object.entries(builtins)\n);\n\n/**\n * Override or extend translations for a given BCP-47 language tag.\n * Merges the provided strings with the existing entry for that tag, so you\n * only need to supply the keys you want to change.\n *\n * Call this once at app startup, before any components render.\n *\n * @example Override a single string for Norwegian Bokmål\n * ```ts\n * setTranslations('nb', { clear: 'Slett' });\n * ```\n *\n * @example Register a completely new language\n * ```ts\n * setTranslations('fr', {\n * clear: 'Effacer',\n * showPassword: 'Afficher le mot de passe',\n * hidePassword: 'Masquer le mot de passe',\n * });\n * ```\n */\nexport function setTranslations(\n lang: string,\n translations: Partial<ComponentTranslations>\n): void {\n const base = resolveBaseLang(lang);\n const existing = registry.get(lang) ?? registry.get(base) ?? builtins.nb;\n registry.set(lang, { ...existing, ...translations });\n}\n\n/**\n * Returns the translations for the given BCP-47 language tag.\n *\n * Resolution order:\n * 1. Exact tag match (e.g. `'nb-NO'`)\n * 2. Base language match (e.g. `'nb'` from `'nb-NO'`)\n * 3. Norwegian Bokmål as final fallback\n */\nexport function getTranslations(lang: string): ComponentTranslations {\n return (\n registry.get(lang) ??\n registry.get(resolveBaseLang(lang)) ??\n builtins.nb\n );\n}\n\nfunction resolveBaseLang(lang: string): string {\n return lang.toLowerCase().split('-')[0];\n}"],"names":[],"mappings":"AAaA,MAAM,WAAkD;AAAA,EACtD,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAAA,EAET,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,EAAA;AAEX;AAEA,MAAM,WAAW,IAAI;AAAA,EACnB,OAAO,QAAQ,QAAQ;AACzB;AAuBO,SAAS,gBACd,MACA,cACM;AACN,QAAM,OAAO,gBAAgB,IAAI;AACjC,QAAM,WAAW,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;AACtE,WAAS,IAAI,MAAM,EAAE,GAAG,UAAU,GAAG,cAAc;AACrD;AAUO,SAAS,gBAAgB,MAAqC;AACnE,SACE,SAAS,IAAI,IAAI,KACjB,SAAS,IAAI,gBAAgB,IAAI,CAAC,KAClC,SAAS;AAEb;AAEA,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,KAAK,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC;AACxC;"}
1
+ {"version":3,"file":"translations.js","sources":["../../src/utilities/translations.ts"],"sourcesContent":["/**\n * All UI strings that components render themselves (e.g. aria-labels on\n * icon-only buttons). Every supported language must provide all keys.\n */\nexport interface ComponentTranslations {\n clear: string;\n showPassword: string;\n hidePassword: string;\n openCountrySelector: string;\n close: string;\n loading: string;\n}\n\n\nconst builtins: Record<string, ComponentTranslations> = {\n nb: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Skjul passord',\n openCountrySelector: 'Åpne landsvelger',\n close: 'Lukk',\n loading: 'Laster',\n },\n nn: {\n clear: 'Tøm',\n showPassword: 'Vis passord',\n hidePassword: 'Gøym passord',\n openCountrySelector: 'Opna landsveljar',\n close: 'Lukk',\n loading: 'Lastar',\n },\n se: {\n clear: 'Sihko',\n showPassword: 'Čájet sátnesuodji',\n hidePassword: 'Čiehka sátnesuodji',\n openCountrySelector: 'Rahpat riikkaválljenjoavkku',\n close: 'Gidde',\n loading: 'Viežžamin',\n },\n en: {\n clear: 'Clear',\n showPassword: 'Show password',\n hidePassword: 'Hide password',\n openCountrySelector: 'Open country selector',\n close: 'Close',\n loading: 'Loading',\n },\n};\n\nconst registry = new Map<string, ComponentTranslations>(\n Object.entries(builtins)\n);\n\n/**\n * Override or extend translations for a given BCP-47 language tag.\n * Merges the provided strings with the existing entry for that tag, so you\n * only need to supply the keys you want to change.\n *\n * Call this once at app startup, before any components render.\n *\n * @example Override a single string for Norwegian Bokmål\n * ```ts\n * setTranslations('nb', { clear: 'Slett' });\n * ```\n *\n * @example Register a completely new language\n * ```ts\n * setTranslations('fr', {\n * clear: 'Effacer',\n * showPassword: 'Afficher le mot de passe',\n * hidePassword: 'Masquer le mot de passe',\n * });\n * ```\n */\nexport function setTranslations(\n lang: string,\n translations: Partial<ComponentTranslations>\n): void {\n const base = resolveBaseLang(lang);\n const existing = registry.get(lang) ?? registry.get(base) ?? builtins.nb;\n registry.set(lang, { ...existing, ...translations });\n}\n\n/**\n * Returns the translations for the given BCP-47 language tag.\n *\n * Resolution order:\n * 1. Exact tag match (e.g. `'nb-NO'`)\n * 2. Base language match (e.g. `'nb'` from `'nb-NO'`)\n * 3. Norwegian Bokmål as final fallback\n */\nexport function getTranslations(lang: string): ComponentTranslations {\n return (\n registry.get(lang) ??\n registry.get(resolveBaseLang(lang)) ??\n builtins.nb\n );\n}\n\nfunction resolveBaseLang(lang: string): string {\n return lang.toLowerCase().split('-')[0];\n}"],"names":[],"mappings":"AAcA,MAAM,WAAkD;AAAA,EACtD,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,EAAA;AAEb;AAEA,MAAM,WAAW,IAAI;AAAA,EACnB,OAAO,QAAQ,QAAQ;AACzB;AAuBO,SAAS,gBACd,MACA,cACM;AACN,QAAM,OAAO,gBAAgB,IAAI;AACjC,QAAM,WAAW,SAAS,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;AACtE,WAAS,IAAI,MAAM,EAAE,GAAG,UAAU,GAAG,cAAc;AACrD;AAUO,SAAS,gBAAgB,MAAqC;AACnE,SACE,SAAS,IAAI,IAAI,KACjB,SAAS,IAAI,gBAAgB,IAAI,CAAC,KAClC,SAAS;AAEb;AAEA,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,KAAK,YAAA,EAAc,MAAM,GAAG,EAAE,CAAC;AACxC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felleslosninger/minid-elements",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "MinID Web Components",
5
5
  "author": "Digitaliseringsdirektoratet",
6
6
  "license": "MIT",
@@ -174,6 +174,7 @@
174
174
  "@changesets/cli": "^2.30.0",
175
175
  "@custom-elements-manifest/analyzer": "^0.10.3",
176
176
  "@digdir/designsystemet": "^1.13.2",
177
+ "@eslint/js": "^10.0.1",
177
178
  "@floating-ui/dom": "^1.6.10",
178
179
  "@navikt/aksel-icons": "^7.1.2",
179
180
  "@storybook/addon-a11y": "^9.0.12",
@@ -181,30 +182,26 @@
181
182
  "@storybook/addon-links": "^9.0.12",
182
183
  "@storybook/addon-vitest": "^9.0.12",
183
184
  "@storybook/builder-vite": "^9.0.12",
184
- "@storybook/test": "^8.6.14",
185
- "@storybook/test-runner": "^0.23.0",
186
185
  "@storybook/web-components-vite": "^9.0.12",
187
186
  "@tailwindcss/cli": "^4.1.6",
188
187
  "@types/node": "^22.7.4",
189
188
  "@types/qrcode": "^1.5.5",
190
189
  "@types/react": "^19.1.2",
191
190
  "@types/webappsec-credential-management": "^0.6.9",
192
- "@typescript-eslint/eslint-plugin": "^8.31.0",
193
- "@typescript-eslint/parser": "^8.31.0",
194
191
  "@u-elements/u-datalist": "^1.0.5",
195
192
  "@vitejs/plugin-basic-ssl": "^2.0.0",
196
193
  "@vitejs/plugin-legacy": "^6.1.0",
197
- "@vitest/browser": "^3.2.4",
198
- "@vitest/coverage-istanbul": "^3.2.4",
199
- "@vitest/coverage-v8": "^3.2.4",
200
- "axe-playwright": "^2.1.0",
201
- "concurrently": "^9.0.1",
202
- "eslint": "^9.25.1",
194
+ "@vitest/browser": "^3.2.7",
195
+ "@vitest/coverage-istanbul": "^3.2.7",
196
+ "@vitest/coverage-v8": "^3.2.7",
197
+ "concurrently": "^9.2.4",
198
+ "eslint": "^10.8.0",
203
199
  "eslint-plugin-storybook": "^9.0.12",
204
200
  "glob": "^13.0.6",
201
+ "globals": "^17.8.0",
205
202
  "jsdom": "^26.1.0",
206
203
  "playwright": "^1.53.0",
207
- "postcss": "^8.5.1",
204
+ "postcss": "^8.5.24",
208
205
  "prettier": "^3.5.3",
209
206
  "prettier-plugin-tailwindcss": "^0.6.11",
210
207
  "rimraf": "^6.0.1",
@@ -216,11 +213,12 @@
216
213
  "terser": "^5.24.0",
217
214
  "tslib": "^2.8.0",
218
215
  "typescript": "^5.6.3",
219
- "vite": "^6.1.0",
216
+ "typescript-eslint": "^8.65.0",
217
+ "vite": "^6.4.3",
220
218
  "vite-plugin-dts": "^4.2.3",
221
219
  "vite-plugin-externalize-deps": "^0.8.0",
222
220
  "vite-plugin-web-components-hmr": "^0.1.3",
223
- "vitest": "^3.2.4"
221
+ "vitest": "^3.2.7"
224
222
  },
225
223
  "scripts": {
226
224
  "make-icons": "node ./scripts/make-icons.js",
@@ -232,6 +230,7 @@
232
230
  "storybook:dev": "concurrently --kill-others \"pnpm run analyze -- --watch\" \"npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./.storybook/public/tailwind.css --watch\" \"pnpm run storybook\"",
233
231
  "storybook:build": "pnpm run build && rimraf storybook-static && pnpm run analyze && npx @tailwindcss/cli -i ./src/styles/tailwind.css -o ./.storybook/public/tailwind.css && pnpm exec storybook build",
234
232
  "analyze": "custom-elements-manifest analyze",
233
+ "lint": "eslint .",
235
234
  "build:theme": "pnpm exec designsystemet tokens create --config designsystemet.config.json && pnpm exec designsystemet tokens build --config designsystemet.config.json --experimental-tailwind",
236
235
  "release": "pnpm build && pnpm exec changeset publish"
237
236
  }