@sb1/indeks-web 0.5.0 → 0.6.0
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/CHANGELOG.md +6 -0
- package/dist/npm/index.d.ts +15 -1
- package/dist/npm/index.js +63 -1
- package/dist/npm/lib/components/icon/IxIcon.d.ts +33 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/npm/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { IxField } from './lib/components/field/IxField.js';
|
|
2
|
+
import { IxIcon, IconName } from './lib/components/icon/IxIcon.js';
|
|
2
3
|
export { IxField };
|
|
4
|
+
export { IxIcon };
|
|
5
|
+
export { ICON_NAMES } from './lib/components/icon/IxIcon.js';
|
|
6
|
+
export type { IconName, IconValue } from './lib/components/icon/IxIcon.js';
|
|
3
7
|
declare global {
|
|
4
8
|
interface HTMLElementTagNameMap {
|
|
5
|
-
'ix-field':
|
|
9
|
+
'ix-field': IxField;
|
|
10
|
+
'ix-icon': IxIcon;
|
|
6
11
|
}
|
|
7
12
|
namespace JSX {
|
|
8
13
|
interface IntrinsicElements {
|
|
@@ -11,6 +16,15 @@ declare global {
|
|
|
11
16
|
class?: string;
|
|
12
17
|
children?: unknown;
|
|
13
18
|
};
|
|
19
|
+
'ix-icon': {
|
|
20
|
+
name?: IconName;
|
|
21
|
+
materialdesignname?: string;
|
|
22
|
+
'data-size'?: 'sm' | 'md' | 'lg' | 'xl';
|
|
23
|
+
'aria-label'?: string;
|
|
24
|
+
'aria-labelledby'?: string;
|
|
25
|
+
class?: string;
|
|
26
|
+
style?: string | Record<string, string>;
|
|
27
|
+
};
|
|
14
28
|
}
|
|
15
29
|
}
|
|
16
30
|
}
|
package/dist/npm/index.js
CHANGED
|
@@ -220,6 +220,67 @@ var IxField = class extends HTMLElement {
|
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
//#endregion
|
|
223
|
+
//#region lib/components/icon/IxIcon.ts
|
|
224
|
+
var ICON_CDN_BASE = "https://cdn.sparebank1.no/icons";
|
|
225
|
+
var ICON_NAMES = {
|
|
226
|
+
hjem: "home",
|
|
227
|
+
meny: "menu",
|
|
228
|
+
sparing: "savings",
|
|
229
|
+
lukk: "close",
|
|
230
|
+
"pil-hoyre": "chevron_right",
|
|
231
|
+
"legg-til": "add",
|
|
232
|
+
hake: "check",
|
|
233
|
+
"apne-ekstern": "open_in_new",
|
|
234
|
+
bankkonto: "account_balance",
|
|
235
|
+
rediger: "edit",
|
|
236
|
+
betalingskort: "credit_card",
|
|
237
|
+
slett: "delete",
|
|
238
|
+
"last-ned": "download",
|
|
239
|
+
person: "person",
|
|
240
|
+
"pil-ned": "keyboard_arrow_down",
|
|
241
|
+
"e-post": "mail",
|
|
242
|
+
betaling: "payments",
|
|
243
|
+
info: "info",
|
|
244
|
+
sok: "search",
|
|
245
|
+
innstillinger: "settings",
|
|
246
|
+
bil: "directions_car",
|
|
247
|
+
"pil-venstre": "chevron_left",
|
|
248
|
+
feil: "error"
|
|
249
|
+
};
|
|
250
|
+
var IxIcon = class extends HTMLElement {
|
|
251
|
+
static get observedAttributes() {
|
|
252
|
+
return [
|
|
253
|
+
"name",
|
|
254
|
+
"materialdesignname",
|
|
255
|
+
"aria-label",
|
|
256
|
+
"aria-labelledby"
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
connectedCallback() {
|
|
260
|
+
this._update();
|
|
261
|
+
}
|
|
262
|
+
attributeChangedCallback(_name, oldValue, newValue) {
|
|
263
|
+
if (oldValue === newValue) return;
|
|
264
|
+
this._update();
|
|
265
|
+
}
|
|
266
|
+
_update() {
|
|
267
|
+
const nameAttr = this.getAttribute("name");
|
|
268
|
+
const materialDesignName = this.getAttribute("materialdesignname");
|
|
269
|
+
const ariaLabel = this.getAttribute("aria-label");
|
|
270
|
+
const ariaLabelledBy = this.getAttribute("aria-labelledby");
|
|
271
|
+
const iconFileName = nameAttr ? ICON_NAMES[nameAttr] ?? nameAttr : materialDesignName;
|
|
272
|
+
if (iconFileName) this.style.setProperty("--ii-icon-url", `url(${ICON_CDN_BASE}/${iconFileName}.svg)`);
|
|
273
|
+
else this.style.removeProperty("--ii-icon-url");
|
|
274
|
+
if (ariaLabel || ariaLabelledBy) {
|
|
275
|
+
this.setAttribute("role", "img");
|
|
276
|
+
this.removeAttribute("aria-hidden");
|
|
277
|
+
} else {
|
|
278
|
+
this.removeAttribute("role");
|
|
279
|
+
this.setAttribute("aria-hidden", "true");
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
//#endregion
|
|
223
284
|
//#region lib/tooltip/tooltip.ts
|
|
224
285
|
var TOOLTIP_ID = "ix-tooltip-singleton";
|
|
225
286
|
var ATTR = "data-tooltip";
|
|
@@ -340,5 +401,6 @@ document.addEventListener("keydown", handleKeydown);
|
|
|
340
401
|
//#endregion
|
|
341
402
|
//#region index.ts
|
|
342
403
|
customElements.define("ix-field", IxField);
|
|
404
|
+
customElements.define("ix-icon", IxIcon);
|
|
343
405
|
//#endregion
|
|
344
|
-
export { IxField };
|
|
406
|
+
export { ICON_NAMES, IxField, IxIcon };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ICON_NAMES: {
|
|
2
|
+
readonly hjem: "home";
|
|
3
|
+
readonly meny: "menu";
|
|
4
|
+
readonly sparing: "savings";
|
|
5
|
+
readonly lukk: "close";
|
|
6
|
+
readonly 'pil-hoyre': "chevron_right";
|
|
7
|
+
readonly 'legg-til': "add";
|
|
8
|
+
readonly hake: "check";
|
|
9
|
+
readonly 'apne-ekstern': "open_in_new";
|
|
10
|
+
readonly bankkonto: "account_balance";
|
|
11
|
+
readonly rediger: "edit";
|
|
12
|
+
readonly betalingskort: "credit_card";
|
|
13
|
+
readonly slett: "delete";
|
|
14
|
+
readonly 'last-ned': "download";
|
|
15
|
+
readonly person: "person";
|
|
16
|
+
readonly 'pil-ned': "keyboard_arrow_down";
|
|
17
|
+
readonly 'e-post': "mail";
|
|
18
|
+
readonly betaling: "payments";
|
|
19
|
+
readonly info: "info";
|
|
20
|
+
readonly sok: "search";
|
|
21
|
+
readonly innstillinger: "settings";
|
|
22
|
+
readonly bil: "directions_car";
|
|
23
|
+
readonly 'pil-venstre': "chevron_left";
|
|
24
|
+
readonly feil: "error";
|
|
25
|
+
};
|
|
26
|
+
export type IconValue = (typeof ICON_NAMES)[keyof typeof ICON_NAMES];
|
|
27
|
+
export type IconName = keyof typeof ICON_NAMES;
|
|
28
|
+
export declare class IxIcon extends HTMLElement {
|
|
29
|
+
static get observedAttributes(): string[];
|
|
30
|
+
connectedCallback(): void;
|
|
31
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
32
|
+
private _update;
|
|
33
|
+
}
|