@sebgroup/green-core 1.73.0 → 1.74.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.
Files changed (69) hide show
  1. package/components/blur/blur.component.d.ts +18 -0
  2. package/components/blur/blur.component.js +18 -0
  3. package/components/blur/blur.d.ts +2 -0
  4. package/components/blur/blur.js +6 -0
  5. package/components/blur/blur.styles.d.ts +2 -0
  6. package/components/blur/blur.styles.js +12 -0
  7. package/components/blur/index.d.ts +1 -0
  8. package/components/blur/index.js +1 -0
  9. package/components/details/details.styles.js +3 -2
  10. package/components/formatted-text/account/account-formatter.d.ts +4 -0
  11. package/components/formatted-text/account/account-formatter.js +13 -0
  12. package/components/formatted-text/account/formatted-account.component.d.ts +28 -0
  13. package/components/formatted-text/account/formatted-account.component.js +34 -0
  14. package/components/formatted-text/account/formatted-account.d.ts +2 -0
  15. package/components/formatted-text/account/formatted-account.js +6 -0
  16. package/components/formatted-text/account/index.d.ts +1 -0
  17. package/components/formatted-text/account/index.js +1 -0
  18. package/components/formatted-text/date/date-time-formatter.d.ts +10 -0
  19. package/components/formatted-text/date/date-time-formatter.js +49 -0
  20. package/components/formatted-text/date/formatted-date.component.d.ts +29 -0
  21. package/components/formatted-text/date/formatted-date.component.js +43 -0
  22. package/components/formatted-text/date/formatted-date.d.ts +2 -0
  23. package/components/formatted-text/date/formatted-date.js +6 -0
  24. package/components/formatted-text/date/index.d.ts +1 -0
  25. package/components/formatted-text/date/index.js +1 -0
  26. package/components/formatted-text/formatted-text.d.ts +12 -0
  27. package/components/formatted-text/formatted-text.js +19 -0
  28. package/components/formatted-text/formatters.d.ts +3 -0
  29. package/components/formatted-text/formatters.js +3 -0
  30. package/components/formatted-text/index.d.ts +4 -0
  31. package/components/formatted-text/index.js +4 -0
  32. package/components/formatted-text/number/formatted-number.component.d.ts +31 -0
  33. package/components/formatted-text/number/formatted-number.component.js +40 -0
  34. package/components/formatted-text/number/formatted-number.d.ts +2 -0
  35. package/components/formatted-text/number/formatted-number.js +6 -0
  36. package/components/formatted-text/number/index.d.ts +1 -0
  37. package/components/formatted-text/number/index.js +1 -0
  38. package/components/formatted-text/number/number-formatter.d.ts +4 -0
  39. package/components/formatted-text/number/number-formatter.js +20 -0
  40. package/components/sensitive/index.d.ts +1 -0
  41. package/components/sensitive/index.js +1 -0
  42. package/components/sensitive/number/index.d.ts +1 -0
  43. package/components/sensitive/number/index.js +1 -0
  44. package/components/sensitive/number/sensitive-number.component.d.ts +31 -0
  45. package/components/sensitive/number/sensitive-number.component.js +43 -0
  46. package/components/sensitive/number/sensitive-number.d.ts +2 -0
  47. package/components/sensitive/number/sensitive-number.js +6 -0
  48. package/components/theme/chlorophyll-tokens.scss.js +1 -1
  49. package/generated/react/blur/index.d.ts +365 -0
  50. package/generated/react/blur/index.js +13 -0
  51. package/generated/react/formatted-account/index.d.ts +428 -0
  52. package/generated/react/formatted-account/index.js +15 -0
  53. package/generated/react/formatted-date/index.d.ts +430 -0
  54. package/generated/react/formatted-date/index.js +13 -0
  55. package/generated/react/formatted-number/index.d.ts +430 -0
  56. package/generated/react/formatted-number/index.js +15 -0
  57. package/generated/react/index.d.ts +8 -3
  58. package/generated/react/index.js +8 -3
  59. package/generated/react/sensitive-number/index.d.ts +431 -0
  60. package/generated/react/sensitive-number/index.js +15 -0
  61. package/package.json +19 -1
  62. package/setup-jest.js +43 -13
  63. package/tokens/dark.css.js +1 -1
  64. package/tokens/light.css.js +1 -1
  65. package/tokens/motion.css.js +1 -1
  66. package/tokens/shadow.css.js +1 -1
  67. package/tokens/size.css.js +1 -1
  68. package/tokens/text.css.js +1 -1
  69. package/utils/helpers/custom-element-scoping.js +1 -1
