@postenbring/hedwig-react 0.0.44 → 0.0.45

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 (96) hide show
  1. package/dist/{chunk-PF6PZIZS.mjs → chunk-4RAMNETH.mjs} +1 -1
  2. package/dist/{chunk-DOJ2ZKNV.mjs → chunk-5NWYVPBZ.mjs} +1 -1
  3. package/dist/chunk-67OMX7FP.mjs +5 -0
  4. package/dist/{chunk-2QZF65FK.mjs → chunk-6IJTNHP4.mjs} +5 -1
  5. package/dist/{chunk-K3BGDNWO.mjs → chunk-E55KF755.mjs} +2 -2
  6. package/dist/{chunk-6KVF3ELJ.mjs → chunk-HZMQWFYP.mjs} +2 -2
  7. package/dist/chunk-IAPRPJQO.mjs +30 -0
  8. package/dist/{chunk-QAYPCD5Z.mjs → chunk-JYEDLLKF.mjs} +21 -12
  9. package/dist/chunk-N5VPBR6T.mjs +129 -0
  10. package/dist/chunk-OKWNTFU5.mjs +5 -0
  11. package/dist/{chunk-SX37JSDS.mjs → chunk-OPW2JS5I.mjs} +1 -1
  12. package/dist/chunk-PPUNMHOX.mjs +0 -0
  13. package/dist/chunk-QMB26PCT.mjs +72 -0
  14. package/dist/{chunk-45BJGKVZ.mjs → chunk-S4F2KVFJ.mjs} +1 -1
  15. package/dist/{chunk-Y2KP4RF2.mjs → chunk-T4IRPRA6.mjs} +2 -2
  16. package/dist/form/error-message/error-message.d.mts +12 -0
  17. package/dist/form/error-message/error-message.d.ts +12 -0
  18. package/dist/form/error-message/error-message.js +66 -0
  19. package/dist/form/error-message/error-message.mjs +7 -0
  20. package/dist/form/error-message/index.d.mts +3 -0
  21. package/dist/form/error-message/index.d.ts +3 -0
  22. package/dist/form/error-message/index.js +72 -0
  23. package/dist/form/error-message/index.mjs +8 -0
  24. package/dist/form/fieldset/fieldset.d.mts +20 -0
  25. package/dist/form/fieldset/fieldset.d.ts +20 -0
  26. package/dist/{input-group/input-group.js → form/fieldset/fieldset.js} +65 -61
  27. package/dist/form/fieldset/fieldset.mjs +9 -0
  28. package/dist/form/fieldset/index.d.mts +2 -0
  29. package/dist/form/fieldset/index.d.ts +2 -0
  30. package/dist/form/fieldset/index.js +152 -0
  31. package/dist/form/fieldset/index.mjs +10 -0
  32. package/dist/form/index.d.mts +6 -0
  33. package/dist/form/index.d.ts +6 -0
  34. package/dist/form/index.js +375 -0
  35. package/dist/form/index.mjs +28 -0
  36. package/dist/{input/input.js → form/input/index.js} +70 -27
  37. package/dist/form/input/index.mjs +12 -0
  38. package/dist/{input/index.js → form/input/input.js} +60 -31
  39. package/dist/form/input/input.mjs +11 -0
  40. package/dist/form/input-group/index.d.mts +2 -0
  41. package/dist/form/input-group/index.d.ts +2 -0
  42. package/dist/{textarea/textarea.js → form/input-group/index.js} +60 -50
  43. package/dist/form/input-group/index.mjs +10 -0
  44. package/dist/{input-group → form/input-group}/input-group.d.mts +1 -7
  45. package/dist/{input-group → form/input-group}/input-group.d.ts +1 -7
  46. package/dist/{input-group/index.js → form/input-group/input-group.js} +51 -21
  47. package/dist/form/input-group/input-group.mjs +9 -0
  48. package/dist/{select/select.js → form/select/index.js} +70 -27
  49. package/dist/form/select/index.mjs +12 -0
  50. package/dist/{select/index.js → form/select/select.js} +60 -31
  51. package/dist/form/select/select.mjs +11 -0
  52. package/dist/form/textarea/index.js +217 -0
  53. package/dist/form/textarea/index.mjs +12 -0
  54. package/dist/{textarea/index.js → form/textarea/textarea.js} +60 -31
  55. package/dist/form/textarea/textarea.mjs +11 -0
  56. package/dist/index.d.mts +7 -6
  57. package/dist/index.d.ts +7 -6
  58. package/dist/index.js +412 -240
  59. package/dist/index.mjs +35 -27
  60. package/dist/list/description-list.d.mts +4 -4
  61. package/dist/list/description-list.d.ts +4 -4
  62. package/dist/list/index.mjs +3 -3
  63. package/dist/modal/index.d.mts +5 -2
  64. package/dist/modal/index.d.ts +5 -2
  65. package/dist/modal/index.js +71 -3
  66. package/dist/modal/index.mjs +2 -2
  67. package/dist/modal/modal.d.mts +20 -2
  68. package/dist/modal/modal.d.ts +20 -2
  69. package/dist/modal/modal.js +77 -5
  70. package/dist/modal/modal.mjs +9 -3
  71. package/dist/tabs/index.mjs +2 -2
  72. package/package.json +2 -2
  73. package/dist/chunk-OB6UNSKV.mjs +0 -60
  74. package/dist/input/index.mjs +0 -10
  75. package/dist/input/input.mjs +0 -9
  76. package/dist/input-group/index.d.mts +0 -2
  77. package/dist/input-group/index.d.ts +0 -2
  78. package/dist/input-group/index.mjs +0 -8
  79. package/dist/input-group/input-group.mjs +0 -7
  80. package/dist/select/index.mjs +0 -10
  81. package/dist/select/select.mjs +0 -9
  82. package/dist/textarea/index.mjs +0 -10
  83. package/dist/textarea/textarea.mjs +0 -9
  84. package/dist/{chunk-WUMZCEIJ.mjs → chunk-BSX4IA3X.mjs} +3 -3
  85. /package/dist/{input → form/input}/index.d.mts +0 -0
  86. /package/dist/{input → form/input}/index.d.ts +0 -0
  87. /package/dist/{input → form/input}/input.d.mts +0 -0
  88. /package/dist/{input → form/input}/input.d.ts +0 -0
  89. /package/dist/{select → form/select}/index.d.mts +0 -0
  90. /package/dist/{select → form/select}/index.d.ts +0 -0
  91. /package/dist/{select → form/select}/select.d.mts +0 -0
  92. /package/dist/{select → form/select}/select.d.ts +0 -0
  93. /package/dist/{textarea → form/textarea}/index.d.mts +0 -0
  94. /package/dist/{textarea → form/textarea}/index.d.ts +0 -0
  95. /package/dist/{textarea → form/textarea}/textarea.d.mts +0 -0
  96. /package/dist/{textarea → form/textarea}/textarea.d.ts +0 -0
