@digdir/designsystemet-react 0.100.52 → 0.101.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 (69) hide show
  1. package/dist/cjs/components/Badge/Badge.js +1 -1
  2. package/dist/cjs/components/Button/Button.js +1 -1
  3. package/dist/cjs/components/Card/Card.js +1 -1
  4. package/dist/cjs/components/Details/Details.js +1 -1
  5. package/dist/cjs/components/Dialog/Dialog.js +17 -9
  6. package/dist/cjs/components/Dialog/DialogTrigger.js +7 -1
  7. package/dist/cjs/components/Popover/Popover.js +1 -1
  8. package/dist/cjs/components/Suggestion/Suggestion.js +1 -0
  9. package/dist/cjs/components/Suggestion/SuggestionClear.js +11 -7
  10. package/dist/esm/components/Badge/Badge.js +1 -1
  11. package/dist/esm/components/Button/Button.js +1 -1
  12. package/dist/esm/components/Card/Card.js +1 -1
  13. package/dist/esm/components/Details/Details.js +1 -1
  14. package/dist/esm/components/Dialog/Dialog.js +17 -9
  15. package/dist/esm/components/Dialog/DialogTrigger.js +7 -1
  16. package/dist/esm/components/Popover/Popover.js +1 -1
  17. package/dist/esm/components/Suggestion/Suggestion.js +1 -0
  18. package/dist/esm/components/Suggestion/SuggestionClear.js +11 -7
  19. package/dist/types/colors.d.ts +7 -4
  20. package/dist/types/colors.d.ts.map +1 -1
  21. package/dist/types/components/Badge/Badge.d.ts +12 -3
  22. package/dist/types/components/Badge/Badge.d.ts.map +1 -1
  23. package/dist/types/components/Badge/index.d.ts +3 -2
  24. package/dist/types/components/Badge/index.d.ts.map +1 -1
  25. package/dist/types/components/Button/Button.d.ts +10 -1
  26. package/dist/types/components/Button/Button.d.ts.map +1 -1
  27. package/dist/types/components/Card/Card.d.ts +3 -3
  28. package/dist/types/components/Card/Card.d.ts.map +1 -1
  29. package/dist/types/components/Card/index.d.ts +2 -2
  30. package/dist/types/components/Details/Details.d.ts +1 -1
  31. package/dist/types/components/Details/Details.d.ts.map +1 -1
  32. package/dist/types/components/Dialog/Dialog.d.ts +34 -8
  33. package/dist/types/components/Dialog/Dialog.d.ts.map +1 -1
  34. package/dist/types/components/Dialog/DialogTrigger.d.ts +2 -1
  35. package/dist/types/components/Dialog/DialogTrigger.d.ts.map +1 -1
  36. package/dist/types/components/Dialog/index.d.ts +6 -3
  37. package/dist/types/components/Dialog/index.d.ts.map +1 -1
  38. package/dist/types/components/MultiSuggestion/MultiSuggestion.d.ts +131 -0
  39. package/dist/types/components/MultiSuggestion/MultiSuggestion.d.ts.map +1 -0
  40. package/dist/types/components/MultiSuggestion/MultiSuggestionChips.d.ts +20 -0
  41. package/dist/types/components/MultiSuggestion/MultiSuggestionChips.d.ts.map +1 -0
  42. package/dist/types/components/MultiSuggestion/MultiSuggestionClear.d.ts +35 -0
  43. package/dist/types/components/MultiSuggestion/MultiSuggestionClear.d.ts.map +1 -0
  44. package/dist/types/components/MultiSuggestion/MultiSuggestionEmpty.d.ts +15 -0
  45. package/dist/types/components/MultiSuggestion/MultiSuggestionEmpty.d.ts.map +1 -0
  46. package/dist/types/components/MultiSuggestion/MultiSuggestionInput.d.ts +21 -0
  47. package/dist/types/components/MultiSuggestion/MultiSuggestionInput.d.ts.map +1 -0
  48. package/dist/types/components/MultiSuggestion/MultiSuggestionList.d.ts +40 -0
  49. package/dist/types/components/MultiSuggestion/MultiSuggestionList.d.ts.map +1 -0
  50. package/dist/types/components/MultiSuggestion/MultiSuggestionOption.d.ts +6 -0
  51. package/dist/types/components/MultiSuggestion/MultiSuggestionOption.d.ts.map +1 -0
  52. package/dist/types/components/MultiSuggestion/index.d.ts +50 -0
  53. package/dist/types/components/MultiSuggestion/index.d.ts.map +1 -0
  54. package/dist/types/components/Popover/Popover.d.ts +12 -3
  55. package/dist/types/components/Popover/Popover.d.ts.map +1 -1
  56. package/dist/types/components/Popover/index.d.ts +3 -2
  57. package/dist/types/components/Popover/index.d.ts.map +1 -1
  58. package/dist/types/components/Search/SearchButton.d.ts +2 -1
  59. package/dist/types/components/Search/SearchButton.d.ts.map +1 -1
  60. package/dist/types/components/Search/index.d.ts +2 -1
  61. package/dist/types/components/Search/index.d.ts.map +1 -1
  62. package/dist/types/components/Suggestion/Suggestion.d.ts.map +1 -1
  63. package/dist/types/components/Suggestion/SuggestionClear.d.ts.map +1 -1
  64. package/dist/types/components/Tag/Tag.d.ts +14 -2
  65. package/dist/types/components/Tag/Tag.d.ts.map +1 -1
  66. package/dist/types/components/ToggleGroup/ToggleGroupItem.d.ts +2 -2
  67. package/dist/types/components/ToggleGroup/ToggleGroupItem.d.ts.map +1 -1
  68. package/dist/types/components/ToggleGroup/index.d.ts +1 -1
  69. package/package.json +4 -3