@@ -0,0 +1,18 @@
1
+ import { GdsElement } from '../../gds-element';
2
+ /**
3
+ * @element gds-blur
4
+ * A container that applies a blur effect to its content.
5
+ *
6
+ * @slot - Content to be blurred.
7
+ *
8
+ * @example
9
+ * <gds-blur>
10
+ * <div>Sensitive content here</div>
11
+ * </gds-blur>
12
+ *
13
+ * @status beta
14
+ */
15
+ export declare class GdsBlur extends GdsElement {
16
+ static styles: import("lit").CSSResult;
17
+ render(): any;
18
+ }
@@ -0,0 +1,18 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../chunks/chunk.QTSIPXV3.js";
4
+ import { GdsElement } from "../../gds-element.js";
5
+ import { gdsCustomElement, html } from "../../scoping.js";
6
+ import styles from "./blur.styles.js";
7
+ let GdsBlur = class extends GdsElement {
8
+ render() {
9
+ return html`<slot></slot>`;
10
+ }
11
+ };
12
+ GdsBlur.styles = styles;
13
+ GdsBlur = __decorateClass([
14
+ gdsCustomElement("gds-blur")
15
+ ], GdsBlur);
16
+ export {
17
+ GdsBlur
18
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsBlur } from './blur.component';
2
+ export { GdsBlur };
@@ -0,0 +1,6 @@
1
+ import "../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsBlur } from "./blur.component.js";
3
+ GdsBlur.define();
4
+ export {
5
+ GdsBlur
6
+ };
@@ -0,0 +1,2 @@
1
+ declare const style: import("lit").CSSResult;
2
+ export default style;
@@ -0,0 +1,12 @@
1
+ import "../../chunks/chunk.QTSIPXV3.js";
2
+ import { css } from "lit";
3
+ const style = css`
4
+ :host {
5
+ --_blur: 5px;
6
+ filter: blur(var(--_blur));
7
+ }
8
+ `;
9
+ var blur_styles_default = style;
10
+ export {
11
+ blur_styles_default as default
12
+ };
@@ -0,0 +1 @@
1
+ export * from './blur';
@@ -0,0 +1 @@
1
+ export * from "./blur.js";
@@ -101,7 +101,9 @@ const styles = css`
101
101
  .content {
102
102
  interpolate-size: allow-keywords;
103
103
  height: 0;
104
- transition: height 0.35s ease;
104
+ transition:
105
+ height 0.35s ease,
106
+ padding-block-end 0.35s ease;
105
107
  overflow-y: clip;
106
108
  outline: none;
107
109
  }
@@ -109,7 +111,6 @@ const styles = css`
109
111
  .content.open {
110
112
  height: max-content;
111
113
  max-height: 100vh;
112
- overflow-y: auto;
113
114
  }
114
115
  }
