@helsenorge/designsystem-react 14.3.0 → 14.4.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/lib/CHANGELOG.md +6 -0
- package/lib/components/Chip/Chip.d.ts +3 -0
- package/lib/components/Chip/index.js +20 -2
- package/lib/components/Chip/index.js.map +1 -1
- package/lib/components/Chip/resourceHelper.d.ts +3 -0
- package/lib/resources/HN.Designsystem.Chip.en-GB.json.d.ts +6 -0
- package/lib/resources/HN.Designsystem.Chip.nb-NO.json.d.ts +6 -0
- package/lib/resources/Resources.d.ts +26 -0
- package/package.json +1 -1
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
|
|
2
|
+
## [14.4.0](https://github.com/helsenorge/designsystem/compare/v14.3.0...v14.4.0) (2026-04-16)
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **chip:** lagt til resources ([10a2b31](https://github.com/helsenorge/designsystem/commit/10a2b31b3ef5c0fcbabea5a27cad7656f1271cff)), closes [#375385](https://github.com/helsenorge/designsystem/issues/375385)
|
|
7
|
+
|
|
2
8
|
## [14.3.0](https://github.com/helsenorge/designsystem/compare/v14.2.1...v14.3.0) (2026-04-14)
|
|
3
9
|
|
|
4
10
|
### Features
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HNDesignsystemChip } from '../../resources/Resources';
|
|
1
2
|
export interface ChipProps {
|
|
2
3
|
/** Sets the text of the chip */
|
|
3
4
|
children: string;
|
|
@@ -13,6 +14,8 @@ export interface ChipProps {
|
|
|
13
14
|
closeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
14
15
|
/** Sets the data-testid attribute on the expander button. */
|
|
15
16
|
testId?: string;
|
|
17
|
+
/** Resources for the component */
|
|
18
|
+
resources?: Partial<HNDesignsystemChip>;
|
|
16
19
|
}
|
|
17
20
|
declare const Chip: React.FC<ChipProps>;
|
|
18
21
|
export default Chip;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import { a as IconSize, n as AnalyticsId } from "../../constants2.js";
|
|
1
|
+
import { a as IconSize, n as AnalyticsId, s as LanguageLocales } from "../../constants2.js";
|
|
2
2
|
import { t as Icon_default } from "../../Icon.js";
|
|
3
|
+
import { n as useLanguage } from "../../useLanguage.js";
|
|
3
4
|
import { t as X_default } from "../../X.js";
|
|
4
5
|
import classNames from "classnames";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import styles from "./styles.module.scss";
|
|
8
|
+
var HN_Designsystem_Chip_en_GB_default = { removeAriaLabel: "Remove" };
|
|
9
|
+
var HN_Designsystem_Chip_nb_NO_default = { removeAriaLabel: "Fjern" };
|
|
10
|
+
const getResources = (language) => {
|
|
11
|
+
switch (language) {
|
|
12
|
+
case LanguageLocales.ENGLISH: return HN_Designsystem_Chip_en_GB_default;
|
|
13
|
+
case LanguageLocales.NORWEGIAN:
|
|
14
|
+
default: return HN_Designsystem_Chip_nb_NO_default;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
7
17
|
var Chip = (props) => {
|
|
8
|
-
const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true } = props;
|
|
18
|
+
const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true, resources } = props;
|
|
19
|
+
const { language } = useLanguage(LanguageLocales.NORWEGIAN);
|
|
20
|
+
const defaultResources = getResources(language);
|
|
21
|
+
const mergedResources = {
|
|
22
|
+
...defaultResources,
|
|
23
|
+
...resources,
|
|
24
|
+
removeAriaLabel: closeButtonProps?.["aria-label"] || resources?.removeAriaLabel || `${defaultResources.removeAriaLabel} ${children}`
|
|
25
|
+
};
|
|
9
26
|
return /* @__PURE__ */ jsxs("div", {
|
|
10
27
|
className: styles["chip"],
|
|
11
28
|
children: [/* @__PURE__ */ jsx("button", {
|
|
@@ -21,6 +38,7 @@ var Chip = (props) => {
|
|
|
21
38
|
})
|
|
22
39
|
}), withCloseButton && /* @__PURE__ */ jsx("button", {
|
|
23
40
|
...closeButtonProps,
|
|
41
|
+
"aria-label": mergedResources.removeAriaLabel,
|
|
24
42
|
className: classNames(styles["chip__close"]),
|
|
25
43
|
onClick: onCloseClick,
|
|
26
44
|
type: "button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Chip: React.FC<ChipProps>"],"sources":["../../../src/components/Chip/Chip.tsx","../../../src/components/Chip/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport Icon, { IconSize } from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface ChipProps {\n /** Sets the text of the chip */\n children: string;\n /** Wether or not to have a close button */\n withCloseButton?: boolean;\n /** onClick handler for text-part of the chip */\n onChipClick?: () => void;\n /** Button props for main chip button */\n chipButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** onClick handler for close button */\n onCloseClick?: () => void;\n /** Button props for the close button */\n closeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst Chip: React.FC<ChipProps> = props => {\n const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true } = props;\n\n return (\n <div className={styles['chip']}>\n <button\n {...chipButtonProps}\n className={classNames(styles['chip__chip'])}\n onClick={onChipClick}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span\n className={classNames(styles['chip__chip__inner'], {\n [styles['chip__chip__inner--without-close']]: !withCloseButton,\n })}\n >\n {children}\n </span>\n </button>\n {withCloseButton && (\n <button\n {...closeButtonProps}\n className={classNames(styles['chip__close'])}\n onClick={onCloseClick}\n type=\"button\"\n data-testid={`${testId}-close`}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span className={styles['chip__close__inner']}>\n <Icon svgIcon={X} size={IconSize.XXSmall} />\n </span>\n </button>\n )}\n </div>\n );\n};\n\nexport default Chip;\n","import Chip from './Chip';\nexport * from './Chip';\nexport default Chip;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["Chip: React.FC<ChipProps>","mergedResources: HNDesignsystemChip"],"sources":["../../../src/resources/HN.Designsystem.Chip.en-GB.json","../../../src/resources/HN.Designsystem.Chip.nb-NO.json","../../../src/components/Chip/resourceHelper.ts","../../../src/components/Chip/Chip.tsx","../../../src/components/Chip/index.ts"],"sourcesContent":["{\n \"removeAriaLabel\": \"Remove\"\n}\n","{\n \"removeAriaLabel\": \"Fjern\"\n}\n","import type { HNDesignsystemChip } from '../../resources/Resources';\n\nimport { LanguageLocales } from '../../constants';\nimport enGB from '../../resources/HN.Designsystem.Chip.en-GB.json';\nimport nbNO from '../../resources/HN.Designsystem.Chip.nb-NO.json';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemChip => {\n switch (language) {\n case LanguageLocales.ENGLISH:\n return enGB;\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import classNames from 'classnames';\n\nimport type { HNDesignsystemChip } from '../../resources/Resources';\n\nimport { getResources } from './resourceHelper';\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { useLanguage } from '../../hooks/useLanguage';\nimport Icon, { IconSize } from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface ChipProps {\n /** Sets the text of the chip */\n children: string;\n /** Wether or not to have a close button */\n withCloseButton?: boolean;\n /** onClick handler for text-part of the chip */\n onChipClick?: () => void;\n /** Button props for main chip button */\n chipButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** onClick handler for close button */\n onCloseClick?: () => void;\n /** Button props for the close button */\n closeButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemChip>;\n}\n\nconst Chip: React.FC<ChipProps> = props => {\n const { children, onChipClick, onCloseClick, chipButtonProps, closeButtonProps, testId, withCloseButton = true, resources } = props;\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const mergedResources: HNDesignsystemChip = {\n ...defaultResources,\n ...resources,\n removeAriaLabel: closeButtonProps?.['aria-label'] || resources?.removeAriaLabel || `${defaultResources.removeAriaLabel} ${children}`,\n };\n\n return (\n <div className={styles['chip']}>\n <button\n {...chipButtonProps}\n className={classNames(styles['chip__chip'])}\n onClick={onChipClick}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span\n className={classNames(styles['chip__chip__inner'], {\n [styles['chip__chip__inner--without-close']]: !withCloseButton,\n })}\n >\n {children}\n </span>\n </button>\n {withCloseButton && (\n <button\n {...closeButtonProps}\n aria-label={mergedResources.removeAriaLabel}\n className={classNames(styles['chip__close'])}\n onClick={onCloseClick}\n type=\"button\"\n data-testid={`${testId}-close`}\n data-analyticsid={AnalyticsId.Tag}\n >\n <span className={styles['chip__close__inner']}>\n <Icon svgIcon={X} size={IconSize.XXSmall} />\n </span>\n </button>\n )}\n </div>\n );\n};\n\nexport default Chip;\n","import Chip from './Chip';\nexport * from './Chip';\nexport default Chip;\n"],"mappings":";;;;;;;;;AEMA,MAAa,gBAAgB,aAAkD;AAC7E,SAAQ,UAAR;EACE,KAAK,gBAAgB,QACnB,QAAO;EACT,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACmBb,IAAMA,QAA4B,UAAS;CACzC,MAAM,EAAE,UAAU,aAAa,cAAc,iBAAiB,kBAAkB,QAAQ,kBAAkB,MAAM,cAAc;CAC9H,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAC5E,MAAM,mBAAmB,aAAa,SAAS;CAC/C,MAAMC,kBAAsC;EAC1C,GAAG;EACH,GAAG;EACH,iBAAiB,mBAAmB,iBAAiB,WAAW,mBAAmB,GAAG,iBAAiB,gBAAgB,GAAG;EAC3H;AAED,QACE,qBAAC,OAAA;EAAI,WAAW,OAAO;aACrB,oBAAC,UAAA;GACC,GAAI;GACJ,WAAW,WAAW,OAAO,cAAc;GAC3C,SAAS;GACT,MAAK;GACL,eAAa;GACb,oBAAkB,YAAY;aAE9B,oBAAC,QAAA;IACC,WAAW,WAAW,OAAO,sBAAsB,GAChD,OAAO,sCAAsC,CAAC,iBAChD,CAAC;IAED;KACI;IACA,EACR,mBACC,oBAAC,UAAA;GACC,GAAI;GACJ,cAAY,gBAAgB;GAC5B,WAAW,WAAW,OAAO,eAAe;GAC5C,SAAS;GACT,MAAK;GACL,eAAa,GAAG,OAAO;GACvB,oBAAkB,YAAY;aAE9B,oBAAC,QAAA;IAAK,WAAW,OAAO;cACtB,oBAAC,cAAA;KAAK,SAAS;KAAG,MAAM,SAAS;MAAW;KACvC;IACA,CAAA;GAEP;;ACxEV,IAAA,eD4Ee"}
|
|
@@ -146,4 +146,30 @@ export type HNDesignsystemInput = {
|
|
|
146
146
|
characters: string;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
+
export type HNDesignsystemFilter = {
|
|
150
|
+
/**
|
|
151
|
+
* Finn
|
|
152
|
+
*/
|
|
153
|
+
filterButtonText: string;
|
|
154
|
+
/**
|
|
155
|
+
* Sortering
|
|
156
|
+
*/
|
|
157
|
+
sortLabel: string;
|
|
158
|
+
/**
|
|
159
|
+
* Nullstill
|
|
160
|
+
*/
|
|
161
|
+
resetButtonText: string;
|
|
162
|
+
/**
|
|
163
|
+
* Vis ${antall} treff
|
|
164
|
+
*/
|
|
165
|
+
showButtonText: string;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type HNDesignsystemChip = {
|
|
169
|
+
/**
|
|
170
|
+
* Fjern
|
|
171
|
+
*/
|
|
172
|
+
removeAriaLabel: string;
|
|
173
|
+
};
|
|
174
|
+
|
|
149
175
|
/* eslint:enable */
|
package/package.json
CHANGED