package/dist/index.mjs CHANGED
@@ -1,45 +1,44 @@
1
- import "./chunk-DOJ2ZKNV.mjs";
2
- import {
3
- Textarea
4
- } from "./chunk-Y2KP4RF2.mjs";
5
- import "./chunk-K2HIKZ7F.mjs";
6
- import {
7
- WarningBanner
8
- } from "./chunk-BHNQPMEB.mjs";
9
- import "./chunk-SX37JSDS.mjs";
10
- import {
11
- Select
12
- } from "./chunk-K3BGDNWO.mjs";
13
1
  import {
14
2
  TabsComponent
15
- } from "./chunk-WUMZCEIJ.mjs";
16
- import "./chunk-ZLCNSHLT.mjs";
3
+ } from "./chunk-BSX4IA3X.mjs";
17
4
  import "./chunk-GRO36EUL.mjs";
18
5
  import "./chunk-G3JPULGO.mjs";
6
+ import "./chunk-ZLCNSHLT.mjs";
19
7
  import "./chunk-4ZM45P62.mjs";
20
- import "./chunk-5OAMKZDX.mjs";
21
- import {
22
- LinkList
23
- } from "./chunk-BRBGRJ2I.mjs";
8
+ import "./chunk-K2HIKZ7F.mjs";
24
9
  import {
25
- OrderedList,
26
- UnorderedList
27
- } from "./chunk-RY53CJI7.mjs";
10
+ WarningBanner
11
+ } from "./chunk-BHNQPMEB.mjs";
28
12
  import {
29
13
  MessageComponent
30
14
  } from "./chunk-MER2HJBC.mjs";
31
15
  import "./chunk-WYPGZY5Q.mjs";