@@ -16,7 +16,7 @@ var react = require('react');
16
16
  * <Icon />
17
17
  * </Badge>
18
18
  */
19
- const Badge = react.forwardRef(function Badge({ className, count, maxCount, 'data-variant': variant = 'base', ...rest }, ref) {
19
+ const Badge = react.forwardRef(function Badge({ className, count, maxCount, variant = 'base', ...rest }, ref) {
20
20
  return (jsxRuntime.jsx("span", { className: cl('ds-badge', className), "data-count": count && maxCount && count > maxCount ? `${maxCount}+` : count, "data-variant": variant, ref: ref, ...rest }));
21
21
  });
22
22
 
@@ -16,7 +16,7 @@ var Spinner = require('../Spinner/Spinner.js');
16
16
  const Button = react.forwardRef(function Button({ asChild, className, children, icon = false, loading = false, variant = 'primary', ...rest }, ref) {
17
17
  const Component = asChild ? reactSlot.Slot : 'button';
18
18
  // Fallbacks to undefined to prevent rendering attribute="false"
19
- return (jsxRuntime.jsxs(Component, { "aria-busy": Boolean(loading) || undefined, className: cl('ds-button', className), "data-icon": icon || undefined, "data-variant": variant, ref: ref,
19
+ return (jsxRuntime.jsxs(Component, { "aria-busy": Boolean(loading) || undefined, "aria-disabled": Boolean(loading) || undefined, className: cl('ds-button', className), "data-icon": icon || undefined, "data-variant": variant, ref: ref,
20
20
  /* don't set type when we use `asChild` */
21
21
  type: asChild ? undefined : 'button', ...rest, children: [loading === true ? (jsxRuntime.jsx(Spinner.Spinner, { "aria-hidden": 'true' })) : (loading // Allow custom loading spinner
22
22
  ), jsxRuntime.jsx(reactSlot.Slottable, { children: children })] }));
@@ -17,7 +17,7 @@ var react = require('react');
17
17
  * <Card.Block>Footer</Card.Block>
18
18
  * </Card>
19
19
  */
20
- const Card = react.forwardRef(function Card({ asChild = false, 'data-variant': variant = 'default', className, ...rest }, ref) {
20
+ const Card = react.forwardRef(function Card({ asChild = false, variant = 'default', className, ...rest }, ref) {
21
21
  const Component = asChild ? reactSlot.Slot : 'div';
22
22
  const cardRef = react.useRef(null);
23
23
  const mergedRefs = react$1.useMergeRefs([cardRef, ref]);
@@ -16,7 +16,7 @@ require('@u-elements/u-details');
16
16
  * <Details.Content>Content</Details.Content>
17
17
  * </Details>
18
18
  */
19
- const Details = react.forwardRef(function Details({ className, open, defaultOpen = false, 'data-variant': variant = 'default', onToggle, ...rest }, ref) {
19
+ const Details = react.forwardRef(function Details({ className, open, defaultOpen = false, variant = 'default', onToggle, ...rest }, ref) {
20
20
  const detailsRef = react.useRef(null);
21
21
  const initialOpen = react.useRef(defaultOpen); // Allow rendering defaultOpen on server, but only render once on client
22
22
  const mergedRefs = react$1.useMergeRefs([detailsRef, ref]);
@@ -27,23 +27,29 @@ var Button = require('../Button/Button.js');
27
27
  *
28
28
  * ...
29
29
  *
30
- * <Button onClick={() => dialogRef.current?.showDialog()}>Open Dialog</Button>
30
+ * <Button onClick={() => dialogRef.current?.showModal()}>Open Dialog</Button>
31
31
  * <Dialog ref={dialogRef}>
32
32
  * Content
33
33
  * </Dialog>
34
34
  */
35
- const Dialog = react.forwardRef(function Dialog({ asChild, children, className, closeButton = 'Lukk dialogvindu', onClose, open, backdropClose = false, ...rest }, ref) {
35
+ const Dialog = react.forwardRef(function Dialog({ asChild, children, className, closeButton = 'Lukk dialogvindu', closedby = 'closerequest', modal = true, onClose, open, ...rest }, ref) {
36
36
  const contextRef = react.useContext(DialogTriggerContext.Context);
37
37
  const dialogRef = react.useRef(null); // This local ref is used to make sure the dialog works without a DialogTriggerContext
38
38
  const Component = asChild ? reactSlot.Slot : 'dialog';
39
39
  const mergedRefs = react$1.useMergeRefs([contextRef, ref, dialogRef]);
40
- react.useEffect(() => dialogRef.current?.[open ? 'showModal' : 'close'](), [open]); // Toggle open based on prop
40
+ const showProp = modal ? 'showModal' : 'show';
41
+ react.useEffect(() => dialogRef.current?.[open ? showProp : 'close'](), [open]); // Toggle open based on prop
41
42
  react.useEffect(() => {
42
43
  const dialog = dialogRef.current;
43
- const handleBackdropClick = ({ clientY: y, clientX: x, target, }) => {
44
+ const handleClosedby = (event) => {
45
+ const { clientY: y, clientX: x, target } = event;
46
+ if (event instanceof KeyboardEvent)
47
+ return (closedby === 'none' &&
48
+ event.key === 'Escape' &&
49
+ event.preventDefault()); // Skip ESC-key if closedby="none"
44
50
  if (window.getSelection()?.toString())
45
51
  return; // Fix bug where if you select text spanning two divs it thinks you clicked outside
46
- if (dialog && target === dialog && backdropClose) {
52
+ if (dialog && target === dialog && closedby === 'any') {
47
53
  const { top, left, right, bottom } = dialog.getBoundingClientRect();
48
54
  const isInDialog = top <= y && y <= bottom && left <= x && x <= right;
49
55
  if (!isInDialog)
@@ -56,19 +62,21 @@ const Dialog = react.forwardRef(function Dialog({ asChild, children, className,
56
62
  autofocus?.focus();
57
63
  };
58
64
  dialog?.addEventListener('animationend', handleAutoFocus);
59
- dialog?.addEventListener('click', handleBackdropClick);
65
+ dialog?.addEventListener('click', handleClosedby);
66
+ dialog?.addEventListener('keydown', handleClosedby);
60
67
  return () => {
61
68
  dialog?.removeEventListener('animationend', handleAutoFocus);
62
- dialog?.removeEventListener('click', handleBackdropClick);
69
+ dialog?.removeEventListener('click', handleClosedby);
70
+ dialog?.removeEventListener('keydown', handleClosedby);
63
71
  };
64
- }, [backdropClose]);
72
+ }, [closedby]);
65
73
  /* handle closing */
66
74
  react.useEffect(() => {
67
75
  const handleClose = (event) => onClose?.(event);
68
76
  dialogRef.current?.addEventListener('close', handleClose);
69
77
  return () => dialogRef.current?.removeEventListener('close', handleClose);
70
78
  }, [onClose]);
71
- return (jsxRuntime.jsxs(Component, { className: cl('ds-dialog', className), ref: mergedRefs, ...rest, children: [closeButton !== false && (jsxRuntime.jsx("form", { method: 'dialog', children: jsxRuntime.jsx(Button.Button, { "aria-label": closeButton, autoFocus: true, "data-color": 'neutral', icon: true, name: 'close', type: 'submit', variant: 'tertiary' }) })), children] }));
79
+ return (jsxRuntime.jsxs(Component, { className: cl('ds-dialog', className), ref: mergedRefs, "data-modal": modal, ...rest, children: [closeButton !== false && (jsxRuntime.jsx("form", { method: 'dialog', children: jsxRuntime.jsx(Button.Button, { "aria-label": closeButton, autoFocus: true, "data-color": 'neutral', icon: true, name: 'close', type: 'submit', variant: 'tertiary' }) })), children] }));
72
80
  });
73
81
 
74
82
  exports.Dialog = Dialog;
@@ -21,7 +21,13 @@ var DialogTriggerContext = require('./DialogTriggerContext.js');
21
21
  const DialogTrigger = react.forwardRef(function DialogTrigger({ asChild, ...rest }, ref) {
22
22
  const contextRef = react.useContext(DialogTriggerContext.Context);
23
23
  const Component = asChild ? reactSlot.Slot : Button.Button;
24
- return (jsxRuntime.jsx(Component, { "aria-haspopup": 'dialog', onClick: () => contextRef?.current?.showModal(), ref: ref, ...rest }));
24
+ const openDialog = () => {
25
+ /* check if element has `data-modal`, it it has, use `showModal` */
26
+ contextRef.current?.getAttribute('data-modal') === 'true'
27
+ ? contextRef.current?.showModal()
28
+ : contextRef.current?.show();
29
+ };
30
+ return (jsxRuntime.jsx(Component, { "aria-haspopup": 'dialog', onClick: openDialog, ref: ref, ...rest }));
25
31
  });
26
32
 
27
33
  exports.DialogTrigger = DialogTrigger;
@@ -26,7 +26,7 @@ var PopoverTriggerContext = require('./PopoverTriggerContext.js');
26
26
  * Content
27
27
  * </Popover>
28
28
  */
29
- const Popover = react.forwardRef(function Popover({ id, className, onClose, onOpen, open, 'data-variant': variant = 'default', placement = 'top', autoPlacement = true, asChild = false, ...rest }, ref) {
29
+ const Popover = react.forwardRef(function Popover({ id, className, onClose, onOpen, open, variant = 'default', placement = 'top', autoPlacement = true, asChild = false, ...rest }, ref) {
30
30
  const Component = asChild ? reactSlot.Slot : 'div';
31
31
  const popoverRef = react.useRef(null);
32
32
  const mergedRefs = react$1.useMergeRefs([popoverRef, ref]);
@@ -31,6 +31,7 @@ const Suggestion = react.forwardRef(function Suggestion({ className, filter = tr
31
31
  // Let <datalist> handle filtering if filter is true
32
32
  if (filter === true || !list)
33
33
  return;
34
+ console.log(list);
34
35
  // Handle custom filter
35
36
  if (filter !== false) {
36
37
  let index = 0;
@@ -33,15 +33,19 @@ const SuggestionClear = react.forwardRef(function SuggestionClear({ 'aria-label'
33
33
  };
34
34
  return (jsxRuntime.jsx(Button.Button, { ref: ref, variant: 'tertiary', type: 'reset', "aria-label": label, onClick: handleClear, icon: true, ...rest }));
35
35
  });
36
+ // Copied from https://github.com/facebook/react/issues/11488#issuecomment-1300987446
36
37
  const setReactInputValue = (input, value) => {
37
- const previousValue = input.value;
38
- input.value = value;
39
- const tracker = input._valueTracker;
40
- if (typeof tracker !== 'undefined') {
41
- tracker.setValue(previousValue);
38
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
39
+ if (nativeInputValueSetter) {
40
+ nativeInputValueSetter.call(input, value);
42
41
  }
43
- //'change' instead of 'input', see https://github.com/facebook/react/issues/11488#issuecomment-381590324
44
- input.dispatchEvent(new Event('change', { bubbles: true }));
42
+ else {
43
+ throw new Error('Unable to find the native input value setter');
44
+ }
45
+ const inputEvent = new Event('input', { bubbles: true });
46
+ const changeEvent = new Event('change', { bubbles: true });
47
+ input.dispatchEvent(inputEvent);
48
+ input.dispatchEvent(changeEvent);
45
49
  };
46
50
 
47
51
  exports.SuggestionClear = SuggestionClear;
@@ -14,7 +14,7 @@ import { forwardRef } from 'react';
14
14
  * <Icon />
15
15
  * </Badge>
16
16
  */
17
- const Badge = forwardRef(function Badge({ className, count, maxCount, 'data-variant': variant = 'base', ...rest }, ref) {
17
+ const Badge = forwardRef(function Badge({ className, count, maxCount, variant = 'base', ...rest }, ref) {
18
18
  return (jsx("span", { className: cl('ds-badge', className), "data-count": count && maxCount && count > maxCount ? `${maxCount}+` : count, "data-variant": variant, ref: ref, ...rest }));
19
19
  });
20
20
 
@@ -14,7 +14,7 @@ import { Spinner } from '../Spinner/Spinner.js';
14
14
  const Button = forwardRef(function Button({ asChild, className, children, icon = false, loading = false, variant = 'primary', ...rest }, ref) {
15
15
  const Component = asChild ? Slot : 'button';
16
16
  // Fallbacks to undefined to prevent rendering attribute="false"
17
- return (jsxs(Component, { "aria-busy": Boolean(loading) || undefined, className: cl('ds-button', className), "data-icon": icon || undefined, "data-variant": variant, ref: ref,
17
+ return (jsxs(Component, { "aria-busy": Boolean(loading) || undefined, "aria-disabled": Boolean(loading) || undefined, className: cl('ds-button', className), "data-icon": icon || undefined, "data-variant": variant, ref: ref,
18
18
  /* don't set type when we use `asChild` */
19
19
  type: asChild ? undefined : 'button', ...rest, children: [loading === true ? (jsx(Spinner, { "aria-hidden": 'true' })) : (loading // Allow custom loading spinner
20
20
  ), jsx(Slottable, { children: children })] }));
@@ -15,7 +15,7 @@ import { forwardRef, useRef, useEffect } from 'react';
15
15
  * <Card.Block>Footer</Card.Block>
16
16
  * </Card>
17
17
  */
18
- const Card = forwardRef(function Card({ asChild = false, 'data-variant': variant = 'default', className, ...rest }, ref) {
18
+ const Card = forwardRef(function Card({ asChild = false, variant = 'default', className, ...rest }, ref) {
19
19
  const Component = asChild ? Slot : 'div';
20
20
  const cardRef = useRef(null);
21
21
  const mergedRefs = useMergeRefs([cardRef, ref]);
@@ -14,7 +14,7 @@ import '@u-elements/u-details';
14
14
  * <Details.Content>Content</Details.Content>
15
15
  * </Details>
16
16
  */
17
- const Details = forwardRef(function Details({ className, open, defaultOpen = false, 'data-variant': variant = 'default', onToggle, ...rest }, ref) {
17
+ const Details = forwardRef(function Details({ className, open, defaultOpen = false, variant = 'default', onToggle, ...rest }, ref) {
18
18
  const detailsRef = useRef(null);
19
19
  const initialOpen = useRef(defaultOpen); // Allow rendering defaultOpen on server, but only render once on client
20
20
  const mergedRefs = useMergeRefs([detailsRef, ref]);
@@ -25,23 +25,29 @@ import { Button } from '../Button/Button.js';
25
25
  *
26
26
  * ...
27
27
  *
28
- * <Button onClick={() => dialogRef.current?.showDialog()}>Open Dialog</Button>
28
+ * <Button onClick={() => dialogRef.current?.showModal()}>Open Dialog</Button>
29
29
  * <Dialog ref={dialogRef}>
30
30
  * Content
31
31
  * </Dialog>
32
32
  */
33
- const Dialog = forwardRef(function Dialog({ asChild, children, className, closeButton = 'Lukk dialogvindu', onClose, open, backdropClose = false, ...rest }, ref) {
33
+ const Dialog = forwardRef(function Dialog({ asChild, children, className, closeButton = 'Lukk dialogvindu', closedby = 'closerequest', modal = true, onClose, open, ...rest }, ref) {
34
34
  const contextRef = useContext(Context);
35
35
  const dialogRef = useRef(null); // This local ref is used to make sure the dialog works without a DialogTriggerContext
36
36
  const Component = asChild ? Slot : 'dialog';
37
37
  const mergedRefs = useMergeRefs([contextRef, ref, dialogRef]);
38
- useEffect(() => dialogRef.current?.[open ? 'showModal' : 'close'](), [open]); // Toggle open based on prop
38
+ const showProp = modal ? 'showModal' : 'show';
39
+ useEffect(() => dialogRef.current?.[open ? showProp : 'close'](), [open]); // Toggle open based on prop
39
40
  useEffect(() => {
40
41
  const dialog = dialogRef.current;
41
- const handleBackdropClick = ({ clientY: y, clientX: x, target, }) => {
42
+ const handleClosedby = (event) => {
43
+ const { clientY: y, clientX: x, target } = event;
44
+ if (event instanceof KeyboardEvent)
45
+ return (closedby === 'none' &&
46
+ event.key === 'Escape' &&
47
+ event.preventDefault()); // Skip ESC-key if closedby="none"
42
48
  if (window.getSelection()?.toString())
43
49
  return; // Fix bug where if you select text spanning two divs it thinks you clicked outside
44
- if (dialog && target === dialog && backdropClose) {
50
+ if (dialog && target === dialog && closedby === 'any') {
45
51
  const { top, left, right, bottom } = dialog.getBoundingClientRect();
46
52
  const isInDialog = top <= y && y <= bottom && left <= x && x <= right;
47
53
  if (!isInDialog)
@@ -54,19 +60,21 @@ const Dialog = forwardRef(function Dialog({ asChild, children, className, closeB
54
60
  autofocus?.focus();
55
61
  };
56
62
  dialog?.addEventListener('animationend', handleAutoFocus);
57
- dialog?.addEventListener('click', handleBackdropClick);
63
+ dialog?.addEventListener('click', handleClosedby);
64
+ dialog?.addEventListener('keydown', handleClosedby);
58
65
  return () => {
59
66
  dialog?.removeEventListener('animationend', handleAutoFocus);
60
- dialog?.removeEventListener('click', handleBackdropClick);
67
+ dialog?.removeEventListener('click', handleClosedby);
68
+ dialog?.removeEventListener('keydown', handleClosedby);
61
69
  };
62
- }, [backdropClose]);
70
+ }, [closedby]);
63
71
  /* handle closing */
64
72
  useEffect(() => {
65
73
  const handleClose = (event) => onClose?.(event);
66
74
  dialogRef.current?.addEventListener('close', handleClose);
67
75
  return () => dialogRef.current?.removeEventListener('close', handleClose);
68
76
  }, [onClose]);
69
- return (jsxs(Component, { className: cl('ds-dialog', className), ref: mergedRefs, ...rest, children: [closeButton !== false && (jsx("form", { method: 'dialog', children: jsx(Button, { "aria-label": closeButton, autoFocus: true, "data-color": 'neutral', icon: true, name: 'close', type: 'submit', variant: 'tertiary' }) })), children] }));
77
+ return (jsxs(Component, { className: cl('ds-dialog', className), ref: mergedRefs, "data-modal": modal, ...rest, children: [closeButton !== false && (jsx("form", { method: 'dialog', children: jsx(Button, { "aria-label": closeButton, autoFocus: true, "data-color": 'neutral', icon: true, name: 'close', type: 'submit', variant: 'tertiary' }) })), children] }));
70
78
  });
71
79
 
72
80
  export { Dialog };
@@ -19,7 +19,13 @@ import { Context } from './DialogTriggerContext.js';
19
19
  const DialogTrigger = forwardRef(function DialogTrigger({ asChild, ...rest }, ref) {
20
20
  const contextRef = useContext(Context);
21
21
  const Component = asChild ? Slot : Button;
22
- return (jsx(Component, { "aria-haspopup": 'dialog', onClick: () => contextRef?.current?.showModal(), ref: ref, ...rest }));
22
+ const openDialog = () => {
23
+ /* check if element has `data-modal`, it it has, use `showModal` */
24
+ contextRef.current?.getAttribute('data-modal') === 'true'
25
+ ? contextRef.current?.showModal()
26
+ : contextRef.current?.show();
27
+ };
28
+ return (jsx(Component, { "aria-haspopup": 'dialog', onClick: openDialog, ref: ref, ...rest }));
23
29
  });
24
30
 
25
31
  export { DialogTrigger };
@@ -24,7 +24,7 @@ import { Context } from './PopoverTriggerContext.js';
24
24
  * Content
25
25
  * </Popover>
26
26
  */
27
- const Popover = forwardRef(function Popover({ id, className, onClose, onOpen, open, 'data-variant': variant = 'default', placement = 'top', autoPlacement = true, asChild = false, ...rest }, ref) {
27
+ const Popover = forwardRef(function Popover({ id, className, onClose, onOpen, open, variant = 'default', placement = 'top', autoPlacement = true, asChild = false, ...rest }, ref) {
28
28
  const Component = asChild ? Slot : 'div';
29
29
  const popoverRef = useRef(null);
30
30
  const mergedRefs = useMergeRefs([popoverRef, ref]);
@@ -29,6 +29,7 @@ const Suggestion = forwardRef(function Suggestion({ className, filter = true, as
29
29
  // Let <datalist> handle filtering if filter is true
30
30
  if (filter === true || !list)
31
31
  return;
32
+ console.log(list);
32
33
  // Handle custom filter
33
34
  if (filter !== false) {
34
35
  let index = 0;
@@ -31,15 +31,19 @@ const SuggestionClear = forwardRef(function SuggestionClear({ 'aria-label': labe
31
31
  };
32
32
  return (jsx(Button, { ref: ref, variant: 'tertiary', type: 'reset', "aria-label": label, onClick: handleClear, icon: true, ...rest }));
33
33
  });
34
+ // Copied from https://github.com/facebook/react/issues/11488#issuecomment-1300987446
34
35
  const setReactInputValue = (input, value) => {
35
- const previousValue = input.value;
36
- input.value = value;
37
- const tracker = input._valueTracker;
38
- if (typeof tracker !== 'undefined') {
39
- tracker.setValue(previousValue);
36
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
37
+ if (nativeInputValueSetter) {
38
+ nativeInputValueSetter.call(input, value);
40
39
  }
41
- //'change' instead of 'input', see https://github.com/facebook/react/issues/11488#issuecomment-381590324
42
- input.dispatchEvent(new Event('change', { bubbles: true }));
40
+ else {
41
+ throw new Error('Unable to find the native input value setter');
42
+ }
43
+ const inputEvent = new Event('input', { bubbles: true });
44
+ const changeEvent = new Event('change', { bubbles: true });
45
+ input.dispatchEvent(inputEvent);
46
+ input.dispatchEvent(changeEvent);
43
47
  };
44
48
 
45
49
  export { SuggestionClear, setReactInputValue };
@@ -13,9 +13,12 @@ export interface MainAndSupportColors {
13
13
  * If {@link MainAndSupportColors} has been extended to include color names, return T,
14
14
  * otherwise return the arbitrary string type.
15
15
  */
16
- type ColorWithFallback<T> = MainAndSupportColors extends EmptyObject ? string & {} : T;
17
- export type SeverityColors = 'info' | 'success' | 'warning' | 'danger';
18
- export type CustomColors = ColorWithFallback<'neutral' | keyof MainAndSupportColors>;
19
- export type Color = CustomColors | ColorWithFallback<SeverityColors>;
16
+ type ColorWithFallback<T> = MainAndSupportColors extends EmptyObject ? string : T;
17
+ export type SeverityInfo = 'info';
18
+ export type SeveritySuccess = 'success';
19
+ export type SeverityWarning = 'warning';
20
+ export type SeverityDanger = 'danger';
21
+ export type SeverityColors = SeverityInfo | SeveritySuccess | SeverityWarning | SeverityDanger;
22
+ export type Color = ColorWithFallback<'neutral' | keyof MainAndSupportColors>;
20
23
  export {};
21
24
  //# sourceMappingURL=colors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAC/C,KAAK,WAAW,GAAG;IAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEnD;;;;GAIG;AAGH,MAAM,WAAW,oBAAoB;CAAG;AAExC;;;GAGG;AACH,KAAK,iBAAiB,CAAC,CAAC,IAAI,oBAAoB,SAAS,WAAW,GAChE,MAAM,GAAG,EAAE,GACX,CAAC,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,iBAAiB,CAC1C,SAAS,GAAG,MAAM,oBAAoB,CACvC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,YAAY,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAC/C,KAAK,WAAW,GAAG;IAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEnD;;;;GAIG;AAGH,MAAM,WAAW,oBAAoB;CAAG;AAExC;;;GAGG;AACH,KAAK,iBAAiB,CAAC,CAAC,IAAI,oBAAoB,SAAS,WAAW,GAChE,MAAM,GACN,CAAC,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AACxC,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;AACtC,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,eAAe,GACf,eAAe,GACf,cAAc,CAAC;AAEnB,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,GAAG,MAAM,oBAAoB,CAAC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { Color, SeverityColors } from '@digdir/designsystemet-react/colors';
1
2
  import { type HTMLAttributes } from 'react';
2
3
  import type { DefaultProps } from '../../types';
3
4
  import type { MergeRight } from '../../utilities';
@@ -15,7 +16,11 @@ export type BadgeProps = MergeRight<DefaultProps & HTMLAttributes<HTMLSpanElemen
15
16
  *
16
17
  * @default 'base'
17
18
  */
18
- 'data-variant'?: 'base' | 'tinted';
19
+ variant?: 'base' | 'tinted';
20
+ /**
21
+ * Change the color scheme of the badge
22
+ */
23
+ 'data-color'?: Color | SeverityColors;
19
24
  children?: never;
20
25
  }>;
21
26
  /**
@@ -29,7 +34,7 @@ export type BadgeProps = MergeRight<DefaultProps & HTMLAttributes<HTMLSpanElemen
29
34
  * <Icon />
30
35
  * </Badge>
31
36
  */
32
- export declare const Badge: React.ForwardRefExoticComponent<Omit<DefaultProps & HTMLAttributes<HTMLSpanElement>, "children" | "data-variant" | "count" | "maxCount"> & {
37
+ export declare const Badge: React.ForwardRefExoticComponent<Omit<DefaultProps & HTMLAttributes<HTMLSpanElement>, "data-color" | "children" | "variant" | "count" | "maxCount"> & {
33
38
  /**
34
39
  * The number to display in the badge
35
40
  */
@@ -43,7 +48,11 @@ export declare const Badge: React.ForwardRefExoticComponent<Omit<DefaultProps &
43
48
  *
44
49
  * @default 'base'
45
50
  */
46
- 'data-variant'?: "base" | "tinted";
51
+ variant?: "base" | "tinted";
52
+ /**
53
+ * Change the color scheme of the badge
54
+ */
55
+ 'data-color'?: Color | SeverityColors;
47
56
  children?: never;
48
57
  } & React.RefAttributes<HTMLSpanElement>>;
49
58
  //# sourceMappingURL=Badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,UAAU,CACjC,YAAY,GAAG,cAAc,CAAC,eAAe,CAAC,EAC9C;IACE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACnC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK;IA7Bd;;OAEG;YACK,MAAM;IACd;;OAEG;eACQ,MAAM;IACjB;;;;OAIG;qBACc,MAAM,GAAG,QAAQ;eACvB,KAAK;yCA8BlB,CAAC"}
1
+ {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACf,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,OAAO,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,UAAU,CACjC,YAAY,GAAG,cAAc,CAAC,eAAe,CAAC,EAC9C;IACE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,cAAc,CAAC;IACtC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK;IAjCd;;OAEG;YACK,MAAM;IACd;;OAEG;eACQ,MAAM;IACjB;;;;OAIG;cACO,MAAM,GAAG,QAAQ;IAC3B;;OAEG;mBACY,KAAK,GAAG,cAAc;eAC1B,KAAK;yCA8BlB,CAAC"}
@@ -5,10 +5,11 @@ import { BadgePosition } from './BadgePosition';
5
5
  * @example without children
6
6
  * <Badge count={5} maxCount={10} />
7
7
  */
8
- declare const Badge: React.ForwardRefExoticComponent<Omit<import("../../types").DefaultProps & React.HTMLAttributes<HTMLSpanElement>, "children" | "data-variant" | "count" | "maxCount"> & {
8
+ declare const Badge: React.ForwardRefExoticComponent<Omit<import("../../types").DefaultProps & React.HTMLAttributes<HTMLSpanElement>, "data-color" | "children" | "variant" | "count" | "maxCount"> & {
9
9
  count?: number;
10
10
  maxCount?: number;
11
- 'data-variant'?: "base" | "tinted";
11
+ variant?: "base" | "tinted";
12
+ 'data-color'?: import("../../colors").Color | import("../../colors").SeverityColors;
12
13
  children?: never;
13
14
  } & React.RefAttributes<HTMLSpanElement>> & {
14
15
  Position: React.ForwardRefExoticComponent<Omit<import("../../types").DefaultProps & React.HTMLAttributes<HTMLSpanElement>, "placement" | "overlap"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;GAKG;AACH,QAAA,MAAM,KAAK;;;;;;;;;;CAAuD,CAAC;AAInE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Badge/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;GAKG;AACH,QAAA,MAAM,KAAK;;;;;;;;;;;CAAuD,CAAC;AAInE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { Color, SeverityDanger } from '@digdir/designsystemet-react/colors';
1
2
  import type { ButtonHTMLAttributes, ReactNode } from 'react';
2
3
  import type { DefaultProps } from '../../types';
3
4
  import type { MergeRight } from '../../utilities';
@@ -7,6 +8,10 @@ export type ButtonProps = MergeRight<DefaultProps & ButtonHTMLAttributes<HTMLBut
7
8
  * @default 'primary'
8
9
  */
9
10
  variant?: 'primary' | 'secondary' | 'tertiary';
11
+ /**
12
+ * Change the color scheme of the button
13
+ */
14
+ 'data-color'?: Color | SeverityDanger;
10
15
  /**
11
16
  * Toggle icon only styling, pass icon as children
12
17
  * @default false
@@ -36,12 +41,16 @@ export type ButtonProps = MergeRight<DefaultProps & ButtonHTMLAttributes<HTMLBut
36
41
  * @example
37
42
  * <Button>Click me</Button>
38
43
  */
39
- export declare const Button: React.ForwardRefExoticComponent<Omit<DefaultProps & ButtonHTMLAttributes<HTMLButtonElement>, "type" | "variant" | "icon" | "loading" | "asChild"> & {
44
+ export declare const Button: React.ForwardRefExoticComponent<Omit<DefaultProps & ButtonHTMLAttributes<HTMLButtonElement>, "type" | "data-color" | "variant" | "icon" | "loading" | "asChild"> & {
40
45
  /**
41
46
  * Specify which variant to use
42
47
  * @default 'primary'
43
48
  */
44
49
  variant?: "primary" | "secondary" | "tertiary";
50
+ /**
51
+ * Change the color scheme of the button
52
+ */
53
+ 'data-color'?: Color | SeverityDanger;
45
54
  /**
46
55
  * Toggle icon only styling, pass icon as children
47
56
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,MAAM,WAAW,GAAG,UAAU,CAClC,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,EACtD;IACE;;;OAGG;IACH,OA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G,SAAS,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;CACxD,CACF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,MAAM;IAxCf;;;OAGG;cACO,SAAS,GAAG,WAAW,GAAG,UAAU;IAC9C;;OAEG;mBACY,KAAK,GAAG,cAAc;IACrC;;;OAGG;WACI,OAAO;IACd;;;;;OAKG;cACO,OAAO,GAAG,SAAS;IAC7B;;;OAGG;cACO,OAAO;IACjB;;;OAGG;WACI,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC;2CAgDzD,CAAC"}
@@ -7,7 +7,7 @@ export type CardProps = MergeRight<DefaultProps & HTMLAttributes<HTMLDivElement>
7
7
  *
8
8
  * @default 'default'
9
9
  */
10
- 'data-variant'?: 'default' | 'tinted';
10
+ variant?: 'default' | 'tinted';
11
11
  /**
12
12
  * Change the default rendered element for the one passed as a child, merging their props and behavior.
13
13
  * @default false
@@ -26,13 +26,13 @@ export type CardProps = MergeRight<DefaultProps & HTMLAttributes<HTMLDivElement>
26
26
  * <Card.Block>Footer</Card.Block>
27
27
  * </Card>
28
28
  */
29
- export declare const Card: React.ForwardRefExoticComponent<Omit<DefaultProps & HTMLAttributes<HTMLDivElement>, "children" | "asChild" | "data-variant"> & {
29
+ export declare const Card: React.ForwardRefExoticComponent<Omit<DefaultProps & HTMLAttributes<HTMLDivElement>, "children" | "variant" | "asChild"> & {
30
30
  /**
31
31
  * Change the background color of the card.
32
32
  *
33
33
  * @default 'default'
34
34
  */
35
- 'data-variant'?: "default" | "tinted";
35
+ variant?: "default" | "tinted";
36
36
  /**
37
37
  * Change the default rendered element for the one passed as a child, merging their props and behavior.
38
38
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../src/components/Card/Card.tsx"],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AO;IACjB,gEAAgE;cACtD,SAAS;wCAgDrB,CAAC"}
@@ -9,8 +9,8 @@ import { CardBlock } from './CardBlock';
9
9
  * <Card.Block>Footer</Card.Block>
10
10
  * </Card>
11
11
  */
12
- declare const Card: React.ForwardRefExoticComponent<Omit<import("../../types").DefaultProps & React.HTMLAttributes<HTMLDivElement>, "children" | "asChild" | "data-variant"> & {
13
- 'data-variant'?: "default" | "tinted";
12
+ declare const Card: React.ForwardRefExoticComponent<Omit<import("../../types").DefaultProps & React.HTMLAttributes<HTMLDivElement>, "children" | "variant" | "asChild"> & {
13
+ variant?: "default" | "tinted";
14
14
  asChild?: boolean;
15
15
  children: React.ReactNode;
16
16
  } & React.RefAttributes<HTMLDivElement>> & {
@@ -8,7 +8,7 @@ export type DetailsProps = MergeRight<DefaultProps & HTMLAttributes<HTMLDetailsE
8
8
  *
9
9
  * @default 'default'
10
10
  */
11
- 'data-variant'?: 'default' | 'tinted';
11
+ variant?: 'default' | 'tinted';
12
12
  /**
13
13
  * Controls open-state.
14
14
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Details.d.ts","sourceRoot":"","sources":["../../../src/components/Details/Details.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,UAAU,CACnC,YAAY,GAAG,cAAc,CAAC,kBAAkB,CAAC,EACjD;IACE;;;;OAIG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IACtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC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AAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CAAE,CACtD,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,yFA2CnB,CAAC"}
@@ -8,10 +8,23 @@ export type DialogProps = MergeRight<DefaultProps & DialogHTMLAttributes<HTMLDia
8
8
  */
9
9
  closeButton?: string | false;
10
10
  /**
11
- * Close on backdrop click.
12
- * @default false
11
+ * Light dismiss behavior, allowing to close on backdrop click by setting `closedby="any"`.
12
+ *
13
+ * @default 'closerequest'
14
+ */
15
+ closedby?: 'none' | 'closerequest' | 'any';
16
+ /**
17
+ * Toogle modal and non-modal dialog.
18
+ *
19
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog#creating_a_modal_dialog
20
+ *
21
+ * @default true
22
+ */
23
+ modal?: boolean;
24
+ /**
25
+ * @note Unlike standard html, where the open attribute always opens a non-modal dialog, Dialog's open prop uses the `modal` prop to determine whether the Dialog is modal or non-modal
13
26
  */
14
- backdropClose?: boolean;
27
+ open?: boolean;
15
28
  /**
16
29
  * Callback that is called when the dialog is closed.
17
30
  */
@@ -40,22 +53,35 @@ export type DialogProps = MergeRight<DefaultProps & DialogHTMLAttributes<HTMLDia
40
53
  *
41
54
  * ...
42
55
  *
43
- * <Button onClick={() => dialogRef.current?.showDialog()}>Open Dialog</Button>
56
+ * <Button onClick={() => dialogRef.current?.showModal()}>Open Dialog</Button>
44
57
  * <Dialog ref={dialogRef}>
45
58
  * Content
46
59
  * </Dialog>
47
60
  */
48
- export declare const Dialog: React.ForwardRefExoticComponent<Omit<DefaultProps & DialogHTMLAttributes<HTMLDialogElement>, "asChild" | "onClose" | "closeButton" | "backdropClose"> & {
61
+ export declare const Dialog: React.ForwardRefExoticComponent<Omit<DefaultProps & DialogHTMLAttributes<HTMLDialogElement>, "asChild" | "open" | "onClose" | "closeButton" | "closedby" | "modal"> & {
49
62
  /**
50
63
  * Screen reader label of close button. Set false to hide the close button.
51
64
  * @default 'Lukk dialogvindu'
52
65
  */
53
66
  closeButton?: string | false;
54
67
  /**
55
- * Close on backdrop click.
56
- * @default false
68
+ * Light dismiss behavior, allowing to close on backdrop click by setting `closedby="any"`.
69
+ *
70
+ * @default 'closerequest'
71
+ */
72
+ closedby?: "none" | "closerequest" | "any";
73
+ /**
74
+ * Toogle modal and non-modal dialog.
75
+ *
76
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog#creating_a_modal_dialog
77
+ *
78
+ * @default true
79
+ */
80
+ modal?: boolean;
81
+ /**
82
+ * @note Unlike standard html, where the open attribute always opens a non-modal dialog, Dialog's open prop uses the `modal` prop to determine whether the Dialog is modal or non-modal
57
83
  */
58
- backdropClose?: boolean;
84
+ open?: boolean;
59
85
  /**
60
86
  * Callback that is called when the dialog is closed.
61
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAGlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,MAAM,WAAW,GAAG,UAAU,CAClC,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,EACtD;IACE;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,MAAM;IA7Cf;;;OAGG;kBACW,MAAM,GAAG,KAAK;IAC5B;;;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