@navikt/ds-react 0.19.16 → 0.19.19
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/_docs.json +38 -0
- package/cjs/accordion/AccordionContent.js +2 -1
- package/cjs/accordion/AccordionHeader.js +3 -7
- package/cjs/form/search/Search.js +6 -4
- package/esm/accordion/AccordionContent.js +2 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +3 -7
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/form/search/Search.d.ts +1 -1
- package/esm/form/search/Search.js +7 -5
- package/esm/form/search/Search.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/AccordionContent.tsx +6 -2
- package/src/accordion/AccordionHeader.tsx +3 -14
- package/src/form/search/Search.tsx +19 -6
- package/src/form/search/search.stories.tsx +21 -0
- package/src/read-more/readmore.stories.tsx +9 -2
- package/cjs/form/search/useSearch.js +0 -31
- package/esm/form/search/useSearch.d.ts +0 -10
- package/esm/form/search/useSearch.js +0 -25
- package/esm/form/search/useSearch.js.map +0 -1
- package/src/form/search/useSearch.ts +0 -31
package/_docs.json
CHANGED
|
@@ -9019,6 +9019,44 @@
|
|
|
9019
9019
|
"name": "\"primary\" | \"secondary\" | \"simple\""
|
|
9020
9020
|
}
|
|
9021
9021
|
},
|
|
9022
|
+
"error": {
|
|
9023
|
+
"defaultValue": null,
|
|
9024
|
+
"description": "Error message for element",
|
|
9025
|
+
"name": "error",
|
|
9026
|
+
"parent": {
|
|
9027
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
9028
|
+
"name": "FormFieldProps"
|
|
9029
|
+
},
|
|
9030
|
+
"declarations": [
|
|
9031
|
+
{
|
|
9032
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
9033
|
+
"name": "FormFieldProps"
|
|
9034
|
+
}
|
|
9035
|
+
],
|
|
9036
|
+
"required": false,
|
|
9037
|
+
"type": {
|
|
9038
|
+
"name": "ReactNode"
|
|
9039
|
+
}
|
|
9040
|
+
},
|
|
9041
|
+
"errorId": {
|
|
9042
|
+
"defaultValue": null,
|
|
9043
|
+
"description": "Override internal errorId",
|
|
9044
|
+
"name": "errorId",
|
|
9045
|
+
"parent": {
|
|
9046
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
9047
|
+
"name": "FormFieldProps"
|
|
9048
|
+
},
|
|
9049
|
+
"declarations": [
|
|
9050
|
+
{
|
|
9051
|
+
"fileName": "react/src/form/useFormField.ts",
|
|
9052
|
+
"name": "FormFieldProps"
|
|
9053
|
+
}
|
|
9054
|
+
],
|
|
9055
|
+
"required": false,
|
|
9056
|
+
"type": {
|
|
9057
|
+
"name": "string"
|
|
9058
|
+
}
|
|
9059
|
+
},
|
|
9022
9060
|
"size": {
|
|
9023
9061
|
"defaultValue": null,
|
|
9024
9062
|
"description": "Changes font-size, padding and gaps",
|
|
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
const classnames_1 = __importDefault(require("classnames"));
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const react_collapse_1 = require("react-collapse");
|
|
43
|
+
const typography_1 = require("../typography");
|
|
43
44
|
const AccordionItem_1 = require("./AccordionItem");
|
|
44
45
|
const AccordionContent = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
46
|
var { children, className, id } = _a, rest = __rest(_a, ["children", "className", "id"]);
|
|
@@ -53,6 +54,6 @@ const AccordionContent = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
53
54
|
: react_collapse_1.UnmountClosed;
|
|
54
55
|
return (react_1.default.createElement("div", Object.assign({ ref: ref, "aria-labelledby": context.buttonId }, rest),
|
|
55
56
|
react_1.default.createElement(CollapseComponent, { isOpened: context.open },
|
|
56
|
-
react_1.default.createElement("div",
|
|
57
|
+
react_1.default.createElement(typography_1.BodyLong, { as: "div", className: (0, classnames_1.default)("navds-accordion__content", className) }, children))));
|
|
57
58
|
});
|
|
58
59
|
exports.default = AccordionContent;
|
|
@@ -59,12 +59,8 @@ const AccordionHeader = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
59
59
|
onClick && onClick(e);
|
|
60
60
|
};
|
|
61
61
|
return (react_1.default.createElement("button", Object.assign({}, rest, { ref: ref, id: context.buttonId, className: (0, classnames_1.default)("navds-accordion__header", className, "navds-heading", "navds-heading--small"), onClick: handleClick, "aria-expanded": context.open }),
|
|
62
|
-
children,
|
|
63
|
-
react_1.default.createElement(ds_icons_1.Expand, { "aria-hidden": true, className:
|
|
64
|
-
|
|
65
|
-
}) }),
|
|
66
|
-
react_1.default.createElement(ds_icons_1.ExpandFilled, { "aria-hidden": true, className: (0, classnames_1.default)("navds-accordion__expand-icon", "navds-accordion__expand-icon--filled", {
|
|
67
|
-
"navds-accordion__expand-icon--flip": context.open,
|
|
68
|
-
}) })));
|
|
62
|
+
react_1.default.createElement("span", { className: "navds-accordion__header-content" }, children),
|
|
63
|
+
react_1.default.createElement(ds_icons_1.Expand, { "aria-hidden": true, className: "navds-accordion__expand-icon" }),
|
|
64
|
+
react_1.default.createElement(ds_icons_1.ExpandFilled, { "aria-hidden": true, className: "navds-accordion__expand-icon navds-accordion__expand-icon--filled" })));
|
|
69
65
|
});
|
|
70
66
|
exports.default = AccordionHeader;
|
|
@@ -43,11 +43,11 @@ const classnames_1 = __importDefault(require("classnames"));
|
|
|
43
43
|
const react_1 = __importStar(require("react"));
|
|
44
44
|
const react_merge_refs_1 = __importDefault(require("react-merge-refs"));
|
|
45
45
|
const __1 = require("../..");
|
|
46
|
+
const useFormField_1 = require("../useFormField");
|
|
46
47
|
const SearchButton_1 = __importDefault(require("./SearchButton"));
|
|
47
|
-
const useSearch_1 = require("./useSearch");
|
|
48
48
|
exports.SearchContext = react_1.default.createContext(null);
|
|
49
49
|
exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
50
|
-
const { inputProps, size = "medium", inputDescriptionId, } = (0,
|
|
50
|
+
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, } = (0, useFormField_1.useFormField)(props, "searchfield");
|
|
51
51
|
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "variant", "defaultValue", "onChange"]);
|
|
52
52
|
const searchRef = (0, react_1.useRef)(null);
|
|
53
53
|
const mergedRef = (0, react_merge_refs_1.default)([searchRef, ref]);
|
|
@@ -70,6 +70,7 @@ exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
70
70
|
}
|
|
71
71
|
}, [handleClear]), wrapperRef);
|
|
72
72
|
return (react_1.default.createElement("div", { ref: setWrapperRef, className: (0, classnames_1.default)(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
73
|
+
"navds-search--error": hasError,
|
|
73
74
|
"navds-search--disabled": !!inputProps.disabled,
|
|
74
75
|
}) },
|
|
75
76
|
react_1.default.createElement(__1.Label, { htmlFor: inputProps.id, size: size, as: "label", className: (0, classnames_1.default)("navds-form-field__label", {
|
|
@@ -81,7 +82,7 @@ exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
81
82
|
react_1.default.createElement("div", { className: "navds-search__wrapper" },
|
|
82
83
|
react_1.default.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
83
84
|
variant === "simple" && (react_1.default.createElement(ds_icons_1.Search, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
84
|
-
react_1.default.createElement("input", Object.assign({ ref: mergedRef }, (0, __1.omit)(rest, ["size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: (0, classnames_1.default)(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
85
|
+
react_1.default.createElement("input", Object.assign({ ref: mergedRef }, (0, __1.omit)(rest, ["error", "errorId", "size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: (0, classnames_1.default)(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
85
86
|
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (react_1.default.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
86
87
|
react_1.default.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
87
88
|
react_1.default.createElement(ds_icons_1.Close, { "aria-hidden": true })))),
|
|
@@ -89,7 +90,8 @@ exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
89
90
|
size,
|
|
90
91
|
disabled: inputProps.disabled,
|
|
91
92
|
variant,
|
|
92
|
-
} }, children ? children : variant !== "simple" && react_1.default.createElement(SearchButton_1.default, null)))
|
|
93
|
+
} }, children ? children : variant !== "simple" && react_1.default.createElement(SearchButton_1.default, null))),
|
|
94
|
+
react_1.default.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (react_1.default.createElement(__1.ErrorMessage, { size: size }, props.error)))));
|
|
93
95
|
});
|
|
94
96
|
exports.Search.Button = SearchButton_1.default;
|
|
95
97
|
exports.default = exports.Search;
|
|
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import cl from "classnames";
|
|
13
13
|
import React, { forwardRef, useContext } from "react";
|
|
14
14
|
import { Collapse, UnmountClosed } from "react-collapse";
|
|
15
|
+
import { BodyLong } from "../typography";
|
|
15
16
|
import { AccordionItemContext } from "./AccordionItem";
|
|
16
17
|
const AccordionContent = forwardRef((_a, ref) => {
|
|
17
18
|
var { children, className, id } = _a, rest = __rest(_a, ["children", "className", "id"]);
|
|
@@ -25,7 +26,7 @@ const AccordionContent = forwardRef((_a, ref) => {
|
|
|
25
26
|
: UnmountClosed;
|
|
26
27
|
return (React.createElement("div", Object.assign({ ref: ref, "aria-labelledby": context.buttonId }, rest),
|
|
27
28
|
React.createElement(CollapseComponent, { isOpened: context.open },
|
|
28
|
-
React.createElement("div",
|
|
29
|
+
React.createElement(BodyLong, { as: "div", className: cl("navds-accordion__content", className) }, children))));
|
|
29
30
|
});
|
|
30
31
|
export default AccordionContent;
|
|
31
32
|
//# sourceMappingURL=AccordionContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionContent.js","sourceRoot":"","sources":["../../src/accordion/AccordionContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgBvD,MAAM,gBAAgB,GAAyB,UAAU,CACvD,CAAC,EAAoC,EAAE,GAAG,EAAE,EAAE;QAA7C,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,OAAW,EAAN,IAAI,cAAlC,+BAAoC,CAAF;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAEjD,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,CAAC,KAAK,CACX,+DAA+D,CAChE,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,uBAAuB;QACvD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC;IAElB,OAAO,CACL,2CAAK,GAAG,EAAE,GAAG,qBAAmB,OAAO,CAAC,QAAQ,IAAM,IAAI;QACxD,oBAAC,iBAAiB,IAAC,QAAQ,EAAE,OAAO,CAAC,IAAI;YACvC,
|
|
1
|
+
{"version":3,"file":"AccordionContent.js","sourceRoot":"","sources":["../../src/accordion/AccordionContent.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgBvD,MAAM,gBAAgB,GAAyB,UAAU,CACvD,CAAC,EAAoC,EAAE,GAAG,EAAE,EAAE;QAA7C,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,OAAW,EAAN,IAAI,cAAlC,+BAAoC,CAAF;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAEjD,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,CAAC,KAAK,CACX,+DAA+D,CAChE,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAED,MAAM,iBAAiB,GAAG,OAAO,CAAC,uBAAuB;QACvD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,aAAa,CAAC;IAElB,OAAO,CACL,2CAAK,GAAG,EAAE,GAAG,qBAAmB,OAAO,CAAC,QAAQ,IAAM,IAAI;QACxD,oBAAC,iBAAiB,IAAC,QAAQ,EAAE,OAAO,CAAC,IAAI;YACvC,oBAAC,QAAQ,IACP,EAAE,EAAC,KAAK,EACR,SAAS,EAAE,EAAE,CAAC,0BAA0B,EAAE,SAAS,CAAC,IAEnD,QAAQ,CACA,CACO,CAChB,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -31,13 +31,9 @@ const AccordionHeader = forwardRef((_a, ref) => {
|
|
|
31
31
|
onClick && onClick(e);
|
|
32
32
|
};
|
|
33
33
|
return (React.createElement("button", Object.assign({}, rest, { ref: ref, id: context.buttonId, className: cl("navds-accordion__header", className, "navds-heading", "navds-heading--small"), onClick: handleClick, "aria-expanded": context.open }),
|
|
34
|
-
children,
|
|
35
|
-
React.createElement(Expand, { "aria-hidden": true, className:
|
|
36
|
-
|
|
37
|
-
}) }),
|
|
38
|
-
React.createElement(ExpandFilled, { "aria-hidden": true, className: cl("navds-accordion__expand-icon", "navds-accordion__expand-icon--filled", {
|
|
39
|
-
"navds-accordion__expand-icon--flip": context.open,
|
|
40
|
-
}) })));
|
|
34
|
+
React.createElement("span", { className: "navds-accordion__header-content" }, children),
|
|
35
|
+
React.createElement(Expand, { "aria-hidden": true, className: "navds-accordion__expand-icon" }),
|
|
36
|
+
React.createElement(ExpandFilled, { "aria-hidden": true, className: "navds-accordion__expand-icon navds-accordion__expand-icon--filled" })));
|
|
41
37
|
});
|
|
42
38
|
export default AccordionHeader;
|
|
43
39
|
//# sourceMappingURL=AccordionHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccordionHeader.js","sourceRoot":"","sources":["../../src/accordion/AccordionHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAclD,MAAM,eAAe,GAAwB,UAAU,CACrD,CAAC,EAA6C,EAAE,GAAG,EAAE,EAAE;QAAtD,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,OAAW,EAAN,IAAI,cAA3C,0CAA6C,CAAF;IAC1C,MAAM,OAAO,GAAG,UAAU,C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C"}
|
|
@@ -8,7 +8,7 @@ export declare type SearchClearEvent = {
|
|
|
8
8
|
trigger: "Escape";
|
|
9
9
|
event: React.KeyboardEvent<HTMLDivElement>;
|
|
10
10
|
};
|
|
11
|
-
export interface SearchProps extends
|
|
11
|
+
export interface SearchProps extends FormFieldProps, Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "onChange"> {
|
|
12
12
|
children?: React.ReactNode;
|
|
13
13
|
/**
|
|
14
14
|
* Search label
|
|
@@ -13,12 +13,12 @@ import { Close, Search as SearchIcon } from "@navikt/ds-icons";
|
|
|
13
13
|
import cl from "classnames";
|
|
14
14
|
import React, { forwardRef, useCallback, useRef, useState, } from "react";
|
|
15
15
|
import mergeRefs from "react-merge-refs";
|
|
16
|
-
import { BodyShort, Label, omit, useEventListener } from "../..";
|
|
16
|
+
import { BodyShort, ErrorMessage, Label, omit, useEventListener } from "../..";
|
|
17
|
+
import { useFormField } from "../useFormField";
|
|
17
18
|
import SearchButton from "./SearchButton";
|
|
18
|
-
import { useSearch } from "./useSearch";
|
|
19
19
|
export const SearchContext = React.createContext(null);
|
|
20
20
|
export const Search = forwardRef((props, ref) => {
|
|
21
|
-
const { inputProps, size = "medium", inputDescriptionId, } =
|
|
21
|
+
const { inputProps, size = "medium", inputDescriptionId, errorId, showErrorMsg, hasError, } = useFormField(props, "searchfield");
|
|
22
22
|
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "variant", "defaultValue", "onChange"]);
|
|
23
23
|
const searchRef = useRef(null);
|
|
24
24
|
const mergedRef = mergeRefs([searchRef, ref]);
|
|
@@ -41,6 +41,7 @@ export const Search = forwardRef((props, ref) => {
|
|
|
41
41
|
}
|
|
42
42
|
}, [handleClear]), wrapperRef);
|
|
43
43
|
return (React.createElement("div", { ref: setWrapperRef, className: cl(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
44
|
+
"navds-search--error": hasError,
|
|
44
45
|
"navds-search--disabled": !!inputProps.disabled,
|
|
45
46
|
}) },
|
|
46
47
|
React.createElement(Label, { htmlFor: inputProps.id, size: size, as: "label", className: cl("navds-form-field__label", {
|
|
@@ -52,7 +53,7 @@ export const Search = forwardRef((props, ref) => {
|
|
|
52
53
|
React.createElement("div", { className: "navds-search__wrapper" },
|
|
53
54
|
React.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
54
55
|
variant === "simple" && (React.createElement(SearchIcon, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
55
|
-
React.createElement("input", Object.assign({ ref: mergedRef }, omit(rest, ["size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: cl(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
56
|
+
React.createElement("input", Object.assign({ ref: mergedRef }, omit(rest, ["error", "errorId", "size"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: "searchbox", className: cl(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-${size}`) })),
|
|
56
57
|
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (React.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
57
58
|
React.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
58
59
|
React.createElement(Close, { "aria-hidden": true })))),
|
|
@@ -60,7 +61,8 @@ export const Search = forwardRef((props, ref) => {
|
|
|
60
61
|
size,
|
|
61
62
|
disabled: inputProps.disabled,
|
|
62
63
|
variant,
|
|
63
|
-
} }, children ? children : variant !== "simple" && React.createElement(SearchButton, null)))
|
|
64
|
+
} }, children ? children : variant !== "simple" && React.createElement(SearchButton, null))),
|
|
65
|
+
React.createElement("div", { className: "navds-form-field__error", id: errorId, "aria-relevant": "additions removals", "aria-live": "polite" }, showErrorMsg && (React.createElement(ErrorMessage, { size: size }, props.error)))));
|
|
64
66
|
});
|
|
65
67
|
Search.Button = SearchButton;
|
|
66
68
|
export default Search;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../../../src/form/search/Search.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EACZ,UAAU,EAEV,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Search.js","sourceRoot":"","sources":["../../../src/form/search/Search.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EACZ,UAAU,EAEV,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAkB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,YAAkC,MAAM,gBAAgB,CAAC;AA6DhE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,IAAI,CACL,CA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AY,IAAI,CACf,oBAAC,YAAY,IAAC,IAAI,EAAE,IAAI,IAAG,KAAK,CAAC,KAAK,CAAgB,CACvD,CACG,CACF,CACP,CAAC;AACJ,CAAC,CACiB,CAAC;AAErB,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC;AAE7B,eAAe,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.19",
|
|
4
4
|
"description": "NAV designsystem react components",
|
|
5
5
|
"author": "NAV Designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react-dom": "0.6.0",
|
|
39
39
|
"@material-ui/core": "^4.12.3",
|
|
40
|
-
"@navikt/ds-icons": "^0.8.
|
|
40
|
+
"@navikt/ds-icons": "^0.8.18",
|
|
41
41
|
"@popperjs/core": "^2.10.1",
|
|
42
42
|
"@radix-ui/react-tabs": "0.1.5",
|
|
43
43
|
"@radix-ui/react-toggle-group": "0.1.5",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"@types/react": "^17.0.30 || ^18.0.0",
|
|
77
77
|
"react": "^17.0.0 || ^18.0.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "43251ae7c36ecc5f62a431326adbffe4970c38ff"
|
|
80
80
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import cl from "classnames";
|
|
2
2
|
import React, { forwardRef, useContext } from "react";
|
|
3
3
|
import { Collapse, UnmountClosed } from "react-collapse";
|
|
4
|
+
import { BodyLong } from "../typography";
|
|
4
5
|
import { AccordionItemContext } from "./AccordionItem";
|
|
5
6
|
|
|
6
7
|
export interface AccordionContentProps
|
|
@@ -35,9 +36,12 @@ const AccordionContent: AccordionContentType = forwardRef(
|
|
|
35
36
|
return (
|
|
36
37
|
<div ref={ref} aria-labelledby={context.buttonId} {...rest}>
|
|
37
38
|
<CollapseComponent isOpened={context.open}>
|
|
38
|
-
<
|
|
39
|
+
<BodyLong
|
|
40
|
+
as="div"
|
|
41
|
+
className={cl("navds-accordion__content", className)}
|
|
42
|
+
>
|
|
39
43
|
{children}
|
|
40
|
-
</
|
|
44
|
+
</BodyLong>
|
|
41
45
|
</CollapseComponent>
|
|
42
46
|
</div>
|
|
43
47
|
);
|
|
@@ -55,22 +55,11 @@ const AccordionHeader: AccordionHeaderType = forwardRef(
|
|
|
55
55
|
onClick={handleClick}
|
|
56
56
|
aria-expanded={context.open}
|
|
57
57
|
>
|
|
58
|
-
{children}
|
|
59
|
-
<Expand
|
|
60
|
-
aria-hidden
|
|
61
|
-
className={cl("navds-accordion__expand-icon", {
|
|
62
|
-
"navds-accordion__expand-icon--flip": context.open,
|
|
63
|
-
})}
|
|
64
|
-
/>
|
|
58
|
+
<span className="navds-accordion__header-content">{children}</span>
|
|
59
|
+
<Expand aria-hidden className="navds-accordion__expand-icon" />
|
|
65
60
|
<ExpandFilled
|
|
66
61
|
aria-hidden
|
|
67
|
-
className=
|
|
68
|
-
"navds-accordion__expand-icon",
|
|
69
|
-
"navds-accordion__expand-icon--filled",
|
|
70
|
-
{
|
|
71
|
-
"navds-accordion__expand-icon--flip": context.open,
|
|
72
|
-
}
|
|
73
|
-
)}
|
|
62
|
+
className="navds-accordion__expand-icon navds-accordion__expand-icon--filled"
|
|
74
63
|
/>
|
|
75
64
|
</button>
|
|
76
65
|
);
|
|
@@ -8,10 +8,9 @@ import React, {
|
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
10
|
import mergeRefs from "react-merge-refs";
|
|
11
|
-
import { BodyShort, Label, omit, useEventListener } from "../..";
|
|
12
|
-
import { FormFieldProps } from "../useFormField";
|
|
11
|
+
import { BodyShort, ErrorMessage, Label, omit, useEventListener } from "../..";
|
|
12
|
+
import { FormFieldProps, useFormField } from "../useFormField";
|
|
13
13
|
import SearchButton, { SearchButtonType } from "./SearchButton";
|
|
14
|
-
import { useSearch } from "./useSearch";
|
|
15
14
|
|
|
16
15
|
export type SearchClearEvent =
|
|
17
16
|
| {
|
|
@@ -21,7 +20,7 @@ export type SearchClearEvent =
|
|
|
21
20
|
| { trigger: "Escape"; event: React.KeyboardEvent<HTMLDivElement> };
|
|
22
21
|
|
|
23
22
|
export interface SearchProps
|
|
24
|
-
extends
|
|
23
|
+
extends FormFieldProps,
|
|
25
24
|
Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "onChange"> {
|
|
26
25
|
children?: React.ReactNode;
|
|
27
26
|
/**
|
|
@@ -82,7 +81,10 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
82
81
|
inputProps,
|
|
83
82
|
size = "medium",
|
|
84
83
|
inputDescriptionId,
|
|
85
|
-
|
|
84
|
+
errorId,
|
|
85
|
+
showErrorMsg,
|
|
86
|
+
hasError,
|
|
87
|
+
} = useFormField(props, "searchfield");
|
|
86
88
|
|
|
87
89
|
const {
|
|
88
90
|
className,
|
|
@@ -146,6 +148,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
146
148
|
`navds-form-field--${size}`,
|
|
147
149
|
"navds-search",
|
|
148
150
|
{
|
|
151
|
+
"navds-search--error": hasError,
|
|
149
152
|
"navds-search--disabled": !!inputProps.disabled,
|
|
150
153
|
}
|
|
151
154
|
)}
|
|
@@ -179,7 +182,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
179
182
|
)}
|
|
180
183
|
<input
|
|
181
184
|
ref={mergedRef}
|
|
182
|
-
{...omit(rest, ["size"])}
|
|
185
|
+
{...omit(rest, ["error", "errorId", "size"])}
|
|
183
186
|
{...inputProps}
|
|
184
187
|
value={value ?? internalValue}
|
|
185
188
|
onChange={(e) => handleChange(e.target.value)}
|
|
@@ -217,6 +220,16 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
217
220
|
{children ? children : variant !== "simple" && <SearchButton />}
|
|
218
221
|
</SearchContext.Provider>
|
|
219
222
|
</div>
|
|
223
|
+
<div
|
|
224
|
+
className="navds-form-field__error"
|
|
225
|
+
id={errorId}
|
|
226
|
+
aria-relevant="additions removals"
|
|
227
|
+
aria-live="polite"
|
|
228
|
+
>
|
|
229
|
+
{showErrorMsg && (
|
|
230
|
+
<ErrorMessage size={size}>{props.error}</ErrorMessage>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
220
233
|
</div>
|
|
221
234
|
);
|
|
222
235
|
}
|
|
@@ -23,6 +23,11 @@ export default {
|
|
|
23
23
|
options: ["primary", "secondary", "simple"],
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
+
error: {
|
|
27
|
+
control: {
|
|
28
|
+
type: "text",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
26
31
|
},
|
|
27
32
|
} as Meta;
|
|
28
33
|
|
|
@@ -38,6 +43,7 @@ export const Default = (props) => {
|
|
|
38
43
|
clearButton={props.clearButton}
|
|
39
44
|
variant={props.variant}
|
|
40
45
|
hideLabel={props.hideLabel}
|
|
46
|
+
error={props.error}
|
|
41
47
|
/>
|
|
42
48
|
</div>
|
|
43
49
|
);
|
|
@@ -79,6 +85,21 @@ export const Variants = () => (
|
|
|
79
85
|
</div>
|
|
80
86
|
);
|
|
81
87
|
|
|
88
|
+
export const ErrorVariants = () => (
|
|
89
|
+
<div className="rowgap">
|
|
90
|
+
<div className="colgap">
|
|
91
|
+
<Search error="errormsg" label="Søk" />
|
|
92
|
+
<Search error="errormsg" label="Søk" variant="secondary" />
|
|
93
|
+
<Search error="errormsg" label="Søk" variant="simple" />
|
|
94
|
+
</div>
|
|
95
|
+
<div className="colgap" data-theme="dark">
|
|
96
|
+
<Search error="errormsg" label="Søk" />
|
|
97
|
+
<Search error="errormsg" label="Søk" variant="secondary" />
|
|
98
|
+
<Search error="errormsg" label="Søk" variant="simple" />
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
|
|
82
103
|
export const Placeholder = () => (
|
|
83
104
|
<div className="rowgap">
|
|
84
105
|
<div className="colgap">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { ReadMore } from ".";
|
|
3
|
+
import { BodyShort } from "..";
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
6
|
title: "ds-react/ReadMore",
|
|
@@ -24,8 +25,14 @@ export const Default = (props) => {
|
|
|
24
25
|
header="Grunnen til at vi spør om dette og i tillegg ber om vedlegg"
|
|
25
26
|
{...props}
|
|
26
27
|
>
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
<BodyShort>
|
|
29
|
+
Command station, this is ST 321. Code Clearance Blue. We're starting our
|
|
30
|
+
approach. Deactivate the security shield.
|
|
31
|
+
</BodyShort>
|
|
32
|
+
<BodyShort>
|
|
33
|
+
Command station, this is ST 321. Code Clearance Blue. We're starting our
|
|
34
|
+
approach. Deactivate the security shield.
|
|
35
|
+
</BodyShort>
|
|
29
36
|
</ReadMore>
|
|
30
37
|
);
|
|
31
38
|
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.useSearch = void 0;
|
|
7
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const index_1 = require("../../index");
|
|
10
|
-
const index_2 = require("../index");
|
|
11
|
-
const useSearch = (props, prefix) => {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
const { size } = props;
|
|
14
|
-
const fieldset = (0, react_1.useContext)(index_2.FieldsetContext);
|
|
15
|
-
const genId = (0, index_1.useId)();
|
|
16
|
-
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${prefix}-${genId}`;
|
|
17
|
-
const inputDescriptionId = `${prefix}-description-${genId}`;
|
|
18
|
-
const disabled = (fieldset === null || fieldset === void 0 ? void 0 : fieldset.disabled) || props.disabled;
|
|
19
|
-
return {
|
|
20
|
-
inputDescriptionId,
|
|
21
|
-
size: (_b = size !== null && size !== void 0 ? size : fieldset === null || fieldset === void 0 ? void 0 : fieldset.size) !== null && _b !== void 0 ? _b : "medium",
|
|
22
|
-
inputProps: {
|
|
23
|
-
id,
|
|
24
|
-
"aria-describedby": (0, classnames_1.default)(props["aria-describedby"], {
|
|
25
|
-
[inputDescriptionId]: !!(props === null || props === void 0 ? void 0 : props.description),
|
|
26
|
-
}) || undefined,
|
|
27
|
-
disabled,
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
exports.useSearch = useSearch;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FormFieldProps } from "../useFormField";
|
|
2
|
-
export declare const useSearch: (props: FormFieldProps, prefix: string) => {
|
|
3
|
-
inputDescriptionId: string;
|
|
4
|
-
size: "small" | "medium";
|
|
5
|
-
inputProps: {
|
|
6
|
-
id: string;
|
|
7
|
-
"aria-describedby": string | undefined;
|
|
8
|
-
disabled: boolean | undefined;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import cl from "classnames";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { useId } from "../../index";
|
|
4
|
-
import { FieldsetContext } from "../index";
|
|
5
|
-
export const useSearch = (props, prefix) => {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
const { size } = props;
|
|
8
|
-
const fieldset = useContext(FieldsetContext);
|
|
9
|
-
const genId = useId();
|
|
10
|
-
const id = (_a = props.id) !== null && _a !== void 0 ? _a : `${prefix}-${genId}`;
|
|
11
|
-
const inputDescriptionId = `${prefix}-description-${genId}`;
|
|
12
|
-
const disabled = (fieldset === null || fieldset === void 0 ? void 0 : fieldset.disabled) || props.disabled;
|
|
13
|
-
return {
|
|
14
|
-
inputDescriptionId,
|
|
15
|
-
size: (_b = size !== null && size !== void 0 ? size : fieldset === null || fieldset === void 0 ? void 0 : fieldset.size) !== null && _b !== void 0 ? _b : "medium",
|
|
16
|
-
inputProps: {
|
|
17
|
-
id,
|
|
18
|
-
"aria-describedby": cl(props["aria-describedby"], {
|
|
19
|
-
[inputDescriptionId]: !!(props === null || props === void 0 ? void 0 : props.description),
|
|
20
|
-
}) || undefined,
|
|
21
|
-
disabled,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=useSearch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSearch.js","sourceRoot":"","sources":["../../../src/form/search/useSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAE,MAAc,EAAE,EAAE;;IACjE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IAEvB,MAAM,QAAQ,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC;IAEtB,MAAM,EAAE,GAAG,MAAA,KAAK,CAAC,EAAE,mCAAI,GAAG,MAAM,IAAI,KAAK,EAAE,CAAC;IAC5C,MAAM,kBAAkB,GAAG,GAAG,MAAM,gBAAgB,KAAK,EAAE,CAAC;IAE5D,MAAM,QAAQ,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,KAAI,KAAK,CAAC,QAAQ,CAAC;IAEtD,OAAO;QACL,kBAAkB;QAClB,IAAI,EAAE,MAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,QAAQ;QACxC,UAAU,EAAE;YACV,EAAE;YACF,kBAAkB,EAChB,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE;gBAC5B,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,CAAA;aAC3C,CAAC,IAAI,SAAS;YACjB,QAAQ;SACT;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import cl from "classnames";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { useId } from "../../index";
|
|
4
|
-
import { FieldsetContext } from "../index";
|
|
5
|
-
import { FormFieldProps } from "../useFormField";
|
|
6
|
-
|
|
7
|
-
export const useSearch = (props: FormFieldProps, prefix: string) => {
|
|
8
|
-
const { size } = props;
|
|
9
|
-
|
|
10
|
-
const fieldset = useContext(FieldsetContext);
|
|
11
|
-
|
|
12
|
-
const genId = useId();
|
|
13
|
-
|
|
14
|
-
const id = props.id ?? `${prefix}-${genId}`;
|
|
15
|
-
const inputDescriptionId = `${prefix}-description-${genId}`;
|
|
16
|
-
|
|
17
|
-
const disabled = fieldset?.disabled || props.disabled;
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
inputDescriptionId,
|
|
21
|
-
size: size ?? fieldset?.size ?? "medium",
|
|
22
|
-
inputProps: {
|
|
23
|
-
id,
|
|
24
|
-
"aria-describedby":
|
|
25
|
-
cl(props["aria-describedby"], {
|
|
26
|
-
[inputDescriptionId]: !!props?.description,
|
|
27
|
-
}) || undefined,
|
|
28
|
-
disabled,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
};
|