@navikt/ds-react 0.8.2 → 0.9.2
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/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionContent.js +5 -5
- package/cjs/accordion/AccordionHeader.js +7 -7
- package/cjs/accordion/AccordionItem.js +6 -6
- package/cjs/accordion-menu/AccordionMenu.js +2 -2
- package/cjs/accordion-menu/AccordionMenuCollapsable.js +3 -3
- package/cjs/accordion-menu/AccordionMenuItem.js +2 -2
- package/cjs/alert/Alert.js +3 -3
- package/cjs/alert/AlertContent.js +3 -3
- package/cjs/alert/AlertTitle.js +3 -3
- package/cjs/button/Button.js +2 -2
- package/cjs/card/MicroCard.js +2 -2
- package/cjs/copy-to-clipboard/CopyToClipboard.js +8 -8
- package/cjs/form/ConfirmationPanel.js +2 -2
- package/cjs/form/ErrorMessage.js +1 -1
- package/cjs/form/Fieldset/Fieldset.js +7 -7
- package/cjs/form/Fieldset/useFieldset.js +1 -1
- package/cjs/form/Select.js +6 -6
- package/cjs/form/TextField.js +7 -7
- package/cjs/form/Textarea.js +9 -9
- package/cjs/form/checkbox/Checkbox.js +4 -4
- package/cjs/form/checkbox/CheckboxGroup.js +4 -4
- package/cjs/form/checkbox/useCheckbox.js +2 -2
- package/cjs/form/error-summary/ErrorSummary.js +2 -2
- package/cjs/form/error-summary/ErrorSummaryItem.js +2 -2
- package/cjs/form/radio/Radio.js +4 -4
- package/cjs/form/radio/RadioGroup.js +4 -4
- package/cjs/form/radio/useRadio.js +2 -2
- package/cjs/form/search-field/SearchField.js +5 -5
- package/cjs/form/search-field/SearchFieldButton.js +3 -3
- package/cjs/form/search-field/SearchFieldClearButton.js +3 -3
- package/cjs/form/search-field/SearchFieldInput.js +3 -3
- package/cjs/form/useFormField.js +3 -3
- package/cjs/grid/Cell.js +2 -2
- package/cjs/grid/ContentContainer.js +2 -2
- package/cjs/grid/Grid.js +2 -2
- package/cjs/guide-panel/Guide.js +3 -3
- package/cjs/guide-panel/GuidePanel.js +2 -2
- package/cjs/help-text/HelpText.js +9 -9
- package/cjs/internal-header/InternalHeader.js +2 -2
- package/cjs/internal-header/InternalHeaderTitle.js +2 -2
- package/cjs/internal-header/InternalHeaderUser.js +2 -2
- package/cjs/link/Link.js +2 -2
- package/cjs/link-panel/LinkPanel.js +2 -2
- package/cjs/link-panel/LinkPanelDescription.js +2 -2
- package/cjs/link-panel/LinkPanelTitle.js +2 -2
- package/cjs/loader/Loader.js +3 -3
- package/cjs/modal/Modal.js +6 -6
- package/cjs/modal/ModalContent.js +2 -2
- package/cjs/page-header/PageHeader.js +2 -2
- package/cjs/panel/Panel.js +2 -2
- package/cjs/popover/Popover.js +11 -11
- package/cjs/popover/PopoverContent.js +2 -2
- package/cjs/speech-bubble/Bubble.js +2 -2
- package/cjs/speech-bubble/SpeechBubble.js +4 -4
- package/cjs/speech-bubble/index.js +1 -4
- package/cjs/tag/Tag.js +2 -2
- package/cjs/typography/BodyLong.js +2 -2
- package/cjs/typography/BodyShort.js +2 -2
- package/cjs/typography/Detail.js +2 -2
- package/cjs/typography/Heading.js +2 -2
- package/cjs/typography/Ingress.js +2 -2
- package/cjs/typography/Label.js +2 -2
- package/cjs/util/useId.js +3 -3
- package/esm/form/TextField.d.ts +5 -0
- package/esm/form/TextField.js +2 -2
- package/esm/form/TextField.js.map +1 -1
- package/esm/speech-bubble/SpeechBubble.d.ts +1 -1
- package/esm/speech-bubble/SpeechBubble.js +1 -1
- package/esm/speech-bubble/SpeechBubble.js.map +1 -1
- package/esm/speech-bubble/index.d.ts +0 -2
- package/esm/speech-bubble/index.js +0 -2
- package/esm/speech-bubble/index.js.map +1 -1
- package/package.json +20 -11
- package/src/form/TextField.tsx +7 -1
- package/src/form/checkbox/Checkbox.test.tsx +29 -0
- package/src/form/stories/text-field.stories.tsx +3 -0
- package/src/speech-bubble/SpeechBubble.tsx +1 -1
- package/src/speech-bubble/index.ts +0 -2
package/esm/form/TextField.js
CHANGED
|
@@ -16,13 +16,13 @@ import ErrorMessage from "./ErrorMessage";
|
|
|
16
16
|
import { useFormField } from "./useFormField";
|
|
17
17
|
const TextField = forwardRef((props, ref) => {
|
|
18
18
|
const { inputProps, errorId, showErrorMsg, hasError, size, inputDescriptionId, } = useFormField(props, "textField");
|
|
19
|
-
const { label, className, description, htmlSize, hideLabel = false } = props, rest = __rest(props, ["label", "className", "description", "htmlSize", "hideLabel"]);
|
|
19
|
+
const { label, className, description, htmlSize, hideLabel = false, type = "text" } = props, rest = __rest(props, ["label", "className", "description", "htmlSize", "hideLabel", "type"]);
|
|
20
20
|
return (React.createElement("div", { className: cl(props.className, "navds-form-field", `navds-form-field--${size}`, { "navds-text-field--error": hasError }) },
|
|
21
21
|
React.createElement(Label, { htmlFor: inputProps.id, size: size, as: "label", className: cl("navds-text-field__label", { "sr-only": hideLabel }) }, label),
|
|
22
22
|
!!description && (React.createElement(BodyShort, { className: cl("navds-text-field__description", {
|
|
23
23
|
"sr-only": hideLabel,
|
|
24
24
|
}), id: inputDescriptionId, size: size }, description)),
|
|
25
|
-
React.createElement("input", Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { ref: ref, type:
|
|
25
|
+
React.createElement("input", Object.assign({}, omit(rest, ["error", "errorId", "size"]), inputProps, { ref: ref, type: type, className: cl(className, "navds-text-field__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "m"}`), size: htmlSize })),
|
|
26
26
|
React.createElement("div", { id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && React.createElement(ErrorMessage, { size: size }, props.error))));
|
|
27
27
|
});
|
|
28
28
|
export default TextField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/form/TextField.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAuB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,MAAM,Y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EAAE,CAAC,IAEjE,KAAK,CACA;QAEP,CAAC,CAAC,WAAW,IAAI,CAChB,oBAAC,SAAS,IACR,SAAS,EAAE,EAAE,CAAC,+BAA+B,EAAE;gBAC7C,SAAS,EAAE,SAAS;aACrB,CAAC,EACF,EAAE,EAAE,kBAAkB,EACtB,IAAI,EAAE,IAAI,IAET,WAAW,CACF,CACb;QACD,+CACM,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,EACxC,UAAU,IACd,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CACX,SAAS,EACT,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,GAAG,EAAE,CAC5B,EACD,IAAI,EAAE,QAAQ,IACd;QACF,6BAAK,EAAE,EAAE,OAAO,mBAAgB,oBAAoB,eAAW,QAAQ,IACpE,YAAY,IAAI,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACnE,CACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef } from "react";
|
|
13
13
|
import cl from "classnames";
|
|
14
|
-
import
|
|
14
|
+
import Bubble from "./Bubble";
|
|
15
15
|
const SpeechBubble = forwardRef((_a, ref) => {
|
|
16
16
|
var { children, className, topText, illustration, position = "left", illustrationBgColor, backgroundColor } = _a, rest = __rest(_a, ["children", "className", "topText", "illustration", "position", "illustrationBgColor", "backgroundColor"]);
|
|
17
17
|
return (React.createElement("div", Object.assign({ ref: ref, className: cl("navds-speechbubble", className, `navds-speechbubble--${position}`, "navds-body-long") }, rest),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpeechBubble.js","sourceRoot":"","sources":["../../src/speech-bubble/SpeechBubble.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"SpeechBubble.js","sourceRoot":"","sources":["../../src/speech-bubble/SpeechBubble.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,MAAsB,MAAM,UAAU,CAAC;AAqC9C,MAAM,YAAY,GAAG,UAAU,CAC7B,CACE,EASC,EACD,GAAG,EACH,EAAE;QAXF,EACE,QAAQ,EACR,SAAS,EACT,OAAO,EACP,YAAY,EACZ,QAAQ,GAAG,MAAM,EACjB,mBAAmB,EACnB,eAAe,OAEhB,EADI,IAAI,cART,0GASC,CADQ;IAIT,OAAO,CACL,2CACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,oBAAoB,EACpB,SAAS,EACT,uBAAuB,QAAQ,EAAE,EACjC,iBAAiB,CAClB,IACG,IAAI;QAER,6BACE,SAAS,EAAC,kCAAkC,EAC5C,KAAK,EAAE,EAAE,eAAe,EAAE,mBAAmB,EAAE,IAE9C,YAAY,CACT;QACN,4BAAI,SAAS,EAAC,iCAAiC,IAC5C,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;gBAC/B,OAAO,CACL,gCACG,KAAK,CAAC,YAAY,CAAC,KAAK,kBACvB,OAAO,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,eAAe,IACZ,KAAK,CAAC,KAAK,EACd,CACC,CACN,CAAC;aACH;QACH,CAAC,CAAC,CACC,CACD,CACP,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC;AAE7B,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/speech-bubble/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,gBAAgB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/speech-bubble/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -30,30 +30,39 @@
|
|
|
30
30
|
"create-package-json-pointers-to-esm": "node ../../utilities/scripts/createPackageJsonsWithESMPointers.js",
|
|
31
31
|
"clean": "rimraf cjs esm",
|
|
32
32
|
"build": "yarn run clean && tsc && tsc -p tsconfig-esm.json && yarn create-package-json-pointers-to-esm",
|
|
33
|
-
"watch": "tsc --watch -p tsconfig-esm.json"
|
|
33
|
+
"watch": "tsc --watch -p tsconfig-esm.json",
|
|
34
|
+
"test": "jest"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@material-ui/core": "^4.12.
|
|
37
|
-
"@navikt/ds-icons": "^0.5.
|
|
38
|
-
"@popperjs/core": "^2.
|
|
37
|
+
"@material-ui/core": "^4.12.3",
|
|
38
|
+
"@navikt/ds-icons": "^0.5.3",
|
|
39
|
+
"@popperjs/core": "^2.10.1",
|
|
39
40
|
"classnames": "^2.2.6",
|
|
40
41
|
"copy-to-clipboard": "^3.3.1",
|
|
41
42
|
"react-collapse": "^5.1.0",
|
|
42
43
|
"react-merge-refs": "^1.1.0",
|
|
43
|
-
"react-modal": "3.
|
|
44
|
-
"react-popper": "^2.2.
|
|
44
|
+
"react-modal": "3.14.3",
|
|
45
|
+
"react-popper": "^2.2.5",
|
|
45
46
|
"uuid": "^8.3.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
50
|
+
"@testing-library/react": "^12.1.0",
|
|
51
|
+
"@testing-library/user-event": "^13.2.1",
|
|
52
|
+
"@types/faker": "^5.5.8",
|
|
53
|
+
"@types/jest": "^27.0.1",
|
|
54
|
+
"@types/react-router-dom": "^5.1.9",
|
|
49
55
|
"@types/styled-components": "^5.1.14",
|
|
50
56
|
"copyfiles": "^2.4.1",
|
|
51
|
-
"
|
|
57
|
+
"faker": "^5.5.3",
|
|
58
|
+
"jest": "^27.2.0",
|
|
59
|
+
"react-router-dom": "^5.3.0",
|
|
52
60
|
"rimraf": "3.0.2",
|
|
53
|
-
"styled-components": "^5.3.1"
|
|
61
|
+
"styled-components": "^5.3.1",
|
|
62
|
+
"ts-jest": "^27.0.5"
|
|
54
63
|
},
|
|
55
64
|
"peerDependencies": {
|
|
56
65
|
"react": "^16.8.0 || ^17.0.0"
|
|
57
66
|
},
|
|
58
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "40d8d369a4c6c111cee4d89b7975bc343f066b3c"
|
|
59
68
|
}
|
package/src/form/TextField.tsx
CHANGED
|
@@ -19,6 +19,11 @@ export interface TextFieldProps
|
|
|
19
19
|
* TextField label
|
|
20
20
|
*/
|
|
21
21
|
label: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Type of form control
|
|
24
|
+
* @default "text"
|
|
25
|
+
*/
|
|
26
|
+
type?: "email" | "number" | "password" | "tel" | "text" | "url";
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
|
|
@@ -37,6 +42,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
|
|
|
37
42
|
description,
|
|
38
43
|
htmlSize,
|
|
39
44
|
hideLabel = false,
|
|
45
|
+
type = "text",
|
|
40
46
|
...rest
|
|
41
47
|
} = props;
|
|
42
48
|
|
|
@@ -73,7 +79,7 @@ const TextField = forwardRef<HTMLInputElement, TextFieldProps>((props, ref) => {
|
|
|
73
79
|
{...omit(rest, ["error", "errorId", "size"])}
|
|
74
80
|
{...inputProps}
|
|
75
81
|
ref={ref}
|
|
76
|
-
type=
|
|
82
|
+
type={type}
|
|
77
83
|
className={cl(
|
|
78
84
|
className,
|
|
79
85
|
"navds-text-field__input",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import faker from "faker";
|
|
5
|
+
import { Checkbox, CheckboxGroup } from ".";
|
|
6
|
+
|
|
7
|
+
test("checkbox group chains onChange calls", () => {
|
|
8
|
+
const onGroupChange = jest.fn();
|
|
9
|
+
const onChange = jest.fn();
|
|
10
|
+
const value = faker.datatype.string();
|
|
11
|
+
const label = faker.datatype.string();
|
|
12
|
+
|
|
13
|
+
render(
|
|
14
|
+
<CheckboxGroup legend="legend" onChange={onGroupChange}>
|
|
15
|
+
<Checkbox onChange={onChange} value={value}>
|
|
16
|
+
{label}
|
|
17
|
+
</Checkbox>
|
|
18
|
+
</CheckboxGroup>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
userEvent.click(screen.getByLabelText(label));
|
|
22
|
+
|
|
23
|
+
expect(onGroupChange).toBeCalledTimes(1);
|
|
24
|
+
expect(onGroupChange).toBeCalledWith([value]);
|
|
25
|
+
expect(onChange).toBeCalledTimes(1);
|
|
26
|
+
expect(firstArgumentOfFirstCall(onChange).target.checked).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const firstArgumentOfFirstCall = (fn: jest.Mock) => fn.mock.calls[0][0];
|