@felleslosninger/minid-elements 0.0.97 → 0.0.99
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.
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.js +44 -25
- package/dist/components/alert.js.map +1 -1
- package/dist/components/button.component.d.ts +4 -5
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.js +58 -53
- package/dist/components/button.js.map +1 -1
- package/dist/components/combobox.component.d.ts +1 -13
- package/dist/components/combobox.component.d.ts.map +1 -1
- package/dist/components/combobox.js +6 -17
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/{modal.component.d.ts → dialog.component.d.ts} +15 -16
- package/dist/components/dialog.component.d.ts.map +1 -0
- package/dist/components/{modal.js → dialog.js} +41 -77
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +4 -5
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.js +37 -57
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/heading.component.d.ts.map +1 -1
- package/dist/components/heading.js +9 -10
- package/dist/components/heading.js.map +1 -1
- package/dist/components/helptext.component.d.ts +1 -25
- package/dist/components/helptext.component.d.ts.map +1 -1
- package/dist/components/helptext.js +20 -48
- package/dist/components/helptext.js.map +1 -1
- package/dist/components/icon/icon.component.d.ts +1 -4
- package/dist/components/icon/icon.component.d.ts.map +1 -1
- package/dist/components/icon/icon.js +3 -12
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/link.component.d.ts +0 -4
- package/dist/components/link.component.d.ts.map +1 -1
- package/dist/components/link.js +3 -22
- package/dist/components/link.js.map +1 -1
- package/dist/components/menu-item.component.d.ts +0 -3
- package/dist/components/menu-item.component.d.ts.map +1 -1
- package/dist/components/menu-item.js +25 -57
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/menu.component.d.ts +2 -11
- package/dist/components/menu.component.d.ts.map +1 -1
- package/dist/components/menu.js +12 -48
- package/dist/components/menu.js.map +1 -1
- package/dist/components/paragraph.component.d.ts.map +1 -1
- package/dist/components/paragraph.js +5 -6
- package/dist/components/paragraph.js.map +1 -1
- package/dist/components/phone-input.component.d.ts +3 -4
- package/dist/components/phone-input.component.d.ts.map +1 -1
- package/dist/components/phone-input.js +23 -62
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popup.component.d.ts +2 -1
- package/dist/components/popup.component.d.ts.map +1 -1
- package/dist/components/popup.js +4 -0
- package/dist/components/popup.js.map +1 -1
- package/dist/components/radio-button.component.d.ts +0 -3
- package/dist/components/radio-button.component.d.ts.map +1 -1
- package/dist/components/radio-button.js.map +1 -1
- package/dist/components/radio.component.d.ts +0 -3
- package/dist/components/radio.component.d.ts.map +1 -1
- package/dist/components/radio.js +2 -5
- package/dist/components/radio.js.map +1 -1
- package/dist/components/textfield.component.d.ts +6 -29
- package/dist/components/textfield.component.d.ts.map +1 -1
- package/dist/components/textfield.js +55 -131
- package/dist/components/textfield.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +4 -37
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.js +18 -34
- package/dist/components/tooltip.js.map +1 -1
- package/dist/designsystemet-tailwind.css +293 -474
- package/dist/index.css +0 -1355
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/mixins/tailwind.mixin.d.ts.map +1 -1
- package/dist/mixins/tailwind.mixin.js +3 -4
- package/dist/mixins/tailwind.mixin.js.map +1 -1
- package/dist/types/animation-name.d.ts +1 -1
- package/dist/types/animation-name.d.ts.map +1 -1
- package/dist/utilities/country-labels-no.d.ts +4 -0
- package/dist/utilities/country-labels-no.d.ts.map +1 -0
- package/dist/utilities/{countries.js → country-labels-no.js} +3 -3
- package/dist/utilities/{countries.js.map → country-labels-no.js.map} +1 -1
- package/package.json +10 -4
- package/dist/components/modal.component.d.ts.map +0 -1
- package/dist/components/modal.js.map +0 -1
- package/dist/utilities/countries.d.ts +0 -3
- package/dist/utilities/countries.d.ts.map +0 -1
|
@@ -9,11 +9,9 @@ import { HasSlotController } from "../internal/slot.js";
|
|
|
9
9
|
import { FormControlMixin } from "../mixins/form-control.mixin.js";
|
|
10
10
|
import { requiredValidator, maxLengthValidator, minLengthValidator, patternValidator } from "../mixins/validators.js";
|
|
11
11
|
import { watch } from "../internal/watch.js";
|
|
12
|
+
import "./icon/icon.js";
|
|
12
13
|
var __defProp = Object.defineProperty;
|
|
13
14
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
-
var __typeError = (msg) => {
|
|
15
|
-
throw TypeError(msg);
|
|
16
|
-
};
|
|
17
15
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
18
16
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
19
17
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -22,65 +20,11 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
22
20
|
if (kind && result) __defProp(target, key, result);
|
|
23
21
|
return result;
|
|
24
22
|
};
|
|
25
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
26
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
27
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
28
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
29
|
-
var _initialValue;
|
|
30
23
|
const styles = [
|
|
31
24
|
css`
|
|
32
25
|
:host {
|
|
33
26
|
display: block;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
|
-
.form-control {
|
|
37
|
-
display: block;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.form-control:has(input:disabled) {
|
|
41
|
-
opacity: 0.3;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.fds-label {
|
|
45
|
-
margin-bottom: 0.5rem;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.input {
|
|
49
|
-
width: 100%;
|
|
50
|
-
outline: none;
|
|
51
|
-
box-shadow: none;
|
|
52
|
-
background-color: transparent;
|
|
53
|
-
padding: 0 1rem;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.field:has(.input:disabled) {
|
|
57
|
-
opacity: var(--fds-opacity-disabled);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.suffix,
|
|
61
|
-
.prefix {
|
|
62
|
-
display: flex;
|
|
63
|
-
place-items: center;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.suffix ::slotted(*) {
|
|
67
|
-
margin-inline-end: 1rem !important; // global style for button is margin: 0
|
|
68
|
-
border-radius: 4px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.prefix ::slotted(*) {
|
|
72
|
-
margin-inline-start: 1rem !important; // global style for button is margin: 0
|
|
73
|
-
border-radius: 4px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.fds-textfield__readonly__icon svg {
|
|
77
|
-
font-size: 1.2em;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.clear-button:not(:disabled, [aria-disabled]):hover mid-icon {
|
|
81
|
-
border-radius: 4px;
|
|
82
|
-
background: var(--fds-semantic-surface-action-subtle-hover);
|
|
83
|
-
}
|
|
84
28
|
`
|
|
85
29
|
];
|
|
86
30
|
let nextUniqueId = 0;
|
|
@@ -90,7 +34,7 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
90
34
|
constructor() {
|
|
91
35
|
super();
|
|
92
36
|
this.hasSlotControler = new HasSlotController(this, "label");
|
|
93
|
-
|
|
37
|
+
this.initialValue = "";
|
|
94
38
|
this.label = "";
|
|
95
39
|
this.description = "";
|
|
96
40
|
this.value = "";
|
|
@@ -110,9 +54,6 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
110
54
|
this.inputId = `mid-textfield-input-${nextUniqueId}`;
|
|
111
55
|
this.descriptionId = `mid-textfield-description-${nextUniqueId}`;
|
|
112
56
|
}
|
|
113
|
-
/**
|
|
114
|
-
* @ignore
|
|
115
|
-
*/
|
|
116
57
|
static get formControlValidators() {
|
|
117
58
|
return [
|
|
118
59
|
requiredValidator,
|
|
@@ -121,15 +62,12 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
121
62
|
patternValidator
|
|
122
63
|
];
|
|
123
64
|
}
|
|
124
|
-
/**
|
|
125
|
-
* @ignore
|
|
126
|
-
*/
|
|
127
65
|
get validationTarget() {
|
|
128
66
|
return this.input;
|
|
129
67
|
}
|
|
130
68
|
connectedCallback() {
|
|
131
69
|
super.connectedCallback();
|
|
132
|
-
|
|
70
|
+
this.initialValue = this.value;
|
|
133
71
|
}
|
|
134
72
|
handleKeydown(event) {
|
|
135
73
|
const hasModifier = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
@@ -191,7 +129,7 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
191
129
|
}
|
|
192
130
|
resetFormControl() {
|
|
193
131
|
this.invalidmessage = "";
|
|
194
|
-
this.value =
|
|
132
|
+
this.value = this.initialValue;
|
|
195
133
|
}
|
|
196
134
|
forceError(message) {
|
|
197
135
|
super.forceError(message);
|
|
@@ -209,72 +147,58 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
209
147
|
const isClearIconVisible = hasClearIcon && (typeof this.value === "number" || this.value.length > 0);
|
|
210
148
|
return html`
|
|
211
149
|
<div
|
|
212
|
-
part="
|
|
150
|
+
part="field"
|
|
213
151
|
class="${classMap({
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
"fds-paragraph--sm": sm,
|
|
219
|
-
"fds-paragraph--md": md,
|
|
220
|
-
"fds-paragraph--lg": lg,
|
|
221
|
-
"fds-textfield--sm": sm,
|
|
222
|
-
"fds-textfield--md": md,
|
|
223
|
-
"fds-textfield--lg": lg
|
|
152
|
+
"opacity-disabled": this.disabled,
|
|
153
|
+
"text-body-sm": sm,
|
|
154
|
+
"text-body-md": md,
|
|
155
|
+
"text-body-lg": lg
|
|
224
156
|
})}"
|
|
225
157
|
>
|
|
226
158
|
<label
|
|
227
159
|
for="${this.inputId}"
|
|
228
160
|
class="${classMap({
|
|
229
|
-
"sr-only": this.hidelabel || !hasLabel
|
|
230
|
-
|
|
231
|
-
"fds-label--medium-weight": true,
|
|
232
|
-
"fds-textfield__label": true,
|
|
233
|
-
"fds-label--sm": sm,
|
|
234
|
-
"fds-label--md": md,
|
|
235
|
-
"fds-label--lg": lg
|
|
236
|
-
})}"
|
|
161
|
+
"sr-only": this.hidelabel || !hasLabel
|
|
162
|
+
})} mb-2 inline-flex items-center gap-1 font-medium"
|
|
237
163
|
>
|
|
238
|
-
${
|
|
239
|
-
class="
|
|
164
|
+
${this.readonly ? html`<mid-icon
|
|
165
|
+
class="size-5"
|
|
240
166
|
library="system"
|
|
241
167
|
name="padlock-locked-fill"
|
|
242
|
-
></mid-icon>`}
|
|
168
|
+
></mid-icon>` : nothing}
|
|
243
169
|
<slot name="label"> ${this.label} </slot>
|
|
244
170
|
</label>
|
|
245
|
-
${
|
|
171
|
+
${this.description ? html`
|
|
246
172
|
<div
|
|
247
173
|
id="${this.descriptionId}"
|
|
248
174
|
part="description"
|
|
249
175
|
class="${classMap({
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
"sr-only": this.hidelabel,
|
|
253
|
-
"fds-paragraph--sm": sm,
|
|
254
|
-
"fds-paragraph--md": md,
|
|
255
|
-
"fds-paragraph--lg": lg,
|
|
256
|
-
"fds-textfield__description": true
|
|
257
|
-
})}"
|
|
176
|
+
"sr-only": this.hidelabel
|
|
177
|
+
})} text-neutral-subtle mb-2"
|
|
258
178
|
>
|
|
259
179
|
${this.description}
|
|
260
180
|
</div>
|
|
261
|
-
`}
|
|
181
|
+
` : nothing}
|
|
262
182
|
<div
|
|
263
183
|
part="base"
|
|
264
184
|
class="${classMap({
|
|
265
|
-
"
|
|
266
|
-
"border-
|
|
267
|
-
"border-
|
|
185
|
+
"border-neutral": !this.invalidmessage && !this.readonly,
|
|
186
|
+
"border-danger": this.invalidmessage && !this.readonly,
|
|
187
|
+
"border-neutral-subtle": this.readonly,
|
|
188
|
+
"bg-neutral-surface-tinted": this.readonly,
|
|
189
|
+
"bg-neutral-surface": !this.readonly,
|
|
268
190
|
border: !this.invalidmessage,
|
|
269
191
|
"border-2": this.invalidmessage
|
|
270
|
-
})}
|
|
192
|
+
})} focus-within:focus-ring flex h-12 items-center rounded-md px-3"
|
|
271
193
|
>
|
|
272
|
-
<span class="
|
|
194
|
+
<span class="slotted:!mr-2 slotted:rounded flex items-center">
|
|
273
195
|
<slot name="prefix"></slot>
|
|
274
196
|
</span>
|
|
275
197
|
<input
|
|
276
198
|
id="${this.inputId}"
|
|
277
|
-
class="
|
|
199
|
+
class="${classMap({
|
|
200
|
+
"[&::-webkit-search-cancel-button]:appearance-none": this.type === "search"
|
|
201
|
+
})} input grow focus-visible:outline-0"
|
|
278
202
|
part="input"
|
|
279
203
|
.value=${live(this.value)}
|
|
280
204
|
?disabled=${this.disabled}
|
|
@@ -300,60 +224,60 @@ let MinidTextfield = class extends FormControlMixin(
|
|
|
300
224
|
<button
|
|
301
225
|
part="clear-button"
|
|
302
226
|
type="button"
|
|
303
|
-
class="
|
|
304
|
-
"text-6": sm,
|
|
305
|
-
"text-7": md,
|
|
306
|
-
"text-8": lg
|
|
307
|
-
})} flex w-[calc(1em+1rem*2)] items-center justify-center rounded"
|
|
227
|
+
class="focus-visible:focus-ring ml-2 flex items-center justify-center rounded-sm"
|
|
308
228
|
aria-label="Tøm"
|
|
309
229
|
@click=${this.handleClearClick}
|
|
310
230
|
>
|
|
311
|
-
<mid-icon
|
|
231
|
+
<mid-icon
|
|
232
|
+
class="size-7"
|
|
233
|
+
library="system"
|
|
234
|
+
name="xmark"
|
|
235
|
+
></mid-icon>
|
|
312
236
|
</button>
|
|
313
237
|
` : ""}
|
|
314
238
|
${this.passwordtoggle && !this.disabled ? html`
|
|
315
239
|
<button
|
|
316
240
|
part="password-toggle-button"
|
|
317
241
|
type="button"
|
|
318
|
-
class="
|
|
319
|
-
"text-6": sm,
|
|
320
|
-
"text-7": md,
|
|
321
|
-
"text-8": lg
|
|
322
|
-
})} flex w-[calc(1em+1rem*2)] items-center justify-center rounded"
|
|
242
|
+
class="ml-2 flex items-center justify-center rounded-sm"
|
|
323
243
|
aria-label=${this.passwordvisible ? "skjul passord" : "vis passord"}
|
|
324
244
|
@click=${this.handlePasswordToggle}
|
|
325
245
|
tabindex="-1"
|
|
326
246
|
>
|
|
327
247
|
${this.passwordvisible ? html` <mid-icon
|
|
328
|
-
|
|
248
|
+
class="size-7"
|
|
329
249
|
library="system"
|
|
250
|
+
name="eye-slash"
|
|
330
251
|
></mid-icon>` : html`
|
|
331
|
-
<mid-icon
|
|
252
|
+
<mid-icon
|
|
253
|
+
class="size-7"
|
|
254
|
+
library="system"
|
|
255
|
+
name="eye"
|
|
256
|
+
></mid-icon>
|
|
332
257
|
`}
|
|
333
258
|
</button>
|
|
334
259
|
` : ""}
|
|
335
|
-
<span part="suffix" class="
|
|
260
|
+
<span part="suffix" class="slotted:!ml-2 slotted:rounded">
|
|
336
261
|
<slot name="suffix"></slot>
|
|
337
262
|
</span>
|
|
338
263
|
</div>
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
class="${classMap({
|
|
264
|
+
<div
|
|
265
|
+
class="${classMap({
|
|
342
266
|
hidden: !this.invalidmessage
|
|
343
|
-
})}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
267
|
+
})} text-danger-subtle mt-2 flex gap-1"
|
|
268
|
+
id="error-message"
|
|
269
|
+
aria-live="polite"
|
|
270
|
+
>
|
|
271
|
+
<mid-icon
|
|
272
|
+
name="xmark-octagon-fill"
|
|
273
|
+
class="mt-1 min-h-5 min-w-5"
|
|
274
|
+
></mid-icon>
|
|
275
|
+
${this.invalidmessage}
|
|
276
|
+
</div>
|
|
349
277
|
</div>
|
|
350
278
|
`;
|
|
351
279
|
}
|
|
352
280
|
};
|
|
353
|
-
_initialValue = /* @__PURE__ */ new WeakMap();
|
|
354
|
-
__decorateClass([
|
|
355
|
-
query(".error-message")
|
|
356
|
-
], MinidTextfield.prototype, "errorMessageDiv", 2);
|
|
357
281
|
__decorateClass([
|
|
358
282
|
query(".input")
|
|
359
283
|
], MinidTextfield.prototype, "input", 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textfield.js","sources":["../../src/components/textfield.component.ts"],"sourcesContent":["import { css, html, LitElement, nothing } 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} from '../mixins/validators';\nimport { watch } from '../internal/watch';\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 .form-control {\n display: block;\n }\n\n .form-control:has(input:disabled) {\n opacity: 0.3;\n }\n\n .fds-label {\n margin-bottom: 0.5rem;\n }\n\n .input {\n width: 100%;\n outline: none;\n box-shadow: none;\n background-color: transparent;\n padding: 0 1rem;\n }\n\n .field:has(.input:disabled) {\n opacity: var(--fds-opacity-disabled);\n }\n\n .suffix,\n .prefix {\n display: flex;\n place-items: center;\n }\n\n .suffix ::slotted(*) {\n margin-inline-end: 1rem !important; // global style for button is margin: 0\n border-radius: 4px;\n }\n\n .prefix ::slotted(*) {\n margin-inline-start: 1rem !important; // global style for button is margin: 0\n border-radius: 4px;\n }\n\n .fds-textfield__readonly__icon svg {\n font-size: 1.2em;\n }\n\n .clear-button:not(:disabled, [aria-disabled]):hover mid-icon {\n border-radius: 4px;\n background: var(--fds-semantic-surface-action-subtle-hover);\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 fields's base wrapper.\n * @csspart input - The internal `<input>` element.\n * @csspart form-control - The form control 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(\n styled(LitElement, styles)\n) {\n /**\n * @ignore\n */\n inputId!: string;\n\n /**\n * @ignore\n */\n descriptionId!: string;\n\n /**\n * @ignore\n */\n hasSlotControler = new HasSlotController(this, 'label');\n\n /**\n * @ignore\n */\n #initialValue = '';\n\n /**\n * @ignore\n */\n @query('.error-message')\n errorMessageDiv!: HTMLDivElement;\n\n /**\n * @ignore\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 * 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 @state()\n hasFocus = false;\n\n /**\n * @ignore\n */\n static get formControlValidators() {\n return [\n requiredValidator,\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n ];\n }\n\n /**\n * @ignore\n */\n get validationTarget() {\n return this.input;\n }\n\n constructor() {\n super();\n nextUniqueId++;\n this.inputId = `mid-textfield-input-${nextUniqueId}`;\n this.descriptionId = `mid-textfield-description-${nextUniqueId}`;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#initialValue = this.value;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\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 this.value = this.input.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 override render() {\n const lg = this.size === 'lg';\n const md = this.size === 'md';\n const sm = this.size === 'sm';\n\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const isClearIconVisible =\n hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n\n return html`\n <div\n part=\"form-control\"\n class=\"${classMap({\n 'form-control': true,\n 'fds-paragraph': true,\n 'fds-textfield': true,\n 'fds-textfield--readonly': this.readonly,\n 'fds-paragraph--sm': sm,\n 'fds-paragraph--md': md,\n 'fds-paragraph--lg': lg,\n 'fds-textfield--sm': sm,\n 'fds-textfield--md': md,\n 'fds-textfield--lg': lg,\n })}\"\n >\n <label\n for=\"${this.inputId}\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n 'fds-label': true,\n 'fds-label--medium-weight': true,\n 'fds-textfield__label': true,\n 'fds-label--sm': sm,\n 'fds-label--md': md,\n 'fds-label--lg': lg,\n })}\"\n >\n ${!this.readonly\n ? nothing\n : html`<mid-icon\n class=\"fds-textfield__readonly__icon\"\n library=\"system\"\n name=\"padlock-locked-fill\"\n ></mid-icon>`}\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n ${!this.description\n ? nothing\n : html`\n <div\n id=\"${this.descriptionId}\"\n part=\"description\"\n class=\"${classMap({\n description: true,\n 'fds-paragraph': true,\n 'sr-only': this.hidelabel,\n 'fds-paragraph--sm': sm,\n 'fds-paragraph--md': md,\n 'fds-paragraph--lg': lg,\n 'fds-textfield__description': true,\n })}\"\n >\n ${this.description}\n </div>\n `}\n <div\n part=\"base\"\n class=\"${classMap({\n 'fds-textfield__field': true,\n 'border-neutral': !this.invalidmessage,\n 'border-danger': this.invalidmessage,\n border: !this.invalidmessage,\n 'border-2': this.invalidmessage,\n })} field focus-within:shadow-focus-inner focus-within:outline-focus-outer outline-2 outline-transparent focus-within:outline-3 focus-within:outline-offset-3\"\n >\n <span class=\"prefix\">\n <slot name=\"prefix\"></slot>\n </span>\n <input\n id=\"${this.inputId}\"\n class=\"input\"\n part=\"input\"\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=\"${this.descriptionId}\"\n aria-errormessage=\"error-message\"\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 @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 <button\n part=\"clear-button\"\n type=\"button\"\n class=\"${classMap({\n 'text-6': sm,\n 'text-7': md,\n 'text-8': lg,\n })} flex w-[calc(1em+1rem*2)] items-center justify-center rounded\"\n aria-label=\"Tøm\"\n @click=${this.handleClearClick}\n >\n <mid-icon name=\"xmark\" library=\"system\"></mid-icon>\n </button>\n `\n : ''}\n ${this.passwordtoggle && !this.disabled\n ? html`\n <button\n part=\"password-toggle-button\"\n type=\"button\"\n class=\"${classMap({\n 'text-6': sm,\n 'text-7': md,\n 'text-8': lg,\n })} flex w-[calc(1em+1rem*2)] items-center justify-center rounded\"\n aria-label=${this.passwordvisible\n ? 'skjul passord'\n : 'vis passord'}\n @click=${this.handlePasswordToggle}\n tabindex=\"-1\"\n >\n ${this.passwordvisible\n ? html` <mid-icon\n name=\"eye-slash\"\n library=\"system\"\n ></mid-icon>`\n : html`\n <mid-icon name=\"eye\" library=\"system\"> </mid-icon>\n `}\n </button>\n `\n : ''}\n <span part=\"suffix\" class=\"suffix\">\n <slot name=\"suffix\"></slot>\n </span>\n </div>\n </div>\n <div\n class=\"${classMap({\n hidden: !this.invalidmessage,\n })} error-message text-danger-subtle flex gap-1 pt-2\"\n id=\"error-message\"\n aria-live=\"polite\"\n >\n <mid-icon name=\"xmark-octagon-fill\" class=\"mt-1 text-xl\"></mid-icon>\n ${this.invalidmessage}\n </div>\n `;\n }\n}\n"],"names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,CAAA;AAAA,GAnI/B,eAoIX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS;AAAA,GAzIC,eA0IX,WAAA,WAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GA/IhB,eAgJX,WAAA,YAAA,CAAA;AAMA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAS,CAAA;AAAA,GArJhB,eAsJX,WAAA,aAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM;AAAA,GAxJI,eAyJX,WAAA,YAAA,CAAA;AAsHA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GA9QH,eA+QX,WAAA,qBAAA,CAAA;AA/QW,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 } 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} from '../mixins/validators';\nimport { watch } from '../internal/watch';\nimport './icon/icon.component.ts';\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];\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(\n styled(LitElement, styles)\n) {\n private readonly inputId!: string;\n private readonly descriptionId!: string;\n private readonly hasSlotControler = new HasSlotController(this, 'label');\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 * 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 @state()\n hasFocus = false;\n\n static get formControlValidators() {\n return [\n requiredValidator,\n maxLengthValidator,\n minLengthValidator,\n patternValidator,\n ];\n }\n\n get validationTarget() {\n return this.input;\n }\n\n constructor() {\n super();\n nextUniqueId++;\n this.inputId = `mid-textfield-input-${nextUniqueId}`;\n this.descriptionId = `mid-textfield-description-${nextUniqueId}`;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.initialValue = this.value;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const hasModifier =\n event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;\n\n // Pressing enter when focused on an input should submit the form like a native input, but we wait a tick before\n // submitting to allow users to cancel the keydown event if they need to\n if (event.key === 'Enter' && !hasModifier) {\n setTimeout(() => {\n //\n // When using an Input Method Editor (IME), pressing enter will cause the form to submit unexpectedly. One way\n // to check for this is to look at event.isComposing, which will be true when the IME is open.\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 this.value = this.input.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 override render() {\n const lg = this.size === 'lg';\n const md = this.size === 'md';\n const sm = this.size === 'sm';\n\n const hasLabelSlot = this.hasSlotControler.test('label');\n const hasLabel = !!this.label || !!hasLabelSlot;\n const hasClearIcon = this.clearable && !this.disabled && !this.readonly;\n const isClearIconVisible =\n hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);\n\n return html`\n <div\n part=\"field\"\n class=\"${classMap({\n 'opacity-disabled': this.disabled,\n 'text-body-sm': sm,\n 'text-body-md': md,\n 'text-body-lg': lg,\n })}\"\n >\n <label\n for=\"${this.inputId}\"\n class=\"${classMap({\n 'sr-only': this.hidelabel || !hasLabel,\n })} mb-2 inline-flex items-center gap-1 font-medium\"\n >\n ${this.readonly\n ? html`<mid-icon\n class=\"size-5\"\n library=\"system\"\n name=\"padlock-locked-fill\"\n ></mid-icon>`\n : nothing}\n <slot name=\"label\"> ${this.label} </slot>\n </label>\n ${this.description\n ? html`\n <div\n id=\"${this.descriptionId}\"\n part=\"description\"\n class=\"${classMap({\n 'sr-only': this.hidelabel,\n })} text-neutral-subtle mb-2\"\n >\n ${this.description}\n </div>\n `\n : nothing}\n <div\n part=\"base\"\n class=\"${classMap({\n 'border-neutral': !this.invalidmessage && !this.readonly,\n 'border-danger': this.invalidmessage && !this.readonly,\n 'border-neutral-subtle': this.readonly,\n 'bg-neutral-surface-tinted': this.readonly,\n 'bg-neutral-surface': !this.readonly,\n border: !this.invalidmessage,\n 'border-2': this.invalidmessage,\n })} focus-within:focus-ring flex h-12 items-center rounded-md px-3\"\n >\n <span class=\"slotted:!mr-2 slotted:rounded flex items-center\">\n <slot name=\"prefix\"></slot>\n </span>\n <input\n id=\"${this.inputId}\"\n class=\"${classMap({\n '[&::-webkit-search-cancel-button]:appearance-none':\n this.type === 'search',\n })} input grow focus-visible:outline-0\"\n part=\"input\"\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=\"${this.descriptionId}\"\n aria-errormessage=\"error-message\"\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 @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 <button\n part=\"clear-button\"\n type=\"button\"\n class=\"focus-visible:focus-ring ml-2 flex items-center justify-center rounded-sm\"\n aria-label=\"Tøm\"\n @click=${this.handleClearClick}\n >\n <mid-icon\n class=\"size-7\"\n library=\"system\"\n name=\"xmark\"\n ></mid-icon>\n </button>\n `\n : ''}\n ${this.passwordtoggle && !this.disabled\n ? html`\n <button\n part=\"password-toggle-button\"\n type=\"button\"\n class=\"ml-2 flex items-center justify-center rounded-sm\"\n aria-label=${this.passwordvisible\n ? 'skjul passord'\n : 'vis passord'}\n @click=${this.handlePasswordToggle}\n tabindex=\"-1\"\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 `\n : ''}\n <span part=\"suffix\" class=\"slotted:!ml-2 slotted:rounded\">\n <slot name=\"suffix\"></slot>\n </span>\n </div>\n <div\n class=\"${classMap({\n hidden: !this.invalidmessage,\n })} text-danger-subtle mt-2 flex gap-1\"\n id=\"error-message\"\n aria-live=\"polite\"\n >\n <mid-icon\n name=\"xmark-octagon-fill\"\n class=\"mt-1 min-h-5 min-w-5\"\n ></mid-icon>\n ${this.invalidmessage}\n </div>\n </div>\n `;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,SAAS;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAKF;AAEA,IAAI,eAAe;AAuBZ,IAAM,iBAAN,cAA6B;AAAA,EAClC,OAAO,YAAY,MAAM;AAC3B,EAAE;AAAA,EA8IA,cAAc;AACN,UAAA;AA5IR,SAAiB,mBAAmB,IAAI,kBAAkB,MAAM,OAAO;AACvE,SAAQ,eAAe;AAMf,SAAA,QAAA;AAGM,SAAA,cAAA;AAGN,SAAA,QAAA;AAGmB,SAAA,OAAA;AASf,SAAA,YAAA;AAoCK,SAAA,iBAAA;AAgBJ,SAAA,OAAA;AAMD,SAAA,YAAA;AAOK,SAAA,iBAAA;AAOC,SAAA,kBAAA;AAGP,SAAA,WAAA;AAGA,SAAA,WAAA;AAYA,SAAA,WAAA;AAMC,SAAA,YAAA;AAGD,SAAA,WAAA;AAiBT;AACK,SAAA,UAAU,uBAAuB,YAAY;AAC7C,SAAA,gBAAgB,6BAA6B,YAAY;AAAA,EAAA;AAAA,EAjBhE,WAAW,wBAAwB;AAC1B,WAAA;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAAA,EAGF,IAAI,mBAA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WAAA,YAAA,CAAA;AAgHA,gBAAA;AAAA,EADC,MAAM,OAAO;AAAA,GAhPH,eAiPX,WAAA,qBAAA,CAAA;AAjPW,iBAAN,gBAAA;AAAA,EADN,cAAc,eAAe;AAAA,GACjB,cAAA;"}
|
|
@@ -18,30 +18,17 @@ declare const MinidTooltip_base: typeof LitElement;
|
|
|
18
18
|
* @csspart base - The component base wrapper. `<mid-popup> element
|
|
19
19
|
* @csspart body - The tooltip body, where the content is rendered
|
|
20
20
|
*
|
|
21
|
+
* @method show - Shows the tooltip
|
|
22
|
+
* @method hide - Hides the tooltip
|
|
23
|
+
*
|
|
21
24
|
* @cssproperty [--max-width=20rem] - Max width of the tooltip content
|
|
22
25
|
* @cssproperty [--hide-delay=0ms] - Delay for hiding the tooltip
|
|
23
26
|
* @cssproperty [--show-delay=150ms] - Delay for showing the tooltip
|
|
24
27
|
*/
|
|
25
28
|
export declare class MinidTooltip extends MinidTooltip_base {
|
|
26
|
-
/**
|
|
27
|
-
* @ignore
|
|
28
|
-
*/
|
|
29
29
|
private hoverTimeout?;
|
|
30
|
-
/**
|
|
31
|
-
* @ignore
|
|
32
|
-
*/
|
|
33
30
|
private closeWatcher;
|
|
34
|
-
/**
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
defaultSlot: HTMLSlotElement;
|
|
38
|
-
/**
|
|
39
|
-
* @ignore
|
|
40
|
-
*/
|
|
41
31
|
body: HTMLElement;
|
|
42
|
-
/**
|
|
43
|
-
* @ignore
|
|
44
|
-
*/
|
|
45
32
|
popup: MinidPopup;
|
|
46
33
|
/**
|
|
47
34
|
* The text to render in the tooltip. If you need HTML you can use the content slot
|
|
@@ -53,6 +40,7 @@ export declare class MinidTooltip extends MinidTooltip_base {
|
|
|
53
40
|
*/
|
|
54
41
|
trigger: 'focus hover' | 'hover' | 'focus' | 'manual' | 'click';
|
|
55
42
|
placement: 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
43
|
+
size: 'sm' | 'md' | 'lg';
|
|
56
44
|
/**
|
|
57
45
|
* Disables the tooltip so it won't show when triggered.
|
|
58
46
|
*/
|
|
@@ -82,33 +70,12 @@ export declare class MinidTooltip extends MinidTooltip_base {
|
|
|
82
70
|
constructor();
|
|
83
71
|
disconnectedCallback(): void;
|
|
84
72
|
firstUpdated(): void;
|
|
85
|
-
/**
|
|
86
|
-
* @ignore
|
|
87
|
-
*/
|
|
88
73
|
private handleBlur;
|
|
89
|
-
/**
|
|
90
|
-
* @ignore
|
|
91
|
-
*/
|
|
92
74
|
private handleClick;
|
|
93
|
-
/**
|
|
94
|
-
* @ignore
|
|
95
|
-
*/
|
|
96
75
|
private handleFocus;
|
|
97
|
-
/**
|
|
98
|
-
* @ignore
|
|
99
|
-
*/
|
|
100
76
|
private handleDocumentKeyDown;
|
|
101
|
-
/**
|
|
102
|
-
* @ignore
|
|
103
|
-
*/
|
|
104
77
|
private handleMouseOver;
|
|
105
|
-
/**
|
|
106
|
-
* @ignore
|
|
107
|
-
*/
|
|
108
78
|
private handleMouseOut;
|
|
109
|
-
/**
|
|
110
|
-
* @ignore
|
|
111
|
-
*/
|
|
112
79
|
private hasTrigger;
|
|
113
80
|
handleOpenChange(): Promise<void>;
|
|
114
81
|
handleOptionsChange(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.component.d.ts","sourceRoot":"","sources":["../../src/components/tooltip.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;AAG5C,OAAO,mBAAmB,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,YAAY,CAAC;KAC7B;CACF;;
|
|
1
|
+
{"version":3,"file":"tooltip.component.d.ts","sourceRoot":"","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C,UAAU;IAMZ,gBAAgB;IAmDhB,mBAAmB;IAQzB,oBAAoB;IAMpB;;OAEG;IACG,IAAI;IASV;;OAEG;IACG,IAAI;IASD,MAAM;CAwChB"}
|
|
@@ -24,19 +24,6 @@ const styles = [
|
|
|
24
24
|
--hide-delay: 0ms;
|
|
25
25
|
--show-delay: 250ms;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
.tooltip__body {
|
|
29
|
-
width: max-content;
|
|
30
|
-
max-width: var(--max-width);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.tooltip {
|
|
34
|
-
--arrow-color: var(--fds-semantic-surface-neutral-inverted);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.tooltip.inverted {
|
|
38
|
-
--arrow-color: var(--fds-semantic-surface-neutral-subtle);
|
|
39
|
-
}
|
|
40
27
|
`
|
|
41
28
|
];
|
|
42
29
|
let MinidTooltip = class extends styled(LitElement, styles) {
|
|
@@ -46,6 +33,7 @@ let MinidTooltip = class extends styled(LitElement, styles) {
|
|
|
46
33
|
this.content = "";
|
|
47
34
|
this.trigger = "focus hover";
|
|
48
35
|
this.placement = "top";
|
|
36
|
+
this.size = "md";
|
|
49
37
|
this.disabled = false;
|
|
50
38
|
this.distance = 8;
|
|
51
39
|
this.open = false;
|
|
@@ -112,9 +100,6 @@ let MinidTooltip = class extends styled(LitElement, styles) {
|
|
|
112
100
|
this.popup.reposition();
|
|
113
101
|
}
|
|
114
102
|
}
|
|
115
|
-
/**
|
|
116
|
-
* @ignore
|
|
117
|
-
*/
|
|
118
103
|
hasTrigger(triggerType) {
|
|
119
104
|
const triggers = this.trigger.split(" ");
|
|
120
105
|
return triggers.includes(triggerType);
|
|
@@ -198,15 +183,13 @@ let MinidTooltip = class extends styled(LitElement, styles) {
|
|
|
198
183
|
role="tooltip"
|
|
199
184
|
?active=${this.open}
|
|
200
185
|
part="base"
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"tooltip--open": this.open
|
|
209
|
-
})}
|
|
186
|
+
class="${classMap({
|
|
187
|
+
"[--arrow-color:var(--color-neutral-base)]": !this.inverted,
|
|
188
|
+
"[--arrow-color:var(--color-neutral-surface)]": this.inverted,
|
|
189
|
+
"text-body-sm": this.size === "sm",
|
|
190
|
+
"text-body-md": this.size === "md",
|
|
191
|
+
"text-body-lg": this.size === "lg"
|
|
192
|
+
})}"
|
|
210
193
|
placement=${this.placement}
|
|
211
194
|
distance=${this.distance}
|
|
212
195
|
skidding=${this.skidding}
|
|
@@ -219,12 +202,13 @@ let MinidTooltip = class extends styled(LitElement, styles) {
|
|
|
219
202
|
<slot slot="anchor"></slot>
|
|
220
203
|
<div
|
|
221
204
|
part="body"
|
|
222
|
-
id="
|
|
205
|
+
id="body"
|
|
223
206
|
class="${classMap({
|
|
224
|
-
"
|
|
225
|
-
|
|
226
|
-
"
|
|
227
|
-
|
|
207
|
+
"bg-neutral": this.inverted,
|
|
208
|
+
"text-neutral": this.inverted,
|
|
209
|
+
"bg-neutral-base": !this.inverted,
|
|
210
|
+
"text-neutral-base-contrast": !this.inverted
|
|
211
|
+
})} leading-sm w-max max-w-(--max-width) rounded px-2 py-1"
|
|
228
212
|
role="tooltip"
|
|
229
213
|
aria-live=${this.open ? "polite" : "off"}
|
|
230
214
|
>
|
|
@@ -235,10 +219,7 @@ let MinidTooltip = class extends styled(LitElement, styles) {
|
|
|
235
219
|
}
|
|
236
220
|
};
|
|
237
221
|
__decorateClass([
|
|
238
|
-
query("
|
|
239
|
-
], MinidTooltip.prototype, "defaultSlot", 2);
|
|
240
|
-
__decorateClass([
|
|
241
|
-
query(".tooltip__body")
|
|
222
|
+
query("#body")
|
|
242
223
|
], MinidTooltip.prototype, "body", 2);
|
|
243
224
|
__decorateClass([
|
|
244
225
|
query("mid-popup")
|
|
@@ -252,6 +233,9 @@ __decorateClass([
|
|
|
252
233
|
__decorateClass([
|
|
253
234
|
property()
|
|
254
235
|
], MinidTooltip.prototype, "placement", 2);
|
|
236
|
+
__decorateClass([
|
|
237
|
+
property()
|
|
238
|
+
], MinidTooltip.prototype, "size", 2);
|
|
255
239
|
__decorateClass([
|
|
256
240
|
property({ type: Boolean, reflect: true })
|
|
257
241
|
], MinidTooltip.prototype, "disabled", 2);
|