32
16
  import {
33
17
  ModalComponent
34
- } from "./chunk-2QZF65FK.mjs";
35
- import "./chunk-OB6UNSKV.mjs";
18
+ } from "./chunk-6IJTNHP4.mjs";
19
+ import "./chunk-N5VPBR6T.mjs";
36
20
  import "./chunk-FSBY3NKV.mjs";
37
- import "./chunk-PF6PZIZS.mjs";
21
+ import "./chunk-PPUNMHOX.mjs";
22
+ import "./chunk-OPW2JS5I.mjs";
23
+ import {
24
+ Select
25
+ } from "./chunk-E55KF755.mjs";
26
+ import "./chunk-5NWYVPBZ.mjs";
27
+ import {
28
+ Textarea
29
+ } from "./chunk-T4IRPRA6.mjs";
30
+ import "./chunk-OKWNTFU5.mjs";
31
+ import {
32
+ Fieldset
33
+ } from "./chunk-QMB26PCT.mjs";
34
+ import "./chunk-4RAMNETH.mjs";
38
35
  import {
39
36
  Input
40
- } from "./chunk-6KVF3ELJ.mjs";
41
- import "./chunk-45BJGKVZ.mjs";
42
- import "./chunk-QAYPCD5Z.mjs";
37
+ } from "./chunk-HZMQWFYP.mjs";
38
+ import "./chunk-S4F2KVFJ.mjs";
39
+ import "./chunk-JYEDLLKF.mjs";
40
+ import "./chunk-67OMX7FP.mjs";
41
+ import "./chunk-IAPRPJQO.mjs";
43
42
  import "./chunk-FJQCHTJZ.mjs";
