@sebgroup/green-core 1.73.0 → 1.74.1
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/components/blur/blur.component.d.ts +18 -0
- package/components/blur/blur.component.js +18 -0
- package/components/blur/blur.d.ts +2 -0
- package/components/blur/blur.js +6 -0
- package/components/blur/blur.styles.d.ts +2 -0
- package/components/blur/blur.styles.js +12 -0
- package/components/blur/index.d.ts +1 -0
- package/components/blur/index.js +1 -0
- package/components/details/details.styles.js +30 -15
- package/components/formatted-text/account/account-formatter.d.ts +4 -0
- package/components/formatted-text/account/account-formatter.js +13 -0
- package/components/formatted-text/account/formatted-account.component.d.ts +28 -0
- package/components/formatted-text/account/formatted-account.component.js +34 -0
- package/components/formatted-text/account/formatted-account.d.ts +2 -0
- package/components/formatted-text/account/formatted-account.js +6 -0
- package/components/formatted-text/account/index.d.ts +1 -0
- package/components/formatted-text/account/index.js +1 -0
- package/components/formatted-text/date/date-time-formatter.d.ts +10 -0
- package/components/formatted-text/date/date-time-formatter.js +49 -0
- package/components/formatted-text/date/formatted-date.component.d.ts +29 -0
- package/components/formatted-text/date/formatted-date.component.js +43 -0
- package/components/formatted-text/date/formatted-date.d.ts +2 -0
- package/components/formatted-text/date/formatted-date.js +6 -0
- package/components/formatted-text/date/index.d.ts +1 -0
- package/components/formatted-text/date/index.js +1 -0
- package/components/formatted-text/formatted-text.d.ts +12 -0
- package/components/formatted-text/formatted-text.js +19 -0
- package/components/formatted-text/formatters.d.ts +3 -0
- package/components/formatted-text/formatters.js +3 -0
- package/components/formatted-text/index.d.ts +4 -0
- package/components/formatted-text/index.js +4 -0
- package/components/formatted-text/number/formatted-number.component.d.ts +31 -0
- package/components/formatted-text/number/formatted-number.component.js +40 -0
- package/components/formatted-text/number/formatted-number.d.ts +2 -0
- package/components/formatted-text/number/formatted-number.js +6 -0
- package/components/formatted-text/number/index.d.ts +1 -0
- package/components/formatted-text/number/index.js +1 -0
- package/components/formatted-text/number/number-formatter.d.ts +4 -0
- package/components/formatted-text/number/number-formatter.js +20 -0
- package/components/sensitive/index.d.ts +1 -0
- package/components/sensitive/index.js +1 -0
- package/components/sensitive/number/index.d.ts +1 -0
- package/components/sensitive/number/index.js +1 -0
- package/components/sensitive/number/sensitive-number.component.d.ts +31 -0
- package/components/sensitive/number/sensitive-number.component.js +43 -0
- package/components/sensitive/number/sensitive-number.d.ts +2 -0
- package/components/sensitive/number/sensitive-number.js +6 -0
- package/components/theme/chlorophyll-tokens.scss.js +1 -1
- package/generated/react/blur/index.d.ts +365 -0
- package/generated/react/blur/index.js +13 -0
- package/generated/react/formatted-account/index.d.ts +428 -0
- package/generated/react/formatted-account/index.js +15 -0
- package/generated/react/formatted-date/index.d.ts +430 -0
- package/generated/react/formatted-date/index.js +13 -0
- package/generated/react/formatted-number/index.d.ts +430 -0
- package/generated/react/formatted-number/index.js +15 -0
- package/generated/react/index.d.ts +9 -4
- package/generated/react/index.js +9 -4
- package/generated/react/sensitive-number/index.d.ts +431 -0
- package/generated/react/sensitive-number/index.js +15 -0
- package/package.json +19 -1
- package/setup-jest.js +43 -13
- package/tokens/dark.css.js +1 -1
- package/tokens/light.css.js +1 -1
- package/tokens/motion.css.js +1 -1
- package/tokens/shadow.css.js +1 -1
- package/tokens/size.css.js +1 -1
- package/tokens/text.css.js +1 -1
- 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 @@
|
|
|
1
|
+
export * from './blur';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./blur.js";
|
|
@@ -32,6 +32,23 @@ const styles = css`
|
|
|
32
32
|
width: max-content;
|
|
33
33
|
height: max-content;
|
|
34
34
|
line-height: 1;
|
|
35
|
+
position: relative;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.summary-icon::after {
|
|
39
|
+
content: '';
|
|
40
|
+
position: absolute;
|
|
41
|
+
border-radius: var(--gds-space-max);
|
|
42
|
+
transition: all 280ms;
|
|
43
|
+
inset: 0;
|
|
44
|
+
scale: 0.9;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
background-color: color-mix(
|
|
48
|
+
in srgb,
|
|
49
|
+
transparent,
|
|
50
|
+
var(--gds-color-l3-states-light-hover)
|
|
51
|
+
);
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
.summary:focus {
|
|
@@ -43,20 +60,15 @@ const styles = css`
|
|
|
43
60
|
}
|
|
44
61
|
|
|
45
62
|
@media (pointer: fine) {
|
|
46
|
-
.summary:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var(--gds-color-l3-states-light-hover)
|
|
51
|
-
);
|
|
63
|
+
.summary:hover .summary-icon::after,
|
|
64
|
+
.summary:focus-visible .summary-icon::after {
|
|
65
|
+
opacity: 1;
|
|
66
|
+
scale: 1;
|
|
52
67
|
}
|
|
53
68
|
|
|
54
|
-
.summary:active .summary-icon {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
transparent,
|
|
58
|
-
var(--gds-color-l3-states-light-pressed)
|
|
59
|
-
);
|
|
69
|
+
.summary:active .summary-icon::after {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
scale: 1;
|
|
60
72
|
}
|
|
61
73
|
|
|
62
74
|
.details:hover,
|
|
@@ -101,15 +113,18 @@ const styles = css`
|
|
|
101
113
|
.content {
|
|
102
114
|
interpolate-size: allow-keywords;
|
|
103
115
|
height: 0;
|
|
104
|
-
transition:
|
|
105
|
-
|
|
116
|
+
transition:
|
|
117
|
+
height 0.35s ease,
|
|
118
|
+
padding-block-end 0.35s ease;
|
|
119
|
+
overflow: hidden;
|
|
106
120
|
outline: none;
|
|
121
|
+
scrollbar-width: none;
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
.content.open {
|
|
125
|
+
overflow: auto;
|
|
110
126
|
height: max-content;
|
|
111
127
|
max-height: 100vh;
|
|
112
|
-
overflow-y: auto;
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
130
|
`;
|
|
@@ -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 @@
|
|
|
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 @@
|
|
|
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,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 @@
|
|
|
1
|
+
export * from './formatted-number';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./formatted-number.js";
|
|
@@ -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
|
+
}
|