@navikt/ds-react 0.17.17 → 0.17.20
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/form/search/Search.js +11 -17
- package/cjs/form/search/SearchButton.js +1 -1
- package/esm/form/search/Search.d.ts +4 -4
- package/esm/form/search/Search.js +13 -19
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +1 -1
- package/esm/form/search/SearchButton.js.map +1 -1
- package/package.json +13 -13
- package/src/accordion/accordion.stories.tsx +82 -70
- package/src/alert/alert.stories.tsx +85 -95
- package/src/button/button.stories.tsx +142 -130
- package/src/card/stories/card.stories.mdx +1 -1
- package/src/card/stories/card.stories.tsx +1 -1
- package/src/form/checkbox/Checkbox.test.tsx +12 -8
- package/src/form/radio/Radio.test.tsx +7 -4
- package/src/form/search/Search.tsx +22 -24
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/search/search-themes.stories.tsx +52 -0
- package/src/form/search/search.stories.tsx +10 -3
- package/src/page-header/stories/header.stories.mdx +1 -1
- package/src/page-header/stories/header.stories.tsx +1 -1
- package/src/step-indicator/stories/step-indicator.stories.mdx +1 -1
- package/src/step-indicator/stories/step-indicator.stories.tsx +1 -1
|
@@ -48,34 +48,27 @@ const useSearch_1 = require("./useSearch");
|
|
|
48
48
|
exports.SearchContext = react_1.default.createContext(null);
|
|
49
49
|
const Search = (0, react_1.forwardRef)((props, ref) => {
|
|
50
50
|
const { inputProps, size = "medium", inputDescriptionId } = (0, useSearch_1.useSearch)(props, "searchfield");
|
|
51
|
-
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "
|
|
51
|
+
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "onSearch", "variant", "defaultValue", "onChange"]);
|
|
52
52
|
const searchRef = (0, react_1.useRef)(null);
|
|
53
53
|
const mergedRef = (0, react_merge_refs_1.default)([searchRef, ref]);
|
|
54
54
|
const [wrapperRef, setWrapperRef] = (0, react_1.useState)(null);
|
|
55
|
-
const [
|
|
55
|
+
const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
56
56
|
const handleChange = (0, react_1.useCallback)((v) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, [props, value]);
|
|
57
|
+
value === undefined && setInternalValue(v);
|
|
58
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(v);
|
|
59
|
+
}, [onChange, value]);
|
|
61
60
|
const handleClear = (0, react_1.useCallback)((event) => {
|
|
62
61
|
var _a, _b;
|
|
63
62
|
onClear === null || onClear === void 0 ? void 0 : onClear(event);
|
|
64
63
|
handleChange("");
|
|
65
|
-
if (searchRef.current && value === undefined) {
|
|
66
|
-
searchRef.current.value = "";
|
|
67
|
-
}
|
|
68
64
|
searchRef.current && ((_b = (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
69
|
-
}, [handleChange, onClear
|
|
65
|
+
}, [handleChange, onClear]);
|
|
70
66
|
(0, __1.useEventListener)("keydown", (0, react_1.useCallback)((e) => {
|
|
71
67
|
if (e.key === "Escape") {
|
|
72
68
|
e.preventDefault();
|
|
73
69
|
handleClear({ trigger: "Escape", event: e });
|
|
74
70
|
}
|
|
75
71
|
}, [handleClear]), wrapperRef);
|
|
76
|
-
(0, react_1.useEffect)(() => {
|
|
77
|
-
value !== undefined && setControlledValue(value);
|
|
78
|
-
}, [value]);
|
|
79
72
|
return (react_1.default.createElement("div", { ref: setWrapperRef, className: (0, classnames_1.default)(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
80
73
|
"navds-search--disabled": !!inputProps.disabled,
|
|
81
74
|
}) },
|
|
@@ -87,16 +80,17 @@ const Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
87
80
|
}), id: inputDescriptionId, size: size }, description)),
|
|
88
81
|
react_1.default.createElement("div", { className: "navds-search__wrapper" },
|
|
89
82
|
react_1.default.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
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
|
+
(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" },
|
|
92
86
|
react_1.default.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
93
87
|
react_1.default.createElement(ds_icons_1.Close, { "aria-hidden": true })))),
|
|
94
88
|
react_1.default.createElement(exports.SearchContext.Provider, { value: {
|
|
95
89
|
size,
|
|
96
90
|
disabled: inputProps.disabled,
|
|
97
91
|
variant,
|
|
98
|
-
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(
|
|
99
|
-
} }, children ? children : react_1.default.createElement(SearchButton_1.default, null)))));
|
|
92
|
+
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(value !== null && value !== void 0 ? value : internalValue),
|
|
93
|
+
} }, children ? children : variant !== "simple" && react_1.default.createElement(SearchButton_1.default, null)))));
|
|
100
94
|
});
|
|
101
95
|
Search.Button = SearchButton_1.default;
|
|
102
96
|
exports.default = Search;
|
|
@@ -51,7 +51,7 @@ const SearchButton = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
const { size, variant, onSearch } = context;
|
|
54
|
-
return (react_1.default.createElement(__1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant, className: (0, classnames_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
54
|
+
return (react_1.default.createElement(__1.Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: (0, classnames_1.default)("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
55
55
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch();
|
|
56
56
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
57
57
|
} }),
|
|
@@ -44,9 +44,9 @@ export interface SearchProps extends Omit<FormFieldProps, "error" | "errorId">,
|
|
|
44
44
|
clearButton?: boolean;
|
|
45
45
|
/**
|
|
46
46
|
* Changes button-variant
|
|
47
|
-
* @default "
|
|
47
|
+
* @default "primary"
|
|
48
48
|
*/
|
|
49
|
-
variant?: "
|
|
49
|
+
variant?: "primary" | "secondary" | "simple";
|
|
50
50
|
}
|
|
51
51
|
interface SearchComponent extends React.ForwardRefExoticComponent<SearchProps & React.RefAttributes<HTMLDivElement>> {
|
|
52
52
|
Button: SearchButtonType;
|
|
@@ -54,8 +54,8 @@ interface SearchComponent extends React.ForwardRefExoticComponent<SearchProps &
|
|
|
54
54
|
export interface SearchContextProps {
|
|
55
55
|
disabled?: boolean;
|
|
56
56
|
size: "medium" | "small";
|
|
57
|
-
variant
|
|
58
|
-
onSearch
|
|
57
|
+
variant: "primary" | "secondary" | "simple";
|
|
58
|
+
onSearch: () => void;
|
|
59
59
|
}
|
|
60
60
|
export declare const SearchContext: React.Context<SearchContextProps | null>;
|
|
61
61
|
declare const Search: SearchComponent;
|
|
@@ -9,9 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { Close } from "@navikt/ds-icons";
|
|
12
|
+
import { Close, Search as SearchIcon } from "@navikt/ds-icons";
|
|
13
13
|
import cl from "classnames";
|
|
14
|
-
import React, { forwardRef, useCallback,
|
|
14
|
+
import React, { forwardRef, useCallback, useRef, useState, } from "react";
|
|
15
15
|
import mergeRefs from "react-merge-refs";
|
|
16
16
|
import { BodyShort, Label, omit, useEventListener } from "../..";
|
|
17
17
|
import SearchButton from "./SearchButton";
|
|
@@ -19,34 +19,27 @@ import { useSearch } from "./useSearch";
|
|
|
19
19
|
export const SearchContext = React.createContext(null);
|
|
20
20
|
const Search = forwardRef((props, ref) => {
|
|
21
21
|
const { inputProps, size = "medium", inputDescriptionId } = useSearch(props, "searchfield");
|
|
22
|
-
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "
|
|
22
|
+
const { className, hideLabel = true, label, description, value, clearButtonLabel, onClear, clearButton = true, children, onSearch, variant = "primary", defaultValue, onChange } = props, rest = __rest(props, ["className", "hideLabel", "label", "description", "value", "clearButtonLabel", "onClear", "clearButton", "children", "onSearch", "variant", "defaultValue", "onChange"]);
|
|
23
23
|
const searchRef = useRef(null);
|
|
24
24
|
const mergedRef = mergeRefs([searchRef, ref]);
|
|
25
25
|
const [wrapperRef, setWrapperRef] = useState(null);
|
|
26
|
-
const [
|
|
26
|
+
const [internalValue, setInternalValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : "");
|
|
27
27
|
const handleChange = useCallback((v) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, [props, value]);
|
|
28
|
+
value === undefined && setInternalValue(v);
|
|
29
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(v);
|
|
30
|
+
}, [onChange, value]);
|
|
32
31
|
const handleClear = useCallback((event) => {
|
|
33
32
|
var _a, _b;
|
|
34
33
|
onClear === null || onClear === void 0 ? void 0 : onClear(event);
|
|
35
34
|
handleChange("");
|
|
36
|
-
if (searchRef.current && value === undefined) {
|
|
37
|
-
searchRef.current.value = "";
|
|
38
|
-
}
|
|
39
35
|
searchRef.current && ((_b = (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
40
|
-
}, [handleChange, onClear
|
|
36
|
+
}, [handleChange, onClear]);
|
|
41
37
|
useEventListener("keydown", useCallback((e) => {
|
|
42
38
|
if (e.key === "Escape") {
|
|
43
39
|
e.preventDefault();
|
|
44
40
|
handleClear({ trigger: "Escape", event: e });
|
|
45
41
|
}
|
|
46
42
|
}, [handleClear]), wrapperRef);
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
value !== undefined && setControlledValue(value);
|
|
49
|
-
}, [value]);
|
|
50
43
|
return (React.createElement("div", { ref: setWrapperRef, className: cl(className, "navds-form-field", `navds-form-field--${size}`, "navds-search", {
|
|
51
44
|
"navds-search--disabled": !!inputProps.disabled,
|
|
52
45
|
}) },
|
|
@@ -58,16 +51,17 @@ const Search = forwardRef((props, ref) => {
|
|
|
58
51
|
}), id: inputDescriptionId, size: size }, description)),
|
|
59
52
|
React.createElement("div", { className: "navds-search__wrapper" },
|
|
60
53
|
React.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
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
|
+
(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" },
|
|
63
57
|
React.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
64
58
|
React.createElement(Close, { "aria-hidden": true })))),
|
|
65
59
|
React.createElement(SearchContext.Provider, { value: {
|
|
66
60
|
size,
|
|
67
61
|
disabled: inputProps.disabled,
|
|
68
62
|
variant,
|
|
69
|
-
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(
|
|
70
|
-
} }, children ? children : React.createElement(SearchButton, null)))));
|
|
63
|
+
onSearch: () => onSearch === null || onSearch === void 0 ? void 0 : onSearch(value !== null && value !== void 0 ? value : internalValue),
|
|
64
|
+
} }, children ? children : variant !== "simple" && React.createElement(SearchButton, null)))));
|
|
71
65
|
});
|
|
72
66
|
Search.Button = SearchButton;
|
|
73
67
|
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,kBAAkB,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,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,YAAkC,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM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AAI,oBAAC,YAAY,OAAG,CACxC,CACrB,CACF,CACP,CAAC;AACJ,CAAC,CAAoB,CAAC;AAEtB,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC;AAE7B,eAAe,MAAM,CAAC"}
|
|
@@ -23,7 +23,7 @@ const SearchButton = forwardRef((_a, ref) => {
|
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
const { size, variant, onSearch } = context;
|
|
26
|
-
return (React.createElement(Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant, className: cl("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
26
|
+
return (React.createElement(Button, Object.assign({ type: "submit" }, rest, { ref: ref, size: size, variant: variant === "secondary" ? "secondary" : "primary", className: cl("navds-search__button-search", className), disabled: (_b = context === null || context === void 0 ? void 0 : context.disabled) !== null && _b !== void 0 ? _b : disabled, onClick: (e) => {
|
|
27
27
|
onSearch === null || onSearch === void 0 ? void 0 : onSearch();
|
|
28
28
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
29
29
|
} }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchButton.js","sourceRoot":"","sources":["../../../src/form/search/SearchButton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,MAAM,EAAe,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAczC,MAAM,YAAY,GAAqB,UAAU,CAC/C,CAAC,EAAmD,EAAE,GAAG,EAAE,EAAE;;QAA5D,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,OA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AI,EAAC,QAAQ,IACT,IAAI,IACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC1D,SAAS,EAAE,EAAE,CAAC,6BAA6B,EAAE,SAAS,CAAC,EACvD,QAAQ,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,mCAAI,QAAQ,EACvC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACb,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI,CAAC;YACb,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAG,CAAC,CAAC,CAAC;QACf,CAAC;QAED,oBAAC,MAAM,0BAAe;QACrB,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,8BAAM,SAAS,EAAC,eAAe,eAAW,CAC1D,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NAV designsystem react components",
|
|
6
6
|
"author": "NAV Designsystem team",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"/src"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"create-package-json-pointers-to-esm": "node ../../../
|
|
30
|
+
"create-package-json-pointers-to-esm": "node ../../../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
33
|
"watch": "tsc --watch -p tsconfig.esm.json",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@floating-ui/react-dom": "0.6.0",
|
|
38
38
|
"@material-ui/core": "^4.12.3",
|
|
39
|
-
"@navikt/ds-icons": "^0.8.
|
|
39
|
+
"@navikt/ds-icons": "^0.8.8",
|
|
40
40
|
"@popperjs/core": "^2.10.1",
|
|
41
41
|
"@radix-ui/react-tabs": "0.1.5",
|
|
42
42
|
"@radix-ui/react-toggle-group": "0.1.5",
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
"uuid": "^8.3.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@testing-library/jest-dom": "^5.
|
|
52
|
-
"@testing-library/react": "^
|
|
53
|
-
"@testing-library/user-event": "^
|
|
54
|
-
"@types/faker": "
|
|
51
|
+
"@testing-library/jest-dom": "^5.16.0",
|
|
52
|
+
"@testing-library/react": "^13.0.0",
|
|
53
|
+
"@testing-library/user-event": "^14.0.0",
|
|
54
|
+
"@types/faker": "5.5.8",
|
|
55
55
|
"@types/jest": "^27.0.1",
|
|
56
56
|
"@types/react-collapse": "^5.0.1",
|
|
57
57
|
"@types/react-modal": "^3.13.1",
|
|
58
58
|
"@types/styled-components": "^5.1.14",
|
|
59
59
|
"copyfiles": "^2.4.1",
|
|
60
|
-
"faker": "
|
|
61
|
-
"jest": "^27.
|
|
62
|
-
"react-router-dom": "^6.
|
|
60
|
+
"faker": "5.5.3",
|
|
61
|
+
"jest": "^27.5.0",
|
|
62
|
+
"react-router-dom": "^6.3.0",
|
|
63
63
|
"rimraf": "3.0.2",
|
|
64
64
|
"styled-components": "^5.3.1",
|
|
65
65
|
"swr": "^1.1.2",
|
|
66
|
-
"ts-jest": "^27.0
|
|
66
|
+
"ts-jest": "^27.1.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"@types/react": "^17.0.30",
|
|
70
|
-
"react": "^17.0.0"
|
|
70
|
+
"react": "^17.0.0 | ^18.0.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "3daa36efa72838b104d80bfaf259723773d11655"
|
|
73
73
|
}
|
|
@@ -5,7 +5,7 @@ import AccordionItem from "./AccordionItem";
|
|
|
5
5
|
import { Accordion } from ".";
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
|
-
title: "ds-react/
|
|
8
|
+
title: "ds-react/Accordion",
|
|
9
9
|
component: Accordion,
|
|
10
10
|
subcomponents: {
|
|
11
11
|
AccordionItem,
|
|
@@ -14,77 +14,89 @@ export default {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const Content = () => (
|
|
18
|
+
<Accordion.Content>
|
|
19
|
+
Magna aliquip aliquip fugiat nostrud nostrud velit pariatur veniam officia
|
|
20
|
+
laboris voluptate officia pariatur.Lorem est ex anim velit occaecat nisi qui
|
|
21
|
+
nostrud sit consectetur consectetur officia nostrud ullamco. Est ex duis
|
|
22
|
+
proident nostrud elit qui laborum anim minim eu eiusmod. Veniam in nostrud
|
|
23
|
+
sunt tempor velit incididunt sint ex dolor qui velit id eu. Deserunt magna
|
|
24
|
+
sunt velit in. Est exercitation id cillum qui do. Minim adipisicing nostrud
|
|
25
|
+
commodo proident occaecat aliquip nulla anim proident reprehenderit. Magna
|
|
26
|
+
ipsum officia veniam cupidatat duis veniam dolore reprehenderit mollit
|
|
27
|
+
velit.Ut consequat commodo minim occaecat id pariatur. Nisi enim tempor
|
|
28
|
+
laborum commodo. Tempor sit quis nostrud eu cupidatat sunt commodo
|
|
29
|
+
reprehenderit irure deserunt eiusmod ipsum. Exercitation quis commodo cillum
|
|
30
|
+
eiusmod eiusmod. Do laborum qui proident commodo adipisicing eiusmod id.
|
|
31
|
+
</Accordion.Content>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export const Default = (props) => {
|
|
35
|
+
const [open, setOpen] = useState(false);
|
|
36
|
+
|
|
37
|
+
const Item = () =>
|
|
38
|
+
props.controlled ? (
|
|
39
|
+
<Accordion.Item
|
|
40
|
+
open={open}
|
|
41
|
+
renderContentWhenClosed={props.renderContentWhenClosed}
|
|
42
|
+
>
|
|
43
|
+
<Accordion.Header onClick={() => setOpen(!open)}>
|
|
44
|
+
Accordion header text
|
|
45
|
+
</Accordion.Header>
|
|
46
|
+
<Content />
|
|
47
|
+
</Accordion.Item>
|
|
48
|
+
) : (
|
|
49
|
+
<Accordion.Item renderContentWhenClosed={props.renderContentWhenClosed}>
|
|
50
|
+
<Accordion.Header>Accordion header text</Accordion.Header>
|
|
51
|
+
<Content />
|
|
52
|
+
</Accordion.Item>
|
|
53
|
+
);
|
|
54
|
+
return (
|
|
55
|
+
<Accordion>
|
|
56
|
+
{[...Array(props.nItems ? props.nItems : 2)].map((_, y) => (
|
|
57
|
+
<Item key={y} />
|
|
58
|
+
))}
|
|
59
|
+
</Accordion>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
Default.args = {
|
|
64
|
+
controlled: false,
|
|
65
|
+
renderContentWhenClosed: false,
|
|
66
|
+
nItems: 2,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Controlled = () => {
|
|
18
70
|
const [open, setOpen] = useState(false);
|
|
71
|
+
const [open2, setOpen2] = useState(false);
|
|
19
72
|
|
|
20
73
|
return (
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
sint ex dolor qui velit id eu. Deserunt magna sunt velit in. Est
|
|
36
|
-
exercitation id cillum qui do. Minim adipisicing nostrud commodo
|
|
37
|
-
proident occaecat aliquip nulla anim proident reprehenderit. Magna
|
|
38
|
-
ipsum officia veniam cupidatat duis veniam dolore reprehenderit
|
|
39
|
-
mollit velit.Ut consequat commodo minim occaecat id pariatur. Nisi
|
|
40
|
-
enim tempor laborum commodo. Tempor sit quis nostrud eu cupidatat
|
|
41
|
-
sunt commodo reprehenderit irure deserunt eiusmod ipsum.
|
|
42
|
-
Exercitation quis commodo cillum eiusmod eiusmod. Do laborum qui
|
|
43
|
-
proident commodo adipisicing eiusmod id.
|
|
44
|
-
</Accordion.Content>
|
|
45
|
-
</Accordion.Item>
|
|
46
|
-
</Accordion>
|
|
47
|
-
<h2>Un-controlled</h2>
|
|
48
|
-
<Accordion>
|
|
49
|
-
<Accordion.Item>
|
|
50
|
-
<Accordion.Header>Accordion header text</Accordion.Header>
|
|
51
|
-
<Accordion.Content>
|
|
52
|
-
Magna aliquip aliquip fugiat nostrud nostrud velit pariatur veniam
|
|
53
|
-
officia laboris voluptate officia pariatur.Lorem est ex anim velit
|
|
54
|
-
occaecat nisi qui nostrud sit consectetur consectetur officia
|
|
55
|
-
nostrud ullamco. Est ex duis proident nostrud elit qui laborum anim
|
|
56
|
-
minim eu eiusmod. Veniam in nostrud sunt tempor velit incididunt
|
|
57
|
-
sint ex dolor qui velit id eu. Deserunt magna sunt velit in. Est
|
|
58
|
-
exercitation id cillum qui do. Minim adipisicing nostrud commodo
|
|
59
|
-
proident occaecat aliquip nulla anim proident reprehenderit. Magna
|
|
60
|
-
ipsum officia veniam cupidatat duis veniam dolore reprehenderit
|
|
61
|
-
mollit velit.Ut consequat commodo minim occaecat id pariatur. Nisi
|
|
62
|
-
enim tempor laborum commodo. Tempor sit quis nostrud eu cupidatat
|
|
63
|
-
sunt commodo reprehenderit irure deserunt eiusmod ipsum.
|
|
64
|
-
Exercitation quis commodo cillum eiusmod eiusmod. Do laborum qui
|
|
65
|
-
proident commodo adipisicing eiusmod id.
|
|
66
|
-
</Accordion.Content>
|
|
67
|
-
</Accordion.Item>
|
|
68
|
-
<Accordion.Item>
|
|
69
|
-
<Accordion.Header>Accordion header text</Accordion.Header>
|
|
70
|
-
<Accordion.Content>
|
|
71
|
-
Magna aliquip aliquip fugiat nostrud nostrud velit pariatur veniam
|
|
72
|
-
officia laboris voluptate officia pariatur.Lorem est ex anim velit
|
|
73
|
-
occaecat nisi qui nostrud sit consectetur consectetur officia
|
|
74
|
-
nostrud ullamco. Est ex duis proident nostrud elit qui laborum anim
|
|
75
|
-
minim eu eiusmod. Veniam in nostrud sunt tempor velit incididunt
|
|
76
|
-
sint ex dolor qui velit id eu. Deserunt magna sunt velit in. Est
|
|
77
|
-
exercitation id cillum qui do. Minim adipisicing nostrud commodo
|
|
78
|
-
proident occaecat aliquip nulla anim proident reprehenderit. Magna
|
|
79
|
-
ipsum officia veniam cupidatat duis veniam dolore reprehenderit
|
|
80
|
-
mollit velit.Ut consequat commodo minim occaecat id pariatur. Nisi
|
|
81
|
-
enim tempor laborum commodo. Tempor sit quis nostrud eu cupidatat
|
|
82
|
-
sunt commodo reprehenderit irure deserunt eiusmod ipsum.
|
|
83
|
-
Exercitation quis commodo cillum eiusmod eiusmod. Do laborum qui
|
|
84
|
-
proident commodo adipisicing eiusmod id.
|
|
85
|
-
</Accordion.Content>
|
|
86
|
-
</Accordion.Item>
|
|
87
|
-
</Accordion>
|
|
88
|
-
</>
|
|
74
|
+
<Accordion>
|
|
75
|
+
<Accordion.Item open={open}>
|
|
76
|
+
<Accordion.Header onClick={() => setOpen(!open)}>
|
|
77
|
+
Accordion header text
|
|
78
|
+
</Accordion.Header>
|
|
79
|
+
<Content />
|
|
80
|
+
</Accordion.Item>
|
|
81
|
+
<Accordion.Item open={open2}>
|
|
82
|
+
<Accordion.Header onClick={() => setOpen2(!open2)}>
|
|
83
|
+
Accordion header text
|
|
84
|
+
</Accordion.Header>
|
|
85
|
+
<Content />
|
|
86
|
+
</Accordion.Item>
|
|
87
|
+
</Accordion>
|
|
89
88
|
);
|
|
90
89
|
};
|
|
90
|
+
|
|
91
|
+
export const Uncontrolled = () => (
|
|
92
|
+
<Accordion>
|
|
93
|
+
<Accordion.Item>
|
|
94
|
+
<Accordion.Header>Accordion header text</Accordion.Header>
|
|
95
|
+
<Content />
|
|
96
|
+
</Accordion.Item>
|
|
97
|
+
<Accordion.Item>
|
|
98
|
+
<Accordion.Header>Accordion header text</Accordion.Header>
|
|
99
|
+
<Content />
|
|
100
|
+
</Accordion.Item>
|
|
101
|
+
</Accordion>
|
|
102
|
+
);
|