@sb1/indeks-web 0.5.0 → 0.7.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @sb1/indeks-web
2
2
 
3
+ ## 0.7.0
4
+
5
+ ## 0.6.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 2348f42: Legg til ix-icon komponent
10
+
3
11
  ## 0.5.0
4
12
 
5
13
  ### Minor Changes
@@ -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': HTMLElement;
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
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
1
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
2
2
  function _typeof(o) {
3
3
  "@babel/helpers - typeof";
4
4
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -8,7 +8,7 @@ function _typeof(o) {
8
8
  }, _typeof(o);
9
9
  }
10
10
  //#endregion
11
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
11
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
12
12
  function toPrimitive(t, r) {
13
13
  if ("object" != _typeof(t) || !t) return t;
14
14
  var e = t[Symbol.toPrimitive];
@@ -20,13 +20,13 @@ function toPrimitive(t, r) {
20
20
  return ("string" === r ? String : Number)(t);
21
21
  }
22
22
  //#endregion
23
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
23
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
24
24
  function toPropertyKey(t) {
25
25
  var i = toPrimitive(t, "string");
26
26
  return "symbol" == _typeof(i) ? i : i + "";
27
27
  }
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
29
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
30
30
  function _defineProperty(e, r, t) {
31
31
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
32
  value: t,
@@ -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";
@@ -248,7 +309,7 @@ function place(trigger, panel, placement) {
248
309
  const pw = panel.offsetWidth;
249
310
  const ph = panel.offsetHeight;
250
311
  const arrowSize = 6;
251
- const gap = arrowSize + 4;
312
+ const gap = 10;
252
313
  const axis = placement.startsWith("top") ? "top" : placement.startsWith("bottom") ? "bottom" : placement;
253
314
  let resolvedAxis = axis;
254
315
  if (axis === "top" && r.top - ph - gap < 0) resolvedAxis = "bottom";
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/indeks-web",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "Web components for Indeks design system",
6
6
  "homepage": "https://design.sparebank1.no",
@@ -40,12 +40,12 @@
40
40
  "author": "",
41
41
  "license": "MIT",
42
42
  "devDependencies": {
43
- "@types/node": "^25.6.2",
43
+ "@types/node": "^25.9.2",
44
44
  "jsdom": "^29.1.1",
45
45
  "typescript": "~6.0.3",
46
- "vite": "^8.0.12",
47
- "vite-plugin-dts": "^5.0.0",
48
- "vitest": "^4.1.5"
46
+ "vite": "^8.0.16",
47
+ "vite-plugin-dts": "^5.0.2",
48
+ "vitest": "^4.1.8"
49
49
  },
50
50
  "scripts": {
51
51
  "dev": "echo not implemented",