@navikt/ds-react 0.14.6 → 0.14.10-next.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.
Files changed (52) hide show
  1. package/cjs/form/Switch.js +1 -1
  2. package/cjs/form/search-field/SearchField.js +44 -23
  3. package/cjs/form/search-field/useSearchField.js +31 -0
  4. package/cjs/help-text/HelpText.js +2 -2
  5. package/cjs/link-panel/LinkPanel.js +1 -1
  6. package/cjs/popover/Popover.js +2 -1
  7. package/cjs/util/index.js +15 -1
  8. package/esm/form/Switch.js +1 -1
  9. package/esm/form/Switch.js.map +1 -1
  10. package/esm/form/search-field/SearchField.d.ts +25 -25
  11. package/esm/form/search-field/SearchField.js +46 -24
  12. package/esm/form/search-field/SearchField.js.map +1 -1
  13. package/esm/form/search-field/useSearchField.d.ts +10 -0
  14. package/esm/form/search-field/useSearchField.js +25 -0
  15. package/esm/form/search-field/useSearchField.js.map +1 -0
  16. package/esm/help-text/HelpText.d.ts +2 -7
  17. package/esm/help-text/HelpText.js +2 -2
  18. package/esm/help-text/HelpText.js.map +1 -1
  19. package/esm/link-panel/LinkPanel.js +1 -1
  20. package/esm/link-panel/LinkPanel.js.map +1 -1
  21. package/esm/popover/Popover.d.ts +6 -0
  22. package/esm/popover/Popover.js +2 -1
  23. package/esm/popover/Popover.js.map +1 -1
  24. package/esm/util/index.d.ts +5 -0
  25. package/esm/util/index.js +13 -0
  26. package/esm/util/index.js.map +1 -1
  27. package/package.json +2 -2
  28. package/src/form/Switch.tsx +2 -2
  29. package/src/form/search-field/SearchField.tsx +126 -71
  30. package/src/form/search-field/stories/search-field.stories.mdx +158 -89
  31. package/src/form/search-field/stories/search-field.stories.tsx +62 -154
  32. package/src/form/search-field/useSearchField.ts +31 -0
  33. package/src/help-text/HelpText.tsx +12 -9
  34. package/src/link-panel/LinkPanel.tsx +1 -4
  35. package/src/popover/Popover.tsx +8 -0
  36. package/src/util/index.ts +33 -0
  37. package/cjs/form/search-field/SearchFieldButton.js +0 -50
  38. package/cjs/form/search-field/SearchFieldClearButton.js +0 -50
  39. package/cjs/form/search-field/SearchFieldInput.js +0 -49
  40. package/esm/form/search-field/SearchFieldButton.d.ts +0 -17
  41. package/esm/form/search-field/SearchFieldButton.js +0 -27
  42. package/esm/form/search-field/SearchFieldButton.js.map +0 -1
  43. package/esm/form/search-field/SearchFieldClearButton.d.ts +0 -17
  44. package/esm/form/search-field/SearchFieldClearButton.js +0 -27
  45. package/esm/form/search-field/SearchFieldClearButton.js.map +0 -1
  46. package/esm/form/search-field/SearchFieldInput.d.ts +0 -6
  47. package/esm/form/search-field/SearchFieldInput.js +0 -26
  48. package/esm/form/search-field/SearchFieldInput.js.map +0 -1
  49. package/src/form/search-field/SearchFieldButton.tsx +0 -47
  50. package/src/form/search-field/SearchFieldClearButton.tsx +0 -49
  51. package/src/form/search-field/SearchFieldInput.tsx +0 -42
  52. package/src/form/search-field/stories/search-field-example.tsx +0 -25
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchFieldClearButton.js","sourceRoot":"","sources":["../../../src/form/search-field/SearchFieldClearButton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,MAAM,EAAe,MAAM,OAAO,CAAC;AAmB5C,MAAM,sBAAsB,GAA+B,UAAU,CACnE,CAAC,EAAuD,EAAE,GAAG,EAAE,EAAE;QAAhE,EAAE,SAAS,EAAE,OAAO,GAAG,WAAW,EAAE,QAAQ,OAAW,EAAN,IAAI,cAArD,oCAAuD,CAAF;IACpD,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAEnD,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,IAAI,CACV,6DAA6D,CAC9D,CAAC;QACF,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEzC,OAAO,CACL,oBAAC,MAAM,oBACD,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,kCAAkC,CAAC,EAC5D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ,IAC1C,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -1,6 +0,0 @@
1
- import React, { InputHTMLAttributes } from "react";
2
- export interface SearchFieldInputProps extends InputHTMLAttributes<HTMLInputElement> {
3
- }
4
- export declare type SearchFieldInputType = React.ForwardRefExoticComponent<SearchFieldInputProps & React.RefAttributes<HTMLInputElement>>;
5
- declare const SearchFieldInput: SearchFieldInputType;
6
- export default SearchFieldInput;
@@ -1,26 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React, { forwardRef, useContext } from "react";
13
- import cl from "classnames";
14
- import { SearchFieldContext } from "./SearchField";
15
- const SearchFieldInput = forwardRef((_a, ref) => {
16
- var { className } = _a, rest = __rest(_a, ["className"]);
17
- const searchField = useContext(SearchFieldContext);
18
- if (searchField === null) {
19
- console.warn("SearchFieldInput has to be wrapped in <SearchField />");
20
- return null;
21
- }
22
- const { size, inputProps } = searchField;
23
- return (React.createElement("input", Object.assign({}, rest, inputProps, { type: "search", role: "searchbox", ref: ref, className: cl(className, "navds-search-field__input", "navds-text-field__input", "navds-body-short", `navds-body-${size !== null && size !== void 0 ? size : "medium"}`) })));
24
- });
25
- export default SearchFieldInput;
26
- //# sourceMappingURL=SearchFieldInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SearchFieldInput.js","sourceRoot":"","sources":["../../../src/form/search-field/SearchFieldInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAuB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AASnD,MAAM,gBAAgB,GAAyB,UAAU,CACvD,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IACnB,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAEnD,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAEzC,OAAO,CACL,+CACM,IAAI,EACJ,UAAU,IACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,WAAW,EAChB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,SAAS,EACT,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,QAAQ,EAAE,CACjC,IACD,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,47 +0,0 @@
1
- import React, { forwardRef, useContext } from "react";
2
- import cl from "classnames";
3
- import { SearchFieldContext } from "./SearchField";
4
- import { Button, ButtonProps } from "../..";
5
-
6
- export interface SearchFieldButtonProps extends Omit<ButtonProps, "size"> {
7
- /**
8
- * Button text
9
- * @example <Search /> <span>Søk</span>
10
- */
11
- children: React.ReactNode;
12
- /**
13
- * Changes design and interactions
14
- * @default "primary"
15
- */
16
- variant?: "primary" | "secondary";
17
- }
18
-
19
- export type SearchFieldButtonType = React.ForwardRefExoticComponent<
20
- SearchFieldButtonProps & React.RefAttributes<HTMLButtonElement>
21
- >;
22
-
23
- const SearchFieldButton: SearchFieldButtonType = forwardRef(
24
- ({ className, variant = "primary", disabled, ...rest }, ref) => {
25
- const searchField = useContext(SearchFieldContext);
26
-
27
- if (searchField === null) {
28
- console.warn("SearchFieldButton has to be wrapped in <SearchField />");
29
- return null;
30
- }
31
-
32
- const { size, inputProps } = searchField;
33
-
34
- return (
35
- <Button
36
- ref={ref}
37
- className={cl(className, "navds-search-field__button")}
38
- {...rest}
39
- size={size}
40
- variant={variant}
41
- disabled={disabled ?? inputProps?.disabled}
42
- />
43
- );
44
- }
45
- );
46
-
47
- export default SearchFieldButton;
@@ -1,49 +0,0 @@
1
- import React, { forwardRef, useContext } from "react";
2
- import cl from "classnames";
3
- import { SearchFieldContext } from "./SearchField";
4
- import { Button, ButtonProps } from "../..";
5
-
6
- export interface SearchFieldClearButtonProps extends Omit<ButtonProps, "size"> {
7
- /**
8
- * Button text
9
- * @example <Close /> <span>Søk</span>
10
- */
11
- children: React.ReactNode;
12
- /**
13
- * Changes design and interactions
14
- * @default "secondary"
15
- */
16
- variant?: "primary" | "secondary";
17
- }
18
-
19
- export type SearchFieldClearButtonType = React.ForwardRefExoticComponent<
20
- SearchFieldClearButtonProps & React.RefAttributes<HTMLButtonElement>
21
- >;
22
-
23
- const SearchFieldClearButton: SearchFieldClearButtonType = forwardRef(
24
- ({ className, variant = "secondary", disabled, ...rest }, ref) => {
25
- const searchField = useContext(SearchFieldContext);
26
-
27
- if (searchField === null) {
28
- console.warn(
29
- "SearchFieldClearButton has to be wrapped in <SearchField />"
30
- );
31
- return null;
32
- }
33
-
34
- const { size, inputProps } = searchField;
35
-
36
- return (
37
- <Button
38
- {...rest}
39
- ref={ref}
40
- className={cl(className, "navds-search-field__clear-button")}
41
- size={size}
42
- variant={variant}
43
- disabled={disabled ?? inputProps?.disabled}
44
- />
45
- );
46
- }
47
- );
48
-
49
- export default SearchFieldClearButton;
@@ -1,42 +0,0 @@
1
- import React, { forwardRef, InputHTMLAttributes, useContext } from "react";
2
- import cl from "classnames";
3
- import { SearchFieldContext } from "./SearchField";
4
-
5
- export interface SearchFieldInputProps
6
- extends InputHTMLAttributes<HTMLInputElement> {}
7
-
8
- export type SearchFieldInputType = React.ForwardRefExoticComponent<
9
- SearchFieldInputProps & React.RefAttributes<HTMLInputElement>
10
- >;
11
-
12
- const SearchFieldInput: SearchFieldInputType = forwardRef(
13
- ({ className, ...rest }, ref) => {
14
- const searchField = useContext(SearchFieldContext);
15
-
16
- if (searchField === null) {
17
- console.warn("SearchFieldInput has to be wrapped in <SearchField />");
18
- return null;
19
- }
20
-
21
- const { size, inputProps } = searchField;
22
-
23
- return (
24
- <input
25
- {...rest}
26
- {...inputProps}
27
- type="search"
28
- role="searchbox"
29
- ref={ref}
30
- className={cl(
31
- className,
32
- "navds-search-field__input",
33
- "navds-text-field__input",
34
- "navds-body-short",
35
- `navds-body-${size ?? "medium"}`
36
- )}
37
- />
38
- );
39
- }
40
- );
41
-
42
- export default SearchFieldInput;
@@ -1,25 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Close, Search } from "@navikt/ds-icons";
3
- import { SearchField } from "../index";
4
-
5
- export const Example = ({ size = "medium" }: { size: "medium" | "small" }) => {
6
- const [value, setValue] = useState("");
7
-
8
- return (
9
- <SearchField size={size} label="Skriv i søkefeltet for å vise clearbutton">
10
- <SearchField.Input
11
- value={value}
12
- onChange={(e) => setValue(e.target.value)}
13
- />
14
- {!!value && (
15
- <SearchField.Clear onClick={() => setValue("")}>
16
- <Close />
17
- Tøm
18
- </SearchField.Clear>
19
- )}
20
- <SearchField.Button>
21
- <Search /> Søk
22
- </SearchField.Button>
23
- </SearchField>
24
- );
25
- };