44
43
  import {
45
44
  Container
@@ -48,9 +47,17 @@ import "./chunk-7SCOBRDZ.mjs";
48
47
  import {
49
48
  Link
50
49
  } from "./chunk-TES7CVGU.mjs";
50
+ import "./chunk-5OAMKZDX.mjs";
51
51
  import {
52
52
  DescriptionList
53
53
  } from "./chunk-3JNHAMRV.mjs";
54
+ import {
55
+ LinkList
56
+ } from "./chunk-BRBGRJ2I.mjs";
57
+ import {
58
+ OrderedList,
59
+ UnorderedList
60
+ } from "./chunk-RY53CJI7.mjs";
54
61
  import {
55
62
  BoxComponent
56
63
  } from "./chunk-E2GAXTBX.mjs";
@@ -93,6 +100,7 @@ export {
93
100
  Container,
94
101
  DarkBadge,
95
102
  DescriptionList,
103
+ Fieldset,
96
104
  Input,
97
105
  Link,
98
106
  LinkList,
@@ -19,9 +19,9 @@ interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
19
19
  * ```tsx
20
20
  * <DescriptionList>
21
21
  * <dt>Vekt</dt>
22
- * <dl>12 kg</dl>
22
+ * <dd>12 kg</dd>
23
23
  * <dt>Antall kolli</dt>
24
- * <dl>2</dl>
24
+ * <dd>2</dd>
25
25
  * </DescriptionList>
26
26
  * ```
27
27
  *
@@ -31,11 +31,11 @@ interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
31
31
  * <DescriptionList>
32
32
  * <div>
33
33
  * <dt>Vekt</dt>
34
- * <dl>12 kg</dl>
34
+ * <dd>12 kg</dd>
35
35
  * </div>
36
36
  * <div>
37
37
  * <dt>Antall kolli</dt>
38
- * <dl>2</dl>
38
+ * <dd>2</dd>
39
39
  * </div>
40
40
  * </DescriptionList>
41
41
  * ```
@@ -19,9 +19,9 @@ interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
19
19
  * ```tsx
20
20
  * <DescriptionList>
21
21
  * <dt>Vekt</dt>
22
- * <dl>12 kg</dl>
22
+ * <dd>12 kg</dd>
23
23
  * <dt>Antall kolli</dt>
24
- * <dl>2</dl>
24
+ * <dd>2</dd>
25
25
  * </DescriptionList>
26
26
  * ```
27
27
  *
@@ -31,11 +31,11 @@ interface DescriptionListProps extends HTMLAttributes<HTMLDListElement> {
31
31
  * <DescriptionList>
32
32
  * <div>
33
33
  * <dt>Vekt</dt>
34
- * <dl>12 kg</dl>
34
+ * <dd>12 kg</dd>
35
35
  * </div>
36
36
  * <div>
37
37
  * <dt>Antall kolli</dt>
38
- * <dl>2</dl>
38
+ * <dd>2</dd>
39
39
  * </div>
40
40
  * </DescriptionList>
41
41
  * ```
@@ -1,4 +1,7 @@
1
1
  import "../chunk-5OAMKZDX.mjs";
2
+ import {
3
+ DescriptionList
4
+ } from "../chunk-3JNHAMRV.mjs";
2
5
  import {
3
6
  LinkList
4
7
  } from "../chunk-BRBGRJ2I.mjs";
@@ -6,9 +9,6 @@ import {
6
9
  OrderedList,
7
10
  UnorderedList
8
11
  } from "../chunk-RY53CJI7.mjs";
9
- import {
10
- DescriptionList
11
- } from "../chunk-3JNHAMRV.mjs";
12
12
  import "../chunk-FUJQIYOF.mjs";
13
13
  export {
14
14
  DescriptionList,
@@ -1,9 +1,12 @@
1
1
  import * as react from 'react';
2
- import { ModalProps, ModalHeader } from './modal.mjs';
2
+ import { ModalProps, ModalHeader, ModalContent, ModalFooter } from './modal.mjs';
3
+ export { useScrollLock } from './modal.mjs';
3
4
  import '../utils-BfZsjuFH.mjs';
4
5
 
5
6
  declare const ModalComponent: react.ForwardRefExoticComponent<ModalProps & react.RefAttributes<HTMLDialogElement>> & {
6
7
  Header: typeof ModalHeader;
8
+ Content: typeof ModalContent;
9
+ Footer: typeof ModalFooter;
7
10
  };
8
11
 
9
- export { ModalComponent as Modal, ModalHeader, ModalProps };
12
+ export { ModalComponent as Modal, ModalContent, ModalFooter, ModalHeader, ModalProps };
@@ -1,9 +1,12 @@
1
1
  import * as react from 'react';
2
- import { ModalProps, ModalHeader } from './modal.js';
2
+ import { ModalProps, ModalHeader, ModalContent, ModalFooter } from './modal.js';
3
+ export { useScrollLock } from './modal.js';
3
4
  import '../utils-BfZsjuFH.js';
4
5
 
5
6
  declare const ModalComponent: react.ForwardRefExoticComponent<ModalProps & react.RefAttributes<HTMLDialogElement>> & {
6
7
  Header: typeof ModalHeader;
8
+ Content: typeof ModalContent;
9
+ Footer: typeof ModalFooter;
7
10
  };
8
11
 
9
- export { ModalComponent as Modal, ModalHeader, ModalProps };
12
+ export { ModalComponent as Modal, ModalContent, ModalFooter, ModalHeader, ModalProps };
@@ -168,21 +168,38 @@ function useMergeRefs(refs) {
168
168
  var import_jsx_runtime2 = require("react/jsx-runtime");
169
169
  var Modal = (0, import_react3.forwardRef)(
170
170
  (_a, ref) => {
171
- var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
171
+ var _b = _a, { children, className, open, closeOnBackdropClick, onClick } = _b, rest = __objRest(_b, ["children", "className", "open", "closeOnBackdropClick", "onClick"]);
172
172
  const modalRef = (0, import_react3.useRef)(null);
173
173
  const mergedRef = useMergeRefs([modalRef, ref]);
174
- function onClose() {
174
+ function onCloseButtonClick() {
175
175
  var _a2;
176
176
  (_a2 = modalRef.current) == null ? void 0 : _a2.close();
177
177
  return false;
178
178
  }
179
+ useScrollLock(modalRef, "hds-modal-scroll-lock");
180
+ (0, import_react3.useEffect)(() => {
181
+ if (modalRef.current && open !== void 0) {
182
+ if (open && !modalRef.current.open) {
183
+ modalRef.current.showModal();
184
+ } else if (!open && modalRef.current.open) {
185
+ modalRef.current.close();
186
+ }
187
+ }
188
+ }, [modalRef, open]);
189
+ function onDialogClick(e) {
190
+ if (closeOnBackdropClick && e.target === modalRef.current) {
191
+ modalRef.current.close();
192
+ }
193
+ onClick == null ? void 0 : onClick(e);
194
+ }
179
195
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
180
196
  Box,
181
197
  __spreadProps(__spreadValues({
182
198
  as: "dialog",
183
199
  className: (0, import_typed_classname2.clsx)("hds-modal", className),
184
200
  closeable: true,
185
- onClose,
201
+ onClick: onDialogClick,
202
+ onClose: onCloseButtonClick,
186
203
  ref: mergedRef,
187
204
  variant: "white"
188
205
  }, rest), {
@@ -205,10 +222,61 @@ var ModalHeader = (0, import_react3.forwardRef)(
205
222
  }
206
223
  );
207
224
  ModalHeader.displayName = "Modal.Header";
225
+ var ModalContent = (0, import_react3.forwardRef)(
226
+ (_a, ref) => {
227
+ var _b = _a, { as: Component = "div", className } = _b, rest = __objRest(_b, ["as", "className"]);
228
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
229
+ Component,
230
+ __spreadValues({
231
+ className: (0, import_typed_classname2.clsx)("hds-modal__content", className),
232
+ ref
233
+ }, rest)
234
+ );
235
+ }
236
+ );
237
+ ModalContent.displayName = "Modal.Content";
238
+ var ModalFooter = (0, import_react3.forwardRef)(
239
+ (_a, ref) => {
240
+ var _b = _a, { as: Component = "footer", className } = _b, rest = __objRest(_b, ["as", "className"]);
241
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
242
+ Component,
243
+ __spreadValues({
244
+ className: (0, import_typed_classname2.clsx)("hds-modal__footer", className),
245
+ ref
246
+ }, rest)
247
+ );
248
+ }
249
+ );
250
+ ModalFooter.displayName = "Modal.Footer";
251
+ function useScrollLock(modalRef, bodyClass) {
252
+ (0, import_react3.useEffect)(() => {
253
+ if (!modalRef.current)
254
+ return;
255
+ if (modalRef.current.open)
256
+ document.body.classList.add(bodyClass);
257
+ const observer = new MutationObserver(() => {
258
+ var _a;
259
+ if ((_a = modalRef.current) == null ? void 0 : _a.open)
260
+ document.body.classList.add(bodyClass);
261
+ else
262
+ document.body.classList.remove(bodyClass);
263
+ });
264
+ observer.observe(modalRef.current, {
265
+ attributes: true,
266
+ attributeFilter: ["open"]
267
+ });
268
+ return () => {
269
+ observer.disconnect();
270
+ document.body.classList.remove(bodyClass);
271
+ };
272
+ }, [bodyClass, modalRef]);
273
+ }
208
274
 
209
275
  // src/modal/index.tsx
210
276
  var ModalComponent = Modal;
211
277
  ModalComponent.Header = ModalHeader;
278
+ ModalComponent.Content = ModalContent;
279
+ ModalComponent.Footer = ModalFooter;
212
280
  // Annotate the CommonJS export names for ESM import in node:
213
281
  0 && (module.exports = {
214
282
  Modal
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ModalComponent
3
- } from "../chunk-2QZF65FK.mjs";
4
- import "../chunk-OB6UNSKV.mjs";
3
+ } from "../chunk-6IJTNHP4.mjs";
4
+ import "../chunk-N5VPBR6T.mjs";
5
5
  import "../chunk-FSBY3NKV.mjs";
6
6
  import "../chunk-WTMT5WCJ.mjs";
7
7
  import "../chunk-FUJQIYOF.mjs";
@@ -3,11 +3,29 @@ import { O as OverridableComponent } from '../utils-BfZsjuFH.mjs';
3
3
 
4
4
  interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {
5
5
  children: React.ReactNode;
6
+ /**
7
+ * Controls the open state of the modal
8
+ */
9
+ open?: boolean;
10
+ /**
11
+ * Whether to close when clicking on the backdrop.
12
+ */
13
+ closeOnBackdropClick?: boolean;
6
14
  }
7
15
  /**
8
16
  * # 🚨 WORK IN PROGRESS 🚨
17
+ *
18
+ * ## TODO
19
+ *
20
+ * - [ ] polyfill the dialog element for the %0.2 users that don't have it yet.
21
+ * - [x] Open the modal where there user is, not top of the page
22
+ * - [x] Support the `open` prop
23
+ * - [x] Support click outside to close
9
24
  */
10
25
  declare const Modal: react.ForwardRefExoticComponent<ModalProps & react.RefAttributes<HTMLDialogElement>>;
11
- declare const ModalHeader: OverridableComponent<object, HTMLParagraphElement>;
26
+ declare const ModalHeader: OverridableComponent<object, HTMLHeadingElement>;
27
+ declare const ModalContent: OverridableComponent<object, HTMLDivElement>;
28
+ declare const ModalFooter: OverridableComponent<object, HTMLDivElement>;
29
+ declare function useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string): void;
12
30
 
13
- export { Modal, ModalHeader, type ModalProps };
31
+ export { Modal, ModalContent, ModalFooter, ModalHeader, type ModalProps, useScrollLock };
@@ -3,11 +3,29 @@ import { O as OverridableComponent } from '../utils-BfZsjuFH.js';
3
3
 
4
4
  interface ModalProps extends React.HTMLAttributes<HTMLDialogElement> {
5
5
  children: React.ReactNode;
6
+ /**
7
+ * Controls the open state of the modal
8
+ */
9
+ open?: boolean;
10
+ /**
11
+ * Whether to close when clicking on the backdrop.
12
+ */
13
+ closeOnBackdropClick?: boolean;
6
14
  }
7
15
  /**
8
16
  * # 🚨 WORK IN PROGRESS 🚨
17
+ *
18
+ * ## TODO
19
+ *
20
+ * - [ ] polyfill the dialog element for the %0.2 users that don't have it yet.
21
+ * - [x] Open the modal where there user is, not top of the page
22
+ * - [x] Support the `open` prop
23
+ * - [x] Support click outside to close
9
24
  */
10
25
  declare const Modal: react.ForwardRefExoticComponent<ModalProps & react.RefAttributes<HTMLDialogElement>>;
11
- declare const ModalHeader: OverridableComponent<object, HTMLParagraphElement>;
26
+ declare const ModalHeader: OverridableComponent<object, HTMLHeadingElement>;
27
+ declare const ModalContent: OverridableComponent<object, HTMLDivElement>;
28
+ declare const ModalFooter: OverridableComponent<object, HTMLDivElement>;
29
+ declare function useScrollLock(modalRef: React.RefObject<HTMLDialogElement>, bodyClass: string): void;
12
30
 
13
- export { Modal, ModalHeader, type ModalProps };
31
+ export { Modal, ModalContent, ModalFooter, ModalHeader, type ModalProps, useScrollLock };
@@ -60,7 +60,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
60
60
  var modal_exports = {};
61
61
  __export(modal_exports, {
62
62
  Modal: () => Modal,
63
- ModalHeader: () => ModalHeader
63
+ ModalContent: () => ModalContent,
64
+ ModalFooter: () => ModalFooter,
65
+ ModalHeader: () => ModalHeader,
66
+ useScrollLock: () => useScrollLock
64
67
  });
65
68
  module.exports = __toCommonJS(modal_exports);
66
69
  var import_react3 = require("react");
@@ -162,21 +165,38 @@ function useMergeRefs(refs) {
162
165
  var import_jsx_runtime2 = require("react/jsx-runtime");
163
166
  var Modal = (0, import_react3.forwardRef)(
164
167
  (_a, ref) => {
165
- var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
168
+ var _b = _a, { children, className, open, closeOnBackdropClick, onClick } = _b, rest = __objRest(_b, ["children", "className", "open", "closeOnBackdropClick", "onClick"]);
166
169
  const modalRef = (0, import_react3.useRef)(null);
167
170
  const mergedRef = useMergeRefs([modalRef, ref]);
168
- function onClose() {
171
+ function onCloseButtonClick() {
169
172
  var _a2;
170
173
  (_a2 = modalRef.current) == null ? void 0 : _a2.close();
171
174
  return false;
172
175
  }
176
+ useScrollLock(modalRef, "hds-modal-scroll-lock");
177
+ (0, import_react3.useEffect)(() => {
178
+ if (modalRef.current && open !== void 0) {
179
+ if (open && !modalRef.current.open) {
180
+ modalRef.current.showModal();
181
+ } else if (!open && modalRef.current.open) {
182
+ modalRef.current.close();
183
+ }
184
+ }
185
+ }, [modalRef, open]);
186
+ function onDialogClick(e) {
187
+ if (closeOnBackdropClick && e.target === modalRef.current) {
188
+ modalRef.current.close();
189
+ }
190
+ onClick == null ? void 0 : onClick(e);
191
+ }
173
192
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
174
193
  Box,
175
194
  __spreadProps(__spreadValues({
176
195
  as: "dialog",
177
196
  className: (0, import_typed_classname2.clsx)("hds-modal", className),
178
197
  closeable: true,
179
- onClose,
198
+ onClick: onDialogClick,
199
+ onClose: onCloseButtonClick,
180
200
  ref: mergedRef,
181
201
  variant: "white"
182
202
  }, rest), {
@@ -199,8 +219,60 @@ var ModalHeader = (0, import_react3.forwardRef)(
199
219
  }
200
220
  );
201
221
  ModalHeader.displayName = "Modal.Header";
222
+ var ModalContent = (0, import_react3.forwardRef)(
223
+ (_a, ref) => {
224
+ var _b = _a, { as: Component = "div", className } = _b, rest = __objRest(_b, ["as", "className"]);
225
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
226
+ Component,
227
+ __spreadValues({
228
+ className: (0, import_typed_classname2.clsx)("hds-modal__content", className),
229
+ ref
230
+ }, rest)
231
+ );
232
+ }
233
+ );
234
+ ModalContent.displayName = "Modal.Content";
235
+ var ModalFooter = (0, import_react3.forwardRef)(
236
+ (_a, ref) => {
237
+ var _b = _a, { as: Component = "footer", className } = _b, rest = __objRest(_b, ["as", "className"]);
238
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
239
+ Component,
240
+ __spreadValues({
241
+ className: (0, import_typed_classname2.clsx)("hds-modal__footer", className),
242
+ ref
243
+ }, rest)
244
+ );
245
+ }
246
+ );
247
+ ModalFooter.displayName = "Modal.Footer";
248
+ function useScrollLock(modalRef, bodyClass) {
249
+ (0, import_react3.useEffect)(() => {
250
+ if (!modalRef.current)
251
+ return;
252
+ if (modalRef.current.open)
253
+ document.body.classList.add(bodyClass);
254
+ const observer = new MutationObserver(() => {
255
+ var _a;
256
+ if ((_a = modalRef.current) == null ? void 0 : _a.open)
257
+ document.body.classList.add(bodyClass);
258
+ else
259
+ document.body.classList.remove(bodyClass);
260
+ });
261
+ observer.observe(modalRef.current, {
262
+ attributes: true,
263
+ attributeFilter: ["open"]
264
+ });
265
+ return () => {
266
+ observer.disconnect();
267
+ document.body.classList.remove(bodyClass);
268
+ };
269
+ }, [bodyClass, modalRef]);
270
+ }
202
271
  // Annotate the CommonJS export names for ESM import in node:
203
272
  0 && (module.exports = {
204
273
  Modal,
205
- ModalHeader
274
+ ModalContent,
275
+ ModalFooter,
276
+ ModalHeader,
277
+ useScrollLock
206
278
  });
@@ -1,11 +1,17 @@
1
1
  import {
2
2
  Modal,
3
- ModalHeader
4
- } from "../chunk-OB6UNSKV.mjs";
3
+ ModalContent,
4
+ ModalFooter,
5
+ ModalHeader,
6
+ useScrollLock
7
+ } from "../chunk-N5VPBR6T.mjs";
5
8
  import "../chunk-FSBY3NKV.mjs";
6
9
  import "../chunk-WTMT5WCJ.mjs";
7
10
  import "../chunk-FUJQIYOF.mjs";
8
11
  export {
9
12
  Modal,
10
- ModalHeader
13
+ ModalContent,
14
+ ModalFooter,
15
+ ModalHeader,
16
+ useScrollLock
11
17
  };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  TabsComponent
3
- } from "../chunk-WUMZCEIJ.mjs";
4
- import "../chunk-ZLCNSHLT.mjs";
3
+ } from "../chunk-BSX4IA3X.mjs";
5
4
  import "../chunk-GRO36EUL.mjs";
6
5
  import "../chunk-G3JPULGO.mjs";
6
+ import "../chunk-ZLCNSHLT.mjs";
7
7
  import "../chunk-4ZM45P62.mjs";
8
8
  import "../chunk-FSBY3NKV.mjs";
9
9
  import "../chunk-FUJQIYOF.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postenbring/hedwig-react",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "hedwig-tsconfig": "0.0.0"
20
20
  },
21
21
  "dependencies": {
22
- "@postenbring/hedwig-css": "0.0.40"
22
+ "@postenbring/hedwig-css": "0.0.41"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
@@ -1,60 +0,0 @@
1
- import {
2
- useMergeRefs
3
- } from "./chunk-FSBY3NKV.mjs";
4
- import {
5
- Box
6
- } from "./chunk-WTMT5WCJ.mjs";
7
- import {
8
- __objRest,
9
- __spreadProps,
10
- __spreadValues
11
- } from "./chunk-FUJQIYOF.mjs";
12
-
13
- // src/modal/modal.tsx
14
- import { forwardRef, useRef } from "react";
15
- import { clsx } from "@postenbring/hedwig-css/typed-classname/index.mjs";
16
- import { jsx } from "react/jsx-runtime";
17
- var Modal = forwardRef(
18
- (_a, ref) => {
19
- var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
20
- const modalRef = useRef(null);
21
- const mergedRef = useMergeRefs([modalRef, ref]);
22
- function onClose() {
23
- var _a2;
24
- (_a2 = modalRef.current) == null ? void 0 : _a2.close();
25
- return false;
26
- }
27
- return /* @__PURE__ */ jsx(
28
- Box,
29
- __spreadProps(__spreadValues({
30
- as: "dialog",
31
- className: clsx("hds-modal", className),
32
- closeable: true,
33
- onClose,
34
- ref: mergedRef,
35
- variant: "white"
36
- }, rest), {
37
- children
38
- })
39
- );
40
- }
41
- );
42
- Modal.displayName = "Modal";
43
- var ModalHeader = forwardRef(
44
- (_a, ref) => {
45
- var _b = _a, { as: Component = "h1", className } = _b, rest = __objRest(_b, ["as", "className"]);
46
- return /* @__PURE__ */ jsx(
47
- Component,
48
- __spreadValues({
49
- className: clsx("hds-modal__header", className),
50
- ref
51
- }, rest)
52
- );
53
- }
54
- );
55
- ModalHeader.displayName = "Modal.Header";
56
-
57
- export {
58
- Modal,
59
- ModalHeader
60
- };
@@ -1,10 +0,0 @@
1
- import "../chunk-PF6PZIZS.mjs";
2
- import {
3
- Input
4
- } from "../chunk-6KVF3ELJ.mjs";
5
- import "../chunk-45BJGKVZ.mjs";
6
- import "../chunk-QAYPCD5Z.mjs";
7
- import "../chunk-FUJQIYOF.mjs";
8
- export {
9
- Input
10
- };
@@ -1,9 +0,0 @@
1
- import {
2
- Input
3
- } from "../chunk-6KVF3ELJ.mjs";
4
- import "../chunk-45BJGKVZ.mjs";
5
- import "../chunk-QAYPCD5Z.mjs";
6
- import "../chunk-FUJQIYOF.mjs";
7
- export {
8
- Input
9
- };
@@ -1,2 +0,0 @@
1
- export { InputGroup, InputGroupProps, InputProps } from './input-group.mjs';
2
- import 'react';
@@ -1,2 +0,0 @@
1
- export { InputGroup, InputGroupProps, InputProps } from './input-group.js';
2
- import 'react';
@@ -1,8 +0,0 @@
1
- import "../chunk-45BJGKVZ.mjs";
2
- import {
3
- InputGroup
4
- } from "../chunk-QAYPCD5Z.mjs";
5
- import "../chunk-FUJQIYOF.mjs";
6
- export {
7
- InputGroup
8
- };
@@ -1,7 +0,0 @@
1
- import {
2
- InputGroup
3
- } from "../chunk-QAYPCD5Z.mjs";
4
- import "../chunk-FUJQIYOF.mjs";
5
- export {
6
- InputGroup
7
- };
@@ -1,10 +0,0 @@
1
- import "../chunk-SX37JSDS.mjs";
2
- import {
3
- Select
4
- } from "../chunk-K3BGDNWO.mjs";
5
- import "../chunk-45BJGKVZ.mjs";
6
- import "../chunk-QAYPCD5Z.mjs";
7
- import "../chunk-FUJQIYOF.mjs";
8
- export {
9
- Select
10
- };