@navikt/ds-react 0.14.10-next.0 → 0.14.13

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 (72) hide show
  1. package/cjs/button/Button.js +22 -3
  2. package/cjs/form/Fieldset/Fieldset.js +3 -3
  3. package/cjs/form/Select.js +2 -2
  4. package/cjs/form/Switch.js +1 -1
  5. package/cjs/form/TextField.js +5 -3
  6. package/cjs/form/Textarea.js +3 -3
  7. package/cjs/form/checkbox/Checkbox.js +1 -1
  8. package/cjs/form/search-field/SearchField.js +21 -42
  9. package/cjs/form/search-field/SearchFieldButton.js +50 -0
  10. package/cjs/form/search-field/SearchFieldClearButton.js +50 -0
  11. package/cjs/form/search-field/SearchFieldInput.js +49 -0
  12. package/cjs/modal/Modal.js +4 -4
  13. package/cjs/util/index.js +1 -15
  14. package/esm/button/Button.d.ts +5 -0
  15. package/esm/button/Button.js +24 -5
  16. package/esm/button/Button.js.map +1 -1
  17. package/esm/form/Fieldset/Fieldset.js +3 -3
  18. package/esm/form/Fieldset/Fieldset.js.map +1 -1
  19. package/esm/form/Select.js +2 -2
  20. package/esm/form/Select.js.map +1 -1
  21. package/esm/form/Switch.js +1 -1
  22. package/esm/form/Switch.js.map +1 -1
  23. package/esm/form/TextField.js +5 -3
  24. package/esm/form/TextField.js.map +1 -1
  25. package/esm/form/Textarea.js +3 -3
  26. package/esm/form/Textarea.js.map +1 -1
  27. package/esm/form/checkbox/Checkbox.js +1 -1
  28. package/esm/form/checkbox/Checkbox.js.map +1 -1
  29. package/esm/form/search-field/SearchField.d.ts +25 -25
  30. package/esm/form/search-field/SearchField.js +22 -44
  31. package/esm/form/search-field/SearchField.js.map +1 -1
  32. package/esm/form/search-field/SearchFieldButton.d.ts +17 -0
  33. package/esm/form/search-field/SearchFieldButton.js +27 -0
  34. package/esm/form/search-field/SearchFieldButton.js.map +1 -0
  35. package/esm/form/search-field/SearchFieldClearButton.d.ts +17 -0
  36. package/esm/form/search-field/SearchFieldClearButton.js +27 -0
  37. package/esm/form/search-field/SearchFieldClearButton.js.map +1 -0
  38. package/esm/form/search-field/SearchFieldInput.d.ts +6 -0
  39. package/esm/form/search-field/SearchFieldInput.js +26 -0
  40. package/esm/form/search-field/SearchFieldInput.js.map +1 -0
  41. package/esm/modal/Modal.d.ts +5 -0
  42. package/esm/modal/Modal.js +4 -4
  43. package/esm/modal/Modal.js.map +1 -1
  44. package/esm/util/index.d.ts +0 -5
  45. package/esm/util/index.js +0 -13
  46. package/esm/util/index.js.map +1 -1
  47. package/package.json +3 -3
  48. package/src/button/Button.tsx +55 -18
  49. package/src/button/stories/button.stories.mdx +17 -11
  50. package/src/button/stories/button.stories.tsx +41 -3
  51. package/src/form/Fieldset/Fieldset.tsx +3 -3
  52. package/src/form/Select.tsx +2 -2
  53. package/src/form/Switch.tsx +1 -1
  54. package/src/form/TextField.tsx +5 -3
  55. package/src/form/Textarea.tsx +3 -3
  56. package/src/form/checkbox/Checkbox.tsx +1 -1
  57. package/src/form/search-field/SearchField.tsx +69 -124
  58. package/src/form/search-field/SearchFieldButton.tsx +47 -0
  59. package/src/form/search-field/SearchFieldClearButton.tsx +49 -0
  60. package/src/form/search-field/SearchFieldInput.tsx +42 -0
  61. package/src/form/search-field/stories/search-field-example.tsx +25 -0
  62. package/src/form/search-field/stories/search-field.stories.mdx +89 -158
  63. package/src/form/search-field/stories/search-field.stories.tsx +154 -62
  64. package/src/loader/stories/loader.stories.mdx +0 -22
  65. package/src/modal/Modal.tsx +19 -12
  66. package/src/modal/stories/modal.stories.tsx +16 -0
  67. package/src/util/index.ts +0 -33
  68. package/cjs/form/search-field/useSearchField.js +0 -31
  69. package/esm/form/search-field/useSearchField.d.ts +0 -10
  70. package/esm/form/search-field/useSearchField.js +0 -25
  71. package/esm/form/search-field/useSearchField.js.map +0 -1
  72. package/src/form/search-field/useSearchField.ts +0 -31
package/src/util/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { useEffect } from "react";
2
-
3
1
  export * from "./OverridableComponent";
4
2
  export * from "./useId";
5
3
 
@@ -13,34 +11,3 @@ export const omit = (obj: object, props: string[]) =>
13
11
  }),
14
12
  {}
15
13
  );
16
-
17
- export interface ListenerT {
18
- addEventListener(
19
- name: string,
20
- handler: (event?: any) => void,
21
- ...args: any[]
22
- );
23
-
24
- removeEventListener(
25
- name: string,
26
- handler: (event?: any) => void,
27
- ...args: any[]
28
- );
29
- }
30
-
31
- /* https://github.com/streamich/react-use/blob/master/src/useEvent.ts */
32
- export const useEventListener = <T extends ListenerT>(
33
- name: Parameters<ListenerT["addEventListener"]>[0],
34
- handler: Parameters<ListenerT["addEventListener"]>[1],
35
- target: null | T | Window = window
36
- ): void => {
37
- useEffect(() => {
38
- if (!target) {
39
- return;
40
- }
41
- target?.addEventListener(name, handler);
42
- return () => {
43
- target?.addEventListener(name, handler);
44
- };
45
- }, [name, handler, target]);
46
- };
@@ -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.useSearchField = 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 useSearchField = (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.useSearchField = useSearchField;
@@ -1,10 +0,0 @@
1
- import { FormFieldProps } from "../useFormField";
2
- export declare const useSearchField: (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 useSearchField = (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=useSearchField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSearchField.js","sourceRoot":"","sources":["../../../src/form/search-field/useSearchField.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,cAAc,GAAG,CAAC,KAAqB,EAAE,MAAc,EAAE,EAAE;;IACtE,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 useSearchField = (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
- };