115
116
  `;
@@ -0,0 +1,4 @@
1
+ export type AccountFormats = keyof typeof accountsFormats;
2
+ export declare const accountsFormats: {
3
+ 'seb-account': (value: string | number | undefined) => string;
4
+ };
@@ -0,0 +1,13 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ const accountsFormats = {
3
+ "seb-account": (value) => {
4
+ const account = typeof value === "string" ? value.replace(" ", "") : value?.toString() ?? "";
5
+ if (account.length !== 11) {
6
+ return account;
7
+ }
8
+ return `${account.slice(0, 4)} ${account.slice(4, 6)} ${account.slice(6, 9)} ${account.slice(9, 11)}`;
9
+ }
10
+ };
11
+ export {
12
+ accountsFormats
13
+ };
@@ -0,0 +1,28 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { GdsFormattedText } from '../formatted-text';
3
+ import { AccountFormats } from './account-formatter';
4
+ /**
5
+ * @element gds-formatted-account
6
+ * @status beta
7
+ *
8
+ * `gds-formatted-account` extends `gds-text` and formats the account to the desired format.
9
+ *
10
+ * @example
11
+ * <gds-formatted-account
12
+ * account="54400023423">
13
+ * </gds-formatted-account>
14
+ */
15
+ export declare class GdsFormattedAccount extends GdsFormattedText {
16
+ /**
17
+ * The account number or identifier to display.
18
+ * For format 'seb-account', it needs to be 11 characters.
19
+ * */
20
+ account?: number | string;
21
+ /**
22
+ * Specifies the account format.
23
+ * @default 'seb-account'
24
+ */
25
+ protected format: AccountFormats;
26
+ get formattedValue(): string;
27
+ protected firstUpdated(_changedProperties: PropertyValues): void;
28
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../../chunks/chunk.QTSIPXV3.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { gdsCustomElement } from "../../../utils/helpers/custom-element-scoping.js";
6
+ import { GdsFormattedText } from "../formatted-text.js";
7
+ import { accountsFormats } from "./account-formatter.js";
8
+ let GdsFormattedAccount = class extends GdsFormattedText {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.format = "seb-account";
12
+ }
13
+ get formattedValue() {
14
+ return accountsFormats[this.format](this.account);
15
+ }
16
+ firstUpdated(_changedProperties) {
17
+ super.firstUpdated(_changedProperties);
18
+ if (!this.account && this.textContent) {
19
+ this.account = this.textContent;
20
+ }
21
+ }
22
+ };
23
+ __decorateClass([
24
+ property()
25
+ ], GdsFormattedAccount.prototype, "account", 2);
26
+ __decorateClass([
27
+ property({ type: String })
28
+ ], GdsFormattedAccount.prototype, "format", 2);
29
+ GdsFormattedAccount = __decorateClass([
30
+ gdsCustomElement("gds-formatted-account")
31
+ ], GdsFormattedAccount);
32
+ export {
33
+ GdsFormattedAccount
34
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsFormattedAccount } from './formatted-account.component';
2
+ export { GdsFormattedAccount };
@@ -0,0 +1,6 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsFormattedAccount } from "./formatted-account.component.js";
3
+ GdsFormattedAccount.define();
4
+ export {
5
+ GdsFormattedAccount
6
+ };
@@ -0,0 +1 @@
1
+ export * from './formatted-account';
@@ -0,0 +1 @@
1
+ export * from "./formatted-account.js";
@@ -0,0 +1,10 @@
1
+ export type DateTimeFormat = keyof typeof dateTimeFormats;
2
+ export declare const dateTimeFormats: {
3
+ dateOnlyNumbers: (value: string | Date | undefined, locale: string | undefined) => string;
4
+ dateLong: (value: string | Date | undefined, locale: string | undefined) => string;
5
+ dateLongWithWeekday: (value: string | Date | undefined, locale: string | undefined) => string;
6
+ dateShort: (value: string | Date | undefined, locale: string | undefined) => string;
7
+ dateShortWithWeekday: (value: string | Date | undefined, locale: string | undefined) => string;
8
+ timeShort: (value: string | Date | undefined, locale: string | undefined) => string;
9
+ timeLong: (value: string | Date | undefined, locale: string | undefined) => string;
10
+ };
@@ -0,0 +1,49 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ const convertValueToDate = (value) => {
3
+ if (typeof value === "string") {
4
+ return new Date(value);
5
+ }
6
+ return value;
7
+ };
8
+ const dateTimeFormats = {
9
+ dateOnlyNumbers: (value, locale) => new Intl.DateTimeFormat(locale, { dateStyle: "short" }).format(
10
+ convertValueToDate(value)
11
+ ),
12
+ dateLong: (value, locale) => new Intl.DateTimeFormat(locale, { dateStyle: "long" }).format(
13
+ convertValueToDate(value)
14
+ ),
15
+ dateLongWithWeekday: (value, locale) => new Intl.DateTimeFormat(locale, { dateStyle: "full" }).format(
16
+ convertValueToDate(value)
17
+ ),
18
+ dateShort: (value, locale) => {
19
+ const formatter = new Intl.DateTimeFormat(locale, { dateStyle: "medium" });
20
+ if (locale?.toLowerCase() === "sv-se") {
21
+ return formatter.format(convertValueToDate(value)).replace(".", "");
22
+ }
23
+ return formatter.format(convertValueToDate(value));
24
+ },
25
+ dateShortWithWeekday: (value, locale) => {
26
+ const formatted = new Intl.DateTimeFormat(locale, {
27
+ weekday: "short",
28
+ year: "numeric",
29
+ month: "short",
30
+ day: "numeric"
31
+ }).format(convertValueToDate(value));
32
+ if (locale?.toLowerCase() === "sv-se") {
33
+ return formatted.replace(".", "");
34
+ }
35
+ if (locale?.toLowerCase() === "en-gb") {
36
+ return formatted.replace(",", "");
37
+ }
38
+ return formatted;
39
+ },
40
+ timeShort: (value, locale) => new Intl.DateTimeFormat(locale, { timeStyle: "short" }).format(
41
+ convertValueToDate(value)
42
+ ),
43
+ timeLong: (value, locale) => new Intl.DateTimeFormat(locale, { timeStyle: "medium" }).format(
44
+ convertValueToDate(value)
45
+ )
46
+ };
47
+ export {
48
+ dateTimeFormats
49
+ };
@@ -0,0 +1,29 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { GdsFormattedText } from '../formatted-text';
3
+ import { DateTimeFormat } from './date-time-formatter';
4
+ /**
5
+ * @element gds-formatted-date
6
+ * @status beta
7
+ *
8
+ * `gds-formatted-date` extends `gds-text` and formats the date to the desired format.
9
+ *
10
+ * @example
11
+ * <gds-formatted-date
12
+ * value="2023-10-10T12:00:00Z"
13
+ * locale="sv-SE"
14
+ * format="dateOnlyNumbers">
15
+ * </gds-formatted-date>
16
+ */
17
+ export declare class GdsFormattedDate extends GdsFormattedText {
18
+ /** The date value to be formatted, either Date or ISO string. */
19
+ value?: Date | string;
20
+ /**
21
+ * Specifies the date format.
22
+ * @default 'dateOnlyNumbers'
23
+ */
24
+ format: DateTimeFormat;
25
+ /** The locale used for date formatting. */
26
+ locale?: string;
27
+ get formattedValue(): string;
28
+ protected firstUpdated(_changedProperties: PropertyValues): void;
29
+ }
@@ -0,0 +1,43 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../../chunks/chunk.QTSIPXV3.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { gdsCustomElement } from "../../../utils/helpers/custom-element-scoping.js";
6
+ import { GdsFormattedText } from "../formatted-text.js";
7
+ import { dateTimeFormats } from "./date-time-formatter.js";
8
+ let GdsFormattedDate = class extends GdsFormattedText {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.format = "dateOnlyNumbers";
12
+ }
13
+ get formattedValue() {
14
+ if (this.format && this.format in dateTimeFormats) {
15
+ return dateTimeFormats[this.format](
16
+ this.value ?? this.element?.textContent ?? void 0,
17
+ this.locale
18
+ );
19
+ }
20
+ return this.value?.toString() ?? "";
21
+ }
22
+ firstUpdated(_changedProperties) {
23
+ super.firstUpdated(_changedProperties);
24
+ if (!this.value && this.textContent) {
25
+ this.value = this.textContent;
26
+ }
27
+ }
28
+ };
29
+ __decorateClass([
30
+ property({ attribute: false })
31
+ ], GdsFormattedDate.prototype, "value", 2);
32
+ __decorateClass([
33
+ property({ type: String })
34
+ ], GdsFormattedDate.prototype, "format", 2);
35
+ __decorateClass([
36
+ property({ type: String })
37
+ ], GdsFormattedDate.prototype, "locale", 2);
38
+ GdsFormattedDate = __decorateClass([
39
+ gdsCustomElement("gds-formatted-date")
40
+ ], GdsFormattedDate);
41
+ export {
42
+ GdsFormattedDate
43
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsFormattedDate } from './formatted-date.component';
2
+ export { GdsFormattedDate };
@@ -0,0 +1,6 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsFormattedDate } from "./formatted-date.component.js";
3
+ GdsFormattedDate.define();
4
+ export {
5
+ GdsFormattedDate
6
+ };
@@ -0,0 +1 @@
1
+ export * from './formatted-date';
@@ -0,0 +1 @@
1
+ export * from "./formatted-date.js";
@@ -0,0 +1,12 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { GdsText } from '../text';
3
+ /**
4
+ * Abstract base class for Green Core formatted texts.
5
+ *
6
+ * @internal
7
+ */
8
+ export declare abstract class GdsFormattedText extends GdsText {
9
+ abstract get formattedValue(): string;
10
+ protected element?: Element;
11
+ protected updated(changedProperties: PropertyValues): void;
12
+ }
@@ -0,0 +1,19 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../chunks/chunk.QTSIPXV3.js";
4
+ import { query } from "lit/decorators.js";
5
+ import { GdsText } from "../text/index.js";
6
+ class GdsFormattedText extends GdsText {
7
+ updated(changedProperties) {
8
+ super.updated(changedProperties);
9
+ if (this.element) {
10
+ this.element.innerHTML = this.formattedValue;
11
+ }
12
+ }
13
+ }
14
+ __decorateClass([
15
+ query("[tag]")
16
+ ], GdsFormattedText.prototype, "element", 2);
17
+ export {
18
+ GdsFormattedText
19
+ };
@@ -0,0 +1,3 @@
1
+ export * from './account/account-formatter';
2
+ export * from './date/date-time-formatter';
3
+ export * from './number/number-formatter';
@@ -0,0 +1,3 @@
1
+ export * from "./account/account-formatter.js";
2
+ export * from "./date/date-time-formatter.js";
3
+ export * from "./number/number-formatter.js";
@@ -0,0 +1,4 @@
1
+ export * from './formatters';
2
+ export * from './account';
3
+ export * from './date';
4
+ export * from './number';
@@ -0,0 +1,4 @@
1
+ export * from "./formatters.js";
2
+ export * from "./account/index.js";
3
+ export * from "./date/index.js";
4
+ export * from "./number/index.js";
@@ -0,0 +1,31 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { GdsFormattedText } from '../formatted-text';
3
+ import { NumberFormats } from '../formatters';
4
+ /**
5
+ * @element gds-formatted-number
6
+ * @status beta
7
+ *
8
+ * `gds-formatted-number` extends `gds-text` and formats the number to the desired format.
9
+ *
10
+ * @example
11
+ * <gds-formatted-number
12
+ * value="1234.5"
13
+ * locale="sv-SE"
14
+ * currency="SEK">
15
+ * </gds-formatted-number>
16
+ */
17
+ export declare class GdsFormattedNumber extends GdsFormattedText {
18
+ /** The numerical value to display. */
19
+ value?: number | string;
20
+ /** The locale used for number formatting. */
21
+ locale?: string;
22
+ /** The currency used when formatting numbers. */
23
+ currency?: string;
24
+ /**
25
+ * Specifies the number format.
26
+ * @default 'decimalsAndThousands'
27
+ */
28
+ protected format: NumberFormats;
29
+ get formattedValue(): string;
30
+ protected firstUpdated(_changedProperties: PropertyValues): void;
31
+ }
@@ -0,0 +1,40 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../../chunks/chunk.QTSIPXV3.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { gdsCustomElement } from "../../../utils/helpers/custom-element-scoping.js";
6
+ import { GdsFormattedText } from "../formatted-text.js";
7
+ import { numberFormats } from "../formatters.js";
8
+ let GdsFormattedNumber = class extends GdsFormattedText {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.format = "decimalsAndThousands";
12
+ }
13
+ get formattedValue() {
14
+ return numberFormats[this.format](this.value, this.locale, this.currency);
15
+ }
16
+ firstUpdated(_changedProperties) {
17
+ super.firstUpdated(_changedProperties);
18
+ if (!this.value && this.textContent) {
19
+ this.value = this.textContent;
20
+ }
21
+ }
22
+ };
23
+ __decorateClass([
24
+ property({ attribute: false })
25
+ ], GdsFormattedNumber.prototype, "value", 2);
26
+ __decorateClass([
27
+ property({ type: String })
28
+ ], GdsFormattedNumber.prototype, "locale", 2);
29
+ __decorateClass([
30
+ property({ type: String })
31
+ ], GdsFormattedNumber.prototype, "currency", 2);
32
+ __decorateClass([
33
+ property({ type: String })
34
+ ], GdsFormattedNumber.prototype, "format", 2);
35
+ GdsFormattedNumber = __decorateClass([
36
+ gdsCustomElement("gds-formatted-number")
37
+ ], GdsFormattedNumber);
38
+ export {
39
+ GdsFormattedNumber
40
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsFormattedNumber } from './formatted-number.component';
2
+ export { GdsFormattedNumber };
@@ -0,0 +1,6 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsFormattedNumber } from "./formatted-number.component.js";
3
+ GdsFormattedNumber.define();
4
+ export {
5
+ GdsFormattedNumber
6
+ };
@@ -0,0 +1 @@
1
+ export * from './formatted-number';
@@ -0,0 +1 @@
1
+ export * from "./formatted-number.js";
@@ -0,0 +1,4 @@
1
+ export type NumberFormats = keyof typeof numberFormats;
2
+ export declare const numberFormats: {
3
+ decimalsAndThousands: (value: string | number | undefined, locale: string | undefined, currency: string | undefined) => string;
4
+ };
@@ -0,0 +1,20 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ const numberFormats = {
3
+ decimalsAndThousands: (value, locale, currency) => {
4
+ const options = {
5
+ maximumFractionDigits: 2,
6
+ minimumFractionDigits: 2
7
+ };
8
+ if (currency) {
9
+ return new Intl.NumberFormat(locale, {
10
+ ...options,
11
+ style: "currency",
12
+ currency
13
+ }).format(Number(value));
14
+ }
15
+ return new Intl.NumberFormat(locale, options).format(Number(value));
16
+ }
17
+ };
18
+ export {
19
+ numberFormats
20
+ };
@@ -0,0 +1 @@
1
+ export * from './number';
@@ -0,0 +1 @@
1
+ export * from "./number/index.js";
@@ -0,0 +1 @@
1
+ export * from './sensitive-number';
@@ -0,0 +1 @@
1
+ export * from "./sensitive-number.js";
@@ -0,0 +1,31 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { GdsFormattedNumber } from '../../formatted-text/number/formatted-number.component';
3
+ /**
4
+ * @element gds-sensitive-number
5
+ *
6
+ * @status beta
7
+ *
8
+ * [Source code](https://github.com/seb-oss/green/tree/main/libs/core/src/components/sensitiv/number)
9
+ *
10
+ * GdsSensitiveNumber is used to display numbers that need to be hidden,
11
+ * helping to protect sensitive numerical data.
12
+ *
13
+ * The component renders the formatted number and conditionally hides it based on the `hide` property.
14
+ *
15
+ * @example
16
+ * <gds-sensitive-number
17
+ * hide
18
+ * value="1234"
19
+ * locale="sv-SE">
20
+ * </gds-sensitive-number>
21
+ */
22
+ export declare class GdsSensitiveNumber extends GdsFormattedNumber {
23
+ /**
24
+ * When true, hides the sensitive number.
25
+ * @default false
26
+ */
27
+ hide: boolean;
28
+ get formattedValue(): string;
29
+ render(): any;
30
+ protected updated(changedProperties: PropertyValues): void;
31
+ }
@@ -0,0 +1,43 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../../../chunks/chunk.QTSIPXV3.js";
4
+ import { property } from "lit/decorators.js";
5
+ import { when } from "lit/directives/when.js";
6
+ import { gdsCustomElement, html } from "../../../scoping.js";
7
+ import { GdsBlur } from "../../blur/blur.component.js";
8
+ import { numberFormats } from "../../formatted-text/index.js";
9
+ import { GdsFormattedNumber } from "../../formatted-text/number/formatted-number.component.js";
10
+ let GdsSensitiveNumber = class extends GdsFormattedNumber {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.hide = false;
14
+ }
15
+ get formattedValue() {
16
+ if (this.hide) {
17
+ return numberFormats[this.format](0, this.locale, this.currency);
18
+ }
19
+ return super.formattedValue;
20
+ }
21
+ render() {
22
+ return when(
23
+ this.hide,
24
+ () => html`<gds-blur>${super.render()}</gds-blur>`,
25
+ () => super.render()
26
+ );
27
+ }
28
+ updated(changedProperties) {
29
+ super.updated(changedProperties);
30
+ if (this.element) {
31
+ this.element.ariaLabel = super.formattedValue;
32
+ }
33
+ }
34
+ };
35
+ __decorateClass([
36
+ property({ type: Boolean })
37
+ ], GdsSensitiveNumber.prototype, "hide", 2);
38
+ GdsSensitiveNumber = __decorateClass([
39
+ gdsCustomElement("gds-sensitive-number", { dependsOn: [GdsBlur] })
40
+ ], GdsSensitiveNumber);
41
+ export {
42
+ GdsSensitiveNumber
43
+ };
@@ -0,0 +1,2 @@
1
+ import { GdsSensitiveNumber } from './sensitive-number.component';
2
+ export { GdsSensitiveNumber };
@@ -0,0 +1,6 @@
1
+ import "../../../chunks/chunk.QTSIPXV3.js";
2
+ import { GdsSensitiveNumber } from "./sensitive-number.component.js";
3
+ GdsSensitiveNumber.define();
4
+ export {
5
+ GdsSensitiveNumber
6
+ };